scope-state 0.1.0 → 0.1.2
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/README.md +43 -9
- package/dist/index.esm.js +762 -226
- package/dist/index.js +769 -244
- package/dist/src/config/index.d.ts +4 -4
- package/dist/src/config/index.d.ts.map +1 -1
- package/dist/src/core/listeners.d.ts +5 -0
- package/dist/src/core/listeners.d.ts.map +1 -1
- package/dist/src/core/proxy.d.ts.map +1 -1
- package/dist/src/index.d.ts +7 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/persistence/adapters.d.ts +73 -0
- package/dist/src/persistence/adapters.d.ts.map +1 -0
- package/dist/src/persistence/advanced.d.ts +60 -7
- package/dist/src/persistence/advanced.d.ts.map +1 -1
- package/dist/src/persistence/storage.d.ts +20 -7
- package/dist/src/persistence/storage.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +168 -3
- package/dist/src/types/index.d.ts.map +1 -1
- package/package.json +1 -3
|
@@ -14,6 +14,7 @@ export declare let proxyConfig: {
|
|
|
14
14
|
nonBlockingProxyCreation: boolean;
|
|
15
15
|
batchSize: number;
|
|
16
16
|
prioritizeUIObjects: boolean;
|
|
17
|
+
priorityPaths: string[];
|
|
17
18
|
maxQueueSize: number;
|
|
18
19
|
memoryLimit: boolean;
|
|
19
20
|
memoryThreshold: number;
|
|
@@ -22,12 +23,9 @@ export declare let proxyConfig: {
|
|
|
22
23
|
disableProxyingUnderPressure: boolean;
|
|
23
24
|
maxProxyCacheSize: number;
|
|
24
25
|
ultraSelectiveProxying: boolean;
|
|
25
|
-
proxySelectorPaths: boolean;
|
|
26
|
-
* Full-featured preset: All features enabled
|
|
27
|
-
*/
|
|
26
|
+
proxySelectorPaths: boolean;
|
|
28
27
|
forceMemoryCheck: boolean;
|
|
29
28
|
aggressiveMemoryManagement: boolean;
|
|
30
|
-
priorityPaths: string[];
|
|
31
29
|
};
|
|
32
30
|
export declare let monitoringConfig: {
|
|
33
31
|
enabled: boolean;
|
|
@@ -47,6 +45,8 @@ export declare let persistenceConfig: {
|
|
|
47
45
|
paths: string[] | undefined;
|
|
48
46
|
blacklist: string[];
|
|
49
47
|
batchDelay: number;
|
|
48
|
+
autoHydrate?: boolean | undefined;
|
|
49
|
+
storageAdapter?: import("../types").StorageAdapter | undefined;
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
52
52
|
* Get current configuration
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACZ,MAAM,UAAU,CAAC;AAGlB,eAAO,MAAM,kBAAkB,EAAE,WAwBhC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,gBAYrC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACZ,MAAM,UAAU,CAAC;AAGlB,eAAO,MAAM,kBAAkB,EAAE,WAwBhC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,gBAYrC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,iBAMtC,CAAC;AAGF,eAAO,IAAI,WAAW;;;;;;;;;;;;;;;;;;;;;;;;CAA4B,CAAC;AACnD,eAAO,IAAI,gBAAgB;;;;;;;;;;;;CAAiC,CAAC;AAC7D,eAAO,IAAI,iBAAiB;;;;;;;CAAkC,CAAC;AAK/D;;GAEG;AACH,wBAAgB,SAAS,IAAI;IAC3B,KAAK,EAAE,WAAW,CAAC;IACnB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,WAAW,EAAE,iBAAiB,CAAC;CAChC,CAMA;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAIlC;AAED;;GAEG;AACH,eAAO,MAAM,OAAO;IAClB;;OAEG;;IAeH;;OAEG;;IAgBH;;OAEG;;IAiBH;;OAEG;;CAeJ,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { PathListeners, Listener, MonitoringStats } from '../types';
|
|
2
2
|
export declare const pathListeners: PathListeners;
|
|
3
|
+
/**
|
|
4
|
+
* Register a callback that fires after every notifyListeners call.
|
|
5
|
+
* Used internally by the persistence system to batch-persist changes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function setOnStateChangeCallback(callback: (path: string[]) => void): void;
|
|
3
8
|
export declare let monitoringStats: MonitoringStats;
|
|
4
9
|
/**
|
|
5
10
|
* Subscribe to changes on a specific path
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listeners.d.ts","sourceRoot":"","sources":["../../../src/core/listeners.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAIzE,eAAO,MAAM,aAAa,EAAE,aAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"listeners.d.ts","sourceRoot":"","sources":["../../../src/core/listeners.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAIzE,eAAO,MAAM,aAAa,EAAE,aAAyB,CAAC;AAMtD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,GAAG,IAAI,CAEjF;AAGD,eAAO,IAAI,eAAe,EAAE,eAwB3B,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,IAAI,CAqBtE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAyEpD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAMzC;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAEzC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAKxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../../src/core/proxy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../../src/core/proxy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAIlE,eAAO,MAAM,YAAY,2BAAkC,CAAC;AAM5D,eAAO,MAAM,cAAc;;;;CAI1B,CAAC;AAGF,eAAO,MAAM,aAAa,aAAoB,CAAC;AAM/C,eAAO,MAAM,eAAe;;;;;CAK3B,CAAC;AAiGF,eAAO,MAAM,cAAc;;;;;;2BA4CF,MAAM;CAS9B,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,CAErD;AAYD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAClD,MAAM,EAAE,CAAC,EACT,IAAI,GAAE,MAAM,EAAO,EACnB,KAAK,GAAE,MAAU,GAChB,CAAC,GAAG,CAAC,CAAC,SAAS,GAAG,EAAE,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CA4JrE;AA8UD;;GAEG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAUtC;AAED;;GAEG;AACH,wBAAgB,kBAAkB;;;;;;;EAMjC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,UAAQ,GAAG,GAAG,CA4B3D"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -3,9 +3,11 @@ export { useLocal } from './hooks/useLocal';
|
|
|
3
3
|
export { getConfig, resetConfig, presets } from './config';
|
|
4
4
|
export { initializeStore, getStore, resetStore } from './core/store';
|
|
5
5
|
export { monitorAPI } from './core/monitoring';
|
|
6
|
-
export { persistenceAPI } from './persistence/advanced';
|
|
6
|
+
export { persistenceAPI, hydrateState, mergePersistedIntoState } from './persistence/advanced';
|
|
7
|
+
export { createLocalStorageAdapter, createMemoryAdapter, createCachedAdapter, getDefaultAdapter } from './persistence/adapters';
|
|
8
|
+
export { setStorageAdapter, getStorageAdapter } from './persistence/storage';
|
|
7
9
|
export { setInitialStoreState, createAdvancedProxy, pathUsageStats, selectorPaths, clearProxyCache, getProxyCacheStats, optimizeMemoryUsage, proxyPathMap } from './core/proxy';
|
|
8
|
-
export type { ScopeConfig, ProxyConfig, MonitoringConfig, PersistenceConfig, CustomMethods, CustomArrayMethods, StoreType, MonitoringStats, ProxyCacheStats, PathUsageStats } from './types';
|
|
10
|
+
export type { ScopeConfig, ProxyConfig, MonitoringConfig, PersistenceConfig, StorageAdapter, MaybePromise, CustomMethods, CustomArrayMethods, StoreType, MonitoringStats, ProxyCacheStats, PathUsageStats } from './types';
|
|
9
11
|
import type { StoreType, CustomMethods, CustomArrayMethods, ScopeConfig } from './types';
|
|
10
12
|
/**
|
|
11
13
|
* Configure Scope with custom settings and return a properly typed store
|
|
@@ -25,9 +27,9 @@ export declare function $activate<T>(obj: T): T;
|
|
|
25
27
|
export declare function getProxy<T = any>(path: string | string[] | any): T;
|
|
26
28
|
export declare function $get<T = any>(path: string | string[] | T): T;
|
|
27
29
|
export declare const debugInfo: {
|
|
28
|
-
getListenerCount: () =>
|
|
29
|
-
getPathCount: () =>
|
|
30
|
-
getActivePaths: () =>
|
|
30
|
+
getListenerCount: () => number;
|
|
31
|
+
getPathCount: () => number;
|
|
32
|
+
getActivePaths: () => string[];
|
|
31
33
|
};
|
|
32
34
|
export declare const rawStore: any;
|
|
33
35
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAIrE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAC/F,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChI,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACb,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,SAAS,EACT,eAAe,EACf,eAAe,EACf,cAAc,EACf,MAAM,SAAS,CAAC;AASjB,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,SA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
|
|
2
|
+
/**
|
|
3
|
+
* Creates a localStorage-based storage adapter.
|
|
4
|
+
*
|
|
5
|
+
* This is the default adapter used in browser environments.
|
|
6
|
+
* All methods are synchronous (localStorage is synchronous by nature).
|
|
7
|
+
*
|
|
8
|
+
* @param prefix - Optional key prefix to namespace all stored keys. Defaults to 'scope_state:'.
|
|
9
|
+
* @returns A StorageAdapter backed by window.localStorage
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { configure, createLocalStorageAdapter } from 'scope-state';
|
|
13
|
+
*
|
|
14
|
+
* configure({
|
|
15
|
+
* initialState: { ... },
|
|
16
|
+
* persistence: {
|
|
17
|
+
* enabled: true,
|
|
18
|
+
* storageAdapter: createLocalStorageAdapter('myapp:'),
|
|
19
|
+
* },
|
|
20
|
+
* });
|
|
21
|
+
*/
|
|
22
|
+
export declare function createLocalStorageAdapter(prefix?: string): StorageAdapter;
|
|
23
|
+
/**
|
|
24
|
+
* Creates an in-memory storage adapter.
|
|
25
|
+
*
|
|
26
|
+
* Useful for:
|
|
27
|
+
* - Server-side rendering (SSR) where no persistent storage is available
|
|
28
|
+
* - Testing environments
|
|
29
|
+
* - Ephemeral state that should not survive page reloads
|
|
30
|
+
*
|
|
31
|
+
* All methods are synchronous.
|
|
32
|
+
*
|
|
33
|
+
* @returns A StorageAdapter backed by an in-memory Map
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* import { configure, createMemoryAdapter } from 'scope-state';
|
|
37
|
+
*
|
|
38
|
+
* configure({
|
|
39
|
+
* initialState: { ... },
|
|
40
|
+
* persistence: {
|
|
41
|
+
* enabled: true,
|
|
42
|
+
* storageAdapter: createMemoryAdapter(),
|
|
43
|
+
* },
|
|
44
|
+
* });
|
|
45
|
+
*/
|
|
46
|
+
export declare function createMemoryAdapter(): StorageAdapter;
|
|
47
|
+
/**
|
|
48
|
+
* Wraps any StorageAdapter in an in-memory cache layer.
|
|
49
|
+
*
|
|
50
|
+
* This is automatically applied to all adapters by the persistence system.
|
|
51
|
+
* The cache prevents hydration mismatches by ensuring:
|
|
52
|
+
*
|
|
53
|
+
* 1. **On startup**: the cache is empty, so reads return `null` and the app
|
|
54
|
+
* renders with `initialState` (matching SSR output).
|
|
55
|
+
* 2. **After hydration**: data is pulled from the backing store into the cache,
|
|
56
|
+
* and components re-render with persisted data.
|
|
57
|
+
* 3. **On writes**: both the cache and the backing store are updated, so
|
|
58
|
+
* subsequent reads are instant from memory.
|
|
59
|
+
*
|
|
60
|
+
* @param backingAdapter - The underlying storage adapter (MMKV, AsyncStorage, etc.)
|
|
61
|
+
* @returns A StorageAdapter with an in-memory cache in front of the backing store
|
|
62
|
+
*/
|
|
63
|
+
export declare function createCachedAdapter(backingAdapter: StorageAdapter): StorageAdapter & {
|
|
64
|
+
warmCache(): Promise<void>;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Returns the default storage adapter for the current environment.
|
|
68
|
+
*
|
|
69
|
+
* - In browsers: returns a localStorage adapter
|
|
70
|
+
* - In non-browser environments (Node, SSR): returns a memory adapter
|
|
71
|
+
*/
|
|
72
|
+
export declare function getDefaultAdapter(): StorageAdapter;
|
|
73
|
+
//# sourceMappingURL=adapters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../../../src/persistence/adapters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,GAAE,MAAuB,GAAG,cAAc,CAyDzF;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,mBAAmB,IAAI,cAAc,CAwBpD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,GAAG,cAAc,GAAG;IAAE,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CA+CnH;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CAKlD"}
|
|
@@ -1,9 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Set the global store reference (raw object) for serialization during persistence.
|
|
3
|
+
* Called internally by configure().
|
|
4
|
+
*/
|
|
5
|
+
export declare function setGlobalStoreRef(store: any): void;
|
|
6
|
+
/**
|
|
7
|
+
* Set the global proxy reference for hydration writes.
|
|
8
|
+
* Writing through the proxy ensures set traps fire and components re-render.
|
|
9
|
+
* Called internally by configure() after the proxy is created.
|
|
10
|
+
*/
|
|
11
|
+
export declare function setGlobalProxyRef(proxy: any): void;
|
|
12
|
+
/**
|
|
13
|
+
* Add a changed path to the persistence batch.
|
|
14
|
+
*
|
|
15
|
+
* The path is converted to its persistence root before being added,
|
|
16
|
+
* so multiple changes within the same slice (e.g. "user.name" and
|
|
17
|
+
* "user.preferences.theme") are deduplicated into a single "user" persist.
|
|
3
18
|
*/
|
|
4
19
|
export declare function addToPersistenceBatch(path: string[]): void;
|
|
5
20
|
/**
|
|
6
|
-
*
|
|
21
|
+
* Merge persisted data into the initial state object **before** the proxy is created.
|
|
22
|
+
*
|
|
23
|
+
* This is the fastest possible hydration path for synchronous adapters (localStorage,
|
|
24
|
+
* memory). Because the merge happens on a plain object — not through the proxy —
|
|
25
|
+
* there are no set traps, no `notifyListeners`, and no React re-renders. The proxy
|
|
26
|
+
* is then created wrapping the already-correct state, so components render with
|
|
27
|
+
* persisted values on their very first render.
|
|
28
|
+
*
|
|
29
|
+
* For async adapters (those wrapped in `createCachedAdapter`), this returns `null`
|
|
30
|
+
* and the caller falls back to the async `hydrateState()` path.
|
|
31
|
+
*
|
|
32
|
+
* @param initialState - The default state from the user's config. Not mutated.
|
|
33
|
+
* @returns A new state object with persisted data merged in, or `null` if the
|
|
34
|
+
* adapter is async and synchronous merge isn't possible.
|
|
35
|
+
*/
|
|
36
|
+
export declare function mergePersistedIntoState(initialState: Record<string, any>): Record<string, any> | null;
|
|
37
|
+
/**
|
|
38
|
+
* Hydrate state from storage using the configured StorageAdapter (async path).
|
|
39
|
+
*
|
|
40
|
+
* This is the fallback for asynchronous adapters (e.g. AsyncStorage wrapped in
|
|
41
|
+
* `createCachedAdapter`). For synchronous adapters, `mergePersistedIntoState()`
|
|
42
|
+
* is used instead — it's faster because it avoids proxy overhead entirely.
|
|
43
|
+
*
|
|
44
|
+
* @param store - The store object to hydrate into. If omitted, uses the
|
|
45
|
+
* global store set by `configure()`.
|
|
7
46
|
*/
|
|
8
47
|
export declare function hydrateState(store?: any): Promise<boolean>;
|
|
9
48
|
/**
|
|
@@ -11,11 +50,11 @@ export declare function hydrateState(store?: any): Promise<boolean>;
|
|
|
11
50
|
*/
|
|
12
51
|
export declare function loadPersistenceConfig(): Promise<void>;
|
|
13
52
|
/**
|
|
14
|
-
* Save persistence configuration
|
|
53
|
+
* Save persistence configuration (excluding non-serializable fields)
|
|
15
54
|
*/
|
|
16
55
|
export declare function savePersistenceConfig(): void;
|
|
17
56
|
/**
|
|
18
|
-
* Persistence API
|
|
57
|
+
* Persistence API — the public interface for controlling persistence at runtime.
|
|
19
58
|
*/
|
|
20
59
|
export declare const persistenceAPI: {
|
|
21
60
|
setEnabled: (enabled: boolean) => void;
|
|
@@ -28,20 +67,34 @@ export declare const persistenceAPI: {
|
|
|
28
67
|
paths: string[] | undefined;
|
|
29
68
|
blacklist: string[];
|
|
30
69
|
batchDelay: number;
|
|
70
|
+
autoHydrate?: boolean | undefined;
|
|
71
|
+
storageAdapter?: import("..").StorageAdapter | undefined;
|
|
31
72
|
};
|
|
32
73
|
setBatchDelay: (delay: number) => void;
|
|
33
74
|
reset: () => Promise<void>;
|
|
34
75
|
persist: () => void;
|
|
35
76
|
flushBatch: () => void;
|
|
77
|
+
/**
|
|
78
|
+
* Manually hydrate state from the backing storage adapter.
|
|
79
|
+
*
|
|
80
|
+
* Use this when `autoHydrate` is `false` and you want to control
|
|
81
|
+
* exactly when persisted data is loaded (e.g., after a splash screen).
|
|
82
|
+
*
|
|
83
|
+
* @param store - Optional store to hydrate into. Defaults to the global store.
|
|
84
|
+
*/
|
|
36
85
|
rehydrate: (store?: any) => Promise<boolean>;
|
|
37
86
|
getBatchStatus: () => {
|
|
38
|
-
|
|
87
|
+
pendingRoots: string[];
|
|
39
88
|
isPersisting: boolean;
|
|
40
89
|
batchSize: number;
|
|
41
90
|
};
|
|
42
91
|
};
|
|
43
92
|
/**
|
|
44
|
-
* Initialize persistence system
|
|
93
|
+
* Initialize persistence system.
|
|
94
|
+
*
|
|
95
|
+
* @param willAutoHydrate - Whether hydrateState will be called automatically.
|
|
96
|
+
* If false (autoHydrate disabled), persistence is enabled immediately since
|
|
97
|
+
* the developer will manually call rehydrate() when ready.
|
|
45
98
|
*/
|
|
46
|
-
export declare function initializePersistence(): void;
|
|
99
|
+
export declare function initializePersistence(willAutoHydrate?: boolean): void;
|
|
47
100
|
//# sourceMappingURL=advanced.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../../src/persistence/advanced.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"advanced.d.ts","sourceRoot":"","sources":["../../../src/persistence/advanced.ts"],"names":[],"mappings":"AAyBA;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,CAElD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,CAElD;AAoFD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAS1D;AA+HD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAChC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CA6F5B;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAAC,KAAK,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAuGhE;AAED;;GAEG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAc3D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAe5C;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;0BAEH,OAAO;0BAMP,MAAM,EAAE;4BAWN,MAAM,EAAE;4BAkBR,MAAM,EAAE;8BAgBN,MAAM,EAAE;;;;;;;;;2BASX,MAAM;;;;IAiD7B;;;;;;;OAOG;wBACiB,GAAG;;;;;;CAQxB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,eAAe,GAAE,OAAc,GAAG,IAAI,CAa3E"}
|
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
import type { StorageAdapter } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Get the current storage adapter, lazily initializing the default if needed.
|
|
4
4
|
*/
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function getStorageAdapter(): StorageAdapter & {
|
|
6
|
+
warmCache?(): Promise<void>;
|
|
7
|
+
};
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
9
|
+
* Set a custom storage adapter.
|
|
10
|
+
*
|
|
11
|
+
* Synchronous adapters (like `createLocalStorageAdapter` and `createMemoryAdapter`)
|
|
12
|
+
* are stored directly — this enables **synchronous hydration** during `configure()`,
|
|
13
|
+
* so components render with persisted values on the very first render (no flash of
|
|
14
|
+
* default values).
|
|
15
|
+
*
|
|
16
|
+
* For asynchronous adapters (AsyncStorage, MMKV with async API), wrap them in
|
|
17
|
+
* `createCachedAdapter()` before passing to `configure()`. The cache layer provides
|
|
18
|
+
* instant reads after the initial warm-up.
|
|
19
|
+
*
|
|
20
|
+
* @param adapter - A StorageAdapter implementation
|
|
8
21
|
*/
|
|
9
|
-
export declare function
|
|
22
|
+
export declare function setStorageAdapter(adapter: StorageAdapter): void;
|
|
10
23
|
/**
|
|
11
|
-
*
|
|
24
|
+
* Reset the storage adapter to the environment default.
|
|
12
25
|
*/
|
|
13
|
-
export declare function
|
|
26
|
+
export declare function resetStorageAdapter(): void;
|
|
14
27
|
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/persistence/storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/persistence/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAc/C;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,GAAG;IAAE,SAAS,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAOpF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAE/D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C"}
|
|
@@ -71,26 +71,86 @@ export interface ProxyConfig {
|
|
|
71
71
|
* @default false @example true
|
|
72
72
|
*/
|
|
73
73
|
selectiveProxying: boolean;
|
|
74
|
+
/** Whether to track path usage (this is a monitoring feature that displays usage statistics in the console).
|
|
75
|
+
* @default true
|
|
76
|
+
*/
|
|
74
77
|
trackPathUsage: boolean;
|
|
78
|
+
/** Whether to proxy deep objects lazily (this is a performance optimization that prevents unnecessary proxy creation for deeply nested objects).
|
|
79
|
+
* @default false
|
|
80
|
+
*/
|
|
75
81
|
lazyProxyDeepObjects: boolean;
|
|
82
|
+
/** The paths to pre-proxy, EVEN if they are not accessed yet and/or a component which is using them is not mounted yet.
|
|
83
|
+
* @default [] @example ['user.name', 'theme']
|
|
84
|
+
*/
|
|
76
85
|
preProxyPaths: string[];
|
|
86
|
+
/** The maximum length of a path (number of nested objects / depth).
|
|
87
|
+
* @default 20
|
|
88
|
+
*/
|
|
77
89
|
maxPathLength: number;
|
|
90
|
+
/** Whether to track array changes.
|
|
91
|
+
* @default true
|
|
92
|
+
*/
|
|
78
93
|
smartArrayTracking: boolean;
|
|
94
|
+
/** Whether to create proxies in a non-blocking, asynchronous way (this is a performance optimization that prevents blocking the main thread for long periods of time).
|
|
95
|
+
* @default true
|
|
96
|
+
*/
|
|
79
97
|
nonBlockingProxyCreation: boolean;
|
|
98
|
+
/** The batch size for proxy creation (the number of proxies to create at once).
|
|
99
|
+
* @default 1
|
|
100
|
+
*/
|
|
80
101
|
batchSize: number;
|
|
102
|
+
/** Whether to prioritize UI objects. If ```true```, you must provide a ```priorityPaths``` array in this config object.
|
|
103
|
+
* @default true
|
|
104
|
+
*/
|
|
81
105
|
prioritizeUIObjects: boolean;
|
|
106
|
+
/** The paths to prioritize. Must be paired with ```prioritizeUIObjects``` being ```true```.
|
|
107
|
+
* @default [] @example ['user.name', 'theme']
|
|
108
|
+
*/
|
|
109
|
+
priorityPaths: string[];
|
|
110
|
+
/** The maximum size of the proxy queue (the number of proxies to create at once).
|
|
111
|
+
* @default 1000
|
|
112
|
+
*/
|
|
82
113
|
maxQueueSize: number;
|
|
114
|
+
/** Whether to limit the memory usage of the proxy cache.
|
|
115
|
+
* @default false
|
|
116
|
+
*/
|
|
83
117
|
memoryLimit: boolean;
|
|
118
|
+
/** The memory threshold for the proxy cache (the percentage of memory usage at which the proxy cache will be cleared).
|
|
119
|
+
* @default 1
|
|
120
|
+
*/
|
|
84
121
|
memoryThreshold: number;
|
|
122
|
+
/** The target memory usage (in megabytes - MB) for the proxy cache (the percentage of memory usage at which the proxy cache will be cleared).
|
|
123
|
+
* @default 3000
|
|
124
|
+
*/
|
|
85
125
|
targetMemoryUsage: number;
|
|
126
|
+
/** The eviction strategy for the proxy cache.
|
|
127
|
+
* @default 'lru'
|
|
128
|
+
*/
|
|
86
129
|
proxyEvictionStrategy: 'lru';
|
|
130
|
+
/** Whether to disable proxying under pressure (this is a performance optimization that prevents proxying under high memory usage).
|
|
131
|
+
* @default false
|
|
132
|
+
*/
|
|
87
133
|
disableProxyingUnderPressure: boolean;
|
|
134
|
+
/** The maximum size of the proxy cache (the number of proxies to create at once).
|
|
135
|
+
* @default 5000
|
|
136
|
+
*/
|
|
88
137
|
maxProxyCacheSize: number;
|
|
138
|
+
/** Whether to enable ultra selective proxying. This causes most proxies to be ignored, unless they are accessed explicitly by a component or marked as a priority path.
|
|
139
|
+
* @default false
|
|
140
|
+
*/
|
|
89
141
|
ultraSelectiveProxying: boolean;
|
|
142
|
+
/** Whether to proxy selector paths. If ```true```, the proxy will be created for all paths that are accessed by a component (including the parent paths of the target value).
|
|
143
|
+
* @default true
|
|
144
|
+
*/
|
|
90
145
|
proxySelectorPaths: boolean;
|
|
146
|
+
/** Whether to force a memory check.
|
|
147
|
+
* @default false
|
|
148
|
+
*/
|
|
91
149
|
forceMemoryCheck: boolean;
|
|
150
|
+
/** Whether to enable aggressive memory management. This causes the proxy cache to be cleared when the memory usage exceeds the target memory usage.
|
|
151
|
+
* @default false
|
|
152
|
+
*/
|
|
92
153
|
aggressiveMemoryManagement: boolean;
|
|
93
|
-
priorityPaths: string[];
|
|
94
154
|
}
|
|
95
155
|
export interface MonitoringConfig {
|
|
96
156
|
enabled: boolean;
|
|
@@ -105,6 +165,72 @@ export interface MonitoringConfig {
|
|
|
105
165
|
leakAlertThreshold: number;
|
|
106
166
|
leakScanMinimumRenderCycles: number;
|
|
107
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* A value that may or may not be wrapped in a Promise.
|
|
170
|
+
*
|
|
171
|
+
* This allows StorageAdapter methods to be implemented synchronously
|
|
172
|
+
* (e.g. MMKV, localStorage) or asynchronously (e.g. AsyncStorage, IndexedDB).
|
|
173
|
+
* The persistence layer always `await`s the result, which is a no-op for
|
|
174
|
+
* synchronous return values.
|
|
175
|
+
*/
|
|
176
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
177
|
+
/**
|
|
178
|
+
* A pluggable storage backend for persistence.
|
|
179
|
+
*
|
|
180
|
+
* Implement this interface to use any storage engine (MMKV, AsyncStorage,
|
|
181
|
+
* localStorage, IndexedDB, etc.) with Scope State's persistence layer.
|
|
182
|
+
*
|
|
183
|
+
* Methods can return either a plain value or a Promise — the persistence
|
|
184
|
+
* layer `await`s every call, so both sync and async implementations work
|
|
185
|
+
* seamlessly with zero overhead for synchronous backends.
|
|
186
|
+
*
|
|
187
|
+
* When a custom adapter is provided, Scope State automatically wraps it
|
|
188
|
+
* in an in-memory cache layer. This means:
|
|
189
|
+
* - On app startup the cache is empty, so the first render uses `initialState`
|
|
190
|
+
* (preventing SSR hydration mismatches).
|
|
191
|
+
* - After `hydrateState()` runs (manually or via `autoHydrate`), persisted
|
|
192
|
+
* data is loaded from the backing store into the cache.
|
|
193
|
+
* - All subsequent reads are served instantly from the in-memory cache.
|
|
194
|
+
* - All writes go to both the cache and the backing store.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* // React Native with MMKV (synchronous — no async/await needed!)
|
|
198
|
+
* import { MMKV } from 'react-native-mmkv';
|
|
199
|
+
* const mmkv = new MMKV();
|
|
200
|
+
* const mmkvAdapter: StorageAdapter = {
|
|
201
|
+
* getItem: (key) => mmkv.getString(key) ?? null,
|
|
202
|
+
* setItem: (key, value) => { mmkv.set(key, value); },
|
|
203
|
+
* removeItem: (key) => { mmkv.delete(key); },
|
|
204
|
+
* keys: () => mmkv.getAllKeys(),
|
|
205
|
+
* clear: () => { mmkv.clearAll(); },
|
|
206
|
+
* };
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* // React Native with AsyncStorage (asynchronous)
|
|
210
|
+
* import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
211
|
+
* const asyncStorageAdapter: StorageAdapter = {
|
|
212
|
+
* getItem: (key) => AsyncStorage.getItem(key),
|
|
213
|
+
* setItem: (key, value) => AsyncStorage.setItem(key, value).then(() => {}),
|
|
214
|
+
* removeItem: (key) => AsyncStorage.removeItem(key).then(() => {}),
|
|
215
|
+
* keys: () => AsyncStorage.getAllKeys().then(k => [...k]),
|
|
216
|
+
* clear: () => AsyncStorage.clear().then(() => {}),
|
|
217
|
+
* };
|
|
218
|
+
*/
|
|
219
|
+
export interface StorageAdapter {
|
|
220
|
+
/** Retrieve a value by key. Returns null if the key does not exist. */
|
|
221
|
+
getItem(key: string): MaybePromise<string | null>;
|
|
222
|
+
/** Store a string value under the given key. */
|
|
223
|
+
setItem(key: string, value: string): MaybePromise<void>;
|
|
224
|
+
/** Remove the value for the given key. */
|
|
225
|
+
removeItem(key: string): MaybePromise<void>;
|
|
226
|
+
/** Return all keys currently stored. */
|
|
227
|
+
keys(): MaybePromise<string[]>;
|
|
228
|
+
/**
|
|
229
|
+
* Optional. Clear all keys from storage.
|
|
230
|
+
* If not provided, `persistenceAPI.reset()` will iterate and remove keys individually.
|
|
231
|
+
*/
|
|
232
|
+
clear?(): MaybePromise<void>;
|
|
233
|
+
}
|
|
108
234
|
export interface PersistenceConfig {
|
|
109
235
|
/** Whether persistence is enabled */
|
|
110
236
|
enabled: boolean;
|
|
@@ -121,6 +247,47 @@ export interface PersistenceConfig {
|
|
|
121
247
|
* @default 300
|
|
122
248
|
*/
|
|
123
249
|
batchDelay: number;
|
|
250
|
+
/**
|
|
251
|
+
* Whether to automatically hydrate state from storage when `configure()` is called.
|
|
252
|
+
*
|
|
253
|
+
* When `true` (default), persisted state is loaded automatically after configuration.
|
|
254
|
+
* When `false`, you must call `persistenceAPI.rehydrate()` or `hydrateState()` manually
|
|
255
|
+
* to load persisted data. This is useful when you need to control exactly when
|
|
256
|
+
* hydration happens (e.g., after a loading screen, after auth, etc.).
|
|
257
|
+
*
|
|
258
|
+
* @default true
|
|
259
|
+
*/
|
|
260
|
+
autoHydrate?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* A custom storage adapter for persistence.
|
|
263
|
+
* If not provided, defaults to a localStorage-based adapter in browsers
|
|
264
|
+
* and a memory adapter in non-browser environments (SSR / Node).
|
|
265
|
+
*
|
|
266
|
+
* All adapters are automatically wrapped in an in-memory cache layer to
|
|
267
|
+
* prevent hydration errors. The cache starts empty (so the first render
|
|
268
|
+
* uses `initialState`), and is populated when hydration runs.
|
|
269
|
+
*
|
|
270
|
+
* Use this to plug in any storage backend (MMKV, AsyncStorage, IndexedDB, etc.).
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* import { createLocalStorageAdapter } from 'scope-state';
|
|
274
|
+
* persistence: { storageAdapter: createLocalStorageAdapter() }
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* // Synchronous adapter (MMKV)
|
|
278
|
+
* import { MMKV } from 'react-native-mmkv';
|
|
279
|
+
* const mmkv = new MMKV();
|
|
280
|
+
* persistence: {
|
|
281
|
+
* storageAdapter: {
|
|
282
|
+
* getItem: (key) => mmkv.getString(key) ?? null,
|
|
283
|
+
* setItem: (key, value) => { mmkv.set(key, value); },
|
|
284
|
+
* removeItem: (key) => { mmkv.delete(key); },
|
|
285
|
+
* keys: () => mmkv.getAllKeys(),
|
|
286
|
+
* clear: () => { mmkv.clearAll(); },
|
|
287
|
+
* }
|
|
288
|
+
* }
|
|
289
|
+
*/
|
|
290
|
+
storageAdapter?: StorageAdapter;
|
|
124
291
|
}
|
|
125
292
|
export interface ScopeConfig<T extends Record<string, any> = Record<string, any>> {
|
|
126
293
|
/** Initial store state */
|
|
@@ -131,8 +298,6 @@ export interface ScopeConfig<T extends Record<string, any> = Record<string, any>
|
|
|
131
298
|
monitoring?: Partial<MonitoringConfig>;
|
|
132
299
|
/** Persistence configuration */
|
|
133
300
|
persistence?: Partial<PersistenceConfig>;
|
|
134
|
-
/** Storage instance for persistence */
|
|
135
|
-
storage?: any;
|
|
136
301
|
}
|
|
137
302
|
export type Listener = () => void;
|
|
138
303
|
export type PathListeners = Map<string, Set<Listener>>;
|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;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC9B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scope-state",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Scope State is the simplest global state system for React that you've ever used — no boilerplate, no spreading, no mental overhead.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -63,7 +63,5 @@
|
|
|
63
63
|
"typescript": "^4.9.5"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"localforage": "^1.10.0",
|
|
67
|
-
"localforage-driver-memory": "^1.0.5"
|
|
68
66
|
}
|
|
69
67
|
}
|