@kubb/renderer-jsx 5.0.0-beta.4 → 5.0.0-beta.40
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/README.md +134 -0
- package/dist/index.cjs +621 -193
- package/dist/index.d.ts +326 -90
- package/dist/index.js +615 -193
- package/dist/jsx-dev-runtime.cjs +1 -1
- package/dist/jsx-dev-runtime.d.ts +7 -8
- package/dist/jsx-dev-runtime.js +2 -2
- package/dist/{jsx-namespace-CNp0arTN.d.ts → jsx-namespace-dmStM1a2.d.ts} +3 -3
- package/dist/{jsx-runtime-DdmO3p0U.cjs → jsx-runtime-4M1bV6ub.cjs} +9 -9
- package/dist/{jsx-runtime-Cvu_ZYgL.js → jsx-runtime-CQ6-_gue.js} +10 -10
- package/dist/jsx-runtime.cjs +1 -1
- package/dist/jsx-runtime.d.ts +9 -10
- package/dist/jsx-runtime.js +2 -2
- package/dist/{types-nAFMiWFw.d.ts → types-B5VGpHs0.d.ts} +11 -10
- package/dist/types.d.ts +1 -1
- package/package.json +8 -12
- package/src/Renderer.ts +1 -5
- package/src/Runtime.tsx +7 -18
- package/src/SyncRuntime.tsx +309 -0
- package/src/components/Callout.tsx +59 -0
- package/src/components/CodeBlock.tsx +37 -0
- package/src/components/Const.tsx +4 -4
- package/src/components/File.tsx +7 -5
- package/src/components/Frontmatter.tsx +38 -0
- package/src/components/Function.tsx +8 -8
- package/src/components/Heading.tsx +34 -0
- package/src/components/Jsx.tsx +1 -1
- package/src/components/List.tsx +40 -0
- package/src/components/Paragraph.tsx +28 -0
- package/src/components/Type.tsx +3 -3
- package/src/constants.ts +19 -9
- package/src/createRenderer.tsx +81 -62
- package/src/dom.ts +7 -19
- package/src/index.ts +7 -1
- package/src/types.ts +9 -8
- package/src/utils.ts +153 -174
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jsx-dev-runtime.cjs.map +0 -1
- package/dist/jsx-dev-runtime.js.map +0 -1
- package/dist/jsx-runtime-Cvu_ZYgL.js.map +0 -1
- package/dist/jsx-runtime-DdmO3p0U.cjs.map +0 -1
- package/dist/jsx-runtime.cjs.map +0 -1
- package/dist/jsx-runtime.js.map +0 -1
- /package/dist/{chunk-Bb7HlUDG.js → chunk-DoukXa0m.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { n as __name } from "./chunk-
|
|
2
|
-
import { a as JSDoc, h as KubbReactNode, m as KubbReactElement, o as Key } from "./types-
|
|
1
|
+
import { n as __name } from "./chunk-DoukXa0m.js";
|
|
2
|
+
import { a as JSDoc, h as KubbReactNode, m as KubbReactElement, o as Key } from "./types-B5VGpHs0.js";
|
|
3
3
|
import { ExportNode, FileNode, ImportNode, SourceNode } from "@kubb/ast";
|
|
4
|
-
import * as _$react from "react";
|
|
5
4
|
|
|
6
5
|
//#region ../../internals/utils/src/context.d.ts
|
|
7
6
|
/**
|
|
@@ -47,6 +46,95 @@ declare function unprovide<T>(key: symbol | Context<T>): void;
|
|
|
47
46
|
*/
|
|
48
47
|
declare function createContext<T>(defaultValue: T): Context<T>;
|
|
49
48
|
//#endregion
|
|
49
|
+
//#region src/components/Callout.d.ts
|
|
50
|
+
declare const CALLOUT_LABEL: {
|
|
51
|
+
readonly tip: "TIP";
|
|
52
|
+
readonly note: "NOTE";
|
|
53
|
+
readonly important: "IMPORTANT";
|
|
54
|
+
readonly warning: "WARNING";
|
|
55
|
+
readonly caution: "CAUTION";
|
|
56
|
+
};
|
|
57
|
+
type CalloutType = keyof typeof CALLOUT_LABEL;
|
|
58
|
+
type Props$8 = {
|
|
59
|
+
key?: Key;
|
|
60
|
+
/**
|
|
61
|
+
* Callout kind. Maps to the uppercase label inside the `> [!TYPE]` marker.
|
|
62
|
+
*/
|
|
63
|
+
type: CalloutType;
|
|
64
|
+
/**
|
|
65
|
+
* Optional title rendered on the same line as the marker.
|
|
66
|
+
*/
|
|
67
|
+
title?: string | null;
|
|
68
|
+
/**
|
|
69
|
+
* Body text. Each line is quoted with `> ` so multi-line content stays
|
|
70
|
+
* inside the callout block.
|
|
71
|
+
*/
|
|
72
|
+
children: string;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Renders a GitHub-style alert callout, portable across GitHub, GitLab,
|
|
76
|
+
* VitePress, Obsidian, and MDX.
|
|
77
|
+
*
|
|
78
|
+
* Emits a `<File.Source>` block containing `> [!TYPE] Title` followed by the
|
|
79
|
+
* body with every line prefixed by `> `.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```tsx
|
|
83
|
+
* <Callout type="tip">Run `kubb start --watch` to keep the generator hot.</Callout>
|
|
84
|
+
* // > [!TIP]
|
|
85
|
+
* // > Run `kubb start --watch` to keep the generator hot.
|
|
86
|
+
*
|
|
87
|
+
* <Callout type="warning" title="Heads up">Breaking change in v6.</Callout>
|
|
88
|
+
* // > [!WARNING] Heads up
|
|
89
|
+
* // > Breaking change in v6.
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function Callout({
|
|
93
|
+
type,
|
|
94
|
+
title,
|
|
95
|
+
children
|
|
96
|
+
}: Props$8): KubbReactElement;
|
|
97
|
+
declare namespace Callout {
|
|
98
|
+
var displayName: string;
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/components/CodeBlock.d.ts
|
|
102
|
+
type Props$7 = {
|
|
103
|
+
key?: Key;
|
|
104
|
+
/**
|
|
105
|
+
* Language tag for syntax highlighting. Rendered after the opening fence.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* `lang: 'typescript'`
|
|
109
|
+
*/
|
|
110
|
+
lang?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Code body. Wrapped in triple-backtick fences as-is.
|
|
113
|
+
*/
|
|
114
|
+
children: string;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Renders a fenced markdown code block.
|
|
118
|
+
*
|
|
119
|
+
* Emits a `<File.Source>` block containing the children wrapped in
|
|
120
|
+
* triple-backtick fences with an optional language tag.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```tsx
|
|
124
|
+
* <CodeBlock lang="typescript">{'const pet = { id: 1 }'}</CodeBlock>
|
|
125
|
+
* // ```typescript
|
|
126
|
+
* // const pet = { id: 1 }
|
|
127
|
+
* // ```
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
declare function CodeBlock({
|
|
131
|
+
lang,
|
|
132
|
+
children
|
|
133
|
+
}: Props$7): KubbReactElement;
|
|
134
|
+
declare namespace CodeBlock {
|
|
135
|
+
var displayName: string;
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
50
138
|
//#region src/components/Const.d.ts
|
|
51
139
|
type ConstProps = {
|
|
52
140
|
key?: Key;
|
|
@@ -63,26 +151,26 @@ type ConstProps = {
|
|
|
63
151
|
* - `false` generates `const name = …`
|
|
64
152
|
* @default false
|
|
65
153
|
*/
|
|
66
|
-
export?: boolean;
|
|
154
|
+
export?: boolean | null;
|
|
67
155
|
/**
|
|
68
156
|
* TypeScript type annotation for the constant, written verbatim after `const name:`.
|
|
69
157
|
*
|
|
70
158
|
* @example
|
|
71
159
|
* `type: 'Pet'` → `const pet: Pet = …`
|
|
72
160
|
*/
|
|
73
|
-
type?: string;
|
|
161
|
+
type?: string | null;
|
|
74
162
|
/**
|
|
75
163
|
* JSDoc block to prepend to the constant declaration.
|
|
76
164
|
* Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
|
|
77
165
|
*/
|
|
78
|
-
JSDoc?: JSDoc;
|
|
166
|
+
JSDoc?: JSDoc | null;
|
|
79
167
|
/**
|
|
80
168
|
* Append `as const` after the initialiser, enabling TypeScript const assertions.
|
|
81
169
|
* - `true` generates `const name = … as const`
|
|
82
170
|
* - `false` generates `const name = …`
|
|
83
171
|
* @default false
|
|
84
172
|
*/
|
|
85
|
-
asConst?: boolean;
|
|
173
|
+
asConst?: boolean | null;
|
|
86
174
|
/**
|
|
87
175
|
* Child nodes rendered as the initialiser expression of the constant.
|
|
88
176
|
*/
|
|
@@ -138,26 +226,28 @@ type BasePropsWithoutBaseName = {
|
|
|
138
226
|
baseName?: never;
|
|
139
227
|
/**
|
|
140
228
|
* Fully qualified path to the generated file.
|
|
141
|
-
* Optional when `baseName` is omitted
|
|
229
|
+
* Optional when `baseName` is omitted, the component renders its children inline.
|
|
142
230
|
*/
|
|
143
|
-
path?: string;
|
|
231
|
+
path?: string | null;
|
|
144
232
|
};
|
|
145
233
|
type BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName;
|
|
146
|
-
type Props$
|
|
234
|
+
type Props$6<TMeta> = BaseProps & {
|
|
147
235
|
key?: Key;
|
|
148
236
|
/**
|
|
149
237
|
* Arbitrary metadata attached to the file node.
|
|
150
238
|
* Used by plugins for barrel generation and custom post-processing.
|
|
151
239
|
*/
|
|
152
|
-
meta?: TMeta;
|
|
240
|
+
meta?: TMeta | null;
|
|
153
241
|
/**
|
|
154
242
|
* Text prepended to the generated file content before any source blocks.
|
|
243
|
+
* Accepts `null` so `resolver.resolveBanner()` results can be passed directly.
|
|
155
244
|
*/
|
|
156
|
-
banner?: string;
|
|
245
|
+
banner?: string | null;
|
|
157
246
|
/**
|
|
158
247
|
* Text appended to the generated file content after all source blocks.
|
|
248
|
+
* Accepts `null` so `resolver.resolveFooter()` results can be passed directly.
|
|
159
249
|
*/
|
|
160
|
-
footer?: string;
|
|
250
|
+
footer?: string | null;
|
|
161
251
|
/**
|
|
162
252
|
* Child nodes rendered as the content of this file (source blocks, imports, exports).
|
|
163
253
|
*/
|
|
@@ -182,7 +272,7 @@ type Props$2<TMeta> = BaseProps & {
|
|
|
182
272
|
declare function File<TMeta extends object = object>({
|
|
183
273
|
children,
|
|
184
274
|
...props
|
|
185
|
-
}: Props$
|
|
275
|
+
}: Props$6<TMeta>): KubbReactElement;
|
|
186
276
|
declare namespace File {
|
|
187
277
|
var displayName: string;
|
|
188
278
|
var Export: typeof FileExport;
|
|
@@ -278,8 +368,44 @@ declare namespace FileImport {
|
|
|
278
368
|
var displayName: string;
|
|
279
369
|
}
|
|
280
370
|
//#endregion
|
|
371
|
+
//#region src/components/Frontmatter.d.ts
|
|
372
|
+
type Props$5 = {
|
|
373
|
+
key?: Key;
|
|
374
|
+
/**
|
|
375
|
+
* Plain object serialised as YAML between `---` fences.
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
* `data: { title: 'Pets', layout: 'doc' }`
|
|
379
|
+
*/
|
|
380
|
+
data: Record<string, unknown>;
|
|
381
|
+
};
|
|
382
|
+
/**
|
|
383
|
+
* Emits a YAML frontmatter envelope at the top of a generated markdown file.
|
|
384
|
+
*
|
|
385
|
+
* Renders a `<File.Source>` block containing `---\n<yaml>\n---`. Place it as
|
|
386
|
+
* the first child of `<File>` so it appears at the top of the output. Pair with
|
|
387
|
+
* `parserMd` to write `.md` files that downstream tooling (VitePress, MDX,
|
|
388
|
+
* static-site generators) treats as frontmatter.
|
|
389
|
+
*
|
|
390
|
+
* @example Page frontmatter at the top of a generated markdown file
|
|
391
|
+
* ```tsx
|
|
392
|
+
* <File baseName="pets.md" path="src/pets.md">
|
|
393
|
+
* <Frontmatter data={{ title: 'Pets', layout: 'doc' }} />
|
|
394
|
+
* <File.Source>
|
|
395
|
+
* {'# Pets\n\nList of pets.'}
|
|
396
|
+
* </File.Source>
|
|
397
|
+
* </File>
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
declare function Frontmatter({
|
|
401
|
+
data
|
|
402
|
+
}: Props$5): KubbReactElement;
|
|
403
|
+
declare namespace Frontmatter {
|
|
404
|
+
var displayName: string;
|
|
405
|
+
}
|
|
406
|
+
//#endregion
|
|
281
407
|
//#region src/components/Function.d.ts
|
|
282
|
-
type Props$
|
|
408
|
+
type Props$4 = {
|
|
283
409
|
key?: Key;
|
|
284
410
|
/**
|
|
285
411
|
* Identifier of the generated function declaration.
|
|
@@ -293,28 +419,28 @@ type Props$1 = {
|
|
|
293
419
|
* Requires `export` to also be `true`.
|
|
294
420
|
* @default false
|
|
295
421
|
*/
|
|
296
|
-
default?: boolean;
|
|
422
|
+
default?: boolean | null;
|
|
297
423
|
/**
|
|
298
424
|
* Parameter list written verbatim between the function's parentheses.
|
|
299
425
|
*
|
|
300
426
|
* @example
|
|
301
427
|
* `params: 'petId: string, options?: RequestOptions'`
|
|
302
428
|
*/
|
|
303
|
-
params?: string;
|
|
429
|
+
params?: string | null;
|
|
304
430
|
/**
|
|
305
431
|
* Emit the `export` keyword before the function declaration.
|
|
306
432
|
* - `true` generates `export function name(…) { … }`
|
|
307
433
|
* - `false` generates `function name(…) { … }`
|
|
308
434
|
* @default false
|
|
309
435
|
*/
|
|
310
|
-
export?: boolean;
|
|
436
|
+
export?: boolean | null;
|
|
311
437
|
/**
|
|
312
438
|
* Emit the `async` keyword, making this an async function.
|
|
313
439
|
* The return type is automatically wrapped in `Promise<returnType>` when both
|
|
314
440
|
* `async` and `returnType` are set.
|
|
315
441
|
* @default false
|
|
316
442
|
*/
|
|
317
|
-
async?: boolean;
|
|
443
|
+
async?: boolean | null;
|
|
318
444
|
/**
|
|
319
445
|
* TypeScript generic type parameters written verbatim between `<` and `>`.
|
|
320
446
|
* Pass an array to emit multiple parameters separated by commas.
|
|
@@ -325,7 +451,7 @@ type Props$1 = {
|
|
|
325
451
|
* @example Multiple generics
|
|
326
452
|
* `generics: ['TData', 'TError = unknown']`
|
|
327
453
|
*/
|
|
328
|
-
generics?: string | string
|
|
454
|
+
generics?: string | Array<string> | null;
|
|
329
455
|
/**
|
|
330
456
|
* TypeScript return type annotation written verbatim after `:`.
|
|
331
457
|
* When `async` is `true`, the value is automatically wrapped in `Promise<…>`.
|
|
@@ -333,12 +459,12 @@ type Props$1 = {
|
|
|
333
459
|
* @example
|
|
334
460
|
* `returnType: 'Pet'`
|
|
335
461
|
*/
|
|
336
|
-
returnType?: string;
|
|
462
|
+
returnType?: string | null;
|
|
337
463
|
/**
|
|
338
464
|
* JSDoc block to prepend to the function declaration.
|
|
339
465
|
* Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
|
|
340
466
|
*/
|
|
341
|
-
JSDoc?: JSDoc;
|
|
467
|
+
JSDoc?: JSDoc | null;
|
|
342
468
|
/**
|
|
343
469
|
* Child nodes rendered as the body of the function.
|
|
344
470
|
*/
|
|
@@ -360,19 +486,19 @@ type Props$1 = {
|
|
|
360
486
|
declare function Function({
|
|
361
487
|
children,
|
|
362
488
|
...props
|
|
363
|
-
}: Props$
|
|
489
|
+
}: Props$4): KubbReactElement;
|
|
364
490
|
declare namespace Function {
|
|
365
491
|
var displayName: string;
|
|
366
492
|
var Arrow: typeof ArrowFunction;
|
|
367
493
|
}
|
|
368
|
-
type ArrowFunctionProps = Props$
|
|
494
|
+
type ArrowFunctionProps = Props$4 & {
|
|
369
495
|
/**
|
|
370
496
|
* Render the arrow function as a single-line expression (no braces around the body).
|
|
371
497
|
* - `true` generates `const name = (…) => expression`
|
|
372
498
|
* - `false` generates `const name = (…) => { … }`
|
|
373
499
|
* @default false
|
|
374
500
|
*/
|
|
375
|
-
singleLine?: boolean;
|
|
501
|
+
singleLine?: boolean | null;
|
|
376
502
|
};
|
|
377
503
|
/**
|
|
378
504
|
* Generates an arrow function expression assigned to a `const`.
|
|
@@ -390,13 +516,47 @@ type ArrowFunctionProps = Props$1 & {
|
|
|
390
516
|
declare function ArrowFunction({
|
|
391
517
|
children,
|
|
392
518
|
...props
|
|
393
|
-
}: ArrowFunctionProps):
|
|
519
|
+
}: ArrowFunctionProps): import("react").JSX.Element;
|
|
394
520
|
declare namespace ArrowFunction {
|
|
395
521
|
var displayName: string;
|
|
396
522
|
}
|
|
397
523
|
//#endregion
|
|
524
|
+
//#region src/components/Heading.d.ts
|
|
525
|
+
type Level = 1 | 2 | 3 | 4 | 5 | 6;
|
|
526
|
+
type Props$3 = {
|
|
527
|
+
key?: Key;
|
|
528
|
+
/**
|
|
529
|
+
* Heading depth, `1` through `6`. Matches the number of `#` characters
|
|
530
|
+
* prefixed to the heading text.
|
|
531
|
+
*/
|
|
532
|
+
level: Level;
|
|
533
|
+
/**
|
|
534
|
+
* Heading text. Inline markdown (links, emphasis) is passed through verbatim.
|
|
535
|
+
*/
|
|
536
|
+
children: string;
|
|
537
|
+
};
|
|
538
|
+
/**
|
|
539
|
+
* Renders an ATX-style markdown heading.
|
|
540
|
+
*
|
|
541
|
+
* Emits a `<File.Source>` block containing `${'#'.repeat(level)} ${children}`.
|
|
542
|
+
* Use inside a `<File>` rendered by `parserMd`.
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```tsx
|
|
546
|
+
* <Heading level={2}>Installation</Heading>
|
|
547
|
+
* // ## Installation
|
|
548
|
+
* ```
|
|
549
|
+
*/
|
|
550
|
+
declare function Heading({
|
|
551
|
+
level,
|
|
552
|
+
children
|
|
553
|
+
}: Props$3): KubbReactElement;
|
|
554
|
+
declare namespace Heading {
|
|
555
|
+
var displayName: string;
|
|
556
|
+
}
|
|
557
|
+
//#endregion
|
|
398
558
|
//#region src/components/Jsx.d.ts
|
|
399
|
-
type Props = {
|
|
559
|
+
type Props$2 = {
|
|
400
560
|
/**
|
|
401
561
|
* Raw JSX string to embed verbatim in the generated code.
|
|
402
562
|
* Supports JSX fragments (`<>…</>`), elements, and any valid JSX syntax.
|
|
@@ -412,7 +572,7 @@ type Props = {
|
|
|
412
572
|
*
|
|
413
573
|
* Use this component when you need to include JSX markup (including fragments
|
|
414
574
|
* `<>…</>`) in the body of a generated function or component. The `children`
|
|
415
|
-
* prop must be a plain string
|
|
575
|
+
* prop must be a plain string, expression attributes that reference runtime
|
|
416
576
|
* values should be written as template literals.
|
|
417
577
|
*
|
|
418
578
|
* @example
|
|
@@ -424,11 +584,79 @@ type Props = {
|
|
|
424
584
|
*/
|
|
425
585
|
declare function Jsx({
|
|
426
586
|
children
|
|
427
|
-
}: Props): KubbReactElement;
|
|
587
|
+
}: Props$2): KubbReactElement;
|
|
428
588
|
declare namespace Jsx {
|
|
429
589
|
var displayName: string;
|
|
430
590
|
}
|
|
431
591
|
//#endregion
|
|
592
|
+
//#region src/components/List.d.ts
|
|
593
|
+
type Props$1 = {
|
|
594
|
+
key?: Key;
|
|
595
|
+
/**
|
|
596
|
+
* When `true`, emits a numbered list (`1. …`). When `false` or omitted,
|
|
597
|
+
* emits a bullet list (`- …`).
|
|
598
|
+
*
|
|
599
|
+
* @default false
|
|
600
|
+
*/
|
|
601
|
+
ordered?: boolean | null;
|
|
602
|
+
/**
|
|
603
|
+
* One entry per line. Inline markdown is passed through verbatim.
|
|
604
|
+
*/
|
|
605
|
+
items: ReadonlyArray<string>;
|
|
606
|
+
};
|
|
607
|
+
/**
|
|
608
|
+
* Renders a markdown list.
|
|
609
|
+
*
|
|
610
|
+
* Emits a `<File.Source>` block containing one entry per line, prefixed with
|
|
611
|
+
* `1.` / `2.` … when `ordered`, or `-` otherwise.
|
|
612
|
+
*
|
|
613
|
+
* @example
|
|
614
|
+
* ```tsx
|
|
615
|
+
* <List items={['Add the parser', 'Render the page']} />
|
|
616
|
+
* // - Add the parser
|
|
617
|
+
* // - Render the page
|
|
618
|
+
*
|
|
619
|
+
* <List ordered items={['First', 'Second']} />
|
|
620
|
+
* // 1. First
|
|
621
|
+
* // 2. Second
|
|
622
|
+
* ```
|
|
623
|
+
*/
|
|
624
|
+
declare function List({
|
|
625
|
+
ordered,
|
|
626
|
+
items
|
|
627
|
+
}: Props$1): KubbReactElement;
|
|
628
|
+
declare namespace List {
|
|
629
|
+
var displayName: string;
|
|
630
|
+
}
|
|
631
|
+
//#endregion
|
|
632
|
+
//#region src/components/Paragraph.d.ts
|
|
633
|
+
type Props = {
|
|
634
|
+
key?: Key;
|
|
635
|
+
/**
|
|
636
|
+
* Paragraph text. Inline markdown (links, emphasis, code spans) is passed
|
|
637
|
+
* through verbatim.
|
|
638
|
+
*/
|
|
639
|
+
children: string;
|
|
640
|
+
};
|
|
641
|
+
/**
|
|
642
|
+
* Renders a markdown paragraph.
|
|
643
|
+
*
|
|
644
|
+
* Emits a `<File.Source>` block containing the text as-is. Paragraphs are
|
|
645
|
+
* separated from surrounding blocks by blank lines via the parser's source
|
|
646
|
+
* joining.
|
|
647
|
+
*
|
|
648
|
+
* @example
|
|
649
|
+
* ```tsx
|
|
650
|
+
* <Paragraph>{'A pet object with `id` and `name` fields.'}</Paragraph>
|
|
651
|
+
* ```
|
|
652
|
+
*/
|
|
653
|
+
declare function Paragraph({
|
|
654
|
+
children
|
|
655
|
+
}: Props): KubbReactElement;
|
|
656
|
+
declare namespace Paragraph {
|
|
657
|
+
var displayName: string;
|
|
658
|
+
}
|
|
659
|
+
//#endregion
|
|
432
660
|
//#region src/components/Root.d.ts
|
|
433
661
|
type RootProps = {
|
|
434
662
|
/**
|
|
@@ -478,12 +706,12 @@ type TypeProps = {
|
|
|
478
706
|
* - `false` generates `type Name = …`
|
|
479
707
|
* @default false
|
|
480
708
|
*/
|
|
481
|
-
export?: boolean;
|
|
709
|
+
export?: boolean | null;
|
|
482
710
|
/**
|
|
483
711
|
* JSDoc block to prepend to the type alias declaration.
|
|
484
712
|
* Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
|
|
485
713
|
*/
|
|
486
|
-
JSDoc?: JSDoc;
|
|
714
|
+
JSDoc?: JSDoc | null;
|
|
487
715
|
/**
|
|
488
716
|
* Child nodes rendered as the type expression on the right-hand side of the alias.
|
|
489
717
|
*/
|
|
@@ -492,7 +720,7 @@ type TypeProps = {
|
|
|
492
720
|
/**
|
|
493
721
|
* Generates a TypeScript type alias declaration.
|
|
494
722
|
*
|
|
495
|
-
* Throws if `name` does not start with an uppercase letter
|
|
723
|
+
* Throws if `name` does not start with an uppercase letter. TypeScript type aliases
|
|
496
724
|
* should follow PascalCase naming conventions.
|
|
497
725
|
*
|
|
498
726
|
* @example Simple exported type alias
|
|
@@ -519,78 +747,86 @@ declare namespace Type {
|
|
|
519
747
|
}
|
|
520
748
|
//#endregion
|
|
521
749
|
//#region src/createRenderer.d.ts
|
|
522
|
-
type Options = {
|
|
523
|
-
/**
|
|
524
|
-
* Print each render result to the console for debugging.
|
|
525
|
-
* Useful when diagnosing output differences between renders.
|
|
526
|
-
* @default false
|
|
527
|
-
*/
|
|
528
|
-
debug?: boolean;
|
|
529
|
-
};
|
|
530
750
|
/**
|
|
531
|
-
*
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
* Render a JSX element tree and collect the resulting {@link FileNode} entries.
|
|
536
|
-
* Resolves once all synchronous render work (including React's flush) is done.
|
|
537
|
-
*/
|
|
538
|
-
render(Element: KubbReactElement): Promise<void>;
|
|
539
|
-
/**
|
|
540
|
-
* Tear down the renderer and release all React resources.
|
|
541
|
-
* Pass an `Error` to signal an abnormal shutdown.
|
|
542
|
-
*/
|
|
543
|
-
unmount(error?: Error | number | null): void;
|
|
544
|
-
/**
|
|
545
|
-
* The {@link FileNode} entries collected from the most recent `render` call.
|
|
546
|
-
*/
|
|
547
|
-
files: Array<FileNode>;
|
|
548
|
-
};
|
|
549
|
-
/**
|
|
550
|
-
* Create a Kubb JSX renderer.
|
|
751
|
+
* Renderer factory that turns the JSX produced by a generator into
|
|
752
|
+
* `FileNode`s using React's reconciler under the hood. Pass as the `renderer`
|
|
753
|
+
* property on `defineGenerator`. Kubb core stays generic, with no hard
|
|
754
|
+
* dependency on `@kubb/renderer-jsx`.
|
|
551
755
|
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
756
|
+
* Use this when generators rely on React features (hooks, suspense, context).
|
|
757
|
+
* For pure-function components, see {@link jsxRendererSync} for ~2-4× faster
|
|
758
|
+
* rendering.
|
|
554
759
|
*
|
|
555
|
-
* @example
|
|
556
|
-
* ```
|
|
557
|
-
* import {
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
*
|
|
760
|
+
* @example Wire up a JSX generator
|
|
761
|
+
* ```tsx
|
|
762
|
+
* import { defineGenerator } from '@kubb/core'
|
|
763
|
+
* import { jsxRenderer } from '@kubb/renderer-jsx'
|
|
764
|
+
*
|
|
765
|
+
* export const myGenerator = defineGenerator<PluginTs>({
|
|
766
|
+
* name: 'types',
|
|
767
|
+
* renderer: jsxRenderer,
|
|
768
|
+
* schema(node, ctx) {
|
|
769
|
+
* return (
|
|
770
|
+
* <File baseName="output.ts" path={`${ctx.root}/output.ts`}>
|
|
771
|
+
* <Type node={node} resolver={ctx.resolver} />
|
|
772
|
+
* </File>
|
|
773
|
+
* )
|
|
774
|
+
* },
|
|
775
|
+
* })
|
|
569
776
|
* ```
|
|
570
777
|
*/
|
|
571
|
-
declare
|
|
778
|
+
declare const jsxRenderer: () => {
|
|
779
|
+
render(element: KubbReactElement): Promise<void>;
|
|
780
|
+
readonly files: FileNode[];
|
|
781
|
+
dispose(): void;
|
|
782
|
+
unmount(error?: Error | number | null): void;
|
|
783
|
+
[Symbol.dispose](): void;
|
|
784
|
+
};
|
|
572
785
|
/**
|
|
573
|
-
*
|
|
786
|
+
* Lightweight renderer that walks the JSX tree in a single recursive pass, * no React reconciler, no scheduler. Drop-in replacement for
|
|
787
|
+
* {@link jsxRenderer} at roughly 2, 4× the throughput.
|
|
574
788
|
*
|
|
575
|
-
*
|
|
576
|
-
*
|
|
577
|
-
* without a hard dependency on `@kubb/renderer-jsx`.
|
|
789
|
+
* Constraints: every component must be a pure function. Hooks, suspense, and
|
|
790
|
+
* class components are not supported.
|
|
578
791
|
*
|
|
579
|
-
*
|
|
580
|
-
*
|
|
581
|
-
*
|
|
792
|
+
* Use this for generators that produce large amounts of output and do not need
|
|
793
|
+
* React's runtime features. It also exposes `stream()` for incremental file
|
|
794
|
+
* emission.
|
|
795
|
+
*
|
|
796
|
+
* @example Drop-in faster renderer
|
|
797
|
+
* ```tsx
|
|
582
798
|
* import { defineGenerator } from '@kubb/core'
|
|
799
|
+
* import { jsxRendererSync } from '@kubb/renderer-jsx'
|
|
583
800
|
*
|
|
584
801
|
* export const myGenerator = defineGenerator<PluginTs>({
|
|
585
|
-
* name: '
|
|
586
|
-
* renderer:
|
|
587
|
-
* schema(node,
|
|
588
|
-
* return
|
|
802
|
+
* name: 'types',
|
|
803
|
+
* renderer: jsxRendererSync,
|
|
804
|
+
* schema(node, ctx) {
|
|
805
|
+
* return (
|
|
806
|
+
* <File baseName="output.ts" path={`${ctx.root}/output.ts`}>
|
|
807
|
+
* <Type node={node} resolver={ctx.resolver} />
|
|
808
|
+
* </File>
|
|
809
|
+
* )
|
|
589
810
|
* },
|
|
590
811
|
* })
|
|
591
812
|
* ```
|
|
813
|
+
*
|
|
814
|
+
* @example Stream files as they are produced
|
|
815
|
+
* ```tsx
|
|
816
|
+
* const renderer = jsxRendererSync()
|
|
817
|
+
* for (const file of renderer.stream(element)) {
|
|
818
|
+
* await writeFile(file.path, file.sources[0])
|
|
819
|
+
* }
|
|
820
|
+
* ```
|
|
592
821
|
*/
|
|
593
|
-
declare const
|
|
822
|
+
declare const jsxRendererSync: () => {
|
|
823
|
+
render(element: KubbReactElement): Promise<void>;
|
|
824
|
+
readonly files: FileNode[];
|
|
825
|
+
stream(element: KubbReactElement): Generator<FileNode>;
|
|
826
|
+
dispose(): void;
|
|
827
|
+
unmount(_error?: Error | number | null): void;
|
|
828
|
+
[Symbol.dispose](): void;
|
|
829
|
+
};
|
|
594
830
|
//#endregion
|
|
595
|
-
export { Const, File, Function, Jsx, Root, Type, createContext,
|
|
831
|
+
export { Callout, CodeBlock, Const, File, Frontmatter, Function, Heading, Jsx, List, Paragraph, Root, Type, createContext, inject, jsxRenderer, jsxRendererSync, provide, unprovide };
|
|
596
832
|
//# sourceMappingURL=index.d.ts.map
|