@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/node.cjs CHANGED
@@ -45,42 +45,42 @@ function schedule() {
45
45
  if (scheduled)
46
46
  return;
47
47
  scheduled = true;
48
- if (!globalQueue.I)
48
+ if (!globalQueue.J)
49
49
  queueMicrotask(flushSync);
50
50
  }
51
51
  var Queue = class {
52
- I = false;
53
- r = [[], [], []];
54
- D = [];
52
+ J = false;
53
+ s = [[], [], []];
54
+ F = [];
55
55
  created = clock;
56
56
  enqueue(type, node) {
57
- this.r[0].push(node);
57
+ this.s[0].push(node);
58
58
  if (type)
59
- this.r[type].push(node);
59
+ this.s[type].push(node);
60
60
  schedule();
61
61
  }
62
62
  run(type) {
63
- if (this.r[type].length) {
63
+ if (this.s[type].length) {
64
64
  if (type === EFFECT_PURE) {
65
- runPureQueue(this.r[type]);
66
- this.r[type] = [];
65
+ runPureQueue(this.s[type]);
66
+ this.s[type] = [];
67
67
  } else {
68
- const effects = this.r[type];
69
- this.r[type] = [];
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.D.length; i++) {
75
- rerun = this.D[i].run(type) || rerun;
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.r[type].length)
77
+ if (type === EFFECT_PURE && this.s[type].length)
78
78
  return true;
79
79
  }
80
80
  flush() {
81
- if (this.I)
81
+ if (this.J)
82
82
  return;
83
- this.I = true;
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.I = false;
92
+ this.J = false;
93
93
  }
94
94
  }
95
95
  addChild(child) {
96
- this.D.push(child);
96
+ this.F.push(child);
97
97
  }
98
98
  removeChild(child) {
99
- const index = this.D.indexOf(child);
99
+ const index = this.F.indexOf(child);
100
100
  if (index >= 0)
101
- this.D.splice(index, 1);
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.s) {
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].y();
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].T();
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.t = child;
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.t || this.s : this, current = this.n, next = null;
185
- while (current && current.s === this) {
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.z();
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.z();
193
+ this.A();
194
194
  if (current)
195
- current.t = !self ? this : this.t;
195
+ current.u = !self ? this : this.u;
196
196
  if (head)
197
197
  head.n = current;
198
198
  }
199
- z() {
200
- if (this.t)
201
- this.t.n = null;
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
- c = null;
302
- e;
303
- E;
304
- A;
301
+ e = null;
302
+ g;
303
+ G;
304
+ B;
305
305
  // Used in __DEV__ mode, hopefully removed in production
306
- Z;
306
+ $;
307
307
  // Using false is an optimization as an alternative to _equals: () => false
308
308
  // which could enable more efficient DIRTY notification
309
- N = isEqual;
310
- U;
309
+ O = isEqual;
310
+ V;
311
311
  /** Whether the computation is an error or has ancestors that are unresolved */
312
- d = 0;
312
+ f = 0;
313
313
  /** Which flags raised by sources are handled, vs. being passed through. */
314
- O = DEFAULT_FLAGS;
315
- P = null;
316
- x = -1;
317
- J = false;
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.A = compute2;
320
+ this.B = compute2;
321
321
  this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
322
- this.d = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
323
- this.e = initialValue;
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.N = options.equals;
325
+ this.O = options.equals;
326
326
  if (options == null ? void 0 : options.unobserved)
327
- this.U = options == null ? void 0 : options.unobserved;
327
+ this.V = options == null ? void 0 : options.unobserved;
328
328
  }
329
- V() {
329
+ W() {
330
330
  var _a;
331
- if (this.A) {
332
- if (this.d & ERROR_BIT && this.x <= getClock())
331
+ if (this.B) {
332
+ if (this.f & ERROR_BIT && this.y <= getClock())
333
333
  update(this);
334
334
  else
335
- this.y();
335
+ this.z();
336
336
  }
337
- if (!this.A || ((_a = this.b) == null ? void 0 : _a.length))
337
+ if (!this.B || ((_a = this.b) == null ? void 0 : _a.length))
338
338
  track(this);
339
- newFlags |= this.d & ~currentMask;
340
- if (this.d & ERROR_BIT) {
341
- throw this.E;
339
+ newFlags |= this.f & ~currentMask;
340
+ if (this.f & ERROR_BIT) {
341
+ throw this.G;
342
342
  } else {
343
- return this.e;
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.V();
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.A && this.d & ERROR_BIT && this.x <= getClock()) {
361
+ if (this.B && this.f & ERROR_BIT && this.y <= getClock()) {
362
362
  update(this);
363
363
  }
364
- if ((notStale || this.d & UNINITIALIZED_BIT) && this.loading()) {
364
+ if ((notStale || this.f & UNINITIALIZED_BIT) && this.loading()) {
365
365
  throw new NotReadyError();
366
366
  }
367
367
  if (staleCheck && this.loading())
368
- staleCheck.e = true;
369
- return this.V();
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.P === null) {
380
- this.P = loadingState(this);
379
+ if (this.Q === null) {
380
+ this.Q = loadingState(this);
381
381
  }
382
- return this.P.read();
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.e) : value;
387
- const valueChanged = newValue !== UNCHANGED && (!!(this.d & UNINITIALIZED_BIT) || this.N === false || !this.N(this.e, newValue));
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.e = newValue;
390
- this.E = void 0;
391
- }
392
- const changedFlagsMask = this.d ^ flags, changedFlags = changedFlagsMask & flags;
393
- this.d = flags;
394
- this.x = getClock() + 1;
395
- if (this.c) {
396
- for (let i = 0; i < this.c.length; i++) {
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.c[i].q(STATE_DIRTY);
398
+ this.e[i].q(STATE_DIRTY);
399
399
  } else if (changedFlagsMask) {
400
- this.c[i].W(changedFlagsMask, changedFlags);
400
+ this.e[i].X(changedFlagsMask, changedFlags);
401
401
  }
402
402
  }
403
403
  }
404
- return this.e;
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.J)
410
+ if (this.a >= state && !this.K)
411
411
  return;
412
- this.J = !!skipQueue;
412
+ this.K = !!skipQueue;
413
413
  this.a = state;
414
- if (this.c) {
415
- for (let i = 0; i < this.c.length; i++) {
416
- this.c[i].q(STATE_CHECK, skipQueue);
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
- W(mask, newFlags2) {
426
+ X(mask, newFlags2) {
427
427
  if (this.a >= STATE_DIRTY)
428
428
  return;
429
- if (mask & this.O) {
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.d & mask;
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.d ^= deltaFlags;
441
- if (this.c) {
442
- for (let i = 0; i < this.c.length; i++) {
443
- this.c[i].W(mask, newFlags2);
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
- F(error) {
449
- this.E = error;
450
- this.write(UNCHANGED, this.d & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
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
- y() {
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].y();
470
- observerFlags |= this.b[i].d;
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
- z() {
486
+ A() {
487
487
  if (this.a === STATE_DISPOSED)
488
488
  return;
489
489
  if (this.b)
490
490
  removeSourceObservers(this, 0);
491
- super.z();
491
+ super.A();
492
492
  }
493
493
  };
494
494
  function loadingState(node) {
495
- const prevOwner = setOwner(node.s);
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.y();
502
- return !!(node.d & LOADING_BIT);
501
+ node.z();
502
+ return !!(node.f & LOADING_BIT);
503
503
  },
504
504
  options
505
505
  );
506
- computation.O = ERROR_BIT | LOADING_BIT;
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.e = computation.x > currentObserver.x;
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.A, 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.d & UNINITIALIZED_BIT);
536
+ node.write(UNCHANGED, newFlags | LOADING_BIT | node.f & UNINITIALIZED_BIT);
537
537
  } else {
538
- node.F(error);
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.c)
556
- source.c = [node];
555
+ if (!source.e)
556
+ source.e = [node];
557
557
  else
558
- source.c.push(node);
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.x = getClock() + 1;
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.c) {
578
- swap = source.c.indexOf(node);
579
- source.c[swap] = source.c[source.c.length - 1];
580
- source.c.pop();
581
- if (!source.c.length)
582
- (_a = source.U) == null ? void 0 : _a.call(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 = { e: false };
596
+ updateCheck = { g: false };
597
597
  try {
598
598
  fn();
599
- return updateCheck.e;
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 = { e: false };
607
+ staleCheck = { g: false };
608
608
  try {
609
609
  latest(fn);
610
- return staleCheck.e;
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.d & UNINITIALIZED_BIT
657
+ newFlags | LOADING_BIT | observer.f & UNINITIALIZED_BIT
658
658
  );
659
659
  } else {
660
- observer.F(error);
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.c)
676
- source.c = [observer];
675
+ if (!source.e)
676
+ source.e = [observer];
677
677
  else
678
- source.c.push(observer);
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.O) ?? DEFAULT_FLAGS;
689
+ currentMask = (observer == null ? void 0 : observer.P) ?? DEFAULT_FLAGS;
690
690
  notStale = true;
691
691
  try {
692
- return fn(observer ? observer.e : void 0);
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
- u;
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.K = effect;
781
- this.L = error;
782
- this.M = initialValue;
783
- this.u = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
784
- if (this.u === EFFECT_RENDER) {
785
- this.A = (p) => getClock() > this.h.created && !(this.d & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
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.y();
788
- !(options == null ? void 0 : options.defer) && (this.u === EFFECT_USER ? this.h.enqueue(this.u, this) : this.T());
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.d;
794
- this.d = flags;
795
- if (this.u === EFFECT_RENDER && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
796
- (_b = (_a = this.h).R) == null ? void 0 : _b.call(_a, this);
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.e;
801
- this.e = value;
802
- this.Q = true;
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.u, this);
809
+ this.h.enqueue(this.w, this);
810
810
  this.a = state;
811
811
  }
812
- F(error) {
812
+ H(error) {
813
813
  var _a, _b, _c;
814
- (_a = this.B) == null ? void 0 : _a.call(this);
815
- if (this.d & LOADING_BIT) {
816
- (_c = (_b = this.h).R) == null ? void 0 : _c.call(_b, this);
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.d = ERROR_BIT;
819
- if (this.u === EFFECT_USER) {
818
+ this.f = ERROR_BIT;
819
+ if (this.w === EFFECT_USER) {
820
820
  try {
821
- return this.L ? this.B = this.L(error) : console.error(new EffectError(this.K, error));
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
- z() {
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
- (_a = this.B) == null ? void 0 : _a.call(this);
836
- this.B = void 0;
837
- super.z();
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
- T() {
839
+ U() {
840
840
  var _a;
841
- if (this.Q && this.a !== STATE_DISPOSED) {
842
- (_a = this.B) == null ? void 0 : _a.call(this);
841
+ if (this.R && this.a !== STATE_DISPOSED) {
842
+ (_a = this.C) == null ? void 0 : _a.call(this);
843
843
  try {
844
- this.B = this.K(this.e, this.M);
844
+ this.C = this.L(this.g, this.N);
845
845
  } catch (e) {
846
846
  this.handleError(e);
847
847
  } finally {
848
- this.M = this.e;
849
- this.Q = false;
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.y();
857
+ !(options == null ? void 0 : options.defer) && this.z();
858
858
  }
859
859
  q(state, skipQueue) {
860
- if (this.a >= state && !this.J)
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.J)
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
- f = /* @__PURE__ */ new Set();
882
+ c = /* @__PURE__ */ new Set();
883
883
  o = false;
884
- S = new Computation(false, null);
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
- R(node) {
891
- if (node.d & LOADING_BIT) {
892
- this.f.add(node);
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.S.write(true);
895
+ this.T.write(true);
896
896
  }
897
897
  } else {
898
- this.f.delete(node);
899
- if (this.f.size === 0) {
898
+ this.c.delete(node);
899
+ if (this.c.size === 0) {
900
900
  this.o = false;
901
- this.S.write(false);
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.d;
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).R) == null ? void 0 : _b.call(_a, this);
913
+ (_b = (_a = this.h).S) == null ? void 0 : _b.call(_a, this);
914
914
  }
915
- return this.e;
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.S.read() || queue.o);
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.s) !== node) {
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.s && !((_c = node.c) == null ? void 0 : _c.length)) {
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
- e: value
971
+ g: value
972
972
  },
973
973
  (p) => {
974
- const value2 = p == null ? void 0 : p.e;
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
- e: source
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.d & ERROR_BIT && signal.x <= getClock()) {
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.F(error);
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({ E: err });
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.F = function(error2) {
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().E, () => {
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.u, 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, setStore] = createStore(initialValue);
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.e : storeValue[property];
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
- const wrappedStore = wrap2(unwrappedStore);
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
- G: new Owner(),
1605
+ I: new Owner(),
1603
1606
  i: 0,
1604
- X: list,
1605
- w: [],
1606
- H: map,
1607
- g: [],
1608
- f: [],
1609
- C: keyFn,
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.X() || [], newLen = newItems.length;
1619
+ const newItems = this.Y() || [], newLen = newItems.length;
1617
1620
  newItems[$TRACK];
1618
- runWithOwner(this.G, () => {
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.H(
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.H(() => item, Computation.prototype.read.bind(this.k[j]));
1632
+ return this.D(() => item, Computation.prototype.read.bind(this.k[j]));
1630
1633
  } : () => {
1631
1634
  const item = newItems[j];
1632
- return this.H(() => item);
1635
+ return this.D(() => item);
1633
1636
  };
1634
1637
  if (newLen === 0) {
1635
1638
  if (this.i !== 0) {
1636
- this.G.dispose(false);
1637
- this.f = [];
1638
- this.w = [];
1639
- this.g = [];
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.g[0]) {
1645
- this.g[0] = compute(
1646
- this.f[0] = new Owner(),
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.f[0])
1653
- this.f[0].dispose();
1654
- this.g = new Array(newLen);
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.w[j] = newItems[j];
1657
- this.g[j] = compute(this.f[j] = new Owner(), mapper, null);
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.w[start] === newItems[start] || this.j && compare(this.C, this.w[start], newItems[start])); start++) {
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.w[end] === newItems[newEnd] || this.j && compare(this.C, this.w[end], newItems[newEnd])); end--, newEnd--) {
1667
- temp[newEnd] = this.g[end];
1668
- tempNodes[newEnd] = this.f[end];
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.C ? this.C(item) : item;
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.w[i];
1683
- key = this.C ? this.C(item) : item;
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.g[i];
1687
- tempNodes[j] = this.f[i];
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.f[i].dispose();
1696
+ this.c[i].dispose();
1694
1697
  }
1695
1698
  for (j = start; j < newLen; j++) {
1696
1699
  if (j in temp) {
1697
- this.g[j] = temp[j];
1698
- this.f[j] = tempNodes[j];
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.g[j] = compute(this.f[j] = new Owner(), mapper, null);
1711
+ this.d[j] = compute(this.c[j] = new Owner(), mapper, null);
1709
1712
  }
1710
1713
  }
1711
- this.g = this.g.slice(0, this.i = newLen);
1712
- this.w = newItems.slice(0);
1714
+ this.d = this.d.slice(0, this.i = newLen);
1715
+ this.x = newItems.slice(0);
1713
1716
  }
1714
1717
  });
1715
- return this.g;
1718
+ return this.d;
1716
1719
  }
1717
1720
  function repeat(count, map, options) {
1718
1721
  return updateRepeat.bind({
1719
- G: new Owner(),
1722
+ I: new Owner(),
1720
1723
  i: 0,
1721
- Y: count,
1722
- H: map,
1723
- f: [],
1724
- g: [],
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
- const newLen = this.Y();
1730
- runWithOwner(this.G, () => {
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.G.dispose(false);
1734
- this.f = [];
1735
- this.g = [];
1740
+ this.I.dispose(false);
1741
+ this.c = [];
1742
+ this.d = [];
1736
1743
  this.i = 0;
1737
1744
  }
1738
- if (this.o && !this.g[0]) {
1739
- this.g[0] = compute(
1740
- this.f[0] = new Owner(),
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
- } else {
1746
- if (this.i === 0 && this.f[0])
1747
- this.f[0].dispose();
1748
- for (let i = this.i; i < newLen; i++) {
1749
- this.g[i] = compute(
1750
- this.f[i] = new Owner(),
1751
- () => this.H(i),
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.g;
1794
+ return this.d;
1762
1795
  }
1763
1796
  function compare(key, a, b) {
1764
1797
  return key ? key(a) === key(b) : true;