@solidjs/signals 0.2.3 → 0.2.4
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 +48 -16
- package/dist/node.cjs +302 -269
- package/dist/prod.js +301 -269
- package/dist/types/map.d.ts +1 -0
- package/dist/types/store/projection.d.ts +3 -1
- package/package.json +1 -1
package/dist/node.cjs
CHANGED
|
@@ -45,42 +45,42 @@ function schedule() {
|
|
|
45
45
|
if (scheduled)
|
|
46
46
|
return;
|
|
47
47
|
scheduled = true;
|
|
48
|
-
if (!globalQueue.
|
|
48
|
+
if (!globalQueue.J)
|
|
49
49
|
queueMicrotask(flushSync);
|
|
50
50
|
}
|
|
51
51
|
var Queue = class {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
J = false;
|
|
53
|
+
s = [[], [], []];
|
|
54
|
+
F = [];
|
|
55
55
|
created = clock;
|
|
56
56
|
enqueue(type, node) {
|
|
57
|
-
this.
|
|
57
|
+
this.s[0].push(node);
|
|
58
58
|
if (type)
|
|
59
|
-
this.
|
|
59
|
+
this.s[type].push(node);
|
|
60
60
|
schedule();
|
|
61
61
|
}
|
|
62
62
|
run(type) {
|
|
63
|
-
if (this.
|
|
63
|
+
if (this.s[type].length) {
|
|
64
64
|
if (type === EFFECT_PURE) {
|
|
65
|
-
runPureQueue(this.
|
|
66
|
-
this.
|
|
65
|
+
runPureQueue(this.s[type]);
|
|
66
|
+
this.s[type] = [];
|
|
67
67
|
} else {
|
|
68
|
-
const effects = this.
|
|
69
|
-
this.
|
|
68
|
+
const effects = this.s[type];
|
|
69
|
+
this.s[type] = [];
|
|
70
70
|
runEffectQueue(effects);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
let rerun = false;
|
|
74
|
-
for (let i = 0; i < this.
|
|
75
|
-
rerun = this.
|
|
74
|
+
for (let i = 0; i < this.F.length; i++) {
|
|
75
|
+
rerun = this.F[i].run(type) || rerun;
|
|
76
76
|
}
|
|
77
|
-
if (type === EFFECT_PURE && this.
|
|
77
|
+
if (type === EFFECT_PURE && this.s[type].length)
|
|
78
78
|
return true;
|
|
79
79
|
}
|
|
80
80
|
flush() {
|
|
81
|
-
if (this.
|
|
81
|
+
if (this.J)
|
|
82
82
|
return;
|
|
83
|
-
this.
|
|
83
|
+
this.J = true;
|
|
84
84
|
try {
|
|
85
85
|
while (this.run(EFFECT_PURE)) {
|
|
86
86
|
}
|
|
@@ -89,16 +89,16 @@ var Queue = class {
|
|
|
89
89
|
this.run(EFFECT_RENDER);
|
|
90
90
|
this.run(EFFECT_USER);
|
|
91
91
|
} finally {
|
|
92
|
-
this.
|
|
92
|
+
this.J = false;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
addChild(child) {
|
|
96
|
-
this.
|
|
96
|
+
this.F.push(child);
|
|
97
97
|
}
|
|
98
98
|
removeChild(child) {
|
|
99
|
-
const index = this.
|
|
99
|
+
const index = this.F.indexOf(child);
|
|
100
100
|
if (index >= 0)
|
|
101
|
-
this.
|
|
101
|
+
this.F.splice(index, 1);
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
104
|
var globalQueue = new Queue();
|
|
@@ -109,14 +109,14 @@ function flushSync() {
|
|
|
109
109
|
}
|
|
110
110
|
function runTop(node) {
|
|
111
111
|
const ancestors = [];
|
|
112
|
-
for (let current = node; current !== null; current = current.
|
|
112
|
+
for (let current = node; current !== null; current = current.t) {
|
|
113
113
|
if (current.a !== STATE_CLEAN) {
|
|
114
114
|
ancestors.push(current);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
118
118
|
if (ancestors[i].a !== STATE_DISPOSED)
|
|
119
|
-
ancestors[i].
|
|
119
|
+
ancestors[i].z();
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
function runPureQueue(queue) {
|
|
@@ -127,7 +127,7 @@ function runPureQueue(queue) {
|
|
|
127
127
|
}
|
|
128
128
|
function runEffectQueue(queue) {
|
|
129
129
|
for (let i = 0; i < queue.length; i++)
|
|
130
|
-
queue[i].
|
|
130
|
+
queue[i].U();
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// src/core/utils.ts
|
|
@@ -150,9 +150,9 @@ var Owner = class {
|
|
|
150
150
|
// We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild
|
|
151
151
|
// However, the children are actually added in reverse creation order
|
|
152
152
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
153
|
-
s = null;
|
|
154
|
-
n = null;
|
|
155
153
|
t = null;
|
|
154
|
+
n = null;
|
|
155
|
+
u = null;
|
|
156
156
|
a = STATE_CLEAN;
|
|
157
157
|
l = null;
|
|
158
158
|
p = defaultContext;
|
|
@@ -163,10 +163,10 @@ var Owner = class {
|
|
|
163
163
|
currentOwner.append(this);
|
|
164
164
|
}
|
|
165
165
|
append(child) {
|
|
166
|
-
child.s = this;
|
|
167
166
|
child.t = this;
|
|
167
|
+
child.u = this;
|
|
168
168
|
if (this.n)
|
|
169
|
-
this.n.
|
|
169
|
+
this.n.u = child;
|
|
170
170
|
child.n = this.n;
|
|
171
171
|
this.n = child;
|
|
172
172
|
if (child.p !== this.p) {
|
|
@@ -181,26 +181,26 @@ var Owner = class {
|
|
|
181
181
|
dispose(self = true) {
|
|
182
182
|
if (this.a === STATE_DISPOSED)
|
|
183
183
|
return;
|
|
184
|
-
let head = self ? this.
|
|
185
|
-
while (current && current.
|
|
184
|
+
let head = self ? this.u || this.t : this, current = this.n, next = null;
|
|
185
|
+
while (current && current.t === this) {
|
|
186
186
|
current.dispose(true);
|
|
187
|
-
current.
|
|
187
|
+
current.A();
|
|
188
188
|
next = current.n;
|
|
189
189
|
current.n = null;
|
|
190
190
|
current = next;
|
|
191
191
|
}
|
|
192
192
|
if (self)
|
|
193
|
-
this.
|
|
193
|
+
this.A();
|
|
194
194
|
if (current)
|
|
195
|
-
current.
|
|
195
|
+
current.u = !self ? this : this.u;
|
|
196
196
|
if (head)
|
|
197
197
|
head.n = current;
|
|
198
198
|
}
|
|
199
|
-
|
|
200
|
-
if (this.
|
|
201
|
-
this.
|
|
202
|
-
this.s = null;
|
|
199
|
+
A() {
|
|
200
|
+
if (this.u)
|
|
201
|
+
this.u.n = null;
|
|
203
202
|
this.t = null;
|
|
203
|
+
this.u = null;
|
|
204
204
|
this.p = defaultContext;
|
|
205
205
|
this.m = null;
|
|
206
206
|
this.a = STATE_DISPOSED;
|
|
@@ -298,49 +298,49 @@ function getObserver() {
|
|
|
298
298
|
var UNCHANGED = Symbol(0);
|
|
299
299
|
var Computation = class extends Owner {
|
|
300
300
|
b = null;
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
301
|
+
e = null;
|
|
302
|
+
g;
|
|
303
|
+
G;
|
|
304
|
+
B;
|
|
305
305
|
// Used in __DEV__ mode, hopefully removed in production
|
|
306
|
-
|
|
306
|
+
$;
|
|
307
307
|
// Using false is an optimization as an alternative to _equals: () => false
|
|
308
308
|
// which could enable more efficient DIRTY notification
|
|
309
|
-
|
|
310
|
-
|
|
309
|
+
O = isEqual;
|
|
310
|
+
V;
|
|
311
311
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
312
|
-
|
|
312
|
+
f = 0;
|
|
313
313
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
314
|
+
P = DEFAULT_FLAGS;
|
|
315
|
+
Q = null;
|
|
316
|
+
y = -1;
|
|
317
|
+
K = false;
|
|
318
318
|
constructor(initialValue, compute2, options) {
|
|
319
319
|
super(compute2 === null);
|
|
320
|
-
this.
|
|
320
|
+
this.B = compute2;
|
|
321
321
|
this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
322
|
-
this.
|
|
323
|
-
this.
|
|
322
|
+
this.f = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
323
|
+
this.g = initialValue;
|
|
324
324
|
if ((options == null ? void 0 : options.equals) !== void 0)
|
|
325
|
-
this.
|
|
325
|
+
this.O = options.equals;
|
|
326
326
|
if (options == null ? void 0 : options.unobserved)
|
|
327
|
-
this.
|
|
327
|
+
this.V = options == null ? void 0 : options.unobserved;
|
|
328
328
|
}
|
|
329
|
-
|
|
329
|
+
W() {
|
|
330
330
|
var _a;
|
|
331
|
-
if (this.
|
|
332
|
-
if (this.
|
|
331
|
+
if (this.B) {
|
|
332
|
+
if (this.f & ERROR_BIT && this.y <= getClock())
|
|
333
333
|
update(this);
|
|
334
334
|
else
|
|
335
|
-
this.
|
|
335
|
+
this.z();
|
|
336
336
|
}
|
|
337
|
-
if (!this.
|
|
337
|
+
if (!this.B || ((_a = this.b) == null ? void 0 : _a.length))
|
|
338
338
|
track(this);
|
|
339
|
-
newFlags |= this.
|
|
340
|
-
if (this.
|
|
341
|
-
throw this.
|
|
339
|
+
newFlags |= this.f & ~currentMask;
|
|
340
|
+
if (this.f & ERROR_BIT) {
|
|
341
|
+
throw this.G;
|
|
342
342
|
} else {
|
|
343
|
-
return this.
|
|
343
|
+
return this.g;
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
/**
|
|
@@ -348,7 +348,7 @@ var Computation = class extends Owner {
|
|
|
348
348
|
* Automatically re-executes the surrounding computation when the value changes
|
|
349
349
|
*/
|
|
350
350
|
read() {
|
|
351
|
-
return this.
|
|
351
|
+
return this.W();
|
|
352
352
|
}
|
|
353
353
|
/**
|
|
354
354
|
* Return the current value of this computation
|
|
@@ -358,15 +358,15 @@ var Computation = class extends Owner {
|
|
|
358
358
|
* before continuing
|
|
359
359
|
*/
|
|
360
360
|
wait() {
|
|
361
|
-
if (this.
|
|
361
|
+
if (this.B && this.f & ERROR_BIT && this.y <= getClock()) {
|
|
362
362
|
update(this);
|
|
363
363
|
}
|
|
364
|
-
if ((notStale || this.
|
|
364
|
+
if ((notStale || this.f & UNINITIALIZED_BIT) && this.loading()) {
|
|
365
365
|
throw new NotReadyError();
|
|
366
366
|
}
|
|
367
367
|
if (staleCheck && this.loading())
|
|
368
|
-
staleCheck.
|
|
369
|
-
return this.
|
|
368
|
+
staleCheck.g = true;
|
|
369
|
+
return this.W();
|
|
370
370
|
}
|
|
371
371
|
/**
|
|
372
372
|
* Return true if the computation is the value is dependent on an unresolved promise
|
|
@@ -376,44 +376,44 @@ var Computation = class extends Owner {
|
|
|
376
376
|
* loading state changes
|
|
377
377
|
*/
|
|
378
378
|
loading() {
|
|
379
|
-
if (this.
|
|
380
|
-
this.
|
|
379
|
+
if (this.Q === null) {
|
|
380
|
+
this.Q = loadingState(this);
|
|
381
381
|
}
|
|
382
|
-
return this.
|
|
382
|
+
return this.Q.read();
|
|
383
383
|
}
|
|
384
384
|
/** Update the computation with a new value. */
|
|
385
385
|
write(value, flags = 0, raw = false) {
|
|
386
|
-
const newValue = !raw && typeof value === "function" ? value(this.
|
|
387
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.
|
|
386
|
+
const newValue = !raw && typeof value === "function" ? value(this.g) : value;
|
|
387
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.f & UNINITIALIZED_BIT) || this.O === false || !this.O(this.g, newValue));
|
|
388
388
|
if (valueChanged) {
|
|
389
|
-
this.
|
|
390
|
-
this.
|
|
391
|
-
}
|
|
392
|
-
const changedFlagsMask = this.
|
|
393
|
-
this.
|
|
394
|
-
this.
|
|
395
|
-
if (this.
|
|
396
|
-
for (let i = 0; i < this.
|
|
389
|
+
this.g = newValue;
|
|
390
|
+
this.G = void 0;
|
|
391
|
+
}
|
|
392
|
+
const changedFlagsMask = this.f ^ flags, changedFlags = changedFlagsMask & flags;
|
|
393
|
+
this.f = flags;
|
|
394
|
+
this.y = getClock() + 1;
|
|
395
|
+
if (this.e) {
|
|
396
|
+
for (let i = 0; i < this.e.length; i++) {
|
|
397
397
|
if (valueChanged) {
|
|
398
|
-
this.
|
|
398
|
+
this.e[i].q(STATE_DIRTY);
|
|
399
399
|
} else if (changedFlagsMask) {
|
|
400
|
-
this.
|
|
400
|
+
this.e[i].X(changedFlagsMask, changedFlags);
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
|
-
return this.
|
|
404
|
+
return this.g;
|
|
405
405
|
}
|
|
406
406
|
/**
|
|
407
407
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
408
408
|
*/
|
|
409
409
|
q(state, skipQueue) {
|
|
410
|
-
if (this.a >= state && !this.
|
|
410
|
+
if (this.a >= state && !this.K)
|
|
411
411
|
return;
|
|
412
|
-
this.
|
|
412
|
+
this.K = !!skipQueue;
|
|
413
413
|
this.a = state;
|
|
414
|
-
if (this.
|
|
415
|
-
for (let i = 0; i < this.
|
|
416
|
-
this.
|
|
414
|
+
if (this.e) {
|
|
415
|
+
for (let i = 0; i < this.e.length; i++) {
|
|
416
|
+
this.e[i].q(STATE_CHECK, skipQueue);
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
419
|
}
|
|
@@ -423,31 +423,31 @@ var Computation = class extends Owner {
|
|
|
423
423
|
* @param mask A bitmask for which flag(s) were changed.
|
|
424
424
|
* @param newFlags The source's new flags, masked to just the changed ones.
|
|
425
425
|
*/
|
|
426
|
-
|
|
426
|
+
X(mask, newFlags2) {
|
|
427
427
|
if (this.a >= STATE_DIRTY)
|
|
428
428
|
return;
|
|
429
|
-
if (mask & this.
|
|
429
|
+
if (mask & this.P) {
|
|
430
430
|
this.q(STATE_DIRTY);
|
|
431
431
|
return;
|
|
432
432
|
}
|
|
433
433
|
if (this.a >= STATE_CHECK)
|
|
434
434
|
return;
|
|
435
|
-
const prevFlags = this.
|
|
435
|
+
const prevFlags = this.f & mask;
|
|
436
436
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
437
437
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
438
438
|
this.q(STATE_CHECK);
|
|
439
439
|
} else {
|
|
440
|
-
this.
|
|
441
|
-
if (this.
|
|
442
|
-
for (let i = 0; i < this.
|
|
443
|
-
this.
|
|
440
|
+
this.f ^= deltaFlags;
|
|
441
|
+
if (this.e) {
|
|
442
|
+
for (let i = 0; i < this.e.length; i++) {
|
|
443
|
+
this.e[i].X(mask, newFlags2);
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
|
-
|
|
449
|
-
this.
|
|
450
|
-
this.write(UNCHANGED, this.
|
|
448
|
+
H(error) {
|
|
449
|
+
this.G = error;
|
|
450
|
+
this.write(UNCHANGED, this.f & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
451
451
|
}
|
|
452
452
|
/**
|
|
453
453
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -456,7 +456,7 @@ var Computation = class extends Owner {
|
|
|
456
456
|
*
|
|
457
457
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
458
458
|
*/
|
|
459
|
-
|
|
459
|
+
z() {
|
|
460
460
|
if (this.a === STATE_DISPOSED) {
|
|
461
461
|
throw new Error("Tried to read a disposed computation");
|
|
462
462
|
}
|
|
@@ -466,8 +466,8 @@ var Computation = class extends Owner {
|
|
|
466
466
|
let observerFlags = 0;
|
|
467
467
|
if (this.a === STATE_CHECK) {
|
|
468
468
|
for (let i = 0; i < this.b.length; i++) {
|
|
469
|
-
this.b[i].
|
|
470
|
-
observerFlags |= this.b[i].
|
|
469
|
+
this.b[i].z();
|
|
470
|
+
observerFlags |= this.b[i].f;
|
|
471
471
|
if (this.a === STATE_DIRTY) {
|
|
472
472
|
break;
|
|
473
473
|
}
|
|
@@ -483,27 +483,27 @@ var Computation = class extends Owner {
|
|
|
483
483
|
/**
|
|
484
484
|
* Remove ourselves from the owner graph and the computation graph
|
|
485
485
|
*/
|
|
486
|
-
|
|
486
|
+
A() {
|
|
487
487
|
if (this.a === STATE_DISPOSED)
|
|
488
488
|
return;
|
|
489
489
|
if (this.b)
|
|
490
490
|
removeSourceObservers(this, 0);
|
|
491
|
-
super.
|
|
491
|
+
super.A();
|
|
492
492
|
}
|
|
493
493
|
};
|
|
494
494
|
function loadingState(node) {
|
|
495
|
-
const prevOwner = setOwner(node.
|
|
495
|
+
const prevOwner = setOwner(node.t);
|
|
496
496
|
const options = void 0;
|
|
497
497
|
const computation = new Computation(
|
|
498
498
|
void 0,
|
|
499
499
|
() => {
|
|
500
500
|
track(node);
|
|
501
|
-
node.
|
|
502
|
-
return !!(node.
|
|
501
|
+
node.z();
|
|
502
|
+
return !!(node.f & LOADING_BIT);
|
|
503
503
|
},
|
|
504
504
|
options
|
|
505
505
|
);
|
|
506
|
-
computation.
|
|
506
|
+
computation.P = ERROR_BIT | LOADING_BIT;
|
|
507
507
|
setOwner(prevOwner);
|
|
508
508
|
return computation;
|
|
509
509
|
}
|
|
@@ -517,7 +517,7 @@ function track(computation) {
|
|
|
517
517
|
newSources.push(computation);
|
|
518
518
|
}
|
|
519
519
|
if (updateCheck) {
|
|
520
|
-
updateCheck.
|
|
520
|
+
updateCheck.g = computation.y > currentObserver.y;
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
523
|
}
|
|
@@ -529,13 +529,13 @@ function update(node) {
|
|
|
529
529
|
try {
|
|
530
530
|
node.dispose(false);
|
|
531
531
|
node.emptyDisposal();
|
|
532
|
-
const result = compute(node, node.
|
|
532
|
+
const result = compute(node, node.B, node);
|
|
533
533
|
node.write(result, newFlags, true);
|
|
534
534
|
} catch (error) {
|
|
535
535
|
if (error instanceof NotReadyError) {
|
|
536
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.
|
|
536
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.f & UNINITIALIZED_BIT);
|
|
537
537
|
} else {
|
|
538
|
-
node.
|
|
538
|
+
node.H(error);
|
|
539
539
|
}
|
|
540
540
|
} finally {
|
|
541
541
|
if (newSources) {
|
|
@@ -552,10 +552,10 @@ function update(node) {
|
|
|
552
552
|
let source;
|
|
553
553
|
for (let i = newSourcesIndex; i < node.b.length; i++) {
|
|
554
554
|
source = node.b[i];
|
|
555
|
-
if (!source.
|
|
556
|
-
source.
|
|
555
|
+
if (!source.e)
|
|
556
|
+
source.e = [node];
|
|
557
557
|
else
|
|
558
|
-
source.
|
|
558
|
+
source.e.push(node);
|
|
559
559
|
}
|
|
560
560
|
} else if (node.b && newSourcesIndex < node.b.length) {
|
|
561
561
|
removeSourceObservers(node, newSourcesIndex);
|
|
@@ -564,7 +564,7 @@ function update(node) {
|
|
|
564
564
|
newSources = prevSources;
|
|
565
565
|
newSourcesIndex = prevSourcesIndex;
|
|
566
566
|
newFlags = prevFlags;
|
|
567
|
-
node.
|
|
567
|
+
node.y = getClock() + 1;
|
|
568
568
|
node.a = STATE_CLEAN;
|
|
569
569
|
}
|
|
570
570
|
}
|
|
@@ -574,12 +574,12 @@ function removeSourceObservers(node, index) {
|
|
|
574
574
|
let swap;
|
|
575
575
|
for (let i = index; i < node.b.length; i++) {
|
|
576
576
|
source = node.b[i];
|
|
577
|
-
if (source.
|
|
578
|
-
swap = source.
|
|
579
|
-
source.
|
|
580
|
-
source.
|
|
581
|
-
if (!source.
|
|
582
|
-
(_a = source.
|
|
577
|
+
if (source.e) {
|
|
578
|
+
swap = source.e.indexOf(node);
|
|
579
|
+
source.e[swap] = source.e[source.e.length - 1];
|
|
580
|
+
source.e.pop();
|
|
581
|
+
if (!source.e.length)
|
|
582
|
+
(_a = source.V) == null ? void 0 : _a.call(source);
|
|
583
583
|
}
|
|
584
584
|
}
|
|
585
585
|
}
|
|
@@ -593,10 +593,10 @@ function untrack(fn) {
|
|
|
593
593
|
}
|
|
594
594
|
function hasUpdated(fn) {
|
|
595
595
|
const current = updateCheck;
|
|
596
|
-
updateCheck = {
|
|
596
|
+
updateCheck = { g: false };
|
|
597
597
|
try {
|
|
598
598
|
fn();
|
|
599
|
-
return updateCheck.
|
|
599
|
+
return updateCheck.g;
|
|
600
600
|
} finally {
|
|
601
601
|
updateCheck = current;
|
|
602
602
|
}
|
|
@@ -604,10 +604,10 @@ function hasUpdated(fn) {
|
|
|
604
604
|
function isPending(fn, loadingValue) {
|
|
605
605
|
const argLength = arguments.length;
|
|
606
606
|
const current = staleCheck;
|
|
607
|
-
staleCheck = {
|
|
607
|
+
staleCheck = { g: false };
|
|
608
608
|
try {
|
|
609
609
|
latest(fn);
|
|
610
|
-
return staleCheck.
|
|
610
|
+
return staleCheck.g;
|
|
611
611
|
} catch (err) {
|
|
612
612
|
if (!(err instanceof NotReadyError))
|
|
613
613
|
return false;
|
|
@@ -654,10 +654,10 @@ function runWithObserver(observer, run) {
|
|
|
654
654
|
if (error instanceof NotReadyError) {
|
|
655
655
|
observer.write(
|
|
656
656
|
UNCHANGED,
|
|
657
|
-
newFlags | LOADING_BIT | observer.
|
|
657
|
+
newFlags | LOADING_BIT | observer.f & UNINITIALIZED_BIT
|
|
658
658
|
);
|
|
659
659
|
} else {
|
|
660
|
-
observer.
|
|
660
|
+
observer.H(error);
|
|
661
661
|
}
|
|
662
662
|
} finally {
|
|
663
663
|
if (newSources) {
|
|
@@ -672,10 +672,10 @@ function runWithObserver(observer, run) {
|
|
|
672
672
|
let source;
|
|
673
673
|
for (let i = newSourcesIndex; i < observer.b.length; i++) {
|
|
674
674
|
source = observer.b[i];
|
|
675
|
-
if (!source.
|
|
676
|
-
source.
|
|
675
|
+
if (!source.e)
|
|
676
|
+
source.e = [observer];
|
|
677
677
|
else
|
|
678
|
-
source.
|
|
678
|
+
source.e.push(observer);
|
|
679
679
|
}
|
|
680
680
|
}
|
|
681
681
|
newSources = prevSources;
|
|
@@ -686,10 +686,10 @@ function runWithObserver(observer, run) {
|
|
|
686
686
|
function compute(owner, fn, observer) {
|
|
687
687
|
const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
|
|
688
688
|
currentObserver = observer;
|
|
689
|
-
currentMask = (observer == null ? void 0 : observer.
|
|
689
|
+
currentMask = (observer == null ? void 0 : observer.P) ?? DEFAULT_FLAGS;
|
|
690
690
|
notStale = true;
|
|
691
691
|
try {
|
|
692
|
-
return fn(observer ? observer.
|
|
692
|
+
return fn(observer ? observer.g : void 0);
|
|
693
693
|
} finally {
|
|
694
694
|
setOwner(prevOwner);
|
|
695
695
|
currentObserver = prevObserver;
|
|
@@ -769,84 +769,84 @@ function createBoundary(fn, queue) {
|
|
|
769
769
|
|
|
770
770
|
// src/core/effect.ts
|
|
771
771
|
var Effect = class extends Computation {
|
|
772
|
-
K;
|
|
773
772
|
L;
|
|
774
|
-
B;
|
|
775
|
-
Q = false;
|
|
776
773
|
M;
|
|
777
|
-
|
|
774
|
+
C;
|
|
775
|
+
R = false;
|
|
776
|
+
N;
|
|
777
|
+
w;
|
|
778
778
|
constructor(initialValue, compute2, effect, error, options) {
|
|
779
779
|
super(initialValue, compute2, options);
|
|
780
|
-
this.
|
|
781
|
-
this.
|
|
782
|
-
this.
|
|
783
|
-
this.
|
|
784
|
-
if (this.
|
|
785
|
-
this.
|
|
780
|
+
this.L = effect;
|
|
781
|
+
this.M = error;
|
|
782
|
+
this.N = initialValue;
|
|
783
|
+
this.w = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
|
|
784
|
+
if (this.w === EFFECT_RENDER) {
|
|
785
|
+
this.B = (p) => getClock() > this.h.created && !(this.f & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
786
786
|
}
|
|
787
|
-
this.
|
|
788
|
-
!(options == null ? void 0 : options.defer) && (this.
|
|
787
|
+
this.z();
|
|
788
|
+
!(options == null ? void 0 : options.defer) && (this.w === EFFECT_USER ? this.h.enqueue(this.w, this) : this.U());
|
|
789
789
|
}
|
|
790
790
|
write(value, flags = 0) {
|
|
791
791
|
var _a, _b;
|
|
792
792
|
if (this.a == STATE_DIRTY) {
|
|
793
|
-
const currentFlags = this.
|
|
794
|
-
this.
|
|
795
|
-
if (this.
|
|
796
|
-
(_b = (_a = this.h).
|
|
793
|
+
const currentFlags = this.f;
|
|
794
|
+
this.f = flags;
|
|
795
|
+
if (this.w === EFFECT_RENDER && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
|
|
796
|
+
(_b = (_a = this.h).S) == null ? void 0 : _b.call(_a, this);
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
799
|
if (value === UNCHANGED)
|
|
800
|
-
return this.
|
|
801
|
-
this.
|
|
802
|
-
this.
|
|
800
|
+
return this.g;
|
|
801
|
+
this.g = value;
|
|
802
|
+
this.R = true;
|
|
803
803
|
return value;
|
|
804
804
|
}
|
|
805
805
|
q(state, skipQueue) {
|
|
806
806
|
if (this.a >= state || skipQueue)
|
|
807
807
|
return;
|
|
808
808
|
if (this.a === STATE_CLEAN)
|
|
809
|
-
this.h.enqueue(this.
|
|
809
|
+
this.h.enqueue(this.w, this);
|
|
810
810
|
this.a = state;
|
|
811
811
|
}
|
|
812
|
-
|
|
812
|
+
H(error) {
|
|
813
813
|
var _a, _b, _c;
|
|
814
|
-
(_a = this.
|
|
815
|
-
if (this.
|
|
816
|
-
(_c = (_b = this.h).
|
|
814
|
+
(_a = this.C) == null ? void 0 : _a.call(this);
|
|
815
|
+
if (this.f & LOADING_BIT) {
|
|
816
|
+
(_c = (_b = this.h).S) == null ? void 0 : _c.call(_b, this);
|
|
817
817
|
}
|
|
818
|
-
this.
|
|
819
|
-
if (this.
|
|
818
|
+
this.f = ERROR_BIT;
|
|
819
|
+
if (this.w === EFFECT_USER) {
|
|
820
820
|
try {
|
|
821
|
-
return this.
|
|
821
|
+
return this.M ? this.C = this.M(error) : console.error(new EffectError(this.L, error));
|
|
822
822
|
} catch (e) {
|
|
823
823
|
error = e;
|
|
824
824
|
}
|
|
825
825
|
}
|
|
826
826
|
this.handleError(error);
|
|
827
827
|
}
|
|
828
|
-
|
|
828
|
+
A() {
|
|
829
829
|
var _a;
|
|
830
830
|
if (this.a === STATE_DISPOSED)
|
|
831
831
|
return;
|
|
832
|
-
this.K = void 0;
|
|
833
|
-
this.M = void 0;
|
|
834
832
|
this.L = void 0;
|
|
835
|
-
|
|
836
|
-
this.
|
|
837
|
-
|
|
833
|
+
this.N = void 0;
|
|
834
|
+
this.M = void 0;
|
|
835
|
+
(_a = this.C) == null ? void 0 : _a.call(this);
|
|
836
|
+
this.C = void 0;
|
|
837
|
+
super.A();
|
|
838
838
|
}
|
|
839
|
-
|
|
839
|
+
U() {
|
|
840
840
|
var _a;
|
|
841
|
-
if (this.
|
|
842
|
-
(_a = this.
|
|
841
|
+
if (this.R && this.a !== STATE_DISPOSED) {
|
|
842
|
+
(_a = this.C) == null ? void 0 : _a.call(this);
|
|
843
843
|
try {
|
|
844
|
-
this.
|
|
844
|
+
this.C = this.L(this.g, this.N);
|
|
845
845
|
} catch (e) {
|
|
846
846
|
this.handleError(e);
|
|
847
847
|
} finally {
|
|
848
|
-
this.
|
|
849
|
-
this.
|
|
848
|
+
this.N = this.g;
|
|
849
|
+
this.R = false;
|
|
850
850
|
}
|
|
851
851
|
}
|
|
852
852
|
}
|
|
@@ -854,10 +854,10 @@ var Effect = class extends Computation {
|
|
|
854
854
|
var EagerComputation = class extends Computation {
|
|
855
855
|
constructor(initialValue, compute2, options) {
|
|
856
856
|
super(initialValue, compute2, options);
|
|
857
|
-
!(options == null ? void 0 : options.defer) && this.
|
|
857
|
+
!(options == null ? void 0 : options.defer) && this.z();
|
|
858
858
|
}
|
|
859
859
|
q(state, skipQueue) {
|
|
860
|
-
if (this.a >= state && !this.
|
|
860
|
+
if (this.a >= state && !this.K)
|
|
861
861
|
return;
|
|
862
862
|
if (this.a === STATE_CLEAN && !skipQueue)
|
|
863
863
|
this.h.enqueue(EFFECT_PURE, this);
|
|
@@ -869,7 +869,7 @@ var ProjectionComputation = class extends Computation {
|
|
|
869
869
|
super(null, compute2);
|
|
870
870
|
}
|
|
871
871
|
q(state, skipQueue) {
|
|
872
|
-
if (this.a >= state && !this.
|
|
872
|
+
if (this.a >= state && !this.K)
|
|
873
873
|
return;
|
|
874
874
|
if (this.a === STATE_CLEAN && !skipQueue)
|
|
875
875
|
this.h.enqueue(EFFECT_PURE, this);
|
|
@@ -879,26 +879,26 @@ var ProjectionComputation = class extends Computation {
|
|
|
879
879
|
|
|
880
880
|
// src/core/suspense.ts
|
|
881
881
|
var SuspenseQueue = class extends Queue {
|
|
882
|
-
|
|
882
|
+
c = /* @__PURE__ */ new Set();
|
|
883
883
|
o = false;
|
|
884
|
-
|
|
884
|
+
T = new Computation(false, null);
|
|
885
885
|
run(type) {
|
|
886
886
|
if (type && this.o)
|
|
887
887
|
return;
|
|
888
888
|
return super.run(type);
|
|
889
889
|
}
|
|
890
|
-
|
|
891
|
-
if (node.
|
|
892
|
-
this.
|
|
890
|
+
S(node) {
|
|
891
|
+
if (node.f & LOADING_BIT) {
|
|
892
|
+
this.c.add(node);
|
|
893
893
|
if (!this.o) {
|
|
894
894
|
this.o = true;
|
|
895
|
-
this.
|
|
895
|
+
this.T.write(true);
|
|
896
896
|
}
|
|
897
897
|
} else {
|
|
898
|
-
this.
|
|
899
|
-
if (this.
|
|
898
|
+
this.c.delete(node);
|
|
899
|
+
if (this.c.size === 0) {
|
|
900
900
|
this.o = false;
|
|
901
|
-
this.
|
|
901
|
+
this.T.write(false);
|
|
902
902
|
}
|
|
903
903
|
}
|
|
904
904
|
}
|
|
@@ -906,13 +906,13 @@ var SuspenseQueue = class extends Queue {
|
|
|
906
906
|
var LiveComputation = class extends EagerComputation {
|
|
907
907
|
write(value, flags = 0) {
|
|
908
908
|
var _a, _b;
|
|
909
|
-
const currentFlags = this.
|
|
909
|
+
const currentFlags = this.f;
|
|
910
910
|
const dirty = this.a === STATE_DIRTY;
|
|
911
911
|
super.write(value, flags);
|
|
912
912
|
if (dirty && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
|
|
913
|
-
(_b = (_a = this.h).
|
|
913
|
+
(_b = (_a = this.h).S) == null ? void 0 : _b.call(_a, this);
|
|
914
914
|
}
|
|
915
|
-
return this.
|
|
915
|
+
return this.g;
|
|
916
916
|
}
|
|
917
917
|
};
|
|
918
918
|
function createSuspense(fn, fallback) {
|
|
@@ -921,7 +921,7 @@ function createSuspense(fn, fallback) {
|
|
|
921
921
|
const child = new Computation(null, fn);
|
|
922
922
|
return new LiveComputation(null, () => flatten(child.wait()));
|
|
923
923
|
}, queue);
|
|
924
|
-
const equality = new Computation(null, () => queue.
|
|
924
|
+
const equality = new Computation(null, () => queue.T.read() || queue.o);
|
|
925
925
|
const comp = new Computation(null, () => equality.read() ? fallback() : tree.read());
|
|
926
926
|
return comp.read.bind(comp);
|
|
927
927
|
}
|
|
@@ -953,10 +953,10 @@ function createMemo(compute2, value, options) {
|
|
|
953
953
|
var _a, _b, _c;
|
|
954
954
|
if (node) {
|
|
955
955
|
resolvedValue = node.wait();
|
|
956
|
-
if (!((_a = node.b) == null ? void 0 : _a.length) && ((_b = node.n) == null ? void 0 : _b.
|
|
956
|
+
if (!((_a = node.b) == null ? void 0 : _a.length) && ((_b = node.n) == null ? void 0 : _b.t) !== node) {
|
|
957
957
|
node.dispose();
|
|
958
958
|
node = void 0;
|
|
959
|
-
} else if (!node.
|
|
959
|
+
} else if (!node.t && !((_c = node.e) == null ? void 0 : _c.length)) {
|
|
960
960
|
node.dispose();
|
|
961
961
|
node.a = STATE_DIRTY;
|
|
962
962
|
}
|
|
@@ -968,10 +968,10 @@ function createAsync(compute2, value, options) {
|
|
|
968
968
|
let uninitialized = value === void 0;
|
|
969
969
|
const lhs = new EagerComputation(
|
|
970
970
|
{
|
|
971
|
-
|
|
971
|
+
g: value
|
|
972
972
|
},
|
|
973
973
|
(p) => {
|
|
974
|
-
const value2 = p == null ? void 0 : p.
|
|
974
|
+
const value2 = p == null ? void 0 : p.g;
|
|
975
975
|
const source = compute2(value2);
|
|
976
976
|
const isPromise = source instanceof Promise;
|
|
977
977
|
const iterator = source[Symbol.asyncIterator];
|
|
@@ -980,13 +980,13 @@ function createAsync(compute2, value, options) {
|
|
|
980
980
|
wait() {
|
|
981
981
|
return source;
|
|
982
982
|
},
|
|
983
|
-
|
|
983
|
+
g: source
|
|
984
984
|
};
|
|
985
985
|
}
|
|
986
986
|
const signal = new Computation(value2, null, options);
|
|
987
987
|
const w = signal.wait;
|
|
988
988
|
signal.wait = function() {
|
|
989
|
-
if (signal.
|
|
989
|
+
if (signal.f & ERROR_BIT && signal.y <= getClock()) {
|
|
990
990
|
lhs.q(STATE_DIRTY);
|
|
991
991
|
throw new NotReadyError();
|
|
992
992
|
}
|
|
@@ -1001,7 +1001,7 @@ function createAsync(compute2, value, options) {
|
|
|
1001
1001
|
},
|
|
1002
1002
|
(error) => {
|
|
1003
1003
|
uninitialized = true;
|
|
1004
|
-
signal.
|
|
1004
|
+
signal.H(error);
|
|
1005
1005
|
}
|
|
1006
1006
|
);
|
|
1007
1007
|
} else {
|
|
@@ -1064,7 +1064,7 @@ function createErrorBoundary(fn, fallback) {
|
|
|
1064
1064
|
);
|
|
1065
1065
|
nodes.add(node);
|
|
1066
1066
|
if (nodes.size === 1)
|
|
1067
|
-
error.write({
|
|
1067
|
+
error.write({ G: err });
|
|
1068
1068
|
}
|
|
1069
1069
|
owner.m = owner.m ? [handler, ...owner.m] : [handler];
|
|
1070
1070
|
const guarded = compute(
|
|
@@ -1072,7 +1072,7 @@ function createErrorBoundary(fn, fallback) {
|
|
|
1072
1072
|
() => {
|
|
1073
1073
|
const c = new Computation(void 0, fn);
|
|
1074
1074
|
const f = new EagerComputation(void 0, () => flatten(c.read()), { defer: true });
|
|
1075
|
-
f.
|
|
1075
|
+
f.H = function(error2) {
|
|
1076
1076
|
this.handleError(error2);
|
|
1077
1077
|
};
|
|
1078
1078
|
return f;
|
|
@@ -1085,12 +1085,12 @@ function createErrorBoundary(fn, fallback) {
|
|
|
1085
1085
|
if (!error.read())
|
|
1086
1086
|
return resolved;
|
|
1087
1087
|
}
|
|
1088
|
-
return fallback(error.read().
|
|
1088
|
+
return fallback(error.read().G, () => {
|
|
1089
1089
|
var _a;
|
|
1090
1090
|
incrementClock();
|
|
1091
1091
|
for (let node of nodes) {
|
|
1092
1092
|
node.a = STATE_DIRTY;
|
|
1093
|
-
(_a = node.h) == null ? void 0 : _a.enqueue(node.
|
|
1093
|
+
(_a = node.h) == null ? void 0 : _a.enqueue(node.w, node);
|
|
1094
1094
|
}
|
|
1095
1095
|
});
|
|
1096
1096
|
});
|
|
@@ -1115,12 +1115,15 @@ function resolve(fn) {
|
|
|
1115
1115
|
|
|
1116
1116
|
// src/store/projection.ts
|
|
1117
1117
|
function createProjection(fn, initialValue = {}) {
|
|
1118
|
-
const [store
|
|
1118
|
+
const [store] = createStore(fn, initialValue);
|
|
1119
|
+
return store;
|
|
1120
|
+
}
|
|
1121
|
+
function wrapProjection(fn, store, setStore) {
|
|
1119
1122
|
const node = new ProjectionComputation(() => {
|
|
1120
1123
|
setStore(fn);
|
|
1121
1124
|
});
|
|
1122
1125
|
const wrapped = /* @__PURE__ */ new WeakMap();
|
|
1123
|
-
return wrap(store, node, wrapped);
|
|
1126
|
+
return [wrap(store, node, wrapped), setStore];
|
|
1124
1127
|
}
|
|
1125
1128
|
function wrap(source, node, wrapped) {
|
|
1126
1129
|
if (wrapped.has(source))
|
|
@@ -1258,7 +1261,7 @@ var proxyTraps = {
|
|
|
1258
1261
|
return desc.get.call(receiver);
|
|
1259
1262
|
}
|
|
1260
1263
|
if (Writing.has(storeValue)) {
|
|
1261
|
-
const value2 = tracked ? tracked.
|
|
1264
|
+
const value2 = tracked ? tracked.g : storeValue[property];
|
|
1262
1265
|
return isWrappable(value2) ? (Writing.add(value2[$RAW] || value2), wrap2(value2)) : value2;
|
|
1263
1266
|
}
|
|
1264
1267
|
let value = tracked ? nodes[property].read() : storeValue[property];
|
|
@@ -1319,10 +1322,8 @@ function setProperty(state, property, value, deleting = false) {
|
|
|
1319
1322
|
}
|
|
1320
1323
|
function createStore(first, second) {
|
|
1321
1324
|
const derived = typeof first === "function", store = derived ? second : first;
|
|
1322
|
-
if (derived)
|
|
1323
|
-
return createProjection(first, store);
|
|
1324
1325
|
const unwrappedStore = unwrap(store, false);
|
|
1325
|
-
|
|
1326
|
+
let wrappedStore = wrap2(unwrappedStore);
|
|
1326
1327
|
const setStore = (fn) => {
|
|
1327
1328
|
try {
|
|
1328
1329
|
Writing.add(unwrappedStore);
|
|
@@ -1331,6 +1332,8 @@ function createStore(first, second) {
|
|
|
1331
1332
|
Writing.clear();
|
|
1332
1333
|
}
|
|
1333
1334
|
};
|
|
1335
|
+
if (derived)
|
|
1336
|
+
return wrapProjection(first, wrappedStore, setStore);
|
|
1334
1337
|
return [wrappedStore, setStore];
|
|
1335
1338
|
}
|
|
1336
1339
|
|
|
@@ -1599,73 +1602,73 @@ function omit(props, ...keys) {
|
|
|
1599
1602
|
function mapArray(list, map, options) {
|
|
1600
1603
|
const keyFn = typeof (options == null ? void 0 : options.keyed) === "function" ? options.keyed : void 0;
|
|
1601
1604
|
return updateKeyedMap.bind({
|
|
1602
|
-
|
|
1605
|
+
I: new Owner(),
|
|
1603
1606
|
i: 0,
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1607
|
+
Y: list,
|
|
1608
|
+
x: [],
|
|
1609
|
+
D: map,
|
|
1610
|
+
d: [],
|
|
1611
|
+
c: [],
|
|
1612
|
+
E: keyFn,
|
|
1610
1613
|
j: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
1611
1614
|
k: map.length > 1 ? [] : void 0,
|
|
1612
1615
|
o: options == null ? void 0 : options.fallback
|
|
1613
1616
|
});
|
|
1614
1617
|
}
|
|
1615
1618
|
function updateKeyedMap() {
|
|
1616
|
-
const newItems = this.
|
|
1619
|
+
const newItems = this.Y() || [], newLen = newItems.length;
|
|
1617
1620
|
newItems[$TRACK];
|
|
1618
|
-
runWithOwner(this.
|
|
1621
|
+
runWithOwner(this.I, () => {
|
|
1619
1622
|
let i, j, mapper = this.j ? () => {
|
|
1620
1623
|
this.j[j] = new Computation(newItems[j], null);
|
|
1621
1624
|
this.k && (this.k[j] = new Computation(j, null));
|
|
1622
|
-
return this.
|
|
1625
|
+
return this.D(
|
|
1623
1626
|
Computation.prototype.read.bind(this.j[j]),
|
|
1624
1627
|
this.k ? Computation.prototype.read.bind(this.k[j]) : void 0
|
|
1625
1628
|
);
|
|
1626
1629
|
} : this.k ? () => {
|
|
1627
1630
|
const item = newItems[j];
|
|
1628
1631
|
this.k[j] = new Computation(j, null);
|
|
1629
|
-
return this.
|
|
1632
|
+
return this.D(() => item, Computation.prototype.read.bind(this.k[j]));
|
|
1630
1633
|
} : () => {
|
|
1631
1634
|
const item = newItems[j];
|
|
1632
|
-
return this.
|
|
1635
|
+
return this.D(() => item);
|
|
1633
1636
|
};
|
|
1634
1637
|
if (newLen === 0) {
|
|
1635
1638
|
if (this.i !== 0) {
|
|
1636
|
-
this.
|
|
1637
|
-
this.
|
|
1638
|
-
this.
|
|
1639
|
-
this.
|
|
1639
|
+
this.I.dispose(false);
|
|
1640
|
+
this.c = [];
|
|
1641
|
+
this.x = [];
|
|
1642
|
+
this.d = [];
|
|
1640
1643
|
this.i = 0;
|
|
1641
1644
|
this.j && (this.j = []);
|
|
1642
1645
|
this.k && (this.k = []);
|
|
1643
1646
|
}
|
|
1644
|
-
if (this.o && !this.
|
|
1645
|
-
this.
|
|
1646
|
-
this.
|
|
1647
|
+
if (this.o && !this.d[0]) {
|
|
1648
|
+
this.d[0] = compute(
|
|
1649
|
+
this.c[0] = new Owner(),
|
|
1647
1650
|
this.o,
|
|
1648
1651
|
null
|
|
1649
1652
|
);
|
|
1650
1653
|
}
|
|
1651
1654
|
} else if (this.i === 0) {
|
|
1652
|
-
if (this.
|
|
1653
|
-
this.
|
|
1654
|
-
this.
|
|
1655
|
+
if (this.c[0])
|
|
1656
|
+
this.c[0].dispose();
|
|
1657
|
+
this.d = new Array(newLen);
|
|
1655
1658
|
for (j = 0; j < newLen; j++) {
|
|
1656
|
-
this.
|
|
1657
|
-
this.
|
|
1659
|
+
this.x[j] = newItems[j];
|
|
1660
|
+
this.d[j] = compute(this.c[j] = new Owner(), mapper, null);
|
|
1658
1661
|
}
|
|
1659
1662
|
this.i = newLen;
|
|
1660
1663
|
} else {
|
|
1661
1664
|
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;
|
|
1662
|
-
for (start = 0, end = Math.min(this.i, newLen); start < end && (this.
|
|
1665
|
+
for (start = 0, end = Math.min(this.i, newLen); start < end && (this.x[start] === newItems[start] || this.j && compare(this.E, this.x[start], newItems[start])); start++) {
|
|
1663
1666
|
if (this.j)
|
|
1664
1667
|
this.j[start].write(newItems[start]);
|
|
1665
1668
|
}
|
|
1666
|
-
for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.
|
|
1667
|
-
temp[newEnd] = this.
|
|
1668
|
-
tempNodes[newEnd] = this.
|
|
1669
|
+
for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.x[end] === newItems[newEnd] || this.j && compare(this.E, this.x[end], newItems[newEnd])); end--, newEnd--) {
|
|
1670
|
+
temp[newEnd] = this.d[end];
|
|
1671
|
+
tempNodes[newEnd] = this.c[end];
|
|
1669
1672
|
tempRows && (tempRows[newEnd] = this.j[end]);
|
|
1670
1673
|
tempIndexes && (tempIndexes[newEnd] = this.k[end]);
|
|
1671
1674
|
}
|
|
@@ -1673,29 +1676,29 @@ function updateKeyedMap() {
|
|
|
1673
1676
|
newIndicesNext = new Array(newEnd + 1);
|
|
1674
1677
|
for (j = newEnd; j >= start; j--) {
|
|
1675
1678
|
item = newItems[j];
|
|
1676
|
-
key = this.
|
|
1679
|
+
key = this.E ? this.E(item) : item;
|
|
1677
1680
|
i = newIndices.get(key);
|
|
1678
1681
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
1679
1682
|
newIndices.set(key, j);
|
|
1680
1683
|
}
|
|
1681
1684
|
for (i = start; i <= end; i++) {
|
|
1682
|
-
item = this.
|
|
1683
|
-
key = this.
|
|
1685
|
+
item = this.x[i];
|
|
1686
|
+
key = this.E ? this.E(item) : item;
|
|
1684
1687
|
j = newIndices.get(key);
|
|
1685
1688
|
if (j !== void 0 && j !== -1) {
|
|
1686
|
-
temp[j] = this.
|
|
1687
|
-
tempNodes[j] = this.
|
|
1689
|
+
temp[j] = this.d[i];
|
|
1690
|
+
tempNodes[j] = this.c[i];
|
|
1688
1691
|
tempRows && (tempRows[j] = this.j[i]);
|
|
1689
1692
|
tempIndexes && (tempIndexes[j] = this.k[i]);
|
|
1690
1693
|
j = newIndicesNext[j];
|
|
1691
1694
|
newIndices.set(key, j);
|
|
1692
1695
|
} else
|
|
1693
|
-
this.
|
|
1696
|
+
this.c[i].dispose();
|
|
1694
1697
|
}
|
|
1695
1698
|
for (j = start; j < newLen; j++) {
|
|
1696
1699
|
if (j in temp) {
|
|
1697
|
-
this.
|
|
1698
|
-
this.
|
|
1700
|
+
this.d[j] = temp[j];
|
|
1701
|
+
this.c[j] = tempNodes[j];
|
|
1699
1702
|
if (tempRows) {
|
|
1700
1703
|
this.j[j] = tempRows[j];
|
|
1701
1704
|
this.j[j].write(newItems[j]);
|
|
@@ -1705,60 +1708,90 @@ function updateKeyedMap() {
|
|
|
1705
1708
|
this.k[j].write(j);
|
|
1706
1709
|
}
|
|
1707
1710
|
} else {
|
|
1708
|
-
this.
|
|
1711
|
+
this.d[j] = compute(this.c[j] = new Owner(), mapper, null);
|
|
1709
1712
|
}
|
|
1710
1713
|
}
|
|
1711
|
-
this.
|
|
1712
|
-
this.
|
|
1714
|
+
this.d = this.d.slice(0, this.i = newLen);
|
|
1715
|
+
this.x = newItems.slice(0);
|
|
1713
1716
|
}
|
|
1714
1717
|
});
|
|
1715
|
-
return this.
|
|
1718
|
+
return this.d;
|
|
1716
1719
|
}
|
|
1717
1720
|
function repeat(count, map, options) {
|
|
1718
1721
|
return updateRepeat.bind({
|
|
1719
|
-
|
|
1722
|
+
I: new Owner(),
|
|
1720
1723
|
i: 0,
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1724
|
+
r: 0,
|
|
1725
|
+
Z: count,
|
|
1726
|
+
D: map,
|
|
1727
|
+
c: [],
|
|
1728
|
+
d: [],
|
|
1729
|
+
_: options == null ? void 0 : options.from,
|
|
1725
1730
|
o: options == null ? void 0 : options.fallback
|
|
1726
1731
|
});
|
|
1727
1732
|
}
|
|
1728
1733
|
function updateRepeat() {
|
|
1729
|
-
|
|
1730
|
-
|
|
1734
|
+
var _a;
|
|
1735
|
+
const newLen = this.Z();
|
|
1736
|
+
const from = ((_a = this._) == null ? void 0 : _a.call(this)) || 0;
|
|
1737
|
+
runWithOwner(this.I, () => {
|
|
1731
1738
|
if (newLen === 0) {
|
|
1732
1739
|
if (this.i !== 0) {
|
|
1733
|
-
this.
|
|
1734
|
-
this.
|
|
1735
|
-
this.
|
|
1740
|
+
this.I.dispose(false);
|
|
1741
|
+
this.c = [];
|
|
1742
|
+
this.d = [];
|
|
1736
1743
|
this.i = 0;
|
|
1737
1744
|
}
|
|
1738
|
-
if (this.o && !this.
|
|
1739
|
-
this.
|
|
1740
|
-
this.
|
|
1745
|
+
if (this.o && !this.d[0]) {
|
|
1746
|
+
this.d[0] = compute(
|
|
1747
|
+
this.c[0] = new Owner(),
|
|
1741
1748
|
this.o,
|
|
1742
1749
|
null
|
|
1743
1750
|
);
|
|
1744
1751
|
}
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
const to = from + newLen;
|
|
1755
|
+
const prevTo = this.r + this.i;
|
|
1756
|
+
if (this.i === 0 && this.c[0])
|
|
1757
|
+
this.c[0].dispose();
|
|
1758
|
+
for (let i = to; i < prevTo; i++)
|
|
1759
|
+
this.c[i - this.r].dispose();
|
|
1760
|
+
if (this.r < from) {
|
|
1761
|
+
let i = this.r;
|
|
1762
|
+
while (i < from && i < this.i)
|
|
1763
|
+
this.c[i++].dispose();
|
|
1764
|
+
this.c.splice(0, from - this.r);
|
|
1765
|
+
this.d.splice(0, from - this.r);
|
|
1766
|
+
} else if (this.r > from) {
|
|
1767
|
+
let i = prevTo - this.r - 1;
|
|
1768
|
+
let difference = this.r - from;
|
|
1769
|
+
this.c.length = this.d.length = newLen;
|
|
1770
|
+
while (i >= difference) {
|
|
1771
|
+
this.c[i] = this.c[i - difference];
|
|
1772
|
+
this.d[i] = this.d[i - difference];
|
|
1773
|
+
i--;
|
|
1774
|
+
}
|
|
1775
|
+
for (let i2 = 0; i2 < difference; i2++) {
|
|
1776
|
+
this.d[i2] = compute(
|
|
1777
|
+
this.c[i2] = new Owner(),
|
|
1778
|
+
() => this.D(i2 + from),
|
|
1752
1779
|
null
|
|
1753
1780
|
);
|
|
1754
1781
|
}
|
|
1755
|
-
for (let i = newLen; i < this.i; i++)
|
|
1756
|
-
this.f[i].dispose();
|
|
1757
|
-
this.g = this.g.slice(0, newLen);
|
|
1758
|
-
this.i = newLen;
|
|
1759
1782
|
}
|
|
1783
|
+
for (let i = prevTo; i < to; i++) {
|
|
1784
|
+
this.d[i - from] = compute(
|
|
1785
|
+
this.c[i - from] = new Owner(),
|
|
1786
|
+
() => this.D(i),
|
|
1787
|
+
null
|
|
1788
|
+
);
|
|
1789
|
+
}
|
|
1790
|
+
this.d = this.d.slice(0, newLen);
|
|
1791
|
+
this.r = from;
|
|
1792
|
+
this.i = newLen;
|
|
1760
1793
|
});
|
|
1761
|
-
return this.
|
|
1794
|
+
return this.d;
|
|
1762
1795
|
}
|
|
1763
1796
|
function compare(key, a, b) {
|
|
1764
1797
|
return key ? key(a) === key(b) : true;
|