reflex-quant 1.1.0 → 1.1.2
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 +144 -106
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.development.cjs +427 -0
- package/dist/index.development.cjs.map +7 -0
- package/dist/index.development.js +408 -0
- package/dist/index.development.js.map +7 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/package.json +4 -1
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
/* reflex-quant 1.1.2 | MIT */
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
10
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
17
|
+
|
|
18
|
+
// src/index.ts
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
__export(index_exports, {
|
|
21
|
+
batch: () => batch,
|
|
22
|
+
computed: () => computed,
|
|
23
|
+
dispose: () => dispose2,
|
|
24
|
+
effect: () => effect,
|
|
25
|
+
get: () => get,
|
|
26
|
+
peek: () => peek2,
|
|
27
|
+
set: () => set,
|
|
28
|
+
signal: () => signal,
|
|
29
|
+
untracked: () => untracked,
|
|
30
|
+
update: () => update
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(index_exports);
|
|
33
|
+
|
|
34
|
+
// src/graph.ts
|
|
35
|
+
var UNREAD = -1, SETTLE = 536870911, SCAN = 8, KEEP = 256, TRIM = 512;
|
|
36
|
+
function node(fn, value, flags) {
|
|
37
|
+
return {
|
|
38
|
+
flags,
|
|
39
|
+
value,
|
|
40
|
+
ver: 0,
|
|
41
|
+
fn,
|
|
42
|
+
deps: null,
|
|
43
|
+
subs: null,
|
|
44
|
+
lastSub: null,
|
|
45
|
+
slot: null,
|
|
46
|
+
gen: 0
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function move(c, e, last, next) {
|
|
50
|
+
let before = e.prev, after = e.next;
|
|
51
|
+
before.next = after, after !== null && (after.prev = before), e.prev = last, e.next = next, last !== null ? last.next = e : c.deps = e, next.prev = e;
|
|
52
|
+
}
|
|
53
|
+
function cut(c, last) {
|
|
54
|
+
let e = last === null ? c.deps : last.next;
|
|
55
|
+
if (e !== null)
|
|
56
|
+
for (last === null ? c.deps = null : last.next = null, e.prev = null; e !== null; e = e.next) unsub(e);
|
|
57
|
+
}
|
|
58
|
+
function settle(c) {
|
|
59
|
+
let gen = c.gen;
|
|
60
|
+
for (let e = c.deps; e !== null; e = e.next) e.gen = gen;
|
|
61
|
+
}
|
|
62
|
+
function unsub(e) {
|
|
63
|
+
let s = e.from, before = e.prevSub, after = e.nextSub;
|
|
64
|
+
before !== null ? before.nextSub = after : s.subs = after, after !== null ? after.prevSub = before : s.lastSub = before, e.prevSub = null, e.nextSub = null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/kernel.ts
|
|
68
|
+
var active = null, cursor = null, stack = new Array(256).fill(null), top = 0;
|
|
69
|
+
var wake = () => {
|
|
70
|
+
};
|
|
71
|
+
function onWake(fn) {
|
|
72
|
+
wake = fn;
|
|
73
|
+
}
|
|
74
|
+
function trim() {
|
|
75
|
+
stack.length > TRIM && top === 0 && (stack.length = KEEP);
|
|
76
|
+
}
|
|
77
|
+
function write(s, value) {
|
|
78
|
+
if (!Object.is(s.value, value)) {
|
|
79
|
+
s.value = value, s.ver = s.ver + 1 & 1073741823 /* Mask */;
|
|
80
|
+
for (let e = s.subs; e !== null; e = e.nextSub) {
|
|
81
|
+
let n = e.to, f = n.flags;
|
|
82
|
+
if ((f & 4 /* Busy */) !== 0) {
|
|
83
|
+
if ((f & 1 /* Stale */) === 0)
|
|
84
|
+
if (n.flags = f | 1 /* Stale */, (f & 16 /* Watch */) !== 0) wake(n);
|
|
85
|
+
else {
|
|
86
|
+
let subs = n.subs;
|
|
87
|
+
subs !== null && mark(subs);
|
|
88
|
+
}
|
|
89
|
+
} else if ((f & 16 /* Watch */) !== 0)
|
|
90
|
+
n.flags = f | 2 /* Dirty */ | 32 /* Woken */, wake(n);
|
|
91
|
+
else if ((f & 1 /* Stale */) !== 0)
|
|
92
|
+
n.flags = f | 2 /* Dirty */;
|
|
93
|
+
else {
|
|
94
|
+
n.flags = f | 2 /* Dirty */ | 1 /* Stale */;
|
|
95
|
+
let subs = n.subs;
|
|
96
|
+
subs !== null && mark(subs);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function mark(first) {
|
|
102
|
+
let base = top, e = first;
|
|
103
|
+
for (; ; ) {
|
|
104
|
+
for (; e !== null; ) {
|
|
105
|
+
let n = e.to, f = n.flags;
|
|
106
|
+
if ((f & 16 /* Watch */) !== 0)
|
|
107
|
+
n.flags = f | 1 /* Stale */, wake(n);
|
|
108
|
+
else if ((f & 1 /* Stale */) === 0) {
|
|
109
|
+
n.flags = f | 1 /* Stale */;
|
|
110
|
+
let subs = n.subs;
|
|
111
|
+
if (subs !== null) {
|
|
112
|
+
let next = e.nextSub;
|
|
113
|
+
next !== null && (stack[top++] = next), e = subs;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
e = e.nextSub;
|
|
118
|
+
}
|
|
119
|
+
if (top === base) {
|
|
120
|
+
trim();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
e = stack[--top], stack[top] = null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function read(n) {
|
|
127
|
+
let value = peek(n), c = active;
|
|
128
|
+
if (c !== null) {
|
|
129
|
+
let last = cursor, next = last === null ? c.deps : last.next;
|
|
130
|
+
next !== null && next.from === n ? (cursor = next, next.ver = n.ver) : miss(c, n, last, next);
|
|
131
|
+
}
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
function peek(n) {
|
|
135
|
+
return (n.flags & 39) !== 0 && pull(n), n.value;
|
|
136
|
+
}
|
|
137
|
+
function pull(root) {
|
|
138
|
+
let f = root.flags;
|
|
139
|
+
if ((f & 36) !== 0)
|
|
140
|
+
throw new Error("Cycle detected");
|
|
141
|
+
if ((f & 2 /* Dirty */) !== 0) return exec(root);
|
|
142
|
+
verify(root, f);
|
|
143
|
+
}
|
|
144
|
+
function verify(root, f) {
|
|
145
|
+
root.flags = f & -2 | 32 /* Checking */;
|
|
146
|
+
let base = top, n = root, e = root.deps;
|
|
147
|
+
try {
|
|
148
|
+
for (; ; ) {
|
|
149
|
+
settled: {
|
|
150
|
+
for (; e !== null; ) {
|
|
151
|
+
let s = e.from, sf = s.flags;
|
|
152
|
+
if ((sf & 39) !== 0) {
|
|
153
|
+
if ((sf & 36) !== 0)
|
|
154
|
+
throw new Error("Cycle detected");
|
|
155
|
+
if ((sf & 2 /* Dirty */) === 0) {
|
|
156
|
+
s.flags = sf & -2 | 32 /* Checking */, stack[top++] = e, n = s, e = s.deps;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
exec(s);
|
|
160
|
+
}
|
|
161
|
+
if (s.ver !== e.ver) {
|
|
162
|
+
n.fn !== null && exec(n);
|
|
163
|
+
break settled;
|
|
164
|
+
}
|
|
165
|
+
e = e.next;
|
|
166
|
+
}
|
|
167
|
+
n.flags &= -33;
|
|
168
|
+
}
|
|
169
|
+
for (; ; ) {
|
|
170
|
+
if (top === base) {
|
|
171
|
+
trim();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
let up = stack[--top];
|
|
175
|
+
if (stack[top] = null, n = up.to, up.from.ver === up.ver) {
|
|
176
|
+
e = up.next;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
n.fn !== null && exec(n);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
} catch (error) {
|
|
183
|
+
for (n.fn !== null && (n.flags = (n.flags | 2 /* Dirty */) & -33); top > base; ) {
|
|
184
|
+
let p = stack[--top].to;
|
|
185
|
+
p.fn !== null && (p.flags = (p.flags | 2 /* Dirty */) & -33), stack[top] = null;
|
|
186
|
+
}
|
|
187
|
+
throw trim(), error;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function check(w) {
|
|
191
|
+
let tentative = w.gen + 1 & 1073741823 /* Mask */, e = w.deps;
|
|
192
|
+
if ((w.flags & 2 /* Dirty */) === 0)
|
|
193
|
+
for (; e !== null; e = e.next) {
|
|
194
|
+
let s = e.from;
|
|
195
|
+
if ((s.flags & 39) !== 0 && e.gen !== tentative && pull(s), s.ver !== e.ver) {
|
|
196
|
+
w.flags |= 2 /* Dirty */, e = e.next;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
for (; e !== null; e = e.next) {
|
|
201
|
+
let s = e.from;
|
|
202
|
+
(s.flags & 39) !== 0 && e.gen !== tentative && pull(s);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function untracked(fn) {
|
|
206
|
+
let prev = active;
|
|
207
|
+
active = null;
|
|
208
|
+
try {
|
|
209
|
+
return fn();
|
|
210
|
+
} finally {
|
|
211
|
+
active = prev;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function exec(n) {
|
|
215
|
+
let prev = active, prevCursor = cursor, base = top;
|
|
216
|
+
n.flags = n.flags & -36 | 4 /* Busy */, active = n, cursor = null;
|
|
217
|
+
let value;
|
|
218
|
+
try {
|
|
219
|
+
value = n.fn(n.value);
|
|
220
|
+
} catch (error) {
|
|
221
|
+
let last2 = cursor;
|
|
222
|
+
throw active = prev, cursor = prevCursor, fail(n, base, last2), error;
|
|
223
|
+
}
|
|
224
|
+
let last = cursor;
|
|
225
|
+
active = prev, cursor = prevCursor;
|
|
226
|
+
let f = n.flags;
|
|
227
|
+
if (last !== null && last.from.slot === last && unindex(n, base), n.flags = f & -5, n.fn === null) return detach(n);
|
|
228
|
+
(last === null ? n.deps : last.next) !== null && cut(n, last), n.gen = n.gen + 1 & 1073741823 /* Mask */, (n.gen & SETTLE) === 0 && settle(n), Object.is(value, n.value) === !1 && (n.value = value, n.ver = n.ver + 1 & 1073741823 /* Mask */);
|
|
229
|
+
}
|
|
230
|
+
function fail(n, base, last) {
|
|
231
|
+
if (last !== null && last.from.slot === last && unindex(n, base), n.flags &= -5, n.fn === null) return detach(n);
|
|
232
|
+
n.flags |= 2 /* Dirty */;
|
|
233
|
+
let tentative = n.gen + 1 & 1073741823 /* Mask */;
|
|
234
|
+
for (let e = last === null ? n.deps : last.next; e !== null; ) {
|
|
235
|
+
let after = e.next;
|
|
236
|
+
if (e.gen === tentative) {
|
|
237
|
+
let before = e.prev;
|
|
238
|
+
before !== null ? before.next = after : n.deps = after, after !== null && (after.prev = before), unsub(e), e.prev = null, e.next = null;
|
|
239
|
+
}
|
|
240
|
+
e = after;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function dispose(n) {
|
|
244
|
+
n.fn !== null && (n.fn = null, (n.flags & 4 /* Busy */) === 0 && detach(n));
|
|
245
|
+
}
|
|
246
|
+
function detach(n) {
|
|
247
|
+
cut(n, null), n.flags &= -36;
|
|
248
|
+
}
|
|
249
|
+
function index(c, next) {
|
|
250
|
+
let unread = !1;
|
|
251
|
+
for (let e = c.deps; e !== null; e = e.next)
|
|
252
|
+
e === next && (unread = !0), unread && (e.ver = UNREAD), claim(e.from, e);
|
|
253
|
+
}
|
|
254
|
+
function claim(s, e) {
|
|
255
|
+
let cell = s.slot;
|
|
256
|
+
cell !== null && (stack[top++] = cell), s.slot = e;
|
|
257
|
+
}
|
|
258
|
+
function unindex(n, base) {
|
|
259
|
+
for (let e = n.deps; e !== null; e = e.next) e.from.slot = null;
|
|
260
|
+
for (; top > base; ) {
|
|
261
|
+
let cell = stack[--top];
|
|
262
|
+
stack[top] = null, cell.from.slot = cell;
|
|
263
|
+
}
|
|
264
|
+
trim();
|
|
265
|
+
}
|
|
266
|
+
function link(c, s, last, next) {
|
|
267
|
+
let tail = s.lastSub, e = {
|
|
268
|
+
from: s,
|
|
269
|
+
to: c,
|
|
270
|
+
ver: s.ver,
|
|
271
|
+
gen: c.gen + 1 & 1073741823 /* Mask */,
|
|
272
|
+
prev: last,
|
|
273
|
+
next,
|
|
274
|
+
prevSub: tail,
|
|
275
|
+
nextSub: null
|
|
276
|
+
};
|
|
277
|
+
last !== null ? last.next = e : c.deps = e, next !== null && (next.prev = e), tail !== null ? tail.nextSub = e : s.subs = e, s.lastSub = e, cursor = e;
|
|
278
|
+
}
|
|
279
|
+
function miss(c, s, last, next) {
|
|
280
|
+
if (last !== null) {
|
|
281
|
+
let from = last.from;
|
|
282
|
+
if (from === s)
|
|
283
|
+
return;
|
|
284
|
+
if (from.slot === last) return slot(c, s, last, next);
|
|
285
|
+
}
|
|
286
|
+
let found, first = s.subs;
|
|
287
|
+
if (first === null) return link(c, s, last, next);
|
|
288
|
+
if (next === null || next.ver !== UNREAD) {
|
|
289
|
+
let e = next !== null ? next.next : null, budget = SCAN;
|
|
290
|
+
for (; e !== null && e.from !== s && --budget !== 0; ) e = e.next;
|
|
291
|
+
if (e !== null && e.from === s)
|
|
292
|
+
return e.ver = s.ver, cursor = e, move(c, e, last, next);
|
|
293
|
+
let p = last !== null ? last.prev : null;
|
|
294
|
+
for (budget = SCAN; p !== null && p.from !== s && --budget !== 0; ) p = p.prev;
|
|
295
|
+
if (p !== null && p.from === s)
|
|
296
|
+
return;
|
|
297
|
+
found = e === null && p === null ? null : pair(first, c), found != null && begin(c, found, first, next);
|
|
298
|
+
} else found = pair(first, c);
|
|
299
|
+
if (found === null) return link(c, s, last, next);
|
|
300
|
+
if (found !== void 0) return take(c, found, s, last, next);
|
|
301
|
+
index(c, next), slot(c, s, last, next);
|
|
302
|
+
}
|
|
303
|
+
function slot(c, s, last, next) {
|
|
304
|
+
let cell = s.slot;
|
|
305
|
+
if (cell !== null && cell.to === c) return take(c, cell, s, last, next);
|
|
306
|
+
link(c, s, last, next), claim(s, cursor);
|
|
307
|
+
}
|
|
308
|
+
function pair(first, c) {
|
|
309
|
+
let budget = SCAN;
|
|
310
|
+
for (let e = first; e !== null; e = e.nextSub) {
|
|
311
|
+
if (e.to === c) return e;
|
|
312
|
+
if (--budget === 0) return;
|
|
313
|
+
}
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
function begin(c, e, first, next) {
|
|
317
|
+
if (next !== null) {
|
|
318
|
+
if (e !== first) return index(c, next);
|
|
319
|
+
for (let u = next; u !== null; u = u.next)
|
|
320
|
+
u.ver = UNREAD;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function take(c, e, s, last, next) {
|
|
324
|
+
e.ver === UNREAD && (e.ver = s.ver, move(c, e, last, next), cursor = e);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// src/host.ts
|
|
328
|
+
var queue = [], size = 0, depth = 0, draining = !1;
|
|
329
|
+
function wake2(w) {
|
|
330
|
+
let flags = w.flags;
|
|
331
|
+
(flags & 192) === 64 /* Auto */ && (w.flags = flags | 128 /* Queued */, queue[size++] = w);
|
|
332
|
+
}
|
|
333
|
+
onWake(wake2);
|
|
334
|
+
function watcher(fn, auto) {
|
|
335
|
+
return node(
|
|
336
|
+
fn,
|
|
337
|
+
void 0,
|
|
338
|
+
19 | (auto ? 64 /* Auto */ : 0)
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
function run(w) {
|
|
342
|
+
let flags = w.flags;
|
|
343
|
+
if (w.fn === null || (flags & 33) === 0) return;
|
|
344
|
+
if (w.flags = flags & -34, (flags & 1 /* Stale */) !== 0)
|
|
345
|
+
try {
|
|
346
|
+
check(w);
|
|
347
|
+
} catch (error) {
|
|
348
|
+
throw w.flags |= 1 /* Stale */, error;
|
|
349
|
+
}
|
|
350
|
+
if ((w.flags & 2 /* Dirty */) === 0 || w.fn === null) return;
|
|
351
|
+
let cleanup = w.value;
|
|
352
|
+
typeof cleanup == "function" && (w.value = void 0, untracked(cleanup), w.fn === null) || exec(w);
|
|
353
|
+
}
|
|
354
|
+
function stop(w) {
|
|
355
|
+
if (w.fn === null) return;
|
|
356
|
+
let cleanup = w.value;
|
|
357
|
+
w.value = void 0, dispose(w), typeof cleanup == "function" && untracked(cleanup);
|
|
358
|
+
}
|
|
359
|
+
function flush() {
|
|
360
|
+
size === 0 || draining || depth !== 0 || drainNow();
|
|
361
|
+
}
|
|
362
|
+
function drainNow() {
|
|
363
|
+
draining = !0, drain(!1, void 0);
|
|
364
|
+
}
|
|
365
|
+
function start(w) {
|
|
366
|
+
if (draining || depth !== 0 || size !== 0)
|
|
367
|
+
return wake2(w), flush();
|
|
368
|
+
draining = !0;
|
|
369
|
+
try {
|
|
370
|
+
exec(w);
|
|
371
|
+
} catch (error) {
|
|
372
|
+
return drain(!0, error);
|
|
373
|
+
}
|
|
374
|
+
drain(!1, void 0);
|
|
375
|
+
}
|
|
376
|
+
function drain(failed, first) {
|
|
377
|
+
for (let i = 0; i < size; i++) {
|
|
378
|
+
let queuedWatcher = queue[i];
|
|
379
|
+
queue[i] = null, queuedWatcher.flags &= -129;
|
|
380
|
+
try {
|
|
381
|
+
run(queuedWatcher);
|
|
382
|
+
} catch (error) {
|
|
383
|
+
failed || (first = error), failed = !0;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (size = 0, draining = !1, failed) throw first;
|
|
387
|
+
}
|
|
388
|
+
function batch(fn) {
|
|
389
|
+
depth++;
|
|
390
|
+
try {
|
|
391
|
+
return fn();
|
|
392
|
+
} finally {
|
|
393
|
+
--depth === 0 && flush();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// src/index.ts
|
|
398
|
+
function signal(value) {
|
|
399
|
+
return node(null, value, 0);
|
|
400
|
+
}
|
|
401
|
+
function computed(fn, initial) {
|
|
402
|
+
return node(fn, initial, 2 /* Dirty */);
|
|
403
|
+
}
|
|
404
|
+
function effect(fn) {
|
|
405
|
+
let effectNode = watcher(fn, !0);
|
|
406
|
+
try {
|
|
407
|
+
start(effectNode);
|
|
408
|
+
} catch (error) {
|
|
409
|
+
throw stop(effectNode), error;
|
|
410
|
+
}
|
|
411
|
+
return effectNode;
|
|
412
|
+
}
|
|
413
|
+
var get = read, peek2 = peek;
|
|
414
|
+
function set(source, value) {
|
|
415
|
+
write(source, value), size !== 0 && !draining && depth === 0 && drainNow();
|
|
416
|
+
}
|
|
417
|
+
function update(source, fn) {
|
|
418
|
+
set(
|
|
419
|
+
source,
|
|
420
|
+
untracked(() => fn(source.value))
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
function dispose2(target) {
|
|
424
|
+
let targetNode = target;
|
|
425
|
+
(targetNode.flags & 16 /* Watch */) !== 0 ? stop(targetNode) : dispose(targetNode);
|
|
426
|
+
}
|
|
427
|
+
//# sourceMappingURL=index.development.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../src/graph.ts", "../src/kernel.ts", "../src/host.ts"],
|
|
4
|
+
"sourcesContent": ["// Public API: signal, computed, effect, get, peek, set, update, dispose,\n// batch, untracked. A handle is the node itself: nothing is allocated besides\n// the node, and handle <-> node conversions are type assertions only (no\n// runtime wrapper). Every operation here exposes existing kernel and host\n// semantics; none adds state.\nimport { Flag } from \"./graph\";\nimport { depth, drainNow, draining, size, start, stop, watcher } from \"./host\";\nimport {\n dispose as detach,\n node,\n peek as refresh,\n read,\n untracked,\n write,\n} from \"./kernel\";\nimport type { Fn, Node } from \"./graph\";\n\nexport { batch } from \"./host\";\nexport { untracked } from \"./kernel\";\n\n// Public handles: compile-time brands over the node, which is the runtime\n// handle. Variance is explicit: reading is covariant, a signal is also\n// written, so it is invariant.\ndeclare const READ: unique symbol;\ndeclare const WRITE: unique symbol;\ndeclare const COMPUTED: unique symbol;\ndeclare const EFFECT: unique symbol;\n\n/** Anything `get` accepts. */\nexport interface Readable<out T> {\n readonly [READ]: T;\n}\n\nexport interface Signal<in out T> extends Readable<T> {\n readonly [WRITE]: (value: T) => void;\n}\n\nexport interface Computed<out T> extends Readable<T> {\n readonly [COMPUTED]: true;\n}\n\nexport interface Effect {\n readonly [EFFECT]: true;\n}\n\nexport function signal<T>(value: T): Signal<T> {\n return node(null, value, 0) as unknown as Signal<T>;\n}\n\n/**\n * `fn` receives `prev`, the last successfully committed value: `initial`\n * (or undefined) before the first commit, unchanged by a failed run.\n * Returning `prev` itself is a cutoff: consumers do not rerun, so custom\n * equality is `(prev) => (equal(prev, next) ? prev : next)`.\n */\nexport function computed<T>(fn: (prev: T | undefined) => T): Computed<T>;\nexport function computed<T>(fn: (prev: T) => T, initial: T): Computed<T>;\nexport function computed<T>(\n fn: (prev: T | undefined) => T,\n initial?: T,\n): Computed<T> {\n return node(fn as Fn, initial, Flag.Dirty) as unknown as Computed<T>;\n}\n\n/** Runs now (or when the enclosing batch or drain ends), then on every change it read. */\nexport function effect(fn: () => void | (() => void)): Effect {\n const effectNode = watcher(fn, true);\n\n try {\n start(effectNode);\n } catch (error) {\n stop(effectNode);\n throw error;\n }\n\n return effectNode as unknown as Effect;\n}\n\n/**\n * Kernel `read` itself under the public type: a signal's flags are 0, so one\n * read path serves signals and computeds, and no surface function stands in\n * front of it.\n */\nexport const get: <T>(source: Readable<T>) => T = read as never;\n\n/** `get` without observation: up to date, but the running consumer does not depend on it. */\nexport const peek: <T>(source: Readable<T>) => T = refresh as never;\n\n/** Writes, then runs what the write scheduled; a write that woke nothing stops at one load. */\nexport function set<T>(source: Signal<T>, value: T): void {\n write(source as unknown as Node, value);\n\n if (size !== 0 && !draining && depth === 0) drainNow();\n}\n\n/**\n * `set(source, fn(current))`. An update is a write, not an observation:\n * `fn` runs untracked, so neither `source` nor what `fn` reads becomes a\n * dependency of the running consumer. If `fn` throws, nothing is written.\n */\nexport function update<T>(source: Signal<T>, fn: (value: T) => T): void {\n set(\n source,\n untracked(() => fn((source as unknown as Node).value as T)),\n );\n}\n\nexport function dispose(target: Computed<unknown> | Effect): void {\n const targetNode = target as unknown as Node;\n\n if ((targetNode.flags & Flag.Watch) !== 0) stop(targetNode);\n else detach(targetNode);\n}\n", "import { stats } from \"./instrumentation\";\n\n// Compile-time vocabulary of the runtime graph. Nothing here exists at runtime.\n\n// The aliases name different facts but do not brand numbers: counters wrap at\n// MASK and edge versions can carry UNREAD.\nexport type Flags = number;\nexport type Version = number;\nexport type Generation = number;\n\n/** A computed's or watcher's body; a signal has none. */\nexport type Fn = (prev: unknown) => unknown;\n/** A watcher's cleanup, run untracked. */\nexport type Cleanup = () => unknown;\n\nexport interface Node {\n flags: Flags;\n value: unknown;\n /** Bumps on every Object.is-visible change of value. */\n ver: Version;\n /** null for a signal and for a disposed node. */\n fn: Fn | null;\n /** Sources, in read order. */\n deps: Edge | null;\n /** Subscribers, in birth order. */\n subs: Edge | null;\n lastSub: Edge | null;\n /** While a reader indexes: this node's edge into that reader. */\n slot: Edge | null;\n /** Successful runs; edges born since the last one are tentative. */\n gen: Generation;\n}\n\nexport interface Edge {\n readonly from: Node;\n readonly to: Node;\n /** from.ver when `to` read it; UNREAD in the pass's marked unread suffix. */\n ver: Version | typeof UNREAD;\n /** to.gen + 1 at birth: tentative while it still equals to.gen + 1. */\n gen: Generation;\n prev: Edge | null;\n next: Edge | null;\n prevSub: Edge | null;\n nextSub: Edge | null;\n}\n\n/** Shared LIFO of the kernel's walks: resume edges and displaced slot cells. */\nexport type WorkStack = (Edge | null)[];\n\n// Flag layout and constants used by the kernel and host.\nexport const enum Flag {\n /** A source below may have changed; a watcher must validate. */\n Stale = 1 << 0,\n /** Must run: first run, failed run, or a direct source changed. */\n Dirty = 1 << 1,\n /** Its run is on the stack. */\n Busy = 1 << 2,\n /** A watcher: handed to the host, never read. */\n Watch = 1 << 4,\n /** Woken by signals only; computed sources need no validation. */\n Woken = 1 << 5,\n /**\n * Development builds only (C1 is a precondition): a computed whose\n * validation is on the stack, no longer STALE and not yet clean. WOKEN's\n * bit, so every mask stays a byte: WOKEN is a watcher's, CHECKING a\n * computed's, and no node is both. A production build never sets it, so\n * a mask that tests it is inert there.\n */\n Checking = 1 << 5,\n /** Host policy: scheduled by the reference host. */\n Auto = 1 << 6,\n /** Host policy: already in its queue. */\n Queued = 1 << 7,\n}\n\n/** Counters wrap inside the SMI range. */\nexport const enum CounterLimit {\n Mask = 0x3fffffff,\n}\n\n/** edge.ver of an edge the marked or indexed run has not read yet. */\nexport const UNREAD = -1;\n/**\n * A committed edge keeps its birth generation, and generations wrap: an edge\n * 2^30 - 1 commits old would read as born in the next run (tentative). So a\n * node restamps its edges with its own generation whenever a commit makes\n * `gen & SETTLE` zero, twice a cycle, and no edge falls that far behind.\n */\nexport const SETTLE = 0x1fffffff;\n/** Scan budget of every bounded search: a constant keeps a run linear. */\nexport const SCAN = 8;\n/**\n * Work-stack slots kept at rest, and the length past which the outermost\n * walk's end cuts the stack back to them. The gap keeps walks only a little\n * deeper than KEEP from cutting and regrowing on every pass.\n */\nexport const KEEP = 256;\nexport const TRIM = 512;\n\n// Intrusive graph operations independent of the execution context.\n\nexport function node(fn: Node[\"fn\"], value: unknown, flags: Flags): Node {\n return {\n flags,\n value,\n ver: 0,\n fn,\n deps: null,\n subs: null,\n lastSub: null,\n slot: null,\n gen: 0,\n };\n}\n\n/** Move an unread edge (strictly after `next`) up to the cursor. */\nexport function move(c: Node, e: Edge, last: Edge | null, next: Edge): void {\n const before = e.prev!;\n const after = e.next;\n before.next = after;\n\n if (after !== null) after.prev = before;\n\n e.prev = last;\n e.next = next;\n\n if (last !== null) last.next = e;\n else c.deps = e;\n next.prev = e;\n}\n\n/** Remove every edge of `c` after `last` (all of them when null). */\nexport function cut(c: Node, last: Edge | null): void {\n let e = last === null ? c.deps : last.next;\n\n if (e === null) return;\n\n if (last === null) c.deps = null;\n else last.next = null;\n // The cut head's back pointer would tie this garbage to the live list, and\n // so to garbage cut later: old garbage keeps newer garbage alive.\n e.prev = null;\n\n for (; e !== null; e = e.next) unsub(e);\n}\n\n/** Restamp every edge of `c`, all of them committed, with its generation (SETTLE). */\nexport function settle(c: Node): void {\n const gen = c.gen;\n\n for (let e = c.deps; e !== null; e = e.next) e.gen = gen;\n}\n\n/** Take an edge out of its source's subscriber list. */\nexport function unsub(e: Edge): void {\n if (__STATS__) stats.unlinks++;\n\n const s = e.from;\n const before = e.prevSub;\n const after = e.nextSub;\n\n if (before !== null) before.nextSub = after;\n else s.subs = after;\n\n if (after !== null) after.prevSub = before;\n else s.lastSub = before;\n // Subscribers are in birth order, so an old removed edge would point at a\n // much younger one and keep it (and its watcher) alive across scavenges.\n e.prevSub = null;\n e.nextSub = null;\n}\n", "// Reactive kernel: tracking, propagation, validation and execution.\n// Detached edges must not retain pointers into live lists.\n// See research/LOG.md for representation rationale.\n\nimport {\n Flag,\n KEEP,\n CounterLimit,\n SCAN,\n SETTLE,\n TRIM,\n UNREAD,\n cut,\n move,\n settle,\n unsub,\n} from \"./graph\";\nimport type { Edge, Flags, Node, WorkStack } from \"./graph\";\nimport { stats } from \"./instrumentation\";\n\nexport { node } from \"./graph\";\nexport { stats } from \"./instrumentation\";\n\n/** The running consumer, or null outside a tracking pass. */\nlet active: Node | null = null;\n/** Last accepted edge of the running pass; saved with `active` on nesting. */\nlet cursor: Edge | null = null;\n/**\n * One LIFO work stack shared by all walks: sibling edges to resume (mark),\n * edges to climb back through (pull), and slot cells an indexed run displaced.\n * Every walk pops back to its own base before returning. Once the stack is\n * empty, an oversized buffer is cut back (`trim`).\n */\nconst stack: WorkStack = new Array(256).fill(null);\n/** First free index of `stack`. */\nlet top = 0;\n/** Longest the work stack has been when `trim` cut it (research). */\nlet peak = 0;\nlet wake: (w: Node) => void = () => {};\n\n/**\n * The host is told about every watcher a write or mark reaches. It owns the\n * deduplication (a queued watcher is not queued again), so a watcher left\n * STALE by a failed check is delivered again by the next push.\n */\nexport function onWake(fn: (w: Node) => void): void {\n wake = fn;\n}\n\n/** No tracked consumer or occupied work-stack slot (tests; untracked suspends cursor). */\nexport function idle(): boolean {\n return active === null && top === 0;\n}\n\n/**\n * Deepest work-stack top reached so far (research). Walks null the slots\n * they pop and only `trim` shrinks the array, so the high-water mark is its\n * length or the longest length `trim` cut.\n */\nexport function stackHighWater(): number {\n return stack.length > peak ? stack.length : peak;\n}\n\n/** Slots the work stack holds now (tests). */\nexport function stackLength(): number {\n return stack.length;\n}\n\n/**\n * When empty, cut a stack that a deep walk grew past TRIM back to KEEP slots,\n * so one deep walk does not hold its depth in memory for good. Setting the\n * length right-trims V8's backing store in place: no allocation, and the\n * array stays packed.\n *\n * Only walks that push check at their exits: mark, verify (also on failure),\n * and unindex. An empty stack has no entries to preserve even if a user\n * callback or a graph cursor is suspended in local variables. `active`\n * is a tracking context, not a call-depth counter (untracked clears it).\n * The length test comes first: a small buffer pays no load of `top`.\n */\nfunction trim(): void {\n if (stack.length > TRIM && top === 0) {\n if (__STATS__ && stack.length > peak) peak = stack.length;\n\n stack.length = KEEP;\n }\n}\n\n// ------------------------------------------------------------------- write\n\nexport function write(s: Node, value: unknown): void {\n if (Object.is(s.value, value)) return;\n\n s.value = value;\n s.ver = (s.ver + 1) & CounterLimit.Mask;\n\n for (let e = s.subs; e !== null; e = e.nextSub) {\n const n = e.to;\n const f = n.flags;\n\n if (__STATS__) stats.marks++;\n\n if ((f & Flag.Busy) !== 0) {\n // Running: it may not have read s yet, so versions decide.\n if ((f & Flag.Stale) === 0) {\n n.flags = f | Flag.Stale;\n\n if ((f & Flag.Watch) !== 0) wake(n);\n else {\n const subs = n.subs;\n\n if (subs !== null) mark(subs);\n }\n }\n } else if ((f & Flag.Watch) !== 0) {\n n.flags = f | Flag.Dirty | Flag.Woken;\n\n wake(n);\n } else if ((f & Flag.Stale) !== 0) {\n n.flags = f | Flag.Dirty;\n } else {\n n.flags = f | Flag.Dirty | Flag.Stale;\n\n const subs = n.subs;\n\n if (subs !== null) mark(subs);\n }\n }\n}\n\n/** Mark everything below the subscriber list `first` STALE, depth first. */\nfunction mark(first: Edge): void {\n const base = top;\n let e: Edge | null = first;\n\n for (;;) {\n while (e !== null) {\n const n: Node = e.to;\n const f = n.flags;\n\n if (__STATS__) stats.marks++;\n // A watcher has no subscribers; the host deduplicates, so it is always told.\n if ((f & Flag.Watch) !== 0) {\n n.flags = f | Flag.Stale;\n wake(n);\n } else if ((f & Flag.Stale) === 0) {\n n.flags = f | Flag.Stale;\n\n const subs = n.subs;\n\n if (subs !== null) {\n const next = e.nextSub;\n\n if (next !== null) stack[top++] = next;\n\n e = subs;\n continue;\n }\n }\n e = e.nextSub;\n }\n\n if (top === base) {\n trim();\n return;\n }\n\n e = stack[--top] as Edge;\n stack[top] = null;\n }\n}\n\n// -------------------------------------------------------------------- read\n\n/** Bring `n` up to date if it is a stale computed, then track it. */\nexport function read(n: Node): unknown {\n const value = peek(n);\n const c = active;\n\n if (c !== null) {\n if (__STATS__) stats.reads++;\n\n const last = cursor;\n const next = last === null ? c.deps : last.next;\n\n if (next !== null && next.from === n) {\n if (__STATS__) stats.hits++;\n\n cursor = next;\n next.ver = n.ver;\n } else miss(c, n, last, next);\n }\n return value;\n}\n\n/** `read` without its tracking half: bring `n` up to date, record no relation. */\nexport function peek(n: Node): unknown {\n if ((n.flags & (Flag.Stale | Flag.Dirty | Flag.Busy | Flag.Checking)) !== 0)\n pull(n);\n\n return n.value;\n}\n\n/**\n * Pull a computed up to date. Existential, in read order: sources are\n * checked first to last and the first changed one makes the node run. A\n * STALE source is descended into (the stack keeps the edge to climb back\n * through); a DIRTY one runs. A throw leaves every node on the walk DIRTY.\n * A node whose run is on the stack is a cycle. A development build also\n * diagnoses a node whose validation is on the stack (CHECKING): C1 is a\n * precondition, so its committed value never answers such a demand there.\n */\nfunction pull(root: Node): void {\n const f = root.flags;\n\n if ((f & (Flag.Busy | Flag.Checking)) !== 0)\n throw new Error(\"Cycle detected\");\n\n if ((f & Flag.Dirty) !== 0) return exec(root);\n\n verify(root, f);\n}\n\n/**\n * The walk of `pull` for a STALE node that is not DIRTY, BUSY or CHECKING;\n * kept apart so `pull` stays small. A node disposed during the walk is not\n * run (W3), nor left DIRTY.\n *\n * Development builds diagnose C1: a node on the walk is CHECKING until it is\n * clean or runs, and a source on the stack (BUSY or CHECKING) is a cycle\n * even when no push marked it again, since its version is not yet a fact.\n * CHECKING is set by the store that clears STALE and cleared by `exec` as it\n * sets BUSY; only a node found clean pays a store of its own. Production\n * builds compile all of it away.\n */\nfunction verify(root: Node, f: Flags): void {\n root.flags = __DEV__ ? (f & ~Flag.Stale) | Flag.Checking : f & ~Flag.Stale;\n const base = top;\n let n = root;\n let e = root.deps;\n\n try {\n for (;;) {\n settled: {\n while (e !== null) {\n const s: Node = e.from;\n const sf = s.flags;\n\n if (__STATS__) stats.checks++;\n\n if (\n (sf &\n (__DEV__\n ? Flag.Stale | Flag.Dirty | Flag.Busy | Flag.Checking\n : Flag.Stale | Flag.Dirty)) !==\n 0\n ) {\n if ((sf & (Flag.Busy | Flag.Checking)) !== 0)\n throw new Error(\"Cycle detected\");\n\n if ((sf & Flag.Dirty) === 0) {\n s.flags = __DEV__\n ? (sf & ~Flag.Stale) | Flag.Checking\n : sf & ~Flag.Stale;\n stack[top++] = e;\n n = s;\n e = s.deps;\n continue;\n }\n exec(s);\n }\n\n if (s.ver !== e.ver) {\n if (n.fn !== null) exec(n);\n break settled;\n }\n e = e.next;\n }\n // Every source unchanged: clean, and no longer on the walk.\n if (__DEV__) n.flags &= ~Flag.Checking;\n }\n\n // Climb; a parent whose child changed runs as well.\n for (;;) {\n if (top === base) {\n trim();\n\n return;\n }\n\n const up = stack[--top] as Edge;\n stack[top] = null;\n n = up.to;\n\n if (up.from.ver === up.ver) {\n e = up.next;\n break;\n }\n\n if (n.fn !== null) exec(n);\n }\n }\n } catch (error) {\n if (n.fn !== null)\n n.flags = __DEV__\n ? (n.flags | Flag.Dirty) & ~Flag.Checking\n : n.flags | Flag.Dirty;\n\n while (top > base) {\n const p = (stack[--top] as Edge).to;\n\n if (p.fn !== null)\n p.flags = __DEV__\n ? (p.flags | Flag.Dirty) & ~Flag.Checking\n : p.flags | Flag.Dirty;\n stack[top] = null;\n }\n trim();\n throw error;\n }\n}\n\n/**\n * Universal check of a watcher: pull every committed source, so a throwing\n * one surfaces before any irreversible step. Marks DIRTY on change. Tentative\n * edges (reads of a failed run) only wake; they exist only while a run is\n * owed, and then versions need no comparison.\n */\nexport function check(w: Node): void {\n const tentative = (w.gen + 1) & CounterLimit.Mask;\n let e = w.deps;\n\n // Until a run is owed, versions decide; then only the pulls remain. A\n // development build pulls a source on the stack too, so the C1 diagnosis\n // fails here, before the cleanup (P4).\n if ((w.flags & Flag.Dirty) === 0) {\n for (; e !== null; e = e.next) {\n const s = e.from;\n\n if (__STATS__) stats.checks++;\n\n if (\n (s.flags &\n (__DEV__\n ? Flag.Stale | Flag.Dirty | Flag.Busy | Flag.Checking\n : Flag.Stale | Flag.Dirty)) !==\n 0 &&\n e.gen !== tentative\n )\n pull(s);\n\n if (s.ver !== e.ver) {\n w.flags |= Flag.Dirty;\n e = e.next;\n break;\n }\n }\n }\n\n for (; e !== null; e = e.next) {\n if (__STATS__) stats.checks++;\n\n const s = e.from;\n\n if (\n (s.flags &\n (__DEV__\n ? Flag.Stale | Flag.Dirty | Flag.Busy | Flag.Checking\n : Flag.Stale | Flag.Dirty)) !==\n 0 &&\n e.gen !== tentative\n )\n pull(s);\n }\n}\n\nexport function untracked<T>(fn: () => T): T {\n const prev = active;\n active = null;\n\n try {\n return fn();\n } finally {\n active = prev;\n }\n}\n\n// --------------------------------------------------------------------- run\n\n/** Run `n.fn` as a tracking pass; commit value and edges on success. */\nexport function exec(n: Node): void {\n const prev = active;\n const prevCursor = cursor;\n const base = top;\n\n if (__STATS__) stats.runs++;\n // Cleared before the run: a push during it marks the node again. In a\n // development build a computed's validation ends here, BUSY taking over\n // from CHECKING; on a watcher the bit is WOKEN, which this run discharges.\n n.flags =\n (n.flags &\n ~(__DEV__\n ? Flag.Stale | Flag.Dirty | Flag.Checking\n : Flag.Stale | Flag.Dirty)) |\n Flag.Busy;\n active = n;\n cursor = null;\n let value: unknown;\n\n try {\n value = n.fn!(n.value);\n } catch (error) {\n const last = cursor as Edge | null;\n active = prev;\n cursor = prevCursor;\n fail(n, base, last);\n throw error;\n }\n const last = cursor as Edge | null;\n active = prev;\n cursor = prevCursor;\n const f = n.flags;\n\n if (last !== null && last.from.slot === last) unindex(n, base);\n\n n.flags = f & ~Flag.Busy;\n\n if (n.fn === null) return detach(n);\n // Commit only after a successful run. Dropping the unread suffix removes\n // sources that this pass no longer depends on.\n if ((last === null ? n.deps : last.next) !== null) cut(n, last);\n\n n.gen = (n.gen + 1) & CounterLimit.Mask;\n\n // Every edge is committed now; see SETTLE.\n if ((n.gen & SETTLE) === 0) settle(n);\n\n if (Object.is(value, n.value) === false) {\n n.value = value;\n n.ver = (n.ver + 1) & CounterLimit.Mask;\n }\n}\n\n/**\n * A failed run: keep committed edges and this run's reads as the wake set,\n * drop unread edges earlier failed runs left behind, owe a run.\n */\nfunction fail(n: Node, base: number, last: Edge | null): void {\n if (last !== null && last.from.slot === last) unindex(n, base);\n\n n.flags &= ~Flag.Busy;\n\n if (n.fn === null) return detach(n);\n\n n.flags |= Flag.Dirty;\n const tentative = (n.gen + 1) & CounterLimit.Mask;\n for (let e = last === null ? n.deps : last.next; e !== null;) {\n const after: Edge | null = e.next;\n\n if (e.gen === tentative) {\n const before = e.prev;\n\n if (before !== null) before.next = after;\n else n.deps = after;\n\n if (after !== null) after.prev = before;\n\n unsub(e);\n e.prev = null;\n e.next = null;\n }\n e = after;\n }\n}\n\n/** Detach `n` from its sources for good; inside its own run, at its end. */\nexport function dispose(n: Node): void {\n if (n.fn === null) return;\n\n n.fn = null;\n\n if ((n.flags & Flag.Busy) === 0) detach(n);\n}\n\nfunction detach(n: Node): void {\n cut(n, null);\n n.flags &= ~(Flag.Stale | Flag.Dirty | Flag.Woken);\n}\n\n// ---------------------------------------------------------------- tracking\n\n/** Put every edge of `c` into its source's slot; mark the unread ones. */\nexport function index(c: Node, next: Edge | null): void {\n if (__STATS__) stats.indexes++;\n\n let unread = false;\n\n for (let e = c.deps; e !== null; e = e.next) {\n if (__STATS__) stats.indexed++;\n\n if (e === next) unread = true;\n\n if (unread) e.ver = UNREAD;\n\n claim(e.from, e);\n }\n}\n\n/**\n * Point the source's slot at `e`, keeping a displaced cell to give back.\n * A cell's immutable `from` is its source, so the cell alone is enough.\n */\nexport function claim(s: Node, e: Edge): void {\n const cell = s.slot;\n\n if (cell !== null) stack[top++] = cell;\n s.slot = e;\n}\n\n/** Clear the run's slots, give back the cells it displaced. */\nfunction unindex(n: Node, base: number): void {\n for (let e = n.deps; e !== null; e = e.next) e.from.slot = null;\n\n while (top > base) {\n const cell = stack[--top] as Edge;\n stack[top] = null;\n cell.from.slot = cell;\n }\n trim();\n}\n\n/** A new edge at the cursor, appended to the source's subscribers. */\nexport function link(\n c: Node,\n s: Node,\n last: Edge | null,\n next: Edge | null,\n): void {\n if (__STATS__) stats.links++;\n\n const tail = s.lastSub;\n const e: Edge = {\n from: s,\n to: c,\n ver: s.ver,\n gen: (c.gen + 1) & CounterLimit.Mask,\n prev: last,\n next,\n prevSub: tail,\n nextSub: null,\n };\n\n if (last !== null) last.next = e;\n else c.deps = e;\n\n if (next !== null) next.prev = e;\n\n if (tail !== null) tail.nextSub = e;\n else s.subs = e;\n s.lastSub = e;\n cursor = e;\n}\n\n// Exact dependency tracking: resolve a read outside the stable cursor path.\n// Proofs come cheapest first: the cursor (in `read`), the previous read, a\n// source nobody reads, bounded scans of this reader's list, then the source's\n// first subscribers. Only a source with more subscribers than the budget needs\n// the slot index. Slot walks and edge creation remain in the kernel because\n// they mutate its shared stack.\n\n/**\n * A read that is not the next edge in read order. Every answer is exact. A\n * repeated read keeps the version of the pass's first observation (P5): a\n * change between the two reads stays visible to the next validation.\n */\nfunction miss(c: Node, s: Node, last: Edge | null, next: Edge | null): void {\n if (last !== null) {\n const from = last.from;\n\n if (from === s) {\n if (__STATS__) stats.repeats++;\n\n return;\n }\n // An indexed pass owns its cursor's source slot. Nested passes restore it.\n if (from.slot === last) return slot(c, s, last, next);\n }\n /** The pair's edge through the source's subscribers; undefined: unknown. */\n let found: Edge | null | undefined;\n const first = s.subs;\n\n // A source without subscribers is absent, whatever the unread suffix mode.\n if (first === null) return link(c, s, last, next);\n\n // Marking, moves and links preserve a continuous UNREAD suffix.\n if (next === null || next.ver !== UNREAD) {\n // An edge found by a scan is the pair's only one; absence needs one side\n // scanned completely (this reader's list, or the source's subscribers).\n let e = next !== null ? next.next : null;\n let budget = SCAN;\n\n while (e !== null && e.from !== s && --budget !== 0) e = e.next;\n\n if (e !== null && e.from === s) {\n if (__STATS__) stats.scans++;\n\n e.ver = s.ver;\n cursor = e;\n return move(c, e, last, next!);\n }\n let p = last !== null ? last.prev : null;\n budget = SCAN;\n\n while (p !== null && p.from !== s && --budget !== 0) p = p.prev;\n\n if (p !== null && p.from === s) {\n if (__STATS__) stats.dups++;\n\n return;\n }\n\n // Absent if this reader's whole list was scanned; otherwise the source's\n // first subscribers decide. Found as the first one: a lookup through the\n // subscribers costs no load beyond the read itself, so mark the unread\n // suffix and let the rest of the pass find its pairs that way, with no\n // slot to fill or clear. Found deeper: every lookup would walk other\n // readers' edges, so index; either way the found edge is taken at once.\n found = e === null && p === null ? null : pair(first, c);\n\n if (found !== null && found !== undefined) begin(c, found, first, next);\n } else found = pair(first, c);\n\n if (found === null) return link(c, s, last, next);\n\n if (found !== undefined) return take(c, found, s, last, next);\n // Past the budget: index the pass, and the slot decides from here on.\n index(c, next);\n slot(c, s, last, next);\n}\n\n/** An indexed pass's lookup: the source's slot holds the pair's edge, or the pair is absent. */\nfunction slot(c: Node, s: Node, last: Edge | null, next: Edge | null): void {\n if (__STATS__) stats.lookups++;\n\n const cell = s.slot;\n\n if (cell !== null && cell.to === c) return take(c, cell, s, last, next);\n link(c, s, last, next);\n claim(s, cursor as Edge);\n}\n\n/**\n * The pair's edge among the source's first SCAN subscribers: null if the list\n * ends first (absent), undefined if the budget runs out (unknown).\n */\nfunction pair(first: Edge | null, c: Node): Edge | null | undefined {\n if (__STATS__) stats.lookups++;\n\n let budget = SCAN;\n\n for (let e = first; e !== null; e = e.nextSub) {\n if (e.to === c) return e;\n\n if (--budget === 0) return undefined;\n }\n return null;\n}\n\n/**\n * The pass's lookup from here on, decided by the found edge's place: the\n * source's first subscriber marks the unread suffix, from `next` on (a walk\n * over edges, not sources); deeper, index.\n */\nfunction begin(c: Node, e: Edge, first: Edge | null, next: Edge | null): void {\n if (next === null) return;\n\n if (e !== first) return index(c, next);\n\n if (__STATS__) stats.sweeps++;\n\n for (let u: Edge | null = next; u !== null; u = u.next) {\n if (__STATS__) stats.indexed++;\n\n u.ver = UNREAD;\n }\n}\n\n/**\n * A found edge: an unread one is observed and moves to the cursor; a repeated\n * read keeps its place and its first observation's version (P5).\n */\nfunction take(\n c: Node,\n e: Edge,\n s: Node,\n last: Edge | null,\n next: Edge | null,\n): void {\n if (e.ver !== UNREAD) {\n if (__STATS__) stats.dups++;\n\n return;\n }\n if (__STATS__) stats.moves++;\n\n e.ver = s.ver;\n move(c, e, last, next!);\n cursor = e;\n}\n", "// Policy around the kernel: the watcher lifecycle (check, consume the\n// cleanup, run), a FIFO queue for scheduled watchers, and batching.\nimport { Flag } from \"./graph\";\nimport type { Cleanup, Fn, Node } from \"./graph\";\nimport { check, dispose, exec, node, onWake, untracked } from \"./kernel\";\n\nconst queue: (Node | null)[] = [];\n// The host's registers. Exported so a write's caller can test for work\n// without a call into the host; ES bindings are read-only to importers, so\n// only this module writes them.\n/** Queued watchers. */\nexport let size = 0;\n/** Open batches. */\nexport let depth = 0;\n/** A drain loop is open. */\nexport let draining = false;\n\n/** Queue a scheduled watcher once; the kernel calls this when it wakes one. */\nexport function wake(w: Node): void {\n const flags = w.flags;\n\n if ((flags & (Flag.Auto | Flag.Queued)) !== Flag.Auto) return;\n\n w.flags = flags | Flag.Queued;\n queue[size++] = w;\n}\n\nonWake(wake);\n\n/** A watcher runs `fn` and keeps a returned function as its cleanup. */\nexport function watcher(fn: Fn, auto: boolean): Node {\n return node(\n fn,\n undefined,\n Flag.Watch | Flag.Stale | Flag.Dirty | (auto ? Flag.Auto : 0),\n );\n}\n\n/**\n * Check every committed source unless only signals woke it, then, if a run\n * is owed, consume the previous cleanup and run. A watcher neither STALE,\n * WOKEN is clean, or cold after a failure until a source changes. A failed\n * check leaves it STALE, so the next run checks again (V1) and the next push\n * finds it queued or delivers it again.\n * Precondition: its own run is not on the stack (flush is not reentrant).\n */\nexport function run(w: Node): void {\n const flags = w.flags;\n\n if (w.fn === null || (flags & (Flag.Stale | Flag.Woken)) === 0) return;\n\n w.flags = flags & ~(Flag.Stale | Flag.Woken);\n\n if ((flags & Flag.Stale) !== 0) {\n try {\n check(w);\n } catch (error) {\n w.flags |= Flag.Stale;\n throw error;\n }\n }\n\n if ((w.flags & Flag.Dirty) === 0 || w.fn === null) return;\n\n const cleanup = w.value;\n\n if (typeof cleanup === \"function\") {\n w.value = undefined;\n untracked(cleanup as Cleanup);\n\n if (w.fn === null) return;\n }\n exec(w);\n}\n\n/** Terminal: detach, then run the last cleanup outside tracking. */\nexport function stop(w: Node): void {\n if (w.fn === null) return;\n\n const cleanup = w.value;\n w.value = undefined;\n dispose(w);\n\n if (typeof cleanup === \"function\") untracked(cleanup as Cleanup);\n}\n\n/** Run queued watchers until the queue drains; rethrow the first error. */\nexport function flush(): void {\n if (size === 0 || draining || depth !== 0) return;\n\n drainNow();\n}\n\n/**\n * `flush` with its guard at the call site: a write's caller tests\n * `size !== 0 && !draining && depth === 0` first (the queue first, so a write\n * that woke nothing costs one load), and calls this only when there is work.\n */\nexport function drainNow(): void {\n draining = true;\n drain(false, undefined);\n}\n\n/**\n * A new scheduled watcher's first run. With no drain open, no batch and an\n * empty queue this is `wake(w); flush()` with the queue slot skipped: the\n * drain opens on `w` (so its run stays inside the drain loop, LOG 11), and a\n * fresh watcher has no sources to check and no cleanup, so `run` is `exec`.\n */\nexport function start(w: Node): void {\n if (draining || depth !== 0 || size !== 0) {\n wake(w);\n return flush();\n }\n draining = true;\n\n try {\n exec(w);\n } catch (error) {\n return drain(true, error);\n }\n drain(false, undefined);\n}\n\n/** The drain loop, opened by the caller: FIFO, the first error rethrown at the end. */\nfunction drain(failed: boolean, first: unknown): void {\n for (let i = 0; i < size; i++) {\n const queuedWatcher = queue[i]!;\n queue[i] = null;\n queuedWatcher.flags &= ~Flag.Queued;\n\n try {\n run(queuedWatcher);\n } catch (error) {\n if (!failed) first = error;\n\n failed = true;\n }\n }\n size = 0;\n draining = false;\n\n if (failed) throw first;\n}\n\nexport function batch<T>(fn: () => T): T {\n depth++;\n\n try {\n return fn();\n } finally {\n if (--depth === 0) flush();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAAA;AAAA,EAAA;AAAA;AAAA,cAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiFO,IAAM,SAAS,IAOT,SAAS,WAET,OAAO,GAMP,OAAO,KACP,OAAO;AAIb,SAAS,KAAK,IAAgB,OAAgB,OAAoB;AACvE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,KAAK;AAAA,IACL;AAAA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