@solidjs/signals 0.4.1 → 0.4.2

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
@@ -24,33 +24,51 @@ var EFFECT_RENDER = 1;
24
24
  var EFFECT_USER = 2;
25
25
  var SUPPORTS_PROXY = typeof Proxy === "function";
26
26
 
27
+ // src/core/flags.ts
28
+ var ERROR_OFFSET = 0;
29
+ var ERROR_BIT = 1 << ERROR_OFFSET;
30
+ var LOADING_OFFSET = 1;
31
+ var LOADING_BIT = 1 << LOADING_OFFSET;
32
+ var UNINITIALIZED_OFFSET = 2;
33
+ var UNINITIALIZED_BIT = 1 << UNINITIALIZED_OFFSET;
34
+ var DEFAULT_FLAGS = ERROR_BIT;
35
+
27
36
  // src/core/scheduler.ts
28
37
  var clock = 0;
29
- function getClock() {
30
- return clock;
31
- }
32
38
  function incrementClock() {
33
39
  clock++;
34
40
  }
41
+ var ActiveTransition = null;
42
+ var unobserved = [];
35
43
  var scheduled = false;
36
44
  function schedule() {
37
45
  if (scheduled)
38
46
  return;
39
47
  scheduled = true;
40
- if (!globalQueue.K)
48
+ if (!globalQueue.x)
41
49
  queueMicrotask(flush);
42
50
  }
51
+ function notifyUnobserved() {
52
+ for (let i = 0; i < unobserved.length; i++) {
53
+ const source = unobserved[i];
54
+ if (!source.d || !source.d.length)
55
+ unobserved[i].ca?.();
56
+ }
57
+ unobserved = [];
58
+ }
43
59
  var pureQueue = [];
