@buoy-gg/storage 1.7.2

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 (187) hide show
  1. package/README.md +607 -0
  2. package/lib/commonjs/index.js +34 -0
  3. package/lib/commonjs/package.json +1 -0
  4. package/lib/commonjs/preset.js +94 -0
  5. package/lib/commonjs/storage/components/DiffViewer/DiffOptionsPanel.js +356 -0
  6. package/lib/commonjs/storage/components/DiffViewer/TreeDiffViewer.js +29 -0
  7. package/lib/commonjs/storage/components/DiffViewer/components/DiffSummary.js +121 -0
  8. package/lib/commonjs/storage/components/DiffViewer/modes/ThemedSplitView.js +419 -0
  9. package/lib/commonjs/storage/components/DiffViewer/themes/diffThemes.js +122 -0
  10. package/lib/commonjs/storage/components/GameUIStorageBrowser.js +924 -0
  11. package/lib/commonjs/storage/components/GameUIStorageStats.js +746 -0
  12. package/lib/commonjs/storage/components/MMKVInstanceInfoPanel.js +257 -0
  13. package/lib/commonjs/storage/components/MMKVInstanceSelector.js +418 -0
  14. package/lib/commonjs/storage/components/SelectionActionBar.js +224 -0
  15. package/lib/commonjs/storage/components/StorageActionButtons.js +239 -0
  16. package/lib/commonjs/storage/components/StorageActions.js +192 -0
  17. package/lib/commonjs/storage/components/StorageBrowserMode.js +31 -0
  18. package/lib/commonjs/storage/components/StorageEventDetailContent.js +1025 -0
  19. package/lib/commonjs/storage/components/StorageEventFilterView.js +141 -0
  20. package/lib/commonjs/storage/components/StorageEventListener.js +357 -0
  21. package/lib/commonjs/storage/components/StorageEventsSection.js +24 -0
  22. package/lib/commonjs/storage/components/StorageFilterCards.js +345 -0
  23. package/lib/commonjs/storage/components/StorageFilterViewV2.js +42 -0
  24. package/lib/commonjs/storage/components/StorageKeyCard.js +516 -0
  25. package/lib/commonjs/storage/components/StorageKeyRow.js +356 -0
  26. package/lib/commonjs/storage/components/StorageKeySection.js +105 -0
  27. package/lib/commonjs/storage/components/StorageKeyStats.js +344 -0
  28. package/lib/commonjs/storage/components/StorageModalWithTabs.js +871 -0
  29. package/lib/commonjs/storage/components/StorageSection.js +43 -0
  30. package/lib/commonjs/storage/hooks/useAsyncStorageKeys.js +126 -0
  31. package/lib/commonjs/storage/hooks/useMMKVInstances.js +221 -0
  32. package/lib/commonjs/storage/hooks/useMMKVKeys.js +362 -0
  33. package/lib/commonjs/storage/hooks/useTickEverySecond.js +21 -0
  34. package/lib/commonjs/storage/index.js +148 -0
  35. package/lib/commonjs/storage/types.js +5 -0
  36. package/lib/commonjs/storage/utils/AsyncStorageListener.js +510 -0
  37. package/lib/commonjs/storage/utils/MMKVInstanceRegistry.js +202 -0
  38. package/lib/commonjs/storage/utils/MMKVListener.js +380 -0
  39. package/lib/commonjs/storage/utils/clearAllStorage.js +47 -0
  40. package/lib/commonjs/storage/utils/index.js +180 -0
  41. package/lib/commonjs/storage/utils/lineDiff.js +363 -0
  42. package/lib/commonjs/storage/utils/mmkvAvailability.js +62 -0
  43. package/lib/commonjs/storage/utils/mmkvTypeDetection.js +139 -0
  44. package/lib/commonjs/storage/utils/objectDiff.js +157 -0
  45. package/lib/commonjs/storage/utils/safeAsyncStorage.js +140 -0
  46. package/lib/commonjs/storage/utils/storageActionHelpers.js +46 -0
  47. package/lib/commonjs/storage/utils/storageQueryUtils.js +35 -0
  48. package/lib/commonjs/storage/utils/valueType.js +18 -0
  49. package/lib/module/index.js +7 -0
  50. package/lib/module/preset.js +89 -0
  51. package/lib/module/storage/components/DiffViewer/DiffOptionsPanel.js +352 -0
  52. package/lib/module/storage/components/DiffViewer/TreeDiffViewer.js +25 -0
  53. package/lib/module/storage/components/DiffViewer/components/DiffSummary.js +117 -0
  54. package/lib/module/storage/components/DiffViewer/modes/ThemedSplitView.js +415 -0
  55. package/lib/module/storage/components/DiffViewer/themes/diffThemes.js +118 -0
  56. package/lib/module/storage/components/GameUIStorageBrowser.js +922 -0
  57. package/lib/module/storage/components/GameUIStorageStats.js +742 -0
  58. package/lib/module/storage/components/MMKVInstanceInfoPanel.js +253 -0
  59. package/lib/module/storage/components/MMKVInstanceSelector.js +414 -0
  60. package/lib/module/storage/components/SelectionActionBar.js +221 -0
  61. package/lib/module/storage/components/StorageActionButtons.js +236 -0
  62. package/lib/module/storage/components/StorageActions.js +189 -0
  63. package/lib/module/storage/components/StorageBrowserMode.js +27 -0
  64. package/lib/module/storage/components/StorageEventDetailContent.js +1020 -0
  65. package/lib/module/storage/components/StorageEventFilterView.js +137 -0
  66. package/lib/module/storage/components/StorageEventListener.js +354 -0
  67. package/lib/module/storage/components/StorageEventsSection.js +20 -0
  68. package/lib/module/storage/components/StorageFilterCards.js +341 -0
  69. package/lib/module/storage/components/StorageFilterViewV2.js +38 -0
  70. package/lib/module/storage/components/StorageKeyCard.js +513 -0
  71. package/lib/module/storage/components/StorageKeyRow.js +353 -0
  72. package/lib/module/storage/components/StorageKeySection.js +101 -0
  73. package/lib/module/storage/components/StorageKeyStats.js +340 -0
  74. package/lib/module/storage/components/StorageModalWithTabs.js +867 -0
  75. package/lib/module/storage/components/StorageSection.js +40 -0
  76. package/lib/module/storage/hooks/useAsyncStorageKeys.js +121 -0
  77. package/lib/module/storage/hooks/useMMKVInstances.js +216 -0
  78. package/lib/module/storage/hooks/useMMKVKeys.js +359 -0
  79. package/lib/module/storage/hooks/useTickEverySecond.js +18 -0
  80. package/lib/module/storage/index.js +25 -0
  81. package/lib/module/storage/types.js +3 -0
  82. package/lib/module/storage/utils/AsyncStorageListener.js +500 -0
  83. package/lib/module/storage/utils/MMKVInstanceRegistry.js +196 -0
  84. package/lib/module/storage/utils/MMKVListener.js +367 -0
  85. package/lib/module/storage/utils/clearAllStorage.js +42 -0
  86. package/lib/module/storage/utils/index.js +22 -0
  87. package/lib/module/storage/utils/lineDiff.js +359 -0
  88. package/lib/module/storage/utils/mmkvAvailability.js +56 -0
  89. package/lib/module/storage/utils/mmkvTypeDetection.js +133 -0
  90. package/lib/module/storage/utils/objectDiff.js +153 -0
  91. package/lib/module/storage/utils/safeAsyncStorage.js +134 -0
  92. package/lib/module/storage/utils/storageActionHelpers.js +42 -0
  93. package/lib/module/storage/utils/storageQueryUtils.js +30 -0
  94. package/lib/module/storage/utils/valueType.js +14 -0
  95. package/lib/typescript/index.d.ts +3 -0
  96. package/lib/typescript/index.d.ts.map +1 -0
  97. package/lib/typescript/preset.d.ts +90 -0
  98. package/lib/typescript/preset.d.ts.map +1 -0
  99. package/lib/typescript/storage/components/DiffViewer/DiffOptionsPanel.d.ts +18 -0
  100. package/lib/typescript/storage/components/DiffViewer/DiffOptionsPanel.d.ts.map +1 -0
  101. package/lib/typescript/storage/components/DiffViewer/TreeDiffViewer.d.ts +7 -0
  102. package/lib/typescript/storage/components/DiffViewer/TreeDiffViewer.d.ts.map +1 -0
  103. package/lib/typescript/storage/components/DiffViewer/components/DiffSummary.d.ts +12 -0
  104. package/lib/typescript/storage/components/DiffViewer/components/DiffSummary.d.ts.map +1 -0
  105. package/lib/typescript/storage/components/DiffViewer/modes/ThemedSplitView.d.ts +13 -0
  106. package/lib/typescript/storage/components/DiffViewer/modes/ThemedSplitView.d.ts.map +1 -0
  107. package/lib/typescript/storage/components/DiffViewer/themes/diffThemes.d.ts +64 -0
  108. package/lib/typescript/storage/components/DiffViewer/themes/diffThemes.d.ts.map +1 -0
  109. package/lib/typescript/storage/components/GameUIStorageBrowser.d.ts +16 -0
  110. package/lib/typescript/storage/components/GameUIStorageBrowser.d.ts.map +1 -0
  111. package/lib/typescript/storage/components/GameUIStorageStats.d.ts +7 -0
  112. package/lib/typescript/storage/components/GameUIStorageStats.d.ts.map +1 -0
  113. package/lib/typescript/storage/components/MMKVInstanceInfoPanel.d.ts +42 -0
  114. package/lib/typescript/storage/components/MMKVInstanceInfoPanel.d.ts.map +1 -0
  115. package/lib/typescript/storage/components/MMKVInstanceSelector.d.ts +35 -0
  116. package/lib/typescript/storage/components/MMKVInstanceSelector.d.ts.map +1 -0
  117. package/lib/typescript/storage/components/SelectionActionBar.d.ts +21 -0
  118. package/lib/typescript/storage/components/SelectionActionBar.d.ts.map +1 -0
  119. package/lib/typescript/storage/components/StorageActionButtons.d.ts +21 -0
  120. package/lib/typescript/storage/components/StorageActionButtons.d.ts.map +1 -0
  121. package/lib/typescript/storage/components/StorageActions.d.ts +10 -0
  122. package/lib/typescript/storage/components/StorageActions.d.ts.map +1 -0
  123. package/lib/typescript/storage/components/StorageBrowserMode.d.ts +18 -0
  124. package/lib/typescript/storage/components/StorageBrowserMode.d.ts.map +1 -0
  125. package/lib/typescript/storage/components/StorageEventDetailContent.d.ts +40 -0
  126. package/lib/typescript/storage/components/StorageEventDetailContent.d.ts.map +1 -0
  127. package/lib/typescript/storage/components/StorageEventFilterView.d.ts +11 -0
  128. package/lib/typescript/storage/components/StorageEventFilterView.d.ts.map +1 -0
  129. package/lib/typescript/storage/components/StorageEventListener.d.ts +6 -0
  130. package/lib/typescript/storage/components/StorageEventListener.d.ts.map +1 -0
  131. package/lib/typescript/storage/components/StorageEventsSection.d.ts +7 -0
  132. package/lib/typescript/storage/components/StorageEventsSection.d.ts.map +1 -0
  133. package/lib/typescript/storage/components/StorageFilterCards.d.ts +36 -0
  134. package/lib/typescript/storage/components/StorageFilterCards.d.ts.map +1 -0
  135. package/lib/typescript/storage/components/StorageFilterViewV2.d.ts +9 -0
  136. package/lib/typescript/storage/components/StorageFilterViewV2.d.ts.map +1 -0
  137. package/lib/typescript/storage/components/StorageKeyCard.d.ts +17 -0
  138. package/lib/typescript/storage/components/StorageKeyCard.d.ts.map +1 -0
  139. package/lib/typescript/storage/components/StorageKeyRow.d.ts +15 -0
  140. package/lib/typescript/storage/components/StorageKeyRow.d.ts.map +1 -0
  141. package/lib/typescript/storage/components/StorageKeySection.d.ts +25 -0
  142. package/lib/typescript/storage/components/StorageKeySection.d.ts.map +1 -0
  143. package/lib/typescript/storage/components/StorageKeyStats.d.ts +15 -0
  144. package/lib/typescript/storage/components/StorageKeyStats.d.ts.map +1 -0
  145. package/lib/typescript/storage/components/StorageModalWithTabs.d.ts +13 -0
  146. package/lib/typescript/storage/components/StorageModalWithTabs.d.ts.map +1 -0
  147. package/lib/typescript/storage/components/StorageSection.d.ts +10 -0
  148. package/lib/typescript/storage/components/StorageSection.d.ts.map +1 -0
  149. package/lib/typescript/storage/hooks/useAsyncStorageKeys.d.ts +10 -0
  150. package/lib/typescript/storage/hooks/useAsyncStorageKeys.d.ts.map +1 -0
  151. package/lib/typescript/storage/hooks/useMMKVInstances.d.ts +114 -0
  152. package/lib/typescript/storage/hooks/useMMKVInstances.d.ts.map +1 -0
  153. package/lib/typescript/storage/hooks/useMMKVKeys.d.ts +94 -0
  154. package/lib/typescript/storage/hooks/useMMKVKeys.d.ts.map +1 -0
  155. package/lib/typescript/storage/hooks/useTickEverySecond.d.ts +6 -0
  156. package/lib/typescript/storage/hooks/useTickEverySecond.d.ts.map +1 -0
  157. package/lib/typescript/storage/index.d.ts +15 -0
  158. package/lib/typescript/storage/index.d.ts.map +1 -0
  159. package/lib/typescript/storage/types.d.ts +41 -0
  160. package/lib/typescript/storage/types.d.ts.map +1 -0
  161. package/lib/typescript/storage/utils/AsyncStorageListener.d.ts +195 -0
  162. package/lib/typescript/storage/utils/AsyncStorageListener.d.ts.map +1 -0
  163. package/lib/typescript/storage/utils/MMKVInstanceRegistry.d.ts +224 -0
  164. package/lib/typescript/storage/utils/MMKVInstanceRegistry.d.ts.map +1 -0
  165. package/lib/typescript/storage/utils/MMKVListener.d.ts +218 -0
  166. package/lib/typescript/storage/utils/MMKVListener.d.ts.map +1 -0
  167. package/lib/typescript/storage/utils/clearAllStorage.d.ts +11 -0
  168. package/lib/typescript/storage/utils/clearAllStorage.d.ts.map +1 -0
  169. package/lib/typescript/storage/utils/index.d.ts +8 -0
  170. package/lib/typescript/storage/utils/index.d.ts.map +1 -0
  171. package/lib/typescript/storage/utils/lineDiff.d.ts +34 -0
  172. package/lib/typescript/storage/utils/lineDiff.d.ts.map +1 -0
  173. package/lib/typescript/storage/utils/mmkvAvailability.d.ts +23 -0
  174. package/lib/typescript/storage/utils/mmkvAvailability.d.ts.map +1 -0
  175. package/lib/typescript/storage/utils/mmkvTypeDetection.d.ts +71 -0
  176. package/lib/typescript/storage/utils/mmkvTypeDetection.d.ts.map +1 -0
  177. package/lib/typescript/storage/utils/objectDiff.d.ts +35 -0
  178. package/lib/typescript/storage/utils/objectDiff.d.ts.map +1 -0
  179. package/lib/typescript/storage/utils/safeAsyncStorage.d.ts +56 -0
  180. package/lib/typescript/storage/utils/safeAsyncStorage.d.ts.map +1 -0
  181. package/lib/typescript/storage/utils/storageActionHelpers.d.ts +5 -0
  182. package/lib/typescript/storage/utils/storageActionHelpers.d.ts.map +1 -0
  183. package/lib/typescript/storage/utils/storageQueryUtils.d.ts +6 -0
  184. package/lib/typescript/storage/utils/storageQueryUtils.d.ts.map +1 -0
  185. package/lib/typescript/storage/utils/valueType.d.ts +3 -0
  186. package/lib/typescript/storage/utils/valueType.d.ts.map +1 -0
  187. package/package.json +68 -0
