@solidjs/signals 0.13.12 → 2.0.0-beta.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.
Files changed (39) hide show
  1. package/README.md +8 -7
  2. package/dist/dev.js +188 -102
  3. package/dist/node.cjs +501 -446
  4. package/dist/prod.js +368 -305
  5. package/dist/types/core/graph.d.ts +1 -0
  6. package/dist/types/core/types.d.ts +2 -2
  7. package/dist/types/signals.d.ts +15 -21
  8. package/dist/types/store/optimistic.d.ts +2 -2
  9. package/dist/types/store/projection.d.ts +4 -4
  10. package/dist/types/store/store.d.ts +2 -2
  11. package/dist/types-cjs/boundaries.d.cts +52 -0
  12. package/dist/types-cjs/core/action.d.cts +1 -0
  13. package/dist/types-cjs/core/async.d.cts +6 -0
  14. package/dist/types-cjs/core/constants.d.cts +25 -0
  15. package/dist/types-cjs/core/context.d.cts +28 -0
  16. package/dist/types-cjs/core/core.d.cts +54 -0
  17. package/dist/types-cjs/core/dev.d.cts +49 -0
  18. package/dist/types-cjs/core/effect.d.cts +30 -0
  19. package/dist/types-cjs/core/error.d.cts +14 -0
  20. package/dist/types-cjs/core/external.d.cts +26 -0
  21. package/dist/types-cjs/core/graph.d.cts +4 -0
  22. package/dist/types-cjs/core/heap.d.cts +14 -0
  23. package/dist/types-cjs/core/index.d.cts +12 -0
  24. package/dist/types-cjs/core/lanes.d.cts +54 -0
  25. package/dist/types-cjs/core/owner.d.cts +26 -0
  26. package/dist/types-cjs/core/scheduler.d.cts +81 -0
  27. package/dist/types-cjs/core/types.d.cts +86 -0
  28. package/dist/types-cjs/index.d.cts +9 -0
  29. package/dist/types-cjs/map.d.cts +24 -0
  30. package/dist/types-cjs/package.json +3 -0
  31. package/dist/types-cjs/signals.d.cts +186 -0
  32. package/dist/types-cjs/store/index.d.cts +9 -0
  33. package/dist/types-cjs/store/optimistic.d.cts +19 -0
  34. package/dist/types-cjs/store/projection.d.cts +26 -0
  35. package/dist/types-cjs/store/reconcile.d.cts +1 -0
  36. package/dist/types-cjs/store/store.d.cts +68 -0
  37. package/dist/types-cjs/store/storePath.d.cts +30 -0
  38. package/dist/types-cjs/store/utils.d.cts +43 -0
  39. package/package.json +31 -24
@@ -1,3 +1,4 @@
1
1
  import type { Computed, Link, Signal } from "./types.js";
2
2
  export declare function unlinkSubs(link: Link): Link | null;
3
+ export declare function unobserved(el: Computed<unknown>): void;
3
4
  export declare function link(dep: Signal<any> | Computed<any>, sub: Computed<any>): void;
