//#region src/lib/constrain.d.ts type Constrain = T & S$1; //#endregion //#region src/lib/maybePromise.d.ts type MaybePromise = T | Promise; //#endregion //#region src/lib/typeHelpers.d.ts type Object_ = Record; type Array_ = readonly any[]; type StringToNumber = T extends `${infer K extends number}` ? K : never; type ArrayToStringPath = T extends readonly [] ? "" : T extends readonly [infer First extends string | number, ...infer Rest] ? First extends `${string}.${string}` ? never : Rest extends readonly [] ? `${First}` : `${First}.${ArrayToStringPath}` : T extends readonly KeyType[] ? string : never; type StringToArrayPath = T extends "" ? readonly [] : T extends `${infer First}.${infer Rest}` ? readonly [First, ...StringToArrayPath] : readonly [T]; type OptionalPropertyOf = Exclude<{ [K in keyof T]: string extends K ? K : number extends K ? K : symbol extends K ? K : T extends Record ? never : K }[keyof T], undefined>; type OptionalProperties = Pick>; type IsAny = 0 extends 1 & T ? true : false; type IsNever = [T] extends [never] ? true : false; //#endregion //#region src/lib/path.d.ts type KeyType = string | number | symbol; type AnyPath = string | readonly KeyType[]; type GetKeys = T extends Array_ ? T extends readonly [] ? never : "0" extends keyof T ? StringToNumber : number : keyof T; type _PathAsArray = (Optional extends false ? readonly [] : never) | (true extends IsAny ? readonly KeyType[] : T extends never ? never : T extends Object_ ? Depth["length"] extends MaxDepth ? readonly string[] : T extends Map ? readonly [K] | readonly [K, ..._PathAsArray] : T extends Set ? readonly [number] : { [K in GetKeys]: (Optional extends true ? K extends OptionalPropertyOf ? readonly [K] : never : readonly [K]) | readonly [K, ..._PathAsArray] }[GetKeys] : never); type PathAsArray = _PathAsArray; type PathAsString = ArrayToStringPath>; type Path = PathAsString | PathAsArray; type Value = P$1 extends readonly [] ? T : true extends IsAny | IsAny ? any : true extends IsNever | IsNever ? never : P$1 extends string ? Value> : P$1 extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]] ? T extends Map | Set ? Value | undefined : T extends Array_ ? any[] extends T ? Value | undefined : Value : T extends Object_ ? Record extends T ? Value | undefined : Value : never : never; type _WildcardPathAsArray = [] | (0 extends 1 & T ? KeyType[] : T extends never ? never : T extends Object_ ? Depth["length"] extends MaxDepth ? string[] : T extends Map ? ["*"] | [K] | [K, ..._WildcardPathAsArray] : T extends Set ? ["*"] | [number] : Record extends T ? ["*"] | ["*", ..._WildcardPathAsArray] : { [K in GetKeys]: ["*"] | ["*", ..._WildcardPathAsArray] | [K] | [K, ..._WildcardPathAsArray] }[GetKeys] : never); type WildcardPathAsArray = _WildcardPathAsArray; type WildcardPathAsString = ArrayToStringPath<_WildcardPathAsArray>; type WildcardPath = WildcardPathAsString | WildcardPathAsArray; type WildcardValue = true extends IsAny | IsAny ? any : true extends IsNever | IsNever ? never : P$1 extends string ? WildcardValue> : P$1 extends readonly [infer First extends KeyType, ...infer Rest extends KeyType[]] ? T extends Map | Set ? WildcardValue | (First extends "*" ? never : undefined) : T extends Array_ ? First extends "*" ? WildcardValue : any[] extends T ? WildcardValue | undefined : First extends keyof T ? WildcardValue : undefined : T extends Object_ ? First extends "*" ? WildcardValue : Record extends T ? WildcardValue | undefined : WildcardValue : never : T; type Join = A extends "" ? B : B extends "" ? A : `${A}.${B}`; type _SettablePathAsArray = readonly [] | (true extends IsAny ? readonly KeyType[] : undefined extends T ? T extends Map | Set ? never : T extends Object_ ? { [K in GetKeys]: Partial extends Omit ? readonly [K] | readonly [K, ..._SettablePathAsArray] : readonly [] }[GetKeys] : never : T extends never ? never : T extends Object_ ? Depth["length"] extends MaxDepth ? readonly string[] : T extends Map ? readonly [K] | readonly [K, ..._SettablePathAsArray] : T extends Set ? readonly [number] : { [K in GetKeys]: readonly [K] | readonly [K, ..._SettablePathAsArray] }[GetKeys] : never); type SettablePathAsArray = _SettablePathAsArray; type SettablePathAsString = ArrayToStringPath>; type SettablePath = SettablePathAsString | SettablePathAsArray; type SettableValue = P$1 extends readonly [] ? T : true extends IsAny | IsAny ? any : true extends IsNever | IsNever ? never : P$1 extends string ? SettableValue> : P$1 extends readonly [infer First extends KeyType, ...infer Rest extends readonly KeyType[]] ? T extends Map | Set ? SettableValue : T extends Array_ ? SettableValue : T extends Object_ ? SettableValue : never : never; //#endregion //#region src/lib/debounce.d.ts type DebounceOptions = Duration | { wait: Duration; maxWait?: Duration; waitOnRunNow?: boolean; }; //#endregion //#region src/core/commonTypes.d.ts interface Listener { (this: TThis, value: T, previouseValue?: T): void; } interface Selector { (value: T): S$1; } interface Effect { (this: T, context: T): void | Cancel; } interface SubscribeOptions { /** If set, this listener does not activate the store. * @default false */ passive?: boolean; /** Whether to execute the callback immediately with the current store value. * @default true */ runNow?: boolean; /** If set, throttle how often the callback can be executed. * The values says how much time needs to pass between to calls. * @example * subscribe(callback, { throttle: { seconds: 10 } }); // Will execute immediately and then at least 10 seconds havbe to pass. If the store changed during those 10 seconds, the callback will be executed again. */ throttle?: Duration; /** If set, callback execution is delayed. */ debounce?: DebounceOptions; /** Provide a custom equality function. By default a strict equals (===) will be used. */ equals?: (a: any, b: any) => boolean; /** An optional AbortSignal that can be used to unsubscribe the listener automatically. */ signal?: AbortSignal; } interface EffectOptions { /** If provided, delay tearing down effects when the last subscriber is removed. This is useful if a short gap in subscriber coverage is supposed to be ignored. E.g. when switching pages, the old page might unsubscribe, while the new page subscribes immediately after. */ retain?: Duration; /** An optional AbortSignal that can be used to cancel the effect. */ signal?: AbortSignal; } interface Cancel { (): void; } interface DisposableCancel { (): void; [Symbol.dispose](): void; } interface DurationObject { milliseconds?: number; seconds?: number; minutes?: number; hours?: number; days?: number; months?: number; years?: number; } type Duration = number | string | DurationObject; type UpdateFrom = Value$1 | ((...args: From) => Value$1); type Update = UpdateFrom; interface UpdateFunction { (update: Update): void; } interface AsyncUpdateFunction { (update: UpdateFrom, [Value$1]>): void; } interface StoreLike { get(): T; subscribe(listener: (value: T) => void, options?: { runNow?: boolean; }): Cancel; invalidate(recursive?: boolean): void; } interface Use { (store: StoreLike): T; } interface BaseConnectionActions { set: UpdateFunction; } interface AsyncConnectionActions extends BaseConnectionActions { updateValue: AsyncUpdateFunction; updateError: (error: unknown) => void; updateIsConnected: (isConnected: boolean) => void; close: () => void; } type ConnectionActions = BaseConnectionActions & (T extends Promise ? AsyncConnectionActions : {}); interface Connection { (actions: ConnectionActions): Cancel; } interface CalculationActions { signal: AbortSignal; use: Use; connect(connection: Connection): Promise; } //#endregion //#region src/lib/calculatedValue.d.ts interface CalculatedValue { value: T; check: () => void; stop(): void; invalidateDependencies(recursive?: boolean): void; } //#endregion //#region src/lib/promiseWithCancel.d.ts declare class PromiseWithCancel extends Promise { private abortController; constructor(executor: (resolve: (value: T) => void, reject: (error: unknown) => void, signal: AbortSignal) => void); cancel(reason?: any): void; } //#endregion //#region src/lib/standardMethods.d.ts type Function_ = (...args: any) => any; declare const arrayMethods: { [P in "splice" | "push" | "pop" | "shift" | "unshift" | "reverse" | "sort"]: >(this: Store, ...args: T[P] extends Function_ ? Parameters : never) => T[P] extends Function_ ? ReturnType : never }; declare const recordMethods: { delete, K$1 extends OptionalPropertyOf>(this: Store, key: K$1): void; clear>(this: OptionalProperties extends T ? Store : never): void; }; declare const mapMethods: { delete(this: Store>, key: K$1): boolean; clear(this: Store>): void; }; declare const setMethods: { add(this: Store>, value: T): void; delete(this: Store>, value: T): void; clear(this: Store>): void; }; //#endregion //#region src/core/store.d.ts type StoreMethods = Record any>; type BoundStoreMethods = Methods & ThisType & Methods>; interface StoreOptions { retain?: Duration; equals?: SubscribeOptions["equals"]; effect?: Effect> | { effect: Effect>; retain?: Duration; }; cacheValue?: boolean; } interface StoreOptionsWithMethods extends StoreOptions { methods?: Methods & ThisType & Methods & StandardMethods>; } type Calculate = (helpers: CalculationActions) => T; type StandardMethods = T extends Map ? typeof mapMethods : T extends Set ? typeof setMethods : T extends Array ? typeof arrayMethods : T extends Record ? typeof recordMethods : Record; type StoreWithMethods = Store & Omit, keyof Store> & StandardMethods; interface OnceOptions { signal?: AbortSignal; timeout?: Duration; } declare class Store { readonly getter: T | Calculate; readonly options: StoreOptions; readonly derivedFrom?: { store: Store; selectors: (Selector | AnyPath)[]; updater: (state: any) => void; } | undefined; private static hooks?; static addHook(hook: (store: Store) => void): DisposableCancel; version?: string; protected calculatedValue?: CalculatedValue; protected defaultValue?: CalculatedValue; protected listeners: Map; protected effects: Map>, { handle?: Cancel; retain?: number; timeout?: ReturnType; }>; protected notifyId: {}; constructor(getter: T | Calculate, options?: StoreOptions, derivedFrom?: { store: Store; selectors: (Selector | AnyPath)[]; updater: (state: any) => void; } | undefined); get(): T; set(update: Update): void; set(path: Constrain>, update: Update>): void; invalidate(recursive?: boolean): void; subscribe(listener: Listener, options?: SubscribeOptions): DisposableCancel; once(condition: (value: T) => value is S$1, options?: OnceOptions): PromiseWithCancel; once(condition: (value: T) => boolean, options?: OnceOptions): PromiseWithCancel; once(options?: OnceOptions): PromiseWithCancel>; map(selector: Selector, updater?: (value: S$1) => Update): Store; map(selector: Constrain>): Store>; /** Add an effect that will be executed when the store becomes active, which means when it has at least one subscriber. * @param effect * If there is already a subscriber, the effect will be executed immediately. * Otherweise it will be executed as soon as the first subscription is created. * Every time all subscriptions are removed and the first is created again, the effect will be executed again. * @param retain * If provided, delay tearing down effects when the last subscriber is removed. This is useful if a short gap in subscriber coverage is supposed to be ignored. E.g. when switching pages, the old page might unsubscribe, while the new page subscribes immediately after. * @returns * The effect can return a teardown callback, which will be executed when the last subscription is removed and potentially the ratain time has passed. */ addEffect(effect: Effect>, { retain, signal }?: EffectOptions): DisposableCancel; /** Return whether the store is currently active, which means whether it has at least one subscriber. */ isActive(): boolean; protected onSubscribe(): void; protected onUnsubscribe(): void; protected notify(): void; } declare function create(calculate: Calculate, options?: StoreOptions): Store; declare function create(initialState: T, options?: StoreOptionsWithMethods): StoreWithMethods; declare const createStore: typeof create & { defaultOptions: StoreOptions; }; //#endregion export { GetKeys as A, Value as B, Selector as C, UpdateFunction as D, UpdateFrom as E, PathAsString as F, MaybePromise as G, WildcardPathAsString as H, SettablePath as I, Constrain as K, SettablePathAsArray as L, KeyType as M, Path as N, Use as O, PathAsArray as P, SettablePathAsString as R, Listener as S, Update as T, WildcardValue as U, WildcardPath as V, Object_ as W, Connection as _, StoreOptions as a, Duration as b, arrayMethods as c, setMethods as d, AsyncConnectionActions as f, Cancel as g, CalculationActions as h, StoreMethods as i, Join as j, AnyPath as k, mapMethods as l, BaseConnectionActions as m, Calculate as n, StoreOptionsWithMethods as o, AsyncUpdateFunction as p, Store as r, createStore as s, BoundStoreMethods as t, recordMethods as u, ConnectionActions as v, SubscribeOptions as w, Effect as x, DisposableCancel as y, SettableValue as z }; //# sourceMappingURL=store-21GsOOLS.d.cts.map