@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
|
@@ -1,34 +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>;
|
|
@@ -1,28 +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;
|
|
@@ -1,21 +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>;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* **Worklet compatible**
|
|
3
|
-
*
|
|
4
|
-
* Performs a deep equality check between two values.
|
|
5
|
-
*
|
|
6
|
-
* This function recursively compares two values, checking if they are equal. For objects,
|
|
7
|
-
* it validates that both have the same keys and that each corresponding value is deeply equal.
|
|
8
|
-
* For non-objects, it uses strict equality.
|
|
9
|
-
*
|
|
10
|
-
* @param obj1 - The first value to compare.
|
|
11
|
-
* @param obj2 - The second value to compare.
|
|
12
|
-
* @returns `true` if the values are deeply equal; otherwise, `false`.
|
|
13
|
-
*/
|
|
14
|
-
export declare function deepEqual<U>(obj1: U, obj2: U): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* **Worklet compatible**
|
|
17
|
-
*
|
|
18
|
-
* Performs a shallow equality check between two values.
|
|
19
|
-
*
|
|
20
|
-
* For non-objects, uses strict equality (===). For objects, checks that both have identical
|
|
21
|
-
* keys and compares their values using `Object.is` without recursing into nested objects.
|
|
22
|
-
*
|
|
23
|
-
* Ideal for preventing re-renders due to top-level object recreation.
|
|
24
|
-
*
|
|
25
|
-
* @param obj1 - The first value to compare.
|
|
26
|
-
* @param obj2 - The second value to compare.
|
|
27
|
-
* @returns `true` if the values are shallowly equal; otherwise, `false`.
|
|
28
|
-
*/
|
|
29
|
-
export declare function shallowEqual<U>(obj1: U, obj2: U): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Performs a deep equality check between two values, supporting objects, arrays, maps, sets, dates, regexps, array buffers, and more.
|
|
32
|
-
* Copied from dequal@2.0.3 and fully typed for TypeScript.
|
|
33
|
-
* @param foo - The first value to compare.
|
|
34
|
-
* @param bar - The second value to compare.
|
|
35
|
-
* @returns `true` if the values are deeply equal; otherwise, `false`.
|
|
36
|
-
*/
|
|
37
|
-
export declare function dequal(foo: unknown, bar: unknown): boolean;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type HydrationCoordinator = {
|
|
2
|
-
readonly complete: () => void;
|
|
3
|
-
readonly fail: (error: Error) => void;
|
|
4
|
-
readonly isHydrated: () => boolean;
|
|
5
|
-
readonly promise: Promise<void>;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Creates a coordinator for tracking async storage hydration lifecycle.
|
|
9
|
-
* Provides a promise that resolves once hydration completes and methods
|
|
10
|
-
* to signal completion or failure.
|
|
11
|
-
*/
|
|
12
|
-
export declare function createHydrationCoordinator(): HydrationCoordinator;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isPromiseLike<T>(value: T | Promise<T> | void): value is Promise<T>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
type SerializedMap = {
|
|
2
|
-
__type: 'Map';
|
|
3
|
-
entries: [unknown, unknown][];
|
|
4
|
-
};
|
|
5
|
-
export declare function isSerializedMap(value: unknown): value is SerializedMap;
|
|
6
|
-
type SerializedSet = {
|
|
7
|
-
__type: 'Set';
|
|
8
|
-
values: unknown[];
|
|
9
|
-
};
|
|
10
|
-
export declare function isSerializedSet(value: unknown): value is SerializedSet;
|
|
11
|
-
export declare function replacer(_: string, value: unknown): unknown;
|
|
12
|
-
export declare function reviver(_: string, value: unknown): unknown;
|
|
13
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
type TimeInMs = number;
|
|
2
|
-
type TimeUtils = {
|
|
3
|
-
/** Returns the input value unchanged, in milliseconds */
|
|
4
|
-
ms: (ms: number) => TimeInMs;
|
|
5
|
-
/** Converts seconds to milliseconds */
|
|
6
|
-
seconds: (seconds: number) => TimeInMs;
|
|
7
|
-
/** Converts minutes to milliseconds */
|
|
8
|
-
minutes: (minutes: number) => TimeInMs;
|
|
9
|
-
/** Converts hours to milliseconds */
|
|
10
|
-
hours: (hours: number) => TimeInMs;
|
|
11
|
-
/** Converts days to milliseconds */
|
|
12
|
-
days: (days: number) => TimeInMs;
|
|
13
|
-
/** Converts weeks to milliseconds */
|
|
14
|
-
weeks: (weeks: number) => TimeInMs;
|
|
15
|
-
/** Represents infinite time */
|
|
16
|
-
infinity: typeof Infinity;
|
|
17
|
-
/** Represents zero time */
|
|
18
|
-
zero: 0;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Worklet-compatible utility object for defining time values.
|
|
22
|
-
*
|
|
23
|
-
* All methods convert the input unit to milliseconds.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* time.seconds(5) // 5 seconds
|
|
27
|
-
* time.minutes(2) // 2 minutes
|
|
28
|
-
* time.hours(1) // 1 hour
|
|
29
|
-
* time.days(5) // 5 days
|
|
30
|
-
* time.weeks(2) // 2 weeks
|
|
31
|
-
* ––
|
|
32
|
-
* time.infinity // Infinity
|
|
33
|
-
* time.zero // 0
|
|
34
|
-
*/
|
|
35
|
-
export declare const time: TimeUtils;
|
|
36
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,t){return t instanceof Map?{__type:"Map",entries:Array.from(t.entries())}:t instanceof Set?{__type:"Set",values:Array.from(t)}:t}function t(e,t){return function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Map"===e.__type}(t)?new Map(t.entries):function(e){return"object"==typeof e&&null!==e&&"__type"in e&&"Set"===e.__type}(t)?new Set(t.values):t}function n(e){return!!e&&"object"==typeof e&&"then"in e&&"function"==typeof e.then}export{n as isPromiseLike,e as replacer,t as reviver};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e="undefined"!=typeof window&&"undefined"!=typeof document,t=!1,n="development"===process.env.NODE_ENV,r="test"===process.env.NODE_ENV,o=Object.freeze(Object.create(null));function c(e){return e}function u(){return Object.create(o)}function f(e,t){return void 0===t?Object.assign(u(),e):Object.assign(u(),e,t)}function i(){}var p=Object.prototype.hasOwnProperty;function s(e,t){return p.call(e,t)}function O(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function l(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}export{e as IS_BROWSER,n as IS_DEV,t as IS_IOS,r as IS_TEST,f as buildNullObject,s as hasOwn,c as identity,O as isPlainObject,l as isRecordLike,i as noop,u as nullObject};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{isPlainObject as r,nullObject as n}from"./chunk-FPYZVFBM.mjs";function t(r){return JSON.stringify(o(r))}function e(r){return JSON.parse(r)}function o(t){return"object"!=typeof t||null===t?t:Object.keys(t).sort().reduce((n,e)=>{const u=t[e];return n[e]=r(u)?o(u):u,n},n())}var u=Symbol("stores.queryParamConfig");function c(r,n){return{[u]:!0,key:n.key,value:r}}function f(r){return!!r&&"object"==typeof r&&u in r}export{t as getQueryKey,f as isQueryParamConfig,e as parseQueryKey,c as queryParam};
|