global: snapshot

This commit is contained in:
nym21
2026-01-14 16:38:53 +01:00
parent ddb1db7a8e
commit d75c2a881b
226 changed files with 7776 additions and 20942 deletions

2132
modules/solidjs-signals/0.9.2/dist/prod.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
import { Queue, type Computed, type Effect } from "./core/index.js";
import type { Signal } from "./core/index.js";
export interface BoundaryComputed<T> extends Computed<T> {
_propagationMask: number;
}
export declare class CollectionQueue extends Queue {
_collectionType: number;
_nodes: Set<Effect<any>>;
_disabled: Signal<boolean>;
_initialized: boolean;
constructor(type: number);
run(type: number): void;
notify(node: Effect<any>, type: number, flags: number): boolean;
}
export declare const enum BoundaryMode {
VISIBLE = "visible",
HIDDEN = "hidden"
}
export declare function createBoundary<T>(fn: () => T, condition: () => BoundaryMode): () => T | undefined;
export declare function createLoadBoundary(fn: () => any, fallback: () => any): () => unknown;
export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): () => unknown;
export declare function flatten(children: any, options?: {
skipNonRendered?: boolean;
doNotUnwrap?: boolean;
}): any;

View File

@@ -0,0 +1,18 @@
export declare const REACTIVE_NONE = 0;
export declare const REACTIVE_CHECK: number;
export declare const REACTIVE_DIRTY: number;
export declare const REACTIVE_RECOMPUTING_DEPS: number;
export declare const REACTIVE_IN_HEAP: number;
export declare const REACTIVE_IN_HEAP_HEIGHT: number;
export declare const REACTIVE_ZOMBIE: number;
export declare const REACTIVE_DISPOSED: number;
export declare const STATUS_NONE = 0;
export declare const STATUS_PENDING: number;
export declare const STATUS_ERROR: number;
export declare const STATUS_UNINITIALIZED: number;
export declare const EFFECT_PURE = 0;
export declare const EFFECT_RENDER = 1;
export declare const EFFECT_USER = 2;
export declare const NOT_PENDING: {};
export declare const SUPPORTS_PROXY: boolean;
export declare const defaultContext: {};

View File

@@ -0,0 +1,28 @@
import { type Owner } from "./core.js";
export interface Context<T> {
readonly id: symbol;
readonly defaultValue: T | undefined;
}
export type ContextRecord = Record<string | symbol, unknown>;
/**
* Context provides a form of dependency injection. It is used to save from needing to pass
* data as props through intermediate components. This function creates a new context object
* that can be used with `getContext` and `setContext`.
*
* A default value can be provided here which will be used when a specific value is not provided
* via a `setContext` call.
*/
export declare function createContext<T>(defaultValue?: T, description?: string): Context<T>;
/**
* Attempts to get a context value for the given key.
*
* @throws `NoOwnerError` if there's no owner at the time of call.
* @throws `ContextNotFoundError` if a context value has not been set yet.
*/
export declare function getContext<T>(context: Context<T>, owner?: Owner | null): T;
/**
* Attempts to set a context value on the parent scope with the given key.
*
* @throws `NoOwnerError` if there's no owner at the time of call.
*/
export declare function setContext<T>(context: Context<T>, value?: T, owner?: Owner | null): void;

View File

