Fossil SCM
Automatically randomize the names of the "pikchr.js" and "pikchr.wasm" files after "make wasm", to force browser cache reloads.
Commit
369cb383159f68cebc504c126290d36d3c7610f9e956bd03fecfa568137dceb2
Parent
81af7db0a3470cf…
7 files changed
+1
-1
+1
-1
+6
-1
+1
+1
+36
+1
-1
| --- extsrc/pikchr-worker.js | ||
| +++ extsrc/pikchr-worker.js | ||
| @@ -206,11 +206,11 @@ | ||
| 206 | 206 | data:{step: ++f.last.step, text: text||null} |
| 207 | 207 | }); |
| 208 | 208 | } |
| 209 | 209 | }; |
| 210 | 210 | |
| 211 | - importScripts('pikchr-v32459876.js'); | |
| 211 | + importScripts('pikchr-v7583078860.js'); | |
| 212 | 212 | /** |
| 213 | 213 | initPikchrModule() is installed via pikchr.js due to |
| 214 | 214 | building with: |
| 215 | 215 | |
| 216 | 216 | emcc ... -sMODULARIZE=1 -sEXPORT_NAME=initPikchrModule |
| 217 | 217 |
| --- extsrc/pikchr-worker.js | |
| +++ extsrc/pikchr-worker.js | |
| @@ -206,11 +206,11 @@ | |
| 206 | data:{step: ++f.last.step, text: text||null} |
| 207 | }); |
| 208 | } |
| 209 | }; |
| 210 | |
| 211 | importScripts('pikchr-v32459876.js'); |
| 212 | /** |
| 213 | initPikchrModule() is installed via pikchr.js due to |
| 214 | building with: |
| 215 | |
| 216 | emcc ... -sMODULARIZE=1 -sEXPORT_NAME=initPikchrModule |
| 217 |
| --- extsrc/pikchr-worker.js | |
| +++ extsrc/pikchr-worker.js | |
| @@ -206,11 +206,11 @@ | |
| 206 | data:{step: ++f.last.step, text: text||null} |
| 207 | }); |
| 208 | } |
| 209 | }; |
| 210 | |
| 211 | importScripts('pikchr-v7583078860.js'); |
| 212 | /** |
| 213 | initPikchrModule() is installed via pikchr.js due to |
| 214 | building with: |
| 215 | |
| 216 | emcc ... -sMODULARIZE=1 -sEXPORT_NAME=initPikchrModule |
| 217 |
+1
-1
| --- extsrc/pikchr.js | ||
| +++ extsrc/pikchr.js | ||
| @@ -300,11 +300,11 @@ | ||
| 300 | 300 | |
| 301 | 301 | // end include: URIUtils.js |
| 302 | 302 | // include: runtime_exceptions.js |
| 303 | 303 | // end include: runtime_exceptions.js |
| 304 | 304 | function findWasmBinary() { |
| 305 | - var f = "pikchr-v09854133.wasm"; | |
| 305 | + var f = "pikchr-v7583078860.wasm"; | |
| 306 | 306 | if (!isDataURI(f)) { |
| 307 | 307 | return locateFile(f); |
| 308 | 308 | } |
| 309 | 309 | return f; |
| 310 | 310 | } |
| 311 | 311 |
| --- extsrc/pikchr.js | |
| +++ extsrc/pikchr.js | |
| @@ -300,11 +300,11 @@ | |
| 300 | |
| 301 | // end include: URIUtils.js |
| 302 | // include: runtime_exceptions.js |
| 303 | // end include: runtime_exceptions.js |
| 304 | function findWasmBinary() { |
| 305 | var f = "pikchr-v09854133.wasm"; |
| 306 | if (!isDataURI(f)) { |
| 307 | return locateFile(f); |
| 308 | } |
| 309 | return f; |
| 310 | } |
| 311 |
| --- extsrc/pikchr.js | |
| +++ extsrc/pikchr.js | |
| @@ -300,11 +300,11 @@ | |
| 300 | |
| 301 | // end include: URIUtils.js |
| 302 | // include: runtime_exceptions.js |
| 303 | // end include: runtime_exceptions.js |
| 304 | function findWasmBinary() { |
| 305 | var f = "pikchr-v7583078860.wasm"; |
| 306 | if (!isDataURI(f)) { |
| 307 | return locateFile(f); |
| 308 | } |
| 309 | return f; |
| 310 | } |
| 311 |
| --- extsrc/pikchr.wasm | ||
| +++ extsrc/pikchr.wasm | ||
| cannot compute difference between binary files | ||
| 1 | 1 |
| --- extsrc/pikchr.wasm | |
| +++ extsrc/pikchr.wasm | |
| 0 | annot compute difference between binary files |
| 1 |
| --- extsrc/pikchr.wasm | |
| +++ extsrc/pikchr.wasm | |
| 0 | annot compute difference between binary files |
| 1 |
+6
-1
| --- src/fossil.page.pikchrshowasm.js | ||
| +++ src/fossil.page.pikchrshowasm.js | ||
| @@ -120,11 +120,16 @@ | ||
| 120 | 120 | } |
| 121 | 121 | }); |
| 122 | 122 | delete PS._config; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - PS.worker = new Worker('builtin/extsrc/pikchr-worker.js'); | |
| 125 | + /* Randomize the name of the worker script so that it is never cached. | |
| 126 | + ** The Fossil /builtin method will automatically remove the "-v000000000" | |
| 127 | + ** part of the filename, resolving it to just "pikchr-worker.js". */ | |
| 128 | + PS.worker = new Worker('builtin/extsrc/pikchr-worker-v'+ | |
| 129 | + (Math.floor(Math.random()*10000000000) + 1000000000)+ | |
| 130 | + '.js'); | |
| 126 | 131 | PS.worker.onmessage = (ev)=>PS.runMsgHandlers(ev.data); |
| 127 | 132 | PS.addMsgHandler('stdout', console.log.bind(console)); |
| 128 | 133 | PS.addMsgHandler('stderr', console.error.bind(console)); |
| 129 | 134 | |
| 130 | 135 | /** Handles status updates from the Module object. */ |
| 131 | 136 |
| --- src/fossil.page.pikchrshowasm.js | |
| +++ src/fossil.page.pikchrshowasm.js | |
| @@ -120,11 +120,16 @@ | |
| 120 | } |
| 121 | }); |
| 122 | delete PS._config; |
| 123 | } |
| 124 | |
| 125 | PS.worker = new Worker('builtin/extsrc/pikchr-worker.js'); |
| 126 | PS.worker.onmessage = (ev)=>PS.runMsgHandlers(ev.data); |
| 127 | PS.addMsgHandler('stdout', console.log.bind(console)); |
| 128 | PS.addMsgHandler('stderr', console.error.bind(console)); |
| 129 | |
| 130 | /** Handles status updates from the Module object. */ |
| 131 |
| --- src/fossil.page.pikchrshowasm.js | |
| +++ src/fossil.page.pikchrshowasm.js | |
| @@ -120,11 +120,16 @@ | |
| 120 | } |
| 121 | }); |
| 122 | delete PS._config; |
| 123 | } |
| 124 | |
| 125 | /* Randomize the name of the worker script so that it is never cached. |
| 126 | ** The Fossil /builtin method will automatically remove the "-v000000000" |
| 127 | ** part of the filename, resolving it to just "pikchr-worker.js". */ |
| 128 | PS.worker = new Worker('builtin/extsrc/pikchr-worker-v'+ |
| 129 | (Math.floor(Math.random()*10000000000) + 1000000000)+ |
| 130 | '.js'); |
| 131 | PS.worker.onmessage = (ev)=>PS.runMsgHandlers(ev.data); |
| 132 | PS.addMsgHandler('stdout', console.log.bind(console)); |
| 133 | PS.addMsgHandler('stderr', console.error.bind(console)); |
| 134 | |
| 135 | /** Handles status updates from the Module object. */ |
| 136 |
+1
| --- src/main.mk | ||
| +++ src/main.mk | ||
| @@ -2142,10 +2142,11 @@ | ||
| 2142 | 2142 | -sEXPORTED_FUNCTIONS=_pikchr,_pikchr_version $(SRCDIR_extsrc)/pikchr.c \ |
| 2143 | 2143 | -sENVIRONMENT=web \ |
| 2144 | 2144 | -sMODULARIZE \ |
| 2145 | 2145 | -sEXPORT_NAME=initPikchrModule \ |
| 2146 | 2146 | --minify 0 |
| 2147 | + $(TCLSH) $(TOPDIR)/tools/randomize-js-names.tcl $(SRCDIR_extsrc) | |
| 2147 | 2148 | @chmod -x $(SRCDIR_extsrc)/pikchr.wasm |
| 2148 | 2149 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 2149 | 2150 | |
| 2150 | 2151 | # |
| 2151 | 2152 | # compile_commands.json support... |
| 2152 | 2153 |
| --- src/main.mk | |
| +++ src/main.mk | |
| @@ -2142,10 +2142,11 @@ | |
| 2142 | -sEXPORTED_FUNCTIONS=_pikchr,_pikchr_version $(SRCDIR_extsrc)/pikchr.c \ |
| 2143 | -sENVIRONMENT=web \ |
| 2144 | -sMODULARIZE \ |
| 2145 | -sEXPORT_NAME=initPikchrModule \ |
| 2146 | --minify 0 |
| 2147 | @chmod -x $(SRCDIR_extsrc)/pikchr.wasm |
| 2148 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 2149 | |
| 2150 | # |
| 2151 | # compile_commands.json support... |
| 2152 |
| --- src/main.mk | |
| +++ src/main.mk | |
| @@ -2142,10 +2142,11 @@ | |
| 2142 | -sEXPORTED_FUNCTIONS=_pikchr,_pikchr_version $(SRCDIR_extsrc)/pikchr.c \ |
| 2143 | -sENVIRONMENT=web \ |
| 2144 | -sMODULARIZE \ |
| 2145 | -sEXPORT_NAME=initPikchrModule \ |
| 2146 | --minify 0 |
| 2147 | $(TCLSH) $(TOPDIR)/tools/randomize-js-names.tcl $(SRCDIR_extsrc) |
| 2148 | @chmod -x $(SRCDIR_extsrc)/pikchr.wasm |
| 2149 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 2150 | |
| 2151 | # |
| 2152 | # compile_commands.json support... |
| 2153 |
+1
| --- tools/makemake.tcl | ||
| +++ tools/makemake.tcl | ||
| @@ -575,10 +575,11 @@ | ||
| 575 | 575 | -sEXPORTED_FUNCTIONS=_pikchr,_pikchr_version $(SRCDIR_extsrc)/pikchr.c <<<NEXT_LINE>>> |
| 576 | 576 | -sENVIRONMENT=web <<<NEXT_LINE>>> |
| 577 | 577 | -sMODULARIZE <<<NEXT_LINE>>> |
| 578 | 578 | -sEXPORT_NAME=initPikchrModule <<<NEXT_LINE>>> |
| 579 | 579 | --minify 0 |
| 580 | + $(TCLSH) $(TOPDIR)/tools/randomize-js-names.tcl $(SRCDIR_extsrc) | |
| 580 | 581 | @chmod -x $(SRCDIR_extsrc)/pikchr.wasm |
| 581 | 582 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 582 | 583 | |
| 583 | 584 | # |
| 584 | 585 | # compile_commands.json support... |
| 585 | 586 | |
| 586 | 587 | ADDED tools/randomize-js-names.tcl |
| --- tools/makemake.tcl | |
| +++ tools/makemake.tcl | |
| @@ -575,10 +575,11 @@ | |
| 575 | -sEXPORTED_FUNCTIONS=_pikchr,_pikchr_version $(SRCDIR_extsrc)/pikchr.c <<<NEXT_LINE>>> |
| 576 | -sENVIRONMENT=web <<<NEXT_LINE>>> |
| 577 | -sMODULARIZE <<<NEXT_LINE>>> |
| 578 | -sEXPORT_NAME=initPikchrModule <<<NEXT_LINE>>> |
| 579 | --minify 0 |
| 580 | @chmod -x $(SRCDIR_extsrc)/pikchr.wasm |
| 581 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 582 | |
| 583 | # |
| 584 | # compile_commands.json support... |
| 585 | |
| 586 | DDED tools/randomize-js-names.tcl |
| --- tools/makemake.tcl | |
| +++ tools/makemake.tcl | |
| @@ -575,10 +575,11 @@ | |
| 575 | -sEXPORTED_FUNCTIONS=_pikchr,_pikchr_version $(SRCDIR_extsrc)/pikchr.c <<<NEXT_LINE>>> |
| 576 | -sENVIRONMENT=web <<<NEXT_LINE>>> |
| 577 | -sMODULARIZE <<<NEXT_LINE>>> |
| 578 | -sEXPORT_NAME=initPikchrModule <<<NEXT_LINE>>> |
| 579 | --minify 0 |
| 580 | $(TCLSH) $(TOPDIR)/tools/randomize-js-names.tcl $(SRCDIR_extsrc) |
| 581 | @chmod -x $(SRCDIR_extsrc)/pikchr.wasm |
| 582 | wasm: $(SRCDIR_extsrc)/pikchr.js |
| 583 | |
| 584 | # |
| 585 | # compile_commands.json support... |
| 586 | |
| 587 | DDED tools/randomize-js-names.tcl |
| --- a/tools/randomize-js-names.tcl | ||
| +++ b/tools/randomize-js-names.tcl | ||
| @@ -0,0 +1,36 @@ | ||
| 1 | +#!/usr/bin/tclsh | |
| 2 | +# | |
| 3 | +# This script is run as part of "make wasm". After emcc has | |
| 4 | +# run to generate extsrc/pikchr.wasm and extsrc/pikchr.js from | |
| 5 | +# extsrc/pikchr.c, we need to make changes to these filenames to | |
| 6 | +# work around caching problems. | |
| 7 | +# | |
| 8 | +# (1) in extsrc/pikchr.js -> change "pikchr.wasm" into | |
| 9 | +# "pikchr-vNNNNNNNN.wasm" where Ns are random digits. | |
| 10 | +# | |
| 11 | +# (2) in extsrc/pikchr-worker.js -> change "pikchr-vNNNNNNNN.js" | |
| 12 | +# by altering the random digits N. | |
| 13 | +# | |
| 14 | +set DIR extsrc | |
| 15 | +if {[llength $argv]>0} { | |
| 16 | + set DIR [lindex $argv 0] | |
| 17 | +} | |
| 18 | + | |
| 19 | +set R [expr {int(rand()*10000000000)+1000000000}] | |
| 20 | +set in [open $DIR/pikchr.js rb] | |
| 21 | +set f1 [read $in] | |
| 22 | +close $in | |
| 23 | +set f1mod [regsub {\ypikchr(-v\d+)?\.wasm\y} $f1 "pikchr-v$R.wasm"] | |
| 24 | +set out [open $DIR/pikchr.js wb] | |
| 25 | +puts -nonewline $out $f1mod | |
| 26 | +close $out | |
| 27 | +puts "modified $DIR/pikchr.js to reference \"pikchr-v$R.wasm\"" | |
| 28 | + | |
| 29 | +set in [open $DIR/pikchr-worker.js rb] | |
| 30 | +set f1 [read $in] | |
| 31 | +close $in | |
| 32 | +set f1mod [regsub {\ypikchr(-v\d+)?\.js\y} $f1 "pikchr-v$R.js"] | |
| 33 | +set out [open $DIR/pikchr-worker.js wb] | |
| 34 | +puts -nonewline $out $f1mod | |
| 35 | +close $out | |
| 36 | +puts "modified $DIR/pikchr-worker.js to reference \"pikchr-v$R.js\"" |
| --- a/tools/randomize-js-names.tcl | |
| +++ b/tools/randomize-js-names.tcl | |
| @@ -0,0 +1,36 @@ | |
| --- a/tools/randomize-js-names.tcl | |
| +++ b/tools/randomize-js-names.tcl | |
| @@ -0,0 +1,36 @@ | |
| 1 | #!/usr/bin/tclsh |
| 2 | # |
| 3 | # This script is run as part of "make wasm". After emcc has |
| 4 | # run to generate extsrc/pikchr.wasm and extsrc/pikchr.js from |
| 5 | # extsrc/pikchr.c, we need to make changes to these filenames to |
| 6 | # work around caching problems. |
| 7 | # |
| 8 | # (1) in extsrc/pikchr.js -> change "pikchr.wasm" into |
| 9 | # "pikchr-vNNNNNNNN.wasm" where Ns are random digits. |
| 10 | # |
| 11 | # (2) in extsrc/pikchr-worker.js -> change "pikchr-vNNNNNNNN.js" |
| 12 | # by altering the random digits N. |
| 13 | # |
| 14 | set DIR extsrc |
| 15 | if {[llength $argv]>0} { |
| 16 | set DIR [lindex $argv 0] |
| 17 | } |
| 18 | |
| 19 | set R [expr {int(rand()*10000000000)+1000000000}] |
| 20 | set in [open $DIR/pikchr.js rb] |
| 21 | set f1 [read $in] |
| 22 | close $in |
| 23 | set f1mod [regsub {\ypikchr(-v\d+)?\.wasm\y} $f1 "pikchr-v$R.wasm"] |
| 24 | set out [open $DIR/pikchr.js wb] |
| 25 | puts -nonewline $out $f1mod |
| 26 | close $out |
| 27 | puts "modified $DIR/pikchr.js to reference \"pikchr-v$R.wasm\"" |
| 28 | |
| 29 | set in [open $DIR/pikchr-worker.js rb] |
| 30 | set f1 [read $in] |
| 31 | close $in |
| 32 | set f1mod [regsub {\ypikchr(-v\d+)?\.js\y} $f1 "pikchr-v$R.js"] |
| 33 | set out [open $DIR/pikchr-worker.js wb] |
| 34 | puts -nonewline $out $f1mod |
| 35 | close $out |
| 36 | puts "modified $DIR/pikchr-worker.js to reference \"pikchr-v$R.js\"" |