react-native-vconsole 0.0.1 → 0.2.0
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/LICENSE +20 -0
- package/README.md +39 -9
- package/Vconsole.podspec +25 -0
- package/android/build.gradle +61 -129
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/vconsole/VconsoleModule.kt +80 -0
- package/android/src/main/java/com/vconsole/VconsolePackage.kt +17 -0
- package/ios/Vconsole.h +6 -0
- package/ios/Vconsole.mm +64 -0
- package/lib/module/VConsole.js +769 -0
- package/lib/module/VConsole.js.map +1 -0
- package/lib/module/core/consoleProxy.js +86 -0
- package/lib/module/core/consoleProxy.js.map +1 -0
- package/lib/module/core/xhrProxy.js +247 -0
- package/lib/module/core/xhrProxy.js.map +1 -0
- package/lib/module/index.js +24 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/VConsole.d.ts +6 -0
- package/lib/typescript/src/VConsole.d.ts.map +1 -0
- package/lib/typescript/src/core/consoleProxy.d.ts +9 -0
- package/lib/typescript/src/core/consoleProxy.d.ts.map +1 -0
- package/lib/typescript/src/core/xhrProxy.d.ts +12 -0
- package/lib/typescript/src/core/xhrProxy.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +37 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +138 -25
- package/src/VConsole.tsx +871 -0
- package/src/core/consoleProxy.ts +108 -0
- package/src/core/xhrProxy.ts +319 -0
- package/src/index.tsx +36 -0
- package/src/types.ts +42 -0
- package/android/README.md +0 -14
- package/android/src/main/java/wiki/qdc/rn/vconsole/ReactNativeVconsoleModule.java +0 -27
- package/android/src/main/java/wiki/qdc/rn/vconsole/ReactNativeVconsolePackage.java +0 -23
- package/index.js +0 -5
- package/ios/.DS_Store +0 -0
- package/ios/ReactNativeVconsole.h +0 -5
- package/ios/ReactNativeVconsole.m +0 -13
- package/ios/ReactNativeVconsole.xcodeproj/project.pbxproj +0 -281
- package/ios/ReactNativeVconsole.xcworkspace/contents.xcworkspacedata +0 -7
- package/react-native-vconsole.podspec +0 -28
|
@@ -0,0 +1,769 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { Animated, Clipboard, Dimensions, FlatList, NativeModules, PanResponder, Platform, Pressable, StatusBar, StyleSheet, Text, View } from 'react-native';
|
|
5
|
+
import { clearLogEntries, getLogEntries, installConsoleProxy, subscribeLogEntries, uninstallConsoleProxy } from "./core/consoleProxy.js";
|
|
6
|
+
import { clearNetworkEntries, getNetworkEntries, installXhrProxy, subscribeNetworkEntries, uninstallXhrProxy } from "./core/xhrProxy.js";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
const BUTTON_WIDTH = 88;
|
|
9
|
+
const BUTTON_HEIGHT = 36;
|
|
10
|
+
const PANEL_HEIGHT_RATIO = 7 / 9;
|
|
11
|
+
const EMPTY_FILTER = [];
|
|
12
|
+
const LOG_SUB_TABS = ['All', 'log', 'info', 'warn', 'error'];
|
|
13
|
+
const ROOT_TABS = ['Log', 'Network', 'System', 'App'];
|
|
14
|
+
const LOG_THEME = {
|
|
15
|
+
log: {
|
|
16
|
+
backgroundColor: '#FFFFFF',
|
|
17
|
+
color: '#111111'
|
|
18
|
+
},
|
|
19
|
+
info: {
|
|
20
|
+
backgroundColor: '#FFFFFF',
|
|
21
|
+
color: '#246BFD'
|
|
22
|
+
},
|
|
23
|
+
warn: {
|
|
24
|
+
backgroundColor: '#FFF8E6',
|
|
25
|
+
color: '#A65A00'
|
|
26
|
+
},
|
|
27
|
+
error: {
|
|
28
|
+
backgroundColor: '#FFECEC',
|
|
29
|
+
color: '#9C1C1C'
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
function clamp(value, min, max) {
|
|
33
|
+
return Math.min(Math.max(value, min), max);
|
|
34
|
+
}
|
|
35
|
+
function getDisplayValue(value) {
|
|
36
|
+
if (typeof value === 'string') {
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
return JSON.stringify(value);
|
|
41
|
+
} catch {
|
|
42
|
+
return String(value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function copyToClipboard(value) {
|
|
46
|
+
Clipboard.setString(value);
|
|
47
|
+
}
|
|
48
|
+
function prettyText(value) {
|
|
49
|
+
if (value === undefined) {
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
if (typeof value === 'string') {
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
return JSON.stringify(value, null, 2);
|
|
57
|
+
} catch {
|
|
58
|
+
return String(value);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function buildNetworkCopyText(item) {
|
|
62
|
+
const status = item.status ?? '-';
|
|
63
|
+
const duration = typeof item.durationMs === 'number' ? `${item.durationMs}ms` : '-';
|
|
64
|
+
return [`${item.method} ${item.url}`, `status ${status} duration ${duration}`, `request headers\n${prettyText(item.requestHeaders)}`, `request body\n${prettyText(item.requestBody)}`, `response headers\n${prettyText(item.responseHeaders)}`, `response data\n${prettyText(item.responseData)}`].join('\n');
|
|
65
|
+
}
|
|
66
|
+
function ObjectTree({
|
|
67
|
+
value,
|
|
68
|
+
nodeKey,
|
|
69
|
+
expandedMap,
|
|
70
|
+
onToggle
|
|
71
|
+
}) {
|
|
72
|
+
if (value === null || value === undefined) {
|
|
73
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
74
|
+
style: styles.valuePrimitive,
|
|
75
|
+
children: String(value)
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const valueType = typeof value;
|
|
79
|
+
if (valueType !== 'object') {
|
|
80
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
81
|
+
style: styles.valuePrimitive,
|
|
82
|
+
children: getDisplayValue(value)
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const isArray = Array.isArray(value);
|
|
86
|
+
const entries = Object.entries(value);
|
|
87
|
+
const opened = !!expandedMap[nodeKey];
|
|
88
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
89
|
+
style: styles.treeNode,
|
|
90
|
+
children: [/*#__PURE__*/_jsxs(Pressable, {
|
|
91
|
+
onPress: () => onToggle(nodeKey),
|
|
92
|
+
style: styles.treeHeader,
|
|
93
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
94
|
+
style: styles.arrow,
|
|
95
|
+
children: opened ? '▼' : '▶'
|
|
96
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
97
|
+
style: styles.treeLabel,
|
|
98
|
+
children: isArray ? `Array(${entries.length})` : `Object(${entries.length})`
|
|
99
|
+
})]
|
|
100
|
+
}), opened ? /*#__PURE__*/_jsx(View, {
|
|
101
|
+
style: styles.treeChildren,
|
|
102
|
+
children: entries.map(([key, item]) => /*#__PURE__*/_jsxs(View, {
|
|
103
|
+
style: styles.treeChildRow,
|
|
104
|
+
children: [/*#__PURE__*/_jsxs(Text, {
|
|
105
|
+
style: styles.treeKey,
|
|
106
|
+
children: [key, ": "]
|
|
107
|
+
}), /*#__PURE__*/_jsx(ObjectTree, {
|
|
108
|
+
value: item,
|
|
109
|
+
nodeKey: `${nodeKey}.${key}`,
|
|
110
|
+
expandedMap: expandedMap,
|
|
111
|
+
onToggle: onToggle
|
|
112
|
+
})]
|
|
113
|
+
}, `${nodeKey}.${key}`))
|
|
114
|
+
}) : null]
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
function ListSeparator() {
|
|
118
|
+
return /*#__PURE__*/_jsx(View, {
|
|
119
|
+
style: styles.separator
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function useFlatListRefs() {
|
|
123
|
+
const allRef = useRef(null);
|
|
124
|
+
const logRef = useRef(null);
|
|
125
|
+
const infoRef = useRef(null);
|
|
126
|
+
const warnRef = useRef(null);
|
|
127
|
+
const errorRef = useRef(null);
|
|
128
|
+
return useMemo(() => ({
|
|
129
|
+
All: allRef,
|
|
130
|
+
log: logRef,
|
|
131
|
+
info: infoRef,
|
|
132
|
+
warn: warnRef,
|
|
133
|
+
error: errorRef
|
|
134
|
+
}), [allRef, errorRef, infoRef, logRef, warnRef]);
|
|
135
|
+
}
|
|
136
|
+
export function VConsole({
|
|
137
|
+
enable = true,
|
|
138
|
+
filter = EMPTY_FILTER
|
|
139
|
+
}) {
|
|
140
|
+
const nativeModule = NativeModules.Vconsole;
|
|
141
|
+
const {
|
|
142
|
+
width,
|
|
143
|
+
height
|
|
144
|
+
} = Dimensions.get('window');
|
|
145
|
+
const topInset = Platform.select({
|
|
146
|
+
ios: 44,
|
|
147
|
+
android: (StatusBar.currentHeight ?? 0) + 8,
|
|
148
|
+
default: 24
|
|
149
|
+
});
|
|
150
|
+
const bottomInset = Platform.select({
|
|
151
|
+
ios: 34,
|
|
152
|
+
android: 56,
|
|
153
|
+
default: 24
|
|
154
|
+
});
|
|
155
|
+
const minX = 0;
|
|
156
|
+
const maxX = width - BUTTON_WIDTH;
|
|
157
|
+
const minY = topInset;
|
|
158
|
+
const maxY = height - bottomInset - BUTTON_HEIGHT;
|
|
159
|
+
const initialY = clamp(height - bottomInset - BUTTON_HEIGHT - 12, minY, maxY);
|
|
160
|
+
const dragPosition = useRef(new Animated.ValueXY({
|
|
161
|
+
x: 12,
|
|
162
|
+
y: initialY
|
|
163
|
+
})).current;
|
|
164
|
+
const dragStartPoint = useRef({
|
|
165
|
+
x: 12,
|
|
166
|
+
y: initialY
|
|
167
|
+
});
|
|
168
|
+
const [panelVisible, setPanelVisible] = useState(false);
|
|
169
|
+
const [activeTab, setActiveTab] = useState('Log');
|
|
170
|
+
const [logSubTab, setLogSubTab] = useState('All');
|
|
171
|
+
const [logEntries, setLogEntries] = useState([]);
|
|
172
|
+
const [networkEntries, setNetworkEntries] = useState([]);
|
|
173
|
+
const [expandedMap, setExpandedMap] = useState({});
|
|
174
|
+
const [systemInfo, setSystemInfo] = useState(null);
|
|
175
|
+
const [appInfo, setAppInfo] = useState(null);
|
|
176
|
+
const panelHeight = Math.floor(height * PANEL_HEIGHT_RATIO);
|
|
177
|
+
const panelTranslateY = useRef(new Animated.Value(panelHeight)).current;
|
|
178
|
+
const logListRefs = useFlatListRefs();
|
|
179
|
+
const networkListRef = useRef(null);
|
|
180
|
+
const normalizedFilter = useMemo(() => filter.map(item => item.trim().toLowerCase()).filter(Boolean), [filter]);
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
if (!enable) {
|
|
183
|
+
setPanelVisible(false);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
installConsoleProxy();
|
|
187
|
+
installXhrProxy({
|
|
188
|
+
filterHosts: normalizedFilter
|
|
189
|
+
});
|
|
190
|
+
const unsubscribeLog = subscribeLogEntries(setLogEntries);
|
|
191
|
+
const unsubscribeNetwork = subscribeNetworkEntries(setNetworkEntries);
|
|
192
|
+
setLogEntries(getLogEntries());
|
|
193
|
+
setNetworkEntries(getNetworkEntries());
|
|
194
|
+
return () => {
|
|
195
|
+
unsubscribeLog();
|
|
196
|
+
unsubscribeNetwork();
|
|
197
|
+
uninstallConsoleProxy();
|
|
198
|
+
uninstallXhrProxy();
|
|
199
|
+
};
|
|
200
|
+
}, [enable, normalizedFilter]);
|
|
201
|
+
useEffect(() => {
|
|
202
|
+
dragPosition.stopAnimation(value => {
|
|
203
|
+
const nextX = clamp(value.x, minX, maxX);
|
|
204
|
+
const nextY = clamp(value.y, minY, maxY);
|
|
205
|
+
dragPosition.setValue({
|
|
206
|
+
x: nextX,
|
|
207
|
+
y: nextY
|
|
208
|
+
});
|
|
209
|
+
dragStartPoint.current = {
|
|
210
|
+
x: nextX,
|
|
211
|
+
y: nextY
|
|
212
|
+
};
|
|
213
|
+
});
|
|
214
|
+
}, [dragPosition, maxX, maxY, minX, minY]);
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
if (panelVisible && activeTab === 'System' && !systemInfo) {
|
|
217
|
+
nativeModule?.getSystemInfo?.().then(result => setSystemInfo(result)).catch(() => undefined);
|
|
218
|
+
}
|
|
219
|
+
if (panelVisible && activeTab === 'App' && !appInfo) {
|
|
220
|
+
nativeModule?.getAppInfo?.().then(result => setAppInfo(result)).catch(() => undefined);
|
|
221
|
+
}
|
|
222
|
+
}, [activeTab, appInfo, nativeModule, panelVisible, systemInfo]);
|
|
223
|
+
const panResponder = useMemo(() => PanResponder.create({
|
|
224
|
+
onMoveShouldSetPanResponder: () => true,
|
|
225
|
+
onPanResponderGrant: () => {
|
|
226
|
+
dragPosition.stopAnimation(value => {
|
|
227
|
+
dragStartPoint.current = {
|
|
228
|
+
x: value.x,
|
|
229
|
+
y: value.y
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
},
|
|
233
|
+
onPanResponderMove: (_, gestureState) => {
|
|
234
|
+
const nextX = clamp(dragStartPoint.current.x + gestureState.dx, minX, maxX);
|
|
235
|
+
const nextY = clamp(dragStartPoint.current.y + gestureState.dy, minY, maxY);
|
|
236
|
+
dragPosition.setValue({
|
|
237
|
+
x: nextX,
|
|
238
|
+
y: nextY
|
|
239
|
+
});
|
|
240
|
+
},
|
|
241
|
+
onPanResponderRelease: () => {
|
|
242
|
+
dragPosition.stopAnimation(value => {
|
|
243
|
+
dragStartPoint.current = {
|
|
244
|
+
x: value.x,
|
|
245
|
+
y: value.y
|
|
246
|
+
};
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}), [dragPosition, maxX, maxY, minX, minY]);
|
|
250
|
+
const openPanel = () => {
|
|
251
|
+
setPanelVisible(true);
|
|
252
|
+
panelTranslateY.setValue(panelHeight);
|
|
253
|
+
Animated.timing(panelTranslateY, {
|
|
254
|
+
toValue: 0,
|
|
255
|
+
duration: 220,
|
|
256
|
+
useNativeDriver: true
|
|
257
|
+
}).start();
|
|
258
|
+
};
|
|
259
|
+
const closePanel = () => {
|
|
260
|
+
Animated.timing(panelTranslateY, {
|
|
261
|
+
toValue: panelHeight,
|
|
262
|
+
duration: 220,
|
|
263
|
+
useNativeDriver: true
|
|
264
|
+
}).start(({
|
|
265
|
+
finished
|
|
266
|
+
}) => {
|
|
267
|
+
if (finished) {
|
|
268
|
+
setPanelVisible(false);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
};
|
|
272
|
+
const logDataByTab = useMemo(() => ({
|
|
273
|
+
All: logEntries,
|
|
274
|
+
log: logEntries.filter(item => item.level === 'log'),
|
|
275
|
+
info: logEntries.filter(item => item.level === 'info'),
|
|
276
|
+
warn: logEntries.filter(item => item.level === 'warn'),
|
|
277
|
+
error: logEntries.filter(item => item.level === 'error')
|
|
278
|
+
}), [logEntries]);
|
|
279
|
+
const onToggleNode = key => {
|
|
280
|
+
setExpandedMap(prev => ({
|
|
281
|
+
...prev,
|
|
282
|
+
[key]: !prev[key]
|
|
283
|
+
}));
|
|
284
|
+
};
|
|
285
|
+
const scrollLogTop = () => {
|
|
286
|
+
logListRefs[logSubTab].current?.scrollToOffset({
|
|
287
|
+
offset: 0,
|
|
288
|
+
animated: true
|
|
289
|
+
});
|
|
290
|
+
};
|
|
291
|
+
const scrollLogBottom = () => {
|
|
292
|
+
logListRefs[logSubTab].current?.scrollToEnd({
|
|
293
|
+
animated: true
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
const scrollNetworkTop = () => {
|
|
297
|
+
networkListRef.current?.scrollToOffset({
|
|
298
|
+
offset: 0,
|
|
299
|
+
animated: true
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
const scrollNetworkBottom = () => {
|
|
303
|
+
networkListRef.current?.scrollToEnd({
|
|
304
|
+
animated: true
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
const renderRootTab = tab => /*#__PURE__*/_jsx(Pressable, {
|
|
308
|
+
style: [styles.topTabButton, activeTab === tab && styles.topTabButtonActive],
|
|
309
|
+
onPress: () => setActiveTab(tab),
|
|
310
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
311
|
+
style: [styles.topTabText, activeTab === tab && styles.topTabTextActive],
|
|
312
|
+
children: tab
|
|
313
|
+
})
|
|
314
|
+
}, tab);
|
|
315
|
+
const renderActionButton = (label, onPress) => /*#__PURE__*/_jsx(Pressable, {
|
|
316
|
+
style: styles.actionButton,
|
|
317
|
+
onPress: onPress,
|
|
318
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
319
|
+
style: styles.actionButtonText,
|
|
320
|
+
children: label
|
|
321
|
+
})
|
|
322
|
+
}, label);
|
|
323
|
+
const renderLogItem = ({
|
|
324
|
+
item
|
|
325
|
+
}) => {
|
|
326
|
+
const levelTheme = LOG_THEME[item.level];
|
|
327
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
328
|
+
style: [styles.listItem, {
|
|
329
|
+
backgroundColor: levelTheme.backgroundColor
|
|
330
|
+
}],
|
|
331
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
332
|
+
style: styles.listItemMain,
|
|
333
|
+
children: [/*#__PURE__*/_jsxs(Text, {
|
|
334
|
+
style: [styles.logLevelText, {
|
|
335
|
+
color: levelTheme.color
|
|
336
|
+
}],
|
|
337
|
+
children: ["[", item.level.toUpperCase(), "]"]
|
|
338
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
339
|
+
style: styles.logPayload,
|
|
340
|
+
children: item.args.map((arg, index) => /*#__PURE__*/_jsx(ObjectTree, {
|
|
341
|
+
value: arg,
|
|
342
|
+
nodeKey: `${item.id}.arg.${index}`,
|
|
343
|
+
expandedMap: expandedMap,
|
|
344
|
+
onToggle: onToggleNode
|
|
345
|
+
}, `${item.id}.arg.${index}`))
|
|
346
|
+
})]
|
|
347
|
+
}), /*#__PURE__*/_jsx(Pressable, {
|
|
348
|
+
style: styles.copyButton,
|
|
349
|
+
onPress: () => copyToClipboard(item.text),
|
|
350
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
351
|
+
style: styles.copyButtonText,
|
|
352
|
+
children: "\u590D\u5236"
|
|
353
|
+
})
|
|
354
|
+
})]
|
|
355
|
+
});
|
|
356
|
+
};
|
|
357
|
+
const renderNetworkItem = ({
|
|
358
|
+
item
|
|
359
|
+
}) => {
|
|
360
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
361
|
+
style: styles.listItem,
|
|
362
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
363
|
+
style: styles.listItemMain,
|
|
364
|
+
children: [/*#__PURE__*/_jsxs(Text, {
|
|
365
|
+
style: styles.networkTitle,
|
|
366
|
+
children: [item.method, " ", item.url]
|
|
367
|
+
}), /*#__PURE__*/_jsxs(Text, {
|
|
368
|
+
style: styles.networkLabel,
|
|
369
|
+
children: ["status ", item.status ?? '-', " duration", ' ', typeof item.durationMs === 'number' ? `${item.durationMs}ms` : '-']
|
|
370
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
371
|
+
style: styles.networkBlock,
|
|
372
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
373
|
+
style: styles.networkLabel,
|
|
374
|
+
children: "request headers"
|
|
375
|
+
}), /*#__PURE__*/_jsx(ObjectTree, {
|
|
376
|
+
value: item.requestHeaders,
|
|
377
|
+
nodeKey: `${item.id}.requestHeaders`,
|
|
378
|
+
expandedMap: expandedMap,
|
|
379
|
+
onToggle: onToggleNode
|
|
380
|
+
})]
|
|
381
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
382
|
+
style: styles.networkBlock,
|
|
383
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
384
|
+
style: styles.networkLabel,
|
|
385
|
+
children: "request body"
|
|
386
|
+
}), /*#__PURE__*/_jsx(ObjectTree, {
|
|
387
|
+
value: item.requestBody ?? '',
|
|
388
|
+
nodeKey: `${item.id}.requestBody`,
|
|
389
|
+
expandedMap: expandedMap,
|
|
390
|
+
onToggle: onToggleNode
|
|
391
|
+
})]
|
|
392
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
393
|
+
style: styles.networkBlock,
|
|
394
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
395
|
+
style: styles.networkLabel,
|
|
396
|
+
children: "response headers"
|
|
397
|
+
}), /*#__PURE__*/_jsx(ObjectTree, {
|
|
398
|
+
value: item.responseHeaders,
|
|
399
|
+
nodeKey: `${item.id}.responseHeaders`,
|
|
400
|
+
expandedMap: expandedMap,
|
|
401
|
+
onToggle: onToggleNode
|
|
402
|
+
})]
|
|
403
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
404
|
+
style: styles.networkBlock,
|
|
405
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
406
|
+
style: styles.networkLabel,
|
|
407
|
+
children: "response data"
|
|
408
|
+
}), /*#__PURE__*/_jsx(ObjectTree, {
|
|
409
|
+
value: item.responseData ?? '',
|
|
410
|
+
nodeKey: `${item.id}.responseData`,
|
|
411
|
+
expandedMap: expandedMap,
|
|
412
|
+
onToggle: onToggleNode
|
|
413
|
+
})]
|
|
414
|
+
})]
|
|
415
|
+
}), /*#__PURE__*/_jsx(Pressable, {
|
|
416
|
+
style: styles.copyButton,
|
|
417
|
+
onPress: () => copyToClipboard(buildNetworkCopyText(item)),
|
|
418
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
419
|
+
style: styles.copyButtonText,
|
|
420
|
+
children: "\u590D\u5236"
|
|
421
|
+
})
|
|
422
|
+
})]
|
|
423
|
+
});
|
|
424
|
+
};
|
|
425
|
+
const renderLogPanel = () => /*#__PURE__*/_jsxs(View, {
|
|
426
|
+
style: styles.contentArea,
|
|
427
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
428
|
+
style: styles.subTabRow,
|
|
429
|
+
children: LOG_SUB_TABS.map(tab => /*#__PURE__*/_jsx(Pressable, {
|
|
430
|
+
style: [styles.subTabButton, logSubTab === tab && styles.subTabButtonActive],
|
|
431
|
+
onPress: () => setLogSubTab(tab),
|
|
432
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
433
|
+
style: [styles.subTabText, logSubTab === tab && styles.subTabTextActive],
|
|
434
|
+
children: tab
|
|
435
|
+
})
|
|
436
|
+
}, tab))
|
|
437
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
438
|
+
style: styles.logListsWrap,
|
|
439
|
+
children: LOG_SUB_TABS.map(tab => /*#__PURE__*/_jsx(View, {
|
|
440
|
+
style: [styles.listHost, logSubTab !== tab && styles.hidden],
|
|
441
|
+
children: /*#__PURE__*/_jsx(FlatList, {
|
|
442
|
+
ref: logListRefs[tab],
|
|
443
|
+
data: logDataByTab[tab],
|
|
444
|
+
keyExtractor: item => `${tab}-${item.id}`,
|
|
445
|
+
renderItem: renderLogItem,
|
|
446
|
+
ItemSeparatorComponent: ListSeparator
|
|
447
|
+
})
|
|
448
|
+
}, tab))
|
|
449
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
450
|
+
style: styles.actionsRow,
|
|
451
|
+
children: [renderActionButton('Clear', () => {
|
|
452
|
+
clearLogEntries();
|
|
453
|
+
setExpandedMap({});
|
|
454
|
+
}), renderActionButton('Top', scrollLogTop), renderActionButton('Bottom', scrollLogBottom), renderActionButton('Hide', closePanel)]
|
|
455
|
+
})]
|
|
456
|
+
});
|
|
457
|
+
const renderNetworkPanel = () => /*#__PURE__*/_jsxs(View, {
|
|
458
|
+
style: styles.contentArea,
|
|
459
|
+
children: [/*#__PURE__*/_jsx(FlatList, {
|
|
460
|
+
ref: networkListRef,
|
|
461
|
+
data: networkEntries,
|
|
462
|
+
keyExtractor: item => `network-${item.id}`,
|
|
463
|
+
renderItem: renderNetworkItem,
|
|
464
|
+
ItemSeparatorComponent: ListSeparator
|
|
465
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
466
|
+
style: styles.actionsRow,
|
|
467
|
+
children: [renderActionButton('Clear', () => {
|
|
468
|
+
clearNetworkEntries();
|
|
469
|
+
setExpandedMap({});
|
|
470
|
+
}), renderActionButton('Top', scrollNetworkTop), renderActionButton('Bottom', scrollNetworkBottom), renderActionButton('Hide', closePanel)]
|
|
471
|
+
})]
|
|
472
|
+
});
|
|
473
|
+
const renderSystemPanel = () => /*#__PURE__*/_jsxs(View, {
|
|
474
|
+
style: styles.contentArea,
|
|
475
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
476
|
+
style: styles.infoCard,
|
|
477
|
+
children: [/*#__PURE__*/_jsxs(Text, {
|
|
478
|
+
style: styles.infoText,
|
|
479
|
+
children: ["\u5382\u5546/\u54C1\u724C: ", systemInfo?.manufacturer ?? '-']
|
|
480
|
+
}), /*#__PURE__*/_jsxs(Text, {
|
|
481
|
+
style: styles.infoText,
|
|
482
|
+
children: ["\u673A\u578B: ", systemInfo?.model ?? '-']
|
|
483
|
+
}), /*#__PURE__*/_jsxs(Text, {
|
|
484
|
+
style: styles.infoText,
|
|
485
|
+
children: ["\u7CFB\u7EDF\u7248\u672C: ", systemInfo?.osVersion ?? '-']
|
|
486
|
+
}), Platform.OS === 'android' ? /*#__PURE__*/_jsxs(Text, {
|
|
487
|
+
style: styles.infoText,
|
|
488
|
+
children: ["\u7F51\u7EDC\u7C7B\u578B: ", systemInfo?.networkType ?? '-']
|
|
489
|
+
}) : null, Platform.OS === 'android' ? /*#__PURE__*/_jsxs(Text, {
|
|
490
|
+
style: styles.infoText,
|
|
491
|
+
children: ["\u7F51\u7EDC\u53EF\u8FBE: ", systemInfo?.isNetworkReachable ? 'true' : 'false']
|
|
492
|
+
}) : null, /*#__PURE__*/_jsxs(Text, {
|
|
493
|
+
style: styles.infoText,
|
|
494
|
+
children: ["\u603B\u5185\u5B58: ", systemInfo?.totalMemory ?? 0]
|
|
495
|
+
}), Platform.OS === 'android' ? /*#__PURE__*/_jsxs(Text, {
|
|
496
|
+
style: styles.infoText,
|
|
497
|
+
children: ["\u53EF\u7528\u5185\u5B58: ", systemInfo?.availableMemory ?? 0]
|
|
498
|
+
}) : null]
|
|
499
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
500
|
+
style: styles.actionsRow,
|
|
501
|
+
children: renderActionButton('Hide', closePanel)
|
|
502
|
+
})]
|
|
503
|
+
});
|
|
504
|
+
const renderAppPanel = () => /*#__PURE__*/_jsxs(View, {
|
|
505
|
+
style: styles.contentArea,
|
|
506
|
+
children: [/*#__PURE__*/_jsxs(View, {
|
|
507
|
+
style: styles.infoCard,
|
|
508
|
+
children: [/*#__PURE__*/_jsxs(Text, {
|
|
509
|
+
style: styles.infoText,
|
|
510
|
+
children: ["App Version: ", appInfo?.appVersion ?? '-']
|
|
511
|
+
}), /*#__PURE__*/_jsxs(Text, {
|
|
512
|
+
style: styles.infoText,
|
|
513
|
+
children: ["Build Number: ", appInfo?.buildNumber ?? '-']
|
|
514
|
+
})]
|
|
515
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
516
|
+
style: styles.actionsRow,
|
|
517
|
+
children: renderActionButton('Hide', closePanel)
|
|
518
|
+
})]
|
|
519
|
+
});
|
|
520
|
+
if (!enable) {
|
|
521
|
+
return null;
|
|
522
|
+
}
|
|
523
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
524
|
+
pointerEvents: "box-none",
|
|
525
|
+
style: StyleSheet.absoluteFill,
|
|
526
|
+
children: [!panelVisible ? /*#__PURE__*/_jsx(Animated.View, {
|
|
527
|
+
style: [styles.floatingButtonWrap, {
|
|
528
|
+
transform: dragPosition.getTranslateTransform()
|
|
529
|
+
}],
|
|
530
|
+
...panResponder.panHandlers,
|
|
531
|
+
children: /*#__PURE__*/_jsx(Pressable, {
|
|
532
|
+
style: styles.floatingButton,
|
|
533
|
+
onPress: openPanel,
|
|
534
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
535
|
+
style: styles.floatingButtonText,
|
|
536
|
+
children: "vConsole"
|
|
537
|
+
})
|
|
538
|
+
})
|
|
539
|
+
}) : null, panelVisible ? /*#__PURE__*/_jsxs(View, {
|
|
540
|
+
style: styles.overlayWrap,
|
|
541
|
+
children: [/*#__PURE__*/_jsx(Pressable, {
|
|
542
|
+
style: styles.mask,
|
|
543
|
+
onPress: closePanel
|
|
544
|
+
}), /*#__PURE__*/_jsxs(Animated.View, {
|
|
545
|
+
style: [styles.panel, {
|
|
546
|
+
height: panelHeight,
|
|
547
|
+
transform: [{
|
|
548
|
+
translateY: panelTranslateY
|
|
549
|
+
}]
|
|
550
|
+
}],
|
|
551
|
+
children: [/*#__PURE__*/_jsx(View, {
|
|
552
|
+
style: styles.topTabRow,
|
|
553
|
+
children: ROOT_TABS.map(renderRootTab)
|
|
554
|
+
}), activeTab === 'Log' ? renderLogPanel() : null, activeTab === 'Network' ? renderNetworkPanel() : null, activeTab === 'System' ? renderSystemPanel() : null, activeTab === 'App' ? renderAppPanel() : null]
|
|
555
|
+
})]
|
|
556
|
+
}) : null]
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
const styles = StyleSheet.create({
|
|
560
|
+
floatingButtonWrap: {
|
|
561
|
+
position: 'absolute',
|
|
562
|
+
zIndex: 9999
|
|
563
|
+
},
|
|
564
|
+
floatingButton: {
|
|
565
|
+
width: BUTTON_WIDTH,
|
|
566
|
+
height: BUTTON_HEIGHT,
|
|
567
|
+
borderRadius: 12,
|
|
568
|
+
backgroundColor: '#22A455',
|
|
569
|
+
justifyContent: 'center',
|
|
570
|
+
alignItems: 'center'
|
|
571
|
+
},
|
|
572
|
+
floatingButtonText: {
|
|
573
|
+
color: '#FFFFFF',
|
|
574
|
+
fontSize: 12,
|
|
575
|
+
fontWeight: '600'
|
|
576
|
+
},
|
|
577
|
+
overlayWrap: {
|
|
578
|
+
...StyleSheet.absoluteFillObject,
|
|
579
|
+
justifyContent: 'flex-end'
|
|
580
|
+
},
|
|
581
|
+
mask: {
|
|
582
|
+
...StyleSheet.absoluteFillObject,
|
|
583
|
+
backgroundColor: 'rgba(0, 0, 0, 0.25)'
|
|
584
|
+
},
|
|
585
|
+
panel: {
|
|
586
|
+
width: '100%',
|
|
587
|
+
backgroundColor: '#FFFFFF',
|
|
588
|
+
borderTopLeftRadius: 14,
|
|
589
|
+
borderTopRightRadius: 14,
|
|
590
|
+
overflow: 'hidden'
|
|
591
|
+
},
|
|
592
|
+
topTabRow: {
|
|
593
|
+
flexDirection: 'row',
|
|
594
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
595
|
+
borderBottomColor: '#D9D9D9',
|
|
596
|
+
paddingHorizontal: 8,
|
|
597
|
+
paddingVertical: 8
|
|
598
|
+
},
|
|
599
|
+
topTabButton: {
|
|
600
|
+
paddingHorizontal: 12,
|
|
601
|
+
paddingVertical: 8,
|
|
602
|
+
borderRadius: 8
|
|
603
|
+
},
|
|
604
|
+
topTabButtonActive: {
|
|
605
|
+
backgroundColor: '#EEF5FF'
|
|
606
|
+
},
|
|
607
|
+
topTabText: {
|
|
608
|
+
color: '#444444',
|
|
609
|
+
fontSize: 13,
|
|
610
|
+
fontWeight: '500'
|
|
611
|
+
},
|
|
612
|
+
topTabTextActive: {
|
|
613
|
+
color: '#246BFD'
|
|
614
|
+
},
|
|
615
|
+
contentArea: {
|
|
616
|
+
flex: 1,
|
|
617
|
+
paddingBottom: 16
|
|
618
|
+
},
|
|
619
|
+
subTabRow: {
|
|
620
|
+
flexDirection: 'row',
|
|
621
|
+
paddingHorizontal: 8,
|
|
622
|
+
paddingVertical: 8,
|
|
623
|
+
borderBottomWidth: StyleSheet.hairlineWidth,
|
|
624
|
+
borderBottomColor: '#E0E0E0'
|
|
625
|
+
},
|
|
626
|
+
subTabButton: {
|
|
627
|
+
marginRight: 8,
|
|
628
|
+
paddingHorizontal: 10,
|
|
629
|
+
paddingVertical: 6,
|
|
630
|
+
borderRadius: 8
|
|
631
|
+
},
|
|
632
|
+
subTabButtonActive: {
|
|
633
|
+
backgroundColor: '#EEF5FF'
|
|
634
|
+
},
|
|
635
|
+
subTabText: {
|
|
636
|
+
color: '#666666',
|
|
637
|
+
fontSize: 12
|
|
638
|
+
},
|
|
639
|
+
subTabTextActive: {
|
|
640
|
+
color: '#246BFD'
|
|
641
|
+
},
|
|
642
|
+
logListsWrap: {
|
|
643
|
+
flex: 1
|
|
644
|
+
},
|
|
645
|
+
listHost: {
|
|
646
|
+
flex: 1
|
|
647
|
+
},
|
|
648
|
+
hidden: {
|
|
649
|
+
display: 'none'
|
|
650
|
+
},
|
|
651
|
+
listItem: {
|
|
652
|
+
paddingHorizontal: 10,
|
|
653
|
+
paddingVertical: 10,
|
|
654
|
+
flexDirection: 'row',
|
|
655
|
+
justifyContent: 'space-between',
|
|
656
|
+
alignItems: 'flex-start'
|
|
657
|
+
},
|
|
658
|
+
listItemMain: {
|
|
659
|
+
flex: 1,
|
|
660
|
+
marginRight: 8
|
|
661
|
+
},
|
|
662
|
+
separator: {
|
|
663
|
+
height: StyleSheet.hairlineWidth,
|
|
664
|
+
backgroundColor: '#DFDFDF'
|
|
665
|
+
},
|
|
666
|
+
logLevelText: {
|
|
667
|
+
fontSize: 11,
|
|
668
|
+
fontWeight: '700',
|
|
669
|
+
marginBottom: 4
|
|
670
|
+
},
|
|
671
|
+
logPayload: {
|
|
672
|
+
flex: 1
|
|
673
|
+
},
|
|
674
|
+
copyButton: {
|
|
675
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
676
|
+
borderColor: '#D0D0D0',
|
|
677
|
+
borderRadius: 6,
|
|
678
|
+
paddingVertical: 4,
|
|
679
|
+
paddingHorizontal: 8
|
|
680
|
+
},
|
|
681
|
+
copyButtonText: {
|
|
682
|
+
fontSize: 11,
|
|
683
|
+
color: '#333333'
|
|
684
|
+
},
|
|
685
|
+
valuePrimitive: {
|
|
686
|
+
color: '#222222',
|
|
687
|
+
fontSize: 12,
|
|
688
|
+
flexShrink: 1
|
|
689
|
+
},
|
|
690
|
+
treeNode: {
|
|
691
|
+
flexDirection: 'column',
|
|
692
|
+
marginBottom: 4
|
|
693
|
+
},
|
|
694
|
+
treeHeader: {
|
|
695
|
+
flexDirection: 'row',
|
|
696
|
+
alignItems: 'center'
|
|
697
|
+
},
|
|
698
|
+
arrow: {
|
|
699
|
+
color: '#666666',
|
|
700
|
+
fontSize: 11,
|
|
701
|
+
marginRight: 4
|
|
702
|
+
},
|
|
703
|
+
treeLabel: {
|
|
704
|
+
color: '#444444',
|
|
705
|
+
fontSize: 12,
|
|
706
|
+
fontWeight: '500'
|
|
707
|
+
},
|
|
708
|
+
treeChildren: {
|
|
709
|
+
marginLeft: 14,
|
|
710
|
+
marginTop: 4
|
|
711
|
+
},
|
|
712
|
+
treeChildRow: {
|
|
713
|
+
flexDirection: 'row',
|
|
714
|
+
alignItems: 'flex-start',
|
|
715
|
+
marginBottom: 2
|
|
716
|
+
},
|
|
717
|
+
treeKey: {
|
|
718
|
+
color: '#666666',
|
|
719
|
+
fontSize: 12
|
|
720
|
+
},
|
|
721
|
+
networkTitle: {
|
|
722
|
+
fontSize: 12,
|
|
723
|
+
color: '#111111',
|
|
724
|
+
fontWeight: '600',
|
|
725
|
+
marginBottom: 6
|
|
726
|
+
},
|
|
727
|
+
networkBlock: {
|
|
728
|
+
marginTop: 2,
|
|
729
|
+
marginBottom: 6
|
|
730
|
+
},
|
|
731
|
+
networkLabel: {
|
|
732
|
+
fontSize: 12,
|
|
733
|
+
color: '#444444',
|
|
734
|
+
marginBottom: 2
|
|
735
|
+
},
|
|
736
|
+
actionsRow: {
|
|
737
|
+
borderTopWidth: StyleSheet.hairlineWidth,
|
|
738
|
+
borderTopColor: '#E1E1E1',
|
|
739
|
+
paddingHorizontal: 8,
|
|
740
|
+
paddingVertical: 8,
|
|
741
|
+
flexDirection: 'row',
|
|
742
|
+
justifyContent: 'space-around'
|
|
743
|
+
},
|
|
744
|
+
actionButton: {
|
|
745
|
+
minWidth: 62,
|
|
746
|
+
borderRadius: 8,
|
|
747
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
748
|
+
borderColor: '#D0D0D0',
|
|
749
|
+
paddingHorizontal: 10,
|
|
750
|
+
paddingVertical: 7,
|
|
751
|
+
alignItems: 'center'
|
|
752
|
+
},
|
|
753
|
+
actionButtonText: {
|
|
754
|
+
color: '#333333',
|
|
755
|
+
fontSize: 12,
|
|
756
|
+
fontWeight: '500'
|
|
757
|
+
},
|
|
758
|
+
infoCard: {
|
|
759
|
+
flex: 1,
|
|
760
|
+
paddingHorizontal: 12,
|
|
761
|
+
paddingVertical: 12
|
|
762
|
+
},
|
|
763
|
+
infoText: {
|
|
764
|
+
fontSize: 13,
|
|
765
|
+
color: '#222222',
|
|
766
|
+
marginBottom: 8
|
|
767
|
+
}
|
|
768
|
+
});
|
|
769
|
+
//# sourceMappingURL=VConsole.js.map
|