react-native-inapp-inspector 2.0.0 → 2.0.2
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 +10 -0
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.9/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/9.2.0/checksums/checksums.lock +0 -0
- package/android/.gradle/9.2.0/fileChanges/last-build.bin +0 -0
- package/android/.gradle/9.2.0/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/9.2.0/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/9.2.0/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build/reports/problems/problems-report.html +659 -0
- package/android/src/main/java/com/inappinspector/NetworkInspectorModule.kt +33 -24
- package/dist/commonjs/components/ConsoleLogCard.js +5 -5
- package/dist/commonjs/components/EndOfListFooter.js +1 -1
- package/dist/commonjs/components/Inspector/AnalyticsTab.js +19 -71
- package/dist/commonjs/components/Inspector/BundleTab.js +670 -188
- package/dist/commonjs/components/Inspector/ConsoleTab.js +109 -98
- package/dist/commonjs/components/Inspector/CrashTab.js +2 -1
- package/dist/commonjs/components/Inspector/InspectorHeader.js +102 -19
- package/dist/commonjs/components/Inspector/MainScreen.js +151 -17
- package/dist/commonjs/components/Inspector/NetworkTab.js +104 -20
- package/dist/commonjs/components/Inspector/SettingsPanel.js +1111 -1385
- package/dist/commonjs/components/Inspector/TabBar.js +3 -4
- package/dist/commonjs/components/Inspector/TelemetryConsentModal.d.ts +3 -0
- package/dist/commonjs/components/Inspector/TelemetryConsentModal.js +212 -0
- package/dist/commonjs/components/JsonViewer.js +9 -4
- package/dist/commonjs/components/LogCard.js +31 -1
- package/dist/commonjs/components/LogSyntaxHighlighter.d.ts +16 -0
- package/dist/commonjs/components/LogSyntaxHighlighter.js +130 -0
- package/dist/commonjs/components/NetworkIcons.d.ts +2 -0
- package/dist/commonjs/components/NetworkIcons.js +10 -1
- package/dist/commonjs/components/Slider.d.ts +13 -0
- package/dist/commonjs/components/Slider.js +261 -0
- package/dist/commonjs/constants/version.d.ts +1 -1
- package/dist/commonjs/constants/version.js +1 -1
- package/dist/commonjs/customHooks/analyticsLogger.js +1 -1
- package/dist/commonjs/customHooks/crashHandler.js +1 -1
- package/dist/commonjs/helpers/index.d.ts +2 -0
- package/dist/commonjs/helpers/index.js +16 -0
- package/dist/commonjs/helpers/searchQueryParser.d.ts +6 -0
- package/dist/commonjs/helpers/searchQueryParser.js +236 -0
- package/dist/commonjs/helpers/settingsStore.js +13 -13
- package/dist/commonjs/helpers/telemetry.d.ts +99 -0
- package/dist/commonjs/helpers/telemetry.js +398 -0
- package/dist/commonjs/index.d.ts +2 -0
- package/dist/commonjs/index.js +30 -21
- package/dist/commonjs/native/NativeInspector.d.ts +5 -0
- package/dist/commonjs/native/NativeInspector.js +3 -2
- package/dist/commonjs/styles/index.js +35 -35
- package/dist/esm/components/ConsoleLogCard.js +5 -5
- package/dist/esm/components/EndOfListFooter.js +2 -2
- package/dist/esm/components/Inspector/AnalyticsTab.js +21 -73
- package/dist/esm/components/Inspector/BundleTab.js +670 -188
- package/dist/esm/components/Inspector/ConsoleTab.js +110 -99
- package/dist/esm/components/Inspector/CrashTab.js +2 -1
- package/dist/esm/components/Inspector/InspectorHeader.js +103 -20
- package/dist/esm/components/Inspector/MainScreen.js +119 -18
- package/dist/esm/components/Inspector/NetworkTab.js +105 -21
- package/dist/esm/components/Inspector/SettingsPanel.js +1114 -1388
- package/dist/esm/components/Inspector/TabBar.js +4 -5
- package/dist/esm/components/Inspector/TelemetryConsentModal.d.ts +3 -0
- package/dist/esm/components/Inspector/TelemetryConsentModal.js +175 -0
- package/dist/esm/components/JsonViewer.js +9 -4
- package/dist/esm/components/LogCard.js +32 -2
- package/dist/esm/components/LogSyntaxHighlighter.d.ts +16 -0
- package/dist/esm/components/LogSyntaxHighlighter.js +123 -0
- package/dist/esm/components/NetworkIcons.d.ts +2 -0
- package/dist/esm/components/NetworkIcons.js +7 -0
- package/dist/esm/components/Slider.d.ts +13 -0
- package/dist/esm/components/Slider.js +222 -0
- package/dist/esm/constants/version.d.ts +1 -1
- package/dist/esm/constants/version.js +1 -1
- package/dist/esm/customHooks/analyticsLogger.js +1 -1
- package/dist/esm/customHooks/crashHandler.js +1 -1
- package/dist/esm/helpers/index.d.ts +2 -0
- package/dist/esm/helpers/index.js +2 -0
- package/dist/esm/helpers/searchQueryParser.d.ts +6 -0
- package/dist/esm/helpers/searchQueryParser.js +233 -0
- package/dist/esm/helpers/settingsStore.js +13 -13
- package/dist/esm/helpers/telemetry.d.ts +99 -0
- package/dist/esm/helpers/telemetry.js +380 -0
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +20 -21
- package/dist/esm/native/NativeInspector.d.ts +5 -0
- package/dist/esm/native/NativeInspector.js +3 -2
- package/dist/esm/styles/index.js +35 -35
- package/ios/{NetworkInspectorModule.m → NetworkInspectorModule.mm} +193 -97
- package/package.json +2 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Animated, ScrollView, Text,
|
|
2
|
+
import { Animated, ScrollView, Text, View } from 'react-native';
|
|
3
3
|
import { useInspector } from './InspectorContext';
|
|
4
4
|
import styles from '../../styles';
|
|
5
5
|
import { AppColors } from '../../styles/AppColors';
|
|
6
|
+
import TouchableScale from '../TouchableScale';
|
|
6
7
|
import { SignalIcon, TerminalIcon, AnalyticsIcon, PackageIcon, ReduxIcon, PerformanceIcon, CrashIcon, } from '../NetworkIcons';
|
|
7
8
|
import { isReduxConnected } from '../../customHooks/reduxLogger';
|
|
8
9
|
import { isAnalyticsConnected } from '../../customHooks/analyticsLogger';
|
|
9
|
-
import { triggerNativeHaptic } from '../../native/NativeInspector';
|
|
10
10
|
const TabBar = React.memo(() => {
|
|
11
11
|
const { activeTab, switchActiveTab, tabVisibility, logs, consoleLogs, analyticsEvents, crashRecords, lastReadApisCount, lastReadLogsCount, lastReadCrashesCount, unreadPulseAnim, } = useInspector();
|
|
12
12
|
const isReduxAvail = isReduxConnected();
|
|
@@ -80,9 +80,8 @@ const TabBar = React.memo(() => {
|
|
|
80
80
|
consoleLogs.length > lastReadLogsCount;
|
|
81
81
|
const hasUnreadCrashes = activeTab !== 'crash' &&
|
|
82
82
|
(crashRecords?.length || 0) > (lastReadCrashesCount || 0);
|
|
83
|
-
return (<
|
|
83
|
+
return (<TouchableScale key={tab.key} onPress={() => {
|
|
84
84
|
switchActiveTab(tab.key);
|
|
85
|
-
triggerNativeHaptic('light');
|
|
86
85
|
}} style={[
|
|
87
86
|
styles.contentTabButton,
|
|
88
87
|
isActive && styles.contentTabButtonActive,
|
|
@@ -119,7 +118,7 @@ const TabBar = React.memo(() => {
|
|
|
119
118
|
transform: [{ scale: unreadPulseAnim }],
|
|
120
119
|
}}/>)}
|
|
121
120
|
</View>
|
|
122
|
-
</
|
|
121
|
+
</TouchableScale>);
|
|
123
122
|
})}
|
|
124
123
|
</ScrollView>
|
|
125
124
|
</View>);
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { Modal, View, Text, TouchableOpacity, StyleSheet, Animated, } from 'react-native';
|
|
3
|
+
import { AppColors } from '../../styles/AppColors';
|
|
4
|
+
import { BrandCircleIcon } from '../BrandCircleIcon';
|
|
5
|
+
import { getTelemetryConsentStatus, setTelemetryConsent, sendSessionTelemetryPing, } from '../../helpers/telemetry';
|
|
6
|
+
export const TelemetryConsentModal = () => {
|
|
7
|
+
const [visible, setVisible] = useState(false);
|
|
8
|
+
const fadeAnim = useState(new Animated.Value(0))[0];
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
let isMounted = true;
|
|
11
|
+
getTelemetryConsentStatus().then(status => {
|
|
12
|
+
if (isMounted && status === 'undetermined') {
|
|
13
|
+
setVisible(true);
|
|
14
|
+
Animated.timing(fadeAnim, {
|
|
15
|
+
toValue: 1,
|
|
16
|
+
duration: 300,
|
|
17
|
+
useNativeDriver: true,
|
|
18
|
+
}).start();
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return () => {
|
|
22
|
+
isMounted = false;
|
|
23
|
+
};
|
|
24
|
+
}, [fadeAnim]);
|
|
25
|
+
const handleDecision = async (granted) => {
|
|
26
|
+
Animated.timing(fadeAnim, {
|
|
27
|
+
toValue: 0,
|
|
28
|
+
duration: 200,
|
|
29
|
+
useNativeDriver: true,
|
|
30
|
+
}).start(async () => {
|
|
31
|
+
setVisible(false);
|
|
32
|
+
await setTelemetryConsent(granted);
|
|
33
|
+
if (granted) {
|
|
34
|
+
// Immediately trigger the session initialization ping
|
|
35
|
+
sendSessionTelemetryPing({ force: true });
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
if (!visible)
|
|
40
|
+
return null;
|
|
41
|
+
return (<Modal transparent visible={visible} animationType="none" statusBarTranslucent>
|
|
42
|
+
<View style={styles.overlay}>
|
|
43
|
+
<Animated.View style={[styles.card, { opacity: fadeAnim }]}>
|
|
44
|
+
<View style={styles.headerRow}>
|
|
45
|
+
<View style={styles.iconWrapper}>
|
|
46
|
+
<BrandCircleIcon size={40}/>
|
|
47
|
+
</View>
|
|
48
|
+
<View style={styles.titleContainer}>
|
|
49
|
+
<Text style={styles.title}>Help Improve In-App Inspector</Text>
|
|
50
|
+
<Text style={styles.subtitle}>Anonymous Diagnostic Insights</Text>
|
|
51
|
+
</View>
|
|
52
|
+
</View>
|
|
53
|
+
|
|
54
|
+
<Text style={styles.description}>
|
|
55
|
+
To help us continually enhance tooling performance and compatibility,
|
|
56
|
+
would you mind sharing anonymous diagnostics (such as React Native
|
|
57
|
+
version, JavaScript engine, and platform architecture)?
|
|
58
|
+
</Text>
|
|
59
|
+
|
|
60
|
+
<View style={styles.privacyBadge}>
|
|
61
|
+
<Text style={styles.privacyText}>
|
|
62
|
+
🔒 <Text style={{ fontWeight: '700' }}>Privacy Guaranteed:</Text> We
|
|
63
|
+
only collect non-identifiable environment metrics. No personal
|
|
64
|
+
data, tokens, or network request payloads are ever collected.
|
|
65
|
+
</Text>
|
|
66
|
+
</View>
|
|
67
|
+
|
|
68
|
+
<View style={styles.buttonRow}>
|
|
69
|
+
<TouchableOpacity style={styles.declineButton} onPress={() => handleDecision(false)} activeOpacity={0.7}>
|
|
70
|
+
<Text style={styles.declineText}>Not Now</Text>
|
|
71
|
+
</TouchableOpacity>
|
|
72
|
+
|
|
73
|
+
<TouchableOpacity style={styles.allowButton} onPress={() => handleDecision(true)} activeOpacity={0.8}>
|
|
74
|
+
<Text style={styles.allowText}>Allow & Share</Text>
|
|
75
|
+
</TouchableOpacity>
|
|
76
|
+
</View>
|
|
77
|
+
</Animated.View>
|
|
78
|
+
</View>
|
|
79
|
+
</Modal>);
|
|
80
|
+
};
|
|
81
|
+
const styles = StyleSheet.create({
|
|
82
|
+
overlay: {
|
|
83
|
+
flex: 1,
|
|
84
|
+
backgroundColor: 'rgba(0, 0, 0, 0.65)',
|
|
85
|
+
justifyContent: 'center',
|
|
86
|
+
alignItems: 'center',
|
|
87
|
+
padding: 24,
|
|
88
|
+
zIndex: 999999,
|
|
89
|
+
},
|
|
90
|
+
card: {
|
|
91
|
+
width: '100%',
|
|
92
|
+
maxWidth: 420,
|
|
93
|
+
backgroundColor: '#1E1F29',
|
|
94
|
+
borderRadius: 20,
|
|
95
|
+
padding: 22,
|
|
96
|
+
borderWidth: 1,
|
|
97
|
+
borderColor: 'rgba(255, 255, 255, 0.12)',
|
|
98
|
+
shadowColor: '#000',
|
|
99
|
+
shadowOffset: { width: 0, height: 10 },
|
|
100
|
+
shadowOpacity: 0.5,
|
|
101
|
+
shadowRadius: 20,
|
|
102
|
+
elevation: 24,
|
|
103
|
+
},
|
|
104
|
+
headerRow: {
|
|
105
|
+
flexDirection: 'row',
|
|
106
|
+
alignItems: 'center',
|
|
107
|
+
marginBottom: 14,
|
|
108
|
+
},
|
|
109
|
+
iconWrapper: {
|
|
110
|
+
marginRight: 14,
|
|
111
|
+
},
|
|
112
|
+
titleContainer: {
|
|
113
|
+
flex: 1,
|
|
114
|
+
},
|
|
115
|
+
title: {
|
|
116
|
+
fontSize: 17,
|
|
117
|
+
fontWeight: '700',
|
|
118
|
+
color: '#FFFFFF',
|
|
119
|
+
letterSpacing: -0.2,
|
|
120
|
+
},
|
|
121
|
+
subtitle: {
|
|
122
|
+
fontSize: 12,
|
|
123
|
+
color: AppColors.purple || '#9055FF',
|
|
124
|
+
fontWeight: '600',
|
|
125
|
+
marginTop: 2,
|
|
126
|
+
},
|
|
127
|
+
description: {
|
|
128
|
+
fontSize: 13,
|
|
129
|
+
lineHeight: 19,
|
|
130
|
+
color: 'rgba(255, 255, 255, 0.75)',
|
|
131
|
+
marginBottom: 14,
|
|
132
|
+
},
|
|
133
|
+
privacyBadge: {
|
|
134
|
+
backgroundColor: 'rgba(144, 85, 255, 0.12)',
|
|
135
|
+
borderRadius: 10,
|
|
136
|
+
padding: 10,
|
|
137
|
+
borderWidth: 1,
|
|
138
|
+
borderColor: 'rgba(144, 85, 255, 0.25)',
|
|
139
|
+
marginBottom: 20,
|
|
140
|
+
},
|
|
141
|
+
privacyText: {
|
|
142
|
+
fontSize: 11,
|
|
143
|
+
lineHeight: 16,
|
|
144
|
+
color: '#D8C6FF',
|
|
145
|
+
},
|
|
146
|
+
buttonRow: {
|
|
147
|
+
flexDirection: 'row',
|
|
148
|
+
justifyContent: 'flex-end',
|
|
149
|
+
alignItems: 'center',
|
|
150
|
+
gap: 12,
|
|
151
|
+
},
|
|
152
|
+
declineButton: {
|
|
153
|
+
paddingVertical: 10,
|
|
154
|
+
paddingHorizontal: 16,
|
|
155
|
+
borderRadius: 10,
|
|
156
|
+
backgroundColor: 'rgba(255, 255, 255, 0.08)',
|
|
157
|
+
},
|
|
158
|
+
declineText: {
|
|
159
|
+
fontSize: 13,
|
|
160
|
+
fontWeight: '600',
|
|
161
|
+
color: 'rgba(255, 255, 255, 0.7)',
|
|
162
|
+
},
|
|
163
|
+
allowButton: {
|
|
164
|
+
paddingVertical: 10,
|
|
165
|
+
paddingHorizontal: 20,
|
|
166
|
+
borderRadius: 10,
|
|
167
|
+
backgroundColor: '#7C3AED',
|
|
168
|
+
},
|
|
169
|
+
allowText: {
|
|
170
|
+
fontSize: 13,
|
|
171
|
+
fontWeight: '700',
|
|
172
|
+
color: '#FFFFFF',
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
export default TelemetryConsentModal;
|
|
@@ -68,20 +68,25 @@ const JsonViewer = React.memo(({ data, search, forceOpen, defaultExpandDepth = 1
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
const rawText = React.useMemo(() => {
|
|
71
|
+
if (data === undefined || data === null) {
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
71
74
|
if (typeof data === 'string') {
|
|
72
75
|
return data;
|
|
73
76
|
}
|
|
74
77
|
try {
|
|
75
|
-
|
|
78
|
+
const stringified = JSON.stringify(data);
|
|
79
|
+
return stringified ?? '';
|
|
76
80
|
}
|
|
77
81
|
catch {
|
|
78
|
-
return String(data);
|
|
82
|
+
return String(data) || '';
|
|
79
83
|
}
|
|
80
84
|
}, [data]);
|
|
81
85
|
const [showFullRaw, setShowFullRaw] = useState(false);
|
|
82
86
|
const RAW_LIMIT = 50000;
|
|
83
|
-
const
|
|
84
|
-
const
|
|
87
|
+
const safeRawText = typeof rawText === 'string' ? rawText : '';
|
|
88
|
+
const isTruncated = safeRawText.length > RAW_LIMIT && !showFullRaw;
|
|
89
|
+
const displayRawText = isTruncated ? safeRawText.slice(0, RAW_LIMIT) : safeRawText;
|
|
85
90
|
useEffect(() => {
|
|
86
91
|
if (externalMode) {
|
|
87
92
|
setInternalMode(externalMode);
|
|
@@ -4,7 +4,7 @@ import Svg, { Path } from 'react-native-svg';
|
|
|
4
4
|
import { AppColors } from '../styles/AppColors';
|
|
5
5
|
import { METHOD_COLORS } from '../constants';
|
|
6
6
|
import { getStatusColor, getDurationColor, formatDateTime, getSize, } from '../helpers';
|
|
7
|
-
import { CalendarIcon, ClockIcon, SizeIcon } from './NetworkIcons';
|
|
7
|
+
import { CalendarIcon, ClockIcon, SizeIcon, GlobeIcon, CircleCheckIcon, CircleAlertIcon, CircleXIcon, RepeatIcon, } from './NetworkIcons';
|
|
8
8
|
import { AppFonts } from '../styles/AppFonts';
|
|
9
9
|
import styles from '../styles';
|
|
10
10
|
import HighlightText from './HighlightText';
|
|
@@ -59,6 +59,22 @@ const LogCard = React.memo(function LogCard({ item, onPress, timelineMinStart, t
|
|
|
59
59
|
}).start();
|
|
60
60
|
}
|
|
61
61
|
}, [isNew]);
|
|
62
|
+
const renderStatusIcon = () => {
|
|
63
|
+
if (isLoading) {
|
|
64
|
+
return <ClockIcon color={AppColors.darkOrange} size={9}/>;
|
|
65
|
+
}
|
|
66
|
+
const num = typeof item.status === 'number' ? item.status : parseInt(String(item.status || 0), 10);
|
|
67
|
+
if (num >= 200 && num < 300) {
|
|
68
|
+
return <CircleCheckIcon color={AppColors.greenColor} size={9}/>;
|
|
69
|
+
}
|
|
70
|
+
if (num >= 300 && num < 400) {
|
|
71
|
+
return <RepeatIcon color={AppColors.amber700} size={9}/>;
|
|
72
|
+
}
|
|
73
|
+
if (num >= 400 && num < 500) {
|
|
74
|
+
return <CircleAlertIcon color={AppColors.darkOrange} size={9}/>;
|
|
75
|
+
}
|
|
76
|
+
return <CircleXIcon color={AppColors.errorColor} size={9}/>;
|
|
77
|
+
};
|
|
62
78
|
const triggeredAt = formatDateTime(item.startTime);
|
|
63
79
|
const isJson = item.url.split('?')[0].toLowerCase().endsWith('.json');
|
|
64
80
|
return (<TouchableScale onPress={onPress} style={[
|
|
@@ -210,6 +226,9 @@ const LogCard = React.memo(function LogCard({ item, onPress, timelineMinStart, t
|
|
|
210
226
|
<View style={[
|
|
211
227
|
styles.statusPill,
|
|
212
228
|
{
|
|
229
|
+
flexDirection: 'row',
|
|
230
|
+
alignItems: 'center',
|
|
231
|
+
gap: 3.5,
|
|
213
232
|
backgroundColor: isFailed
|
|
214
233
|
? `${AppColors.errorColor}15`
|
|
215
234
|
: isLoading
|
|
@@ -222,6 +241,7 @@ const LogCard = React.memo(function LogCard({ item, onPress, timelineMinStart, t
|
|
|
222
241
|
: `${statusColor}30`,
|
|
223
242
|
},
|
|
224
243
|
]}>
|
|
244
|
+
{renderStatusIcon()}
|
|
225
245
|
<Text style={[
|
|
226
246
|
styles.statusPillText,
|
|
227
247
|
{
|
|
@@ -244,7 +264,17 @@ const LogCard = React.memo(function LogCard({ item, onPress, timelineMinStart, t
|
|
|
244
264
|
{/* Row 2: Full URL Capsule Container (Clickable with link prompt) */}
|
|
245
265
|
<View style={styles.cardSlugBox}>
|
|
246
266
|
<Pressable onPress={handleOpenUrl} style={styles.slugLeft} hitSlop={6}>
|
|
247
|
-
<
|
|
267
|
+
<View style={{
|
|
268
|
+
width: 17,
|
|
269
|
+
height: 17,
|
|
270
|
+
borderRadius: 4,
|
|
271
|
+
backgroundColor: `${AppColors.skyBlue}1A`,
|
|
272
|
+
alignItems: 'center',
|
|
273
|
+
justifyContent: 'center',
|
|
274
|
+
marginRight: 4,
|
|
275
|
+
}}>
|
|
276
|
+
<GlobeIcon color={AppColors.skyBlue} size={11}/>
|
|
277
|
+
</View>
|
|
248
278
|
<HighlightText text={item.url} search={searchStr} style={[styles.slugText, { color: AppColors.skyBlue, textDecorationLine: 'underline' }]} highlightStyle={styles.highlight} numberOfLines={2} ellipsizeMode="middle"/>
|
|
249
279
|
</Pressable>
|
|
250
280
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextStyle } from 'react-native';
|
|
3
|
+
export interface LogSyntaxHighlighterProps {
|
|
4
|
+
text: string;
|
|
5
|
+
search?: string;
|
|
6
|
+
numberOfLines?: number;
|
|
7
|
+
style?: TextStyle | TextStyle[];
|
|
8
|
+
detectLinks?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface Token {
|
|
11
|
+
type: 'key' | 'string' | 'number' | 'boolean' | 'null' | 'url' | 'bracket' | 'tag' | 'plain';
|
|
12
|
+
value: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const tokenizeText: (input: string) => Token[];
|
|
15
|
+
export declare const LogSyntaxHighlighter: React.FC<LogSyntaxHighlighterProps>;
|
|
16
|
+
export default LogSyntaxHighlighter;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, Text } from 'react-native';
|
|
3
|
+
import { AppColors } from '../styles/AppColors';
|
|
4
|
+
import { AppFonts } from '../styles/AppFonts';
|
|
5
|
+
import { escapeRegex, handleOpenExternalLink } from '../helpers';
|
|
6
|
+
const TOKEN_REGEX = /("(?:\\.|[^"\\])*"(?=\s*:))|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')|(\b-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b)|(\b(?:true|false)\b)|(\b(?:null|undefined|NaN)\b)|(https?:\/\/[^\s"',]+)|(\[[\w\s_-]+\])|([{}[\],:])|([^"'\d\s{}[\],:]+|[ \t\r\n]+)/g;
|
|
7
|
+
export const tokenizeText = (input) => {
|
|
8
|
+
if (!input)
|
|
9
|
+
return [];
|
|
10
|
+
const tokens = [];
|
|
11
|
+
let match;
|
|
12
|
+
TOKEN_REGEX.lastIndex = 0;
|
|
13
|
+
while ((match = TOKEN_REGEX.exec(input)) !== null) {
|
|
14
|
+
if (match[1]) {
|
|
15
|
+
tokens.push({ type: 'key', value: match[1] });
|
|
16
|
+
}
|
|
17
|
+
else if (match[2]) {
|
|
18
|
+
tokens.push({ type: 'string', value: match[2] });
|
|
19
|
+
}
|
|
20
|
+
else if (match[3]) {
|
|
21
|
+
tokens.push({ type: 'number', value: match[3] });
|
|
22
|
+
}
|
|
23
|
+
else if (match[4]) {
|
|
24
|
+
tokens.push({ type: 'boolean', value: match[4] });
|
|
25
|
+
}
|
|
26
|
+
else if (match[5]) {
|
|
27
|
+
tokens.push({ type: 'null', value: match[5] });
|
|
28
|
+
}
|
|
29
|
+
else if (match[6]) {
|
|
30
|
+
tokens.push({ type: 'url', value: match[6] });
|
|
31
|
+
}
|
|
32
|
+
else if (match[7]) {
|
|
33
|
+
tokens.push({ type: 'tag', value: match[7] });
|
|
34
|
+
}
|
|
35
|
+
else if (match[8]) {
|
|
36
|
+
tokens.push({ type: 'bracket', value: match[8] });
|
|
37
|
+
}
|
|
38
|
+
else if (match[9]) {
|
|
39
|
+
tokens.push({ type: 'plain', value: match[9] });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return tokens;
|
|
43
|
+
};
|
|
44
|
+
const getTokenColor = (type) => {
|
|
45
|
+
switch (type) {
|
|
46
|
+
case 'key':
|
|
47
|
+
return AppColors.sky600 || '#0369a1';
|
|
48
|
+
case 'string':
|
|
49
|
+
return AppColors.emerald600 || '#059669';
|
|
50
|
+
case 'number':
|
|
51
|
+
return AppColors.amber600 || '#d97706';
|
|
52
|
+
case 'boolean':
|
|
53
|
+
return AppColors.purple || '#7c3aed';
|
|
54
|
+
case 'null':
|
|
55
|
+
return AppColors.red600 || '#dc2626';
|
|
56
|
+
case 'url':
|
|
57
|
+
return '#0284c7';
|
|
58
|
+
case 'tag':
|
|
59
|
+
return AppColors.violet600 || '#7c3aed';
|
|
60
|
+
case 'bracket':
|
|
61
|
+
return AppColors.slate500 || '#64748b';
|
|
62
|
+
case 'plain':
|
|
63
|
+
default:
|
|
64
|
+
return AppColors.primaryBlack || '#1e293b';
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
export const LogSyntaxHighlighter = React.memo(({ text, search, numberOfLines, style, detectLinks = true }) => {
|
|
68
|
+
if (!text)
|
|
69
|
+
return null;
|
|
70
|
+
const tokens = React.useMemo(() => tokenizeText(text), [text]);
|
|
71
|
+
const renderToken = (token, tokenIdx) => {
|
|
72
|
+
const baseColor = getTokenColor(token.type);
|
|
73
|
+
const isUrl = token.type === 'url';
|
|
74
|
+
const isKey = token.type === 'key';
|
|
75
|
+
const tokenStyle = {
|
|
76
|
+
color: baseColor,
|
|
77
|
+
fontFamily: isKey ? AppFonts.interBold : AppFonts.interRegular,
|
|
78
|
+
textDecorationLine: isUrl ? 'underline' : 'none',
|
|
79
|
+
};
|
|
80
|
+
if (!search || search.trim().length === 0) {
|
|
81
|
+
return (<Text key={tokenIdx} style={tokenStyle} onPress={isUrl && detectLinks
|
|
82
|
+
? () => handleOpenExternalLink(token.value)
|
|
83
|
+
: undefined}>
|
|
84
|
+
{token.value}
|
|
85
|
+
</Text>);
|
|
86
|
+
}
|
|
87
|
+
const regex = new RegExp(`(${escapeRegex(search.trim())})`, 'gi');
|
|
88
|
+
const parts = token.value.split(regex);
|
|
89
|
+
return (<Text key={tokenIdx} style={tokenStyle}>
|
|
90
|
+
{parts.map((part, partIdx) => {
|
|
91
|
+
const isMatch = part.toLowerCase() === search.trim().toLowerCase();
|
|
92
|
+
return isMatch ? (<Text key={partIdx} style={[
|
|
93
|
+
tokenStyle,
|
|
94
|
+
styles.searchHighlight,
|
|
95
|
+
]}>
|
|
96
|
+
{part}
|
|
97
|
+
</Text>) : (<Text key={partIdx} style={tokenStyle} onPress={isUrl && detectLinks
|
|
98
|
+
? () => handleOpenExternalLink(token.value)
|
|
99
|
+
: undefined}>
|
|
100
|
+
{part}
|
|
101
|
+
</Text>);
|
|
102
|
+
})}
|
|
103
|
+
</Text>);
|
|
104
|
+
};
|
|
105
|
+
return (<Text style={[styles.containerText, style]} numberOfLines={numberOfLines}>
|
|
106
|
+
{tokens.map(renderToken)}
|
|
107
|
+
</Text>);
|
|
108
|
+
});
|
|
109
|
+
const styles = StyleSheet.create({
|
|
110
|
+
containerText: {
|
|
111
|
+
fontFamily: AppFonts.interRegular,
|
|
112
|
+
fontSize: 12,
|
|
113
|
+
lineHeight: 18,
|
|
114
|
+
color: AppColors.primaryBlack,
|
|
115
|
+
},
|
|
116
|
+
searchHighlight: {
|
|
117
|
+
backgroundColor: '#fef08a',
|
|
118
|
+
color: '#854d0e',
|
|
119
|
+
fontFamily: AppFonts.interBold,
|
|
120
|
+
borderRadius: 2,
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
export default LogSyntaxHighlighter;
|
|
@@ -125,3 +125,5 @@ export declare const AlertTriangleIcon: ({ color, size }: IconProps) => React.JS
|
|
|
125
125
|
export declare const BugIcon: ({ color, size }: IconProps) => React.JSX.Element;
|
|
126
126
|
export declare const TagIcon: ({ color, size }: IconProps) => React.JSX.Element;
|
|
127
127
|
export declare const NpmIcon: ({ color, size }: IconProps) => React.JSX.Element;
|
|
128
|
+
export declare const ResetIcon: ({ color, size }: IconProps) => React.JSX.Element;
|
|
129
|
+
export declare const ChevronDownIcon: ({ color, size }: IconProps) => React.JSX.Element;
|
|
@@ -704,3 +704,10 @@ export const NpmIcon = ({ color = '#CB3837', size = 14 }) => (<Svg width={size}
|
|
|
704
704
|
<Rect width="256" height="256" rx="32" fill={color}/>
|
|
705
705
|
<Path d="M48 48h160v160h-32V96h-32v112H48V48z" fill="#FFFFFF"/>
|
|
706
706
|
</Svg>);
|
|
707
|
+
export const ResetIcon = ({ color = AppColors.white, size = 16 }) => (<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
708
|
+
<Path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" stroke={color} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
709
|
+
<Path d="M3 3v5h5" stroke={color} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
710
|
+
</Svg>);
|
|
711
|
+
export const ChevronDownIcon = ({ color = AppColors.grayTextWeak, size = 14 }) => (<Svg width={size} height={size} viewBox="0 0 24 24" fill="none">
|
|
712
|
+
<Path d="M6 9l6 6 6-6" stroke={color} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
713
|
+
</Svg>);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface SliderProps {
|
|
3
|
+
value: number;
|
|
4
|
+
onValueChange: (value: number) => void;
|
|
5
|
+
min?: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
step?: number;
|
|
8
|
+
formatLabel?: (value: number) => string;
|
|
9
|
+
quickPresets?: number[];
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const Slider: React.FC<SliderProps>;
|
|
13
|
+
export default Slider;
|