rspress-plugin-api-extractor 0.1.0 → 0.1.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.
@@ -0,0 +1,173 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { Root } from 'hast';
3
+
4
+ /**
5
+ * Renders an example code block.
6
+ *
7
+ * Replaces ExampleBlockWrapper with a simpler component that takes a plain
8
+ * code string (no base64, no HAST for code). The code should already have
9
+ * Twoslash directives stripped.
10
+ *
11
+ * In SSG-MD mode, renders a plain code block with the example code.
12
+ */
13
+ export declare function ApiExample({ code, hast }: ApiExampleProps): ReactElement;
14
+
15
+ export declare interface ApiExampleProps {
16
+ /** Example code (no Twoslash directives) */
17
+ code: string;
18
+ /**
19
+ * Pre-generated HAST tree from Shiki (base64-encoded JSON string).
20
+ * Injected by the remark-api-codeblocks plugin during MDX compilation.
21
+ */
22
+ hast?: string;
23
+ }
24
+
25
+ /**
26
+ * Renders an individual class/interface member signature block.
27
+ *
28
+ * Replaces MemberSignatureWrapper with a simpler component that takes plain
29
+ * string props. The `code` prop contains only the member signature (not
30
+ * wrapped in a class skeleton), and `summary` is plain markdown-compatible
31
+ * text (not HTML with anchor tags, not base64-encoded).
32
+ *
33
+ * In SSG-MD mode, renders a heading with member name, summary text,
34
+ * and a plain code block with the member signature.
35
+ */
36
+ export declare function ApiMember({ code, memberName, summary, id, hast, hasParameters }: ApiMemberProps): ReactElement;
37
+
38
+ export declare interface ApiMemberProps {
39
+ /** Member signature code (not wrapped in class/interface) */
40
+ code: string;
41
+ /** Display name for the heading */
42
+ memberName: string;
43
+ /** Plain text or markdown summary (not HTML, not base64) */
44
+ summary?: string;
45
+ /** Anchor ID */
46
+ id?: string;
47
+ /**
48
+ * Pre-generated HAST tree from Shiki (base64-encoded JSON string).
49
+ * Injected by the remark-api-codeblocks plugin during MDX compilation.
50
+ */
51
+ hast?: string;
52
+ /** Whether this signature has parameters (affects border radius in browser mode) */
53
+ hasParameters?: boolean | string;
54
+ }
55
+
56
+ /**
57
+ * Renders a full API type signature block.
58
+ *
59
+ * Replaces SignatureBlockWrapper with a simpler component that takes plain
60
+ * string props (no base64 encoding for code). Produces clean semantic HTML
61
+ * that RSPress converts to LLM-readable markdown in SSG-MD mode, and renders
62
+ * interactive Shiki-highlighted code in browser mode.
63
+ *
64
+ * In SSG-MD mode, renders a "Signature" heading followed by a plain
65
+ * code block with the type signature.
66
+ */
67
+ export declare function ApiSignature({ code, heading: _heading, id: _id, hast, hasParameters, hasMembers, }: ApiSignatureProps): ReactElement;
68
+
69
+ export declare interface ApiSignatureProps {
70
+ /** Display code (clean, no Twoslash directives) */
71
+ code: string;
72
+ /** Section heading (default: "Signature") */
73
+ heading?: string;
74
+ /** Anchor ID (default: "signature") */
75
+ id?: string;
76
+ /**
77
+ * Pre-generated HAST tree from Shiki (base64-encoded JSON string).
78
+ * Injected by the remark-api-codeblocks plugin during MDX compilation.
79
+ */
80
+ hast?: string;
81
+ /** Whether this signature has parameters (affects border radius in browser mode) */
82
+ hasParameters?: boolean | string;
83
+ /** Whether this signature has members table below (affects border radius in browser mode) */
84
+ hasMembers?: boolean | string;
85
+ }
86
+
87
+ export declare interface EnumMember {
88
+ name: string;
89
+ value?: string;
90
+ description: string;
91
+ }
92
+
93
+ export declare const EnumMembersTable: ({ members }: EnumMembersTableProps) => ReactElement | null;
94
+
95
+ export declare interface EnumMembersTableProps {
96
+ members: EnumMember[];
97
+ }
98
+
99
+ /**
100
+ * Code block for examples - displays syntax-highlighted code without a heading
101
+ * Similar to SignatureBlock but without the "Signature" header
102
+ * Includes both copy and wrap buttons in the toolbar
103
+ */
104
+ export declare function ExampleBlock({ hast, code }: ExampleBlockProps): ReactElement;
105
+
106
+ export declare interface ExampleBlockProps {
107
+ /** Pre-generated HAST (Hypertext Abstract Syntax Tree) from Shiki */
108
+ hast: Root | null;
109
+ /** The code for copy functionality (optional for backwards compatibility) */
110
+ code?: string;
111
+ }
112
+
113
+ /**
114
+ * Convert a HAST (Hypertext Abstract Syntax Tree) root to a React element.
115
+ *
116
+ * This function is used to render pre-generated Shiki HAST trees at runtime,
117
+ * avoiding the need for `dangerouslySetInnerHTML` and eliminating MDX parsing
118
+ * issues caused by long HTML strings with special characters.
119
+ *
120
+ * @param hast - The HAST root node from Shiki's `codeToHast()`
121
+ * @returns A React element representing the HAST tree
122
+ */
123
+ export declare function hastToReact(hast: Root): ReactElement;
124
+
125
+ /**
126
+ * Interactive member signature block with h3 header and wrap button
127
+ * Displays syntax-highlighted TypeScript member signatures with hover tooltips
128
+ */
129
+ export declare function MemberSignature({ hast, memberName, id, summary, hasParameters, }: MemberSignatureProps): ReactElement;
130
+
131
+ export declare interface MemberSignatureProps {
132
+ /** Pre-generated HAST (Hypertext Abstract Syntax Tree) from Shiki */
133
+ hast: Root | null;
134
+ /** Member name to display in the header */
135
+ memberName: string;
136
+ /** Optional ID for the anchor link */
137
+ id?: string;
138
+ /** Optional plain text summary to display in the toolbar */
139
+ summary?: string;
140
+ /** Whether this signature has parameters (affects border radius) */
141
+ hasParameters?: boolean;
142
+ }
143
+
144
+ export declare interface Parameter {
145
+ name: string;
146
+ type?: string;
147
+ description: string;
148
+ }
149
+
150
+ export declare const ParametersTable: ({ parameters }: ParametersTableProps) => ReactElement | null;
151
+
152
+ export declare interface ParametersTableProps {
153
+ parameters: Parameter[];
154
+ }
155
+
156
+ /**
157
+ * Interactive signature block with wrap button
158
+ * Displays syntax-highlighted TypeScript signatures with hover tooltips
159
+ */
160
+ export declare function SignatureBlock({ hast, heading, id, hasParameters, }: SignatureBlockProps): ReactElement;
161
+
162
+ export declare interface SignatureBlockProps {
163
+ /** Pre-generated HAST (Hypertext Abstract Syntax Tree) from Shiki */
164
+ hast: Root | null;
165
+ /** Optional heading text to display in the toolbar */
166
+ heading?: string;
167
+ /** Optional ID for the heading anchor link */
168
+ id?: string;
169
+ /** Whether this signature has parameters (affects border radius) */
170
+ hasParameters?: boolean;
171
+ }
172
+
173
+ export { }