rspress-plugin-api-extractor 0.2.2 → 0.3.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.
Files changed (51) hide show
  1. package/api-extracted-package.js +2 -1
  2. package/build-program.js +20 -12
  3. package/build-stages.js +124 -30
  4. package/config-utils.js +36 -7
  5. package/content-hash.js +1 -1
  6. package/errors.js +1 -1
  7. package/index.d.ts +329 -202
  8. package/layers/ConfigServiceLive.js +300 -136
  9. package/layers/ObservabilityLive.js +49 -85
  10. package/layers/TypeRegistryServiceLive.js +122 -21
  11. package/layers/build-metrics.js +61 -0
  12. package/llms-program.js +29 -7
  13. package/loader.js +16 -2
  14. package/markdown/helpers.js +1 -1
  15. package/markdown/index.js +1 -1
  16. package/markdown/shiki-utils.js +16 -2
  17. package/observability/EventBus.js +38 -0
  18. package/observability/events.js +17 -0
  19. package/observability/sinks/console-sink.js +63 -0
  20. package/observability/sinks/metrics-sink.js +68 -0
  21. package/observability/sinks/trace-sink.js +38 -0
  22. package/observability/spans.js +57 -0
  23. package/og-resolver.js +37 -5
  24. package/package.json +6 -6
  25. package/plugin.js +73 -19
  26. package/prettier-formatter.js +15 -4
  27. package/remark-api-codeblocks.js +22 -3
  28. package/remark-with-api.js +27 -14
  29. package/route-collisions.js +1 -1
  30. package/runtime/components/ApiExample/index.js +5 -5
  31. package/runtime/components/ApiMember/index.js +5 -7
  32. package/runtime/components/ApiSignature/index.js +4 -6
  33. package/runtime/components/EnumMembersTable/index.js +5 -0
  34. package/runtime/components/ExampleBlock/index.js +5 -3
  35. package/runtime/components/MemberSignature/index.js +4 -2
  36. package/runtime/components/ParametersTable/index.js +5 -0
  37. package/runtime/components/SignatureBlock/index.js +4 -2
  38. package/runtime/components/shared/variables.css +0 -15
  39. package/runtime/index.d.ts +65 -399
  40. package/runtime/index.js +1 -5
  41. package/runtime/utils/hast-renderer.js +1 -0
  42. package/schemas/config.js +105 -4
  43. package/schemas/index.js +3 -2
  44. package/schemas/observability.js +62 -0
  45. package/schemas/opengraph.js +30 -0
  46. package/schemas/performance.js +1 -1
  47. package/serve.js +13 -0
  48. package/tsconfig-parser.js +1 -1
  49. package/twoslash-patterns.js +1 -1
  50. package/twoslash-transformer.js +93 -8
  51. package/typescript-config.js +1 -1
@@ -1,6 +1,11 @@
1
1
  import { ReactElement } from "react";
2
2
 
3
3
  //#region src/runtime/components/ApiExample/index.d.ts
