hrgdavor / jscadui

MIT License
30 stars 7 forks source link

gzip in data: uri #80

Closed hrgdavor closed 7 months ago

hrgdavor commented 7 months ago

fixes: #76

here is a sample gzipped script: data:application/gzip;base64,H4sICN1FqGUAA3Rlc3QADcrBDkAwDADQu6/YjV3GxUUi8SuLFRXrpl1FIv6dd34xBT3AwZ0TFxkXpblgIhM9UmMfhqJMhuFUZGjqaZfZhzamAAfSWluXGSMWvECc5A3+9LAPqDKYvnvtW33S8ZutYgAAAA==

for script:

module.exports=function main(){return require('@jscad/modeling').primitives.sphere({radius: 50})}

@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==

Hermann-SW commented 7 months ago

@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==

@hrgdavor Thank you, works nicely with bigger scripts, with this bash script:

pi@raspberrypi5:~/JSCAD $ cat doit2.b2 
#!/bin/bash
browser=firefox
browser=chromium-browser

$browser "3d.hrg.hr/jscad/app1/#data:application/gzip;base64,`gzip -c $1 | base64 -w 0`"
pi@raspberrypi5:~/JSCAD $ 

I started

./doit2.b2 C36_10.correct.jscad

with 23891 bytes length script. The complete URL length is only 6547 bytes! 6547 bytes length URL to test (you might want to select 6coloring for face coloring, and set look_inside to yes and rotate the sphere for inside view)

Thanks to you and your colleagues for such quick resolutions and implementation of new feature!

Hermann-SW commented 7 months ago

@hrgdavor Hi, the "6547 bytes length URL to test" link above does not work anymore. Can you please reenable https://3d.hrg.hr/jscad/app1/#data:application/gzip;base64,... feature?

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. gzip+base64 should work for my new GP3D generated demo model, that is accessible as gist as well since last night: https://jscad.app/#https://gist.githubusercontent.com/Hermann-SW/b3e85c8fe6827cd29238c14f9da346be/raw/C36.10.fixed.jscad.good_enough.jscad

hrgdavor commented 7 months ago

@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, https://3d.hrg.hr/jscad/app-gzip/#data:application/gzip;base64,H4sICN1FqGUAA3Rlc3QADcrBDkAwDADQu6/YjV3GxUUi8SuLFRXrpl1FIv6dd34xBT3AwZ0TFxkXpblgIhM9UmMfhqJMhuFUZGjqaZfZhzamAAfSWluXGSMWvECc5A3+9LAPqDKYvnvtW33S8ZutYgAAAA==

but after it is on official jscad.app it will ikely be removed to declutter my hosting folder

Hermann-SW commented 7 months ago

@hrgdavor THANK you, I see that "app1" server became "app-gzip". I updated the tool in my repo: https://github.com/Hermann-SW/GP3D/blob/main/tools/view_gzb64 I will update again to jscad.app when it works there.

tools/view_b64 app-gzip.jscad fails because of 32KB URL restriction for my newest model. But changed tool does work !

pi@raspberrypi5:~/GP3D $ tools/view_gzb64 app-gzip.jscad
Opening in existing browser session.
pi@raspberrypi5:~/GP3D $ 

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).

hrgdavor commented 7 months ago

@Hermann-SW data url gzip and uncompressed are now live on jscad.app , check browser cache if not working

https://jscad.app/#data:application/gzip;base64,H4sICN1FqGUAA3Rlc3QADcrBDkAwDADQu6/YjV3GxUUi8SuLFRXrpl1FIv6dd34xBT3AwZ0TFxkXpblgIhM9UmMfhqJMhuFUZGjqaZfZhzamAAfSWluXGSMWvECc5A3+9LAPqDKYvnvtW33S8ZutYgAAAA==

Hermann-SW commented 7 months ago

@hrgdavor https://stamm-wilbrandt.de/cgi-bin/echo-e.to.braille.pl?i=Thank+you+%21

$ echo -e 'Thank you !' | pbmtext -builtin fixed | pnmcrop | pbmtobraille
⡖⢲⠒⡎⡇⣀⠀⢀⣀⡀⢀⢀⣀⠀⢹⠀⣀⠀⠀⠀⠀⣀⡀⣀⡀⢀⣀⠀⣀⠀⣀⠀⠀⠀⠀⠀⢸
⠀⢸⠀⠀⡏⠀⡇⢠⠒⢺⠀⡏⠀⡇⢸⠪⡀⠀⠀⠀⠀⠘⣄⡜⠀⡇⠀⡇⢸⠀⢸⠀⠀⠀⠀⠀⠸
⠈⠉⠉⠈⠉⠈⠉⠀⠉⠁⠉⠉⠀⠉⠉⠀⠈⠁⠀⠀⠀⢀⡸⠀⠀⠈⠉⠀⠀⠉⠁⠁⠀⠀⠀⠀⠈
$ 

I just updated GP3D tool to target jscad.app now: https://github.com/Hermann-SW/GP3D/blob/main/tools/view_gzb64

I created below link with that tool:

pi@raspberrypi5:~/GP3D $ tools/view_gzb64 gp.jscad
Opening in existing browser session.
pi@raspberrypi5:~/GP3D $

6552 bytes base64(gzip(jscad)) data URL — works like a charm ... https://stamm-wilbrandt.de/images/JSCAD.half_vertex.png