@solidjs/signals 0.0.5 → 0.0.7

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/dev.js CHANGED
@@ -622,16 +622,21 @@ var Queue = class {
622
622
  runEffectQueue(effects);
623
623
  }
624
624
  }
625
+ let rerun = false;
625
626
  for (let i = 0; i < this._children.length; i++) {
626
- this._children[i].run(type);
627
+ rerun = this._children[i].run(type) || rerun;
627
628
  }
629
+ if (type === EFFECT_PURE && this._queues[type].length)
630
+ return true;
628
631
  }
629
632
  flush() {
630
633
  if (this._running)
631
634
  return;
632
635
  this._running = true;
633
636
  try {
634
- this.run(EFFECT_PURE);
637
+ while (this.run(EFFECT_PURE)) {
638
+ }
639
+ ;
635
640
  incrementClock();
636
641
  scheduled = false;
637
642
  this.run(EFFECT_RENDER);
@@ -775,7 +780,7 @@ var SuspenseQueue = class extends Queue {
775
780
  run(type) {
776
781
  if (type && this._fallback)
777
782
  return;
778
- super.run(type);
783
+ return super.run(type);
779
784
  }
780
785
  _update(node) {
781
786
  if (node._stateFlags & LOADING_BIT) {
@@ -803,14 +808,14 @@ var LiveComputation = class extends EagerComputation {
803
808
  return this._value;
804
809
  }
805
810
  };
806
- function createSuspense(fn, fallbackFn) {
811
+ function createSuspense(fn, fallback) {
807
812
  const queue = new SuspenseQueue();
808
813
  const tree = createBoundary(() => {
809
814
  const child = new Computation(null, fn);
810
815
  return new LiveComputation(null, () => flatten(child.wait()));
811
816
  }, queue);
812
817
  const equality = new Computation(null, () => queue._signal.read() || queue._fallback);
813
- const comp = new Computation(null, () => equality.read() ? untrack(fallbackFn) : tree.read());
818
+ const comp = new Computation(null, () => equality.read() ? fallback() : tree.read());
814
819
  return comp.read.bind(comp);
815
820
  }
816
821
 
@@ -926,14 +931,36 @@ function runWithOwner(owner, run) {
926
931
  return void 0;
927
932
  }
928
933
  }
929
- function catchError(fn, handler) {
934
+ function createErrorBoundary(fn, fallback) {
930
935
  const owner = new Owner();
936
+ const error = new Computation(null, null);
937
+ const reset = new Computation(null, null, { equals: false });
938
+ const handler = (err) => error.write({ _error: err });
931
939
  owner._handlers = owner._handlers ? [handler, ...owner._handlers] : [handler];
932
- try {
933
- return compute(owner, fn, null);
934
- } catch (error) {
935
- owner.handleError(error);
936
- }
940
+ const guarded = compute(
941
+ owner,
942
+ () => {
943
+ const c = new Computation(null, () => (reset.read(), fn()));
944
+ const f = new Computation(null, () => flatten(c.read()));
945
+ f._setError = function(error2) {
946
+ this.handleError(error2);
947
+ };
948
+ return f;
949
+ },
950
+ null
951
+ );
952
+ const decision = new Computation(null, () => {
953
+ if (!error.read()) {
954
+ const resolved = guarded.read();
955
+ if (!error.read())
956
+ return resolved;
957
+ }
958
+ return fallback(error.read()._error, () => {
959
+ error.write(null);
960
+ reset.write(null);
961
+ });
962
+ });
963
+ return decision.read.bind(decision);
937
964
  }
938
965
 
939
966
  // src/store/store.ts
@@ -1414,10 +1441,10 @@ function updateKeyedMap() {
1414
1441
  runWithOwner(this._owner, () => {
1415
1442
  let i, j, mapper = this._rows ? () => {
1416
1443
  this._rows[j] = new Computation(newItems[j], null);
1417
- this._indexes[j] = new Computation(j, null);
1444
+ this._indexes && (this._indexes[j] = new Computation(j, null));
1418
1445
  return this._map(
1419
1446
  Computation.prototype.read.bind(this._rows[j]),
1420
- Computation.prototype.read.bind(this._indexes[j])
1447
+ this._indexes ? Computation.prototype.read.bind(this._indexes[j]) : void 0
1421
1448
  );
1422
1449
  } : this._indexes ? () => {
1423
1450
  const item = newItems[j];
@@ -1514,4 +1541,4 @@ function compare(key, a, b) {
1514
1541
  return key ? key(a) === key(b) : true;
1515
1542
  }
1516
1543
 
1517
- export { $PROXY, $RAW, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, SUPPORTS_PROXY, catchError, createAsync, createBoundary, createContext, createEffect, createMemo, createProjection, createRenderEffect, createRoot, createSignal, createStore, createSuspense, flatten, flushSync, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, runWithOwner, setContext, untrack, unwrap };
1544
+ export { $PROXY, $RAW, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, SUPPORTS_PROXY, createAsync, createBoundary, createContext, createEffect, createErrorBoundary, createMemo, createProjection, createRenderEffect, createRoot, createSignal, createStore, createSuspense, flatten, flushSync, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, runWithOwner, setContext, untrack, unwrap };