@buoy-gg/storage 7.0.41 → 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 -90
- package/lib/commonjs/index.js +1 -353
- package/lib/commonjs/preset.js +1 -85
- 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 -1259
- package/lib/commonjs/storage/components/MMKVInstanceInfoPanel.js +1 -257
- package/lib/commonjs/storage/components/MMKVInstanceSelector.js +1 -419
- package/lib/commonjs/storage/components/SelectionActionBar.js +1 -207
- package/lib/commonjs/storage/components/StorageActionButtons.js +1 -242
- 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 -118
- package/lib/commonjs/storage/components/StorageEventDetailContent.js +1 -494
- package/lib/commonjs/storage/components/StorageEventFilterView.js +1 -160
- 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 -345
- 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 -144
- 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 -202
- 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 -492
- 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 -89
- 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 -10
- package/lib/commonjs/storage/utils/browserStorageLifecycle.web.js +1 -70
- 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 -21
- 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 -13
- package/lib/commonjs/storage/utils/storageLabels.web.js +1 -13
- 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 -114
- package/lib/module/preset.js +1 -82
- 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 -1257
- package/lib/module/storage/components/MMKVInstanceInfoPanel.js +1 -253
- package/lib/module/storage/components/MMKVInstanceSelector.js +1 -415
- package/lib/module/storage/components/SelectionActionBar.js +1 -204
- package/lib/module/storage/components/StorageActionButtons.js +1 -238
- 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 -113
- package/lib/module/storage/components/StorageEventDetailContent.js +1 -490
- package/lib/module/storage/components/StorageEventFilterView.js +1 -156
- 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 -342
- 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 -139
- 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 -199
- 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 -486
- 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 -76
- 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 -6
- package/lib/module/storage/utils/browserStorageLifecycle.web.js +1 -66
- 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 -15
- 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 -9
- package/lib/module/storage/utils/storageLabels.web.js +1 -9
- 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/web/index.mjs +2 -3
- package/package.json +5 -5
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
- package/lib/typescript/storage/components/DiffViewer/TreeDiffViewer.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/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/StorageSection.d.ts.map +0 -1
- package/lib/typescript/storage/components/StorageTypeFilterBar.d.ts.map +0 -1
- package/lib/typescript/storage/hooks/useAsyncStorageKeys.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/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/AsyncStorageListener.web.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/browserStorageLifecycle.d.ts.map +0 -1
- package/lib/typescript/storage/utils/browserStorageLifecycle.web.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/mmkvAvailability.web.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/storageLabels.d.ts.map +0 -1
- package/lib/typescript/storage/utils/storageLabels.web.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,89 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.asyncStorageCaps = exports.asyncStorage = void 0;
|
|
7
|
-
exports.readMany = readMany;
|
|
8
|
-
exports.removeMany = removeMany;
|
|
9
|
-
exports.writeMany = writeMany;
|
|
10
|
-
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
/**
|
|
13
|
-
* AsyncStorage compatibility adapter (v2 + v3)
|
|
14
|
-
*
|
|
15
|
-
* `@react-native-async-storage/async-storage` 3.x reshaped the default-export
|
|
16
|
-
* API. The single-item methods kept their v2 signatures, but the batch + merge
|
|
17
|
-
* methods changed:
|
|
18
|
-
*
|
|
19
|
-
* v2 (what this package was written against) v3
|
|
20
|
-
* ------------------------------------------ --------------------------------
|
|
21
|
-
* multiGet(keys): [key, value|null][] getMany(keys): Record<key, value|null>
|
|
22
|
-
* multiSet([[k, v]]): void setMany({ k: v }): void
|
|
23
|
-
* multiRemove(keys): void removeMany(keys): void
|
|
24
|
-
* mergeItem / multiMerge removed entirely
|
|
25
|
-
*
|
|
26
|
-
* This module is the single seam between the storage tool and whichever
|
|
27
|
-
* async-storage version the host app installed. The rest of the package always
|
|
28
|
-
* speaks the v2 tuple-shaped API; we translate to v3 here when needed.
|
|
29
|
-
*
|
|
30
|
-
* Reads (`readMany`) are routed through the *unswizzled* native methods, so the
|
|
31
|
-
* event listener can safely call them while capturing previous values without
|
|
32
|
-
* re-triggering itself.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
// Loosely typed because the surface differs across major versions; callers go
|
|
36
|
-
// through the helpers below rather than touching this directly.
|
|
37
|
-
|
|
38
|
-
/** The live default-export object (methods may be swizzled by the listener). */
|
|
39
|
-
const asyncStorage = exports.asyncStorage = _asyncStorage.default;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Capability flags describing which API surface the installed version exposes.
|
|
43
|
-
* `multiGet` only exists on v2; `mergeItem` was removed in v3.
|
|
44
|
-
*/
|
|
45
|
-
const asyncStorageCaps = exports.asyncStorageCaps = {
|
|
46
|
-
/** v2 exposes multiGet/multiSet/multiRemove; v3 renamed these to *Many. */
|
|
47
|
-
hasLegacyMultiApi: typeof asyncStorage?.multiGet === "function",
|
|
48
|
-
/** v3 removed mergeItem/multiMerge with no replacement. */
|
|
49
|
-
hasMergeApi: typeof asyncStorage?.mergeItem === "function"
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Batch-read keys, normalized to the v2 `[key, value|null][]` tuple shape and
|
|
54
|
-
* preserving the requested key order regardless of installed version.
|
|
55
|
-
*/
|
|
56
|
-
async function readMany(keys) {
|
|
57
|
-
if (typeof asyncStorage.multiGet === "function") {
|
|
58
|
-
return await asyncStorage.multiGet(keys);
|
|
59
|
-
}
|
|
60
|
-
// v3: getMany returns a Record; rebuild ordered tuples ("what you request is
|
|
61
|
-
// what you get" — missing keys come back as null).
|
|
62
|
-
const record = await asyncStorage.getMany(keys);
|
|
63
|
-
return keys.map(key => [key, record[key] ?? null]);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Batch-write key/value pairs. Calls the live method (which may be swizzled by
|
|
68
|
-
* the listener on v2's `multiSet` / v3's `setMany`) so writes still emit events.
|
|
69
|
-
*/
|
|
70
|
-
async function writeMany(pairs) {
|
|
71
|
-
if (typeof asyncStorage.multiSet === "function") {
|
|
72
|
-
return asyncStorage.multiSet(pairs);
|
|
73
|
-
}
|
|
74
|
-
const record = {};
|
|
75
|
-
for (const [key, value] of pairs) record[key] = value;
|
|
76
|
-
return asyncStorage.setMany(record);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Batch-remove keys via the live method (swizzled on v2's `multiRemove` /
|
|
81
|
-
* v3's `removeMany`).
|
|
82
|
-
*/
|
|
83
|
-
async function removeMany(keys) {
|
|
84
|
-
if (typeof asyncStorage.multiRemove === "function") {
|
|
85
|
-
return asyncStorage.multiRemove(keys);
|
|
86
|
-
}
|
|
87
|
-
return asyncStorage.removeMany(keys);
|
|
88
|
-
}
|
|
89
|
-
var _default = exports.default = asyncStorage;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.asyncStorageCaps=exports.asyncStorage=void 0;exports.readMany=readMany;exports.removeMany=removeMany;exports.writeMany=writeMany;var _asyncStorage=_interopRequireDefault(require("@react-native-async-storage/async-storage"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const asyncStorage=exports.asyncStorage=_asyncStorage.default;const asyncStorageCaps=exports.asyncStorageCaps={hasLegacyMultiApi:typeof asyncStorage?.multiGet==="function",hasMergeApi:typeof asyncStorage?.mergeItem==="function"};async function readMany(e){if(typeof asyncStorage.multiGet==="function"){return await asyncStorage.multiGet(e)}const t=await asyncStorage.getMany(e);return e.map(r=>[r,t[r]??null])}async function writeMany(e){if(typeof asyncStorage.multiSet==="function"){return asyncStorage.multiSet(e)}const t={};for(const[r,n]of e)t[r]=n;return asyncStorage.setMany(t)}async function removeMany(e){if(typeof asyncStorage.multiRemove==="function"){return asyncStorage.multiRemove(e)}return asyncStorage.removeMany(e)}var _default=exports.default=asyncStorage;
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.startBrowserStorageCapture = startBrowserStorageCapture;
|
|
7
|
-
/** Native backends are registered by the host application. */
|
|
8
|
-
function startBrowserStorageCapture() {
|
|
9
|
-
return () => {};
|
|
10
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.startBrowserStorageCapture=startBrowserStorageCapture;function startBrowserStorageCapture(){return()=>{}}
|
|
@@ -1,70 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.startBrowserStorageCapture = startBrowserStorageCapture;
|
|
7
|
-
var _utils = require("@buoy-gg/shared-ui/utils");
|
|
8
|
-
var _MMKVInstanceRegistry = require("./MMKVInstanceRegistry");
|
|
9
|
-
let owners = 0;
|
|
10
|
-
const storage = () => (0, _utils.getBrowserStorage)('sessionStorage');
|
|
11
|
-
const keys = () => Array.from({
|
|
12
|
-
length: storage().length
|
|
13
|
-
}, (_, index) => storage().key(index)).filter(key => key !== null);
|
|
14
|
-
// Reuse the synchronous storage editor and snapshot provider with Web Storage strings.
|
|
15
|
-
const sessionBackend = {
|
|
16
|
-
set(key, value) {
|
|
17
|
-
storage().setItem(key, String(value));
|
|
18
|
-
},
|
|
19
|
-
getString(key) {
|
|
20
|
-
return storage().getItem(key) ?? undefined;
|
|
21
|
-
},
|
|
22
|
-
getNumber() {
|
|
23
|
-
return undefined;
|
|
24
|
-
},
|
|
25
|
-
getBoolean() {
|
|
26
|
-
return undefined;
|
|
27
|
-
},
|
|
28
|
-
getBuffer() {
|
|
29
|
-
return undefined;
|
|
30
|
-
},
|
|
31
|
-
contains(key) {
|
|
32
|
-
return storage().getItem(key) !== null;
|
|
33
|
-
},
|
|
34
|
-
delete(key) {
|
|
35
|
-
const found = this.contains(key);
|
|
36
|
-
storage().removeItem(key);
|
|
37
|
-
return found;
|
|
38
|
-
},
|
|
39
|
-
getAllKeys: keys,
|
|
40
|
-
clearAll() {
|
|
41
|
-
storage().clear();
|
|
42
|
-
},
|
|
43
|
-
get size() {
|
|
44
|
-
return keys().reduce((bytes, key) => bytes + 2 * (key.length + (storage().getItem(key)?.length ?? 0)), 0);
|
|
45
|
-
},
|
|
46
|
-
addOnValueChangedListener(listener) {
|
|
47
|
-
return {
|
|
48
|
-
remove: (0, _utils.subscribeToBrowserStorage)(change => {
|
|
49
|
-
if (change.area !== 'sessionStorage') return;
|
|
50
|
-
if (change.key !== undefined) listener(change.key);else change.prevPairs?.forEach(([key]) => listener(key));
|
|
51
|
-
})
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
function startBrowserStorageCapture() {
|
|
56
|
-
if (typeof window === 'undefined') return () => {};
|
|
57
|
-
try {
|
|
58
|
-
storage();
|
|
59
|
-
} catch {
|
|
60
|
-
return () => {};
|
|
61
|
-
}
|
|
62
|
-
if (++owners === 1) (0, _MMKVInstanceRegistry.registerMMKVInstance)('sessionStorage', sessionBackend);
|
|
63
|
-
let active = true;
|
|
64
|
-
return () => {
|
|
65
|
-
if (active) {
|
|
66
|
-
active = false;
|
|
67
|
-
if (--owners === 0) (0, _MMKVInstanceRegistry.unregisterMMKVInstance)('sessionStorage');
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.startBrowserStorageCapture=startBrowserStorageCapture;var _utils=require("@buoy-gg/shared-ui/utils");var _MMKVInstanceRegistry=require("./MMKVInstanceRegistry");let owners=0;const storage=()=>(0,_utils.getBrowserStorage)("sessionStorage");const keys=()=>Array.from({length:storage().length},(e,r)=>storage().key(r)).filter(e=>e!==null);const sessionBackend={set(e,r){storage().setItem(e,String(r))},getString(e){return storage().getItem(e)??void 0},getNumber(){return void 0},getBoolean(){return void 0},getBuffer(){return void 0},contains(e){return storage().getItem(e)!==null},delete(e){const r=this.contains(e);storage().removeItem(e);return r},getAllKeys:keys,clearAll(){storage().clear()},get size(){return keys().reduce((e,r)=>e+2*(r.length+(storage().getItem(r)?.length??0)),0)},addOnValueChangedListener(e){return{remove:(0,_utils.subscribeToBrowserStorage)(r=>{if(r.area!=="sessionStorage")return;if(r.key!==void 0)e(r.key);else r.prevPairs?.forEach(([t])=>e(t))})}}};function startBrowserStorageCapture(){if(typeof window==="undefined")return()=>{};try{storage()}catch{return()=>{}}if(++owners===1)(0,_MMKVInstanceRegistry.registerMMKVInstance)("sessionStorage",sessionBackend);let e=true;return()=>{if(e){e=false;if(--owners===0)(0,_MMKVInstanceRegistry.unregisterMMKVInstance)("sessionStorage")}}}
|
|
@@ -1,48 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.clearAllAppStorage = clearAllAppStorage;
|
|
7
|
-
exports.clearAllStorageIncludingDevTools = clearAllStorageIncludingDevTools;
|
|
8
|
-
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
9
|
-
var _asyncStorageCompat = require("./asyncStorageCompat");
|
|
10
|
-
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
/**
|
|
13
|
-
* Clear all storage data except dev tools keys
|
|
14
|
-
* This preserves dev tool settings while clearing app data
|
|
15
|
-
*/
|
|
16
|
-
async function clearAllAppStorage() {
|
|
17
|
-
// Get all keys
|
|
18
|
-
const allKeys = await _asyncStorage.default.getAllKeys();
|
|
19
|
-
if (!allKeys || allKeys.length === 0) {
|
|
20
|
-
// No keys to clear
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Filter out dev tool keys - we don't want to clear those
|
|
25
|
-
const keysToRemove = allKeys.filter(key => !(0, _sharedUi.isDevToolsStorageKey)(key));
|
|
26
|
-
if (keysToRemove.length === 0) {
|
|
27
|
-
// No app keys to clear (only dev tool keys found)
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Clearing ${keysToRemove.length} app storage keys
|
|
32
|
-
|
|
33
|
-
// Remove all non-dev-tool keys
|
|
34
|
-
await (0, _asyncStorageCompat.removeMany)(keysToRemove);
|
|
35
|
-
|
|
36
|
-
// Successfully cleared app storage
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Clear absolutely all storage data including dev tools
|
|
41
|
-
* Use with caution - this will reset all dev tool settings
|
|
42
|
-
*/
|
|
43
|
-
async function clearAllStorageIncludingDevTools() {
|
|
44
|
-
// Clear everything
|
|
45
|
-
await _asyncStorage.default.clear();
|
|
46
|
-
|
|
47
|
-
// Successfully cleared all storage including dev tools
|
|
48
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.clearAllAppStorage=clearAllAppStorage;exports.clearAllStorageIncludingDevTools=clearAllStorageIncludingDevTools;var _asyncStorage=_interopRequireDefault(require("@react-native-async-storage/async-storage"));var _asyncStorageCompat=require("./asyncStorageCompat");var _sharedUi=require("@buoy-gg/shared-ui");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}async function clearAllAppStorage(){const e=await _asyncStorage.default.getAllKeys();if(!e||e.length===0){return}const a=e.filter(r=>!(0,_sharedUi.isDevToolsStorageKey)(r));if(a.length===0){return}await(0,_asyncStorageCompat.removeMany)(a)}async function clearAllStorageIncludingDevTools(){await _asyncStorage.default.clear()}
|
|
@@ -1,82 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.deleteStorageKeys = deleteStorageKeys;
|
|
7
|
-
var _asyncStorageCompat = require("./asyncStorageCompat");
|
|
8
|
-
var _SecureStoreRegistry = require("./SecureStoreRegistry");
|
|
9
|
-
/**
|
|
10
|
-
* Deleting storage keys, in one place.
|
|
11
|
-
*
|
|
12
|
-
* Each backend removes keys differently — AsyncStorage takes a batch,
|
|
13
|
-
* SecureStore has to go through the registry (only it knows each key's
|
|
14
|
-
* `keychainService` options), and MMKV deletes per registered instance. A
|
|
15
|
-
* second copy of that fan-out is exactly how one backend quietly stops being
|
|
16
|
-
* cleaned up — which is not hypothetical: the MMKV branch called a method
|
|
17
|
-
* react-native-mmkv v4 had renamed, and deleting an MMKV key silently did
|
|
18
|
-
* nothing until an e2e test deleted from all three backends at once.
|
|
19
|
-
*
|
|
20
|
-
* One call site today: the selection action bar. Deleting is deliberately not
|
|
21
|
-
* an affordance on the row itself — see `StorageKeyRow`, whose expanded card
|
|
22
|
-
* carries three actions and only one of them changes anything.
|
|
23
|
-
*
|
|
24
|
-
* Pro gating and confirmation are deliberately NOT here: they belong to the UI
|
|
25
|
-
* that has the user's attention. This function assumes the caller already asked.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Remove one key from an MMKV instance, whichever version it is.
|
|
30
|
-
*
|
|
31
|
-
* react-native-mmkv v4 renamed `delete(key)` to `remove(key)`. Calling the old
|
|
32
|
-
* name on a v4 instance throws, and because the callers wrap deletion in a
|
|
33
|
-
* try/catch that only surfaces an alert, the visible result was a key that
|
|
34
|
-
* refused to delete — the same shape as a permissions problem or a read-only
|
|
35
|
-
* instance, and nothing to point at the real cause.
|
|
36
|
-
*
|
|
37
|
-
* `storageSyncAdapter` and `snapshotProvider` already did this; this path was
|
|
38
|
-
* the one that missed it.
|
|
39
|
-
*/
|
|
40
|
-
function removeMMKVKey(instance, key) {
|
|
41
|
-
if (typeof instance.remove === "function") {
|
|
42
|
-
instance.remove(key);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (typeof instance.delete === "function") {
|
|
46
|
-
instance.delete(key);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
throw new Error("MMKV instance exposes neither remove() nor delete()");
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Removes every key from whichever backend holds it. Rejects on the first
|
|
54
|
-
* failure — callers surface that, rather than reporting a partial delete as
|
|
55
|
-
* success.
|
|
56
|
-
*/
|
|
57
|
-
async function deleteStorageKeys(keys, mmkvInstances) {
|
|
58
|
-
if (keys.length === 0) return;
|
|
59
|
-
const asyncKeys = keys.filter(k => k.storageType === "async");
|
|
60
|
-
const mmkvKeys = keys.filter(k => k.storageType === "mmkv");
|
|
61
|
-
const secureKeys = keys.filter(k => k.storageType === "secure");
|
|
62
|
-
if (asyncKeys.length > 0) {
|
|
63
|
-
await (0, _asyncStorageCompat.removeMany)(asyncKeys.map(k => k.key));
|
|
64
|
-
}
|
|
65
|
-
for (const k of secureKeys) {
|
|
66
|
-
await _SecureStoreRegistry.secureStoreRegistry.deleteValue(k.key);
|
|
67
|
-
}
|
|
68
|
-
if (mmkvKeys.length > 0) {
|
|
69
|
-
const byInstance = {};
|
|
70
|
-
mmkvKeys.forEach(k => {
|
|
71
|
-
const instanceId = k.instanceId || "default";
|
|
72
|
-
if (!byInstance[instanceId]) byInstance[instanceId] = [];
|
|
73
|
-
byInstance[instanceId].push(k.key);
|
|
74
|
-
});
|
|
75
|
-
Object.entries(byInstance).forEach(([instanceId, instanceKeys]) => {
|
|
76
|
-
const inst = mmkvInstances.find(i => i.id === instanceId);
|
|
77
|
-
if (inst) {
|
|
78
|
-
instanceKeys.forEach(key => removeMMKVKey(inst.instance, key));
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.deleteStorageKeys=deleteStorageKeys;var _asyncStorageCompat=require("./asyncStorageCompat");var _SecureStoreRegistry=require("./SecureStoreRegistry");function removeMMKVKey(t,o){if(typeof t.remove==="function"){t.remove(o);return}if(typeof t.delete==="function"){t.delete(o);return}throw new Error("MMKV instance exposes neither remove() nor delete()")}async function deleteStorageKeys(t,o){if(t.length===0)return;const a=t.filter(e=>e.storageType==="async");const c=t.filter(e=>e.storageType==="mmkv");const f=t.filter(e=>e.storageType==="secure");if(a.length>0){await(0,_asyncStorageCompat.removeMany)(a.map(e=>e.key))}for(const e of f){await _SecureStoreRegistry.secureStoreRegistry.deleteValue(e.key)}if(c.length>0){const e={};c.forEach(n=>{const r=n.instanceId||"default";if(!e[r])e[r]=[];e[r].push(n.key)});Object.entries(e).forEach(([n,r])=>{const i=o.find(s=>s.id===n);if(i){r.forEach(s=>removeMMKVKey(i.instance,s))}})}}
|
|
@@ -1,30 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "ABSENT_VALUE", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _dataViewer.ABSENT_VALUE;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "DiffType", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _dataViewer.DiffType;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "computeLineDiff", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _dataViewer.computeLineDiff;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "isAbsent", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _dataViewer.isAbsent;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
var _dataViewer = require("@buoy-gg/shared-ui/dataViewer");
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"ABSENT_VALUE",{enumerable:true,get:function(){return _dataViewer.ABSENT_VALUE}});Object.defineProperty(exports,"DiffType",{enumerable:true,get:function(){return _dataViewer.DiffType}});Object.defineProperty(exports,"computeLineDiff",{enumerable:true,get:function(){return _dataViewer.computeLineDiff}});Object.defineProperty(exports,"isAbsent",{enumerable:true,get:function(){return _dataViewer.isAbsent}});var _dataViewer=require("@buoy-gg/shared-ui/dataViewer");
|
|
@@ -1,62 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getMMKVClass = getMMKVClass;
|
|
7
|
-
exports.getMMKVUnavailableMessage = getMMKVUnavailableMessage;
|
|
8
|
-
exports.isMMKVAvailable = isMMKVAvailable;
|
|
9
|
-
/**
|
|
10
|
-
* MMKV Availability Detection
|
|
11
|
-
*
|
|
12
|
-
* Safely detects if react-native-mmkv is available in the current environment.
|
|
13
|
-
* This allows the app to work in Expo Go where native modules aren't available.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
let _isMMKVAvailable = null;
|
|
17
|
-
let _MMKVClass = null;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Check if MMKV is available in the current environment
|
|
21
|
-
*
|
|
22
|
-
* @returns True if react-native-mmkv is installed and available
|
|
23
|
-
*/
|
|
24
|
-
function isMMKVAvailable() {
|
|
25
|
-
// Cache the result after first check
|
|
26
|
-
if (_isMMKVAvailable !== null) {
|
|
27
|
-
return _isMMKVAvailable;
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
// Attempt to require MMKV
|
|
31
|
-
const MMKVModule = require('react-native-mmkv');
|
|
32
|
-
|
|
33
|
-
// v4 uses createMMKV factory function, v3 used MMKV class
|
|
34
|
-
// Try v4 API first (recommended), fall back to v3
|
|
35
|
-
_MMKVClass = MMKVModule.createMMKV || MMKVModule.MMKV;
|
|
36
|
-
_isMMKVAvailable = _MMKVClass !== undefined;
|
|
37
|
-
return _isMMKVAvailable;
|
|
38
|
-
} catch (error) {
|
|
39
|
-
// MMKV is not available (e.g., Expo Go, not installed)
|
|
40
|
-
_isMMKVAvailable = false;
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Get the MMKV class if available
|
|
47
|
-
*
|
|
48
|
-
* @returns MMKV class or null if not available
|
|
49
|
-
*/
|
|
50
|
-
function getMMKVClass() {
|
|
51
|
-
if (!isMMKVAvailable()) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
return _MMKVClass;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Get a user-friendly error message when MMKV is not available
|
|
59
|
-
*/
|
|
60
|
-
function getMMKVUnavailableMessage() {
|
|
61
|
-
return 'MMKV is not available in this environment. MMKV requires native modules and cannot run in Expo Go. Please use a development build or EAS Build.';
|
|
62
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getMMKVClass=getMMKVClass;exports.getMMKVUnavailableMessage=getMMKVUnavailableMessage;exports.isMMKVAvailable=isMMKVAvailable;let _isMMKVAvailable=null;let _MMKVClass=null;function isMMKVAvailable(){if(_isMMKVAvailable!==null){return _isMMKVAvailable}try{const e=require("react-native-mmkv");_MMKVClass=e.createMMKV||e.MMKV;_isMMKVAvailable=_MMKVClass!==void 0;return _isMMKVAvailable}catch(e){_isMMKVAvailable=false;return false}}function getMMKVClass(){if(!isMMKVAvailable()){return null}return _MMKVClass}function getMMKVUnavailableMessage(){return"MMKV is not available in this environment. MMKV requires native modules and cannot run in Expo Go. Please use a development build or EAS Build."}
|
|
@@ -1,21 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getMMKVClass = getMMKVClass;
|
|
7
|
-
exports.getMMKVUnavailableMessage = getMMKVUnavailableMessage;
|
|
8
|
-
exports.isMMKVAvailable = isMMKVAvailable;
|
|
9
|
-
function isMMKVAvailable() {
|
|
10
|
-
try {
|
|
11
|
-
return typeof window !== 'undefined' && !!window.sessionStorage;
|
|
12
|
-
} catch {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function getMMKVClass() {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
function getMMKVUnavailableMessage() {
|
|
20
|
-
return 'Session storage is unavailable in this browser context.';
|
|
21
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getMMKVClass=getMMKVClass;exports.getMMKVUnavailableMessage=getMMKVUnavailableMessage;exports.isMMKVAvailable=isMMKVAvailable;function isMMKVAvailable(){try{return typeof window!=="undefined"&&!!window.sessionStorage}catch{return false}}function getMMKVClass(){return null}function getMMKVUnavailableMessage(){return"Session storage is unavailable in this browser context."}
|
|
@@ -1,154 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.detectMMKVType = detectMMKVType;
|
|
7
|
-
exports.formatMMKVValue = formatMMKVValue;
|
|
8
|
-
exports.isTypeMatch = isTypeMatch;
|
|
9
|
-
/**
|
|
10
|
-
* MMKV Type Detection Utilities
|
|
11
|
-
*
|
|
12
|
-
* MMKV stores values with native types (string, number, boolean, ArrayBuffer).
|
|
13
|
-
* This module provides utilities to detect the type of a stored value by trying
|
|
14
|
-
* each getter sequentially.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
// Use 'any' type for MMKV to avoid hard dependency on react-native-mmkv
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Detect the type of a value stored in MMKV by trying each getter.
|
|
21
|
-
*
|
|
22
|
-
* Since MMKV doesn't provide a getType() method, we must try each getter
|
|
23
|
-
* (getString, getNumber, getBoolean, getBuffer) until one returns a value.
|
|
24
|
-
*
|
|
25
|
-
* Order matters: We try in order of most common types first.
|
|
26
|
-
*
|
|
27
|
-
* @param instance - MMKV instance to read from
|
|
28
|
-
* @param key - Storage key
|
|
29
|
-
* @returns Value and its detected type
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* const instance = createMMKV();
|
|
34
|
-
* instance.set('name', 'John');
|
|
35
|
-
* instance.set('age', 30);
|
|
36
|
-
* instance.set('active', true);
|
|
37
|
-
*
|
|
38
|
-
* detectMMKVType(instance, 'name'); // { value: 'John', type: 'string' }
|
|
39
|
-
* detectMMKVType(instance, 'age'); // { value: 30, type: 'number' }
|
|
40
|
-
* detectMMKVType(instance, 'active'); // { value: true, type: 'boolean' }
|
|
41
|
-
* detectMMKVType(instance, 'missing');// { value: undefined, type: 'unknown' }
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
function detectMMKVType(instance, key) {
|
|
45
|
-
// MMKV stores no type metadata, so the native getters can cross-read: in
|
|
46
|
-
// particular `getString` returns "" (an empty string, NOT undefined) for many
|
|
47
|
-
// non-string values like numbers and `false`. Trying getString first and
|
|
48
|
-
// trusting its result therefore mis-detects those as empty strings — e.g.
|
|
49
|
-
// a key set to 42 or false would render as "". Probe the getters and only let
|
|
50
|
-
// getString win when it returns a NON-empty string; treat an empty result as
|
|
51
|
-
// ambiguous and prefer the number/boolean getters.
|
|
52
|
-
const stringValue = instance.getString(key);
|
|
53
|
-
|
|
54
|
-
// A non-empty string is unambiguously a string.
|
|
55
|
-
if (stringValue !== undefined && stringValue !== '') {
|
|
56
|
-
return {
|
|
57
|
-
value: stringValue,
|
|
58
|
-
type: 'string'
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Empty getString result is ambiguous (genuine "" vs a number/boolean the
|
|
63
|
-
// native layer decoded to ""). Prefer typed getters when they have a value.
|
|
64
|
-
const numberValue = instance.getNumber(key);
|
|
65
|
-
if (numberValue !== undefined) {
|
|
66
|
-
return {
|
|
67
|
-
value: numberValue,
|
|
68
|
-
type: 'number'
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
const booleanValue = instance.getBoolean(key);
|
|
72
|
-
if (booleanValue !== undefined) {
|
|
73
|
-
return {
|
|
74
|
-
value: booleanValue,
|
|
75
|
-
type: 'boolean'
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// getString returned "" and nothing else matched -> a genuine empty string.
|
|
80
|
-
if (stringValue === '') {
|
|
81
|
-
return {
|
|
82
|
-
value: '',
|
|
83
|
-
type: 'string'
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Try buffer (least common)
|
|
88
|
-
const bufferValue = instance.getBuffer(key);
|
|
89
|
-
if (bufferValue !== undefined) {
|
|
90
|
-
// Format buffer for display (don't return raw ArrayBuffer)
|
|
91
|
-
return {
|
|
92
|
-
value: `<ArrayBuffer ${bufferValue.byteLength} bytes>`,
|
|
93
|
-
type: 'buffer'
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Key doesn't exist or unknown type
|
|
98
|
-
return {
|
|
99
|
-
value: undefined,
|
|
100
|
-
type: 'unknown'
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Format an MMKV value for display in the UI.
|
|
106
|
-
*
|
|
107
|
-
* @param value - The value to format
|
|
108
|
-
* @param type - The detected type
|
|
109
|
-
* @returns Formatted string representation
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```typescript
|
|
113
|
-
* formatMMKVValue('hello', 'string'); // '"hello"'
|
|
114
|
-
* formatMMKVValue(42, 'number'); // '42'
|
|
115
|
-
* formatMMKVValue(true, 'boolean'); // 'true'
|
|
116
|
-
* formatMMKVValue('<ArrayBuffer 1024 bytes>', 'buffer'); // '<ArrayBuffer 1024 bytes>'
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
function formatMMKVValue(value, type) {
|
|
120
|
-
if (value === undefined) return 'undefined';
|
|
121
|
-
if (value === null) return 'null';
|
|
122
|
-
switch (type) {
|
|
123
|
-
case 'string':
|
|
124
|
-
return `"${value}"`;
|
|
125
|
-
case 'number':
|
|
126
|
-
return String(value);
|
|
127
|
-
case 'boolean':
|
|
128
|
-
return value ? 'true' : 'false';
|
|
129
|
-
case 'buffer':
|
|
130
|
-
// Value is already formatted as "<ArrayBuffer X bytes>"
|
|
131
|
-
return value;
|
|
132
|
-
case 'unknown':
|
|
133
|
-
return 'unknown';
|
|
134
|
-
default:
|
|
135
|
-
return String(value);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Check if a value type matches an expected type for validation.
|
|
141
|
-
*
|
|
142
|
-
* @param actualType - Detected type
|
|
143
|
-
* @param expectedType - Expected type from configuration
|
|
144
|
-
* @returns True if types match
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```typescript
|
|
148
|
-
* isTypeMatch('string', 'string'); // true
|
|
149
|
-
* isTypeMatch('number', 'string'); // false
|
|
150
|
-
* ```
|
|
151
|
-
*/
|
|
152
|
-
function isTypeMatch(actualType, expectedType) {
|
|
153
|
-
return actualType === expectedType;
|
|
154
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.detectMMKVType=detectMMKVType;exports.formatMMKVValue=formatMMKVValue;exports.isTypeMatch=isTypeMatch;function detectMMKVType(e,n){const r=e.getString(n);if(r!==void 0&&r!==""){return{value:r,type:"string"}}const t=e.getNumber(n);if(t!==void 0){return{value:t,type:"number"}}const u=e.getBoolean(n);if(u!==void 0){return{value:u,type:"boolean"}}if(r===""){return{value:"",type:"string"}}const f=e.getBuffer(n);if(f!==void 0){return{value:`<ArrayBuffer ${f.byteLength} bytes>`,type:"buffer"}}return{value:void 0,type:"unknown"}}function formatMMKVValue(e,n){if(e===void 0)return"undefined";if(e===null)return"null";switch(n){case"string":return`"${e}"`;case"number":return String(e);case"boolean":return e?"true":"false";case"buffer":return e;case"unknown":return"unknown";default:return String(e)}}function isTypeMatch(e,n){return e===n}
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.requiredKeyAppliesTo = requiredKeyAppliesTo;
|
|
7
|
-
/**
|
|
8
|
-
* Whether a required-key declaration should be enforced by a given backend
|
|
9
|
-
* hook. Explicit `storageType` wins; bare string keys default to AsyncStorage
|
|
10
|
-
* (the historical zero-config backend). Objects without `storageType` still
|
|
11
|
-
* apply to every backend — matching prior behavior for apps that never set it.
|
|
12
|
-
*/
|
|
13
|
-
function requiredKeyAppliesTo(req, backend) {
|
|
14
|
-
if (typeof req === "string") return backend === "async";
|
|
15
|
-
if (req.storageType) return req.storageType === backend;
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requiredKeyAppliesTo=requiredKeyAppliesTo;function requiredKeyAppliesTo(e,r){if(typeof e==="string")return r==="async";if(e.storageType)return e.storageType===r;return true}
|