@@ -0,0 +1,353 @@
1
+ "use strict";
2
+
3
+ import { View, Text, StyleSheet, TouchableOpacity } from "react-native";
4
+ import { macOSColors, CompactRow, TypeBadge, HardDrive, Square, CheckSquare } from "@buoy-gg/shared-ui";
5
+ import { getStorageTypeLabel } from "../utils/storageQueryUtils";
6
+ import { getValueTypeLabel } from "../utils/valueType";
7
+ import { DataViewer } from "@buoy-gg/shared-ui/dataViewer";
8
+
9
+ // MMKV Instance color palette - consistent colors per instance
10
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
+ const INSTANCE_COLORS = [macOSColors.semantic.info,
12
+ // Blue
13
+ macOSColors.semantic.success,
14
+ // Green
15
+ macOSColors.semantic.warning,
16
+ // Orange
17
+ macOSColors.semantic.debug,
18
+ // Purple
19
+ '#FF6B9D',
20
+ // Pink
21
+ '#00D9FF' // Cyan
22
+ ];
23
+
24
+ /**
25
+ * Get consistent color for an MMKV instance based on its ID
26
+ * Uses simple hash to ensure same instance always gets same color
27
+ */
28
+ function getInstanceColor(instanceId) {
29
+ const hash = instanceId.split('').reduce((acc, char) => acc + char.charCodeAt(0), 0);
30
+ return INSTANCE_COLORS[hash % INSTANCE_COLORS.length];
31
+ }
32
+ const getStatusConfig = status => {
33
+ switch (status) {
34
+ case "required_present":
35
+ return {
36
+ label: "Valid",
37
+ color: macOSColors.semantic.success,
38
+ sublabel: "Required"
39
+ };
40
+ case "required_missing":
41
+ return {
42
+ label: "Missing",
43
+ color: macOSColors.semantic.error,
44
+ sublabel: "Required"
45
+ };
46
+ case "required_wrong_value":
47
+ return {
48
+ label: "Wrong",
49
+ color: macOSColors.semantic.warning,
50
+ sublabel: "Invalid value"
51
+ };
52
+ case "required_wrong_type":
53
+ return {
54
+ label: "Type Error",
55
+ color: macOSColors.semantic.info,
56
+ sublabel: "Wrong type"
57
+ };
58
+ case "optional_present":
59
+ return {
60
+ label: "Set",
61
+ color: macOSColors.semantic.debug,
62
+ sublabel: "Optional"
63
+ };
64
+ }
65
+ };
66
+ const formatValue = value => {
67
+ if (value === undefined || value === null) {
68
+ return "undefined";
69
+ }
70
+ const str = typeof value === "string" ? value : JSON.stringify(value);
71
+ return str;
72
+ };
73
+ export function StorageKeyRow({
74
+ storageKey,
75
+ isExpanded,
76
+ onPress,
77
+ isSelectMode = false,
78
+ isSelected = false,
79
+ onSelectionChange
80
+ }) {
81
+ const config = getStatusConfig(storageKey.status);
82
+ const hasValue = storageKey.value !== undefined && storageKey.value !== null;
83
+
84
+ // Format primary text - show the key
85
+ const primaryText = storageKey.key;
86
+
87
+ // Show storage type as secondary text
88
+ const storageTypeLabel = getStorageTypeLabel(storageKey.storageType);
89
+
90
+ // Check if value is JSON object/array for DataViewer
91
+ const isJsonData = storageKey.value && (typeof storageKey.value === "object" || typeof storageKey.value === "string" && (storageKey.value.startsWith("{") || storageKey.value.startsWith("[")));
92
+
93
+ // Parse JSON string if needed
94
+ let parsedValue = storageKey.value;
95
+ if (typeof storageKey.value === "string" && isJsonData) {
96
+ try {
97
+ parsedValue = JSON.parse(storageKey.value);
98
+ } catch {
99
+ // Keep original if parse fails
100
+ }
101
+ }
102
+
103
+ // Create expanded content for value and storage details
104
+ const expandedContent = /*#__PURE__*/_jsxs(View, {
105
+ style: styles.expandedContainer,
106
+ children: [/*#__PURE__*/_jsxs(View, {
107
+ style: styles.expandedRow,
108
+ children: [/*#__PURE__*/_jsx(Text, {
109
+ style: styles.expandedLabel,
110
+ children: "Storage:"
111
+ }), /*#__PURE__*/_jsx(View, {
112
+ style: [styles.storageBadge, {
113
+ backgroundColor: getStorageTypeColor(storageKey.storageType) + "12",
114
+ borderColor: getStorageTypeColor(storageKey.storageType) + "25"
115
+ }],
116
+ children: /*#__PURE__*/_jsx(Text, {
117
+ style: [styles.storageBadgeText, {
118
+ color: getStorageTypeColor(storageKey.storageType)
119
+ }],
120
+ children: storageTypeLabel
121
+ })
122
+ })]
123
+ }), storageKey.storageType === 'mmkv' && storageKey.instanceId && /*#__PURE__*/_jsxs(View, {
124
+ style: styles.expandedRow,
125
+ children: [/*#__PURE__*/_jsx(Text, {
126
+ style: styles.expandedLabel,
127
+ children: "Instance:"
128
+ }), /*#__PURE__*/_jsxs(View, {
129
+ style: [styles.instanceBadge, {
130
+ backgroundColor: getInstanceColor(storageKey.instanceId) + '20',
131
+ borderColor: getInstanceColor(storageKey.instanceId) + '40'
132
+ }],
133
+ children: [/*#__PURE__*/_jsx(HardDrive, {
134
+ size: 9,
135
+ color: getInstanceColor(storageKey.instanceId)
136
+ }), /*#__PURE__*/_jsx(Text, {
137
+ style: [styles.instanceText, {
138
+ color: getInstanceColor(storageKey.instanceId)
139
+ }],
140
+ children: storageKey.instanceId
141
+ })]
142
+ })]
143
+ }), isJsonData && typeof parsedValue === "object" ? /*#__PURE__*/_jsx(View, {
144
+ style: styles.dataViewerContainer,
145
+ children: /*#__PURE__*/_jsx(DataViewer, {
146
+ data: parsedValue,
147
+ title: "Value"
148
+ })
149
+ }) : /*#__PURE__*/_jsxs(View, {
150
+ style: styles.expandedRow,
151
+ children: [/*#__PURE__*/_jsx(Text, {
152
+ style: styles.expandedLabel,
153
+ children: "Value:"
154
+ }), /*#__PURE__*/_jsx(Text, {
155
+ style: styles.expandedValue,
156
+ numberOfLines: 3,
157
+ children: formatValue(storageKey.value) || "undefined"
158
+ })]
159
+ }), storageKey.status === "required_wrong_type" && storageKey.expectedType && /*#__PURE__*/_jsxs(_Fragment, {
160
+ children: [/*#__PURE__*/_jsxs(View, {
161
+ style: styles.expandedRow,
162
+ children: [/*#__PURE__*/_jsx(Text, {
163
+ style: styles.expandedLabel,
164
+ children: "Type:"
165
+ }), /*#__PURE__*/_jsx(TypeBadge, {
166
+ type: getValueTypeLabel(storageKey.value)
167
+ })]
168
+ }), /*#__PURE__*/_jsxs(View, {
169
+ style: styles.expandedRow,
170
+ children: [/*#__PURE__*/_jsx(Text, {
171
+ style: styles.expandedLabel,
172
+ children: "Expected:"
173
+ }), /*#__PURE__*/_jsx(TypeBadge, {
174
+ type: storageKey.expectedType
175
+ })]
176
+ })]
177
+ }), storageKey.status === "required_wrong_value" && storageKey.expectedValue && /*#__PURE__*/_jsxs(View, {
178
+ style: styles.expandedRow,
179
+ children: [/*#__PURE__*/_jsx(Text, {
180
+ style: styles.expandedLabel,
181
+ children: "Expected:"
182
+ }), /*#__PURE__*/_jsx(Text, {
183
+ style: styles.expandedExpected,
184
+ children: String(storageKey.expectedValue)
185
+ })]
186
+ }), storageKey.description && /*#__PURE__*/_jsxs(View, {
187
+ style: styles.expandedRow,
188
+ children: [/*#__PURE__*/_jsx(Text, {
189
+ style: styles.expandedLabel,
190
+ children: "Info:"
191
+ }), /*#__PURE__*/_jsx(Text, {
192
+ style: styles.expandedDescription,
193
+ children: storageKey.description
194
+ })]
195
+ })]
196
+ });
197
+
198
+ // Create storage type badge
199
+ const storageBadge = /*#__PURE__*/_jsx(View, {
200
+ style: [styles.storageBadge, {
201
+ backgroundColor: getStorageTypeColor(storageKey.storageType) + "12",
202
+ borderColor: getStorageTypeColor(storageKey.storageType) + "25"
203
+ }],
204
+ children: /*#__PURE__*/_jsx(Text, {
205
+ style: [styles.storageBadgeText, {
206
+ color: getStorageTypeColor(storageKey.storageType)
207
+ }],
208
+ children: storageTypeLabel
209
+ })
210
+ });
211
+
212
+ // Handle checkbox press in select mode
213
+ const handleCheckboxPress = () => {
214
+ onSelectionChange?.(storageKey, !isSelected);
215
+ };
216
+
217
+ // Create checkbox element for select mode
218
+ const selectionCheckbox = isSelectMode ? /*#__PURE__*/_jsx(TouchableOpacity, {
219
+ onPress: handleCheckboxPress,
220
+ style: styles.checkboxContainer,
221
+ hitSlop: {
222
+ top: 8,
223
+ bottom: 8,
224
+ left: 8,
225
+ right: 8
226
+ },
227
+ children: isSelected ? /*#__PURE__*/_jsx(CheckSquare, {
228
+ size: 18,
229
+ color: macOSColors.semantic.info
230
+ }) : /*#__PURE__*/_jsx(Square, {
231
+ size: 18,
232
+ color: macOSColors.text.muted
233
+ })
234
+ }) : null;
235
+ return /*#__PURE__*/_jsxs(View, {
236
+ style: [styles.rowContainer, isSelected && styles.rowContainerSelected],
237
+ children: [selectionCheckbox, /*#__PURE__*/_jsx(View, {
238
+ style: styles.compactRowWrapper,
239
+ children: /*#__PURE__*/_jsx(CompactRow, {
240
+ statusDotColor: config.color,
241
+ statusLabel: config.label,
242
+ statusSublabel: config.sublabel,
243
+ primaryText: primaryText,
244
+ secondaryText: hasValue ? getValueTypeLabel(storageKey.value) : undefined,
245
+ expandedContent: expandedContent,
246
+ isExpanded: isExpanded,
247
+ expandedGlowColor: config.color,
248
+ customBadge: storageBadge,
249
+ showChevron: !isSelectMode,
250
+ onPress: isSelectMode ? handleCheckboxPress : onPress ? () => onPress(storageKey) : undefined
251
+ })
252
+ })]
253
+ });
254
+ }
255
+ const getStorageTypeColor = storageType => {
256
+ switch (storageType) {
257
+ case "mmkv":
258
+ return macOSColors.semantic.info;
259
+ case "async":
260
+ return macOSColors.semantic.warning;
261
+ case "secure":
262
+ return macOSColors.semantic.success;
263
+ default:
264
+ return macOSColors.text.secondary;
265
+ }
266
+ };
267
+ const styles = StyleSheet.create({
268
+ expandedContainer: {
269
+ gap: 8
270
+ },
271
+ expandedRow: {
272
+ flexDirection: "row",
273
+ alignItems: "center",
274
+ gap: 10
275
+ },
276
+ expandedLabel: {
277
+ fontSize: 10,
278
+ color: macOSColors.text.muted,
279
+ fontWeight: "600",
280
+ minWidth: 70,
281
+ fontFamily: "monospace"
282
+ },
283
+ expandedValue: {
284
+ fontSize: 11,
285
+ color: macOSColors.text.secondary,
286
+ fontFamily: "monospace",
287
+ flex: 1
288
+ },
289
+ expandedExpected: {
290
+ fontSize: 11,
291
+ color: macOSColors.semantic.warning,
292
+ fontFamily: "monospace",
293
+ flex: 1
294
+ },
295
+ expandedDescription: {
296
+ fontSize: 11,
297
+ color: macOSColors.text.secondary,
298
+ flex: 1
299
+ },
300
+ dataViewerContainer: {
301
+ marginTop: 6,
302
+ marginBottom: 6,
303
+ backgroundColor: macOSColors.background.base,
304
+ borderRadius: 6,
305
+ borderWidth: 1,
306
+ borderColor: macOSColors.border.default,
307
+ padding: 6
308
+ },
309
+ storageBadge: {
310
+ paddingHorizontal: 8,
311
+ paddingVertical: 3,
312
+ borderRadius: 999,
313
+ borderWidth: 1
314
+ },
315
+ storageBadgeText: {
316
+ fontSize: 10,
317
+ fontWeight: "700",
318
+ fontFamily: "monospace",
319
+ letterSpacing: 0.5
320
+ },
321
+ instanceBadge: {
322
+ paddingHorizontal: 8,
323
+ paddingVertical: 3,
324
+ borderRadius: 999,
325
+ borderWidth: 1,
326
+ flexDirection: 'row',
327
+ alignItems: 'center',
328
+ gap: 4
329
+ },
330
+ instanceText: {
331
+ fontSize: 10,
332
+ fontWeight: "700",
333
+ fontFamily: "monospace",
334
+ letterSpacing: 0.3
335
+ },
336
+ rowContainer: {
337
+ flexDirection: "row",
338
+ alignItems: "flex-start"
339
+ },
340
+ rowContainerSelected: {
341
+ backgroundColor: macOSColors.semantic.info + "08",
342
+ borderRadius: 8
343
+ },
344
+ checkboxContainer: {
345
+ paddingLeft: 4,
346
+ paddingRight: 8,
347
+ paddingTop: 10,
348
+ alignSelf: "flex-start"
349
+ },
350
+ compactRowWrapper: {
351
+ flex: 1
352
+ }
353
+ });
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ import { useCallback, useState } from "react";
4
+ import { View, Text, StyleSheet } from "react-native";
5
+ import { StorageKeyRow } from "./StorageKeyRow";
6
+ import { SectionHeader } from "@buoy-gg/shared-ui";
7
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
+ /**
9
+ * Storage key section component following composition principles [[rule3]]
10
+ *
11
+ * Applied principles:
12
+ * - Decompose by Responsibility: Single purpose component for grouped storage keys
13
+ * - Prefer Composition over Configuration: Reuses patterns from EnvVarSection
14
+ * - Extract Reusable Logic: Shares expansion state management pattern
15
+ */
16
+ export function StorageKeySection({
17
+ title,
18
+ count,
19
+ keys,
20
+ emptyMessage,
21
+ headerColor,
22
+ isSelectMode = false,
23
+ selectedKeys = new Set(),
24
+ onSelectionChange
25
+ }) {
26
+ const [expandedKey, setExpandedKey] = useState(null);
27
+ const handleKeyPress = useCallback(storageKey => {
28
+ setExpandedKey(prev => prev === storageKey.key ? null : storageKey.key);
29
+ }, []);
30
+
31
+ // Generate unique identifier for a storage key
32
+ const getKeyIdentifier = useCallback(storageKey => {
33
+ return storageKey.instanceId ? `${storageKey.storageType}-${storageKey.instanceId}-${storageKey.key}` : `${storageKey.storageType}-${storageKey.key}`;
34
+ }, []);
35
+ if (keys.length === 0 && title === "Required Keys") {
36
+ return /*#__PURE__*/_jsxs(View, {
37
+ style: styles.sectionContainer,
38
+ children: [/*#__PURE__*/_jsxs(SectionHeader, {
39
+ children: [/*#__PURE__*/_jsx(SectionHeader.Title, {
40
+ children: title
41
+ }), /*#__PURE__*/_jsx(SectionHeader.Badge, {
42
+ count: 0,
43
+ color: headerColor
44
+ })]
45
+ }), /*#__PURE__*/_jsx(View, {
46
+ style: styles.emptySection,
47
+ children: /*#__PURE__*/_jsx(Text, {
48
+ style: styles.emptySectionText,
49
+ children: emptyMessage
50
+ })
51
+ })]
52
+ });
53
+ }
54
+ if (keys.length === 0) return null;
55
+ return /*#__PURE__*/_jsxs(View, {
56
+ style: styles.sectionContainer,
57
+ children: [title && /*#__PURE__*/_jsxs(SectionHeader, {
58
+ children: [/*#__PURE__*/_jsx(SectionHeader.Title, {
59
+ children: title
60
+ }), count >= 0 && /*#__PURE__*/_jsx(SectionHeader.Badge, {
61
+ count: count,
62
+ color: headerColor
63
+ })]
64
+ }), /*#__PURE__*/_jsx(View, {
65
+ style: styles.sectionContent,
66
+ children: keys.map(storageKey => {
67
+ // Create unique key by combining storage type, instance ID (if present), and key name
68
+ const uniqueKey = getKeyIdentifier(storageKey);
69
+ return /*#__PURE__*/_jsx(StorageKeyRow, {
70
+ storageKey: storageKey,
71
+ isExpanded: !isSelectMode && expandedKey === storageKey.key,
72
+ onPress: handleKeyPress,
73
+ isSelectMode: isSelectMode,
74
+ isSelected: selectedKeys.has(uniqueKey),
75
+ onSelectionChange: onSelectionChange
76
+ }, uniqueKey);
77
+ })
78
+ })]
79
+ });
80
+ }
81
+ const styles = StyleSheet.create({
82
+ sectionContainer: {
83
+ gap: 8
84
+ },
85
+ sectionContent: {
86
+ // No gap needed, StorageKeyRow has its own margins
87
+ },
88
+ emptySection: {
89
+ backgroundColor: "rgba(255, 255, 255, 0.02)",
90
+ borderRadius: 6,
91
+ padding: 16,
92
+ borderWidth: 1,
93
+ borderColor: "rgba(255, 255, 255, 0.05)",
94
+ alignItems: "center"
95
+ },
96
+ emptySectionText: {
97
+ color: "#6B7280",
98
+ fontSize: 11,
99
+ textAlign: "center"
100
+ }
101
+ });