@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/node.cjs
CHANGED
|
@@ -47,14 +47,14 @@ function schedule() {
|
|
|
47
47
|
if (scheduled)
|
|
48
48
|
return;
|
|
49
49
|
scheduled = true;
|
|
50
|
-
if (!globalQueue.
|
|
50
|
+
if (!globalQueue.B)
|
|
51
51
|
queueMicrotask(flush);
|
|
52
52
|
}
|
|
53
53
|
function notifyUnobserved() {
|
|
54
54
|
var _a, _b;
|
|
55
55
|
for (let i = 0; i < Unobserved.length; i++) {
|
|
56
56
|
const source = Unobserved[i];
|
|
57
|
-
if (!source.
|
|
57
|
+
if (!source.c || !source.c.length)
|
|
58
58
|
(_b = (_a = Unobserved[i]).ea) == null ? void 0 : _b.call(_a);
|
|
59
59
|
}
|
|
60
60
|
Unobserved = [];
|
|
@@ -62,7 +62,7 @@ function notifyUnobserved() {
|
|
|
62
62
|
var pureQueue = [];
|
|
63
63
|
var Queue = class {
|
|
64
64
|
k = null;
|
|
65
|
-
|
|
65
|
+
B = false;
|
|
66
66
|
g = [[], []];
|
|
67
67
|
f = [];
|
|
68
68
|
created = clock;
|
|
@@ -87,9 +87,9 @@ var Queue = class {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
flush() {
|
|
90
|
-
if (this.
|
|
90
|
+
if (this.B)
|
|
91
91
|
return;
|
|
92
|
-
this.
|
|
92
|
+
this.B = true;
|
|
93
93
|
try {
|
|
94
94
|
this.run(EFFECT_PURE);
|
|
95
95
|
incrementClock();
|
|
@@ -97,19 +97,19 @@ var Queue = class {
|
|
|
97
97
|
this.run(EFFECT_RENDER);
|
|
98
98
|
this.run(EFFECT_USER);
|
|
99
99
|
} finally {
|
|
100
|
-
this.
|
|
100
|
+
this.B = false;
|
|
101
101
|
Unobserved.length && notifyUnobserved();
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
addChild(child) {
|
|
105
|
-
if (ActiveTransition && ActiveTransition.
|
|
106
|
-
return ActiveTransition.
|
|
105
|
+
if (ActiveTransition && ActiveTransition.H.has(this))
|
|
106
|
+
return ActiveTransition.H.get(this).addChild(child);
|
|
107
107
|
this.f.push(child);
|
|
108
108
|
child.k = this;
|
|
109
109
|
}
|
|
110
110
|
removeChild(child) {
|
|
111
|
-
if (ActiveTransition && ActiveTransition.
|
|
112
|
-
return ActiveTransition.
|
|
111
|
+
if (ActiveTransition && ActiveTransition.H.has(this))
|
|
112
|
+
return ActiveTransition.H.get(this).removeChild(child);
|
|
113
113
|
const index = this.f.indexOf(child);
|
|
114
114
|
if (index >= 0) {
|
|
115
115
|
this.f.splice(index, 1);
|
|
@@ -125,7 +125,7 @@ var Queue = class {
|
|
|
125
125
|
this.g[0].push.apply(this.g[0], queue.g[0]);
|
|
126
126
|
this.g[1].push.apply(this.g[1], queue.g[1]);
|
|
127
127
|
for (let i = 0; i < queue.f.length; i++) {
|
|
128
|
-
const og = this.f.find((c) => c.
|
|
128
|
+
const og = this.f.find((c) => c.d === queue.f[i].d);
|
|
129
129
|
if (og)
|
|
130
130
|
og.merge(queue.f[i]);
|
|
131
131
|
else
|
|
@@ -144,12 +144,12 @@ function removeSourceObservers(node, index) {
|
|
|
144
144
|
let swap;
|
|
145
145
|
for (let i = index; i < node.a.length; i++) {
|
|
146
146
|
source = getTransitionSource(node.a[i]);
|
|
147
|
-
if (source.
|
|
148
|
-
if ((swap = source.
|
|
149
|
-
source.
|
|
150
|
-
source.
|
|
147
|
+
if (source.c) {
|
|
148
|
+
if ((swap = source.c.indexOf(node)) !== -1) {
|
|
149
|
+
source.c[swap] = source.c[source.c.length - 1];
|
|
150
|
+
source.c.pop();
|
|
151
151
|
}
|
|
152
|
-
if (!source.
|
|
152
|
+
if (!source.c.length)
|
|
153
153
|
Unobserved.push(source);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
@@ -160,35 +160,35 @@ function runQueue(queue, type) {
|
|
|
160
160
|
}
|
|
161
161
|
var Transition = class _Transition {
|
|
162
162
|
a = /* @__PURE__ */ new Map();
|
|
163
|
-
|
|
164
|
-
H = /* @__PURE__ */ new Set();
|
|
163
|
+
s = /* @__PURE__ */ new Set();
|
|
165
164
|
I = /* @__PURE__ */ new Set();
|
|
166
|
-
|
|
165
|
+
J = /* @__PURE__ */ new Set();
|
|
166
|
+
E = false;
|
|
167
167
|
g = [[], []];
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
H = /* @__PURE__ */ new Map();
|
|
169
|
+
K = [];
|
|
170
170
|
f = [];
|
|
171
171
|
k = null;
|
|
172
|
-
|
|
172
|
+
B = false;
|
|
173
173
|
Y = false;
|
|
174
|
-
|
|
174
|
+
d = globalQueue;
|
|
175
175
|
created = clock;
|
|
176
176
|
constructor() {
|
|
177
|
-
this.
|
|
177
|
+
this.H.set(globalQueue, this);
|
|
178
178
|
for (const child of globalQueue.f) {
|
|
179
179
|
cloneQueue(child, this, this);
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
enqueue(type, fn) {
|
|
183
|
-
this.
|
|
183
|
+
this.K.push(fn);
|
|
184
184
|
if (type)
|
|
185
185
|
this.g[type - 1].push(fn);
|
|
186
186
|
this.schedule();
|
|
187
187
|
}
|
|
188
188
|
run(type) {
|
|
189
189
|
if (type === EFFECT_PURE) {
|
|
190
|
-
this.
|
|
191
|
-
this.
|
|
190
|
+
this.K.length && runQueue(this.K, type);
|
|
191
|
+
this.K = [];
|
|
192
192
|
return;
|
|
193
193
|
} else if (this.g[type - 1].length) {
|
|
194
194
|
const effects = this.g[type - 1];
|
|
@@ -200,9 +200,9 @@ var Transition = class _Transition {
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
flush() {
|
|
203
|
-
if (this.
|
|
203
|
+
if (this.B)
|
|
204
204
|
return;
|
|
205
|
-
this.
|
|
205
|
+
this.B = true;
|
|
206
206
|
let currentTransition = ActiveTransition;
|
|
207
207
|
ActiveTransition = this;
|
|
208
208
|
try {
|
|
@@ -212,7 +212,7 @@ var Transition = class _Transition {
|
|
|
212
212
|
ActiveTransition = currentTransition;
|
|
213
213
|
finishTransition(this);
|
|
214
214
|
} finally {
|
|
215
|
-
this.
|
|
215
|
+
this.B = false;
|
|
216
216
|
ActiveTransition = currentTransition;
|
|
217
217
|
}
|
|
218
218
|
}
|
|
@@ -229,18 +229,18 @@ var Transition = class _Transition {
|
|
|
229
229
|
if (!(type & LOADING_BIT))
|
|
230
230
|
return false;
|
|
231
231
|
if (flags & LOADING_BIT) {
|
|
232
|
-
this.
|
|
232
|
+
this.s.add(node);
|
|
233
233
|
} else {
|
|
234
|
-
this.
|
|
234
|
+
this.s.delete(node);
|
|
235
235
|
}
|
|
236
236
|
return true;
|
|
237
237
|
}
|
|
238
238
|
merge(queue) {
|
|
239
239
|
this.g[0].push.apply(this.g[0], queue.g[0]);
|
|
240
240
|
this.g[1].push.apply(this.g[1], queue.g[1]);
|
|
241
|
-
this.
|
|
241
|
+
this.K.push.apply(this.K, queue.K);
|
|
242
242
|
for (let i = 0; i < queue.f.length; i++) {
|
|
243
|
-
const og = this.f.find((c) => c.
|
|
243
|
+
const og = this.f.find((c) => c.d === queue.f[i].d);
|
|
244
244
|
if (og)
|
|
245
245
|
og.merge(queue.f[i]);
|
|
246
246
|
else
|
|
@@ -251,13 +251,13 @@ var Transition = class _Transition {
|
|
|
251
251
|
if (this.Y)
|
|
252
252
|
return;
|
|
253
253
|
this.Y = true;
|
|
254
|
-
if (!this.
|
|
254
|
+
if (!this.B)
|
|
255
255
|
queueMicrotask(() => this.flush());
|
|
256
256
|
}
|
|
257
257
|
runTransition(fn, force = false) {
|
|
258
|
-
if (this.
|
|
259
|
-
if (this.
|
|
260
|
-
return this.
|
|
258
|
+
if (this.E) {
|
|
259
|
+
if (this.E instanceof _Transition)
|
|
260
|
+
return this.E.runTransition(fn, force);
|
|
261
261
|
if (!force)
|
|
262
262
|
throw new Error("Transition already completed");
|
|
263
263
|
fn();
|
|
@@ -272,12 +272,12 @@ var Transition = class _Transition {
|
|
|
272
272
|
let temp, value;
|
|
273
273
|
while (!(temp = result.next(value)).done) {
|
|
274
274
|
if (temp.value instanceof Promise) {
|
|
275
|
-
transition2.
|
|
275
|
+
transition2.I.add(temp.value);
|
|
276
276
|
try {
|
|
277
277
|
value = await temp.value;
|
|
278
278
|
} finally {
|
|
279
279
|
transition2 = latestTransition(transition2);
|
|
280
|
-
transition2.
|
|
280
|
+
transition2.I.delete(temp.value);
|
|
281
281
|
}
|
|
282
282
|
ActiveTransition = transition2;
|
|
283
283
|
} else
|
|
@@ -288,10 +288,10 @@ var Transition = class _Transition {
|
|
|
288
288
|
})();
|
|
289
289
|
}
|
|
290
290
|
if (result instanceof Promise) {
|
|
291
|
-
transition2.
|
|
291
|
+
transition2.I.add(result);
|
|
292
292
|
result.finally(() => {
|
|
293
293
|
transition2 = latestTransition(transition2);
|
|
294
|
-
transition2.
|
|
294
|
+
transition2.I.delete(result);
|
|
295
295
|
ActiveTransition = null;
|
|
296
296
|
finishTransition(transition2);
|
|
297
297
|
});
|
|
@@ -309,7 +309,7 @@ var Transition = class _Transition {
|
|
|
309
309
|
return;
|
|
310
310
|
}
|
|
311
311
|
fn.j = this;
|
|
312
|
-
this.
|
|
312
|
+
this.J.add(fn);
|
|
313
313
|
}
|
|
314
314
|
};
|
|
315
315
|
function transition(fn) {
|
|
@@ -328,29 +328,29 @@ function cloneGraph(node, optimistic) {
|
|
|
328
328
|
Object.assign(clone, node, {
|
|
329
329
|
n: null,
|
|
330
330
|
m: null,
|
|
331
|
-
|
|
331
|
+
c: null,
|
|
332
332
|
a: node.a ? [...node.a] : null,
|
|
333
|
-
|
|
334
|
-
|
|
333
|
+
d: node,
|
|
334
|
+
J: !!optimistic
|
|
335
335
|
});
|
|
336
|
-
delete clone.
|
|
336
|
+
delete clone.T;
|
|
337
337
|
ActiveTransition.a.set(node, clone);
|
|
338
338
|
node.j = ActiveTransition;
|
|
339
339
|
if (!optimistic && node.a) {
|
|
340
340
|
for (let i = 0; i < node.a.length; i++)
|
|
341
|
-
node.a[i].
|
|
341
|
+
node.a[i].c.push(clone);
|
|
342
342
|
}
|
|
343
|
-
if (node.
|
|
344
|
-
clone.
|
|
345
|
-
for (let i = 0, length = node.
|
|
346
|
-
!node.
|
|
343
|
+
if (node.c) {
|
|
344
|
+
clone.c = [];
|
|
345
|
+
for (let i = 0, length = node.c.length; i < length; i++) {
|
|
346
|
+
!node.c[i].d && clone.c.push(cloneGraph(node.c[i], optimistic));
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
return clone;
|
|
350
350
|
}
|
|
351
351
|
function latestTransition(t) {
|
|
352
|
-
while (t.
|
|
353
|
-
t = t.
|
|
352
|
+
while (t.E instanceof Transition)
|
|
353
|
+
t = t.E;
|
|
354
354
|
return t;
|
|
355
355
|
}
|
|
356
356
|
function replaceSourceObservers(node, transition2) {
|
|
@@ -360,16 +360,16 @@ function replaceSourceObservers(node, transition2) {
|
|
|
360
360
|
for (let i = 0; i < node.a.length; i++) {
|
|
361
361
|
transitionSource = transition2.a.get(node.a[i]);
|
|
362
362
|
source = transitionSource || node.a[i];
|
|
363
|
-
if (source.
|
|
364
|
-
source.
|
|
365
|
-
!transitionSource && source.
|
|
363
|
+
if (source.c && (swap = source.c.indexOf(node)) !== -1) {
|
|
364
|
+
source.c[swap] = transitionSource ? node.d : source.c[source.c.length - 1];
|
|
365
|
+
!transitionSource && source.c.pop();
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
369
|
function cloneQueue(queue, parent, transition2) {
|
|
370
370
|
const clone = Object.create(Object.getPrototypeOf(queue));
|
|
371
371
|
Object.assign(clone, queue, {
|
|
372
|
-
|
|
372
|
+
d: queue,
|
|
373
373
|
k: parent,
|
|
374
374
|
f: [],
|
|
375
375
|
enqueue(type, fn) {
|
|
@@ -377,8 +377,8 @@ function cloneQueue(queue, parent, transition2) {
|
|
|
377
377
|
transition2.enqueue(type, fn);
|
|
378
378
|
},
|
|
379
379
|
notify(node, type, flags) {
|
|
380
|
-
node = node.
|
|
381
|
-
if (!clone.
|
|
380
|
+
node = node.d || node;
|
|
381
|
+
if (!clone.L || type & LOADING_BIT) {
|
|
382
382
|
type &= ~LOADING_BIT;
|
|
383
383
|
transition2 = latestTransition(transition2);
|
|
384
384
|
transition2.notify(node, LOADING_BIT, flags);
|
|
@@ -389,14 +389,14 @@ function cloneQueue(queue, parent, transition2) {
|
|
|
389
389
|
}
|
|
390
390
|
});
|
|
391
391
|
parent.f.push(clone);
|
|
392
|
-
transition2.
|
|
392
|
+
transition2.H.set(queue, clone);
|
|
393
393
|
for (const child of queue.f) {
|
|
394
394
|
cloneQueue(child, clone, transition2);
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
397
|
function resolveQueues(children) {
|
|
398
398
|
for (const child of children) {
|
|
399
|
-
const og = child.
|
|
399
|
+
const og = child.d;
|
|
400
400
|
if (og) {
|
|
401
401
|
const clonedChildren = child.f;
|
|
402
402
|
delete child.enqueue;
|
|
@@ -404,10 +404,10 @@ function resolveQueues(children) {
|
|
|
404
404
|
delete child.k;
|
|
405
405
|
delete child.f;
|
|
406
406
|
Object.assign(og, child);
|
|
407
|
-
delete og.
|
|
407
|
+
delete og.d;
|
|
408
408
|
resolveQueues(clonedChildren);
|
|
409
|
-
} else if (child.k.
|
|
410
|
-
child.k.
|
|
409
|
+
} else if (child.k.d) {
|
|
410
|
+
child.k.d.addChild(child);
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
413
|
}
|
|
@@ -416,22 +416,22 @@ function mergeTransitions(t1, t2) {
|
|
|
416
416
|
key.j = t1;
|
|
417
417
|
t1.a.set(key, value);
|
|
418
418
|
});
|
|
419
|
-
t2.
|
|
419
|
+
t2.J.forEach((c) => {
|
|
420
420
|
c.j = t1;
|
|
421
|
-
t1.
|
|
421
|
+
t1.J.add(c);
|
|
422
422
|
});
|
|
423
|
-
t2.
|
|
424
|
-
t2.
|
|
423
|
+
t2.I.forEach((p) => t1.I.add(p));
|
|
424
|
+
t2.s.forEach((n) => t1.s.add(n));
|
|
425
425
|
t1.merge(t2);
|
|
426
|
-
t2.
|
|
426
|
+
t2.E = t1;
|
|
427
427
|
}
|
|
428
428
|
function getTransitionSource(input) {
|
|
429
429
|
return ActiveTransition && ActiveTransition.a.get(input) || input;
|
|
430
430
|
}
|
|
431
431
|
function getQueue(node) {
|
|
432
432
|
var _a;
|
|
433
|
-
const transition2 = ActiveTransition || ((_a = node.
|
|
434
|
-
return transition2 && transition2.
|
|
433
|
+
const transition2 = ActiveTransition || ((_a = node.d) == null ? void 0 : _a.j);
|
|
434
|
+
return transition2 && transition2.H.get(node.C) || node.C;
|
|
435
435
|
}
|
|
436
436
|
function initialDispose(node) {
|
|
437
437
|
let current = node.m;
|
|
@@ -444,7 +444,7 @@ function initialDispose(node) {
|
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
446
|
function finishTransition(transition2) {
|
|
447
|
-
if (transition2.
|
|
447
|
+
if (transition2.E || transition2.Y || transition2.I.size || transition2.s.size)
|
|
448
448
|
return;
|
|
449
449
|
globalQueue.g[0].push.apply(globalQueue.g[0], transition2.g[0]);
|
|
450
450
|
globalQueue.g[1].push.apply(globalQueue.g[1], transition2.g[1]);
|
|
@@ -456,14 +456,14 @@ function finishTransition(transition2) {
|
|
|
456
456
|
}
|
|
457
457
|
if (clone.a)
|
|
458
458
|
replaceSourceObservers(clone, transition2);
|
|
459
|
-
if (clone.
|
|
459
|
+
if (clone.J) {
|
|
460
460
|
clone.dispose();
|
|
461
461
|
clone.emptyDisposal();
|
|
462
462
|
delete source.j;
|
|
463
463
|
continue;
|
|
464
464
|
}
|
|
465
|
-
if (clone.Z || clone.
|
|
466
|
-
source.dispose(clone.
|
|
465
|
+
if (clone.Z || clone.b === STATE_DISPOSED) {
|
|
466
|
+
source.dispose(clone.b === STATE_DISPOSED);
|
|
467
467
|
source.emptyDisposal();
|
|
468
468
|
delete clone.Z;
|
|
469
469
|
} else {
|
|
@@ -471,18 +471,18 @@ function finishTransition(transition2) {
|
|
|
471
471
|
delete clone.n;
|
|
472
472
|
}
|
|
473
473
|
Object.assign(source, clone);
|
|
474
|
-
delete source.
|
|
474
|
+
delete source.d;
|
|
475
475
|
let current = clone.m;
|
|
476
|
-
if ((current == null ? void 0 : current.
|
|
477
|
-
current.
|
|
476
|
+
if ((current == null ? void 0 : current.y) === clone)
|
|
477
|
+
current.y = source;
|
|
478
478
|
while ((current == null ? void 0 : current.k) === clone) {
|
|
479
479
|
current.k = source;
|
|
480
480
|
current = current.m;
|
|
481
481
|
}
|
|
482
482
|
delete source.j;
|
|
483
483
|
}
|
|
484
|
-
transition2.
|
|
485
|
-
for (const reset of transition2.
|
|
484
|
+
transition2.E = true;
|
|
485
|
+
for (const reset of transition2.J) {
|
|
486
486
|
delete reset.j;
|
|
487
487
|
reset();
|
|
488
488
|
}
|
|
@@ -506,11 +506,11 @@ var Owner = class {
|
|
|
506
506
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
507
507
|
k = null;
|
|
508
508
|
m = null;
|
|
509
|
-
|
|
510
|
-
|
|
509
|
+
y = null;
|
|
510
|
+
b = STATE_CLEAN;
|
|
511
511
|
n = null;
|
|
512
|
-
|
|
513
|
-
|
|
512
|
+
z = defaultContext;
|
|
513
|
+
C = globalQueue;
|
|
514
514
|
fa = 0;
|
|
515
515
|
id = null;
|
|
516
516
|
constructor(id = null, skipAppend = false) {
|
|
@@ -521,23 +521,23 @@ var Owner = class {
|
|
|
521
521
|
}
|
|
522
522
|
append(child) {
|
|
523
523
|
child.k = this;
|
|
524
|
-
child.
|
|
524
|
+
child.y = this;
|
|
525
525
|
if (this.m)
|
|
526
|
-
this.m.
|
|
526
|
+
this.m.y = child;
|
|
527
527
|
child.m = this.m;
|
|
528
528
|
this.m = child;
|
|
529
529
|
if (this.id != null && child.id == null)
|
|
530
530
|
child.id = this.getNextChildId();
|
|
531
|
-
if (child.
|
|
532
|
-
child.
|
|
531
|
+
if (child.z !== this.z) {
|
|
532
|
+
child.z = { ...this.z, ...child.z };
|
|
533
533
|
}
|
|
534
|
-
if (this.
|
|
535
|
-
child.
|
|
534
|
+
if (this.C)
|
|
535
|
+
child.C = this.C;
|
|
536
536
|
}
|
|
537
537
|
dispose(self = true) {
|
|
538
|
-
if (this.
|
|
538
|
+
if (this.b === STATE_DISPOSED)
|
|
539
539
|
return;
|
|
540
|
-
let head = self ? this.
|
|
540
|
+
let head = self ? this.y || this.k : this, current = this.m, next = null;
|
|
541
541
|
while (current && current.k === this) {
|
|
542
542
|
current.dispose(true);
|
|
543
543
|
next = current.m;
|
|
@@ -546,19 +546,19 @@ var Owner = class {
|
|
|
546
546
|
}
|
|
547
547
|
this.fa = 0;
|
|
548
548
|
if (self)
|
|
549
|
-
this.
|
|
549
|
+
this.M();
|
|
550
550
|
if (current)
|
|
551
|
-
current.
|
|
551
|
+
current.y = !self ? this : this.y;
|
|
552
552
|
if (head)
|
|
553
553
|
head.m = current;
|
|
554
554
|
}
|
|
555
|
-
|
|
556
|
-
if (this.
|
|
557
|
-
this.
|
|
555
|
+
M() {
|
|
556
|
+
if (this.y)
|
|
557
|
+
this.y.m = null;
|
|
558
558
|
this.k = null;
|
|
559
|
-
this.
|
|
560
|
-
this.
|
|
561
|
-
this.
|
|
559
|
+
this.y = null;
|
|
560
|
+
this.z = defaultContext;
|
|
561
|
+
this.b = STATE_DISPOSED;
|
|
562
562
|
this.emptyDisposal();
|
|
563
563
|
}
|
|
564
564
|
emptyDisposal() {
|
|
@@ -587,7 +587,7 @@ function getContext(context, owner = currentOwner) {
|
|
|
587
587
|
if (!owner) {
|
|
588
588
|
throw new NoOwnerError();
|
|
589
589
|
}
|
|
590
|
-
const value = hasContext(context, owner) ? owner.
|
|
590
|
+
const value = hasContext(context, owner) ? owner.z[context.id] : context.defaultValue;
|
|
591
591
|
if (isUndefined(value)) {
|
|
592
592
|
throw new ContextNotFoundError();
|
|
593
593
|
}
|
|
@@ -597,13 +597,13 @@ function setContext(context, value, owner = currentOwner) {
|
|
|
597
597
|
if (!owner) {
|
|
598
598
|
throw new NoOwnerError();
|
|
599
599
|
}
|
|
600
|
-
owner.
|
|
601
|
-
...owner.
|
|
600
|
+
owner.z = {
|
|
601
|
+
...owner.z,
|
|
602
602
|
[context.id]: isUndefined(value) ? context.defaultValue : value
|
|
603
603
|
};
|
|
604
604
|
}
|
|
605
605
|
function hasContext(context, owner = currentOwner) {
|
|
606
|
-
return !isUndefined(owner == null ? void 0 : owner.
|
|
606
|
+
return !isUndefined(owner == null ? void 0 : owner.z[context.id]);
|
|
607
607
|
}
|
|
608
608
|
function onCleanup(fn) {
|
|
609
609
|
if (!currentOwner)
|
|
@@ -641,10 +641,10 @@ function getObserver() {
|
|
|
641
641
|
var UNCHANGED = Symbol(0);
|
|
642
642
|
var Computation = class extends Owner {
|
|
643
643
|
a = null;
|
|
644
|
-
|
|
644
|
+
c = null;
|
|
645
645
|
l;
|
|
646
|
-
|
|
647
|
-
|
|
646
|
+
O;
|
|
647
|
+
P;
|
|
648
648
|
// Used in __DEV__ mode, hopefully removed in production
|
|
649
649
|
la;
|
|
650
650
|
// Using false is an optimization as an alternative to _equals: () => false
|
|
@@ -653,19 +653,19 @@ var Computation = class extends Owner {
|
|
|
653
653
|
ea;
|
|
654
654
|
ha = false;
|
|
655
655
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
656
|
-
|
|
656
|
+
i = 0;
|
|
657
657
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
658
658
|
ba = DEFAULT_FLAGS;
|
|
659
|
-
|
|
660
|
-
|
|
659
|
+
Q = -1;
|
|
660
|
+
F = false;
|
|
661
661
|
j;
|
|
662
|
-
|
|
663
|
-
|
|
662
|
+
d;
|
|
663
|
+
J = false;
|
|
664
664
|
constructor(initialValue, compute2, options) {
|
|
665
665
|
super(options == null ? void 0 : options.id, compute2 === null);
|
|
666
|
-
this.
|
|
667
|
-
this.
|
|
668
|
-
this.
|
|
666
|
+
this.P = compute2;
|
|
667
|
+
this.b = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
668
|
+
this.i = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
669
669
|
this.l = initialValue;
|
|
670
670
|
if ((options == null ? void 0 : options.equals) !== void 0)
|
|
671
671
|
this.aa = options.equals;
|
|
@@ -678,9 +678,9 @@ var Computation = class extends Owner {
|
|
|
678
678
|
}
|
|
679
679
|
ga() {
|
|
680
680
|
track(this);
|
|
681
|
-
newFlags |= this.
|
|
682
|
-
if (this.
|
|
683
|
-
throw this.
|
|
681
|
+
newFlags |= this.i & ~currentMask;
|
|
682
|
+
if (this.i & ERROR_BIT) {
|
|
683
|
+
throw this.O;
|
|
684
684
|
} else {
|
|
685
685
|
return this.l;
|
|
686
686
|
}
|
|
@@ -690,16 +690,16 @@ var Computation = class extends Owner {
|
|
|
690
690
|
* Automatically re-executes the surrounding computation when the value changes
|
|
691
691
|
*/
|
|
692
692
|
read() {
|
|
693
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.
|
|
693
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.i & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
694
694
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
695
695
|
if (clone !== this)
|
|
696
696
|
return clone.read();
|
|
697
697
|
}
|
|
698
|
-
if (this.
|
|
699
|
-
if (this.
|
|
698
|
+
if (this.P) {
|
|
699
|
+
if (this.i & ERROR_BIT && this.Q <= clock)
|
|
700
700
|
update(this);
|
|
701
701
|
else
|
|
702
|
-
this.
|
|
702
|
+
this.D();
|
|
703
703
|
}
|
|
704
704
|
return this.ga();
|
|
705
705
|
}
|
|
@@ -711,49 +711,49 @@ var Computation = class extends Owner {
|
|
|
711
711
|
* before continuing
|
|
712
712
|
*/
|
|
713
713
|
wait() {
|
|
714
|
-
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.
|
|
714
|
+
if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.i & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
715
715
|
const clone = ActiveTransition.a.get(this) || cloneGraph(this);
|
|
716
716
|
if (clone !== this)
|
|
717
717
|
return clone.wait();
|
|
718
718
|
}
|
|
719
|
-
if (this.
|
|
720
|
-
if (this.
|
|
719
|
+
if (this.P) {
|
|
720
|
+
if (this.i & ERROR_BIT && this.Q <= clock)
|
|
721
721
|
update(this);
|
|
722
722
|
else
|
|
723
|
-
this.
|
|
723
|
+
this.D();
|
|
724
724
|
}
|
|
725
|
-
if ((notStale || this.
|
|
725
|
+
if ((notStale || this.i & UNINITIALIZED_BIT) && this.i & LOADING_BIT) {
|
|
726
726
|
track(this);
|
|
727
727
|
throw new NotReadyError();
|
|
728
728
|
}
|
|
729
|
-
if (staleCheck && this.
|
|
729
|
+
if (staleCheck && this.i & LOADING_BIT) {
|
|
730
730
|
staleCheck.l = true;
|
|
731
731
|
}
|
|
732
732
|
return this.ga();
|
|
733
733
|
}
|
|
734
734
|
/** Update the computation with a new value. */
|
|
735
735
|
write(value, flags = 0, raw = false) {
|
|
736
|
-
if (ActiveTransition && !this.
|
|
736
|
+
if (ActiveTransition && !this.d) {
|
|
737
737
|
const clone = cloneGraph(this);
|
|
738
738
|
if (clone !== this)
|
|
739
739
|
return clone.write(value, flags, raw);
|
|
740
740
|
}
|
|
741
741
|
const newValue = !raw && typeof value === "function" ? value(this.l) : value;
|
|
742
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
742
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.i & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
|
|
743
743
|
this.aa === false || !this.aa(this.l, newValue));
|
|
744
744
|
if (valueChanged) {
|
|
745
745
|
this.l = newValue;
|
|
746
|
-
this.
|
|
746
|
+
this.O = void 0;
|
|
747
747
|
}
|
|
748
|
-
const changedFlagsMask = this.
|
|
749
|
-
this.
|
|
750
|
-
this.
|
|
751
|
-
if (this.
|
|
752
|
-
for (let i = 0; i < this.
|
|
748
|
+
const changedFlagsMask = this.i ^ flags, changedFlags = changedFlagsMask & flags;
|
|
749
|
+
this.i = flags;
|
|
750
|
+
this.Q = clock + 1;
|
|
751
|
+
if (this.c) {
|
|
752
|
+
for (let i = 0; i < this.c.length; i++) {
|
|
753
753
|
if (valueChanged) {
|
|
754
|
-
this.
|
|
754
|
+
this.c[i].t(STATE_DIRTY);
|
|
755
755
|
} else if (changedFlagsMask) {
|
|
756
|
-
this.
|
|
756
|
+
this.c[i]._(changedFlagsMask, changedFlags);
|
|
757
757
|
}
|
|
758
758
|
}
|
|
759
759
|
}
|
|
@@ -762,14 +762,14 @@ var Computation = class extends Owner {
|
|
|
762
762
|
/**
|
|
763
763
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
764
764
|
*/
|
|
765
|
-
|
|
766
|
-
if (this.
|
|
765
|
+
t(state, skipQueue) {
|
|
766
|
+
if (this.b >= state && !this.F)
|
|
767
767
|
return;
|
|
768
|
-
this.
|
|
769
|
-
this.
|
|
770
|
-
if (this.
|
|
771
|
-
for (let i = 0; i < this.
|
|
772
|
-
this.
|
|
768
|
+
this.F = !!skipQueue;
|
|
769
|
+
this.b = state;
|
|
770
|
+
if (this.c) {
|
|
771
|
+
for (let i = 0; i < this.c.length; i++) {
|
|
772
|
+
this.c[i].t(STATE_CHECK, skipQueue);
|
|
773
773
|
}
|
|
774
774
|
}
|
|
775
775
|
}
|
|
@@ -780,35 +780,35 @@ var Computation = class extends Owner {
|
|
|
780
780
|
* @param newFlags The source's new flags, masked to just the changed ones.
|
|
781
781
|
*/
|
|
782
782
|
_(mask, newFlags2) {
|
|
783
|
-
if (this.
|
|
783
|
+
if (this.b >= STATE_DIRTY)
|
|
784
784
|
return;
|
|
785
785
|
if (mask & this.ba) {
|
|
786
|
-
this.
|
|
786
|
+
this.t(STATE_DIRTY);
|
|
787
787
|
return;
|
|
788
788
|
}
|
|
789
|
-
if (this.
|
|
789
|
+
if (this.b >= STATE_CHECK && !this.F)
|
|
790
790
|
return;
|
|
791
|
-
const prevFlags = this.
|
|
791
|
+
const prevFlags = this.i & mask;
|
|
792
792
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
793
793
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
794
|
-
this.
|
|
794
|
+
this.t(STATE_CHECK);
|
|
795
795
|
} else {
|
|
796
|
-
this.
|
|
797
|
-
if (this.
|
|
798
|
-
for (let i = 0; i < this.
|
|
799
|
-
this.
|
|
796
|
+
this.i ^= deltaFlags;
|
|
797
|
+
if (this.c) {
|
|
798
|
+
for (let i = 0; i < this.c.length; i++) {
|
|
799
|
+
this.c[i]._(mask, newFlags2);
|
|
800
800
|
}
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
803
|
}
|
|
804
|
-
|
|
805
|
-
if (ActiveTransition && !this.
|
|
804
|
+
N(error) {
|
|
805
|
+
if (ActiveTransition && !this.d) {
|
|
806
806
|
const clone = cloneGraph(this);
|
|
807
807
|
if (clone !== this)
|
|
808
|
-
return clone.
|
|
808
|
+
return clone.N(error);
|
|
809
809
|
}
|
|
810
|
-
this.
|
|
811
|
-
this.write(UNCHANGED, this.
|
|
810
|
+
this.O = error;
|
|
811
|
+
this.write(UNCHANGED, this.i & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
812
812
|
}
|
|
813
813
|
/**
|
|
814
814
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -817,48 +817,48 @@ var Computation = class extends Owner {
|
|
|
817
817
|
*
|
|
818
818
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
819
819
|
*/
|
|
820
|
-
|
|
821
|
-
if (!this.
|
|
820
|
+
D() {
|
|
821
|
+
if (!this.P) {
|
|
822
822
|
return;
|
|
823
823
|
}
|
|
824
|
-
if (this.
|
|
824
|
+
if (this.b === STATE_DISPOSED) {
|
|
825
825
|
return;
|
|
826
826
|
}
|
|
827
|
-
if (this.
|
|
827
|
+
if (this.b === STATE_CLEAN) {
|
|
828
828
|
return;
|
|
829
829
|
}
|
|
830
830
|
let observerFlags = 0;
|
|
831
|
-
if (this.
|
|
831
|
+
if (this.b === STATE_CHECK) {
|
|
832
832
|
for (let i = 0; i < this.a.length; i++) {
|
|
833
833
|
const source = getTransitionSource(this.a[i]);
|
|
834
|
-
source.
|
|
835
|
-
observerFlags |= source.
|
|
836
|
-
if (this.
|
|
834
|
+
source.D();
|
|
835
|
+
observerFlags |= source.i & ~UNINITIALIZED_BIT;
|
|
836
|
+
if (this.b === STATE_DIRTY) {
|
|
837
837
|
break;
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
840
|
}
|
|
841
|
-
if (this.
|
|
841
|
+
if (this.b === STATE_DIRTY) {
|
|
842
842
|
update(this);
|
|
843
843
|
} else {
|
|
844
844
|
this.write(UNCHANGED, observerFlags);
|
|
845
|
-
this.
|
|
845
|
+
this.b = STATE_CLEAN;
|
|
846
846
|
}
|
|
847
847
|
}
|
|
848
848
|
/**
|
|
849
849
|
* Remove ourselves from the owner graph and the computation graph
|
|
850
850
|
*/
|
|
851
|
-
|
|
852
|
-
if (this.
|
|
851
|
+
M() {
|
|
852
|
+
if (this.b === STATE_DISPOSED)
|
|
853
853
|
return;
|
|
854
854
|
if (this.a)
|
|
855
855
|
removeSourceObservers(this, 0);
|
|
856
|
-
super.
|
|
856
|
+
super.M();
|
|
857
857
|
}
|
|
858
858
|
};
|
|
859
859
|
function track(computation) {
|
|
860
|
-
if (ActiveTransition && computation.
|
|
861
|
-
computation = computation.
|
|
860
|
+
if (ActiveTransition && computation.d)
|
|
861
|
+
computation = computation.d;
|
|
862
862
|
if (currentObserver) {
|
|
863
863
|
if (!newSources && currentObserver.a && currentObserver.a[newSourcesIndex] === computation) {
|
|
864
864
|
newSourcesIndex++;
|
|
@@ -868,7 +868,7 @@ function track(computation) {
|
|
|
868
868
|
newSources.push(computation);
|
|
869
869
|
}
|
|
870
870
|
if (updateCheck) {
|
|
871
|
-
updateCheck.l = computation.
|
|
871
|
+
updateCheck.l = computation.Q > currentObserver.Q;
|
|
872
872
|
}
|
|
873
873
|
}
|
|
874
874
|
}
|
|
@@ -878,19 +878,19 @@ function update(node) {
|
|
|
878
878
|
newSourcesIndex = 0;
|
|
879
879
|
newFlags = 0;
|
|
880
880
|
try {
|
|
881
|
-
if (ActiveTransition && node.
|
|
882
|
-
initialDispose(node.
|
|
881
|
+
if (ActiveTransition && node.d && !node.Z) {
|
|
882
|
+
initialDispose(node.d);
|
|
883
883
|
node.Z = true;
|
|
884
884
|
}
|
|
885
885
|
node.dispose(false);
|
|
886
886
|
node.emptyDisposal();
|
|
887
|
-
const result = compute(node, node.
|
|
887
|
+
const result = compute(node, node.P, node);
|
|
888
888
|
node.write(result, newFlags, true);
|
|
889
889
|
} catch (error) {
|
|
890
890
|
if (error instanceof NotReadyError) {
|
|
891
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.
|
|
891
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.i & UNINITIALIZED_BIT);
|
|
892
892
|
} else {
|
|
893
|
-
node.
|
|
893
|
+
node.N(error);
|
|
894
894
|
}
|
|
895
895
|
} finally {
|
|
896
896
|
if (newSources) {
|
|
@@ -907,10 +907,10 @@ function update(node) {
|
|
|
907
907
|
let source;
|
|
908
908
|
for (let i = newSourcesIndex; i < node.a.length; i++) {
|
|
909
909
|
source = getTransitionSource(node.a[i]);
|
|
910
|
-
if (!source.
|
|
911
|
-
source.
|
|
910
|
+
if (!source.c)
|
|
911
|
+
source.c = [node];
|
|
912
912
|
else
|
|
913
|
-
source.
|
|
913
|
+
source.c.push(node);
|
|
914
914
|
}
|
|
915
915
|
} else if (node.a && newSourcesIndex < node.a.length) {
|
|
916
916
|
removeSourceObservers(node, newSourcesIndex);
|
|
@@ -919,8 +919,8 @@ function update(node) {
|
|
|
919
919
|
newSources = prevSources;
|
|
920
920
|
newSourcesIndex = prevSourcesIndex;
|
|
921
921
|
newFlags = prevFlags;
|
|
922
|
-
node.
|
|
923
|
-
node.
|
|
922
|
+
node.Q = clock + 1;
|
|
923
|
+
node.b = STATE_CLEAN;
|
|
924
924
|
}
|
|
925
925
|
}
|
|
926
926
|
function isEqual(a, b) {
|
|
@@ -980,46 +980,6 @@ function latest(fn, fallback) {
|
|
|
980
980
|
notStale = prevNotStale;
|
|
981
981
|
}
|
|
982
982
|
}
|
|
983
|
-
function runWithObserver(observer, run) {
|
|
984
|
-
const prevSources = newSources, prevSourcesIndex = newSourcesIndex, prevFlags = newFlags;
|
|
985
|
-
newSources = null;
|
|
986
|
-
newSourcesIndex = observer.a ? observer.a.length : 0;
|
|
987
|
-
newFlags = 0;
|
|
988
|
-
try {
|
|
989
|
-
return compute(observer, run, observer);
|
|
990
|
-
} catch (error) {
|
|
991
|
-
if (error instanceof NotReadyError) {
|
|
992
|
-
observer.write(
|
|
993
|
-
UNCHANGED,
|
|
994
|
-
newFlags | LOADING_BIT | observer.h & UNINITIALIZED_BIT
|
|
995
|
-
);
|
|
996
|
-
} else {
|
|
997
|
-
observer.D(error);
|
|
998
|
-
}
|
|
999
|
-
} finally {
|
|
1000
|
-
if (newSources) {
|
|
1001
|
-
if (newSourcesIndex > 0) {
|
|
1002
|
-
observer.a.length = newSourcesIndex + newSources.length;
|
|
1003
|
-
for (let i = 0; i < newSources.length; i++) {
|
|
1004
|
-
observer.a[newSourcesIndex + i] = newSources[i];
|
|
1005
|
-
}
|
|
1006
|
-
} else {
|
|
1007
|
-
observer.a = newSources;
|
|
1008
|
-
}
|
|
1009
|
-
let source;
|
|
1010
|
-
for (let i = newSourcesIndex; i < observer.a.length; i++) {
|
|
1011
|
-
source = observer.a[i];
|
|
1012
|
-
if (!source.b)
|
|
1013
|
-
source.b = [observer];
|
|
1014
|
-
else
|
|
1015
|
-
source.b.push(observer);
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
newSources = prevSources;
|
|
1019
|
-
newSourcesIndex = prevSourcesIndex;
|
|
1020
|
-
newFlags = prevFlags;
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
983
|
function compute(owner, fn, observer) {
|
|
1024
984
|
const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
|
|
1025
985
|
currentObserver = observer;
|
|
@@ -1039,66 +999,66 @@ function compute(owner, fn, observer) {
|
|
|
1039
999
|
var Effect = class extends Computation {
|
|
1040
1000
|
ca;
|
|
1041
1001
|
$;
|
|
1042
|
-
|
|
1002
|
+
u;
|
|
1043
1003
|
da = false;
|
|
1044
|
-
|
|
1045
|
-
|
|
1004
|
+
T;
|
|
1005
|
+
r;
|
|
1046
1006
|
constructor(initialValue, compute2, effect, error, options) {
|
|
1047
1007
|
super(initialValue, compute2, options);
|
|
1048
1008
|
this.ca = effect;
|
|
1049
1009
|
this.$ = error;
|
|
1050
|
-
this.
|
|
1051
|
-
this.
|
|
1052
|
-
if (this.
|
|
1053
|
-
this.
|
|
1054
|
-
return !this.
|
|
1010
|
+
this.T = initialValue;
|
|
1011
|
+
this.r = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
|
|
1012
|
+
if (this.r === EFFECT_RENDER) {
|
|
1013
|
+
this.P = function(p) {
|
|
1014
|
+
return !this.d && clock > this.C.created && !(this.i & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
1055
1015
|
};
|
|
1056
1016
|
}
|
|
1057
|
-
this.
|
|
1058
|
-
!(options == null ? void 0 : options.defer) && (this.
|
|
1017
|
+
this.D();
|
|
1018
|
+
!(options == null ? void 0 : options.defer) && (this.r === EFFECT_USER ? getQueue(this).enqueue(this.r, this.w.bind(this)) : this.w(this.r));
|
|
1059
1019
|
}
|
|
1060
1020
|
write(value, flags = 0) {
|
|
1061
|
-
if (this.
|
|
1062
|
-
this.
|
|
1063
|
-
if (this.
|
|
1064
|
-
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.
|
|
1021
|
+
if (this.b == STATE_DIRTY) {
|
|
1022
|
+
this.i = flags;
|
|
1023
|
+
if (this.r === EFFECT_RENDER) {
|
|
1024
|
+
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.i);
|
|
1065
1025
|
}
|
|
1066
1026
|
}
|
|
1067
1027
|
if (value === UNCHANGED)
|
|
1068
1028
|
return this.l;
|
|
1069
1029
|
this.l = value;
|
|
1070
1030
|
this.da = true;
|
|
1071
|
-
this.
|
|
1031
|
+
this.O = void 0;
|
|
1072
1032
|
return value;
|
|
1073
1033
|
}
|
|
1074
|
-
|
|
1075
|
-
if (this.
|
|
1034
|
+
t(state, skipQueue) {
|
|
1035
|
+
if (this.b >= state || skipQueue)
|
|
1076
1036
|
return;
|
|
1077
|
-
if (this.
|
|
1078
|
-
getQueue(this).enqueue(this.
|
|
1079
|
-
this.
|
|
1037
|
+
if (this.b === STATE_CLEAN || this.d && !ActiveTransition)
|
|
1038
|
+
getQueue(this).enqueue(this.r, this.w.bind(this));
|
|
1039
|
+
this.b = state;
|
|
1080
1040
|
}
|
|
1081
1041
|
_(mask, newFlags2) {
|
|
1082
|
-
if (this.
|
|
1083
|
-
if (this.
|
|
1042
|
+
if (this.d) {
|
|
1043
|
+
if (this.b >= STATE_DIRTY)
|
|
1084
1044
|
return;
|
|
1085
1045
|
if (mask & 3) {
|
|
1086
|
-
this.
|
|
1046
|
+
this.t(STATE_DIRTY);
|
|
1087
1047
|
return;
|
|
1088
1048
|
}
|
|
1089
1049
|
}
|
|
1090
1050
|
super._(mask, newFlags2);
|
|
1091
1051
|
}
|
|
1092
|
-
|
|
1093
|
-
this.
|
|
1052
|
+
N(error) {
|
|
1053
|
+
this.O = error;
|
|
1094
1054
|
getQueue(this).notify(this, LOADING_BIT, 0);
|
|
1095
|
-
this.
|
|
1096
|
-
if (this.
|
|
1055
|
+
this.i = ERROR_BIT;
|
|
1056
|
+
if (this.r === EFFECT_USER) {
|
|
1097
1057
|
try {
|
|
1098
1058
|
return this.$ ? this.$(error, () => {
|
|
1099
1059
|
var _a;
|
|
1100
|
-
(_a = this.
|
|
1101
|
-
this.
|
|
1060
|
+
(_a = this.u) == null ? void 0 : _a.call(this);
|
|
1061
|
+
this.u = void 0;
|
|
1102
1062
|
}) : console.error(error);
|
|
1103
1063
|
} catch (e) {
|
|
1104
1064
|
error = e;
|
|
@@ -1107,52 +1067,85 @@ var Effect = class extends Computation {
|
|
|
1107
1067
|
if (!getQueue(this).notify(this, ERROR_BIT, ERROR_BIT))
|
|
1108
1068
|
throw error;
|
|
1109
1069
|
}
|
|
1110
|
-
|
|
1070
|
+
M() {
|
|
1111
1071
|
var _a;
|
|
1112
|
-
if (this.
|
|
1072
|
+
if (this.b === STATE_DISPOSED)
|
|
1113
1073
|
return;
|
|
1114
1074
|
this.ca = void 0;
|
|
1115
|
-
this.
|
|
1075
|
+
this.T = void 0;
|
|
1116
1076
|
this.$ = void 0;
|
|
1117
|
-
(_a = this.
|
|
1118
|
-
this.
|
|
1077
|
+
(_a = this.u) == null ? void 0 : _a.call(this);
|
|
1078
|
+
this.u = void 0;
|
|
1119
1079
|
getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
|
|
1120
|
-
super.
|
|
1080
|
+
super.M();
|
|
1121
1081
|
}
|
|
1122
|
-
|
|
1082
|
+
w(type) {
|
|
1123
1083
|
var _a;
|
|
1124
1084
|
if (type) {
|
|
1125
|
-
const effect = this.
|
|
1126
|
-
if (effect.da && effect.
|
|
1127
|
-
(_a = effect.
|
|
1085
|
+
const effect = this.d || this;
|
|
1086
|
+
if (effect.da && effect.b !== STATE_DISPOSED) {
|
|
1087
|
+
(_a = effect.u) == null ? void 0 : _a.call(effect);
|
|
1128
1088
|
try {
|
|
1129
|
-
effect.
|
|
1089
|
+
effect.u = effect.ca(effect.l, effect.T);
|
|
1130
1090
|
} catch (e) {
|
|
1131
1091
|
if (!getQueue(effect).notify(effect, ERROR_BIT, ERROR_BIT))
|
|
1132
1092
|
throw e;
|
|
1133
1093
|
} finally {
|
|
1134
|
-
effect.
|
|
1094
|
+
effect.T = effect.l;
|
|
1135
1095
|
effect.da = false;
|
|
1136
1096
|
}
|
|
1137
1097
|
}
|
|
1138
1098
|
} else
|
|
1139
|
-
this.
|
|
1099
|
+
this.b !== STATE_CLEAN && runTop(this);
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1102
|
+
var TrackedEffect = class extends Computation {
|
|
1103
|
+
r = EFFECT_USER;
|
|
1104
|
+
u;
|
|
1105
|
+
constructor(compute2, options) {
|
|
1106
|
+
super(void 0, () => {
|
|
1107
|
+
var _a;
|
|
1108
|
+
(_a = this.u) == null ? void 0 : _a.call(this);
|
|
1109
|
+
this.u = latest(compute2);
|
|
1110
|
+
return void 0;
|
|
1111
|
+
}, options);
|
|
1112
|
+
getQueue(this).enqueue(this.r, this.w.bind(this));
|
|
1113
|
+
}
|
|
1114
|
+
t(state, skipQueue) {
|
|
1115
|
+
if (this.b >= state || skipQueue)
|
|
1116
|
+
return;
|
|
1117
|
+
if (this.b === STATE_CLEAN || this.d && !ActiveTransition)
|
|
1118
|
+
getQueue(this).enqueue(this.r, this.w.bind(this));
|
|
1119
|
+
this.b = state;
|
|
1120
|
+
}
|
|
1121
|
+
M() {
|
|
1122
|
+
var _a;
|
|
1123
|
+
if (this.b === STATE_DISPOSED)
|
|
1124
|
+
return;
|
|
1125
|
+
(_a = this.u) == null ? void 0 : _a.call(this);
|
|
1126
|
+
this.u = void 0;
|
|
1127
|
+
getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
|
|
1128
|
+
super.M();
|
|
1129
|
+
}
|
|
1130
|
+
w(type) {
|
|
1131
|
+
if (type)
|
|
1132
|
+
this.b !== STATE_CLEAN && runTop(this);
|
|
1140
1133
|
}
|
|
1141
1134
|
};
|
|
1142
1135
|
var EagerComputation = class extends Computation {
|
|
1143
1136
|
constructor(initialValue, compute2, options) {
|
|
1144
1137
|
super(initialValue, compute2, options);
|
|
1145
|
-
!(options == null ? void 0 : options.defer) && this.
|
|
1138
|
+
!(options == null ? void 0 : options.defer) && this.D();
|
|
1146
1139
|
}
|
|
1147
|
-
|
|
1148
|
-
if (this.
|
|
1140
|
+
t(state, skipQueue) {
|
|
1141
|
+
if (this.b >= state && !this.F)
|
|
1149
1142
|
return;
|
|
1150
|
-
if (!skipQueue && (this.
|
|
1151
|
-
getQueue(this).enqueue(EFFECT_PURE, this.
|
|
1152
|
-
super.
|
|
1143
|
+
if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.F))
|
|
1144
|
+
getQueue(this).enqueue(EFFECT_PURE, this.w.bind(this));
|
|
1145
|
+
super.t(state, skipQueue);
|
|
1153
1146
|
}
|
|
1154
|
-
|
|
1155
|
-
this.
|
|
1147
|
+
w() {
|
|
1148
|
+
this.b !== STATE_CLEAN && runTop(this);
|
|
1156
1149
|
}
|
|
1157
1150
|
};
|
|
1158
1151
|
var FirewallComputation = class extends Computation {
|
|
@@ -1160,16 +1153,16 @@ var FirewallComputation = class extends Computation {
|
|
|
1160
1153
|
constructor(compute2) {
|
|
1161
1154
|
super(void 0, compute2);
|
|
1162
1155
|
}
|
|
1163
|
-
|
|
1164
|
-
if (this.
|
|
1156
|
+
t(state, skipQueue) {
|
|
1157
|
+
if (this.b >= state && !this.F)
|
|
1165
1158
|
return;
|
|
1166
|
-
if (!skipQueue && (this.
|
|
1167
|
-
getQueue(this).enqueue(EFFECT_PURE, this.
|
|
1168
|
-
super.
|
|
1169
|
-
this.
|
|
1159
|
+
if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.F))
|
|
1160
|
+
getQueue(this).enqueue(EFFECT_PURE, this.w.bind(this));
|
|
1161
|
+
super.t(state, true);
|
|
1162
|
+
this.F = !!skipQueue;
|
|
1170
1163
|
}
|
|
1171
|
-
|
|
1172
|
-
this.
|
|
1164
|
+
w() {
|
|
1165
|
+
this.b !== STATE_CLEAN && runTop(this);
|
|
1173
1166
|
}
|
|
1174
1167
|
};
|
|
1175
1168
|
function runTop(node) {
|
|
@@ -1177,28 +1170,24 @@ function runTop(node) {
|
|
|
1177
1170
|
for (let current = node; current !== null; current = current.k) {
|
|
1178
1171
|
if (ActiveTransition && current.j)
|
|
1179
1172
|
current = ActiveTransition.a.get(current);
|
|
1180
|
-
if (current.
|
|
1173
|
+
if (current.b !== STATE_CLEAN) {
|
|
1181
1174
|
ancestors.push(current);
|
|
1182
1175
|
}
|
|
1183
1176
|
}
|
|
1184
1177
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
1185
|
-
if (ancestors[i].
|
|
1186
|
-
ancestors[i].
|
|
1178
|
+
if (ancestors[i].b !== STATE_DISPOSED)
|
|
1179
|
+
ancestors[i].D();
|
|
1187
1180
|
}
|
|
1188
1181
|
}
|
|
1189
1182
|
|
|
1190
1183
|
// src/signals.ts
|
|
1191
1184
|
function createSignal(first, second, third) {
|
|
1192
1185
|
if (typeof first === "function") {
|
|
1193
|
-
const
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
);
|
|
1199
|
-
return [node2.read.bind(node2), node2.write.bind(node2)];
|
|
1200
|
-
});
|
|
1201
|
-
return [() => memo()[0](), (value) => memo()[1](value)];
|
|
1186
|
+
const node2 = new Computation(second, first, third);
|
|
1187
|
+
return [node2.read.bind(node2), (v) => {
|
|
1188
|
+
node2.D();
|
|
1189
|
+
return node2.write(v);
|
|
1190
|
+
}];
|
|
1202
1191
|
}
|
|
1203
1192
|
const o = getOwner();
|
|
1204
1193
|
const needsId = (o == null ? void 0 : o.id) != null;
|
|
@@ -1219,12 +1208,12 @@ function createMemo(compute2, value, options) {
|
|
|
1219
1208
|
return () => {
|
|
1220
1209
|
var _a, _b;
|
|
1221
1210
|
if (node) {
|
|
1222
|
-
if (node.
|
|
1211
|
+
if (node.b === STATE_DISPOSED) {
|
|
1223
1212
|
node = void 0;
|
|
1224
1213
|
return resolvedValue;
|
|
1225
1214
|
}
|
|
1226
1215
|
resolvedValue = node.wait();
|
|
1227
|
-
if (!((_a = node.a) == null ? void 0 : _a.length) && ((_b = node.m) == null ? void 0 : _b.k) !== node && !(node.
|
|
1216
|
+
if (!((_a = node.a) == null ? void 0 : _a.length) && ((_b = node.m) == null ? void 0 : _b.k) !== node && !(node.i & UNINITIALIZED_BIT)) {
|
|
1228
1217
|
node.dispose();
|
|
1229
1218
|
node = void 0;
|
|
1230
1219
|
}
|
|
@@ -1262,8 +1251,8 @@ function createAsync(compute2, value, options) {
|
|
|
1262
1251
|
if (abort)
|
|
1263
1252
|
return;
|
|
1264
1253
|
if (transition2)
|
|
1265
|
-
return transition2.runTransition(() => node.
|
|
1266
|
-
node.
|
|
1254
|
+
return transition2.runTransition(() => node.N(error), true);
|
|
1255
|
+
node.N(error);
|
|
1267
1256
|
}
|
|
1268
1257
|
);
|
|
1269
1258
|
} else {
|
|
@@ -1284,10 +1273,10 @@ function createAsync(compute2, value, options) {
|
|
|
1284
1273
|
return;
|
|
1285
1274
|
if (transition2)
|
|
1286
1275
|
return transition2.runTransition(() => {
|
|
1287
|
-
node.
|
|
1276
|
+
node.N(error);
|
|
1288
1277
|
transition2 = null;
|
|
1289
1278
|
}, true);
|
|
1290
|
-
node.
|
|
1279
|
+
node.N(error);
|
|
1291
1280
|
}
|
|
1292
1281
|
})();
|
|
1293
1282
|
}
|
|
@@ -1298,12 +1287,12 @@ function createAsync(compute2, value, options) {
|
|
|
1298
1287
|
const read = node.wait.bind(node);
|
|
1299
1288
|
read.refresh = () => {
|
|
1300
1289
|
let n = node;
|
|
1301
|
-
if (ActiveTransition && !node.
|
|
1290
|
+
if (ActiveTransition && !node.d) {
|
|
1302
1291
|
n = cloneGraph(node);
|
|
1303
1292
|
}
|
|
1304
|
-
n.
|
|
1293
|
+
n.b = STATE_DIRTY;
|
|
1305
1294
|
refreshing = true;
|
|
1306
|
-
n.
|
|
1295
|
+
n.D();
|
|
1307
1296
|
};
|
|
1308
1297
|
return read;
|
|
1309
1298
|
}
|
|
@@ -1311,7 +1300,7 @@ function createEffect(compute2, effect, value, options) {
|
|
|
1311
1300
|
void new Effect(
|
|
1312
1301
|
value,
|
|
1313
1302
|
compute2,
|
|
1314
|
-
effect.effect
|
|
1303
|
+
effect.effect || effect,
|
|
1315
1304
|
effect.error,
|
|
1316
1305
|
options
|
|
1317
1306
|
);
|
|
@@ -1322,6 +1311,30 @@ function createRenderEffect(compute2, effect, value, options) {
|
|
|
1322
1311
|
...options
|
|
1323
1312
|
});
|
|
1324
1313
|
}
|
|
1314
|
+
function createTrackedEffect(compute2, options) {
|
|
1315
|
+
void new TrackedEffect(compute2, options);
|
|
1316
|
+
}
|
|
1317
|
+
function createReaction(effect, options) {
|
|
1318
|
+
let cleanup = void 0;
|
|
1319
|
+
onCleanup(() => cleanup == null ? void 0 : cleanup());
|
|
1320
|
+
return (tracking) => {
|
|
1321
|
+
const node = new Effect(
|
|
1322
|
+
void 0,
|
|
1323
|
+
tracking,
|
|
1324
|
+
() => {
|
|
1325
|
+
var _a;
|
|
1326
|
+
cleanup == null ? void 0 : cleanup();
|
|
1327
|
+
cleanup = (_a = effect.effect || effect) == null ? void 0 : _a();
|
|
1328
|
+
node.dispose(true);
|
|
1329
|
+
},
|
|
1330
|
+
effect.error,
|
|
1331
|
+
{
|
|
1332
|
+
defer: true,
|
|
1333
|
+
...options
|
|
1334
|
+
}
|
|
1335
|
+
);
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1325
1338
|
function createRoot(init, options) {
|
|
1326
1339
|
const owner = new Owner(options == null ? void 0 : options.id);
|
|
1327
1340
|
return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
|
|
@@ -1345,23 +1358,25 @@ function resolve(fn) {
|
|
|
1345
1358
|
});
|
|
1346
1359
|
});
|
|
1347
1360
|
}
|
|
1348
|
-
function
|
|
1349
|
-
const node = new Computation(
|
|
1350
|
-
const reset = () => node.write(
|
|
1351
|
-
function write() {
|
|
1361
|
+
function createOptimistic(first, second, third) {
|
|
1362
|
+
const node = typeof first === "function" ? new Computation(second, first, third) : new Computation(first, null, second);
|
|
1363
|
+
const reset = () => node.write(first);
|
|
1364
|
+
function write(v) {
|
|
1352
1365
|
if (!ActiveTransition)
|
|
1353
|
-
|
|
1366
|
+
throw new Error("createOptimistic can only be updated inside a transition");
|
|
1354
1367
|
ActiveTransition.addOptimistic(reset);
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1368
|
+
cloneGraph(node, true);
|
|
1369
|
+
queueMicrotask(() => {
|
|
1370
|
+
if (reset.j) {
|
|
1371
|
+
node.D();
|
|
1372
|
+
node.write(v);
|
|
1373
|
+
}
|
|
1374
|
+
});
|
|
1360
1375
|
}
|
|
1361
|
-
return [read, write];
|
|
1376
|
+
return [node.read.bind(node), write];
|
|
1362
1377
|
}
|
|
1363
1378
|
function useTransition() {
|
|
1364
|
-
const [pending, setPending] =
|
|
1379
|
+
const [pending, setPending] = createOptimistic(false);
|
|
1365
1380
|
function start(fn) {
|
|
1366
1381
|
transition((resume) => {
|
|
1367
1382
|
setPending(true);
|
|
@@ -1834,7 +1849,7 @@ function deep(store) {
|
|
|
1834
1849
|
}
|
|
1835
1850
|
|
|
1836
1851
|
// src/store/optimistic.ts
|
|
1837
|
-
function
|
|
1852
|
+
function createOptimisticStore(first, second, options) {
|
|
1838
1853
|
const derived = typeof first === "function";
|
|
1839
1854
|
const { store, node } = derived ? createProjectionInternal(first, second, options) : createProjectionInternal(() => {
|
|
1840
1855
|
}, first);
|
|
@@ -1848,7 +1863,7 @@ function createOptimistic(first, second, options) {
|
|
|
1848
1863
|
);
|
|
1849
1864
|
const write = (v) => {
|
|
1850
1865
|
if (!ActiveTransition)
|
|
1851
|
-
throw new Error("
|
|
1866
|
+
throw new Error("createOptimisticStore can only be updated inside a transition");
|
|
1852
1867
|
ActiveTransition.addOptimistic(reset);
|
|
1853
1868
|
cloneGraph(node, true);
|
|
1854
1869
|
queueMicrotask(() => reset.j && storeSetter(store, v));
|
|
@@ -2064,11 +2079,11 @@ function mapArray(list, map, options) {
|
|
|
2064
2079
|
U: new Owner(),
|
|
2065
2080
|
o: 0,
|
|
2066
2081
|
ia: list,
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2082
|
+
G: [],
|
|
2083
|
+
R: map,
|
|
2084
|
+
h: [],
|
|
2085
|
+
e: [],
|
|
2086
|
+
S: keyFn,
|
|
2072
2087
|
p: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
2073
2088
|
q: map.length > 1 ? [] : void 0,
|
|
2074
2089
|
V: options == null ? void 0 : options.fallback
|
|
@@ -2082,53 +2097,53 @@ function updateKeyedMap() {
|
|
|
2082
2097
|
let i, j, mapper = this.p ? () => {
|
|
2083
2098
|
this.p[j] = new Computation(newItems[j], null, pureOptions);
|
|
2084
2099
|
this.q && (this.q[j] = new Computation(j, null, pureOptions));
|
|
2085
|
-
return this.
|
|
2100
|
+
return this.R(
|
|
2086
2101
|
Computation.prototype.read.bind(this.p[j]),
|
|
2087
2102
|
this.q ? Computation.prototype.read.bind(this.q[j]) : void 0
|
|
2088
2103
|
);
|
|
2089
2104
|
} : this.q ? () => {
|
|
2090
2105
|
const item = newItems[j];
|
|
2091
2106
|
this.q[j] = new Computation(j, null, pureOptions);
|
|
2092
|
-
return this.
|
|
2107
|
+
return this.R(() => item, Computation.prototype.read.bind(this.q[j]));
|
|
2093
2108
|
} : () => {
|
|
2094
2109
|
const item = newItems[j];
|
|
2095
|
-
return this.
|
|
2110
|
+
return this.R(() => item);
|
|
2096
2111
|
};
|
|
2097
2112
|
if (newLen === 0) {
|
|
2098
2113
|
if (this.o !== 0) {
|
|
2099
2114
|
this.U.dispose(false);
|
|
2100
|
-
this.
|
|
2101
|
-
this.
|
|
2102
|
-
this.
|
|
2115
|
+
this.e = [];
|
|
2116
|
+
this.G = [];
|
|
2117
|
+
this.h = [];
|
|
2103
2118
|
this.o = 0;
|
|
2104
2119
|
this.p && (this.p = []);
|
|
2105
2120
|
this.q && (this.q = []);
|
|
2106
2121
|
}
|
|
2107
|
-
if (this.V && !this.
|
|
2108
|
-
this.
|
|
2109
|
-
this.
|
|
2122
|
+
if (this.V && !this.h[0]) {
|
|
2123
|
+
this.h[0] = compute(
|
|
2124
|
+
this.e[0] = new Owner(),
|
|
2110
2125
|
this.V,
|
|
2111
2126
|
null
|
|
2112
2127
|
);
|
|
2113
2128
|
}
|
|
2114
2129
|
} else if (this.o === 0) {
|
|
2115
|
-
if (this.
|
|
2116
|
-
this.
|
|
2117
|
-
this.
|
|
2130
|
+
if (this.e[0])
|
|
2131
|
+
this.e[0].dispose();
|
|
2132
|
+
this.h = new Array(newLen);
|
|
2118
2133
|
for (j = 0; j < newLen; j++) {
|
|
2119
|
-
this.
|
|
2120
|
-
this.
|
|
2134
|
+
this.G[j] = newItems[j];
|
|
2135
|
+
this.h[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2121
2136
|
}
|
|
2122
2137
|
this.o = newLen;
|
|
2123
2138
|
} else {
|
|
2124
2139
|
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;
|
|
2125
|
-
for (start = 0, end = Math.min(this.o, newLen); start < end && (this.
|
|
2140
|
+
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++) {
|
|
2126
2141
|
if (this.p)
|
|
2127
2142
|
this.p[start].write(newItems[start]);
|
|
2128
2143
|
}
|
|
2129
|
-
for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.
|
|
2130
|
-
temp[newEnd] = this.
|
|
2131
|
-
tempNodes[newEnd] = this.
|
|
2144
|
+
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--) {
|
|
2145
|
+
temp[newEnd] = this.h[end];
|
|
2146
|
+
tempNodes[newEnd] = this.e[end];
|
|
2132
2147
|
tempRows && (tempRows[newEnd] = this.p[end]);
|
|
2133
2148
|
tempIndexes && (tempIndexes[newEnd] = this.q[end]);
|
|
2134
2149
|
}
|
|
@@ -2136,29 +2151,29 @@ function updateKeyedMap() {
|
|
|
2136
2151
|
newIndicesNext = new Array(newEnd + 1);
|
|
2137
2152
|
for (j = newEnd; j >= start; j--) {
|
|
2138
2153
|
item = newItems[j];
|
|
2139
|
-
key = this.
|
|
2154
|
+
key = this.S ? this.S(item) : item;
|
|
2140
2155
|
i = newIndices.get(key);
|
|
2141
2156
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
2142
2157
|
newIndices.set(key, j);
|
|
2143
2158
|
}
|
|
2144
2159
|
for (i = start; i <= end; i++) {
|
|
2145
|
-
item = this.
|
|
2146
|
-
key = this.
|
|
2160
|
+
item = this.G[i];
|
|
2161
|
+
key = this.S ? this.S(item) : item;
|
|
2147
2162
|
j = newIndices.get(key);
|
|
2148
2163
|
if (j !== void 0 && j !== -1) {
|
|
2149
|
-
temp[j] = this.
|
|
2150
|
-
tempNodes[j] = this.
|
|
2164
|
+
temp[j] = this.h[i];
|
|
2165
|
+
tempNodes[j] = this.e[i];
|
|
2151
2166
|
tempRows && (tempRows[j] = this.p[i]);
|
|
2152
2167
|
tempIndexes && (tempIndexes[j] = this.q[i]);
|
|
2153
2168
|
j = newIndicesNext[j];
|
|
2154
2169
|
newIndices.set(key, j);
|
|
2155
2170
|
} else
|
|
2156
|
-
this.
|
|
2171
|
+
this.e[i].dispose();
|
|
2157
2172
|
}
|
|
2158
2173
|
for (j = start; j < newLen; j++) {
|
|
2159
2174
|
if (j in temp) {
|
|
2160
|
-
this.
|
|
2161
|
-
this.
|
|
2175
|
+
this.h[j] = temp[j];
|
|
2176
|
+
this.e[j] = tempNodes[j];
|
|
2162
2177
|
if (tempRows) {
|
|
2163
2178
|
this.p[j] = tempRows[j];
|
|
2164
2179
|
this.p[j].write(newItems[j]);
|
|
@@ -2168,24 +2183,24 @@ function updateKeyedMap() {
|
|
|
2168
2183
|
this.q[j].write(j);
|
|
2169
2184
|
}
|
|
2170
2185
|
} else {
|
|
2171
|
-
this.
|
|
2186
|
+
this.h[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2172
2187
|
}
|
|
2173
2188
|
}
|
|
2174
|
-
this.
|
|
2175
|
-
this.
|
|
2189
|
+
this.h = this.h.slice(0, this.o = newLen);
|
|
2190
|
+
this.G = newItems.slice(0);
|
|
2176
2191
|
}
|
|
2177
2192
|
});
|
|
2178
|
-
return this.
|
|
2193
|
+
return this.h;
|
|
2179
2194
|
}
|
|
2180
2195
|
function repeat(count, map, options) {
|
|
2181
2196
|
return updateRepeat.bind({
|
|
2182
2197
|
U: new Owner(),
|
|
2183
2198
|
o: 0,
|
|
2184
|
-
|
|
2199
|
+
A: 0,
|
|
2185
2200
|
ja: count,
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2201
|
+
R: map,
|
|
2202
|
+
e: [],
|
|
2203
|
+
h: [],
|
|
2189
2204
|
ka: options == null ? void 0 : options.from,
|
|
2190
2205
|
V: options == null ? void 0 : options.fallback
|
|
2191
2206
|
});
|
|
@@ -2198,13 +2213,13 @@ function updateRepeat() {
|
|
|
2198
2213
|
if (newLen === 0) {
|
|
2199
2214
|
if (this.o !== 0) {
|
|
2200
2215
|
this.U.dispose(false);
|
|
2201
|
-
this.
|
|
2202
|
-
this.
|
|
2216
|
+
this.e = [];
|
|
2217
|
+
this.h = [];
|
|
2203
2218
|
this.o = 0;
|
|
2204
2219
|
}
|
|
2205
|
-
if (this.V && !this.
|
|
2206
|
-
this.
|
|
2207
|
-
this.
|
|
2220
|
+
if (this.V && !this.h[0]) {
|
|
2221
|
+
this.h[0] = compute(
|
|
2222
|
+
this.e[0] = new Owner(),
|
|
2208
2223
|
this.V,
|
|
2209
2224
|
null
|
|
2210
2225
|
);
|
|
@@ -2212,46 +2227,46 @@ function updateRepeat() {
|
|
|
2212
2227
|
return;
|
|
2213
2228
|
}
|
|
2214
2229
|
const to = from + newLen;
|
|
2215
|
-
const prevTo = this.
|
|
2216
|
-
if (this.o === 0 && this.
|
|
2217
|
-
this.
|
|
2230
|
+
const prevTo = this.A + this.o;
|
|
2231
|
+
if (this.o === 0 && this.e[0])
|
|
2232
|
+
this.e[0].dispose();
|
|
2218
2233
|
for (let i = to; i < prevTo; i++)
|
|
2219
|
-
this.
|
|
2220
|
-
if (this.
|
|
2221
|
-
let i = this.
|
|
2234
|
+
this.e[i - this.A].dispose();
|
|
2235
|
+
if (this.A < from) {
|
|
2236
|
+
let i = this.A;
|
|
2222
2237
|
while (i < from && i < this.o)
|
|
2223
|
-
this.
|
|
2224
|
-
this.
|
|
2225
|
-
this.
|
|
2226
|
-
} else if (this.
|
|
2227
|
-
let i = prevTo - this.
|
|
2228
|
-
let difference = this.
|
|
2229
|
-
this.
|
|
2238
|
+
this.e[i++].dispose();
|
|
2239
|
+
this.e.splice(0, from - this.A);
|
|
2240
|
+
this.h.splice(0, from - this.A);
|
|
2241
|
+
} else if (this.A > from) {
|
|
2242
|
+
let i = prevTo - this.A - 1;
|
|
2243
|
+
let difference = this.A - from;
|
|
2244
|
+
this.e.length = this.h.length = newLen;
|
|
2230
2245
|
while (i >= difference) {
|
|
2231
|
-
this.
|
|
2232
|
-
this.
|
|
2246
|
+
this.e[i] = this.e[i - difference];
|
|
2247
|
+
this.h[i] = this.h[i - difference];
|
|
2233
2248
|
i--;
|
|
2234
2249
|
}
|
|
2235
2250
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
2236
|
-
this.
|
|
2237
|
-
this.
|
|
2238
|
-
() => this.
|
|
2251
|
+
this.h[i2] = compute(
|
|
2252
|
+
this.e[i2] = new Owner(),
|
|
2253
|
+
() => this.R(i2 + from),
|
|
2239
2254
|
null
|
|
2240
2255
|
);
|
|
2241
2256
|
}
|
|
2242
2257
|
}
|
|
2243
2258
|
for (let i = prevTo; i < to; i++) {
|
|
2244
|
-
this.
|
|
2245
|
-
this.
|
|
2246
|
-
() => this.
|
|
2259
|
+
this.h[i - from] = compute(
|
|
2260
|
+
this.e[i - from] = new Owner(),
|
|
2261
|
+
() => this.R(i),
|
|
2247
2262
|
null
|
|
2248
2263
|
);
|
|
2249
2264
|
}
|
|
2250
|
-
this.
|
|
2251
|
-
this.
|
|
2265
|
+
this.h = this.h.slice(0, newLen);
|
|
2266
|
+
this.A = from;
|
|
2252
2267
|
this.o = newLen;
|
|
2253
2268
|
});
|
|
2254
|
-
return this.
|
|
2269
|
+
return this.h;
|
|
2255
2270
|
}
|
|
2256
2271
|
function compare(key, a, b) {
|
|
2257
2272
|
return key ? key(a) === key(b) : true;
|
|
@@ -2266,7 +2281,7 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2266
2281
|
}
|
|
2267
2282
|
write(value, flags) {
|
|
2268
2283
|
super.write(value, flags & ~this.W);
|
|
2269
|
-
if (this.W & LOADING_BIT && !(this.
|
|
2284
|
+
if (this.W & LOADING_BIT && !(this.i & UNINITIALIZED_BIT || ActiveTransition)) {
|
|
2270
2285
|
flags &= ~LOADING_BIT;
|
|
2271
2286
|
}
|
|
2272
2287
|
getQueue(this).notify(this, this.W, flags);
|
|
@@ -2274,9 +2289,9 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2274
2289
|
}
|
|
2275
2290
|
};
|
|
2276
2291
|
function createBoundChildren(owner, fn, queue, mask) {
|
|
2277
|
-
const parentQueue = owner.
|
|
2278
|
-
parentQueue.addChild(owner.
|
|
2279
|
-
onCleanup(() => parentQueue.removeChild(owner.
|
|
2292
|
+
const parentQueue = owner.C;
|
|
2293
|
+
parentQueue.addChild(owner.C = queue);
|
|
2294
|
+
onCleanup(() => parentQueue.removeChild(owner.C));
|
|
2280
2295
|
return compute(
|
|
2281
2296
|
owner,
|
|
2282
2297
|
() => {
|
|
@@ -2287,25 +2302,25 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
2287
2302
|
);
|
|
2288
2303
|
}
|
|
2289
2304
|
var ConditionalQueue = class extends Queue {
|
|
2290
|
-
|
|
2305
|
+
x;
|
|
2291
2306
|
X = /* @__PURE__ */ new Set();
|
|
2292
|
-
|
|
2307
|
+
s = /* @__PURE__ */ new Set();
|
|
2293
2308
|
constructor(disabled) {
|
|
2294
2309
|
super();
|
|
2295
|
-
this.
|
|
2310
|
+
this.x = disabled;
|
|
2296
2311
|
}
|
|
2297
2312
|
run(type) {
|
|
2298
|
-
if (!type || this.
|
|
2313
|
+
if (!type || this.x.read())
|
|
2299
2314
|
return;
|
|
2300
2315
|
return super.run(type);
|
|
2301
2316
|
}
|
|
2302
2317
|
notify(node, type, flags) {
|
|
2303
|
-
if (this.
|
|
2318
|
+
if (this.x.read()) {
|
|
2304
2319
|
if (type & LOADING_BIT) {
|
|
2305
2320
|
if (flags & LOADING_BIT) {
|
|
2306
|
-
this.
|
|
2321
|
+
this.s.add(node);
|
|
2307
2322
|
type &= ~LOADING_BIT;
|
|
2308
|
-
} else if (this.
|
|
2323
|
+
} else if (this.s.delete(node))
|
|
2309
2324
|
type &= ~LOADING_BIT;
|
|
2310
2325
|
}
|
|
2311
2326
|
if (type & ERROR_BIT) {
|
|
@@ -2319,41 +2334,41 @@ var ConditionalQueue = class extends Queue {
|
|
|
2319
2334
|
return type ? super.notify(node, type, flags) : true;
|
|
2320
2335
|
}
|
|
2321
2336
|
merge(queue) {
|
|
2322
|
-
queue.
|
|
2337
|
+
queue.s.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
|
|
2323
2338
|
queue.X.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
|
|
2324
2339
|
super.merge(queue);
|
|
2325
2340
|
}
|
|
2326
2341
|
};
|
|
2327
2342
|
var CollectionQueue = class extends Queue {
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2343
|
+
L;
|
|
2344
|
+
e = /* @__PURE__ */ new Set();
|
|
2345
|
+
x = new Computation(false, null, { pureWrite: true });
|
|
2331
2346
|
constructor(type) {
|
|
2332
2347
|
super();
|
|
2333
|
-
this.
|
|
2348
|
+
this.L = type;
|
|
2334
2349
|
}
|
|
2335
2350
|
run(type) {
|
|
2336
|
-
if (!type || this.
|
|
2351
|
+
if (!type || this.x.read())
|
|
2337
2352
|
return;
|
|
2338
2353
|
return super.run(type);
|
|
2339
2354
|
}
|
|
2340
2355
|
notify(node, type, flags) {
|
|
2341
|
-
if (!(type & this.
|
|
2356
|
+
if (!(type & this.L))
|
|
2342
2357
|
return super.notify(node, type, flags);
|
|
2343
|
-
if (flags & this.
|
|
2344
|
-
this.
|
|
2345
|
-
if (this.
|
|
2346
|
-
this.
|
|
2347
|
-
} else if (this.
|
|
2348
|
-
this.
|
|
2349
|
-
if (this.
|
|
2350
|
-
this.
|
|
2351
|
-
}
|
|
2352
|
-
type &= ~this.
|
|
2358
|
+
if (flags & this.L) {
|
|
2359
|
+
this.e.add(node);
|
|
2360
|
+
if (this.e.size === 1)
|
|
2361
|
+
this.x.write(true);
|
|
2362
|
+
} else if (this.e.size > 0) {
|
|
2363
|
+
this.e.delete(node);
|
|
2364
|
+
if (this.e.size === 0)
|
|
2365
|
+
this.x.write(false);
|
|
2366
|
+
}
|
|
2367
|
+
type &= ~this.L;
|
|
2353
2368
|
return type ? super.notify(node, type, flags) : true;
|
|
2354
2369
|
}
|
|
2355
2370
|
merge(queue) {
|
|
2356
|
-
queue.
|
|
2371
|
+
queue.e.forEach((n) => this.notify(n, this.L, this.L));
|
|
2357
2372
|
super.merge(queue);
|
|
2358
2373
|
}
|
|
2359
2374
|
};
|
|
@@ -2364,25 +2379,25 @@ function createBoundary(fn, condition) {
|
|
|
2364
2379
|
);
|
|
2365
2380
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
2366
2381
|
new EagerComputation(void 0, () => {
|
|
2367
|
-
const disabled = queue.
|
|
2382
|
+
const disabled = queue.x.read();
|
|
2368
2383
|
tree.W = disabled ? ERROR_BIT | LOADING_BIT : 0;
|
|
2369
2384
|
if (!disabled) {
|
|
2370
|
-
queue.
|
|
2385
|
+
queue.s.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
|
|
2371
2386
|
queue.X.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
|
|
2372
|
-
queue.
|
|
2387
|
+
queue.s.clear();
|
|
2373
2388
|
queue.X.clear();
|
|
2374
2389
|
}
|
|
2375
2390
|
});
|
|
2376
|
-
return () => queue.
|
|
2391
|
+
return () => queue.x.read() ? void 0 : tree.read();
|
|
2377
2392
|
}
|
|
2378
2393
|
function createCollectionBoundary(type, fn, fallback) {
|
|
2379
2394
|
const owner = new Owner();
|
|
2380
2395
|
const queue = new CollectionQueue(type);
|
|
2381
2396
|
const tree = createBoundChildren(owner, fn, queue, type);
|
|
2382
2397
|
const decision = new Computation(void 0, () => {
|
|
2383
|
-
if (!queue.
|
|
2398
|
+
if (!queue.x.read()) {
|
|
2384
2399
|
const resolved = tree.read();
|
|
2385
|
-
if (!untrack(() => queue.
|
|
2400
|
+
if (!untrack(() => queue.x.read()))
|
|
2386
2401
|
return resolved;
|
|
2387
2402
|
}
|
|
2388
2403
|
return fallback(queue);
|
|
@@ -2394,14 +2409,14 @@ function createSuspense(fn, fallback) {
|
|
|
2394
2409
|
}
|
|
2395
2410
|
function createErrorBoundary(fn, fallback) {
|
|
2396
2411
|
return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
|
|
2397
|
-
let node = getTransitionSource(queue.
|
|
2398
|
-
return fallback(node.
|
|
2412
|
+
let node = getTransitionSource(queue.e.values().next().value);
|
|
2413
|
+
return fallback(node.O, () => {
|
|
2399
2414
|
incrementClock();
|
|
2400
|
-
for (let node2 of queue.
|
|
2401
|
-
if (ActiveTransition && !node2.
|
|
2415
|
+
for (let node2 of queue.e) {
|
|
2416
|
+
if (ActiveTransition && !node2.d)
|
|
2402
2417
|
node2 = cloneGraph(node2);
|
|
2403
|
-
node2.
|
|
2404
|
-
getQueue(node2).enqueue(node2.
|
|
2418
|
+
node2.b = STATE_DIRTY;
|
|
2419
|
+
getQueue(node2).enqueue(node2.r, node2.w.bind(node2));
|
|
2405
2420
|
}
|
|
2406
2421
|
});
|
|
2407
2422
|
});
|
|
@@ -2478,12 +2493,15 @@ exports.createEffect = createEffect;
|
|
|
2478
2493
|
exports.createErrorBoundary = createErrorBoundary;
|
|
2479
2494
|
exports.createMemo = createMemo;
|
|
2480
2495
|
exports.createOptimistic = createOptimistic;
|
|
2496
|
+
exports.createOptimisticStore = createOptimisticStore;
|
|
2481
2497
|
exports.createProjection = createProjection;
|
|
2498
|
+
exports.createReaction = createReaction;
|
|
2482
2499
|
exports.createRenderEffect = createRenderEffect;
|
|
2483
2500
|
exports.createRoot = createRoot;
|
|
2484
2501
|
exports.createSignal = createSignal;
|
|
2485
2502
|
exports.createStore = createStore;
|
|
2486
2503
|
exports.createSuspense = createSuspense;
|
|
2504
|
+
exports.createTrackedEffect = createTrackedEffect;
|
|
2487
2505
|
exports.deep = deep;
|
|
2488
2506
|
exports.flatten = flatten;
|
|
2489
2507
|
exports.flush = flush;
|
|
@@ -2503,7 +2521,6 @@ exports.onCleanup = onCleanup;
|
|
|
2503
2521
|
exports.reconcile = reconcile;
|
|
2504
2522
|
exports.repeat = repeat;
|
|
2505
2523
|
exports.resolve = resolve;
|
|
2506
|
-
exports.runWithObserver = runWithObserver;
|
|
2507
2524
|
exports.runWithOwner = runWithOwner;
|
|
2508
2525
|
exports.setContext = setContext;
|
|
2509
2526
|
exports.snapshot = snapshot;
|