@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,382 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
4
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
5
|
-
var _asyncStorageCompat = require("./asyncStorageCompat");
|
|
6
|
-
var _clearAllStorage = require("./clearAllStorage");
|
|
7
|
-
var _MMKVInstanceRegistry = require("./MMKVInstanceRegistry");
|
|
8
|
-
var _mmkvTypeDetection = require("./mmkvTypeDetection");
|
|
9
|
-
var _SecureStoreRegistry = require("./SecureStoreRegistry");
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
/**
|
|
12
|
-
* Time Machine snapshot provider for device storage (AsyncStorage + MMKV +
|
|
13
|
-
* SecureStore).
|
|
14
|
-
*
|
|
15
|
-
* Registered into @buoy-gg/shared-ui's stateSnapshotRegistry at module init;
|
|
16
|
-
* consumed by @buoy-gg/time-machine.
|
|
17
|
-
*
|
|
18
|
-
* Buoy's own keys (isDevToolsStorageKey — @react_buoy*, @buoy*, buoy-*,
|
|
19
|
-
* legacy patterns) are excluded on BOTH capture and restore, so a snapshot
|
|
20
|
-
* can never clobber dev-tool settings. Restore is a diff: app keys missing
|
|
21
|
-
* from the snapshot are deleted, snapshot entries are written back.
|
|
22
|
-
*
|
|
23
|
-
* Known-lossy by design (each surfaces a warning/skip):
|
|
24
|
-
* - MMKV ArrayBuffer values are never transported.
|
|
25
|
-
* - SecureStore biometric keys are never read or written (auth prompt).
|
|
26
|
-
* - SecureStore keys outside the registered descriptor list are invisible.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
function deleteMMKVKey(instance, key) {
|
|
30
|
-
// v4 renamed delete() to remove() — support both
|
|
31
|
-
if (instance.remove) instance.remove(key);else instance.delete?.(key);
|
|
32
|
-
}
|
|
33
|
-
function status() {
|
|
34
|
-
return {
|
|
35
|
-
canCapture: true,
|
|
36
|
-
canRestore: true
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** Shared by capture() and the live side of previewItems(). */
|
|
41
|
-
async function captureStorageData() {
|
|
42
|
-
const warnings = [];
|
|
43
|
-
const appKeys = (await _asyncStorage.default.getAllKeys()).filter(k => !(0, _sharedUi.isDevToolsStorageKey)(k));
|
|
44
|
-
const asyncPairs = (await (0, _asyncStorageCompat.readMany)(appKeys)).filter(pair => pair[1] !== null);
|
|
45
|
-
const mmkv = {};
|
|
46
|
-
for (const {
|
|
47
|
-
id,
|
|
48
|
-
instance
|
|
49
|
-
} of _MMKVInstanceRegistry.mmkvInstanceRegistry.getAll()) {
|
|
50
|
-
try {
|
|
51
|
-
mmkv[id] = instance.getAllKeys().filter(key => !(0, _sharedUi.isDevToolsStorageKey)(key)).map(key => {
|
|
52
|
-
const {
|
|
53
|
-
value,
|
|
54
|
-
type: valueType
|
|
55
|
-
} = (0, _mmkvTypeDetection.detectMMKVType)(instance, key);
|
|
56
|
-
if (valueType === "buffer") {
|
|
57
|
-
warnings.push(`mmkv "${id}"/"${key}": ArrayBuffer value not capturable`);
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
key,
|
|
61
|
-
value,
|
|
62
|
-
valueType
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
|
-
} catch {
|
|
66
|
-
warnings.push(`mmkv "${id}": unreadable, captured without entries`);
|
|
67
|
-
mmkv[id] = [];
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const secure = {};
|
|
71
|
-
const secureModule = _SecureStoreRegistry.secureStoreRegistry.getModule();
|
|
72
|
-
for (const {
|
|
73
|
-
key,
|
|
74
|
-
options
|
|
75
|
-
} of _SecureStoreRegistry.secureStoreRegistry.getAll()) {
|
|
76
|
-
if (options.requireAuthentication) {
|
|
77
|
-
warnings.push(`secure "${key}": biometric-protected, not capturable`);
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
let value = null;
|
|
81
|
-
if (secureModule) {
|
|
82
|
-
try {
|
|
83
|
-
value = await secureModule.getItemAsync(key, options);
|
|
84
|
-
} catch {
|
|
85
|
-
warnings.push(`secure "${key}": unreadable, captured as unset`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
secure[key] = value;
|
|
89
|
-
}
|
|
90
|
-
return {
|
|
91
|
-
data: {
|
|
92
|
-
async: asyncPairs,
|
|
93
|
-
mmkv,
|
|
94
|
-
secure
|
|
95
|
-
},
|
|
96
|
-
warnings
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
async function capture() {
|
|
100
|
-
const {
|
|
101
|
-
data,
|
|
102
|
-
warnings
|
|
103
|
-
} = await captureStorageData();
|
|
104
|
-
return {
|
|
105
|
-
data,
|
|
106
|
-
warnings
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
async function restore(data, options) {
|
|
110
|
-
const snapshot = data;
|
|
111
|
-
const scope = (0, _sharedUi.createRestoreScope)(options);
|
|
112
|
-
/** True when this item may be touched (scope + exclusions agree). */
|
|
113
|
-
const touch = scope.touch;
|
|
114
|
-
const result = (0, _sharedUi.emptyRestoreResult)();
|
|
115
|
-
if (!snapshot) {
|
|
116
|
-
return (0, _sharedUi.failedRestore)("empty storage snapshot");
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// ── AsyncStorage: delete app keys missing from the snapshot, write the rest ──
|
|
120
|
-
try {
|
|
121
|
-
const snapPairs = (snapshot.async ?? []).filter(([k]) => !(0, _sharedUi.isDevToolsStorageKey)(k) && touch(`async:${k}`));
|
|
122
|
-
const snapKeys = new Set(snapPairs.map(([k]) => k));
|
|
123
|
-
const liveKeys = (await _asyncStorage.default.getAllKeys()).filter(k => !(0, _sharedUi.isDevToolsStorageKey)(k));
|
|
124
|
-
const toRemove = liveKeys.filter(k => !snapKeys.has(k) && touch(`async:${k}`));
|
|
125
|
-
scope.countExcluded((snapshot.async ?? []).length - snapPairs.length);
|
|
126
|
-
if (toRemove.length > 0) await (0, _asyncStorageCompat.removeMany)(toRemove);
|
|
127
|
-
if (snapPairs.length > 0) await (0, _asyncStorageCompat.writeMany)(snapPairs);
|
|
128
|
-
result.applied += snapPairs.length + toRemove.length;
|
|
129
|
-
} catch (e) {
|
|
130
|
-
result.ok = false;
|
|
131
|
-
result.warnings.push(`asyncstorage restore failed: ${String(e)}`);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// ── MMKV: per registered writable instance, diff against the snapshot ──
|
|
135
|
-
for (const [id, entries] of Object.entries(snapshot.mmkv ?? {})) {
|
|
136
|
-
const registered = _MMKVInstanceRegistry.mmkvInstanceRegistry.get(id);
|
|
137
|
-
if (!registered) {
|
|
138
|
-
result.skipped.push({
|
|
139
|
-
id: `mmkv:${id}`,
|
|
140
|
-
reason: "instance not registered"
|
|
141
|
-
});
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
if (registered.instance.isReadOnly) {
|
|
145
|
-
result.skipped.push({
|
|
146
|
-
id: `mmkv:${id}`,
|
|
147
|
-
reason: "instance registered read-only"
|
|
148
|
-
});
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
const {
|
|
152
|
-
instance
|
|
153
|
-
} = registered;
|
|
154
|
-
try {
|
|
155
|
-
const snapKeys = new Set(entries.map(e => e.key));
|
|
156
|
-
const liveKeys = instance.getAllKeys().filter(key => !(0, _sharedUi.isDevToolsStorageKey)(key));
|
|
157
|
-
for (const key of liveKeys) {
|
|
158
|
-
if (!scope.allows(`mmkv:${id}/${key}`)) continue;
|
|
159
|
-
if (!snapKeys.has(key)) {
|
|
160
|
-
deleteMMKVKey(instance, key);
|
|
161
|
-
result.applied += 1;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
for (const entry of entries) {
|
|
165
|
-
if ((0, _sharedUi.isDevToolsStorageKey)(entry.key)) continue;
|
|
166
|
-
if (!touch(`mmkv:${id}/${entry.key}`)) continue;
|
|
167
|
-
if (entry.valueType === "buffer") {
|
|
168
|
-
result.skipped.push({
|
|
169
|
-
id: `mmkv:${id}/${entry.key}`,
|
|
170
|
-
reason: "ArrayBuffer values cannot be restored"
|
|
171
|
-
});
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
instance.set(entry.key, entry.value);
|
|
175
|
-
result.applied += 1;
|
|
176
|
-
}
|
|
177
|
-
} catch (e) {
|
|
178
|
-
result.ok = false;
|
|
179
|
-
result.warnings.push(`mmkv "${id}" restore failed: ${String(e)}`);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// ── SecureStore: diff over the registered, non-biometric descriptor list ──
|
|
184
|
-
const secureSnap = snapshot.secure ?? {};
|
|
185
|
-
for (const {
|
|
186
|
-
key,
|
|
187
|
-
options
|
|
188
|
-
} of _SecureStoreRegistry.secureStoreRegistry.getAll()) {
|
|
189
|
-
if (!scope.allows(`secure:${key}`)) continue;
|
|
190
|
-
if (options.requireAuthentication) {
|
|
191
|
-
if (key in secureSnap) {
|
|
192
|
-
result.skipped.push({
|
|
193
|
-
id: `secure:${key}`,
|
|
194
|
-
reason: "biometric-protected keys are never written"
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
try {
|
|
200
|
-
if (key in secureSnap) {
|
|
201
|
-
const value = secureSnap[key];
|
|
202
|
-
if (value === null) await _SecureStoreRegistry.secureStoreRegistry.deleteValue(key);else await _SecureStoreRegistry.secureStoreRegistry.setValue(key, value);
|
|
203
|
-
} else {
|
|
204
|
-
// Registered key with no snapshot entry — snapshot predates it; unset.
|
|
205
|
-
await _SecureStoreRegistry.secureStoreRegistry.deleteValue(key);
|
|
206
|
-
}
|
|
207
|
-
result.applied += 1;
|
|
208
|
-
} catch (e) {
|
|
209
|
-
result.ok = false;
|
|
210
|
-
result.warnings.push(`secure "${key}" restore failed: ${String(e)}`);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
for (const key of Object.keys(secureSnap)) {
|
|
214
|
-
if (!touch(`secure:${key}`)) continue;
|
|
215
|
-
if (!_SecureStoreRegistry.secureStoreRegistry.getAll().some(e => e.key === key)) {
|
|
216
|
-
result.skipped.push({
|
|
217
|
-
id: `secure:${key}`,
|
|
218
|
-
reason: "key no longer registered with registerSecureStoreKeys"
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
const excludedWarning = scope.excludedWarning("item(s)");
|
|
223
|
-
if (excludedWarning) result.warnings.push(excludedWarning);
|
|
224
|
-
return result;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/** Wipe to fresh-install state (Buoy keys preserved). Used by baseline restore. */
|
|
228
|
-
async function clear() {
|
|
229
|
-
const result = (0, _sharedUi.emptyRestoreResult)();
|
|
230
|
-
try {
|
|
231
|
-
await (0, _clearAllStorage.clearAllAppStorage)();
|
|
232
|
-
result.applied += 1;
|
|
233
|
-
} catch (e) {
|
|
234
|
-
result.ok = false;
|
|
235
|
-
result.warnings.push(`asyncstorage clear failed: ${String(e)}`);
|
|
236
|
-
}
|
|
237
|
-
for (const {
|
|
238
|
-
id,
|
|
239
|
-
instance
|
|
240
|
-
} of _MMKVInstanceRegistry.mmkvInstanceRegistry.getAll()) {
|
|
241
|
-
if (instance.isReadOnly) {
|
|
242
|
-
result.skipped.push({
|
|
243
|
-
id: `mmkv:${id}`,
|
|
244
|
-
reason: "instance registered read-only"
|
|
245
|
-
});
|
|
246
|
-
continue;
|
|
247
|
-
}
|
|
248
|
-
try {
|
|
249
|
-
for (const key of instance.getAllKeys().filter(k => !(0, _sharedUi.isDevToolsStorageKey)(k))) {
|
|
250
|
-
deleteMMKVKey(instance, key);
|
|
251
|
-
result.applied += 1;
|
|
252
|
-
}
|
|
253
|
-
} catch (e) {
|
|
254
|
-
result.ok = false;
|
|
255
|
-
result.warnings.push(`mmkv "${id}" clear failed: ${String(e)}`);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
for (const {
|
|
259
|
-
key,
|
|
260
|
-
options
|
|
261
|
-
} of _SecureStoreRegistry.secureStoreRegistry.getAll()) {
|
|
262
|
-
if (options.requireAuthentication) {
|
|
263
|
-
result.skipped.push({
|
|
264
|
-
id: `secure:${key}`,
|
|
265
|
-
reason: "biometric-protected keys are never written"
|
|
266
|
-
});
|
|
267
|
-
continue;
|
|
268
|
-
}
|
|
269
|
-
try {
|
|
270
|
-
await _SecureStoreRegistry.secureStoreRegistry.deleteValue(key);
|
|
271
|
-
result.applied += 1;
|
|
272
|
-
} catch (e) {
|
|
273
|
-
result.ok = false;
|
|
274
|
-
result.warnings.push(`secure "${key}" clear failed: ${String(e)}`);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
return result;
|
|
278
|
-
}
|
|
279
|
-
const ITEM_RENDER_CHAR_LIMIT = 256 * 1024;
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Storage values are strings (or MMKV primitives): identity equality and a
|
|
283
|
-
* character-length size gate are the right tests, not a deep walk.
|
|
284
|
-
*/
|
|
285
|
-
function classifyValue(key, label, oldValue, newValue, inOld, inNew) {
|
|
286
|
-
return (0, _sharedUi.classifyPreviewItem)({
|
|
287
|
-
key,
|
|
288
|
-
label,
|
|
289
|
-
oldValue,
|
|
290
|
-
newValue,
|
|
291
|
-
inOld,
|
|
292
|
-
inNew
|
|
293
|
-
}, {
|
|
294
|
-
equal: Object.is,
|
|
295
|
-
tooLarge: value => typeof value === "string" && value.length > ITEM_RENDER_CHAR_LIMIT,
|
|
296
|
-
tooLargeReason: "value too large to render a diff — restore still applies it"
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/** Per-key restore preview across all three backends. */
|
|
301
|
-
async function previewItems(target, base) {
|
|
302
|
-
const targetData = target ?? {
|
|
303
|
-
async: [],
|
|
304
|
-
mmkv: {},
|
|
305
|
-
secure: {}
|
|
306
|
-
};
|
|
307
|
-
const liveMode = base === undefined;
|
|
308
|
-
const baseData = liveMode ? (await captureStorageData()).data : base ?? {
|
|
309
|
-
async: [],
|
|
310
|
-
mmkv: {},
|
|
311
|
-
secure: {}
|
|
312
|
-
};
|
|
313
|
-
const items = [];
|
|
314
|
-
const notes = [];
|
|
315
|
-
|
|
316
|
-
// ── AsyncStorage ──
|
|
317
|
-
const oldAsync = new Map(baseData.async ?? []);
|
|
318
|
-
const newAsync = new Map(targetData.async ?? []);
|
|
319
|
-
for (const key of (0, _sharedUi.unionKeys)(oldAsync, newAsync)) {
|
|
320
|
-
if ((0, _sharedUi.isDevToolsStorageKey)(key)) continue;
|
|
321
|
-
items.push(classifyValue(`async:${key}`, key, oldAsync.get(key), newAsync.get(key), oldAsync.has(key), newAsync.has(key)));
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// ── MMKV ──
|
|
325
|
-
for (const id of (0, _sharedUi.unionKeys)(baseData.mmkv, targetData.mmkv)) {
|
|
326
|
-
const registered = liveMode ? _MMKVInstanceRegistry.mmkvInstanceRegistry.get(id) : null;
|
|
327
|
-
const instanceUnavailable = liveMode && !registered;
|
|
328
|
-
const readOnly = liveMode && registered?.instance.isReadOnly === true;
|
|
329
|
-
const oldEntries = new Map((baseData.mmkv?.[id] ?? []).map(e => [e.key, e]));
|
|
330
|
-
const newEntries = new Map((targetData.mmkv?.[id] ?? []).map(e => [e.key, e]));
|
|
331
|
-
for (const key of (0, _sharedUi.unionKeys)(oldEntries, newEntries)) {
|
|
332
|
-
if ((0, _sharedUi.isDevToolsStorageKey)(key)) continue;
|
|
333
|
-
const itemKey = `mmkv:${id}/${key}`;
|
|
334
|
-
const label = `${id} · ${key}`;
|
|
335
|
-
const oldE = oldEntries.get(key);
|
|
336
|
-
const newE = newEntries.get(key);
|
|
337
|
-
let item = classifyValue(itemKey, label, oldE?.value, newE?.value, oldEntries.has(key), newEntries.has(key));
|
|
338
|
-
if (instanceUnavailable) {
|
|
339
|
-
item = (0, _sharedUi.wontApply)(item, "MMKV instance not registered");
|
|
340
|
-
} else if (readOnly) {
|
|
341
|
-
item = (0, _sharedUi.wontApply)(item, "MMKV instance registered read-only");
|
|
342
|
-
} else if (newE?.valueType === "buffer" || oldE?.valueType === "buffer") {
|
|
343
|
-
item = (0, _sharedUi.wontApply)(item, "ArrayBuffer values cannot be restored");
|
|
344
|
-
}
|
|
345
|
-
items.push(item);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// ── SecureStore ──
|
|
350
|
-
const oldSecure = baseData.secure ?? {};
|
|
351
|
-
const newSecure = targetData.secure ?? {};
|
|
352
|
-
const registeredSecure = liveMode ? new Map(_SecureStoreRegistry.secureStoreRegistry.getAll().map(e => [e.key, e])) : null;
|
|
353
|
-
for (const key of (0, _sharedUi.unionKeys)(oldSecure, newSecure)) {
|
|
354
|
-
let item = classifyValue(`secure:${key}`, key, oldSecure[key], newSecure[key], key in oldSecure, key in newSecure);
|
|
355
|
-
if (liveMode) {
|
|
356
|
-
const entry = registeredSecure?.get(key);
|
|
357
|
-
if (!entry) {
|
|
358
|
-
item = (0, _sharedUi.wontApply)(item, "key no longer registered with registerSecureStoreKeys");
|
|
359
|
-
} else if (entry.options.requireAuthentication) {
|
|
360
|
-
item = (0, _sharedUi.wontApply)(item, "biometric-protected keys are never written");
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
items.push(item);
|
|
364
|
-
}
|
|
365
|
-
// No blanket "N biometric-protected keys" note: a biometric key a restore
|
|
366
|
-
// would actually touch already gets its own won't-apply row carrying that
|
|
367
|
-
// exact reason, so the note only ever restated it for keys nothing was
|
|
368
|
-
// going to do anything with.
|
|
369
|
-
return {
|
|
370
|
-
items,
|
|
371
|
-
notes
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
(0, _sharedUi.registerStateSnapshotProvider)({
|
|
375
|
-
id: "storage",
|
|
376
|
-
label: "Storage",
|
|
377
|
-
status,
|
|
378
|
-
capture,
|
|
379
|
-
restore,
|
|
380
|
-
clear,
|
|
381
|
-
previewItems
|
|
382
|
-
});
|
|
1
|
+
"use strict";var _asyncStorage=_interopRequireDefault(require("@react-native-async-storage/async-storage"));var _sharedUi=require("@buoy-gg/shared-ui");var _asyncStorageCompat=require("./asyncStorageCompat");var _clearAllStorage=require("./clearAllStorage");var _MMKVInstanceRegistry=require("./MMKVInstanceRegistry");var _mmkvTypeDetection=require("./mmkvTypeDetection");var _SecureStoreRegistry=require("./SecureStoreRegistry");function _interopRequireDefault(s){return s&&s.__esModule?s:{default:s}}function deleteMMKVKey(s,a){if(s.remove)s.remove(a);else s.delete?.(a)}function status(){return{canCapture:true,canRestore:true}}async function captureStorageData(){const s=[];const a=(await _asyncStorage.default.getAllKeys()).filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o));const i=(await(0,_asyncStorageCompat.readMany)(a)).filter(o=>o[1]!==null);const n={};for(const{id:o,instance:f}of _MMKVInstanceRegistry.mmkvInstanceRegistry.getAll()){try{n[o]=f.getAllKeys().filter(e=>!(0,_sharedUi.isDevToolsStorageKey)(e)).map(e=>{const{value:y,type:l}=(0,_mmkvTypeDetection.detectMMKVType)(f,e);if(l==="buffer"){s.push(`mmkv "${o}"/"${e}": ArrayBuffer value not capturable`)}return{key:e,value:y,valueType:l}})}catch{s.push(`mmkv "${o}": unreadable, captured without entries`);n[o]=[]}}const u={};const r=_SecureStoreRegistry.secureStoreRegistry.getModule();for(const{key:o,options:f}of _SecureStoreRegistry.secureStoreRegistry.getAll()){if(f.requireAuthentication){s.push(`secure "${o}": biometric-protected, not capturable`);continue}let e=null;if(r){try{e=await r.getItemAsync(o,f)}catch{s.push(`secure "${o}": unreadable, captured as unset`)}}u[o]=e}return{data:{async:i,mmkv:n,secure:u},warnings:s}}async function capture(){const{data:s,warnings:a}=await captureStorageData();return{data:s,warnings:a}}async function restore(s,a){const i=s;const n=(0,_sharedUi.createRestoreScope)(a);const u=n.touch;const r=(0,_sharedUi.emptyRestoreResult)();if(!i){return(0,_sharedUi.failedRestore)("empty storage snapshot")}try{const e=(i.async??[]).filter(([t])=>!(0,_sharedUi.isDevToolsStorageKey)(t)&&u(`async:${t}`));const y=new Set(e.map(([t])=>t));const l=(await _asyncStorage.default.getAllKeys()).filter(t=>!(0,_sharedUi.isDevToolsStorageKey)(t));const d=l.filter(t=>!y.has(t)&&u(`async:${t}`));n.countExcluded((i.async??[]).length-e.length);if(d.length>0)await(0,_asyncStorageCompat.removeMany)(d);if(e.length>0)await(0,_asyncStorageCompat.writeMany)(e);r.applied+=e.length+d.length}catch(e){r.ok=false;r.warnings.push(`asyncstorage restore failed: ${String(e)}`)}for(const[e,y]of Object.entries(i.mmkv??{})){const l=_MMKVInstanceRegistry.mmkvInstanceRegistry.get(e);if(!l){r.skipped.push({id:`mmkv:${e}`,reason:"instance not registered"});continue}if(l.instance.isReadOnly){r.skipped.push({id:`mmkv:${e}`,reason:"instance registered read-only"});continue}const{instance:d}=l;try{const t=new Set(y.map(c=>c.key));const g=d.getAllKeys().filter(c=>!(0,_sharedUi.isDevToolsStorageKey)(c));for(const c of g){if(!n.allows(`mmkv:${e}/${c}`))continue;if(!t.has(c)){deleteMMKVKey(d,c);r.applied+=1}}for(const c of y){if((0,_sharedUi.isDevToolsStorageKey)(c.key))continue;if(!u(`mmkv:${e}/${c.key}`))continue;if(c.valueType==="buffer"){r.skipped.push({id:`mmkv:${e}/${c.key}`,reason:"ArrayBuffer values cannot be restored"});continue}d.set(c.key,c.value);r.applied+=1}}catch(t){r.ok=false;r.warnings.push(`mmkv "${e}" restore failed: ${String(t)}`)}}const o=i.secure??{};for(const{key:e,options:y}of _SecureStoreRegistry.secureStoreRegistry.getAll()){if(!n.allows(`secure:${e}`))continue;if(y.requireAuthentication){if(e in o){r.skipped.push({id:`secure:${e}`,reason:"biometric-protected keys are never written"})}continue}try{if(e in o){const l=o[e];if(l===null)await _SecureStoreRegistry.secureStoreRegistry.deleteValue(e);else await _SecureStoreRegistry.secureStoreRegistry.setValue(e,l)}else{await _SecureStoreRegistry.secureStoreRegistry.deleteValue(e)}r.applied+=1}catch(l){r.ok=false;r.warnings.push(`secure "${e}" restore failed: ${String(l)}`)}}for(const e of Object.keys(o)){if(!u(`secure:${e}`))continue;if(!_SecureStoreRegistry.secureStoreRegistry.getAll().some(y=>y.key===e)){r.skipped.push({id:`secure:${e}`,reason:"key no longer registered with registerSecureStoreKeys"})}}const f=n.excludedWarning("item(s)");if(f)r.warnings.push(f);return r}async function clear(){const s=(0,_sharedUi.emptyRestoreResult)();try{await(0,_clearAllStorage.clearAllAppStorage)();s.applied+=1}catch(a){s.ok=false;s.warnings.push(`asyncstorage clear failed: ${String(a)}`)}for(const{id:a,instance:i}of _MMKVInstanceRegistry.mmkvInstanceRegistry.getAll()){if(i.isReadOnly){s.skipped.push({id:`mmkv:${a}`,reason:"instance registered read-only"});continue}try{for(const n of i.getAllKeys().filter(u=>!(0,_sharedUi.isDevToolsStorageKey)(u))){deleteMMKVKey(i,n);s.applied+=1}}catch(n){s.ok=false;s.warnings.push(`mmkv "${a}" clear failed: ${String(n)}`)}}for(const{key:a,options:i}of _SecureStoreRegistry.secureStoreRegistry.getAll()){if(i.requireAuthentication){s.skipped.push({id:`secure:${a}`,reason:"biometric-protected keys are never written"});continue}try{await _SecureStoreRegistry.secureStoreRegistry.deleteValue(a);s.applied+=1}catch(n){s.ok=false;s.warnings.push(`secure "${a}" clear failed: ${String(n)}`)}}return s}const ITEM_RENDER_CHAR_LIMIT=256*1024;function classifyValue(s,a,i,n,u,r){return(0,_sharedUi.classifyPreviewItem)({key:s,label:a,oldValue:i,newValue:n,inOld:u,inNew:r},{equal:Object.is,tooLarge:o=>typeof o==="string"&&o.length>ITEM_RENDER_CHAR_LIMIT,tooLargeReason:"value too large to render a diff \u2014 restore still applies it"})}async function previewItems(s,a){const i=s??{async:[],mmkv:{},secure:{}};const n=a===void 0;const u=n?(await captureStorageData()).data:a??{async:[],mmkv:{},secure:{}};const r=[];const o=[];const f=new Map(u.async??[]);const e=new Map(i.async??[]);for(const t of(0,_sharedUi.unionKeys)(f,e)){if((0,_sharedUi.isDevToolsStorageKey)(t))continue;r.push(classifyValue(`async:${t}`,t,f.get(t),e.get(t),f.has(t),e.has(t)))}for(const t of(0,_sharedUi.unionKeys)(u.mmkv,i.mmkv)){const g=n?_MMKVInstanceRegistry.mmkvInstanceRegistry.get(t):null;const c=n&&!g;const w=n&&g?.instance.isReadOnly===true;const v=new Map((u.mmkv?.[t]??[]).map(p=>[p.key,p]));const k=new Map((i.mmkv?.[t]??[]).map(p=>[p.key,p]));for(const p of(0,_sharedUi.unionKeys)(v,k)){if((0,_sharedUi.isDevToolsStorageKey)(p))continue;const $=`mmkv:${t}/${p}`;const R=`${t} \xB7 ${p}`;const h=v.get(p);const S=k.get(p);let m=classifyValue($,R,h?.value,S?.value,v.has(p),k.has(p));if(c){m=(0,_sharedUi.wontApply)(m,"MMKV instance not registered")}else if(w){m=(0,_sharedUi.wontApply)(m,"MMKV instance registered read-only")}else if(S?.valueType==="buffer"||h?.valueType==="buffer"){m=(0,_sharedUi.wontApply)(m,"ArrayBuffer values cannot be restored")}r.push(m)}}const y=u.secure??{};const l=i.secure??{};const d=n?new Map(_SecureStoreRegistry.secureStoreRegistry.getAll().map(t=>[t.key,t])):null;for(const t of(0,_sharedUi.unionKeys)(y,l)){let g=classifyValue(`secure:${t}`,t,y[t],l[t],t in y,t in l);if(n){const c=d?.get(t);if(!c){g=(0,_sharedUi.wontApply)(g,"key no longer registered with registerSecureStoreKeys")}else if(c.options.requireAuthentication){g=(0,_sharedUi.wontApply)(g,"biometric-protected keys are never written")}}r.push(g)}return{items:r,notes:o}}(0,_sharedUi.registerStateSnapshotProvider)({id:"storage",label:"Storage",status,capture,restore,clear,previewItems});
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.translateStorageAction = translateStorageAction;
|
|
7
|
-
/**
|
|
8
|
-
* Translates storage action types to human-readable labels
|
|
9
|
-
*/
|
|
10
|
-
function translateStorageAction(action) {
|
|
11
|
-
switch (action) {
|
|
12
|
-
// AsyncStorage actions
|
|
13
|
-
case "setItem":
|
|
14
|
-
return "SET";
|
|
15
|
-
case "removeItem":
|
|
16
|
-
return "REMOVE";
|
|
17
|
-
case "mergeItem":
|
|
18
|
-
return "MERGE";
|
|
19
|
-
case "clear":
|
|
20
|
-
return "CLEAR";
|
|
21
|
-
case "multiSet":
|
|
22
|
-
return "MULTI SET";
|
|
23
|
-
case "multiRemove":
|
|
24
|
-
return "MULTI REMOVE";
|
|
25
|
-
case "multiMerge":
|
|
26
|
-
return "MULTI MERGE";
|
|
27
|
-
|
|
28
|
-
// MMKV actions - simplified to match AsyncStorage
|
|
29
|
-
case "set.string":
|
|
30
|
-
case "set.number":
|
|
31
|
-
case "set.boolean":
|
|
32
|
-
case "set.buffer":
|
|
33
|
-
return "SET";
|
|
34
|
-
case "delete":
|
|
35
|
-
return "REMOVE";
|
|
36
|
-
case "clearAll":
|
|
37
|
-
return "CLEAR";
|
|
38
|
-
case "get.string":
|
|
39
|
-
case "get.number":
|
|
40
|
-
case "get.boolean":
|
|
41
|
-
case "get.buffer":
|
|
42
|
-
return "GET";
|
|
43
|
-
default:
|
|
44
|
-
return "UNKNOWN ACTION";
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.translateStorageAction=translateStorageAction;function translateStorageAction(e){switch(e){case"setItem":return"SET";case"removeItem":return"REMOVE";case"mergeItem":return"MERGE";case"clear":return"CLEAR";case"multiSet":return"MULTI SET";case"multiRemove":return"MULTI REMOVE";case"multiMerge":return"MULTI MERGE";case"set.string":case"set.number":case"set.boolean":case"set.buffer":return"SET";case"delete":return"REMOVE";case"clearAll":return"CLEAR";case"get.string":case"get.number":case"get.boolean":case"get.buffer":return"GET";default:return"UNKNOWN ACTION"}}
|
|
@@ -1,49 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.onStorageBrowserRefresh = onStorageBrowserRefresh;
|
|
7
|
-
exports.requestStorageBrowserRefresh = requestStorageBrowserRefresh;
|
|
8
|
-
/**
|
|
9
|
-
* A "the underlying storage changed, re-read it" signal for the storage
|
|
10
|
-
* browser.
|
|
11
|
-
*
|
|
12
|
-
* On device the browser refreshes itself from the AsyncStorage/MMKV listeners,
|
|
13
|
-
* but those never fire in remote-mirror mode (the desktop dashboard suppresses
|
|
14
|
-
* local capture and receives the device's events as snapshots instead). Without
|
|
15
|
-
* this seam the browse tab is a one-shot read at mount — values stay frozen
|
|
16
|
-
* until the panel remounts, which is exactly the "shows old data until I switch
|
|
17
|
-
* tools and come back" behaviour.
|
|
18
|
-
*
|
|
19
|
-
* The dashboard calls {@link requestStorageBrowserRefresh} whenever a fresh
|
|
20
|
-
* device snapshot lands; the browser re-reads all three backends (debounced).
|
|
21
|
-
* It is a no-op when nothing is listening.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
const listeners = new Set();
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Subscribe to external refresh requests. Returns an unsubscribe function.
|
|
28
|
-
* @internal — used by the storage browser.
|
|
29
|
-
*/
|
|
30
|
-
function onStorageBrowserRefresh(listener) {
|
|
31
|
-
listeners.add(listener);
|
|
32
|
-
return () => {
|
|
33
|
-
listeners.delete(listener);
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Ask any mounted storage browser to re-read AsyncStorage, MMKV and
|
|
39
|
-
* SecureStore. Safe to call at any rate — the browser debounces.
|
|
40
|
-
*/
|
|
41
|
-
function requestStorageBrowserRefresh() {
|
|
42
|
-
listeners.forEach(listener => {
|
|
43
|
-
try {
|
|
44
|
-
listener();
|
|
45
|
-
} catch {
|
|
46
|
-
// Listener errors are not ours
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.onStorageBrowserRefresh=onStorageBrowserRefresh;exports.requestStorageBrowserRefresh=requestStorageBrowserRefresh;const listeners=new Set;function onStorageBrowserRefresh(e){listeners.add(e);return()=>{listeners.delete(e)}}function requestStorageBrowserRefresh(){listeners.forEach(e=>{try{e()}catch{}})}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.storageLabels=void 0;const storageLabels=exports.storageLabels={async:"Async",asyncFull:"AsyncStorage",mmkv:"MMKV",secure:"Secure",hasSecure:true};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.storageLabels=void 0;const storageLabels=exports.storageLabels={async:"Local",asyncFull:"localStorage",mmkv:"Session",secure:"Secure",hasSecure:false};
|
|
@@ -1,53 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.STORAGE_OPS = void 0;
|
|
7
|
-
exports.isInitialScan = isInitialScan;
|
|
8
|
-
exports.storageOpDot = storageOpDot;
|
|
9
|
-
exports.storageOpOf = storageOpOf;
|
|
10
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
11
|
-
/**
|
|
12
|
-
* The five operations a storage event can be, and how to recognise one.
|
|
13
|
-
*
|
|
14
|
-
* AsyncStorage and MMKV each have their own action union, and neither maps
|
|
15
|
-
* cleanly onto what a reader wants to see — `multiRemove`, `removeItem` and
|
|
16
|
-
* `delete` are one idea wearing three names. These collapse both onto a single
|
|
17
|
-
* vocabulary so every surface labels, filters and colours events the same way.
|
|
18
|
-
*
|
|
19
|
-
* This is semantics, not presentation: it lives in `utils` rather than beside
|
|
20
|
-
* any one view, so a view can be deleted without taking the vocabulary with it.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
const STORAGE_OPS = exports.STORAGE_OPS = ["SET", "GET", "MERGE", "DELETE", "CLEAR"];
|
|
24
|
-
const OP_DOT = {
|
|
25
|
-
SET: _sharedUi.macOSColors.semantic.info,
|
|
26
|
-
GET: _sharedUi.macOSColors.text.muted,
|
|
27
|
-
MERGE: _sharedUi.macOSColors.semantic.debug,
|
|
28
|
-
DELETE: _sharedUi.macOSColors.semantic.error,
|
|
29
|
-
CLEAR: _sharedUi.macOSColors.semantic.warning
|
|
30
|
-
};
|
|
31
|
-
function storageOpDot(op) {
|
|
32
|
-
return OP_DOT[op];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Both backends' action unions, collapsed onto the five display operations. */
|
|
36
|
-
function storageOpOf(event) {
|
|
37
|
-
const action = event.action;
|
|
38
|
-
if (action === "clear" || action === "clearAll") return "CLEAR";
|
|
39
|
-
if (action.startsWith("get.")) return "GET";
|
|
40
|
-
if (action === "removeItem" || action === "multiRemove" || action === "delete") return "DELETE";
|
|
41
|
-
if (action === "mergeItem" || action === "multiMerge") return "MERGE";
|
|
42
|
-
return "SET";
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* The store synthesises one event per existing key when it first subscribes, so
|
|
47
|
-
* the list isn't empty on open. Those are a SNAPSHOT, not a write: the key
|
|
48
|
-
* already held that value, so there is no "before" to diff against and showing
|
|
49
|
-
* one would invent a change that never happened.
|
|
50
|
-
*/
|
|
51
|
-
function isInitialScan(event) {
|
|
52
|
-
return Boolean(event.data?.initialScan);
|
|
53
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.STORAGE_OPS=void 0;exports.isInitialScan=isInitialScan;exports.storageOpDot=storageOpDot;exports.storageOpOf=storageOpOf;var _sharedUi=require("@buoy-gg/shared-ui");const STORAGE_OPS=exports.STORAGE_OPS=["SET","GET","MERGE","DELETE","CLEAR"];const OP_DOT={SET:_sharedUi.macOSColors.semantic.info,GET:_sharedUi.macOSColors.text.muted,MERGE:_sharedUi.macOSColors.semantic.debug,DELETE:_sharedUi.macOSColors.semantic.error,CLEAR:_sharedUi.macOSColors.semantic.warning};function storageOpDot(t){return OP_DOT[t]}function storageOpOf(t){const e=t.action;if(e==="clear"||e==="clearAll")return"CLEAR";if(e.startsWith("get."))return"GET";if(e==="removeItem"||e==="multiRemove"||e==="delete")return"DELETE";if(e==="mergeItem"||e==="multiMerge")return"MERGE";return"SET"}function isInitialScan(t){return Boolean(t.data?.initialScan)}
|
|
@@ -1,35 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getStorageTypeHexColor = getStorageTypeHexColor;
|
|
7
|
-
exports.getStorageTypeLabel = getStorageTypeLabel;
|
|
8
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
9
|
-
/** Human readable label for a storage type id. */
|
|
10
|
-
function getStorageTypeLabel(storageType) {
|
|
11
|
-
switch (storageType) {
|
|
12
|
-
case "mmkv":
|
|
13
|
-
return "MMKV";
|
|
14
|
-
case "async":
|
|
15
|
-
return "Async";
|
|
16
|
-
case "secure":
|
|
17
|
-
return "Secure";
|
|
18
|
-
default:
|
|
19
|
-
return storageType;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** Preferred color token for rendering a given storage type. */
|
|
24
|
-
function getStorageTypeHexColor(storageType) {
|
|
25
|
-
switch (storageType) {
|
|
26
|
-
case "mmkv":
|
|
27
|
-
return _sharedUi.gameUIColors.info;
|
|
28
|
-
case "async":
|
|
29
|
-
return _sharedUi.gameUIColors.warning;
|
|
30
|
-
case "secure":
|
|
31
|
-
return _sharedUi.gameUIColors.success;
|
|
32
|
-
default:
|
|
33
|
-
return _sharedUi.gameUIColors.muted;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getStorageTypeHexColor=getStorageTypeHexColor;exports.getStorageTypeLabel=getStorageTypeLabel;var _sharedUi=require("@buoy-gg/shared-ui");function getStorageTypeLabel(e){switch(e){case"mmkv":return"MMKV";case"async":return"Async";case"secure":return"Secure";default:return e}}function getStorageTypeHexColor(e){switch(e){case"mmkv":return _sharedUi.gameUIColors.info;case"async":return _sharedUi.gameUIColors.warning;case"secure":return _sharedUi.gameUIColors.success;default:return _sharedUi.gameUIColors.muted}}
|