@solidjs/signals 0.2.2 → 0.2.3

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
@@ -138,60 +138,6 @@ function runEffectQueue(queue) {
138
138
  function isUndefined(value) {
139
139
  return typeof value === "undefined";
140
140
  }
141
- function flatten(children, options) {
142
- if (typeof children === "function" && !children.length) {
143
- if (options?.doNotUnwrap)
144
- return children;
145
- do {
146
- children = children();
147
- } while (typeof children === "function" && !children.length);
148
- }
149
- if (options?.skipNonRendered && (children == null || children === true || children === false || children === ""))
150
- return;
151
- if (Array.isArray(children)) {
152
- let results = [];
153
- if (flattenArray(children, results, options)) {
154
- return () => {
155
- let nested = [];
156
- flattenArray(results, nested, { ...options, doNotUnwrap: false });
157
- return nested;
158
- };
159
- }
160
- return results;
161
- }
162
- return children;
163
- }
164
- function flattenArray(children, results = [], options) {
165
- let notReady = null;
166
- let needsUnwrap = false;
167
- for (let i = 0; i < children.length; i++) {
168
- try {
169
- let child = children[i];
170
- if (typeof child === "function" && !child.length) {
171
- if (options?.doNotUnwrap) {
172
- results.push(child);
173
- needsUnwrap = true;
174
- continue;
175
- }
176
- do {
177
- child = child();
178
- } while (typeof child === "function" && !child.length);
179
- }
180
- if (Array.isArray(child)) {
181
- needsUnwrap = flattenArray(child, results, options);
182
- } else if (options?.skipNonRendered && (child == null || child === true || child === false || child === "")) {
183
- } else
184
- results.push(child);
185
- } catch (e) {
186
- if (!(e instanceof NotReadyError))
187
- throw e;
188
- notReady = e;
189
- }
190
- }
191
- if (notReady)
192
- throw notReady;
193
- return needsUnwrap;
194
- }
195
141
 
196
142
  // src/core/owner.ts
197
143
  var currentOwner = null;
@@ -754,6 +700,68 @@ function compute(owner, fn, observer) {
754
700
  notStale = prevNotStale;
755
701
  }
756
702
  }
