-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathxw_worker.js
31 lines (31 loc) · 1.06 KB
/
xw_worker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
let onRuntimeInitialized;
let emscriptenPromise = new Promise((resolve, reject) => {
onRuntimeInitialized = resolve;
});
var Module = {
wasmBinaryFile: "third_party/glucose-3.0/simp/xwsolve.wasm",
onRuntimeInitialized: onRuntimeInitialized,
};
importScripts('third_party/glucose-3.0/simp/xwsolve.js');
onmessage = function(e) {
emscriptenPromise.then((dummy) => {
let cmd = e.data;
switch (cmd[0]) {
case 'run':
FS.writeFile('/wordlist', cmd[1]);
FS.writeFile('/puz', cmd[2]);
let isQuick = cmd[3];
console.log('calling main');
let args = ['-no-pre', '/wordlist', '/puz'];
if (isQuick) {
// args.splice(0, 0, '-compute-forced', '-thresh1=13', '-thresh2=10');
args.splice(0, 0, '-thresh1=13', '-thresh2=10');
}
Module.callMain(args);
break;
case 'cancel':
Module.ccall('cancel', 'void', [], []);
break;
}
});
}