@solidjs/signals 0.7.3 → 0.7.5
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 +80 -41
- package/dist/node.cjs +359 -318
- package/dist/prod.js +356 -317
- package/dist/types/core/core.d.ts +1 -0
- package/dist/types/core/error.d.ts +1 -0
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/core/scheduler.d.ts +2 -11
- package/dist/types/index.d.ts +1 -1
- package/dist/types/signals.d.ts +10 -0
- package/package.json +1 -1
package/dist/prod.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// src/core/error.ts
|
|
2
2
|
var NotReadyError = class extends Error {
|
|
3
|
+
constructor(node) {
|
|
4
|
+
super();
|
|
5
|
+
this.cause = node;
|
|
6
|
+
}
|
|
3
7
|
};
|
|
4
8
|
var NoOwnerError = class extends Error {
|
|
5
9
|
constructor() {
|
|
@@ -52,21 +56,21 @@ function notifyUnobserved() {
|
|
|
52
56
|
for (let i = 0; i < Unobserved.length; i++) {
|
|
53
57
|
const source = Unobserved[i];
|
|
54
58
|
if (!source.c || !source.c.length)
|
|
55
|
-
Unobserved[i].
|
|
59
|
+
Unobserved[i].fa?.();
|
|
56
60
|
}
|
|
57
61
|
Unobserved = [];
|
|
58
62
|
}
|
|
59
63
|
var pureQueue = [];
|
|
60
64
|
var Queue = class {
|
|
61
|
-
|
|
65
|
+
l = null;
|
|
62
66
|
C = false;
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
h = [[], []];
|
|
68
|
+
i = [];
|
|
65
69
|
created = clock;
|
|
66
70
|
enqueue(type, fn) {
|
|
67
71
|
pureQueue.push(fn);
|
|
68
72
|
if (type)
|
|
69
|
-
this.
|
|
73
|
+
this.h[type - 1].push(fn);
|
|
70
74
|
schedule();
|
|
71
75
|
}
|
|
72
76
|
run(type) {
|
|
@@ -74,13 +78,13 @@ var Queue = class {
|
|
|
74
78
|
pureQueue.length && runQueue(pureQueue, type);
|
|
75
79
|
pureQueue = [];
|
|
76
80
|
return;
|
|
77
|
-
} else if (this.
|
|
78
|
-
const effects = this.
|
|
79
|
-
this.
|
|
81
|
+
} else if (this.h[type - 1].length) {
|
|
82
|
+
const effects = this.h[type - 1];
|
|
83
|
+
this.h[type - 1] = [];
|
|
80
84
|
runQueue(effects, type);
|
|
81
85
|
}
|
|
82
|
-
for (let i = 0; i < this.
|
|
83
|
-
this.
|
|
86
|
+
for (let i = 0; i < this.i.length; i++) {
|
|
87
|
+
this.i[i].run(type);
|
|
84
88
|
}
|
|
85
89
|
}
|
|
86
90
|
flush() {
|
|
@@ -101,32 +105,32 @@ var Queue = class {
|
|
|
101
105
|
addChild(child) {
|
|
102
106
|
if (ActiveTransition && ActiveTransition.J.has(this))
|
|
103
107
|
return ActiveTransition.J.get(this).addChild(child);
|
|
104
|
-
this.
|
|
105
|
-
child.
|
|
108
|
+
this.i.push(child);
|
|
109
|
+
child.l = this;
|
|
106
110
|
}
|
|
107
111
|
removeChild(child) {
|
|
108
112
|
if (ActiveTransition && ActiveTransition.J.has(this))
|
|
109
113
|
return ActiveTransition.J.get(this).removeChild(child);
|
|
110
|
-
const index = this.
|
|
114
|
+
const index = this.i.indexOf(child);
|
|
111
115
|
if (index >= 0) {
|
|
112
|
-
this.
|
|
113
|
-
child.
|
|
116
|
+
this.i.splice(index, 1);
|
|
117
|
+
child.l = null;
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
120
|
notify(...args) {
|
|
117
|
-
if (this.
|
|
118
|
-
return this.
|
|
121
|
+
if (this.l)
|
|
122
|
+
return this.l.notify(...args);
|
|
119
123
|
return false;
|
|
120
124
|
}
|
|
121
125
|
merge(queue) {
|
|
122
|
-
this.
|
|
123
|
-
this.
|
|
124
|
-
for (let i = 0; i < queue.
|
|
125
|
-
const og = this.
|
|
126
|
+
this.h[0].push.apply(this.h[0], queue.h[0]);
|
|
127
|
+
this.h[1].push.apply(this.h[1], queue.h[1]);
|
|
128
|
+
for (let i = 0; i < queue.i.length; i++) {
|
|
129
|
+
const og = this.i.find((c) => c.d === queue.i[i].d);
|
|
126
130
|
if (og)
|
|
127
|
-
og.merge(queue.
|
|
131
|
+
og.merge(queue.i[i]);
|
|
128
132
|
else
|
|
129
|
-
this.addChild(queue.
|
|
133
|
+
this.addChild(queue.i[i]);
|
|
130
134
|
}
|
|
131
135
|
}
|
|
132
136
|
};
|
|
@@ -139,8 +143,8 @@ function flush() {
|
|
|
139
143
|
function removeSourceObservers(node, index) {
|
|
140
144
|
let source;
|
|
141
145
|
let swap;
|
|
142
|
-
for (let i = index; i < node.
|
|
143
|
-
source = getTransitionSource(node.
|
|
146
|
+
for (let i = index; i < node.b.length; i++) {
|
|
147
|
+
source = getTransitionSource(node.b[i]);
|
|
144
148
|
if (source.c) {
|
|
145
149
|
if ((swap = source.c.indexOf(node)) !== -1) {
|
|
146
150
|
source.c[swap] = source.c[source.c.length - 1];
|
|
@@ -156,30 +160,32 @@ function runQueue(queue, type) {
|
|
|
156
160
|
queue[i](type);
|
|
157
161
|
}
|
|
158
162
|
var Transition = class _Transition {
|
|
159
|
-
|
|
163
|
+
b = /* @__PURE__ */ new Map();
|
|
160
164
|
t = /* @__PURE__ */ new Set();
|
|
161
165
|
K = /* @__PURE__ */ new Set();
|
|
162
|
-
|
|
166
|
+
j = /* @__PURE__ */ new Set();
|
|
163
167
|
D = false;
|
|
164
|
-
|
|
168
|
+
h = [[], []];
|
|
165
169
|
J = /* @__PURE__ */ new Map();
|
|
166
170
|
G = [];
|
|
167
|
-
|
|
168
|
-
|
|
171
|
+
i = [];
|
|
172
|
+
l = null;
|
|
169
173
|
C = false;
|
|
170
174
|
Y = false;
|
|
171
175
|
d = globalQueue;
|
|
176
|
+
aa;
|
|
172
177
|
created = clock;
|
|
173
|
-
constructor() {
|
|
178
|
+
constructor(signal) {
|
|
179
|
+
this.aa = signal;
|
|
174
180
|
this.J.set(globalQueue, this);
|
|
175
|
-
for (const child of globalQueue.
|
|
181
|
+
for (const child of globalQueue.i) {
|
|
176
182
|
cloneQueue(child, this, this);
|
|
177
183
|
}
|
|
178
184
|
}
|
|
179
185
|
enqueue(type, fn) {
|
|
180
186
|
this.G.push(fn);
|
|
181
187
|
if (type)
|
|
182
|
-
this.
|
|
188
|
+
this.h[type - 1].push(fn);
|
|
183
189
|
this.schedule();
|
|
184
190
|
}
|
|
185
191
|
run(type) {
|
|
@@ -187,18 +193,19 @@ var Transition = class _Transition {
|
|
|
187
193
|
this.G.length && runQueue(this.G, type);
|
|
188
194
|
this.G = [];
|
|
189
195
|
return;
|
|
190
|
-
} else if (this.
|
|
191
|
-
const effects = this.
|
|
192
|
-
this.
|
|
196
|
+
} else if (this.h[type - 1].length) {
|
|
197
|
+
const effects = this.h[type - 1];
|
|
198
|
+
this.h[type - 1] = [];
|
|
193
199
|
runQueue(effects, type);
|
|
194
200
|
}
|
|
195
|
-
for (let i = 0; i < this.
|
|
196
|
-
this.
|
|
201
|
+
for (let i = 0; i < this.i.length; i++) {
|
|
202
|
+
this.i[i].run(type);
|
|
197
203
|
}
|
|
198
204
|
}
|
|
199
205
|
flush() {
|
|
200
206
|
if (this.C || this.D)
|
|
201
207
|
return;
|
|
208
|
+
globalQueue.flush();
|
|
202
209
|
this.C = true;
|
|
203
210
|
let currentTransition = ActiveTransition;
|
|
204
211
|
ActiveTransition = this;
|
|
@@ -214,13 +221,13 @@ var Transition = class _Transition {
|
|
|
214
221
|
}
|
|
215
222
|
}
|
|
216
223
|
addChild(child) {
|
|
217
|
-
this.
|
|
218
|
-
child.
|
|
224
|
+
this.i.push(child);
|
|
225
|
+
child.l = this;
|
|
219
226
|
}
|
|
220
227
|
removeChild(child) {
|
|
221
|
-
const index = this.
|
|
228
|
+
const index = this.i.indexOf(child);
|
|
222
229
|
if (index >= 0)
|
|
223
|
-
this.
|
|
230
|
+
this.i.splice(index, 1);
|
|
224
231
|
}
|
|
225
232
|
notify(node, type, flags) {
|
|
226
233
|
if (!(type & LOADING_BIT))
|
|
@@ -233,18 +240,18 @@ var Transition = class _Transition {
|
|
|
233
240
|
return true;
|
|
234
241
|
}
|
|
235
242
|
merge(queue) {
|
|
236
|
-
this.
|
|
237
|
-
this.
|
|
243
|
+
this.h[0].push.apply(this.h[0], queue.h[0]);
|
|
244
|
+
this.h[1].push.apply(this.h[1], queue.h[1]);
|
|
238
245
|
this.G.push.apply(this.G, queue.G);
|
|
239
|
-
queue.
|
|
240
|
-
queue.
|
|
246
|
+
queue.h[0].length = 0;
|
|
247
|
+
queue.h[1].length = 0;
|
|
241
248
|
queue.G.length = 0;
|
|
242
|
-
for (let i = 0; i < queue.
|
|
243
|
-
const og = this.
|
|
249
|
+
for (let i = 0; i < queue.i.length; i++) {
|
|
250
|
+
const og = this.i.find((c) => c.d === queue.i[i].d);
|
|
244
251
|
if (og)
|
|
245
|
-
og.merge(queue.
|
|
252
|
+
og.merge(queue.i[i]);
|
|
246
253
|
else
|
|
247
|
-
this.addChild(queue.
|
|
254
|
+
this.addChild(queue.i[i]);
|
|
248
255
|
}
|
|
249
256
|
}
|
|
250
257
|
schedule() {
|
|
@@ -304,45 +311,44 @@ var Transition = class _Transition {
|
|
|
304
311
|
}
|
|
305
312
|
}
|
|
306
313
|
addOptimistic(fn) {
|
|
307
|
-
if (fn.
|
|
308
|
-
mergeTransitions(fn.
|
|
309
|
-
ActiveTransition = fn.
|
|
314
|
+
if (fn.f && fn.f !== this) {
|
|
315
|
+
mergeTransitions(fn.f, this);
|
|
316
|
+
ActiveTransition = fn.f;
|
|
310
317
|
return;
|
|
311
318
|
}
|
|
312
|
-
fn.
|
|
313
|
-
this.
|
|
319
|
+
fn.f = this;
|
|
320
|
+
this.j.add(fn);
|
|
314
321
|
}
|
|
315
322
|
};
|
|
316
|
-
function transition(fn) {
|
|
317
|
-
let t = new Transition();
|
|
318
|
-
queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
|
|
319
|
-
}
|
|
320
323
|
function cloneGraph(node) {
|
|
321
|
-
if (node.
|
|
322
|
-
|
|
324
|
+
if (node.j) {
|
|
325
|
+
if (node.a !== STATE_DISPOSED) {
|
|
326
|
+
!node.f && node.j.ia?.();
|
|
327
|
+
ActiveTransition.addOptimistic(node.j);
|
|
328
|
+
}
|
|
323
329
|
return node;
|
|
324
330
|
}
|
|
325
|
-
if (node.
|
|
326
|
-
if (node.
|
|
327
|
-
mergeTransitions(node.
|
|
328
|
-
ActiveTransition = node.
|
|
331
|
+
if (node.f) {
|
|
332
|
+
if (node.f !== ActiveTransition) {
|
|
333
|
+
mergeTransitions(node.f, ActiveTransition);
|
|
334
|
+
ActiveTransition = node.f;
|
|
329
335
|
}
|
|
330
|
-
return node.
|
|
336
|
+
return node.f.b.get(node);
|
|
331
337
|
}
|
|
332
338
|
const clone = Object.create(Object.getPrototypeOf(node));
|
|
333
339
|
Object.assign(clone, node, {
|
|
334
340
|
o: null,
|
|
335
341
|
n: null,
|
|
336
342
|
c: null,
|
|
337
|
-
|
|
343
|
+
b: node.b ? [...node.b] : null,
|
|
338
344
|
d: node
|
|
339
345
|
});
|
|
340
346
|
delete clone.T;
|
|
341
|
-
ActiveTransition.
|
|
342
|
-
node.
|
|
343
|
-
if (node.
|
|
344
|
-
for (let i = 0; i < node.
|
|
345
|
-
node.
|
|
347
|
+
ActiveTransition.b.set(node, clone);
|
|
348
|
+
node.f = ActiveTransition;
|
|
349
|
+
if (node.b) {
|
|
350
|
+
for (let i = 0; i < node.b.length; i++)
|
|
351
|
+
node.b[i].c.push(clone);
|
|
346
352
|
}
|
|
347
353
|
if (node.c) {
|
|
348
354
|
clone.c = [];
|
|
@@ -361,9 +367,9 @@ function replaceSourceObservers(node, transition2) {
|
|
|
361
367
|
let source;
|
|
362
368
|
let transitionSource;
|
|
363
369
|
let swap;
|
|
364
|
-
for (let i = 0; i < node.
|
|
365
|
-
transitionSource = transition2.
|
|
366
|
-
source = transitionSource || node.
|
|
370
|
+
for (let i = 0; i < node.b.length; i++) {
|
|
371
|
+
transitionSource = transition2.b.get(node.b[i]);
|
|
372
|
+
source = transitionSource || node.b[i];
|
|
367
373
|
if (source.c && (swap = source.c.indexOf(node)) !== -1) {
|
|
368
374
|
source.c[swap] = transitionSource ? node.d : source.c[source.c.length - 1];
|
|
369
375
|
!transitionSource && source.c.pop();
|
|
@@ -374,8 +380,8 @@ function cloneQueue(queue, parent, transition2) {
|
|
|
374
380
|
const clone = Object.create(Object.getPrototypeOf(queue));
|
|
375
381
|
Object.assign(clone, queue, {
|
|
376
382
|
d: queue,
|
|
377
|
-
|
|
378
|
-
|
|
383
|
+
l: parent,
|
|
384
|
+
i: [],
|
|
379
385
|
enqueue(type, fn) {
|
|
380
386
|
transition2 = latestTransition(transition2);
|
|
381
387
|
transition2.enqueue(type, fn);
|
|
@@ -392,9 +398,9 @@ function cloneQueue(queue, parent, transition2) {
|
|
|
392
398
|
return queue.notify.call(this, node, type, flags);
|
|
393
399
|
}
|
|
394
400
|
});
|
|
395
|
-
parent.
|
|
401
|
+
parent.i.push(clone);
|
|
396
402
|
transition2.J.set(queue, clone);
|
|
397
|
-
for (const child of queue.
|
|
403
|
+
for (const child of queue.i) {
|
|
398
404
|
cloneQueue(child, clone, transition2);
|
|
399
405
|
}
|
|
400
406
|
}
|
|
@@ -402,27 +408,27 @@ function resolveQueues(children) {
|
|
|
402
408
|
for (const child of children) {
|
|
403
409
|
const og = child.d;
|
|
404
410
|
if (og) {
|
|
405
|
-
const clonedChildren = child.
|
|
411
|
+
const clonedChildren = child.i;
|
|
406
412
|
delete child.enqueue;
|
|
407
413
|
delete child.notify;
|
|
408
|
-
delete child.
|
|
409
|
-
delete child.
|
|
414
|
+
delete child.l;
|
|
415
|
+
delete child.i;
|
|
410
416
|
Object.assign(og, child);
|
|
411
417
|
delete og.d;
|
|
412
418
|
resolveQueues(clonedChildren);
|
|
413
|
-
} else if (child.
|
|
414
|
-
child.
|
|
419
|
+
} else if (child.l.d) {
|
|
420
|
+
child.l.d.addChild(child);
|
|
415
421
|
}
|
|
416
422
|
}
|
|
417
423
|
}
|
|
418
424
|
function mergeTransitions(t1, t2) {
|
|
419
|
-
t2.
|
|
420
|
-
key.
|
|
421
|
-
t1.
|
|
425
|
+
t2.b.forEach((value, key) => {
|
|
426
|
+
key.f = t1;
|
|
427
|
+
t1.b.set(key, value);
|
|
422
428
|
});
|
|
423
|
-
t2.
|
|
424
|
-
c.
|
|
425
|
-
t1.
|
|
429
|
+
t2.j.forEach((c) => {
|
|
430
|
+
c.f = t1;
|
|
431
|
+
t1.j.add(c);
|
|
426
432
|
});
|
|
427
433
|
t2.K.forEach((p) => t1.K.add(p));
|
|
428
434
|
t2.t.forEach((n) => t1.t.add(n));
|
|
@@ -430,17 +436,17 @@ function mergeTransitions(t1, t2) {
|
|
|
430
436
|
t2.D = t1;
|
|
431
437
|
}
|
|
432
438
|
function getTransitionSource(input) {
|
|
433
|
-
return ActiveTransition && ActiveTransition.
|
|
439
|
+
return ActiveTransition && ActiveTransition.b.get(input) || input;
|
|
434
440
|
}
|
|
435
441
|
function getQueue(node) {
|
|
436
|
-
const transition2 = ActiveTransition || node.d?.
|
|
442
|
+
const transition2 = ActiveTransition || node.d?.f;
|
|
437
443
|
return transition2 && transition2.J.get(node.E) || node.E;
|
|
438
444
|
}
|
|
439
445
|
function initialDispose(node) {
|
|
440
446
|
let current = node.n;
|
|
441
|
-
while (current !== null && current.
|
|
447
|
+
while (current !== null && current.l === node) {
|
|
442
448
|
initialDispose(current);
|
|
443
|
-
const clone = ActiveTransition.
|
|
449
|
+
const clone = ActiveTransition.b.get(current);
|
|
444
450
|
if (clone && !clone.Z)
|
|
445
451
|
clone.dispose(true);
|
|
446
452
|
current = current.n;
|
|
@@ -449,18 +455,18 @@ function initialDispose(node) {
|
|
|
449
455
|
function finishTransition(transition2) {
|
|
450
456
|
if (transition2.D || transition2.Y || transition2.K.size || transition2.t.size)
|
|
451
457
|
return;
|
|
452
|
-
globalQueue.
|
|
453
|
-
globalQueue.
|
|
454
|
-
resolveQueues(transition2.
|
|
455
|
-
for (const [source, clone] of transition2.
|
|
456
|
-
if (source === clone || source.
|
|
457
|
-
delete source.
|
|
458
|
+
globalQueue.h[0].push.apply(globalQueue.h[0], transition2.h[0]);
|
|
459
|
+
globalQueue.h[1].push.apply(globalQueue.h[1], transition2.h[1]);
|
|
460
|
+
resolveQueues(transition2.i);
|
|
461
|
+
for (const [source, clone] of transition2.b) {
|
|
462
|
+
if (source === clone || source.f !== transition2) {
|
|
463
|
+
delete source.f;
|
|
458
464
|
continue;
|
|
459
465
|
}
|
|
460
|
-
if (clone.
|
|
466
|
+
if (clone.b)
|
|
461
467
|
replaceSourceObservers(clone, transition2);
|
|
462
|
-
if (clone.Z || clone.
|
|
463
|
-
source.dispose(clone.
|
|
468
|
+
if (clone.Z || clone.a === STATE_DISPOSED) {
|
|
469
|
+
source.dispose(clone.a === STATE_DISPOSED);
|
|
464
470
|
source.emptyDisposal();
|
|
465
471
|
delete clone.Z;
|
|
466
472
|
} else {
|
|
@@ -472,17 +478,18 @@ function finishTransition(transition2) {
|
|
|
472
478
|
let current = clone.n;
|
|
473
479
|
if (current?.z === clone)
|
|
474
480
|
current.z = source;
|
|
475
|
-
while (current?.
|
|
476
|
-
current.
|
|
481
|
+
while (current?.l === clone) {
|
|
482
|
+
current.l = source;
|
|
477
483
|
current = current.n;
|
|
478
484
|
}
|
|
479
|
-
delete source.
|
|
485
|
+
delete source.f;
|
|
480
486
|
}
|
|
481
487
|
transition2.D = true;
|
|
482
|
-
for (const reset of transition2.
|
|
483
|
-
delete reset.
|
|
488
|
+
for (const reset of transition2.j) {
|
|
489
|
+
delete reset.f;
|
|
484
490
|
reset();
|
|
485
491
|
}
|
|
492
|
+
transition2.aa.write(true);
|
|
486
493
|
globalQueue.flush();
|
|
487
494
|
}
|
|
488
495
|
|
|
@@ -501,14 +508,14 @@ var Owner = class {
|
|
|
501
508
|
// We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild
|
|
502
509
|
// However, the children are actually added in reverse creation order
|
|
503
510
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
504
|
-
|
|
511
|
+
l = null;
|
|
505
512
|
n = null;
|
|
506
513
|
z = null;
|
|
507
|
-
|
|
514
|
+
a = STATE_CLEAN;
|
|
508
515
|
o = null;
|
|
509
516
|
A = defaultContext;
|
|
510
517
|
E = globalQueue;
|
|
511
|
-
|
|
518
|
+
ga = 0;
|
|
512
519
|
id = null;
|
|
513
520
|
constructor(id = null, skipAppend = false) {
|
|
514
521
|
this.id = id;
|
|
@@ -517,7 +524,7 @@ var Owner = class {
|
|
|
517
524
|
}
|
|
518
525
|
}
|
|
519
526
|
append(child) {
|
|
520
|
-
child.
|
|
527
|
+
child.l = this;
|
|
521
528
|
child.z = this;
|
|
522
529
|
if (this.n)
|
|
523
530
|
this.n.z = child;
|
|
@@ -532,16 +539,16 @@ var Owner = class {
|
|
|
532
539
|
child.E = this.E;
|
|
533
540
|
}
|
|
534
541
|
dispose(self = true) {
|
|
535
|
-
if (this.
|
|
542
|
+
if (this.a === STATE_DISPOSED)
|
|
536
543
|
return;
|
|
537
|
-
let head = self ? this.z || this.
|
|
538
|
-
while (current && current.
|
|
544
|
+
let head = self ? this.z || this.l : this, current = this.n, next = null;
|
|
545
|
+
while (current && current.l === this) {
|
|
539
546
|
current.dispose(true);
|
|
540
547
|
next = current.n;
|
|
541
548
|
current.n = null;
|
|
542
549
|
current = next;
|
|
543
550
|
}
|
|
544
|
-
this.
|
|
551
|
+
this.ga = 0;
|
|
545
552
|
if (self)
|
|
546
553
|
this.M();
|
|
547
554
|
if (current)
|
|
@@ -552,10 +559,10 @@ var Owner = class {
|
|
|
552
559
|
M() {
|
|
553
560
|
if (this.z)
|
|
554
561
|
this.z.n = null;
|
|
555
|
-
this.
|
|
562
|
+
this.l = null;
|
|
556
563
|
this.z = null;
|
|
557
564
|
this.A = defaultContext;
|
|
558
|
-
this.
|
|
565
|
+
this.a = STATE_DISPOSED;
|
|
559
566
|
this.emptyDisposal();
|
|
560
567
|
}
|
|
561
568
|
emptyDisposal() {
|
|
@@ -573,7 +580,7 @@ var Owner = class {
|
|
|
573
580
|
}
|
|
574
581
|
getNextChildId() {
|
|
575
582
|
if (this.id != null)
|
|
576
|
-
return formatId(this.id, this.
|
|
583
|
+
return formatId(this.id, this.ga++);
|
|
577
584
|
throw new Error("Cannot get child id from owner without an id");
|
|
578
585
|
}
|
|
579
586
|
};
|
|
@@ -637,49 +644,53 @@ function getObserver() {
|
|
|
637
644
|
}
|
|
638
645
|
var UNCHANGED = Symbol(0);
|
|
639
646
|
var Computation = class extends Owner {
|
|
640
|
-
|
|
647
|
+
b = null;
|
|
641
648
|
c = null;
|
|
642
|
-
|
|
649
|
+
m;
|
|
643
650
|
O;
|
|
644
651
|
P;
|
|
645
652
|
// Used in __DEV__ mode, hopefully removed in production
|
|
646
|
-
|
|
653
|
+
na;
|
|
647
654
|
// Using false is an optimization as an alternative to _equals: () => false
|
|
648
655
|
// which could enable more efficient DIRTY notification
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
656
|
+
ba = isEqual;
|
|
657
|
+
fa;
|
|
658
|
+
ja = false;
|
|
652
659
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
653
|
-
|
|
660
|
+
g = 0;
|
|
654
661
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
655
|
-
|
|
662
|
+
ca = DEFAULT_FLAGS;
|
|
656
663
|
Q = -1;
|
|
657
664
|
H = false;
|
|
658
|
-
|
|
665
|
+
f;
|
|
659
666
|
d;
|
|
660
|
-
|
|
667
|
+
j;
|
|
661
668
|
constructor(initialValue, compute2, options) {
|
|
662
669
|
super(options?.id, compute2 === null);
|
|
663
670
|
this.P = compute2;
|
|
664
|
-
this.
|
|
665
|
-
this.
|
|
666
|
-
this.
|
|
671
|
+
this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
672
|
+
this.g = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
673
|
+
this.m = initialValue;
|
|
667
674
|
if (options?.equals !== void 0)
|
|
668
|
-
this.
|
|
669
|
-
this.
|
|
670
|
-
this.
|
|
675
|
+
this.ba = options.equals;
|
|
676
|
+
this.ja = !!options?.pureWrite;
|
|
677
|
+
this.fa = options?.unobserved;
|
|
671
678
|
if (ActiveTransition) {
|
|
672
|
-
this.
|
|
673
|
-
ActiveTransition.
|
|
679
|
+
this.f = ActiveTransition;
|
|
680
|
+
ActiveTransition.b.set(this, this);
|
|
674
681
|
}
|
|
675
682
|
}
|
|
676
|
-
|
|
683
|
+
ha() {
|
|
684
|
+
if (staleCheck && (this.g & LOADING_BIT || this.f)) {
|
|
685
|
+
staleCheck.m = true;
|
|
686
|
+
this.f?.aa.read();
|
|
687
|
+
}
|
|
677
688
|
track(this);
|
|
678
|
-
newFlags |= this.
|
|
679
|
-
if (this.
|
|
689
|
+
newFlags |= this.g & ~currentMask;
|
|
690
|
+
if (this.g & ERROR_BIT) {
|
|
680
691
|
throw this.O;
|
|
681
692
|
} else {
|
|
682
|
-
return this.
|
|
693
|
+
return this.m;
|
|
683
694
|
}
|
|
684
695
|
}
|
|
685
696
|
/**
|
|
@@ -687,18 +698,18 @@ var Computation = class extends Owner {
|
|
|
687
698
|
* Automatically re-executes the surrounding computation when the value changes
|
|
688
699
|
*/
|
|
689
700
|
read() {
|
|
690
|
-
if (ActiveTransition && (ActiveTransition.
|
|
691
|
-
const clone = ActiveTransition.
|
|
701
|
+
if (ActiveTransition && (ActiveTransition.b.has(this) || !this.d && this.g & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
702
|
+
const clone = ActiveTransition.b.get(this) || cloneGraph(this);
|
|
692
703
|
if (clone !== this)
|
|
693
704
|
return clone.read();
|
|
694
705
|
}
|
|
695
706
|
if (this.P) {
|
|
696
|
-
if (this.
|
|
707
|
+
if (this.g & ERROR_BIT && this.Q <= clock)
|
|
697
708
|
update(this);
|
|
698
709
|
else
|
|
699
710
|
this.F();
|
|
700
711
|
}
|
|
701
|
-
return this.
|
|
712
|
+
return this.ha();
|
|
702
713
|
}
|
|
703
714
|
/**
|
|
704
715
|
* Return the current value of this computation
|
|
@@ -708,25 +719,21 @@ var Computation = class extends Owner {
|
|
|
708
719
|
* before continuing
|
|
709
720
|
*/
|
|
710
721
|
wait() {
|
|
711
|
-
if (ActiveTransition && (ActiveTransition.
|
|
712
|
-
const clone = ActiveTransition.
|
|
722
|
+
if (ActiveTransition && (ActiveTransition.b.has(this) || !this.d && this.g & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
723
|
+
const clone = ActiveTransition.b.get(this) || cloneGraph(this);
|
|
713
724
|
if (clone !== this)
|
|
714
725
|
return clone.wait();
|
|
715
726
|
}
|
|
716
727
|
if (this.P) {
|
|
717
|
-
if (this.
|
|
728
|
+
if (this.g & ERROR_BIT && this.Q <= clock)
|
|
718
729
|
update(this);
|
|
719
730
|
else
|
|
720
731
|
this.F();
|
|
721
732
|
}
|
|
722
|
-
if ((notStale || this.
|
|
723
|
-
|
|
724
|
-
throw new NotReadyError();
|
|
725
|
-
}
|
|
726
|
-
if (staleCheck && this.f & LOADING_BIT) {
|
|
727
|
-
staleCheck.l = true;
|
|
733
|
+
if ((notStale || this.g & UNINITIALIZED_BIT) && this.g & LOADING_BIT) {
|
|
734
|
+
throw new NotReadyError(this);
|
|
728
735
|
}
|
|
729
|
-
return this.
|
|
736
|
+
return this.ha();
|
|
730
737
|
}
|
|
731
738
|
/** Update the computation with a new value. */
|
|
732
739
|
write(value, flags = 0, raw = false) {
|
|
@@ -735,17 +742,17 @@ var Computation = class extends Owner {
|
|
|
735
742
|
if (clone !== this)
|
|
736
743
|
return clone.write(value, flags, raw);
|
|
737
744
|
}
|
|
738
|
-
const newValue = !raw && typeof value === "function" ? value(this.
|
|
739
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
740
|
-
this.
|
|
745
|
+
const newValue = !raw && typeof value === "function" ? value(this.m) : value;
|
|
746
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.g & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
|
|
747
|
+
this.ba === false || !this.ba(this.m, newValue));
|
|
741
748
|
if (valueChanged) {
|
|
742
|
-
this.
|
|
749
|
+
this.m = newValue;
|
|
743
750
|
this.O = void 0;
|
|
744
751
|
}
|
|
745
|
-
const changedFlagsMask = this.
|
|
746
|
-
this.
|
|
752
|
+
const changedFlagsMask = this.g ^ flags, changedFlags = changedFlagsMask & flags;
|
|
753
|
+
this.g = flags;
|
|
747
754
|
this.Q = clock + 1;
|
|
748
|
-
if (this.c && !(this.
|
|
755
|
+
if (this.c && !(this.j && ActiveTransition)) {
|
|
749
756
|
for (let i = 0; i < this.c.length; i++) {
|
|
750
757
|
if (valueChanged) {
|
|
751
758
|
this.c[i].u(STATE_DIRTY);
|
|
@@ -754,17 +761,17 @@ var Computation = class extends Owner {
|
|
|
754
761
|
}
|
|
755
762
|
}
|
|
756
763
|
}
|
|
757
|
-
return this.
|
|
764
|
+
return this.m;
|
|
758
765
|
}
|
|
759
766
|
/**
|
|
760
767
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
761
768
|
*/
|
|
762
769
|
u(state, skipQueue) {
|
|
763
|
-
if (this.
|
|
770
|
+
if (this.a >= state && !this.H)
|
|
764
771
|
return;
|
|
765
772
|
this.H = !!skipQueue;
|
|
766
|
-
this.
|
|
767
|
-
if (this.c && !(this.
|
|
773
|
+
this.a = state;
|
|
774
|
+
if (this.c && !(this.j && ActiveTransition)) {
|
|
768
775
|
for (let i = 0; i < this.c.length; i++) {
|
|
769
776
|
this.c[i].u(STATE_CHECK, skipQueue);
|
|
770
777
|
}
|
|
@@ -777,20 +784,20 @@ var Computation = class extends Owner {
|
|
|
777
784
|
* @param newFlags The source's new flags, masked to just the changed ones.
|
|
778
785
|
*/
|
|
779
786
|
_(mask, newFlags2) {
|
|
780
|
-
if (this.
|
|
787
|
+
if (this.a >= STATE_DIRTY)
|
|
781
788
|
return;
|
|
782
|
-
if (mask & this.
|
|
789
|
+
if (mask & this.ca || this.j && ActiveTransition) {
|
|
783
790
|
this.u(STATE_DIRTY);
|
|
784
791
|
return;
|
|
785
792
|
}
|
|
786
|
-
if (this.
|
|
793
|
+
if (this.a >= STATE_CHECK && !this.H)
|
|
787
794
|
return;
|
|
788
|
-
const prevFlags = this.
|
|
795
|
+
const prevFlags = this.g & mask;
|
|
789
796
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
790
797
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
791
798
|
this.u(STATE_CHECK);
|
|
792
799
|
} else {
|
|
793
|
-
this.
|
|
800
|
+
this.g ^= deltaFlags;
|
|
794
801
|
if (this.c) {
|
|
795
802
|
for (let i = 0; i < this.c.length; i++) {
|
|
796
803
|
this.c[i]._(mask, newFlags2);
|
|
@@ -805,7 +812,7 @@ var Computation = class extends Owner {
|
|
|
805
812
|
return clone.N(error);
|
|
806
813
|
}
|
|
807
814
|
this.O = error;
|
|
808
|
-
this.write(UNCHANGED, this.
|
|
815
|
+
this.write(UNCHANGED, this.g & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
809
816
|
}
|
|
810
817
|
/**
|
|
811
818
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -818,37 +825,37 @@ var Computation = class extends Owner {
|
|
|
818
825
|
if (!this.P) {
|
|
819
826
|
return;
|
|
820
827
|
}
|
|
821
|
-
if (this.
|
|
828
|
+
if (this.a === STATE_DISPOSED) {
|
|
822
829
|
return;
|
|
823
830
|
}
|
|
824
|
-
if (this.
|
|
831
|
+
if (this.a === STATE_CLEAN) {
|
|
825
832
|
return;
|
|
826
833
|
}
|
|
827
834
|
let observerFlags = 0;
|
|
828
|
-
if (this.
|
|
829
|
-
for (let i = 0; i < this.
|
|
830
|
-
const source = getTransitionSource(this.
|
|
835
|
+
if (this.a === STATE_CHECK) {
|
|
836
|
+
for (let i = 0; i < this.b.length; i++) {
|
|
837
|
+
const source = getTransitionSource(this.b[i]);
|
|
831
838
|
source.F();
|
|
832
|
-
observerFlags |= source.
|
|
833
|
-
if (this.
|
|
839
|
+
observerFlags |= source.g & ~UNINITIALIZED_BIT;
|
|
840
|
+
if (this.a === STATE_DIRTY) {
|
|
834
841
|
break;
|
|
835
842
|
}
|
|
836
843
|
}
|
|
837
844
|
}
|
|
838
|
-
if (this.
|
|
845
|
+
if (this.a === STATE_DIRTY) {
|
|
839
846
|
update(this);
|
|
840
847
|
} else {
|
|
841
848
|
this.write(UNCHANGED, observerFlags);
|
|
842
|
-
this.
|
|
849
|
+
this.a = STATE_CLEAN;
|
|
843
850
|
}
|
|
844
851
|
}
|
|
845
852
|
/**
|
|
846
853
|
* Remove ourselves from the owner graph and the computation graph
|
|
847
854
|
*/
|
|
848
855
|
M() {
|
|
849
|
-
if (this.
|
|
856
|
+
if (this.a === STATE_DISPOSED)
|
|
850
857
|
return;
|
|
851
|
-
if (this.
|
|
858
|
+
if (this.b)
|
|
852
859
|
removeSourceObservers(this, 0);
|
|
853
860
|
super.M();
|
|
854
861
|
}
|
|
@@ -857,7 +864,7 @@ function track(computation) {
|
|
|
857
864
|
if (ActiveTransition && computation.d)
|
|
858
865
|
computation = computation.d;
|
|
859
866
|
if (currentObserver) {
|
|
860
|
-
if (!newSources && currentObserver.
|
|
867
|
+
if (!newSources && currentObserver.b && currentObserver.b[newSourcesIndex] === computation) {
|
|
861
868
|
newSourcesIndex++;
|
|
862
869
|
} else if (!newSources)
|
|
863
870
|
newSources = [computation];
|
|
@@ -865,7 +872,7 @@ function track(computation) {
|
|
|
865
872
|
newSources.push(computation);
|
|
866
873
|
}
|
|
867
874
|
if (updateCheck) {
|
|
868
|
-
updateCheck.
|
|
875
|
+
updateCheck.m = computation.Q > currentObserver.Q;
|
|
869
876
|
}
|
|
870
877
|
}
|
|
871
878
|
}
|
|
@@ -885,39 +892,45 @@ function update(node) {
|
|
|
885
892
|
node.write(result, newFlags, true);
|
|
886
893
|
} catch (error) {
|
|
887
894
|
if (error instanceof NotReadyError) {
|
|
888
|
-
|
|
895
|
+
if (error.cause !== node)
|
|
896
|
+
compute(
|
|
897
|
+
node,
|
|
898
|
+
() => track(error.cause),
|
|
899
|
+
node
|
|
900
|
+
);
|
|
901
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.g & UNINITIALIZED_BIT);
|
|
889
902
|
} else {
|
|
890
903
|
node.N(error);
|
|
891
904
|
}
|
|
892
905
|
} finally {
|
|
893
906
|
if (newSources) {
|
|
894
|
-
if (node.
|
|
907
|
+
if (node.b)
|
|
895
908
|
removeSourceObservers(node, newSourcesIndex);
|
|
896
|
-
if (node.
|
|
897
|
-
node.
|
|
909
|
+
if (node.b && newSourcesIndex > 0) {
|
|
910
|
+
node.b.length = newSourcesIndex + newSources.length;
|
|
898
911
|
for (let i = 0; i < newSources.length; i++) {
|
|
899
|
-
node.
|
|
912
|
+
node.b[newSourcesIndex + i] = newSources[i];
|
|
900
913
|
}
|
|
901
914
|
} else {
|
|
902
|
-
node.
|
|
915
|
+
node.b = newSources;
|
|
903
916
|
}
|
|
904
917
|
let source;
|
|
905
|
-
for (let i = newSourcesIndex; i < node.
|
|
906
|
-
source = getTransitionSource(node.
|
|
918
|
+
for (let i = newSourcesIndex; i < node.b.length; i++) {
|
|
919
|
+
source = getTransitionSource(node.b[i]);
|
|
907
920
|
if (!source.c)
|
|
908
921
|
source.c = [node];
|
|
909
922
|
else
|
|
910
923
|
source.c.push(node);
|
|
911
924
|
}
|
|
912
|
-
} else if (node.
|
|
925
|
+
} else if (node.b && newSourcesIndex < node.b.length) {
|
|
913
926
|
removeSourceObservers(node, newSourcesIndex);
|
|
914
|
-
node.
|
|
927
|
+
node.b.length = newSourcesIndex;
|
|
915
928
|
}
|
|
916
929
|
newSources = prevSources;
|
|
917
930
|
newSourcesIndex = prevSourcesIndex;
|
|
918
931
|
newFlags = prevFlags;
|
|
919
932
|
node.Q = clock + 1;
|
|
920
|
-
node.
|
|
933
|
+
node.a = STATE_CLEAN;
|
|
921
934
|
}
|
|
922
935
|
}
|
|
923
936
|
function isEqual(a, b) {
|
|
@@ -930,20 +943,20 @@ function untrack(fn) {
|
|
|
930
943
|
}
|
|
931
944
|
function hasUpdated(fn) {
|
|
932
945
|
const current = updateCheck;
|
|
933
|
-
updateCheck = {
|
|
946
|
+
updateCheck = { m: false };
|
|
934
947
|
try {
|
|
935
948
|
fn();
|
|
936
|
-
return updateCheck.
|
|
949
|
+
return updateCheck.m;
|
|
937
950
|
} finally {
|
|
938
951
|
updateCheck = current;
|
|
939
952
|
}
|
|
940
953
|
}
|
|
941
954
|
function pendingCheck(fn, loadingValue) {
|
|
942
955
|
const current = staleCheck;
|
|
943
|
-
staleCheck = {
|
|
956
|
+
staleCheck = { m: false };
|
|
944
957
|
try {
|
|
945
958
|
latest(fn);
|
|
946
|
-
return staleCheck.
|
|
959
|
+
return staleCheck.m;
|
|
947
960
|
} catch (err) {
|
|
948
961
|
if (!(err instanceof NotReadyError))
|
|
949
962
|
return false;
|
|
@@ -958,8 +971,17 @@ function isPending(fn, loadingValue) {
|
|
|
958
971
|
if (!currentObserver)
|
|
959
972
|
return pendingCheck(fn, loadingValue);
|
|
960
973
|
const c = new Computation(void 0, () => pendingCheck(fn, loadingValue));
|
|
961
|
-
c.
|
|
962
|
-
|
|
974
|
+
c.j = () => c.write(false);
|
|
975
|
+
c.j.ia = () => globalQueue.enqueue(0, () => c.j.f && c.write(true));
|
|
976
|
+
c.ca |= LOADING_BIT;
|
|
977
|
+
const res = c.wait();
|
|
978
|
+
c.o = () => {
|
|
979
|
+
if (c.j.f) {
|
|
980
|
+
c.j.f.j.delete(c.j);
|
|
981
|
+
delete c.j.f;
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
return res;
|
|
963
985
|
}
|
|
964
986
|
function latest(fn, fallback) {
|
|
965
987
|
const argLength = arguments.length;
|
|
@@ -980,10 +1002,10 @@ function latest(fn, fallback) {
|
|
|
980
1002
|
function compute(owner, fn, observer) {
|
|
981
1003
|
const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
|
|
982
1004
|
currentObserver = observer;
|
|
983
|
-
currentMask = observer?.
|
|
1005
|
+
currentMask = observer?.ca ?? DEFAULT_FLAGS;
|
|
984
1006
|
notStale = true;
|
|
985
1007
|
try {
|
|
986
|
-
return fn.call(observer, observer ? observer.
|
|
1008
|
+
return fn.call(observer, observer ? observer.m : void 0);
|
|
987
1009
|
} finally {
|
|
988
1010
|
setOwner(prevOwner);
|
|
989
1011
|
currentObserver = prevObserver;
|
|
@@ -994,50 +1016,50 @@ function compute(owner, fn, observer) {
|
|
|
994
1016
|
|
|
995
1017
|
// src/core/effect.ts
|
|
996
1018
|
var Effect = class extends Computation {
|
|
997
|
-
|
|
1019
|
+
da;
|
|
998
1020
|
$;
|
|
999
1021
|
w;
|
|
1000
|
-
|
|
1022
|
+
ea = false;
|
|
1001
1023
|
T;
|
|
1002
1024
|
s;
|
|
1003
1025
|
constructor(initialValue, compute2, effect, error, options) {
|
|
1004
1026
|
super(initialValue, compute2, options);
|
|
1005
|
-
this.
|
|
1027
|
+
this.da = effect;
|
|
1006
1028
|
this.$ = error;
|
|
1007
1029
|
this.T = initialValue;
|
|
1008
1030
|
this.s = options?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
1009
1031
|
if (this.s === EFFECT_RENDER) {
|
|
1010
1032
|
this.P = function(p) {
|
|
1011
|
-
return !this.d && clock > this.E.created && !(this.
|
|
1033
|
+
return !this.d && clock > this.E.created && !(this.g & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
1012
1034
|
};
|
|
1013
1035
|
}
|
|
1014
1036
|
this.F();
|
|
1015
1037
|
!options?.defer && (this.s === EFFECT_USER ? getQueue(this).enqueue(this.s, this.x.bind(this)) : this.x(this.s));
|
|
1016
1038
|
}
|
|
1017
1039
|
write(value, flags = 0) {
|
|
1018
|
-
if (this.
|
|
1019
|
-
this.
|
|
1040
|
+
if (this.a == STATE_DIRTY) {
|
|
1041
|
+
this.g = flags;
|
|
1020
1042
|
if (this.s === EFFECT_RENDER) {
|
|
1021
|
-
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.
|
|
1043
|
+
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.g);
|
|
1022
1044
|
}
|
|
1023
1045
|
}
|
|
1024
1046
|
if (value === UNCHANGED)
|
|
1025
|
-
return this.
|
|
1026
|
-
this.
|
|
1027
|
-
this.
|
|
1047
|
+
return this.m;
|
|
1048
|
+
this.m = value;
|
|
1049
|
+
this.ea = true;
|
|
1028
1050
|
this.O = void 0;
|
|
1029
1051
|
return value;
|
|
1030
1052
|
}
|
|
1031
1053
|
u(state, skipQueue) {
|
|
1032
|
-
if (this.
|
|
1054
|
+
if (this.a >= state || skipQueue)
|
|
1033
1055
|
return;
|
|
1034
|
-
if (this.
|
|
1056
|
+
if (this.a === STATE_CLEAN || this.d && !ActiveTransition)
|
|
1035
1057
|
getQueue(this).enqueue(this.s, this.x.bind(this));
|
|
1036
|
-
this.
|
|
1058
|
+
this.a = state;
|
|
1037
1059
|
}
|
|
1038
1060
|
_(mask, newFlags2) {
|
|
1039
1061
|
if (this.d) {
|
|
1040
|
-
if (this.
|
|
1062
|
+
if (this.a >= STATE_DIRTY)
|
|
1041
1063
|
return;
|
|
1042
1064
|
if (mask & 3) {
|
|
1043
1065
|
this.u(STATE_DIRTY);
|
|
@@ -1049,7 +1071,7 @@ var Effect = class extends Computation {
|
|
|
1049
1071
|
N(error) {
|
|
1050
1072
|
this.O = error;
|
|
1051
1073
|
getQueue(this).notify(this, LOADING_BIT, 0);
|
|
1052
|
-
this.
|
|
1074
|
+
this.g = ERROR_BIT;
|
|
1053
1075
|
if (this.s === EFFECT_USER) {
|
|
1054
1076
|
try {
|
|
1055
1077
|
return this.$ ? this.$(error, () => {
|
|
@@ -1064,9 +1086,9 @@ var Effect = class extends Computation {
|
|
|
1064
1086
|
throw error;
|
|
1065
1087
|
}
|
|
1066
1088
|
M() {
|
|
1067
|
-
if (this.
|
|
1089
|
+
if (this.a === STATE_DISPOSED)
|
|
1068
1090
|
return;
|
|
1069
|
-
this.
|
|
1091
|
+
this.da = void 0;
|
|
1070
1092
|
this.T = void 0;
|
|
1071
1093
|
this.$ = void 0;
|
|
1072
1094
|
this.w?.();
|
|
@@ -1077,42 +1099,46 @@ var Effect = class extends Computation {
|
|
|
1077
1099
|
x(type) {
|
|
1078
1100
|
if (type) {
|
|
1079
1101
|
const effect = this.d || this;
|
|
1080
|
-
if (effect.
|
|
1102
|
+
if (effect.ea && effect.a !== STATE_DISPOSED) {
|
|
1081
1103
|
effect.w?.();
|
|
1082
1104
|
try {
|
|
1083
|
-
effect.w = effect.
|
|
1105
|
+
effect.w = effect.da(effect.m, effect.T);
|
|
1084
1106
|
} catch (e) {
|
|
1085
1107
|
if (!getQueue(effect).notify(effect, ERROR_BIT, ERROR_BIT))
|
|
1086
1108
|
throw e;
|
|
1087
1109
|
} finally {
|
|
1088
|
-
effect.T = effect.
|
|
1089
|
-
effect.
|
|
1110
|
+
effect.T = effect.m;
|
|
1111
|
+
effect.ea = false;
|
|
1090
1112
|
}
|
|
1091
1113
|
}
|
|
1092
1114
|
} else
|
|
1093
|
-
this.
|
|
1115
|
+
this.a !== STATE_CLEAN && runTop(this);
|
|
1094
1116
|
}
|
|
1095
1117
|
};
|
|
1096
1118
|
var TrackedEffect = class extends Computation {
|
|
1097
1119
|
s = EFFECT_USER;
|
|
1098
1120
|
w;
|
|
1099
1121
|
constructor(compute2, options) {
|
|
1100
|
-
super(
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1122
|
+
super(
|
|
1123
|
+
void 0,
|
|
1124
|
+
() => {
|
|
1125
|
+
this.w?.();
|
|
1126
|
+
this.w = latest(compute2);
|
|
1127
|
+
return void 0;
|
|
1128
|
+
},
|
|
1129
|
+
options
|
|
1130
|
+
);
|
|
1105
1131
|
getQueue(this).enqueue(this.s, this.x.bind(this));
|
|
1106
1132
|
}
|
|
1107
1133
|
u(state, skipQueue) {
|
|
1108
|
-
if (this.
|
|
1134
|
+
if (this.a >= state || skipQueue)
|
|
1109
1135
|
return;
|
|
1110
|
-
if (this.
|
|
1136
|
+
if (this.a === STATE_CLEAN || this.d && !ActiveTransition)
|
|
1111
1137
|
getQueue(this).enqueue(this.s, this.x.bind(this));
|
|
1112
|
-
this.
|
|
1138
|
+
this.a = state;
|
|
1113
1139
|
}
|
|
1114
1140
|
M() {
|
|
1115
|
-
if (this.
|
|
1141
|
+
if (this.a === STATE_DISPOSED)
|
|
1116
1142
|
return;
|
|
1117
1143
|
this.w?.();
|
|
1118
1144
|
this.w = void 0;
|
|
@@ -1121,7 +1147,7 @@ var TrackedEffect = class extends Computation {
|
|
|
1121
1147
|
}
|
|
1122
1148
|
x(type) {
|
|
1123
1149
|
if (type)
|
|
1124
|
-
this.
|
|
1150
|
+
this.a !== STATE_CLEAN && runTop(this);
|
|
1125
1151
|
}
|
|
1126
1152
|
};
|
|
1127
1153
|
var EagerComputation = class extends Computation {
|
|
@@ -1130,14 +1156,14 @@ var EagerComputation = class extends Computation {
|
|
|
1130
1156
|
!options?.defer && this.F();
|
|
1131
1157
|
}
|
|
1132
1158
|
u(state, skipQueue) {
|
|
1133
|
-
if (this.
|
|
1159
|
+
if (this.a >= state && !this.H)
|
|
1134
1160
|
return;
|
|
1135
|
-
if (!skipQueue && (this.
|
|
1161
|
+
if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.H))
|
|
1136
1162
|
getQueue(this).enqueue(EFFECT_PURE, this.x.bind(this));
|
|
1137
1163
|
super.u(state, skipQueue);
|
|
1138
1164
|
}
|
|
1139
1165
|
x() {
|
|
1140
|
-
this.
|
|
1166
|
+
this.a !== STATE_CLEAN && runTop(this);
|
|
1141
1167
|
}
|
|
1142
1168
|
};
|
|
1143
1169
|
var FirewallComputation = class extends Computation {
|
|
@@ -1146,34 +1172,34 @@ var FirewallComputation = class extends Computation {
|
|
|
1146
1172
|
super(void 0, compute2);
|
|
1147
1173
|
}
|
|
1148
1174
|
u(state, skipQueue) {
|
|
1149
|
-
if (this.
|
|
1175
|
+
if (this.a >= state && !this.H)
|
|
1150
1176
|
return;
|
|
1151
|
-
if (!skipQueue && (this.
|
|
1177
|
+
if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.H))
|
|
1152
1178
|
getQueue(this).enqueue(EFFECT_PURE, this.x.bind(this));
|
|
1153
1179
|
super.u(state, true);
|
|
1154
1180
|
this.H = !!skipQueue;
|
|
1155
1181
|
}
|
|
1156
1182
|
x() {
|
|
1157
|
-
const prevFlags = this.
|
|
1158
|
-
this.
|
|
1159
|
-
if (ActiveTransition && this.
|
|
1160
|
-
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.
|
|
1161
|
-
this.
|
|
1162
|
-
this.
|
|
1183
|
+
const prevFlags = this.g;
|
|
1184
|
+
this.a !== STATE_CLEAN && runTop(this);
|
|
1185
|
+
if (ActiveTransition && this.j && (this.g !== prevFlags || this.g !== this.j.flags)) {
|
|
1186
|
+
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.g);
|
|
1187
|
+
this.j.flags = this.g;
|
|
1188
|
+
this.g = prevFlags;
|
|
1163
1189
|
}
|
|
1164
1190
|
}
|
|
1165
1191
|
};
|
|
1166
1192
|
function runTop(node) {
|
|
1167
1193
|
const ancestors = [];
|
|
1168
|
-
for (let current = node; current !== null; current = current.
|
|
1169
|
-
if (ActiveTransition && current.
|
|
1170
|
-
current = ActiveTransition.
|
|
1171
|
-
if (current.
|
|
1194
|
+
for (let current = node; current !== null; current = current.l) {
|
|
1195
|
+
if (ActiveTransition && current.f)
|
|
1196
|
+
current = ActiveTransition.b.get(current);
|
|
1197
|
+
if (current.a !== STATE_CLEAN) {
|
|
1172
1198
|
ancestors.push(current);
|
|
1173
1199
|
}
|
|
1174
1200
|
}
|
|
1175
1201
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
1176
|
-
if (ancestors[i].
|
|
1202
|
+
if (ancestors[i].a !== STATE_DISPOSED)
|
|
1177
1203
|
ancestors[i].F();
|
|
1178
1204
|
}
|
|
1179
1205
|
}
|
|
@@ -1182,10 +1208,13 @@ function runTop(node) {
|
|
|
1182
1208
|
function createSignal(first, second, third) {
|
|
1183
1209
|
if (typeof first === "function") {
|
|
1184
1210
|
const node2 = new Computation(second, first, third);
|
|
1185
|
-
return [
|
|
1186
|
-
node2.
|
|
1187
|
-
|
|
1188
|
-
|
|
1211
|
+
return [
|
|
1212
|
+
node2.wait.bind(node2),
|
|
1213
|
+
(v) => {
|
|
1214
|
+
node2.F();
|
|
1215
|
+
return node2.write(v);
|
|
1216
|
+
}
|
|
1217
|
+
];
|
|
1189
1218
|
}
|
|
1190
1219
|
const o = getOwner();
|
|
1191
1220
|
const needsId = o?.id != null;
|
|
@@ -1205,12 +1234,12 @@ function createMemo(compute2, value, options) {
|
|
|
1205
1234
|
let resolvedValue;
|
|
1206
1235
|
return () => {
|
|
1207
1236
|
if (node) {
|
|
1208
|
-
if (node.
|
|
1237
|
+
if (node.a === STATE_DISPOSED) {
|
|
1209
1238
|
node = void 0;
|
|
1210
1239
|
return resolvedValue;
|
|
1211
1240
|
}
|
|
1212
1241
|
resolvedValue = node.wait();
|
|
1213
|
-
if (!node.
|
|
1242
|
+
if (!node.b?.length && node.n?.l !== node && !(node.g & UNINITIALIZED_BIT)) {
|
|
1214
1243
|
node.dispose();
|
|
1215
1244
|
node = void 0;
|
|
1216
1245
|
}
|
|
@@ -1277,7 +1306,7 @@ function createAsync(compute2, value, options) {
|
|
|
1277
1306
|
}
|
|
1278
1307
|
})();
|
|
1279
1308
|
}
|
|
1280
|
-
throw new NotReadyError();
|
|
1309
|
+
throw new NotReadyError(getOwner());
|
|
1281
1310
|
},
|
|
1282
1311
|
options
|
|
1283
1312
|
);
|
|
@@ -1287,7 +1316,7 @@ function createAsync(compute2, value, options) {
|
|
|
1287
1316
|
if (ActiveTransition && !node.d) {
|
|
1288
1317
|
n = cloneGraph(node);
|
|
1289
1318
|
}
|
|
1290
|
-
n.
|
|
1319
|
+
n.a = STATE_DIRTY;
|
|
1291
1320
|
refreshing = true;
|
|
1292
1321
|
n.F();
|
|
1293
1322
|
};
|
|
@@ -1355,25 +1384,34 @@ function resolve(fn) {
|
|
|
1355
1384
|
});
|
|
1356
1385
|
}
|
|
1357
1386
|
function createOptimistic(first, second, third) {
|
|
1358
|
-
const node = typeof first === "function" ? new Computation(
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1387
|
+
const node = typeof first === "function" ? new Computation(
|
|
1388
|
+
second,
|
|
1389
|
+
(prev) => {
|
|
1390
|
+
if (node.j.f) {
|
|
1391
|
+
latest(() => first(prev));
|
|
1392
|
+
return prev;
|
|
1393
|
+
}
|
|
1394
|
+
return first(prev);
|
|
1395
|
+
},
|
|
1396
|
+
third
|
|
1397
|
+
) : new Computation(first, null, second);
|
|
1398
|
+
node.j = () => node.write(first);
|
|
1365
1399
|
function write(v) {
|
|
1366
1400
|
if (!ActiveTransition)
|
|
1367
1401
|
throw new Error("createOptimistic can only be updated inside a transition");
|
|
1368
|
-
ActiveTransition.addOptimistic(node.
|
|
1402
|
+
ActiveTransition.addOptimistic(node.j);
|
|
1369
1403
|
queueMicrotask(() => {
|
|
1370
|
-
if (node.
|
|
1404
|
+
if (node.j.f) {
|
|
1371
1405
|
node.F();
|
|
1372
1406
|
node.write(v);
|
|
1373
1407
|
}
|
|
1374
1408
|
});
|
|
1375
1409
|
}
|
|
1376
|
-
return [node.
|
|
1410
|
+
return [node.wait.bind(node), write];
|
|
1411
|
+
}
|
|
1412
|
+
function transition(fn) {
|
|
1413
|
+
let t = new Transition(new Computation(void 0, null));
|
|
1414
|
+
queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
|
|
1377
1415
|
}
|
|
1378
1416
|
function useTransition() {
|
|
1379
1417
|
const [pending, setPending] = createOptimistic(false);
|
|
@@ -1653,7 +1691,7 @@ var storeTraps = {
|
|
|
1653
1691
|
return desc.get.call(receiver);
|
|
1654
1692
|
}
|
|
1655
1693
|
if (Writing?.has(receiver)) {
|
|
1656
|
-
let value2 = tracked && (overridden || !proxySource) ? tracked.
|
|
1694
|
+
let value2 = tracked && (overridden || !proxySource) ? tracked.m : storeValue[property];
|
|
1657
1695
|
value2 === $DELETED && (value2 = void 0);
|
|
1658
1696
|
if (!isWrappable(value2))
|
|
1659
1697
|
return value2;
|
|
@@ -1844,28 +1882,29 @@ function deep(store) {
|
|
|
1844
1882
|
// src/store/optimistic.ts
|
|
1845
1883
|
function createOptimisticStore(first, second, options) {
|
|
1846
1884
|
const derived = typeof first === "function";
|
|
1847
|
-
const { store, node } = derived ? createProjectionInternal(
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1885
|
+
const { store, node } = derived ? createProjectionInternal(
|
|
1886
|
+
(draft) => {
|
|
1887
|
+
if (reset.f) {
|
|
1888
|
+
latest(() => first(draft));
|
|
1889
|
+
return draft;
|
|
1890
|
+
}
|
|
1891
|
+
return first(draft);
|
|
1892
|
+
},
|
|
1893
|
+
second,
|
|
1894
|
+
options
|
|
1895
|
+
) : createProjectionInternal(() => {
|
|
1853
1896
|
}, first);
|
|
1854
1897
|
const reset = () => storeSetter(
|
|
1855
1898
|
store,
|
|
1856
|
-
reconcile(
|
|
1857
|
-
derived ? first(store) || store : first,
|
|
1858
|
-
options?.key || "id",
|
|
1859
|
-
options?.all
|
|
1860
|
-
)
|
|
1899
|
+
reconcile(derived ? first(store) || store : first, options?.key || "id", options?.all)
|
|
1861
1900
|
);
|
|
1862
1901
|
const write = (v) => {
|
|
1863
1902
|
if (!ActiveTransition)
|
|
1864
1903
|
throw new Error("createOptimisticStore can only be updated inside a transition");
|
|
1865
1904
|
ActiveTransition.addOptimistic(reset);
|
|
1866
|
-
queueMicrotask(() => reset.
|
|
1905
|
+
queueMicrotask(() => reset.f && storeSetter(store, v));
|
|
1867
1906
|
};
|
|
1868
|
-
node.
|
|
1907
|
+
node.j = reset;
|
|
1869
1908
|
return [store, write];
|
|
1870
1909
|
}
|
|
1871
1910
|
|
|
@@ -2075,10 +2114,10 @@ function mapArray(list, map, options) {
|
|
|
2075
2114
|
return updateKeyedMap.bind({
|
|
2076
2115
|
U: new Owner(),
|
|
2077
2116
|
p: 0,
|
|
2078
|
-
|
|
2117
|
+
ka: list,
|
|
2079
2118
|
I: [],
|
|
2080
2119
|
R: map,
|
|
2081
|
-
|
|
2120
|
+
k: [],
|
|
2082
2121
|
e: [],
|
|
2083
2122
|
S: keyFn,
|
|
2084
2123
|
q: keyFn || options?.keyed === false ? [] : void 0,
|
|
@@ -2088,7 +2127,7 @@ function mapArray(list, map, options) {
|
|
|
2088
2127
|
}
|
|
2089
2128
|
var pureOptions = { pureWrite: true };
|
|
2090
2129
|
function updateKeyedMap() {
|
|
2091
|
-
const newItems = this.
|
|
2130
|
+
const newItems = this.ka() || [], newLen = newItems.length;
|
|
2092
2131
|
newItems[$TRACK];
|
|
2093
2132
|
runWithOwner(this.U, () => {
|
|
2094
2133
|
let i, j, mapper = this.q ? () => {
|
|
@@ -2111,13 +2150,13 @@ function updateKeyedMap() {
|
|
|
2111
2150
|
this.U.dispose(false);
|
|
2112
2151
|
this.e = [];
|
|
2113
2152
|
this.I = [];
|
|
2114
|
-
this.
|
|
2153
|
+
this.k = [];
|
|
2115
2154
|
this.p = 0;
|
|
2116
2155
|
this.q && (this.q = []);
|
|
2117
2156
|
this.r && (this.r = []);
|
|
2118
2157
|
}
|
|
2119
|
-
if (this.V && !this.
|
|
2120
|
-
this.
|
|
2158
|
+
if (this.V && !this.k[0]) {
|
|
2159
|
+
this.k[0] = compute(
|
|
2121
2160
|
this.e[0] = new Owner(),
|
|
2122
2161
|
this.V,
|
|
2123
2162
|
null
|
|
@@ -2126,10 +2165,10 @@ function updateKeyedMap() {
|
|
|
2126
2165
|
} else if (this.p === 0) {
|
|
2127
2166
|
if (this.e[0])
|
|
2128
2167
|
this.e[0].dispose();
|
|
2129
|
-
this.
|
|
2168
|
+
this.k = new Array(newLen);
|
|
2130
2169
|
for (j = 0; j < newLen; j++) {
|
|
2131
2170
|
this.I[j] = newItems[j];
|
|
2132
|
-
this.
|
|
2171
|
+
this.k[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2133
2172
|
}
|
|
2134
2173
|
this.p = newLen;
|
|
2135
2174
|
} else {
|
|
@@ -2139,7 +2178,7 @@ function updateKeyedMap() {
|
|
|
2139
2178
|
this.q[start].write(newItems[start]);
|
|
2140
2179
|
}
|
|
2141
2180
|
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--) {
|
|
2142
|
-
temp[newEnd] = this.
|
|
2181
|
+
temp[newEnd] = this.k[end];
|
|
2143
2182
|
tempNodes[newEnd] = this.e[end];
|
|
2144
2183
|
tempRows && (tempRows[newEnd] = this.q[end]);
|
|
2145
2184
|
tempIndexes && (tempIndexes[newEnd] = this.r[end]);
|
|
@@ -2158,7 +2197,7 @@ function updateKeyedMap() {
|
|
|
2158
2197
|
key = this.S ? this.S(item) : item;
|
|
2159
2198
|
j = newIndices.get(key);
|
|
2160
2199
|
if (j !== void 0 && j !== -1) {
|
|
2161
|
-
temp[j] = this.
|
|
2200
|
+
temp[j] = this.k[i];
|
|
2162
2201
|
tempNodes[j] = this.e[i];
|
|
2163
2202
|
tempRows && (tempRows[j] = this.q[i]);
|
|
2164
2203
|
tempIndexes && (tempIndexes[j] = this.r[i]);
|
|
@@ -2169,7 +2208,7 @@ function updateKeyedMap() {
|
|
|
2169
2208
|
}
|
|
2170
2209
|
for (j = start; j < newLen; j++) {
|
|
2171
2210
|
if (j in temp) {
|
|
2172
|
-
this.
|
|
2211
|
+
this.k[j] = temp[j];
|
|
2173
2212
|
this.e[j] = tempNodes[j];
|
|
2174
2213
|
if (tempRows) {
|
|
2175
2214
|
this.q[j] = tempRows[j];
|
|
@@ -2180,41 +2219,41 @@ function updateKeyedMap() {
|
|
|
2180
2219
|
this.r[j].write(j);
|
|
2181
2220
|
}
|
|
2182
2221
|
} else {
|
|
2183
|
-
this.
|
|
2222
|
+
this.k[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2184
2223
|
}
|
|
2185
2224
|
}
|
|
2186
|
-
this.
|
|
2225
|
+
this.k = this.k.slice(0, this.p = newLen);
|
|
2187
2226
|
this.I = newItems.slice(0);
|
|
2188
2227
|
}
|
|
2189
2228
|
});
|
|
2190
|
-
return this.
|
|
2229
|
+
return this.k;
|
|
2191
2230
|
}
|
|
2192
2231
|
function repeat(count, map, options) {
|
|
2193
2232
|
return updateRepeat.bind({
|
|
2194
2233
|
U: new Owner(),
|
|
2195
2234
|
p: 0,
|
|
2196
2235
|
B: 0,
|
|
2197
|
-
|
|
2236
|
+
la: count,
|
|
2198
2237
|
R: map,
|
|
2199
2238
|
e: [],
|
|
2200
|
-
|
|
2201
|
-
|
|
2239
|
+
k: [],
|
|
2240
|
+
ma: options?.from,
|
|
2202
2241
|
V: options?.fallback
|
|
2203
2242
|
});
|
|
2204
2243
|
}
|
|
2205
2244
|
function updateRepeat() {
|
|
2206
|
-
const newLen = this.
|
|
2207
|
-
const from = this.
|
|
2245
|
+
const newLen = this.la();
|
|
2246
|
+
const from = this.ma?.() || 0;
|
|
2208
2247
|
runWithOwner(this.U, () => {
|
|
2209
2248
|
if (newLen === 0) {
|
|
2210
2249
|
if (this.p !== 0) {
|
|
2211
2250
|
this.U.dispose(false);
|
|
2212
2251
|
this.e = [];
|
|
2213
|
-
this.
|
|
2252
|
+
this.k = [];
|
|
2214
2253
|
this.p = 0;
|
|
2215
2254
|
}
|
|
2216
|
-
if (this.V && !this.
|
|
2217
|
-
this.
|
|
2255
|
+
if (this.V && !this.k[0]) {
|
|
2256
|
+
this.k[0] = compute(
|
|
2218
2257
|
this.e[0] = new Owner(),
|
|
2219
2258
|
this.V,
|
|
2220
2259
|
null
|
|
@@ -2233,18 +2272,18 @@ function updateRepeat() {
|
|
|
2233
2272
|
while (i < from && i < this.p)
|
|
2234
2273
|
this.e[i++].dispose();
|
|
2235
2274
|
this.e.splice(0, from - this.B);
|
|
2236
|
-
this.
|
|
2275
|
+
this.k.splice(0, from - this.B);
|
|
2237
2276
|
} else if (this.B > from) {
|
|
2238
2277
|
let i = prevTo - this.B - 1;
|
|
2239
2278
|
let difference = this.B - from;
|
|
2240
|
-
this.e.length = this.
|
|
2279
|
+
this.e.length = this.k.length = newLen;
|
|
2241
2280
|
while (i >= difference) {
|
|
2242
2281
|
this.e[i] = this.e[i - difference];
|
|
2243
|
-
this.
|
|
2282
|
+
this.k[i] = this.k[i - difference];
|
|
2244
2283
|
i--;
|
|
2245
2284
|
}
|
|
2246
2285
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
2247
|
-
this.
|
|
2286
|
+
this.k[i2] = compute(
|
|
2248
2287
|
this.e[i2] = new Owner(),
|
|
2249
2288
|
() => this.R(i2 + from),
|
|
2250
2289
|
null
|
|
@@ -2252,17 +2291,17 @@ function updateRepeat() {
|
|
|
2252
2291
|
}
|
|
2253
2292
|
}
|
|
2254
2293
|
for (let i = prevTo; i < to; i++) {
|
|
2255
|
-
this.
|
|
2294
|
+
this.k[i - from] = compute(
|
|
2256
2295
|
this.e[i - from] = new Owner(),
|
|
2257
2296
|
() => this.R(i),
|
|
2258
2297
|
null
|
|
2259
2298
|
);
|
|
2260
2299
|
}
|
|
2261
|
-
this.
|
|
2300
|
+
this.k = this.k.slice(0, newLen);
|
|
2262
2301
|
this.B = from;
|
|
2263
2302
|
this.p = newLen;
|
|
2264
2303
|
});
|
|
2265
|
-
return this.
|
|
2304
|
+
return this.k;
|
|
2266
2305
|
}
|
|
2267
2306
|
function compare(key, a, b) {
|
|
2268
2307
|
return key ? key(a) === key(b) : true;
|
|
@@ -2277,11 +2316,11 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2277
2316
|
}
|
|
2278
2317
|
write(value, flags) {
|
|
2279
2318
|
super.write(value, flags & ~this.W);
|
|
2280
|
-
if (this.W & LOADING_BIT && !(this.
|
|
2319
|
+
if (this.W & LOADING_BIT && !(this.g & UNINITIALIZED_BIT || ActiveTransition)) {
|
|
2281
2320
|
flags &= ~LOADING_BIT;
|
|
2282
2321
|
}
|
|
2283
2322
|
getQueue(this).notify(this, this.W, flags);
|
|
2284
|
-
return this.
|
|
2323
|
+
return this.m;
|
|
2285
2324
|
}
|
|
2286
2325
|
};
|
|
2287
2326
|
function createBoundChildren(owner, fn, queue, mask) {
|
|
@@ -2292,7 +2331,7 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
2292
2331
|
owner,
|
|
2293
2332
|
() => {
|
|
2294
2333
|
const c = new Computation(void 0, fn);
|
|
2295
|
-
return new BoundaryComputation(() => flatten(c.wait()), mask);
|
|
2334
|
+
return new BoundaryComputation(() => latest(() => flatten(c.wait())), mask);
|
|
2296
2335
|
},
|
|
2297
2336
|
null
|
|
2298
2337
|
);
|
|
@@ -2411,7 +2450,7 @@ function createErrorBoundary(fn, fallback) {
|
|
|
2411
2450
|
for (let node2 of queue.e) {
|
|
2412
2451
|
if (ActiveTransition && !node2.d)
|
|
2413
2452
|
node2 = cloneGraph(node2);
|
|
2414
|
-
node2.
|
|
2453
|
+
node2.a = STATE_DIRTY;
|
|
2415
2454
|
getQueue(node2).enqueue(node2.s, node2.x.bind(node2));
|
|
2416
2455
|
}
|
|
2417
2456
|
});
|