@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.
- package/README.md +607 -0
- package/lib/commonjs/index.js +34 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/preset.js +94 -0
- package/lib/commonjs/storage/components/DiffViewer/DiffOptionsPanel.js +356 -0
- package/lib/commonjs/storage/components/DiffViewer/TreeDiffViewer.js +29 -0
- package/lib/commonjs/storage/components/DiffViewer/components/DiffSummary.js +121 -0
- package/lib/commonjs/storage/components/DiffViewer/modes/ThemedSplitView.js +419 -0
- package/lib/commonjs/storage/components/DiffViewer/themes/diffThemes.js +122 -0
- package/lib/commonjs/storage/components/GameUIStorageBrowser.js +924 -0
- package/lib/commonjs/storage/components/GameUIStorageStats.js +746 -0
- package/lib/commonjs/storage/components/MMKVInstanceInfoPanel.js +257 -0
- package/lib/commonjs/storage/components/MMKVInstanceSelector.js +418 -0
- package/lib/commonjs/storage/components/SelectionActionBar.js +224 -0
- package/lib/commonjs/storage/components/StorageActionButtons.js +239 -0
- package/lib/commonjs/storage/components/StorageActions.js +192 -0
- package/lib/commonjs/storage/components/StorageBrowserMode.js +31 -0
- package/lib/commonjs/storage/components/StorageEventDetailContent.js +1025 -0
- package/lib/commonjs/storage/components/StorageEventFilterView.js +141 -0
- package/lib/commonjs/storage/components/StorageEventListener.js +357 -0
- package/lib/commonjs/storage/components/StorageEventsSection.js +24 -0
- package/lib/commonjs/storage/components/StorageFilterCards.js +345 -0
- package/lib/commonjs/storage/components/StorageFilterViewV2.js +42 -0
- package/lib/commonjs/storage/components/StorageKeyCard.js +516 -0
- package/lib/commonjs/storage/components/StorageKeyRow.js +356 -0
- package/lib/commonjs/storage/components/StorageKeySection.js +105 -0
- package/lib/commonjs/storage/components/StorageKeyStats.js +344 -0
- package/lib/commonjs/storage/components/StorageModalWithTabs.js +871 -0
- package/lib/commonjs/storage/components/StorageSection.js +43 -0
- package/lib/commonjs/storage/hooks/useAsyncStorageKeys.js +126 -0
- package/lib/commonjs/storage/hooks/useMMKVInstances.js +221 -0
- package/lib/commonjs/storage/hooks/useMMKVKeys.js +362 -0
- package/lib/commonjs/storage/hooks/useTickEverySecond.js +21 -0
- package/lib/commonjs/storage/index.js +148 -0
- package/lib/commonjs/storage/types.js +5 -0
- package/lib/commonjs/storage/utils/AsyncStorageListener.js +510 -0
- package/lib/commonjs/storage/utils/MMKVInstanceRegistry.js +202 -0
- package/lib/commonjs/storage/utils/MMKVListener.js +380 -0
- package/lib/commonjs/storage/utils/clearAllStorage.js +47 -0
- package/lib/commonjs/storage/utils/index.js +180 -0
- package/lib/commonjs/storage/utils/lineDiff.js +363 -0
- package/lib/commonjs/storage/utils/mmkvAvailability.js +62 -0
- package/lib/commonjs/storage/utils/mmkvTypeDetection.js +139 -0
- package/lib/commonjs/storage/utils/objectDiff.js +157 -0
- package/lib/commonjs/storage/utils/safeAsyncStorage.js +140 -0
- package/lib/commonjs/storage/utils/storageActionHelpers.js +46 -0
- package/lib/commonjs/storage/utils/storageQueryUtils.js +35 -0
- package/lib/commonjs/storage/utils/valueType.js +18 -0
- package/lib/module/index.js +7 -0
- package/lib/module/preset.js +89 -0
- package/lib/module/storage/components/DiffViewer/DiffOptionsPanel.js +352 -0
- package/lib/module/storage/components/DiffViewer/TreeDiffViewer.js +25 -0
- package/lib/module/storage/components/DiffViewer/components/DiffSummary.js +117 -0
- package/lib/module/storage/components/DiffViewer/modes/ThemedSplitView.js +415 -0
- package/lib/module/storage/components/DiffViewer/themes/diffThemes.js +118 -0
- package/lib/module/storage/components/GameUIStorageBrowser.js +922 -0
- package/lib/module/storage/components/GameUIStorageStats.js +742 -0
- package/lib/module/storage/components/MMKVInstanceInfoPanel.js +253 -0
- package/lib/module/storage/components/MMKVInstanceSelector.js +414 -0
- package/lib/module/storage/components/SelectionActionBar.js +221 -0
- package/lib/module/storage/components/StorageActionButtons.js +236 -0
- package/lib/module/storage/components/StorageActions.js +189 -0
- package/lib/module/storage/components/StorageBrowserMode.js +27 -0
- package/lib/module/storage/components/StorageEventDetailContent.js +1020 -0
- package/lib/module/storage/components/StorageEventFilterView.js +137 -0
- package/lib/module/storage/components/StorageEventListener.js +354 -0
- package/lib/module/storage/components/StorageEventsSection.js +20 -0
- package/lib/module/storage/components/StorageFilterCards.js +341 -0
- package/lib/module/storage/components/StorageFilterViewV2.js +38 -0
- package/lib/module/storage/components/StorageKeyCard.js +513 -0
- package/lib/module/storage/components/StorageKeyRow.js +353 -0
- package/lib/module/storage/components/StorageKeySection.js +101 -0
- package/lib/module/storage/components/StorageKeyStats.js +340 -0
- package/lib/module/storage/components/StorageModalWithTabs.js +867 -0
- package/lib/module/storage/components/StorageSection.js +40 -0
- package/lib/module/storage/hooks/useAsyncStorageKeys.js +121 -0
- package/lib/module/storage/hooks/useMMKVInstances.js +216 -0
- package/lib/module/storage/hooks/useMMKVKeys.js +359 -0
- package/lib/module/storage/hooks/useTickEverySecond.js +18 -0
- package/lib/module/storage/index.js +25 -0
- package/lib/module/storage/types.js +3 -0
- package/lib/module/storage/utils/AsyncStorageListener.js +500 -0
- package/lib/module/storage/utils/MMKVInstanceRegistry.js +196 -0
- package/lib/module/storage/utils/MMKVListener.js +367 -0
- package/lib/module/storage/utils/clearAllStorage.js +42 -0
- package/lib/module/storage/utils/index.js +22 -0
- package/lib/module/storage/utils/lineDiff.js +359 -0
- package/lib/module/storage/utils/mmkvAvailability.js +56 -0
- package/lib/module/storage/utils/mmkvTypeDetection.js +133 -0
- package/lib/module/storage/utils/objectDiff.js +153 -0
- package/lib/module/storage/utils/safeAsyncStorage.js +134 -0
- package/lib/module/storage/utils/storageActionHelpers.js +42 -0
- package/lib/module/storage/utils/storageQueryUtils.js +30 -0
- package/lib/module/storage/utils/valueType.js +14 -0
- package/lib/typescript/index.d.ts +3 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/preset.d.ts +90 -0
- package/lib/typescript/preset.d.ts.map +1 -0
- package/lib/typescript/storage/components/DiffViewer/DiffOptionsPanel.d.ts +18 -0
- package/lib/typescript/storage/components/DiffViewer/DiffOptionsPanel.d.ts.map +1 -0
- package/lib/typescript/storage/components/DiffViewer/TreeDiffViewer.d.ts +7 -0
- package/lib/typescript/storage/components/DiffViewer/TreeDiffViewer.d.ts.map +1 -0
- package/lib/typescript/storage/components/DiffViewer/components/DiffSummary.d.ts +12 -0
- package/lib/typescript/storage/components/DiffViewer/components/DiffSummary.d.ts.map +1 -0
- package/lib/typescript/storage/components/DiffViewer/modes/ThemedSplitView.d.ts +13 -0
- package/lib/typescript/storage/components/DiffViewer/modes/ThemedSplitView.d.ts.map +1 -0
- package/lib/typescript/storage/components/DiffViewer/themes/diffThemes.d.ts +64 -0
- package/lib/typescript/storage/components/DiffViewer/themes/diffThemes.d.ts.map +1 -0
- package/lib/typescript/storage/components/GameUIStorageBrowser.d.ts +16 -0
- package/lib/typescript/storage/components/GameUIStorageBrowser.d.ts.map +1 -0
- package/lib/typescript/storage/components/GameUIStorageStats.d.ts +7 -0
- package/lib/typescript/storage/components/GameUIStorageStats.d.ts.map +1 -0
- package/lib/typescript/storage/components/MMKVInstanceInfoPanel.d.ts +42 -0
- package/lib/typescript/storage/components/MMKVInstanceInfoPanel.d.ts.map +1 -0
- package/lib/typescript/storage/components/MMKVInstanceSelector.d.ts +35 -0
- package/lib/typescript/storage/components/MMKVInstanceSelector.d.ts.map +1 -0
- package/lib/typescript/storage/components/SelectionActionBar.d.ts +21 -0
- package/lib/typescript/storage/components/SelectionActionBar.d.ts.map +1 -0
- package/lib/typescript/storage/components/StorageActionButtons.d.ts +21 -0
- package/lib/typescript/storage/components/StorageActionButtons.d.ts.map +1 -0
- package/lib/typescript/storage/components/StorageActions.d.ts +10 -0
- package/lib/typescript/storage/components/StorageActions.d.ts.map +1 -0
- package/lib/typescript/storage/components/StorageBrowserMode.d.ts +18 -0
- package/lib/typescript/storage/components/StorageBrowserMode.d.ts.map +1 -0
- package/lib/typescript/storage/components/StorageEventDetailContent.d.ts +40 -0
- package/lib/typescript/storage/components/StorageEventDetailContent.d.ts.map +1 -0
- package/lib/typescript/storage/components/StorageEventFilterView.d.ts +11 -0
- package/lib/typescript/storage/components/StorageEventFilterView.d.ts.map +1 -0
- package/lib/typescript/storage/components/StorageEventListener.d.ts +6 -0
- package/lib/typescript/storage/components/StorageEventListener.d.ts.map +1 -0
- package/lib/typescript/storage/components/StorageEventsSection.d.ts +7 -0
- package/lib/typescript/storage/components/StorageEventsSection.d.ts.map +1 -0
- package/lib/typescript/storage/components/StorageFilterCards.d.ts +36 -0
- package/lib/typescript/storage/components/StorageFilterCards.d.ts.map +1 -0
- package/lib/typescript/storage/components/StorageFilterViewV2.d.ts +9 -0
- package/lib/typescript/storage/components/StorageFilterViewV2.d.ts.map +1 -0
- package/lib/typescript/storage/components/StorageKeyCard.d.ts +17 -0
- package/lib/typescript/storage/components/StorageKeyCard.d.ts.map +1 -0
- package/lib/typescript/storage/components/StorageKeyRow.d.ts +15 -0
- package/lib/typescript/storage/components/StorageKeyRow.d.ts.map +1 -0
- package/lib/typescript/storage/components/StorageKeySection.d.ts +25 -0
- package/lib/typescript/storage/components/StorageKeySection.d.ts.map +1 -0
- package/lib/typescript/storage/components/StorageKeyStats.d.ts +15 -0
- package/lib/typescript/storage/components/StorageKeyStats.d.ts.map +1 -0
- package/lib/typescript/storage/components/StorageModalWithTabs.d.ts +13 -0
- package/lib/typescript/storage/components/StorageModalWithTabs.d.ts.map +1 -0
- package/lib/typescript/storage/components/StorageSection.d.ts +10 -0
- package/lib/typescript/storage/components/StorageSection.d.ts.map +1 -0
- package/lib/typescript/storage/hooks/useAsyncStorageKeys.d.ts +10 -0
- package/lib/typescript/storage/hooks/useAsyncStorageKeys.d.ts.map +1 -0
- package/lib/typescript/storage/hooks/useMMKVInstances.d.ts +114 -0
- package/lib/typescript/storage/hooks/useMMKVInstances.d.ts.map +1 -0
- package/lib/typescript/storage/hooks/useMMKVKeys.d.ts +94 -0
- package/lib/typescript/storage/hooks/useMMKVKeys.d.ts.map +1 -0
- package/lib/typescript/storage/hooks/useTickEverySecond.d.ts +6 -0
- package/lib/typescript/storage/hooks/useTickEverySecond.d.ts.map +1 -0
- package/lib/typescript/storage/index.d.ts +15 -0
- package/lib/typescript/storage/index.d.ts.map +1 -0
- package/lib/typescript/storage/types.d.ts +41 -0
- package/lib/typescript/storage/types.d.ts.map +1 -0
- package/lib/typescript/storage/utils/AsyncStorageListener.d.ts +195 -0
- package/lib/typescript/storage/utils/AsyncStorageListener.d.ts.map +1 -0
- package/lib/typescript/storage/utils/MMKVInstanceRegistry.d.ts +224 -0
- package/lib/typescript/storage/utils/MMKVInstanceRegistry.d.ts.map +1 -0
- package/lib/typescript/storage/utils/MMKVListener.d.ts +218 -0
- package/lib/typescript/storage/utils/MMKVListener.d.ts.map +1 -0
- package/lib/typescript/storage/utils/clearAllStorage.d.ts +11 -0
- package/lib/typescript/storage/utils/clearAllStorage.d.ts.map +1 -0
- package/lib/typescript/storage/utils/index.d.ts +8 -0
- package/lib/typescript/storage/utils/index.d.ts.map +1 -0
- package/lib/typescript/storage/utils/lineDiff.d.ts +34 -0
- package/lib/typescript/storage/utils/lineDiff.d.ts.map +1 -0
- package/lib/typescript/storage/utils/mmkvAvailability.d.ts +23 -0
- package/lib/typescript/storage/utils/mmkvAvailability.d.ts.map +1 -0
- package/lib/typescript/storage/utils/mmkvTypeDetection.d.ts +71 -0
- package/lib/typescript/storage/utils/mmkvTypeDetection.d.ts.map +1 -0
- package/lib/typescript/storage/utils/objectDiff.d.ts +35 -0
- package/lib/typescript/storage/utils/objectDiff.d.ts.map +1 -0
- package/lib/typescript/storage/utils/safeAsyncStorage.d.ts +56 -0
- package/lib/typescript/storage/utils/safeAsyncStorage.d.ts.map +1 -0
- package/lib/typescript/storage/utils/storageActionHelpers.d.ts +5 -0
- package/lib/typescript/storage/utils/storageActionHelpers.d.ts.map +1 -0
- package/lib/typescript/storage/utils/storageQueryUtils.d.ts +6 -0
- package/lib/typescript/storage/utils/storageQueryUtils.d.ts.map +1 -0
- package/lib/typescript/storage/utils/valueType.d.ts +3 -0
- package/lib/typescript/storage/utils/valueType.d.ts.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
export interface AsyncStorageEvent {
|
|
2
|
+
action: "setItem" | "removeItem" | "mergeItem" | "clear" | "multiSet" | "multiRemove" | "multiMerge";
|
|
3
|
+
timestamp: Date;
|
|
4
|
+
data?: {
|
|
5
|
+
key?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
keys?: string[];
|
|
8
|
+
pairs?: [string, string][];
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export type AsyncStorageEventListener = (event: AsyncStorageEvent) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Singleton class for intercepting and monitoring AsyncStorage operations
|
|
14
|
+
*
|
|
15
|
+
* This class uses method swizzling to intercept all AsyncStorage operations
|
|
16
|
+
* (setItem, removeItem, mergeItem, clear, multiSet, multiRemove, multiMerge)
|
|
17
|
+
* and emits events to registered listeners. It maintains the original functionality
|
|
18
|
+
* while providing observability for debugging and development tools.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // Start listening to all AsyncStorage operations
|
|
23
|
+
* startListening();
|
|
24
|
+
*
|
|
25
|
+
* // Add a listener for storage events
|
|
26
|
+
* const unsubscribe = addListener((event) => {
|
|
27
|
+
* console.log(`${event.action}:`, event.data);
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // Clean up
|
|
31
|
+
* unsubscribe();
|
|
32
|
+
* stopListening();
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @performance Uses method interception rather than polling for zero-overhead when inactive
|
|
36
|
+
* @performance Includes key filtering to prevent dev tools from triggering self-events
|
|
37
|
+
*/
|
|
38
|
+
declare class AsyncStorageListener {
|
|
39
|
+
private listeners;
|
|
40
|
+
private isListening;
|
|
41
|
+
private isInitialized;
|
|
42
|
+
private ignoredKeys;
|
|
43
|
+
private originalSetItem;
|
|
44
|
+
private originalRemoveItem;
|
|
45
|
+
private originalMergeItem;
|
|
46
|
+
private originalClear;
|
|
47
|
+
private originalMultiSet;
|
|
48
|
+
private originalMultiRemove;
|
|
49
|
+
private originalMultiMerge;
|
|
50
|
+
/**
|
|
51
|
+
* Determines if a storage key should be ignored to prevent infinite loops
|
|
52
|
+
*
|
|
53
|
+
* Dev tools often store their own state in AsyncStorage, which would trigger
|
|
54
|
+
* events and cause infinite loops or unnecessary noise.
|
|
55
|
+
*
|
|
56
|
+
* @param key - The storage key to check
|
|
57
|
+
* @returns True if the key should be ignored, false otherwise
|
|
58
|
+
*/
|
|
59
|
+
private shouldIgnoreKey;
|
|
60
|
+
/**
|
|
61
|
+
* Initialize the listener by loading AsyncStorage and storing original methods
|
|
62
|
+
*
|
|
63
|
+
* This method performs safety checks to ensure we don't double-initialize
|
|
64
|
+
* and verifies that AsyncStorage methods haven't already been swizzled.
|
|
65
|
+
*
|
|
66
|
+
* @returns Promise<boolean> - True if initialization succeeded, false otherwise
|
|
67
|
+
*
|
|
68
|
+
* @throws Will log errors if AsyncStorage is already swizzled by another instance
|
|
69
|
+
*/
|
|
70
|
+
private initialize;
|
|
71
|
+
/**
|
|
72
|
+
* Restore original AsyncStorage methods to their unmodified state
|
|
73
|
+
*
|
|
74
|
+
* This method undoes the method swizzling by restoring the original
|
|
75
|
+
* AsyncStorage methods that were saved during initialization.
|
|
76
|
+
*/
|
|
77
|
+
private restoreOriginalMethods;
|
|
78
|
+
/**
|
|
79
|
+
* Emit an AsyncStorage event to all registered listeners
|
|
80
|
+
*
|
|
81
|
+
* @param event - The AsyncStorage event to emit
|
|
82
|
+
*
|
|
83
|
+
* @performance Skips processing when no listeners are registered
|
|
84
|
+
*/
|
|
85
|
+
private emit;
|
|
86
|
+
/**
|
|
87
|
+
* Start intercepting AsyncStorage operations by swizzling methods
|
|
88
|
+
*
|
|
89
|
+
* This method replaces all AsyncStorage methods with wrapped versions
|
|
90
|
+
* that emit events while preserving the original functionality.
|
|
91
|
+
*
|
|
92
|
+
* @throws Will log errors if initialization fails or methods are already swizzled
|
|
93
|
+
*
|
|
94
|
+
* @performance Uses method swizzling for minimal runtime overhead
|
|
95
|
+
* @performance Includes safety checks to prevent double-initialization
|
|
96
|
+
*/
|
|
97
|
+
startListening(): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Stop listening and restore original AsyncStorage methods
|
|
100
|
+
*
|
|
101
|
+
* This method undoes all method swizzling and restores AsyncStorage
|
|
102
|
+
* to its original state.
|
|
103
|
+
*/
|
|
104
|
+
stopListening(): void;
|
|
105
|
+
/**
|
|
106
|
+
* Add a listener for AsyncStorage events
|
|
107
|
+
*
|
|
108
|
+
* @param listener - Callback function to handle AsyncStorage events
|
|
109
|
+
* @returns Unsubscribe function to remove the listener
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const unsubscribe = asyncStorageListener.addListener((event) => {
|
|
114
|
+
* console.log('Storage operation:', event.action, event.data);
|
|
115
|
+
* });
|
|
116
|
+
*
|
|
117
|
+
* // Later, remove the listener
|
|
118
|
+
* unsubscribe();
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
addListener(listener: AsyncStorageEventListener): () => void;
|
|
122
|
+
/**
|
|
123
|
+
* Remove all registered event listeners
|
|
124
|
+
*
|
|
125
|
+
* Clears the internal listeners array, stopping all event notifications.
|
|
126
|
+
*/
|
|
127
|
+
removeAllListeners(): void;
|
|
128
|
+
/**
|
|
129
|
+
* Check if the listener is currently active and intercepting operations
|
|
130
|
+
*
|
|
131
|
+
* @returns True if currently listening to AsyncStorage operations
|
|
132
|
+
*/
|
|
133
|
+
get isActive(): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Get the number of currently registered event listeners
|
|
136
|
+
*
|
|
137
|
+
* @returns Number of active listeners
|
|
138
|
+
*/
|
|
139
|
+
get listenerCount(): number;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Singleton instance of AsyncStorageListener
|
|
143
|
+
*
|
|
144
|
+
* This ensures only one listener instance exists across the entire application,
|
|
145
|
+
* preventing conflicts and duplicate event handling.
|
|
146
|
+
*/
|
|
147
|
+
declare const asyncStorageListener: AsyncStorageListener;
|
|
148
|
+
/**
|
|
149
|
+
* Start listening to AsyncStorage operations
|
|
150
|
+
*
|
|
151
|
+
* @returns Promise that resolves when listening starts successfully
|
|
152
|
+
*/
|
|
153
|
+
export declare const startListening: () => Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Stop listening to AsyncStorage operations
|
|
156
|
+
*/
|
|
157
|
+
export declare const stopListening: () => void;
|
|
158
|
+
/**
|
|
159
|
+
* Add an event listener for AsyncStorage operations
|
|
160
|
+
*
|
|
161
|
+
* @param listener - Callback function to handle events
|
|
162
|
+
* @returns Unsubscribe function to remove the listener
|
|
163
|
+
*/
|
|
164
|
+
export declare const addListener: (listener: AsyncStorageEventListener) => () => void;
|
|
165
|
+
/**
|
|
166
|
+
* Remove all registered event listeners
|
|
167
|
+
*/
|
|
168
|
+
export declare const removeAllListeners: () => void;
|
|
169
|
+
/**
|
|
170
|
+
* Check if currently listening to AsyncStorage operations
|
|
171
|
+
*
|
|
172
|
+
* @returns True if actively intercepting AsyncStorage methods
|
|
173
|
+
*/
|
|
174
|
+
export declare const isListening: () => boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Get the current number of registered event listeners
|
|
177
|
+
*
|
|
178
|
+
* @returns Number of active listeners
|
|
179
|
+
*/
|
|
180
|
+
export declare const getListenerCount: () => number;
|
|
181
|
+
/**
|
|
182
|
+
* Export the singleton instance for advanced usage
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* import asyncStorageListener from './AsyncStorageListener';
|
|
187
|
+
*
|
|
188
|
+
* // Access advanced methods directly
|
|
189
|
+
* if (asyncStorageListener.isActive) {
|
|
190
|
+
* console.log(`${asyncStorageListener.listenerCount} listeners active`);
|
|
191
|
+
* }
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
export default asyncStorageListener;
|
|
195
|
+
//# sourceMappingURL=AsyncStorageListener.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncStorageListener.d.ts","sourceRoot":"","sources":["../../../../src/storage/utils/AsyncStorageListener.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,iBAAiB;IAChC,MAAM,EACF,SAAS,GACT,YAAY,GACZ,WAAW,GACX,OAAO,GACP,UAAU,GACV,aAAa,GACb,YAAY,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,CAAC,EAAE;QACL,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAChB,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;KAC5B,CAAC;CACH;AAED,MAAM,MAAM,yBAAyB,GAAG,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,cAAM,oBAAoB;IACxB,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,aAAa,CAAS;IAI9B,OAAO,CAAC,WAAW,CAKhB;IAGH,OAAO,CAAC,eAAe,CAAoC;IAC3D,OAAO,CAAC,kBAAkB,CAAuC;IACjE,OAAO,CAAC,iBAAiB,CAAsC;IAC/D,OAAO,CAAC,aAAa,CAAkC;IACvD,OAAO,CAAC,gBAAgB,CAAqC;IAC7D,OAAO,CAAC,mBAAmB,CAAwC;IACnE,OAAO,CAAC,kBAAkB,CAAuC;IAEjE;;;;;;;;OAQG;IACH,OAAO,CAAC,eAAe;IAYvB;;;;;;;;;OASG;YACW,UAAU;IAiCxB;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;IA0B9B;;;;;;OAMG;IACH,OAAO,CAAC,IAAI;IAeZ;;;;;;;;;;OAUG;IACG,cAAc;IAmLpB;;;;;OAKG;IACH,aAAa;IAsCb;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CAAC,QAAQ,EAAE,yBAAyB;IAY/C;;;;OAIG;IACH,kBAAkB;IAKlB;;;;OAIG;IACH,IAAI,QAAQ,YAEX;IAED;;;;OAIG;IACH,IAAI,aAAa,WAEhB;CACF;AAED;;;;;GAKG;AACH,QAAA,MAAM,oBAAoB,sBAA6B,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,cAAc,qBAA8C,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,aAAa,YAA6C,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,yBAAyB,eACnB,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,kBAAkB,YACY,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,WAAW,eAAsC,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,cAA2C,CAAC;AAEzE;;;;;;;;;;;;GAYG;AACH,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MMKV Instance Registry
|
|
3
|
+
*
|
|
4
|
+
* Centralized registry for tracking all MMKV instances in the application.
|
|
5
|
+
* Provides a singleton pattern to manage multiple MMKV instances and their metadata.
|
|
6
|
+
*
|
|
7
|
+
* @module MMKVInstanceRegistry
|
|
8
|
+
* @since 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Type-safe representation of an MMKV instance.
|
|
12
|
+
* Uses conditional typing to avoid hard dependency on react-native-mmkv.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export type MMKV = {
|
|
17
|
+
/**
|
|
18
|
+
* Set a value for the given key
|
|
19
|
+
*/
|
|
20
|
+
set(key: string, value: boolean | string | number | ArrayBuffer): void;
|
|
21
|
+
/**
|
|
22
|
+
* Get a string value for the given key
|
|
23
|
+
*/
|
|
24
|
+
getString(key: string): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Get a number value for the given key
|
|
27
|
+
*/
|
|
28
|
+
getNumber(key: string): number | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Get a boolean value for the given key
|
|
31
|
+
*/
|
|
32
|
+
getBoolean(key: string): boolean | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Get a buffer value for the given key
|
|
35
|
+
*/
|
|
36
|
+
getBuffer(key: string): ArrayBuffer | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Check if a key exists
|
|
39
|
+
*/
|
|
40
|
+
contains(key: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Delete a key (v4 uses 'remove', but we support both)
|
|
43
|
+
*/
|
|
44
|
+
delete?(key: string): boolean;
|
|
45
|
+
remove?(key: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Get all keys
|
|
48
|
+
*/
|
|
49
|
+
getAllKeys(): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Clear all data
|
|
52
|
+
*/
|
|
53
|
+
clearAll(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Trim storage to reclaim disk space
|
|
56
|
+
*/
|
|
57
|
+
trim?(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Whether this instance is read-only
|
|
60
|
+
*/
|
|
61
|
+
readonly isReadOnly?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Current storage size in bytes
|
|
64
|
+
*/
|
|
65
|
+
readonly size: number;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Metadata about a registered MMKV instance
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
export interface MMKVInstanceInfo {
|
|
73
|
+
/**
|
|
74
|
+
* Unique identifier for this MMKV instance
|
|
75
|
+
* @example "mmkv.default", "user-preferences", "secure-storage"
|
|
76
|
+
*/
|
|
77
|
+
id: string;
|
|
78
|
+
/**
|
|
79
|
+
* The MMKV instance object
|
|
80
|
+
*/
|
|
81
|
+
instance: MMKV;
|
|
82
|
+
/**
|
|
83
|
+
* Whether this instance uses encryption
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
encrypted: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Whether this instance is read-only
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
readOnly: boolean;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Configuration options for registering an MMKV instance
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
export interface MMKVRegistrationConfig {
|
|
99
|
+
/**
|
|
100
|
+
* Whether this instance uses encryption
|
|
101
|
+
* Set to true if you provided an encryptionKey when creating the instance
|
|
102
|
+
* @default false
|
|
103
|
+
*/
|
|
104
|
+
encrypted?: boolean;
|
|
105
|
+
}
|
|
106
|
+
declare class MMKVInstanceRegistry {
|
|
107
|
+
private instances;
|
|
108
|
+
/**
|
|
109
|
+
* Register an MMKV instance for monitoring
|
|
110
|
+
*
|
|
111
|
+
* @param id - Unique identifier for this instance
|
|
112
|
+
* @param instance - The MMKV instance to register
|
|
113
|
+
* @param config - Optional configuration (e.g., encrypted flag)
|
|
114
|
+
*/
|
|
115
|
+
register(id: string, instance: MMKV, config?: MMKVRegistrationConfig): void;
|
|
116
|
+
/**
|
|
117
|
+
* Unregister an MMKV instance
|
|
118
|
+
*/
|
|
119
|
+
unregister(id: string): void;
|
|
120
|
+
/**
|
|
121
|
+
* Get a specific instance by ID
|
|
122
|
+
*/
|
|
123
|
+
get(id: string): MMKVInstanceInfo | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Get all registered instances
|
|
126
|
+
*/
|
|
127
|
+
getAll(): MMKVInstanceInfo[];
|
|
128
|
+
/**
|
|
129
|
+
* Check if an instance is registered
|
|
130
|
+
*/
|
|
131
|
+
has(id: string): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Get count of registered instances
|
|
134
|
+
*/
|
|
135
|
+
count(): number;
|
|
136
|
+
}
|
|
137
|
+
export declare const mmkvInstanceRegistry: MMKVInstanceRegistry;
|
|
138
|
+
/**
|
|
139
|
+
* Register an MMKV instance with React Buoy DevTools for monitoring and debugging.
|
|
140
|
+
*
|
|
141
|
+
* **⚠️ REQUIRED**: Manual registration is required for `react-native-mmkv` v4.
|
|
142
|
+
* Auto-detection is not possible due to Metro bundler and ES6 module limitations.
|
|
143
|
+
*
|
|
144
|
+
* Call this function immediately after creating each MMKV instance you want to monitor.
|
|
145
|
+
* The DevTools will then be able to:
|
|
146
|
+
* - Display all keys and values
|
|
147
|
+
* - Show real-time updates when data changes
|
|
148
|
+
* - Allow editing values directly from the DevTools
|
|
149
|
+
* - Track storage size and performance
|
|
150
|
+
*
|
|
151
|
+
* @param id - Unique identifier for this MMKV instance. Should match the `id` you used when creating the instance.
|
|
152
|
+
* @param instance - The MMKV instance returned from `createMMKV()`
|
|
153
|
+
* @param config - Optional configuration
|
|
154
|
+
* @param config.encrypted - Set to `true` if this instance uses encryption (has an `encryptionKey`)
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* **Basic usage:**
|
|
158
|
+
* ```typescript
|
|
159
|
+
* import { createMMKV } from 'react-native-mmkv';
|
|
160
|
+
* import { registerMMKVInstance } from '@buoy-gg/storage';
|
|
161
|
+
*
|
|
162
|
+
* // Create and register default instance
|
|
163
|
+
* export const storage = createMMKV({ id: 'mmkv.default' });
|
|
164
|
+
* registerMMKVInstance('mmkv.default', storage);
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* **With encryption:**
|
|
169
|
+
* ```typescript
|
|
170
|
+
* import { createMMKV } from 'react-native-mmkv';
|
|
171
|
+
* import { registerMMKVInstance } from '@buoy-gg/storage';
|
|
172
|
+
*
|
|
173
|
+
* // Create encrypted instance
|
|
174
|
+
* export const secureStorage = createMMKV({
|
|
175
|
+
* id: 'secure-storage',
|
|
176
|
+
* encryptionKey: 'my-encryption-key'
|
|
177
|
+
* });
|
|
178
|
+
*
|
|
179
|
+
* // Register with encrypted flag
|
|
180
|
+
* registerMMKVInstance('secure-storage', secureStorage, { encrypted: true });
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* **Multiple instances:**
|
|
185
|
+
* ```typescript
|
|
186
|
+
* import { createMMKV } from 'react-native-mmkv';
|
|
187
|
+
* import { registerMMKVInstance } from '@buoy-gg/storage';
|
|
188
|
+
*
|
|
189
|
+
* // User preferences
|
|
190
|
+
* export const userPrefs = createMMKV({ id: 'user-prefs' });
|
|
191
|
+
* registerMMKVInstance('user-prefs', userPrefs);
|
|
192
|
+
*
|
|
193
|
+
* // Cache
|
|
194
|
+
* export const cache = createMMKV({ id: 'cache' });
|
|
195
|
+
* registerMMKVInstance('cache', cache);
|
|
196
|
+
*
|
|
197
|
+
* // Auth (encrypted)
|
|
198
|
+
* export const auth = createMMKV({ id: 'auth', encryptionKey: 'key' });
|
|
199
|
+
* registerMMKVInstance('auth', auth, { encrypted: true });
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* @public
|
|
203
|
+
* @since 1.0.0
|
|
204
|
+
*/
|
|
205
|
+
export declare function registerMMKVInstance(id: string, instance: MMKV, config?: MMKVRegistrationConfig): void;
|
|
206
|
+
/**
|
|
207
|
+
* Unregister an MMKV instance from DevTools monitoring.
|
|
208
|
+
*
|
|
209
|
+
* This stops the DevTools from tracking changes to this instance.
|
|
210
|
+
* Typically not needed unless you're dynamically creating/destroying instances.
|
|
211
|
+
*
|
|
212
|
+
* @param id - The instance ID to unregister
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* unregisterMMKVInstance('cache');
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* @public
|
|
220
|
+
* @since 1.0.0
|
|
221
|
+
*/
|
|
222
|
+
export declare function unregisterMMKVInstance(id: string): void;
|
|
223
|
+
export {};
|
|
224
|
+
//# sourceMappingURL=MMKVInstanceRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MMKVInstanceRegistry.d.ts","sourceRoot":"","sources":["../../../../src/storage/utils/MMKVInstanceRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC;IACvE;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC3C;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC3C;;OAEG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IAC7C;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;IAChD;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B;;OAEG;IACH,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;OAEG;IACH,UAAU,IAAI,MAAM,EAAE,CAAC;IACvB;;OAEG;IACH,QAAQ,IAAI,IAAI,CAAC;IACjB;;OAEG;IACH,IAAI,CAAC,IAAI,IAAI,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,QAAQ,EAAE,IAAI,CAAC;IACf;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,cAAM,oBAAoB;IACxB,OAAO,CAAC,SAAS,CAAuC;IAExD;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,sBAAsB,GAAG,IAAI;IAU3E;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI5B;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAI7C;;OAEG;IACH,MAAM,IAAI,gBAAgB,EAAE;IAI5B;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAIxB;;OAEG;IACH,KAAK,IAAI,MAAM;CAGhB;AAGD,eAAO,MAAM,oBAAoB,sBAA6B,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,IAAI,EACd,MAAM,CAAC,EAAE,sBAAsB,GAC9B,IAAI,CASN;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAOvD"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MMKVListener - Hybrid Monitoring Strategy
|
|
3
|
+
*
|
|
4
|
+
* This module provides comprehensive monitoring for MMKV storage instances using
|
|
5
|
+
* a hybrid approach that combines:
|
|
6
|
+
*
|
|
7
|
+
* 1. MMKV's built-in addOnValueChangedListener() - for write operations
|
|
8
|
+
* 2. Method wrapping - for read operations and type detection
|
|
9
|
+
*
|
|
10
|
+
* Why Hybrid Strategy?
|
|
11
|
+
* - MMKV listeners only fire on writes (set/delete), not reads
|
|
12
|
+
* - MMKV listeners don't provide value type information
|
|
13
|
+
* - Method wrapping captures ALL operations with full context
|
|
14
|
+
* - Combining both gives complete observability
|
|
15
|
+
*
|
|
16
|
+
* Key Differences from AsyncStorage:
|
|
17
|
+
* - Synchronous API (no async/await needed)
|
|
18
|
+
* - Multi-instance support (track multiple MMKV instances)
|
|
19
|
+
* - Native types (string, number, boolean, buffer)
|
|
20
|
+
* - Built-in listener support (MMKV.addOnValueChangedListener)
|
|
21
|
+
*
|
|
22
|
+
* @see AsyncStorageListener.ts for AsyncStorage equivalent
|
|
23
|
+
*/
|
|
24
|
+
type MMKV = any;
|
|
25
|
+
import { MMKVValueType } from "./mmkvTypeDetection";
|
|
26
|
+
/**
|
|
27
|
+
* Event types for MMKV operations
|
|
28
|
+
*/
|
|
29
|
+
export interface MMKVEvent {
|
|
30
|
+
action: "set.string" | "set.number" | "set.boolean" | "set.buffer" | "delete" | "clearAll" | "get.string" | "get.number" | "get.boolean" | "get.buffer";
|
|
31
|
+
timestamp: Date;
|
|
32
|
+
instanceId: string;
|
|
33
|
+
data?: {
|
|
34
|
+
key?: string;
|
|
35
|
+
value?: any;
|
|
36
|
+
valueType?: MMKVValueType;
|
|
37
|
+
success?: boolean;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export type MMKVEventListener = (event: MMKVEvent) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Singleton class for monitoring MMKV operations across multiple instances
|
|
43
|
+
*
|
|
44
|
+
* Uses a hybrid monitoring strategy:
|
|
45
|
+
* 1. MMKV's built-in listener API for write notifications
|
|
46
|
+
* 2. Method wrapping for read operations and type information
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* import { MMKV } from 'react-native-mmkv';
|
|
51
|
+
* import { mmkvListener } from './MMKVListener';
|
|
52
|
+
*
|
|
53
|
+
* const storage = new MMKV();
|
|
54
|
+
*
|
|
55
|
+
* // Start monitoring this instance
|
|
56
|
+
* mmkvListener.addInstance(storage, 'mmkv.default');
|
|
57
|
+
*
|
|
58
|
+
* // Add listener for all MMKV events
|
|
59
|
+
* const unsubscribe = mmkvListener.addListener((event) => {
|
|
60
|
+
* console.log(`[${event.instanceId}] ${event.action}:`, event.data);
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* // Cleanup
|
|
64
|
+
* unsubscribe();
|
|
65
|
+
* mmkvListener.removeInstance('mmkv.default');
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
declare class MMKVListener {
|
|
69
|
+
private listeners;
|
|
70
|
+
private instances;
|
|
71
|
+
private ignoredKeys;
|
|
72
|
+
/**
|
|
73
|
+
* Determines if a storage key should be ignored
|
|
74
|
+
*/
|
|
75
|
+
private shouldIgnoreKey;
|
|
76
|
+
/**
|
|
77
|
+
* Emit an MMKV event to all registered listeners
|
|
78
|
+
*/
|
|
79
|
+
private emit;
|
|
80
|
+
/**
|
|
81
|
+
* Add an MMKV instance for monitoring
|
|
82
|
+
*
|
|
83
|
+
* This method sets up both native MMKV listeners and method wrapping
|
|
84
|
+
* to provide complete observability.
|
|
85
|
+
*
|
|
86
|
+
* @param instance - MMKV instance to monitor
|
|
87
|
+
* @param instanceId - Unique identifier for this instance
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const storage = new MMKV();
|
|
92
|
+
* mmkvListener.addInstance(storage, 'mmkv.default');
|
|
93
|
+
*
|
|
94
|
+
* const secureStorage = new MMKV({ id: 'secure', encryptionKey: key });
|
|
95
|
+
* mmkvListener.addInstance(secureStorage, 'secure');
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
addInstance(instance: MMKV, instanceId: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* Remove an MMKV instance from monitoring
|
|
101
|
+
*
|
|
102
|
+
* Restores original methods and removes native listener.
|
|
103
|
+
*
|
|
104
|
+
* @param instanceId - Identifier of instance to stop monitoring
|
|
105
|
+
*/
|
|
106
|
+
removeInstance(instanceId: string): void;
|
|
107
|
+
/**
|
|
108
|
+
* Remove all monitored instances
|
|
109
|
+
*/
|
|
110
|
+
removeAllInstances(): void;
|
|
111
|
+
/**
|
|
112
|
+
* Add a listener for MMKV events across all monitored instances
|
|
113
|
+
*
|
|
114
|
+
* @param listener - Callback function to handle MMKV events
|
|
115
|
+
* @returns Unsubscribe function to remove the listener
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* const unsubscribe = mmkvListener.addListener((event) => {
|
|
120
|
+
* console.log(`[${event.instanceId}] ${event.action}:`, event.data);
|
|
121
|
+
* });
|
|
122
|
+
*
|
|
123
|
+
* // Later, remove the listener
|
|
124
|
+
* unsubscribe();
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
addListener(listener: MMKVEventListener): () => void;
|
|
128
|
+
/**
|
|
129
|
+
* Remove all registered event listeners
|
|
130
|
+
*/
|
|
131
|
+
removeAllListeners(): void;
|
|
132
|
+
/**
|
|
133
|
+
* Check if an instance is currently being monitored
|
|
134
|
+
*/
|
|
135
|
+
hasInstance(instanceId: string): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Get list of all monitored instance IDs
|
|
138
|
+
*/
|
|
139
|
+
getMonitoredInstances(): string[];
|
|
140
|
+
/**
|
|
141
|
+
* Get the number of currently monitored instances
|
|
142
|
+
*/
|
|
143
|
+
get instanceCount(): number;
|
|
144
|
+
/**
|
|
145
|
+
* Get the number of currently registered event listeners
|
|
146
|
+
*/
|
|
147
|
+
get listenerCount(): number;
|
|
148
|
+
/**
|
|
149
|
+
* Check if any instances are being monitored
|
|
150
|
+
*/
|
|
151
|
+
get isActive(): boolean;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Singleton instance of MMKVListener
|
|
155
|
+
*
|
|
156
|
+
* This ensures only one listener manager exists across the entire application.
|
|
157
|
+
*/
|
|
158
|
+
export declare const mmkvListener: MMKVListener;
|
|
159
|
+
/**
|
|
160
|
+
* Add an MMKV instance for monitoring
|
|
161
|
+
*
|
|
162
|
+
* @param instance - MMKV instance to monitor
|
|
163
|
+
* @param instanceId - Unique identifier for this instance
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* import { MMKV } from 'react-native-mmkv';
|
|
168
|
+
* import { addMMKVInstance } from '@buoy-gg/storage';
|
|
169
|
+
*
|
|
170
|
+
* const storage = new MMKV();
|
|
171
|
+
* addMMKVInstance(storage, 'mmkv.default');
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
export declare const addMMKVInstance: (instance: MMKV, instanceId: string) => void;
|
|
175
|
+
/**
|
|
176
|
+
* Remove an MMKV instance from monitoring
|
|
177
|
+
*/
|
|
178
|
+
export declare const removeMMKVInstance: (instanceId: string) => void;
|
|
179
|
+
/**
|
|
180
|
+
* Remove all monitored MMKV instances
|
|
181
|
+
*/
|
|
182
|
+
export declare const removeAllMMKVInstances: () => void;
|
|
183
|
+
/**
|
|
184
|
+
* Add an event listener for MMKV operations
|
|
185
|
+
*
|
|
186
|
+
* @param listener - Callback function to handle events
|
|
187
|
+
* @returns Unsubscribe function to remove the listener
|
|
188
|
+
*/
|
|
189
|
+
export declare const addMMKVListener: (listener: MMKVEventListener) => () => void;
|
|
190
|
+
/**
|
|
191
|
+
* Remove all registered event listeners
|
|
192
|
+
*/
|
|
193
|
+
export declare const removeAllMMKVListeners: () => void;
|
|
194
|
+
/**
|
|
195
|
+
* Check if an MMKV instance is currently being monitored
|
|
196
|
+
*/
|
|
197
|
+
export declare const isMMKVInstanceMonitored: (instanceId: string) => boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Get list of all monitored MMKV instance IDs
|
|
200
|
+
*/
|
|
201
|
+
export declare const getMonitoredMMKVInstances: () => string[];
|
|
202
|
+
/**
|
|
203
|
+
* Get the current number of monitored MMKV instances
|
|
204
|
+
*/
|
|
205
|
+
export declare const getMMKVInstanceCount: () => number;
|
|
206
|
+
/**
|
|
207
|
+
* Get the current number of registered event listeners
|
|
208
|
+
*/
|
|
209
|
+
export declare const getMMKVListenerCount: () => number;
|
|
210
|
+
/**
|
|
211
|
+
* Check if any MMKV instances are being monitored
|
|
212
|
+
*/
|
|
213
|
+
export declare const isMMKVListening: () => boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Export the singleton instance for advanced usage
|
|
216
|
+
*/
|
|
217
|
+
export default mmkvListener;
|
|
218
|
+
//# sourceMappingURL=MMKVListener.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MMKVListener.d.ts","sourceRoot":"","sources":["../../../../src/storage/utils/MMKVListener.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,KAAK,IAAI,GAAG,GAAG,CAAC;AAChB,OAAO,EAAkB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAcpE;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,MAAM,EACF,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,YAAY,GACZ,QAAQ,GACR,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,YAAY,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE;QACL,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,SAAS,CAAC,EAAE,aAAa,CAAC;QAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;AAyB3D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,cAAM,YAAY;IAChB,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,SAAS,CAA2C;IAG5D,OAAO,CAAC,WAAW,CAKhB;IAEH;;OAEG;IACH,OAAO,CAAC,eAAe;IAUvB;;OAEG;IACH,OAAO,CAAC,IAAI;IAYZ;;;;;;;;;;;;;;;;;OAiBG;IACH,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IA+ErD;;;;;;OAMG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAiBxC;;OAEG;IACH,kBAAkB,IAAI,IAAI;IAK1B;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,IAAI;IAYpD;;OAEG;IACH,kBAAkB,IAAI,IAAI;IAI1B;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAIxC;;OAEG;IACH,qBAAqB,IAAI,MAAM,EAAE;IAIjC;;OAEG;IACH,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED;;OAEG;IACH,IAAI,QAAQ,IAAI,OAAO,CAEtB;CACF;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,cAAqB,CAAC;AAE/C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,IAAI,EAAE,YAAY,MAAM,SAClB,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,YAAY,MAAM,SACZ,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,sBAAsB,YAA0C,CAAC;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,iBAAiB,WAjGT,IAkGd,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,sBAAsB,YAA0C,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,YAAY,MAAM,YACpB,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,yBAAyB,gBACA,CAAC;AAEvC;;GAEG;AACH,eAAO,MAAM,oBAAoB,cAAmC,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,oBAAoB,cAAmC,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,eAAe,eAA8B,CAAC;AAE3D;;GAEG;AACH,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clear all storage data except dev tools keys
|
|
3
|
+
* This preserves dev tool settings while clearing app data
|
|
4
|
+
*/
|
|
5
|
+
export declare function clearAllAppStorage(): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Clear absolutely all storage data including dev tools
|
|
8
|
+
* Use with caution - this will reset all dev tool settings
|
|
9
|
+
*/
|
|
10
|
+
export declare function clearAllStorageIncludingDevTools(): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=clearAllStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clearAllStorage.d.ts","sourceRoot":"","sources":["../../../../src/storage/utils/clearAllStorage.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAyBxD;AAED;;;GAGG;AACH,wBAAsB,gCAAgC,IAAI,OAAO,CAAC,IAAI,CAAC,CAKtE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { clearAllAppStorage } from "./clearAllStorage";
|
|
2
|
+
export { isMMKVAvailable, getMMKVClass, getMMKVUnavailableMessage, } from "./mmkvAvailability";
|
|
3
|
+
export { startListening, stopListening, addListener, removeAllListeners, isListening, getListenerCount, type AsyncStorageEvent, type AsyncStorageEventListener, } from "./AsyncStorageListener";
|
|
4
|
+
export { default as asyncStorageListener } from "./AsyncStorageListener";
|
|
5
|
+
export { registerMMKVInstance, unregisterMMKVInstance, mmkvInstanceRegistry, type MMKVInstanceInfo, } from "./MMKVInstanceRegistry";
|
|
6
|
+
export { addMMKVInstance, removeMMKVInstance, removeAllMMKVInstances, addMMKVListener, removeAllMMKVListeners, isMMKVInstanceMonitored, getMonitoredMMKVInstances, getMMKVInstanceCount, getMMKVListenerCount, isMMKVListening, mmkvListener, type MMKVEvent, type MMKVEventListener, } from "./MMKVListener";
|
|
7
|
+
export { detectMMKVType, formatMMKVValue, isTypeMatch, type MMKVValueType, type MMKVValueInfo, } from "./mmkvTypeDetection";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/utils/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EACL,eAAe,EACf,YAAY,EACZ,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,cAAc,EACd,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,GAC/B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGzE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,KAAK,gBAAgB,GACtB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,yBAAyB,EACzB,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,iBAAiB,GACvB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,cAAc,EACd,eAAe,EACf,WAAW,EACX,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC"}
|