@buoy-gg/zustand 7.0.38 → 7.0.39

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