@solidjs/signals 0.13.13 → 2.0.0-beta.8
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 +312 -174
- package/dist/node.cjs +1068 -953
- package/dist/prod.js +744 -619
- package/dist/types/boundaries.d.ts +44 -3
- package/dist/types/core/core.d.ts +2 -2
- package/dist/types/core/effect.d.ts +3 -2
- package/dist/types/core/graph.d.ts +1 -0
- package/dist/types/core/scheduler.d.ts +1 -0
- package/dist/types/core/types.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/signals.d.ts +34 -26
- package/dist/types/store/optimistic.d.ts +3 -3
- package/dist/types/store/projection.d.ts +19 -5
- package/dist/types/store/store.d.ts +4 -4
- package/dist/types-cjs/boundaries.d.cts +93 -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 +31 -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 +82 -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 +200 -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 +40 -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,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,31 @@
|
|
|
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), options?: NodeOptions<any> & {
|
|
16
|
+
user?: boolean;
|
|
17
|
+
defer?: boolean;
|
|
18
|
+
schedule?: boolean;
|
|
19
|
+
}): void;
|
|
20
|
+
export interface TrackedEffect extends Computed<void> {
|
|
21
|
+
_cleanup?: () => void;
|
|
22
|
+
_modified: boolean;
|
|
23
|
+
_type: number;
|
|
24
|
+
_run: () => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Internal tracked effect - bypasses heap, goes directly to effect queue.
|
|
28
|
+
* Runs as a leaf owner: child primitives and onCleanup are forbidden (__DEV__ throws).
|
|
29
|
+
* Uses stale reads.
|
|
30
|
+
*/
|
|
31
|
+
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,82 @@
|
|
|
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 registerTransientStoreNode(node: Signal<any>): void;
|
|
13
|
+
export declare function resetUnhandledAsync(): void;
|
|
14
|
+
export declare function enforceLoadingBoundary(enabled: boolean): void;
|
|
15
|
+
export declare function shouldReadStashedOptimisticValue(node: Signal<any>): boolean;
|
|
16
|
+
export declare function setProjectionWriteActive(value: boolean): void;
|
|
17
|
+
export declare function setTrackedQueueCallback(value: boolean): void;
|
|
18
|
+
export type QueueCallback = (type: number) => void;
|
|
19
|
+
type QueueStub = {
|
|
20
|
+
_queues: [QueueCallback[], QueueCallback[]];
|
|
21
|
+
_children: QueueStub[];
|
|
22
|
+
};
|
|
23
|
+
type OptimisticNode = Signal<any> | Computed<any>;
|
|
24
|
+
export interface Transition {
|
|
25
|
+
_time: number;
|
|
26
|
+
_asyncReporters: Map<Computed<any>, Set<Computed<any>>>;
|
|
27
|
+
_pendingNodes: Signal<any>[];
|
|
28
|
+
_optimisticNodes: OptimisticNode[];
|
|
29
|
+
_optimisticStores: Set<any>;
|
|
30
|
+
_actions: Array<Generator<any, any, any> | AsyncGenerator<any, any, any>>;
|
|
31
|
+
_queueStash: QueueStub;
|
|
32
|
+
_done: boolean | Transition;
|
|
33
|
+
}
|
|
34
|
+
export declare function schedule(): void;
|
|
35
|
+
export interface IQueue {
|
|
36
|
+
enqueue(type: number, fn: QueueCallback): void;
|
|
37
|
+
run(type: number): boolean | void;
|
|
38
|
+
addChild(child: IQueue): void;
|
|
39
|
+
removeChild(child: IQueue): void;
|
|
40
|
+
created: number;
|
|
41
|
+
notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
|
|
42
|
+
stashQueues(stub: QueueStub): void;
|
|
43
|
+
restoreQueues(stub: QueueStub): void;
|
|
44
|
+
_parent: IQueue | null;
|
|
45
|
+
}
|
|
46
|
+
export declare class Queue implements IQueue {
|
|
47
|
+
_parent: IQueue | null;
|
|
48
|
+
_queues: [QueueCallback[], QueueCallback[]];
|
|
49
|
+
_children: IQueue[];
|
|
50
|
+
created: number;
|
|
51
|
+
addChild(child: IQueue): void;
|
|
52
|
+
removeChild(child: IQueue): void;
|
|
53
|
+
notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
|
|
54
|
+
run(type: number): void;
|
|
55
|
+
enqueue(type: number, fn: QueueCallback): void;
|
|
56
|
+
stashQueues(stub: QueueStub): void;
|
|
57
|
+
restoreQueues(stub: QueueStub): void;
|
|
58
|
+
}
|
|
59
|
+
export declare class GlobalQueue extends Queue {
|
|
60
|
+
_running: boolean;
|
|
61
|
+
_pendingNodes: Signal<any>[];
|
|
62
|
+
_optimisticNodes: OptimisticNode[];
|
|
63
|
+
_optimisticStores: Set<any>;
|
|
64
|
+
static _update: (el: Computed<unknown>) => void;
|
|
65
|
+
static _dispose: (el: Computed<unknown>, self: boolean, zombie: boolean) => void;
|
|
66
|
+
static _clearOptimisticStore: ((store: any) => void) | null;
|
|
67
|
+
flush(): void;
|
|
68
|
+
notify(node: Computed<any>, mask: number, flags: number, error?: any): boolean;
|
|
69
|
+
initTransition(transition?: Transition | null): void;
|
|
70
|
+
}
|
|
71
|
+
export declare function insertSubs(node: Signal<any> | Computed<any>, optimistic?: boolean): void;
|
|
72
|
+
export declare function finalizePureQueue(completingTransition?: Transition | null, incomplete?: boolean): void;
|
|
73
|
+
export declare function trackOptimisticStore(store: any): void;
|
|
74
|
+
export declare const globalQueue: GlobalQueue;
|
|
75
|
+
/**
|
|
76
|
+
* By default, changes are batched on the microtask queue which is an async process. You can flush
|
|
77
|
+
* the queue synchronously to get the latest updates by calling `flush()`.
|
|
78
|
+
*/
|
|
79
|
+
export declare function flush(): void;
|
|
80
|
+
export declare function currentTransition(transition: Transition): Transition;
|
|
81
|
+
export declare function setActiveTransition(transition: Transition | null): void;
|
|
82
|
+
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, type RevealOrder } 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[]>;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { Disposable } from "./core/index.cjs";
|
|
2
|
+
export declare function onCleanup(fn: Disposable): Disposable;
|
|
3
|
+
export type Accessor<T> = () => T;
|
|
4
|
+
export declare function accessor<T>(node: any): Accessor<T>;
|
|
5
|
+
export type Setter<in out T> = {
|
|
6
|
+
<U extends T>(...args: undefined extends T ? [] : [value: Exclude<U, Function> | ((prev: T) => U)]): undefined extends T ? undefined : U;
|
|
7
|
+
<U extends T>(value: (prev: T) => U): U;
|
|
8
|
+
<U extends T>(value: Exclude<U, Function>): U;
|
|
9
|
+
<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)): U;
|
|
10
|
+
};
|
|
11
|
+
export type Signal<T> = [get: Accessor<T>, set: Setter<T>];
|
|
12
|
+
export type ComputeFunction<Prev, Next extends Prev = Prev> = (v: Prev) => PromiseLike<Next> | AsyncIterable<Next> | Next;
|
|
13
|
+
export type EffectFunction<Prev, Next extends Prev = Prev> = (v: Next, p?: Prev) => (() => void) | void;
|
|
14
|
+
export type EffectBundle<Prev, Next extends Prev = Prev> = {
|
|
15
|
+
effect: EffectFunction<Prev, Next>;
|
|
16
|
+
error: (err: unknown, cleanup: () => void) => void;
|
|
17
|
+
};
|
|
18
|
+
/** Options shared by every effect primitive. */
|
|
19
|
+
interface BaseEffectOptions {
|
|
20
|
+
/** Debug name (dev mode only) */
|
|
21
|
+
name?: string;
|
|
22
|
+
}
|
|
23
|
+
/** Options for effect primitives that support deferring/scheduling their initial run (`createEffect`, `createRenderEffect`, `createReaction`). */
|
|
24
|
+
export interface EffectOptions extends BaseEffectOptions {
|
|
25
|
+
/** When true, defers the initial effect execution until the next change */
|
|
26
|
+
defer?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* When true, enqueues the initial effect callback through the effect queue instead of running
|
|
29
|
+
* it synchronously at creation. Lets the initial run participate in transitions -- if any
|
|
30
|
+
* source throws `NotReadyError` during the compute phase, the callback is held until the
|
|
31
|
+
* transition settles.
|
|
32
|
+
*
|
|
33
|
+
* Primarily for render effects that need transition-aware initial mounts (e.g. the root
|
|
34
|
+
* `insert()` in `render()`).
|
|
35
|
+
*/
|
|
36
|
+
schedule?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** Options for plain signals created with `createSignal(value)` or `createOptimistic(value)`. */
|
|
39
|
+
export interface SignalOptions<T> {
|
|
40
|
+
/** Debug name (dev mode only) */
|
|
41
|
+
name?: string;
|
|
42
|
+
/** Custom equality function, or `false` to always notify subscribers */
|
|
43
|
+
equals?: false | ((prev: T, next: T) => boolean);
|
|
44
|
+
/** Suppress dev-mode warnings when writing inside an owned scope */
|
|
45
|
+
ownedWrite?: boolean;
|
|
46
|
+
/** Callback invoked when the signal loses all subscribers */
|
|
47
|
+
unobserved?: () => void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Options for read-only memos created with `createMemo`.
|
|
51
|
+
* Also used in combination with `SignalOptions` for writable memos
|
|
52
|
+
* (`createSignal(fn)` / `createOptimistic(fn)`).
|
|
53
|
+
*/
|
|
54
|
+
export interface MemoOptions<T> {
|
|
55
|
+
/** Stable identifier for the owner hierarchy */
|
|
56
|
+
id?: string;
|
|
57
|
+
/** Debug name (dev mode only) */
|
|
58
|
+
name?: string;
|
|
59
|
+
/** When true, the owner is invisible to the ID scheme -- inherits parent ID and doesn't consume a childCount slot */
|
|
60
|
+
transparent?: boolean;
|
|
61
|
+
/** Custom equality function, or `false` to always notify subscribers */
|
|
62
|
+
equals?: false | ((prev: T, next: T) => boolean);
|
|
63
|
+
/** Callback invoked when the computed loses all subscribers */
|
|
64
|
+
unobserved?: () => void;
|
|
65
|
+
/** When true, defers the initial computation until the value is first read */
|
|
66
|
+
lazy?: boolean;
|
|
67
|
+
}
|
|
68
|
+
export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
|
|
69
|
+
/**
|
|
70
|
+
* Creates a simple reactive state with a getter and setter.
|
|
71
|
+
*
|
|
72
|
+
* When called with a plain value, creates a signal with `SignalOptions` (name, equals, ownedWrite, unobserved).
|
|
73
|
+
* When called with a function, creates a writable memo with `SignalOptions & MemoOptions` (adds id, lazy).
|
|
74
|
+
*
|
|
75
|
+
* ```typescript
|
|
76
|
+
* // Plain signal
|
|
77
|
+
* const [state, setState] = createSignal<T>(value, options?: SignalOptions<T>);
|
|
78
|
+
* // Writable memo (function overload)
|
|
79
|
+
* const [state, setState] = createSignal<T>(fn, initialValue?, options?: SignalOptions<T> & MemoOptions<T>);
|
|
80
|
+
* ```
|
|
81
|
+
* @param value initial value of the state; if empty, the state's type will automatically extended with undefined
|
|
82
|
+
* @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
|
|
83
|
+
*
|
|
84
|
+
* @returns `[state: Accessor<T>, setState: Setter<T>]`
|
|
85
|
+
*
|
|
86
|
+
* @description https://docs.solidjs.com/reference/basic-reactivity/create-signal
|
|
87
|
+
*/
|
|
88
|
+
export declare function createSignal<T>(): Signal<T | undefined>;
|
|
89
|
+
export declare function createSignal<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
|
|
90
|
+
export declare function createSignal<T>(fn: ComputeFunction<T>, options?: SignalOptions<T> & MemoOptions<T>): Signal<T>;
|
|
91
|
+
/**
|
|
92
|
+
* Creates a readonly derived reactive memoized signal.
|
|
93
|
+
*
|
|
94
|
+
* ```typescript
|
|
95
|
+
* const value = createMemo<T>(compute, options?: MemoOptions<T>);
|
|
96
|
+
* ```
|
|
97
|
+
* @param compute a function that receives its previous value and returns a new value used to react on a computation
|
|
98
|
+
* @param options `MemoOptions` -- id, name, equals, unobserved, lazy
|
|
99
|
+
*
|
|
100
|
+
* @description https://docs.solidjs.com/reference/basic-reactivity/create-memo
|
|
101
|
+
*/
|
|
102
|
+
export declare function createMemo<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: MemoOptions<T>): Accessor<T>;
|
|
103
|
+
/**
|
|
104
|
+
* Creates a reactive effect that runs after the render phase.
|
|
105
|
+
*
|
|
106
|
+
* ```typescript
|
|
107
|
+
* createEffect<T>(compute, effectFn | { effect, error }, options?: EffectOptions);
|
|
108
|
+
* ```
|
|
109
|
+
* @param compute a function that receives its previous value and returns a new value used to react on a computation
|
|
110
|
+
* @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
|
|
111
|
+
* @param options `EffectOptions` -- name, defer
|
|
112
|
+
*
|
|
113
|
+
* @description https://docs.solidjs.com/reference/basic-reactivity/create-effect
|
|
114
|
+
*/
|
|
115
|
+
export declare function createEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effectFn: EffectFunction<NoInfer<T>, T> | EffectBundle<NoInfer<T>, T>, options?: EffectOptions): void;
|
|
116
|
+
/**
|
|
117
|
+
* Creates a reactive computation that runs during the render phase as DOM elements
|
|
118
|
+
* are created and updated but not necessarily connected.
|
|
119
|
+
*
|
|
120
|
+
* ```typescript
|
|
121
|
+
* createRenderEffect<T>(compute, effectFn, options?: EffectOptions);
|
|
122
|
+
* ```
|
|
123
|
+
* @param compute a function that receives its previous value and returns a new value used to react on a computation
|
|
124
|
+
* @param effectFn a function that receives the new value and is used to perform side effects
|
|
125
|
+
* @param options `EffectOptions` -- name, defer
|
|
126
|
+
*
|
|
127
|
+
* @description https://docs.solidjs.com/reference/secondary-primitives/create-render-effect
|
|
128
|
+
*/
|
|
129
|
+
export declare function createRenderEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effectFn: EffectFunction<NoInfer<T>, T>, options?: EffectOptions): void;
|
|
130
|
+
/**
|
|
131
|
+
* Creates a tracked reactive effect where dependency tracking and side effects happen
|
|
132
|
+
* in the same scope.
|
|
133
|
+
*
|
|
134
|
+
* WARNING: Because tracking and effects happen in the same scope, this primitive
|
|
135
|
+
* may run multiple times for a single change or show tearing (reading inconsistent
|
|
136
|
+
* state). Use only when dynamic subscription patterns require same-scope tracking.
|
|
137
|
+
*
|
|
138
|
+
* ```typescript
|
|
139
|
+
* createTrackedEffect(compute, options?: { name?: string });
|
|
140
|
+
* ```
|
|
141
|
+
* @param compute a function that contains reactive reads to track and returns an optional cleanup function to run on disposal or before next execution
|
|
142
|
+
* @param options -- name
|
|
143
|
+
*
|
|
144
|
+
* @description https://docs.solidjs.com/reference/secondary-primitives/create-tracked-effect
|
|
145
|
+
*/
|
|
146
|
+
export declare function createTrackedEffect(compute: () => void | (() => void), options?: BaseEffectOptions): void;
|
|
147
|
+
/**
|
|
148
|
+
* Creates a reactive computation that runs after the render phase with flexible tracking.
|
|
149
|
+
*
|
|
150
|
+
* ```typescript
|
|
151
|
+
* const track = createReaction(effectFn, options?: EffectOptions);
|
|
152
|
+
* track(() => { // reactive reads });
|
|
153
|
+
* ```
|
|
154
|
+
* @param effectFn a function (or `EffectBundle`) that is called when tracked function is invalidated
|
|
155
|
+
* @param options `EffectOptions` -- name, defer
|
|
156
|
+
*
|
|
157
|
+
* @description https://docs.solidjs.com/reference/secondary-primitives/create-reaction
|
|
158
|
+
*/
|
|
159
|
+
export declare function createReaction(effectFn: EffectFunction<undefined> | EffectBundle<undefined>, options?: EffectOptions): (tracking: () => void) => void;
|
|
160
|
+
/**
|
|
161
|
+
* Returns a promise of the resolved value of a reactive expression
|
|
162
|
+
* @param fn a reactive expression to resolve
|
|
163
|
+
*/
|
|
164
|
+
export declare function resolve<T>(fn: () => T): Promise<T>;
|
|
165
|
+
/**
|
|
166
|
+
* Creates an optimistic signal that can be used to optimistically update a value
|
|
167
|
+
* and then revert it back to the previous value at end of transition.
|
|
168
|
+
*
|
|
169
|
+
* When called with a plain value, creates an optimistic signal with `SignalOptions` (name, equals, ownedWrite, unobserved).
|
|
170
|
+
* When called with a function, creates a writable optimistic memo with `SignalOptions & MemoOptions` (adds id, lazy).
|
|
171
|
+
*
|
|
172
|
+
* ```typescript
|
|
173
|
+
* // Plain optimistic signal
|
|
174
|
+
* const [state, setState] = createOptimistic<T>(value, options?: SignalOptions<T>);
|
|
175
|
+
* // Writable optimistic memo (function overload)
|
|
176
|
+
* const [state, setState] = createOptimistic<T>(fn, options?: SignalOptions<T> & MemoOptions<T>);
|
|
177
|
+
* ```
|
|
178
|
+
* @param value initial value of the signal; if empty, the signal's type will automatically extended with undefined
|
|
179
|
+
* @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
|
|
180
|
+
*
|
|
181
|
+
* @returns `[state: Accessor<T>, setState: Setter<T>]`
|
|
182
|
+
*
|
|
183
|
+
* @description https://docs.solidjs.com/reference/basic-reactivity/create-optimistic-signal
|
|
184
|
+
*/
|
|
185
|
+
export declare function createOptimistic<T>(): Signal<T | undefined>;
|
|
186
|
+
export declare function createOptimistic<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
|
|
187
|
+
export declare function createOptimistic<T>(fn: ComputeFunction<T>, options?: SignalOptions<T> & MemoOptions<T>): Signal<T>;
|
|
188
|
+
/**
|
|
189
|
+
* Runs a callback after the current flush cycle completes.
|
|
190
|
+
*
|
|
191
|
+
* When called within a reactive context (owner), uses a tracked effect with untracked
|
|
192
|
+
* reads - this means normal signal reads won't create subscriptions, but uninitialized
|
|
193
|
+
* async values will throw NotReadyError, causing the callback to re-run when they settle.
|
|
194
|
+
*
|
|
195
|
+
* When called without an owner, runs once and immediately calls any returned cleanup.
|
|
196
|
+
*
|
|
197
|
+
* @param callback Function to run, may return a cleanup function
|
|
198
|
+
*/
|
|
199
|
+
export declare function onSettled(callback: () => void | (() => void)): void;
|
|
200
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { Store, StoreSetter, StoreNode, StoreOptions, ProjectionOptions, NotWrappable, SolidStore } from "./store.cjs";
|
|
2
|
+
export type { Merge, Omit } from "./utils.cjs";
|
|
3
|
+
export { isWrappable, createStore, $TRACK, $PROXY, $TARGET } from "./store.cjs";
|
|
4
|
+
export { createProjection } from "./projection.cjs";
|
|
5
|
+
export { createOptimisticStore } from "./optimistic.cjs";
|
|
6
|
+
export { reconcile } from "./reconcile.cjs";
|
|
7
|
+
export { storePath } from "./storePath.cjs";
|
|
8
|
+
export type { PathSetter, Part, StorePathRange, ArrayFilterFn, CustomPartial } from "./storePath.cjs";
|
|
9
|
+
export { snapshot, deep, merge, omit } from "./utils.cjs";
|