@jagoankode/api-client 1.0.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/dist/index.d.mts +88 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.js +941 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +901 -0
- package/dist/index.mjs.map +1 -0
- package/dist/init.js +5650 -0
- package/dist/init.js.map +1 -0
- package/package.json +58 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,901 @@
|
|
|
1
|
+
// #style-inject:#style-inject
|
|
2
|
+
function styleInject(css, { insertAt } = {}) {
|
|
3
|
+
if (!css || typeof document === "undefined") return;
|
|
4
|
+
const head = document.head || document.getElementsByTagName("head")[0];
|
|
5
|
+
const style = document.createElement("style");
|
|
6
|
+
style.type = "text/css";
|
|
7
|
+
if (insertAt === "top") {
|
|
8
|
+
if (head.firstChild) {
|
|
9
|
+
head.insertBefore(style, head.firstChild);
|
|
10
|
+
} else {
|
|
11
|
+
head.appendChild(style);
|
|
12
|
+
}
|
|
13
|
+
} else {
|
|
14
|
+
head.appendChild(style);
|
|
15
|
+
}
|
|
16
|
+
if (style.styleSheet) {
|
|
17
|
+
style.styleSheet.cssText = css;
|
|
18
|
+
} else {
|
|
19
|
+
style.appendChild(document.createTextNode(css));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/styles.css
|
|
24
|
+
styleInject('*,\n::before,\n::after {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-gradient-from-position: ;\n --tw-gradient-via-position: ;\n --tw-gradient-to-position: ;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n --tw-contain-size: ;\n --tw-contain-layout: ;\n --tw-contain-paint: ;\n --tw-contain-style: ;\n}\n::backdrop {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-gradient-from-position: ;\n --tw-gradient-via-position: ;\n --tw-gradient-to-position: ;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n --tw-contain-size: ;\n --tw-contain-layout: ;\n --tw-contain-paint: ;\n --tw-contain-style: ;\n}\n.nat-absolute {\n position: absolute;\n}\n.nat-relative {\n position: relative;\n}\n.nat-right-2 {\n right: 0.5rem;\n}\n.nat-top-2 {\n top: 0.5rem;\n}\n.-nat-mb-px {\n margin-bottom: -1px;\n}\n.nat-mb-1\\.5 {\n margin-bottom: 0.375rem;\n}\n.nat-mb-3 {\n margin-bottom: 0.75rem;\n}\n.nat-ml-auto {\n margin-left: auto;\n}\n.nat-mt-1 {\n margin-top: 0.25rem;\n}\n.nat-flex {\n display: flex;\n}\n.nat-inline-flex {\n display: inline-flex;\n}\n.nat-h-1\\.5 {\n height: 0.375rem;\n}\n.nat-h-2 {\n height: 0.5rem;\n}\n.nat-h-3\\.5 {\n height: 0.875rem;\n}\n.nat-h-6 {\n height: 1.5rem;\n}\n.nat-h-\\[45\\%\\] {\n height: 45%;\n}\n.nat-h-\\[55\\%\\] {\n height: 55%;\n}\n.nat-h-full {\n height: 100%;\n}\n.nat-h-screen {\n height: 100vh;\n}\n.nat-min-h-\\[150px\\] {\n min-height: 150px;\n}\n.nat-min-h-\\[300px\\] {\n min-height: 300px;\n}\n.nat-w-1\\.5 {\n width: 0.375rem;\n}\n.nat-w-1\\/3 {\n width: 33.333333%;\n}\n.nat-w-2 {\n width: 0.5rem;\n}\n.nat-w-2\\/3 {\n width: 66.666667%;\n}\n.nat-w-3\\.5 {\n width: 0.875rem;\n}\n.nat-w-6 {\n width: 1.5rem;\n}\n.nat-w-72 {\n width: 18rem;\n}\n.nat-w-full {\n width: 100%;\n}\n.nat-w-max {\n width: -moz-max-content;\n width: max-content;\n}\n.nat-max-w-md {\n max-width: 28rem;\n}\n.nat-flex-1 {\n flex: 1 1 0%;\n}\n.nat-resize-y {\n resize: vertical;\n}\n.nat-flex-col {\n flex-direction: column;\n}\n.nat-flex-wrap {\n flex-wrap: wrap;\n}\n.nat-items-center {\n align-items: center;\n}\n.nat-justify-center {\n justify-content: center;\n}\n.nat-justify-between {\n justify-content: space-between;\n}\n.nat-gap-1\\.5 {\n gap: 0.375rem;\n}\n.nat-gap-2 {\n gap: 0.5rem;\n}\n.nat-gap-3 {\n gap: 0.75rem;\n}\n.nat-gap-4 {\n gap: 1rem;\n}\n.nat-gap-6 {\n gap: 1.5rem;\n}\n.nat-gap-px {\n gap: 1px;\n}\n.nat-overflow-hidden {\n overflow: hidden;\n}\n.nat-overflow-y-auto {\n overflow-y: auto;\n}\n.nat-truncate {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.nat-whitespace-pre-wrap {\n white-space: pre-wrap;\n}\n.nat-break-all {\n word-break: break-all;\n}\n.nat-rounded {\n border-radius: 0.25rem;\n}\n.nat-rounded-full {\n border-radius: 9999px;\n}\n.nat-rounded-xl {\n border-radius: 0.75rem;\n}\n.nat-border {\n border-width: 1px;\n}\n.nat-border-b {\n border-bottom-width: 1px;\n}\n.nat-border-b-2 {\n border-bottom-width: 2px;\n}\n.nat-border-l {\n border-left-width: 1px;\n}\n.nat-border-r {\n border-right-width: 1px;\n}\n.nat-border-amber-500\\/20 {\n border-color: rgb(245 158 11 / 0.2);\n}\n.nat-border-emerald-500\\/20 {\n border-color: rgb(16 185 129 / 0.2);\n}\n.nat-border-neutral-700 {\n --tw-border-opacity: 1;\n border-color: rgb(64 64 64 / var(--tw-border-opacity, 1));\n}\n.nat-border-neutral-800 {\n --tw-border-opacity: 1;\n border-color: rgb(38 38 38 / var(--tw-border-opacity, 1));\n}\n.nat-border-neutral-800\\/50 {\n border-color: rgb(38 38 38 / 0.5);\n}\n.nat-border-orange-500 {\n --tw-border-opacity: 1;\n border-color: rgb(249 115 22 / var(--tw-border-opacity, 1));\n}\n.nat-border-rose-500\\/20 {\n border-color: rgb(244 63 94 / 0.2);\n}\n.nat-border-rose-900\\/50 {\n border-color: rgb(136 19 55 / 0.5);\n}\n.nat-border-transparent {\n border-color: transparent;\n}\n.nat-bg-amber-500\\/10 {\n background-color: rgb(245 158 11 / 0.1);\n}\n.nat-bg-blue-500\\/10 {\n background-color: rgb(59 130 246 / 0.1);\n}\n.nat-bg-emerald-500 {\n --tw-bg-opacity: 1;\n background-color: rgb(16 185 129 / var(--tw-bg-opacity, 1));\n}\n.nat-bg-emerald-500\\/10 {\n background-color: rgb(16 185 129 / 0.1);\n}\n.nat-bg-neutral-800 {\n --tw-bg-opacity: 1;\n background-color: rgb(38 38 38 / var(--tw-bg-opacity, 1));\n}\n.nat-bg-neutral-900 {\n --tw-bg-opacity: 1;\n background-color: rgb(23 23 23 / var(--tw-bg-opacity, 1));\n}\n.nat-bg-neutral-900\\/50 {\n background-color: rgb(23 23 23 / 0.5);\n}\n.nat-bg-neutral-950 {\n --tw-bg-opacity: 1;\n background-color: rgb(10 10 10 / var(--tw-bg-opacity, 1));\n}\n.nat-bg-neutral-950\\/50 {\n background-color: rgb(10 10 10 / 0.5);\n}\n.nat-bg-orange-600 {\n --tw-bg-opacity: 1;\n background-color: rgb(234 88 12 / var(--tw-bg-opacity, 1));\n}\n.nat-bg-purple-500\\/10 {\n background-color: rgb(168 85 247 / 0.1);\n}\n.nat-bg-rose-500 {\n --tw-bg-opacity: 1;\n background-color: rgb(244 63 94 / var(--tw-bg-opacity, 1));\n}\n.nat-bg-rose-500\\/10 {\n background-color: rgb(244 63 94 / 0.1);\n}\n.nat-bg-rose-950\\/20 {\n background-color: rgb(76 5 25 / 0.2);\n}\n.nat-bg-zinc-500\\/10 {\n background-color: rgb(113 113 122 / 0.1);\n}\n.nat-p-0 {\n padding: 0px;\n}\n.nat-p-2 {\n padding: 0.5rem;\n}\n.nat-p-3 {\n padding: 0.75rem;\n}\n.nat-p-4 {\n padding: 1rem;\n}\n.nat-p-6 {\n padding: 1.5rem;\n}\n.nat-p-8 {\n padding: 2rem;\n}\n.nat-px-1 {\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n}\n.nat-px-1\\.5 {\n padding-left: 0.375rem;\n padding-right: 0.375rem;\n}\n.nat-px-2 {\n padding-left: 0.5rem;\n padding-right: 0.5rem;\n}\n.nat-px-2\\.5 {\n padding-left: 0.625rem;\n padding-right: 0.625rem;\n}\n.nat-px-3 {\n padding-left: 0.75rem;\n padding-right: 0.75rem;\n}\n.nat-px-4 {\n padding-left: 1rem;\n padding-right: 1rem;\n}\n.nat-px-6 {\n padding-left: 1.5rem;\n padding-right: 1.5rem;\n}\n.nat-py-0\\.5 {\n padding-top: 0.125rem;\n padding-bottom: 0.125rem;\n}\n.nat-py-1 {\n padding-top: 0.25rem;\n padding-bottom: 0.25rem;\n}\n.nat-py-1\\.5 {\n padding-top: 0.375rem;\n padding-bottom: 0.375rem;\n}\n.nat-py-2 {\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n}\n.nat-py-2\\.5 {\n padding-top: 0.625rem;\n padding-bottom: 0.625rem;\n}\n.nat-py-3 {\n padding-top: 0.75rem;\n padding-bottom: 0.75rem;\n}\n.nat-pb-2 {\n padding-bottom: 0.5rem;\n}\n.nat-text-left {\n text-align: left;\n}\n.nat-text-center {\n text-align: center;\n}\n.nat-font-mono {\n font-family:\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n "Liberation Mono",\n "Courier New",\n monospace;\n}\n.nat-font-sans {\n font-family:\n ui-sans-serif,\n system-ui,\n sans-serif,\n "Apple Color Emoji",\n "Segoe UI Emoji",\n "Segoe UI Symbol",\n "Noto Color Emoji";\n}\n.nat-text-\\[10px\\] {\n font-size: 10px;\n}\n.nat-text-\\[11px\\] {\n font-size: 11px;\n}\n.nat-text-\\[9px\\] {\n font-size: 9px;\n}\n.nat-text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n.nat-text-xl {\n font-size: 1.25rem;\n line-height: 1.75rem;\n}\n.nat-text-xs {\n font-size: 0.75rem;\n line-height: 1rem;\n}\n.nat-font-bold {\n font-weight: 700;\n}\n.nat-font-medium {\n font-weight: 500;\n}\n.nat-font-semibold {\n font-weight: 600;\n}\n.nat-uppercase {\n text-transform: uppercase;\n}\n.nat-leading-relaxed {\n line-height: 1.625;\n}\n.nat-tracking-tight {\n letter-spacing: -0.025em;\n}\n.nat-text-amber-400 {\n --tw-text-opacity: 1;\n color: rgb(251 191 36 / var(--tw-text-opacity, 1));\n}\n.nat-text-amber-500 {\n --tw-text-opacity: 1;\n color: rgb(245 158 11 / var(--tw-text-opacity, 1));\n}\n.nat-text-blue-400 {\n --tw-text-opacity: 1;\n color: rgb(96 165 250 / var(--tw-text-opacity, 1));\n}\n.nat-text-emerald-400 {\n --tw-text-opacity: 1;\n color: rgb(52 211 153 / var(--tw-text-opacity, 1));\n}\n.nat-text-emerald-400\\/90 {\n color: rgb(52 211 153 / 0.9);\n}\n.nat-text-emerald-500 {\n --tw-text-opacity: 1;\n color: rgb(16 185 129 / var(--tw-text-opacity, 1));\n}\n.nat-text-neutral-100 {\n --tw-text-opacity: 1;\n color: rgb(245 245 245 / var(--tw-text-opacity, 1));\n}\n.nat-text-neutral-200 {\n --tw-text-opacity: 1;\n color: rgb(229 229 229 / var(--tw-text-opacity, 1));\n}\n.nat-text-neutral-300 {\n --tw-text-opacity: 1;\n color: rgb(212 212 212 / var(--tw-text-opacity, 1));\n}\n.nat-text-neutral-400 {\n --tw-text-opacity: 1;\n color: rgb(163 163 163 / var(--tw-text-opacity, 1));\n}\n.nat-text-neutral-500 {\n --tw-text-opacity: 1;\n color: rgb(115 115 115 / var(--tw-text-opacity, 1));\n}\n.nat-text-neutral-600 {\n --tw-text-opacity: 1;\n color: rgb(82 82 82 / var(--tw-text-opacity, 1));\n}\n.nat-text-orange-500 {\n --tw-text-opacity: 1;\n color: rgb(249 115 22 / var(--tw-text-opacity, 1));\n}\n.nat-text-purple-400 {\n --tw-text-opacity: 1;\n color: rgb(192 132 252 / var(--tw-text-opacity, 1));\n}\n.nat-text-rose-400 {\n --tw-text-opacity: 1;\n color: rgb(251 113 133 / var(--tw-text-opacity, 1));\n}\n.nat-text-rose-400\\/80 {\n color: rgb(251 113 133 / 0.8);\n}\n.nat-text-rose-500 {\n --tw-text-opacity: 1;\n color: rgb(244 63 94 / var(--tw-text-opacity, 1));\n}\n.nat-text-white {\n --tw-text-opacity: 1;\n color: rgb(255 255 255 / var(--tw-text-opacity, 1));\n}\n.nat-text-zinc-400 {\n --tw-text-opacity: 1;\n color: rgb(161 161 170 / var(--tw-text-opacity, 1));\n}\n.nat-accent-orange-500 {\n accent-color: #f97316;\n}\n.nat-opacity-0 {\n opacity: 0;\n}\n.nat-shadow-2xl {\n --tw-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);\n --tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);\n box-shadow:\n var(--tw-ring-offset-shadow, 0 0 #0000),\n var(--tw-ring-shadow, 0 0 #0000),\n var(--tw-shadow);\n}\n.nat-transition-all {\n transition-property: all;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.nat-transition-colors {\n transition-property:\n color,\n background-color,\n border-color,\n text-decoration-color,\n fill,\n stroke;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.nat-transition-opacity {\n transition-property: opacity;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 150ms;\n}\n.nat-scrollbar::-webkit-scrollbar {\n width: 6px;\n height: 6px;\n}\n.nat-scrollbar::-webkit-scrollbar-track {\n background: transparent;\n}\n.nat-scrollbar::-webkit-scrollbar-thumb {\n background: #3f3f46;\n border-radius: 3px;\n}\n.nat-scrollbar::-webkit-scrollbar-thumb:hover {\n background: #52525b;\n}\n.placeholder\\:nat-text-neutral-600::-moz-placeholder {\n --tw-text-opacity: 1;\n color: rgb(82 82 82 / var(--tw-text-opacity, 1));\n}\n.placeholder\\:nat-text-neutral-600::placeholder {\n --tw-text-opacity: 1;\n color: rgb(82 82 82 / var(--tw-text-opacity, 1));\n}\n.hover\\:nat-bg-neutral-700:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(64 64 64 / var(--tw-bg-opacity, 1));\n}\n.hover\\:nat-bg-neutral-800\\/50:hover {\n background-color: rgb(38 38 38 / 0.5);\n}\n.hover\\:nat-bg-neutral-800\\/80:hover {\n background-color: rgb(38 38 38 / 0.8);\n}\n.hover\\:nat-bg-orange-700:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(194 65 12 / var(--tw-bg-opacity, 1));\n}\n.hover\\:nat-text-neutral-300:hover {\n --tw-text-opacity: 1;\n color: rgb(212 212 212 / var(--tw-text-opacity, 1));\n}\n.hover\\:nat-text-orange-400:hover {\n --tw-text-opacity: 1;\n color: rgb(251 146 60 / var(--tw-text-opacity, 1));\n}\n.hover\\:nat-text-rose-400:hover {\n --tw-text-opacity: 1;\n color: rgb(251 113 133 / var(--tw-text-opacity, 1));\n}\n.hover\\:nat-text-rose-500:hover {\n --tw-text-opacity: 1;\n color: rgb(244 63 94 / var(--tw-text-opacity, 1));\n}\n.focus\\:nat-border-neutral-600:focus {\n --tw-border-opacity: 1;\n border-color: rgb(82 82 82 / var(--tw-border-opacity, 1));\n}\n.focus\\:nat-border-orange-500:focus {\n --tw-border-opacity: 1;\n border-color: rgb(249 115 22 / var(--tw-border-opacity, 1));\n}\n.focus\\:nat-outline-none:focus {\n outline: 2px solid transparent;\n outline-offset: 2px;\n}\n.focus\\:nat-ring-1:focus {\n --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);\n --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);\n box-shadow:\n var(--tw-ring-offset-shadow),\n var(--tw-ring-shadow),\n var(--tw-shadow, 0 0 #0000);\n}\n.focus\\:nat-ring-orange-500\\/50:focus {\n --tw-ring-color: rgb(249 115 22 / 0.5);\n}\n.disabled\\:nat-cursor-not-allowed:disabled {\n cursor: not-allowed;\n}\n.disabled\\:nat-opacity-50:disabled {\n opacity: 0.5;\n}\n.nat-group:hover .group-hover\\:nat-text-neutral-300 {\n --tw-text-opacity: 1;\n color: rgb(212 212 212 / var(--tw-text-opacity, 1));\n}\n.nat-group:hover .group-hover\\:nat-text-neutral-500 {\n --tw-text-opacity: 1;\n color: rgb(115 115 115 / var(--tw-text-opacity, 1));\n}\n.nat-group:hover .group-hover\\:nat-opacity-100 {\n opacity: 1;\n}\n');
|
|
25
|
+
|
|
26
|
+
// src/components/RequestPanel.tsx
|
|
27
|
+
import { useState } from "react";
|
|
28
|
+
|
|
29
|
+
// node_modules/zustand/esm/vanilla.mjs
|
|
30
|
+
var createStoreImpl = (createState) => {
|
|
31
|
+
let state;
|
|
32
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
33
|
+
const setState = (partial, replace) => {
|
|
34
|
+
const nextState = typeof partial === "function" ? partial(state) : partial;
|
|
35
|
+
if (!Object.is(nextState, state)) {
|
|
36
|
+
const previousState = state;
|
|
37
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
|
38
|
+
listeners.forEach((listener) => listener(state, previousState));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const getState = () => state;
|
|
42
|
+
const getInitialState = () => initialState;
|
|
43
|
+
const subscribe = (listener) => {
|
|
44
|
+
listeners.add(listener);
|
|
45
|
+
return () => listeners.delete(listener);
|
|
46
|
+
};
|
|
47
|
+
const api = { setState, getState, getInitialState, subscribe };
|
|
48
|
+
const initialState = state = createState(setState, getState, api);
|
|
49
|
+
return api;
|
|
50
|
+
};
|
|
51
|
+
var createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);
|
|
52
|
+
|
|
53
|
+
// node_modules/zustand/esm/react.mjs
|
|
54
|
+
import React from "react";
|
|
55
|
+
var identity = (arg) => arg;
|
|
56
|
+
function useStore(api, selector = identity) {
|
|
57
|
+
const slice = React.useSyncExternalStore(
|
|
58
|
+
api.subscribe,
|
|
59
|
+
React.useCallback(() => selector(api.getState()), [api, selector]),
|
|
60
|
+
React.useCallback(() => selector(api.getInitialState()), [api, selector])
|
|
61
|
+
);
|
|
62
|
+
React.useDebugValue(slice);
|
|
63
|
+
return slice;
|
|
64
|
+
}
|
|
65
|
+
var createImpl = (createState) => {
|
|
66
|
+
const api = createStore(createState);
|
|
67
|
+
const useBoundStore = (selector) => useStore(api, selector);
|
|
68
|
+
Object.assign(useBoundStore, api);
|
|
69
|
+
return useBoundStore;
|
|
70
|
+
};
|
|
71
|
+
var create = ((createState) => createState ? createImpl(createState) : createImpl);
|
|
72
|
+
|
|
73
|
+
// node_modules/zustand/esm/middleware.mjs
|
|
74
|
+
function createJSONStorage(getStorage, options) {
|
|
75
|
+
let storage;
|
|
76
|
+
try {
|
|
77
|
+
storage = getStorage();
|
|
78
|
+
} catch (e) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const persistStorage = {
|
|
82
|
+
getItem: (name) => {
|
|
83
|
+
var _a;
|
|
84
|
+
const parse = (str2) => {
|
|
85
|
+
if (str2 === null) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
return JSON.parse(str2, options == null ? void 0 : options.reviver);
|
|
89
|
+
};
|
|
90
|
+
const str = (_a = storage.getItem(name)) != null ? _a : null;
|
|
91
|
+
if (str instanceof Promise) {
|
|
92
|
+
return str.then(parse);
|
|
93
|
+
}
|
|
94
|
+
return parse(str);
|
|
95
|
+
},
|
|
96
|
+
setItem: (name, newValue) => storage.setItem(name, JSON.stringify(newValue, options == null ? void 0 : options.replacer)),
|
|
97
|
+
removeItem: (name) => storage.removeItem(name)
|
|
98
|
+
};
|
|
99
|
+
return persistStorage;
|
|
100
|
+
}
|
|
101
|
+
var toThenable = (fn) => (input) => {
|
|
102
|
+
try {
|
|
103
|
+
const result = fn(input);
|
|
104
|
+
if (result instanceof Promise) {
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
then(onFulfilled) {
|
|
109
|
+
return toThenable(onFulfilled)(result);
|
|
110
|
+
},
|
|
111
|
+
catch(_onRejected) {
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
} catch (e) {
|
|
116
|
+
return {
|
|
117
|
+
then(_onFulfilled) {
|
|
118
|
+
return this;
|
|
119
|
+
},
|
|
120
|
+
catch(onRejected) {
|
|
121
|
+
return toThenable(onRejected)(e);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var persistImpl = (config, baseOptions) => (set, get, api) => {
|
|
127
|
+
let options = {
|
|
128
|
+
storage: createJSONStorage(() => window.localStorage),
|
|
129
|
+
partialize: (state) => state,
|
|
130
|
+
version: 0,
|
|
131
|
+
merge: (persistedState, currentState) => ({
|
|
132
|
+
...currentState,
|
|
133
|
+
...persistedState
|
|
134
|
+
}),
|
|
135
|
+
...baseOptions
|
|
136
|
+
};
|
|
137
|
+
let hasHydrated = false;
|
|
138
|
+
let hydrationVersion = 0;
|
|
139
|
+
const hydrationListeners = /* @__PURE__ */ new Set();
|
|
140
|
+
const finishHydrationListeners = /* @__PURE__ */ new Set();
|
|
141
|
+
let storage = options.storage;
|
|
142
|
+
if (!storage) {
|
|
143
|
+
return config(
|
|
144
|
+
(...args) => {
|
|
145
|
+
console.warn(
|
|
146
|
+
`[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`
|
|
147
|
+
);
|
|
148
|
+
set(...args);
|
|
149
|
+
},
|
|
150
|
+
get,
|
|
151
|
+
api
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
const setItem = () => {
|
|
155
|
+
const state = options.partialize({ ...get() });
|
|
156
|
+
return storage.setItem(options.name, {
|
|
157
|
+
state,
|
|
158
|
+
version: options.version
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
const savedSetState = api.setState;
|
|
162
|
+
api.setState = (state, replace) => {
|
|
163
|
+
savedSetState(state, replace);
|
|
164
|
+
return setItem();
|
|
165
|
+
};
|
|
166
|
+
const configResult = config(
|
|
167
|
+
(...args) => {
|
|
168
|
+
set(...args);
|
|
169
|
+
return setItem();
|
|
170
|
+
},
|
|
171
|
+
get,
|
|
172
|
+
api
|
|
173
|
+
);
|
|
174
|
+
api.getInitialState = () => configResult;
|
|
175
|
+
let stateFromStorage;
|
|
176
|
+
const hydrate = () => {
|
|
177
|
+
var _a, _b;
|
|
178
|
+
if (!storage) return;
|
|
179
|
+
const currentVersion = ++hydrationVersion;
|
|
180
|
+
hasHydrated = false;
|
|
181
|
+
hydrationListeners.forEach((cb) => {
|
|
182
|
+
var _a2;
|
|
183
|
+
return cb((_a2 = get()) != null ? _a2 : configResult);
|
|
184
|
+
});
|
|
185
|
+
const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;
|
|
186
|
+
return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {
|
|
187
|
+
if (deserializedStorageValue) {
|
|
188
|
+
if (typeof deserializedStorageValue.version === "number" && deserializedStorageValue.version !== options.version) {
|
|
189
|
+
if (options.migrate) {
|
|
190
|
+
const migration = options.migrate(
|
|
191
|
+
deserializedStorageValue.state,
|
|
192
|
+
deserializedStorageValue.version
|
|
193
|
+
);
|
|
194
|
+
if (migration instanceof Promise) {
|
|
195
|
+
return migration.then((result) => [true, result]);
|
|
196
|
+
}
|
|
197
|
+
return [true, migration];
|
|
198
|
+
}
|
|
199
|
+
console.error(
|
|
200
|
+
`State loaded from storage couldn't be migrated since no migrate function was provided`
|
|
201
|
+
);
|
|
202
|
+
} else {
|
|
203
|
+
return [false, deserializedStorageValue.state];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return [false, void 0];
|
|
207
|
+
}).then((migrationResult) => {
|
|
208
|
+
var _a2;
|
|
209
|
+
if (currentVersion !== hydrationVersion) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const [migrated, migratedState] = migrationResult;
|
|
213
|
+
stateFromStorage = options.merge(
|
|
214
|
+
migratedState,
|
|
215
|
+
(_a2 = get()) != null ? _a2 : configResult
|
|
216
|
+
);
|
|
217
|
+
set(stateFromStorage, true);
|
|
218
|
+
if (migrated) {
|
|
219
|
+
return setItem();
|
|
220
|
+
}
|
|
221
|
+
}).then(() => {
|
|
222
|
+
if (currentVersion !== hydrationVersion) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
postRehydrationCallback == null ? void 0 : postRehydrationCallback(get(), void 0);
|
|
226
|
+
stateFromStorage = get();
|
|
227
|
+
hasHydrated = true;
|
|
228
|
+
finishHydrationListeners.forEach((cb) => cb(stateFromStorage));
|
|
229
|
+
}).catch((e) => {
|
|
230
|
+
if (currentVersion !== hydrationVersion) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
api.persist = {
|
|
237
|
+
setOptions: (newOptions) => {
|
|
238
|
+
options = {
|
|
239
|
+
...options,
|
|
240
|
+
...newOptions
|
|
241
|
+
};
|
|
242
|
+
if (newOptions.storage) {
|
|
243
|
+
storage = newOptions.storage;
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
clearStorage: () => {
|
|
247
|
+
storage == null ? void 0 : storage.removeItem(options.name);
|
|
248
|
+
},
|
|
249
|
+
getOptions: () => options,
|
|
250
|
+
rehydrate: () => hydrate(),
|
|
251
|
+
hasHydrated: () => hasHydrated,
|
|
252
|
+
onHydrate: (cb) => {
|
|
253
|
+
hydrationListeners.add(cb);
|
|
254
|
+
return () => {
|
|
255
|
+
hydrationListeners.delete(cb);
|
|
256
|
+
};
|
|
257
|
+
},
|
|
258
|
+
onFinishHydration: (cb) => {
|
|
259
|
+
finishHydrationListeners.add(cb);
|
|
260
|
+
return () => {
|
|
261
|
+
finishHydrationListeners.delete(cb);
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
if (!options.skipHydration) {
|
|
266
|
+
hydrate();
|
|
267
|
+
}
|
|
268
|
+
return stateFromStorage || configResult;
|
|
269
|
+
};
|
|
270
|
+
var persist = persistImpl;
|
|
271
|
+
|
|
272
|
+
// src/utils/fetcher.ts
|
|
273
|
+
function getCookie(name) {
|
|
274
|
+
if (typeof document === "undefined") return null;
|
|
275
|
+
const match = new RegExp(new RegExp(String.raw`(?:^|;\s*)${name}=([^;]*)`)).exec(document.cookie);
|
|
276
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
277
|
+
}
|
|
278
|
+
function getCsrfToken() {
|
|
279
|
+
return getCookie("next-auth.csrf-token");
|
|
280
|
+
}
|
|
281
|
+
function getAuthToken() {
|
|
282
|
+
return getCookie("next-auth.session-token") || getCookie("__Secure-next-auth.session-token") || getCookie("authjs.session-token") || getCookie("__Secure-authjs.session-token");
|
|
283
|
+
}
|
|
284
|
+
function headersToRecord(items) {
|
|
285
|
+
const record = {};
|
|
286
|
+
for (const item of items) {
|
|
287
|
+
if (item.enabled && item.key.trim()) {
|
|
288
|
+
record[item.key.trim()] = item.value;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return record;
|
|
292
|
+
}
|
|
293
|
+
function parseUrlParams(url) {
|
|
294
|
+
try {
|
|
295
|
+
const qIndex = url.indexOf("?");
|
|
296
|
+
if (qIndex === -1) {
|
|
297
|
+
return { baseUrl: url, params: [{ key: "", value: "", enabled: true }] };
|
|
298
|
+
}
|
|
299
|
+
const baseUrl = url.slice(0, qIndex);
|
|
300
|
+
const queryString = url.slice(qIndex + 1);
|
|
301
|
+
const searchParams = new URLSearchParams(queryString);
|
|
302
|
+
const params = [];
|
|
303
|
+
searchParams.forEach((value, key) => {
|
|
304
|
+
params.push({ key, value, enabled: true });
|
|
305
|
+
});
|
|
306
|
+
if (params.length === 0) {
|
|
307
|
+
params.push({ key: "", value: "", enabled: true });
|
|
308
|
+
}
|
|
309
|
+
return { baseUrl, params };
|
|
310
|
+
} catch {
|
|
311
|
+
return { baseUrl: url, params: [{ key: "", value: "", enabled: true }] };
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function buildUrl(baseUrl, params) {
|
|
315
|
+
const activeParams = params.filter((p) => p.enabled && p.key.trim() !== "");
|
|
316
|
+
if (activeParams.length === 0) {
|
|
317
|
+
return baseUrl;
|
|
318
|
+
}
|
|
319
|
+
const searchParams = new URLSearchParams();
|
|
320
|
+
activeParams.forEach((p) => {
|
|
321
|
+
searchParams.append(p.key.trim(), p.value);
|
|
322
|
+
});
|
|
323
|
+
const queryString = searchParams.toString();
|
|
324
|
+
return queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
|
325
|
+
}
|
|
326
|
+
function getAuthInfo() {
|
|
327
|
+
return {
|
|
328
|
+
csrfToken: getCsrfToken(),
|
|
329
|
+
authToken: getAuthToken()
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
async function executeRequest(config) {
|
|
333
|
+
const headers = new Headers(headersToRecord(config.headers));
|
|
334
|
+
const csrfToken = getCsrfToken();
|
|
335
|
+
if (csrfToken) {
|
|
336
|
+
headers.set("X-CSRF-Token", csrfToken);
|
|
337
|
+
}
|
|
338
|
+
if (!headers.has("Content-Type") && config.body && config.method !== "GET") {
|
|
339
|
+
headers.set("Content-Type", "application/json");
|
|
340
|
+
}
|
|
341
|
+
const start = performance.now();
|
|
342
|
+
const res = await fetch(config.url, {
|
|
343
|
+
method: config.method,
|
|
344
|
+
headers,
|
|
345
|
+
body: config.body && config.method !== "GET" ? config.body : void 0,
|
|
346
|
+
credentials: "same-origin"
|
|
347
|
+
});
|
|
348
|
+
const duration = Math.round(performance.now() - start);
|
|
349
|
+
let body;
|
|
350
|
+
try {
|
|
351
|
+
body = await res.text();
|
|
352
|
+
} catch {
|
|
353
|
+
body = "";
|
|
354
|
+
}
|
|
355
|
+
const responseHeaders = {};
|
|
356
|
+
res.headers.forEach((value, key) => {
|
|
357
|
+
responseHeaders[key] = value;
|
|
358
|
+
});
|
|
359
|
+
return {
|
|
360
|
+
status: res.status,
|
|
361
|
+
statusText: res.statusText,
|
|
362
|
+
body,
|
|
363
|
+
headers: responseHeaders,
|
|
364
|
+
duration
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// src/store/useTesterStore.ts
|
|
369
|
+
var idCounter = 0;
|
|
370
|
+
function generateId() {
|
|
371
|
+
idCounter += 1;
|
|
372
|
+
return `req_${Date.now()}_${idCounter}`;
|
|
373
|
+
}
|
|
374
|
+
function createDefaultHeaders() {
|
|
375
|
+
return [{ key: "", value: "", enabled: true }];
|
|
376
|
+
}
|
|
377
|
+
function createDefaultParams() {
|
|
378
|
+
return [{ key: "", value: "", enabled: true }];
|
|
379
|
+
}
|
|
380
|
+
var useTesterStore = create()(
|
|
381
|
+
persist(
|
|
382
|
+
(set, get) => ({
|
|
383
|
+
url: "",
|
|
384
|
+
method: "GET",
|
|
385
|
+
headers: createDefaultHeaders(),
|
|
386
|
+
params: createDefaultParams(),
|
|
387
|
+
body: "",
|
|
388
|
+
history: [],
|
|
389
|
+
loading: false,
|
|
390
|
+
setUrl: (url) => {
|
|
391
|
+
const parsed = parseUrlParams(url);
|
|
392
|
+
set({ url, params: parsed.params });
|
|
393
|
+
},
|
|
394
|
+
setMethod: (method) => set({ method }),
|
|
395
|
+
setHeaders: (headers) => set({ headers }),
|
|
396
|
+
addHeader: () => set((state) => ({
|
|
397
|
+
headers: [...state.headers, { key: "", value: "", enabled: true }]
|
|
398
|
+
})),
|
|
399
|
+
removeHeader: (index) => set((state) => ({
|
|
400
|
+
headers: state.headers.filter((_, i) => i !== index)
|
|
401
|
+
})),
|
|
402
|
+
updateHeader: (index, field, value) => set((state) => ({
|
|
403
|
+
headers: state.headers.map(
|
|
404
|
+
(h, i) => i === index ? { ...h, [field]: value } : h
|
|
405
|
+
)
|
|
406
|
+
})),
|
|
407
|
+
setParams: (params) => {
|
|
408
|
+
const currentUrl = get().url;
|
|
409
|
+
const qIndex = currentUrl.indexOf("?");
|
|
410
|
+
const baseUrl = qIndex === -1 ? currentUrl : currentUrl.slice(0, qIndex);
|
|
411
|
+
const newUrl = buildUrl(baseUrl, params);
|
|
412
|
+
set({ params, url: newUrl });
|
|
413
|
+
},
|
|
414
|
+
addParam: () => {
|
|
415
|
+
const newParams = [...get().params, { key: "", value: "", enabled: true }];
|
|
416
|
+
get().setParams(newParams);
|
|
417
|
+
},
|
|
418
|
+
removeParam: (index) => {
|
|
419
|
+
const newParams = get().params.filter((_, i) => i !== index);
|
|
420
|
+
get().setParams(newParams);
|
|
421
|
+
},
|
|
422
|
+
updateParam: (index, field, value) => {
|
|
423
|
+
const newParams = get().params.map(
|
|
424
|
+
(p, i) => i === index ? { ...p, [field]: value } : p
|
|
425
|
+
);
|
|
426
|
+
get().setParams(newParams);
|
|
427
|
+
},
|
|
428
|
+
setBody: (body) => set({ body }),
|
|
429
|
+
executeRequest: async () => {
|
|
430
|
+
const { url, method, headers, params, body } = get();
|
|
431
|
+
set({ loading: true });
|
|
432
|
+
const entry = {
|
|
433
|
+
id: generateId(),
|
|
434
|
+
timestamp: Date.now(),
|
|
435
|
+
config: { url, method, headers, params, body },
|
|
436
|
+
response: null
|
|
437
|
+
};
|
|
438
|
+
try {
|
|
439
|
+
const result = await executeRequest({ url, method, headers, params, body });
|
|
440
|
+
entry.response = result;
|
|
441
|
+
} catch (err) {
|
|
442
|
+
entry.error = err instanceof Error ? err.message : "Unknown error";
|
|
443
|
+
}
|
|
444
|
+
set((state) => ({
|
|
445
|
+
loading: false,
|
|
446
|
+
history: [entry, ...state.history].slice(0, 100)
|
|
447
|
+
}));
|
|
448
|
+
return entry;
|
|
449
|
+
},
|
|
450
|
+
loadFromHistory: (entry) => set({
|
|
451
|
+
url: entry.config.url,
|
|
452
|
+
method: entry.config.method,
|
|
453
|
+
headers: entry.config.headers || createDefaultHeaders(),
|
|
454
|
+
params: entry.config.params || createDefaultParams(),
|
|
455
|
+
body: entry.config.body
|
|
456
|
+
}),
|
|
457
|
+
clearHistory: () => set({ history: [] })
|
|
458
|
+
}),
|
|
459
|
+
{
|
|
460
|
+
name: "api-client-history",
|
|
461
|
+
partialize: (state) => ({ history: state.history })
|
|
462
|
+
}
|
|
463
|
+
)
|
|
464
|
+
);
|
|
465
|
+
|
|
466
|
+
// src/components/RequestPanel.tsx
|
|
467
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
468
|
+
var METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"];
|
|
469
|
+
function RequestPanel() {
|
|
470
|
+
const {
|
|
471
|
+
url,
|
|
472
|
+
method,
|
|
473
|
+
headers,
|
|
474
|
+
params,
|
|
475
|
+
body,
|
|
476
|
+
loading,
|
|
477
|
+
setUrl,
|
|
478
|
+
setMethod,
|
|
479
|
+
setBody,
|
|
480
|
+
addHeader,
|
|
481
|
+
removeHeader,
|
|
482
|
+
updateHeader,
|
|
483
|
+
addParam,
|
|
484
|
+
removeParam,
|
|
485
|
+
updateParam,
|
|
486
|
+
executeRequest: executeRequest2
|
|
487
|
+
} = useTesterStore();
|
|
488
|
+
const [activeTab, setActiveTab] = useState("params");
|
|
489
|
+
return /* @__PURE__ */ jsxs("div", { className: "nat-flex nat-flex-col nat-gap-4 nat-h-full", children: [
|
|
490
|
+
/* @__PURE__ */ jsxs("div", { className: "nat-flex nat-gap-2", children: [
|
|
491
|
+
/* @__PURE__ */ jsx(
|
|
492
|
+
"select",
|
|
493
|
+
{
|
|
494
|
+
value: method,
|
|
495
|
+
onChange: (e) => setMethod(e.target.value),
|
|
496
|
+
className: "nat-px-3 nat-py-2 nat-rounded nat-border nat-border-neutral-700 nat-bg-neutral-800 nat-text-sm nat-font-bold nat-text-neutral-200 focus:nat-outline-none focus:nat-border-orange-500 focus:nat-ring-1 focus:nat-ring-orange-500/50",
|
|
497
|
+
children: METHODS.map((m) => /* @__PURE__ */ jsx("option", { value: m, children: m }, m))
|
|
498
|
+
}
|
|
499
|
+
),
|
|
500
|
+
/* @__PURE__ */ jsx(
|
|
501
|
+
"input",
|
|
502
|
+
{
|
|
503
|
+
type: "text",
|
|
504
|
+
placeholder: "https://localhost:3000/api/...",
|
|
505
|
+
value: url,
|
|
506
|
+
onChange: (e) => setUrl(e.target.value),
|
|
507
|
+
onKeyDown: (e) => {
|
|
508
|
+
if (e.key === "Enter") executeRequest2();
|
|
509
|
+
},
|
|
510
|
+
className: "nat-flex-1 nat-px-3 nat-py-2 nat-rounded nat-border nat-border-neutral-700 nat-bg-neutral-900 nat-text-neutral-200 nat-text-sm focus:nat-outline-none focus:nat-border-orange-500 focus:nat-ring-1 focus:nat-ring-orange-500/50 placeholder:nat-text-neutral-600 font-mono"
|
|
511
|
+
}
|
|
512
|
+
),
|
|
513
|
+
/* @__PURE__ */ jsx(
|
|
514
|
+
"button",
|
|
515
|
+
{
|
|
516
|
+
onClick: () => executeRequest2(),
|
|
517
|
+
disabled: loading || !url.trim(),
|
|
518
|
+
className: "nat-px-6 nat-py-2 nat-rounded nat-bg-orange-600 nat-text-white nat-text-sm nat-font-semibold hover:nat-bg-orange-700 disabled:nat-opacity-50 disabled:nat-cursor-not-allowed nat-transition-colors",
|
|
519
|
+
children: loading ? "Sending..." : "Send"
|
|
520
|
+
}
|
|
521
|
+
)
|
|
522
|
+
] }),
|
|
523
|
+
/* @__PURE__ */ jsxs("div", { className: "nat-flex nat-flex-col nat-flex-1 nat-overflow-hidden", children: [
|
|
524
|
+
/* @__PURE__ */ jsxs("div", { className: "nat-flex nat-gap-6 nat-border-b nat-border-neutral-800 nat-mb-3", children: [
|
|
525
|
+
/* @__PURE__ */ jsxs(TabButton, { active: activeTab === "params", onClick: () => setActiveTab("params"), children: [
|
|
526
|
+
"Params (",
|
|
527
|
+
params.filter((p) => p.key.trim()).length,
|
|
528
|
+
")"
|
|
529
|
+
] }),
|
|
530
|
+
/* @__PURE__ */ jsxs(TabButton, { active: activeTab === "headers", onClick: () => setActiveTab("headers"), children: [
|
|
531
|
+
"Headers (",
|
|
532
|
+
headers.filter((h) => h.key.trim()).length,
|
|
533
|
+
")"
|
|
534
|
+
] }),
|
|
535
|
+
/* @__PURE__ */ jsx(TabButton, { active: activeTab === "body", onClick: () => setActiveTab("body"), children: "Body" })
|
|
536
|
+
] }),
|
|
537
|
+
/* @__PURE__ */ jsxs("div", { className: "nat-flex-1 nat-overflow-y-auto nat-scrollbar", children: [
|
|
538
|
+
activeTab === "params" && /* @__PURE__ */ jsx(
|
|
539
|
+
KeyValueTable,
|
|
540
|
+
{
|
|
541
|
+
items: params,
|
|
542
|
+
onAdd: addParam,
|
|
543
|
+
onRemove: removeParam,
|
|
544
|
+
onUpdate: updateParam,
|
|
545
|
+
placeholderKey: "Query Param"
|
|
546
|
+
}
|
|
547
|
+
),
|
|
548
|
+
activeTab === "headers" && /* @__PURE__ */ jsx(
|
|
549
|
+
KeyValueTable,
|
|
550
|
+
{
|
|
551
|
+
items: headers,
|
|
552
|
+
onAdd: addHeader,
|
|
553
|
+
onRemove: removeHeader,
|
|
554
|
+
onUpdate: updateHeader,
|
|
555
|
+
placeholderKey: "Header"
|
|
556
|
+
}
|
|
557
|
+
),
|
|
558
|
+
activeTab === "body" && /* @__PURE__ */ jsx("div", { className: "nat-flex nat-flex-col nat-h-full", children: method === "GET" || method === "HEAD" ? /* @__PURE__ */ jsxs("div", { className: "nat-text-sm nat-text-neutral-500 nat-p-4 nat-text-center", children: [
|
|
559
|
+
method,
|
|
560
|
+
" requests generally do not contain a body."
|
|
561
|
+
] }) : /* @__PURE__ */ jsx(
|
|
562
|
+
"textarea",
|
|
563
|
+
{
|
|
564
|
+
value: body,
|
|
565
|
+
onChange: (e) => setBody(e.target.value),
|
|
566
|
+
placeholder: '{"key": "value"}',
|
|
567
|
+
className: "nat-w-full nat-flex-1 nat-min-h-[150px] nat-p-3 nat-rounded nat-border nat-border-neutral-800 nat-bg-neutral-900 nat-text-xs nat-font-mono nat-text-neutral-300 nat-resize-y focus:nat-outline-none focus:nat-border-orange-500 focus:nat-ring-1 focus:nat-ring-orange-500/50",
|
|
568
|
+
spellCheck: false
|
|
569
|
+
}
|
|
570
|
+
) })
|
|
571
|
+
] })
|
|
572
|
+
] })
|
|
573
|
+
] });
|
|
574
|
+
}
|
|
575
|
+
function TabButton({ active, onClick, children }) {
|
|
576
|
+
return /* @__PURE__ */ jsx(
|
|
577
|
+
"button",
|
|
578
|
+
{
|
|
579
|
+
onClick,
|
|
580
|
+
className: `nat-pb-2 nat-text-sm nat-font-medium nat-transition-colors nat-border-b-2 ${active ? "nat-text-orange-500 nat-border-orange-500" : "nat-text-neutral-400 nat-border-transparent hover:nat-text-neutral-300"}`,
|
|
581
|
+
children
|
|
582
|
+
}
|
|
583
|
+
);
|
|
584
|
+
}
|
|
585
|
+
function KeyValueTable({
|
|
586
|
+
items,
|
|
587
|
+
onAdd,
|
|
588
|
+
onRemove,
|
|
589
|
+
onUpdate,
|
|
590
|
+
placeholderKey
|
|
591
|
+
}) {
|
|
592
|
+
return /* @__PURE__ */ jsxs("div", { className: "nat-flex nat-flex-col nat-gap-1.5", children: [
|
|
593
|
+
items.map((item, i) => /* @__PURE__ */ jsxs("div", { className: "nat-flex nat-gap-2 nat-items-center nat-group", children: [
|
|
594
|
+
/* @__PURE__ */ jsx(
|
|
595
|
+
"input",
|
|
596
|
+
{
|
|
597
|
+
type: "checkbox",
|
|
598
|
+
checked: item.enabled,
|
|
599
|
+
onChange: (e) => onUpdate(i, "enabled", e.target.checked),
|
|
600
|
+
className: "nat-w-3.5 nat-h-3.5 nat-accent-orange-500"
|
|
601
|
+
}
|
|
602
|
+
),
|
|
603
|
+
/* @__PURE__ */ jsx(
|
|
604
|
+
"input",
|
|
605
|
+
{
|
|
606
|
+
type: "text",
|
|
607
|
+
placeholder: placeholderKey,
|
|
608
|
+
value: item.key,
|
|
609
|
+
onChange: (e) => onUpdate(i, "key", e.target.value),
|
|
610
|
+
className: "nat-flex-1 nat-px-2.5 nat-py-1.5 nat-rounded nat-border nat-border-neutral-800 nat-bg-neutral-900 nat-text-xs nat-font-mono nat-text-neutral-200 placeholder:nat-text-neutral-600 focus:nat-outline-none focus:nat-border-neutral-600"
|
|
611
|
+
}
|
|
612
|
+
),
|
|
613
|
+
/* @__PURE__ */ jsx(
|
|
614
|
+
"input",
|
|
615
|
+
{
|
|
616
|
+
type: "text",
|
|
617
|
+
placeholder: "Value",
|
|
618
|
+
value: item.value,
|
|
619
|
+
onChange: (e) => onUpdate(i, "value", e.target.value),
|
|
620
|
+
className: "nat-flex-1 nat-px-2.5 nat-py-1.5 nat-rounded nat-border nat-border-neutral-800 nat-bg-neutral-900 nat-text-xs nat-font-mono nat-text-neutral-200 placeholder:nat-text-neutral-600 focus:nat-outline-none focus:nat-border-neutral-600"
|
|
621
|
+
}
|
|
622
|
+
),
|
|
623
|
+
/* @__PURE__ */ jsx(
|
|
624
|
+
"button",
|
|
625
|
+
{
|
|
626
|
+
onClick: () => onRemove(i),
|
|
627
|
+
className: "nat-w-6 nat-h-6 nat-flex nat-items-center nat-justify-center nat-text-neutral-600 hover:nat-text-rose-500 nat-transition-colors nat-opacity-0 group-hover:nat-opacity-100",
|
|
628
|
+
title: "Remove",
|
|
629
|
+
children: "\u2715"
|
|
630
|
+
}
|
|
631
|
+
)
|
|
632
|
+
] }, i)),
|
|
633
|
+
/* @__PURE__ */ jsxs(
|
|
634
|
+
"button",
|
|
635
|
+
{
|
|
636
|
+
onClick: onAdd,
|
|
637
|
+
className: "nat-text-xs nat-text-orange-500 hover:nat-text-orange-400 nat-text-left nat-py-2 nat-mt-1 nat-w-max nat-font-medium",
|
|
638
|
+
children: [
|
|
639
|
+
"+ Add ",
|
|
640
|
+
placeholderKey
|
|
641
|
+
]
|
|
642
|
+
}
|
|
643
|
+
)
|
|
644
|
+
] });
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// src/components/ResponsePanel.tsx
|
|
648
|
+
import { useMemo, useState as useState2 } from "react";
|
|
649
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
650
|
+
function ResponsePanel() {
|
|
651
|
+
const history = useTesterStore((s) => s.history);
|
|
652
|
+
const latest = history[0];
|
|
653
|
+
const [activeTab, setActiveTab] = useState2("body");
|
|
654
|
+
const authInfo = useMemo(() => {
|
|
655
|
+
try {
|
|
656
|
+
return getAuthInfo();
|
|
657
|
+
} catch {
|
|
658
|
+
return { csrfToken: null, authToken: null };
|
|
659
|
+
}
|
|
660
|
+
}, [history]);
|
|
661
|
+
if (!latest) {
|
|
662
|
+
return /* @__PURE__ */ jsxs2("div", { className: "nat-flex-1 nat-flex nat-flex-col nat-items-center nat-justify-center nat-text-neutral-500 nat-text-sm nat-h-full", children: [
|
|
663
|
+
authInfo.authToken ? /* @__PURE__ */ jsx2("div", { className: "nat-text-emerald-500 nat-text-xs nat-mb-3 nat-font-medium nat-px-3 nat-py-1 nat-bg-emerald-500/10 nat-rounded-full", children: "\u25CF Authenticated (NextAuth session detected)" }) : /* @__PURE__ */ jsx2("div", { className: "nat-text-amber-500 nat-text-xs nat-mb-3 nat-font-medium nat-px-3 nat-py-1 nat-bg-amber-500/10 nat-rounded-full", children: "\u25CB No NextAuth session detected" }),
|
|
664
|
+
/* @__PURE__ */ jsx2("div", { className: "nat-text-neutral-600", children: "Send a request to see the response" })
|
|
665
|
+
] });
|
|
666
|
+
}
|
|
667
|
+
const response = latest.response;
|
|
668
|
+
const isError = !!latest.error || !response;
|
|
669
|
+
if (isError) {
|
|
670
|
+
return /* @__PURE__ */ jsxs2("div", { className: "nat-flex-1 nat-flex nat-flex-col nat-gap-3 nat-p-4", children: [
|
|
671
|
+
/* @__PURE__ */ jsxs2("div", { className: "nat-text-rose-500 nat-font-semibold nat-text-sm nat-flex nat-items-center nat-gap-2", children: [
|
|
672
|
+
/* @__PURE__ */ jsx2("span", { className: "nat-w-2 nat-h-2 nat-rounded-full nat-bg-rose-500" }),
|
|
673
|
+
" Request Failed"
|
|
674
|
+
] }),
|
|
675
|
+
/* @__PURE__ */ jsx2("pre", { className: "nat-text-xs nat-text-rose-400/80 nat-whitespace-pre-wrap nat-break-all nat-bg-rose-950/20 nat-p-4 nat-rounded nat-border nat-border-rose-900/50", children: latest.error || "No response received" })
|
|
676
|
+
] });
|
|
677
|
+
}
|
|
678
|
+
const formattedBody = formatJson(response.body);
|
|
679
|
+
let statusColor = "nat-text-rose-500 nat-bg-rose-500/10 nat-border-rose-500/20";
|
|
680
|
+
if (response.status < 300) {
|
|
681
|
+
statusColor = "nat-text-emerald-400 nat-bg-emerald-500/10 nat-border-emerald-500/20";
|
|
682
|
+
} else if (response.status < 500) {
|
|
683
|
+
statusColor = "nat-text-amber-400 nat-bg-amber-500/10 nat-border-amber-500/20";
|
|
684
|
+
}
|
|
685
|
+
return /* @__PURE__ */ jsxs2("div", { className: "nat-flex-1 nat-flex nat-flex-col nat-h-full", children: [
|
|
686
|
+
/* @__PURE__ */ jsxs2("div", { className: "nat-flex nat-items-center nat-justify-between nat-px-4 nat-py-3 nat-bg-neutral-900 nat-border-b nat-border-neutral-800", children: [
|
|
687
|
+
/* @__PURE__ */ jsxs2("div", { className: "nat-flex nat-items-center nat-gap-3 nat-flex-wrap", children: [
|
|
688
|
+
/* @__PURE__ */ jsxs2("span", { className: `nat-font-semibold nat-text-[11px] nat-px-2 nat-py-1 nat-rounded nat-border ${statusColor}`, children: [
|
|
689
|
+
response.status,
|
|
690
|
+
" ",
|
|
691
|
+
response.statusText
|
|
692
|
+
] }),
|
|
693
|
+
/* @__PURE__ */ jsxs2("span", { className: "nat-text-[11px] nat-font-medium nat-text-neutral-400 nat-bg-neutral-800 nat-px-2 nat-py-1 nat-rounded nat-border nat-border-neutral-700", children: [
|
|
694
|
+
response.duration,
|
|
695
|
+
" ms"
|
|
696
|
+
] }),
|
|
697
|
+
/* @__PURE__ */ jsx2("span", { className: "nat-text-[11px] nat-font-medium nat-text-neutral-400 nat-bg-neutral-800 nat-px-2 nat-py-1 nat-rounded nat-border nat-border-neutral-700", children: formatBytes(response.body.length) })
|
|
698
|
+
] }),
|
|
699
|
+
/* @__PURE__ */ jsx2("div", { className: "nat-flex nat-items-center nat-gap-2", children: /* @__PURE__ */ jsx2(AuthBadge, {}) })
|
|
700
|
+
] }),
|
|
701
|
+
/* @__PURE__ */ jsxs2("div", { className: "nat-flex nat-gap-6 nat-px-4 nat-border-b nat-border-neutral-800 nat-bg-neutral-900/50", children: [
|
|
702
|
+
/* @__PURE__ */ jsx2(TabButton2, { active: activeTab === "body", onClick: () => setActiveTab("body"), children: "Body" }),
|
|
703
|
+
/* @__PURE__ */ jsxs2(TabButton2, { active: activeTab === "headers", onClick: () => setActiveTab("headers"), children: [
|
|
704
|
+
"Headers (",
|
|
705
|
+
Object.keys(response.headers).length,
|
|
706
|
+
")"
|
|
707
|
+
] })
|
|
708
|
+
] }),
|
|
709
|
+
/* @__PURE__ */ jsxs2("div", { className: "nat-flex-1 nat-overflow-y-auto nat-scrollbar nat-bg-neutral-950 nat-p-4", children: [
|
|
710
|
+
activeTab === "body" && /* @__PURE__ */ jsxs2("div", { className: "nat-relative nat-group", children: [
|
|
711
|
+
/* @__PURE__ */ jsx2("div", { className: "nat-absolute nat-top-2 nat-right-2 nat-opacity-0 group-hover:nat-opacity-100 nat-transition-opacity", children: /* @__PURE__ */ jsx2(CopyButton, { text: formattedBody || response.body }) }),
|
|
712
|
+
/* @__PURE__ */ jsx2("pre", { className: "nat-text-xs nat-text-emerald-400/90 nat-whitespace-pre-wrap nat-break-all nat-font-mono nat-leading-relaxed", children: formattedBody || /* @__PURE__ */ jsx2("span", { className: "nat-text-neutral-600 italic", children: "No content in response body" }) })
|
|
713
|
+
] }),
|
|
714
|
+
activeTab === "headers" && /* @__PURE__ */ jsx2("div", { className: "nat-flex nat-flex-col nat-gap-px nat-bg-neutral-800 nat-rounded nat-overflow-hidden nat-border nat-border-neutral-800", children: Object.entries(response.headers).map(([key, value]) => /* @__PURE__ */ jsxs2("div", { className: "nat-flex nat-text-xs nat-bg-neutral-900 hover:nat-bg-neutral-800/80 nat-transition-colors", children: [
|
|
715
|
+
/* @__PURE__ */ jsx2("div", { className: "nat-w-1/3 nat-p-2 nat-font-semibold nat-text-neutral-400 nat-border-r nat-border-neutral-800 nat-break-all", children: key }),
|
|
716
|
+
/* @__PURE__ */ jsx2("div", { className: "nat-w-2/3 nat-p-2 nat-text-neutral-300 nat-font-mono nat-break-all", children: value })
|
|
717
|
+
] }, key)) })
|
|
718
|
+
] })
|
|
719
|
+
] });
|
|
720
|
+
}
|
|
721
|
+
function TabButton2({ active, onClick, children }) {
|
|
722
|
+
return /* @__PURE__ */ jsx2(
|
|
723
|
+
"button",
|
|
724
|
+
{
|
|
725
|
+
onClick,
|
|
726
|
+
className: `nat-py-2.5 nat-text-sm nat-font-medium nat-transition-colors nat-border-b-2 -nat-mb-px ${active ? "nat-text-orange-500 nat-border-orange-500" : "nat-text-neutral-400 nat-border-transparent hover:nat-text-neutral-300"}`,
|
|
727
|
+
children
|
|
728
|
+
}
|
|
729
|
+
);
|
|
730
|
+
}
|
|
731
|
+
function AuthBadge() {
|
|
732
|
+
try {
|
|
733
|
+
const { authToken } = getAuthInfo();
|
|
734
|
+
if (authToken) {
|
|
735
|
+
return /* @__PURE__ */ jsxs2("span", { className: "nat-inline-flex nat-items-center nat-gap-1.5 nat-text-[10px] nat-font-medium nat-text-emerald-400 nat-bg-emerald-500/10 nat-border nat-border-emerald-500/20 nat-px-2 nat-py-1 nat-rounded-full", children: [
|
|
736
|
+
/* @__PURE__ */ jsx2("span", { className: "nat-w-1.5 nat-h-1.5 nat-rounded-full nat-bg-emerald-500" }),
|
|
737
|
+
" Session"
|
|
738
|
+
] });
|
|
739
|
+
}
|
|
740
|
+
} catch {
|
|
741
|
+
}
|
|
742
|
+
return null;
|
|
743
|
+
}
|
|
744
|
+
function CopyButton({ text }) {
|
|
745
|
+
return /* @__PURE__ */ jsx2(
|
|
746
|
+
"button",
|
|
747
|
+
{
|
|
748
|
+
onClick: () => {
|
|
749
|
+
navigator.clipboard.writeText(text).catch(() => {
|
|
750
|
+
});
|
|
751
|
+
},
|
|
752
|
+
className: "nat-px-2 nat-py-1 nat-bg-neutral-800 hover:nat-bg-neutral-700 nat-border nat-border-neutral-700 nat-rounded nat-text-[10px] nat-font-medium nat-text-neutral-300 nat-transition-colors",
|
|
753
|
+
children: "Copy"
|
|
754
|
+
}
|
|
755
|
+
);
|
|
756
|
+
}
|
|
757
|
+
function formatJson(raw) {
|
|
758
|
+
if (!raw) return "";
|
|
759
|
+
try {
|
|
760
|
+
return JSON.stringify(JSON.parse(raw), null, 2);
|
|
761
|
+
} catch {
|
|
762
|
+
return raw;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
function formatBytes(bytes) {
|
|
766
|
+
if (bytes === 0) return "0 B";
|
|
767
|
+
const k = 1024;
|
|
768
|
+
const sizes = ["B", "KB", "MB", "GB"];
|
|
769
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
770
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i];
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// src/components/Sidebar.tsx
|
|
774
|
+
import { useState as useState3 } from "react";
|
|
775
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
776
|
+
var METHOD_COLORS = {
|
|
777
|
+
GET: "nat-text-emerald-400 nat-bg-emerald-500/10",
|
|
778
|
+
POST: "nat-text-amber-400 nat-bg-amber-500/10",
|
|
779
|
+
PUT: "nat-text-blue-400 nat-bg-blue-500/10",
|
|
780
|
+
PATCH: "nat-text-purple-400 nat-bg-purple-500/10",
|
|
781
|
+
DELETE: "nat-text-rose-400 nat-bg-rose-500/10",
|
|
782
|
+
HEAD: "nat-text-zinc-400 nat-bg-zinc-500/10",
|
|
783
|
+
OPTIONS: "nat-text-zinc-400 nat-bg-zinc-500/10"
|
|
784
|
+
};
|
|
785
|
+
function Sidebar() {
|
|
786
|
+
const history = useTesterStore((s) => s.history);
|
|
787
|
+
const loadFromHistory = useTesterStore((s) => s.loadFromHistory);
|
|
788
|
+
const clearHistory = useTesterStore((s) => s.clearHistory);
|
|
789
|
+
const [search, setSearch] = useState3("");
|
|
790
|
+
const filteredHistory = history.filter(
|
|
791
|
+
(entry) => entry.config.url.toLowerCase().includes(search.toLowerCase())
|
|
792
|
+
);
|
|
793
|
+
return /* @__PURE__ */ jsxs3("div", { className: "nat-w-72 nat-flex nat-flex-col nat-h-full nat-bg-neutral-900/50", children: [
|
|
794
|
+
/* @__PURE__ */ jsxs3("div", { className: "nat-p-4 nat-flex nat-flex-col nat-gap-3 nat-border-b nat-border-neutral-800", children: [
|
|
795
|
+
/* @__PURE__ */ jsxs3("div", { className: "nat-flex nat-justify-between nat-items-center", children: [
|
|
796
|
+
/* @__PURE__ */ jsx3("span", { className: "nat-text-sm nat-font-medium nat-text-neutral-200", children: "History" }),
|
|
797
|
+
history.length > 0 && /* @__PURE__ */ jsx3(
|
|
798
|
+
"button",
|
|
799
|
+
{
|
|
800
|
+
onClick: clearHistory,
|
|
801
|
+
className: "nat-text-[10px] nat-font-medium nat-text-neutral-500 hover:nat-text-rose-400 nat-transition-colors",
|
|
802
|
+
children: "Clear All"
|
|
803
|
+
}
|
|
804
|
+
)
|
|
805
|
+
] }),
|
|
806
|
+
/* @__PURE__ */ jsx3(
|
|
807
|
+
"input",
|
|
808
|
+
{
|
|
809
|
+
type: "text",
|
|
810
|
+
placeholder: "Filter...",
|
|
811
|
+
value: search,
|
|
812
|
+
onChange: (e) => setSearch(e.target.value),
|
|
813
|
+
className: "nat-w-full nat-px-2 nat-py-1.5 nat-bg-neutral-950/50 nat-border nat-border-neutral-800 nat-rounded nat-text-xs nat-text-neutral-200 placeholder:nat-text-neutral-600 focus:nat-outline-none focus:nat-border-orange-500 focus:nat-ring-1 focus:nat-ring-orange-500/50 nat-transition-all"
|
|
814
|
+
}
|
|
815
|
+
)
|
|
816
|
+
] }),
|
|
817
|
+
/* @__PURE__ */ jsx3("div", { className: "nat-flex-1 nat-overflow-y-auto nat-scrollbar", children: filteredHistory.length === 0 ? /* @__PURE__ */ jsx3("div", { className: "nat-p-6 nat-text-xs nat-text-neutral-500 nat-text-center", children: history.length === 0 ? "No requests yet" : "No matches found" }) : /* @__PURE__ */ jsx3("div", { className: "nat-flex nat-flex-col", children: filteredHistory.map((entry) => /* @__PURE__ */ jsx3(
|
|
818
|
+
HistoryItem,
|
|
819
|
+
{
|
|
820
|
+
entry,
|
|
821
|
+
onClick: () => loadFromHistory(entry)
|
|
822
|
+
},
|
|
823
|
+
entry.id
|
|
824
|
+
)) }) })
|
|
825
|
+
] });
|
|
826
|
+
}
|
|
827
|
+
function HistoryItem({
|
|
828
|
+
entry,
|
|
829
|
+
onClick
|
|
830
|
+
}) {
|
|
831
|
+
const status = entry.response?.status;
|
|
832
|
+
const hasError = !!entry.error || !entry.response;
|
|
833
|
+
return /* @__PURE__ */ jsxs3(
|
|
834
|
+
"button",
|
|
835
|
+
{
|
|
836
|
+
onClick,
|
|
837
|
+
className: "nat-w-full nat-text-left nat-px-4 nat-py-3 nat-border-b nat-border-neutral-800/50 hover:nat-bg-neutral-800/50 nat-transition-colors nat-group",
|
|
838
|
+
children: [
|
|
839
|
+
/* @__PURE__ */ jsxs3("div", { className: "nat-flex nat-items-center nat-justify-between nat-mb-1.5", children: [
|
|
840
|
+
/* @__PURE__ */ jsxs3("div", { className: "nat-flex nat-items-center nat-gap-2", children: [
|
|
841
|
+
/* @__PURE__ */ jsx3(
|
|
842
|
+
"span",
|
|
843
|
+
{
|
|
844
|
+
className: `nat-px-1.5 nat-py-0.5 nat-rounded nat-text-[9px] nat-font-bold nat-uppercase ${METHOD_COLORS[entry.config.method]}`,
|
|
845
|
+
children: entry.config.method
|
|
846
|
+
}
|
|
847
|
+
),
|
|
848
|
+
status && /* @__PURE__ */ jsx3(
|
|
849
|
+
"span",
|
|
850
|
+
{
|
|
851
|
+
className: `nat-text-[10px] nat-font-medium ${status < 300 ? "nat-text-emerald-500" : status < 500 ? "nat-text-amber-500" : "nat-text-rose-500"}`,
|
|
852
|
+
children: status
|
|
853
|
+
}
|
|
854
|
+
),
|
|
855
|
+
hasError && /* @__PURE__ */ jsx3("span", { className: "nat-text-[10px] nat-font-medium nat-text-rose-500", children: "ERR" })
|
|
856
|
+
] }),
|
|
857
|
+
/* @__PURE__ */ jsx3("div", { className: "nat-text-[9px] nat-text-neutral-600 group-hover:nat-text-neutral-500 nat-transition-colors", children: new Date(entry.timestamp).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
|
|
858
|
+
] }),
|
|
859
|
+
/* @__PURE__ */ jsx3("div", { className: "nat-text-[11px] nat-text-neutral-400 nat-truncate group-hover:nat-text-neutral-300 nat-transition-colors", children: entry.config.url || "(empty URL)" })
|
|
860
|
+
]
|
|
861
|
+
}
|
|
862
|
+
);
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
// src/components/ApiTester.tsx
|
|
866
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
867
|
+
function ApiTester() {
|
|
868
|
+
if (globalThis.window !== void 0 && process.env.NODE_ENV !== "development") {
|
|
869
|
+
return /* @__PURE__ */ jsx4("div", { className: "nat-flex nat-items-center nat-justify-center nat-h-screen nat-bg-neutral-950 nat-text-neutral-300", children: /* @__PURE__ */ jsxs4("div", { className: "nat-text-center nat-max-w-md nat-p-8 nat-bg-neutral-900 nat-rounded-xl nat-border nat-border-neutral-800 nat-shadow-2xl", children: [
|
|
870
|
+
/* @__PURE__ */ jsx4("div", { className: "nat-text-rose-500 nat-text-xl nat-font-semibold nat-mb-3", children: "API Tester Disabled" }),
|
|
871
|
+
/* @__PURE__ */ jsxs4("div", { className: "nat-text-neutral-400 nat-text-sm", children: [
|
|
872
|
+
"This tool is exclusively available in development mode for security reasons. Please start your application with ",
|
|
873
|
+
/* @__PURE__ */ jsx4("code", { className: "nat-px-1 nat-py-0.5 nat-bg-neutral-800 nat-rounded", children: "npm run dev" }),
|
|
874
|
+
" to use it."
|
|
875
|
+
] })
|
|
876
|
+
] }) });
|
|
877
|
+
}
|
|
878
|
+
return /* @__PURE__ */ jsxs4("div", { className: "nat-flex nat-h-screen nat-w-full nat-bg-neutral-950 nat-text-neutral-300 nat-font-sans nat-overflow-hidden", children: [
|
|
879
|
+
/* @__PURE__ */ jsx4(Sidebar, {}),
|
|
880
|
+
/* @__PURE__ */ jsxs4("div", { className: "nat-flex-1 nat-flex nat-flex-col nat-border-l nat-border-neutral-800 nat-overflow-hidden nat-bg-neutral-950", children: [
|
|
881
|
+
/* @__PURE__ */ jsxs4("div", { className: "nat-flex nat-items-center nat-px-6 nat-py-3 nat-border-b nat-border-neutral-800 nat-bg-neutral-900/50", children: [
|
|
882
|
+
/* @__PURE__ */ jsxs4("div", { className: "nat-flex nat-items-center nat-gap-2", children: [
|
|
883
|
+
/* @__PURE__ */ jsx4("div", { className: "nat-w-6 nat-h-6 nat-rounded nat-bg-orange-600 nat-flex nat-items-center nat-justify-center nat-text-white nat-font-bold nat-text-xs", children: "N" }),
|
|
884
|
+
/* @__PURE__ */ jsx4("h1", { className: "nat-text-sm nat-font-semibold nat-text-neutral-100 nat-tracking-tight", children: "Next.js API Tester" })
|
|
885
|
+
] }),
|
|
886
|
+
/* @__PURE__ */ jsx4("div", { className: "nat-ml-auto nat-flex nat-items-center nat-gap-3", children: /* @__PURE__ */ jsx4("span", { className: "nat-px-2 nat-py-1 nat-bg-neutral-800 nat-border nat-border-neutral-700 nat-rounded nat-text-[10px] nat-font-mono nat-text-neutral-400", children: process.env.NODE_ENV || "development" }) })
|
|
887
|
+
] }),
|
|
888
|
+
/* @__PURE__ */ jsxs4("div", { className: "nat-flex-1 nat-flex nat-flex-col nat-overflow-hidden", children: [
|
|
889
|
+
/* @__PURE__ */ jsx4("div", { className: "nat-h-[45%] nat-min-h-[300px] nat-border-b nat-border-neutral-800 nat-overflow-y-auto nat-scrollbar nat-p-4", children: /* @__PURE__ */ jsx4(RequestPanel, {}) }),
|
|
890
|
+
/* @__PURE__ */ jsx4("div", { className: "nat-h-[55%] nat-min-h-[300px] nat-overflow-y-auto nat-scrollbar nat-p-0", children: /* @__PURE__ */ jsx4(ResponsePanel, {}) })
|
|
891
|
+
] })
|
|
892
|
+
] })
|
|
893
|
+
] });
|
|
894
|
+
}
|
|
895
|
+
export {
|
|
896
|
+
ApiTester,
|
|
897
|
+
executeRequest,
|
|
898
|
+
getAuthInfo,
|
|
899
|
+
useTesterStore
|
|
900
|
+
};
|
|
901
|
+
//# sourceMappingURL=index.mjs.map
|