@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,221 @@
1
+ "use strict";
2
+
3
+ import { useState } from "react";
4
+ import { View, Text, StyleSheet, TouchableOpacity, Alert } from "react-native";
5
+ import { Trash2, CopyButton, CheckSquare, ProUpgradeModal } from "@buoy-gg/shared-ui";
6
+ import { macOSColors } from "@buoy-gg/shared-ui";
7
+ import AsyncStorage from "@react-native-async-storage/async-storage";
8
+
9
+ // Lazy load the license hooks to avoid circular dependencies
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ let _useIsPro = null;
12
+ let _licenseLoadAttempted = false;
13
+ function loadLicenseModule() {
14
+ if (_licenseLoadAttempted) return;
15
+ _licenseLoadAttempted = true;
16
+ try {
17
+ const mod = require("@buoy-gg/license");
18
+ if (mod) {
19
+ _useIsPro = mod.useIsPro ?? null;
20
+ }
21
+ } catch {
22
+ // License package not available
23
+ }
24
+ }
25
+ function getUseIsPro() {
26
+ loadLicenseModule();
27
+ return _useIsPro ?? (() => false);
28
+ }
29
+ export function SelectionActionBar({
30
+ selectedKeys,
31
+ mmkvInstances,
32
+ onDeleteComplete,
33
+ onSelectAll,
34
+ onClearSelection,
35
+ totalVisibleKeys
36
+ }) {
37
+ const [showUpgradeModal, setShowUpgradeModal] = useState(false);
38
+
39
+ // Check Pro status internally
40
+ const useIsPro = getUseIsPro();
41
+ const isPro = useIsPro();
42
+ const selectedCount = selectedKeys.length;
43
+ const allSelected = selectedCount === totalVisibleKeys && totalVisibleKeys > 0;
44
+
45
+ // Generate copy data for selected keys
46
+ const getCopyData = () => {
47
+ const data = {};
48
+ selectedKeys.forEach(key => {
49
+ const prefix = key.instanceId ? `[${key.storageType}:${key.instanceId}]` : `[${key.storageType}]`;
50
+ data[`${prefix} ${key.key}`] = key.value;
51
+ });
52
+ return {
53
+ selectedCount,
54
+ keys: data,
55
+ timestamp: new Date().toISOString()
56
+ };
57
+ };
58
+
59
+ // Handle delete selected keys
60
+ const handleDeleteSelected = () => {
61
+ if (selectedCount === 0) return;
62
+
63
+ // Gate delete behind Pro
64
+ if (!isPro) {
65
+ setShowUpgradeModal(true);
66
+ return;
67
+ }
68
+ Alert.alert("Delete Selected Keys", `Delete ${selectedCount} selected key${selectedCount > 1 ? "s" : ""}? This cannot be undone.`, [{
69
+ text: "Cancel",
70
+ style: "cancel"
71
+ }, {
72
+ text: "Delete",
73
+ style: "destructive",
74
+ onPress: async () => {
75
+ try {
76
+ // Group keys by storage type
77
+ const asyncKeys = selectedKeys.filter(k => k.storageType === "async");
78
+ const mmkvKeys = selectedKeys.filter(k => k.storageType === "mmkv");
79
+
80
+ // Delete AsyncStorage keys
81
+ if (asyncKeys.length > 0) {
82
+ await AsyncStorage.multiRemove(asyncKeys.map(k => k.key));
83
+ }
84
+
85
+ // Delete MMKV keys
86
+ if (mmkvKeys.length > 0) {
87
+ // Group by instance
88
+ const byInstance = {};
89
+ mmkvKeys.forEach(k => {
90
+ const instanceId = k.instanceId || "default";
91
+ if (!byInstance[instanceId]) byInstance[instanceId] = [];
92
+ byInstance[instanceId].push(k.key);
93
+ });
94
+
95
+ // Delete from each instance
96
+ Object.entries(byInstance).forEach(([instanceId, keys]) => {
97
+ const inst = mmkvInstances.find(i => i.id === instanceId);
98
+ if (inst) {
99
+ keys.forEach(key => inst.instance.delete(key));
100
+ }
101
+ });
102
+ }
103
+ onDeleteComplete?.();
104
+ } catch (error) {
105
+ Alert.alert("Error", `Failed to delete keys: ${error}`);
106
+ }
107
+ }
108
+ }]);
109
+ };
110
+ if (selectedCount === 0) {
111
+ return null;
112
+ }
113
+ return /*#__PURE__*/_jsxs(View, {
114
+ style: styles.container,
115
+ children: [/*#__PURE__*/_jsxs(View, {
116
+ style: styles.leftSection,
117
+ children: [/*#__PURE__*/_jsxs(TouchableOpacity, {
118
+ style: styles.selectAllButton,
119
+ onPress: allSelected ? onClearSelection : onSelectAll,
120
+ children: [/*#__PURE__*/_jsx(CheckSquare, {
121
+ size: 14,
122
+ color: allSelected ? macOSColors.semantic.info : macOSColors.text.secondary
123
+ }), /*#__PURE__*/_jsx(Text, {
124
+ style: styles.selectAllText,
125
+ children: allSelected ? "Deselect All" : "Select All"
126
+ })]
127
+ }), /*#__PURE__*/_jsx(View, {
128
+ style: styles.countBadge,
129
+ children: /*#__PURE__*/_jsxs(Text, {
130
+ style: styles.countText,
131
+ children: [selectedCount, " selected"]
132
+ })
133
+ })]
134
+ }), /*#__PURE__*/_jsxs(View, {
135
+ style: styles.actionsSection,
136
+ children: [/*#__PURE__*/_jsx(CopyButton, {
137
+ value: getCopyData(),
138
+ size: 14,
139
+ buttonStyle: styles.actionButton,
140
+ colors: {
141
+ idle: macOSColors.semantic.info,
142
+ success: macOSColors.semantic.success,
143
+ error: macOSColors.semantic.error
144
+ }
145
+ }), /*#__PURE__*/_jsx(TouchableOpacity, {
146
+ style: styles.actionButton,
147
+ onPress: handleDeleteSelected,
148
+ children: /*#__PURE__*/_jsx(Trash2, {
149
+ size: 14,
150
+ color: macOSColors.semantic.error
151
+ })
152
+ })]
153
+ }), /*#__PURE__*/_jsx(ProUpgradeModal, {
154
+ visible: showUpgradeModal,
155
+ onClose: () => setShowUpgradeModal(false),
156
+ featureName: "Storage Editing"
157
+ })]
158
+ });
159
+ }
160
+ const styles = StyleSheet.create({
161
+ container: {
162
+ flexDirection: "row",
163
+ alignItems: "center",
164
+ justifyContent: "space-between",
165
+ backgroundColor: macOSColors.semantic.info + "15",
166
+ borderRadius: 8,
167
+ borderWidth: 1,
168
+ borderColor: macOSColors.semantic.info + "30",
169
+ paddingHorizontal: 12,
170
+ paddingVertical: 8,
171
+ marginBottom: 10
172
+ },
173
+ leftSection: {
174
+ flexDirection: "row",
175
+ alignItems: "center",
176
+ gap: 12
177
+ },
178
+ selectAllButton: {
179
+ flexDirection: "row",
180
+ alignItems: "center",
181
+ gap: 6,
182
+ paddingVertical: 4,
183
+ paddingHorizontal: 8,
184
+ backgroundColor: macOSColors.background.card,
185
+ borderRadius: 6,
186
+ borderWidth: 1,
187
+ borderColor: macOSColors.border.default
188
+ },
189
+ selectAllText: {
190
+ fontSize: 11,
191
+ fontWeight: "600",
192
+ color: macOSColors.text.secondary
193
+ },
194
+ countBadge: {
195
+ backgroundColor: macOSColors.semantic.info + "20",
196
+ paddingHorizontal: 8,
197
+ paddingVertical: 4,
198
+ borderRadius: 6
199
+ },
200
+ countText: {
201
+ fontSize: 11,
202
+ fontWeight: "700",
203
+ color: macOSColors.semantic.info,
204
+ fontFamily: "monospace"
205
+ },
206
+ actionsSection: {
207
+ flexDirection: "row",
208
+ alignItems: "center",
209
+ gap: 8
210
+ },
211
+ actionButton: {
212
+ width: 28,
213
+ height: 28,
214
+ alignItems: "center",
215
+ justifyContent: "center",
216
+ borderRadius: 6,
217
+ backgroundColor: macOSColors.background.card,
218
+ borderWidth: 1,
219
+ borderColor: macOSColors.border.default
220
+ }
221
+ });
@@ -0,0 +1,236 @@
1
+ "use strict";
2
+
3
+ import { useState } from "react";
4
+ import { View, Text, StyleSheet, TouchableOpacity, Alert } from "react-native";
5
+ import { Trash2, CopyButton, SquareDashed, X, ProUpgradeModal } from "@buoy-gg/shared-ui";
6
+ import { macOSColors } from "@buoy-gg/shared-ui";
7
+ import AsyncStorage from "@react-native-async-storage/async-storage";
8
+
9
+ // Lazy load the license hooks to avoid circular dependencies
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ let _useIsPro = null;
12
+ let _licenseLoadAttempted = false;
13
+ function loadLicenseModule() {
14
+ if (_licenseLoadAttempted) return;
15
+ _licenseLoadAttempted = true;
16
+ try {
17
+ const mod = require("@buoy-gg/license");
18
+ if (mod) {
19
+ _useIsPro = mod.useIsPro ?? null;
20
+ }
21
+ } catch {
22
+ // License package not available
23
+ }
24
+ }
25
+ function getUseIsPro() {
26
+ loadLicenseModule();
27
+ return _useIsPro ?? (() => false);
28
+ }
29
+ export function StorageActionButtons({
30
+ copyValue,
31
+ mmkvInstances = [],
32
+ activeStorageType = "all",
33
+ onClearComplete,
34
+ isSelectMode = false,
35
+ onToggleSelectMode,
36
+ selectedCount = 0
37
+ }) {
38
+ const [showUpgradeModal, setShowUpgradeModal] = useState(false);
39
+
40
+ // Check Pro status internally
41
+ const useIsPro = getUseIsPro();
42
+ const isPro = useIsPro();
43
+ const handleClearAsyncStorage = () => {
44
+ // Gate clear behind Pro
45
+ if (!isPro) {
46
+ setShowUpgradeModal(true);
47
+ return;
48
+ }
49
+ Alert.alert("Clear AsyncStorage", "Delete all AsyncStorage keys? This cannot be undone.", [{
50
+ text: "Cancel",
51
+ style: "cancel"
52
+ }, {
53
+ text: "Clear",
54
+ style: "destructive",
55
+ onPress: async () => {
56
+ try {
57
+ await AsyncStorage.clear();
58
+ onClearComplete?.();
59
+ } catch (error) {
60
+ Alert.alert("Error", `Failed: ${error}`);
61
+ }
62
+ }
63
+ }]);
64
+ };
65
+ const handleClearMMKV = (instanceId, instanceName) => {
66
+ // Gate clear behind Pro
67
+ if (!isPro) {
68
+ setShowUpgradeModal(true);
69
+ return;
70
+ }
71
+ Alert.alert(`Clear ${instanceName}`, `Delete all keys from ${instanceName}? This cannot be undone.`, [{
72
+ text: "Cancel",
73
+ style: "cancel"
74
+ }, {
75
+ text: "Clear",
76
+ style: "destructive",
77
+ onPress: () => {
78
+ try {
79
+ const inst = mmkvInstances.find(i => i.id === instanceId);
80
+ if (inst) {
81
+ inst.instance.clearAll();
82
+ onClearComplete?.();
83
+ }
84
+ } catch (error) {
85
+ Alert.alert("Error", `Failed: ${error}`);
86
+ }
87
+ }
88
+ }]);
89
+ };
90
+ const handleClearAllMMKV = () => {
91
+ // Gate clear behind Pro
92
+ if (!isPro) {
93
+ setShowUpgradeModal(true);
94
+ return;
95
+ }
96
+ Alert.alert("Clear All MMKV", `Delete all keys from ${mmkvInstances.length} instances? This cannot be undone.`, [{
97
+ text: "Cancel",
98
+ style: "cancel"
99
+ }, {
100
+ text: "Clear All",
101
+ style: "destructive",
102
+ onPress: () => {
103
+ try {
104
+ mmkvInstances.forEach(inst => inst.instance.clearAll());
105
+ onClearComplete?.();
106
+ } catch (error) {
107
+ Alert.alert("Error", `Failed: ${error}`);
108
+ }
109
+ }
110
+ }]);
111
+ };
112
+ const handleClearAll = () => {
113
+ // Gate clear behind Pro
114
+ if (!isPro) {
115
+ setShowUpgradeModal(true);
116
+ return;
117
+ }
118
+ Alert.alert("Clear All Storage", "Delete all storage data? This cannot be undone.", [{
119
+ text: "Cancel",
120
+ style: "cancel"
121
+ }, {
122
+ text: "Clear All",
123
+ style: "destructive",
124
+ onPress: async () => {
125
+ try {
126
+ await AsyncStorage.clear();
127
+ mmkvInstances.forEach(inst => inst.instance.clearAll());
128
+ onClearComplete?.();
129
+ } catch (error) {
130
+ Alert.alert("Error", `Failed: ${error}`);
131
+ }
132
+ }
133
+ }]);
134
+ };
135
+ const showAsyncActions = activeStorageType === "all" || activeStorageType === "async";
136
+ const showMMKVActions = activeStorageType === "all" || activeStorageType === "mmkv";
137
+
138
+ // Determine which clear actions to show based on active filter
139
+ const showClearAll = activeStorageType === "all";
140
+ const showClearAsync = showAsyncActions && !showClearAll;
141
+ const showClearMMKVIndividual = showMMKVActions && !showClearAll;
142
+ const showClearAllMMKV = showMMKVActions && mmkvInstances.length > 1 && !showClearAll;
143
+ return /*#__PURE__*/_jsxs(View, {
144
+ style: styles.container,
145
+ children: [onToggleSelectMode && /*#__PURE__*/_jsx(TouchableOpacity, {
146
+ onPress: onToggleSelectMode,
147
+ style: [styles.actionButton, isSelectMode && styles.actionButtonActive],
148
+ children: isSelectMode ? /*#__PURE__*/_jsxs(View, {
149
+ style: styles.selectModeActiveContainer,
150
+ children: [/*#__PURE__*/_jsx(X, {
151
+ size: 14,
152
+ color: macOSColors.semantic.info
153
+ }), selectedCount > 0 && /*#__PURE__*/_jsx(Text, {
154
+ style: styles.selectedCountText,
155
+ children: selectedCount
156
+ })]
157
+ }) : /*#__PURE__*/_jsx(SquareDashed, {
158
+ size: 16,
159
+ color: macOSColors.text.secondary
160
+ })
161
+ }), !isSelectMode && /*#__PURE__*/_jsx(CopyButton, {
162
+ value: copyValue,
163
+ size: 16,
164
+ buttonStyle: styles.actionButton,
165
+ colors: {
166
+ idle: macOSColors.text.secondary,
167
+ success: macOSColors.semantic.success,
168
+ error: macOSColors.semantic.error
169
+ }
170
+ }), !isSelectMode && showClearAll && /*#__PURE__*/_jsx(TouchableOpacity, {
171
+ onPress: handleClearAll,
172
+ style: styles.actionButton,
173
+ children: /*#__PURE__*/_jsx(Trash2, {
174
+ size: 16,
175
+ color: macOSColors.semantic.error
176
+ })
177
+ }), !isSelectMode && showClearAsync && /*#__PURE__*/_jsx(TouchableOpacity, {
178
+ onPress: handleClearAsyncStorage,
179
+ style: styles.actionButton,
180
+ children: /*#__PURE__*/_jsx(Trash2, {
181
+ size: 16,
182
+ color: macOSColors.semantic.error
183
+ })
184
+ }), !isSelectMode && showClearAllMMKV && /*#__PURE__*/_jsx(TouchableOpacity, {
185
+ onPress: handleClearAllMMKV,
186
+ style: styles.actionButton,
187
+ children: /*#__PURE__*/_jsx(Trash2, {
188
+ size: 16,
189
+ color: macOSColors.semantic.error
190
+ })
191
+ }), !isSelectMode && showClearMMKVIndividual && mmkvInstances.length === 1 && /*#__PURE__*/_jsx(TouchableOpacity, {
192
+ onPress: () => handleClearMMKV(mmkvInstances[0].id, mmkvInstances[0].id),
193
+ style: styles.actionButton,
194
+ children: /*#__PURE__*/_jsx(Trash2, {
195
+ size: 16,
196
+ color: macOSColors.semantic.error
197
+ })
198
+ }), /*#__PURE__*/_jsx(ProUpgradeModal, {
199
+ visible: showUpgradeModal,
200
+ onClose: () => setShowUpgradeModal(false),
201
+ featureName: "Storage Editing"
202
+ })]
203
+ });
204
+ }
205
+ const styles = StyleSheet.create({
206
+ container: {
207
+ flexDirection: "row",
208
+ alignItems: "center",
209
+ gap: 8
210
+ },
211
+ actionButton: {
212
+ width: 32,
213
+ height: 32,
214
+ alignItems: "center",
215
+ justifyContent: "center",
216
+ borderRadius: 6,
217
+ backgroundColor: macOSColors.background.input,
218
+ borderWidth: 1,
219
+ borderColor: macOSColors.border.default
220
+ },
221
+ actionButtonActive: {
222
+ backgroundColor: macOSColors.semantic.info + "20",
223
+ borderColor: macOSColors.semantic.info + "40"
224
+ },
225
+ selectModeActiveContainer: {
226
+ flexDirection: "row",
227
+ alignItems: "center",
228
+ gap: 2
229
+ },
230
+ selectedCountText: {
231
+ fontSize: 10,
232
+ fontWeight: "700",
233
+ color: macOSColors.semantic.info,
234
+ fontFamily: "monospace"
235
+ }
236
+ });
@@ -0,0 +1,189 @@
1
+ "use strict";
2
+
3
+ import { View, Text, TouchableOpacity, StyleSheet, Alert } from "react-native";
4
+ import { useState, useCallback } from "react";
5
+ import { clearAllStorageIncludingDevTools } from "../utils/clearAllStorage";
6
+ import { RefreshCw, Trash2, CopyButton, ProUpgradeModal } from "@buoy-gg/shared-ui";
7
+
8
+ // Lazy load the license hooks to avoid circular dependencies
9
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
10
+ let _useIsPro = null;
11
+ let _licenseLoadAttempted = false;
12
+ function loadLicenseModule() {
13
+ if (_licenseLoadAttempted) return;
14
+ _licenseLoadAttempted = true;
15
+ try {
16
+ const mod = require("@buoy-gg/license");
17
+ if (mod) {
18
+ _useIsPro = mod.useIsPro ?? null;
19
+ }
20
+ } catch {
21
+ // License package not available
22
+ }
23
+ }
24
+ function getUseIsPro() {
25
+ loadLicenseModule();
26
+ return _useIsPro ?? (() => false);
27
+ }
28
+ export function StorageActions({
29
+ storageKeys,
30
+ onClearAll,
31
+ onRefresh,
32
+ totalCount
33
+ }) {
34
+ const [isRefreshing, setIsRefreshing] = useState(false);
35
+ const [showUpgradeModal, setShowUpgradeModal] = useState(false);
36
+
37
+ // Check Pro status internally
38
+ const useIsPro = getUseIsPro();
39
+ const isPro = useIsPro();
40
+ const handleRefresh = useCallback(async () => {
41
+ setIsRefreshing(true);
42
+ try {
43
+ await onRefresh();
44
+ } finally {
45
+ setTimeout(() => setIsRefreshing(false), 500);
46
+ }
47
+ }, [onRefresh]);
48
+ const handleClear = () => {
49
+ // Gate clear behind Pro
50
+ if (!isPro) {
51
+ setShowUpgradeModal(true);
52
+ return;
53
+ }
54
+ Alert.alert("Clear Storage", "Choose what to clear:", [{
55
+ text: "Cancel",
56
+ style: "cancel"
57
+ }, {
58
+ text: "Clear App Data",
59
+ onPress: handleClearAppData
60
+ }, {
61
+ text: "Clear Everything",
62
+ style: "destructive",
63
+ onPress: handleClearEverything
64
+ }]);
65
+ };
66
+ const handleClearAppData = async () => {
67
+ try {
68
+ await onClearAll();
69
+ await onRefresh(); // Auto-refresh after clearing
70
+ } catch (error) {
71
+ Alert.alert("Error", `Failed to clear storage: ${error}`);
72
+ }
73
+ };
74
+ const handleClearEverything = async () => {
75
+ // Clear everything directly without extra confirmation
76
+ try {
77
+ await clearAllStorageIncludingDevTools();
78
+ await onRefresh(); // Auto-refresh after clearing
79
+
80
+ // Show success message briefly
81
+ Alert.alert("Success", "All storage cleared including dev tools settings.", [{
82
+ text: "OK"
83
+ }], {
84
+ cancelable: true
85
+ });
86
+ } catch (error) {
87
+ Alert.alert("Error", `Failed to clear all storage: ${error}`);
88
+ }
89
+ };
90
+ return /*#__PURE__*/_jsxs(View, {
91
+ style: styles.headerContainer,
92
+ children: [/*#__PURE__*/_jsx(View, {
93
+ style: styles.leftSection,
94
+ children: /*#__PURE__*/_jsxs(Text, {
95
+ style: styles.keyCount,
96
+ children: [totalCount, " ", totalCount === 1 ? "key" : "keys", " found"]
97
+ })
98
+ }), /*#__PURE__*/_jsxs(View, {
99
+ style: styles.headerActions,
100
+ children: [/*#__PURE__*/_jsx(TouchableOpacity, {
101
+ "sentry-label": "ignore storage refresh button",
102
+ onPress: handleRefresh,
103
+ style: [styles.iconButton, isRefreshing && styles.activeButton],
104
+ accessibilityLabel: "Refresh storage",
105
+ children: /*#__PURE__*/_jsx(RefreshCw, {
106
+ size: 16,
107
+ color: isRefreshing ? "#10B981" : "#9CA3AF"
108
+ })
109
+ }), /*#__PURE__*/_jsx(CopyButton, {
110
+ value: storageKeys,
111
+ size: 16,
112
+ buttonStyle: styles.iconButton,
113
+ colors: {
114
+ idle: "#3B82F6",
115
+ success: "#10B981",
116
+ error: "#F87171"
117
+ }
118
+ }), /*#__PURE__*/_jsx(TouchableOpacity, {
119
+ "sentry-label": "ignore storage clear button",
120
+ onPress: handleClear,
121
+ style: styles.iconButton,
122
+ accessibilityLabel: "Clear storage",
123
+ children: /*#__PURE__*/_jsx(Trash2, {
124
+ size: 16,
125
+ color: "#F87171"
126
+ })
127
+ })]
128
+ }), /*#__PURE__*/_jsx(ProUpgradeModal, {
129
+ visible: showUpgradeModal,
130
+ onClose: () => setShowUpgradeModal(false),
131
+ featureName: "Storage Editing"
132
+ })]
133
+ });
134
+ }
135
+ const styles = StyleSheet.create({
136
+ // Header styles matching Sentry pattern
137
+ headerContainer: {
138
+ flexDirection: "row",
139
+ alignItems: "center",
140
+ justifyContent: "space-between",
141
+ paddingHorizontal: 12,
142
+ paddingVertical: 8,
143
+ backgroundColor: "rgba(255, 255, 255, 0.03)",
144
+ borderRadius: 8,
145
+ marginBottom: 12,
146
+ borderWidth: 1,
147
+ borderColor: "rgba(255, 255, 255, 0.08)"
148
+ },
149
+ leftSection: {
150
+ flexDirection: "row",
151
+ alignItems: "center",
152
+ gap: 8
153
+ },
154
+ keyCount: {
155
+ color: "#9CA3AF",
156
+ fontSize: 12,
157
+ fontWeight: "500"
158
+ },
159
+ copiedBadge: {
160
+ backgroundColor: "#10B981",
161
+ paddingHorizontal: 8,
162
+ paddingVertical: 3,
163
+ borderRadius: 10
164
+ },
165
+ copiedText: {
166
+ color: "#FFFFFF",
167
+ fontSize: 10,
168
+ fontWeight: "600"
169
+ },
170
+ headerActions: {
171
+ flexDirection: "row",
172
+ alignItems: "center",
173
+ gap: 8
174
+ },
175
+ iconButton: {
176
+ width: 32,
177
+ height: 32,
178
+ borderRadius: 6,
179
+ backgroundColor: "rgba(255, 255, 255, 0.03)",
180
+ borderWidth: 1,
181
+ borderColor: "rgba(255, 255, 255, 0.08)",
182
+ alignItems: "center",
183
+ justifyContent: "center"
184
+ },
185
+ activeButton: {
186
+ backgroundColor: "rgba(16, 185, 129, 0.1)",
187
+ borderColor: "rgba(16, 185, 129, 0.2)"
188
+ }
189
+ });
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ import { GameUIStorageBrowser } from "./GameUIStorageBrowser";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ /**
6
+ * Storage browser mode component
7
+ * Displays storage keys with game UI styled interface
8
+ */
9
+ export function StorageBrowserMode({
10
+ requiredStorageKeys = [],
11
+ showFilters = false,
12
+ ignoredPatterns = new Set(),
13
+ onTogglePattern,
14
+ onAddPattern,
15
+ searchQuery = "",
16
+ storageDataRef
17
+ }) {
18
+ return /*#__PURE__*/_jsx(GameUIStorageBrowser, {
19
+ requiredStorageKeys: requiredStorageKeys,
20
+ showFilters: showFilters,
21
+ ignoredPatterns: ignoredPatterns,
22
+ onTogglePattern: onTogglePattern,
23
+ onAddPattern: onAddPattern,
24
+ searchQuery: searchQuery,
25
+ storageDataRef: storageDataRef
26
+ });
27
+ }