@@ -0,0 +1,122 @@
import { NOT_PENDING } from "./constants.js";
import { type IQueue, type Transition } from "./scheduler.js";
export interface Disposable {
(): void;
}
export interface Link {
_dep: Signal<unknown> | Computed<unknown>;
_sub: Computed<unknown>;
_nextDep: Link | null;
_prevSub: Link | null;
_nextSub: Link | null;
}
export interface SignalOptions<T> {
id?: string;
name?: string;
equals?: ((prev: T, next: T) => boolean) | false;
pureWrite?: boolean;
unobserved?: () => void;
lazy?: boolean;
}
export interface RawSignal<T> {
id?: string;
_subs: Link | null;
_subsTail: Link | null;
_value: T;
_error?: unknown;
_statusFlags: number;
_name?: string;
_equals: false | ((a: T, b: T) => boolean);
_pureWrite?: boolean;
_unobserved?: () => void;
_time: number;
_transition: Transition | null;
_pendingValue: T | typeof NOT_PENDING;
_pendingCheck?: Signal<boolean> & {
_set: (v: boolean) => void;
};
_pendingSignal?: Signal<T> & {
_set: (v: T) => void;
};
_optimistic?: boolean;
}
export interface FirewallSignal<T> extends RawSignal<T> {
_firewall: Computed<any>;
_nextChild: FirewallSignal<unknown> | null;
}
export type Signal<T> = RawSignal<T> | FirewallSignal<T>;
export interface Owner {
id?: string;
_disposal: Disposable | Disposable[] | null;
_parent: Owner | null;
_context: Record<symbol | string, unknown>;
_childCount: number;
_queue: IQueue;
_firstChild: Owner | null;
_nextSibling: Owner | null;
_pendingDisposal: Disposable | Disposable[] | null;
_pendingFirstChild: Owner | null;
}
export interface Computed<T> extends RawSignal<T>, Owner {
_deps: Link | null;
_depsTail: Link | null;
_flags: number;
_height: number;
_nextHeap: Computed<any> | undefined;
_prevHeap: Computed<any>;
_fn: (prev?: T) => T;
_inFlight: Promise<T> | AsyncIterable<T> | null;
_child: FirewallSignal<any> | null;
_notifyQueue?: (statusFlagsChanged: boolean, prevStatusFlags: number) => void;
}
export interface Root extends Owner {
_root: true;
_parentComputed: Computed<any> | null;
dispose(self?: boolean): void;
}
export declare let context: Owner | null;
export declare function recompute(el: Computed<any>, create?: boolean): void;
export declare function handleAsync<T>(el: Computed<T>, result: T | Promise<T> | AsyncIterable<T>, setter?: (value: T) => void): T;
export declare function dispose(node: Computed<unknown>): void;
export declare function getNextChildId(owner: Owner): string;
export declare function computed<T>(fn: (prev?: T) => T | Promise<T> | AsyncIterable<T>): Computed<T>;
export declare function computed<T>(fn: (prev: T) => T | Promise<T> | AsyncIterable<T>, initialValue?: T, options?: SignalOptions<T>): Computed<T>;
export declare function signal<T>(v: T, options?: SignalOptions<T>): Signal<T>;
export declare function signal<T>(v: T, options?: SignalOptions<T>, firewall?: Computed<any>): FirewallSignal<T>;
export declare function isEqual<T>(a: T, b: T): boolean;
/**
* Returns the current value stored inside the given compute function without triggering any
* dependencies. Use `untrack` if you want to also disable owner tracking.
*/
export declare function untrack<T>(fn: () => T): T;
export declare function read<T>(el: Signal<T> | Computed<T>): T;
export declare function setSignal<T>(el: Signal<T> | Computed<T>, v: T | ((prev: T) => T)): T;
export declare function getObserver(): Owner | null;
export declare function getOwner(): Owner | null;
export declare function onCleanup(fn: Disposable): Disposable;
export declare function createOwner(options?: {
id: string;
}): Root;
/**
* Creates a new non-tracked reactive context with manual disposal
*
* @param fn a function in which the reactive state is scoped
* @returns the output of `fn`.
*
* @description https://docs.solidjs.com/reference/reactive-utilities/create-root
*/
export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T), options?: {
id: string;
}): T;
/**
* Runs the given function in the given owner to move ownership of nested primitives and cleanups.
* This method untracks the current scope.
*
* Warning: Usually there are simpler ways of modeling a problem that avoid using this function
*/
export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
export declare function staleValues<T>(fn: () => T, set?: boolean): T;
export declare function pending<T>(fn: () => T): T;
export declare function isPending(fn: () => any): boolean;
export declare function refresh<T>(fn: () => T): T;
export declare function isRefreshing(): boolean;

