@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,253 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * MMKVInstanceInfoPanel Component
5
+ *
6
+ * Displays detailed information about a selected MMKV instance:
7
+ * - Instance ID and path
8
+ * - Encryption status
9
+ * - Read-only status
10
+ * - Key count
11
+ * - Size (if available)
12
+ *
13
+ * Used in GameUIStorageBrowser below the instance selector.
14
+ */
15
+
16
+ import { View, Text, StyleSheet } from 'react-native';
17
+ import { macOSColors } from '@buoy-gg/shared-ui';
18
+ import { useMMKVInstance } from '../hooks/useMMKVInstances';
19
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
20
+ /**
21
+ * MMKV Instance Info Panel
22
+ *
23
+ * Shows metadata and statistics for a selected MMKV instance.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * function MyStorageUI() {
28
+ * const [selectedInstance, setSelectedInstance] = useState('mmkv.default');
29
+ *
30
+ * return (
31
+ * <View>
32
+ * <MMKVInstanceSelector
33
+ * selectedInstanceId={selectedInstance}
34
+ * onSelectInstance={setSelectedInstance}
35
+ * />
36
+ * {selectedInstance && (
37
+ * <MMKVInstanceInfoPanel instanceId={selectedInstance} />
38
+ * )}
39
+ * </View>
40
+ * );
41
+ * }
42
+ * ```
43
+ */
44
+ export function MMKVInstanceInfoPanel({
45
+ instanceId
46
+ }) {
47
+ const instance = useMMKVInstance(instanceId);
48
+ if (!instance) {
49
+ return /*#__PURE__*/_jsx(View, {
50
+ style: styles.container,
51
+ children: /*#__PURE__*/_jsx(View, {
52
+ style: styles.errorState,
53
+ children: /*#__PURE__*/_jsxs(Text, {
54
+ style: styles.errorText,
55
+ children: ["Instance not found: ", instanceId]
56
+ })
57
+ })
58
+ });
59
+ }
60
+ return /*#__PURE__*/_jsx(View, {
61
+ style: styles.container,
62
+ children: /*#__PURE__*/_jsxs(View, {
63
+ style: styles.panel,
64
+ children: [/*#__PURE__*/_jsx(View, {
65
+ style: styles.header,
66
+ children: /*#__PURE__*/_jsx(Text, {
67
+ style: styles.headerTitle,
68
+ children: "Instance Details"
69
+ })
70
+ }), /*#__PURE__*/_jsxs(View, {
71
+ style: styles.infoGrid,
72
+ children: [/*#__PURE__*/_jsx(InfoItem, {
73
+ label: "Instance ID",
74
+ value: instance.id,
75
+ valueStyle: styles.monoValue
76
+ }), /*#__PURE__*/_jsx(InfoItem, {
77
+ label: "Keys",
78
+ value: `${instance.keyCount} ${instance.keyCount === 1 ? 'key' : 'keys'}`,
79
+ highlight: true
80
+ }), /*#__PURE__*/_jsx(InfoItem, {
81
+ label: "Encryption",
82
+ value: instance.encrypted ? '🔒 Encrypted' : '🔓 Not encrypted',
83
+ valueColor: instance.encrypted ? macOSColors.semantic.success : macOSColors.text.muted
84
+ }), /*#__PURE__*/_jsx(InfoItem, {
85
+ label: "Access",
86
+ value: instance.readOnly ? '👁️ Read-only' : '✏️ Read-write',
87
+ valueColor: instance.readOnly ? macOSColors.semantic.warning : macOSColors.text.muted
88
+ }), instance.size !== undefined && /*#__PURE__*/_jsx(InfoItem, {
89
+ label: "Size",
90
+ value: formatBytes(instance.size),
91
+ valueStyle: styles.monoValue
92
+ })]
93
+ }), instance.encrypted && /*#__PURE__*/_jsxs(View, {
94
+ style: styles.notice,
95
+ children: [/*#__PURE__*/_jsx(Text, {
96
+ style: styles.noticeIcon,
97
+ children: "\uD83D\uDD12"
98
+ }), /*#__PURE__*/_jsx(Text, {
99
+ style: styles.noticeText,
100
+ children: "This instance is encrypted. Values are protected at rest."
101
+ })]
102
+ }), instance.readOnly && /*#__PURE__*/_jsxs(View, {
103
+ style: [styles.notice, styles.noticeWarning],
104
+ children: [/*#__PURE__*/_jsx(Text, {
105
+ style: styles.noticeIcon,
106
+ children: "\uD83D\uDC41\uFE0F"
107
+ }), /*#__PURE__*/_jsx(Text, {
108
+ style: [styles.noticeText, styles.noticeTextWarning],
109
+ children: "Read-only mode. Cannot modify values in this instance."
110
+ })]
111
+ })]
112
+ })
113
+ });
114
+ }
115
+
116
+ /**
117
+ * InfoItem Component - Displays a label-value pair
118
+ */
119
+ function InfoItem({
120
+ label,
121
+ value,
122
+ valueStyle,
123
+ valueColor,
124
+ highlight
125
+ }) {
126
+ return /*#__PURE__*/_jsxs(View, {
127
+ style: styles.infoItem,
128
+ children: [/*#__PURE__*/_jsx(Text, {
129
+ style: styles.infoLabel,
130
+ children: label
131
+ }), /*#__PURE__*/_jsx(Text, {
132
+ style: [styles.infoValue, valueStyle, valueColor && {
133
+ color: valueColor
134
+ }, highlight && styles.infoValueHighlight],
135
+ children: value
136
+ })]
137
+ });
138
+ }
139
+
140
+ /**
141
+ * Format bytes to human-readable string
142
+ */
143
+ function formatBytes(bytes) {
144
+ if (bytes === 0) return '0 Bytes';
145
+ const k = 1024;
146
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
147
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
148
+ return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
149
+ }
150
+ const styles = StyleSheet.create({
151
+ container: {
152
+ marginBottom: 12
153
+ },
154
+ // Error state
155
+ errorState: {
156
+ backgroundColor: macOSColors.semantic.error + '15',
157
+ borderRadius: 12,
158
+ padding: 12,
159
+ borderWidth: 1,
160
+ borderColor: macOSColors.semantic.error + '40'
161
+ },
162
+ errorText: {
163
+ fontSize: 12,
164
+ color: macOSColors.semantic.error,
165
+ textAlign: 'center'
166
+ },
167
+ // Panel
168
+ panel: {
169
+ backgroundColor: macOSColors.background.card,
170
+ borderRadius: 12,
171
+ borderWidth: 1,
172
+ borderColor: macOSColors.border.default + '50',
173
+ overflow: 'hidden',
174
+ shadowColor: '#000000',
175
+ shadowOpacity: 0.03,
176
+ shadowRadius: 8,
177
+ shadowOffset: {
178
+ width: 0,
179
+ height: 2
180
+ }
181
+ },
182
+ // Header
183
+ header: {
184
+ padding: 12,
185
+ borderBottomWidth: 1,
186
+ borderBottomColor: macOSColors.border.default + '30'
187
+ },
188
+ headerTitle: {
189
+ fontSize: 11,
190
+ fontWeight: '600',
191
+ color: macOSColors.text.primary,
192
+ textTransform: 'uppercase',
193
+ letterSpacing: 0.5
194
+ },
195
+ // Info grid
196
+ infoGrid: {
197
+ padding: 12,
198
+ gap: 10
199
+ },
200
+ infoItem: {
201
+ flexDirection: 'row',
202
+ justifyContent: 'space-between',
203
+ alignItems: 'center',
204
+ paddingVertical: 4
205
+ },
206
+ infoLabel: {
207
+ fontSize: 12,
208
+ color: macOSColors.text.muted,
209
+ fontWeight: '500'
210
+ },
211
+ infoValue: {
212
+ fontSize: 12,
213
+ color: macOSColors.text.primary,
214
+ fontWeight: '500'
215
+ },
216
+ infoValueHighlight: {
217
+ fontSize: 14,
218
+ fontWeight: '600',
219
+ color: macOSColors.semantic.info
220
+ },
221
+ monoValue: {
222
+ fontFamily: 'monospace'
223
+ },
224
+ // Notices
225
+ notice: {
226
+ flexDirection: 'row',
227
+ alignItems: 'center',
228
+ gap: 8,
229
+ padding: 10,
230
+ margin: 12,
231
+ marginTop: 0,
232
+ backgroundColor: macOSColors.semantic.success + '10',
233
+ borderRadius: 8,
234
+ borderWidth: 1,
235
+ borderColor: macOSColors.semantic.success + '30'
236
+ },
237
+ noticeWarning: {
238
+ backgroundColor: macOSColors.semantic.warning + '10',
239
+ borderColor: macOSColors.semantic.warning + '30'
240
+ },
241
+ noticeIcon: {
242
+ fontSize: 14
243
+ },
244
+ noticeText: {
245
+ flex: 1,
246
+ fontSize: 11,
247
+ color: macOSColors.semantic.success,
248
+ lineHeight: 16
249
+ },
250
+ noticeTextWarning: {
251
+ color: macOSColors.semantic.warning
252
+ }
253
+ });
@@ -0,0 +1,414 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * MMKVInstanceSelector Component
5
+ *
6
+ * Dropdown selector for choosing between multiple MMKV instances.
7
+ * Shows instance ID, key count, and metadata badges (encrypted, read-only).
8
+ *
9
+ * Used in GameUIStorageBrowser when storage type filter is set to "mmkv".
10
+ */
11
+
12
+ import { useState } from 'react';
13
+ import { View, Text, StyleSheet, TouchableOpacity, ScrollView, Modal } from 'react-native';
14
+ import { macOSColors } from '@buoy-gg/shared-ui';
15
+ import { useMMKVInstances } from '../hooks/useMMKVInstances';
16
+ import { isMMKVAvailable, getMMKVUnavailableMessage } from '../utils/mmkvAvailability';
17
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
+ /**
19
+ * MMKV Instance Selector Component
20
+ *
21
+ * Displays a dropdown to select between registered MMKV instances.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * function MyStorageUI() {
26
+ * const [selectedInstance, setSelectedInstance] = useState('mmkv.default');
27
+ *
28
+ * return (
29
+ * <MMKVInstanceSelector
30
+ * selectedInstanceId={selectedInstance}
31
+ * onSelectInstance={setSelectedInstance}
32
+ * />
33
+ * );
34
+ * }
35
+ * ```
36
+ */
37
+ export function MMKVInstanceSelector({
38
+ selectedInstanceId,
39
+ onSelectInstance,
40
+ showRefreshButton = true
41
+ }) {
42
+ const [isDropdownOpen, setIsDropdownOpen] = useState(false);
43
+ const {
44
+ instances,
45
+ instanceCount,
46
+ refresh
47
+ } = useMMKVInstances(false);
48
+
49
+ // Find the selected instance
50
+ const selectedInstance = instances.find(inst => inst.id === selectedInstanceId);
51
+
52
+ // Handle instance selection
53
+ const handleSelectInstance = instanceId => {
54
+ onSelectInstance(instanceId);
55
+ setIsDropdownOpen(false);
56
+ };
57
+
58
+ // If MMKV is not available, show unavailable message
59
+ if (!isMMKVAvailable()) {
60
+ return /*#__PURE__*/_jsx(View, {
61
+ style: styles.container,
62
+ children: /*#__PURE__*/_jsxs(View, {
63
+ style: styles.unavailableState,
64
+ children: [/*#__PURE__*/_jsx(Text, {
65
+ style: styles.unavailableTitle,
66
+ children: "MMKV Not Available"
67
+ }), /*#__PURE__*/_jsx(Text, {
68
+ style: styles.unavailableDescription,
69
+ children: getMMKVUnavailableMessage()
70
+ })]
71
+ })
72
+ });
73
+ }
74
+
75
+ // If no instances registered, show message
76
+ if (instanceCount === 0) {
77
+ return /*#__PURE__*/_jsx(View, {
78
+ style: styles.container,
79
+ children: /*#__PURE__*/_jsxs(View, {
80
+ style: styles.emptyState,
81
+ children: [/*#__PURE__*/_jsx(Text, {
82
+ style: styles.emptyStateTitle,
83
+ children: "No MMKV Instances Registered"
84
+ }), /*#__PURE__*/_jsx(Text, {
85
+ style: styles.emptyStateDescription,
86
+ children: "Register MMKV instances using registerMMKVInstance() to monitor them in dev tools."
87
+ }), showRefreshButton && /*#__PURE__*/_jsx(TouchableOpacity, {
88
+ style: styles.refreshButton,
89
+ onPress: refresh,
90
+ activeOpacity: 0.7,
91
+ children: /*#__PURE__*/_jsx(Text, {
92
+ style: styles.refreshButtonText,
93
+ children: "\u21BB Refresh"
94
+ })
95
+ })]
96
+ })
97
+ });
98
+ }
99
+ return /*#__PURE__*/_jsxs(View, {
100
+ style: styles.container,
101
+ children: [/*#__PURE__*/_jsxs(TouchableOpacity, {
102
+ style: styles.selectorButton,
103
+ onPress: () => setIsDropdownOpen(true),
104
+ activeOpacity: 0.7,
105
+ children: [/*#__PURE__*/_jsx(View, {
106
+ style: styles.selectorContent,
107
+ children: selectedInstance ? /*#__PURE__*/_jsx(InstanceRow, {
108
+ instance: selectedInstance,
109
+ isSelected: true
110
+ }) : /*#__PURE__*/_jsx(Text, {
111
+ style: styles.placeholderText,
112
+ children: "Select MMKV Instance"
113
+ })
114
+ }), /*#__PURE__*/_jsx(Text, {
115
+ style: styles.dropdownArrow,
116
+ children: "\u25BC"
117
+ })]
118
+ }), /*#__PURE__*/_jsx(Modal, {
119
+ visible: isDropdownOpen,
120
+ transparent: true,
121
+ animationType: "fade",
122
+ onRequestClose: () => setIsDropdownOpen(false),
123
+ children: /*#__PURE__*/_jsx(TouchableOpacity, {
124
+ style: styles.modalOverlay,
125
+ activeOpacity: 1,
126
+ onPress: () => setIsDropdownOpen(false),
127
+ children: /*#__PURE__*/_jsxs(View, {
128
+ style: styles.dropdownContainer,
129
+ children: [/*#__PURE__*/_jsxs(View, {
130
+ style: styles.dropdownHeader,
131
+ children: [/*#__PURE__*/_jsxs(Text, {
132
+ style: styles.dropdownTitle,
133
+ children: ["Select MMKV Instance (", instanceCount, ")"]
134
+ }), showRefreshButton && /*#__PURE__*/_jsx(TouchableOpacity, {
135
+ style: styles.headerRefreshButton,
136
+ onPress: refresh,
137
+ activeOpacity: 0.7,
138
+ children: /*#__PURE__*/_jsx(Text, {
139
+ style: styles.headerRefreshText,
140
+ children: "\u21BB"
141
+ })
142
+ })]
143
+ }), /*#__PURE__*/_jsx(ScrollView, {
144
+ style: styles.dropdownList,
145
+ children: instances.map(instance => /*#__PURE__*/_jsx(TouchableOpacity, {
146
+ style: [styles.dropdownItem, instance.id === selectedInstanceId && styles.dropdownItemSelected],
147
+ onPress: () => handleSelectInstance(instance.id),
148
+ activeOpacity: 0.7,
149
+ children: /*#__PURE__*/_jsx(InstanceRow, {
150
+ instance: instance,
151
+ isSelected: instance.id === selectedInstanceId
152
+ })
153
+ }, instance.id))
154
+ })]
155
+ })
156
+ })
157
+ })]
158
+ });
159
+ }
160
+
161
+ /**
162
+ * Instance Row Component
163
+ *
164
+ * Displays a single MMKV instance with its metadata.
165
+ */
166
+ function InstanceRow({
167
+ instance,
168
+ isSelected
169
+ }) {
170
+ return /*#__PURE__*/_jsxs(View, {
171
+ style: styles.instanceRow,
172
+ children: [/*#__PURE__*/_jsxs(View, {
173
+ style: styles.instanceLeft,
174
+ children: [/*#__PURE__*/_jsx(Text, {
175
+ style: [styles.instanceId, isSelected && styles.instanceIdSelected],
176
+ numberOfLines: 1,
177
+ children: instance.id
178
+ }), /*#__PURE__*/_jsxs(View, {
179
+ style: styles.instanceBadges,
180
+ children: [instance.encrypted && /*#__PURE__*/_jsx(View, {
181
+ style: [styles.badge, styles.badgeEncrypted],
182
+ children: /*#__PURE__*/_jsx(Text, {
183
+ style: styles.badgeText,
184
+ children: "\uD83D\uDD12 Encrypted"
185
+ })
186
+ }), instance.readOnly && /*#__PURE__*/_jsx(View, {
187
+ style: [styles.badge, styles.badgeReadOnly],
188
+ children: /*#__PURE__*/_jsx(Text, {
189
+ style: styles.badgeText,
190
+ children: "\uD83D\uDC41\uFE0F Read-only"
191
+ })
192
+ })]
193
+ })]
194
+ }), /*#__PURE__*/_jsxs(View, {
195
+ style: styles.instanceRight,
196
+ children: [/*#__PURE__*/_jsx(Text, {
197
+ style: styles.keyCount,
198
+ children: instance.keyCount
199
+ }), /*#__PURE__*/_jsx(Text, {
200
+ style: styles.keyCountLabel,
201
+ children: "keys"
202
+ })]
203
+ })]
204
+ });
205
+ }
206
+ const styles = StyleSheet.create({
207
+ container: {
208
+ marginBottom: 12
209
+ },
210
+ // Unavailable state
211
+ unavailableState: {
212
+ backgroundColor: macOSColors.semantic.warning + '15',
213
+ borderRadius: 12,
214
+ padding: 20,
215
+ borderWidth: 1,
216
+ borderColor: macOSColors.semantic.warning + '40',
217
+ alignItems: 'center',
218
+ gap: 12
219
+ },
220
+ unavailableTitle: {
221
+ fontSize: 14,
222
+ fontWeight: '600',
223
+ color: macOSColors.semantic.warning
224
+ },
225
+ unavailableDescription: {
226
+ fontSize: 12,
227
+ color: macOSColors.text.secondary,
228
+ textAlign: 'center',
229
+ lineHeight: 18
230
+ },
231
+ // Empty state
232
+ emptyState: {
233
+ backgroundColor: macOSColors.background.card,
234
+ borderRadius: 12,
235
+ padding: 20,
236
+ borderWidth: 1,
237
+ borderColor: macOSColors.border.default + '50',
238
+ alignItems: 'center',
239
+ gap: 12
240
+ },
241
+ emptyStateTitle: {
242
+ fontSize: 14,
243
+ fontWeight: '600',
244
+ color: macOSColors.text.primary
245
+ },
246
+ emptyStateDescription: {
247
+ fontSize: 12,
248
+ color: macOSColors.text.muted,
249
+ textAlign: 'center',
250
+ lineHeight: 18
251
+ },
252
+ refreshButton: {
253
+ marginTop: 8,
254
+ paddingHorizontal: 16,
255
+ paddingVertical: 8,
256
+ backgroundColor: macOSColors.semantic.info + '20',
257
+ borderRadius: 8,
258
+ borderWidth: 1,
259
+ borderColor: macOSColors.semantic.info + '40'
260
+ },
261
+ refreshButtonText: {
262
+ fontSize: 12,
263
+ fontWeight: '600',
264
+ color: macOSColors.semantic.info
265
+ },
266
+ // Selector button
267
+ selectorButton: {
268
+ backgroundColor: macOSColors.background.card,
269
+ borderRadius: 12,
270
+ borderWidth: 1,
271
+ borderColor: macOSColors.border.default + '50',
272
+ padding: 12,
273
+ flexDirection: 'row',
274
+ alignItems: 'center',
275
+ justifyContent: 'space-between',
276
+ shadowColor: '#000000',
277
+ shadowOpacity: 0.03,
278
+ shadowRadius: 8,
279
+ shadowOffset: {
280
+ width: 0,
281
+ height: 2
282
+ }
283
+ },
284
+ selectorContent: {
285
+ flex: 1
286
+ },
287
+ placeholderText: {
288
+ fontSize: 13,
289
+ color: macOSColors.text.muted,
290
+ fontStyle: 'italic'
291
+ },
292
+ dropdownArrow: {
293
+ fontSize: 10,
294
+ color: macOSColors.text.muted,
295
+ marginLeft: 8
296
+ },
297
+ // Modal overlay
298
+ modalOverlay: {
299
+ flex: 1,
300
+ backgroundColor: 'rgba(0, 0, 0, 0.5)',
301
+ justifyContent: 'center',
302
+ alignItems: 'center',
303
+ padding: 20
304
+ },
305
+ // Dropdown container
306
+ dropdownContainer: {
307
+ backgroundColor: macOSColors.background.card,
308
+ borderRadius: 16,
309
+ borderWidth: 1,
310
+ borderColor: macOSColors.border.default,
311
+ width: '100%',
312
+ maxWidth: 500,
313
+ maxHeight: '70%',
314
+ shadowColor: '#000000',
315
+ shadowOpacity: 0.2,
316
+ shadowRadius: 20,
317
+ shadowOffset: {
318
+ width: 0,
319
+ height: 10
320
+ },
321
+ overflow: 'hidden'
322
+ },
323
+ dropdownHeader: {
324
+ flexDirection: 'row',
325
+ alignItems: 'center',
326
+ justifyContent: 'space-between',
327
+ padding: 16,
328
+ borderBottomWidth: 1,
329
+ borderBottomColor: macOSColors.border.default + '50'
330
+ },
331
+ dropdownTitle: {
332
+ fontSize: 14,
333
+ fontWeight: '600',
334
+ color: macOSColors.text.primary
335
+ },
336
+ headerRefreshButton: {
337
+ padding: 4
338
+ },
339
+ headerRefreshText: {
340
+ fontSize: 18,
341
+ color: macOSColors.semantic.info
342
+ },
343
+ dropdownList: {
344
+ maxHeight: 400
345
+ },
346
+ dropdownItem: {
347
+ padding: 12,
348
+ borderBottomWidth: 1,
349
+ borderBottomColor: macOSColors.border.default + '30'
350
+ },
351
+ dropdownItemSelected: {
352
+ backgroundColor: macOSColors.semantic.info + '10'
353
+ },
354
+ // Instance row
355
+ instanceRow: {
356
+ flexDirection: 'row',
357
+ alignItems: 'center',
358
+ justifyContent: 'space-between',
359
+ gap: 12
360
+ },
361
+ instanceLeft: {
362
+ flex: 1,
363
+ gap: 6
364
+ },
365
+ instanceId: {
366
+ fontSize: 13,
367
+ fontWeight: '500',
368
+ color: macOSColors.text.primary,
369
+ fontFamily: 'monospace'
370
+ },
371
+ instanceIdSelected: {
372
+ fontWeight: '600',
373
+ color: macOSColors.semantic.info
374
+ },
375
+ instanceBadges: {
376
+ flexDirection: 'row',
377
+ flexWrap: 'wrap',
378
+ gap: 6
379
+ },
380
+ badge: {
381
+ paddingHorizontal: 6,
382
+ paddingVertical: 2,
383
+ borderRadius: 4,
384
+ borderWidth: 1
385
+ },
386
+ badgeEncrypted: {
387
+ backgroundColor: macOSColors.semantic.success + '15',
388
+ borderColor: macOSColors.semantic.success + '40'
389
+ },
390
+ badgeReadOnly: {
391
+ backgroundColor: macOSColors.semantic.warning + '15',
392
+ borderColor: macOSColors.semantic.warning + '40'
393
+ },
394
+ badgeText: {
395
+ fontSize: 9,
396
+ fontWeight: '500',
397
+ color: macOSColors.text.secondary
398
+ },
399
+ instanceRight: {
400
+ alignItems: 'flex-end'
401
+ },
402
+ keyCount: {
403
+ fontSize: 16,
404
+ fontWeight: '600',
405
+ color: macOSColors.text.primary,
406
+ fontFamily: 'monospace'
407
+ },
408
+ keyCountLabel: {
409
+ fontSize: 9,
410
+ color: macOSColors.text.muted,
411
+ textTransform: 'uppercase',
412
+ letterSpacing: 0.5
413
+ }
414
+ });