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,6 +1,23 @@
|
|
|
1
1
|
let currentReduxState = null;
|
|
2
2
|
const listeners = new Set();
|
|
3
|
+
let globalReduxAutoRefresh = true;
|
|
4
|
+
let lastActionForReducer = {};
|
|
5
|
+
let actionHistory = [];
|
|
3
6
|
export const getReduxState = () => currentReduxState;
|
|
7
|
+
export const setReduxAutoRefresh = (val) => {
|
|
8
|
+
globalReduxAutoRefresh = val;
|
|
9
|
+
};
|
|
10
|
+
export const getReduxAutoRefresh = () => globalReduxAutoRefresh;
|
|
11
|
+
export const getLastActionForReducer = () => lastActionForReducer;
|
|
12
|
+
export const clearLastActionForReducer = () => {
|
|
13
|
+
lastActionForReducer = {};
|
|
14
|
+
listeners.forEach(cb => cb());
|
|
15
|
+
};
|
|
16
|
+
export const getActionHistory = () => actionHistory;
|
|
17
|
+
export const clearActionHistory = () => {
|
|
18
|
+
actionHistory = [];
|
|
19
|
+
listeners.forEach(cb => cb());
|
|
20
|
+
};
|
|
4
21
|
export const setReduxState = (state) => {
|
|
5
22
|
currentReduxState = state;
|
|
6
23
|
listeners.forEach(cb => cb());
|
|
@@ -16,8 +33,54 @@ export const connectReduxStore = (store) => {
|
|
|
16
33
|
console.warn('[NetworkInspector] Invalid Redux store passed to connectReduxStore.');
|
|
17
34
|
return;
|
|
18
35
|
}
|
|
36
|
+
// Intercept dispatch calls to log actions and tie them to modified state slices
|
|
37
|
+
const originalDispatch = store.dispatch.bind(store);
|
|
38
|
+
store.dispatch = (action) => {
|
|
39
|
+
const prevState = store.getState();
|
|
40
|
+
const result = originalDispatch(action);
|
|
41
|
+
const nextState = store.getState();
|
|
42
|
+
// Map the dispatched action to state slices that actually changed
|
|
43
|
+
const affectedSlices = [];
|
|
44
|
+
if (prevState &&
|
|
45
|
+
nextState &&
|
|
46
|
+
typeof prevState === 'object' &&
|
|
47
|
+
typeof nextState === 'object' &&
|
|
48
|
+
action &&
|
|
49
|
+
typeof action === 'object') {
|
|
50
|
+
Object.keys(nextState).forEach(key => {
|
|
51
|
+
if (prevState[key] !== nextState[key]) {
|
|
52
|
+
const actionObj = {
|
|
53
|
+
type: action.type || 'UNKNOWN_ACTION',
|
|
54
|
+
payload: action.payload !== undefined ? action.payload : null,
|
|
55
|
+
timestamp: new Date().toLocaleTimeString(),
|
|
56
|
+
};
|
|
57
|
+
lastActionForReducer[key] = actionObj;
|
|
58
|
+
affectedSlices.push(key);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
// Push to history
|
|
62
|
+
actionHistory.unshift({
|
|
63
|
+
id: Date.now() + Math.random(),
|
|
64
|
+
type: action.type || 'UNKNOWN_ACTION',
|
|
65
|
+
payload: action.payload !== undefined ? action.payload : null,
|
|
66
|
+
timestamp: new Date().toLocaleTimeString(),
|
|
67
|
+
affectedSlices,
|
|
68
|
+
});
|
|
69
|
+
// Cap size at 50
|
|
70
|
+
if (actionHistory.length > 50) {
|
|
71
|
+
actionHistory.pop();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (globalReduxAutoRefresh) {
|
|
75
|
+
setReduxState(nextState);
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
};
|
|
19
79
|
setReduxState(store.getState());
|
|
80
|
+
// Listen to subscription for devtools updates or any other state changes
|
|
20
81
|
store.subscribe(() => {
|
|
21
|
-
|
|
82
|
+
if (globalReduxAutoRefresh) {
|
|
83
|
+
setReduxState(store.getState());
|
|
84
|
+
}
|
|
22
85
|
});
|
|
23
86
|
};
|