rn-backstage 1.2.0 → 1.2.1
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 +2 -0
- package/lib/commonjs/Backstage.js +40 -33
- package/lib/commonjs/Backstage.js.map +1 -1
- package/lib/commonjs/ThemeContext.js +43 -0
- package/lib/commonjs/ThemeContext.js.map +1 -0
- package/lib/commonjs/components/BackstagePanel.js +17 -10
- package/lib/commonjs/components/BackstagePanel.js.map +1 -1
- package/lib/commonjs/components/FlagsTab.js +50 -49
- package/lib/commonjs/components/FlagsTab.js.map +1 -1
- package/lib/commonjs/components/FloatingPill.js +4 -2
- package/lib/commonjs/components/FloatingPill.js.map +1 -1
- package/lib/commonjs/components/InfoTab.js +73 -107
- package/lib/commonjs/components/InfoTab.js.map +1 -1
- package/lib/commonjs/components/JsonTreeView.js +39 -34
- package/lib/commonjs/components/JsonTreeView.js.map +1 -1
- package/lib/commonjs/components/LogItem.js +33 -29
- package/lib/commonjs/components/LogItem.js.map +1 -1
- package/lib/commonjs/components/LogsTab.js +37 -42
- package/lib/commonjs/components/LogsTab.js.map +1 -1
- package/lib/commonjs/components/NetworkItem.js +111 -135
- package/lib/commonjs/components/NetworkItem.js.map +1 -1
- package/lib/commonjs/components/NetworkTab.js +48 -49
- package/lib/commonjs/components/NetworkTab.js.map +1 -1
- package/lib/commonjs/components/TabBar.js +8 -5
- package/lib/commonjs/components/TabBar.js.map +1 -1
- package/lib/commonjs/constants.js +24 -1
- package/lib/commonjs/constants.js.map +1 -1
- package/lib/commonjs/index.js +19 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/Backstage.js +40 -33
- package/lib/module/Backstage.js.map +1 -1
- package/lib/module/ThemeContext.js +37 -0
- package/lib/module/ThemeContext.js.map +1 -0
- package/lib/module/components/BackstagePanel.js +19 -12
- package/lib/module/components/BackstagePanel.js.map +1 -1
- package/lib/module/components/FlagsTab.js +51 -50
- package/lib/module/components/FlagsTab.js.map +1 -1
- package/lib/module/components/FloatingPill.js +5 -3
- package/lib/module/components/FloatingPill.js.map +1 -1
- package/lib/module/components/InfoTab.js +73 -107
- package/lib/module/components/InfoTab.js.map +1 -1
- package/lib/module/components/JsonTreeView.js +42 -38
- package/lib/module/components/JsonTreeView.js.map +1 -1
- package/lib/module/components/LogItem.js +35 -31
- package/lib/module/components/LogItem.js.map +1 -1
- package/lib/module/components/LogsTab.js +38 -43
- package/lib/module/components/LogsTab.js.map +1 -1
- package/lib/module/components/NetworkItem.js +113 -137
- package/lib/module/components/NetworkItem.js.map +1 -1
- package/lib/module/components/NetworkTab.js +49 -50
- package/lib/module/components/NetworkTab.js.map +1 -1
- package/lib/module/components/TabBar.js +10 -7
- package/lib/module/components/TabBar.js.map +1 -1
- package/lib/module/constants.js +23 -0
- package/lib/module/constants.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/Backstage.d.ts.map +1 -1
- package/lib/typescript/ThemeContext.d.ts +11 -0
- package/lib/typescript/ThemeContext.d.ts.map +1 -0
- package/lib/typescript/components/BackstagePanel.d.ts +1 -0
- package/lib/typescript/components/BackstagePanel.d.ts.map +1 -1
- package/lib/typescript/components/FlagsTab.d.ts.map +1 -1
- package/lib/typescript/components/FloatingPill.d.ts.map +1 -1
- package/lib/typescript/components/InfoTab.d.ts +1 -0
- package/lib/typescript/components/InfoTab.d.ts.map +1 -1
- package/lib/typescript/components/JsonTreeView.d.ts.map +1 -1
- package/lib/typescript/components/LogItem.d.ts +1 -0
- package/lib/typescript/components/LogItem.d.ts.map +1 -1
- package/lib/typescript/components/LogsTab.d.ts +1 -0
- package/lib/typescript/components/LogsTab.d.ts.map +1 -1
- package/lib/typescript/components/NetworkItem.d.ts +1 -0
- package/lib/typescript/components/NetworkItem.d.ts.map +1 -1
- package/lib/typescript/components/NetworkTab.d.ts +1 -0
- package/lib/typescript/components/NetworkTab.d.ts.map +1 -1
- package/lib/typescript/components/TabBar.d.ts.map +1 -1
- package/lib/typescript/constants.d.ts +1 -0
- package/lib/typescript/constants.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +4 -0
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Backstage.tsx +39 -33
- package/src/ThemeContext.tsx +38 -0
- package/src/components/BackstagePanel.tsx +66 -57
- package/src/components/FlagsTab.tsx +123 -174
- package/src/components/FloatingPill.tsx +6 -3
- package/src/components/InfoTab.tsx +152 -186
- package/src/components/JsonTreeView.tsx +53 -73
- package/src/components/LogItem.tsx +55 -100
- package/src/components/LogsTab.tsx +110 -132
- package/src/components/NetworkItem.tsx +306 -417
- package/src/components/NetworkTab.tsx +129 -163
- package/src/components/TabBar.tsx +51 -47
- package/src/constants.ts +23 -0
- package/src/index.ts +2 -0
- package/src/types.ts +6 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, { useCallback, useState } from 'react'
|
|
1
|
+
import React, { useCallback, useMemo, useState } from 'react'
|
|
2
2
|
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'
|
|
3
|
-
import {
|
|
3
|
+
import { MonospaceFont } from '../constants'
|
|
4
|
+
import { useBackstageTheme } from '../ThemeContext'
|
|
4
5
|
import { NetworkState } from '../types'
|
|
5
|
-
import type { NetworkEntry } from '../types'
|
|
6
|
+
import type { NetworkEntry, BackstageTheme } from '../types'
|
|
6
7
|
import { formatTimestamp } from '../utils/formatTimestamp'
|
|
7
8
|
import { JsonTreeView } from './JsonTreeView'
|
|
8
9
|
import { toCurl } from '../network-interceptor'
|
|
@@ -12,32 +13,20 @@ import { toCurl } from '../network-interceptor'
|
|
|
12
13
|
interface NetworkItemProps {
|
|
13
14
|
item: NetworkEntry
|
|
14
15
|
onCopy?: (text: string) => void
|
|
16
|
+
jsonMaxDepth?: number
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
// ─── Status Badge Config ─────────────────────────────────────────────────────
|
|
18
20
|
|
|
19
|
-
function getStatusConfig(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
rowBg: string
|
|
24
|
-
} {
|
|
21
|
+
function getStatusConfig(
|
|
22
|
+
entry: NetworkEntry,
|
|
23
|
+
t: BackstageTheme,
|
|
24
|
+
): { label: string; color: string; bgColor: string; rowBg: string } {
|
|
25
25
|
if (entry.state === NetworkState.pending) {
|
|
26
|
-
return {
|
|
27
|
-
label: '…',
|
|
28
|
-
color: DarkTheme.warning,
|
|
29
|
-
bgColor: DarkTheme.warningDim,
|
|
30
|
-
rowBg: 'transparent',
|
|
31
|
-
}
|
|
26
|
+
return { label: '…', color: t.warning, bgColor: t.warningDim, rowBg: 'transparent' }
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
if (entry.state === NetworkState.error) {
|
|
35
|
-
return {
|
|
36
|
-
label: 'ERR',
|
|
37
|
-
color: DarkTheme.error,
|
|
38
|
-
bgColor: DarkTheme.errorDim,
|
|
39
|
-
rowBg: 'rgba(255, 77, 106, 0.06)',
|
|
40
|
-
}
|
|
29
|
+
return { label: 'ERR', color: t.error, bgColor: t.errorDim, rowBg: 'rgba(255, 77, 106, 0.06)' }
|
|
41
30
|
}
|
|
42
31
|
|
|
43
32
|
const status = entry.status ?? 0
|
|
@@ -45,54 +34,46 @@ function getStatusConfig(entry: NetworkEntry): {
|
|
|
45
34
|
if (status >= 200 && status < 300) {
|
|
46
35
|
return {
|
|
47
36
|
label: String(status),
|
|
48
|
-
color:
|
|
37
|
+
color: t.success,
|
|
49
38
|
bgColor: 'rgba(52, 211, 153, 0.12)',
|
|
50
39
|
rowBg: 'transparent',
|
|
51
40
|
}
|
|
52
41
|
}
|
|
53
|
-
|
|
54
42
|
if (status >= 300 && status < 400) {
|
|
55
|
-
return {
|
|
56
|
-
label: String(status),
|
|
57
|
-
color: DarkTheme.info,
|
|
58
|
-
bgColor: DarkTheme.infoDim,
|
|
59
|
-
rowBg: 'transparent',
|
|
60
|
-
}
|
|
43
|
+
return { label: String(status), color: t.info, bgColor: t.infoDim, rowBg: 'transparent' }
|
|
61
44
|
}
|
|
62
|
-
|
|
63
45
|
if (status >= 400 && status < 500) {
|
|
64
46
|
return {
|
|
65
47
|
label: String(status),
|
|
66
|
-
color:
|
|
67
|
-
bgColor:
|
|
48
|
+
color: t.warning,
|
|
49
|
+
bgColor: t.warningDim,
|
|
68
50
|
rowBg: 'rgba(255, 178, 36, 0.06)',
|
|
69
51
|
}
|
|
70
52
|
}
|
|
71
|
-
|
|
72
53
|
// 5xx
|
|
73
54
|
return {
|
|
74
55
|
label: String(status),
|
|
75
|
-
color:
|
|
76
|
-
bgColor:
|
|
56
|
+
color: t.error,
|
|
57
|
+
bgColor: t.errorDim,
|
|
77
58
|
rowBg: 'rgba(255, 77, 106, 0.06)',
|
|
78
59
|
}
|
|
79
60
|
}
|
|
80
61
|
|
|
81
62
|
// ─── Method Badge Colors ─────────────────────────────────────────────────────
|
|
82
63
|
|
|
83
|
-
function getMethodColor(method: string): string {
|
|
64
|
+
function getMethodColor(method: string, t: BackstageTheme): string {
|
|
84
65
|
switch (method) {
|
|
85
66
|
case 'GET':
|
|
86
|
-
return
|
|
67
|
+
return t.success
|
|
87
68
|
case 'POST':
|
|
88
|
-
return
|
|
69
|
+
return t.info
|
|
89
70
|
case 'PUT':
|
|
90
71
|
case 'PATCH':
|
|
91
|
-
return
|
|
72
|
+
return t.warning
|
|
92
73
|
case 'DELETE':
|
|
93
|
-
return
|
|
74
|
+
return t.error
|
|
94
75
|
default:
|
|
95
|
-
return
|
|
76
|
+
return t.textSecondary
|
|
96
77
|
}
|
|
97
78
|
}
|
|
98
79
|
|
|
@@ -144,393 +125,301 @@ function tryParseJSON(text?: string): unknown | null {
|
|
|
144
125
|
|
|
145
126
|
// ─── Component ───────────────────────────────────────────────────────────────
|
|
146
127
|
|
|
147
|
-
export const NetworkItem: React.FC<NetworkItemProps> = React.memo(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
128
|
+
export const NetworkItem: React.FC<NetworkItemProps> = React.memo(
|
|
129
|
+
({ item, onCopy, jsonMaxDepth }) => {
|
|
130
|
+
const theme = useBackstageTheme()
|
|
131
|
+
const s = useMemo(() => createStyles(theme), [theme])
|
|
132
|
+
const [expanded, setExpanded] = useState(false)
|
|
133
|
+
const [detailSection, setDetailSection] = useState<'general' | 'request' | 'response'>(
|
|
134
|
+
'general',
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
const config = getStatusConfig(item, theme)
|
|
138
|
+
const methodColor = getMethodColor(item.method, theme)
|
|
139
|
+
const isPending = item.state === NetworkState.pending
|
|
140
|
+
|
|
141
|
+
const toggleExpand = useCallback(() => {
|
|
142
|
+
setExpanded(prev => !prev)
|
|
143
|
+
}, [])
|
|
144
|
+
|
|
145
|
+
const handleCopyCurl = useCallback(() => {
|
|
146
|
+
if (onCopy) {
|
|
147
|
+
onCopy(toCurl(item))
|
|
148
|
+
}
|
|
149
|
+
}, [item, onCopy])
|
|
150
|
+
|
|
151
|
+
// ─── Detail Row (inline) ─────────────────────────────────
|
|
152
|
+
const renderDetailRow = (
|
|
153
|
+
label: string,
|
|
154
|
+
value: string,
|
|
155
|
+
selectable?: boolean,
|
|
156
|
+
isError?: boolean,
|
|
157
|
+
) => (
|
|
158
|
+
<View style={s.detailRow}>
|
|
159
|
+
<Text style={s.detailLabel}>{label}</Text>
|
|
160
|
+
<Text
|
|
161
|
+
style={[s.detailValue, isError && { color: theme.error }]}
|
|
162
|
+
numberOfLines={3}
|
|
163
|
+
selectable={selectable}
|
|
164
|
+
>
|
|
165
|
+
{value}
|
|
166
|
+
</Text>
|
|
167
|
+
</View>
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<TouchableOpacity
|
|
172
|
+
style={[s.container, { backgroundColor: config.rowBg }]}
|
|
173
|
+
onPress={toggleExpand}
|
|
174
|
+
onLongPress={handleCopyCurl}
|
|
175
|
+
activeOpacity={0.7}
|
|
176
|
+
>
|
|
177
|
+
{/* ── Collapsed Row ─────────────────────────────────────── */}
|
|
178
|
+
<View style={s.headerRow}>
|
|
179
|
+
<View style={[s.methodBadge, { borderColor: methodColor }]}>
|
|
180
|
+
<Text style={[s.methodText, { color: methodColor }]}>{item.method}</Text>
|
|
181
|
+
</View>
|
|
182
|
+
<View style={[s.statusBadge, { backgroundColor: config.bgColor }]}>
|
|
183
|
+
<Text style={[s.statusText, { color: config.color }]}>{config.label}</Text>
|
|
184
|
+
</View>
|
|
185
|
+
{!isPending && <Text style={s.duration}>{formatDuration(item.duration)}</Text>}
|
|
186
|
+
{isPending && <Text style={[s.duration, { color: theme.warning }]}>pending</Text>}
|
|
187
|
+
{item.responseSize !== undefined && (
|
|
188
|
+
<Text style={s.size}>{formatSize(item.responseSize)}</Text>
|
|
189
|
+
)}
|
|
190
|
+
<Text style={s.timestamp}>{formatTimestamp(item.startTime)}</Text>
|
|
182
191
|
</View>
|
|
183
192
|
|
|
184
|
-
{
|
|
185
|
-
|
|
186
|
-
|
|
193
|
+
<Text style={s.path} numberOfLines={expanded ? undefined : 1}>
|
|
194
|
+
{extractPath(item.url)}
|
|
195
|
+
</Text>
|
|
196
|
+
<Text style={s.host} numberOfLines={1}>
|
|
197
|
+
{extractHost(item.url)}
|
|
198
|
+
</Text>
|
|
187
199
|
|
|
188
|
-
{
|
|
189
|
-
|
|
190
|
-
|
|
200
|
+
{item.error && (
|
|
201
|
+
<Text style={s.errorText} numberOfLines={expanded ? undefined : 1}>
|
|
202
|
+
✕ {item.error}
|
|
203
|
+
</Text>
|
|
191
204
|
)}
|
|
192
205
|
|
|
193
|
-
{/*
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
{extractHost(item.url)}
|
|
203
|
-
</Text>
|
|
204
|
-
|
|
205
|
-
{/* Error message */}
|
|
206
|
-
{item.error && (
|
|
207
|
-
<Text style={styles.errorText} numberOfLines={expanded ? undefined : 1}>
|
|
208
|
-
✕ {item.error}
|
|
209
|
-
</Text>
|
|
210
|
-
)}
|
|
211
|
-
|
|
212
|
-
{/* ── Expanded Detail ───────────────────────────────────── */}
|
|
213
|
-
{expanded && (
|
|
214
|
-
<View style={styles.detailContainer}>
|
|
215
|
-
{/* Section tabs */}
|
|
216
|
-
<View style={styles.sectionTabs}>
|
|
217
|
-
{(['general', 'request', 'response'] as const).map(section => (
|
|
218
|
-
<TouchableOpacity
|
|
219
|
-
key={section}
|
|
220
|
-
style={[styles.sectionTab, detailSection === section && styles.sectionTabActive]}
|
|
221
|
-
onPress={() => setDetailSection(section)}
|
|
222
|
-
>
|
|
223
|
-
<Text
|
|
224
|
-
style={[
|
|
225
|
-
styles.sectionTabText,
|
|
226
|
-
detailSection === section && styles.sectionTabTextActive,
|
|
227
|
-
]}
|
|
206
|
+
{/* ── Expanded Detail ───────────────────────────────────── */}
|
|
207
|
+
{expanded && (
|
|
208
|
+
<View style={s.detailContainer}>
|
|
209
|
+
<View style={s.sectionTabs}>
|
|
210
|
+
{(['general', 'request', 'response'] as const).map(section => (
|
|
211
|
+
<TouchableOpacity
|
|
212
|
+
key={section}
|
|
213
|
+
style={[s.sectionTab, detailSection === section && s.sectionTabActive]}
|
|
214
|
+
onPress={() => setDetailSection(section)}
|
|
228
215
|
>
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
{detailSection === 'general' && (
|
|
237
|
-
<View style={styles.sectionContent}>
|
|
238
|
-
<DetailRow label="Method" value={item.method} />
|
|
239
|
-
<DetailRow label="URL" value={item.url} selectable />
|
|
240
|
-
<DetailRow
|
|
241
|
-
label="Status"
|
|
242
|
-
value={item.status ? `${item.status} ${item.statusText || ''}` : '—'}
|
|
243
|
-
/>
|
|
244
|
-
<DetailRow label="Duration" value={formatDuration(item.duration)} />
|
|
245
|
-
{item.responseSize !== undefined && (
|
|
246
|
-
<DetailRow label="Size" value={formatSize(item.responseSize)} />
|
|
247
|
-
)}
|
|
248
|
-
{item.error && <DetailRow label="Error" value={item.error} isError />}
|
|
216
|
+
<Text
|
|
217
|
+
style={[s.sectionTabText, detailSection === section && s.sectionTabTextActive]}
|
|
218
|
+
>
|
|
219
|
+
{section.charAt(0).toUpperCase() + section.slice(1)}
|
|
220
|
+
</Text>
|
|
221
|
+
</TouchableOpacity>
|
|
222
|
+
))}
|
|
249
223
|
</View>
|
|
250
|
-
)}
|
|
251
224
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
225
|
+
{detailSection === 'general' && (
|
|
226
|
+
<View style={s.sectionContent}>
|
|
227
|
+
{renderDetailRow('Method', item.method)}
|
|
228
|
+
{renderDetailRow('URL', item.url, true)}
|
|
229
|
+
{renderDetailRow(
|
|
230
|
+
'Status',
|
|
231
|
+
item.status ? `${item.status} ${item.statusText || ''}` : '—',
|
|
232
|
+
)}
|
|
233
|
+
{renderDetailRow('Duration', formatDuration(item.duration))}
|
|
234
|
+
{item.responseSize !== undefined &&
|
|
235
|
+
renderDetailRow('Size', formatSize(item.responseSize))}
|
|
236
|
+
{item.error && renderDetailRow('Error', item.error, false, true)}
|
|
237
|
+
</View>
|
|
238
|
+
)}
|
|
239
|
+
|
|
240
|
+
{detailSection === 'request' && (
|
|
241
|
+
<View style={s.sectionContent}>
|
|
242
|
+
{item.requestHeaders && Object.keys(item.requestHeaders).length > 0 ? (
|
|
243
|
+
<>
|
|
244
|
+
<Text style={s.subsectionTitle}>HEADERS</Text>
|
|
245
|
+
<View style={s.jsonContainer}>
|
|
246
|
+
<JsonTreeView data={item.requestHeaders} hideRoot maxDepth={jsonMaxDepth} />
|
|
270
247
|
</View>
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
248
|
+
</>
|
|
249
|
+
) : (
|
|
250
|
+
<Text style={s.emptyNote}>No request headers captured</Text>
|
|
251
|
+
)}
|
|
252
|
+
{item.requestBody ? (
|
|
253
|
+
<>
|
|
254
|
+
<Text style={s.subsectionTitle}>BODY</Text>
|
|
255
|
+
{tryParseJSON(item.requestBody) ? (
|
|
256
|
+
<View style={s.jsonContainer}>
|
|
257
|
+
<JsonTreeView
|
|
258
|
+
data={tryParseJSON(item.requestBody)}
|
|
259
|
+
hideRoot
|
|
260
|
+
maxDepth={jsonMaxDepth}
|
|
261
|
+
/>
|
|
262
|
+
</View>
|
|
263
|
+
) : (
|
|
264
|
+
<Text style={s.bodyText} selectable>
|
|
265
|
+
{item.requestBody}
|
|
266
|
+
</Text>
|
|
267
|
+
)}
|
|
268
|
+
</>
|
|
269
|
+
) : null}
|
|
270
|
+
</View>
|
|
271
|
+
)}
|
|
272
|
+
|
|
273
|
+
{detailSection === 'response' && (
|
|
274
|
+
<View style={s.sectionContent}>
|
|
275
|
+
{item.responseHeaders && Object.keys(item.responseHeaders).length > 0 ? (
|
|
276
|
+
<>
|
|
277
|
+
<Text style={s.subsectionTitle}>HEADERS</Text>
|
|
278
|
+
<View style={s.jsonContainer}>
|
|
279
|
+
<JsonTreeView data={item.responseHeaders} hideRoot maxDepth={jsonMaxDepth} />
|
|
299
280
|
</View>
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
281
|
+
</>
|
|
282
|
+
) : (
|
|
283
|
+
<Text style={s.emptyNote}>No response headers captured</Text>
|
|
284
|
+
)}
|
|
285
|
+
{item.responseBody ? (
|
|
286
|
+
<>
|
|
287
|
+
<Text style={s.subsectionTitle}>BODY</Text>
|
|
288
|
+
{tryParseJSON(item.responseBody) ? (
|
|
289
|
+
<View style={s.jsonContainer}>
|
|
290
|
+
<JsonTreeView
|
|
291
|
+
data={tryParseJSON(item.responseBody)}
|
|
292
|
+
hideRoot
|
|
293
|
+
maxDepth={jsonMaxDepth}
|
|
294
|
+
/>
|
|
295
|
+
</View>
|
|
296
|
+
) : (
|
|
297
|
+
<Text style={s.bodyText} selectable>
|
|
298
|
+
{item.responseBody}
|
|
299
|
+
</Text>
|
|
300
|
+
)}
|
|
301
|
+
</>
|
|
302
|
+
) : (
|
|
303
|
+
<Text style={s.emptyNote}>
|
|
304
|
+
{isPending ? 'Awaiting response…' : 'No response body'}
|
|
305
|
+
</Text>
|
|
306
|
+
)}
|
|
307
|
+
</View>
|
|
308
|
+
)}
|
|
309
|
+
|
|
310
|
+
{onCopy && (
|
|
311
|
+
<TouchableOpacity style={s.curlButton} onPress={handleCopyCurl} activeOpacity={0.7}>
|
|
312
|
+
<Text style={s.curlButtonText}>⧉ Copy as cURL</Text>
|
|
313
|
+
</TouchableOpacity>
|
|
314
|
+
)}
|
|
315
|
+
</View>
|
|
316
|
+
)}
|
|
313
317
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
onPress={handleCopyCurl}
|
|
319
|
-
activeOpacity={0.7}
|
|
320
|
-
>
|
|
321
|
-
<Text style={styles.curlButtonText}>⧉ Copy as cURL</Text>
|
|
322
|
-
</TouchableOpacity>
|
|
323
|
-
)}
|
|
324
|
-
</View>
|
|
325
|
-
)}
|
|
326
|
-
|
|
327
|
-
{/* Expand hint */}
|
|
328
|
-
{!expanded && <Text style={styles.expandHint}>tap to inspect ▾</Text>}
|
|
329
|
-
</TouchableOpacity>
|
|
330
|
-
)
|
|
331
|
-
})
|
|
332
|
-
|
|
333
|
-
// ─── Detail Row ──────────────────────────────────────────────────────────────
|
|
334
|
-
|
|
335
|
-
const DetailRow: React.FC<{
|
|
336
|
-
label: string
|
|
337
|
-
value: string
|
|
338
|
-
selectable?: boolean
|
|
339
|
-
isError?: boolean
|
|
340
|
-
}> = ({ label, value, selectable, isError }) => (
|
|
341
|
-
<View style={styles.detailRow}>
|
|
342
|
-
<Text style={styles.detailLabel}>{label}</Text>
|
|
343
|
-
<Text
|
|
344
|
-
style={[styles.detailValue, isError && { color: DarkTheme.error }]}
|
|
345
|
-
numberOfLines={3}
|
|
346
|
-
selectable={selectable}
|
|
347
|
-
>
|
|
348
|
-
{value}
|
|
349
|
-
</Text>
|
|
350
|
-
</View>
|
|
318
|
+
{!expanded && <Text style={s.expandHint}>tap to inspect ▾</Text>}
|
|
319
|
+
</TouchableOpacity>
|
|
320
|
+
)
|
|
321
|
+
},
|
|
351
322
|
)
|
|
352
323
|
|
|
353
324
|
// ─── Styles ──────────────────────────────────────────────────────────────────
|
|
354
325
|
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
flexDirection: 'row',
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
borderColor: DarkTheme.accent,
|
|
456
|
-
},
|
|
457
|
-
sectionTabText: {
|
|
458
|
-
fontFamily: MonospaceFont,
|
|
459
|
-
fontSize: 11,
|
|
460
|
-
fontWeight: '600',
|
|
461
|
-
color: DarkTheme.textMuted,
|
|
462
|
-
},
|
|
463
|
-
sectionTabTextActive: {
|
|
464
|
-
color: DarkTheme.accent,
|
|
465
|
-
},
|
|
466
|
-
sectionContent: {
|
|
467
|
-
marginBottom: 8,
|
|
468
|
-
},
|
|
469
|
-
subsectionTitle: {
|
|
470
|
-
fontFamily: MonospaceFont,
|
|
471
|
-
fontSize: 10,
|
|
472
|
-
fontWeight: '700',
|
|
473
|
-
color: DarkTheme.textMuted,
|
|
474
|
-
letterSpacing: 1.2,
|
|
475
|
-
marginBottom: 6,
|
|
476
|
-
marginTop: 8,
|
|
477
|
-
},
|
|
478
|
-
jsonContainer: {
|
|
479
|
-
backgroundColor: DarkTheme.surfaceElevated,
|
|
480
|
-
borderRadius: 8,
|
|
481
|
-
borderWidth: 1,
|
|
482
|
-
borderColor: DarkTheme.border,
|
|
483
|
-
padding: 8,
|
|
484
|
-
},
|
|
485
|
-
bodyText: {
|
|
486
|
-
fontFamily: MonospaceFont,
|
|
487
|
-
fontSize: 11,
|
|
488
|
-
color: DarkTheme.text,
|
|
489
|
-
lineHeight: 16,
|
|
490
|
-
backgroundColor: DarkTheme.surfaceElevated,
|
|
491
|
-
borderRadius: 8,
|
|
492
|
-
borderWidth: 1,
|
|
493
|
-
borderColor: DarkTheme.border,
|
|
494
|
-
padding: 8,
|
|
495
|
-
overflow: 'hidden',
|
|
496
|
-
},
|
|
497
|
-
emptyNote: {
|
|
498
|
-
fontFamily: MonospaceFont,
|
|
499
|
-
fontSize: 11,
|
|
500
|
-
color: DarkTheme.textMuted,
|
|
501
|
-
fontStyle: 'italic',
|
|
502
|
-
paddingVertical: 8,
|
|
503
|
-
},
|
|
504
|
-
detailRow: {
|
|
505
|
-
flexDirection: 'row',
|
|
506
|
-
paddingVertical: 4,
|
|
507
|
-
},
|
|
508
|
-
detailLabel: {
|
|
509
|
-
fontFamily: MonospaceFont,
|
|
510
|
-
fontSize: 11,
|
|
511
|
-
color: DarkTheme.textMuted,
|
|
512
|
-
width: 70,
|
|
513
|
-
},
|
|
514
|
-
detailValue: {
|
|
515
|
-
fontFamily: MonospaceFont,
|
|
516
|
-
fontSize: 11,
|
|
517
|
-
color: DarkTheme.text,
|
|
518
|
-
flex: 1,
|
|
519
|
-
},
|
|
520
|
-
curlButton: {
|
|
521
|
-
marginTop: 10,
|
|
522
|
-
backgroundColor: DarkTheme.accentDim,
|
|
523
|
-
borderRadius: 8,
|
|
524
|
-
borderWidth: 1,
|
|
525
|
-
borderColor: DarkTheme.accent,
|
|
526
|
-
paddingVertical: 8,
|
|
527
|
-
paddingHorizontal: 14,
|
|
528
|
-
alignSelf: 'flex-start',
|
|
529
|
-
},
|
|
530
|
-
curlButtonText: {
|
|
531
|
-
fontFamily: MonospaceFont,
|
|
532
|
-
fontSize: 12,
|
|
533
|
-
fontWeight: '700',
|
|
534
|
-
color: DarkTheme.accent,
|
|
535
|
-
},
|
|
536
|
-
})
|
|
326
|
+
const createStyles = (t: BackstageTheme) =>
|
|
327
|
+
StyleSheet.create({
|
|
328
|
+
container: {
|
|
329
|
+
paddingHorizontal: 14,
|
|
330
|
+
paddingVertical: 10,
|
|
331
|
+
borderBottomWidth: 1,
|
|
332
|
+
borderBottomColor: t.border,
|
|
333
|
+
},
|
|
334
|
+
headerRow: { flexDirection: 'row', alignItems: 'center', marginBottom: 4, gap: 6 },
|
|
335
|
+
methodBadge: { borderRadius: 4, borderWidth: 1, paddingHorizontal: 6, paddingVertical: 1 },
|
|
336
|
+
methodText: { fontFamily: MonospaceFont, fontSize: 10, fontWeight: '800', letterSpacing: 0.5 },
|
|
337
|
+
statusBadge: { borderRadius: 4, paddingHorizontal: 6, paddingVertical: 2 },
|
|
338
|
+
statusText: { fontFamily: MonospaceFont, fontSize: 10, fontWeight: '800', letterSpacing: 0.5 },
|
|
339
|
+
duration: { fontFamily: MonospaceFont, fontSize: 11, color: t.textMuted },
|
|
340
|
+
size: { fontFamily: MonospaceFont, fontSize: 10, color: t.textMuted, opacity: 0.7 },
|
|
341
|
+
timestamp: { fontFamily: MonospaceFont, fontSize: 10, color: t.textMuted, marginLeft: 'auto' },
|
|
342
|
+
path: { fontFamily: MonospaceFont, fontSize: 12, color: t.text, lineHeight: 18 },
|
|
343
|
+
host: { fontFamily: MonospaceFont, fontSize: 10, color: t.textMuted, marginTop: 1 },
|
|
344
|
+
errorText: { fontFamily: MonospaceFont, fontSize: 11, color: t.error, marginTop: 4 },
|
|
345
|
+
expandHint: {
|
|
346
|
+
fontFamily: MonospaceFont,
|
|
347
|
+
fontSize: 10,
|
|
348
|
+
color: t.textMuted,
|
|
349
|
+
marginTop: 4,
|
|
350
|
+
fontStyle: 'italic',
|
|
351
|
+
},
|
|
352
|
+
detailContainer: {
|
|
353
|
+
marginTop: 10,
|
|
354
|
+
paddingTop: 10,
|
|
355
|
+
borderTopWidth: 1,
|
|
356
|
+
borderTopColor: t.border,
|
|
357
|
+
},
|
|
358
|
+
sectionTabs: { flexDirection: 'row', gap: 4, marginBottom: 10 },
|
|
359
|
+
sectionTab: {
|
|
360
|
+
paddingHorizontal: 12,
|
|
361
|
+
paddingVertical: 6,
|
|
362
|
+
borderRadius: 6,
|
|
363
|
+
backgroundColor: t.surfaceElevated,
|
|
364
|
+
borderWidth: 1,
|
|
365
|
+
borderColor: t.border,
|
|
366
|
+
},
|
|
367
|
+
sectionTabActive: { backgroundColor: t.accentDim, borderColor: t.accent },
|
|
368
|
+
sectionTabText: {
|
|
369
|
+
fontFamily: MonospaceFont,
|
|
370
|
+
fontSize: 11,
|
|
371
|
+
fontWeight: '600',
|
|
372
|
+
color: t.textMuted,
|
|
373
|
+
},
|
|
374
|
+
sectionTabTextActive: { color: t.accent },
|
|
375
|
+
sectionContent: { marginBottom: 8 },
|
|
376
|
+
subsectionTitle: {
|
|
377
|
+
fontFamily: MonospaceFont,
|
|
378
|
+
fontSize: 10,
|
|
379
|
+
fontWeight: '700',
|
|
380
|
+
color: t.textMuted,
|
|
381
|
+
letterSpacing: 1.2,
|
|
382
|
+
marginBottom: 6,
|
|
383
|
+
marginTop: 8,
|
|
384
|
+
},
|
|
385
|
+
jsonContainer: {
|
|
386
|
+
backgroundColor: t.surfaceElevated,
|
|
387
|
+
borderRadius: 8,
|
|
388
|
+
borderWidth: 1,
|
|
389
|
+
borderColor: t.border,
|
|
390
|
+
padding: 8,
|
|
391
|
+
},
|
|
392
|
+
bodyText: {
|
|
393
|
+
fontFamily: MonospaceFont,
|
|
394
|
+
fontSize: 11,
|
|
395
|
+
color: t.text,
|
|
396
|
+
lineHeight: 16,
|
|
397
|
+
backgroundColor: t.surfaceElevated,
|
|
398
|
+
borderRadius: 8,
|
|
399
|
+
borderWidth: 1,
|
|
400
|
+
borderColor: t.border,
|
|
401
|
+
padding: 8,
|
|
402
|
+
overflow: 'hidden',
|
|
403
|
+
},
|
|
404
|
+
emptyNote: {
|
|
405
|
+
fontFamily: MonospaceFont,
|
|
406
|
+
fontSize: 11,
|
|
407
|
+
color: t.textMuted,
|
|
408
|
+
fontStyle: 'italic',
|
|
409
|
+
paddingVertical: 8,
|
|
410
|
+
},
|
|
411
|
+
detailRow: { flexDirection: 'row', paddingVertical: 4 },
|
|
412
|
+
detailLabel: { fontFamily: MonospaceFont, fontSize: 11, color: t.textMuted, width: 70 },
|
|
413
|
+
detailValue: { fontFamily: MonospaceFont, fontSize: 11, color: t.text, flex: 1 },
|
|
414
|
+
curlButton: {
|
|
415
|
+
marginTop: 10,
|
|
416
|
+
backgroundColor: t.accentDim,
|
|
417
|
+
borderRadius: 8,
|
|
418
|
+
borderWidth: 1,
|
|
419
|
+
borderColor: t.accent,
|
|
420
|
+
paddingVertical: 8,
|
|
421
|
+
paddingHorizontal: 14,
|
|
422
|
+
alignSelf: 'flex-start',
|
|
423
|
+
},
|
|
424
|
+
curlButtonText: { fontFamily: MonospaceFont, fontSize: 12, fontWeight: '700', color: t.accent },
|
|
425
|
+
})
|