4
+ /**
5
+ * Props for the {@link ApiExample} component used in generated MDX pages.
6
+ *
7
+ * @public
8
+ */
4
9
  interface ApiExampleProps {
5
10
  /** Example code (no Twoslash directives) */
6
11
  code: string;
@@ -11,13 +16,13 @@ interface ApiExampleProps {
11
16
  hast?: string;
12
17
  }
13
18
  /**
14
- * Renders an example code block.
19
+ * Renders an example code block in generated API documentation pages.
15
20
  *
16
- * Replaces ExampleBlockWrapper with a simpler component that takes a plain
17
- * code string (no base64, no HAST for code). The code should already have
18
- * Twoslash directives stripped.
21
+ * In browser mode renders a Shiki-highlighted code block with copy and wrap
22
+ * controls. In SSG-MD mode renders a plain fenced code block.
19
23
  *
20
- * In SSG-MD mode, renders a plain code block with the example code.
24
+ * @param props - {@link ApiExampleProps}
25
+ * @public
21
26
  */
22
27
  declare function ApiExample({
23
28
  code,
@@ -25,6 +30,11 @@ declare function ApiExample({
25
30
  }: ApiExampleProps): ReactElement;
26
31
  //#endregion
27
32
  //#region src/runtime/components/ApiMember/index.d.ts
33
+ /**
34
+ * Props for the {@link ApiMember} component used in generated MDX pages.
35
+ *
36
+ * @public
37
+ */
28
38
  interface ApiMemberProps {
29
39
  /** Member signature code (not wrapped in class/interface) */
30
40
  code: string;
@@ -43,15 +53,13 @@ interface ApiMemberProps {
43
53
  hasParameters?: boolean | string;
44
54
  }
45
55
  /**
46
- * Renders an individual class/interface member signature block.
56
+ * Renders an individual class or interface member signature block.
47
57
  *
48
- * Replaces MemberSignatureWrapper with a simpler component that takes plain
49
- * string props. The `code` prop contains only the member signature (not
50
- * wrapped in a class skeleton), and `summary` is plain markdown-compatible
51
- * text (not HTML with anchor tags, not base64-encoded).
58
+ * In browser mode renders an `h3` heading with a Shiki-highlighted signature.
59
+ * In SSG-MD mode renders a heading, summary, and plain fenced code block.
52
60
  *
53
- * In SSG-MD mode, renders a heading with member name, summary text,
54
- * and a plain code block with the member signature.
61
+ * @param props - {@link ApiMemberProps}
62
+ * @public
55
63
  */
56
64
  declare function ApiMember({
57
65
  code,
@@ -63,6 +71,11 @@ declare function ApiMember({
63
71
  }: ApiMemberProps): ReactElement;
64
72
  //#endregion
65
73
  //#region src/runtime/components/ApiSignature/index.d.ts
74
+ /**
75
+ * Props for the {@link ApiSignature} component used in generated MDX pages.
76
+ *
77
+ * @public
78
+ */
66
79
  interface ApiSignatureProps {
67
80
  /** Display code (clean, no Twoslash directives) */
68
81
  code: string;
@@ -83,13 +96,11 @@ interface ApiSignatureProps {
83
96
  /**
84
97
  * Renders a full API type signature block.
85
98
  *
86
- * Replaces SignatureBlockWrapper with a simpler component that takes plain
87
- * string props (no base64 encoding for code). Produces clean semantic HTML
88
- * that RSPress converts to LLM-readable markdown in SSG-MD mode, and renders
89
- * interactive Shiki-highlighted code in browser mode.
99
+ * In browser mode renders an interactive Shiki-highlighted code block.
100
+ * In SSG-MD mode renders a plain fenced code block for LLM consumption.
90
101
  *
91
- * In SSG-MD mode, renders a "Signature" heading followed by a plain
92
- * code block with the type signature.
102
+ * @param props - {@link ApiSignatureProps}
103
+ * @public
93
104
  */
94
105
  declare function ApiSignature({
95
106
  code,
@@ -101,413 +112,68 @@ declare function ApiSignature({
101
112
  }: ApiSignatureProps): ReactElement;
102
113
  //#endregion
103
114
  //#region src/runtime/components/EnumMembersTable/index.d.ts
115
+ /**
116
+ * A single enum member entry for {@link EnumMembersTable}.
117
+ *
118
+ * @public
119
+ */
104
120
  interface EnumMember {
121
+ /** The enum member name. */
105
122
  name: string;
123
+ /** The string or numeric value of the member, if any. */
106
124
  value?: string;
125
+ /** HTML description rendered in the table cell. */
107
126
  description: string;
108
127
  }
109
- interface EnumMembersTableProps {
110
- members: EnumMember[];
111
- }
112
- declare const EnumMembersTable: ({
113
- members
114
- }: EnumMembersTableProps) => ReactElement | null;
115
- //#endregion
116
- //#region ../node_modules/.pnpm/@types+unist@3.0.3/node_modules/@types/unist/index.d.ts
117
- // ## Interfaces
118
- /**
119
- * Info associated with nodes by the ecosystem.
120
- *
121
- * This space is guaranteed to never be specified by unist or specifications
122
- * implementing unist.
123
- * But you can use it in utilities and plugins to store data.
124
- *
125
- * This type can be augmented to register custom data.
126
- * For example:
127
- *
128
- * ```ts
129
- * declare module 'unist' {
130
- * interface Data {
131
- * // `someNode.data.myId` is typed as `number | undefined`
132
- * myId?: number | undefined
133
- * }
134
- * }
135
- * ```
136
- */
137
- interface Data$1 {}
138
- /**
139
- * One place in a source file.
140
- */
141
- interface Point {
142
- /**
143
- * Line in a source file (1-indexed integer).
144
- */
145
- line: number;
146
- /**
147
- * Column in a source file (1-indexed integer).
148
- */
149
- column: number;
150
- /**
151
- * Character in a source file (0-indexed integer).
152
- */
153
- offset?: number | undefined;
154
- }
155
128
  /**
156
- * Position of a node in a source document.
129
+ * Props for the {@link EnumMembersTable} component.
157
130
  *
158
- * A position is a range between two points.
131
+ * @public
159
132
  */
160
- interface Position {
161
- /**
162
- * Place of the first character of the parsed source region.
163
- */
164
- start: Point;
165
- /**
166
- * Place of the first character after the parsed source region.
167
- */
168
- end: Point;
133
+ interface EnumMembersTableProps {
134
+ /** Enum members to display. */
135
+ members: EnumMember[];
169
136
  }
170
137
  /**
171
- * Abstract unist node.
138
+ * Renders a table of enum members with their values and descriptions.
172
139
  *
173
- * The syntactic unit in unist syntax trees are called nodes.
174
- *
175
- * This interface is supposed to be extended.
176
- * If you can use {@link Literal} or {@link Parent}, you should.
177
- * But for example in markdown, a `thematicBreak` (`***`), is neither literal
178
- * nor parent, but still a node.
140
+ * @public
179
141
  */
180
- interface Node$1 {
181
- /**
182
- * Node type.
183
- */
184
- type: string;
185
- /**
186
- * Info from the ecosystem.
187
- */
188
- data?: Data$1 | undefined;
189
- /**
190
- * Position of a node in a source document.
191
- *
192
- * Nodes that are generated (not in the original source document) must not
193
- * have a position.
194
- */
195
- position?: Position | undefined;
196
- }
142
+ declare const EnumMembersTable: ({
143
+ members
144
+ }: EnumMembersTableProps) => ReactElement | null;
197
145
  //#endregion
198
- //#region ../node_modules/.pnpm/@types+hast@3.0.4/node_modules/@types/hast/index.d.ts
199
- // ## Interfaces
200
- /**
201
- * Info associated with hast nodes by the ecosystem.
202
- *
203
- * This space is guaranteed to never be specified by unist or hast.
204
- * But you can use it in utilities and plugins to store data.
205
- *
206
- * This type can be augmented to register custom data.
207
- * For example:
208
- *
209
- * ```ts
210
- * declare module 'hast' {
211
- * interface Data {
212
- * // `someNode.data.myId` is typed as `number | undefined`
213
- * myId?: number | undefined
214
- * }
215
- * }
216
- * ```
217
- */
218
- interface Data extends Data$1 {}
219
- /**
220
- * Info associated with an element.
221
- */
222
- interface Properties {
223
- [PropertyName: string]: boolean | number | string | null | undefined | Array<string | number>;
224
- }
225
- // ## Content maps
226
- /**
227
- * Union of registered hast nodes that can occur in {@link Element}.
228
- *
229
- * To register mote custom hast nodes, add them to {@link ElementContentMap}.
230
- * They will be automatically added here.
231
- */
232
- type ElementContent = ElementContentMap[keyof ElementContentMap];
233
- /**
234
- * Registry of all hast nodes that can occur as children of {@link Element}.
235
- *
236
- * For a union of all {@link Element} children, see {@link ElementContent}.
237
- */
238
- interface ElementContentMap {
239
- comment: Comment;
240
- element: Element;
241
- text: Text;
242
- }
243
- /**
244
- * Union of registered hast nodes that can occur in {@link Root}.
245
- *
246
- * To register custom hast nodes, add them to {@link RootContentMap}.
247
- * They will be automatically added here.
248
- */
249
- type RootContent = RootContentMap[keyof RootContentMap];
250
- /**
251
- * Registry of all hast nodes that can occur as children of {@link Root}.
252
- *
253
- * > 👉 **Note**: {@link Root} does not need to be an entire document.
254
- * > it can also be a fragment.
255
- *
256
- * For a union of all {@link Root} children, see {@link RootContent}.
257
- */
258
- interface RootContentMap {
259
- comment: Comment;
260
- doctype: Doctype;
261
- element: Element;
262
- text: Text;
263
- }
264
- // ## Abstract nodes
265
- /**
266
- * Abstract hast node.
267
- *
268
- * This interface is supposed to be extended.
269
- * If you can use {@link Literal} or {@link Parent}, you should.
270
- * But for example in HTML, a `Doctype` is neither literal nor parent, but
271
- * still a node.
272
- *
273
- * To register custom hast nodes, add them to {@link RootContentMap} and other
274
- * places where relevant (such as {@link ElementContentMap}).
275
- *
276
- * For a union of all registered hast nodes, see {@link Nodes}.
277
- */
278
- interface Node extends Node$1 {
279
- /**
280
- * Info from the ecosystem.
281
- */
282
- data?: Data | undefined;
283
- }
284
- /**
285
- * Abstract hast node that contains the smallest possible value.
286
- *
287
- * This interface is supposed to be extended if you make custom hast nodes.
288
- *
289
- * For a union of all registered hast literals, see {@link Literals}.
290
- */
291
- interface Literal extends Node {
292
- /**
293
- * Plain-text value.
294
- */
295
- value: string;
296
- }
297
- /**
298
- * Abstract hast node that contains other hast nodes (*children*).
299
- *
300
- * This interface is supposed to be extended if you make custom hast nodes.
301
- *
302
- * For a union of all registered hast parents, see {@link Parents}.
303
- */
304
- interface Parent extends Node {
305
- /**
306
- * List of children.
307
- */
308
- children: RootContent[];
309
- }
310
- // ## Concrete nodes
311
- /**
312
- * HTML comment.
313
- */
314
- interface Comment extends Literal {
315
- /**
316
- * Node type of HTML comments in hast.
317
- */
318
- type: "comment";
319
- /**
320
- * Data associated with the comment.
321
- */
322
- data?: CommentData | undefined;
323
- }
324
- /**
325
- * Info associated with hast comments by the ecosystem.
326
- */
327
- interface CommentData extends Data {}
328
- /**
329
- * HTML document type.
330
- */
331
- interface Doctype extends Node$1 {
332
- /**
333
- * Node type of HTML document types in hast.
334
- */
335
- type: "doctype";
336
- /**
337
- * Data associated with the doctype.
338
- */
339
- data?: DoctypeData | undefined;
340
- }
341
- /**
342
- * Info associated with hast doctypes by the ecosystem.
343
- */
344
- interface DoctypeData extends Data {}
345
- /**
346
- * HTML element.
347
- */
348
- interface Element extends Parent {
349
- /**
350
- * Node type of elements.
351
- */
352
- type: "element";
353
- /**
354
- * Tag name (such as `'body'`) of the element.
355
- */
356
- tagName: string;
357
- /**
358
- * Info associated with the element.
359
- */
360
- properties: Properties;
361
- /**
362
- * Children of element.
363
- */
364
- children: ElementContent[];
365
- /**
366
- * When the `tagName` field is `'template'`, a `content` field can be
367
- * present.
368
- */
369
- content?: Root | undefined;
370
- /**
371
- * Data associated with the element.
372
- */
373
- data?: ElementData | undefined;
374
- }
375
- /**
376
- * Info associated with hast elements by the ecosystem.
377
- */
378
- interface ElementData extends Data {}
146
+ //#region src/runtime/components/ParametersTable/index.d.ts
379
147
  /**
380
- * Document fragment or a whole document.
148
+ * A single parameter entry for {@link ParametersTable}.
381
149
  *
382
- * Should be used as the root of a tree and must not be used as a child.
383
- *
384
- * Can also be used as the value for the content field on a `'template'` element.
385
- */
386
- interface Root extends Parent {
387
- /**
388
- * Node type of hast root.
389
- */
390
- type: "root";
391
- /**
392
- * Children of root.
393
- */
394
- children: RootContent[];
395
- /**
396
- * Data associated with the hast root.
397
- */
398
- data?: RootData | undefined;
399
- }
400
- /**
401
- * Info associated with hast root nodes by the ecosystem.
402
- */
403
- interface RootData extends Data {}
404
- /**
405
- * HTML character data (plain text).
406
- */
407
- interface Text extends Literal {
408
- /**
409
- * Node type of HTML character data (plain text) in hast.
410
- */
411
- type: "text";
412
- /**
413
- * Data associated with the text.
414
- */
415
- data?: TextData | undefined;
416
- }
417
- /**
418
- * Info associated with hast texts by the ecosystem.
419
- */
420
- interface TextData extends Data {}
421
- //#endregion
422
- //#region src/runtime/components/ExampleBlock/index.d.ts
423
- interface ExampleBlockProps {
424
- /** Pre-generated HAST (Hypertext Abstract Syntax Tree) from Shiki */
425
- hast: Root | null;
426
- /** The code for copy functionality (optional for backwards compatibility) */
427
- code?: string;
428
- }
429
- /**
430
- * Code block for examples - displays syntax-highlighted code without a heading
431
- * Similar to SignatureBlock but without the "Signature" header
432
- * Includes both copy and wrap buttons in the toolbar
150
+ * @public
433
151
  */
434
- declare function ExampleBlock({
435
- hast,
436
- code
437
- }: ExampleBlockProps): ReactElement;
438
- //#endregion
439
- //#region src/runtime/components/MemberSignature/index.d.ts
440
- interface MemberSignatureProps {
441
- /** Pre-generated HAST (Hypertext Abstract Syntax Tree) from Shiki */
442
- hast: Root | null;
443
- /** Member name to display in the header */
444
- memberName: string;
445
- /** Optional ID for the anchor link */
446
- id?: string;
447
- /** Optional plain text summary to display in the toolbar */
448
- summary?: string;
449
- /** Whether this signature has parameters (affects border radius) */
450
- hasParameters?: boolean;
451
- }
452
- /**
453
- * Interactive member signature block with h3 header and wrap button
454
- * Displays syntax-highlighted TypeScript member signatures with hover tooltips
455
- */
456
- declare function MemberSignature({
457
- hast,
458
- memberName,
459
- id,
460
- summary,
461
- hasParameters
462
- }: MemberSignatureProps): ReactElement;
463
- //#endregion
464
- //#region src/runtime/components/ParametersTable/index.d.ts
465
152
  interface Parameter {
153
+ /** Parameter name. */
466
154
  name: string;
155
+ /** TypeScript type string, if available. */
467
156
  type?: string;
157
+ /** HTML description rendered in the table cell. */
468
158
  description: string;
469
159
  }
160
+ /**
161
+ * Props for the {@link ParametersTable} component.
162
+ *
163
+ * @public
164
+ */
470
165
  interface ParametersTableProps {
166
+ /** Parameters to display. */
471
167
  parameters: Parameter[];
472
168
  }
473
- declare const ParametersTable: ({
474
- parameters
475
- }: ParametersTableProps) => ReactElement | null;
476
- //#endregion
477
- //#region src/runtime/components/SignatureBlock/index.d.ts
478
- interface SignatureBlockProps {
479
- /** Pre-generated HAST (Hypertext Abstract Syntax Tree) from Shiki */
480
- hast: Root | null;
481
- /** Optional heading text to display in the toolbar */
482
- heading?: string;
483
- /** Optional ID for the heading anchor link */
484
- id?: string;
485
- /** Whether this signature has parameters (affects border radius) */
486
- hasParameters?: boolean;
487
- }
488
169
  /**
489
- * Interactive signature block with wrap button
490
- * Displays syntax-highlighted TypeScript signatures with hover tooltips
491
- */
492
- declare function SignatureBlock({
493
- hast,
494
- heading,
495
- id,
496
- hasParameters
497
- }: SignatureBlockProps): ReactElement;
498
- //#endregion
499
- //#region src/runtime/utils/hast-renderer.d.ts
500
- /**
501
- * Convert a HAST (Hypertext Abstract Syntax Tree) root to a React element.
502
- *
503
- * This function is used to render pre-generated Shiki HAST trees at runtime,
504
- * avoiding the need for `dangerouslySetInnerHTML` and eliminating MDX parsing
505
- * issues caused by long HTML strings with special characters.
170
+ * Renders a table of function or method parameters with their types and descriptions.
506
171
  *
507
- * @param hast - The HAST root node from Shiki's `codeToHast()`
508
- * @returns A React element representing the HAST tree
172
+ * @public
509
173
  */
510
- declare function hastToReact(hast: Root): ReactElement;
174
+ declare const ParametersTable: ({
175
+ parameters
176
+ }: ParametersTableProps) => ReactElement | null;
511
177
  //#endregion
512
- export { ApiExample, type ApiExampleProps, ApiMember, type ApiMemberProps, ApiSignature, type ApiSignatureProps, type EnumMember, EnumMembersTable, type EnumMembersTableProps, ExampleBlock, type ExampleBlockProps, MemberSignature, type MemberSignatureProps, type Parameter, ParametersTable, type ParametersTableProps, SignatureBlock, type SignatureBlockProps, hastToReact };
178
+ export { ApiExample, type ApiExampleProps, ApiMember, type ApiMemberProps, ApiSignature, type ApiSignatureProps, type EnumMember, EnumMembersTable, type EnumMembersTableProps, type Parameter, ParametersTable, type ParametersTableProps };
513
179
  //# sourceMappingURL=index.d.ts.map
package/runtime/index.js CHANGED
@@ -1,13 +1,9 @@
1
1
  import "./components/shared/variables.css";
2
2
  import "./components/shared/_twoslash.css";
3
- import { hastToReact } from "./utils/hast-renderer.js";
4
- import { ExampleBlock } from "./components/ExampleBlock/index.js";
5
3
  import { ApiExample } from "./components/ApiExample/index.js";
6
- import { MemberSignature } from "./components/MemberSignature/index.js";
7
4
  import { ApiMember } from "./components/ApiMember/index.js";
8
- import { SignatureBlock } from "./components/SignatureBlock/index.js";
9
5
  import { ApiSignature } from "./components/ApiSignature/index.js";
10
6
  import { EnumMembersTable } from "./components/EnumMembersTable/index.js";
11
7
  import { ParametersTable } from "./components/ParametersTable/index.js";
12
8
 
13
- export { ApiExample, ApiMember, ApiSignature, EnumMembersTable, ExampleBlock, MemberSignature, ParametersTable, SignatureBlock, hastToReact };
9
+ export { ApiExample, ApiMember, ApiSignature, EnumMembersTable, ParametersTable };
@@ -11,6 +11,7 @@ import { toJsxRuntime } from "hast-util-to-jsx-runtime";
11
11
  *
12
12
  * @param hast - The HAST root node from Shiki's `codeToHast()`
13
13
  * @returns A React element representing the HAST tree
14
+ * @internal
14
15
  */
15
16
  function hastToReact(hast) {
16
17
  return toJsxRuntime(hast, {