react-native-inapp-inspector 1.1.2 → 1.1.4
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 +30 -0
- package/dist/commonjs/components/ConsoleLogCard.js +18 -0
- package/dist/commonjs/components/LogCard.js +19 -2
- package/dist/commonjs/components/NetworkIcons.d.ts +9 -2
- package/dist/commonjs/components/NetworkIcons.js +59 -3
- package/dist/commonjs/constants/version.d.ts +1 -1
- package/dist/commonjs/constants/version.js +1 -1
- package/dist/commonjs/customHooks/reduxLogger.d.ts +21 -7
- package/dist/commonjs/customHooks/reduxLogger.js +147 -48
- package/dist/commonjs/customHooks/webViewLogger.js +13 -8
- package/dist/commonjs/helpers/settingsStore.d.ts +28 -0
- package/dist/commonjs/helpers/settingsStore.js +92 -0
- package/dist/commonjs/index.d.ts +1 -1
- package/dist/commonjs/index.js +893 -185
- package/dist/commonjs/styles/index.d.ts +17 -1
- package/dist/commonjs/styles/index.js +25 -3
- package/dist/commonjs/types/index.d.ts +4 -0
- package/dist/esm/components/ConsoleLogCard.js +18 -0
- package/dist/esm/components/LogCard.js +19 -2
- package/dist/esm/components/NetworkIcons.d.ts +9 -2
- package/dist/esm/components/NetworkIcons.js +51 -2
- package/dist/esm/constants/version.d.ts +1 -1
- package/dist/esm/constants/version.js +1 -1
- package/dist/esm/customHooks/reduxLogger.d.ts +21 -7
- package/dist/esm/customHooks/reduxLogger.js +145 -47
- package/dist/esm/customHooks/webViewLogger.js +13 -8
- package/dist/esm/helpers/settingsStore.d.ts +28 -0
- package/dist/esm/helpers/settingsStore.js +84 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +892 -187
- package/dist/esm/styles/index.d.ts +17 -1
- package/dist/esm/styles/index.js +25 -3
- package/dist/esm/types/index.d.ts +4 -0
- package/example/ios/example.xcodeproj/project.pbxproj +0 -8
- package/example/package-lock.json +75 -33
- package/example/package.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// #5 — Persistence layer for the inspector's settings selections.
|
|
2
|
+
//
|
|
3
|
+
// Backed by iOS Settings (NSUserDefaults) for iOS, or custom storage if passed (e.g. AsyncStorage/MMKV).
|
|
4
|
+
// Contains an in-memory fallback for Android or Jest test environments.
|
|
5
|
+
import { Platform, Settings } from 'react-native';
|
|
6
|
+
// In-memory fallback (settings survive for the app session only).
|
|
7
|
+
const memory = new Map();
|
|
8
|
+
let customStorage = null;
|
|
9
|
+
export function setCustomStorage(storage) {
|
|
10
|
+
customStorage = storage;
|
|
11
|
+
}
|
|
12
|
+
const SETTINGS_KEY = 'rn-inapp-inspector.settings.v1';
|
|
13
|
+
export async function loadSettings() {
|
|
14
|
+
try {
|
|
15
|
+
if (customStorage) {
|
|
16
|
+
const raw = await customStorage.getItem(SETTINGS_KEY);
|
|
17
|
+
if (!raw)
|
|
18
|
+
return {};
|
|
19
|
+
const parsed = JSON.parse(raw);
|
|
20
|
+
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
21
|
+
}
|
|
22
|
+
if (Platform.OS === 'ios') {
|
|
23
|
+
const raw = Settings.get(SETTINGS_KEY);
|
|
24
|
+
if (!raw)
|
|
25
|
+
return {};
|
|
26
|
+
if (typeof raw === 'string') {
|
|
27
|
+
const parsed = JSON.parse(raw);
|
|
28
|
+
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
29
|
+
}
|
|
30
|
+
return raw && typeof raw === 'object' ? raw : {};
|
|
31
|
+
}
|
|
32
|
+
// Android/fallback: memory
|
|
33
|
+
const raw = memory.get(SETTINGS_KEY);
|
|
34
|
+
if (!raw)
|
|
35
|
+
return {};
|
|
36
|
+
const parsed = JSON.parse(raw);
|
|
37
|
+
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function saveSettings(settings) {
|
|
44
|
+
try {
|
|
45
|
+
const raw = JSON.stringify(settings);
|
|
46
|
+
if (customStorage) {
|
|
47
|
+
customStorage.setItem(SETTINGS_KEY, raw);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (Platform.OS === 'ios') {
|
|
51
|
+
Settings.set({ [SETTINGS_KEY]: raw });
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
// Android/fallback: memory
|
|
55
|
+
memory.set(SETTINGS_KEY, raw);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// ignore
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export async function clearPersistedSettings() {
|
|
62
|
+
try {
|
|
63
|
+
if (customStorage) {
|
|
64
|
+
if (typeof customStorage.removeItem === 'function') {
|
|
65
|
+
await customStorage.removeItem(SETTINGS_KEY);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
await customStorage.setItem(SETTINGS_KEY, '');
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (Platform.OS === 'ios') {
|
|
73
|
+
Settings.set({ [SETTINGS_KEY]: null });
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
memory.delete(SETTINGS_KEY);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// ignore
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export const isPersistentStorageAvailable = () => {
|
|
83
|
+
return customStorage !== null || Platform.OS === 'ios';
|
|
84
|
+
};
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export { setupConsoleLogger, clearConsoleLogs, subscribeConsoleLogs, } from './c
|
|
|
6
6
|
export { setupAnalyticsLogger, logAnalyticsEvent, subscribeAnalyticsEvents, clearAnalyticsEvents, } from './customHooks/analyticsLogger';
|
|
7
7
|
export { WebView, getWebViewLogs, getWebViewNavHistory, getWebViewHtml, getWebViewCss, getWebViewJs, getWebViewHtmlUrl, clearWebViewData, subscribeWebView, } from './customHooks/webViewLogger';
|
|
8
8
|
export { default as ErrorBoundary } from './components/ErrorBoundary';
|
|
9
|
-
export { connectReduxStore, getReduxState, subscribeReduxState, } from './customHooks/reduxLogger';
|
|
9
|
+
export { connectReduxStore, inspectorReduxMiddleware, getReduxState, subscribeReduxState, getActionHistory, clearActionHistory, } from './customHooks/reduxLogger';
|