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