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