-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: openjscad.xyz/?uri= support for "data" scheme in addition to "http(s)" #1318
Comments
@z3dev if I remember correctly you are like me not so keen fixing opejscad web ui. https://github.com/hrgdavor/jscadui/tree/main/apps/jscad-web also the multifile scripts with import like this jscad example: https://jscad.app/#https://raw.githubusercontent.com/jscad/OpenJSCAD.org/master/packages/examples/import/STLImport/index.js there is also support for new input type=file so script like this can allow uploading custom stl to work on remote file download is first attempted from browser directly, and if CORS headers are not ok, it falls back to remote serverside proxy |
I take what works.
Nice.
Good. I tested jscad.app and it seems to even load same model a bit faster than openjscad.xyz. jscad.app problems:
|
@Hermann-SW and direct url from my browser returns the simple sphere script could be some kind of caching issue ? did you have a different script on that url ? |
@Hermann-SW also here is excerpt from jscadui app about CORS. this can benefit you also if hosting jascad, as you can then load external scripts without making a proxy script using url to load external script and CORSIf you want to share a script from your website you should setup CORS, and make sure to use HTTPS! if you do not setup CORS jscad.app can fallback to For hostings (that are uaually cheap and abundant) on CPanel adding .htaccess to your folder should work.
If you are using github you should be fine, as gists and github pages have those CORS headers. |
@hrgdavor It should look like this:
Copy that script into jscad.app and press SHIFT+ENTER, that gives bottom message:
Why does that script work with openjscad.xyz, and does not work with jscad.app? |
@hrgdavor
The URL length jscad.app allows for is bigger than the 8KB of openjscad.xyz, I have not tested how big it is. In order to use data link for bigger scripts as well I would like to use this script:
It creates the gzipped script in jscad.app editor, with many unreadable characters. |
@Hermann-SW browsers only support gzip at transport level, not in data url https://stackoverflow.com/questions/28793110/img-src-data-with-gzipped-file since I use fflate for 3mf, this additional option to unzip the script could be implemented without too much trouble regarding the script not working, it lloks like openjscad allows for default export to be the main function as well as object with also I am available on discord cadhub/jscad channel |
Expected Behavior
Providing a "data" scheme would work the same as providing "http" scheme uri.
I tried with below script, that opens $browser with "...?uri=data:text/plain;base64,..." for passed input file.
But it does not work because of missing "data" scheme support.
Actual Behavior
Fails to open script passed via "data" scheme.
Steps to Reproduce the Problem
Specifications
Biggest gain of "data" scheme support would be being able to share link without having to store script on a publically accessible webserver first.
I have implemented similar concept in my GraphvizFiddle, "Share" button creates a long URL containing configuration that can be shared, here an example:
https://stamm-wilbrandt.de/GraphvizFiddle/?1705330894960#digraph%20G%20%7Brankdir%3DLR%3B%20JS-%3ECAD%7D%0A
I am aware of the 8KB URL length limit of openjscad.xyz, but "data:text/plain;base64," would allow for up to 6KB length scripts. "data:application/gzip;base64," would allow for much larger scripts, with their gziped size limited by 6KB.
P.S:
In case "data" scheme will be added, a script like below would be nice to have in the repo, for direct use (eg. under OpenJSCAD.org/packages/examples):
The text was updated successfully, but these errors were encountered: