-
Notifications
You must be signed in to change notification settings - Fork 9
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
gzip in data: uri #80
Conversation
@hrgdavor Thank you, works nicely with bigger scripts, with this bash script:
I started
with 23891 bytes length script. The complete URL length is only 6547 bytes! Thanks to you and your colleagues for such quick resolutions and implementation of new feature! |
@hrgdavor I need that to test whether that feature allows to extend the jscad.app URL length restriction. I tested, and if base64 encoded data URL (without gzip) is >32KB, it does not work on jscad.app. |
@Hermann-SW the PR is not yet merged nad the mentioned url is just experimental page use to share with ppl before it is available on jscad.app. here is a link taht will live longer for that PR only, but after it is on official jscad.app it will ikely be removed to declutter my hosting folder |
@hrgdavor tools/view_b64 app-gzip.jscad fails because of 32KB URL restriction for my newest model.
You can open the 6655 bytes data url and see latest new features generated with PARI/GP script (look_inside enabled, theta angles as vertex labels, vertices not on seperating circle drawn as half spheres, 6coloring chosen as face coloring). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to work. My only comments would be:
- I hate adding dependencies.
- fflate looks very compact, and provides real value, cool
- base64-arraybuffer seems unnecessary, as it could be done using native apis only.
- these dependencies are not big so I don't it too be too much of a problem, but also I think it will be rare that people use this code path. Would it make sense to split out the gzip decoding as a bundle and only load it if needed?
I tested this alternative and it appears to work fine, without the base64-arraybuffer dependency:
/**
* Converts a Base64 encoded string to an ArrayBuffer.
* @param {string} base64 - base64 encoded string
* @returns {ArrayBuffer} output ArrayBuffer
*/
const base64ToArrayBuffer = (base64) => {
return Uint8Array.from(atob(base64), c => c.charCodeAt(0)).buffer
}
@Hermann-SW data url gzip and uncompressed are now live on jscad.app , check browser cache if not working |
@hrgdavor
I just updated GP3D tool to target jscad.app now: I created below link with that tool:
6552 bytes base64(gzip(jscad)) data URL — works like a charm ... |
fixes: #76
here is a sample gzipped script:
data:application/gzip;base64,H4sICN1FqGUAA3Rlc3QADcrBDkAwDADQu6/YjV3GxUUi8SuLFRXrpl1FIv6dd34xBT3AwZ0TFxkXpblgIhM9UmMfhqJMhuFUZGjqaZfZhzamAAfSWluXGSMWvECc5A3+9LAPqDKYvnvtW33S8ZutYgAAAA==
for script:
@Hermann-SW works temporarily here(you may need to hit ctrl+F5) until merged and published to jscad.app
https://3d.hrg.hr/jscad/app1/#data:application/gzip;base64,H4sICN1FqGUAA3Rlc3QADcrBDkAwDADQu6/YjV3GxUUi8SuLFRXrpl1FIv6dd34xBT3AwZ0TFxkXpblgIhM9UmMfhqJMhuFUZGjqaZfZhzamAAfSWluXGSMWvECc5A3+9LAPqDKYvnvtW33S8ZutYgAAAA==