@solidjs/signals 0.13.13 → 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.
- package/README.md +8 -7
- package/dist/dev.js +90 -61
- package/dist/node.cjs +156 -137
- package/dist/prod.js +108 -81
- package/dist/types/core/graph.d.ts +1 -0
- package/dist/types/core/types.d.ts +2 -2
- package/dist/types/signals.d.ts +15 -21
- package/dist/types/store/optimistic.d.ts +2 -2
- package/dist/types/store/projection.d.ts +4 -4
- package/dist/types/store/store.d.ts +2 -2
- package/dist/types-cjs/boundaries.d.cts +52 -0
- package/dist/types-cjs/core/action.d.cts +1 -0
- package/dist/types-cjs/core/async.d.cts +6 -0
- package/dist/types-cjs/core/constants.d.cts +25 -0
- package/dist/types-cjs/core/context.d.cts +28 -0
- package/dist/types-cjs/core/core.d.cts +54 -0
- package/dist/types-cjs/core/dev.d.cts +49 -0
- package/dist/types-cjs/core/effect.d.cts +30 -0
- package/dist/types-cjs/core/error.d.cts +14 -0
- package/dist/types-cjs/core/external.d.cts +26 -0
- package/dist/types-cjs/core/graph.d.cts +4 -0
- package/dist/types-cjs/core/heap.d.cts +14 -0
- package/dist/types-cjs/core/index.d.cts +12 -0
- package/dist/types-cjs/core/lanes.d.cts +54 -0
- package/dist/types-cjs/core/owner.d.cts +26 -0
- package/dist/types-cjs/core/scheduler.d.cts +81 -0
- package/dist/types-cjs/core/types.d.cts +86 -0
- package/dist/types-cjs/index.d.cts +9 -0
- package/dist/types-cjs/map.d.cts +24 -0
- package/dist/types-cjs/package.json +3 -0
- package/dist/types-cjs/signals.d.cts +186 -0
- package/dist/types-cjs/store/index.d.cts +9 -0
- package/dist/types-cjs/store/optimistic.d.cts +19 -0
- package/dist/types-cjs/store/projection.d.cts +26 -0
- package/dist/types-cjs/store/reconcile.d.cts +1 -0
- package/dist/types-cjs/store/store.d.cts +68 -0
- package/dist/types-cjs/store/storePath.d.cts +30 -0
- package/dist/types-cjs/store/utils.d.cts +43 -0
- package/package.json +31 -24
|
@@ -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;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type Heap } from "./heap.cjs";
|
|
2
|
+
import { activeLanes, assignOrMergeLane, findLane } from "./lanes.cjs";
|
|
3
|
+
import type { Computed, Signal } from "./types.cjs";
|
|
4
|
+
export { activeLanes, assignOrMergeLane, findLane };
|
|
5
|
+
export { getOrCreateLane, hasActiveOverride, mergeLanes, resolveLane } from "./lanes.cjs";
|
|
6
|
+
export declare const dirtyQueue: Heap;
|
|
7
|
+
export declare const zombieQueue: Heap;
|
|
8
|
+
export declare let clock: number;
|
|
9
|
+
export declare let activeTransition: Transition | null;
|
|
10
|
+
export declare let projectionWriteActive: boolean;
|
|
11
|
+
export declare let _hitUnhandledAsync: boolean;
|
|
12
|
+
export declare function resetUnhandledAsync(): void;
|
|
13
|
+
export declare function enforceLoadingBoundary(enabled: boolean): void;
|
|
14
|
+
export declare function shouldReadStashedOptimisticValue(node: Signal<any>): boolean;
|
|
15
|
+
export declare function setProjectionWriteActive(value: boolean): void;
|
|
16
|
+
export declare function setTrackedQueueCallback(value: boolean): void;
|
|
17
|
+
export type QueueCallback = (type: number) => void;
|
|
18
|
+
type QueueStub = {
|
|
19
|
+
_queues: [QueueCallback[], QueueCallback[]];
|
|
20
|
+
_children: QueueStub[];
|
|
21
|
+
};
|
|
22
|
+
type OptimisticNode = Signal<any> | Computed<any>;
|
|
23
|
+
export interface Transition {
|
|
24
|
+
_time: number;
|
|
25
|
+
_asyncReporters: Map<Computed<any>, Set<Computed<any>>>;
|
|
26
|
+
_pendingNodes: Signal<any>[];
|
|
27
|
+
_optimisticNodes: OptimisticNode[];
|
|
28
|
+
_optimisticStores: Set<any>;
|
|
29
|
+
_actions: Array<Generator<any, any, any> | AsyncGenerator<any, any, any>>;
|
|
30
|
+
_queueStash: QueueStub;
|
|
31
|
+
_done: boolean | Transition;
|
|
32
|
+
}
|
|
33
|
+
export declare function schedule(): void;
|
|
34
|
+
export interface IQueue {
|
|
35
|
+
enqueue(type: number, fn: QueueCallback): void;
|
|
36
|
+
run(type: number): boolean | void;
|
|
37
|
+
addChild(child: IQueue): void;
|
|
38
|
+
removeChild(child: IQueue): void;
|
|
39
|
+
created: number;
|
|
40
|
+
notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
|
|
41
|
+
stashQueues(stub: QueueStub): void;
|
|
42
|
+
restoreQueues(stub: QueueStub): void;
|
|
43
|
+
_parent: IQueue | null;
|
|
44
|
+
}
|
|
45
|
+
export declare class Queue implements IQueue {
|
|
46
|
+
_parent: IQueue | null;
|
|
47
|
+
_queues: [QueueCallback[], QueueCallback[]];
|
|
48
|
+
_children: IQueue[];
|
|
49
|
+
created: number;
|
|
50
|
+
addChild(child: IQueue): void;
|
|
51
|
+
removeChild(child: IQueue): void;
|
|
52
|
+
notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
|
|
53
|
+
run(type: number): void;
|
|
54
|
+
enqueue(type: number, fn: QueueCallback): void;
|
|
55
|
+
stashQueues(stub: QueueStub): void;
|
|
56
|
+
restoreQueues(stub: QueueStub): void;
|
|
57
|
+
}
|
|
58
|
+
export declare class GlobalQueue extends Queue {
|
|
59
|
+
_running: boolean;
|
|
60
|
+
_pendingNodes: Signal<any>[];
|
|
61
|
+
_optimisticNodes: OptimisticNode[];
|
|
62
|
+
_optimisticStores: Set<any>;
|
|
63
|
+
static _update: (el: Computed<unknown>) => void;
|
|
64
|
+
static _dispose: (el: Computed<unknown>, self: boolean, zombie: boolean) => void;
|
|
65
|
+
static _clearOptimisticStore: ((store: any) => void) | null;
|
|
66
|
+
flush(): void;
|
|
67
|
+
notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
|
|
68
|
+
initTransition(transition?: Transition | null): void;
|
|
69
|
+
}
|
|
70
|
+
export declare function insertSubs(node: Signal<any> | Computed<any>, optimistic?: boolean): void;
|
|
71
|
+
export declare function finalizePureQueue(completingTransition?: Transition | null, incomplete?: boolean): void;
|
|
72
|
+
export declare function trackOptimisticStore(store: any): void;
|
|
73
|
+
export declare const globalQueue: GlobalQueue;
|
|
74
|
+
/**
|
|
75
|
+
* By default, changes are batched on the microtask queue which is an async process. You can flush
|
|
76
|
+
* the queue synchronously to get the latest updates by calling `flush()`.
|
|
77
|
+
*/
|
|
78
|
+
export declare function flush(): void;
|
|
79
|
+
export declare function currentTransition(transition: Transition): Transition;
|
|
80
|
+
export declare function setActiveTransition(transition: Transition | null): void;
|
|
81
|
+
export declare function runInTransition<T>(transition: Transition, fn: () => T): T;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { NOT_PENDING } from "./constants.cjs";
|
|
2
|
+
import type { OptimisticLane } from "./lanes.cjs";
|
|
3
|
+
import type { IQueue, Transition } from "./scheduler.cjs";
|
|
4
|
+
export interface Disposable {
|
|
5
|
+
(): void;
|
|
6
|
+
}
|
|
7
|
+
export interface Link {
|
|
8
|
+
_dep: Signal<unknown> | Computed<unknown>;
|
|
9
|
+
_sub: Computed<unknown>;
|
|
10
|
+
_nextDep: Link | null;
|
|
11
|
+
_prevSub: Link | null;
|
|
12
|
+
_nextSub: Link | null;
|
|
13
|
+
}
|
|
14
|
+
export interface NodeOptions<T> {
|
|
15
|
+
id?: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
transparent?: boolean;
|
|
18
|
+
equals?: ((prev: T, next: T) => boolean) | false;
|
|
19
|
+
ownedWrite?: boolean;
|
|
20
|
+
/** Exclude this signal from snapshot capture (internal — not part of public API) */
|
|
21
|
+
_noSnapshot?: boolean;
|
|
22
|
+
unobserved?: () => void;
|
|
23
|
+
lazy?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface RawSignal<T> {
|
|
26
|
+
_subs: Link | null;
|
|
27
|
+
_subsTail: Link | null;
|
|
28
|
+
_value: T;
|
|
29
|
+
_snapshotValue?: any;
|
|
30
|
+
_name?: string;
|
|
31
|
+
_equals: false | ((a: T, b: T) => boolean);
|
|
32
|
+
_ownedWrite?: boolean;
|
|
33
|
+
_noSnapshot?: boolean;
|
|
34
|
+
_unobserved?: () => void;
|
|
35
|
+
_time: number;
|
|
36
|
+
_transition: Transition | null;
|
|
37
|
+
_pendingValue: T | typeof NOT_PENDING;
|
|
38
|
+
_overrideValue?: T | typeof NOT_PENDING;
|
|
39
|
+
_optimisticLane?: OptimisticLane;
|
|
40
|
+
_pendingSignal?: Signal<boolean>;
|
|
41
|
+
_latestValueComputed?: Computed<T>;
|
|
42
|
+
_parentSource?: Signal<any> | Computed<any>;
|
|
43
|
+
}
|
|
44
|
+
export interface FirewallSignal<T> extends RawSignal<T> {
|
|
45
|
+
_firewall: Computed<any>;
|
|
46
|
+
_nextChild: FirewallSignal<unknown> | null;
|
|
47
|
+
}
|
|
48
|
+
export type Signal<T> = RawSignal<T> | FirewallSignal<T>;
|
|
49
|
+
export interface Owner {
|
|
50
|
+
id?: string;
|
|
51
|
+
_transparent?: boolean;
|
|
52
|
+
_childrenForbidden?: boolean;
|
|
53
|
+
_snapshotScope?: boolean;
|
|
54
|
+
_disposal: Disposable | Disposable[] | null;
|
|
55
|
+
_parent: Owner | null;
|
|
56
|
+
_context: Record<symbol | string, unknown>;
|
|
57
|
+
_childCount: number;
|
|
58
|
+
_queue: IQueue;
|
|
59
|
+
_firstChild: Owner | null;
|
|
60
|
+
_nextSibling: Owner | null;
|
|
61
|
+
_pendingDisposal: Disposable | Disposable[] | null;
|
|
62
|
+
_pendingFirstChild: Owner | null;
|
|
63
|
+
}
|
|
64
|
+
export interface Computed<T> extends RawSignal<T>, Owner {
|
|
65
|
+
_deps: Link | null;
|
|
66
|
+
_depsTail: Link | null;
|
|
67
|
+
_flags: number;
|
|
68
|
+
_inSnapshotScope?: boolean;
|
|
69
|
+
_blocked?: boolean;
|
|
70
|
+
_pendingSource?: Computed<any>;
|
|
71
|
+
_pendingSources?: Set<Computed<any>>;
|
|
72
|
+
_error?: unknown;
|
|
73
|
+
_statusFlags: number;
|
|
74
|
+
_height: number;
|
|
75
|
+
_nextHeap: Computed<any> | undefined;
|
|
76
|
+
_prevHeap: Computed<any>;
|
|
77
|
+
_fn: (prev?: T) => T;
|
|
78
|
+
_inFlight: PromiseLike<T> | AsyncIterable<T> | null;
|
|
79
|
+
_child: FirewallSignal<any> | null;
|
|
80
|
+
_notifyStatus?: (status?: number, error?: any) => void;
|
|
81
|
+
}
|
|
82
|
+
export interface Root extends Owner {
|
|
83
|
+
_root: true;
|
|
84
|
+
_parentComputed: Computed<any> | null;
|
|
85
|
+
dispose(self?: boolean): void;
|
|
86
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { $REFRESH, ContextNotFoundError, NoOwnerError, NotReadyError, action, createContext, createOwner, createRoot, runWithOwner, flush, getNextChildId, peekNextChildId, getContext, setContext, getOwner, isDisposed, getObserver, isEqual, untrack, isPending, latest, isRefreshing, refresh, SUPPORTS_PROXY, setSnapshotCapture, markSnapshotScope, releaseSnapshotScope, clearSnapshots, enforceLoadingBoundary, enableExternalSource } from "./core/index.cjs";
|
|
2
|
+
import { type Dev } from "./core/index.cjs";
|
|
3
|
+
export declare const DEV: Dev | undefined;
|
|
4
|
+
export type { Owner, Context, ContextRecord, IQueue, ExternalSourceFactory, ExternalSource, ExternalSourceConfig, Dev, DevHooks, DiagnosticCapture, DiagnosticCode, DiagnosticEvent, DiagnosticKind, Diagnostics, DiagnosticSeverity } from "./core/index.cjs";
|
|
5
|
+
export { createSignal, createMemo, createEffect, createRenderEffect, createTrackedEffect, createReaction, createOptimistic, resolve, onSettled, onCleanup } from "./signals.cjs";
|
|
6
|
+
export type { Accessor, Setter, Signal, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, SignalOptions, MemoOptions, NoInfer } from "./signals.cjs";
|
|
7
|
+
export { mapArray, repeat, type Maybe } from "./map.cjs";
|
|
8
|
+
export * from "./store/index.cjs";
|
|
9
|
+
export { createLoadingBoundary, createErrorBoundary, createRevealOrder, flatten } from "./boundaries.cjs";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Accessor } from "./signals.cjs";
|
|
2
|
+
export type Maybe<T> = T | void | null | undefined | false;
|
|
3
|
+
/**
|
|
4
|
+
* Reactively transforms an array with a callback function - underlying helper for the `<For>` control flow
|
|
5
|
+
*
|
|
6
|
+
* similar to `Array.prototype.map`, but gets the value and index as accessors, transforms only values that changed and returns an accessor and reactively tracks changes to the list.
|
|
7
|
+
*
|
|
8
|
+
* @description https://docs.solidjs.com/reference/reactive-utilities/map-array
|
|
9
|
+
*/
|
|
10
|
+
export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Accessor<Item>, index: Accessor<number>) => MappedItem, options?: {
|
|
11
|
+
keyed?: boolean | ((item: Item) => any);
|
|
12
|
+
fallback?: Accessor<any>;
|
|
13
|
+
name?: string;
|
|
14
|
+
}): Accessor<MappedItem[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Reactively repeats a callback function the count provided - underlying helper for the `<Repeat>` control flow
|
|
17
|
+
*
|
|
18
|
+
* @description https://docs.solidjs.com/reference/reactive-utilities/repeat
|
|
19
|
+
*/
|
|
20
|
+
export declare function repeat(count: Accessor<number>, map: (index: number) => any, options?: {
|
|
21
|
+
from?: Accessor<number | undefined>;
|
|
22
|
+
fallback?: Accessor<any>;
|
|
23
|
+
name?: string;
|
|
24
|
+
}): Accessor<any[]>;
|