experimentally load worker into engine as base64 blob payload
This commit is contained in:
parent
87137e44d1
commit
bc0f51cc7b
2 changed files with 13 additions and 8 deletions
15
app.js
15
app.js
|
|
@ -495,6 +495,7 @@ const script = {
|
||||||
"&main/kiri",
|
"&main/kiri",
|
||||||
],
|
],
|
||||||
engine : [
|
engine : [
|
||||||
|
"@kiri_work",
|
||||||
"&kiri-run/engine",
|
"&kiri-run/engine",
|
||||||
"&main/kiri",
|
"&main/kiri",
|
||||||
],
|
],
|
||||||
|
|
@ -696,6 +697,9 @@ function concatCode(key) {
|
||||||
// in debug mode, the script should load dependent
|
// in debug mode, the script should load dependent
|
||||||
// scripts instead of serving a complete bundle
|
// scripts instead of serving a complete bundle
|
||||||
if (debug) {
|
if (debug) {
|
||||||
|
inject.forEach(key => {
|
||||||
|
code.push(synth[key]);
|
||||||
|
});
|
||||||
code.push(...[
|
code.push(...[
|
||||||
oversion ? `self.debug_version='${oversion}';self.enable_service=${serviceWorker};` : '',
|
oversion ? `self.debug_version='${oversion}';self.enable_service=${serviceWorker};` : '',
|
||||||
'self.debug=true;',
|
'self.debug=true;',
|
||||||
|
|
@ -709,6 +713,7 @@ function concatCode(key) {
|
||||||
']; function load_next() {',
|
']; function load_next() {',
|
||||||
'let file = load.shift();',
|
'let file = load.shift();',
|
||||||
'if (!file) return;',
|
'if (!file) return;',
|
||||||
|
// 'console.log("loading", file);',
|
||||||
'if (!self.document) { importScripts(file); return load_next() }',
|
'if (!self.document) { importScripts(file); return load_next() }',
|
||||||
'let s = document.createElement("script");',
|
'let s = document.createElement("script");',
|
||||||
's.type = "text/javascript";',
|
's.type = "text/javascript";',
|
||||||
|
|
@ -717,11 +722,11 @@ function concatCode(key) {
|
||||||
'document.head.appendChild(s);',
|
'document.head.appendChild(s);',
|
||||||
'} load_next(); })();'
|
'} load_next(); })();'
|
||||||
].join('\n'));
|
].join('\n'));
|
||||||
|
code = code.join('\n');
|
||||||
|
} else {
|
||||||
inject.forEach(key => {
|
inject.forEach(key => {
|
||||||
code.push(synth[key]);
|
code.push(synth[key]);
|
||||||
});
|
});
|
||||||
code = code.join('\n');
|
|
||||||
} else {
|
|
||||||
direct.forEach(file => {
|
direct.forEach(file => {
|
||||||
let cached = getCachedFile(file, path => {
|
let cached = getCachedFile(file, path => {
|
||||||
return minify(PATH.join(dir,file));
|
return minify(PATH.join(dir,file));
|
||||||
|
|
@ -731,13 +736,9 @@ function concatCode(key) {
|
||||||
}
|
}
|
||||||
code.push(cached);
|
code.push(cached);
|
||||||
});
|
});
|
||||||
inject.forEach(key => {
|
|
||||||
code.push(synth[key]);
|
|
||||||
});
|
|
||||||
code = code.join('');
|
code = code.join('');
|
||||||
|
synth[key] = `self.${key} = "${Buffer.from(code).toString('base64')}";\n`;
|
||||||
}
|
}
|
||||||
// console.log(`SETTING synth[${key}]`);
|
|
||||||
// synth[key] = `self.${key} = "${Buffer.from(code).toString('base64')}";\n`;
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,11 +126,15 @@ let Instance;
|
||||||
|
|
||||||
ext.manifold.then(mod => {
|
ext.manifold.then(mod => {
|
||||||
mod.default({
|
mod.default({
|
||||||
locateFile() { return "/wasm/manifold.wasm" }
|
locateFile(a,b,c) {
|
||||||
|
return "/wasm/manifold.wasm";
|
||||||
|
}
|
||||||
}).then(inst => {
|
}).then(inst => {
|
||||||
inst.setup();
|
inst.setup();
|
||||||
Instance = inst;
|
Instance = inst;
|
||||||
CSG.Instance = () => { return Instance };
|
CSG.Instance = () => { return Instance };
|
||||||
|
}).catch(error => {
|
||||||
|
console.log('manifold load error', error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue