@solidjs/signals 0.7.2 → 0.7.3
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 +14 -10
- package/dist/node.cjs +158 -154
- package/dist/prod.js +158 -154
- package/dist/types/core/core.d.ts +3 -1
- package/package.json +1 -1
package/dist/prod.js
CHANGED
|
@@ -60,13 +60,13 @@ var pureQueue = [];
|
|
|
60
60
|
var Queue = class {
|
|
61
61
|
k = null;
|
|
62
62
|
C = false;
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
g = [[], []];
|
|
64
|
+
h = [];
|
|
65
65
|
created = clock;
|
|
66
66
|
enqueue(type, fn) {
|
|
67
67
|
pureQueue.push(fn);
|
|
68
68
|
if (type)
|
|
69
|
-
this.
|
|
69
|
+
this.g[type - 1].push(fn);
|
|
70
70
|
schedule();
|
|
71
71
|
}
|
|
72
72
|
run(type) {
|
|
@@ -74,13 +74,13 @@ var Queue = class {
|
|
|
74
74
|
pureQueue.length && runQueue(pureQueue, type);
|
|
75
75
|
pureQueue = [];
|
|
76
76
|
return;
|
|
77
|
-
} else if (this.
|
|
78
|
-
const effects = this.
|
|
79
|
-
this.
|
|
77
|
+
} else if (this.g[type - 1].length) {
|
|
78
|
+
const effects = this.g[type - 1];
|
|
79
|
+
this.g[type - 1] = [];
|
|
80
80
|
runQueue(effects, type);
|
|
81
81
|
}
|
|
82
|
-
for (let i = 0; i < this.
|
|
83
|
-
this.
|
|
82
|
+
for (let i = 0; i < this.h.length; i++) {
|
|
83
|
+
this.h[i].run(type);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
flush() {
|
|
@@ -101,15 +101,15 @@ var Queue = class {
|
|
|
101
101
|
addChild(child) {
|
|
102
102
|
if (ActiveTransition && ActiveTransition.J.has(this))
|
|
103
103
|
return ActiveTransition.J.get(this).addChild(child);
|
|
104
|
-
this.
|
|
104
|
+
this.h.push(child);
|
|
105
105
|
child.k = this;
|
|
106
106
|
}
|
|
107
107
|
removeChild(child) {
|
|
108
108
|
if (ActiveTransition && ActiveTransition.J.has(this))
|
|
109
109
|
return ActiveTransition.J.get(this).removeChild(child);
|
|
110
|
-
const index = this.
|
|
110
|
+
const index = this.h.indexOf(child);
|
|
111
111
|
if (index >= 0) {
|
|
112
|
-
this.
|
|
112
|
+
this.h.splice(index, 1);
|
|
113
113
|
child.k = null;
|
|
114
114
|
}
|
|
115
115
|
}
|
|
@@ -119,14 +119,14 @@ var Queue = class {
|
|
|
119
119
|
return false;
|
|
120
120
|
}
|
|
121
121
|
merge(queue) {
|
|
122
|
-
this.
|
|
123
|
-
this.
|
|
124
|
-
for (let i = 0; i < queue.
|
|
125
|
-
const og = this.
|
|
122
|
+
this.g[0].push.apply(this.g[0], queue.g[0]);
|
|
123
|
+
this.g[1].push.apply(this.g[1], queue.g[1]);
|
|
124
|
+
for (let i = 0; i < queue.h.length; i++) {
|
|
125
|
+
const og = this.h.find((c) => c.d === queue.h[i].d);
|
|
126
126
|
if (og)
|
|
127
|
-
og.merge(queue.
|
|
127
|
+
og.merge(queue.h[i]);
|
|
128
128
|
else
|
|
129
|
-
this.addChild(queue.
|
|
129
|
+
this.addChild(queue.h[i]);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
};
|
|
@@ -159,12 +159,12 @@ var Transition = class _Transition {
|
|
|
159
159
|
a = /* @__PURE__ */ new Map();
|
|
160
160
|
t = /* @__PURE__ */ new Set();
|
|
161
161
|
K = /* @__PURE__ */ new Set();
|
|
162
|
-
|
|
162
|
+
m = /* @__PURE__ */ new Set();
|
|
163
163
|
D = false;
|
|
164
|
-
|
|
164
|
+
g = [[], []];
|
|
165
165
|
J = /* @__PURE__ */ new Map();
|
|
166
166
|
G = [];
|
|
167
|
-
|
|
167
|
+
h = [];
|
|
168
168
|
k = null;
|
|
169
169
|
C = false;
|
|
170
170
|
Y = false;
|
|
@@ -172,14 +172,14 @@ var Transition = class _Transition {
|
|
|
172
172
|
created = clock;
|
|
173
173
|
constructor() {
|
|
174
174
|
this.J.set(globalQueue, this);
|
|
175
|
-
for (const child of globalQueue.
|
|
175
|
+
for (const child of globalQueue.h) {
|
|
176
176
|
cloneQueue(child, this, this);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
enqueue(type, fn) {
|
|
180
180
|
this.G.push(fn);
|
|
181
181
|
if (type)
|
|
182
|
-
this.
|
|
182
|
+
this.g[type - 1].push(fn);
|
|
183
183
|
this.schedule();
|
|
184
184
|
}
|
|
185
185
|
run(type) {
|
|
@@ -187,13 +187,13 @@ var Transition = class _Transition {
|
|
|
187
187
|
this.G.length && runQueue(this.G, type);
|
|
188
188
|
this.G = [];
|
|
189
189
|
return;
|
|
190
|
-
} else if (this.
|
|
191
|
-
const effects = this.
|
|
192
|
-
this.
|
|
190
|
+
} else if (this.g[type - 1].length) {
|
|
191
|
+
const effects = this.g[type - 1];
|
|
192
|
+
this.g[type - 1] = [];
|
|
193
193
|
runQueue(effects, type);
|
|
194
194
|
}
|
|
195
|
-
for (let i = 0; i < this.
|
|
196
|
-
this.
|
|
195
|
+
for (let i = 0; i < this.h.length; i++) {
|
|
196
|
+
this.h[i].run(type);
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
flush() {
|
|
@@ -214,13 +214,13 @@ var Transition = class _Transition {
|
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
addChild(child) {
|
|
217
|
-
this.
|
|
217
|
+
this.h.push(child);
|
|
218
218
|
child.k = this;
|
|
219
219
|
}
|
|
220
220
|
removeChild(child) {
|
|
221
|
-
const index = this.
|
|
221
|
+
const index = this.h.indexOf(child);
|
|
222
222
|
if (index >= 0)
|
|
223
|
-
this.
|
|
223
|
+
this.h.splice(index, 1);
|
|
224
224
|
}
|
|
225
225
|
notify(node, type, flags) {
|
|
226
226
|
if (!(type & LOADING_BIT))
|
|
@@ -233,18 +233,18 @@ var Transition = class _Transition {
|
|
|
233
233
|
return true;
|
|
234
234
|
}
|
|
235
235
|
merge(queue) {
|
|
236
|
-
this.
|
|
237
|
-
this.
|
|
236
|
+
this.g[0].push.apply(this.g[0], queue.g[0]);
|
|
237
|
+
this.g[1].push.apply(this.g[1], queue.g[1]);
|
|
238
238
|
this.G.push.apply(this.G, queue.G);
|
|
239
|
-
queue.
|
|
240
|
-
queue.
|
|
239
|
+
queue.g[0].length = 0;
|
|
240
|
+
queue.g[1].length = 0;
|
|
241
241
|
queue.G.length = 0;
|
|
242
|
-
for (let i = 0; i < queue.
|
|
243
|
-
const og = this.
|
|
242
|
+
for (let i = 0; i < queue.h.length; i++) {
|
|
243
|
+
const og = this.h.find((c) => c.d === queue.h[i].d);
|
|
244
244
|
if (og)
|
|
245
|
-
og.merge(queue.
|
|
245
|
+
og.merge(queue.h[i]);
|
|
246
246
|
else
|
|
247
|
-
this.addChild(queue.
|
|
247
|
+
this.addChild(queue.h[i]);
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
schedule() {
|
|
@@ -310,7 +310,7 @@ var Transition = class _Transition {
|
|
|
310
310
|
return;
|
|
311
311
|
}
|
|
312
312
|
fn.j = this;
|
|
313
|
-
this.
|
|
313
|
+
this.m.add(fn);
|
|
314
314
|
}
|
|
315
315
|
};
|
|
316
316
|
function transition(fn) {
|
|
@@ -318,8 +318,10 @@ function transition(fn) {
|
|
|
318
318
|
queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
|
|
319
319
|
}
|
|
320
320
|
function cloneGraph(node) {
|
|
321
|
-
if (node.
|
|
321
|
+
if (node.m) {
|
|
322
|
+
ActiveTransition.addOptimistic(node.m);
|
|
322
323
|
return node;
|
|
324
|
+
}
|
|
323
325
|
if (node.j) {
|
|
324
326
|
if (node.j !== ActiveTransition) {
|
|
325
327
|
mergeTransitions(node.j, ActiveTransition);
|
|
@@ -329,8 +331,8 @@ function cloneGraph(node) {
|
|
|
329
331
|
}
|
|
330
332
|
const clone = Object.create(Object.getPrototypeOf(node));
|
|
331
333
|
Object.assign(clone, node, {
|
|
334
|
+
o: null,
|
|
332
335
|
n: null,
|
|
333
|
-
m: null,
|
|
334
336
|
c: null,
|
|
335
337
|
a: node.a ? [...node.a] : null,
|
|
336
338
|
d: node
|
|
@@ -373,7 +375,7 @@ function cloneQueue(queue, parent, transition2) {
|
|
|
373
375
|
Object.assign(clone, queue, {
|
|
374
376
|
d: queue,
|
|
375
377
|
k: parent,
|
|
376
|
-
|
|
378
|
+
h: [],
|
|
377
379
|
enqueue(type, fn) {
|
|
378
380
|
transition2 = latestTransition(transition2);
|
|
379
381
|
transition2.enqueue(type, fn);
|
|
@@ -390,9 +392,9 @@ function cloneQueue(queue, parent, transition2) {
|
|
|
390
392
|
return queue.notify.call(this, node, type, flags);
|
|
391
393
|
}
|
|
392
394
|
});
|
|
393
|
-
parent.
|
|
395
|
+
parent.h.push(clone);
|
|
394
396
|
transition2.J.set(queue, clone);
|
|
395
|
-
for (const child of queue.
|
|
397
|
+
for (const child of queue.h) {
|
|
396
398
|
cloneQueue(child, clone, transition2);
|
|
397
399
|
}
|
|
398
400
|
}
|
|
@@ -400,11 +402,11 @@ function resolveQueues(children) {
|
|
|
400
402
|
for (const child of children) {
|
|
401
403
|
const og = child.d;
|
|
402
404
|
if (og) {
|
|
403
|
-
const clonedChildren = child.
|
|
405
|
+
const clonedChildren = child.h;
|
|
404
406
|
delete child.enqueue;
|
|
405
407
|
delete child.notify;
|
|
406
408
|
delete child.k;
|
|
407
|
-
delete child.
|
|
409
|
+
delete child.h;
|
|
408
410
|
Object.assign(og, child);
|
|
409
411
|
delete og.d;
|
|
410
412
|
resolveQueues(clonedChildren);
|
|
@@ -418,9 +420,9 @@ function mergeTransitions(t1, t2) {
|
|
|
418
420
|
key.j = t1;
|
|
419
421
|
t1.a.set(key, value);
|
|
420
422
|
});
|
|
421
|
-
t2.
|
|
423
|
+
t2.m.forEach((c) => {
|
|
422
424
|
c.j = t1;
|
|
423
|
-
t1.
|
|
425
|
+
t1.m.add(c);
|
|
424
426
|
});
|
|
425
427
|
t2.K.forEach((p) => t1.K.add(p));
|
|
426
428
|
t2.t.forEach((n) => t1.t.add(n));
|
|
@@ -435,21 +437,21 @@ function getQueue(node) {
|
|
|
435
437
|
return transition2 && transition2.J.get(node.E) || node.E;
|
|
436
438
|
}
|
|
437
439
|
function initialDispose(node) {
|
|
438
|
-
let current = node.
|
|
440
|
+
let current = node.n;
|
|
439
441
|
while (current !== null && current.k === node) {
|
|
440
442
|
initialDispose(current);
|
|
441
443
|
const clone = ActiveTransition.a.get(current);
|
|
442
444
|
if (clone && !clone.Z)
|
|
443
445
|
clone.dispose(true);
|
|
444
|
-
current = current.
|
|
446
|
+
current = current.n;
|
|
445
447
|
}
|
|
446
448
|
}
|
|
447
449
|
function finishTransition(transition2) {
|
|
448
450
|
if (transition2.D || transition2.Y || transition2.K.size || transition2.t.size)
|
|
449
451
|
return;
|
|
450
|
-
globalQueue.
|
|
451
|
-
globalQueue.
|
|
452
|
-
resolveQueues(transition2.
|
|
452
|
+
globalQueue.g[0].push.apply(globalQueue.g[0], transition2.g[0]);
|
|
453
|
+
globalQueue.g[1].push.apply(globalQueue.g[1], transition2.g[1]);
|
|
454
|
+
resolveQueues(transition2.h);
|
|
453
455
|
for (const [source, clone] of transition2.a) {
|
|
454
456
|
if (source === clone || source.j !== transition2) {
|
|
455
457
|
delete source.j;
|
|
@@ -462,22 +464,22 @@ function finishTransition(transition2) {
|
|
|
462
464
|
source.emptyDisposal();
|
|
463
465
|
delete clone.Z;
|
|
464
466
|
} else {
|
|
465
|
-
delete clone.m;
|
|
466
467
|
delete clone.n;
|
|
468
|
+
delete clone.o;
|
|
467
469
|
}
|
|
468
470
|
Object.assign(source, clone);
|
|
469
471
|
delete source.d;
|
|
470
|
-
let current = clone.
|
|
472
|
+
let current = clone.n;
|
|
471
473
|
if (current?.z === clone)
|
|
472
474
|
current.z = source;
|
|
473
475
|
while (current?.k === clone) {
|
|
474
476
|
current.k = source;
|
|
475
|
-
current = current.
|
|
477
|
+
current = current.n;
|
|
476
478
|
}
|
|
477
479
|
delete source.j;
|
|
478
480
|
}
|
|
479
481
|
transition2.D = true;
|
|
480
|
-
for (const reset of transition2.
|
|
482
|
+
for (const reset of transition2.m) {
|
|
481
483
|
delete reset.j;
|
|
482
484
|
reset();
|
|
483
485
|
}
|
|
@@ -500,10 +502,10 @@ var Owner = class {
|
|
|
500
502
|
// However, the children are actually added in reverse creation order
|
|
501
503
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
502
504
|
k = null;
|
|
503
|
-
|
|
505
|
+
n = null;
|
|
504
506
|
z = null;
|
|
505
507
|
b = STATE_CLEAN;
|
|
506
|
-
|
|
508
|
+
o = null;
|
|
507
509
|
A = defaultContext;
|
|
508
510
|
E = globalQueue;
|
|
509
511
|
fa = 0;
|
|
@@ -517,10 +519,10 @@ var Owner = class {
|
|
|
517
519
|
append(child) {
|
|
518
520
|
child.k = this;
|
|
519
521
|
child.z = this;
|
|
520
|
-
if (this.
|
|
521
|
-
this.
|
|
522
|
-
child.
|
|
523
|
-
this.
|
|
522
|
+
if (this.n)
|
|
523
|
+
this.n.z = child;
|
|
524
|
+
child.n = this.n;
|
|
525
|
+
this.n = child;
|
|
524
526
|
if (this.id != null && child.id == null)
|
|
525
527
|
child.id = this.getNextChildId();
|
|
526
528
|
if (child.A !== this.A) {
|
|
@@ -532,11 +534,11 @@ var Owner = class {
|
|
|
532
534
|
dispose(self = true) {
|
|
533
535
|
if (this.b === STATE_DISPOSED)
|
|
534
536
|
return;
|
|
535
|
-
let head = self ? this.z || this.k : this, current = this.
|
|
537
|
+
let head = self ? this.z || this.k : this, current = this.n, next = null;
|
|
536
538
|
while (current && current.k === this) {
|
|
537
539
|
current.dispose(true);
|
|
538
|
-
next = current.
|
|
539
|
-
current.
|
|
540
|
+
next = current.n;
|
|
541
|
+
current.n = null;
|
|
540
542
|
current = next;
|
|
541
543
|
}
|
|
542
544
|
this.fa = 0;
|
|
@@ -545,11 +547,11 @@ var Owner = class {
|
|
|
545
547
|
if (current)
|
|
546
548
|
current.z = !self ? this : this.z;
|
|
547
549
|
if (head)
|
|
548
|
-
head.
|
|
550
|
+
head.n = current;
|
|
549
551
|
}
|
|
550
552
|
M() {
|
|
551
553
|
if (this.z)
|
|
552
|
-
this.z.
|
|
554
|
+
this.z.n = null;
|
|
553
555
|
this.k = null;
|
|
554
556
|
this.z = null;
|
|
555
557
|
this.A = defaultContext;
|
|
@@ -557,17 +559,17 @@ var Owner = class {
|
|
|
557
559
|
this.emptyDisposal();
|
|
558
560
|
}
|
|
559
561
|
emptyDisposal() {
|
|
560
|
-
if (!this.
|
|
562
|
+
if (!this.o)
|
|
561
563
|
return;
|
|
562
|
-
if (Array.isArray(this.
|
|
563
|
-
for (let i = 0; i < this.
|
|
564
|
-
const callable = this.
|
|
564
|
+
if (Array.isArray(this.o)) {
|
|
565
|
+
for (let i = 0; i < this.o.length; i++) {
|
|
566
|
+
const callable = this.o[i];
|
|
565
567
|
callable.call(callable);
|
|
566
568
|
}
|
|
567
569
|
} else {
|
|
568
|
-
this.
|
|
570
|
+
this.o.call(this.o);
|
|
569
571
|
}
|
|
570
|
-
this.
|
|
572
|
+
this.o = null;
|
|
571
573
|
}
|
|
572
574
|
getNextChildId() {
|
|
573
575
|
if (this.id != null)
|
|
@@ -604,12 +606,12 @@ function onCleanup(fn) {
|
|
|
604
606
|
if (!currentOwner)
|
|
605
607
|
return fn;
|
|
606
608
|
const node = currentOwner;
|
|
607
|
-
if (!node.
|
|
608
|
-
node.
|
|
609
|
-
} else if (Array.isArray(node.
|
|
610
|
-
node.
|
|
609
|
+
if (!node.o) {
|
|
610
|
+
node.o = fn;
|
|
611
|
+
} else if (Array.isArray(node.o)) {
|
|
612
|
+
node.o.push(fn);
|
|
611
613
|
} else {
|
|
612
|
-
node.
|
|
614
|
+
node.o = [node.o, fn];
|
|
613
615
|
}
|
|
614
616
|
return fn;
|
|
615
617
|
}
|
|
@@ -648,19 +650,19 @@ var Computation = class extends Owner {
|
|
|
648
650
|
ea;
|
|
649
651
|
ha = false;
|
|
650
652
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
651
|
-
|
|
653
|
+
f = 0;
|
|
652
654
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
653
655
|
ba = DEFAULT_FLAGS;
|
|
654
656
|
Q = -1;
|
|
655
657
|
H = false;
|
|
656
658
|
j;
|
|
657
659
|
d;
|
|
658
|
-
|
|
660
|
+
m;
|
|
659
661
|
constructor(initialValue, compute2, options) {
|
|
660
662
|
super(options?.id, compute2 === null);
|
|
661
663
|
this.P = compute2;
|
|
662
664
|
this.b = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
663
|
-
this.
|
|
665
|
+
this.f = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
664
666
|
this.l = initialValue;
|
|
665
667
|
if (options?.equals !== void 0)
|
|
666
668
|
this.aa = options.equals;
|
|
@@ -673,8 +675,8 @@ var Computation = class extends Owner {
|
|
|
673
675
|
}
|
|
674
676
|
ga() {
|
|
675
677
|
track(this);
|
|
676
|
-
newFlags |= this.
|
|
677
|
-
if (this.
|
|
678
|
+
newFlags |= this.f & ~currentMask;
|
|
679
|
+
if (this.f & ERROR_BIT) {
|
|
678
680
|
throw this.O;
|
|
679
681
|
} else {
|
|
680
682
|
return this.l;
|
|
@@ -685,13 +687,13 @@ var Computation = class extends Owner {
|
|
|
685
687
|
* Automatically re-executes the surrounding computation when the value changes
|
|
686
688
|
*/
|
|
687
689
|
read() {
|
|
688
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.
|
|
690
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.f & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
689
691
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
690
692
|
if (clone !== this)
|
|
691
693
|
return clone.read();
|
|
692
694
|
}
|
|
693
695
|
if (this.P) {
|
|
694
|
-
if (this.
|
|
696
|
+
if (this.f & ERROR_BIT && this.Q <= clock)
|
|
695
697
|
update(this);
|
|
696
698
|
else
|
|
697
699
|
this.F();
|
|
@@ -706,22 +708,22 @@ var Computation = class extends Owner {
|
|
|
706
708
|
* before continuing
|
|
707
709
|
*/
|
|
708
710
|
wait() {
|
|
709
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.
|
|
711
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.f & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
710
712
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
711
713
|
if (clone !== this)
|
|
712
714
|
return clone.wait();
|
|
713
715
|
}
|
|
714
716
|
if (this.P) {
|
|
715
|
-
if (this.
|
|
717
|
+
if (this.f & ERROR_BIT && this.Q <= clock)
|
|
716
718
|
update(this);
|
|
717
719
|
else
|
|
718
720
|
this.F();
|
|
719
721
|
}
|
|
720
|
-
if ((notStale || this.
|
|
722
|
+
if ((notStale || this.f & UNINITIALIZED_BIT) && this.f & LOADING_BIT) {
|
|
721
723
|
track(this);
|
|
722
724
|
throw new NotReadyError();
|
|
723
725
|
}
|
|
724
|
-
if (staleCheck && this.
|
|
726
|
+
if (staleCheck && this.f & LOADING_BIT) {
|
|
725
727
|
staleCheck.l = true;
|
|
726
728
|
}
|
|
727
729
|
return this.ga();
|
|
@@ -734,16 +736,16 @@ var Computation = class extends Owner {
|
|
|
734
736
|
return clone.write(value, flags, raw);
|
|
735
737
|
}
|
|
736
738
|
const newValue = !raw && typeof value === "function" ? value(this.l) : value;
|
|
737
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
739
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.f & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
|
|
738
740
|
this.aa === false || !this.aa(this.l, newValue));
|
|
739
741
|
if (valueChanged) {
|
|
740
742
|
this.l = newValue;
|
|
741
743
|
this.O = void 0;
|
|
742
744
|
}
|
|
743
|
-
const changedFlagsMask = this.
|
|
744
|
-
this.
|
|
745
|
+
const changedFlagsMask = this.f ^ flags, changedFlags = changedFlagsMask & flags;
|
|
746
|
+
this.f = flags;
|
|
745
747
|
this.Q = clock + 1;
|
|
746
|
-
if (this.c && !(this.
|
|
748
|
+
if (this.c && !(this.m && ActiveTransition)) {
|
|
747
749
|
for (let i = 0; i < this.c.length; i++) {
|
|
748
750
|
if (valueChanged) {
|
|
749
751
|
this.c[i].u(STATE_DIRTY);
|
|
@@ -762,7 +764,7 @@ var Computation = class extends Owner {
|
|
|
762
764
|
return;
|
|
763
765
|
this.H = !!skipQueue;
|
|
764
766
|
this.b = state;
|
|
765
|
-
if (this.c && !(this.
|
|
767
|
+
if (this.c && !(this.m && ActiveTransition)) {
|
|
766
768
|
for (let i = 0; i < this.c.length; i++) {
|
|
767
769
|
this.c[i].u(STATE_CHECK, skipQueue);
|
|
768
770
|
}
|
|
@@ -777,18 +779,18 @@ var Computation = class extends Owner {
|
|
|
777
779
|
_(mask, newFlags2) {
|
|
778
780
|
if (this.b >= STATE_DIRTY)
|
|
779
781
|
return;
|
|
780
|
-
if (mask & this.ba || this.
|
|
782
|
+
if (mask & this.ba || this.m && ActiveTransition) {
|
|
781
783
|
this.u(STATE_DIRTY);
|
|
782
784
|
return;
|
|
783
785
|
}
|
|
784
786
|
if (this.b >= STATE_CHECK && !this.H)
|
|
785
787
|
return;
|
|
786
|
-
const prevFlags = this.
|
|
788
|
+
const prevFlags = this.f & mask;
|
|
787
789
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
788
790
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
789
791
|
this.u(STATE_CHECK);
|
|
790
792
|
} else {
|
|
791
|
-
this.
|
|
793
|
+
this.f ^= deltaFlags;
|
|
792
794
|
if (this.c) {
|
|
793
795
|
for (let i = 0; i < this.c.length; i++) {
|
|
794
796
|
this.c[i]._(mask, newFlags2);
|
|
@@ -803,7 +805,7 @@ var Computation = class extends Owner {
|
|
|
803
805
|
return clone.N(error);
|
|
804
806
|
}
|
|
805
807
|
this.O = error;
|
|
806
|
-
this.write(UNCHANGED, this.
|
|
808
|
+
this.write(UNCHANGED, this.f & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
807
809
|
}
|
|
808
810
|
/**
|
|
809
811
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -827,7 +829,7 @@ var Computation = class extends Owner {
|
|
|
827
829
|
for (let i = 0; i < this.a.length; i++) {
|
|
828
830
|
const source = getTransitionSource(this.a[i]);
|
|
829
831
|
source.F();
|
|
830
|
-
observerFlags |= source.
|
|
832
|
+
observerFlags |= source.f & ~UNINITIALIZED_BIT;
|
|
831
833
|
if (this.b === STATE_DIRTY) {
|
|
832
834
|
break;
|
|
833
835
|
}
|
|
@@ -883,7 +885,7 @@ function update(node) {
|
|
|
883
885
|
node.write(result, newFlags, true);
|
|
884
886
|
} catch (error) {
|
|
885
887
|
if (error instanceof NotReadyError) {
|
|
886
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.
|
|
888
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.f & UNINITIALIZED_BIT);
|
|
887
889
|
} else {
|
|
888
890
|
node.N(error);
|
|
889
891
|
}
|
|
@@ -957,7 +959,7 @@ function isPending(fn, loadingValue) {
|
|
|
957
959
|
return pendingCheck(fn, loadingValue);
|
|
958
960
|
const c = new Computation(void 0, () => pendingCheck(fn, loadingValue));
|
|
959
961
|
c.ba |= LOADING_BIT;
|
|
960
|
-
return c.
|
|
962
|
+
return c.wait();
|
|
961
963
|
}
|
|
962
964
|
function latest(fn, fallback) {
|
|
963
965
|
const argLength = arguments.length;
|
|
@@ -1006,7 +1008,7 @@ var Effect = class extends Computation {
|
|
|
1006
1008
|
this.s = options?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
1007
1009
|
if (this.s === EFFECT_RENDER) {
|
|
1008
1010
|
this.P = function(p) {
|
|
1009
|
-
return !this.d && clock > this.E.created && !(this.
|
|
1011
|
+
return !this.d && clock > this.E.created && !(this.f & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
1010
1012
|
};
|
|
1011
1013
|
}
|
|
1012
1014
|
this.F();
|
|
@@ -1014,9 +1016,9 @@ var Effect = class extends Computation {
|
|
|
1014
1016
|
}
|
|
1015
1017
|
write(value, flags = 0) {
|
|
1016
1018
|
if (this.b == STATE_DIRTY) {
|
|
1017
|
-
this.
|
|
1019
|
+
this.f = flags;
|
|
1018
1020
|
if (this.s === EFFECT_RENDER) {
|
|
1019
|
-
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.
|
|
1021
|
+
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.f);
|
|
1020
1022
|
}
|
|
1021
1023
|
}
|
|
1022
1024
|
if (value === UNCHANGED)
|
|
@@ -1047,7 +1049,7 @@ var Effect = class extends Computation {
|
|
|
1047
1049
|
N(error) {
|
|
1048
1050
|
this.O = error;
|
|
1049
1051
|
getQueue(this).notify(this, LOADING_BIT, 0);
|
|
1050
|
-
this.
|
|
1052
|
+
this.f = ERROR_BIT;
|
|
1051
1053
|
if (this.s === EFFECT_USER) {
|
|
1052
1054
|
try {
|
|
1053
1055
|
return this.$ ? this.$(error, () => {
|
|
@@ -1152,10 +1154,13 @@ var FirewallComputation = class extends Computation {
|
|
|
1152
1154
|
this.H = !!skipQueue;
|
|
1153
1155
|
}
|
|
1154
1156
|
x() {
|
|
1155
|
-
const prevFlags = this.
|
|
1157
|
+
const prevFlags = this.f;
|
|
1156
1158
|
this.b !== STATE_CLEAN && runTop(this);
|
|
1157
|
-
if (ActiveTransition && this.
|
|
1158
|
-
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.
|
|
1159
|
+
if (ActiveTransition && this.m && (this.f !== prevFlags || this.f !== this.m.flags)) {
|
|
1160
|
+
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.f);
|
|
1161
|
+
this.m.flags = this.f;
|
|
1162
|
+
this.f = prevFlags;
|
|
1163
|
+
}
|
|
1159
1164
|
}
|
|
1160
1165
|
};
|
|
1161
1166
|
function runTop(node) {
|
|
@@ -1205,7 +1210,7 @@ function createMemo(compute2, value, options) {
|
|
|
1205
1210
|
return resolvedValue;
|
|
1206
1211
|
}
|
|
1207
1212
|
resolvedValue = node.wait();
|
|
1208
|
-
if (!node.a?.length && node.
|
|
1213
|
+
if (!node.a?.length && node.n?.k !== node && !(node.f & UNINITIALIZED_BIT)) {
|
|
1209
1214
|
node.dispose();
|
|
1210
1215
|
node = void 0;
|
|
1211
1216
|
}
|
|
@@ -1352,18 +1357,17 @@ function resolve(fn) {
|
|
|
1352
1357
|
function createOptimistic(first, second, third) {
|
|
1353
1358
|
const node = typeof first === "function" ? new Computation(second, (prev) => {
|
|
1354
1359
|
const res = first(prev);
|
|
1355
|
-
if (
|
|
1360
|
+
if (node.m.j)
|
|
1356
1361
|
return prev;
|
|
1357
1362
|
return res;
|
|
1358
1363
|
}, third) : new Computation(first, null, second);
|
|
1359
|
-
node.
|
|
1360
|
-
const reset = () => node.write(first);
|
|
1364
|
+
node.m = () => node.write(first);
|
|
1361
1365
|
function write(v) {
|
|
1362
1366
|
if (!ActiveTransition)
|
|
1363
1367
|
throw new Error("createOptimistic can only be updated inside a transition");
|
|
1364
|
-
ActiveTransition.addOptimistic(
|
|
1368
|
+
ActiveTransition.addOptimistic(node.m);
|
|
1365
1369
|
queueMicrotask(() => {
|
|
1366
|
-
if (
|
|
1370
|
+
if (node.m.j) {
|
|
1367
1371
|
node.F();
|
|
1368
1372
|
node.write(v);
|
|
1369
1373
|
}
|
|
@@ -1847,7 +1851,6 @@ function createOptimisticStore(first, second, options) {
|
|
|
1847
1851
|
return res;
|
|
1848
1852
|
}, second, options) : createProjectionInternal(() => {
|
|
1849
1853
|
}, first);
|
|
1850
|
-
node.r = true;
|
|
1851
1854
|
const reset = () => storeSetter(
|
|
1852
1855
|
store,
|
|
1853
1856
|
reconcile(
|
|
@@ -1862,6 +1865,7 @@ function createOptimisticStore(first, second, options) {
|
|
|
1862
1865
|
ActiveTransition.addOptimistic(reset);
|
|
1863
1866
|
queueMicrotask(() => reset.j && storeSetter(store, v));
|
|
1864
1867
|
};
|
|
1868
|
+
node.m = reset;
|
|
1865
1869
|
return [store, write];
|
|
1866
1870
|
}
|
|
1867
1871
|
|
|
@@ -2070,15 +2074,15 @@ function mapArray(list, map, options) {
|
|
|
2070
2074
|
const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
|
|
2071
2075
|
return updateKeyedMap.bind({
|
|
2072
2076
|
U: new Owner(),
|
|
2073
|
-
|
|
2077
|
+
p: 0,
|
|
2074
2078
|
ia: list,
|
|
2075
2079
|
I: [],
|
|
2076
2080
|
R: map,
|
|
2077
2081
|
i: [],
|
|
2078
2082
|
e: [],
|
|
2079
2083
|
S: keyFn,
|
|
2080
|
-
|
|
2081
|
-
|
|
2084
|
+
q: keyFn || options?.keyed === false ? [] : void 0,
|
|
2085
|
+
r: map.length > 1 ? [] : void 0,
|
|
2082
2086
|
V: options?.fallback
|
|
2083
2087
|
});
|
|
2084
2088
|
}
|
|
@@ -2087,30 +2091,30 @@ function updateKeyedMap() {
|
|
|
2087
2091
|
const newItems = this.ia() || [], newLen = newItems.length;
|
|
2088
2092
|
newItems[$TRACK];
|
|
2089
2093
|
runWithOwner(this.U, () => {
|
|
2090
|
-
let i, j, mapper = this.
|
|
2091
|
-
this.
|
|
2092
|
-
this.
|
|
2094
|
+
let i, j, mapper = this.q ? () => {
|
|
2095
|
+
this.q[j] = new Computation(newItems[j], null, pureOptions);
|
|
2096
|
+
this.r && (this.r[j] = new Computation(j, null, pureOptions));
|
|
2093
2097
|
return this.R(
|
|
2094
|
-
Computation.prototype.read.bind(this.
|
|
2095
|
-
this.
|
|
2098
|
+
Computation.prototype.read.bind(this.q[j]),
|
|
2099
|
+
this.r ? Computation.prototype.read.bind(this.r[j]) : void 0
|
|
2096
2100
|
);
|
|
2097
|
-
} : this.
|
|
2101
|
+
} : this.r ? () => {
|
|
2098
2102
|
const item = newItems[j];
|
|
2099
|
-
this.
|
|
2100
|
-
return this.R(() => item, Computation.prototype.read.bind(this.
|
|
2103
|
+
this.r[j] = new Computation(j, null, pureOptions);
|
|
2104
|
+
return this.R(() => item, Computation.prototype.read.bind(this.r[j]));
|
|
2101
2105
|
} : () => {
|
|
2102
2106
|
const item = newItems[j];
|
|
2103
2107
|
return this.R(() => item);
|
|
2104
2108
|
};
|
|
2105
2109
|
if (newLen === 0) {
|
|
2106
|
-
if (this.
|
|
2110
|
+
if (this.p !== 0) {
|
|
2107
2111
|
this.U.dispose(false);
|
|
2108
2112
|
this.e = [];
|
|
2109
2113
|
this.I = [];
|
|
2110
2114
|
this.i = [];
|
|
2111
|
-
this.
|
|
2112
|
-
this.p && (this.p = []);
|
|
2115
|
+
this.p = 0;
|
|
2113
2116
|
this.q && (this.q = []);
|
|
2117
|
+
this.r && (this.r = []);
|
|
2114
2118
|
}
|
|
2115
2119
|
if (this.V && !this.i[0]) {
|
|
2116
2120
|
this.i[0] = compute(
|
|
@@ -2119,7 +2123,7 @@ function updateKeyedMap() {
|
|
|
2119
2123
|
null
|
|
2120
2124
|
);
|
|
2121
2125
|
}
|
|
2122
|
-
} else if (this.
|
|
2126
|
+
} else if (this.p === 0) {
|
|
2123
2127
|
if (this.e[0])
|
|
2124
2128
|
this.e[0].dispose();
|
|
2125
2129
|
this.i = new Array(newLen);
|
|
@@ -2127,18 +2131,18 @@ function updateKeyedMap() {
|
|
|
2127
2131
|
this.I[j] = newItems[j];
|
|
2128
2132
|
this.i[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2129
2133
|
}
|
|
2130
|
-
this.
|
|
2134
|
+
this.p = newLen;
|
|
2131
2135
|
} else {
|
|
2132
|
-
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.
|
|
2133
|
-
for (start = 0, end = Math.min(this.
|
|
2134
|
-
if (this.
|
|
2135
|
-
this.
|
|
2136
|
+
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.q ? new Array(newLen) : void 0, tempIndexes = this.r ? new Array(newLen) : void 0;
|
|
2137
|
+
for (start = 0, end = Math.min(this.p, newLen); start < end && (this.I[start] === newItems[start] || this.q && compare(this.S, this.I[start], newItems[start])); start++) {
|
|
2138
|
+
if (this.q)
|
|
2139
|
+
this.q[start].write(newItems[start]);
|
|
2136
2140
|
}
|
|
2137
|
-
for (end = this.
|
|
2141
|
+
for (end = this.p - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.I[end] === newItems[newEnd] || this.q && compare(this.S, this.I[end], newItems[newEnd])); end--, newEnd--) {
|
|
2138
2142
|
temp[newEnd] = this.i[end];
|
|
2139
2143
|
tempNodes[newEnd] = this.e[end];
|
|
2140
|
-
tempRows && (tempRows[newEnd] = this.
|
|
2141
|
-
tempIndexes && (tempIndexes[newEnd] = this.
|
|
2144
|
+
tempRows && (tempRows[newEnd] = this.q[end]);
|
|
2145
|
+
tempIndexes && (tempIndexes[newEnd] = this.r[end]);
|
|
2142
2146
|
}
|
|
2143
2147
|
newIndices = /* @__PURE__ */ new Map();
|
|
2144
2148
|
newIndicesNext = new Array(newEnd + 1);
|
|
@@ -2156,8 +2160,8 @@ function updateKeyedMap() {
|
|
|
2156
2160
|
if (j !== void 0 && j !== -1) {
|
|
2157
2161
|
temp[j] = this.i[i];
|
|
2158
2162
|
tempNodes[j] = this.e[i];
|
|
2159
|
-
tempRows && (tempRows[j] = this.
|
|
2160
|
-
tempIndexes && (tempIndexes[j] = this.
|
|
2163
|
+
tempRows && (tempRows[j] = this.q[i]);
|
|
2164
|
+
tempIndexes && (tempIndexes[j] = this.r[i]);
|
|
2161
2165
|
j = newIndicesNext[j];
|
|
2162
2166
|
newIndices.set(key, j);
|
|
2163
2167
|
} else
|
|
@@ -2168,18 +2172,18 @@ function updateKeyedMap() {
|
|
|
2168
2172
|
this.i[j] = temp[j];
|
|
2169
2173
|
this.e[j] = tempNodes[j];
|
|
2170
2174
|
if (tempRows) {
|
|
2171
|
-
this.
|
|
2172
|
-
this.
|
|
2175
|
+
this.q[j] = tempRows[j];
|
|
2176
|
+
this.q[j].write(newItems[j]);
|
|
2173
2177
|
}
|
|
2174
2178
|
if (tempIndexes) {
|
|
2175
|
-
this.
|
|
2176
|
-
this.
|
|
2179
|
+
this.r[j] = tempIndexes[j];
|
|
2180
|
+
this.r[j].write(j);
|
|
2177
2181
|
}
|
|
2178
2182
|
} else {
|
|
2179
2183
|
this.i[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2180
2184
|
}
|
|
2181
2185
|
}
|
|
2182
|
-
this.i = this.i.slice(0, this.
|
|
2186
|
+
this.i = this.i.slice(0, this.p = newLen);
|
|
2183
2187
|
this.I = newItems.slice(0);
|
|
2184
2188
|
}
|
|
2185
2189
|
});
|
|
@@ -2188,7 +2192,7 @@ function updateKeyedMap() {
|
|
|
2188
2192
|
function repeat(count, map, options) {
|
|
2189
2193
|
return updateRepeat.bind({
|
|
2190
2194
|
U: new Owner(),
|
|
2191
|
-
|
|
2195
|
+
p: 0,
|
|
2192
2196
|
B: 0,
|
|
2193
2197
|
ja: count,
|
|
2194
2198
|
R: map,
|
|
@@ -2203,11 +2207,11 @@ function updateRepeat() {
|
|
|
2203
2207
|
const from = this.ka?.() || 0;
|
|
2204
2208
|
runWithOwner(this.U, () => {
|
|
2205
2209
|
if (newLen === 0) {
|
|
2206
|
-
if (this.
|
|
2210
|
+
if (this.p !== 0) {
|
|
2207
2211
|
this.U.dispose(false);
|
|
2208
2212
|
this.e = [];
|
|
2209
2213
|
this.i = [];
|
|
2210
|
-
this.
|
|
2214
|
+
this.p = 0;
|
|
2211
2215
|
}
|
|
2212
2216
|
if (this.V && !this.i[0]) {
|
|
2213
2217
|
this.i[0] = compute(
|
|
@@ -2219,14 +2223,14 @@ function updateRepeat() {
|
|
|
2219
2223
|
return;
|
|
2220
2224
|
}
|
|
2221
2225
|
const to = from + newLen;
|
|
2222
|
-
const prevTo = this.B + this.
|
|
2223
|
-
if (this.
|
|
2226
|
+
const prevTo = this.B + this.p;
|
|
2227
|
+
if (this.p === 0 && this.e[0])
|
|
2224
2228
|
this.e[0].dispose();
|
|
2225
2229
|
for (let i = to; i < prevTo; i++)
|
|
2226
2230
|
this.e[i - this.B].dispose();
|
|
2227
2231
|
if (this.B < from) {
|
|
2228
2232
|
let i = this.B;
|
|
2229
|
-
while (i < from && i < this.
|
|
2233
|
+
while (i < from && i < this.p)
|
|
2230
2234
|
this.e[i++].dispose();
|
|
2231
2235
|
this.e.splice(0, from - this.B);
|
|
2232
2236
|
this.i.splice(0, from - this.B);
|
|
@@ -2256,7 +2260,7 @@ function updateRepeat() {
|
|
|
2256
2260
|
}
|
|
2257
2261
|
this.i = this.i.slice(0, newLen);
|
|
2258
2262
|
this.B = from;
|
|
2259
|
-
this.
|
|
2263
|
+
this.p = newLen;
|
|
2260
2264
|
});
|
|
2261
2265
|
return this.i;
|
|
2262
2266
|
}
|
|
@@ -2273,7 +2277,7 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2273
2277
|
}
|
|
2274
2278
|
write(value, flags) {
|
|
2275
2279
|
super.write(value, flags & ~this.W);
|
|
2276
|
-
if (this.W & LOADING_BIT && !(this.
|
|
2280
|
+
if (this.W & LOADING_BIT && !(this.f & UNINITIALIZED_BIT || ActiveTransition)) {
|
|
2277
2281
|
flags &= ~LOADING_BIT;
|
|
2278
2282
|
}
|
|
2279
2283
|
getQueue(this).notify(this, this.W, flags);
|