Skip to content

Commit 5411b4a

Browse files
committed
reorganize a bit
+ make the packaging script work
1 parent 0e27c0f commit 5411b4a

2 files changed

Lines changed: 21 additions & 20 deletions

File tree

web/main.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,28 @@ var Main = function () {
7878
}
7979
},
8080

81-
check_GL_enabled: function () {
82-
var testCanvas = document.createElement('canvas');
83-
if (!testCanvas.getContext("webgl2") && !testCanvas.getContext("webgl")) {
84-
var elem = document.getElementById('dragdrop');
85-
elem.classList.add("error");
81+
init_ww: function (canvas) {
82+
let noww = (window.location.hash == "#noww");
83+
if (noww || typeof OffscreenCanvas === 'undefined' || typeof Worker === 'undefined') {
84+
return false;
8685
}
86+
console.log("ww impl");
87+
var offscreen = canvas.transferControlToOffscreen();
88+
_ww = new Worker('send-worker.js');
89+
_ww.onmessage = Report.handleWorkerMessage;
90+
_ww.onerror = function (err) {
91+
console.error('[send] Worker error: ', err);
92+
};
93+
_ww.postMessage({ fun: 'init_window', args: [offscreen] }, [offscreen]);
94+
return true;
8795
},
8896

8997
on_ww_init: function (force_local) {
9098
console.log('on ww init ' + force_local);
9199

92100
if (force_local) {
93101
_ww = undefined;
102+
// force refresh in main thread mode
94103
window.location.hash = "#noww";
95104
window.location.reload();
96105
return;
@@ -100,21 +109,13 @@ var Main = function () {
100109
_ww.postMessage({ fun: 'nextFrame', args: [] });
101110
},
102111

103-
init_ww: function (canvas) {
104-
let noww = (window.location.hash == "#noww");
105-
if (noww || typeof OffscreenCanvas === 'undefined' || typeof Worker === 'undefined') {
106-
return false;
112+
113+
check_GL_enabled: function () {
114+
var testCanvas = document.createElement('canvas');
115+
if (!testCanvas.getContext("webgl2") && !testCanvas.getContext("webgl")) {
116+
var elem = document.getElementById('dragdrop');
117+
elem.classList.add("error");
107118
}
108-
console.log("ww impl");
109-
// TODO: clone canvas maybe?
110-
var offscreen = canvas.transferControlToOffscreen();
111-
_ww = new Worker('send-worker.js');
112-
_ww.onmessage = Report.handleWorkerMessage;
113-
_ww.onerror = function (err) {
114-
console.error('[send] Worker error: ', err);
115-
};
116-
_ww.postMessage({ fun: 'init_window', args: [offscreen] }, [offscreen]);
117-
return true;
118119
},
119120

120121
resize: function () {

web/wasmgz.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# run from within web dir
33
# does various renames for cache busting
44

5-
RENAME_FILES=$(ls cimbar_js.js cimbar_js.wasm main.js recv.js recv-worker.js zstd.js pwa*.json)
5+
RENAME_FILES=$(ls cimbar_js.js cimbar_js.wasm main.js send.js send-worker.js recv.js recv-worker.js zstd.js pwa*.json)
66
GSUB_FILES="index.html recv.html sw.js recv-sw.js $(echo $RENAME_FILES | sed 's/cimbar_js\.wasm//g')"
77

88
VERSION=${VERSION:-$(date --utc '+%Y-%m-%dT%H%M')}

0 commit comments

Comments
 (0)