@@ -16,7 +16,7 @@ export interface NodeOptions<T> {
16
16
  name?: string;
17
17
  transparent?: boolean;
18
18
  equals?: ((prev: T, next: T) => boolean) | false;
19
- pureWrite?: boolean;
19
+ ownedWrite?: boolean;
20
20
  /** Exclude this signal from snapshot capture (internal — not part of public API) */
21
21
  _noSnapshot?: boolean;
22
22
  unobserved?: () => void;
@@ -29,7 +29,7 @@ export interface RawSignal<T> {
29
29
  _snapshotValue?: any;
30
30
  _name?: string;
31
31
  _equals: false | ((a: T, b: T) => boolean);
32
- _pureWrite?: boolean;
32
+ _ownedWrite?: boolean;
33
33
  _noSnapshot?: boolean;
34
34
  _unobserved?: () => void;
35
35
  _time: number;
@@ -29,7 +29,7 @@ export interface SignalOptions<T> {
29
29
  /** Custom equality function, or `false` to always notify subscribers */
30
30
  equals?: false | ((prev: T, next: T) => boolean);
31
31
  /** Suppress dev-mode warnings when writing inside an owned scope */
32
- pureWrite?: boolean;
32
+ ownedWrite?: boolean;
33
33
  /** Callback invoked when the signal loses all subscribers */
34
34
  unobserved?: () => void;
35
35
  }
@@ -56,7 +56,7 @@ export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
56
56
  /**
57
57
  * Creates a simple reactive state with a getter and setter.
58
58
  *
59
- * When called with a plain value, creates a signal with `SignalOptions` (name, equals, pureWrite, unobserved).
59
+ * When called with a plain value, creates a signal with `SignalOptions` (name, equals, ownedWrite, unobserved).
60
60
  * When called with a function, creates a writable memo with `SignalOptions & MemoOptions` (adds id, lazy).
61
61
  *
62
62
  * ```typescript
@@ -74,52 +74,46 @@ export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
74
74
  */
75
75
  export declare function createSignal<T>(): Signal<T | undefined>;
76
76
  export declare function createSignal<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
77
- export declare function createSignal<T>(fn: ComputeFunction<T>, initialValue?: T, options?: SignalOptions<T> & MemoOptions<T>): Signal<T>;
77
+ export declare function createSignal<T>(fn: ComputeFunction<T>, options?: SignalOptions<T> & MemoOptions<T>): Signal<T>;
78
78
  /**
79
79
  * Creates a readonly derived reactive memoized signal.
80
80
  *
81
81
  * ```typescript
82
- * const value = createMemo<T>(compute, initialValue?, options?: MemoOptions<T>);
82
+ * const value = createMemo<T>(compute, options?: MemoOptions<T>);
83
83
  * ```
84
- * @param compute a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
85
- * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
84
+ * @param compute a function that receives its previous value and returns a new value used to react on a computation
86
85
  * @param options `MemoOptions` -- id, name, equals, unobserved, lazy
87
86
  *
88
87
  * @description https://docs.solidjs.com/reference/basic-reactivity/create-memo
89
88
  */
90
- export declare function createMemo<Next extends Prev, Prev = Next>(compute: ComputeFunction<undefined | NoInfer<Prev>, Next>): Accessor<Next>;
91
- export declare function createMemo<Next extends Prev, Init = Next, Prev = Next>(compute: ComputeFunction<Init | Prev, Next>, value: Init, options?: MemoOptions<Next>): Accessor<Next>;
89
+ export declare function createMemo<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: MemoOptions<T>): Accessor<T>;
92
90
  /**
93
91
  * Creates a reactive effect that runs after the render phase.
94
92
  *
95
93
  * ```typescript
96
- * createEffect<T>(compute, effectFn | { effect, error }, initialValue?, options?: EffectOptions);
94
+ * createEffect<T>(compute, effectFn | { effect, error }, options?: EffectOptions);
97
95
  * ```
98
- * @param compute a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
96
+ * @param compute a function that receives its previous value and returns a new value used to react on a computation
99
97
  * @param effectFn a function that receives the new value and is used to perform side effects (return a cleanup function), or an `EffectBundle` with `effect` and `error` handlers
100
- * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
101
98
  * @param options `EffectOptions` -- name, defer
102
99
  *
103
100
  * @description https://docs.solidjs.com/reference/basic-reactivity/create-effect
104
101
  */
105
- export declare function createEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next> | EffectBundle<NoInfer<Next>, Next>): void;
106
- export declare function createEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effect: EffectFunction<Next, Next> | EffectBundle<Next, Next>, value: Init, options?: EffectOptions): void;
102
+ export declare function createEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effectFn: EffectFunction<NoInfer<T>, T> | EffectBundle<NoInfer<T>, T>, options?: EffectOptions): void;
107
103
  /**
108
104
  * Creates a reactive computation that runs during the render phase as DOM elements
109
105
  * are created and updated but not necessarily connected.
110
106
  *
111
107
  * ```typescript
112
- * createRenderEffect<T>(compute, effectFn, initialValue?, options?: EffectOptions);
108
+ * createRenderEffect<T>(compute, effectFn, options?: EffectOptions);
113
109
  * ```
114
- * @param compute a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
110
+ * @param compute a function that receives its previous value and returns a new value used to react on a computation
115
111
  * @param effectFn a function that receives the new value and is used to perform side effects
116
- * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
117
112
  * @param options `EffectOptions` -- name, defer
118
113
  *
119
114
  * @description https://docs.solidjs.com/reference/secondary-primitives/create-render-effect
120
115
  */