View File

@@ -0,0 +1,18 @@
import { type Computed, type Owner, type SignalOptions } from "./core.js";
export interface Effect<T> extends Computed<T>, Owner {
_effectFn: (val: T, prev: T | undefined) => void | (() => void);
_errorFn?: (err: unknown, cleanup: () => void) => void;
_cleanup?: () => void;
_modified: boolean;
_prevValue: T | undefined;
_type: number;
}
/**
* Effects are the leaf nodes of our reactive graph. When their sources change, they are
* automatically added to the queue of effects to re-execute, which will cause them to fetch their
* sources and recompute
*/
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?: SignalOptions<any> & {
render?: boolean;
defer?: boolean;
}): void;

View File

@@ -0,0 +1,10 @@
export declare class NotReadyError extends Error {
cause: any;
constructor(cause: any);
}
export declare class NoOwnerError extends Error {
constructor();
}
export declare class ContextNotFoundError extends Error {
constructor();
}

View File

@@ -0,0 +1,14 @@
import type { Computed } from "./core.js";
export interface Heap {
_heap: (Computed<unknown> | undefined)[];
_marked: boolean;
_min: number;
_max: number;
}
export declare function increaseHeapSize(n: number, heap: Heap): void;
export declare function insertIntoHeap(n: Computed<any>, heap: Heap): void;
export declare function insertIntoHeapHeight(n: Computed<unknown>, heap: Heap): void;
export declare function deleteFromHeap(n: Computed<unknown>, heap: Heap): void;
export declare function markHeap(heap: Heap): void;
export declare function markNode(el: Computed<unknown>, newState?: number): void;
export declare function runHeap(heap: Heap, recompute: (el: Computed<unknown>) => void): void;

View File

@@ -0,0 +1,6 @@
export { ContextNotFoundError, NoOwnerError, NotReadyError } from "./error.js";
export { createContext, getContext, setContext, type Context, type ContextRecord } from "./context.js";
export { getObserver, isEqual, untrack, getOwner, runWithOwner, createOwner, createRoot, computed, dispose, signal, read, setSignal, onCleanup, getNextChildId, isPending, pending, refresh, isRefreshing, staleValues, handleAsync, type Owner, type Computed, type Root, type Signal, type SignalOptions } from "./core.js";
export { effect, type Effect } from "./effect.js";
export { flush, Queue, type IQueue, type QueueCallback } from "./scheduler.js";
export * from "./constants.js";

View File

@@ -0,0 +1,65 @@
import type { Computed, Signal } from "./core.js";
import { type Heap } from "./heap.js";
export declare let optimisticRun: boolean;
export declare const dirtyQueue: Heap;
export declare const zombieQueue: Heap;
export declare let clock: number;
export declare let activeTransition: Transition | null;
export type QueueCallback = (type: number) => void;
type QueueStub = {
_queues: [QueueCallback[], QueueCallback[]];
_children: QueueStub[];
};
export interface Transition {
time: number;
asyncNodes: Computed<any>[];
pendingNodes: Signal<any>[];
optimisticNodes: Signal<any>[];
queueStash: QueueStub;
done: boolean;
}
export declare function schedule(): void;
export interface IQueue {
enqueue(type: number, fn: QueueCallback): void;
run(type: number): boolean | void;
addChild(child: IQueue): void;
removeChild(child: IQueue): void;
created: number;
notify(node: Computed<any>, mask: number, flags: number): boolean;
stashQueues(stub: QueueStub): void;
restoreQueues(stub: QueueStub): void;
_parent: IQueue | null;
}
export declare class Queue implements IQueue {
_parent: IQueue | null;
_queues: [QueueCallback[], QueueCallback[]];
_children: IQueue[];
created: number;
addChild(child: IQueue): void;
removeChild(child: IQueue): void;
notify(node: Computed<any>, mask: number, flags: number): boolean;
run(type: number): void;
enqueue(type: number, fn: QueueCallback): void;
stashQueues(stub: QueueStub): void;
restoreQueues(stub: QueueStub): void;
}
export declare class GlobalQueue extends Queue {
_running: boolean;
_pendingNodes: Signal<any>[];
_optimisticNodes: Signal<any>[];
static _update: (el: Computed<unknown>) => void;
static _dispose: (el: Computed<unknown>, self: boolean, zombie: boolean) => void;
flush(): void;
notify(node: Computed<any>, mask: number, flags: number): boolean;
initTransition(node: Computed<any>): void;
}
export declare function notifySubs(node: Signal<any> | Computed<any>): void;
export declare function runOptimistic(activeTransition?: Transition | null): void;
export declare const globalQueue: GlobalQueue;
/**
* By default, changes are batched on the microtask queue which is an async process. You can flush
* the queue synchronously to get the latest updates by calling `flush()`.
*/
export declare function flush(): void;
export declare function runInTransition(el: Computed<unknown>, recompute: (el: Computed<unknown>) => void): void;
export {};

