@buoy-gg/storage 7.0.40 → 7.0.42
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 +11 -86
- package/lib/commonjs/index.js +1 -346
- package/lib/commonjs/preset.js +1 -80
- package/lib/commonjs/storage/components/DiffViewer/TreeDiffViewer.js +1 -36
- package/lib/commonjs/storage/components/DiffViewer/modes/ThemedSplitView.js +1 -12
- package/lib/commonjs/storage/components/DiffViewer/themes/diffThemes.js +1 -24
- package/lib/commonjs/storage/components/GameUIStorageBrowser.js +3 -1258
- package/lib/commonjs/storage/components/MMKVInstanceInfoPanel.js +1 -257
- package/lib/commonjs/storage/components/MMKVInstanceSelector.js +1 -418
- package/lib/commonjs/storage/components/SelectionActionBar.js +1 -207
- package/lib/commonjs/storage/components/StorageActionButtons.js +1 -241
- package/lib/commonjs/storage/components/StorageBrowserMode.js +1 -61
- package/lib/commonjs/storage/components/StorageEventActionButton.js +1 -121
- package/lib/commonjs/storage/components/StorageEventCard.js +1 -117
- package/lib/commonjs/storage/components/StorageEventDetailContent.js +1 -494
- package/lib/commonjs/storage/components/StorageEventFilterView.js +1 -159
- package/lib/commonjs/storage/components/StorageEventsSection.js +1 -24
- package/lib/commonjs/storage/components/StorageFilterCards.js +1 -231
- package/lib/commonjs/storage/components/StorageKeyCard.js +1 -520
- package/lib/commonjs/storage/components/StorageKeyDetailScreen.js +1 -579
- package/lib/commonjs/storage/components/StorageKeyRow.js +1 -559
- package/lib/commonjs/storage/components/StorageKeySection.js +1 -160
- package/lib/commonjs/storage/components/StorageKeyStats.js +1 -344
- package/lib/commonjs/storage/components/StorageModalWithTabs.js +1 -954
- package/lib/commonjs/storage/components/StorageSaveNotice.js +1 -171
- package/lib/commonjs/storage/components/StorageSection.js +1 -43
- package/lib/commonjs/storage/components/StorageTypeFilterBar.js +1 -143
- package/lib/commonjs/storage/hooks/useAsyncStorageKeys.js +1 -141
- package/lib/commonjs/storage/hooks/useMMKVInstances.js +1 -210
- package/lib/commonjs/storage/hooks/useMMKVKeys.js +1 -376
- package/lib/commonjs/storage/hooks/useSecureStoreKeys.js +1 -159
- package/lib/commonjs/storage/hooks/useStorageEvents.js +1 -61
- package/lib/commonjs/storage/stores/storageEventStore.js +1 -312
- package/lib/commonjs/storage/sync/storageSyncAdapter.js +1 -478
- package/lib/commonjs/storage/types.js +1 -5
- package/lib/commonjs/storage/utils/AsyncStorageListener.js +1 -691
- package/lib/commonjs/storage/utils/AsyncStorageListener.web.js +1 -0
- package/lib/commonjs/storage/utils/MMKVInstanceRegistry.js +1 -203
- package/lib/commonjs/storage/utils/MMKVListener.js +1 -416
- package/lib/commonjs/storage/utils/SecureStoreRegistry.js +1 -200
- package/lib/commonjs/storage/utils/asyncStorageCompat.js +1 -89
- package/lib/commonjs/storage/utils/browserStorageLifecycle.js +1 -0
- package/lib/commonjs/storage/utils/browserStorageLifecycle.web.js +1 -0
- package/lib/commonjs/storage/utils/clearAllStorage.js +1 -48
- package/lib/commonjs/storage/utils/deleteStorageKeys.js +1 -82
- package/lib/commonjs/storage/utils/lineDiff.js +1 -30
- package/lib/commonjs/storage/utils/mmkvAvailability.js +1 -62
- package/lib/commonjs/storage/utils/mmkvAvailability.web.js +1 -0
- package/lib/commonjs/storage/utils/mmkvTypeDetection.js +1 -154
- package/lib/commonjs/storage/utils/requiredStorageKeyScope.js +1 -17
- package/lib/commonjs/storage/utils/setStorageValue.js +1 -218
- package/lib/commonjs/storage/utils/snapshotProvider.js +1 -382
- package/lib/commonjs/storage/utils/storageActionHelpers.js +1 -46
- package/lib/commonjs/storage/utils/storageBrowserRefresh.js +1 -49
- package/lib/commonjs/storage/utils/storageLabels.js +1 -0
- package/lib/commonjs/storage/utils/storageLabels.web.js +1 -0
- package/lib/commonjs/storage/utils/storageOps.js +1 -53
- package/lib/commonjs/storage/utils/storageQueryUtils.js +1 -35
- package/lib/commonjs/storage/utils/storageTimeTravelUtils.js +1 -288
- package/lib/commonjs/storage/utils/valueType.js +1 -83
- package/lib/module/index.js +1 -112
- package/lib/module/preset.js +1 -76
- package/lib/module/storage/components/DiffViewer/TreeDiffViewer.js +1 -32
- package/lib/module/storage/components/DiffViewer/modes/ThemedSplitView.js +1 -9
- package/lib/module/storage/components/DiffViewer/themes/diffThemes.js +1 -10
- package/lib/module/storage/components/GameUIStorageBrowser.js +3 -1256
- package/lib/module/storage/components/MMKVInstanceInfoPanel.js +1 -253
- package/lib/module/storage/components/MMKVInstanceSelector.js +1 -414
- package/lib/module/storage/components/SelectionActionBar.js +1 -204
- package/lib/module/storage/components/StorageActionButtons.js +1 -237
- package/lib/module/storage/components/StorageBrowserMode.js +1 -57
- package/lib/module/storage/components/StorageEventActionButton.js +1 -118
- package/lib/module/storage/components/StorageEventCard.js +1 -112
- package/lib/module/storage/components/StorageEventDetailContent.js +1 -490
- package/lib/module/storage/components/StorageEventFilterView.js +1 -155
- package/lib/module/storage/components/StorageEventsSection.js +1 -20
- package/lib/module/storage/components/StorageFilterCards.js +1 -227
- package/lib/module/storage/components/StorageKeyCard.js +1 -517
- package/lib/module/storage/components/StorageKeyDetailScreen.js +1 -577
- package/lib/module/storage/components/StorageKeyRow.js +1 -554
- package/lib/module/storage/components/StorageKeySection.js +1 -155
- package/lib/module/storage/components/StorageKeyStats.js +1 -341
- package/lib/module/storage/components/StorageModalWithTabs.js +1 -949
- package/lib/module/storage/components/StorageSaveNotice.js +1 -168
- package/lib/module/storage/components/StorageSection.js +1 -40
- package/lib/module/storage/components/StorageTypeFilterBar.js +1 -138
- package/lib/module/storage/hooks/useAsyncStorageKeys.js +1 -136
- package/lib/module/storage/hooks/useMMKVInstances.js +1 -204
- package/lib/module/storage/hooks/useMMKVKeys.js +1 -371
- package/lib/module/storage/hooks/useSecureStoreKeys.js +1 -156
- package/lib/module/storage/hooks/useStorageEvents.js +1 -58
- package/lib/module/storage/stores/storageEventStore.js +1 -301
- package/lib/module/storage/sync/storageSyncAdapter.js +1 -474
- package/lib/module/storage/types.js +1 -3
- package/lib/module/storage/utils/AsyncStorageListener.js +1 -679
- package/lib/module/storage/utils/AsyncStorageListener.web.js +1 -0
- package/lib/module/storage/utils/MMKVInstanceRegistry.js +1 -197
- package/lib/module/storage/utils/MMKVListener.js +1 -403
- package/lib/module/storage/utils/SecureStoreRegistry.js +1 -194
- package/lib/module/storage/utils/asyncStorageCompat.js +1 -81
- package/lib/module/storage/utils/browserStorageLifecycle.js +1 -0
- package/lib/module/storage/utils/browserStorageLifecycle.web.js +1 -0
- package/lib/module/storage/utils/clearAllStorage.js +1 -43
- package/lib/module/storage/utils/deleteStorageKeys.js +1 -78
- package/lib/module/storage/utils/lineDiff.js +1 -12
- package/lib/module/storage/utils/mmkvAvailability.js +1 -56
- package/lib/module/storage/utils/mmkvAvailability.web.js +1 -0
- package/lib/module/storage/utils/mmkvTypeDetection.js +1 -148
- package/lib/module/storage/utils/requiredStorageKeyScope.js +1 -13
- package/lib/module/storage/utils/setStorageValue.js +1 -209
- package/lib/module/storage/utils/snapshotProvider.js +1 -380
- package/lib/module/storage/utils/storageActionHelpers.js +1 -42
- package/lib/module/storage/utils/storageBrowserRefresh.js +1 -44
- package/lib/module/storage/utils/storageLabels.js +1 -0
- package/lib/module/storage/utils/storageLabels.web.js +1 -0
- package/lib/module/storage/utils/storageOps.js +1 -46
- package/lib/module/storage/utils/storageQueryUtils.js +1 -30
- package/lib/module/storage/utils/storageTimeTravelUtils.js +1 -281
- package/lib/module/storage/utils/valueType.js +1 -76
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/storage/components/MMKVInstanceSelector.d.ts +0 -8
- package/lib/typescript/storage/components/StorageEventCard.d.ts +0 -7
- package/lib/typescript/storage/components/StorageKeyRow.d.ts +2 -6
- package/lib/typescript/storage/components/StorageTypeFilterBar.d.ts +0 -15
- package/lib/typescript/storage/hooks/useSecureStoreKeys.d.ts +2 -2
- package/lib/typescript/storage/sync/storageSyncAdapter.d.ts +7 -13
- package/lib/typescript/storage/utils/AsyncStorageListener.web.d.ts +24 -0
- package/lib/typescript/storage/utils/browserStorageLifecycle.d.ts +3 -0
- package/lib/typescript/storage/utils/browserStorageLifecycle.web.d.ts +2 -0
- package/lib/typescript/storage/utils/mmkvAvailability.web.d.ts +4 -0
- package/lib/typescript/storage/utils/storageLabels.d.ts +8 -0
- package/lib/typescript/storage/utils/storageLabels.web.d.ts +8 -0
- package/lib/web/index.mjs +4 -0
- package/package.json +40 -14
- package/lib/commonjs/storage/components/DiffViewer/DiffOptionsPanel.js +0 -356
- package/lib/commonjs/storage/components/DiffViewer/components/DiffSummary.js +0 -122
- package/lib/commonjs/storage/components/StorageKeyEditorScreen.js +0 -414
- package/lib/commonjs/storage/components/StorageScalarKeyEditor.js +0 -61
- package/lib/commonjs/storage/components/StorageValueEditModal.js +0 -24
- package/lib/commonjs/storage/hooks/useKeyEditor.js +0 -31
- package/lib/commonjs/storage/hooks/useTreeDraft.js +0 -25
- package/lib/module/storage/components/DiffViewer/DiffOptionsPanel.js +0 -352
- package/lib/module/storage/components/DiffViewer/components/DiffSummary.js +0 -118
- package/lib/module/storage/components/StorageKeyEditorScreen.js +0 -410
- package/lib/module/storage/components/StorageScalarKeyEditor.js +0 -57
- package/lib/module/storage/components/StorageValueEditModal.js +0 -20
- package/lib/module/storage/hooks/useKeyEditor.js +0 -27
- package/lib/module/storage/hooks/useTreeDraft.js +0 -21
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
- package/lib/typescript/storage/components/DiffViewer/DiffOptionsPanel.d.ts +0 -18
- package/lib/typescript/storage/components/DiffViewer/DiffOptionsPanel.d.ts.map +0 -1
- package/lib/typescript/storage/components/DiffViewer/TreeDiffViewer.d.ts.map +0 -1
- package/lib/typescript/storage/components/DiffViewer/components/DiffSummary.d.ts +0 -12
- package/lib/typescript/storage/components/DiffViewer/components/DiffSummary.d.ts.map +0 -1
- package/lib/typescript/storage/components/DiffViewer/modes/ThemedSplitView.d.ts.map +0 -1
- package/lib/typescript/storage/components/DiffViewer/themes/diffThemes.d.ts.map +0 -1
- package/lib/typescript/storage/components/GameUIStorageBrowser.d.ts.map +0 -1
- package/lib/typescript/storage/components/MMKVInstanceInfoPanel.d.ts.map +0 -1
- package/lib/typescript/storage/components/MMKVInstanceSelector.d.ts.map +0 -1
- package/lib/typescript/storage/components/SelectionActionBar.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageActionButtons.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageBrowserMode.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageEventActionButton.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageEventCard.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageEventDetailContent.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageEventFilterView.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageEventsSection.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageFilterCards.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageKeyCard.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageKeyDetailScreen.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageKeyEditorScreen.d.ts +0 -42
- package/lib/typescript/storage/components/StorageKeyEditorScreen.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageKeyRow.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageKeySection.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageKeyStats.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageModalWithTabs.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageSaveNotice.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageScalarKeyEditor.d.ts +0 -24
- package/lib/typescript/storage/components/StorageScalarKeyEditor.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageSection.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageTypeFilterBar.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageValueEditModal.d.ts +0 -14
- package/lib/typescript/storage/components/StorageValueEditModal.d.ts.map +0 -1
- package/lib/typescript/storage/hooks/useAsyncStorageKeys.d.ts.map +0 -1
- package/lib/typescript/storage/hooks/useKeyEditor.d.ts +0 -27
- package/lib/typescript/storage/hooks/useKeyEditor.d.ts.map +0 -1
- package/lib/typescript/storage/hooks/useMMKVInstances.d.ts.map +0 -1
- package/lib/typescript/storage/hooks/useMMKVKeys.d.ts.map +0 -1
- package/lib/typescript/storage/hooks/useSecureStoreKeys.d.ts.map +0 -1
- package/lib/typescript/storage/hooks/useStorageEvents.d.ts.map +0 -1
- package/lib/typescript/storage/hooks/useTreeDraft.d.ts +0 -16
- package/lib/typescript/storage/hooks/useTreeDraft.d.ts.map +0 -1
- package/lib/typescript/storage/stores/storageEventStore.d.ts.map +0 -1
- package/lib/typescript/storage/sync/storageSyncAdapter.d.ts.map +0 -1
- package/lib/typescript/storage/types.d.ts.map +0 -1
- package/lib/typescript/storage/utils/AsyncStorageListener.d.ts.map +0 -1
- package/lib/typescript/storage/utils/MMKVInstanceRegistry.d.ts.map +0 -1
- package/lib/typescript/storage/utils/MMKVListener.d.ts.map +0 -1
- package/lib/typescript/storage/utils/SecureStoreRegistry.d.ts.map +0 -1
- package/lib/typescript/storage/utils/asyncStorageCompat.d.ts.map +0 -1
- package/lib/typescript/storage/utils/clearAllStorage.d.ts.map +0 -1
- package/lib/typescript/storage/utils/deleteStorageKeys.d.ts.map +0 -1
- package/lib/typescript/storage/utils/lineDiff.d.ts.map +0 -1
- package/lib/typescript/storage/utils/mmkvAvailability.d.ts.map +0 -1
- package/lib/typescript/storage/utils/mmkvTypeDetection.d.ts.map +0 -1
- package/lib/typescript/storage/utils/requiredStorageKeyScope.d.ts.map +0 -1
- package/lib/typescript/storage/utils/setStorageValue.d.ts.map +0 -1
- package/lib/typescript/storage/utils/snapshotProvider.d.ts.map +0 -1
- package/lib/typescript/storage/utils/storageActionHelpers.d.ts.map +0 -1
- package/lib/typescript/storage/utils/storageBrowserRefresh.d.ts.map +0 -1
- package/lib/typescript/storage/utils/storageOps.d.ts.map +0 -1
- package/lib/typescript/storage/utils/storageQueryUtils.d.ts.map +0 -1
- package/lib/typescript/storage/utils/storageTimeTravelUtils.d.ts.map +0 -1
- package/lib/typescript/storage/utils/valueType.d.ts.map +0 -1
|
@@ -1,288 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.canUndo = canUndo;
|
|
7
|
-
exports.jumpToState = jumpToState;
|
|
8
|
-
exports.undoOperation = undoOperation;
|
|
9
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
10
|
-
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
11
|
-
var _asyncStorageCompat = require("./asyncStorageCompat");
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
/**
|
|
14
|
-
* Storage Time-Travel Utilities
|
|
15
|
-
*
|
|
16
|
-
* Provides jump and undo functionality for AsyncStorage operations.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
function isOmittedStorageValue(value) {
|
|
20
|
-
return !!value && typeof value === "object" && value.__buoyValueOnDevice === true;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Undo a single storage operation
|
|
25
|
-
*
|
|
26
|
-
* Restores the previous value(s) before the operation occurred.
|
|
27
|
-
*
|
|
28
|
-
* The restore is deliberately NOT capture-paused. Pausing it meant the write
|
|
29
|
-
* landed but emitted no event, so the modal's event list and current-value
|
|
30
|
-
* panel never changed — UNDO looked like a dead button even though it had
|
|
31
|
-
* worked. Letting the restore emit normally makes it visible and keeps the
|
|
32
|
-
* history honest about what the storage actually did. There is no feedback
|
|
33
|
-
* loop: a write emits an event, and an event never triggers a write.
|
|
34
|
-
*
|
|
35
|
-
* @param event - The storage event to undo
|
|
36
|
-
*/
|
|
37
|
-
async function undoOperation(event) {
|
|
38
|
-
const {
|
|
39
|
-
action,
|
|
40
|
-
data
|
|
41
|
-
} = event;
|
|
42
|
-
if (isOmittedStorageValue(data?.prevValue) || isOmittedStorageValue(data?.prevPairs)) {
|
|
43
|
-
throw new Error("Cannot undo: previous value is still on the device — fetch getEventDetail first");
|
|
44
|
-
}
|
|
45
|
-
{
|
|
46
|
-
switch (action) {
|
|
47
|
-
case "setItem":
|
|
48
|
-
case "mergeItem":
|
|
49
|
-
if (data?.key) {
|
|
50
|
-
if (data.prevValue === null || data.prevValue === undefined) {
|
|
51
|
-
// Key didn't exist before, remove it
|
|
52
|
-
await _asyncStorage.default.removeItem(data.key);
|
|
53
|
-
} else {
|
|
54
|
-
// Restore previous value
|
|
55
|
-
await _asyncStorage.default.setItem(data.key, data.prevValue);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
case "removeItem":
|
|
60
|
-
if (data?.key && data.prevValue !== null && data.prevValue !== undefined) {
|
|
61
|
-
// Restore the removed value
|
|
62
|
-
await _asyncStorage.default.setItem(data.key, data.prevValue);
|
|
63
|
-
}
|
|
64
|
-
break;
|
|
65
|
-
case "multiSet":
|
|
66
|
-
case "multiMerge":
|
|
67
|
-
if (data?.prevPairs && data.prevPairs.length > 0) {
|
|
68
|
-
// Restore all previous values
|
|
69
|
-
for (const [key, value] of data.prevPairs) {
|
|
70
|
-
if (value === null) {
|
|
71
|
-
await _asyncStorage.default.removeItem(key);
|
|
72
|
-
} else {
|
|
73
|
-
await _asyncStorage.default.setItem(key, value);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
break;
|
|
78
|
-
case "multiRemove":
|
|
79
|
-
if (data?.prevPairs && data.prevPairs.length > 0) {
|
|
80
|
-
// Restore all removed values
|
|
81
|
-
for (const [key, value] of data.prevPairs) {
|
|
82
|
-
if (value !== null) {
|
|
83
|
-
await _asyncStorage.default.setItem(key, value);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
break;
|
|
88
|
-
case "clear":
|
|
89
|
-
if (data?.prevPairs && data.prevPairs.length > 0) {
|
|
90
|
-
// Restore all cleared key-value pairs
|
|
91
|
-
const pairsToRestore = data.prevPairs.filter(([, value]) => value !== null);
|
|
92
|
-
if (pairsToRestore.length > 0) {
|
|
93
|
-
await (0, _asyncStorageCompat.writeMany)(pairsToRestore);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
break;
|
|
97
|
-
default:
|
|
98
|
-
throw new Error(`Cannot undo unknown action type: ${action}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Jump to a specific point in storage history
|
|
105
|
-
*
|
|
106
|
-
* Reconstructs the state as of `targetEventIndex` by replaying `events` up to
|
|
107
|
-
* that point, then reconciling ONLY the keys that timeline governs.
|
|
108
|
-
*
|
|
109
|
-
* This used to begin with `AsyncStorage.clear()`, which was badly out of
|
|
110
|
-
* proportion: the modal's JUMP button passes one key's history, so clearing
|
|
111
|
-
* wiped every unrelated app key — and Buoy's own `@react_buoy*` settings with
|
|
112
|
-
* them — to restore a single value. Now a jump touches exactly the keys that
|
|
113
|
-
* appear in the events it was given, and never Buoy's own keys. Like
|
|
114
|
-
* [undoOperation], the writes emit normally so the change is visible.
|
|
115
|
-
*
|
|
116
|
-
* @param events - All events in chronological order (oldest first)
|
|
117
|
-
* @param targetEventIndex - The index of the event to jump to (0-based)
|
|
118
|
-
*/
|
|
119
|
-
async function jumpToState(events, targetEventIndex) {
|
|
120
|
-
if (targetEventIndex < 0 || targetEventIndex >= events.length) {
|
|
121
|
-
throw new Error(`Invalid event index: ${targetEventIndex}`);
|
|
122
|
-
}
|
|
123
|
-
for (const event of events) {
|
|
124
|
-
const data = event.data;
|
|
125
|
-
if (isOmittedStorageValue(data?.value) || isOmittedStorageValue(data?.prevValue) || isOmittedStorageValue(data?.pairs) || isOmittedStorageValue(data?.prevPairs)) {
|
|
126
|
-
throw new Error("Cannot jump: some event values are still on the device — fetch getEventDetail first");
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Build up the state by applying each event up to and including the target.
|
|
131
|
-
// We use the final values from each event, not the operations themselves.
|
|
132
|
-
const stateMap = new Map();
|
|
133
|
-
for (let i = 0; i <= targetEventIndex; i++) {
|
|
134
|
-
applyEventToStateMap(events[i], stateMap);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Every key the WHOLE timeline touches — including events after the target,
|
|
138
|
-
// so a key created later is removed rather than left behind.
|
|
139
|
-
const governedKeys = new Set();
|
|
140
|
-
for (const event of events) {
|
|
141
|
-
collectEventKeys(event, governedKeys);
|
|
142
|
-
}
|
|
143
|
-
const pairsToSet = [];
|
|
144
|
-
const keysToRemove = [];
|
|
145
|
-
for (const key of governedKeys) {
|
|
146
|
-
// Buoy's own settings are never app state to travel through.
|
|
147
|
-
if ((0, _sharedUi.isDevToolsStorageKey)(key)) continue;
|
|
148
|
-
const value = stateMap.get(key);
|
|
149
|
-
if (value === undefined || value === null) {
|
|
150
|
-
keysToRemove.push(key);
|
|
151
|
-
} else {
|
|
152
|
-
pairsToSet.push([key, value]);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (keysToRemove.length > 0) {
|
|
156
|
-
await (0, _asyncStorageCompat.removeMany)(keysToRemove);
|
|
157
|
-
}
|
|
158
|
-
if (pairsToSet.length > 0) {
|
|
159
|
-
await (0, _asyncStorageCompat.writeMany)(pairsToSet);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Collect every key an event refers to, across all action shapes — including
|
|
165
|
-
* `prevPairs`, so keys a `clear` removed are still governed by the timeline.
|
|
166
|
-
*/
|
|
167
|
-
function collectEventKeys(event, into) {
|
|
168
|
-
const {
|
|
169
|
-
data
|
|
170
|
-
} = event;
|
|
171
|
-
if (!data) return;
|
|
172
|
-
if (data.key) into.add(data.key);
|
|
173
|
-
if (data.keys) for (const key of data.keys) into.add(key);
|
|
174
|
-
if (data.pairs) for (const [key] of data.pairs) into.add(key);
|
|
175
|
-
if (data.prevPairs) for (const [key] of data.prevPairs) into.add(key);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Helper to apply an event's effects to a state map
|
|
180
|
-
*/
|
|
181
|
-
function applyEventToStateMap(event, stateMap) {
|
|
182
|
-
const {
|
|
183
|
-
action,
|
|
184
|
-
data
|
|
185
|
-
} = event;
|
|
186
|
-
switch (action) {
|
|
187
|
-
case "setItem":
|
|
188
|
-
if (data?.key && data?.value !== undefined) {
|
|
189
|
-
stateMap.set(data.key, data.value);
|
|
190
|
-
}
|
|
191
|
-
break;
|
|
192
|
-
case "removeItem":
|
|
193
|
-
if (data?.key) {
|
|
194
|
-
stateMap.set(data.key, null);
|
|
195
|
-
}
|
|
196
|
-
break;
|
|
197
|
-
case "mergeItem":
|
|
198
|
-
if (data?.key && data?.value !== undefined) {
|
|
199
|
-
const existing = stateMap.get(data.key);
|
|
200
|
-
if (existing) {
|
|
201
|
-
try {
|
|
202
|
-
// Merge JSON objects
|
|
203
|
-
const existingObj = JSON.parse(existing);
|
|
204
|
-
const newObj = JSON.parse(data.value);
|
|
205
|
-
const merged = {
|
|
206
|
-
...existingObj,
|
|
207
|
-
...newObj
|
|
208
|
-
};
|
|
209
|
-
stateMap.set(data.key, JSON.stringify(merged));
|
|
210
|
-
} catch {
|
|
211
|
-
// If not valid JSON, just overwrite
|
|
212
|
-
stateMap.set(data.key, data.value);
|
|
213
|
-
}
|
|
214
|
-
} else {
|
|
215
|
-
stateMap.set(data.key, data.value);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
break;
|
|
219
|
-
case "multiSet":
|
|
220
|
-
if (data?.pairs) {
|
|
221
|
-
for (const [key, value] of data.pairs) {
|
|
222
|
-
stateMap.set(key, value);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
break;
|
|
226
|
-
case "multiRemove":
|
|
227
|
-
if (data?.keys) {
|
|
228
|
-
for (const key of data.keys) {
|
|
229
|
-
stateMap.set(key, null);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
break;
|
|
233
|
-
case "multiMerge":
|
|
234
|
-
if (data?.pairs) {
|
|
235
|
-
for (const [key, value] of data.pairs) {
|
|
236
|
-
const existing = stateMap.get(key);
|
|
237
|
-
if (existing) {
|
|
238
|
-
try {
|
|
239
|
-
const existingObj = JSON.parse(existing);
|
|
240
|
-
const newObj = JSON.parse(value);
|
|
241
|
-
const merged = {
|
|
242
|
-
...existingObj,
|
|
243
|
-
...newObj
|
|
244
|
-
};
|
|
245
|
-
stateMap.set(key, JSON.stringify(merged));
|
|
246
|
-
} catch {
|
|
247
|
-
stateMap.set(key, value);
|
|
248
|
-
}
|
|
249
|
-
} else {
|
|
250
|
-
stateMap.set(key, value);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
break;
|
|
255
|
-
case "clear":
|
|
256
|
-
// Clear the entire state map
|
|
257
|
-
stateMap.clear();
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* Check if an operation can be undone
|
|
264
|
-
*
|
|
265
|
-
* Some operations may not have the previous value captured.
|
|
266
|
-
*/
|
|
267
|
-
function canUndo(event) {
|
|
268
|
-
const {
|
|
269
|
-
action,
|
|
270
|
-
data
|
|
271
|
-
} = event;
|
|
272
|
-
switch (action) {
|
|
273
|
-
case "setItem":
|
|
274
|
-
case "mergeItem":
|
|
275
|
-
case "removeItem":
|
|
276
|
-
// Can undo if we have the key — but not while prevValue is still a
|
|
277
|
-
// wire-form on-device marker (restoring that would write garbage).
|
|
278
|
-
return !!data?.key && !isOmittedStorageValue(data.prevValue);
|
|
279
|
-
case "multiSet":
|
|
280
|
-
case "multiRemove":
|
|
281
|
-
case "multiMerge":
|
|
282
|
-
case "clear":
|
|
283
|
-
// Can undo if we have previous pairs
|
|
284
|
-
return !!data?.prevPairs && data.prevPairs.length > 0 && !isOmittedStorageValue(data.prevPairs);
|
|
285
|
-
default:
|
|
286
|
-
return false;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.canUndo=canUndo;exports.jumpToState=jumpToState;exports.undoOperation=undoOperation;var _sharedUi=require("@buoy-gg/shared-ui");var _asyncStorage=_interopRequireDefault(require("@react-native-async-storage/async-storage"));var _asyncStorageCompat=require("./asyncStorageCompat");function _interopRequireDefault(s){return s&&s.__esModule?s:{default:s}}function isOmittedStorageValue(s){return!!s&&typeof s==="object"&&s.__buoyValueOnDevice===true}async function undoOperation(s){const{action:r,data:e}=s;if(isOmittedStorageValue(e?.prevValue)||isOmittedStorageValue(e?.prevPairs)){throw new Error("Cannot undo: previous value is still on the device \u2014 fetch getEventDetail first")}{switch(r){case"setItem":case"mergeItem":if(e?.key){if(e.prevValue===null||e.prevValue===void 0){await _asyncStorage.default.removeItem(e.key)}else{await _asyncStorage.default.setItem(e.key,e.prevValue)}}break;case"removeItem":if(e?.key&&e.prevValue!==null&&e.prevValue!==void 0){await _asyncStorage.default.setItem(e.key,e.prevValue)}break;case"multiSet":case"multiMerge":if(e?.prevPairs&&e.prevPairs.length>0){for(const[t,a]of e.prevPairs){if(a===null){await _asyncStorage.default.removeItem(t)}else{await _asyncStorage.default.setItem(t,a)}}}break;case"multiRemove":if(e?.prevPairs&&e.prevPairs.length>0){for(const[t,a]of e.prevPairs){if(a!==null){await _asyncStorage.default.setItem(t,a)}}}break;case"clear":if(e?.prevPairs&&e.prevPairs.length>0){const t=e.prevPairs.filter(([,a])=>a!==null);if(t.length>0){await(0,_asyncStorageCompat.writeMany)(t)}}break;default:throw new Error(`Cannot undo unknown action type: ${r}`)}}}async function jumpToState(s,r){if(r<0||r>=s.length){throw new Error(`Invalid event index: ${r}`)}for(const i of s){const n=i.data;if(isOmittedStorageValue(n?.value)||isOmittedStorageValue(n?.prevValue)||isOmittedStorageValue(n?.pairs)||isOmittedStorageValue(n?.prevPairs)){throw new Error("Cannot jump: some event values are still on the device \u2014 fetch getEventDetail first")}}const e=new Map;for(let i=0;i<=r;i++){applyEventToStateMap(s[i],e)}const t=new Set;for(const i of s){collectEventKeys(i,t)}const a=[];const o=[];for(const i of t){if((0,_sharedUi.isDevToolsStorageKey)(i))continue;const n=e.get(i);if(n===void 0||n===null){o.push(i)}else{a.push([i,n])}}if(o.length>0){await(0,_asyncStorageCompat.removeMany)(o)}if(a.length>0){await(0,_asyncStorageCompat.writeMany)(a)}}function collectEventKeys(s,r){const{data:e}=s;if(!e)return;if(e.key)r.add(e.key);if(e.keys)for(const t of e.keys)r.add(t);if(e.pairs)for(const[t]of e.pairs)r.add(t);if(e.prevPairs)for(const[t]of e.prevPairs)r.add(t)}function applyEventToStateMap(s,r){const{action:e,data:t}=s;switch(e){case"setItem":if(t?.key&&t?.value!==void 0){r.set(t.key,t.value)}break;case"removeItem":if(t?.key){r.set(t.key,null)}break;case"mergeItem":if(t?.key&&t?.value!==void 0){const a=r.get(t.key);if(a){try{const o=JSON.parse(a);const i=JSON.parse(t.value);const n={...o,...i};r.set(t.key,JSON.stringify(n))}catch{r.set(t.key,t.value)}}else{r.set(t.key,t.value)}}break;case"multiSet":if(t?.pairs){for(const[a,o]of t.pairs){r.set(a,o)}}break;case"multiRemove":if(t?.keys){for(const a of t.keys){r.set(a,null)}}break;case"multiMerge":if(t?.pairs){for(const[a,o]of t.pairs){const i=r.get(a);if(i){try{const n=JSON.parse(i);const c=JSON.parse(o);const u={...n,...c};r.set(a,JSON.stringify(u))}catch{r.set(a,o)}}else{r.set(a,o)}}}break;case"clear":r.clear();break}}function canUndo(s){const{action:r,data:e}=s;switch(r){case"setItem":case"mergeItem":case"removeItem":return!!e?.key&&!isOmittedStorageValue(e.prevValue);case"multiSet":case"multiRemove":case"multiMerge":case"clear":return!!e?.prevPairs&&e.prevPairs.length>0&&!isOmittedStorageValue(e.prevPairs);default:return false}}
|
|
@@ -1,83 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getValuePreview = getValuePreview;
|
|
7
|
-
exports.getValueTypeLabel = getValueTypeLabel;
|
|
8
|
-
exports.getValueTypeWithPreview = getValueTypeWithPreview;
|
|
9
|
-
exports.parseStorageValue = parseStorageValue;
|
|
10
|
-
/** Return a concise string describing the JavaScript type of the provided value. */
|
|
11
|
-
function getValueTypeLabel(value) {
|
|
12
|
-
if (value === null) return "null";
|
|
13
|
-
if (value === undefined) return "undefined";
|
|
14
|
-
if (Array.isArray(value)) return "array";
|
|
15
|
-
const type = typeof value;
|
|
16
|
-
if (type === "object") return "object";
|
|
17
|
-
if (type === "boolean") return "boolean";
|
|
18
|
-
if (type === "number") return "number";
|
|
19
|
-
if (type === "string") return "string";
|
|
20
|
-
return "unknown";
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* A stored value as a tree can show it.
|
|
25
|
-
*
|
|
26
|
-
* AsyncStorage and SecureStore hold strings, so an object arrives as the text
|
|
27
|
-
* `{"a":1}` — displaying that as a string is technically true and useless. Any
|
|
28
|
-
* surface that renders or edits a value structurally has to do this same
|
|
29
|
-
* un-stringify first, so it lives here rather than being re-derived (slightly
|
|
30
|
-
* differently) in each one.
|
|
31
|
-
*
|
|
32
|
-
* A string that doesn't parse comes back untouched: it was just a string that
|
|
33
|
-
* happened to start with a brace.
|
|
34
|
-
*/
|
|
35
|
-
function parseStorageValue(value) {
|
|
36
|
-
if (typeof value !== "string") return value;
|
|
37
|
-
const trimmed = value.trim();
|
|
38
|
-
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) return value;
|
|
39
|
-
try {
|
|
40
|
-
return JSON.parse(value);
|
|
41
|
-
} catch {
|
|
42
|
-
return value;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Longest value preview rendered inline next to the type label. */
|
|
47
|
-
const MAX_INLINE_PREVIEW = 40;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Short, human-readable preview of a value for inline display next to the type
|
|
51
|
-
* label, or `null` when the value is too large/complex to preview (long
|
|
52
|
-
* strings, objects, arrays). Lets the user read simple values without opening
|
|
53
|
-
* the card.
|
|
54
|
-
*/
|
|
55
|
-
function getValuePreview(value) {
|
|
56
|
-
switch (typeof value) {
|
|
57
|
-
case "boolean":
|
|
58
|
-
return value ? "true" : "false";
|
|
59
|
-
case "number":
|
|
60
|
-
return Number.isFinite(value) ? String(value) : null;
|
|
61
|
-
case "string":
|
|
62
|
-
{
|
|
63
|
-
if (value.length === 0) return '""';
|
|
64
|
-
if (value.length > MAX_INLINE_PREVIEW) return null;
|
|
65
|
-
// Collapse whitespace so multi-line/tabbed values stay on one line.
|
|
66
|
-
return `"${value.replace(/\s+/g, " ")}"`;
|
|
67
|
-
}
|
|
68
|
-
default:
|
|
69
|
-
return null;
|
|
70
|
-
// objects, arrays, null, undefined
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Type label optionally followed by a short value preview — e.g. `boolean · true`,
|
|
76
|
-
* `number · 42`, `string · "hello"`. Falls back to just the type label when the
|
|
77
|
-
* value is too large to preview.
|
|
78
|
-
*/
|
|
79
|
-
function getValueTypeWithPreview(value) {
|
|
80
|
-
const label = getValueTypeLabel(value);
|
|
81
|
-
const preview = getValuePreview(value);
|
|
82
|
-
return preview ? `${label} · ${preview}` : label;
|
|
83
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getValuePreview=getValuePreview;exports.getValueTypeLabel=getValueTypeLabel;exports.getValueTypeWithPreview=getValueTypeWithPreview;exports.parseStorageValue=parseStorageValue;function getValueTypeLabel(e){if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";const r=typeof e;if(r==="object")return"object";if(r==="boolean")return"boolean";if(r==="number")return"number";if(r==="string")return"string";return"unknown"}function parseStorageValue(e){if(typeof e!=="string")return e;const r=e.trim();if(!r.startsWith("{")&&!r.startsWith("["))return e;try{return JSON.parse(e)}catch{return e}}const MAX_INLINE_PREVIEW=40;function getValuePreview(e){switch(typeof e){case"boolean":return e?"true":"false";case"number":return Number.isFinite(e)?String(e):null;case"string":{if(e.length===0)return'""';if(e.length>MAX_INLINE_PREVIEW)return null;return`"${e.replace(/\s+/g," ")}"`}default:return null}}function getValueTypeWithPreview(e){const r=getValueTypeLabel(e);const t=getValuePreview(e);return t?`${r} \xB7 ${t}`:r}
|
package/lib/module/index.js
CHANGED
|
@@ -1,112 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @buoy-gg/storage
|
|
5
|
-
*
|
|
6
|
-
* Storage monitoring tool for React Native DevTools.
|
|
7
|
-
* Supports AsyncStorage and MMKV.
|
|
8
|
-
*
|
|
9
|
-
* PUBLIC API - Only these exports are supported for external use.
|
|
10
|
-
* Internal listeners and capture controls are not exported to prevent
|
|
11
|
-
* bypassing the tool's intended usage patterns.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
// Side-effect: registers the Time Machine snapshot provider
|
|
15
|
-
import "./storage/utils/snapshotProvider";
|
|
16
|
-
|
|
17
|
-
// =============================================================================
|
|
18
|
-
// PRESET (Primary entry point for users)
|
|
19
|
-
// =============================================================================
|
|
20
|
-
export { storageToolPreset, createStorageTool } from "./preset";
|
|
21
|
-
|
|
22
|
-
// =============================================================================
|
|
23
|
-
// COMPONENTS (For custom UI implementations)
|
|
24
|
-
// =============================================================================
|
|
25
|
-
export { StorageSection } from "./storage/components/StorageSection";
|
|
26
|
-
// `StorageToolView` is the same tool rendered inline (header bar + body +
|
|
27
|
-
// footer) instead of inside a JsModal — for hosts that show tools in a panel.
|
|
28
|
-
export { StorageModalWithTabs, StorageToolView } from "./storage/components/StorageModalWithTabs";
|
|
29
|
-
export { StorageKeyCard } from "./storage/components/StorageKeyCard";
|
|
30
|
-
export { StorageKeyStatsSection } from "./storage/components/StorageKeyStats";
|
|
31
|
-
export { StorageKeySection } from "./storage/components/StorageKeySection";
|
|
32
|
-
export { StorageBrowserMode } from "./storage/components/StorageBrowserMode";
|
|
33
|
-
// The backend filter, shared by the Keys and Events tabs.
|
|
34
|
-
export { StorageTypeFilterBar, countByStorageType } from "./storage/components/StorageTypeFilterBar";
|
|
35
|
-
export { StorageEventsSection } from "./storage/components/StorageEventsSection";
|
|
36
|
-
// The five display operations a storage event collapses onto — semantics, not
|
|
37
|
-
// presentation, so hosts can filter or group by the same vocabulary the UI uses.
|
|
38
|
-
export { STORAGE_OPS, storageOpOf, storageOpDot, isInitialScan } from "./storage/utils/storageOps";
|
|
39
|
-
export { StorageEventCard, getValueType } from "./storage/components/StorageEventCard";
|
|
40
|
-
export { StorageEventDetailContent, StorageEventDetailFooter } from "./storage/components/StorageEventDetailContent";
|
|
41
|
-
export { MMKVInstanceSelector } from "./storage/components/MMKVInstanceSelector";
|
|
42
|
-
export { MMKVInstanceInfoPanel } from "./storage/components/MMKVInstanceInfoPanel";
|
|
43
|
-
|
|
44
|
-
// =============================================================================
|
|
45
|
-
// HOOKS (For consuming storage data in custom components)
|
|
46
|
-
// =============================================================================
|
|
47
|
-
export { useAsyncStorageKeys } from "./storage/hooks/useAsyncStorageKeys";
|
|
48
|
-
export { useMMKVKeys, useMultiMMKVKeys } from "./storage/hooks/useMMKVKeys";
|
|
49
|
-
export { useMMKVInstances, useMMKVInstance, useMMKVInstanceExists } from "./storage/hooks/useMMKVInstances";
|
|
50
|
-
export { useStorageEvents } from "./storage/hooks/useStorageEvents";
|
|
51
|
-
|
|
52
|
-
// =============================================================================
|
|
53
|
-
// TYPES
|
|
54
|
-
// =============================================================================
|
|
55
|
-
|
|
56
|
-
// =============================================================================
|
|
57
|
-
// UTILITIES (Public helpers only)
|
|
58
|
-
// =============================================================================
|
|
59
|
-
export { clearAllAppStorage } from "./storage/utils/clearAllStorage";
|
|
60
|
-
// Writing a value back, with the per-backend type rules in one place. Exported
|
|
61
|
-
// so a host with its own storage UI edits through the same path the tool does.
|
|
62
|
-
export { setStorageValue, storageEditBlockedReason, validateStorageValue, storageValueToEditableText } from "./storage/utils/setStorageValue";
|
|
63
|
-
export { isMMKVAvailable, getMMKVClass, getMMKVUnavailableMessage } from "./storage/utils/mmkvAvailability";
|
|
64
|
-
export { detectMMKVType, formatMMKVValue, isTypeMatch } from "./storage/utils/mmkvTypeDetection";
|
|
65
|
-
export { undoOperation, jumpToState, canUndo } from "./storage/utils/storageTimeTravelUtils";
|
|
66
|
-
// =============================================================================
|
|
67
|
-
// MMKV INSTANCE REGISTRATION (For users to register their MMKV instances)
|
|
68
|
-
// =============================================================================
|
|
69
|
-
export { registerMMKVInstance, unregisterMMKVInstance } from "./storage/utils/MMKVInstanceRegistry";
|
|
70
|
-
|
|
71
|
-
// =============================================================================
|
|
72
|
-
// SECURE STORE REGISTRATION (For users to register their expo-secure-store keys)
|
|
73
|
-
// SecureStore has no key-enumeration API, so keys must be declared to appear.
|
|
74
|
-
// =============================================================================
|
|
75
|
-
export { registerSecureStoreKeys, unregisterSecureStoreKey } from "./storage/utils/SecureStoreRegistry";
|
|
76
|
-
// =============================================================================
|
|
77
|
-
// EXTERNAL SYNC (Adapter for @buoy-gg/external-sync's useExternalSync)
|
|
78
|
-
// =============================================================================
|
|
79
|
-
export { storageSyncAdapter } from "./storage/sync/storageSyncAdapter";
|
|
80
|
-
|
|
81
|
-
// =============================================================================
|
|
82
|
-
// INTERNAL EXPORTS (For @buoy-gg/* packages only - not part of public API)
|
|
83
|
-
// =============================================================================
|
|
84
|
-
/** @internal */
|
|
85
|
-
export { storageEventStore,
|
|
86
|
-
// Exported so remote mirrors (Buoy Desktop) can ask "did the device withhold
|
|
87
|
-
// this value?" without re-deriving the wire contract — and, in the case of
|
|
88
|
-
// `batchPairsOf`, without re-introducing the union-narrowing bug that reading
|
|
89
|
-
// `pairs`/`prevPairs` off a StorageEvent invites.
|
|
90
|
-
isValueOnDevice, batchPairsOf } from "./storage/stores/storageEventStore";
|
|
91
|
-
/**
|
|
92
|
-
* Tell a mounted storage browser to re-read every backend. Used by the desktop
|
|
93
|
-
* dashboard, where local storage listeners are suppressed and device data
|
|
94
|
-
* arrives as snapshots instead.
|
|
95
|
-
* @internal
|
|
96
|
-
*/
|
|
97
|
-
export { requestStorageBrowserRefresh } from "./storage/utils/storageBrowserRefresh";
|
|
98
|
-
|
|
99
|
-
// =============================================================================
|
|
100
|
-
// NOT EXPORTED (Internal capture controls)
|
|
101
|
-
// =============================================================================
|
|
102
|
-
// The following are intentionally NOT exported to prevent bypassing:
|
|
103
|
-
// - subscribeToStorageEvents, onStorageEvent, getStorageEvents, clearStorageEvents
|
|
104
|
-
// - isStorageCapturing
|
|
105
|
-
// - startListening, stopListening, addListener, removeAllListeners (AsyncStorage)
|
|
106
|
-
// - pauseCapture, resumeCapture, isPaused, isListening, getListenerCount
|
|
107
|
-
// - asyncStorageListener instance
|
|
108
|
-
// - addMMKVInstance, removeMMKVInstance, removeAllMMKVInstances (MMKV listener controls)
|
|
109
|
-
// - addMMKVListener, removeAllMMKVListeners, isMMKVInstanceMonitored
|
|
110
|
-
// - getMonitoredMMKVInstances, getMMKVInstanceCount, getMMKVListenerCount, isMMKVListening
|
|
111
|
-
// - mmkvListener instance
|
|
112
|
-
// - mmkvInstanceRegistry instance
|
|
1
|
+
"use strict";import"./storage/utils/snapshotProvider";export{storageToolPreset,createStorageTool}from"./preset";export{StorageSection}from"./storage/components/StorageSection";export{StorageModalWithTabs,StorageToolView}from"./storage/components/StorageModalWithTabs";export{StorageKeyCard}from"./storage/components/StorageKeyCard";export{StorageKeyStatsSection}from"./storage/components/StorageKeyStats";export{StorageKeySection}from"./storage/components/StorageKeySection";export{StorageBrowserMode}from"./storage/components/StorageBrowserMode";export{StorageTypeFilterBar,countByStorageType}from"./storage/components/StorageTypeFilterBar";export{StorageEventsSection}from"./storage/components/StorageEventsSection";export{STORAGE_OPS,storageOpOf,storageOpDot,isInitialScan}from"./storage/utils/storageOps";export{StorageEventCard,getValueType}from"./storage/components/StorageEventCard";export{StorageEventDetailContent,StorageEventDetailFooter}from"./storage/components/StorageEventDetailContent";export{MMKVInstanceSelector}from"./storage/components/MMKVInstanceSelector";export{MMKVInstanceInfoPanel}from"./storage/components/MMKVInstanceInfoPanel";export{useAsyncStorageKeys}from"./storage/hooks/useAsyncStorageKeys";export{useMMKVKeys,useMultiMMKVKeys}from"./storage/hooks/useMMKVKeys";export{useMMKVInstances,useMMKVInstance,useMMKVInstanceExists}from"./storage/hooks/useMMKVInstances";export{useStorageEvents}from"./storage/hooks/useStorageEvents";export{clearAllAppStorage}from"./storage/utils/clearAllStorage";export{setStorageValue,storageEditBlockedReason,validateStorageValue,storageValueToEditableText}from"./storage/utils/setStorageValue";export{isMMKVAvailable,getMMKVClass,getMMKVUnavailableMessage}from"./storage/utils/mmkvAvailability";export{detectMMKVType,formatMMKVValue,isTypeMatch}from"./storage/utils/mmkvTypeDetection";export{undoOperation,jumpToState,canUndo}from"./storage/utils/storageTimeTravelUtils";export{registerMMKVInstance,unregisterMMKVInstance}from"./storage/utils/MMKVInstanceRegistry";export{registerSecureStoreKeys,unregisterSecureStoreKey}from"./storage/utils/SecureStoreRegistry";export{storageSyncAdapter}from"./storage/sync/storageSyncAdapter";export{storageEventStore,isValueOnDevice,batchPairsOf}from"./storage/stores/storageEventStore";export{requestStorageBrowserRefresh}from"./storage/utils/storageBrowserRefresh";export{startBrowserStorageCapture}from"./storage/utils/browserStorageLifecycle";
|
package/lib/module/preset.js
CHANGED
|
@@ -1,76 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Pre-configured AsyncStorage browser tool for FloatingDevTools
|
|
5
|
-
*
|
|
6
|
-
* This preset provides a zero-config way to add AsyncStorage inspection to your dev tools.
|
|
7
|
-
* Just import and add it to your apps array!
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```tsx
|
|
11
|
-
* import { storageToolPreset } from '@buoy-gg/storage';
|
|
12
|
-
*
|
|
13
|
-
* const installedApps = [
|
|
14
|
-
* storageToolPreset, // That's it!
|
|
15
|
-
* // ...other tools
|
|
16
|
-
* ];
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { StorageIcon } from "@buoy-gg/floating-tools-core";
|
|
21
|
-
import { createToolFactory, defineToolPreset } from "@buoy-gg/shared-ui";
|
|
22
|
-
import { StorageModalWithTabs } from "./storage/components/StorageModalWithTabs";
|
|
23
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
-
/**
|
|
25
|
-
* Pre-configured AsyncStorage browser tool for FloatingDevTools.
|
|
26
|
-
* Includes:
|
|
27
|
-
* - Browse all AsyncStorage keys and values
|
|
28
|
-
* - Edit, delete, and add storage items
|
|
29
|
-
* - Live storage event monitoring
|
|
30
|
-
* - Required key validation
|
|
31
|
-
*/
|
|
32
|
-
export const storageToolPreset = defineToolPreset({
|
|
33
|
-
id: "storage",
|
|
34
|
-
name: "STORAGE",
|
|
35
|
-
description: "AsyncStorage browser",
|
|
36
|
-
slot: "both",
|
|
37
|
-
icon: ({
|
|
38
|
-
size
|
|
39
|
-
}) => /*#__PURE__*/_jsx(StorageIcon, {
|
|
40
|
-
size: size
|
|
41
|
-
}),
|
|
42
|
-
component: StorageModalWithTabs,
|
|
43
|
-
props: {
|
|
44
|
-
requiredStorageKeys: [],
|
|
45
|
-
enableSharedModalDimensions: false
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Create a custom AsyncStorage browser tool configuration.
|
|
51
|
-
* Use this if you want to override default settings or provide required storage keys.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```tsx
|
|
55
|
-
* import { createStorageTool } from '@buoy-gg/storage';
|
|
56
|
-
*
|
|
57
|
-
* const requiredStorageKeys = [
|
|
58
|
-
* {
|
|
59
|
-
* key: "@app/session",
|
|
60
|
-
* expectedType: "string",
|
|
61
|
-
* description: "User session token",
|
|
62
|
-
* storageType: "async",
|
|
63
|
-
* },
|
|
64
|
-
* ];
|
|
65
|
-
*
|
|
66
|
-
* const myStorageTool = createStorageTool({
|
|
67
|
-
* requiredStorageKeys,
|
|
68
|
-
* colorPreset: "purple",
|
|
69
|
-
* enableSharedModalDimensions: true,
|
|
70
|
-
* });
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
export const createStorageTool = createToolFactory(storageToolPreset, options => ({
|
|
74
|
-
requiredStorageKeys: options.requiredStorageKeys || [],
|
|
75
|
-
enableSharedModalDimensions: options.enableSharedModalDimensions ?? false
|
|
76
|
-
}));
|
|
1
|
+
"use strict";import{StorageIcon as o}from"@buoy-gg/floating-tools-core";import{createToolFactory as r,defineToolPreset as t}from"@buoy-gg/shared-ui";import{StorageModalWithTabs as s}from"./storage/components/StorageModalWithTabs";import{setToolRequiredStorageKeys as a}from"./storage/sync/storageSyncAdapter";import{jsx as i}from"react/jsx-runtime";export const storageToolPreset=t({id:"storage",name:"STORAGE",description:"AsyncStorage browser",slot:"both",icon:({size:e})=>i(o,{size:e}),component:s,props:{requiredStorageKeys:[],enableSharedModalDimensions:false}});export const createStorageTool=r(storageToolPreset,e=>{a(e.requiredStorageKeys||[]);return{requiredStorageKeys:e.requiredStorageKeys||[],enableSharedModalDimensions:e.enableSharedModalDimensions??false}});
|
|
@@ -1,32 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { View, StyleSheet } from "react-native";
|
|
4
|
-
import { night } from "@buoy-gg/shared-ui";
|
|
5
|
-
import { TreeDiffViewer as SharedTreeDiffViewer } from "@buoy-gg/shared-ui/dataViewer";
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
export function TreeDiffViewer({
|
|
8
|
-
oldValue,
|
|
9
|
-
newValue,
|
|
10
|
-
scrollEnabled = true
|
|
11
|
-
}) {
|
|
12
|
-
return /*#__PURE__*/_jsx(View, {
|
|
13
|
-
style: scrollEnabled ? styles.container : styles.containerInline,
|
|
14
|
-
children: /*#__PURE__*/_jsx(SharedTreeDiffViewer, {
|
|
15
|
-
oldValue: oldValue,
|
|
16
|
-
newValue: newValue,
|
|
17
|
-
theme: "dark",
|
|
18
|
-
scrollEnabled: scrollEnabled
|
|
19
|
-
})
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
const styles = StyleSheet.create({
|
|
23
|
-
container: {
|
|
24
|
-
flex: 1,
|
|
25
|
-
backgroundColor: night.color.bg
|
|
26
|
-
},
|
|
27
|
-
// Inline: size to the tree so the page scroll reveals it, rather than
|
|
28
|
-
// stretching to the pane and clipping the rows.
|
|
29
|
-
containerInline: {
|
|
30
|
-
backgroundColor: night.color.bg
|
|
31
|
-
}
|
|
32
|
-
});
|
|
1
|
+
"use strict";import{View as l,StyleSheet as a}from"react-native";import{night as r}from"@buoy-gg/shared-ui";import{TreeDiffViewer as c}from"@buoy-gg/shared-ui/dataViewer";import{jsx as o}from"react/jsx-runtime";export function TreeDiffViewer({oldValue:i,newValue:n,scrollEnabled:e=true}){return o(l,{style:e?t.container:t.containerInline,children:o(c,{oldValue:i,newValue:n,theme:"dark",scrollEnabled:e})})}const t=a.create({container:{flex:1,backgroundColor:r.color.bg},containerInline:{backgroundColor:r.color.bg}});
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Re-export shim — ThemedSplitView now lives in @buoy-gg/shared-ui/dataViewer
|
|
5
|
-
* (promoted so redux/zustand/jotai/time-machine share one copy; this used to
|
|
6
|
-
* be the only fork with folding + virtualization, and fixes had to be made
|
|
7
|
-
* twice). Keep importing from here inside the storage package.
|
|
8
|
-
*/
|
|
9
|
-
export { ThemedSplitView } from "@buoy-gg/shared-ui/dataViewer";
|
|
1
|
+
"use strict";export{ThemedSplitView}from"@buoy-gg/shared-ui/dataViewer";
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Re-export shim — the diff theme system now lives in
|
|
5
|
-
* @buoy-gg/shared-ui/dataViewer (this used to be a byte-for-byte fork, and
|
|
6
|
-
* the night-theme pass had to be made twice before it was collapsed; same
|
|
7
|
-
* story as ../modes/ThemedSplitView). Keep importing from here inside the
|
|
8
|
-
* storage package.
|
|
9
|
-
*/
|
|
10
|
-
export { diffThemes, gitClassicTheme, devToolsDefaultTheme } from "@buoy-gg/shared-ui/dataViewer";
|
|
1
|
+
"use strict";export{diffThemes,gitClassicTheme,devToolsDefaultTheme}from"@buoy-gg/shared-ui/dataViewer";
|