@solidjs/signals 0.4.0 → 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.J)
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
- J = false;
47
- K = [[], []];
48
- E = [];
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.K[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.K[type - 1].length) {
62
- const effects = this.K[type - 1];
63
- this.K[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.E.length; i++) {
67
- this.E[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.J)
89
+ if (this.x)
72
90
  return;
73
- this.J = 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.J = false;
99
+ this.x = false;
100
+ unobserved.length && notifyUnobserved();
82
101
  }
83
102
  }
84
103
  addChild(child) {
85
- this.E.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.E.indexOf(child);
108
+ const index = this.q.indexOf(child);
90
109
  if (index >= 0)
91
- this.E.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.y();
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.y();
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
- y() {
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
- F;
276
- z;
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
- R = 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
- S = DEFAULT_FLAGS;
288
- A = -1;
289
- w = 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.z = 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.R = 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.z) {
305
- if (this.f & ERROR_BIT && this.A <= getClock())
306
- update(this);
307
- else
308
- this.x();
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.F;
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.z && this.f & ERROR_BIT && this.A <= getClock()) {
334
- update(this);
335
- } else {
336
- this.x();
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.R === false || !this.R(this.g, newValue));
575
+ this._ === false || !this._(this.g, newValue));
352
576
  if (valueChanged) {
353
577
  this.g = newValue;
354
- this.F = 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.A = 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.w)
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.w = !!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.S) {
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
- L(error) {
413
- this.F = 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
- x() {
424
- if (!this.z) {
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].x();
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
- y() {
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.y();
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.A > currentObserver.A;
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.z, 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.L(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.A = getClock() + 1;
520
- node.a = STATE_CLEAN;
521
- }
522
- }
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
- }
750
+ node.I = clock + 1;
751
+ node.b = STATE_CLEAN;
535
752
  }
536
753
  }
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.S |= 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.L(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?.S ?? 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
- T;
660
- M;
661
- B;
662
- U = false;
663
- N;
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.T = effect;
668
- this.M = error;
669
- this.N = initialValue;
670
- this.s = options?.render ? EFFECT_RENDER : EFFECT_USER;
671
- if (this.s === EFFECT_RENDER) {
672
- this.z = (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.x();
675
- !options?.defer && (this.s === EFFECT_USER ? this.h.enqueue(this.s, this.V.bind(this)) : this.V(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.U = 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.V.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
- L(error) {
699
- this.F = 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.M ? this.M(error, () => {
705
- this.B?.();
706
- this.B = 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
- y() {
716
- if (this.a === STATE_DISPOSED)
937
+ G() {
938
+ if (this.b === STATE_DISPOSED)
717
939
  return;
718
- this.T = void 0;
719
- this.N = void 0;
720
- this.M = void 0;
721
- this.B?.();
722
- this.B = void 0;
723
- super.y();
724
- }
725
- V(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.U && this.a !== STATE_DISPOSED) {
728
- this.B?.();
949
+ if (this.ba && this.b !== STATE_DISPOSED) {
950
+ this.J?.();
729
951
  try {
730
- this.B = this.T(this.g, this.N);
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.N = this.g;
736
- this.U = 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
- function runComputation() {
744
- this.a !== STATE_CLEAN && runTop(this);
745
- }
746
965
  var EagerComputation = class extends Computation {
747
966
  constructor(initialValue, compute2, options) {
748
967
  super(initialValue, compute2, options);
749
- !options?.defer && this.x();
968
+ !options?.defer && this.D();
750
969
  }
751
- r(state, skipQueue) {
752
- if (this.a >= state && !this.w)
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)
753
975
  return;
754
- if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.w))
755
- this.h.enqueue(EFFECT_PURE, runComputation.bind(this));
756
- 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);
979
+ }
980
+ A() {
981
+ this.b !== STATE_CLEAN && runTop(this);
757
982
  }
758
983
  };
759
984
  var FirewallComputation = class extends Computation {
@@ -761,190 +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.w)
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.w))
768
- this.h.enqueue(EFFECT_PURE, runComputation.bind(this));
769
- super.r(state, true);
770
- this.w = !!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;
999
+ }
1000
+ A() {
1001
+ this.b !== STATE_CLEAN && runTop(this);
771
1002
  }
772
1003
  };
773
1004
  function runTop(node) {
774
1005
  const ancestors = [];
775
- for (let current = node; current !== null; current = current.o) {
776
- if (current.a !== STATE_CLEAN) {
1006
+ for (let current = node; current !== null; current = current.p) {
1007
+ if (current.b !== STATE_CLEAN) {
777
1008
  ancestors.push(current);
778
1009
  }
779
1010
  }
780
1011
  for (let i = ancestors.length - 1; i >= 0; i--) {
781
- if (ancestors[i].a !== STATE_DISPOSED)
782
- ancestors[i].x();
1012
+ if (ancestors[i].b !== STATE_DISPOSED)
1013
+ ancestors[i].D();
783
1014
  }
784
1015
  }
785
1016
 
786
- // src/signals.ts
787
- function createSignal(first, second, third) {
788
- if (typeof first === "function") {
789
- const memo = createMemo((p) => {
790
- const node2 = new Computation(
791
- first(p ? untrack(p[0]) : second),
792
- null,
793
- third
794
- );
795
- return [node2.read.bind(node2), node2.write.bind(node2)];
796
- });
797
- return [() => memo()[0](), (value) => memo()[1](value)];
798
- }
799
- const o = getOwner();
800
- const needsId = o?.id != null;
801
- const node = new Computation(
802
- first,
803
- null,
804
- needsId ? { id: o.getNextChildId(), ...second } : second
805
- );
806
- return [node.read.bind(node), node.write.bind(node)];
807
- }
808
- function createMemo(compute2, value, options) {
809
- let node = new Computation(
810
- value,
811
- compute2,
812
- options
813
- );
814
- let resolvedValue;
815
- return () => {
816
- if (node) {
817
- if (node.a === STATE_DISPOSED) {
818
- node = void 0;
819
- return resolvedValue;
820
- }
821
- resolvedValue = node.wait();
822
- if (!node.c?.length && node.m?.o !== node) {
823
- node.dispose();
824
- node = void 0;
825
- }
826
- }
827
- return resolvedValue;
828
- };
829
- }
830
- function createAsync(compute2, value, options) {
831
- let refreshing = false;
832
- const node = new EagerComputation(
833
- value,
834
- (p) => {
835
- const source = compute2(p, refreshing);
836
- refreshing = false;
837
- const isPromise = source instanceof Promise;
838
- const iterator = source[Symbol.asyncIterator];
839
- if (!isPromise && !iterator) {
840
- return source;
841
- }
842
- let abort = false;
843
- onCleanup(() => abort = true);
844
- if (isPromise) {
845
- source.then(
846
- (value3) => {
847
- if (abort)
848
- return;
849
- node.write(value3, 0, true);
850
- },
851
- (error) => {
852
- if (abort)
853
- return;
854
- node.L(error);
855
- }
856
- );
857
- } else {
858
- (async () => {
859
- try {
860
- for await (let value3 of source) {
861
- if (abort)
862
- return;
863
- node.write(value3, 0, true);
864
- }
865
- } catch (error) {
866
- if (abort)
867
- return;
868
- node.write(error, ERROR_BIT);
869
- }
870
- })();
871
- }
872
- throw new NotReadyError();
873
- },
874
- options
875
- );
876
- const read = node.wait.bind(node);
877
- read.refresh = () => {
878
- node.a = STATE_DIRTY;
879
- refreshing = true;
880
- node.x();
881
- };
882
- return read;
883
- }
884
- function createEffect(compute2, effect, value, options) {
885
- void new Effect(
886
- value,
887
- compute2,
888
- effect.effect ? effect.effect : effect,
889
- effect.error,
890
- options
891
- );
892
- }
893
- function createRenderEffect(compute2, effect, value, options) {
894
- void new Effect(value, compute2, effect, void 0, {
895
- render: true,
896
- ...options
897
- });
898
- }
899
- function createRoot(init, options) {
900
- const owner = new Owner(options?.id);
901
- return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
902
- }
903
- function runWithOwner(owner, run) {
904
- return compute(owner, run, null);
905
- }
906
- function resolve(fn) {
907
- return new Promise((res, rej) => {
908
- createRoot((dispose) => {
909
- new EagerComputation(void 0, () => {
910
- try {
911
- res(fn());
912
- } catch (err) {
913
- if (err instanceof NotReadyError)
914
- throw err;
915
- rej(err);
916
- }
917
- dispose();
918
- });
919
- });
920
- });
921
- }
922
- function tryCatch(fn) {
923
- try {
924
- const v = fn();
925
- if (v instanceof Promise) {
926
- return v.then(
927
- (v2) => [void 0, v2],
928
- (e) => {
929
- if (e instanceof NotReadyError)
930
- throw e;
931
- return [e];
932
- }
933
- );
934
- }
935
- return [void 0, v];
936
- } catch (e) {
937
- if (e instanceof NotReadyError)
938
- throw e;
939
- return [e];
940
- }
941
- }
942
- function transition(fn) {
943
- }
944
- function createOptimistic(initial, compute2, options) {
945
- return [];
946
- }
947
-
948
1017
  // src/store/projection.ts
949
1018
  function createProjection(fn, initialValue = {}) {
950
1019
  let wrappedStore;
@@ -1574,198 +1643,405 @@ function omit(props, ...keys) {
1574
1643
  return result;
1575
1644
  }
1576
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
+
1577
1853
  // src/map.ts
1578
1854
  function mapArray(list, map, options) {
1579
1855
  const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
1580
1856
  return updateKeyedMap.bind({
1581
- G: new Owner(),
1582
- i: 0,
1583
- $: list,
1584
- u: [],
1585
- C: map,
1857
+ Q: new Owner(),
1858
+ l: 0,
1859
+ ga: list,
1860
+ B: [],
1861
+ K: map,
1586
1862
  e: [],
1587
- b: [],
1588
- D: keyFn,
1589
- j: keyFn || options?.keyed === false ? [] : void 0,
1590
- k: map.length > 1 ? [] : void 0,
1591
- H: 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
1592
1868
  });
1593
1869
  }
1594
1870
  var pureOptions = { pureWrite: true };
1595
1871
  function updateKeyedMap() {
1596
- const newItems = this.$() || [], newLen = newItems.length;
1872
+ const newItems = this.ga() || [], newLen = newItems.length;
1597
1873
  newItems[$TRACK];
1598
- runWithOwner(this.G, () => {
1599
- let i, j, mapper = this.j ? () => {
1600
- this.j[j] = new Computation(newItems[j], null, pureOptions);
1601
- this.k && (this.k[j] = new Computation(j, null, pureOptions));
1602
- return this.C(
1603
- Computation.prototype.read.bind(this.j[j]),
1604
- 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
1605
1881
  );
1606
- } : this.k ? () => {
1882
+ } : this.n ? () => {
1607
1883
  const item = newItems[j];
1608
- this.k[j] = new Computation(j, null, pureOptions);
1609
- return this.C(() => 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]));
1610
1886
  } : () => {
1611
1887
  const item = newItems[j];
1612
- return this.C(() => item);
1888
+ return this.K(() => item);
1613
1889
  };
1614
1890
  if (newLen === 0) {
1615
- if (this.i !== 0) {
1616
- this.G.dispose(false);
1617
- this.b = [];
1618
- this.u = [];
1891
+ if (this.l !== 0) {
1892
+ this.Q.dispose(false);
1893
+ this.c = [];
1894
+ this.B = [];
1619
1895
  this.e = [];
1620
- this.i = 0;
1621
- this.j && (this.j = []);
1622
- this.k && (this.k = []);
1896
+ this.l = 0;
1897
+ this.m && (this.m = []);
1898
+ this.n && (this.n = []);
1623
1899
  }
1624
- if (this.H && !this.e[0]) {
1900
+ if (this.R && !this.e[0]) {
1625
1901
  this.e[0] = compute(
1626
- this.b[0] = new Owner(),
1627
- this.H,
1902
+ this.c[0] = new Owner(),
1903
+ this.R,
1628
1904
  null
1629
1905
  );
1630
1906
  }
1631
- } else if (this.i === 0) {
1632
- if (this.b[0])
1633
- this.b[0].dispose();
1907
+ } else if (this.l === 0) {
1908
+ if (this.c[0])
1909
+ this.c[0].dispose();
1634
1910
  this.e = new Array(newLen);
1635
1911
  for (j = 0; j < newLen; j++) {
1636
- this.u[j] = newItems[j];
1637
- 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);
1638
1914
  }
1639
- this.i = newLen;
1915
+ this.l = newLen;
1640
1916
  } else {
1641
- 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;
1642
- for (start = 0, end = Math.min(this.i, newLen); start < end && (this.u[start] === newItems[start] || this.j && compare(this.D, this.u[start], newItems[start])); start++) {
1643
- if (this.j)
1644
- 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]);
1645
1921
  }
1646
- for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.u[end] === newItems[newEnd] || this.j && compare(this.D, this.u[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--) {
1647
1923
  temp[newEnd] = this.e[end];
1648
- tempNodes[newEnd] = this.b[end];
1649
- tempRows && (tempRows[newEnd] = this.j[end]);
1650
- 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]);
1651
1927
  }
1652
1928
  newIndices = /* @__PURE__ */ new Map();
1653
1929
  newIndicesNext = new Array(newEnd + 1);
1654
1930
  for (j = newEnd; j >= start; j--) {
1655
1931
  item = newItems[j];
1656
- key = this.D ? this.D(item) : item;
1932
+ key = this.L ? this.L(item) : item;
1657
1933
  i = newIndices.get(key);
1658
1934
  newIndicesNext[j] = i === void 0 ? -1 : i;
1659
1935
  newIndices.set(key, j);
1660
1936
  }
1661
1937
  for (i = start; i <= end; i++) {
1662
- item = this.u[i];
1663
- key = this.D ? this.D(item) : item;
1938
+ item = this.B[i];
1939
+ key = this.L ? this.L(item) : item;
1664
1940
  j = newIndices.get(key);
1665
1941
  if (j !== void 0 && j !== -1) {
1666
1942
  temp[j] = this.e[i];
1667
- tempNodes[j] = this.b[i];
1668
- tempRows && (tempRows[j] = this.j[i]);
1669
- 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]);
1670
1946
  j = newIndicesNext[j];
1671
1947
  newIndices.set(key, j);
1672
1948
  } else
1673
- this.b[i].dispose();
1949
+ this.c[i].dispose();
1674
1950
  }
1675
1951
  for (j = start; j < newLen; j++) {
1676
1952
  if (j in temp) {
1677
1953
  this.e[j] = temp[j];
1678
- this.b[j] = tempNodes[j];
1954
+ this.c[j] = tempNodes[j];
1679
1955
  if (tempRows) {
1680
- this.j[j] = tempRows[j];
1681
- this.j[j].write(newItems[j]);
1956
+ this.m[j] = tempRows[j];
1957
+ this.m[j].write(newItems[j]);
1682
1958
  }
1683
1959
  if (tempIndexes) {
1684
- this.k[j] = tempIndexes[j];
1685
- this.k[j].write(j);
1960
+ this.n[j] = tempIndexes[j];
1961
+ this.n[j].write(j);
1686
1962
  }
1687
1963
  } else {
1688
- this.e[j] = compute(this.b[j] = new Owner(), mapper, null);
1964
+ this.e[j] = compute(this.c[j] = new Owner(), mapper, null);
1689
1965
  }
1690
1966
  }
1691
- this.e = this.e.slice(0, this.i = newLen);
1692
- this.u = newItems.slice(0);
1967
+ this.e = this.e.slice(0, this.l = newLen);
1968
+ this.B = newItems.slice(0);
1693
1969
  }
1694
1970
  });
1695
1971
  return this.e;
1696
1972
  }
1697
1973
  function repeat(count, map, options) {
1698
1974
  return updateRepeat.bind({
1699
- G: new Owner(),
1700
- i: 0,
1701
- q: 0,
1702
- aa: count,
1703
- C: map,
1704
- b: [],
1975
+ Q: new Owner(),
1976
+ l: 0,
1977
+ w: 0,
1978
+ ha: count,
1979
+ K: map,
1980
+ c: [],
1705
1981
  e: [],
1706
- ba: options?.from,
1707
- H: options?.fallback
1982
+ ia: options?.from,
1983
+ R: options?.fallback
1708
1984
  });
1709
1985
  }
1710
1986
  function updateRepeat() {
1711
- const newLen = this.aa();
1712
- const from = this.ba?.() || 0;
1713
- runWithOwner(this.G, () => {
1987
+ const newLen = this.ha();
1988
+ const from = this.ia?.() || 0;
1989
+ runWithOwner(this.Q, () => {
1714
1990
  if (newLen === 0) {
1715
- if (this.i !== 0) {
1716
- this.G.dispose(false);
1717
- this.b = [];
1991
+ if (this.l !== 0) {
1992
+ this.Q.dispose(false);
1993
+ this.c = [];
1718
1994
  this.e = [];
1719
- this.i = 0;
1995
+ this.l = 0;
1720
1996
  }
1721
- if (this.H && !this.e[0]) {
1997
+ if (this.R && !this.e[0]) {
1722
1998
  this.e[0] = compute(
1723
- this.b[0] = new Owner(),
1724
- this.H,
1999
+ this.c[0] = new Owner(),
2000
+ this.R,
1725
2001
  null
1726
2002
  );
1727
2003
  }
1728
2004
  return;
1729
2005
  }
1730
2006
  const to = from + newLen;
1731
- const prevTo = this.q + this.i;
1732
- if (this.i === 0 && this.b[0])
1733
- this.b[0].dispose();
2007
+ const prevTo = this.w + this.l;
2008
+ if (this.l === 0 && this.c[0])
2009
+ this.c[0].dispose();
1734
2010
  for (let i = to; i < prevTo; i++)
1735
- this.b[i - this.q].dispose();
1736
- if (this.q < from) {
1737
- let i = this.q;
1738
- while (i < from && i < this.i)
1739
- this.b[i++].dispose();
1740
- this.b.splice(0, from - this.q);
1741
- this.e.splice(0, from - this.q);
1742
- } else if (this.q > from) {
1743
- let i = prevTo - this.q - 1;
1744
- let difference = this.q - from;
1745
- 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;
1746
2022
  while (i >= difference) {
1747
- this.b[i] = this.b[i - difference];
2023
+ this.c[i] = this.c[i - difference];
1748
2024
  this.e[i] = this.e[i - difference];
1749
2025
  i--;
1750
2026
  }
1751
2027
  for (let i2 = 0; i2 < difference; i2++) {
1752
2028
  this.e[i2] = compute(
1753
- this.b[i2] = new Owner(),
1754
- () => this.C(i2 + from),
2029
+ this.c[i2] = new Owner(),
2030
+ () => this.K(i2 + from),
1755
2031
  null
1756
2032
  );
1757
2033
  }
1758
2034
  }
1759
2035
  for (let i = prevTo; i < to; i++) {
1760
2036
  this.e[i - from] = compute(
1761
- this.b[i - from] = new Owner(),
1762
- () => this.C(i),
2037
+ this.c[i - from] = new Owner(),
2038
+ () => this.K(i),
1763
2039
  null
1764
2040
  );
1765
2041
  }
1766
2042
  this.e = this.e.slice(0, newLen);
1767
- this.q = from;
1768
- this.i = newLen;
2043
+ this.w = from;
2044
+ this.l = newLen;
1769
2045
  });
1770
2046
  return this.e;
1771
2047
  }
@@ -1775,24 +2051,24 @@ function compare(key, a, b) {
1775
2051
 
1776
2052
  // src/boundaries.ts
1777
2053
  var BoundaryComputation = class extends EagerComputation {
1778
- I;
2054
+ S;
1779
2055
  constructor(compute2, propagationMask) {
1780
2056
  super(void 0, compute2, { defer: true });
1781
- this.I = propagationMask;
2057
+ this.S = propagationMask;
1782
2058
  }
1783
2059
  write(value, flags) {
1784
- super.write(value, flags & ~this.I);
1785
- if (this.I & LOADING_BIT && !(this.f & UNINITIALIZED_BIT)) {
2060
+ super.write(value, flags & ~this.S);
2061
+ if (this.S & LOADING_BIT && !(this.f & UNINITIALIZED_BIT)) {
1786
2062
  flags &= ~LOADING_BIT;
1787
2063
  }
1788
- this.h.notify(this, this.I, flags);
2064
+ this.i.notify(this, this.S, flags);
1789
2065
  return this.g;
1790
2066
  }
1791
2067
  };
1792
2068
  function createBoundChildren(owner, fn, queue, mask) {
1793
- const parentQueue = owner.h;
1794
- parentQueue.addChild(owner.h = queue);
1795
- onCleanup(() => parentQueue.removeChild(owner.h));
2069
+ const parentQueue = owner.i;
2070
+ parentQueue.addChild(owner.i = queue);
2071
+ onCleanup(() => parentQueue.removeChild(owner.i));
1796
2072
  return compute(
1797
2073
  owner,
1798
2074
  () => {
@@ -1803,32 +2079,32 @@ function createBoundChildren(owner, fn, queue, mask) {
1803
2079
  );
1804
2080
  }
1805
2081
  var ConditionalQueue = class extends Queue {
1806
- n;
1807
- O = /* @__PURE__ */ new Set();
1808
- P = /* @__PURE__ */ new Set();
2082
+ s;
2083
+ Y = /* @__PURE__ */ new Set();
2084
+ t = /* @__PURE__ */ new Set();
1809
2085
  constructor(disabled) {
1810
2086
  super();
1811
- this.n = disabled;
2087
+ this.s = disabled;
1812
2088
  }
1813
2089
  run(type) {
1814
- if (!type || this.n.read())
2090
+ if (!type || this.s.read())
1815
2091
  return;
1816
2092
  return super.run(type);
1817
2093
  }
1818
2094
  notify(node, type, flags) {
1819
- if (this.n.read()) {
2095
+ if (this.s.read()) {
1820
2096
  if (type & LOADING_BIT) {
1821
2097
  if (flags & LOADING_BIT) {
1822
- this.P.add(node);
2098
+ this.t.add(node);
1823
2099
  type &= ~LOADING_BIT;
1824
- } else if (this.P.delete(node))
2100
+ } else if (this.t.delete(node))
1825
2101
  type &= ~LOADING_BIT;
1826
2102
  }
1827
2103
  if (type & ERROR_BIT) {
1828
2104
  if (flags & ERROR_BIT) {
1829
- this.O.add(node);
2105
+ this.Y.add(node);
1830
2106
  type &= ~ERROR_BIT;
1831
- } else if (this.O.delete(node))
2107
+ } else if (this.Y.delete(node))
1832
2108
  type &= ~ERROR_BIT;
1833
2109
  }
1834
2110
  }
@@ -1836,31 +2112,31 @@ var ConditionalQueue = class extends Queue {
1836
2112
  }
1837
2113
  };
1838
2114
  var CollectionQueue = class extends Queue {
1839
- Q;
1840
- b = /* @__PURE__ */ new Set();
1841
- n = new Computation(false, null, { pureWrite: true });
2115
+ Z;
2116
+ c = /* @__PURE__ */ new Set();
2117
+ s = new Computation(false, null, { pureWrite: true });
1842
2118
  constructor(type) {
1843
2119
  super();
1844
- this.Q = type;
2120
+ this.Z = type;
1845
2121
  }
1846
2122
  run(type) {
1847
- if (!type || this.n.read())
2123
+ if (!type || this.s.read())
1848
2124
  return;
1849
2125
  return super.run(type);
1850
2126
  }
1851
2127
  notify(node, type, flags) {
1852
- if (!(type & this.Q))
2128
+ if (!(type & this.Z))
1853
2129
  return super.notify(node, type, flags);
1854
- if (flags & this.Q) {
1855
- this.b.add(node);
1856
- if (this.b.size === 1)
1857
- 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);
1858
2134
  } else {
1859
- this.b.delete(node);
1860
- if (this.b.size === 0)
1861
- this.n.write(false);
2135
+ this.c.delete(node);
2136
+ if (this.c.size === 0)
2137
+ this.s.write(false);
1862
2138
  }
1863
- type &= ~this.Q;
2139
+ type &= ~this.Z;
1864
2140
  return type ? super.notify(node, type, flags) : true;
1865
2141
  }
1866
2142
  };
@@ -1871,25 +2147,25 @@ function createBoundary(fn, condition) {
1871
2147
  );
1872
2148
  const tree = createBoundChildren(owner, fn, queue, 0);
1873
2149
  new EagerComputation(void 0, () => {
1874
- const disabled = queue.n.read();
1875
- tree.I = disabled ? ERROR_BIT | LOADING_BIT : 0;
2150
+ const disabled = queue.s.read();
2151
+ tree.S = disabled ? ERROR_BIT | LOADING_BIT : 0;
1876
2152
  if (!disabled) {
1877
- queue.P.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
1878
- queue.O.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
1879
- queue.P.clear();
1880
- queue.O.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();
1881
2157
  }
1882
2158
  });
1883
- return () => queue.n.read() ? void 0 : tree.read();
2159
+ return () => queue.s.read() ? void 0 : tree.read();
1884
2160
  }
1885
2161
  function createCollectionBoundary(type, fn, fallback) {
1886
2162
  const owner = new Owner();
1887
2163
  const queue = new CollectionQueue(type);
1888
2164
  const tree = createBoundChildren(owner, fn, queue, type);
1889
2165
  const decision = new Computation(void 0, () => {
1890
- if (!queue.n.read()) {
2166
+ if (!queue.s.read()) {
1891
2167
  const resolved = tree.read();
1892
- if (!queue.n.read())
2168
+ if (!queue.s.read())
1893
2169
  return resolved;
1894
2170
  }
1895
2171
  return fallback(queue);
@@ -1903,11 +2179,11 @@ function createErrorBoundary(fn, fallback) {
1903
2179
  return createCollectionBoundary(
1904
2180
  ERROR_BIT,
1905
2181
  fn,
1906
- (queue) => fallback(queue.b.values().next().value.F, () => {
2182
+ (queue) => fallback(queue.c.values().next().value.O, () => {
1907
2183
  incrementClock();
1908
- for (let node of queue.b) {
1909
- node.a = STATE_DIRTY;
1910
- node.h?.enqueue(node.s, node);
2184
+ for (let node of queue.c) {
2185
+ node.b = STATE_DIRTY;
2186
+ node.i?.enqueue(node.y, node.A.bind(node));
1911
2187
  }
1912
2188
  })
1913
2189
  );