@solidjs/signals 0.12.0 → 0.13.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.
@@ -8,13 +8,17 @@ export declare class CollectionQueue extends Queue {
8
8
  _sources: Set<Computed<any>>;
9
9
  _disabled: Signal<boolean>;
10
10
  _initialized: boolean;
11
+ _onFn: (() => any) | undefined;
12
+ _prevOn: any;
11
13
  constructor(type: number);
12
14
  run(type: number): void;
13
15
  notify(node: Effect<any>, type: number, flags: number, error?: any): boolean;
14
16
  checkSources(): void;
15
17
  }
16
- export declare function createLoadBoundary(fn: () => any, fallback: () => any): () => unknown;
17
- export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): () => unknown;
18
+ export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
19
+ on?: () => any;
20
+ }): import("./signals.js").Accessor<unknown>;
21
+ export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): import("./signals.js").Accessor<unknown>;
18
22
  export declare function flatten(children: any, options?: {
19
23
  skipNonRendered?: boolean;
20
24
  doNotUnwrap?: boolean;
@@ -0,0 +1,26 @@
1
+ export type ExternalSourceFactory = (fn: (prev: any) => any, trigger: () => void) => ExternalSource;
2
+ export interface ExternalSource {
3
+ track: (prev: any) => any;
4
+ dispose: () => void;
5
+ }
6
+ export interface ExternalSourceConfig {
7
+ factory: ExternalSourceFactory;
8
+ untrack?: <T>(fn: () => T) => T;
9
+ }
10
+ export declare let externalSourceConfig: {
11
+ factory: ExternalSourceFactory;
12
+ untrack: <T>(fn: () => T) => T;
13
+ } | null;
14
+ /**
15
+ * Registers a factory that bridges external reactive systems (e.g. MobX, Vue refs)
16
+ * into Solid's tracking graph. Every computation will be wrapped so that the
17
+ * external library can track its own dependencies alongside Solid's.
18
+ *
19
+ * Multiple calls pipe together: each new factory wraps the previous one.
20
+ *
21
+ * @param config.factory receives `(fn, trigger)` — wrap fn execution in external tracking,
22
+ * call trigger when external deps change. Return `{ track, dispose }`.
23
+ * @param config.untrack optional wrapper for `untrack` — disables external tracking too.
24
+ */
25
+ export declare function enableExternalSource(config: ExternalSourceConfig): void;
26
+ export declare function _resetExternalSourceConfig(): void;
@@ -1,10 +1,11 @@
1
1
  export { ContextNotFoundError, NoOwnerError, NotReadyError } from "./error.js";
2
- export { isEqual, untrack, runWithOwner, computed, signal, read, setSignal, optimisticSignal, optimisticComputed, isPending, latest, refresh, isRefreshing, staleValues, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots, } from "./core.js";
2
+ export { isEqual, untrack, runWithOwner, computed, signal, read, setSignal, optimisticSignal, optimisticComputed, isPending, latest, refresh, isRefreshing, staleValues, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots } from "./core.js";
3
+ export { enableExternalSource, _resetExternalSourceConfig, type ExternalSourceFactory, type ExternalSource, type ExternalSourceConfig } from "./external.js";
3
4
  export { createOwner, createRoot, dispose, getNextChildId, getObserver, getOwner, isDisposed, onCleanup, peekNextChildId } from "./owner.js";
4
5
  export { createContext, getContext, setContext, type Context, type ContextRecord } from "./context.js";
5
6
  export { handleAsync } from "./async.js";
6
7
  export type { Computed, Disposable, FirewallSignal, Link, Owner, Root, Signal, NodeOptions } from "./types.js";
7
8
  export { effect, trackedEffect, type Effect, type TrackedEffect } from "./effect.js";
8
9
  export { action } from "./action.js";
9
- export { flush, Queue, GlobalQueue, trackOptimisticStore, setOnUnhandledAsync, type IQueue, type QueueCallback } from "./scheduler.js";
10
+ export { flush, Queue, GlobalQueue, trackOptimisticStore, enforceLoadingBoundary, type IQueue, type QueueCallback } from "./scheduler.js";
10
11
  export * from "./constants.js";
@@ -35,11 +35,10 @@ export declare function resolveLane(el: {
35
35
  _optimisticLane?: OptimisticLane;
36
36
  }): OptimisticLane | undefined;
37
37
  /**
38
- * Check if a node has an active optimistic override (pending value differs from base).
38
+ * Check if a node has an active optimistic override.
39
39
  */
40
40
  export declare function hasActiveOverride(el: {
41
- _optimistic?: boolean;
42
- _pendingValue?: any;
41
+ _overrideValue?: any;
43
42
  }): boolean;
44
43
  /**
45
44
  * Assign or merge a lane onto a node. At convergence points (node already has
@@ -47,6 +46,5 @@ export declare function hasActiveOverride(el: {
47
46
  */
48
47
  export declare function assignOrMergeLane(el: {
49
48
  _optimisticLane?: OptimisticLane;
50
- _optimistic?: boolean;
51
- _pendingValue?: any;
49
+ _overrideValue?: any;
52
50
  }, sourceLane: OptimisticLane): void;
@@ -8,7 +8,9 @@ export declare const zombieQueue: Heap;
8
8
  export declare let clock: number;
9
9
  export declare let activeTransition: Transition | null;
10
10
  export declare let projectionWriteActive: boolean;
11
- export declare function setOnUnhandledAsync(fn: (() => void) | null): void;
11
+ export declare let _hitUnhandledAsync: boolean;
12
+ export declare function resetUnhandledAsync(): void;
13
+ export declare function enforceLoadingBoundary(enabled: boolean): void;
12
14
  export declare function setProjectionWriteActive(value: boolean): void;
13
15
  export type QueueCallback = (type: number) => void;
14
16
  type QueueStub = {
@@ -32,7 +32,7 @@ export interface RawSignal<T> {
32
32
  _time: number;
33
33
  _transition: Transition | null;
34
34
  _pendingValue: T | typeof NOT_PENDING;
35
- _optimistic?: boolean;
35
+ _overrideValue?: T | typeof NOT_PENDING;
36
36
  _optimisticLane?: OptimisticLane;
37
37
  _pendingSignal?: Signal<boolean>;
38
38
  _latestValueComputed?: Computed<T>;
@@ -1,6 +1,7 @@
1
- export { $REFRESH, ContextNotFoundError, NoOwnerError, NotReadyError, action, createContext, createOwner, createRoot, runWithOwner, flush, getNextChildId, peekNextChildId, getContext, setContext, getOwner, onCleanup, isDisposed, getObserver, isEqual, untrack, isPending, latest, isRefreshing, refresh, SUPPORTS_PROXY, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots, setOnUnhandledAsync, } from "./core/index.js";
2
- export type { Owner, Context, ContextRecord, IQueue } from "./core/index.js";
3
- export * from "./signals.js";
1
+ export { $REFRESH, ContextNotFoundError, NoOwnerError, NotReadyError, action, createContext, createOwner, createRoot, runWithOwner, flush, getNextChildId, peekNextChildId, getContext, setContext, getOwner, onCleanup, isDisposed, getObserver, isEqual, untrack, isPending, latest, isRefreshing, refresh, SUPPORTS_PROXY, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots, enforceLoadingBoundary, enableExternalSource } from "./core/index.js";
2
+ export type { Owner, Context, ContextRecord, IQueue, ExternalSourceFactory, ExternalSource, ExternalSourceConfig } from "./core/index.js";
3
+ export { createSignal, createMemo, createEffect, createRenderEffect, createTrackedEffect, createReaction, createOptimistic, resolve, onSettled } from "./signals.js";
4
+ export type { Accessor, Setter, Signal, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, SignalOptions, MemoOptions, NoInfer } from "./signals.js";
4
5
  export { mapArray, repeat, type Maybe } from "./map.js";
5
6
  export * from "./store/index.js";
6
- export { createLoadBoundary, createErrorBoundary, flatten } from "./boundaries.js";
7
+ export { createLoadingBoundary, createErrorBoundary, flatten } from "./boundaries.js";
@@ -1,4 +1,5 @@
1
1
  export type Accessor<T> = () => T;
2
+ export declare function accessor<T>(node: any): Accessor<T>;
2
3
  export type Setter<in out T> = {
3
4
  <U extends T>(...args: undefined extends T ? [] : [value: Exclude<U, Function> | ((prev: T) => U)]): undefined extends T ? undefined : U;
4
5
  <U extends T>(value: (prev: T) => U): U;
@@ -1,9 +1,9 @@
1
1
  export type { Store, StoreSetter, StoreNode, StoreOptions, ProjectionOptions, NotWrappable, SolidStore } from "./store.js";
2
2
  export type { Merge, Omit } from "./utils.js";
3
- export { isWrappable, createStore, deep, $TRACK, $PROXY, $TARGET } from "./store.js";
3
+ export { isWrappable, createStore, $TRACK, $PROXY, $TARGET } from "./store.js";
4
4
  export { createProjection } from "./projection.js";
5
5
  export { createOptimisticStore } from "./optimistic.js";
6
6
  export { reconcile } from "./reconcile.js";
7
7
  export { storePath } from "./storePath.js";
8
8
  export type { PathSetter, Part, StorePathRange, ArrayFilterFn, CustomPartial } from "./storePath.js";
9
- export { snapshot, merge, omit } from "./utils.js";
9
+ export { snapshot, deep, merge, omit } from "./utils.js";
@@ -1 +1 @@
1
- export declare function reconcile<T extends U, U>(value: T, key: string | ((item: NonNullable<any>) => any), all?: boolean): (state: U) => void;
1
+ export declare function reconcile<T extends U, U>(value: T, key: string | ((item: NonNullable<any>) => any)): (state: U) => void;
@@ -10,13 +10,11 @@ export interface StoreOptions {
10
10
  export interface ProjectionOptions extends StoreOptions {
11
11
  /** Key property name or function for reconciliation identity */
12
12
  key?: string | ((item: NonNullable<any>) => any);
13
- /** When true, reconciles all properties (not just tracked ones) */
14
- all?: boolean;
15
13
  }
16
14
  export type NoFn<T> = T extends Function ? never : T;
17
15
  type DataNode = Signal<any>;
18
16
  type DataNodes = Record<PropertyKey, DataNode>;
19
- export declare const $TRACK: unique symbol, $DEEP: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol;
17
+ export declare const $TRACK: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol;
20
18
  export declare const STORE_VALUE = "v", STORE_OVERRIDE = "o", STORE_OPTIMISTIC_OVERRIDE = "x", STORE_NODE = "n", STORE_HAS = "h", STORE_WRAP = "w", STORE_LOOKUP = "l", STORE_FIREWALL = "f", STORE_OPTIMISTIC = "p";
21
19
  export type StoreNode = {
22
20
  [$PROXY]: any;
@@ -41,6 +39,7 @@ export declare const storeLookup: WeakMap<WeakKey, any>;
41
39
  export declare function wrap<T extends Record<PropertyKey, any>>(value: T, target?: StoreNode): T;
42
40
  export declare function isWrappable<T>(obj: T | NotWrappable): obj is T;
43
41
  export declare function setWriteOverride(value: boolean): void;
42
+ export declare function trackSelf(target: StoreNode, symbol?: symbol): void;
44
43
  export declare function getKeys(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, enumerable?: boolean): PropertyKey[];
45
44
  export declare function getPropertyDescriptor(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, property: PropertyKey): PropertyDescriptor | undefined;
46
45
  export declare const storeTraps: ProxyHandler<StoreNode>;
@@ -66,5 +65,4 @@ export declare function createStore<T extends object = {}>(store: NoFn<T> | Stor
66
65
  export declare function createStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store?: NoFn<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Store<T> & {
67
66
  [$REFRESH]: any;
68
67
  }, set: StoreSetter<T>];
69
- export declare function deep<T extends object>(store: Store<T>): Store<T>;
70
68
  export {};
@@ -1,3 +1,4 @@
1
+ import { type Store } from "./store.js";
1
2
  /**
2
3
  * Returns a non reactive copy of the store object.
3
4
  * It will attempt to preserver the original reference unless the value has been modified.
@@ -5,6 +6,13 @@
5
6
  */
6
7
  export declare function snapshot<T>(item: T): T;
7
8
  export declare function snapshot<T>(item: T, map?: Map<unknown, unknown>, lookup?: WeakMap<any, any>): T;
9
+ /**
10
+ * Returns a non-reactive snapshot of the store while subscribing to all nested changes.
11
+ * Subscribes to `$TRACK` at every level so that any deep change triggers recomputation,
12
+ * and returns plain (non-proxy) data. Works correctly with `reconcile()`.
13
+ * @param store store proxy object
14
+ */
15
+ export declare function deep<T extends object>(store: Store<T>): T;
8
16
  type DistributeOverride<T, F> = T extends undefined ? F : T;
9
17
  type Override<T, U> = T extends any ? U extends any ? {
10
18
  [K in keyof T]: K extends keyof U ? DistributeOverride<U[K], T[K]> : T[K];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/signals",
3
- "version": "0.12.0",
3
+ "version": "0.13.1",
4
4
  "description": "SolidJS' standalone reactivity implementation",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",