@buoy-gg/zustand 7.0.30 → 7.0.31
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/lib/commonjs/zustand/components/ZustandActionButton.js +3 -1
- package/lib/commonjs/zustand/components/ZustandDetailViewToggle.js +7 -0
- package/lib/commonjs/zustand/components/ZustandEventFilterView.js +19 -4
- package/lib/commonjs/zustand/components/ZustandModal.js +173 -32
- package/lib/commonjs/zustand/components/ZustandStateChangeItem.js +36 -37
- package/lib/commonjs/zustand/components/ZustandStateDetailContent.js +22 -5
- package/lib/commonjs/zustand/components/ZustandStateInfoView.js +30 -7
- package/lib/commonjs/zustand/components/ZustandStoreBrowser.js +23 -126
- package/lib/commonjs/zustand/components/ZustandStoreDetailContent.js +471 -0
- package/lib/commonjs/zustand/components/ZustandStoreEditorScreen.js +393 -0
- package/lib/commonjs/zustand/sync/zustandSyncAdapter.js +54 -0
- package/lib/commonjs/zustand/utils/buoyZustandMiddleware.js +71 -7
- package/lib/commonjs/zustand/utils/editableState.js +139 -0
- package/lib/commonjs/zustand/utils/snapshotProvider.js +10 -37
- package/lib/commonjs/zustand/utils/testIDs.js +82 -0
- package/lib/commonjs/zustand/utils/zustandStateStore.js +16 -3
- package/lib/module/zustand/components/ZustandActionButton.js +3 -1
- package/lib/module/zustand/components/ZustandDetailViewToggle.js +7 -0
- package/lib/module/zustand/components/ZustandEventFilterView.js +19 -4
- package/lib/module/zustand/components/ZustandModal.js +173 -32
- package/lib/module/zustand/components/ZustandStateChangeItem.js +36 -37
- package/lib/module/zustand/components/ZustandStateDetailContent.js +22 -5
- package/lib/module/zustand/components/ZustandStateInfoView.js +30 -7
- package/lib/module/zustand/components/ZustandStoreBrowser.js +26 -129
- package/lib/module/zustand/components/ZustandStoreDetailContent.js +469 -0
- package/lib/module/zustand/components/ZustandStoreEditorScreen.js +389 -0
- package/lib/module/zustand/sync/zustandSyncAdapter.js +54 -0
- package/lib/module/zustand/utils/buoyZustandMiddleware.js +71 -7
- package/lib/module/zustand/utils/editableState.js +131 -0
- package/lib/module/zustand/utils/snapshotProvider.js +4 -30
- package/lib/module/zustand/utils/testIDs.js +74 -0
- package/lib/module/zustand/utils/zustandStateStore.js +16 -3
- package/lib/typescript/zustand/components/ZustandActionButton.d.ts +2 -1
- package/lib/typescript/zustand/components/ZustandActionButton.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandDetailViewToggle.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandEventFilterView.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandModal.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandStateChangeItem.d.ts +6 -0
- package/lib/typescript/zustand/components/ZustandStateChangeItem.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandStateDetailContent.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandStateInfoView.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandStoreBrowser.d.ts +7 -9
- package/lib/typescript/zustand/components/ZustandStoreBrowser.d.ts.map +1 -1
- package/lib/typescript/zustand/components/ZustandStoreDetailContent.d.ts +40 -0
- package/lib/typescript/zustand/components/ZustandStoreDetailContent.d.ts.map +1 -0
- package/lib/typescript/zustand/components/ZustandStoreEditorScreen.d.ts +42 -0
- package/lib/typescript/zustand/components/ZustandStoreEditorScreen.d.ts.map +1 -0
- package/lib/typescript/zustand/sync/zustandSyncAdapter.d.ts +35 -0
- package/lib/typescript/zustand/sync/zustandSyncAdapter.d.ts.map +1 -1
- package/lib/typescript/zustand/types/index.d.ts +13 -0
- package/lib/typescript/zustand/types/index.d.ts.map +1 -1
- package/lib/typescript/zustand/utils/buoyZustandMiddleware.d.ts +31 -3
- package/lib/typescript/zustand/utils/buoyZustandMiddleware.d.ts.map +1 -1
- package/lib/typescript/zustand/utils/editableState.d.ts +65 -0
- package/lib/typescript/zustand/utils/editableState.d.ts.map +1 -0
- package/lib/typescript/zustand/utils/testIDs.d.ts +54 -0
- package/lib/typescript/zustand/utils/testIDs.d.ts.map +1 -0
- package/lib/typescript/zustand/utils/zustandStateStore.d.ts +1 -0
- package/lib/typescript/zustand/utils/zustandStateStore.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What of a zustand store's state can be EDITED, and how an edit is written.
|
|
5
|
+
*
|
|
6
|
+
* The two zustand facts every rule here follows from:
|
|
7
|
+
*
|
|
8
|
+
* 1. Stores conventionally keep their action functions IN state
|
|
9
|
+
* (`increment: () => …`). Functions can't be typed into a tree editor and
|
|
10
|
+
* don't survive serialization, so the editor works on a function-free view
|
|
11
|
+
* of state.
|
|
12
|
+
* 2. `setState` is either a TOP-LEVEL SHALLOW MERGE (`Object.assign({}, state,
|
|
13
|
+
* partial)`) or a full replace that deletes every key not present — actions
|
|
14
|
+
* included. So the editor writes merge-only, always: every edit, however
|
|
15
|
+
* deep, is expressed as "replace the top-level key(s) that contain it"
|
|
16
|
+
* ({@link computeMergePartial}), and the two edits a merge cannot express —
|
|
17
|
+
* removing or renaming a top-level key — are refused rather than silently
|
|
18
|
+
* not happening.
|
|
19
|
+
*
|
|
20
|
+
* `stripFunctions` lives here (the Time Machine snapshot provider imports it)
|
|
21
|
+
* because capture and editing need the identical answer to "what is this
|
|
22
|
+
* store's data".
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** Bounds every recursive walk over store state. */
|
|
26
|
+
export const STRIP_MAX_DEPTH = 8;
|
|
27
|
+
export function isPlainObjectLike(v) {
|
|
28
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Clone `value` without functions, recording their paths. */
|
|
32
|
+
export function stripFunctions(value, path, fnPaths, seen, depth) {
|
|
33
|
+
if (typeof value === "function") {
|
|
34
|
+
fnPaths.push(path);
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
if (typeof value !== "object" || value === null || depth >= STRIP_MAX_DEPTH) {
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
if (seen.has(value)) return undefined; // cycle — drop the back-reference
|
|
41
|
+
seen.add(value);
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
return value.map((item, i) => typeof item === "function" ? (fnPaths.push(`${path}[${i}]`), null) : stripFunctions(item, `${path}[${i}]`, fnPaths, seen, depth + 1));
|
|
44
|
+
}
|
|
45
|
+
if (!isPlainObjectLike(value)) return value; // Date/Map/Set/etc. — superjson handles
|
|
46
|
+
const out = {};
|
|
47
|
+
for (const [k, v] of Object.entries(value)) {
|
|
48
|
+
if (typeof v === "function") {
|
|
49
|
+
fnPaths.push(path ? `${path}.${k}` : k);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
out[k] = stripFunctions(v, path ? `${path}.${k}` : k, fnPaths, seen, depth + 1);
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The editor's view of one store's state, with the reasons it may refuse.
|
|
58
|
+
*
|
|
59
|
+
* - A remote mirror that hasn't hydrated yet holds a marker, not state — the
|
|
60
|
+
* real value is one `getStoreState` round trip away, so "wait" rather than
|
|
61
|
+
* "can't".
|
|
62
|
+
* - Non-object state (`create(() => 5)`) has no top-level keys, so a merge
|
|
63
|
+
* write cannot address any part of it. Editing it would require a replace,
|
|
64
|
+
* which is the destructive path this editor exists to avoid.
|
|
65
|
+
* - A function nested BELOW the top level (rare — the convention keeps actions
|
|
66
|
+
* at the top) sits inside the very key an edit would rewrite, and a merge
|
|
67
|
+
* write of that key would silently drop it. Refusing the whole store is
|
|
68
|
+
* blunt but honest; per-key locks can come later if this ever bites.
|
|
69
|
+
*/
|
|
70
|
+
export function editableStateOf(state) {
|
|
71
|
+
if (isPlainObjectLike(state) && state.__buoyStateOnDevice === true) {
|
|
72
|
+
return {
|
|
73
|
+
data: null,
|
|
74
|
+
fnPaths: [],
|
|
75
|
+
blockedReason: "Store state hasn't synced from the device yet."
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (!isPlainObjectLike(state)) {
|
|
79
|
+
return {
|
|
80
|
+
data: null,
|
|
81
|
+
fnPaths: [],
|
|
82
|
+
blockedReason: "Only stores whose state is a plain object can be edited — " + "a merge write has nothing to address in " + (Array.isArray(state) ? "an array" : `a ${typeof state}`) + "."
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const fnPaths = [];
|
|
86
|
+
const data = stripFunctions(state, "", fnPaths, new WeakSet(), 0);
|
|
87
|
+
const nested = fnPaths.filter(p => p.includes(".") || p.includes("["));
|
|
88
|
+
if (nested.length > 0) {
|
|
89
|
+
return {
|
|
90
|
+
data: null,
|
|
91
|
+
fnPaths,
|
|
92
|
+
blockedReason: `State keeps a function inside "${nested[0]}" — a merge write of ` + "that key would drop it, so this store can't be edited here."
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
data,
|
|
97
|
+
fnPaths,
|
|
98
|
+
blockedReason: null
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Diff an edited draft against the state it was seeded from, as a `setState`
|
|
104
|
+
* MERGE partial: only the top-level keys whose contents changed.
|
|
105
|
+
*
|
|
106
|
+
* Diffed against the SEED, not the live state at save time, on purpose — the
|
|
107
|
+
* partial then carries exactly what the user changed, so a key the app wrote
|
|
108
|
+
* while the editor was open and the user never touched keeps the app's value
|
|
109
|
+
* (per-key last-write-wins, the same contract the draft's own dirtiness uses).
|
|
110
|
+
*
|
|
111
|
+
* Throws on the two edits a merge cannot express, naming the key: a draft
|
|
112
|
+
* that dropped a top-level key (which is also what a raw-JSON rename produces
|
|
113
|
+
* — the old key dropped, a new one added), because `setState(partial, false)`
|
|
114
|
+
* would leave it exactly as it was while the editor showed it gone.
|
|
115
|
+
*/
|
|
116
|
+
export function computeMergePartial(seed, draft) {
|
|
117
|
+
if (!isPlainObjectLike(draft)) {
|
|
118
|
+
throw new Error("The store's state must stay an object.");
|
|
119
|
+
}
|
|
120
|
+
const dropped = Object.keys(seed).filter(k => !(k in draft));
|
|
121
|
+
if (dropped.length > 0) {
|
|
122
|
+
throw new Error(`Can't remove top-level ${dropped.length === 1 ? "key" : "keys"} ` + `${dropped.map(k => `"${k}"`).join(", ")} — zustand merge writes ` + "can't delete. Edit the value instead.");
|
|
123
|
+
}
|
|
124
|
+
const partial = {};
|
|
125
|
+
for (const key of Object.keys(draft)) {
|
|
126
|
+
if (!(key in seed) || JSON.stringify(draft[key]) !== JSON.stringify(seed[key])) {
|
|
127
|
+
partial[key] = draft[key];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return partial;
|
|
131
|
+
}
|
|
@@ -16,37 +16,11 @@
|
|
|
16
16
|
import { registerStateSnapshotProvider } from "@buoy-gg/shared-ui";
|
|
17
17
|
import { boundedDeepEqual, jsonLikelyLargerThan } from "@buoy-gg/shared-ui/dataViewer";
|
|
18
18
|
import { zustandStateStore } from "./zustandStateStore";
|
|
19
|
-
|
|
20
|
-
function isPlainObjectLike(v) {
|
|
21
|
-
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** Clone `value` without functions, recording their paths. */
|
|
25
|
-
function stripFunctions(value, path, fnPaths, seen, depth) {
|
|
26
|
-
if (typeof value === "function") {
|
|
27
|
-
fnPaths.push(path);
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
if (typeof value !== "object" || value === null || depth >= MAX_DEPTH) {
|
|
31
|
-
return value;
|
|
32
|
-
}
|
|
33
|
-
if (seen.has(value)) return undefined; // cycle — drop the back-reference
|
|
34
|
-
seen.add(value);
|
|
35
|
-
if (Array.isArray(value)) {
|
|
36
|
-
return value.map((item, i) => typeof item === "function" ? (fnPaths.push(`${path}[${i}]`), null) : stripFunctions(item, `${path}[${i}]`, fnPaths, seen, depth + 1));
|
|
37
|
-
}
|
|
38
|
-
if (!isPlainObjectLike(value)) return value; // Date/Map/Set/etc. — superjson handles
|
|
39
|
-
const out = {};
|
|
40
|
-
for (const [k, v] of Object.entries(value)) {
|
|
41
|
-
if (typeof v === "function") {
|
|
42
|
-
fnPaths.push(path ? `${path}.${k}` : k);
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
out[k] = stripFunctions(v, path ? `${path}.${k}` : k, fnPaths, seen, depth + 1);
|
|
46
|
-
}
|
|
47
|
-
return out;
|
|
48
|
-
}
|
|
19
|
+
import { isPlainObjectLike, stripFunctions, STRIP_MAX_DEPTH } from "./editableState";
|
|
49
20
|
|
|
21
|
+
// The function-stripping walk is shared with the store editor (editableState
|
|
22
|
+
// .ts) — capture and editing must agree on what a store's "data" is.
|
|
23
|
+
const MAX_DEPTH = STRIP_MAX_DEPTH;
|
|
50
24
|
/**
|
|
51
25
|
* Copy every function-valued property from the LIVE state onto the restored
|
|
52
26
|
* snapshot (creating containers as needed), so store actions keep working
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Zustand tool test handles.
|
|
5
|
+
*
|
|
6
|
+
* Every tappable and every value the e2e suite reads back is addressed
|
|
7
|
+
* `buoy-zustand-<thing>`. Two rules in here need explaining.
|
|
8
|
+
*
|
|
9
|
+
* **A change row's handle carries an ORDINAL, and it counts per STORE.** The
|
|
10
|
+
* Events tool can address a row by what it is about, because an event is a
|
|
11
|
+
* thing that happened to a named subject — one key, one URL, one atom. A
|
|
12
|
+
* zustand state change is not: a store that a screen writes to fifty times
|
|
13
|
+
* produces fifty separate, equally real rows. Addressing them by store name
|
|
14
|
+
* alone would give fifty views one handle, and Detox fails a *matcher* that
|
|
15
|
+
* hits more than one element — so a suite would break on `toExist()`, before
|
|
16
|
+
* any assertion, with an error that says nothing about duplicate changes.
|
|
17
|
+
*
|
|
18
|
+
* So the handle is `buoy-zustand-row-<slug(storeName)>-<n>`, where n counts
|
|
19
|
+
* back from the newest row of that store (1 = newest). Deliberately relative:
|
|
20
|
+
* a state change has no identity a host could know in advance — `id` is a
|
|
21
|
+
* timestamp plus a per-process counter whose value depends on how many
|
|
22
|
+
* changes the app happened to make before the test looked. What a test CAN
|
|
23
|
+
* know is "the set I just fired is the newest change to that store". Read and
|
|
24
|
+
* tap in one beat: a row's ordinal moves the instant another change lands.
|
|
25
|
+
*
|
|
26
|
+
* **A store row's handle does NOT.** A store is registered once under a name
|
|
27
|
+
* that is unique by construction (`zustandStateStore.registerStore` returns
|
|
28
|
+
* early on a name it already holds), so `buoy-zustand-store-<slug(name)>` is
|
|
29
|
+
* as stable as the store itself — and unlike a change, it is a thing the host
|
|
30
|
+
* knows the name of before the app has booted.
|
|
31
|
+
*
|
|
32
|
+
* The suite mirrors these rules in CommonJS (`example-dev-build/utils/
|
|
33
|
+
* zustandBench.js`) and asserts the two agree — Detox runs in Node on the host
|
|
34
|
+
* and cannot import TypeScript.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/** Prefix every handle in this tool shares. */
|
|
38
|
+
export const ZUSTAND_TEST_ID = "buoy-zustand";
|
|
39
|
+
|
|
40
|
+
/** `zbenchWatch` → `zbenchwatch`. Shared with every Buoy tool. */
|
|
41
|
+
export function slugForTestID(value) {
|
|
42
|
+
return String(value ?? "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "unknown";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Handle for one change row: `buoy-zustand-row-zbenchwatch-1`.
|
|
47
|
+
*
|
|
48
|
+
* `ordinal` is 1-based and counts back from the newest row of this store.
|
|
49
|
+
*/
|
|
50
|
+
export function changeRowTestID(storeName, ordinal) {
|
|
51
|
+
return `${ZUSTAND_TEST_ID}-row-${slugForTestID(storeName)}-${ordinal}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Handle for one store row in the browser: `buoy-zustand-store-zbenchwatch`. */
|
|
55
|
+
export function storeRowTestID(storeName) {
|
|
56
|
+
return `${ZUSTAND_TEST_ID}-store-${slugForTestID(storeName)}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Row handle per change id for one rendered list, newest-first.
|
|
61
|
+
*
|
|
62
|
+
* Built once for the whole list rather than per row, because an ordinal is a
|
|
63
|
+
* fact about the list and a row cannot compute its own.
|
|
64
|
+
*/
|
|
65
|
+
export function buildChangeRowTestIDs(changes) {
|
|
66
|
+
const seen = new Map();
|
|
67
|
+
const handles = new Map();
|
|
68
|
+
for (const change of changes) {
|
|
69
|
+
const ordinal = (seen.get(change.storeName) ?? 0) + 1;
|
|
70
|
+
seen.set(change.storeName, ordinal);
|
|
71
|
+
handles.set(change.id, changeRowTestID(change.storeName, ordinal));
|
|
72
|
+
}
|
|
73
|
+
return handles;
|
|
74
|
+
}
|
|
@@ -124,7 +124,14 @@ function formatPartialPreview(partial, maxLength = 40) {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
/**
|
|
127
|
-
* Calculate state diff summary
|
|
127
|
+
* Calculate state diff summary.
|
|
128
|
+
*
|
|
129
|
+
* `changedCount` counts the keys in `changedKeys` and nothing else. The two
|
|
130
|
+
* used to disagree: a state object that was REPLACED without any top-level
|
|
131
|
+
* value moving — which is exactly what zustand's persist middleware does when
|
|
132
|
+
* it rehydrates — reported one changed key and named none, so the row said
|
|
133
|
+
* "1 key changed" and the detail page it opened drew no CHANGED KEYS card at
|
|
134
|
+
* all. `summary` is where a change with no nameable keys is described.
|
|
128
135
|
*/
|
|
129
136
|
function getStateDiffSummary(prevState, nextState) {
|
|
130
137
|
if (prevState === nextState) {
|
|
@@ -138,7 +145,7 @@ function getStateDiffSummary(prevState, nextState) {
|
|
|
138
145
|
return {
|
|
139
146
|
summary: "changed",
|
|
140
147
|
changedKeys: [],
|
|
141
|
-
changedCount:
|
|
148
|
+
changedCount: 0
|
|
142
149
|
};
|
|
143
150
|
}
|
|
144
151
|
const prevKeys = Object.keys(prevState);
|
|
@@ -161,7 +168,7 @@ function getStateDiffSummary(prevState, nextState) {
|
|
|
161
168
|
return {
|
|
162
169
|
summary: "nested change",
|
|
163
170
|
changedKeys: [],
|
|
164
|
-
changedCount:
|
|
171
|
+
changedCount: 0
|
|
165
172
|
};
|
|
166
173
|
}
|
|
167
174
|
return {
|
|
@@ -325,6 +332,11 @@ class ZustandStateStore {
|
|
|
325
332
|
stateChangeCount: store.stateChangeCount,
|
|
326
333
|
isPersisted: store.isPersisted,
|
|
327
334
|
persistName: store.persistName,
|
|
335
|
+
// Persisted is not the same as re-readable: a store registered before
|
|
336
|
+
// its persist middleware attached has a name but no handle. The
|
|
337
|
+
// Storage tool needs the difference to decide between offering "apply"
|
|
338
|
+
// and telling the user to restart.
|
|
339
|
+
canRehydrate: typeof store.rehydrate === "function",
|
|
328
340
|
color: store.color,
|
|
329
341
|
currentState
|
|
330
342
|
};
|
|
@@ -446,6 +458,7 @@ class ZustandStateStore {
|
|
|
446
458
|
stateChangeCount: 0,
|
|
447
459
|
isPersisted: options?.isPersisted ?? false,
|
|
448
460
|
persistName: options?.persistName,
|
|
461
|
+
rehydrate: options?.rehydrate,
|
|
449
462
|
color: getStoreColor(name)
|
|
450
463
|
};
|
|
451
464
|
this.stores.set(name, storeInfo);
|
|
@@ -36,7 +36,8 @@ interface ZustandActionButtonProps {
|
|
|
36
36
|
text: string;
|
|
37
37
|
type: ButtonType;
|
|
38
38
|
disabled?: boolean;
|
|
39
|
+
testID?: string;
|
|
39
40
|
}
|
|
40
|
-
export declare function ZustandActionButton({ onPress, text, type, disabled, }: ZustandActionButtonProps): import("react").JSX.Element;
|
|
41
|
+
export declare function ZustandActionButton({ onPress, text, type, disabled, testID, }: ZustandActionButtonProps): import("react").JSX.Element;
|
|
41
42
|
export {};
|
|
42
43
|
//# sourceMappingURL=ZustandActionButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZustandActionButton.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandActionButton.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;CAyBlB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,aAAa,CAAC;AAEpD,UAAU,wBAAwB;IAChC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ZustandActionButton.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandActionButton.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;CAyBlB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,aAAa,CAAC;AAEpD,UAAU,wBAAwB;IAChC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,QAAgB,EAChB,MAAM,GACP,EAAE,wBAAwB,+BA2C1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZustandDetailViewToggle.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandDetailViewToggle.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAe,MAAM,OAAO,CAAC;AAIpC,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAWhE,UAAU,4BAA4B;IACpC,UAAU,EAAE,qBAAqB,CAAC;IAClC,YAAY,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACpD,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AA0BD,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"ZustandDetailViewToggle.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandDetailViewToggle.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAe,MAAM,OAAO,CAAC;AAIpC,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAWhE,UAAU,4BAA4B;IACpC,UAAU,EAAE,qBAAqB,CAAC;IAClC,YAAY,EAAE,CAAC,IAAI,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACpD,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AA0BD,eAAO,MAAM,uBAAuB,0DAqElC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZustandEventFilterView.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandEventFilterView.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ZustandEventFilterView.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandEventFilterView.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAIjD,UAAU,2BAA2B;IACnC,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC7B,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B;AAuBD,wBAAgB,sBAAsB,CAAC,EACrC,eAAe,EACf,eAAe,EACf,YAAY,EACZ,MAAM,GACP,EAAE,2BAA2B,+BAmM7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZustandModal.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandModal.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"ZustandModal.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandModal.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA6CH,OAAO,KAAK,EAAE,iBAAiB,EAAsB,MAAM,UAAU,CAAC;AAkCtE,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,OAAO,EACP,MAAM,EACN,UAAU,EACV,2BAAmC,EACnC,MAAc,EACd,aAAqB,EACrB,UAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,aAAa,GACd,EAAE,iBAAiB,sCAyuBnB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,KAAK,GAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAM,+BAGtE"}
|
|
@@ -7,6 +7,12 @@ import type { ZustandStateChange } from "../types";
|
|
|
7
7
|
interface ZustandStateChangeItemProps {
|
|
8
8
|
change: ZustandStateChange;
|
|
9
9
|
onPress: (change: ZustandStateChange) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Row handle, built by the LIST (see ../utils/testIDs.ts). A row cannot
|
|
12
|
+
* compute its own: the ordinal it carries is a fact about the list around
|
|
13
|
+
* it, not about the change.
|
|
14
|
+
*/
|
|
15
|
+
testID?: string;
|
|
10
16
|
}
|
|
11
17
|
export declare const ZustandStateChangeItem: import("react").NamedExoticComponent<ZustandStateChangeItemProps>;
|
|
12
18
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZustandStateChangeItem.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandStateChangeItem.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,kBAAkB,EAAuB,MAAM,UAAU,CAAC;AAGxE,UAAU,2BAA2B;IACnC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,OAAO,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"ZustandStateChangeItem.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandStateChangeItem.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,kBAAkB,EAAuB,MAAM,UAAU,CAAC;AAGxE,UAAU,2BAA2B;IACnC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,OAAO,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC9C;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA2FD,eAAO,MAAM,sBAAsB,mEA0DjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZustandStateDetailContent.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandStateDetailContent.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAiBH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"ZustandStateDetailContent.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandStateDetailContent.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAiBH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,2BAA2B,CAAC;AAMnC,UAAU,8BAA8B;IACtC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,0EAA0E;IAC1E,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACrC;AAyCD,wBAAgB,yBAAyB,CAAC,EACxC,MAAM,EACN,OAAO,EACP,aAAa,EACb,aAAa,EACb,qBAA6B,EAC7B,WAAsB,GACvB,EAAE,8BAA8B,+BAmNhC;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,MAAM,EACN,OAAO,EACP,aAAa,EACb,aAAa,GACd,EAAE;IACD,MAAM,EAAE,kBAAkB,CAAC;IAC3B,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,sCAmBA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZustandStateInfoView.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandStateInfoView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAiD,MAAM,OAAO,CAAC;AAiBtE,OAAO,KAAK,EAAE,kBAAkB,EAAuB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ZustandStateInfoView.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandStateInfoView.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAiD,MAAM,OAAO,CAAC;AAiBtE,OAAO,KAAK,EAAE,kBAAkB,EAAuB,MAAM,UAAU,CAAC;AAKxE,UAAU,yBAAyB;IACjC,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAwGD,eAAO,MAAM,oBAAoB,uDAuQ/B,CAAC"}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ZustandStoreBrowser
|
|
3
3
|
*
|
|
4
|
-
* Browse tab —
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* via the shared DataViewer component.
|
|
4
|
+
* Browse tab — lists all registered Zustand stores. Tapping a card opens the
|
|
5
|
+
* store's detail screen (ZustandStoreDetailContent): live state editor on
|
|
6
|
+
* top, store details and the read-only tree below — the React Query
|
|
7
|
+
* interaction, replacing the old expand-in-place card.
|
|
9
8
|
*/
|
|
10
9
|
import type { ZustandStoreInfo } from "../types";
|
|
11
10
|
interface ZustandStoreBrowserProps {
|
|
12
11
|
stores: ZustandStoreInfo[];
|
|
13
12
|
searchQuery: string;
|
|
14
|
-
onViewHistory: (storeName: string) => void;
|
|
15
13
|
/**
|
|
16
14
|
* True while we're still waiting for the device's first stores snapshot.
|
|
17
15
|
* Lets the browser show a loading state instead of the "no stores"
|
|
@@ -19,9 +17,9 @@ interface ZustandStoreBrowserProps {
|
|
|
19
17
|
* watch handshake).
|
|
20
18
|
*/
|
|
21
19
|
isLoading?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
|
|
20
|
+
/** Open a store's detail screen. The modal owns that view. */
|
|
21
|
+
onOpenStore: (storeName: string) => void;
|
|
24
22
|
}
|
|
25
|
-
export declare function ZustandStoreBrowser({ stores, searchQuery,
|
|
23
|
+
export declare function ZustandStoreBrowser({ stores, searchQuery, isLoading, onOpenStore, }: ZustandStoreBrowserProps): import("react").JSX.Element;
|
|
26
24
|
export {};
|
|
27
25
|
//# sourceMappingURL=ZustandStoreBrowser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZustandStoreBrowser.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandStoreBrowser.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ZustandStoreBrowser.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandStoreBrowser.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAWH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAIjD,UAAU,wBAAwB;IAChC,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8DAA8D;IAC9D,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C;AA4DD,wBAAgB,mBAAmB,CAAC,EAClC,MAAM,EACN,WAAW,EACX,SAAiB,EACjB,WAAW,GACZ,EAAE,wBAAwB,+BA6F1B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One store, on a screen of its own — the React Query detail-screen shape
|
|
3
|
+
* pointed at a live zustand store.
|
|
4
|
+
*
|
|
5
|
+
* Tapping a store card opens this instead of expanding in place. Top to
|
|
6
|
+
* bottom, mirroring RQ's `DataEditorMode`:
|
|
7
|
+
*
|
|
8
|
+
* 1. STATE EDITOR — the shared LiveExplorer. No draft, no Save: an edit
|
|
9
|
+
* writes into the live store as you make it and the app reacts
|
|
10
|
+
* immediately. Typing commits on a short debounce (~300ms, flushed on
|
|
11
|
+
* blur) so a word is one recorded change, not one per keystroke —
|
|
12
|
+
* zustand writes land in the change log and count against the free
|
|
13
|
+
* tier's cap, which is the one way this tool differs from RQ's
|
|
14
|
+
* unlogged cache writes.
|
|
15
|
+
* 2. STORE DETAILS — what the expanded card used to say: backing,
|
|
16
|
+
* change count (with the road to history), the store's actions.
|
|
17
|
+
* 3. STATE EXPLORER — the read-only tree of the same state.
|
|
18
|
+
*
|
|
19
|
+
* THE WRITE RULE (unchanged from the previous editor — see editableState.ts):
|
|
20
|
+
* merge-only, always. However deep the edit, it is written as
|
|
21
|
+
* `setState({ [topKey]: rewritten }, false)`, which cannot delete a top-level
|
|
22
|
+
* key and cannot touch the action functions stores keep in state. The
|
|
23
|
+
* explorer's delete affordance is therefore vetoed at depth 1 via
|
|
24
|
+
* `canRemove`, and the Raw escape hatch (whole-state JSON, for the add-key /
|
|
25
|
+
* restructure cases live editing can't express) refuses drops through
|
|
26
|
+
* `computeMergePartial`, naming the key.
|
|
27
|
+
*
|
|
28
|
+
* On a desktop mirror the same writes go over the wire: the mirrored store's
|
|
29
|
+
* `api.setState` forwards to the device's sync adapter (the time-travel
|
|
30
|
+
* path), fire-and-forget, with the next snapshot as confirmation.
|
|
31
|
+
*/
|
|
32
|
+
import type { ZustandStoreInfo } from "../types";
|
|
33
|
+
interface ZustandStoreDetailContentProps {
|
|
34
|
+
store: ZustandStoreInfo;
|
|
35
|
+
/** Open this store's change history (the modal owns that view). */
|
|
36
|
+
onViewHistory: (storeName: string) => void;
|
|
37
|
+
}
|
|
38
|
+
export declare function ZustandStoreDetailContent({ store, onViewHistory, }: ZustandStoreDetailContentProps): import("react").JSX.Element;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=ZustandStoreDetailContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZustandStoreDetailContent.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandStoreDetailContent.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AA2BH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAyBjD,UAAU,8BAA8B;IACtC,KAAK,EAAE,gBAAgB,CAAC;IACxB,mEAAmE;IACnE,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAED,wBAAgB,yBAAyB,CAAC,EACxC,KAAK,EACL,aAAa,GACd,EAAE,8BAA8B,+BAsQhC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editing a store, on a screen of its own — the Storage key editor's shape,
|
|
3
|
+
* pointed at a live zustand store.
|
|
4
|
+
*
|
|
5
|
+
* Same reasoning as storage's editor screen: a tree, six structural actions
|
|
6
|
+
* and a keyboard don't fit inside an expanded card, so the card offers ONE
|
|
7
|
+
* edit button and the work happens here with the whole viewport. The tree,
|
|
8
|
+
* dock, draft and value modal are the shared-ui editor — one implementation,
|
|
9
|
+
* two tools.
|
|
10
|
+
*
|
|
11
|
+
* What is zustand-specific is the WRITE. Storage saves by replacing one key's
|
|
12
|
+
* serialized value; a store has no such luxury — its state holds the app's
|
|
13
|
+
* action functions, and a full `setState(draft, true)` replace would delete
|
|
14
|
+
* them (see `editableState.ts`). So Save diffs the draft against the state it
|
|
15
|
+
* was seeded from and writes ONE top-level merge:
|
|
16
|
+
*
|
|
17
|
+
* store.api.setState(changedTopLevelKeys, false)
|
|
18
|
+
*
|
|
19
|
+
* which by construction cannot remove a key or touch a function. The two
|
|
20
|
+
* edits a merge cannot express — removing or renaming a top-level key — are
|
|
21
|
+
* disabled in the dock (`rootEntriesLocked`) and refused at save if they
|
|
22
|
+
* arrive through the raw-JSON escape hatch.
|
|
23
|
+
*
|
|
24
|
+
* On a desktop mirror the same line goes over the wire: the mirrored store's
|
|
25
|
+
* `api.setState` forwards to the device's sync adapter (the time-travel
|
|
26
|
+
* path). That write has no ack, so a remote save resolves optimistically and
|
|
27
|
+
* the next device snapshot is the confirmation.
|
|
28
|
+
*/
|
|
29
|
+
import type { ZustandStoreInfo } from "../types";
|
|
30
|
+
interface ZustandStoreEditorScreenProps {
|
|
31
|
+
store: ZustandStoreInfo;
|
|
32
|
+
/** Leave the editor. Called only once any unsaved work is resolved. */
|
|
33
|
+
onClose: () => void;
|
|
34
|
+
/**
|
|
35
|
+
* Pad the docked controls past the home indicator. On in a bottom sheet,
|
|
36
|
+
* whose edge is the screen's; off in a floating window, whose isn't.
|
|
37
|
+
*/
|
|
38
|
+
applySafeAreaInset?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export declare function ZustandStoreEditorScreen({ store, onClose, applySafeAreaInset, }: ZustandStoreEditorScreenProps): import("react").JSX.Element;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=ZustandStoreEditorScreen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZustandStoreEditorScreen.d.ts","sourceRoot":"","sources":["../../../../src/zustand/components/ZustandStoreEditorScreen.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AA4BH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAMjD,UAAU,6BAA6B;IACrC,KAAK,EAAE,gBAAgB,CAAC;IACxB,uEAAuE;IACvE,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,wBAAgB,wBAAwB,CAAC,EACvC,KAAK,EACL,OAAO,EACP,kBAAkB,GACnB,EAAE,6BAA6B,+BAsO/B"}
|
|
@@ -41,6 +41,7 @@ export declare const zustandSyncAdapter: {
|
|
|
41
41
|
stateChangeCount: number;
|
|
42
42
|
isPersisted: boolean;
|
|
43
43
|
persistName?: string;
|
|
44
|
+
canRehydrate?: boolean;
|
|
44
45
|
color: string;
|
|
45
46
|
}[];
|
|
46
47
|
};
|
|
@@ -95,12 +96,14 @@ export declare const zustandSyncAdapter: {
|
|
|
95
96
|
changes: number;
|
|
96
97
|
isPersisted: boolean;
|
|
97
98
|
persistName: string | undefined;
|
|
99
|
+
canRehydrate: boolean | undefined;
|
|
98
100
|
} | {
|
|
99
101
|
keys: string[] | undefined;
|
|
100
102
|
name: string;
|
|
101
103
|
changes: number;
|
|
102
104
|
isPersisted: boolean;
|
|
103
105
|
persistName: string | undefined;
|
|
106
|
+
canRehydrate: boolean | undefined;
|
|
104
107
|
})[];
|
|
105
108
|
total: number;
|
|
106
109
|
returned: number;
|
|
@@ -113,6 +116,38 @@ export declare const zustandSyncAdapter: {
|
|
|
113
116
|
ok: boolean;
|
|
114
117
|
error?: undefined;
|
|
115
118
|
};
|
|
119
|
+
/**
|
|
120
|
+
* Re-read a persisted store's saved value and merge it into the live store.
|
|
121
|
+
*
|
|
122
|
+
* This is what makes editing a store's storage key mean anything. The app
|
|
123
|
+
* reads that key once at startup and then holds the state in memory, so an
|
|
124
|
+
* outside write — the Storage tool, a scenario, an agent — changes the disk
|
|
125
|
+
* and nothing else, and the next time the store saves it writes its own
|
|
126
|
+
* copy straight back over the edit.
|
|
127
|
+
*
|
|
128
|
+
* `persist.rehydrate()` is plain zustand, not a devtools hook, so unlike
|
|
129
|
+
* reloading the app this also works in a release build. It merges the saved
|
|
130
|
+
* value OVER current state (zustand's default merge is
|
|
131
|
+
* `{...current, ...persisted}`), so the store's action functions survive,
|
|
132
|
+
* and it does not write back to storage unless a version migration ran —
|
|
133
|
+
* the edit stays exactly as it was typed.
|
|
134
|
+
*
|
|
135
|
+
* Two honest limits, both inherent to persist rather than to this action:
|
|
136
|
+
* a key the store's `partialize` excludes is not in the saved value and so
|
|
137
|
+
* cannot be applied, and because the merge is shallow, DELETING a top-level
|
|
138
|
+
* key from the saved JSON does not remove it from the live store.
|
|
139
|
+
*/
|
|
140
|
+
rehydrate: (params?: unknown) => Promise<{
|
|
141
|
+
ok: boolean;
|
|
142
|
+
error: string;
|
|
143
|
+
storeName?: undefined;
|
|
144
|
+
persistName?: undefined;
|
|
145
|
+
} | {
|
|
146
|
+
ok: boolean;
|
|
147
|
+
storeName: string;
|
|
148
|
+
persistName: string | undefined;
|
|
149
|
+
error?: undefined;
|
|
150
|
+
}>;
|
|
116
151
|
};
|
|
117
152
|
};
|
|
118
153
|
//# sourceMappingURL=zustandSyncAdapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zustandSyncAdapter.d.ts","sourceRoot":"","sources":["../../../../src/zustand/sync/zustandSyncAdapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;EAG1B,CAAC;AAEH,sFAAsF;AACtF,eAAO,MAAM,iBAAiB;;;EAG5B,CAAC;AA2DH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"zustandSyncAdapter.d.ts","sourceRoot":"","sources":["../../../../src/zustand/sync/zustandSyncAdapter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGnD;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;EAG1B,CAAC;AAEH,sFAAsF;AACtF,eAAO,MAAM,iBAAiB;;;EAG5B,CAAC;AA2DH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;0BASP,MAAM,IAAI;;;QAY9B;;;;WAIG;mCACwB,OAAO;;;;;;;;;;;;;;;QAmBlC;;;WAGG;iCACsB,OAAO;;;;;;;;;;;QA2BhC;;;;;WAKG;8BACmB,OAAO;;;;;;;;;;;;;;;;;;;;4BAuBT,OAAO;;;;;;;QAQ3B;;;;;;;;;;;;;;;;;;;;WAoBG;6BACwB,OAAO;;;;;;;;;;;;CAqBrC,CAAC"}
|
|
@@ -40,6 +40,17 @@ export interface ZustandStoreInfo {
|
|
|
40
40
|
stateChangeCount: number;
|
|
41
41
|
isPersisted: boolean;
|
|
42
42
|
persistName?: string;
|
|
43
|
+
/**
|
|
44
|
+
* `persist.rehydrate()` for a persisted store — re-reads the saved value and
|
|
45
|
+
* merges it into the live store.
|
|
46
|
+
*
|
|
47
|
+
* Kept because a store's saved copy is the ONLY thing an outside editor can
|
|
48
|
+
* write, and writing it changes nothing on its own: the app read that key
|
|
49
|
+
* once at startup and has held the state in memory ever since. This is the
|
|
50
|
+
* one call that closes that loop, and unlike reloading the app it is plain
|
|
51
|
+
* zustand API, so it works in a release build too.
|
|
52
|
+
*/
|
|
53
|
+
rehydrate?: () => Promise<void> | void;
|
|
43
54
|
color: string;
|
|
44
55
|
}
|
|
45
56
|
/**
|
|
@@ -51,6 +62,8 @@ export interface ZustandStoreSnapshot {
|
|
|
51
62
|
stateChangeCount: number;
|
|
52
63
|
isPersisted: boolean;
|
|
53
64
|
persistName?: string;
|
|
65
|
+
/** True when Buoy holds a `persist.rehydrate()` handle for this store. */
|
|
66
|
+
canRehydrate?: boolean;
|
|
54
67
|
color: string;
|
|
55
68
|
currentState: unknown;
|
|
56
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/zustand/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAC3B,UAAU,GACV,SAAS,GACT,SAAS,GACT,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IAGjB,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE;QACH,QAAQ,EAAE,MAAM,OAAO,CAAC;QACxB,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC;QAChC,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OA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