fumadocs-openapi 5.12.0 → 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.
@@ -1,315 +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 } 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$6 = [
64
- [
65
- "path",
66
- {
67
- d: "M20 6 9 17l-5-5",
68
- key: "1gmf2c"
69
- }
70
- ]
71
- ];
72
- const Check = createLucideIcon("Check", __iconNode$6);
73
-
74
- const __iconNode$5 = [
75
- [
76
- "path",
77
- {
78
- d: "m6 9 6 6 6-6",
79
- key: "qrunsl"
80
- }
81
- ]
82
- ];
83
- const ChevronDown = createLucideIcon("ChevronDown", __iconNode$5);
84
-
85
- const __iconNode$4 = [
86
- [
87
- "path",
88
- {
89
- d: "m18 15-6-6-6 6",
90
- key: "153udz"
91
- }
92
- ]
93
- ];
94
- const ChevronUp = createLucideIcon("ChevronUp", __iconNode$4);
95
-
96
- const __iconNode$3 = [
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$3);
115
-
116
- const __iconNode$2 = [
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$2);
142
-
143
- const __iconNode$1 = [
144
- [
145
- "path",
146
- {
147
- d: "M5 12h14",
148
- key: "1ays0h"
149
- }
150
- ],
151
- [
152
- "path",
153
- {
154
- d: "M12 5v14",
155
- key: "s699le"
156
- }
157
- ]
158
- ];
159
- const Plus = createLucideIcon("Plus", __iconNode$1);
160
-
161
- const __iconNode = [
162
- [
163
- "path",
164
- {
165
- d: "M3 6h18",
166
- key: "d0wm0j"
167
- }
168
- ],
169
- [
170
- "path",
171
- {
172
- d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",
173
- key: "4alrt4"
174
- }
175
- ],
176
- [
177
- "path",
178
- {
179
- d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",
180
- key: "v07s0e"
181
- }
182
- ],
183
- [
184
- "line",
185
- {
186
- x1: "10",
187
- x2: "10",
188
- y1: "11",
189
- y2: "17",
190
- key: "1uufr5"
191
- }
192
- ],
193
- [
194
- "line",
195
- {
196
- x1: "14",
197
- x2: "14",
198
- y1: "11",
199
- y2: "17",
200
- key: "xtxkd"
201
- }
202
- ]
203
- ];
204
- const Trash2 = createLucideIcon("Trash2", __iconNode);
205
-
206
- const ApiContext = /*#__PURE__*/ createContext(undefined);
207
- const ServerSelectContext = /*#__PURE__*/ createContext(undefined);
208
- function useApiContext() {
209
- const ctx = useContext(ApiContext);
210
- if (!ctx) throw new Error('Component must be used under <ApiProvider />');
211
- return ctx;
212
- }
213
- function useServerSelectContext() {
214
- const ctx = useContext(ServerSelectContext);
215
- if (!ctx) throw new Error('Component must be used under <ApiProvider />');
216
- return ctx;
217
- }
218
- function ApiProvider({ defaultBaseUrl, children, ...props }) {
219
- const [server, setServer] = useState(()=>{
220
- const defaultItem = defaultBaseUrl ? props.servers.find((item)=>item.url === defaultBaseUrl) : undefined;
221
- return defaultItem ? {
222
- url: defaultItem.url,
223
- variables: getDefaultValues(defaultItem)
224
- } : null;
225
- });
226
- const serverRef = useRef(server);
227
- serverRef.current = server;
228
- useEffect(()=>{
229
- const cached = localStorage.getItem('apiBaseUrl');
230
- if (!cached) return;
231
- try {
232
- const obj = JSON.parse(cached);
233
- if (!obj || typeof obj !== 'object') return;
234
- setServer(obj);
235
- } catch {
236
- // ignore
237
- }
238
- }, []);
239
- return /*#__PURE__*/ jsx(ApiContext.Provider, {
240
- value: useMemo(()=>({
241
- ...props,
242
- serverRef
243
- }), [
244
- props
245
- ]),
246
- children: /*#__PURE__*/ jsx(ServerSelectContext.Provider, {
247
- value: useMemo(()=>({
248
- server,
249
- setServerVariables (variables) {
250
- setServer((prev)=>{
251
- if (!prev) return null;
252
- const updated = {
253
- ...prev,
254
- variables
255
- };
256
- localStorage.setItem('apiBaseUrl', JSON.stringify(updated));
257
- return updated;
258
- });
259
- },
260
- setServer (value) {
261
- const obj = props.servers.find((item)=>item.url === value);
262
- if (!obj) return;
263
- const result = {
264
- url: value,
265
- variables: getDefaultValues(obj)
266
- };
267
- localStorage.setItem('apiBaseUrl', JSON.stringify(result));
268
- setServer(result);
269
- }
270
- }), [
271
- server,
272
- props.servers
273
- ]),
274
- children: children
275
- })
276
- });
277
- }
278
- function getDefaultValues(server) {
279
- return Object.fromEntries(Object.entries(server.variables ?? {}).map(([k, v])=>[
280
- k,
281
- v.default
282
- ]));
283
- }
284
-
285
- function getUrl(url, variables) {
286
- let out = url;
287
- for (const [key, value] of Object.entries(variables)){
288
- out = out.replaceAll(`{${key}}`, value);
289
- }
290
- return out;
291
- }
292
-
293
- const SchemaContext = /*#__PURE__*/ createContext(undefined);
294
- function useSchemaContext() {
295
- const ctx = useContext(SchemaContext);
296
- if (!ctx) throw new Error('Missing provider');
297
- return ctx;
298
- }
299
-
300
- const APIPlayground = dynamic(()=>import('./index-client-XPLtFTfD.js').then(function (n) { return n.i; }).then((mod)=>mod.APIPlayground));
301
- const ScalarPlayground = dynamic(()=>import('./index-client-XPLtFTfD.js').then(function (n) { return n.e; }));
302
- function Root({ children, baseUrl, className, shikiOptions, servers, ...props }) {
303
- return /*#__PURE__*/ jsx("div", {
304
- className: cn('flex flex-col gap-24 text-sm text-fd-muted-foreground', className),
305
- ...props,
306
- children: /*#__PURE__*/ jsx(ApiProvider, {
307
- servers: servers,
308
- shikiOptions: shikiOptions,
309
- defaultBaseUrl: baseUrl,
310
- children: children
311
- })
312
- });
313
- }
314
-
315
- export { APIPlayground as A, ChevronDown as C, Plus as P, Root as R, SchemaContext as S, Trash2 as T, ChevronUp as a, Check as b, CircleCheck as c, CircleX as d, useApiContext as e, useServerSelectContext as f, getUrl as g, ScalarPlayground as h, useSchemaContext as u };