@kubb/renderer-jsx 5.0.0-beta.7 → 5.0.0-beta.71
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/LICENSE +17 -10
- package/README.md +37 -27
- package/dist/index.cjs +388 -17919
- package/dist/index.d.ts +248 -165
- package/dist/index.js +373 -17901
- package/dist/jsx-dev-runtime.cjs +3 -10
- package/dist/jsx-dev-runtime.d.ts +4 -8
- package/dist/jsx-dev-runtime.js +1 -9
- package/dist/jsx-runtime.cjs +24 -6
- package/dist/jsx-runtime.d.ts +59 -10
- package/dist/jsx-runtime.js +24 -7
- package/dist/rolldown-runtime-C0LytTxp.js +8 -0
- package/dist/rolldown-runtime-ClG-MNz_.cjs +13 -0
- package/dist/types-OZ23urxc.d.ts +119 -0
- package/dist/types.d.ts +2 -2
- package/package.json +8 -31
- package/dist/chunk-Bb7HlUDG.js +0 -28
- package/dist/jsx-namespace-CNp0arTN.d.ts +0 -39
- package/dist/jsx-runtime-Cvu_ZYgL.js +0 -1448
- package/dist/jsx-runtime-DdmO3p0U.cjs +0 -1503
- package/dist/types-nAFMiWFw.d.ts +0 -168
- package/src/Renderer.ts +0 -182
- package/src/Runtime.tsx +0 -159
- package/src/components/Const.tsx +0 -72
- package/src/components/File.tsx +0 -186
- package/src/components/Function.tsx +0 -152
- package/src/components/Jsx.tsx +0 -34
- package/src/components/Root.tsx +0 -70
- package/src/components/Type.tsx +0 -66
- package/src/constants.ts +0 -28
- package/src/createRenderer.tsx +0 -93
- package/src/dom.ts +0 -105
- package/src/globals.ts +0 -34
- package/src/index.ts +0 -8
- package/src/jsx-dev-runtime.ts +0 -10
- package/src/jsx-namespace.d.ts +0 -52
- package/src/jsx-runtime.ts +0 -12
- package/src/types.ts +0 -207
- package/src/utils.ts +0 -267
package/dist/index.d.ts
CHANGED
|
@@ -1,51 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { d as KubbReactNode, n as Key, t as JSDoc, u as KubbReactElement } from "./types-OZ23urxc.js";
|
|
3
3
|
import { ExportNode, FileNode, ImportNode, SourceNode } from "@kubb/ast";
|
|
4
|
-
import * as _$react from "react";
|
|
5
4
|
|
|
6
|
-
//#region
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
readonly
|
|
5
|
+
//#region src/components/Callout.d.ts
|
|
6
|
+
declare const CALLOUT_LABEL: {
|
|
7
|
+
readonly tip: "TIP";
|
|
8
|
+
readonly note: "NOTE";
|
|
9
|
+
readonly important: "IMPORTANT";
|
|
10
|
+
readonly warning: "WARNING";
|
|
11
|
+
readonly caution: "CAUTION";
|
|
12
|
+
};
|
|
13
|
+
type CalloutType = keyof typeof CALLOUT_LABEL;
|
|
14
|
+
type Props$7 = {
|
|
15
|
+
key?: Key;
|
|
16
|
+
/**
|
|
17
|
+
* Callout kind. Maps to the uppercase label inside the `> [!TYPE]` marker.
|
|
18
|
+
*/
|
|
19
|
+
type: CalloutType;
|
|
20
|
+
/**
|
|
21
|
+
* Optional title rendered on the same line as the marker.
|
|
22
|
+
*/
|
|
23
|
+
title?: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Body text. Each line is quoted with `> ` so multi-line content stays
|
|
26
|
+
* inside the callout block.
|
|
27
|
+
*/
|
|
28
|
+
children: string;
|
|
13
29
|
};
|
|
14
30
|
/**
|
|
15
|
-
*
|
|
31
|
+
* Renders a GitHub-style alert callout using the `> [!TYPE]` blockquote syntax.
|
|
16
32
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* const ThemeKey = Symbol('theme')
|
|
20
|
-
* provide(ThemeKey, { color: 'blue' })
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
declare function provide<T>(key: symbol | Context<T>, value: T): void;
|
|
24
|
-
/**
|
|
25
|
-
* Injects a value provided by an ancestor component (Vue 3 style)
|
|
33
|
+
* Emits a `<File.Source>` block containing `> [!TYPE] Title` followed by the
|
|
34
|
+
* body with every line prefixed by `> `.
|
|
26
35
|
*
|
|
27
36
|
* @example
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
declare function inject<T>(key: symbol | Context<T>, defaultValue?: T): T;
|
|
33
|
-
/**
|
|
34
|
-
* Removes a provided value from the context stack (for cleanup)
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
declare function unprovide<T>(key: symbol | Context<T>): void;
|
|
38
|
-
/**
|
|
39
|
-
* Creates a context key with a default value (React-style compatibility)
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <Callout type="tip">Run `kubb start --watch` to keep the generator hot.</Callout>
|
|
39
|
+
* // > [!TIP]
|
|
40
|
+
* // > Run `kubb start --watch` to keep the generator hot.
|
|
40
41
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* // ThemeContext is now typed as Context<{ color: string }>
|
|
45
|
-
* const theme = useContext(ThemeContext) // theme is { color: string }
|
|
42
|
+
* <Callout type="warning" title="Heads up">Breaking change in v6.</Callout>
|
|
43
|
+
* // > [!WARNING] Heads up
|
|
44
|
+
* // > Breaking change in v6.
|
|
46
45
|
* ```
|
|
47
46
|
*/
|
|
48
|
-
declare function
|
|
47
|
+
declare function Callout({
|
|
48
|
+
type,
|
|
49
|
+
title,
|
|
50
|
+
children
|
|
51
|
+
}: Props$7): KubbReactElement;
|
|
52
|
+
declare namespace Callout {
|
|
53
|
+
var displayName: string;
|
|
54
|
+
}
|
|
49
55
|
//#endregion
|
|
50
56
|
//#region src/components/Const.d.ts
|
|
51
57
|
type ConstProps = {
|
|
@@ -61,30 +67,28 @@ type ConstProps = {
|
|
|
61
67
|
* Emit the `export` keyword before the `const` declaration.
|
|
62
68
|
* - `true` generates `export const name = …`
|
|
63
69
|
* - `false` generates `const name = …`
|
|
64
|
-
* @default false
|
|
65
70
|
*/
|
|
66
|
-
export?: boolean;
|
|
71
|
+
export?: boolean | null;
|
|
67
72
|
/**
|
|
68
73
|
* TypeScript type annotation for the constant, written verbatim after `const name:`.
|
|
69
74
|
*
|
|
70
75
|
* @example
|
|
71
76
|
* `type: 'Pet'` → `const pet: Pet = …`
|
|
72
77
|
*/
|
|
73
|
-
type?: string;
|
|
78
|
+
type?: string | null;
|
|
74
79
|
/**
|
|
75
80
|
* JSDoc block to prepend to the constant declaration.
|
|
76
81
|
* Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
|
|
77
82
|
*/
|
|
78
|
-
JSDoc?: JSDoc;
|
|
83
|
+
JSDoc?: JSDoc | null;
|
|
79
84
|
/**
|
|
80
|
-
* Append `as const` after the
|
|
85
|
+
* Append `as const` after the initializer, enabling TypeScript const assertions.
|
|
81
86
|
* - `true` generates `const name = … as const`
|
|
82
87
|
* - `false` generates `const name = …`
|
|
83
|
-
* @default false
|
|
84
88
|
*/
|
|
85
|
-
asConst?: boolean;
|
|
89
|
+
asConst?: boolean | null;
|
|
86
90
|
/**
|
|
87
|
-
* Child nodes rendered as the
|
|
91
|
+
* Child nodes rendered as the initializer expression of the constant.
|
|
88
92
|
*/
|
|
89
93
|
children?: KubbReactNode;
|
|
90
94
|
};
|
|
@@ -138,26 +142,34 @@ type BasePropsWithoutBaseName = {
|
|
|
138
142
|
baseName?: never;
|
|
139
143
|
/**
|
|
140
144
|
* Fully qualified path to the generated file.
|
|
141
|
-
* Optional when `baseName` is omitted
|
|
145
|
+
* Optional when `baseName` is omitted, the component renders its children inline.
|
|
142
146
|
*/
|
|
143
|
-
path?: string;
|
|
147
|
+
path?: string | null;
|
|
144
148
|
};
|
|
145
149
|
type BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName;
|
|
146
|
-
type Props$
|
|
150
|
+
type Props$6<TMeta> = BaseProps & {
|
|
147
151
|
key?: Key;
|
|
148
152
|
/**
|
|
149
|
-
* Arbitrary metadata attached to the file node.
|
|
150
|
-
* Used by plugins for barrel generation and custom post-processing.
|
|
153
|
+
* Arbitrary metadata attached to the file node for plugins to read.
|
|
151
154
|
*/
|
|
152
|
-
meta?: TMeta;
|
|
155
|
+
meta?: TMeta | null;
|
|
153
156
|
/**
|
|
154
157
|
* Text prepended to the generated file content before any source blocks.
|
|
158
|
+
* Accepts `null` so `resolver.resolveBanner()` results can be passed directly.
|
|
155
159
|
*/
|
|
156
|
-
banner?: string;
|
|
160
|
+
banner?: string | null;
|
|
157
161
|
/**
|
|
158
162
|
* Text appended to the generated file content after all source blocks.
|
|
163
|
+
* Accepts `null` so `resolver.resolveFooter()` results can be passed directly.
|
|
164
|
+
*/
|
|
165
|
+
footer?: string | null;
|
|
166
|
+
/**
|
|
167
|
+
* Absolute on-disk path to copy verbatim into the output, bypassing the parser. Use to emit a
|
|
168
|
+
* real source file shipped inside a package (a template) into the generated folder. Only
|
|
169
|
+
* `banner`/`footer` are applied around the copied content; child source blocks are ignored for
|
|
170
|
+
* output but still drive barrel generation.
|
|
159
171
|
*/
|
|
160
|
-
|
|
172
|
+
copy?: string | null;
|
|
161
173
|
/**
|
|
162
174
|
* Child nodes rendered as the content of this file (source blocks, imports, exports).
|
|
163
175
|
*/
|
|
@@ -182,7 +194,7 @@ type Props$2<TMeta> = BaseProps & {
|
|
|
182
194
|
declare function File<TMeta extends object = object>({
|
|
183
195
|
children,
|
|
184
196
|
...props
|
|
185
|
-
}: Props$
|
|
197
|
+
}: Props$6<TMeta>): KubbReactElement;
|
|
186
198
|
declare namespace File {
|
|
187
199
|
var displayName: string;
|
|
188
200
|
var Export: typeof FileExport;
|
|
@@ -199,8 +211,8 @@ type FileSourceProps = Omit<SourceNode, 'kind' | 'value'> & {
|
|
|
199
211
|
/**
|
|
200
212
|
* Marks a block of source text to be associated with the enclosing {@link File}.
|
|
201
213
|
*
|
|
202
|
-
* Children are treated as the source string.
|
|
203
|
-
* `
|
|
214
|
+
* Children are treated as the source string. `isExportable` prepends the `export` keyword,
|
|
215
|
+
* `isIndexable` includes the source in barrel/index generation, and `name` keys deduplication.
|
|
204
216
|
*
|
|
205
217
|
* @example Exportable, indexable source block
|
|
206
218
|
* ```tsx
|
|
@@ -278,8 +290,43 @@ declare namespace FileImport {
|
|
|
278
290
|
var displayName: string;
|
|
279
291
|
}
|
|
280
292
|
//#endregion
|
|
293
|
+
//#region src/components/Frontmatter.d.ts
|
|
294
|
+
type Props$5 = {
|
|
295
|
+
key?: Key;
|
|
296
|
+
/**
|
|
297
|
+
* Plain object serialized as YAML between `---` fences.
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* `{ title: 'Pets', layout: 'doc' }`
|
|
301
|
+
*/
|
|
302
|
+
data: Record<string, unknown>;
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* Emits a YAML frontmatter envelope at the top of a generated markdown file.
|
|
306
|
+
*
|
|
307
|
+
* Renders a `<File.Source>` block containing `---\n<yaml>\n---`. Place it as
|
|
308
|
+
* the first child of `<File>` so it appears at the top of the output. Pair with
|
|
309
|
+
* `parserMd` to write `.md` files whose frontmatter downstream tooling can read.
|
|
310
|
+
*
|
|
311
|
+
* @example Page frontmatter at the top of a generated markdown file
|
|
312
|
+
* ```tsx
|
|
313
|
+
* <File baseName="pets.md" path="src/pets.md">
|
|
314
|
+
* <Frontmatter data={{ title: 'Pets', layout: 'doc' }} />
|
|
315
|
+
* <File.Source>
|
|
316
|
+
* {'# Pets\n\nList of pets.'}
|
|
317
|
+
* </File.Source>
|
|
318
|
+
* </File>
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
declare function Frontmatter({
|
|
322
|
+
data
|
|
323
|
+
}: Props$5): KubbReactElement;
|
|
324
|
+
declare namespace Frontmatter {
|
|
325
|
+
var displayName: string;
|
|
326
|
+
}
|
|
327
|
+
//#endregion
|
|
281
328
|
//#region src/components/Function.d.ts
|
|
282
|
-
type Props$
|
|
329
|
+
type Props$4 = {
|
|
283
330
|
key?: Key;
|
|
284
331
|
/**
|
|
285
332
|
* Identifier of the generated function declaration.
|
|
@@ -291,30 +338,27 @@ type Props$1 = {
|
|
|
291
338
|
/**
|
|
292
339
|
* Emit `default` after the `export` keyword, making this the module's default export.
|
|
293
340
|
* Requires `export` to also be `true`.
|
|
294
|
-
* @default false
|
|
295
341
|
*/
|
|
296
|
-
default?: boolean;
|
|
342
|
+
default?: boolean | null;
|
|
297
343
|
/**
|
|
298
344
|
* Parameter list written verbatim between the function's parentheses.
|
|
299
345
|
*
|
|
300
346
|
* @example
|
|
301
347
|
* `params: 'petId: string, options?: RequestOptions'`
|
|
302
348
|
*/
|
|
303
|
-
params?: string;
|
|
349
|
+
params?: string | null;
|
|
304
350
|
/**
|
|
305
351
|
* Emit the `export` keyword before the function declaration.
|
|
306
352
|
* - `true` generates `export function name(…) { … }`
|
|
307
353
|
* - `false` generates `function name(…) { … }`
|
|
308
|
-
* @default false
|
|
309
354
|
*/
|
|
310
|
-
export?: boolean;
|
|
355
|
+
export?: boolean | null;
|
|
311
356
|
/**
|
|
312
357
|
* Emit the `async` keyword, making this an async function.
|
|
313
358
|
* The return type is automatically wrapped in `Promise<returnType>` when both
|
|
314
359
|
* `async` and `returnType` are set.
|
|
315
|
-
* @default false
|
|
316
360
|
*/
|
|
317
|
-
async?: boolean;
|
|
361
|
+
async?: boolean | null;
|
|
318
362
|
/**
|
|
319
363
|
* TypeScript generic type parameters written verbatim between `<` and `>`.
|
|
320
364
|
* Pass an array to emit multiple parameters separated by commas.
|
|
@@ -325,7 +369,7 @@ type Props$1 = {
|
|
|
325
369
|
* @example Multiple generics
|
|
326
370
|
* `generics: ['TData', 'TError = unknown']`
|
|
327
371
|
*/
|
|
328
|
-
generics?: string | string
|
|
372
|
+
generics?: string | Array<string> | null;
|
|
329
373
|
/**
|
|
330
374
|
* TypeScript return type annotation written verbatim after `:`.
|
|
331
375
|
* When `async` is `true`, the value is automatically wrapped in `Promise<…>`.
|
|
@@ -333,12 +377,12 @@ type Props$1 = {
|
|
|
333
377
|
* @example
|
|
334
378
|
* `returnType: 'Pet'`
|
|
335
379
|
*/
|
|
336
|
-
returnType?: string;
|
|
380
|
+
returnType?: string | null;
|
|
337
381
|
/**
|
|
338
382
|
* JSDoc block to prepend to the function declaration.
|
|
339
383
|
* Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
|
|
340
384
|
*/
|
|
341
|
-
JSDoc?: JSDoc;
|
|
385
|
+
JSDoc?: JSDoc | null;
|
|
342
386
|
/**
|
|
343
387
|
* Child nodes rendered as the body of the function.
|
|
344
388
|
*/
|
|
@@ -360,19 +404,18 @@ type Props$1 = {
|
|
|
360
404
|
declare function Function({
|
|
361
405
|
children,
|
|
362
406
|
...props
|
|
363
|
-
}: Props$
|
|
407
|
+
}: Props$4): KubbReactElement;
|
|
364
408
|
declare namespace Function {
|
|
365
409
|
var displayName: string;
|
|
366
410
|
var Arrow: typeof ArrowFunction;
|
|
367
411
|
}
|
|
368
|
-
type ArrowFunctionProps = Props$
|
|
412
|
+
type ArrowFunctionProps = Props$4 & {
|
|
369
413
|
/**
|
|
370
414
|
* Render the arrow function as a single-line expression (no braces around the body).
|
|
371
415
|
* - `true` generates `const name = (…) => expression`
|
|
372
416
|
* - `false` generates `const name = (…) => { … }`
|
|
373
|
-
* @default false
|
|
374
417
|
*/
|
|
375
|
-
singleLine?: boolean;
|
|
418
|
+
singleLine?: boolean | null;
|
|
376
419
|
};
|
|
377
420
|
/**
|
|
378
421
|
* Generates an arrow function expression assigned to a `const`.
|
|
@@ -390,16 +433,51 @@ type ArrowFunctionProps = Props$1 & {
|
|
|
390
433
|
declare function ArrowFunction({
|
|
391
434
|
children,
|
|
392
435
|
...props
|
|
393
|
-
}: ArrowFunctionProps):
|
|
436
|
+
}: ArrowFunctionProps): any;
|
|
394
437
|
declare namespace ArrowFunction {
|
|
395
438
|
var displayName: string;
|
|
396
439
|
}
|
|
397
440
|
//#endregion
|
|
441
|
+
//#region src/components/Heading.d.ts
|
|
442
|
+
type Level = 1 | 2 | 3 | 4 | 5 | 6;
|
|
443
|
+
type Props$3 = {
|
|
444
|
+
key?: Key;
|
|
445
|
+
/**
|
|
446
|
+
* Heading depth, `1` through `6`. Matches the number of `#` characters
|
|
447
|
+
* prefixed to the heading text.
|
|
448
|
+
*/
|
|
449
|
+
level: Level;
|
|
450
|
+
/**
|
|
451
|
+
* Heading text. Inline markdown (links, emphasis) is passed through verbatim.
|
|
452
|
+
*/
|
|
453
|
+
children: string;
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* Renders an ATX-style markdown heading.
|
|
457
|
+
*
|
|
458
|
+
* Emits a `<File.Source>` block containing `${'#'.repeat(level)} ${children}`.
|
|
459
|
+
* Use inside a `<File>` rendered by `parserMd`.
|
|
460
|
+
*
|
|
461
|
+
* @example
|
|
462
|
+
* ```tsx
|
|
463
|
+
* <Heading level={2}>Installation</Heading>
|
|
464
|
+
* // ## Installation
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
declare function Heading({
|
|
468
|
+
level,
|
|
469
|
+
children
|
|
470
|
+
}: Props$3): KubbReactElement;
|
|
471
|
+
declare namespace Heading {
|
|
472
|
+
var displayName: string;
|
|
473
|
+
}
|
|
474
|
+
//#endregion
|
|
398
475
|
//#region src/components/Jsx.d.ts
|
|
399
|
-
type Props = {
|
|
476
|
+
type Props$2 = {
|
|
400
477
|
/**
|
|
401
|
-
* Raw JSX string
|
|
402
|
-
*
|
|
478
|
+
* Raw JSX string embedded verbatim in the generated code, including
|
|
479
|
+
* fragments (`<>…</>`).
|
|
480
|
+
*
|
|
403
481
|
* @example
|
|
404
482
|
* ```tsx
|
|
405
483
|
* <Jsx>{'<>\n <a href={href}>Open</a>\n</>'}</Jsx>
|
|
@@ -410,10 +488,10 @@ type Props = {
|
|
|
410
488
|
/**
|
|
411
489
|
* Embeds a raw JSX string verbatim in the generated source code.
|
|
412
490
|
*
|
|
413
|
-
* Use this component
|
|
414
|
-
*
|
|
415
|
-
*
|
|
416
|
-
*
|
|
491
|
+
* Use this component to include JSX markup (including fragments `<>…</>`) in the
|
|
492
|
+
* body of a generated function or component. The `children` prop must be a plain
|
|
493
|
+
* string. Write expression attributes that reference runtime values as template
|
|
494
|
+
* literals.
|
|
417
495
|
*
|
|
418
496
|
* @example
|
|
419
497
|
* ```tsx
|
|
@@ -424,40 +502,76 @@ type Props = {
|
|
|
424
502
|
*/
|
|
425
503
|
declare function Jsx({
|
|
426
504
|
children
|
|
427
|
-
}: Props): KubbReactElement;
|
|
505
|
+
}: Props$2): KubbReactElement;
|
|
428
506
|
declare namespace Jsx {
|
|
429
507
|
var displayName: string;
|
|
430
508
|
}
|
|
431
509
|
//#endregion
|
|
432
|
-
//#region src/components/
|
|
433
|
-
type
|
|
510
|
+
//#region src/components/List.d.ts
|
|
511
|
+
type Props$1 = {
|
|
512
|
+
key?: Key;
|
|
434
513
|
/**
|
|
435
|
-
*
|
|
436
|
-
*
|
|
437
|
-
*
|
|
514
|
+
* When `true`, emits a numbered list (`1. …`). When `false` or omitted,
|
|
515
|
+
* emits a bullet list (`- …`).
|
|
516
|
+
*
|
|
517
|
+
* @default false
|
|
438
518
|
*/
|
|
439
|
-
|
|
519
|
+
ordered?: boolean | null;
|
|
440
520
|
/**
|
|
441
|
-
*
|
|
442
|
-
* Use this to propagate errors up to the caller of {@link createRenderer}.
|
|
521
|
+
* One entry per line. Inline markdown is passed through verbatim.
|
|
443
522
|
*/
|
|
444
|
-
|
|
523
|
+
items: ReadonlyArray<string>;
|
|
524
|
+
};
|
|
525
|
+
/**
|
|
526
|
+
* Renders a markdown list.
|
|
527
|
+
*
|
|
528
|
+
* Emits a `<File.Source>` block containing one entry per line, prefixed with
|
|
529
|
+
* `1.` / `2.` … when `ordered`, or `-` otherwise.
|
|
530
|
+
*
|
|
531
|
+
* @example
|
|
532
|
+
* ```tsx
|
|
533
|
+
* <List items={['Add the parser', 'Render the page']} />
|
|
534
|
+
* // - Add the parser
|
|
535
|
+
* // - Render the page
|
|
536
|
+
*
|
|
537
|
+
* <List ordered items={['First', 'Second']} />
|
|
538
|
+
* // 1. First
|
|
539
|
+
* // 2. Second
|
|
540
|
+
* ```
|
|
541
|
+
*/
|
|
542
|
+
declare function List({
|
|
543
|
+
ordered,
|
|
544
|
+
items
|
|
545
|
+
}: Props$1): KubbReactElement;
|
|
546
|
+
declare namespace List {
|
|
547
|
+
var displayName: string;
|
|
548
|
+
}
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region src/components/Paragraph.d.ts
|
|
551
|
+
type Props = {
|
|
552
|
+
key?: Key;
|
|
445
553
|
/**
|
|
446
|
-
*
|
|
554
|
+
* Paragraph text. Inline markdown (links, emphasis, code spans) is passed
|
|
555
|
+
* through verbatim.
|
|
447
556
|
*/
|
|
448
|
-
children
|
|
557
|
+
children: string;
|
|
449
558
|
};
|
|
450
559
|
/**
|
|
451
|
-
*
|
|
560
|
+
* Renders a markdown paragraph.
|
|
452
561
|
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
562
|
+
* Emits a `<File.Source>` block containing the text as-is. Paragraphs are
|
|
563
|
+
* separated from surrounding blocks by blank lines via the parser's source
|
|
564
|
+
* joining.
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* ```tsx
|
|
568
|
+
* <Paragraph>{'A pet object with `id` and `name` fields.'}</Paragraph>
|
|
569
|
+
* ```
|
|
455
570
|
*/
|
|
456
|
-
declare function
|
|
457
|
-
onError,
|
|
571
|
+
declare function Paragraph({
|
|
458
572
|
children
|
|
459
|
-
}:
|
|
460
|
-
declare namespace
|
|
573
|
+
}: Props): KubbReactElement;
|
|
574
|
+
declare namespace Paragraph {
|
|
461
575
|
var displayName: string;
|
|
462
576
|
}
|
|
463
577
|
//#endregion
|
|
@@ -476,14 +590,13 @@ type TypeProps = {
|
|
|
476
590
|
* Emit the `export` keyword before the type alias declaration.
|
|
477
591
|
* - `true` generates `export type Name = …`
|
|
478
592
|
* - `false` generates `type Name = …`
|
|
479
|
-
* @default false
|
|
480
593
|
*/
|
|
481
|
-
export?: boolean;
|
|
594
|
+
export?: boolean | null;
|
|
482
595
|
/**
|
|
483
596
|
* JSDoc block to prepend to the type alias declaration.
|
|
484
597
|
* Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
|
|
485
598
|
*/
|
|
486
|
-
JSDoc?: JSDoc;
|
|
599
|
+
JSDoc?: JSDoc | null;
|
|
487
600
|
/**
|
|
488
601
|
* Child nodes rendered as the type expression on the right-hand side of the alias.
|
|
489
602
|
*/
|
|
@@ -492,7 +605,7 @@ type TypeProps = {
|
|
|
492
605
|
/**
|
|
493
606
|
* Generates a TypeScript type alias declaration.
|
|
494
607
|
*
|
|
495
|
-
* Throws if `name` does not start with an uppercase letter
|
|
608
|
+
* Throws if `name` does not start with an uppercase letter. TypeScript type aliases
|
|
496
609
|
* should follow PascalCase naming conventions.
|
|
497
610
|
*
|
|
498
611
|
* @example Simple exported type alias
|
|
@@ -519,78 +632,48 @@ declare namespace Type {
|
|
|
519
632
|
}
|
|
520
633
|
//#endregion
|
|
521
634
|
//#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
|
-
/**
|
|
531
|
-
* The renderer instance returned by {@link createRenderer}.
|
|
532
|
-
*/
|
|
533
|
-
type Renderer = {
|
|
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
635
|
/**
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
* @example Basic usage
|
|
556
|
-
* ```ts
|
|
557
|
-
* import { createRenderer, File } from '@kubb/renderer-jsx'
|
|
558
|
-
*
|
|
559
|
-
* const renderer = createRenderer()
|
|
560
|
-
* await renderer.render(
|
|
561
|
-
* <File baseName="pet.ts" path="src/models/pet.ts">
|
|
562
|
-
* <File.Source name="Pet" isExportable isIndexable>
|
|
563
|
-
* {`export type Pet = { id: number; name: string }`}
|
|
564
|
-
* </File.Source>
|
|
565
|
-
* </File>
|
|
566
|
-
* )
|
|
567
|
-
* console.log(renderer.files) // [FileNode]
|
|
568
|
-
* renderer.unmount()
|
|
569
|
-
* ```
|
|
570
|
-
*/
|
|
571
|
-
declare function createRenderer(options?: Options): Renderer;
|
|
572
|
-
/**
|
|
573
|
-
* A renderer factory for generators that produce JSX output.
|
|
636
|
+
* Factory for a renderer that walks the JSX tree in a single recursive pass,
|
|
637
|
+
* with no React reconciler or scheduler. Pass it as the `renderer` property on
|
|
638
|
+
* `defineGenerator`. Kubb core calls the factory once per render cycle and stays
|
|
639
|
+
* generic, with no hard dependency on `@kubb/renderer-jsx`.
|
|
574
640
|
*
|
|
575
|
-
*
|
|
576
|
-
*
|
|
577
|
-
*
|
|
641
|
+
* Every component must be a pure function. Hooks, suspense, and class
|
|
642
|
+
* components are not supported. The returned renderer also exposes `stream()`
|
|
643
|
+
* for incremental file emission.
|
|
578
644
|
*
|
|
579
|
-
* @example
|
|
580
|
-
* ```
|
|
581
|
-
* import { jsxRenderer } from '@kubb/renderer-jsx'
|
|
645
|
+
* @example Wire up a JSX generator
|
|
646
|
+
* ```tsx
|
|
582
647
|
* import { defineGenerator } from '@kubb/core'
|
|
648
|
+
* import { jsxRenderer } from '@kubb/renderer-jsx'
|
|
583
649
|
*
|
|
584
650
|
* export const myGenerator = defineGenerator<PluginTs>({
|
|
585
|
-
* name: '
|
|
651
|
+
* name: 'types',
|
|
586
652
|
* renderer: jsxRenderer,
|
|
587
|
-
* schema(node,
|
|
588
|
-
* return
|
|
653
|
+
* schema(node, ctx) {
|
|
654
|
+
* return (
|
|
655
|
+
* <File baseName="output.ts" path={`${ctx.root}/output.ts`}>
|
|
656
|
+
* <Type node={node} resolver={ctx.resolver} />
|
|
657
|
+
* </File>
|
|
658
|
+
* )
|
|
589
659
|
* },
|
|
590
660
|
* })
|
|
591
661
|
* ```
|
|
662
|
+
*
|
|
663
|
+
* @example Stream files as they are produced
|
|
664
|
+
* ```tsx
|
|
665
|
+
* const renderer = jsxRenderer()
|
|
666
|
+
* for (const file of renderer.stream(element)) {
|
|
667
|
+
* await writeFile(file.path, file.sources[0])
|
|
668
|
+
* }
|
|
669
|
+
* ```
|
|
592
670
|
*/
|
|
593
|
-
declare const jsxRenderer: () =>
|
|
671
|
+
declare const jsxRenderer: () => {
|
|
672
|
+
render(element: KubbReactElement): Promise<void>;
|
|
673
|
+
readonly files: FileNode[];
|
|
674
|
+
stream(element: KubbReactElement): Generator<FileNode>;
|
|
675
|
+
[Symbol.dispose](): void;
|
|
676
|
+
};
|
|
594
677
|
//#endregion
|
|
595
|
-
export { Const, File,
|
|
678
|
+
export { Callout, Const, File, Frontmatter, Function, Heading, Jsx, List, Paragraph, Type, jsxRenderer };
|
|
596
679
|
//# sourceMappingURL=index.d.ts.map
|