@solidjs/signals 0.9.11 → 0.10.0

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
@@ -102,8 +102,8 @@ function markNode(e, t = REACTIVE_DIRTY) {
102
102
  for (let t = e.p; t !== null; t = t.h) {
103
103
  markNode(t.A, REACTIVE_CHECK);
104
104
  }
105
- if (e.N !== null) {
106
- for (let t = e.N; t !== null; t = t.P) {
105
+ if (e.P !== null) {
106
+ for (let t = e.P; t !== null; t = t.C) {
107
107
  for (let e = t.p; e !== null; e = e.h) {
108
108
  markNode(e.A, REACTIVE_CHECK);
109
109
  }
@@ -112,12 +112,12 @@ function markNode(e, t = REACTIVE_DIRTY) {
112
112
  }
113
113
  function runHeap(e, t) {
114
114
  e.I = false;
115
- for (e.C = 0; e.C <= e.S; e.C++) {
116
- let n = e.T[e.C];
115
+ for (e.N = 0; e.N <= e.S; e.N++) {
116
+ let n = e.T[e.N];
117
117
  while (n !== undefined) {
118
118
  if (n._ & REACTIVE_IN_HEAP) t(n);
119
119
  else adjustHeight(n, e);
120
- n = e.T[e.C];
120
+ n = e.T[e.N];
121
121
  }
122
122
  }
123
123
  e.S = 0;
@@ -125,10 +125,10 @@ function runHeap(e, t) {
125
125
  function adjustHeight(e, t) {
126
126
  deleteFromHeap(e, t);
127
127
  let n = e.u;
128
- for (let t = e.D; t; t = t.m) {
129
- const e = t.V;
128
+ for (let t = e.D; t; t = t.V) {
129
+ const e = t.m;
130
130
  const i = e.L || e;
131
- if (i.U && i.u >= n) n = i.u + 1;
131
+ if (i.k && i.u >= n) n = i.u + 1;
132
132
  }
133
133
  if (e.u !== n) {
134
134
  e.u = n;
@@ -138,86 +138,18 @@ function adjustHeight(e, t) {
138
138
  }
139
139
  }
140
140
  const transitions = new Set();
141
- const dirtyQueue = { T: new Array(2e3).fill(undefined), I: false, C: 0, S: 0 };
142
- const zombieQueue = { T: new Array(2e3).fill(undefined), I: false, C: 0, S: 0 };
141
+ const dirtyQueue = { T: new Array(2e3).fill(undefined), I: false, N: 0, S: 0 };
142
+ const zombieQueue = { T: new Array(2e3).fill(undefined), I: false, N: 0, S: 0 };
143
143
  let clock = 0;
144
144
  let activeTransition = null;
145
145
  let scheduled = false;
146
146
  let projectionWriteActive = false;
147
- const signalLanes = new WeakMap();
148
- const activeLanes = new Set();
149
- let currentOptimisticLane = null;
150
- function setCurrentOptimisticLane(e) {
151
- currentOptimisticLane = e;
152
- }
153
- function getOrCreateLane(e) {
154
- let t = signalLanes.get(e);
155
- if (t) {
156
- return findLane(t);
157
- }
158
- const n = e.k;
159
- const i = n?.W ? findLane(n.W) : null;
160
- t = { t: e, G: new Set(), M: [[], []], F: null, $: activeTransition, H: i };
161
- signalLanes.set(e, t);
162
- activeLanes.add(t);
163
- e.j = e.K || 0;
164
- return t;
165
- }
166
- function findLane(e) {
167
- while (e.F) e = e.F;
168
- return e;
169
- }
170
- function mergeLanes(e, t) {
171
- e = findLane(e);
172
- t = findLane(t);
173
- if (e === t) return e;
174
- t.F = e;
175
- for (const n of t.G) e.G.add(n);
176
- e.M[0].push(...t.M[0]);
177
- e.M[1].push(...t.M[1]);
178
- return e;
179
- }
180
- function clearLaneEntry(e) {
181
- signalLanes.delete(e);
182
- }
183
- function resolveLane(e) {
184
- const t = e.W;
185
- if (!t) return undefined;
186
- const n = findLane(t);
187
- if (activeLanes.has(n)) return n;
188
- e.W = undefined;
189
- return undefined;
190
- }
191
- function hasActiveOverride(e) {
192
- return !!(e.Y && e.B !== NOT_PENDING);
193
- }
194
- function assignOrMergeLane(e, t) {
195
- const n = findLane(t);
196
- const i = e.W;
197
- if (i) {
198
- if (i.F) {
199
- e.W = t;
200
- return;
201
- }
202
- const r = findLane(i);
203
- if (activeLanes.has(r)) {
204
- if (r !== n && !hasActiveOverride(e)) {
205
- if (n.H && findLane(n.H) === r) {
206
- e.W = t;
207
- } else if (r.H && findLane(r.H) === n);
208
- else mergeLanes(n, r);
209
- }
210
- return;
211
- }
212
- }
213
- e.W = t;
214
- }
215
147
  function runLaneEffects(e) {
216
148
  for (const t of activeLanes) {
217
- if (t.F || t.G.size > 0) continue;
218
- const n = t.M[e - 1];
149
+ if (t.U || t.W.size > 0) continue;
150
+ const n = t.F[e - 1];
219
151
  if (n.length) {
220
- t.M[e - 1] = [];
152
+ t.F[e - 1] = [];
221
153
  runQueue(n, e);
222
154
  }
223
155
  }
@@ -228,21 +160,21 @@ function setProjectionWriteActive(e) {
228
160
  function schedule() {
229
161
  if (scheduled) return;
230
162
  scheduled = true;
231
- if (!globalQueue.X) queueMicrotask(flush);
163
+ if (!globalQueue.G) queueMicrotask(flush);
232
164
  }
233
165
  class Queue {
234
166
  o = null;
235
- q = [[], []];
236
- Z = [];
167
+ M = [[], []];
168
+ $ = [];
237
169
  created = clock;
238
170
  addChild(e) {
239
- this.Z.push(e);
171
+ this.$.push(e);
240
172
  e.o = this;
241
173
  }
242
174
  removeChild(e) {
243
- const t = this.Z.indexOf(e);
175
+ const t = this.$.indexOf(e);
244
176
  if (t >= 0) {
245
- this.Z.splice(t, 1);
177
+ this.$.splice(t, 1);
246
178
  e.o = null;
247
179
  }
248
180
  }
@@ -251,106 +183,106 @@ class Queue {
251
183
  return false;
252
184
  }
253
185
  run(e) {
254
- if (this.q[e - 1].length) {
255
- const t = this.q[e - 1];
256
- this.q[e - 1] = [];
186
+ if (this.M[e - 1].length) {
187
+ const t = this.M[e - 1];
188
+ this.M[e - 1] = [];
257
189
  runQueue(t, e);
258
190
  }
259
- for (let t = 0; t < this.Z.length; t++) this.Z[t].run?.(e);
191
+ for (let t = 0; t < this.$.length; t++) this.$[t].run?.(e);
260
192
  }
261
193
  enqueue(e, t) {
262
194
  if (e) {
263
195
  if (currentOptimisticLane) {
264
196
  const n = findLane(currentOptimisticLane);
265
- n.M[e - 1].push(t);
197
+ n.F[e - 1].push(t);
266
198
  } else {
267
- this.q[e - 1].push(t);
199
+ this.M[e - 1].push(t);
268
200
  }
269
201
  }
270
202
  schedule();
271
203
  }
272
204
  stashQueues(e) {
273
- e.q[0].push(...this.q[0]);
274
- e.q[1].push(...this.q[1]);
275
- this.q = [[], []];
276
- for (let t = 0; t < this.Z.length; t++) {
277
- let n = this.Z[t];
278
- let i = e.Z[t];
205
+ e.M[0].push(...this.M[0]);
206
+ e.M[1].push(...this.M[1]);
207
+ this.M = [[], []];
208
+ for (let t = 0; t < this.$.length; t++) {
209
+ let n = this.$[t];
210
+ let i = e.$[t];
279
211
  if (!i) {
280
- i = { q: [[], []], Z: [] };
281
- e.Z[t] = i;
212
+ i = { M: [[], []], $: [] };
213
+ e.$[t] = i;
282
214
  }
283
215
  n.stashQueues(i);
284
216
  }
285
217
  }
286
218
  restoreQueues(e) {
287
- this.q[0].push(...e.q[0]);
288
- this.q[1].push(...e.q[1]);
289
- for (let t = 0; t < e.Z.length; t++) {
290
- const n = e.Z[t];
291
- let i = this.Z[t];
219
+ this.M[0].push(...e.M[0]);
220
+ this.M[1].push(...e.M[1]);
221
+ for (let t = 0; t < e.$.length; t++) {
222
+ const n = e.$[t];
223
+ let i = this.$[t];
292
224
  if (i) i.restoreQueues(n);
293
225
  }
294
226
  }
295
227
  }
296
228
  class GlobalQueue extends Queue {
297
- X = false;
298
- J = [];
299
- ee = [];
300
- te = new Set();
301
- static ne;
302
- static ie;
303
- static re = null;
229
+ G = false;
230
+ H = [];
231
+ j = [];
232
+ K = new Set();
233
+ static Y;
234
+ static B;
235
+ static X = null;
304
236
  flush() {
305
- if (this.X) return;
306
- this.X = true;
237
+ if (this.G) return;
238
+ this.G = true;
307
239
  try {
308
- runHeap(dirtyQueue, GlobalQueue.ne);
240
+ runHeap(dirtyQueue, GlobalQueue.Y);
309
241
  if (activeTransition) {
310
242
  const e = transitionComplete(activeTransition);
311
243
  if (!e) {
312
244
  let e = activeTransition;
313
- runHeap(zombieQueue, GlobalQueue.ne);
314
- this.J = [];
315
- this.ee = [];
316
- this.te = new Set();
245
+ runHeap(zombieQueue, GlobalQueue.Y);
246
+ this.H = [];
247
+ this.j = [];
248
+ this.K = new Set();
317
249
  runLaneEffects(EFFECT_RENDER);
318
250
  runLaneEffects(EFFECT_USER);
319
- this.stashQueues(activeTransition.oe);
251
+ this.stashQueues(activeTransition.q);
320
252
  clock++;
321
- scheduled = dirtyQueue.S >= dirtyQueue.C;
322
- reassignPendingTransition(activeTransition.J);
253
+ scheduled = dirtyQueue.S >= dirtyQueue.N;
254
+ reassignPendingTransition(activeTransition.H);
323
255
  activeTransition = null;
324
256
  finalizePureQueue(null, true);
325
257
  return;
326
258
  }
327
- this.J !== activeTransition.J && this.J.push(...activeTransition.J);
328
- this.restoreQueues(activeTransition.oe);
259
+ this.H !== activeTransition.H && this.H.push(...activeTransition.H);
260
+ this.restoreQueues(activeTransition.q);
329
261
  transitions.delete(activeTransition);
330
262
  const t = activeTransition;
331
263
  activeTransition = null;
332
- reassignPendingTransition(this.J);
264
+ reassignPendingTransition(this.H);
333
265
  finalizePureQueue(t);
334
266
  } else {
335
- if (transitions.size) runHeap(zombieQueue, GlobalQueue.ne);
267
+ if (transitions.size) runHeap(zombieQueue, GlobalQueue.Y);
336
268
  finalizePureQueue();
337
269
  }
338
270
  clock++;
339
- scheduled = dirtyQueue.S >= dirtyQueue.C;
271
+ scheduled = dirtyQueue.S >= dirtyQueue.N;
340
272
  runLaneEffects(EFFECT_RENDER);
341
273
  this.run(EFFECT_RENDER);
342
274
  runLaneEffects(EFFECT_USER);
343
275
  this.run(EFFECT_USER);
344
276
  } finally {
345
- this.X = false;
277
+ this.G = false;
346
278
  }
347
279
  }
348
280
  notify(e, t, n, i) {
349
281
  if (t & STATUS_PENDING) {
350
282
  if (n & STATUS_PENDING) {
351
- const t = i !== undefined ? i : e.se;
352
- if (activeTransition && t && !activeTransition.ue.includes(t.t)) {
353
- activeTransition.ue.push(t.t);
283
+ const t = i !== undefined ? i : e.Z;
284
+ if (activeTransition && t && !activeTransition.J.includes(t.t)) {
285
+ activeTransition.J.push(t.t);
354
286
  schedule();
355
287
  }
356
288
  }
@@ -361,143 +293,143 @@ class GlobalQueue extends Queue {
361
293
  initTransition(e) {
362
294
  if (e) e = currentTransition(e);
363
295
  if (e && e === activeTransition) return;
364
- if (!e && activeTransition && activeTransition.ce === clock) return;
296
+ if (!e && activeTransition && activeTransition.ee === clock) return;
365
297
  if (!activeTransition) {
366
298
  activeTransition = e ?? {
367
- ce: clock,
299
+ ee: clock,
300
+ H: [],
368
301
  J: [],
369
- ue: [],
370
- ee: [],
371
- te: new Set(),
372
- le: [],
373
- oe: { q: [[], []], Z: [] },
374
- ae: false
302
+ j: [],
303
+ K: new Set(),
304
+ te: [],
305
+ q: { M: [[], []], $: [] },
306
+ ne: false
375
307
  };
376
308
  } else if (e) {
377
309
  const t = activeTransition;
378
- t.ae = e;
379
- e.le.push(...t.le);
310
+ t.ne = e;
311
+ e.te.push(...t.te);
380
312
  for (const n of activeLanes) {
381
- if (n.$ === t) n.$ = e;
313
+ if (n.ie === t) n.ie = e;
382
314
  }
383
- e.ee.push(...t.ee);
384
- for (const n of t.te) {
385
- e.te.add(n);
315
+ e.j.push(...t.j);
316
+ for (const n of t.K) {
317
+ e.K.add(n);
386
318
  }
387
319
  transitions.delete(t);
388
320
  activeTransition = e;
389
321
  }
390
322
  transitions.add(activeTransition);
391
- activeTransition.ce = clock;
392
- for (let e = 0; e < this.J.length; e++) {
393
- const t = this.J[e];
394
- t.$ = activeTransition;
395
- activeTransition.J.push(t);
396
- }
397
- this.J = activeTransition.J;
398
- for (let e = 0; e < this.ee.length; e++) {
399
- const t = this.ee[e];
400
- t.$ = activeTransition;
401
- activeTransition.ee.push(t);
402
- }
403
- this.ee = activeTransition.ee;
323
+ activeTransition.ee = clock;
324
+ for (let e = 0; e < this.H.length; e++) {
325
+ const t = this.H[e];
326
+ t.ie = activeTransition;
327
+ activeTransition.H.push(t);
328
+ }
329
+ this.H = activeTransition.H;
330
+ for (let e = 0; e < this.j.length; e++) {
331
+ const t = this.j[e];
332
+ t.ie = activeTransition;
333
+ activeTransition.j.push(t);
334
+ }
335
+ this.j = activeTransition.j;
404
336
  for (const e of activeLanes) {
405
- if (!e.$) e.$ = activeTransition;
337
+ if (!e.ie) e.ie = activeTransition;
406
338
  }
407
- for (const e of this.te) activeTransition.te.add(e);
408
- this.te = activeTransition.te;
339
+ for (const e of this.K) activeTransition.K.add(e);
340
+ this.K = activeTransition.K;
409
341
  }
410
342
  }
411
343
  function insertSubs(e, t = false) {
412
- const n = e.W || currentOptimisticLane;
344
+ const n = e.re || currentOptimisticLane;
413
345
  for (let i = e.p; i !== null; i = i.h) {
414
346
  if (t && n) {
415
347
  i.A._ |= REACTIVE_OPTIMISTIC_DIRTY;
416
348
  assignOrMergeLane(i.A, n);
417
349
  } else if (t) {
418
350
  i.A._ |= REACTIVE_OPTIMISTIC_DIRTY;
419
- i.A.W = undefined;
351
+ i.A.re = undefined;
420
352
  }
421
353
  const e = i.A;
422
- if (e.fe === EFFECT_TRACKED) {
423
- if (!e.Ee) {
424
- e.Ee = true;
425
- e.Te.enqueue(EFFECT_USER, e.de);
354
+ if (e.oe === EFFECT_TRACKED) {
355
+ if (!e.se) {
356
+ e.se = true;
357
+ e.ue.enqueue(EFFECT_USER, e.ce);
426
358
  }
427
359
  continue;
428
360
  }
429
361
  const r = i.A._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
430
- if (r.C > i.A.u) r.C = i.A.u;
362
+ if (r.N > i.A.u) r.N = i.A.u;
431
363
  insertIntoHeap(i.A, r);
432
364
  }
433
365
  }
434
366
  function finalizePureQueue(e = null, t = false) {
435
367
  let n = !t;
436
368
  if (!t) checkBoundaryChildren(globalQueue);
437
- if (dirtyQueue.S >= dirtyQueue.C) runHeap(dirtyQueue, GlobalQueue.ne);
369
+ if (dirtyQueue.S >= dirtyQueue.N) runHeap(dirtyQueue, GlobalQueue.Y);
438
370
  if (n) {
439
- const t = globalQueue.J;
371
+ const t = globalQueue.H;
440
372
  for (let e = 0; e < t.length; e++) {
441
373
  const n = t[e];
442
- if (n.B !== NOT_PENDING) {
443
- n.Re = n.B;
444
- n.B = NOT_PENDING;
445
- if (n.fe && n.fe !== EFFECT_TRACKED) n.Ee = true;
374
+ if (n.le !== NOT_PENDING) {
375
+ n.ae = n.le;
376
+ n.le = NOT_PENDING;
377
+ if (n.oe && n.oe !== EFFECT_TRACKED) n.se = true;
446
378
  }
447
- n.Oe &= ~STATUS_UNINITIALIZED;
448
- if (n.U) GlobalQueue.ie(n, false, true);
379
+ n.fe &= ~STATUS_UNINITIALIZED;
380
+ if (n.k) GlobalQueue.B(n, false, true);
449
381
  }
450
382
  t.length = 0;
451
- const n = e ? e.ee : globalQueue.ee;
383
+ const n = e ? e.j : globalQueue.j;
452
384
  for (let e = 0; e < n.length; e++) {
453
385
  const t = n[e];
454
- const i = t.B;
455
- t.W = undefined;
456
- if (i !== NOT_PENDING && t.Re !== i) {
457
- t.Re = i;
386
+ const i = t.le;
387
+ t.re = undefined;
388
+ if (i !== NOT_PENDING && t.ae !== i) {
389
+ t.ae = i;
458
390
  insertSubs(t, true);
459
391
  }
460
- t.B = NOT_PENDING;
461
- t.$ = null;
392
+ t.le = NOT_PENDING;
393
+ t.ie = null;
462
394
  }
463
395
  n.length = 0;
464
- const i = e ? e.te : globalQueue.te;
465
- if (GlobalQueue.re && i.size) {
396
+ const i = e ? e.K : globalQueue.K;
397
+ if (GlobalQueue.X && i.size) {
466
398
  for (const e of i) {
467
- GlobalQueue.re(e);
399
+ GlobalQueue.X(e);
468
400
  }
469
401
  i.clear();
470
402
  schedule();
471
403
  }
472
404
  for (const t of activeLanes) {
473
- const n = e ? t.$ === e : !t.$;
405
+ const n = e ? t.ie === e : !t.ie;
474
406
  if (!n) continue;
475
- if (!t.F) {
476
- if (t.M[0].length) runQueue(t.M[0], EFFECT_RENDER);
477
- if (t.M[1].length) runQueue(t.M[1], EFFECT_USER);
478
- }
479
- if (t.t.W === t) t.t.W = undefined;
480
- t.G.clear();
481
- t.M[0].length = 0;
482
- t.M[1].length = 0;
407
+ if (!t.U) {
408
+ if (t.F[0].length) runQueue(t.F[0], EFFECT_RENDER);
409
+ if (t.F[1].length) runQueue(t.F[1], EFFECT_USER);
410
+ }
411
+ if (t.t.re === t) t.t.re = undefined;
412
+ t.W.clear();
413
+ t.F[0].length = 0;
414
+ t.F[1].length = 0;
483
415
  activeLanes.delete(t);
484
416
  signalLanes.delete(t.t);
485
417
  }
486
418
  }
487
419
  }
488
420
  function checkBoundaryChildren(e) {
489
- for (const t of e.Z) {
421
+ for (const t of e.$) {
490
422
  t.checkSources?.();
491
423
  checkBoundaryChildren(t);
492
424
  }
493
425
  }
494
426
  function trackOptimisticStore(e) {
495
- globalQueue.te.add(e);
427
+ globalQueue.K.add(e);
496
428
  schedule();
497
429
  }
498
430
  function reassignPendingTransition(e) {
499
431
  for (let t = 0; t < e.length; t++) {
500
- e[t].$ = activeTransition;
432
+ e[t].ie = activeTransition;
501
433
  }
502
434
  }
503
435
  const globalQueue = new GlobalQueue();
@@ -510,23 +442,26 @@ function runQueue(e, t) {
510
442
  for (let n = 0; n < e.length; n++) e[n](t);
511
443
  }
512
444
  function transitionComplete(e) {
513
- if (e.ae) return true;
514
- if (e.le.length) return false;
445
+ if (e.ne) return true;
446
+ if (e.te.length) return false;
515
447
  let t = true;
516
- for (let n = 0; n < e.ue.length; n++) {
517
- const i = e.ue[n];
518
- if (i.Oe & STATUS_PENDING && i.se?.t === i) {
448
+ for (let n = 0; n < e.J.length; n++) {
449
+ const i = e.J[n];
450
+ if (i.fe & STATUS_PENDING && i.Z?.t === i) {
519
451
  t = false;
520
452
  break;
521
453
  }
522
454
  }
523
- t && (e.ae = true);
455
+ t && (e.ne = true);
524
456
  return t;
525
457
  }
526
458
  function currentTransition(e) {
527
- while (e.ae && typeof e.ae === "object") e = e.ae;
459
+ while (e.ne && typeof e.ne === "object") e = e.ne;
528
460
  return e;
529
461
  }
462
+ function setActiveTransition(e) {
463
+ activeTransition = e;
464
+ }
530
465
  function runInTransition(e, t) {
531
466
  const n = activeTransition;
532
467
  try {
@@ -536,196 +471,107 @@ function runInTransition(e, t) {
536
471
  activeTransition = n;
537
472
  }
538
473
  }
539
- function restoreTransition(e, t) {
540
- globalQueue.initTransition(e);
541
- const n = t();
542
- flush();
543
- return n;
474
+ const signalLanes = new WeakMap();
475
+ const activeLanes = new Set();
476
+ function getOrCreateLane(e) {
477
+ let t = signalLanes.get(e);
478
+ if (t) {
479
+ return findLane(t);
480
+ }
481
+ const n = e.Ee;
482
+ const i = n?.re ? findLane(n.re) : null;
483
+ t = { t: e, W: new Set(), F: [[], []], U: null, ie: activeTransition, Te: i };
484
+ signalLanes.set(e, t);
485
+ activeLanes.add(t);
486
+ e.de = e.Re || 0;
487
+ return t;
544
488
  }
545
- function action(e) {
546
- return (...t) =>
547
- new Promise((n, i) => {
548
- const r = e(...t);
549
- globalQueue.initTransition();
550
- let o = activeTransition;
551
- o.le.push(r);
552
- const done = (e, t) => {
553
- o = currentTransition(o);
554
- const s = o.le.indexOf(r);
555
- if (s >= 0) o.le.splice(s, 1);
556
- activeTransition = o;
557
- schedule();
558
- t ? i(t) : n(e);
559
- };
560
- const step = (e, t) => {
561
- let n;
562
- try {
563
- n = t ? r.throw(e) : r.next(e);
564
- } catch (e) {
565
- return done(undefined, e);
566
- }
567
- if (n instanceof Promise)
568
- return void n.then(run, e => restoreTransition(o, () => step(e, true)));
569
- run(n);
570
- };
571
- const run = e => {
572
- if (e.done) return done(e.value);
573
- if (e.value instanceof Promise)
574
- return void e.value.then(
575
- e => restoreTransition(o, () => step(e)),
576
- e => restoreTransition(o, () => step(e, true))
577
- );
578
- restoreTransition(o, () => step(e.value));
579
- };
580
- step();
581
- });
489
+ function findLane(e) {
490
+ while (e.U) e = e.U;
491
+ return e;
582
492
  }
583
- GlobalQueue.ne = recompute;
584
- GlobalQueue.ie = disposeChildren;
585
- let tracking = false;
586
- let stale = false;
587
- let refreshing = false;
588
- let pendingCheckActive = false;
589
- let foundPending = false;
590
- let pendingReadActive = false;
591
- let context = null;
592
- function recompute(e, t = false) {
593
- const n = e.fe;
594
- if (!t) {
595
- if (e.$ && (!n || activeTransition) && activeTransition !== e.$)
596
- globalQueue.initTransition(e.$);
597
- deleteFromHeap(e, e._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
598
- if (e.$ || n === EFFECT_TRACKED) disposeChildren(e);
599
- else {
600
- markDisposal(e);
601
- e.Se = e._e;
602
- e.Ie = e.pe;
603
- e._e = null;
604
- e.pe = null;
605
- }
606
- }
607
- const i = !!(e._ & REACTIVE_OPTIMISTIC_DIRTY);
608
- const r = hasActiveOverride(e);
609
- const o = !!(e.Oe & STATUS_PENDING);
610
- const s = context;
611
- context = e;
612
- e.he = null;
613
- e._ = REACTIVE_RECOMPUTING_DEPS;
614
- e.ce = clock;
615
- let u = e.B === NOT_PENDING ? e.Re : e.B;
616
- let c = e.u;
617
- let l = tracking;
618
- let a = currentOptimisticLane;
619
- tracking = true;
493
+ function mergeLanes(e, t) {
494
+ e = findLane(e);
495
+ t = findLane(t);
496
+ if (e === t) return e;
497
+ t.U = e;
498
+ for (const n of t.W) e.W.add(n);
499
+ e.F[0].push(...t.F[0]);
500
+ e.F[1].push(...t.F[1]);
501
+ return e;
502
+ }
503
+ function resolveLane(e) {
504
+ const t = e.re;
505
+ if (!t) return undefined;
506
+ const n = findLane(t);
507
+ if (activeLanes.has(n)) return n;
508
+ e.re = undefined;
509
+ return undefined;
510
+ }
511
+ function hasActiveOverride(e) {
512
+ return !!(e.Oe && e.le !== NOT_PENDING);
513
+ }
514
+ function assignOrMergeLane(e, t) {
515
+ const n = findLane(t);
516
+ const i = e.re;
620
517
  if (i) {
621
- const t = resolveLane(e);
622
- if (t) setCurrentOptimisticLane(t);
623
- }
624
- try {
625
- u = handleAsync(e, e.U(u));
626
- clearStatus(e);
627
- const t = resolveLane(e);
628
- if (t) {
629
- t.G.delete(e);
630
- updatePendingSignal(t.t);
631
- }
632
- } catch (t) {
633
- if (t instanceof NotReadyError && currentOptimisticLane) {
634
- const t = findLane(currentOptimisticLane);
635
- if (t.t !== e) {
636
- t.G.add(e);
637
- e.W = t;
638
- updatePendingSignal(t.t);
639
- }
640
- }
641
- notifyStatus(
642
- e,
643
- t instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR,
644
- t,
645
- undefined,
646
- t instanceof NotReadyError ? e.W : undefined
647
- );
648
- } finally {
649
- tracking = l;
650
- e._ = REACTIVE_NONE;
651
- context = s;
652
- }
653
- if (!e.se) {
654
- const s = e.he;
655
- let l = s !== null ? s.m : e.D;
656
- if (l !== null) {
657
- do {
658
- l = unlinkSubs(l);
659
- } while (l !== null);
660
- if (s !== null) s.m = null;
661
- else e.D = null;
518
+ if (i.U) {
519
+ e.re = t;
520
+ return;
662
521
  }
663
- const a = r ? e.Re : e.B === NOT_PENDING ? e.Re : e.B;
664
- const f = !e.Ae || !e.Ae(a, u);
665
- if (f) {
666
- const s = r ? e.Re : undefined;
667
- if (t || (n && activeTransition !== e.$) || i) e.Re = u;
668
- else e.B = u;
669
- if (r && !i && o) {
670
- const t = e.K || 0;
671
- const n = e.j || 0;
672
- if (t <= n) e.Re = u;
673
- }
674
- if (!r || i || e.Re !== s) {
675
- insertSubs(e, i || r);
676
- }
677
- } else if (r) {
678
- e.B = u;
679
- } else if (e.u != c) {
680
- for (let t = e.p; t !== null; t = t.h) {
681
- insertIntoHeapHeight(t.A, t.A._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
522
+ const r = findLane(i);
523
+ if (activeLanes.has(r)) {
524
+ if (r !== n && !hasActiveOverride(e)) {
525
+ if (n.Te && findLane(n.Te) === r) {
526
+ e.re = t;
527
+ } else if (r.Te && findLane(r.Te) === n);
528
+ else mergeLanes(n, r);
682
529
  }
530
+ return;
683
531
  }
684
532
  }
685
- setCurrentOptimisticLane(a);
686
- (!t || e.Oe & STATUS_PENDING) && !e.$ && !(activeTransition && e.Y) && globalQueue.J.push(e);
687
- e.$ && n && activeTransition !== e.$ && runInTransition(e.$, () => recompute(e));
533
+ e.re = t;
688
534
  }
689
535
  function handleAsync(e, t, n) {
690
536
  const i = typeof t === "object" && t !== null;
691
537
  const r = i && untrack(() => t[Symbol.asyncIterator]);
692
538
  const o = !r && i && untrack(() => typeof t.then === "function");
693
539
  if (!o && !r) {
694
- e.ge = null;
540
+ e.Se = null;
695
541
  return t;
696
542
  }
697
- e.ge = t;
543
+ e.Se = t;
698
544
  let s;
699
545
  const handleError = n => {
700
- if (e.ge !== t) return;
701
- globalQueue.initTransition(e.$);
546
+ if (e.Se !== t) return;
547
+ globalQueue.initTransition(e.ie);
702
548
  notifyStatus(e, n instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR, n);
703
- e.ce = clock;
549
+ e.ee = clock;
704
550
  };
705
551
  const asyncWrite = (i, r) => {
706
- if (e.ge !== t) return;
552
+ if (e.Se !== t) return;
707
553
  if (e._ & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY)) return;
708
- globalQueue.initTransition(e.$);
554
+ globalQueue.initTransition(e.ie);
709
555
  clearStatus(e);
710
556
  const o = resolveLane(e);
711
- if (o) o.G.delete(e);
557
+ if (o) o.W.delete(e);
712
558
  if (n) n(i);
713
- else if (e.Y) {
714
- const t = e.B !== NOT_PENDING;
715
- if (e.U) e.B = i;
559
+ else if (e.Oe) {
560
+ const t = e.le !== NOT_PENDING;
561
+ if (e.k) e.le = i;
716
562
  if (!t) {
717
- e.Re = i;
563
+ e.ae = i;
718
564
  insertSubs(e);
719
565
  }
720
- e.ce = clock;
566
+ e.ee = clock;
721
567
  } else if (o) {
722
- const t = e.Re;
723
- const n = e.Ae;
568
+ const t = e.ae;
569
+ const n = e._e;
724
570
  if (!n || !n(i, t)) {
725
- e.Re = i;
726
- e.ce = clock;
727
- if (e.Ne) {
728
- setSignal(e.Ne, i);
571
+ e.ae = i;
572
+ e.ee = clock;
573
+ if (e.Ie) {
574
+ setSignal(e.Ie, i);
729
575
  }
730
576
  insertSubs(e, true);
731
577
  }
@@ -752,7 +598,7 @@ function handleAsync(e, t, n) {
752
598
  );
753
599
  i = false;
754
600
  if (!n) {
755
- globalQueue.initTransition(e.$);
601
+ globalQueue.initTransition(e.ie);
756
602
  throw new NotReadyError(context);
757
603
  }
758
604
  }
@@ -784,27 +630,27 @@ function handleAsync(e, t, n) {
784
630
  };
785
631
  const r = iterate();
786
632
  if (!i && !r) {
787
- globalQueue.initTransition(e.$);
633
+ globalQueue.initTransition(e.ie);
788
634
  throw new NotReadyError(context);
789
635
  }
790
636
  }
791
637
  return s;
792
638
  }
793
639
  function clearStatus(e) {
794
- e.Oe = e.Oe & STATUS_UNINITIALIZED;
795
- e.se = null;
640
+ e.fe = e.fe & STATUS_UNINITIALIZED;
641
+ e.Z = null;
796
642
  updatePendingSignal(e);
797
- e.Pe?.();
643
+ e.pe?.();
798
644
  }
799
645
  function notifyStatus(e, t, n, i, r) {
800
646
  if (t === STATUS_ERROR && !(n instanceof StatusError) && !(n instanceof NotReadyError))
801
647
  n = new StatusError(e, n);
802
648
  const o = n instanceof NotReadyError && n.t === e;
803
- const s = t === STATUS_PENDING && e.Y && !o;
649
+ const s = t === STATUS_PENDING && e.Oe && !o;
804
650
  const u = s && hasActiveOverride(e);
805
651
  if (!i) {
806
- e.Oe = t | (t !== STATUS_ERROR ? e.Oe & STATUS_UNINITIALIZED : 0);
807
- e.se = n;
652
+ e.fe = t | (t !== STATUS_ERROR ? e.fe & STATUS_UNINITIALIZED : 0);
653
+ e.Z = n;
808
654
  updatePendingSignal(e);
809
655
  }
810
656
  if (r && !i) {
@@ -812,68 +658,249 @@ function notifyStatus(e, t, n, i, r) {
812
658
  }
813
659
  if (u && activeTransition && n instanceof NotReadyError) {
814
660
  const e = n.t;
815
- if (!activeTransition.ue.includes(e)) {
816
- activeTransition.ue.push(e);
661
+ if (!activeTransition.J.includes(e)) {
662
+ activeTransition.J.push(e);
817
663
  }
818
664
  }
819
665
  const c = i || u;
820
666
  const l = i || s ? undefined : r;
821
- if (e.Pe) {
667
+ if (e.pe) {
822
668
  if (c) {
823
- e.Pe(t, n);
669
+ e.pe(t, n);
824
670
  } else {
825
- e.Pe();
671
+ e.pe();
826
672
  }
827
673
  return;
828
674
  }
829
675
  for (let i = e.p; i !== null; i = i.h) {
830
- i.A.ce = clock;
831
- if (i.A.se !== n) {
832
- !i.A.$ && globalQueue.J.push(i.A);
676
+ i.A.ee = clock;
677
+ if (i.A.Z !== n) {
678
+ !i.A.ie && globalQueue.H.push(i.A);
833
679
  notifyStatus(i.A, t, n, c, l);
834
680
  }
835
681
  }
836
- for (let i = e.N; i !== null; i = i.P) {
682
+ for (let i = e.P; i !== null; i = i.C) {
837
683
  for (let e = i.p; e !== null; e = e.h) {
838
- e.A.ce = clock;
839
- if (e.A.se !== n) {
840
- !e.A.$ && globalQueue.J.push(e.A);
684
+ e.A.ee = clock;
685
+ if (e.A.Z !== n) {
686
+ !e.A.ie && globalQueue.H.push(e.A);
841
687
  notifyStatus(e.A, t, n, c, l);
842
688
  }
843
689
  }
844
690
  }
845
691
  }
846
- function updateIfNecessary(e) {
847
- if (e._ & REACTIVE_CHECK) {
848
- for (let t = e.D; t; t = t.m) {
849
- const n = t.V;
850
- const i = n.L || n;
851
- if (i.U) {
852
- updateIfNecessary(i);
692
+ function effect(e, t, n, i, r) {
693
+ let o = false;
694
+ const s = computed(r?.render ? t => staleValues(() => e(t)) : e, i, {
695
+ ...r,
696
+ equals: () => {
697
+ s.se = !s.Z;
698
+ if (o) s.ue.enqueue(s.oe, runEffect.bind(s));
699
+ return false;
700
+ },
701
+ lazy: true
702
+ });
703
+ s.he = i;
704
+ s.Ae = t;
705
+ s.ge = n;
706
+ s.Pe = undefined;
707
+ s.oe = r?.render ? EFFECT_RENDER : EFFECT_USER;
708
+ s.pe = (e, t) => {
709
+ const n = e !== undefined ? e : s.fe;
710
+ const i = t !== undefined ? t : s.Z;
711
+ if (n & STATUS_ERROR) {
712
+ let e = i;
713
+ s.ue.notify(s, STATUS_PENDING, 0);
714
+ if (s.oe === EFFECT_USER) {
715
+ try {
716
+ return s.ge
717
+ ? s.ge(e, () => {
718
+ s.Pe?.();
719
+ s.Pe = undefined;
720
+ })
721
+ : console.error(e);
722
+ } catch (t) {
723
+ e = t;
724
+ }
853
725
  }
854
- if (e._ & REACTIVE_DIRTY) {
855
- break;
726
+ if (!s.ue.notify(s, STATUS_ERROR, STATUS_ERROR)) throw e;
727
+ } else if (s.oe === EFFECT_RENDER) s.ue.notify(s, STATUS_PENDING | STATUS_ERROR, n, i);
728
+ };
729
+ recompute(s, true);
730
+ !r?.defer && (s.oe === EFFECT_USER ? s.ue.enqueue(s.oe, runEffect.bind(s)) : runEffect.call(s));
731
+ o = true;
732
+ onCleanup(() => s.Pe?.());
733
+ }
734
+ function runEffect() {
735
+ if (!this.se || this._ & REACTIVE_DISPOSED) return;
736
+ this.Pe?.();
737
+ this.Pe = undefined;
738
+ try {
739
+ this.Pe = this.Ae(this.ae, this.he);
740
+ } catch (e) {
741
+ if (!this.ue.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
742
+ } finally {
743
+ this.he = this.ae;
744
+ this.se = false;
745
+ }
746
+ }
747
+ function trackedEffect(e, t) {
748
+ const run = () => {
749
+ if (!n.se || n._ & REACTIVE_DISPOSED) return;
750
+ n.se = false;
751
+ recompute(n);
752
+ };
753
+ const n = computed(
754
+ () => {
755
+ try {
756
+ n.Pe?.();
757
+ n.Pe = undefined;
758
+ n.Pe = staleValues(e) || undefined;
759
+ } finally {
856
760
  }
761
+ },
762
+ undefined,
763
+ { ...t, lazy: true, pureWrite: true }
764
+ );
765
+ n.Pe = undefined;
766
+ n.se = true;
767
+ n.oe = EFFECT_TRACKED;
768
+ n.ce = run;
769
+ n.ue.enqueue(EFFECT_USER, run);
770
+ onCleanup(() => n.Pe?.());
771
+ }
772
+ const PENDING_OWNER = {};
773
+ function markDisposal(e) {
774
+ let t = e.Ce;
775
+ while (t) {
776
+ t._ |= REACTIVE_ZOMBIE;
777
+ if (t._ & REACTIVE_IN_HEAP) {
778
+ deleteFromHeap(t, dirtyQueue);
779
+ insertIntoHeap(t, zombieQueue);
857
780
  }
781
+ markDisposal(t);
782
+ t = t.Ne;
858
783
  }
859
- if (e._ & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || (e.se && e.ce < clock)) {
860
- recompute(e);
784
+ }
785
+ function dispose(e) {
786
+ let t = e.D || null;
787
+ do {
788
+ t = unlinkSubs(t);
789
+ } while (t !== null);
790
+ e.D = null;
791
+ e.ye = null;
792
+ disposeChildren(e, true);
793
+ }
794
+ function disposeChildren(e, t = false, n) {
795
+ if (e._ & REACTIVE_DISPOSED) return;
796
+ if (t) e._ = REACTIVE_DISPOSED;
797
+ let i = n ? e.De : e.Ce;
798
+ while (i) {
799
+ const e = i.Ne;
800
+ if (i.D) {
801
+ const e = i;
802
+ deleteFromHeap(e, e._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
803
+ let t = e.D;
804
+ do {
805
+ t = unlinkSubs(t);
806
+ } while (t !== null);
807
+ e.D = null;
808
+ e.ye = null;
809
+ }
810
+ disposeChildren(i, true);
811
+ i = e;
861
812
  }
862
- e._ = REACTIVE_NONE;
813
+ if (n) {
814
+ e.De = null;
815
+ } else {
816
+ e.Ce = null;
817
+ e.Ne = null;
818
+ }
819
+ runDisposal(e, n);
820
+ }
821
+ function runDisposal(e, t) {
822
+ let n = t ? e.ve : e.we;
823
+ if (!n) return;
824
+ if (Array.isArray(n)) {
825
+ for (let e = 0; e < n.length; e++) {
826
+ const t = n[e];
827
+ t.call(t);
828
+ }
829
+ } else {
830
+ n.call(n);
831
+ }
832
+ t ? (e.ve = null) : (e.we = null);
833
+ }
834
+ function getNextChildId(e) {
835
+ if (e.id != null) return formatId(e.id, e.be++);
836
+ throw new Error("Cannot get child id from owner without an id");
837
+ }
838
+ function formatId(e, t) {
839
+ const n = t.toString(36),
840
+ i = n.length - 1;
841
+ return e + (i ? String.fromCharCode(64 + i) : "") + n;
842
+ }
843
+ function getObserver() {
844
+ if (pendingCheckActive || pendingReadActive) return PENDING_OWNER;
845
+ return tracking ? context : null;
846
+ }
847
+ function getOwner() {
848
+ return context;
849
+ }
850
+ function onCleanup(e) {
851
+ if (!context) return e;
852
+ if (!context.we) context.we = e;
853
+ else if (Array.isArray(context.we)) context.we.push(e);
854
+ else context.we = [context.we, e];
855
+ return e;
856
+ }
857
+ function createOwner(e) {
858
+ const t = context;
859
+ const n = {
860
+ id: e?.id ?? (t?.id != null ? getNextChildId(t) : undefined),
861
+ i: true,
862
+ l: t?.i ? t.l : t,
863
+ Ce: null,
864
+ Ne: null,
865
+ we: null,
866
+ ue: t?.ue ?? globalQueue,
867
+ Ve: t?.Ve || defaultContext,
868
+ be: 0,
869
+ ve: null,
870
+ De: null,
871
+ o: t,
872
+ dispose(e = true) {
873
+ disposeChildren(n, e);
874
+ }
875
+ };
876
+ if (t) {
877
+ const e = t.Ce;
878
+ if (e === null) {
879
+ t.Ce = n;
880
+ } else {
881
+ n.Ne = e;
882
+ t.Ce = n;
883
+ }
884
+ }
885
+ return n;
886
+ }
887
+ function createRoot(e, t) {
888
+ const n = createOwner(t);
889
+ return runWithOwner(n, () => e(n.dispose));
863
890
  }
864
891
  function unlinkSubs(e) {
865
- const t = e.V;
866
- const n = e.m;
892
+ const t = e.m;
893
+ const n = e.V;
867
894
  const i = e.h;
868
- const r = e.Ce;
869
- if (i !== null) i.Ce = r;
870
- else t.ye = r;
895
+ const r = e.me;
896
+ if (i !== null) i.me = r;
897
+ else t.Le = r;
871
898
  if (r !== null) r.h = i;
872
899
  else {
873
900
  t.p = i;
874
901
  if (i === null) {
875
- t.De?.();
876
- t.U && !t.ve && unobserved(t);
902
+ t.ke?.();
903
+ t.k && !t.Ue && unobserved(t);
877
904
  }
878
905
  }
879
906
  return n;
@@ -888,148 +915,203 @@ function unobserved(e) {
888
915
  disposeChildren(e, true);
889
916
  }
890
917
  function link(e, t) {
891
- const n = t.he;
892
- if (n !== null && n.V === e) return;
918
+ const n = t.ye;
919
+ if (n !== null && n.m === e) return;
893
920
  let i = null;
894
921
  const r = t._ & REACTIVE_RECOMPUTING_DEPS;
895
922
  if (r) {
896
- i = n !== null ? n.m : t.D;
897
- if (i !== null && i.V === e) {
898
- t.he = i;
923
+ i = n !== null ? n.V : t.D;
924
+ if (i !== null && i.m === e) {
925
+ t.ye = i;
899
926
  return;
900
927
  }
901
928
  }
902
- const o = e.ye;
929
+ const o = e.Le;
903
930
  if (o !== null && o.A === t && (!r || isValidLink(o, t))) return;
904
- const s = (t.he = e.ye = { V: e, A: t, m: i, Ce: o, h: null });
905
- if (n !== null) n.m = s;
931
+ const s = (t.ye = e.Le = { m: e, A: t, V: i, me: o, h: null });
932
+ if (n !== null) n.V = s;
906
933
  else t.D = s;
907
934
  if (o !== null) o.h = s;
908
935
  else e.p = s;
909
936
  }
910
937
  function isValidLink(e, t) {
911
- const n = t.he;
938
+ const n = t.ye;
912
939
  if (n !== null) {
913
940
  let i = t.D;
914
941
  do {
915
942
  if (i === e) return true;
916
943
  if (i === n) break;
917
- i = i.m;
944
+ i = i.V;
918
945
  } while (i !== null);
919
946
  }
920
947
  return false;
921
948
  }
922
- function markDisposal(e) {
923
- let t = e.pe;
924
- while (t) {
925
- t._ |= REACTIVE_ZOMBIE;
926
- if (t._ & REACTIVE_IN_HEAP) {
927
- deleteFromHeap(t, dirtyQueue);
928
- insertIntoHeap(t, zombieQueue);
949
+ GlobalQueue.Y = recompute;
950
+ GlobalQueue.B = disposeChildren;
951
+ let tracking = false;
952
+ let stale = false;
953
+ let refreshing = false;
954
+ let pendingCheckActive = false;
955
+ let foundPending = false;
956
+ let pendingReadActive = false;
957
+ let context = null;
958
+ let currentOptimisticLane = null;
959
+ function recompute(e, t = false) {
960
+ const n = e.oe;
961
+ if (!t) {
962
+ if (e.ie && (!n || activeTransition) && activeTransition !== e.ie)
963
+ globalQueue.initTransition(e.ie);
964
+ deleteFromHeap(e, e._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
965
+ if (e.ie || n === EFFECT_TRACKED) disposeChildren(e);
966
+ else {
967
+ markDisposal(e);
968
+ e.ve = e.we;
969
+ e.De = e.Ce;
970
+ e.we = null;
971
+ e.Ce = null;
929
972
  }
930
- markDisposal(t);
931
- t = t.we;
932
973
  }
933
- }
934
- function dispose(e) {
935
- let t = e.D || null;
936
- do {
937
- t = unlinkSubs(t);
938
- } while (t !== null);
939
- e.D = null;
940
- e.he = null;
941
- disposeChildren(e, true);
942
- }
943
- function disposeChildren(e, t = false, n) {
944
- if (e._ & REACTIVE_DISPOSED) return;
945
- if (t) e._ = REACTIVE_DISPOSED;
946
- let i = n ? e.Ie : e.pe;
947
- while (i) {
948
- const e = i.we;
949
- if (i.D) {
950
- const e = i;
951
- deleteFromHeap(e, e._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
952
- let t = e.D;
974
+ const i = !!(e._ & REACTIVE_OPTIMISTIC_DIRTY);
975
+ const r = hasActiveOverride(e);
976
+ const o = !!(e.fe & STATUS_PENDING);
977
+ const s = context;
978
+ context = e;
979
+ e.ye = null;
980
+ e._ = REACTIVE_RECOMPUTING_DEPS;
981
+ e.ee = clock;
982
+ let u = e.le === NOT_PENDING ? e.ae : e.le;
983
+ let c = e.u;
984
+ let l = tracking;
985
+ let a = currentOptimisticLane;
986
+ tracking = true;
987
+ if (i) {
988
+ const t = resolveLane(e);
989
+ if (t) currentOptimisticLane = t;
990
+ }
991
+ try {
992
+ u = handleAsync(e, e.k(u));
993
+ clearStatus(e);
994
+ const t = resolveLane(e);
995
+ if (t) {
996
+ t.W.delete(e);
997
+ updatePendingSignal(t.t);
998
+ }
999
+ } catch (t) {
1000
+ if (t instanceof NotReadyError && currentOptimisticLane) {
1001
+ const t = findLane(currentOptimisticLane);
1002
+ if (t.t !== e) {
1003
+ t.W.add(e);
1004
+ e.re = t;
1005
+ updatePendingSignal(t.t);
1006
+ }
1007
+ }
1008
+ notifyStatus(
1009
+ e,
1010
+ t instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR,
1011
+ t,
1012
+ undefined,
1013
+ t instanceof NotReadyError ? e.re : undefined
1014
+ );
1015
+ } finally {
1016
+ tracking = l;
1017
+ e._ = REACTIVE_NONE;
1018
+ context = s;
1019
+ }
1020
+ if (!e.Z) {
1021
+ const s = e.ye;
1022
+ let l = s !== null ? s.V : e.D;
1023
+ if (l !== null) {
953
1024
  do {
954
- t = unlinkSubs(t);
955
- } while (t !== null);
956
- e.D = null;
957
- e.he = null;
1025
+ l = unlinkSubs(l);
1026
+ } while (l !== null);
1027
+ if (s !== null) s.V = null;
1028
+ else e.D = null;
1029
+ }
1030
+ const a = r ? e.ae : e.le === NOT_PENDING ? e.ae : e.le;
1031
+ const f = !e._e || !e._e(a, u);
1032
+ if (f) {
1033
+ const s = r ? e.ae : undefined;
1034
+ if (t || (n && activeTransition !== e.ie) || i) e.ae = u;
1035
+ else e.le = u;
1036
+ if (r && !i && o) {
1037
+ const t = e.Re || 0;
1038
+ const n = e.de || 0;
1039
+ if (t <= n) e.ae = u;
1040
+ }
1041
+ if (!r || i || e.ae !== s) {
1042
+ insertSubs(e, i || r);
1043
+ }
1044
+ } else if (r) {
1045
+ e.le = u;
1046
+ } else if (e.u != c) {
1047
+ for (let t = e.p; t !== null; t = t.h) {
1048
+ insertIntoHeapHeight(t.A, t.A._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
1049
+ }
958
1050
  }
959
- disposeChildren(i, true);
960
- i = e;
961
- }
962
- if (n) {
963
- e.Ie = null;
964
- } else {
965
- e.pe = null;
966
- e.we = null;
967
1051
  }
968
- runDisposal(e, n);
1052
+ currentOptimisticLane = a;
1053
+ (!t || e.fe & STATUS_PENDING) && !e.ie && !(activeTransition && e.Oe) && globalQueue.H.push(e);
1054
+ e.ie && n && activeTransition !== e.ie && runInTransition(e.ie, () => recompute(e));
969
1055
  }
970
- function runDisposal(e, t) {
971
- let n = t ? e.Se : e._e;
972
- if (!n) return;
973
- if (Array.isArray(n)) {
974
- for (let e = 0; e < n.length; e++) {
975
- const t = n[e];
976
- t.call(t);
1056
+ function updateIfNecessary(e) {
1057
+ if (e._ & REACTIVE_CHECK) {
1058
+ for (let t = e.D; t; t = t.V) {
1059
+ const n = t.m;
1060
+ const i = n.L || n;
1061
+ if (i.k) {
1062
+ updateIfNecessary(i);
1063
+ }
1064
+ if (e._ & REACTIVE_DIRTY) {
1065
+ break;
1066
+ }
977
1067
  }
978
- } else {
979
- n.call(n);
980
1068
  }
981
- t ? (e.Se = null) : (e._e = null);
982
- }
983
- function getNextChildId(e) {
984
- if (e.id != null) return formatId(e.id, e.be++);
985
- throw new Error("Cannot get child id from owner without an id");
986
- }
987
- function formatId(e, t) {
988
- const n = t.toString(36),
989
- i = n.length - 1;
990
- return e + (i ? String.fromCharCode(64 + i) : "") + n;
1069
+ if (e._ & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY) || (e.Z && e.ee < clock)) {
1070
+ recompute(e);
1071
+ }
1072
+ e._ = REACTIVE_NONE;
991
1073
  }
992
1074
  function computed(e, t, n) {
993
1075
  const i = {
994
1076
  id: n?.id ?? (context?.id != null ? getNextChildId(context) : undefined),
995
- Ae: n?.equals != null ? n.equals : isEqual,
996
- me: !!n?.pureWrite,
997
- De: n?.unobserved,
998
- _e: null,
999
- Te: context?.Te ?? globalQueue,
1077
+ _e: n?.equals != null ? n.equals : isEqual,
1078
+ We: !!n?.pureWrite,
1079
+ ke: n?.unobserved,
1080
+ we: null,
1081
+ ue: context?.ue ?? globalQueue,
1000
1082
  Ve: context?.Ve ?? defaultContext,
1001
1083
  be: 0,
1002
- U: e,
1003
- Re: t,
1084
+ k: e,
1085
+ ae: t,
1004
1086
  u: 0,
1005
- N: null,
1087
+ P: null,
1006
1088
  O: undefined,
1007
1089
  R: null,
1008
1090
  D: null,
1009
- he: null,
1010
- p: null,
1011
1091
  ye: null,
1092
+ p: null,
1093
+ Le: null,
1012
1094
  o: context,
1013
- we: null,
1014
- pe: null,
1095
+ Ne: null,
1096
+ Ce: null,
1015
1097
  _: REACTIVE_NONE,
1016
- Oe: STATUS_UNINITIALIZED,
1017
- ce: clock,
1018
- B: NOT_PENDING,
1098
+ fe: STATUS_UNINITIALIZED,
1099
+ ee: clock,
1100
+ le: NOT_PENDING,
1101
+ ve: null,
1102
+ De: null,
1019
1103
  Se: null,
1020
- Ie: null,
1021
- ge: null,
1022
- $: null
1104
+ ie: null
1023
1105
  };
1024
1106
  i.R = i;
1025
1107
  const r = context?.i ? context.l : context;
1026
1108
  if (context) {
1027
- const e = context.pe;
1109
+ const e = context.Ce;
1028
1110
  if (e === null) {
1029
- context.pe = i;
1111
+ context.Ce = i;
1030
1112
  } else {
1031
- i.we = e;
1032
- context.pe = i;
1113
+ i.Ne = e;
1114
+ context.Ce = i;
1033
1115
  }
1034
1116
  }
1035
1117
  if (r) i.u = r.u + 1;
@@ -1038,87 +1120,30 @@ function computed(e, t, n) {
1038
1120
  }
1039
1121
  function signal(e, t, n = null) {
1040
1122
  const i = {
1041
- Ae: t?.equals != null ? t.equals : isEqual,
1042
- me: !!t?.pureWrite,
1043
- De: t?.unobserved,
1044
- Re: e,
1123
+ _e: t?.equals != null ? t.equals : isEqual,
1124
+ We: !!t?.pureWrite,
1125
+ ke: t?.unobserved,
1126
+ ae: e,
1045
1127
  p: null,
1046
- ye: null,
1047
- ce: clock,
1128
+ Le: null,
1129
+ ee: clock,
1048
1130
  L: n,
1049
- P: n?.N || null,
1050
- B: NOT_PENDING
1131
+ C: n?.P || null,
1132
+ le: NOT_PENDING
1051
1133
  };
1052
- n && (n.N = i);
1134
+ n && (n.P = i);
1053
1135
  return i;
1054
1136
  }
1055
1137
  function optimisticSignal(e, t) {
1056
1138
  const n = signal(e, t);
1057
- n.Y = true;
1139
+ n.Oe = true;
1058
1140
  return n;
1059
1141
  }
1060
1142
  function optimisticComputed(e, t, n) {
1061
1143
  const i = computed(e, t, n);
1062
- i.Y = true;
1144
+ i.Oe = true;
1063
1145
  return i;
1064
1146
  }
1065
- function getPendingSignal(e) {
1066
- if (!e.Le) {
1067
- e.Le = optimisticSignal(false, { pureWrite: true });
1068
- if (e.k) {
1069
- e.Le.k = e;
1070
- }
1071
- if (computePendingState(e)) setSignal(e.Le, true);
1072
- }
1073
- return e.Le;
1074
- }
1075
- function computePendingState(e) {
1076
- const t = e;
1077
- if (e.Y && e.B !== NOT_PENDING) {
1078
- if (t.Oe & STATUS_PENDING && !(t.Oe & STATUS_UNINITIALIZED)) return true;
1079
- if (e.k) {
1080
- const t = e.W ? findLane(e.W) : null;
1081
- return !!(t && t.G.size > 0);
1082
- }
1083
- return true;
1084
- }
1085
- if (e.B !== NOT_PENDING && !(t.Oe & STATUS_UNINITIALIZED)) return true;
1086
- return !!(t.Oe & STATUS_PENDING && !(t.Oe & STATUS_UNINITIALIZED));
1087
- }
1088
- function getPendingValueComputed(e) {
1089
- if (!e.Ne) {
1090
- const t = pendingReadActive;
1091
- pendingReadActive = false;
1092
- const n = pendingCheckActive;
1093
- pendingCheckActive = false;
1094
- const i = context;
1095
- context = null;
1096
- e.Ne = optimisticComputed(() => read(e));
1097
- e.Ne.k = e;
1098
- context = i;
1099
- pendingCheckActive = n;
1100
- pendingReadActive = t;
1101
- }
1102
- return e.Ne;
1103
- }
1104
- function updatePendingSignal(e) {
1105
- if (e.Le) {
1106
- const t = computePendingState(e);
1107
- const n = e.Le;
1108
- setSignal(n, t);
1109
- if (!t && n.W) {
1110
- const t = resolveLane(e);
1111
- if (t && t.G.size > 0) {
1112
- const e = findLane(n.W);
1113
- if (e !== t) {
1114
- mergeLanes(t, e);
1115
- }
1116
- }
1117
- clearLaneEntry(n);
1118
- n.W = undefined;
1119
- }
1120
- }
1121
- }
1122
1147
  function isEqual(e, t) {
1123
1148
  return e === t;
1124
1149
  }
@@ -1138,12 +1163,12 @@ function read(e) {
1138
1163
  pendingReadActive = false;
1139
1164
  const i = read(t);
1140
1165
  pendingReadActive = n;
1141
- if (t.Oe & STATUS_PENDING) return e.Re;
1142
- if (stale && currentOptimisticLane && t.W) {
1143
- const n = findLane(t.W);
1166
+ if (t.fe & STATUS_PENDING) return e.ae;
1167
+ if (stale && currentOptimisticLane && t.re) {
1168
+ const n = findLane(t.re);
1144
1169
  const i = findLane(currentOptimisticLane);
1145
- if (n !== i && n.G.size > 0) {
1146
- return e.Re;
1170
+ if (n !== i && n.W.size > 0) {
1171
+ return e.ae;
1147
1172
  }
1148
1173
  }
1149
1174
  return i;
@@ -1157,18 +1182,18 @@ function read(e) {
1157
1182
  foundPending = true;
1158
1183
  }
1159
1184
  pendingCheckActive = i;
1160
- return e.Re;
1185
+ return e.ae;
1161
1186
  }
1162
1187
  let t = context;
1163
1188
  if (t?.i) t = t.l;
1164
- if (refreshing && e.U) recompute(e);
1189
+ if (refreshing && e.k) recompute(e);
1165
1190
  if (t && tracking) {
1166
- if (e.U && e._ & REACTIVE_DISPOSED) recompute(e);
1191
+ if (e.k && e._ & REACTIVE_DISPOSED) recompute(e);
1167
1192
  link(e, t);
1168
1193
  const n = e.L || e;
1169
- if (n.U) {
1194
+ if (n.k) {
1170
1195
  const i = e._ & REACTIVE_ZOMBIE;
1171
- if (n.u >= (i ? zombieQueue.C : dirtyQueue.C)) {
1196
+ if (n.u >= (i ? zombieQueue.N : dirtyQueue.N)) {
1172
1197
  markNode(t);
1173
1198
  markHeap(i ? zombieQueue : dirtyQueue);
1174
1199
  updateIfNecessary(n);
@@ -1180,122 +1205,73 @@ function read(e) {
1180
1205
  }
1181
1206
  }
1182
1207
  const n = e.L || e;
1183
- if (t && n.Oe & STATUS_PENDING && !(stale && n.$ && activeTransition !== n.$)) {
1208
+ if (t && n.fe & STATUS_PENDING && !(stale && n.ie && activeTransition !== n.ie)) {
1184
1209
  if (currentOptimisticLane) {
1185
- const i = n.W;
1210
+ const i = n.re;
1186
1211
  const r = findLane(currentOptimisticLane);
1187
1212
  if (i && findLane(i) === r && !hasActiveOverride(n)) {
1188
1213
  if (!tracking) link(e, t);
1189
- throw n.se;
1214
+ throw n.Z;
1190
1215
  }
1191
1216
  } else {
1192
1217
  if (!tracking) link(e, t);
1193
- throw n.se;
1218
+ throw n.Z;
1194
1219
  }
1195
1220
  }
1196
- if (e.U && e.Oe & STATUS_ERROR) {
1197
- if (e.ce < clock) {
1221
+ if (e.k && e.fe & STATUS_ERROR) {
1222
+ if (e.ee < clock) {
1198
1223
  recompute(e, true);
1199
1224
  return read(e);
1200
- } else throw e.se;
1225
+ } else throw e.Z;
1201
1226
  }
1202
1227
  return !t ||
1203
1228
  currentOptimisticLane !== null ||
1204
- e.B === NOT_PENDING ||
1205
- (stale && e.$ && activeTransition !== e.$)
1206
- ? e.Re
1207
- : e.B;
1229
+ e.le === NOT_PENDING ||
1230
+ (stale && e.ie && activeTransition !== e.ie)
1231
+ ? e.ae
1232
+ : e.le;
1208
1233
  }
1209
1234
  function setSignal(e, t) {
1210
- if (e.$ && activeTransition !== e.$) globalQueue.initTransition(e.$);
1211
- const n = e.Y && !projectionWriteActive;
1212
- const i = n ? e.Re : e.B === NOT_PENDING ? e.Re : e.B;
1235
+ if (e.ie && activeTransition !== e.ie) globalQueue.initTransition(e.ie);
1236
+ const n = e.Oe && !projectionWriteActive;
1237
+ const i = n ? e.ae : e.le === NOT_PENDING ? e.ae : e.le;
1213
1238
  if (typeof t === "function") t = t(i);
1214
- const r = !e.Ae || !e.Ae(i, t);
1239
+ const r = !e._e || !e._e(i, t);
1215
1240
  if (!r) {
1216
- if (n && e.B !== NOT_PENDING && e.U) {
1241
+ if (n && e.le !== NOT_PENDING && e.k) {
1217
1242
  insertSubs(e, true);
1218
1243
  schedule();
1219
1244
  }
1220
1245
  return t;
1221
1246
  }
1222
1247
  if (n) {
1223
- const n = globalQueue.ee.includes(e);
1224
- if (e.$ && n) {
1225
- globalQueue.initTransition(e.$);
1248
+ const n = globalQueue.j.includes(e);
1249
+ if (e.ie && n) {
1250
+ globalQueue.initTransition(e.ie);
1226
1251
  }
1227
- if (e.B === NOT_PENDING) {
1228
- e.B = e.Re;
1252
+ if (e.le === NOT_PENDING) {
1253
+ e.le = e.ae;
1229
1254
  }
1230
1255
  if (!n) {
1231
- globalQueue.ee.push(e);
1256
+ globalQueue.j.push(e);
1232
1257
  }
1233
- e.K = (e.K || 0) + 1;
1258
+ e.Re = (e.Re || 0) + 1;
1234
1259
  const i = getOrCreateLane(e);
1235
- e.W = i;
1236
- e.Re = t;
1260
+ e.re = i;
1261
+ e.ae = t;
1237
1262
  } else {
1238
- if (e.B === NOT_PENDING) globalQueue.J.push(e);
1239
- e.B = t;
1263
+ if (e.le === NOT_PENDING) globalQueue.H.push(e);
1264
+ e.le = t;
1240
1265
  }
1241
1266
  updatePendingSignal(e);
1242
- if (e.Ne) {
1243
- setSignal(e.Ne, t);
1267
+ if (e.Ie) {
1268
+ setSignal(e.Ie, t);
1244
1269
  }
1245
- e.ce = clock;
1270
+ e.ee = clock;
1246
1271
  insertSubs(e, n);
1247
1272
  schedule();
1248
1273
  return t;
1249
1274
  }
1250
- const PENDING_OWNER = {};
1251
- function getObserver() {
1252
- if (pendingCheckActive || pendingReadActive) return PENDING_OWNER;
1253
- return tracking ? context : null;
1254
- }
1255
- function getOwner() {
1256
- return context;
1257
- }
1258
- function onCleanup(e) {
1259
- if (!context) return e;
1260
- if (!context._e) context._e = e;
1261
- else if (Array.isArray(context._e)) context._e.push(e);
1262
- else context._e = [context._e, e];
1263
- return e;
1264
- }
1265
- function createOwner(e) {
1266
- const t = context;
1267
- const n = {
1268
- id: e?.id ?? (t?.id != null ? getNextChildId(t) : undefined),
1269
- i: true,
1270
- l: t?.i ? t.l : t,
1271
- pe: null,
1272
- we: null,
1273
- _e: null,
1274
- Te: t?.Te ?? globalQueue,
1275
- Ve: t?.Ve || defaultContext,
1276
- be: 0,
1277
- Se: null,
1278
- Ie: null,
1279
- o: t,
1280
- dispose(e = true) {
1281
- disposeChildren(n, e);
1282
- }
1283
- };
1284
- if (t) {
1285
- const e = t.pe;
1286
- if (e === null) {
1287
- t.pe = n;
1288
- } else {
1289
- n.we = e;
1290
- t.pe = n;
1291
- }
1292
- }
1293
- return n;
1294
- }
1295
- function createRoot(e, t) {
1296
- const n = createOwner(t);
1297
- return runWithOwner(n, () => e(n.dispose));
1298
- }
1299
1275
  function runWithOwner(e, t) {
1300
1276
  const n = context;
1301
1277
  const i = tracking;
@@ -1308,6 +1284,63 @@ function runWithOwner(e, t) {
1308
1284
  tracking = i;
1309
1285
  }
1310
1286
  }
1287
+ function getPendingSignal(e) {
1288
+ if (!e.Qe) {
1289
+ e.Qe = optimisticSignal(false, { pureWrite: true });
1290
+ if (e.Ee) {
1291
+ e.Qe.Ee = e;
1292
+ }
1293
+ if (computePendingState(e)) setSignal(e.Qe, true);
1294
+ }
1295
+ return e.Qe;
1296
+ }
1297
+ function computePendingState(e) {
1298
+ const t = e;
1299
+ if (e.Oe && e.le !== NOT_PENDING) {
1300
+ if (t.fe & STATUS_PENDING && !(t.fe & STATUS_UNINITIALIZED)) return true;
1301
+ if (e.Ee) {
1302
+ const t = e.re ? findLane(e.re) : null;
1303
+ return !!(t && t.W.size > 0);
1304
+ }
1305
+ return true;
1306
+ }
1307
+ if (e.le !== NOT_PENDING && !(t.fe & STATUS_UNINITIALIZED)) return true;
1308
+ return !!(t.fe & STATUS_PENDING && !(t.fe & STATUS_UNINITIALIZED));
1309
+ }
1310
+ function updatePendingSignal(e) {
1311
+ if (e.Qe) {
1312
+ const t = computePendingState(e);
1313
+ const n = e.Qe;
1314
+ setSignal(n, t);
1315
+ if (!t && n.re) {
1316
+ const t = resolveLane(e);
1317
+ if (t && t.W.size > 0) {
1318
+ const e = findLane(n.re);
1319
+ if (e !== t) {
1320
+ mergeLanes(t, e);
1321
+ }
1322
+ }
1323
+ signalLanes.delete(n);
1324
+ n.re = undefined;
1325
+ }
1326
+ }
1327
+ }
1328
+ function getPendingValueComputed(e) {
1329
+ if (!e.Ie) {
1330
+ const t = pendingReadActive;
1331
+ pendingReadActive = false;
1332
+ const n = pendingCheckActive;
1333
+ pendingCheckActive = false;
1334
+ const i = context;
1335
+ context = null;
1336
+ e.Ie = optimisticComputed(() => read(e));
1337
+ e.Ie.Ee = e;
1338
+ context = i;
1339
+ pendingCheckActive = n;
1340
+ pendingReadActive = t;
1341
+ }
1342
+ return e.Ie;
1343
+ }
1311
1344
  function staleValues(e, t = true) {
1312
1345
  const n = stale;
1313
1346
  stale = t;
@@ -1385,85 +1418,49 @@ function hasContext(e, t) {
1385
1418
  function isUndefined(e) {
1386
1419
  return typeof e === "undefined";
1387
1420
  }
1388
- function effect(e, t, n, i, r) {
1389
- let o = false;
1390
- const s = computed(r?.render ? t => staleValues(() => e(t)) : e, i, {
1391
- ...r,
1392
- equals: () => {
1393
- s.Ee = !s.se;
1394
- if (o) s.Te.enqueue(s.fe, runEffect.bind(s));
1395
- return false;
1396
- },
1397
- lazy: true
1398
- });
1399
- s.Ue = i;
1400
- s.ke = t;
1401
- s.We = n;
1402
- s.Qe = undefined;
1403
- s.fe = r?.render ? EFFECT_RENDER : EFFECT_USER;
1404
- s.Pe = (e, t) => {
1405
- const n = e !== undefined ? e : s.Oe;
1406
- const i = t !== undefined ? t : s.se;
1407
- if (n & STATUS_ERROR) {
1408
- let e = i;
1409
- s.Te.notify(s, STATUS_PENDING, 0);
1410
- if (s.fe === EFFECT_USER) {
1421
+ function restoreTransition(e, t) {
1422
+ globalQueue.initTransition(e);
1423
+ const n = t();
1424
+ flush();
1425
+ return n;
1426
+ }
1427
+ function action(e) {
1428
+ return (...t) =>
1429
+ new Promise((n, i) => {
1430
+ const r = e(...t);
1431
+ globalQueue.initTransition();
1432
+ let o = activeTransition;
1433
+ o.te.push(r);
1434
+ const done = (e, t) => {
1435
+ o = currentTransition(o);
1436
+ const s = o.te.indexOf(r);
1437
+ if (s >= 0) o.te.splice(s, 1);
1438
+ setActiveTransition(o);
1439
+ schedule();
1440
+ t ? i(t) : n(e);
1441
+ };
1442
+ const step = (e, t) => {
1443
+ let n;
1411
1444
  try {
1412
- return s.We
1413
- ? s.We(e, () => {
1414
- s.Qe?.();
1415
- s.Qe = undefined;
1416
- })
1417
- : console.error(e);
1418
- } catch (t) {
1419
- e = t;
1445
+ n = t ? r.throw(e) : r.next(e);
1446
+ } catch (e) {
1447
+ return done(undefined, e);
1420
1448
  }
1421
- }
1422
- if (!s.Te.notify(s, STATUS_ERROR, STATUS_ERROR)) throw e;
1423
- } else if (s.fe === EFFECT_RENDER) s.Te.notify(s, STATUS_PENDING | STATUS_ERROR, n, i);
1424
- };
1425
- recompute(s, true);
1426
- !r?.defer && (s.fe === EFFECT_USER ? s.Te.enqueue(s.fe, runEffect.bind(s)) : runEffect.call(s));
1427
- o = true;
1428
- onCleanup(() => s.Qe?.());
1429
- }
1430
- function runEffect() {
1431
- if (!this.Ee || this._ & REACTIVE_DISPOSED) return;
1432
- this.Qe?.();
1433
- this.Qe = undefined;
1434
- try {
1435
- this.Qe = this.ke(this.Re, this.Ue);
1436
- } catch (e) {
1437
- if (!this.Te.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
1438
- } finally {
1439
- this.Ue = this.Re;
1440
- this.Ee = false;
1441
- }
1442
- }
1443
- function trackedEffect(e, t) {
1444
- const run = () => {
1445
- if (!n.Ee || n._ & REACTIVE_DISPOSED) return;
1446
- n.Ee = false;
1447
- recompute(n);
1448
- };
1449
- const n = computed(
1450
- () => {
1451
- try {
1452
- n.Qe?.();
1453
- n.Qe = undefined;
1454
- n.Qe = staleValues(e) || undefined;
1455
- } finally {
1456
- }
1457
- },
1458
- undefined,
1459
- { ...t, lazy: true, pureWrite: true }
1460
- );
1461
- n.Qe = undefined;
1462
- n.Ee = true;
1463
- n.fe = EFFECT_TRACKED;
1464
- n.de = run;
1465
- n.Te.enqueue(EFFECT_USER, run);
1466
- onCleanup(() => n.Qe?.());
1449
+ if (n instanceof Promise)
1450
+ return void n.then(run, e => restoreTransition(o, () => step(e, true)));
1451
+ run(n);
1452
+ };
1453
+ const run = e => {
1454
+ if (e.done) return done(e.value);
1455
+ if (e.value instanceof Promise)
1456
+ return void e.value.then(
1457
+ e => restoreTransition(o, () => step(e)),
1458
+ e => restoreTransition(o, () => step(e, true))
1459
+ );
1460
+ restoreTransition(o, () => step(e.value));
1461
+ };
1462
+ step();
1463
+ });
1467
1464
  }
1468
1465
  function createSignal(e, t, n) {
1469
1466
  if (typeof e === "function") {
@@ -1697,7 +1694,7 @@ function createProjectionInternal(e, t = {}, n) {
1697
1694
  r !== i && r !== undefined && reconcile(r, n?.key || "id", n?.all)(o);
1698
1695
  });
1699
1696
  });
1700
- i.ve = true;
1697
+ i.Ue = true;
1701
1698
  return { store: o, node: i };
1702
1699
  }
1703
1700
  function createProjection(e, t = {}, n) {
@@ -1797,7 +1794,7 @@ function getNode(e, t, n, i, r = isEqual, o) {
1797
1794
  },
1798
1795
  i
1799
1796
  );
1800
- if (o) s.Y = true;
1797
+ if (o) s.Oe = true;
1801
1798
  return (e[t] = s);
1802
1799
  }
1803
1800
  function trackSelf(e, t = $TRACK) {
@@ -1850,7 +1847,7 @@ const storeTraps = {
1850
1847
  if (e && e.get) return e.get.call(n);
1851
1848
  }
1852
1849
  if (writeOnly(n)) {
1853
- let n = r && (s || !u) ? (r.B !== NOT_PENDING ? (r.Y ? r.Re : r.B) : r.Re) : c[t];
1850
+ let n = r && (s || !u) ? (r.le !== NOT_PENDING ? (r.Oe ? r.ae : r.le) : r.ae) : c[t];
1854
1851
  n === $DELETED && (n = undefined);
1855
1852
  if (!isWrappable(n)) return n;
1856
1853
  const i = wrap(n, e);
@@ -1899,8 +1896,8 @@ const storeTraps = {
1899
1896
  if (writeOnly(i)) {
1900
1897
  if (e[STORE_OPTIMISTIC]) {
1901
1898
  const t = e[STORE_FIREWALL];
1902
- if (t?.$) {
1903
- globalQueue.initTransition(t.$);
1899
+ if (t?.ie) {
1900
+ globalQueue.initTransition(t.ie);
1904
1901
  }
1905
1902
  }
1906
1903
  untrack(() => {
@@ -2089,7 +2086,7 @@ function deep(e) {
2089
2086
  return e[$DEEP];
2090
2087
  }
2091
2088
  function createOptimisticStore(e, t, n) {
2092
- GlobalQueue.re ||= clearOptimisticStore;
2089
+ GlobalQueue.X ||= clearOptimisticStore;
2093
2090
  const i = typeof e === "function";
2094
2091
  const r = (i ? t : e) ?? {};
2095
2092
  const o = i ? e : undefined;
@@ -2106,7 +2103,7 @@ function clearOptimisticStore(e) {
2106
2103
  if (i) {
2107
2104
  for (const e of Reflect.ownKeys(n)) {
2108
2105
  if (i[e]) {
2109
- i[e].W = undefined;
2106
+ i[e].re = undefined;
2110
2107
  const n =
2111
2108
  t[STORE_OVERRIDE] && e in t[STORE_OVERRIDE] ? t[STORE_OVERRIDE][e] : t[STORE_VALUE][e];
2112
2109
  const r = n === $DELETED ? undefined : n;
@@ -2114,7 +2111,7 @@ function clearOptimisticStore(e) {
2114
2111
  }
2115
2112
  }
2116
2113
  if (i[$TRACK]) {
2117
- i[$TRACK].W = undefined;
2114
+ i[$TRACK].re = undefined;
2118
2115
  setSignal(i[$TRACK], undefined);
2119
2116
  }
2120
2117
  }
@@ -2165,7 +2162,7 @@ function createOptimisticProjectionInternal(e, t = {}, n) {
2165
2162
  setProjectionWriteActive(false);
2166
2163
  }
2167
2164
  });
2168
- i.ve = true;
2165
+ i.Ue = true;
2169
2166
  }
2170
2167
  return { store: o, node: i };
2171
2168
  }
@@ -2350,9 +2347,9 @@ function mapArray(e, t, n) {
2350
2347
  return createMemo(
2351
2348
  updateKeyedMap.bind({
2352
2349
  xe: createOwner(),
2353
- Ge: 0,
2354
- Me: e,
2355
- Fe: [],
2350
+ Fe: 0,
2351
+ Ge: e,
2352
+ Me: [],
2356
2353
  $e: t,
2357
2354
  He: [],
2358
2355
  je: [],
@@ -2365,7 +2362,7 @@ function mapArray(e, t, n) {
2365
2362
  }
2366
2363
  const pureOptions = { pureWrite: true };
2367
2364
  function updateKeyedMap() {
2368
- const e = this.Me() || [],
2365
+ const e = this.Ge() || [],
2369
2366
  t = e.length;
2370
2367
  e[$TRACK];
2371
2368
  runWithOwner(this.xe, () => {
@@ -2391,26 +2388,26 @@ function updateKeyedMap() {
2391
2388
  return this.$e(() => t);
2392
2389
  };
2393
2390
  if (t === 0) {
2394
- if (this.Ge !== 0) {
2391
+ if (this.Fe !== 0) {
2395
2392
  this.xe.dispose(false);
2396
2393
  this.je = [];
2397
- this.Fe = [];
2394
+ this.Me = [];
2398
2395
  this.He = [];
2399
- this.Ge = 0;
2396
+ this.Fe = 0;
2400
2397
  this.Ye && (this.Ye = []);
2401
2398
  this.Be && (this.Be = []);
2402
2399
  }
2403
2400
  if (this.Xe && !this.He[0]) {
2404
2401
  this.He[0] = runWithOwner((this.je[0] = createOwner()), this.Xe);
2405
2402
  }
2406
- } else if (this.Ge === 0) {
2403
+ } else if (this.Fe === 0) {
2407
2404
  if (this.je[0]) this.je[0].dispose();
2408
2405
  this.He = new Array(t);
2409
2406
  for (i = 0; i < t; i++) {
2410
- this.Fe[i] = e[i];
2407
+ this.Me[i] = e[i];
2411
2408
  this.He[i] = runWithOwner((this.je[i] = createOwner()), r);
2412
2409
  }
2413
- this.Ge = t;
2410
+ this.Fe = t;
2414
2411
  } else {
2415
2412
  let o,
2416
2413
  s,
@@ -2424,17 +2421,17 @@ function updateKeyedMap() {
2424
2421
  d = this.Ye ? new Array(t) : undefined,
2425
2422
  R = this.Be ? new Array(t) : undefined;
2426
2423
  for (
2427
- o = 0, s = Math.min(this.Ge, t);
2428
- o < s && (this.Fe[o] === e[o] || (this.Ye && compare(this.Ke, this.Fe[o], e[o])));
2424
+ o = 0, s = Math.min(this.Fe, t);
2425
+ o < s && (this.Me[o] === e[o] || (this.Ye && compare(this.Ke, this.Me[o], e[o])));
2429
2426
  o++
2430
2427
  ) {
2431
2428
  if (this.Ye) setSignal(this.Ye[o], e[o]);
2432
2429
  }
2433
2430
  for (
2434
- s = this.Ge - 1, u = t - 1;
2431
+ s = this.Fe - 1, u = t - 1;
2435
2432
  s >= o &&
2436
2433
  u >= o &&
2437
- (this.Fe[s] === e[u] || (this.Ye && compare(this.Ke, this.Fe[s], e[u])));
2434
+ (this.Me[s] === e[u] || (this.Ye && compare(this.Ke, this.Me[s], e[u])));
2438
2435
  s--, u--
2439
2436
  ) {
2440
2437
  E[u] = this.He[s];
@@ -2452,7 +2449,7 @@ function updateKeyedMap() {
2452
2449
  a.set(l, i);
2453
2450
  }
2454
2451
  for (n = o; n <= s; n++) {
2455
- c = this.Fe[n];
2452
+ c = this.Me[n];
2456
2453
  l = this.Ke ? this.Ke(c) : c;
2457
2454
  i = a.get(l);
2458
2455
  if (i !== undefined && i !== -1) {
@@ -2480,8 +2477,8 @@ function updateKeyedMap() {
2480
2477
  this.He[i] = runWithOwner((this.je[i] = createOwner()), r);
2481
2478
  }
2482
2479
  }
2483
- this.He = this.He.slice(0, (this.Ge = t));
2484
- this.Fe = e.slice(0);
2480
+ this.He = this.He.slice(0, (this.Fe = t));
2481
+ this.Me = e.slice(0);
2485
2482
  }
2486
2483
  });
2487
2484
  return this.He;
@@ -2489,7 +2486,7 @@ function updateKeyedMap() {
2489
2486
  function repeat(e, t, n) {
2490
2487
  return updateRepeat.bind({
2491
2488
  xe: createOwner(),
2492
- Ge: 0,
2489
+ Fe: 0,
2493
2490
  qe: 0,
2494
2491
  ze: e,
2495
2492
  $e: t,
@@ -2504,11 +2501,11 @@ function updateRepeat() {
2504
2501
  const t = this.Ze?.() || 0;
2505
2502
  runWithOwner(this.xe, () => {
2506
2503
  if (e === 0) {
2507
- if (this.Ge !== 0) {
2504
+ if (this.Fe !== 0) {
2508
2505
  this.xe.dispose(false);
2509
2506
  this.je = [];
2510
2507
  this.He = [];
2511
- this.Ge = 0;
2508
+ this.Fe = 0;
2512
2509
  }
2513
2510
  if (this.Xe && !this.He[0]) {
2514
2511
  this.He[0] = runWithOwner((this.je[0] = createOwner()), this.Xe);
@@ -2516,12 +2513,12 @@ function updateRepeat() {
2516
2513
  return;
2517
2514
  }
2518
2515
  const n = t + e;
2519
- const i = this.qe + this.Ge;
2520
- if (this.Ge === 0 && this.je[0]) this.je[0].dispose();
2516
+ const i = this.qe + this.Fe;
2517
+ if (this.Fe === 0 && this.je[0]) this.je[0].dispose();
2521
2518
  for (let e = n; e < i; e++) this.je[e - this.qe].dispose();
2522
2519
  if (this.qe < t) {
2523
2520
  let e = this.qe;
2524
- while (e < t && e < this.Ge) this.je[e++].dispose();
2521
+ while (e < t && e < this.Fe) this.je[e++].dispose();
2525
2522
  this.je.splice(0, t - this.qe);
2526
2523
  this.He.splice(0, t - this.qe);
2527
2524
  } else if (this.qe > t) {
@@ -2542,7 +2539,7 @@ function updateRepeat() {
2542
2539
  }
2543
2540
  this.He = this.He.slice(0, e);
2544
2541
  this.qe = t;
2545
- this.Ge = e;
2542
+ this.Fe = e;
2546
2543
  });
2547
2544
  return this.He;
2548
2545
  }
@@ -2551,119 +2548,68 @@ function compare(e, t, n) {
2551
2548
  }
2552
2549
  function boundaryComputed(e, t) {
2553
2550
  const n = computed(e, undefined, { lazy: true });
2554
- n.Pe = (e, t) => {
2555
- const i = e !== undefined ? e : n.Oe;
2556
- const r = t !== undefined ? t : n.se;
2557
- n.Oe &= ~n.Je;
2558
- n.Te.notify(n, n.Je, i, r);
2551
+ n.pe = (e, t) => {
2552
+ const i = e !== undefined ? e : n.fe;
2553
+ const r = t !== undefined ? t : n.Z;
2554
+ n.fe &= ~n.Je;
2555
+ n.ue.notify(n, n.Je, i, r);
2559
2556
  };
2560
2557
  n.Je = t;
2561
- n.ve = true;
2558
+ n.Ue = true;
2562
2559
  recompute(n, true);
2563
2560
  return n;
2564
2561
  }
2565
2562
  function createBoundChildren(e, t, n, i) {
2566
- const r = e.Te;
2567
- r.addChild((e.Te = n));
2568
- onCleanup(() => r.removeChild(e.Te));
2563
+ const r = e.ue;
2564
+ r.addChild((e.ue = n));
2565
+ onCleanup(() => r.removeChild(e.ue));
2569
2566
  return runWithOwner(e, () => {
2570
2567
  const e = computed(t);
2571
2568
  return boundaryComputed(() => staleValues(() => flatten(read(e))), i);
2572
2569
  });
2573
2570
  }
2574
- class ConditionalQueue extends Queue {
2571
+ class CollectionQueue extends Queue {
2575
2572
  et;
2576
2573
  tt = new Set();
2577
- J = new Set();
2574
+ nt = signal(false, { pureWrite: true });
2575
+ it = false;
2578
2576
  constructor(e) {
2579
2577
  super();
2580
2578
  this.et = e;
2581
2579
  }
2582
2580
  run(e) {
2583
- if (!e || read(this.et)) return;
2584
- return super.run(e);
2585
- }
2586
- notify(e, t, n, i) {
2587
- if (read(this.et)) {
2588
- if (t & STATUS_PENDING) {
2589
- if (n & STATUS_PENDING) {
2590
- this.J.add(e);
2591
- t &= ~STATUS_PENDING;
2592
- } else if (this.J.delete(e)) t &= ~STATUS_PENDING;
2593
- }
2594
- if (t & STATUS_ERROR) {
2595
- if (n & STATUS_ERROR) {
2596
- this.tt.add(e);
2597
- t &= ~STATUS_ERROR;
2598
- } else if (this.tt.delete(e)) t &= ~STATUS_ERROR;
2599
- }
2600
- }
2601
- return t ? super.notify(e, t, n, i ?? e.se) : true;
2602
- }
2603
- }
2604
- class CollectionQueue extends Queue {
2605
- nt;
2606
- it = new Set();
2607
- et = signal(false, { pureWrite: true });
2608
- rt = false;
2609
- constructor(e) {
2610
- super();
2611
- this.nt = e;
2612
- }
2613
- run(e) {
2614
- if (!e || read(this.et)) return;
2581
+ if (!e || read(this.nt)) return;
2615
2582
  return super.run(e);
2616
2583
  }
2617
2584
  notify(e, t, n, i) {
2618
- if (!(t & this.nt) || (this.nt & STATUS_PENDING && this.rt)) return super.notify(e, t, n, i);
2619
- if (n & this.nt) {
2620
- const t = i?.t || e.se?.t;
2585
+ if (!(t & this.et) || (this.et & STATUS_PENDING && this.it)) return super.notify(e, t, n, i);
2586
+ if (n & this.et) {
2587
+ const t = i?.t || e.Z?.t;
2621
2588
  if (t) {
2622
- const e = this.it.size === 0;
2623
- this.it.add(t);
2624
- if (e) setSignal(this.et, true);
2589
+ const e = this.tt.size === 0;
2590
+ this.tt.add(t);
2591
+ if (e) setSignal(this.nt, true);
2625
2592
  }
2626
2593
  }
2627
- t &= ~this.nt;
2594
+ t &= ~this.et;
2628
2595
  return t ? super.notify(e, t, n, i) : true;
2629
2596
  }
2630
2597
  checkSources() {
2631
- for (const e of this.it) {
2632
- if (!(e.Oe & this.nt)) this.it.delete(e);
2633
- }
2634
- if (!this.it.size) setSignal(this.et, false);
2635
- }
2636
- }
2637
- var BoundaryMode;
2638
- (function (e) {
2639
- e["VISIBLE"] = "visible";
2640
- e["HIDDEN"] = "hidden";
2641
- })(BoundaryMode || (BoundaryMode = {}));
2642
- function createBoundary(e, t) {
2643
- const n = createOwner();
2644
- const i = new ConditionalQueue(computed(() => t() === BoundaryMode.HIDDEN));
2645
- const r = createBoundChildren(n, e, i, 0);
2646
- computed(() => {
2647
- const e = read(i.et);
2648
- r.Je = e ? STATUS_ERROR | STATUS_PENDING : 0;
2649
- if (!e) {
2650
- i.J.forEach(e => i.notify(e, STATUS_PENDING, STATUS_PENDING, e.se));
2651
- i.tt.forEach(e => i.notify(e, STATUS_ERROR, STATUS_ERROR, e.se));
2652
- i.J.clear();
2653
- i.tt.clear();
2598
+ for (const e of this.tt) {
2599
+ if (!(e.fe & this.et)) this.tt.delete(e);
2654
2600
  }
2655
- });
2656
- return () => (read(i.et) ? undefined : read(r));
2601
+ if (!this.tt.size) setSignal(this.nt, false);
2602
+ }
2657
2603
  }
2658
2604
  function createCollectionBoundary(e, t, n) {
2659
2605
  const i = createOwner();
2660
2606
  const r = new CollectionQueue(e);
2661
2607
  const o = createBoundChildren(i, t, r, e);
2662
2608
  const s = computed(() => {
2663
- if (!read(r.et)) {
2609
+ if (!read(r.nt)) {
2664
2610
  const e = read(o);
2665
- if (!untrack(() => read(r.et))) {
2666
- r.rt = true;
2611
+ if (!untrack(() => read(r.nt))) {
2612
+ r.it = true;
2667
2613
  return e;
2668
2614
  }
2669
2615
  }
@@ -2676,10 +2622,10 @@ function createLoadBoundary(e, t) {
2676
2622
  }
2677
2623
  function createErrorBoundary(e, t) {
2678
2624
  return createCollectionBoundary(STATUS_ERROR, e, e => {
2679
- let n = e.it.values().next().value;
2680
- const i = n.se?.cause ?? n.se;
2625
+ let n = e.tt.values().next().value;
2626
+ const i = n.Z?.cause ?? n.Z;
2681
2627
  return t(i, () => {
2682
- for (const t of e.it) recompute(t);
2628
+ for (const t of e.tt) recompute(t);
2683
2629
  schedule();
2684
2630
  });
2685
2631
  });
@@ -2742,7 +2688,6 @@ export {
2742
2688
  NotReadyError,
2743
2689
  SUPPORTS_PROXY,
2744
2690
  action,
2745
- createBoundary,
2746
2691
  createContext,
2747
2692
  createEffect,
2748
2693
  createErrorBoundary,
@@ -2750,6 +2695,7 @@ export {
2750
2695
  createMemo,
2751
2696
  createOptimistic,
2752
2697
  createOptimisticStore,
2698
+ createOwner,
2753
2699
  createProjection,
2754
2700
  createReaction,
2755
2701
  createRenderEffect,