@solidjs/signals 0.6.4 → 0.7.1
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 +79 -65
- package/dist/node.cjs +447 -430
- package/dist/prod.js +442 -430
- package/dist/types/core/core.d.ts +0 -6
- package/dist/types/core/effect.d.ts +8 -0
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/signals.d.ts +31 -0
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/optimistic.d.ts +2 -2
- package/package.json +1 -1
package/dist/prod.js
CHANGED
|
@@ -45,13 +45,13 @@ function schedule() {
|
|
|
45
45
|
if (scheduled)
|
|
46
46
|
return;
|
|
47
47
|
scheduled = true;
|
|
48
|
-
if (!globalQueue.
|
|
48
|
+
if (!globalQueue.B)
|
|
49
49
|
queueMicrotask(flush);
|
|
50
50
|
}
|
|
51
51
|
function notifyUnobserved() {
|
|
52
52
|
for (let i = 0; i < Unobserved.length; i++) {
|
|
53
53
|
const source = Unobserved[i];
|
|
54
|
-
if (!source.
|
|
54
|
+
if (!source.c || !source.c.length)
|
|
55
55
|
Unobserved[i].ea?.();
|
|
56
56
|
}
|
|
57
57
|
Unobserved = [];
|
|
@@ -59,7 +59,7 @@ function notifyUnobserved() {
|
|
|
59
59
|
var pureQueue = [];
|
|
60
60
|
var Queue = class {
|
|
61
61
|
k = null;
|
|
62
|
-
|
|
62
|
+
B = false;
|
|
63
63
|
g = [[], []];
|
|
64
64
|
f = [];
|
|
65
65
|
created = clock;
|
|
@@ -84,9 +84,9 @@ var Queue = class {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
flush() {
|
|
87
|
-
if (this.
|
|
87
|
+
if (this.B)
|
|
88
88
|
return;
|
|
89
|
-
this.
|
|
89
|
+
this.B = true;
|
|
90
90
|
try {
|
|
91
91
|
this.run(EFFECT_PURE);
|
|
92
92
|
incrementClock();
|
|
@@ -94,19 +94,19 @@ var Queue = class {
|
|
|
94
94
|
this.run(EFFECT_RENDER);
|
|
95
95
|
this.run(EFFECT_USER);
|
|
96
96
|
} finally {
|
|
97
|
-
this.
|
|
97
|
+
this.B = false;
|
|
98
98
|
Unobserved.length && notifyUnobserved();
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
addChild(child) {
|
|
102
|
-
if (ActiveTransition && ActiveTransition.
|
|
103
|
-
return ActiveTransition.
|
|
102
|
+
if (ActiveTransition && ActiveTransition.H.has(this))
|
|
103
|
+
return ActiveTransition.H.get(this).addChild(child);
|
|
104
104
|
this.f.push(child);
|
|
105
105
|
child.k = this;
|
|
106
106
|
}
|
|
107
107
|
removeChild(child) {
|
|
108
|
-
if (ActiveTransition && ActiveTransition.
|
|
109
|
-
return ActiveTransition.
|
|
108
|
+
if (ActiveTransition && ActiveTransition.H.has(this))
|
|
109
|
+
return ActiveTransition.H.get(this).removeChild(child);
|
|
110
110
|
const index = this.f.indexOf(child);
|
|
111
111
|
if (index >= 0) {
|
|
112
112
|
this.f.splice(index, 1);
|
|
@@ -122,7 +122,7 @@ var Queue = class {
|
|
|
122
122
|
this.g[0].push.apply(this.g[0], queue.g[0]);
|
|
123
123
|
this.g[1].push.apply(this.g[1], queue.g[1]);
|
|
124
124
|
for (let i = 0; i < queue.f.length; i++) {
|
|
125
|
-
const og = this.f.find((c) => c.
|
|
125
|
+
const og = this.f.find((c) => c.d === queue.f[i].d);
|
|
126
126
|
if (og)
|
|
127
127
|
og.merge(queue.f[i]);
|
|
128
128
|
else
|
|
@@ -141,12 +141,12 @@ function removeSourceObservers(node, index) {
|
|
|
141
141
|
let swap;
|
|
142
142
|
for (let i = index; i < node.a.length; i++) {
|
|
143
143
|
source = getTransitionSource(node.a[i]);
|
|
144
|
-
if (source.
|
|
145
|
-
if ((swap = source.
|
|
146
|
-
source.
|
|
147
|
-
source.
|
|
144
|
+
if (source.c) {
|
|
145
|
+
if ((swap = source.c.indexOf(node)) !== -1) {
|
|
146
|
+
source.c[swap] = source.c[source.c.length - 1];
|
|
147
|
+
source.c.pop();
|
|
148
148
|
}
|
|
149
|
-
if (!source.
|
|
149
|
+
if (!source.c.length)
|
|
150
150
|
Unobserved.push(source);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
@@ -157,35 +157,35 @@ function runQueue(queue, type) {
|
|
|
157
157
|
}
|
|
158
158
|
var Transition = class _Transition {
|
|
159
159
|
a = /* @__PURE__ */ new Map();
|
|
160
|
-
|
|
161
|
-
H = /* @__PURE__ */ new Set();
|
|
160
|
+
s = /* @__PURE__ */ new Set();
|
|
162
161
|
I = /* @__PURE__ */ new Set();
|
|
163
|
-
|
|
162
|
+
J = /* @__PURE__ */ new Set();
|
|
163
|
+
E = false;
|
|
164
164
|
g = [[], []];
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
H = /* @__PURE__ */ new Map();
|
|
166
|
+
K = [];
|
|
167
167
|
f = [];
|
|
168
168
|
k = null;
|
|
169
|
-
|
|
169
|
+
B = false;
|
|
170
170
|
Y = false;
|
|
171
|
-
|
|
171
|
+
d = globalQueue;
|
|
172
172
|
created = clock;
|
|
173
173
|
constructor() {
|
|
174
|
-
this.
|
|
174
|
+
this.H.set(globalQueue, this);
|
|
175
175
|
for (const child of globalQueue.f) {
|
|
176
176
|
cloneQueue(child, this, this);
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
enqueue(type, fn) {
|
|
180
|
-
this.
|
|
180
|
+
this.K.push(fn);
|
|
181
181
|
if (type)
|
|
182
182
|
this.g[type - 1].push(fn);
|
|
183
183
|
this.schedule();
|
|
184
184
|
}
|
|
185
185
|
run(type) {
|
|
186
186
|
if (type === EFFECT_PURE) {
|
|
187
|
-
this.
|
|
188
|
-
this.
|
|
187
|
+
this.K.length && runQueue(this.K, type);
|
|
188
|
+
this.K = [];
|
|
189
189
|
return;
|
|
190
190
|
} else if (this.g[type - 1].length) {
|
|
191
191
|
const effects = this.g[type - 1];
|
|
@@ -197,9 +197,9 @@ var Transition = class _Transition {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
flush() {
|
|
200
|
-
if (this.
|
|
200
|
+
if (this.B)
|
|
201
201
|
return;
|
|
202
|
-
this.
|
|
202
|
+
this.B = true;
|
|
203
203
|
let currentTransition = ActiveTransition;
|
|
204
204
|
ActiveTransition = this;
|
|
205
205
|
try {
|
|
@@ -209,7 +209,7 @@ var Transition = class _Transition {
|
|
|
209
209
|
ActiveTransition = currentTransition;
|
|
210
210
|
finishTransition(this);
|
|
211
211
|
} finally {
|
|
212
|
-
this.
|
|
212
|
+
this.B = false;
|
|
213
213
|
ActiveTransition = currentTransition;
|
|
214
214
|
}
|
|
215
215
|
}
|
|
@@ -226,18 +226,18 @@ var Transition = class _Transition {
|
|
|
226
226
|
if (!(type & LOADING_BIT))
|
|
227
227
|
return false;
|
|
228
228
|
if (flags & LOADING_BIT) {
|
|
229
|
-
this.
|
|
229
|
+
this.s.add(node);
|
|
230
230
|
} else {
|
|
231
|
-
this.
|
|
231
|
+
this.s.delete(node);
|
|
232
232
|
}
|
|
233
233
|
return true;
|
|
234
234
|
}
|
|
235
235
|
merge(queue) {
|
|
236
236
|
this.g[0].push.apply(this.g[0], queue.g[0]);
|
|
237
237
|
this.g[1].push.apply(this.g[1], queue.g[1]);
|
|
238
|
-
this.
|
|
238
|
+
this.K.push.apply(this.K, queue.K);
|
|
239
239
|
for (let i = 0; i < queue.f.length; i++) {
|
|
240
|
-
const og = this.f.find((c) => c.
|
|
240
|
+
const og = this.f.find((c) => c.d === queue.f[i].d);
|
|
241
241
|
if (og)
|
|
242
242
|
og.merge(queue.f[i]);
|
|
243
243
|
else
|
|
@@ -248,13 +248,13 @@ var Transition = class _Transition {
|
|
|
248
248
|
if (this.Y)
|
|
249
249
|
return;
|
|
250
250
|
this.Y = true;
|
|
251
|
-
if (!this.
|
|
251
|
+
if (!this.B)
|
|
252
252
|
queueMicrotask(() => this.flush());
|
|
253
253
|
}
|
|
254
254
|
runTransition(fn, force = false) {
|
|
255
|
-
if (this.
|
|
256
|
-
if (this.
|
|
257
|
-
return this.
|
|
255
|
+
if (this.E) {
|
|
256
|
+
if (this.E instanceof _Transition)
|
|
257
|
+
return this.E.runTransition(fn, force);
|
|
258
258
|
if (!force)
|
|
259
259
|
throw new Error("Transition already completed");
|
|
260
260
|
fn();
|
|
@@ -269,12 +269,12 @@ var Transition = class _Transition {
|
|
|
269
269
|
let temp, value;
|
|
270
270
|
while (!(temp = result.next(value)).done) {
|
|
271
271
|
if (temp.value instanceof Promise) {
|
|
272
|
-
transition2.
|
|
272
|
+
transition2.I.add(temp.value);
|
|
273
273
|
try {
|
|
274
274
|
value = await temp.value;
|
|
275
275
|
} finally {
|
|
276
276
|
transition2 = latestTransition(transition2);
|
|
277
|
-
transition2.
|
|
277
|
+
transition2.I.delete(temp.value);
|
|
278
278
|
}
|
|
279
279
|
ActiveTransition = transition2;
|
|
280
280
|
} else
|
|
@@ -285,10 +285,10 @@ var Transition = class _Transition {
|
|
|
285
285
|
})();
|
|
286
286
|
}
|
|
287
287
|
if (result instanceof Promise) {
|
|
288
|
-
transition2.
|
|
288
|
+
transition2.I.add(result);
|
|
289
289
|
result.finally(() => {
|
|
290
290
|
transition2 = latestTransition(transition2);
|
|
291
|
-
transition2.
|
|
291
|
+
transition2.I.delete(result);
|
|
292
292
|
ActiveTransition = null;
|
|
293
293
|
finishTransition(transition2);
|
|
294
294
|
});
|
|
@@ -306,7 +306,7 @@ var Transition = class _Transition {
|
|
|
306
306
|
return;
|
|
307
307
|
}
|
|
308
308
|
fn.j = this;
|
|
309
|
-
this.
|
|
309
|
+
this.J.add(fn);
|
|
310
310
|
}
|
|
311
311
|
};
|
|
312
312
|
function transition(fn) {
|
|
@@ -325,29 +325,29 @@ function cloneGraph(node, optimistic) {
|
|
|
325
325
|
Object.assign(clone, node, {
|
|
326
326
|
n: null,
|
|
327
327
|
m: null,
|
|
328
|
-
|
|
328
|
+
c: null,
|
|
329
329
|
a: node.a ? [...node.a] : null,
|
|
330
|
-
|
|
331
|
-
|
|
330
|
+
d: node,
|
|
331
|
+
J: !!optimistic
|
|
332
332
|
});
|
|
333
|
-
delete clone.
|
|
333
|
+
delete clone.T;
|
|
334
334
|
ActiveTransition.a.set(node, clone);
|
|
335
335
|
node.j = ActiveTransition;
|
|
336
336
|
if (!optimistic && node.a) {
|
|
337
337
|
for (let i = 0; i < node.a.length; i++)
|
|
338
|
-
node.a[i].
|
|
338
|
+
node.a[i].c.push(clone);
|
|
339
339
|
}
|
|
340
|
-
if (node.
|
|
341
|
-
clone.
|
|
342
|
-
for (let i = 0, length = node.
|
|
343
|
-
!node.
|
|
340
|
+
if (node.c) {
|
|
341
|
+
clone.c = [];
|
|
342
|
+
for (let i = 0, length = node.c.length; i < length; i++) {
|
|
343
|
+
!node.c[i].d && clone.c.push(cloneGraph(node.c[i], optimistic));
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
return clone;
|
|
347
347
|
}
|
|
348
348
|
function latestTransition(t) {
|
|
349
|
-
while (t.
|
|
350
|
-
t = t.
|
|
349
|
+
while (t.E instanceof Transition)
|
|
350
|
+
t = t.E;
|
|
351
351
|
return t;
|
|
352
352
|
}
|
|
353
353
|
function replaceSourceObservers(node, transition2) {
|
|
@@ -357,16 +357,16 @@ function replaceSourceObservers(node, transition2) {
|
|
|
357
357
|
for (let i = 0; i < node.a.length; i++) {
|
|
358
358
|
transitionSource = transition2.a.get(node.a[i]);
|
|
359
359
|
source = transitionSource || node.a[i];
|
|
360
|
-
if (source.
|
|
361
|
-
source.
|
|
362
|
-
!transitionSource && source.
|
|
360
|
+
if (source.c && (swap = source.c.indexOf(node)) !== -1) {
|
|
361
|
+
source.c[swap] = transitionSource ? node.d : source.c[source.c.length - 1];
|
|
362
|
+
!transitionSource && source.c.pop();
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
function cloneQueue(queue, parent, transition2) {
|
|
367
367
|
const clone = Object.create(Object.getPrototypeOf(queue));
|
|
368
368
|
Object.assign(clone, queue, {
|
|
369
|
-
|
|
369
|
+
d: queue,
|
|
370
370
|
k: parent,
|
|
371
371
|
f: [],
|
|
372
372
|
enqueue(type, fn) {
|
|
@@ -374,8 +374,8 @@ function cloneQueue(queue, parent, transition2) {
|
|
|
374
374
|
transition2.enqueue(type, fn);
|
|
375
375
|
},
|
|
376
376
|
notify(node, type, flags) {
|
|
377
|
-
node = node.
|
|
378
|
-
if (!clone.
|
|
377
|
+
node = node.d || node;
|
|
378
|
+
if (!clone.L || type & LOADING_BIT) {
|
|
379
379
|
type &= ~LOADING_BIT;
|
|
380
380
|
transition2 = latestTransition(transition2);
|
|
381
381
|
transition2.notify(node, LOADING_BIT, flags);
|
|
@@ -386,14 +386,14 @@ function cloneQueue(queue, parent, transition2) {
|
|
|
386
386
|
}
|
|
387
387
|
});
|
|
388
388
|
parent.f.push(clone);
|
|
389
|
-
transition2.
|
|
389
|
+
transition2.H.set(queue, clone);
|
|
390
390
|
for (const child of queue.f) {
|
|
391
391
|
cloneQueue(child, clone, transition2);
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
394
|
function resolveQueues(children) {
|
|
395
395
|
for (const child of children) {
|
|
396
|
-
const og = child.
|
|
396
|
+
const og = child.d;
|
|
397
397
|
if (og) {
|
|
398
398
|
const clonedChildren = child.f;
|
|
399
399
|
delete child.enqueue;
|
|
@@ -401,10 +401,10 @@ function resolveQueues(children) {
|
|
|
401
401
|
delete child.k;
|
|
402
402
|
delete child.f;
|
|
403
403
|
Object.assign(og, child);
|
|
404
|
-
delete og.
|
|
404
|
+
delete og.d;
|
|
405
405
|
resolveQueues(clonedChildren);
|
|
406
|
-
} else if (child.k.
|
|
407
|
-
child.k.
|
|
406
|
+
} else if (child.k.d) {
|
|
407
|
+
child.k.d.addChild(child);
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
}
|
|
@@ -413,21 +413,21 @@ function mergeTransitions(t1, t2) {
|
|
|
413
413
|
key.j = t1;
|
|
414
414
|
t1.a.set(key, value);
|
|
415
415
|
});
|
|
416
|
-
t2.
|
|
416
|
+
t2.J.forEach((c) => {
|
|
417
417
|
c.j = t1;
|
|
418
|
-
t1.
|
|
418
|
+
t1.J.add(c);
|
|
419
419
|
});
|
|
420
|
-
t2.
|
|
421
|
-
t2.
|
|
420
|
+
t2.I.forEach((p) => t1.I.add(p));
|
|
421
|
+
t2.s.forEach((n) => t1.s.add(n));
|
|
422
422
|
t1.merge(t2);
|
|
423
|
-
t2.
|
|
423
|
+
t2.E = t1;
|
|
424
424
|
}
|
|
425
425
|
function getTransitionSource(input) {
|
|
426
426
|
return ActiveTransition && ActiveTransition.a.get(input) || input;
|
|
427
427
|
}
|
|
428
428
|
function getQueue(node) {
|
|
429
|
-
const transition2 = ActiveTransition || node.
|
|
430
|
-
return transition2 && transition2.
|
|
429
|
+
const transition2 = ActiveTransition || node.d?.j;
|
|
430
|
+
return transition2 && transition2.H.get(node.C) || node.C;
|
|
431
431
|
}
|
|
432
432
|
function initialDispose(node) {
|
|
433
433
|
let current = node.m;
|
|
@@ -440,7 +440,7 @@ function initialDispose(node) {
|
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
442
|
function finishTransition(transition2) {
|
|
443
|
-
if (transition2.
|
|
443
|
+
if (transition2.E || transition2.Y || transition2.I.size || transition2.s.size)
|
|
444
444
|
return;
|
|
445
445
|
globalQueue.g[0].push.apply(globalQueue.g[0], transition2.g[0]);
|
|
446
446
|
globalQueue.g[1].push.apply(globalQueue.g[1], transition2.g[1]);
|
|
@@ -452,14 +452,14 @@ function finishTransition(transition2) {
|
|
|
452
452
|
}
|
|
453
453
|
if (clone.a)
|
|
454
454
|
replaceSourceObservers(clone, transition2);
|
|
455
|
-
if (clone.
|
|
455
|
+
if (clone.J) {
|
|
456
456
|
clone.dispose();
|
|
457
457
|
clone.emptyDisposal();
|
|
458
458
|
delete source.j;
|
|
459
459
|
continue;
|
|
460
460
|
}
|
|
461
|
-
if (clone.Z || clone.
|
|
462
|
-
source.dispose(clone.
|
|
461
|
+
if (clone.Z || clone.b === STATE_DISPOSED) {
|
|
462
|
+
source.dispose(clone.b === STATE_DISPOSED);
|
|
463
463
|
source.emptyDisposal();
|
|
464
464
|
delete clone.Z;
|
|
465
465
|
} else {
|
|
@@ -467,18 +467,18 @@ function finishTransition(transition2) {
|
|
|
467
467
|
delete clone.n;
|
|
468
468
|
}
|
|
469
469
|
Object.assign(source, clone);
|
|
470
|
-
delete source.
|
|
470
|
+
delete source.d;
|
|
471
471
|
let current = clone.m;
|
|
472
|
-
if (current?.
|
|
473
|
-
current.
|
|
472
|
+
if (current?.y === clone)
|
|
473
|
+
current.y = source;
|
|
474
474
|
while (current?.k === clone) {
|
|
475
475
|
current.k = source;
|
|
476
476
|
current = current.m;
|
|
477
477
|
}
|
|
478
478
|
delete source.j;
|
|
479
479
|
}
|
|
480
|
-
transition2.
|
|
481
|
-
for (const reset of transition2.
|
|
480
|
+
transition2.E = true;
|
|
481
|
+
for (const reset of transition2.J) {
|
|
482
482
|
delete reset.j;
|
|
483
483
|
reset();
|
|
484
484
|
}
|
|
@@ -502,11 +502,11 @@ var Owner = class {
|
|
|
502
502
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
503
503
|
k = null;
|
|
504
504
|
m = null;
|
|
505
|
-
|
|
506
|
-
|
|
505
|
+
y = null;
|
|
506
|
+
b = STATE_CLEAN;
|
|
507
507
|
n = null;
|
|
508
|
-
|
|
509
|
-
|
|
508
|
+
z = defaultContext;
|
|
509
|
+
C = globalQueue;
|
|
510
510
|
fa = 0;
|
|
511
511
|
id = null;
|
|
512
512
|
constructor(id = null, skipAppend = false) {
|
|
@@ -517,23 +517,23 @@ var Owner = class {
|
|
|
517
517
|
}
|
|
518
518
|
append(child) {
|
|
519
519
|
child.k = this;
|
|
520
|
-
child.
|
|
520
|
+
child.y = this;
|
|
521
521
|
if (this.m)
|
|
522
|
-
this.m.
|
|
522
|
+
this.m.y = child;
|
|
523
523
|
child.m = this.m;
|
|
524
524
|
this.m = child;
|
|
525
525
|
if (this.id != null && child.id == null)
|
|
526
526
|
child.id = this.getNextChildId();
|
|
527
|
-
if (child.
|
|
528
|
-
child.
|
|
527
|
+
if (child.z !== this.z) {
|
|
528
|
+
child.z = { ...this.z, ...child.z };
|
|
529
529
|
}
|
|
530
|
-
if (this.
|
|
531
|
-
child.
|
|
530
|
+
if (this.C)
|
|
531
|
+
child.C = this.C;
|
|
532
532
|
}
|
|
533
533
|
dispose(self = true) {
|
|
534
|
-
if (this.
|
|
534
|
+
if (this.b === STATE_DISPOSED)
|
|
535
535
|
return;
|
|
536
|
-
let head = self ? this.
|
|
536
|
+
let head = self ? this.y || this.k : this, current = this.m, next = null;
|
|
537
537
|
while (current && current.k === this) {
|
|
538
538
|
current.dispose(true);
|
|
539
539
|
next = current.m;
|
|
@@ -542,19 +542,19 @@ var Owner = class {
|
|
|
542
542
|
}
|
|
543
543
|
this.fa = 0;
|
|
544
544
|
if (self)
|
|
545
|
-
this.
|
|
545
|
+
this.M();
|
|
546
546
|
if (current)
|
|
547
|
-
current.
|
|
547
|
+
current.y = !self ? this : this.y;
|
|
548
548
|
if (head)
|
|
549
549
|
head.m = current;
|
|
550
550
|
}
|
|
551
|
-
|
|
552
|
-
if (this.
|
|
553
|
-
this.
|
|
551
|
+
M() {
|
|
552
|
+
if (this.y)
|
|
553
|
+
this.y.m = null;
|
|
554
554
|
this.k = null;
|
|
555
|
-
this.
|
|
556
|
-
this.
|
|
557
|
-
this.
|
|
555
|
+
this.y = null;
|
|
556
|
+
this.z = defaultContext;
|
|
557
|
+
this.b = STATE_DISPOSED;
|
|
558
558
|
this.emptyDisposal();
|
|
559
559
|
}
|
|
560
560
|
emptyDisposal() {
|
|
@@ -583,7 +583,7 @@ function getContext(context, owner = currentOwner) {
|
|
|
583
583
|
if (!owner) {
|
|
584
584
|
throw new NoOwnerError();
|
|
585
585
|
}
|
|
586
|
-
const value = hasContext(context, owner) ? owner.
|
|
586
|
+
const value = hasContext(context, owner) ? owner.z[context.id] : context.defaultValue;
|
|
587
587
|
if (isUndefined(value)) {
|
|
588
588
|
throw new ContextNotFoundError();
|
|
589
589
|
}
|
|
@@ -593,13 +593,13 @@ function setContext(context, value, owner = currentOwner) {
|
|
|
593
593
|
if (!owner) {
|
|
594
594
|
throw new NoOwnerError();
|
|
595
595
|
}
|
|
596
|
-
owner.
|
|
597
|
-
...owner.
|
|
596
|
+
owner.z = {
|
|
597
|
+
...owner.z,
|
|
598
598
|
[context.id]: isUndefined(value) ? context.defaultValue : value
|
|
599
599
|
};
|
|
600
600
|
}
|
|
601
601
|
function hasContext(context, owner = currentOwner) {
|
|
602
|
-
return !isUndefined(owner?.
|
|
602
|
+
return !isUndefined(owner?.z[context.id]);
|
|
603
603
|
}
|
|
604
604
|
function onCleanup(fn) {
|
|
605
605
|
if (!currentOwner)
|
|
@@ -637,10 +637,10 @@ function getObserver() {
|
|
|
637
637
|
var UNCHANGED = Symbol(0);
|
|
638
638
|
var Computation = class extends Owner {
|
|
639
639
|
a = null;
|
|
640
|
-
|
|
640
|
+
c = null;
|
|
641
641
|
l;
|
|
642
|
-
|
|
643
|
-
|
|
642
|
+
O;
|
|
643
|
+
P;
|
|
644
644
|
// Used in __DEV__ mode, hopefully removed in production
|
|
645
645
|
la;
|
|
646
646
|
// Using false is an optimization as an alternative to _equals: () => false
|
|
@@ -649,19 +649,19 @@ var Computation = class extends Owner {
|
|
|
649
649
|
ea;
|
|
650
650
|
ha = false;
|
|
651
651
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
652
|
-
|
|
652
|
+
i = 0;
|
|
653
653
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
654
654
|
ba = DEFAULT_FLAGS;
|
|
655
|
-
|
|
656
|
-
|
|
655
|
+
Q = -1;
|
|
656
|
+
F = false;
|
|
657
657
|
j;
|
|
658
|
-
|
|
659
|
-
|
|
658
|
+
d;
|
|
659
|
+
J = false;
|
|
660
660
|
constructor(initialValue, compute2, options) {
|
|
661
661
|
super(options?.id, compute2 === null);
|
|
662
|
-
this.
|
|
663
|
-
this.
|
|
664
|
-
this.
|
|
662
|
+
this.P = compute2;
|
|
663
|
+
this.b = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
664
|
+
this.i = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
665
665
|
this.l = initialValue;
|
|
666
666
|
if (options?.equals !== void 0)
|
|
667
667
|
this.aa = options.equals;
|
|
@@ -674,9 +674,9 @@ var Computation = class extends Owner {
|
|
|
674
674
|
}
|
|
675
675
|
ga() {
|
|
676
676
|
track(this);
|
|
677
|
-
newFlags |= this.
|
|
678
|
-
if (this.
|
|
679
|
-
throw this.
|
|
677
|
+
newFlags |= this.i & ~currentMask;
|
|
678
|
+
if (this.i & ERROR_BIT) {
|
|
679
|
+
throw this.O;
|
|
680
680
|
} else {
|
|
681
681
|
return this.l;
|
|
682
682
|
}
|
|
@@ -686,16 +686,16 @@ var Computation = class extends Owner {
|
|
|
686
686
|
* Automatically re-executes the surrounding computation when the value changes
|
|
687
687
|
*/
|
|
688
688
|
read() {
|
|
689
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.
|
|
689
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.i & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
690
690
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
691
691
|
if (clone !== this)
|
|
692
692
|
return clone.read();
|
|
693
693
|
}
|
|
694
|
-
if (this.
|
|
695
|
-
if (this.
|
|
694
|
+
if (this.P) {
|
|
695
|
+
if (this.i & ERROR_BIT && this.Q <= clock)
|
|
696
696
|
update(this);
|
|
697
697
|
else
|
|
698
|
-
this.
|
|
698
|
+
this.D();
|
|
699
699
|
}
|
|
700
700
|
return this.ga();
|
|
701
701
|
}
|
|
@@ -707,49 +707,49 @@ var Computation = class extends Owner {
|
|
|
707
707
|
* before continuing
|
|
708
708
|
*/
|
|
709
709
|
wait() {
|
|
710
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.
|
|
710
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.i & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
711
711
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
712
712
|
if (clone !== this)
|
|
713
713
|
return clone.wait();
|
|
714
714
|
}
|
|
715
|
-
if (this.
|
|
716
|
-
if (this.
|
|
715
|
+
if (this.P) {
|
|
716
|
+
if (this.i & ERROR_BIT && this.Q <= clock)
|
|
717
717
|
update(this);
|
|
718
718
|
else
|
|
719
|
-
this.
|
|
719
|
+
this.D();
|
|
720
720
|
}
|
|
721
|
-
if ((notStale || this.
|
|
721
|
+
if ((notStale || this.i & UNINITIALIZED_BIT) && this.i & LOADING_BIT) {
|
|
722
722
|
track(this);
|
|
723
723
|
throw new NotReadyError();
|
|
724
724
|
}
|
|
725
|
-
if (staleCheck && this.
|
|
725
|
+
if (staleCheck && this.i & LOADING_BIT) {
|
|
726
726
|
staleCheck.l = true;
|
|
727
727
|
}
|
|
728
728
|
return this.ga();
|
|
729
729
|
}
|
|
730
730
|
/** Update the computation with a new value. */
|
|
731
731
|
write(value, flags = 0, raw = false) {
|
|
732
|
-
if (ActiveTransition && !this.
|
|
732
|
+
if (ActiveTransition && !this.d) {
|
|
733
733
|
const clone = cloneGraph(this);
|
|
734
734
|
if (clone !== this)
|
|
735
735
|
return clone.write(value, flags, raw);
|
|
736
736
|
}
|
|
737
737
|
const newValue = !raw && typeof value === "function" ? value(this.l) : value;
|
|
738
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
738
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.i & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
|
|
739
739
|
this.aa === false || !this.aa(this.l, newValue));
|
|
740
740
|
if (valueChanged) {
|
|
741
741
|
this.l = newValue;
|
|
742
|
-
this.
|
|
742
|
+
this.O = void 0;
|
|
743
743
|
}
|
|
744
|
-
const changedFlagsMask = this.
|
|
745
|
-
this.
|
|
746
|
-
this.
|
|
747
|
-
if (this.
|
|
748
|
-
for (let i = 0; i < this.
|
|
744
|
+
const changedFlagsMask = this.i ^ flags, changedFlags = changedFlagsMask & flags;
|
|
745
|
+
this.i = flags;
|
|
746
|
+
this.Q = clock + 1;
|
|
747
|
+
if (this.c) {
|
|
748
|
+
for (let i = 0; i < this.c.length; i++) {
|
|
749
749
|
if (valueChanged) {
|
|
750
|
-
this.
|
|
750
|
+
this.c[i].t(STATE_DIRTY);
|
|
751
751
|
} else if (changedFlagsMask) {
|
|
752
|
-
this.
|
|
752
|
+
this.c[i]._(changedFlagsMask, changedFlags);
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
755
|
}
|
|
@@ -758,14 +758,14 @@ var Computation = class extends Owner {
|
|
|
758
758
|
/**
|
|
759
759
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
760
760
|
*/
|
|
761
|
-
|
|
762
|
-
if (this.
|
|
761
|
+
t(state, skipQueue) {
|
|
762
|
+
if (this.b >= state && !this.F)
|
|
763
763
|
return;
|
|
764
|
-
this.
|
|
765
|
-
this.
|
|
766
|
-
if (this.
|
|
767
|
-
for (let i = 0; i < this.
|
|
768
|
-
this.
|
|
764
|
+
this.F = !!skipQueue;
|
|
765
|
+
this.b = state;
|
|
766
|
+
if (this.c) {
|
|
767
|
+
for (let i = 0; i < this.c.length; i++) {
|
|
768
|
+
this.c[i].t(STATE_CHECK, skipQueue);
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
771
|
}
|
|
@@ -776,35 +776,35 @@ var Computation = class extends Owner {
|
|
|
776
776
|
* @param newFlags The source's new flags, masked to just the changed ones.
|
|
777
777
|
*/
|
|
778
778
|
_(mask, newFlags2) {
|
|
779
|
-
if (this.
|
|
779
|
+
if (this.b >= STATE_DIRTY)
|
|
780
780
|
return;
|
|
781
781
|
if (mask & this.ba) {
|
|
782
|
-
this.
|
|
782
|
+
this.t(STATE_DIRTY);
|
|
783
783
|
return;
|
|
784
784
|
}
|
|
785
|
-
if (this.
|
|
785
|
+
if (this.b >= STATE_CHECK && !this.F)
|
|
786
786
|
return;
|
|
787
|
-
const prevFlags = this.
|
|
787
|
+
const prevFlags = this.i & mask;
|
|
788
788
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
789
789
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
790
|
-
this.
|
|
790
|
+
this.t(STATE_CHECK);
|
|
791
791
|
} else {
|
|
792
|
-
this.
|
|
793
|
-
if (this.
|
|
794
|
-
for (let i = 0; i < this.
|
|
795
|
-
this.
|
|
792
|
+
this.i ^= deltaFlags;
|
|
793
|
+
if (this.c) {
|
|
794
|
+
for (let i = 0; i < this.c.length; i++) {
|
|
795
|
+
this.c[i]._(mask, newFlags2);
|
|
796
796
|
}
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
|
-
|
|
801
|
-
if (ActiveTransition && !this.
|
|
800
|
+
N(error) {
|
|
801
|
+
if (ActiveTransition && !this.d) {
|
|
802
802
|
const clone = cloneGraph(this);
|
|
803
803
|
if (clone !== this)
|
|
804
|
-
return clone.
|
|
804
|
+
return clone.N(error);
|
|
805
805
|
}
|
|
806
|
-
this.
|
|
807
|
-
this.write(UNCHANGED, this.
|
|
806
|
+
this.O = error;
|
|
807
|
+
this.write(UNCHANGED, this.i & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
808
808
|
}
|
|
809
809
|
/**
|
|
810
810
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -813,48 +813,48 @@ var Computation = class extends Owner {
|
|
|
813
813
|
*
|
|
814
814
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
815
815
|
*/
|
|
816
|
-
|
|
817
|
-
if (!this.
|
|
816
|
+
D() {
|
|
817
|
+
if (!this.P) {
|
|
818
818
|
return;
|
|
819
819
|
}
|
|
820
|
-
if (this.
|
|
820
|
+
if (this.b === STATE_DISPOSED) {
|
|
821
821
|
return;
|
|
822
822
|
}
|
|
823
|
-
if (this.
|
|
823
|
+
if (this.b === STATE_CLEAN) {
|
|
824
824
|
return;
|
|
825
825
|
}
|
|
826
826
|
let observerFlags = 0;
|
|
827
|
-
if (this.
|
|
827
|
+
if (this.b === STATE_CHECK) {
|
|
828
828
|
for (let i = 0; i < this.a.length; i++) {
|
|
829
829
|
const source = getTransitionSource(this.a[i]);
|
|
830
|
-
source.
|
|
831
|
-
observerFlags |= source.
|
|
832
|
-
if (this.
|
|
830
|
+
source.D();
|
|
831
|
+
observerFlags |= source.i & ~UNINITIALIZED_BIT;
|
|
832
|
+
if (this.b === STATE_DIRTY) {
|
|
833
833
|
break;
|
|
834
834
|
}
|
|
835
835
|
}
|
|
836
836
|
}
|
|
837
|
-
if (this.
|
|
837
|
+
if (this.b === STATE_DIRTY) {
|
|
838
838
|
update(this);
|
|
839
839
|
} else {
|
|
840
840
|
this.write(UNCHANGED, observerFlags);
|
|
841
|
-
this.
|
|
841
|
+
this.b = STATE_CLEAN;
|
|
842
842
|
}
|
|
843
843
|
}
|
|
844
844
|
/**
|
|
845
845
|
* Remove ourselves from the owner graph and the computation graph
|
|
846
846
|
*/
|
|
847
|
-
|
|
848
|
-
if (this.
|
|
847
|
+
M() {
|
|
848
|
+
if (this.b === STATE_DISPOSED)
|
|
849
849
|
return;
|
|
850
850
|
if (this.a)
|
|
851
851
|
removeSourceObservers(this, 0);
|
|
852
|
-
super.
|
|
852
|
+
super.M();
|
|
853
853
|
}
|
|
854
854
|
};
|
|
855
855
|
function track(computation) {
|
|
856
|
-
if (ActiveTransition && computation.
|
|
857
|
-
computation = computation.
|
|
856
|
+
if (ActiveTransition && computation.d)
|
|
857
|
+
computation = computation.d;
|
|
858
858
|
if (currentObserver) {
|
|
859
859
|
if (!newSources && currentObserver.a && currentObserver.a[newSourcesIndex] === computation) {
|
|
860
860
|
newSourcesIndex++;
|
|
@@ -864,7 +864,7 @@ function track(computation) {
|
|
|
864
864
|
newSources.push(computation);
|
|
865
865
|
}
|
|
866
866
|
if (updateCheck) {
|
|
867
|
-
updateCheck.l = computation.
|
|
867
|
+
updateCheck.l = computation.Q > currentObserver.Q;
|
|
868
868
|
}
|
|
869
869
|
}
|
|
870
870
|
}
|
|
@@ -874,19 +874,19 @@ function update(node) {
|
|
|
874
874
|
newSourcesIndex = 0;
|
|
875
875
|
newFlags = 0;
|
|
876
876
|
try {
|
|
877
|
-
if (ActiveTransition && node.
|
|
878
|
-
initialDispose(node.
|
|
877
|
+
if (ActiveTransition && node.d && !node.Z) {
|
|
878
|
+
initialDispose(node.d);
|
|
879
879
|
node.Z = true;
|
|
880
880
|
}
|
|
881
881
|
node.dispose(false);
|
|
882
882
|
node.emptyDisposal();
|
|
883
|
-
const result = compute(node, node.
|
|
883
|
+
const result = compute(node, node.P, node);
|
|
884
884
|
node.write(result, newFlags, true);
|
|
885
885
|
} catch (error) {
|
|
886
886
|
if (error instanceof NotReadyError) {
|
|
887
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.
|
|
887
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.i & UNINITIALIZED_BIT);
|
|
888
888
|
} else {
|
|
889
|
-
node.
|
|
889
|
+
node.N(error);
|
|
890
890
|
}
|
|
891
891
|
} finally {
|
|
892
892
|
if (newSources) {
|
|
@@ -903,10 +903,10 @@ function update(node) {
|
|
|
903
903
|
let source;
|
|
904
904
|
for (let i = newSourcesIndex; i < node.a.length; i++) {
|
|
905
905
|
source = getTransitionSource(node.a[i]);
|
|
906
|
-
if (!source.
|
|
907
|
-
source.
|
|
906
|
+
if (!source.c)
|
|
907
|
+
source.c = [node];
|
|
908
908
|
else
|
|
909
|
-
source.
|
|
909
|
+
source.c.push(node);
|
|
910
910
|
}
|
|
911
911
|
} else if (node.a && newSourcesIndex < node.a.length) {
|
|
912
912
|
removeSourceObservers(node, newSourcesIndex);
|
|
@@ -915,8 +915,8 @@ function update(node) {
|
|
|
915
915
|
newSources = prevSources;
|
|
916
916
|
newSourcesIndex = prevSourcesIndex;
|
|
917
917
|
newFlags = prevFlags;
|
|
918
|
-
node.
|
|
919
|
-
node.
|
|
918
|
+
node.Q = clock + 1;
|
|
919
|
+
node.b = STATE_CLEAN;
|
|
920
920
|
}
|
|
921
921
|
}
|
|
922
922
|
function isEqual(a, b) {
|
|
@@ -976,46 +976,6 @@ function latest(fn, fallback) {
|
|
|
976
976
|
notStale = prevNotStale;
|
|
977
977
|
}
|
|
978
978
|
}
|
|
979
|
-
function runWithObserver(observer, run) {
|
|
980
|
-
const prevSources = newSources, prevSourcesIndex = newSourcesIndex, prevFlags = newFlags;
|
|
981
|
-
newSources = null;
|
|
982
|
-
newSourcesIndex = observer.a ? observer.a.length : 0;
|
|
983
|
-
newFlags = 0;
|
|
984
|
-
try {
|
|
985
|
-
return compute(observer, run, observer);
|
|
986
|
-
} catch (error) {
|
|
987
|
-
if (error instanceof NotReadyError) {
|
|
988
|
-
observer.write(
|
|
989
|
-
UNCHANGED,
|
|
990
|
-
newFlags | LOADING_BIT | observer.h & UNINITIALIZED_BIT
|
|
991
|
-
);
|
|
992
|
-
} else {
|
|
993
|
-
observer.D(error);
|
|
994
|
-
}
|
|
995
|
-
} finally {
|
|
996
|
-
if (newSources) {
|
|
997
|
-
if (newSourcesIndex > 0) {
|
|
998
|
-
observer.a.length = newSourcesIndex + newSources.length;
|
|
999
|
-
for (let i = 0; i < newSources.length; i++) {
|
|
1000
|
-
observer.a[newSourcesIndex + i] = newSources[i];
|
|
1001
|
-
}
|
|
1002
|
-
} else {
|
|
1003
|
-
observer.a = newSources;
|
|
1004
|
-
}
|
|
1005
|
-
let source;
|
|
1006
|
-
for (let i = newSourcesIndex; i < observer.a.length; i++) {
|
|
1007
|
-
source = observer.a[i];
|
|
1008
|
-
if (!source.b)
|
|
1009
|
-
source.b = [observer];
|
|
1010
|
-
else
|
|
1011
|
-
source.b.push(observer);
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
newSources = prevSources;
|
|
1015
|
-
newSourcesIndex = prevSourcesIndex;
|
|
1016
|
-
newFlags = prevFlags;
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
979
|
function compute(owner, fn, observer) {
|
|
1020
980
|
const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
|
|
1021
981
|
currentObserver = observer;
|
|
@@ -1035,65 +995,65 @@ function compute(owner, fn, observer) {
|
|
|
1035
995
|
var Effect = class extends Computation {
|
|
1036
996
|
ca;
|
|
1037
997
|
$;
|
|
1038
|
-
|
|
998
|
+
u;
|
|
1039
999
|
da = false;
|
|
1040
|
-
|
|
1041
|
-
|
|
1000
|
+
T;
|
|
1001
|
+
r;
|
|
1042
1002
|
constructor(initialValue, compute2, effect, error, options) {
|
|
1043
1003
|
super(initialValue, compute2, options);
|
|
1044
1004
|
this.ca = effect;
|
|
1045
1005
|
this.$ = error;
|
|
1046
|
-
this.
|
|
1047
|
-
this.
|
|
1048
|
-
if (this.
|
|
1049
|
-
this.
|
|
1050
|
-
return !this.
|
|
1006
|
+
this.T = initialValue;
|
|
1007
|
+
this.r = options?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
1008
|
+
if (this.r === EFFECT_RENDER) {
|
|
1009
|
+
this.P = function(p) {
|
|
1010
|
+
return !this.d && clock > this.C.created && !(this.i & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
1051
1011
|
};
|
|
1052
1012
|
}
|
|
1053
|
-
this.
|
|
1054
|
-
!options?.defer && (this.
|
|
1013
|
+
this.D();
|
|
1014
|
+
!options?.defer && (this.r === EFFECT_USER ? getQueue(this).enqueue(this.r, this.w.bind(this)) : this.w(this.r));
|
|
1055
1015
|
}
|
|
1056
1016
|
write(value, flags = 0) {
|
|
1057
|
-
if (this.
|
|
1058
|
-
this.
|
|
1059
|
-
if (this.
|
|
1060
|
-
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.
|
|
1017
|
+
if (this.b == STATE_DIRTY) {
|
|
1018
|
+
this.i = flags;
|
|
1019
|
+
if (this.r === EFFECT_RENDER) {
|
|
1020
|
+
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.i);
|
|
1061
1021
|
}
|
|
1062
1022
|
}
|
|
1063
1023
|
if (value === UNCHANGED)
|
|
1064
1024
|
return this.l;
|
|
1065
1025
|
this.l = value;
|
|
1066
1026
|
this.da = true;
|
|
1067
|
-
this.
|
|
1027
|
+
this.O = void 0;
|
|
1068
1028
|
return value;
|
|
1069
1029
|
}
|
|
1070
|
-
|
|
1071
|
-
if (this.
|
|
1030
|
+
t(state, skipQueue) {
|
|
1031
|
+
if (this.b >= state || skipQueue)
|
|
1072
1032
|
return;
|
|
1073
|
-
if (this.
|
|
1074
|
-
getQueue(this).enqueue(this.
|
|
1075
|
-
this.
|
|
1033
|
+
if (this.b === STATE_CLEAN || this.d && !ActiveTransition)
|
|
1034
|
+
getQueue(this).enqueue(this.r, this.w.bind(this));
|
|
1035
|
+
this.b = state;
|
|
1076
1036
|
}
|
|
1077
1037
|
_(mask, newFlags2) {
|
|
1078
|
-
if (this.
|
|
1079
|
-
if (this.
|
|
1038
|
+
if (this.d) {
|
|
1039
|
+
if (this.b >= STATE_DIRTY)
|
|
1080
1040
|
return;
|
|
1081
1041
|
if (mask & 3) {
|
|
1082
|
-
this.
|
|
1042
|
+
this.t(STATE_DIRTY);
|
|
1083
1043
|
return;
|
|
1084
1044
|
}
|
|
1085
1045
|
}
|
|
1086
1046
|
super._(mask, newFlags2);
|
|
1087
1047
|
}
|
|
1088
|
-
|
|
1089
|
-
this.
|
|
1048
|
+
N(error) {
|
|
1049
|
+
this.O = error;
|
|
1090
1050
|
getQueue(this).notify(this, LOADING_BIT, 0);
|
|
1091
|
-
this.
|
|
1092
|
-
if (this.
|
|
1051
|
+
this.i = ERROR_BIT;
|
|
1052
|
+
if (this.r === EFFECT_USER) {
|
|
1093
1053
|
try {
|
|
1094
1054
|
return this.$ ? this.$(error, () => {
|
|
1095
|
-
this.
|
|
1096
|
-
this.
|
|
1055
|
+
this.u?.();
|
|
1056
|
+
this.u = void 0;
|
|
1097
1057
|
}) : console.error(error);
|
|
1098
1058
|
} catch (e) {
|
|
1099
1059
|
error = e;
|
|
@@ -1102,50 +1062,81 @@ var Effect = class extends Computation {
|
|
|
1102
1062
|
if (!getQueue(this).notify(this, ERROR_BIT, ERROR_BIT))
|
|
1103
1063
|
throw error;
|
|
1104
1064
|
}
|
|
1105
|
-
|
|
1106
|
-
if (this.
|
|
1065
|
+
M() {
|
|
1066
|
+
if (this.b === STATE_DISPOSED)
|
|
1107
1067
|
return;
|
|
1108
1068
|
this.ca = void 0;
|
|
1109
|
-
this.
|
|
1069
|
+
this.T = void 0;
|
|
1110
1070
|
this.$ = void 0;
|
|
1111
|
-
this.
|
|
1112
|
-
this.
|
|
1071
|
+
this.u?.();
|
|
1072
|
+
this.u = void 0;
|
|
1113
1073
|
getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
|
|
1114
|
-
super.
|
|
1074
|
+
super.M();
|
|
1115
1075
|
}
|
|
1116
|
-
|
|
1076
|
+
w(type) {
|
|
1117
1077
|
if (type) {
|
|
1118
|
-
const effect = this.
|
|
1119
|
-
if (effect.da && effect.
|
|
1120
|
-
effect.
|
|
1078
|
+
const effect = this.d || this;
|
|
1079
|
+
if (effect.da && effect.b !== STATE_DISPOSED) {
|
|
1080
|
+
effect.u?.();
|
|
1121
1081
|
try {
|
|
1122
|
-
effect.
|
|
1082
|
+
effect.u = effect.ca(effect.l, effect.T);
|
|
1123
1083
|
} catch (e) {
|
|
1124
1084
|
if (!getQueue(effect).notify(effect, ERROR_BIT, ERROR_BIT))
|
|
1125
1085
|
throw e;
|
|
1126
1086
|
} finally {
|
|
1127
|
-
effect.
|
|
1087
|
+
effect.T = effect.l;
|
|
1128
1088
|
effect.da = false;
|
|
1129
1089
|
}
|
|
1130
1090
|
}
|
|
1131
1091
|
} else
|
|
1132
|
-
this.
|
|
1092
|
+
this.b !== STATE_CLEAN && runTop(this);
|
|
1093
|
+
}
|
|
1094
|
+
};
|
|
1095
|
+
var TrackedEffect = class extends Computation {
|
|
1096
|
+
r = EFFECT_USER;
|
|
1097
|
+
u;
|
|
1098
|
+
constructor(compute2, options) {
|
|
1099
|
+
super(void 0, () => {
|
|
1100
|
+
this.u?.();
|
|
1101
|
+
this.u = latest(compute2);
|
|
1102
|
+
return void 0;
|
|
1103
|
+
}, options);
|
|
1104
|
+
getQueue(this).enqueue(this.r, this.w.bind(this));
|
|
1105
|
+
}
|
|
1106
|
+
t(state, skipQueue) {
|
|
1107
|
+
if (this.b >= state || skipQueue)
|
|
1108
|
+
return;
|
|
1109
|
+
if (this.b === STATE_CLEAN || this.d && !ActiveTransition)
|
|
1110
|
+
getQueue(this).enqueue(this.r, this.w.bind(this));
|
|
1111
|
+
this.b = state;
|
|
1112
|
+
}
|
|
1113
|
+
M() {
|
|
1114
|
+
if (this.b === STATE_DISPOSED)
|
|
1115
|
+
return;
|
|
1116
|
+
this.u?.();
|
|
1117
|
+
this.u = void 0;
|
|
1118
|
+
getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
|
|
1119
|
+
super.M();
|
|
1120
|
+
}
|
|
1121
|
+
w(type) {
|
|
1122
|
+
if (type)
|
|
1123
|
+
this.b !== STATE_CLEAN && runTop(this);
|
|
1133
1124
|
}
|
|
1134
1125
|
};
|
|
1135
1126
|
var EagerComputation = class extends Computation {
|
|
1136
1127
|
constructor(initialValue, compute2, options) {
|
|
1137
1128
|
super(initialValue, compute2, options);
|
|
1138
|
-
!options?.defer && this.
|
|
1129
|
+
!options?.defer && this.D();
|
|
1139
1130
|
}
|
|
1140
|
-
|
|
1141
|
-
if (this.
|
|
1131
|
+
t(state, skipQueue) {
|
|
1132
|
+
if (this.b >= state && !this.F)
|
|
1142
1133
|
return;
|
|
1143
|
-
if (!skipQueue && (this.
|
|
1144
|
-
getQueue(this).enqueue(EFFECT_PURE, this.
|
|
1145
|
-
super.
|
|
1134
|
+
if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.F))
|
|
1135
|
+
getQueue(this).enqueue(EFFECT_PURE, this.w.bind(this));
|
|
1136
|
+
super.t(state, skipQueue);
|
|
1146
1137
|
}
|
|
1147
|
-
|
|
1148
|
-
this.
|
|
1138
|
+
w() {
|
|
1139
|
+
this.b !== STATE_CLEAN && runTop(this);
|
|
1149
1140
|
}
|
|
1150
1141
|
};
|
|
1151
1142
|
var FirewallComputation = class extends Computation {
|
|
@@ -1153,16 +1144,16 @@ var FirewallComputation = class extends Computation {
|
|
|
1153
1144
|
constructor(compute2) {
|
|
1154
1145
|
super(void 0, compute2);
|
|
1155
1146
|
}
|
|
1156
|
-
|
|
1157
|
-
if (this.
|
|
1147
|
+
t(state, skipQueue) {
|
|
1148
|
+
if (this.b >= state && !this.F)
|
|
1158
1149
|
return;
|
|
1159
|
-
if (!skipQueue && (this.
|
|
1160
|
-
getQueue(this).enqueue(EFFECT_PURE, this.
|
|
1161
|
-
super.
|
|
1162
|
-
this.
|
|
1150
|
+
if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.F))
|
|
1151
|
+
getQueue(this).enqueue(EFFECT_PURE, this.w.bind(this));
|
|
1152
|
+
super.t(state, true);
|
|
1153
|
+
this.F = !!skipQueue;
|
|
1163
1154
|
}
|
|
1164
|
-
|
|
1165
|
-
this.
|
|
1155
|
+
w() {
|
|
1156
|
+
this.b !== STATE_CLEAN && runTop(this);
|
|
1166
1157
|
}
|
|
1167
1158
|
};
|
|
1168
1159
|
function runTop(node) {
|
|
@@ -1170,28 +1161,24 @@ function runTop(node) {
|
|
|
1170
1161
|
for (let current = node; current !== null; current = current.k) {
|
|
1171
1162
|
if (ActiveTransition && current.j)
|
|
1172
1163
|
current = ActiveTransition.a.get(current);
|
|
1173
|
-
if (current.
|
|
1164
|
+
if (current.b !== STATE_CLEAN) {
|
|
1174
1165
|
ancestors.push(current);
|
|
1175
1166
|
}
|
|
1176
1167
|
}
|
|
1177
1168
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
1178
|
-
if (ancestors[i].
|
|
1179
|
-
ancestors[i].
|
|
1169
|
+
if (ancestors[i].b !== STATE_DISPOSED)
|
|
1170
|
+
ancestors[i].D();
|
|
1180
1171
|
}
|
|
1181
1172
|
}
|
|
1182
1173
|
|
|
1183
1174
|
// src/signals.ts
|
|
1184
1175
|
function createSignal(first, second, third) {
|
|
1185
1176
|
if (typeof first === "function") {
|
|
1186
|
-
const
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
);
|
|
1192
|
-
return [node2.read.bind(node2), node2.write.bind(node2)];
|
|
1193
|
-
});
|
|
1194
|
-
return [() => memo()[0](), (value) => memo()[1](value)];
|
|
1177
|
+
const node2 = new Computation(second, first, third);
|
|
1178
|
+
return [node2.read.bind(node2), (v) => {
|
|
1179
|
+
node2.D();
|
|
1180
|
+
return node2.write(v);
|
|
1181
|
+
}];
|
|
1195
1182
|
}
|
|
1196
1183
|
const o = getOwner();
|
|
1197
1184
|
const needsId = o?.id != null;
|
|
@@ -1211,12 +1198,12 @@ function createMemo(compute2, value, options) {
|
|
|
1211
1198
|
let resolvedValue;
|
|
1212
1199
|
return () => {
|
|
1213
1200
|
if (node) {
|
|
1214
|
-
if (node.
|
|
1201
|
+
if (node.b === STATE_DISPOSED) {
|
|
1215
1202
|
node = void 0;
|
|
1216
1203
|
return resolvedValue;
|
|
1217
1204
|
}
|
|
1218
1205
|
resolvedValue = node.wait();
|
|
1219
|
-
if (!node.a?.length && node.m?.k !== node && !(node.
|
|
1206
|
+
if (!node.a?.length && node.m?.k !== node && !(node.i & UNINITIALIZED_BIT)) {
|
|
1220
1207
|
node.dispose();
|
|
1221
1208
|
node = void 0;
|
|
1222
1209
|
}
|
|
@@ -1254,8 +1241,8 @@ function createAsync(compute2, value, options) {
|
|
|
1254
1241
|
if (abort)
|
|
1255
1242
|
return;
|
|
1256
1243
|
if (transition2)
|
|
1257
|
-
return transition2.runTransition(() => node.
|
|
1258
|
-
node.
|
|
1244
|
+
return transition2.runTransition(() => node.N(error), true);
|
|
1245
|
+
node.N(error);
|
|
1259
1246
|
}
|
|
1260
1247
|
);
|
|
1261
1248
|
} else {
|
|
@@ -1276,10 +1263,10 @@ function createAsync(compute2, value, options) {
|
|
|
1276
1263
|
return;
|
|
1277
1264
|
if (transition2)
|
|
1278
1265
|
return transition2.runTransition(() => {
|
|
1279
|
-
node.
|
|
1266
|
+
node.N(error);
|
|
1280
1267
|
transition2 = null;
|
|
1281
1268
|
}, true);
|
|
1282
|
-
node.
|
|
1269
|
+
node.N(error);
|
|
1283
1270
|
}
|
|
1284
1271
|
})();
|
|
1285
1272
|
}
|
|
@@ -1290,12 +1277,12 @@ function createAsync(compute2, value, options) {
|
|
|
1290
1277
|
const read = node.wait.bind(node);
|
|
1291
1278
|
read.refresh = () => {
|
|
1292
1279
|
let n = node;
|
|
1293
|
-
if (ActiveTransition && !node.
|
|
1280
|
+
if (ActiveTransition && !node.d) {
|
|
1294
1281
|
n = cloneGraph(node);
|
|
1295
1282
|
}
|
|
1296
|
-
n.
|
|
1283
|
+
n.b = STATE_DIRTY;
|
|
1297
1284
|
refreshing = true;
|
|
1298
|
-
n.
|
|
1285
|
+
n.D();
|
|
1299
1286
|
};
|
|
1300
1287
|
return read;
|
|
1301
1288
|
}
|
|
@@ -1303,7 +1290,7 @@ function createEffect(compute2, effect, value, options) {
|
|
|
1303
1290
|
void new Effect(
|
|
1304
1291
|
value,
|
|
1305
1292
|
compute2,
|
|
1306
|
-
effect.effect
|
|
1293
|
+
effect.effect || effect,
|
|
1307
1294
|
effect.error,
|
|
1308
1295
|
options
|
|
1309
1296
|
);
|
|
@@ -1314,6 +1301,29 @@ function createRenderEffect(compute2, effect, value, options) {
|
|
|
1314
1301
|
...options
|
|
1315
1302
|
});
|
|
1316
1303
|
}
|
|
1304
|
+
function createTrackedEffect(compute2, options) {
|
|
1305
|
+
void new TrackedEffect(compute2, options);
|
|
1306
|
+
}
|
|
1307
|
+
function createReaction(effect, options) {
|
|
1308
|
+
let cleanup = void 0;
|
|
1309
|
+
onCleanup(() => cleanup?.());
|
|
1310
|
+
return (tracking) => {
|
|
1311
|
+
const node = new Effect(
|
|
1312
|
+
void 0,
|
|
1313
|
+
tracking,
|
|
1314
|
+
() => {
|
|
1315
|
+
cleanup?.();
|
|
1316
|
+
cleanup = (effect.effect || effect)?.();
|
|
1317
|
+
node.dispose(true);
|
|
1318
|
+
},
|
|
1319
|
+
effect.error,
|
|
1320
|
+
{
|
|
1321
|
+
defer: true,
|
|
1322
|
+
...options
|
|
1323
|
+
}
|
|
1324
|
+
);
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1317
1327
|
function createRoot(init, options) {
|
|
1318
1328
|
const owner = new Owner(options?.id);
|
|
1319
1329
|
return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
|
|
@@ -1337,23 +1347,25 @@ function resolve(fn) {
|
|
|
1337
1347
|
});
|
|
1338
1348
|
});
|
|
1339
1349
|
}
|
|
1340
|
-
function
|
|
1341
|
-
const node = new Computation(
|
|
1342
|
-
const reset = () => node.write(
|
|
1343
|
-
function write() {
|
|
1350
|
+
function createOptimistic(first, second, third) {
|
|
1351
|
+
const node = typeof first === "function" ? new Computation(second, first, third) : new Computation(first, null, second);
|
|
1352
|
+
const reset = () => node.write(first);
|
|
1353
|
+
function write(v) {
|
|
1344
1354
|
if (!ActiveTransition)
|
|
1345
|
-
|
|
1355
|
+
throw new Error("createOptimistic can only be updated inside a transition");
|
|
1346
1356
|
ActiveTransition.addOptimistic(reset);
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1357
|
+
cloneGraph(node, true);
|
|
1358
|
+
queueMicrotask(() => {
|
|
1359
|
+
if (reset.j) {
|
|
1360
|
+
node.D();
|
|
1361
|
+
node.write(v);
|
|
1362
|
+
}
|
|
1363
|
+
});
|
|
1352
1364
|
}
|
|
1353
|
-
return [read, write];
|
|
1365
|
+
return [node.read.bind(node), write];
|
|
1354
1366
|
}
|
|
1355
1367
|
function useTransition() {
|
|
1356
|
-
const [pending, setPending] =
|
|
1368
|
+
const [pending, setPending] = createOptimistic(false);
|
|
1357
1369
|
function start(fn) {
|
|
1358
1370
|
transition((resume) => {
|
|
1359
1371
|
setPending(true);
|
|
@@ -1819,7 +1831,7 @@ function deep(store) {
|
|
|
1819
1831
|
}
|
|
1820
1832
|
|
|
1821
1833
|
// src/store/optimistic.ts
|
|
1822
|
-
function
|
|
1834
|
+
function createOptimisticStore(first, second, options) {
|
|
1823
1835
|
const derived = typeof first === "function";
|
|
1824
1836
|
const { store, node } = derived ? createProjectionInternal(first, second, options) : createProjectionInternal(() => {
|
|
1825
1837
|
}, first);
|
|
@@ -1833,7 +1845,7 @@ function createOptimistic(first, second, options) {
|
|
|
1833
1845
|
);
|
|
1834
1846
|
const write = (v) => {
|
|
1835
1847
|
if (!ActiveTransition)
|
|
1836
|
-
throw new Error("
|
|
1848
|
+
throw new Error("createOptimisticStore can only be updated inside a transition");
|
|
1837
1849
|
ActiveTransition.addOptimistic(reset);
|
|
1838
1850
|
cloneGraph(node, true);
|
|
1839
1851
|
queueMicrotask(() => reset.j && storeSetter(store, v));
|
|
@@ -2048,11 +2060,11 @@ function mapArray(list, map, options) {
|
|
|
2048
2060
|
U: new Owner(),
|
|
2049
2061
|
o: 0,
|
|
2050
2062
|
ia: list,
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2063
|
+
G: [],
|
|
2064
|
+
R: map,
|
|
2065
|
+
h: [],
|
|
2066
|
+
e: [],
|
|
2067
|
+
S: keyFn,
|
|
2056
2068
|
p: keyFn || options?.keyed === false ? [] : void 0,
|
|
2057
2069
|
q: map.length > 1 ? [] : void 0,
|
|
2058
2070
|
V: options?.fallback
|
|
@@ -2066,53 +2078,53 @@ function updateKeyedMap() {
|
|
|
2066
2078
|
let i, j, mapper = this.p ? () => {
|
|
2067
2079
|
this.p[j] = new Computation(newItems[j], null, pureOptions);
|
|
2068
2080
|
this.q && (this.q[j] = new Computation(j, null, pureOptions));
|
|
2069
|
-
return this.
|
|
2081
|
+
return this.R(
|
|
2070
2082
|
Computation.prototype.read.bind(this.p[j]),
|
|
2071
2083
|
this.q ? Computation.prototype.read.bind(this.q[j]) : void 0
|
|
2072
2084
|
);
|
|
2073
2085
|
} : this.q ? () => {
|
|
2074
2086
|
const item = newItems[j];
|
|
2075
2087
|
this.q[j] = new Computation(j, null, pureOptions);
|
|
2076
|
-
return this.
|
|
2088
|
+
return this.R(() => item, Computation.prototype.read.bind(this.q[j]));
|
|
2077
2089
|
} : () => {
|
|
2078
2090
|
const item = newItems[j];
|
|
2079
|
-
return this.
|
|
2091
|
+
return this.R(() => item);
|
|
2080
2092
|
};
|
|
2081
2093
|
if (newLen === 0) {
|
|
2082
2094
|
if (this.o !== 0) {
|
|
2083
2095
|
this.U.dispose(false);
|
|
2084
|
-
this.
|
|
2085
|
-
this.
|
|
2086
|
-
this.
|
|
2096
|
+
this.e = [];
|
|
2097
|
+
this.G = [];
|
|
2098
|
+
this.h = [];
|
|
2087
2099
|
this.o = 0;
|
|
2088
2100
|
this.p && (this.p = []);
|
|
2089
2101
|
this.q && (this.q = []);
|
|
2090
2102
|
}
|
|
2091
|
-
if (this.V && !this.
|
|
2092
|
-
this.
|
|
2093
|
-
this.
|
|
2103
|
+
if (this.V && !this.h[0]) {
|
|
2104
|
+
this.h[0] = compute(
|
|
2105
|
+
this.e[0] = new Owner(),
|
|
2094
2106
|
this.V,
|
|
2095
2107
|
null
|
|
2096
2108
|
);
|
|
2097
2109
|
}
|
|
2098
2110
|
} else if (this.o === 0) {
|
|
2099
|
-
if (this.
|
|
2100
|
-
this.
|
|
2101
|
-
this.
|
|
2111
|
+
if (this.e[0])
|
|
2112
|
+
this.e[0].dispose();
|
|
2113
|
+
this.h = new Array(newLen);
|
|
2102
2114
|
for (j = 0; j < newLen; j++) {
|
|
2103
|
-
this.
|
|
2104
|
-
this.
|
|
2115
|
+
this.G[j] = newItems[j];
|
|
2116
|
+
this.h[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2105
2117
|
}
|
|
2106
2118
|
this.o = newLen;
|
|
2107
2119
|
} else {
|
|
2108
2120
|
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.p ? new Array(newLen) : void 0, tempIndexes = this.q ? new Array(newLen) : void 0;
|
|
2109
|
-
for (start = 0, end = Math.min(this.o, newLen); start < end && (this.
|
|
2121
|
+
for (start = 0, end = Math.min(this.o, newLen); start < end && (this.G[start] === newItems[start] || this.p && compare(this.S, this.G[start], newItems[start])); start++) {
|
|
2110
2122
|
if (this.p)
|
|
2111
2123
|
this.p[start].write(newItems[start]);
|
|
2112
2124
|
}
|
|
2113
|
-
for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.
|
|
2114
|
-
temp[newEnd] = this.
|
|
2115
|
-
tempNodes[newEnd] = this.
|
|
2125
|
+
for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.G[end] === newItems[newEnd] || this.p && compare(this.S, this.G[end], newItems[newEnd])); end--, newEnd--) {
|
|
2126
|
+
temp[newEnd] = this.h[end];
|
|
2127
|
+
tempNodes[newEnd] = this.e[end];
|
|
2116
2128
|
tempRows && (tempRows[newEnd] = this.p[end]);
|
|
2117
2129
|
tempIndexes && (tempIndexes[newEnd] = this.q[end]);
|
|
2118
2130
|
}
|
|
@@ -2120,29 +2132,29 @@ function updateKeyedMap() {
|
|
|
2120
2132
|
newIndicesNext = new Array(newEnd + 1);
|
|
2121
2133
|
for (j = newEnd; j >= start; j--) {
|
|
2122
2134
|
item = newItems[j];
|
|
2123
|
-
key = this.
|
|
2135
|
+
key = this.S ? this.S(item) : item;
|
|
2124
2136
|
i = newIndices.get(key);
|
|
2125
2137
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
2126
2138
|
newIndices.set(key, j);
|
|
2127
2139
|
}
|
|
2128
2140
|
for (i = start; i <= end; i++) {
|
|
2129
|
-
item = this.
|
|
2130
|
-
key = this.
|
|
2141
|
+
item = this.G[i];
|
|
2142
|
+
key = this.S ? this.S(item) : item;
|
|
2131
2143
|
j = newIndices.get(key);
|
|
2132
2144
|
if (j !== void 0 && j !== -1) {
|
|
2133
|
-
temp[j] = this.
|
|
2134
|
-
tempNodes[j] = this.
|
|
2145
|
+
temp[j] = this.h[i];
|
|
2146
|
+
tempNodes[j] = this.e[i];
|
|
2135
2147
|
tempRows && (tempRows[j] = this.p[i]);
|
|
2136
2148
|
tempIndexes && (tempIndexes[j] = this.q[i]);
|
|
2137
2149
|
j = newIndicesNext[j];
|
|
2138
2150
|
newIndices.set(key, j);
|
|
2139
2151
|
} else
|
|
2140
|
-
this.
|
|
2152
|
+
this.e[i].dispose();
|
|
2141
2153
|
}
|
|
2142
2154
|
for (j = start; j < newLen; j++) {
|
|
2143
2155
|
if (j in temp) {
|
|
2144
|
-
this.
|
|
2145
|
-
this.
|
|
2156
|
+
this.h[j] = temp[j];
|
|
2157
|
+
this.e[j] = tempNodes[j];
|
|
2146
2158
|
if (tempRows) {
|
|
2147
2159
|
this.p[j] = tempRows[j];
|
|
2148
2160
|
this.p[j].write(newItems[j]);
|
|
@@ -2152,24 +2164,24 @@ function updateKeyedMap() {
|
|
|
2152
2164
|
this.q[j].write(j);
|
|
2153
2165
|
}
|
|
2154
2166
|
} else {
|
|
2155
|
-
this.
|
|
2167
|
+
this.h[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2156
2168
|
}
|
|
2157
2169
|
}
|
|
2158
|
-
this.
|
|
2159
|
-
this.
|
|
2170
|
+
this.h = this.h.slice(0, this.o = newLen);
|
|
2171
|
+
this.G = newItems.slice(0);
|
|
2160
2172
|
}
|
|
2161
2173
|
});
|
|
2162
|
-
return this.
|
|
2174
|
+
return this.h;
|
|
2163
2175
|
}
|
|
2164
2176
|
function repeat(count, map, options) {
|
|
2165
2177
|
return updateRepeat.bind({
|
|
2166
2178
|
U: new Owner(),
|
|
2167
2179
|
o: 0,
|
|
2168
|
-
|
|
2180
|
+
A: 0,
|
|
2169
2181
|
ja: count,
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2182
|
+
R: map,
|
|
2183
|
+
e: [],
|
|
2184
|
+
h: [],
|
|
2173
2185
|
ka: options?.from,
|
|
2174
2186
|
V: options?.fallback
|
|
2175
2187
|
});
|
|
@@ -2181,13 +2193,13 @@ function updateRepeat() {
|
|
|
2181
2193
|
if (newLen === 0) {
|
|
2182
2194
|
if (this.o !== 0) {
|
|
2183
2195
|
this.U.dispose(false);
|
|
2184
|
-
this.
|
|
2185
|
-
this.
|
|
2196
|
+
this.e = [];
|
|
2197
|
+
this.h = [];
|
|
2186
2198
|
this.o = 0;
|
|
2187
2199
|
}
|
|
2188
|
-
if (this.V && !this.
|
|
2189
|
-
this.
|
|
2190
|
-
this.
|
|
2200
|
+
if (this.V && !this.h[0]) {
|
|
2201
|
+
this.h[0] = compute(
|
|
2202
|
+
this.e[0] = new Owner(),
|
|
2191
2203
|
this.V,
|
|
2192
2204
|
null
|
|
2193
2205
|
);
|
|
@@ -2195,46 +2207,46 @@ function updateRepeat() {
|
|
|
2195
2207
|
return;
|
|
2196
2208
|
}
|
|
2197
2209
|
const to = from + newLen;
|
|
2198
|
-
const prevTo = this.
|
|
2199
|
-
if (this.o === 0 && this.
|
|
2200
|
-
this.
|
|
2210
|
+
const prevTo = this.A + this.o;
|
|
2211
|
+
if (this.o === 0 && this.e[0])
|
|
2212
|
+
this.e[0].dispose();
|
|
2201
2213
|
for (let i = to; i < prevTo; i++)
|
|
2202
|
-
this.
|
|
2203
|
-
if (this.
|
|
2204
|
-
let i = this.
|
|
2214
|
+
this.e[i - this.A].dispose();
|
|
2215
|
+
if (this.A < from) {
|
|
2216
|
+
let i = this.A;
|
|
2205
2217
|
while (i < from && i < this.o)
|
|
2206
|
-
this.
|
|
2207
|
-
this.
|
|
2208
|
-
this.
|
|
2209
|
-
} else if (this.
|
|
2210
|
-
let i = prevTo - this.
|
|
2211
|
-
let difference = this.
|
|
2212
|
-
this.
|
|
2218
|
+
this.e[i++].dispose();
|
|
2219
|
+
this.e.splice(0, from - this.A);
|
|
2220
|
+
this.h.splice(0, from - this.A);
|
|
2221
|
+
} else if (this.A > from) {
|
|
2222
|
+
let i = prevTo - this.A - 1;
|
|
2223
|
+
let difference = this.A - from;
|
|
2224
|
+
this.e.length = this.h.length = newLen;
|
|
2213
2225
|
while (i >= difference) {
|
|
2214
|
-
this.
|
|
2215
|
-
this.
|
|
2226
|
+
this.e[i] = this.e[i - difference];
|
|
2227
|
+
this.h[i] = this.h[i - difference];
|
|
2216
2228
|
i--;
|
|
2217
2229
|
}
|
|
2218
2230
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
2219
|
-
this.
|
|
2220
|
-
this.
|
|
2221
|
-
() => this.
|
|
2231
|
+
this.h[i2] = compute(
|
|
2232
|
+
this.e[i2] = new Owner(),
|
|
2233
|
+
() => this.R(i2 + from),
|
|
2222
2234
|
null
|
|
2223
2235
|
);
|
|
2224
2236
|
}
|
|
2225
2237
|
}
|
|
2226
2238
|
for (let i = prevTo; i < to; i++) {
|
|
2227
|
-
this.
|
|
2228
|
-
this.
|
|
2229
|
-
() => this.
|
|
2239
|
+
this.h[i - from] = compute(
|
|
2240
|
+
this.e[i - from] = new Owner(),
|
|
2241
|
+
() => this.R(i),
|
|
2230
2242
|
null
|
|
2231
2243
|
);
|
|
2232
2244
|
}
|
|
2233
|
-
this.
|
|
2234
|
-
this.
|
|
2245
|
+
this.h = this.h.slice(0, newLen);
|
|
2246
|
+
this.A = from;
|
|
2235
2247
|
this.o = newLen;
|
|
2236
2248
|
});
|
|
2237
|
-
return this.
|
|
2249
|
+
return this.h;
|
|
2238
2250
|
}
|
|
2239
2251
|
function compare(key, a, b) {
|
|
2240
2252
|
return key ? key(a) === key(b) : true;
|
|
@@ -2249,7 +2261,7 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2249
2261
|
}
|
|
2250
2262
|
write(value, flags) {
|
|
2251
2263
|
super.write(value, flags & ~this.W);
|
|
2252
|
-
if (this.W & LOADING_BIT && !(this.
|
|
2264
|
+
if (this.W & LOADING_BIT && !(this.i & UNINITIALIZED_BIT || ActiveTransition)) {
|
|
2253
2265
|
flags &= ~LOADING_BIT;
|
|
2254
2266
|
}
|
|
2255
2267
|
getQueue(this).notify(this, this.W, flags);
|
|
@@ -2257,9 +2269,9 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2257
2269
|
}
|
|
2258
2270
|
};
|
|
2259
2271
|
function createBoundChildren(owner, fn, queue, mask) {
|
|
2260
|
-
const parentQueue = owner.
|
|
2261
|
-
parentQueue.addChild(owner.
|
|
2262
|
-
onCleanup(() => parentQueue.removeChild(owner.
|
|
2272
|
+
const parentQueue = owner.C;
|
|
2273
|
+
parentQueue.addChild(owner.C = queue);
|
|
2274
|
+
onCleanup(() => parentQueue.removeChild(owner.C));
|
|
2263
2275
|
return compute(
|
|
2264
2276
|
owner,
|
|
2265
2277
|
() => {
|
|
@@ -2270,25 +2282,25 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
2270
2282
|
);
|
|
2271
2283
|
}
|
|
2272
2284
|
var ConditionalQueue = class extends Queue {
|
|
2273
|
-
|
|
2285
|
+
x;
|
|
2274
2286
|
X = /* @__PURE__ */ new Set();
|
|
2275
|
-
|
|
2287
|
+
s = /* @__PURE__ */ new Set();
|
|
2276
2288
|
constructor(disabled) {
|
|
2277
2289
|
super();
|
|
2278
|
-
this.
|
|
2290
|
+
this.x = disabled;
|
|
2279
2291
|
}
|
|
2280
2292
|
run(type) {
|
|
2281
|
-
if (!type || this.
|
|
2293
|
+
if (!type || this.x.read())
|
|
2282
2294
|
return;
|
|
2283
2295
|
return super.run(type);
|
|
2284
2296
|
}
|
|
2285
2297
|
notify(node, type, flags) {
|
|
2286
|
-
if (this.
|
|
2298
|
+
if (this.x.read()) {
|
|
2287
2299
|
if (type & LOADING_BIT) {
|
|
2288
2300
|
if (flags & LOADING_BIT) {
|
|
2289
|
-
this.
|
|
2301
|
+
this.s.add(node);
|
|
2290
2302
|
type &= ~LOADING_BIT;
|
|
2291
|
-
} else if (this.
|
|
2303
|
+
} else if (this.s.delete(node))
|
|
2292
2304
|
type &= ~LOADING_BIT;
|
|
2293
2305
|
}
|
|
2294
2306
|
if (type & ERROR_BIT) {
|
|
@@ -2302,41 +2314,41 @@ var ConditionalQueue = class extends Queue {
|
|
|
2302
2314
|
return type ? super.notify(node, type, flags) : true;
|
|
2303
2315
|
}
|
|
2304
2316
|
merge(queue) {
|
|
2305
|
-
queue.
|
|
2317
|
+
queue.s.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
|
|
2306
2318
|
queue.X.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
|
|
2307
2319
|
super.merge(queue);
|
|
2308
2320
|
}
|
|
2309
2321
|
};
|
|
2310
2322
|
var CollectionQueue = class extends Queue {
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2323
|
+
L;
|
|
2324
|
+
e = /* @__PURE__ */ new Set();
|
|
2325
|
+
x = new Computation(false, null, { pureWrite: true });
|
|
2314
2326
|
constructor(type) {
|
|
2315
2327
|
super();
|
|
2316
|
-
this.
|
|
2328
|
+
this.L = type;
|
|
2317
2329
|
}
|
|
2318
2330
|
run(type) {
|
|
2319
|
-
if (!type || this.
|
|
2331
|
+
if (!type || this.x.read())
|
|
2320
2332
|
return;
|
|
2321
2333
|
return super.run(type);
|
|
2322
2334
|
}
|
|
2323
2335
|
notify(node, type, flags) {
|
|
2324
|
-
if (!(type & this.
|
|
2336
|
+
if (!(type & this.L))
|
|
2325
2337
|
return super.notify(node, type, flags);
|
|
2326
|
-
if (flags & this.
|
|
2327
|
-
this.
|
|
2328
|
-
if (this.
|
|
2329
|
-
this.
|
|
2330
|
-
} else if (this.
|
|
2331
|
-
this.
|
|
2332
|
-
if (this.
|
|
2333
|
-
this.
|
|
2334
|
-
}
|
|
2335
|
-
type &= ~this.
|
|
2338
|
+
if (flags & this.L) {
|
|
2339
|
+
this.e.add(node);
|
|
2340
|
+
if (this.e.size === 1)
|
|
2341
|
+
this.x.write(true);
|
|
2342
|
+
} else if (this.e.size > 0) {
|
|
2343
|
+
this.e.delete(node);
|
|
2344
|
+
if (this.e.size === 0)
|
|
2345
|
+
this.x.write(false);
|
|
2346
|
+
}
|
|
2347
|
+
type &= ~this.L;
|
|
2336
2348
|
return type ? super.notify(node, type, flags) : true;
|
|
2337
2349
|
}
|
|
2338
2350
|
merge(queue) {
|
|
2339
|
-
queue.
|
|
2351
|
+
queue.e.forEach((n) => this.notify(n, this.L, this.L));
|
|
2340
2352
|
super.merge(queue);
|
|
2341
2353
|
}
|
|
2342
2354
|
};
|
|
@@ -2347,25 +2359,25 @@ function createBoundary(fn, condition) {
|
|
|
2347
2359
|
);
|
|
2348
2360
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
2349
2361
|
new EagerComputation(void 0, () => {
|
|
2350
|
-
const disabled = queue.
|
|
2362
|
+
const disabled = queue.x.read();
|
|
2351
2363
|
tree.W = disabled ? ERROR_BIT | LOADING_BIT : 0;
|
|
2352
2364
|
if (!disabled) {
|
|
2353
|
-
queue.
|
|
2365
|
+
queue.s.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
|
|
2354
2366
|
queue.X.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
|
|
2355
|
-
queue.
|
|
2367
|
+
queue.s.clear();
|
|
2356
2368
|
queue.X.clear();
|
|
2357
2369
|
}
|
|
2358
2370
|
});
|
|
2359
|
-
return () => queue.
|
|
2371
|
+
return () => queue.x.read() ? void 0 : tree.read();
|
|
2360
2372
|
}
|
|
2361
2373
|
function createCollectionBoundary(type, fn, fallback) {
|
|
2362
2374
|
const owner = new Owner();
|
|
2363
2375
|
const queue = new CollectionQueue(type);
|
|
2364
2376
|
const tree = createBoundChildren(owner, fn, queue, type);
|
|
2365
2377
|
const decision = new Computation(void 0, () => {
|
|
2366
|
-
if (!queue.
|
|
2378
|
+
if (!queue.x.read()) {
|
|
2367
2379
|
const resolved = tree.read();
|
|
2368
|
-
if (!untrack(() => queue.
|
|
2380
|
+
if (!untrack(() => queue.x.read()))
|
|
2369
2381
|
return resolved;
|
|
2370
2382
|
}
|
|
2371
2383
|
return fallback(queue);
|
|
@@ -2377,14 +2389,14 @@ function createSuspense(fn, fallback) {
|
|
|
2377
2389
|
}
|
|
2378
2390
|
function createErrorBoundary(fn, fallback) {
|
|
2379
2391
|
return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
|
|
2380
|
-
let node = getTransitionSource(queue.
|
|
2381
|
-
return fallback(node.
|
|
2392
|
+
let node = getTransitionSource(queue.e.values().next().value);
|
|
2393
|
+
return fallback(node.O, () => {
|
|
2382
2394
|
incrementClock();
|
|
2383
|
-
for (let node2 of queue.
|
|
2384
|
-
if (ActiveTransition && !node2.
|
|
2395
|
+
for (let node2 of queue.e) {
|
|
2396
|
+
if (ActiveTransition && !node2.d)
|
|
2385
2397
|
node2 = cloneGraph(node2);
|
|
2386
|
-
node2.
|
|
2387
|
-
getQueue(node2).enqueue(node2.
|
|
2398
|
+
node2.b = STATE_DIRTY;
|
|
2399
|
+
getQueue(node2).enqueue(node2.r, node2.w.bind(node2));
|
|
2388
2400
|
}
|
|
2389
2401
|
});
|
|
2390
2402
|
});
|
|
@@ -2444,4 +2456,4 @@ function flattenArray(children, results = [], options) {
|
|
|
2444
2456
|
return needsUnwrap;
|
|
2445
2457
|
}
|
|
2446
2458
|
|
|
2447
|
-
export { $PROXY, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, SUPPORTS_PROXY, createAsync, createBoundary, createContext, createEffect, createErrorBoundary, createMemo, createOptimistic, createProjection, createRenderEffect, createRoot, createSignal, createStore, createSuspense, deep, flatten, flush, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, repeat, resolve,
|
|
2459
|
+
export { $PROXY, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, SUPPORTS_PROXY, createAsync, createBoundary, createContext, createEffect, createErrorBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createSuspense, createTrackedEffect, deep, flatten, flush, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, repeat, resolve, runWithOwner, setContext, snapshot, transition, untrack, useTransition };
|