View File

@@ -0,0 +1,6 @@
export { ContextNotFoundError, NoOwnerError, NotReadyError, createContext, createRoot, runWithOwner, flush, getNextChildId, getContext, setContext, getOwner, onCleanup, getObserver, isEqual, untrack, isPending, pending, isRefreshing, refresh, SUPPORTS_PROXY } from "./core/index.js";
export type { Owner, SignalOptions, Context, ContextRecord, IQueue } from "./core/index.js";
export * from "./signals.js";
export { mapArray, repeat, type Maybe } from "./map.js";
export * from "./store/index.js";
export { createLoadBoundary, createErrorBoundary, createBoundary, flatten, type BoundaryMode } from "./boundaries.js";

View File

@@ -0,0 +1,22 @@
import { type Accessor } from "./signals.js";
export type Maybe<T> = T | void | null | undefined | false;
/**
* Reactively transforms an array with a callback function - underlying helper for the `<For>` control flow
*
* 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.
*
* @description https://docs.solidjs.com/reference/reactive-utilities/map-array
*/
export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Accessor<Item>, index: Accessor<number>) => MappedItem, options?: {
keyed?: boolean | ((item: Item) => any);
fallback?: Accessor<any>;
}): Accessor<MappedItem[]>;
/**
* Reactively repeats a callback function the count provided - underlying helper for the `<Repeat>` control flow
*
* @description https://docs.solidjs.com/reference/reactive-utilities/repeat
*/
export declare function repeat(count: Accessor<number>, map: (index: number) => any, options?: {
from?: Accessor<number | undefined>;
fallback?: Accessor<any>;
}): Accessor<any[]>;

View File

