@buoy-gg/zustand 7.0.36 → 7.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +27 -5
  2. package/lib/commonjs/index.js +1 -105
  3. package/lib/commonjs/preset.js +1 -102
  4. package/lib/commonjs/zustand/components/ZustandActionButton.js +1 -118
  5. package/lib/commonjs/zustand/components/ZustandDetailViewToggle.js +1 -48
  6. package/lib/commonjs/zustand/components/ZustandEventFilterView.js +1 -43
  7. package/lib/commonjs/zustand/components/ZustandIcon.js +1 -18
  8. package/lib/commonjs/zustand/components/ZustandModal.js +1 -772
  9. package/lib/commonjs/zustand/components/ZustandStateChangeItem.js +1 -117
  10. package/lib/commonjs/zustand/components/ZustandStateDetailContent.js +1 -372
  11. package/lib/commonjs/zustand/components/ZustandStateInfoView.js +1 -488
  12. package/lib/commonjs/zustand/components/ZustandStoreBrowser.js +1 -204
  13. package/lib/commonjs/zustand/components/ZustandStoreDetailContent.js +1 -471
  14. package/lib/commonjs/zustand/components/ZustandStoreEditorScreen.js +1 -393
  15. package/lib/commonjs/zustand/hooks/useZustandStateChanges.js +1 -72
  16. package/lib/commonjs/zustand/sync/zustandSyncAdapter.js +1 -382
  17. package/lib/commonjs/zustand/utils/buoyZustandMiddleware.js +1 -284
  18. package/lib/commonjs/zustand/utils/editableState.js +1 -139
  19. package/lib/commonjs/zustand/utils/snapshotProvider.js +1 -209
  20. package/lib/commonjs/zustand/utils/testIDs.js +1 -82
  21. package/lib/commonjs/zustand/utils/zustandStateStore.js +1 -375
  22. package/lib/module/index.js +1 -90
  23. package/lib/module/preset.js +1 -98
  24. package/lib/module/zustand/components/ZustandActionButton.js +1 -114
  25. package/lib/module/zustand/components/ZustandDetailViewToggle.js +1 -43
  26. package/lib/module/zustand/components/ZustandEventFilterView.js +1 -39
  27. package/lib/module/zustand/components/ZustandIcon.js +1 -11
  28. package/lib/module/zustand/components/ZustandModal.js +1 -767
  29. package/lib/module/zustand/components/ZustandStateChangeItem.js +1 -113
  30. package/lib/module/zustand/components/ZustandStateDetailContent.js +1 -368
  31. package/lib/module/zustand/components/ZustandStateInfoView.js +1 -483
  32. package/lib/module/zustand/components/ZustandStoreBrowser.js +1 -200
  33. package/lib/module/zustand/components/ZustandStoreDetailContent.js +1 -469
  34. package/lib/module/zustand/components/ZustandStoreEditorScreen.js +1 -389
  35. package/lib/module/zustand/hooks/useZustandStateChanges.js +1 -68
  36. package/lib/module/zustand/sync/zustandSyncAdapter.js +1 -380
  37. package/lib/module/zustand/utils/buoyZustandMiddleware.js +1 -278
  38. package/lib/module/zustand/utils/editableState.js +1 -131
  39. package/lib/module/zustand/utils/snapshotProvider.js +1 -209
  40. package/lib/module/zustand/utils/testIDs.js +1 -74
  41. package/lib/module/zustand/utils/zustandStateStore.js +1 -371
  42. package/package.json +4 -4
  43. package/lib/typescript/index.d.ts.map +0 -1
  44. package/lib/typescript/preset.d.ts.map +0 -1
  45. package/lib/typescript/zustand/components/ZustandActionButton.d.ts.map +0 -1
  46. package/lib/typescript/zustand/components/ZustandDetailViewToggle.d.ts.map +0 -1
  47. package/lib/typescript/zustand/components/ZustandEventFilterView.d.ts.map +0 -1
  48. package/lib/typescript/zustand/components/ZustandIcon.d.ts.map +0 -1
  49. package/lib/typescript/zustand/components/ZustandModal.d.ts.map +0 -1
  50. package/lib/typescript/zustand/components/ZustandStateChangeItem.d.ts.map +0 -1
  51. package/lib/typescript/zustand/components/ZustandStateDetailContent.d.ts.map +0 -1
  52. package/lib/typescript/zustand/components/ZustandStateInfoView.d.ts.map +0 -1
  53. package/lib/typescript/zustand/components/ZustandStoreBrowser.d.ts.map +0 -1
  54. package/lib/typescript/zustand/components/ZustandStoreDetailContent.d.ts.map +0 -1
  55. package/lib/typescript/zustand/components/ZustandStoreEditorScreen.d.ts.map +0 -1
  56. package/lib/typescript/zustand/hooks/useZustandStateChanges.d.ts.map +0 -1
  57. package/lib/typescript/zustand/sync/zustandSyncAdapter.d.ts.map +0 -1
  58. package/lib/typescript/zustand/types/index.d.ts.map +0 -1
  59. package/lib/typescript/zustand/utils/buoyZustandMiddleware.d.ts.map +0 -1
  60. package/lib/typescript/zustand/utils/editableState.d.ts.map +0 -1
  61. package/lib/typescript/zustand/utils/snapshotProvider.d.ts.map +0 -1
  62. package/lib/typescript/zustand/utils/testIDs.d.ts.map +0 -1
  63. package/lib/typescript/zustand/utils/zustandStateStore.d.ts.map +0 -1
