@buoy-gg/storage 1.7.7 → 2.1.1

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.
Files changed (61) hide show
  1. package/lib/commonjs/index.js +219 -16
  2. package/lib/commonjs/storage/components/DiffViewer/themes/diffThemes.js +35 -44
  3. package/lib/commonjs/storage/components/GameUIStorageBrowser.js +9 -23
  4. package/lib/commonjs/storage/components/SelectionActionBar.js +8 -22
  5. package/lib/commonjs/storage/components/StorageActionButtons.js +8 -22
  6. package/lib/commonjs/storage/components/StorageActions.js +8 -22
  7. package/lib/commonjs/storage/components/StorageEventActionButton.js +120 -0
  8. package/lib/commonjs/storage/components/StorageEventCard.js +112 -0
  9. package/lib/commonjs/storage/components/StorageEventDetailContent.js +331 -822
  10. package/lib/commonjs/storage/components/StorageModalWithTabs.js +43 -200
  11. package/lib/commonjs/storage/hooks/useStorageEvents.js +98 -0
  12. package/lib/commonjs/storage/index.js +111 -2
  13. package/lib/commonjs/storage/stores/storageEventStore.js +243 -0
  14. package/lib/commonjs/storage/utils/AsyncStorageListener.js +164 -35
  15. package/lib/commonjs/storage/utils/index.js +37 -0
  16. package/lib/commonjs/storage/utils/storageTimeTravelUtils.js +251 -0
  17. package/lib/module/index.js +74 -3
  18. package/lib/module/storage/components/DiffViewer/themes/diffThemes.js +35 -44
  19. package/lib/module/storage/components/GameUIStorageBrowser.js +9 -23
  20. package/lib/module/storage/components/SelectionActionBar.js +9 -24
  21. package/lib/module/storage/components/StorageActionButtons.js +9 -24
  22. package/lib/module/storage/components/StorageActions.js +9 -24
  23. package/lib/module/storage/components/StorageEventActionButton.js +117 -0
  24. package/lib/module/storage/components/StorageEventCard.js +107 -0
  25. package/lib/module/storage/components/StorageEventDetailContent.js +332 -824
  26. package/lib/module/storage/components/StorageModalWithTabs.js +45 -202
  27. package/lib/module/storage/hooks/useStorageEvents.js +95 -0
  28. package/lib/module/storage/index.js +7 -1
  29. package/lib/module/storage/stores/storageEventStore.js +231 -0
  30. package/lib/module/storage/utils/AsyncStorageListener.js +159 -33
  31. package/lib/module/storage/utils/index.js +4 -1
  32. package/lib/module/storage/utils/storageTimeTravelUtils.js +245 -0
  33. package/lib/typescript/index.d.ts +36 -1
  34. package/lib/typescript/index.d.ts.map +1 -1
  35. package/lib/typescript/storage/components/DiffViewer/themes/diffThemes.d.ts +1 -1
  36. package/lib/typescript/storage/components/DiffViewer/themes/diffThemes.d.ts.map +1 -1
  37. package/lib/typescript/storage/components/GameUIStorageBrowser.d.ts.map +1 -1
  38. package/lib/typescript/storage/components/SelectionActionBar.d.ts.map +1 -1
  39. package/lib/typescript/storage/components/StorageActionButtons.d.ts +0 -2
  40. package/lib/typescript/storage/components/StorageActionButtons.d.ts.map +1 -1
  41. package/lib/typescript/storage/components/StorageActions.d.ts.map +1 -1
  42. package/lib/typescript/storage/components/StorageEventActionButton.d.ts +37 -0
  43. package/lib/typescript/storage/components/StorageEventActionButton.d.ts.map +1 -0
  44. package/lib/typescript/storage/components/StorageEventCard.d.ts +40 -0
  45. package/lib/typescript/storage/components/StorageEventCard.d.ts.map +1 -0
  46. package/lib/typescript/storage/components/StorageEventDetailContent.d.ts +11 -3
  47. package/lib/typescript/storage/components/StorageEventDetailContent.d.ts.map +1 -1
  48. package/lib/typescript/storage/components/StorageModalWithTabs.d.ts.map +1 -1
  49. package/lib/typescript/storage/hooks/useStorageEvents.d.ts +51 -0
  50. package/lib/typescript/storage/hooks/useStorageEvents.d.ts.map +1 -0
  51. package/lib/typescript/storage/index.d.ts +4 -0
  52. package/lib/typescript/storage/index.d.ts.map +1 -1
  53. package/lib/typescript/storage/stores/storageEventStore.d.ts +113 -0
  54. package/lib/typescript/storage/stores/storageEventStore.d.ts.map +1 -0
  55. package/lib/typescript/storage/utils/AsyncStorageListener.d.ts +38 -1
  56. package/lib/typescript/storage/utils/AsyncStorageListener.d.ts.map +1 -1
  57. package/lib/typescript/storage/utils/index.d.ts +2 -1
  58. package/lib/typescript/storage/utils/index.d.ts.map +1 -1
  59. package/lib/typescript/storage/utils/storageTimeTravelUtils.d.ts +35 -0
  60. package/lib/typescript/storage/utils/storageTimeTravelUtils.d.ts.map +1 -0
  61. package/package.json +20 -4
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * StorageEventActionButton
5
+ *
6
+ * Action button for Storage DevTools detail view
7
+ * Matches Redux DevTools ActionButton styling
8
+ */
9
+
10
+ import { TouchableOpacity, Text, View, StyleSheet } from "react-native";
11
+ import { buoyColors, Lock } from "@buoy-gg/shared-ui";
12
+
13
+ // Button color configurations matching Redux/React Query pattern
14
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
+ const buttonConfigs = {
16
+ copy: {
17
+ color: buoyColors.primary,
18
+ backgroundColor: buoyColors.primary + "15",
19
+ borderColor: buoyColors.primary + "40",
20
+ textColor: buoyColors.primary
21
+ },
22
+ jump: {
23
+ color: buoyColors.warning,
24
+ backgroundColor: buoyColors.warning + "15",
25
+ borderColor: buoyColors.warning + "40",
26
+ textColor: buoyColors.warning
27
+ },
28
+ undo: {
29
+ color: buoyColors.info,
30
+ backgroundColor: buoyColors.info + "15",
31
+ borderColor: buoyColors.info + "40",
32
+ textColor: buoyColors.info
33
+ }
34
+ };
35
+ export function StorageEventActionButton({
36
+ onPress,
37
+ text,
38
+ type,
39
+ disabled = false,
40
+ locked = false
41
+ }) {
42
+ const config = buttonConfigs[type];
43
+ const isDisabledOrLocked = disabled || locked;
44
+ return /*#__PURE__*/_jsxs(TouchableOpacity, {
45
+ disabled: isDisabledOrLocked,
46
+ onPress: onPress,
47
+ style: [styles.button, {
48
+ backgroundColor: isDisabledOrLocked ? buoyColors.textMuted + "1A" : config.backgroundColor,
49
+ borderColor: isDisabledOrLocked ? buoyColors.textMuted + "33" : config.borderColor,
50
+ opacity: disabled ? 0.5 : 1
51
+ }],
52
+ activeOpacity: 0.7,
53
+ accessibilityRole: "button",
54
+ accessibilityLabel: text,
55
+ accessibilityState: {
56
+ disabled: isDisabledOrLocked
57
+ },
58
+ children: [locked ? /*#__PURE__*/_jsx(Lock, {
59
+ size: 10,
60
+ color: buoyColors.textMuted,
61
+ style: styles.lockIcon
62
+ }) : /*#__PURE__*/_jsx(View, {
63
+ style: [styles.dot, {
64
+ backgroundColor: isDisabledOrLocked ? buoyColors.textMuted : config.color
65
+ }]
66
+ }), /*#__PURE__*/_jsx(Text, {
67
+ style: [styles.text, {
68
+ color: isDisabledOrLocked ? buoyColors.textMuted : config.textColor
69
+ }],
70
+ children: text
71
+ })]
72
+ });
73
+ }
74
+ const styles = StyleSheet.create({
75
+ button: {
76
+ flexDirection: "row",
77
+ alignItems: "center",
78
+ justifyContent: "center",
79
+ borderRadius: 6,
80
+ borderWidth: 1,
81
+ paddingHorizontal: 12,
82
+ paddingVertical: 6,
83
+ height: 25,
84
+ minWidth: 70,
85
+ shadowOffset: {
86
+ width: 0,
87
+ height: 1
88
+ },
89
+ shadowOpacity: 0.2,
90
+ shadowRadius: 2,
91
+ elevation: 2
92
+ },
93
+ dot: {
94
+ width: 5,
95
+ height: 5,
96
+ borderRadius: 3,
97
+ marginRight: 6,
98
+ shadowColor: buoyColors.text,
99
+ shadowOffset: {
100
+ width: 0,
101
+ height: 0
102
+ },
103
+ shadowOpacity: 0.6,
104
+ shadowRadius: 2
105
+ },
106
+ lockIcon: {
107
+ marginRight: 4
108
+ },
109
+ text: {
110
+ fontSize: 10,
111
+ fontWeight: "600",
112
+ letterSpacing: 0.5,
113
+ textTransform: "uppercase",
114
+ fontFamily: "monospace",
115
+ height: 12
116
+ }
117
+ });
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * StorageEventCard
5
+ *
6
+ * Shared card component for displaying storage events.
7
+ * Used by both Storage DevTools and Events DevTools for consistent UI.
8
+ * Uses CompactRow for consistent layout with Redux/React Query cards.
9
+ */
10
+
11
+ import { memo } from "react";
12
+ import { formatRelativeTime, macOSColors, parseValue, CompactRow } from "@buoy-gg/shared-ui";
13
+ import { translateStorageAction } from "../utils/storageActionHelpers";
14
+
15
+ /** Value type for storage events */
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ /**
18
+ * Compute value type from a value
19
+ */
20
+ export function getValueType(value) {
21
+ const parsed = parseValue(value);
22
+ if (parsed === null) return "null";
23
+ if (parsed === undefined) return "undefined";
24
+ if (Array.isArray(parsed)) return "array";
25
+ if (typeof parsed === "boolean") return "boolean";
26
+ if (typeof parsed === "number") return "number";
27
+ if (typeof parsed === "string") return "string";
28
+ if (typeof parsed === "object") return "object";
29
+ return "undefined";
30
+ }
31
+ /**
32
+ * Get color for action type
33
+ */
34
+ function getActionColor(action) {
35
+ switch (action) {
36
+ // AsyncStorage & MMKV - Set operations
37
+ case "setItem":
38
+ case "multiSet":
39
+ case "set.string":
40
+ case "set.number":
41
+ case "set.boolean":
42
+ case "set.buffer":
43
+ return macOSColors.semantic.success;
44
+
45
+ // AsyncStorage & MMKV - Remove/Delete operations
46
+ case "removeItem":
47
+ case "multiRemove":
48
+ case "clear":
49
+ case "delete":
50
+ case "clearAll":
51
+ return macOSColors.semantic.error;
52
+
53
+ // AsyncStorage - Merge operations
54
+ case "mergeItem":
55
+ case "multiMerge":
56
+ return macOSColors.semantic.info;
57
+
58
+ // MMKV - Get operations
59
+ case "get.string":
60
+ case "get.number":
61
+ case "get.boolean":
62
+ case "get.buffer":
63
+ return macOSColors.semantic.warning;
64
+ default:
65
+ return macOSColors.text.muted;
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Get storage type label for sublabel
71
+ */
72
+ function getStorageTypeSublabel(storageTypes, totalOps) {
73
+ const types = Array.from(storageTypes).map(t => t === "async" ? "Async" : "MMKV").join("/");
74
+ return `${types} · ${totalOps} op${totalOps !== 1 ? "s" : ""}`;
75
+ }
76
+ export const StorageEventCard = /*#__PURE__*/memo(function StorageEventCard({
77
+ data,
78
+ onPress,
79
+ isSelected = false,
80
+ showChevron = true
81
+ }) {
82
+ const actionColor = getActionColor(data.lastAction);
83
+ const actionLabel = translateStorageAction(data.lastAction);
84
+ const totalOps = data.totalOperations ?? 1;
85
+ return /*#__PURE__*/_jsx(CompactRow
86
+ // Status section (left) - shows "Storage" with action-colored dot
87
+ , {
88
+ statusDotColor: actionColor,
89
+ statusLabel: "Storage",
90
+ statusSublabel: getStorageTypeSublabel(data.storageTypes, totalOps)
91
+ // Content section (middle) - shows the key name
92
+ ,
93
+ primaryText: data.key
94
+ // Badge section (right) - shows action label (SET, REMOVE, etc.)
95
+ ,
96
+ badgeText: actionLabel,
97
+ badgeColor: actionColor,
98
+ showChevron: showChevron
99
+ // Bottom right - timestamp
100
+ ,
101
+ bottomRightText: formatRelativeTime(data.lastEventTimestamp)
102
+ // Interaction
103
+ ,
104
+ isSelected: isSelected,
105
+ onPress: onPress
106
+ });
107
+ });