@buoy-gg/zustand 2.1.11 → 2.1.13

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 (57) hide show
  1. package/LICENSE +58 -0
  2. package/lib/commonjs/index.js +1 -91
  3. package/lib/commonjs/preset.js +1 -102
  4. package/lib/commonjs/zustand/components/ZustandActionButton.js +1 -116
  5. package/lib/commonjs/zustand/components/ZustandDetailViewToggle.js +1 -134
  6. package/lib/commonjs/zustand/components/ZustandEventFilterView.js +1 -291
  7. package/lib/commonjs/zustand/components/ZustandIcon.js +1 -35
  8. package/lib/commonjs/zustand/components/ZustandModal.js +1 -603
  9. package/lib/commonjs/zustand/components/ZustandStateChangeItem.js +1 -165
  10. package/lib/commonjs/zustand/components/ZustandStateDetailContent.js +1 -352
  11. package/lib/commonjs/zustand/components/ZustandStateInfoView.js +1 -508
  12. package/lib/commonjs/zustand/components/ZustandStoreBrowser.js +1 -307
  13. package/lib/commonjs/zustand/components/index.js +1 -73
  14. package/lib/commonjs/zustand/hooks/index.js +1 -12
  15. package/lib/commonjs/zustand/hooks/useZustandStateChanges.js +1 -92
  16. package/lib/commonjs/zustand/index.js +1 -99
  17. package/lib/commonjs/zustand/utils/buoyZustandMiddleware.js +1 -220
  18. package/lib/commonjs/zustand/utils/index.js +1 -31
  19. package/lib/commonjs/zustand/utils/zustandStateStore.js +1 -361
  20. package/lib/module/index.js +1 -80
  21. package/lib/module/preset.js +1 -98
  22. package/lib/module/zustand/components/ZustandActionButton.js +1 -112
  23. package/lib/module/zustand/components/ZustandDetailViewToggle.js +1 -129
  24. package/lib/module/zustand/components/ZustandEventFilterView.js +1 -287
  25. package/lib/module/zustand/components/ZustandIcon.js +1 -32
  26. package/lib/module/zustand/components/ZustandModal.js +1 -599
  27. package/lib/module/zustand/components/ZustandStateChangeItem.js +1 -161
  28. package/lib/module/zustand/components/ZustandStateDetailContent.js +1 -348
  29. package/lib/module/zustand/components/ZustandStateInfoView.js +1 -503
  30. package/lib/module/zustand/components/ZustandStoreBrowser.js +1 -303
  31. package/lib/module/zustand/components/index.js +1 -10
  32. package/lib/module/zustand/hooks/index.js +1 -3
  33. package/lib/module/zustand/hooks/useZustandStateChanges.js +1 -88
  34. package/lib/module/zustand/index.js +1 -12
  35. package/lib/module/zustand/utils/buoyZustandMiddleware.js +1 -214
  36. package/lib/module/zustand/utils/index.js +1 -4
  37. package/lib/module/zustand/utils/zustandStateStore.js +1 -357
  38. package/package.json +10 -10
  39. package/lib/typescript/index.d.ts.map +0 -1
  40. package/lib/typescript/preset.d.ts.map +0 -1
  41. package/lib/typescript/zustand/components/ZustandActionButton.d.ts.map +0 -1
  42. package/lib/typescript/zustand/components/ZustandDetailViewToggle.d.ts.map +0 -1
  43. package/lib/typescript/zustand/components/ZustandEventFilterView.d.ts.map +0 -1
  44. package/lib/typescript/zustand/components/ZustandIcon.d.ts.map +0 -1
  45. package/lib/typescript/zustand/components/ZustandModal.d.ts.map +0 -1
  46. package/lib/typescript/zustand/components/ZustandStateChangeItem.d.ts.map +0 -1
  47. package/lib/typescript/zustand/components/ZustandStateDetailContent.d.ts.map +0 -1
  48. package/lib/typescript/zustand/components/ZustandStateInfoView.d.ts.map +0 -1
  49. package/lib/typescript/zustand/components/ZustandStoreBrowser.d.ts.map +0 -1
  50. package/lib/typescript/zustand/components/index.d.ts.map +0 -1
  51. package/lib/typescript/zustand/hooks/index.d.ts.map +0 -1
  52. package/lib/typescript/zustand/hooks/useZustandStateChanges.d.ts.map +0 -1
  53. package/lib/typescript/zustand/index.d.ts.map +0 -1
  54. package/lib/typescript/zustand/types/index.d.ts.map +0 -1
  55. package/lib/typescript/zustand/utils/buoyZustandMiddleware.d.ts.map +0 -1
  56. package/lib/typescript/zustand/utils/index.d.ts.map +0 -1
  57. package/lib/typescript/zustand/utils/zustandStateStore.d.ts.map +0 -1