@@ -0,0 +1,143 @@
import type { SignalOptions } from "./core/index.js";
export type Accessor<T> = () => T;
export type Setter<in out T> = {
<U extends T>(...args: undefined extends T ? [] : [value: Exclude<U, Function> | ((prev: T) => U)]): undefined extends T ? undefined : U;
<U extends T>(value: (prev: T) => U): U;
<U extends T>(value: Exclude<U, Function>): U;
<U extends T>(value: Exclude<U, Function> | ((prev: T) => U)): U;
};
export type Signal<T> = [get: Accessor<T>, set: Setter<T>];
export type ComputeFunction<Prev, Next extends Prev = Prev> = (v: Prev) => Promise<Next> | AsyncIterable<Next> | Next;
export type EffectFunction<Prev, Next extends Prev = Prev> = (v: Next, p?: Prev) => (() => void) | void;
export type EffectBundle<Prev, Next extends Prev = Prev> = {
effect: EffectFunction<Prev, Next>;
error: (err: unknown, cleanup: () => void) => void;
};
export interface EffectOptions {
name?: string;
defer?: boolean;
}
export interface MemoOptions<T> {
name?: string;
equals?: false | ((prev: T, next: T) => boolean);
}
export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
/**
* Creates a simple reactive state with a getter and setter
* ```typescript
* const [state: Accessor<T>, setState: Setter<T>] = createSignal<T>(
* value: T,
* options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) }
* )
* ```
* @param value initial value of the state; if empty, the state's type will automatically extended with undefined; otherwise you need to extend the type manually if you want setting to undefined not be an error
* @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
*
* @returns ```typescript
* [state: Accessor<T>, setState: Setter<T>]
* ```
* * the Accessor is a function that returns the current value and registers each call to the reactive root
* * the Setter is a function that allows directly setting or mutating the value:
* ```typescript
* const [count, setCount] = createSignal(0);
* setCount(count => count + 1);
* ```
*
* @description https://docs.solidjs.com/reference/basic-reactivity/create-signal
*/
export declare function createSignal<T>(): Signal<T | undefined>;
export declare function createSignal<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
export declare function createSignal<T>(fn: ComputeFunction<T>, initialValue?: T, options?: SignalOptions<T>): Signal<T>;
/**
* Creates a readonly derived reactive memoized signal
* ```typescript
* export function createMemo<T>(
* compute: (v: T) => T,
* value?: T,
* options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) }
* ): () => T;
* ```
* @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
* @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
* @param options allows to set a name in dev mode for debugging purposes and use a custom comparison function in equals
*
* @description https://docs.solidjs.com/reference/basic-reactivity/create-memo
*/
export declare function createMemo<Next extends Prev, Prev = Next>(compute: ComputeFunction<undefined | NoInfer<Prev>, Next>): Accessor<Next>;
export declare function createMemo<Next extends Prev, Init = Next, Prev = Next>(compute: ComputeFunction<Init | Prev, Next>, value: Init, options?: MemoOptions<Next>): Accessor<Next>;
/**
* Creates a reactive effect that runs after the render phase
* ```typescript
* export function createEffect<T>(
* compute: (prev: T) => T,
* effect: (v: T, prev: T) => (() => void) | void,
* value?: T,
* options?: { name?: string }
* ): void;
* ```
* @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
* @param effect a function that receives the new value and is used to perform side effects, return a cleanup function to run on disposal
* @param error an optional function that receives an error if thrown during the computation
* @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
* @param options allows to set a name in dev mode for debugging purposes
*
* @description https://docs.solidjs.com/reference/basic-reactivity/create-effect
*/
export declare function createEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next> | EffectBundle<NoInfer<Next>, Next>): void;
export declare function createEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effect: EffectFunction<Next, Next> | EffectBundle<Next, Next>, value: Init, options?: EffectOptions): void;
/**
* Creates a reactive computation that runs during the render phase as DOM elements are created and updated but not necessarily connected
* ```typescript
* export function createRenderEffect<T>(
* compute: (prev: T) => T,
* effect: (v: T, prev: T) => (() => void) | void,
* value?: T,
* options?: { name?: string }
* ): void;
* ```
* @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
* @param effect a function that receives the new value and is used to perform side effects
* @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
* @param options allows to set a name in dev mode for debugging purposes
*
* @description https://docs.solidjs.com/reference/secondary-primitives/create-render-effect
*/
export declare function createRenderEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next>): void;
export declare function createRenderEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effectFn: EffectFunction<Next, Next>, value: Init, options?: EffectOptions): void;
/**
* Creates a tracked reactive effect that only tracks dependencies inside the effect itself
* ```typescript
* export function createTrackedEffect(
* compute: () => (() => void) | void,
* options?: { name?: string, defer?: boolean }
* ): void;
* ```
* @param compute a function that contains reactive reads to track and returns an optional cleanup function to run on disposal or before next execution
* @param options allows to set a name in dev mode for debugging purposes
*
* @description https://docs.solidjs.com/reference/secondary-primitives/create-tracked-effect
*/
export declare function createTrackedEffect(compute: () => void | (() => void), options?: EffectOptions): void;
/**
* Creates a reactive computation that runs after the render phase with flexible tracking
* ```typescript
* export function createReaction(
* onInvalidate: () => void,
* options?: { name?: string }
* ): (fn: () => void) => void;
* ```
* @param invalidated a function that is called when tracked function is invalidated.
* @param options allows to set a name in dev mode for debugging purposes
*
* @description https://docs.solidjs.com/reference/secondary-primitives/create-reaction
*/
export declare function createReaction(effectFn: EffectFunction<undefined> | EffectBundle<undefined>, options?: EffectOptions): (tracking: () => void) => void;
/**
* Returns a promise of the resolved value of a reactive expression
* @param fn a reactive expression to resolve
*/
export declare function resolve<T>(fn: () => T): Promise<T>;
export declare function createOptimistic<T>(): Signal<T | undefined>;
export declare function createOptimistic<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
export declare function createOptimistic<T>(fn: ComputeFunction<T>, initialValue?: T, options?: SignalOptions<T>): Signal<T>;
export declare function onSettled(callback: () => void | (() => void)): void;

