@atolljs/core 0.1.7 → 0.1.8
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.
- package/README.md +1 -1
- package/dist/contract/memoryDevtools.d.ts +30 -0
- package/dist/contract/sharedMemory.d.ts +4 -2
- package/dist/contract/types.d.ts +11 -0
- package/dist/devtools.d.ts +127 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +19 -17
- package/dist/index10.js +29 -14
- package/dist/index11.js +14 -307
- package/dist/index12.js +29 -50
- package/dist/index13.js +46 -60
- package/dist/index14.js +56 -22
- package/dist/index15.js +332 -55
- package/dist/index16.js +246 -45
- package/dist/index17.js +56 -51
- package/dist/index18.js +9 -39
- package/dist/index19.js +56 -80
- package/dist/index20.js +24 -53
- package/dist/index21.js +56 -52
- package/dist/index22.js +48 -0
- package/dist/index23.js +68 -0
- package/dist/index24.js +41 -0
- package/dist/index25.js +46 -0
- package/dist/index26.js +113 -0
- package/dist/index27.js +60 -0
- package/dist/index28.js +57 -0
- package/dist/index5.js +135 -64
- package/dist/index6.js +160 -35
- package/dist/index7.js +45 -503
- package/dist/index8.js +513 -19
- package/dist/index9.js +19 -33
- package/dist/pool/dedicatedWorker.d.ts +63 -0
- package/dist/pool/devtoolsCommands.d.ts +54 -0
- package/dist/pool/subWorkerClient.d.ts +50 -0
- package/dist/pool/workerChannel.d.ts +44 -0
- package/dist/pool/workerClient.d.ts +36 -8
- package/dist/pool/workerPool.d.ts +10 -1
- package/dist/reactive.d.ts +15 -0
- package/dist/reactiveGraph.d.ts +9 -0
- package/dist/userTiming.d.ts +27 -0
- package/package.json +2 -1
- package/src/contract/memoryDevtools.ts +249 -0
- package/src/contract/sharedMemory.ts +20 -6
- package/src/contract/types.ts +11 -0
- package/src/devtools.ts +251 -6
- package/src/index.ts +13 -1
- package/src/log.ts +22 -0
- package/src/observable.ts +16 -3
- package/src/pool/dedicatedWorker.ts +332 -0
- package/src/pool/devtoolsCommands.ts +165 -0
- package/src/pool/subWorkerClient.ts +70 -0
- package/src/pool/workerChannel.ts +99 -0
- package/src/pool/workerClient.ts +61 -15
- package/src/pool/workerPool.ts +75 -45
- package/src/reactive.ts +87 -12
- package/src/reactiveGraph.ts +91 -0
- package/src/testing/inProcessWorker.ts +4 -3
- package/src/userTiming.ts +71 -0
- package/src/worker/workerBootstrap.ts +27 -4
package/dist/index6.js
CHANGED
|
@@ -1,38 +1,163 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
r
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import { emitDevtools as e, previewValue as t, registerDevtoolsCommand as n } from "./index5.js";
|
|
2
|
+
//#region src/contract/memoryDevtools.ts
|
|
3
|
+
var r = /* @__PURE__ */ new Map(), i = () => [], a = !1, o = 5, s = 16, c = (e) => {
|
|
4
|
+
let n = e;
|
|
5
|
+
if (typeof n.readAt == "function" && typeof n.recordCount == "number") {
|
|
6
|
+
let e = Array.from({ length: Math.min(o, n.recordCount) }, (e, t) => n.readAt(t));
|
|
7
|
+
return t({
|
|
8
|
+
records: n.recordCount,
|
|
9
|
+
head: e
|
|
10
|
+
}, 1024);
|
|
11
|
+
}
|
|
12
|
+
let r = e.read();
|
|
13
|
+
if (ArrayBuffer.isView(r) && !(r instanceof DataView)) {
|
|
14
|
+
let e = r, t = Array.from({ length: Math.min(s, e.length) }, (t, n) => typeof e[n] == "bigint" ? `${e[n]}n` : e[n]);
|
|
15
|
+
return `${r.constructor.name}(${e.length}) ${JSON.stringify(t)}${e.length > s ? "…" : ""}`;
|
|
16
|
+
}
|
|
17
|
+
return t(r, 1024);
|
|
18
|
+
}, l = (e, t) => e.connector(t), u = (e) => e._version ? Atomics.load(e._version.view, e._version.index) : 0, d = (e) => {
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(e);
|
|
21
|
+
} catch {
|
|
22
|
+
return e;
|
|
23
|
+
}
|
|
24
|
+
}, f = (e) => typeof e == "number" ? e : typeof e == "bigint" ? Number(e) : null, p = (e) => {
|
|
25
|
+
let n = e.trim();
|
|
26
|
+
if (n === "change") return {
|
|
27
|
+
text: n,
|
|
28
|
+
test: () => !0
|
|
29
|
+
};
|
|
30
|
+
let r = /^(>=|<=|==|!=|>|<)\s*(.+)$/.exec(n);
|
|
31
|
+
if (!r) throw Error(`memory.watch: bad rule '${e}' — use change, > n, < n, >= n, <= n, == v, != v`);
|
|
32
|
+
let [, i, a] = r;
|
|
33
|
+
if (i === "==" || i === "!=") {
|
|
34
|
+
let e = d(a), r = (n) => typeof n == "object" && n ? t(n) === t(e) : Object.is(n, e) || typeof n == "bigint" && Number(n) === e;
|
|
35
|
+
return {
|
|
36
|
+
text: n,
|
|
37
|
+
test: i === "==" ? r : (e) => !r(e)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
let o = Number(a);
|
|
41
|
+
if (!Number.isFinite(o)) throw Error(`memory.watch: '${a}' is not a number`);
|
|
42
|
+
let s = {
|
|
43
|
+
">": (e) => e > o,
|
|
44
|
+
"<": (e) => e < o,
|
|
45
|
+
">=": (e) => e >= o,
|
|
46
|
+
"<=": (e) => e <= o
|
|
47
|
+
};
|
|
28
48
|
return {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
text: n,
|
|
50
|
+
test: (e) => {
|
|
51
|
+
let t = f(e);
|
|
52
|
+
return t !== null && s[i](t);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}, m = (t, n, r, i, a) => {
|
|
56
|
+
let o = r.seen.get(t);
|
|
57
|
+
if (o && o.version >= a) return;
|
|
58
|
+
let s = r.rule.text === "change", l = typeof i.readAt == "function", u, d;
|
|
59
|
+
try {
|
|
60
|
+
d = c(i), u = s || l ? void 0 : i.read();
|
|
61
|
+
} catch {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
r.seen.set(t, {
|
|
65
|
+
version: a,
|
|
66
|
+
preview: d
|
|
67
|
+
}), (s ? d !== o?.preview : !l && r.rule.test(u)) && (r.hits++, e({
|
|
68
|
+
type: "memory:watch-hit",
|
|
69
|
+
path: n,
|
|
70
|
+
version: a,
|
|
71
|
+
value: d,
|
|
72
|
+
rule: r.rule.text
|
|
73
|
+
}));
|
|
74
|
+
}, h = (e, t, n) => {
|
|
75
|
+
let i = r.get(t);
|
|
76
|
+
i && m(e, t, i, l(e, t), n);
|
|
77
|
+
}, g = (e, t) => {
|
|
78
|
+
let n = !1, r = () => {
|
|
79
|
+
for (let n of i()) {
|
|
80
|
+
if (!n.bound) continue;
|
|
81
|
+
let r;
|
|
82
|
+
try {
|
|
83
|
+
r = l(n, e);
|
|
84
|
+
} catch {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
m(n, e, t, r, u(r));
|
|
88
|
+
}
|
|
34
89
|
};
|
|
35
|
-
|
|
36
|
-
|
|
90
|
+
if (typeof Atomics.waitAsync == "function") return (async () => {
|
|
91
|
+
for (; !n;) {
|
|
92
|
+
let t = i().find((t) => {
|
|
93
|
+
try {
|
|
94
|
+
return t.bound && l(t, e)._version !== void 0;
|
|
95
|
+
} catch {
|
|
96
|
+
return !1;
|
|
97
|
+
}
|
|
98
|
+
}), a = t ? l(t, e)._version : void 0;
|
|
99
|
+
if (a) {
|
|
100
|
+
let e = Atomics.waitAsync(a.view, a.index, Atomics.load(a.view, a.index), 250);
|
|
101
|
+
e.async && await e.value;
|
|
102
|
+
} else await new Promise((e) => setTimeout(e, 250));
|
|
103
|
+
n || r();
|
|
104
|
+
}
|
|
105
|
+
})(), () => {
|
|
106
|
+
n = !0;
|
|
107
|
+
};
|
|
108
|
+
let a = setInterval(r, 50);
|
|
109
|
+
return a.unref?.(), () => {
|
|
110
|
+
n = !0, clearInterval(a);
|
|
111
|
+
};
|
|
112
|
+
}, _ = () => [...r.entries()].map(([e, t]) => ({
|
|
113
|
+
path: e,
|
|
114
|
+
rule: t.rule.text,
|
|
115
|
+
hits: t.hits
|
|
116
|
+
})), v = (e) => {
|
|
117
|
+
i = e, !a && (a = !0, n("memory.read", () => {
|
|
118
|
+
let e = [];
|
|
119
|
+
return i().forEach((t, n) => {
|
|
120
|
+
if (t.bound) for (let { path: r } of t.fields()) try {
|
|
121
|
+
let i = l(t, r);
|
|
122
|
+
e.push({
|
|
123
|
+
path: r,
|
|
124
|
+
value: c(i),
|
|
125
|
+
version: u(i),
|
|
126
|
+
contract: n
|
|
127
|
+
});
|
|
128
|
+
} catch (t) {
|
|
129
|
+
e.push({
|
|
130
|
+
path: r,
|
|
131
|
+
value: `[unreadable: ${t.message}]`,
|
|
132
|
+
version: -1,
|
|
133
|
+
contract: n
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}), e;
|
|
137
|
+
}), n("memory.watch", (e) => {
|
|
138
|
+
let t = String(e.path ?? "");
|
|
139
|
+
if (!t) throw Error("memory.watch: `path` is required");
|
|
140
|
+
if (!i().some((e) => e.fields().some((e) => e.path === t))) throw Error(`memory.watch: no contract defines a field '${t}'`);
|
|
141
|
+
let n = p(String(e.rule ?? "change"));
|
|
142
|
+
r.get(t)?.stop();
|
|
143
|
+
let a = {
|
|
144
|
+
rule: n,
|
|
145
|
+
seen: /* @__PURE__ */ new WeakMap(),
|
|
146
|
+
stop: () => {},
|
|
147
|
+
hits: 0
|
|
148
|
+
};
|
|
149
|
+
for (let e of i()) if (e.bound) try {
|
|
150
|
+
let n = l(e, t);
|
|
151
|
+
a.seen.set(e, {
|
|
152
|
+
version: u(n),
|
|
153
|
+
preview: c(n)
|
|
154
|
+
});
|
|
155
|
+
} catch {}
|
|
156
|
+
return r.set(t, a), a.stop = g(t, a), _();
|
|
157
|
+
}), n("memory.unwatch", (e) => {
|
|
158
|
+
let t = String(e.path ?? "");
|
|
159
|
+
return r.get(t)?.stop(), r.delete(t), _();
|
|
160
|
+
}), n("memory.watches", () => _()));
|
|
161
|
+
};
|
|
37
162
|
//#endregion
|
|
38
|
-
export {
|
|
163
|
+
export { h as checkWatchOnWrite, v as ensureMemoryCommands, c as fieldPreview, r as memoryWatches, p as parseWatchRule };
|