@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,137 @@
1
+ "use strict";
2
+
3
+ import { View, Text, StyleSheet, TouchableOpacity } from "react-native";
4
+ import { Filter, DynamicFilterView, Database, HardDrive, Shield, macOSColors } from "@buoy-gg/shared-ui";
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ export function StorageEventFilterView({
7
+ ignoredPatterns,
8
+ onTogglePattern,
9
+ onAddPattern,
10
+ availableKeys = [],
11
+ enabledStorageTypes,
12
+ onToggleStorageType
13
+ }) {
14
+ const filterConfig = {
15
+ addFilterSection: {
16
+ enabled: true,
17
+ placeholder: "Enter key pattern to hide...",
18
+ title: "KEY FILTERS",
19
+ icon: Filter
20
+ },
21
+ availableItemsSection: {
22
+ enabled: true,
23
+ title: "AVAILABLE EVENT KEYS",
24
+ emptyMessage: "No storage event keys available. Events will appear here once captured.",
25
+ items: availableKeys
26
+ },
27
+ howItWorksSection: {
28
+ enabled: true,
29
+ title: "HOW EVENT FILTERS WORK",
30
+ description: "Patterns hide matching storage keys from the event list. Storage type toggles control which storage backends are monitored.",
31
+ examples: ["• react_buoy → hides keys containing react_buoy", "• @temp → hides @temp_user, @temp_data", "• redux → hides redux-persist:root", "• AsyncStorage → show/hide AsyncStorage events", "• MMKV → show/hide MMKV events"],
32
+ icon: Filter
33
+ },
34
+ onPatternToggle: onTogglePattern,
35
+ onPatternAdd: onAddPattern,
36
+ activePatterns: ignoredPatterns
37
+ };
38
+ return /*#__PURE__*/_jsxs(View, {
39
+ style: styles.container,
40
+ children: [/*#__PURE__*/_jsxs(View, {
41
+ style: styles.storageTypeSection,
42
+ children: [/*#__PURE__*/_jsx(Text, {
43
+ style: styles.sectionTitle,
44
+ children: "STORAGE TYPES"
45
+ }), /*#__PURE__*/_jsxs(View, {
46
+ style: styles.storageTypeButtons,
47
+ children: [/*#__PURE__*/_jsxs(TouchableOpacity, {
48
+ style: [styles.storageTypeButton, enabledStorageTypes.has('async') && styles.storageTypeButtonActive, {
49
+ borderColor: macOSColors.semantic.warning + '40'
50
+ }],
51
+ onPress: () => onToggleStorageType('async'),
52
+ children: [/*#__PURE__*/_jsx(Database, {
53
+ size: 16,
54
+ color: enabledStorageTypes.has('async') ? macOSColors.semantic.warning : macOSColors.text.muted
55
+ }), /*#__PURE__*/_jsx(Text, {
56
+ style: [styles.storageTypeButtonText, enabledStorageTypes.has('async') && {
57
+ color: macOSColors.semantic.warning
58
+ }],
59
+ children: "AsyncStorage"
60
+ })]
61
+ }), /*#__PURE__*/_jsxs(TouchableOpacity, {
62
+ style: [styles.storageTypeButton, enabledStorageTypes.has('mmkv') && styles.storageTypeButtonActive, {
63
+ borderColor: macOSColors.semantic.info + '40'
64
+ }],
65
+ onPress: () => onToggleStorageType('mmkv'),
66
+ children: [/*#__PURE__*/_jsx(HardDrive, {
67
+ size: 16,
68
+ color: enabledStorageTypes.has('mmkv') ? macOSColors.semantic.info : macOSColors.text.muted
69
+ }), /*#__PURE__*/_jsx(Text, {
70
+ style: [styles.storageTypeButtonText, enabledStorageTypes.has('mmkv') && {
71
+ color: macOSColors.semantic.info
72
+ }],
73
+ children: "MMKV"
74
+ })]
75
+ }), /*#__PURE__*/_jsxs(TouchableOpacity, {
76
+ style: [styles.storageTypeButton, enabledStorageTypes.has('secure') && styles.storageTypeButtonActive, {
77
+ borderColor: macOSColors.semantic.success + '40'
78
+ }],
79
+ onPress: () => onToggleStorageType('secure'),
80
+ children: [/*#__PURE__*/_jsx(Shield, {
81
+ size: 16,
82
+ color: enabledStorageTypes.has('secure') ? macOSColors.semantic.success : macOSColors.text.muted
83
+ }), /*#__PURE__*/_jsx(Text, {
84
+ style: [styles.storageTypeButtonText, enabledStorageTypes.has('secure') && {
85
+ color: macOSColors.semantic.success
86
+ }],
87
+ children: "Secure Storage"
88
+ })]
89
+ })]
90
+ })]
91
+ }), /*#__PURE__*/_jsx(DynamicFilterView, {
92
+ ...filterConfig
93
+ })]
94
+ });
95
+ }
96
+ const styles = StyleSheet.create({
97
+ container: {
98
+ flex: 1
99
+ },
100
+ storageTypeSection: {
101
+ padding: 16,
102
+ borderBottomWidth: 1,
103
+ borderBottomColor: macOSColors.border.default
104
+ },
105
+ sectionTitle: {
106
+ fontSize: 11,
107
+ fontWeight: '700',
108
+ color: macOSColors.text.secondary,
109
+ letterSpacing: 0.8,
110
+ marginBottom: 12
111
+ },
112
+ storageTypeButtons: {
113
+ flexDirection: 'row',
114
+ gap: 8
115
+ },
116
+ storageTypeButton: {
117
+ flex: 1,
118
+ flexDirection: 'row',
119
+ alignItems: 'center',
120
+ justifyContent: 'center',
121
+ gap: 6,
122
+ paddingVertical: 10,
123
+ paddingHorizontal: 12,
124
+ backgroundColor: macOSColors.background.input,
125
+ borderRadius: 8,
126
+ borderWidth: 1,
127
+ borderColor: macOSColors.border.default
128
+ },
129
+ storageTypeButtonActive: {
130
+ backgroundColor: macOSColors.background.card
131
+ },
132
+ storageTypeButtonText: {
133
+ fontSize: 11,
134
+ fontWeight: '600',
135
+ color: macOSColors.text.muted
136
+ }
137
+ });
@@ -0,0 +1,354 @@
1
+ "use strict";
2
+
3
+ import { useEffect, useState, useCallback } from "react";
4
+ import { View, Text, StyleSheet, TouchableOpacity, ScrollView } from "react-native";
5
+ import { Play, Pause, Trash2 } from "@buoy-gg/shared-ui";
6
+ import { startListening, stopListening, addListener, isListening as checkIsListening } from "../utils/AsyncStorageListener";
7
+ import { translateStorageAction } from "../utils/storageActionHelpers";
8
+ import { isMMKVAvailable } from "../utils/mmkvAvailability";
9
+
10
+ // Conditionally import MMKV listener
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ let addMMKVListener;
13
+
14
+ // Define type for MMKV events (imported conditionally at runtime)
15
+
16
+ if (isMMKVAvailable()) {
17
+ const mmkvListener = require("../utils/MMKVListener");
18
+ addMMKVListener = mmkvListener.addMMKVListener;
19
+ }
20
+
21
+ // Unified event type that covers both AsyncStorage and MMKV
22
+
23
+ /**
24
+ * Storage event listener component for monitoring AsyncStorage and MMKV operations
25
+ * Follows the Sentry component pattern for consistency
26
+ */
27
+ export function StorageEventListener() {
28
+ const [events, setEvents] = useState([]);
29
+ const [isListening, setIsListening] = useState(false);
30
+ const [isAsyncStorageAvailable, setIsAsyncStorageAvailable] = useState(false);
31
+ useEffect(() => {
32
+ // Component mounted, AsyncStorage is available
33
+ setIsAsyncStorageAvailable(true);
34
+
35
+ // Add listener for AsyncStorage events
36
+ const unsubscribeAsync = addListener(event => {
37
+ setEvents(prev => {
38
+ const newEvents = [{
39
+ ...event,
40
+ storageType: 'async'
41
+ }, ...prev.slice(0, 99)];
42
+ return newEvents;
43
+ });
44
+ });
45
+
46
+ // Add listener for MMKV events (only if available)
47
+ let unsubscribeMMKV = () => {};
48
+ if (isMMKVAvailable() && addMMKVListener) {
49
+ unsubscribeMMKV = addMMKVListener(event => {
50
+ setEvents(prev => {
51
+ const newEvents = [{
52
+ ...event,
53
+ storageType: 'mmkv'
54
+ }, ...prev.slice(0, 99)];
55
+ return newEvents;
56
+ });
57
+ });
58
+ }
59
+
60
+ // Check initial listening state
61
+ const initialState = checkIsListening();
62
+ setIsListening(initialState);
63
+ return () => {
64
+ if (checkIsListening()) {
65
+ stopListening();
66
+ }
67
+ unsubscribeAsync();
68
+ unsubscribeMMKV();
69
+ };
70
+ }, []);
71
+ const handleToggleListening = useCallback(async () => {
72
+ if (!isAsyncStorageAvailable) {
73
+ return;
74
+ }
75
+ if (isListening) {
76
+ // Stopping listener
77
+ stopListening();
78
+ setIsListening(false);
79
+ } else {
80
+ // Starting listener
81
+ await startListening();
82
+ setIsListening(true);
83
+ }
84
+ }, [isListening, isAsyncStorageAvailable]);
85
+ const handleClearEvents = useCallback(() => {
86
+ // Clearing all events
87
+ setEvents([]);
88
+ }, []);
89
+ const formatEventData = event => {
90
+ if (!event.data) return "";
91
+
92
+ // MMKV events
93
+ if (event.storageType === 'mmkv') {
94
+ const mmkvEvent = event;
95
+
96
+ // Show instance ID for MMKV events
97
+ const instancePrefix = `[${mmkvEvent.instanceId}] `;
98
+ if (mmkvEvent.action.startsWith('set.') || mmkvEvent.action.startsWith('get.') || mmkvEvent.action === 'delete') {
99
+ const keyInfo = mmkvEvent.data?.key ? `${mmkvEvent.data.key}` : "";
100
+ const typeInfo = mmkvEvent.data?.valueType ? ` (${mmkvEvent.data.valueType})` : "";
101
+ return instancePrefix + keyInfo + typeInfo;
102
+ }
103
+ if (mmkvEvent.action === 'clearAll') {
104
+ return instancePrefix + "All keys";
105
+ }
106
+ return instancePrefix;
107
+ }
108
+
109
+ // AsyncStorage events
110
+ if (event.action === "setItem" || event.action === "removeItem" || event.action === "mergeItem") {
111
+ return event.data.key || "";
112
+ }
113
+ if (event.action === "multiSet" || event.action === "multiMerge") {
114
+ return `${event.data.pairs?.length || 0} pairs`;
115
+ }
116
+ if (event.action === "multiRemove") {
117
+ return `${event.data.keys?.length || 0} keys`;
118
+ }
119
+ if (event.action === "clear") {
120
+ return "All storage";
121
+ }
122
+ return "";
123
+ };
124
+ const getActionColor = action => {
125
+ // MMKV actions
126
+ if (action.startsWith('set.')) {
127
+ return "#10B981"; // Green for writes
128
+ }
129
+ if (action.startsWith('get.')) {
130
+ return "#F59E0B"; // Orange for reads
131
+ }
132
+ if (action === 'delete' || action === 'clearAll') {
133
+ return "#EF4444"; // Red for deletes
134
+ }
135
+
136
+ // AsyncStorage actions
137
+ switch (action) {
138
+ case "setItem":
139
+ case "multiSet":
140
+ return "#10B981";
141
+ // Green for write
142
+ case "removeItem":
143
+ case "multiRemove":
144
+ case "clear":
145
+ return "#EF4444";
146
+ // Red for delete
147
+ case "mergeItem":
148
+ case "multiMerge":
149
+ return "#3B82F6";
150
+ // Blue for merge
151
+ default:
152
+ return "#6B7280";
153
+ }
154
+ };
155
+ if (!isAsyncStorageAvailable) {
156
+ return null; // Don't show component if AsyncStorage isn't available
157
+ }
158
+ return /*#__PURE__*/_jsxs(View, {
159
+ style: styles.container,
160
+ children: [/*#__PURE__*/_jsxs(View, {
161
+ style: styles.header,
162
+ children: [/*#__PURE__*/_jsxs(View, {
163
+ style: styles.headerLeft,
164
+ children: [/*#__PURE__*/_jsx(Text, {
165
+ style: styles.title,
166
+ children: "Storage Events"
167
+ }), /*#__PURE__*/_jsxs(View, {
168
+ style: styles.statsContainer,
169
+ children: [/*#__PURE__*/_jsx(Text, {
170
+ style: styles.statsText,
171
+ children: events.length
172
+ }), isListening && /*#__PURE__*/_jsx(View, {
173
+ style: styles.listeningIndicator
174
+ })]
175
+ })]
176
+ }), /*#__PURE__*/_jsxs(View, {
177
+ style: styles.headerActions,
178
+ children: [/*#__PURE__*/_jsx(TouchableOpacity, {
179
+ "sentry-label": "ignore toggle listening",
180
+ onPress: handleToggleListening,
181
+ style: [styles.actionButton, isListening ? styles.stopButton : styles.startButton],
182
+ accessibilityLabel: isListening ? "Stop listening" : "Start listening",
183
+ children: isListening ? /*#__PURE__*/_jsx(Pause, {
184
+ size: 14,
185
+ color: "#EF4444"
186
+ }) : /*#__PURE__*/_jsx(Play, {
187
+ size: 14,
188
+ color: "#10B981"
189
+ })
190
+ }), /*#__PURE__*/_jsx(TouchableOpacity, {
191
+ "sentry-label": "ignore clear events",
192
+ onPress: handleClearEvents,
193
+ style: styles.actionButton,
194
+ accessibilityLabel: "Clear events",
195
+ disabled: events.length === 0,
196
+ children: /*#__PURE__*/_jsx(Trash2, {
197
+ size: 14,
198
+ color: events.length > 0 ? "#6B7280" : "#374151"
199
+ })
200
+ })]
201
+ })]
202
+ }), /*#__PURE__*/_jsx(ScrollView, {
203
+ style: styles.eventsList,
204
+ nestedScrollEnabled: true,
205
+ showsVerticalScrollIndicator: false,
206
+ "sentry-label": "ignore event list scroll",
207
+ children: events.length === 0 ? /*#__PURE__*/_jsx(View, {
208
+ style: styles.emptyState,
209
+ children: /*#__PURE__*/_jsx(Text, {
210
+ style: styles.emptyText,
211
+ children: isListening ? "Waiting for storage operations..." : "Start listening to capture events"
212
+ })
213
+ }) : events.map((event, index) => /*#__PURE__*/_jsxs(View, {
214
+ style: styles.eventItem,
215
+ children: [/*#__PURE__*/_jsxs(View, {
216
+ style: styles.eventLeft,
217
+ children: [/*#__PURE__*/_jsx(Text, {
218
+ style: [styles.eventAction, {
219
+ color: getActionColor(event.action)
220
+ }],
221
+ children: translateStorageAction(event.action)
222
+ }), /*#__PURE__*/_jsx(Text, {
223
+ style: styles.eventData,
224
+ numberOfLines: 1,
225
+ children: formatEventData(event)
226
+ })]
227
+ }), /*#__PURE__*/_jsx(Text, {
228
+ style: styles.eventTime,
229
+ children: event.timestamp.toLocaleTimeString([], {
230
+ hour: "2-digit",
231
+ minute: "2-digit",
232
+ second: "2-digit"
233
+ })
234
+ })]
235
+ }, `${event.timestamp.getTime()}-${index}`))
236
+ })]
237
+ });
238
+ }
239
+ const styles = StyleSheet.create({
240
+ container: {
241
+ backgroundColor: "rgba(255, 255, 255, 0.03)",
242
+ borderRadius: 8,
243
+ borderWidth: 1,
244
+ borderColor: "rgba(255, 255, 255, 0.08)",
245
+ marginBottom: 12,
246
+ maxHeight: 200
247
+ },
248
+ header: {
249
+ flexDirection: "row",
250
+ alignItems: "center",
251
+ justifyContent: "space-between",
252
+ paddingHorizontal: 12,
253
+ paddingVertical: 8,
254
+ borderBottomWidth: 1,
255
+ borderBottomColor: "rgba(255, 255, 255, 0.06)"
256
+ },
257
+ headerLeft: {
258
+ flexDirection: "row",
259
+ alignItems: "center",
260
+ gap: 8
261
+ },
262
+ title: {
263
+ fontSize: 12,
264
+ fontWeight: "500",
265
+ color: "#9CA3AF",
266
+ textTransform: "uppercase",
267
+ letterSpacing: 0.5
268
+ },
269
+ statsContainer: {
270
+ flexDirection: "row",
271
+ alignItems: "center",
272
+ gap: 6,
273
+ backgroundColor: "rgba(0, 0, 0, 0.2)",
274
+ paddingHorizontal: 8,
275
+ paddingVertical: 2,
276
+ borderRadius: 10
277
+ },
278
+ statsText: {
279
+ fontSize: 11,
280
+ color: "#6B7280",
281
+ fontWeight: "500"
282
+ },
283
+ listeningIndicator: {
284
+ width: 6,
285
+ height: 6,
286
+ borderRadius: 3,
287
+ backgroundColor: "#10B981"
288
+ },
289
+ headerActions: {
290
+ flexDirection: "row",
291
+ alignItems: "center",
292
+ gap: 6
293
+ },
294
+ actionButton: {
295
+ width: 28,
296
+ height: 28,
297
+ borderRadius: 6,
298
+ backgroundColor: "rgba(255, 255, 255, 0.03)",
299
+ borderWidth: 1,
300
+ borderColor: "rgba(255, 255, 255, 0.08)",
301
+ alignItems: "center",
302
+ justifyContent: "center"
303
+ },
304
+ startButton: {
305
+ backgroundColor: "rgba(16, 185, 129, 0.1)",
306
+ borderColor: "rgba(16, 185, 129, 0.2)"
307
+ },
308
+ stopButton: {
309
+ backgroundColor: "rgba(239, 68, 68, 0.1)",
310
+ borderColor: "rgba(239, 68, 68, 0.2)"
311
+ },
312
+ eventsList: {
313
+ maxHeight: 150
314
+ },
315
+ emptyState: {
316
+ padding: 20,
317
+ alignItems: "center"
318
+ },
319
+ emptyText: {
320
+ fontSize: 11,
321
+ color: "#6B7280",
322
+ fontStyle: "italic"
323
+ },
324
+ eventItem: {
325
+ flexDirection: "row",
326
+ alignItems: "center",
327
+ justifyContent: "space-between",
328
+ paddingHorizontal: 12,
329
+ paddingVertical: 6,
330
+ borderBottomWidth: 1,
331
+ borderBottomColor: "rgba(255, 255, 255, 0.03)"
332
+ },
333
+ eventLeft: {
334
+ flex: 1,
335
+ flexDirection: "row",
336
+ alignItems: "center",
337
+ gap: 8,
338
+ marginRight: 8
339
+ },
340
+ eventAction: {
341
+ fontSize: 11,
342
+ fontWeight: "600",
343
+ minWidth: 60
344
+ },
345
+ eventData: {
346
+ fontSize: 11,
347
+ color: "#9CA3AF",
348
+ flex: 1
349
+ },
350
+ eventTime: {
351
+ fontSize: 10,
352
+ color: "#6B7280"
353
+ }
354
+ });
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ import { Database, CyberpunkSectionButton } from "@buoy-gg/shared-ui";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ export function StorageEventsSection({
6
+ onPress,
7
+ eventCount = 0
8
+ }) {
9
+ const subtitle = eventCount > 0 ? `${eventCount} events` : "Monitoring";
10
+ return /*#__PURE__*/_jsx(CyberpunkSectionButton, {
11
+ id: "storage-events",
12
+ title: "EVENTS",
13
+ subtitle: subtitle,
14
+ icon: Database,
15
+ iconColor: "#00E5FF",
16
+ iconBackgroundColor: "rgba(0, 229, 255, 0.1)",
17
+ onPress: onPress,
18
+ index: 3
19
+ });
20
+ }