@solidjs/signals 0.4.4 → 0.4.6
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/dist/dev.js +73 -52
- package/dist/node.cjs +381 -360
- package/dist/prod.js +381 -360
- package/dist/types/core/core.d.ts +3 -2
- package/dist/types/core/scheduler.d.ts +2 -2
- package/package.json +1 -1
package/dist/prod.js
CHANGED
|
@@ -39,7 +39,7 @@ function incrementClock() {
|
|
|
39
39
|
clock++;
|
|
40
40
|
}
|
|
41
41
|
var ActiveTransition = null;
|
|
42
|
-
var
|
|
42
|
+
var Unobserved = [];
|
|
43
43
|
var scheduled = false;
|
|
44
44
|
function schedule() {
|
|
45
45
|
if (scheduled)
|
|
@@ -49,12 +49,12 @@ function schedule() {
|
|
|
49
49
|
queueMicrotask(flush);
|
|
50
50
|
}
|
|
51
51
|
function notifyUnobserved() {
|
|
52
|
-
for (let i = 0; i <
|
|
53
|
-
const source =
|
|
54
|
-
if (!source.
|
|
55
|
-
|
|
52
|
+
for (let i = 0; i < Unobserved.length; i++) {
|
|
53
|
+
const source = Unobserved[i];
|
|
54
|
+
if (!source.b || !source.b.length)
|
|
55
|
+
Unobserved[i].da?.();
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
Unobserved = [];
|
|
58
58
|
}
|
|
59
59
|
var pureQueue = [];
|
|
60
60
|
var Queue = class {
|
|
@@ -64,8 +64,8 @@ var Queue = class {
|
|
|
64
64
|
e = [];
|
|
65
65
|
created = clock;
|
|
66
66
|
enqueue(type, fn) {
|
|
67
|
-
if (ActiveTransition && ActiveTransition.
|
|
68
|
-
return ActiveTransition.
|
|
67
|
+
if (ActiveTransition && ActiveTransition.u.has(this))
|
|
68
|
+
return ActiveTransition.u.get(this).enqueue(type, fn);
|
|
69
69
|
pureQueue.push(fn);
|
|
70
70
|
if (type)
|
|
71
71
|
this.f[type - 1].push(fn);
|
|
@@ -97,7 +97,7 @@ var Queue = class {
|
|
|
97
97
|
this.run(EFFECT_USER);
|
|
98
98
|
} finally {
|
|
99
99
|
this.z = false;
|
|
100
|
-
|
|
100
|
+
Unobserved.length && notifyUnobserved();
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
addChild(child) {
|
|
@@ -110,8 +110,8 @@ var Queue = class {
|
|
|
110
110
|
this.e.splice(index, 1);
|
|
111
111
|
}
|
|
112
112
|
notify(...args) {
|
|
113
|
-
if (ActiveTransition && ActiveTransition.
|
|
114
|
-
return ActiveTransition.
|
|
113
|
+
if (ActiveTransition && ActiveTransition.u.has(this))
|
|
114
|
+
return ActiveTransition.u.get(this).notify(...args);
|
|
115
115
|
if (this.m)
|
|
116
116
|
return this.m.notify(...args);
|
|
117
117
|
return false;
|
|
@@ -120,7 +120,7 @@ var Queue = class {
|
|
|
120
120
|
this.f[0].push.apply(this.f[0], queue.f[0]);
|
|
121
121
|
this.f[1].push.apply(this.f[1], queue.f[1]);
|
|
122
122
|
for (let i = 0; i < queue.e.length; i++) {
|
|
123
|
-
const og = this.e.find((c) => c.
|
|
123
|
+
const og = this.e.find((c) => c.g === queue.e[i].g);
|
|
124
124
|
if (og)
|
|
125
125
|
og.merge(queue.e[i]);
|
|
126
126
|
else
|
|
@@ -140,12 +140,12 @@ function runQueue(queue, type) {
|
|
|
140
140
|
}
|
|
141
141
|
var Transition = class _Transition {
|
|
142
142
|
a = /* @__PURE__ */ new Map();
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
s = /* @__PURE__ */ new Set();
|
|
144
|
+
R = /* @__PURE__ */ new Set();
|
|
145
145
|
W = /* @__PURE__ */ new Set();
|
|
146
146
|
I = false;
|
|
147
147
|
f = [[], []];
|
|
148
|
-
|
|
148
|
+
u = /* @__PURE__ */ new Map();
|
|
149
149
|
E = [];
|
|
150
150
|
e = [];
|
|
151
151
|
m = null;
|
|
@@ -153,9 +153,9 @@ var Transition = class _Transition {
|
|
|
153
153
|
X = false;
|
|
154
154
|
created = clock;
|
|
155
155
|
constructor() {
|
|
156
|
-
this.
|
|
156
|
+
this.u.set(globalQueue, this);
|
|
157
157
|
for (const child of globalQueue.e) {
|
|
158
|
-
cloneQueue(child, this, this.
|
|
158
|
+
cloneQueue(child, this, this.u);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
enqueue(type, fn) {
|
|
@@ -208,9 +208,9 @@ var Transition = class _Transition {
|
|
|
208
208
|
if (!(type & LOADING_BIT))
|
|
209
209
|
return false;
|
|
210
210
|
if (flags & LOADING_BIT) {
|
|
211
|
-
this.
|
|
211
|
+
this.s.add(node);
|
|
212
212
|
} else {
|
|
213
|
-
this.
|
|
213
|
+
this.s.delete(node);
|
|
214
214
|
}
|
|
215
215
|
return true;
|
|
216
216
|
}
|
|
@@ -219,7 +219,7 @@ var Transition = class _Transition {
|
|
|
219
219
|
this.f[1].push.apply(this.f[1], queue.f[1]);
|
|
220
220
|
this.E.push.apply(this.E, queue.E);
|
|
221
221
|
for (let i = 0; i < queue.e.length; i++) {
|
|
222
|
-
const og = this.e.find((c) => c.
|
|
222
|
+
const og = this.e.find((c) => c.g === queue.e[i].g);
|
|
223
223
|
if (og)
|
|
224
224
|
og.merge(queue.e[i]);
|
|
225
225
|
else
|
|
@@ -247,9 +247,9 @@ var Transition = class _Transition {
|
|
|
247
247
|
const result = fn();
|
|
248
248
|
const transition2 = ActiveTransition;
|
|
249
249
|
if (result instanceof Promise) {
|
|
250
|
-
transition2.
|
|
250
|
+
transition2.R.add(result);
|
|
251
251
|
result.finally(() => {
|
|
252
|
-
transition2.
|
|
252
|
+
transition2.R.delete(result);
|
|
253
253
|
finishTransition(transition2);
|
|
254
254
|
});
|
|
255
255
|
}
|
|
@@ -260,12 +260,12 @@ var Transition = class _Transition {
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
addOptimistic(fn) {
|
|
263
|
-
if (fn.
|
|
264
|
-
mergeTransitions(fn.
|
|
265
|
-
ActiveTransition = fn.
|
|
263
|
+
if (fn.l && fn.l !== this) {
|
|
264
|
+
mergeTransitions(fn.l, this);
|
|
265
|
+
ActiveTransition = fn.l;
|
|
266
266
|
return;
|
|
267
267
|
}
|
|
268
|
-
fn.
|
|
268
|
+
fn.l = this;
|
|
269
269
|
this.W.add(fn);
|
|
270
270
|
}
|
|
271
271
|
};
|
|
@@ -274,51 +274,59 @@ function transition(fn) {
|
|
|
274
274
|
queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
|
|
275
275
|
}
|
|
276
276
|
function cloneGraph(node) {
|
|
277
|
-
if (node.
|
|
278
|
-
if (node.
|
|
279
|
-
mergeTransitions(node.
|
|
280
|
-
ActiveTransition = node.
|
|
277
|
+
if (node.l) {
|
|
278
|
+
if (node.l !== ActiveTransition) {
|
|
279
|
+
mergeTransitions(node.l, ActiveTransition);
|
|
280
|
+
ActiveTransition = node.l;
|
|
281
281
|
}
|
|
282
|
-
return node.
|
|
282
|
+
return node.l.a.get(node);
|
|
283
283
|
}
|
|
284
284
|
const clone = Object.create(Object.getPrototypeOf(node));
|
|
285
|
-
Object.assign(clone, node, {
|
|
285
|
+
Object.assign(clone, node, {
|
|
286
|
+
n: null,
|
|
287
|
+
r: null,
|
|
288
|
+
b: null,
|
|
289
|
+
a: node.a ? [...node.a] : null,
|
|
290
|
+
g: node
|
|
291
|
+
});
|
|
286
292
|
ActiveTransition.a.set(node, clone);
|
|
287
|
-
node.
|
|
288
|
-
if (node.
|
|
289
|
-
for (let i = 0
|
|
290
|
-
|
|
291
|
-
|
|
293
|
+
node.l = ActiveTransition;
|
|
294
|
+
if (node.a) {
|
|
295
|
+
for (let i = 0; i < node.a.length; i++)
|
|
296
|
+
node.a[i].b.push(clone);
|
|
297
|
+
}
|
|
298
|
+
if (node.b) {
|
|
299
|
+
clone.b = [];
|
|
300
|
+
for (let i = 0, length = node.b.length; i < length; i++) {
|
|
301
|
+
!node.b[i].g && clone.b.push(cloneGraph(node.b[i]));
|
|
292
302
|
}
|
|
293
303
|
}
|
|
294
304
|
return clone;
|
|
295
305
|
}
|
|
296
|
-
function
|
|
306
|
+
function replaceSourceObservers(node, transition2) {
|
|
297
307
|
let source;
|
|
308
|
+
let transitionSource;
|
|
298
309
|
let swap;
|
|
299
|
-
for (let i =
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
if (!source.d.length)
|
|
307
|
-
unobserved.push(source);
|
|
310
|
+
for (let i = 0; i < node.a.length; i++) {
|
|
311
|
+
transitionSource = transition2.a.get(node.a[i]);
|
|
312
|
+
source = transitionSource || node.a[i];
|
|
313
|
+
if (source.b && (swap = source.b.indexOf(node)) !== -1) {
|
|
314
|
+
source.b[swap] = transitionSource ? node.g : source.b[source.b.length - 1];
|
|
315
|
+
!transitionSource && source.b.pop();
|
|
308
316
|
}
|
|
309
317
|
}
|
|
310
318
|
}
|
|
311
319
|
function cloneQueue(queue, parent, clonedQueues) {
|
|
312
320
|
const clone = Object.create(Object.getPrototypeOf(queue));
|
|
313
321
|
Object.assign(clone, queue, {
|
|
314
|
-
|
|
322
|
+
g: queue,
|
|
315
323
|
m: parent,
|
|
316
324
|
e: [],
|
|
317
325
|
enqueue(type, fn) {
|
|
318
326
|
ActiveTransition?.enqueue(type, fn);
|
|
319
327
|
},
|
|
320
328
|
notify(node, type, flags) {
|
|
321
|
-
node = node.
|
|
329
|
+
node = node.g || node;
|
|
322
330
|
if (!clone.F || type & LOADING_BIT) {
|
|
323
331
|
type &= ~LOADING_BIT;
|
|
324
332
|
ActiveTransition?.notify(node, LOADING_BIT, flags);
|
|
@@ -336,7 +344,7 @@ function cloneQueue(queue, parent, clonedQueues) {
|
|
|
336
344
|
}
|
|
337
345
|
function resolveQueues(children) {
|
|
338
346
|
for (const child of children) {
|
|
339
|
-
const og = child.
|
|
347
|
+
const og = child.g;
|
|
340
348
|
if (og) {
|
|
341
349
|
const clonedChildren = child.e;
|
|
342
350
|
delete child.enqueue;
|
|
@@ -344,50 +352,50 @@ function resolveQueues(children) {
|
|
|
344
352
|
delete child.m;
|
|
345
353
|
delete child.e;
|
|
346
354
|
Object.assign(og, child);
|
|
347
|
-
delete og.
|
|
355
|
+
delete og.g;
|
|
348
356
|
resolveQueues(clonedChildren);
|
|
349
|
-
} else if (child.m.
|
|
350
|
-
child.m.
|
|
357
|
+
} else if (child.m.g) {
|
|
358
|
+
child.m.g.addChild(child);
|
|
351
359
|
}
|
|
352
360
|
}
|
|
353
361
|
}
|
|
354
362
|
function mergeTransitions(t1, t2) {
|
|
355
363
|
t2.a.forEach((value, key) => {
|
|
356
|
-
key.
|
|
364
|
+
key.l = t1;
|
|
357
365
|
t1.a.set(key, value);
|
|
358
366
|
});
|
|
359
367
|
t2.W.forEach((c) => {
|
|
360
|
-
c.
|
|
368
|
+
c.l = t1;
|
|
361
369
|
t1.W.add(c);
|
|
362
370
|
});
|
|
363
|
-
t2.
|
|
364
|
-
t2.
|
|
371
|
+
t2.R.forEach((p) => t1.R.add(p));
|
|
372
|
+
t2.s.forEach((n) => t1.s.add(n));
|
|
365
373
|
t1.merge(t2);
|
|
366
374
|
t2.I = t1;
|
|
367
375
|
}
|
|
368
376
|
function finishTransition(transition2) {
|
|
369
|
-
if (transition2.I || transition2.X || transition2.
|
|
377
|
+
if (transition2.I || transition2.X || transition2.R.size || transition2.s.size)
|
|
370
378
|
return;
|
|
371
379
|
for (const [source, clone] of transition2.a) {
|
|
372
|
-
if (source === clone || source.
|
|
380
|
+
if (source === clone || source.l !== transition2)
|
|
373
381
|
continue;
|
|
374
382
|
if (clone.a)
|
|
375
|
-
|
|
383
|
+
replaceSourceObservers(clone, transition2);
|
|
376
384
|
source.dispose(false);
|
|
377
385
|
source.emptyDisposal();
|
|
378
386
|
Object.assign(source, clone);
|
|
379
|
-
delete source.
|
|
380
|
-
delete source.
|
|
387
|
+
delete source.g;
|
|
388
|
+
delete source.l;
|
|
381
389
|
}
|
|
382
390
|
globalQueue.f[0].push.apply(globalQueue.f[0], transition2.f[0]);
|
|
383
391
|
globalQueue.f[1].push.apply(globalQueue.f[1], transition2.f[1]);
|
|
384
392
|
resolveQueues(transition2.e);
|
|
385
393
|
transition2.I = true;
|
|
386
|
-
globalQueue.flush();
|
|
387
394
|
for (const reset of transition2.W) {
|
|
388
|
-
delete reset.
|
|
395
|
+
delete reset.l;
|
|
389
396
|
reset();
|
|
390
397
|
}
|
|
398
|
+
globalQueue.flush();
|
|
391
399
|
}
|
|
392
400
|
|
|
393
401
|
// src/core/owner.ts
|
|
@@ -406,12 +414,12 @@ var Owner = class {
|
|
|
406
414
|
// However, the children are actually added in reverse creation order
|
|
407
415
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
408
416
|
m = null;
|
|
409
|
-
|
|
417
|
+
r = null;
|
|
410
418
|
B = null;
|
|
411
|
-
|
|
419
|
+
c = STATE_CLEAN;
|
|
412
420
|
n = null;
|
|
413
|
-
|
|
414
|
-
|
|
421
|
+
w = defaultContext;
|
|
422
|
+
k = globalQueue;
|
|
415
423
|
ea = 0;
|
|
416
424
|
id = null;
|
|
417
425
|
constructor(id = null, skipAppend = false) {
|
|
@@ -423,27 +431,27 @@ var Owner = class {
|
|
|
423
431
|
append(child) {
|
|
424
432
|
child.m = this;
|
|
425
433
|
child.B = this;
|
|
426
|
-
if (this.
|
|
427
|
-
this.
|
|
428
|
-
child.
|
|
429
|
-
this.
|
|
434
|
+
if (this.r)
|
|
435
|
+
this.r.B = child;
|
|
436
|
+
child.r = this.r;
|
|
437
|
+
this.r = child;
|
|
430
438
|
if (this.id != null && child.id == null)
|
|
431
439
|
child.id = this.getNextChildId();
|
|
432
|
-
if (child.
|
|
433
|
-
child.
|
|
440
|
+
if (child.w !== this.w) {
|
|
441
|
+
child.w = { ...this.w, ...child.w };
|
|
434
442
|
}
|
|
435
|
-
if (this.
|
|
436
|
-
child.
|
|
443
|
+
if (this.k)
|
|
444
|
+
child.k = this.k;
|
|
437
445
|
}
|
|
438
446
|
dispose(self = true) {
|
|
439
|
-
if (this.
|
|
447
|
+
if (this.c === STATE_DISPOSED)
|
|
440
448
|
return;
|
|
441
|
-
let head = self ? this.B || this.m : this, current = this.
|
|
449
|
+
let head = self ? this.B || this.m : this, current = this.r, next = null;
|
|
442
450
|
while (current && current.m === this) {
|
|
443
451
|
current.dispose(true);
|
|
444
452
|
current.J();
|
|
445
|
-
next = current.
|
|
446
|
-
current.
|
|
453
|
+
next = current.r;
|
|
454
|
+
current.r = null;
|
|
447
455
|
current = next;
|
|
448
456
|
}
|
|
449
457
|
this.ea = 0;
|
|
@@ -452,15 +460,15 @@ var Owner = class {
|
|
|
452
460
|
if (current)
|
|
453
461
|
current.B = !self ? this : this.B;
|
|
454
462
|
if (head)
|
|
455
|
-
head.
|
|
463
|
+
head.r = current;
|
|
456
464
|
}
|
|
457
465
|
J() {
|
|
458
466
|
if (this.B)
|
|
459
|
-
this.B.
|
|
467
|
+
this.B.r = null;
|
|
460
468
|
this.m = null;
|
|
461
469
|
this.B = null;
|
|
462
|
-
this.
|
|
463
|
-
this.
|
|
470
|
+
this.w = defaultContext;
|
|
471
|
+
this.c = STATE_DISPOSED;
|
|
464
472
|
this.emptyDisposal();
|
|
465
473
|
}
|
|
466
474
|
emptyDisposal() {
|
|
@@ -489,7 +497,7 @@ function getContext(context, owner = currentOwner) {
|
|
|
489
497
|
if (!owner) {
|
|
490
498
|
throw new NoOwnerError();
|
|
491
499
|
}
|
|
492
|
-
const value = hasContext(context, owner) ? owner.
|
|
500
|
+
const value = hasContext(context, owner) ? owner.w[context.id] : context.defaultValue;
|
|
493
501
|
if (isUndefined(value)) {
|
|
494
502
|
throw new ContextNotFoundError();
|
|
495
503
|
}
|
|
@@ -499,13 +507,13 @@ function setContext(context, value, owner = currentOwner) {
|
|
|
499
507
|
if (!owner) {
|
|
500
508
|
throw new NoOwnerError();
|
|
501
509
|
}
|
|
502
|
-
owner.
|
|
503
|
-
...owner.
|
|
510
|
+
owner.w = {
|
|
511
|
+
...owner.w,
|
|
504
512
|
[context.id]: isUndefined(value) ? context.defaultValue : value
|
|
505
513
|
};
|
|
506
514
|
}
|
|
507
515
|
function hasContext(context, owner = currentOwner) {
|
|
508
|
-
return !isUndefined(owner?.
|
|
516
|
+
return !isUndefined(owner?.w[context.id]);
|
|
509
517
|
}
|
|
510
518
|
function onCleanup(fn) {
|
|
511
519
|
if (!currentOwner)
|
|
@@ -543,10 +551,10 @@ function getObserver() {
|
|
|
543
551
|
var UNCHANGED = Symbol(0);
|
|
544
552
|
var Computation = class extends Owner {
|
|
545
553
|
a = null;
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
R;
|
|
554
|
+
b = null;
|
|
555
|
+
j;
|
|
549
556
|
K;
|
|
557
|
+
L;
|
|
550
558
|
// Used in __DEV__ mode, hopefully removed in production
|
|
551
559
|
ka;
|
|
552
560
|
// Using false is an optimization as an alternative to _equals: () => false
|
|
@@ -558,16 +566,16 @@ var Computation = class extends Owner {
|
|
|
558
566
|
h = 0;
|
|
559
567
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
560
568
|
aa = DEFAULT_FLAGS;
|
|
561
|
-
|
|
569
|
+
M = -1;
|
|
562
570
|
G = false;
|
|
563
|
-
|
|
564
|
-
|
|
571
|
+
l;
|
|
572
|
+
g;
|
|
565
573
|
constructor(initialValue, compute2, options) {
|
|
566
574
|
super(options?.id, compute2 === null);
|
|
567
|
-
this.
|
|
568
|
-
this.
|
|
575
|
+
this.L = compute2;
|
|
576
|
+
this.c = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
569
577
|
this.h = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
570
|
-
this.
|
|
578
|
+
this.j = initialValue;
|
|
571
579
|
if (options?.equals !== void 0)
|
|
572
580
|
this.$ = options.equals;
|
|
573
581
|
if (options?.pureWrite)
|
|
@@ -575,7 +583,7 @@ var Computation = class extends Owner {
|
|
|
575
583
|
if (options?.unobserved)
|
|
576
584
|
this.da = options?.unobserved;
|
|
577
585
|
if (ActiveTransition) {
|
|
578
|
-
this.
|
|
586
|
+
this.l = ActiveTransition;
|
|
579
587
|
ActiveTransition.a.set(this, this);
|
|
580
588
|
}
|
|
581
589
|
}
|
|
@@ -583,9 +591,9 @@ var Computation = class extends Owner {
|
|
|
583
591
|
track(this);
|
|
584
592
|
newFlags |= this.h & ~currentMask;
|
|
585
593
|
if (this.h & ERROR_BIT) {
|
|
586
|
-
throw this.
|
|
594
|
+
throw this.K;
|
|
587
595
|
} else {
|
|
588
|
-
return this.
|
|
596
|
+
return this.j;
|
|
589
597
|
}
|
|
590
598
|
}
|
|
591
599
|
/**
|
|
@@ -593,13 +601,13 @@ var Computation = class extends Owner {
|
|
|
593
601
|
* Automatically re-executes the surrounding computation when the value changes
|
|
594
602
|
*/
|
|
595
603
|
read() {
|
|
596
|
-
if (ActiveTransition && ActiveTransition.a.has(this)) {
|
|
597
|
-
const clone = ActiveTransition.a.get(this);
|
|
604
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.g && this.h & UNINITIALIZED_BIT)) {
|
|
605
|
+
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
598
606
|
if (clone !== this)
|
|
599
607
|
return clone.read();
|
|
600
608
|
}
|
|
601
|
-
if (this.
|
|
602
|
-
if (this.h & ERROR_BIT && this.
|
|
609
|
+
if (this.L) {
|
|
610
|
+
if (this.h & ERROR_BIT && this.M <= clock)
|
|
603
611
|
update(this);
|
|
604
612
|
else
|
|
605
613
|
this.H();
|
|
@@ -614,13 +622,13 @@ var Computation = class extends Owner {
|
|
|
614
622
|
* before continuing
|
|
615
623
|
*/
|
|
616
624
|
wait() {
|
|
617
|
-
if (ActiveTransition && ActiveTransition.a.has(this)) {
|
|
618
|
-
const clone = ActiveTransition.a.get(this);
|
|
625
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.g && this.h & UNINITIALIZED_BIT)) {
|
|
626
|
+
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
619
627
|
if (clone !== this)
|
|
620
628
|
return clone.wait();
|
|
621
629
|
}
|
|
622
|
-
if (this.
|
|
623
|
-
if (this.h & ERROR_BIT && this.
|
|
630
|
+
if (this.L) {
|
|
631
|
+
if (this.h & ERROR_BIT && this.M <= clock)
|
|
624
632
|
update(this);
|
|
625
633
|
else
|
|
626
634
|
this.H();
|
|
@@ -630,54 +638,49 @@ var Computation = class extends Owner {
|
|
|
630
638
|
throw new NotReadyError();
|
|
631
639
|
}
|
|
632
640
|
if (staleCheck && this.h & LOADING_BIT) {
|
|
633
|
-
staleCheck.
|
|
641
|
+
staleCheck.j = true;
|
|
634
642
|
}
|
|
635
643
|
return this.fa();
|
|
636
644
|
}
|
|
637
645
|
/** Update the computation with a new value. */
|
|
638
646
|
write(value, flags = 0, raw = false) {
|
|
639
|
-
if (ActiveTransition && !this.
|
|
647
|
+
if (ActiveTransition && !this.g) {
|
|
640
648
|
const clone = cloneGraph(this);
|
|
641
649
|
if (clone !== this)
|
|
642
650
|
return clone.write(value, flags, raw);
|
|
643
651
|
}
|
|
644
|
-
const newValue = !raw && typeof value === "function" ? value(this.
|
|
652
|
+
const newValue = !raw && typeof value === "function" ? value(this.j) : value;
|
|
645
653
|
const valueChanged = newValue !== UNCHANGED && (!!(this.h & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
|
|
646
|
-
this.$ === false || !this.$(this.
|
|
654
|
+
this.$ === false || !this.$(this.j, newValue));
|
|
647
655
|
if (valueChanged) {
|
|
648
|
-
this.
|
|
649
|
-
this.
|
|
656
|
+
this.j = newValue;
|
|
657
|
+
this.K = void 0;
|
|
650
658
|
}
|
|
651
659
|
const changedFlagsMask = this.h ^ flags, changedFlags = changedFlagsMask & flags;
|
|
652
660
|
this.h = flags;
|
|
653
|
-
this.
|
|
654
|
-
if (this.
|
|
655
|
-
for (let i = 0; i < this.
|
|
661
|
+
this.M = clock + 1;
|
|
662
|
+
if (this.b) {
|
|
663
|
+
for (let i = 0; i < this.b.length; i++) {
|
|
656
664
|
if (valueChanged) {
|
|
657
|
-
this.
|
|
665
|
+
this.b[i].x(STATE_DIRTY);
|
|
658
666
|
} else if (changedFlagsMask) {
|
|
659
|
-
this.
|
|
667
|
+
this.b[i].Y(changedFlagsMask, changedFlags);
|
|
660
668
|
}
|
|
661
669
|
}
|
|
662
670
|
}
|
|
663
|
-
return this.
|
|
671
|
+
return this.j;
|
|
664
672
|
}
|
|
665
673
|
/**
|
|
666
674
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
667
675
|
*/
|
|
668
|
-
|
|
669
|
-
if (
|
|
670
|
-
const clone = ActiveTransition.a.get(this);
|
|
671
|
-
if (clone !== this)
|
|
672
|
-
return clone.o(state, skipQueue);
|
|
673
|
-
}
|
|
674
|
-
if (this.b >= state && !this.G)
|
|
676
|
+
x(state, skipQueue) {
|
|
677
|
+
if (this.c >= state && !this.G)
|
|
675
678
|
return;
|
|
676
679
|
this.G = !!skipQueue;
|
|
677
|
-
this.
|
|
678
|
-
if (this.
|
|
679
|
-
for (let i = 0; i < this.
|
|
680
|
-
this.
|
|
680
|
+
this.c = state;
|
|
681
|
+
if (this.b) {
|
|
682
|
+
for (let i = 0; i < this.b.length; i++) {
|
|
683
|
+
this.b[i].x(STATE_CHECK, skipQueue);
|
|
681
684
|
}
|
|
682
685
|
}
|
|
683
686
|
}
|
|
@@ -688,34 +691,34 @@ var Computation = class extends Owner {
|
|
|
688
691
|
* @param newFlags The source's new flags, masked to just the changed ones.
|
|
689
692
|
*/
|
|
690
693
|
Y(mask, newFlags2) {
|
|
691
|
-
if (this.
|
|
694
|
+
if (this.c >= STATE_DIRTY)
|
|
692
695
|
return;
|
|
693
696
|
if (mask & this.aa) {
|
|
694
|
-
this.
|
|
697
|
+
this.x(STATE_DIRTY);
|
|
695
698
|
return;
|
|
696
699
|
}
|
|
697
|
-
if (this.
|
|
700
|
+
if (this.c >= STATE_CHECK)
|
|
698
701
|
return;
|
|
699
702
|
const prevFlags = this.h & mask;
|
|
700
703
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
701
704
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
702
|
-
this.
|
|
705
|
+
this.x(STATE_CHECK);
|
|
703
706
|
} else {
|
|
704
707
|
this.h ^= deltaFlags;
|
|
705
|
-
if (this.
|
|
706
|
-
for (let i = 0; i < this.
|
|
707
|
-
this.
|
|
708
|
+
if (this.b) {
|
|
709
|
+
for (let i = 0; i < this.b.length; i++) {
|
|
710
|
+
this.b[i].Y(mask, newFlags2);
|
|
708
711
|
}
|
|
709
712
|
}
|
|
710
713
|
}
|
|
711
714
|
}
|
|
712
|
-
|
|
713
|
-
if (ActiveTransition && !this.
|
|
715
|
+
N(error) {
|
|
716
|
+
if (ActiveTransition && !this.g) {
|
|
714
717
|
const clone = cloneGraph(this);
|
|
715
718
|
if (clone !== this)
|
|
716
|
-
return clone.
|
|
719
|
+
return clone.N(error);
|
|
717
720
|
}
|
|
718
|
-
this.
|
|
721
|
+
this.K = error;
|
|
719
722
|
this.write(UNCHANGED, this.h & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
720
723
|
}
|
|
721
724
|
/**
|
|
@@ -726,38 +729,38 @@ var Computation = class extends Owner {
|
|
|
726
729
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
727
730
|
*/
|
|
728
731
|
H() {
|
|
729
|
-
if (!this.
|
|
732
|
+
if (!this.L) {
|
|
730
733
|
return;
|
|
731
734
|
}
|
|
732
|
-
if (this.
|
|
735
|
+
if (this.c === STATE_DISPOSED) {
|
|
733
736
|
return;
|
|
734
737
|
}
|
|
735
|
-
if (this.
|
|
738
|
+
if (this.c === STATE_CLEAN) {
|
|
736
739
|
return;
|
|
737
740
|
}
|
|
738
741
|
let observerFlags = 0;
|
|
739
|
-
if (this.
|
|
742
|
+
if (this.c === STATE_CHECK) {
|
|
740
743
|
for (let i = 0; i < this.a.length; i++) {
|
|
741
744
|
const source = ActiveTransition && ActiveTransition.a.get(this.a[i]) || this.a[i];
|
|
742
745
|
source.H();
|
|
743
|
-
observerFlags |= source.h;
|
|
744
|
-
if (this.
|
|
746
|
+
observerFlags |= source.h & ~UNINITIALIZED_BIT;
|
|
747
|
+
if (this.c === STATE_DIRTY) {
|
|
745
748
|
break;
|
|
746
749
|
}
|
|
747
750
|
}
|
|
748
751
|
}
|
|
749
|
-
if (this.
|
|
752
|
+
if (this.c === STATE_DIRTY) {
|
|
750
753
|
update(this);
|
|
751
754
|
} else {
|
|
752
755
|
this.write(UNCHANGED, observerFlags);
|
|
753
|
-
this.
|
|
756
|
+
this.c = STATE_CLEAN;
|
|
754
757
|
}
|
|
755
758
|
}
|
|
756
759
|
/**
|
|
757
760
|
* Remove ourselves from the owner graph and the computation graph
|
|
758
761
|
*/
|
|
759
762
|
J() {
|
|
760
|
-
if (this.
|
|
763
|
+
if (this.c === STATE_DISPOSED)
|
|
761
764
|
return;
|
|
762
765
|
if (this.a)
|
|
763
766
|
removeSourceObservers(this, 0);
|
|
@@ -765,8 +768,8 @@ var Computation = class extends Owner {
|
|
|
765
768
|
}
|
|
766
769
|
};
|
|
767
770
|
function track(computation) {
|
|
768
|
-
if (ActiveTransition && computation.
|
|
769
|
-
computation = computation.
|
|
771
|
+
if (ActiveTransition && computation.g)
|
|
772
|
+
computation = computation.g;
|
|
770
773
|
if (currentObserver) {
|
|
771
774
|
if (!newSources && currentObserver.a && currentObserver.a[newSourcesIndex] === computation) {
|
|
772
775
|
newSourcesIndex++;
|
|
@@ -776,7 +779,7 @@ function track(computation) {
|
|
|
776
779
|
newSources.push(computation);
|
|
777
780
|
}
|
|
778
781
|
if (updateCheck) {
|
|
779
|
-
updateCheck.
|
|
782
|
+
updateCheck.j = computation.M > currentObserver.M;
|
|
780
783
|
}
|
|
781
784
|
}
|
|
782
785
|
}
|
|
@@ -788,13 +791,13 @@ function update(node) {
|
|
|
788
791
|
try {
|
|
789
792
|
node.dispose(false);
|
|
790
793
|
node.emptyDisposal();
|
|
791
|
-
const result = compute(node, node.
|
|
794
|
+
const result = compute(node, node.L, node);
|
|
792
795
|
node.write(result, newFlags, true);
|
|
793
796
|
} catch (error) {
|
|
794
797
|
if (error instanceof NotReadyError) {
|
|
795
798
|
node.write(UNCHANGED, newFlags | LOADING_BIT | node.h & UNINITIALIZED_BIT);
|
|
796
799
|
} else {
|
|
797
|
-
node.
|
|
800
|
+
node.N(error);
|
|
798
801
|
}
|
|
799
802
|
} finally {
|
|
800
803
|
if (newSources) {
|
|
@@ -810,11 +813,11 @@ function update(node) {
|
|
|
810
813
|
}
|
|
811
814
|
let source;
|
|
812
815
|
for (let i = newSourcesIndex; i < node.a.length; i++) {
|
|
813
|
-
source = node.a[i];
|
|
814
|
-
if (!source.
|
|
815
|
-
source.
|
|
816
|
+
source = ActiveTransition && ActiveTransition.a.get(node.a[i]) || node.a[i];
|
|
817
|
+
if (!source.b)
|
|
818
|
+
source.b = [node];
|
|
816
819
|
else
|
|
817
|
-
source.
|
|
820
|
+
source.b.push(node);
|
|
818
821
|
}
|
|
819
822
|
} else if (node.a && newSourcesIndex < node.a.length) {
|
|
820
823
|
removeSourceObservers(node, newSourcesIndex);
|
|
@@ -823,8 +826,23 @@ function update(node) {
|
|
|
823
826
|
newSources = prevSources;
|
|
824
827
|
newSourcesIndex = prevSourcesIndex;
|
|
825
828
|
newFlags = prevFlags;
|
|
826
|
-
node.
|
|
827
|
-
node.
|
|
829
|
+
node.M = clock + 1;
|
|
830
|
+
node.c = STATE_CLEAN;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
function removeSourceObservers(node, index) {
|
|
834
|
+
let source;
|
|
835
|
+
let swap;
|
|
836
|
+
for (let i = index; i < node.a.length; i++) {
|
|
837
|
+
source = ActiveTransition && ActiveTransition.a.get(node.a[i]) || node.a[i];
|
|
838
|
+
if (source.b) {
|
|
839
|
+
if ((swap = source.b.indexOf(node)) !== -1) {
|
|
840
|
+
source.b[swap] = source.b[source.b.length - 1];
|
|
841
|
+
source.b.pop();
|
|
842
|
+
}
|
|
843
|
+
if (!source.b.length)
|
|
844
|
+
Unobserved.push(source);
|
|
845
|
+
}
|
|
828
846
|
}
|
|
829
847
|
}
|
|
830
848
|
function isEqual(a, b) {
|
|
@@ -837,20 +855,20 @@ function untrack(fn) {
|
|
|
837
855
|
}
|
|
838
856
|
function hasUpdated(fn) {
|
|
839
857
|
const current = updateCheck;
|
|
840
|
-
updateCheck = {
|
|
858
|
+
updateCheck = { j: false };
|
|
841
859
|
try {
|
|
842
860
|
fn();
|
|
843
|
-
return updateCheck.
|
|
861
|
+
return updateCheck.j;
|
|
844
862
|
} finally {
|
|
845
863
|
updateCheck = current;
|
|
846
864
|
}
|
|
847
865
|
}
|
|
848
866
|
function pendingCheck(fn, loadingValue) {
|
|
849
867
|
const current = staleCheck;
|
|
850
|
-
staleCheck = {
|
|
868
|
+
staleCheck = { j: false };
|
|
851
869
|
try {
|
|
852
870
|
latest(fn);
|
|
853
|
-
return staleCheck.
|
|
871
|
+
return staleCheck.j;
|
|
854
872
|
} catch (err) {
|
|
855
873
|
if (!(err instanceof NotReadyError))
|
|
856
874
|
return false;
|
|
@@ -898,7 +916,7 @@ function runWithObserver(observer, run) {
|
|
|
898
916
|
newFlags | LOADING_BIT | observer.h & UNINITIALIZED_BIT
|
|
899
917
|
);
|
|
900
918
|
} else {
|
|
901
|
-
observer.
|
|
919
|
+
observer.N(error);
|
|
902
920
|
}
|
|
903
921
|
} finally {
|
|
904
922
|
if (newSources) {
|
|
@@ -913,10 +931,10 @@ function runWithObserver(observer, run) {
|
|
|
913
931
|
let source;
|
|
914
932
|
for (let i = newSourcesIndex; i < observer.a.length; i++) {
|
|
915
933
|
source = observer.a[i];
|
|
916
|
-
if (!source.
|
|
917
|
-
source.
|
|
934
|
+
if (!source.b)
|
|
935
|
+
source.b = [observer];
|
|
918
936
|
else
|
|
919
|
-
source.
|
|
937
|
+
source.b.push(observer);
|
|
920
938
|
}
|
|
921
939
|
}
|
|
922
940
|
newSources = prevSources;
|
|
@@ -930,7 +948,7 @@ function compute(owner, fn, observer) {
|
|
|
930
948
|
currentMask = observer?.aa ?? DEFAULT_FLAGS;
|
|
931
949
|
notStale = true;
|
|
932
950
|
try {
|
|
933
|
-
return fn(observer ? observer.
|
|
951
|
+
return fn.call(observer, observer ? observer.j : void 0);
|
|
934
952
|
} finally {
|
|
935
953
|
setOwner(prevOwner);
|
|
936
954
|
currentObserver = prevObserver;
|
|
@@ -943,7 +961,7 @@ function compute(owner, fn, observer) {
|
|
|
943
961
|
var Effect = class extends Computation {
|
|
944
962
|
ba;
|
|
945
963
|
Z;
|
|
946
|
-
|
|
964
|
+
O;
|
|
947
965
|
ca = false;
|
|
948
966
|
_;
|
|
949
967
|
A;
|
|
@@ -954,89 +972,90 @@ var Effect = class extends Computation {
|
|
|
954
972
|
this._ = initialValue;
|
|
955
973
|
this.A = options?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
956
974
|
if (this.A === EFFECT_RENDER) {
|
|
957
|
-
this.
|
|
975
|
+
this.L = function(p) {
|
|
976
|
+
return !this.g && clock > this.k.created && !(this.h & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
977
|
+
};
|
|
958
978
|
}
|
|
959
979
|
this.H();
|
|
960
|
-
!options?.defer && (this.A === EFFECT_USER ? this.
|
|
980
|
+
!options?.defer && (this.A === EFFECT_USER ? this.k.enqueue(this.A, this.C.bind(this)) : this.C(this.A));
|
|
961
981
|
}
|
|
962
982
|
write(value, flags = 0) {
|
|
963
|
-
if (this.
|
|
983
|
+
if (this.c == STATE_DIRTY) {
|
|
964
984
|
this.h = flags;
|
|
965
985
|
if (this.A === EFFECT_RENDER) {
|
|
966
|
-
this.
|
|
986
|
+
this.k.notify(this, LOADING_BIT | ERROR_BIT, this.h);
|
|
967
987
|
}
|
|
968
988
|
}
|
|
969
989
|
if (value === UNCHANGED)
|
|
970
|
-
return this.
|
|
971
|
-
this.
|
|
990
|
+
return this.j;
|
|
991
|
+
this.j = value;
|
|
972
992
|
this.ca = true;
|
|
993
|
+
this.K = void 0;
|
|
973
994
|
return value;
|
|
974
995
|
}
|
|
975
|
-
|
|
976
|
-
if (
|
|
977
|
-
return ActiveTransition.a.get(this).o(state, skipQueue);
|
|
978
|
-
}
|
|
979
|
-
if (this.b >= state || skipQueue)
|
|
996
|
+
x(state, skipQueue) {
|
|
997
|
+
if (this.c >= state || skipQueue)
|
|
980
998
|
return;
|
|
981
|
-
if (this.
|
|
982
|
-
this.
|
|
983
|
-
this.
|
|
999
|
+
if (this.c === STATE_CLEAN)
|
|
1000
|
+
this.k.enqueue(this.A, this.C.bind(this));
|
|
1001
|
+
this.c = state;
|
|
984
1002
|
}
|
|
985
1003
|
Y(mask, newFlags2) {
|
|
986
|
-
if (
|
|
987
|
-
if (this.
|
|
1004
|
+
if (this.g) {
|
|
1005
|
+
if (this.c >= STATE_DIRTY)
|
|
988
1006
|
return;
|
|
989
1007
|
if (mask & 3) {
|
|
990
|
-
this.
|
|
1008
|
+
this.x(STATE_DIRTY);
|
|
991
1009
|
return;
|
|
992
1010
|
}
|
|
993
1011
|
}
|
|
994
1012
|
super.Y(mask, newFlags2);
|
|
995
1013
|
}
|
|
996
|
-
|
|
997
|
-
this.
|
|
998
|
-
this.
|
|
1014
|
+
N(error) {
|
|
1015
|
+
this.K = error;
|
|
1016
|
+
this.k.notify(this, LOADING_BIT, 0);
|
|
999
1017
|
this.h = ERROR_BIT;
|
|
1000
1018
|
if (this.A === EFFECT_USER) {
|
|
1001
1019
|
try {
|
|
1002
1020
|
return this.Z ? this.Z(error, () => {
|
|
1003
|
-
this.
|
|
1004
|
-
this.
|
|
1021
|
+
this.O?.();
|
|
1022
|
+
this.O = void 0;
|
|
1005
1023
|
}) : console.error(error);
|
|
1006
1024
|
} catch (e) {
|
|
1007
1025
|
error = e;
|
|
1008
1026
|
}
|
|
1009
1027
|
}
|
|
1010
|
-
if (!this.
|
|
1028
|
+
if (!this.k.notify(this, ERROR_BIT, ERROR_BIT))
|
|
1011
1029
|
throw error;
|
|
1012
1030
|
}
|
|
1013
1031
|
J() {
|
|
1014
|
-
if (this.
|
|
1032
|
+
if (this.c === STATE_DISPOSED)
|
|
1015
1033
|
return;
|
|
1016
1034
|
this.ba = void 0;
|
|
1017
1035
|
this._ = void 0;
|
|
1018
1036
|
this.Z = void 0;
|
|
1019
|
-
this.
|
|
1020
|
-
this.
|
|
1037
|
+
this.O?.();
|
|
1038
|
+
this.O = void 0;
|
|
1039
|
+
this.k.notify(this, ERROR_BIT | LOADING_BIT, 0);
|
|
1021
1040
|
super.J();
|
|
1022
1041
|
}
|
|
1023
1042
|
C(type) {
|
|
1024
1043
|
if (type) {
|
|
1025
|
-
const effect = this.
|
|
1026
|
-
if (effect.ca && effect.
|
|
1027
|
-
effect.
|
|
1044
|
+
const effect = this.g || this;
|
|
1045
|
+
if (effect.ca && effect.c !== STATE_DISPOSED) {
|
|
1046
|
+
effect.O?.();
|
|
1028
1047
|
try {
|
|
1029
|
-
effect.
|
|
1048
|
+
effect.O = effect.ba(effect.j, effect._);
|
|
1030
1049
|
} catch (e) {
|
|
1031
|
-
if (!effect.
|
|
1050
|
+
if (!effect.k.notify(effect, ERROR_BIT, ERROR_BIT))
|
|
1032
1051
|
throw e;
|
|
1033
1052
|
} finally {
|
|
1034
|
-
effect._ = effect.
|
|
1053
|
+
effect._ = effect.j;
|
|
1035
1054
|
effect.ca = false;
|
|
1036
1055
|
}
|
|
1037
1056
|
}
|
|
1038
1057
|
} else
|
|
1039
|
-
this.
|
|
1058
|
+
this.c !== STATE_CLEAN && runTop(this);
|
|
1040
1059
|
}
|
|
1041
1060
|
};
|
|
1042
1061
|
var EagerComputation = class extends Computation {
|
|
@@ -1044,18 +1063,15 @@ var EagerComputation = class extends Computation {
|
|
|
1044
1063
|
super(initialValue, compute2, options);
|
|
1045
1064
|
!options?.defer && this.H();
|
|
1046
1065
|
}
|
|
1047
|
-
|
|
1048
|
-
if (
|
|
1049
|
-
return ActiveTransition.a.get(this).o(state, skipQueue);
|
|
1050
|
-
}
|
|
1051
|
-
if (this.b >= state && !this.G)
|
|
1066
|
+
x(state, skipQueue) {
|
|
1067
|
+
if (this.c >= state && !this.G)
|
|
1052
1068
|
return;
|
|
1053
|
-
if (!skipQueue && (this.
|
|
1054
|
-
this.
|
|
1055
|
-
super.
|
|
1069
|
+
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.G))
|
|
1070
|
+
this.k.enqueue(EFFECT_PURE, this.C.bind(this));
|
|
1071
|
+
super.x(state, skipQueue);
|
|
1056
1072
|
}
|
|
1057
1073
|
C() {
|
|
1058
|
-
this.
|
|
1074
|
+
this.c !== STATE_CLEAN && runTop(this);
|
|
1059
1075
|
}
|
|
1060
1076
|
};
|
|
1061
1077
|
var FirewallComputation = class extends Computation {
|
|
@@ -1063,30 +1079,27 @@ var FirewallComputation = class extends Computation {
|
|
|
1063
1079
|
constructor(compute2) {
|
|
1064
1080
|
super(void 0, compute2);
|
|
1065
1081
|
}
|
|
1066
|
-
|
|
1067
|
-
if (
|
|
1068
|
-
return ActiveTransition.a.get(this).o(state, skipQueue);
|
|
1069
|
-
}
|
|
1070
|
-
if (this.b >= state && !this.G)
|
|
1082
|
+
x(state, skipQueue) {
|
|
1083
|
+
if (this.c >= state && !this.G)
|
|
1071
1084
|
return;
|
|
1072
|
-
if (!skipQueue && (this.
|
|
1073
|
-
this.
|
|
1074
|
-
super.
|
|
1085
|
+
if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.G))
|
|
1086
|
+
this.k.enqueue(EFFECT_PURE, this.C.bind(this));
|
|
1087
|
+
super.x(state, true);
|
|
1075
1088
|
this.G = !!skipQueue;
|
|
1076
1089
|
}
|
|
1077
1090
|
C() {
|
|
1078
|
-
this.
|
|
1091
|
+
this.c !== STATE_CLEAN && runTop(this);
|
|
1079
1092
|
}
|
|
1080
1093
|
};
|
|
1081
1094
|
function runTop(node) {
|
|
1082
1095
|
const ancestors = [];
|
|
1083
1096
|
for (let current = node; current !== null; current = current.m) {
|
|
1084
|
-
if (current.
|
|
1097
|
+
if (current.c !== STATE_CLEAN) {
|
|
1085
1098
|
ancestors.push(current);
|
|
1086
1099
|
}
|
|
1087
1100
|
}
|
|
1088
1101
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
1089
|
-
if (ancestors[i].
|
|
1102
|
+
if (ancestors[i].c !== STATE_DISPOSED)
|
|
1090
1103
|
ancestors[i].H();
|
|
1091
1104
|
}
|
|
1092
1105
|
}
|
|
@@ -1221,7 +1234,7 @@ var storeTraps = {
|
|
|
1221
1234
|
return desc.get.call(receiver);
|
|
1222
1235
|
}
|
|
1223
1236
|
if (Writing?.has(receiver)) {
|
|
1224
|
-
let value2 = tracked && (overridden || !proxySource) ? tracked.
|
|
1237
|
+
let value2 = tracked && (overridden || !proxySource) ? tracked.j : storeValue[property];
|
|
1225
1238
|
value2 === $DELETED && (value2 = void 0);
|
|
1226
1239
|
if (!isWrappable(value2))
|
|
1227
1240
|
return value2;
|
|
@@ -1512,6 +1525,8 @@ function applyState(next, state, keyFn, all) {
|
|
|
1512
1525
|
}
|
|
1513
1526
|
function reconcile(value, key, all = false) {
|
|
1514
1527
|
return (state) => {
|
|
1528
|
+
if (state == null)
|
|
1529
|
+
throw new Error("Cannot reconcile null or undefined state");
|
|
1515
1530
|
const keyFn = typeof key === "string" ? (item) => item[key] : key;
|
|
1516
1531
|
const eq = keyFn(state);
|
|
1517
1532
|
if (eq !== void 0 && keyFn(value) !== keyFn(state))
|
|
@@ -1751,12 +1766,12 @@ function createMemo(compute2, value, options) {
|
|
|
1751
1766
|
let resolvedValue;
|
|
1752
1767
|
return () => {
|
|
1753
1768
|
if (node) {
|
|
1754
|
-
if (node.
|
|
1769
|
+
if (node.c === STATE_DISPOSED) {
|
|
1755
1770
|
node = void 0;
|
|
1756
1771
|
return resolvedValue;
|
|
1757
1772
|
}
|
|
1758
1773
|
resolvedValue = node.wait();
|
|
1759
|
-
if (!node.a?.length && node.
|
|
1774
|
+
if (!node.a?.length && node.r?.m !== node && !(node.h & UNINITIALIZED_BIT)) {
|
|
1760
1775
|
node.dispose();
|
|
1761
1776
|
node = void 0;
|
|
1762
1777
|
}
|
|
@@ -1792,8 +1807,8 @@ function createAsync(compute2, value, options) {
|
|
|
1792
1807
|
if (abort)
|
|
1793
1808
|
return;
|
|
1794
1809
|
if (transition2)
|
|
1795
|
-
return transition2.runTransition(() => node.
|
|
1796
|
-
node.
|
|
1810
|
+
return transition2.runTransition(() => node.N(error), true);
|
|
1811
|
+
node.N(error);
|
|
1797
1812
|
}
|
|
1798
1813
|
);
|
|
1799
1814
|
} else {
|
|
@@ -1817,9 +1832,13 @@ function createAsync(compute2, value, options) {
|
|
|
1817
1832
|
);
|
|
1818
1833
|
const read = node.wait.bind(node);
|
|
1819
1834
|
read.refresh = () => {
|
|
1820
|
-
|
|
1835
|
+
let n = node;
|
|
1836
|
+
if (ActiveTransition && !node.g) {
|
|
1837
|
+
n = cloneGraph(node);
|
|
1838
|
+
}
|
|
1839
|
+
n.c = STATE_DIRTY;
|
|
1821
1840
|
refreshing = true;
|
|
1822
|
-
|
|
1841
|
+
n.H();
|
|
1823
1842
|
};
|
|
1824
1843
|
return read;
|
|
1825
1844
|
}
|
|
@@ -1900,7 +1919,7 @@ function createOptimistic(initial, compute2, key) {
|
|
|
1900
1919
|
(s) => {
|
|
1901
1920
|
const value = initial();
|
|
1902
1921
|
if (!ActiveTransition)
|
|
1903
|
-
|
|
1922
|
+
reconcile({ value }, key)(s);
|
|
1904
1923
|
},
|
|
1905
1924
|
{ value: void 0 }
|
|
1906
1925
|
);
|
|
@@ -1908,9 +1927,9 @@ function createOptimistic(initial, compute2, key) {
|
|
|
1908
1927
|
[store, setStore] = createStore({ value: initial });
|
|
1909
1928
|
const reset = () => setStore(
|
|
1910
1929
|
(s) => reconcile(
|
|
1911
|
-
typeof initial === "function" ? initial() : initial,
|
|
1930
|
+
{ value: typeof initial === "function" ? initial() : initial },
|
|
1912
1931
|
key
|
|
1913
|
-
)(s
|
|
1932
|
+
)(s)
|
|
1914
1933
|
);
|
|
1915
1934
|
let lastChange = void 0;
|
|
1916
1935
|
function write(v) {
|
|
@@ -1932,15 +1951,15 @@ function mapArray(list, map, options) {
|
|
|
1932
1951
|
const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
|
|
1933
1952
|
return updateKeyedMap.bind({
|
|
1934
1953
|
S: new Owner(),
|
|
1935
|
-
|
|
1954
|
+
o: 0,
|
|
1936
1955
|
ha: list,
|
|
1937
1956
|
D: [],
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1957
|
+
P: map,
|
|
1958
|
+
i: [],
|
|
1959
|
+
d: [],
|
|
1960
|
+
Q: keyFn,
|
|
1961
|
+
p: keyFn || options?.keyed === false ? [] : void 0,
|
|
1962
|
+
q: map.length > 1 ? [] : void 0,
|
|
1944
1963
|
T: options?.fallback
|
|
1945
1964
|
});
|
|
1946
1965
|
}
|
|
@@ -1949,113 +1968,113 @@ function updateKeyedMap() {
|
|
|
1949
1968
|
const newItems = this.ha() || [], newLen = newItems.length;
|
|
1950
1969
|
newItems[$TRACK];
|
|
1951
1970
|
runWithOwner(this.S, () => {
|
|
1952
|
-
let i, j, mapper = this.
|
|
1953
|
-
this.
|
|
1954
|
-
this.
|
|
1955
|
-
return this.
|
|
1956
|
-
Computation.prototype.read.bind(this.
|
|
1957
|
-
this.
|
|
1971
|
+
let i, j, mapper = this.p ? () => {
|
|
1972
|
+
this.p[j] = new Computation(newItems[j], null, pureOptions);
|
|
1973
|
+
this.q && (this.q[j] = new Computation(j, null, pureOptions));
|
|
1974
|
+
return this.P(
|
|
1975
|
+
Computation.prototype.read.bind(this.p[j]),
|
|
1976
|
+
this.q ? Computation.prototype.read.bind(this.q[j]) : void 0
|
|
1958
1977
|
);
|
|
1959
|
-
} : this.
|
|
1978
|
+
} : this.q ? () => {
|
|
1960
1979
|
const item = newItems[j];
|
|
1961
|
-
this.
|
|
1962
|
-
return this.
|
|
1980
|
+
this.q[j] = new Computation(j, null, pureOptions);
|
|
1981
|
+
return this.P(() => item, Computation.prototype.read.bind(this.q[j]));
|
|
1963
1982
|
} : () => {
|
|
1964
1983
|
const item = newItems[j];
|
|
1965
|
-
return this.
|
|
1984
|
+
return this.P(() => item);
|
|
1966
1985
|
};
|
|
1967
1986
|
if (newLen === 0) {
|
|
1968
|
-
if (this.
|
|
1987
|
+
if (this.o !== 0) {
|
|
1969
1988
|
this.S.dispose(false);
|
|
1970
|
-
this.
|
|
1989
|
+
this.d = [];
|
|
1971
1990
|
this.D = [];
|
|
1972
|
-
this.
|
|
1973
|
-
this.
|
|
1991
|
+
this.i = [];
|
|
1992
|
+
this.o = 0;
|
|
1993
|
+
this.p && (this.p = []);
|
|
1974
1994
|
this.q && (this.q = []);
|
|
1975
|
-
this.r && (this.r = []);
|
|
1976
1995
|
}
|
|
1977
|
-
if (this.T && !this.
|
|
1978
|
-
this.
|
|
1979
|
-
this.
|
|
1996
|
+
if (this.T && !this.i[0]) {
|
|
1997
|
+
this.i[0] = compute(
|
|
1998
|
+
this.d[0] = new Owner(),
|
|
1980
1999
|
this.T,
|
|
1981
2000
|
null
|
|
1982
2001
|
);
|
|
1983
2002
|
}
|
|
1984
|
-
} else if (this.
|
|
1985
|
-
if (this.
|
|
1986
|
-
this.
|
|
1987
|
-
this.
|
|
2003
|
+
} else if (this.o === 0) {
|
|
2004
|
+
if (this.d[0])
|
|
2005
|
+
this.d[0].dispose();
|
|
2006
|
+
this.i = new Array(newLen);
|
|
1988
2007
|
for (j = 0; j < newLen; j++) {
|
|
1989
2008
|
this.D[j] = newItems[j];
|
|
1990
|
-
this.
|
|
2009
|
+
this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
|
|
1991
2010
|
}
|
|
1992
|
-
this.
|
|
2011
|
+
this.o = newLen;
|
|
1993
2012
|
} else {
|
|
1994
|
-
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.
|
|
1995
|
-
for (start = 0, end = Math.min(this.
|
|
1996
|
-
if (this.
|
|
1997
|
-
this.
|
|
2013
|
+
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.p ? new Array(newLen) : void 0, tempIndexes = this.q ? new Array(newLen) : void 0;
|
|
2014
|
+
for (start = 0, end = Math.min(this.o, newLen); start < end && (this.D[start] === newItems[start] || this.p && compare(this.Q, this.D[start], newItems[start])); start++) {
|
|
2015
|
+
if (this.p)
|
|
2016
|
+
this.p[start].write(newItems[start]);
|
|
1998
2017
|
}
|
|
1999
|
-
for (end = this.
|
|
2000
|
-
temp[newEnd] = this.
|
|
2001
|
-
tempNodes[newEnd] = this.
|
|
2002
|
-
tempRows && (tempRows[newEnd] = this.
|
|
2003
|
-
tempIndexes && (tempIndexes[newEnd] = this.
|
|
2018
|
+
for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.D[end] === newItems[newEnd] || this.p && compare(this.Q, this.D[end], newItems[newEnd])); end--, newEnd--) {
|
|
2019
|
+
temp[newEnd] = this.i[end];
|
|
2020
|
+
tempNodes[newEnd] = this.d[end];
|
|
2021
|
+
tempRows && (tempRows[newEnd] = this.p[end]);
|
|
2022
|
+
tempIndexes && (tempIndexes[newEnd] = this.q[end]);
|
|
2004
2023
|
}
|
|
2005
2024
|
newIndices = /* @__PURE__ */ new Map();
|
|
2006
2025
|
newIndicesNext = new Array(newEnd + 1);
|
|
2007
2026
|
for (j = newEnd; j >= start; j--) {
|
|
2008
2027
|
item = newItems[j];
|
|
2009
|
-
key = this.
|
|
2028
|
+
key = this.Q ? this.Q(item) : item;
|
|
2010
2029
|
i = newIndices.get(key);
|
|
2011
2030
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
2012
2031
|
newIndices.set(key, j);
|
|
2013
2032
|
}
|
|
2014
2033
|
for (i = start; i <= end; i++) {
|
|
2015
2034
|
item = this.D[i];
|
|
2016
|
-
key = this.
|
|
2035
|
+
key = this.Q ? this.Q(item) : item;
|
|
2017
2036
|
j = newIndices.get(key);
|
|
2018
2037
|
if (j !== void 0 && j !== -1) {
|
|
2019
|
-
temp[j] = this.
|
|
2020
|
-
tempNodes[j] = this.
|
|
2021
|
-
tempRows && (tempRows[j] = this.
|
|
2022
|
-
tempIndexes && (tempIndexes[j] = this.
|
|
2038
|
+
temp[j] = this.i[i];
|
|
2039
|
+
tempNodes[j] = this.d[i];
|
|
2040
|
+
tempRows && (tempRows[j] = this.p[i]);
|
|
2041
|
+
tempIndexes && (tempIndexes[j] = this.q[i]);
|
|
2023
2042
|
j = newIndicesNext[j];
|
|
2024
2043
|
newIndices.set(key, j);
|
|
2025
2044
|
} else
|
|
2026
|
-
this.
|
|
2045
|
+
this.d[i].dispose();
|
|
2027
2046
|
}
|
|
2028
2047
|
for (j = start; j < newLen; j++) {
|
|
2029
2048
|
if (j in temp) {
|
|
2030
|
-
this.
|
|
2031
|
-
this.
|
|
2049
|
+
this.i[j] = temp[j];
|
|
2050
|
+
this.d[j] = tempNodes[j];
|
|
2032
2051
|
if (tempRows) {
|
|
2033
|
-
this.
|
|
2034
|
-
this.
|
|
2052
|
+
this.p[j] = tempRows[j];
|
|
2053
|
+
this.p[j].write(newItems[j]);
|
|
2035
2054
|
}
|
|
2036
2055
|
if (tempIndexes) {
|
|
2037
|
-
this.
|
|
2038
|
-
this.
|
|
2056
|
+
this.q[j] = tempIndexes[j];
|
|
2057
|
+
this.q[j].write(j);
|
|
2039
2058
|
}
|
|
2040
2059
|
} else {
|
|
2041
|
-
this.
|
|
2060
|
+
this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
|
|
2042
2061
|
}
|
|
2043
2062
|
}
|
|
2044
|
-
this.
|
|
2063
|
+
this.i = this.i.slice(0, this.o = newLen);
|
|
2045
2064
|
this.D = newItems.slice(0);
|
|
2046
2065
|
}
|
|
2047
2066
|
});
|
|
2048
|
-
return this.
|
|
2067
|
+
return this.i;
|
|
2049
2068
|
}
|
|
2050
2069
|
function repeat(count, map, options) {
|
|
2051
2070
|
return updateRepeat.bind({
|
|
2052
2071
|
S: new Owner(),
|
|
2053
|
-
|
|
2072
|
+
o: 0,
|
|
2054
2073
|
y: 0,
|
|
2055
2074
|
ia: count,
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2075
|
+
P: map,
|
|
2076
|
+
d: [],
|
|
2077
|
+
i: [],
|
|
2059
2078
|
ja: options?.from,
|
|
2060
2079
|
T: options?.fallback
|
|
2061
2080
|
});
|
|
@@ -2065,15 +2084,15 @@ function updateRepeat() {
|
|
|
2065
2084
|
const from = this.ja?.() || 0;
|
|
2066
2085
|
runWithOwner(this.S, () => {
|
|
2067
2086
|
if (newLen === 0) {
|
|
2068
|
-
if (this.
|
|
2087
|
+
if (this.o !== 0) {
|
|
2069
2088
|
this.S.dispose(false);
|
|
2070
|
-
this.
|
|
2071
|
-
this.
|
|
2072
|
-
this.
|
|
2089
|
+
this.d = [];
|
|
2090
|
+
this.i = [];
|
|
2091
|
+
this.o = 0;
|
|
2073
2092
|
}
|
|
2074
|
-
if (this.T && !this.
|
|
2075
|
-
this.
|
|
2076
|
-
this.
|
|
2093
|
+
if (this.T && !this.i[0]) {
|
|
2094
|
+
this.i[0] = compute(
|
|
2095
|
+
this.d[0] = new Owner(),
|
|
2077
2096
|
this.T,
|
|
2078
2097
|
null
|
|
2079
2098
|
);
|
|
@@ -2081,46 +2100,46 @@ function updateRepeat() {
|
|
|
2081
2100
|
return;
|
|
2082
2101
|
}
|
|
2083
2102
|
const to = from + newLen;
|
|
2084
|
-
const prevTo = this.y + this.
|
|
2085
|
-
if (this.
|
|
2086
|
-
this.
|
|
2103
|
+
const prevTo = this.y + this.o;
|
|
2104
|
+
if (this.o === 0 && this.d[0])
|
|
2105
|
+
this.d[0].dispose();
|
|
2087
2106
|
for (let i = to; i < prevTo; i++)
|
|
2088
|
-
this.
|
|
2107
|
+
this.d[i - this.y].dispose();
|
|
2089
2108
|
if (this.y < from) {
|
|
2090
2109
|
let i = this.y;
|
|
2091
|
-
while (i < from && i < this.
|
|
2092
|
-
this.
|
|
2093
|
-
this.
|
|
2094
|
-
this.
|
|
2110
|
+
while (i < from && i < this.o)
|
|
2111
|
+
this.d[i++].dispose();
|
|
2112
|
+
this.d.splice(0, from - this.y);
|
|
2113
|
+
this.i.splice(0, from - this.y);
|
|
2095
2114
|
} else if (this.y > from) {
|
|
2096
2115
|
let i = prevTo - this.y - 1;
|
|
2097
2116
|
let difference = this.y - from;
|
|
2098
|
-
this.
|
|
2117
|
+
this.d.length = this.i.length = newLen;
|
|
2099
2118
|
while (i >= difference) {
|
|
2100
|
-
this.
|
|
2101
|
-
this.
|
|
2119
|
+
this.d[i] = this.d[i - difference];
|
|
2120
|
+
this.i[i] = this.i[i - difference];
|
|
2102
2121
|
i--;
|
|
2103
2122
|
}
|
|
2104
2123
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
2105
|
-
this.
|
|
2106
|
-
this.
|
|
2107
|
-
() => this.
|
|
2124
|
+
this.i[i2] = compute(
|
|
2125
|
+
this.d[i2] = new Owner(),
|
|
2126
|
+
() => this.P(i2 + from),
|
|
2108
2127
|
null
|
|
2109
2128
|
);
|
|
2110
2129
|
}
|
|
2111
2130
|
}
|
|
2112
2131
|
for (let i = prevTo; i < to; i++) {
|
|
2113
|
-
this.
|
|
2114
|
-
this.
|
|
2115
|
-
() => this.
|
|
2132
|
+
this.i[i - from] = compute(
|
|
2133
|
+
this.d[i - from] = new Owner(),
|
|
2134
|
+
() => this.P(i),
|
|
2116
2135
|
null
|
|
2117
2136
|
);
|
|
2118
2137
|
}
|
|
2119
|
-
this.
|
|
2138
|
+
this.i = this.i.slice(0, newLen);
|
|
2120
2139
|
this.y = from;
|
|
2121
|
-
this.
|
|
2140
|
+
this.o = newLen;
|
|
2122
2141
|
});
|
|
2123
|
-
return this.
|
|
2142
|
+
return this.i;
|
|
2124
2143
|
}
|
|
2125
2144
|
function compare(key, a, b) {
|
|
2126
2145
|
return key ? key(a) === key(b) : true;
|
|
@@ -2138,14 +2157,14 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2138
2157
|
if (this.U & LOADING_BIT && !(this.h & UNINITIALIZED_BIT)) {
|
|
2139
2158
|
flags &= ~LOADING_BIT;
|
|
2140
2159
|
}
|
|
2141
|
-
this.
|
|
2142
|
-
return this.
|
|
2160
|
+
this.k.notify(this, this.U, flags);
|
|
2161
|
+
return this.j;
|
|
2143
2162
|
}
|
|
2144
2163
|
};
|
|
2145
2164
|
function createBoundChildren(owner, fn, queue, mask) {
|
|
2146
|
-
const parentQueue = owner.
|
|
2147
|
-
parentQueue.addChild(owner.
|
|
2148
|
-
onCleanup(() => parentQueue.removeChild(owner.
|
|
2165
|
+
const parentQueue = owner.k;
|
|
2166
|
+
parentQueue.addChild(owner.k = queue);
|
|
2167
|
+
onCleanup(() => parentQueue.removeChild(owner.k));
|
|
2149
2168
|
return compute(
|
|
2150
2169
|
owner,
|
|
2151
2170
|
() => {
|
|
@@ -2156,27 +2175,27 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
2156
2175
|
);
|
|
2157
2176
|
}
|
|
2158
2177
|
var ConditionalQueue = class extends Queue {
|
|
2159
|
-
|
|
2178
|
+
t;
|
|
2160
2179
|
V = /* @__PURE__ */ new Set();
|
|
2161
|
-
|
|
2180
|
+
s = /* @__PURE__ */ new Set();
|
|
2162
2181
|
constructor(disabled) {
|
|
2163
2182
|
super();
|
|
2164
|
-
this.
|
|
2183
|
+
this.t = disabled;
|
|
2165
2184
|
}
|
|
2166
2185
|
run(type) {
|
|
2167
|
-
if (!type || this.
|
|
2186
|
+
if (!type || this.t.read())
|
|
2168
2187
|
return;
|
|
2169
2188
|
return super.run(type);
|
|
2170
2189
|
}
|
|
2171
2190
|
notify(node, type, flags) {
|
|
2172
|
-
if (ActiveTransition && ActiveTransition.
|
|
2173
|
-
return ActiveTransition.
|
|
2174
|
-
if (this.
|
|
2191
|
+
if (ActiveTransition && ActiveTransition.u.has(this))
|
|
2192
|
+
return ActiveTransition.u.get(this).notify(node, type, flags);
|
|
2193
|
+
if (this.t.read()) {
|
|
2175
2194
|
if (type & LOADING_BIT) {
|
|
2176
2195
|
if (flags & LOADING_BIT) {
|
|
2177
|
-
this.
|
|
2196
|
+
this.s.add(node);
|
|
2178
2197
|
type &= ~LOADING_BIT;
|
|
2179
|
-
} else if (this.
|
|
2198
|
+
} else if (this.s.delete(node))
|
|
2180
2199
|
type &= ~LOADING_BIT;
|
|
2181
2200
|
}
|
|
2182
2201
|
if (type & ERROR_BIT) {
|
|
@@ -2190,43 +2209,43 @@ var ConditionalQueue = class extends Queue {
|
|
|
2190
2209
|
return type ? super.notify(node, type, flags) : true;
|
|
2191
2210
|
}
|
|
2192
2211
|
merge(queue) {
|
|
2193
|
-
queue.
|
|
2212
|
+
queue.s.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
|
|
2194
2213
|
queue.V.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
|
|
2195
2214
|
super.merge(queue);
|
|
2196
2215
|
}
|
|
2197
2216
|
};
|
|
2198
2217
|
var CollectionQueue = class extends Queue {
|
|
2199
2218
|
F;
|
|
2200
|
-
|
|
2201
|
-
|
|
2219
|
+
d = /* @__PURE__ */ new Set();
|
|
2220
|
+
t = new Computation(false, null, { pureWrite: true });
|
|
2202
2221
|
constructor(type) {
|
|
2203
2222
|
super();
|
|
2204
2223
|
this.F = type;
|
|
2205
2224
|
}
|
|
2206
2225
|
run(type) {
|
|
2207
|
-
if (!type || this.
|
|
2226
|
+
if (!type || this.t.read())
|
|
2208
2227
|
return;
|
|
2209
2228
|
return super.run(type);
|
|
2210
2229
|
}
|
|
2211
2230
|
notify(node, type, flags) {
|
|
2212
|
-
if (ActiveTransition && ActiveTransition.
|
|
2213
|
-
return ActiveTransition.
|
|
2231
|
+
if (ActiveTransition && ActiveTransition.u.has(this))
|
|
2232
|
+
return ActiveTransition.u.get(this).notify(node, type, flags);
|
|
2214
2233
|
if (!(type & this.F))
|
|
2215
2234
|
return super.notify(node, type, flags);
|
|
2216
2235
|
if (flags & this.F) {
|
|
2217
|
-
this.
|
|
2218
|
-
if (this.
|
|
2219
|
-
this.
|
|
2236
|
+
this.d.add(node);
|
|
2237
|
+
if (this.d.size === 1)
|
|
2238
|
+
this.t.write(true);
|
|
2220
2239
|
} else {
|
|
2221
|
-
this.
|
|
2222
|
-
if (this.
|
|
2223
|
-
this.
|
|
2240
|
+
this.d.delete(node);
|
|
2241
|
+
if (this.d.size === 0)
|
|
2242
|
+
this.t.write(false);
|
|
2224
2243
|
}
|
|
2225
2244
|
type &= ~this.F;
|
|
2226
2245
|
return type ? super.notify(node, type, flags) : true;
|
|
2227
2246
|
}
|
|
2228
2247
|
merge(queue) {
|
|
2229
|
-
queue.
|
|
2248
|
+
queue.d.forEach((n) => this.notify(n, this.F, this.F));
|
|
2230
2249
|
super.merge(queue);
|
|
2231
2250
|
}
|
|
2232
2251
|
};
|
|
@@ -2237,25 +2256,25 @@ function createBoundary(fn, condition) {
|
|
|
2237
2256
|
);
|
|
2238
2257
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
2239
2258
|
new EagerComputation(void 0, () => {
|
|
2240
|
-
const disabled = queue.
|
|
2259
|
+
const disabled = queue.t.read();
|
|
2241
2260
|
tree.U = disabled ? ERROR_BIT | LOADING_BIT : 0;
|
|
2242
2261
|
if (!disabled) {
|
|
2243
|
-
queue.
|
|
2262
|
+
queue.s.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
|
|
2244
2263
|
queue.V.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
|
|
2245
|
-
queue.
|
|
2264
|
+
queue.s.clear();
|
|
2246
2265
|
queue.V.clear();
|
|
2247
2266
|
}
|
|
2248
2267
|
});
|
|
2249
|
-
return () => queue.
|
|
2268
|
+
return () => queue.t.read() ? void 0 : tree.read();
|
|
2250
2269
|
}
|
|
2251
2270
|
function createCollectionBoundary(type, fn, fallback) {
|
|
2252
2271
|
const owner = new Owner();
|
|
2253
2272
|
const queue = new CollectionQueue(type);
|
|
2254
2273
|
const tree = createBoundChildren(owner, fn, queue, type);
|
|
2255
2274
|
const decision = new Computation(void 0, () => {
|
|
2256
|
-
if (!queue.
|
|
2275
|
+
if (!queue.t.read()) {
|
|
2257
2276
|
const resolved = tree.read();
|
|
2258
|
-
if (!queue.
|
|
2277
|
+
if (!queue.t.read())
|
|
2259
2278
|
return resolved;
|
|
2260
2279
|
}
|
|
2261
2280
|
return fallback(queue);
|
|
@@ -2267,13 +2286,15 @@ function createSuspense(fn, fallback) {
|
|
|
2267
2286
|
}
|
|
2268
2287
|
function createErrorBoundary(fn, fallback) {
|
|
2269
2288
|
return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
|
|
2270
|
-
let node = queue.
|
|
2289
|
+
let node = queue.d.values().next().value;
|
|
2271
2290
|
ActiveTransition && ActiveTransition.a.has(node) && (node = ActiveTransition.a.get(node));
|
|
2272
|
-
return fallback(node.
|
|
2291
|
+
return fallback(node.K, () => {
|
|
2273
2292
|
incrementClock();
|
|
2274
|
-
for (let node2 of queue.
|
|
2275
|
-
node2.
|
|
2276
|
-
|
|
2293
|
+
for (let node2 of queue.d) {
|
|
2294
|
+
if (ActiveTransition && !node2.g)
|
|
2295
|
+
node2 = cloneGraph(node2);
|
|
2296
|
+
node2.c = STATE_DIRTY;
|
|
2297
|
+
node2.k?.enqueue(node2.A, node2.C.bind(node2));
|
|
2277
2298
|
}
|
|
2278
2299
|
});
|
|
2279
2300
|
});
|