@@ -1,375 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.zustandStateStore = void 0;
7
- var _sharedUi = require("@buoy-gg/shared-ui");
8
- /**
9
- * Zustand state store - captures and stores Zustand state changes
10
- *
11
- * The generic event-log half (ring buffer, listeners, clear-forwarding for
12
- * the desktop mirror, pause/suppress flags, hydrate-by-id) is the shared
13
- * `ChangeLog`; this file owns the zustand-specific half — the store registry,
14
- * snapshots, mirror rebuild, filters and stats.
15
- */
16
-
17
- // ============================================
18
- // Store Color Palette
19
- // ============================================
20
-
21
- const STORE_COLORS = {
22
- counter: "#10B981",
23
- // emerald
24
- auth: "#8B5CF6",
25
- // purple
26
- user: "#3B82F6",
27
- // blue
28
- cart: "#EC4899",
29
- // pink
30
- app: "#6366F1",
31
- // indigo
32
- ui: "#F59E0B",
33
- // amber
34
- settings: "#14B8A6",
35
- // teal
36
- theme: "#06B6D4",
37
- // cyan
38
- navigation: "#F97316",
39
- // orange
40
- form: "#EF4444" // red
41
- };
42
-
43
- /**
44
- * Get consistent color for a store based on its name
45
- */
46
- function getStoreColor(storeName) {
47
- return (0, _sharedUi.entityColor)(storeName, STORE_COLORS);
48
- }
49
-
50
- /**
51
- * Format payload preview for display
52
- */
53
- function formatPartialPreview(partial, maxLength = 40) {
54
- return (0, _sharedUi.formatValuePreview)(partial, {
55
- maxLength,
56
- undefinedLabel: "",
57
- functionLabel: "(updater fn)"
58
- });
59
- }
60
-
61
- // ============================================
62
- // Zustand State Store
63
- // ============================================
64
-
65
- class ZustandStateStore extends _sharedUi.ChangeLog {
66
- stores = new Map();
67
- storeListeners = new Set();
68
- remoteSetStateHandler = null;
69
-
70
- // ---- State Change Tracking ----
71
-
72
- addStateChange(params) {
73
- if (!this.canRecord()) return;
74
- const {
75
- storeName,
76
- partial,
77
- replace,
78
- prevState,
79
- nextState,
80
- duration,
81
- category,
82
- isPersisted = false
83
- } = params;
84
- const hasStateChange = prevState !== nextState;
85
- // `changedCount` counts the keys in `changedKeys` and nothing else, so the
86
- // row's "N keys changed" and the detail page's CHANGED KEYS card agree —
87
- // including the persist-rehydrate case where the object is replaced
88
- // without any top-level value moving.
89
- const {
90
- summary,
91
- changedKeys,
92
- changedCount
93
- } = (0, _sharedUi.shallowDiffSummary)(prevState, nextState);
94
- const partialPreview = formatPartialPreview(partial);
95
- const isSlowUpdate = (duration ?? 0) > 16;
96
- const resolvedCategory = category ?? (replace ? "replace" : "setState");
97
- const stateChange = {
98
- id: this.nextId(),
99
- storeName,
100
- timestamp: Date.now(),
101
- prevState,
102
- nextState,
103
- partial,
104
- duration,
105
- hasStateChange,
106
- replace,
107
- category: resolvedCategory,
108
- changedKeys,
109
- changedKeysCount: changedCount,
110
- diffSummary: summary,
111
- partialPreview,
112
- isSlowUpdate,
113
- isPersisted
114
- };
115
- this.push(stateChange);
116
-
117
- // Update store change count
118
- const storeInfo = this.stores.get(storeName);
119
- if (storeInfo) {
120
- storeInfo.stateChangeCount++;
121
- }
122
- this.notifyListeners();
123
- }
124
- getStateChanges() {
125
- return this.getAll();
126
- }
127
- getStateChangeById(id) {
128
- return this.getById(id);
129
- }
130
- clearStateChanges() {
131
- // Reset counts
132
- for (const store of this.stores.values()) {
133
- store.stateChangeCount = 0;
134
- }
135
- this.clear();
136
- }
137
-
138
- // ---- Remote Mirror Mode ----
139
-
140
- /**
141
- * Replace the change log without touching the store registry. Used when a
142
- * host keeps real registered stores (JUMP / RESET stay wired) but needs to
143
- * reseed the event list — the docs live tour, or any mirror that already
144
- * called `registerStore`. Does not fire `onClear`. Respects the enabled
145
- * flag so the UI's pause button freezes the reseed.
146
- */
147
- replaceStateChanges(changes) {
148
- if (!this.getEnabled()) return;
149
- for (const store of this.stores.values()) {
150
- store.stateChangeCount = 0;
151
- }
152
- const kept = changes.slice(0, this.max);
153
- for (const change of kept) {
154
- const store = this.stores.get(change.storeName);
155
- if (store) store.stateChangeCount++;
156
- }
157
- this.setItems(kept);
158
- this.notifyStoreListeners();
159
- }
160
-
161
- /**
162
- * Serializable snapshot of the tracked stores (registry metadata plus each
163
- * store's current state). Used by the sync adapter on the device side —
164
- * the live `api` handles can't go over the wire.
165
- */
166
- getStoreSnapshots() {
167
- return Array.from(this.stores.values()).map(store => {
168
- let currentState;
169
- try {
170
- currentState = store.api.getState();
171
- } catch {
172
- currentState = undefined;
173
- }
174
- return {
175
- name: store.name,
176
- stateChangeCount: store.stateChangeCount,
177
- isPersisted: store.isPersisted,
178
- persistName: store.persistName,
179
- // Persisted is not the same as re-readable: a store registered before
180
- // its persist middleware attached has a name but no handle. The
181
- // Storage tool needs the difference to decide between offering "apply"
182
- // and telling the user to restart.
183
- canRehydrate: typeof store.rehydrate === "function",
184
- color: store.color,
185
- currentState
186
- };
187
- });
188
- }
189
-
190
- /**
191
- * Handler invoked when the UI calls setState on a mirrored store (e.g.
192
- * time-travel from the dashboard). Forward it to the synced device.
193
- */
194
- setRemoteSetStateHandler(handler) {
195
- this.remoteSetStateHandler = handler;
196
- }
197
-
198
- /**
199
- * Replace the entire mirror contents from a synced device snapshot. The
200
- * rebuilt registry entries get stub `api` handles: getState() serves the
201
- * snapshotted state, setState() forwards to the remote handler. Respects
202
- * the enabled flag so the UI's pause button freezes the mirror.
203
- */
204
- replaceFromSnapshot(changes, storeSnapshots) {
205
- if (!this.getEnabled()) return;
206
-
207
- // Preserve trees a remote mirror already hydrated — wire-form snapshots
208
- // always carry markers, and a later snapshot must not blank the detail pane.
209
- const hydrated = new Map();
210
- for (const existing of this.items) {
211
- const prev = existing.prevState;
212
- if (!prev || prev.__buoyStateOnDevice !== true) {
213
- hydrated.set(existing.id, existing);
214
- }
215
- }
216
- const merged = changes.slice(0, this.max).map(change => {
217
- const kept = hydrated.get(change.id);
218
- const incoming = change.prevState;
219
- return kept && incoming?.__buoyStateOnDevice === true ? {
220
- ...change,
221
- prevState: kept.prevState,
222
- nextState: kept.nextState,
223
- partial: kept.partial
224
- } : change;
225
- });
226
-
227
- // Preserve currentState a remote mirror already hydrated — oversized
228
- // stores arrive as STATE_ON_DEVICE markers on every snapshot.
229
- const hydratedStores = new Map();
230
- for (const [name, store] of this.stores) {
231
- try {
232
- const state = store.api.getState();
233
- const marker = state;
234
- if (!marker || marker.__buoyStateOnDevice !== true) {
235
- hydratedStores.set(name, state);
236
- }
237
- } catch {
238
- // ignore
239
- }
240
- }
241
- this.stores = new Map(storeSnapshots.map(snapshot => {
242
- const incoming = snapshot.currentState;
243
- const kept = hydratedStores.get(snapshot.name);
244
- const currentState = kept !== undefined && incoming?.__buoyStateOnDevice === true ? kept : snapshot.currentState;
245
- return [snapshot.name, {
246
- name: snapshot.name,
247
- api: {
248
- getState: () => currentState,
249
- setState: (partial, replace) => {
250
- this.remoteSetStateHandler?.(snapshot.name, partial, replace);
251
- },
252
- subscribe: () => () => {}
253
- },
254
- stateChangeCount: snapshot.stateChangeCount,
255
- isPersisted: snapshot.isPersisted,
256
- persistName: snapshot.persistName,
257
- color: snapshot.color
258
- }];
259
- }));
260
- this.setItems(merged);
261
- this.notifyStoreListeners();
262
- }
263
-
264
- /**
265
- * Hydrate one mirrored change with real trees fetched on demand from the
266
- * device via the adapter's `getChangeDetail`. Remote-mirror (desktop) only.
267
- */
268
- hydrateChange(id, patch) {
269
- this.hydrateById(id, patch);
270
- }
271
-
272
- /**
273
- * Hydrate one mirrored store's currentState fetched on demand from the
274
- * device via the adapter's `getStoreState`. Remote-mirror (desktop) only.
275
- */
276
- hydrateStoreState(storeName, currentState) {
277
- const store = this.stores.get(storeName);
278
- if (!store) return;
279
- this.stores.set(storeName, {
280
- ...store,
281
- api: {
282
- ...store.api,
283
- getState: () => currentState
284
- }
285
- });
286
- this.notifyStoreListeners();
287
- }
288
-
289
- // ---- Store Registry ----
290
-
291
- registerStore(name, api, options) {
292
- if (this.stores.has(name)) return;
293
- const storeInfo = {
294
- name,
295
- api,
296
- stateChangeCount: 0,
297
- isPersisted: options?.isPersisted ?? false,
298
- persistName: options?.persistName,
299
- rehydrate: options?.rehydrate,
300
- color: getStoreColor(name)
301
- };
302
- this.stores.set(name, storeInfo);
303
- this.notifyStoreListeners();
304
- }
305
- unregisterStore(name) {
306
- this.stores.delete(name);
307
- this.notifyStoreListeners();
308
- }
309
- getStores() {
310
- return Array.from(this.stores.values());
311
- }
312
- getStore(name) {
313
- return this.stores.get(name);
314
- }
315
- getStoreColor(name) {
316
- return this.stores.get(name)?.color ?? getStoreColor(name);
317
- }
318
-
319
- // ---- Filtering ----
320
-
321
- filterStateChanges(filter) {
322
- let filtered = this.getAll();
323
- if (filter.searchText) {
324
- const search = filter.searchText.toLowerCase();
325
- filtered = filtered.filter(c => c.storeName.toLowerCase().includes(search) || c.partialPreview.toLowerCase().includes(search) || c.changedKeys.some(k => k.toLowerCase().includes(search)));
326
- }
327
- if (filter.storeNames && filter.storeNames.length > 0) {
328
- filtered = filtered.filter(c => filter.storeNames.includes(c.storeName));
329
- }
330
- if (filter.onlyWithChanges) {
331
- filtered = filtered.filter(c => c.hasStateChange);
332
- }
333
- return filtered;
334
- }
335
-
336
- // ---- Stats ----
337
-
338
- getStats() {
339
- const total = this.items.length;
340
- const withChanges = this.items.filter(c => c.hasStateChange).length;
341
- const storeCount = this.stores.size;
342
- const durations = this.items.filter(c => c.duration !== undefined).map(c => c.duration);
343
- const avgDuration = durations.length > 0 ? durations.reduce((sum, d) => sum + d, 0) / durations.length : 0;
344
- return {
345
- totalChanges: total,
346
- changesWithStateChange: withChanges,
347
- changesWithoutStateChange: total - withChanges,
348
- storeCount,
349
- averageDuration: Math.round(avgDuration * 100) / 100
350
- };
351
- }
352
- getUniqueStoreNames() {
353
- return Array.from(this.stores.keys()).sort();
354
- }
355
-
356
- // ---- Enable / Disable ----
357
-
358
- setMaxChanges(max) {
359
- this.setMax(max);
360
- }
361
-
362
- // ---- Subscriptions ----
363
-
364
- subscribeToStores(listener) {
365
- this.storeListeners.add(listener);
366
- return () => {
367
- this.storeListeners.delete(listener);
368
- };
369
- }
370
- notifyStoreListeners() {
371
- const stores = this.getStores();
372
- this.storeListeners.forEach(listener => listener(stores));
373
- }
374
- }
375
- const zustandStateStore = exports.zustandStateStore = new ZustandStateStore();
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.zustandStateStore=void 0;var _sharedUi=require("@buoy-gg/shared-ui");const STORE_COLORS={counter:"#10B981",auth:"#8B5CF6",user:"#3B82F6",cart:"#EC4899",app:"#6366F1",ui:"#F59E0B",settings:"#14B8A6",theme:"#06B6D4",navigation:"#F97316",form:"#EF4444"};function getStoreColor(t){return(0,_sharedUi.entityColor)(t,STORE_COLORS)}function formatPartialPreview(t,e=40){return(0,_sharedUi.formatValuePreview)(t,{maxLength:e,undefinedLabel:"",functionLabel:"(updater fn)"})}class ZustandStateStore extends _sharedUi.ChangeLog{stores=new Map;storeListeners=new Set;remoteSetStateHandler=null;addStateChange(t){if(!this.canRecord())return;const{storeName:e,partial:s,replace:r,prevState:a,nextState:o,duration:n,category:i,isPersisted:h=!1}=t,u=a!==o,{summary:S,changedKeys:c,changedCount:g}=(0,_sharedUi.shallowDiffSummary)(a,o),l=formatPartialPreview(s),d=(n??0)>16,m=i??(r?"replace":"setState"),p={id:this.nextId(),storeName:e,timestamp:Date.now(),prevState:a,nextState:o,partial:s,duration:n,hasStateChange:u,replace:r,category:m,changedKeys:c,changedKeysCount:g,diffSummary:S,partialPreview:l,isSlowUpdate:d,isPersisted:h};this.push(p);const C=this.stores.get(e);C&&C.stateChangeCount++,this.notifyListeners()}getStateChanges(){return this.getAll()}getStateChangeById(t){return this.getById(t)}clearStateChanges(){for(const t of this.stores.values())t.stateChangeCount=0;this.clear(),this.notifyStoreListeners()}replaceStateChanges(t){if(!this.getEnabled())return;for(const t of this.stores.values())t.stateChangeCount=0;const e=t.slice(0,this.max);for(const t of e){const e=this.stores.get(t.storeName);e&&e.stateChangeCount++}this.setItems(e),this.notifyStoreListeners()}getStoreSnapshots(){return Array.from(this.stores.values()).map(t=>{let e;try{e=t.api.getState()}catch{e=void 0}return{name:t.name,stateChangeCount:t.stateChangeCount,isPersisted:t.isPersisted,persistName:t.persistName,canRehydrate:"function"==typeof t.rehydrate,color:t.color,currentState:e}})}setRemoteSetStateHandler(t){this.remoteSetStateHandler=t}replaceFromSnapshot(t,e){if(!this.getEnabled())return;const s=new Map;for(const t of this.items){const e=t.prevState;e&&!0===e.__buoyStateOnDevice||s.set(t.id,t)}const r=t.slice(0,this.max).map(t=>{const e=s.get(t.id),r=t.prevState;return e&&!0===r?.__buoyStateOnDevice?{...t,prevState:e.prevState,nextState:e.nextState,partial:e.partial}:t}),a=new Map;for(const[t,e]of this.stores)try{const s=e.api.getState();s&&!0===s.__buoyStateOnDevice||a.set(t,s)}catch{}this.stores=new Map(e.map(t=>{const e=t.currentState,s=a.get(t.name),r=void 0!==s&&!0===e?.__buoyStateOnDevice?s:t.currentState;return[t.name,{name:t.name,api:{getState:()=>r,setState:(e,s)=>{this.remoteSetStateHandler?.(t.name,e,s)},subscribe:()=>()=>{}},stateChangeCount:t.stateChangeCount,isPersisted:t.isPersisted,persistName:t.persistName,color:t.color}]})),this.setItems(r),this.notifyStoreListeners()}hydrateChange(t,e){this.hydrateById(t,e)}hydrateStoreState(t,e){const s=this.stores.get(t);s&&(this.stores.set(t,{...s,api:{...s.api,getState:()=>e}}),this.notifyStoreListeners())}registerStore(t,e,s){if(this.stores.has(t))return;const r={name:t,api:e,stateChangeCount:0,isPersisted:s?.isPersisted??!1,persistName:s?.persistName,rehydrate:s?.rehydrate,color:getStoreColor(t)};this.stores.set(t,r),this.notifyStoreListeners()}unregisterStore(t){this.stores.delete(t),this.notifyStoreListeners()}getStores(){return Array.from(this.stores.values())}getStore(t){return this.stores.get(t)}getStoreColor(t){return this.stores.get(t)?.color??getStoreColor(t)}filterStateChanges(t){let e=this.getAll();if(t.searchText){const s=t.searchText.toLowerCase();e=e.filter(t=>t.storeName.toLowerCase().includes(s)||t.partialPreview.toLowerCase().includes(s)||t.changedKeys.some(t=>t.toLowerCase().includes(s)))}return t.storeNames&&t.storeNames.length>0&&(e=e.filter(e=>t.storeNames.includes(e.storeName))),t.onlyWithChanges&&(e=e.filter(t=>t.hasStateChange)),e}getStats(){const t=this.items.length,e=this.items.filter(t=>t.hasStateChange).length,s=this.stores.size,r=this.items.filter(t=>void 0!==t.duration).map(t=>t.duration),a=r.length>0?r.reduce((t,e)=>t+e,0)/r.length:0;return{totalChanges:t,changesWithStateChange:e,changesWithoutStateChange:t-e,storeCount:s,averageDuration:Math.round(100*a)/100}}getUniqueStoreNames(){return Array.from(this.stores.keys()).sort()}setMaxChanges(t){this.setMax(t)}subscribeToStores(t){return this.storeListeners.add(t),()=>{this.storeListeners.delete(t)}}notifyStoreListeners(){const t=this.getStores();this.storeListeners.forEach(e=>e(t))}}const zustandStateStore=exports.zustandStateStore=new ZustandStateStore;
@@ -1,90 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * @buoy-gg/zustand
5
- *
6
- * Zustand Store DevTools for React Native
7
- *
8
- * PUBLIC API - Only these exports are supported for external use.
9
- *
10
- * @example Recommended setup (one line, zero store modifications)
11
- * ```tsx
12
- * import { watchStores } from '@buoy-gg/zustand';
13
- * import { useCounterStore } from './stores/counter';
14
- * import { useAuthStore } from './stores/auth';
15
- *
16
- * // One call, anywhere at module scope or in your root layout:
17
- * watchStores({
18
- * counterStore: useCounterStore,
19
- * authStore: useAuthStore,
20
- * });
21
- * ```
22
- *
23
- * @example Advanced: middleware for extra detail (partial + timing)
24
- * ```tsx
25
- * import { create } from 'zustand';
26
- * import { buoyDevTools } from '@buoy-gg/zustand';
27
- *
28
- * const useCounterStore = create(
29
- * buoyDevTools(
30
- * (set) => ({
31
- * count: 0,
32
- * increment: () => set((s) => ({ count: s.count + 1 })),
33
- * }),
34
- * { name: 'counterStore' }
35
- * )
36
- * );
37
- * ```
38
- */
39
-
40
- // Side-effect: registers the Time Machine snapshot provider
41
- import "./zustand/utils/snapshotProvider";
42
-
43
- // =============================================================================
44
- // PRESET (Primary entry point for FloatingDevTools)
45
- // =============================================================================
46
- export { zustandToolPreset, createZustandTool } from "./preset";
47
-
48
- // =============================================================================
49
- // WATCH STORES (Recommended — non-intrusive, subscribe-only)
50
- // =============================================================================
51
- export { watchStores } from "./zustand/utils/buoyZustandMiddleware";
52
-
53
- // =============================================================================
54
- // MIDDLEWARE (Advanced — wraps setState for partial + timing capture)
55
- // =============================================================================
56
- export { buoyDevTools } from "./zustand/utils/buoyZustandMiddleware";
57
-
58
- // =============================================================================
59
- // UTILITIES
60
- // =============================================================================
61
- export { isStoreInstrumented } from "./zustand/utils/buoyZustandMiddleware";
62
-
63
- // =============================================================================
64
- // HOOKS (For consuming Zustand state data)
65
- // =============================================================================
66
- export { useZustandStateChanges } from "./zustand/hooks/useZustandStateChanges";
67
- // =============================================================================
68
- // COMPONENTS (For custom UI implementations)
69
- // =============================================================================
70
- // `ZustandToolView` is the same tool rendered inline (header bar + body + footer)
71
- // instead of inside a JsModal — for hosts that show tools in a panel.
72
- export { ZustandModal, ZustandToolView } from "./zustand/components/ZustandModal";
73
- export { ZustandStateChangeItem } from "./zustand/components/ZustandStateChangeItem";
74
- export { ZustandStateDetailContent, ZustandStateDetailFooter } from "./zustand/components/ZustandStateDetailContent";
75
- export { ZustandIcon, ZUSTAND_ICON_COLOR } from "./zustand/components/ZustandIcon";
76
-
77
- // =============================================================================
78
- // EXTERNAL SYNC (Adapter for @buoy-gg/external-sync's useExternalSync)
79
- // =============================================================================
80
- export { zustandSyncAdapter } from "./zustand/sync/zustandSyncAdapter";
81
-
82
- // =============================================================================
83
- // TYPES
84
- // =============================================================================
85
-
86
- // =============================================================================
87
- // INTERNAL EXPORTS (For @buoy-gg/* packages only - not part of public API)
88
- // =============================================================================
89
- /** @internal */
90
- export { zustandStateStore } from "./zustand/utils/zustandStateStore";
1
+ "use strict";import"./zustand/utils/snapshotProvider";export{zustandToolPreset,createZustandTool}from"./preset";export{watchStores}from"./zustand/utils/buoyZustandMiddleware";export{buoyDevTools}from"./zustand/utils/buoyZustandMiddleware";export{isStoreInstrumented}from"./zustand/utils/buoyZustandMiddleware";export{useZustandStateChanges}from"./zustand/hooks/useZustandStateChanges";export{ZustandModal,ZustandToolView}from"./zustand/components/ZustandModal";export{ZustandStateChangeItem}from"./zustand/components/ZustandStateChangeItem";export{ZustandStateDetailContent,ZustandStateDetailFooter}from"./zustand/components/ZustandStateDetailContent";export{ZustandIcon,ZUSTAND_ICON_COLOR}from"./zustand/components/ZustandIcon";export{zustandSyncAdapter}from"./zustand/sync/zustandSyncAdapter";export{zustandStateStore}from"./zustand/utils/zustandStateStore";
@@ -1,98 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * Pre-configured Zustand DevTools preset for FloatingDevTools
5
- *
6
- * ZERO-CONFIG: This preset is auto-discovered by FloatingDevTools!
7
- * Just install @buoy-gg/zustand and wrap your stores with buoyDevTools().
8
- *
9
- * @example Automatic (recommended)
10
- * ```tsx
11
- * import { create } from 'zustand';
12
- * import { buoyDevTools } from '@buoy-gg/zustand';
13
- *
14
- * const useCounterStore = create(
15
- * buoyDevTools(
16
- * (set) => ({ count: 0, increment: () => set((s) => ({ count: s.count + 1 })) }),
17
- * { name: 'counterStore' }
18
- * )
19
- * );
20
- *
21
- * // The Zustand tool appears automatically in FloatingDevTools!
22
- * <FloatingDevTools />
23
- * ```
24
- *
25
- * @example Manual (only for custom configuration)
26
- * ```tsx
27
- * import { createZustandTool } from '@buoy-gg/zustand';
28
- *
29
- * const customZustandTool = createZustandTool({
30
- * name: "STATE",
31
- * iconColor: "#463B3F",
32
- * });
33
- *
34
- * <FloatingDevTools apps={[customZustandTool]} />
35
- * ```
36
- */
37
-
38
- import { ZustandModal } from "./zustand/components/ZustandModal";
39
- import { ZustandIcon } from "./zustand/components/ZustandIcon";
40
-
41
- /**
42
- * Pre-configured Zustand DevTools preset for FloatingDevTools.
43
- * Includes:
44
- * - Live state change monitoring
45
- * - State inspection (JSON viewer)
46
- * - State diff visualization (tree + split)
47
- * - Filter by store name
48
- * - Changed keys tracking
49
- */
50
- import { jsx as _jsx } from "react/jsx-runtime";
51
- export const zustandToolPreset = {
52
- id: "zustand",
53
- name: "ZUSTAND",
54
- description: "Zustand store & state inspector",
55
- slot: "both",
56
- icon: ({
57
- size
58
- }) => /*#__PURE__*/_jsx(ZustandIcon, {
59
- size: size
60
- }),
61
- component: ZustandModal,
62
- props: {
63
- enableSharedModalDimensions: false
64
- }
65
- };
66
-
67
- /**
68
- * Create a custom Zustand DevTools configuration.
69
- * Use this if you want to override default settings.
70
- *
71
- * @example
72
- * ```tsx
73
- * import { createZustandTool } from '@buoy-gg/zustand';
74
- *
75
- * const myZustandTool = createZustandTool({
76
- * name: "STATE",
77
- * iconColor: "#463B3F",
78
- * });
79
- * ```
80
- */
81
- export function createZustandTool(options) {
82
- return {
83
- id: options?.id || "zustand",
84
- name: options?.name || "ZUSTAND",
85
- description: options?.description || "Zustand store & state inspector",
86
- slot: "both",
87
- icon: ({
88
- size
89
- }) => /*#__PURE__*/_jsx(ZustandIcon, {
90
- size: size,
91
- color: options?.iconColor
92
- }),
93
- component: ZustandModal,
94
- props: {
95
- enableSharedModalDimensions: options?.enableSharedModalDimensions !== undefined ? options.enableSharedModalDimensions : false
96
- }
97
- };
98
- }
1
+ "use strict";import{ZustandModal}from"./zustand/components/ZustandModal";import{ZustandIcon}from"./zustand/components/ZustandIcon";import{jsx as _jsx}from"react/jsx-runtime";export const zustandToolPreset={id:"zustand",name:"ZUSTAND",description:"Zustand store & state inspector",slot:"both",icon:({size:o})=>_jsx(ZustandIcon,{size:o}),component:ZustandModal,props:{enableSharedModalDimensions:!1}};export function createZustandTool(o){return{id:o?.id||"zustand",name:o?.name||"ZUSTAND",description:o?.description||"Zustand store & state inspector",slot:"both",icon:({size:n})=>_jsx(ZustandIcon,{size:n,color:o?.iconColor}),component:ZustandModal,props:{enableSharedModalDimensions:void 0!==o?.enableSharedModalDimensions&&o.enableSharedModalDimensions}}}
@@ -1,114 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * ZustandActionButton
5
- *
6
- * Generic action button for Zustand DevTools footer.
7
- * Mirrors ReduxActionButton.tsx
8
- */
9
-
10
- import { TouchableOpacity, Text, View, StyleSheet } from "react-native";
11
- import { night, monoFont } from "@buoy-gg/shared-ui";
12
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- const buttonConfigs = {
14
- copy: {
15
- color: night.color.accent,
16
- backgroundColor: night.color.accentSoft,
17
- borderColor: night.color.accentBorder,
18
- textColor: night.color.accent
19
- },
20
- reset: {
21
- color: night.color.warning,
22
- backgroundColor: night.color.warningSoft,
23
- borderColor: night.color.warning + "40",
24
- textColor: night.color.warning
25
- },
26
- clear: {
27
- color: night.color.danger,
28
- backgroundColor: night.color.dangerSoft,
29
- borderColor: night.color.danger + "40",
30
- textColor: night.color.danger
31
- },
32
- jump: {
33
- color: night.color.warning,
34
- backgroundColor: night.color.warningSoft,
35
- borderColor: night.color.warning + "40",
36
- textColor: night.color.warning
37
- }
38
- };
39
- export function ZustandActionButton({
40
- onPress,
41
- text,
42
- type,
43
- disabled = false,
44
- testID
45
- }) {
46
- const config = buttonConfigs[type];
47
- return /*#__PURE__*/_jsxs(TouchableOpacity, {
48
- disabled: disabled,
49
- onPress: onPress,
50
- style: [styles.button, {
51
- backgroundColor: disabled ? night.color.textTertiary + "1A" : config.backgroundColor,
52
- borderColor: disabled ? night.color.textTertiary + "33" : config.borderColor,
53
- opacity: disabled ? 0.5 : 1
54
- }],
55
- activeOpacity: 0.7,
56
- testID: testID,
57
- accessibilityRole: "button",
58
- accessibilityLabel: text,
59
- accessibilityState: {
60
- disabled
61
- },
62
- children: [/*#__PURE__*/_jsx(View, {
63
- style: [styles.dot, {
64
- backgroundColor: disabled ? night.color.textTertiary : config.color
65
- }]
66
- }), /*#__PURE__*/_jsx(Text, {
67
- style: [styles.text, {
68
- color: disabled ? night.color.textTertiary : config.textColor
69
- }],
70
- children: text
71
- })]
72
- });
73
- }
74
- const styles = StyleSheet.create({
75
- button: {
76
- flexDirection: "row",
77
- alignItems: "center",
78
- justifyContent: "center",
79
- borderRadius: 6,
80
- borderWidth: 1,
81
- paddingHorizontal: 12,
82
- paddingVertical: 6,
83
- height: 25,
84
- minWidth: 80,
85
- shadowOffset: {
86
- width: 0,
87
- height: 1
88
- },
89
- shadowOpacity: 0.2,
90
- shadowRadius: 2,
91
- elevation: 2
92
- },
93
- dot: {
94
- width: 5,
95
- height: 5,
96
- borderRadius: 3,
97
- marginRight: 6,
98
- shadowColor: night.color.text,
99
- shadowOffset: {
100
- width: 0,
101
- height: 0
102
- },
103
- shadowOpacity: 0.6,
104
- shadowRadius: 2
105
- },
106
- text: {
107
- fontSize: 10,
108
- fontWeight: "600",
109
- letterSpacing: 0.5,
110
- textTransform: "uppercase",
111
- fontFamily: monoFont,
112
- height: 12
113
- }
114
- });
1
+ "use strict";import{TouchableOpacity,Text,View,StyleSheet}from"react-native";import{night,monoFont}from"@buoy-gg/shared-ui";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const buttonConfigs={copy:{color:night.color.accent,backgroundColor:night.color.accentSoft,borderColor:night.color.accentBorder,textColor:night.color.accent},reset:{color:night.color.warning,backgroundColor:night.color.warningSoft,borderColor:night.color.warning+"40",textColor:night.color.warning},clear:{color:night.color.danger,backgroundColor:night.color.dangerSoft,borderColor:night.color.danger+"40",textColor:night.color.danger},jump:{color:night.color.warning,backgroundColor:night.color.warningSoft,borderColor:night.color.warning+"40",textColor:night.color.warning}};export function ZustandActionButton({onPress:o,text:t,type:r,disabled:e=!1,testID:i}){const n=buttonConfigs[r];return _jsxs(TouchableOpacity,{disabled:e,onPress:o,style:[styles.button,{backgroundColor:e?night.color.textTertiary+"1A":n.backgroundColor,borderColor:e?night.color.textTertiary+"33":n.borderColor,opacity:e?.5:1}],activeOpacity:.7,testID:i,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:e},children:[_jsx(View,{style:[styles.dot,{backgroundColor:e?night.color.textTertiary:n.color}]}),_jsx(Text,{style:[styles.text,{color:e?night.color.textTertiary:n.textColor}],children:t})]})}const styles=StyleSheet.create({button:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:6,borderWidth:1,paddingHorizontal:12,paddingVertical:6,height:25,minWidth:80,shadowOffset:{width:0,height:1},shadowOpacity:.2,shadowRadius:2,elevation:2},dot:{width:5,height:5,borderRadius:3,marginRight:6,shadowColor:night.color.text,shadowOffset:{width:0,height:0},shadowOpacity:.6,shadowRadius:2},text:{fontSize:10,fontWeight:"600",letterSpacing:.5,textTransform:"uppercase",fontFamily:monoFont,height:12}});