@solidjs/signals 0.7.1 → 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 +40 -24
- package/dist/node.cjs +337 -321
- package/dist/prod.js +337 -321
- package/dist/types/core/core.d.ts +3 -1
- package/dist/types/core/scheduler.d.ts +1 -1
- package/package.json +1 -1
package/dist/node.cjs
CHANGED
|
@@ -47,7 +47,7 @@ function schedule() {
|
|
|
47
47
|
if (scheduled)
|
|
48
48
|
return;
|
|
49
49
|
scheduled = true;
|
|
50
|
-
if (!globalQueue.
|
|
50
|
+
if (!globalQueue.C)
|
|
51
51
|
queueMicrotask(flush);
|
|
52
52
|
}
|
|
53
53
|
function notifyUnobserved() {
|
|
@@ -62,9 +62,9 @@ function notifyUnobserved() {
|
|
|
62
62
|
var pureQueue = [];
|
|
63
63
|
var Queue = class {
|
|
64
64
|
k = null;
|
|
65
|
-
|
|
65
|
+
C = false;
|
|
66
66
|
g = [[], []];
|
|
67
|
-
|
|
67
|
+
h = [];
|
|
68
68
|
created = clock;
|
|
69
69
|
enqueue(type, fn) {
|
|
70
70
|
pureQueue.push(fn);
|
|
@@ -82,14 +82,14 @@ var Queue = class {
|
|
|
82
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() {
|
|
90
|
-
if (this.
|
|
90
|
+
if (this.C)
|
|
91
91
|
return;
|
|
92
|
-
this.
|
|
92
|
+
this.C = true;
|
|
93
93
|
try {
|
|
94
94
|
this.run(EFFECT_PURE);
|
|
95
95
|
incrementClock();
|
|
@@ -97,22 +97,22 @@ var Queue = class {
|
|
|
97
97
|
this.run(EFFECT_RENDER);
|
|
98
98
|
this.run(EFFECT_USER);
|
|
99
99
|
} finally {
|
|
100
|
-
this.
|
|
100
|
+
this.C = false;
|
|
101
101
|
Unobserved.length && notifyUnobserved();
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
addChild(child) {
|
|
105
|
-
if (ActiveTransition && ActiveTransition.
|
|
106
|
-
return ActiveTransition.
|
|
107
|
-
this.
|
|
105
|
+
if (ActiveTransition && ActiveTransition.J.has(this))
|
|
106
|
+
return ActiveTransition.J.get(this).addChild(child);
|
|
107
|
+
this.h.push(child);
|
|
108
108
|
child.k = this;
|
|
109
109
|
}
|
|
110
110
|
removeChild(child) {
|
|
111
|
-
if (ActiveTransition && ActiveTransition.
|
|
112
|
-
return ActiveTransition.
|
|
113
|
-
const index = this.
|
|
111
|
+
if (ActiveTransition && ActiveTransition.J.has(this))
|
|
112
|
+
return ActiveTransition.J.get(this).removeChild(child);
|
|
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
|
}
|
|
@@ -124,12 +124,12 @@ var Queue = class {
|
|
|
124
124
|
merge(queue) {
|
|
125
125
|
this.g[0].push.apply(this.g[0], queue.g[0]);
|
|
126
126
|
this.g[1].push.apply(this.g[1], queue.g[1]);
|
|
127
|
-
for (let i = 0; i < queue.
|
|
128
|
-
const og = this.
|
|
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
|
};
|
|
@@ -160,49 +160,49 @@ function runQueue(queue, type) {
|
|
|
160
160
|
}
|
|
161
161
|
var Transition = class _Transition {
|
|
162
162
|
a = /* @__PURE__ */ new Map();
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
t = /* @__PURE__ */ new Set();
|
|
164
|
+
K = /* @__PURE__ */ new Set();
|
|
165
|
+
m = /* @__PURE__ */ new Set();
|
|
166
|
+
D = false;
|
|
167
167
|
g = [[], []];
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
J = /* @__PURE__ */ new Map();
|
|
169
|
+
G = [];
|
|
170
|
+
h = [];
|
|
171
171
|
k = null;
|
|
172
|
-
|
|
172
|
+
C = false;
|
|
173
173
|
Y = false;
|
|
174
174
|
d = globalQueue;
|
|
175
175
|
created = clock;
|
|
176
176
|
constructor() {
|
|
177
|
-
this.
|
|
178
|
-
for (const child of globalQueue.
|
|
177
|
+
this.J.set(globalQueue, this);
|
|
178
|
+
for (const child of globalQueue.h) {
|
|
179
179
|
cloneQueue(child, this, this);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
enqueue(type, fn) {
|
|
183
|
-
this.
|
|
183
|
+
this.G.push(fn);
|
|
184
184
|
if (type)
|
|
185
185
|
this.g[type - 1].push(fn);
|
|
186
186
|
this.schedule();
|
|
187
187
|
}
|
|
188
188
|
run(type) {
|
|
189
189
|
if (type === EFFECT_PURE) {
|
|
190
|
-
this.
|
|
191
|
-
this.
|
|
190
|
+
this.G.length && runQueue(this.G, type);
|
|
191
|
+
this.G = [];
|
|
192
192
|
return;
|
|
193
193
|
} else if (this.g[type - 1].length) {
|
|
194
194
|
const effects = this.g[type - 1];
|
|
195
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() {
|
|
203
|
-
if (this.
|
|
203
|
+
if (this.C || this.D)
|
|
204
204
|
return;
|
|
205
|
-
this.
|
|
205
|
+
this.C = true;
|
|
206
206
|
let currentTransition = ActiveTransition;
|
|
207
207
|
ActiveTransition = this;
|
|
208
208
|
try {
|
|
@@ -212,52 +212,55 @@ var Transition = class _Transition {
|
|
|
212
212
|
ActiveTransition = currentTransition;
|
|
213
213
|
finishTransition(this);
|
|
214
214
|
} finally {
|
|
215
|
-
this.
|
|
215
|
+
this.C = false;
|
|
216
216
|
ActiveTransition = currentTransition;
|
|
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))
|
|
230
230
|
return false;
|
|
231
231
|
if (flags & LOADING_BIT) {
|
|
232
|
-
this.
|
|
232
|
+
this.t.add(node);
|
|
233
233
|
} else {
|
|
234
|
-
this.
|
|
234
|
+
this.t.delete(node);
|
|
235
235
|
}
|
|
236
236
|
return true;
|
|
237
237
|
}
|
|
238
238
|
merge(queue) {
|
|
239
239
|
this.g[0].push.apply(this.g[0], queue.g[0]);
|
|
240
240
|
this.g[1].push.apply(this.g[1], queue.g[1]);
|
|
241
|
-
this.
|
|
242
|
-
|
|
243
|
-
|
|
241
|
+
this.G.push.apply(this.G, queue.G);
|
|
242
|
+
queue.g[0].length = 0;
|
|
243
|
+
queue.g[1].length = 0;
|
|
244
|
+
queue.G.length = 0;
|
|
245
|
+
for (let i = 0; i < queue.h.length; i++) {
|
|
246
|
+
const og = this.h.find((c) => c.d === queue.h[i].d);
|
|
244
247
|
if (og)
|
|
245
|
-
og.merge(queue.
|
|
248
|
+
og.merge(queue.h[i]);
|
|
246
249
|
else
|
|
247
|
-
this.addChild(queue.
|
|
250
|
+
this.addChild(queue.h[i]);
|
|
248
251
|
}
|
|
249
252
|
}
|
|
250
253
|
schedule() {
|
|
251
254
|
if (this.Y)
|
|
252
255
|
return;
|
|
253
256
|
this.Y = true;
|
|
254
|
-
if (!this.
|
|
257
|
+
if (!this.C)
|
|
255
258
|
queueMicrotask(() => this.flush());
|
|
256
259
|
}
|
|
257
260
|
runTransition(fn, force = false) {
|
|
258
|
-
if (this.
|
|
259
|
-
if (this.
|
|
260
|
-
return this.
|
|
261
|
+
if (this.D) {
|
|
262
|
+
if (this.D instanceof _Transition)
|
|
263
|
+
return this.D.runTransition(fn, force);
|
|
261
264
|
if (!force)
|
|
262
265
|
throw new Error("Transition already completed");
|
|
263
266
|
fn();
|
|
@@ -271,13 +274,14 @@ var Transition = class _Transition {
|
|
|
271
274
|
(async function() {
|
|
272
275
|
let temp, value;
|
|
273
276
|
while (!(temp = result.next(value)).done) {
|
|
277
|
+
transition2 = ActiveTransition;
|
|
274
278
|
if (temp.value instanceof Promise) {
|
|
275
|
-
transition2.
|
|
279
|
+
transition2.K.add(temp.value);
|
|
276
280
|
try {
|
|
277
281
|
value = await temp.value;
|
|
278
282
|
} finally {
|
|
279
283
|
transition2 = latestTransition(transition2);
|
|
280
|
-
transition2.
|
|
284
|
+
transition2.K.delete(temp.value);
|
|
281
285
|
}
|
|
282
286
|
ActiveTransition = transition2;
|
|
283
287
|
} else
|
|
@@ -288,10 +292,10 @@ var Transition = class _Transition {
|
|
|
288
292
|
})();
|
|
289
293
|
}
|
|
290
294
|
if (result instanceof Promise) {
|
|
291
|
-
transition2.
|
|
295
|
+
transition2.K.add(result);
|
|
292
296
|
result.finally(() => {
|
|
293
297
|
transition2 = latestTransition(transition2);
|
|
294
|
-
transition2.
|
|
298
|
+
transition2.K.delete(result);
|
|
295
299
|
ActiveTransition = null;
|
|
296
300
|
finishTransition(transition2);
|
|
297
301
|
});
|
|
@@ -309,14 +313,18 @@ var Transition = class _Transition {
|
|
|
309
313
|
return;
|
|
310
314
|
}
|
|
311
315
|
fn.j = this;
|
|
312
|
-
this.
|
|
316
|
+
this.m.add(fn);
|
|
313
317
|
}
|
|
314
318
|
};
|
|
315
319
|
function transition(fn) {
|
|
316
320
|
let t = new Transition();
|
|
317
321
|
queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
|
|
318
322
|
}
|
|
319
|
-
function cloneGraph(node
|
|
323
|
+
function cloneGraph(node) {
|
|
324
|
+
if (node.m) {
|
|
325
|
+
ActiveTransition.addOptimistic(node.m);
|
|
326
|
+
return node;
|
|
327
|
+
}
|
|
320
328
|
if (node.j) {
|
|
321
329
|
if (node.j !== ActiveTransition) {
|
|
322
330
|
mergeTransitions(node.j, ActiveTransition);
|
|
@@ -326,31 +334,30 @@ function cloneGraph(node, optimistic) {
|
|
|
326
334
|
}
|
|
327
335
|
const clone = Object.create(Object.getPrototypeOf(node));
|
|
328
336
|
Object.assign(clone, node, {
|
|
337
|
+
o: null,
|
|
329
338
|
n: null,
|
|
330
|
-
m: null,
|
|
331
339
|
c: null,
|
|
332
340
|
a: node.a ? [...node.a] : null,
|
|
333
|
-
d: node
|
|
334
|
-
J: !!optimistic
|
|
341
|
+
d: node
|
|
335
342
|
});
|
|
336
343
|
delete clone.T;
|
|
337
344
|
ActiveTransition.a.set(node, clone);
|
|
338
345
|
node.j = ActiveTransition;
|
|
339
|
-
if (
|
|
346
|
+
if (node.a) {
|
|
340
347
|
for (let i = 0; i < node.a.length; i++)
|
|
341
348
|
node.a[i].c.push(clone);
|
|
342
349
|
}
|
|
343
350
|
if (node.c) {
|
|
344
351
|
clone.c = [];
|
|
345
352
|
for (let i = 0, length = node.c.length; i < length; i++) {
|
|
346
|
-
!node.c[i].d && clone.c.push(cloneGraph(node.c[i]
|
|
353
|
+
!node.c[i].d && clone.c.push(cloneGraph(node.c[i]));
|
|
347
354
|
}
|
|
348
355
|
}
|
|
349
356
|
return clone;
|
|
350
357
|
}
|
|
351
358
|
function latestTransition(t) {
|
|
352
|
-
while (t.
|
|
353
|
-
t = t.
|
|
359
|
+
while (t.D instanceof Transition)
|
|
360
|
+
t = t.D;
|
|
354
361
|
return t;
|
|
355
362
|
}
|
|
356
363
|
function replaceSourceObservers(node, transition2) {
|
|
@@ -371,7 +378,7 @@ function cloneQueue(queue, parent, transition2) {
|
|
|
371
378
|
Object.assign(clone, queue, {
|
|
372
379
|
d: queue,
|
|
373
380
|
k: parent,
|
|
374
|
-
|
|
381
|
+
h: [],
|
|
375
382
|
enqueue(type, fn) {
|
|
376
383
|
transition2 = latestTransition(transition2);
|
|
377
384
|
transition2.enqueue(type, fn);
|
|
@@ -388,9 +395,9 @@ function cloneQueue(queue, parent, transition2) {
|
|
|
388
395
|
return queue.notify.call(this, node, type, flags);
|
|
389
396
|
}
|
|
390
397
|
});
|
|
391
|
-
parent.
|
|
392
|
-
transition2.
|
|
393
|
-
for (const child of queue.
|
|
398
|
+
parent.h.push(clone);
|
|
399
|
+
transition2.J.set(queue, clone);
|
|
400
|
+
for (const child of queue.h) {
|
|
394
401
|
cloneQueue(child, clone, transition2);
|
|
395
402
|
}
|
|
396
403
|
}
|
|
@@ -398,11 +405,11 @@ function resolveQueues(children) {
|
|
|
398
405
|
for (const child of children) {
|
|
399
406
|
const og = child.d;
|
|
400
407
|
if (og) {
|
|
401
|
-
const clonedChildren = child.
|
|
408
|
+
const clonedChildren = child.h;
|
|
402
409
|
delete child.enqueue;
|
|
403
410
|
delete child.notify;
|
|
404
411
|
delete child.k;
|
|
405
|
-
delete child.
|
|
412
|
+
delete child.h;
|
|
406
413
|
Object.assign(og, child);
|
|
407
414
|
delete og.d;
|
|
408
415
|
resolveQueues(clonedChildren);
|
|
@@ -416,14 +423,14 @@ function mergeTransitions(t1, t2) {
|
|
|
416
423
|
key.j = t1;
|
|
417
424
|
t1.a.set(key, value);
|
|
418
425
|
});
|
|
419
|
-
t2.
|
|
426
|
+
t2.m.forEach((c) => {
|
|
420
427
|
c.j = t1;
|
|
421
|
-
t1.
|
|
428
|
+
t1.m.add(c);
|
|
422
429
|
});
|
|
423
|
-
t2.
|
|
424
|
-
t2.
|
|
430
|
+
t2.K.forEach((p) => t1.K.add(p));
|
|
431
|
+
t2.t.forEach((n) => t1.t.add(n));
|
|
425
432
|
t1.merge(t2);
|
|
426
|
-
t2.
|
|
433
|
+
t2.D = t1;
|
|
427
434
|
}
|
|
428
435
|
function getTransitionSource(input) {
|
|
429
436
|
return ActiveTransition && ActiveTransition.a.get(input) || input;
|
|
@@ -431,24 +438,24 @@ function getTransitionSource(input) {
|
|
|
431
438
|
function getQueue(node) {
|
|
432
439
|
var _a;
|
|
433
440
|
const transition2 = ActiveTransition || ((_a = node.d) == null ? void 0 : _a.j);
|
|
434
|
-
return transition2 && transition2.
|
|
441
|
+
return transition2 && transition2.J.get(node.E) || node.E;
|
|
435
442
|
}
|
|
436
443
|
function initialDispose(node) {
|
|
437
|
-
let current = node.
|
|
444
|
+
let current = node.n;
|
|
438
445
|
while (current !== null && current.k === node) {
|
|
439
446
|
initialDispose(current);
|
|
440
447
|
const clone = ActiveTransition.a.get(current);
|
|
441
448
|
if (clone && !clone.Z)
|
|
442
449
|
clone.dispose(true);
|
|
443
|
-
current = current.
|
|
450
|
+
current = current.n;
|
|
444
451
|
}
|
|
445
452
|
}
|
|
446
453
|
function finishTransition(transition2) {
|
|
447
|
-
if (transition2.
|
|
454
|
+
if (transition2.D || transition2.Y || transition2.K.size || transition2.t.size)
|
|
448
455
|
return;
|
|
449
456
|
globalQueue.g[0].push.apply(globalQueue.g[0], transition2.g[0]);
|
|
450
457
|
globalQueue.g[1].push.apply(globalQueue.g[1], transition2.g[1]);
|
|
451
|
-
resolveQueues(transition2.
|
|
458
|
+
resolveQueues(transition2.h);
|
|
452
459
|
for (const [source, clone] of transition2.a) {
|
|
453
460
|
if (source === clone || source.j !== transition2) {
|
|
454
461
|
delete source.j;
|
|
@@ -456,33 +463,27 @@ function finishTransition(transition2) {
|
|
|
456
463
|
}
|
|
457
464
|
if (clone.a)
|
|
458
465
|
replaceSourceObservers(clone, transition2);
|
|
459
|
-
if (clone.J) {
|
|
460
|
-
clone.dispose();
|
|
461
|
-
clone.emptyDisposal();
|
|
462
|
-
delete source.j;
|
|
463
|
-
continue;
|
|
464
|
-
}
|
|
465
466
|
if (clone.Z || clone.b === STATE_DISPOSED) {
|
|
466
467
|
source.dispose(clone.b === STATE_DISPOSED);
|
|
467
468
|
source.emptyDisposal();
|
|
468
469
|
delete clone.Z;
|
|
469
470
|
} else {
|
|
470
|
-
delete clone.m;
|
|
471
471
|
delete clone.n;
|
|
472
|
+
delete clone.o;
|
|
472
473
|
}
|
|
473
474
|
Object.assign(source, clone);
|
|
474
475
|
delete source.d;
|
|
475
|
-
let current = clone.
|
|
476
|
-
if ((current == null ? void 0 : current.
|
|
477
|
-
current.
|
|
476
|
+
let current = clone.n;
|
|
477
|
+
if ((current == null ? void 0 : current.z) === clone)
|
|
478
|
+
current.z = source;
|
|
478
479
|
while ((current == null ? void 0 : current.k) === clone) {
|
|
479
480
|
current.k = source;
|
|
480
|
-
current = current.
|
|
481
|
+
current = current.n;
|
|
481
482
|
}
|
|
482
483
|
delete source.j;
|
|
483
484
|
}
|
|
484
|
-
transition2.
|
|
485
|
-
for (const reset of transition2.
|
|
485
|
+
transition2.D = true;
|
|
486
|
+
for (const reset of transition2.m) {
|
|
486
487
|
delete reset.j;
|
|
487
488
|
reset();
|
|
488
489
|
}
|
|
@@ -505,12 +506,12 @@ var Owner = class {
|
|
|
505
506
|
// However, the children are actually added in reverse creation order
|
|
506
507
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
507
508
|
k = null;
|
|
508
|
-
m = null;
|
|
509
|
-
y = null;
|
|
510
|
-
b = STATE_CLEAN;
|
|
511
509
|
n = null;
|
|
512
|
-
z =
|
|
513
|
-
|
|
510
|
+
z = null;
|
|
511
|
+
b = STATE_CLEAN;
|
|
512
|
+
o = null;
|
|
513
|
+
A = defaultContext;
|
|
514
|
+
E = globalQueue;
|
|
514
515
|
fa = 0;
|
|
515
516
|
id = null;
|
|
516
517
|
constructor(id = null, skipAppend = false) {
|
|
@@ -521,58 +522,58 @@ var Owner = class {
|
|
|
521
522
|
}
|
|
522
523
|
append(child) {
|
|
523
524
|
child.k = this;
|
|
524
|
-
child.
|
|
525
|
-
if (this.
|
|
526
|
-
this.
|
|
527
|
-
child.
|
|
528
|
-
this.
|
|
525
|
+
child.z = this;
|
|
526
|
+
if (this.n)
|
|
527
|
+
this.n.z = child;
|
|
528
|
+
child.n = this.n;
|
|
529
|
+
this.n = child;
|
|
529
530
|
if (this.id != null && child.id == null)
|
|
530
531
|
child.id = this.getNextChildId();
|
|
531
|
-
if (child.
|
|
532
|
-
child.
|
|
532
|
+
if (child.A !== this.A) {
|
|
533
|
+
child.A = { ...this.A, ...child.A };
|
|
533
534
|
}
|
|
534
|
-
if (this.
|
|
535
|
-
child.
|
|
535
|
+
if (this.E)
|
|
536
|
+
child.E = this.E;
|
|
536
537
|
}
|
|
537
538
|
dispose(self = true) {
|
|
538
539
|
if (this.b === STATE_DISPOSED)
|
|
539
540
|
return;
|
|
540
|
-
let head = self ? this.
|
|
541
|
+
let head = self ? this.z || this.k : this, current = this.n, next = null;
|
|
541
542
|
while (current && current.k === this) {
|
|
542
543
|
current.dispose(true);
|
|
543
|
-
next = current.
|
|
544
|
-
current.
|
|
544
|
+
next = current.n;
|
|
545
|
+
current.n = null;
|
|
545
546
|
current = next;
|
|
546
547
|
}
|
|
547
548
|
this.fa = 0;
|
|
548
549
|
if (self)
|
|
549
550
|
this.M();
|
|
550
551
|
if (current)
|
|
551
|
-
current.
|
|
552
|
+
current.z = !self ? this : this.z;
|
|
552
553
|
if (head)
|
|
553
|
-
head.
|
|
554
|
+
head.n = current;
|
|
554
555
|
}
|
|
555
556
|
M() {
|
|
556
|
-
if (this.
|
|
557
|
-
this.
|
|
557
|
+
if (this.z)
|
|
558
|
+
this.z.n = null;
|
|
558
559
|
this.k = null;
|
|
559
|
-
this.
|
|
560
|
-
this.
|
|
560
|
+
this.z = null;
|
|
561
|
+
this.A = defaultContext;
|
|
561
562
|
this.b = STATE_DISPOSED;
|
|
562
563
|
this.emptyDisposal();
|
|
563
564
|
}
|
|
564
565
|
emptyDisposal() {
|
|
565
|
-
if (!this.
|
|
566
|
+
if (!this.o)
|
|
566
567
|
return;
|
|
567
|
-
if (Array.isArray(this.
|
|
568
|
-
for (let i = 0; i < this.
|
|
569
|
-
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];
|
|
570
571
|
callable.call(callable);
|
|
571
572
|
}
|
|
572
573
|
} else {
|
|
573
|
-
this.
|
|
574
|
+
this.o.call(this.o);
|
|
574
575
|
}
|
|
575
|
-
this.
|
|
576
|
+
this.o = null;
|
|
576
577
|
}
|
|
577
578
|
getNextChildId() {
|
|
578
579
|
if (this.id != null)
|
|
@@ -587,7 +588,7 @@ function getContext(context, owner = currentOwner) {
|
|
|
587
588
|
if (!owner) {
|
|
588
589
|
throw new NoOwnerError();
|
|
589
590
|
}
|
|
590
|
-
const value = hasContext(context, owner) ? owner.
|
|
591
|
+
const value = hasContext(context, owner) ? owner.A[context.id] : context.defaultValue;
|
|
591
592
|
if (isUndefined(value)) {
|
|
592
593
|
throw new ContextNotFoundError();
|
|
593
594
|
}
|
|
@@ -597,24 +598,24 @@ function setContext(context, value, owner = currentOwner) {
|
|
|
597
598
|
if (!owner) {
|
|
598
599
|
throw new NoOwnerError();
|
|
599
600
|
}
|
|
600
|
-
owner.
|
|
601
|
-
...owner.
|
|
601
|
+
owner.A = {
|
|
602
|
+
...owner.A,
|
|
602
603
|
[context.id]: isUndefined(value) ? context.defaultValue : value
|
|
603
604
|
};
|
|
604
605
|
}
|
|
605
606
|
function hasContext(context, owner = currentOwner) {
|
|
606
|
-
return !isUndefined(owner == null ? void 0 : owner.
|
|
607
|
+
return !isUndefined(owner == null ? void 0 : owner.A[context.id]);
|
|
607
608
|
}
|
|
608
609
|
function onCleanup(fn) {
|
|
609
610
|
if (!currentOwner)
|
|
610
611
|
return fn;
|
|
611
612
|
const node = currentOwner;
|
|
612
|
-
if (!node.
|
|
613
|
-
node.
|
|
614
|
-
} else if (Array.isArray(node.
|
|
615
|
-
node.
|
|
613
|
+
if (!node.o) {
|
|
614
|
+
node.o = fn;
|
|
615
|
+
} else if (Array.isArray(node.o)) {
|
|
616
|
+
node.o.push(fn);
|
|
616
617
|
} else {
|
|
617
|
-
node.
|
|
618
|
+
node.o = [node.o, fn];
|
|
618
619
|
}
|
|
619
620
|
return fn;
|
|
620
621
|
}
|
|
@@ -653,19 +654,19 @@ var Computation = class extends Owner {
|
|
|
653
654
|
ea;
|
|
654
655
|
ha = false;
|
|
655
656
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
656
|
-
|
|
657
|
+
f = 0;
|
|
657
658
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
658
659
|
ba = DEFAULT_FLAGS;
|
|
659
660
|
Q = -1;
|
|
660
|
-
|
|
661
|
+
H = false;
|
|
661
662
|
j;
|
|
662
663
|
d;
|
|
663
|
-
|
|
664
|
+
m;
|
|
664
665
|
constructor(initialValue, compute2, options) {
|
|
665
666
|
super(options == null ? void 0 : options.id, compute2 === null);
|
|
666
667
|
this.P = compute2;
|
|
667
668
|
this.b = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
668
|
-
this.
|
|
669
|
+
this.f = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
669
670
|
this.l = initialValue;
|
|
670
671
|
if ((options == null ? void 0 : options.equals) !== void 0)
|
|
671
672
|
this.aa = options.equals;
|
|
@@ -678,8 +679,8 @@ var Computation = class extends Owner {
|
|
|
678
679
|
}
|
|
679
680
|
ga() {
|
|
680
681
|
track(this);
|
|
681
|
-
newFlags |= this.
|
|
682
|
-
if (this.
|
|
682
|
+
newFlags |= this.f & ~currentMask;
|
|
683
|
+
if (this.f & ERROR_BIT) {
|
|
683
684
|
throw this.O;
|
|
684
685
|
} else {
|
|
685
686
|
return this.l;
|
|
@@ -690,16 +691,16 @@ var Computation = class extends Owner {
|
|
|
690
691
|
* Automatically re-executes the surrounding computation when the value changes
|
|
691
692
|
*/
|
|
692
693
|
read() {
|
|
693
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.
|
|
694
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.f & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
694
695
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
695
696
|
if (clone !== this)
|
|
696
697
|
return clone.read();
|
|
697
698
|
}
|
|
698
699
|
if (this.P) {
|
|
699
|
-
if (this.
|
|
700
|
+
if (this.f & ERROR_BIT && this.Q <= clock)
|
|
700
701
|
update(this);
|
|
701
702
|
else
|
|
702
|
-
this.
|
|
703
|
+
this.F();
|
|
703
704
|
}
|
|
704
705
|
return this.ga();
|
|
705
706
|
}
|
|
@@ -711,22 +712,22 @@ var Computation = class extends Owner {
|
|
|
711
712
|
* before continuing
|
|
712
713
|
*/
|
|
713
714
|
wait() {
|
|
714
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.
|
|
715
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.f & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
715
716
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
716
717
|
if (clone !== this)
|
|
717
718
|
return clone.wait();
|
|
718
719
|
}
|
|
719
720
|
if (this.P) {
|
|
720
|
-
if (this.
|
|
721
|
+
if (this.f & ERROR_BIT && this.Q <= clock)
|
|
721
722
|
update(this);
|
|
722
723
|
else
|
|
723
|
-
this.
|
|
724
|
+
this.F();
|
|
724
725
|
}
|
|
725
|
-
if ((notStale || this.
|
|
726
|
+
if ((notStale || this.f & UNINITIALIZED_BIT) && this.f & LOADING_BIT) {
|
|
726
727
|
track(this);
|
|
727
728
|
throw new NotReadyError();
|
|
728
729
|
}
|
|
729
|
-
if (staleCheck && this.
|
|
730
|
+
if (staleCheck && this.f & LOADING_BIT) {
|
|
730
731
|
staleCheck.l = true;
|
|
731
732
|
}
|
|
732
733
|
return this.ga();
|
|
@@ -739,19 +740,19 @@ var Computation = class extends Owner {
|
|
|
739
740
|
return clone.write(value, flags, raw);
|
|
740
741
|
}
|
|
741
742
|
const newValue = !raw && typeof value === "function" ? value(this.l) : value;
|
|
742
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
743
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.f & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
|
|
743
744
|
this.aa === false || !this.aa(this.l, newValue));
|
|
744
745
|
if (valueChanged) {
|
|
745
746
|
this.l = newValue;
|
|
746
747
|
this.O = void 0;
|
|
747
748
|
}
|
|
748
|
-
const changedFlagsMask = this.
|
|
749
|
-
this.
|
|
749
|
+
const changedFlagsMask = this.f ^ flags, changedFlags = changedFlagsMask & flags;
|
|
750
|
+
this.f = flags;
|
|
750
751
|
this.Q = clock + 1;
|
|
751
|
-
if (this.c) {
|
|
752
|
+
if (this.c && !(this.m && ActiveTransition)) {
|
|
752
753
|
for (let i = 0; i < this.c.length; i++) {
|
|
753
754
|
if (valueChanged) {
|
|
754
|
-
this.c[i].
|
|
755
|
+
this.c[i].u(STATE_DIRTY);
|
|
755
756
|
} else if (changedFlagsMask) {
|
|
756
757
|
this.c[i]._(changedFlagsMask, changedFlags);
|
|
757
758
|
}
|
|
@@ -762,14 +763,14 @@ var Computation = class extends Owner {
|
|
|
762
763
|
/**
|
|
763
764
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
764
765
|
*/
|
|
765
|
-
|
|
766
|
-
if (this.b >= state && !this.
|
|
766
|
+
u(state, skipQueue) {
|
|
767
|
+
if (this.b >= state && !this.H)
|
|
767
768
|
return;
|
|
768
|
-
this.
|
|
769
|
+
this.H = !!skipQueue;
|
|
769
770
|
this.b = state;
|
|
770
|
-
if (this.c) {
|
|
771
|
+
if (this.c && !(this.m && ActiveTransition)) {
|
|
771
772
|
for (let i = 0; i < this.c.length; i++) {
|
|
772
|
-
this.c[i].
|
|
773
|
+
this.c[i].u(STATE_CHECK, skipQueue);
|
|
773
774
|
}
|
|
774
775
|
}
|
|
775
776
|
}
|
|
@@ -782,18 +783,18 @@ var Computation = class extends Owner {
|
|
|
782
783
|
_(mask, newFlags2) {
|
|
783
784
|
if (this.b >= STATE_DIRTY)
|
|
784
785
|
return;
|
|
785
|
-
if (mask & this.ba) {
|
|
786
|
-
this.
|
|
786
|
+
if (mask & this.ba || this.m && ActiveTransition) {
|
|
787
|
+
this.u(STATE_DIRTY);
|
|
787
788
|
return;
|
|
788
789
|
}
|
|
789
|
-
if (this.b >= STATE_CHECK && !this.
|
|
790
|
+
if (this.b >= STATE_CHECK && !this.H)
|
|
790
791
|
return;
|
|
791
|
-
const prevFlags = this.
|
|
792
|
+
const prevFlags = this.f & mask;
|
|
792
793
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
793
794
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
794
|
-
this.
|
|
795
|
+
this.u(STATE_CHECK);
|
|
795
796
|
} else {
|
|
796
|
-
this.
|
|
797
|
+
this.f ^= deltaFlags;
|
|
797
798
|
if (this.c) {
|
|
798
799
|
for (let i = 0; i < this.c.length; i++) {
|
|
799
800
|
this.c[i]._(mask, newFlags2);
|
|
@@ -808,7 +809,7 @@ var Computation = class extends Owner {
|
|
|
808
809
|
return clone.N(error);
|
|
809
810
|
}
|
|
810
811
|
this.O = error;
|
|
811
|
-
this.write(UNCHANGED, this.
|
|
812
|
+
this.write(UNCHANGED, this.f & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
812
813
|
}
|
|
813
814
|
/**
|
|
814
815
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -817,7 +818,7 @@ var Computation = class extends Owner {
|
|
|
817
818
|
*
|
|
818
819
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
819
820
|
*/
|
|
820
|
-
|
|
821
|
+
F() {
|
|
821
822
|
if (!this.P) {
|
|
822
823
|
return;
|
|
823
824
|
}
|
|
@@ -831,8 +832,8 @@ var Computation = class extends Owner {
|
|
|
831
832
|
if (this.b === STATE_CHECK) {
|
|
832
833
|
for (let i = 0; i < this.a.length; i++) {
|
|
833
834
|
const source = getTransitionSource(this.a[i]);
|
|
834
|
-
source.
|
|
835
|
-
observerFlags |= source.
|
|
835
|
+
source.F();
|
|
836
|
+
observerFlags |= source.f & ~UNINITIALIZED_BIT;
|
|
836
837
|
if (this.b === STATE_DIRTY) {
|
|
837
838
|
break;
|
|
838
839
|
}
|
|
@@ -888,7 +889,7 @@ function update(node) {
|
|
|
888
889
|
node.write(result, newFlags, true);
|
|
889
890
|
} catch (error) {
|
|
890
891
|
if (error instanceof NotReadyError) {
|
|
891
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.
|
|
892
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.f & UNINITIALIZED_BIT);
|
|
892
893
|
} else {
|
|
893
894
|
node.N(error);
|
|
894
895
|
}
|
|
@@ -962,7 +963,7 @@ function isPending(fn, loadingValue) {
|
|
|
962
963
|
return pendingCheck(fn, loadingValue);
|
|
963
964
|
const c = new Computation(void 0, () => pendingCheck(fn, loadingValue));
|
|
964
965
|
c.ba |= LOADING_BIT;
|
|
965
|
-
return c.
|
|
966
|
+
return c.wait();
|
|
966
967
|
}
|
|
967
968
|
function latest(fn, fallback) {
|
|
968
969
|
const argLength = arguments.length;
|
|
@@ -999,29 +1000,29 @@ function compute(owner, fn, observer) {
|
|
|
999
1000
|
var Effect = class extends Computation {
|
|
1000
1001
|
ca;
|
|
1001
1002
|
$;
|
|
1002
|
-
|
|
1003
|
+
w;
|
|
1003
1004
|
da = false;
|
|
1004
1005
|
T;
|
|
1005
|
-
|
|
1006
|
+
s;
|
|
1006
1007
|
constructor(initialValue, compute2, effect, error, options) {
|
|
1007
1008
|
super(initialValue, compute2, options);
|
|
1008
1009
|
this.ca = effect;
|
|
1009
1010
|
this.$ = error;
|
|
1010
1011
|
this.T = initialValue;
|
|
1011
|
-
this.
|
|
1012
|
-
if (this.
|
|
1012
|
+
this.s = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
|
|
1013
|
+
if (this.s === EFFECT_RENDER) {
|
|
1013
1014
|
this.P = function(p) {
|
|
1014
|
-
return !this.d && clock > this.
|
|
1015
|
+
return !this.d && clock > this.E.created && !(this.f & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
1015
1016
|
};
|
|
1016
1017
|
}
|
|
1017
|
-
this.
|
|
1018
|
-
!(options == null ? void 0 : options.defer) && (this.
|
|
1018
|
+
this.F();
|
|
1019
|
+
!(options == null ? void 0 : options.defer) && (this.s === EFFECT_USER ? getQueue(this).enqueue(this.s, this.x.bind(this)) : this.x(this.s));
|
|
1019
1020
|
}
|
|
1020
1021
|
write(value, flags = 0) {
|
|
1021
1022
|
if (this.b == STATE_DIRTY) {
|
|
1022
|
-
this.
|
|
1023
|
-
if (this.
|
|
1024
|
-
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.
|
|
1023
|
+
this.f = flags;
|
|
1024
|
+
if (this.s === EFFECT_RENDER) {
|
|
1025
|
+
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.f);
|
|
1025
1026
|
}
|
|
1026
1027
|
}
|
|
1027
1028
|
if (value === UNCHANGED)
|
|
@@ -1031,11 +1032,11 @@ var Effect = class extends Computation {
|
|
|
1031
1032
|
this.O = void 0;
|
|
1032
1033
|
return value;
|
|
1033
1034
|
}
|
|
1034
|
-
|
|
1035
|
+
u(state, skipQueue) {
|
|
1035
1036
|
if (this.b >= state || skipQueue)
|
|
1036
1037
|
return;
|
|
1037
1038
|
if (this.b === STATE_CLEAN || this.d && !ActiveTransition)
|
|
1038
|
-
getQueue(this).enqueue(this.
|
|
1039
|
+
getQueue(this).enqueue(this.s, this.x.bind(this));
|
|
1039
1040
|
this.b = state;
|
|
1040
1041
|
}
|
|
1041
1042
|
_(mask, newFlags2) {
|
|
@@ -1043,7 +1044,7 @@ var Effect = class extends Computation {
|
|
|
1043
1044
|
if (this.b >= STATE_DIRTY)
|
|
1044
1045
|
return;
|
|
1045
1046
|
if (mask & 3) {
|
|
1046
|
-
this.
|
|
1047
|
+
this.u(STATE_DIRTY);
|
|
1047
1048
|
return;
|
|
1048
1049
|
}
|
|
1049
1050
|
}
|
|
@@ -1052,13 +1053,13 @@ var Effect = class extends Computation {
|
|
|
1052
1053
|
N(error) {
|
|
1053
1054
|
this.O = error;
|
|
1054
1055
|
getQueue(this).notify(this, LOADING_BIT, 0);
|
|
1055
|
-
this.
|
|
1056
|
-
if (this.
|
|
1056
|
+
this.f = ERROR_BIT;
|
|
1057
|
+
if (this.s === EFFECT_USER) {
|
|
1057
1058
|
try {
|
|
1058
1059
|
return this.$ ? this.$(error, () => {
|
|
1059
1060
|
var _a;
|
|
1060
|
-
(_a = this.
|
|
1061
|
-
this.
|
|
1061
|
+
(_a = this.w) == null ? void 0 : _a.call(this);
|
|
1062
|
+
this.w = void 0;
|
|
1062
1063
|
}) : console.error(error);
|
|
1063
1064
|
} catch (e) {
|
|
1064
1065
|
error = e;
|
|
@@ -1074,19 +1075,19 @@ var Effect = class extends Computation {
|
|
|
1074
1075
|
this.ca = void 0;
|
|
1075
1076
|
this.T = void 0;
|
|
1076
1077
|
this.$ = void 0;
|
|
1077
|
-
(_a = this.
|
|
1078
|
-
this.
|
|
1078
|
+
(_a = this.w) == null ? void 0 : _a.call(this);
|
|
1079
|
+
this.w = void 0;
|
|
1079
1080
|
getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
|
|
1080
1081
|
super.M();
|
|
1081
1082
|
}
|
|
1082
|
-
|
|
1083
|
+
x(type) {
|
|
1083
1084
|
var _a;
|
|
1084
1085
|
if (type) {
|
|
1085
1086
|
const effect = this.d || this;
|
|
1086
1087
|
if (effect.da && effect.b !== STATE_DISPOSED) {
|
|
1087
|
-
(_a = effect.
|
|
1088
|
+
(_a = effect.w) == null ? void 0 : _a.call(effect);
|
|
1088
1089
|
try {
|
|
1089
|
-
effect.
|
|
1090
|
+
effect.w = effect.ca(effect.l, effect.T);
|
|
1090
1091
|
} catch (e) {
|
|
1091
1092
|
if (!getQueue(effect).notify(effect, ERROR_BIT, ERROR_BIT))
|
|
1092
1093
|
throw e;
|
|
@@ -1100,34 +1101,34 @@ var Effect = class extends Computation {
|
|
|
1100
1101
|
}
|
|
1101
1102
|
};
|
|
1102
1103
|
var TrackedEffect = class extends Computation {
|
|
1103
|
-
|
|
1104
|
-
|
|
1104
|
+
s = EFFECT_USER;
|
|
1105
|
+
w;
|
|
1105
1106
|
constructor(compute2, options) {
|
|
1106
1107
|
super(void 0, () => {
|
|
1107
1108
|
var _a;
|
|
1108
|
-
(_a = this.
|
|
1109
|
-
this.
|
|
1109
|
+
(_a = this.w) == null ? void 0 : _a.call(this);
|
|
1110
|
+
this.w = latest(compute2);
|
|
1110
1111
|
return void 0;
|
|
1111
1112
|
}, options);
|
|
1112
|
-
getQueue(this).enqueue(this.
|
|
1113
|
+
getQueue(this).enqueue(this.s, this.x.bind(this));
|
|
1113
1114
|
}
|
|
1114
|
-
|
|
1115
|
+
u(state, skipQueue) {
|
|
1115
1116
|
if (this.b >= state || skipQueue)
|
|
1116
1117
|
return;
|
|
1117
1118
|
if (this.b === STATE_CLEAN || this.d && !ActiveTransition)
|
|
1118
|
-
getQueue(this).enqueue(this.
|
|
1119
|
+
getQueue(this).enqueue(this.s, this.x.bind(this));
|
|
1119
1120
|
this.b = state;
|
|
1120
1121
|
}
|
|
1121
1122
|
M() {
|
|
1122
1123
|
var _a;
|
|
1123
1124
|
if (this.b === STATE_DISPOSED)
|
|
1124
1125
|
return;
|
|
1125
|
-
(_a = this.
|
|
1126
|
-
this.
|
|
1126
|
+
(_a = this.w) == null ? void 0 : _a.call(this);
|
|
1127
|
+
this.w = void 0;
|
|
1127
1128
|
getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
|
|
1128
1129
|
super.M();
|
|
1129
1130
|
}
|
|
1130
|
-
|
|
1131
|
+
x(type) {
|
|
1131
1132
|
if (type)
|
|
1132
1133
|
this.b !== STATE_CLEAN && runTop(this);
|
|
1133
1134
|
}
|
|
@@ -1135,16 +1136,16 @@ var TrackedEffect = class extends Computation {
|
|
|
1135
1136
|
var EagerComputation = class extends Computation {
|
|
1136
1137
|
constructor(initialValue, compute2, options) {
|
|
1137
1138
|
super(initialValue, compute2, options);
|
|
1138
|
-
!(options == null ? void 0 : options.defer) && this.
|
|
1139
|
+
!(options == null ? void 0 : options.defer) && this.F();
|
|
1139
1140
|
}
|
|
1140
|
-
|
|
1141
|
-
if (this.b >= state && !this.
|
|
1141
|
+
u(state, skipQueue) {
|
|
1142
|
+
if (this.b >= state && !this.H)
|
|
1142
1143
|
return;
|
|
1143
|
-
if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.
|
|
1144
|
-
getQueue(this).enqueue(EFFECT_PURE, this.
|
|
1145
|
-
super.
|
|
1144
|
+
if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.H))
|
|
1145
|
+
getQueue(this).enqueue(EFFECT_PURE, this.x.bind(this));
|
|
1146
|
+
super.u(state, skipQueue);
|
|
1146
1147
|
}
|
|
1147
|
-
|
|
1148
|
+
x() {
|
|
1148
1149
|
this.b !== STATE_CLEAN && runTop(this);
|
|
1149
1150
|
}
|
|
1150
1151
|
};
|
|
@@ -1153,16 +1154,22 @@ var FirewallComputation = class extends Computation {
|
|
|
1153
1154
|
constructor(compute2) {
|
|
1154
1155
|
super(void 0, compute2);
|
|
1155
1156
|
}
|
|
1156
|
-
|
|
1157
|
-
if (this.b >= state && !this.
|
|
1157
|
+
u(state, skipQueue) {
|
|
1158
|
+
if (this.b >= state && !this.H)
|
|
1158
1159
|
return;
|
|
1159
|
-
if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.
|
|
1160
|
-
getQueue(this).enqueue(EFFECT_PURE, this.
|
|
1161
|
-
super.
|
|
1162
|
-
this.
|
|
1160
|
+
if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.H))
|
|
1161
|
+
getQueue(this).enqueue(EFFECT_PURE, this.x.bind(this));
|
|
1162
|
+
super.u(state, true);
|
|
1163
|
+
this.H = !!skipQueue;
|
|
1163
1164
|
}
|
|
1164
|
-
|
|
1165
|
+
x() {
|
|
1166
|
+
const prevFlags = this.f;
|
|
1165
1167
|
this.b !== STATE_CLEAN && runTop(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
|
+
}
|
|
1166
1173
|
}
|
|
1167
1174
|
};
|
|
1168
1175
|
function runTop(node) {
|
|
@@ -1176,7 +1183,7 @@ function runTop(node) {
|
|
|
1176
1183
|
}
|
|
1177
1184
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
1178
1185
|
if (ancestors[i].b !== STATE_DISPOSED)
|
|
1179
|
-
ancestors[i].
|
|
1186
|
+
ancestors[i].F();
|
|
1180
1187
|
}
|
|
1181
1188
|
}
|
|
1182
1189
|
|
|
@@ -1185,7 +1192,7 @@ function createSignal(first, second, third) {
|
|
|
1185
1192
|
if (typeof first === "function") {
|
|
1186
1193
|
const node2 = new Computation(second, first, third);
|
|
1187
1194
|
return [node2.read.bind(node2), (v) => {
|
|
1188
|
-
node2.
|
|
1195
|
+
node2.F();
|
|
1189
1196
|
return node2.write(v);
|
|
1190
1197
|
}];
|
|
1191
1198
|
}
|
|
@@ -1213,7 +1220,7 @@ function createMemo(compute2, value, options) {
|
|
|
1213
1220
|
return resolvedValue;
|
|
1214
1221
|
}
|
|
1215
1222
|
resolvedValue = node.wait();
|
|
1216
|
-
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)) {
|
|
1217
1224
|
node.dispose();
|
|
1218
1225
|
node = void 0;
|
|
1219
1226
|
}
|
|
@@ -1292,7 +1299,7 @@ function createAsync(compute2, value, options) {
|
|
|
1292
1299
|
}
|
|
1293
1300
|
n.b = STATE_DIRTY;
|
|
1294
1301
|
refreshing = true;
|
|
1295
|
-
n.
|
|
1302
|
+
n.F();
|
|
1296
1303
|
};
|
|
1297
1304
|
return read;
|
|
1298
1305
|
}
|
|
@@ -1359,16 +1366,20 @@ function resolve(fn) {
|
|
|
1359
1366
|
});
|
|
1360
1367
|
}
|
|
1361
1368
|
function createOptimistic(first, second, third) {
|
|
1362
|
-
const node = typeof first === "function" ? new Computation(second,
|
|
1363
|
-
|
|
1369
|
+
const node = typeof first === "function" ? new Computation(second, (prev) => {
|
|
1370
|
+
const res = first(prev);
|
|
1371
|
+
if (node.m.j)
|
|
1372
|
+
return prev;
|
|
1373
|
+
return res;
|
|
1374
|
+
}, third) : new Computation(first, null, second);
|
|
1375
|
+
node.m = () => node.write(first);
|
|
1364
1376
|
function write(v) {
|
|
1365
1377
|
if (!ActiveTransition)
|
|
1366
1378
|
throw new Error("createOptimistic can only be updated inside a transition");
|
|
1367
|
-
ActiveTransition.addOptimistic(
|
|
1368
|
-
cloneGraph(node, true);
|
|
1379
|
+
ActiveTransition.addOptimistic(node.m);
|
|
1369
1380
|
queueMicrotask(() => {
|
|
1370
|
-
if (
|
|
1371
|
-
node.
|
|
1381
|
+
if (node.m.j) {
|
|
1382
|
+
node.F();
|
|
1372
1383
|
node.write(v);
|
|
1373
1384
|
}
|
|
1374
1385
|
});
|
|
@@ -1851,7 +1862,12 @@ function deep(store) {
|
|
|
1851
1862
|
// src/store/optimistic.ts
|
|
1852
1863
|
function createOptimisticStore(first, second, options) {
|
|
1853
1864
|
const derived = typeof first === "function";
|
|
1854
|
-
const { store, node } = derived ? createProjectionInternal(
|
|
1865
|
+
const { store, node } = derived ? createProjectionInternal((draft) => {
|
|
1866
|
+
const res = first(draft);
|
|
1867
|
+
if (reset.j)
|
|
1868
|
+
return draft;
|
|
1869
|
+
return res;
|
|
1870
|
+
}, second, options) : createProjectionInternal(() => {
|
|
1855
1871
|
}, first);
|
|
1856
1872
|
const reset = () => storeSetter(
|
|
1857
1873
|
store,
|
|
@@ -1865,9 +1881,9 @@ function createOptimisticStore(first, second, options) {
|
|
|
1865
1881
|
if (!ActiveTransition)
|
|
1866
1882
|
throw new Error("createOptimisticStore can only be updated inside a transition");
|
|
1867
1883
|
ActiveTransition.addOptimistic(reset);
|
|
1868
|
-
cloneGraph(node, true);
|
|
1869
1884
|
queueMicrotask(() => reset.j && storeSetter(store, v));
|
|
1870
1885
|
};
|
|
1886
|
+
node.m = reset;
|
|
1871
1887
|
return [store, write];
|
|
1872
1888
|
}
|
|
1873
1889
|
|
|
@@ -2077,15 +2093,15 @@ function mapArray(list, map, options) {
|
|
|
2077
2093
|
const keyFn = typeof (options == null ? void 0 : options.keyed) === "function" ? options.keyed : void 0;
|
|
2078
2094
|
return updateKeyedMap.bind({
|
|
2079
2095
|
U: new Owner(),
|
|
2080
|
-
|
|
2096
|
+
p: 0,
|
|
2081
2097
|
ia: list,
|
|
2082
|
-
|
|
2098
|
+
I: [],
|
|
2083
2099
|
R: map,
|
|
2084
|
-
|
|
2100
|
+
i: [],
|
|
2085
2101
|
e: [],
|
|
2086
2102
|
S: keyFn,
|
|
2087
|
-
|
|
2088
|
-
|
|
2103
|
+
q: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
2104
|
+
r: map.length > 1 ? [] : void 0,
|
|
2089
2105
|
V: options == null ? void 0 : options.fallback
|
|
2090
2106
|
});
|
|
2091
2107
|
}
|
|
@@ -2094,58 +2110,58 @@ function updateKeyedMap() {
|
|
|
2094
2110
|
const newItems = this.ia() || [], newLen = newItems.length;
|
|
2095
2111
|
newItems[$TRACK];
|
|
2096
2112
|
runWithOwner(this.U, () => {
|
|
2097
|
-
let i, j, mapper = this.
|
|
2098
|
-
this.
|
|
2099
|
-
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));
|
|
2100
2116
|
return this.R(
|
|
2101
|
-
Computation.prototype.read.bind(this.
|
|
2102
|
-
this.
|
|
2117
|
+
Computation.prototype.read.bind(this.q[j]),
|
|
2118
|
+
this.r ? Computation.prototype.read.bind(this.r[j]) : void 0
|
|
2103
2119
|
);
|
|
2104
|
-
} : this.
|
|
2120
|
+
} : this.r ? () => {
|
|
2105
2121
|
const item = newItems[j];
|
|
2106
|
-
this.
|
|
2107
|
-
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]));
|
|
2108
2124
|
} : () => {
|
|
2109
2125
|
const item = newItems[j];
|
|
2110
2126
|
return this.R(() => item);
|
|
2111
2127
|
};
|
|
2112
2128
|
if (newLen === 0) {
|
|
2113
|
-
if (this.
|
|
2129
|
+
if (this.p !== 0) {
|
|
2114
2130
|
this.U.dispose(false);
|
|
2115
2131
|
this.e = [];
|
|
2116
|
-
this.
|
|
2117
|
-
this.
|
|
2118
|
-
this.
|
|
2119
|
-
this.p && (this.p = []);
|
|
2132
|
+
this.I = [];
|
|
2133
|
+
this.i = [];
|
|
2134
|
+
this.p = 0;
|
|
2120
2135
|
this.q && (this.q = []);
|
|
2136
|
+
this.r && (this.r = []);
|
|
2121
2137
|
}
|
|
2122
|
-
if (this.V && !this.
|
|
2123
|
-
this.
|
|
2138
|
+
if (this.V && !this.i[0]) {
|
|
2139
|
+
this.i[0] = compute(
|
|
2124
2140
|
this.e[0] = new Owner(),
|
|
2125
2141
|
this.V,
|
|
2126
2142
|
null
|
|
2127
2143
|
);
|
|
2128
2144
|
}
|
|
2129
|
-
} else if (this.
|
|
2145
|
+
} else if (this.p === 0) {
|
|
2130
2146
|
if (this.e[0])
|
|
2131
2147
|
this.e[0].dispose();
|
|
2132
|
-
this.
|
|
2148
|
+
this.i = new Array(newLen);
|
|
2133
2149
|
for (j = 0; j < newLen; j++) {
|
|
2134
|
-
this.
|
|
2135
|
-
this.
|
|
2150
|
+
this.I[j] = newItems[j];
|
|
2151
|
+
this.i[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2136
2152
|
}
|
|
2137
|
-
this.
|
|
2153
|
+
this.p = newLen;
|
|
2138
2154
|
} else {
|
|
2139
|
-
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.
|
|
2140
|
-
for (start = 0, end = Math.min(this.
|
|
2141
|
-
if (this.
|
|
2142
|
-
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]);
|
|
2143
2159
|
}
|
|
2144
|
-
for (end = this.
|
|
2145
|
-
temp[newEnd] = 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--) {
|
|
2161
|
+
temp[newEnd] = this.i[end];
|
|
2146
2162
|
tempNodes[newEnd] = this.e[end];
|
|
2147
|
-
tempRows && (tempRows[newEnd] = this.
|
|
2148
|
-
tempIndexes && (tempIndexes[newEnd] = this.
|
|
2163
|
+
tempRows && (tempRows[newEnd] = this.q[end]);
|
|
2164
|
+
tempIndexes && (tempIndexes[newEnd] = this.r[end]);
|
|
2149
2165
|
}
|
|
2150
2166
|
newIndices = /* @__PURE__ */ new Map();
|
|
2151
2167
|
newIndicesNext = new Array(newEnd + 1);
|
|
@@ -2157,14 +2173,14 @@ function updateKeyedMap() {
|
|
|
2157
2173
|
newIndices.set(key, j);
|
|
2158
2174
|
}
|
|
2159
2175
|
for (i = start; i <= end; i++) {
|
|
2160
|
-
item = this.
|
|
2176
|
+
item = this.I[i];
|
|
2161
2177
|
key = this.S ? this.S(item) : item;
|
|
2162
2178
|
j = newIndices.get(key);
|
|
2163
2179
|
if (j !== void 0 && j !== -1) {
|
|
2164
|
-
temp[j] = this.
|
|
2180
|
+
temp[j] = this.i[i];
|
|
2165
2181
|
tempNodes[j] = this.e[i];
|
|
2166
|
-
tempRows && (tempRows[j] = this.
|
|
2167
|
-
tempIndexes && (tempIndexes[j] = this.
|
|
2182
|
+
tempRows && (tempRows[j] = this.q[i]);
|
|
2183
|
+
tempIndexes && (tempIndexes[j] = this.r[i]);
|
|
2168
2184
|
j = newIndicesNext[j];
|
|
2169
2185
|
newIndices.set(key, j);
|
|
2170
2186
|
} else
|
|
@@ -2172,35 +2188,35 @@ function updateKeyedMap() {
|
|
|
2172
2188
|
}
|
|
2173
2189
|
for (j = start; j < newLen; j++) {
|
|
2174
2190
|
if (j in temp) {
|
|
2175
|
-
this.
|
|
2191
|
+
this.i[j] = temp[j];
|
|
2176
2192
|
this.e[j] = tempNodes[j];
|
|
2177
2193
|
if (tempRows) {
|
|
2178
|
-
this.
|
|
2179
|
-
this.
|
|
2194
|
+
this.q[j] = tempRows[j];
|
|
2195
|
+
this.q[j].write(newItems[j]);
|
|
2180
2196
|
}
|
|
2181
2197
|
if (tempIndexes) {
|
|
2182
|
-
this.
|
|
2183
|
-
this.
|
|
2198
|
+
this.r[j] = tempIndexes[j];
|
|
2199
|
+
this.r[j].write(j);
|
|
2184
2200
|
}
|
|
2185
2201
|
} else {
|
|
2186
|
-
this.
|
|
2202
|
+
this.i[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2187
2203
|
}
|
|
2188
2204
|
}
|
|
2189
|
-
this.
|
|
2190
|
-
this.
|
|
2205
|
+
this.i = this.i.slice(0, this.p = newLen);
|
|
2206
|
+
this.I = newItems.slice(0);
|
|
2191
2207
|
}
|
|
2192
2208
|
});
|
|
2193
|
-
return this.
|
|
2209
|
+
return this.i;
|
|
2194
2210
|
}
|
|
2195
2211
|
function repeat(count, map, options) {
|
|
2196
2212
|
return updateRepeat.bind({
|
|
2197
2213
|
U: new Owner(),
|
|
2198
|
-
|
|
2199
|
-
|
|
2214
|
+
p: 0,
|
|
2215
|
+
B: 0,
|
|
2200
2216
|
ja: count,
|
|
2201
2217
|
R: map,
|
|
2202
2218
|
e: [],
|
|
2203
|
-
|
|
2219
|
+
i: [],
|
|
2204
2220
|
ka: options == null ? void 0 : options.from,
|
|
2205
2221
|
V: options == null ? void 0 : options.fallback
|
|
2206
2222
|
});
|
|
@@ -2211,14 +2227,14 @@ function updateRepeat() {
|
|
|
2211
2227
|
const from = ((_a = this.ka) == null ? void 0 : _a.call(this)) || 0;
|
|
2212
2228
|
runWithOwner(this.U, () => {
|
|
2213
2229
|
if (newLen === 0) {
|
|
2214
|
-
if (this.
|
|
2230
|
+
if (this.p !== 0) {
|
|
2215
2231
|
this.U.dispose(false);
|
|
2216
2232
|
this.e = [];
|
|
2217
|
-
this.
|
|
2218
|
-
this.
|
|
2233
|
+
this.i = [];
|
|
2234
|
+
this.p = 0;
|
|
2219
2235
|
}
|
|
2220
|
-
if (this.V && !this.
|
|
2221
|
-
this.
|
|
2236
|
+
if (this.V && !this.i[0]) {
|
|
2237
|
+
this.i[0] = compute(
|
|
2222
2238
|
this.e[0] = new Owner(),
|
|
2223
2239
|
this.V,
|
|
2224
2240
|
null
|
|
@@ -2227,28 +2243,28 @@ function updateRepeat() {
|
|
|
2227
2243
|
return;
|
|
2228
2244
|
}
|
|
2229
2245
|
const to = from + newLen;
|
|
2230
|
-
const prevTo = this.
|
|
2231
|
-
if (this.
|
|
2246
|
+
const prevTo = this.B + this.p;
|
|
2247
|
+
if (this.p === 0 && this.e[0])
|
|
2232
2248
|
this.e[0].dispose();
|
|
2233
2249
|
for (let i = to; i < prevTo; i++)
|
|
2234
|
-
this.e[i - this.
|
|
2235
|
-
if (this.
|
|
2236
|
-
let i = this.
|
|
2237
|
-
while (i < from && i < this.
|
|
2250
|
+
this.e[i - this.B].dispose();
|
|
2251
|
+
if (this.B < from) {
|
|
2252
|
+
let i = this.B;
|
|
2253
|
+
while (i < from && i < this.p)
|
|
2238
2254
|
this.e[i++].dispose();
|
|
2239
|
-
this.e.splice(0, from - this.
|
|
2240
|
-
this.
|
|
2241
|
-
} else if (this.
|
|
2242
|
-
let i = prevTo - this.
|
|
2243
|
-
let difference = this.
|
|
2244
|
-
this.e.length = this.
|
|
2255
|
+
this.e.splice(0, from - this.B);
|
|
2256
|
+
this.i.splice(0, from - this.B);
|
|
2257
|
+
} else if (this.B > from) {
|
|
2258
|
+
let i = prevTo - this.B - 1;
|
|
2259
|
+
let difference = this.B - from;
|
|
2260
|
+
this.e.length = this.i.length = newLen;
|
|
2245
2261
|
while (i >= difference) {
|
|
2246
2262
|
this.e[i] = this.e[i - difference];
|
|
2247
|
-
this.
|
|
2263
|
+
this.i[i] = this.i[i - difference];
|
|
2248
2264
|
i--;
|
|
2249
2265
|
}
|
|
2250
2266
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
2251
|
-
this.
|
|
2267
|
+
this.i[i2] = compute(
|
|
2252
2268
|
this.e[i2] = new Owner(),
|
|
2253
2269
|
() => this.R(i2 + from),
|
|
2254
2270
|
null
|
|
@@ -2256,17 +2272,17 @@ function updateRepeat() {
|
|
|
2256
2272
|
}
|
|
2257
2273
|
}
|
|
2258
2274
|
for (let i = prevTo; i < to; i++) {
|
|
2259
|
-
this.
|
|
2275
|
+
this.i[i - from] = compute(
|
|
2260
2276
|
this.e[i - from] = new Owner(),
|
|
2261
2277
|
() => this.R(i),
|
|
2262
2278
|
null
|
|
2263
2279
|
);
|
|
2264
2280
|
}
|
|
2265
|
-
this.
|
|
2266
|
-
this.
|
|
2267
|
-
this.
|
|
2281
|
+
this.i = this.i.slice(0, newLen);
|
|
2282
|
+
this.B = from;
|
|
2283
|
+
this.p = newLen;
|
|
2268
2284
|
});
|
|
2269
|
-
return this.
|
|
2285
|
+
return this.i;
|
|
2270
2286
|
}
|
|
2271
2287
|
function compare(key, a, b) {
|
|
2272
2288
|
return key ? key(a) === key(b) : true;
|
|
@@ -2281,7 +2297,7 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2281
2297
|
}
|
|
2282
2298
|
write(value, flags) {
|
|
2283
2299
|
super.write(value, flags & ~this.W);
|
|
2284
|
-
if (this.W & LOADING_BIT && !(this.
|
|
2300
|
+
if (this.W & LOADING_BIT && !(this.f & UNINITIALIZED_BIT || ActiveTransition)) {
|
|
2285
2301
|
flags &= ~LOADING_BIT;
|
|
2286
2302
|
}
|
|
2287
2303
|
getQueue(this).notify(this, this.W, flags);
|
|
@@ -2289,9 +2305,9 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2289
2305
|
}
|
|
2290
2306
|
};
|
|
2291
2307
|
function createBoundChildren(owner, fn, queue, mask) {
|
|
2292
|
-
const parentQueue = owner.
|
|
2293
|
-
parentQueue.addChild(owner.
|
|
2294
|
-
onCleanup(() => parentQueue.removeChild(owner.
|
|
2308
|
+
const parentQueue = owner.E;
|
|
2309
|
+
parentQueue.addChild(owner.E = queue);
|
|
2310
|
+
onCleanup(() => parentQueue.removeChild(owner.E));
|
|
2295
2311
|
return compute(
|
|
2296
2312
|
owner,
|
|
2297
2313
|
() => {
|
|
@@ -2302,25 +2318,25 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
2302
2318
|
);
|
|
2303
2319
|
}
|
|
2304
2320
|
var ConditionalQueue = class extends Queue {
|
|
2305
|
-
|
|
2321
|
+
y;
|
|
2306
2322
|
X = /* @__PURE__ */ new Set();
|
|
2307
|
-
|
|
2323
|
+
t = /* @__PURE__ */ new Set();
|
|
2308
2324
|
constructor(disabled) {
|
|
2309
2325
|
super();
|
|
2310
|
-
this.
|
|
2326
|
+
this.y = disabled;
|
|
2311
2327
|
}
|
|
2312
2328
|
run(type) {
|
|
2313
|
-
if (!type || this.
|
|
2329
|
+
if (!type || this.y.read())
|
|
2314
2330
|
return;
|
|
2315
2331
|
return super.run(type);
|
|
2316
2332
|
}
|
|
2317
2333
|
notify(node, type, flags) {
|
|
2318
|
-
if (this.
|
|
2334
|
+
if (this.y.read()) {
|
|
2319
2335
|
if (type & LOADING_BIT) {
|
|
2320
2336
|
if (flags & LOADING_BIT) {
|
|
2321
|
-
this.
|
|
2337
|
+
this.t.add(node);
|
|
2322
2338
|
type &= ~LOADING_BIT;
|
|
2323
|
-
} else if (this.
|
|
2339
|
+
} else if (this.t.delete(node))
|
|
2324
2340
|
type &= ~LOADING_BIT;
|
|
2325
2341
|
}
|
|
2326
2342
|
if (type & ERROR_BIT) {
|
|
@@ -2334,7 +2350,7 @@ var ConditionalQueue = class extends Queue {
|
|
|
2334
2350
|
return type ? super.notify(node, type, flags) : true;
|
|
2335
2351
|
}
|
|
2336
2352
|
merge(queue) {
|
|
2337
|
-
queue.
|
|
2353
|
+
queue.t.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
|
|
2338
2354
|
queue.X.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
|
|
2339
2355
|
super.merge(queue);
|
|
2340
2356
|
}
|
|
@@ -2342,13 +2358,13 @@ var ConditionalQueue = class extends Queue {
|
|
|
2342
2358
|
var CollectionQueue = class extends Queue {
|
|
2343
2359
|
L;
|
|
2344
2360
|
e = /* @__PURE__ */ new Set();
|
|
2345
|
-
|
|
2361
|
+
y = new Computation(false, null, { pureWrite: true });
|
|
2346
2362
|
constructor(type) {
|
|
2347
2363
|
super();
|
|
2348
2364
|
this.L = type;
|
|
2349
2365
|
}
|
|
2350
2366
|
run(type) {
|
|
2351
|
-
if (!type || this.
|
|
2367
|
+
if (!type || this.y.read())
|
|
2352
2368
|
return;
|
|
2353
2369
|
return super.run(type);
|
|
2354
2370
|
}
|
|
@@ -2358,11 +2374,11 @@ var CollectionQueue = class extends Queue {
|
|
|
2358
2374
|
if (flags & this.L) {
|
|
2359
2375
|
this.e.add(node);
|
|
2360
2376
|
if (this.e.size === 1)
|
|
2361
|
-
this.
|
|
2377
|
+
this.y.write(true);
|
|
2362
2378
|
} else if (this.e.size > 0) {
|
|
2363
2379
|
this.e.delete(node);
|
|
2364
2380
|
if (this.e.size === 0)
|
|
2365
|
-
this.
|
|
2381
|
+
this.y.write(false);
|
|
2366
2382
|
}
|
|
2367
2383
|
type &= ~this.L;
|
|
2368
2384
|
return type ? super.notify(node, type, flags) : true;
|
|
@@ -2379,25 +2395,25 @@ function createBoundary(fn, condition) {
|
|
|
2379
2395
|
);
|
|
2380
2396
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
2381
2397
|
new EagerComputation(void 0, () => {
|
|
2382
|
-
const disabled = queue.
|
|
2398
|
+
const disabled = queue.y.read();
|
|
2383
2399
|
tree.W = disabled ? ERROR_BIT | LOADING_BIT : 0;
|
|
2384
2400
|
if (!disabled) {
|
|
2385
|
-
queue.
|
|
2401
|
+
queue.t.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
|
|
2386
2402
|
queue.X.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
|
|
2387
|
-
queue.
|
|
2403
|
+
queue.t.clear();
|
|
2388
2404
|
queue.X.clear();
|
|
2389
2405
|
}
|
|
2390
2406
|
});
|
|
2391
|
-
return () => queue.
|
|
2407
|
+
return () => queue.y.read() ? void 0 : tree.read();
|
|
2392
2408
|
}
|
|
2393
2409
|
function createCollectionBoundary(type, fn, fallback) {
|
|
2394
2410
|
const owner = new Owner();
|
|
2395
2411
|
const queue = new CollectionQueue(type);
|
|
2396
2412
|
const tree = createBoundChildren(owner, fn, queue, type);
|
|
2397
2413
|
const decision = new Computation(void 0, () => {
|
|
2398
|
-
if (!queue.
|
|
2414
|
+
if (!queue.y.read()) {
|
|
2399
2415
|
const resolved = tree.read();
|
|
2400
|
-
if (!untrack(() => queue.
|
|
2416
|
+
if (!untrack(() => queue.y.read()))
|
|
2401
2417
|
return resolved;
|
|
2402
2418
|
}
|
|
2403
2419
|
return fallback(queue);
|
|
@@ -2416,7 +2432,7 @@ function createErrorBoundary(fn, fallback) {
|
|
|
2416
2432
|
if (ActiveTransition && !node2.d)
|
|
2417
2433
|
node2 = cloneGraph(node2);
|
|
2418
2434
|
node2.b = STATE_DIRTY;
|
|
2419
|
-
getQueue(node2).enqueue(node2.
|
|
2435
|
+
getQueue(node2).enqueue(node2.s, node2.x.bind(node2));
|
|
2420
2436
|
}
|
|
2421
2437
|
});
|
|
2422
2438
|
});
|