@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/node.cjs
CHANGED
|
@@ -63,13 +63,13 @@ var pureQueue = [];
|
|
|
63
63
|
var Queue = class {
|
|
64
64
|
k = null;
|
|
65
65
|
C = false;
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
g = [[], []];
|
|
67
|
+
h = [];
|
|
68
68
|
created = clock;
|
|
69
69
|
enqueue(type, fn) {
|
|
70
70
|
pureQueue.push(fn);
|
|
71
71
|
if (type)
|
|
72
|
-
this.
|
|
72
|
+
this.g[type - 1].push(fn);
|
|
73
73
|
schedule();
|
|
74
74
|
}
|
|
75
75
|
run(type) {
|
|
@@ -77,13 +77,13 @@ var Queue = class {
|
|
|
77
77
|
pureQueue.length && runQueue(pureQueue, type);
|
|
78
78
|
pureQueue = [];
|
|
79
79
|
return;
|
|
80
|
-
} else if (this.
|
|
81
|
-
const effects = this.
|
|
82
|
-
this.
|
|
80
|
+
} else if (this.g[type - 1].length) {
|
|
81
|
+
const effects = this.g[type - 1];
|
|
82
|
+
this.g[type - 1] = [];
|
|
83
83
|
runQueue(effects, type);
|
|
84
84
|
}
|
|
85
|
-
for (let i = 0; i < this.
|
|
86
|
-
this.
|
|
85
|
+
for (let i = 0; i < this.h.length; i++) {
|
|
86
|
+
this.h[i].run(type);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
flush() {
|
|
@@ -104,15 +104,15 @@ var Queue = class {
|
|
|
104
104
|
addChild(child) {
|
|
105
105
|
if (ActiveTransition && ActiveTransition.J.has(this))
|
|
106
106
|
return ActiveTransition.J.get(this).addChild(child);
|
|
107
|
-
this.
|
|
107
|
+
this.h.push(child);
|
|
108
108
|
child.k = this;
|
|
109
109
|
}
|
|
110
110
|
removeChild(child) {
|
|
111
111
|
if (ActiveTransition && ActiveTransition.J.has(this))
|
|
112
112
|
return ActiveTransition.J.get(this).removeChild(child);
|
|
113
|
-
const index = this.
|
|
113
|
+
const index = this.h.indexOf(child);
|
|
114
114
|
if (index >= 0) {
|
|
115
|
-
this.
|
|
115
|
+
this.h.splice(index, 1);
|
|
116
116
|
child.k = null;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
@@ -122,14 +122,14 @@ var Queue = class {
|
|
|
122
122
|
return false;
|
|
123
123
|
}
|
|
124
124
|
merge(queue) {
|
|
125
|
-
this.
|
|
126
|
-
this.
|
|
127
|
-
for (let i = 0; i < queue.
|
|
128
|
-
const og = this.
|
|
125
|
+
this.g[0].push.apply(this.g[0], queue.g[0]);
|
|
126
|
+
this.g[1].push.apply(this.g[1], queue.g[1]);
|
|
127
|
+
for (let i = 0; i < queue.h.length; i++) {
|
|
128
|
+
const og = this.h.find((c) => c.d === queue.h[i].d);
|
|
129
129
|
if (og)
|
|
130
|
-
og.merge(queue.
|
|
130
|
+
og.merge(queue.h[i]);
|
|
131
131
|
else
|
|
132
|
-
this.addChild(queue.
|
|
132
|
+
this.addChild(queue.h[i]);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
};
|
|
@@ -162,12 +162,12 @@ var Transition = class _Transition {
|
|
|
162
162
|
a = /* @__PURE__ */ new Map();
|
|
163
163
|
t = /* @__PURE__ */ new Set();
|
|
164
164
|
K = /* @__PURE__ */ new Set();
|
|
165
|
-
|
|
165
|
+
m = /* @__PURE__ */ new Set();
|
|
166
166
|
D = false;
|
|
167
|
-
|
|
167
|
+
g = [[], []];
|
|
168
168
|
J = /* @__PURE__ */ new Map();
|
|
169
169
|
G = [];
|
|
170
|
-
|
|
170
|
+
h = [];
|
|
171
171
|
k = null;
|
|
172
172
|
C = false;
|
|
173
173
|
Y = false;
|
|
@@ -175,14 +175,14 @@ var Transition = class _Transition {
|
|
|
175
175
|
created = clock;
|
|
176
176
|
constructor() {
|
|
177
177
|
this.J.set(globalQueue, this);
|
|
178
|
-
for (const child of globalQueue.
|
|
178
|
+
for (const child of globalQueue.h) {
|
|
179
179
|
cloneQueue(child, this, this);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
enqueue(type, fn) {
|
|
183
183
|
this.G.push(fn);
|
|
184
184
|
if (type)
|
|
185
|
-
this.
|
|
185
|
+
this.g[type - 1].push(fn);
|
|
186
186
|
this.schedule();
|
|
187
187
|
}
|
|
188
188
|
run(type) {
|
|
@@ -190,13 +190,13 @@ var Transition = class _Transition {
|
|
|
190
190
|
this.G.length && runQueue(this.G, type);
|
|
191
191
|
this.G = [];
|
|
192
192
|
return;
|
|
193
|
-
} else if (this.
|
|
194
|
-
const effects = this.
|
|
195
|
-
this.
|
|
193
|
+
} else if (this.g[type - 1].length) {
|
|
194
|
+
const effects = this.g[type - 1];
|
|
195
|
+
this.g[type - 1] = [];
|
|
196
196
|
runQueue(effects, type);
|
|
197
197
|
}
|
|
198
|
-
for (let i = 0; i < this.
|
|
199
|
-
this.
|
|
198
|
+
for (let i = 0; i < this.h.length; i++) {
|
|
199
|
+
this.h[i].run(type);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
flush() {
|
|
@@ -217,13 +217,13 @@ var Transition = class _Transition {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
addChild(child) {
|
|
220
|
-
this.
|
|
220
|
+
this.h.push(child);
|
|
221
221
|
child.k = this;
|
|
222
222
|
}
|
|
223
223
|
removeChild(child) {
|
|
224
|
-
const index = this.
|
|
224
|
+
const index = this.h.indexOf(child);
|
|
225
225
|
if (index >= 0)
|
|
226
|
-
this.
|
|
226
|
+
this.h.splice(index, 1);
|
|
227
227
|
}
|
|
228
228
|
notify(node, type, flags) {
|
|
229
229
|
if (!(type & LOADING_BIT))
|
|
@@ -236,18 +236,18 @@ var Transition = class _Transition {
|
|
|
236
236
|
return true;
|
|
237
237
|
}
|
|
238
238
|
merge(queue) {
|
|
239
|
-
this.
|
|
240
|
-
this.
|
|
239
|
+
this.g[0].push.apply(this.g[0], queue.g[0]);
|
|
240
|
+
this.g[1].push.apply(this.g[1], queue.g[1]);
|
|
241
241
|
this.G.push.apply(this.G, queue.G);
|
|
242
|
-
queue.
|
|
243
|
-
queue.
|
|
242
|
+
queue.g[0].length = 0;
|
|
243
|
+
queue.g[1].length = 0;
|
|
244
244
|
queue.G.length = 0;
|
|
245
|
-
for (let i = 0; i < queue.
|
|
246
|
-
const og = this.
|
|
245
|
+
for (let i = 0; i < queue.h.length; i++) {
|
|
246
|
+
const og = this.h.find((c) => c.d === queue.h[i].d);
|
|
247
247
|
if (og)
|
|
248
|
-
og.merge(queue.
|
|
248
|
+
og.merge(queue.h[i]);
|
|
249
249
|
else
|
|
250
|
-
this.addChild(queue.
|
|
250
|
+
this.addChild(queue.h[i]);
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
schedule() {
|
|
@@ -313,7 +313,7 @@ var Transition = class _Transition {
|
|
|
313
313
|
return;
|
|
314
314
|
}
|
|
315
315
|
fn.j = this;
|
|
316
|
-
this.
|
|
316
|
+
this.m.add(fn);
|
|
317
317
|
}
|
|
318
318
|
};
|
|
319
319
|
function transition(fn) {
|
|
@@ -321,8 +321,10 @@ function transition(fn) {
|
|
|
321
321
|
queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
|
|
322
322
|
}
|
|
323
323
|
function cloneGraph(node) {
|
|
324
|
-
if (node.
|
|
324
|
+
if (node.m) {
|
|
325
|
+
ActiveTransition.addOptimistic(node.m);
|
|
325
326
|
return node;
|
|
327
|
+
}
|
|
326
328
|
if (node.j) {
|
|
327
329
|
if (node.j !== ActiveTransition) {
|
|
328
330
|
mergeTransitions(node.j, ActiveTransition);
|
|
@@ -332,8 +334,8 @@ function cloneGraph(node) {
|
|
|
332
334
|
}
|
|
333
335
|
const clone = Object.create(Object.getPrototypeOf(node));
|
|
334
336
|
Object.assign(clone, node, {
|
|
337
|
+
o: null,
|
|
335
338
|
n: null,
|
|
336
|
-
m: null,
|
|
337
339
|
c: null,
|
|
338
340
|
a: node.a ? [...node.a] : null,
|
|
339
341
|
d: node
|
|
@@ -376,7 +378,7 @@ function cloneQueue(queue, parent, transition2) {
|
|
|
376
378
|
Object.assign(clone, queue, {
|
|
377
379
|
d: queue,
|
|
378
380
|
k: parent,
|
|
379
|
-
|
|
381
|
+
h: [],
|
|
380
382
|
enqueue(type, fn) {
|
|
381
383
|
transition2 = latestTransition(transition2);
|
|
382
384
|
transition2.enqueue(type, fn);
|
|
@@ -393,9 +395,9 @@ function cloneQueue(queue, parent, transition2) {
|
|
|
393
395
|
return queue.notify.call(this, node, type, flags);
|
|
394
396
|
}
|
|
395
397
|
});
|
|
396
|
-
parent.
|
|
398
|
+
parent.h.push(clone);
|
|
397
399
|
transition2.J.set(queue, clone);
|
|
398
|
-
for (const child of queue.
|
|
400
|
+
for (const child of queue.h) {
|
|
399
401
|
cloneQueue(child, clone, transition2);
|
|
400
402
|
}
|
|
401
403
|
}
|
|
@@ -403,11 +405,11 @@ function resolveQueues(children) {
|
|
|
403
405
|
for (const child of children) {
|
|
404
406
|
const og = child.d;
|
|
405
407
|
if (og) {
|
|
406
|
-
const clonedChildren = child.
|
|
408
|
+
const clonedChildren = child.h;
|
|
407
409
|
delete child.enqueue;
|
|
408
410
|
delete child.notify;
|
|
409
411
|
delete child.k;
|
|
410
|
-
delete child.
|
|
412
|
+
delete child.h;
|
|
411
413
|
Object.assign(og, child);
|
|
412
414
|
delete og.d;
|
|
413
415
|
resolveQueues(clonedChildren);
|
|
@@ -421,9 +423,9 @@ function mergeTransitions(t1, t2) {
|
|
|
421
423
|
key.j = t1;
|
|
422
424
|
t1.a.set(key, value);
|
|
423
425
|
});
|
|
424
|
-
t2.
|
|
426
|
+
t2.m.forEach((c) => {
|
|
425
427
|
c.j = t1;
|
|
426
|
-
t1.
|
|
428
|
+
t1.m.add(c);
|
|
427
429
|
});
|
|
428
430
|
t2.K.forEach((p) => t1.K.add(p));
|
|
429
431
|
t2.t.forEach((n) => t1.t.add(n));
|
|
@@ -439,21 +441,21 @@ function getQueue(node) {
|
|
|
439
441
|
return transition2 && transition2.J.get(node.E) || node.E;
|
|
440
442
|
}
|
|
441
443
|
function initialDispose(node) {
|
|
442
|
-
let current = node.
|
|
444
|
+
let current = node.n;
|
|
443
445
|
while (current !== null && current.k === node) {
|
|
444
446
|
initialDispose(current);
|
|
445
447
|
const clone = ActiveTransition.a.get(current);
|
|
446
448
|
if (clone && !clone.Z)
|
|
447
449
|
clone.dispose(true);
|
|
448
|
-
current = current.
|
|
450
|
+
current = current.n;
|
|
449
451
|
}
|
|
450
452
|
}
|
|
451
453
|
function finishTransition(transition2) {
|
|
452
454
|
if (transition2.D || transition2.Y || transition2.K.size || transition2.t.size)
|
|
453
455
|
return;
|
|
454
|
-
globalQueue.
|
|
455
|
-
globalQueue.
|
|
456
|
-
resolveQueues(transition2.
|
|
456
|
+
globalQueue.g[0].push.apply(globalQueue.g[0], transition2.g[0]);
|
|
457
|
+
globalQueue.g[1].push.apply(globalQueue.g[1], transition2.g[1]);
|
|
458
|
+
resolveQueues(transition2.h);
|
|
457
459
|
for (const [source, clone] of transition2.a) {
|
|
458
460
|
if (source === clone || source.j !== transition2) {
|
|
459
461
|
delete source.j;
|
|
@@ -466,22 +468,22 @@ function finishTransition(transition2) {
|
|
|
466
468
|
source.emptyDisposal();
|
|
467
469
|
delete clone.Z;
|
|
468
470
|
} else {
|
|
469
|
-
delete clone.m;
|
|
470
471
|
delete clone.n;
|
|
472
|
+
delete clone.o;
|
|
471
473
|
}
|
|
472
474
|
Object.assign(source, clone);
|
|
473
475
|
delete source.d;
|
|
474
|
-
let current = clone.
|
|
476
|
+
let current = clone.n;
|
|
475
477
|
if ((current == null ? void 0 : current.z) === clone)
|
|
476
478
|
current.z = source;
|
|
477
479
|
while ((current == null ? void 0 : current.k) === clone) {
|
|
478
480
|
current.k = source;
|
|
479
|
-
current = current.
|
|
481
|
+
current = current.n;
|
|
480
482
|
}
|
|
481
483
|
delete source.j;
|
|
482
484
|
}
|
|
483
485
|
transition2.D = true;
|
|
484
|
-
for (const reset of transition2.
|
|
486
|
+
for (const reset of transition2.m) {
|
|
485
487
|
delete reset.j;
|
|
486
488
|
reset();
|
|
487
489
|
}
|
|
@@ -504,10 +506,10 @@ var Owner = class {
|
|
|
504
506
|
// However, the children are actually added in reverse creation order
|
|
505
507
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
506
508
|
k = null;
|
|
507
|
-
|
|
509
|
+
n = null;
|
|
508
510
|
z = null;
|
|
509
511
|
b = STATE_CLEAN;
|
|
510
|
-
|
|
512
|
+
o = null;
|
|
511
513
|
A = defaultContext;
|
|
512
514
|
E = globalQueue;
|
|
513
515
|
fa = 0;
|
|
@@ -521,10 +523,10 @@ var Owner = class {
|
|
|
521
523
|
append(child) {
|
|
522
524
|
child.k = this;
|
|
523
525
|
child.z = this;
|
|
524
|
-
if (this.
|
|
525
|
-
this.
|
|
526
|
-
child.
|
|
527
|
-
this.
|
|
526
|
+
if (this.n)
|
|
527
|
+
this.n.z = child;
|
|
528
|
+
child.n = this.n;
|
|
529
|
+
this.n = child;
|
|
528
530
|
if (this.id != null && child.id == null)
|
|
529
531
|
child.id = this.getNextChildId();
|
|
530
532
|
if (child.A !== this.A) {
|
|
@@ -536,11 +538,11 @@ var Owner = class {
|
|
|
536
538
|
dispose(self = true) {
|
|
537
539
|
if (this.b === STATE_DISPOSED)
|
|
538
540
|
return;
|
|
539
|
-
let head = self ? this.z || this.k : this, current = this.
|
|
541
|
+
let head = self ? this.z || this.k : this, current = this.n, next = null;
|
|
540
542
|
while (current && current.k === this) {
|
|
541
543
|
current.dispose(true);
|
|
542
|
-
next = current.
|
|
543
|
-
current.
|
|
544
|
+
next = current.n;
|
|
545
|
+
current.n = null;
|
|
544
546
|
current = next;
|
|
545
547
|
}
|
|
546
548
|
this.fa = 0;
|
|
@@ -549,11 +551,11 @@ var Owner = class {
|
|
|
549
551
|
if (current)
|
|
550
552
|
current.z = !self ? this : this.z;
|
|
551
553
|
if (head)
|
|
552
|
-
head.
|
|
554
|
+
head.n = current;
|
|
553
555
|
}
|
|
554
556
|
M() {
|
|
555
557
|
if (this.z)
|
|
556
|
-
this.z.
|
|
558
|
+
this.z.n = null;
|
|
557
559
|
this.k = null;
|
|
558
560
|
this.z = null;
|
|
559
561
|
this.A = defaultContext;
|
|
@@ -561,17 +563,17 @@ var Owner = class {
|
|
|
561
563
|
this.emptyDisposal();
|
|
562
564
|
}
|
|
563
565
|
emptyDisposal() {
|
|
564
|
-
if (!this.
|
|
566
|
+
if (!this.o)
|
|
565
567
|
return;
|
|
566
|
-
if (Array.isArray(this.
|
|
567
|
-
for (let i = 0; i < this.
|
|
568
|
-
const callable = this.
|
|
568
|
+
if (Array.isArray(this.o)) {
|
|
569
|
+
for (let i = 0; i < this.o.length; i++) {
|
|
570
|
+
const callable = this.o[i];
|
|
569
571
|
callable.call(callable);
|
|
570
572
|
}
|
|
571
573
|
} else {
|
|
572
|
-
this.
|
|
574
|
+
this.o.call(this.o);
|
|
573
575
|
}
|
|
574
|
-
this.
|
|
576
|
+
this.o = null;
|
|
575
577
|
}
|
|
576
578
|
getNextChildId() {
|
|
577
579
|
if (this.id != null)
|
|
@@ -608,12 +610,12 @@ function onCleanup(fn) {
|
|
|
608
610
|
if (!currentOwner)
|
|
609
611
|
return fn;
|
|
610
612
|
const node = currentOwner;
|
|
611
|
-
if (!node.
|
|
612
|
-
node.
|
|
613
|
-
} else if (Array.isArray(node.
|
|
614
|
-
node.
|
|
613
|
+
if (!node.o) {
|
|
614
|
+
node.o = fn;
|
|
615
|
+
} else if (Array.isArray(node.o)) {
|
|
616
|
+
node.o.push(fn);
|
|
615
617
|
} else {
|
|
616
|
-
node.
|
|
618
|
+
node.o = [node.o, fn];
|
|
617
619
|
}
|
|
618
620
|
return fn;
|
|
619
621
|
}
|
|
@@ -652,19 +654,19 @@ var Computation = class extends Owner {
|
|
|
652
654
|
ea;
|
|
653
655
|
ha = false;
|
|
654
656
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
655
|
-
|
|
657
|
+
f = 0;
|
|
656
658
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
657
659
|
ba = DEFAULT_FLAGS;
|
|
658
660
|
Q = -1;
|
|
659
661
|
H = false;
|
|
660
662
|
j;
|
|
661
663
|
d;
|
|
662
|
-
|
|
664
|
+
m;
|
|
663
665
|
constructor(initialValue, compute2, options) {
|
|
664
666
|
super(options == null ? void 0 : options.id, compute2 === null);
|
|
665
667
|
this.P = compute2;
|
|
666
668
|
this.b = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
667
|
-
this.
|
|
669
|
+
this.f = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
668
670
|
this.l = initialValue;
|
|
669
671
|
if ((options == null ? void 0 : options.equals) !== void 0)
|
|
670
672
|
this.aa = options.equals;
|
|
@@ -677,8 +679,8 @@ var Computation = class extends Owner {
|
|
|
677
679
|
}
|
|
678
680
|
ga() {
|
|
679
681
|
track(this);
|
|
680
|
-
newFlags |= this.
|
|
681
|
-
if (this.
|
|
682
|
+
newFlags |= this.f & ~currentMask;
|
|
683
|
+
if (this.f & ERROR_BIT) {
|
|
682
684
|
throw this.O;
|
|
683
685
|
} else {
|
|
684
686
|
return this.l;
|
|
@@ -689,13 +691,13 @@ var Computation = class extends Owner {
|
|
|
689
691
|
* Automatically re-executes the surrounding computation when the value changes
|
|
690
692
|
*/
|
|
691
693
|
read() {
|
|
692
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.
|
|
694
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.f & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
693
695
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
694
696
|
if (clone !== this)
|
|
695
697
|
return clone.read();
|
|
696
698
|
}
|
|
697
699
|
if (this.P) {
|
|
698
|
-
if (this.
|
|
700
|
+
if (this.f & ERROR_BIT && this.Q <= clock)
|
|
699
701
|
update(this);
|
|
700
702
|
else
|
|
701
703
|
this.F();
|
|
@@ -710,22 +712,22 @@ var Computation = class extends Owner {
|
|
|
710
712
|
* before continuing
|
|
711
713
|
*/
|
|
712
714
|
wait() {
|
|
713
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.
|
|
715
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.f & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
714
716
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
715
717
|
if (clone !== this)
|
|
716
718
|
return clone.wait();
|
|
717
719
|
}
|
|
718
720
|
if (this.P) {
|
|
719
|
-
if (this.
|
|
721
|
+
if (this.f & ERROR_BIT && this.Q <= clock)
|
|
720
722
|
update(this);
|
|
721
723
|
else
|
|
722
724
|
this.F();
|
|
723
725
|
}
|
|
724
|
-
if ((notStale || this.
|
|
726
|
+
if ((notStale || this.f & UNINITIALIZED_BIT) && this.f & LOADING_BIT) {
|
|
725
727
|
track(this);
|
|
726
728
|
throw new NotReadyError();
|
|
727
729
|
}
|
|
728
|
-
if (staleCheck && this.
|
|
730
|
+
if (staleCheck && this.f & LOADING_BIT) {
|
|
729
731
|
staleCheck.l = true;
|
|
730
732
|
}
|
|
731
733
|
return this.ga();
|
|
@@ -738,16 +740,16 @@ var Computation = class extends Owner {
|
|
|
738
740
|
return clone.write(value, flags, raw);
|
|
739
741
|
}
|
|
740
742
|
const newValue = !raw && typeof value === "function" ? value(this.l) : value;
|
|
741
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
743
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.f & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
|
|
742
744
|
this.aa === false || !this.aa(this.l, newValue));
|
|
743
745
|
if (valueChanged) {
|
|
744
746
|
this.l = newValue;
|
|
745
747
|
this.O = void 0;
|
|
746
748
|
}
|
|
747
|
-
const changedFlagsMask = this.
|
|
748
|
-
this.
|
|
749
|
+
const changedFlagsMask = this.f ^ flags, changedFlags = changedFlagsMask & flags;
|
|
750
|
+
this.f = flags;
|
|
749
751
|
this.Q = clock + 1;
|
|
750
|
-
if (this.c && !(this.
|
|
752
|
+
if (this.c && !(this.m && ActiveTransition)) {
|
|
751
753
|
for (let i = 0; i < this.c.length; i++) {
|
|
752
754
|
if (valueChanged) {
|
|
753
755
|
this.c[i].u(STATE_DIRTY);
|
|
@@ -766,7 +768,7 @@ var Computation = class extends Owner {
|
|
|
766
768
|
return;
|
|
767
769
|
this.H = !!skipQueue;
|
|
768
770
|
this.b = state;
|
|
769
|
-
if (this.c && !(this.
|
|
771
|
+
if (this.c && !(this.m && ActiveTransition)) {
|
|
770
772
|
for (let i = 0; i < this.c.length; i++) {
|
|
771
773
|
this.c[i].u(STATE_CHECK, skipQueue);
|
|
772
774
|
}
|
|
@@ -781,18 +783,18 @@ var Computation = class extends Owner {
|
|
|
781
783
|
_(mask, newFlags2) {
|
|
782
784
|
if (this.b >= STATE_DIRTY)
|
|
783
785
|
return;
|
|
784
|
-
if (mask & this.ba || this.
|
|
786
|
+
if (mask & this.ba || this.m && ActiveTransition) {
|
|
785
787
|
this.u(STATE_DIRTY);
|
|
786
788
|
return;
|
|
787
789
|
}
|
|
788
790
|
if (this.b >= STATE_CHECK && !this.H)
|
|
789
791
|
return;
|
|
790
|
-
const prevFlags = this.
|
|
792
|
+
const prevFlags = this.f & mask;
|
|
791
793
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
792
794
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
793
795
|
this.u(STATE_CHECK);
|
|
794
796
|
} else {
|
|
795
|
-
this.
|
|
797
|
+
this.f ^= deltaFlags;
|
|
796
798
|
if (this.c) {
|
|
797
799
|
for (let i = 0; i < this.c.length; i++) {
|
|
798
800
|
this.c[i]._(mask, newFlags2);
|
|
@@ -807,7 +809,7 @@ var Computation = class extends Owner {
|
|
|
807
809
|
return clone.N(error);
|
|
808
810
|
}
|
|
809
811
|
this.O = error;
|
|
810
|
-
this.write(UNCHANGED, this.
|
|
812
|
+
this.write(UNCHANGED, this.f & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
811
813
|
}
|
|
812
814
|
/**
|
|
813
815
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -831,7 +833,7 @@ var Computation = class extends Owner {
|
|
|
831
833
|
for (let i = 0; i < this.a.length; i++) {
|
|
832
834
|
const source = getTransitionSource(this.a[i]);
|
|
833
835
|
source.F();
|
|
834
|
-
observerFlags |= source.
|
|
836
|
+
observerFlags |= source.f & ~UNINITIALIZED_BIT;
|
|
835
837
|
if (this.b === STATE_DIRTY) {
|
|
836
838
|
break;
|
|
837
839
|
}
|
|
@@ -887,7 +889,7 @@ function update(node) {
|
|
|
887
889
|
node.write(result, newFlags, true);
|
|
888
890
|
} catch (error) {
|
|
889
891
|
if (error instanceof NotReadyError) {
|
|
890
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.
|
|
892
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.f & UNINITIALIZED_BIT);
|
|
891
893
|
} else {
|
|
892
894
|
node.N(error);
|
|
893
895
|
}
|
|
@@ -961,7 +963,7 @@ function isPending(fn, loadingValue) {
|
|
|
961
963
|
return pendingCheck(fn, loadingValue);
|
|
962
964
|
const c = new Computation(void 0, () => pendingCheck(fn, loadingValue));
|
|
963
965
|
c.ba |= LOADING_BIT;
|
|
964
|
-
return c.
|
|
966
|
+
return c.wait();
|
|
965
967
|
}
|
|
966
968
|
function latest(fn, fallback) {
|
|
967
969
|
const argLength = arguments.length;
|
|
@@ -1010,7 +1012,7 @@ var Effect = class extends Computation {
|
|
|
1010
1012
|
this.s = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
|
|
1011
1013
|
if (this.s === EFFECT_RENDER) {
|
|
1012
1014
|
this.P = function(p) {
|
|
1013
|
-
return !this.d && clock > this.E.created && !(this.
|
|
1015
|
+
return !this.d && clock > this.E.created && !(this.f & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
1014
1016
|
};
|
|
1015
1017
|
}
|
|
1016
1018
|
this.F();
|
|
@@ -1018,9 +1020,9 @@ var Effect = class extends Computation {
|
|
|
1018
1020
|
}
|
|
1019
1021
|
write(value, flags = 0) {
|
|
1020
1022
|
if (this.b == STATE_DIRTY) {
|
|
1021
|
-
this.
|
|
1023
|
+
this.f = flags;
|
|
1022
1024
|
if (this.s === EFFECT_RENDER) {
|
|
1023
|
-
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.
|
|
1025
|
+
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.f);
|
|
1024
1026
|
}
|
|
1025
1027
|
}
|
|
1026
1028
|
if (value === UNCHANGED)
|
|
@@ -1051,7 +1053,7 @@ var Effect = class extends Computation {
|
|
|
1051
1053
|
N(error) {
|
|
1052
1054
|
this.O = error;
|
|
1053
1055
|
getQueue(this).notify(this, LOADING_BIT, 0);
|
|
1054
|
-
this.
|
|
1056
|
+
this.f = ERROR_BIT;
|
|
1055
1057
|
if (this.s === EFFECT_USER) {
|
|
1056
1058
|
try {
|
|
1057
1059
|
return this.$ ? this.$(error, () => {
|
|
@@ -1161,10 +1163,13 @@ var FirewallComputation = class extends Computation {
|
|
|
1161
1163
|
this.H = !!skipQueue;
|
|
1162
1164
|
}
|
|
1163
1165
|
x() {
|
|
1164
|
-
const prevFlags = this.
|
|
1166
|
+
const prevFlags = this.f;
|
|
1165
1167
|
this.b !== STATE_CLEAN && runTop(this);
|
|
1166
|
-
if (ActiveTransition && this.
|
|
1167
|
-
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.
|
|
1168
|
+
if (ActiveTransition && this.m && (this.f !== prevFlags || this.f !== this.m.flags)) {
|
|
1169
|
+
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.f);
|
|
1170
|
+
this.m.flags = this.f;
|
|
1171
|
+
this.f = prevFlags;
|
|
1172
|
+
}
|
|
1168
1173
|
}
|
|
1169
1174
|
};
|
|
1170
1175
|
function runTop(node) {
|
|
@@ -1215,7 +1220,7 @@ function createMemo(compute2, value, options) {
|
|
|
1215
1220
|
return resolvedValue;
|
|
1216
1221
|
}
|
|
1217
1222
|
resolvedValue = node.wait();
|
|
1218
|
-
if (!((_a = node.a) == null ? void 0 : _a.length) && ((_b = node.
|
|
1223
|
+
if (!((_a = node.a) == null ? void 0 : _a.length) && ((_b = node.n) == null ? void 0 : _b.k) !== node && !(node.f & UNINITIALIZED_BIT)) {
|
|
1219
1224
|
node.dispose();
|
|
1220
1225
|
node = void 0;
|
|
1221
1226
|
}
|
|
@@ -1363,18 +1368,17 @@ function resolve(fn) {
|
|
|
1363
1368
|
function createOptimistic(first, second, third) {
|
|
1364
1369
|
const node = typeof first === "function" ? new Computation(second, (prev) => {
|
|
1365
1370
|
const res = first(prev);
|
|
1366
|
-
if (
|
|
1371
|
+
if (node.m.j)
|
|
1367
1372
|
return prev;
|
|
1368
1373
|
return res;
|
|
1369
1374
|
}, third) : new Computation(first, null, second);
|
|
1370
|
-
node.
|
|
1371
|
-
const reset = () => node.write(first);
|
|
1375
|
+
node.m = () => node.write(first);
|
|
1372
1376
|
function write(v) {
|
|
1373
1377
|
if (!ActiveTransition)
|
|
1374
1378
|
throw new Error("createOptimistic can only be updated inside a transition");
|
|
1375
|
-
ActiveTransition.addOptimistic(
|
|
1379
|
+
ActiveTransition.addOptimistic(node.m);
|
|
1376
1380
|
queueMicrotask(() => {
|
|
1377
|
-
if (
|
|
1381
|
+
if (node.m.j) {
|
|
1378
1382
|
node.F();
|
|
1379
1383
|
node.write(v);
|
|
1380
1384
|
}
|
|
@@ -1865,7 +1869,6 @@ function createOptimisticStore(first, second, options) {
|
|
|
1865
1869
|
return res;
|
|
1866
1870
|
}, second, options) : createProjectionInternal(() => {
|
|
1867
1871
|
}, first);
|
|
1868
|
-
node.r = true;
|
|
1869
1872
|
const reset = () => storeSetter(
|
|
1870
1873
|
store,
|
|
1871
1874
|
reconcile(
|
|
@@ -1880,6 +1883,7 @@ function createOptimisticStore(first, second, options) {
|
|
|
1880
1883
|
ActiveTransition.addOptimistic(reset);
|
|
1881
1884
|
queueMicrotask(() => reset.j && storeSetter(store, v));
|
|
1882
1885
|
};
|
|
1886
|
+
node.m = reset;
|
|
1883
1887
|
return [store, write];
|
|
1884
1888
|
}
|
|
1885
1889
|
|
|
@@ -2089,15 +2093,15 @@ function mapArray(list, map, options) {
|
|
|
2089
2093
|
const keyFn = typeof (options == null ? void 0 : options.keyed) === "function" ? options.keyed : void 0;
|
|
2090
2094
|
return updateKeyedMap.bind({
|
|
2091
2095
|
U: new Owner(),
|
|
2092
|
-
|
|
2096
|
+
p: 0,
|
|
2093
2097
|
ia: list,
|
|
2094
2098
|
I: [],
|
|
2095
2099
|
R: map,
|
|
2096
2100
|
i: [],
|
|
2097
2101
|
e: [],
|
|
2098
2102
|
S: keyFn,
|
|
2099
|
-
|
|
2100
|
-
|
|
2103
|
+
q: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
2104
|
+
r: map.length > 1 ? [] : void 0,
|
|
2101
2105
|
V: options == null ? void 0 : options.fallback
|
|
2102
2106
|
});
|
|
2103
2107
|
}
|
|
@@ -2106,30 +2110,30 @@ function updateKeyedMap() {
|
|
|
2106
2110
|
const newItems = this.ia() || [], newLen = newItems.length;
|
|
2107
2111
|
newItems[$TRACK];
|
|
2108
2112
|
runWithOwner(this.U, () => {
|
|
2109
|
-
let i, j, mapper = this.
|
|
2110
|
-
this.
|
|
2111
|
-
this.
|
|
2113
|
+
let i, j, mapper = this.q ? () => {
|
|
2114
|
+
this.q[j] = new Computation(newItems[j], null, pureOptions);
|
|
2115
|
+
this.r && (this.r[j] = new Computation(j, null, pureOptions));
|
|
2112
2116
|
return this.R(
|
|
2113
|
-
Computation.prototype.read.bind(this.
|
|
2114
|
-
this.
|
|
2117
|
+
Computation.prototype.read.bind(this.q[j]),
|
|
2118
|
+
this.r ? Computation.prototype.read.bind(this.r[j]) : void 0
|
|
2115
2119
|
);
|
|
2116
|
-
} : this.
|
|
2120
|
+
} : this.r ? () => {
|
|
2117
2121
|
const item = newItems[j];
|
|
2118
|
-
this.
|
|
2119
|
-
return this.R(() => item, Computation.prototype.read.bind(this.
|
|
2122
|
+
this.r[j] = new Computation(j, null, pureOptions);
|
|
2123
|
+
return this.R(() => item, Computation.prototype.read.bind(this.r[j]));
|
|
2120
2124
|
} : () => {
|
|
2121
2125
|
const item = newItems[j];
|
|
2122
2126
|
return this.R(() => item);
|
|
2123
2127
|
};
|
|
2124
2128
|
if (newLen === 0) {
|
|
2125
|
-
if (this.
|
|
2129
|
+
if (this.p !== 0) {
|
|
2126
2130
|
this.U.dispose(false);
|
|
2127
2131
|
this.e = [];
|
|
2128
2132
|
this.I = [];
|
|
2129
2133
|
this.i = [];
|
|
2130
|
-
this.
|
|
2131
|
-
this.p && (this.p = []);
|
|
2134
|
+
this.p = 0;
|
|
2132
2135
|
this.q && (this.q = []);
|
|
2136
|
+
this.r && (this.r = []);
|
|
2133
2137
|
}
|
|
2134
2138
|
if (this.V && !this.i[0]) {
|
|
2135
2139
|
this.i[0] = compute(
|
|
@@ -2138,7 +2142,7 @@ function updateKeyedMap() {
|
|
|
2138
2142
|
null
|
|
2139
2143
|
);
|
|
2140
2144
|
}
|
|
2141
|
-
} else if (this.
|
|
2145
|
+
} else if (this.p === 0) {
|
|
2142
2146
|
if (this.e[0])
|
|
2143
2147
|
this.e[0].dispose();
|
|
2144
2148
|
this.i = new Array(newLen);
|
|
@@ -2146,18 +2150,18 @@ function updateKeyedMap() {
|
|
|
2146
2150
|
this.I[j] = newItems[j];
|
|
2147
2151
|
this.i[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2148
2152
|
}
|
|
2149
|
-
this.
|
|
2153
|
+
this.p = newLen;
|
|
2150
2154
|
} else {
|
|
2151
|
-
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.
|
|
2152
|
-
for (start = 0, end = Math.min(this.
|
|
2153
|
-
if (this.
|
|
2154
|
-
this.
|
|
2155
|
+
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;
|
|
2156
|
+
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++) {
|
|
2157
|
+
if (this.q)
|
|
2158
|
+
this.q[start].write(newItems[start]);
|
|
2155
2159
|
}
|
|
2156
|
-
for (end = this.
|
|
2160
|
+
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--) {
|
|
2157
2161
|
temp[newEnd] = this.i[end];
|
|
2158
2162
|
tempNodes[newEnd] = this.e[end];
|
|
2159
|
-
tempRows && (tempRows[newEnd] = this.
|
|
2160
|
-
tempIndexes && (tempIndexes[newEnd] = this.
|
|
2163
|
+
tempRows && (tempRows[newEnd] = this.q[end]);
|
|
2164
|
+
tempIndexes && (tempIndexes[newEnd] = this.r[end]);
|
|
2161
2165
|
}
|
|
2162
2166
|
newIndices = /* @__PURE__ */ new Map();
|
|
2163
2167
|
newIndicesNext = new Array(newEnd + 1);
|
|
@@ -2175,8 +2179,8 @@ function updateKeyedMap() {
|
|
|
2175
2179
|
if (j !== void 0 && j !== -1) {
|
|
2176
2180
|
temp[j] = this.i[i];
|
|
2177
2181
|
tempNodes[j] = this.e[i];
|
|
2178
|
-
tempRows && (tempRows[j] = this.
|
|
2179
|
-
tempIndexes && (tempIndexes[j] = this.
|
|
2182
|
+
tempRows && (tempRows[j] = this.q[i]);
|
|
2183
|
+
tempIndexes && (tempIndexes[j] = this.r[i]);
|
|
2180
2184
|
j = newIndicesNext[j];
|
|
2181
2185
|
newIndices.set(key, j);
|
|
2182
2186
|
} else
|
|
@@ -2187,18 +2191,18 @@ function updateKeyedMap() {
|
|
|
2187
2191
|
this.i[j] = temp[j];
|
|
2188
2192
|
this.e[j] = tempNodes[j];
|
|
2189
2193
|
if (tempRows) {
|
|
2190
|
-
this.
|
|
2191
|
-
this.
|
|
2194
|
+
this.q[j] = tempRows[j];
|
|
2195
|
+
this.q[j].write(newItems[j]);
|
|
2192
2196
|
}
|
|
2193
2197
|
if (tempIndexes) {
|
|
2194
|
-
this.
|
|
2195
|
-
this.
|
|
2198
|
+
this.r[j] = tempIndexes[j];
|
|
2199
|
+
this.r[j].write(j);
|
|
2196
2200
|
}
|
|
2197
2201
|
} else {
|
|
2198
2202
|
this.i[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2199
2203
|
}
|
|
2200
2204
|
}
|
|
2201
|
-
this.i = this.i.slice(0, this.
|
|
2205
|
+
this.i = this.i.slice(0, this.p = newLen);
|
|
2202
2206
|
this.I = newItems.slice(0);
|
|
2203
2207
|
}
|
|
2204
2208
|
});
|
|
@@ -2207,7 +2211,7 @@ function updateKeyedMap() {
|
|
|
2207
2211
|
function repeat(count, map, options) {
|
|
2208
2212
|
return updateRepeat.bind({
|
|
2209
2213
|
U: new Owner(),
|
|
2210
|
-
|
|
2214
|
+
p: 0,
|
|
2211
2215
|
B: 0,
|
|
2212
2216
|
ja: count,
|
|
2213
2217
|
R: map,
|
|
@@ -2223,11 +2227,11 @@ function updateRepeat() {
|
|
|
2223
2227
|
const from = ((_a = this.ka) == null ? void 0 : _a.call(this)) || 0;
|
|
2224
2228
|
runWithOwner(this.U, () => {
|
|
2225
2229
|
if (newLen === 0) {
|
|
2226
|
-
if (this.
|
|
2230
|
+
if (this.p !== 0) {
|
|
2227
2231
|
this.U.dispose(false);
|
|
2228
2232
|
this.e = [];
|
|
2229
2233
|
this.i = [];
|
|
2230
|
-
this.
|
|
2234
|
+
this.p = 0;
|
|
2231
2235
|
}
|
|
2232
2236
|
if (this.V && !this.i[0]) {
|
|
2233
2237
|
this.i[0] = compute(
|
|
@@ -2239,14 +2243,14 @@ function updateRepeat() {
|
|
|
2239
2243
|
return;
|
|
2240
2244
|
}
|
|
2241
2245
|
const to = from + newLen;
|
|
2242
|
-
const prevTo = this.B + this.
|
|
2243
|
-
if (this.
|
|
2246
|
+
const prevTo = this.B + this.p;
|
|
2247
|
+
if (this.p === 0 && this.e[0])
|
|
2244
2248
|
this.e[0].dispose();
|
|
2245
2249
|
for (let i = to; i < prevTo; i++)
|
|
2246
2250
|
this.e[i - this.B].dispose();
|
|
2247
2251
|
if (this.B < from) {
|
|
2248
2252
|
let i = this.B;
|
|
2249
|
-
while (i < from && i < this.
|
|
2253
|
+
while (i < from && i < this.p)
|
|
2250
2254
|
this.e[i++].dispose();
|
|
2251
2255
|
this.e.splice(0, from - this.B);
|
|
2252
2256
|
this.i.splice(0, from - this.B);
|
|
@@ -2276,7 +2280,7 @@ function updateRepeat() {
|
|
|
2276
2280
|
}
|
|
2277
2281
|
this.i = this.i.slice(0, newLen);
|
|
2278
2282
|
this.B = from;
|
|
2279
|
-
this.
|
|
2283
|
+
this.p = newLen;
|
|
2280
2284
|
});
|
|
2281
2285
|
return this.i;
|
|
2282
2286
|
}
|
|
@@ -2293,7 +2297,7 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2293
2297
|
}
|
|
2294
2298
|
write(value, flags) {
|
|
2295
2299
|
super.write(value, flags & ~this.W);
|
|
2296
|
-
if (this.W & LOADING_BIT && !(this.
|
|
2300
|
+
if (this.W & LOADING_BIT && !(this.f & UNINITIALIZED_BIT || ActiveTransition)) {
|
|
2297
2301
|
flags &= ~LOADING_BIT;
|
|
2298
2302
|
}
|
|
2299
2303
|
getQueue(this).notify(this, this.W, flags);
|