@buoy-gg/storage 7.0.6 → 7.0.8

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 (42) hide show
  1. package/lib/typescript/storage/sync/storageSyncAdapter.d.ts +1 -1
  2. package/package.json +5 -5
  3. package/lib/commonjs/storage/components/GameUIStorageStats.js +0 -746
  4. package/lib/commonjs/storage/components/StorageActions.js +0 -178
  5. package/lib/commonjs/storage/components/StorageEventListener.js +0 -357
  6. package/lib/commonjs/storage/components/StorageFilterViewV2.js +0 -42
  7. package/lib/commonjs/storage/hooks/useMeasuredWidth.js +0 -74
  8. package/lib/commonjs/storage/hooks/useTickEverySecond.js +0 -21
  9. package/lib/commonjs/storage/index.js +0 -258
  10. package/lib/commonjs/storage/utils/index.js +0 -230
  11. package/lib/commonjs/storage/utils/objectDiff.js +0 -157
  12. package/lib/commonjs/storage/utils/safeAsyncStorage.js +0 -140
  13. package/lib/module/storage/components/GameUIStorageStats.js +0 -743
  14. package/lib/module/storage/components/StorageActions.js +0 -174
  15. package/lib/module/storage/components/StorageEventListener.js +0 -354
  16. package/lib/module/storage/components/StorageFilterViewV2.js +0 -38
  17. package/lib/module/storage/hooks/useMeasuredWidth.js +0 -71
  18. package/lib/module/storage/hooks/useTickEverySecond.js +0 -18
  19. package/lib/module/storage/index.js +0 -34
  20. package/lib/module/storage/utils/index.js +0 -28
  21. package/lib/module/storage/utils/objectDiff.js +0 -153
  22. package/lib/module/storage/utils/safeAsyncStorage.js +0 -134
  23. package/lib/typescript/storage/components/GameUIStorageStats.d.ts +0 -7
  24. package/lib/typescript/storage/components/GameUIStorageStats.d.ts.map +0 -1
  25. package/lib/typescript/storage/components/StorageActions.d.ts +0 -10
  26. package/lib/typescript/storage/components/StorageActions.d.ts.map +0 -1
  27. package/lib/typescript/storage/components/StorageEventListener.d.ts +0 -6
  28. package/lib/typescript/storage/components/StorageEventListener.d.ts.map +0 -1
  29. package/lib/typescript/storage/components/StorageFilterViewV2.d.ts +0 -9
  30. package/lib/typescript/storage/components/StorageFilterViewV2.d.ts.map +0 -1
  31. package/lib/typescript/storage/hooks/useMeasuredWidth.d.ts +0 -37
  32. package/lib/typescript/storage/hooks/useMeasuredWidth.d.ts.map +0 -1
  33. package/lib/typescript/storage/hooks/useTickEverySecond.d.ts +0 -6
  34. package/lib/typescript/storage/hooks/useTickEverySecond.d.ts.map +0 -1
  35. package/lib/typescript/storage/index.d.ts +0 -21
  36. package/lib/typescript/storage/index.d.ts.map +0 -1
  37. package/lib/typescript/storage/utils/index.d.ts +0 -10
  38. package/lib/typescript/storage/utils/index.d.ts.map +0 -1
  39. package/lib/typescript/storage/utils/objectDiff.d.ts +0 -35
  40. package/lib/typescript/storage/utils/objectDiff.d.ts.map +0 -1
  41. package/lib/typescript/storage/utils/safeAsyncStorage.d.ts +0 -56
  42. package/lib/typescript/storage/utils/safeAsyncStorage.d.ts.map +0 -1
