@solidjs/signals 0.0.9 → 0.0.11
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 +154 -134
- package/dist/node.cjs +346 -328
- package/dist/prod.js +345 -325
- package/dist/types/core/core.d.ts +2 -2
- package/dist/types/core/effect.d.ts +3 -5
- package/dist/types/core/error.d.ts +2 -1
- package/dist/types/core/index.d.ts +2 -2
- package/dist/types/core/owner.d.ts +2 -2
- package/dist/types/core/scheduler.d.ts +5 -2
- package/package.json +1 -1
package/dist/node.cjs
CHANGED
|
@@ -32,6 +32,104 @@ var EFFECT_RENDER = 1;
|
|
|
32
32
|
var EFFECT_USER = 2;
|
|
33
33
|
var SUPPORTS_PROXY = typeof Proxy === "function";
|
|
34
34
|
|
|
35
|
+
// src/core/scheduler.ts
|
|
36
|
+
var clock = 0;
|
|
37
|
+
function getClock() {
|
|
38
|
+
return clock;
|
|
39
|
+
}
|
|
40
|
+
function incrementClock() {
|
|
41
|
+
clock++;
|
|
42
|
+
}
|
|
43
|
+
var scheduled = false;
|
|
44
|
+
function schedule() {
|
|
45
|
+
if (scheduled)
|
|
46
|
+
return;
|
|
47
|
+
scheduled = true;
|
|
48
|
+
if (!globalQueue.H)
|
|
49
|
+
queueMicrotask(flushSync);
|
|
50
|
+
}
|
|
51
|
+
var Queue = class {
|
|
52
|
+
H = false;
|
|
53
|
+
r = [[], [], []];
|
|
54
|
+
D = [];
|
|
55
|
+
created = clock;
|
|
56
|
+
enqueue(type, node) {
|
|
57
|
+
this.r[0].push(node);
|
|
58
|
+
if (type)
|
|
59
|
+
this.r[type].push(node);
|
|
60
|
+
schedule();
|
|
61
|
+
}
|
|
62
|
+
run(type) {
|
|
63
|
+
if (this.r[type].length) {
|
|
64
|
+
if (type === EFFECT_PURE) {
|
|
65
|
+
runPureQueue(this.r[type]);
|
|
66
|
+
this.r[type] = [];
|
|
67
|
+
} else {
|
|
68
|
+
const effects = this.r[type];
|
|
69
|
+
this.r[type] = [];
|
|
70
|
+
runEffectQueue(effects);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
let rerun = false;
|
|
74
|
+
for (let i = 0; i < this.D.length; i++) {
|
|
75
|
+
rerun = this.D[i].run(type) || rerun;
|
|
76
|
+
}
|
|
77
|
+
if (type === EFFECT_PURE && this.r[type].length)
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
flush() {
|
|
81
|
+
if (this.H)
|
|
82
|
+
return;
|
|
83
|
+
this.H = true;
|
|
84
|
+
try {
|
|
85
|
+
while (this.run(EFFECT_PURE)) {
|
|
86
|
+
}
|
|
87
|
+
incrementClock();
|
|
88
|
+
scheduled = false;
|
|
89
|
+
this.run(EFFECT_RENDER);
|
|
90
|
+
this.run(EFFECT_USER);
|
|
91
|
+
} finally {
|
|
92
|
+
this.H = false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
addChild(child) {
|
|
96
|
+
this.D.push(child);
|
|
97
|
+
}
|
|
98
|
+
removeChild(child) {
|
|
99
|
+
const index = this.D.indexOf(child);
|
|
100
|
+
if (index >= 0)
|
|
101
|
+
this.D.splice(index, 1);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var globalQueue = new Queue();
|
|
105
|
+
function flushSync() {
|
|
106
|
+
while (scheduled) {
|
|
107
|
+
globalQueue.flush();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function runTop(node) {
|
|
111
|
+
const ancestors = [];
|
|
112
|
+
for (let current = node; current !== null; current = current.s) {
|
|
113
|
+
if (current.a !== STATE_CLEAN) {
|
|
114
|
+
ancestors.push(current);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
118
|
+
if (ancestors[i].a !== STATE_DISPOSED)
|
|
119
|
+
ancestors[i].y();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function runPureQueue(queue) {
|
|
123
|
+
for (let i = 0; i < queue.length; i++) {
|
|
124
|
+
if (queue[i].a !== STATE_CLEAN)
|
|
125
|
+
runTop(queue[i]);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function runEffectQueue(queue) {
|
|
129
|
+
for (let i = 0; i < queue.length; i++)
|
|
130
|
+
queue[i].T();
|
|
131
|
+
}
|
|
132
|
+
|
|
35
133
|
// src/core/utils.ts
|
|
36
134
|
function isUndefined(value) {
|
|
37
135
|
return typeof value === "undefined";
|
|
@@ -106,23 +204,23 @@ var Owner = class {
|
|
|
106
204
|
// We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild
|
|
107
205
|
// However, the children are actually added in reverse creation order
|
|
108
206
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
109
|
-
r = null;
|
|
110
|
-
n = null;
|
|
111
207
|
s = null;
|
|
208
|
+
n = null;
|
|
209
|
+
t = null;
|
|
112
210
|
a = STATE_CLEAN;
|
|
113
211
|
l = null;
|
|
114
212
|
p = defaultContext;
|
|
115
213
|
m = null;
|
|
116
|
-
|
|
214
|
+
h = globalQueue;
|
|
117
215
|
constructor(signal = false) {
|
|
118
216
|
if (currentOwner && !signal)
|
|
119
217
|
currentOwner.append(this);
|
|
120
218
|
}
|
|
121
219
|
append(child) {
|
|
122
|
-
child.r = this;
|
|
123
220
|
child.s = this;
|
|
221
|
+
child.t = this;
|
|
124
222
|
if (this.n)
|
|
125
|
-
this.n.
|
|
223
|
+
this.n.t = child;
|
|
126
224
|
child.n = this.n;
|
|
127
225
|
this.n = child;
|
|
128
226
|
if (child.p !== this.p) {
|
|
@@ -131,32 +229,32 @@ var Owner = class {
|
|
|
131
229
|
if (this.m) {
|
|
132
230
|
child.m = !child.m ? this.m : [...child.m, ...this.m];
|
|
133
231
|
}
|
|
134
|
-
if (this.
|
|
135
|
-
child.
|
|
232
|
+
if (this.h)
|
|
233
|
+
child.h = this.h;
|
|
136
234
|
}
|
|
137
235
|
dispose(self = true) {
|
|
138
236
|
if (this.a === STATE_DISPOSED)
|
|
139
237
|
return;
|
|
140
|
-
let head = self ? this.
|
|
141
|
-
while (current && current.
|
|
238
|
+
let head = self ? this.t || this.s : this, current = this.n, next = null;
|
|
239
|
+
while (current && current.s === this) {
|
|
142
240
|
current.dispose(true);
|
|
143
|
-
current.
|
|
241
|
+
current.A();
|
|
144
242
|
next = current.n;
|
|
145
243
|
current.n = null;
|
|
146
244
|
current = next;
|
|
147
245
|
}
|
|
148
246
|
if (self)
|
|
149
|
-
this.
|
|
247
|
+
this.A();
|
|
150
248
|
if (current)
|
|
151
|
-
current.
|
|
249
|
+
current.t = !self ? this : this.t;
|
|
152
250
|
if (head)
|
|
153
251
|
head.n = current;
|
|
154
252
|
}
|
|
155
|
-
|
|
156
|
-
if (this.
|
|
157
|
-
this.
|
|
158
|
-
this.r = null;
|
|
253
|
+
A() {
|
|
254
|
+
if (this.t)
|
|
255
|
+
this.t.n = null;
|
|
159
256
|
this.s = null;
|
|
257
|
+
this.t = null;
|
|
160
258
|
this.p = defaultContext;
|
|
161
259
|
this.m = null;
|
|
162
260
|
this.a = STATE_DISPOSED;
|
|
@@ -181,7 +279,7 @@ var Owner = class {
|
|
|
181
279
|
let i = 0, len = this.m.length;
|
|
182
280
|
for (i = 0; i < len; i++) {
|
|
183
281
|
try {
|
|
184
|
-
this.m[i](error);
|
|
282
|
+
this.m[i](error, this);
|
|
185
283
|
break;
|
|
186
284
|
} catch (e) {
|
|
187
285
|
error = e;
|
|
@@ -245,61 +343,58 @@ var currentMask = DEFAULT_FLAGS;
|
|
|
245
343
|
var newSources = null;
|
|
246
344
|
var newSourcesIndex = 0;
|
|
247
345
|
var newFlags = 0;
|
|
248
|
-
var clock = 0;
|
|
249
346
|
var notStale = false;
|
|
250
347
|
var updateCheck = null;
|
|
251
348
|
var staleCheck = null;
|
|
252
349
|
function getObserver() {
|
|
253
350
|
return currentObserver;
|
|
254
351
|
}
|
|
255
|
-
function getClock() {
|
|
256
|
-
return clock;
|
|
257
|
-
}
|
|
258
|
-
function incrementClock() {
|
|
259
|
-
clock++;
|
|
260
|
-
}
|
|
261
352
|
var UNCHANGED = Symbol(0);
|
|
262
353
|
var Computation = class extends Owner {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
354
|
+
f = null;
|
|
355
|
+
d = null;
|
|
356
|
+
b;
|
|
357
|
+
E;
|
|
358
|
+
u;
|
|
268
359
|
// Used in __DEV__ mode, hopefully removed in production
|
|
269
360
|
Z;
|
|
270
361
|
// Using false is an optimization as an alternative to _equals: () => false
|
|
271
362
|
// which could enable more efficient DIRTY notification
|
|
272
363
|
N = isEqual;
|
|
273
|
-
|
|
364
|
+
U;
|
|
274
365
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
275
|
-
|
|
366
|
+
c = 0;
|
|
276
367
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
277
368
|
O = DEFAULT_FLAGS;
|
|
278
369
|
P = null;
|
|
279
|
-
|
|
280
|
-
|
|
370
|
+
z = -1;
|
|
371
|
+
I = false;
|
|
281
372
|
constructor(initialValue, compute2, options) {
|
|
282
373
|
super(compute2 === null);
|
|
283
|
-
this.
|
|
374
|
+
this.u = compute2;
|
|
284
375
|
this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
285
|
-
this.
|
|
286
|
-
this.
|
|
376
|
+
this.c = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
377
|
+
this.b = initialValue;
|
|
287
378
|
if ((options == null ? void 0 : options.equals) !== void 0)
|
|
288
379
|
this.N = options.equals;
|
|
289
380
|
if (options == null ? void 0 : options.unobserved)
|
|
290
|
-
this.
|
|
381
|
+
this.U = options == null ? void 0 : options.unobserved;
|
|
291
382
|
}
|
|
292
|
-
|
|
383
|
+
V() {
|
|
293
384
|
var _a;
|
|
294
|
-
if (this.
|
|
295
|
-
this.
|
|
296
|
-
|
|
385
|
+
if (this.u) {
|
|
386
|
+
if (this.c & ERROR_BIT && this.z <= getClock())
|
|
387
|
+
update(this);
|
|
388
|
+
else
|
|
389
|
+
this.y();
|
|
390
|
+
}
|
|
391
|
+
if (!this.u || ((_a = this.f) == null ? void 0 : _a.length))
|
|
297
392
|
track(this);
|
|
298
|
-
newFlags |= this.
|
|
299
|
-
if (this.
|
|
300
|
-
throw this.
|
|
393
|
+
newFlags |= this.c & ~currentMask;
|
|
394
|
+
if (this.c & ERROR_BIT) {
|
|
395
|
+
throw this.E;
|
|
301
396
|
} else {
|
|
302
|
-
return this.
|
|
397
|
+
return this.b;
|
|
303
398
|
}
|
|
304
399
|
}
|
|
305
400
|
/**
|
|
@@ -307,7 +402,7 @@ var Computation = class extends Owner {
|
|
|
307
402
|
* Automatically re-executes the surrounding computation when the value changes
|
|
308
403
|
*/
|
|
309
404
|
read() {
|
|
310
|
-
return this.
|
|
405
|
+
return this.V();
|
|
311
406
|
}
|
|
312
407
|
/**
|
|
313
408
|
* Return the current value of this computation
|
|
@@ -317,15 +412,15 @@ var Computation = class extends Owner {
|
|
|
317
412
|
* before continuing
|
|
318
413
|
*/
|
|
319
414
|
wait() {
|
|
320
|
-
if (this.
|
|
415
|
+
if (this.u && this.c & ERROR_BIT && this.z <= getClock()) {
|
|
321
416
|
update(this);
|
|
322
417
|
}
|
|
323
|
-
if ((notStale || this.
|
|
418
|
+
if ((notStale || this.c & UNINITIALIZED_BIT) && this.loading()) {
|
|
324
419
|
throw new NotReadyError();
|
|
325
420
|
}
|
|
326
|
-
if (staleCheck && this.
|
|
327
|
-
staleCheck.
|
|
328
|
-
return this.
|
|
421
|
+
if (staleCheck && this.loading())
|
|
422
|
+
staleCheck.b = true;
|
|
423
|
+
return this.V();
|
|
329
424
|
}
|
|
330
425
|
/**
|
|
331
426
|
* Return true if the computation is the value is dependent on an unresolved promise
|
|
@@ -342,37 +437,37 @@ var Computation = class extends Owner {
|
|
|
342
437
|
}
|
|
343
438
|
/** Update the computation with a new value. */
|
|
344
439
|
write(value, flags = 0, raw = false) {
|
|
345
|
-
const newValue = !raw && typeof value === "function" ? value(this.
|
|
346
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
440
|
+
const newValue = !raw && typeof value === "function" ? value(this.b) : value;
|
|
441
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.c & UNINITIALIZED_BIT) || this.N === false || !this.N(this.b, newValue));
|
|
347
442
|
if (valueChanged) {
|
|
348
|
-
this.
|
|
349
|
-
this.
|
|
443
|
+
this.b = newValue;
|
|
444
|
+
this.E = void 0;
|
|
350
445
|
}
|
|
351
|
-
const changedFlagsMask = this.
|
|
352
|
-
this.
|
|
353
|
-
this.
|
|
354
|
-
if (this.
|
|
355
|
-
for (let i = 0; i < this.
|
|
446
|
+
const changedFlagsMask = this.c ^ flags, changedFlags = changedFlagsMask & flags;
|
|
447
|
+
this.c = flags;
|
|
448
|
+
this.z = getClock() + 1;
|
|
449
|
+
if (this.d) {
|
|
450
|
+
for (let i = 0; i < this.d.length; i++) {
|
|
356
451
|
if (valueChanged) {
|
|
357
|
-
this.
|
|
452
|
+
this.d[i].q(STATE_DIRTY);
|
|
358
453
|
} else if (changedFlagsMask) {
|
|
359
|
-
this.
|
|
454
|
+
this.d[i].W(changedFlagsMask, changedFlags);
|
|
360
455
|
}
|
|
361
456
|
}
|
|
362
457
|
}
|
|
363
|
-
return this.
|
|
458
|
+
return this.b;
|
|
364
459
|
}
|
|
365
460
|
/**
|
|
366
461
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
367
462
|
*/
|
|
368
463
|
q(state, skipQueue) {
|
|
369
|
-
if (this.a >= state && !this.
|
|
464
|
+
if (this.a >= state && !this.I)
|
|
370
465
|
return;
|
|
371
|
-
this.
|
|
466
|
+
this.I = !!skipQueue;
|
|
372
467
|
this.a = state;
|
|
373
|
-
if (this.
|
|
374
|
-
for (let i = 0; i < this.
|
|
375
|
-
this.
|
|
468
|
+
if (this.d) {
|
|
469
|
+
for (let i = 0; i < this.d.length; i++) {
|
|
470
|
+
this.d[i].q(STATE_CHECK, skipQueue);
|
|
376
471
|
}
|
|
377
472
|
}
|
|
378
473
|
}
|
|
@@ -382,7 +477,7 @@ var Computation = class extends Owner {
|
|
|
382
477
|
* @param mask A bitmask for which flag(s) were changed.
|
|
383
478
|
* @param newFlags The source's new flags, masked to just the changed ones.
|
|
384
479
|
*/
|
|
385
|
-
|
|
480
|
+
W(mask, newFlags2) {
|
|
386
481
|
if (this.a >= STATE_DIRTY)
|
|
387
482
|
return;
|
|
388
483
|
if (mask & this.O) {
|
|
@@ -391,22 +486,22 @@ var Computation = class extends Owner {
|
|
|
391
486
|
}
|
|
392
487
|
if (this.a >= STATE_CHECK)
|
|
393
488
|
return;
|
|
394
|
-
const prevFlags = this.
|
|
489
|
+
const prevFlags = this.c & mask;
|
|
395
490
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
396
491
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
397
492
|
this.q(STATE_CHECK);
|
|
398
493
|
} else {
|
|
399
|
-
this.
|
|
400
|
-
if (this.
|
|
401
|
-
for (let i = 0; i < this.
|
|
402
|
-
this.
|
|
494
|
+
this.c ^= deltaFlags;
|
|
495
|
+
if (this.d) {
|
|
496
|
+
for (let i = 0; i < this.d.length; i++) {
|
|
497
|
+
this.d[i].W(mask, newFlags2);
|
|
403
498
|
}
|
|
404
499
|
}
|
|
405
500
|
}
|
|
406
501
|
}
|
|
407
|
-
|
|
408
|
-
this.
|
|
409
|
-
this.write(UNCHANGED, this.
|
|
502
|
+
J(error) {
|
|
503
|
+
this.E = error;
|
|
504
|
+
this.write(UNCHANGED, this.c & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
410
505
|
}
|
|
411
506
|
/**
|
|
412
507
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -415,7 +510,7 @@ var Computation = class extends Owner {
|
|
|
415
510
|
*
|
|
416
511
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
417
512
|
*/
|
|
418
|
-
|
|
513
|
+
y() {
|
|
419
514
|
if (this.a === STATE_DISPOSED) {
|
|
420
515
|
throw new Error("Tried to read a disposed computation");
|
|
421
516
|
}
|
|
@@ -424,9 +519,9 @@ var Computation = class extends Owner {
|
|
|
424
519
|
}
|
|
425
520
|
let observerFlags = 0;
|
|
426
521
|
if (this.a === STATE_CHECK) {
|
|
427
|
-
for (let i = 0; i < this.
|
|
428
|
-
this.
|
|
429
|
-
observerFlags |= this.
|
|
522
|
+
for (let i = 0; i < this.f.length; i++) {
|
|
523
|
+
this.f[i].y();
|
|
524
|
+
observerFlags |= this.f[i].c;
|
|
430
525
|
if (this.a === STATE_DIRTY) {
|
|
431
526
|
break;
|
|
432
527
|
}
|
|
@@ -442,23 +537,23 @@ var Computation = class extends Owner {
|
|
|
442
537
|
/**
|
|
443
538
|
* Remove ourselves from the owner graph and the computation graph
|
|
444
539
|
*/
|
|
445
|
-
|
|
540
|
+
A() {
|
|
446
541
|
if (this.a === STATE_DISPOSED)
|
|
447
542
|
return;
|
|
448
|
-
if (this.
|
|
543
|
+
if (this.f)
|
|
449
544
|
removeSourceObservers(this, 0);
|
|
450
|
-
super.
|
|
545
|
+
super.A();
|
|
451
546
|
}
|
|
452
547
|
};
|
|
453
548
|
function loadingState(node) {
|
|
454
|
-
const prevOwner = setOwner(node.
|
|
549
|
+
const prevOwner = setOwner(node.s);
|
|
455
550
|
const options = void 0;
|
|
456
551
|
const computation = new Computation(
|
|
457
552
|
void 0,
|
|
458
553
|
() => {
|
|
459
554
|
track(node);
|
|
460
|
-
node.
|
|
461
|
-
return !!(node.
|
|
555
|
+
node.y();
|
|
556
|
+
return !!(node.c & LOADING_BIT);
|
|
462
557
|
},
|
|
463
558
|
options
|
|
464
559
|
);
|
|
@@ -468,7 +563,7 @@ function loadingState(node) {
|
|
|
468
563
|
}
|
|
469
564
|
function track(computation) {
|
|
470
565
|
if (currentObserver) {
|
|
471
|
-
if (!newSources && currentObserver.
|
|
566
|
+
if (!newSources && currentObserver.f && currentObserver.f[newSourcesIndex] === computation) {
|
|
472
567
|
newSourcesIndex++;
|
|
473
568
|
} else if (!newSources)
|
|
474
569
|
newSources = [computation];
|
|
@@ -476,7 +571,7 @@ function track(computation) {
|
|
|
476
571
|
newSources.push(computation);
|
|
477
572
|
}
|
|
478
573
|
if (updateCheck) {
|
|
479
|
-
updateCheck.
|
|
574
|
+
updateCheck.b = computation.z > currentObserver.z;
|
|
480
575
|
}
|
|
481
576
|
}
|
|
482
577
|
}
|
|
@@ -488,42 +583,42 @@ function update(node) {
|
|
|
488
583
|
try {
|
|
489
584
|
node.dispose(false);
|
|
490
585
|
node.emptyDisposal();
|
|
491
|
-
const result = compute(node, node.
|
|
586
|
+
const result = compute(node, node.u, node);
|
|
492
587
|
node.write(result, newFlags, true);
|
|
493
588
|
} catch (error) {
|
|
494
589
|
if (error instanceof NotReadyError) {
|
|
495
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.
|
|
590
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.c & UNINITIALIZED_BIT);
|
|
496
591
|
} else {
|
|
497
|
-
node.
|
|
592
|
+
node.J(error);
|
|
498
593
|
}
|
|
499
594
|
} finally {
|
|
500
595
|
if (newSources) {
|
|
501
|
-
if (node.
|
|
596
|
+
if (node.f)
|
|
502
597
|
removeSourceObservers(node, newSourcesIndex);
|
|
503
|
-
if (node.
|
|
504
|
-
node.
|
|
598
|
+
if (node.f && newSourcesIndex > 0) {
|
|
599
|
+
node.f.length = newSourcesIndex + newSources.length;
|
|
505
600
|
for (let i = 0; i < newSources.length; i++) {
|
|
506
|
-
node.
|
|
601
|
+
node.f[newSourcesIndex + i] = newSources[i];
|
|
507
602
|
}
|
|
508
603
|
} else {
|
|
509
|
-
node.
|
|
604
|
+
node.f = newSources;
|
|
510
605
|
}
|
|
511
606
|
let source;
|
|
512
|
-
for (let i = newSourcesIndex; i < node.
|
|
513
|
-
source = node.
|
|
514
|
-
if (!source.
|
|
515
|
-
source.
|
|
607
|
+
for (let i = newSourcesIndex; i < node.f.length; i++) {
|
|
608
|
+
source = node.f[i];
|
|
609
|
+
if (!source.d)
|
|
610
|
+
source.d = [node];
|
|
516
611
|
else
|
|
517
|
-
source.
|
|
612
|
+
source.d.push(node);
|
|
518
613
|
}
|
|
519
|
-
} else if (node.
|
|
614
|
+
} else if (node.f && newSourcesIndex < node.f.length) {
|
|
520
615
|
removeSourceObservers(node, newSourcesIndex);
|
|
521
|
-
node.
|
|
616
|
+
node.f.length = newSourcesIndex;
|
|
522
617
|
}
|
|
523
618
|
newSources = prevSources;
|
|
524
619
|
newSourcesIndex = prevSourcesIndex;
|
|
525
620
|
newFlags = prevFlags;
|
|
526
|
-
node.
|
|
621
|
+
node.z = getClock() + 1;
|
|
527
622
|
node.a = STATE_CLEAN;
|
|
528
623
|
}
|
|
529
624
|
}
|
|
@@ -531,14 +626,14 @@ function removeSourceObservers(node, index) {
|
|
|
531
626
|
var _a;
|
|
532
627
|
let source;
|
|
533
628
|
let swap;
|
|
534
|
-
for (let i = index; i < node.
|
|
535
|
-
source = node.
|
|
536
|
-
if (source.
|
|
537
|
-
swap = source.
|
|
538
|
-
source.
|
|
539
|
-
source.
|
|
540
|
-
if (!source.
|
|
541
|
-
(_a = source.
|
|
629
|
+
for (let i = index; i < node.f.length; i++) {
|
|
630
|
+
source = node.f[i];
|
|
631
|
+
if (source.d) {
|
|
632
|
+
swap = source.d.indexOf(node);
|
|
633
|
+
source.d[swap] = source.d[source.d.length - 1];
|
|
634
|
+
source.d.pop();
|
|
635
|
+
if (!source.d.length)
|
|
636
|
+
(_a = source.U) == null ? void 0 : _a.call(source);
|
|
542
637
|
}
|
|
543
638
|
}
|
|
544
639
|
}
|
|
@@ -552,20 +647,20 @@ function untrack(fn) {
|
|
|
552
647
|
}
|
|
553
648
|
function hasUpdated(fn) {
|
|
554
649
|
const current = updateCheck;
|
|
555
|
-
updateCheck = {
|
|
650
|
+
updateCheck = { b: false };
|
|
556
651
|
try {
|
|
557
652
|
fn();
|
|
558
|
-
return updateCheck.
|
|
653
|
+
return updateCheck.b;
|
|
559
654
|
} finally {
|
|
560
655
|
updateCheck = current;
|
|
561
656
|
}
|
|
562
657
|
}
|
|
563
658
|
function isStale(fn) {
|
|
564
659
|
const current = staleCheck;
|
|
565
|
-
staleCheck = {
|
|
660
|
+
staleCheck = { b: false };
|
|
566
661
|
try {
|
|
567
662
|
latest(fn);
|
|
568
|
-
return staleCheck.
|
|
663
|
+
return staleCheck.b;
|
|
569
664
|
} catch {
|
|
570
665
|
} finally {
|
|
571
666
|
staleCheck = current;
|
|
@@ -598,7 +693,7 @@ function compute(owner, fn, observer) {
|
|
|
598
693
|
currentMask = (observer == null ? void 0 : observer.O) ?? DEFAULT_FLAGS;
|
|
599
694
|
notStale = true;
|
|
600
695
|
try {
|
|
601
|
-
return fn(observer ? observer.
|
|
696
|
+
return fn(observer ? observer.b : void 0);
|
|
602
697
|
} finally {
|
|
603
698
|
setOwner(prevOwner);
|
|
604
699
|
currentObserver = prevObserver;
|
|
@@ -606,103 +701,13 @@ function compute(owner, fn, observer) {
|
|
|
606
701
|
notStale = prevNotStale;
|
|
607
702
|
}
|
|
608
703
|
}
|
|
609
|
-
|
|
610
|
-
// src/core/scheduler.ts
|
|
611
|
-
var scheduled = false;
|
|
612
|
-
function schedule() {
|
|
613
|
-
if (scheduled)
|
|
614
|
-
return;
|
|
615
|
-
scheduled = true;
|
|
616
|
-
if (!globalQueue.J)
|
|
617
|
-
queueMicrotask(flushSync);
|
|
618
|
-
}
|
|
619
|
-
var Queue = class {
|
|
620
|
-
J = false;
|
|
621
|
-
u = [[], [], []];
|
|
622
|
-
E = [];
|
|
623
|
-
enqueue(type, node) {
|
|
624
|
-
this.u[0].push(node);
|
|
625
|
-
if (type)
|
|
626
|
-
this.u[type].push(node);
|
|
627
|
-
schedule();
|
|
628
|
-
}
|
|
629
|
-
run(type) {
|
|
630
|
-
if (this.u[type].length) {
|
|
631
|
-
if (type === EFFECT_PURE) {
|
|
632
|
-
runPureQueue(this.u[type]);
|
|
633
|
-
this.u[type] = [];
|
|
634
|
-
} else {
|
|
635
|
-
const effects = this.u[type];
|
|
636
|
-
this.u[type] = [];
|
|
637
|
-
runEffectQueue(effects);
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
let rerun = false;
|
|
641
|
-
for (let i = 0; i < this.E.length; i++) {
|
|
642
|
-
rerun = this.E[i].run(type) || rerun;
|
|
643
|
-
}
|
|
644
|
-
if (type === EFFECT_PURE && this.u[type].length)
|
|
645
|
-
return true;
|
|
646
|
-
}
|
|
647
|
-
flush() {
|
|
648
|
-
if (this.J)
|
|
649
|
-
return;
|
|
650
|
-
this.J = true;
|
|
651
|
-
try {
|
|
652
|
-
while (this.run(EFFECT_PURE)) {
|
|
653
|
-
}
|
|
654
|
-
incrementClock();
|
|
655
|
-
scheduled = false;
|
|
656
|
-
this.run(EFFECT_RENDER);
|
|
657
|
-
this.run(EFFECT_USER);
|
|
658
|
-
} finally {
|
|
659
|
-
this.J = false;
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
addChild(child) {
|
|
663
|
-
this.E.push(child);
|
|
664
|
-
}
|
|
665
|
-
removeChild(child) {
|
|
666
|
-
const index = this.E.indexOf(child);
|
|
667
|
-
if (index >= 0)
|
|
668
|
-
this.E.splice(index, 1);
|
|
669
|
-
}
|
|
670
|
-
};
|
|
671
|
-
var globalQueue = new Queue();
|
|
672
|
-
function flushSync() {
|
|
673
|
-
while (scheduled) {
|
|
674
|
-
globalQueue.flush();
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
704
|
function createBoundary(fn, queue) {
|
|
678
705
|
const owner = new Owner();
|
|
679
|
-
const parentQueue = owner.
|
|
680
|
-
parentQueue.addChild(owner.
|
|
681
|
-
onCleanup(() => parentQueue.removeChild(owner.
|
|
706
|
+
const parentQueue = owner.h;
|
|
707
|
+
parentQueue.addChild(owner.h = queue);
|
|
708
|
+
onCleanup(() => parentQueue.removeChild(owner.h));
|
|
682
709
|
return compute(owner, fn, null);
|
|
683
710
|
}
|
|
684
|
-
function runTop(node) {
|
|
685
|
-
const ancestors = [];
|
|
686
|
-
for (let current = node; current !== null; current = current.r) {
|
|
687
|
-
if (current.a !== STATE_CLEAN) {
|
|
688
|
-
ancestors.push(current);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
692
|
-
if (ancestors[i].a !== STATE_DISPOSED)
|
|
693
|
-
ancestors[i].x();
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
function runPureQueue(queue) {
|
|
697
|
-
for (let i = 0; i < queue.length; i++) {
|
|
698
|
-
if (queue[i].a !== STATE_CLEAN)
|
|
699
|
-
runTop(queue[i]);
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
function runEffectQueue(queue) {
|
|
703
|
-
for (let i = 0; i < queue.length; i++)
|
|
704
|
-
queue[i].W();
|
|
705
|
-
}
|
|
706
711
|
|
|
707
712
|
// src/core/effect.ts
|
|
708
713
|
var Effect = class extends Computation {
|
|
@@ -711,36 +716,33 @@ var Effect = class extends Computation {
|
|
|
711
716
|
B;
|
|
712
717
|
Q = false;
|
|
713
718
|
M;
|
|
714
|
-
|
|
715
|
-
b;
|
|
719
|
+
w;
|
|
716
720
|
constructor(initialValue, compute2, effect, error, options) {
|
|
717
|
-
var _a;
|
|
718
721
|
super(initialValue, compute2, options);
|
|
719
722
|
this.K = effect;
|
|
720
723
|
this.L = error;
|
|
721
724
|
this.M = initialValue;
|
|
722
|
-
this.
|
|
723
|
-
if (this.
|
|
724
|
-
this.
|
|
725
|
+
this.w = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
|
|
726
|
+
if (this.w === EFFECT_RENDER) {
|
|
727
|
+
this.u = (p) => getClock() > this.h.created ? latest(() => compute2(p)) : compute2(p);
|
|
725
728
|
}
|
|
726
|
-
this.b = ((_a = getOwner()) == null ? void 0 : _a.b) || globalQueue;
|
|
727
729
|
if (!(options == null ? void 0 : options.defer)) {
|
|
728
|
-
this.
|
|
729
|
-
this.
|
|
730
|
+
this.y();
|
|
731
|
+
this.w === EFFECT_USER ? this.h.enqueue(this.w, this) : this.T();
|
|
730
732
|
}
|
|
731
733
|
}
|
|
732
734
|
write(value, flags = 0) {
|
|
733
735
|
var _a, _b;
|
|
734
736
|
if (this.a == STATE_DIRTY) {
|
|
735
|
-
const currentFlags = this.
|
|
736
|
-
this.
|
|
737
|
-
if (this.
|
|
738
|
-
(_b = (_a = this.
|
|
737
|
+
const currentFlags = this.c;
|
|
738
|
+
this.c = flags;
|
|
739
|
+
if (this.w === EFFECT_RENDER && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
|
|
740
|
+
(_b = (_a = this.h).R) == null ? void 0 : _b.call(_a, this);
|
|
739
741
|
}
|
|
740
742
|
}
|
|
741
743
|
if (value === UNCHANGED)
|
|
742
|
-
return this.
|
|
743
|
-
this.
|
|
744
|
+
return this.b;
|
|
745
|
+
this.b = value;
|
|
744
746
|
this.Q = true;
|
|
745
747
|
return value;
|
|
746
748
|
}
|
|
@@ -748,17 +750,17 @@ var Effect = class extends Computation {
|
|
|
748
750
|
if (this.a >= state || skipQueue)
|
|
749
751
|
return;
|
|
750
752
|
if (this.a === STATE_CLEAN)
|
|
751
|
-
this.
|
|
753
|
+
this.h.enqueue(this.w, this);
|
|
752
754
|
this.a = state;
|
|
753
755
|
}
|
|
754
|
-
|
|
756
|
+
J(error) {
|
|
755
757
|
var _a, _b, _c;
|
|
756
758
|
(_a = this.B) == null ? void 0 : _a.call(this);
|
|
757
|
-
if (this.
|
|
758
|
-
this.
|
|
759
|
-
(_c = (_b = this.
|
|
759
|
+
if (this.c & LOADING_BIT) {
|
|
760
|
+
this.c = 0;
|
|
761
|
+
(_c = (_b = this.h).R) == null ? void 0 : _c.call(_b, this);
|
|
760
762
|
}
|
|
761
|
-
if (this.
|
|
763
|
+
if (this.w === EFFECT_USER) {
|
|
762
764
|
try {
|
|
763
765
|
return this.L ? this.B = this.L(error) : console.error(new EffectError(this.K, error));
|
|
764
766
|
} catch (e) {
|
|
@@ -767,7 +769,7 @@ var Effect = class extends Computation {
|
|
|
767
769
|
}
|
|
768
770
|
this.handleError(error);
|
|
769
771
|
}
|
|
770
|
-
|
|
772
|
+
A() {
|
|
771
773
|
var _a;
|
|
772
774
|
if (this.a === STATE_DISPOSED)
|
|
773
775
|
return;
|
|
@@ -776,58 +778,52 @@ var Effect = class extends Computation {
|
|
|
776
778
|
this.L = void 0;
|
|
777
779
|
(_a = this.B) == null ? void 0 : _a.call(this);
|
|
778
780
|
this.B = void 0;
|
|
779
|
-
super.
|
|
781
|
+
super.A();
|
|
780
782
|
}
|
|
781
|
-
|
|
783
|
+
T() {
|
|
782
784
|
var _a;
|
|
783
785
|
if (this.Q && this.a !== STATE_DISPOSED) {
|
|
784
786
|
(_a = this.B) == null ? void 0 : _a.call(this);
|
|
785
787
|
try {
|
|
786
|
-
this.B = this.K(this.
|
|
788
|
+
this.B = this.K(this.b, this.M);
|
|
787
789
|
} catch (e) {
|
|
788
790
|
this.handleError(e);
|
|
789
791
|
} finally {
|
|
790
|
-
this.M = this.
|
|
792
|
+
this.M = this.b;
|
|
791
793
|
this.Q = false;
|
|
792
794
|
}
|
|
793
795
|
}
|
|
794
796
|
}
|
|
795
797
|
};
|
|
796
798
|
var EagerComputation = class extends Computation {
|
|
797
|
-
b;
|
|
798
799
|
constructor(initialValue, compute2, options) {
|
|
799
|
-
var _a;
|
|
800
800
|
super(initialValue, compute2, options);
|
|
801
|
-
|
|
802
|
-
this.x();
|
|
801
|
+
!(options == null ? void 0 : options.defer) && this.y();
|
|
803
802
|
}
|
|
804
803
|
q(state, skipQueue) {
|
|
805
|
-
if (this.a >= state && !this.
|
|
804
|
+
if (this.a >= state && !this.I)
|
|
806
805
|
return;
|
|
807
806
|
if (this.a === STATE_CLEAN && !skipQueue)
|
|
808
|
-
this.
|
|
807
|
+
this.h.enqueue(EFFECT_PURE, this);
|
|
809
808
|
super.q(state, skipQueue);
|
|
810
809
|
}
|
|
811
810
|
};
|
|
812
811
|
var ProjectionComputation = class extends Computation {
|
|
813
|
-
b;
|
|
814
812
|
constructor(compute2) {
|
|
815
|
-
var _a;
|
|
816
813
|
super(null, compute2);
|
|
817
|
-
this.b = ((_a = getOwner()) == null ? void 0 : _a.b) || globalQueue;
|
|
818
814
|
}
|
|
819
815
|
q(state, skipQueue) {
|
|
820
|
-
if (this.a >= state && !this.
|
|
816
|
+
if (this.a >= state && !this.I)
|
|
821
817
|
return;
|
|
822
818
|
if (this.a === STATE_CLEAN && !skipQueue)
|
|
823
|
-
this.
|
|
819
|
+
this.h.enqueue(EFFECT_PURE, this);
|
|
824
820
|
super.q(state, true);
|
|
825
821
|
}
|
|
826
822
|
};
|
|
827
823
|
|
|
828
824
|
// src/core/suspense.ts
|
|
829
825
|
var SuspenseQueue = class extends Queue {
|
|
830
|
-
|
|
826
|
+
e = /* @__PURE__ */ new Set();
|
|
831
827
|
o = false;
|
|
832
828
|
S = new Computation(false, null);
|
|
833
829
|
run(type) {
|
|
@@ -836,15 +832,15 @@ var SuspenseQueue = class extends Queue {
|
|
|
836
832
|
return super.run(type);
|
|
837
833
|
}
|
|
838
834
|
R(node) {
|
|
839
|
-
if (node.
|
|
840
|
-
this.
|
|
835
|
+
if (node.c & LOADING_BIT) {
|
|
836
|
+
this.e.add(node);
|
|
841
837
|
if (!this.o) {
|
|
842
838
|
this.o = true;
|
|
843
839
|
this.S.write(true);
|
|
844
840
|
}
|
|
845
841
|
} else {
|
|
846
|
-
this.
|
|
847
|
-
if (this.
|
|
842
|
+
this.e.delete(node);
|
|
843
|
+
if (this.e.size === 0) {
|
|
848
844
|
this.o = false;
|
|
849
845
|
this.S.write(false);
|
|
850
846
|
}
|
|
@@ -854,12 +850,13 @@ var SuspenseQueue = class extends Queue {
|
|
|
854
850
|
var LiveComputation = class extends EagerComputation {
|
|
855
851
|
write(value, flags = 0) {
|
|
856
852
|
var _a, _b;
|
|
857
|
-
const currentFlags = this.
|
|
853
|
+
const currentFlags = this.c;
|
|
854
|
+
const dirty = this.a === STATE_DIRTY;
|
|
858
855
|
super.write(value, flags);
|
|
859
|
-
if ((flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
|
|
860
|
-
(_b = (_a = this.
|
|
856
|
+
if (dirty && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
|
|
857
|
+
(_b = (_a = this.h).R) == null ? void 0 : _b.call(_a, this);
|
|
861
858
|
}
|
|
862
|
-
return this.
|
|
859
|
+
return this.b;
|
|
863
860
|
}
|
|
864
861
|
};
|
|
865
862
|
function createSuspense(fn, fallback) {
|
|
@@ -900,10 +897,10 @@ function createMemo(compute2, value, options) {
|
|
|
900
897
|
var _a, _b, _c;
|
|
901
898
|
if (node) {
|
|
902
899
|
resolvedValue = node.wait();
|
|
903
|
-
if (!((_a = node.
|
|
900
|
+
if (!((_a = node.f) == null ? void 0 : _a.length) && ((_b = node.n) == null ? void 0 : _b.s) !== node) {
|
|
904
901
|
node.dispose();
|
|
905
902
|
node = void 0;
|
|
906
|
-
} else if (!node.
|
|
903
|
+
} else if (!node.s && !((_c = node.d) == null ? void 0 : _c.length)) {
|
|
907
904
|
node.dispose();
|
|
908
905
|
node.a = STATE_DIRTY;
|
|
909
906
|
}
|
|
@@ -915,10 +912,10 @@ function createAsync(compute2, value, options) {
|
|
|
915
912
|
let uninitialized = value === void 0;
|
|
916
913
|
const lhs = new EagerComputation(
|
|
917
914
|
{
|
|
918
|
-
|
|
915
|
+
b: value
|
|
919
916
|
},
|
|
920
917
|
(p) => {
|
|
921
|
-
const value2 = p == null ? void 0 : p.
|
|
918
|
+
const value2 = p == null ? void 0 : p.b;
|
|
922
919
|
const source = compute2(value2);
|
|
923
920
|
const isPromise = source instanceof Promise;
|
|
924
921
|
const iterator = source[Symbol.asyncIterator];
|
|
@@ -927,13 +924,13 @@ function createAsync(compute2, value, options) {
|
|
|
927
924
|
wait() {
|
|
928
925
|
return source;
|
|
929
926
|
},
|
|
930
|
-
|
|
927
|
+
b: source
|
|
931
928
|
};
|
|
932
929
|
}
|
|
933
930
|
const signal = new Computation(value2, null, options);
|
|
934
931
|
const w = signal.wait;
|
|
935
932
|
signal.wait = function() {
|
|
936
|
-
if (signal.
|
|
933
|
+
if (signal.c & ERROR_BIT && signal.z <= getClock()) {
|
|
937
934
|
lhs.q(STATE_DIRTY);
|
|
938
935
|
throw new NotReadyError();
|
|
939
936
|
}
|
|
@@ -948,7 +945,7 @@ function createAsync(compute2, value, options) {
|
|
|
948
945
|
},
|
|
949
946
|
(error) => {
|
|
950
947
|
uninitialized = true;
|
|
951
|
-
signal.
|
|
948
|
+
signal.J(error);
|
|
952
949
|
}
|
|
953
950
|
);
|
|
954
951
|
} else {
|
|
@@ -1000,16 +997,31 @@ function runWithOwner(owner, run) {
|
|
|
1000
997
|
}
|
|
1001
998
|
function createErrorBoundary(fn, fallback) {
|
|
1002
999
|
const owner = new Owner();
|
|
1003
|
-
const error = new Computation(
|
|
1004
|
-
const
|
|
1005
|
-
|
|
1000
|
+
const error = new Computation(void 0, null);
|
|
1001
|
+
const nodes = /* @__PURE__ */ new Set();
|
|
1002
|
+
function handler(err, node) {
|
|
1003
|
+
if (nodes.has(node))
|
|
1004
|
+
return;
|
|
1005
|
+
compute(
|
|
1006
|
+
node,
|
|
1007
|
+
() => onCleanup(() => {
|
|
1008
|
+
nodes.delete(node);
|
|
1009
|
+
if (!nodes.size)
|
|
1010
|
+
error.write(void 0);
|
|
1011
|
+
}),
|
|
1012
|
+
null
|
|
1013
|
+
);
|
|
1014
|
+
nodes.add(node);
|
|
1015
|
+
if (nodes.size === 1)
|
|
1016
|
+
error.write({ E: err });
|
|
1017
|
+
}
|
|
1006
1018
|
owner.m = owner.m ? [handler, ...owner.m] : [handler];
|
|
1007
1019
|
const guarded = compute(
|
|
1008
1020
|
owner,
|
|
1009
1021
|
() => {
|
|
1010
|
-
const c = new Computation(
|
|
1011
|
-
const f = new
|
|
1012
|
-
f.
|
|
1022
|
+
const c = new Computation(void 0, fn);
|
|
1023
|
+
const f = new EagerComputation(void 0, () => flatten(c.read()), { defer: true });
|
|
1024
|
+
f.J = function(error2) {
|
|
1013
1025
|
this.handleError(error2);
|
|
1014
1026
|
};
|
|
1015
1027
|
return f;
|
|
@@ -1022,24 +1034,30 @@ function createErrorBoundary(fn, fallback) {
|
|
|
1022
1034
|
if (!error.read())
|
|
1023
1035
|
return resolved;
|
|
1024
1036
|
}
|
|
1025
|
-
return fallback(error.read().
|
|
1026
|
-
|
|
1027
|
-
|
|
1037
|
+
return fallback(error.read().E, () => {
|
|
1038
|
+
var _a;
|
|
1039
|
+
incrementClock();
|
|
1040
|
+
for (let node of nodes) {
|
|
1041
|
+
node.a = STATE_DIRTY;
|
|
1042
|
+
(_a = node.h) == null ? void 0 : _a.enqueue(node.w, node);
|
|
1043
|
+
}
|
|
1028
1044
|
});
|
|
1029
1045
|
});
|
|
1030
1046
|
return decision.read.bind(decision);
|
|
1031
1047
|
}
|
|
1032
1048
|
function resolve(fn) {
|
|
1033
1049
|
return new Promise((res, rej) => {
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1050
|
+
createRoot((dispose) => {
|
|
1051
|
+
new EagerComputation(void 0, () => {
|
|
1052
|
+
try {
|
|
1053
|
+
res(fn());
|
|
1054
|
+
} catch (err) {
|
|
1055
|
+
if (err instanceof NotReadyError)
|
|
1056
|
+
throw err;
|
|
1057
|
+
rej(err);
|
|
1058
|
+
}
|
|
1059
|
+
dispose();
|
|
1060
|
+
});
|
|
1043
1061
|
});
|
|
1044
1062
|
});
|
|
1045
1063
|
}
|
|
@@ -1050,10 +1068,10 @@ function createReaction(effect, error, options) {
|
|
|
1050
1068
|
...void 0
|
|
1051
1069
|
});
|
|
1052
1070
|
return (tracking) => {
|
|
1053
|
-
node.
|
|
1071
|
+
node.u = tracking;
|
|
1054
1072
|
node.a = STATE_DIRTY;
|
|
1055
|
-
node.
|
|
1056
|
-
node.
|
|
1073
|
+
node.y();
|
|
1074
|
+
node.u = null;
|
|
1057
1075
|
};
|
|
1058
1076
|
}
|
|
1059
1077
|
|
|
@@ -1202,7 +1220,7 @@ var proxyTraps = {
|
|
|
1202
1220
|
return desc.get.call(receiver);
|
|
1203
1221
|
}
|
|
1204
1222
|
if (Writing.has(storeValue)) {
|
|
1205
|
-
const value2 = tracked ? tracked.
|
|
1223
|
+
const value2 = tracked ? tracked.b : storeValue[property];
|
|
1206
1224
|
return isWrappable(value2) ? (Writing.add(value2[$RAW] || value2), wrap2(value2)) : value2;
|
|
1207
1225
|
}
|
|
1208
1226
|
let value = tracked ? nodes[property].read() : storeValue[property];
|
|
@@ -1546,10 +1564,10 @@ function mapArray(list, map, options) {
|
|
|
1546
1564
|
F: new Owner(),
|
|
1547
1565
|
i: 0,
|
|
1548
1566
|
X: list,
|
|
1549
|
-
|
|
1567
|
+
x: [],
|
|
1550
1568
|
G: map,
|
|
1551
|
-
|
|
1552
|
-
|
|
1569
|
+
g: [],
|
|
1570
|
+
e: [],
|
|
1553
1571
|
C: keyFn,
|
|
1554
1572
|
j: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
1555
1573
|
k: map.length > 1 ? [] : void 0,
|
|
@@ -1578,38 +1596,38 @@ function updateKeyedMap() {
|
|
|
1578
1596
|
if (newLen === 0) {
|
|
1579
1597
|
if (this.i !== 0) {
|
|
1580
1598
|
this.F.dispose(false);
|
|
1581
|
-
this.
|
|
1582
|
-
this.
|
|
1583
|
-
this.
|
|
1599
|
+
this.e = [];
|
|
1600
|
+
this.x = [];
|
|
1601
|
+
this.g = [];
|
|
1584
1602
|
this.i = 0;
|
|
1585
1603
|
this.j && (this.j = []);
|
|
1586
1604
|
this.k && (this.k = []);
|
|
1587
1605
|
}
|
|
1588
|
-
if (this.o && !this.
|
|
1589
|
-
this.
|
|
1590
|
-
this.
|
|
1606
|
+
if (this.o && !this.g[0]) {
|
|
1607
|
+
this.g[0] = compute(
|
|
1608
|
+
this.e[0] = new Owner(),
|
|
1591
1609
|
this.o,
|
|
1592
1610
|
null
|
|
1593
1611
|
);
|
|
1594
1612
|
}
|
|
1595
1613
|
} else if (this.i === 0) {
|
|
1596
|
-
if (this.
|
|
1597
|
-
this.
|
|
1598
|
-
this.
|
|
1614
|
+
if (this.e[0])
|
|
1615
|
+
this.e[0].dispose();
|
|
1616
|
+
this.g = new Array(newLen);
|
|
1599
1617
|
for (j = 0; j < newLen; j++) {
|
|
1600
|
-
this.
|
|
1601
|
-
this.
|
|
1618
|
+
this.x[j] = newItems[j];
|
|
1619
|
+
this.g[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
1602
1620
|
}
|
|
1603
1621
|
this.i = newLen;
|
|
1604
1622
|
} else {
|
|
1605
1623
|
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.j ? new Array(newLen) : void 0, tempIndexes = this.k ? new Array(newLen) : void 0;
|
|
1606
|
-
for (start = 0, end = Math.min(this.i, newLen); start < end && (this.
|
|
1624
|
+
for (start = 0, end = Math.min(this.i, newLen); start < end && (this.x[start] === newItems[start] || this.j && compare(this.C, this.x[start], newItems[start])); start++) {
|
|
1607
1625
|
if (this.j)
|
|
1608
1626
|
this.j[start].write(newItems[start]);
|
|
1609
1627
|
}
|
|
1610
|
-
for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.
|
|
1611
|
-
temp[newEnd] = this.
|
|
1612
|
-
tempNodes[newEnd] = this.
|
|
1628
|
+
for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.x[end] === newItems[newEnd] || this.j && compare(this.C, this.x[end], newItems[newEnd])); end--, newEnd--) {
|
|
1629
|
+
temp[newEnd] = this.g[end];
|
|
1630
|
+
tempNodes[newEnd] = this.e[end];
|
|
1613
1631
|
tempRows && (tempRows[newEnd] = this.j[end]);
|
|
1614
1632
|
tempIndexes && (tempIndexes[newEnd] = this.k[end]);
|
|
1615
1633
|
}
|
|
@@ -1623,23 +1641,23 @@ function updateKeyedMap() {
|
|
|
1623
1641
|
newIndices.set(key, j);
|
|
1624
1642
|
}
|
|
1625
1643
|
for (i = start; i <= end; i++) {
|
|
1626
|
-
item = this.
|
|
1644
|
+
item = this.x[i];
|
|
1627
1645
|
key = this.C ? this.C(item) : item;
|
|
1628
1646
|
j = newIndices.get(key);
|
|
1629
1647
|
if (j !== void 0 && j !== -1) {
|
|
1630
|
-
temp[j] = this.
|
|
1631
|
-
tempNodes[j] = this.
|
|
1648
|
+
temp[j] = this.g[i];
|
|
1649
|
+
tempNodes[j] = this.e[i];
|
|
1632
1650
|
tempRows && (tempRows[j] = this.j[i]);
|
|
1633
1651
|
tempIndexes && (tempIndexes[j] = this.k[i]);
|
|
1634
1652
|
j = newIndicesNext[j];
|
|
1635
1653
|
newIndices.set(key, j);
|
|
1636
1654
|
} else
|
|
1637
|
-
this.
|
|
1655
|
+
this.e[i].dispose();
|
|
1638
1656
|
}
|
|
1639
1657
|
for (j = start; j < newLen; j++) {
|
|
1640
1658
|
if (j in temp) {
|
|
1641
|
-
this.
|
|
1642
|
-
this.
|
|
1659
|
+
this.g[j] = temp[j];
|
|
1660
|
+
this.e[j] = tempNodes[j];
|
|
1643
1661
|
if (tempRows) {
|
|
1644
1662
|
this.j[j] = tempRows[j];
|
|
1645
1663
|
this.j[j].write(newItems[j]);
|
|
@@ -1649,14 +1667,14 @@ function updateKeyedMap() {
|
|
|
1649
1667
|
this.k[j].write(j);
|
|
1650
1668
|
}
|
|
1651
1669
|
} else {
|
|
1652
|
-
this.
|
|
1670
|
+
this.g[j] = compute(this.e[j] = new Owner(), mapper, null);
|
|
1653
1671
|
}
|
|
1654
1672
|
}
|
|
1655
|
-
this.
|
|
1656
|
-
this.
|
|
1673
|
+
this.g = this.g.slice(0, this.i = newLen);
|
|
1674
|
+
this.x = newItems.slice(0);
|
|
1657
1675
|
}
|
|
1658
1676
|
});
|
|
1659
|
-
return this.
|
|
1677
|
+
return this.g;
|
|
1660
1678
|
}
|
|
1661
1679
|
function repeat(count, map, options) {
|
|
1662
1680
|
return updateRepeat.bind({
|
|
@@ -1664,8 +1682,8 @@ function repeat(count, map, options) {
|
|
|
1664
1682
|
i: 0,
|
|
1665
1683
|
Y: count,
|
|
1666
1684
|
G: map,
|
|
1667
|
-
|
|
1668
|
-
|
|
1685
|
+
e: [],
|
|
1686
|
+
g: [],
|
|
1669
1687
|
o: options == null ? void 0 : options.fallback
|
|
1670
1688
|
});
|
|
1671
1689
|
}
|
|
@@ -1675,34 +1693,34 @@ function updateRepeat() {
|
|
|
1675
1693
|
if (newLen === 0) {
|
|
1676
1694
|
if (this.i !== 0) {
|
|
1677
1695
|
this.F.dispose(false);
|
|
1678
|
-
this.
|
|
1679
|
-
this.
|
|
1696
|
+
this.e = [];
|
|
1697
|
+
this.g = [];
|
|
1680
1698
|
this.i = 0;
|
|
1681
1699
|
}
|
|
1682
|
-
if (this.o && !this.
|
|
1683
|
-
this.
|
|
1684
|
-
this.
|
|
1700
|
+
if (this.o && !this.g[0]) {
|
|
1701
|
+
this.g[0] = compute(
|
|
1702
|
+
this.e[0] = new Owner(),
|
|
1685
1703
|
this.o,
|
|
1686
1704
|
null
|
|
1687
1705
|
);
|
|
1688
1706
|
}
|
|
1689
1707
|
} else {
|
|
1690
|
-
if (this.i === 0 && this.
|
|
1691
|
-
this.
|
|
1708
|
+
if (this.i === 0 && this.e[0])
|
|
1709
|
+
this.e[0].dispose();
|
|
1692
1710
|
for (let i = this.i; i < newLen; i++) {
|
|
1693
|
-
this.
|
|
1694
|
-
this.
|
|
1711
|
+
this.g[i] = compute(
|
|
1712
|
+
this.e[i] = new Owner(),
|
|
1695
1713
|
() => this.G(i),
|
|
1696
1714
|
null
|
|
1697
1715
|
);
|
|
1698
1716
|
}
|
|
1699
1717
|
for (let i = newLen; i < this.i; i++)
|
|
1700
|
-
this.
|
|
1701
|
-
this.
|
|
1718
|
+
this.e[i].dispose();
|
|
1719
|
+
this.g = this.g.slice(0, newLen);
|
|
1702
1720
|
this.i = newLen;
|
|
1703
1721
|
}
|
|
1704
1722
|
});
|
|
1705
|
-
return this.
|
|
1723
|
+
return this.g;
|
|
1706
1724
|
}
|
|
1707
1725
|
function compare(key, a, b) {
|
|
1708
1726
|
return key ? key(a) === key(b) : true;
|