View File

@@ -0,0 +1,7 @@
export type { Store, StoreSetter, StoreNode, NotWrappable, SolidStore } from "./store.js";
export type { Merge, Omit } from "./utils.js";
export { isWrappable, createStore, deep, $TRACK, $PROXY, $TARGET } from "./store.js";
export { createProjection } from "./projection.js";
export { createOptimisticStore } from "./optimistic.js";
export { reconcile } from "./reconcile.js";
export { snapshot, merge, omit } from "./utils.js";

View File

@@ -0,0 +1,22 @@
import { type Store, type StoreSetter } from "./store.js";
/**
* Creates an optimistic store that can be used to optimistically update a value
* and then revert it back to the previous value at end of transition.
* ```typescript
* export function createOptimistic<T>(
* fn: (store: T) => void,
* initial: T,
* options?: { key?: string | ((item: NonNullable<any>) => any); all?: boolean }
* ): [get: Store<T>, set: StoreSetter<T>];
* ```
* @param fn a function that receives the current store and can be used to mutate it directly inside a transition
* @param initial The initial value of the signal.
* @param options Optional signal options.
*
* @returns A tuple containing an accessor for the current value and a setter function to apply changes.
*/
export declare function createOptimisticStore<T extends object = {}>(initial: T | Store<T>): [get: Store<T>, set: StoreSetter<T>];
export declare function createOptimisticStore<T extends object = {}>(fn: (store: T) => T | void, initial: T | Store<T>, options?: {
key?: string | ((item: NonNullable<any>) => any);
all?: boolean;
}): [get: Store<T>, set: StoreSetter<T>];

View File

@@ -0,0 +1,11 @@
import { type Store, type StoreOptions } from "./store.js";
export declare function createProjectionInternal<T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue?: T, options?: StoreOptions): {
store: Readonly<T>;
node: any;
};
/**
* Creates a mutable derived value
*
* @see {@link https://github.com/solidjs/x-reactivity#createprojection}
*/
export declare function createProjection<T extends Object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue?: T, options?: StoreOptions): Store<T>;

View File

@@ -0,0 +1 @@
export declare function reconcile<T extends U, U>(value: T, key: string | ((item: NonNullable<any>) => any), all?: boolean): (state: U) => void;

View File