121
- export declare function createRenderEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next>): void;
122
- export declare function createRenderEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effectFn: EffectFunction<Next, Next>, value: Init, options?: EffectOptions): void;
116
+ export declare function createRenderEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effectFn: EffectFunction<NoInfer<T>, T>, options?: EffectOptions): void;
123
117
  /**
124
118
  * Creates a tracked reactive effect where dependency tracking and side effects happen
125
119
  * in the same scope.
@@ -159,14 +153,14 @@ export declare function resolve<T>(fn: () => T): Promise<T>;
159
153
  * Creates an optimistic signal that can be used to optimistically update a value
160
154
  * and then revert it back to the previous value at end of transition.
161
155
  *
162
- * When called with a plain value, creates an optimistic signal with `SignalOptions` (name, equals, pureWrite, unobserved).
156
+ * When called with a plain value, creates an optimistic signal with `SignalOptions` (name, equals, ownedWrite, unobserved).
163
157
  * When called with a function, creates a writable optimistic memo with `SignalOptions & MemoOptions` (adds id, lazy).
164
158
  *
165
159
  * ```typescript
166
160
  * // Plain optimistic signal
167
161
  * const [state, setState] = createOptimistic<T>(value, options?: SignalOptions<T>);
168
162
  * // Writable optimistic memo (function overload)
169
- * const [state, setState] = createOptimistic<T>(fn, initialValue?, options?: SignalOptions<T> & MemoOptions<T>);
163
+ * const [state, setState] = createOptimistic<T>(fn, options?: SignalOptions<T> & MemoOptions<T>);
170
164
  * ```
171
165
  * @param value initial value of the signal; if empty, the signal's type will automatically extended with undefined
172
166
  * @param options optional object with a name for debugging purposes and equals, a comparator function for the previous and next value to allow fine-grained control over the reactivity
@@ -177,7 +171,7 @@ export declare function resolve<T>(fn: () => T): Promise<T>;
177
171
  */
178
172
  export declare function createOptimistic<T>(): Signal<T | undefined>;
179
173
  export declare function createOptimistic<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
180
- export declare function createOptimistic<T>(fn: ComputeFunction<T>, initialValue?: T, options?: SignalOptions<T> & MemoOptions<T>): Signal<T>;
174
+ export declare function createOptimistic<T>(fn: ComputeFunction<T>, options?: SignalOptions<T> & MemoOptions<T>): Signal<T>;
181
175
  /**
182
176
  * Runs a callback after the current flush cycle completes.
183
177
  *
@@ -8,12 +8,12 @@ import { type NoFn, type ProjectionOptions, type Store, type StoreSetter } from
8
8
  * When called with a function, creates a derived optimistic store with `ProjectionOptions` (name, key, all).
9
9
  *
10
10
  * @param fn a function that receives the current store and can be used to mutate it directly inside a transition
11
- * @param initial The initial value of the store.
11
+ * @param store The plain store value, or the backing seed when using the derived-store form.
12
12
  * @param options Optional projection options for reconciliation.
13
13
  *
14
14
  * @returns A tuple containing a store accessor and a setter function to apply changes.
15
15
  */
16
16
  export declare function createOptimisticStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
17
- export declare function createOptimisticStore<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> & {
17
+ export declare function createOptimisticStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Store<T> & {
18
18
  [$REFRESH]: any;
19
19
  }, set: StoreSetter<T>];
@@ -1,6 +1,6 @@
1
1
  import { $REFRESH, type Computed } from "../core/index.js";
2
2
  import { type ProjectionOptions, type Store } from "./store.js";
