'How to integrate non-nodejs browser based javascript/html app into offline angular electron app?
I have an offline angular electron desktop app and I'm trying to connect an open source nesting tool to it but I can't seem to get it working. The nesting tool is non-nodejs browser based app that uses JS/html and is run by using "http-server" command while in its directory.
Link to Nesting Tool: https://github.com/Jack000/SVGnest
Note:
- The project must be working while not connected to the internet
- Utility modules in the nesting tool are imported via the html file with
We tried integrating this in two ways:
- The first approach was to just try to import all the javascript files into our angular project and change the syntax a bit so it would work with angular. I.E adding export, import, and require to add all the modules and files. This worked for the main svgnest.js but failed when going deeper into the functions of the util modules. More specifically the parallel.js, workers, and eval.js files are giving me trouble and parallel would fail when I attempt to use the .require function. It would either error out saying it cant find a specific path "localhost:4200/[path to module]" or say it cannot use importScript for the specific path.
"Uncaught SyntaxError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The URL 'matrix.js' is invalid."
or "GET http://localhost:4200/util/eval.js 404 (Not Found)"
- The second approach was using an iframe in the electron desktop app that links to the JS/Html http-server. This allowed us to see the nesting features inside our desktop app but we realized that we couldn't communicate with the document or it's functions. I believe this was because they have to run on different ports and it says the origins are different.
"ERROR DOMException: Blocked a frame with origin "http://localhost:4200" from accessing a cross-origin frame."
Is there any ways to solve these issues and if not what other approaches should I try to make this integration work?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
