blob: 42b2d07fcf4bcd9fc144f8d92a434cd06a3640b3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import { wrap, proxy } from './comlink-4.3.1.js';
report.onclick = () => { location.pathname = '/report' };
window.sandbox = new class {
box = wrap(new Worker('sandbox.js', { type: 'module' }));
run(code) {
return new Promise(async (resolve, reject) => {
const errorHandler = proxy(reject);
const result = await this.box.run(code, errorHandler);
resolve(result);
});
}
}();
const query = new URLSearchParams(location.search);
const code = query.get('code') ?? '7*7';
let tmp = await window.sandbox.run(code);
console.log(tmp);
output.textContent = tmp;
|