@solidjs/signals 0.2.5 → 0.3.1

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
@@ -43,11 +43,12 @@ function schedule() {
43
43
  if (scheduled)
44
44
  return;
45
45
  scheduled = true;
46
- if (!globalQueue.J)
46
+ if (!globalQueue.K)
47
47
  queueMicrotask(flushSync);
48
48
  }
49
49
  var Queue = class {
50
- J = false;
50
+ n = null;
51
+ K = false;
51
52
  s = [[], [], []];
52
53
  F = [];
53
54
  created = clock;
@@ -72,13 +73,13 @@ var Queue = class {
72
73
  for (let i = 0; i < this.F.length; i++) {
73
74
  rerun = this.F[i].run(type) || rerun;
74
75
  }
75
- if (type === EFFECT_PURE && this.s[type].length)
76
- return true;
76
+ if (type === EFFECT_PURE)
77
+ return rerun || !!this.s[type].length;
77
78
  }
78
79
  flush() {
79
- if (this.J)
80
+ if (this.K)
80
81
  return;
81
- this.J = true;
82
+ this.K = true;
82
83
  try {
83
84
  while (this.run(EFFECT_PURE)) {
84
85
  }
@@ -87,17 +88,23 @@ var Queue = class {
87
88
  this.run(EFFECT_RENDER);
88
89
  this.run(EFFECT_USER);
89
90
  } finally {
90
- this.J = false;
91
+ this.K = false;
91
92
  }
92
93
  }
93
94
  addChild(child) {
94
95
  this.F.push(child);
96
+ child.n = this;
95
97
  }
96
98
  removeChild(child) {
97
99
  const index = this.F.indexOf(child);
98
100
  if (index >= 0)
99
101
  this.F.splice(index, 1);
100
102
  }
103
+ notify(...args) {
104
+ if (this.n)
105
+ return this.n.notify(...args);
106
+ return false;
107
+ }
101
108
  };
102
109
  var globalQueue = new Queue();
103
110
  function flushSync() {
@@ -107,14 +114,14 @@ function flushSync() {
107
114
  }
108
115
  function runTop(node) {
109
116
  const ancestors = [];
110
- for (let current = node; current !== null; current = current.t) {
117
+ for (let current = node; current !== null; current = current.n) {
111
118
  if (current.a !== STATE_CLEAN) {
112
119
  ancestors.push(current);
113
120
  }
114
121
  }
115
122
  for (let i = ancestors.length - 1; i >= 0; i--) {
116
123
  if (ancestors[i].a !== STATE_DISPOSED)
117
- ancestors[i].z();
124
+ ancestors[i].x();
118
125
  }
119
126
  }
120
127
  function runPureQueue(queue) {
@@ -125,13 +132,33 @@ function runPureQueue(queue) {
125
132
  }
126
133
  function runEffectQueue(queue) {
127
134
  for (let i = 0; i < queue.length; i++)
128
- queue[i].U();
135
+ queue[i].V();
129
136
  }
130
137
 
131
138
  // src/core/utils.ts
132
139
  function isUndefined(value) {
133
140
  return typeof value === "undefined";
134
141
  }
142
+ function tryCatch(fn) {
143
+ try {
144
+ const v = fn();
145
+ if (v instanceof Promise) {
146
+ return v.then(
147
+ (v2) => [void 0, v2],
148
+ (e) => {
149
+ if (e instanceof NotReadyError)
150
+ throw e;
151
+ return [e];
152
+ }
153
+ );
154
+ }
155
+ return [void 0, v];
156
+ } catch (e) {
157
+ if (e instanceof NotReadyError)
158
+ throw e;
159
+ return [e];
160
+ }
161
+ }
135
162
 
136
163
  // src/core/owner.ts
137
164
  var currentOwner = null;
@@ -144,34 +171,40 @@ function setOwner(owner) {
144
171
  currentOwner = owner;
145
172
  return out;
146
173
  }
174
+ function formatId(prefix, id) {
175
+ const num = id.toString(36), len = num.length - 1;
176
+ return prefix + (len ? String.fromCharCode(64 + len) : "") + num;
177
+ }
147
178
  var Owner = class {
148
179
  // We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild
149
180
  // However, the children are actually added in reverse creation order
150
181
  // See comment at the top of the file for an example of the _nextSibling traversal
151
- t = null;
152
182
  n = null;
153
- u = null;
183
+ m = null;
184
+ t = null;
154
185
  a = STATE_CLEAN;
155
186
  l = null;
156
- p = defaultContext;
157
- m = null;
187
+ o = defaultContext;
158
188
  h = globalQueue;
159
- constructor(signal = false) {
160
- if (currentOwner && !signal)
161
- currentOwner.append(this);
189
+ W = 0;
190
+ id = null;
191
+ constructor(id = null, skipAppend = false) {
192
+ this.id = id;
193
+ if (currentOwner) {
194
+ if (!id && currentOwner.id)
195
+ this.id = currentOwner.getNextChildId();
196
+ !skipAppend && currentOwner.append(this);
197
+ }
162
198
  }
163
199
  append(child) {
200
+ child.n = this;
164
201
  child.t = this;
165
- child.u = this;
166
- if (this.n)
167
- this.n.u = child;
168
- child.n = this.n;
169
- this.n = child;
170
- if (child.p !== this.p) {
171
- child.p = { ...this.p, ...child.p };
172
- }
173
- if (this.m) {
174
- child.m = !child.m ? this.m : [...child.m, ...this.m];
202
+ if (this.m)
203
+ this.m.t = child;
204
+ child.m = this.m;
205
+ this.m = child;
206
+ if (child.o !== this.o) {
207
+ child.o = { ...this.o, ...child.o };
175
208
  }
176
209
  if (this.h)
177
210
  child.h = this.h;
@@ -179,28 +212,28 @@ var Owner = class {
179
212
  dispose(self = true) {
180
213
  if (this.a === STATE_DISPOSED)
181
214
  return;
182
- let head = self ? this.u || this.t : this, current = this.n, next = null;
183
- while (current && current.t === this) {
215
+ let head = self ? this.t || this.n : this, current = this.m, next = null;
216
+ while (current && current.n === this) {
184
217
  current.dispose(true);
185
- current.A();
186
- next = current.n;
187
- current.n = null;
218
+ current.y();
219
+ next = current.m;
220
+ current.m = null;
188
221
  current = next;
189
222
  }
223
+ this.W = 0;
190
224
  if (self)
191
- this.A();
225
+ this.y();
192
226
  if (current)
193
- current.u = !self ? this : this.u;
227
+ current.t = !self ? this : this.t;
194
228
  if (head)
195
- head.n = current;
229
+ head.m = current;
196
230
  }
197
- A() {
198
- if (this.u)
199
- this.u.n = null;
231
+ y() {
232
+ if (this.t)
233
+ this.t.m = null;
234
+ this.n = null;
200
235
  this.t = null;
201
- this.u = null;
202
- this.p = defaultContext;
203
- this.m = null;
236
+ this.o = defaultContext;
204
237
  this.a = STATE_DISPOSED;
205
238
  this.emptyDisposal();
206
239
  }
@@ -217,20 +250,10 @@ var Owner = class {
217
250
  }
218
251
  this.l = null;
219
252
  }
220
- handleError(error) {
221
- if (!this.m)
222
- throw error;
223
- let i = 0, len = this.m.length;
224
- for (i = 0; i < len; i++) {
225
- try {
226
- this.m[i](error, this);
227
- break;
228
- } catch (e) {
229
- error = e;
230
- }
231
- }
232
- if (i === len)
233
- throw error;
253
+ getNextChildId() {
254
+ if (this.id)
255
+ return formatId(this.id, this.W++);
256
+ throw new Error("Cannot get child id from owner without an id");
234
257
  }
235
258
  };
236
259
  function createContext(defaultValue, description) {
@@ -240,7 +263,7 @@ function getContext(context, owner = currentOwner) {
240
263
  if (!owner) {
241
264
  throw new NoOwnerError();
242
265
  }
243
- const value = hasContext(context, owner) ? owner.p[context.id] : context.defaultValue;
266
+ const value = hasContext(context, owner) ? owner.o[context.id] : context.defaultValue;
244
267
  if (isUndefined(value)) {
245
268
  throw new ContextNotFoundError();
246
269
  }
@@ -250,13 +273,13 @@ function setContext(context, value, owner = currentOwner) {
250
273
  if (!owner) {
251
274
  throw new NoOwnerError();
252
275
  }
253
- owner.p = {
254
- ...owner.p,
276
+ owner.o = {
277
+ ...owner.o,
255
278
  [context.id]: isUndefined(value) ? context.defaultValue : value
256
279
  };
257
280
  }
258
281
  function hasContext(context, owner = currentOwner) {
259
- return !isUndefined(owner?.p[context.id]);
282
+ return !isUndefined(owner?.o[context.id]);
260
283
  }
261
284
  function onCleanup(fn) {
262
285
  if (!currentOwner)
@@ -295,44 +318,42 @@ function getObserver() {
295
318
  }
296
319
  var UNCHANGED = Symbol(0);
297
320
  var Computation = class extends Owner {
298
- b = null;
321
+ c = null;
299
322
  e = null;
300
323
  g;
301
324
  G;
302
- B;
325
+ z;
303
326
  // Used in __DEV__ mode, hopefully removed in production
304
- $;
327
+ ba;
305
328
  // Using false is an optimization as an alternative to _equals: () => false
306
329
  // which could enable more efficient DIRTY notification
307
- O = isEqual;
308
- V;
330
+ S = isEqual;
331
+ X;
309
332
  /** Whether the computation is an error or has ancestors that are unresolved */
310
333
  f = 0;
311
334
  /** Which flags raised by sources are handled, vs. being passed through. */
312
- P = DEFAULT_FLAGS;
313
- Q = null;
314
- y = -1;
315
- K = false;
335
+ T = DEFAULT_FLAGS;
336
+ A = -1;
337
+ B = false;
316
338
  constructor(initialValue, compute2, options) {
317
- super(compute2 === null);
318
- this.B = compute2;
339
+ super(null, compute2 === null);
340
+ this.z = compute2;
319
341
  this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
320
342
  this.f = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
321
343
  this.g = initialValue;
322
344
  if (options?.equals !== void 0)
323
- this.O = options.equals;
345
+ this.S = options.equals;
324
346
  if (options?.unobserved)
325
- this.V = options?.unobserved;
347
+ this.X = options?.unobserved;
326
348
  }
327
- W() {
328
- if (this.B) {
329
- if (this.f & ERROR_BIT && this.y <= getClock())
349
+ Y() {
350
+ if (this.z) {
351
+ if (this.f & ERROR_BIT && this.A <= getClock())
330
352
  update(this);
331
353
  else
332
- this.z();
354
+ this.x();
333
355
  }
334
- if (!this.B || this.b?.length)
335
- track(this);
356
+ track(this);
336
357
  newFlags |= this.f & ~currentMask;
337
358
  if (this.f & ERROR_BIT) {
338
359
  throw this.G;
@@ -345,7 +366,7 @@ var Computation = class extends Owner {
345
366
  * Automatically re-executes the surrounding computation when the value changes
346
367
  */
347
368
  read() {
348
- return this.W();
369
+ return this.Y();
349
370
  }
350
371
  /**
351
372
  * Return the current value of this computation
@@ -355,46 +376,37 @@ var Computation = class extends Owner {
355
376
  * before continuing
356
377
  */
357
378
  wait() {
358
- if (this.B && this.f & ERROR_BIT && this.y <= getClock()) {
379
+ if (this.z && this.f & ERROR_BIT && this.A <= getClock()) {
359
380
  update(this);
381
+ } else {
382
+ this.x();
360
383
  }
361
- if ((notStale || this.f & UNINITIALIZED_BIT) && this.loading()) {
384
+ track(this);
385
+ if ((notStale || this.f & UNINITIALIZED_BIT) && this.f & LOADING_BIT) {
362
386
  throw new NotReadyError();
363
387
  }
364
- if (staleCheck && this.loading())
388
+ if (staleCheck && this.f & LOADING_BIT) {
365
389
  staleCheck.g = true;
366
- return this.W();
367
- }
368
- /**
369
- * Return true if the computation is the value is dependent on an unresolved promise
370
- * Triggers re-execution of the computation when the loading state changes
371
- *
372
- * This is useful especially when effects want to re-execute when a computation's
373
- * loading state changes
374
- */
375
- loading() {
376
- if (this.Q === null) {
377
- this.Q = loadingState(this);
378
390
  }
379
- return this.Q.read();
391
+ return this.Y();
380
392
  }
381
393
  /** Update the computation with a new value. */
382
394
  write(value, flags = 0, raw = false) {
383
395
  const newValue = !raw && typeof value === "function" ? value(this.g) : value;
384
- const valueChanged = newValue !== UNCHANGED && (!!(this.f & UNINITIALIZED_BIT) || this.O === false || !this.O(this.g, newValue));
396
+ const valueChanged = newValue !== UNCHANGED && (!!(this.f & UNINITIALIZED_BIT) || this.f & LOADING_BIT & ~flags || this.S === false || !this.S(this.g, newValue));
385
397
  if (valueChanged) {
386
398
  this.g = newValue;
387
399
  this.G = void 0;
388
400
  }
389
401
  const changedFlagsMask = this.f ^ flags, changedFlags = changedFlagsMask & flags;
390
402
  this.f = flags;
391
- this.y = getClock() + 1;
403
+ this.A = getClock() + 1;
392
404
  if (this.e) {
393
405
  for (let i = 0; i < this.e.length; i++) {
394
406
  if (valueChanged) {
395
- this.e[i].q(STATE_DIRTY);
407
+ this.e[i].r(STATE_DIRTY);
396
408
  } else if (changedFlagsMask) {
397
- this.e[i].X(changedFlagsMask, changedFlags);
409
+ this.e[i].Z(changedFlagsMask, changedFlags);
398
410
  }
399
411
  }
400
412
  }
@@ -403,14 +415,14 @@ var Computation = class extends Owner {
403
415
  /**
404
416
  * Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
405
417
  */
406
- q(state, skipQueue) {
407
- if (this.a >= state && !this.K)
418
+ r(state, skipQueue) {
419
+ if (this.a >= state && !this.B)
408
420
  return;
409
- this.K = !!skipQueue;
421
+ this.B = !!skipQueue;
410
422
  this.a = state;
411
423
  if (this.e) {
412
424
  for (let i = 0; i < this.e.length; i++) {
413
- this.e[i].q(STATE_CHECK, skipQueue);
425
+ this.e[i].r(STATE_CHECK, skipQueue);
414
426
  }
415
427
  }
416
428
  }
@@ -420,11 +432,11 @@ var Computation = class extends Owner {
420
432
  * @param mask A bitmask for which flag(s) were changed.
421
433
  * @param newFlags The source's new flags, masked to just the changed ones.
422
434
  */
423
- X(mask, newFlags2) {
435
+ Z(mask, newFlags2) {
424
436
  if (this.a >= STATE_DIRTY)
425
437
  return;
426
- if (mask & this.P) {
427
- this.q(STATE_DIRTY);
438
+ if (mask & this.T) {
439
+ this.r(STATE_DIRTY);
428
440
  return;
429
441
  }
430
442
  if (this.a >= STATE_CHECK)
@@ -432,17 +444,17 @@ var Computation = class extends Owner {
432
444
  const prevFlags = this.f & mask;
433
445
  const deltaFlags = prevFlags ^ newFlags2;
434
446
  if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
435
- this.q(STATE_CHECK);
447
+ this.r(STATE_CHECK);
436
448
  } else {
437
449
  this.f ^= deltaFlags;
438
450
  if (this.e) {
439
451
  for (let i = 0; i < this.e.length; i++) {
440
- this.e[i].X(mask, newFlags2);
452
+ this.e[i].Z(mask, newFlags2);
441
453
  }
442
454
  }
443
455
  }
444
456
  }
445
- H(error) {
457
+ L(error) {
446
458
  this.G = error;
447
459
  this.write(UNCHANGED, this.f & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
448
460
  }
@@ -453,18 +465,21 @@ var Computation = class extends Owner {
453
465
  *
454
466
  * This function will ensure that the value and states we read from the computation are up to date
455
467
  */
456
- z() {
468
+ x() {
469
+ if (!this.z) {
470
+ return;
471
+ }
457
472
  if (this.a === STATE_DISPOSED) {
458
- throw new Error("Tried to read a disposed computation");
473
+ return;
459
474
  }
460
475
  if (this.a === STATE_CLEAN) {
461
476
  return;
462
477
  }
463
478
  let observerFlags = 0;
464
479
  if (this.a === STATE_CHECK) {
465
- for (let i = 0; i < this.b.length; i++) {
466
- this.b[i].z();
467
- observerFlags |= this.b[i].f;
480
+ for (let i = 0; i < this.c.length; i++) {
481
+ this.c[i].x();
482
+ observerFlags |= this.c[i].f;
468
483
  if (this.a === STATE_DIRTY) {
469
484
  break;
470
485
  }
@@ -480,33 +495,17 @@ var Computation = class extends Owner {
480
495
  /**
481
496
  * Remove ourselves from the owner graph and the computation graph
482
497
  */
483
- A() {
498
+ y() {
484
499
  if (this.a === STATE_DISPOSED)
485
500
  return;
486
- if (this.b)
501
+ if (this.c)
487
502
  removeSourceObservers(this, 0);
488
- super.A();
503
+ super.y();
489
504
  }
490
505
  };
491
- function loadingState(node) {
492
- const prevOwner = setOwner(node.t);
493
- const options = void 0;
494
- const computation = new Computation(
495
- void 0,
496
- () => {
497
- track(node);
498
- node.z();
499
- return !!(node.f & LOADING_BIT);
500
- },
501
- options
502
- );
503
- computation.P = ERROR_BIT | LOADING_BIT;
504
- setOwner(prevOwner);
505
- return computation;
506
- }
507
506
  function track(computation) {
508
507
  if (currentObserver) {
509
- if (!newSources && currentObserver.b && currentObserver.b[newSourcesIndex] === computation) {
508
+ if (!newSources && currentObserver.c && currentObserver.c[newSourcesIndex] === computation) {
510
509
  newSourcesIndex++;
511
510
  } else if (!newSources)
512
511
  newSources = [computation];
@@ -514,7 +513,7 @@ function track(computation) {
514
513
  newSources.push(computation);
515
514
  }
516
515
  if (updateCheck) {
517
- updateCheck.g = computation.y > currentObserver.y;
516
+ updateCheck.g = computation.A > currentObserver.A;
518
517
  }
519
518
  }
520
519
  }
@@ -526,56 +525,56 @@ function update(node) {
526
525
  try {
527
526
  node.dispose(false);
528
527
  node.emptyDisposal();
529
- const result = compute(node, node.B, node);
528
+ const result = compute(node, node.z, node);
530
529
  node.write(result, newFlags, true);
531
530
  } catch (error) {
532
531
  if (error instanceof NotReadyError) {
533
532
  node.write(UNCHANGED, newFlags | LOADING_BIT | node.f & UNINITIALIZED_BIT);
534
533
  } else {
535
- node.H(error);
534
+ node.L(error);
536
535
  }
537
536
  } finally {
538
537
  if (newSources) {
539
- if (node.b)
538
+ if (node.c)
540
539
  removeSourceObservers(node, newSourcesIndex);
541
- if (node.b && newSourcesIndex > 0) {
542
- node.b.length = newSourcesIndex + newSources.length;
540
+ if (node.c && newSourcesIndex > 0) {
541
+ node.c.length = newSourcesIndex + newSources.length;
543
542
  for (let i = 0; i < newSources.length; i++) {
544
- node.b[newSourcesIndex + i] = newSources[i];
543
+ node.c[newSourcesIndex + i] = newSources[i];
545
544
  }
546
545
  } else {
547
- node.b = newSources;
546
+ node.c = newSources;
548
547
  }
549
548
  let source;
550
- for (let i = newSourcesIndex; i < node.b.length; i++) {
551
- source = node.b[i];
549
+ for (let i = newSourcesIndex; i < node.c.length; i++) {
550
+ source = node.c[i];
552
551
  if (!source.e)
553
552
  source.e = [node];
554
553
  else
555
554
  source.e.push(node);
556
555
  }
557
- } else if (node.b && newSourcesIndex < node.b.length) {
556
+ } else if (node.c && newSourcesIndex < node.c.length) {
558
557
  removeSourceObservers(node, newSourcesIndex);
559
- node.b.length = newSourcesIndex;
558
+ node.c.length = newSourcesIndex;
560
559
  }
561
560
  newSources = prevSources;
562
561
  newSourcesIndex = prevSourcesIndex;
563
562
  newFlags = prevFlags;
564
- node.y = getClock() + 1;
563
+ node.A = getClock() + 1;
565
564
  node.a = STATE_CLEAN;
566
565
  }
567
566
  }
568
567
  function removeSourceObservers(node, index) {
569
568
  let source;
570
569
  let swap;
571
- for (let i = index; i < node.b.length; i++) {
572
- source = node.b[i];
570
+ for (let i = index; i < node.c.length; i++) {
571
+ source = node.c[i];
573
572
  if (source.e) {
574
573
  swap = source.e.indexOf(node);
575
574
  source.e[swap] = source.e[source.e.length - 1];
576
575
  source.e.pop();
577
576
  if (!source.e.length)
578
- source.V?.();
577
+ source.X?.();
579
578
  }
580
579
  }
581
580
  }
@@ -597,8 +596,7 @@ function hasUpdated(fn) {
597
596
  updateCheck = current;
598
597
  }
599
598
  }
600
- function isPending(fn, loadingValue) {
601
- const argLength = arguments.length;
599
+ function pendingCheck(fn, loadingValue) {
602
600
  const current = staleCheck;
603
601
  staleCheck = { g: false };
604
602
  try {
@@ -607,13 +605,20 @@ function isPending(fn, loadingValue) {
607
605
  } catch (err) {
608
606
  if (!(err instanceof NotReadyError))
609
607
  return false;
610
- if (argLength > 1)
608
+ if (loadingValue !== void 0)
611
609
  return loadingValue;
612
610
  throw err;
613
611
  } finally {
614
612
  staleCheck = current;
615
613
  }
616
614
  }
615
+ function isPending(fn, loadingValue) {
616
+ if (!currentObserver)
617
+ return pendingCheck(fn, loadingValue);
618
+ const c = new Computation(void 0, () => pendingCheck(fn, loadingValue));
619
+ c.T |= LOADING_BIT;
620
+ return c.read();
621
+ }
617
622
  function latest(fn, fallback) {
618
623
  const argLength = arguments.length;
619
624
  const prevFlags = newFlags;
@@ -630,19 +635,10 @@ function latest(fn, fallback) {
630
635
  notStale = prevNotStale;
631
636
  }
632
637
  }
633
- function catchError(fn) {
634
- try {
635
- fn();
636
- } catch (e) {
637
- if (e instanceof NotReadyError)
638
- throw e;
639
- return e;
640
- }
641
- }
642
638
  function runWithObserver(observer, run) {
643
639
  const prevSources = newSources, prevSourcesIndex = newSourcesIndex, prevFlags = newFlags;
644
640
  newSources = null;
645
- newSourcesIndex = observer.b ? observer.b.length : 0;
641
+ newSourcesIndex = observer.c ? observer.c.length : 0;
646
642
  newFlags = 0;
647
643
  try {
648
644
  return compute(observer, run, observer);
@@ -653,21 +649,21 @@ function runWithObserver(observer, run) {
653
649
  newFlags | LOADING_BIT | observer.f & UNINITIALIZED_BIT
654
650
  );
655
651
  } else {
656
- observer.H(error);
652
+ observer.L(error);
657
653
  }
658
654
  } finally {
659
655
  if (newSources) {
660
656
  if (newSourcesIndex > 0) {
661
- observer.b.length = newSourcesIndex + newSources.length;
657
+ observer.c.length = newSourcesIndex + newSources.length;
662
658
  for (let i = 0; i < newSources.length; i++) {
663
- observer.b[newSourcesIndex + i] = newSources[i];
659
+ observer.c[newSourcesIndex + i] = newSources[i];
664
660
  }
665
661
  } else {
666
- observer.b = newSources;
662
+ observer.c = newSources;
667
663
  }
668
664
  let source;
669
- for (let i = newSourcesIndex; i < observer.b.length; i++) {
670
- source = observer.b[i];
665
+ for (let i = newSourcesIndex; i < observer.c.length; i++) {
666
+ source = observer.c[i];
671
667
  if (!source.e)
672
668
  source.e = [observer];
673
669
  else
@@ -682,7 +678,7 @@ function runWithObserver(observer, run) {
682
678
  function compute(owner, fn, observer) {
683
679
  const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask, prevNotStale = notStale;
684
680
  currentObserver = observer;
685
- currentMask = observer?.P ?? DEFAULT_FLAGS;
681
+ currentMask = observer?.T ?? DEFAULT_FLAGS;
686
682
  notStale = true;
687
683
  try {
688
684
  return fn(observer ? observer.g : void 0);
@@ -755,90 +751,84 @@ function flattenArray(children, results = [], options) {
755
751
  throw notReady;
756
752
  return needsUnwrap;
757
753
  }
758
- function createBoundary(fn, queue) {
759
- const owner = new Owner();
760
- const parentQueue = owner.h;
761
- parentQueue.addChild(owner.h = queue);
762
- onCleanup(() => parentQueue.removeChild(owner.h));
763
- return compute(owner, fn, null);
764
- }
765
754
 
766
755
  // src/core/effect.ts
767
756
  var Effect = class extends Computation {
768
- L;
769
757
  M;
770
- C;
771
- R = false;
772
758
  N;
773
- w;
759
+ C;
760
+ U = false;
761
+ O;
762
+ u;
774
763
  constructor(initialValue, compute2, effect, error, options) {
775
764
  super(initialValue, compute2, options);
776
- this.L = effect;
777
- this.M = error;
778
- this.N = initialValue;
779
- this.w = options?.render ? EFFECT_RENDER : EFFECT_USER;
780
- if (this.w === EFFECT_RENDER) {
781
- this.B = (p) => getClock() > this.h.created && !(this.f & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
765
+ this.M = effect;
766
+ this.N = error;
767
+ this.O = initialValue;
768
+ this.u = options?.render ? EFFECT_RENDER : EFFECT_USER;
769
+ if (this.u === EFFECT_RENDER) {
770
+ this.z = (p) => getClock() > this.h.created && !(this.f & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
782
771
  }
783
- this.z();
784
- !options?.defer && (this.w === EFFECT_USER ? this.h.enqueue(this.w, this) : this.U());
772
+ this.x();
773
+ !options?.defer && (this.u === EFFECT_USER ? this.h.enqueue(this.u, this) : this.V());
785
774
  }
786
775
  write(value, flags = 0) {
787
776
  if (this.a == STATE_DIRTY) {
788
- const currentFlags = this.f;
777
+ this.f;
789
778
  this.f = flags;
790
- if (this.w === EFFECT_RENDER && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
791
- this.h.S?.(this);
779
+ if (this.u === EFFECT_RENDER) {
780
+ this.h.notify(this, LOADING_BIT | ERROR_BIT, flags);
792
781
  }
793
782
  }
794
783
  if (value === UNCHANGED)
795
784
  return this.g;
796
785
  this.g = value;
797
- this.R = true;
786
+ this.U = true;
798
787
  return value;
799
788
  }
800
- q(state, skipQueue) {
789
+ r(state, skipQueue) {
801
790
  if (this.a >= state || skipQueue)
802
791
  return;
803
792
  if (this.a === STATE_CLEAN)
804
- this.h.enqueue(this.w, this);
793
+ this.h.enqueue(this.u, this);
805
794
  this.a = state;
806
795
  }
807
- H(error) {
796
+ L(error) {
797
+ this.G = error;
808
798
  this.C?.();
809
- if (this.f & LOADING_BIT) {
810
- this.h.S?.(this);
811
- }
799
+ this.h.notify(this, LOADING_BIT, 0);
812
800
  this.f = ERROR_BIT;
813
- if (this.w === EFFECT_USER) {
801
+ if (this.u === EFFECT_USER) {
814
802
  try {
815
- return this.M ? this.C = this.M(error) : console.error(new EffectError(this.L, error));
803
+ return this.N ? this.C = this.N(error) : console.error(new EffectError(this.M, error));
816
804
  } catch (e) {
817
805
  error = e;
818
806
  }
819
807
  }
820
- this.handleError(error);
808
+ if (!this.h.notify(this, ERROR_BIT, ERROR_BIT))
809
+ throw error;
821
810
  }
822
- A() {
811
+ y() {
823
812
  if (this.a === STATE_DISPOSED)
824
813
  return;
825
- this.L = void 0;
826
- this.N = void 0;
827
814
  this.M = void 0;
815
+ this.O = void 0;
816
+ this.N = void 0;
828
817
  this.C?.();
829
818
  this.C = void 0;
830
- super.A();
819
+ super.y();
831
820
  }
832
- U() {
833
- if (this.R && this.a !== STATE_DISPOSED) {
821
+ V() {
822
+ if (this.U && this.a !== STATE_DISPOSED) {
834
823
  this.C?.();
835
824
  try {
836
- this.C = this.L(this.g, this.N);
825
+ this.C = this.M(this.g, this.O);
837
826
  } catch (e) {
838
- this.handleError(e);
827
+ if (!this.h.notify(this, ERROR_BIT, ERROR_BIT))
828
+ throw e;
839
829
  } finally {
840
- this.N = this.g;
841
- this.R = false;
830
+ this.O = this.g;
831
+ this.U = false;
842
832
  }
843
833
  }
844
834
  }
@@ -846,75 +836,154 @@ var Effect = class extends Computation {
846
836
  var EagerComputation = class extends Computation {
847
837
  constructor(initialValue, compute2, options) {
848
838
  super(initialValue, compute2, options);
849
- !options?.defer && this.z();
839
+ !options?.defer && this.x();
850
840
  }
851
- q(state, skipQueue) {
852
- if (this.a >= state && !this.K)
841
+ r(state, skipQueue) {
842
+ if (this.a >= state && !this.B)
853
843
  return;
854
844
  if (this.a === STATE_CLEAN && !skipQueue)
855
845
  this.h.enqueue(EFFECT_PURE, this);
856
- super.q(state, skipQueue);
846
+ super.r(state, skipQueue);
857
847
  }
858
848
  };
859
849
  var ProjectionComputation = class extends Computation {
860
850
  constructor(compute2) {
861
- super(null, compute2);
851
+ super(void 0, compute2);
862
852
  }
863
- q(state, skipQueue) {
864
- if (this.a >= state && !this.K)
853
+ r(state, skipQueue) {
854
+ if (this.a >= state && !this.B)
865
855
  return;
866
- if (this.a === STATE_CLEAN && !skipQueue)
856
+ if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.B))
867
857
  this.h.enqueue(EFFECT_PURE, this);
868
- super.q(state, true);
858
+ super.r(state, true);
859
+ this.B = !!skipQueue;
869
860
  }
870
861
  };
871
862
 
872
- // src/core/suspense.ts
873
- var SuspenseQueue = class extends Queue {
874
- c = /* @__PURE__ */ new Set();
875
- o = false;
876
- T = new Computation(false, null);
863
+ // src/core/boundaries.ts
864
+ var BoundaryComputation = class extends EagerComputation {
865
+ H;
866
+ constructor(compute2, propagationMask) {
867
+ super(void 0, compute2, { defer: true });
868
+ this.H = propagationMask;
869
+ }
870
+ write(value, flags) {
871
+ super.write(value, flags & ~this.H);
872
+ if (this.H & LOADING_BIT && !(this.f & UNINITIALIZED_BIT)) {
873
+ flags &= ~LOADING_BIT;
874
+ }
875
+ this.h.notify(this, this.H, flags);
876
+ return this.g;
877
+ }
878
+ };
879
+ function createBoundChildren(owner, fn, queue, mask) {
880
+ const parentQueue = owner.h;
881
+ parentQueue.addChild(owner.h = queue);
882
+ onCleanup(() => parentQueue.removeChild(owner.h));
883
+ return compute(
884
+ owner,
885
+ () => {
886
+ const c = new Computation(void 0, fn);
887
+ return new BoundaryComputation(() => flatten(c.wait()), mask);
888
+ },
889
+ null
890
+ );
891
+ }
892
+ var ConditionalQueue = class extends Queue {
893
+ p;
894
+ P = /* @__PURE__ */ new Set();
895
+ Q = /* @__PURE__ */ new Set();
896
+ constructor(disabled) {
897
+ super();
898
+ this.p = disabled;
899
+ }
877
900
  run(type) {
878
- if (type && this.o)
901
+ if (type && this.p.read())
879
902
  return;
880
903
  return super.run(type);
881
904
  }
882
- S(node) {
883
- if (node.f & LOADING_BIT) {
884
- this.c.add(node);
885
- if (!this.o) {
886
- this.o = true;
887
- this.T.write(true);
905
+ notify(node, type, flags) {
906
+ if (this.p.read()) {
907
+ if (type === LOADING_BIT) {
908
+ flags & LOADING_BIT ? this.Q.add(node) : this.Q.delete(node);
888
909
  }
889
- } else {
890
- this.c.delete(node);
891
- if (this.c.size === 0) {
892
- this.o = false;
893
- this.T.write(false);
910
+ if (type === ERROR_BIT) {
911
+ flags & ERROR_BIT ? this.P.add(node) : this.P.delete(node);
894
912
  }
913
+ return true;
895
914
  }
915
+ return super.notify(node, type, flags);
896
916
  }
897
917
  };
898
- var LiveComputation = class extends EagerComputation {
899
- write(value, flags = 0) {
900
- const currentFlags = this.f;
901
- const dirty = this.a === STATE_DIRTY;
902
- super.write(value, flags);
903
- if (dirty && (flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
904
- this.h.S?.(this);
918
+ var CollectionQueue = class extends Queue {
919
+ R;
920
+ b = /* @__PURE__ */ new Set();
921
+ p = new Computation(false, null);
922
+ constructor(type) {
923
+ super();
924
+ this.R = type;
925
+ }
926
+ notify(node, type, flags) {
927
+ if (!(type & this.R))
928
+ return super.notify(node, type, flags);
929
+ if (flags & this.R) {
930
+ this.b.add(node);
931
+ if (this.b.size === 1)
932
+ this.p.write(true);
933
+ } else {
934
+ this.b.delete(node);
935
+ if (this.b.size === 0)
936
+ this.p.write(false);
905
937
  }
906
- return this.g;
938
+ type &= ~this.R;
939
+ return type ? super.notify(node, type, flags) : true;
907
940
  }
908
941
  };
942
+ function createBoundary(fn, condition) {
943
+ const owner = new Owner();
944
+ const queue = new ConditionalQueue(new Computation(void 0, () => condition() === "hidden" /* HIDDEN */));
945
+ const tree = createBoundChildren(owner, fn, queue, 0);
946
+ new EagerComputation(void 0, () => {
947
+ const disabled = queue.p.read();
948
+ tree.H = disabled ? ERROR_BIT | LOADING_BIT : 0;
949
+ if (!disabled) {
950
+ queue.Q.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
951
+ queue.P.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
952
+ queue.Q.clear();
953
+ queue.P.clear();
954
+ }
955
+ });
956
+ return () => queue.p.read() ? void 0 : tree.read();
957
+ }
958
+ function createCollectionBoundary(type, fn, fallback) {
959
+ const owner = new Owner();
960
+ const queue = new CollectionQueue(type);
961
+ const tree = createBoundChildren(owner, fn, queue, type);
962
+ const decision = new Computation(void 0, () => {
963
+ if (!queue.p.read()) {
964
+ const resolved = tree.read();
965
+ if (!queue.p.read())
966
+ return resolved;
967
+ }
968
+ return fallback(queue);
969
+ });
970
+ return decision.read.bind(decision);
971
+ }
909
972
  function createSuspense(fn, fallback) {
910
- const queue = new SuspenseQueue();
911
- const tree = createBoundary(() => {
912
- const child = new Computation(null, fn);
913
- return new LiveComputation(null, () => flatten(child.wait()));
914
- }, queue);
915
- const equality = new Computation(null, () => queue.T.read() || queue.o);
916
- const comp = new Computation(null, () => equality.read() ? fallback() : tree.read());
917
- return comp.read.bind(comp);
973
+ return createCollectionBoundary(LOADING_BIT, fn, () => fallback());
974
+ }
975
+ function createErrorBoundary(fn, fallback) {
976
+ return createCollectionBoundary(
977
+ ERROR_BIT,
978
+ fn,
979
+ (queue) => fallback(queue.b.values().next().value.G, () => {
980
+ incrementClock();
981
+ for (let node of queue.b) {
982
+ node.a = STATE_DIRTY;
983
+ node.h?.enqueue(node.u, node);
984
+ }
985
+ })
986
+ );
918
987
  }
919
988
 
920
989
  // src/signals.ts
@@ -942,77 +1011,64 @@ function createMemo(compute2, value, options) {
942
1011
  let resolvedValue;
943
1012
  return () => {
944
1013
  if (node) {
1014
+ if (node.a === STATE_DISPOSED) {
1015
+ node = void 0;
1016
+ return resolvedValue;
1017
+ }
945
1018
  resolvedValue = node.wait();
946
- if (!node.b?.length && node.n?.t !== node) {
1019
+ if (!node.c?.length && node.m?.n !== node) {
947
1020
  node.dispose();
948
1021
  node = void 0;
949
- } else if (!node.t && !node.e?.length) {
950
- node.dispose();
951
- node.a = STATE_DIRTY;
952
1022
  }
953
1023
  }
954
1024
  return resolvedValue;
955
1025
  };
956
1026
  }
957
1027
  function createAsync(compute2, value, options) {
958
- let uninitialized = value === void 0;
959
- const lhs = new EagerComputation(
960
- {
961
- g: value
962
- },
1028
+ const node = new EagerComputation(
1029
+ value,
963
1030
  (p) => {
964
- const value2 = p?.g;
965
- const source = compute2(value2);
1031
+ const source = compute2(p);
966
1032
  const isPromise = source instanceof Promise;
967
1033
  const iterator = source[Symbol.asyncIterator];
968
1034
  if (!isPromise && !iterator) {
969
- return {
970
- wait() {
971
- return source;
972
- },
973
- g: source
974
- };
1035
+ return source;
975
1036
  }
976
- const signal = new Computation(value2, null, iterator ? { ...options, equals: false } : options);
977
- const w = signal.wait;
978
- signal.wait = function() {
979
- if (signal.f & ERROR_BIT && signal.y <= getClock()) {
980
- lhs.q(STATE_DIRTY);
981
- throw new NotReadyError();
982
- }
983
- return w.call(this);
984
- };
985
- signal.write(UNCHANGED, LOADING_BIT | (uninitialized ? UNINITIALIZED_BIT : 0));
1037
+ let abort = false;
1038
+ onCleanup(() => abort = true);
986
1039
  if (isPromise) {
987
1040
  source.then(
988
1041
  (value3) => {
989
- uninitialized = false;
990
- signal.write(value3, 0, true);
1042
+ if (abort)
1043
+ return;
1044
+ node.write(value3, 0, true);
991
1045
  },
992
1046
  (error) => {
993
- uninitialized = true;
994
- signal.H(error);
1047
+ if (abort)
1048
+ return;
1049
+ node.L(error);
995
1050
  }
996
1051
  );
997
1052
  } else {
998
- let abort = false;
999
- onCleanup(() => abort = true);
1000
1053
  (async () => {
1001
1054
  try {
1002
1055
  for await (let value3 of source) {
1003
1056
  if (abort)
1004
1057
  return;
1005
- signal.write(value3, 0, true);
1058
+ node.write(value3, 0, true);
1006
1059
  }
1007
1060
  } catch (error) {
1008
- signal.write(error, ERROR_BIT);
1061
+ if (abort)
1062
+ return;
1063
+ node.write(error, ERROR_BIT);
1009
1064
  }
1010
1065
  })();
1011
1066
  }
1012
- return signal;
1013
- }
1067
+ throw new NotReadyError();
1068
+ },
1069
+ options
1014
1070
  );
1015
- return () => lhs.wait().wait();
1071
+ return node.wait.bind(node);
1016
1072
  }
1017
1073
  function createEffect(compute2, effect, error, value, options) {
1018
1074
  void new Effect(
@@ -1029,62 +1085,13 @@ function createRenderEffect(compute2, effect, value, options) {
1029
1085
  ...options
1030
1086
  });
1031
1087
  }
1032
- function createRoot(init) {
1033
- const owner = new Owner();
1088
+ function createRoot(init, options) {
1089
+ const owner = new Owner(options?.id);
1034
1090
  return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
1035
1091
  }
1036
1092
  function runWithOwner(owner, run) {
1037
1093
  return compute(owner, run, null);
1038
1094
  }
1039
- function createErrorBoundary(fn, fallback) {
1040
- const owner = new Owner();
1041
- const error = new Computation(void 0, null);
1042
- const nodes = /* @__PURE__ */ new Set();
1043
- function handler(err, node) {
1044
- if (nodes.has(node))
1045
- return;
1046
- compute(
1047
- node,
1048
- () => onCleanup(() => {
1049
- nodes.delete(node);
1050
- if (!nodes.size)
1051
- error.write(void 0);
1052
- }),
1053
- null
1054
- );
1055
- nodes.add(node);
1056
- if (nodes.size === 1)
1057
- error.write({ G: err });
1058
- }
1059
- owner.m = owner.m ? [handler, ...owner.m] : [handler];
1060
- const guarded = compute(
1061
- owner,
1062
- () => {
1063
- const c = new Computation(void 0, fn);
1064
- const f = new EagerComputation(void 0, () => flatten(c.read()), { defer: true });
1065
- f.H = function(error2) {
1066
- this.handleError(error2);
1067
- };
1068
- return f;
1069
- },
1070
- null
1071
- );
1072
- const decision = new Computation(null, () => {
1073
- if (!error.read()) {
1074
- const resolved = guarded.read();
1075
- if (!error.read())
1076
- return resolved;
1077
- }
1078
- return fallback(error.read().G, () => {
1079
- incrementClock();
1080
- for (let node of nodes) {
1081
- node.a = STATE_DIRTY;
1082
- node.h?.enqueue(node.w, node);
1083
- }
1084
- });
1085
- });
1086
- return decision.read.bind(decision);
1087
- }
1088
1095
  function resolve(fn) {
1089
1096
  return new Promise((res, rej) => {
1090
1097
  createRoot((dispose) => {
@@ -1230,7 +1237,7 @@ function ownKeys(target) {
1230
1237
  trackSelf(target);
1231
1238
  return Reflect.ownKeys(target[STORE_VALUE]);
1232
1239
  }
1233
- var Writing = /* @__PURE__ */ new Set();
1240
+ var Writing = null;
1234
1241
  var proxyTraps = {
1235
1242
  get(target, property, receiver) {
1236
1243
  if (property === $TARGET)
@@ -1251,7 +1258,7 @@ var proxyTraps = {
1251
1258
  if (desc && desc.get)
1252
1259
  return desc.get.call(receiver);
1253
1260
  }
1254
- if (Writing.has(storeValue)) {
1261
+ if (Writing?.has(storeValue)) {
1255
1262
  const value2 = tracked ? tracked.g : storeValue[property];
1256
1263
  return isWrappable(value2) ? (Writing.add(value2[$RAW] || value2), wrap2(value2)) : value2;
1257
1264
  }
@@ -1274,11 +1281,11 @@ var proxyTraps = {
1274
1281
  return has;
1275
1282
  },
1276
1283
  set(target, property, value) {
1277
- Writing.has(target[STORE_VALUE]) && setProperty(target[STORE_VALUE], property, unwrap(value, false));
1284
+ Writing?.has(target[STORE_VALUE]) && setProperty(target[STORE_VALUE], property, unwrap(value, false));
1278
1285
  return true;
1279
1286
  },
1280
1287
  deleteProperty(target, property) {
1281
- Writing.has(target[STORE_VALUE]) && setProperty(target[STORE_VALUE], property, void 0, true);
1288
+ Writing?.has(target[STORE_VALUE]) && setProperty(target[STORE_VALUE], property, void 0, true);
1282
1289
  return true;
1283
1290
  },
1284
1291
  ownKeys,
@@ -1361,11 +1368,14 @@ function createStore(first, second) {
1361
1368
  const unwrappedStore = unwrap(store);
1362
1369
  let wrappedStore = wrap2(unwrappedStore);
1363
1370
  const setStore = (fn) => {
1371
+ const prevWriting = Writing;
1372
+ Writing = /* @__PURE__ */ new Set();
1373
+ Writing.add(unwrappedStore);
1364
1374
  try {
1365
- Writing.add(unwrappedStore);
1366
1375
  fn(wrappedStore);
1367
1376
  } finally {
1368
1377
  Writing.clear();
1378
+ Writing = prevWriting;
1369
1379
  }
1370
1380
  };
1371
1381
  if (derived)
@@ -1643,19 +1653,19 @@ function mapArray(list, map, options) {
1643
1653
  return updateKeyedMap.bind({
1644
1654
  I: new Owner(),
1645
1655
  i: 0,
1646
- Y: list,
1647
- x: [],
1656
+ _: list,
1657
+ w: [],
1648
1658
  D: map,
1649
1659
  d: [],
1650
- c: [],
1660
+ b: [],
1651
1661
  E: keyFn,
1652
1662
  j: keyFn || options?.keyed === false ? [] : void 0,
1653
1663
  k: map.length > 1 ? [] : void 0,
1654
- o: options?.fallback
1664
+ J: options?.fallback
1655
1665
  });
1656
1666
  }
1657
1667
  function updateKeyedMap() {
1658
- const newItems = this.Y() || [], newLen = newItems.length;
1668
+ const newItems = this._() || [], newLen = newItems.length;
1659
1669
  newItems[$TRACK];
1660
1670
  runWithOwner(this.I, () => {
1661
1671
  let i, j, mapper = this.j ? () => {
@@ -1676,38 +1686,38 @@ function updateKeyedMap() {
1676
1686
  if (newLen === 0) {
1677
1687
  if (this.i !== 0) {
1678
1688
  this.I.dispose(false);
1679
- this.c = [];
1680
- this.x = [];
1689
+ this.b = [];
1690
+ this.w = [];
1681
1691
  this.d = [];
1682
1692
  this.i = 0;
1683
1693
  this.j && (this.j = []);
1684
1694
  this.k && (this.k = []);
1685
1695
  }
1686
- if (this.o && !this.d[0]) {
1696
+ if (this.J && !this.d[0]) {
1687
1697
  this.d[0] = compute(
1688
- this.c[0] = new Owner(),
1689
- this.o,
1698
+ this.b[0] = new Owner(),
1699
+ this.J,
1690
1700
  null
1691
1701
  );
1692
1702
  }
1693
1703
  } else if (this.i === 0) {
1694
- if (this.c[0])
1695
- this.c[0].dispose();
1704
+ if (this.b[0])
1705
+ this.b[0].dispose();
1696
1706
  this.d = new Array(newLen);
1697
1707
  for (j = 0; j < newLen; j++) {
1698
- this.x[j] = newItems[j];
1699
- this.d[j] = compute(this.c[j] = new Owner(), mapper, null);
1708
+ this.w[j] = newItems[j];
1709
+ this.d[j] = compute(this.b[j] = new Owner(), mapper, null);
1700
1710
  }
1701
1711
  this.i = newLen;
1702
1712
  } else {
1703
1713
  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;
1704
- for (start = 0, end = Math.min(this.i, newLen); start < end && (this.x[start] === newItems[start] || this.j && compare(this.E, this.x[start], newItems[start])); start++) {
1714
+ 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++) {
1705
1715
  if (this.j)
1706
1716
  this.j[start].write(newItems[start]);
1707
1717
  }
1708
- for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.x[end] === newItems[newEnd] || this.j && compare(this.E, this.x[end], newItems[newEnd])); end--, newEnd--) {
1718
+ 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--) {
1709
1719
  temp[newEnd] = this.d[end];
1710
- tempNodes[newEnd] = this.c[end];
1720
+ tempNodes[newEnd] = this.b[end];
1711
1721
  tempRows && (tempRows[newEnd] = this.j[end]);
1712
1722
  tempIndexes && (tempIndexes[newEnd] = this.k[end]);
1713
1723
  }
@@ -1721,23 +1731,23 @@ function updateKeyedMap() {
1721
1731
  newIndices.set(key, j);
1722
1732
  }
1723
1733
  for (i = start; i <= end; i++) {
1724
- item = this.x[i];
1734
+ item = this.w[i];
1725
1735
  key = this.E ? this.E(item) : item;
1726
1736
  j = newIndices.get(key);
1727
1737
  if (j !== void 0 && j !== -1) {
1728
1738
  temp[j] = this.d[i];
1729
- tempNodes[j] = this.c[i];
1739
+ tempNodes[j] = this.b[i];
1730
1740
  tempRows && (tempRows[j] = this.j[i]);
1731
1741
  tempIndexes && (tempIndexes[j] = this.k[i]);
1732
1742
  j = newIndicesNext[j];
1733
1743
  newIndices.set(key, j);
1734
1744
  } else
1735
- this.c[i].dispose();
1745
+ this.b[i].dispose();
1736
1746
  }
1737
1747
  for (j = start; j < newLen; j++) {
1738
1748
  if (j in temp) {
1739
1749
  this.d[j] = temp[j];
1740
- this.c[j] = tempNodes[j];
1750
+ this.b[j] = tempNodes[j];
1741
1751
  if (tempRows) {
1742
1752
  this.j[j] = tempRows[j];
1743
1753
  this.j[j].write(newItems[j]);
@@ -1747,11 +1757,11 @@ function updateKeyedMap() {
1747
1757
  this.k[j].write(j);
1748
1758
  }
1749
1759
  } else {
1750
- this.d[j] = compute(this.c[j] = new Owner(), mapper, null);
1760
+ this.d[j] = compute(this.b[j] = new Owner(), mapper, null);
1751
1761
  }
1752
1762
  }
1753
1763
  this.d = this.d.slice(0, this.i = newLen);
1754
- this.x = newItems.slice(0);
1764
+ this.w = newItems.slice(0);
1755
1765
  }
1756
1766
  });
1757
1767
  return this.d;
@@ -1760,59 +1770,59 @@ function repeat(count, map, options) {
1760
1770
  return updateRepeat.bind({
1761
1771
  I: new Owner(),
1762
1772
  i: 0,
1763
- r: 0,
1764
- Z: count,
1773
+ q: 0,
1774
+ $: count,
1765
1775
  D: map,
1766
- c: [],
1776
+ b: [],
1767
1777
  d: [],
1768
- _: options?.from,
1769
- o: options?.fallback
1778
+ aa: options?.from,
1779
+ J: options?.fallback
1770
1780
  });
1771
1781
  }
1772
1782
  function updateRepeat() {
1773
- const newLen = this.Z();
1774
- const from = this._?.() || 0;
1783
+ const newLen = this.$();
1784
+ const from = this.aa?.() || 0;
1775
1785
  runWithOwner(this.I, () => {
1776
1786
  if (newLen === 0) {
1777
1787
  if (this.i !== 0) {
1778
1788
  this.I.dispose(false);
1779
- this.c = [];
1789
+ this.b = [];
1780
1790
  this.d = [];
1781
1791
  this.i = 0;
1782
1792
  }
1783
- if (this.o && !this.d[0]) {
1793
+ if (this.J && !this.d[0]) {
1784
1794
  this.d[0] = compute(
1785
- this.c[0] = new Owner(),
1786
- this.o,
1795
+ this.b[0] = new Owner(),
1796
+ this.J,
1787
1797
  null
1788
1798
  );
1789
1799
  }
1790
1800
  return;
1791
1801
  }
1792
1802
  const to = from + newLen;
1793
- const prevTo = this.r + this.i;
1794
- if (this.i === 0 && this.c[0])
1795
- this.c[0].dispose();
1803
+ const prevTo = this.q + this.i;
1804
+ if (this.i === 0 && this.b[0])
1805
+ this.b[0].dispose();
1796
1806
  for (let i = to; i < prevTo; i++)
1797
- this.c[i - this.r].dispose();
1798
- if (this.r < from) {
1799
- let i = this.r;
1807
+ this.b[i - this.q].dispose();
1808
+ if (this.q < from) {
1809
+ let i = this.q;
1800
1810
  while (i < from && i < this.i)
1801
- this.c[i++].dispose();
1802
- this.c.splice(0, from - this.r);
1803
- this.d.splice(0, from - this.r);
1804
- } else if (this.r > from) {
1805
- let i = prevTo - this.r - 1;
1806
- let difference = this.r - from;
1807
- this.c.length = this.d.length = newLen;
1811
+ this.b[i++].dispose();
1812
+ this.b.splice(0, from - this.q);
1813
+ this.d.splice(0, from - this.q);
1814
+ } else if (this.q > from) {
1815
+ let i = prevTo - this.q - 1;
1816
+ let difference = this.q - from;
1817
+ this.b.length = this.d.length = newLen;
1808
1818
  while (i >= difference) {
1809
- this.c[i] = this.c[i - difference];
1819
+ this.b[i] = this.b[i - difference];
1810
1820
  this.d[i] = this.d[i - difference];
1811
1821
  i--;
1812
1822
  }
1813
1823
  for (let i2 = 0; i2 < difference; i2++) {
1814
1824
  this.d[i2] = compute(
1815
- this.c[i2] = new Owner(),
1825
+ this.b[i2] = new Owner(),
1816
1826
  () => this.D(i2 + from),
1817
1827
  null
1818
1828
  );
@@ -1820,13 +1830,13 @@ function updateRepeat() {
1820
1830
  }
1821
1831
  for (let i = prevTo; i < to; i++) {
1822
1832
  this.d[i - from] = compute(
1823
- this.c[i - from] = new Owner(),
1833
+ this.b[i - from] = new Owner(),
1824
1834
  () => this.D(i),
1825
1835
  null
1826
1836
  );
1827
1837
  }
1828
1838
  this.d = this.d.slice(0, newLen);
1829
- this.r = from;
1839
+ this.q = from;
1830
1840
  this.i = newLen;
1831
1841
  });
1832
1842
  return this.d;
@@ -1835,4 +1845,4 @@ function compare(key, a, b) {
1835
1845
  return key ? key(a) === key(b) : true;
1836
1846
  }
1837
1847
 
1838
- export { $PROXY, $RAW, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, SUPPORTS_PROXY, catchError, createAsync, createBoundary, createContext, createEffect, createErrorBoundary, createMemo, createProjection, createRenderEffect, createRoot, createSignal, createStore, createSuspense, deep, flatten, flushSync, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, repeat, resolve, runWithObserver, runWithOwner, setContext, untrack, unwrap };
1848
+ export { $PROXY, $RAW, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, SUPPORTS_PROXY, createAsync, createBoundary, createContext, createEffect, createErrorBoundary, createMemo, createProjection, createRenderEffect, createRoot, createSignal, createStore, createSuspense, deep, flatten, flushSync, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, repeat, resolve, runWithObserver, runWithOwner, setContext, tryCatch, untrack, unwrap };