@@ -1,508 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ZustandStateInfoView = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _reactNative = require("react-native");
9
- var _sharedUi = require("@buoy-gg/shared-ui");
10
- var _license = require("@buoy-gg/license");
11
- var _dataViewer = require("@buoy-gg/shared-ui/dataViewer");
12
- var _ZustandActionButton = require("./ZustandActionButton");
13
- var _zustandStateStore = require("../utils/zustandStateStore");
14
- var _jsxRuntime = require("react/jsx-runtime");
15
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
16
- /**
17
- * ZustandStateInfoView
18
- *
19
- * Displays comprehensive state change information including:
20
- * - Change metadata (store, category, duration)
21
- * - Partial data passed to setState
22
- * - Changed keys list
23
- *
24
- * Mirrors ReduxActionInfoView.tsx
25
- */
26
-
27
- function getCategoryInfo(category) {
28
- switch (category) {
29
- case "replace":
30
- return {
31
- label: "REPLACE",
32
- color: _sharedUi.buoyColors.warning,
33
- bgColor: _sharedUi.buoyColors.warning + "26"
34
- };
35
- case "persist":
36
- return {
37
- label: "PERSIST",
38
- color: _sharedUi.buoyColors.info,
39
- bgColor: _sharedUi.buoyColors.info + "26"
40
- };
41
- case "initial":
42
- return {
43
- label: "INITIAL",
44
- color: _sharedUi.buoyColors.textMuted,
45
- bgColor: _sharedUi.buoyColors.textMuted + "26"
46
- };
47
- default:
48
- return {
49
- label: "SET STATE",
50
- color: _sharedUi.buoyColors.success,
51
- bgColor: _sharedUi.buoyColors.success + "26"
52
- };
53
- }
54
- }
55
- function formatDuration(duration) {
56
- if (duration === undefined) return "N/A";
57
- if (duration < 1) return "<1ms";
58
- return `${duration.toFixed(1)}ms`;
59
- }
60
- function SectionHeader({
61
- icon: Icon,
62
- title,
63
- badge
64
- }) {
65
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
66
- style: styles.sectionHeader,
67
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
68
- style: styles.sectionHeaderLeft,
69
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {
70
- size: 14,
71
- color: _sharedUi.buoyColors.primary
72
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
73
- style: styles.sectionTitle,
74
- children: title
75
- })]
76
- }), badge]
77
- });
78
- }
79
- function InfoRow({
80
- label,
81
- value,
82
- valueColor,
83
- mono = false
84
- }) {
85
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
86
- style: styles.infoRow,
87
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
88
- style: styles.infoLabel,
89
- children: label
90
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
91
- style: [styles.infoValue, mono && styles.infoValueMono, valueColor ? {
92
- color: valueColor
93
- } : undefined],
94
- numberOfLines: 1,
95
- ellipsizeMode: "middle",
96
- children: value
97
- })]
98
- });
99
- }
100
- function formatTime(timestamp) {
101
- const date = new Date(timestamp);
102
- const hours = date.getHours().toString().padStart(2, "0");
103
- const minutes = date.getMinutes().toString().padStart(2, "0");
104
- const seconds = date.getSeconds().toString().padStart(2, "0");
105
- const ms = date.getMilliseconds().toString().padStart(3, "0");
106
- return `${hours}:${minutes}:${seconds}.${ms}`;
107
- }
108
- const ZustandStateInfoView = exports.ZustandStateInfoView = /*#__PURE__*/(0, _react.memo)(function ZustandStateInfoView({
109
- change
110
- }) {
111
- const isPro = (0, _license.useIsPro)();
112
- const [showProModal, setShowProModal] = (0, _react.useState)(false);
113
- (0, _react.useEffect)(() => {
114
- if (showProModal && isPro) {
115
- setShowProModal(false);
116
- }
117
- }, [showProModal, isPro]);
118
- const categoryInfo = getCategoryInfo(change.category);
119
- const hasPartial = change.partial !== undefined && change.partial !== "(updater fn)";
120
- const hasChangedKeys = change.changedKeys.length > 0;
121
- const storeColor = _zustandStateStore.zustandStateStore.getStoreColor(change.storeName);
122
- const handleCopyState = (0, _react.useCallback)(async () => {
123
- if (!isPro) {
124
- setShowProModal(true);
125
- return;
126
- }
127
- await (0, _sharedUi.copyToClipboard)(change.nextState);
128
- }, [change.nextState, isPro]);
129
- const handleResetStore = (0, _react.useCallback)(() => {
130
- const storeInfo = _zustandStateStore.zustandStateStore.getStore(change.storeName);
131
- if (storeInfo?.api.getInitialState) {
132
- const initialState = storeInfo.api.getInitialState();
133
- storeInfo.api.setState(initialState, true);
134
- }
135
- }, [change.storeName]);
136
- const handleJumpToState = (0, _react.useCallback)(() => {
137
- const storeInfo = _zustandStateStore.zustandStateStore.getStore(change.storeName);
138
- if (storeInfo) {
139
- storeInfo.api.setState(change.nextState, true);
140
- }
141
- }, [change.storeName, change.nextState]);
142
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.ScrollView, {
143
- style: styles.container,
144
- contentContainerStyle: styles.contentContainer,
145
- showsVerticalScrollIndicator: false,
146
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
147
- style: styles.card,
148
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(SectionHeader, {
149
- icon: _sharedUi.Info,
150
- title: "CHANGE INFO"
151
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
152
- style: styles.cardContent,
153
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
154
- label: "Store",
155
- value: change.storeName,
156
- mono: true,
157
- valueColor: storeColor
158
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoRow, {
159
- label: "Time",
160
- value: formatTime(change.timestamp),
161
- mono: true
162
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
163
- style: styles.badgeRow,
164
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
165
- style: [styles.categoryBadge, {
166
- backgroundColor: categoryInfo.bgColor
167
- }],
168
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
169
- style: [styles.categoryText, {
170
- color: categoryInfo.color
171
- }],
172
- children: categoryInfo.label
173
- })
174
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
175
- style: [styles.durationBadge, change.isSlowUpdate && styles.durationBadgeSlow],
176
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Clock, {
177
- size: 10,
178
- color: change.isSlowUpdate ? _sharedUi.buoyColors.error : _sharedUi.buoyColors.textSecondary
179
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
180
- style: [styles.durationText, change.isSlowUpdate && styles.durationTextSlow],
181
- children: formatDuration(change.duration)
182
- }), change.isSlowUpdate && /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.AlertTriangle, {
183
- size: 10,
184
- color: _sharedUi.buoyColors.error
185
- })]
186
- }), change.hasStateChange ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
187
- style: styles.changesBadge,
188
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Zap, {
189
- size: 10,
190
- color: _sharedUi.buoyColors.success
191
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
192
- style: styles.changesText,
193
- children: change.diffSummary || "changed"
194
- })]
195
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
196
- style: styles.noChangesBadge,
197
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
198
- style: styles.noChangesText,
199
- children: "no change"
200
- })
201
- }), change.isPersisted && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
202
- style: styles.persistBadge,
203
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.Database, {
204
- size: 10,
205
- color: _sharedUi.buoyColors.info
206
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
207
- style: styles.persistText,
208
- children: "PERSISTED"
209
- })]
210
- })]
211
- })]
212
- })]
213
- }), hasChangedKeys && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
214
- style: styles.card,
215
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(SectionHeader, {
216
- icon: _sharedUi.Zap,
217
- title: "CHANGED KEYS",
218
- badge: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
219
- style: styles.countBadge,
220
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
221
- style: styles.countText,
222
- children: change.changedKeys.length
223
- })
224
- })
225
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
226
- style: styles.cardContent,
227
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
228
- style: styles.keysContainer,
229
- children: change.changedKeys.map(key => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
230
- style: styles.keyBadge,
231
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
232
- style: styles.keyText,
233
- children: key
234
- })
235
- }, key))
236
- })
237
- })]
238
- }), hasPartial && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
239
- style: styles.card,
240
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(SectionHeader, {
241
- icon: _sharedUi.Box,
242
- title: "PARTIAL (setState argument)",
243
- badge: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
244
- style: styles.typeBadge,
245
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
246
- style: styles.typeText,
247
- children: Array.isArray(change.partial) ? "ARRAY" : typeof change.partial === "object" ? "OBJECT" : String(typeof change.partial).toUpperCase()
248
- })
249
- })
250
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
251
- style: styles.dataViewerContainer,
252
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_dataViewer.DataViewer, {
253
- title: "",
254
- data: (0, _sharedUi.parseValue)(change.partial),
255
- showTypeFilter: true,
256
- rawMode: true,
257
- initialExpanded: true
258
- })
259
- })]
260
- }), change.partial === "(updater fn)" && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
261
- style: styles.card,
262
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(SectionHeader, {
263
- icon: _sharedUi.Box,
264
- title: "SET STATE CALL"
265
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
266
- style: styles.cardContent,
267
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
268
- style: styles.updaterText,
269
- children: "Called with an updater function: set((state) => ...)"
270
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
271
- style: styles.updaterSubtext,
272
- children: "The partial value is computed at runtime from the previous state. See the DIFF tab to view the resulting changes."
273
- })]
274
- })]
275
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
276
- style: styles.actionsGrid,
277
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ZustandActionButton.ZustandActionButton, {
278
- type: "jump",
279
- text: "JUMP",
280
- onPress: handleJumpToState
281
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ZustandActionButton.ZustandActionButton, {
282
- type: "reset",
283
- text: "RESET STORE",
284
- onPress: handleResetStore
285
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ZustandActionButton.ZustandActionButton, {
286
- type: "copy",
287
- text: "COPY STATE",
288
- onPress: handleCopyState
289
- })]
290
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.ProUpgradeModal, {
291
- visible: showProModal,
292
- onClose: () => setShowProModal(false),
293
- featureName: "Copy"
294
- })]
295
- });
296
- });
297
- const styles = _reactNative.StyleSheet.create({
298
- container: {
299
- flex: 1
300
- },
301
- contentContainer: {
302
- padding: 8,
303
- paddingBottom: 100,
304
- gap: 16
305
- },
306
- card: {
307
- backgroundColor: _sharedUi.buoyColors.card,
308
- borderRadius: 6,
309
- borderWidth: 1,
310
- borderColor: _sharedUi.buoyColors.primary + "4D",
311
- overflow: "hidden",
312
- shadowColor: _sharedUi.buoyColors.primary,
313
- shadowOffset: {
314
- width: 0,
315
- height: 0
316
- },
317
- shadowOpacity: 0.1,
318
- shadowRadius: 6
319
- },
320
- sectionHeader: {
321
- flexDirection: "row",
322
- alignItems: "center",
323
- justifyContent: "space-between",
324
- paddingHorizontal: 12,
325
- paddingVertical: 10,
326
- borderBottomWidth: 1,
327
- borderBottomColor: _sharedUi.buoyColors.primary + "33",
328
- backgroundColor: _sharedUi.buoyColors.primary + "15"
329
- },
330
- sectionHeaderLeft: {
331
- flexDirection: "row",
332
- alignItems: "center",
333
- gap: 6
334
- },
335
- sectionTitle: {
336
- fontSize: 12,
337
- fontWeight: "600",
338
- letterSpacing: 0.5,
339
- color: _sharedUi.buoyColors.primary,
340
- fontFamily: "monospace"
341
- },
342
- cardContent: {
343
- padding: 14,
344
- gap: 10
345
- },
346
- infoRow: {
347
- flexDirection: "row",
348
- alignItems: "center",
349
- justifyContent: "space-between"
350
- },
351
- infoLabel: {
352
- fontSize: 11,
353
- color: _sharedUi.buoyColors.textMuted,
354
- fontWeight: "500"
355
- },
356
- infoValue: {
357
- fontSize: 11,
358
- color: _sharedUi.buoyColors.text,
359
- fontWeight: "500",
360
- flex: 1,
361
- textAlign: "right",
362
- marginLeft: 12
363
- },
364
- infoValueMono: {
365
- fontFamily: "monospace"
366
- },
367
- badgeRow: {
368
- flexDirection: "row",
369
- flexWrap: "wrap",
370
- gap: 8,
371
- marginTop: 6
372
- },
373
- categoryBadge: {
374
- paddingHorizontal: 8,
375
- paddingVertical: 3,
376
- borderRadius: 4
377
- },
378
- categoryText: {
379
- fontSize: 9,
380
- fontWeight: "700",
381
- letterSpacing: 0.3
382
- },
383
- durationBadge: {
384
- flexDirection: "row",
385
- alignItems: "center",
386
- gap: 4,
387
- paddingHorizontal: 8,
388
- paddingVertical: 3,
389
- borderRadius: 4,
390
- backgroundColor: _sharedUi.buoyColors.input
391
- },
392
- durationBadgeSlow: {
393
- backgroundColor: _sharedUi.buoyColors.error + "26"
394
- },
395
- durationText: {
396
- fontSize: 9,
397
- fontWeight: "600",
398
- color: _sharedUi.buoyColors.textSecondary,
399
- fontFamily: "monospace"
400
- },
401
- durationTextSlow: {
402
- color: _sharedUi.buoyColors.error
403
- },
404
- changesBadge: {
405
- flexDirection: "row",
406
- alignItems: "center",
407
- gap: 4,
408
- paddingHorizontal: 8,
409
- paddingVertical: 3,
410
- borderRadius: 4,
411
- backgroundColor: _sharedUi.buoyColors.success + "26"
412
- },
413
- changesText: {
414
- fontSize: 9,
415
- fontWeight: "600",
416
- color: _sharedUi.buoyColors.success
417
- },
418
- noChangesBadge: {
419
- paddingHorizontal: 8,
420
- paddingVertical: 3,
421
- borderRadius: 4,
422
- backgroundColor: _sharedUi.buoyColors.input
423
- },
424
- noChangesText: {
425
- fontSize: 9,
426
- fontWeight: "600",
427
- color: _sharedUi.buoyColors.textMuted
428
- },
429
- persistBadge: {
430
- flexDirection: "row",
431
- alignItems: "center",
432
- gap: 4,
433
- paddingHorizontal: 8,
434
- paddingVertical: 3,
435
- borderRadius: 4,
436
- backgroundColor: _sharedUi.buoyColors.info + "26"
437
- },
438
- persistText: {
439
- fontSize: 9,
440
- fontWeight: "700",
441
- color: _sharedUi.buoyColors.info,
442
- letterSpacing: 0.3
443
- },
444
- keysContainer: {
445
- flexDirection: "row",
446
- flexWrap: "wrap",
447
- gap: 6
448
- },
449
- keyBadge: {
450
- paddingHorizontal: 8,
451
- paddingVertical: 4,
452
- borderRadius: 4,
453
- backgroundColor: _sharedUi.buoyColors.primary + "20",
454
- borderWidth: 1,
455
- borderColor: _sharedUi.buoyColors.primary + "40"
456
- },
457
- keyText: {
458
- fontSize: 11,
459
- fontWeight: "600",
460
- color: _sharedUi.buoyColors.primary,
461
- fontFamily: "monospace"
462
- },
463
- countBadge: {
464
- paddingHorizontal: 8,
465
- paddingVertical: 3,
466
- borderRadius: 4,
467
- backgroundColor: _sharedUi.buoyColors.primary + "26"
468
- },
469
- countText: {
470
- fontSize: 9,
471
- fontWeight: "700",
472
- color: _sharedUi.buoyColors.primary,
473
- fontFamily: "monospace"
474
- },
475
- typeBadge: {
476
- paddingHorizontal: 6,
477
- paddingVertical: 2,
478
- borderRadius: 3,
479
- backgroundColor: _sharedUi.buoyColors.input
480
- },
481
- typeText: {
482
- fontSize: 8,
483
- fontWeight: "600",
484
- color: _sharedUi.buoyColors.textMuted,
485
- fontFamily: "monospace"
486
- },
487
- dataViewerContainer: {
488
- backgroundColor: _sharedUi.buoyColors.base,
489
- minHeight: 60
490
- },
491
- updaterText: {
492
- fontSize: 12,
493
- color: _sharedUi.buoyColors.text,
494
- fontFamily: "monospace"
495
- },
496
- updaterSubtext: {
497
- fontSize: 11,
498
- color: _sharedUi.buoyColors.textMuted,
499
- lineHeight: 16,
500
- marginTop: 4
501
- },
502
- actionsGrid: {
503
- flexDirection: "row",
504
- flexWrap: "wrap",
505
- gap: 12,
506
- justifyContent: "flex-start"
507
- }
508
- });
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ZustandStateInfoView=void 0;var _react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_sharedUi=require("@buoy-gg/shared-ui"),_license=require("@buoy-gg/license"),_dataViewer=require("@buoy-gg/shared-ui/dataViewer"),_ZustandActionButton=require("./ZustandActionButton"),_zustandStateStore=require("../utils/zustandStateStore"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var o=new WeakMap,r=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var a,i,s={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return s;if(a=t?r:o){if(a.has(e))return a.get(e);a.set(e,s)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((i=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(i.get||i.set)?a(s,t,i):s[t]=e[t]);return s})(e,t)}function getCategoryInfo(e){switch(e){case"replace":return{label:"REPLACE",color:_sharedUi.buoyColors.warning,bgColor:_sharedUi.buoyColors.warning+"26"};case"persist":return{label:"PERSIST",color:_sharedUi.buoyColors.info,bgColor:_sharedUi.buoyColors.info+"26"};case"initial":return{label:"INITIAL",color:_sharedUi.buoyColors.textMuted,bgColor:_sharedUi.buoyColors.textMuted+"26"};default:return{label:"SET STATE",color:_sharedUi.buoyColors.success,bgColor:_sharedUi.buoyColors.success+"26"}}}function formatDuration(e){return void 0===e?"N/A":e<1?"<1ms":`${e.toFixed(1)}ms`}function SectionHeader({icon:e,title:t,badge:o}){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionHeader,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionHeaderLeft,children:[(0,_jsxRuntime.jsx)(e,{size:14,color:_sharedUi.buoyColors.primary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionTitle,children:t})]}),o]})}function InfoRow({label:e,value:t,valueColor:o,mono:r=!1}){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.infoRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.infoLabel,children:e}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.infoValue,r&&styles.infoValueMono,o?{color:o}:void 0],numberOfLines:1,ellipsizeMode:"middle",children:t})]})}function formatTime(e){const t=new Date(e);return`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}const ZustandStateInfoView=exports.ZustandStateInfoView=(0,_react.memo)(function({change:e}){const t=(0,_license.useIsPro)(),[o,r]=(0,_react.useState)(!1);(0,_react.useEffect)(()=>{o&&t&&r(!1)},[o,t]);const a=getCategoryInfo(e.category),i=void 0!==e.partial&&"(updater fn)"!==e.partial,s=e.changedKeys.length>0,n=_zustandStateStore.zustandStateStore.getStoreColor(e.storeName),l=(0,_react.useCallback)(async()=>{t?await(0,_sharedUi.copyToClipboard)(e.nextState):r(!0)},[e.nextState,t]),d=(0,_react.useCallback)(()=>{const t=_zustandStateStore.zustandStateStore.getStore(e.storeName);if(t?.api.getInitialState){const e=t.api.getInitialState();t.api.setState(e,!0)}},[e.storeName]),c=(0,_react.useCallback)(()=>{const t=_zustandStateStore.zustandStateStore.getStore(e.storeName);t&&t.api.setState(e.nextState,!0)},[e.storeName,e.nextState]);return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.container,contentContainerStyle:styles.contentContainer,showsVerticalScrollIndicator:!1,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.card,children:[(0,_jsxRuntime.jsx)(SectionHeader,{icon:_sharedUi.Info,title:"CHANGE INFO"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.cardContent,children:[(0,_jsxRuntime.jsx)(InfoRow,{label:"Store",value:e.storeName,mono:!0,valueColor:n}),(0,_jsxRuntime.jsx)(InfoRow,{label:"Time",value:formatTime(e.timestamp),mono:!0}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.badgeRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.categoryBadge,{backgroundColor:a.bgColor}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.categoryText,{color:a.color}],children:a.label})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.durationBadge,e.isSlowUpdate&&styles.durationBadgeSlow],children:[(0,_jsxRuntime.jsx)(_sharedUi.Clock,{size:10,color:e.isSlowUpdate?_sharedUi.buoyColors.error:_sharedUi.buoyColors.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.durationText,e.isSlowUpdate&&styles.durationTextSlow],children:formatDuration(e.duration)}),e.isSlowUpdate&&(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:10,color:_sharedUi.buoyColors.error})]}),e.hasStateChange?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.changesBadge,children:[(0,_jsxRuntime.jsx)(_sharedUi.Zap,{size:10,color:_sharedUi.buoyColors.success}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.changesText,children:e.diffSummary||"changed"})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.noChangesBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.noChangesText,children:"no change"})}),e.isPersisted&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.persistBadge,children:[(0,_jsxRuntime.jsx)(_sharedUi.Database,{size:10,color:_sharedUi.buoyColors.info}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.persistText,children:"PERSISTED"})]})]})]})]}),s&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.card,children:[(0,_jsxRuntime.jsx)(SectionHeader,{icon:_sharedUi.Zap,title:"CHANGED KEYS",badge:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.countBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.countText,children:e.changedKeys.length})})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.cardContent,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.keysContainer,children:e.changedKeys.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.keyBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.keyText,children:e})},e))})})]}),i&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.card,children:[(0,_jsxRuntime.jsx)(SectionHeader,{icon:_sharedUi.Box,title:"PARTIAL (setState argument)",badge:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.typeBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.typeText,children:Array.isArray(e.partial)?"ARRAY":"object"==typeof e.partial?"OBJECT":String(typeof e.partial).toUpperCase()})})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.dataViewerContainer,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:"",data:(0,_sharedUi.parseValue)(e.partial),showTypeFilter:!0,rawMode:!0,initialExpanded:!0})})]}),"(updater fn)"===e.partial&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.card,children:[(0,_jsxRuntime.jsx)(SectionHeader,{icon:_sharedUi.Box,title:"SET STATE CALL"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.cardContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.updaterText,children:"Called with an updater function: set((state) => ...)"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.updaterSubtext,children:"The partial value is computed at runtime from the previous state. See the DIFF tab to view the resulting changes."})]})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionsGrid,children:[(0,_jsxRuntime.jsx)(_ZustandActionButton.ZustandActionButton,{type:"jump",text:"JUMP",onPress:c}),(0,_jsxRuntime.jsx)(_ZustandActionButton.ZustandActionButton,{type:"reset",text:"RESET STORE",onPress:d}),(0,_jsxRuntime.jsx)(_ZustandActionButton.ZustandActionButton,{type:"copy",text:"COPY STATE",onPress:l})]}),(0,_jsxRuntime.jsx)(_sharedUi.ProUpgradeModal,{visible:o,onClose:()=>r(!1),featureName:"Copy"})]})}),styles=_reactNative.StyleSheet.create({container:{flex:1},contentContainer:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:_sharedUi.buoyColors.card,borderRadius:6,borderWidth:1,borderColor:_sharedUi.buoyColors.primary+"4D",overflow:"hidden",shadowColor:_sharedUi.buoyColors.primary,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:_sharedUi.buoyColors.primary+"33",backgroundColor:_sharedUi.buoyColors.primary+"15"},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:_sharedUi.buoyColors.primary,fontFamily:"monospace"},cardContent:{padding:14,gap:10},infoRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},infoLabel:{fontSize:11,color:_sharedUi.buoyColors.textMuted,fontWeight:"500"},infoValue:{fontSize:11,color:_sharedUi.buoyColors.text,fontWeight:"500",flex:1,textAlign:"right",marginLeft:12},infoValueMono:{fontFamily:"monospace"},badgeRow:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},categoryBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4},categoryText:{fontSize:9,fontWeight:"700",letterSpacing:.3},durationBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.buoyColors.input},durationBadgeSlow:{backgroundColor:_sharedUi.buoyColors.error+"26"},durationText:{fontSize:9,fontWeight:"600",color:_sharedUi.buoyColors.textSecondary,fontFamily:"monospace"},durationTextSlow:{color:_sharedUi.buoyColors.error},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.buoyColors.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:_sharedUi.buoyColors.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.buoyColors.input},noChangesText:{fontSize:9,fontWeight:"600",color:_sharedUi.buoyColors.textMuted},persistBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.buoyColors.info+"26"},persistText:{fontSize:9,fontWeight:"700",color:_sharedUi.buoyColors.info,letterSpacing:.3},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:_sharedUi.buoyColors.primary+"20",borderWidth:1,borderColor:_sharedUi.buoyColors.primary+"40"},keyText:{fontSize:11,fontWeight:"600",color:_sharedUi.buoyColors.primary,fontFamily:"monospace"},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.buoyColors.primary+"26"},countText:{fontSize:9,fontWeight:"700",color:_sharedUi.buoyColors.primary,fontFamily:"monospace"},typeBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:3,backgroundColor:_sharedUi.buoyColors.input},typeText:{fontSize:8,fontWeight:"600",color:_sharedUi.buoyColors.textMuted,fontFamily:"monospace"},dataViewerContainer:{backgroundColor:_sharedUi.buoyColors.base,minHeight:60},updaterText:{fontSize:12,color:_sharedUi.buoyColors.text,fontFamily:"monospace"},updaterSubtext:{fontSize:11,color:_sharedUi.buoyColors.textMuted,lineHeight:16,marginTop:4},actionsGrid:{flexDirection:"row",flexWrap:"wrap",gap:12,justifyContent:"flex-start"}});