@solidjs/signals 0.0.8 → 0.0.9
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 +75 -45
- package/dist/node.cjs +283 -254
- package/dist/prod.js +281 -253
- package/dist/types/core/constants.d.ts +1 -2
- package/dist/types/core/core.d.ts +6 -9
- package/dist/types/core/effect.d.ts +7 -2
- package/dist/types/core/flags.d.ts +3 -0
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/node.cjs
CHANGED
|
@@ -26,8 +26,7 @@ var EffectError = class extends Error {
|
|
|
26
26
|
var STATE_CLEAN = 0;
|
|
27
27
|
var STATE_CHECK = 1;
|
|
28
28
|
var STATE_DIRTY = 2;
|
|
29
|
-
var
|
|
30
|
-
var STATE_DISPOSED = 4;
|
|
29
|
+
var STATE_DISPOSED = 3;
|
|
31
30
|
var EFFECT_PURE = 0;
|
|
32
31
|
var EFFECT_RENDER = 1;
|
|
33
32
|
var EFFECT_USER = 2;
|
|
@@ -114,7 +113,7 @@ var Owner = class {
|
|
|
114
113
|
l = null;
|
|
115
114
|
p = defaultContext;
|
|
116
115
|
m = null;
|
|
117
|
-
|
|
116
|
+
b = null;
|
|
118
117
|
constructor(signal = false) {
|
|
119
118
|
if (currentOwner && !signal)
|
|
120
119
|
currentOwner.append(this);
|
|
@@ -132,8 +131,8 @@ var Owner = class {
|
|
|
132
131
|
if (this.m) {
|
|
133
132
|
child.m = !child.m ? this.m : [...child.m, ...this.m];
|
|
134
133
|
}
|
|
135
|
-
if (this.
|
|
136
|
-
child.
|
|
134
|
+
if (this.b)
|
|
135
|
+
child.b = this.b;
|
|
137
136
|
}
|
|
138
137
|
dispose(self = true) {
|
|
139
138
|
if (this.a === STATE_DISPOSED)
|
|
@@ -141,19 +140,19 @@ var Owner = class {
|
|
|
141
140
|
let head = self ? this.s || this.r : this, current = this.n, next = null;
|
|
142
141
|
while (current && current.r === this) {
|
|
143
142
|
current.dispose(true);
|
|
144
|
-
current.
|
|
143
|
+
current.z();
|
|
145
144
|
next = current.n;
|
|
146
145
|
current.n = null;
|
|
147
146
|
current = next;
|
|
148
147
|
}
|
|
149
148
|
if (self)
|
|
150
|
-
this.
|
|
149
|
+
this.z();
|
|
151
150
|
if (current)
|
|
152
151
|
current.s = !self ? this : this.s;
|
|
153
152
|
if (head)
|
|
154
153
|
head.n = current;
|
|
155
154
|
}
|
|
156
|
-
|
|
155
|
+
z() {
|
|
157
156
|
if (this.s)
|
|
158
157
|
this.s.n = null;
|
|
159
158
|
this.r = null;
|
|
@@ -236,6 +235,8 @@ var ERROR_OFFSET = 0;
|
|
|
236
235
|
var ERROR_BIT = 1 << ERROR_OFFSET;
|
|
237
236
|
var LOADING_OFFSET = 1;
|
|
238
237
|
var LOADING_BIT = 1 << LOADING_OFFSET;
|
|
238
|
+
var UNINITIALIZED_OFFSET = 2;
|
|
239
|
+
var UNINITIALIZED_BIT = 1 << UNINITIALIZED_OFFSET;
|
|
239
240
|
var DEFAULT_FLAGS = ERROR_BIT;
|
|
240
241
|
|
|
241
242
|
// src/core/core.ts
|
|
@@ -245,8 +246,9 @@ var newSources = null;
|
|
|
245
246
|
var newSourcesIndex = 0;
|
|
246
247
|
var newFlags = 0;
|
|
247
248
|
var clock = 0;
|
|
248
|
-
var
|
|
249
|
+
var notStale = false;
|
|
249
250
|
var updateCheck = null;
|
|
251
|
+
var staleCheck = null;
|
|
250
252
|
function getObserver() {
|
|
251
253
|
return currentObserver;
|
|
252
254
|
}
|
|
@@ -258,44 +260,46 @@ function incrementClock() {
|
|
|
258
260
|
}
|
|
259
261
|
var UNCHANGED = Symbol(0);
|
|
260
262
|
var Computation = class extends Owner {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
g = null;
|
|
264
|
+
e = null;
|
|
265
|
+
c;
|
|
266
|
+
D;
|
|
267
|
+
t;
|
|
265
268
|
// Used in __DEV__ mode, hopefully removed in production
|
|
266
|
-
|
|
269
|
+
Z;
|
|
267
270
|
// Using false is an optimization as an alternative to _equals: () => false
|
|
268
271
|
// which could enable more efficient DIRTY notification
|
|
269
|
-
|
|
270
|
-
|
|
272
|
+
N = isEqual;
|
|
273
|
+
T;
|
|
271
274
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
272
|
-
|
|
275
|
+
d = 0;
|
|
273
276
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
+
O = DEFAULT_FLAGS;
|
|
278
|
+
P = null;
|
|
279
|
+
A = -1;
|
|
277
280
|
H = false;
|
|
278
281
|
constructor(initialValue, compute2, options) {
|
|
279
282
|
super(compute2 === null);
|
|
280
|
-
this.
|
|
281
|
-
this.a = compute2 ?
|
|
282
|
-
this.
|
|
283
|
+
this.t = compute2;
|
|
284
|
+
this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
285
|
+
this.d = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
286
|
+
this.c = initialValue;
|
|
283
287
|
if ((options == null ? void 0 : options.equals) !== void 0)
|
|
284
|
-
this.
|
|
288
|
+
this.N = options.equals;
|
|
285
289
|
if (options == null ? void 0 : options.unobserved)
|
|
286
|
-
this.
|
|
290
|
+
this.T = options == null ? void 0 : options.unobserved;
|
|
287
291
|
}
|
|
288
|
-
|
|
292
|
+
U() {
|
|
289
293
|
var _a;
|
|
290
|
-
if (this.
|
|
294
|
+
if (this.t)
|
|
291
295
|
this.x();
|
|
292
|
-
if (!this.
|
|
296
|
+
if (!this.t || ((_a = this.g) == null ? void 0 : _a.length))
|
|
293
297
|
track(this);
|
|
294
|
-
newFlags |= this.
|
|
295
|
-
if (this.
|
|
296
|
-
throw this.
|
|
298
|
+
newFlags |= this.d & ~currentMask;
|
|
299
|
+
if (this.d & ERROR_BIT) {
|
|
300
|
+
throw this.D;
|
|
297
301
|
} else {
|
|
298
|
-
return this.
|
|
302
|
+
return this.c;
|
|
299
303
|
}
|
|
300
304
|
}
|
|
301
305
|
/**
|
|
@@ -303,7 +307,7 @@ var Computation = class extends Owner {
|
|
|
303
307
|
* Automatically re-executes the surrounding computation when the value changes
|
|
304
308
|
*/
|
|
305
309
|
read() {
|
|
306
|
-
return this.
|
|
310
|
+
return this.U();
|
|
307
311
|
}
|
|
308
312
|
/**
|
|
309
313
|
* Return the current value of this computation
|
|
@@ -313,13 +317,15 @@ var Computation = class extends Owner {
|
|
|
313
317
|
* before continuing
|
|
314
318
|
*/
|
|
315
319
|
wait() {
|
|
316
|
-
if (this.
|
|
320
|
+
if (this.t && this.d & ERROR_BIT && this.A <= clock) {
|
|
317
321
|
update(this);
|
|
318
322
|
}
|
|
319
|
-
if (
|
|
323
|
+
if ((notStale || this.d & UNINITIALIZED_BIT) && this.loading()) {
|
|
320
324
|
throw new NotReadyError();
|
|
321
325
|
}
|
|
322
|
-
|
|
326
|
+
if (staleCheck && this.d & LOADING_BIT)
|
|
327
|
+
staleCheck.c = true;
|
|
328
|
+
return this.U();
|
|
323
329
|
}
|
|
324
330
|
/**
|
|
325
331
|
* Return true if the computation is the value is dependent on an unresolved promise
|
|
@@ -329,30 +335,32 @@ var Computation = class extends Owner {
|
|
|
329
335
|
* loading state changes
|
|
330
336
|
*/
|
|
331
337
|
loading() {
|
|
332
|
-
if (this.
|
|
333
|
-
this.
|
|
338
|
+
if (this.P === null) {
|
|
339
|
+
this.P = loadingState(this);
|
|
334
340
|
}
|
|
335
|
-
return this.
|
|
341
|
+
return this.P.read();
|
|
336
342
|
}
|
|
337
343
|
/** Update the computation with a new value. */
|
|
338
344
|
write(value, flags = 0, raw = false) {
|
|
339
|
-
const newValue = !raw && typeof value === "function" ? value(this.
|
|
340
|
-
const valueChanged = newValue !== UNCHANGED && (!!(
|
|
341
|
-
if (valueChanged)
|
|
342
|
-
this.
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
this.
|
|
346
|
-
|
|
347
|
-
|
|
345
|
+
const newValue = !raw && typeof value === "function" ? value(this.c) : value;
|
|
346
|
+
const valueChanged = newValue !== UNCHANGED && (!!(this.d & UNINITIALIZED_BIT) || this.N === false || !this.N(this.c, newValue));
|
|
347
|
+
if (valueChanged) {
|
|
348
|
+
this.c = newValue;
|
|
349
|
+
this.D = void 0;
|
|
350
|
+
}
|
|
351
|
+
const changedFlagsMask = this.d ^ flags, changedFlags = changedFlagsMask & flags;
|
|
352
|
+
this.d = flags;
|
|
353
|
+
this.A = clock + 1;
|
|
354
|
+
if (this.e) {
|
|
355
|
+
for (let i = 0; i < this.e.length; i++) {
|
|
348
356
|
if (valueChanged) {
|
|
349
|
-
this.
|
|
357
|
+
this.e[i].q(STATE_DIRTY);
|
|
350
358
|
} else if (changedFlagsMask) {
|
|
351
|
-
this.
|
|
359
|
+
this.e[i].V(changedFlagsMask, changedFlags);
|
|
352
360
|
}
|
|
353
361
|
}
|
|
354
362
|
}
|
|
355
|
-
return this.
|
|
363
|
+
return this.c;
|
|
356
364
|
}
|
|
357
365
|
/**
|
|
358
366
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
@@ -362,9 +370,9 @@ var Computation = class extends Owner {
|
|
|
362
370
|
return;
|
|
363
371
|
this.H = !!skipQueue;
|
|
364
372
|
this.a = state;
|
|
365
|
-
if (this.
|
|
366
|
-
for (let i = 0; i < this.
|
|
367
|
-
this.
|
|
373
|
+
if (this.e) {
|
|
374
|
+
for (let i = 0; i < this.e.length; i++) {
|
|
375
|
+
this.e[i].q(STATE_CHECK, skipQueue);
|
|
368
376
|
}
|
|
369
377
|
}
|
|
370
378
|
}
|
|
@@ -374,30 +382,31 @@ var Computation = class extends Owner {
|
|
|
374
382
|
* @param mask A bitmask for which flag(s) were changed.
|
|
375
383
|
* @param newFlags The source's new flags, masked to just the changed ones.
|
|
376
384
|
*/
|
|
377
|
-
|
|
385
|
+
V(mask, newFlags2) {
|
|
378
386
|
if (this.a >= STATE_DIRTY)
|
|
379
387
|
return;
|
|
380
|
-
if (mask & this.
|
|
388
|
+
if (mask & this.O) {
|
|
381
389
|
this.q(STATE_DIRTY);
|
|
382
390
|
return;
|
|
383
391
|
}
|
|
384
392
|
if (this.a >= STATE_CHECK)
|
|
385
393
|
return;
|
|
386
|
-
const prevFlags = this.
|
|
394
|
+
const prevFlags = this.d & mask;
|
|
387
395
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
388
396
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
389
397
|
this.q(STATE_CHECK);
|
|
390
398
|
} else {
|
|
391
|
-
this.
|
|
392
|
-
if (this.
|
|
393
|
-
for (let i = 0; i < this.
|
|
394
|
-
this.
|
|
399
|
+
this.d ^= deltaFlags;
|
|
400
|
+
if (this.e) {
|
|
401
|
+
for (let i = 0; i < this.e.length; i++) {
|
|
402
|
+
this.e[i].V(mask, newFlags2);
|
|
395
403
|
}
|
|
396
404
|
}
|
|
397
405
|
}
|
|
398
406
|
}
|
|
399
|
-
|
|
400
|
-
this.
|
|
407
|
+
I(error) {
|
|
408
|
+
this.D = error;
|
|
409
|
+
this.write(UNCHANGED, this.d & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
401
410
|
}
|
|
402
411
|
/**
|
|
403
412
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -415,15 +424,15 @@ var Computation = class extends Owner {
|
|
|
415
424
|
}
|
|
416
425
|
let observerFlags = 0;
|
|
417
426
|
if (this.a === STATE_CHECK) {
|
|
418
|
-
for (let i = 0; i < this.
|
|
419
|
-
this.
|
|
420
|
-
observerFlags |= this.
|
|
427
|
+
for (let i = 0; i < this.g.length; i++) {
|
|
428
|
+
this.g[i].x();
|
|
429
|
+
observerFlags |= this.g[i].d;
|
|
421
430
|
if (this.a === STATE_DIRTY) {
|
|
422
431
|
break;
|
|
423
432
|
}
|
|
424
433
|
}
|
|
425
434
|
}
|
|
426
|
-
if (this.a === STATE_DIRTY
|
|
435
|
+
if (this.a === STATE_DIRTY) {
|
|
427
436
|
update(this);
|
|
428
437
|
} else {
|
|
429
438
|
this.write(UNCHANGED, observerFlags);
|
|
@@ -433,12 +442,12 @@ var Computation = class extends Owner {
|
|
|
433
442
|
/**
|
|
434
443
|
* Remove ourselves from the owner graph and the computation graph
|
|
435
444
|
*/
|
|
436
|
-
|
|
445
|
+
z() {
|
|
437
446
|
if (this.a === STATE_DISPOSED)
|
|
438
447
|
return;
|
|
439
|
-
if (this.
|
|
448
|
+
if (this.g)
|
|
440
449
|
removeSourceObservers(this, 0);
|
|
441
|
-
super.
|
|
450
|
+
super.z();
|
|
442
451
|
}
|
|
443
452
|
};
|
|
444
453
|
function loadingState(node) {
|
|
@@ -449,17 +458,17 @@ function loadingState(node) {
|
|
|
449
458
|
() => {
|
|
450
459
|
track(node);
|
|
451
460
|
node.x();
|
|
452
|
-
return !!(node.
|
|
461
|
+
return !!(node.d & LOADING_BIT);
|
|
453
462
|
},
|
|
454
463
|
options
|
|
455
464
|
);
|
|
456
|
-
computation.
|
|
465
|
+
computation.O = ERROR_BIT | LOADING_BIT;
|
|
457
466
|
setOwner(prevOwner);
|
|
458
467
|
return computation;
|
|
459
468
|
}
|
|
460
469
|
function track(computation) {
|
|
461
470
|
if (currentObserver) {
|
|
462
|
-
if (!newSources && currentObserver.
|
|
471
|
+
if (!newSources && currentObserver.g && currentObserver.g[newSourcesIndex] === computation) {
|
|
463
472
|
newSourcesIndex++;
|
|
464
473
|
} else if (!newSources)
|
|
465
474
|
newSources = [computation];
|
|
@@ -467,7 +476,7 @@ function track(computation) {
|
|
|
467
476
|
newSources.push(computation);
|
|
468
477
|
}
|
|
469
478
|
if (updateCheck) {
|
|
470
|
-
updateCheck.
|
|
479
|
+
updateCheck.c = computation.A > currentObserver.A;
|
|
471
480
|
}
|
|
472
481
|
}
|
|
473
482
|
}
|
|
@@ -479,42 +488,42 @@ function update(node) {
|
|
|
479
488
|
try {
|
|
480
489
|
node.dispose(false);
|
|
481
490
|
node.emptyDisposal();
|
|
482
|
-
const result = compute(node, node.
|
|
491
|
+
const result = compute(node, node.t, node);
|
|
483
492
|
node.write(result, newFlags, true);
|
|
484
493
|
} catch (error) {
|
|
485
494
|
if (error instanceof NotReadyError) {
|
|
486
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT);
|
|
495
|
+
node.write(UNCHANGED, newFlags | LOADING_BIT | node.d & UNINITIALIZED_BIT);
|
|
487
496
|
} else {
|
|
488
|
-
node.
|
|
497
|
+
node.I(error);
|
|
489
498
|
}
|
|
490
499
|
} finally {
|
|
491
500
|
if (newSources) {
|
|
492
|
-
if (node.
|
|
501
|
+
if (node.g)
|
|
493
502
|
removeSourceObservers(node, newSourcesIndex);
|
|
494
|
-
if (node.
|
|
495
|
-
node.
|
|
503
|
+
if (node.g && newSourcesIndex > 0) {
|
|
504
|
+
node.g.length = newSourcesIndex + newSources.length;
|
|
496
505
|
for (let i = 0; i < newSources.length; i++) {
|
|
497
|
-
node.
|
|
506
|
+
node.g[newSourcesIndex + i] = newSources[i];
|
|
498
507
|
}
|
|
499
508
|
} else {
|
|
500
|
-
node.
|
|
509
|
+
node.g = newSources;
|
|
501
510
|
}
|
|
502
511
|
let source;
|
|
503
|
-
for (let i = newSourcesIndex; i < node.
|
|
504
|
-
source = node.
|
|
505
|
-
if (!source.
|
|
506
|
-
source.
|
|
512
|
+
for (let i = newSourcesIndex; i < node.g.length; i++) {
|
|
513
|
+
source = node.g[i];
|
|
514
|
+
if (!source.e)
|
|
515
|
+
source.e = [node];
|
|
507
516
|
else
|
|
508
|
-
source.
|
|
517
|
+
source.e.push(node);
|
|
509
518
|
}
|
|
510
|
-
} else if (node.
|
|
519
|
+
} else if (node.g && newSourcesIndex < node.g.length) {
|
|
511
520
|
removeSourceObservers(node, newSourcesIndex);
|
|
512
|
-
node.
|
|
521
|
+
node.g.length = newSourcesIndex;
|
|
513
522
|
}
|
|
514
523
|
newSources = prevSources;
|
|
515
524
|
newSourcesIndex = prevSourcesIndex;
|
|
516
525
|
newFlags = prevFlags;
|
|
517
|
-
node.
|
|
526
|
+
node.A = clock + 1;
|
|
518
527
|
node.a = STATE_CLEAN;
|
|
519
528
|
}
|
|
520
529
|
}
|
|
@@ -522,14 +531,14 @@ function removeSourceObservers(node, index) {
|
|
|
522
531
|
var _a;
|
|
523
532
|
let source;
|
|
524
533
|
let swap;
|
|
525
|
-
for (let i = index; i < node.
|
|
526
|
-
source = node.
|
|
527
|
-
if (source.
|
|
528
|
-
swap = source.
|
|
529
|
-
source.
|
|
530
|
-
source.
|
|
531
|
-
if (!source.
|
|
532
|
-
(_a = source.
|
|
534
|
+
for (let i = index; i < node.g.length; i++) {
|
|
535
|
+
source = node.g[i];
|
|
536
|
+
if (source.e) {
|
|
537
|
+
swap = source.e.indexOf(node);
|
|
538
|
+
source.e[swap] = source.e[source.e.length - 1];
|
|
539
|
+
source.e.pop();
|
|
540
|
+
if (!source.e.length)
|
|
541
|
+
(_a = source.T) == null ? void 0 : _a.call(source);
|
|
533
542
|
}
|
|
534
543
|
}
|
|
535
544
|
}
|
|
@@ -543,31 +552,35 @@ function untrack(fn) {
|
|
|
543
552
|
}
|
|
544
553
|
function hasUpdated(fn) {
|
|
545
554
|
const current = updateCheck;
|
|
546
|
-
updateCheck = {
|
|
555
|
+
updateCheck = { c: false };
|
|
547
556
|
try {
|
|
548
557
|
fn();
|
|
549
|
-
return updateCheck.
|
|
558
|
+
return updateCheck.c;
|
|
550
559
|
} finally {
|
|
551
560
|
updateCheck = current;
|
|
552
561
|
}
|
|
553
562
|
}
|
|
554
|
-
function
|
|
563
|
+
function isStale(fn) {
|
|
564
|
+
const current = staleCheck;
|
|
565
|
+
staleCheck = { c: false };
|
|
555
566
|
try {
|
|
556
|
-
fn
|
|
557
|
-
return
|
|
558
|
-
} catch
|
|
559
|
-
|
|
567
|
+
latest(fn);
|
|
568
|
+
return staleCheck.c;
|
|
569
|
+
} catch {
|
|
570
|
+
} finally {
|
|
571
|
+
staleCheck = current;
|
|
560
572
|
}
|
|
573
|
+
return false;
|
|
561
574
|
}
|
|
562
|
-
function
|
|
575
|
+
function latest(fn) {
|
|
563
576
|
const prevFlags = newFlags;
|
|
564
|
-
|
|
577
|
+
const prevNotStale = notStale;
|
|
578
|
+
notStale = false;
|
|
565
579
|
try {
|
|
566
580
|
return fn();
|
|
567
|
-
} catch {
|
|
568
581
|
} finally {
|
|
569
582
|
newFlags = prevFlags;
|
|
570
|
-
|
|
583
|
+
notStale = prevNotStale;
|
|
571
584
|
}
|
|
572
585
|
}
|
|
573
586
|
function catchError(fn) {
|
|
@@ -579,16 +592,18 @@ function catchError(fn) {
|
|
|
579
592
|
return e;
|
|
580
593
|
}
|
|
581
594
|
}
|
|
582
|
-
function compute(owner,
|
|
583
|
-
const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask;
|
|
595
|
+
function compute(owner, fn, observer) {
|
|
596
|
+
const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
|
|
584
597
|
currentObserver = observer;
|
|
585
|
-
currentMask = (observer == null ? void 0 : observer.
|
|
598
|
+
currentMask = (observer == null ? void 0 : observer.O) ?? DEFAULT_FLAGS;
|
|
599
|
+
notStale = true;
|
|
586
600
|
try {
|
|
587
|
-
return
|
|
601
|
+
return fn(observer ? observer.c : void 0);
|
|
588
602
|
} finally {
|
|
589
603
|
setOwner(prevOwner);
|
|
590
604
|
currentObserver = prevObserver;
|
|
591
605
|
currentMask = prevMask;
|
|
606
|
+
notStale = prevNotStale;
|
|
592
607
|
}
|
|
593
608
|
}
|
|
594
609
|
|
|
@@ -598,27 +613,27 @@ function schedule() {
|
|
|
598
613
|
if (scheduled)
|
|
599
614
|
return;
|
|
600
615
|
scheduled = true;
|
|
601
|
-
if (!globalQueue.
|
|
616
|
+
if (!globalQueue.J)
|
|
602
617
|
queueMicrotask(flushSync);
|
|
603
618
|
}
|
|
604
619
|
var Queue = class {
|
|
605
|
-
|
|
606
|
-
|
|
620
|
+
J = false;
|
|
621
|
+
u = [[], [], []];
|
|
607
622
|
E = [];
|
|
608
623
|
enqueue(type, node) {
|
|
609
|
-
this.
|
|
624
|
+
this.u[0].push(node);
|
|
610
625
|
if (type)
|
|
611
|
-
this.
|
|
626
|
+
this.u[type].push(node);
|
|
612
627
|
schedule();
|
|
613
628
|
}
|
|
614
629
|
run(type) {
|
|
615
|
-
if (this.
|
|
630
|
+
if (this.u[type].length) {
|
|
616
631
|
if (type === EFFECT_PURE) {
|
|
617
|
-
runPureQueue(this.
|
|
618
|
-
this.
|
|
632
|
+
runPureQueue(this.u[type]);
|
|
633
|
+
this.u[type] = [];
|
|
619
634
|
} else {
|
|
620
|
-
const effects = this.
|
|
621
|
-
this.
|
|
635
|
+
const effects = this.u[type];
|
|
636
|
+
this.u[type] = [];
|
|
622
637
|
runEffectQueue(effects);
|
|
623
638
|
}
|
|
624
639
|
}
|
|
@@ -626,13 +641,13 @@ var Queue = class {
|
|
|
626
641
|
for (let i = 0; i < this.E.length; i++) {
|
|
627
642
|
rerun = this.E[i].run(type) || rerun;
|
|
628
643
|
}
|
|
629
|
-
if (type === EFFECT_PURE && this.
|
|
644
|
+
if (type === EFFECT_PURE && this.u[type].length)
|
|
630
645
|
return true;
|
|
631
646
|
}
|
|
632
647
|
flush() {
|
|
633
|
-
if (this.
|
|
648
|
+
if (this.J)
|
|
634
649
|
return;
|
|
635
|
-
this.
|
|
650
|
+
this.J = true;
|
|
636
651
|
try {
|
|
637
652
|
while (this.run(EFFECT_PURE)) {
|
|
638
653
|
}
|
|
@@ -641,7 +656,7 @@ var Queue = class {
|
|
|
641
656
|
this.run(EFFECT_RENDER);
|
|
642
657
|
this.run(EFFECT_USER);
|
|
643
658
|
} finally {
|
|
644
|
-
this.
|
|
659
|
+
this.J = false;
|
|
645
660
|
}
|
|
646
661
|
}
|
|
647
662
|
addChild(child) {
|
|
@@ -661,9 +676,9 @@ function flushSync() {
|
|
|
661
676
|
}
|
|
662
677
|
function createBoundary(fn, queue) {
|
|
663
678
|
const owner = new Owner();
|
|
664
|
-
const parentQueue = owner.
|
|
665
|
-
parentQueue.addChild(owner.
|
|
666
|
-
onCleanup(() => parentQueue.removeChild(owner.
|
|
679
|
+
const parentQueue = owner.b || globalQueue;
|
|
680
|
+
parentQueue.addChild(owner.b = queue);
|
|
681
|
+
onCleanup(() => parentQueue.removeChild(owner.b));
|
|
667
682
|
return compute(owner, fn, null);
|
|
668
683
|
}
|
|
669
684
|
function runTop(node) {
|
|
@@ -686,132 +701,152 @@ function runPureQueue(queue) {
|
|
|
686
701
|
}
|
|
687
702
|
function runEffectQueue(queue) {
|
|
688
703
|
for (let i = 0; i < queue.length; i++)
|
|
689
|
-
queue[i].
|
|
704
|
+
queue[i].W();
|
|
690
705
|
}
|
|
691
706
|
|
|
692
707
|
// src/core/effect.ts
|
|
693
708
|
var Effect = class extends Computation {
|
|
694
|
-
J;
|
|
695
|
-
A;
|
|
696
|
-
B;
|
|
697
|
-
P = false;
|
|
698
709
|
K;
|
|
699
|
-
|
|
700
|
-
|
|
710
|
+
L;
|
|
711
|
+
B;
|
|
712
|
+
Q = false;
|
|
713
|
+
M;
|
|
714
|
+
y;
|
|
715
|
+
b;
|
|
701
716
|
constructor(initialValue, compute2, effect, error, options) {
|
|
702
717
|
var _a;
|
|
703
718
|
super(initialValue, compute2, options);
|
|
704
|
-
this.
|
|
705
|
-
this.
|
|
706
|
-
this.
|
|
707
|
-
this.
|
|
708
|
-
this.
|
|
719
|
+
this.K = effect;
|
|
720
|
+
this.L = error;
|
|
721
|
+
this.M = initialValue;
|
|
722
|
+
this.y = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
|
|
723
|
+
if (this.y === EFFECT_RENDER) {
|
|
724
|
+
this.t = (p) => latest(() => compute2(p));
|
|
725
|
+
}
|
|
726
|
+
this.b = ((_a = getOwner()) == null ? void 0 : _a.b) || globalQueue;
|
|
709
727
|
if (!(options == null ? void 0 : options.defer)) {
|
|
710
728
|
this.x();
|
|
711
|
-
this.
|
|
729
|
+
this.y === EFFECT_USER ? this.b.enqueue(this.y, this) : this.W();
|
|
712
730
|
}
|
|
713
731
|
}
|
|
714
732
|
write(value, flags = 0) {
|
|
715
733
|
var _a, _b;
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
734
|
+
if (this.a == STATE_DIRTY) {
|
|
735
|
+
const currentFlags = this.d;
|
|
736
|
+
this.d = flags;
|
|
737
|
+
if (this.y === EFFECT_RENDER && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
|
|
738
|
+
(_b = (_a = this.b).R) == null ? void 0 : _b.call(_a, this);
|
|
739
|
+
}
|
|
720
740
|
}
|
|
721
741
|
if (value === UNCHANGED)
|
|
722
|
-
return this.
|
|
723
|
-
this.
|
|
724
|
-
this.
|
|
742
|
+
return this.c;
|
|
743
|
+
this.c = value;
|
|
744
|
+
this.Q = true;
|
|
725
745
|
return value;
|
|
726
746
|
}
|
|
727
747
|
q(state, skipQueue) {
|
|
728
748
|
if (this.a >= state || skipQueue)
|
|
729
749
|
return;
|
|
730
750
|
if (this.a === STATE_CLEAN)
|
|
731
|
-
this.
|
|
751
|
+
this.b.enqueue(this.y, this);
|
|
732
752
|
this.a = state;
|
|
733
753
|
}
|
|
734
|
-
|
|
754
|
+
I(error) {
|
|
735
755
|
var _a, _b, _c;
|
|
736
756
|
(_a = this.B) == null ? void 0 : _a.call(this);
|
|
737
|
-
if (this.
|
|
738
|
-
this.
|
|
739
|
-
(_c = (_b = this.
|
|
757
|
+
if (this.d & LOADING_BIT) {
|
|
758
|
+
this.d = 0;
|
|
759
|
+
(_c = (_b = this.b).R) == null ? void 0 : _c.call(_b, this);
|
|
740
760
|
}
|
|
741
|
-
if (this.
|
|
761
|
+
if (this.y === EFFECT_USER) {
|
|
742
762
|
try {
|
|
743
|
-
return this.
|
|
763
|
+
return this.L ? this.B = this.L(error) : console.error(new EffectError(this.K, error));
|
|
744
764
|
} catch (e) {
|
|
745
765
|
error = e;
|
|
746
766
|
}
|
|
747
767
|
}
|
|
748
768
|
this.handleError(error);
|
|
749
769
|
}
|
|
750
|
-
|
|
770
|
+
z() {
|
|
751
771
|
var _a;
|
|
752
772
|
if (this.a === STATE_DISPOSED)
|
|
753
773
|
return;
|
|
754
|
-
this.J = void 0;
|
|
755
774
|
this.K = void 0;
|
|
756
|
-
this.
|
|
775
|
+
this.M = void 0;
|
|
776
|
+
this.L = void 0;
|
|
757
777
|
(_a = this.B) == null ? void 0 : _a.call(this);
|
|
758
778
|
this.B = void 0;
|
|
759
|
-
super.
|
|
779
|
+
super.z();
|
|
760
780
|
}
|
|
761
|
-
|
|
781
|
+
W() {
|
|
762
782
|
var _a;
|
|
763
|
-
if (this.
|
|
783
|
+
if (this.Q && this.a !== STATE_DISPOSED) {
|
|
764
784
|
(_a = this.B) == null ? void 0 : _a.call(this);
|
|
765
785
|
try {
|
|
766
|
-
this.B = this.
|
|
786
|
+
this.B = this.K(this.c, this.M);
|
|
767
787
|
} catch (e) {
|
|
768
788
|
this.handleError(e);
|
|
769
789
|
} finally {
|
|
770
|
-
this.
|
|
771
|
-
this.
|
|
790
|
+
this.M = this.c;
|
|
791
|
+
this.Q = false;
|
|
772
792
|
}
|
|
773
793
|
}
|
|
774
794
|
}
|
|
775
795
|
};
|
|
776
796
|
var EagerComputation = class extends Computation {
|
|
777
|
-
|
|
797
|
+
b;
|
|
778
798
|
constructor(initialValue, compute2, options) {
|
|
779
799
|
var _a;
|
|
780
800
|
super(initialValue, compute2, options);
|
|
781
|
-
this.
|
|
801
|
+
this.b = ((_a = getOwner()) == null ? void 0 : _a.b) || globalQueue;
|
|
782
802
|
this.x();
|
|
783
803
|
}
|
|
784
804
|
q(state, skipQueue) {
|
|
785
805
|
if (this.a >= state && !this.H)
|
|
786
806
|
return;
|
|
787
807
|
if (this.a === STATE_CLEAN && !skipQueue)
|
|
788
|
-
this.
|
|
808
|
+
this.b.enqueue(EFFECT_PURE, this);
|
|
789
809
|
super.q(state, skipQueue);
|
|
790
810
|
}
|
|
791
811
|
};
|
|
812
|
+
var ProjectionComputation = class extends Computation {
|
|
813
|
+
b;
|
|
814
|
+
constructor(compute2) {
|
|
815
|
+
var _a;
|
|
816
|
+
super(null, compute2);
|
|
817
|
+
this.b = ((_a = getOwner()) == null ? void 0 : _a.b) || globalQueue;
|
|
818
|
+
}
|
|
819
|
+
q(state, skipQueue) {
|
|
820
|
+
if (this.a >= state && !this.H)
|
|
821
|
+
return;
|
|
822
|
+
if (this.a === STATE_CLEAN && !skipQueue)
|
|
823
|
+
this.b.enqueue(EFFECT_PURE, this);
|
|
824
|
+
super.q(state, true);
|
|
825
|
+
}
|
|
826
|
+
};
|
|
792
827
|
|
|
793
828
|
// src/core/suspense.ts
|
|
794
829
|
var SuspenseQueue = class extends Queue {
|
|
795
|
-
|
|
830
|
+
f = /* @__PURE__ */ new Set();
|
|
796
831
|
o = false;
|
|
797
|
-
|
|
832
|
+
S = new Computation(false, null);
|
|
798
833
|
run(type) {
|
|
799
834
|
if (type && this.o)
|
|
800
835
|
return;
|
|
801
836
|
return super.run(type);
|
|
802
837
|
}
|
|
803
|
-
|
|
804
|
-
if (node.
|
|
805
|
-
this.
|
|
838
|
+
R(node) {
|
|
839
|
+
if (node.d & LOADING_BIT) {
|
|
840
|
+
this.f.add(node);
|
|
806
841
|
if (!this.o) {
|
|
807
842
|
this.o = true;
|
|
808
|
-
this.
|
|
843
|
+
this.S.write(true);
|
|
809
844
|
}
|
|
810
845
|
} else {
|
|
811
|
-
this.
|
|
812
|
-
if (this.
|
|
846
|
+
this.f.delete(node);
|
|
847
|
+
if (this.f.size === 0) {
|
|
813
848
|
this.o = false;
|
|
814
|
-
this.
|
|
849
|
+
this.S.write(false);
|
|
815
850
|
}
|
|
816
851
|
}
|
|
817
852
|
}
|
|
@@ -819,12 +854,12 @@ var SuspenseQueue = class extends Queue {
|
|
|
819
854
|
var LiveComputation = class extends EagerComputation {
|
|
820
855
|
write(value, flags = 0) {
|
|
821
856
|
var _a, _b;
|
|
822
|
-
const currentFlags = this.
|
|
857
|
+
const currentFlags = this.d;
|
|
823
858
|
super.write(value, flags);
|
|
824
859
|
if ((flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
|
|
825
|
-
(_b = (_a = this.
|
|
860
|
+
(_b = (_a = this.b).R) == null ? void 0 : _b.call(_a, this);
|
|
826
861
|
}
|
|
827
|
-
return this.
|
|
862
|
+
return this.c;
|
|
828
863
|
}
|
|
829
864
|
};
|
|
830
865
|
function createSuspense(fn, fallback) {
|
|
@@ -833,7 +868,7 @@ function createSuspense(fn, fallback) {
|
|
|
833
868
|
const child = new Computation(null, fn);
|
|
834
869
|
return new LiveComputation(null, () => flatten(child.wait()));
|
|
835
870
|
}, queue);
|
|
836
|
-
const equality = new Computation(null, () => queue.
|
|
871
|
+
const equality = new Computation(null, () => queue.S.read() || queue.o);
|
|
837
872
|
const comp = new Computation(null, () => equality.read() ? fallback() : tree.read());
|
|
838
873
|
return comp.read.bind(comp);
|
|
839
874
|
}
|
|
@@ -865,24 +900,25 @@ function createMemo(compute2, value, options) {
|
|
|
865
900
|
var _a, _b, _c;
|
|
866
901
|
if (node) {
|
|
867
902
|
resolvedValue = node.wait();
|
|
868
|
-
if (!((_a = node.
|
|
903
|
+
if (!((_a = node.g) == null ? void 0 : _a.length) && ((_b = node.n) == null ? void 0 : _b.r) !== node) {
|
|
869
904
|
node.dispose();
|
|
870
905
|
node = void 0;
|
|
871
|
-
} else if (!node.r && !((_c = node.
|
|
906
|
+
} else if (!node.r && !((_c = node.e) == null ? void 0 : _c.length)) {
|
|
872
907
|
node.dispose();
|
|
873
|
-
node.a =
|
|
908
|
+
node.a = STATE_DIRTY;
|
|
874
909
|
}
|
|
875
910
|
}
|
|
876
911
|
return resolvedValue;
|
|
877
912
|
};
|
|
878
913
|
}
|
|
879
914
|
function createAsync(compute2, value, options) {
|
|
915
|
+
let uninitialized = value === void 0;
|
|
880
916
|
const lhs = new EagerComputation(
|
|
881
917
|
{
|
|
882
|
-
|
|
918
|
+
c: value
|
|
883
919
|
},
|
|
884
920
|
(p) => {
|
|
885
|
-
const value2 = p == null ? void 0 : p.
|
|
921
|
+
const value2 = p == null ? void 0 : p.c;
|
|
886
922
|
const source = compute2(value2);
|
|
887
923
|
const isPromise = source instanceof Promise;
|
|
888
924
|
const iterator = source[Symbol.asyncIterator];
|
|
@@ -891,26 +927,28 @@ function createAsync(compute2, value, options) {
|
|
|
891
927
|
wait() {
|
|
892
928
|
return source;
|
|
893
929
|
},
|
|
894
|
-
|
|
930
|
+
c: source
|
|
895
931
|
};
|
|
896
932
|
}
|
|
897
933
|
const signal = new Computation(value2, null, options);
|
|
898
934
|
const w = signal.wait;
|
|
899
935
|
signal.wait = function() {
|
|
900
|
-
if (signal.
|
|
936
|
+
if (signal.d & ERROR_BIT && signal.A <= getClock()) {
|
|
901
937
|
lhs.q(STATE_DIRTY);
|
|
902
938
|
throw new NotReadyError();
|
|
903
939
|
}
|
|
904
940
|
return w.call(this);
|
|
905
941
|
};
|
|
906
|
-
signal.write(UNCHANGED, LOADING_BIT);
|
|
942
|
+
signal.write(UNCHANGED, LOADING_BIT | (uninitialized ? UNINITIALIZED_BIT : 0));
|
|
907
943
|
if (isPromise) {
|
|
908
944
|
source.then(
|
|
909
945
|
(value3) => {
|
|
946
|
+
uninitialized = false;
|
|
910
947
|
signal.write(value3, 0, true);
|
|
911
948
|
},
|
|
912
949
|
(error) => {
|
|
913
|
-
|
|
950
|
+
uninitialized = true;
|
|
951
|
+
signal.I(error);
|
|
914
952
|
}
|
|
915
953
|
);
|
|
916
954
|
} else {
|
|
@@ -964,14 +1002,14 @@ function createErrorBoundary(fn, fallback) {
|
|
|
964
1002
|
const owner = new Owner();
|
|
965
1003
|
const error = new Computation(null, null);
|
|
966
1004
|
const reset = new Computation(null, null, { equals: false });
|
|
967
|
-
const handler = (err) => error.write({
|
|
1005
|
+
const handler = (err) => error.write({ D: err });
|
|
968
1006
|
owner.m = owner.m ? [handler, ...owner.m] : [handler];
|
|
969
1007
|
const guarded = compute(
|
|
970
1008
|
owner,
|
|
971
1009
|
() => {
|
|
972
1010
|
const c = new Computation(null, () => (reset.read(), fn()));
|
|
973
1011
|
const f = new Computation(null, () => flatten(c.read()));
|
|
974
|
-
f.
|
|
1012
|
+
f.I = function(error2) {
|
|
975
1013
|
this.handleError(error2);
|
|
976
1014
|
};
|
|
977
1015
|
return f;
|
|
@@ -984,7 +1022,7 @@ function createErrorBoundary(fn, fallback) {
|
|
|
984
1022
|
if (!error.read())
|
|
985
1023
|
return resolved;
|
|
986
1024
|
}
|
|
987
|
-
return fallback(error.read().
|
|
1025
|
+
return fallback(error.read().D, () => {
|
|
988
1026
|
error.write(null);
|
|
989
1027
|
reset.write(null);
|
|
990
1028
|
});
|
|
@@ -1012,26 +1050,17 @@ function createReaction(effect, error, options) {
|
|
|
1012
1050
|
...void 0
|
|
1013
1051
|
});
|
|
1014
1052
|
return (tracking) => {
|
|
1015
|
-
node.
|
|
1053
|
+
node.t = tracking;
|
|
1016
1054
|
node.a = STATE_DIRTY;
|
|
1017
1055
|
node.x();
|
|
1018
|
-
node.
|
|
1056
|
+
node.t = null;
|
|
1019
1057
|
};
|
|
1020
1058
|
}
|
|
1021
1059
|
|
|
1022
1060
|
// src/store/projection.ts
|
|
1023
|
-
var ProjectionComputation = class extends EagerComputation {
|
|
1024
|
-
q(state, skipQueue) {
|
|
1025
|
-
if (this.a >= state && !this.H)
|
|
1026
|
-
return;
|
|
1027
|
-
if (this.a === STATE_CLEAN && !skipQueue)
|
|
1028
|
-
this.g.enqueue(EFFECT_PURE, this);
|
|
1029
|
-
super.q(state, true);
|
|
1030
|
-
}
|
|
1031
|
-
};
|
|
1032
1061
|
function createProjection(fn, initialValue = {}) {
|
|
1033
1062
|
const [store, setStore] = createStore(initialValue);
|
|
1034
|
-
const node = new ProjectionComputation(
|
|
1063
|
+
const node = new ProjectionComputation(() => {
|
|
1035
1064
|
setStore(fn);
|
|
1036
1065
|
});
|
|
1037
1066
|
const wrapped = /* @__PURE__ */ new WeakMap();
|
|
@@ -1173,7 +1202,7 @@ var proxyTraps = {
|
|
|
1173
1202
|
return desc.get.call(receiver);
|
|
1174
1203
|
}
|
|
1175
1204
|
if (Writing.has(storeValue)) {
|
|
1176
|
-
const value2 = tracked ? tracked.
|
|
1205
|
+
const value2 = tracked ? tracked.c : storeValue[property];
|
|
1177
1206
|
return isWrappable(value2) ? (Writing.add(value2[$RAW] || value2), wrap2(value2)) : value2;
|
|
1178
1207
|
}
|
|
1179
1208
|
let value = tracked ? nodes[property].read() : storeValue[property];
|
|
@@ -1516,19 +1545,19 @@ function mapArray(list, map, options) {
|
|
|
1516
1545
|
return updateKeyedMap.bind({
|
|
1517
1546
|
F: new Owner(),
|
|
1518
1547
|
i: 0,
|
|
1519
|
-
|
|
1520
|
-
|
|
1548
|
+
X: list,
|
|
1549
|
+
w: [],
|
|
1521
1550
|
G: map,
|
|
1551
|
+
h: [],
|
|
1522
1552
|
f: [],
|
|
1523
|
-
|
|
1524
|
-
D: keyFn,
|
|
1553
|
+
C: keyFn,
|
|
1525
1554
|
j: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
1526
1555
|
k: map.length > 1 ? [] : void 0,
|
|
1527
1556
|
o: options == null ? void 0 : options.fallback
|
|
1528
1557
|
});
|
|
1529
1558
|
}
|
|
1530
1559
|
function updateKeyedMap() {
|
|
1531
|
-
const newItems = this.
|
|
1560
|
+
const newItems = this.X() || [], newLen = newItems.length;
|
|
1532
1561
|
newItems[$TRACK];
|
|
1533
1562
|
runWithOwner(this.F, () => {
|
|
1534
1563
|
let i, j, mapper = this.j ? () => {
|
|
@@ -1549,38 +1578,38 @@ function updateKeyedMap() {
|
|
|
1549
1578
|
if (newLen === 0) {
|
|
1550
1579
|
if (this.i !== 0) {
|
|
1551
1580
|
this.F.dispose(false);
|
|
1552
|
-
this.c = [];
|
|
1553
|
-
this.u = [];
|
|
1554
1581
|
this.f = [];
|
|
1582
|
+
this.w = [];
|
|
1583
|
+
this.h = [];
|
|
1555
1584
|
this.i = 0;
|
|
1556
1585
|
this.j && (this.j = []);
|
|
1557
1586
|
this.k && (this.k = []);
|
|
1558
1587
|
}
|
|
1559
|
-
if (this.o && !this.
|
|
1560
|
-
this.
|
|
1561
|
-
this.
|
|
1588
|
+
if (this.o && !this.h[0]) {
|
|
1589
|
+
this.h[0] = compute(
|
|
1590
|
+
this.f[0] = new Owner(),
|
|
1562
1591
|
this.o,
|
|
1563
1592
|
null
|
|
1564
1593
|
);
|
|
1565
1594
|
}
|
|
1566
1595
|
} else if (this.i === 0) {
|
|
1567
|
-
if (this.
|
|
1568
|
-
this.
|
|
1569
|
-
this.
|
|
1596
|
+
if (this.f[0])
|
|
1597
|
+
this.f[0].dispose();
|
|
1598
|
+
this.h = new Array(newLen);
|
|
1570
1599
|
for (j = 0; j < newLen; j++) {
|
|
1571
|
-
this.
|
|
1572
|
-
this.
|
|
1600
|
+
this.w[j] = newItems[j];
|
|
1601
|
+
this.h[j] = compute(this.f[j] = new Owner(), mapper, null);
|
|
1573
1602
|
}
|
|
1574
1603
|
this.i = newLen;
|
|
1575
1604
|
} else {
|
|
1576
1605
|
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;
|
|
1577
|
-
for (start = 0, end = Math.min(this.i, newLen); start < end && (this.
|
|
1606
|
+
for (start = 0, end = Math.min(this.i, newLen); start < end && (this.w[start] === newItems[start] || this.j && compare(this.C, this.w[start], newItems[start])); start++) {
|
|
1578
1607
|
if (this.j)
|
|
1579
1608
|
this.j[start].write(newItems[start]);
|
|
1580
1609
|
}
|
|
1581
|
-
for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.
|
|
1582
|
-
temp[newEnd] = this.
|
|
1583
|
-
tempNodes[newEnd] = this.
|
|
1610
|
+
for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.w[end] === newItems[newEnd] || this.j && compare(this.C, this.w[end], newItems[newEnd])); end--, newEnd--) {
|
|
1611
|
+
temp[newEnd] = this.h[end];
|
|
1612
|
+
tempNodes[newEnd] = this.f[end];
|
|
1584
1613
|
tempRows && (tempRows[newEnd] = this.j[end]);
|
|
1585
1614
|
tempIndexes && (tempIndexes[newEnd] = this.k[end]);
|
|
1586
1615
|
}
|
|
@@ -1588,29 +1617,29 @@ function updateKeyedMap() {
|
|
|
1588
1617
|
newIndicesNext = new Array(newEnd + 1);
|
|
1589
1618
|
for (j = newEnd; j >= start; j--) {
|
|
1590
1619
|
item = newItems[j];
|
|
1591
|
-
key = this.
|
|
1620
|
+
key = this.C ? this.C(item) : item;
|
|
1592
1621
|
i = newIndices.get(key);
|
|
1593
1622
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
1594
1623
|
newIndices.set(key, j);
|
|
1595
1624
|
}
|
|
1596
1625
|
for (i = start; i <= end; i++) {
|
|
1597
|
-
item = this.
|
|
1598
|
-
key = this.
|
|
1626
|
+
item = this.w[i];
|
|
1627
|
+
key = this.C ? this.C(item) : item;
|
|
1599
1628
|
j = newIndices.get(key);
|
|
1600
1629
|
if (j !== void 0 && j !== -1) {
|
|
1601
|
-
temp[j] = this.
|
|
1602
|
-
tempNodes[j] = this.
|
|
1630
|
+
temp[j] = this.h[i];
|
|
1631
|
+
tempNodes[j] = this.f[i];
|
|
1603
1632
|
tempRows && (tempRows[j] = this.j[i]);
|
|
1604
1633
|
tempIndexes && (tempIndexes[j] = this.k[i]);
|
|
1605
1634
|
j = newIndicesNext[j];
|
|
1606
1635
|
newIndices.set(key, j);
|
|
1607
1636
|
} else
|
|
1608
|
-
this.
|
|
1637
|
+
this.f[i].dispose();
|
|
1609
1638
|
}
|
|
1610
1639
|
for (j = start; j < newLen; j++) {
|
|
1611
1640
|
if (j in temp) {
|
|
1612
|
-
this.
|
|
1613
|
-
this.
|
|
1641
|
+
this.h[j] = temp[j];
|
|
1642
|
+
this.f[j] = tempNodes[j];
|
|
1614
1643
|
if (tempRows) {
|
|
1615
1644
|
this.j[j] = tempRows[j];
|
|
1616
1645
|
this.j[j].write(newItems[j]);
|
|
@@ -1620,60 +1649,60 @@ function updateKeyedMap() {
|
|
|
1620
1649
|
this.k[j].write(j);
|
|
1621
1650
|
}
|
|
1622
1651
|
} else {
|
|
1623
|
-
this.
|
|
1652
|
+
this.h[j] = compute(this.f[j] = new Owner(), mapper, null);
|
|
1624
1653
|
}
|
|
1625
1654
|
}
|
|
1626
|
-
this.
|
|
1627
|
-
this.
|
|
1655
|
+
this.h = this.h.slice(0, this.i = newLen);
|
|
1656
|
+
this.w = newItems.slice(0);
|
|
1628
1657
|
}
|
|
1629
1658
|
});
|
|
1630
|
-
return this.
|
|
1659
|
+
return this.h;
|
|
1631
1660
|
}
|
|
1632
1661
|
function repeat(count, map, options) {
|
|
1633
1662
|
return updateRepeat.bind({
|
|
1634
1663
|
F: new Owner(),
|
|
1635
1664
|
i: 0,
|
|
1636
|
-
|
|
1665
|
+
Y: count,
|
|
1637
1666
|
G: map,
|
|
1638
|
-
c: [],
|
|
1639
1667
|
f: [],
|
|
1668
|
+
h: [],
|
|
1640
1669
|
o: options == null ? void 0 : options.fallback
|
|
1641
1670
|
});
|
|
1642
1671
|
}
|
|
1643
1672
|
function updateRepeat() {
|
|
1644
|
-
const newLen = this.
|
|
1673
|
+
const newLen = this.Y();
|
|
1645
1674
|
runWithOwner(this.F, () => {
|
|
1646
1675
|
if (newLen === 0) {
|
|
1647
1676
|
if (this.i !== 0) {
|
|
1648
1677
|
this.F.dispose(false);
|
|
1649
|
-
this.c = [];
|
|
1650
1678
|
this.f = [];
|
|
1679
|
+
this.h = [];
|
|
1651
1680
|
this.i = 0;
|
|
1652
1681
|
}
|
|
1653
|
-
if (this.o && !this.
|
|
1654
|
-
this.
|
|
1655
|
-
this.
|
|
1682
|
+
if (this.o && !this.h[0]) {
|
|
1683
|
+
this.h[0] = compute(
|
|
1684
|
+
this.f[0] = new Owner(),
|
|
1656
1685
|
this.o,
|
|
1657
1686
|
null
|
|
1658
1687
|
);
|
|
1659
1688
|
}
|
|
1660
1689
|
} else {
|
|
1661
|
-
if (this.i === 0 && this.
|
|
1662
|
-
this.
|
|
1690
|
+
if (this.i === 0 && this.f[0])
|
|
1691
|
+
this.f[0].dispose();
|
|
1663
1692
|
for (let i = this.i; i < newLen; i++) {
|
|
1664
|
-
this.
|
|
1665
|
-
this.
|
|
1693
|
+
this.h[i] = compute(
|
|
1694
|
+
this.f[i] = new Owner(),
|
|
1666
1695
|
() => this.G(i),
|
|
1667
1696
|
null
|
|
1668
1697
|
);
|
|
1669
1698
|
}
|
|
1670
1699
|
for (let i = newLen; i < this.i; i++)
|
|
1671
|
-
this.
|
|
1672
|
-
this.
|
|
1700
|
+
this.f[i].dispose();
|
|
1701
|
+
this.h = this.h.slice(0, newLen);
|
|
1673
1702
|
this.i = newLen;
|
|
1674
1703
|
}
|
|
1675
1704
|
});
|
|
1676
|
-
return this.
|
|
1705
|
+
return this.h;
|
|
1677
1706
|
}
|
|
1678
1707
|
function compare(key, a, b) {
|
|
1679
1708
|
return key ? key(a) === key(b) : true;
|
|
@@ -1712,8 +1741,9 @@ exports.getOwner = getOwner;
|
|
|
1712
1741
|
exports.hasContext = hasContext;
|
|
1713
1742
|
exports.hasUpdated = hasUpdated;
|
|
1714
1743
|
exports.isEqual = isEqual;
|
|
1715
|
-
exports.
|
|
1744
|
+
exports.isStale = isStale;
|
|
1716
1745
|
exports.isWrappable = isWrappable;
|
|
1746
|
+
exports.latest = latest;
|
|
1717
1747
|
exports.mapArray = mapArray;
|
|
1718
1748
|
exports.merge = merge;
|
|
1719
1749
|
exports.omit = omit;
|
|
@@ -1721,7 +1751,6 @@ exports.onCleanup = onCleanup;
|
|
|
1721
1751
|
exports.reconcile = reconcile;
|
|
1722
1752
|
exports.repeat = repeat;
|
|
1723
1753
|
exports.resolve = resolve;
|
|
1724
|
-
exports.resolveSync = resolveSync;
|
|
1725
1754
|
exports.runWithOwner = runWithOwner;
|
|
1726
1755
|
exports.setContext = setContext;
|
|
1727
1756
|
exports.untrack = untrack;
|