@storesjs/stores 0.11.0 → 0.12.1
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/dist/index.d.ts +1586 -4
- package/dist/native/index.js +7 -1
- package/dist/native/index.mjs +7 -1
- package/dist/plugins/chrome/index.d.ts +186 -4
- package/dist/vanilla/index.js +1 -1
- package/dist/vanilla/index.mjs +1 -1
- package/dist/vanilla/index.vanilla.d.ts +1472 -1
- package/dist/web/chrome.js +1 -1
- package/dist/web/chrome.mjs +1 -1
- package/dist/web/index.js +1 -1
- package/dist/web/index.mjs +1 -1
- package/dist/web/internal/runtime.js +2 -1
- package/dist/web/internal/runtime.mjs +2 -1
- package/dist/web/queryParam-Ckp7Zi5t.mjs +1 -0
- package/dist/web/queryParam-Ctnhipnd.js +1 -0
- package/dist/web/serialization-BgaGfw_1.mjs +1 -0
- package/dist/web/serialization-Dau9pNHc.js +1 -0
- package/dist/web/utils-Ba1RIeAA.mjs +1 -0
- package/dist/web/utils-CwejruRb.js +1 -0
- package/package.json +9 -8
- package/dist/createBaseStore.d.ts +0 -36
- package/dist/createDerivedStore.d.ts +0 -63
- package/dist/createQueryStore.d.ts +0 -111
- package/dist/createVirtualStore.d.ts +0 -40
- package/dist/env.native.d.ts +0 -7
- package/dist/env.web.d.ts +0 -7
- package/dist/hooks/useLazyRef.d.ts +0 -13
- package/dist/hooks/useListen.d.ts +0 -98
- package/dist/hooks/useStableValue.d.ts +0 -16
- package/dist/hooks/useSyncExternalStoreWithSelector.d.ts +0 -5
- package/dist/index.shared.d.ts +0 -14
- package/dist/index.vanilla.d.ts +0 -2
- package/dist/internal/baseStore.d.ts +0 -2
- package/dist/internal/config.d.ts +0 -64
- package/dist/internal/createStoreActions.d.ts +0 -24
- package/dist/internal/derivedStore/deriveProxy.d.ts +0 -15
- package/dist/internal/derivedStore/pathFinder.d.ts +0 -26
- package/dist/internal/derivedStore.d.ts +0 -2
- package/dist/internal/errors.d.ts +0 -10
- package/dist/internal/logger.d.ts +0 -10
- package/dist/internal/middleware/createHydrationGate.d.ts +0 -20
- package/dist/internal/queryStore/queryParams.d.ts +0 -18
- package/dist/internal/queryStore/queryStoreDefaults.d.ts +0 -8
- package/dist/internal/queryStore.d.ts +0 -2
- package/dist/internal/runtime.d.ts +0 -12
- package/dist/internal/storage/storageCreators.d.ts +0 -12
- package/dist/internal/storeUtils.d.ts +0 -46
- package/dist/internal/sync/browserSyncEngine.d.ts +0 -3
- package/dist/internal/sync/noopSyncEngine.d.ts +0 -3
- package/dist/internal/sync/syncEnhancer.d.ts +0 -26
- package/dist/internal/sync/syncUtils.d.ts +0 -6
- package/dist/internal/types/internalSubscribeTypes.d.ts +0 -16
- package/dist/internal/utils/persistUtils.d.ts +0 -9
- package/dist/internal/virtualStore.d.ts +0 -2
- package/dist/plugins/chrome/chromeExtensionSyncEngine.d.ts +0 -30
- package/dist/plugins/chrome/chromeStorageAdapter.d.ts +0 -31
- package/dist/plugins/chrome/createSyncedChromeStorage.d.ts +0 -14
- package/dist/queryStore/classes/SubscriptionManager.d.ts +0 -39
- package/dist/queryStore/queryKey.d.ts +0 -10
- package/dist/queryStore/queryParam.d.ts +0 -37
- package/dist/queryStore/types.d.ts +0 -361
- package/dist/storage/storageTypes.d.ts +0 -13
- package/dist/store/attachStoreHook.react.d.ts +0 -5
- package/dist/store/attachStoreHook.vanilla.d.ts +0 -6
- package/dist/store/batchStoreNotifications.native.d.ts +0 -3
- package/dist/store/batchStoreNotifications.web.d.ts +0 -2
- package/dist/store/cascadeScheduler.d.ts +0 -38
- package/dist/store/createStore.d.ts +0 -6
- package/dist/store/persist.d.ts +0 -14
- package/dist/store/stateUpdate.d.ts +0 -10
- package/dist/store/types.d.ts +0 -108
- package/dist/storesStorage.native.d.ts +0 -3
- package/dist/storesStorage.web.d.ts +0 -3
- package/dist/sync/types.d.ts +0 -115
- package/dist/types/functions.d.ts +0 -24
- package/dist/types/objects.d.ts +0 -11
- package/dist/types/setState.d.ts +0 -22
- package/dist/types/subscribe.d.ts +0 -27
- package/dist/types/useStoreCallSignatures.d.ts +0 -2
- package/dist/types/useStoreCallSignatures.react.d.ts +0 -6
- package/dist/types/useStoreCallSignatures.vanilla.d.ts +0 -2
- package/dist/types/utils.d.ts +0 -13
- package/dist/types.d.ts +0 -288
- package/dist/utils/core.d.ts +0 -26
- package/dist/utils/createAsyncMicrotaskScheduler.d.ts +0 -35
- package/dist/utils/createMicrotaskScheduler.d.ts +0 -29
- package/dist/utils/debounce.d.ts +0 -22
- package/dist/utils/equality.d.ts +0 -38
- package/dist/utils/hydrationCoordinator.d.ts +0 -13
- package/dist/utils/promiseUtils.d.ts +0 -2
- package/dist/utils/serialization.d.ts +0 -14
- package/dist/utils/stringUtils.d.ts +0 -7
- package/dist/utils/time.d.ts +0 -37
- package/dist/vanilla/createBaseStore.d.ts +0 -35
- package/dist/vanilla/createDerivedStore.d.ts +0 -62
- package/dist/vanilla/createQueryStore.d.ts +0 -110
- package/dist/vanilla/createVirtualStore.d.ts +0 -39
- package/dist/vanilla/env.web.d.ts +0 -6
- package/dist/vanilla/index.d.ts +0 -1
- package/dist/vanilla/index.shared.d.ts +0 -13
- package/dist/vanilla/internal/baseStore.d.ts +0 -1
- package/dist/vanilla/internal/config.d.ts +0 -63
- package/dist/vanilla/internal/createStoreActions.d.ts +0 -23
- package/dist/vanilla/internal/derivedStore/deriveProxy.d.ts +0 -14
- package/dist/vanilla/internal/derivedStore/pathFinder.d.ts +0 -25
- package/dist/vanilla/internal/derivedStore.d.ts +0 -1
- package/dist/vanilla/internal/errors.d.ts +0 -9
- package/dist/vanilla/internal/logger.d.ts +0 -9
- package/dist/vanilla/internal/middleware/createHydrationGate.d.ts +0 -19
- package/dist/vanilla/internal/queryStore/queryParams.d.ts +0 -17
- package/dist/vanilla/internal/queryStore/queryStoreDefaults.d.ts +0 -7
- package/dist/vanilla/internal/queryStore.d.ts +0 -1
- package/dist/vanilla/internal/runtime.d.ts +0 -11
- package/dist/vanilla/internal/storage/storageCreators.d.ts +0 -11
- package/dist/vanilla/internal/storeUtils.d.ts +0 -45
- package/dist/vanilla/internal/sync/browserSyncEngine.d.ts +0 -2
- package/dist/vanilla/internal/sync/noopSyncEngine.d.ts +0 -2
- package/dist/vanilla/internal/sync/syncEnhancer.d.ts +0 -25
- package/dist/vanilla/internal/types/internalSubscribeTypes.d.ts +0 -15
- package/dist/vanilla/internal/utils/persistUtils.d.ts +0 -8
- package/dist/vanilla/internal/virtualStore.d.ts +0 -1
- package/dist/vanilla/queryStore/classes/SubscriptionManager.d.ts +0 -38
- package/dist/vanilla/queryStore/queryKey.d.ts +0 -9
- package/dist/vanilla/queryStore/queryParam.d.ts +0 -36
- package/dist/vanilla/queryStore/types.d.ts +0 -360
- package/dist/vanilla/storage/storageTypes.d.ts +0 -12
- package/dist/vanilla/store/attachStoreHook.d.ts +0 -5
- package/dist/vanilla/store/attachStoreHook.vanilla.d.ts +0 -5
- package/dist/vanilla/store/batchStoreNotifications.web.d.ts +0 -1
- package/dist/vanilla/store/cascadeScheduler.d.ts +0 -37
- package/dist/vanilla/store/createStore.d.ts +0 -5
- package/dist/vanilla/store/persist.d.ts +0 -13
- package/dist/vanilla/store/stateUpdate.d.ts +0 -9
- package/dist/vanilla/store/types.d.ts +0 -107
- package/dist/vanilla/storesStorage.web.d.ts +0 -2
- package/dist/vanilla/sync/types.d.ts +0 -114
- package/dist/vanilla/types/functions.d.ts +0 -23
- package/dist/vanilla/types/objects.d.ts +0 -10
- package/dist/vanilla/types/setState.d.ts +0 -21
- package/dist/vanilla/types/subscribe.d.ts +0 -26
- package/dist/vanilla/types/useStoreCallSignatures.d.ts +0 -1
- package/dist/vanilla/types/useStoreCallSignatures.vanilla.d.ts +0 -1
- package/dist/vanilla/types/utils.d.ts +0 -12
- package/dist/vanilla/types.d.ts +0 -287
- package/dist/vanilla/utils/core.d.ts +0 -25
- package/dist/vanilla/utils/createAsyncMicrotaskScheduler.d.ts +0 -34
- package/dist/vanilla/utils/createMicrotaskScheduler.d.ts +0 -28
- package/dist/vanilla/utils/debounce.d.ts +0 -21
- package/dist/vanilla/utils/equality.d.ts +0 -37
- package/dist/vanilla/utils/hydrationCoordinator.d.ts +0 -12
- package/dist/vanilla/utils/promiseUtils.d.ts +0 -1
- package/dist/vanilla/utils/serialization.d.ts +0 -13
- package/dist/vanilla/utils/stringUtils.d.ts +0 -6
- package/dist/vanilla/utils/time.d.ts +0 -36
- package/dist/web/chunk-FENSEQ3V.mjs +0 -1
- package/dist/web/chunk-FPYZVFBM.mjs +0 -1
- package/dist/web/chunk-PLDNKWGX.mjs +0 -1
package/dist/sync/types.d.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { UnknownFunction } from '../types/functions';
|
|
2
|
-
/**
|
|
3
|
-
* Metadata for a field's last write.
|
|
4
|
-
*/
|
|
5
|
-
export type FieldMetadata = readonly [timestamp: number, sessionId: string];
|
|
6
|
-
export type SyncStateKey<T extends Record<string, unknown>> = Extract<{
|
|
7
|
-
[K in keyof T]-?: T[K] extends UnknownFunction ? never : K;
|
|
8
|
-
}[keyof T], string>;
|
|
9
|
-
export type SyncValues<T extends Record<string, unknown>> = Partial<T> & {
|
|
10
|
-
[K in SyncStateKey<T>]?: T[K];
|
|
11
|
-
};
|
|
12
|
-
export type SyncUpdate<T extends Record<string, unknown>> = {
|
|
13
|
-
replace: boolean;
|
|
14
|
-
sessionId: string;
|
|
15
|
-
timestamp: number;
|
|
16
|
-
values: SyncValues<T>;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Passed to `SyncEngine.register()` to connect a store to the sync system.
|
|
20
|
-
*/
|
|
21
|
-
export type SyncRegistration<T extends Record<string, unknown>> = {
|
|
22
|
-
/** Callback invoked by the engine to apply incoming remote updates to the store. */
|
|
23
|
-
apply: (update: SyncUpdate<T>) => void;
|
|
24
|
-
/** The state keys to sync. Non-function properties only. */
|
|
25
|
-
fields: ReadonlyArray<SyncStateKey<T>>;
|
|
26
|
-
/** Returns the store's current state. Used by engines that need to read state (e.g., for diffing). */
|
|
27
|
-
getState: () => T;
|
|
28
|
-
/** Unique identifier for this store. Must match across clients to sync the same data. */
|
|
29
|
-
key: string;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Returned by `SyncEngine.register()`. Controls the lifecycle of a synced store.
|
|
33
|
-
*/
|
|
34
|
-
export interface SyncHandle<T extends Record<string, unknown>> {
|
|
35
|
-
/**
|
|
36
|
-
* Permanently removes this store from the sync engine. After calling, the handle
|
|
37
|
-
* is invalid and the store will no longer send or receive updates. To temporarily
|
|
38
|
-
* pause sync, use `onFirstSubscribe`/`onLastUnsubscribe` lifecycle hooks instead.
|
|
39
|
-
*/
|
|
40
|
-
destroy: () => void;
|
|
41
|
-
/** Returns `true` once the store has received its initial state from the engine. */
|
|
42
|
-
hydrated?: () => boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Called when the store's subscriber count goes from 0 to 1. The registration
|
|
45
|
-
* remains active. Use for lazy resource acquisition (e.g., opening a WebSocket).
|
|
46
|
-
*/
|
|
47
|
-
onFirstSubscribe?: () => void;
|
|
48
|
-
/** Registers a one-time callback to run when hydration completes. */
|
|
49
|
-
onHydrated?: (callback: () => void) => void;
|
|
50
|
-
/**
|
|
51
|
-
* Called when the store's subscriber count drops to 0. The registration remains
|
|
52
|
-
* active and `onFirstSubscribe` will fire again on the next subscription.
|
|
53
|
-
* Use for resource cleanup (e.g., closing idle connections).
|
|
54
|
-
*/
|
|
55
|
-
onLastUnsubscribe?: () => void;
|
|
56
|
-
/**
|
|
57
|
-
* Broadcasts a state update to other clients. Set to `null` for engines where
|
|
58
|
-
* publishing is implicit (e.g., `chrome.storage` where the write itself triggers sync).
|
|
59
|
-
*/
|
|
60
|
-
publish: ((update: SyncUpdate<T>) => void) | null;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Interface for multi-client state synchronization. Stores register to send and receive updates.
|
|
64
|
-
*/
|
|
65
|
-
export interface SyncEngine {
|
|
66
|
-
/**
|
|
67
|
-
* When `true`, embeds sync metadata (`{ origin, timestamp, fields }`) into persisted
|
|
68
|
-
* storage values. Required for engines that use storage writes as their transport.
|
|
69
|
-
* Only effective when the store is also persisted.
|
|
70
|
-
* @default false
|
|
71
|
-
*/
|
|
72
|
-
readonly injectStorageMetadata?: boolean;
|
|
73
|
-
/** Registers a store for synchronization. Returns a handle to control the sync lifecycle. */
|
|
74
|
-
register: {
|
|
75
|
-
<T extends Record<string, unknown>>(registration: SyncRegistration<T>): SyncHandle<T>;
|
|
76
|
-
(registration: SyncRegistration<Record<string, unknown>>): SyncHandle<Record<string, unknown>>;
|
|
77
|
-
};
|
|
78
|
-
/** Unique identifier for this client session. Used for conflict resolution and filtering self-updates. */
|
|
79
|
-
readonly sessionId: string;
|
|
80
|
-
}
|
|
81
|
-
export type SyncMergeFn<T, TState = unknown> = (incoming: T, current: T, currentState: TState, incomingValues: Partial<TState>) => T;
|
|
82
|
-
export type SyncConfig<T extends Record<string, unknown>> = {
|
|
83
|
-
/**
|
|
84
|
-
* The sync engine implementation to use.
|
|
85
|
-
*
|
|
86
|
-
* Defaults to cross-tab sync in browser environments. No-op in other environments unless a
|
|
87
|
-
* custom engine is provided.
|
|
88
|
-
*/
|
|
89
|
-
engine?: SyncEngine;
|
|
90
|
-
/** The state keys to sync. If unspecified, all non-function store properties are synced. */
|
|
91
|
-
fields?: ReadonlyArray<SyncStateKey<T>>;
|
|
92
|
-
/**
|
|
93
|
-
* When true, injects sync metadata (`{ origin, timestamp, fields }`) into the persisted
|
|
94
|
-
* storage payload. Only takes effect when used with a persisted store.
|
|
95
|
-
*
|
|
96
|
-
* Useful for sync engines that use storage events as their transport (e.g., `chrome.storage`).
|
|
97
|
-
*
|
|
98
|
-
* Can also be set on the `engine` object. This option takes precedence if both are provided.
|
|
99
|
-
* @default false
|
|
100
|
-
*/
|
|
101
|
-
injectStorageMetadata?: boolean;
|
|
102
|
-
/** The key used to identify the store to the sync engine. Required if `storageKey` is absent. */
|
|
103
|
-
key?: string;
|
|
104
|
-
/** Optional merge function to use for each synced state key. Use with caution. */
|
|
105
|
-
merge?: {
|
|
106
|
-
[K in SyncStateKey<T>]?: SyncMergeFn<T[K], T>;
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
/**
|
|
110
|
-
* Internal type for `SyncConfig` with `key` always present.
|
|
111
|
-
*/
|
|
112
|
-
export type NormalizedSyncConfig<T extends Record<string, unknown>> = SyncConfig<T> & {
|
|
113
|
-
key: string;
|
|
114
|
-
};
|
|
115
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Relaxes function parameter variance to allow subtype
|
|
3
|
-
* assignment otherwise blocked by strict contravariance.
|
|
4
|
-
*/
|
|
5
|
-
export type BivariantMethod<T extends Record<string, UnknownFunction>> = T[keyof T];
|
|
6
|
-
/**
|
|
7
|
-
* Extract the keys of `T` whose values are functions.
|
|
8
|
-
*/
|
|
9
|
-
export type FunctionKeys<T> = {
|
|
10
|
-
[K in keyof T]-?: T[K] extends UnknownFunction ? K : never;
|
|
11
|
-
}[keyof T];
|
|
12
|
-
/**
|
|
13
|
-
* A record of string keys to unknown functions.
|
|
14
|
-
*/
|
|
15
|
-
export type FunctionRecord = Record<string, UnknownFunction>;
|
|
16
|
-
/**
|
|
17
|
-
* Return `T` if it is **not** a function, otherwise `never`.
|
|
18
|
-
*/
|
|
19
|
-
export type NonFunction<T> = T extends (...args: infer _) => unknown ? never : T;
|
|
20
|
-
/**
|
|
21
|
-
* Unknown generic function type.
|
|
22
|
-
*/
|
|
23
|
-
export type UnknownFunction = (...args: never[]) => unknown;
|
|
24
|
-
//# sourceMappingURL=functions.d.ts.map
|
package/dist/types/objects.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Forces TypeScript to expand a type for clearer IDE display.
|
|
3
|
-
*/
|
|
4
|
-
export type Prettify<T> = T extends infer U ? {
|
|
5
|
-
[K in keyof U]: U[K];
|
|
6
|
-
} : never;
|
|
7
|
-
/**
|
|
8
|
-
* Enforce no overlapping keys between two objects.
|
|
9
|
-
*/
|
|
10
|
-
export type NoOverlap<A, B> = B & Record<Extract<keyof A, keyof B>, never>;
|
|
11
|
-
//# sourceMappingURL=objects.d.ts.map
|
package/dist/types/setState.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { BivariantMethod } from './functions';
|
|
2
|
-
export type SetPartial<S> = S | Partial<S> | BivariantMethod<{
|
|
3
|
-
updater(state: S): S | Partial<S>;
|
|
4
|
-
}>;
|
|
5
|
-
export type SetFull<S> = S | BivariantMethod<{
|
|
6
|
-
updater(state: S): S;
|
|
7
|
-
}>;
|
|
8
|
-
export type SetStateReplaceArgs<S, ExtraArgs extends unknown[] = []> = [update: SetFull<S>, replace: true, ...extraArgs: ExtraArgs];
|
|
9
|
-
export type SetStatePartialArgs<S, ExtraArgs extends unknown[] = []> = [update: SetPartial<S>, replace?: false, ...extraArgs: ExtraArgs];
|
|
10
|
-
export type SetStateArgs<S, ExtraArgs extends unknown[] = []> = SetStatePartialArgs<S, ExtraArgs> | SetStateReplaceArgs<S, ExtraArgs>;
|
|
11
|
-
/**
|
|
12
|
-
* Rest-argument form of `setState`, used when forwarding calls.
|
|
13
|
-
*/
|
|
14
|
-
export type SetState<S, ExtraArgs extends unknown[] = [], PersistReturn extends Promise<void> | void = void> = (...args: SetStateArgs<S, ExtraArgs>) => PersistReturn;
|
|
15
|
-
/**
|
|
16
|
-
* Store `setState` method overloads for partial updates and full replacement.
|
|
17
|
-
*/
|
|
18
|
-
export type SetStateOverloads<S, PersistReturn extends Promise<void> | void = void> = BivariantMethod<{
|
|
19
|
-
setState(update: SetPartial<S>, replace?: false): PersistReturn;
|
|
20
|
-
setState(update: SetFull<S>, replace: true): PersistReturn;
|
|
21
|
-
}>;
|
|
22
|
-
//# sourceMappingURL=setState.d.ts.map
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export type Listener<S> = (state: S, prevState: S) => void;
|
|
2
|
-
export type Selector<S, Selected> = (state: S) => Selected;
|
|
3
|
-
export type EqualityFn<T = unknown> = (a: T, b: T) => boolean;
|
|
4
|
-
/**
|
|
5
|
-
* Minimum store API required for subscription.
|
|
6
|
-
*/
|
|
7
|
-
export type SubscribableStore = {
|
|
8
|
-
subscribe(selector: Selector<unknown, unknown>, listener: () => void, options?: SubscribeOptions<unknown>): UnsubscribeFn;
|
|
9
|
-
};
|
|
10
|
-
export type SubscribeOptions<Selected> = {
|
|
11
|
-
equalityFn?: EqualityFn<Selected>;
|
|
12
|
-
fireImmediately?: boolean;
|
|
13
|
-
};
|
|
14
|
-
export type ListenerArgs<S> = [listener: Listener<S>];
|
|
15
|
-
export type SelectorArgs<S, Selected> = [
|
|
16
|
-
selector: Selector<S, Selected>,
|
|
17
|
-
listener: Listener<Selected>,
|
|
18
|
-
options?: SubscribeOptions<Selected>
|
|
19
|
-
];
|
|
20
|
-
export type SubscribeArgs<S, Selected = unknown> = ListenerArgs<S> | SelectorArgs<S, Selected>;
|
|
21
|
-
export type UnsubscribeFn = () => void;
|
|
22
|
-
export type SubscribeFn<S, Selected = S> = (...args: SubscribeArgs<S, Selected>) => UnsubscribeFn;
|
|
23
|
-
export type SubscribeOverloads<S> = {
|
|
24
|
-
(listener: Listener<S>): UnsubscribeFn;
|
|
25
|
-
<Selected>(selector: Selector<S, Selected>, listener: Listener<Selected>, options?: SubscribeOptions<Selected>): UnsubscribeFn;
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=subscribe.d.ts.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { EqualityFn, Selector } from './subscribe';
|
|
2
|
-
export type UseStoreCallSignatures<State> = {
|
|
3
|
-
(): State;
|
|
4
|
-
<Selected>(selector: Selector<State, Selected>, equalityFn?: EqualityFn<Selected>): Selected;
|
|
5
|
-
};
|
|
6
|
-
//# sourceMappingURL=useStoreCallSignatures.react.d.ts.map
|
package/dist/types/utils.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typed `hasOwnProperty` alias.
|
|
3
|
-
*/
|
|
4
|
-
export declare function hasOwn<T extends Record<string, unknown>, K extends string>(value: T, key: K): value is T & Record<K, unknown>;
|
|
5
|
-
/**
|
|
6
|
-
* Checks prototype is `Object.prototype` or `null`. Excludes arrays, class instances, etc.
|
|
7
|
-
*/
|
|
8
|
-
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
9
|
-
/**
|
|
10
|
-
* Checks for non-null, non-array objects.
|
|
11
|
-
*/
|
|
12
|
-
export declare function isRecordLike(value: unknown): value is Record<string, unknown>;
|
|
13
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/types.d.ts
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import type { StorageValue } from './storage/storageTypes';
|
|
2
|
-
import type { PersistOptions, StateCreator as StoreStateCreator, StoreApi, StoreMutators, WithPersist } from './store/types';
|
|
3
|
-
import type { SyncConfig } from './sync/types';
|
|
4
|
-
import type { FunctionKeys } from './types/functions';
|
|
5
|
-
import type { SetFull, SetPartial, SetStateArgs } from './types/setState';
|
|
6
|
-
import type { EqualityFn, Selector, SubscribeOverloads } from './types/subscribe';
|
|
7
|
-
import type { UseStoreCallSignatures } from './types/useStoreCallSignatures';
|
|
8
|
-
export type { StoreMutators } from './store/types';
|
|
9
|
-
export type * from './types/setState';
|
|
10
|
-
export type * from './types/subscribe';
|
|
11
|
-
export type * from './types/useStoreCallSignatures';
|
|
12
|
-
export type StoreMutatorsWithSelector<Mutators extends StoreMutators = StoreMutators> = Mutators;
|
|
13
|
-
export type StateCreator<S, U = S> = StoreStateCreator<S, [], [], U>;
|
|
14
|
-
export type UseBoundStoreWithEqualityFn<Store extends {
|
|
15
|
-
getState: () => unknown;
|
|
16
|
-
}, State = InferStoreState<Store>> = UseStoreCallSignatures<State> & Store;
|
|
17
|
-
export type BaseStore<S> = UseBoundStoreWithEqualityFn<StoreApi<S>> & {
|
|
18
|
-
subscribe: SubscribeOverloads<S>;
|
|
19
|
-
};
|
|
20
|
-
export type PersistedStore<S, PersistedState = Partial<S>, PersistReturn extends void | Promise<void> = void | Promise<void>> = UseStoreCallSignatures<S> & WithPersist<BaseStore<S>, PersistedState, PersistReturn>;
|
|
21
|
-
export type Store<S, PersistedState extends Partial<S> = never, PersistReturn extends void | Promise<void> = void | Promise<void>> = [
|
|
22
|
-
PersistedState
|
|
23
|
-
] extends [never] ? BaseStore<S> : PersistedStore<S, PersistedState, PersistReturn>;
|
|
24
|
-
/**
|
|
25
|
-
* Store returned by creators that accept optional persistence options.
|
|
26
|
-
* `persist` exists only when persistence is configured.
|
|
27
|
-
*/
|
|
28
|
-
export type OptionallyPersistedStore<S, PersistedState, PersistReturn extends void | Promise<void> = void> = UseStoreCallSignatures<S> & Omit<BaseStore<S>, 'setState'> & {
|
|
29
|
-
persist?: PersistedStore<S, PersistedState, PersistReturn>['persist'];
|
|
30
|
-
setState(update: SetPartial<S>, replace?: false): PersistReturn;
|
|
31
|
-
setState(update: SetFull<S>, replace: true): PersistReturn;
|
|
32
|
-
};
|
|
33
|
-
export type NoInfer<T> = [T][T extends unknown ? 0 : never];
|
|
34
|
-
export type Timeout = ReturnType<typeof setTimeout>;
|
|
35
|
-
export type InferStoreState<Store> = Store extends {
|
|
36
|
-
getState: () => infer T;
|
|
37
|
-
} ? T : never;
|
|
38
|
-
/**
|
|
39
|
-
* Action methods returned by `createStoreActions(store)`.
|
|
40
|
-
*/
|
|
41
|
-
export type StoreActions<Store extends StoreApi<unknown>> = Pick<InferStoreState<Store>, FunctionKeys<InferStoreState<Store>>>;
|
|
42
|
-
/**
|
|
43
|
-
* Extracts a store's `setState` return type.
|
|
44
|
-
* - `void` for non-persisted or synchronous persisted stores.
|
|
45
|
-
* - `Promise<void>` for async persisted stores.
|
|
46
|
-
*/
|
|
47
|
-
export type InferSetStateReturn<Store> = Store extends {
|
|
48
|
-
setState(...args: SetStateArgs<infer S>): infer R;
|
|
49
|
-
} ? R : void;
|
|
50
|
-
/**
|
|
51
|
-
* Extracts a store's `PersistedState` type.
|
|
52
|
-
* Returns `never` if the store doesn't use persistence.
|
|
53
|
-
*/
|
|
54
|
-
export type InferPersistedState<PersistedStore> = PersistedStore extends Store<infer _, infer PersistedState> ? PersistedState : never;
|
|
55
|
-
/**
|
|
56
|
-
* Reads store state and records dependencies for tracked computations.
|
|
57
|
-
* - `$(store, selector, equalityFn?)` depends on the selected state
|
|
58
|
-
* - `$(store)` depends on accessed state paths
|
|
59
|
-
*/
|
|
60
|
-
export type DeriveGetter = {
|
|
61
|
-
<Store extends StoreApi<InferStoreState<Store>>>(store: Store): InferStoreState<Store>;
|
|
62
|
-
<Store extends StoreApi<InferStoreState<Store>>, Selected>(store: Store, selector: Selector<InferStoreState<Store>, Selected>, equalityFn?: EqualityFn<Selected>): Selected;
|
|
63
|
-
};
|
|
64
|
-
export type DerivedStore<S> = WithFlushUpdates<ReadOnlyDerivedStore<BaseStore<S>>>;
|
|
65
|
-
export type WithFlushUpdates<Store extends StoreApi<unknown>> = Store & {
|
|
66
|
-
/**
|
|
67
|
-
* Destroy the derived store and its subscriptions.
|
|
68
|
-
*
|
|
69
|
-
* Derived stores automatically clean up internal resources and subscriptions
|
|
70
|
-
* when no subscribers exist. So calling `destroy()` is usually unnecessary,
|
|
71
|
-
* unless `keepAlive: true` is specified and explict teardown is desired.
|
|
72
|
-
*/
|
|
73
|
-
destroy: () => void;
|
|
74
|
-
/**
|
|
75
|
-
* Flush all pending updates — only applicable to **debounced** derived stores.
|
|
76
|
-
*/
|
|
77
|
-
flushUpdates: () => void;
|
|
78
|
-
};
|
|
79
|
-
export type WithGetSnapshot<Store extends StoreApi<unknown>> = Store & {
|
|
80
|
-
/**
|
|
81
|
-
* Reads the current snapshot while activating lazy derived stores before subscription.
|
|
82
|
-
*/
|
|
83
|
-
getSnapshot: () => InferStoreState<Store>;
|
|
84
|
-
};
|
|
85
|
-
type ReadOnlyDerivedStore<Store extends BaseStore<unknown>> = Omit<Store, 'getInitialState' | 'setState'> & UseStoreCallSignatures<InferStoreState<Store>> & {
|
|
86
|
-
/**
|
|
87
|
-
* @deprecated **Not applicable to derived stores.** Will throw an error.
|
|
88
|
-
*/
|
|
89
|
-
getInitialState: Store['getInitialState'];
|
|
90
|
-
/**
|
|
91
|
-
* @deprecated **Not applicable to derived stores.** Will throw an error.
|
|
92
|
-
*/
|
|
93
|
-
setState: Store['setState'];
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Configuration for creating derived stores. You can pass either:
|
|
97
|
-
* - A **function** (used as `equalityFn`), or
|
|
98
|
-
* - An **object** with the fields below
|
|
99
|
-
*/
|
|
100
|
-
export type DeriveOptions<DerivedState = unknown> = EqualityFn<DerivedState> | {
|
|
101
|
-
/**
|
|
102
|
-
* Delay before triggering a re-derive when dependencies change.
|
|
103
|
-
* Accepts a number (ms) or debounce options:
|
|
104
|
-
*
|
|
105
|
-
* `{ delay: number, leading?: boolean, trailing?: boolean, maxWait?: number }`
|
|
106
|
-
* @default 0
|
|
107
|
-
*/
|
|
108
|
-
debounce?: number | DebounceOptions;
|
|
109
|
-
/**
|
|
110
|
-
* If `true`, the store will log debug messages to the console.
|
|
111
|
-
*
|
|
112
|
-
* If `'verbose'`, the store will log the subscriptions it creates each time the derive
|
|
113
|
-
* function is run, rather than only the first time.
|
|
114
|
-
* @default false
|
|
115
|
-
*/
|
|
116
|
-
debugMode?: boolean | 'verbose';
|
|
117
|
-
/**
|
|
118
|
-
* A custom comparison function for detecting state changes.
|
|
119
|
-
* @default `Object.is`
|
|
120
|
-
*/
|
|
121
|
-
equalityFn?: EqualityFn<DerivedState>;
|
|
122
|
-
/**
|
|
123
|
-
* If `true`, the derived store will never destroy itself. Useful in cases where your
|
|
124
|
-
* derived store serves as a permanent cache subscribed to intermittently or not at all.
|
|
125
|
-
* Manual calls to `destroy` *will* destroy the store even when `keepAlive` is `true`.
|
|
126
|
-
*
|
|
127
|
-
* *Use this option carefully.*
|
|
128
|
-
* @default false
|
|
129
|
-
*/
|
|
130
|
-
keepAlive?: boolean;
|
|
131
|
-
/**
|
|
132
|
-
* Locks the dependency graph after the first derivation. Subscriptions to
|
|
133
|
-
* underlying stores are established once and reused on subsequent runs, rather
|
|
134
|
-
* than being torn down and rebuilt (the default behavior).
|
|
135
|
-
*
|
|
136
|
-
* This avoids the overhead of regenerating selectors and prevents unnecessary
|
|
137
|
-
* subscription churn. However, it means only the *initially tracked* dependencies
|
|
138
|
-
* will trigger updates — even if your derive function conditionally reads different
|
|
139
|
-
* stores in later runs.
|
|
140
|
-
*
|
|
141
|
-
* **Requirement**: All `$` calls in your derive function must be consistent and
|
|
142
|
-
* top level. Conditional dependency tracking will not work correctly.
|
|
143
|
-
*
|
|
144
|
-
* Safe to enable for most derived stores where dependencies are static.
|
|
145
|
-
*
|
|
146
|
-
* @default false
|
|
147
|
-
*/
|
|
148
|
-
lockDependencies?: boolean;
|
|
149
|
-
};
|
|
150
|
-
export type Deserializer<SerializedState, PersistedState> = (serializedState: SerializedState) => StorageValue<PersistedState>;
|
|
151
|
-
export type Serializer<SerializedState> = <PersistedState>(storageValue: StorageValue<PersistedState>) => SerializedState;
|
|
152
|
-
/**
|
|
153
|
-
* Synchronous storage interface.
|
|
154
|
-
* Used for localStorage and MMKV implementations.
|
|
155
|
-
*/
|
|
156
|
-
export type SyncStorageInterface<SerializedState = unknown> = {
|
|
157
|
-
readonly async?: false;
|
|
158
|
-
/**
|
|
159
|
-
* Adapter-level deserializer used when a store does not supply its own.
|
|
160
|
-
* Acts as the default before falling back to the framework implementation.
|
|
161
|
-
*/
|
|
162
|
-
deserializer?<PersistedState>(serializedState: SerializedState): StorageValue<PersistedState>;
|
|
163
|
-
/**
|
|
164
|
-
* Adapter-level serializer used when a store does not supply its own.
|
|
165
|
-
* Acts as the default before falling back to the framework implementation.
|
|
166
|
-
*/
|
|
167
|
-
serializer?<PersistedState>(storageValue: StorageValue<PersistedState>): SerializedState;
|
|
168
|
-
clearAll(): void;
|
|
169
|
-
contains(key: string): boolean;
|
|
170
|
-
delete(key: string): void;
|
|
171
|
-
get(key: string): SerializedState | undefined;
|
|
172
|
-
getAllKeys(): string[];
|
|
173
|
-
set(key: string, value: SerializedState): void;
|
|
174
|
-
};
|
|
175
|
-
/**
|
|
176
|
-
* Asynchronous storage interface.
|
|
177
|
-
* Used for Chrome storage and other async storage implementations.
|
|
178
|
-
*/
|
|
179
|
-
export type AsyncStorageInterface<SerializedState = unknown> = {
|
|
180
|
-
readonly async: true;
|
|
181
|
-
/**
|
|
182
|
-
* Adapter-level deserializer used when a store does not supply its own.
|
|
183
|
-
* Acts as the default before falling back to the framework implementation.
|
|
184
|
-
*/
|
|
185
|
-
deserializer?<PersistedState>(serializedState: SerializedState): StorageValue<PersistedState>;
|
|
186
|
-
/**
|
|
187
|
-
* Adapter-level serializer used when a store does not supply its own.
|
|
188
|
-
* Acts as the default before falling back to the framework implementation.
|
|
189
|
-
*/
|
|
190
|
-
serializer?<PersistedState>(storageValue: StorageValue<PersistedState>): SerializedState;
|
|
191
|
-
clearAll(): Promise<void>;
|
|
192
|
-
contains(key: string): Promise<boolean>;
|
|
193
|
-
delete(key: string): Promise<void>;
|
|
194
|
-
get(key: string): Promise<SerializedState | undefined>;
|
|
195
|
-
getAllKeys(): Promise<string[]>;
|
|
196
|
-
set(key: string, value: SerializedState): Promise<void>;
|
|
197
|
-
};
|
|
198
|
-
/**
|
|
199
|
-
* Configuration options for creating a persistable store.
|
|
200
|
-
*/
|
|
201
|
-
export type PersistConfig<S, PersistedState extends Partial<S> = Partial<S>, PersistReturn = void> = {
|
|
202
|
-
/**
|
|
203
|
-
* A function to convert the serialized value back into the state object.
|
|
204
|
-
* If not provided, the storage adapter's `deserializer` is used before falling back to the default implementation.
|
|
205
|
-
*/
|
|
206
|
-
deserializer?: (serializedState: unknown) => StorageValue<PersistedState>;
|
|
207
|
-
/**
|
|
208
|
-
* A function to merge persisted state with current state during hydration.
|
|
209
|
-
* By default, persisted state is shallow-merged into the current state.
|
|
210
|
-
*/
|
|
211
|
-
merge?: PersistOptions<S, PersistedState>['merge'];
|
|
212
|
-
/**
|
|
213
|
-
* A function to perform persisted state migration.
|
|
214
|
-
* This function will be called when persisted state versions mismatch with the one specified here.
|
|
215
|
-
*/
|
|
216
|
-
migrate?: PersistOptions<S, PersistedState>['migrate'];
|
|
217
|
-
/**
|
|
218
|
-
* A function returning another (optional) function.
|
|
219
|
-
* The main function will be called before the state rehydration.
|
|
220
|
-
* The returned function will be called after the state rehydration or when an error occurred.
|
|
221
|
-
*/
|
|
222
|
-
onRehydrateStorage?: PersistOptions<S, PersistedState>['onRehydrateStorage'];
|
|
223
|
-
/**
|
|
224
|
-
* A function that determines which parts of the state should be persisted.
|
|
225
|
-
* By default, the entire state is persisted.
|
|
226
|
-
*/
|
|
227
|
-
partialize?: (state: Readonly<S>) => PersistedState;
|
|
228
|
-
/**
|
|
229
|
-
* The throttle rate for the persist operation in milliseconds.
|
|
230
|
-
* @default iOS: time.seconds(3) | Android: time.seconds(5)
|
|
231
|
-
*/
|
|
232
|
-
persistThrottleMs?: PersistReturn extends Promise<unknown> ? undefined : number;
|
|
233
|
-
/**
|
|
234
|
-
* A function to serialize the state and version for storage.
|
|
235
|
-
* If not provided, the storage adapter's `serializer` is used before falling back to the default implementation.
|
|
236
|
-
*/
|
|
237
|
-
serializer?: (storageValue: StorageValue<PersistedState>) => string;
|
|
238
|
-
/**
|
|
239
|
-
* Custom storage implementation. If async, `setState` will return a Promise that resolves
|
|
240
|
-
* when the state is persisted. If sync, `setState` will return void.
|
|
241
|
-
*/
|
|
242
|
-
storage?: PersistReturn extends Promise<unknown> ? AsyncStorageInterface : SyncStorageInterface;
|
|
243
|
-
/**
|
|
244
|
-
* The unique key for the persisted store.
|
|
245
|
-
*/
|
|
246
|
-
storageKey: string;
|
|
247
|
-
/**
|
|
248
|
-
* The version of the store's schema.
|
|
249
|
-
* Useful for handling schema changes across app versions.
|
|
250
|
-
* @default 0
|
|
251
|
-
*/
|
|
252
|
-
version?: number;
|
|
253
|
-
};
|
|
254
|
-
export type EnforceStorageKey<Options> = {
|
|
255
|
-
storageKey: string;
|
|
256
|
-
} extends Options ? Options : never;
|
|
257
|
-
export type BaseStoreOptions<S, PersistedState extends Partial<S> = Partial<S>, PersistReturn = void> = (PersistConfig<S, PersistedState, PersistReturn> & {
|
|
258
|
-
sync?: S extends Record<string, unknown> ? SyncOption<S> : undefined;
|
|
259
|
-
}) | ({
|
|
260
|
-
sync: S extends Record<string, unknown> ? SyncWithoutStorageOption<NoInfer<S>> : undefined;
|
|
261
|
-
} & UndefinedPersistKeys<S, PersistedState, PersistReturn>);
|
|
262
|
-
/**
|
|
263
|
-
* The `sync` option can be:
|
|
264
|
-
* - `SyncConfig` object
|
|
265
|
-
* - `string` (shorthand for `{ key: string }`)
|
|
266
|
-
* - `true` (inherits key from `storageKey` — only valid with persistence)
|
|
267
|
-
*/
|
|
268
|
-
export type SyncOption<S extends Record<string, unknown>> = SyncConfig<S> | string | true;
|
|
269
|
-
type SyncWithoutStorageOption<S extends Record<string, unknown>> = string | (Omit<SyncConfig<S>, 'injectStorageMetadata' | 'key'> & {
|
|
270
|
-
injectStorageMetadata?: never;
|
|
271
|
-
key: SyncWithoutStorageKey<SyncConfig<S>>;
|
|
272
|
-
});
|
|
273
|
-
type SyncWithoutStorageKey<Config> = Config extends {
|
|
274
|
-
key?: infer Key;
|
|
275
|
-
} ? Extract<Key, string> extends never ? string : Extract<Key, string> : string;
|
|
276
|
-
type UndefinedPersistKeys<S, PersistedState extends Partial<S>, PersistReturn> = {
|
|
277
|
-
[K in keyof PersistConfig<S, PersistedState, PersistReturn>]?: undefined;
|
|
278
|
-
};
|
|
279
|
-
/**
|
|
280
|
-
* Expanded options for custom debounce behavior.
|
|
281
|
-
*/
|
|
282
|
-
export type DebounceOptions = {
|
|
283
|
-
delay: number;
|
|
284
|
-
leading?: boolean;
|
|
285
|
-
maxWait?: number;
|
|
286
|
-
trailing?: boolean;
|
|
287
|
-
};
|
|
288
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/utils/core.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the argument provided.
|
|
3
|
-
*/
|
|
4
|
-
export declare function identity<T>(value: T): T;
|
|
5
|
-
export declare function identity<T, _>(value: T): T;
|
|
6
|
-
/**
|
|
7
|
-
* Creates a null-prototype object using the runtime-optimal path:
|
|
8
|
-
* - React Native: direct literal `{ __proto__: null }`
|
|
9
|
-
* - Web/Node: `Object.create` with a shared, frozen null prototype
|
|
10
|
-
*/
|
|
11
|
-
export declare function nullObject<T extends Record<string, unknown> | object = Record<string, unknown>>(): T;
|
|
12
|
-
/**
|
|
13
|
-
* Builds null-prototype objects. Provided arguments are
|
|
14
|
-
* shallow-merged into a newly created null-prototype object:
|
|
15
|
-
*
|
|
16
|
-
* ```ts
|
|
17
|
-
* Object.assign(nullObject(), a, b?)
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function buildNullObject<A extends Record<string, unknown>>(a: A): A;
|
|
21
|
-
export declare function buildNullObject<A extends object, B>(a: object, b?: object): [undefined] extends B ? A : A & B;
|
|
22
|
-
/**
|
|
23
|
-
* Does nothing.
|
|
24
|
-
*/
|
|
25
|
-
export declare function noop(): void;
|
|
26
|
-
//# sourceMappingURL=core.d.ts.map
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates an async microtask-batched scheduler for a given async function.
|
|
3
|
-
*
|
|
4
|
-
* When the returned scheduler is called multiple times synchronously, only a single
|
|
5
|
-
* microtask execution occurs. All callers receive the same Promise that resolves
|
|
6
|
-
* after the batched execution completes. The function will be invoked with the
|
|
7
|
-
* arguments from the most recent call.
|
|
8
|
-
*
|
|
9
|
-
* This is useful for batching rapid successive async operations (e.g., async storage
|
|
10
|
-
* writes, network requests) to reduce unnecessary work while ensuring:
|
|
11
|
-
* - The latest values are used
|
|
12
|
-
* - All callers can await the completion of the batched operation
|
|
13
|
-
*
|
|
14
|
-
* @template Args - The argument types of the async function to schedule
|
|
15
|
-
* @param fn - The async function to schedule for microtask execution
|
|
16
|
-
* @returns A scheduler function that returns a Promise resolving after execution
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* const batchedSave = createAsyncMicrotaskScheduler(async (data: string) => {
|
|
21
|
-
* await storage.write(data);
|
|
22
|
-
* console.log('Saved:', data);
|
|
23
|
-
* });
|
|
24
|
-
*
|
|
25
|
-
* await Promise.all([
|
|
26
|
-
* batchedSave('first'),
|
|
27
|
-
* batchedSave('second'),
|
|
28
|
-
* batchedSave('third'),
|
|
29
|
-
* ]);
|
|
30
|
-
* // Writes "third" to storage once, all three Promises resolve together
|
|
31
|
-
* // Logs "Saved: third"
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export declare function createAsyncMicrotaskScheduler<Args extends unknown[]>(fn: (...args: Args) => Promise<void>): (...args: Args) => Promise<void>;
|
|
35
|
-
//# sourceMappingURL=createAsyncMicrotaskScheduler.d.ts.map
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a microtask-batched scheduler for a given function.
|
|
3
|
-
*
|
|
4
|
-
* When the returned scheduler is called multiple times synchronously, only a single
|
|
5
|
-
* microtask execution occurs. The function will be invoked with the arguments from
|
|
6
|
-
* the most recent call.
|
|
7
|
-
*
|
|
8
|
-
* This is useful for batching rapid successive calls (e.g., state updates, change
|
|
9
|
-
* handlers) to reduce unnecessary work while ensuring the latest values are used.
|
|
10
|
-
*
|
|
11
|
-
* @template TArgs - The argument types of the function to schedule
|
|
12
|
-
* @param fn - The function to schedule for microtask execution
|
|
13
|
-
* @param enqueue - The queue that should run the scheduled task
|
|
14
|
-
* @returns A scheduler function with the same signature as the input function
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* const batchedUpdate = createMicrotaskScheduler((value: number) => {
|
|
19
|
-
* console.log('Updated:', value);
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* batchedUpdate(1);
|
|
23
|
-
* batchedUpdate(2);
|
|
24
|
-
* batchedUpdate(3);
|
|
25
|
-
* // Logs "Updated: 3" once in the next microtask
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare function createMicrotaskScheduler<Args extends unknown[]>(fn: (...args: Args) => void, enqueue?: (task: () => void) => void): (...args: Args) => void;
|
|
29
|
-
//# sourceMappingURL=createMicrotaskScheduler.d.ts.map
|
package/dist/utils/debounce.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export type DebounceOptions = {
|
|
2
|
-
leading?: boolean;
|
|
3
|
-
maxWait?: number;
|
|
4
|
-
trailing?: boolean;
|
|
5
|
-
};
|
|
6
|
-
export type DebouncedFunction<F extends (...args: Parameters<F>) => ReturnType<F>> = {
|
|
7
|
-
(...args: Parameters<F>): ReturnType<F> | undefined;
|
|
8
|
-
cancel: () => void;
|
|
9
|
-
flush: () => ReturnType<F> | undefined;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Creates a debounced function that delays invoking `func` until after `wait` milliseconds
|
|
13
|
-
* have elapsed since the last time the debounced function was invoked.
|
|
14
|
-
* Copied and adapted from lodash@4.17.21.
|
|
15
|
-
*
|
|
16
|
-
* @param func The function to debounce.
|
|
17
|
-
* @param wait The number of milliseconds to delay.
|
|
18
|
-
* @param options The options object.
|
|
19
|
-
* @returns Returns the new debounced function.
|
|
20
|
-
*/
|
|
21
|
-
export declare function debounce<F extends (...args: Parameters<F>) => ReturnType<F>>(func: F, wait?: number, options?: DebounceOptions): DebouncedFunction<F>;
|
|
22
|
-
//# sourceMappingURL=debounce.d.ts.map
|