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