3
- export declare function createProjectionInternal<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue?: T, options?: ProjectionOptions): {
3
+ export declare function createProjectionInternal<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T>, options?: ProjectionOptions): {
4
4
  store: Store<T> & {
5
5
  [$REFRESH]: any;
6
6
  };
@@ -11,15 +11,15 @@ export declare function createProjectionInternal<T extends object = {}>(fn: (dra
11
11
  * draft and can mutate it directly or return a new value for reconciliation.
12
12
  *
13
13
  * ```typescript
14
- * const store = createProjection<T>(fn, initialValue?, options?: ProjectionOptions);
14
+ * const store = createProjection<T>(fn, seed, options?: ProjectionOptions);
15
15
  * ```
16
16
  * @param fn a function that receives the current draft and mutates it or returns new data
17
- * @param initialValue the initial store value (defaults to `{}`)
17
+ * @param seed the backing store host value to wrap and reconcile into
18
18
  * @param options `ProjectionOptions` -- name, key, all
19
19
  *
20
20
  * @see {@link https://github.com/solidjs/x-reactivity#createprojection}
21
21
  */
22
- export declare function createProjection<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue?: T, options?: ProjectionOptions): Store<T> & {
22
+ export declare function createProjection<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, seed: Partial<T>, options?: ProjectionOptions): Store<T> & {
23
23
  [$REFRESH]: any;
24
24
  };
25
25
  export declare function createWriteTraps(isActive?: () => boolean): ProxyHandler<any>;
@@ -54,7 +54,7 @@ export declare function storeSetter<T extends object>(store: Store<T>, fn: (draf
54
54
  * // Plain store
55
55
  * const [store, setStore] = createStore<T>(initialValue);
56
56
  * // Derived store (projection)
57
- * const [store, setStore] = createStore<T>(fn, initialValue?, options?: ProjectionOptions);
57
+ * const [store, setStore] = createStore<T>(fn, seed, options?: ProjectionOptions);
58
58
  * ```
59
59
  * @param store initial value to wrap in a reactive proxy, or a derive function
60
60
  * @param options `ProjectionOptions` -- name, key, all (only for derived stores)
@@ -62,7 +62,7 @@ export declare function storeSetter<T extends object>(store: Store<T>, fn: (draf
62
62
  * @returns `[store: Store<T>, setStore: StoreSetter<T>]`
63
63
  */
64
64
  export declare function createStore<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
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> & {
65
+ export declare function createStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: Partial<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Store<T> & {
66
66
  [$REFRESH]: any;
67
67
  }, set: StoreSetter<T>];
68
68
  export {};
@@ -0,0 +1,52 @@
1
+ import { Queue, type Computed, type Effect } from "./core/index.cjs";
2
+ import type { Signal } from "./core/index.cjs";
3
+ export interface BoundaryComputed<T> extends Computed<T> {
4
+ _propagationMask: number;
5
+ }
6
+ type RevealSlot = CollectionQueue | RevealController;
7
+ type BoolAccessor = () => boolean;
8
+ export declare class RevealController {
9
+ _togetherAccessor: BoolAccessor;
10
+ _collapsedAccessor: BoolAccessor;
11
+ _slots: RevealSlot[];
12
+ _parentController?: RevealController;
13
+ _disabled: Signal<boolean>;
14
+ _collapsed: Signal<boolean>;
15
+ _ready: boolean;
16
+ _evaluating: boolean;
17
+ constructor(together: BoolAccessor, collapsed: BoolAccessor);
18
+ _forEachOwnedSlot(fn: (slot: RevealSlot) => boolean | void): boolean;
19
+ isReady(): boolean;
20
+ register(slot: RevealSlot): void;
21
+ unregister(slot: RevealSlot): void;
22
+ evaluate(disabledOverride?: boolean, collapsedOverride?: boolean): void;
23
+ }
24
+ export declare class CollectionQueue extends Queue {
25
+ _collectionType: number;
26
+ _sources: Set<Computed<any>>;
27
+ _tree?: BoundaryComputed<any>;
28
+ _pending: boolean;
29
+ _disabled: Signal<boolean>;
30
+ _collapsed: Signal<boolean>;
31
+ _revealController?: RevealController;
32
+ _initialized: boolean;
33
+ _onFn: (() => any) | undefined;
34
+ _prevOn: any;
35
+ constructor(type: number);
36
+ run(type: number): void;
37
+ notify(node: Effect<any>, type: number, flags: number, error?: any): boolean;
38
+ checkSources(): void;
39
+ }
40
+ export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
41
+ on?: () => any;
42
+ }): import("./signals.cjs").Accessor<unknown>;
43
+ export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): import("./signals.cjs").Accessor<unknown>;
44
+ export declare function createRevealOrder<T>(fn: () => T, options?: {
45
+ together?: BoolAccessor;
46
+ collapsed?: BoolAccessor;
47
+ }): T;
48
+ export declare function flatten(children: any, options?: {
49
+ skipNonRendered?: boolean;
50
+ doNotUnwrap?: boolean;
51
+ }): any;
52
+ export {};
@@ -0,0 +1 @@
1
+ export declare function action<Args extends any[], Y, R>(genFn: (...args: Args) => Generator<Y, R, any> | AsyncGenerator<Y, R, any>): (...args: Args) => Promise<R>;
@@ -0,0 +1,6 @@
1
+ import { type OptimisticLane } from "./lanes.cjs";
2
+ import type { Computed } from "./types.cjs";
3
+ export declare function settlePendingSource(el: Computed<any>): void;
4
+ export declare function handleAsync<T>(el: Computed<T>, result: T | PromiseLike<T> | AsyncIterable<T>, setter?: (value: T) => void): T;
5
+ export declare function clearStatus(el: Computed<any>, clearUninitialized?: boolean): void;
6
+ export declare function notifyStatus(el: Computed<any>, status: number, error: any, blockStatus?: boolean, lane?: OptimisticLane): void;
@@ -0,0 +1,25 @@
1
+ export declare const REACTIVE_NONE = 0;
2
+ export declare const REACTIVE_CHECK: number;
3
+ export declare const REACTIVE_DIRTY: number;
4
+ export declare const REACTIVE_RECOMPUTING_DEPS: number;
5
+ export declare const REACTIVE_IN_HEAP: number;
6
+ export declare const REACTIVE_IN_HEAP_HEIGHT: number;
7
+ export declare const REACTIVE_ZOMBIE: number;
8
+ export declare const REACTIVE_DISPOSED: number;
9
+ export declare const REACTIVE_OPTIMISTIC_DIRTY: number;
10
+ export declare const REACTIVE_SNAPSHOT_STALE: number;
11
+ export declare const REACTIVE_LAZY: number;
12
+ export declare const STATUS_NONE = 0;
13
+ export declare const STATUS_PENDING: number;
14
+ export declare const STATUS_ERROR: number;
15
+ export declare const STATUS_UNINITIALIZED: number;
16
+ export declare const EFFECT_PURE = 0;
17
+ export declare const EFFECT_RENDER = 1;
18
+ export declare const EFFECT_USER = 2;
19
+ export declare const EFFECT_TRACKED = 3;
20
+ export declare const NOT_PENDING: {};
21
+ export declare const NO_SNAPSHOT: {};
22
+ export declare const STORE_SNAPSHOT_PROPS = "sp";
23
+ export declare const SUPPORTS_PROXY: boolean;
24
+ export declare const defaultContext: {};
25
+ export declare const $REFRESH: unique symbol;
@@ -0,0 +1,28 @@
1
+ import type { Owner } from "./types.cjs";
2
+ export interface Context<T> {
3
+ readonly id: symbol;
4
+ readonly defaultValue: T | undefined;
5
+ }
6
+ export type ContextRecord = Record<string | symbol, unknown>;
7
+ /**
8
+ * Context provides a form of dependency injection. It is used to save from needing to pass
9
+ * data as props through intermediate components. This function creates a new context object
10
+ * that can be used with `getContext` and `setContext`.
11
+ *
12
+ * A default value can be provided here which will be used when a specific value is not provided
13
+ * via a `setContext` call.
14
+ */
15
+ export declare function createContext<T>(defaultValue?: T, description?: string): Context<T>;
16
+ /**
17
+ * Attempts to get a context value for the given key.
18
+ *
19
+ * @throws `NoOwnerError` if there's no owner at the time of call.
20
+ * @throws `ContextNotFoundError` if a context value has not been set yet.
21
+ */
22
+ export declare function getContext<T>(context: Context<T>, owner?: Owner | null): T;
23
+ /**
24
+ * Attempts to set a context value on the parent scope with the given key.
25
+ *
26
+ * @throws `NoOwnerError` if there's no owner at the time of call.
27
+ */
28
+ export declare function setContext<T>(context: Context<T>, value?: T, owner?: Owner | null): void;
@@ -0,0 +1,54 @@
1
+ import { $REFRESH } from "./constants.cjs";
2
+ import { type OptimisticLane } from "./lanes.cjs";
3
+ import type { Computed, FirewallSignal, NodeOptions, Owner, Signal } from "./types.cjs";
4
+ export declare let tracking: boolean;
5
+ export declare let stale: boolean;
6
+ export declare let refreshing: boolean;
7
+ export declare let pendingCheckActive: boolean;
8
+ export declare let foundPending: boolean;
9
+ export declare let latestReadActive: boolean;
10
+ export declare let context: Owner | null;
11
+ export declare let currentOptimisticLane: OptimisticLane | null;
12
+ export declare let snapshotCaptureActive: boolean;
13
+ export declare let snapshotSources: Set<any> | null;
14
+ export declare function setSnapshotCapture(active: boolean): void;
15
+ export declare function markSnapshotScope(owner: Owner): void;
16
+ export declare function releaseSnapshotScope(owner: Owner): void;
17
+ export declare function clearSnapshots(): void;
18
+ export declare function recompute(el: Computed<any>, create?: boolean): void;
19
+ export declare function computed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>): Computed<T>;
20
+ export declare function computed<T>(fn: (prev: T) => T | PromiseLike<T> | AsyncIterable<T>, initialValue?: T, options?: NodeOptions<T>): Computed<T>;
21
+ export declare function signal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
22
+ export declare function signal<T>(v: T, options?: NodeOptions<T>, firewall?: Computed<any>): FirewallSignal<T>;
23
+ export declare function optimisticSignal<T>(v: T, options?: NodeOptions<T>): Signal<T>;
24
+ export declare function optimisticComputed<T>(fn: (prev?: T) => T | PromiseLike<T> | AsyncIterable<T>, initialValue?: T, options?: NodeOptions<T>): Computed<T>;
25
+ export declare function isEqual<T>(a: T, b: T): boolean;
26
+ /**
27
+ * When set to a component name string, any reactive read that is not inside a nested tracking
28
+ * scope will log a dev-mode warning. Managed automatically by `untrack(fn, strictReadLabel)`.
29
+ */
30
+ export declare let strictRead: string | false;
31
+ export declare function setStrictRead(v: string | false): string | false;
32
+ /**
33
+ * Executes `fn` without tracking reactive dependencies.
34
+ *
35
+ * Pass a `strictReadLabel` string to enable strict-read warnings: any reactive read inside `fn`
36
+ * that is not inside a nested tracking scope will log a warning in dev mode.
37
+ */
38
+ export declare function untrack<T>(fn: () => T, strictReadLabel?: string | false): T;
39
+ export declare function read<T>(el: Signal<T> | Computed<T>): T;
40
+ export declare function setSignal<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)): T;
41
+ export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
42
+ /**
43
+ * Update _pendingSignal when pending state changes. When the override clears
44
+ * (pending -> not pending), merge the sub-lane into the source's lane so
45
+ * isPending effects are blocked until the full scope resolves.
46
+ */
47
+ export declare function updatePendingSignal(el: Signal<any> | Computed<any>): void;
48
+ export declare function staleValues<T>(fn: () => T, set?: boolean): T;
49
+ export declare function latest<T>(fn: () => T): T;
50
+ export declare function isPending(fn: () => any): boolean;
51
+ export declare function refresh<T>(fn: (() => T) | (T & {
52
+ [$REFRESH]: any;
53
+ })): T;
54
+ export declare function isRefreshing(): boolean;
@@ -0,0 +1,49 @@
1
+ import type { Computed, Owner, Signal } from "./types.cjs";
2
+ export interface DevHooks {
3
+ onOwner?: (owner: Owner) => void;
4
+ onGraph?: (value: any, owner: Owner | null) => void;
5
+ onUpdate?: () => void;
6
+ onStoreNodeUpdate?: (state: any, property: PropertyKey, value: any, prev: any) => void;
7
+ }
8
+ export type DiagnosticSeverity = "warn" | "error";
9
+ export type DiagnosticCode = "STRICT_READ_UNTRACKED" | "PENDING_ASYNC_UNTRACKED_READ" | "PENDING_ASYNC_FORBIDDEN_SCOPE" | "SIGNAL_WRITE_IN_OWNED_SCOPE" | "RUN_WITH_DISPOSED_OWNER" | "NO_OWNER_CLEANUP" | "CLEANUP_IN_FORBIDDEN_SCOPE" | "NO_OWNER_EFFECT" | "NO_OWNER_BOUNDARY" | "ASYNC_OUTSIDE_LOADING_BOUNDARY";
10
+ export type DiagnosticKind = "strict-read" | "async" | "write" | "lifecycle" | "owner";
11
+ export interface DiagnosticEvent {
12
+ sequence: number;
13
+ code: DiagnosticCode;
14
+ kind: DiagnosticKind;
15
+ severity: DiagnosticSeverity;
16
+ message: string;
17
+ ownerId?: string;
18
+ ownerName?: string;
19
+ nodeName?: string;
20
+ data?: Record<string, unknown>;
21
+ }
22
+ export type DiagnosticListener = (event: DiagnosticEvent) => void;
23
+ export interface DiagnosticCapture {
24
+ readonly events: readonly DiagnosticEvent[];
25
+ clear(): void;
26
+ stop(): DiagnosticEvent[];
27
+ }
28
+ export interface Diagnostics {
29
+ subscribe(listener: DiagnosticListener): () => void;
30
+ capture(): DiagnosticCapture;
31
+ }
32
+ export interface Dev {
33
+ hooks: DevHooks;
34
+ diagnostics: Diagnostics;
35
+ getChildren: typeof getChildren;
36
+ getSignals: typeof getSignals;
37
+ getParent: typeof getParent;
38
+ getSources: typeof getSources;
39
+ getObservers: typeof getObservers;
40
+ }
41
+ export declare const DEV: Dev;
42
+ export declare function emitDiagnostic(event: Omit<DiagnosticEvent, "sequence">): DiagnosticEvent;
43
+ export declare function registerGraph(value: any, owner: Owner | null): void;
44
+ export declare function clearSignals(node: Owner): void;
45
+ export declare function getChildren(owner: Owner): Owner[];
46
+ export declare function getSignals(owner: Owner): any[];
47
+ export declare function getParent(owner: Owner): Owner | null;
48
+ export declare function getSources(computation: Computed<any>): (Signal<any> | Computed<any>)[];
49
+ export declare function getObservers(node: Signal<any> | Computed<any>): Computed<any>[];
@@ -0,0 +1,30 @@
1
+ import type { Computed, NodeOptions, Owner } from "./types.cjs";
2
+ export interface Effect<T> extends Computed<T>, Owner {
3
+ _effectFn: (val: T, prev: T | undefined) => void | (() => void);
4
+ _errorFn?: (err: unknown, cleanup: () => void) => void;
5
+ _cleanup?: () => void;
6
+ _modified: boolean;
7
+ _prevValue: T | undefined;
8
+ _type: number;
9
+ }
10
+ /**
11
+ * Effects are the leaf nodes of our reactive graph. When their sources change, they are
12
+ * automatically added to the queue of effects to re-execute, which will cause them to fetch their
13
+ * sources and recompute
14
+ */
15
+ export declare function effect<T>(compute: (prev: T | undefined) => T, effect: (val: T, prev: T | undefined) => void | (() => void), error?: (err: unknown, cleanup: () => void) => void | (() => void), initialValue?: T, options?: NodeOptions<any> & {
16
+ render?: boolean;
17
+ defer?: boolean;
18
+ }): void;
19
+ export interface TrackedEffect extends Computed<void> {
20
+ _cleanup?: () => void;
21
+ _modified: boolean;
22
+ _type: number;
23
+ _run: () => void;
24
+ }
25
+ /**
26
+ * Internal tracked effect - bypasses heap, goes directly to effect queue.
27
+ * Runs as a leaf owner: child primitives and onCleanup are forbidden (__DEV__ throws).
28
+ * Uses stale reads.
29
+ */
30
+ export declare function trackedEffect(fn: () => void | (() => void), options?: NodeOptions<any>): void;
@@ -0,0 +1,14 @@
1
+ export declare class NotReadyError extends Error {
2
+ source: any;
3
+ constructor(source: any);
4
+ }
5
+ export declare class StatusError extends Error {
6
+ source: any;
7
+ constructor(source: any, original: any);
8
+ }
9
+ export declare class NoOwnerError extends Error {
10
+ constructor();
11
+ }
12
+ export declare class ContextNotFoundError extends Error {
13
+ constructor();
14
+ }
@@ -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;
@@ -0,0 +1,4 @@
1
+ import type { Computed, Link, Signal } from "./types.cjs";
2
+ export declare function unlinkSubs(link: Link): Link | null;
3
+ export declare function unobserved(el: Computed<unknown>): void;
4
+ export declare function link(dep: Signal<any> | Computed<any>, sub: Computed<any>): void;
@@ -0,0 +1,14 @@
1
+ import type { Computed } from "./types.cjs";
2
+ export interface Heap {
3
+ _heap: (Computed<unknown> | undefined)[];
4
+ _marked: boolean;
5
+ _min: number;
6
+ _max: number;
7
+ }
8
+ export declare function increaseHeapSize(n: number, heap: Heap): void;
9
+ export declare function insertIntoHeap(n: Computed<any>, heap: Heap): void;
10
+ export declare function insertIntoHeapHeight(n: Computed<unknown>, heap: Heap): void;
11
+ export declare function deleteFromHeap(n: Computed<unknown>, heap: Heap): void;
12
+ export declare function markHeap(heap: Heap): void;
13
+ export declare function markNode(el: Computed<unknown>, newState?: number): void;
14
+ export declare function runHeap(heap: Heap, recompute: (el: Computed<unknown>) => void): void;
@@ -0,0 +1,12 @@
1
+ export { ContextNotFoundError, NoOwnerError, NotReadyError } from "./error.cjs";
2
+ export { isEqual, untrack, runWithOwner, computed, signal, read, setSignal, optimisticSignal, optimisticComputed, isPending, latest, refresh, isRefreshing, staleValues, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots } from "./core.cjs";
3
+ export { enableExternalSource, _resetExternalSourceConfig, type ExternalSourceFactory, type ExternalSource, type ExternalSourceConfig } from "./external.cjs";
4
+ export { createOwner, createRoot, dispose, getNextChildId, getObserver, getOwner, isDisposed, cleanup, peekNextChildId } from "./owner.cjs";
5
+ export { createContext, getContext, setContext, type Context, type ContextRecord } from "./context.cjs";
6
+ export { handleAsync } from "./async.cjs";
7
+ export type { Computed, Disposable, FirewallSignal, Link, Owner, Root, Signal, NodeOptions } from "./types.cjs";
8
+ export { effect, trackedEffect, type Effect, type TrackedEffect } from "./effect.cjs";
9
+ export { action } from "./action.cjs";
10
+ export { flush, Queue, GlobalQueue, trackOptimisticStore, enforceLoadingBoundary, type IQueue, type QueueCallback } from "./scheduler.cjs";
11
+ export { DEV, type Dev, type DevHooks, type DiagnosticCapture, type DiagnosticCode, type DiagnosticEvent, type DiagnosticKind, type Diagnostics, type DiagnosticSeverity } from "./dev.cjs";
12
+ export * from "./constants.cjs";
@@ -0,0 +1,54 @@
1
+ import { type QueueCallback, type Transition } from "./scheduler.cjs";
2
+ import type { Computed, Signal } from "./types.cjs";
3
+ /**
4
+ * OptimisticLane represents the context for a single optimistic write.
5
+ * Each optimistic signal creates its own lane. Lanes merge when their
6
+ * dependency graphs overlap.
7
+ */
8
+ export interface OptimisticLane {
9
+ _source: Signal<any>;
10
+ _pendingAsync: Set<Computed<any>>;
11
+ _effectQueues: [QueueCallback[], QueueCallback[]];
12
+ _mergedInto: OptimisticLane | null;
13
+ _transition: Transition | null;
14
+ _parentLane: OptimisticLane | null;
15
+ }
16
+ export declare const signalLanes: WeakMap<Signal<any>, OptimisticLane>;
17
+ export declare const activeLanes: Set<OptimisticLane>;
18
+ /**
19
+ * Get an existing lane for a signal or create a new one.
20
+ * Reuses lane for multiple writes to the same signal.
21
+ */
22
+ export declare function getOrCreateLane(signal: Signal<any>): OptimisticLane;
23
+ /**
24
+ * Union-find: find the root lane.
25
+ */
26
+ export declare function findLane(lane: OptimisticLane): OptimisticLane;
27
+ /**
28
+ * Merge two lanes when their dependency graphs overlap.
29
+ */
30
+ export declare function mergeLanes(lane1: OptimisticLane, lane2: OptimisticLane): OptimisticLane;
31
+ /**
32
+ * Resolve a node's lane: follow union-find chain, verify active, clear if stale.
33
+ */
34
+ export declare function resolveLane(el: {
35
+ _optimisticLane?: OptimisticLane;
36
+ }): OptimisticLane | undefined;
37
+ export declare function resolveTransition(el: {
38
+ _optimisticLane?: OptimisticLane;
39
+ _transition?: Transition | null;
40
+ }): Transition | null | undefined;
41
+ /**
42
+ * Check if a node has an active optimistic override.
43
+ */
44
+ export declare function hasActiveOverride(el: {
45
+ _overrideValue?: any;
46
+ }): boolean;
47
+ /**
48
+ * Assign or merge a lane onto a node. At convergence points (node already has
49
+ * a different active lane), merge unless the node has an active override.
50
+ */
51
+ export declare function assignOrMergeLane(el: {
52
+ _optimisticLane?: OptimisticLane;
53
+ _overrideValue?: any;
54
+ }, sourceLane: OptimisticLane): void;
@@ -0,0 +1,26 @@
1
+ import type { Computed, Disposable, Owner, Root } from "./types.cjs";
2
+ export declare function markDisposal(el: Owner): void;
3
+ export declare function dispose(node: Computed<unknown>): void;
4
+ export declare function disposeChildren(node: Owner, self?: boolean, zombie?: boolean): void;
5
+ export declare function getNextChildId(owner: Owner): string;
6
+ export declare function peekNextChildId(owner: Owner): string;
7
+ export declare function getObserver(): Owner | null;
8
+ export declare function getOwner(): Owner | null;
9
+ export declare function cleanup(fn: Disposable): Disposable;
10
+ export declare function isDisposed(node: Owner): boolean;
11
+ export declare function createOwner(options?: {
12
+ id?: string;
13
+ transparent?: boolean;
14
+ }): Root;
15
+ /**
16
+ * Creates a new non-tracked reactive context with manual disposal
17
+ *
18
+ * @param fn a function in which the reactive state is scoped
19
+ * @returns the output of `fn`.
20
+ *
21
+ * @description https://docs.solidjs.com/reference/reactive-utilities/create-root
22
+ */
23
+ export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T), options?: {
24
+ id?: string;
25
+ transparent?: boolean;
26
+ }): T;