@doccov/fumadocs-adapter 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bunup.config.ts +10 -0
- package/dist/components/index.d.ts +160 -0
- package/dist/components/index.js +237 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +10 -0
- package/dist/server.d.ts +34 -0
- package/dist/server.js +38 -0
- package/dist/shared/chunk-pqaj3kdh.js +1488 -0
- package/package.json +33 -0
- package/src/components/api-page.tsx +90 -0
- package/src/components/class-page.tsx +165 -0
- package/src/components/code-example.tsx +40 -0
- package/src/components/collapsible-method.tsx +185 -0
- package/src/components/coverage-badge.tsx +80 -0
- package/src/components/enum-page.tsx +86 -0
- package/src/components/examples.tsx +84 -0
- package/src/components/expandable-property.tsx +240 -0
- package/src/components/function-page.tsx +93 -0
- package/src/components/index.ts +51 -0
- package/src/components/interface-page.tsx +94 -0
- package/src/components/members-section.tsx +193 -0
- package/src/components/method-section.tsx +18 -0
- package/src/components/parameter-card.tsx +53 -0
- package/src/components/signature.tsx +108 -0
- package/src/components/type-table.tsx +80 -0
- package/src/components/variable-page.tsx +78 -0
- package/src/index.ts +8 -0
- package/src/server.ts +80 -0
- package/src/styles/docskit.css +130 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,1488 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/components/parameter-card.tsx
|
|
3
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
4
|
+
|
|
5
|
+
function formatSchema(schema) {
|
|
6
|
+
if (!schema)
|
|
7
|
+
return "unknown";
|
|
8
|
+
if (typeof schema === "string")
|
|
9
|
+
return schema;
|
|
10
|
+
if (typeof schema === "object" && schema !== null) {
|
|
11
|
+
const s = schema;
|
|
12
|
+
if (s.$ref && typeof s.$ref === "string") {
|
|
13
|
+
return s.$ref.replace("#/types/", "");
|
|
14
|
+
}
|
|
15
|
+
if (s.tsType)
|
|
16
|
+
return String(s.tsType);
|
|
17
|
+
if (s.type)
|
|
18
|
+
return String(s.type);
|
|
19
|
+
}
|
|
20
|
+
return "unknown";
|
|
21
|
+
}
|
|
22
|
+
function ParameterCard({ param, spec }) {
|
|
23
|
+
const type = formatSchema(param.schema);
|
|
24
|
+
const isRequired = param.required !== false;
|
|
25
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
26
|
+
className: "rounded-lg border border-fd-border bg-fd-card/50 p-4",
|
|
27
|
+
children: [
|
|
28
|
+
/* @__PURE__ */ jsxDEV("div", {
|
|
29
|
+
className: "flex items-center gap-2 mb-1",
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ jsxDEV("span", {
|
|
32
|
+
className: "font-mono text-sm text-fd-foreground",
|
|
33
|
+
children: param.name
|
|
34
|
+
}, undefined, false, undefined, this),
|
|
35
|
+
isRequired && /* @__PURE__ */ jsxDEV("span", {
|
|
36
|
+
className: "text-[10px] font-semibold px-1.5 py-0.5 rounded border border-fd-border bg-fd-muted text-fd-muted-foreground uppercase tracking-wide",
|
|
37
|
+
children: "Required"
|
|
38
|
+
}, undefined, false, undefined, this)
|
|
39
|
+
]
|
|
40
|
+
}, undefined, true, undefined, this),
|
|
41
|
+
/* @__PURE__ */ jsxDEV("div", {
|
|
42
|
+
className: "text-sm text-fd-muted-foreground font-mono",
|
|
43
|
+
children: type
|
|
44
|
+
}, undefined, false, undefined, this),
|
|
45
|
+
param.description && /* @__PURE__ */ jsxDEV("p", {
|
|
46
|
+
className: "text-sm text-fd-muted-foreground mt-2",
|
|
47
|
+
children: param.description
|
|
48
|
+
}, undefined, false, undefined, this)
|
|
49
|
+
]
|
|
50
|
+
}, undefined, true, undefined, this);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/components/code-example.tsx
|
|
54
|
+
import { ClientDocsKitCode } from "@doccov/ui/docskit";
|
|
55
|
+
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
56
|
+
|
|
57
|
+
function cleanCode(code) {
|
|
58
|
+
let cleaned = code.trim();
|
|
59
|
+
if (cleaned.startsWith("```")) {
|
|
60
|
+
const lines = cleaned.split(`
|
|
61
|
+
`);
|
|
62
|
+
lines.shift();
|
|
63
|
+
if (lines[lines.length - 1] === "```") {
|
|
64
|
+
lines.pop();
|
|
65
|
+
}
|
|
66
|
+
cleaned = lines.join(`
|
|
67
|
+
`);
|
|
68
|
+
}
|
|
69
|
+
return cleaned;
|
|
70
|
+
}
|
|
71
|
+
function CodeExample({ code, filename = "example.ts", language = "typescript" }) {
|
|
72
|
+
const cleaned = cleanCode(code);
|
|
73
|
+
const codeblock = {
|
|
74
|
+
value: cleaned,
|
|
75
|
+
lang: language,
|
|
76
|
+
meta: `${filename} -cn`
|
|
77
|
+
};
|
|
78
|
+
return /* @__PURE__ */ jsxDEV2(ClientDocsKitCode, {
|
|
79
|
+
codeblock,
|
|
80
|
+
className: "not-fumadocs-codeblock"
|
|
81
|
+
}, undefined, false, undefined, this);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// src/components/coverage-badge.tsx
|
|
85
|
+
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
86
|
+
|
|
87
|
+
function getScoreColor(score) {
|
|
88
|
+
if (score >= 80)
|
|
89
|
+
return "text-green-600 dark:text-green-400 bg-green-500/10 border-green-500/20";
|
|
90
|
+
if (score >= 60)
|
|
91
|
+
return "text-yellow-600 dark:text-yellow-400 bg-yellow-500/10 border-yellow-500/20";
|
|
92
|
+
return "text-red-600 dark:text-red-400 bg-red-500/10 border-red-500/20";
|
|
93
|
+
}
|
|
94
|
+
function formatSignal(signal) {
|
|
95
|
+
return signal.charAt(0).toUpperCase() + signal.slice(1);
|
|
96
|
+
}
|
|
97
|
+
function CoverageBadge({ docs, showMissing = true, showDrift = true }) {
|
|
98
|
+
const score = docs.coverageScore;
|
|
99
|
+
const hasMissing = showMissing && docs.missing && docs.missing.length > 0;
|
|
100
|
+
const hasDrift = showDrift && docs.drift && docs.drift.length > 0;
|
|
101
|
+
if (score == null && !hasMissing && !hasDrift)
|
|
102
|
+
return null;
|
|
103
|
+
return /* @__PURE__ */ jsxDEV3("div", {
|
|
104
|
+
className: "my-6 space-y-3",
|
|
105
|
+
children: [
|
|
106
|
+
score != null && /* @__PURE__ */ jsxDEV3("div", {
|
|
107
|
+
className: `inline-flex items-center gap-2 px-3 py-1.5 rounded-md border text-sm font-medium ${getScoreColor(score)}`,
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ jsxDEV3("svg", {
|
|
110
|
+
className: "w-4 h-4",
|
|
111
|
+
fill: "none",
|
|
112
|
+
stroke: "currentColor",
|
|
113
|
+
viewBox: "0 0 24 24",
|
|
114
|
+
children: /* @__PURE__ */ jsxDEV3("path", {
|
|
115
|
+
strokeLinecap: "round",
|
|
116
|
+
strokeLinejoin: "round",
|
|
117
|
+
strokeWidth: 2,
|
|
118
|
+
d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
119
|
+
}, undefined, false, undefined, this)
|
|
120
|
+
}, undefined, false, undefined, this),
|
|
121
|
+
"Coverage: ",
|
|
122
|
+
score,
|
|
123
|
+
"%"
|
|
124
|
+
]
|
|
125
|
+
}, undefined, true, undefined, this),
|
|
126
|
+
hasMissing && /* @__PURE__ */ jsxDEV3("div", {
|
|
127
|
+
className: "rounded-md bg-yellow-500/10 border border-yellow-500/20 px-3 py-2",
|
|
128
|
+
children: [
|
|
129
|
+
/* @__PURE__ */ jsxDEV3("p", {
|
|
130
|
+
className: "text-sm font-medium text-yellow-600 dark:text-yellow-400 mb-1",
|
|
131
|
+
children: "Missing Documentation"
|
|
132
|
+
}, undefined, false, undefined, this),
|
|
133
|
+
/* @__PURE__ */ jsxDEV3("ul", {
|
|
134
|
+
className: "text-sm text-yellow-600/80 dark:text-yellow-400/80 list-disc list-inside",
|
|
135
|
+
children: docs.missing.map((signal) => /* @__PURE__ */ jsxDEV3("li", {
|
|
136
|
+
children: formatSignal(signal)
|
|
137
|
+
}, signal, false, undefined, this))
|
|
138
|
+
}, undefined, false, undefined, this)
|
|
139
|
+
]
|
|
140
|
+
}, undefined, true, undefined, this),
|
|
141
|
+
hasDrift && /* @__PURE__ */ jsxDEV3("div", {
|
|
142
|
+
className: "rounded-md bg-red-500/10 border border-red-500/20 px-3 py-2",
|
|
143
|
+
children: [
|
|
144
|
+
/* @__PURE__ */ jsxDEV3("p", {
|
|
145
|
+
className: "text-sm font-medium text-red-600 dark:text-red-400 mb-1",
|
|
146
|
+
children: "Documentation Drift"
|
|
147
|
+
}, undefined, false, undefined, this),
|
|
148
|
+
/* @__PURE__ */ jsxDEV3("ul", {
|
|
149
|
+
className: "text-sm text-red-600/80 dark:text-red-400/80 space-y-1",
|
|
150
|
+
children: docs.drift.map((drift, index) => /* @__PURE__ */ jsxDEV3("li", {
|
|
151
|
+
className: "flex flex-col",
|
|
152
|
+
children: [
|
|
153
|
+
/* @__PURE__ */ jsxDEV3("span", {
|
|
154
|
+
className: "font-medium",
|
|
155
|
+
children: drift.type
|
|
156
|
+
}, undefined, false, undefined, this),
|
|
157
|
+
/* @__PURE__ */ jsxDEV3("span", {
|
|
158
|
+
className: "text-xs opacity-80",
|
|
159
|
+
children: drift.issue
|
|
160
|
+
}, undefined, false, undefined, this),
|
|
161
|
+
drift.suggestion && /* @__PURE__ */ jsxDEV3("span", {
|
|
162
|
+
className: "text-xs text-fd-muted-foreground mt-0.5",
|
|
163
|
+
children: [
|
|
164
|
+
"Suggestion: ",
|
|
165
|
+
drift.suggestion
|
|
166
|
+
]
|
|
167
|
+
}, undefined, true, undefined, this)
|
|
168
|
+
]
|
|
169
|
+
}, index, true, undefined, this))
|
|
170
|
+
}, undefined, false, undefined, this)
|
|
171
|
+
]
|
|
172
|
+
}, undefined, true, undefined, this)
|
|
173
|
+
]
|
|
174
|
+
}, undefined, true, undefined, this);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// src/components/function-page.tsx
|
|
178
|
+
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
179
|
+
|
|
180
|
+
function formatSchema2(schema) {
|
|
181
|
+
if (!schema)
|
|
182
|
+
return "unknown";
|
|
183
|
+
if (typeof schema === "string")
|
|
184
|
+
return schema;
|
|
185
|
+
if (typeof schema === "object" && schema !== null) {
|
|
186
|
+
const s = schema;
|
|
187
|
+
if (s.$ref && typeof s.$ref === "string") {
|
|
188
|
+
return s.$ref.replace("#/types/", "");
|
|
189
|
+
}
|
|
190
|
+
if (s.tsType)
|
|
191
|
+
return String(s.tsType);
|
|
192
|
+
if (s.type)
|
|
193
|
+
return String(s.type);
|
|
194
|
+
}
|
|
195
|
+
return "unknown";
|
|
196
|
+
}
|
|
197
|
+
function FunctionPage({ export: exp, spec }) {
|
|
198
|
+
const sig = exp.signatures?.[0];
|
|
199
|
+
const hasExamples = exp.examples && exp.examples.length > 0;
|
|
200
|
+
const hasParams = sig?.parameters && sig.parameters.length > 0;
|
|
201
|
+
return /* @__PURE__ */ jsxDEV4("div", {
|
|
202
|
+
className: "space-y-6 not-prose",
|
|
203
|
+
children: [
|
|
204
|
+
exp.description && /* @__PURE__ */ jsxDEV4("p", {
|
|
205
|
+
className: "text-fd-muted-foreground leading-relaxed",
|
|
206
|
+
children: exp.description
|
|
207
|
+
}, undefined, false, undefined, this),
|
|
208
|
+
sig?.returns && /* @__PURE__ */ jsxDEV4("p", {
|
|
209
|
+
className: "text-fd-muted-foreground text-sm",
|
|
210
|
+
children: [
|
|
211
|
+
/* @__PURE__ */ jsxDEV4("span", {
|
|
212
|
+
className: "font-medium text-fd-foreground",
|
|
213
|
+
children: "Returns:"
|
|
214
|
+
}, undefined, false, undefined, this),
|
|
215
|
+
" ",
|
|
216
|
+
sig.returns.description || `A ${sig.returns.tsType ?? formatSchema2(sig.returns.schema)}`
|
|
217
|
+
]
|
|
218
|
+
}, undefined, true, undefined, this),
|
|
219
|
+
/* @__PURE__ */ jsxDEV4("div", {
|
|
220
|
+
className: "not-prose",
|
|
221
|
+
style: {
|
|
222
|
+
display: hasExamples ? "grid" : "block",
|
|
223
|
+
gridTemplateColumns: hasExamples ? "repeat(2, minmax(0, 1fr))" : undefined,
|
|
224
|
+
gap: "2rem",
|
|
225
|
+
alignItems: "start"
|
|
226
|
+
},
|
|
227
|
+
children: [
|
|
228
|
+
/* @__PURE__ */ jsxDEV4("div", {
|
|
229
|
+
className: "space-y-6",
|
|
230
|
+
children: hasParams && /* @__PURE__ */ jsxDEV4("div", {
|
|
231
|
+
children: [
|
|
232
|
+
/* @__PURE__ */ jsxDEV4("h3", {
|
|
233
|
+
className: "text-sm font-semibold uppercase tracking-wide text-fd-muted-foreground mb-4",
|
|
234
|
+
children: "Parameters"
|
|
235
|
+
}, undefined, false, undefined, this),
|
|
236
|
+
/* @__PURE__ */ jsxDEV4("div", {
|
|
237
|
+
className: "space-y-3",
|
|
238
|
+
children: sig.parameters.map((param, index) => /* @__PURE__ */ jsxDEV4(ParameterCard, {
|
|
239
|
+
param,
|
|
240
|
+
spec
|
|
241
|
+
}, param.name ?? index, false, undefined, this))
|
|
242
|
+
}, undefined, false, undefined, this)
|
|
243
|
+
]
|
|
244
|
+
}, undefined, true, undefined, this)
|
|
245
|
+
}, undefined, false, undefined, this),
|
|
246
|
+
hasExamples && /* @__PURE__ */ jsxDEV4("div", {
|
|
247
|
+
style: { position: "sticky", top: "5rem" },
|
|
248
|
+
children: [
|
|
249
|
+
/* @__PURE__ */ jsxDEV4("h3", {
|
|
250
|
+
className: "text-sm font-semibold uppercase tracking-wide text-fd-muted-foreground mb-4",
|
|
251
|
+
children: "Example"
|
|
252
|
+
}, undefined, false, undefined, this),
|
|
253
|
+
/* @__PURE__ */ jsxDEV4(CodeExample, {
|
|
254
|
+
code: exp.examples[0],
|
|
255
|
+
filename: `${exp.name.toLowerCase().replace(/[^a-z0-9]/g, "-")}.ts`
|
|
256
|
+
}, undefined, false, undefined, this)
|
|
257
|
+
]
|
|
258
|
+
}, undefined, true, undefined, this)
|
|
259
|
+
]
|
|
260
|
+
}, undefined, true, undefined, this),
|
|
261
|
+
exp.docs && /* @__PURE__ */ jsxDEV4(CoverageBadge, {
|
|
262
|
+
docs: exp.docs
|
|
263
|
+
}, undefined, false, undefined, this)
|
|
264
|
+
]
|
|
265
|
+
}, undefined, true, undefined, this);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// src/components/expandable-property.tsx
|
|
269
|
+
import { useState } from "react";
|
|
270
|
+
import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
|
|
271
|
+
|
|
272
|
+
function ChevronIcon({ expanded }) {
|
|
273
|
+
return /* @__PURE__ */ jsxDEV5("svg", {
|
|
274
|
+
width: "12",
|
|
275
|
+
height: "12",
|
|
276
|
+
viewBox: "0 0 12 12",
|
|
277
|
+
fill: "none",
|
|
278
|
+
className: `transition-transform duration-200 ${expanded ? "rotate-90" : ""}`,
|
|
279
|
+
children: /* @__PURE__ */ jsxDEV5("path", {
|
|
280
|
+
d: "M4.5 2.5L8 6L4.5 9.5",
|
|
281
|
+
stroke: "currentColor",
|
|
282
|
+
strokeWidth: "1.5",
|
|
283
|
+
strokeLinecap: "round",
|
|
284
|
+
strokeLinejoin: "round"
|
|
285
|
+
}, undefined, false, undefined, this)
|
|
286
|
+
}, undefined, false, undefined, this);
|
|
287
|
+
}
|
|
288
|
+
function formatType(schema) {
|
|
289
|
+
if (!schema)
|
|
290
|
+
return "unknown";
|
|
291
|
+
if (typeof schema === "string")
|
|
292
|
+
return schema;
|
|
293
|
+
if (typeof schema === "object" && schema !== null) {
|
|
294
|
+
const s = schema;
|
|
295
|
+
if (s.tsType && typeof s.tsType === "string") {
|
|
296
|
+
const tsType = s.tsType;
|
|
297
|
+
if (tsType.length > 80) {
|
|
298
|
+
return tsType.slice(0, 77) + "...";
|
|
299
|
+
}
|
|
300
|
+
return tsType;
|
|
301
|
+
}
|
|
302
|
+
if (s.$ref && typeof s.$ref === "string") {
|
|
303
|
+
return s.$ref.replace("#/types/", "");
|
|
304
|
+
}
|
|
305
|
+
if (s.enum && Array.isArray(s.enum)) {
|
|
306
|
+
const enumVals = s.enum.map((v) => JSON.stringify(v)).join(" | ");
|
|
307
|
+
if (enumVals.length > 50)
|
|
308
|
+
return enumVals.slice(0, 47) + "...";
|
|
309
|
+
return enumVals;
|
|
310
|
+
}
|
|
311
|
+
if (s.anyOf && Array.isArray(s.anyOf)) {
|
|
312
|
+
return s.anyOf.map(formatType).join(" | ");
|
|
313
|
+
}
|
|
314
|
+
if (s.oneOf && Array.isArray(s.oneOf)) {
|
|
315
|
+
return s.oneOf.map(formatType).join(" | ");
|
|
316
|
+
}
|
|
317
|
+
if (s.type === "array" && s.items) {
|
|
318
|
+
return `${formatType(s.items)}[]`;
|
|
319
|
+
}
|
|
320
|
+
if (s.type)
|
|
321
|
+
return String(s.type);
|
|
322
|
+
}
|
|
323
|
+
return "unknown";
|
|
324
|
+
}
|
|
325
|
+
function getNestedProperties(schema) {
|
|
326
|
+
if (!schema || typeof schema !== "object")
|
|
327
|
+
return null;
|
|
328
|
+
const s = schema;
|
|
329
|
+
if (s.type === "object" && s.properties && typeof s.properties === "object") {
|
|
330
|
+
return s.properties;
|
|
331
|
+
}
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
function getRequiredFields(schema) {
|
|
335
|
+
if (!schema || typeof schema !== "object")
|
|
336
|
+
return [];
|
|
337
|
+
const s = schema;
|
|
338
|
+
if (Array.isArray(s.required)) {
|
|
339
|
+
return s.required;
|
|
340
|
+
}
|
|
341
|
+
return [];
|
|
342
|
+
}
|
|
343
|
+
function countProperties(schema) {
|
|
344
|
+
const props = getNestedProperties(schema);
|
|
345
|
+
return props ? Object.keys(props).length : 0;
|
|
346
|
+
}
|
|
347
|
+
function NestedProperty({ name, schema, required = false, depth = 0 }) {
|
|
348
|
+
const [expanded, setExpanded] = useState(false);
|
|
349
|
+
const type = formatType(schema);
|
|
350
|
+
const nestedProps = getNestedProperties(schema);
|
|
351
|
+
const nestedCount = countProperties(schema);
|
|
352
|
+
const hasNested = nestedCount > 0;
|
|
353
|
+
const schemaObj = schema;
|
|
354
|
+
const description = schemaObj?.description;
|
|
355
|
+
return /* @__PURE__ */ jsxDEV5("div", {
|
|
356
|
+
className: "flex flex-col border-b border-fd-border last:border-0",
|
|
357
|
+
children: [
|
|
358
|
+
/* @__PURE__ */ jsxDEV5("div", {
|
|
359
|
+
className: "flex flex-row items-start gap-2 py-2.5 px-3",
|
|
360
|
+
children: [
|
|
361
|
+
/* @__PURE__ */ jsxDEV5("div", {
|
|
362
|
+
className: "flex-1 min-w-0",
|
|
363
|
+
children: [
|
|
364
|
+
/* @__PURE__ */ jsxDEV5("div", {
|
|
365
|
+
className: "flex items-baseline gap-2 flex-wrap",
|
|
366
|
+
children: [
|
|
367
|
+
/* @__PURE__ */ jsxDEV5("span", {
|
|
368
|
+
className: "font-mono text-sm font-medium text-fd-foreground",
|
|
369
|
+
children: [
|
|
370
|
+
name,
|
|
371
|
+
!required && "?",
|
|
372
|
+
":"
|
|
373
|
+
]
|
|
374
|
+
}, undefined, true, undefined, this),
|
|
375
|
+
/* @__PURE__ */ jsxDEV5("span", {
|
|
376
|
+
className: "font-mono text-sm text-fd-muted-foreground",
|
|
377
|
+
children: hasNested ? "object" : type
|
|
378
|
+
}, undefined, false, undefined, this)
|
|
379
|
+
]
|
|
380
|
+
}, undefined, true, undefined, this),
|
|
381
|
+
description && /* @__PURE__ */ jsxDEV5("p", {
|
|
382
|
+
className: "text-sm text-fd-muted-foreground mt-0.5 leading-relaxed",
|
|
383
|
+
children: description
|
|
384
|
+
}, undefined, false, undefined, this)
|
|
385
|
+
]
|
|
386
|
+
}, undefined, true, undefined, this),
|
|
387
|
+
hasNested && /* @__PURE__ */ jsxDEV5("button", {
|
|
388
|
+
onClick: () => setExpanded(!expanded),
|
|
389
|
+
className: `flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-md
|
|
390
|
+
bg-fd-muted text-fd-muted-foreground hover:bg-fd-accent hover:text-fd-accent-foreground
|
|
391
|
+
transition-colors cursor-pointer shrink-0`,
|
|
392
|
+
children: [
|
|
393
|
+
/* @__PURE__ */ jsxDEV5(ChevronIcon, {
|
|
394
|
+
expanded
|
|
395
|
+
}, undefined, false, undefined, this),
|
|
396
|
+
/* @__PURE__ */ jsxDEV5("span", {
|
|
397
|
+
children: [
|
|
398
|
+
nestedCount,
|
|
399
|
+
" properties"
|
|
400
|
+
]
|
|
401
|
+
}, undefined, true, undefined, this)
|
|
402
|
+
]
|
|
403
|
+
}, undefined, true, undefined, this)
|
|
404
|
+
]
|
|
405
|
+
}, undefined, true, undefined, this),
|
|
406
|
+
hasNested && expanded && nestedProps && /* @__PURE__ */ jsxDEV5("div", {
|
|
407
|
+
className: "mx-3 mb-3 rounded-lg border border-fd-border bg-fd-card/50 overflow-hidden",
|
|
408
|
+
children: Object.entries(nestedProps).map(([propName, propSchema]) => /* @__PURE__ */ jsxDEV5(NestedProperty, {
|
|
409
|
+
name: propName,
|
|
410
|
+
schema: propSchema,
|
|
411
|
+
required: getRequiredFields(schema).includes(propName),
|
|
412
|
+
depth: depth + 1
|
|
413
|
+
}, propName, false, undefined, this))
|
|
414
|
+
}, undefined, false, undefined, this)
|
|
415
|
+
]
|
|
416
|
+
}, undefined, true, undefined, this);
|
|
417
|
+
}
|
|
418
|
+
function ExpandableProperty({ param, depth = 0 }) {
|
|
419
|
+
const [expanded, setExpanded] = useState(false);
|
|
420
|
+
const type = formatType(param.schema);
|
|
421
|
+
const isOptional = param.required === false;
|
|
422
|
+
const nestedProps = getNestedProperties(param.schema);
|
|
423
|
+
const nestedCount = countProperties(param.schema);
|
|
424
|
+
const hasNested = nestedCount > 0;
|
|
425
|
+
return /* @__PURE__ */ jsxDEV5("div", {
|
|
426
|
+
className: "flex flex-col border-b border-fd-border last:border-0",
|
|
427
|
+
children: [
|
|
428
|
+
/* @__PURE__ */ jsxDEV5("div", {
|
|
429
|
+
className: "flex flex-row items-start gap-2 py-3",
|
|
430
|
+
children: [
|
|
431
|
+
/* @__PURE__ */ jsxDEV5("div", {
|
|
432
|
+
className: "flex-1 min-w-0",
|
|
433
|
+
children: [
|
|
434
|
+
/* @__PURE__ */ jsxDEV5("div", {
|
|
435
|
+
className: "flex items-baseline gap-2 flex-wrap",
|
|
436
|
+
children: [
|
|
437
|
+
/* @__PURE__ */ jsxDEV5("span", {
|
|
438
|
+
className: "font-mono text-sm font-medium text-fd-foreground",
|
|
439
|
+
children: [
|
|
440
|
+
param.name,
|
|
441
|
+
isOptional && "?",
|
|
442
|
+
":"
|
|
443
|
+
]
|
|
444
|
+
}, undefined, true, undefined, this),
|
|
445
|
+
/* @__PURE__ */ jsxDEV5("span", {
|
|
446
|
+
className: "font-mono text-sm text-fd-muted-foreground",
|
|
447
|
+
children: hasNested ? "object" : type
|
|
448
|
+
}, undefined, false, undefined, this)
|
|
449
|
+
]
|
|
450
|
+
}, undefined, true, undefined, this),
|
|
451
|
+
param.description && /* @__PURE__ */ jsxDEV5("p", {
|
|
452
|
+
className: "text-sm text-fd-muted-foreground mt-1 leading-relaxed",
|
|
453
|
+
children: param.description
|
|
454
|
+
}, undefined, false, undefined, this)
|
|
455
|
+
]
|
|
456
|
+
}, undefined, true, undefined, this),
|
|
457
|
+
hasNested && /* @__PURE__ */ jsxDEV5("button", {
|
|
458
|
+
onClick: () => setExpanded(!expanded),
|
|
459
|
+
className: `flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-md
|
|
460
|
+
bg-fd-muted text-fd-muted-foreground hover:bg-fd-accent hover:text-fd-accent-foreground
|
|
461
|
+
transition-colors cursor-pointer shrink-0`,
|
|
462
|
+
children: [
|
|
463
|
+
/* @__PURE__ */ jsxDEV5(ChevronIcon, {
|
|
464
|
+
expanded
|
|
465
|
+
}, undefined, false, undefined, this),
|
|
466
|
+
/* @__PURE__ */ jsxDEV5("span", {
|
|
467
|
+
children: [
|
|
468
|
+
nestedCount,
|
|
469
|
+
" properties"
|
|
470
|
+
]
|
|
471
|
+
}, undefined, true, undefined, this)
|
|
472
|
+
]
|
|
473
|
+
}, undefined, true, undefined, this)
|
|
474
|
+
]
|
|
475
|
+
}, undefined, true, undefined, this),
|
|
476
|
+
hasNested && expanded && nestedProps && /* @__PURE__ */ jsxDEV5("div", {
|
|
477
|
+
className: "ml-4 mb-3 rounded-lg border border-fd-border bg-fd-card/50 overflow-hidden",
|
|
478
|
+
children: Object.entries(nestedProps).map(([propName, propSchema]) => /* @__PURE__ */ jsxDEV5(NestedProperty, {
|
|
479
|
+
name: propName,
|
|
480
|
+
schema: propSchema,
|
|
481
|
+
required: getRequiredFields(param.schema).includes(propName),
|
|
482
|
+
depth: depth + 1
|
|
483
|
+
}, propName, false, undefined, this))
|
|
484
|
+
}, undefined, false, undefined, this)
|
|
485
|
+
]
|
|
486
|
+
}, undefined, true, undefined, this);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// src/components/collapsible-method.tsx
|
|
490
|
+
import { useState as useState2, useEffect } from "react";
|
|
491
|
+
import { jsxDEV as jsxDEV6 } from "react/jsx-dev-runtime";
|
|
492
|
+
|
|
493
|
+
function ChevronIcon2({ expanded }) {
|
|
494
|
+
return /* @__PURE__ */ jsxDEV6("svg", {
|
|
495
|
+
width: "16",
|
|
496
|
+
height: "16",
|
|
497
|
+
viewBox: "0 0 16 16",
|
|
498
|
+
fill: "none",
|
|
499
|
+
className: `transition-transform duration-200 ${expanded ? "rotate-90" : ""}`,
|
|
500
|
+
children: /* @__PURE__ */ jsxDEV6("path", {
|
|
501
|
+
d: "M6 4L10 8L6 12",
|
|
502
|
+
stroke: "currentColor",
|
|
503
|
+
strokeWidth: "1.5",
|
|
504
|
+
strokeLinecap: "round",
|
|
505
|
+
strokeLinejoin: "round"
|
|
506
|
+
}, undefined, false, undefined, this)
|
|
507
|
+
}, undefined, false, undefined, this);
|
|
508
|
+
}
|
|
509
|
+
function formatSchema3(schema) {
|
|
510
|
+
if (!schema)
|
|
511
|
+
return "unknown";
|
|
512
|
+
if (typeof schema === "string")
|
|
513
|
+
return schema;
|
|
514
|
+
if (typeof schema === "object" && schema !== null) {
|
|
515
|
+
const s = schema;
|
|
516
|
+
if (s.$ref && typeof s.$ref === "string") {
|
|
517
|
+
return s.$ref.replace("#/types/", "");
|
|
518
|
+
}
|
|
519
|
+
if (s.tsType) {
|
|
520
|
+
const tsType = String(s.tsType);
|
|
521
|
+
if (tsType.length > 40)
|
|
522
|
+
return tsType.slice(0, 37) + "...";
|
|
523
|
+
return tsType;
|
|
524
|
+
}
|
|
525
|
+
if (s.type)
|
|
526
|
+
return String(s.type);
|
|
527
|
+
}
|
|
528
|
+
return "unknown";
|
|
529
|
+
}
|
|
530
|
+
function formatReturnType(returns) {
|
|
531
|
+
if (!returns)
|
|
532
|
+
return "void";
|
|
533
|
+
if (returns.tsType) {
|
|
534
|
+
const t = returns.tsType;
|
|
535
|
+
if (t.length > 40)
|
|
536
|
+
return t.slice(0, 37) + "...";
|
|
537
|
+
return t;
|
|
538
|
+
}
|
|
539
|
+
return formatSchema3(returns.schema);
|
|
540
|
+
}
|
|
541
|
+
function formatParamPreview(params) {
|
|
542
|
+
if (!params || params.length === 0)
|
|
543
|
+
return "";
|
|
544
|
+
if (params.length === 1)
|
|
545
|
+
return params[0].name || "arg";
|
|
546
|
+
return `${params[0].name || "arg"}, ...`;
|
|
547
|
+
}
|
|
548
|
+
function CollapsibleMethod({ member, defaultExpanded = false }) {
|
|
549
|
+
const [expanded, setExpanded] = useState2(defaultExpanded);
|
|
550
|
+
const sig = member.signatures?.[0];
|
|
551
|
+
const hasParams = sig?.parameters && sig.parameters.length > 0;
|
|
552
|
+
const visibility = member.visibility ?? "public";
|
|
553
|
+
const flags = member.flags;
|
|
554
|
+
const isStatic = flags?.static;
|
|
555
|
+
const isAsync = flags?.async;
|
|
556
|
+
const returnType = formatReturnType(sig?.returns);
|
|
557
|
+
const returnDescription = sig?.returns?.description;
|
|
558
|
+
const paramPreview = formatParamPreview(sig?.parameters);
|
|
559
|
+
useEffect(() => {
|
|
560
|
+
if (typeof window !== "undefined" && window.location.hash === `#${member.name}`) {
|
|
561
|
+
setExpanded(true);
|
|
562
|
+
}
|
|
563
|
+
}, [member.name]);
|
|
564
|
+
return /* @__PURE__ */ jsxDEV6("div", {
|
|
565
|
+
id: member.name,
|
|
566
|
+
className: "scroll-mt-20 border-b border-fd-border last:border-0",
|
|
567
|
+
children: [
|
|
568
|
+
/* @__PURE__ */ jsxDEV6("button", {
|
|
569
|
+
onClick: () => setExpanded(!expanded),
|
|
570
|
+
className: "w-full flex items-center gap-3 py-4 px-1 text-left hover:bg-fd-muted/30 transition-colors cursor-pointer group",
|
|
571
|
+
children: [
|
|
572
|
+
/* @__PURE__ */ jsxDEV6("span", {
|
|
573
|
+
className: "text-fd-muted-foreground group-hover:text-fd-foreground transition-colors",
|
|
574
|
+
children: /* @__PURE__ */ jsxDEV6(ChevronIcon2, {
|
|
575
|
+
expanded
|
|
576
|
+
}, undefined, false, undefined, this)
|
|
577
|
+
}, undefined, false, undefined, this),
|
|
578
|
+
/* @__PURE__ */ jsxDEV6("div", {
|
|
579
|
+
className: "flex-1 min-w-0 flex items-baseline gap-2 flex-wrap",
|
|
580
|
+
children: [
|
|
581
|
+
/* @__PURE__ */ jsxDEV6("span", {
|
|
582
|
+
className: "font-mono text-sm font-semibold text-fd-foreground",
|
|
583
|
+
children: [
|
|
584
|
+
member.name,
|
|
585
|
+
/* @__PURE__ */ jsxDEV6("span", {
|
|
586
|
+
className: "text-fd-muted-foreground font-normal",
|
|
587
|
+
children: [
|
|
588
|
+
"(",
|
|
589
|
+
paramPreview,
|
|
590
|
+
")"
|
|
591
|
+
]
|
|
592
|
+
}, undefined, true, undefined, this)
|
|
593
|
+
]
|
|
594
|
+
}, undefined, true, undefined, this),
|
|
595
|
+
/* @__PURE__ */ jsxDEV6("span", {
|
|
596
|
+
className: "text-fd-muted-foreground",
|
|
597
|
+
children: "→"
|
|
598
|
+
}, undefined, false, undefined, this),
|
|
599
|
+
/* @__PURE__ */ jsxDEV6("span", {
|
|
600
|
+
className: "font-mono text-sm text-fd-muted-foreground truncate",
|
|
601
|
+
children: returnType
|
|
602
|
+
}, undefined, false, undefined, this)
|
|
603
|
+
]
|
|
604
|
+
}, undefined, true, undefined, this),
|
|
605
|
+
/* @__PURE__ */ jsxDEV6("div", {
|
|
606
|
+
className: "flex gap-1.5 shrink-0",
|
|
607
|
+
children: [
|
|
608
|
+
visibility !== "public" && /* @__PURE__ */ jsxDEV6("span", {
|
|
609
|
+
className: "text-xs px-1.5 py-0.5 rounded bg-fd-muted text-fd-muted-foreground",
|
|
610
|
+
children: visibility
|
|
611
|
+
}, undefined, false, undefined, this),
|
|
612
|
+
isStatic && /* @__PURE__ */ jsxDEV6("span", {
|
|
613
|
+
className: "text-xs px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-600 dark:text-blue-400",
|
|
614
|
+
children: "static"
|
|
615
|
+
}, undefined, false, undefined, this),
|
|
616
|
+
isAsync && /* @__PURE__ */ jsxDEV6("span", {
|
|
617
|
+
className: "text-xs px-1.5 py-0.5 rounded bg-purple-500/10 text-purple-600 dark:text-purple-400",
|
|
618
|
+
children: "async"
|
|
619
|
+
}, undefined, false, undefined, this)
|
|
620
|
+
]
|
|
621
|
+
}, undefined, true, undefined, this)
|
|
622
|
+
]
|
|
623
|
+
}, undefined, true, undefined, this),
|
|
624
|
+
expanded && /* @__PURE__ */ jsxDEV6("div", {
|
|
625
|
+
className: "pb-6 pl-8 pr-4",
|
|
626
|
+
children: [
|
|
627
|
+
member.description && /* @__PURE__ */ jsxDEV6("p", {
|
|
628
|
+
className: "text-fd-muted-foreground mb-4 leading-relaxed",
|
|
629
|
+
children: member.description
|
|
630
|
+
}, undefined, false, undefined, this),
|
|
631
|
+
hasParams && /* @__PURE__ */ jsxDEV6("div", {
|
|
632
|
+
className: "mb-4",
|
|
633
|
+
children: [
|
|
634
|
+
/* @__PURE__ */ jsxDEV6("span", {
|
|
635
|
+
className: "text-xs uppercase tracking-wide text-fd-muted-foreground font-medium block mb-2",
|
|
636
|
+
children: "Parameters"
|
|
637
|
+
}, undefined, false, undefined, this),
|
|
638
|
+
/* @__PURE__ */ jsxDEV6("div", {
|
|
639
|
+
className: "border-l-2 border-fd-border pl-4",
|
|
640
|
+
children: sig.parameters.map((param, index) => /* @__PURE__ */ jsxDEV6(ExpandableProperty, {
|
|
641
|
+
param
|
|
642
|
+
}, param.name ?? index, false, undefined, this))
|
|
643
|
+
}, undefined, false, undefined, this)
|
|
644
|
+
]
|
|
645
|
+
}, undefined, true, undefined, this),
|
|
646
|
+
sig?.returns && returnType !== "void" && /* @__PURE__ */ jsxDEV6("div", {
|
|
647
|
+
children: [
|
|
648
|
+
/* @__PURE__ */ jsxDEV6("span", {
|
|
649
|
+
className: "text-xs uppercase tracking-wide text-fd-muted-foreground font-medium block mb-2",
|
|
650
|
+
children: "Returns"
|
|
651
|
+
}, undefined, false, undefined, this),
|
|
652
|
+
/* @__PURE__ */ jsxDEV6("div", {
|
|
653
|
+
className: "border-l-2 border-fd-border pl-4 py-2",
|
|
654
|
+
children: [
|
|
655
|
+
/* @__PURE__ */ jsxDEV6("span", {
|
|
656
|
+
className: "font-mono text-sm text-fd-muted-foreground",
|
|
657
|
+
children: sig.returns.tsType || formatSchema3(sig.returns.schema)
|
|
658
|
+
}, undefined, false, undefined, this),
|
|
659
|
+
returnDescription && /* @__PURE__ */ jsxDEV6("p", {
|
|
660
|
+
className: "text-sm text-fd-muted-foreground mt-1 leading-relaxed",
|
|
661
|
+
children: returnDescription
|
|
662
|
+
}, undefined, false, undefined, this)
|
|
663
|
+
]
|
|
664
|
+
}, undefined, true, undefined, this)
|
|
665
|
+
]
|
|
666
|
+
}, undefined, true, undefined, this)
|
|
667
|
+
]
|
|
668
|
+
}, undefined, true, undefined, this)
|
|
669
|
+
]
|
|
670
|
+
}, undefined, true, undefined, this);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// src/components/class-page.tsx
|
|
674
|
+
import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
|
|
675
|
+
|
|
676
|
+
function formatSchema4(schema) {
|
|
677
|
+
if (!schema)
|
|
678
|
+
return "unknown";
|
|
679
|
+
if (typeof schema === "string")
|
|
680
|
+
return schema;
|
|
681
|
+
if (typeof schema === "object" && schema !== null) {
|
|
682
|
+
const s = schema;
|
|
683
|
+
if (s.$ref && typeof s.$ref === "string") {
|
|
684
|
+
return s.$ref.replace("#/types/", "");
|
|
685
|
+
}
|
|
686
|
+
if (s.tsType)
|
|
687
|
+
return String(s.tsType);
|
|
688
|
+
if (s.type)
|
|
689
|
+
return String(s.type);
|
|
690
|
+
}
|
|
691
|
+
return "unknown";
|
|
692
|
+
}
|
|
693
|
+
function PropertyItem({ member }) {
|
|
694
|
+
const visibility = member.visibility ?? "public";
|
|
695
|
+
const flags = member.flags;
|
|
696
|
+
const isStatic = flags?.static;
|
|
697
|
+
const isReadonly = flags?.readonly;
|
|
698
|
+
const type = formatSchema4(member.schema);
|
|
699
|
+
return /* @__PURE__ */ jsxDEV7("div", {
|
|
700
|
+
className: "py-3 border-b border-fd-border last:border-0",
|
|
701
|
+
children: [
|
|
702
|
+
/* @__PURE__ */ jsxDEV7("div", {
|
|
703
|
+
className: "flex items-baseline gap-2 flex-wrap",
|
|
704
|
+
children: [
|
|
705
|
+
/* @__PURE__ */ jsxDEV7("span", {
|
|
706
|
+
className: "font-semibold text-fd-foreground",
|
|
707
|
+
children: [
|
|
708
|
+
member.name,
|
|
709
|
+
":"
|
|
710
|
+
]
|
|
711
|
+
}, undefined, true, undefined, this),
|
|
712
|
+
/* @__PURE__ */ jsxDEV7("span", {
|
|
713
|
+
className: "text-fd-muted-foreground font-mono text-sm",
|
|
714
|
+
children: type
|
|
715
|
+
}, undefined, false, undefined, this),
|
|
716
|
+
visibility !== "public" && /* @__PURE__ */ jsxDEV7("span", {
|
|
717
|
+
className: "text-xs px-1.5 py-0.5 rounded bg-fd-muted text-fd-muted-foreground",
|
|
718
|
+
children: visibility
|
|
719
|
+
}, undefined, false, undefined, this),
|
|
720
|
+
isStatic && /* @__PURE__ */ jsxDEV7("span", {
|
|
721
|
+
className: "text-xs px-1.5 py-0.5 rounded bg-blue-500/10 text-blue-600 dark:text-blue-400",
|
|
722
|
+
children: "static"
|
|
723
|
+
}, undefined, false, undefined, this),
|
|
724
|
+
isReadonly && /* @__PURE__ */ jsxDEV7("span", {
|
|
725
|
+
className: "text-xs px-1.5 py-0.5 rounded bg-purple-500/10 text-purple-600 dark:text-purple-400",
|
|
726
|
+
children: "readonly"
|
|
727
|
+
}, undefined, false, undefined, this)
|
|
728
|
+
]
|
|
729
|
+
}, undefined, true, undefined, this),
|
|
730
|
+
member.description && /* @__PURE__ */ jsxDEV7("p", {
|
|
731
|
+
className: "text-sm text-fd-muted-foreground mt-1",
|
|
732
|
+
children: member.description
|
|
733
|
+
}, undefined, false, undefined, this)
|
|
734
|
+
]
|
|
735
|
+
}, undefined, true, undefined, this);
|
|
736
|
+
}
|
|
737
|
+
function ClassPage({ export: exp, spec }) {
|
|
738
|
+
const hasExamples = exp.examples && exp.examples.length > 0;
|
|
739
|
+
const constructors = exp.members?.filter((m) => m.kind === "constructor") ?? [];
|
|
740
|
+
const properties = exp.members?.filter((m) => m.kind === "property" || m.kind === "field") ?? [];
|
|
741
|
+
const methods = exp.members?.filter((m) => m.kind === "method") ?? [];
|
|
742
|
+
const constructorSig = constructors[0]?.signatures?.[0];
|
|
743
|
+
const constructorParams = constructorSig?.parameters ?? [];
|
|
744
|
+
return /* @__PURE__ */ jsxDEV7("div", {
|
|
745
|
+
className: "space-y-8",
|
|
746
|
+
children: [
|
|
747
|
+
exp.description && /* @__PURE__ */ jsxDEV7("p", {
|
|
748
|
+
className: "text-fd-muted-foreground text-lg leading-relaxed",
|
|
749
|
+
children: exp.description
|
|
750
|
+
}, undefined, false, undefined, this),
|
|
751
|
+
/* @__PURE__ */ jsxDEV7("div", {
|
|
752
|
+
className: "rounded-lg border border-fd-border bg-fd-muted/30 p-4 overflow-x-auto",
|
|
753
|
+
children: /* @__PURE__ */ jsxDEV7("code", {
|
|
754
|
+
className: "font-mono text-sm text-fd-foreground whitespace-pre",
|
|
755
|
+
children: [
|
|
756
|
+
"class ",
|
|
757
|
+
exp.name,
|
|
758
|
+
exp.extends ? ` extends ${exp.extends}` : "",
|
|
759
|
+
exp.implements?.length ? ` implements ${exp.implements.join(", ")}` : ""
|
|
760
|
+
]
|
|
761
|
+
}, undefined, true, undefined, this)
|
|
762
|
+
}, undefined, false, undefined, this),
|
|
763
|
+
/* @__PURE__ */ jsxDEV7("div", {
|
|
764
|
+
className: `grid gap-8 ${hasExamples ? "lg:grid-cols-2" : "grid-cols-1"}`,
|
|
765
|
+
children: [
|
|
766
|
+
/* @__PURE__ */ jsxDEV7("div", {
|
|
767
|
+
className: "space-y-8",
|
|
768
|
+
children: [
|
|
769
|
+
constructorParams.length > 0 && /* @__PURE__ */ jsxDEV7("section", {
|
|
770
|
+
children: [
|
|
771
|
+
/* @__PURE__ */ jsxDEV7("h3", {
|
|
772
|
+
className: "text-sm font-semibold uppercase tracking-wide text-fd-muted-foreground mb-4",
|
|
773
|
+
children: "Constructor"
|
|
774
|
+
}, undefined, false, undefined, this),
|
|
775
|
+
/* @__PURE__ */ jsxDEV7("div", {
|
|
776
|
+
className: "ml-2 border-l-2 border-fd-border pl-4",
|
|
777
|
+
children: constructorParams.map((param, index) => /* @__PURE__ */ jsxDEV7(ExpandableProperty, {
|
|
778
|
+
param
|
|
779
|
+
}, param.name ?? index, false, undefined, this))
|
|
780
|
+
}, undefined, false, undefined, this)
|
|
781
|
+
]
|
|
782
|
+
}, undefined, true, undefined, this),
|
|
783
|
+
methods.length > 0 && /* @__PURE__ */ jsxDEV7("section", {
|
|
784
|
+
children: [
|
|
785
|
+
/* @__PURE__ */ jsxDEV7("h3", {
|
|
786
|
+
className: "text-sm font-semibold uppercase tracking-wide text-fd-muted-foreground mb-4",
|
|
787
|
+
children: "Methods"
|
|
788
|
+
}, undefined, false, undefined, this),
|
|
789
|
+
/* @__PURE__ */ jsxDEV7("div", {
|
|
790
|
+
className: "rounded-lg border border-fd-border overflow-hidden",
|
|
791
|
+
children: methods.map((member, index) => /* @__PURE__ */ jsxDEV7(CollapsibleMethod, {
|
|
792
|
+
member,
|
|
793
|
+
defaultExpanded: index === 0
|
|
794
|
+
}, member.name ?? index, false, undefined, this))
|
|
795
|
+
}, undefined, false, undefined, this)
|
|
796
|
+
]
|
|
797
|
+
}, undefined, true, undefined, this),
|
|
798
|
+
properties.length > 0 && /* @__PURE__ */ jsxDEV7("section", {
|
|
799
|
+
children: [
|
|
800
|
+
/* @__PURE__ */ jsxDEV7("h3", {
|
|
801
|
+
className: "text-sm font-semibold uppercase tracking-wide text-fd-muted-foreground mb-4",
|
|
802
|
+
children: "Properties"
|
|
803
|
+
}, undefined, false, undefined, this),
|
|
804
|
+
/* @__PURE__ */ jsxDEV7("div", {
|
|
805
|
+
className: "rounded-lg border border-fd-border bg-fd-card px-4",
|
|
806
|
+
children: properties.map((member, index) => /* @__PURE__ */ jsxDEV7(PropertyItem, {
|
|
807
|
+
member
|
|
808
|
+
}, member.name ?? index, false, undefined, this))
|
|
809
|
+
}, undefined, false, undefined, this)
|
|
810
|
+
]
|
|
811
|
+
}, undefined, true, undefined, this)
|
|
812
|
+
]
|
|
813
|
+
}, undefined, true, undefined, this),
|
|
814
|
+
hasExamples && /* @__PURE__ */ jsxDEV7("div", {
|
|
815
|
+
className: "lg:sticky lg:top-20 lg:self-start",
|
|
816
|
+
children: [
|
|
817
|
+
/* @__PURE__ */ jsxDEV7("h3", {
|
|
818
|
+
className: "text-sm font-semibold uppercase tracking-wide text-fd-muted-foreground mb-4",
|
|
819
|
+
children: "Example"
|
|
820
|
+
}, undefined, false, undefined, this),
|
|
821
|
+
/* @__PURE__ */ jsxDEV7(CodeExample, {
|
|
822
|
+
code: exp.examples[0],
|
|
823
|
+
filename: `${exp.name.toLowerCase()}.ts`
|
|
824
|
+
}, undefined, false, undefined, this)
|
|
825
|
+
]
|
|
826
|
+
}, undefined, true, undefined, this)
|
|
827
|
+
]
|
|
828
|
+
}, undefined, true, undefined, this),
|
|
829
|
+
exp.docs && /* @__PURE__ */ jsxDEV7(CoverageBadge, {
|
|
830
|
+
docs: exp.docs
|
|
831
|
+
}, undefined, false, undefined, this)
|
|
832
|
+
]
|
|
833
|
+
}, undefined, true, undefined, this);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
// src/components/signature.tsx
|
|
837
|
+
import { ClientDocsKitCode as ClientDocsKitCode2 } from "@doccov/ui/docskit";
|
|
838
|
+
import { jsxDEV as jsxDEV8 } from "react/jsx-dev-runtime";
|
|
839
|
+
|
|
840
|
+
function formatTypeParameters(typeParams) {
|
|
841
|
+
if (!typeParams?.length)
|
|
842
|
+
return "";
|
|
843
|
+
const params = typeParams.map((tp) => {
|
|
844
|
+
let str = tp.name;
|
|
845
|
+
if (tp.constraint)
|
|
846
|
+
str += ` extends ${tp.constraint}`;
|
|
847
|
+
if (tp.default)
|
|
848
|
+
str += ` = ${tp.default}`;
|
|
849
|
+
return str;
|
|
850
|
+
});
|
|
851
|
+
return `<${params.join(", ")}>`;
|
|
852
|
+
}
|
|
853
|
+
function formatParameters(sig) {
|
|
854
|
+
if (!sig?.parameters?.length)
|
|
855
|
+
return "()";
|
|
856
|
+
const params = sig.parameters.map((p) => {
|
|
857
|
+
const optional = p.required === false ? "?" : "";
|
|
858
|
+
const type = formatSchema5(p.schema);
|
|
859
|
+
return `${p.name}${optional}: ${type}`;
|
|
860
|
+
});
|
|
861
|
+
return `(${params.join(", ")})`;
|
|
862
|
+
}
|
|
863
|
+
function formatSchema5(schema) {
|
|
864
|
+
if (!schema)
|
|
865
|
+
return "unknown";
|
|
866
|
+
if (typeof schema === "string")
|
|
867
|
+
return schema;
|
|
868
|
+
if (typeof schema === "object" && schema !== null) {
|
|
869
|
+
const s = schema;
|
|
870
|
+
if (s.$ref && typeof s.$ref === "string") {
|
|
871
|
+
return s.$ref.replace("#/types/", "");
|
|
872
|
+
}
|
|
873
|
+
if (s.tsType)
|
|
874
|
+
return String(s.tsType);
|
|
875
|
+
if (s.type)
|
|
876
|
+
return String(s.type);
|
|
877
|
+
}
|
|
878
|
+
return "unknown";
|
|
879
|
+
}
|
|
880
|
+
function formatReturnType2(sig) {
|
|
881
|
+
if (!sig?.returns)
|
|
882
|
+
return "void";
|
|
883
|
+
if (sig.returns.tsType)
|
|
884
|
+
return sig.returns.tsType;
|
|
885
|
+
return formatSchema5(sig.returns.schema);
|
|
886
|
+
}
|
|
887
|
+
function buildSignatureString(exp, sigIndex = 0) {
|
|
888
|
+
const sig = exp.signatures?.[sigIndex];
|
|
889
|
+
const typeParams = formatTypeParameters(exp.typeParameters || sig?.typeParameters);
|
|
890
|
+
switch (exp.kind) {
|
|
891
|
+
case "function": {
|
|
892
|
+
const params = formatParameters(sig);
|
|
893
|
+
const returnType = formatReturnType2(sig);
|
|
894
|
+
return `function ${exp.name}${typeParams}${params}: ${returnType}`;
|
|
895
|
+
}
|
|
896
|
+
case "class": {
|
|
897
|
+
const ext = exp.extends ? ` extends ${exp.extends}` : "";
|
|
898
|
+
const impl = exp.implements?.length ? ` implements ${exp.implements.join(", ")}` : "";
|
|
899
|
+
return `class ${exp.name}${typeParams}${ext}${impl}`;
|
|
900
|
+
}
|
|
901
|
+
case "interface": {
|
|
902
|
+
const ext = exp.extends ? ` extends ${exp.extends}` : "";
|
|
903
|
+
return `interface ${exp.name}${typeParams}${ext}`;
|
|
904
|
+
}
|
|
905
|
+
case "type": {
|
|
906
|
+
const typeValue = typeof exp.type === "string" ? exp.type : formatSchema5(exp.schema);
|
|
907
|
+
return `type ${exp.name}${typeParams} = ${typeValue}`;
|
|
908
|
+
}
|
|
909
|
+
case "enum": {
|
|
910
|
+
return `enum ${exp.name}`;
|
|
911
|
+
}
|
|
912
|
+
case "variable": {
|
|
913
|
+
const typeValue = typeof exp.type === "string" ? exp.type : formatSchema5(exp.schema);
|
|
914
|
+
return `const ${exp.name}: ${typeValue}`;
|
|
915
|
+
}
|
|
916
|
+
default:
|
|
917
|
+
return exp.name;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
function Signature({ export: exp, signatureIndex = 0 }) {
|
|
921
|
+
const signature = buildSignatureString(exp, signatureIndex);
|
|
922
|
+
const codeblock = {
|
|
923
|
+
value: signature,
|
|
924
|
+
lang: "typescript",
|
|
925
|
+
meta: "c"
|
|
926
|
+
};
|
|
927
|
+
return /* @__PURE__ */ jsxDEV8("div", {
|
|
928
|
+
className: "not-prose",
|
|
929
|
+
children: [
|
|
930
|
+
/* @__PURE__ */ jsxDEV8(ClientDocsKitCode2, {
|
|
931
|
+
codeblock
|
|
932
|
+
}, undefined, false, undefined, this),
|
|
933
|
+
exp.deprecated && /* @__PURE__ */ jsxDEV8("div", {
|
|
934
|
+
className: "mt-2 rounded-md bg-yellow-500/10 border border-yellow-500/20 px-3 py-2 text-sm text-yellow-600 dark:text-yellow-400",
|
|
935
|
+
children: [
|
|
936
|
+
/* @__PURE__ */ jsxDEV8("strong", {
|
|
937
|
+
children: "Deprecated:"
|
|
938
|
+
}, undefined, false, undefined, this),
|
|
939
|
+
" This export is deprecated."
|
|
940
|
+
]
|
|
941
|
+
}, undefined, true, undefined, this)
|
|
942
|
+
]
|
|
943
|
+
}, undefined, true, undefined, this);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
// src/components/type-table.tsx
|
|
947
|
+
import { jsxDEV as jsxDEV9 } from "react/jsx-dev-runtime";
|
|
948
|
+
|
|
949
|
+
function formatSchema6(schema) {
|
|
950
|
+
if (!schema)
|
|
951
|
+
return "unknown";
|
|
952
|
+
if (typeof schema === "string")
|
|
953
|
+
return schema;
|
|
954
|
+
if (typeof schema === "object" && schema !== null) {
|
|
955
|
+
const s = schema;
|
|
956
|
+
if (s.$ref && typeof s.$ref === "string") {
|
|
957
|
+
const refName = s.$ref.replace("#/types/", "");
|
|
958
|
+
return refName;
|
|
959
|
+
}
|
|
960
|
+
if (s.type)
|
|
961
|
+
return String(s.type);
|
|
962
|
+
if (s.tsType)
|
|
963
|
+
return String(s.tsType);
|
|
964
|
+
}
|
|
965
|
+
return "unknown";
|
|
966
|
+
}
|
|
967
|
+
function isParameter(item) {
|
|
968
|
+
return "required" in item;
|
|
969
|
+
}
|
|
970
|
+
function TypeTable({ items, showRequired = true }) {
|
|
971
|
+
if (!items?.length)
|
|
972
|
+
return null;
|
|
973
|
+
return /* @__PURE__ */ jsxDEV9("div", {
|
|
974
|
+
className: "my-4 overflow-x-auto",
|
|
975
|
+
children: /* @__PURE__ */ jsxDEV9("table", {
|
|
976
|
+
className: "w-full text-sm border-collapse",
|
|
977
|
+
children: [
|
|
978
|
+
/* @__PURE__ */ jsxDEV9("thead", {
|
|
979
|
+
children: /* @__PURE__ */ jsxDEV9("tr", {
|
|
980
|
+
className: "border-b border-fd-border",
|
|
981
|
+
children: [
|
|
982
|
+
/* @__PURE__ */ jsxDEV9("th", {
|
|
983
|
+
className: "text-left py-2 px-3 font-medium text-fd-muted-foreground",
|
|
984
|
+
children: "Name"
|
|
985
|
+
}, undefined, false, undefined, this),
|
|
986
|
+
/* @__PURE__ */ jsxDEV9("th", {
|
|
987
|
+
className: "text-left py-2 px-3 font-medium text-fd-muted-foreground",
|
|
988
|
+
children: "Type"
|
|
989
|
+
}, undefined, false, undefined, this),
|
|
990
|
+
/* @__PURE__ */ jsxDEV9("th", {
|
|
991
|
+
className: "text-left py-2 px-3 font-medium text-fd-muted-foreground",
|
|
992
|
+
children: "Description"
|
|
993
|
+
}, undefined, false, undefined, this)
|
|
994
|
+
]
|
|
995
|
+
}, undefined, true, undefined, this)
|
|
996
|
+
}, undefined, false, undefined, this),
|
|
997
|
+
/* @__PURE__ */ jsxDEV9("tbody", {
|
|
998
|
+
children: items.map((item, index) => {
|
|
999
|
+
const name = item.name ?? `arg${index}`;
|
|
1000
|
+
const type = formatSchema6(item.schema);
|
|
1001
|
+
const description = item.description ?? "";
|
|
1002
|
+
const required = isParameter(item) ? item.required : true;
|
|
1003
|
+
return /* @__PURE__ */ jsxDEV9("tr", {
|
|
1004
|
+
className: "border-b border-fd-border last:border-0",
|
|
1005
|
+
children: [
|
|
1006
|
+
/* @__PURE__ */ jsxDEV9("td", {
|
|
1007
|
+
className: "py-2 px-3 align-top",
|
|
1008
|
+
children: [
|
|
1009
|
+
/* @__PURE__ */ jsxDEV9("code", {
|
|
1010
|
+
className: "text-fd-primary font-mono text-xs bg-fd-secondary px-1.5 py-0.5 rounded",
|
|
1011
|
+
children: name
|
|
1012
|
+
}, undefined, false, undefined, this),
|
|
1013
|
+
showRequired && required && /* @__PURE__ */ jsxDEV9("span", {
|
|
1014
|
+
className: "ml-1 text-red-500 text-xs",
|
|
1015
|
+
children: "*"
|
|
1016
|
+
}, undefined, false, undefined, this),
|
|
1017
|
+
showRequired && !required && /* @__PURE__ */ jsxDEV9("span", {
|
|
1018
|
+
className: "ml-1 text-fd-muted-foreground text-xs",
|
|
1019
|
+
children: "?"
|
|
1020
|
+
}, undefined, false, undefined, this)
|
|
1021
|
+
]
|
|
1022
|
+
}, undefined, true, undefined, this),
|
|
1023
|
+
/* @__PURE__ */ jsxDEV9("td", {
|
|
1024
|
+
className: "py-2 px-3 align-top",
|
|
1025
|
+
children: /* @__PURE__ */ jsxDEV9("code", {
|
|
1026
|
+
className: "font-mono text-xs text-fd-muted-foreground",
|
|
1027
|
+
children: type
|
|
1028
|
+
}, undefined, false, undefined, this)
|
|
1029
|
+
}, undefined, false, undefined, this),
|
|
1030
|
+
/* @__PURE__ */ jsxDEV9("td", {
|
|
1031
|
+
className: "py-2 px-3 align-top text-fd-muted-foreground",
|
|
1032
|
+
children: description
|
|
1033
|
+
}, undefined, false, undefined, this)
|
|
1034
|
+
]
|
|
1035
|
+
}, name, true, undefined, this);
|
|
1036
|
+
})
|
|
1037
|
+
}, undefined, false, undefined, this)
|
|
1038
|
+
]
|
|
1039
|
+
}, undefined, true, undefined, this)
|
|
1040
|
+
}, undefined, false, undefined, this);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
// src/components/examples.tsx
|
|
1044
|
+
import { useState as useState3 } from "react";
|
|
1045
|
+
import { jsxDEV as jsxDEV10 } from "react/jsx-dev-runtime";
|
|
1046
|
+
|
|
1047
|
+
function CopyButton({ text }) {
|
|
1048
|
+
const [copied, setCopied] = useState3(false);
|
|
1049
|
+
const handleCopy = async () => {
|
|
1050
|
+
await navigator.clipboard.writeText(text);
|
|
1051
|
+
setCopied(true);
|
|
1052
|
+
setTimeout(() => setCopied(false), 2000);
|
|
1053
|
+
};
|
|
1054
|
+
return /* @__PURE__ */ jsxDEV10("button", {
|
|
1055
|
+
type: "button",
|
|
1056
|
+
onClick: handleCopy,
|
|
1057
|
+
className: "absolute top-2 right-2 p-1.5 rounded-md bg-fd-secondary hover:bg-fd-accent text-fd-muted-foreground hover:text-fd-foreground transition-colors opacity-0 group-hover:opacity-100",
|
|
1058
|
+
"aria-label": "Copy code",
|
|
1059
|
+
children: copied ? /* @__PURE__ */ jsxDEV10("svg", {
|
|
1060
|
+
className: "w-4 h-4",
|
|
1061
|
+
fill: "none",
|
|
1062
|
+
stroke: "currentColor",
|
|
1063
|
+
viewBox: "0 0 24 24",
|
|
1064
|
+
children: /* @__PURE__ */ jsxDEV10("path", {
|
|
1065
|
+
strokeLinecap: "round",
|
|
1066
|
+
strokeLinejoin: "round",
|
|
1067
|
+
strokeWidth: 2,
|
|
1068
|
+
d: "M5 13l4 4L19 7"
|
|
1069
|
+
}, undefined, false, undefined, this)
|
|
1070
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsxDEV10("svg", {
|
|
1071
|
+
className: "w-4 h-4",
|
|
1072
|
+
fill: "none",
|
|
1073
|
+
stroke: "currentColor",
|
|
1074
|
+
viewBox: "0 0 24 24",
|
|
1075
|
+
children: /* @__PURE__ */ jsxDEV10("path", {
|
|
1076
|
+
strokeLinecap: "round",
|
|
1077
|
+
strokeLinejoin: "round",
|
|
1078
|
+
strokeWidth: 2,
|
|
1079
|
+
d: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"
|
|
1080
|
+
}, undefined, false, undefined, this)
|
|
1081
|
+
}, undefined, false, undefined, this)
|
|
1082
|
+
}, undefined, false, undefined, this);
|
|
1083
|
+
}
|
|
1084
|
+
function ExamplesSection({ examples }) {
|
|
1085
|
+
const [activeIndex, setActiveIndex] = useState3(0);
|
|
1086
|
+
if (!examples?.length)
|
|
1087
|
+
return null;
|
|
1088
|
+
const showTabs = examples.length > 1;
|
|
1089
|
+
return /* @__PURE__ */ jsxDEV10("div", {
|
|
1090
|
+
className: "my-6",
|
|
1091
|
+
children: [
|
|
1092
|
+
/* @__PURE__ */ jsxDEV10("h3", {
|
|
1093
|
+
className: "text-lg font-semibold mb-3",
|
|
1094
|
+
children: "Examples"
|
|
1095
|
+
}, undefined, false, undefined, this),
|
|
1096
|
+
showTabs && /* @__PURE__ */ jsxDEV10("div", {
|
|
1097
|
+
className: "flex gap-1 mb-2 border-b border-fd-border",
|
|
1098
|
+
children: examples.map((_, index) => /* @__PURE__ */ jsxDEV10("button", {
|
|
1099
|
+
type: "button",
|
|
1100
|
+
onClick: () => setActiveIndex(index),
|
|
1101
|
+
className: `px-3 py-1.5 text-sm font-medium transition-colors ${activeIndex === index ? "text-fd-primary border-b-2 border-fd-primary -mb-px" : "text-fd-muted-foreground hover:text-fd-foreground"}`,
|
|
1102
|
+
children: [
|
|
1103
|
+
"Example ",
|
|
1104
|
+
index + 1
|
|
1105
|
+
]
|
|
1106
|
+
}, index, true, undefined, this))
|
|
1107
|
+
}, undefined, false, undefined, this),
|
|
1108
|
+
/* @__PURE__ */ jsxDEV10("div", {
|
|
1109
|
+
className: "group relative",
|
|
1110
|
+
children: [
|
|
1111
|
+
/* @__PURE__ */ jsxDEV10("pre", {
|
|
1112
|
+
className: "overflow-x-auto rounded-lg border border-fd-border bg-fd-secondary p-4",
|
|
1113
|
+
children: /* @__PURE__ */ jsxDEV10("code", {
|
|
1114
|
+
className: "font-mono text-sm text-fd-foreground whitespace-pre",
|
|
1115
|
+
children: examples[activeIndex]
|
|
1116
|
+
}, undefined, false, undefined, this)
|
|
1117
|
+
}, undefined, false, undefined, this),
|
|
1118
|
+
/* @__PURE__ */ jsxDEV10(CopyButton, {
|
|
1119
|
+
text: examples[activeIndex]
|
|
1120
|
+
}, undefined, false, undefined, this)
|
|
1121
|
+
]
|
|
1122
|
+
}, undefined, true, undefined, this)
|
|
1123
|
+
]
|
|
1124
|
+
}, undefined, true, undefined, this);
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
// src/components/interface-page.tsx
|
|
1128
|
+
import { jsxDEV as jsxDEV11 } from "react/jsx-dev-runtime";
|
|
1129
|
+
|
|
1130
|
+
function InterfacePage({ export: exp, spec }) {
|
|
1131
|
+
const properties = exp.members?.filter((m) => m.kind === "property" || m.kind === "field" || !m.kind);
|
|
1132
|
+
const methods = exp.members?.filter((m) => m.kind === "method" || m.kind === "function");
|
|
1133
|
+
return /* @__PURE__ */ jsxDEV11("div", {
|
|
1134
|
+
className: "space-y-6",
|
|
1135
|
+
children: [
|
|
1136
|
+
exp.description && /* @__PURE__ */ jsxDEV11("p", {
|
|
1137
|
+
className: "text-fd-muted-foreground text-base leading-relaxed",
|
|
1138
|
+
children: exp.description
|
|
1139
|
+
}, undefined, false, undefined, this),
|
|
1140
|
+
/* @__PURE__ */ jsxDEV11("section", {
|
|
1141
|
+
children: [
|
|
1142
|
+
/* @__PURE__ */ jsxDEV11("h2", {
|
|
1143
|
+
className: "text-xl font-semibold mb-2",
|
|
1144
|
+
children: "Declaration"
|
|
1145
|
+
}, undefined, false, undefined, this),
|
|
1146
|
+
/* @__PURE__ */ jsxDEV11(Signature, {
|
|
1147
|
+
export: exp
|
|
1148
|
+
}, undefined, false, undefined, this)
|
|
1149
|
+
]
|
|
1150
|
+
}, undefined, true, undefined, this),
|
|
1151
|
+
exp.extends && /* @__PURE__ */ jsxDEV11("section", {
|
|
1152
|
+
children: [
|
|
1153
|
+
/* @__PURE__ */ jsxDEV11("h2", {
|
|
1154
|
+
className: "text-xl font-semibold mb-2",
|
|
1155
|
+
children: "Extends"
|
|
1156
|
+
}, undefined, false, undefined, this),
|
|
1157
|
+
/* @__PURE__ */ jsxDEV11("div", {
|
|
1158
|
+
className: "rounded-lg border border-fd-border bg-fd-card p-4",
|
|
1159
|
+
children: /* @__PURE__ */ jsxDEV11("code", {
|
|
1160
|
+
className: "font-mono text-sm text-fd-primary",
|
|
1161
|
+
children: exp.extends
|
|
1162
|
+
}, undefined, false, undefined, this)
|
|
1163
|
+
}, undefined, false, undefined, this)
|
|
1164
|
+
]
|
|
1165
|
+
}, undefined, true, undefined, this),
|
|
1166
|
+
properties && properties.length > 0 && /* @__PURE__ */ jsxDEV11("section", {
|
|
1167
|
+
children: [
|
|
1168
|
+
/* @__PURE__ */ jsxDEV11("h2", {
|
|
1169
|
+
className: "text-xl font-semibold mb-2",
|
|
1170
|
+
children: "Properties"
|
|
1171
|
+
}, undefined, false, undefined, this),
|
|
1172
|
+
/* @__PURE__ */ jsxDEV11(TypeTable, {
|
|
1173
|
+
items: properties,
|
|
1174
|
+
spec,
|
|
1175
|
+
showRequired: true
|
|
1176
|
+
}, undefined, false, undefined, this)
|
|
1177
|
+
]
|
|
1178
|
+
}, undefined, true, undefined, this),
|
|
1179
|
+
methods && methods.length > 0 && /* @__PURE__ */ jsxDEV11("section", {
|
|
1180
|
+
children: [
|
|
1181
|
+
/* @__PURE__ */ jsxDEV11("h2", {
|
|
1182
|
+
className: "text-xl font-semibold mb-2",
|
|
1183
|
+
children: "Methods"
|
|
1184
|
+
}, undefined, false, undefined, this),
|
|
1185
|
+
/* @__PURE__ */ jsxDEV11("div", {
|
|
1186
|
+
className: "space-y-4",
|
|
1187
|
+
children: methods.map((method, index) => {
|
|
1188
|
+
const sig = method.signatures?.[0];
|
|
1189
|
+
const params = sig?.parameters ?? [];
|
|
1190
|
+
const returnType = sig?.returns?.tsType ?? "void";
|
|
1191
|
+
return /* @__PURE__ */ jsxDEV11("div", {
|
|
1192
|
+
className: "rounded-lg border border-fd-border p-4",
|
|
1193
|
+
children: [
|
|
1194
|
+
/* @__PURE__ */ jsxDEV11("code", {
|
|
1195
|
+
className: "font-mono text-sm text-fd-primary",
|
|
1196
|
+
children: [
|
|
1197
|
+
method.name,
|
|
1198
|
+
"(",
|
|
1199
|
+
params.map((p) => {
|
|
1200
|
+
const optional = p.required === false ? "?" : "";
|
|
1201
|
+
const type = typeof p.schema === "string" ? p.schema : p.schema?.tsType ?? "any";
|
|
1202
|
+
return `${p.name}${optional}: ${type}`;
|
|
1203
|
+
}).join(", "),
|
|
1204
|
+
"): ",
|
|
1205
|
+
returnType
|
|
1206
|
+
]
|
|
1207
|
+
}, undefined, true, undefined, this),
|
|
1208
|
+
method.description && /* @__PURE__ */ jsxDEV11("p", {
|
|
1209
|
+
className: "text-sm text-fd-muted-foreground mt-2",
|
|
1210
|
+
children: method.description
|
|
1211
|
+
}, undefined, false, undefined, this)
|
|
1212
|
+
]
|
|
1213
|
+
}, method.name ?? index, true, undefined, this);
|
|
1214
|
+
})
|
|
1215
|
+
}, undefined, false, undefined, this)
|
|
1216
|
+
]
|
|
1217
|
+
}, undefined, true, undefined, this),
|
|
1218
|
+
exp.examples && exp.examples.length > 0 && /* @__PURE__ */ jsxDEV11(ExamplesSection, {
|
|
1219
|
+
examples: exp.examples
|
|
1220
|
+
}, undefined, false, undefined, this),
|
|
1221
|
+
exp.docs && /* @__PURE__ */ jsxDEV11(CoverageBadge, {
|
|
1222
|
+
docs: exp.docs
|
|
1223
|
+
}, undefined, false, undefined, this)
|
|
1224
|
+
]
|
|
1225
|
+
}, undefined, true, undefined, this);
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
// src/components/enum-page.tsx
|
|
1229
|
+
import { jsxDEV as jsxDEV12 } from "react/jsx-dev-runtime";
|
|
1230
|
+
|
|
1231
|
+
function EnumPage({ export: exp, spec }) {
|
|
1232
|
+
const members = exp.members ?? [];
|
|
1233
|
+
return /* @__PURE__ */ jsxDEV12("div", {
|
|
1234
|
+
className: "space-y-6",
|
|
1235
|
+
children: [
|
|
1236
|
+
exp.description && /* @__PURE__ */ jsxDEV12("p", {
|
|
1237
|
+
className: "text-fd-muted-foreground text-base leading-relaxed",
|
|
1238
|
+
children: exp.description
|
|
1239
|
+
}, undefined, false, undefined, this),
|
|
1240
|
+
/* @__PURE__ */ jsxDEV12("section", {
|
|
1241
|
+
children: [
|
|
1242
|
+
/* @__PURE__ */ jsxDEV12("h2", {
|
|
1243
|
+
className: "text-xl font-semibold mb-2",
|
|
1244
|
+
children: "Declaration"
|
|
1245
|
+
}, undefined, false, undefined, this),
|
|
1246
|
+
/* @__PURE__ */ jsxDEV12(Signature, {
|
|
1247
|
+
export: exp
|
|
1248
|
+
}, undefined, false, undefined, this)
|
|
1249
|
+
]
|
|
1250
|
+
}, undefined, true, undefined, this),
|
|
1251
|
+
members.length > 0 && /* @__PURE__ */ jsxDEV12("section", {
|
|
1252
|
+
children: [
|
|
1253
|
+
/* @__PURE__ */ jsxDEV12("h2", {
|
|
1254
|
+
className: "text-xl font-semibold mb-2",
|
|
1255
|
+
children: "Members"
|
|
1256
|
+
}, undefined, false, undefined, this),
|
|
1257
|
+
/* @__PURE__ */ jsxDEV12("div", {
|
|
1258
|
+
className: "overflow-x-auto",
|
|
1259
|
+
children: /* @__PURE__ */ jsxDEV12("table", {
|
|
1260
|
+
className: "w-full text-sm border-collapse",
|
|
1261
|
+
children: [
|
|
1262
|
+
/* @__PURE__ */ jsxDEV12("thead", {
|
|
1263
|
+
children: /* @__PURE__ */ jsxDEV12("tr", {
|
|
1264
|
+
className: "border-b border-fd-border",
|
|
1265
|
+
children: [
|
|
1266
|
+
/* @__PURE__ */ jsxDEV12("th", {
|
|
1267
|
+
className: "text-left py-2 px-3 font-medium text-fd-muted-foreground",
|
|
1268
|
+
children: "Name"
|
|
1269
|
+
}, undefined, false, undefined, this),
|
|
1270
|
+
/* @__PURE__ */ jsxDEV12("th", {
|
|
1271
|
+
className: "text-left py-2 px-3 font-medium text-fd-muted-foreground",
|
|
1272
|
+
children: "Value"
|
|
1273
|
+
}, undefined, false, undefined, this),
|
|
1274
|
+
/* @__PURE__ */ jsxDEV12("th", {
|
|
1275
|
+
className: "text-left py-2 px-3 font-medium text-fd-muted-foreground",
|
|
1276
|
+
children: "Description"
|
|
1277
|
+
}, undefined, false, undefined, this)
|
|
1278
|
+
]
|
|
1279
|
+
}, undefined, true, undefined, this)
|
|
1280
|
+
}, undefined, false, undefined, this),
|
|
1281
|
+
/* @__PURE__ */ jsxDEV12("tbody", {
|
|
1282
|
+
children: members.map((member, index) => {
|
|
1283
|
+
const value = member.schema !== undefined ? typeof member.schema === "object" && member.schema !== null ? member.schema.const ?? member.schema.default ?? "-" : member.schema : "-";
|
|
1284
|
+
return /* @__PURE__ */ jsxDEV12("tr", {
|
|
1285
|
+
className: "border-b border-fd-border last:border-0",
|
|
1286
|
+
children: [
|
|
1287
|
+
/* @__PURE__ */ jsxDEV12("td", {
|
|
1288
|
+
className: "py-2 px-3 align-top",
|
|
1289
|
+
children: /* @__PURE__ */ jsxDEV12("code", {
|
|
1290
|
+
className: "text-fd-primary font-mono text-xs bg-fd-secondary px-1.5 py-0.5 rounded",
|
|
1291
|
+
children: member.name
|
|
1292
|
+
}, undefined, false, undefined, this)
|
|
1293
|
+
}, undefined, false, undefined, this),
|
|
1294
|
+
/* @__PURE__ */ jsxDEV12("td", {
|
|
1295
|
+
className: "py-2 px-3 align-top",
|
|
1296
|
+
children: /* @__PURE__ */ jsxDEV12("code", {
|
|
1297
|
+
className: "font-mono text-xs text-fd-muted-foreground",
|
|
1298
|
+
children: String(value)
|
|
1299
|
+
}, undefined, false, undefined, this)
|
|
1300
|
+
}, undefined, false, undefined, this),
|
|
1301
|
+
/* @__PURE__ */ jsxDEV12("td", {
|
|
1302
|
+
className: "py-2 px-3 align-top text-fd-muted-foreground",
|
|
1303
|
+
children: member.description ?? ""
|
|
1304
|
+
}, undefined, false, undefined, this)
|
|
1305
|
+
]
|
|
1306
|
+
}, member.name ?? index, true, undefined, this);
|
|
1307
|
+
})
|
|
1308
|
+
}, undefined, false, undefined, this)
|
|
1309
|
+
]
|
|
1310
|
+
}, undefined, true, undefined, this)
|
|
1311
|
+
}, undefined, false, undefined, this)
|
|
1312
|
+
]
|
|
1313
|
+
}, undefined, true, undefined, this),
|
|
1314
|
+
exp.examples && exp.examples.length > 0 && /* @__PURE__ */ jsxDEV12(ExamplesSection, {
|
|
1315
|
+
examples: exp.examples
|
|
1316
|
+
}, undefined, false, undefined, this),
|
|
1317
|
+
exp.docs && /* @__PURE__ */ jsxDEV12(CoverageBadge, {
|
|
1318
|
+
docs: exp.docs
|
|
1319
|
+
}, undefined, false, undefined, this)
|
|
1320
|
+
]
|
|
1321
|
+
}, undefined, true, undefined, this);
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
// src/components/variable-page.tsx
|
|
1325
|
+
import { jsxDEV as jsxDEV13 } from "react/jsx-dev-runtime";
|
|
1326
|
+
|
|
1327
|
+
function formatSchema7(schema) {
|
|
1328
|
+
if (!schema)
|
|
1329
|
+
return "unknown";
|
|
1330
|
+
if (typeof schema === "string")
|
|
1331
|
+
return schema;
|
|
1332
|
+
if (typeof schema === "object" && schema !== null) {
|
|
1333
|
+
const s = schema;
|
|
1334
|
+
if (s.$ref && typeof s.$ref === "string") {
|
|
1335
|
+
return s.$ref.replace("#/types/", "");
|
|
1336
|
+
}
|
|
1337
|
+
if (s.tsType)
|
|
1338
|
+
return String(s.tsType);
|
|
1339
|
+
if (s.type)
|
|
1340
|
+
return String(s.type);
|
|
1341
|
+
}
|
|
1342
|
+
return "unknown";
|
|
1343
|
+
}
|
|
1344
|
+
function VariablePage({ export: exp, spec }) {
|
|
1345
|
+
const typeValue = typeof exp.type === "string" ? exp.type : formatSchema7(exp.schema);
|
|
1346
|
+
const hasExamples = exp.examples && exp.examples.length > 0;
|
|
1347
|
+
return /* @__PURE__ */ jsxDEV13("div", {
|
|
1348
|
+
className: "space-y-8",
|
|
1349
|
+
children: [
|
|
1350
|
+
exp.description && /* @__PURE__ */ jsxDEV13("p", {
|
|
1351
|
+
className: "text-fd-muted-foreground text-lg leading-relaxed",
|
|
1352
|
+
children: exp.description
|
|
1353
|
+
}, undefined, false, undefined, this),
|
|
1354
|
+
/* @__PURE__ */ jsxDEV13("div", {
|
|
1355
|
+
className: "rounded-lg border border-fd-border bg-fd-muted/30 p-4 overflow-x-auto",
|
|
1356
|
+
children: /* @__PURE__ */ jsxDEV13("code", {
|
|
1357
|
+
className: "font-mono text-sm text-fd-foreground whitespace-pre",
|
|
1358
|
+
children: [
|
|
1359
|
+
"const ",
|
|
1360
|
+
exp.name,
|
|
1361
|
+
": ",
|
|
1362
|
+
typeValue
|
|
1363
|
+
]
|
|
1364
|
+
}, undefined, true, undefined, this)
|
|
1365
|
+
}, undefined, false, undefined, this),
|
|
1366
|
+
/* @__PURE__ */ jsxDEV13("div", {
|
|
1367
|
+
className: `grid gap-8 ${hasExamples ? "lg:grid-cols-2" : "grid-cols-1"}`,
|
|
1368
|
+
children: [
|
|
1369
|
+
/* @__PURE__ */ jsxDEV13("div", {
|
|
1370
|
+
className: "space-y-6",
|
|
1371
|
+
children: /* @__PURE__ */ jsxDEV13("div", {
|
|
1372
|
+
children: [
|
|
1373
|
+
/* @__PURE__ */ jsxDEV13("h3", {
|
|
1374
|
+
className: "text-sm font-semibold uppercase tracking-wide text-fd-muted-foreground mb-3",
|
|
1375
|
+
children: "Type"
|
|
1376
|
+
}, undefined, false, undefined, this),
|
|
1377
|
+
/* @__PURE__ */ jsxDEV13("div", {
|
|
1378
|
+
className: "rounded-lg border border-fd-border bg-fd-card p-4",
|
|
1379
|
+
children: /* @__PURE__ */ jsxDEV13("code", {
|
|
1380
|
+
className: "font-mono text-sm text-fd-primary",
|
|
1381
|
+
children: typeValue
|
|
1382
|
+
}, undefined, false, undefined, this)
|
|
1383
|
+
}, undefined, false, undefined, this)
|
|
1384
|
+
]
|
|
1385
|
+
}, undefined, true, undefined, this)
|
|
1386
|
+
}, undefined, false, undefined, this),
|
|
1387
|
+
hasExamples && /* @__PURE__ */ jsxDEV13("div", {
|
|
1388
|
+
children: [
|
|
1389
|
+
/* @__PURE__ */ jsxDEV13("h3", {
|
|
1390
|
+
className: "text-sm font-semibold uppercase tracking-wide text-fd-muted-foreground mb-3",
|
|
1391
|
+
children: [
|
|
1392
|
+
exp.name,
|
|
1393
|
+
" usage"
|
|
1394
|
+
]
|
|
1395
|
+
}, undefined, true, undefined, this),
|
|
1396
|
+
/* @__PURE__ */ jsxDEV13(CodeExample, {
|
|
1397
|
+
code: exp.examples[0],
|
|
1398
|
+
filename: `${exp.name.toLowerCase()}.ts`
|
|
1399
|
+
}, undefined, false, undefined, this)
|
|
1400
|
+
]
|
|
1401
|
+
}, undefined, true, undefined, this)
|
|
1402
|
+
]
|
|
1403
|
+
}, undefined, true, undefined, this),
|
|
1404
|
+
exp.docs && /* @__PURE__ */ jsxDEV13(CoverageBadge, {
|
|
1405
|
+
docs: exp.docs
|
|
1406
|
+
}, undefined, false, undefined, this)
|
|
1407
|
+
]
|
|
1408
|
+
}, undefined, true, undefined, this);
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
// src/components/api-page.tsx
|
|
1412
|
+
import { jsxDEV as jsxDEV14 } from "react/jsx-dev-runtime";
|
|
1413
|
+
|
|
1414
|
+
function NotFound({ id }) {
|
|
1415
|
+
return /* @__PURE__ */ jsxDEV14("div", {
|
|
1416
|
+
className: "rounded-lg border border-fd-border bg-fd-card p-6 text-center",
|
|
1417
|
+
children: /* @__PURE__ */ jsxDEV14("p", {
|
|
1418
|
+
className: "text-fd-muted-foreground",
|
|
1419
|
+
children: [
|
|
1420
|
+
"Export ",
|
|
1421
|
+
/* @__PURE__ */ jsxDEV14("code", {
|
|
1422
|
+
className: "font-mono text-fd-primary",
|
|
1423
|
+
children: id
|
|
1424
|
+
}, undefined, false, undefined, this),
|
|
1425
|
+
" not found in spec."
|
|
1426
|
+
]
|
|
1427
|
+
}, undefined, true, undefined, this)
|
|
1428
|
+
}, undefined, false, undefined, this);
|
|
1429
|
+
}
|
|
1430
|
+
function APIPage({ spec, instance, id }) {
|
|
1431
|
+
const resolvedSpec = spec ?? instance?.spec;
|
|
1432
|
+
if (!resolvedSpec) {
|
|
1433
|
+
return /* @__PURE__ */ jsxDEV14("div", {
|
|
1434
|
+
className: "rounded-lg border border-red-500/20 bg-red-500/10 p-6 text-center",
|
|
1435
|
+
children: /* @__PURE__ */ jsxDEV14("p", {
|
|
1436
|
+
className: "text-red-600 dark:text-red-400",
|
|
1437
|
+
children: [
|
|
1438
|
+
"No spec provided. Pass either ",
|
|
1439
|
+
/* @__PURE__ */ jsxDEV14("code", {
|
|
1440
|
+
children: "spec"
|
|
1441
|
+
}, undefined, false, undefined, this),
|
|
1442
|
+
" or ",
|
|
1443
|
+
/* @__PURE__ */ jsxDEV14("code", {
|
|
1444
|
+
children: "instance"
|
|
1445
|
+
}, undefined, false, undefined, this),
|
|
1446
|
+
" prop."
|
|
1447
|
+
]
|
|
1448
|
+
}, undefined, true, undefined, this)
|
|
1449
|
+
}, undefined, false, undefined, this);
|
|
1450
|
+
}
|
|
1451
|
+
const exp = resolvedSpec.exports.find((e) => e.id === id);
|
|
1452
|
+
if (!exp) {
|
|
1453
|
+
return /* @__PURE__ */ jsxDEV14(NotFound, {
|
|
1454
|
+
id
|
|
1455
|
+
}, undefined, false, undefined, this);
|
|
1456
|
+
}
|
|
1457
|
+
const pageProps = { export: exp, spec: resolvedSpec };
|
|
1458
|
+
switch (exp.kind) {
|
|
1459
|
+
case "function":
|
|
1460
|
+
return /* @__PURE__ */ jsxDEV14(FunctionPage, {
|
|
1461
|
+
...pageProps
|
|
1462
|
+
}, undefined, false, undefined, this);
|
|
1463
|
+
case "class":
|
|
1464
|
+
return /* @__PURE__ */ jsxDEV14(ClassPage, {
|
|
1465
|
+
...pageProps
|
|
1466
|
+
}, undefined, false, undefined, this);
|
|
1467
|
+
case "interface":
|
|
1468
|
+
case "type":
|
|
1469
|
+
return /* @__PURE__ */ jsxDEV14(InterfacePage, {
|
|
1470
|
+
...pageProps
|
|
1471
|
+
}, undefined, false, undefined, this);
|
|
1472
|
+
case "enum":
|
|
1473
|
+
return /* @__PURE__ */ jsxDEV14(EnumPage, {
|
|
1474
|
+
...pageProps
|
|
1475
|
+
}, undefined, false, undefined, this);
|
|
1476
|
+
case "variable":
|
|
1477
|
+
case "namespace":
|
|
1478
|
+
case "module":
|
|
1479
|
+
case "reference":
|
|
1480
|
+
case "external":
|
|
1481
|
+
default:
|
|
1482
|
+
return /* @__PURE__ */ jsxDEV14(VariablePage, {
|
|
1483
|
+
...pageProps
|
|
1484
|
+
}, undefined, false, undefined, this);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
export { ParameterCard, CodeExample, CoverageBadge, FunctionPage, NestedProperty, ExpandableProperty, CollapsibleMethod, ClassPage, Signature, TypeTable, ExamplesSection, InterfacePage, EnumPage, VariablePage, APIPage };
|