703
+ function flatten(children, options) {
704
+ try {
705
+ if (typeof children === "function" && !children.length) {
706
+ if (options?.doNotUnwrap)
707
+ return children;
708
+ do {
709
+ children = children();
710
+ } while (typeof children === "function" && !children.length);
711
+ }
712
+ if (options?.skipNonRendered && (children == null || children === true || children === false || children === ""))
713
+ return;
714
+ if (Array.isArray(children)) {
715
+ let results = [];
716
+ if (flattenArray(children, results, options)) {
717
+ return () => {
718
+ let nested = [];
719
+ flattenArray(results, nested, { ...options, doNotUnwrap: false });
720
+ return nested;
721
+ };
722
+ }
723
+ return results;
724
+ }
725
+ return children;
726
+ } catch (e) {
727
+ if (options?.skipNonRendered && e instanceof NotReadyError) {
728
+ newFlags |= LOADING_BIT;
729
+ return void 0;
730
+ }
731
+ throw e;
732
+ }
733
+ }
734
+ function flattenArray(children, results = [], options) {
735
+ let notReady = null;
736
+ let needsUnwrap = false;
737
+ for (let i = 0; i < children.length; i++) {
738
+ try {
739
+ let child = children[i];
740
+ if (typeof child === "function" && !child.length) {
741
+ if (options?.doNotUnwrap) {
742
+ results.push(child);
743
+ needsUnwrap = true;
744
+ continue;
745
+ }
746
+ do {
747
+ child = child();
748
+ } while (typeof child === "function" && !child.length);
749
+ }
750
+ if (Array.isArray(child)) {
751
+ needsUnwrap = flattenArray(child, results, options);
752
+ } else if (options?.skipNonRendered && (child == null || child === true || child === false || child === "")) {
753
+ } else
754
+ results.push(child);
755
+ } catch (e) {
756
+ if (!(e instanceof NotReadyError))
757
+ throw e;
758
+ notReady = e;
759
+ }
760
+ }
761
+ if (notReady)
762
+ throw notReady;
763
+ return needsUnwrap;
764
+ }
757
765
  function createBoundary(fn, queue) {
758
766
  const owner = new Owner();
759
767
  const parentQueue = owner._queue;
@@ -777,7 +785,7 @@ var Effect = class extends Computation {
777
785
  this._prevValue = initialValue;
778
786
  this._type = options?.render ? EFFECT_RENDER : EFFECT_USER;
779
787
  if (this._type === EFFECT_RENDER) {
780
- this._compute = (p) => getClock() > this._queue.created ? latest(() => compute2(p)) : compute2(p);
788
+ this._compute = (p) => getClock() > this._queue.created && !(this._stateFlags & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
781
789
  }
782
790
  this._updateIfNecessary();
783
791
  !options?.defer && (this._type === EFFECT_USER ? this._queue.enqueue(this._type, this) : this._runEffect());
@@ -808,9 +816,9 @@ var Effect = class extends Computation {
808
816
  _setError(error) {
809
817
  this._cleanup?.();
810
818
  if (this._stateFlags & LOADING_BIT) {
811
- this._stateFlags = 0;
812
819
  this._queue._update?.(this);
813
820
  }
821
+ this._stateFlags = ERROR_BIT;
814
822
  if (this._type === EFFECT_USER) {
815
823
  try {
816
824
  return this._onerror ? this._cleanup = this._onerror(error) : console.error(new EffectError(this._effect, error));
@@ -1439,7 +1447,7 @@ function reconcile(value, key) {
1439
1447
  };
1440
1448
  }
1441
1449
 
1442
- // src/store/utilities.ts
1450
+ // src/store/utils.ts
1443
1451
  function trueFn() {
1444
1452
  return true;
1445
1453
  }
package/dist/node.cjs CHANGED
@@ -134,60 +134,6 @@ function runEffectQueue(queue) {
134
134
  function isUndefined(value) {
135
135
  return typeof value === "undefined";
136
136
  }
137
- function flatten(children, options) {
138
- if (typeof children === "function" && !children.length) {
139
- if (options == null ? void 0 : options.doNotUnwrap)
140
- return children;
141
- do {
142
- children = children();
143
- } while (typeof children === "function" && !children.length);
144
- }
145
- if ((options == null ? void 0 : options.skipNonRendered) && (children == null || children === true || children === false || children === ""))
146
- return;
147
- if (Array.isArray(children)) {
148
- let results = [];
149
- if (flattenArray(children, results, options)) {
150
- return () => {
151
- let nested = [];
152
- flattenArray(results, nested, { ...options, doNotUnwrap: false });
153
- return nested;
154
- };
155
- }
156
- return results;
157
- }
158
- return children;
159
- }
160
- function flattenArray(children, results = [], options) {
161
- let notReady = null;
162
- let needsUnwrap = false;
163
- for (let i = 0; i < children.length; i++) {
164
- try {
165
- let child = children[i];
166
- if (typeof child === "function" && !child.length) {
167
- if (options == null ? void 0 : options.doNotUnwrap) {
168
- results.push(child);
169
- needsUnwrap = true;
170
- continue;
171
- }
172
- do {
173
- child = child();
174
- } while (typeof child === "function" && !child.length);
175
- }
176
- if (Array.isArray(child)) {
177
- needsUnwrap = flattenArray(child, results, options);
178
- } else if ((options == null ? void 0 : options.skipNonRendered) && (child == null || child === true || child === false || child === "")) {
179
- } else
180
- results.push(child);
181
- } catch (e) {
182
- if (!(e instanceof NotReadyError))
183
- throw e;
184
- notReady = e;
185
- }
186
- }
187
- if (notReady)
188
- throw notReady;
189
- return needsUnwrap;
190
- }
191
137
 
192
138
  // src/core/owner.ts
193
139
  var currentOwner = null;
@@ -751,6 +697,68 @@ function compute(owner, fn, observer) {
751
697
  notStale = prevNotStale;
752
698
  }
753
699
  }
700
+ function flatten(children, options) {
701
+ try {
702
+ if (typeof children === "function" && !children.length) {
703
+ if (options == null ? void 0 : options.doNotUnwrap)
704
+ return children;
705
+ do {
706
+ children = children();
707
+ } while (typeof children === "function" && !children.length);
708
+ }
709
+ if ((options == null ? void 0 : options.skipNonRendered) && (children == null || children === true || children === false || children === ""))
710
+ return;
711
+ if (Array.isArray(children)) {
712
+ let results = [];
713
+ if (flattenArray(children, results, options)) {
714
+ return () => {
715
+ let nested = [];
716
+ flattenArray(results, nested, { ...options, doNotUnwrap: false });
717
+ return nested;
718
+ };
719
+ }
720
+ return results;
721
+ }
722
+ return children;
723
+ } catch (e) {
724
+ if ((options == null ? void 0 : options.skipNonRendered) && e instanceof NotReadyError) {
725
+ newFlags |= LOADING_BIT;
726
+ return void 0;
727
+ }
728
+ throw e;
729
+ }
730
+ }
731
+ function flattenArray(children, results = [], options) {
732
+ let notReady = null;
733
+ let needsUnwrap = false;
734
+ for (let i = 0; i < children.length; i++) {
735
+ try {
736
+ let child = children[i];
737
+ if (typeof child === "function" && !child.length) {
738
+ if (options == null ? void 0 : options.doNotUnwrap) {
739
+ results.push(child);
740
+ needsUnwrap = true;
741
+ continue;
742
+ }
743
+ do {
744
+ child = child();
745
+ } while (typeof child === "function" && !child.length);
746
+ }
747
+ if (Array.isArray(child)) {
748
+ needsUnwrap = flattenArray(child, results, options);
749
+ } else if ((options == null ? void 0 : options.skipNonRendered) && (child == null || child === true || child === false || child === "")) {
750
+ } else
751
+ results.push(child);
752
+ } catch (e) {
753
+ if (!(e instanceof NotReadyError))
754
+ throw e;
755
+ notReady = e;
756
+ }
757
+ }
758
+ if (notReady)
759
+ throw notReady;
760
+ return needsUnwrap;
761
+ }
754
762
  function createBoundary(fn, queue) {
755
763
  const owner = new Owner();
756
764
  const parentQueue = owner.h;
@@ -774,7 +782,7 @@ var Effect = class extends Computation {
774
782
  this.M = initialValue;
775
783
  this.u = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
776
784
  if (this.u === EFFECT_RENDER) {
777
- this.A = (p) => getClock() > this.h.created ? latest(() => compute2(p)) : compute2(p);
785
+ this.A = (p) => getClock() > this.h.created && !(this.d & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
778
786
  }
779
787
  this.y();
780
788
  !(options == null ? void 0 : options.defer) && (this.u === EFFECT_USER ? this.h.enqueue(this.u, this) : this.T());
@@ -805,9 +813,9 @@ var Effect = class extends Computation {
805
813
  var _a, _b, _c;
806
814
  (_a = this.B) == null ? void 0 : _a.call(this);
807
815
  if (this.d & LOADING_BIT) {
808
- this.d = 0;
809
816
  (_c = (_b = this.h).R) == null ? void 0 : _c.call(_b, this);
810
817
  }
818
+ this.d = ERROR_BIT;
811
819
  if (this.u === EFFECT_USER) {
812
820
  try {
813
821
  return this.L ? this.B = this.L(error) : console.error(new EffectError(this.K, error));
@@ -1439,7 +1447,7 @@ function reconcile(value, key) {
1439
1447
  };
1440
1448
  }
1441
1449
 
1442
- // src/store/utilities.ts
1450
+ // src/store/utils.ts
1443
1451
  function trueFn() {
1444
1452
  return true;
1445
1453
  }
package/dist/prod.js CHANGED
@@ -132,60 +132,6 @@ function runEffectQueue(queue) {
132
132
  function isUndefined(value) {
133
133
  return typeof value === "undefined";
134
134
  }
135
- function flatten(children, options) {
136
- if (typeof children === "function" && !children.length) {
137
- if (options?.doNotUnwrap)
138
- return children;
139
- do {
140
- children = children();
141
- } while (typeof children === "function" && !children.length);
142
- }
143
- if (options?.skipNonRendered && (children == null || children === true || children === false || children === ""))
144
- return;
145
- if (Array.isArray(children)) {
146
- let results = [];
147
- if (flattenArray(children, results, options)) {
148
- return () => {
149
- let nested = [];
150
- flattenArray(results, nested, { ...options, doNotUnwrap: false });
151
- return nested;
152
- };
153
- }
154
- return results;
155
- }
156
- return children;
157
- }
158
- function flattenArray(children, results = [], options) {
159
- let notReady = null;
160
- let needsUnwrap = false;
161
- for (let i = 0; i < children.length; i++) {
162
- try {
163
- let child = children[i];
164
- if (typeof child === "function" && !child.length) {
165
- if (options?.doNotUnwrap) {
166
- results.push(child);
167
- needsUnwrap = true;
168
- continue;
169
- }
170
- do {
171
- child = child();
172
- } while (typeof child === "function" && !child.length);
173
- }
174
- if (Array.isArray(child)) {
175
- needsUnwrap = flattenArray(child, results, options);
176
- } else if (options?.skipNonRendered && (child == null || child === true || child === false || child === "")) {
177
- } else
178
- results.push(child);
179
- } catch (e) {
180
- if (!(e instanceof NotReadyError))
181
- throw e;
182
- notReady = e;
183
- }
184
- }
185
- if (notReady)
186
- throw notReady;
187
- return needsUnwrap;
188
- }
189
135
 
190
136
  // src/core/owner.ts
191
137
  var currentOwner = null;
@@ -747,6 +693,68 @@ function compute(owner, fn, observer) {
747
693
  notStale = prevNotStale;
748
694
  }
749
695
  }
696
+ function flatten(children, options) {
697
+ try {
698
+ if (typeof children === "function" && !children.length) {
699
+ if (options?.doNotUnwrap)
700
+ return children;
701
+ do {
702
+ children = children();
703
+ } while (typeof children === "function" && !children.length);
704
+ }
705
+ if (options?.skipNonRendered && (children == null || children === true || children === false || children === ""))
706
+ return;
707
+ if (Array.isArray(children)) {
708
+ let results = [];
709
+ if (flattenArray(children, results, options)) {
710
+ return () => {
711
+ let nested = [];
712
+ flattenArray(results, nested, { ...options, doNotUnwrap: false });
713
+ return nested;
714
+ };
715
+ }
716
+ return results;
717
+ }
718
+ return children;
719
+ } catch (e) {
720
+ if (options?.skipNonRendered && e instanceof NotReadyError) {
721
+ newFlags |= LOADING_BIT;
722
+ return void 0;
723
+ }
724
+ throw e;
725
+ }
726
+ }
727
+ function flattenArray(children, results = [], options) {
728
+ let notReady = null;
729
+ let needsUnwrap = false;
730
+ for (let i = 0; i < children.length; i++) {
731
+ try {
732
+ let child = children[i];
733
+ if (typeof child === "function" && !child.length) {
734
+ if (options?.doNotUnwrap) {
735
+ results.push(child);
736
+ needsUnwrap = true;
737
+ continue;
738
+ }
739
+ do {
740
+ child = child();
741
+ } while (typeof child === "function" && !child.length);
742
+ }
743
+ if (Array.isArray(child)) {
744
+ needsUnwrap = flattenArray(child, results, options);
745
+ } else if (options?.skipNonRendered && (child == null || child === true || child === false || child === "")) {
746
+ } else
747
+ results.push(child);
748
+ } catch (e) {
749
+ if (!(e instanceof NotReadyError))
750
+ throw e;
751
+ notReady = e;
752
+ }
753
+ }
754
+ if (notReady)
755
+ throw notReady;
756
+ return needsUnwrap;
757
+ }
750
758
  function createBoundary(fn, queue) {
751
759
  const owner = new Owner();
752
760
  const parentQueue = owner.h;
@@ -770,7 +778,7 @@ var Effect = class extends Computation {
770
778
  this.M = initialValue;
771
779
  this.u = options?.render ? EFFECT_RENDER : EFFECT_USER;
772
780
  if (this.u === EFFECT_RENDER) {
773
- this.A = (p) => getClock() > this.h.created ? latest(() => compute2(p)) : compute2(p);
781
+ this.A = (p) => getClock() > this.h.created && !(this.d & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
774
782
  }
775
783
  this.y();
776
784
  !options?.defer && (this.u === EFFECT_USER ? this.h.enqueue(this.u, this) : this.T());
@@ -799,9 +807,9 @@ var Effect = class extends Computation {
799
807
  F(error) {
800
808
  this.B?.();
801
809
  if (this.d & LOADING_BIT) {
802
- this.d = 0;
803
810
  this.h.R?.(this);
804
811
  }
812
+ this.d = ERROR_BIT;
805
813
  if (this.u === EFFECT_USER) {
806
814
  try {
807
815
  return this.L ? this.B = this.L(error) : console.error(new EffectError(this.K, error));
@@ -1426,7 +1434,7 @@ function reconcile(value, key) {
1426
1434
  };
1427
1435
  }
1428
1436
 
1429
- // src/store/utilities.ts
1437
+ // src/store/utils.ts
1430
1438
  function trueFn() {
1431
1439
  return true;
1432
1440
  }
@@ -162,5 +162,9 @@ export declare function runWithObserver<T>(observer: Computation, run: () => T):
162
162
  */
163
163
  export declare function compute<T>(owner: Owner | null, fn: (val: T) => T, observer: Computation<T>): T;
164
164
  export declare function compute<T>(owner: Owner | null, fn: (val: undefined) => T, observer: null): T;
165
+ export declare function flatten(children: any, options?: {
166
+ skipNonRendered?: boolean;
167
+ doNotUnwrap?: boolean;
168
+ }): any;
165
169
  export declare function createBoundary<T>(fn: () => T, queue: IQueue): T;
166
170
  export {};
@@ -1,9 +1,8 @@
1
1
  export { ContextNotFoundError, NoOwnerError, NotReadyError, type ErrorHandler } from "./error.js";
2
2
  export { Owner, createContext, getContext, setContext, hasContext, getOwner, onCleanup, type Context, type ContextRecord, type Disposable } from "./owner.js";
3
- export { Computation, createBoundary, getObserver, isEqual, untrack, hasUpdated, isPending, latest, catchError, UNCHANGED, compute, runWithObserver, type SignalOptions } from "./core.js";
3
+ export { Computation, createBoundary, getObserver, isEqual, untrack, hasUpdated, isPending, latest, flatten, catchError, UNCHANGED, compute, runWithObserver, type SignalOptions } from "./core.js";
4
4
  export { Effect, EagerComputation } from "./effect.js";
5
5
  export { flushSync, getClock, incrementClock, type IQueue, Queue } from "./scheduler.js";
6
6
  export { createSuspense } from "./suspense.js";
7
7
  export { SUPPORTS_PROXY } from "./constants.js";
8
8
  export * from "./flags.js";
9
- export { flatten } from "./utils.js";
@@ -1,5 +1 @@
1
1
  export declare function isUndefined(value: any): value is undefined;
2
- export declare function flatten(children: any, options?: {
3
- skipNonRendered?: boolean;
4
- doNotUnwrap?: boolean;
5
- }): any;
@@ -1,6 +1,6 @@
1
1
  export type { Store, StoreSetter, StoreNode, NotWrappable, SolidStore } from "./store.js";
2
- export type { Merge, Omit } from "./utilities.js";
2
+ export type { Merge, Omit } from "./utils.js";
3
3
  export { unwrap, isWrappable, createStore, $RAW, $TRACK, $PROXY, $TARGET } from "./store.js";
4
4
  export { createProjection } from "./projection.js";
5
5
  export { reconcile } from "./reconcile.js";
6
- export { merge, omit } from "./utilities.js";
6
+ export { merge, omit } from "./utils.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/signals",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
File without changes