@solidjs/signals 0.2.2 → 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/prod.js CHANGED
@@ -43,42 +43,42 @@ function schedule() {
43
43
  if (scheduled)
44
44
  return;
45
45
  scheduled = true;
46
- if (!globalQueue.I)
46
+ if (!globalQueue.J)
47
47
  queueMicrotask(flushSync);
48
48
  }
49
49
  var Queue = class {
50
- I = false;
51
- r = [[], [], []];
52
- D = [];
50
+ J = false;
51
+ s = [[], [], []];
52
+ F = [];
53
53
  created = clock;
54
54
  enqueue(type, node) {
55
- this.r[0].push(node);
55
+ this.s[0].push(node);
56
56
  if (type)
57
- this.r[type].push(node);
57
+ this.s[type].push(node);
58
58
  schedule();
59
59
  }
60
60
  run(type) {
61
- if (this.r[type].length) {
61
+ if (this.s[type].length) {
62
62
  if (type === EFFECT_PURE) {
63
- runPureQueue(this.r[type]);
64
- this.r[type] = [];
63
+ runPureQueue(this.s[type]);
64
+ this.s[type] = [];
65
65
  } else {
66
- const effects = this.r[type];
67
- this.r[type] = [];
66
+ const effects = this.s[type];
67
+ this.s[type] = [];
68
68
  runEffectQueue(effects);
69
69
  }
70
70
  }
71
71
  let rerun = false;
72
- for (let i = 0; i < this.D.length; i++) {
73
- rerun = this.D[i].run(type) || rerun;
72
+ for (let i = 0; i < this.F.length; i++) {
73
+ rerun = this.F[i].run(type) || rerun;
74
74
  }
75
- if (type === EFFECT_PURE && this.r[type].length)
75
+ if (type === EFFECT_PURE && this.s[type].length)
76
76
  return true;
77
77
  }
78
78
  flush() {
79
- if (this.I)
79
+ if (this.J)
80
80
  return;
81
- this.I = true;
81
+ this.J = true;
82
82
  try {
83
83
  while (this.run(EFFECT_PURE)) {
84
84
  }
@@ -87,16 +87,16 @@ var Queue = class {
87
87
  this.run(EFFECT_RENDER);
88
88
  this.run(EFFECT_USER);
89
89
  } finally {
90
- this.I = false;
90
+ this.J = false;
91
91
  }
92
92
  }
93
93
  addChild(child) {
94
- this.D.push(child);
94
+ this.F.push(child);
95
95
  }
96
96
  removeChild(child) {
97
- const index = this.D.indexOf(child);
97
+ const index = this.F.indexOf(child);
98
98
  if (index >= 0)
99
- this.D.splice(index, 1);
99
+ this.F.splice(index, 1);
100
100
  }
101
101
  };
102
102
  var globalQueue = new Queue();
@@ -107,14 +107,14 @@ function flushSync() {
107
107
  }
108
108
  function runTop(node) {
109
109
  const ancestors = [];
110
- for (let current = node; current !== null; current = current.s) {
110
+ for (let current = node; current !== null; current = current.t) {
111
111
  if (current.a !== STATE_CLEAN) {
112
112
  ancestors.push(current);
113
113
  }
114
114
  }
115
115
  for (let i = ancestors.length - 1; i >= 0; i--) {
116
116
  if (ancestors[i].a !== STATE_DISPOSED)
117
- ancestors[i].y();
117
+ ancestors[i].z();
118
118
  }
119
119
  }
120
120
  function runPureQueue(queue) {
@@ -125,67 +125,13 @@ function runPureQueue(queue) {
125
125
  }
126
126
  function runEffectQueue(queue) {
127
127
  for (let i = 0; i < queue.length; i++)
128
- queue[i].T();
128
+ queue[i].U();
129
129
  }
130
130
 
131
131
  // src/core/utils.ts
132
132
  function isUndefined(value) {
133
133
  return typeof value === "undefined";
134
134
  }
135
- function flatten(children, options) {
136
- if (typeof children === "function" && !children.length) {
137
- if (options?.doNotUnwrap)
138
- return children;
139
- do {
140
- children = children();
141
- } while (typeof children === "function" && !children.length);
142
- }
143
- if (options?.skipNonRendered && (children == null || children === true || children === false || children === ""))
144
- return;
145
- if (Array.isArray(children)) {
146
- let results = [];
147
- if (flattenArray(children, results, options)) {
148
- return () => {
149
- let nested = [];
150
- flattenArray(results, nested, { ...options, doNotUnwrap: false });
151
- return nested;
152
- };
153
- }
154
- return results;
155
- }
156
- return children;
157
- }
158
- function flattenArray(children, results = [], options) {
159
- let notReady = null;
160
- let needsUnwrap = false;
161
- for (let i = 0; i < children.length; i++) {
162
- try {
163
- let child = children[i];
164
- if (typeof child === "function" && !child.length) {
165
- if (options?.doNotUnwrap) {
166
- results.push(child);
167
- needsUnwrap = true;
168
- continue;
169
- }
170
- do {
171
- child = child();
172
- } while (typeof child === "function" && !child.length);
173
- }
174
- if (Array.isArray(child)) {
175
- needsUnwrap = flattenArray(child, results, options);
176
- } else if (options?.skipNonRendered && (child == null || child === true || child === false || child === "")) {
177
- } else
178
- results.push(child);
179
- } catch (e) {
180
- if (!(e instanceof NotReadyError))
181
- throw e;
182
- notReady = e;
183
- }
184
- }
185
- if (notReady)
186
- throw notReady;
187
- return needsUnwrap;
188
- }
189
135
 
190
136
  // src/core/owner.ts
191
137
  var currentOwner = null;
@@ -202,9 +148,9 @@ var Owner = class {
202
148
  // We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild
203
149
  // However, the children are actually added in reverse creation order
204
150
  // See comment at the top of the file for an example of the _nextSibling traversal
205
- s = null;
206
- n = null;
207
151
  t = null;
152
+ n = null;
153
+ u = null;
208
154
  a = STATE_CLEAN;
209
155
  l = null;
210
156
  p = defaultContext;
@@ -215,10 +161,10 @@ var Owner = class {
215
161
  currentOwner.append(this);
216
162
  }
217
163
  append(child) {
218
- child.s = this;
219
164
  child.t = this;
165
+ child.u = this;
220
166
  if (this.n)
221
- this.n.t = child;
167
+ this.n.u = child;
222
168
  child.n = this.n;
223
169
  this.n = child;
224
170
  if (child.p !== this.p) {
@@ -233,26 +179,26 @@ var Owner = class {
233
179
  dispose(self = true) {
234
180
  if (this.a === STATE_DISPOSED)
235
181
  return;
236
- let head = self ? this.t || this.s : this, current = this.n, next = null;
237
- while (current && current.s === this) {
182
+ let head = self ? this.u || this.t : this, current = this.n, next = null;
183
+ while (current && current.t === this) {
238
184
  current.dispose(true);
239
- current.z();
185
+ current.A();
240
186
  next = current.n;
241
187
  current.n = null;
242
188
  current = next;
243
189
  }
244
190
  if (self)
245
- this.z();
191
+ this.A();
246
192
  if (current)
247
- current.t = !self ? this : this.t;
193
+ current.u = !self ? this : this.u;
248
194
  if (head)
249
195
  head.n = current;
250
196
  }
251
- z() {
252
- if (this.t)
253
- this.t.n = null;
254
- this.s = null;
197
+ A() {
198
+ if (this.u)
199
+ this.u.n = null;
255
200
  this.t = null;
201
+ this.u = null;
256
202
  this.p = defaultContext;
257
203
  this.m = null;
258
204
  this.a = STATE_DISPOSED;
@@ -350,48 +296,48 @@ function getObserver() {
350
296
  var UNCHANGED = Symbol(0);
351
297
  var Computation = class extends Owner {
352
298
  b = null;
353
- c = null;
354
- e;
355
- E;
356
- A;
299
+ e = null;
300
+ g;
301
+ G;
302
+ B;
357
303
  // Used in __DEV__ mode, hopefully removed in production
358
- Z;
304
+ $;
359
305
  // Using false is an optimization as an alternative to _equals: () => false
360
306
  // which could enable more efficient DIRTY notification
361
- N = isEqual;
362
- U;
307
+ O = isEqual;
308
+ V;
363
309
  /** Whether the computation is an error or has ancestors that are unresolved */
364
- d = 0;
310
+ f = 0;
365
311
  /** Which flags raised by sources are handled, vs. being passed through. */
366
- O = DEFAULT_FLAGS;
367
- P = null;
368
- x = -1;
369
- J = false;
312
+ P = DEFAULT_FLAGS;
313
+ Q = null;
314
+ y = -1;
315
+ K = false;
370
316
  constructor(initialValue, compute2, options) {
371
317
  super(compute2 === null);
372
- this.A = compute2;
318
+ this.B = compute2;
373
319
  this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
374
- this.d = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
375
- this.e = initialValue;
320
+ this.f = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
321
+ this.g = initialValue;
376
322
  if (options?.equals !== void 0)
377
- this.N = options.equals;
323
+ this.O = options.equals;
378
324
  if (options?.unobserved)
379
- this.U = options?.unobserved;
325
+ this.V = options?.unobserved;
380
326
  }
381
- V() {
382
- if (this.A) {
383
- if (this.d & ERROR_BIT && this.x <= getClock())
327
+ W() {
328
+ if (this.B) {
329
+ if (this.f & ERROR_BIT && this.y <= getClock())
384
330
  update(this);
385
331
  else
386
- this.y();
332
+ this.z();
387
333
  }
388
- if (!this.A || this.b?.length)
334
+ if (!this.B || this.b?.length)
389
335
  track(this);
390
- newFlags |= this.d & ~currentMask;
391
- if (this.d & ERROR_BIT) {
392
- throw this.E;
336
+ newFlags |= this.f & ~currentMask;
337
+ if (this.f & ERROR_BIT) {
338
+ throw this.G;
393
339
  } else {
394
- return this.e;
340
+ return this.g;
395
341
  }
396
342
  }
397
343
  /**
@@ -399,7 +345,7 @@ var Computation = class extends Owner {
399
345
  * Automatically re-executes the surrounding computation when the value changes
400
346
  */
401
347
  read() {
402
- return this.V();
348
+ return this.W();
403
349
  }
404
350
  /**
405
351
  * Return the current value of this computation
@@ -409,15 +355,15 @@ var Computation = class extends Owner {
409
355
  * before continuing
410
356
  */
411
357
  wait() {
412
- if (this.A && this.d & ERROR_BIT && this.x <= getClock()) {
358
+ if (this.B && this.f & ERROR_BIT && this.y <= getClock()) {
413
359
  update(this);
414
360
  }
415
- if ((notStale || this.d & UNINITIALIZED_BIT) && this.loading()) {
361
+ if ((notStale || this.f & UNINITIALIZED_BIT) && this.loading()) {
416
362
  throw new NotReadyError();
417
363
  }
418
364
  if (staleCheck && this.loading())
419
- staleCheck.e = true;
420
- return this.V();
365
+ staleCheck.g = true;
366
+ return this.W();
421
367
  }
422
368
  /**
423
369
  * Return true if the computation is the value is dependent on an unresolved promise
@@ -427,44 +373,44 @@ var Computation = class extends Owner {
427
373
  * loading state changes
428
374
  */
429
375
  loading() {
430
- if (this.P === null) {
431
- this.P = loadingState(this);
376
+ if (this.Q === null) {
377
+ this.Q = loadingState(this);
432
378
  }
433
- return this.P.read();
379
+ return this.Q.read();
434
380
  }
435
381
  /** Update the computation with a new value. */
436
382
  write(value, flags = 0, raw = false) {
437
- const newValue = !raw && typeof value === "function" ? value(this.e) : value;
438
- const valueChanged = newValue !== UNCHANGED && (!!(this.d & UNINITIALIZED_BIT) || this.N === false || !this.N(this.e, newValue));
383
+ const newValue = !raw && typeof value === "function" ? value(this.g) : value;
384
+ const valueChanged = newValue !== UNCHANGED && (!!(this.f & UNINITIALIZED_BIT) || this.O === false || !this.O(this.g, newValue));
439
385
  if (valueChanged) {
440
- this.e = newValue;
441
- this.E = void 0;
442
- }
443
- const changedFlagsMask = this.d ^ flags, changedFlags = changedFlagsMask & flags;
444
- this.d = flags;
445
- this.x = getClock() + 1;
446
- if (this.c) {
447
- for (let i = 0; i < this.c.length; i++) {
386
+ this.g = newValue;
387
+ this.G = void 0;
388
+ }
389
+ const changedFlagsMask = this.f ^ flags, changedFlags = changedFlagsMask & flags;
390
+ this.f = flags;
391
+ this.y = getClock() + 1;
392
+ if (this.e) {
393
+ for (let i = 0; i < this.e.length; i++) {
448
394
  if (valueChanged) {
449
- this.c[i].q(STATE_DIRTY);
395
+ this.e[i].q(STATE_DIRTY);
450
396
  } else if (changedFlagsMask) {
451
- this.c[i].W(changedFlagsMask, changedFlags);
397
+ this.e[i].X(changedFlagsMask, changedFlags);
452
398
  }
453
399
  }
454
400
  }
455
- return this.e;
401
+ return this.g;
456
402
  }
457
403
  /**
458
404
  * Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
459
405
  */
460
406
  q(state, skipQueue) {
461
- if (this.a >= state && !this.J)
407
+ if (this.a >= state && !this.K)
462
408
  return;
463
- this.J = !!skipQueue;
409
+ this.K = !!skipQueue;
464
410
  this.a = state;
465
- if (this.c) {
466
- for (let i = 0; i < this.c.length; i++) {
467
- this.c[i].q(STATE_CHECK, skipQueue);
411
+ if (this.e) {
412
+ for (let i = 0; i < this.e.length; i++) {
413
+ this.e[i].q(STATE_CHECK, skipQueue);
468
414
  }
469
415
  }
470
416
  }
@@ -474,31 +420,31 @@ var Computation = class extends Owner {
474
420
  * @param mask A bitmask for which flag(s) were changed.
475
421
  * @param newFlags The source's new flags, masked to just the changed ones.
476
422
  */
477
- W(mask, newFlags2) {
423
+ X(mask, newFlags2) {
478
424
  if (this.a >= STATE_DIRTY)
479
425
  return;
480
- if (mask & this.O) {
426
+ if (mask & this.P) {
481
427
  this.q(STATE_DIRTY);
482
428
  return;
483
429
  }
484
430
  if (this.a >= STATE_CHECK)
485
431
  return;
486
- const prevFlags = this.d & mask;
432
+ const prevFlags = this.f & mask;
487
433
  const deltaFlags = prevFlags ^ newFlags2;
488
434
  if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
489
435
  this.q(STATE_CHECK);
490
436
  } else {
491
- this.d ^= deltaFlags;
492
- if (this.c) {
493
- for (let i = 0; i < this.c.length; i++) {
494
- this.c[i].W(mask, newFlags2);
437
+ this.f ^= deltaFlags;
438
+ if (this.e) {
439
+ for (let i = 0; i < this.e.length; i++) {
440
+ this.e[i].X(mask, newFlags2);
495
441
  }
496
442
  }
497
443
  }
498
444
  }
499
- F(error) {
500
- this.E = error;
501
- this.write(UNCHANGED, this.d & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
445
+ H(error) {
446
+ this.G = error;
447
+ this.write(UNCHANGED, this.f & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
502
448
  }
503
449
  /**
504
450
  * This is the core part of the reactivity system, which makes sure that the values are updated
@@ -507,7 +453,7 @@ var Computation = class extends Owner {
507
453
  *
508
454
  * This function will ensure that the value and states we read from the computation are up to date
509
455
  */
510
- y() {
456
+ z() {
511
457
  if (this.a === STATE_DISPOSED) {
512
458
  throw new Error("Tried to read a disposed computation");
513
459
  }
@@ -517,8 +463,8 @@ var Computation = class extends Owner {
517
463
  let observerFlags = 0;
518
464
  if (this.a === STATE_CHECK) {
519
465
  for (let i = 0; i < this.b.length; i++) {
520
- this.b[i].y();
521
- observerFlags |= this.b[i].d;
466
+ this.b[i].z();
467
+ observerFlags |= this.b[i].f;
522
468
  if (this.a === STATE_DIRTY) {
523
469
  break;
524
470
  }
@@ -534,27 +480,27 @@ var Computation = class extends Owner {
534
480
  /**
535
481
  * Remove ourselves from the owner graph and the computation graph
536
482
  */
537
- z() {
483
+ A() {
538
484
  if (this.a === STATE_DISPOSED)
539
485
  return;
540
486
  if (this.b)
541
487
  removeSourceObservers(this, 0);
542
- super.z();
488
+ super.A();
543
489
  }
544
490
  };
545
491
  function loadingState(node) {
546
- const prevOwner = setOwner(node.s);
492
+ const prevOwner = setOwner(node.t);
547
493
  const options = void 0;
548
494
  const computation = new Computation(
549
495
  void 0,
550
496
  () => {
551
497
  track(node);
552
- node.y();
553
- return !!(node.d & LOADING_BIT);
498
+ node.z();
499
+ return !!(node.f & LOADING_BIT);
554
500
  },
555
501
  options
556
502
  );
557
- computation.O = ERROR_BIT | LOADING_BIT;
503
+ computation.P = ERROR_BIT | LOADING_BIT;
558
504
  setOwner(prevOwner);
559
505
  return computation;
560
506
  }
@@ -568,7 +514,7 @@ function track(computation) {
568
514
  newSources.push(computation);
569
515
  }
570
516
  if (updateCheck) {
571
- updateCheck.e = computation.x > currentObserver.x;
517
+ updateCheck.g = computation.y > currentObserver.y;
572
518
  }
573
519
  }
574
520
  }
@@ -580,13 +526,13 @@ function update(node) {
580
526
  try {
581
527
  node.dispose(false);
582
528
  node.emptyDisposal();
583
- const result = compute(node, node.A, node);
529
+ const result = compute(node, node.B, node);
584
530
  node.write(result, newFlags, true);
585
531
  } catch (error) {
586
532
  if (error instanceof NotReadyError) {
587
- node.write(UNCHANGED, newFlags | LOADING_BIT | node.d & UNINITIALIZED_BIT);
533
+ node.write(UNCHANGED, newFlags | LOADING_BIT | node.f & UNINITIALIZED_BIT);
588
534
  } else {
589
- node.F(error);
535
+ node.H(error);
590
536
  }
591
537
  } finally {
592
538
  if (newSources) {
@@ -603,10 +549,10 @@ function update(node) {
603
549
  let source;
604
550
  for (let i = newSourcesIndex; i < node.b.length; i++) {
605
551
  source = node.b[i];
606
- if (!source.c)
607
- source.c = [node];
552
+ if (!source.e)
553
+ source.e = [node];
608
554
  else
609
- source.c.push(node);
555
+ source.e.push(node);
610
556
  }
611
557
  } else if (node.b && newSourcesIndex < node.b.length) {
612
558
  removeSourceObservers(node, newSourcesIndex);
@@ -615,7 +561,7 @@ function update(node) {
615
561
  newSources = prevSources;
616
562
  newSourcesIndex = prevSourcesIndex;
617
563
  newFlags = prevFlags;
618
- node.x = getClock() + 1;
564
+ node.y = getClock() + 1;
619
565
  node.a = STATE_CLEAN;
620
566
  }
621
567
  }
@@ -624,12 +570,12 @@ function removeSourceObservers(node, index) {
624
570
  let swap;
625
571
  for (let i = index; i < node.b.length; i++) {
626
572
  source = node.b[i];
627
- if (source.c) {
628
- swap = source.c.indexOf(node);
629
- source.c[swap] = source.c[source.c.length - 1];
630
- source.c.pop();
631
- if (!source.c.length)
632
- source.U?.();
573
+ if (source.e) {
574
+ swap = source.e.indexOf(node);
575
+ source.e[swap] = source.e[source.e.length - 1];
576
+ source.e.pop();
577
+ if (!source.e.length)
578
+ source.V?.();
633
579
  }
634
580
  }
635
581
  }
@@ -643,10 +589,10 @@ function untrack(fn) {
643
589
  }
644
590
  function hasUpdated(fn) {
645
591
  const current = updateCheck;
646
- updateCheck = { e: false };
592
+ updateCheck = { g: false };
647
593
  try {
648
594
  fn();
649
- return updateCheck.e;
595
+ return updateCheck.g;
650
596
  } finally {
651
597
  updateCheck = current;
652
598
  }
@@ -654,10 +600,10 @@ function hasUpdated(fn) {
654
600
  function isPending(fn, loadingValue) {
655
601
  const argLength = arguments.length;
656
602
  const current = staleCheck;
657
- staleCheck = { e: false };
603
+ staleCheck = { g: false };
658
604
  try {
659
605
  latest(fn);
660
- return staleCheck.e;
606
+ return staleCheck.g;
661
607
  } catch (err) {
662
608
  if (!(err instanceof NotReadyError))
663
609
  return false;
@@ -704,10 +650,10 @@ function runWithObserver(observer, run) {
704
650
  if (error instanceof NotReadyError) {
705
651
  observer.write(
706
652
  UNCHANGED,
707
- newFlags | LOADING_BIT | observer.d & UNINITIALIZED_BIT
653
+ newFlags | LOADING_BIT | observer.f & UNINITIALIZED_BIT
708
654
  );
709
655
  } else {
710
- observer.F(error);
656
+ observer.H(error);
711
657
  }
712
658
  } finally {
713
659
  if (newSources) {
@@ -722,10 +668,10 @@ function runWithObserver(observer, run) {
722
668
  let source;
723
669
  for (let i = newSourcesIndex; i < observer.b.length; i++) {
724
670
  source = observer.b[i];
725
- if (!source.c)
726
- source.c = [observer];
671
+ if (!source.e)
672
+ source.e = [observer];
727
673
  else
728
- source.c.push(observer);
674
+ source.e.push(observer);
729
675
  }
730
676
  }
731
677
  newSources = prevSources;
@@ -736,10 +682,10 @@ function runWithObserver(observer, run) {
736
682
  function compute(owner, fn, observer) {
737
683
  const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
738
684
  currentObserver = observer;
739
- currentMask = observer?.O ?? DEFAULT_FLAGS;
685
+ currentMask = observer?.P ?? DEFAULT_FLAGS;
740
686
  notStale = true;
741
687
  try {
742
- return fn(observer ? observer.e : void 0);
688
+ return fn(observer ? observer.g : void 0);
743
689
  } finally {
744
690
  setOwner(prevOwner);
745
691
  currentObserver = prevObserver;
@@ -747,6 +693,68 @@ function compute(owner, fn, observer) {
747
693
  notStale = prevNotStale;
748
694
  }
749
695
  }
696
+ function flatten(children, options) {
697
+ try {
698
+ if (typeof children === "function" && !children.length) {
699
+ if (options?.doNotUnwrap)
700
+ return children;
701
+ do {
702
+ children = children();
703
+ } while (typeof children === "function" && !children.length);
704
+ }
705
+ if (options?.skipNonRendered && (children == null || children === true || children === false || children === ""))
706
+ return;
707
+ if (Array.isArray(children)) {
708
+ let results = [];
709
+ if (flattenArray(children, results, options)) {
710
+ return () => {
711
+ let nested = [];
712
+ flattenArray(results, nested, { ...options, doNotUnwrap: false });
713
+ return nested;
714
+ };
715
+ }
716
+ return results;
717
+ }
718
+ return children;
719
+ } catch (e) {
720
+ if (options?.skipNonRendered && e instanceof NotReadyError) {
721
+ newFlags |= LOADING_BIT;
722
+ return void 0;
723
+ }
724
+ throw e;
725
+ }
726
+ }
727
+ function flattenArray(children, results = [], options) {
728
+ let notReady = null;
729
+ let needsUnwrap = false;
730
+ for (let i = 0; i < children.length; i++) {
731
+ try {
732
+ let child = children[i];
733
+ if (typeof child === "function" && !child.length) {
734
+ if (options?.doNotUnwrap) {
735
+ results.push(child);
736
+ needsUnwrap = true;
737
+ continue;
738
+ }
739
+ do {
740
+ child = child();
741
+ } while (typeof child === "function" && !child.length);
742
+ }
743
+ if (Array.isArray(child)) {
744
+ needsUnwrap = flattenArray(child, results, options);
745
+ } else if (options?.skipNonRendered && (child == null || child === true || child === false || child === "")) {
746
+ } else
747
+ results.push(child);
748
+ } catch (e) {
749
+ if (!(e instanceof NotReadyError))
750
+ throw e;
751
+ notReady = e;
752
+ }
753
+ }
754
+ if (notReady)
755
+ throw notReady;
756
+ return needsUnwrap;
757
+ }
750
758
  function createBoundary(fn, queue) {
751
759
  const owner = new Owner();
752
760
  const parentQueue = owner.h;
@@ -757,80 +765,80 @@ function createBoundary(fn, queue) {
757
765
 
758
766
  // src/core/effect.ts
759
767
  var Effect = class extends Computation {
760
- K;
761
768
  L;
762
- B;
763
- Q = false;
764
769
  M;
765
- u;
770
+ C;
771
+ R = false;
772
+ N;
773
+ w;
766
774
  constructor(initialValue, compute2, effect, error, options) {
767
775
  super(initialValue, compute2, options);
768
- this.K = effect;
769
- this.L = error;
770
- this.M = initialValue;
771
- this.u = options?.render ? EFFECT_RENDER : EFFECT_USER;
772
- if (this.u === EFFECT_RENDER) {
773
- this.A = (p) => getClock() > this.h.created ? latest(() => compute2(p)) : compute2(p);
776
+ this.L = effect;
777
+ this.M = error;
778
+ this.N = initialValue;
779
+ this.w = options?.render ? EFFECT_RENDER : EFFECT_USER;
780
+ if (this.w === EFFECT_RENDER) {
781
+ this.B = (p) => getClock() > this.h.created && !(this.f & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
774
782
  }
775
- this.y();
776
- !options?.defer && (this.u === EFFECT_USER ? this.h.enqueue(this.u, this) : this.T());
783
+ this.z();
784
+ !options?.defer && (this.w === EFFECT_USER ? this.h.enqueue(this.w, this) : this.U());
777
785
  }
778
786
  write(value, flags = 0) {
779
787
  if (this.a == STATE_DIRTY) {
780
- const currentFlags = this.d;
781
- this.d = flags;
782
- if (this.u === EFFECT_RENDER && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
783
- this.h.R?.(this);
788
+ const currentFlags = this.f;
789
+ this.f = flags;
790
+ if (this.w === EFFECT_RENDER && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
791
+ this.h.S?.(this);
784
792
  }
785
793
  }
786
794
  if (value === UNCHANGED)
787
- return this.e;
788
- this.e = value;
789
- this.Q = true;
795
+ return this.g;
796
+ this.g = value;
797
+ this.R = true;
790
798
  return value;
791
799
  }
792
800
  q(state, skipQueue) {
793
801
  if (this.a >= state || skipQueue)
794
802
  return;
795
803
  if (this.a === STATE_CLEAN)
796
- this.h.enqueue(this.u, this);
804
+ this.h.enqueue(this.w, this);
797
805
  this.a = state;
798
806
  }
799
- F(error) {
800
- this.B?.();
801
- if (this.d & LOADING_BIT) {
802
- this.d = 0;
803
- this.h.R?.(this);
807
+ H(error) {
808
+ this.C?.();
809
+ if (this.f & LOADING_BIT) {
810
+ this.h.S?.(this);
804
811
  }
805
- if (this.u === EFFECT_USER) {
812
+ this.f = ERROR_BIT;
813
+ if (this.w === EFFECT_USER) {
806
814
  try {
807
- return this.L ? this.B = this.L(error) : console.error(new EffectError(this.K, error));
815
+ return this.M ? this.C = this.M(error) : console.error(new EffectError(this.L, error));
808
816
  } catch (e) {
809
817
  error = e;
810
818
  }
811
819
  }
812
820
  this.handleError(error);
813
821
  }
814
- z() {
822
+ A() {
815
823
  if (this.a === STATE_DISPOSED)
816
824
  return;
817
- this.K = void 0;
818
- this.M = void 0;
819
825
  this.L = void 0;
820
- this.B?.();
821
- this.B = void 0;
822
- super.z();
826
+ this.N = void 0;
827
+ this.M = void 0;
828
+ this.C?.();
829
+ this.C = void 0;
830
+ super.A();
823
831
  }
824
- T() {
825
- if (this.Q && this.a !== STATE_DISPOSED) {
826
- this.B?.();
832
+ U() {
833
+ if (this.R && this.a !== STATE_DISPOSED) {
834
+ this.C?.();
827
835
  try {
828
- this.B = this.K(this.e, this.M);
836
+ this.C = this.L(this.g, this.N);
829
837
  } catch (e) {
830
838
  this.handleError(e);
831
839
  } finally {
832
- this.M = this.e;
833
- this.Q = false;
840
+ this.N = this.g;
841
+ this.R = false;
834
842
  }
835
843
  }
836
844
  }
@@ -838,10 +846,10 @@ var Effect = class extends Computation {
838
846
  var EagerComputation = class extends Computation {
839
847
  constructor(initialValue, compute2, options) {
840
848
  super(initialValue, compute2, options);
841
- !options?.defer && this.y();
849
+ !options?.defer && this.z();
842
850
  }
843
851
  q(state, skipQueue) {
844
- if (this.a >= state && !this.J)
852
+ if (this.a >= state && !this.K)
845
853
  return;
846
854
  if (this.a === STATE_CLEAN && !skipQueue)
847
855
  this.h.enqueue(EFFECT_PURE, this);
@@ -853,7 +861,7 @@ var ProjectionComputation = class extends Computation {
853
861
  super(null, compute2);
854
862
  }
855
863
  q(state, skipQueue) {
856
- if (this.a >= state && !this.J)
864
+ if (this.a >= state && !this.K)
857
865
  return;
858
866
  if (this.a === STATE_CLEAN && !skipQueue)
859
867
  this.h.enqueue(EFFECT_PURE, this);
@@ -863,39 +871,39 @@ var ProjectionComputation = class extends Computation {
863
871
 
864
872
  // src/core/suspense.ts
865
873
  var SuspenseQueue = class extends Queue {
866
- f = /* @__PURE__ */ new Set();
874
+ c = /* @__PURE__ */ new Set();
867
875
  o = false;
868
- S = new Computation(false, null);
876
+ T = new Computation(false, null);
869
877
  run(type) {
870
878
  if (type && this.o)
871
879
  return;
872
880
  return super.run(type);
873
881
  }
874
- R(node) {
875
- if (node.d & LOADING_BIT) {
876
- this.f.add(node);
882
+ S(node) {
883
+ if (node.f & LOADING_BIT) {
884
+ this.c.add(node);
877
885
  if (!this.o) {
878
886
  this.o = true;
879
- this.S.write(true);
887
+ this.T.write(true);
880
888
  }
881
889
  } else {
882
- this.f.delete(node);
883
- if (this.f.size === 0) {
890
+ this.c.delete(node);
891
+ if (this.c.size === 0) {
884
892
  this.o = false;
885
- this.S.write(false);
893
+ this.T.write(false);
886
894
  }
887
895
  }
888
896
  }
889
897
  };
890
898
  var LiveComputation = class extends EagerComputation {
891
899
  write(value, flags = 0) {
892
- const currentFlags = this.d;
900
+ const currentFlags = this.f;
893
901
  const dirty = this.a === STATE_DIRTY;
894
902
  super.write(value, flags);
895
903
  if (dirty && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
896
- this.h.R?.(this);
904
+ this.h.S?.(this);
897
905
  }
898
- return this.e;
906
+ return this.g;
899
907
  }
900
908
  };
901
909
  function createSuspense(fn, fallback) {
@@ -904,7 +912,7 @@ function createSuspense(fn, fallback) {
904
912
  const child = new Computation(null, fn);
905
913
  return new LiveComputation(null, () => flatten(child.wait()));
906
914
  }, queue);
907
- const equality = new Computation(null, () => queue.S.read() || queue.o);
915
+ const equality = new Computation(null, () => queue.T.read() || queue.o);
908
916
  const comp = new Computation(null, () => equality.read() ? fallback() : tree.read());
909
917
  return comp.read.bind(comp);
910
918
  }
@@ -935,10 +943,10 @@ function createMemo(compute2, value, options) {
935
943
  return () => {
936
944
  if (node) {
937
945
  resolvedValue = node.wait();
938
- if (!node.b?.length && node.n?.s !== node) {
946
+ if (!node.b?.length && node.n?.t !== node) {
939
947
  node.dispose();
940
948
  node = void 0;
941
- } else if (!node.s && !node.c?.length) {
949
+ } else if (!node.t && !node.e?.length) {
942
950
  node.dispose();
943
951
  node.a = STATE_DIRTY;
944
952
  }
@@ -950,10 +958,10 @@ function createAsync(compute2, value, options) {
950
958
  let uninitialized = value === void 0;
951
959
  const lhs = new EagerComputation(
952
960
  {
953
- e: value
961
+ g: value
954
962
  },
955
963
  (p) => {
956
- const value2 = p?.e;
964
+ const value2 = p?.g;
957
965
  const source = compute2(value2);
958
966
  const isPromise = source instanceof Promise;
959
967
  const iterator = source[Symbol.asyncIterator];
@@ -962,13 +970,13 @@ function createAsync(compute2, value, options) {
962
970
  wait() {
963
971
  return source;
964
972
  },
965
- e: source
973
+ g: source
966
974
  };
967
975
  }
968
976
  const signal = new Computation(value2, null, options);
969
977
  const w = signal.wait;
970
978
  signal.wait = function() {
971
- if (signal.d & ERROR_BIT && signal.x <= getClock()) {
979
+ if (signal.f & ERROR_BIT && signal.y <= getClock()) {
972
980
  lhs.q(STATE_DIRTY);
973
981
  throw new NotReadyError();
974
982
  }
@@ -983,7 +991,7 @@ function createAsync(compute2, value, options) {
983
991
  },
984
992
  (error) => {
985
993
  uninitialized = true;
986
- signal.F(error);
994
+ signal.H(error);
987
995
  }
988
996
  );
989
997
  } else {
@@ -1046,7 +1054,7 @@ function createErrorBoundary(fn, fallback) {
1046
1054
  );
1047
1055
  nodes.add(node);
1048
1056
  if (nodes.size === 1)
1049
- error.write({ E: err });
1057
+ error.write({ G: err });
1050
1058
  }
1051
1059
  owner.m = owner.m ? [handler, ...owner.m] : [handler];
1052
1060
  const guarded = compute(
@@ -1054,7 +1062,7 @@ function createErrorBoundary(fn, fallback) {
1054
1062
  () => {
1055
1063
  const c = new Computation(void 0, fn);
1056
1064
  const f = new EagerComputation(void 0, () => flatten(c.read()), { defer: true });
1057
- f.F = function(error2) {
1065
+ f.H = function(error2) {
1058
1066
  this.handleError(error2);
1059
1067
  };
1060
1068
  return f;
@@ -1067,11 +1075,11 @@ function createErrorBoundary(fn, fallback) {
1067
1075
  if (!error.read())
1068
1076
  return resolved;
1069
1077
  }
1070
- return fallback(error.read().E, () => {
1078
+ return fallback(error.read().G, () => {
1071
1079
  incrementClock();
1072
1080
  for (let node of nodes) {
1073
1081
  node.a = STATE_DIRTY;
1074
- node.h?.enqueue(node.u, node);
1082
+ node.h?.enqueue(node.w, node);
1075
1083
  }
1076
1084
  });
1077
1085
  });
@@ -1096,12 +1104,15 @@ function resolve(fn) {
1096
1104
 
1097
1105
  // src/store/projection.ts
1098
1106
  function createProjection(fn, initialValue = {}) {
1099
- const [store, setStore] = createStore(initialValue);
1107
+ const [store] = createStore(fn, initialValue);
1108
+ return store;
1109
+ }
1110
+ function wrapProjection(fn, store, setStore) {
1100
1111
  const node = new ProjectionComputation(() => {
1101
1112
  setStore(fn);
1102
1113
  });
1103
1114
  const wrapped = /* @__PURE__ */ new WeakMap();
1104
- return wrap(store, node, wrapped);
1115
+ return [wrap(store, node, wrapped), setStore];
1105
1116
  }
1106
1117
  function wrap(source, node, wrapped) {
1107
1118
  if (wrapped.has(source))
@@ -1239,7 +1250,7 @@ var proxyTraps = {
1239
1250
  return desc.get.call(receiver);
1240
1251
  }
1241
1252
  if (Writing.has(storeValue)) {
1242
- const value2 = tracked ? tracked.e : storeValue[property];
1253
+ const value2 = tracked ? tracked.g : storeValue[property];
1243
1254
  return isWrappable(value2) ? (Writing.add(value2[$RAW] || value2), wrap2(value2)) : value2;
1244
1255
  }
1245
1256
  let value = tracked ? nodes[property].read() : storeValue[property];
@@ -1299,10 +1310,8 @@ function setProperty(state, property, value, deleting = false) {
1299
1310
  }
1300
1311
  function createStore(first, second) {
1301
1312
  const derived = typeof first === "function", store = derived ? second : first;
1302
- if (derived)
1303
- return createProjection(first, store);
1304
1313
  const unwrappedStore = unwrap(store, false);
1305
- const wrappedStore = wrap2(unwrappedStore);
1314
+ let wrappedStore = wrap2(unwrappedStore);
1306
1315
  const setStore = (fn) => {
1307
1316
  try {
1308
1317
  Writing.add(unwrappedStore);
@@ -1311,6 +1320,8 @@ function createStore(first, second) {
1311
1320
  Writing.clear();
1312
1321
  }
1313
1322
  };
1323
+ if (derived)
1324
+ return wrapProjection(first, wrappedStore, setStore);
1314
1325
  return [wrappedStore, setStore];
1315
1326
  }
1316
1327
 
@@ -1426,7 +1437,7 @@ function reconcile(value, key) {
1426
1437
  };
1427
1438
  }
1428
1439
 
1429
- // src/store/utilities.ts
1440
+ // src/store/utils.ts
1430
1441
  function trueFn() {
1431
1442
  return true;
1432
1443
  }
@@ -1578,73 +1589,73 @@ function omit(props, ...keys) {
1578
1589
  function mapArray(list, map, options) {
1579
1590
  const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
1580
1591
  return updateKeyedMap.bind({
1581
- G: new Owner(),
1592
+ I: new Owner(),
1582
1593
  i: 0,
1583
- X: list,
1584
- w: [],
1585
- H: map,
1586
- g: [],
1587
- f: [],
1588
- C: keyFn,
1594
+ Y: list,
1595
+ x: [],
1596
+ D: map,
1597
+ d: [],
1598
+ c: [],
1599
+ E: keyFn,
1589
1600
  j: keyFn || options?.keyed === false ? [] : void 0,
1590
1601
  k: map.length > 1 ? [] : void 0,
1591
1602
  o: options?.fallback
1592
1603
  });
1593
1604
  }
1594
1605
  function updateKeyedMap() {
1595
- const newItems = this.X() || [], newLen = newItems.length;
1606
+ const newItems = this.Y() || [], newLen = newItems.length;
1596
1607
  newItems[$TRACK];
1597
- runWithOwner(this.G, () => {
1608
+ runWithOwner(this.I, () => {
1598
1609
  let i, j, mapper = this.j ? () => {
1599
1610
  this.j[j] = new Computation(newItems[j], null);
1600
1611
  this.k && (this.k[j] = new Computation(j, null));
1601
- return this.H(
1612
+ return this.D(
1602
1613
  Computation.prototype.read.bind(this.j[j]),
1603
1614
  this.k ? Computation.prototype.read.bind(this.k[j]) : void 0
1604
1615
  );
1605
1616
  } : this.k ? () => {
1606
1617
  const item = newItems[j];
1607
1618
  this.k[j] = new Computation(j, null);
1608
- return this.H(() => item, Computation.prototype.read.bind(this.k[j]));
1619
+ return this.D(() => item, Computation.prototype.read.bind(this.k[j]));
1609
1620
  } : () => {
1610
1621
  const item = newItems[j];
1611
- return this.H(() => item);
1622
+ return this.D(() => item);
1612
1623
  };
1613
1624
  if (newLen === 0) {
1614
1625
  if (this.i !== 0) {
1615
- this.G.dispose(false);
1616
- this.f = [];
1617
- this.w = [];
1618
- this.g = [];
1626
+ this.I.dispose(false);
1627
+ this.c = [];
1628
+ this.x = [];
1629
+ this.d = [];
1619
1630
  this.i = 0;
1620
1631
  this.j && (this.j = []);
1621
1632
  this.k && (this.k = []);
1622
1633
  }
1623
- if (this.o && !this.g[0]) {
1624
- this.g[0] = compute(
1625
- this.f[0] = new Owner(),
1634
+ if (this.o && !this.d[0]) {
1635
+ this.d[0] = compute(
1636
+ this.c[0] = new Owner(),
1626
1637
  this.o,
1627
1638
  null
1628
1639
  );
1629
1640
  }
1630
1641
  } else if (this.i === 0) {
1631
- if (this.f[0])
1632
- this.f[0].dispose();
1633
- this.g = new Array(newLen);
1642
+ if (this.c[0])
1643
+ this.c[0].dispose();
1644
+ this.d = new Array(newLen);
1634
1645
  for (j = 0; j < newLen; j++) {
1635
- this.w[j] = newItems[j];
1636
- this.g[j] = compute(this.f[j] = new Owner(), mapper, null);
1646
+ this.x[j] = newItems[j];
1647
+ this.d[j] = compute(this.c[j] = new Owner(), mapper, null);
1637
1648
  }
1638
1649
  this.i = newLen;
1639
1650
  } else {
1640
1651
  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;
1641
- 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++) {
1652
+ 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++) {
1642
1653
  if (this.j)
1643
1654
  this.j[start].write(newItems[start]);
1644
1655
  }
1645
- 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--) {
1646
- temp[newEnd] = this.g[end];
1647
- tempNodes[newEnd] = this.f[end];
1656
+ 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--) {
1657
+ temp[newEnd] = this.d[end];
1658
+ tempNodes[newEnd] = this.c[end];
1648
1659
  tempRows && (tempRows[newEnd] = this.j[end]);
1649
1660
  tempIndexes && (tempIndexes[newEnd] = this.k[end]);
1650
1661
  }
@@ -1652,29 +1663,29 @@ function updateKeyedMap() {
1652
1663
  newIndicesNext = new Array(newEnd + 1);
1653
1664
  for (j = newEnd; j >= start; j--) {
1654
1665
  item = newItems[j];
1655
- key = this.C ? this.C(item) : item;
1666
+ key = this.E ? this.E(item) : item;
1656
1667
  i = newIndices.get(key);
1657
1668
  newIndicesNext[j] = i === void 0 ? -1 : i;
1658
1669
  newIndices.set(key, j);
1659
1670
  }
1660
1671
  for (i = start; i <= end; i++) {
1661
- item = this.w[i];
1662
- key = this.C ? this.C(item) : item;
1672
+ item = this.x[i];
1673
+ key = this.E ? this.E(item) : item;
1663
1674
  j = newIndices.get(key);
1664
1675
  if (j !== void 0 && j !== -1) {
1665
- temp[j] = this.g[i];
1666
- tempNodes[j] = this.f[i];
1676
+ temp[j] = this.d[i];
1677
+ tempNodes[j] = this.c[i];
1667
1678
  tempRows && (tempRows[j] = this.j[i]);
1668
1679
  tempIndexes && (tempIndexes[j] = this.k[i]);
1669
1680
  j = newIndicesNext[j];
1670
1681
  newIndices.set(key, j);
1671
1682
  } else
1672
- this.f[i].dispose();
1683
+ this.c[i].dispose();
1673
1684
  }
1674
1685
  for (j = start; j < newLen; j++) {
1675
1686
  if (j in temp) {
1676
- this.g[j] = temp[j];
1677
- this.f[j] = tempNodes[j];
1687
+ this.d[j] = temp[j];
1688
+ this.c[j] = tempNodes[j];
1678
1689
  if (tempRows) {
1679
1690
  this.j[j] = tempRows[j];
1680
1691
  this.j[j].write(newItems[j]);
@@ -1684,60 +1695,89 @@ function updateKeyedMap() {
1684
1695
  this.k[j].write(j);
1685
1696
  }
1686
1697
  } else {
1687
- this.g[j] = compute(this.f[j] = new Owner(), mapper, null);
1698
+ this.d[j] = compute(this.c[j] = new Owner(), mapper, null);
1688
1699
  }
1689
1700
  }
1690
- this.g = this.g.slice(0, this.i = newLen);
1691
- this.w = newItems.slice(0);
1701
+ this.d = this.d.slice(0, this.i = newLen);
1702
+ this.x = newItems.slice(0);
1692
1703
  }
1693
1704
  });
1694
- return this.g;
1705
+ return this.d;
1695
1706
  }
1696
1707
  function repeat(count, map, options) {
1697
1708
  return updateRepeat.bind({
1698
- G: new Owner(),
1709
+ I: new Owner(),
1699
1710
  i: 0,
1700
- Y: count,
1701
- H: map,
1702
- f: [],
1703
- g: [],
1711
+ r: 0,
1712
+ Z: count,
1713
+ D: map,
1714
+ c: [],
1715
+ d: [],
1716
+ _: options?.from,
1704
1717
  o: options?.fallback
1705
1718
  });
1706
1719
  }
1707
1720
  function updateRepeat() {
1708
- const newLen = this.Y();
1709
- runWithOwner(this.G, () => {
1721
+ const newLen = this.Z();
1722
+ const from = this._?.() || 0;
1723
+ runWithOwner(this.I, () => {
1710
1724
  if (newLen === 0) {
1711
1725
  if (this.i !== 0) {
1712
- this.G.dispose(false);
1713
- this.f = [];
1714
- this.g = [];
1726
+ this.I.dispose(false);
1727
+ this.c = [];
1728
+ this.d = [];
1715
1729
  this.i = 0;
1716
1730
  }
1717
- if (this.o && !this.g[0]) {
1718
- this.g[0] = compute(
1719
- this.f[0] = new Owner(),
1731
+ if (this.o && !this.d[0]) {
1732
+ this.d[0] = compute(
1733
+ this.c[0] = new Owner(),
1720
1734
  this.o,
1721
1735
  null
1722
1736
  );
1723
1737
  }
1724
- } else {
1725
- if (this.i === 0 && this.f[0])
1726
- this.f[0].dispose();
1727
- for (let i = this.i; i < newLen; i++) {
1728
- this.g[i] = compute(
1729
- this.f[i] = new Owner(),
1730
- () => this.H(i),
1738
+ return;
1739
+ }
1740
+ const to = from + newLen;
1741
+ const prevTo = this.r + this.i;
1742
+ if (this.i === 0 && this.c[0])
1743
+ this.c[0].dispose();
1744
+ for (let i = to; i < prevTo; i++)
1745
+ this.c[i - this.r].dispose();
1746
+ if (this.r < from) {
1747
+ let i = this.r;
1748
+ while (i < from && i < this.i)
1749
+ this.c[i++].dispose();
1750
+ this.c.splice(0, from - this.r);
1751
+ this.d.splice(0, from - this.r);
1752
+ } else if (this.r > from) {
1753
+ let i = prevTo - this.r - 1;
1754
+ let difference = this.r - from;
1755
+ this.c.length = this.d.length = newLen;
1756
+ while (i >= difference) {
1757
+ this.c[i] = this.c[i - difference];
1758
+ this.d[i] = this.d[i - difference];
1759
+ i--;
1760
+ }
1761
+ for (let i2 = 0; i2 < difference; i2++) {
1762
+ this.d[i2] = compute(
1763
+ this.c[i2] = new Owner(),
1764
+ () => this.D(i2 + from),
1731
1765
  null
1732
1766
  );
1733
1767
  }
1734
- for (let i = newLen; i < this.i; i++)
1735
- this.f[i].dispose();
1736
- this.g = this.g.slice(0, newLen);
1737
- this.i = newLen;
1738
1768
  }
1769
+ for (let i = prevTo; i < to; i++) {
1770
+ this.d[i - from] = compute(
1771
+ this.c[i - from] = new Owner(),
1772
+ () => this.D(i),
1773
+ null
1774
+ );
1775
+ }
1776
+ this.d = this.d.slice(0, newLen);
1777
+ this.r = from;
1778
+ this.i = newLen;
1739
1779
  });
1740
- return this.g;
1780
+ return this.d;
1741
1781
  }
1742
1782
  function compare(key, a, b) {
1743
1783
  return key ? key(a) === key(b) : true;