Sandify Local Install

Before I enter npm hell, can someone tell me what the minimum version(s) of node I will need to run sandify locally? I want to put it on a box running CENTOS 7 and I don’t want to upgrade it. I believe it can support node v16.0.0. I know it can’t run v18 and later.

Got impatient and opened the gate…

Used node v 16.4.0

npm install went fine. No errors. 2 severity vulnerabilities…

npm audit fix … changed 2 packages. No errors.

npm start … No errors… VITE v4.5.2 server URL http://127.0.0.1:3000

Opened with browser… Blank screen, Infinite page loading…

Opened a second browser window to same
Received the following:

Sorry! Something went wrong.

visibleEffects.findLast is not a function

And, my record for linux apps that failed to work on the first try is still … 100% :rofl:

Any ideas?

Cheers

1 Like

Never mind. I realized that the problem was with the browser - I was testing it with an old version of Firefox.

Doh!

It should be pretty agnostic to browser type. I do sometimes get a blank screen on my test setup, but I haven’t seen anyone else, so I assumed it was something to do with my local storage, which gets cluttered as a dev.

There is a docker compose file inside. I run it like that so other nom/node versions don’t fight with it. I always forget the commands, so I pasted them in the docker compose file. You will need a recentish version of docker and docker compose (if your version of docker is old enough to not include compose).

Thanks. I finally got it working. It also took me a little while to figure out how to expose it outside the localhost machine.

vite gives a nice clear message on startup: use --host to expose

except

npm run --hosts

doesn’t work, but

npm run – --host

works. :angry:

oh - and I did notice a blank screen once on startup, so it’s not just your machine.

1 Like

Jeff,

Was hoping you could give me some advice before I head down a rabbit hole that has no bottom. I am writing a web app that is basically an extension of the fluidnc WebUI. It makes it easy to choose the work coordinates, a tool, transfer a gCode file, run it, then delete the file all with one or two taps on a tablet. I was also in the process of incorporating features that create gCode on the fly from text, svg and mathematical patterns. I stumbled upon Sandify and it occurred to me that Sandify does much of what I was starting to write. So I thought if I could incorporate sandify info the app, I could save a bunch of time. The problem is, my app is mostly javascript with a java backend that crunches font curves and such, and I have no experience with node.js and react so my learning curve may be a bit steep.

So, I was wondering if you think that is an easy thing or is it complicated? I am not asking you to do this, only if you think it is doable. I could probably get away with adding a few features like the ability to input arguments (like those in an .sdf file) via a GET or POST and have the app return a page with gcode, maybe an image of the preview window, etc. Not really anything new, but, for instance, returning the gcode in a web page response instead of having to download it in a file and setting the sdf parameters without needing to upload a file. Hopefully easy stuff once I figure out the structure of react??

Any thoughts on this?

Sandify uses react just for the UI. The core code is mostly written as libraries and the glue that calls the functions based on what is happening in react is redux. Filling the redux state and then calling the main vertex calculate function would return the vertices from the pattern without dealing with a UI.

It also always has the constraint of never lifting a pen. Most plotters and CNCs don’t have that constraint. Sandify is self limiting that way. So just adopting the majority of it probably won’t make sense.

The algorithms or math or library code that is useful might be:

  • The rectangular and polar limits. This actually took a lot of work to get right.
  • The font to vertices code. I started with a simple thing and Bob made the fancy text.
  • The effects, if you’re into that kind of thing. Specifically the transform but any of them should be quick to extract.

What I don’t see working easily is to just keep sandify intact and trying to call it like an api. I doubt it will be useable that way and any future updates will immediately break it. It is 100% JavaScript and runs client side. Node/npm is just how we manay the dependencies and “build” it for testing or production.

Here is an example. This is where the limits are enforced for rectangles. This code is called in Machine.js:

This where the fancy text is turned into vertices:

But I’m not an expert in this either. You may see a bridge to success that I can’t. So don’t let me discourage you.

Hmmm. It wasn’t occurring to me that there is no server side once sandify is loaded. I guess that should have been obvious since that is what node.js actually does. Right?

Anyways, it may be fairly simple then. I’d have to add some handlers in sandify that expose the functions that set parameters and generate vertices, so it would have to be a local instance with some additional scripts. Then just load the modded sandify into an iframe on the same web page as the rest of my app. Then call the handlers from my app. There is a Cross Origin barrier there, since my app and sandify will originate from different ports on the server, but I believe there is an API that can get around that. The z-axis stuff isn’t a big deal for my application, but if I wanted to add a feature to change pens mid drawing, inserting something into the gcode to enable that shouldn’t be too difficult.

I think that might work. :thinking:

Thanks again for your time.

If you’re running javascript already, you can just copy the files into your project and reuse them, can’t you?

Well, I wanted to keep your UI intact and I thought there was some magic happening in node.js, but if it is as simple as including all the sandify javascript files in a web page and somehow sticking the UI inside a div tag, then I guess that is the way to go. Is it really that simple?

So then the questions are -

  1. What is the best way to package all the javascript files?
  2. What other files/libraries are needed? React, redux …
  3. What is the code to display the app inside a div? Do I need vite?

Well, I’m not really a JavaScript expert. My cup o tea is C++. So I’m not sure.

The top level “App” tag is delivered by javascript, and it is here:

That is created by the JavaScript in index.js in src.

This is JS. So there are a lot of dependencies:

Vite is only in the dev dependencies. It isn’t needed for deployment. If you do something like npm build it will do the deployment to a local folder. You can see what it does. It moves all the dependencies to CDN values, it combines all the code to one or two pages and minifies them (which makes them annoying to read, but improves loading times).

Honestly, this stuff is all at the edge of my understanding. I started with some help from James and made an example react bootstrap app. I filled in some things and Bob and I have refactored it several times since then. I could maybe fumble through it with some stack overflowing to push it together, but I couldn’t describe the right steps.

I feel that everything these days is at the edge of my understanding. :rofl: :rofl:

I’m just an old guy with a engineer’s brain and a little bit of coding experience that can usually figure things out with enough time and a little help from Google and ChatGPT. Your Sandify project is really amazing. I can’t emphasize that enough. I really appreciate the time spent on the code development and I’m sure all the ZenXY builders do as well. I spent hours today looking at the different sand table builds. I think there is definitely one in my future.

1 Like