@doccov/fumadocs-adapter 0.0.2 → 0.0.3
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/CHANGELOG.md +6 -0
- package/dist/components/index.d.ts +17 -17
- package/dist/components/index.js +11 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/shared/{chunk-mmca4gp7.js → chunk-edfpjshy.js} +52 -50
- package/package.json +1 -1
- package/src/components/api-page.tsx +1 -1
- package/src/components/class-page.tsx +1 -2
- package/src/components/code-example.tsx +1 -1
- package/src/components/collapsible-method.tsx +8 -13
- package/src/components/coverage-badge.tsx +14 -4
- package/src/components/enum-page.tsx +4 -2
- package/src/components/examples.tsx +17 -5
- package/src/components/expandable-property.tsx +10 -11
- package/src/components/function-page.tsx +2 -3
- package/src/components/interface-page.tsx +16 -6
- package/src/components/members-section.tsx +6 -3
- package/src/components/method-section.tsx +4 -1
- package/src/components/parameter-card.tsx +1 -2
- package/src/components/signature.tsx +1 -3
- package/src/components/type-table.tsx +1 -3
- package/src/components/variable-page.tsx +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -42,19 +42,19 @@ interface APIPageProps {
|
|
|
42
42
|
* <APIPage instance={openpkg} id="createClient" />
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
|
-
declare function APIPage({ spec, instance, id }: APIPageProps);
|
|
45
|
+
declare function APIPage({ spec, instance, id }: APIPageProps): React.ReactNode;
|
|
46
46
|
import { OpenPkg as OpenPkg3, SpecExport as SpecExport2 } from "@openpkg-ts/spec";
|
|
47
47
|
interface ClassPageProps {
|
|
48
48
|
export: SpecExport2;
|
|
49
49
|
spec: OpenPkg3;
|
|
50
50
|
}
|
|
51
|
-
declare function ClassPage({ export: exp, spec }: ClassPageProps);
|
|
51
|
+
declare function ClassPage({ export: exp, spec: _spec }: ClassPageProps): React.ReactNode;
|
|
52
52
|
interface CodeExampleProps {
|
|
53
53
|
code: string;
|
|
54
54
|
filename?: string;
|
|
55
55
|
language?: string;
|
|
56
56
|
}
|
|
57
|
-
declare function CodeExample({ code, filename, language }: CodeExampleProps);
|
|
57
|
+
declare function CodeExample({ code, filename, language }: CodeExampleProps): React.ReactNode;
|
|
58
58
|
import { SpecMember } from "@openpkg-ts/spec";
|
|
59
59
|
interface CollapsibleMethodProps {
|
|
60
60
|
member: SpecMember;
|
|
@@ -64,24 +64,24 @@ interface CollapsibleMethodProps {
|
|
|
64
64
|
* Collapsible method section with expand/collapse behavior
|
|
65
65
|
* Shows compact signature when collapsed, full details when expanded
|
|
66
66
|
*/
|
|
67
|
-
declare function CollapsibleMethod({ member, defaultExpanded }: CollapsibleMethodProps);
|
|
67
|
+
declare function CollapsibleMethod({ member, defaultExpanded }: CollapsibleMethodProps): React.ReactNode;
|
|
68
68
|
import { SpecDocsMetadata } from "@openpkg-ts/spec";
|
|
69
69
|
interface CoverageBadgeProps {
|
|
70
70
|
docs: SpecDocsMetadata;
|
|
71
71
|
showMissing?: boolean;
|
|
72
72
|
showDrift?: boolean;
|
|
73
73
|
}
|
|
74
|
-
declare function CoverageBadge({ docs, showMissing, showDrift }: CoverageBadgeProps);
|
|
74
|
+
declare function CoverageBadge({ docs, showMissing, showDrift }: CoverageBadgeProps): React.ReactNode;
|
|
75
75
|
import { OpenPkg as OpenPkg4, SpecExport as SpecExport3 } from "@openpkg-ts/spec";
|
|
76
76
|
interface EnumPageProps {
|
|
77
77
|
export: SpecExport3;
|
|
78
78
|
spec: OpenPkg4;
|
|
79
79
|
}
|
|
80
|
-
declare function EnumPage({ export: exp, spec }: EnumPageProps);
|
|
80
|
+
declare function EnumPage({ export: exp, spec: _spec }: EnumPageProps): React.ReactNode;
|
|
81
81
|
interface ExamplesSectionProps {
|
|
82
82
|
examples: string[];
|
|
83
83
|
}
|
|
84
|
-
declare function ExamplesSection({ examples }: ExamplesSectionProps);
|
|
84
|
+
declare function ExamplesSection({ examples }: ExamplesSectionProps): React.ReactNode;
|
|
85
85
|
import { SpecSchema, SpecSignatureParameter } from "@openpkg-ts/spec";
|
|
86
86
|
interface ExpandablePropertyProps {
|
|
87
87
|
param: SpecSignatureParameter;
|
|
@@ -96,31 +96,31 @@ interface NestedPropertyProps {
|
|
|
96
96
|
/**
|
|
97
97
|
* Nested property row with expandable nested objects
|
|
98
98
|
*/
|
|
99
|
-
declare function NestedProperty({ name, schema, required, depth }: NestedPropertyProps);
|
|
99
|
+
declare function NestedProperty({ name, schema, required, depth }: NestedPropertyProps): React.ReactNode;
|
|
100
100
|
/**
|
|
101
101
|
* Top-level expandable property for method parameters
|
|
102
102
|
* Entry point for rendering a parameter with progressive disclosure
|
|
103
103
|
*/
|
|
104
|
-
declare function ExpandableProperty({ param, depth }: ExpandablePropertyProps);
|
|
104
|
+
declare function ExpandableProperty({ param, depth }: ExpandablePropertyProps): React.ReactNode;
|
|
105
105
|
import { OpenPkg as OpenPkg5, SpecExport as SpecExport4 } from "@openpkg-ts/spec";
|
|
106
106
|
interface FunctionPageProps {
|
|
107
107
|
export: SpecExport4;
|
|
108
108
|
spec: OpenPkg5;
|
|
109
109
|
}
|
|
110
|
-
declare function FunctionPage({ export: exp, spec }: FunctionPageProps);
|
|
110
|
+
declare function FunctionPage({ export: exp, spec }: FunctionPageProps): React.ReactNode;
|
|
111
111
|
import { OpenPkg as OpenPkg6, SpecExport as SpecExport5 } from "@openpkg-ts/spec";
|
|
112
112
|
interface InterfacePageProps {
|
|
113
113
|
export: SpecExport5;
|
|
114
114
|
spec: OpenPkg6;
|
|
115
115
|
}
|
|
116
|
-
declare function InterfacePage({ export: exp, spec }: InterfacePageProps);
|
|
116
|
+
declare function InterfacePage({ export: exp, spec }: InterfacePageProps): React.ReactNode;
|
|
117
117
|
import { OpenPkg as OpenPkg7, SpecMember as SpecMember2 } from "@openpkg-ts/spec";
|
|
118
118
|
interface MembersSectionProps {
|
|
119
119
|
members: SpecMember2[];
|
|
120
120
|
spec?: OpenPkg7;
|
|
121
121
|
title?: string;
|
|
122
122
|
}
|
|
123
|
-
declare function MembersSection({ members, spec, title }: MembersSectionProps);
|
|
123
|
+
declare function MembersSection({ members, spec: _spec, title }: MembersSectionProps): React.ReactNode;
|
|
124
124
|
import { SpecMember as SpecMember3 } from "@openpkg-ts/spec";
|
|
125
125
|
interface MethodSectionProps {
|
|
126
126
|
member: SpecMember3;
|
|
@@ -131,30 +131,30 @@ interface MethodSectionProps {
|
|
|
131
131
|
* Method display section with collapsible behavior
|
|
132
132
|
* @deprecated Use CollapsibleMethod directly for more control
|
|
133
133
|
*/
|
|
134
|
-
declare function MethodSection({ member, defaultExpanded }: MethodSectionProps);
|
|
134
|
+
declare function MethodSection({ member, defaultExpanded }: MethodSectionProps): React.ReactNode;
|
|
135
135
|
import { OpenPkg as OpenPkg8, SpecSignatureParameter as SpecSignatureParameter2 } from "@openpkg-ts/spec";
|
|
136
136
|
interface ParameterCardProps {
|
|
137
137
|
param: SpecSignatureParameter2;
|
|
138
138
|
spec?: OpenPkg8;
|
|
139
139
|
}
|
|
140
|
-
declare function ParameterCard({ param, spec }: ParameterCardProps);
|
|
140
|
+
declare function ParameterCard({ param, spec: _spec }: ParameterCardProps): React.ReactNode;
|
|
141
141
|
import { SpecExport as SpecExport6 } from "@openpkg-ts/spec";
|
|
142
142
|
interface SignatureProps {
|
|
143
143
|
export: SpecExport6;
|
|
144
144
|
signatureIndex?: number;
|
|
145
145
|
}
|
|
146
|
-
declare function Signature({ export: exp, signatureIndex }: SignatureProps);
|
|
146
|
+
declare function Signature({ export: exp, signatureIndex }: SignatureProps): React.ReactNode;
|
|
147
147
|
import { OpenPkg as OpenPkg9, SpecMember as SpecMember4, SpecSignatureParameter as SpecSignatureParameter3 } from "@openpkg-ts/spec";
|
|
148
148
|
interface TypeTableProps {
|
|
149
149
|
items: (SpecSignatureParameter3 | SpecMember4)[];
|
|
150
150
|
spec?: OpenPkg9;
|
|
151
151
|
showRequired?: boolean;
|
|
152
152
|
}
|
|
153
|
-
declare function TypeTable({ items, showRequired }: TypeTableProps);
|
|
153
|
+
declare function TypeTable({ items, showRequired }: TypeTableProps): React.ReactNode;
|
|
154
154
|
import { OpenPkg as OpenPkg10, SpecExport as SpecExport7 } from "@openpkg-ts/spec";
|
|
155
155
|
interface VariablePageProps {
|
|
156
156
|
export: SpecExport7;
|
|
157
157
|
spec: OpenPkg10;
|
|
158
158
|
}
|
|
159
|
-
declare function VariablePage({ export: exp, spec }: VariablePageProps);
|
|
159
|
+
declare function VariablePage({ export: exp, spec: _spec }: VariablePageProps): React.ReactNode;
|
|
160
160
|
export { VariablePageProps, VariablePage, TypeTableProps, TypeTable, SignatureProps, Signature, ParameterCardProps, ParameterCard, NestedPropertyProps, NestedProperty, MethodSectionProps, MethodSection, MembersSectionProps, MembersSection, InterfacePageProps, InterfacePage, FunctionPageProps, FunctionPage, ExpandablePropertyProps, ExpandableProperty, ExamplesSectionProps, ExamplesSection, EnumPageProps, EnumPage, CoverageBadgeProps, CoverageBadge, CollapsibleMethodProps, CollapsibleMethod, CodeExampleProps, CodeExample, ClassPageProps, ClassPage, APIPageProps, APIPage };
|
package/dist/components/index.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
Signature,
|
|
16
16
|
TypeTable,
|
|
17
17
|
VariablePage
|
|
18
|
-
} from "../shared/chunk-
|
|
18
|
+
} from "../shared/chunk-edfpjshy.js";
|
|
19
19
|
// src/components/members-section.tsx
|
|
20
20
|
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
21
21
|
|
|
@@ -29,8 +29,6 @@ function formatSchema(schema) {
|
|
|
29
29
|
if (s.$ref && typeof s.$ref === "string") {
|
|
30
30
|
return s.$ref.replace("#/types/", "");
|
|
31
31
|
}
|
|
32
|
-
if (s.tsType)
|
|
33
|
-
return String(s.tsType);
|
|
34
32
|
if (s.type)
|
|
35
33
|
return String(s.type);
|
|
36
34
|
}
|
|
@@ -82,7 +80,7 @@ function MemberRow({ member }) {
|
|
|
82
80
|
const optional = p.required === false ? "?" : "";
|
|
83
81
|
return `${p.name}${optional}: ${formatSchema(p.schema)}`;
|
|
84
82
|
}) ?? [];
|
|
85
|
-
const returnType =
|
|
83
|
+
const returnType = formatSchema(sig.returns?.schema) ?? "void";
|
|
86
84
|
signature = `(${params.join(", ")}): ${returnType}`;
|
|
87
85
|
}
|
|
88
86
|
return /* @__PURE__ */ jsxDEV("div", {
|
|
@@ -118,7 +116,11 @@ function MemberRow({ member }) {
|
|
|
118
116
|
]
|
|
119
117
|
}, undefined, true, undefined, this);
|
|
120
118
|
}
|
|
121
|
-
function MembersSection({
|
|
119
|
+
function MembersSection({
|
|
120
|
+
members,
|
|
121
|
+
spec: _spec,
|
|
122
|
+
title = "Members"
|
|
123
|
+
}) {
|
|
122
124
|
if (!members?.length)
|
|
123
125
|
return null;
|
|
124
126
|
const groups = groupMembersByKind(members);
|
|
@@ -210,7 +212,10 @@ function MembersSection({ members, spec, title = "Members" }) {
|
|
|
210
212
|
// src/components/method-section.tsx
|
|
211
213
|
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
212
214
|
|
|
213
|
-
function MethodSection({
|
|
215
|
+
function MethodSection({
|
|
216
|
+
member,
|
|
217
|
+
defaultExpanded = false
|
|
218
|
+
}) {
|
|
214
219
|
return /* @__PURE__ */ jsxDEV2(CollapsibleMethod, {
|
|
215
220
|
member,
|
|
216
221
|
defaultExpanded
|
package/dist/index.d.ts
CHANGED
|
@@ -60,5 +60,5 @@ interface APIPageProps {
|
|
|
60
60
|
* <APIPage instance={openpkg} id="createClient" />
|
|
61
61
|
* ```
|
|
62
62
|
*/
|
|
63
|
-
declare function APIPage({ spec, instance, id }: APIPageProps);
|
|
63
|
+
declare function APIPage({ spec, instance, id }: APIPageProps): React.ReactNode;
|
|
64
64
|
export { createOpenPkg, OpenPkgOptions, OpenPkgInstance, APIPageProps, APIPage };
|
package/dist/index.js
CHANGED
|
@@ -45,6 +45,7 @@ function ChevronIcon({ expanded }) {
|
|
|
45
45
|
viewBox: "0 0 12 12",
|
|
46
46
|
fill: "none",
|
|
47
47
|
className: `transition-transform duration-200 ${expanded ? "rotate-90" : ""}`,
|
|
48
|
+
"aria-hidden": "true",
|
|
48
49
|
children: /* @__PURE__ */ jsxDEV2("path", {
|
|
49
50
|
d: "M4.5 2.5L8 6L4.5 9.5",
|
|
50
51
|
stroke: "currentColor",
|
|
@@ -61,13 +62,6 @@ function formatType(schema) {
|
|
|
61
62
|
return schema;
|
|
62
63
|
if (typeof schema === "object" && schema !== null) {
|
|
63
64
|
const s = schema;
|
|
64
|
-
if (s.tsType && typeof s.tsType === "string") {
|
|
65
|
-
const tsType = s.tsType;
|
|
66
|
-
if (tsType.length > 80) {
|
|
67
|
-
return `${tsType.slice(0, 77)}...`;
|
|
68
|
-
}
|
|
69
|
-
return tsType;
|
|
70
|
-
}
|
|
71
65
|
if (s.$ref && typeof s.$ref === "string") {
|
|
72
66
|
return s.$ref.replace("#/types/", "");
|
|
73
67
|
}
|
|
@@ -113,7 +107,12 @@ function countProperties(schema) {
|
|
|
113
107
|
const props = getNestedProperties(schema);
|
|
114
108
|
return props ? Object.keys(props).length : 0;
|
|
115
109
|
}
|
|
116
|
-
function NestedProperty({
|
|
110
|
+
function NestedProperty({
|
|
111
|
+
name,
|
|
112
|
+
schema,
|
|
113
|
+
required = false,
|
|
114
|
+
depth = 0
|
|
115
|
+
}) {
|
|
117
116
|
const [expanded, setExpanded] = useState(false);
|
|
118
117
|
const type = formatType(schema);
|
|
119
118
|
const nestedProps = getNestedProperties(schema);
|
|
@@ -154,6 +153,7 @@ function NestedProperty({ name, schema, required = false, depth = 0 }) {
|
|
|
154
153
|
]
|
|
155
154
|
}, undefined, true, undefined, this),
|
|
156
155
|
hasNested && /* @__PURE__ */ jsxDEV2("button", {
|
|
156
|
+
type: "button",
|
|
157
157
|
onClick: () => setExpanded(!expanded),
|
|
158
158
|
className: `flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-md
|
|
159
159
|
bg-fd-muted text-fd-muted-foreground hover:bg-fd-accent hover:text-fd-accent-foreground
|
|
@@ -224,6 +224,7 @@ function ExpandableProperty({ param, depth = 0 }) {
|
|
|
224
224
|
]
|
|
225
225
|
}, undefined, true, undefined, this),
|
|
226
226
|
hasNested && /* @__PURE__ */ jsxDEV2("button", {
|
|
227
|
+
type: "button",
|
|
227
228
|
onClick: () => setExpanded(!expanded),
|
|
228
229
|
className: `flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-md
|
|
229
230
|
bg-fd-muted text-fd-muted-foreground hover:bg-fd-accent hover:text-fd-accent-foreground
|
|
@@ -266,6 +267,7 @@ function ChevronIcon2({ expanded }) {
|
|
|
266
267
|
viewBox: "0 0 16 16",
|
|
267
268
|
fill: "none",
|
|
268
269
|
className: `transition-transform duration-200 ${expanded ? "rotate-90" : ""}`,
|
|
270
|
+
"aria-hidden": "true",
|
|
269
271
|
children: /* @__PURE__ */ jsxDEV3("path", {
|
|
270
272
|
d: "M6 4L10 8L6 12",
|
|
271
273
|
stroke: "currentColor",
|
|
@@ -285,12 +287,6 @@ function formatSchema(schema) {
|
|
|
285
287
|
if (s.$ref && typeof s.$ref === "string") {
|
|
286
288
|
return s.$ref.replace("#/types/", "");
|
|
287
289
|
}
|
|
288
|
-
if (s.tsType) {
|
|
289
|
-
const tsType = String(s.tsType);
|
|
290
|
-
if (tsType.length > 40)
|
|
291
|
-
return `${tsType.slice(0, 37)}...`;
|
|
292
|
-
return tsType;
|
|
293
|
-
}
|
|
294
290
|
if (s.type)
|
|
295
291
|
return String(s.type);
|
|
296
292
|
}
|
|
@@ -299,12 +295,6 @@ function formatSchema(schema) {
|
|
|
299
295
|
function formatReturnType(returns) {
|
|
300
296
|
if (!returns)
|
|
301
297
|
return "void";
|
|
302
|
-
if (returns.tsType) {
|
|
303
|
-
const t = returns.tsType;
|
|
304
|
-
if (t.length > 40)
|
|
305
|
-
return `${t.slice(0, 37)}...`;
|
|
306
|
-
return t;
|
|
307
|
-
}
|
|
308
298
|
return formatSchema(returns.schema);
|
|
309
299
|
}
|
|
310
300
|
function formatParamPreview(params) {
|
|
@@ -314,7 +304,10 @@ function formatParamPreview(params) {
|
|
|
314
304
|
return params[0].name || "arg";
|
|
315
305
|
return `${params[0].name || "arg"}, ...`;
|
|
316
306
|
}
|
|
317
|
-
function CollapsibleMethod({
|
|
307
|
+
function CollapsibleMethod({
|
|
308
|
+
member,
|
|
309
|
+
defaultExpanded = false
|
|
310
|
+
}) {
|
|
318
311
|
const [expanded, setExpanded] = useState2(defaultExpanded);
|
|
319
312
|
const sig = member.signatures?.[0];
|
|
320
313
|
const hasParams = sig?.parameters && sig.parameters.length > 0;
|
|
@@ -335,6 +328,7 @@ function CollapsibleMethod({ member, defaultExpanded = false }) {
|
|
|
335
328
|
className: "scroll-mt-20 border-b border-fd-border last:border-0",
|
|
336
329
|
children: [
|
|
337
330
|
/* @__PURE__ */ jsxDEV3("button", {
|
|
331
|
+
type: "button",
|
|
338
332
|
onClick: () => setExpanded(!expanded),
|
|
339
333
|
className: "w-full flex items-center gap-3 py-4 px-1 text-left hover:bg-fd-muted/30 transition-colors cursor-pointer group",
|
|
340
334
|
children: [
|
|
@@ -423,7 +417,7 @@ function CollapsibleMethod({ member, defaultExpanded = false }) {
|
|
|
423
417
|
children: [
|
|
424
418
|
/* @__PURE__ */ jsxDEV3("span", {
|
|
425
419
|
className: "font-mono text-sm text-fd-muted-foreground",
|
|
426
|
-
children:
|
|
420
|
+
children: formatSchema(sig.returns.schema)
|
|
427
421
|
}, undefined, false, undefined, this),
|
|
428
422
|
returnDescription && /* @__PURE__ */ jsxDEV3("p", {
|
|
429
423
|
className: "text-sm text-fd-muted-foreground mt-1 leading-relaxed",
|
|
@@ -452,7 +446,11 @@ function getScoreColor(score) {
|
|
|
452
446
|
function formatSignal(signal) {
|
|
453
447
|
return signal.charAt(0).toUpperCase() + signal.slice(1);
|
|
454
448
|
}
|
|
455
|
-
function CoverageBadge({
|
|
449
|
+
function CoverageBadge({
|
|
450
|
+
docs,
|
|
451
|
+
showMissing = true,
|
|
452
|
+
showDrift = true
|
|
453
|
+
}) {
|
|
456
454
|
const score = docs.coverageScore;
|
|
457
455
|
const hasMissing = showMissing && docs.missing && docs.missing.length > 0;
|
|
458
456
|
const hasDrift = showDrift && docs.drift && docs.drift.length > 0;
|
|
@@ -469,6 +467,7 @@ function CoverageBadge({ docs, showMissing = true, showDrift = true }) {
|
|
|
469
467
|
fill: "none",
|
|
470
468
|
stroke: "currentColor",
|
|
471
469
|
viewBox: "0 0 24 24",
|
|
470
|
+
"aria-hidden": "true",
|
|
472
471
|
children: /* @__PURE__ */ jsxDEV4("path", {
|
|
473
472
|
strokeLinecap: "round",
|
|
474
473
|
strokeLinejoin: "round",
|
|
@@ -505,7 +504,7 @@ function CoverageBadge({ docs, showMissing = true, showDrift = true }) {
|
|
|
505
504
|
}, undefined, false, undefined, this),
|
|
506
505
|
/* @__PURE__ */ jsxDEV4("ul", {
|
|
507
506
|
className: "text-sm text-red-600/80 dark:text-red-400/80 space-y-1",
|
|
508
|
-
children: docs.drift.map((drift
|
|
507
|
+
children: docs.drift.map((drift) => /* @__PURE__ */ jsxDEV4("li", {
|
|
509
508
|
className: "flex flex-col",
|
|
510
509
|
children: [
|
|
511
510
|
/* @__PURE__ */ jsxDEV4("span", {
|
|
@@ -524,7 +523,7 @@ function CoverageBadge({ docs, showMissing = true, showDrift = true }) {
|
|
|
524
523
|
]
|
|
525
524
|
}, undefined, true, undefined, this)
|
|
526
525
|
]
|
|
527
|
-
},
|
|
526
|
+
}, `${drift.type}-${drift.issue}`, true, undefined, this))
|
|
528
527
|
}, undefined, false, undefined, this)
|
|
529
528
|
]
|
|
530
529
|
}, undefined, true, undefined, this)
|
|
@@ -545,8 +544,6 @@ function formatSchema2(schema) {
|
|
|
545
544
|
if (s.$ref && typeof s.$ref === "string") {
|
|
546
545
|
return s.$ref.replace("#/types/", "");
|
|
547
546
|
}
|
|
548
|
-
if (s.tsType)
|
|
549
|
-
return String(s.tsType);
|
|
550
547
|
if (s.type)
|
|
551
548
|
return String(s.type);
|
|
552
549
|
}
|
|
@@ -596,7 +593,7 @@ function PropertyItem({ member }) {
|
|
|
596
593
|
]
|
|
597
594
|
}, undefined, true, undefined, this);
|
|
598
595
|
}
|
|
599
|
-
function ClassPage({ export: exp, spec }) {
|
|
596
|
+
function ClassPage({ export: exp, spec: _spec }) {
|
|
600
597
|
const hasExamples = exp.examples && exp.examples.length > 0;
|
|
601
598
|
const constructors = exp.members?.filter((m) => m.kind === "constructor") ?? [];
|
|
602
599
|
const properties = exp.members?.filter((m) => m.kind === "property" || m.kind === "field") ?? [];
|
|
@@ -716,6 +713,7 @@ function CopyButton({ text }) {
|
|
|
716
713
|
fill: "none",
|
|
717
714
|
stroke: "currentColor",
|
|
718
715
|
viewBox: "0 0 24 24",
|
|
716
|
+
"aria-hidden": "true",
|
|
719
717
|
children: /* @__PURE__ */ jsxDEV6("path", {
|
|
720
718
|
strokeLinecap: "round",
|
|
721
719
|
strokeLinejoin: "round",
|
|
@@ -727,6 +725,7 @@ function CopyButton({ text }) {
|
|
|
727
725
|
fill: "none",
|
|
728
726
|
stroke: "currentColor",
|
|
729
727
|
viewBox: "0 0 24 24",
|
|
728
|
+
"aria-hidden": "true",
|
|
730
729
|
children: /* @__PURE__ */ jsxDEV6("path", {
|
|
731
730
|
strokeLinecap: "round",
|
|
732
731
|
strokeLinejoin: "round",
|
|
@@ -750,7 +749,7 @@ function ExamplesSection({ examples }) {
|
|
|
750
749
|
}, undefined, false, undefined, this),
|
|
751
750
|
showTabs && /* @__PURE__ */ jsxDEV6("div", {
|
|
752
751
|
className: "flex gap-1 mb-2 border-b border-fd-border",
|
|
753
|
-
children: examples.map((
|
|
752
|
+
children: examples.map((example, index) => /* @__PURE__ */ jsxDEV6("button", {
|
|
754
753
|
type: "button",
|
|
755
754
|
onClick: () => setActiveIndex(index),
|
|
756
755
|
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"}`,
|
|
@@ -758,7 +757,7 @@ function ExamplesSection({ examples }) {
|
|
|
758
757
|
"Example ",
|
|
759
758
|
index + 1
|
|
760
759
|
]
|
|
761
|
-
},
|
|
760
|
+
}, `example-${typeof example === "string" ? example.slice(0, 20) : index}`, true, undefined, this))
|
|
762
761
|
}, undefined, false, undefined, this),
|
|
763
762
|
/* @__PURE__ */ jsxDEV6("div", {
|
|
764
763
|
className: "group relative",
|
|
@@ -816,8 +815,6 @@ function formatSchema3(schema) {
|
|
|
816
815
|
if (s.$ref && typeof s.$ref === "string") {
|
|
817
816
|
return s.$ref.replace("#/types/", "");
|
|
818
817
|
}
|
|
819
|
-
if (s.tsType)
|
|
820
|
-
return String(s.tsType);
|
|
821
818
|
if (s.type)
|
|
822
819
|
return String(s.type);
|
|
823
820
|
}
|
|
@@ -826,8 +823,6 @@ function formatSchema3(schema) {
|
|
|
826
823
|
function formatReturnType2(sig) {
|
|
827
824
|
if (!sig?.returns)
|
|
828
825
|
return "void";
|
|
829
|
-
if (sig.returns.tsType)
|
|
830
|
-
return sig.returns.tsType;
|
|
831
826
|
return formatSchema3(sig.returns.schema);
|
|
832
827
|
}
|
|
833
828
|
function buildSignatureString(exp, sigIndex = 0) {
|
|
@@ -892,7 +887,7 @@ function Signature({ export: exp, signatureIndex = 0 }) {
|
|
|
892
887
|
// src/components/enum-page.tsx
|
|
893
888
|
import { jsxDEV as jsxDEV8 } from "react/jsx-dev-runtime";
|
|
894
889
|
|
|
895
|
-
function EnumPage({ export: exp, spec }) {
|
|
890
|
+
function EnumPage({ export: exp, spec: _spec }) {
|
|
896
891
|
const members = exp.members ?? [];
|
|
897
892
|
return /* @__PURE__ */ jsxDEV8("div", {
|
|
898
893
|
className: "space-y-6",
|
|
@@ -998,14 +993,12 @@ function formatSchema4(schema) {
|
|
|
998
993
|
if (s.$ref && typeof s.$ref === "string") {
|
|
999
994
|
return s.$ref.replace("#/types/", "");
|
|
1000
995
|
}
|
|
1001
|
-
if (s.tsType)
|
|
1002
|
-
return String(s.tsType);
|
|
1003
996
|
if (s.type)
|
|
1004
997
|
return String(s.type);
|
|
1005
998
|
}
|
|
1006
999
|
return "unknown";
|
|
1007
1000
|
}
|
|
1008
|
-
function ParameterCard({ param, spec }) {
|
|
1001
|
+
function ParameterCard({ param, spec: _spec }) {
|
|
1009
1002
|
const type = formatSchema4(param.schema);
|
|
1010
1003
|
const isRequired = param.required !== false;
|
|
1011
1004
|
return /* @__PURE__ */ jsxDEV9("div", {
|
|
@@ -1049,8 +1042,6 @@ function formatSchema5(schema) {
|
|
|
1049
1042
|
if (s.$ref && typeof s.$ref === "string") {
|
|
1050
1043
|
return s.$ref.replace("#/types/", "");
|
|
1051
1044
|
}
|
|
1052
|
-
if (s.tsType)
|
|
1053
|
-
return String(s.tsType);
|
|
1054
1045
|
if (s.type)
|
|
1055
1046
|
return String(s.type);
|
|
1056
1047
|
}
|
|
@@ -1075,7 +1066,7 @@ function FunctionPage({ export: exp, spec }) {
|
|
|
1075
1066
|
children: "Returns:"
|
|
1076
1067
|
}, undefined, false, undefined, this),
|
|
1077
1068
|
" ",
|
|
1078
|
-
sig.returns.description || `A ${
|
|
1069
|
+
sig.returns.description || `A ${formatSchema5(sig.returns.schema)}`
|
|
1079
1070
|
]
|
|
1080
1071
|
}, undefined, true, undefined, this),
|
|
1081
1072
|
/* @__PURE__ */ jsxDEV10("div", {
|
|
@@ -1143,8 +1134,6 @@ function formatSchema6(schema) {
|
|
|
1143
1134
|
}
|
|
1144
1135
|
if (s.type)
|
|
1145
1136
|
return String(s.type);
|
|
1146
|
-
if (s.tsType)
|
|
1147
|
-
return String(s.tsType);
|
|
1148
1137
|
}
|
|
1149
1138
|
return "unknown";
|
|
1150
1139
|
}
|
|
@@ -1227,6 +1216,21 @@ function TypeTable({ items, showRequired = true }) {
|
|
|
1227
1216
|
// src/components/interface-page.tsx
|
|
1228
1217
|
import { jsxDEV as jsxDEV12 } from "react/jsx-dev-runtime";
|
|
1229
1218
|
|
|
1219
|
+
function formatSchema7(schema) {
|
|
1220
|
+
if (!schema)
|
|
1221
|
+
return "unknown";
|
|
1222
|
+
if (typeof schema === "string")
|
|
1223
|
+
return schema;
|
|
1224
|
+
if (typeof schema === "object" && schema !== null) {
|
|
1225
|
+
const s = schema;
|
|
1226
|
+
if (s.$ref && typeof s.$ref === "string") {
|
|
1227
|
+
return s.$ref.replace("#/types/", "");
|
|
1228
|
+
}
|
|
1229
|
+
if (s.type)
|
|
1230
|
+
return String(s.type);
|
|
1231
|
+
}
|
|
1232
|
+
return "unknown";
|
|
1233
|
+
}
|
|
1230
1234
|
function InterfacePage({ export: exp, spec }) {
|
|
1231
1235
|
const properties = exp.members?.filter((m) => m.kind === "property" || m.kind === "field" || !m.kind);
|
|
1232
1236
|
const methods = exp.members?.filter((m) => m.kind === "method" || m.kind === "function");
|
|
@@ -1287,7 +1291,7 @@ function InterfacePage({ export: exp, spec }) {
|
|
|
1287
1291
|
children: methods.map((method, index) => {
|
|
1288
1292
|
const sig = method.signatures?.[0];
|
|
1289
1293
|
const params = sig?.parameters ?? [];
|
|
1290
|
-
const returnType = sig?.returns?.
|
|
1294
|
+
const returnType = formatSchema7(sig?.returns?.schema);
|
|
1291
1295
|
return /* @__PURE__ */ jsxDEV12("div", {
|
|
1292
1296
|
className: "rounded-lg border border-fd-border p-4",
|
|
1293
1297
|
children: [
|
|
@@ -1298,7 +1302,7 @@ function InterfacePage({ export: exp, spec }) {
|
|
|
1298
1302
|
"(",
|
|
1299
1303
|
params.map((p) => {
|
|
1300
1304
|
const optional = p.required === false ? "?" : "";
|
|
1301
|
-
const type =
|
|
1305
|
+
const type = formatSchema7(p.schema);
|
|
1302
1306
|
return `${p.name}${optional}: ${type}`;
|
|
1303
1307
|
}).join(", "),
|
|
1304
1308
|
"): ",
|
|
@@ -1328,7 +1332,7 @@ function InterfacePage({ export: exp, spec }) {
|
|
|
1328
1332
|
// src/components/variable-page.tsx
|
|
1329
1333
|
import { jsxDEV as jsxDEV13 } from "react/jsx-dev-runtime";
|
|
1330
1334
|
|
|
1331
|
-
function
|
|
1335
|
+
function formatSchema8(schema) {
|
|
1332
1336
|
if (!schema)
|
|
1333
1337
|
return "unknown";
|
|
1334
1338
|
if (typeof schema === "string")
|
|
@@ -1338,15 +1342,13 @@ function formatSchema7(schema) {
|
|
|
1338
1342
|
if (s.$ref && typeof s.$ref === "string") {
|
|
1339
1343
|
return s.$ref.replace("#/types/", "");
|
|
1340
1344
|
}
|
|
1341
|
-
if (s.tsType)
|
|
1342
|
-
return String(s.tsType);
|
|
1343
1345
|
if (s.type)
|
|
1344
1346
|
return String(s.type);
|
|
1345
1347
|
}
|
|
1346
1348
|
return "unknown";
|
|
1347
1349
|
}
|
|
1348
|
-
function VariablePage({ export: exp, spec }) {
|
|
1349
|
-
const typeValue = typeof exp.type === "string" ? exp.type :
|
|
1350
|
+
function VariablePage({ export: exp, spec: _spec }) {
|
|
1351
|
+
const typeValue = typeof exp.type === "string" ? exp.type : formatSchema8(exp.schema);
|
|
1350
1352
|
const hasExamples = exp.examples && exp.examples.length > 0;
|
|
1351
1353
|
return /* @__PURE__ */ jsxDEV13("div", {
|
|
1352
1354
|
className: "space-y-8",
|
package/package.json
CHANGED
|
@@ -47,7 +47,7 @@ function NotFound({ id }: { id: string }) {
|
|
|
47
47
|
* <APIPage instance={openpkg} id="createClient" />
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
|
-
export function APIPage({ spec, instance, id }: APIPageProps) {
|
|
50
|
+
export function APIPage({ spec, instance, id }: APIPageProps): React.ReactNode {
|
|
51
51
|
const resolvedSpec = spec ?? instance?.spec;
|
|
52
52
|
|
|
53
53
|
if (!resolvedSpec) {
|
|
@@ -19,7 +19,6 @@ function formatSchema(schema: unknown): string {
|
|
|
19
19
|
if (s.$ref && typeof s.$ref === 'string') {
|
|
20
20
|
return s.$ref.replace('#/types/', '');
|
|
21
21
|
}
|
|
22
|
-
if (s.tsType) return String(s.tsType);
|
|
23
22
|
if (s.type) return String(s.type);
|
|
24
23
|
}
|
|
25
24
|
return 'unknown';
|
|
@@ -63,7 +62,7 @@ function PropertyItem({ member }: { member: SpecMember }) {
|
|
|
63
62
|
);
|
|
64
63
|
}
|
|
65
64
|
|
|
66
|
-
export function ClassPage({ export: exp, spec }: ClassPageProps) {
|
|
65
|
+
export function ClassPage({ export: exp, spec: _spec }: ClassPageProps): React.ReactNode {
|
|
67
66
|
const hasExamples = exp.examples && exp.examples.length > 0;
|
|
68
67
|
|
|
69
68
|
// Group members
|
|
@@ -18,6 +18,7 @@ function ChevronIcon({ expanded }: { expanded: boolean }) {
|
|
|
18
18
|
viewBox="0 0 16 16"
|
|
19
19
|
fill="none"
|
|
20
20
|
className={`transition-transform duration-200 ${expanded ? 'rotate-90' : ''}`}
|
|
21
|
+
aria-hidden="true"
|
|
21
22
|
>
|
|
22
23
|
<path
|
|
23
24
|
d="M6 4L10 8L6 12"
|
|
@@ -38,23 +39,13 @@ function formatSchema(schema: unknown): string {
|
|
|
38
39
|
if (s.$ref && typeof s.$ref === 'string') {
|
|
39
40
|
return s.$ref.replace('#/types/', '');
|
|
40
41
|
}
|
|
41
|
-
if (s.tsType) {
|
|
42
|
-
const tsType = String(s.tsType);
|
|
43
|
-
if (tsType.length > 40) return `${tsType.slice(0, 37)}...`;
|
|
44
|
-
return tsType;
|
|
45
|
-
}
|
|
46
42
|
if (s.type) return String(s.type);
|
|
47
43
|
}
|
|
48
44
|
return 'unknown';
|
|
49
45
|
}
|
|
50
46
|
|
|
51
|
-
function formatReturnType(returns: { schema?: SpecSchema
|
|
47
|
+
function formatReturnType(returns: { schema?: SpecSchema } | undefined): string {
|
|
52
48
|
if (!returns) return 'void';
|
|
53
|
-
if (returns.tsType) {
|
|
54
|
-
const t = returns.tsType;
|
|
55
|
-
if (t.length > 40) return `${t.slice(0, 37)}...`;
|
|
56
|
-
return t;
|
|
57
|
-
}
|
|
58
49
|
return formatSchema(returns.schema);
|
|
59
50
|
}
|
|
60
51
|
|
|
@@ -68,7 +59,10 @@ function formatParamPreview(params: { name?: string }[] | undefined): string {
|
|
|
68
59
|
* Collapsible method section with expand/collapse behavior
|
|
69
60
|
* Shows compact signature when collapsed, full details when expanded
|
|
70
61
|
*/
|
|
71
|
-
export function CollapsibleMethod({
|
|
62
|
+
export function CollapsibleMethod({
|
|
63
|
+
member,
|
|
64
|
+
defaultExpanded = false,
|
|
65
|
+
}: CollapsibleMethodProps): React.ReactNode {
|
|
72
66
|
const [expanded, setExpanded] = useState(defaultExpanded);
|
|
73
67
|
|
|
74
68
|
const sig = member.signatures?.[0];
|
|
@@ -93,6 +87,7 @@ export function CollapsibleMethod({ member, defaultExpanded = false }: Collapsib
|
|
|
93
87
|
<div id={member.name} className="scroll-mt-20 border-b border-fd-border last:border-0">
|
|
94
88
|
{/* Clickable header */}
|
|
95
89
|
<button
|
|
90
|
+
type="button"
|
|
96
91
|
onClick={() => setExpanded(!expanded)}
|
|
97
92
|
className="w-full flex items-center gap-3 py-4 px-1 text-left hover:bg-fd-muted/30 transition-colors cursor-pointer group"
|
|
98
93
|
>
|
|
@@ -161,7 +156,7 @@ export function CollapsibleMethod({ member, defaultExpanded = false }: Collapsib
|
|
|
161
156
|
</span>
|
|
162
157
|
<div className="border-l-2 border-fd-border pl-4 py-2">
|
|
163
158
|
<span className="font-mono text-sm text-fd-muted-foreground">
|
|
164
|
-
{
|
|
159
|
+
{formatSchema(sig.returns.schema)}
|
|
165
160
|
</span>
|
|
166
161
|
{returnDescription && (
|
|
167
162
|
<p className="text-sm text-fd-muted-foreground mt-1 leading-relaxed">
|
|
@@ -19,7 +19,11 @@ function formatSignal(signal: string): string {
|
|
|
19
19
|
return signal.charAt(0).toUpperCase() + signal.slice(1);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export function CoverageBadge({
|
|
22
|
+
export function CoverageBadge({
|
|
23
|
+
docs,
|
|
24
|
+
showMissing = true,
|
|
25
|
+
showDrift = true,
|
|
26
|
+
}: CoverageBadgeProps): React.ReactNode {
|
|
23
27
|
const score = docs.coverageScore;
|
|
24
28
|
const hasMissing = showMissing && docs.missing && docs.missing.length > 0;
|
|
25
29
|
const hasDrift = showDrift && docs.drift && docs.drift.length > 0;
|
|
@@ -32,7 +36,13 @@ export function CoverageBadge({ docs, showMissing = true, showDrift = true }: Co
|
|
|
32
36
|
<div
|
|
33
37
|
className={`inline-flex items-center gap-2 px-3 py-1.5 rounded-md border text-sm font-medium ${getScoreColor(score)}`}
|
|
34
38
|
>
|
|
35
|
-
<svg
|
|
39
|
+
<svg
|
|
40
|
+
className="w-4 h-4"
|
|
41
|
+
fill="none"
|
|
42
|
+
stroke="currentColor"
|
|
43
|
+
viewBox="0 0 24 24"
|
|
44
|
+
aria-hidden="true"
|
|
45
|
+
>
|
|
36
46
|
<path
|
|
37
47
|
strokeLinecap="round"
|
|
38
48
|
strokeLinejoin="round"
|
|
@@ -63,8 +73,8 @@ export function CoverageBadge({ docs, showMissing = true, showDrift = true }: Co
|
|
|
63
73
|
Documentation Drift
|
|
64
74
|
</p>
|
|
65
75
|
<ul className="text-sm text-red-600/80 dark:text-red-400/80 space-y-1">
|
|
66
|
-
{docs.drift!.map((drift
|
|
67
|
-
<li key={
|
|
76
|
+
{docs.drift!.map((drift) => (
|
|
77
|
+
<li key={`${drift.type}-${drift.issue}`} className="flex flex-col">
|
|
68
78
|
<span className="font-medium">{drift.type}</span>
|
|
69
79
|
<span className="text-xs opacity-80">{drift.issue}</span>
|
|
70
80
|
{drift.suggestion && (
|
|
@@ -10,7 +10,7 @@ export interface EnumPageProps {
|
|
|
10
10
|
spec: OpenPkg;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export function EnumPage({ export: exp, spec }: EnumPageProps) {
|
|
13
|
+
export function EnumPage({ export: exp, spec: _spec }: EnumPageProps): React.ReactNode {
|
|
14
14
|
const members = exp.members ?? [];
|
|
15
15
|
|
|
16
16
|
return (
|
|
@@ -49,7 +49,9 @@ export function EnumPage({ export: exp, spec }: EnumPageProps) {
|
|
|
49
49
|
const value =
|
|
50
50
|
member.schema !== undefined
|
|
51
51
|
? typeof member.schema === 'object' && member.schema !== null
|
|
52
|
-
? ((member.schema as
|
|
52
|
+
? ((member.schema as Record<string, unknown>).const ??
|
|
53
|
+
(member.schema as Record<string, unknown>).default ??
|
|
54
|
+
'-')
|
|
53
55
|
: member.schema
|
|
54
56
|
: '-';
|
|
55
57
|
|
|
@@ -23,11 +23,23 @@ function CopyButton({ text }: { text: string }) {
|
|
|
23
23
|
aria-label="Copy code"
|
|
24
24
|
>
|
|
25
25
|
{copied ? (
|
|
26
|
-
<svg
|
|
26
|
+
<svg
|
|
27
|
+
className="w-4 h-4"
|
|
28
|
+
fill="none"
|
|
29
|
+
stroke="currentColor"
|
|
30
|
+
viewBox="0 0 24 24"
|
|
31
|
+
aria-hidden="true"
|
|
32
|
+
>
|
|
27
33
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
|
|
28
34
|
</svg>
|
|
29
35
|
) : (
|
|
30
|
-
<svg
|
|
36
|
+
<svg
|
|
37
|
+
className="w-4 h-4"
|
|
38
|
+
fill="none"
|
|
39
|
+
stroke="currentColor"
|
|
40
|
+
viewBox="0 0 24 24"
|
|
41
|
+
aria-hidden="true"
|
|
42
|
+
>
|
|
31
43
|
<path
|
|
32
44
|
strokeLinecap="round"
|
|
33
45
|
strokeLinejoin="round"
|
|
@@ -40,7 +52,7 @@ function CopyButton({ text }: { text: string }) {
|
|
|
40
52
|
);
|
|
41
53
|
}
|
|
42
54
|
|
|
43
|
-
export function ExamplesSection({ examples }: ExamplesSectionProps) {
|
|
55
|
+
export function ExamplesSection({ examples }: ExamplesSectionProps): React.ReactNode {
|
|
44
56
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
45
57
|
|
|
46
58
|
if (!examples?.length) return null;
|
|
@@ -53,9 +65,9 @@ export function ExamplesSection({ examples }: ExamplesSectionProps) {
|
|
|
53
65
|
|
|
54
66
|
{showTabs && (
|
|
55
67
|
<div className="flex gap-1 mb-2 border-b border-fd-border">
|
|
56
|
-
{examples.map((
|
|
68
|
+
{examples.map((example, index) => (
|
|
57
69
|
<button
|
|
58
|
-
key={index}
|
|
70
|
+
key={`example-${typeof example === 'string' ? example.slice(0, 20) : index}`}
|
|
59
71
|
type="button"
|
|
60
72
|
onClick={() => setActiveIndex(index)}
|
|
61
73
|
className={`px-3 py-1.5 text-sm font-medium transition-colors ${
|
|
@@ -24,6 +24,7 @@ function ChevronIcon({ expanded }: { expanded: boolean }) {
|
|
|
24
24
|
viewBox="0 0 12 12"
|
|
25
25
|
fill="none"
|
|
26
26
|
className={`transition-transform duration-200 ${expanded ? 'rotate-90' : ''}`}
|
|
27
|
+
aria-hidden="true"
|
|
27
28
|
>
|
|
28
29
|
<path
|
|
29
30
|
d="M4.5 2.5L8 6L4.5 9.5"
|
|
@@ -42,15 +43,6 @@ function formatType(schema: SpecSchema): string {
|
|
|
42
43
|
if (typeof schema === 'object' && schema !== null) {
|
|
43
44
|
const s = schema as Record<string, unknown>;
|
|
44
45
|
|
|
45
|
-
// Use tsType if available (most readable)
|
|
46
|
-
if (s.tsType && typeof s.tsType === 'string') {
|
|
47
|
-
const tsType = s.tsType as string;
|
|
48
|
-
if (tsType.length > 80) {
|
|
49
|
-
return `${tsType.slice(0, 77)}...`;
|
|
50
|
-
}
|
|
51
|
-
return tsType;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
46
|
// Handle refs
|
|
55
47
|
if (s.$ref && typeof s.$ref === 'string') {
|
|
56
48
|
return (s.$ref as string).replace('#/types/', '');
|
|
@@ -108,7 +100,12 @@ function countProperties(schema: SpecSchema): number {
|
|
|
108
100
|
/**
|
|
109
101
|
* Nested property row with expandable nested objects
|
|
110
102
|
*/
|
|
111
|
-
export function NestedProperty({
|
|
103
|
+
export function NestedProperty({
|
|
104
|
+
name,
|
|
105
|
+
schema,
|
|
106
|
+
required = false,
|
|
107
|
+
depth = 0,
|
|
108
|
+
}: NestedPropertyProps): React.ReactNode {
|
|
112
109
|
const [expanded, setExpanded] = useState(false);
|
|
113
110
|
const type = formatType(schema);
|
|
114
111
|
const nestedProps = getNestedProperties(schema);
|
|
@@ -142,6 +139,7 @@ export function NestedProperty({ name, schema, required = false, depth = 0 }: Ne
|
|
|
142
139
|
{/* Expand badge for nested objects */}
|
|
143
140
|
{hasNested && (
|
|
144
141
|
<button
|
|
142
|
+
type="button"
|
|
145
143
|
onClick={() => setExpanded(!expanded)}
|
|
146
144
|
className="flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-md
|
|
147
145
|
bg-fd-muted text-fd-muted-foreground hover:bg-fd-accent hover:text-fd-accent-foreground
|
|
@@ -175,7 +173,7 @@ export function NestedProperty({ name, schema, required = false, depth = 0 }: Ne
|
|
|
175
173
|
* Top-level expandable property for method parameters
|
|
176
174
|
* Entry point for rendering a parameter with progressive disclosure
|
|
177
175
|
*/
|
|
178
|
-
export function ExpandableProperty({ param, depth = 0 }: ExpandablePropertyProps) {
|
|
176
|
+
export function ExpandableProperty({ param, depth = 0 }: ExpandablePropertyProps): React.ReactNode {
|
|
179
177
|
const [expanded, setExpanded] = useState(false);
|
|
180
178
|
const type = formatType(param.schema);
|
|
181
179
|
const isOptional = param.required === false;
|
|
@@ -208,6 +206,7 @@ export function ExpandableProperty({ param, depth = 0 }: ExpandablePropertyProps
|
|
|
208
206
|
{/* Expand badge for nested objects */}
|
|
209
207
|
{hasNested && (
|
|
210
208
|
<button
|
|
209
|
+
type="button"
|
|
211
210
|
onClick={() => setExpanded(!expanded)}
|
|
212
211
|
className="flex items-center gap-1 px-2 py-0.5 text-xs font-medium rounded-md
|
|
213
212
|
bg-fd-muted text-fd-muted-foreground hover:bg-fd-accent hover:text-fd-accent-foreground
|
|
@@ -18,13 +18,12 @@ function formatSchema(schema: unknown): string {
|
|
|
18
18
|
if (s.$ref && typeof s.$ref === 'string') {
|
|
19
19
|
return s.$ref.replace('#/types/', '');
|
|
20
20
|
}
|
|
21
|
-
if (s.tsType) return String(s.tsType);
|
|
22
21
|
if (s.type) return String(s.type);
|
|
23
22
|
}
|
|
24
23
|
return 'unknown';
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
export function FunctionPage({ export: exp, spec }: FunctionPageProps) {
|
|
26
|
+
export function FunctionPage({ export: exp, spec }: FunctionPageProps): React.ReactNode {
|
|
28
27
|
const sig = exp.signatures?.[0];
|
|
29
28
|
const hasExamples = exp.examples && exp.examples.length > 0;
|
|
30
29
|
const hasParams = sig?.parameters && sig.parameters.length > 0;
|
|
@@ -40,7 +39,7 @@ export function FunctionPage({ export: exp, spec }: FunctionPageProps) {
|
|
|
40
39
|
{sig?.returns && (
|
|
41
40
|
<p className="text-fd-muted-foreground text-sm">
|
|
42
41
|
<span className="font-medium text-fd-foreground">Returns:</span>{' '}
|
|
43
|
-
{sig.returns.description || `A ${
|
|
42
|
+
{sig.returns.description || `A ${formatSchema(sig.returns.schema)}`}
|
|
44
43
|
</p>
|
|
45
44
|
)}
|
|
46
45
|
|
|
@@ -6,12 +6,25 @@ import { ExamplesSection } from './examples';
|
|
|
6
6
|
import { Signature } from './signature';
|
|
7
7
|
import { TypeTable } from './type-table';
|
|
8
8
|
|
|
9
|
+
function formatSchema(schema: unknown): string {
|
|
10
|
+
if (!schema) return 'unknown';
|
|
11
|
+
if (typeof schema === 'string') return schema;
|
|
12
|
+
if (typeof schema === 'object' && schema !== null) {
|
|
13
|
+
const s = schema as Record<string, unknown>;
|
|
14
|
+
if (s.$ref && typeof s.$ref === 'string') {
|
|
15
|
+
return s.$ref.replace('#/types/', '');
|
|
16
|
+
}
|
|
17
|
+
if (s.type) return String(s.type);
|
|
18
|
+
}
|
|
19
|
+
return 'unknown';
|
|
20
|
+
}
|
|
21
|
+
|
|
9
22
|
export interface InterfacePageProps {
|
|
10
23
|
export: SpecExport;
|
|
11
24
|
spec: OpenPkg;
|
|
12
25
|
}
|
|
13
26
|
|
|
14
|
-
export function InterfacePage({ export: exp, spec }: InterfacePageProps) {
|
|
27
|
+
export function InterfacePage({ export: exp, spec }: InterfacePageProps): React.ReactNode {
|
|
15
28
|
// For interfaces/types, members are the properties
|
|
16
29
|
const properties = exp.members?.filter(
|
|
17
30
|
(m) => m.kind === 'property' || m.kind === 'field' || !m.kind,
|
|
@@ -57,7 +70,7 @@ export function InterfacePage({ export: exp, spec }: InterfacePageProps) {
|
|
|
57
70
|
{methods.map((method, index) => {
|
|
58
71
|
const sig = method.signatures?.[0];
|
|
59
72
|
const params = sig?.parameters ?? [];
|
|
60
|
-
const returnType = sig?.returns?.
|
|
73
|
+
const returnType = formatSchema(sig?.returns?.schema);
|
|
61
74
|
|
|
62
75
|
return (
|
|
63
76
|
<div key={method.name ?? index} className="rounded-lg border border-fd-border p-4">
|
|
@@ -66,10 +79,7 @@ export function InterfacePage({ export: exp, spec }: InterfacePageProps) {
|
|
|
66
79
|
{params
|
|
67
80
|
.map((p) => {
|
|
68
81
|
const optional = p.required === false ? '?' : '';
|
|
69
|
-
const type =
|
|
70
|
-
typeof p.schema === 'string'
|
|
71
|
-
? p.schema
|
|
72
|
-
: ((p.schema as any)?.tsType ?? 'any');
|
|
82
|
+
const type = formatSchema(p.schema);
|
|
73
83
|
return `${p.name}${optional}: ${type}`;
|
|
74
84
|
})
|
|
75
85
|
.join(', ')}
|
|
@@ -16,7 +16,6 @@ function formatSchema(schema: unknown): string {
|
|
|
16
16
|
if (s.$ref && typeof s.$ref === 'string') {
|
|
17
17
|
return s.$ref.replace('#/types/', '');
|
|
18
18
|
}
|
|
19
|
-
if (s.tsType) return String(s.tsType);
|
|
20
19
|
if (s.type) return String(s.type);
|
|
21
20
|
}
|
|
22
21
|
return 'unknown';
|
|
@@ -80,7 +79,7 @@ function MemberRow({ member }: { member: SpecMember }) {
|
|
|
80
79
|
const optional = p.required === false ? '?' : '';
|
|
81
80
|
return `${p.name}${optional}: ${formatSchema(p.schema)}`;
|
|
82
81
|
}) ?? [];
|
|
83
|
-
const returnType =
|
|
82
|
+
const returnType = formatSchema(sig.returns?.schema) ?? 'void';
|
|
84
83
|
signature = `(${params.join(', ')}): ${returnType}`;
|
|
85
84
|
}
|
|
86
85
|
|
|
@@ -114,7 +113,11 @@ function MemberRow({ member }: { member: SpecMember }) {
|
|
|
114
113
|
);
|
|
115
114
|
}
|
|
116
115
|
|
|
117
|
-
export function MembersSection({
|
|
116
|
+
export function MembersSection({
|
|
117
|
+
members,
|
|
118
|
+
spec: _spec,
|
|
119
|
+
title = 'Members',
|
|
120
|
+
}: MembersSectionProps): React.ReactNode {
|
|
118
121
|
if (!members?.length) return null;
|
|
119
122
|
|
|
120
123
|
const groups = groupMembersByKind(members);
|
|
@@ -13,6 +13,9 @@ export interface MethodSectionProps {
|
|
|
13
13
|
* Method display section with collapsible behavior
|
|
14
14
|
* @deprecated Use CollapsibleMethod directly for more control
|
|
15
15
|
*/
|
|
16
|
-
export function MethodSection({
|
|
16
|
+
export function MethodSection({
|
|
17
|
+
member,
|
|
18
|
+
defaultExpanded = false,
|
|
19
|
+
}: MethodSectionProps): React.ReactNode {
|
|
17
20
|
return <CollapsibleMethod member={member} defaultExpanded={defaultExpanded} />;
|
|
18
21
|
}
|
|
@@ -15,13 +15,12 @@ function formatSchema(schema: unknown): string {
|
|
|
15
15
|
if (s.$ref && typeof s.$ref === 'string') {
|
|
16
16
|
return s.$ref.replace('#/types/', '');
|
|
17
17
|
}
|
|
18
|
-
if (s.tsType) return String(s.tsType);
|
|
19
18
|
if (s.type) return String(s.type);
|
|
20
19
|
}
|
|
21
20
|
return 'unknown';
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
export function ParameterCard({ param, spec }: ParameterCardProps) {
|
|
23
|
+
export function ParameterCard({ param, spec: _spec }: ParameterCardProps): React.ReactNode {
|
|
25
24
|
const type = formatSchema(param.schema);
|
|
26
25
|
const isRequired = param.required !== false;
|
|
27
26
|
|
|
@@ -38,7 +38,6 @@ function formatSchema(schema: unknown): string {
|
|
|
38
38
|
if (s.$ref && typeof s.$ref === 'string') {
|
|
39
39
|
return s.$ref.replace('#/types/', '');
|
|
40
40
|
}
|
|
41
|
-
if (s.tsType) return String(s.tsType);
|
|
42
41
|
if (s.type) return String(s.type);
|
|
43
42
|
}
|
|
44
43
|
return 'unknown';
|
|
@@ -46,7 +45,6 @@ function formatSchema(schema: unknown): string {
|
|
|
46
45
|
|
|
47
46
|
function formatReturnType(sig?: SpecSignature): string {
|
|
48
47
|
if (!sig?.returns) return 'void';
|
|
49
|
-
if (sig.returns.tsType) return sig.returns.tsType;
|
|
50
48
|
return formatSchema(sig.returns.schema);
|
|
51
49
|
}
|
|
52
50
|
|
|
@@ -85,7 +83,7 @@ function buildSignatureString(exp: SpecExport, sigIndex = 0): string {
|
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
85
|
|
|
88
|
-
export function Signature({ export: exp, signatureIndex = 0 }: SignatureProps) {
|
|
86
|
+
export function Signature({ export: exp, signatureIndex = 0 }: SignatureProps): React.ReactNode {
|
|
89
87
|
const signature = buildSignatureString(exp, signatureIndex);
|
|
90
88
|
|
|
91
89
|
// Build RawCode for syntax highlighting
|
|
@@ -20,8 +20,6 @@ function formatSchema(schema: unknown): string {
|
|
|
20
20
|
}
|
|
21
21
|
// Handle type
|
|
22
22
|
if (s.type) return String(s.type);
|
|
23
|
-
// Handle tsType
|
|
24
|
-
if (s.tsType) return String(s.tsType);
|
|
25
23
|
}
|
|
26
24
|
return 'unknown';
|
|
27
25
|
}
|
|
@@ -30,7 +28,7 @@ function isParameter(item: SpecSignatureParameter | SpecMember): item is SpecSig
|
|
|
30
28
|
return 'required' in item;
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
export function TypeTable({ items, showRequired = true }: TypeTableProps) {
|
|
31
|
+
export function TypeTable({ items, showRequired = true }: TypeTableProps): React.ReactNode {
|
|
34
32
|
if (!items?.length) return null;
|
|
35
33
|
|
|
36
34
|
return (
|
|
@@ -17,13 +17,12 @@ function formatSchema(schema: unknown): string {
|
|
|
17
17
|
if (s.$ref && typeof s.$ref === 'string') {
|
|
18
18
|
return s.$ref.replace('#/types/', '');
|
|
19
19
|
}
|
|
20
|
-
if (s.tsType) return String(s.tsType);
|
|
21
20
|
if (s.type) return String(s.type);
|
|
22
21
|
}
|
|
23
22
|
return 'unknown';
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
export function VariablePage({ export: exp, spec }: VariablePageProps) {
|
|
25
|
+
export function VariablePage({ export: exp, spec: _spec }: VariablePageProps): React.ReactNode {
|
|
27
26
|
const typeValue = typeof exp.type === 'string' ? exp.type : formatSchema(exp.schema);
|
|
28
27
|
const hasExamples = exp.examples && exp.examples.length > 0;
|
|
29
28
|
|