juststore 1.2.0 → 1.2.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/README.md +3 -2
- package/dist/form.js +35 -19
- package/package.json +1 -1
- package/dist/src/atom.d.ts +0 -45
- package/dist/src/atom.js +0 -141
- package/dist/src/form.d.ts +0 -97
- package/dist/src/form.js +0 -176
- package/dist/src/impl.d.ts +0 -128
- package/dist/src/impl.js +0 -644
- package/dist/src/index.d.ts +0 -10
- package/dist/src/index.js +0 -7
- package/dist/src/kv_store.d.ts +0 -29
- package/dist/src/kv_store.js +0 -127
- package/dist/src/local_storage.d.ts +0 -7
- package/dist/src/local_storage.js +0 -43
- package/dist/src/memory.d.ts +0 -54
- package/dist/src/memory.js +0 -55
- package/dist/src/mixed_state.d.ts +0 -20
- package/dist/src/mixed_state.js +0 -45
- package/dist/src/node.d.ts +0 -41
- package/dist/src/node.js +0 -374
- package/dist/src/path.d.ts +0 -136
- package/dist/src/path.js +0 -26
- package/dist/src/root.d.ts +0 -23
- package/dist/src/root.js +0 -81
- package/dist/src/stable_keys.d.ts +0 -4
- package/dist/src/stable_keys.js +0 -31
- package/dist/src/store.d.ts +0 -42
- package/dist/src/store.js +0 -40
- package/dist/src/types.d.ts +0 -143
- package/dist/src/types.js +0 -1
- package/dist/src/utils.d.ts +0 -72
- package/dist/src/utils.js +0 -76
package/dist/src/impl.d.ts
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import type { FieldPath, FieldPathValue, FieldValues } from "./path";
|
|
2
|
-
import { getStableKeys, setExternalKeyOrder } from "./stable_keys";
|
|
3
|
-
export { getNestedValue, getSnapshot, getStableKeys, isClass, isEqual, isRecord, joinPath, notifyListeners, produce, rename, setExternalKeyOrder, setLeaf, setNestedValue, subscribe, testReset, updateSnapshot, useCompute, useDebounce, useObject, };
|
|
4
|
-
declare function testReset(): void;
|
|
5
|
-
declare function isClass(value: unknown): boolean;
|
|
6
|
-
declare function isRecord(value: unknown): boolean;
|
|
7
|
-
/** Compare two values for equality
|
|
8
|
-
* @description
|
|
9
|
-
* - react-fast-compare for non-class instances
|
|
10
|
-
* - reference equality for class instances
|
|
11
|
-
* @param a - The first value to compare
|
|
12
|
-
* @param b - The second value to compare
|
|
13
|
-
* @returns True if the values are equal, false otherwise
|
|
14
|
-
*/
|
|
15
|
-
declare function isEqual(a: unknown, b: unknown): boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Joins a namespace and path into a full key string.
|
|
18
|
-
*
|
|
19
|
-
* @param namespace - The store namespace (root key)
|
|
20
|
-
* @param path - Optional dot-separated path within the namespace
|
|
21
|
-
* @returns Combined key string (e.g., "app.user.name")
|
|
22
|
-
*/
|
|
23
|
-
declare function joinPath(namespace: string, path?: string): string;
|
|
24
|
-
/** Snapshot getter used by React's useSyncExternalStore. */
|
|
25
|
-
declare function getSnapshot(key: string, memoryOnly: boolean): unknown;
|
|
26
|
-
/** Updates the snapshot of a key. */
|
|
27
|
-
declare function updateSnapshot(key: string, value: unknown, memoryOnly: boolean): void;
|
|
28
|
-
/** Get a nested value from an object/array using a dot-separated path. */
|
|
29
|
-
declare function getNestedValue(obj: unknown, path: string): unknown;
|
|
30
|
-
/**
|
|
31
|
-
* Immutably sets or deletes a nested value using a dot-separated path.
|
|
32
|
-
*
|
|
33
|
-
* Creates intermediate objects or arrays as needed based on whether the next
|
|
34
|
-
* path segment is numeric. When value is undefined, the key is deleted from
|
|
35
|
-
* objects or the index is spliced from arrays.
|
|
36
|
-
*
|
|
37
|
-
* @param obj - The root object to update
|
|
38
|
-
* @param path - Dot-separated path to the target location
|
|
39
|
-
* @param value - The value to set, or undefined to delete
|
|
40
|
-
* @returns A new root object with the change applied
|
|
41
|
-
*/
|
|
42
|
-
declare function setNestedValue(obj: unknown, path: string, value: unknown): unknown;
|
|
43
|
-
/**
|
|
44
|
-
* Notifies all relevant listeners when a value changes.
|
|
45
|
-
*
|
|
46
|
-
* Handles three types of listeners:
|
|
47
|
-
* 1. Exact match - listeners subscribed to the exact changed path
|
|
48
|
-
* 2. Root listeners - listeners on the namespace root (for full-store subscriptions)
|
|
49
|
-
* 3. Child listeners - listeners on nested paths that may be affected by the change
|
|
50
|
-
*
|
|
51
|
-
* Child listeners are only notified if their specific value actually changed,
|
|
52
|
-
* determined by deep equality comparison.
|
|
53
|
-
*/
|
|
54
|
-
declare function notifyListeners(key: string, oldValue: unknown, newValue: unknown, { skipRoot, skipChildren, forceNotify }?: {
|
|
55
|
-
skipRoot?: boolean | undefined;
|
|
56
|
-
skipChildren?: boolean | undefined;
|
|
57
|
-
forceNotify?: boolean | undefined;
|
|
58
|
-
}): void;
|
|
59
|
-
/**
|
|
60
|
-
* Subscribes to changes for a specific key.
|
|
61
|
-
*
|
|
62
|
-
* @param key - The full key path to subscribe to
|
|
63
|
-
* @param listener - Callback invoked when the value changes
|
|
64
|
-
* @returns An unsubscribe function to remove the listener
|
|
65
|
-
*/
|
|
66
|
-
declare function subscribe(key: string, listener: () => void): () => void;
|
|
67
|
-
declare function useCompute<T = unknown, R = unknown>(namespace: string, path: string | undefined, fn: (value: T) => R, deps?: readonly unknown[], memoryOnly?: boolean): R;
|
|
68
|
-
/**
|
|
69
|
-
* Core mutation function that updates the store and notifies listeners.
|
|
70
|
-
*
|
|
71
|
-
* Handles both setting and deleting values, with optimizations to skip
|
|
72
|
-
* unnecessary updates when the value hasn't changed.
|
|
73
|
-
*
|
|
74
|
-
* @param key - The full key path to update
|
|
75
|
-
* @param value - The new value, or undefined to delete
|
|
76
|
-
* @param skipUpdate - When true, skips notifying listeners
|
|
77
|
-
* @param memoryOnly - When true, skips localStorage persistence
|
|
78
|
-
*/
|
|
79
|
-
declare function produce(key: string, value: unknown, skipUpdate: boolean, memoryOnly: boolean): void;
|
|
80
|
-
/**
|
|
81
|
-
* Renames a key in an object.
|
|
82
|
-
*
|
|
83
|
-
* It trigger updates to
|
|
84
|
-
*
|
|
85
|
-
* - listeners to `path` (key is updated)
|
|
86
|
-
* - listeners to `path.oldKey` (deleted)
|
|
87
|
-
* - listeners to `path.newKey` (created)
|
|
88
|
-
*
|
|
89
|
-
* @param path - The full key path to rename
|
|
90
|
-
* @param oldKey - The old key to rename
|
|
91
|
-
* @param newKey - The new key to rename to
|
|
92
|
-
*/
|
|
93
|
-
declare function rename(path: string, oldKey: string, newKey: string, memoryOnly: boolean): void;
|
|
94
|
-
/**
|
|
95
|
-
* React hook that subscribes to and reads a value at a path.
|
|
96
|
-
*
|
|
97
|
-
* Uses useSyncExternalStore for tear-free reads and automatic re-rendering
|
|
98
|
-
* when the subscribed value changes.
|
|
99
|
-
*
|
|
100
|
-
* @param key - The namespace or full key
|
|
101
|
-
* @param path - Optional path within the namespace
|
|
102
|
-
* @param memoryOnly - When true, skips localStorage persistence
|
|
103
|
-
* @returns The current value at the path, or undefined if not set
|
|
104
|
-
*/
|
|
105
|
-
declare function useObject<T extends FieldValues, P extends FieldPath<T>>(key: string, path: P | undefined, memoryOnly: boolean): FieldPathValue<T, P> | undefined;
|
|
106
|
-
/**
|
|
107
|
-
* React hook that subscribes to a value with debounced updates.
|
|
108
|
-
*
|
|
109
|
-
* The returned value only updates after the specified delay has passed
|
|
110
|
-
* since the last change, useful for expensive operations like search.
|
|
111
|
-
*
|
|
112
|
-
* @param key - The namespace or full key
|
|
113
|
-
* @param path - Path within the namespace
|
|
114
|
-
* @param delay - Debounce delay in milliseconds
|
|
115
|
-
* @param memoryOnly - When true, skips localStorage persistence
|
|
116
|
-
* @returns The debounced value at the path
|
|
117
|
-
*/
|
|
118
|
-
declare function useDebounce<T extends FieldValues, P extends FieldPath<T>>(key: string, path: P, delay: number, memoryOnly: boolean): FieldPathValue<T, P> | undefined;
|
|
119
|
-
/**
|
|
120
|
-
* Sets a value at a specific path within a namespace.
|
|
121
|
-
*
|
|
122
|
-
* @param key - The namespace
|
|
123
|
-
* @param path - Path within the namespace
|
|
124
|
-
* @param value - The value to set, or undefined to delete
|
|
125
|
-
* @param skipUpdate - When true, skips notifying listeners
|
|
126
|
-
* @param memoryOnly - When true, skips localStorage persistence
|
|
127
|
-
*/
|
|
128
|
-
declare function setLeaf<T extends FieldValues, P extends FieldPath<T>>(key: string, path: P, value: FieldPathValue<T, P> | undefined, skipUpdate?: boolean, memoryOnly?: boolean): void;
|