@@ -0,0 +1,38 @@
import { type Computed, type Signal } from "../core/index.js";
export type Store<T> = Readonly<T>;
export type StoreSetter<T> = (fn: (state: T) => T | void) => void;
export type StoreOptions = {
key?: string | ((item: NonNullable<any>) => any);
all?: boolean;
};
type DataNode = Signal<any>;
type DataNodes = Record<PropertyKey, DataNode>;
export declare const $TRACK: unique symbol, $DEEP: unique symbol, $TARGET: unique symbol, $PROXY: unique symbol, $DELETED: unique symbol;
export declare const STORE_VALUE = "v", STORE_OVERRIDE = "o", STORE_NODE = "n", STORE_HAS = "h", STORE_WRAP = "w", STORE_LOOKUP = "l", STORE_FIREWALL = "f";
export type StoreNode = {
[$PROXY]: any;
[STORE_VALUE]: Record<PropertyKey, any>;
[STORE_OVERRIDE]?: Record<PropertyKey, any>;
[STORE_NODE]?: DataNodes;
[STORE_HAS]?: DataNodes;
[STORE_WRAP]?: (value: any, target?: StoreNode) => any;
[STORE_LOOKUP]?: WeakMap<any, any>;
[STORE_FIREWALL]?: () => Computed<any>;
};
export declare namespace SolidStore {
interface Unwrappable {
}
}
export type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined | SolidStore.Unwrappable[keyof SolidStore.Unwrappable];
export declare function createStoreProxy<T extends object>(value: T, traps?: ProxyHandler<StoreNode>, extend?: Record<PropertyKey, any>): any;
export declare const storeLookup: WeakMap<object, any>;
export declare function wrap<T extends Record<PropertyKey, any>>(value: T, target?: StoreNode): T;
export declare function isWrappable<T>(obj: T | NotWrappable): obj is T;
export declare function getKeys(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, enumerable?: boolean): PropertyKey[];
export declare function getPropertyDescriptor(source: Record<PropertyKey, any>, override: Record<PropertyKey, any> | undefined, property: PropertyKey): PropertyDescriptor | undefined;
export declare const storeTraps: ProxyHandler<StoreNode>;
export declare function storeSetter<T extends object>(store: Store<T>, fn: (draft: T) => T | void): void;
export declare function createStore<T extends object = {}>(store: T | Store<T>): [get: Store<T>, set: StoreSetter<T>];
export declare function createStore<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: T | Store<T>, options?: StoreOptions): [get: Store<T>, set: StoreSetter<T>];
export declare function deep<T extends object>(store: Store<T>): Store<T>;
export {};

View File

@@ -0,0 +1,36 @@
/**
* Returns a non reactive copy of the store object.
* It will attempt to preserver the original reference unless the value has been modified.
* @param item store proxy object
*/
export declare function snapshot<T>(item: T): T;
export declare function snapshot<T>(item: T, map?: Map<unknown, unknown>, lookup?: WeakMap<any, any>): T;
type DistributeOverride<T, F> = T extends undefined ? F : T;
type Override<T, U> = T extends any ? U extends any ? {
[K in keyof T]: K extends keyof U ? DistributeOverride<U[K], T[K]> : T[K];
} & {
[K in keyof U]: K extends keyof T ? DistributeOverride<U[K], T[K]> : U[K];
} : T & U : T & U;
type OverrideSpread<T, U> = T extends any ? {
[K in keyof ({
[K in keyof T]: any;
} & {
[K in keyof U]?: any;
} & {
[K in U extends any ? keyof U : keyof U]?: any;
})]: K extends keyof T ? Exclude<U extends any ? U[K & keyof U] : never, undefined> | T[K] : U extends any ? U[K & keyof U] : never;
} : T & U;
type Simplify<T> = T extends any ? {
[K in keyof T]: T[K];
} : T;
type _Merge<T extends unknown[], Curr = {}> = T extends [
infer Next | (() => infer Next),
...infer Rest
] ? _Merge<Rest, Override<Curr, Next>> : T extends [...infer Rest, infer Next | (() => infer Next)] ? Override<_Merge<Rest, Curr>, Next> : T extends [] ? Curr : T extends (infer I | (() => infer I))[] ? OverrideSpread<Curr, I> : Curr;
export type Merge<T extends unknown[]> = Simplify<_Merge<T>>;
export declare function merge<T extends unknown[]>(...sources: T): Merge<T>;
export type Omit<T, K extends readonly (keyof T)[]> = {
[P in keyof T as Exclude<P, K[number]>]: T[P];
};
export declare function omit<T extends Record<any, any>, K extends readonly (keyof T)[]>(props: T, ...keys: K): Omit<T, K>;
export {};