app-devtools 0.1.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/.eslintignore +3 -0
- package/.eslintrc.cjs +112 -0
- package/.gitattributes +22 -0
- package/.prettierrc +10 -0
- package/.quokka.ts +115 -0
- package/.vscode/settings.json +7 -0
- package/.vscode/snippets.code-snippets +75 -0
- package/.vscode/tasks.json +17 -0
- package/index.html +46 -0
- package/package.json +66 -0
- package/pnpm-lock.yaml +5313 -0
- package/scripts/check-if-is-sync.sh +6 -0
- package/scripts/filterFetchRequests.ts +60 -0
- package/src/Root.tsx +11 -0
- package/src/assets/icons/caret-down.svg +11 -0
- package/src/assets/icons/network.svg +6 -0
- package/src/assets/icons/search.svg +3 -0
- package/src/assets/icons/send.svg +3 -0
- package/src/assets/icons/settings.svg +3 -0
- package/src/components/ButtonElement.tsx +18 -0
- package/src/components/Icon.tsx +44 -0
- package/src/components/Section.tsx +57 -0
- package/src/components/Select.tsx +101 -0
- package/src/components/ValueVisualizer.tsx +397 -0
- package/src/config/icons.tsx +23 -0
- package/src/initializeApp.tsx +28 -0
- package/src/initializeDevTools.ts +33 -0
- package/src/main.ts +42 -0
- package/src/mocks/mockedRequests.json +28391 -0
- package/src/pages/api-explorer/ApiExplorerMenu.tsx +136 -0
- package/src/pages/api-explorer/ApiExplorerMenuItem.tsx +208 -0
- package/src/pages/api-explorer/Diff.tsx +223 -0
- package/src/pages/api-explorer/RequestDetails.tsx +264 -0
- package/src/pages/api-explorer/Timeline.tsx +174 -0
- package/src/pages/api-explorer/api-explorer.tsx +21 -0
- package/src/pages/api-explorer/getRequestPayload.tsx +15 -0
- package/src/pages/app/App.tsx +79 -0
- package/src/stores/callsStore.ts +267 -0
- package/src/stores/uiStore.ts +15 -0
- package/src/style/globalStyle.ts +54 -0
- package/src/style/helpers/allowTextSelection.ts +7 -0
- package/src/style/helpers/anchorColor.ts +9 -0
- package/src/style/helpers/centerContent.ts +5 -0
- package/src/style/helpers/circle.ts +7 -0
- package/src/style/helpers/ellipsis.ts +8 -0
- package/src/style/helpers/fillContainer.ts +7 -0
- package/src/style/helpers/gradientBorder.ts +28 -0
- package/src/style/helpers/gradientText.ts +8 -0
- package/src/style/helpers/inline.ts +34 -0
- package/src/style/helpers/mountAnim.ts +26 -0
- package/src/style/helpers/multilineEllipsis.ts +8 -0
- package/src/style/helpers/outline.ts +5 -0
- package/src/style/helpers/responsiveSize.ts +27 -0
- package/src/style/helpers/stack.ts +36 -0
- package/src/style/helpers/transition.ts +63 -0
- package/src/style/mediaQueries.ts +6 -0
- package/src/style/reset.ts +75 -0
- package/src/style/scrollBar.ts +37 -0
- package/src/style/theme.ts +35 -0
- package/src/types/global.d.ts +8 -0
- package/src/utils/initializeScreenLogger.ts +12 -0
- package/tsconfig.json +36 -0
- package/tsconfig.prod.json +10 -0
- package/tsup.config.ts +7 -0
- package/utils/arrayUtils.ts +29 -0
- package/utils/assertions.ts +7 -0
- package/utils/autoIncrementId.ts +5 -0
- package/utils/createThemev2.ts +64 -0
- package/utils/cx.ts +27 -0
- package/utils/getDiff.ts +15 -0
- package/utils/hexToRgb.ts +14 -0
- package/utils/objectUtils.ts +3 -0
- package/utils/parseUnit.ts +10 -0
- package/utils/solid.ts +76 -0
- package/utils/truncateText.ts +7 -0
- package/utils/tryExpression.ts +14 -0
- package/utils/typed.ts +23 -0
- package/utils/typings.ts +40 -0
- package/utils/urlPattern.ts +25 -0
- package/vite.config.ts +46 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import ButtonElement from '@src/components/ButtonElement'
|
|
2
|
+
import { Section } from '@src/components/Section'
|
|
3
|
+
import { ValueVisualizer } from '@src/components/ValueVisualizer'
|
|
4
|
+
import { Diff } from '@src/pages/api-explorer/Diff'
|
|
5
|
+
import { ApiCall, callsStore } from '@src/stores/callsStore'
|
|
6
|
+
import { setUiStore, uiStore } from '@src/stores/uiStore'
|
|
7
|
+
import { ellipsis } from '@src/style/helpers/ellipsis'
|
|
8
|
+
import { inline } from '@src/style/helpers/inline'
|
|
9
|
+
import { stack } from '@src/style/helpers/stack'
|
|
10
|
+
import { colors, fonts } from '@src/style/theme'
|
|
11
|
+
import dayjs from 'dayjs'
|
|
12
|
+
import { createMemo } from 'solid-js'
|
|
13
|
+
import { css } from 'solid-styled-components'
|
|
14
|
+
|
|
15
|
+
const containerStyle = css`
|
|
16
|
+
&&& {
|
|
17
|
+
${stack()};
|
|
18
|
+
padding-left: 10px;
|
|
19
|
+
|
|
20
|
+
> h1 {
|
|
21
|
+
margin-top: 12px;
|
|
22
|
+
font-family: ${fonts.decorative};
|
|
23
|
+
${ellipsis};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
> h2 {
|
|
27
|
+
margin-top: 4px;
|
|
28
|
+
font-family: ${fonts.decorative};
|
|
29
|
+
font-size: 12px;
|
|
30
|
+
opacity: 0.5;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.tags {
|
|
34
|
+
${inline({ gap: 8 })};
|
|
35
|
+
margin-top: 8px;
|
|
36
|
+
|
|
37
|
+
.method {
|
|
38
|
+
color: ${colors.primary.var};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.code {
|
|
42
|
+
color: ${colors.success.var};
|
|
43
|
+
|
|
44
|
+
&.error {
|
|
45
|
+
color: ${colors.error.var};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.tag {
|
|
50
|
+
font-size: 11px;
|
|
51
|
+
color: ${colors.warning.var};
|
|
52
|
+
padding: 1px 3px;
|
|
53
|
+
border-radius: 4px;
|
|
54
|
+
border: 1px solid ${colors.warning.alpha(0.6)};
|
|
55
|
+
|
|
56
|
+
&.error {
|
|
57
|
+
color: ${colors.error.var};
|
|
58
|
+
font-weight: 600;
|
|
59
|
+
border-color: ${colors.error.alpha(0.6)};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
> .details {
|
|
65
|
+
margin-top: 14px;
|
|
66
|
+
padding-right: 10px;
|
|
67
|
+
${stack({ gap: 8 })};
|
|
68
|
+
flex: 1 1;
|
|
69
|
+
overflow-y: auto;
|
|
70
|
+
padding-bottom: 20px;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
`
|
|
74
|
+
|
|
75
|
+
const tabsStyle = css`
|
|
76
|
+
&&& {
|
|
77
|
+
${inline({ gap: 20 })};
|
|
78
|
+
color: ${colors.secondary.var};
|
|
79
|
+
margin-top: 20px;
|
|
80
|
+
|
|
81
|
+
> button {
|
|
82
|
+
opacity: 0.74;
|
|
83
|
+
padding-bottom: 2px;
|
|
84
|
+
|
|
85
|
+
&.selected {
|
|
86
|
+
border-bottom: 2px solid currentColor;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&.selected,
|
|
90
|
+
&:hover {
|
|
91
|
+
opacity: 1;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
`
|
|
96
|
+
|
|
97
|
+
export const RequestDetails = () => {
|
|
98
|
+
const selectedCallId = $(uiStore.selectedCall)
|
|
99
|
+
const selectedRequestId = $(uiStore.selectedRequest)
|
|
100
|
+
const selectedTab = $(uiStore.selectedTab || 'summary')
|
|
101
|
+
|
|
102
|
+
const selectedRequest = createMemo(() => {
|
|
103
|
+
let selectedCall: ApiCall | undefined
|
|
104
|
+
|
|
105
|
+
if (selectedCallId) {
|
|
106
|
+
selectedCall = callsStore.calls[selectedCallId]
|
|
107
|
+
} else {
|
|
108
|
+
selectedCall = Object.values(callsStore.calls).at(-1)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const selectedRequest =
|
|
112
|
+
(selectedRequestId &&
|
|
113
|
+
selectedCall?.requests.find(
|
|
114
|
+
(request) => request.id === selectedRequestId,
|
|
115
|
+
)) ||
|
|
116
|
+
selectedCall?.requests.at(-1)
|
|
117
|
+
|
|
118
|
+
if (selectedRequest && selectedCall) {
|
|
119
|
+
return {
|
|
120
|
+
...selectedRequest,
|
|
121
|
+
callName: selectedCall.name,
|
|
122
|
+
callPath: selectedCall.path,
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return null
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
function getTab(tabId: string, label: string) {
|
|
130
|
+
return (
|
|
131
|
+
<ButtonElement
|
|
132
|
+
classList={{
|
|
133
|
+
selected: selectedTab === tabId,
|
|
134
|
+
}}
|
|
135
|
+
onClick={() => {
|
|
136
|
+
setUiStore('selectedTab', tabId)
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
{label}
|
|
140
|
+
</ButtonElement>
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<div class={containerStyle}>
|
|
146
|
+
<Show
|
|
147
|
+
when={selectedRequest()}
|
|
148
|
+
keyed
|
|
149
|
+
>
|
|
150
|
+
{(request) => (
|
|
151
|
+
<>
|
|
152
|
+
<h1>
|
|
153
|
+
{request.callName}
|
|
154
|
+
{request.alias && ` | ${request.alias}`}
|
|
155
|
+
</h1>
|
|
156
|
+
|
|
157
|
+
{request.callPath !== request.callName && (
|
|
158
|
+
<h2>{request.callPath}</h2>
|
|
159
|
+
)}
|
|
160
|
+
|
|
161
|
+
<div class="tags">
|
|
162
|
+
{request.method && <div class="method">{request.method}</div>}
|
|
163
|
+
|
|
164
|
+
{request.code && (
|
|
165
|
+
<div
|
|
166
|
+
class="code"
|
|
167
|
+
classList={{
|
|
168
|
+
error: request.code >= 400,
|
|
169
|
+
}}
|
|
170
|
+
>
|
|
171
|
+
{request.code}
|
|
172
|
+
</div>
|
|
173
|
+
)}
|
|
174
|
+
|
|
175
|
+
{request.isError && <div class="tag error">Has Error</div>}
|
|
176
|
+
|
|
177
|
+
<For each={request.tags}>
|
|
178
|
+
{(tag) => <div class="tag">{tag}</div>}
|
|
179
|
+
</For>
|
|
180
|
+
</div>
|
|
181
|
+
|
|
182
|
+
<div class={tabsStyle}>
|
|
183
|
+
{getTab('summary', 'Summary')}
|
|
184
|
+
{!!request.payload && getTab('payload', 'Payload')}
|
|
185
|
+
{!!request.searchParams && getTab('urlParams', 'URL Params')}
|
|
186
|
+
{getTab('response', 'Response')}
|
|
187
|
+
{getTab('diff', 'Diff')}
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
<div class="details">
|
|
191
|
+
<Switch>
|
|
192
|
+
<Match when={selectedTab === 'summary'}>
|
|
193
|
+
{!!request.payload && (
|
|
194
|
+
<Section title="Payload">
|
|
195
|
+
<ValueVisualizer
|
|
196
|
+
value={request.payload}
|
|
197
|
+
compact
|
|
198
|
+
/>
|
|
199
|
+
</Section>
|
|
200
|
+
)}
|
|
201
|
+
|
|
202
|
+
{!!request.searchParams && (
|
|
203
|
+
<Section title="URL Params">
|
|
204
|
+
<ValueVisualizer
|
|
205
|
+
value={request.searchParams}
|
|
206
|
+
compact
|
|
207
|
+
/>
|
|
208
|
+
</Section>
|
|
209
|
+
)}
|
|
210
|
+
|
|
211
|
+
{!!request.response && (
|
|
212
|
+
<Section title="Response">
|
|
213
|
+
<ValueVisualizer
|
|
214
|
+
value={request.response}
|
|
215
|
+
compact
|
|
216
|
+
/>
|
|
217
|
+
</Section>
|
|
218
|
+
)}
|
|
219
|
+
|
|
220
|
+
<Section title="Stats">
|
|
221
|
+
<ValueVisualizer
|
|
222
|
+
value={{
|
|
223
|
+
'Duration (ms)': Math.round(request.duration),
|
|
224
|
+
'Start Time': `${dayjs(request.startTime).format(
|
|
225
|
+
'HH:mm:ss',
|
|
226
|
+
)} (${dayjs(request.startTime).fromNow()})`,
|
|
227
|
+
}}
|
|
228
|
+
/>
|
|
229
|
+
</Section>
|
|
230
|
+
|
|
231
|
+
<Section title="Metadata">
|
|
232
|
+
<ValueVisualizer value={request.metadata} />
|
|
233
|
+
</Section>
|
|
234
|
+
</Match>
|
|
235
|
+
|
|
236
|
+
<Match when={selectedTab === 'payload'}>
|
|
237
|
+
<Section title={null}>
|
|
238
|
+
<ValueVisualizer value={request.payload} />
|
|
239
|
+
</Section>
|
|
240
|
+
</Match>
|
|
241
|
+
|
|
242
|
+
<Match when={selectedTab === 'response'}>
|
|
243
|
+
<Section title={null}>
|
|
244
|
+
<ValueVisualizer value={request.response} />
|
|
245
|
+
</Section>
|
|
246
|
+
</Match>
|
|
247
|
+
|
|
248
|
+
<Match when={selectedTab === 'urlParams'}>
|
|
249
|
+
<Section title={null}>
|
|
250
|
+
<ValueVisualizer value={request.searchParams} />
|
|
251
|
+
</Section>
|
|
252
|
+
</Match>
|
|
253
|
+
|
|
254
|
+
<Match when={selectedTab === 'diff'}>
|
|
255
|
+
<Diff />
|
|
256
|
+
</Match>
|
|
257
|
+
</Switch>
|
|
258
|
+
</div>
|
|
259
|
+
</>
|
|
260
|
+
)}
|
|
261
|
+
</Show>
|
|
262
|
+
</div>
|
|
263
|
+
)
|
|
264
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import ButtonElement from '@src/components/ButtonElement'
|
|
2
|
+
import { callsStore } from '@src/stores/callsStore'
|
|
3
|
+
import { setUiStore, uiStore } from '@src/stores/uiStore'
|
|
4
|
+
import { ellipsis } from '@src/style/helpers/ellipsis'
|
|
5
|
+
import { inline } from '@src/style/helpers/inline'
|
|
6
|
+
import { stack } from '@src/style/helpers/stack'
|
|
7
|
+
import { colors, fonts } from '@src/style/theme'
|
|
8
|
+
import { reverseCopy } from '@utils/arrayUtils'
|
|
9
|
+
import dayjs from 'dayjs'
|
|
10
|
+
import { createMemo } from 'solid-js'
|
|
11
|
+
import { css } from 'solid-styled-components'
|
|
12
|
+
import { getRequestPayload } from './getRequestPayload'
|
|
13
|
+
|
|
14
|
+
const containerStyle = css`
|
|
15
|
+
&&& {
|
|
16
|
+
${stack()};
|
|
17
|
+
border-right: 1px solid ${colors.white.alpha(0.1)};
|
|
18
|
+
|
|
19
|
+
> h1 {
|
|
20
|
+
font-size: 16px;
|
|
21
|
+
padding-left: 12px;
|
|
22
|
+
padding-top: 10px;
|
|
23
|
+
font-family: ${fonts.decorative};
|
|
24
|
+
color: ${colors.secondary.var};
|
|
25
|
+
padding-bottom: 16px;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`
|
|
29
|
+
|
|
30
|
+
const itemsContainerStyle = css`
|
|
31
|
+
&&& {
|
|
32
|
+
${stack()};
|
|
33
|
+
flex: 1 1;
|
|
34
|
+
overflow-y: auto;
|
|
35
|
+
}
|
|
36
|
+
`
|
|
37
|
+
|
|
38
|
+
const requestItemStyle = css`
|
|
39
|
+
&&& {
|
|
40
|
+
font-size: 13px;
|
|
41
|
+
${stack()};
|
|
42
|
+
|
|
43
|
+
&.error {
|
|
44
|
+
color: ${colors.error.var};
|
|
45
|
+
font-weight: 600;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
> button {
|
|
49
|
+
padding: 4px 12px;
|
|
50
|
+
${inline({ gap: 8 })};
|
|
51
|
+
opacity: 0.8;
|
|
52
|
+
|
|
53
|
+
&.selected {
|
|
54
|
+
opacity: 1;
|
|
55
|
+
background-color: ${colors.secondary.alpha(0.16)};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
> .start-time {
|
|
59
|
+
font-family: ${fonts.decorative};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
> .separator {
|
|
63
|
+
opacity: 0.5;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
> .payload {
|
|
67
|
+
${ellipsis};
|
|
68
|
+
flex-shrink: 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`
|
|
73
|
+
|
|
74
|
+
const emptyStateStyle = css`
|
|
75
|
+
&&& {
|
|
76
|
+
opacity: 0.4;
|
|
77
|
+
font-size: 14px;
|
|
78
|
+
padding: 12px;
|
|
79
|
+
padding-top: 0;
|
|
80
|
+
}
|
|
81
|
+
`
|
|
82
|
+
|
|
83
|
+
export const Timeline = () => {
|
|
84
|
+
const selectedCall = createMemo(() => {
|
|
85
|
+
const selectedCallId = uiStore.selectedCall
|
|
86
|
+
|
|
87
|
+
if (!selectedCallId) {
|
|
88
|
+
const callsEntries = Object.values(callsStore.calls).at(-1)
|
|
89
|
+
|
|
90
|
+
return callsEntries || null
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (selectedCallId) {
|
|
94
|
+
return callsStore.calls[selectedCallId]
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return null
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
const requests = createMemo(() => {
|
|
101
|
+
const reversed = reverseCopy(selectedCall()?.requests)
|
|
102
|
+
return reversed.length === 0 ? null : reversed
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
const filteredRequests = createMemo(() => {
|
|
106
|
+
if (uiStore.selectedSubitem) {
|
|
107
|
+
return requests()?.filter((request) => {
|
|
108
|
+
return request.alias === uiStore.selectedSubitem
|
|
109
|
+
})
|
|
110
|
+
} else {
|
|
111
|
+
return requests()
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
const selectedRequestId = $(
|
|
116
|
+
uiStore.selectedRequest || filteredRequests()?.[0]?.id,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<div class={containerStyle}>
|
|
121
|
+
<h1>timeline</h1>
|
|
122
|
+
|
|
123
|
+
<div class={itemsContainerStyle}>
|
|
124
|
+
<For
|
|
125
|
+
each={filteredRequests()}
|
|
126
|
+
fallback={<div class={emptyStateStyle}>no requests found</div>}
|
|
127
|
+
>
|
|
128
|
+
{(request) => {
|
|
129
|
+
const startTime = dayjs(request.startTime)
|
|
130
|
+
const formattedStartTime = startTime.format('HH:mm:ss')
|
|
131
|
+
const relativeStartTime = startTime.fromNow()
|
|
132
|
+
|
|
133
|
+
const payload = getRequestPayload(request)
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<div
|
|
137
|
+
class={requestItemStyle}
|
|
138
|
+
classList={{ error: request.isError }}
|
|
139
|
+
>
|
|
140
|
+
<ButtonElement
|
|
141
|
+
onClick={() => {
|
|
142
|
+
setUiStore('selectedRequest', request.id)
|
|
143
|
+
}}
|
|
144
|
+
classList={{
|
|
145
|
+
selected: request.id === selectedRequestId,
|
|
146
|
+
}}
|
|
147
|
+
>
|
|
148
|
+
<span
|
|
149
|
+
class="start-time"
|
|
150
|
+
title={relativeStartTime}
|
|
151
|
+
>
|
|
152
|
+
{formattedStartTime}
|
|
153
|
+
</span>
|
|
154
|
+
|
|
155
|
+
{!!payload && (
|
|
156
|
+
<>
|
|
157
|
+
<span class="separator">|</span>
|
|
158
|
+
<span
|
|
159
|
+
class="payload"
|
|
160
|
+
title={payload}
|
|
161
|
+
>
|
|
162
|
+
{payload}
|
|
163
|
+
</span>
|
|
164
|
+
</>
|
|
165
|
+
)}
|
|
166
|
+
</ButtonElement>
|
|
167
|
+
</div>
|
|
168
|
+
)
|
|
169
|
+
}}
|
|
170
|
+
</For>
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
)
|
|
174
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ApiExplorerMenu } from '@src/pages/api-explorer/ApiExplorerMenu'
|
|
2
|
+
import { RequestDetails } from '@src/pages/api-explorer/RequestDetails'
|
|
3
|
+
import { Timeline } from '@src/pages/api-explorer/Timeline'
|
|
4
|
+
import { css } from 'solid-styled-components'
|
|
5
|
+
|
|
6
|
+
const containerStyle = css`
|
|
7
|
+
&&& {
|
|
8
|
+
display: grid;
|
|
9
|
+
grid-template-columns: 1.5fr 1fr 3fr;
|
|
10
|
+
}
|
|
11
|
+
`
|
|
12
|
+
|
|
13
|
+
export const ApiExplorerPage = () => {
|
|
14
|
+
return (
|
|
15
|
+
<div class={containerStyle}>
|
|
16
|
+
<ApiExplorerMenu />
|
|
17
|
+
<Timeline />
|
|
18
|
+
<RequestDetails />
|
|
19
|
+
</div>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApiRequest } from '@src/stores/callsStore';
|
|
2
|
+
|
|
3
|
+
export function getRequestPayload(request: ApiRequest) {
|
|
4
|
+
const payload = request.alias || request.payload || request.searchParams;
|
|
5
|
+
|
|
6
|
+
if (!payload || Object.keys(payload).length === 0) {
|
|
7
|
+
return '';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (typeof payload === 'string' || typeof payload === 'number') {
|
|
11
|
+
return String(payload);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return JSON.stringify(payload);
|
|
15
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import ButtonElement from '@src/components/ButtonElement'
|
|
2
|
+
import Icon from '@src/components/Icon'
|
|
3
|
+
import { unmountApp } from '@src/initializeApp'
|
|
4
|
+
import { ApiExplorerPage } from '@src/pages/api-explorer/api-explorer'
|
|
5
|
+
import { globalStyle } from '@src/style/globalStyle'
|
|
6
|
+
import { centerContent } from '@src/style/helpers/centerContent'
|
|
7
|
+
import { fillContainer } from '@src/style/helpers/fillContainer'
|
|
8
|
+
import { stack } from '@src/style/helpers/stack'
|
|
9
|
+
import { resetStyle } from '@src/style/reset'
|
|
10
|
+
import { colors } from '@src/style/theme'
|
|
11
|
+
import { css } from 'goober'
|
|
12
|
+
|
|
13
|
+
const containerStyle = css`
|
|
14
|
+
${resetStyle};
|
|
15
|
+
${globalStyle};
|
|
16
|
+
|
|
17
|
+
position: fixed;
|
|
18
|
+
inset: 32px;
|
|
19
|
+
border-radius: 4px;
|
|
20
|
+
background: ${colors.bgPrimary.var};
|
|
21
|
+
display: grid;
|
|
22
|
+
grid-template-columns: 51px 1fr;
|
|
23
|
+
|
|
24
|
+
nav {
|
|
25
|
+
${stack()};
|
|
26
|
+
border-right: 1px solid ${colors.white.alpha(0.1)};
|
|
27
|
+
|
|
28
|
+
button {
|
|
29
|
+
${centerContent};
|
|
30
|
+
width: 100%;
|
|
31
|
+
aspect-ratio: 1 / 1;
|
|
32
|
+
color: ${colors.bgPrimary.var};
|
|
33
|
+
--icon-size: 30px;
|
|
34
|
+
|
|
35
|
+
&::before {
|
|
36
|
+
content: '';
|
|
37
|
+
inset: 6px;
|
|
38
|
+
border-radius: 3px;
|
|
39
|
+
position: absolute;
|
|
40
|
+
background: ${colors.primary.var};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
> main > * {
|
|
46
|
+
${fillContainer};
|
|
47
|
+
}
|
|
48
|
+
`
|
|
49
|
+
|
|
50
|
+
const backdropStyle = css`
|
|
51
|
+
${fillContainer};
|
|
52
|
+
position: fixed;
|
|
53
|
+
inset: 0;
|
|
54
|
+
`
|
|
55
|
+
|
|
56
|
+
export const App = () => {
|
|
57
|
+
return (
|
|
58
|
+
<>
|
|
59
|
+
<div
|
|
60
|
+
class={backdropStyle}
|
|
61
|
+
onClick={unmountApp}
|
|
62
|
+
/>
|
|
63
|
+
<div
|
|
64
|
+
class={containerStyle}
|
|
65
|
+
id="dev-tools-root-element"
|
|
66
|
+
>
|
|
67
|
+
<nav>
|
|
68
|
+
<ButtonElement title="API Explorer">
|
|
69
|
+
<Icon name="network" />
|
|
70
|
+
</ButtonElement>
|
|
71
|
+
</nav>
|
|
72
|
+
|
|
73
|
+
<main>
|
|
74
|
+
<ApiExplorerPage />
|
|
75
|
+
</main>
|
|
76
|
+
</div>
|
|
77
|
+
</>
|
|
78
|
+
)
|
|
79
|
+
}
|