@solidjs/signals 0.4.1 → 0.4.2

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