@@ -1,140 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getAsyncStorageInstance = getAsyncStorageInstance;
7
- exports.isAsyncStorageAvailable = isAsyncStorageAvailable;
8
- exports.safeAsyncStorage = void 0;
9
- /**
10
- * Safe AsyncStorage wrapper that handles missing dependencies gracefully.
11
- *
12
- * This wrapper allows the storage dev tools to work even when
13
- * @react-native-async-storage/async-storage is not installed in the host app.
14
- *
15
- * When AsyncStorage is not available:
16
- * - All operations return empty results or no-ops
17
- * - No errors are thrown
18
- * - The dev tools can still load (but storage features will be limited)
19
- */
20
-
21
- let AsyncStorage = null;
22
- let isAvailable = false;
23
- let checkedAvailability = false;
24
- let checkError = null;
25
-
26
- /**
27
- * Check if AsyncStorage is available in the host app
28
- * This handles three cases:
29
- * 1. Package not installed (module not found)
30
- * 2. Package installed but native module not linked (native module null)
31
- * 3. Package installed and working
32
- */
33
- function checkAsyncStorageAvailability() {
34
- if (checkedAvailability) {
35
- return isAvailable;
36
- }
37
- try {
38
- // Attempt to require AsyncStorage
39
- // This might throw if:
40
- // - Package is not installed (module not found)
41
- // - Native module is not linked (RCTAsyncStorage is null)
42
- const AsyncStorageModule = require("@react-native-async-storage/async-storage");
43
- AsyncStorage = AsyncStorageModule?.default || AsyncStorageModule;
44
-
45
- // Verify it's actually usable (has the methods we need)
46
- if (AsyncStorage && typeof AsyncStorage.getItem === "function") {
47
- isAvailable = true;
48
- } else {
49
- isAvailable = false;
50
- AsyncStorage = null;
51
- }
52
- } catch (error) {
53
- // Catch ALL errors:
54
- // - Module not found (package not installed)
55
- // - Native module errors (package installed but native not linked)
56
- // - Any other initialization errors
57
- checkError = error;
58
- isAvailable = false;
59
- AsyncStorage = null;
60
- }
61
- checkedAvailability = true;
62
- return isAvailable;
63
- }
64
-
65
- /**
66
- * Returns true if AsyncStorage is available in the host app
67
- */
68
- function isAsyncStorageAvailable() {
69
- return checkAsyncStorageAvailability();
70
- }
71
-
72
- /**
73
- * No-op AsyncStorage implementation for when the package is not installed
74
- */
75
- const noOpAsyncStorage = {
76
- getItem: async _key => null,
77
- setItem: async (_key, _value) => {},
78
- removeItem: async _key => {},
79
- getAllKeys: async () => [],
80
- multiGet: async _keys => [],
81
- multiSet: async _keyValuePairs => {},
82
- multiRemove: async _keys => {},
83
- clear: async () => {},
84
- mergeItem: async (_key, _value) => {},
85
- multiMerge: async _keyValuePairs => {}
86
- };
87
-
88
- /**
89
- * Safe AsyncStorage wrapper that provides no-op fallbacks when unavailable.
90
- *
91
- * Usage:
92
- * ```ts
93
- * import { safeAsyncStorage } from './utils/safeAsyncStorage';
94
- *
95
- * // This will work even if AsyncStorage is not installed
96
- * const value = await safeAsyncStorage.getItem('myKey');
97
- * ```
98
- */
99
- const safeAsyncStorage = exports.safeAsyncStorage = new Proxy(noOpAsyncStorage, {
100
- get(_target, prop) {
101
- // Avoid triggering check for React internal properties or symbols
102
- if (typeof prop === "symbol" || prop.startsWith("_") || prop.startsWith("$$")) {
103
- return noOpAsyncStorage[prop];
104
- }
105
-
106
- // Only check availability when actually accessing AsyncStorage methods
107
- try {
108
- checkAsyncStorageAvailability();
109
- if (isAvailable && AsyncStorage) {
110
- return AsyncStorage[prop];
111
- }
112
- } catch (error) {
113
- // If check throws for any reason, fall back to no-op
114
- }
115
-
116
- // Return no-op implementation
117
- return noOpAsyncStorage[prop];
118
- }
119
- });
120
-
121
- /**
122
- * Get the actual AsyncStorage instance if available, or null if not.
123
- * Use this when you need to check if AsyncStorage is available before using it.
124
- *
125
- * @example
126
- * ```ts
127
- * const storage = getAsyncStorageInstance();
128
- * if (storage) {
129
- * // AsyncStorage is available
130
- * await storage.setItem('key', 'value');
131
- * } else {
132
- * // AsyncStorage is not available, handle gracefully
133
- * console.warn('AsyncStorage not available');
134
- * }
135
- * ```
136
- */
137
- function getAsyncStorageInstance() {
138
- checkAsyncStorageAvailability();
139
- return isAvailable ? AsyncStorage : null;
140
- }