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