@solidjs/signals 0.4.3 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node.cjs CHANGED
@@ -41,37 +41,37 @@ function incrementClock() {
41
41
  clock++;
42
42
  }
43
43
  var ActiveTransition = null;
44
- var unobserved = [];
44
+ var Unobserved = [];
45
45
  var scheduled = false;
46
46
  function schedule() {
47
47
  if (scheduled)
48
48
  return;
49
49
  scheduled = true;
50
- if (!globalQueue.x)
50
+ if (!globalQueue.z)
51
51
  queueMicrotask(flush);
52
52
  }
53
53
  function notifyUnobserved() {
54
54
  var _a, _b;
55
- for (let i = 0; i < unobserved.length; i++) {
56
- const source = unobserved[i];
57
- if (!source.d || !source.d.length)
58
- (_b = (_a = unobserved[i]).ca) == null ? void 0 : _b.call(_a);
55
+ for (let i = 0; i < Unobserved.length; i++) {
56
+ const source = Unobserved[i];
57
+ if (!source.b || !source.b.length)
58
+ (_b = (_a = Unobserved[i]).da) == null ? void 0 : _b.call(_a);
59
59
  }
60
- unobserved = [];
60
+ Unobserved = [];
61
61
  }
62
62
  var pureQueue = [];
63
63
  var Queue = class {
64
- p = null;
65
- x = false;
66
- o = [[], []];
67
- q = [];
64
+ m = null;
65
+ z = false;
66
+ f = [[], []];
67
+ e = [];
68
68
  created = clock;
69
69
  enqueue(type, fn) {
70
- if (ActiveTransition)
71
- return ActiveTransition.enqueue(type, fn);
70
+ if (ActiveTransition && ActiveTransition.u.has(this))
71
+ return ActiveTransition.u.get(this).enqueue(type, fn);
72
72
  pureQueue.push(fn);
73
73
  if (type)
74
- this.o[type - 1].push(fn);
74
+ this.f[type - 1].push(fn);
75
75
  schedule();
76
76
  }
77
77
  run(type) {
@@ -79,19 +79,19 @@ var Queue = class {
79
79
  pureQueue.length && runQueue(pureQueue, type);
80
80
  pureQueue = [];
81
81
  return;
82
- } else if (this.o[type - 1].length) {
83
- const effects = this.o[type - 1];
84
- this.o[type - 1] = [];
82
+ } else if (this.f[type - 1].length) {
83
+ const effects = this.f[type - 1];
84
+ this.f[type - 1] = [];
85
85
  runQueue(effects, type);
86
86
  }
87
- for (let i = 0; i < this.q.length; i++) {
88
- this.q[i].run(type);
87
+ for (let i = 0; i < this.e.length; i++) {
88
+ this.e[i].run(type);
89
89
  }
90
90
  }
91
91
  flush() {
92
- if (this.x)
92
+ if (this.z)
93
93
  return;
94
- this.x = true;
94
+ this.z = true;
95
95
  try {
96
96
  this.run(EFFECT_PURE);
97
97
  incrementClock();
@@ -99,24 +99,37 @@ var Queue = class {
99
99
  this.run(EFFECT_RENDER);
100
100
  this.run(EFFECT_USER);
101
101
  } finally {
102
- this.x = false;
103
- unobserved.length && notifyUnobserved();
102
+ this.z = false;
103
+ Unobserved.length && notifyUnobserved();
104
104
  }
105
105
  }
106
106
  addChild(child) {
107
- this.q.push(child);
108
- child.p = this;
107
+ this.e.push(child);
108
+ child.m = this;
109
109
  }
110
110
  removeChild(child) {
111
- const index = this.q.indexOf(child);
111
+ const index = this.e.indexOf(child);
112
112
  if (index >= 0)
113
- this.q.splice(index, 1);
113
+ this.e.splice(index, 1);
114
114
  }
115
115
  notify(...args) {
116
- if (this.p)
117
- return this.p.notify(...args);
116
+ if (ActiveTransition && ActiveTransition.u.has(this))
117
+ return ActiveTransition.u.get(this).notify(...args);
118
+ if (this.m)
119
+ return this.m.notify(...args);
118
120
  return false;
119
121
  }
122
+ merge(queue) {
123
+ this.f[0].push.apply(this.f[0], queue.f[0]);
124
+ this.f[1].push.apply(this.f[1], queue.f[1]);
125
+ for (let i = 0; i < queue.e.length; i++) {
126
+ const og = this.e.find((c) => c.g === queue.e[i].g);
127
+ if (og)
128
+ og.merge(queue.e[i]);
129
+ else
130
+ this.addChild(queue.e[i]);
131
+ }
132
+ }
120
133
  };
121
134
  var globalQueue = new Queue();
122
135
  function flush() {
@@ -130,84 +143,103 @@ function runQueue(queue, type) {
130
143
  }
131
144
  var Transition = class _Transition {
132
145
  a = /* @__PURE__ */ new Map();
133
- t = /* @__PURE__ */ new Set();
134
- M = /* @__PURE__ */ new Set();
135
- T = /* @__PURE__ */ new Set();
136
- E = false;
137
- o = [[], []];
138
- F = [];
139
- q = [];
140
- p = null;
141
- x = false;
142
- U = false;
146
+ s = /* @__PURE__ */ new Set();
147
+ R = /* @__PURE__ */ new Set();
148
+ W = /* @__PURE__ */ new Set();
149
+ I = false;
150
+ f = [[], []];
151
+ u = /* @__PURE__ */ new Map();
152
+ E = [];
153
+ e = [];
154
+ m = null;
155
+ z = false;
156
+ X = false;
143
157
  created = clock;
158
+ constructor() {
159
+ this.u.set(globalQueue, this);
160
+ for (const child of globalQueue.e) {
161
+ cloneQueue(child, this, this.u);
162
+ }
163
+ }
144
164
  enqueue(type, fn) {
145
- this.F.push(fn);
165
+ this.E.push(fn);
146
166
  if (type)
147
- this.o[type - 1].push(fn);
167
+ this.f[type - 1].push(fn);
148
168
  this.schedule();
149
169
  }
150
170
  run(type) {
151
171
  if (type === EFFECT_PURE) {
152
- this.F.length && runQueue(this.F, type);
153
- this.F = [];
172
+ this.E.length && runQueue(this.E, type);
173
+ this.E = [];
154
174
  return;
155
- } else if (this.o[type - 1].length) {
156
- const effects = this.o[type - 1];
157
- this.o[type - 1] = [];
175
+ } else if (this.f[type - 1].length) {
176
+ const effects = this.f[type - 1];
177
+ this.f[type - 1] = [];
158
178
  runQueue(effects, type);
159
179
  }
160
- for (let i = 0; i < this.q.length; i++) {
161
- this.q[i].run(type);
180
+ for (let i = 0; i < this.e.length; i++) {
181
+ this.e[i].run(type);
162
182
  }
163
183
  }
164
184
  flush() {
165
- if (this.x)
185
+ if (this.z)
166
186
  return;
167
- this.x = true;
187
+ this.z = true;
168
188
  let currentTransition = ActiveTransition;
169
189
  ActiveTransition = this;
170
190
  try {
171
191
  this.run(EFFECT_PURE);
172
192
  incrementClock();
173
- this.U = false;
193
+ this.X = false;
174
194
  ActiveTransition = currentTransition;
175
195
  finishTransition(this);
176
196
  } finally {
177
- this.x = false;
197
+ this.z = false;
178
198
  ActiveTransition = currentTransition;
179
199
  }
180
200
  }
181
201
  addChild(child) {
182
- this.q.push(child);
183
- child.p = this;
202
+ this.e.push(child);
203
+ child.m = this;
184
204
  }
185
205
  removeChild(child) {
186
- const index = this.q.indexOf(child);
206
+ const index = this.e.indexOf(child);
187
207
  if (index >= 0)
188
- this.q.splice(index, 1);
208
+ this.e.splice(index, 1);
189
209
  }
190
210
  notify(node, type, flags) {
191
211
  if (!(type & LOADING_BIT))
192
212
  return false;
193
213
  if (flags & LOADING_BIT) {
194
- this.t.add(node);
214
+ this.s.add(node);
195
215
  } else {
196
- this.t.delete(node);
216
+ this.s.delete(node);
197
217
  }
198
218
  return true;
199
219
  }
220
+ merge(queue) {
221
+ this.f[0].push.apply(this.f[0], queue.f[0]);
222
+ this.f[1].push.apply(this.f[1], queue.f[1]);
223
+ this.E.push.apply(this.E, queue.E);
224
+ for (let i = 0; i < queue.e.length; i++) {
225
+ const og = this.e.find((c) => c.g === queue.e[i].g);
226
+ if (og)
227
+ og.merge(queue.e[i]);
228
+ else
229
+ this.addChild(queue.e[i]);
230
+ }
231
+ }
200
232
  schedule() {
201
- if (this.U)
233
+ if (this.X)
202
234
  return;
203
- this.U = true;
204
- if (!this.x)
235
+ this.X = true;
236
+ if (!this.z)
205
237
  queueMicrotask(() => this.flush());
206
238
  }
207
239
  runTransition(fn, force = false) {
208
- if (this.E) {
209
- if (this.E instanceof _Transition)
210
- return this.E.runTransition(fn, force);
240
+ if (this.I) {
241
+ if (this.I instanceof _Transition)
242
+ return this.I.runTransition(fn, force);
211
243
  if (!force)
212
244
  throw new Error("Transition already completed");
213
245
  fn();
@@ -218,9 +250,9 @@ var Transition = class _Transition {
218
250
  const result = fn();
219
251
  const transition2 = ActiveTransition;
220
252
  if (result instanceof Promise) {
221
- transition2.M.add(result);
253
+ transition2.R.add(result);
222
254
  result.finally(() => {
223
- transition2.M.delete(result);
255
+ transition2.R.delete(result);
224
256
  finishTransition(transition2);
225
257
  });
226
258
  }
@@ -231,96 +263,142 @@ var Transition = class _Transition {
231
263
  }
232
264
  }
233
265
  addOptimistic(fn) {
234
- if (fn.h && fn.h !== this) {
235
- mergeTransitions(fn.h, this);
236
- ActiveTransition = fn.h;
266
+ if (fn.k && fn.k !== this) {
267
+ mergeTransitions(fn.k, this);
268
+ ActiveTransition = fn.k;
237
269
  return;
238
270
  }
239
- fn.h = this;
240
- this.T.add(fn);
271
+ fn.k = this;
272
+ this.W.add(fn);
241
273
  }
242
274
  };
243
- var Transitions = /* @__PURE__ */ new Set();
244
275
  function transition(fn) {
245
276
  let t = new Transition();
246
- Transitions.add(t);
247
277
  queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
248
278
  }
249
279
  function cloneGraph(node) {
250
- if (node.h) {
251
- if (node.h !== ActiveTransition) {
252
- mergeTransitions(node.h, ActiveTransition);
253
- ActiveTransition = node.h;
280
+ if (node.k) {
281
+ if (node.k !== ActiveTransition) {
282
+ mergeTransitions(node.k, ActiveTransition);
283
+ ActiveTransition = node.k;
254
284
  }
255
- return node.h.a.get(node);
285
+ return node.k.a.get(node);
256
286
  }
257
287
  const clone = Object.create(Object.getPrototypeOf(node));
258
- Object.assign(clone, node, { j: null, r: null, N: node });
288
+ Object.assign(clone, node, {
289
+ n: null,
290
+ r: null,
291
+ b: null,
292
+ a: node.a ? [...node.a] : null,
293
+ g: node
294
+ });
259
295
  ActiveTransition.a.set(node, clone);
260
- node.h = ActiveTransition;
261
- if (node.d) {
262
- for (let i = 0, length = node.d.length; i < length; i++) {
263
- const o = node.d[i];
264
- node.d.push(cloneGraph(o));
296
+ node.k = ActiveTransition;
297
+ if (node.a) {
298
+ for (let i = 0; i < node.a.length; i++)
299
+ node.a[i].b.push(clone);
300
+ }
301
+ if (node.b) {
302
+ clone.b = [];
303
+ for (let i = 0, length = node.b.length; i < length; i++) {
304
+ !node.b[i].g && clone.b.push(cloneGraph(node.b[i]));
265
305
  }
266
306
  }
267
307
  return clone;
268
308
  }
269
- function removeSourceObservers(node, index) {
309
+ function replaceSourceObservers(node, transition2) {
270
310
  let source;
311
+ let transitionSource;
271
312
  let swap;
272
- for (let i = index; i < node.a.length; i++) {
273
- source = ActiveTransition && ActiveTransition.a.get(node.a[i]) || node.a[i];
274
- if (source.d) {
275
- if ((swap = source.d.indexOf(node)) !== -1) {
276
- source.d[swap] = source.d[source.d.length - 1];
277
- source.d.pop();
313
+ for (let i = 0; i < node.a.length; i++) {
314
+ transitionSource = transition2.a.get(node.a[i]);
315
+ source = transitionSource || node.a[i];
316
+ if (source.b && (swap = source.b.indexOf(node)) !== -1) {
317
+ source.b[swap] = transitionSource ? node.g : source.b[source.b.length - 1];
318
+ !transitionSource && source.b.pop();
319
+ }
320
+ }
321
+ }
322
+ function cloneQueue(queue, parent, clonedQueues) {
323
+ const clone = Object.create(Object.getPrototypeOf(queue));
324
+ Object.assign(clone, queue, {
325
+ g: queue,
326
+ m: parent,
327
+ e: [],
328
+ enqueue(type, fn) {
329
+ ActiveTransition == null ? void 0 : ActiveTransition.enqueue(type, fn);
330
+ },
331
+ notify(node, type, flags) {
332
+ node = node.g || node;
333
+ if (!clone.F || type & LOADING_BIT) {
334
+ type &= ~LOADING_BIT;
335
+ ActiveTransition == null ? void 0 : ActiveTransition.notify(node, LOADING_BIT, flags);
336
+ if (!type)
337
+ return true;
278
338
  }
279
- if (!source.d.length)
280
- unobserved.push(source);
339
+ return queue.notify.call(this, node, type, flags);
340
+ }
341
+ });
342
+ parent.e.push(clone);
343
+ clonedQueues.set(queue, clone);
344
+ for (const child of queue.e) {
345
+ cloneQueue(child, clone, clonedQueues);
346
+ }
347
+ }
348
+ function resolveQueues(children) {
349
+ for (const child of children) {
350
+ const og = child.g;
351
+ if (og) {
352
+ const clonedChildren = child.e;
353
+ delete child.enqueue;
354
+ delete child.notify;
355
+ delete child.m;
356
+ delete child.e;
357
+ Object.assign(og, child);
358
+ delete og.g;
359
+ resolveQueues(clonedChildren);
360
+ } else if (child.m.g) {
361
+ child.m.g.addChild(child);
281
362
  }
282
363
  }
283
364
  }
284
365
  function mergeTransitions(t1, t2) {
285
366
  t2.a.forEach((value, key) => {
286
- key.h = t1;
367
+ key.k = t1;
287
368
  t1.a.set(key, value);
288
369
  });
289
- t2.T.forEach((c) => {
290
- c.h = t1;
291
- t1.T.add(c);
370
+ t2.W.forEach((c) => {
371
+ c.k = t1;
372
+ t1.W.add(c);
292
373
  });
293
- t2.M.forEach((p) => t1.M.add(p));
294
- t2.t.forEach((n) => t1.t.add(n));
295
- t2.o[0].forEach((f) => t1.o[0].push(f));
296
- t2.o[1].forEach((f) => t1.o[1].push(f));
297
- t2.F.forEach((f) => t1.F.push(f));
298
- t2.q.forEach((c) => t1.addChild(c));
299
- t2.E = t1;
300
- Transitions.delete(t2);
374
+ t2.R.forEach((p) => t1.R.add(p));
375
+ t2.s.forEach((n) => t1.s.add(n));
376
+ t1.merge(t2);
377
+ t2.I = t1;
301
378
  }
302
379
  function finishTransition(transition2) {
303
- if (transition2.E || transition2.U || transition2.M.size || transition2.t.size)
380
+ if (transition2.I || transition2.X || transition2.R.size || transition2.s.size)
304
381
  return;
305
382
  for (const [source, clone] of transition2.a) {
306
- if (source === clone || source.h !== transition2)
383
+ if (source === clone || source.k !== transition2)
307
384
  continue;
308
385
  if (clone.a)
309
- removeSourceObservers(clone, 0);
386
+ replaceSourceObservers(clone, transition2);
310
387
  source.dispose(false);
311
388
  source.emptyDisposal();
312
389
  Object.assign(source, clone);
313
- delete source.N;
314
- delete source.h;
315
- }
316
- transition2.E = true;
317
- Transitions.delete(transition2);
318
- transition2.run(EFFECT_RENDER);
319
- transition2.run(EFFECT_USER);
320
- for (const reset of transition2.T) {
321
- delete reset.h;
390
+ delete source.g;
391
+ delete source.k;
392
+ }
393
+ globalQueue.f[0].push.apply(globalQueue.f[0], transition2.f[0]);
394
+ globalQueue.f[1].push.apply(globalQueue.f[1], transition2.f[1]);
395
+ resolveQueues(transition2.e);
396
+ transition2.I = true;
397
+ for (const reset of transition2.W) {
398
+ delete reset.k;
322
399
  reset();
323
400
  }
401
+ globalQueue.flush();
324
402
  }
325
403
 
326
404
  // src/core/owner.ts
@@ -338,14 +416,14 @@ var Owner = class {
338
416
  // We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild
339
417
  // However, the children are actually added in reverse creation order
340
418
  // See comment at the top of the file for an example of the _nextSibling traversal
341
- p = null;
419
+ m = null;
342
420
  r = null;
343
- z = null;
344
- b = STATE_CLEAN;
345
- j = null;
346
- u = defaultContext;
347
- i = globalQueue;
348
- da = 0;
421
+ B = null;
422
+ c = STATE_CLEAN;
423
+ n = null;
424
+ w = defaultContext;
425
+ l = globalQueue;
426
+ ea = 0;
349
427
  id = null;
350
428
  constructor(id = null, skipAppend = false) {
351
429
  this.id = id;
@@ -354,64 +432,64 @@ var Owner = class {
354
432
  }
355
433
  }
356
434
  append(child) {
357
- child.p = this;
358
- child.z = this;
435
+ child.m = this;
436
+ child.B = this;
359
437
  if (this.r)
360
- this.r.z = child;
438
+ this.r.B = child;
361
439
  child.r = this.r;
362
440
  this.r = child;
363
441
  if (this.id != null && child.id == null)
364
442
  child.id = this.getNextChildId();
365
- if (child.u !== this.u) {
366
- child.u = { ...this.u, ...child.u };
443
+ if (child.w !== this.w) {
444
+ child.w = { ...this.w, ...child.w };
367
445
  }
368
- if (this.i)
369
- child.i = this.i;
446
+ if (this.l)
447
+ child.l = this.l;
370
448
  }
371
449
  dispose(self = true) {
372
- if (this.b === STATE_DISPOSED)
450
+ if (this.c === STATE_DISPOSED)
373
451
  return;
374
- let head = self ? this.z || this.p : this, current = this.r, next = null;
375
- while (current && current.p === this) {
452
+ let head = self ? this.B || this.m : this, current = this.r, next = null;
453
+ while (current && current.m === this) {
376
454
  current.dispose(true);
377
- current.G();
455
+ current.J();
378
456
  next = current.r;
379
457
  current.r = null;
380
458
  current = next;
381
459
  }
382
- this.da = 0;
460
+ this.ea = 0;
383
461
  if (self)
384
- this.G();
462
+ this.J();
385
463
  if (current)
386
- current.z = !self ? this : this.z;
464
+ current.B = !self ? this : this.B;
387
465
  if (head)
388
466
  head.r = current;
389
467
  }
390
- G() {
391
- if (this.z)
392
- this.z.r = null;
393
- this.p = null;
394
- this.z = null;
395
- this.u = defaultContext;
396
- this.b = STATE_DISPOSED;
468
+ J() {
469
+ if (this.B)
470
+ this.B.r = null;
471
+ this.m = null;
472
+ this.B = null;
473
+ this.w = defaultContext;
474
+ this.c = STATE_DISPOSED;
397
475
  this.emptyDisposal();
398
476
  }
399
477
  emptyDisposal() {
400
- if (!this.j)
478
+ if (!this.n)
401
479
  return;
402
- if (Array.isArray(this.j)) {
403
- for (let i = 0; i < this.j.length; i++) {
404
- const callable = this.j[i];
480
+ if (Array.isArray(this.n)) {
481
+ for (let i = 0; i < this.n.length; i++) {
482
+ const callable = this.n[i];
405
483
  callable.call(callable);
406
484
  }
407
485
  } else {
408
- this.j.call(this.j);
486
+ this.n.call(this.n);
409
487
  }
410
- this.j = null;
488
+ this.n = null;
411
489
  }
412
490
  getNextChildId() {
413
491
  if (this.id != null)
414
- return formatId(this.id, this.da++);
492
+ return formatId(this.id, this.ea++);
415
493
  throw new Error("Cannot get child id from owner without an id");
416
494
  }
417
495
  };
@@ -422,7 +500,7 @@ function getContext(context, owner = currentOwner) {
422
500
  if (!owner) {
423
501
  throw new NoOwnerError();
424
502
  }
425
- const value = hasContext(context, owner) ? owner.u[context.id] : context.defaultValue;
503
+ const value = hasContext(context, owner) ? owner.w[context.id] : context.defaultValue;
426
504
  if (isUndefined(value)) {
427
505
  throw new ContextNotFoundError();
428
506
  }
@@ -432,24 +510,24 @@ function setContext(context, value, owner = currentOwner) {
432
510
  if (!owner) {
433
511
  throw new NoOwnerError();
434
512
  }
435
- owner.u = {
436
- ...owner.u,
513
+ owner.w = {
514
+ ...owner.w,
437
515
  [context.id]: isUndefined(value) ? context.defaultValue : value
438
516
  };
439
517
  }
440
518
  function hasContext(context, owner = currentOwner) {
441
- return !isUndefined(owner == null ? void 0 : owner.u[context.id]);
519
+ return !isUndefined(owner == null ? void 0 : owner.w[context.id]);
442
520
  }
443
521
  function onCleanup(fn) {
444
522
  if (!currentOwner)
445
523
  return fn;
446
524
  const node = currentOwner;
447
- if (!node.j) {
448
- node.j = fn;
449
- } else if (Array.isArray(node.j)) {
450
- node.j.push(fn);
525
+ if (!node.n) {
526
+ node.n = fn;
527
+ } else if (Array.isArray(node.n)) {
528
+ node.n.push(fn);
451
529
  } else {
452
- node.j = [node.j, fn];
530
+ node.n = [node.n, fn];
453
531
  }
454
532
  return fn;
455
533
  }
@@ -476,49 +554,49 @@ function getObserver() {
476
554
  var UNCHANGED = Symbol(0);
477
555
  var Computation = class extends Owner {
478
556
  a = null;
479
- d = null;
480
- g;
481
- O;
482
- H;
557
+ b = null;
558
+ j;
559
+ K;
560
+ L;
483
561
  // Used in __DEV__ mode, hopefully removed in production
484
- ja;
562
+ ka;
485
563
  // Using false is an optimization as an alternative to _equals: () => false
486
564
  // which could enable more efficient DIRTY notification
487
- _ = isEqual;
488
- ca;
489
- fa = false;
565
+ $ = isEqual;
566
+ da;
567
+ ga = false;
490
568
  /** Whether the computation is an error or has ancestors that are unresolved */
491
- f = 0;
569
+ h = 0;
492
570
  /** Which flags raised by sources are handled, vs. being passed through. */
493
- $ = DEFAULT_FLAGS;
494
- I = -1;
495
- C = false;
496
- h;
497
- N;
571
+ aa = DEFAULT_FLAGS;
572
+ M = -1;
573
+ G = false;
574
+ k;
575
+ g;
498
576
  constructor(initialValue, compute2, options) {
499
577
  super(options == null ? void 0 : options.id, compute2 === null);
500
- this.H = compute2;
501
- this.b = compute2 ? STATE_DIRTY : STATE_CLEAN;
502
- this.f = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
503
- this.g = initialValue;
578
+ this.L = compute2;
579
+ this.c = compute2 ? STATE_DIRTY : STATE_CLEAN;
580
+ this.h = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
581
+ this.j = initialValue;
504
582
  if ((options == null ? void 0 : options.equals) !== void 0)
505
- this._ = options.equals;
583
+ this.$ = options.equals;
506
584
  if (options == null ? void 0 : options.pureWrite)
507
- this.fa = true;
585
+ this.ga = true;
508
586
  if (options == null ? void 0 : options.unobserved)
509
- this.ca = options == null ? void 0 : options.unobserved;
587
+ this.da = options == null ? void 0 : options.unobserved;
510
588
  if (ActiveTransition) {
511
- this.h = ActiveTransition;
589
+ this.k = ActiveTransition;
512
590
  ActiveTransition.a.set(this, this);
513
591
  }
514
592
  }
515
- ea() {
593
+ fa() {
516
594
  track(this);
517
- newFlags |= this.f & ~currentMask;
518
- if (this.f & ERROR_BIT) {
519
- throw this.O;
595
+ newFlags |= this.h & ~currentMask;
596
+ if (this.h & ERROR_BIT) {
597
+ throw this.K;
520
598
  } else {
521
- return this.g;
599
+ return this.j;
522
600
  }
523
601
  }
524
602
  /**
@@ -526,18 +604,18 @@ var Computation = class extends Owner {
526
604
  * Automatically re-executes the surrounding computation when the value changes
527
605
  */
528
606
  read() {
529
- if (ActiveTransition && ActiveTransition.a.has(this)) {
530
- const clone = ActiveTransition.a.get(this);
607
+ if (ActiveTransition && (ActiveTransition.a.has(this) || !this.g && this.h & UNINITIALIZED_BIT)) {
608
+ const clone = ActiveTransition.a.get(this) || cloneGraph(this);
531
609
  if (clone !== this)
532
610
  return clone.read();
533
611
  }
534
- if (this.H) {
535
- if (this.f & ERROR_BIT && this.I <= clock)
612
+ if (this.L) {
613
+ if (this.h & ERROR_BIT && this.M <= clock)
536
614
  update(this);
537
615
  else
538
- this.D();
616
+ this.H();
539
617
  }
540
- return this.ea();
618
+ return this.fa();
541
619
  }
542
620
  /**
543
621
  * Return the current value of this computation
@@ -547,69 +625,65 @@ var Computation = class extends Owner {
547
625
  * before continuing
548
626
  */
549
627
  wait() {
550
- if (ActiveTransition && ActiveTransition.a.has(this)) {
551
- const clone = ActiveTransition.a.get(this);
628
+ if (ActiveTransition && (ActiveTransition.a.has(this) || !this.g && this.h & UNINITIALIZED_BIT)) {
629
+ const clone = ActiveTransition.a.get(this) || cloneGraph(this);
552
630
  if (clone !== this)
553
631
  return clone.wait();
554
632
  }
555
- if (this.H) {
556
- if (this.f & ERROR_BIT && this.I <= clock)
633
+ if (this.L) {
634
+ if (this.h & ERROR_BIT && this.M <= clock)
557
635
  update(this);
558
636
  else
559
- this.D();
637
+ this.H();
560
638
  }
561
- if ((notStale || this.f & UNINITIALIZED_BIT) && this.f & LOADING_BIT) {
639
+ if ((notStale || this.h & UNINITIALIZED_BIT) && this.h & LOADING_BIT) {
562
640
  track(this);
563
641
  throw new NotReadyError();
564
642
  }
565
- if (staleCheck && this.f & LOADING_BIT) {
566
- staleCheck.g = true;
643
+ if (staleCheck && this.h & LOADING_BIT) {
644
+ staleCheck.j = true;
567
645
  }
568
- return this.ea();
646
+ return this.fa();
569
647
  }
570
648
  /** Update the computation with a new value. */
571
649
  write(value, flags = 0, raw = false) {
572
- if (ActiveTransition && !this.N) {
650
+ if (ActiveTransition && !this.g) {
573
651
  const clone = cloneGraph(this);
574
- return clone.write(value, flags, raw);
652
+ if (clone !== this)
653
+ return clone.write(value, flags, raw);
575
654
  }
576
- const newValue = !raw && typeof value === "function" ? value(this.g) : value;
577
- const valueChanged = newValue !== UNCHANGED && (!!(this.f & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
578
- this._ === false || !this._(this.g, newValue));
655
+ const newValue = !raw && typeof value === "function" ? value(this.j) : value;
656
+ const valueChanged = newValue !== UNCHANGED && (!!(this.h & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
657
+ this.$ === false || !this.$(this.j, newValue));
579
658
  if (valueChanged) {
580
- this.g = newValue;
581
- this.O = void 0;
582
- }
583
- const changedFlagsMask = this.f ^ flags, changedFlags = changedFlagsMask & flags;
584
- this.f = flags;
585
- this.I = clock + 1;
586
- if (this.d) {
587
- for (let i = 0; i < this.d.length; i++) {
659
+ this.j = newValue;
660
+ this.K = void 0;
661
+ }
662
+ const changedFlagsMask = this.h ^ flags, changedFlags = changedFlagsMask & flags;
663
+ this.h = flags;
664
+ this.M = clock + 1;
665
+ if (this.b) {
666
+ for (let i = 0; i < this.b.length; i++) {
588
667
  if (valueChanged) {
589
- this.d[i].k(STATE_DIRTY);
668
+ this.b[i].x(STATE_DIRTY);
590
669
  } else if (changedFlagsMask) {
591
- this.d[i].V(changedFlagsMask, changedFlags);
670
+ this.b[i].Y(changedFlagsMask, changedFlags);
592
671
  }
593
672
  }
594
673
  }
595
- return this.g;
674
+ return this.j;
596
675
  }
597
676
  /**
598
677
  * Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
599
678
  */
600
- k(state, skipQueue) {
601
- if (ActiveTransition && ActiveTransition.a.has(this)) {
602
- const clone = ActiveTransition.a.get(this);
603
- if (clone !== this)
604
- return clone.k(state, skipQueue);
605
- }
606
- if (this.b >= state && !this.C)
679
+ x(state, skipQueue) {
680
+ if (this.c >= state && !this.G)
607
681
  return;
608
- this.C = !!skipQueue;
609
- this.b = state;
610
- if (this.d) {
611
- for (let i = 0; i < this.d.length; i++) {
612
- this.d[i].k(STATE_CHECK, skipQueue);
682
+ this.G = !!skipQueue;
683
+ this.c = state;
684
+ if (this.b) {
685
+ for (let i = 0; i < this.b.length; i++) {
686
+ this.b[i].x(STATE_CHECK, skipQueue);
613
687
  }
614
688
  }
615
689
  }
@@ -619,31 +693,36 @@ var Computation = class extends Owner {
619
693
  * @param mask A bitmask for which flag(s) were changed.
620
694
  * @param newFlags The source's new flags, masked to just the changed ones.
621
695
  */
622
- V(mask, newFlags2) {
623
- if (this.b >= STATE_DIRTY)
696
+ Y(mask, newFlags2) {
697
+ if (this.c >= STATE_DIRTY)
624
698
  return;
625
- if (mask & this.$) {
626
- this.k(STATE_DIRTY);
699
+ if (mask & this.aa) {
700
+ this.x(STATE_DIRTY);
627
701
  return;
628
702
  }
629
- if (this.b >= STATE_CHECK)
703
+ if (this.c >= STATE_CHECK)
630
704
  return;
631
- const prevFlags = this.f & mask;
705
+ const prevFlags = this.h & mask;
632
706
  const deltaFlags = prevFlags ^ newFlags2;
633
707
  if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
634
- this.k(STATE_CHECK);
708
+ this.x(STATE_CHECK);
635
709
  } else {
636
- this.f ^= deltaFlags;
637
- if (this.d) {
638
- for (let i = 0; i < this.d.length; i++) {
639
- this.d[i].V(mask, newFlags2);
710
+ this.h ^= deltaFlags;
711
+ if (this.b) {
712
+ for (let i = 0; i < this.b.length; i++) {
713
+ this.b[i].Y(mask, newFlags2);
640
714
  }
641
715
  }
642
716
  }
643
717
  }
644
- P(error) {
645
- this.O = error;
646
- this.write(UNCHANGED, this.f & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
718
+ N(error) {
719
+ if (ActiveTransition && !this.g) {
720
+ const clone = cloneGraph(this);
721
+ if (clone !== this)
722
+ return clone.N(error);
723
+ }
724
+ this.K = error;
725
+ this.write(UNCHANGED, this.h & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
647
726
  }
648
727
  /**
649
728
  * This is the core part of the reactivity system, which makes sure that the values are updated
@@ -652,48 +731,48 @@ var Computation = class extends Owner {
652
731
  *
653
732
  * This function will ensure that the value and states we read from the computation are up to date
654
733
  */
655
- D() {
656
- if (!this.H) {
734
+ H() {
735
+ if (!this.L) {
657
736
  return;
658
737
  }
659
- if (this.b === STATE_DISPOSED) {
738
+ if (this.c === STATE_DISPOSED) {
660
739
  return;
661
740
  }
662
- if (this.b === STATE_CLEAN) {
741
+ if (this.c === STATE_CLEAN) {
663
742
  return;
664
743
  }
665
744
  let observerFlags = 0;
666
- if (this.b === STATE_CHECK) {
745
+ if (this.c === STATE_CHECK) {
667
746
  for (let i = 0; i < this.a.length; i++) {
668
747
  const source = ActiveTransition && ActiveTransition.a.get(this.a[i]) || this.a[i];
669
- source.D();
670
- observerFlags |= source.f;
671
- if (this.b === STATE_DIRTY) {
748
+ source.H();
749
+ observerFlags |= source.h & ~UNINITIALIZED_BIT;
750
+ if (this.c === STATE_DIRTY) {
672
751
  break;
673
752
  }
674
753
  }
675
754
  }
676
- if (this.b === STATE_DIRTY) {
755
+ if (this.c === STATE_DIRTY) {
677
756
  update(this);
678
757
  } else {
679
758
  this.write(UNCHANGED, observerFlags);
680
- this.b = STATE_CLEAN;
759
+ this.c = STATE_CLEAN;
681
760
  }
682
761
  }
683
762
  /**
684
763
  * Remove ourselves from the owner graph and the computation graph
685
764
  */
686
- G() {
687
- if (this.b === STATE_DISPOSED)
765
+ J() {
766
+ if (this.c === STATE_DISPOSED)
688
767
  return;
689
768
  if (this.a)
690
769
  removeSourceObservers(this, 0);
691
- super.G();
770
+ super.J();
692
771
  }
693
772
  };
694
773
  function track(computation) {
695
- if (ActiveTransition && computation.N)
696
- computation = computation.N;
774
+ if (ActiveTransition && computation.g)
775
+ computation = computation.g;
697
776
  if (currentObserver) {
698
777
  if (!newSources && currentObserver.a && currentObserver.a[newSourcesIndex] === computation) {
699
778
  newSourcesIndex++;
@@ -703,7 +782,7 @@ function track(computation) {
703
782
  newSources.push(computation);
704
783
  }
705
784
  if (updateCheck) {
706
- updateCheck.g = computation.I > currentObserver.I;
785
+ updateCheck.j = computation.M > currentObserver.M;
707
786
  }
708
787
  }
709
788
  }
@@ -715,13 +794,13 @@ function update(node) {
715
794
  try {
716
795
  node.dispose(false);
717
796
  node.emptyDisposal();
718
- const result = compute(node, node.H, node);
797
+ const result = compute(node, node.L, node);
719
798
  node.write(result, newFlags, true);
720
799
  } catch (error) {
721
800
  if (error instanceof NotReadyError) {
722
- node.write(UNCHANGED, newFlags | LOADING_BIT | node.f & UNINITIALIZED_BIT);
801
+ node.write(UNCHANGED, newFlags | LOADING_BIT | node.h & UNINITIALIZED_BIT);
723
802
  } else {
724
- node.P(error);
803
+ node.N(error);
725
804
  }
726
805
  } finally {
727
806
  if (newSources) {
@@ -737,11 +816,11 @@ function update(node) {
737
816
  }
738
817
  let source;
739
818
  for (let i = newSourcesIndex; i < node.a.length; i++) {
740
- source = node.a[i];
741
- if (!source.d)
742
- source.d = [node];
819
+ source = ActiveTransition && ActiveTransition.a.get(node.a[i]) || node.a[i];
820
+ if (!source.b)
821
+ source.b = [node];
743
822
  else
744
- source.d.push(node);
823
+ source.b.push(node);
745
824
  }
746
825
  } else if (node.a && newSourcesIndex < node.a.length) {
747
826
  removeSourceObservers(node, newSourcesIndex);
@@ -750,8 +829,23 @@ function update(node) {
750
829
  newSources = prevSources;
751
830
  newSourcesIndex = prevSourcesIndex;
752
831
  newFlags = prevFlags;
753
- node.I = clock + 1;
754
- node.b = STATE_CLEAN;
832
+ node.M = clock + 1;
833
+ node.c = STATE_CLEAN;
834
+ }
835
+ }
836
+ function removeSourceObservers(node, index) {
837
+ let source;
838
+ let swap;
839
+ for (let i = index; i < node.a.length; i++) {
840
+ source = ActiveTransition && ActiveTransition.a.get(node.a[i]) || node.a[i];
841
+ if (source.b) {
842
+ if ((swap = source.b.indexOf(node)) !== -1) {
843
+ source.b[swap] = source.b[source.b.length - 1];
844
+ source.b.pop();
845
+ }
846
+ if (!source.b.length)
847
+ Unobserved.push(source);
848
+ }
755
849
  }
756
850
  }
757
851
  function isEqual(a, b) {
@@ -764,20 +858,20 @@ function untrack(fn) {
764
858
  }
765
859
  function hasUpdated(fn) {
766
860
  const current = updateCheck;
767
- updateCheck = { g: false };
861
+ updateCheck = { j: false };
768
862
  try {
769
863
  fn();
770
- return updateCheck.g;
864
+ return updateCheck.j;
771
865
  } finally {
772
866
  updateCheck = current;
773
867
  }
774
868
  }
775
869
  function pendingCheck(fn, loadingValue) {
776
870
  const current = staleCheck;
777
- staleCheck = { g: false };
871
+ staleCheck = { j: false };
778
872
  try {
779
873
  latest(fn);
780
- return staleCheck.g;
874
+ return staleCheck.j;
781
875
  } catch (err) {
782
876
  if (!(err instanceof NotReadyError))
783
877
  return false;
@@ -792,7 +886,7 @@ function isPending(fn, loadingValue) {
792
886
  if (!currentObserver)
793
887
  return pendingCheck(fn, loadingValue);
794
888
  const c = new Computation(void 0, () => pendingCheck(fn, loadingValue));
795
- c.$ |= LOADING_BIT;
889
+ c.aa |= LOADING_BIT;
796
890
  return c.read();
797
891
  }
798
892
  function latest(fn, fallback) {
@@ -822,10 +916,10 @@ function runWithObserver(observer, run) {
822
916
  if (error instanceof NotReadyError) {
823
917
  observer.write(
824
918
  UNCHANGED,
825
- newFlags | LOADING_BIT | observer.f & UNINITIALIZED_BIT
919
+ newFlags | LOADING_BIT | observer.h & UNINITIALIZED_BIT
826
920
  );
827
921
  } else {
828
- observer.P(error);
922
+ observer.N(error);
829
923
  }
830
924
  } finally {
831
925
  if (newSources) {
@@ -840,10 +934,10 @@ function runWithObserver(observer, run) {
840
934
  let source;
841
935
  for (let i = newSourcesIndex; i < observer.a.length; i++) {
842
936
  source = observer.a[i];
843
- if (!source.d)
844
- source.d = [observer];
937
+ if (!source.b)
938
+ source.b = [observer];
845
939
  else
846
- source.d.push(observer);
940
+ source.b.push(observer);
847
941
  }
848
942
  }
849
943
  newSources = prevSources;
@@ -854,10 +948,10 @@ function runWithObserver(observer, run) {
854
948
  function compute(owner, fn, observer) {
855
949
  const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
856
950
  currentObserver = observer;
857
- currentMask = (observer == null ? void 0 : observer.$) ?? DEFAULT_FLAGS;
951
+ currentMask = (observer == null ? void 0 : observer.aa) ?? DEFAULT_FLAGS;
858
952
  notStale = true;
859
953
  try {
860
- return fn(observer ? observer.g : void 0);
954
+ return fn.call(observer, observer ? observer.j : void 0);
861
955
  } finally {
862
956
  setOwner(prevOwner);
863
957
  currentObserver = prevObserver;
@@ -868,123 +962,121 @@ function compute(owner, fn, observer) {
868
962
 
869
963
  // src/core/effect.ts
870
964
  var Effect = class extends Computation {
871
- aa;
872
- W;
873
- J;
874
- ba = false;
875
- X;
876
- y;
965
+ ba;
966
+ Z;
967
+ O;
968
+ ca = false;
969
+ _;
970
+ A;
877
971
  constructor(initialValue, compute2, effect, error, options) {
878
972
  super(initialValue, compute2, options);
879
- this.aa = effect;
880
- this.W = error;
881
- this.X = initialValue;
882
- this.y = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
883
- if (this.y === EFFECT_RENDER) {
884
- this.H = (p) => !ActiveTransition && clock > this.i.created && !(this.f & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
973
+ this.ba = effect;
974
+ this.Z = error;
975
+ this._ = initialValue;
976
+ this.A = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
977
+ if (this.A === EFFECT_RENDER) {
978
+ this.L = function(p) {
979
+ return !this.g && clock > this.l.created && !(this.h & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
980
+ };
885
981
  }
886
- this.D();
887
- !(options == null ? void 0 : options.defer) && (this.y === EFFECT_USER ? (ActiveTransition || this.i).enqueue(this.y, this.A.bind(this)) : this.A(this.y));
982
+ this.H();
983
+ !(options == null ? void 0 : options.defer) && (this.A === EFFECT_USER ? this.l.enqueue(this.A, this.C.bind(this)) : this.C(this.A));
888
984
  }
889
985
  write(value, flags = 0) {
890
- if (this.b == STATE_DIRTY) {
891
- this.f = flags;
892
- if (this.y === EFFECT_RENDER) {
893
- (ActiveTransition || this.i).notify(this, LOADING_BIT | ERROR_BIT, flags);
986
+ if (this.c == STATE_DIRTY) {
987
+ this.h = flags;
988
+ if (this.A === EFFECT_RENDER) {
989
+ this.l.notify(this, LOADING_BIT | ERROR_BIT, this.h);
894
990
  }
895
991
  }
896
992
  if (value === UNCHANGED)
897
- return this.g;
898
- this.g = value;
899
- this.ba = true;
993
+ return this.j;
994
+ this.j = value;
995
+ this.ca = true;
996
+ this.K = void 0;
900
997
  return value;
901
998
  }
902
- k(state, skipQueue) {
903
- if (ActiveTransition && ActiveTransition.a.has(this)) {
904
- return ActiveTransition.a.get(this).k(state, skipQueue);
905
- }
906
- if (this.b >= state || skipQueue)
999
+ x(state, skipQueue) {
1000
+ if (this.c >= state || skipQueue)
907
1001
  return;
908
- if (this.b === STATE_CLEAN)
909
- (ActiveTransition || this.i).enqueue(this.y, this.A.bind(this));
910
- this.b = state;
1002
+ if (this.c === STATE_CLEAN)
1003
+ this.l.enqueue(this.A, this.C.bind(this));
1004
+ this.c = state;
911
1005
  }
912
- V(mask, newFlags2) {
913
- if (ActiveTransition && ActiveTransition.a.has(this)) {
914
- if (this.b >= STATE_CHECK)
1006
+ Y(mask, newFlags2) {
1007
+ if (this.g) {
1008
+ if (this.c >= STATE_DIRTY)
915
1009
  return;
916
1010
  if (mask & 3) {
917
- this.k(STATE_DIRTY);
1011
+ this.x(STATE_DIRTY);
918
1012
  return;
919
1013
  }
920
1014
  }
921
- super.V(mask, newFlags2);
1015
+ super.Y(mask, newFlags2);
922
1016
  }
923
- P(error) {
924
- this.O = error;
925
- (ActiveTransition || this.i).notify(this, LOADING_BIT, 0);
926
- this.f = ERROR_BIT;
927
- if (this.y === EFFECT_USER) {
1017
+ N(error) {
1018
+ this.K = error;
1019
+ this.l.notify(this, LOADING_BIT, 0);
1020
+ this.h = ERROR_BIT;
1021
+ if (this.A === EFFECT_USER) {
928
1022
  try {
929
- return this.W ? this.W(error, () => {
1023
+ return this.Z ? this.Z(error, () => {
930
1024
  var _a;
931
- (_a = this.J) == null ? void 0 : _a.call(this);
932
- this.J = void 0;
1025
+ (_a = this.O) == null ? void 0 : _a.call(this);
1026
+ this.O = void 0;
933
1027
  }) : console.error(error);
934
1028
  } catch (e) {
935
1029
  error = e;
936
1030
  }
937
1031
  }
938
- if (!(ActiveTransition || this.i).notify(this, ERROR_BIT, ERROR_BIT))
1032
+ if (!this.l.notify(this, ERROR_BIT, ERROR_BIT))
939
1033
  throw error;
940
1034
  }
941
- G() {
1035
+ J() {
942
1036
  var _a;
943
- if (this.b === STATE_DISPOSED)
1037
+ if (this.c === STATE_DISPOSED)
944
1038
  return;
945
- this.aa = void 0;
946
- this.X = void 0;
947
- this.W = void 0;
948
- (_a = this.J) == null ? void 0 : _a.call(this);
949
- this.J = void 0;
950
- super.G();
951
- }
952
- A(type) {
1039
+ this.ba = void 0;
1040
+ this._ = void 0;
1041
+ this.Z = void 0;
1042
+ (_a = this.O) == null ? void 0 : _a.call(this);
1043
+ this.O = void 0;
1044
+ super.J();
1045
+ }
1046
+ C(type) {
953
1047
  var _a;
954
1048
  if (type) {
955
- if (this.ba && this.b !== STATE_DISPOSED) {
956
- (_a = this.J) == null ? void 0 : _a.call(this);
1049
+ const effect = this.g || this;
1050
+ if (effect.ca && effect.c !== STATE_DISPOSED) {
1051
+ (_a = effect.O) == null ? void 0 : _a.call(effect);
957
1052
  try {
958
- this.J = this.aa(this.g, this.X);
1053
+ effect.O = effect.ba(effect.j, effect._);
959
1054
  } catch (e) {
960
- if (!(ActiveTransition || this.i).notify(this, ERROR_BIT, ERROR_BIT))
1055
+ if (!effect.l.notify(effect, ERROR_BIT, ERROR_BIT))
961
1056
  throw e;
962
1057
  } finally {
963
- this.X = this.g;
964
- this.ba = false;
1058
+ effect._ = effect.j;
1059
+ effect.ca = false;
965
1060
  }
966
1061
  }
967
1062
  } else
968
- this.b !== STATE_CLEAN && runTop(this);
1063
+ this.c !== STATE_CLEAN && runTop(this);
969
1064
  }
970
1065
  };
971
1066
  var EagerComputation = class extends Computation {
972
1067
  constructor(initialValue, compute2, options) {
973
1068
  super(initialValue, compute2, options);
974
- !(options == null ? void 0 : options.defer) && this.D();
1069
+ !(options == null ? void 0 : options.defer) && this.H();
975
1070
  }
976
- k(state, skipQueue) {
977
- if (ActiveTransition && ActiveTransition.a.has(this)) {
978
- return ActiveTransition.a.get(this).k(state, skipQueue);
979
- }
980
- if (this.b >= state && !this.C)
1071
+ x(state, skipQueue) {
1072
+ if (this.c >= state && !this.G)
981
1073
  return;
982
- if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.C))
983
- (ActiveTransition || this.i).enqueue(EFFECT_PURE, this.A.bind(this));
984
- super.k(state, skipQueue);
1074
+ if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.G))
1075
+ this.l.enqueue(EFFECT_PURE, this.C.bind(this));
1076
+ super.x(state, skipQueue);
985
1077
  }
986
- A() {
987
- this.b !== STATE_CLEAN && runTop(this);
1078
+ C() {
1079
+ this.c !== STATE_CLEAN && runTop(this);
988
1080
  }
989
1081
  };
990
1082
  var FirewallComputation = class extends Computation {
@@ -992,31 +1084,28 @@ var FirewallComputation = class extends Computation {
992
1084
  constructor(compute2) {
993
1085
  super(void 0, compute2);
994
1086
  }
995
- k(state, skipQueue) {
996
- if (ActiveTransition && ActiveTransition.a.has(this)) {
997
- return ActiveTransition.a.get(this).k(state, skipQueue);
998
- }
999
- if (this.b >= state && !this.C)
1087
+ x(state, skipQueue) {
1088
+ if (this.c >= state && !this.G)
1000
1089
  return;
1001
- if (!skipQueue && (this.b === STATE_CLEAN || this.b === STATE_CHECK && this.C))
1002
- (ActiveTransition || this.i).enqueue(EFFECT_PURE, this.A.bind(this));
1003
- super.k(state, true);
1004
- this.C = !!skipQueue;
1090
+ if (!skipQueue && (this.c === STATE_CLEAN || this.c === STATE_CHECK && this.G))
1091
+ this.l.enqueue(EFFECT_PURE, this.C.bind(this));
1092
+ super.x(state, true);
1093
+ this.G = !!skipQueue;
1005
1094
  }
1006
- A() {
1007
- this.b !== STATE_CLEAN && runTop(this);
1095
+ C() {
1096
+ this.c !== STATE_CLEAN && runTop(this);
1008
1097
  }
1009
1098
  };
1010
1099
  function runTop(node) {
1011
1100
  const ancestors = [];
1012
- for (let current = node; current !== null; current = current.p) {
1013
- if (current.b !== STATE_CLEAN) {
1101
+ for (let current = node; current !== null; current = current.m) {
1102
+ if (current.c !== STATE_CLEAN) {
1014
1103
  ancestors.push(current);
1015
1104
  }
1016
1105
  }
1017
1106
  for (let i = ancestors.length - 1; i >= 0; i--) {
1018
- if (ancestors[i].b !== STATE_DISPOSED)
1019
- ancestors[i].D();
1107
+ if (ancestors[i].c !== STATE_DISPOSED)
1108
+ ancestors[i].H();
1020
1109
  }
1021
1110
  }
1022
1111
 
@@ -1151,7 +1240,7 @@ var storeTraps = {
1151
1240
  return desc.get.call(receiver);
1152
1241
  }
1153
1242
  if (Writing == null ? void 0 : Writing.has(receiver)) {
1154
- let value2 = tracked && (overridden || !proxySource) ? tracked.g : storeValue[property];
1243
+ let value2 = tracked && (overridden || !proxySource) ? tracked.j : storeValue[property];
1155
1244
  value2 === $DELETED && (value2 = void 0);
1156
1245
  if (!isWrappable(value2))
1157
1246
  return value2;
@@ -1448,6 +1537,8 @@ function applyState(next, state, keyFn, all) {
1448
1537
  }
1449
1538
  function reconcile(value, key, all = false) {
1450
1539
  return (state) => {
1540
+ if (state == null)
1541
+ throw new Error("Cannot reconcile null or undefined state");
1451
1542
  const keyFn = typeof key === "string" ? (item) => item[key] : key;
1452
1543
  const eq = keyFn(state);
1453
1544
  if (eq !== void 0 && keyFn(value) !== keyFn(state))
@@ -1689,12 +1780,12 @@ function createMemo(compute2, value, options) {
1689
1780
  return () => {
1690
1781
  var _a, _b;
1691
1782
  if (node) {
1692
- if (node.b === STATE_DISPOSED) {
1783
+ if (node.c === STATE_DISPOSED) {
1693
1784
  node = void 0;
1694
1785
  return resolvedValue;
1695
1786
  }
1696
1787
  resolvedValue = node.wait();
1697
- if (!((_a = node.a) == null ? void 0 : _a.length) && ((_b = node.r) == null ? void 0 : _b.p) !== node) {
1788
+ if (!((_a = node.a) == null ? void 0 : _a.length) && ((_b = node.r) == null ? void 0 : _b.m) !== node && !(node.h & UNINITIALIZED_BIT)) {
1698
1789
  node.dispose();
1699
1790
  node = void 0;
1700
1791
  }
@@ -1730,8 +1821,8 @@ function createAsync(compute2, value, options) {
1730
1821
  if (abort)
1731
1822
  return;
1732
1823
  if (transition2)
1733
- return transition2.runTransition(() => node.P(error), true);
1734
- node.P(error);
1824
+ return transition2.runTransition(() => node.N(error), true);
1825
+ node.N(error);
1735
1826
  }
1736
1827
  );
1737
1828
  } else {
@@ -1755,9 +1846,13 @@ function createAsync(compute2, value, options) {
1755
1846
  );
1756
1847
  const read = node.wait.bind(node);
1757
1848
  read.refresh = () => {
1758
- node.b = STATE_DIRTY;
1849
+ let n = node;
1850
+ if (ActiveTransition && !node.g) {
1851
+ n = cloneGraph(node);
1852
+ }
1853
+ n.c = STATE_DIRTY;
1759
1854
  refreshing = true;
1760
- node.D();
1855
+ n.H();
1761
1856
  };
1762
1857
  return read;
1763
1858
  }
@@ -1838,7 +1933,7 @@ function createOptimistic(initial, compute2, key) {
1838
1933
  (s) => {
1839
1934
  const value = initial();
1840
1935
  if (!ActiveTransition)
1841
- s.value = value;
1936
+ reconcile({ value }, key)(s);
1842
1937
  },
1843
1938
  { value: void 0 }
1844
1939
  );
@@ -1846,9 +1941,9 @@ function createOptimistic(initial, compute2, key) {
1846
1941
  [store, setStore] = createStore({ value: initial });
1847
1942
  const reset = () => setStore(
1848
1943
  (s) => reconcile(
1849
- typeof initial === "function" ? initial() : initial,
1944
+ { value: typeof initial === "function" ? initial() : initial },
1850
1945
  key
1851
- )(s.value)
1946
+ )(s)
1852
1947
  );
1853
1948
  let lastChange = void 0;
1854
1949
  function write(v) {
@@ -1869,197 +1964,197 @@ function createOptimistic(initial, compute2, key) {
1869
1964
  function mapArray(list, map, options) {
1870
1965
  const keyFn = typeof (options == null ? void 0 : options.keyed) === "function" ? options.keyed : void 0;
1871
1966
  return updateKeyedMap.bind({
1872
- Q: new Owner(),
1873
- l: 0,
1874
- ga: list,
1875
- B: [],
1876
- K: map,
1877
- e: [],
1878
- c: [],
1879
- L: keyFn,
1880
- m: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
1881
- n: map.length > 1 ? [] : void 0,
1882
- R: options == null ? void 0 : options.fallback
1967
+ S: new Owner(),
1968
+ o: 0,
1969
+ ha: list,
1970
+ D: [],
1971
+ P: map,
1972
+ i: [],
1973
+ d: [],
1974
+ Q: keyFn,
1975
+ p: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
1976
+ q: map.length > 1 ? [] : void 0,
1977
+ T: options == null ? void 0 : options.fallback
1883
1978
  });
1884
1979
  }
1885
1980
  var pureOptions = { pureWrite: true };
1886
1981
  function updateKeyedMap() {
1887
- const newItems = this.ga() || [], newLen = newItems.length;
1982
+ const newItems = this.ha() || [], newLen = newItems.length;
1888
1983
  newItems[$TRACK];
1889
- runWithOwner(this.Q, () => {
1890
- let i, j, mapper = this.m ? () => {
1891
- this.m[j] = new Computation(newItems[j], null, pureOptions);
1892
- this.n && (this.n[j] = new Computation(j, null, pureOptions));
1893
- return this.K(
1894
- Computation.prototype.read.bind(this.m[j]),
1895
- this.n ? Computation.prototype.read.bind(this.n[j]) : void 0
1984
+ runWithOwner(this.S, () => {
1985
+ let i, j, mapper = this.p ? () => {
1986
+ this.p[j] = new Computation(newItems[j], null, pureOptions);
1987
+ this.q && (this.q[j] = new Computation(j, null, pureOptions));
1988
+ return this.P(
1989
+ Computation.prototype.read.bind(this.p[j]),
1990
+ this.q ? Computation.prototype.read.bind(this.q[j]) : void 0
1896
1991
  );
1897
- } : this.n ? () => {
1992
+ } : this.q ? () => {
1898
1993
  const item = newItems[j];
1899
- this.n[j] = new Computation(j, null, pureOptions);
1900
- return this.K(() => item, Computation.prototype.read.bind(this.n[j]));
1994
+ this.q[j] = new Computation(j, null, pureOptions);
1995
+ return this.P(() => item, Computation.prototype.read.bind(this.q[j]));
1901
1996
  } : () => {
1902
1997
  const item = newItems[j];
1903
- return this.K(() => item);
1998
+ return this.P(() => item);
1904
1999
  };
1905
2000
  if (newLen === 0) {
1906
- if (this.l !== 0) {
1907
- this.Q.dispose(false);
1908
- this.c = [];
1909
- this.B = [];
1910
- this.e = [];
1911
- this.l = 0;
1912
- this.m && (this.m = []);
1913
- this.n && (this.n = []);
2001
+ if (this.o !== 0) {
2002
+ this.S.dispose(false);
2003
+ this.d = [];
2004
+ this.D = [];
2005
+ this.i = [];
2006
+ this.o = 0;
2007
+ this.p && (this.p = []);
2008
+ this.q && (this.q = []);
1914
2009
  }
1915
- if (this.R && !this.e[0]) {
1916
- this.e[0] = compute(
1917
- this.c[0] = new Owner(),
1918
- this.R,
2010
+ if (this.T && !this.i[0]) {
2011
+ this.i[0] = compute(
2012
+ this.d[0] = new Owner(),
2013
+ this.T,
1919
2014
  null
1920
2015
  );
1921
2016
  }
1922
- } else if (this.l === 0) {
1923
- if (this.c[0])
1924
- this.c[0].dispose();
1925
- this.e = new Array(newLen);
2017
+ } else if (this.o === 0) {
2018
+ if (this.d[0])
2019
+ this.d[0].dispose();
2020
+ this.i = new Array(newLen);
1926
2021
  for (j = 0; j < newLen; j++) {
1927
- this.B[j] = newItems[j];
1928
- this.e[j] = compute(this.c[j] = new Owner(), mapper, null);
2022
+ this.D[j] = newItems[j];
2023
+ this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
1929
2024
  }
1930
- this.l = newLen;
2025
+ this.o = newLen;
1931
2026
  } else {
1932
- 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;
1933
- 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++) {
1934
- if (this.m)
1935
- this.m[start].write(newItems[start]);
2027
+ let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.p ? new Array(newLen) : void 0, tempIndexes = this.q ? new Array(newLen) : void 0;
2028
+ for (start = 0, end = Math.min(this.o, newLen); start < end && (this.D[start] === newItems[start] || this.p && compare(this.Q, this.D[start], newItems[start])); start++) {
2029
+ if (this.p)
2030
+ this.p[start].write(newItems[start]);
1936
2031
  }
1937
- 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--) {
1938
- temp[newEnd] = this.e[end];
1939
- tempNodes[newEnd] = this.c[end];
1940
- tempRows && (tempRows[newEnd] = this.m[end]);
1941
- tempIndexes && (tempIndexes[newEnd] = this.n[end]);
2032
+ for (end = this.o - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.D[end] === newItems[newEnd] || this.p && compare(this.Q, this.D[end], newItems[newEnd])); end--, newEnd--) {
2033
+ temp[newEnd] = this.i[end];
2034
+ tempNodes[newEnd] = this.d[end];
2035
+ tempRows && (tempRows[newEnd] = this.p[end]);
2036
+ tempIndexes && (tempIndexes[newEnd] = this.q[end]);
1942
2037
  }
1943
2038
  newIndices = /* @__PURE__ */ new Map();
1944
2039
  newIndicesNext = new Array(newEnd + 1);
1945
2040
  for (j = newEnd; j >= start; j--) {
1946
2041
  item = newItems[j];
1947
- key = this.L ? this.L(item) : item;
2042
+ key = this.Q ? this.Q(item) : item;
1948
2043
  i = newIndices.get(key);
1949
2044
  newIndicesNext[j] = i === void 0 ? -1 : i;
1950
2045
  newIndices.set(key, j);
1951
2046
  }
1952
2047
  for (i = start; i <= end; i++) {
1953
- item = this.B[i];
1954
- key = this.L ? this.L(item) : item;
2048
+ item = this.D[i];
2049
+ key = this.Q ? this.Q(item) : item;
1955
2050
  j = newIndices.get(key);
1956
2051
  if (j !== void 0 && j !== -1) {
1957
- temp[j] = this.e[i];
1958
- tempNodes[j] = this.c[i];
1959
- tempRows && (tempRows[j] = this.m[i]);
1960
- tempIndexes && (tempIndexes[j] = this.n[i]);
2052
+ temp[j] = this.i[i];
2053
+ tempNodes[j] = this.d[i];
2054
+ tempRows && (tempRows[j] = this.p[i]);
2055
+ tempIndexes && (tempIndexes[j] = this.q[i]);
1961
2056
  j = newIndicesNext[j];
1962
2057
  newIndices.set(key, j);
1963
2058
  } else
1964
- this.c[i].dispose();
2059
+ this.d[i].dispose();
1965
2060
  }
1966
2061
  for (j = start; j < newLen; j++) {
1967
2062
  if (j in temp) {
1968
- this.e[j] = temp[j];
1969
- this.c[j] = tempNodes[j];
2063
+ this.i[j] = temp[j];
2064
+ this.d[j] = tempNodes[j];
1970
2065
  if (tempRows) {
1971
- this.m[j] = tempRows[j];
1972
- this.m[j].write(newItems[j]);
2066
+ this.p[j] = tempRows[j];
2067
+ this.p[j].write(newItems[j]);
1973
2068
  }
1974
2069
  if (tempIndexes) {
1975
- this.n[j] = tempIndexes[j];
1976
- this.n[j].write(j);
2070
+ this.q[j] = tempIndexes[j];
2071
+ this.q[j].write(j);
1977
2072
  }
1978
2073
  } else {
1979
- this.e[j] = compute(this.c[j] = new Owner(), mapper, null);
2074
+ this.i[j] = compute(this.d[j] = new Owner(), mapper, null);
1980
2075
  }
1981
2076
  }
1982
- this.e = this.e.slice(0, this.l = newLen);
1983
- this.B = newItems.slice(0);
2077
+ this.i = this.i.slice(0, this.o = newLen);
2078
+ this.D = newItems.slice(0);
1984
2079
  }
1985
2080
  });
1986
- return this.e;
2081
+ return this.i;
1987
2082
  }
1988
2083
  function repeat(count, map, options) {
1989
2084
  return updateRepeat.bind({
1990
- Q: new Owner(),
1991
- l: 0,
1992
- w: 0,
1993
- ha: count,
1994
- K: map,
1995
- c: [],
1996
- e: [],
1997
- ia: options == null ? void 0 : options.from,
1998
- R: options == null ? void 0 : options.fallback
2085
+ S: new Owner(),
2086
+ o: 0,
2087
+ y: 0,
2088
+ ia: count,
2089
+ P: map,
2090
+ d: [],
2091
+ i: [],
2092
+ ja: options == null ? void 0 : options.from,
2093
+ T: options == null ? void 0 : options.fallback
1999
2094
  });
2000
2095
  }
2001
2096
  function updateRepeat() {
2002
2097
  var _a;
2003
- const newLen = this.ha();
2004
- const from = ((_a = this.ia) == null ? void 0 : _a.call(this)) || 0;
2005
- runWithOwner(this.Q, () => {
2098
+ const newLen = this.ia();
2099
+ const from = ((_a = this.ja) == null ? void 0 : _a.call(this)) || 0;
2100
+ runWithOwner(this.S, () => {
2006
2101
  if (newLen === 0) {
2007
- if (this.l !== 0) {
2008
- this.Q.dispose(false);
2009
- this.c = [];
2010
- this.e = [];
2011
- this.l = 0;
2102
+ if (this.o !== 0) {
2103
+ this.S.dispose(false);
2104
+ this.d = [];
2105
+ this.i = [];
2106
+ this.o = 0;
2012
2107
  }
2013
- if (this.R && !this.e[0]) {
2014
- this.e[0] = compute(
2015
- this.c[0] = new Owner(),
2016
- this.R,
2108
+ if (this.T && !this.i[0]) {
2109
+ this.i[0] = compute(
2110
+ this.d[0] = new Owner(),
2111
+ this.T,
2017
2112
  null
2018
2113
  );
2019
2114
  }
2020
2115
  return;
2021
2116
  }
2022
2117
  const to = from + newLen;
2023
- const prevTo = this.w + this.l;
2024
- if (this.l === 0 && this.c[0])
2025
- this.c[0].dispose();
2118
+ const prevTo = this.y + this.o;
2119
+ if (this.o === 0 && this.d[0])
2120
+ this.d[0].dispose();
2026
2121
  for (let i = to; i < prevTo; i++)
2027
- this.c[i - this.w].dispose();
2028
- if (this.w < from) {
2029
- let i = this.w;
2030
- while (i < from && i < this.l)
2031
- this.c[i++].dispose();
2032
- this.c.splice(0, from - this.w);
2033
- this.e.splice(0, from - this.w);
2034
- } else if (this.w > from) {
2035
- let i = prevTo - this.w - 1;
2036
- let difference = this.w - from;
2037
- this.c.length = this.e.length = newLen;
2122
+ this.d[i - this.y].dispose();
2123
+ if (this.y < from) {
2124
+ let i = this.y;
2125
+ while (i < from && i < this.o)
2126
+ this.d[i++].dispose();
2127
+ this.d.splice(0, from - this.y);
2128
+ this.i.splice(0, from - this.y);
2129
+ } else if (this.y > from) {
2130
+ let i = prevTo - this.y - 1;
2131
+ let difference = this.y - from;
2132
+ this.d.length = this.i.length = newLen;
2038
2133
  while (i >= difference) {
2039
- this.c[i] = this.c[i - difference];
2040
- this.e[i] = this.e[i - difference];
2134
+ this.d[i] = this.d[i - difference];
2135
+ this.i[i] = this.i[i - difference];
2041
2136
  i--;
2042
2137
  }
2043
2138
  for (let i2 = 0; i2 < difference; i2++) {
2044
- this.e[i2] = compute(
2045
- this.c[i2] = new Owner(),
2046
- () => this.K(i2 + from),
2139
+ this.i[i2] = compute(
2140
+ this.d[i2] = new Owner(),
2141
+ () => this.P(i2 + from),
2047
2142
  null
2048
2143
  );
2049
2144
  }
2050
2145
  }
2051
2146
  for (let i = prevTo; i < to; i++) {
2052
- this.e[i - from] = compute(
2053
- this.c[i - from] = new Owner(),
2054
- () => this.K(i),
2147
+ this.i[i - from] = compute(
2148
+ this.d[i - from] = new Owner(),
2149
+ () => this.P(i),
2055
2150
  null
2056
2151
  );
2057
2152
  }
2058
- this.e = this.e.slice(0, newLen);
2059
- this.w = from;
2060
- this.l = newLen;
2153
+ this.i = this.i.slice(0, newLen);
2154
+ this.y = from;
2155
+ this.o = newLen;
2061
2156
  });
2062
- return this.e;
2157
+ return this.i;
2063
2158
  }
2064
2159
  function compare(key, a, b) {
2065
2160
  return key ? key(a) === key(b) : true;
@@ -2067,24 +2162,24 @@ function compare(key, a, b) {
2067
2162
 
2068
2163
  // src/boundaries.ts
2069
2164
  var BoundaryComputation = class extends EagerComputation {
2070
- S;
2165
+ U;
2071
2166
  constructor(compute2, propagationMask) {
2072
2167
  super(void 0, compute2, { defer: true });
2073
- this.S = propagationMask;
2168
+ this.U = propagationMask;
2074
2169
  }
2075
2170
  write(value, flags) {
2076
- super.write(value, flags & ~this.S);
2077
- if (this.S & LOADING_BIT && !(this.f & UNINITIALIZED_BIT)) {
2171
+ super.write(value, flags & ~this.U);
2172
+ if (this.U & LOADING_BIT && !(this.h & UNINITIALIZED_BIT)) {
2078
2173
  flags &= ~LOADING_BIT;
2079
2174
  }
2080
- this.i.notify(this, this.S, flags);
2081
- return this.g;
2175
+ this.l.notify(this, this.U, flags);
2176
+ return this.j;
2082
2177
  }
2083
2178
  };
2084
2179
  function createBoundChildren(owner, fn, queue, mask) {
2085
- const parentQueue = owner.i;
2086
- parentQueue.addChild(owner.i = queue);
2087
- onCleanup(() => parentQueue.removeChild(owner.i));
2180
+ const parentQueue = owner.l;
2181
+ parentQueue.addChild(owner.l = queue);
2182
+ onCleanup(() => parentQueue.removeChild(owner.l));
2088
2183
  return compute(
2089
2184
  owner,
2090
2185
  () => {
@@ -2095,66 +2190,79 @@ function createBoundChildren(owner, fn, queue, mask) {
2095
2190
  );
2096
2191
  }
2097
2192
  var ConditionalQueue = class extends Queue {
2098
- s;
2099
- Y = /* @__PURE__ */ new Set();
2100
- t = /* @__PURE__ */ new Set();
2193
+ t;
2194
+ V = /* @__PURE__ */ new Set();
2195
+ s = /* @__PURE__ */ new Set();
2101
2196
  constructor(disabled) {
2102
2197
  super();
2103
- this.s = disabled;
2198
+ this.t = disabled;
2104
2199
  }
2105
2200
  run(type) {
2106
- if (!type || this.s.read())
2201
+ if (!type || this.t.read())
2107
2202
  return;
2108
2203
  return super.run(type);
2109
2204
  }
2110
2205
  notify(node, type, flags) {
2111
- if (this.s.read()) {
2206
+ if (ActiveTransition && ActiveTransition.u.has(this))
2207
+ return ActiveTransition.u.get(this).notify(node, type, flags);
2208
+ if (this.t.read()) {
2112
2209
  if (type & LOADING_BIT) {
2113
2210
  if (flags & LOADING_BIT) {
2114
- this.t.add(node);
2211
+ this.s.add(node);
2115
2212
  type &= ~LOADING_BIT;
2116
- } else if (this.t.delete(node))
2213
+ } else if (this.s.delete(node))
2117
2214
  type &= ~LOADING_BIT;
2118
2215
  }
2119
2216
  if (type & ERROR_BIT) {
2120
2217
  if (flags & ERROR_BIT) {
2121
- this.Y.add(node);
2218
+ this.V.add(node);
2122
2219
  type &= ~ERROR_BIT;
2123
- } else if (this.Y.delete(node))
2220
+ } else if (this.V.delete(node))
2124
2221
  type &= ~ERROR_BIT;
2125
2222
  }
2126
2223
  }
2127
2224
  return type ? super.notify(node, type, flags) : true;
2128
2225
  }
2226
+ merge(queue) {
2227
+ queue.s.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
2228
+ queue.V.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
2229
+ super.merge(queue);
2230
+ }
2129
2231
  };
2130
2232
  var CollectionQueue = class extends Queue {
2131
- Z;
2132
- c = /* @__PURE__ */ new Set();
2133
- s = new Computation(false, null, { pureWrite: true });
2233
+ F;
2234
+ d = /* @__PURE__ */ new Set();
2235
+ t = new Computation(false, null, { pureWrite: true });
2134
2236
  constructor(type) {
2135
2237
  super();
2136
- this.Z = type;
2238
+ this.F = type;
2137
2239
  }
2138
2240
  run(type) {
2139
- if (!type || this.s.read())
2241
+ if (!type || this.t.read())
2140
2242
  return;
2141
2243
  return super.run(type);
2142
2244
  }
2143
2245
  notify(node, type, flags) {
2144
- if (!(type & this.Z))
2246
+ if (ActiveTransition && ActiveTransition.u.has(this))
2247
+ return ActiveTransition.u.get(this).notify(node, type, flags);
2248
+ if (!(type & this.F))
2145
2249
  return super.notify(node, type, flags);
2146
- if (flags & this.Z) {
2147
- this.c.add(node);
2148
- if (this.c.size === 1)
2149
- this.s.write(true);
2250
+ if (flags & this.F) {
2251
+ this.d.add(node);
2252
+ if (this.d.size === 1)
2253
+ this.t.write(true);
2150
2254
  } else {
2151
- this.c.delete(node);
2152
- if (this.c.size === 0)
2153
- this.s.write(false);
2255
+ this.d.delete(node);
2256
+ if (this.d.size === 0)
2257
+ this.t.write(false);
2154
2258
  }
2155
- type &= ~this.Z;
2259
+ type &= ~this.F;
2156
2260
  return type ? super.notify(node, type, flags) : true;
2157
2261
  }
2262
+ merge(queue) {
2263
+ queue.d.forEach((n) => this.notify(n, this.F, this.F));
2264
+ super.merge(queue);
2265
+ }
2158
2266
  };
2159
2267
  function createBoundary(fn, condition) {
2160
2268
  const owner = new Owner();
@@ -2163,25 +2271,25 @@ function createBoundary(fn, condition) {
2163
2271
  );
2164
2272
  const tree = createBoundChildren(owner, fn, queue, 0);
2165
2273
  new EagerComputation(void 0, () => {
2166
- const disabled = queue.s.read();
2167
- tree.S = disabled ? ERROR_BIT | LOADING_BIT : 0;
2274
+ const disabled = queue.t.read();
2275
+ tree.U = disabled ? ERROR_BIT | LOADING_BIT : 0;
2168
2276
  if (!disabled) {
2169
- queue.t.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
2170
- queue.Y.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
2171
- queue.t.clear();
2172
- queue.Y.clear();
2277
+ queue.s.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
2278
+ queue.V.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
2279
+ queue.s.clear();
2280
+ queue.V.clear();
2173
2281
  }
2174
2282
  });
2175
- return () => queue.s.read() ? void 0 : tree.read();
2283
+ return () => queue.t.read() ? void 0 : tree.read();
2176
2284
  }
2177
2285
  function createCollectionBoundary(type, fn, fallback) {
2178
2286
  const owner = new Owner();
2179
2287
  const queue = new CollectionQueue(type);
2180
2288
  const tree = createBoundChildren(owner, fn, queue, type);
2181
2289
  const decision = new Computation(void 0, () => {
2182
- if (!queue.s.read()) {
2290
+ if (!queue.t.read()) {
2183
2291
  const resolved = tree.read();
2184
- if (!queue.s.read())
2292
+ if (!queue.t.read())
2185
2293
  return resolved;
2186
2294
  }
2187
2295
  return fallback(queue);
@@ -2192,18 +2300,20 @@ function createSuspense(fn, fallback) {
2192
2300
  return createCollectionBoundary(LOADING_BIT, fn, () => fallback());
2193
2301
  }
2194
2302
  function createErrorBoundary(fn, fallback) {
2195
- return createCollectionBoundary(
2196
- ERROR_BIT,
2197
- fn,
2198
- (queue) => fallback(queue.c.values().next().value.O, () => {
2303
+ return createCollectionBoundary(ERROR_BIT, fn, (queue) => {
2304
+ let node = queue.d.values().next().value;
2305
+ ActiveTransition && ActiveTransition.a.has(node) && (node = ActiveTransition.a.get(node));
2306
+ return fallback(node.K, () => {
2199
2307
  var _a;
2200
2308
  incrementClock();
2201
- for (let node of queue.c) {
2202
- node.b = STATE_DIRTY;
2203
- (_a = node.i) == null ? void 0 : _a.enqueue(node.y, node.A.bind(node));
2309
+ for (let node2 of queue.d) {
2310
+ if (ActiveTransition && !node2.g)
2311
+ node2 = cloneGraph(node2);
2312
+ node2.c = STATE_DIRTY;
2313
+ (_a = node2.l) == null ? void 0 : _a.enqueue(node2.A, node2.C.bind(node2));
2204
2314
  }
2205
- })
2206
- );
2315
+ });
2316
+ });
2207
2317
  }
2208
2318
  function flatten(children, options) {
2209
2319
  if (typeof children === "function" && !children.length) {