fumadocs-openapi 5.11.8 → 6.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.ts +20 -71
- package/dist/index.js +21 -18
- package/dist/scalar/client-client-DgnHaOQ3.js +93 -0
- package/dist/scalar/index.d.ts +176 -0
- package/dist/scalar/index.js +13 -0
- package/dist/server/index.d.ts +24 -71
- package/dist/server/index.js +218 -212
- package/dist/ui/client-client-CpwKrzlY.js +107 -0
- package/dist/ui/{fetcher-Cc3BieIx.js → fetcher-Cey1qI8X.js} +1 -1
- package/dist/ui/{index-client-DPqAL2w9.js → index-client-CehDtJk-.js} +582 -434
- package/dist/ui/index.d.ts +32 -15
- package/dist/ui/index.js +33 -82
- package/dist/ui/server-select-client-CbFencmM.js +86 -0
- package/package.json +24 -11
- package/dist/ui/client-client-B06fJG48.js +0 -359
- package/dist/ui/server-select-client-CtG30byb.js +0 -101
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { forwardRef, createElement, useContext, createContext, useState, useRef, useEffect, useMemo } from 'react';
|
|
3
|
-
import { jsx } from 'react/jsx-runtime';
|
|
4
|
-
import { cn, useCopyButton, buttonVariants } from 'fumadocs-ui/components/api';
|
|
5
|
-
import dynamic from 'next/dynamic';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @license lucide-react v0.473.0 - ISC
|
|
9
|
-
*
|
|
10
|
-
* This source code is licensed under the ISC license.
|
|
11
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
-
*/ const toKebabCase = (string)=>string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
13
|
-
const mergeClasses = (...classes)=>classes.filter((className, index, array)=>{
|
|
14
|
-
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
|
|
15
|
-
}).join(" ").trim();
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @license lucide-react v0.473.0 - ISC
|
|
19
|
-
*
|
|
20
|
-
* This source code is licensed under the ISC license.
|
|
21
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
-
*/ var defaultAttributes = {
|
|
23
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
24
|
-
width: 24,
|
|
25
|
-
height: 24,
|
|
26
|
-
viewBox: "0 0 24 24",
|
|
27
|
-
fill: "none",
|
|
28
|
-
stroke: "currentColor",
|
|
29
|
-
strokeWidth: 2,
|
|
30
|
-
strokeLinecap: "round",
|
|
31
|
-
strokeLinejoin: "round"
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const Icon = /*#__PURE__*/ forwardRef(({ color = "currentColor", size = 24, strokeWidth = 2, absoluteStrokeWidth, className = "", children, iconNode, ...rest }, ref)=>{
|
|
35
|
-
return /*#__PURE__*/ createElement("svg", {
|
|
36
|
-
ref,
|
|
37
|
-
...defaultAttributes,
|
|
38
|
-
width: size,
|
|
39
|
-
height: size,
|
|
40
|
-
stroke: color,
|
|
41
|
-
strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
|
|
42
|
-
className: mergeClasses("lucide", className),
|
|
43
|
-
...rest
|
|
44
|
-
}, [
|
|
45
|
-
...iconNode.map(([tag, attrs])=>/*#__PURE__*/ createElement(tag, attrs)),
|
|
46
|
-
...Array.isArray(children) ? children : [
|
|
47
|
-
children
|
|
48
|
-
]
|
|
49
|
-
]);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const createLucideIcon = (iconName, iconNode)=>{
|
|
53
|
-
const Component = /*#__PURE__*/ forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ createElement(Icon, {
|
|
54
|
-
ref,
|
|
55
|
-
iconNode,
|
|
56
|
-
className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className),
|
|
57
|
-
...props
|
|
58
|
-
}));
|
|
59
|
-
Component.displayName = `${iconName}`;
|
|
60
|
-
return Component;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const __iconNode$7 = [
|
|
64
|
-
[
|
|
65
|
-
"path",
|
|
66
|
-
{
|
|
67
|
-
d: "M20 6 9 17l-5-5",
|
|
68
|
-
key: "1gmf2c"
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
];
|
|
72
|
-
const Check = createLucideIcon("Check", __iconNode$7);
|
|
73
|
-
|
|
74
|
-
const __iconNode$6 = [
|
|
75
|
-
[
|
|
76
|
-
"path",
|
|
77
|
-
{
|
|
78
|
-
d: "m6 9 6 6 6-6",
|
|
79
|
-
key: "qrunsl"
|
|
80
|
-
}
|
|
81
|
-
]
|
|
82
|
-
];
|
|
83
|
-
const ChevronDown = createLucideIcon("ChevronDown", __iconNode$6);
|
|
84
|
-
|
|
85
|
-
const __iconNode$5 = [
|
|
86
|
-
[
|
|
87
|
-
"path",
|
|
88
|
-
{
|
|
89
|
-
d: "m18 15-6-6-6 6",
|
|
90
|
-
key: "153udz"
|
|
91
|
-
}
|
|
92
|
-
]
|
|
93
|
-
];
|
|
94
|
-
const ChevronUp = createLucideIcon("ChevronUp", __iconNode$5);
|
|
95
|
-
|
|
96
|
-
const __iconNode$4 = [
|
|
97
|
-
[
|
|
98
|
-
"circle",
|
|
99
|
-
{
|
|
100
|
-
cx: "12",
|
|
101
|
-
cy: "12",
|
|
102
|
-
r: "10",
|
|
103
|
-
key: "1mglay"
|
|
104
|
-
}
|
|
105
|
-
],
|
|
106
|
-
[
|
|
107
|
-
"path",
|
|
108
|
-
{
|
|
109
|
-
d: "m9 12 2 2 4-4",
|
|
110
|
-
key: "dzmm74"
|
|
111
|
-
}
|
|
112
|
-
]
|
|
113
|
-
];
|
|
114
|
-
const CircleCheck = createLucideIcon("CircleCheck", __iconNode$4);
|
|
115
|
-
|
|
116
|
-
const __iconNode$3 = [
|
|
117
|
-
[
|
|
118
|
-
"circle",
|
|
119
|
-
{
|
|
120
|
-
cx: "12",
|
|
121
|
-
cy: "12",
|
|
122
|
-
r: "10",
|
|
123
|
-
key: "1mglay"
|
|
124
|
-
}
|
|
125
|
-
],
|
|
126
|
-
[
|
|
127
|
-
"path",
|
|
128
|
-
{
|
|
129
|
-
d: "m15 9-6 6",
|
|
130
|
-
key: "1uzhvr"
|
|
131
|
-
}
|
|
132
|
-
],
|
|
133
|
-
[
|
|
134
|
-
"path",
|
|
135
|
-
{
|
|
136
|
-
d: "m9 9 6 6",
|
|
137
|
-
key: "z0biqf"
|
|
138
|
-
}
|
|
139
|
-
]
|
|
140
|
-
];
|
|
141
|
-
const CircleX = createLucideIcon("CircleX", __iconNode$3);
|
|
142
|
-
|
|
143
|
-
const __iconNode$2 = [
|
|
144
|
-
[
|
|
145
|
-
"rect",
|
|
146
|
-
{
|
|
147
|
-
width: "14",
|
|
148
|
-
height: "14",
|
|
149
|
-
x: "8",
|
|
150
|
-
y: "8",
|
|
151
|
-
rx: "2",
|
|
152
|
-
ry: "2",
|
|
153
|
-
key: "17jyea"
|
|
154
|
-
}
|
|
155
|
-
],
|
|
156
|
-
[
|
|
157
|
-
"path",
|
|
158
|
-
{
|
|
159
|
-
d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",
|
|
160
|
-
key: "zix9uf"
|
|
161
|
-
}
|
|
162
|
-
]
|
|
163
|
-
];
|
|
164
|
-
const Copy = createLucideIcon("Copy", __iconNode$2);
|
|
165
|
-
|
|
166
|
-
const __iconNode$1 = [
|
|
167
|
-
[
|
|
168
|
-
"path",
|
|
169
|
-
{
|
|
170
|
-
d: "M5 12h14",
|
|
171
|
-
key: "1ays0h"
|
|
172
|
-
}
|
|
173
|
-
],
|
|
174
|
-
[
|
|
175
|
-
"path",
|
|
176
|
-
{
|
|
177
|
-
d: "M12 5v14",
|
|
178
|
-
key: "s699le"
|
|
179
|
-
}
|
|
180
|
-
]
|
|
181
|
-
];
|
|
182
|
-
const Plus = createLucideIcon("Plus", __iconNode$1);
|
|
183
|
-
|
|
184
|
-
const __iconNode = [
|
|
185
|
-
[
|
|
186
|
-
"path",
|
|
187
|
-
{
|
|
188
|
-
d: "M3 6h18",
|
|
189
|
-
key: "d0wm0j"
|
|
190
|
-
}
|
|
191
|
-
],
|
|
192
|
-
[
|
|
193
|
-
"path",
|
|
194
|
-
{
|
|
195
|
-
d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",
|
|
196
|
-
key: "4alrt4"
|
|
197
|
-
}
|
|
198
|
-
],
|
|
199
|
-
[
|
|
200
|
-
"path",
|
|
201
|
-
{
|
|
202
|
-
d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",
|
|
203
|
-
key: "v07s0e"
|
|
204
|
-
}
|
|
205
|
-
],
|
|
206
|
-
[
|
|
207
|
-
"line",
|
|
208
|
-
{
|
|
209
|
-
x1: "10",
|
|
210
|
-
x2: "10",
|
|
211
|
-
y1: "11",
|
|
212
|
-
y2: "17",
|
|
213
|
-
key: "1uufr5"
|
|
214
|
-
}
|
|
215
|
-
],
|
|
216
|
-
[
|
|
217
|
-
"line",
|
|
218
|
-
{
|
|
219
|
-
x1: "14",
|
|
220
|
-
x2: "14",
|
|
221
|
-
y1: "11",
|
|
222
|
-
y2: "17",
|
|
223
|
-
key: "xtxkd"
|
|
224
|
-
}
|
|
225
|
-
]
|
|
226
|
-
];
|
|
227
|
-
const Trash2 = createLucideIcon("Trash2", __iconNode);
|
|
228
|
-
|
|
229
|
-
const ApiContext = /*#__PURE__*/ createContext(undefined);
|
|
230
|
-
const ServerSelectContext = /*#__PURE__*/ createContext(undefined);
|
|
231
|
-
function useApiContext() {
|
|
232
|
-
const ctx = useContext(ApiContext);
|
|
233
|
-
if (!ctx) throw new Error('Component must be used under <ApiProvider />');
|
|
234
|
-
return ctx;
|
|
235
|
-
}
|
|
236
|
-
function useServerSelectContext() {
|
|
237
|
-
const ctx = useContext(ServerSelectContext);
|
|
238
|
-
if (!ctx) throw new Error('Component must be used under <ApiProvider />');
|
|
239
|
-
return ctx;
|
|
240
|
-
}
|
|
241
|
-
function ApiProvider({ defaultBaseUrl, children, ...props }) {
|
|
242
|
-
const [server, setServer] = useState(()=>{
|
|
243
|
-
const defaultItem = defaultBaseUrl ? props.servers.find((item)=>item.url === defaultBaseUrl) : undefined;
|
|
244
|
-
return defaultItem ? {
|
|
245
|
-
url: defaultItem.url,
|
|
246
|
-
variables: getDefaultValues(defaultItem)
|
|
247
|
-
} : null;
|
|
248
|
-
});
|
|
249
|
-
const serverRef = useRef(server);
|
|
250
|
-
serverRef.current = server;
|
|
251
|
-
useEffect(()=>{
|
|
252
|
-
const cached = localStorage.getItem('apiBaseUrl');
|
|
253
|
-
if (!cached) return;
|
|
254
|
-
try {
|
|
255
|
-
const obj = JSON.parse(cached);
|
|
256
|
-
if (!obj || typeof obj !== 'object') return;
|
|
257
|
-
setServer(obj);
|
|
258
|
-
} catch {
|
|
259
|
-
// ignore
|
|
260
|
-
}
|
|
261
|
-
}, []);
|
|
262
|
-
return /*#__PURE__*/ jsx(ApiContext.Provider, {
|
|
263
|
-
value: useMemo(()=>({
|
|
264
|
-
...props,
|
|
265
|
-
serverRef
|
|
266
|
-
}), [
|
|
267
|
-
props
|
|
268
|
-
]),
|
|
269
|
-
children: /*#__PURE__*/ jsx(ServerSelectContext.Provider, {
|
|
270
|
-
value: useMemo(()=>({
|
|
271
|
-
server,
|
|
272
|
-
setServerVariables (variables) {
|
|
273
|
-
setServer((prev)=>{
|
|
274
|
-
if (!prev) return null;
|
|
275
|
-
const updated = {
|
|
276
|
-
...prev,
|
|
277
|
-
variables
|
|
278
|
-
};
|
|
279
|
-
localStorage.setItem('apiBaseUrl', JSON.stringify(updated));
|
|
280
|
-
return updated;
|
|
281
|
-
});
|
|
282
|
-
},
|
|
283
|
-
setServer (value) {
|
|
284
|
-
const obj = props.servers.find((item)=>item.url === value);
|
|
285
|
-
if (!obj) return;
|
|
286
|
-
const result = {
|
|
287
|
-
url: value,
|
|
288
|
-
variables: getDefaultValues(obj)
|
|
289
|
-
};
|
|
290
|
-
localStorage.setItem('apiBaseUrl', JSON.stringify(result));
|
|
291
|
-
setServer(result);
|
|
292
|
-
}
|
|
293
|
-
}), [
|
|
294
|
-
server,
|
|
295
|
-
props.servers
|
|
296
|
-
]),
|
|
297
|
-
children: children
|
|
298
|
-
})
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
function getDefaultValues(server) {
|
|
302
|
-
return Object.fromEntries(Object.entries(server.variables ?? {}).map(([k, v])=>[
|
|
303
|
-
k,
|
|
304
|
-
v.default
|
|
305
|
-
]));
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
function getUrl(url, variables) {
|
|
309
|
-
let out = url;
|
|
310
|
-
for (const [key, value] of Object.entries(variables)){
|
|
311
|
-
out = out.replaceAll(`{${key}}`, value);
|
|
312
|
-
}
|
|
313
|
-
return out;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const SchemaContext = /*#__PURE__*/ createContext(undefined);
|
|
317
|
-
function useSchemaContext() {
|
|
318
|
-
const ctx = useContext(SchemaContext);
|
|
319
|
-
if (!ctx) throw new Error('Missing provider');
|
|
320
|
-
return ctx;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
const APIPlayground = dynamic(()=>import('./index-client-DPqAL2w9.js').then(function (n) { return n.i; }).then((mod)=>mod.APIPlayground));
|
|
324
|
-
const ServerSelect = dynamic(()=>import('./server-select-client-CtG30byb.js'));
|
|
325
|
-
function Root({ children, baseUrl, className, shikiOptions, servers, ...props }) {
|
|
326
|
-
return /*#__PURE__*/ jsx("div", {
|
|
327
|
-
className: cn('flex flex-col gap-24 text-sm text-fd-muted-foreground', className),
|
|
328
|
-
...props,
|
|
329
|
-
children: /*#__PURE__*/ jsx(ApiProvider, {
|
|
330
|
-
servers: servers,
|
|
331
|
-
shikiOptions: shikiOptions,
|
|
332
|
-
defaultBaseUrl: baseUrl,
|
|
333
|
-
children: children
|
|
334
|
-
})
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
function CopyRouteButton({ className, route, ...props }) {
|
|
338
|
-
const { serverRef } = useApiContext();
|
|
339
|
-
const [checked, onCopy] = useCopyButton(()=>{
|
|
340
|
-
void navigator.clipboard.writeText(`${serverRef.current ? getUrl(serverRef.current.url, serverRef.current.variables) : ''}${route}`);
|
|
341
|
-
});
|
|
342
|
-
return /*#__PURE__*/ jsx("button", {
|
|
343
|
-
type: "button",
|
|
344
|
-
className: cn(buttonVariants({
|
|
345
|
-
color: 'ghost',
|
|
346
|
-
className
|
|
347
|
-
})),
|
|
348
|
-
onClick: onCopy,
|
|
349
|
-
"aria-label": "Copy route path",
|
|
350
|
-
...props,
|
|
351
|
-
children: checked ? /*#__PURE__*/ jsx(Check, {
|
|
352
|
-
className: "size-full"
|
|
353
|
-
}) : /*#__PURE__*/ jsx(Copy, {
|
|
354
|
-
className: "size-full"
|
|
355
|
-
})
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
export { APIPlayground as A, ChevronDown as C, Plus as P, Root as R, SchemaContext as S, Trash2 as T, Check as a, ChevronUp as b, CircleCheck as c, CircleX as d, useApiContext as e, useServerSelectContext as f, getUrl as g, CopyRouteButton as h, ServerSelect as i, useSchemaContext as u };
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { e as useApiContext, f as useServerSelectContext, C as ChevronDown } from './client-client-B06fJG48.js';
|
|
4
|
-
import { Collapsible, CollapsibleTrigger, CollapsibleContent } from 'fumadocs-ui/components/ui/collapsible';
|
|
5
|
-
import { S as Select, a as SelectTrigger, b as SelectValue, c as SelectContent, d as SelectItem, I as Input } from './index-client-DPqAL2w9.js';
|
|
6
|
-
|
|
7
|
-
function ServerSelect() {
|
|
8
|
-
const { servers } = useApiContext();
|
|
9
|
-
const { server, setServer, setServerVariables } = useServerSelectContext();
|
|
10
|
-
if (servers.length <= 1) return null;
|
|
11
|
-
const schema = server ? servers.find((item)=>item.url === server.url) : undefined;
|
|
12
|
-
return /*#__PURE__*/ jsxs(Collapsible, {
|
|
13
|
-
className: "-m-2 mt-2",
|
|
14
|
-
children: [
|
|
15
|
-
/*#__PURE__*/ jsxs(CollapsibleTrigger, {
|
|
16
|
-
className: "flex w-full flex-row items-center justify-between p-2 text-xs font-medium text-fd-muted-foreground",
|
|
17
|
-
children: [
|
|
18
|
-
"Configure Server",
|
|
19
|
-
/*#__PURE__*/ jsx(ChevronDown, {
|
|
20
|
-
className: "size-4"
|
|
21
|
-
})
|
|
22
|
-
]
|
|
23
|
-
}),
|
|
24
|
-
/*#__PURE__*/ jsx(CollapsibleContent, {
|
|
25
|
-
children: /*#__PURE__*/ jsxs("div", {
|
|
26
|
-
className: "flex flex-col gap-4 p-2",
|
|
27
|
-
children: [
|
|
28
|
-
/*#__PURE__*/ jsxs(Select, {
|
|
29
|
-
value: server?.url,
|
|
30
|
-
onValueChange: setServer,
|
|
31
|
-
children: [
|
|
32
|
-
/*#__PURE__*/ jsx(SelectTrigger, {
|
|
33
|
-
className: "h-auto break-all",
|
|
34
|
-
children: /*#__PURE__*/ jsx(SelectValue, {})
|
|
35
|
-
}),
|
|
36
|
-
/*#__PURE__*/ jsx(SelectContent, {
|
|
37
|
-
children: servers.map((item)=>/*#__PURE__*/ jsxs(SelectItem, {
|
|
38
|
-
value: item.url,
|
|
39
|
-
children: [
|
|
40
|
-
item.url,
|
|
41
|
-
/*#__PURE__*/ jsx("p", {
|
|
42
|
-
className: "text-start text-xs text-fd-muted-foreground",
|
|
43
|
-
children: item.description
|
|
44
|
-
})
|
|
45
|
-
]
|
|
46
|
-
}, item.url))
|
|
47
|
-
})
|
|
48
|
-
]
|
|
49
|
-
}),
|
|
50
|
-
Object.entries(schema?.variables ?? {}).map(([key, variable])=>{
|
|
51
|
-
if (!server) return;
|
|
52
|
-
const id = `fd_server_select_${key}`;
|
|
53
|
-
return /*#__PURE__*/ jsxs("fieldset", {
|
|
54
|
-
className: "flex flex-col gap-1",
|
|
55
|
-
children: [
|
|
56
|
-
/*#__PURE__*/ jsx("label", {
|
|
57
|
-
className: "font-mono text-xs text-fd-foreground",
|
|
58
|
-
htmlFor: id,
|
|
59
|
-
children: key
|
|
60
|
-
}),
|
|
61
|
-
/*#__PURE__*/ jsx("p", {
|
|
62
|
-
className: "text-xs text-fd-muted-foreground empty:hidden",
|
|
63
|
-
children: variable.description
|
|
64
|
-
}),
|
|
65
|
-
variable.enum ? /*#__PURE__*/ jsxs(Select, {
|
|
66
|
-
value: server.variables[key],
|
|
67
|
-
onValueChange: (v)=>setServerVariables({
|
|
68
|
-
...server?.variables,
|
|
69
|
-
[key]: v
|
|
70
|
-
}),
|
|
71
|
-
children: [
|
|
72
|
-
/*#__PURE__*/ jsx(SelectTrigger, {
|
|
73
|
-
id: id,
|
|
74
|
-
children: /*#__PURE__*/ jsx(SelectValue, {})
|
|
75
|
-
}),
|
|
76
|
-
/*#__PURE__*/ jsx(SelectContent, {
|
|
77
|
-
children: variable.enum.map((value)=>/*#__PURE__*/ jsx(SelectItem, {
|
|
78
|
-
value: value,
|
|
79
|
-
children: value
|
|
80
|
-
}, value))
|
|
81
|
-
})
|
|
82
|
-
]
|
|
83
|
-
}) : /*#__PURE__*/ jsx(Input, {
|
|
84
|
-
id: id,
|
|
85
|
-
value: server.variables[key],
|
|
86
|
-
onChange: (e)=>setServerVariables({
|
|
87
|
-
...server?.variables,
|
|
88
|
-
[key]: e.target.value
|
|
89
|
-
})
|
|
90
|
-
})
|
|
91
|
-
]
|
|
92
|
-
}, key);
|
|
93
|
-
})
|
|
94
|
-
]
|
|
95
|
-
})
|
|
96
|
-
})
|
|
97
|
-
]
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export { ServerSelect as default };
|