44
60
  var Queue = class {
45
- o = null;
46
- K = false;
47
- L = [[], []];
48
- F = [];
61
+ p = null;
62
+ x = false;
63
+ o = [[], []];
64
+ q = [];
49
65
  created = clock;
50
66
  enqueue(type, fn) {
67
+ if (ActiveTransition)
68
+ return ActiveTransition.enqueue(type, fn);
51
69
  pureQueue.push(fn);
52
70
  if (type)
53
- this.L[type - 1].push(fn);
71
+ this.o[type - 1].push(fn);
54
72
  schedule();
55
73
  }
56
74
  run(type) {
@@ -58,19 +76,19 @@ var Queue = class {
58
76
  pureQueue.length && runQueue(pureQueue, type);
59
77
  pureQueue = [];
60
78
  return;
61
- } else if (this.L[type - 1].length) {
62
- const effects = this.L[type - 1];
63
- this.L[type - 1] = [];
79
+ } else if (this.o[type - 1].length) {
80
+ const effects = this.o[type - 1];
81
+ this.o[type - 1] = [];
64
82
  runQueue(effects, type);
65
83
  }
66
- for (let i = 0; i < this.F.length; i++) {
67
- this.F[i].run(type);
84
+ for (let i = 0; i < this.q.length; i++) {
85
+ this.q[i].run(type);
68
86
  }
69
87
  }
70
88
  flush() {
71
- if (this.K)
89
+ if (this.x)
72
90
  return;
73
- this.K = true;
91
+ this.x = true;
74
92
  try {
75
93
  this.run(EFFECT_PURE);
76
94
  incrementClock();
@@ -78,21 +96,22 @@ var Queue = class {
78
96
  this.run(EFFECT_RENDER);
79
97
  this.run(EFFECT_USER);
80
98
  } finally {
81
- this.K = false;
99
+ this.x = false;
100
+ unobserved.length && notifyUnobserved();
82
101
  }
83
102
  }
84
103
  addChild(child) {
85
- this.F.push(child);
86
- child.o = this;
104
+ this.q.push(child);
105
+ child.p = this;
87
106
  }
88
107
  removeChild(child) {
89
- const index = this.F.indexOf(child);
108
+ const index = this.q.indexOf(child);
90
109
  if (index >= 0)
91
- this.F.splice(index, 1);
110
+ this.q.splice(index, 1);
92
111
  }
93
112
  notify(...args) {
94
- if (this.o)
95
- return this.o.notify(...args);
113
+ if (this.p)
114
+ return this.p.notify(...args);
96
115
  return false;
97
116
  }
98
117
  };
@@ -106,6 +125,200 @@ function runQueue(queue, type) {
106
125
  for (let i = 0; i < queue.length; i++)
107
126
  queue[i](type);
108
127
  }
128
+ var Transition = class _Transition {
129
+ a = /* @__PURE__ */ new Map();
130
+ t = /* @__PURE__ */ new Set();
131
+ M = /* @__PURE__ */ new Set();
132
+ T = /* @__PURE__ */ new Set();
133
+ E = false;
134
+ o = [[], []];
135
+ F = [];
136
+ q = [];
137
+ p = null;
138
+ x = false;
139
+ U = false;
140
+ created = clock;
141
+ enqueue(type, fn) {
142
+ this.F.push(fn);
143
+ if (type)
144
+ this.o[type - 1].push(fn);
145
+ this.schedule();
146
+ }
147
+ run(type) {
148
+ if (type === EFFECT_PURE) {
149
+ this.F.length && runQueue(this.F, type);
150
+ this.F = [];
151
+ return;
152
+ } else if (this.o[type - 1].length) {
153
+ const effects = this.o[type - 1];
154
+ this.o[type - 1] = [];
155
+ runQueue(effects, type);
156
+ }
157
+ for (let i = 0; i < this.q.length; i++) {
158
+ this.q[i].run(type);
159
+ }
160
+ }
161
+ flush() {
162
+ if (this.x)
163
+ return;
164
+ this.x = true;
165
+ let currentTransition = ActiveTransition;
166
+ ActiveTransition = this;
167
+ try {
168
+ this.run(EFFECT_PURE);
169
+ incrementClock();
170
+ this.U = false;
171
+ ActiveTransition = currentTransition;
172
+ finishTransition(this);
173
+ } finally {
174
+ this.x = false;
175
+ ActiveTransition = currentTransition;
176
+ }
177
+ }
178
+ addChild(child) {
179
+ this.q.push(child);
180
+ child.p = this;
181
+ }
182
+ removeChild(child) {
183
+ const index = this.q.indexOf(child);
184
+ if (index >= 0)
185
+ this.q.splice(index, 1);
186
+ }
187
+ notify(node, type, flags) {
188
+ if (!(type & LOADING_BIT))
189
+ return false;
190
+ if (flags & LOADING_BIT) {
191
+ this.t.add(node);
192
+ } else {
193
+ this.t.delete(node);
194
+ }
195
+ return true;
196
+ }
197
+ schedule() {
198
+ if (this.U)
199
+ return;
200
+ this.U = true;
201
+ if (!this.x)
202
+ queueMicrotask(() => this.flush());
203
+ }
204
+ runTransition(fn, force = false) {
205
+ if (this.E) {
206
+ if (this.E instanceof _Transition)
207
+ return this.E.runTransition(fn, force);
208
+ if (!force)
209
+ throw new Error("Transition already completed");
210
+ fn();
211
+ return;
212
+ }
213
+ ActiveTransition = this;
214
+ try {
215
+ const result = fn();
216
+ const transition2 = ActiveTransition;
217
+ if (result instanceof Promise) {
218
+ transition2.M.add(result);
219
+ result.finally(() => {
220
+ transition2.M.delete(result);
221
+ finishTransition(transition2);
222
+ });
223
+ }
224
+ } finally {
225
+ const transition2 = ActiveTransition;
226
+ ActiveTransition = null;
227
+ finishTransition(transition2);
228
+ }
229
+ }
230
+ addOptimistic(fn) {
231
+ if (fn.h && fn.h !== this) {
232
+ mergeTransitions(fn.h, this);
233
+ ActiveTransition = fn.h;
234
+ return;
235
+ }
236
+ fn.h = this;
237
+ this.T.add(fn);
238
+ }
239
+ };
240
+ var Transitions = /* @__PURE__ */ new Set();
241
+ function transition(fn) {
242
+ let t = new Transition();
243
+ Transitions.add(t);
244
+ queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
245
+ }
246
+ function cloneGraph(node) {
247
+ if (node.h) {
248
+ if (node.h !== ActiveTransition) {
249
+ mergeTransitions(node.h, ActiveTransition);
250
+ ActiveTransition = node.h;
251
+ }
252
+ return node.h.a.get(node);
253
+ }
254
+ const clone = Object.create(Object.getPrototypeOf(node));
255
+ Object.assign(clone, node, { j: null, r: null, N: node });
256
+ ActiveTransition.a.set(node, clone);
257
+ node.h = ActiveTransition;
258
+ if (node.d) {
259
+ for (let i = 0, length = node.d.length; i < length; i++) {
260
+ const o = node.d[i];
261
+ node.d.push(cloneGraph(o));
262
+ }
263
+ }
264
+ return clone;
265
+ }
266
+ function removeSourceObservers(node, index) {
267
+ let source;
268
+ let swap;
269
+ for (let i = index; i < node.a.length; i++) {
270
+ source = ActiveTransition && ActiveTransition.a.get(node.a[i]) || node.a[i];
271
+ if (source.d) {
272
+ if ((swap = source.d.indexOf(node)) !== -1) {
273
+ source.d[swap] = source.d[source.d.length - 1];
274
+ source.d.pop();
275
+ }
276
+ if (!source.d.length)
277
+ unobserved.push(source);
278
+ }
279
+ }
280
+ }
281
+ function mergeTransitions(t1, t2) {
282
+ t2.a.forEach((value, key) => {
283
+ key.h = t1;
284
+ t1.a.set(key, value);
285
+ });
286
+ t2.T.forEach((c) => {
287
+ c.h = t1;
288
+ t1.T.add(c);
289
+ });
290
+ t2.M.forEach((p) => t1.M.add(p));
291
+ t2.t.forEach((n) => t1.t.add(n));
292
+ t2.o[0].forEach((f) => t1.o[0].push(f));
293
+ t2.o[1].forEach((f) => t1.o[1].push(f));
294
+ t2.F.forEach((f) => t1.F.push(f));
295
+ t2.q.forEach((c) => t1.addChild(c));
296
+ t2.E = t1;
297
+ Transitions.delete(t2);
298
+ }
299
+ function finishTransition(transition2) {
300
+ if (transition2.E || transition2.U || transition2.M.size || transition2.t.size)
301
+ return;
302
+ for (const [source, clone] of transition2.a) {
303
+ if (source === clone || source.h !== transition2)
304
+ continue;
305
+ if (clone.a)
306
+ removeSourceObservers(clone, 0);
307
+ source.dispose(false);
308
+ source.emptyDisposal();
309
+ Object.assign(source, clone);
310
+ delete source.N;
311
+ delete source.h;
312
+ }
313
+ transition2.E = true;
314
+ Transitions.delete(transition2);
315
+ transition2.run(EFFECT_RENDER);
316
+ transition2.run(EFFECT_USER);
317
+ for (const reset of transition2.T) {
318
+ delete reset.h;
319
+ reset();
320
+ }
321
+ }
109
322
 
110
323
  // src/core/owner.ts
111
324
  var currentOwner = null;
@@ -122,14 +335,14 @@ var Owner = class {
122
335
  // We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild
123
336
  // However, the children are actually added in reverse creation order
124
337
  // See comment at the top of the file for an example of the _nextSibling traversal
125
- o = null;
126
- m = null;
127
- t = null;
128
- a = STATE_CLEAN;
129
- l = null;
130
- p = defaultContext;
131
- h = globalQueue;
132
- W = 0;
338
+ p = null;
339
+ r = null;
340
+ z = null;
341
+ b = STATE_CLEAN;
342
+ j = null;
343
+ u = defaultContext;
344
+ i = globalQueue;
345
+ da = 0;
133
346
  id = null;
134
347
  constructor(id = null, skipAppend = false) {
135
348
  this.id = id;
@@ -138,64 +351,64 @@ var Owner = class {
138
351
  }
139
352
  }
140
353
  append(child) {
141
- child.o = this;
142
- child.t = this;
143
- if (this.m)
144
- this.m.t = child;
145
- child.m = this.m;
146
- this.m = child;
354
+ child.p = this;
355
+ child.z = this;
356
+ if (this.r)
357
+ this.r.z = child;
358
+ child.r = this.r;
359
+ this.r = child;
147
360
  if (this.id != null && child.id == null)
148
361
  child.id = this.getNextChildId();
149
- if (child.p !== this.p) {
150
- child.p = { ...this.p, ...child.p };
362
+ if (child.u !== this.u) {
363
+ child.u = { ...this.u, ...child.u };
151
364
  }
152
- if (this.h)
153
- child.h = this.h;
365
+ if (this.i)
366
+ child.i = this.i;
154
367
  }
155
368
  dispose(self = true) {
156
- if (this.a === STATE_DISPOSED)
369
+ if (this.b === STATE_DISPOSED)
157
370
  return;
158
- let head = self ? this.t || this.o : this, current = this.m, next = null;
159
- while (current && current.o === this) {
371
+ let head = self ? this.z || this.p : this, current = this.r, next = null;
372
+ while (current && current.p === this) {
160
373
  current.dispose(true);
161
- current.z();
162
- next = current.m;
163
- current.m = null;
374
+ current.G();
375
+ next = current.r;
376
+ current.r = null;
164
377
  current = next;
165
378
  }
166
- this.W = 0;
379
+ this.da = 0;
167
380
  if (self)
168
- this.z();
381
+ this.G();
169
382
  if (current)
170
- current.t = !self ? this : this.t;
383
+ current.z = !self ? this : this.z;
171
384
  if (head)
172
- head.m = current;
173
- }
174
- z() {
175
- if (this.t)
176
- this.t.m = null;
177
- this.o = null;
178
- this.t = null;
179
- this.p = defaultContext;
180
- this.a = STATE_DISPOSED;
385
+ head.r = current;
386
+ }
387
+ G() {
388
+ if (this.z)
389
+ this.z.r = null;
390
+ this.p = null;
391
+ this.z = null;
392
+ this.u = defaultContext;
393
+ this.b = STATE_DISPOSED;
181
394
  this.emptyDisposal();
182
395
  }
183
396
  emptyDisposal() {
184
- if (!this.l)
397
+ if (!this.j)
185
398
  return;
186
- if (Array.isArray(this.l)) {
187
- for (let i = 0; i < this.l.length; i++) {
188
- const callable = this.l[i];
399
+ if (Array.isArray(this.j)) {
400
+ for (let i = 0; i < this.j.length; i++) {
401
+ const callable = this.j[i];
189
402
  callable.call(callable);
190
403
  }
191
404
  } else {
192
- this.l.call(this.l);
405
+ this.j.call(this.j);
193
406
  }
194
- this.l = null;
407
+ this.j = null;
195
408
  }
196
409
  getNextChildId() {
197
410
  if (this.id != null)
198
- return formatId(this.id, this.W++);
411
+ return formatId(this.id, this.da++);
199
412
  throw new Error("Cannot get child id from owner without an id");
200
413
  }
201
414
  };
@@ -206,7 +419,7 @@ function getContext(context, owner = currentOwner) {
206
419
  if (!owner) {
207
420
  throw new NoOwnerError();
208
421
  }
209
- const value = hasContext(context, owner) ? owner.p[context.id] : context.defaultValue;
422
+ const value = hasContext(context, owner) ? owner.u[context.id] : context.defaultValue;
210
423
  if (isUndefined(value)) {
211
424
  throw new ContextNotFoundError();
212
425
  }
@@ -216,24 +429,24 @@ function setContext(context, value, owner = currentOwner) {
216
429
  if (!owner) {
217
430
  throw new NoOwnerError();
218
431
  }
219
- owner.p = {
220
- ...owner.p,
432
+ owner.u = {
433
+ ...owner.u,
221
434
  [context.id]: isUndefined(value) ? context.defaultValue : value
222
435
  };
223
436
  }
224
437
  function hasContext(context, owner = currentOwner) {
225
- return !isUndefined(owner?.p[context.id]);
438
+ return !isUndefined(owner?.u[context.id]);
226
439
  }
227
440
  function onCleanup(fn) {
228
441
  if (!currentOwner)
229
442
  return fn;
230
443
  const node = currentOwner;
231
- if (!node.l) {
232
- node.l = fn;
233
- } else if (Array.isArray(node.l)) {
234
- node.l.push(fn);
444
+ if (!node.j) {
445
+ node.j = fn;
446
+ } else if (Array.isArray(node.j)) {
447
+ node.j.push(fn);
235
448
  } else {
236
- node.l = [node.l, fn];
449
+ node.j = [node.j, fn];
237
450
  }
238
451
  return fn;
239
452
  }
@@ -245,22 +458,12 @@ function isUndefined(value) {
245
458
  return typeof value === "undefined";
246
459
  }
247
460
 
248
- // src/core/flags.ts
249
- var ERROR_OFFSET = 0;
250
- var ERROR_BIT = 1 << ERROR_OFFSET;
251
- var LOADING_OFFSET = 1;
252
- var LOADING_BIT = 1 << LOADING_OFFSET;
253
- var UNINITIALIZED_OFFSET = 2;
254
- var UNINITIALIZED_BIT = 1 << UNINITIALIZED_OFFSET;
255
- var DEFAULT_FLAGS = ERROR_BIT;
256
-
257
461
  // src/core/core.ts
258
462
  var currentObserver = null;
259
463
  var currentMask = DEFAULT_FLAGS;
260
464
  var newSources = null;
261
465
  var newSourcesIndex = 0;
262
466
  var newFlags = 0;
263
- var unobserved = [];
264
467
  var notStale = false;
265
468
  var updateCheck = null;
266
469
  var staleCheck = null;
@@ -269,48 +472,48 @@ function getObserver() {
269
472
  }
270
473
  var UNCHANGED = Symbol(0);
271
474
  var Computation = class extends Owner {
272
- c = null;
475
+ a = null;
273
476
  d = null;
274
477
  g;
275
- G;
276
- A;
478
+ O;
479
+ H;
277
480
  // Used in __DEV__ mode, hopefully removed in production
278
- ca;
481
+ ja;
279
482
  // Using false is an optimization as an alternative to _equals: () => false
280
483
  // which could enable more efficient DIRTY notification
281
- S = isEqual;
282
- X;
283
- _ = false;
484
+ _ = isEqual;
485
+ ca;
486
+ fa = false;
284
487
  /** Whether the computation is an error or has ancestors that are unresolved */
285
488
  f = 0;
286
489
  /** Which flags raised by sources are handled, vs. being passed through. */
287
- T = DEFAULT_FLAGS;
288
- B = -1;
289
- x = false;
490
+ $ = DEFAULT_FLAGS;
491
+ I = -1;
492
+ C = false;
493
+ h;
494
+ N;
290
495
  constructor(initialValue, compute2, options) {
291
496
  super(options?.id, compute2 === null);
292
- this.A = compute2;
293
- this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
497
+ this.H = compute2;
498
+ this.b = compute2 ? STATE_DIRTY : STATE_CLEAN;
294
499
  this.f = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
295
500
  this.g = initialValue;
296
501
  if (options?.equals !== void 0)
297
- this.S = options.equals;
502
+ this._ = options.equals;
298
503
  if (options?.pureWrite)
299
- this._ = true;
504
+ this.fa = true;
300
505
  if (options?.unobserved)
301
- this.X = options?.unobserved;
302
- }
303
- Y() {
304
- if (this.A) {
305
- if (this.f & ERROR_BIT && this.B <= getClock())
306
- update(this);
307
- else
308
- this.y();
506
+ this.ca = options?.unobserved;
507
+ if (ActiveTransition) {
508
+ this.h = ActiveTransition;
509
+ ActiveTransition.a.set(this, this);
309
510
  }
511
+ }
512
+ ea() {
310
513
  track(this);
311
514
  newFlags |= this.f & ~currentMask;
312
515
  if (this.f & ERROR_BIT) {
313
- throw this.G;
516
+ throw this.O;
314
517
  } else {
315
518
  return this.g;
316
519
  }
@@ -320,7 +523,18 @@ var Computation = class extends Owner {
320
523
  * Automatically re-executes the surrounding computation when the value changes
321
524
  */
322
525
  read() {
323
- return this.Y();
526
+ if (ActiveTransition && ActiveTransition.a.has(this)) {
527
+ const clone = ActiveTransition.a.get(this);
528
+ if (clone !== this)
529
+ return clone.read();
530
+ }
531
+ if (this.H) {
532
+ if (this.f & ERROR_BIT && this.I <= clock)
533
+ update(this);
534
+ else
535
+ this.D();
536
+ }
537
+ return this.ea();
324
538
  }
325
539
  /**
326
540
  * Return the current value of this computation
@@ -330,38 +544,48 @@ var Computation = class extends Owner {
330
544
  * before continuing
331
545
  */
332
546
  wait() {
333
- if (this.A && this.f & ERROR_BIT && this.B <= getClock()) {
334
- update(this);
335
- } else {
336
- this.y();
547
+ if (ActiveTransition && ActiveTransition.a.has(this)) {
548
+ const clone = ActiveTransition.a.get(this);
549
+ if (clone !== this)
550
+ return clone.wait();
551
+ }
552
+ if (this.H) {
553
+ if (this.f & ERROR_BIT && this.I <= clock)
554
+ update(this);
555
+ else
556
+ this.D();
337
557
  }
338
- track(this);
339
558
  if ((notStale || this.f & UNINITIALIZED_BIT) && this.f & LOADING_BIT) {
559
+ track(this);
340
560
  throw new NotReadyError();
341
561
  }
342
562
  if (staleCheck && this.f & LOADING_BIT) {
343
563
  staleCheck.g = true;
344
564
  }
345
- return this.Y();
565
+ return this.ea();
346
566
  }
347
567
  /** Update the computation with a new value. */
348
568
  write(value, flags = 0, raw = false) {
569
+ if (ActiveTransition && !this.N) {
570
+ const clone = cloneGraph(this);
571
+ return clone.write(value, flags, raw);
572
+ }
349
573
  const newValue = !raw && typeof value === "function" ? value(this.g) : value;
350
574
  const valueChanged = newValue !== UNCHANGED && (!!(this.f & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
351
- this.S === false || !this.S(this.g, newValue));
575
+ this._ === false || !this._(this.g, newValue));
352
576
  if (valueChanged) {
353
577
  this.g = newValue;
354
- this.G = void 0;
578
+ this.O = void 0;
355
579
  }
356
580
  const changedFlagsMask = this.f ^ flags, changedFlags = changedFlagsMask & flags;
357
581
  this.f = flags;
358
- this.B = getClock() + 1;
582
+ this.I = clock + 1;
359
583
  if (this.d) {
360
584
  for (let i = 0; i < this.d.length; i++) {
361
585
  if (valueChanged) {
362
- this.d[i].r(STATE_DIRTY);
586
+ this.d[i].k(STATE_DIRTY);
363
587
  } else if (changedFlagsMask) {
364
- this.d[i].Z(changedFlagsMask, changedFlags);
588
+ this.d[i].V(changedFlagsMask, changedFlags);
365
589
  }
366
590
  }
367
591
  }
@@ -370,14 +594,19 @@ var Computation = class extends Owner {
370
594
  /**
371
595
  * Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
372
596
  */
373
- r(state, skipQueue) {
374
- if (this.a >= state && !this.x)
597
+ k(state, skipQueue) {
598
+ if (ActiveTransition && ActiveTransition.a.has(this)) {
599
+ const clone = ActiveTransition.a.get(this);
600
+ if (clone !== this)
601
+ return clone.k(state, skipQueue);
602
+ }
603
+ if (this.b >= state && !this.C)
375
604
  return;
376
- this.x = !!skipQueue;
377
- this.a = state;
605
+ this.C = !!skipQueue;
606
+ this.b = state;
378
607
  if (this.d) {
379
608
  for (let i = 0; i < this.d.length; i++) {
380
- this.d[i].r(STATE_CHECK, skipQueue);
609
+ this.d[i].k(STATE_CHECK, skipQueue);
381
610
  }
382
611
  }
383
612
  }
@@ -387,30 +616,30 @@ var Computation = class extends Owner {
387
616
  * @param mask A bitmask for which flag(s) were changed.
388
617
  * @param newFlags The source's new flags, masked to just the changed ones.
389
618
  */
390
- Z(mask, newFlags2) {
391
- if (this.a >= STATE_DIRTY)
619
+ V(mask, newFlags2) {
620
+ if (this.b >= STATE_DIRTY)
392
621
  return;
393
- if (mask & this.T) {
394
- this.r(STATE_DIRTY);
622
+ if (mask & this.$) {
623
+ this.k(STATE_DIRTY);
395
624
  return;
396
625
  }
397
- if (this.a >= STATE_CHECK)
626
+ if (this.b >= STATE_CHECK)
398
627
  return;
399
628
  const prevFlags = this.f & mask;
400
629
  const deltaFlags = prevFlags ^ newFlags2;
401
630
  if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
402
- this.r(STATE_CHECK);
631
+ this.k(STATE_CHECK);
403
632
  } else {
404
633
  this.f ^= deltaFlags;
405
634
  if (this.d) {
406
635
  for (let i = 0; i < this.d.length; i++) {
407
- this.d[i].Z(mask, newFlags2);
636
+ this.d[i].V(mask, newFlags2);
408
637
  }
409
638
  }
410
639
  }
411
640
  }
412
- M(error) {
413
- this.G = error;
641
+ P(error) {
642
+ this.O = error;
414
643
  this.write(UNCHANGED, this.f & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
415
644
  }
416
645
  /**
@@ -420,47 +649,50 @@ var Computation = class extends Owner {
420
649
  *
421
650
  * This function will ensure that the value and states we read from the computation are up to date
422
651
  */
423
- y() {
424
- if (!this.A) {
652
+ D() {
653
+ if (!this.H) {
425
654
  return;
426
655
  }
427
- if (this.a === STATE_DISPOSED) {
656
+ if (this.b === STATE_DISPOSED) {
428
657
  return;
429
658
  }
430
- if (this.a === STATE_CLEAN) {
659
+ if (this.b === STATE_CLEAN) {
431
660
  return;
432
661
  }
433
662
  let observerFlags = 0;
434
- if (this.a === STATE_CHECK) {
435
- for (let i = 0; i < this.c.length; i++) {
436
- this.c[i].y();
437
- observerFlags |= this.c[i].f;
438
- if (this.a === STATE_DIRTY) {
663
+ if (this.b === STATE_CHECK) {
664
+ for (let i = 0; i < this.a.length; i++) {
665
+ const source = ActiveTransition && ActiveTransition.a.get(this.a[i]) || this.a[i];
666
+ source.D();
667
+ observerFlags |= source.f;
668
+ if (this.b === STATE_DIRTY) {
439
669
  break;
440
670
  }
441
671
  }
442
672
  }
443
- if (this.a === STATE_DIRTY) {
673
+ if (this.b === STATE_DIRTY) {
444
674
  update(this);
445
675
  } else {
446
676
  this.write(UNCHANGED, observerFlags);
447
- this.a = STATE_CLEAN;
677
+ this.b = STATE_CLEAN;
448
678
  }
449
679
  }
450
680
  /**
451
681
  * Remove ourselves from the owner graph and the computation graph
452
682
  */
453
- z() {
454
- if (this.a === STATE_DISPOSED)
683
+ G() {
684
+ if (this.b === STATE_DISPOSED)
455
685
  return;
456
- if (this.c)
686
+ if (this.a)
457
687
  removeSourceObservers(this, 0);
458
- super.z();
688
+ super.G();
459
689
  }
460
690
  };
461
691
  function track(computation) {
692
+ if (ActiveTransition && computation.N)
693
+ computation = computation.N;
462
694
  if (currentObserver) {
463
- if (!newSources && currentObserver.c && currentObserver.c[newSourcesIndex] === computation) {
695
+ if (!newSources && currentObserver.a && currentObserver.a[newSourcesIndex] === computation) {
464
696
  newSourcesIndex++;
465
697
  } else if (!newSources)
466
698
  newSources = [computation];
@@ -468,7 +700,7 @@ function track(computation) {
468
700
  newSources.push(computation);
469
701
  }
470
702
  if (updateCheck) {
471
- updateCheck.g = computation.B > currentObserver.B;
703
+ updateCheck.g = computation.I > currentObserver.I;
472
704
  }
473
705
  }
474
706
  }
@@ -480,68 +712,45 @@ function update(node) {
480
712
  try {
481
713
  node.dispose(false);
482
714
  node.emptyDisposal();
483
- const result = compute(node, node.A, node);
715
+ const result = compute(node, node.H, node);
484
716
  node.write(result, newFlags, true);
485
717
  } catch (error) {
486
718
  if (error instanceof NotReadyError) {
487
719
  node.write(UNCHANGED, newFlags | LOADING_BIT | node.f & UNINITIALIZED_BIT);
488
720
  } else {
489
- node.M(error);
721
+ node.P(error);
490
722
  }
491
723
  } finally {
492
724
  if (newSources) {
493
- if (node.c)
725
+ if (node.a)
494
726
  removeSourceObservers(node, newSourcesIndex);
495
- if (node.c && newSourcesIndex > 0) {
496
- node.c.length = newSourcesIndex + newSources.length;
727
+ if (node.a && newSourcesIndex > 0) {
728
+ node.a.length = newSourcesIndex + newSources.length;
497
729
  for (let i = 0; i < newSources.length; i++) {
498
- node.c[newSourcesIndex + i] = newSources[i];
730
+ node.a[newSourcesIndex + i] = newSources[i];
499
731
  }
500
732
  } else {
501
- node.c = newSources;
733
+ node.a = newSources;
502
734
  }
503
735
  let source;
504
- for (let i = newSourcesIndex; i < node.c.length; i++) {
505
- source = node.c[i];
736
+ for (let i = newSourcesIndex; i < node.a.length; i++) {
737
+ source = node.a[i];
506
738
  if (!source.d)
507
739
  source.d = [node];
508
740
  else
509
741
  source.d.push(node);
510
742
  }
511
- } else if (node.c && newSourcesIndex < node.c.length) {
743
+ } else if (node.a && newSourcesIndex < node.a.length) {
512
744
  removeSourceObservers(node, newSourcesIndex);
513
- node.c.length = newSourcesIndex;
745
+ node.a.length = newSourcesIndex;
514
746
  }
515
- unobserved.length && notifyUnobserved();
516
747
  newSources = prevSources;
517
748
  newSourcesIndex = prevSourcesIndex;
518
749
  newFlags = prevFlags;
519
- node.B = getClock() + 1;
520
- node.a = STATE_CLEAN;
750
+ node.I = clock + 1;
751
+ node.b = STATE_CLEAN;
521
752
  }
522
753
  }
523
- function removeSourceObservers(node, index) {
524
- let source;
525
- let swap;
526
- for (let i = index; i < node.c.length; i++) {
527
- source = node.c[i];
528
- if (source.d) {
529
- swap = source.d.indexOf(node);
530
- source.d[swap] = source.d[source.d.length - 1];
531
- source.d.pop();
532
- if (!source.d.length)
533
- unobserved.push(source);
534
- }
535
- }
536
- }
537
- function notifyUnobserved() {
538
- for (let i = 0; i < unobserved.length; i++) {
539
- const source = unobserved[i];
540
- if (!source.d || !source.d.length)
541
- unobserved[i].X?.();
542
- }
543
- unobserved = [];
544
- }
545
754
  function isEqual(a, b) {
546
755
  return a === b;
547
756
  }
@@ -580,7 +789,7 @@ function isPending(fn, loadingValue) {
580
789
  if (!currentObserver)
581
790
  return pendingCheck(fn, loadingValue);
582
791
  const c = new Computation(void 0, () => pendingCheck(fn, loadingValue));
583
- c.T |= LOADING_BIT;
792
+ c.$ |= LOADING_BIT;
584
793
  return c.read();
585
794
  }
586
795
  function latest(fn, fallback) {
@@ -602,7 +811,7 @@ function latest(fn, fallback) {
602
811
  function runWithObserver(observer, run) {
603
812
  const prevSources = newSources, prevSourcesIndex = newSourcesIndex, prevFlags = newFlags;
604
813
  newSources = null;
605
- newSourcesIndex = observer.c ? observer.c.length : 0;
814
+ newSourcesIndex = observer.a ? observer.a.length : 0;
606
815
  newFlags = 0;
607
816
  try {
608
817
  return compute(observer, run, observer);
@@ -613,21 +822,21 @@ function runWithObserver(observer, run) {
613
822
  newFlags | LOADING_BIT | observer.f & UNINITIALIZED_BIT
614
823
  );
615
824
  } else {
616
- observer.M(error);
825
+ observer.P(error);
617
826
  }
618
827
  } finally {
619
828
  if (newSources) {
620
829
  if (newSourcesIndex > 0) {
621
- observer.c.length = newSourcesIndex + newSources.length;
830
+ observer.a.length = newSourcesIndex + newSources.length;
622
831
  for (let i = 0; i < newSources.length; i++) {
623
- observer.c[newSourcesIndex + i] = newSources[i];
832
+ observer.a[newSourcesIndex + i] = newSources[i];
624
833
  }
625
834
  } else {
626
- observer.c = newSources;
835
+ observer.a = newSources;
627
836
  }
628
837
  let source;
629
- for (let i = newSourcesIndex; i < observer.c.length; i++) {
630
- source = observer.c[i];
838
+ for (let i = newSourcesIndex; i < observer.a.length; i++) {
839
+ source = observer.a[i];
631
840
  if (!source.d)
632
841
  source.d = [observer];
633
842
  else
@@ -642,7 +851,7 @@ function runWithObserver(observer, run) {
642
851
  function compute(owner, fn, observer) {
643
852
  const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
644
853
  currentObserver = observer;
645
- currentMask = observer?.T ?? DEFAULT_FLAGS;
854
+ currentMask = observer?.$ ?? DEFAULT_FLAGS;
646
855
  notStale = true;
647
856
  try {
648
857
  return fn(observer ? observer.g : void 0);
@@ -656,104 +865,120 @@ function compute(owner, fn, observer) {
656
865
 
657
866
  // src/core/effect.ts
658
867
  var Effect = class extends Computation {
659
- U;
660
- N;
661
- C;
662
- V = false;
663
- O;
664
- s;
868
+ aa;
869
+ W;
870
+ J;
871
+ ba = false;
872
+ X;
873
+ y;
665
874
  constructor(initialValue, compute2, effect, error, options) {
666
875
  super(initialValue, compute2, options);
667
- this.U = effect;
668
- this.N = error;
669
- this.O = initialValue;
670
- this.s = options?.render ? EFFECT_RENDER : EFFECT_USER;
671
- if (this.s === EFFECT_RENDER) {
672
- this.A = (p) => getClock() > this.h.created && !(this.f & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
876
+ this.aa = effect;
877
+ this.W = error;
878
+ this.X = initialValue;
879
+ this.y = options?.render ? EFFECT_RENDER : EFFECT_USER;
880
+ if (this.y === EFFECT_RENDER) {
881
+ this.H = (p) => !ActiveTransition && clock > this.i.created && !(this.f & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
673
882
  }
674
- this.y();
675
- !options?.defer && (this.s === EFFECT_USER ? this.h.enqueue(this.s, this.u.bind(this)) : this.u(this.s));
883
+ this.D();
884
+ !options?.defer && (this.y === EFFECT_USER ? (ActiveTransition || this.i).enqueue(this.y, this.A.bind(this)) : this.A(this.y));
676
885
  }
677
886
  write(value, flags = 0) {
678
- if (this.a == STATE_DIRTY) {
679
- this.f;
887
+ if (this.b == STATE_DIRTY || flags !== this.f) {
680
888
  this.f = flags;
681
- if (this.s === EFFECT_RENDER) {
682
- this.h.notify(this, LOADING_BIT | ERROR_BIT, flags);
889
+ if (this.y === EFFECT_RENDER) {
890
+ (ActiveTransition || this.i).notify(this, LOADING_BIT | ERROR_BIT, flags);
683
891
  }
684
892
  }
685
893
  if (value === UNCHANGED)
686
894
  return this.g;
687
895
  this.g = value;
688
- this.V = true;
896
+ this.ba = true;
689
897
  return value;
690
898
  }
691
- r(state, skipQueue) {
692
- if (this.a >= state || skipQueue)
899
+ k(state, skipQueue) {
900
+ if (ActiveTransition && ActiveTransition.a.has(this)) {
901
+ return ActiveTransition.a.get(this).k(state, skipQueue);
902
+ }
903
+ if (this.b >= state || skipQueue)
693
904
  return;
694
- if (this.a === STATE_CLEAN)
695
- this.h.enqueue(this.s, this.u.bind(this));
696
- this.a = state;
905
+ if (this.b === STATE_CLEAN)
906
+ (ActiveTransition || this.i).enqueue(this.y, this.A.bind(this));
907
+ this.b = state;
908
+ }
909
+ V(mask, newFlags2) {
910
+ if (ActiveTransition && ActiveTransition.a.has(this)) {
911
+ if (this.b >= STATE_CHECK)
912
+ return;
913
+ if (mask & 3) {
914
+ this.k(STATE_DIRTY);
915
+ return;
916
+ }
917
+ }
918
+ super.V(mask, newFlags2);
697
919
  }
698
- M(error) {
699
- this.G = error;
700
- this.h.notify(this, LOADING_BIT, 0);
920
+ P(error) {
921
+ this.O = error;
922
+ (ActiveTransition || this.i).notify(this, LOADING_BIT, 0);
701
923
  this.f = ERROR_BIT;
702
- if (this.s === EFFECT_USER) {
924
+ if (this.y === EFFECT_USER) {
703
925
  try {
704
- return this.N ? this.N(error, () => {
705
- this.C?.();
706
- this.C = void 0;
926
+ return this.W ? this.W(error, () => {
927
+ this.J?.();
928
+ this.J = void 0;
707
929
  }) : console.error(error);
708
930
  } catch (e) {
709
931
  error = e;
710
932
  }
711
933
  }
712
- if (!this.h.notify(this, ERROR_BIT, ERROR_BIT))
934
+ if (!(ActiveTransition || this.i).notify(this, ERROR_BIT, ERROR_BIT))
713
935
  throw error;
714
936
  }
715
- z() {
716
- if (this.a === STATE_DISPOSED)
937
+ G() {
938
+ if (this.b === STATE_DISPOSED)
717
939
  return;
718
- this.U = void 0;
719
- this.O = void 0;
720
- this.N = void 0;
721
- this.C?.();
722
- this.C = void 0;
723
- super.z();
724
- }
725
- u(type) {
940
+ this.aa = void 0;
941
+ this.X = void 0;
942
+ this.W = void 0;
943
+ this.J?.();
944
+ this.J = void 0;
945
+ super.G();
946
+ }
947
+ A(type) {
726
948
  if (type) {
727
- if (this.V && this.a !== STATE_DISPOSED) {
728
- this.C?.();
949
+ if (this.ba && this.b !== STATE_DISPOSED) {
950
+ this.J?.();
729
951
  try {
730
- this.C = this.U(this.g, this.O);
952
+ this.J = this.aa(this.g, this.X);
731
953
  } catch (e) {
732
- if (!this.h.notify(this, ERROR_BIT, ERROR_BIT))
954
+ if (!(ActiveTransition || this.i).notify(this, ERROR_BIT, ERROR_BIT))
733
955
  throw e;
734
956
  } finally {
735
- this.O = this.g;
736
- this.V = false;
957
+ this.X = this.g;
958
+ this.ba = false;
737
959
  }
738
960
  }
739
961
  } else
740
- this.a !== STATE_CLEAN && runTop(this);
962
+ this.b !== STATE_CLEAN && runTop(this);
741
963
  }
742
964
  };
743
965
  var EagerComputation = class extends Computation {
744
966
  constructor(initialValue, compute2, options) {
745
967
  super(initialValue, compute2, options);
746
- !options?.defer && this.y();
968
+ !options?.defer && this.D();
747
969
  }
748
- r(state, skipQueue) {
749
- if (this.a >= state && !this.x)
970
+ k(state, skipQueue) {
971
+ if (ActiveTransition && ActiveTransition.a.has(this)) {
972
+ return ActiveTransition.a.get(this).k(state, skipQueue);
973
+ }
974
+ if (this.b >= state && !this.C)
750
975
  return;
751
- if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.x))
752
- this.h.enqueue(EFFECT_PURE, this.u.bind(this));
753
- super.r(state, skipQueue);
976
+ if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.C))
977
+ (ActiveTransition || this.i).enqueue(EFFECT_PURE, this.A.bind(this));
978
+ super.k(state, skipQueue);
754
979
  }
755
- u() {
756
- this.a !== STATE_CLEAN && runTop(this);
980
+ A() {
981
+ this.b !== STATE_CLEAN && runTop(this);
757
982
  }
758
983
  };
759
984
  var FirewallComputation = class extends Computation {
@@ -761,193 +986,34 @@ var FirewallComputation = class extends Computation {
761
986
  constructor(compute2) {
762
987
  super(void 0, compute2);
763
988
  }
764
- r(state, skipQueue) {
765
- if (this.a >= state && !this.x)
989
+ k(state, skipQueue) {
990
+ if (ActiveTransition && ActiveTransition.a.has(this)) {
991
+ return ActiveTransition.a.get(this).k(state, skipQueue);
992
+ }
993
+ if (this.b >= state && !this.C)
766
994
  return;
767
- if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.x))
768
- this.h.enqueue(EFFECT_PURE, this.u.bind(this));
769
- super.r(state, true);
770
- this.x = !!skipQueue;
995
+ if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.C))
996
+ (ActiveTransition || this.i).enqueue(EFFECT_PURE, this.A.bind(this));
997
+ super.k(state, true);
998
+ this.C = !!skipQueue;
771
999
  }
772
- u() {
773
- this.a !== STATE_CLEAN && runTop(this);
1000
+ A() {
1001
+ this.b !== STATE_CLEAN && runTop(this);
774
1002
  }
775
1003
  };
776
1004
  function runTop(node) {
777
1005
  const ancestors = [];
778
- for (let current = node; current !== null; current = current.o) {
779
- if (current.a !== STATE_CLEAN) {
1006
+ for (let current = node; current !== null; current = current.p) {
1007
+ if (current.b !== STATE_CLEAN) {
780
1008
  ancestors.push(current);
781
1009
  }
782
1010
  }
783
1011
  for (let i = ancestors.length - 1; i >= 0; i--) {
784
- if (ancestors[i].a !== STATE_DISPOSED)
785
- ancestors[i].y();
1012
+ if (ancestors[i].b !== STATE_DISPOSED)
1013
+ ancestors[i].D();
786
1014
  }
787
1015
  }
788
1016
 
789
- // src/signals.ts
790
- function createSignal(first, second, third) {
791
- if (typeof first === "function") {
792
- const memo = createMemo((p) => {
793
- const node2 = new Computation(
794
- first(p ? untrack(p[0]) : second),
795
- null,
796
- third
797
- );
798
- return [node2.read.bind(node2), node2.write.bind(node2)];
799
- });
800
- return [() => memo()[0](), (value) => memo()[1](value)];
801
- }
802
- const o = getOwner();
803
- const needsId = o?.id != null;
804
- const node = new Computation(
805
- first,
806
- null,
807
- needsId ? { id: o.getNextChildId(), ...second } : second
808
- );
809
- return [node.read.bind(node), node.write.bind(node)];
810
- }
811
- function createMemo(compute2, value, options) {
812
- let node = new Computation(
813
- value,
814
- compute2,
815
- options
816
- );
817
- let resolvedValue;
818
- return () => {
819
- if (node) {
820
- if (node.a === STATE_DISPOSED) {
821
- node = void 0;
822
- return resolvedValue;
823
- }
824
- resolvedValue = node.wait();
825
- if (!node.c?.length && node.m?.o !== node) {
826
- node.dispose();
827
- node = void 0;
828
- }
829
- }
830
- return resolvedValue;
831
- };
832
- }
833
- function createAsync(compute2, value, options) {
834
- let refreshing = false;
835
- const node = new EagerComputation(
836
- value,
837
- (p) => {
838
- const source = compute2(p, refreshing);
839
- refreshing = false;
840
- const isPromise = source instanceof Promise;
841
- const iterator = source[Symbol.asyncIterator];
842
- if (!isPromise && !iterator) {
843
- return source;
844
- }
845
- let abort = false;
846
- onCleanup(() => abort = true);
847
- if (isPromise) {
848
- source.then(
849
- (value3) => {
850
- if (abort)
851
- return;
852
- node.write(value3, 0, true);
853
- },
854
- (error) => {
855
- if (abort)
856
- return;
857
- node.M(error);
858
- }
859
- );
860
- } else {
861
- (async () => {
862
- try {
863
- for await (let value3 of source) {
864
- if (abort)
865
- return;
866
- node.write(value3, 0, true);
867
- }
868
- } catch (error) {
869
- if (abort)
870
- return;
871
- node.write(error, ERROR_BIT);
872
- }
873
- })();
874
- }
875
- throw new NotReadyError();
876
- },
877
- options
878
- );
879
- const read = node.wait.bind(node);
880
- read.refresh = () => {
881
- node.a = STATE_DIRTY;
882
- refreshing = true;
883
- node.y();
884
- };
885
- return read;
886
- }
887
- function createEffect(compute2, effect, value, options) {
888
- void new Effect(
889
- value,
890
- compute2,
891
- effect.effect ? effect.effect : effect,
892
- effect.error,
893
- options
894
- );
895
- }
896
- function createRenderEffect(compute2, effect, value, options) {
897
- void new Effect(value, compute2, effect, void 0, {
898
- render: true,
899
- ...options
900
- });
901
- }
902
- function createRoot(init, options) {
903
- const owner = new Owner(options?.id);
904
- return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
905
- }
906
- function runWithOwner(owner, run) {
907
- return compute(owner, run, null);
908
- }
909
- function resolve(fn) {
910
- return new Promise((res, rej) => {
911
- createRoot((dispose) => {
912
- new EagerComputation(void 0, () => {
913
- try {
914
- res(fn());
915
- } catch (err) {
916
- if (err instanceof NotReadyError)
917
- throw err;
918
- rej(err);
919
- }
920
- dispose();
921
- });
922
- });
923
- });
924
- }
925
- function tryCatch(fn) {
926
- try {
927
- const v = fn();
928
- if (v instanceof Promise) {
929
- return v.then(
930
- (v2) => [void 0, v2],
931
- (e) => {
932
- if (e instanceof NotReadyError)
933
- throw e;
934
- return [e];
935
- }
936
- );
937
- }
938
- return [void 0, v];
939
- } catch (e) {
940
- if (e instanceof NotReadyError)
941
- throw e;
942
- return [e];
943
- }
944
- }
945
- function transition(fn) {
946
- }
947
- function createOptimistic(initial, compute2, options) {
948
- return [];
949
- }
950
-
951
1017
  // src/store/projection.ts
952
1018
  function createProjection(fn, initialValue = {}) {
953
1019
  let wrappedStore;
@@ -1577,198 +1643,405 @@ function omit(props, ...keys) {
1577
1643
  return result;
1578
1644
  }
1579
1645
 
1646
+ // src/signals.ts
1647
+ function createSignal(first, second, third) {
1648
+ if (typeof first === "function") {
1649
+ const memo = createMemo((p) => {
1650
+ const node2 = new Computation(
1651
+ first(p ? untrack(p[0]) : second),
1652
+ null,
1653
+ third
1654
+ );
1655
+ return [node2.read.bind(node2), node2.write.bind(node2)];
1656
+ });
1657
+ return [() => memo()[0](), (value) => memo()[1](value)];
1658
+ }
1659
+ const o = getOwner();
1660
+ const needsId = o?.id != null;
1661
+ const node = new Computation(
1662
+ first,
1663
+ null,
1664
+ needsId ? { id: o.getNextChildId(), ...second } : second
1665
+ );
1666
+ return [node.read.bind(node), node.write.bind(node)];
1667
+ }
1668
+ function createMemo(compute2, value, options) {
1669
+ let node = new Computation(
1670
+ value,
1671
+ compute2,
1672
+ options
1673
+ );
1674
+ let resolvedValue;
1675
+ return () => {
1676
+ if (node) {
1677
+ if (node.b === STATE_DISPOSED) {
1678
+ node = void 0;
1679
+ return resolvedValue;
1680
+ }
1681
+ resolvedValue = node.wait();
1682
+ if (!node.a?.length && node.r?.p !== node) {
1683
+ node.dispose();
1684
+ node = void 0;
1685
+ }
1686
+ }
1687
+ return resolvedValue;
1688
+ };
1689
+ }
1690
+ function createAsync(compute2, value, options) {
1691
+ let refreshing = false;
1692
+ const node = new EagerComputation(
1693
+ value,
1694
+ (p) => {
1695
+ const source = compute2(p, refreshing);
1696
+ refreshing = false;
1697
+ const isPromise = source instanceof Promise;
1698
+ const iterator = source[Symbol.asyncIterator];
1699
+ if (!isPromise && !iterator) {
1700
+ return source;
1701
+ }
1702
+ let abort = false;
1703
+ onCleanup(() => abort = true);
1704
+ const transition2 = ActiveTransition;
1705
+ if (isPromise) {
1706
+ source.then(
1707
+ (value3) => {
1708
+ if (abort)
1709
+ return;
1710
+ if (transition2)
1711
+ return transition2.runTransition(() => node.write(value3, 0, true), true);
1712
+ node.write(value3, 0, true);
1713
+ },
1714
+ (error) => {
1715
+ if (abort)
1716
+ return;
1717
+ if (transition2)
1718
+ return transition2.runTransition(() => node.P(error), true);
1719
+ node.P(error);
1720
+ }
1721
+ );
1722
+ } else {
1723
+ (async () => {
1724
+ try {
1725
+ for await (let value3 of source) {
1726
+ if (abort)
1727
+ return;
1728
+ node.write(value3, 0, true);
1729
+ }
1730
+ } catch (error) {
1731
+ if (abort)
1732
+ return;
1733
+ node.write(error, ERROR_BIT);
1734
+ }
1735
+ })();
1736
+ }
1737
+ throw new NotReadyError();
1738
+ },
1739
+ options
1740
+ );
1741
+ const read = node.wait.bind(node);
1742
+ read.refresh = () => {
1743
+ node.b = STATE_DIRTY;
1744
+ refreshing = true;
1745
+ node.D();
1746
+ };
1747
+ return read;
1748
+ }
1749
+ function createEffect(compute2, effect, value, options) {
1750
+ void new Effect(
1751
+ value,
1752
+ compute2,
1753
+ effect.effect ? effect.effect : effect,
1754
+ effect.error,
1755
+ options
1756
+ );
1757
+ }
1758
+ function createRenderEffect(compute2, effect, value, options) {
1759
+ void new Effect(value, compute2, effect, void 0, {
1760
+ render: true,
1761
+ ...options
1762
+ });
1763
+ }
1764
+ function createRoot(init, options) {
1765
+ const owner = new Owner(options?.id);
1766
+ return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
1767
+ }
1768
+ function runWithOwner(owner, run) {
1769
+ return compute(owner, run, null);
1770
+ }
1771
+ function resolve(fn) {
1772
+ return new Promise((res, rej) => {
1773
+ createRoot((dispose) => {
1774
+ new EagerComputation(void 0, () => {
1775
+ try {
1776
+ res(fn());
1777
+ } catch (err) {
1778
+ if (err instanceof NotReadyError)
1779
+ throw err;
1780
+ rej(err);
1781
+ }
1782
+ dispose();
1783
+ });
1784
+ });
1785
+ });
1786
+ }
1787
+ function tryCatch(fn) {
1788
+ try {
1789
+ const v = fn();
1790
+ if (v instanceof Promise) {
1791
+ return v.then(
1792
+ (v2) => [void 0, v2],
1793
+ (e) => {
1794
+ if (e instanceof NotReadyError)
1795
+ throw e;
1796
+ return [e];
1797
+ }
1798
+ );
1799
+ }
1800
+ return [void 0, v];
1801
+ } catch (e) {
1802
+ if (e instanceof NotReadyError)
1803
+ throw e;
1804
+ return [e];
1805
+ }
1806
+ }
1807
+ function createOptimistic(initial, compute2, key) {
1808
+ if (!compute2) {
1809
+ let write2 = function(v) {
1810
+ if (!ActiveTransition)
1811
+ throw new Error("createOptimistic can only be updated inside a transition");
1812
+ ActiveTransition.addOptimistic(reset2);
1813
+ queueMicrotask(() => node.write(v));
1814
+ };
1815
+ var write = write2;
1816
+ const node = new Computation(initial, null);
1817
+ const reset2 = () => node.write(initial);
1818
+ return [node.read.bind(node), write2];
1819
+ }
1820
+ let store, setStore;
1821
+ if (typeof initial === "function") {
1822
+ [store, setStore] = createStore(
1823
+ (s) => {
1824
+ const value = initial();
1825
+ if (!ActiveTransition)
1826
+ s.value = value;
1827
+ },
1828
+ { value: void 0 }
1829
+ );
1830
+ } else
1831
+ [store, setStore] = createStore({ value: initial });
1832
+ const reset = () => setStore(
1833
+ (s) => reconcile(
1834
+ typeof initial === "function" ? initial() : initial,
1835
+ key
1836
+ )(s.value)
1837
+ );
1838
+ let lastChange = void 0;
1839
+ function write(v) {
1840
+ if (!ActiveTransition)
1841
+ throw new Error("createOptimistic can only be updated inside a transition");
1842
+ ActiveTransition.addOptimistic(reset);
1843
+ queueMicrotask(
1844
+ () => setStore((s) => {
1845
+ lastChange = typeof v === "function" ? v(lastChange) : v;
1846
+ compute2(s.value, lastChange);
1847
+ })
1848
+ );
1849
+ }
1850
+ return [() => store.value, write];
1851
+ }
1852
+
1580
1853
  // src/map.ts
1581
1854
  function mapArray(list, map, options) {
1582
1855
  const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
1583
1856
  return updateKeyedMap.bind({
1584
- H: new Owner(),
1585
- i: 0,
1586
- $: list,
1587
- w: [],
1588
- D: map,
1857
+ Q: new Owner(),
1858
+ l: 0,
1859
+ ga: list,
1860
+ B: [],
1861
+ K: map,
1589
1862
  e: [],
1590
- b: [],
1591
- E: keyFn,
1592
- j: keyFn || options?.keyed === false ? [] : void 0,
1593
- k: map.length > 1 ? [] : void 0,
1594
- I: options?.fallback
1863
+ c: [],
1864
+ L: keyFn,
1865
+ m: keyFn || options?.keyed === false ? [] : void 0,
1866
+ n: map.length > 1 ? [] : void 0,
1867
+ R: options?.fallback
1595
1868
  });
1596
1869
  }
1597
1870
  var pureOptions = { pureWrite: true };
1598
1871
  function updateKeyedMap() {
1599
- const newItems = this.$() || [], newLen = newItems.length;
1872
+ const newItems = this.ga() || [], newLen = newItems.length;
1600
1873
  newItems[$TRACK];
1601
- runWithOwner(this.H, () => {
1602
- let i, j, mapper = this.j ? () => {
1603
- this.j[j] = new Computation(newItems[j], null, pureOptions);
1604
- this.k && (this.k[j] = new Computation(j, null, pureOptions));
1605
- return this.D(
1606
- Computation.prototype.read.bind(this.j[j]),
1607
- this.k ? Computation.prototype.read.bind(this.k[j]) : void 0
1874
+ runWithOwner(this.Q, () => {
1875
+ let i, j, mapper = this.m ? () => {
1876
+ this.m[j] = new Computation(newItems[j], null, pureOptions);
1877
+ this.n && (this.n[j] = new Computation(j, null, pureOptions));
1878
+ return this.K(
1879
+ Computation.prototype.read.bind(this.m[j]),
1880
+ this.n ? Computation.prototype.read.bind(this.n[j]) : void 0
1608
1881
  );
1609
- } : this.k ? () => {
1882
+ } : this.n ? () => {
1610
1883
  const item = newItems[j];
1611
- this.k[j] = new Computation(j, null, pureOptions);
1612
- return this.D(() => item, Computation.prototype.read.bind(this.k[j]));
1884
+ this.n[j] = new Computation(j, null, pureOptions);
1885
+ return this.K(() => item, Computation.prototype.read.bind(this.n[j]));
1613
1886
  } : () => {
1614
1887
  const item = newItems[j];
1615
- return this.D(() => item);
1888
+ return this.K(() => item);
1616
1889
  };
1617
1890
  if (newLen === 0) {
1618
- if (this.i !== 0) {
1619
- this.H.dispose(false);
1620
- this.b = [];
1621
- this.w = [];
1891
+ if (this.l !== 0) {
1892
+ this.Q.dispose(false);
1893
+ this.c = [];
1894
+ this.B = [];
1622
1895
  this.e = [];
1623
- this.i = 0;
1624
- this.j && (this.j = []);
1625
- this.k && (this.k = []);
1896
+ this.l = 0;
1897
+ this.m && (this.m = []);
1898
+ this.n && (this.n = []);
1626
1899
  }
1627
- if (this.I && !this.e[0]) {
1900
+ if (this.R && !this.e[0]) {
1628
1901
  this.e[0] = compute(
1629
- this.b[0] = new Owner(),
1630
- this.I,
1902
+ this.c[0] = new Owner(),
1903
+ this.R,
1631
1904
  null
1632
1905
  );
1633
1906
  }
1634
- } else if (this.i === 0) {
1635
- if (this.b[0])
1636
- this.b[0].dispose();
1907
+ } else if (this.l === 0) {
1908
+ if (this.c[0])
1909
+ this.c[0].dispose();
1637
1910
  this.e = new Array(newLen);
1638
1911
  for (j = 0; j < newLen; j++) {
1639
- this.w[j] = newItems[j];
1640
- this.e[j] = compute(this.b[j] = new Owner(), mapper, null);
1912
+ this.B[j] = newItems[j];
1913
+ this.e[j] = compute(this.c[j] = new Owner(), mapper, null);
1641
1914
  }
1642
- this.i = newLen;
1915
+ this.l = newLen;
1643
1916
  } else {
1644
- 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;
1645
- for (start = 0, end = Math.min(this.i, newLen); start < end && (this.w[start] === newItems[start] || this.j && compare(this.E, this.w[start], newItems[start])); start++) {
1646
- if (this.j)
1647
- this.j[start].write(newItems[start]);
1917
+ let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.m ? new Array(newLen) : void 0, tempIndexes = this.n ? new Array(newLen) : void 0;
1918
+ for (start = 0, end = Math.min(this.l, newLen); start < end && (this.B[start] === newItems[start] || this.m && compare(this.L, this.B[start], newItems[start])); start++) {
1919
+ if (this.m)
1920
+ this.m[start].write(newItems[start]);
1648
1921
  }
1649
- for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.w[end] === newItems[newEnd] || this.j && compare(this.E, this.w[end], newItems[newEnd])); end--, newEnd--) {
1922
+ for (end = this.l - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.B[end] === newItems[newEnd] || this.m && compare(this.L, this.B[end], newItems[newEnd])); end--, newEnd--) {
1650
1923
  temp[newEnd] = this.e[end];
1651
- tempNodes[newEnd] = this.b[end];
1652
- tempRows && (tempRows[newEnd] = this.j[end]);
1653
- tempIndexes && (tempIndexes[newEnd] = this.k[end]);
1924
+ tempNodes[newEnd] = this.c[end];
1925
+ tempRows && (tempRows[newEnd] = this.m[end]);
1926
+ tempIndexes && (tempIndexes[newEnd] = this.n[end]);
1654
1927
  }
1655
1928
  newIndices = /* @__PURE__ */ new Map();
1656
1929
  newIndicesNext = new Array(newEnd + 1);
1657
1930
  for (j = newEnd; j >= start; j--) {
1658
1931
  item = newItems[j];
1659
- key = this.E ? this.E(item) : item;
1932
+ key = this.L ? this.L(item) : item;
1660
1933
  i = newIndices.get(key);
1661
1934
  newIndicesNext[j] = i === void 0 ? -1 : i;
1662
1935
  newIndices.set(key, j);
1663
1936
  }
1664
1937
  for (i = start; i <= end; i++) {
1665
- item = this.w[i];
1666
- key = this.E ? this.E(item) : item;
1938
+ item = this.B[i];
1939
+ key = this.L ? this.L(item) : item;
1667
1940
  j = newIndices.get(key);
1668
1941
  if (j !== void 0 && j !== -1) {
1669
1942
  temp[j] = this.e[i];
1670
- tempNodes[j] = this.b[i];
1671
- tempRows && (tempRows[j] = this.j[i]);
1672
- tempIndexes && (tempIndexes[j] = this.k[i]);
1943
+ tempNodes[j] = this.c[i];
1944
+ tempRows && (tempRows[j] = this.m[i]);
1945
+ tempIndexes && (tempIndexes[j] = this.n[i]);
1673
1946
  j = newIndicesNext[j];
1674
1947
  newIndices.set(key, j);
1675
1948
  } else
1676
- this.b[i].dispose();
1949
+ this.c[i].dispose();
1677
1950
  }
1678
1951
  for (j = start; j < newLen; j++) {
1679
1952
  if (j in temp) {
1680
1953
  this.e[j] = temp[j];
1681
- this.b[j] = tempNodes[j];
1954
+ this.c[j] = tempNodes[j];
1682
1955
  if (tempRows) {
1683
- this.j[j] = tempRows[j];
1684
- this.j[j].write(newItems[j]);
1956
+ this.m[j] = tempRows[j];
1957
+ this.m[j].write(newItems[j]);
1685
1958
  }
1686
1959
  if (tempIndexes) {
1687
- this.k[j] = tempIndexes[j];
1688
- this.k[j].write(j);
1960
+ this.n[j] = tempIndexes[j];
1961
+ this.n[j].write(j);
1689
1962
  }
1690
1963
  } else {
1691
- this.e[j] = compute(this.b[j] = new Owner(), mapper, null);
1964
+ this.e[j] = compute(this.c[j] = new Owner(), mapper, null);
1692
1965
  }
1693
1966
  }
1694
- this.e = this.e.slice(0, this.i = newLen);
1695
- this.w = newItems.slice(0);
1967
+ this.e = this.e.slice(0, this.l = newLen);
1968
+ this.B = newItems.slice(0);
1696
1969
  }
1697
1970
  });
1698
1971
  return this.e;
1699
1972
  }
1700
1973
  function repeat(count, map, options) {
1701
1974
  return updateRepeat.bind({
1702
- H: new Owner(),
1703
- i: 0,
1704
- q: 0,
1705
- aa: count,
1706
- D: map,
1707
- b: [],
1975
+ Q: new Owner(),
1976
+ l: 0,
1977
+ w: 0,
1978
+ ha: count,
1979
+ K: map,
1980
+ c: [],
1708
1981
  e: [],
1709
- ba: options?.from,
1710
- I: options?.fallback
1982
+ ia: options?.from,
1983
+ R: options?.fallback
1711
1984
  });
1712
1985
  }
1713
1986
  function updateRepeat() {
1714
- const newLen = this.aa();
1715
- const from = this.ba?.() || 0;
1716
- runWithOwner(this.H, () => {
1987
+ const newLen = this.ha();
1988
+ const from = this.ia?.() || 0;
1989
+ runWithOwner(this.Q, () => {
1717
1990
  if (newLen === 0) {
1718
- if (this.i !== 0) {
1719
- this.H.dispose(false);
1720
- this.b = [];
1991
+ if (this.l !== 0) {
1992
+ this.Q.dispose(false);
1993
+ this.c = [];
1721
1994
  this.e = [];
1722
- this.i = 0;
1995
+ this.l = 0;
1723
1996
  }
1724
- if (this.I && !this.e[0]) {
1997
+ if (this.R && !this.e[0]) {
1725
1998
  this.e[0] = compute(
1726
- this.b[0] = new Owner(),
1727
- this.I,
1999
+ this.c[0] = new Owner(),
2000
+ this.R,
1728
2001
  null
1729
2002
  );
1730
2003
  }
1731
2004
  return;
1732
2005
  }
1733
2006
  const to = from + newLen;
1734
- const prevTo = this.q + this.i;
1735
- if (this.i === 0 && this.b[0])
1736
- this.b[0].dispose();
2007
+ const prevTo = this.w + this.l;
2008
+ if (this.l === 0 && this.c[0])
2009
+ this.c[0].dispose();
1737
2010
  for (let i = to; i < prevTo; i++)
1738
- this.b[i - this.q].dispose();
1739
- if (this.q < from) {
1740
- let i = this.q;
1741
- while (i < from && i < this.i)
1742
- this.b[i++].dispose();
1743
- this.b.splice(0, from - this.q);
1744
- this.e.splice(0, from - this.q);
1745
- } else if (this.q > from) {
1746
- let i = prevTo - this.q - 1;
1747
- let difference = this.q - from;
1748
- this.b.length = this.e.length = newLen;
2011
+ this.c[i - this.w].dispose();
2012
+ if (this.w < from) {
2013
+ let i = this.w;
2014
+ while (i < from && i < this.l)
2015
+ this.c[i++].dispose();
2016
+ this.c.splice(0, from - this.w);
2017
+ this.e.splice(0, from - this.w);
2018
+ } else if (this.w > from) {
2019
+ let i = prevTo - this.w - 1;
2020
+ let difference = this.w - from;
2021
+ this.c.length = this.e.length = newLen;
1749
2022
  while (i >= difference) {
1750
- this.b[i] = this.b[i - difference];
2023
+ this.c[i] = this.c[i - difference];
1751
2024
  this.e[i] = this.e[i - difference];
1752
2025
  i--;
1753
2026
  }
1754
2027
  for (let i2 = 0; i2 < difference; i2++) {
1755
2028
  this.e[i2] = compute(
1756
- this.b[i2] = new Owner(),
1757
- () => this.D(i2 + from),
2029
+ this.c[i2] = new Owner(),
2030
+ () => this.K(i2 + from),
1758
2031
  null
1759
2032
  );
1760
2033
  }
1761
2034
  }
1762
2035
  for (let i = prevTo; i < to; i++) {
1763
2036
  this.e[i - from] = compute(
1764
- this.b[i - from] = new Owner(),
1765
- () => this.D(i),
2037
+ this.c[i - from] = new Owner(),
2038
+ () => this.K(i),
1766
2039
  null
1767
2040
  );
1768
2041
  }
1769
2042
  this.e = this.e.slice(0, newLen);
1770
- this.q = from;
1771
- this.i = newLen;
2043
+ this.w = from;
2044
+ this.l = newLen;
1772
2045
  });
1773
2046
  return this.e;
1774
2047
  }
@@ -1778,24 +2051,24 @@ function compare(key, a, b) {
1778
2051
 
1779
2052
  // src/boundaries.ts
1780
2053
  var BoundaryComputation = class extends EagerComputation {
1781
- J;
2054
+ S;
1782
2055
  constructor(compute2, propagationMask) {
1783
2056
  super(void 0, compute2, { defer: true });
1784
- this.J = propagationMask;
2057
+ this.S = propagationMask;
1785
2058
  }
1786
2059
  write(value, flags) {
1787
- super.write(value, flags & ~this.J);
1788
- if (this.J & LOADING_BIT && !(this.f & UNINITIALIZED_BIT)) {
2060
+ super.write(value, flags & ~this.S);
2061
+ if (this.S & LOADING_BIT && !(this.f & UNINITIALIZED_BIT)) {
1789
2062
  flags &= ~LOADING_BIT;
1790
2063
  }
1791
- this.h.notify(this, this.J, flags);
2064
+ this.i.notify(this, this.S, flags);
1792
2065
  return this.g;
1793
2066
  }
1794
2067
  };
1795
2068
  function createBoundChildren(owner, fn, queue, mask) {
1796
- const parentQueue = owner.h;
1797
- parentQueue.addChild(owner.h = queue);
1798
- onCleanup(() => parentQueue.removeChild(owner.h));
2069
+ const parentQueue = owner.i;
2070
+ parentQueue.addChild(owner.i = queue);
2071
+ onCleanup(() => parentQueue.removeChild(owner.i));
1799
2072
  return compute(
1800
2073
  owner,
1801
2074
  () => {
@@ -1806,32 +2079,32 @@ function createBoundChildren(owner, fn, queue, mask) {
1806
2079
  );
1807
2080
  }
1808
2081
  var ConditionalQueue = class extends Queue {
1809
- n;
1810
- P = /* @__PURE__ */ new Set();
1811
- Q = /* @__PURE__ */ new Set();
2082
+ s;
2083
+ Y = /* @__PURE__ */ new Set();
2084
+ t = /* @__PURE__ */ new Set();
1812
2085
  constructor(disabled) {
1813
2086
  super();
1814
- this.n = disabled;
2087
+ this.s = disabled;
1815
2088
  }
1816
2089
  run(type) {
1817
- if (!type || this.n.read())
2090
+ if (!type || this.s.read())
1818
2091
  return;
1819
2092
  return super.run(type);
1820
2093
  }
1821
2094
  notify(node, type, flags) {
1822
- if (this.n.read()) {
2095
+ if (this.s.read()) {
1823
2096
  if (type & LOADING_BIT) {
1824
2097
  if (flags & LOADING_BIT) {
1825
- this.Q.add(node);
2098
+ this.t.add(node);
1826
2099
  type &= ~LOADING_BIT;
1827
- } else if (this.Q.delete(node))
2100
+ } else if (this.t.delete(node))
1828
2101
  type &= ~LOADING_BIT;
1829
2102
  }
1830
2103
  if (type & ERROR_BIT) {
1831
2104
  if (flags & ERROR_BIT) {
1832
- this.P.add(node);
2105
+ this.Y.add(node);
1833
2106
  type &= ~ERROR_BIT;
1834
- } else if (this.P.delete(node))
2107
+ } else if (this.Y.delete(node))
1835
2108
  type &= ~ERROR_BIT;
1836
2109
  }
1837
2110
  }
@@ -1839,31 +2112,31 @@ var ConditionalQueue = class extends Queue {
1839
2112
  }
1840
2113
  };
1841
2114
  var CollectionQueue = class extends Queue {
1842
- R;
1843
- b = /* @__PURE__ */ new Set();
1844
- n = new Computation(false, null, { pureWrite: true });
2115
+ Z;
2116
+ c = /* @__PURE__ */ new Set();
2117
+ s = new Computation(false, null, { pureWrite: true });
1845
2118
  constructor(type) {
1846
2119
  super();
1847
- this.R = type;
2120
+ this.Z = type;
1848
2121
  }
1849
2122
  run(type) {
1850
- if (!type || this.n.read())
2123
+ if (!type || this.s.read())
1851
2124
  return;
1852
2125
  return super.run(type);
1853
2126
  }
1854
2127
  notify(node, type, flags) {
1855
- if (!(type & this.R))
2128
+ if (!(type & this.Z))
1856
2129
  return super.notify(node, type, flags);
1857
- if (flags & this.R) {
1858
- this.b.add(node);
1859
- if (this.b.size === 1)
1860
- this.n.write(true);
2130
+ if (flags & this.Z) {
2131
+ this.c.add(node);
2132
+ if (this.c.size === 1)
2133
+ this.s.write(true);
1861
2134
  } else {
1862
- this.b.delete(node);
1863
- if (this.b.size === 0)
1864
- this.n.write(false);
2135
+ this.c.delete(node);
2136
+ if (this.c.size === 0)
2137
+ this.s.write(false);
1865
2138
  }
1866
- type &= ~this.R;
2139
+ type &= ~this.Z;
1867
2140
  return type ? super.notify(node, type, flags) : true;
1868
2141
  }
1869
2142
  };
@@ -1874,25 +2147,25 @@ function createBoundary(fn, condition) {
1874
2147
  );
1875
2148
  const tree = createBoundChildren(owner, fn, queue, 0);
1876
2149
  new EagerComputation(void 0, () => {
1877
- const disabled = queue.n.read();
1878
- tree.J = disabled ? ERROR_BIT | LOADING_BIT : 0;
2150
+ const disabled = queue.s.read();
2151
+ tree.S = disabled ? ERROR_BIT | LOADING_BIT : 0;
1879
2152
  if (!disabled) {
1880
- queue.Q.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
1881
- queue.P.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
1882
- queue.Q.clear();
1883
- queue.P.clear();
2153
+ queue.t.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
2154
+ queue.Y.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
2155
+ queue.t.clear();
2156
+ queue.Y.clear();
1884
2157
  }
1885
2158
  });
1886
- return () => queue.n.read() ? void 0 : tree.read();
2159
+ return () => queue.s.read() ? void 0 : tree.read();
1887
2160
  }
1888
2161
  function createCollectionBoundary(type, fn, fallback) {
1889
2162
  const owner = new Owner();
1890
2163
  const queue = new CollectionQueue(type);
1891
2164
  const tree = createBoundChildren(owner, fn, queue, type);
1892
2165
  const decision = new Computation(void 0, () => {
1893
- if (!queue.n.read()) {
2166
+ if (!queue.s.read()) {
1894
2167
  const resolved = tree.read();
1895
- if (!queue.n.read())
2168
+ if (!queue.s.read())
1896
2169
  return resolved;
1897
2170
  }
1898
2171
  return fallback(queue);
@@ -1906,11 +2179,11 @@ function createErrorBoundary(fn, fallback) {
1906
2179
  return createCollectionBoundary(
1907
2180
  ERROR_BIT,
1908
2181
  fn,
1909
- (queue) => fallback(queue.b.values().next().value.G, () => {
2182
+ (queue) => fallback(queue.c.values().next().value.O, () => {
1910
2183
  incrementClock();
1911
- for (let node of queue.b) {
1912
- node.a = STATE_DIRTY;
1913
- node.h?.enqueue(node.s, node.u.bind(node));
2184
+ for (let node of queue.c) {
2185
+ node.b = STATE_DIRTY;
2186
+ node.i?.enqueue(node.y, node.A.bind(node));
1914
2187
  }
1915
2188
  })
1916
2189
  );