@kubb/renderer-jsx 5.0.0-beta.61 → 5.0.0-beta.63
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/dist/index.cjs +19 -22
- package/dist/index.d.ts +21 -30
- package/dist/index.js +19 -22
- package/dist/jsx-runtime.d.ts +2 -3
- package/package.json +2 -2
- package/src/SyncRuntime.tsx +5 -6
- package/src/components/Callout.tsx +1 -2
- package/src/components/Const.tsx +2 -4
- package/src/components/File.tsx +3 -4
- package/src/components/Frontmatter.tsx +2 -3
- package/src/components/Function.tsx +0 -4
- package/src/components/Jsx.tsx +7 -6
- package/src/components/Type.tsx +0 -1
- package/src/createRenderer.tsx +6 -6
- package/src/jsx-namespace.d.ts +2 -3
package/dist/index.cjs
CHANGED
|
@@ -12,8 +12,7 @@ const CALLOUT_LABEL = {
|
|
|
12
12
|
caution: "CAUTION"
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
|
-
* Renders a GitHub-style alert callout
|
|
16
|
-
* VitePress, Obsidian, and MDX.
|
|
15
|
+
* Renders a GitHub-style alert callout using the `> [!TYPE]` blockquote syntax.
|
|
17
16
|
*
|
|
18
17
|
* Emits a `<File.Source>` block containing `> [!TYPE] Title` followed by the
|
|
19
18
|
* body with every line prefixed by `> `.
|
|
@@ -99,8 +98,8 @@ File.displayName = "File";
|
|
|
99
98
|
/**
|
|
100
99
|
* Marks a block of source text to be associated with the enclosing {@link File}.
|
|
101
100
|
*
|
|
102
|
-
* Children are treated as the source string.
|
|
103
|
-
* `
|
|
101
|
+
* Children are treated as the source string. `isExportable` prepends the `export` keyword,
|
|
102
|
+
* `isIndexable` includes the source in barrel/index generation, and `name` keys deduplication.
|
|
104
103
|
*
|
|
105
104
|
* @example Exportable, indexable source block
|
|
106
105
|
* ```tsx
|
|
@@ -198,8 +197,7 @@ File.Source = FileSource;
|
|
|
198
197
|
*
|
|
199
198
|
* Renders a `<File.Source>` block containing `---\n<yaml>\n---`. Place it as
|
|
200
199
|
* the first child of `<File>` so it appears at the top of the output. Pair with
|
|
201
|
-
* `parserMd` to write `.md` files
|
|
202
|
-
* static-site generators) treats as frontmatter.
|
|
200
|
+
* `parserMd` to write `.md` files whose frontmatter downstream tooling can read.
|
|
203
201
|
*
|
|
204
202
|
* @example Page frontmatter at the top of a generated markdown file
|
|
205
203
|
* ```tsx
|
|
@@ -304,10 +302,10 @@ Heading.displayName = "Heading";
|
|
|
304
302
|
/**
|
|
305
303
|
* Embeds a raw JSX string verbatim in the generated source code.
|
|
306
304
|
*
|
|
307
|
-
* Use this component
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
*
|
|
305
|
+
* Use this component to include JSX markup (including fragments `<>…</>`) in the
|
|
306
|
+
* body of a generated function or component. The `children` prop must be a plain
|
|
307
|
+
* string. Write expression attributes that reference runtime values as template
|
|
308
|
+
* literals.
|
|
311
309
|
*
|
|
312
310
|
* @example
|
|
313
311
|
* ```tsx
|
|
@@ -404,10 +402,10 @@ Type.displayName = "Type";
|
|
|
404
402
|
//#endregion
|
|
405
403
|
//#region src/SyncRuntime.tsx
|
|
406
404
|
/**
|
|
407
|
-
* Walks `element`, resolving arrays, Fragments, and function components
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
405
|
+
* Walks `element`, resolving arrays, Fragments, and function components, then
|
|
406
|
+
* calls `onText` for primitive values and `onHost` for each host element.
|
|
407
|
+
* Function components are called synchronously. Hooks and class components are
|
|
408
|
+
* not supported.
|
|
411
409
|
*/
|
|
412
410
|
function walkElement(element, onText, onHost) {
|
|
413
411
|
if (element == null || typeof element === "boolean") return;
|
|
@@ -597,8 +595,7 @@ function* walkFiles(element) {
|
|
|
597
595
|
* DOM. No React fiber, scheduler, or work loop is involved.
|
|
598
596
|
*
|
|
599
597
|
* All components must be pure functions. Hooks and class components are not
|
|
600
|
-
* supported.
|
|
601
|
-
* approximately 2, 4× the speed and a fraction of the allocations.
|
|
598
|
+
* supported.
|
|
602
599
|
*/
|
|
603
600
|
var SyncRuntime = class {
|
|
604
601
|
/**
|
|
@@ -632,14 +629,14 @@ var SyncRuntime = class {
|
|
|
632
629
|
//#endregion
|
|
633
630
|
//#region src/createRenderer.tsx
|
|
634
631
|
/**
|
|
635
|
-
*
|
|
636
|
-
* reconciler or scheduler. Pass as the `renderer` property on
|
|
637
|
-
* `defineGenerator`. Kubb core
|
|
638
|
-
* `@kubb/renderer-jsx`.
|
|
632
|
+
* Factory for a renderer that walks the JSX tree in a single recursive pass,
|
|
633
|
+
* with no React reconciler or scheduler. Pass it as the `renderer` property on
|
|
634
|
+
* `defineGenerator`. Kubb core calls the factory once per render cycle and stays
|
|
635
|
+
* generic, with no hard dependency on `@kubb/renderer-jsx`.
|
|
639
636
|
*
|
|
640
637
|
* Every component must be a pure function. Hooks, suspense, and class
|
|
641
|
-
* components are not supported.
|
|
642
|
-
* file emission.
|
|
638
|
+
* components are not supported. The returned renderer also exposes `stream()`
|
|
639
|
+
* for incremental file emission.
|
|
643
640
|
*
|
|
644
641
|
* @example Wire up a JSX generator
|
|
645
642
|
* ```tsx
|
package/dist/index.d.ts
CHANGED
|
@@ -28,8 +28,7 @@ type Props$7 = {
|
|
|
28
28
|
children: string;
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
|
-
* Renders a GitHub-style alert callout
|
|
32
|
-
* VitePress, Obsidian, and MDX.
|
|
31
|
+
* Renders a GitHub-style alert callout using the `> [!TYPE]` blockquote syntax.
|
|
33
32
|
*
|
|
34
33
|
* Emits a `<File.Source>` block containing `> [!TYPE] Title` followed by the
|
|
35
34
|
* body with every line prefixed by `> `.
|
|
@@ -68,7 +67,6 @@ type ConstProps = {
|
|
|
68
67
|
* Emit the `export` keyword before the `const` declaration.
|
|
69
68
|
* - `true` generates `export const name = …`
|
|
70
69
|
* - `false` generates `const name = …`
|
|
71
|
-
* @default false
|
|
72
70
|
*/
|
|
73
71
|
export?: boolean | null;
|
|
74
72
|
/**
|
|
@@ -84,14 +82,13 @@ type ConstProps = {
|
|
|
84
82
|
*/
|
|
85
83
|
JSDoc?: JSDoc | null;
|
|
86
84
|
/**
|
|
87
|
-
* Append `as const` after the
|
|
85
|
+
* Append `as const` after the initializer, enabling TypeScript const assertions.
|
|
88
86
|
* - `true` generates `const name = … as const`
|
|
89
87
|
* - `false` generates `const name = …`
|
|
90
|
-
* @default false
|
|
91
88
|
*/
|
|
92
89
|
asConst?: boolean | null;
|
|
93
90
|
/**
|
|
94
|
-
* Child nodes rendered as the
|
|
91
|
+
* Child nodes rendered as the initializer expression of the constant.
|
|
95
92
|
*/
|
|
96
93
|
children?: KubbReactNode;
|
|
97
94
|
};
|
|
@@ -153,8 +150,7 @@ type BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName;
|
|
|
153
150
|
type Props$6<TMeta> = BaseProps & {
|
|
154
151
|
key?: Key;
|
|
155
152
|
/**
|
|
156
|
-
* Arbitrary metadata attached to the file node.
|
|
157
|
-
* Used by plugins for barrel generation and custom post-processing.
|
|
153
|
+
* Arbitrary metadata attached to the file node for plugins to read.
|
|
158
154
|
*/
|
|
159
155
|
meta?: TMeta | null;
|
|
160
156
|
/**
|
|
@@ -208,8 +204,8 @@ type FileSourceProps = Omit<SourceNode, 'kind' | 'value'> & {
|
|
|
208
204
|
/**
|
|
209
205
|
* Marks a block of source text to be associated with the enclosing {@link File}.
|
|
210
206
|
*
|
|
211
|
-
* Children are treated as the source string.
|
|
212
|
-
* `
|
|
207
|
+
* Children are treated as the source string. `isExportable` prepends the `export` keyword,
|
|
208
|
+
* `isIndexable` includes the source in barrel/index generation, and `name` keys deduplication.
|
|
213
209
|
*
|
|
214
210
|
* @example Exportable, indexable source block
|
|
215
211
|
* ```tsx
|
|
@@ -294,7 +290,7 @@ type Props$5 = {
|
|
|
294
290
|
* Plain object serialized as YAML between `---` fences.
|
|
295
291
|
*
|
|
296
292
|
* @example
|
|
297
|
-
* `
|
|
293
|
+
* `{ title: 'Pets', layout: 'doc' }`
|
|
298
294
|
*/
|
|
299
295
|
data: Record<string, unknown>;
|
|
300
296
|
};
|
|
@@ -303,8 +299,7 @@ type Props$5 = {
|
|
|
303
299
|
*
|
|
304
300
|
* Renders a `<File.Source>` block containing `---\n<yaml>\n---`. Place it as
|
|
305
301
|
* the first child of `<File>` so it appears at the top of the output. Pair with
|
|
306
|
-
* `parserMd` to write `.md` files
|
|
307
|
-
* static-site generators) treats as frontmatter.
|
|
302
|
+
* `parserMd` to write `.md` files whose frontmatter downstream tooling can read.
|
|
308
303
|
*
|
|
309
304
|
* @example Page frontmatter at the top of a generated markdown file
|
|
310
305
|
* ```tsx
|
|
@@ -336,7 +331,6 @@ type Props$4 = {
|
|
|
336
331
|
/**
|
|
337
332
|
* Emit `default` after the `export` keyword, making this the module's default export.
|
|
338
333
|
* Requires `export` to also be `true`.
|
|
339
|
-
* @default false
|
|
340
334
|
*/
|
|
341
335
|
default?: boolean | null;
|
|
342
336
|
/**
|
|
@@ -350,14 +344,12 @@ type Props$4 = {
|
|
|
350
344
|
* Emit the `export` keyword before the function declaration.
|
|
351
345
|
* - `true` generates `export function name(…) { … }`
|
|
352
346
|
* - `false` generates `function name(…) { … }`
|
|
353
|
-
* @default false
|
|
354
347
|
*/
|
|
355
348
|
export?: boolean | null;
|
|
356
349
|
/**
|
|
357
350
|
* Emit the `async` keyword, making this an async function.
|
|
358
351
|
* The return type is automatically wrapped in `Promise<returnType>` when both
|
|
359
352
|
* `async` and `returnType` are set.
|
|
360
|
-
* @default false
|
|
361
353
|
*/
|
|
362
354
|
async?: boolean | null;
|
|
363
355
|
/**
|
|
@@ -415,7 +407,6 @@ type ArrowFunctionProps = Props$4 & {
|
|
|
415
407
|
* Render the arrow function as a single-line expression (no braces around the body).
|
|
416
408
|
* - `true` generates `const name = (…) => expression`
|
|
417
409
|
* - `false` generates `const name = (…) => { … }`
|
|
418
|
-
* @default false
|
|
419
410
|
*/
|
|
420
411
|
singleLine?: boolean | null;
|
|
421
412
|
};
|
|
@@ -477,8 +468,9 @@ declare namespace Heading {
|
|
|
477
468
|
//#region src/components/Jsx.d.ts
|
|
478
469
|
type Props$2 = {
|
|
479
470
|
/**
|
|
480
|
-
* Raw JSX string
|
|
481
|
-
*
|
|
471
|
+
* Raw JSX string embedded verbatim in the generated code, including
|
|
472
|
+
* fragments (`<>…</>`).
|
|
473
|
+
*
|
|
482
474
|
* @example
|
|
483
475
|
* ```tsx
|
|
484
476
|
* <Jsx>{'<>\n <a href={href}>Open</a>\n</>'}</Jsx>
|
|
@@ -489,10 +481,10 @@ type Props$2 = {
|
|
|
489
481
|
/**
|
|
490
482
|
* Embeds a raw JSX string verbatim in the generated source code.
|
|
491
483
|
*
|
|
492
|
-
* Use this component
|
|
493
|
-
*
|
|
494
|
-
*
|
|
495
|
-
*
|
|
484
|
+
* Use this component to include JSX markup (including fragments `<>…</>`) in the
|
|
485
|
+
* body of a generated function or component. The `children` prop must be a plain
|
|
486
|
+
* string. Write expression attributes that reference runtime values as template
|
|
487
|
+
* literals.
|
|
496
488
|
*
|
|
497
489
|
* @example
|
|
498
490
|
* ```tsx
|
|
@@ -591,7 +583,6 @@ type TypeProps = {
|
|
|
591
583
|
* Emit the `export` keyword before the type alias declaration.
|
|
592
584
|
* - `true` generates `export type Name = …`
|
|
593
585
|
* - `false` generates `type Name = …`
|
|
594
|
-
* @default false
|
|
595
586
|
*/
|
|
596
587
|
export?: boolean | null;
|
|
597
588
|
/**
|
|
@@ -635,14 +626,14 @@ declare namespace Type {
|
|
|
635
626
|
//#endregion
|
|
636
627
|
//#region src/createRenderer.d.ts
|
|
637
628
|
/**
|
|
638
|
-
*
|
|
639
|
-
* reconciler or scheduler. Pass as the `renderer` property on
|
|
640
|
-
* `defineGenerator`. Kubb core
|
|
641
|
-
* `@kubb/renderer-jsx`.
|
|
629
|
+
* Factory for a renderer that walks the JSX tree in a single recursive pass,
|
|
630
|
+
* with no React reconciler or scheduler. Pass it as the `renderer` property on
|
|
631
|
+
* `defineGenerator`. Kubb core calls the factory once per render cycle and stays
|
|
632
|
+
* generic, with no hard dependency on `@kubb/renderer-jsx`.
|
|
642
633
|
*
|
|
643
634
|
* Every component must be a pure function. Hooks, suspense, and class
|
|
644
|
-
* components are not supported.
|
|
645
|
-
* file emission.
|
|
635
|
+
* components are not supported. The returned renderer also exposes `stream()`
|
|
636
|
+
* for incremental file emission.
|
|
646
637
|
*
|
|
647
638
|
* @example Wire up a JSX generator
|
|
648
639
|
* ```tsx
|
package/dist/index.js
CHANGED
|
@@ -11,8 +11,7 @@ const CALLOUT_LABEL = {
|
|
|
11
11
|
caution: "CAUTION"
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
|
-
* Renders a GitHub-style alert callout
|
|
15
|
-
* VitePress, Obsidian, and MDX.
|
|
14
|
+
* Renders a GitHub-style alert callout using the `> [!TYPE]` blockquote syntax.
|
|
16
15
|
*
|
|
17
16
|
* Emits a `<File.Source>` block containing `> [!TYPE] Title` followed by the
|
|
18
17
|
* body with every line prefixed by `> `.
|
|
@@ -98,8 +97,8 @@ File.displayName = "File";
|
|
|
98
97
|
/**
|
|
99
98
|
* Marks a block of source text to be associated with the enclosing {@link File}.
|
|
100
99
|
*
|
|
101
|
-
* Children are treated as the source string.
|
|
102
|
-
* `
|
|
100
|
+
* Children are treated as the source string. `isExportable` prepends the `export` keyword,
|
|
101
|
+
* `isIndexable` includes the source in barrel/index generation, and `name` keys deduplication.
|
|
103
102
|
*
|
|
104
103
|
* @example Exportable, indexable source block
|
|
105
104
|
* ```tsx
|
|
@@ -197,8 +196,7 @@ File.Source = FileSource;
|
|
|
197
196
|
*
|
|
198
197
|
* Renders a `<File.Source>` block containing `---\n<yaml>\n---`. Place it as
|
|
199
198
|
* the first child of `<File>` so it appears at the top of the output. Pair with
|
|
200
|
-
* `parserMd` to write `.md` files
|
|
201
|
-
* static-site generators) treats as frontmatter.
|
|
199
|
+
* `parserMd` to write `.md` files whose frontmatter downstream tooling can read.
|
|
202
200
|
*
|
|
203
201
|
* @example Page frontmatter at the top of a generated markdown file
|
|
204
202
|
* ```tsx
|
|
@@ -303,10 +301,10 @@ Heading.displayName = "Heading";
|
|
|
303
301
|
/**
|
|
304
302
|
* Embeds a raw JSX string verbatim in the generated source code.
|
|
305
303
|
*
|
|
306
|
-
* Use this component
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
304
|
+
* Use this component to include JSX markup (including fragments `<>…</>`) in the
|
|
305
|
+
* body of a generated function or component. The `children` prop must be a plain
|
|
306
|
+
* string. Write expression attributes that reference runtime values as template
|
|
307
|
+
* literals.
|
|
310
308
|
*
|
|
311
309
|
* @example
|
|
312
310
|
* ```tsx
|
|
@@ -403,10 +401,10 @@ Type.displayName = "Type";
|
|
|
403
401
|
//#endregion
|
|
404
402
|
//#region src/SyncRuntime.tsx
|
|
405
403
|
/**
|
|
406
|
-
* Walks `element`, resolving arrays, Fragments, and function components
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
*
|
|
404
|
+
* Walks `element`, resolving arrays, Fragments, and function components, then
|
|
405
|
+
* calls `onText` for primitive values and `onHost` for each host element.
|
|
406
|
+
* Function components are called synchronously. Hooks and class components are
|
|
407
|
+
* not supported.
|
|
410
408
|
*/
|
|
411
409
|
function walkElement(element, onText, onHost) {
|
|
412
410
|
if (element == null || typeof element === "boolean") return;
|
|
@@ -596,8 +594,7 @@ function* walkFiles(element) {
|
|
|
596
594
|
* DOM. No React fiber, scheduler, or work loop is involved.
|
|
597
595
|
*
|
|
598
596
|
* All components must be pure functions. Hooks and class components are not
|
|
599
|
-
* supported.
|
|
600
|
-
* approximately 2, 4× the speed and a fraction of the allocations.
|
|
597
|
+
* supported.
|
|
601
598
|
*/
|
|
602
599
|
var SyncRuntime = class {
|
|
603
600
|
/**
|
|
@@ -631,14 +628,14 @@ var SyncRuntime = class {
|
|
|
631
628
|
//#endregion
|
|
632
629
|
//#region src/createRenderer.tsx
|
|
633
630
|
/**
|
|
634
|
-
*
|
|
635
|
-
* reconciler or scheduler. Pass as the `renderer` property on
|
|
636
|
-
* `defineGenerator`. Kubb core
|
|
637
|
-
* `@kubb/renderer-jsx`.
|
|
631
|
+
* Factory for a renderer that walks the JSX tree in a single recursive pass,
|
|
632
|
+
* with no React reconciler or scheduler. Pass it as the `renderer` property on
|
|
633
|
+
* `defineGenerator`. Kubb core calls the factory once per render cycle and stays
|
|
634
|
+
* generic, with no hard dependency on `@kubb/renderer-jsx`.
|
|
638
635
|
*
|
|
639
636
|
* Every component must be a pure function. Hooks, suspense, and class
|
|
640
|
-
* components are not supported.
|
|
641
|
-
* file emission.
|
|
637
|
+
* components are not supported. The returned renderer also exposes `stream()`
|
|
638
|
+
* for incremental file emission.
|
|
642
639
|
*
|
|
643
640
|
* @example Wire up a JSX generator
|
|
644
641
|
* ```tsx
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -6,9 +6,8 @@ import { a as KubbExportProps, c as KubbImportProps, d as KubbReactNode, f as Ku
|
|
|
6
6
|
* JSX contract for `@kubb/renderer-jsx`, resolved through `jsxImportSource`.
|
|
7
7
|
*
|
|
8
8
|
* It is self-contained and does not extend `React.JSX`. The renderer only emits
|
|
9
|
-
* the custom `kubb-*` hosts plus `br`,
|
|
10
|
-
*
|
|
11
|
-
* from `@types/react` is not needed.
|
|
9
|
+
* the custom `kubb-*` hosts plus `br`, and supports pure function components, so
|
|
10
|
+
* the HTML element and class-component machinery from `@types/react` is not needed.
|
|
12
11
|
*/
|
|
13
12
|
declare namespace JSX {
|
|
14
13
|
type ElementType = string | ((props: any) => KubbReactNode);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/renderer-jsx",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.63",
|
|
4
4
|
"description": "Self-contained synchronous JSX renderer for Kubb. Turns JSX into FileNodes with built-in components (File, Function, Type, Const) for component-based, type-safe code generation. No React dependency.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codegen",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"yaml": "^2.9.0",
|
|
78
|
-
"@kubb/ast": "5.0.0-beta.
|
|
78
|
+
"@kubb/ast": "5.0.0-beta.63"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@internals/utils": "0.0.0"
|
package/src/SyncRuntime.tsx
CHANGED
|
@@ -8,10 +8,10 @@ type OnText = (text: string) => void
|
|
|
8
8
|
type OnHost = (type: string, props: Record<string, unknown>) => void
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Walks `element`, resolving arrays, Fragments, and function components
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* Walks `element`, resolving arrays, Fragments, and function components, then
|
|
12
|
+
* calls `onText` for primitive values and `onHost` for each host element.
|
|
13
|
+
* Function components are called synchronously. Hooks and class components are
|
|
14
|
+
* not supported.
|
|
15
15
|
*/
|
|
16
16
|
function walkElement(element: unknown, onText: OnText, onHost: OnHost): void {
|
|
17
17
|
if (element == null || typeof element === 'boolean') return
|
|
@@ -260,8 +260,7 @@ function* walkFiles(element: unknown): Generator<FileNode> {
|
|
|
260
260
|
* DOM. No React fiber, scheduler, or work loop is involved.
|
|
261
261
|
*
|
|
262
262
|
* All components must be pure functions. Hooks and class components are not
|
|
263
|
-
* supported.
|
|
264
|
-
* approximately 2, 4× the speed and a fraction of the allocations.
|
|
263
|
+
* supported.
|
|
265
264
|
*/
|
|
266
265
|
export class SyncRuntime {
|
|
267
266
|
/**
|
|
@@ -28,8 +28,7 @@ type Props = {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Renders a GitHub-style alert callout
|
|
32
|
-
* VitePress, Obsidian, and MDX.
|
|
31
|
+
* Renders a GitHub-style alert callout using the `> [!TYPE]` blockquote syntax.
|
|
33
32
|
*
|
|
34
33
|
* Emits a `<File.Source>` block containing `> [!TYPE] Title` followed by the
|
|
35
34
|
* body with every line prefixed by `> `.
|
package/src/components/Const.tsx
CHANGED
|
@@ -13,7 +13,6 @@ type ConstProps = {
|
|
|
13
13
|
* Emit the `export` keyword before the `const` declaration.
|
|
14
14
|
* - `true` generates `export const name = …`
|
|
15
15
|
* - `false` generates `const name = …`
|
|
16
|
-
* @default false
|
|
17
16
|
*/
|
|
18
17
|
export?: boolean | null
|
|
19
18
|
/**
|
|
@@ -29,14 +28,13 @@ type ConstProps = {
|
|
|
29
28
|
*/
|
|
30
29
|
JSDoc?: JSDoc | null
|
|
31
30
|
/**
|
|
32
|
-
* Append `as const` after the
|
|
31
|
+
* Append `as const` after the initializer, enabling TypeScript const assertions.
|
|
33
32
|
* - `true` generates `const name = … as const`
|
|
34
33
|
* - `false` generates `const name = …`
|
|
35
|
-
* @default false
|
|
36
34
|
*/
|
|
37
35
|
asConst?: boolean | null
|
|
38
36
|
/**
|
|
39
|
-
* Child nodes rendered as the
|
|
37
|
+
* Child nodes rendered as the initializer expression of the constant.
|
|
40
38
|
*/
|
|
41
39
|
children?: KubbReactNode
|
|
42
40
|
}
|
package/src/components/File.tsx
CHANGED
|
@@ -35,8 +35,7 @@ type BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName
|
|
|
35
35
|
type Props<TMeta> = BaseProps & {
|
|
36
36
|
key?: Key
|
|
37
37
|
/**
|
|
38
|
-
* Arbitrary metadata attached to the file node.
|
|
39
|
-
* Used by plugins for barrel generation and custom post-processing.
|
|
38
|
+
* Arbitrary metadata attached to the file node for plugins to read.
|
|
40
39
|
*/
|
|
41
40
|
meta?: TMeta | null
|
|
42
41
|
/**
|
|
@@ -94,8 +93,8 @@ type FileSourceProps = Omit<SourceNode, 'kind' | 'value'> & {
|
|
|
94
93
|
/**
|
|
95
94
|
* Marks a block of source text to be associated with the enclosing {@link File}.
|
|
96
95
|
*
|
|
97
|
-
* Children are treated as the source string.
|
|
98
|
-
* `
|
|
96
|
+
* Children are treated as the source string. `isExportable` prepends the `export` keyword,
|
|
97
|
+
* `isIndexable` includes the source in barrel/index generation, and `name` keys deduplication.
|
|
99
98
|
*
|
|
100
99
|
* @example Exportable, indexable source block
|
|
101
100
|
* ```tsx
|
|
@@ -7,7 +7,7 @@ type Props = {
|
|
|
7
7
|
* Plain object serialized as YAML between `---` fences.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
|
-
* `
|
|
10
|
+
* `{ title: 'Pets', layout: 'doc' }`
|
|
11
11
|
*/
|
|
12
12
|
data: Record<string, unknown>
|
|
13
13
|
}
|
|
@@ -17,8 +17,7 @@ type Props = {
|
|
|
17
17
|
*
|
|
18
18
|
* Renders a `<File.Source>` block containing `---\n<yaml>\n---`. Place it as
|
|
19
19
|
* the first child of `<File>` so it appears at the top of the output. Pair with
|
|
20
|
-
* `parserMd` to write `.md` files
|
|
21
|
-
* static-site generators) treats as frontmatter.
|
|
20
|
+
* `parserMd` to write `.md` files whose frontmatter downstream tooling can read.
|
|
22
21
|
*
|
|
23
22
|
* @example Page frontmatter at the top of a generated markdown file
|
|
24
23
|
* ```tsx
|
|
@@ -12,7 +12,6 @@ type Props = {
|
|
|
12
12
|
/**
|
|
13
13
|
* Emit `default` after the `export` keyword, making this the module's default export.
|
|
14
14
|
* Requires `export` to also be `true`.
|
|
15
|
-
* @default false
|
|
16
15
|
*/
|
|
17
16
|
default?: boolean | null
|
|
18
17
|
/**
|
|
@@ -26,14 +25,12 @@ type Props = {
|
|
|
26
25
|
* Emit the `export` keyword before the function declaration.
|
|
27
26
|
* - `true` generates `export function name(…) { … }`
|
|
28
27
|
* - `false` generates `function name(…) { … }`
|
|
29
|
-
* @default false
|
|
30
28
|
*/
|
|
31
29
|
export?: boolean | null
|
|
32
30
|
/**
|
|
33
31
|
* Emit the `async` keyword, making this an async function.
|
|
34
32
|
* The return type is automatically wrapped in `Promise<returnType>` when both
|
|
35
33
|
* `async` and `returnType` are set.
|
|
36
|
-
* @default false
|
|
37
34
|
*/
|
|
38
35
|
async?: boolean | null
|
|
39
36
|
/**
|
|
@@ -108,7 +105,6 @@ type ArrowFunctionProps = Props & {
|
|
|
108
105
|
* Render the arrow function as a single-line expression (no braces around the body).
|
|
109
106
|
* - `true` generates `const name = (…) => expression`
|
|
110
107
|
* - `false` generates `const name = (…) => { … }`
|
|
111
|
-
* @default false
|
|
112
108
|
*/
|
|
113
109
|
singleLine?: boolean | null
|
|
114
110
|
}
|
package/src/components/Jsx.tsx
CHANGED
|
@@ -2,8 +2,9 @@ import type { KubbReactElement } from '../types.ts'
|
|
|
2
2
|
|
|
3
3
|
type Props = {
|
|
4
4
|
/**
|
|
5
|
-
* Raw JSX string
|
|
6
|
-
*
|
|
5
|
+
* Raw JSX string embedded verbatim in the generated code, including
|
|
6
|
+
* fragments (`<>…</>`).
|
|
7
|
+
*
|
|
7
8
|
* @example
|
|
8
9
|
* ```tsx
|
|
9
10
|
* <Jsx>{'<>\n <a href={href}>Open</a>\n</>'}</Jsx>
|
|
@@ -15,10 +16,10 @@ type Props = {
|
|
|
15
16
|
/**
|
|
16
17
|
* Embeds a raw JSX string verbatim in the generated source code.
|
|
17
18
|
*
|
|
18
|
-
* Use this component
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* Use this component to include JSX markup (including fragments `<>…</>`) in the
|
|
20
|
+
* body of a generated function or component. The `children` prop must be a plain
|
|
21
|
+
* string. Write expression attributes that reference runtime values as template
|
|
22
|
+
* literals.
|
|
22
23
|
*
|
|
23
24
|
* @example
|
|
24
25
|
* ```tsx
|
package/src/components/Type.tsx
CHANGED
package/src/createRenderer.tsx
CHANGED
|
@@ -3,14 +3,14 @@ import { SyncRuntime } from './SyncRuntime.tsx'
|
|
|
3
3
|
import type { KubbReactElement } from './types.ts'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* reconciler or scheduler. Pass as the `renderer` property on
|
|
8
|
-
* `defineGenerator`. Kubb core
|
|
9
|
-
* `@kubb/renderer-jsx`.
|
|
6
|
+
* Factory for a renderer that walks the JSX tree in a single recursive pass,
|
|
7
|
+
* with no React reconciler or scheduler. Pass it as the `renderer` property on
|
|
8
|
+
* `defineGenerator`. Kubb core calls the factory once per render cycle and stays
|
|
9
|
+
* generic, with no hard dependency on `@kubb/renderer-jsx`.
|
|
10
10
|
*
|
|
11
11
|
* Every component must be a pure function. Hooks, suspense, and class
|
|
12
|
-
* components are not supported.
|
|
13
|
-
* file emission.
|
|
12
|
+
* components are not supported. The returned renderer also exposes `stream()`
|
|
13
|
+
* for incremental file emission.
|
|
14
14
|
*
|
|
15
15
|
* @example Wire up a JSX generator
|
|
16
16
|
* ```tsx
|
package/src/jsx-namespace.d.ts
CHANGED
|
@@ -18,9 +18,8 @@ import type {
|
|
|
18
18
|
* JSX contract for `@kubb/renderer-jsx`, resolved through `jsxImportSource`.
|
|
19
19
|
*
|
|
20
20
|
* It is self-contained and does not extend `React.JSX`. The renderer only emits
|
|
21
|
-
* the custom `kubb-*` hosts plus `br`,
|
|
22
|
-
*
|
|
23
|
-
* from `@types/react` is not needed.
|
|
21
|
+
* the custom `kubb-*` hosts plus `br`, and supports pure function components, so
|
|
22
|
+
* the HTML element and class-component machinery from `@types/react` is not needed.
|
|
24
23
|
*/
|
|
25
24
|
export namespace JSX {
|
|
26
25
|
type ElementType = string | ((props: any) => KubbReactNode)
|