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