@solidjs/signals 0.7.1 → 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 +31 -19
- package/dist/node.cjs +287 -275
- package/dist/prod.js +287 -275
- 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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
t = /* @__PURE__ */ new Set();
|
|
164
|
+
K = /* @__PURE__ */ new Set();
|
|
165
|
+
r = /* @__PURE__ */ new Set();
|
|
166
|
+
D = false;
|
|
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,52 +212,55 @@ var Transition = class _Transition {
|
|
|
212
212
|
ActiveTransition = currentTransition;
|
|
213
213
|
finishTransition(this);
|
|
214
214
|
} finally {
|
|
215
|
-
this.
|
|
215
|
+
this.C = false;
|
|
216
216
|
ActiveTransition = currentTransition;
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
addChild(child) {
|
|
220
|
-
this.
|
|
220
|
+
this.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) {
|
|
258
|
-
if (this.
|
|
259
|
-
if (this.
|
|
260
|
-
return this.
|
|
261
|
+
if (this.D) {
|
|
262
|
+
if (this.D instanceof _Transition)
|
|
263
|
+
return this.D.runTransition(fn, force);
|
|
261
264
|
if (!force)
|
|
262
265
|
throw new Error("Transition already completed");
|
|
263
266
|
fn();
|
|
@@ -271,13 +274,14 @@ var Transition = class _Transition {
|
|
|
271
274
|
(async function() {
|
|
272
275
|
let temp, value;
|
|
273
276
|
while (!(temp = result.next(value)).done) {
|
|
277
|
+
transition2 = ActiveTransition;
|
|
274
278
|
if (temp.value instanceof Promise) {
|
|
275
|
-
transition2.
|
|
279
|
+
transition2.K.add(temp.value);
|
|
276
280
|
try {
|
|
277
281
|
value = await temp.value;
|
|
278
282
|
} finally {
|
|
279
283
|
transition2 = latestTransition(transition2);
|
|
280
|
-
transition2.
|
|
284
|
+
transition2.K.delete(temp.value);
|
|
281
285
|
}
|
|
282
286
|
ActiveTransition = transition2;
|
|
283
287
|
} else
|
|
@@ -288,10 +292,10 @@ var Transition = class _Transition {
|
|
|
288
292
|
})();
|
|
289
293
|
}
|
|
290
294
|
if (result instanceof Promise) {
|
|
291
|
-
transition2.
|
|
295
|
+
transition2.K.add(result);
|
|
292
296
|
result.finally(() => {
|
|
293
297
|
transition2 = latestTransition(transition2);
|
|
294
|
-
transition2.
|
|
298
|
+
transition2.K.delete(result);
|
|
295
299
|
ActiveTransition = null;
|
|
296
300
|
finishTransition(transition2);
|
|
297
301
|
});
|
|
@@ -309,14 +313,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,27 +336,26 @@ function cloneGraph(node, optimistic) {
|
|
|
330
336
|
m: null,
|
|
331
337
|
c: null,
|
|
332
338
|
a: node.a ? [...node.a] : null,
|
|
333
|
-
d: node
|
|
334
|
-
J: !!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;
|
|
350
355
|
}
|
|
351
356
|
function latestTransition(t) {
|
|
352
|
-
while (t.
|
|
353
|
-
t = t.
|
|
357
|
+
while (t.D instanceof Transition)
|
|
358
|
+
t = t.D;
|
|
354
359
|
return t;
|
|
355
360
|
}
|
|
356
361
|
function replaceSourceObservers(node, transition2) {
|
|
@@ -371,7 +376,7 @@ 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);
|
|
@@ -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,14 +421,14 @@ 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
|
-
t2.
|
|
431
|
+
t2.D = t1;
|
|
427
432
|
}
|
|
428
433
|
function getTransitionSource(input) {
|
|
429
434
|
return ActiveTransition && ActiveTransition.a.get(input) || input;
|
|
@@ -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.
|
|
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.J) {
|
|
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,16 +472,16 @@ 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;
|
|
481
480
|
}
|
|
482
481
|
delete source.j;
|
|
483
482
|
}
|
|
484
|
-
transition2.
|
|
485
|
-
for (const reset of transition2.
|
|
483
|
+
transition2.D = true;
|
|
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;
|
|
@@ -548,16 +547,16 @@ var Owner = class {
|
|
|
548
547
|
if (self)
|
|
549
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
554
|
M() {
|
|
556
|
-
if (this.
|
|
557
|
-
this.
|
|
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
|
}
|
|
@@ -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;
|
|
@@ -1074,19 +1073,19 @@ var Effect = class extends Computation {
|
|
|
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
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
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
|
|
|
@@ -1185,7 +1187,7 @@ function createSignal(first, second, third) {
|
|
|
1185
1187
|
if (typeof first === "function") {
|
|
1186
1188
|
const node2 = new Computation(second, first, third);
|
|
1187
1189
|
return [node2.read.bind(node2), (v) => {
|
|
1188
|
-
node2.
|
|
1190
|
+
node2.F();
|
|
1189
1191
|
return node2.write(v);
|
|
1190
1192
|
}];
|
|
1191
1193
|
}
|
|
@@ -1213,7 +1215,7 @@ function createMemo(compute2, value, options) {
|
|
|
1213
1215
|
return resolvedValue;
|
|
1214
1216
|
}
|
|
1215
1217
|
resolvedValue = node.wait();
|
|
1216
|
-
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)) {
|
|
1217
1219
|
node.dispose();
|
|
1218
1220
|
node = void 0;
|
|
1219
1221
|
}
|
|
@@ -1292,7 +1294,7 @@ function createAsync(compute2, value, options) {
|
|
|
1292
1294
|
}
|
|
1293
1295
|
n.b = STATE_DIRTY;
|
|
1294
1296
|
refreshing = true;
|
|
1295
|
-
n.
|
|
1297
|
+
n.F();
|
|
1296
1298
|
};
|
|
1297
1299
|
return read;
|
|
1298
1300
|
}
|
|
@@ -1359,16 +1361,21 @@ function resolve(fn) {
|
|
|
1359
1361
|
});
|
|
1360
1362
|
}
|
|
1361
1363
|
function createOptimistic(first, second, third) {
|
|
1362
|
-
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;
|
|
1363
1371
|
const reset = () => node.write(first);
|
|
1364
1372
|
function write(v) {
|
|
1365
1373
|
if (!ActiveTransition)
|
|
1366
1374
|
throw new Error("createOptimistic can only be updated inside a transition");
|
|
1367
1375
|
ActiveTransition.addOptimistic(reset);
|
|
1368
|
-
cloneGraph(node, true);
|
|
1369
1376
|
queueMicrotask(() => {
|
|
1370
1377
|
if (reset.j) {
|
|
1371
|
-
node.
|
|
1378
|
+
node.F();
|
|
1372
1379
|
node.write(v);
|
|
1373
1380
|
}
|
|
1374
1381
|
});
|
|
@@ -1851,8 +1858,14 @@ function deep(store) {
|
|
|
1851
1858
|
// src/store/optimistic.ts
|
|
1852
1859
|
function createOptimisticStore(first, second, options) {
|
|
1853
1860
|
const derived = typeof first === "function";
|
|
1854
|
-
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(() => {
|
|
1855
1867
|
}, first);
|
|
1868
|
+
node.r = true;
|
|
1856
1869
|
const reset = () => storeSetter(
|
|
1857
1870
|
store,
|
|
1858
1871
|
reconcile(
|
|
@@ -1865,7 +1878,6 @@ function createOptimisticStore(first, second, options) {
|
|
|
1865
1878
|
if (!ActiveTransition)
|
|
1866
1879
|
throw new Error("createOptimisticStore can only be updated inside a transition");
|
|
1867
1880
|
ActiveTransition.addOptimistic(reset);
|
|
1868
|
-
cloneGraph(node, true);
|
|
1869
1881
|
queueMicrotask(() => reset.j && storeSetter(store, v));
|
|
1870
1882
|
};
|
|
1871
1883
|
return [store, write];
|
|
@@ -2079,9 +2091,9 @@ function mapArray(list, map, options) {
|
|
|
2079
2091
|
U: new Owner(),
|
|
2080
2092
|
o: 0,
|
|
2081
2093
|
ia: list,
|
|
2082
|
-
|
|
2094
|
+
I: [],
|
|
2083
2095
|
R: map,
|
|
2084
|
-
|
|
2096
|
+
i: [],
|
|
2085
2097
|
e: [],
|
|
2086
2098
|
S: keyFn,
|
|
2087
2099
|
p: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
@@ -2113,14 +2125,14 @@ function updateKeyedMap() {
|
|
|
2113
2125
|
if (this.o !== 0) {
|
|
2114
2126
|
this.U.dispose(false);
|
|
2115
2127
|
this.e = [];
|
|
2116
|
-
this.
|
|
2117
|
-
this.
|
|
2128
|
+
this.I = [];
|
|
2129
|
+
this.i = [];
|
|
2118
2130
|
this.o = 0;
|
|
2119
2131
|
this.p && (this.p = []);
|
|
2120
2132
|
this.q && (this.q = []);
|
|
2121
2133
|
}
|
|
2122
|
-
if (this.V && !this.
|
|
2123
|
-
this.
|
|
2134
|
+
if (this.V && !this.i[0]) {
|
|
2135
|
+
this.i[0] = compute(
|
|
2124
2136
|
this.e[0] = new Owner(),
|
|
2125
2137
|
this.V,
|
|
2126
2138
|
null
|
|
@@ -2129,20 +2141,20 @@ function updateKeyedMap() {
|
|
|
2129
2141
|
} else if (this.o === 0) {
|
|
2130
2142
|
if (this.e[0])
|
|
2131
2143
|
this.e[0].dispose();
|
|
2132
|
-
this.
|
|
2144
|
+
this.i = new Array(newLen);
|
|
2133
2145
|
for (j = 0; j < newLen; j++) {
|
|
2134
|
-
this.
|
|
2135
|
-
this.
|
|
2146
|
+
this.I[j] = newItems[j];
|
|
2147
|
+
this.i[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2136
2148
|
}
|
|
2137
2149
|
this.o = newLen;
|
|
2138
2150
|
} else {
|
|
2139
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;
|
|
2140
|
-
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++) {
|
|
2141
2153
|
if (this.p)
|
|
2142
2154
|
this.p[start].write(newItems[start]);
|
|
2143
2155
|
}
|
|
2144
|
-
for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.
|
|
2145
|
-
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];
|
|
2146
2158
|
tempNodes[newEnd] = this.e[end];
|
|
2147
2159
|
tempRows && (tempRows[newEnd] = this.p[end]);
|
|
2148
2160
|
tempIndexes && (tempIndexes[newEnd] = this.q[end]);
|
|
@@ -2157,11 +2169,11 @@ function updateKeyedMap() {
|
|
|
2157
2169
|
newIndices.set(key, j);
|
|
2158
2170
|
}
|
|
2159
2171
|
for (i = start; i <= end; i++) {
|
|
2160
|
-
item = this.
|
|
2172
|
+
item = this.I[i];
|
|
2161
2173
|
key = this.S ? this.S(item) : item;
|
|
2162
2174
|
j = newIndices.get(key);
|
|
2163
2175
|
if (j !== void 0 && j !== -1) {
|
|
2164
|
-
temp[j] = this.
|
|
2176
|
+
temp[j] = this.i[i];
|
|
2165
2177
|
tempNodes[j] = this.e[i];
|
|
2166
2178
|
tempRows && (tempRows[j] = this.p[i]);
|
|
2167
2179
|
tempIndexes && (tempIndexes[j] = this.q[i]);
|
|
@@ -2172,7 +2184,7 @@ function updateKeyedMap() {
|
|
|
2172
2184
|
}
|
|
2173
2185
|
for (j = start; j < newLen; j++) {
|
|
2174
2186
|
if (j in temp) {
|
|
2175
|
-
this.
|
|
2187
|
+
this.i[j] = temp[j];
|
|
2176
2188
|
this.e[j] = tempNodes[j];
|
|
2177
2189
|
if (tempRows) {
|
|
2178
2190
|
this.p[j] = tempRows[j];
|
|
@@ -2183,24 +2195,24 @@ function updateKeyedMap() {
|
|
|
2183
2195
|
this.q[j].write(j);
|
|
2184
2196
|
}
|
|
2185
2197
|
} else {
|
|
2186
|
-
this.
|
|
2198
|
+
this.i[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
2187
2199
|
}
|
|
2188
2200
|
}
|
|
2189
|
-
this.
|
|
2190
|
-
this.
|
|
2201
|
+
this.i = this.i.slice(0, this.o = newLen);
|
|
2202
|
+
this.I = newItems.slice(0);
|
|
2191
2203
|
}
|
|
2192
2204
|
});
|
|
2193
|
-
return this.
|
|
2205
|
+
return this.i;
|
|
2194
2206
|
}
|
|
2195
2207
|
function repeat(count, map, options) {
|
|
2196
2208
|
return updateRepeat.bind({
|
|
2197
2209
|
U: new Owner(),
|
|
2198
2210
|
o: 0,
|
|
2199
|
-
|
|
2211
|
+
B: 0,
|
|
2200
2212
|
ja: count,
|
|
2201
2213
|
R: map,
|
|
2202
2214
|
e: [],
|
|
2203
|
-
|
|
2215
|
+
i: [],
|
|
2204
2216
|
ka: options == null ? void 0 : options.from,
|
|
2205
2217
|
V: options == null ? void 0 : options.fallback
|
|
2206
2218
|
});
|
|
@@ -2214,11 +2226,11 @@ function updateRepeat() {
|
|
|
2214
2226
|
if (this.o !== 0) {
|
|
2215
2227
|
this.U.dispose(false);
|
|
2216
2228
|
this.e = [];
|
|
2217
|
-
this.
|
|
2229
|
+
this.i = [];
|
|
2218
2230
|
this.o = 0;
|
|
2219
2231
|
}
|
|
2220
|
-
if (this.V && !this.
|
|
2221
|
-
this.
|
|
2232
|
+
if (this.V && !this.i[0]) {
|
|
2233
|
+
this.i[0] = compute(
|
|
2222
2234
|
this.e[0] = new Owner(),
|
|
2223
2235
|
this.V,
|
|
2224
2236
|
null
|
|
@@ -2227,28 +2239,28 @@ function updateRepeat() {
|
|
|
2227
2239
|
return;
|
|
2228
2240
|
}
|
|
2229
2241
|
const to = from + newLen;
|
|
2230
|
-
const prevTo = this.
|
|
2242
|
+
const prevTo = this.B + this.o;
|
|
2231
2243
|
if (this.o === 0 && this.e[0])
|
|
2232
2244
|
this.e[0].dispose();
|
|
2233
2245
|
for (let i = to; i < prevTo; i++)
|
|
2234
|
-
this.e[i - this.
|
|
2235
|
-
if (this.
|
|
2236
|
-
let i = this.
|
|
2246
|
+
this.e[i - this.B].dispose();
|
|
2247
|
+
if (this.B < from) {
|
|
2248
|
+
let i = this.B;
|
|
2237
2249
|
while (i < from && i < this.o)
|
|
2238
2250
|
this.e[i++].dispose();
|
|
2239
|
-
this.e.splice(0, from - this.
|
|
2240
|
-
this.
|
|
2241
|
-
} else if (this.
|
|
2242
|
-
let i = prevTo - this.
|
|
2243
|
-
let difference = this.
|
|
2244
|
-
this.e.length = this.
|
|
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;
|
|
2245
2257
|
while (i >= difference) {
|
|
2246
2258
|
this.e[i] = this.e[i - difference];
|
|
2247
|
-
this.
|
|
2259
|
+
this.i[i] = this.i[i - difference];
|
|
2248
2260
|
i--;
|
|
2249
2261
|
}
|
|
2250
2262
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
2251
|
-
this.
|
|
2263
|
+
this.i[i2] = compute(
|
|
2252
2264
|
this.e[i2] = new Owner(),
|
|
2253
2265
|
() => this.R(i2 + from),
|
|
2254
2266
|
null
|
|
@@ -2256,17 +2268,17 @@ function updateRepeat() {
|
|
|
2256
2268
|
}
|
|
2257
2269
|
}
|
|
2258
2270
|
for (let i = prevTo; i < to; i++) {
|
|
2259
|
-
this.
|
|
2271
|
+
this.i[i - from] = compute(
|
|
2260
2272
|
this.e[i - from] = new Owner(),
|
|
2261
2273
|
() => this.R(i),
|
|
2262
2274
|
null
|
|
2263
2275
|
);
|
|
2264
2276
|
}
|
|
2265
|
-
this.
|
|
2266
|
-
this.
|
|
2277
|
+
this.i = this.i.slice(0, newLen);
|
|
2278
|
+
this.B = from;
|
|
2267
2279
|
this.o = newLen;
|
|
2268
2280
|
});
|
|
2269
|
-
return this.
|
|
2281
|
+
return this.i;
|
|
2270
2282
|
}
|
|
2271
2283
|
function compare(key, a, b) {
|
|
2272
2284
|
return key ? key(a) === key(b) : true;
|
|
@@ -2281,7 +2293,7 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2281
2293
|
}
|
|
2282
2294
|
write(value, flags) {
|
|
2283
2295
|
super.write(value, flags & ~this.W);
|
|
2284
|
-
if (this.W & LOADING_BIT && !(this.
|
|
2296
|
+
if (this.W & LOADING_BIT && !(this.h & UNINITIALIZED_BIT || ActiveTransition)) {
|
|
2285
2297
|
flags &= ~LOADING_BIT;
|
|
2286
2298
|
}
|
|
2287
2299
|
getQueue(this).notify(this, this.W, flags);
|
|
@@ -2289,9 +2301,9 @@ var BoundaryComputation = class extends EagerComputation {
|
|
|
2289
2301
|
}
|
|
2290
2302
|
};
|
|
2291
2303
|
function createBoundChildren(owner, fn, queue, mask) {
|
|
2292
|
-
const parentQueue = owner.
|
|
2293
|
-
parentQueue.addChild(owner.
|
|
2294
|
-
onCleanup(() => parentQueue.removeChild(owner.
|
|
2304
|
+
const parentQueue = owner.E;
|
|
2305
|
+
parentQueue.addChild(owner.E = queue);
|
|
2306
|
+
onCleanup(() => parentQueue.removeChild(owner.E));
|
|
2295
2307
|
return compute(
|
|
2296
2308
|
owner,
|
|
2297
2309
|
() => {
|
|
@@ -2302,25 +2314,25 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
2302
2314
|
);
|
|
2303
2315
|
}
|
|
2304
2316
|
var ConditionalQueue = class extends Queue {
|
|
2305
|
-
|
|
2317
|
+
y;
|
|
2306
2318
|
X = /* @__PURE__ */ new Set();
|
|
2307
|
-
|
|
2319
|
+
t = /* @__PURE__ */ new Set();
|
|
2308
2320
|
constructor(disabled) {
|
|
2309
2321
|
super();
|
|
2310
|
-
this.
|
|
2322
|
+
this.y = disabled;
|
|
2311
2323
|
}
|
|
2312
2324
|
run(type) {
|
|
2313
|
-
if (!type || this.
|
|
2325
|
+
if (!type || this.y.read())
|
|
2314
2326
|
return;
|
|
2315
2327
|
return super.run(type);
|
|
2316
2328
|
}
|
|
2317
2329
|
notify(node, type, flags) {
|
|
2318
|
-
if (this.
|
|
2330
|
+
if (this.y.read()) {
|
|
2319
2331
|
if (type & LOADING_BIT) {
|
|
2320
2332
|
if (flags & LOADING_BIT) {
|
|
2321
|
-
this.
|
|
2333
|
+
this.t.add(node);
|
|
2322
2334
|
type &= ~LOADING_BIT;
|
|
2323
|
-
} else if (this.
|
|
2335
|
+
} else if (this.t.delete(node))
|
|
2324
2336
|
type &= ~LOADING_BIT;
|
|
2325
2337
|
}
|
|
2326
2338
|
if (type & ERROR_BIT) {
|
|
@@ -2334,7 +2346,7 @@ var ConditionalQueue = class extends Queue {
|
|
|
2334
2346
|
return type ? super.notify(node, type, flags) : true;
|
|
2335
2347
|
}
|
|
2336
2348
|
merge(queue) {
|
|
2337
|
-
queue.
|
|
2349
|
+
queue.t.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
|
|
2338
2350
|
queue.X.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
|
|
2339
2351
|
super.merge(queue);
|
|
2340
2352
|
}
|
|
@@ -2342,13 +2354,13 @@ var ConditionalQueue = class extends Queue {
|
|
|
2342
2354
|
var CollectionQueue = class extends Queue {
|
|
2343
2355
|
L;
|
|
2344
2356
|
e = /* @__PURE__ */ new Set();
|
|
2345
|
-
|
|
2357
|
+
y = new Computation(false, null, { pureWrite: true });
|
|
2346
2358
|
constructor(type) {
|
|
2347
2359
|
super();
|
|
2348
2360
|
this.L = type;
|
|
2349
2361
|
}
|
|
2350
2362
|
run(type) {
|
|
2351
|
-
if (!type || this.
|
|
2363
|
+
if (!type || this.y.read())
|
|
2352
2364
|
return;
|
|
2353
2365
|
return super.run(type);
|
|
2354
2366
|
}
|
|
@@ -2358,11 +2370,11 @@ var CollectionQueue = class extends Queue {
|
|
|
2358
2370
|
if (flags & this.L) {
|
|
2359
2371
|
this.e.add(node);
|
|
2360
2372
|
if (this.e.size === 1)
|
|
2361
|
-
this.
|
|
2373
|
+
this.y.write(true);
|
|
2362
2374
|
} else if (this.e.size > 0) {
|
|
2363
2375
|
this.e.delete(node);
|
|
2364
2376
|
if (this.e.size === 0)
|
|
2365
|
-
this.
|
|
2377
|
+
this.y.write(false);
|
|
2366
2378
|
}
|
|
2367
2379
|
type &= ~this.L;
|
|
2368
2380
|
return type ? super.notify(node, type, flags) : true;
|
|
@@ -2379,25 +2391,25 @@ function createBoundary(fn, condition) {
|
|
|
2379
2391
|
);
|
|
2380
2392
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
2381
2393
|
new EagerComputation(void 0, () => {
|
|
2382
|
-
const disabled = queue.
|
|
2394
|
+
const disabled = queue.y.read();
|
|
2383
2395
|
tree.W = disabled ? ERROR_BIT | LOADING_BIT : 0;
|
|
2384
2396
|
if (!disabled) {
|
|
2385
|
-
queue.
|
|
2397
|
+
queue.t.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
|
|
2386
2398
|
queue.X.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
|
|
2387
|
-
queue.
|
|
2399
|
+
queue.t.clear();
|
|
2388
2400
|
queue.X.clear();
|
|
2389
2401
|
}
|
|
2390
2402
|
});
|
|
2391
|
-
return () => queue.
|
|
2403
|
+
return () => queue.y.read() ? void 0 : tree.read();
|
|
2392
2404
|
}
|
|
2393
2405
|
function createCollectionBoundary(type, fn, fallback) {
|
|
2394
2406
|
const owner = new Owner();
|
|
2395
2407
|
const queue = new CollectionQueue(type);
|
|
2396
2408
|
const tree = createBoundChildren(owner, fn, queue, type);
|
|
2397
2409
|
const decision = new Computation(void 0, () => {
|
|
2398
|
-
if (!queue.
|
|
2410
|
+
if (!queue.y.read()) {
|
|
2399
2411
|
const resolved = tree.read();
|
|
2400
|
-
if (!untrack(() => queue.
|
|
2412
|
+
if (!untrack(() => queue.y.read()))
|
|
2401
2413
|
return resolved;
|
|
2402
2414
|
}
|
|
2403
2415
|
return fallback(queue);
|
|
@@ -2416,7 +2428,7 @@ function createErrorBoundary(fn, fallback) {
|
|
|
2416
2428
|
if (ActiveTransition && !node2.d)
|
|
2417
2429
|
node2 = cloneGraph(node2);
|
|
2418
2430
|
node2.b = STATE_DIRTY;
|
|
2419
|
-
getQueue(node2).enqueue(node2.
|
|
2431
|
+
getQueue(node2).enqueue(node2.s, node2.x.bind(node2));
|
|
2420
2432
|
}
|
|
2421
2433
|
});
|
|
2422
2434
|
});
|