@solidjs/signals 0.6.4 → 0.7.0
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 +71 -65
- package/dist/node.cjs +402 -393
- package/dist/prod.js +397 -393
- package/dist/types/core/core.d.ts +0 -6
- package/dist/types/core/effect.d.ts +8 -0
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/signals.d.ts +31 -0
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/optimistic.d.ts +2 -2
- package/package.json +1 -1
package/dist/prod.js
CHANGED
|
@@ -45,13 +45,13 @@ function schedule() {
|
|
|
45
45
|
if (scheduled)
|
|
46
46
|
return;
|
|
47
47
|
scheduled = true;
|
|
48
|
-
if (!globalQueue.
|
|
48
|
+
if (!globalQueue.B)
|
|
49
49
|
queueMicrotask(flush);
|
|
50
50
|
}
|
|
51
51
|
function notifyUnobserved() {
|
|
52
52
|
for (let i = 0; i < Unobserved.length; i++) {
|
|
53
53
|
const source = Unobserved[i];
|
|
54
|
-
if (!source.
|
|
54
|
+
if (!source.c || !source.c.length)
|
|
55
55
|
Unobserved[i].ea?.();
|
|
56
56
|
}
|
|
57
57
|
Unobserved = [];
|
|
@@ -59,7 +59,7 @@ function notifyUnobserved() {
|
|
|
59
59
|
var pureQueue = [];
|
|
60
60
|
var Queue = class {
|
|
61
61
|
k = null;
|
|
62
|
-
|
|
62
|
+
B = false;
|
|
63
63
|
g = [[], []];
|
|
64
64
|
f = [];
|
|
65
65
|
created = clock;
|
|
@@ -84,9 +84,9 @@ var Queue = class {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
flush() {
|
|
87
|
-
if (this.
|
|
87
|
+
if (this.B)
|
|
88
88
|
return;
|
|
89
|
-
this.
|
|
89
|
+
this.B = true;
|
|
90
90
|
try {
|
|
91
91
|
this.run(EFFECT_PURE);
|
|
92
92
|
incrementClock();
|
|
@@ -94,7 +94,7 @@ var Queue = class {
|
|
|
94
94
|
this.run(EFFECT_RENDER);
|
|
95
95
|
this.run(EFFECT_USER);
|
|
96
96
|
} finally {
|
|
97
|
-
this.
|
|
97
|
+
this.B = false;
|
|
98
98
|
Unobserved.length && notifyUnobserved();
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -122,7 +122,7 @@ var Queue = class {
|
|
|
122
122
|
this.g[0].push.apply(this.g[0], queue.g[0]);
|
|
123
123
|
this.g[1].push.apply(this.g[1], queue.g[1]);
|
|
124
124
|
for (let i = 0; i < queue.f.length; i++) {
|
|
125
|
-
const og = this.f.find((c) => c.
|
|
125
|
+
const og = this.f.find((c) => c.d === queue.f[i].d);
|
|
126
126
|
if (og)
|
|
127
127
|
og.merge(queue.f[i]);
|
|
128
128
|
else
|
|
@@ -141,12 +141,12 @@ function removeSourceObservers(node, index) {
|
|
|
141
141
|
let swap;
|
|
142
142
|
for (let i = index; i < node.a.length; i++) {
|
|
143
143
|
source = getTransitionSource(node.a[i]);
|
|
144
|
-
if (source.
|
|
145
|
-
if ((swap = source.
|
|
146
|
-
source.
|
|
147
|
-
source.
|
|
144
|
+
if (source.c) {
|
|
145
|
+
if ((swap = source.c.indexOf(node)) !== -1) {
|
|
146
|
+
source.c[swap] = source.c[source.c.length - 1];
|
|
147
|
+
source.c.pop();
|
|
148
148
|
}
|
|
149
|
-
if (!source.
|
|
149
|
+
if (!source.c.length)
|
|
150
150
|
Unobserved.push(source);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
@@ -157,18 +157,18 @@ function runQueue(queue, type) {
|
|
|
157
157
|
}
|
|
158
158
|
var Transition = class _Transition {
|
|
159
159
|
a = /* @__PURE__ */ new Map();
|
|
160
|
-
|
|
160
|
+
s = /* @__PURE__ */ new Set();
|
|
161
161
|
H = /* @__PURE__ */ new Set();
|
|
162
162
|
I = /* @__PURE__ */ new Set();
|
|
163
|
-
|
|
163
|
+
D = false;
|
|
164
164
|
g = [[], []];
|
|
165
165
|
G = /* @__PURE__ */ new Map();
|
|
166
166
|
J = [];
|
|
167
167
|
f = [];
|
|
168
168
|
k = null;
|
|
169
|
-
|
|
169
|
+
B = false;
|
|
170
170
|
Y = false;
|
|
171
|
-
|
|
171
|
+
d = globalQueue;
|
|
172
172
|
created = clock;
|
|
173
173
|
constructor() {
|
|
174
174
|
this.G.set(globalQueue, this);
|
|
@@ -197,9 +197,9 @@ var Transition = class _Transition {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
flush() {
|
|
200
|
-
if (this.
|
|
200
|
+
if (this.B)
|
|
201
201
|
return;
|
|
202
|
-
this.
|
|
202
|
+
this.B = true;
|
|
203
203
|
let currentTransition = ActiveTransition;
|
|
204
204
|
ActiveTransition = this;
|
|
205
205
|
try {
|
|
@@ -209,7 +209,7 @@ var Transition = class _Transition {
|
|
|
209
209
|
ActiveTransition = currentTransition;
|
|
210
210
|
finishTransition(this);
|
|
211
211
|
} finally {
|
|
212
|
-
this.
|
|
212
|
+
this.B = false;
|
|
213
213
|
ActiveTransition = currentTransition;
|
|
214
214
|
}
|
|
215
215
|
}
|
|
@@ -226,9 +226,9 @@ var Transition = class _Transition {
|
|
|
226
226
|
if (!(type & LOADING_BIT))
|
|
227
227
|
return false;
|
|
228
228
|
if (flags & LOADING_BIT) {
|
|
229
|
-
this.
|
|
229
|
+
this.s.add(node);
|
|
230
230
|
} else {
|
|
231
|
-
this.
|
|
231
|
+
this.s.delete(node);
|
|
232
232
|
}
|
|
233
233
|
return true;
|
|
234
234
|
}
|
|
@@ -237,7 +237,7 @@ var Transition = class _Transition {
|
|
|
237
237
|
this.g[1].push.apply(this.g[1], queue.g[1]);
|
|
238
238
|
this.J.push.apply(this.J, queue.J);
|
|
239
239
|
for (let i = 0; i < queue.f.length; i++) {
|
|
240
|
-
const og = this.f.find((c) => c.
|
|
240
|
+
const og = this.f.find((c) => c.d === queue.f[i].d);
|
|
241
241
|
if (og)
|
|
242
242
|
og.merge(queue.f[i]);
|
|
243
243
|
else
|
|
@@ -248,13 +248,13 @@ var Transition = class _Transition {
|
|
|
248
248
|
if (this.Y)
|
|
249
249
|
return;
|
|
250
250
|
this.Y = true;
|
|
251
|
-
if (!this.
|
|
251
|
+
if (!this.B)
|
|
252
252
|
queueMicrotask(() => this.flush());
|
|
253
253
|
}
|
|
254
254
|
runTransition(fn, force = false) {
|
|
255
|
-
if (this.
|
|
256
|
-
if (this.
|
|
257
|
-
return this.
|
|
255
|
+
if (this.D) {
|
|
256
|
+
if (this.D instanceof _Transition)
|
|
257
|
+
return this.D.runTransition(fn, force);
|
|
258
258
|
if (!force)
|
|
259
259
|
throw new Error("Transition already completed");
|
|
260
260
|
fn();
|
|
@@ -325,29 +325,29 @@ function cloneGraph(node, optimistic) {
|
|
|
325
325
|
Object.assign(clone, node, {
|
|
326
326
|
n: null,
|
|
327
327
|
m: null,
|
|
328
|
-
|
|
328
|
+
c: null,
|
|
329
329
|
a: node.a ? [...node.a] : null,
|
|
330
|
-
|
|
330
|
+
d: node,
|
|
331
331
|
I: !!optimistic
|
|
332
332
|
});
|
|
333
|
-
delete clone.
|
|
333
|
+
delete clone.T;
|
|
334
334
|
ActiveTransition.a.set(node, clone);
|
|
335
335
|
node.j = ActiveTransition;
|
|
336
336
|
if (!optimistic && node.a) {
|
|
337
337
|
for (let i = 0; i < node.a.length; i++)
|
|
338
|
-
node.a[i].
|
|
338
|
+
node.a[i].c.push(clone);
|
|
339
339
|
}
|
|
340
|
-
if (node.
|
|
341
|
-
clone.
|
|
342
|
-
for (let i = 0, length = node.
|
|
343
|
-
!node.
|
|
340
|
+
if (node.c) {
|
|
341
|
+
clone.c = [];
|
|
342
|
+
for (let i = 0, length = node.c.length; i < length; i++) {
|
|
343
|
+
!node.c[i].d && clone.c.push(cloneGraph(node.c[i], optimistic));
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
return clone;
|
|
347
347
|
}
|
|
348
348
|
function latestTransition(t) {
|
|
349
|
-
while (t.
|
|
350
|
-
t = t.
|
|
349
|
+
while (t.D instanceof Transition)
|
|
350
|
+
t = t.D;
|
|
351
351
|
return t;
|
|
352
352
|
}
|
|
353
353
|
function replaceSourceObservers(node, transition2) {
|
|
@@ -357,16 +357,16 @@ function replaceSourceObservers(node, transition2) {
|
|
|
357
357
|
for (let i = 0; i < node.a.length; i++) {
|
|
358
358
|
transitionSource = transition2.a.get(node.a[i]);
|
|
359
359
|
source = transitionSource || node.a[i];
|
|
360
|
-
if (source.
|
|
361
|
-
source.
|
|
362
|
-
!transitionSource && source.
|
|
360
|
+
if (source.c && (swap = source.c.indexOf(node)) !== -1) {
|
|
361
|
+
source.c[swap] = transitionSource ? node.d : source.c[source.c.length - 1];
|
|
362
|
+
!transitionSource && source.c.pop();
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
function cloneQueue(queue, parent, transition2) {
|
|
367
367
|
const clone = Object.create(Object.getPrototypeOf(queue));
|
|
368
368
|
Object.assign(clone, queue, {
|
|
369
|
-
|
|
369
|
+
d: queue,
|
|
370
370
|
k: parent,
|
|
371
371
|
f: [],
|
|
372
372
|
enqueue(type, fn) {
|
|
@@ -374,7 +374,7 @@ function cloneQueue(queue, parent, transition2) {
|
|
|
374
374
|
transition2.enqueue(type, fn);
|
|
375
375
|
},
|
|
376
376
|
notify(node, type, flags) {
|
|
377
|
-
node = node.
|
|
377
|
+
node = node.d || node;
|
|
378
378
|
if (!clone.K || type & LOADING_BIT) {
|
|
379
379
|
type &= ~LOADING_BIT;
|
|
380
380
|
transition2 = latestTransition(transition2);
|
|
@@ -393,7 +393,7 @@ function cloneQueue(queue, parent, transition2) {
|
|
|
393
393
|
}
|
|
394
394
|
function resolveQueues(children) {
|
|
395
395
|
for (const child of children) {
|
|
396
|
-
const og = child.
|
|
396
|
+
const og = child.d;
|
|
397
397
|
if (og) {
|
|
398
398
|
const clonedChildren = child.f;
|
|
399
399
|
delete child.enqueue;
|
|
@@ -401,10 +401,10 @@ function resolveQueues(children) {
|
|
|
401
401
|
delete child.k;
|
|
402
402
|
delete child.f;
|
|
403
403
|
Object.assign(og, child);
|
|
404
|
-
delete og.
|
|
404
|
+
delete og.d;
|
|
405
405
|
resolveQueues(clonedChildren);
|
|
406
|
-
} else if (child.k.
|
|
407
|
-
child.k.
|
|
406
|
+
} else if (child.k.d) {
|
|
407
|
+
child.k.d.addChild(child);
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
}
|
|
@@ -418,16 +418,16 @@ function mergeTransitions(t1, t2) {
|
|
|
418
418
|
t1.I.add(c);
|
|
419
419
|
});
|
|
420
420
|
t2.H.forEach((p) => t1.H.add(p));
|
|
421
|
-
t2.
|
|
421
|
+
t2.s.forEach((n) => t1.s.add(n));
|
|
422
422
|
t1.merge(t2);
|
|
423
|
-
t2.
|
|
423
|
+
t2.D = t1;
|
|
424
424
|
}
|
|
425
425
|
function getTransitionSource(input) {
|
|
426
426
|
return ActiveTransition && ActiveTransition.a.get(input) || input;
|
|
427
427
|
}
|
|
428
428
|
function getQueue(node) {
|
|
429
|
-
const transition2 = ActiveTransition || node.
|
|
430
|
-
return transition2 && transition2.G.get(node.
|
|
429
|
+
const transition2 = ActiveTransition || node.d?.j;
|
|
430
|
+
return transition2 && transition2.G.get(node.C) || node.C;
|
|
431
431
|
}
|
|
432
432
|
function initialDispose(node) {
|
|
433
433
|
let current = node.m;
|
|
@@ -440,7 +440,7 @@ function initialDispose(node) {
|
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
442
|
function finishTransition(transition2) {
|
|
443
|
-
if (transition2.
|
|
443
|
+
if (transition2.D || transition2.Y || transition2.H.size || transition2.s.size)
|
|
444
444
|
return;
|
|
445
445
|
globalQueue.g[0].push.apply(globalQueue.g[0], transition2.g[0]);
|
|
446
446
|
globalQueue.g[1].push.apply(globalQueue.g[1], transition2.g[1]);
|
|
@@ -458,8 +458,8 @@ function finishTransition(transition2) {
|
|
|
458
458
|
delete source.j;
|
|
459
459
|
continue;
|
|
460
460
|
}
|
|
461
|
-
if (clone.Z || clone.
|
|
462
|
-
source.dispose(clone.
|
|
461
|
+
if (clone.Z || clone.b === STATE_DISPOSED) {
|
|
462
|
+
source.dispose(clone.b === STATE_DISPOSED);
|
|
463
463
|
source.emptyDisposal();
|
|
464
464
|
delete clone.Z;
|
|
465
465
|
} else {
|
|
@@ -467,17 +467,17 @@ function finishTransition(transition2) {
|
|
|
467
467
|
delete clone.n;
|
|
468
468
|
}
|
|
469
469
|
Object.assign(source, clone);
|
|
470
|
-
delete source.
|
|
470
|
+
delete source.d;
|
|
471
471
|
let current = clone.m;
|
|
472
|
-
if (current?.
|
|
473
|
-
current.
|
|
472
|
+
if (current?.y === clone)
|
|
473
|
+
current.y = source;
|
|
474
474
|
while (current?.k === clone) {
|
|
475
475
|
current.k = source;
|
|
476
476
|
current = current.m;
|
|
477
477
|
}
|
|
478
478
|
delete source.j;
|
|
479
479
|
}
|
|
480
|
-
transition2.
|
|
480
|
+
transition2.D = true;
|
|
481
481
|
for (const reset of transition2.I) {
|
|
482
482
|
delete reset.j;
|
|
483
483
|
reset();
|
|
@@ -502,11 +502,11 @@ var Owner = class {
|
|
|
502
502
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
503
503
|
k = null;
|
|
504
504
|
m = null;
|
|
505
|
-
|
|
506
|
-
|
|
505
|
+
y = null;
|
|
506
|
+
b = STATE_CLEAN;
|
|
507
507
|
n = null;
|
|
508
|
-
|
|
509
|
-
|
|
508
|
+
z = defaultContext;
|
|
509
|
+
C = globalQueue;
|
|
510
510
|
fa = 0;
|
|
511
511
|
id = null;
|
|
512
512
|
constructor(id = null, skipAppend = false) {
|
|
@@ -517,23 +517,23 @@ var Owner = class {
|
|
|
517
517
|
}
|
|
518
518
|
append(child) {
|
|
519
519
|
child.k = this;
|
|
520
|
-
child.
|
|
520
|
+
child.y = this;
|
|
521
521
|
if (this.m)
|
|
522
|
-
this.m.
|
|
522
|
+
this.m.y = child;
|
|
523
523
|
child.m = this.m;
|
|
524
524
|
this.m = child;
|
|
525
525
|
if (this.id != null && child.id == null)
|
|
526
526
|
child.id = this.getNextChildId();
|
|
527
|
-
if (child.
|
|
528
|
-
child.
|
|
527
|
+
if (child.z !== this.z) {
|
|
528
|
+
child.z = { ...this.z, ...child.z };
|
|
529
529
|
}
|
|
530
|
-
if (this.
|
|
531
|
-
child.
|
|
530
|
+
if (this.C)
|
|
531
|
+
child.C = this.C;
|
|
532
532
|
}
|
|
533
533
|
dispose(self = true) {
|
|
534
|
-
if (this.
|
|
534
|
+
if (this.b === STATE_DISPOSED)
|
|
535
535
|
return;
|
|
536
|
-
let head = self ? this.
|
|
536
|
+
let head = self ? this.y || this.k : this, current = this.m, next = null;
|
|
537
537
|
while (current && current.k === this) {
|
|
538
538
|
current.dispose(true);
|
|
539
539
|
next = current.m;
|
|
@@ -542,19 +542,19 @@ var Owner = class {
|
|
|
542
542
|
}
|
|
543
543
|
this.fa = 0;
|
|
544
544
|
if (self)
|
|
545
|
-
this.
|
|
545
|
+
this.L();
|
|
546
546
|
if (current)
|
|
547
|
-
current.
|
|
547
|
+
current.y = !self ? this : this.y;
|
|
548
548
|
if (head)
|
|
549
549
|
head.m = current;
|
|
550
550
|
}
|
|
551
|
-
|
|
552
|
-
if (this.
|
|
553
|
-
this.
|
|
551
|
+
L() {
|
|
552
|
+
if (this.y)
|
|
553
|
+
this.y.m = null;
|
|
554
554
|
this.k = null;
|
|
555
|
-
this.
|
|
556
|
-
this.
|
|
557
|
-
this.
|
|
555
|
+
this.y = null;
|
|
556
|
+
this.z = defaultContext;
|
|
557
|
+
this.b = STATE_DISPOSED;
|
|
558
558
|
this.emptyDisposal();
|
|
559
559
|
}
|
|
560
560
|
emptyDisposal() {
|
|
@@ -583,7 +583,7 @@ function getContext(context, owner = currentOwner) {
|
|
|
583
583
|
if (!owner) {
|
|
584
584
|
throw new NoOwnerError();
|
|
585
585
|
}
|
|
586
|
-
const value = hasContext(context, owner) ? owner.
|
|
586
|
+
const value = hasContext(context, owner) ? owner.z[context.id] : context.defaultValue;
|
|
587
587
|
if (isUndefined(value)) {
|
|
588
588
|
throw new ContextNotFoundError();
|
|
589
589
|
}
|
|
@@ -593,13 +593,13 @@ function setContext(context, value, owner = currentOwner) {
|
|
|
593
593
|
if (!owner) {
|
|
594
594
|
throw new NoOwnerError();
|
|
595
595
|
}
|
|
596
|
-
owner.
|
|
597
|
-
...owner.
|
|
596
|
+
owner.z = {
|
|
597
|
+
...owner.z,
|
|
598
598
|
[context.id]: isUndefined(value) ? context.defaultValue : value
|
|
599
599
|
};
|
|
600
600
|
}
|
|
601
601
|
function hasContext(context, owner = currentOwner) {
|
|
602
|
-
return !isUndefined(owner?.
|
|
602
|
+
return !isUndefined(owner?.z[context.id]);
|
|
603
603
|
}
|
|
604
604
|
function onCleanup(fn) {
|
|
605
605
|
if (!currentOwner)
|
|
@@ -637,10 +637,10 @@ function getObserver() {
|
|
|
637
637
|
var UNCHANGED = Symbol(0);
|
|
638
638
|
var Computation = class extends Owner {
|
|
639
639
|
a = null;
|
|
640
|
-
|
|
640
|
+
c = null;
|
|
641
641
|
l;
|
|
642
|
-
|
|
643
|
-
|
|
642
|
+
O;
|
|
643
|
+
P;
|
|
644
644
|
// Used in __DEV__ mode, hopefully removed in production
|
|
645
645
|
la;
|
|
646
646
|
// Using false is an optimization as an alternative to _equals: () => false
|
|
@@ -649,19 +649,19 @@ var Computation = class extends Owner {
|
|
|
649
649
|
ea;
|
|
650
650
|
ha = false;
|
|
651
651
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
652
|
-
|
|
652
|
+
i = 0;
|
|
653
653
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
654
654
|
ba = DEFAULT_FLAGS;
|
|
655
|
-
|
|
656
|
-
|
|
655
|
+
Q = -1;
|
|
656
|
+
E = false;
|
|
657
657
|
j;
|
|
658
|
-
|
|
658
|
+
d;
|
|
659
659
|
I = false;
|
|
660
660
|
constructor(initialValue, compute2, options) {
|
|
661
661
|
super(options?.id, compute2 === null);
|
|
662
|
-
this.
|
|
663
|
-
this.
|
|
664
|
-
this.
|
|
662
|
+
this.P = compute2;
|
|
663
|
+
this.b = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
664
|
+
this.i = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
665
665
|
this.l = initialValue;
|
|
666
666
|
if (options?.equals !== void 0)
|
|
667
667
|
this.aa = options.equals;
|
|
@@ -674,9 +674,9 @@ var Computation = class extends Owner {
|
|
|
674
674
|
}
|
|
675
675
|
ga() {
|
|
676
676
|
track(this);
|
|
677
|
-
newFlags |= this.
|
|
678
|
-
if (this.
|
|
679
|
-
throw this.
|
|
677
|
+
newFlags |= this.i & ~currentMask;
|
|
678
|
+
if (this.i & ERROR_BIT) {
|
|
679
|
+
throw this.O;
|
|
680
680
|
} else {
|
|
681
681
|
return this.l;
|
|
682
682
|
}
|
|
@@ -686,16 +686,16 @@ var Computation = class extends Owner {
|
|
|
686
686
|
* Automatically re-executes the surrounding computation when the value changes
|
|
687
687
|
*/
|
|
688
688
|
read() {
|
|
689
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.
|
|
689
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.i & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
690
690
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
691
691
|
if (clone !== this)
|
|
692
692
|
return clone.read();
|
|
693
693
|
}
|
|
694
|
-
if (this.
|
|
695
|
-
if (this.
|
|
694
|
+
if (this.P) {
|
|
695
|
+
if (this.i & ERROR_BIT && this.Q <= clock)
|
|
696
696
|
update(this);
|
|
697
697
|
else
|
|
698
|
-
this.
|
|
698
|
+
this.M();
|
|
699
699
|
}
|
|
700
700
|
return this.ga();
|
|
701
701
|
}
|
|
@@ -707,49 +707,49 @@ var Computation = class extends Owner {
|
|
|
707
707
|
* before continuing
|
|
708
708
|
*/
|
|
709
709
|
wait() {
|
|
710
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.
|
|
710
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.i & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
711
711
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
712
712
|
if (clone !== this)
|
|
713
713
|
return clone.wait();
|
|
714
714
|
}
|
|
715
|
-
if (this.
|
|
716
|
-
if (this.
|
|
715
|
+
if (this.P) {
|
|
716
|
+
if (this.i & ERROR_BIT && this.Q <= clock)
|
|
717
717
|
update(this);
|
|
718
718
|
else
|
|
719
|
-
this.
|
|
719
|
+
this.M();
|
|
720
720
|
}
|
|
721
|
-
if ((notStale || this.
|
|
721
|
+
if ((notStale || this.i & UNINITIALIZED_BIT) && this.i & LOADING_BIT) {
|
|
722
722
|
track(this);
|
|
723
723
|
throw new NotReadyError();
|
|
724
724
|
}
|
|
725
|
-
if (staleCheck && this.
|
|
725
|
+
if (staleCheck && this.i & LOADING_BIT) {
|
|
726
726
|
staleCheck.l = true;
|
|
727
727
|
}
|
|
728
728
|
return this.ga();
|
|
729
729
|
}
|
|
730
730
|
/** Update the computation with a new value. */
|
|
731
731
|
write(value, flags = 0, raw = false) {
|
|
732
|
-
if (ActiveTransition && !this.
|
|
732
|
+
if (ActiveTransition && !this.d) {
|
|
733
733
|
const clone = cloneGraph(this);
|
|
734
734
|
if (clone !== this)
|
|
735
735
|
return clone.write(value, flags, raw);
|
|
736
736
|
}
|
|
737
737
|
const newValue = !raw && typeof value === "function" ? value(this.l) : value;
|
|
738
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
738
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.i & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
|
|
739
739
|
this.aa === false || !this.aa(this.l, newValue));
|
|
740
740
|
if (valueChanged) {
|
|
741
741
|
this.l = newValue;
|
|
742
|
-
this.
|
|
742
|
+
this.O = void 0;
|
|
743
743
|
}
|
|
744
|
-
const changedFlagsMask = this.
|
|
745
|
-
this.
|
|
746
|
-
this.
|
|
747
|
-
if (this.
|
|
748
|
-
for (let i = 0; i < this.
|
|
744
|
+
const changedFlagsMask = this.i ^ flags, changedFlags = changedFlagsMask & flags;
|
|
745
|
+
this.i = flags;
|
|
746
|
+
this.Q = clock + 1;
|
|
747
|
+
if (this.c) {
|
|
748
|
+
for (let i = 0; i < this.c.length; i++) {
|
|
749
749
|
if (valueChanged) {
|
|
750
|
-
this.
|
|
750
|
+
this.c[i].t(STATE_DIRTY);
|
|
751
751
|
} else if (changedFlagsMask) {
|
|
752
|
-
this.
|
|
752
|
+
this.c[i]._(changedFlagsMask, changedFlags);
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
755
|
}
|
|
@@ -758,14 +758,14 @@ var Computation = class extends Owner {
|
|
|
758
758
|
/**
|
|
759
759
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
760
760
|
*/
|
|
761
|
-
|
|
762
|
-
if (this.
|
|
761
|
+
t(state, skipQueue) {
|
|
762
|
+
if (this.b >= state && !this.E)
|
|
763
763
|
return;
|
|
764
|
-
this.
|
|
765
|
-
this.
|
|
766
|
-
if (this.
|
|
767
|
-
for (let i = 0; i < this.
|
|
768
|
-
this.
|
|
764
|
+
this.E = !!skipQueue;
|
|
765
|
+
this.b = state;
|
|
766
|
+
if (this.c) {
|
|
767
|
+
for (let i = 0; i < this.c.length; i++) {
|
|
768
|
+
this.c[i].t(STATE_CHECK, skipQueue);
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
771
|
}
|
|
@@ -776,35 +776,35 @@ var Computation = class extends Owner {
|
|
|
776
776
|
* @param newFlags The source's new flags, masked to just the changed ones.
|
|
777
777
|
*/
|
|
778
778
|
_(mask, newFlags2) {
|
|
779
|
-
if (this.
|
|
779
|
+
if (this.b >= STATE_DIRTY)
|
|
780
780
|
return;
|
|
781
781
|
if (mask & this.ba) {
|
|
782
|
-
this.
|
|
782
|
+
this.t(STATE_DIRTY);
|
|
783
783
|
return;
|
|
784
784
|
}
|
|
785
|
-
if (this.
|
|
785
|
+
if (this.b >= STATE_CHECK && !this.E)
|
|
786
786
|
return;
|
|
787
|
-
const prevFlags = this.
|
|
787
|
+
const prevFlags = this.i & mask;
|
|
788
788
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
789
789
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
790
|
-
this.
|
|
790
|
+
this.t(STATE_CHECK);
|
|
791
791
|
} else {
|
|
792
|
-
this.
|
|
793
|
-
if (this.
|
|
794
|
-
for (let i = 0; i < this.
|
|
795
|
-
this.
|
|
792
|
+
this.i ^= deltaFlags;
|
|
793
|
+
if (this.c) {
|
|
794
|
+
for (let i = 0; i < this.c.length; i++) {
|
|
795
|
+
this.c[i]._(mask, newFlags2);
|
|
796
796
|
}
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
|
-
|
|
801
|
-
if (ActiveTransition && !this.
|
|
800
|
+
N(error) {
|
|
801
|
+
if (ActiveTransition && !this.d) {
|
|
802
802
|
const clone = cloneGraph(this);
|
|
803
803
|
if (clone !== this)
|
|
804
|
-
return clone.
|
|
804
|
+
return clone.N(error);
|
|
805
805
|
}
|
|
806
|
-
this.
|
|
807
|
-
this.write(UNCHANGED, this.
|
|
806
|
+
this.O = error;
|
|
807
|
+
this.write(UNCHANGED, this.i & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
808
808
|
}
|
|
809
809
|
/**
|
|
810
810
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -813,48 +813,48 @@ var Computation = class extends Owner {
|
|
|
813
813
|
*
|
|
814
814
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
815
815
|
*/
|
|
816
|
-
|
|
817
|
-
if (!this.
|
|
816
|
+
M() {
|
|
817
|
+
if (!this.P) {
|
|
818
818
|
return;
|
|
819
819
|
}
|
|
820
|
-
if (this.
|
|
820
|
+
if (this.b === STATE_DISPOSED) {
|
|
821
821
|
return;
|
|
822
822
|
}
|
|
823
|
-
if (this.
|
|
823
|
+
if (this.b === STATE_CLEAN) {
|
|
824
824
|
return;
|
|
825
825
|
}
|
|
826
826
|
let observerFlags = 0;
|
|
827
|
-
if (this.
|
|
827
|
+
if (this.b === STATE_CHECK) {
|
|
828
828
|
for (let i = 0; i < this.a.length; i++) {
|
|
829
829
|
const source = getTransitionSource(this.a[i]);
|
|
830
|
-
source.
|
|
831
|
-
observerFlags |= source.
|
|
832
|
-
if (this.
|
|
830
|
+
source.M();
|
|
831
|
+
observerFlags |= source.i & ~UNINITIALIZED_BIT;
|
|
832
|
+
if (this.b === STATE_DIRTY) {
|
|
833
833
|
break;
|
|
834
834
|
}
|
|
835
835
|
}
|
|
836
836
|
}
|
|
837
|
-
if (this.
|
|
837
|
+
if (this.b === STATE_DIRTY) {
|
|
838
838
|
update(this);
|
|
839
839
|
} else {
|
|
840
840
|
this.write(UNCHANGED, observerFlags);
|
|
841
|
-
this.
|
|
841
|
+
this.b = STATE_CLEAN;
|
|
842
842
|
}
|
|
843
843
|
}
|
|
844
844
|
/**
|
|
845
845
|
* Remove ourselves from the owner graph and the computation graph
|
|
846
846
|
*/
|
|
847
|
-
|
|
848
|
-
if (this.
|
|
847
|
+
L() {
|
|
848
|
+
if (this.b === STATE_DISPOSED)
|
|
849
849
|
return;
|
|
850
850
|
if (this.a)
|
|
851
851
|
removeSourceObservers(this, 0);
|
|
852
|
-
super.
|
|
852
|
+
super.L();
|
|
853
853
|
}
|
|
854
854
|
};
|
|
855
855
|
function track(computation) {
|
|
856
|
-
if (ActiveTransition && computation.
|
|
857
|
-
computation = computation.
|
|
856
|
+
if (ActiveTransition && computation.d)
|
|
857
|
+
computation = computation.d;
|
|
858
858
|
if (currentObserver) {
|
|
859
859
|
if (!newSources && currentObserver.a && currentObserver.a[newSourcesIndex] === computation) {
|
|
860
860
|
newSourcesIndex++;
|
|
@@ -864,7 +864,7 @@ function track(computation) {
|
|
|
864
864
|
newSources.push(computation);
|
|
865
865
|
}
|
|
866
866
|
if (updateCheck) {
|
|
867
|
-
updateCheck.l = computation.
|
|
867
|
+
updateCheck.l = computation.Q > currentObserver.Q;
|
|
868
868
|
}
|
|
869
869
|
}
|
|
870
870
|
}
|
|
@@ -874,19 +874,19 @@ function update(node) {
|
|
|
874
874
|
newSourcesIndex = 0;
|
|
875
875
|
newFlags = 0;
|
|
876
876
|
try {
|
|
877
|
-
if (ActiveTransition && node.
|
|
878
|
-
initialDispose(node.
|
|
877
|
+
if (ActiveTransition && node.d && !node.Z) {
|
|
878
|
+
initialDispose(node.d);
|
|
879
879
|
node.Z = true;
|
|
880
880
|
}
|
|
881
881
|
node.dispose(false);
|
|
882
882
|
node.emptyDisposal();
|
|
883
|
-
const result = compute(node, node.
|
|
883
|
+
const result = compute(node, node.P, node);
|
|
884
884
|
node.write(result, newFlags, true);
|
|
885
885
|
} catch (error) {
|
|
886
886
|
if (error instanceof NotReadyError) {
|
|
887
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.
|
|
887
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.i & UNINITIALIZED_BIT);
|
|
888
888
|
} else {
|
|
889
|
-
node.
|
|
889
|
+
node.N(error);
|
|
890
890
|
}
|
|
891
891
|
} finally {
|
|
892
892
|
if (newSources) {
|
|
@@ -903,10 +903,10 @@ function update(node) {
|
|
|
903
903
|
let source;
|
|
904
904
|
for (let i = newSourcesIndex; i < node.a.length; i++) {
|
|
905
905
|
source = getTransitionSource(node.a[i]);
|
|
906
|
-
if (!source.
|
|
907
|
-
source.
|
|
906
|
+
if (!source.c)
|
|
907
|
+
source.c = [node];
|
|
908
908
|
else
|
|
909
|
-
source.
|
|
909
|
+
source.c.push(node);
|
|
910
910
|
}
|
|
911
911
|
} else if (node.a && newSourcesIndex < node.a.length) {
|
|
912
912
|
removeSourceObservers(node, newSourcesIndex);
|
|
@@ -915,8 +915,8 @@ function update(node) {
|
|
|
915
915
|
newSources = prevSources;
|
|
916
916
|
newSourcesIndex = prevSourcesIndex;
|
|
917
917
|
newFlags = prevFlags;
|
|
918
|
-
node.
|
|
919
|
-
node.
|
|
918
|
+
node.Q = clock + 1;
|
|
919
|
+
node.b = STATE_CLEAN;
|
|
920
920
|
}
|
|
921
921
|
}
|
|
922
922
|
function isEqual(a, b) {
|
|
@@ -976,46 +976,6 @@ function latest(fn, fallback) {
|
|
|
976
976
|
notStale = prevNotStale;
|
|
977
977
|
}
|
|
978
978
|
}
|
|
979
|
-
function runWithObserver(observer, run) {
|
|
980
|
-
const prevSources = newSources, prevSourcesIndex = newSourcesIndex, prevFlags = newFlags;
|
|
981
|
-
newSources = null;
|
|
982
|
-
newSourcesIndex = observer.a ? observer.a.length : 0;
|
|
983
|
-
newFlags = 0;
|
|
984
|
-
try {
|
|
985
|
-
return compute(observer, run, observer);
|
|
986
|
-
} catch (error) {
|
|
987
|
-
if (error instanceof NotReadyError) {
|
|
988
|
-
observer.write(
|
|
989
|
-
UNCHANGED,
|
|
990
|
-
newFlags | LOADING_BIT | observer.h & UNINITIALIZED_BIT
|
|
991
|
-
);
|
|
992
|
-
} else {
|
|
993
|
-
observer.D(error);
|
|
994
|
-
}
|
|
995
|
-
} finally {
|
|
996
|
-
if (newSources) {
|
|
997
|
-
if (newSourcesIndex > 0) {
|
|
998
|
-
observer.a.length = newSourcesIndex + newSources.length;
|
|
999
|
-
for (let i = 0; i < newSources.length; i++) {
|
|
1000
|
-
observer.a[newSourcesIndex + i] = newSources[i];
|
|
1001
|
-
}
|
|
1002
|
-
} else {
|
|
1003
|
-
observer.a = newSources;
|
|
1004
|
-
}
|
|
1005
|
-
let source;
|
|
1006
|
-
for (let i = newSourcesIndex; i < observer.a.length; i++) {
|
|
1007
|
-
source = observer.a[i];
|
|
1008
|
-
if (!source.b)
|
|
1009
|
-
source.b = [observer];
|
|
1010
|
-
else
|
|
1011
|
-
source.b.push(observer);
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
newSources = prevSources;
|
|
1015
|
-
newSourcesIndex = prevSourcesIndex;
|
|
1016
|
-
newFlags = prevFlags;
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
979
|
function compute(owner, fn, observer) {
|
|
1020
980
|
const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
|
|
1021
981
|
currentObserver = observer;
|
|
@@ -1035,65 +995,65 @@ function compute(owner, fn, observer) {
|
|
|
1035
995
|
var Effect = class extends Computation {
|
|
1036
996
|
ca;
|
|
1037
997
|
$;
|
|
1038
|
-
|
|
998
|
+
u;
|
|
1039
999
|
da = false;
|
|
1040
|
-
|
|
1041
|
-
|
|
1000
|
+
T;
|
|
1001
|
+
r;
|
|
1042
1002
|
constructor(initialValue, compute2, effect, error, options) {
|
|
1043
1003
|
super(initialValue, compute2, options);
|
|
1044
1004
|
this.ca = effect;
|
|
1045
1005
|
this.$ = error;
|
|
1046
|
-
this.
|
|
1047
|
-
this.
|
|
1048
|
-
if (this.
|
|
1049
|
-
this.
|
|
1050
|
-
return !this.
|
|
1006
|
+
this.T = initialValue;
|
|
1007
|
+
this.r = options?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
1008
|
+
if (this.r === EFFECT_RENDER) {
|
|
1009
|
+
this.P = function(p) {
|
|
1010
|
+
return !this.d && clock > this.C.created && !(this.i & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
1051
1011
|
};
|
|
1052
1012
|
}
|
|
1053
|
-
this.
|
|
1054
|
-
!options?.defer && (this.
|
|
1013
|
+
this.M();
|
|
1014
|
+
!options?.defer && (this.r === EFFECT_USER ? getQueue(this).enqueue(this.r, this.w.bind(this)) : this.w(this.r));
|
|
1055
1015
|
}
|
|
1056
1016
|
write(value, flags = 0) {
|
|
1057
|
-
if (this.
|
|
1058
|
-
this.
|
|
1059
|
-
if (this.
|
|
1060
|
-
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.
|
|
1017
|
+
if (this.b == STATE_DIRTY) {
|
|
1018
|
+
this.i = flags;
|
|
1019
|
+
if (this.r === EFFECT_RENDER) {
|
|
1020
|
+
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.i);
|
|
1061
1021
|
}
|
|
1062
1022
|
}
|
|
1063
1023
|
if (value === UNCHANGED)
|
|
1064
1024
|
return this.l;
|
|
1065
1025
|
this.l = value;
|
|
1066
1026
|
this.da = true;
|
|
1067
|
-
this.
|
|
1027
|
+
this.O = void 0;
|
|
1068
1028
|
return value;
|
|
1069
1029
|
}
|
|
1070
|
-
|
|
1071
|
-
if (this.
|
|
1030
|
+
t(state, skipQueue) {
|
|
1031
|
+
if (this.b >= state || skipQueue)
|
|
1072
1032
|
return;
|
|
1073
|
-
if (this.
|
|
1074
|
-
getQueue(this).enqueue(this.
|
|
1075
|
-
this.
|
|
1033
|
+
if (this.b === STATE_CLEAN || this.d && !ActiveTransition)
|
|
1034
|
+
getQueue(this).enqueue(this.r, this.w.bind(this));
|
|
1035
|
+
this.b = state;
|
|
1076
1036
|
}
|
|
1077
1037
|
_(mask, newFlags2) {
|
|
1078
|
-
if (this.
|
|
1079
|
-
if (this.
|
|
1038
|
+
if (this.d) {
|
|
1039
|
+
if (this.b >= STATE_DIRTY)
|
|
1080
1040
|
return;
|
|
1081
1041
|
if (mask & 3) {
|
|
1082
|
-
this.
|
|
1042
|
+
this.t(STATE_DIRTY);
|
|
1083
1043
|
return;
|
|
1084
1044
|
}
|
|
1085
1045
|
}
|
|
1086
1046
|
super._(mask, newFlags2);
|
|
1087
1047
|
}
|
|
1088
|
-
|
|
1089
|
-
this.
|
|
1048
|
+
N(error) {
|
|
1049
|
+
this.O = error;
|
|
1090
1050
|
getQueue(this).notify(this, LOADING_BIT, 0);
|
|
1091
|
-
this.
|
|
1092
|
-
if (this.
|
|
1051
|
+
this.i = ERROR_BIT;
|
|
1052
|
+
if (this.r === EFFECT_USER) {
|
|
1093
1053
|
try {
|
|
1094
1054
|
return this.$ ? this.$(error, () => {
|
|
1095
|
-
this.
|
|
1096
|
-
this.
|
|
1055
|
+
this.u?.();
|
|
1056
|
+
this.u = void 0;
|
|
1097
1057
|
}) : console.error(error);
|
|
1098
1058
|
} catch (e) {
|
|
1099
1059
|
error = e;
|
|
@@ -1102,50 +1062,81 @@ var Effect = class extends Computation {
|
|
|
1102
1062
|
if (!getQueue(this).notify(this, ERROR_BIT, ERROR_BIT))
|
|
1103
1063
|
throw error;
|
|
1104
1064
|
}
|
|
1105
|
-
|
|
1106
|
-
if (this.
|
|
1065
|
+
L() {
|
|
1066
|
+
if (this.b === STATE_DISPOSED)
|
|
1107
1067
|
return;
|
|
1108
1068
|
this.ca = void 0;
|
|
1109
|
-
this.
|
|
1069
|
+
this.T = void 0;
|
|
1110
1070
|
this.$ = void 0;
|
|
1111
|
-
this.
|
|
1112
|
-
this.
|
|
1071
|
+
this.u?.();
|
|
1072
|
+
this.u = void 0;
|
|
1113
1073
|
getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
|
|
1114
|
-
super.
|
|
1074
|
+
super.L();
|
|
1115
1075
|
}
|
|
1116
|
-
|
|
1076
|
+
w(type) {
|
|
1117
1077
|
if (type) {
|
|
1118
|
-
const effect = this.
|
|
1119
|
-
if (effect.da && effect.
|
|
1120
|
-
effect.
|
|
1078
|
+
const effect = this.d || this;
|
|
1079
|
+
if (effect.da && effect.b !== STATE_DISPOSED) {
|
|
1080
|
+
effect.u?.();
|
|
1121
1081
|
try {
|
|
1122
|
-
effect.
|
|
1082
|
+
effect.u = effect.ca(effect.l, effect.T);
|
|
1123
1083
|
} catch (e) {
|
|
1124
1084
|
if (!getQueue(effect).notify(effect, ERROR_BIT, ERROR_BIT))
|
|
1125
1085
|
throw e;
|
|
1126
1086
|
} finally {
|
|
1127
|
-
effect.
|
|
1087
|
+
effect.T = effect.l;
|
|
1128
1088
|
effect.da = false;
|
|
1129
1089
|
}
|
|
1130
1090
|
}
|
|
1131
1091
|
} else
|
|
1132
|
-
this.
|
|
1092
|
+
this.b !== STATE_CLEAN && runTop(this);
|
|
1093
|
+
}
|
|
1094
|
+
};
|
|
1095
|
+
var TrackedEffect = class extends Computation {
|
|
1096
|
+
r = EFFECT_USER;
|
|
1097
|
+
u;
|
|
1098
|
+
constructor(compute2, options) {
|
|
1099
|
+
super(void 0, () => {
|
|
1100
|
+
this.u?.();
|
|
1101
|
+
this.u = latest(compute2);
|
|
1102
|
+
return void 0;
|
|
1103
|
+
}, options);
|
|
1104
|
+
getQueue(this).enqueue(this.r, this.w.bind(this));
|
|
1105
|
+
}
|
|
1106
|
+
t(state, skipQueue) {
|
|
1107
|
+
if (this.b >= state || skipQueue)
|
|
1108
|
+
return;
|
|
1109
|
+
if (this.b === STATE_CLEAN || this.d && !ActiveTransition)
|
|
1110
|
+
getQueue(this).enqueue(this.r, this.w.bind(this));
|
|
1111
|
+
this.b = state;
|
|
1112
|
+
}
|
|
1113
|
+
L() {
|
|
1114
|
+
if (this.b === STATE_DISPOSED)
|
|
1115
|
+
return;
|
|
1116
|
+
this.u?.();
|
|
1117
|
+
this.u = void 0;
|
|
1118
|
+
getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
|
|
1119
|
+
super.L();
|
|
1120
|
+
}
|
|
1121
|
+
w(type) {
|
|
1122
|
+
if (type)
|
|
1123
|
+
this.b !== STATE_CLEAN && runTop(this);
|
|
1133
1124
|
}
|
|
1134
1125
|
};
|
|
1135
1126
|
var EagerComputation = class extends Computation {
|
|
1136
1127
|
constructor(initialValue, compute2, options) {
|
|
1137
1128
|
super(initialValue, compute2, options);
|
|
1138
|
-
!options?.defer && this.
|
|
1129
|
+
!options?.defer && this.M();
|
|
1139
1130
|
}
|
|
1140
|
-
|
|
1141
|
-
if (this.
|
|
1131
|
+
t(state, skipQueue) {
|
|
1132
|
+
if (this.b >= state && !this.E)
|
|
1142
1133
|
return;
|
|
1143
|
-
if (!skipQueue && (this.
|
|
1144
|
-
getQueue(this).enqueue(EFFECT_PURE, this.
|
|
1145
|
-
super.
|
|
1134
|
+
if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.E))
|
|
1135
|
+
getQueue(this).enqueue(EFFECT_PURE, this.w.bind(this));
|
|
1136
|
+
super.t(state, skipQueue);
|
|
1146
1137
|
}
|
|
1147
|
-
|
|
1148
|
-
this.
|
|
1138
|
+
w() {
|
|
1139
|
+
this.b !== STATE_CLEAN && runTop(this);
|
|
1149
1140
|
}
|
|
1150
1141
|
};
|
|
1151
1142
|
var FirewallComputation = class extends Computation {
|
|
@@ -1153,16 +1144,16 @@ var FirewallComputation = class extends Computation {
|
|
|
1153
1144
|
constructor(compute2) {
|
|
1154
1145
|
super(void 0, compute2);
|
|
1155
1146
|
}
|
|
1156
|
-
|
|
1157
|
-
if (this.
|
|
1147
|
+
t(state, skipQueue) {
|
|
1148
|
+
if (this.b >= state && !this.E)
|
|
1158
1149
|
return;
|
|
1159
|
-
if (!skipQueue && (this.
|
|
1160
|
-
getQueue(this).enqueue(EFFECT_PURE, this.
|
|
1161
|
-
super.
|
|
1162
|
-
this.
|
|
1150
|
+
if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.E))
|
|
1151
|
+
getQueue(this).enqueue(EFFECT_PURE, this.w.bind(this));
|
|
1152
|
+
super.t(state, true);
|
|
1153
|
+
this.E = !!skipQueue;
|
|
1163
1154
|
}
|
|
1164
|
-
|
|
1165
|
-
this.
|
|
1155
|
+
w() {
|
|
1156
|
+
this.b !== STATE_CLEAN && runTop(this);
|
|
1166
1157
|
}
|
|
1167
1158
|
};
|
|
1168
1159
|
function runTop(node) {
|
|
@@ -1170,28 +1161,21 @@ function runTop(node) {
|
|
|
1170
1161
|
for (let current = node; current !== null; current = current.k) {
|
|
1171
1162
|
if (ActiveTransition && current.j)
|
|
1172
1163
|
current = ActiveTransition.a.get(current);
|
|
1173
|
-
if (current.
|
|
1164
|
+
if (current.b !== STATE_CLEAN) {
|
|
1174
1165
|
ancestors.push(current);
|
|
1175
1166
|
}
|
|
1176
1167
|
}
|
|
1177
1168
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
1178
|
-
if (ancestors[i].
|
|
1179
|
-
ancestors[i].
|
|
1169
|
+
if (ancestors[i].b !== STATE_DISPOSED)
|
|
1170
|
+
ancestors[i].M();
|
|
1180
1171
|
}
|
|
1181
1172
|
}
|
|
1182
1173
|
|
|
1183
1174
|
// src/signals.ts
|
|
1184
1175
|
function createSignal(first, second, third) {
|
|
1185
1176
|
if (typeof first === "function") {
|
|
1186
|
-
const
|
|
1187
|
-
|
|
1188
|
-
first(p ? untrack(p[0]) : second),
|
|
1189
|
-
null,
|
|
1190
|
-
third
|
|
1191
|
-
);
|
|
1192
|
-
return [node2.read.bind(node2), node2.write.bind(node2)];
|
|
1193
|
-
});
|
|
1194
|
-
return [() => memo()[0](), (value) => memo()[1](value)];
|
|
1177
|
+
const node2 = new Computation(second, first, third);
|
|
1178
|
+
return [node2.read.bind(node2), node2.write.bind(node2)];
|
|
1195
1179
|
}
|
|
1196
1180
|
const o = getOwner();
|
|
1197
1181
|
const needsId = o?.id != null;
|
|
@@ -1211,12 +1195,12 @@ function createMemo(compute2, value, options) {
|
|
|
1211
1195
|
let resolvedValue;
|
|
1212
1196
|
return () => {
|
|
1213
1197
|
if (node) {
|
|
1214
|
-
if (node.
|
|
1198
|
+
if (node.b === STATE_DISPOSED) {
|
|
1215
1199
|
node = void 0;
|
|
1216
1200
|
return resolvedValue;
|
|
1217
1201
|
}
|
|
1218
1202
|
resolvedValue = node.wait();
|
|
1219
|
-
if (!node.a?.length && node.m?.k !== node && !(node.
|
|
1203
|
+
if (!node.a?.length && node.m?.k !== node && !(node.i & UNINITIALIZED_BIT)) {
|
|
1220
1204
|
node.dispose();
|
|
1221
1205
|
node = void 0;
|
|
1222
1206
|
}
|
|
@@ -1254,8 +1238,8 @@ function createAsync(compute2, value, options) {
|
|
|
1254
1238
|
if (abort)
|
|
1255
1239
|
return;
|
|
1256
1240
|
if (transition2)
|
|
1257
|
-
return transition2.runTransition(() => node.
|
|
1258
|
-
node.
|
|
1241
|
+
return transition2.runTransition(() => node.N(error), true);
|
|
1242
|
+
node.N(error);
|
|
1259
1243
|
}
|
|
1260
1244
|
);
|
|
1261
1245
|
} else {
|
|
@@ -1276,10 +1260,10 @@ function createAsync(compute2, value, options) {
|
|
|
1276
1260
|
return;
|
|
1277
1261
|
if (transition2)
|
|
1278
1262
|
return transition2.runTransition(() => {
|
|
1279
|
-
node.
|
|
1263
|
+
node.N(error);
|
|
1280
1264
|
transition2 = null;
|
|
1281
1265
|
}, true);
|
|
1282
|
-
node.
|
|
1266
|
+
node.N(error);
|
|
1283
1267
|
}
|
|
1284
1268
|
})();
|
|
1285
1269
|
}
|
|
@@ -1290,12 +1274,12 @@ function createAsync(compute2, value, options) {
|
|
|
1290
1274
|
const read = node.wait.bind(node);
|
|
1291
1275
|
read.refresh = () => {
|
|
1292
1276
|
let n = node;
|
|
1293
|
-
if (ActiveTransition && !node.
|
|
1277
|
+
if (ActiveTransition && !node.d) {
|
|
1294
1278
|
n = cloneGraph(node);
|
|
1295
1279
|
}
|
|
1296
|
-
n.
|
|
1280
|
+
n.b = STATE_DIRTY;
|
|
1297
1281
|
refreshing = true;
|
|
1298
|
-
n.
|
|
1282
|
+
n.M();
|
|
1299
1283
|
};
|
|
1300
1284
|
return read;
|
|
1301
1285
|
}
|
|
@@ -1303,7 +1287,7 @@ function createEffect(compute2, effect, value, options) {
|
|
|
1303
1287
|
void new Effect(
|
|
1304
1288
|
value,
|
|
1305
1289
|
compute2,
|
|
1306
|
-
effect.effect
|
|
1290
|
+
effect.effect || effect,
|
|
1307
1291
|
effect.error,
|
|
1308
1292
|
options
|
|
1309
1293
|
);
|
|
@@ -1314,6 +1298,29 @@ function createRenderEffect(compute2, effect, value, options) {
|
|
|
1314
1298
|
...options
|
|
1315
1299
|
});
|
|
1316
1300
|
}
|
|
1301
|
+
function createTrackedEffect(compute2, options) {
|
|
1302
|
+
void new TrackedEffect(compute2, options);
|
|
1303
|
+
}
|
|
1304
|
+
function createReaction(effect, options) {
|
|
1305
|
+
let cleanup = void 0;
|
|
1306
|
+
onCleanup(() => cleanup?.());
|
|
1307
|
+
return (tracking) => {
|
|
1308
|
+
const node = new Effect(
|
|
1309
|
+
void 0,
|
|
1310
|
+
tracking,
|
|
1311
|
+
() => {
|
|
1312
|
+
cleanup?.();
|
|
1313
|
+
cleanup = (effect.effect || effect)?.();
|
|
1314
|
+
node.dispose(true);
|
|
1315
|
+
},
|
|
1316
|
+
effect.error,
|
|
1317
|
+
{
|
|
1318
|
+
defer: true,
|
|
1319
|
+
...options
|
|
1320
|
+
}
|
|
1321
|
+
);
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1317
1324
|
function createRoot(init, options) {
|
|
1318
1325
|
const owner = new Owner(options?.id);
|
|
1319
1326
|
return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
|
|
@@ -1337,23 +1344,20 @@ function resolve(fn) {
|
|
|
1337
1344
|
});
|
|
1338
1345
|
});
|
|
1339
1346
|
}
|
|
1340
|
-
function
|
|
1341
|
-
const node = new Computation(
|
|
1342
|
-
const reset = () => node.write(
|
|
1343
|
-
function write() {
|
|
1347
|
+
function createOptimistic(first, second, third) {
|
|
1348
|
+
const node = typeof first === "function" ? new Computation(second, first, third) : new Computation(first, null, second);
|
|
1349
|
+
const reset = () => node.write(first);
|
|
1350
|
+
function write(v) {
|
|
1344
1351
|
if (!ActiveTransition)
|
|
1345
|
-
|
|
1352
|
+
throw new Error("createOptimistic can only be updated inside a transition");
|
|
1346
1353
|
ActiveTransition.addOptimistic(reset);
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
function read() {
|
|
1350
|
-
const v = node.read();
|
|
1351
|
-
return ActiveTransition ? false : v;
|
|
1354
|
+
cloneGraph(node, true);
|
|
1355
|
+
queueMicrotask(() => reset.j && node.write(v));
|
|
1352
1356
|
}
|
|
1353
|
-
return [read, write];
|
|
1357
|
+
return [node.read.bind(node), write];
|
|
1354
1358
|
}
|
|
1355
1359
|
function useTransition() {
|
|
1356
|
-
const [pending, setPending] =
|
|
1360
|
+
const [pending, setPending] = createOptimistic(false);
|
|
1357
1361
|
function start(fn) {
|
|
1358
1362
|
transition((resume) => {
|
|
1359
1363
|
setPending(true);
|
|
@@ -1819,7 +1823,7 @@ function deep(store) {
|
|
|
1819
1823
|
}
|
|
1820
1824
|
|
|
1821
1825
|
// src/store/optimistic.ts
|
|
1822
|
-
function
|
|
1826
|
+
function createOptimisticStore(first, second, options) {
|
|
1823
1827
|
const derived = typeof first === "function";
|
|
1824
1828
|
const { store, node } = derived ? createProjectionInternal(first, second, options) : createProjectionInternal(() => {
|
|
1825
1829
|
}, first);
|
|
@@ -1833,7 +1837,7 @@ function createOptimistic(first, second, options) {
|
|
|
1833
1837
|
);
|
|
1834
1838
|
const write = (v) => {
|
|
1835
1839
|
if (!ActiveTransition)
|
|
1836
|
-
throw new Error("
|
|
1840
|
+
throw new Error("createOptimisticStore can only be updated inside a transition");
|
|
1837
1841
|
ActiveTransition.addOptimistic(reset);
|
|
1838
1842
|
cloneGraph(node, true);
|
|
1839
1843
|
queueMicrotask(() => reset.j && storeSetter(store, v));
|
|
@@ -2049,10 +2053,10 @@ function mapArray(list, map, options) {
|
|
|
2049
2053
|
o: 0,
|
|
2050
2054
|
ia: list,
|
|
2051
2055
|
F: [],
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
+
R: map,
|
|
2057
|
+
h: [],
|
|
2058
|
+
e: [],
|
|
2059
|
+
S: keyFn,
|
|
2056
2060
|
p: keyFn || options?.keyed === false ? [] : void 0,
|
|
2057
2061
|
q: map.length > 1 ? [] : void 0,
|
|
2058
2062
|
V: options?.fallback
|
|
@@ -2066,53 +2070,53 @@ function updateKeyedMap() {
|
|
|
2066
2070
|
let i, j, mapper = this.p ? () => {
|
|
2067
2071
|
this.p[j] = new Computation(newItems[j], null, pureOptions);
|
|
2068
2072
|
this.q && (this.q[j] = new Computation(j, null, pureOptions));
|
|
2069
|
-
return this.
|
|
2073
|
+
return this.R(
|
|
2070
2074
|
Computation.prototype.read.bind(this.p[j]),
|
|
2071
2075
|
this.q ? Computation.prototype.read.bind(this.q[j]) : void 0
|
|
2072
2076
|
);
|
|
2073
2077
|
} : this.q ? () => {
|
|
2074
2078
|
const item = newItems[j];
|
|
2075
2079
|
this.q[j] = new Computation(j, null, pureOptions);
|
|
2076
|
-
return this.
|
|
2080
|
+
return this.R(() => item, Computation.prototype.read.bind(this.q[j]));
|
|
2077
2081
|
} : () => {
|
|
2078
2082
|
const item = newItems[j];
|
|
2079
|
-
return this.
|
|
2083
|
+
return this.R(() => item);
|
|
2080
2084
|
};
|
|
2081
2085
|
if (newLen === 0) {
|
|
2082
2086
|
if (this.o !== 0) {
|
|
2083
2087
|
this.U.dispose(false);
|
|
2084
|
-
this.
|
|
2088
|
+
this.e = [];
|
|
2085
2089
|
this.F = [];
|
|
2086
|
-
this.
|
|
2090
|
+
this.h = [];
|
|
2087
2091
|
this.o = 0;
|
|
2088
2092
|
this.p && (this.p = []);
|
|
2089
2093
|
this.q && (this.q = []);
|
|
2090
2094
|
}
|
|
2091
|
-
if (this.V && !this.
|
|
2092
|
-
this.
|
|
2093
|
-
this.
|
|
2095
|
+
if (this.V && !this.h[0]) {
|
|
2096
|
+
this.h[0] = compute(
|
|
2097
|
+
this.e[0] = new Owner(),
|
|
2094
2098
|
this.V,
|
|
2095
2099
|
null
|
|
2096
2100
|
);
|
|
2097
2101
|
}
|
|
2098
2102
|
} else if (this.o === 0) {
|
|
2099
|
-
if (this.
|
|
2100
|
-
this.
|
|
2101
|
-
this.
|
|
2103
|
+
if (this.e[0])
|
|
2104
|
+
this.e[0].dispose();
|
|
2105
|
+
this.h = new Array(newLen);
|
|
2102
2106
|
for (j = 0; j < newLen; j++) {
|
|
2103
2107
|
this.F[j] = newItems[j];
|
|
2104
|
-
this.
|
|
2108
|
+
this.h[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2105
2109
|
}
|
|
2106
2110
|
this.o = newLen;
|
|
2107
2111
|
} else {
|
|
2108
2112
|
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;
|
|
2109
|
-
for (start = 0, end = Math.min(this.o, newLen); start < end && (this.F[start] === newItems[start] || this.p && compare(this.
|
|
2113
|
+
for (start = 0, end = Math.min(this.o, newLen); start < end && (this.F[start] === newItems[start] || this.p && compare(this.S, this.F[start], newItems[start])); start++) {
|
|
2110
2114
|
if (this.p)
|
|
2111
2115
|
this.p[start].write(newItems[start]);
|
|
2112
2116
|
}
|
|
2113
|
-
for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.F[end] === newItems[newEnd] || this.p && compare(this.
|
|
2114
|
-
temp[newEnd] = this.
|
|
2115
|
-
tempNodes[newEnd] = this.
|
|
2117
|
+
for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.F[end] === newItems[newEnd] || this.p && compare(this.S, this.F[end], newItems[newEnd])); end--, newEnd--) {
|
|
2118
|
+
temp[newEnd] = this.h[end];
|
|
2119
|
+
tempNodes[newEnd] = this.e[end];
|
|
2116
2120
|
tempRows && (tempRows[newEnd] = this.p[end]);
|
|
2117
2121
|
tempIndexes && (tempIndexes[newEnd] = this.q[end]);
|
|
2118
2122
|
}
|
|
@@ -2120,29 +2124,29 @@ function updateKeyedMap() {
|
|
|
2120
2124
|
newIndicesNext = new Array(newEnd + 1);
|
|
2121
2125
|
for (j = newEnd; j >= start; j--) {
|
|
2122
2126
|
item = newItems[j];
|
|
2123
|
-
key = this.
|
|
2127
|
+
key = this.S ? this.S(item) : item;
|
|
2124
2128
|
i = newIndices.get(key);
|
|
2125
2129
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
2126
2130
|
newIndices.set(key, j);
|
|
2127
2131
|
}
|
|
2128
2132
|
for (i = start; i <= end; i++) {
|
|
2129
2133
|
item = this.F[i];
|
|
2130
|
-
key = this.
|
|
2134
|
+
key = this.S ? this.S(item) : item;
|
|
2131
2135
|
j = newIndices.get(key);
|
|
2132
2136
|
if (j !== void 0 && j !== -1) {
|
|
2133
|
-
temp[j] = this.
|
|
2134
|
-
tempNodes[j] = this.
|
|
2137
|
+
temp[j] = this.h[i];
|
|
2138
|
+
tempNodes[j] = this.e[i];
|
|
2135
2139
|
tempRows && (tempRows[j] = this.p[i]);
|
|
2136
2140
|
tempIndexes && (tempIndexes[j] = this.q[i]);
|
|
2137
2141
|
j = newIndicesNext[j];
|
|
2138
2142
|
newIndices.set(key, j);
|
|
2139
2143
|
} else
|
|
2140
|
-
this.
|
|
2144
|
+
this.e[i].dispose();
|
|
2141
2145
|
}
|
|
2142
2146
|
for (j = start; j < newLen; j++) {
|
|
2143
2147
|
if (j in temp) {
|
|
2144
|
-
this.
|
|
2145
|
-
this.
|
|
2148
|
+
this.h[j] = temp[j];
|
|
2149
|
+
this.e[j] = tempNodes[j];
|
|
2146
2150
|
if (tempRows) {
|
|
2147
2151
|
this.p[j] = tempRows[j];
|
|
2148
2152
|
this.p[j].write(newItems[j]);
|
|
@@ -2152,24 +2156,24 @@ function updateKeyedMap() {
|
|
|
2152
2156
|
this.q[j].write(j);
|
|
2153
2157
|
}
|
|
2154
2158
|
} else {
|
|
2155
|
-
this.
|
|
2159
|
+
this.h[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2156
2160
|
}
|
|
2157
2161
|
}
|
|
2158
|
-
this.
|
|
2162
|
+
this.h = this.h.slice(0, this.o = newLen);
|
|
2159
2163
|
this.F = newItems.slice(0);
|
|
2160
2164
|
}
|
|
2161
2165
|
});
|
|
2162
|
-
return this.
|
|
2166
|
+
return this.h;
|
|
2163
2167
|
}
|
|
2164
2168
|
function repeat(count, map, options) {
|
|
2165
2169
|
return updateRepeat.bind({
|
|
2166
2170
|
U: new Owner(),
|
|
2167
2171
|
o: 0,
|
|
2168
|
-
|
|
2172
|
+
A: 0,
|
|
2169
2173
|
ja: count,
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2174
|
+
R: map,
|
|
2175
|
+
e: [],
|
|
2176
|
+
h: [],
|
|
2173
2177
|
ka: options?.from,
|
|
2174
2178
|
V: options?.fallback
|
|
2175
2179
|
});
|
|
@@ -2181,13 +2185,13 @@ function updateRepeat() {
|
|
|
2181
2185
|
if (newLen === 0) {
|
|
2182
2186
|
if (this.o !== 0) {
|
|
2183
2187
|
this.U.dispose(false);
|
|
2184
|
-
this.
|
|
2185
|
-
this.
|
|
2188
|
+
this.e = [];
|
|
2189
|
+
this.h = [];
|
|
2186
2190
|
this.o = 0;
|
|
2187
2191
|
}
|
|
2188
|
-
if (this.V && !this.
|
|
2189
|
-
this.
|
|
2190
|
-
this.
|
|
2192
|
+
if (this.V && !this.h[0]) {
|
|
2193
|
+
this.h[0] = compute(
|
|
2194
|
+
this.e[0] = new Owner(),
|
|
2191
2195
|
this.V,
|
|
2192
2196
|
null
|
|
2193
2197
|
);
|
|
@@ -2195,46 +2199,46 @@ function updateRepeat() {
|
|
|
2195
2199
|
return;
|
|
2196
2200
|
}
|
|
2197
2201
|
const to = from + newLen;
|
|
2198
|
-
const prevTo = this.
|
|
2199
|
-
if (this.o === 0 && this.
|
|
2200
|
-
this.
|
|
2202
|
+
const prevTo = this.A + this.o;
|
|
2203
|
+
if (this.o === 0 && this.e[0])
|
|
2204
|
+
this.e[0].dispose();
|
|
2201
2205
|
for (let i = to; i < prevTo; i++)
|
|
2202
|
-
this.
|
|
2203
|
-
if (this.
|
|
2204
|
-
let i = this.
|
|
2206
|
+
this.e[i - this.A].dispose();
|
|
2207
|
+
if (this.A < from) {
|
|
2208
|
+
let i = this.A;
|
|
2205
2209
|
while (i < from && i < this.o)
|
|
2206
|
-
this.
|
|
2207
|
-
this.
|
|
2208
|
-
this.
|
|
2209
|
-
} else if (this.
|
|
2210
|
-
let i = prevTo - this.
|
|
2211
|
-
let difference = this.
|
|
2212
|
-
this.
|
|
2210
|
+
this.e[i++].dispose();
|
|
2211
|
+
this.e.splice(0, from - this.A);
|
|
2212
|
+
this.h.splice(0, from - this.A);
|
|
2213
|
+
} else if (this.A > from) {
|
|
2214
|
+
let i = prevTo - this.A - 1;
|
|
2215
|
+
let difference = this.A - from;
|
|
2216
|
+
this.e.length = this.h.length = newLen;
|
|
2213
2217
|
while (i >= difference) {
|
|
2214
|
-
this.
|
|
2215
|
-
this.
|
|
2218
|
+
this.e[i] = this.e[i - difference];
|
|
2219
|
+
this.h[i] = this.h[i - difference];
|
|
2216
2220
|
i--;
|
|
2217
2221
|
}
|
|
2218
2222
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
2219
|
-
this.
|
|
2220
|
-
this.
|
|
2221
|
-
() => this.
|
|
2223
|
+
this.h[i2] = compute(
|
|
2224
|
+
this.e[i2] = new Owner(),
|
|
2225
|
+
() => this.R(i2 + from),
|
|
2222
2226
|
null
|
|
2223
2227
|
);
|
|
2224
2228
|
}
|
|
2225
2229
|
}
|
|
2226
2230
|
for (let i = prevTo; i < to; i++) {
|
|
2227
|
-
this.
|
|
2228
|
-
this.
|
|
2229
|
-
() => this.
|
|
2231
|
+
this.h[i - from] = compute(
|
|
2232
|
+
this.e[i - from] = new Owner(),
|
|
2233
|
+
() => this.R(i),
|
|
2230
2234
|
null
|
|
2231
2235
|
);
|
|
2232
2236
|
}
|
|
2233
|
-
this.
|
|
2234
|
-
this.
|
|
2237
|
+
this.h = this.h.slice(0, newLen);
|
|
2238
|
+
this.A = from;
|
|
2235
2239
|
this.o = newLen;
|
|
2236
2240
|
});
|
|
2237
|
-
return this.
|
|
2241
|
+
return this.h;
|
|
2238
2242
|
}
|
|
2239
2243
|
function compare(key, a, b) {
|
|
2240
2244
|
return key ? key(a) === key(b) : true;
|
|
@@ -2249,7 +2253,7 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2249
2253
|
}
|
|
2250
2254
|
write(value, flags) {
|
|
2251
2255
|
super.write(value, flags & ~this.W);
|
|
2252
|
-
if (this.W & LOADING_BIT && !(this.
|
|
2256
|
+
if (this.W & LOADING_BIT && !(this.i & UNINITIALIZED_BIT || ActiveTransition)) {
|
|
2253
2257
|
flags &= ~LOADING_BIT;
|
|
2254
2258
|
}
|
|
2255
2259
|
getQueue(this).notify(this, this.W, flags);
|
|
@@ -2257,9 +2261,9 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2257
2261
|
}
|
|
2258
2262
|
};
|
|
2259
2263
|
function createBoundChildren(owner, fn, queue, mask) {
|
|
2260
|
-
const parentQueue = owner.
|
|
2261
|
-
parentQueue.addChild(owner.
|
|
2262
|
-
onCleanup(() => parentQueue.removeChild(owner.
|
|
2264
|
+
const parentQueue = owner.C;
|
|
2265
|
+
parentQueue.addChild(owner.C = queue);
|
|
2266
|
+
onCleanup(() => parentQueue.removeChild(owner.C));
|
|
2263
2267
|
return compute(
|
|
2264
2268
|
owner,
|
|
2265
2269
|
() => {
|
|
@@ -2270,25 +2274,25 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
2270
2274
|
);
|
|
2271
2275
|
}
|
|
2272
2276
|
var ConditionalQueue = class extends Queue {
|
|
2273
|
-
|
|
2277
|
+
x;
|
|
2274
2278
|
X = /* @__PURE__ */ new Set();
|
|
2275
|
-
|
|
2279
|
+
s = /* @__PURE__ */ new Set();
|
|
2276
2280
|
constructor(disabled) {
|
|
2277
2281
|
super();
|
|
2278
|
-
this.
|
|
2282
|
+
this.x = disabled;
|
|
2279
2283
|
}
|
|
2280
2284
|
run(type) {
|
|
2281
|
-
if (!type || this.
|
|
2285
|
+
if (!type || this.x.read())
|
|
2282
2286
|
return;
|
|
2283
2287
|
return super.run(type);
|
|
2284
2288
|
}
|
|
2285
2289
|
notify(node, type, flags) {
|
|
2286
|
-
if (this.
|
|
2290
|
+
if (this.x.read()) {
|
|
2287
2291
|
if (type & LOADING_BIT) {
|
|
2288
2292
|
if (flags & LOADING_BIT) {
|
|
2289
|
-
this.
|
|
2293
|
+
this.s.add(node);
|
|
2290
2294
|
type &= ~LOADING_BIT;
|
|
2291
|
-
} else if (this.
|
|
2295
|
+
} else if (this.s.delete(node))
|
|
2292
2296
|
type &= ~LOADING_BIT;
|
|
2293
2297
|
}
|
|
2294
2298
|
if (type & ERROR_BIT) {
|
|
@@ -2302,21 +2306,21 @@ var ConditionalQueue = class extends Queue {
|
|
|
2302
2306
|
return type ? super.notify(node, type, flags) : true;
|
|
2303
2307
|
}
|
|
2304
2308
|
merge(queue) {
|
|
2305
|
-
queue.
|
|
2309
|
+
queue.s.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
|
|
2306
2310
|
queue.X.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
|
|
2307
2311
|
super.merge(queue);
|
|
2308
2312
|
}
|
|
2309
2313
|
};
|
|
2310
2314
|
var CollectionQueue = class extends Queue {
|
|
2311
2315
|
K;
|
|
2312
|
-
|
|
2313
|
-
|
|
2316
|
+
e = /* @__PURE__ */ new Set();
|
|
2317
|
+
x = new Computation(false, null, { pureWrite: true });
|
|
2314
2318
|
constructor(type) {
|
|
2315
2319
|
super();
|
|
2316
2320
|
this.K = type;
|
|
2317
2321
|
}
|
|
2318
2322
|
run(type) {
|
|
2319
|
-
if (!type || this.
|
|
2323
|
+
if (!type || this.x.read())
|
|
2320
2324
|
return;
|
|
2321
2325
|
return super.run(type);
|
|
2322
2326
|
}
|
|
@@ -2324,19 +2328,19 @@ var CollectionQueue = class extends Queue {
|
|
|
2324
2328
|
if (!(type & this.K))
|
|
2325
2329
|
return super.notify(node, type, flags);
|
|
2326
2330
|
if (flags & this.K) {
|
|
2327
|
-
this.
|
|
2328
|
-
if (this.
|
|
2329
|
-
this.
|
|
2330
|
-
} else if (this.
|
|
2331
|
-
this.
|
|
2332
|
-
if (this.
|
|
2333
|
-
this.
|
|
2331
|
+
this.e.add(node);
|
|
2332
|
+
if (this.e.size === 1)
|
|
2333
|
+
this.x.write(true);
|
|
2334
|
+
} else if (this.e.size > 0) {
|
|
2335
|
+
this.e.delete(node);
|
|
2336
|
+
if (this.e.size === 0)
|
|
2337
|
+
this.x.write(false);
|
|
2334
2338
|
}
|
|
2335
2339
|
type &= ~this.K;
|
|
2336
2340
|
return type ? super.notify(node, type, flags) : true;
|
|
2337
2341
|
}
|
|
2338
2342
|
merge(queue) {
|
|
2339
|
-
queue.
|
|
2343
|
+
queue.e.forEach((n) => this.notify(n, this.K, this.K));
|
|
2340
2344
|
super.merge(queue);
|
|
2341
2345
|
}
|
|
2342
2346
|
};
|
|
@@ -2347,25 +2351,25 @@ function createBoundary(fn, condition) {
|
|
|
2347
2351
|
);
|
|
2348
2352
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
2349
2353
|
new EagerComputation(void 0, () => {
|
|
2350
|
-
const disabled = queue.
|
|
2354
|
+
const disabled = queue.x.read();
|
|
2351
2355
|
tree.W = disabled ? ERROR_BIT | LOADING_BIT : 0;
|
|
2352
2356
|
if (!disabled) {
|
|
2353
|
-
queue.
|
|
2357
|
+
queue.s.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
|
|
2354
2358
|
queue.X.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
|
|
2355
|
-
queue.
|
|
2359
|
+
queue.s.clear();
|
|
2356
2360
|
queue.X.clear();
|
|
2357
2361
|
}
|
|
2358
2362
|
});
|
|
2359
|
-
return () => queue.
|
|
2363
|
+
return () => queue.x.read() ? void 0 : tree.read();
|
|
2360
2364
|
}
|
|
2361
2365
|
function createCollectionBoundary(type, fn, fallback) {
|
|
2362
2366
|
const owner = new Owner();
|
|
2363
2367
|
const queue = new CollectionQueue(type);
|
|
2364
2368
|
const tree = createBoundChildren(owner, fn, queue, type);
|
|
2365
2369
|
const decision = new Computation(void 0, () => {
|
|
2366
|
-
if (!queue.
|
|
2370
|
+
if (!queue.x.read()) {
|
|
2367
2371
|
const resolved = tree.read();
|
|
2368
|
-
if (!untrack(() => queue.
|
|
2372
|
+
if (!untrack(() => queue.x.read()))
|
|
2369
2373
|
return resolved;
|
|
2370
2374
|
}
|
|
2371
2375
|
return fallback(queue);
|
|
@@ -2377,14 +2381,14 @@ function createSuspense(fn, fallback) {
|
|
|
2377
2381
|
}
|
|
2378
2382
|
function createErrorBoundary(fn, fallback) {
|
|
2379
2383
|
return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
|
|
2380
|
-
let node = getTransitionSource(queue.
|
|
2381
|
-
return fallback(node.
|
|
2384
|
+
let node = getTransitionSource(queue.e.values().next().value);
|
|
2385
|
+
return fallback(node.O, () => {
|
|
2382
2386
|
incrementClock();
|
|
2383
|
-
for (let node2 of queue.
|
|
2384
|
-
if (ActiveTransition && !node2.
|
|
2387
|
+
for (let node2 of queue.e) {
|
|
2388
|
+
if (ActiveTransition && !node2.d)
|
|
2385
2389
|
node2 = cloneGraph(node2);
|
|
2386
|
-
node2.
|
|
2387
|
-
getQueue(node2).enqueue(node2.
|
|
2390
|
+
node2.b = STATE_DIRTY;
|
|
2391
|
+
getQueue(node2).enqueue(node2.r, node2.w.bind(node2));
|
|
2388
2392
|
}
|
|
2389
2393
|
});
|
|
2390
2394
|
});
|
|
@@ -2444,4 +2448,4 @@ function flattenArray(children, results = [], options) {
|
|
|
2444
2448
|
return needsUnwrap;
|
|
2445
2449
|
}
|
|
2446
2450
|
|
|
2447
|
-
export { $PROXY, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, SUPPORTS_PROXY, createAsync, createBoundary, createContext, createEffect, createErrorBoundary, createMemo, createOptimistic, createProjection, createRenderEffect, createRoot, createSignal, createStore, createSuspense, deep, flatten, flush, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, repeat, resolve,
|
|
2451
|
+
export { $PROXY, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, SUPPORTS_PROXY, createAsync, createBoundary, createContext, createEffect, createErrorBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createSuspense, createTrackedEffect, deep, flatten, flush, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, repeat, resolve, runWithOwner, setContext, snapshot, transition, untrack, useTransition };
|