react-native-inapp-inspector 1.0.9 → 1.0.11
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 +5 -6
- package/dist/commonjs/components/AnalyticsDetail.js +28 -23
- package/dist/commonjs/components/AnalyticsEventCard.js +9 -9
- package/dist/commonjs/components/BrandSquareIcon.d.ts +5 -0
- package/dist/commonjs/components/BrandSquareIcon.js +180 -0
- package/dist/commonjs/components/CodeSnippet.js +32 -24
- package/dist/commonjs/components/ConsoleLogCard.js +127 -70
- package/dist/commonjs/components/JsonViewer.d.ts +2 -1
- package/dist/commonjs/components/JsonViewer.js +2 -2
- package/dist/commonjs/components/MetaAccordion.d.ts +1 -1
- package/dist/commonjs/components/MetaAccordion.js +45 -2
- package/dist/commonjs/components/NetworkIcons.d.ts +7 -0
- package/dist/commonjs/components/NetworkIcons.js +42 -1
- package/dist/commonjs/components/ReduxTreeView.d.ts +17 -0
- package/dist/commonjs/components/ReduxTreeView.js +630 -0
- package/dist/commonjs/components/TouchableScale.js +15 -1
- package/dist/commonjs/components/TreeNode.js +3 -3
- package/dist/commonjs/customHooks/reduxLogger.d.ts +12 -0
- package/dist/commonjs/customHooks/reduxLogger.js +71 -2
- package/dist/commonjs/index.js +1568 -505
- package/dist/commonjs/styles/index.d.ts +11 -1
- package/dist/commonjs/styles/index.js +19 -9
- package/dist/commonjs/types/index.d.ts +4 -0
- package/dist/esm/components/AnalyticsDetail.js +28 -23
- package/dist/esm/components/AnalyticsEventCard.js +9 -9
- package/dist/esm/components/BrandSquareIcon.d.ts +5 -0
- package/dist/esm/components/BrandSquareIcon.js +140 -0
- package/dist/esm/components/CodeSnippet.js +32 -24
- package/dist/esm/components/ConsoleLogCard.js +127 -70
- package/dist/esm/components/JsonViewer.d.ts +2 -1
- package/dist/esm/components/JsonViewer.js +2 -2
- package/dist/esm/components/MetaAccordion.d.ts +1 -1
- package/dist/esm/components/MetaAccordion.js +46 -3
- package/dist/esm/components/NetworkIcons.d.ts +7 -0
- package/dist/esm/components/NetworkIcons.js +34 -0
- package/dist/esm/components/ReduxTreeView.d.ts +17 -0
- package/dist/esm/components/ReduxTreeView.js +592 -0
- package/dist/esm/components/TouchableScale.js +16 -2
- package/dist/esm/components/TreeNode.js +3 -3
- package/dist/esm/customHooks/reduxLogger.d.ts +12 -0
- package/dist/esm/customHooks/reduxLogger.js +64 -1
- package/dist/esm/index.js +1571 -508
- package/dist/esm/styles/index.d.ts +11 -1
- package/dist/esm/styles/index.js +19 -9
- package/dist/esm/types/index.d.ts +4 -0
- package/example/App.tsx +46 -0
- package/package.json +7 -5
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
export declare const getReduxState: () => any;
|
|
2
|
+
export declare const setReduxAutoRefresh: (val: boolean) => void;
|
|
3
|
+
export declare const getReduxAutoRefresh: () => boolean;
|
|
4
|
+
export declare const getLastActionForReducer: () => Record<string, any>;
|
|
5
|
+
export declare const clearLastActionForReducer: () => void;
|
|
6
|
+
export declare const getActionHistory: () => {
|
|
7
|
+
id: number;
|
|
8
|
+
type: string;
|
|
9
|
+
payload: any;
|
|
10
|
+
timestamp: string;
|
|
11
|
+
affectedSlices: string[];
|
|
12
|
+
}[];
|
|
13
|
+
export declare const clearActionHistory: () => void;
|
|
2
14
|
export declare const setReduxState: (state: any) => void;
|
|
3
15
|
export declare const subscribeReduxState: (cb: () => void) => () => void;
|
|
4
16
|
export declare const connectReduxStore: (store: any) => void;
|
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.connectReduxStore = exports.subscribeReduxState = exports.setReduxState = exports.getReduxState = void 0;
|
|
3
|
+
exports.connectReduxStore = exports.subscribeReduxState = exports.setReduxState = exports.clearActionHistory = exports.getActionHistory = exports.clearLastActionForReducer = exports.getLastActionForReducer = exports.getReduxAutoRefresh = exports.setReduxAutoRefresh = exports.getReduxState = void 0;
|
|
4
4
|
let currentReduxState = null;
|
|
5
5
|
const listeners = new Set();
|
|
6
|
+
let globalReduxAutoRefresh = true;
|
|
7
|
+
let lastActionForReducer = {};
|
|
8
|
+
let actionHistory = [];
|
|
6
9
|
const getReduxState = () => currentReduxState;
|
|
7
10
|
exports.getReduxState = getReduxState;
|
|
11
|
+
const setReduxAutoRefresh = (val) => {
|
|
12
|
+
globalReduxAutoRefresh = val;
|
|
13
|
+
};
|
|
14
|
+
exports.setReduxAutoRefresh = setReduxAutoRefresh;
|
|
15
|
+
const getReduxAutoRefresh = () => globalReduxAutoRefresh;
|
|
16
|
+
exports.getReduxAutoRefresh = getReduxAutoRefresh;
|
|
17
|
+
const getLastActionForReducer = () => lastActionForReducer;
|
|
18
|
+
exports.getLastActionForReducer = getLastActionForReducer;
|
|
19
|
+
const clearLastActionForReducer = () => {
|
|
20
|
+
lastActionForReducer = {};
|
|
21
|
+
listeners.forEach(cb => cb());
|
|
22
|
+
};
|
|
23
|
+
exports.clearLastActionForReducer = clearLastActionForReducer;
|
|
24
|
+
const getActionHistory = () => actionHistory;
|
|
25
|
+
exports.getActionHistory = getActionHistory;
|
|
26
|
+
const clearActionHistory = () => {
|
|
27
|
+
actionHistory = [];
|
|
28
|
+
listeners.forEach(cb => cb());
|
|
29
|
+
};
|
|
30
|
+
exports.clearActionHistory = clearActionHistory;
|
|
8
31
|
const setReduxState = (state) => {
|
|
9
32
|
currentReduxState = state;
|
|
10
33
|
listeners.forEach(cb => cb());
|
|
@@ -22,9 +45,55 @@ const connectReduxStore = (store) => {
|
|
|
22
45
|
console.warn('[NetworkInspector] Invalid Redux store passed to connectReduxStore.');
|
|
23
46
|
return;
|
|
24
47
|
}
|
|
48
|
+
// Intercept dispatch calls to log actions and tie them to modified state slices
|
|
49
|
+
const originalDispatch = store.dispatch.bind(store);
|
|
50
|
+
store.dispatch = (action) => {
|
|
51
|
+
const prevState = store.getState();
|
|
52
|
+
const result = originalDispatch(action);
|
|
53
|
+
const nextState = store.getState();
|
|
54
|
+
// Map the dispatched action to state slices that actually changed
|
|
55
|
+
const affectedSlices = [];
|
|
56
|
+
if (prevState &&
|
|
57
|
+
nextState &&
|
|
58
|
+
typeof prevState === 'object' &&
|
|
59
|
+
typeof nextState === 'object' &&
|
|
60
|
+
action &&
|
|
61
|
+
typeof action === 'object') {
|
|
62
|
+
Object.keys(nextState).forEach(key => {
|
|
63
|
+
if (prevState[key] !== nextState[key]) {
|
|
64
|
+
const actionObj = {
|
|
65
|
+
type: action.type || 'UNKNOWN_ACTION',
|
|
66
|
+
payload: action.payload !== undefined ? action.payload : null,
|
|
67
|
+
timestamp: new Date().toLocaleTimeString(),
|
|
68
|
+
};
|
|
69
|
+
lastActionForReducer[key] = actionObj;
|
|
70
|
+
affectedSlices.push(key);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
// Push to history
|
|
74
|
+
actionHistory.unshift({
|
|
75
|
+
id: Date.now() + Math.random(),
|
|
76
|
+
type: action.type || 'UNKNOWN_ACTION',
|
|
77
|
+
payload: action.payload !== undefined ? action.payload : null,
|
|
78
|
+
timestamp: new Date().toLocaleTimeString(),
|
|
79
|
+
affectedSlices,
|
|
80
|
+
});
|
|
81
|
+
// Cap size at 50
|
|
82
|
+
if (actionHistory.length > 50) {
|
|
83
|
+
actionHistory.pop();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (globalReduxAutoRefresh) {
|
|
87
|
+
(0, exports.setReduxState)(nextState);
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
};
|
|
25
91
|
(0, exports.setReduxState)(store.getState());
|
|
92
|
+
// Listen to subscription for devtools updates or any other state changes
|
|
26
93
|
store.subscribe(() => {
|
|
27
|
-
|
|
94
|
+
if (globalReduxAutoRefresh) {
|
|
95
|
+
(0, exports.setReduxState)(store.getState());
|
|
96
|
+
}
|
|
28
97
|
});
|
|
29
98
|
};
|
|
30
99
|
exports.connectReduxStore = connectReduxStore;
|