@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.
Files changed (157) hide show
  1. package/dist/index.d.ts +1586 -4
  2. package/dist/native/index.js +7 -1
  3. package/dist/native/index.mjs +7 -1
  4. package/dist/plugins/chrome/index.d.ts +186 -4
  5. package/dist/vanilla/index.js +1 -1
  6. package/dist/vanilla/index.mjs +1 -1
  7. package/dist/vanilla/index.vanilla.d.ts +1472 -1
  8. package/dist/web/chrome.js +1 -1
  9. package/dist/web/chrome.mjs +1 -1
  10. package/dist/web/index.js +1 -1
  11. package/dist/web/index.mjs +1 -1
  12. package/dist/web/internal/runtime.js +2 -1
  13. package/dist/web/internal/runtime.mjs +2 -1
  14. package/dist/web/queryParam-Ckp7Zi5t.mjs +1 -0
  15. package/dist/web/queryParam-Ctnhipnd.js +1 -0
  16. package/dist/web/serialization-BgaGfw_1.mjs +1 -0
  17. package/dist/web/serialization-Dau9pNHc.js +1 -0
  18. package/dist/web/utils-Ba1RIeAA.mjs +1 -0
  19. package/dist/web/utils-CwejruRb.js +1 -0
  20. package/package.json +9 -8
  21. package/dist/createBaseStore.d.ts +0 -36
  22. package/dist/createDerivedStore.d.ts +0 -63
  23. package/dist/createQueryStore.d.ts +0 -111
  24. package/dist/createVirtualStore.d.ts +0 -40
  25. package/dist/env.native.d.ts +0 -7
  26. package/dist/env.web.d.ts +0 -7
  27. package/dist/hooks/useLazyRef.d.ts +0 -13
  28. package/dist/hooks/useListen.d.ts +0 -98
  29. package/dist/hooks/useStableValue.d.ts +0 -16
  30. package/dist/hooks/useSyncExternalStoreWithSelector.d.ts +0 -5
  31. package/dist/index.shared.d.ts +0 -14
  32. package/dist/index.vanilla.d.ts +0 -2
  33. package/dist/internal/baseStore.d.ts +0 -2
  34. package/dist/internal/config.d.ts +0 -64
  35. package/dist/internal/createStoreActions.d.ts +0 -24
  36. package/dist/internal/derivedStore/deriveProxy.d.ts +0 -15
  37. package/dist/internal/derivedStore/pathFinder.d.ts +0 -26
  38. package/dist/internal/derivedStore.d.ts +0 -2
  39. package/dist/internal/errors.d.ts +0 -10
  40. package/dist/internal/logger.d.ts +0 -10
  41. package/dist/internal/middleware/createHydrationGate.d.ts +0 -20
  42. package/dist/internal/queryStore/queryParams.d.ts +0 -18
  43. package/dist/internal/queryStore/queryStoreDefaults.d.ts +0 -8
  44. package/dist/internal/queryStore.d.ts +0 -2
  45. package/dist/internal/runtime.d.ts +0 -12
  46. package/dist/internal/storage/storageCreators.d.ts +0 -12
  47. package/dist/internal/storeUtils.d.ts +0 -46
  48. package/dist/internal/sync/browserSyncEngine.d.ts +0 -3
  49. package/dist/internal/sync/noopSyncEngine.d.ts +0 -3
  50. package/dist/internal/sync/syncEnhancer.d.ts +0 -26
  51. package/dist/internal/sync/syncUtils.d.ts +0 -6
  52. package/dist/internal/types/internalSubscribeTypes.d.ts +0 -16
  53. package/dist/internal/utils/persistUtils.d.ts +0 -9
  54. package/dist/internal/virtualStore.d.ts +0 -2
  55. package/dist/plugins/chrome/chromeExtensionSyncEngine.d.ts +0 -30
  56. package/dist/plugins/chrome/chromeStorageAdapter.d.ts +0 -31
  57. package/dist/plugins/chrome/createSyncedChromeStorage.d.ts +0 -14
  58. package/dist/queryStore/classes/SubscriptionManager.d.ts +0 -39
  59. package/dist/queryStore/queryKey.d.ts +0 -10
  60. package/dist/queryStore/queryParam.d.ts +0 -37
  61. package/dist/queryStore/types.d.ts +0 -361
  62. package/dist/storage/storageTypes.d.ts +0 -13
  63. package/dist/store/attachStoreHook.react.d.ts +0 -5
  64. package/dist/store/attachStoreHook.vanilla.d.ts +0 -6
  65. package/dist/store/batchStoreNotifications.native.d.ts +0 -3
  66. package/dist/store/batchStoreNotifications.web.d.ts +0 -2
  67. package/dist/store/cascadeScheduler.d.ts +0 -38
  68. package/dist/store/createStore.d.ts +0 -6
  69. package/dist/store/persist.d.ts +0 -14
  70. package/dist/store/stateUpdate.d.ts +0 -10
  71. package/dist/store/types.d.ts +0 -108
  72. package/dist/storesStorage.native.d.ts +0 -3
  73. package/dist/storesStorage.web.d.ts +0 -3
  74. package/dist/sync/types.d.ts +0 -115
  75. package/dist/types/functions.d.ts +0 -24
  76. package/dist/types/objects.d.ts +0 -11
  77. package/dist/types/setState.d.ts +0 -22
  78. package/dist/types/subscribe.d.ts +0 -27
  79. package/dist/types/useStoreCallSignatures.d.ts +0 -2
  80. package/dist/types/useStoreCallSignatures.react.d.ts +0 -6
  81. package/dist/types/useStoreCallSignatures.vanilla.d.ts +0 -2
  82. package/dist/types/utils.d.ts +0 -13
  83. package/dist/types.d.ts +0 -288
  84. package/dist/utils/core.d.ts +0 -26
  85. package/dist/utils/createAsyncMicrotaskScheduler.d.ts +0 -35
  86. package/dist/utils/createMicrotaskScheduler.d.ts +0 -29
  87. package/dist/utils/debounce.d.ts +0 -22
  88. package/dist/utils/equality.d.ts +0 -38
  89. package/dist/utils/hydrationCoordinator.d.ts +0 -13
  90. package/dist/utils/promiseUtils.d.ts +0 -2
  91. package/dist/utils/serialization.d.ts +0 -14
  92. package/dist/utils/stringUtils.d.ts +0 -7
  93. package/dist/utils/time.d.ts +0 -37
  94. package/dist/vanilla/createBaseStore.d.ts +0 -35
  95. package/dist/vanilla/createDerivedStore.d.ts +0 -62
  96. package/dist/vanilla/createQueryStore.d.ts +0 -110
  97. package/dist/vanilla/createVirtualStore.d.ts +0 -39
  98. package/dist/vanilla/env.web.d.ts +0 -6
  99. package/dist/vanilla/index.d.ts +0 -1
  100. package/dist/vanilla/index.shared.d.ts +0 -13
  101. package/dist/vanilla/internal/baseStore.d.ts +0 -1
  102. package/dist/vanilla/internal/config.d.ts +0 -63
  103. package/dist/vanilla/internal/createStoreActions.d.ts +0 -23
  104. package/dist/vanilla/internal/derivedStore/deriveProxy.d.ts +0 -14
  105. package/dist/vanilla/internal/derivedStore/pathFinder.d.ts +0 -25
  106. package/dist/vanilla/internal/derivedStore.d.ts +0 -1
  107. package/dist/vanilla/internal/errors.d.ts +0 -9
  108. package/dist/vanilla/internal/logger.d.ts +0 -9
  109. package/dist/vanilla/internal/middleware/createHydrationGate.d.ts +0 -19
  110. package/dist/vanilla/internal/queryStore/queryParams.d.ts +0 -17
  111. package/dist/vanilla/internal/queryStore/queryStoreDefaults.d.ts +0 -7
  112. package/dist/vanilla/internal/queryStore.d.ts +0 -1
  113. package/dist/vanilla/internal/runtime.d.ts +0 -11
  114. package/dist/vanilla/internal/storage/storageCreators.d.ts +0 -11
  115. package/dist/vanilla/internal/storeUtils.d.ts +0 -45
  116. package/dist/vanilla/internal/sync/browserSyncEngine.d.ts +0 -2
  117. package/dist/vanilla/internal/sync/noopSyncEngine.d.ts +0 -2
  118. package/dist/vanilla/internal/sync/syncEnhancer.d.ts +0 -25
  119. package/dist/vanilla/internal/types/internalSubscribeTypes.d.ts +0 -15
  120. package/dist/vanilla/internal/utils/persistUtils.d.ts +0 -8
  121. package/dist/vanilla/internal/virtualStore.d.ts +0 -1
  122. package/dist/vanilla/queryStore/classes/SubscriptionManager.d.ts +0 -38
  123. package/dist/vanilla/queryStore/queryKey.d.ts +0 -9
  124. package/dist/vanilla/queryStore/queryParam.d.ts +0 -36
  125. package/dist/vanilla/queryStore/types.d.ts +0 -360
  126. package/dist/vanilla/storage/storageTypes.d.ts +0 -12
  127. package/dist/vanilla/store/attachStoreHook.d.ts +0 -5
  128. package/dist/vanilla/store/attachStoreHook.vanilla.d.ts +0 -5
  129. package/dist/vanilla/store/batchStoreNotifications.web.d.ts +0 -1
  130. package/dist/vanilla/store/cascadeScheduler.d.ts +0 -37
  131. package/dist/vanilla/store/createStore.d.ts +0 -5
  132. package/dist/vanilla/store/persist.d.ts +0 -13
  133. package/dist/vanilla/store/stateUpdate.d.ts +0 -9
  134. package/dist/vanilla/store/types.d.ts +0 -107
  135. package/dist/vanilla/storesStorage.web.d.ts +0 -2
  136. package/dist/vanilla/sync/types.d.ts +0 -114
  137. package/dist/vanilla/types/functions.d.ts +0 -23
  138. package/dist/vanilla/types/objects.d.ts +0 -10
  139. package/dist/vanilla/types/setState.d.ts +0 -21
  140. package/dist/vanilla/types/subscribe.d.ts +0 -26
  141. package/dist/vanilla/types/useStoreCallSignatures.d.ts +0 -1
  142. package/dist/vanilla/types/useStoreCallSignatures.vanilla.d.ts +0 -1
  143. package/dist/vanilla/types/utils.d.ts +0 -12
  144. package/dist/vanilla/types.d.ts +0 -287
  145. package/dist/vanilla/utils/core.d.ts +0 -25
  146. package/dist/vanilla/utils/createAsyncMicrotaskScheduler.d.ts +0 -34
  147. package/dist/vanilla/utils/createMicrotaskScheduler.d.ts +0 -28
  148. package/dist/vanilla/utils/debounce.d.ts +0 -21
  149. package/dist/vanilla/utils/equality.d.ts +0 -37
  150. package/dist/vanilla/utils/hydrationCoordinator.d.ts +0 -12
  151. package/dist/vanilla/utils/promiseUtils.d.ts +0 -1
  152. package/dist/vanilla/utils/serialization.d.ts +0 -13
  153. package/dist/vanilla/utils/stringUtils.d.ts +0 -6
  154. package/dist/vanilla/utils/time.d.ts +0 -36
  155. package/dist/web/chunk-FENSEQ3V.mjs +0 -1
  156. package/dist/web/chunk-FPYZVFBM.mjs +0 -1
  157. package/dist/web/chunk-PLDNKWGX.mjs +0 -1
