@endge/computation-sandbox 0.1.11 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -19,16 +19,19 @@ class c {
|
|
|
19
19
|
}
|
|
20
20
|
dispose() {
|
|
21
21
|
this.disposed = !0;
|
|
22
|
-
for (const e of this.queue)
|
|
22
|
+
for (const e of this.queue)
|
|
23
|
+
e.reject(new Error("Computation sandbox is disposed."));
|
|
23
24
|
this.queue.splice(0);
|
|
24
|
-
for (const e of this.workers)
|
|
25
|
+
for (const e of this.workers)
|
|
26
|
+
e.dispose();
|
|
25
27
|
}
|
|
26
28
|
flush() {
|
|
27
29
|
if (this.scheduled = !1, this.disposed || !this.queue.length)
|
|
28
30
|
return;
|
|
29
31
|
const e = Array.from({ length: this.workers.length }, () => []);
|
|
30
32
|
let t = 0;
|
|
31
|
-
for (; this.queue.length; )
|
|
33
|
+
for (; this.queue.length; )
|
|
34
|
+
e[t++ % e.length].push(this.queue.shift());
|
|
32
35
|
e.forEach((r, i) => {
|
|
33
36
|
r.length && this.workers[i].execute(r);
|
|
34
37
|
});
|
|
@@ -46,15 +49,19 @@ class l {
|
|
|
46
49
|
}
|
|
47
50
|
execute(e) {
|
|
48
51
|
if (this.disposed) {
|
|
49
|
-
for (const t of e)
|
|
52
|
+
for (const t of e)
|
|
53
|
+
t.reject(new Error("Computation Worker was disposed."));
|
|
50
54
|
return;
|
|
51
55
|
}
|
|
52
56
|
this.queued.push(e), this.pump();
|
|
53
57
|
}
|
|
54
58
|
dispose() {
|
|
55
59
|
this.disposed = !0, this.timer && clearTimeout(this.timer), this.timer = null, this.worker.terminate();
|
|
56
|
-
for (const e of this.active ?? [])
|
|
57
|
-
|
|
60
|
+
for (const e of this.active ?? [])
|
|
61
|
+
e.reject(new Error("Computation Worker was disposed."));
|
|
62
|
+
for (const e of this.queued)
|
|
63
|
+
for (const t of e)
|
|
64
|
+
t.reject(new Error("Computation Worker was disposed."));
|
|
58
65
|
this.active = null, this.queued.splice(0), this.busy = !1;
|
|
59
66
|
}
|
|
60
67
|
pump() {
|
|
@@ -64,7 +71,8 @@ class l {
|
|
|
64
71
|
const e = this.queued.shift();
|
|
65
72
|
this.active = e, this.timer = setTimeout(() => {
|
|
66
73
|
this.worker.terminate(), this.worker = this.createWorker();
|
|
67
|
-
for (const t of e)
|
|
74
|
+
for (const t of e)
|
|
75
|
+
t.reject(new Error(`Computation Worker exceeded ${this.watchdogMs} ms watchdog.`));
|
|
68
76
|
this.active = null, this.timer = null, this.busy = !1, this.pump();
|
|
69
77
|
}, this.watchdogMs), this.worker.onmessage = (t) => {
|
|
70
78
|
this.timer && clearTimeout(this.timer), this.timer = null;
|
|
@@ -76,7 +84,8 @@ class l {
|
|
|
76
84
|
this.active = null, this.busy = !1, this.pump();
|
|
77
85
|
}, this.worker.onerror = (t) => {
|
|
78
86
|
this.timer && clearTimeout(this.timer), this.timer = null;
|
|
79
|
-
for (const r of e)
|
|
87
|
+
for (const r of e)
|
|
88
|
+
r.reject(new Error(t.message || "Computation Worker failed."));
|
|
80
89
|
this.worker.terminate(), this.worker = this.createWorker(), this.active = null, this.busy = !1, this.pump();
|
|
81
90
|
}, this.worker.postMessage({
|
|
82
91
|
type: "execute-batch",
|
|
@@ -86,7 +95,7 @@ class l {
|
|
|
86
95
|
createWorker() {
|
|
87
96
|
return new Worker(new URL(
|
|
88
97
|
/* @vite-ignore */
|
|
89
|
-
"" + new URL("assets/computation-sandbox.worker-
|
|
98
|
+
"" + new URL("assets/computation-sandbox.worker-D1PJv1Tp.js", import.meta.url).href,
|
|
90
99
|
import.meta.url
|
|
91
100
|
), { type: "module" });
|
|
92
101
|
}
|
package/package.json
CHANGED
|
@@ -1,40 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@endge/computation-sandbox",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.16",
|
|
4
5
|
"private": false,
|
|
5
6
|
"license": "Apache-2.0",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "./dist/computation-sandbox.js",
|
|
8
|
-
"module": "./dist/computation-sandbox.js",
|
|
9
|
-
"types": "./dist/main.d.ts",
|
|
10
7
|
"exports": {
|
|
11
8
|
".": {
|
|
12
9
|
"types": "./dist/main.d.ts",
|
|
13
10
|
"import": "./dist/computation-sandbox.js"
|
|
14
11
|
}
|
|
15
12
|
},
|
|
16
|
-
"
|
|
13
|
+
"main": "./dist/computation-sandbox.js",
|
|
14
|
+
"module": "./dist/computation-sandbox.js",
|
|
15
|
+
"types": "./dist/main.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
17
19
|
"scripts": {
|
|
18
20
|
"dev": "vite build --watch",
|
|
19
21
|
"build": "vite build",
|
|
20
22
|
"test": "vitest",
|
|
21
|
-
"typecheck": "tsc --noEmit"
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"lint-check": "eslint . --cache",
|
|
25
|
+
"lint-fix": "eslint . --fix --cache"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@endge/core": "^3.0.1 || ^4.0.0"
|
|
22
29
|
},
|
|
23
30
|
"dependencies": {
|
|
24
31
|
"@jitl/quickjs-ng-wasmfile-release-sync": "^0.32.0",
|
|
25
32
|
"quickjs-emscripten-core": "^0.32.0",
|
|
26
|
-
"typescript": "
|
|
27
|
-
},
|
|
28
|
-
"peerDependencies": {
|
|
29
|
-
"@endge/core": "^3.0.1"
|
|
33
|
+
"typescript": "~6.0.3"
|
|
30
34
|
},
|
|
31
35
|
"devDependencies": {
|
|
32
|
-
"@
|
|
36
|
+
"@antfu/eslint-config": "9.3.0",
|
|
37
|
+
"@endge/core": "^4.0.0",
|
|
33
38
|
"@endge/raph": "^3.0.11",
|
|
34
|
-
"@endge/utils": "^0.
|
|
39
|
+
"@endge/utils": "^0.25.0",
|
|
40
|
+
"eslint": "10.9.1",
|
|
35
41
|
"rimraf": "^6.0.1",
|
|
42
|
+
"unplugin-dts": "^1.0.3",
|
|
36
43
|
"vite": "^6.1.0",
|
|
37
|
-
"vite-plugin-dts": "^4.5.0",
|
|
38
44
|
"vitest": "^2.1.9"
|
|
39
45
|
}
|
|
40
46
|
}
|