@solidjs/signals 0.6.3 → 0.7.0

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
@@ -45,13 +45,13 @@ function schedule() {
45
45
  if (scheduled)
46
46
  return;
47
47
  scheduled = true;
48
- if (!globalQueue.A)
48
+ if (!globalQueue.B)
49
49
  queueMicrotask(flush);
50
50
  }
51
51
  function notifyUnobserved() {
52
52
  for (let i = 0; i < Unobserved.length; i++) {
53
53
  const source = Unobserved[i];
54
- if (!source.b || !source.b.length)
54
+ if (!source.c || !source.c.length)
55
55
  Unobserved[i].ea?.();
56
56
  }
57
57
  Unobserved = [];
@@ -59,7 +59,7 @@ function notifyUnobserved() {
59
59
  var pureQueue = [];
60
60
  var Queue = class {
61
61
  k = null;
62
- A = false;
62
+ B = false;
63
63
  g = [[], []];
64
64
  f = [];
65
65
  created = clock;
@@ -84,9 +84,9 @@ var Queue = class {
84
84
  }
85
85
  }
86
86
  flush() {
87
- if (this.A)
87
+ if (this.B)
88
88
  return;
89
- this.A = true;
89
+ this.B = true;
90
90
  try {
91
91
  this.run(EFFECT_PURE);
92
92
  incrementClock();
@@ -94,19 +94,19 @@ var Queue = class {
94
94
  this.run(EFFECT_RENDER);
95
95
  this.run(EFFECT_USER);
96
96
  } finally {
97
- this.A = false;
97
+ this.B = false;
98
98
  Unobserved.length && notifyUnobserved();
99
99
  }
100
100
  }
101
101
  addChild(child) {
102
- if (ActiveTransition && ActiveTransition.r.has(this))
103
- return ActiveTransition.r.get(this).addChild(child);
102
+ if (ActiveTransition && ActiveTransition.G.has(this))
103
+ return ActiveTransition.G.get(this).addChild(child);
104
104
  this.f.push(child);
105
105
  child.k = this;
106
106
  }
107
107
  removeChild(child) {
108
- if (ActiveTransition && ActiveTransition.r.has(this))
109
- return ActiveTransition.r.get(this).removeChild(child);
108
+ if (ActiveTransition && ActiveTransition.G.has(this))
109
+ return ActiveTransition.G.get(this).removeChild(child);
110
110
  const index = this.f.indexOf(child);
111
111
  if (index >= 0) {
112
112
  this.f.splice(index, 1);
@@ -122,7 +122,7 @@ var Queue = class {
122
122
  this.g[0].push.apply(this.g[0], queue.g[0]);
123
123
  this.g[1].push.apply(this.g[1], queue.g[1]);
124
124
  for (let i = 0; i < queue.f.length; i++) {
125
- const og = this.f.find((c) => c.e === queue.f[i].e);
125
+ const og = this.f.find((c) => c.d === queue.f[i].d);
126
126
  if (og)
127
127
  og.merge(queue.f[i]);
128
128
  else
@@ -141,12 +141,12 @@ function removeSourceObservers(node, index) {
141
141
  let swap;
142
142
  for (let i = index; i < node.a.length; i++) {
143
143
  source = getTransitionSource(node.a[i]);
144
- if (source.b) {
145
- if ((swap = source.b.indexOf(node)) !== -1) {
146
- source.b[swap] = source.b[source.b.length - 1];
147
- source.b.pop();
144
+ if (source.c) {
145
+ if ((swap = source.c.indexOf(node)) !== -1) {
146
+ source.c[swap] = source.c[source.c.length - 1];
147
+ source.c.pop();
148
148
  }
149
- if (!source.b.length)
149
+ if (!source.c.length)
150
150
  Unobserved.push(source);
151
151
  }
152
152
  }
@@ -159,33 +159,33 @@ var Transition = class _Transition {
159
159
  a = /* @__PURE__ */ new Map();
160
160
  s = /* @__PURE__ */ new Set();
161
161
  H = /* @__PURE__ */ new Set();
162
- W = /* @__PURE__ */ new Set();
163
- u = false;
162
+ I = /* @__PURE__ */ new Set();
163
+ D = false;
164
164
  g = [[], []];
165
- r = /* @__PURE__ */ new Map();
166
- I = [];
165
+ G = /* @__PURE__ */ new Map();
166
+ J = [];
167
167
  f = [];
168
168
  k = null;
169
- A = false;
170
- X = false;
171
- e = globalQueue;
169
+ B = false;
170
+ Y = false;
171
+ d = globalQueue;
172
172
  created = clock;
173
173
  constructor() {
174
- this.r.set(globalQueue, this);
174
+ this.G.set(globalQueue, this);
175
175
  for (const child of globalQueue.f) {
176
- cloneQueue(child, this, this.r);
176
+ cloneQueue(child, this, this);
177
177
  }
178
178
  }
179
179
  enqueue(type, fn) {
180
- this.I.push(fn);
180
+ this.J.push(fn);
181
181
  if (type)
182
182
  this.g[type - 1].push(fn);
183
183
  this.schedule();
184
184
  }
185
185
  run(type) {
186
186
  if (type === EFFECT_PURE) {
187
- this.I.length && runQueue(this.I, type);
188
- this.I = [];
187
+ this.J.length && runQueue(this.J, type);
188
+ this.J = [];
189
189
  return;
190
190
  } else if (this.g[type - 1].length) {
191
191
  const effects = this.g[type - 1];
@@ -197,19 +197,19 @@ var Transition = class _Transition {
197
197
  }
198
198
  }
199
199
  flush() {
200
- if (this.A)
200
+ if (this.B)
201
201
  return;
202
- this.A = true;
202
+ this.B = true;
203
203
  let currentTransition = ActiveTransition;
204
204
  ActiveTransition = this;
205
205
  try {
206
206
  this.run(EFFECT_PURE);
207
207
  incrementClock();
208
- this.X = false;
208
+ this.Y = false;
209
209
  ActiveTransition = currentTransition;
210
210
  finishTransition(this);
211
211
  } finally {
212
- this.A = false;
212
+ this.B = false;
213
213
  ActiveTransition = currentTransition;
214
214
  }
215
215
  }
@@ -235,9 +235,9 @@ var Transition = class _Transition {
235
235
  merge(queue) {
236
236
  this.g[0].push.apply(this.g[0], queue.g[0]);
237
237
  this.g[1].push.apply(this.g[1], queue.g[1]);
238
- this.I.push.apply(this.I, queue.I);
238
+ this.J.push.apply(this.J, queue.J);
239
239
  for (let i = 0; i < queue.f.length; i++) {
240
- const og = this.f.find((c) => c.e === queue.f[i].e);
240
+ const og = this.f.find((c) => c.d === queue.f[i].d);
241
241
  if (og)
242
242
  og.merge(queue.f[i]);
243
243
  else
@@ -245,16 +245,16 @@ var Transition = class _Transition {
245
245
  }
246
246
  }
247
247
  schedule() {
248
- if (this.X)
248
+ if (this.Y)
249
249
  return;
250
- this.X = true;
251
- if (!this.A)
250
+ this.Y = true;
251
+ if (!this.B)
252
252
  queueMicrotask(() => this.flush());
253
253
  }
254
254
  runTransition(fn, force = false) {
255
- if (this.u) {
256
- if (this.u instanceof _Transition)
257
- return this.u.runTransition(fn, force);
255
+ if (this.D) {
256
+ if (this.D instanceof _Transition)
257
+ return this.D.runTransition(fn, force);
258
258
  if (!force)
259
259
  throw new Error("Transition already completed");
260
260
  fn();
@@ -273,8 +273,7 @@ var Transition = class _Transition {
273
273
  try {
274
274
  value = await temp.value;
275
275
  } finally {
276
- while (transition2.u instanceof _Transition)
277
- transition2 = transition2.u;
276
+ transition2 = latestTransition(transition2);
278
277
  transition2.H.delete(temp.value);
279
278
  }
280
279
  ActiveTransition = transition2;
@@ -288,8 +287,7 @@ var Transition = class _Transition {
288
287
  if (result instanceof Promise) {
289
288
  transition2.H.add(result);
290
289
  result.finally(() => {
291
- while (transition2.u instanceof _Transition)
292
- transition2 = transition2.u;
290
+ transition2 = latestTransition(transition2);
293
291
  transition2.H.delete(result);
294
292
  ActiveTransition = null;
295
293
  finishTransition(transition2);
@@ -308,14 +306,14 @@ var Transition = class _Transition {
308
306
  return;
309
307
  }
310
308
  fn.j = this;
311
- this.W.add(fn);
309
+ this.I.add(fn);
312
310
  }
313
311
  };
314
312
  function transition(fn) {
315
313
  let t = new Transition();
316
314
  queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
317
315
  }
318
- function cloneGraph(node) {
316
+ function cloneGraph(node, optimistic) {
319
317
  if (node.j) {
320
318
  if (node.j !== ActiveTransition) {
321
319
  mergeTransitions(node.j, ActiveTransition);
@@ -327,50 +325,60 @@ function cloneGraph(node) {
327
325
  Object.assign(clone, node, {
328
326
  n: null,
329
327
  m: null,
330
- b: null,
328
+ c: null,
331
329
  a: node.a ? [...node.a] : null,
332
- e: node
330
+ d: node,
331
+ I: !!optimistic
333
332
  });
333
+ delete clone.T;
334
334
  ActiveTransition.a.set(node, clone);
335
335
  node.j = ActiveTransition;
336
- if (node.a) {
336
+ if (!optimistic && node.a) {
337
337
  for (let i = 0; i < node.a.length; i++)
338
- node.a[i].b.push(clone);
338
+ node.a[i].c.push(clone);
339
339
  }
340
- if (node.b) {
341
- clone.b = [];
342
- for (let i = 0, length = node.b.length; i < length; i++) {
343
- !node.b[i].e && clone.b.push(cloneGraph(node.b[i]));
340
+ if (node.c) {
341
+ clone.c = [];
342
+ for (let i = 0, length = node.c.length; i < length; i++) {
343
+ !node.c[i].d && clone.c.push(cloneGraph(node.c[i], optimistic));
344
344
  }
345
345
  }
346
346
  return clone;
347
347
  }
348
+ function latestTransition(t) {
349
+ while (t.D instanceof Transition)
350
+ t = t.D;
351
+ return t;
352
+ }
348
353
  function replaceSourceObservers(node, transition2) {
349
354
  let source;
355
+ let transitionSource;
350
356
  let swap;
351
357
  for (let i = 0; i < node.a.length; i++) {
352
- source = transition2.a.get(node.a[i]) || node.a[i];
353
- if (source.b && (swap = source.b.indexOf(node)) !== -1) {
354
- const remove = source.b.indexOf(node.e) > -1;
355
- source.b[swap] = !remove ? node.e : source.b[source.b.length - 1];
356
- remove && source.b.pop();
358
+ transitionSource = transition2.a.get(node.a[i]);
359
+ source = transitionSource || node.a[i];
360
+ if (source.c && (swap = source.c.indexOf(node)) !== -1) {
361
+ source.c[swap] = transitionSource ? node.d : source.c[source.c.length - 1];
362
+ !transitionSource && source.c.pop();
357
363
  }
358
364
  }
359
365
  }
360
- function cloneQueue(queue, parent, clonedQueues) {
366
+ function cloneQueue(queue, parent, transition2) {
361
367
  const clone = Object.create(Object.getPrototypeOf(queue));
362
368
  Object.assign(clone, queue, {
363
- e: queue,
369
+ d: queue,
364
370
  k: parent,
365
371
  f: [],
366
372
  enqueue(type, fn) {
367
- ActiveTransition?.enqueue(type, fn);
373
+ transition2 = latestTransition(transition2);
374
+ transition2.enqueue(type, fn);
368
375
  },
369
376
  notify(node, type, flags) {
370
- node = node.e || node;
371
- if (!clone.J || type & LOADING_BIT) {
377
+ node = node.d || node;
378
+ if (!clone.K || type & LOADING_BIT) {
372
379
  type &= ~LOADING_BIT;
373
- ActiveTransition?.notify(node, LOADING_BIT, flags);
380
+ transition2 = latestTransition(transition2);
381
+ transition2.notify(node, LOADING_BIT, flags);
374
382
  if (!type)
375
383
  return true;
376
384
  }
@@ -378,14 +386,14 @@ function cloneQueue(queue, parent, clonedQueues) {
378
386
  }
379
387
  });
380
388
  parent.f.push(clone);
381
- clonedQueues.set(queue, clone);
389
+ transition2.G.set(queue, clone);
382
390
  for (const child of queue.f) {
383
- cloneQueue(child, clone, clonedQueues);
391
+ cloneQueue(child, clone, transition2);
384
392
  }
385
393
  }
386
394
  function resolveQueues(children) {
387
395
  for (const child of children) {
388
- const og = child.e;
396
+ const og = child.d;
389
397
  if (og) {
390
398
  const clonedChildren = child.f;
391
399
  delete child.enqueue;
@@ -393,10 +401,10 @@ function resolveQueues(children) {
393
401
  delete child.k;
394
402
  delete child.f;
395
403
  Object.assign(og, child);
396
- delete og.e;
404
+ delete og.d;
397
405
  resolveQueues(clonedChildren);
398
- } else if (child.k.e) {
399
- child.k.e.addChild(child);
406
+ } else if (child.k.d) {
407
+ child.k.d.addChild(child);
400
408
  }
401
409
  }
402
410
  }
@@ -405,34 +413,34 @@ function mergeTransitions(t1, t2) {
405
413
  key.j = t1;
406
414
  t1.a.set(key, value);
407
415
  });
408
- t2.W.forEach((c) => {
416
+ t2.I.forEach((c) => {
409
417
  c.j = t1;
410
- t1.W.add(c);
418
+ t1.I.add(c);
411
419
  });
412
420
  t2.H.forEach((p) => t1.H.add(p));
413
421
  t2.s.forEach((n) => t1.s.add(n));
414
422
  t1.merge(t2);
415
- t2.u = t1;
423
+ t2.D = t1;
416
424
  }
417
425
  function getTransitionSource(input) {
418
426
  return ActiveTransition && ActiveTransition.a.get(input) || input;
419
427
  }
420
428
  function getQueue(node) {
421
- const transition2 = ActiveTransition || node.e?.j;
422
- return transition2 && transition2.r.get(node.B) || node.B;
429
+ const transition2 = ActiveTransition || node.d?.j;
430
+ return transition2 && transition2.G.get(node.C) || node.C;
423
431
  }
424
432
  function initialDispose(node) {
425
433
  let current = node.m;
426
434
  while (current !== null && current.k === node) {
427
435
  initialDispose(current);
428
436
  const clone = ActiveTransition.a.get(current);
429
- if (clone && !clone.Y)
437
+ if (clone && !clone.Z)
430
438
  clone.dispose(true);
431
439
  current = current.m;
432
440
  }
433
441
  }
434
442
  function finishTransition(transition2) {
435
- if (transition2.u || transition2.X || transition2.H.size || transition2.s.size)
443
+ if (transition2.D || transition2.Y || transition2.H.size || transition2.s.size)
436
444
  return;
437
445
  globalQueue.g[0].push.apply(globalQueue.g[0], transition2.g[0]);
438
446
  globalQueue.g[1].push.apply(globalQueue.g[1], transition2.g[1]);
@@ -444,27 +452,33 @@ function finishTransition(transition2) {
444
452
  }
445
453
  if (clone.a)
446
454
  replaceSourceObservers(clone, transition2);
447
- if (clone.Y || clone.c === STATE_DISPOSED) {
448
- source.dispose(clone.c === STATE_DISPOSED);
455
+ if (clone.I) {
456
+ clone.dispose();
457
+ clone.emptyDisposal();
458
+ delete source.j;
459
+ continue;
460
+ }
461
+ if (clone.Z || clone.b === STATE_DISPOSED) {
462
+ source.dispose(clone.b === STATE_DISPOSED);
449
463
  source.emptyDisposal();
450
- delete clone.Y;
464
+ delete clone.Z;
451
465
  } else {
452
466
  delete clone.m;
453
467
  delete clone.n;
454
468
  }
455
469
  Object.assign(source, clone);
456
- delete source.e;
470
+ delete source.d;
457
471
  let current = clone.m;
458
- if (current?.w === clone)
459
- current.w = source;
472
+ if (current?.y === clone)
473
+ current.y = source;
460
474
  while (current?.k === clone) {
461
475
  current.k = source;
462
476
  current = current.m;
463
477
  }
464
478
  delete source.j;
465
479
  }
466
- transition2.u = true;
467
- for (const reset of transition2.W) {
480
+ transition2.D = true;
481
+ for (const reset of transition2.I) {
468
482
  delete reset.j;
469
483
  reset();
470
484
  }
@@ -488,11 +502,11 @@ var Owner = class {
488
502
  // See comment at the top of the file for an example of the _nextSibling traversal
489
503
  k = null;
490
504
  m = null;
491
- w = null;
492
- c = STATE_CLEAN;
505
+ y = null;
506
+ b = STATE_CLEAN;
493
507
  n = null;
494
- x = defaultContext;
495
- B = globalQueue;
508
+ z = defaultContext;
509
+ C = globalQueue;
496
510
  fa = 0;
497
511
  id = null;
498
512
  constructor(id = null, skipAppend = false) {
@@ -503,23 +517,23 @@ var Owner = class {
503
517
  }
504
518
  append(child) {
505
519
  child.k = this;
506
- child.w = this;
520
+ child.y = this;
507
521
  if (this.m)
508
- this.m.w = child;
522
+ this.m.y = child;
509
523
  child.m = this.m;
510
524
  this.m = child;
511
525
  if (this.id != null && child.id == null)
512
526
  child.id = this.getNextChildId();
513
- if (child.x !== this.x) {
514
- child.x = { ...this.x, ...child.x };
527
+ if (child.z !== this.z) {
528
+ child.z = { ...this.z, ...child.z };
515
529
  }
516
- if (this.B)
517
- child.B = this.B;
530
+ if (this.C)
531
+ child.C = this.C;
518
532
  }
519
533
  dispose(self = true) {
520
- if (this.c === STATE_DISPOSED)
534
+ if (this.b === STATE_DISPOSED)
521
535
  return;
522
- let head = self ? this.w || this.k : this, current = this.m, next = null;
536
+ let head = self ? this.y || this.k : this, current = this.m, next = null;
523
537
  while (current && current.k === this) {
524
538
  current.dispose(true);
525
539
  next = current.m;
@@ -528,19 +542,19 @@ var Owner = class {
528
542
  }
529
543
  this.fa = 0;
530
544
  if (self)
531
- this.R();
545
+ this.L();
532
546
  if (current)
533
- current.w = !self ? this : this.w;
547
+ current.y = !self ? this : this.y;
534
548
  if (head)
535
549
  head.m = current;
536
550
  }
537
- R() {
538
- if (this.w)
539
- this.w.m = null;
551
+ L() {
552
+ if (this.y)
553
+ this.y.m = null;
540
554
  this.k = null;
541
- this.w = null;
542
- this.x = defaultContext;
543
- this.c = STATE_DISPOSED;
555
+ this.y = null;
556
+ this.z = defaultContext;
557
+ this.b = STATE_DISPOSED;
544
558
  this.emptyDisposal();
545
559
  }
546
560
  emptyDisposal() {
@@ -569,7 +583,7 @@ function getContext(context, owner = currentOwner) {
569
583
  if (!owner) {
570
584
  throw new NoOwnerError();
571
585
  }
572
- const value = hasContext(context, owner) ? owner.x[context.id] : context.defaultValue;
586
+ const value = hasContext(context, owner) ? owner.z[context.id] : context.defaultValue;
573
587
  if (isUndefined(value)) {
574
588
  throw new ContextNotFoundError();
575
589
  }
@@ -579,13 +593,13 @@ function setContext(context, value, owner = currentOwner) {
579
593
  if (!owner) {
580
594
  throw new NoOwnerError();
581
595
  }
582
- owner.x = {
583
- ...owner.x,
596
+ owner.z = {
597
+ ...owner.z,
584
598
  [context.id]: isUndefined(value) ? context.defaultValue : value
585
599
  };
586
600
  }
587
601
  function hasContext(context, owner = currentOwner) {
588
- return !isUndefined(owner?.x[context.id]);
602
+ return !isUndefined(owner?.z[context.id]);
589
603
  }
590
604
  function onCleanup(fn) {
591
605
  if (!currentOwner)
@@ -623,10 +637,10 @@ function getObserver() {
623
637
  var UNCHANGED = Symbol(0);
624
638
  var Computation = class extends Owner {
625
639
  a = null;
626
- b = null;
640
+ c = null;
627
641
  l;
628
- L;
629
- M;
642
+ O;
643
+ P;
630
644
  // Used in __DEV__ mode, hopefully removed in production
631
645
  la;
632
646
  // Using false is an optimization as an alternative to _equals: () => false
@@ -635,25 +649,24 @@ var Computation = class extends Owner {
635
649
  ea;
636
650
  ha = false;
637
651
  /** Whether the computation is an error or has ancestors that are unresolved */
638
- h = 0;
652
+ i = 0;
639
653
  /** Which flags raised by sources are handled, vs. being passed through. */
640
654
  ba = DEFAULT_FLAGS;
641
- N = -1;
642
- D = false;
655
+ Q = -1;
656
+ E = false;
643
657
  j;
644
- e;
658
+ d;
659
+ I = false;
645
660
  constructor(initialValue, compute2, options) {
646
661
  super(options?.id, compute2 === null);
647
- this.M = compute2;
648
- this.c = compute2 ? STATE_DIRTY : STATE_CLEAN;
649
- this.h = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
662
+ this.P = compute2;
663
+ this.b = compute2 ? STATE_DIRTY : STATE_CLEAN;
664
+ this.i = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
650
665
  this.l = initialValue;
651
666
  if (options?.equals !== void 0)
652
667
  this.aa = options.equals;
653
- if (options?.pureWrite)
654
- this.ha = true;
655
- if (options?.unobserved)
656
- this.ea = options?.unobserved;
668
+ this.ha = !!options?.pureWrite;
669
+ this.ea = options?.unobserved;
657
670
  if (ActiveTransition) {
658
671
  this.j = ActiveTransition;
659
672
  ActiveTransition.a.set(this, this);
@@ -661,9 +674,9 @@ var Computation = class extends Owner {
661
674
  }
662
675
  ga() {
663
676
  track(this);
664
- newFlags |= this.h & ~currentMask;
665
- if (this.h & ERROR_BIT) {
666
- throw this.L;
677
+ newFlags |= this.i & ~currentMask;
678
+ if (this.i & ERROR_BIT) {
679
+ throw this.O;
667
680
  } else {
668
681
  return this.l;
669
682
  }
@@ -673,16 +686,16 @@ var Computation = class extends Owner {
673
686
  * Automatically re-executes the surrounding computation when the value changes
674
687
  */
675
688
  read() {
676
- if (ActiveTransition && (ActiveTransition.a.has(this) || !this.e && this.h & (UNINITIALIZED_BIT | ERROR_BIT))) {
689
+ if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.i & (UNINITIALIZED_BIT | ERROR_BIT))) {
677
690
  const clone = ActiveTransition.a.get(this) || cloneGraph(this);
678
691
  if (clone !== this)
679
692
  return clone.read();
680
693
  }
681
- if (this.M) {
682
- if (this.h & ERROR_BIT && this.N <= clock)
694
+ if (this.P) {
695
+ if (this.i & ERROR_BIT && this.Q <= clock)
683
696
  update(this);
684
697
  else
685
- this.K();
698
+ this.M();
686
699
  }
687
700
  return this.ga();
688
701
  }
@@ -694,49 +707,49 @@ var Computation = class extends Owner {
694
707
  * before continuing
695
708
  */
696
709
  wait() {
697
- if (ActiveTransition && (ActiveTransition.a.has(this) || !this.e && this.h & (UNINITIALIZED_BIT | ERROR_BIT))) {
710
+ if (ActiveTransition && (ActiveTransition.a.has(this) || !this.d && this.i & (UNINITIALIZED_BIT | ERROR_BIT))) {
698
711
  const clone = ActiveTransition.a.get(this) || cloneGraph(this);
699
712
  if (clone !== this)
700
713
  return clone.wait();
701
714
  }
702
- if (this.M) {
703
- if (this.h & ERROR_BIT && this.N <= clock)
715
+ if (this.P) {
716
+ if (this.i & ERROR_BIT && this.Q <= clock)
704
717
  update(this);
705
718
  else
706
- this.K();
719
+ this.M();
707
720
  }
708
- if ((notStale || this.h & UNINITIALIZED_BIT) && this.h & LOADING_BIT) {
721
+ if ((notStale || this.i & UNINITIALIZED_BIT) && this.i & LOADING_BIT) {
709
722
  track(this);
710
723
  throw new NotReadyError();
711
724
  }
712
- if (staleCheck && this.h & LOADING_BIT) {
725
+ if (staleCheck && this.i & LOADING_BIT) {
713
726
  staleCheck.l = true;
714
727
  }
715
728
  return this.ga();
716
729
  }
717
730
  /** Update the computation with a new value. */
718
731
  write(value, flags = 0, raw = false) {
719
- if (ActiveTransition && !this.e) {
732
+ if (ActiveTransition && !this.d) {
720
733
  const clone = cloneGraph(this);
721
734
  if (clone !== this)
722
735
  return clone.write(value, flags, raw);
723
736
  }
724
737
  const newValue = !raw && typeof value === "function" ? value(this.l) : value;
725
- const valueChanged = newValue !== UNCHANGED && (!!(this.h & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
738
+ const valueChanged = newValue !== UNCHANGED && (!!(this.i & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
726
739
  this.aa === false || !this.aa(this.l, newValue));
727
740
  if (valueChanged) {
728
741
  this.l = newValue;
729
- this.L = void 0;
742
+ this.O = void 0;
730
743
  }
731
- const changedFlagsMask = this.h ^ flags, changedFlags = changedFlagsMask & flags;
732
- this.h = flags;
733
- this.N = clock + 1;
734
- if (this.b) {
735
- for (let i = 0; i < this.b.length; i++) {
744
+ const changedFlagsMask = this.i ^ flags, changedFlags = changedFlagsMask & flags;
745
+ this.i = flags;
746
+ this.Q = clock + 1;
747
+ if (this.c) {
748
+ for (let i = 0; i < this.c.length; i++) {
736
749
  if (valueChanged) {
737
- this.b[i].y(STATE_DIRTY);
750
+ this.c[i].t(STATE_DIRTY);
738
751
  } else if (changedFlagsMask) {
739
- this.b[i].Z(changedFlagsMask, changedFlags);
752
+ this.c[i]._(changedFlagsMask, changedFlags);
740
753
  }
741
754
  }
742
755
  }
@@ -745,14 +758,14 @@ var Computation = class extends Owner {
745
758
  /**
746
759
  * Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
747
760
  */
748
- y(state, skipQueue) {
749
- if (this.c >= state && !this.D)
761
+ t(state, skipQueue) {
762
+ if (this.b >= state && !this.E)
750
763
  return;
751
- this.D = !!skipQueue;
752
- this.c = state;
753
- if (this.b) {
754
- for (let i = 0; i < this.b.length; i++) {
755
- this.b[i].y(STATE_CHECK, skipQueue);
764
+ this.E = !!skipQueue;
765
+ this.b = state;
766
+ if (this.c) {
767
+ for (let i = 0; i < this.c.length; i++) {
768
+ this.c[i].t(STATE_CHECK, skipQueue);
756
769
  }
757
770
  }
758
771
  }
@@ -762,36 +775,36 @@ var Computation = class extends Owner {
762
775
  * @param mask A bitmask for which flag(s) were changed.
763
776
  * @param newFlags The source's new flags, masked to just the changed ones.
764
777
  */
765
- Z(mask, newFlags2) {
766
- if (this.c >= STATE_DIRTY)
778
+ _(mask, newFlags2) {
779
+ if (this.b >= STATE_DIRTY)
767
780
  return;
768
781
  if (mask & this.ba) {
769
- this.y(STATE_DIRTY);
782
+ this.t(STATE_DIRTY);
770
783
  return;
771
784
  }
772
- if (this.c >= STATE_CHECK && !this.D)
785
+ if (this.b >= STATE_CHECK && !this.E)
773
786
  return;
774
- const prevFlags = this.h & mask;
787
+ const prevFlags = this.i & mask;
775
788
  const deltaFlags = prevFlags ^ newFlags2;
776
789
  if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
777
- this.y(STATE_CHECK);
790
+ this.t(STATE_CHECK);
778
791
  } else {
779
- this.h ^= deltaFlags;
780
- if (this.b) {
781
- for (let i = 0; i < this.b.length; i++) {
782
- this.b[i].Z(mask, newFlags2);
792
+ this.i ^= deltaFlags;
793
+ if (this.c) {
794
+ for (let i = 0; i < this.c.length; i++) {
795
+ this.c[i]._(mask, newFlags2);
783
796
  }
784
797
  }
785
798
  }
786
799
  }
787
- E(error) {
788
- if (ActiveTransition && !this.e) {
800
+ N(error) {
801
+ if (ActiveTransition && !this.d) {
789
802
  const clone = cloneGraph(this);
790
803
  if (clone !== this)
791
- return clone.E(error);
804
+ return clone.N(error);
792
805
  }
793
- this.L = error;
794
- this.write(UNCHANGED, this.h & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
806
+ this.O = error;
807
+ this.write(UNCHANGED, this.i & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
795
808
  }
796
809
  /**
797
810
  * This is the core part of the reactivity system, which makes sure that the values are updated
@@ -800,48 +813,48 @@ var Computation = class extends Owner {
800
813
  *
801
814
  * This function will ensure that the value and states we read from the computation are up to date
802
815
  */
803
- K() {
804
- if (!this.M) {
816
+ M() {
817
+ if (!this.P) {
805
818
  return;
806
819
  }
807
- if (this.c === STATE_DISPOSED) {
820
+ if (this.b === STATE_DISPOSED) {
808
821
  return;
809
822
  }
810
- if (this.c === STATE_CLEAN) {
823
+ if (this.b === STATE_CLEAN) {
811
824
  return;
812
825
  }
813
826
  let observerFlags = 0;
814
- if (this.c === STATE_CHECK) {
827
+ if (this.b === STATE_CHECK) {
815
828
  for (let i = 0; i < this.a.length; i++) {
816
829
  const source = getTransitionSource(this.a[i]);
817
- source.K();
818
- observerFlags |= source.h & ~UNINITIALIZED_BIT;
819
- if (this.c === STATE_DIRTY) {
830
+ source.M();
831
+ observerFlags |= source.i & ~UNINITIALIZED_BIT;
832
+ if (this.b === STATE_DIRTY) {
820
833
  break;
821
834
  }
822
835
  }
823
836
  }
824
- if (this.c === STATE_DIRTY) {
837
+ if (this.b === STATE_DIRTY) {
825
838
  update(this);
826
839
  } else {
827
840
  this.write(UNCHANGED, observerFlags);
828
- this.c = STATE_CLEAN;
841
+ this.b = STATE_CLEAN;
829
842
  }
830
843
  }
831
844
  /**
832
845
  * Remove ourselves from the owner graph and the computation graph
833
846
  */
834
- R() {
835
- if (this.c === STATE_DISPOSED)
847
+ L() {
848
+ if (this.b === STATE_DISPOSED)
836
849
  return;
837
850
  if (this.a)
838
851
  removeSourceObservers(this, 0);
839
- super.R();
852
+ super.L();
840
853
  }
841
854
  };
842
855
  function track(computation) {
843
- if (ActiveTransition && computation.e)
844
- computation = computation.e;
856
+ if (ActiveTransition && computation.d)
857
+ computation = computation.d;
845
858
  if (currentObserver) {
846
859
  if (!newSources && currentObserver.a && currentObserver.a[newSourcesIndex] === computation) {
847
860
  newSourcesIndex++;
@@ -851,7 +864,7 @@ function track(computation) {
851
864
  newSources.push(computation);
852
865
  }
853
866
  if (updateCheck) {
854
- updateCheck.l = computation.N > currentObserver.N;
867
+ updateCheck.l = computation.Q > currentObserver.Q;
855
868
  }
856
869
  }
857
870
  }
@@ -861,19 +874,19 @@ function update(node) {
861
874
  newSourcesIndex = 0;
862
875
  newFlags = 0;
863
876
  try {
864
- if (ActiveTransition && node.e && !node.Y) {
865
- initialDispose(node.e);
866
- node.Y = true;
877
+ if (ActiveTransition && node.d && !node.Z) {
878
+ initialDispose(node.d);
879
+ node.Z = true;
867
880
  }
868
881
  node.dispose(false);
869
882
  node.emptyDisposal();
870
- const result = compute(node, node.M, node);
883
+ const result = compute(node, node.P, node);
871
884
  node.write(result, newFlags, true);
872
885
  } catch (error) {
873
886
  if (error instanceof NotReadyError) {
874
- node.write(UNCHANGED, newFlags | LOADING_BIT | node.h & UNINITIALIZED_BIT);
887
+ node.write(UNCHANGED, newFlags | LOADING_BIT | node.i & UNINITIALIZED_BIT);
875
888
  } else {
876
- node.E(error);
889
+ node.N(error);
877
890
  }
878
891
  } finally {
879
892
  if (newSources) {
@@ -890,10 +903,10 @@ function update(node) {
890
903
  let source;
891
904
  for (let i = newSourcesIndex; i < node.a.length; i++) {
892
905
  source = getTransitionSource(node.a[i]);
893
- if (!source.b)
894
- source.b = [node];
906
+ if (!source.c)
907
+ source.c = [node];
895
908
  else
896
- source.b.push(node);
909
+ source.c.push(node);
897
910
  }
898
911
  } else if (node.a && newSourcesIndex < node.a.length) {
899
912
  removeSourceObservers(node, newSourcesIndex);
@@ -902,8 +915,8 @@ function update(node) {
902
915
  newSources = prevSources;
903
916
  newSourcesIndex = prevSourcesIndex;
904
917
  newFlags = prevFlags;
905
- node.N = clock + 1;
906
- node.c = STATE_CLEAN;
918
+ node.Q = clock + 1;
919
+ node.b = STATE_CLEAN;
907
920
  }
908
921
  }
909
922
  function isEqual(a, b) {
@@ -963,46 +976,6 @@ function latest(fn, fallback) {
963
976
  notStale = prevNotStale;
964
977
  }
965
978
  }
966
- function runWithObserver(observer, run) {
967
- const prevSources = newSources, prevSourcesIndex = newSourcesIndex, prevFlags = newFlags;
968
- newSources = null;
969
- newSourcesIndex = observer.a ? observer.a.length : 0;
970
- newFlags = 0;
971
- try {
972
- return compute(observer, run, observer);
973
- } catch (error) {
974
- if (error instanceof NotReadyError) {
975
- observer.write(
976
- UNCHANGED,
977
- newFlags | LOADING_BIT | observer.h & UNINITIALIZED_BIT
978
- );
979
- } else {
980
- observer.E(error);
981
- }
982
- } finally {
983
- if (newSources) {
984
- if (newSourcesIndex > 0) {
985
- observer.a.length = newSourcesIndex + newSources.length;
986
- for (let i = 0; i < newSources.length; i++) {
987
- observer.a[newSourcesIndex + i] = newSources[i];
988
- }
989
- } else {
990
- observer.a = newSources;
991
- }
992
- let source;
993
- for (let i = newSourcesIndex; i < observer.a.length; i++) {
994
- source = observer.a[i];
995
- if (!source.b)
996
- source.b = [observer];
997
- else
998
- source.b.push(observer);
999
- }
1000
- }
1001
- newSources = prevSources;
1002
- newSourcesIndex = prevSourcesIndex;
1003
- newFlags = prevFlags;
1004
- }
1005
- }
1006
979
  function compute(owner, fn, observer) {
1007
980
  const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
1008
981
  currentObserver = observer;
@@ -1021,66 +994,66 @@ function compute(owner, fn, observer) {
1021
994
  // src/core/effect.ts
1022
995
  var Effect = class extends Computation {
1023
996
  ca;
1024
- _;
1025
- O;
1026
- da = false;
1027
997
  $;
1028
- C;
998
+ u;
999
+ da = false;
1000
+ T;
1001
+ r;
1029
1002
  constructor(initialValue, compute2, effect, error, options) {
1030
1003
  super(initialValue, compute2, options);
1031
1004
  this.ca = effect;
1032
- this._ = error;
1033
- this.$ = initialValue;
1034
- this.C = options?.render ? EFFECT_RENDER : EFFECT_USER;
1035
- if (this.C === EFFECT_RENDER) {
1036
- this.M = function(p) {
1037
- return !this.e && clock > this.B.created && !(this.h & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
1005
+ this.$ = error;
1006
+ this.T = initialValue;
1007
+ this.r = options?.render ? EFFECT_RENDER : EFFECT_USER;
1008
+ if (this.r === EFFECT_RENDER) {
1009
+ this.P = function(p) {
1010
+ return !this.d && clock > this.C.created && !(this.i & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
1038
1011
  };
1039
1012
  }
1040
- this.K();
1041
- !options?.defer && (this.C === EFFECT_USER ? getQueue(this).enqueue(this.C, this.F.bind(this)) : this.F(this.C));
1013
+ this.M();
1014
+ !options?.defer && (this.r === EFFECT_USER ? getQueue(this).enqueue(this.r, this.w.bind(this)) : this.w(this.r));
1042
1015
  }
1043
1016
  write(value, flags = 0) {
1044
- if (this.c == STATE_DIRTY) {
1045
- this.h = flags;
1046
- if (this.C === EFFECT_RENDER) {
1047
- getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.h);
1017
+ if (this.b == STATE_DIRTY) {
1018
+ this.i = flags;
1019
+ if (this.r === EFFECT_RENDER) {
1020
+ getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.i);
1048
1021
  }
1049
1022
  }
1050
1023
  if (value === UNCHANGED)
1051
1024
  return this.l;
1052
1025
  this.l = value;
1053
1026
  this.da = true;
1054
- this.L = void 0;
1027
+ this.O = void 0;
1055
1028
  return value;
1056
1029
  }
1057
- y(state, skipQueue) {
1058
- if (this.c >= state || skipQueue)
1030
+ t(state, skipQueue) {
1031
+ if (this.b >= state || skipQueue)
1059
1032
  return;
1060
- if (this.c === STATE_CLEAN)
1061
- getQueue(this).enqueue(this.C, this.F.bind(this));
1062
- this.c = state;
1033
+ if (this.b === STATE_CLEAN || this.d && !ActiveTransition)
1034
+ getQueue(this).enqueue(this.r, this.w.bind(this));
1035
+ this.b = state;
1063
1036
  }
1064
- Z(mask, newFlags2) {
1065
- if (this.e) {
1066
- if (this.c >= STATE_DIRTY)
1037
+ _(mask, newFlags2) {
1038
+ if (this.d) {
1039
+ if (this.b >= STATE_DIRTY)
1067
1040
  return;
1068
1041
  if (mask & 3) {
1069
- this.y(STATE_DIRTY);
1042
+ this.t(STATE_DIRTY);
1070
1043
  return;
1071
1044
  }
1072
1045
  }
1073
- super.Z(mask, newFlags2);
1046
+ super._(mask, newFlags2);
1074
1047
  }
1075
- E(error) {
1076
- this.L = error;
1048
+ N(error) {
1049
+ this.O = error;
1077
1050
  getQueue(this).notify(this, LOADING_BIT, 0);
1078
- this.h = ERROR_BIT;
1079
- if (this.C === EFFECT_USER) {
1051
+ this.i = ERROR_BIT;
1052
+ if (this.r === EFFECT_USER) {
1080
1053
  try {
1081
- return this._ ? this._(error, () => {
1082
- this.O?.();
1083
- this.O = void 0;
1054
+ return this.$ ? this.$(error, () => {
1055
+ this.u?.();
1056
+ this.u = void 0;
1084
1057
  }) : console.error(error);
1085
1058
  } catch (e) {
1086
1059
  error = e;
@@ -1089,50 +1062,81 @@ var Effect = class extends Computation {
1089
1062
  if (!getQueue(this).notify(this, ERROR_BIT, ERROR_BIT))
1090
1063
  throw error;
1091
1064
  }
1092
- R() {
1093
- if (this.c === STATE_DISPOSED)
1065
+ L() {
1066
+ if (this.b === STATE_DISPOSED)
1094
1067
  return;
1095
1068
  this.ca = void 0;
1069
+ this.T = void 0;
1096
1070
  this.$ = void 0;
1097
- this._ = void 0;
1098
- this.O?.();
1099
- this.O = void 0;
1071
+ this.u?.();
1072
+ this.u = void 0;
1100
1073
  getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
1101
- super.R();
1074
+ super.L();
1102
1075
  }
1103
- F(type) {
1076
+ w(type) {
1104
1077
  if (type) {
1105
- const effect = this.e || this;
1106
- if (effect.da && effect.c !== STATE_DISPOSED) {
1107
- effect.O?.();
1078
+ const effect = this.d || this;
1079
+ if (effect.da && effect.b !== STATE_DISPOSED) {
1080
+ effect.u?.();
1108
1081
  try {
1109
- effect.O = effect.ca(effect.l, effect.$);
1082
+ effect.u = effect.ca(effect.l, effect.T);
1110
1083
  } catch (e) {
1111
1084
  if (!getQueue(effect).notify(effect, ERROR_BIT, ERROR_BIT))
1112
1085
  throw e;
1113
1086
  } finally {
1114
- effect.$ = effect.l;
1087
+ effect.T = effect.l;
1115
1088
  effect.da = false;
1116
1089
  }
1117
1090
  }
1118
1091
  } else
1119
- this.c !== STATE_CLEAN && runTop(this);
1092
+ this.b !== STATE_CLEAN && runTop(this);
1093
+ }
1094
+ };
1095
+ var TrackedEffect = class extends Computation {
1096
+ r = EFFECT_USER;
1097
+ u;
1098
+ constructor(compute2, options) {
1099
+ super(void 0, () => {
1100
+ this.u?.();
1101
+ this.u = latest(compute2);
1102
+ return void 0;
1103
+ }, options);
1104
+ getQueue(this).enqueue(this.r, this.w.bind(this));
1105
+ }
1106
+ t(state, skipQueue) {
1107
+ if (this.b >= state || skipQueue)
1108
+ return;
1109
+ if (this.b === STATE_CLEAN || this.d && !ActiveTransition)
1110
+ getQueue(this).enqueue(this.r, this.w.bind(this));
1111
+ this.b = state;
1112
+ }
1113
+ L() {
1114
+ if (this.b === STATE_DISPOSED)
1115
+ return;
1116
+ this.u?.();
1117
+ this.u = void 0;
1118
+ getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
1119
+ super.L();
1120
+ }
1121
+ w(type) {
1122
+ if (type)
1123
+ this.b !== STATE_CLEAN && runTop(this);
1120
1124
  }
1121
1125
  };
1122
1126
  var EagerComputation = class extends Computation {
1123
1127
  constructor(initialValue, compute2, options) {
1124
1128
  super(initialValue, compute2, options);
1125
- !options?.defer && this.K();
1129
+ !options?.defer && this.M();
1126
1130
  }
1127
- y(state, skipQueue) {
1128
- if (this.c >= state && !this.D)
1131
+ t(state, skipQueue) {
1132
+ if (this.b >= state && !this.E)
1129
1133
  return;
1130
- if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.D))
1131
- getQueue(this).enqueue(EFFECT_PURE, this.F.bind(this));
1132
- super.y(state, skipQueue);
1134
+ if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.E))
1135
+ getQueue(this).enqueue(EFFECT_PURE, this.w.bind(this));
1136
+ super.t(state, skipQueue);
1133
1137
  }
1134
- F() {
1135
- this.c !== STATE_CLEAN && runTop(this);
1138
+ w() {
1139
+ this.b !== STATE_CLEAN && runTop(this);
1136
1140
  }
1137
1141
  };
1138
1142
  var FirewallComputation = class extends Computation {
@@ -1140,16 +1144,16 @@ var FirewallComputation = class extends Computation {
1140
1144
  constructor(compute2) {
1141
1145
  super(void 0, compute2);
1142
1146
  }
1143
- y(state, skipQueue) {
1144
- if (this.c >= state && !this.D)
1147
+ t(state, skipQueue) {
1148
+ if (this.b >= state && !this.E)
1145
1149
  return;
1146
- if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.D))
1147
- getQueue(this).enqueue(EFFECT_PURE, this.F.bind(this));
1148
- super.y(state, true);
1149
- this.D = !!skipQueue;
1150
+ if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.E))
1151
+ getQueue(this).enqueue(EFFECT_PURE, this.w.bind(this));
1152
+ super.t(state, true);
1153
+ this.E = !!skipQueue;
1150
1154
  }
1151
- F() {
1152
- this.c !== STATE_CLEAN && runTop(this);
1155
+ w() {
1156
+ this.b !== STATE_CLEAN && runTop(this);
1153
1157
  }
1154
1158
  };
1155
1159
  function runTop(node) {
@@ -1157,22 +1161,218 @@ function runTop(node) {
1157
1161
  for (let current = node; current !== null; current = current.k) {
1158
1162
  if (ActiveTransition && current.j)
1159
1163
  current = ActiveTransition.a.get(current);
1160
- if (current.c !== STATE_CLEAN) {
1164
+ if (current.b !== STATE_CLEAN) {
1161
1165
  ancestors.push(current);
1162
1166
  }
1163
1167
  }
1164
1168
  for (let i = ancestors.length - 1; i >= 0; i--) {
1165
- if (ancestors[i].c !== STATE_DISPOSED)
1166
- ancestors[i].K();
1169
+ if (ancestors[i].b !== STATE_DISPOSED)
1170
+ ancestors[i].M();
1167
1171
  }
1168
1172
  }
1169
1173
 
1174
+ // src/signals.ts
1175
+ function createSignal(first, second, third) {
1176
+ if (typeof first === "function") {
1177
+ const node2 = new Computation(second, first, third);
1178
+ return [node2.read.bind(node2), node2.write.bind(node2)];
1179
+ }
1180
+ const o = getOwner();
1181
+ const needsId = o?.id != null;
1182
+ const node = new Computation(
1183
+ first,
1184
+ null,
1185
+ needsId ? { id: o.getNextChildId(), ...second } : second
1186
+ );
1187
+ return [node.read.bind(node), node.write.bind(node)];
1188
+ }
1189
+ function createMemo(compute2, value, options) {
1190
+ let node = new Computation(
1191
+ value,
1192
+ compute2,
1193
+ options
1194
+ );
1195
+ let resolvedValue;
1196
+ return () => {
1197
+ if (node) {
1198
+ if (node.b === STATE_DISPOSED) {
1199
+ node = void 0;
1200
+ return resolvedValue;
1201
+ }
1202
+ resolvedValue = node.wait();
1203
+ if (!node.a?.length && node.m?.k !== node && !(node.i & UNINITIALIZED_BIT)) {
1204
+ node.dispose();
1205
+ node = void 0;
1206
+ }
1207
+ }
1208
+ return resolvedValue;
1209
+ };
1210
+ }
1211
+ function createAsync(compute2, value, options) {
1212
+ let refreshing = false;
1213
+ const node = new EagerComputation(
1214
+ value,
1215
+ (p) => {
1216
+ const source = compute2(p, refreshing);
1217
+ refreshing = false;
1218
+ const isPromise = source instanceof Promise;
1219
+ const iterator = source[Symbol.asyncIterator];
1220
+ if (!isPromise && !iterator) {
1221
+ return source;
1222
+ }
1223
+ let abort = false;
1224
+ onCleanup(() => abort = true);
1225
+ let transition2 = ActiveTransition;
1226
+ if (isPromise) {
1227
+ source.then(
1228
+ (value3) => {
1229
+ if (abort)
1230
+ return;
1231
+ if (transition2)
1232
+ return transition2.runTransition(() => {
1233
+ node.write(value3, 0, true);
1234
+ }, true);
1235
+ node.write(value3, 0, true);
1236
+ },
1237
+ (error) => {
1238
+ if (abort)
1239
+ return;
1240
+ if (transition2)
1241
+ return transition2.runTransition(() => node.N(error), true);
1242
+ node.N(error);
1243
+ }
1244
+ );
1245
+ } else {
1246
+ (async () => {
1247
+ try {
1248
+ for await (let value3 of source) {
1249
+ if (abort)
1250
+ return;
1251
+ if (transition2)
1252
+ return transition2.runTransition(() => {
1253
+ node.write(value3, 0, true);
1254
+ transition2 = null;
1255
+ }, true);
1256
+ node.write(value3, 0, true);
1257
+ }
1258
+ } catch (error) {
1259
+ if (abort)
1260
+ return;
1261
+ if (transition2)
1262
+ return transition2.runTransition(() => {
1263
+ node.N(error);
1264
+ transition2 = null;
1265
+ }, true);
1266
+ node.N(error);
1267
+ }
1268
+ })();
1269
+ }
1270
+ throw new NotReadyError();
1271
+ },
1272
+ options
1273
+ );
1274
+ const read = node.wait.bind(node);
1275
+ read.refresh = () => {
1276
+ let n = node;
1277
+ if (ActiveTransition && !node.d) {
1278
+ n = cloneGraph(node);
1279
+ }
1280
+ n.b = STATE_DIRTY;
1281
+ refreshing = true;
1282
+ n.M();
1283
+ };
1284
+ return read;
1285
+ }
1286
+ function createEffect(compute2, effect, value, options) {
1287
+ void new Effect(
1288
+ value,
1289
+ compute2,
1290
+ effect.effect || effect,
1291
+ effect.error,
1292
+ options
1293
+ );
1294
+ }
1295
+ function createRenderEffect(compute2, effect, value, options) {
1296
+ void new Effect(value, compute2, effect, void 0, {
1297
+ render: true,
1298
+ ...options
1299
+ });
1300
+ }
1301
+ function createTrackedEffect(compute2, options) {
1302
+ void new TrackedEffect(compute2, options);
1303
+ }
1304
+ function createReaction(effect, options) {
1305
+ let cleanup = void 0;
1306
+ onCleanup(() => cleanup?.());
1307
+ return (tracking) => {
1308
+ const node = new Effect(
1309
+ void 0,
1310
+ tracking,
1311
+ () => {
1312
+ cleanup?.();
1313
+ cleanup = (effect.effect || effect)?.();
1314
+ node.dispose(true);
1315
+ },
1316
+ effect.error,
1317
+ {
1318
+ defer: true,
1319
+ ...options
1320
+ }
1321
+ );
1322
+ };
1323
+ }
1324
+ function createRoot(init, options) {
1325
+ const owner = new Owner(options?.id);
1326
+ return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
1327
+ }
1328
+ function runWithOwner(owner, run) {
1329
+ return compute(owner, run, null);
1330
+ }
1331
+ function resolve(fn) {
1332
+ return new Promise((res, rej) => {
1333
+ createRoot((dispose) => {
1334
+ new EagerComputation(void 0, () => {
1335
+ try {
1336
+ res(fn());
1337
+ } catch (err) {
1338
+ if (err instanceof NotReadyError)
1339
+ throw err;
1340
+ rej(err);
1341
+ }
1342
+ dispose();
1343
+ });
1344
+ });
1345
+ });
1346
+ }
1347
+ function createOptimistic(first, second, third) {
1348
+ const node = typeof first === "function" ? new Computation(second, first, third) : new Computation(first, null, second);
1349
+ const reset = () => node.write(first);
1350
+ function write(v) {
1351
+ if (!ActiveTransition)
1352
+ throw new Error("createOptimistic can only be updated inside a transition");
1353
+ ActiveTransition.addOptimistic(reset);
1354
+ cloneGraph(node, true);
1355
+ queueMicrotask(() => reset.j && node.write(v));
1356
+ }
1357
+ return [node.read.bind(node), write];
1358
+ }
1359
+ function useTransition() {
1360
+ const [pending, setPending] = createOptimistic(false);
1361
+ function start(fn) {
1362
+ transition((resume) => {
1363
+ setPending(true);
1364
+ return fn(resume);
1365
+ });
1366
+ }
1367
+ return [pending, start];
1368
+ }
1369
+
1170
1370
  // src/store/reconcile.ts
1171
1371
  function unwrap(value) {
1172
1372
  return value?.[$TARGET]?.[STORE_NODE] ?? value;
1173
1373
  }
1174
- function getOverrideValue(value, override, key) {
1175
- return override && key in override ? override[key] : value[key];
1374
+ function getOverrideValue(value, override, nodes, key) {
1375
+ return nodes && key in nodes ? nodes[key].read() : override && key in override ? override[key] : value[key];
1176
1376
  }
1177
1377
  function getAllKeys(value, override, next) {
1178
1378
  const keys = getKeys(value, override);
@@ -1185,6 +1385,7 @@ function applyState(next, state, keyFn, all) {
1185
1385
  return;
1186
1386
  const previous = target[STORE_VALUE];
1187
1387
  const override = target[STORE_OVERRIDE];
1388
+ let nodes = target[STORE_NODE];
1188
1389
  if (next === previous && !override)
1189
1390
  return;
1190
1391
  (target[STORE_LOOKUP] || storeLookup).set(next, target[$PROXY]);
@@ -1192,14 +1393,14 @@ function applyState(next, state, keyFn, all) {
1192
1393
  target[STORE_OVERRIDE] = void 0;
1193
1394
  if (Array.isArray(previous)) {
1194
1395
  let changed = false;
1195
- const prevLength = getOverrideValue(previous, override, "length");
1396
+ const prevLength = getOverrideValue(previous, override, nodes, "length");
1196
1397
  if (next.length && prevLength && next[0] && keyFn(next[0]) != null) {
1197
1398
  let i, j, start, end, newEnd, item, newIndicesNext, keyVal;
1198
- for (start = 0, end = Math.min(prevLength, next.length); start < end && ((item = getOverrideValue(previous, override, start)) === next[start] || item && next[start] && keyFn(item) === keyFn(next[start])); start++) {
1399
+ for (start = 0, end = Math.min(prevLength, next.length); start < end && ((item = getOverrideValue(previous, override, nodes, start)) === next[start] || item && next[start] && keyFn(item) === keyFn(next[start])); start++) {
1199
1400
  applyState(next[start], wrap(item, target), keyFn, all);
1200
1401
  }
1201
1402
  const temp = new Array(next.length), newIndices = /* @__PURE__ */ new Map();
1202
- for (end = prevLength - 1, newEnd = next.length - 1; end >= start && newEnd >= start && ((item = getOverrideValue(previous, override, end)) === next[newEnd] || item && next[newEnd] && keyFn(item) === keyFn(next[newEnd])); end--, newEnd--) {
1403
+ for (end = prevLength - 1, newEnd = next.length - 1; end >= start && newEnd >= start && ((item = getOverrideValue(previous, override, nodes, end)) === next[newEnd] || item && next[newEnd] && keyFn(item) === keyFn(next[newEnd])); end--, newEnd--) {
1203
1404
  temp[newEnd] = item;
1204
1405
  }
1205
1406
  if (start > newEnd || start > end) {
@@ -1226,7 +1427,7 @@ function applyState(next, state, keyFn, all) {
1226
1427
  newIndices.set(keyVal, j);
1227
1428
  }
1228
1429
  for (i = start; i <= end; i++) {
1229
- item = getOverrideValue(previous, override, i);
1430
+ item = getOverrideValue(previous, override, nodes, i);
1230
1431
  keyVal = item ? keyFn(item) : item;
1231
1432
  j = newIndices.get(keyVal);
1232
1433
  if (j !== void 0 && j !== -1) {
@@ -1247,7 +1448,7 @@ function applyState(next, state, keyFn, all) {
1247
1448
  changed = true;
1248
1449
  } else if (prevLength && next.length) {
1249
1450
  for (let i = 0, len = next.length; i < len; i++) {
1250
- const item = getOverrideValue(previous, override, i);
1451
+ const item = getOverrideValue(previous, override, nodes, i);
1251
1452
  isWrappable(item) && applyState(next[i], wrap(item, target), keyFn, all);
1252
1453
  }
1253
1454
  }
@@ -1258,14 +1459,13 @@ function applyState(next, state, keyFn, all) {
1258
1459
  changed && target[STORE_NODE][$TRACK]?.write(void 0);
1259
1460
  return;
1260
1461
  }
1261
- let nodes = target[STORE_NODE];
1262
1462
  if (nodes) {
1263
1463
  const tracked = nodes[$TRACK];
1264
1464
  const keys = tracked || all ? getAllKeys(previous, override, next) : Object.keys(nodes);
1265
1465
  for (let i = 0, len = keys.length; i < len; i++) {
1266
1466
  const key = keys[i];
1267
1467
  const node = nodes[key];
1268
- const previousValue = unwrap(getOverrideValue(previous, override, key));
1468
+ const previousValue = unwrap(getOverrideValue(previous, override, nodes, key));
1269
1469
  let nextValue = unwrap(next[key]);
1270
1470
  if (previousValue === nextValue)
1271
1471
  continue;
@@ -1296,16 +1496,7 @@ function reconcile(value, key, all = false) {
1296
1496
  }
1297
1497
 
1298
1498
  // src/store/projection.ts
1299
- function createProjection(fn, initialValue = {}, options) {
1300
- let wrappedStore;
1301
- const node = new FirewallComputation(() => {
1302
- storeSetter(wrappedStore, (s) => {
1303
- const value = fn(s);
1304
- if (value !== s && value !== void 0) {
1305
- reconcile(value, options?.key || "id", options?.all)(s);
1306
- }
1307
- });
1308
- });
1499
+ function createProjectionInternal(fn, initialValue = {}, options) {
1309
1500
  const wrappedMap = /* @__PURE__ */ new WeakMap();
1310
1501
  const traps = {
1311
1502
  ...storeTraps,
@@ -1316,7 +1507,7 @@ function createProjection(fn, initialValue = {}, options) {
1316
1507
  return storeTraps.get(target, property, receiver);
1317
1508
  }
1318
1509
  };
1319
- function wrapProjection(source) {
1510
+ const wrapProjection = (source) => {
1320
1511
  if (wrappedMap.has(source))
1321
1512
  return wrappedMap.get(source);
1322
1513
  if (source[$TARGET]?.[STORE_WRAP] === wrapProjection)
@@ -1327,8 +1518,20 @@ function createProjection(fn, initialValue = {}, options) {
1327
1518
  });
1328
1519
  wrappedMap.set(source, wrapped);
1329
1520
  return wrapped;
1330
- }
1331
- return wrappedStore = wrapProjection(initialValue);
1521
+ };
1522
+ const wrappedStore = wrapProjection(initialValue);
1523
+ const node = new FirewallComputation(() => {
1524
+ storeSetter(wrappedStore, (s) => {
1525
+ const value = fn(s);
1526
+ if (value !== s && value !== void 0) {
1527
+ reconcile(value, options?.key || "id", options?.all)(s);
1528
+ }
1529
+ });
1530
+ });
1531
+ return { store: wrappedStore, node };
1532
+ }
1533
+ function createProjection(fn, initialValue = {}, options) {
1534
+ return createProjectionInternal(fn, initialValue, options).store;
1332
1535
  }
1333
1536
 
1334
1537
  // src/store/store.ts
@@ -1464,7 +1667,7 @@ var storeTraps = {
1464
1667
  untrack(() => {
1465
1668
  const state = target[STORE_VALUE];
1466
1669
  const base = state[property];
1467
- const prev = target[STORE_OVERRIDE]?.[property] || base;
1670
+ const prev = target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE] ? target[STORE_OVERRIDE][property] : base;
1468
1671
  const value = rawValue?.[$TARGET]?.[STORE_VALUE] ?? rawValue;
1469
1672
  if (prev === value)
1470
1673
  return true;
@@ -1496,7 +1699,7 @@ var storeTraps = {
1496
1699
  deleteProperty(target, property) {
1497
1700
  if (Writing?.has(target[$PROXY]) && target[STORE_OVERRIDE]?.[property] !== $DELETED) {
1498
1701
  untrack(() => {
1499
- const prev = target[STORE_OVERRIDE]?.[property] || target[STORE_VALUE][property];
1702
+ const prev = target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE] ? target[STORE_OVERRIDE][property] : target[STORE_VALUE][property];
1500
1703
  if (property in target[STORE_VALUE]) {
1501
1704
  (target[STORE_OVERRIDE] || (target[STORE_OVERRIDE] = /* @__PURE__ */ Object.create(null)))[property] = $DELETED;
1502
1705
  } else if (target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE]) {
@@ -1555,7 +1758,7 @@ function storeSetter(store, fn) {
1555
1758
  }
1556
1759
  }
1557
1760
  function createStore(first, second, options) {
1558
- const derived = typeof first === "function", wrappedStore = derived ? createProjection(first, second, options) : wrap(first);
1761
+ const derived = typeof first === "function", wrappedStore = derived ? createProjectionInternal(first, second, options).store : wrap(first);
1559
1762
  return [wrappedStore, (fn) => storeSetter(wrappedStore, fn)];
1560
1763
  }
1561
1764
  function recursivelyNotify(state, lookup) {
@@ -1619,6 +1822,29 @@ function deep(store) {
1619
1822
  return store[$DEEP];
1620
1823
  }
1621
1824
 
1825
+ // src/store/optimistic.ts
1826
+ function createOptimisticStore(first, second, options) {
1827
+ const derived = typeof first === "function";
1828
+ const { store, node } = derived ? createProjectionInternal(first, second, options) : createProjectionInternal(() => {
1829
+ }, first);
1830
+ const reset = () => storeSetter(
1831
+ store,
1832
+ reconcile(
1833
+ derived ? first(store) || store : first,
1834
+ options?.key || "id",
1835
+ options?.all
1836
+ )
1837
+ );
1838
+ const write = (v) => {
1839
+ if (!ActiveTransition)
1840
+ throw new Error("createOptimisticStore can only be updated inside a transition");
1841
+ ActiveTransition.addOptimistic(reset);
1842
+ cloneGraph(node, true);
1843
+ queueMicrotask(() => reset.j && storeSetter(store, v));
1844
+ };
1845
+ return [store, write];
1846
+ }
1847
+
1622
1848
  // src/store/utils.ts
1623
1849
  function snapshot(item, map, lookup) {
1624
1850
  let target, isArray, override, result, unwrapped, v;
@@ -1819,287 +2045,78 @@ function omit(props, ...keys) {
1819
2045
  return result;
1820
2046
  }
1821
2047
 
1822
- // src/signals.ts
1823
- function createSignal(first, second, third) {
1824
- if (typeof first === "function") {
1825
- const memo = createMemo((p) => {
1826
- const node2 = new Computation(
1827
- first(p ? untrack(p[0]) : second),
1828
- null,
1829
- third
1830
- );
1831
- return [node2.read.bind(node2), node2.write.bind(node2)];
1832
- });
1833
- return [() => memo()[0](), (value) => memo()[1](value)];
1834
- }
1835
- const o = getOwner();
1836
- const needsId = o?.id != null;
1837
- const node = new Computation(
1838
- first,
1839
- null,
1840
- needsId ? { id: o.getNextChildId(), ...second } : second
1841
- );
1842
- return [node.read.bind(node), node.write.bind(node)];
1843
- }
1844
- function createMemo(compute2, value, options) {
1845
- let node = new Computation(
1846
- value,
1847
- compute2,
1848
- options
1849
- );
1850
- let resolvedValue;
1851
- return () => {
1852
- if (node) {
1853
- if (node.c === STATE_DISPOSED) {
1854
- node = void 0;
1855
- return resolvedValue;
1856
- }
1857
- resolvedValue = node.wait();
1858
- if (!node.a?.length && node.m?.k !== node && !(node.h & UNINITIALIZED_BIT)) {
1859
- node.dispose();
1860
- node = void 0;
1861
- }
1862
- }
1863
- return resolvedValue;
1864
- };
1865
- }
1866
- function createAsync(compute2, value, options) {
1867
- let refreshing = false;
1868
- const node = new EagerComputation(
1869
- value,
1870
- (p) => {
1871
- const source = compute2(p, refreshing);
1872
- refreshing = false;
1873
- const isPromise = source instanceof Promise;
1874
- const iterator = source[Symbol.asyncIterator];
1875
- if (!isPromise && !iterator) {
1876
- return source;
1877
- }
1878
- let abort = false;
1879
- onCleanup(() => abort = true);
1880
- let transition2 = ActiveTransition;
1881
- if (isPromise) {
1882
- source.then(
1883
- (value3) => {
1884
- if (abort)
1885
- return;
1886
- if (transition2)
1887
- return transition2.runTransition(() => {
1888
- node.write(value3, 0, true);
1889
- }, true);
1890
- node.write(value3, 0, true);
1891
- },
1892
- (error) => {
1893
- if (abort)
1894
- return;
1895
- if (transition2)
1896
- return transition2.runTransition(() => node.E(error), true);
1897
- node.E(error);
1898
- }
1899
- );
1900
- } else {
1901
- (async () => {
1902
- try {
1903
- for await (let value3 of source) {
1904
- if (abort)
1905
- return;
1906
- if (transition2)
1907
- return transition2.runTransition(() => {
1908
- node.write(value3, 0, true);
1909
- transition2 = null;
1910
- }, true);
1911
- node.write(value3, 0, true);
1912
- }
1913
- } catch (error) {
1914
- if (abort)
1915
- return;
1916
- if (transition2)
1917
- return transition2.runTransition(() => {
1918
- node.E(error);
1919
- transition2 = null;
1920
- }, true);
1921
- node.E(error);
1922
- }
1923
- })();
1924
- }
1925
- throw new NotReadyError();
1926
- },
1927
- options
1928
- );
1929
- const read = node.wait.bind(node);
1930
- read.refresh = () => {
1931
- let n = node;
1932
- if (ActiveTransition && !node.e) {
1933
- n = cloneGraph(node);
1934
- }
1935
- n.c = STATE_DIRTY;
1936
- refreshing = true;
1937
- n.K();
1938
- };
1939
- return read;
1940
- }
1941
- function createEffect(compute2, effect, value, options) {
1942
- void new Effect(
1943
- value,
1944
- compute2,
1945
- effect.effect ? effect.effect : effect,
1946
- effect.error,
1947
- options
1948
- );
1949
- }
1950
- function createRenderEffect(compute2, effect, value, options) {
1951
- void new Effect(value, compute2, effect, void 0, {
1952
- render: true,
1953
- ...options
1954
- });
1955
- }
1956
- function createRoot(init, options) {
1957
- const owner = new Owner(options?.id);
1958
- return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
1959
- }
1960
- function runWithOwner(owner, run) {
1961
- return compute(owner, run, null);
1962
- }
1963
- function resolve(fn) {
1964
- return new Promise((res, rej) => {
1965
- createRoot((dispose) => {
1966
- new EagerComputation(void 0, () => {
1967
- try {
1968
- res(fn());
1969
- } catch (err) {
1970
- if (err instanceof NotReadyError)
1971
- throw err;
1972
- rej(err);
1973
- }
1974
- dispose();
1975
- });
1976
- });
1977
- });
1978
- }
1979
- function createPending() {
1980
- const node = new Computation(false, null);
1981
- const reset = () => node.write(false);
1982
- function write() {
1983
- if (!ActiveTransition)
1984
- return false;
1985
- ActiveTransition.addOptimistic(reset);
1986
- queueMicrotask(() => reset.j && node.write(true));
1987
- }
1988
- function read() {
1989
- const v = node.read();
1990
- return ActiveTransition ? false : v;
1991
- }
1992
- return [read, write];
1993
- }
1994
- function useTransition() {
1995
- const [pending, setPending] = createPending();
1996
- function start(fn) {
1997
- transition((resume) => {
1998
- setPending(true);
1999
- return fn(resume);
2000
- });
2001
- }
2002
- return [pending, start];
2003
- }
2004
- function createOptimistic(first, second, options) {
2005
- let store, setStore;
2006
- if (typeof first === "function") {
2007
- [store, setStore] = createStore((s) => {
2008
- const value = first(s);
2009
- if (!ActiveTransition)
2010
- return value;
2011
- ActiveTransition.addOptimistic(reset);
2012
- }, {});
2013
- } else
2014
- [store, setStore] = createStore(first);
2015
- const reset = () => setStore(
2016
- reconcile(
2017
- typeof first === "function" ? first(second) : first,
2018
- options?.key || "id",
2019
- options?.all
2020
- )
2021
- );
2022
- function write(v) {
2023
- if (!ActiveTransition)
2024
- throw new Error("createOptimistic can only be updated inside a transition");
2025
- ActiveTransition.addOptimistic(reset);
2026
- queueMicrotask(() => reset.j && setStore(v));
2027
- }
2028
- return [store, write];
2029
- }
2030
-
2031
2048
  // src/map.ts
2032
2049
  function mapArray(list, map, options) {
2033
2050
  const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
2034
2051
  return updateKeyedMap.bind({
2035
- S: new Owner(),
2052
+ U: new Owner(),
2036
2053
  o: 0,
2037
2054
  ia: list,
2038
- G: [],
2039
- P: map,
2040
- i: [],
2041
- d: [],
2042
- Q: keyFn,
2055
+ F: [],
2056
+ R: map,
2057
+ h: [],
2058
+ e: [],
2059
+ S: keyFn,
2043
2060
  p: keyFn || options?.keyed === false ? [] : void 0,
2044
2061
  q: map.length > 1 ? [] : void 0,
2045
- T: options?.fallback
2062
+ V: options?.fallback
2046
2063
  });
2047
2064
  }
2048
2065
  var pureOptions = { pureWrite: true };
2049
2066
  function updateKeyedMap() {
2050
2067
  const newItems = this.ia() || [], newLen = newItems.length;
2051
2068
  newItems[$TRACK];
2052
- runWithOwner(this.S, () => {
2069
+ runWithOwner(this.U, () => {
2053
2070
  let i, j, mapper = this.p ? () => {
2054
2071
  this.p[j] = new Computation(newItems[j], null, pureOptions);
2055
2072
  this.q && (this.q[j] = new Computation(j, null, pureOptions));
2056
- return this.P(
2073
+ return this.R(
2057
2074
  Computation.prototype.read.bind(this.p[j]),
2058
2075
  this.q ? Computation.prototype.read.bind(this.q[j]) : void 0
2059
2076
  );
2060
2077
  } : this.q ? () => {
2061
2078
  const item = newItems[j];
2062
2079
  this.q[j] = new Computation(j, null, pureOptions);
2063
- return this.P(() => item, Computation.prototype.read.bind(this.q[j]));
2080
+ return this.R(() => item, Computation.prototype.read.bind(this.q[j]));
2064
2081
  } : () => {
2065
2082
  const item = newItems[j];
2066
- return this.P(() => item);
2083
+ return this.R(() => item);
2067
2084
  };
2068
2085
  if (newLen === 0) {
2069
2086
  if (this.o !== 0) {
2070
- this.S.dispose(false);
2071
- this.d = [];
2072
- this.G = [];
2073
- this.i = [];
2087
+ this.U.dispose(false);
2088
+ this.e = [];
2089
+ this.F = [];
2090
+ this.h = [];
2074
2091
  this.o = 0;
2075
2092
  this.p && (this.p = []);
2076
2093
  this.q && (this.q = []);
2077
2094
  }
2078
- if (this.T && !this.i[0]) {
2079
- this.i[0] = compute(
2080
- this.d[0] = new Owner(),
2081
- this.T,
2095
+ if (this.V && !this.h[0]) {
2096
+ this.h[0] = compute(
2097
+ this.e[0] = new Owner(),
2098
+ this.V,
2082
2099
  null
2083
2100
  );
2084
2101
  }
2085
2102
  } else if (this.o === 0) {
2086
- if (this.d[0])
2087
- this.d[0].dispose();
2088
- this.i = new Array(newLen);
2103
+ if (this.e[0])
2104
+ this.e[0].dispose();
2105
+ this.h = new Array(newLen);
2089
2106
  for (j = 0; j < newLen; j++) {
2090
- this.G[j] = newItems[j];
2091
- this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
2107
+ this.F[j] = newItems[j];
2108
+ this.h[j] = compute(this.e[j] = new Owner(), mapper, null);
2092
2109
  }
2093
2110
  this.o = newLen;
2094
2111
  } else {
2095
2112
  let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.p ? new Array(newLen) : void 0, tempIndexes = this.q ? new Array(newLen) : void 0;
2096
- for (start = 0, end = Math.min(this.o, newLen); start < end && (this.G[start] === newItems[start] || this.p && compare(this.Q, this.G[start], newItems[start])); start++) {
2113
+ for (start = 0, end = Math.min(this.o, newLen); start < end && (this.F[start] === newItems[start] || this.p && compare(this.S, this.F[start], newItems[start])); start++) {
2097
2114
  if (this.p)
2098
2115
  this.p[start].write(newItems[start]);
2099
2116
  }
2100
- for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.G[end] === newItems[newEnd] || this.p && compare(this.Q, this.G[end], newItems[newEnd])); end--, newEnd--) {
2101
- temp[newEnd] = this.i[end];
2102
- tempNodes[newEnd] = this.d[end];
2117
+ for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.F[end] === newItems[newEnd] || this.p && compare(this.S, this.F[end], newItems[newEnd])); end--, newEnd--) {
2118
+ temp[newEnd] = this.h[end];
2119
+ tempNodes[newEnd] = this.e[end];
2103
2120
  tempRows && (tempRows[newEnd] = this.p[end]);
2104
2121
  tempIndexes && (tempIndexes[newEnd] = this.q[end]);
2105
2122
  }
@@ -2107,29 +2124,29 @@ function updateKeyedMap() {
2107
2124
  newIndicesNext = new Array(newEnd + 1);
2108
2125
  for (j = newEnd; j >= start; j--) {
2109
2126
  item = newItems[j];
2110
- key = this.Q ? this.Q(item) : item;
2127
+ key = this.S ? this.S(item) : item;
2111
2128
  i = newIndices.get(key);
2112
2129
  newIndicesNext[j] = i === void 0 ? -1 : i;
2113
2130
  newIndices.set(key, j);
2114
2131
  }
2115
2132
  for (i = start; i <= end; i++) {
2116
- item = this.G[i];
2117
- key = this.Q ? this.Q(item) : item;
2133
+ item = this.F[i];
2134
+ key = this.S ? this.S(item) : item;
2118
2135
  j = newIndices.get(key);
2119
2136
  if (j !== void 0 && j !== -1) {
2120
- temp[j] = this.i[i];
2121
- tempNodes[j] = this.d[i];
2137
+ temp[j] = this.h[i];
2138
+ tempNodes[j] = this.e[i];
2122
2139
  tempRows && (tempRows[j] = this.p[i]);
2123
2140
  tempIndexes && (tempIndexes[j] = this.q[i]);
2124
2141
  j = newIndicesNext[j];
2125
2142
  newIndices.set(key, j);
2126
2143
  } else
2127
- this.d[i].dispose();
2144
+ this.e[i].dispose();
2128
2145
  }
2129
2146
  for (j = start; j < newLen; j++) {
2130
2147
  if (j in temp) {
2131
- this.i[j] = temp[j];
2132
- this.d[j] = tempNodes[j];
2148
+ this.h[j] = temp[j];
2149
+ this.e[j] = tempNodes[j];
2133
2150
  if (tempRows) {
2134
2151
  this.p[j] = tempRows[j];
2135
2152
  this.p[j].write(newItems[j]);
@@ -2139,89 +2156,89 @@ function updateKeyedMap() {
2139
2156
  this.q[j].write(j);
2140
2157
  }
2141
2158
  } else {
2142
- this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
2159
+ this.h[j] = compute(this.e[j] = new Owner(), mapper, null);
2143
2160
  }
2144
2161
  }
2145
- this.i = this.i.slice(0, this.o = newLen);
2146
- this.G = newItems.slice(0);
2162
+ this.h = this.h.slice(0, this.o = newLen);
2163
+ this.F = newItems.slice(0);
2147
2164
  }
2148
2165
  });
2149
- return this.i;
2166
+ return this.h;
2150
2167
  }
2151
2168
  function repeat(count, map, options) {
2152
2169
  return updateRepeat.bind({
2153
- S: new Owner(),
2170
+ U: new Owner(),
2154
2171
  o: 0,
2155
- z: 0,
2172
+ A: 0,
2156
2173
  ja: count,
2157
- P: map,
2158
- d: [],
2159
- i: [],
2174
+ R: map,
2175
+ e: [],
2176
+ h: [],
2160
2177
  ka: options?.from,
2161
- T: options?.fallback
2178
+ V: options?.fallback
2162
2179
  });
2163
2180
  }
2164
2181
  function updateRepeat() {
2165
2182
  const newLen = this.ja();
2166
2183
  const from = this.ka?.() || 0;
2167
- runWithOwner(this.S, () => {
2184
+ runWithOwner(this.U, () => {
2168
2185
  if (newLen === 0) {
2169
2186
  if (this.o !== 0) {
2170
- this.S.dispose(false);
2171
- this.d = [];
2172
- this.i = [];
2187
+ this.U.dispose(false);
2188
+ this.e = [];
2189
+ this.h = [];
2173
2190
  this.o = 0;
2174
2191
  }
2175
- if (this.T && !this.i[0]) {
2176
- this.i[0] = compute(
2177
- this.d[0] = new Owner(),
2178
- this.T,
2192
+ if (this.V && !this.h[0]) {
2193
+ this.h[0] = compute(
2194
+ this.e[0] = new Owner(),
2195
+ this.V,
2179
2196
  null
2180
2197
  );
2181
2198
  }
2182
2199
  return;
2183
2200
  }
2184
2201
  const to = from + newLen;
2185
- const prevTo = this.z + this.o;
2186
- if (this.o === 0 && this.d[0])
2187
- this.d[0].dispose();
2202
+ const prevTo = this.A + this.o;
2203
+ if (this.o === 0 && this.e[0])
2204
+ this.e[0].dispose();
2188
2205
  for (let i = to; i < prevTo; i++)
2189
- this.d[i - this.z].dispose();
2190
- if (this.z < from) {
2191
- let i = this.z;
2206
+ this.e[i - this.A].dispose();
2207
+ if (this.A < from) {
2208
+ let i = this.A;
2192
2209
  while (i < from && i < this.o)
2193
- this.d[i++].dispose();
2194
- this.d.splice(0, from - this.z);
2195
- this.i.splice(0, from - this.z);
2196
- } else if (this.z > from) {
2197
- let i = prevTo - this.z - 1;
2198
- let difference = this.z - from;
2199
- this.d.length = this.i.length = newLen;
2210
+ this.e[i++].dispose();
2211
+ this.e.splice(0, from - this.A);
2212
+ this.h.splice(0, from - this.A);
2213
+ } else if (this.A > from) {
2214
+ let i = prevTo - this.A - 1;
2215
+ let difference = this.A - from;
2216
+ this.e.length = this.h.length = newLen;
2200
2217
  while (i >= difference) {
2201
- this.d[i] = this.d[i - difference];
2202
- this.i[i] = this.i[i - difference];
2218
+ this.e[i] = this.e[i - difference];
2219
+ this.h[i] = this.h[i - difference];
2203
2220
  i--;
2204
2221
  }
2205
2222
  for (let i2 = 0; i2 < difference; i2++) {
2206
- this.i[i2] = compute(
2207
- this.d[i2] = new Owner(),
2208
- () => this.P(i2 + from),
2223
+ this.h[i2] = compute(
2224
+ this.e[i2] = new Owner(),
2225
+ () => this.R(i2 + from),
2209
2226
  null
2210
2227
  );
2211
2228
  }
2212
2229
  }
2213
2230
  for (let i = prevTo; i < to; i++) {
2214
- this.i[i - from] = compute(
2215
- this.d[i - from] = new Owner(),
2216
- () => this.P(i),
2231
+ this.h[i - from] = compute(
2232
+ this.e[i - from] = new Owner(),
2233
+ () => this.R(i),
2217
2234
  null
2218
2235
  );
2219
2236
  }
2220
- this.i = this.i.slice(0, newLen);
2221
- this.z = from;
2237
+ this.h = this.h.slice(0, newLen);
2238
+ this.A = from;
2222
2239
  this.o = newLen;
2223
2240
  });
2224
- return this.i;
2241
+ return this.h;
2225
2242
  }
2226
2243
  function compare(key, a, b) {
2227
2244
  return key ? key(a) === key(b) : true;
@@ -2229,24 +2246,24 @@ function compare(key, a, b) {
2229
2246
 
2230
2247
  // src/boundaries.ts
2231
2248
  var BoundaryComputation = class extends EagerComputation {
2232
- U;
2249
+ W;
2233
2250
  constructor(compute2, propagationMask) {
2234
2251
  super(void 0, compute2, { defer: true });
2235
- this.U = propagationMask;
2252
+ this.W = propagationMask;
2236
2253
  }
2237
2254
  write(value, flags) {
2238
- super.write(value, flags & ~this.U);
2239
- if (this.U & LOADING_BIT && !(this.h & UNINITIALIZED_BIT || ActiveTransition)) {
2255
+ super.write(value, flags & ~this.W);
2256
+ if (this.W & LOADING_BIT && !(this.i & UNINITIALIZED_BIT || ActiveTransition)) {
2240
2257
  flags &= ~LOADING_BIT;
2241
2258
  }
2242
- getQueue(this).notify(this, this.U, flags);
2259
+ getQueue(this).notify(this, this.W, flags);
2243
2260
  return this.l;
2244
2261
  }
2245
2262
  };
2246
2263
  function createBoundChildren(owner, fn, queue, mask) {
2247
- const parentQueue = owner.B;
2248
- parentQueue.addChild(owner.B = queue);
2249
- onCleanup(() => parentQueue.removeChild(owner.B));
2264
+ const parentQueue = owner.C;
2265
+ parentQueue.addChild(owner.C = queue);
2266
+ onCleanup(() => parentQueue.removeChild(owner.C));
2250
2267
  return compute(
2251
2268
  owner,
2252
2269
  () => {
@@ -2257,22 +2274,20 @@ function createBoundChildren(owner, fn, queue, mask) {
2257
2274
  );
2258
2275
  }
2259
2276
  var ConditionalQueue = class extends Queue {
2260
- t;
2261
- V = /* @__PURE__ */ new Set();
2277
+ x;
2278
+ X = /* @__PURE__ */ new Set();
2262
2279
  s = /* @__PURE__ */ new Set();
2263
2280
  constructor(disabled) {
2264
2281
  super();
2265
- this.t = disabled;
2282
+ this.x = disabled;
2266
2283
  }
2267
2284
  run(type) {
2268
- if (!type || this.t.read())
2285
+ if (!type || this.x.read())
2269
2286
  return;
2270
2287
  return super.run(type);
2271
2288
  }
2272
2289
  notify(node, type, flags) {
2273
- if (ActiveTransition && ActiveTransition.r.has(this))
2274
- return ActiveTransition.r.get(this).notify(node, type, flags);
2275
- if (this.t.read()) {
2290
+ if (this.x.read()) {
2276
2291
  if (type & LOADING_BIT) {
2277
2292
  if (flags & LOADING_BIT) {
2278
2293
  this.s.add(node);
@@ -2282,9 +2297,9 @@ var ConditionalQueue = class extends Queue {
2282
2297
  }
2283
2298
  if (type & ERROR_BIT) {
2284
2299
  if (flags & ERROR_BIT) {
2285
- this.V.add(node);
2300
+ this.X.add(node);
2286
2301
  type &= ~ERROR_BIT;
2287
- } else if (this.V.delete(node))
2302
+ } else if (this.X.delete(node))
2288
2303
  type &= ~ERROR_BIT;
2289
2304
  }
2290
2305
  }
@@ -2292,42 +2307,40 @@ var ConditionalQueue = class extends Queue {
2292
2307
  }
2293
2308
  merge(queue) {
2294
2309
  queue.s.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
2295
- queue.V.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
2310
+ queue.X.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
2296
2311
  super.merge(queue);
2297
2312
  }
2298
2313
  };
2299
2314
  var CollectionQueue = class extends Queue {
2300
- J;
2301
- d = /* @__PURE__ */ new Set();
2302
- t = new Computation(false, null, { pureWrite: true });
2315
+ K;
2316
+ e = /* @__PURE__ */ new Set();
2317
+ x = new Computation(false, null, { pureWrite: true });
2303
2318
  constructor(type) {
2304
2319
  super();
2305
- this.J = type;
2320
+ this.K = type;
2306
2321
  }
2307
2322
  run(type) {
2308
- if (!type || this.t.read())
2323
+ if (!type || this.x.read())
2309
2324
  return;
2310
2325
  return super.run(type);
2311
2326
  }
2312
2327
  notify(node, type, flags) {
2313
- if (ActiveTransition && ActiveTransition.r.has(this))
2314
- return ActiveTransition.r.get(this).notify(node, type, flags);
2315
- if (!(type & this.J))
2328
+ if (!(type & this.K))
2316
2329
  return super.notify(node, type, flags);
2317
- if (flags & this.J) {
2318
- this.d.add(node);
2319
- if (this.d.size === 1)
2320
- this.t.write(true);
2321
- } else if (this.d.size > 0) {
2322
- this.d.delete(node);
2323
- if (this.d.size === 0)
2324
- this.t.write(false);
2325
- }
2326
- type &= ~this.J;
2330
+ if (flags & this.K) {
2331
+ this.e.add(node);
2332
+ if (this.e.size === 1)
2333
+ this.x.write(true);
2334
+ } else if (this.e.size > 0) {
2335
+ this.e.delete(node);
2336
+ if (this.e.size === 0)
2337
+ this.x.write(false);
2338
+ }
2339
+ type &= ~this.K;
2327
2340
  return type ? super.notify(node, type, flags) : true;
2328
2341
  }
2329
2342
  merge(queue) {
2330
- queue.d.forEach((n) => this.notify(n, this.J, this.J));
2343
+ queue.e.forEach((n) => this.notify(n, this.K, this.K));
2331
2344
  super.merge(queue);
2332
2345
  }
2333
2346
  };
@@ -2338,25 +2351,25 @@ function createBoundary(fn, condition) {
2338
2351
  );
2339
2352
  const tree = createBoundChildren(owner, fn, queue, 0);
2340
2353
  new EagerComputation(void 0, () => {
2341
- const disabled = queue.t.read();
2342
- tree.U = disabled ? ERROR_BIT | LOADING_BIT : 0;
2354
+ const disabled = queue.x.read();
2355
+ tree.W = disabled ? ERROR_BIT | LOADING_BIT : 0;
2343
2356
  if (!disabled) {
2344
2357
  queue.s.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
2345
- queue.V.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
2358
+ queue.X.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
2346
2359
  queue.s.clear();
2347
- queue.V.clear();
2360
+ queue.X.clear();
2348
2361
  }
2349
2362
  });
2350
- return () => queue.t.read() ? void 0 : tree.read();
2363
+ return () => queue.x.read() ? void 0 : tree.read();
2351
2364
  }
2352
2365
  function createCollectionBoundary(type, fn, fallback) {
2353
2366
  const owner = new Owner();
2354
2367
  const queue = new CollectionQueue(type);
2355
2368
  const tree = createBoundChildren(owner, fn, queue, type);
2356
2369
  const decision = new Computation(void 0, () => {
2357
- if (!queue.t.read()) {
2370
+ if (!queue.x.read()) {
2358
2371
  const resolved = tree.read();
2359
- if (!untrack(() => queue.t.read()))
2372
+ if (!untrack(() => queue.x.read()))
2360
2373
  return resolved;
2361
2374
  }
2362
2375
  return fallback(queue);
@@ -2368,14 +2381,14 @@ function createSuspense(fn, fallback) {
2368
2381
  }
2369
2382
  function createErrorBoundary(fn, fallback) {
2370
2383
  return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
2371
- let node = getTransitionSource(queue.d.values().next().value);
2372
- return fallback(node.L, () => {
2384
+ let node = getTransitionSource(queue.e.values().next().value);
2385
+ return fallback(node.O, () => {
2373
2386
  incrementClock();
2374
- for (let node2 of queue.d) {
2375
- if (ActiveTransition && !node2.e)
2387
+ for (let node2 of queue.e) {
2388
+ if (ActiveTransition && !node2.d)
2376
2389
  node2 = cloneGraph(node2);
2377
- node2.c = STATE_DIRTY;
2378
- getQueue(node2).enqueue(node2.C, node2.F.bind(node2));
2390
+ node2.b = STATE_DIRTY;
2391
+ getQueue(node2).enqueue(node2.r, node2.w.bind(node2));
2379
2392
  }
2380
2393
  });
2381
2394
  });
@@ -2435,4 +2448,4 @@ function flattenArray(children, results = [], options) {
2435
2448
  return needsUnwrap;
2436
2449
  }
2437
2450
 
2438
- export { $PROXY, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, SUPPORTS_PROXY, createAsync, createBoundary, createContext, createEffect, createErrorBoundary, createMemo, createOptimistic, createProjection, createRenderEffect, createRoot, createSignal, createStore, createSuspense, deep, flatten, flush, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, repeat, resolve, runWithObserver, runWithOwner, setContext, snapshot, transition, untrack, useTransition };
2451
+ export { $PROXY, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, SUPPORTS_PROXY, createAsync, createBoundary, createContext, createEffect, createErrorBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createSuspense, createTrackedEffect, deep, flatten, flush, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, repeat, resolve, runWithOwner, setContext, snapshot, transition, untrack, useTransition };