@buoy-gg/storage 7.0.41 → 7.0.43
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 +6 -10
- 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,253 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* MMKVInstanceInfoPanel Component
|
|
5
|
-
*
|
|
6
|
-
* Displays detailed information about a selected MMKV instance:
|
|
7
|
-
* - Instance ID and path
|
|
8
|
-
* - Encryption status
|
|
9
|
-
* - Read-only status
|
|
10
|
-
* - Key count
|
|
11
|
-
* - Size (if available)
|
|
12
|
-
*
|
|
13
|
-
* Used in GameUIStorageBrowser below the instance selector.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { View, Text, StyleSheet } from 'react-native';
|
|
17
|
-
import { macOSColors, night, monoFont } from '@buoy-gg/shared-ui';
|
|
18
|
-
import { useMMKVInstance } from '../hooks/useMMKVInstances';
|
|
19
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
-
/**
|
|
21
|
-
* MMKV Instance Info Panel
|
|
22
|
-
*
|
|
23
|
-
* Shows metadata and statistics for a selected MMKV instance.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* function MyStorageUI() {
|
|
28
|
-
* const [selectedInstance, setSelectedInstance] = useState('mmkv.default');
|
|
29
|
-
*
|
|
30
|
-
* return (
|
|
31
|
-
* <View>
|
|
32
|
-
* <MMKVInstanceSelector
|
|
33
|
-
* selectedInstanceId={selectedInstance}
|
|
34
|
-
* onSelectInstance={setSelectedInstance}
|
|
35
|
-
* />
|
|
36
|
-
* {selectedInstance && (
|
|
37
|
-
* <MMKVInstanceInfoPanel instanceId={selectedInstance} />
|
|
38
|
-
* )}
|
|
39
|
-
* </View>
|
|
40
|
-
* );
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export function MMKVInstanceInfoPanel({
|
|
45
|
-
instanceId
|
|
46
|
-
}) {
|
|
47
|
-
const instance = useMMKVInstance(instanceId);
|
|
48
|
-
if (!instance) {
|
|
49
|
-
return /*#__PURE__*/_jsx(View, {
|
|
50
|
-
style: styles.container,
|
|
51
|
-
children: /*#__PURE__*/_jsx(View, {
|
|
52
|
-
style: styles.errorState,
|
|
53
|
-
children: /*#__PURE__*/_jsxs(Text, {
|
|
54
|
-
style: styles.errorText,
|
|
55
|
-
children: ["Instance not found: ", instanceId]
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return /*#__PURE__*/_jsx(View, {
|
|
61
|
-
style: styles.container,
|
|
62
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
63
|
-
style: styles.panel,
|
|
64
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
65
|
-
style: styles.header,
|
|
66
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
67
|
-
style: styles.headerTitle,
|
|
68
|
-
children: "Instance Details"
|
|
69
|
-
})
|
|
70
|
-
}), /*#__PURE__*/_jsxs(View, {
|
|
71
|
-
style: styles.infoGrid,
|
|
72
|
-
children: [/*#__PURE__*/_jsx(InfoItem, {
|
|
73
|
-
label: "Instance ID",
|
|
74
|
-
value: instance.id,
|
|
75
|
-
valueStyle: styles.monoValue
|
|
76
|
-
}), /*#__PURE__*/_jsx(InfoItem, {
|
|
77
|
-
label: "Keys",
|
|
78
|
-
value: `${instance.keyCount} ${instance.keyCount === 1 ? 'key' : 'keys'}`,
|
|
79
|
-
highlight: true
|
|
80
|
-
}), /*#__PURE__*/_jsx(InfoItem, {
|
|
81
|
-
label: "Encryption",
|
|
82
|
-
value: instance.encrypted ? '🔒 Encrypted' : '🔓 Not encrypted',
|
|
83
|
-
valueColor: instance.encrypted ? macOSColors.semantic.success : night.color.textTertiary
|
|
84
|
-
}), /*#__PURE__*/_jsx(InfoItem, {
|
|
85
|
-
label: "Access",
|
|
86
|
-
value: instance.readOnly ? '👁️ Read-only' : '✏️ Read-write',
|
|
87
|
-
valueColor: instance.readOnly ? macOSColors.semantic.warning : night.color.textTertiary
|
|
88
|
-
}), instance.size !== undefined && /*#__PURE__*/_jsx(InfoItem, {
|
|
89
|
-
label: "Size",
|
|
90
|
-
value: formatBytes(instance.size),
|
|
91
|
-
valueStyle: styles.monoValue
|
|
92
|
-
})]
|
|
93
|
-
}), instance.encrypted && /*#__PURE__*/_jsxs(View, {
|
|
94
|
-
style: styles.notice,
|
|
95
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
96
|
-
style: styles.noticeIcon,
|
|
97
|
-
children: "\uD83D\uDD12"
|
|
98
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
99
|
-
style: styles.noticeText,
|
|
100
|
-
children: "This instance is encrypted. Values are protected at rest."
|
|
101
|
-
})]
|
|
102
|
-
}), instance.readOnly && /*#__PURE__*/_jsxs(View, {
|
|
103
|
-
style: [styles.notice, styles.noticeWarning],
|
|
104
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
105
|
-
style: styles.noticeIcon,
|
|
106
|
-
children: "\uD83D\uDC41\uFE0F"
|
|
107
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
108
|
-
style: [styles.noticeText, styles.noticeTextWarning],
|
|
109
|
-
children: "Read-only mode. Cannot modify values in this instance."
|
|
110
|
-
})]
|
|
111
|
-
})]
|
|
112
|
-
})
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* InfoItem Component - Displays a label-value pair
|
|
118
|
-
*/
|
|
119
|
-
function InfoItem({
|
|
120
|
-
label,
|
|
121
|
-
value,
|
|
122
|
-
valueStyle,
|
|
123
|
-
valueColor,
|
|
124
|
-
highlight
|
|
125
|
-
}) {
|
|
126
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
127
|
-
style: styles.infoItem,
|
|
128
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
129
|
-
style: styles.infoLabel,
|
|
130
|
-
children: label
|
|
131
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
132
|
-
style: [styles.infoValue, valueStyle, valueColor && {
|
|
133
|
-
color: valueColor
|
|
134
|
-
}, highlight && styles.infoValueHighlight],
|
|
135
|
-
children: value
|
|
136
|
-
})]
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Format bytes to human-readable string
|
|
142
|
-
*/
|
|
143
|
-
function formatBytes(bytes) {
|
|
144
|
-
if (bytes === 0) return '0 Bytes';
|
|
145
|
-
const k = 1024;
|
|
146
|
-
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
147
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
148
|
-
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`;
|
|
149
|
-
}
|
|
150
|
-
const styles = StyleSheet.create({
|
|
151
|
-
container: {
|
|
152
|
-
marginBottom: 12
|
|
153
|
-
},
|
|
154
|
-
// Error state
|
|
155
|
-
errorState: {
|
|
156
|
-
backgroundColor: macOSColors.semantic.error + '15',
|
|
157
|
-
borderRadius: 12,
|
|
158
|
-
padding: 12,
|
|
159
|
-
borderWidth: 1,
|
|
160
|
-
borderColor: macOSColors.semantic.error + '40'
|
|
161
|
-
},
|
|
162
|
-
errorText: {
|
|
163
|
-
fontSize: 12,
|
|
164
|
-
color: macOSColors.semantic.error,
|
|
165
|
-
textAlign: 'center'
|
|
166
|
-
},
|
|
167
|
-
// Panel
|
|
168
|
-
panel: {
|
|
169
|
-
backgroundColor: night.color.surface,
|
|
170
|
-
borderRadius: 12,
|
|
171
|
-
borderWidth: 1,
|
|
172
|
-
borderColor: night.color.border,
|
|
173
|
-
overflow: 'hidden',
|
|
174
|
-
shadowColor: '#000000',
|
|
175
|
-
shadowOpacity: 0.03,
|
|
176
|
-
shadowRadius: 8,
|
|
177
|
-
shadowOffset: {
|
|
178
|
-
width: 0,
|
|
179
|
-
height: 2
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
// Header
|
|
183
|
-
header: {
|
|
184
|
-
padding: 12,
|
|
185
|
-
borderBottomWidth: 1,
|
|
186
|
-
borderBottomColor: night.color.separator
|
|
187
|
-
},
|
|
188
|
-
headerTitle: {
|
|
189
|
-
fontSize: 11,
|
|
190
|
-
fontWeight: '600',
|
|
191
|
-
color: night.color.text,
|
|
192
|
-
textTransform: "uppercase",
|
|
193
|
-
letterSpacing: 0.5
|
|
194
|
-
},
|
|
195
|
-
// Info grid
|
|
196
|
-
infoGrid: {
|
|
197
|
-
padding: 12,
|
|
198
|
-
gap: 10
|
|
199
|
-
},
|
|
200
|
-
infoItem: {
|
|
201
|
-
flexDirection: 'row',
|
|
202
|
-
justifyContent: 'space-between',
|
|
203
|
-
alignItems: 'center',
|
|
204
|
-
paddingVertical: 4
|
|
205
|
-
},
|
|
206
|
-
infoLabel: {
|
|
207
|
-
fontSize: 12,
|
|
208
|
-
color: night.color.textTertiary,
|
|
209
|
-
fontWeight: '500'
|
|
210
|
-
},
|
|
211
|
-
infoValue: {
|
|
212
|
-
fontSize: 12,
|
|
213
|
-
color: night.color.text,
|
|
214
|
-
fontWeight: '500'
|
|
215
|
-
},
|
|
216
|
-
infoValueHighlight: {
|
|
217
|
-
fontSize: 14,
|
|
218
|
-
fontWeight: '600',
|
|
219
|
-
color: night.color.accent
|
|
220
|
-
},
|
|
221
|
-
monoValue: {
|
|
222
|
-
fontFamily: monoFont
|
|
223
|
-
},
|
|
224
|
-
// Notices
|
|
225
|
-
notice: {
|
|
226
|
-
flexDirection: 'row',
|
|
227
|
-
alignItems: 'center',
|
|
228
|
-
gap: 8,
|
|
229
|
-
padding: 10,
|
|
230
|
-
margin: 12,
|
|
231
|
-
marginTop: 0,
|
|
232
|
-
backgroundColor: macOSColors.semantic.success + '10',
|
|
233
|
-
borderRadius: 8,
|
|
234
|
-
borderWidth: 1,
|
|
235
|
-
borderColor: macOSColors.semantic.success + '30'
|
|
236
|
-
},
|
|
237
|
-
noticeWarning: {
|
|
238
|
-
backgroundColor: macOSColors.semantic.warning + '10',
|
|
239
|
-
borderColor: macOSColors.semantic.warning + '30'
|
|
240
|
-
},
|
|
241
|
-
noticeIcon: {
|
|
242
|
-
fontSize: 14
|
|
243
|
-
},
|
|
244
|
-
noticeText: {
|
|
245
|
-
flex: 1,
|
|
246
|
-
fontSize: 11,
|
|
247
|
-
color: macOSColors.semantic.success,
|
|
248
|
-
lineHeight: 16
|
|
249
|
-
},
|
|
250
|
-
noticeTextWarning: {
|
|
251
|
-
color: macOSColors.semantic.warning
|
|
252
|
-
}
|
|
253
|
-
});
|
|
1
|
+
"use strict";import{View as r,Text as a,StyleSheet as f}from"react-native";import{macOSColors as n,night as i,monoFont as y}from"@buoy-gg/shared-ui";import{useMMKVInstance as g}from"../hooks/useMMKVInstances";import{jsxs as c,jsx as t}from"react/jsx-runtime";export function MMKVInstanceInfoPanel({instanceId:l}){const o=g(l);if(!o){return t(r,{style:e.container,children:t(r,{style:e.errorState,children:c(a,{style:e.errorText,children:["Instance not found: ",l]})})})}return t(r,{style:e.container,children:c(r,{style:e.panel,children:[t(r,{style:e.header,children:t(a,{style:e.headerTitle,children:"Instance Details"})}),c(r,{style:e.infoGrid,children:[t(d,{label:"Instance ID",value:o.id,valueStyle:e.monoValue}),t(d,{label:"Keys",value:`${o.keyCount} ${o.keyCount===1?"key":"keys"}`,highlight:true}),t(d,{label:"Encryption",value:o.encrypted?"\u{1F512} Encrypted":"\u{1F513} Not encrypted",valueColor:o.encrypted?n.semantic.success:i.color.textTertiary}),t(d,{label:"Access",value:o.readOnly?"\u{1F441}\uFE0F Read-only":"\u270F\uFE0F Read-write",valueColor:o.readOnly?n.semantic.warning:i.color.textTertiary}),o.size!==void 0&&t(d,{label:"Size",value:m(o.size),valueStyle:e.monoValue})]}),o.encrypted&&c(r,{style:e.notice,children:[t(a,{style:e.noticeIcon,children:"\u{1F512}"}),t(a,{style:e.noticeText,children:"This instance is encrypted. Values are protected at rest."})]}),o.readOnly&&c(r,{style:[e.notice,e.noticeWarning],children:[t(a,{style:e.noticeIcon,children:"\u{1F441}\uFE0F"}),t(a,{style:[e.noticeText,e.noticeTextWarning],children:"Read-only mode. Cannot modify values in this instance."})]})]})})}function d({label:l,value:o,valueStyle:h,valueColor:s,highlight:u}){return c(r,{style:e.infoItem,children:[t(a,{style:e.infoLabel,children:l}),t(a,{style:[e.infoValue,h,s&&{color:s},u&&e.infoValueHighlight],children:o})]})}function m(l){if(l===0)return"0 Bytes";const o=1024;const h=["Bytes","KB","MB","GB"];const s=Math.floor(Math.log(l)/Math.log(o));return`${parseFloat((l/Math.pow(o,s)).toFixed(2))} ${h[s]}`}const e=f.create({container:{marginBottom:12},errorState:{backgroundColor:n.semantic.error+"15",borderRadius:12,padding:12,borderWidth:1,borderColor:n.semantic.error+"40"},errorText:{fontSize:12,color:n.semantic.error,textAlign:"center"},panel:{backgroundColor:i.color.surface,borderRadius:12,borderWidth:1,borderColor:i.color.border,overflow:"hidden",shadowColor:"#000000",shadowOpacity:.03,shadowRadius:8,shadowOffset:{width:0,height:2}},header:{padding:12,borderBottomWidth:1,borderBottomColor:i.color.separator},headerTitle:{fontSize:11,fontWeight:"600",color:i.color.text,textTransform:"uppercase",letterSpacing:.5},infoGrid:{padding:12,gap:10},infoItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:4},infoLabel:{fontSize:12,color:i.color.textTertiary,fontWeight:"500"},infoValue:{fontSize:12,color:i.color.text,fontWeight:"500"},infoValueHighlight:{fontSize:14,fontWeight:"600",color:i.color.accent},monoValue:{fontFamily:y},notice:{flexDirection:"row",alignItems:"center",gap:8,padding:10,margin:12,marginTop:0,backgroundColor:n.semantic.success+"10",borderRadius:8,borderWidth:1,borderColor:n.semantic.success+"30"},noticeWarning:{backgroundColor:n.semantic.warning+"10",borderColor:n.semantic.warning+"30"},noticeIcon:{fontSize:14},noticeText:{flex:1,fontSize:11,color:n.semantic.success,lineHeight:16},noticeTextWarning:{color:n.semantic.warning}});
|
|
@@ -1,415 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { storageLabels } from "../utils/storageLabels";
|
|
4
|
-
/**
|
|
5
|
-
* MMKVInstanceSelector Component
|
|
6
|
-
*
|
|
7
|
-
* Dropdown selector for choosing between multiple MMKV instances.
|
|
8
|
-
* Shows instance ID, key count, and metadata badges (encrypted, read-only).
|
|
9
|
-
*
|
|
10
|
-
* Used in GameUIStorageBrowser when storage type filter is set to "mmkv".
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import { useState } from 'react';
|
|
14
|
-
import { View, Text, StyleSheet, TouchableOpacity, ScrollView, Modal } from 'react-native';
|
|
15
|
-
import { macOSColors, night, monoFont } from '@buoy-gg/shared-ui';
|
|
16
|
-
import { useMMKVInstances } from '../hooks/useMMKVInstances';
|
|
17
|
-
import { isMMKVAvailable, getMMKVUnavailableMessage } from '../utils/mmkvAvailability';
|
|
18
|
-
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
-
/**
|
|
20
|
-
* MMKV Instance Selector Component
|
|
21
|
-
*
|
|
22
|
-
* Displays a dropdown to select between registered MMKV instances.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* function MyStorageUI() {
|
|
27
|
-
* const [selectedInstance, setSelectedInstance] = useState('mmkv.default');
|
|
28
|
-
*
|
|
29
|
-
* return (
|
|
30
|
-
* <MMKVInstanceSelector
|
|
31
|
-
* selectedInstanceId={selectedInstance}
|
|
32
|
-
* onSelectInstance={setSelectedInstance}
|
|
33
|
-
* />
|
|
34
|
-
* );
|
|
35
|
-
* }
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export function MMKVInstanceSelector({
|
|
39
|
-
selectedInstanceId,
|
|
40
|
-
onSelectInstance,
|
|
41
|
-
showRefreshButton = true
|
|
42
|
-
}) {
|
|
43
|
-
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
|
44
|
-
const {
|
|
45
|
-
instances,
|
|
46
|
-
instanceCount,
|
|
47
|
-
refresh
|
|
48
|
-
} = useMMKVInstances(false);
|
|
49
|
-
|
|
50
|
-
// Find the selected instance
|
|
51
|
-
const selectedInstance = instances.find(inst => inst.id === selectedInstanceId);
|
|
52
|
-
|
|
53
|
-
// Handle instance selection
|
|
54
|
-
const handleSelectInstance = instanceId => {
|
|
55
|
-
onSelectInstance(instanceId);
|
|
56
|
-
setIsDropdownOpen(false);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// If MMKV is not available, show unavailable message
|
|
60
|
-
if (!isMMKVAvailable()) {
|
|
61
|
-
return /*#__PURE__*/_jsx(View, {
|
|
62
|
-
style: styles.container,
|
|
63
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
64
|
-
style: styles.unavailableState,
|
|
65
|
-
children: [/*#__PURE__*/_jsxs(Text, {
|
|
66
|
-
style: styles.unavailableTitle,
|
|
67
|
-
children: [storageLabels.mmkv, " Not Available"]
|
|
68
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
69
|
-
style: styles.unavailableDescription,
|
|
70
|
-
children: getMMKVUnavailableMessage()
|
|
71
|
-
})]
|
|
72
|
-
})
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// If no instances registered, show message
|
|
77
|
-
if (instanceCount === 0) {
|
|
78
|
-
return /*#__PURE__*/_jsx(View, {
|
|
79
|
-
style: styles.container,
|
|
80
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
81
|
-
style: styles.emptyState,
|
|
82
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
83
|
-
style: styles.emptyStateTitle,
|
|
84
|
-
children: "No MMKV Instances Registered"
|
|
85
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
86
|
-
style: styles.emptyStateDescription,
|
|
87
|
-
children: "Register MMKV instances using registerMMKVInstance() to monitor them in dev tools."
|
|
88
|
-
}), showRefreshButton && /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
89
|
-
style: styles.refreshButton,
|
|
90
|
-
onPress: refresh,
|
|
91
|
-
activeOpacity: 0.7,
|
|
92
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
93
|
-
style: styles.refreshButtonText,
|
|
94
|
-
children: "\u21BB Refresh"
|
|
95
|
-
})
|
|
96
|
-
})]
|
|
97
|
-
})
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
101
|
-
style: styles.container,
|
|
102
|
-
children: [/*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
103
|
-
style: styles.selectorButton,
|
|
104
|
-
onPress: () => setIsDropdownOpen(true),
|
|
105
|
-
activeOpacity: 0.7,
|
|
106
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
107
|
-
style: styles.selectorContent,
|
|
108
|
-
children: selectedInstance ? /*#__PURE__*/_jsx(InstanceRow, {
|
|
109
|
-
instance: selectedInstance,
|
|
110
|
-
isSelected: true
|
|
111
|
-
}) : /*#__PURE__*/_jsx(Text, {
|
|
112
|
-
style: styles.placeholderText,
|
|
113
|
-
children: "Select MMKV Instance"
|
|
114
|
-
})
|
|
115
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
116
|
-
style: styles.dropdownArrow,
|
|
117
|
-
children: "\u25BC"
|
|
118
|
-
})]
|
|
119
|
-
}), /*#__PURE__*/_jsx(Modal, {
|
|
120
|
-
visible: isDropdownOpen,
|
|
121
|
-
transparent: true,
|
|
122
|
-
animationType: "fade",
|
|
123
|
-
onRequestClose: () => setIsDropdownOpen(false),
|
|
124
|
-
children: /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
125
|
-
style: styles.modalOverlay,
|
|
126
|
-
activeOpacity: 1,
|
|
127
|
-
onPress: () => setIsDropdownOpen(false),
|
|
128
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
129
|
-
style: styles.dropdownContainer,
|
|
130
|
-
children: [/*#__PURE__*/_jsxs(View, {
|
|
131
|
-
style: styles.dropdownHeader,
|
|
132
|
-
children: [/*#__PURE__*/_jsxs(Text, {
|
|
133
|
-
style: styles.dropdownTitle,
|
|
134
|
-
children: ["Select MMKV Instance (", instanceCount, ")"]
|
|
135
|
-
}), showRefreshButton && /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
136
|
-
style: styles.headerRefreshButton,
|
|
137
|
-
onPress: refresh,
|
|
138
|
-
activeOpacity: 0.7,
|
|
139
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
140
|
-
style: styles.headerRefreshText,
|
|
141
|
-
children: "\u21BB"
|
|
142
|
-
})
|
|
143
|
-
})]
|
|
144
|
-
}), /*#__PURE__*/_jsx(ScrollView, {
|
|
145
|
-
style: styles.dropdownList,
|
|
146
|
-
children: instances.map(instance => /*#__PURE__*/_jsx(TouchableOpacity, {
|
|
147
|
-
style: [styles.dropdownItem, instance.id === selectedInstanceId && styles.dropdownItemSelected],
|
|
148
|
-
onPress: () => handleSelectInstance(instance.id),
|
|
149
|
-
activeOpacity: 0.7,
|
|
150
|
-
children: /*#__PURE__*/_jsx(InstanceRow, {
|
|
151
|
-
instance: instance,
|
|
152
|
-
isSelected: instance.id === selectedInstanceId
|
|
153
|
-
})
|
|
154
|
-
}, instance.id))
|
|
155
|
-
})]
|
|
156
|
-
})
|
|
157
|
-
})
|
|
158
|
-
})]
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Instance Row Component
|
|
164
|
-
*
|
|
165
|
-
* Displays a single MMKV instance with its metadata.
|
|
166
|
-
*/
|
|
167
|
-
function InstanceRow({
|
|
168
|
-
instance,
|
|
169
|
-
isSelected
|
|
170
|
-
}) {
|
|
171
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
172
|
-
style: styles.instanceRow,
|
|
173
|
-
children: [/*#__PURE__*/_jsxs(View, {
|
|
174
|
-
style: styles.instanceLeft,
|
|
175
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
176
|
-
style: [styles.instanceId, isSelected && styles.instanceIdSelected],
|
|
177
|
-
numberOfLines: 1,
|
|
178
|
-
children: instance.id
|
|
179
|
-
}), /*#__PURE__*/_jsxs(View, {
|
|
180
|
-
style: styles.instanceBadges,
|
|
181
|
-
children: [instance.encrypted && /*#__PURE__*/_jsx(View, {
|
|
182
|
-
style: [styles.badge, styles.badgeEncrypted],
|
|
183
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
184
|
-
style: styles.badgeText,
|
|
185
|
-
children: "\uD83D\uDD12 Encrypted"
|
|
186
|
-
})
|
|
187
|
-
}), instance.readOnly && /*#__PURE__*/_jsx(View, {
|
|
188
|
-
style: [styles.badge, styles.badgeReadOnly],
|
|
189
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
190
|
-
style: styles.badgeText,
|
|
191
|
-
children: "\uD83D\uDC41\uFE0F Read-only"
|
|
192
|
-
})
|
|
193
|
-
})]
|
|
194
|
-
})]
|
|
195
|
-
}), /*#__PURE__*/_jsxs(View, {
|
|
196
|
-
style: styles.instanceRight,
|
|
197
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
198
|
-
style: styles.keyCount,
|
|
199
|
-
children: instance.keyCount
|
|
200
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
201
|
-
style: styles.keyCountLabel,
|
|
202
|
-
children: "keys"
|
|
203
|
-
})]
|
|
204
|
-
})]
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
const styles = StyleSheet.create({
|
|
208
|
-
container: {
|
|
209
|
-
marginBottom: 12
|
|
210
|
-
},
|
|
211
|
-
// Unavailable state
|
|
212
|
-
unavailableState: {
|
|
213
|
-
backgroundColor: macOSColors.semantic.warning + '15',
|
|
214
|
-
borderRadius: 12,
|
|
215
|
-
padding: 20,
|
|
216
|
-
borderWidth: 1,
|
|
217
|
-
borderColor: macOSColors.semantic.warning + '40',
|
|
218
|
-
alignItems: 'center',
|
|
219
|
-
gap: 12
|
|
220
|
-
},
|
|
221
|
-
unavailableTitle: {
|
|
222
|
-
fontSize: 14,
|
|
223
|
-
fontWeight: '600',
|
|
224
|
-
color: macOSColors.semantic.warning
|
|
225
|
-
},
|
|
226
|
-
unavailableDescription: {
|
|
227
|
-
fontSize: 12,
|
|
228
|
-
color: night.color.textSecondary,
|
|
229
|
-
textAlign: 'center',
|
|
230
|
-
lineHeight: 18
|
|
231
|
-
},
|
|
232
|
-
// Empty state
|
|
233
|
-
emptyState: {
|
|
234
|
-
backgroundColor: night.color.surface,
|
|
235
|
-
borderRadius: 12,
|
|
236
|
-
padding: 20,
|
|
237
|
-
borderWidth: 1,
|
|
238
|
-
borderColor: night.color.border,
|
|
239
|
-
alignItems: 'center',
|
|
240
|
-
gap: 12
|
|
241
|
-
},
|
|
242
|
-
emptyStateTitle: {
|
|
243
|
-
fontSize: 14,
|
|
244
|
-
fontWeight: '600',
|
|
245
|
-
color: night.color.text
|
|
246
|
-
},
|
|
247
|
-
emptyStateDescription: {
|
|
248
|
-
fontSize: 12,
|
|
249
|
-
color: night.color.textTertiary,
|
|
250
|
-
textAlign: 'center',
|
|
251
|
-
lineHeight: 18
|
|
252
|
-
},
|
|
253
|
-
refreshButton: {
|
|
254
|
-
marginTop: 8,
|
|
255
|
-
paddingHorizontal: 16,
|
|
256
|
-
paddingVertical: 8,
|
|
257
|
-
backgroundColor: night.color.accentSoft,
|
|
258
|
-
borderRadius: 8,
|
|
259
|
-
borderWidth: 1,
|
|
260
|
-
borderColor: night.color.accentBorderStrong
|
|
261
|
-
},
|
|
262
|
-
refreshButtonText: {
|
|
263
|
-
fontSize: 12,
|
|
264
|
-
fontWeight: '600',
|
|
265
|
-
color: night.color.accent
|
|
266
|
-
},
|
|
267
|
-
// Selector button
|
|
268
|
-
selectorButton: {
|
|
269
|
-
backgroundColor: night.color.surface,
|
|
270
|
-
borderRadius: 12,
|
|
271
|
-
borderWidth: 1,
|
|
272
|
-
borderColor: night.color.border,
|
|
273
|
-
padding: 12,
|
|
274
|
-
flexDirection: 'row',
|
|
275
|
-
alignItems: 'center',
|
|
276
|
-
justifyContent: 'space-between',
|
|
277
|
-
shadowColor: '#000000',
|
|
278
|
-
shadowOpacity: 0.03,
|
|
279
|
-
shadowRadius: 8,
|
|
280
|
-
shadowOffset: {
|
|
281
|
-
width: 0,
|
|
282
|
-
height: 2
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
selectorContent: {
|
|
286
|
-
flex: 1
|
|
287
|
-
},
|
|
288
|
-
placeholderText: {
|
|
289
|
-
fontSize: 13,
|
|
290
|
-
color: night.color.placeholder,
|
|
291
|
-
fontStyle: 'italic'
|
|
292
|
-
},
|
|
293
|
-
dropdownArrow: {
|
|
294
|
-
fontSize: 10,
|
|
295
|
-
color: night.color.textTertiary,
|
|
296
|
-
marginLeft: 8
|
|
297
|
-
},
|
|
298
|
-
// Modal overlay
|
|
299
|
-
modalOverlay: {
|
|
300
|
-
flex: 1,
|
|
301
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
302
|
-
justifyContent: 'center',
|
|
303
|
-
alignItems: 'center',
|
|
304
|
-
padding: 20
|
|
305
|
-
},
|
|
306
|
-
// Dropdown container
|
|
307
|
-
dropdownContainer: {
|
|
308
|
-
backgroundColor: night.color.surface,
|
|
309
|
-
borderRadius: 16,
|
|
310
|
-
borderWidth: 1,
|
|
311
|
-
borderColor: night.color.border,
|
|
312
|
-
width: '100%',
|
|
313
|
-
maxWidth: 500,
|
|
314
|
-
maxHeight: '70%',
|
|
315
|
-
shadowColor: '#000000',
|
|
316
|
-
shadowOpacity: 0.2,
|
|
317
|
-
shadowRadius: 20,
|
|
318
|
-
shadowOffset: {
|
|
319
|
-
width: 0,
|
|
320
|
-
height: 10
|
|
321
|
-
},
|
|
322
|
-
overflow: 'hidden'
|
|
323
|
-
},
|
|
324
|
-
dropdownHeader: {
|
|
325
|
-
flexDirection: 'row',
|
|
326
|
-
alignItems: 'center',
|
|
327
|
-
justifyContent: 'space-between',
|
|
328
|
-
padding: 16,
|
|
329
|
-
borderBottomWidth: 1,
|
|
330
|
-
borderBottomColor: night.color.separator
|
|
331
|
-
},
|
|
332
|
-
dropdownTitle: {
|
|
333
|
-
fontSize: 14,
|
|
334
|
-
fontWeight: '600',
|
|
335
|
-
color: night.color.text
|
|
336
|
-
},
|
|
337
|
-
headerRefreshButton: {
|
|
338
|
-
padding: 4
|
|
339
|
-
},
|
|
340
|
-
headerRefreshText: {
|
|
341
|
-
fontSize: 18,
|
|
342
|
-
color: night.color.accent
|
|
343
|
-
},
|
|
344
|
-
dropdownList: {
|
|
345
|
-
maxHeight: 400
|
|
346
|
-
},
|
|
347
|
-
dropdownItem: {
|
|
348
|
-
padding: 12,
|
|
349
|
-
borderBottomWidth: 1,
|
|
350
|
-
borderBottomColor: night.color.separator
|
|
351
|
-
},
|
|
352
|
-
dropdownItemSelected: {
|
|
353
|
-
backgroundColor: night.color.accentSoft
|
|
354
|
-
},
|
|
355
|
-
// Instance row
|
|
356
|
-
instanceRow: {
|
|
357
|
-
flexDirection: 'row',
|
|
358
|
-
alignItems: 'center',
|
|
359
|
-
justifyContent: 'space-between',
|
|
360
|
-
gap: 12
|
|
361
|
-
},
|
|
362
|
-
instanceLeft: {
|
|
363
|
-
flex: 1,
|
|
364
|
-
gap: 6
|
|
365
|
-
},
|
|
366
|
-
instanceId: {
|
|
367
|
-
fontSize: 13,
|
|
368
|
-
fontWeight: '500',
|
|
369
|
-
color: night.color.text,
|
|
370
|
-
fontFamily: monoFont
|
|
371
|
-
},
|
|
372
|
-
instanceIdSelected: {
|
|
373
|
-
fontWeight: '600',
|
|
374
|
-
color: night.color.accent
|
|
375
|
-
},
|
|
376
|
-
instanceBadges: {
|
|
377
|
-
flexDirection: 'row',
|
|
378
|
-
flexWrap: 'wrap',
|
|
379
|
-
gap: 6
|
|
380
|
-
},
|
|
381
|
-
badge: {
|
|
382
|
-
paddingHorizontal: 6,
|
|
383
|
-
paddingVertical: 2,
|
|
384
|
-
borderRadius: 4,
|
|
385
|
-
borderWidth: 1
|
|
386
|
-
},
|
|
387
|
-
badgeEncrypted: {
|
|
388
|
-
backgroundColor: macOSColors.semantic.success + '15',
|
|
389
|
-
borderColor: macOSColors.semantic.success + '40'
|
|
390
|
-
},
|
|
391
|
-
badgeReadOnly: {
|
|
392
|
-
backgroundColor: macOSColors.semantic.warning + '15',
|
|
393
|
-
borderColor: macOSColors.semantic.warning + '40'
|
|
394
|
-
},
|
|
395
|
-
badgeText: {
|
|
396
|
-
fontSize: 9,
|
|
397
|
-
fontWeight: '500',
|
|
398
|
-
color: night.color.textSecondary
|
|
399
|
-
},
|
|
400
|
-
instanceRight: {
|
|
401
|
-
alignItems: 'flex-end'
|
|
402
|
-
},
|
|
403
|
-
keyCount: {
|
|
404
|
-
fontSize: 16,
|
|
405
|
-
fontWeight: '600',
|
|
406
|
-
color: night.color.text,
|
|
407
|
-
fontFamily: monoFont
|
|
408
|
-
},
|
|
409
|
-
keyCountLabel: {
|
|
410
|
-
fontSize: 9,
|
|
411
|
-
color: night.color.textTertiary,
|
|
412
|
-
textTransform: "uppercase",
|
|
413
|
-
letterSpacing: 0.5
|
|
414
|
-
}
|
|
415
|
-
});
|
|
1
|
+
"use strict";import{storageLabels as x}from"../utils/storageLabels";import{useState as C}from"react";import{View as r,Text as n,StyleSheet as R,TouchableOpacity as c,ScrollView as T,Modal as I}from"react-native";import{macOSColors as d,night as o,monoFont as b}from"@buoy-gg/shared-ui";import{useMMKVInstances as v}from"../hooks/useMMKVInstances";import{isMMKVAvailable as B,getMMKVUnavailableMessage as M}from"../utils/mmkvAvailability";import{jsxs as i,jsx as t}from"react/jsx-runtime";export function MMKVInstanceSelector({selectedInstanceId:a,onSelectInstance:h,showRefreshButton:g=true}){const[w,s]=C(false);const{instances:p,instanceCount:f,refresh:y}=v(false);const u=p.find(l=>l.id===a);const S=l=>{h(l);s(false)};if(!B()){return t(r,{style:e.container,children:i(r,{style:e.unavailableState,children:[i(n,{style:e.unavailableTitle,children:[x.mmkv," Not Available"]}),t(n,{style:e.unavailableDescription,children:M()})]})})}if(f===0){return t(r,{style:e.container,children:i(r,{style:e.emptyState,children:[t(n,{style:e.emptyStateTitle,children:"No MMKV Instances Registered"}),t(n,{style:e.emptyStateDescription,children:"Register MMKV instances using registerMMKVInstance() to monitor them in dev tools."}),g&&t(c,{style:e.refreshButton,onPress:y,activeOpacity:.7,children:t(n,{style:e.refreshButtonText,children:"\u21BB Refresh"})})]})})}return i(r,{style:e.container,children:[i(c,{style:e.selectorButton,onPress:()=>s(true),activeOpacity:.7,children:[t(r,{style:e.selectorContent,children:u?t(m,{instance:u,isSelected:true}):t(n,{style:e.placeholderText,children:"Select MMKV Instance"})}),t(n,{style:e.dropdownArrow,children:"\u25BC"})]}),t(I,{visible:w,transparent:true,animationType:"fade",onRequestClose:()=>s(false),children:t(c,{style:e.modalOverlay,activeOpacity:1,onPress:()=>s(false),children:i(r,{style:e.dropdownContainer,children:[i(r,{style:e.dropdownHeader,children:[i(n,{style:e.dropdownTitle,children:["Select MMKV Instance (",f,")"]}),g&&t(c,{style:e.headerRefreshButton,onPress:y,activeOpacity:.7,children:t(n,{style:e.headerRefreshText,children:"\u21BB"})})]}),t(T,{style:e.dropdownList,children:p.map(l=>t(c,{style:[e.dropdownItem,l.id===a&&e.dropdownItemSelected],onPress:()=>S(l.id),activeOpacity:.7,children:t(m,{instance:l,isSelected:l.id===a})},l.id))})]})})})]})}function m({instance:a,isSelected:h}){return i(r,{style:e.instanceRow,children:[i(r,{style:e.instanceLeft,children:[t(n,{style:[e.instanceId,h&&e.instanceIdSelected],numberOfLines:1,children:a.id}),i(r,{style:e.instanceBadges,children:[a.encrypted&&t(r,{style:[e.badge,e.badgeEncrypted],children:t(n,{style:e.badgeText,children:"\u{1F512} Encrypted"})}),a.readOnly&&t(r,{style:[e.badge,e.badgeReadOnly],children:t(n,{style:e.badgeText,children:"\u{1F441}\uFE0F Read-only"})})]})]}),i(r,{style:e.instanceRight,children:[t(n,{style:e.keyCount,children:a.keyCount}),t(n,{style:e.keyCountLabel,children:"keys"})]})]})}const e=R.create({container:{marginBottom:12},unavailableState:{backgroundColor:d.semantic.warning+"15",borderRadius:12,padding:20,borderWidth:1,borderColor:d.semantic.warning+"40",alignItems:"center",gap:12},unavailableTitle:{fontSize:14,fontWeight:"600",color:d.semantic.warning},unavailableDescription:{fontSize:12,color:o.color.textSecondary,textAlign:"center",lineHeight:18},emptyState:{backgroundColor:o.color.surface,borderRadius:12,padding:20,borderWidth:1,borderColor:o.color.border,alignItems:"center",gap:12},emptyStateTitle:{fontSize:14,fontWeight:"600",color:o.color.text},emptyStateDescription:{fontSize:12,color:o.color.textTertiary,textAlign:"center",lineHeight:18},refreshButton:{marginTop:8,paddingHorizontal:16,paddingVertical:8,backgroundColor:o.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:o.color.accentBorderStrong},refreshButtonText:{fontSize:12,fontWeight:"600",color:o.color.accent},selectorButton:{backgroundColor:o.color.surface,borderRadius:12,borderWidth:1,borderColor:o.color.border,padding:12,flexDirection:"row",alignItems:"center",justifyContent:"space-between",shadowColor:"#000000",shadowOpacity:.03,shadowRadius:8,shadowOffset:{width:0,height:2}},selectorContent:{flex:1},placeholderText:{fontSize:13,color:o.color.placeholder,fontStyle:"italic"},dropdownArrow:{fontSize:10,color:o.color.textTertiary,marginLeft:8},modalOverlay:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.5)",justifyContent:"center",alignItems:"center",padding:20},dropdownContainer:{backgroundColor:o.color.surface,borderRadius:16,borderWidth:1,borderColor:o.color.border,width:"100%",maxWidth:500,maxHeight:"70%",shadowColor:"#000000",shadowOpacity:.2,shadowRadius:20,shadowOffset:{width:0,height:10},overflow:"hidden"},dropdownHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16,borderBottomWidth:1,borderBottomColor:o.color.separator},dropdownTitle:{fontSize:14,fontWeight:"600",color:o.color.text},headerRefreshButton:{padding:4},headerRefreshText:{fontSize:18,color:o.color.accent},dropdownList:{maxHeight:400},dropdownItem:{padding:12,borderBottomWidth:1,borderBottomColor:o.color.separator},dropdownItemSelected:{backgroundColor:o.color.accentSoft},instanceRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12},instanceLeft:{flex:1,gap:6},instanceId:{fontSize:13,fontWeight:"500",color:o.color.text,fontFamily:b},instanceIdSelected:{fontWeight:"600",color:o.color.accent},instanceBadges:{flexDirection:"row",flexWrap:"wrap",gap:6},badge:{paddingHorizontal:6,paddingVertical:2,borderRadius:4,borderWidth:1},badgeEncrypted:{backgroundColor:d.semantic.success+"15",borderColor:d.semantic.success+"40"},badgeReadOnly:{backgroundColor:d.semantic.warning+"15",borderColor:d.semantic.warning+"40"},badgeText:{fontSize:9,fontWeight:"500",color:o.color.textSecondary},instanceRight:{alignItems:"flex-end"},keyCount:{fontSize:16,fontWeight:"600",color:o.color.text,fontFamily:b},keyCountLabel:{fontSize:9,color:o.color.textTertiary,textTransform:"uppercase",letterSpacing:.5}});
|