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