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