@@ -1,98 +0,0 @@
1
- import { RefObject } from 'react';
2
- import { BaseStore, EqualityFn, InferStoreState, Selector } from '../types';
3
- /**
4
- * Handle returned by `useListen`.
5
- *
6
- * The hook cleans itself up, so you normally ignore this handle.
7
- * Keep it only when you need to pause or resume the listener manually
8
- * (e.g. suspend heavy work while a long-lived component is off screen).
9
- */
10
- export type ListenHandle = {
11
- /** `true` while the listener is attached. */
12
- isActive: boolean;
13
- /** Re-attach the listener. */
14
- resubscribe: (options?: ResubscribeOptions) => void;
15
- /** Detach the listener. Safe to call more than once. */
16
- unsubscribe: () => void;
17
- };
18
- /**
19
- * Options for resubscribing a listener.
20
- */
21
- export type ResubscribeOptions = {
22
- /**
23
- * Whether to fire the callback immediately when resubscribing.
24
- * @default false
25
- */
26
- fireImmediately?: boolean;
27
- /**
28
- * Whether to force a resubscription even if the listener is already active.
29
- * @default false
30
- */
31
- forceResubscribe?: boolean;
32
- };
33
- /**
34
- * Options for the `useListen` hook.
35
- */
36
- export type UseListenOptions<Selected> = {
37
- /**
38
- * Whether to log debug messages to the console.
39
- * @default false
40
- */
41
- debugMode?: boolean;
42
- /**
43
- * Whether to enable the listener.
44
- * @default true
45
- */
46
- enabled?: boolean;
47
- /**
48
- * Dictates whether `react` should be called on state slice changes.
49
- * Compares the previous and current selected values.
50
- * @default Object.is
51
- */
52
- equalityFn?: EqualityFn<Selected>;
53
- /**
54
- * Whether to fire the callback immediately on mount. Note that if `true`,
55
- * the `react` callback will be called on mount regardless of whether the
56
- * selected value has changed.
57
- * @default false
58
- */
59
- fireImmediately?: boolean;
60
- };
61
- /**
62
- * ### `useListen`
63
- *
64
- * Subscribes to a slice of a store and runs a callback whenever that slice changes,
65
- * **without triggering re-renders**.
66
- *
67
- * Useful for forwarding updates to non-React state (e.g. Reanimated shared values), scoped side
68
- * effects, or deciding yourself if or when a render should happen.
69
- *
70
- * The hook attaches the listener and cleans it up automatically. Use the returned `ListenHandle`
71
- * only when you need to pause or resume the listener manually.
72
- *
73
- * ---
74
- * 💡 **Note:** With the exception of `enabled`, changes in `options` are **not reactive**.
75
- * They take effect only if a resubscription occurs.
76
- *
77
- * ---
78
- * @param store - Store to listen to. Should be a stable reference.
79
- * @param selector - Selects the slice of the store state to listen to.
80
- * @param react - Triggered when the selected slice changes. Receives `(current, previous, unsubscribe)`.
81
- * @param optionsOrEqualityFn - Optional `equalityFn`, `fireImmediately` settings, forwarded to `store.subscribe`.
82
- *
83
- * ---
84
- * @example
85
- * ```ts
86
- * useListen(
87
- * useCandlestickStore,
88
- * state => state.getData(),
89
- * (candles, previous, unsubscribe) => {
90
- * if (candles?.unsupported) return unsubscribe();
91
- * updateTokenPrice(token, getPriceUpdate(candles, previous));
92
- * runOnUI(() => chartManager.value?.setCandles(candles))();
93
- * }
94
- * );
95
- * ```
96
- */
97
- export declare function useListen<Store extends BaseStore<S>, Selected, S = InferStoreState<Store>>(store: Store, selector: Selector<S, Selected>, react: (current: Selected, previous: Selected, unsubscribe: () => void) => void, optionsOrEqualityFn?: UseListenOptions<Selected> | UseListenOptions<Selected>['equalityFn']): RefObject<Readonly<ListenHandle>>;
98
- //# sourceMappingURL=useListen.d.ts.map
@@ -1,16 +0,0 @@
1
- /**
2
- * **Initializes a value once**, guaranteeing stability across renders.
3
- *
4
- * @param initializer A function that produces the value. It is invoked **only
5
- * on the first render** for a given component instance.
6
- *
7
- * @returns A stable `T` guaranteed to be the value initially returned by the
8
- * provided `initializer`.
9
- *
10
- * @example
11
- * ```ts
12
- * const initialState = useStableValue(() => getInitialState());
13
- * ```
14
- */
15
- export declare function useStableValue<T>(init: () => T): T;
16
- //# sourceMappingURL=useStableValue.d.ts.map
@@ -1,5 +0,0 @@
1
- import type { EqualityFn, Selector, SubscribeOverloads } from '../types';
2
- export declare function useSyncExternalStoreWithSelector<State>(subscribe: SubscribeOverloads<State>, getSnapshot: () => State, getServerSnapshot?: (() => State) | undefined, selector?: undefined, equalityFn?: undefined): State;
3
- export declare function useSyncExternalStoreWithSelector<State, Selected>(subscribe: SubscribeOverloads<State>, getSnapshot: () => State, getServerSnapshot: (() => State) | undefined, selector: Selector<State, Selected>, equalityFn?: EqualityFn<Selected>): Selected;
4
- export declare function useSyncExternalStoreWithSelector<State, Selected>(subscribe: SubscribeOverloads<State>, getSnapshot: () => State, getServerSnapshot: (() => State) | undefined, selector: Selector<State, Selected> | undefined, equalityFn?: EqualityFn<Selected>): State | Selected;
5
- //# sourceMappingURL=useSyncExternalStoreWithSelector.d.ts.map
@@ -1,14 +0,0 @@
1
- export * from './createBaseStore';
2
- export * from './createDerivedStore';
3
- export * from './createQueryStore';
4
- export * from './createVirtualStore';
5
- export { configureStores, StoresError } from './internal/runtime';
6
- export { applyStateUpdate, replacer, reviver } from './internal/runtime';
7
- export { destroyStore, destroyStores, getStoreName, hasGetSnapshot, isDerivedStore, isPersistedStore, isQueryStore, isVirtualStore, } from './internal/runtime';
8
- export type * from './sync/types';
9
- export { QueryStatuses } from './internal/runtime';
10
- export type * from './queryStore/types';
11
- export type * from './storage/storageTypes';
12
- export type * from './types';
13
- export { createStoreActions, deepEqual, identity, nullObject, shallowEqual, time } from './internal/runtime';
14
- //# sourceMappingURL=index.shared.d.ts.map
@@ -1,2 +0,0 @@
1
- export * from './index.shared';
2
- //# sourceMappingURL=index.vanilla.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=baseStore.d.ts.map
@@ -1,64 +0,0 @@
1
- import { QueryStoreConfig } from '../queryStore/types';
2
- import { SyncEngine } from '../sync/types';
3
- import { AsyncStorageInterface, SyncStorageInterface } from '../types';
4
- import { NonFunction } from '../types/functions';
5
- import { Prettify } from '../types/objects';
6
- import { Logger } from './logger';
7
- /**
8
- * Global configuration for all stores.
9
- */
10
- export type StoresConfig = {
11
- /**
12
- * Custom logger for debug output. Defaults to a no-op logger in production.
13
- */
14
- logger: Logger;
15
- /**
16
- * Default options used by all query stores.
17
- */
18
- queryStoreDefaults: QueryStoreDefaults;
19
- /**
20
- * Storage backend for persisted stores. Defaults to `localStorage` in browsers,
21
- * MMKV in React Native.
22
- */
23
- storage: AsyncStorageInterface | SyncStorageInterface;
24
- /**
25
- * Prefix for storage keys built by the default storage adapter.
26
- * Should include a delimiter, e.g., `'myapp:'`.
27
- * @default 'stores:'
28
- */
29
- storageKeyPrefix: string;
30
- /**
31
- * Sync engine for cross-client state synchronization. Defaults to cross-tab sync
32
- * in browsers, no-op in other environments.
33
- */
34
- syncEngine: SyncEngine;
35
- };
36
- export type QueryStoreDefaults = Prettify<ConfigDefaults<QueryStoreConfig<unknown, Record<string, unknown>>, 'disableCache' | 'enabled' | 'params', 'retryDelay'>> & {
37
- /**
38
- * Minimum stale time for auto-refetching query stores under which to log warnings in development.
39
- * `false` disables warnings.
40
- * @default false
41
- */
42
- minStaleTime?: number | false;
43
- };
44
- type ConfigDefaults<C, Excluded extends keyof C = never, AllowedFunctions extends keyof C = never> = Omit<{
45
- [K in keyof C as K extends AllowedFunctions ? K : NonFunction<C[K]> extends undefined ? never : K]?: K extends AllowedFunctions ? C[K] : NonFunction<C[K]>;
46
- }, Excluded>;
47
- /**
48
- * Configures global defaults for all stores.
49
- *
50
- * If used, must be called before creating any stores.
51
- *
52
- * @see {@link StoresConfig}
53
- *
54
- * @example
55
- * ```ts
56
- * configureStores({
57
- * logger: { debug: console.debug, error: console.error },
58
- * storageKeyPrefix: 'myapp:',
59
- * });
60
- * ```
61
- */
62
- export declare function configureStores(config: Partial<StoresConfig>): void;
63
- export {};
64
- //# sourceMappingURL=config.d.ts.map
@@ -1,24 +0,0 @@
1
- import type { StoreApi } from '../store/types';
2
- import type { InferStoreState, StoreActions } from '../types';
3
- import type { FunctionRecord } from '../types/functions';
4
- import type { NoOverlap } from '../types/objects';
5
- /**
6
- * Given a store instance, produces a new object containing only its actions.
7
- *
8
- * Intended for export alongside the associated store.
9
- *
10
- * @param store - The store to create actions for.
11
- * @param bundledMethods - Optional extra methods to bundle into the actions object.
12
- *
13
- * @example
14
- * export const useCounterStore = createRainbowStore(set => ({
15
- * count: 0,
16
- * increment: () => set(state => ({ count: state.count + 1 })),
17
- * }));
18
- *
19
- * export const exampleActions = createStoreActions(useExampleStore);
20
- * exampleActions.increment();
21
- */
22
- export declare function createStoreActions<Store extends StoreApi<unknown>>(store: Store): StoreActions<Store>;
23
- export declare function createStoreActions<Store extends StoreApi<unknown>, Bundled extends FunctionRecord>(store: Store, bundledMethods: NoOverlap<InferStoreState<Store>, Bundled>): StoreActions<Store> & Bundled;
24
- //# sourceMappingURL=createStoreActions.d.ts.map
@@ -1,15 +0,0 @@
1
- import type { StoreApi } from '../../store/types';
2
- import { TrackPathFn } from './pathFinder';
3
- /**
4
- * Gets or creates a lightweight tracking proxy that records path access and store
5
- * method invocations via proxy traps. Used to auto-generate selectors that point
6
- * to either the accessed path or the value returned by an invoked store method.
7
- */
8
- export declare function getOrCreateProxy<S>(store: StoreApi<S>, rootProxyCache: WeakMap<object, unknown>, trackPath: TrackPathFn): S;
9
- /**
10
- * Strips tracking proxies from published values to ensure
11
- * proxies remain confined to internal tracking contexts.
12
- */
13
- export declare function stripProxies<T>(value: T): T;
14
- export declare function stripProxies(value: unknown, seen?: WeakSet<object>): unknown;
15
- //# sourceMappingURL=deriveProxy.d.ts.map
@@ -1,26 +0,0 @@
1
- import { Selector, SubscribableStore } from '../../types';
2
- type TrackedInvocation = {
3
- args: unknown[] | undefined;
4
- };
5
- type PathEntry = {
6
- path: string[];
7
- store: SubscribableStore;
8
- invocation?: TrackedInvocation;
9
- isLeaf: boolean;
10
- };
11
- type SubscriptionBuilder = (store: SubscribableStore, selector: Selector<unknown, unknown>, path: string[]) => void;
12
- export type PathFinder = {
13
- buildProxySubscriptions(createSubscription: SubscriptionBuilder, shouldLog: boolean, minConsolidationDepth?: number, shouldBuild?: (paths: Set<PathEntry>) => boolean): void;
14
- reset(): void;
15
- trackPath: TrackPathFn;
16
- };
17
- export type TrackPathFn = (store: SubscribableStore, path: string[], isLeaf: boolean, invocation?: TrackedInvocation) => void;
18
- /**
19
- * A factory that returns a proxy path-tracking object with three methods:
20
- * - `buildProxySubscriptions()`: builds subscriptions to the final paths
21
- * - `reset()`: clears all tracked paths
22
- * - `trackPath()`: records usage of a store path
23
- */
24
- export declare function createPathFinder(): PathFinder;
25
- export {};
26
- //# sourceMappingURL=pathFinder.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=derivedStore.d.ts.map
@@ -1,10 +0,0 @@
1
- /**
2
- * Error reported or thrown by the stores package itself.
3
- *
4
- * If an underlying thrown value caused the failure, it is available as `cause`.
5
- */
6
- export declare class StoresError extends Error {
7
- cause?: unknown;
8
- constructor(message: string, cause?: unknown);
9
- }
10
- //# sourceMappingURL=errors.d.ts.map
@@ -1,10 +0,0 @@
1
- export interface Logger {
2
- debug: (message: string, context?: Record<string, unknown>) => void;
3
- error: {
4
- <T extends Error>(error: T, context?: Record<string, unknown>): void;
5
- <T extends string>(error: T, context?: Record<string, unknown>): void;
6
- };
7
- info: (message: string, context?: Record<string, unknown>) => void;
8
- warn: (message: string, context?: Record<string, unknown>) => void;
9
- }
10
- //# sourceMappingURL=logger.d.ts.map
@@ -1,20 +0,0 @@
1
- import { StateCreator } from '../../types';
2
- import { SyncContext } from '../sync/syncEnhancer';
3
- type WrappedOnRehydrateStorage<S> = (userCallback: ((state: S) => ((finalState?: S, error?: unknown) => void) | void) | undefined, syncContext: SyncContext | undefined) => (state: S) => (finalState?: S, error?: unknown) => void;
4
- /**
5
- * Creates hydration-gating middleware that queues state updates until rehydration completes.
6
- *
7
- * **Before hydration**: Queues all `set()` calls and flushes them sequentially after rehydration.
8
- *
9
- * **After hydration**: Passes `set()` calls through synchronously without batching.
10
- *
11
- * This ensures persistence sees a fully rehydrated base state before applying queued updates,
12
- * while keeping in-memory state changes synchronous post-hydration.
13
- */
14
- export declare function createHydrationGate<S>(stateCreator: StateCreator<S>): {
15
- hydrationPromise: () => Promise<void>;
16
- stateCreator: StateCreator<S>;
17
- wrapOnRehydrateStorage: WrappedOnRehydrateStorage<S>;
18
- };
19
- export {};
20
- //# sourceMappingURL=createHydrationGate.d.ts.map
@@ -1,18 +0,0 @@
1
- import type { QueryParam, ReactiveParam } from '../../queryStore/queryParam';
2
- import type { StoreApi } from '../../store/types';
3
- import type { InternalUnsubscribeFn } from '../types/internalSubscribeTypes';
4
- export type TrackedValue<T> = {
5
- readonly initialValue: T;
6
- subscribe(listener: (value: T) => void): InternalUnsubscribeFn;
7
- };
8
- export type QueryParams<TParams extends Record<string, unknown>> = {
9
- buildKey(params?: TParams): string;
10
- complete(params: Partial<TParams> | undefined): TParams;
11
- get(): TParams;
12
- subscribe(onChange: (key: keyof TParams, oldValue: unknown, newValue: unknown) => void): InternalUnsubscribeFn;
13
- };
14
- export declare function createQueryParams<TParams extends Record<string, unknown>, State>(params: {
15
- [K in keyof TParams]: QueryParam<TParams[K], State>;
16
- } | undefined, store: StoreApi<State>, requiredKeys: (keyof TParams)[]): QueryParams<TParams>;
17
- export declare function trackQueryValue<T, State>(getValue: ReactiveParam<T, State>, ownerStore: StoreApi<State>): TrackedValue<T>;
18
- //# sourceMappingURL=queryParams.d.ts.map
@@ -1,8 +0,0 @@
1
- import { Prettify } from '../../types/objects';
2
- import { QueryStoreDefaults } from '../config';
3
- export declare function getQueryStoreDefaults(): Prettify<Required<QueryStoreDefaults>>;
4
- /**
5
- * Exponential backoff: starts at `baseDelay` (5s), doubles each retry, capped at `maxDelay` (5m).
6
- */
7
- export declare function defaultRetryDelay(retryCount: number): number;
8
- //# sourceMappingURL=queryStoreDefaults.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=queryStore.d.ts.map
@@ -1,12 +0,0 @@
1
- export { configureStores } from './config';
2
- export { StoresError } from './errors';
3
- export { QueryStatuses } from '../queryStore/types';
4
- export { defaultRetryDelay } from './queryStore/queryStoreDefaults';
5
- export { applyStateUpdate } from '../store/stateUpdate';
6
- export { replacer, reviver } from '../utils/serialization';
7
- export { destroyStore, destroyStores, getStoreName, hasGetSnapshot, isDerivedStore, isPersistedStore, isQueryStore, isVirtualStore, } from './storeUtils';
8
- export { identity, nullObject } from '../utils/core';
9
- export { createStoreActions } from './createStoreActions';
10
- export { deepEqual, shallowEqual } from '../utils/equality';
11
- export { time } from '../utils/time';
12
- //# sourceMappingURL=runtime.d.ts.map
@@ -1,12 +0,0 @@
1
- import type { AsyncPersistStorage, PersistStorageConfig } from '../../store/types';
2
- import type { AsyncStorageInterface, BaseStoreOptions, EnforceStorageKey, SyncStorageInterface } from '../../types';
3
- import type { SyncContext } from '../sync/syncEnhancer';
4
- /**
5
- * Creates a persist storage object for the base store.
6
- */
7
- export declare function createPersistStorage<S, PersistedState extends Partial<S>, PersistReturn>(options: EnforceStorageKey<BaseStoreOptions<S, PersistedState, PersistReturn>>, storage: AsyncStorageInterface | SyncStorageInterface | undefined, syncContext: SyncContext | undefined): PersistStorageConfig<S, PersistedState>;
8
- /**
9
- * Creates an asynchronous persist storage adapter.
10
- */
11
- export declare function createAsyncPersistStorage<S, PersistedState extends Partial<S>, PersistReturn>(storage: AsyncStorageInterface, options: EnforceStorageKey<BaseStoreOptions<S, PersistedState, PersistReturn>>, persistThrottleMs: number | undefined, syncContext?: SyncContext): AsyncPersistStorage<S, PersistedState>;
12
- //# sourceMappingURL=storageCreators.d.ts.map
@@ -1,46 +0,0 @@
1
- import type { QueryStore, QueryStoreState } from '../queryStore/types';
2
- import type { StoreApi } from '../store/types';
3
- import type { BaseStore, InferStoreState, PersistedStore } from '../types';
4
- /**
5
- * Calls the appropriate reset or destroy method on the store, if available.
6
- * Handles both `DerivedStore` and `QueryStore`.
7
- */
8
- export declare function destroyStore(store: BaseStore<unknown> | StoreApi<unknown> | QueryStore<unknown, Record<string, unknown>, unknown>, options?: {
9
- clearQueryCache?: boolean;
10
- }): void;
11
- export declare function destroyStores(stores: Partial<Record<string, BaseStore<unknown> | StoreApi<unknown>>> | (BaseStore<unknown> | StoreApi<unknown> | undefined)[], options?: {
12
- clearQueryCache?: boolean;
13
- skipDestroy?: (store: BaseStore<unknown> | StoreApi<unknown>) => boolean;
14
- }): void;
15
- /**
16
- * Returns the name of the store, either from the `persist` options or the store itself.
17
- */
18
- export declare function getStoreName(store: BaseStore<unknown>): string;
19
- /**
20
- * Checks if a store is a `DerivedStore` and reveals its internal `getSnapshot` method.
21
- */
22
- export declare function hasGetSnapshot<T extends BaseStore<unknown> | StoreApi<unknown>>(store: T): store is T & {
23
- getSnapshot: () => InferStoreState<T>;
24
- };
25
- /**
26
- * Checks if a store is a `QueryStore`.
27
- */
28
- export declare function isQueryStore<T extends object>(store: T): store is Extract<T, BaseStore<QueryStoreState<unknown, Record<string, unknown>, unknown>>>;
29
- /**
30
- * Checks if a store is a `DerivedStore`.
31
- */
32
- export declare function isDerivedStore<T extends BaseStore<unknown> | StoreApi<unknown>>(store: T): store is T & {
33
- destroy: () => void;
34
- flushUpdates: () => void;
35
- };
36
- /**
37
- * Checks if a store is persisted.
38
- */
39
- export declare function isPersistedStore<T extends BaseStore<unknown> | PersistedStore<unknown>>(store: T): store is T & {
40
- persist: PersistedStore<InferStoreState<T>>['persist'];
41
- };
42
- /**
43
- * Checks if a store is a virtual store.
44
- */
45
- export declare function isVirtualStore<T extends BaseStore<unknown> | StoreApi<unknown>>(store: T): store is T & BaseStore<InferStoreState<T>>;
46
- //# sourceMappingURL=storeUtils.d.ts.map
@@ -1,3 +0,0 @@
1
- import { SyncEngine } from '../../sync/types';
2
- export declare function createBrowserSyncEngine(): SyncEngine;
3
- //# sourceMappingURL=browserSyncEngine.d.ts.map
@@ -1,3 +0,0 @@
1
- import { SyncEngine } from '../../sync/types';
2
- export declare function createNoopSyncEngine(): SyncEngine;
3
- //# sourceMappingURL=noopSyncEngine.d.ts.map
@@ -1,26 +0,0 @@
1
- import { NormalizedSyncConfig } from '../../sync/types';
2
- import { StateCreator } from '../../types';
3
- export type SyncContext = {
4
- isAsync: boolean;
5
- clearFieldTimestamps: (snapshot: Record<string, number> | undefined) => void;
6
- getFieldTimestampSnapshot: () => Record<string, number> | undefined;
7
- getIsApplyingRemote: () => boolean;
8
- getSessionId: () => string | undefined;
9
- getTimestamp: () => number | undefined;
10
- mergeFieldTimestamps: (fields: Record<string, number>) => void;
11
- onHydrationComplete: (() => void) | undefined;
12
- onHydrationFlushEnd: (() => void) | undefined;
13
- setIsApplyingRemote: (value: boolean) => void;
14
- setSessionId: (sessionId: string) => void;
15
- setTimestamp: (timestamp: number) => void;
16
- setWithoutPersist: (<_T extends (..._: unknown[]) => void | Promise<void>, Args extends unknown[]>(..._: Args) => void | Promise<void>) | undefined;
17
- };
18
- export declare function createSyncedStateCreator<T extends Record<string, unknown>>(stateCreator: StateCreator<T>, config: NormalizedSyncConfig<T>, isAsync: boolean): {
19
- stateCreator: StateCreator<T>;
20
- syncContext: SyncContext;
21
- };
22
- /**
23
- * Readable indices for `FieldMetadata` tuples.
24
- */
25
- export declare const TIMESTAMP: 0, SESSION_ID: 1;
26
- //# sourceMappingURL=syncEnhancer.d.ts.map
@@ -1,6 +0,0 @@
1
- import { FieldMetadata } from '../../sync/types';
2
- /**
3
- * Helper to create `FieldMetadata` tuples.
4
- */
5
- export declare function createFieldMetadata(timestamp: number, sessionId: string): FieldMetadata;
6
- //# sourceMappingURL=syncUtils.d.ts.map
@@ -1,16 +0,0 @@
1
- import type { Listener, ListenerArgs, Selector, SubscribeOptions } from '../../types/subscribe';
2
- export type InternalSubscribeOptions<Selected> = SubscribeOptions<Selected> & {
3
- isCascadeParticipant?: boolean;
4
- };
5
- export type InternalSelectorArgs<S, Selected> = [
6
- selector: Selector<S, Selected>,
7
- listener: Listener<Selected>,
8
- options?: InternalSubscribeOptions<Selected>
9
- ];
10
- export type InternalSubscribeArgs<S, Selected = unknown> = ListenerArgs<S> | InternalSelectorArgs<S, Selected>;
11
- export type InternalUnsubscribeFn = (skipAbortFetch?: boolean) => void;
12
- export type InternalSubscribeOverloads<S> = {
13
- (...args: ListenerArgs<S>): InternalUnsubscribeFn;
14
- <Selected>(...args: InternalSelectorArgs<S, Selected>): InternalUnsubscribeFn;
15
- };
16
- //# sourceMappingURL=internalSubscribeTypes.d.ts.map
@@ -1,9 +0,0 @@
1
- import type { StorageValue } from '../../storage/storageTypes';
2
- /**
3
- * Default partialize function if none is provided. It omits top-level store
4
- * methods and keeps all other state.
5
- */
6
- export declare function omitStoreMethods<S, PersistedState extends Partial<S> = Partial<S>>(state: S): PersistedState;
7
- export declare function defaultSerializeState<PersistedState>(storageValue: StorageValue<PersistedState>, shouldUseReplacer: boolean): string;
8
- export declare function defaultDeserializeState<PersistedState>(serializedState: string, shouldUseReviver: boolean): StorageValue<PersistedState>;
9
- //# sourceMappingURL=persistUtils.d.ts.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=virtualStore.d.ts.map
@@ -1,30 +0,0 @@
1
- import { SyncEngine, SyncHandle, SyncRegistration } from '../../sync/types';
2
- import { ChromeStorageAdapter, ChromeStorageAdapterOptions } from './chromeStorageAdapter';
3
- export type ChromeExtensionSyncEngineOptions = ChromeStorageAdapterOptions | {
4
- storage: ChromeStorageAdapter;
5
- };
6
- export declare class ChromeExtensionSyncEngine implements SyncEngine {
7
- readonly injectStorageMetadata = true;
8
- readonly sessionId: string;
9
- private readonly area;
10
- private readonly storageKeyPrefix;
11
- private readonly registrations;
12
- private isListening;
13
- constructor(options?: ChromeExtensionSyncEngineOptions);
14
- destroy(): void;
15
- register<T extends Record<string, unknown>>(registration: SyncRegistration<T>): SyncHandle<T>;
16
- private generateSessionId;
17
- private attachListener;
18
- private detachListener;
19
- private onStorageChanged;
20
- /**
21
- * Extracts which fields changed in this update.
22
- * Prefers field-level metadata when available, falls back to full state diff.
23
- * Does NOT perform conflict resolution - that's handled by syncEnhancer.processUpdate.
24
- */
25
- private extractChangedFields;
26
- private setRegistration;
27
- private toStorageKey;
28
- private parsePersistValue;
29
- }
30
- //# sourceMappingURL=chromeExtensionSyncEngine.d.ts.map
@@ -1,31 +0,0 @@
1
- import { StorageValue } from '../../storage/storageTypes';
2
- import { AsyncStorageInterface } from '../../types';
3
- export type AreaName = keyof Pick<typeof chrome.storage, 'local' | 'managed' | 'session' | 'sync'>;
4
- export type ChromeStorageAdapterOptions = {
5
- area?: AreaName;
6
- storageKeyPrefix?: string;
7
- };
8
- export type ChromeStorageValue<PersistedState = unknown> = StorageValue<PersistedState>;
9
- export declare class ChromeStorageAdapter implements AsyncStorageInterface {
10
- readonly area: AreaName;
11
- readonly storageKeyPrefix: string;
12
- readonly async = true;
13
- readonly deserializer: typeof deserializeChromeStorageValue;
14
- readonly serializer: typeof serializeChromeStorageValue;
15
- constructor(options?: ChromeStorageAdapterOptions);
16
- clearAll(): Promise<void>;
17
- contains(key: string): Promise<boolean>;
18
- delete(key: string): Promise<void>;
19
- getAllKeys(): Promise<string[]>;
20
- get(key: string): Promise<unknown>;
21
- set(key: string, value: unknown): Promise<void>;
22
- private ensureStorage;
23
- private toStorageKey;
24
- private listPrefixedKeys;
25
- private getFromStorage;
26
- private execute;
27
- private invokeWithCallbackSupport;
28
- }
29
- export declare function serializeChromeStorageValue<PersistedState>(storageValue: StorageValue<PersistedState>): unknown;
30
- export declare function deserializeChromeStorageValue<PersistedState>(serializedState: unknown): StorageValue<PersistedState>;
31
- //# sourceMappingURL=chromeStorageAdapter.d.ts.map
@@ -1,14 +0,0 @@
1
- import { ChromeExtensionSyncEngine } from './chromeExtensionSyncEngine';
2
- import { ChromeStorageAdapter, ChromeStorageAdapterOptions } from './chromeStorageAdapter';
3
- /**
4
- * Creates a synced Chrome storage engine for extension environments.
5
- * @returns
6
- * ```ts
7
- * { engine: ChromeExtensionSyncEngine; storage: ChromeStorageAdapter }
8
- * ```
9
- */
10
- export declare function createSyncedChromeStorage(options?: ChromeStorageAdapterOptions): {
11
- storage: ChromeStorageAdapter;
12
- syncEngine: ChromeExtensionSyncEngine;
13
- };
14
- //# sourceMappingURL=createSyncedChromeStorage.d.ts.map
@@ -1,39 +0,0 @@
1
- /**
2
- * Lazy initialization config for subscription handlers.
3
- */
4
- interface SubscriptionHandlerConfig {
5
- /**
6
- * Callback executed when a subscription is added.
7
- * @param isFirstSubscription - Whether this is the first subscription
8
- * @param shouldThrottle - Whether to throttle the fetch
9
- */
10
- onSubscribe: (isFirstSubscription: boolean, shouldThrottle: boolean) => void;
11
- /** Callback executed when the last remaining subscription is removed. */
12
- onLastUnsubscribe: (willResubscribe?: boolean) => void;
13
- }
14
- /**
15
- * Manages subscription state and lifecycle events for a `createQueryStore` instance.
16
- */
17
- export declare class SubscriptionManager {
18
- private count;
19
- private lastSubscriptionTime;
20
- private readonly fetchThrottleMs;
21
- private onSubscribe;
22
- private onLastUnsubscribe;
23
- /**
24
- * Creates a new SubscriptionManager instance.
25
- */
26
- constructor(disableAutoRefetching: boolean);
27
- /**
28
- * Initializes subscription event handlers.
29
- */
30
- init({ onSubscribe, onLastUnsubscribe }: SubscriptionHandlerConfig): void;
31
- hasSubscribers(): boolean;
32
- /**
33
- * Adds a new subscription and triggers relevant lifecycle callbacks.
34
- * @returns A cleanup function that removes the subscription when called
35
- */
36
- subscribe(): (skipAbortFetch?: boolean) => void;
37
- }
38
- export {};
39
- //# sourceMappingURL=SubscriptionManager.d.ts.map
@@ -1,10 +0,0 @@
1
- /**
2
- * Generates a deterministic query store `queryKey` from the given
3
- * key payload, consistent with internally generated keys.
4
- */
5
- export declare function getQueryKey<TKeyPayload extends Record<string, unknown>>(keyPayload: TKeyPayload): string;
6
- /**
7
- * Parses a query store `queryKey` into the key payload it encodes.
8
- */
9
- export declare function parseQueryKey<TKeyPayload extends Record<string, unknown> = Record<string, unknown>>(queryKey: string): TKeyPayload;
10
- //# sourceMappingURL=queryKey.d.ts.map