@kubb/renderer-jsx 5.0.0-beta.11 → 5.0.0-beta.110
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 +38 -27
- package/dist/index.cjs +367 -17898
- package/dist/index.d.ts +734 -149
- package/dist/index.js +351 -17880
- package/dist/jsx-dev-runtime.cjs +3 -10
- package/dist/jsx-dev-runtime.d.ts +2 -14
- package/dist/jsx-dev-runtime.js +1 -9
- package/dist/jsx-runtime.cjs +24 -6
- package/dist/jsx-runtime.d.ts +83 -13
- 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-seYG0czS.d.ts +44 -0
- package/dist/types.d.ts +2 -2
- package/package.json +7 -36
- 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 -180
- 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 -38
- package/src/dom.ts +0 -103
- 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,54 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
type
|
|
13
|
-
|
|
1
|
+
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { i as KubbReactNode, n as Key, r as KubbReactElement, t as JSDoc } from "./types-seYG0czS.js";
|
|
3
|
+
import { ast } from "@kubb/kit";
|
|
4
|
+
//#region src/components/md/Callout.d.ts
|
|
5
|
+
declare const CALLOUT_LABEL: {
|
|
6
|
+
readonly tip: "TIP";
|
|
7
|
+
readonly note: "NOTE";
|
|
8
|
+
readonly important: "IMPORTANT";
|
|
9
|
+
readonly warning: "WARNING";
|
|
10
|
+
readonly caution: "CAUTION";
|
|
11
|
+
};
|
|
12
|
+
type CalloutType = keyof typeof CALLOUT_LABEL;
|
|
13
|
+
type Props$7 = {
|
|
14
|
+
key?: Key;
|
|
15
|
+
/**
|
|
16
|
+
* Callout kind. Maps to the uppercase label inside the `> [!TYPE]` marker.
|
|
17
|
+
*/
|
|
18
|
+
type: CalloutType;
|
|
19
|
+
/**
|
|
20
|
+
* Optional title rendered on the same line as the marker.
|
|
21
|
+
*/
|
|
22
|
+
title?: string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Body text. Each line is quoted with `> ` so multi-line content stays
|
|
25
|
+
* inside the callout block.
|
|
26
|
+
*/
|
|
27
|
+
children: string;
|
|
14
28
|
};
|
|
15
29
|
/**
|
|
16
|
-
*
|
|
30
|
+
* Renders a GitHub-style alert callout using the `> [!TYPE]` blockquote syntax.
|
|
17
31
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* const ThemeKey = Symbol('theme')
|
|
21
|
-
* provide(ThemeKey, { color: 'blue' })
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
declare function provide<T>(key: symbol | Context<T>, value: T): void;
|
|
25
|
-
/**
|
|
26
|
-
* Injects a value provided by an ancestor component (Vue 3 style)
|
|
32
|
+
* Emits a `<File.Source>` block containing `> [!TYPE] Title` followed by the
|
|
33
|
+
* body with every line prefixed by `> `.
|
|
27
34
|
*
|
|
28
35
|
* @example
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
declare function inject<T>(key: symbol | Context<T>, defaultValue?: T): T;
|
|
34
|
-
/**
|
|
35
|
-
* Removes a provided value from the context stack (for cleanup)
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
|
-
declare function unprovide<T>(key: symbol | Context<T>): void;
|
|
39
|
-
/**
|
|
40
|
-
* Creates a context key with a default value (React-style compatibility)
|
|
36
|
+
* ```tsx
|
|
37
|
+
* <Callout type="tip">Run `kubb start --watch` to keep the generator hot.</Callout>
|
|
38
|
+
* // > [!TIP]
|
|
39
|
+
* // > Run `kubb start --watch` to keep the generator hot.
|
|
41
40
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* // ThemeContext is now typed as Context<{ color: string }>
|
|
46
|
-
* const theme = useContext(ThemeContext) // theme is { color: string }
|
|
41
|
+
* <Callout type="warning" title="Heads up">Breaking change in v6.</Callout>
|
|
42
|
+
* // > [!WARNING] Heads up
|
|
43
|
+
* // > Breaking change in v6.
|
|
47
44
|
* ```
|
|
48
45
|
*/
|
|
49
|
-
declare function
|
|
46
|
+
declare function Callout({ type, title, children }: Props$7): KubbReactElement;
|
|
47
|
+
declare namespace Callout {
|
|
48
|
+
var displayName: string;
|
|
49
|
+
}
|
|
50
50
|
//#endregion
|
|
51
|
-
//#region src/components/Const.d.ts
|
|
51
|
+
//#region src/components/js/Const.d.ts
|
|
52
52
|
type ConstProps = {
|
|
53
53
|
key?: Key;
|
|
54
54
|
/**
|
|
@@ -62,30 +62,28 @@ type ConstProps = {
|
|
|
62
62
|
* Emit the `export` keyword before the `const` declaration.
|
|
63
63
|
* - `true` generates `export const name = …`
|
|
64
64
|
* - `false` generates `const name = …`
|
|
65
|
-
* @default false
|
|
66
65
|
*/
|
|
67
|
-
export?: boolean;
|
|
66
|
+
export?: boolean | null;
|
|
68
67
|
/**
|
|
69
68
|
* TypeScript type annotation for the constant, written verbatim after `const name:`.
|
|
70
69
|
*
|
|
71
70
|
* @example
|
|
72
71
|
* `type: 'Pet'` → `const pet: Pet = …`
|
|
73
72
|
*/
|
|
74
|
-
type?: string;
|
|
73
|
+
type?: string | null;
|
|
75
74
|
/**
|
|
76
75
|
* JSDoc block to prepend to the constant declaration.
|
|
77
76
|
* Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
|
|
78
77
|
*/
|
|
79
|
-
JSDoc?: JSDoc;
|
|
78
|
+
JSDoc?: JSDoc | null;
|
|
80
79
|
/**
|
|
81
|
-
* Append `as const` after the
|
|
80
|
+
* Append `as const` after the initializer, enabling TypeScript const assertions.
|
|
82
81
|
* - `true` generates `const name = … as const`
|
|
83
82
|
* - `false` generates `const name = …`
|
|
84
|
-
* @default false
|
|
85
83
|
*/
|
|
86
|
-
asConst?: boolean;
|
|
84
|
+
asConst?: boolean | null;
|
|
87
85
|
/**
|
|
88
|
-
* Child nodes rendered as the
|
|
86
|
+
* Child nodes rendered as the initializer expression of the constant.
|
|
89
87
|
*/
|
|
90
88
|
children?: KubbReactNode;
|
|
91
89
|
};
|
|
@@ -107,10 +105,7 @@ type ConstProps = {
|
|
|
107
105
|
* </Const>
|
|
108
106
|
* ```
|
|
109
107
|
*/
|
|
110
|
-
declare function Const({
|
|
111
|
-
children,
|
|
112
|
-
...props
|
|
113
|
-
}: ConstProps): KubbReactElement;
|
|
108
|
+
declare function Const({ children, ...props }: ConstProps): KubbReactElement;
|
|
114
109
|
declare namespace Const {
|
|
115
110
|
var displayName: string;
|
|
116
111
|
}
|
|
@@ -139,26 +134,34 @@ type BasePropsWithoutBaseName = {
|
|
|
139
134
|
baseName?: never;
|
|
140
135
|
/**
|
|
141
136
|
* Fully qualified path to the generated file.
|
|
142
|
-
* Optional when `baseName` is omitted
|
|
137
|
+
* Optional when `baseName` is omitted, the component renders its children inline.
|
|
143
138
|
*/
|
|
144
|
-
path?: string;
|
|
139
|
+
path?: string | null;
|
|
145
140
|
};
|
|
146
141
|
type BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName;
|
|
147
|
-
type Props$
|
|
142
|
+
type Props$6<TMeta> = BaseProps & {
|
|
148
143
|
key?: Key;
|
|
149
144
|
/**
|
|
150
|
-
* Arbitrary metadata attached to the file node.
|
|
151
|
-
* Used by plugins for barrel generation and custom post-processing.
|
|
145
|
+
* Arbitrary metadata attached to the file node for plugins to read.
|
|
152
146
|
*/
|
|
153
|
-
meta?: TMeta;
|
|
147
|
+
meta?: TMeta | null;
|
|
154
148
|
/**
|
|
155
149
|
* Text prepended to the generated file content before any source blocks.
|
|
150
|
+
* Accepts `null` so `resolver.default.banner()` results can be passed directly.
|
|
156
151
|
*/
|
|
157
|
-
banner?: string;
|
|
152
|
+
banner?: string | null;
|
|
158
153
|
/**
|
|
159
154
|
* Text appended to the generated file content after all source blocks.
|
|
155
|
+
* Accepts `null` so `resolver.default.footer()` results can be passed directly.
|
|
156
|
+
*/
|
|
157
|
+
footer?: string | null;
|
|
158
|
+
/**
|
|
159
|
+
* Absolute on-disk path to copy verbatim into the output, bypassing the parser. Use to emit a
|
|
160
|
+
* real source file shipped inside a package (a template) into the generated folder. Only
|
|
161
|
+
* `banner`/`footer` are applied around the copied content; child source blocks are ignored for
|
|
162
|
+
* output but still drive barrel generation.
|
|
160
163
|
*/
|
|
161
|
-
|
|
164
|
+
copy?: string | null;
|
|
162
165
|
/**
|
|
163
166
|
* Child nodes rendered as the content of this file (source blocks, imports, exports).
|
|
164
167
|
*/
|
|
@@ -180,17 +183,14 @@ type Props$2<TMeta> = BaseProps & {
|
|
|
180
183
|
* </File>
|
|
181
184
|
* ```
|
|
182
185
|
*/
|
|
183
|
-
declare function File<TMeta extends object = object>({
|
|
184
|
-
children,
|
|
185
|
-
...props
|
|
186
|
-
}: Props$2<TMeta>): KubbReactElement;
|
|
186
|
+
declare function File<TMeta extends object = object>({ children, ...props }: Props$6<TMeta>): KubbReactElement;
|
|
187
187
|
declare namespace File {
|
|
188
188
|
var displayName: string;
|
|
189
189
|
var Export: typeof FileExport;
|
|
190
190
|
var Import: typeof FileImport;
|
|
191
191
|
var Source: typeof FileSource;
|
|
192
192
|
}
|
|
193
|
-
type FileSourceProps = Omit<SourceNode, 'kind' | 'value'> & {
|
|
193
|
+
type FileSourceProps = Omit<ast.SourceNode, 'kind' | 'value'> & {
|
|
194
194
|
key?: Key;
|
|
195
195
|
/**
|
|
196
196
|
* Child nodes rendered as the source content of this block.
|
|
@@ -200,8 +200,8 @@ type FileSourceProps = Omit<SourceNode, 'kind' | 'value'> & {
|
|
|
200
200
|
/**
|
|
201
201
|
* Marks a block of source text to be associated with the enclosing {@link File}.
|
|
202
202
|
*
|
|
203
|
-
* Children are treated as the source string.
|
|
204
|
-
* `
|
|
203
|
+
* Children are treated as the source string. `isExportable` prepends the `export` keyword,
|
|
204
|
+
* `isIndexable` includes the source in barrel/index generation, and `name` keys deduplication.
|
|
205
205
|
*
|
|
206
206
|
* @example Exportable, indexable source block
|
|
207
207
|
* ```tsx
|
|
@@ -217,14 +217,11 @@ type FileSourceProps = Omit<SourceNode, 'kind' | 'value'> & {
|
|
|
217
217
|
* </File.Source>
|
|
218
218
|
* ```
|
|
219
219
|
*/
|
|
220
|
-
declare function FileSource({
|
|
221
|
-
children,
|
|
222
|
-
...props
|
|
223
|
-
}: FileSourceProps): KubbReactElement;
|
|
220
|
+
declare function FileSource({ children, ...props }: FileSourceProps): KubbReactElement;
|
|
224
221
|
declare namespace FileSource {
|
|
225
222
|
var displayName: string;
|
|
226
223
|
}
|
|
227
|
-
type FileExportProps = Omit<ExportNode, 'kind'> & {
|
|
224
|
+
type FileExportProps = Omit<ast.ExportNode, 'kind'> & {
|
|
228
225
|
key?: Key;
|
|
229
226
|
};
|
|
230
227
|
/**
|
|
@@ -248,7 +245,7 @@ declare function FileExport(props: FileExportProps): KubbReactElement;
|
|
|
248
245
|
declare namespace FileExport {
|
|
249
246
|
var displayName: string;
|
|
250
247
|
}
|
|
251
|
-
type FileImportProps = Omit<ImportNode, 'kind'> & {
|
|
248
|
+
type FileImportProps = Omit<ast.ImportNode, 'kind'> & {
|
|
252
249
|
key?: Key;
|
|
253
250
|
};
|
|
254
251
|
/**
|
|
@@ -279,8 +276,41 @@ declare namespace FileImport {
|
|
|
279
276
|
var displayName: string;
|
|
280
277
|
}
|
|
281
278
|
//#endregion
|
|
282
|
-
//#region src/components/
|
|
283
|
-
type Props$
|
|
279
|
+
//#region src/components/md/Frontmatter.d.ts
|
|
280
|
+
type Props$5 = {
|
|
281
|
+
key?: Key;
|
|
282
|
+
/**
|
|
283
|
+
* Plain object serialized as YAML between `---` fences.
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* `{ title: 'Pets', layout: 'doc' }`
|
|
287
|
+
*/
|
|
288
|
+
data: Record<string, unknown>;
|
|
289
|
+
};
|
|
290
|
+
/**
|
|
291
|
+
* Emits a YAML frontmatter envelope at the top of a generated markdown file.
|
|
292
|
+
*
|
|
293
|
+
* Renders a `<File.Source>` block containing `---\n<yaml>\n---`. Place it as
|
|
294
|
+
* the first child of `<File>` so it appears at the top of the output. Pair with
|
|
295
|
+
* `parserMd` to write `.md` files whose frontmatter downstream tooling can read.
|
|
296
|
+
*
|
|
297
|
+
* @example Page frontmatter at the top of a generated markdown file
|
|
298
|
+
* ```tsx
|
|
299
|
+
* <File baseName="pets.md" path="src/pets.md">
|
|
300
|
+
* <Frontmatter data={{ title: 'Pets', layout: 'doc' }} />
|
|
301
|
+
* <File.Source>
|
|
302
|
+
* {'# Pets\n\nList of pets.'}
|
|
303
|
+
* </File.Source>
|
|
304
|
+
* </File>
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
|
+
declare function Frontmatter({ data }: Props$5): KubbReactElement;
|
|
308
|
+
declare namespace Frontmatter {
|
|
309
|
+
var displayName: string;
|
|
310
|
+
}
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region src/components/js/Function.d.ts
|
|
313
|
+
type Props$4 = {
|
|
284
314
|
key?: Key;
|
|
285
315
|
/**
|
|
286
316
|
* Identifier of the generated function declaration.
|
|
@@ -292,30 +322,27 @@ type Props$1 = {
|
|
|
292
322
|
/**
|
|
293
323
|
* Emit `default` after the `export` keyword, making this the module's default export.
|
|
294
324
|
* Requires `export` to also be `true`.
|
|
295
|
-
* @default false
|
|
296
325
|
*/
|
|
297
|
-
default?: boolean;
|
|
326
|
+
default?: boolean | null;
|
|
298
327
|
/**
|
|
299
328
|
* Parameter list written verbatim between the function's parentheses.
|
|
300
329
|
*
|
|
301
330
|
* @example
|
|
302
331
|
* `params: 'petId: string, options?: RequestOptions'`
|
|
303
332
|
*/
|
|
304
|
-
params?: string;
|
|
333
|
+
params?: string | null;
|
|
305
334
|
/**
|
|
306
335
|
* Emit the `export` keyword before the function declaration.
|
|
307
336
|
* - `true` generates `export function name(…) { … }`
|
|
308
337
|
* - `false` generates `function name(…) { … }`
|
|
309
|
-
* @default false
|
|
310
338
|
*/
|
|
311
|
-
export?: boolean;
|
|
339
|
+
export?: boolean | null;
|
|
312
340
|
/**
|
|
313
341
|
* Emit the `async` keyword, making this an async function.
|
|
314
342
|
* The return type is automatically wrapped in `Promise<returnType>` when both
|
|
315
343
|
* `async` and `returnType` are set.
|
|
316
|
-
* @default false
|
|
317
344
|
*/
|
|
318
|
-
async?: boolean;
|
|
345
|
+
async?: boolean | null;
|
|
319
346
|
/**
|
|
320
347
|
* TypeScript generic type parameters written verbatim between `<` and `>`.
|
|
321
348
|
* Pass an array to emit multiple parameters separated by commas.
|
|
@@ -326,7 +353,7 @@ type Props$1 = {
|
|
|
326
353
|
* @example Multiple generics
|
|
327
354
|
* `generics: ['TData', 'TError = unknown']`
|
|
328
355
|
*/
|
|
329
|
-
generics?: string | string
|
|
356
|
+
generics?: string | Array<string> | null;
|
|
330
357
|
/**
|
|
331
358
|
* TypeScript return type annotation written verbatim after `:`.
|
|
332
359
|
* When `async` is `true`, the value is automatically wrapped in `Promise<…>`.
|
|
@@ -334,12 +361,12 @@ type Props$1 = {
|
|
|
334
361
|
* @example
|
|
335
362
|
* `returnType: 'Pet'`
|
|
336
363
|
*/
|
|
337
|
-
returnType?: string;
|
|
364
|
+
returnType?: string | null;
|
|
338
365
|
/**
|
|
339
366
|
* JSDoc block to prepend to the function declaration.
|
|
340
367
|
* Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
|
|
341
368
|
*/
|
|
342
|
-
JSDoc?: JSDoc;
|
|
369
|
+
JSDoc?: JSDoc | null;
|
|
343
370
|
/**
|
|
344
371
|
* Child nodes rendered as the body of the function.
|
|
345
372
|
*/
|
|
@@ -358,22 +385,18 @@ type Props$1 = {
|
|
|
358
385
|
* // }
|
|
359
386
|
* ```
|
|
360
387
|
*/
|
|
361
|
-
declare function Function({
|
|
362
|
-
children,
|
|
363
|
-
...props
|
|
364
|
-
}: Props$1): KubbReactElement;
|
|
388
|
+
declare function Function({ children, ...props }: Props$4): KubbReactElement;
|
|
365
389
|
declare namespace Function {
|
|
366
390
|
var displayName: string;
|
|
367
391
|
var Arrow: typeof ArrowFunction;
|
|
368
392
|
}
|
|
369
|
-
type ArrowFunctionProps = Props$
|
|
393
|
+
type ArrowFunctionProps = Props$4 & {
|
|
370
394
|
/**
|
|
371
395
|
* Render the arrow function as a single-line expression (no braces around the body).
|
|
372
396
|
* - `true` generates `const name = (…) => expression`
|
|
373
397
|
* - `false` generates `const name = (…) => { … }`
|
|
374
|
-
* @default false
|
|
375
398
|
*/
|
|
376
|
-
singleLine?: boolean;
|
|
399
|
+
singleLine?: boolean | null;
|
|
377
400
|
};
|
|
378
401
|
/**
|
|
379
402
|
* Generates an arrow function expression assigned to a `const`.
|
|
@@ -388,19 +411,48 @@ type ArrowFunctionProps = Props$1 & {
|
|
|
388
411
|
* // export const double = (n: number): number => n * 2
|
|
389
412
|
* ```
|
|
390
413
|
*/
|
|
391
|
-
declare function ArrowFunction({
|
|
392
|
-
children,
|
|
393
|
-
...props
|
|
394
|
-
}: ArrowFunctionProps): _$react.JSX.Element;
|
|
414
|
+
declare function ArrowFunction({ children, ...props }: ArrowFunctionProps): any;
|
|
395
415
|
declare namespace ArrowFunction {
|
|
396
416
|
var displayName: string;
|
|
397
417
|
}
|
|
398
418
|
//#endregion
|
|
399
|
-
//#region src/components/
|
|
400
|
-
type
|
|
419
|
+
//#region src/components/md/Heading.d.ts
|
|
420
|
+
type Level = 1 | 2 | 3 | 4 | 5 | 6;
|
|
421
|
+
type Props$3 = {
|
|
422
|
+
key?: Key;
|
|
423
|
+
/**
|
|
424
|
+
* Heading depth, `1` through `6`. Matches the number of `#` characters
|
|
425
|
+
* prefixed to the heading text.
|
|
426
|
+
*/
|
|
427
|
+
level: Level;
|
|
428
|
+
/**
|
|
429
|
+
* Heading text. Inline markdown (links, emphasis) is passed through verbatim.
|
|
430
|
+
*/
|
|
431
|
+
children: string;
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* Renders an ATX-style markdown heading.
|
|
435
|
+
*
|
|
436
|
+
* Emits a `<File.Source>` block containing `${'#'.repeat(level)} ${children}`.
|
|
437
|
+
* Use inside a `<File>` rendered by `parserMd`.
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```tsx
|
|
441
|
+
* <Heading level={2}>Installation</Heading>
|
|
442
|
+
* // ## Installation
|
|
443
|
+
* ```
|
|
444
|
+
*/
|
|
445
|
+
declare function Heading({ level, children }: Props$3): KubbReactElement;
|
|
446
|
+
declare namespace Heading {
|
|
447
|
+
var displayName: string;
|
|
448
|
+
}
|
|
449
|
+
//#endregion
|
|
450
|
+
//#region src/components/jsx/Jsx.d.ts
|
|
451
|
+
type Props$2 = {
|
|
401
452
|
/**
|
|
402
|
-
* Raw JSX string
|
|
403
|
-
*
|
|
453
|
+
* Raw JSX string embedded verbatim in the generated code, including
|
|
454
|
+
* fragments (`<>…</>`).
|
|
455
|
+
*
|
|
404
456
|
* @example
|
|
405
457
|
* ```tsx
|
|
406
458
|
* <Jsx>{'<>\n <a href={href}>Open</a>\n</>'}</Jsx>
|
|
@@ -411,10 +463,10 @@ type Props = {
|
|
|
411
463
|
/**
|
|
412
464
|
* Embeds a raw JSX string verbatim in the generated source code.
|
|
413
465
|
*
|
|
414
|
-
* Use this component
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
*
|
|
466
|
+
* Use this component to include JSX markup (including fragments `<>…</>`) in the
|
|
467
|
+
* body of a generated function or component. The `children` prop must be a plain
|
|
468
|
+
* string. Write expression attributes that reference runtime values as template
|
|
469
|
+
* literals.
|
|
418
470
|
*
|
|
419
471
|
* @example
|
|
420
472
|
* ```tsx
|
|
@@ -423,46 +475,75 @@ type Props = {
|
|
|
423
475
|
* </Function>
|
|
424
476
|
* ```
|
|
425
477
|
*/
|
|
426
|
-
declare function Jsx({
|
|
427
|
-
children
|
|
428
|
-
}: Props): KubbReactElement;
|
|
478
|
+
declare function Jsx({ children }: Props$2): KubbReactElement;
|
|
429
479
|
declare namespace Jsx {
|
|
430
480
|
var displayName: string;
|
|
431
481
|
}
|
|
432
482
|
//#endregion
|
|
433
|
-
//#region src/components/
|
|
434
|
-
type
|
|
483
|
+
//#region src/components/md/List.d.ts
|
|
484
|
+
type Props$1 = {
|
|
485
|
+
key?: Key;
|
|
435
486
|
/**
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
487
|
+
* When `true`, emits a numbered list (`1. …`). When `false` or omitted,
|
|
488
|
+
* emits a bullet list (`- …`).
|
|
489
|
+
*
|
|
490
|
+
* @default false
|
|
439
491
|
*/
|
|
440
|
-
|
|
492
|
+
ordered?: boolean | null;
|
|
441
493
|
/**
|
|
442
|
-
*
|
|
443
|
-
* Use this to propagate errors up to the caller of {@link createRenderer}.
|
|
494
|
+
* One entry per line. Inline markdown is passed through verbatim.
|
|
444
495
|
*/
|
|
445
|
-
|
|
496
|
+
items: ReadonlyArray<string>;
|
|
497
|
+
};
|
|
498
|
+
/**
|
|
499
|
+
* Renders a markdown list.
|
|
500
|
+
*
|
|
501
|
+
* Emits a `<File.Source>` block containing one entry per line, prefixed with
|
|
502
|
+
* `1.` / `2.` … when `ordered`, or `-` otherwise.
|
|
503
|
+
*
|
|
504
|
+
* @example
|
|
505
|
+
* ```tsx
|
|
506
|
+
* <List items={['Add the parser', 'Render the page']} />
|
|
507
|
+
* // - Add the parser
|
|
508
|
+
* // - Render the page
|
|
509
|
+
*
|
|
510
|
+
* <List ordered items={['First', 'Second']} />
|
|
511
|
+
* // 1. First
|
|
512
|
+
* // 2. Second
|
|
513
|
+
* ```
|
|
514
|
+
*/
|
|
515
|
+
declare function List({ ordered, items }: Props$1): KubbReactElement;
|
|
516
|
+
declare namespace List {
|
|
517
|
+
var displayName: string;
|
|
518
|
+
}
|
|
519
|
+
//#endregion
|
|
520
|
+
//#region src/components/md/Paragraph.d.ts
|
|
521
|
+
type Props = {
|
|
522
|
+
key?: Key;
|
|
446
523
|
/**
|
|
447
|
-
*
|
|
524
|
+
* Paragraph text. Inline markdown (links, emphasis, code spans) is passed
|
|
525
|
+
* through verbatim.
|
|
448
526
|
*/
|
|
449
|
-
children
|
|
527
|
+
children: string;
|
|
450
528
|
};
|
|
451
529
|
/**
|
|
452
|
-
*
|
|
530
|
+
* Renders a markdown paragraph.
|
|
531
|
+
*
|
|
532
|
+
* Emits a `<File.Source>` block containing the text as-is. Paragraphs are
|
|
533
|
+
* separated from surrounding blocks by blank lines via the parser's source
|
|
534
|
+
* joining.
|
|
453
535
|
*
|
|
454
|
-
*
|
|
455
|
-
*
|
|
536
|
+
* @example
|
|
537
|
+
* ```tsx
|
|
538
|
+
* <Paragraph>{'A pet object with `id` and `name` fields.'}</Paragraph>
|
|
539
|
+
* ```
|
|
456
540
|
*/
|
|
457
|
-
declare function
|
|
458
|
-
|
|
459
|
-
children
|
|
460
|
-
}: RootProps): KubbReactElement;
|
|
461
|
-
declare namespace Root {
|
|
541
|
+
declare function Paragraph({ children }: Props): KubbReactElement;
|
|
542
|
+
declare namespace Paragraph {
|
|
462
543
|
var displayName: string;
|
|
463
544
|
}
|
|
464
545
|
//#endregion
|
|
465
|
-
//#region src/components/Type.d.ts
|
|
546
|
+
//#region src/components/js/Type.d.ts
|
|
466
547
|
type TypeProps = {
|
|
467
548
|
key?: Key;
|
|
468
549
|
/**
|
|
@@ -477,14 +558,13 @@ type TypeProps = {
|
|
|
477
558
|
* Emit the `export` keyword before the type alias declaration.
|
|
478
559
|
* - `true` generates `export type Name = …`
|
|
479
560
|
* - `false` generates `type Name = …`
|
|
480
|
-
* @default false
|
|
481
561
|
*/
|
|
482
|
-
export?: boolean;
|
|
562
|
+
export?: boolean | null;
|
|
483
563
|
/**
|
|
484
564
|
* JSDoc block to prepend to the type alias declaration.
|
|
485
565
|
* Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
|
|
486
566
|
*/
|
|
487
|
-
JSDoc?: JSDoc;
|
|
567
|
+
JSDoc?: JSDoc | null;
|
|
488
568
|
/**
|
|
489
569
|
* Child nodes rendered as the type expression on the right-hand side of the alias.
|
|
490
570
|
*/
|
|
@@ -493,7 +573,7 @@ type TypeProps = {
|
|
|
493
573
|
/**
|
|
494
574
|
* Generates a TypeScript type alias declaration.
|
|
495
575
|
*
|
|
496
|
-
* Throws if `name` does not start with an uppercase letter
|
|
576
|
+
* Throws if `name` does not start with an uppercase letter. TypeScript type aliases
|
|
497
577
|
* should follow PascalCase naming conventions.
|
|
498
578
|
*
|
|
499
579
|
* @example Simple exported type alias
|
|
@@ -511,41 +591,546 @@ type TypeProps = {
|
|
|
511
591
|
* </Type>
|
|
512
592
|
* ```
|
|
513
593
|
*/
|
|
514
|
-
declare function Type({
|
|
515
|
-
children,
|
|
516
|
-
...props
|
|
517
|
-
}: TypeProps): KubbReactElement;
|
|
594
|
+
declare function Type({ children, ...props }: TypeProps): KubbReactElement;
|
|
518
595
|
declare namespace Type {
|
|
519
596
|
var displayName: string;
|
|
520
597
|
}
|
|
521
598
|
//#endregion
|
|
522
|
-
//#region src/
|
|
599
|
+
//#region ../ast/src/nodes/base.d.ts
|
|
523
600
|
/**
|
|
524
|
-
*
|
|
601
|
+
* `kind` values used by AST nodes.
|
|
525
602
|
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
603
|
+
* @example
|
|
604
|
+
* ```ts
|
|
605
|
+
* const kind: NodeKind = 'Schema'
|
|
606
|
+
* ```
|
|
607
|
+
*/
|
|
608
|
+
type NodeKind = 'Input' | 'Output' | 'Operation' | 'Schema' | 'Property' | 'Parameter' | 'Response' | 'RequestBody' | 'Content' | 'Type' | 'File' | 'Import' | 'Export' | 'Source' | 'Const' | 'Function' | 'ArrowFunction' | 'Text' | 'Break' | 'Jsx';
|
|
609
|
+
/**
|
|
610
|
+
* Base shape shared by all AST nodes.
|
|
529
611
|
*
|
|
530
612
|
* @example
|
|
531
613
|
* ```ts
|
|
532
|
-
*
|
|
614
|
+
* const base: BaseNode = { kind: 'Input' }
|
|
615
|
+
* ```
|
|
616
|
+
*/
|
|
617
|
+
type BaseNode = {
|
|
618
|
+
/**
|
|
619
|
+
* Node discriminator.
|
|
620
|
+
*/
|
|
621
|
+
kind: NodeKind;
|
|
622
|
+
};
|
|
623
|
+
//#endregion
|
|
624
|
+
//#region ../ast/src/nodes/code.d.ts
|
|
625
|
+
/**
|
|
626
|
+
* JSDoc documentation metadata attached to code declarations.
|
|
627
|
+
*/
|
|
628
|
+
type JSDocNode = {
|
|
629
|
+
/**
|
|
630
|
+
* JSDoc comment lines. `undefined` entries are filtered out during rendering.
|
|
631
|
+
*
|
|
632
|
+
* @example
|
|
633
|
+
* ```ts
|
|
634
|
+
* ['@description A pet resource', '@deprecated']
|
|
635
|
+
* ```
|
|
636
|
+
*/
|
|
637
|
+
comments?: Array<string | undefined>;
|
|
638
|
+
};
|
|
639
|
+
/**
|
|
640
|
+
* AST node representing a TypeScript `const` declaration.
|
|
641
|
+
*
|
|
642
|
+
* Mirrors the props of the `Const` component from `@kubb/renderer-jsx`.
|
|
643
|
+
* The `children` prop of the component is represented as `nodes`.
|
|
644
|
+
*
|
|
645
|
+
* @example
|
|
646
|
+
* ```ts
|
|
647
|
+
* createConst({ name: 'pet', export: true, asConst: true })
|
|
648
|
+
* // export const pet = ... as const
|
|
649
|
+
* ```
|
|
650
|
+
*/
|
|
651
|
+
type ConstNode = BaseNode & {
|
|
652
|
+
kind: 'Const';
|
|
653
|
+
/**
|
|
654
|
+
* Name of the constant declaration.
|
|
655
|
+
*/
|
|
656
|
+
name: string;
|
|
657
|
+
/**
|
|
658
|
+
* Whether the declaration should be exported.
|
|
659
|
+
*/
|
|
660
|
+
export?: boolean | null;
|
|
661
|
+
/**
|
|
662
|
+
* Explicit type annotation.
|
|
663
|
+
*
|
|
664
|
+
* @example Type reference
|
|
665
|
+
* `'Pet'`
|
|
666
|
+
*/
|
|
667
|
+
type?: string | null;
|
|
668
|
+
/**
|
|
669
|
+
* JSDoc documentation metadata.
|
|
670
|
+
*/
|
|
671
|
+
JSDoc?: JSDocNode | null;
|
|
672
|
+
/**
|
|
673
|
+
* Whether to append `as const` to the declaration.
|
|
674
|
+
*/
|
|
675
|
+
asConst?: boolean | null;
|
|
676
|
+
/**
|
|
677
|
+
* Child nodes representing the value of the constant (children of the `Const` component).
|
|
678
|
+
* Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
|
|
679
|
+
*/
|
|
680
|
+
nodes?: Array<CodeNode>;
|
|
681
|
+
};
|
|
682
|
+
/**
|
|
683
|
+
* AST node representing a TypeScript `type` alias declaration.
|
|
684
|
+
*
|
|
685
|
+
* Mirrors the props of the `Type` component from `@kubb/renderer-jsx`.
|
|
686
|
+
* The `children` prop of the component is represented as `nodes`.
|
|
687
|
+
*
|
|
688
|
+
* @example
|
|
689
|
+
* ```ts
|
|
690
|
+
* createType({ name: 'Pet', export: true })
|
|
691
|
+
* // export type Pet = ...
|
|
692
|
+
* ```
|
|
693
|
+
*/
|
|
694
|
+
type TypeNode = BaseNode & {
|
|
695
|
+
kind: 'Type';
|
|
696
|
+
/**
|
|
697
|
+
* Name of the type alias.
|
|
698
|
+
*/
|
|
699
|
+
name: string;
|
|
700
|
+
/**
|
|
701
|
+
* Whether the declaration should be exported.
|
|
702
|
+
*/
|
|
703
|
+
export?: boolean | null;
|
|
704
|
+
/**
|
|
705
|
+
* JSDoc documentation metadata.
|
|
706
|
+
*/
|
|
707
|
+
JSDoc?: JSDocNode | null;
|
|
708
|
+
/**
|
|
709
|
+
* Child nodes representing the type body (children of the `Type` component).
|
|
710
|
+
* Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
|
|
711
|
+
*/
|
|
712
|
+
nodes?: Array<CodeNode>;
|
|
713
|
+
};
|
|
714
|
+
/**
|
|
715
|
+
* AST node representing a TypeScript `function` declaration.
|
|
716
|
+
*
|
|
717
|
+
* Mirrors the props of the `Function` component from `@kubb/renderer-jsx`.
|
|
718
|
+
* The `children` prop of the component is represented as `nodes`.
|
|
719
|
+
*
|
|
720
|
+
* @example
|
|
721
|
+
* ```ts
|
|
722
|
+
* createFunction({ name: 'getPet', export: true, async: true, returnType: 'Pet' })
|
|
723
|
+
* // export async function getPet(): Promise<Pet> { ... }
|
|
724
|
+
* ```
|
|
725
|
+
*/
|
|
726
|
+
type FunctionNode = BaseNode & {
|
|
727
|
+
kind: 'Function';
|
|
728
|
+
/**
|
|
729
|
+
* Name of the function.
|
|
730
|
+
*/
|
|
731
|
+
name: string;
|
|
732
|
+
/**
|
|
733
|
+
* Whether the function is a default export.
|
|
734
|
+
*/
|
|
735
|
+
default?: boolean | null;
|
|
736
|
+
/**
|
|
737
|
+
* Function parameter list as a pre-rendered string, written verbatim between the parentheses.
|
|
738
|
+
*
|
|
739
|
+
* @example
|
|
740
|
+
* `'id: string, config: Config = {}'`
|
|
741
|
+
*/
|
|
742
|
+
params?: string | null;
|
|
743
|
+
/**
|
|
744
|
+
* Whether the function should be exported.
|
|
745
|
+
*/
|
|
746
|
+
export?: boolean | null;
|
|
747
|
+
/**
|
|
748
|
+
* Whether the function is async. When `true`, the return type is wrapped in `Promise<>`.
|
|
749
|
+
*/
|
|
750
|
+
async?: boolean | null;
|
|
751
|
+
/**
|
|
752
|
+
* TypeScript generic type parameters.
|
|
753
|
+
*
|
|
754
|
+
* @example Constrained generics
|
|
755
|
+
* `['T', 'U extends string']`
|
|
756
|
+
*/
|
|
757
|
+
generics?: string | Array<string> | null;
|
|
758
|
+
/**
|
|
759
|
+
* Return type annotation.
|
|
760
|
+
*
|
|
761
|
+
* @example Type reference
|
|
762
|
+
* `'Pet'`
|
|
763
|
+
*/
|
|
764
|
+
returnType?: string | null;
|
|
765
|
+
/**
|
|
766
|
+
* JSDoc documentation metadata.
|
|
767
|
+
*/
|
|
768
|
+
JSDoc?: JSDocNode | null;
|
|
769
|
+
/**
|
|
770
|
+
* Child nodes representing the function body (children of the `Function` component).
|
|
771
|
+
* Each entry is a {@link CodeNode}. Use {@link TextNode} for raw string content.
|
|
772
|
+
*/
|
|
773
|
+
nodes?: Array<CodeNode>;
|
|
774
|
+
};
|
|
775
|
+
/**
|
|
776
|
+
* AST node representing a TypeScript arrow function (`const name = () => { ... }`).
|
|
777
|
+
*
|
|
778
|
+
* Mirrors the props of the `Function.Arrow` component from `@kubb/renderer-jsx`.
|
|
779
|
+
* The `children` prop of the component is represented as `nodes`.
|
|
780
|
+
*
|
|
781
|
+
* @example
|
|
782
|
+
* ```ts
|
|
783
|
+
* createArrowFunction({ name: 'getPet', export: true, singleLine: true })
|
|
784
|
+
* // export const getPet = () => ...
|
|
785
|
+
* ```
|
|
786
|
+
*/
|
|
787
|
+
type ArrowFunctionNode = Omit<FunctionNode, 'kind'> & {
|
|
788
|
+
kind: 'ArrowFunction';
|
|
789
|
+
/**
|
|
790
|
+
* Render the arrow function body as a single-line expression.
|
|
791
|
+
*/
|
|
792
|
+
singleLine?: boolean | null;
|
|
793
|
+
};
|
|
794
|
+
/**
|
|
795
|
+
* AST node representing a raw text/string fragment in the source output.
|
|
796
|
+
*
|
|
797
|
+
* Used instead of bare `string` values so that all entries in `nodes` arrays
|
|
798
|
+
* are typed `CodeNode` objects rather than a mixed `CodeNode | string` union.
|
|
799
|
+
*
|
|
800
|
+
* @example
|
|
801
|
+
* ```ts
|
|
802
|
+
* createText('return fetch(id)')
|
|
803
|
+
* // { kind: 'Text', value: 'return fetch(id)' }
|
|
804
|
+
* ```
|
|
805
|
+
*/
|
|
806
|
+
type TextNode = BaseNode & {
|
|
807
|
+
kind: 'Text';
|
|
808
|
+
/**
|
|
809
|
+
* The raw string content.
|
|
810
|
+
*/
|
|
811
|
+
value: string;
|
|
812
|
+
};
|
|
813
|
+
/**
|
|
814
|
+
* AST node representing a blank line in the source output.
|
|
815
|
+
*
|
|
816
|
+
* Corresponds to `<br/>` in JSX components. `printNodes` turns a `Break` between two
|
|
817
|
+
* statements into one blank line. Consecutive breaks, and breaks at the start or end of
|
|
818
|
+
* the list, are folded away, so a `Break` never produces more than one blank line.
|
|
819
|
+
*
|
|
820
|
+
* @example
|
|
821
|
+
* ```ts
|
|
822
|
+
* createBreak()
|
|
823
|
+
* // { kind: 'Break' }
|
|
824
|
+
* ```
|
|
825
|
+
*/
|
|
826
|
+
type BreakNode = BaseNode & {
|
|
827
|
+
kind: 'Break';
|
|
828
|
+
};
|
|
829
|
+
/**
|
|
830
|
+
* AST node representing a raw JSX fragment in the source output.
|
|
831
|
+
*
|
|
832
|
+
* Mirrors the `Jsx` component from `@kubb/renderer-jsx`. Embeds raw JSX/TSX markup
|
|
833
|
+
* (including fragments `<>…</>`) directly in generated code.
|
|
834
|
+
*
|
|
835
|
+
* @example
|
|
836
|
+
* ```ts
|
|
837
|
+
* createJsx('<>\n <a href={href}>Open</a>\n</>')
|
|
838
|
+
* // { kind: 'Jsx', value: '<>\n <a href={href}>Open</a>\n</>' }
|
|
839
|
+
* ```
|
|
840
|
+
*/
|
|
841
|
+
type JsxNode = BaseNode & {
|
|
842
|
+
kind: 'Jsx';
|
|
843
|
+
/**
|
|
844
|
+
* The raw JSX string content.
|
|
845
|
+
*/
|
|
846
|
+
value: string;
|
|
847
|
+
};
|
|
848
|
+
/**
|
|
849
|
+
* Union of all code-generation AST nodes.
|
|
850
|
+
*
|
|
851
|
+
* These nodes mirror the JSX components from `@kubb/renderer-jsx` and are used as
|
|
852
|
+
* structured children in {@link SourceNode.nodes}.
|
|
853
|
+
*/
|
|
854
|
+
type CodeNode = ConstNode | TypeNode | FunctionNode | ArrowFunctionNode | TextNode | BreakNode | JsxNode;
|
|
855
|
+
//#endregion
|
|
856
|
+
//#region ../ast/src/nodes/file.d.ts
|
|
857
|
+
/**
|
|
858
|
+
* Supported file extensions.
|
|
859
|
+
*/
|
|
860
|
+
type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
|
|
861
|
+
type ImportName = string | Array<string | {
|
|
862
|
+
propertyName: string;
|
|
863
|
+
name?: string;
|
|
864
|
+
}>;
|
|
865
|
+
/**
|
|
866
|
+
* Represents a language-agnostic import/dependency declaration.
|
|
867
|
+
*
|
|
868
|
+
* @example Named import (TypeScript: `import { useState } from 'react'`)
|
|
869
|
+
* ```ts
|
|
870
|
+
* createImport({ name: ['useState'], path: 'react' })
|
|
871
|
+
* ```
|
|
872
|
+
*
|
|
873
|
+
* @example Default import (TypeScript: `import React from 'react'`)
|
|
874
|
+
* ```ts
|
|
875
|
+
* createImport({ name: 'React', path: 'react' })
|
|
876
|
+
* ```
|
|
877
|
+
*
|
|
878
|
+
* @example Type-only import (TypeScript: `import type { FC } from 'react'`)
|
|
879
|
+
* ```ts
|
|
880
|
+
* createImport({ name: ['FC'], path: 'react', isTypeOnly: true })
|
|
881
|
+
* ```
|
|
882
|
+
*
|
|
883
|
+
* @example Namespace import (TypeScript: `import * as React from 'react'`)
|
|
884
|
+
* ```ts
|
|
885
|
+
* createImport({ name: 'React', path: 'react', isNameSpace: true })
|
|
886
|
+
* ```
|
|
887
|
+
*/
|
|
888
|
+
type ImportNode = BaseNode & {
|
|
889
|
+
kind: 'Import';
|
|
890
|
+
/**
|
|
891
|
+
* Import name(s) to be used.
|
|
892
|
+
*
|
|
893
|
+
* @example Named imports
|
|
894
|
+
* `['useState']`
|
|
895
|
+
*
|
|
896
|
+
* @example Default import
|
|
897
|
+
* `'React'`
|
|
898
|
+
*/
|
|
899
|
+
name: ImportName;
|
|
900
|
+
/**
|
|
901
|
+
* Path for the import.
|
|
902
|
+
*
|
|
903
|
+
* @example
|
|
904
|
+
* `'@kubb/core'`
|
|
905
|
+
*/
|
|
906
|
+
path: string;
|
|
907
|
+
/**
|
|
908
|
+
* Add a type-only import prefix.
|
|
909
|
+
* - `true` generates `import type { Type } from './path'`
|
|
910
|
+
* - `false` generates `import { Type } from './path'`
|
|
911
|
+
*/
|
|
912
|
+
isTypeOnly?: boolean | null;
|
|
913
|
+
/**
|
|
914
|
+
* Import the entire module as a namespace.
|
|
915
|
+
* - `true` generates `import * as Name from './path'`
|
|
916
|
+
* - `false` generates a standard import
|
|
917
|
+
*/
|
|
918
|
+
isNameSpace?: boolean | null;
|
|
919
|
+
/**
|
|
920
|
+
* When set, the import path is resolved relative to this root.
|
|
921
|
+
*/
|
|
922
|
+
root?: string | null;
|
|
923
|
+
};
|
|
924
|
+
/**
|
|
925
|
+
* Represents a language-agnostic export/public API declaration.
|
|
926
|
+
*
|
|
927
|
+
* @example Named export (TypeScript: `export { Pets } from './Pets'`)
|
|
928
|
+
* ```ts
|
|
929
|
+
* createExport({ name: ['Pets'], path: './Pets' })
|
|
930
|
+
* ```
|
|
931
|
+
*
|
|
932
|
+
* @example Type-only export (TypeScript: `export type { Pet } from './Pet'`)
|
|
933
|
+
* ```ts
|
|
934
|
+
* createExport({ name: ['Pet'], path: './Pet', isTypeOnly: true })
|
|
935
|
+
* ```
|
|
936
|
+
*
|
|
937
|
+
* @example Wildcard export (TypeScript: `export * from './utils'`)
|
|
938
|
+
* ```ts
|
|
939
|
+
* createExport({ path: './utils' })
|
|
940
|
+
* ```
|
|
941
|
+
*
|
|
942
|
+
* @example Namespace alias (TypeScript: `export * as utils from './utils'`)
|
|
943
|
+
* ```ts
|
|
944
|
+
* createExport({ name: 'utils', path: './utils', asAlias: true })
|
|
945
|
+
* ```
|
|
946
|
+
*/
|
|
947
|
+
type ExportNode = BaseNode & {
|
|
948
|
+
kind: 'Export';
|
|
949
|
+
/**
|
|
950
|
+
* Export name(s) to be used. When omitted, generates a wildcard export.
|
|
951
|
+
*
|
|
952
|
+
* @example Named exports
|
|
953
|
+
* `['useState']`
|
|
954
|
+
*
|
|
955
|
+
* @example Single export
|
|
956
|
+
* `'React'`
|
|
957
|
+
*/
|
|
958
|
+
name?: string | Array<string> | null;
|
|
959
|
+
/**
|
|
960
|
+
* Path for the export.
|
|
961
|
+
*
|
|
962
|
+
* @example
|
|
963
|
+
* `'@kubb/core'`
|
|
964
|
+
*/
|
|
965
|
+
path: string;
|
|
966
|
+
/**
|
|
967
|
+
* Add a type-only export prefix.
|
|
968
|
+
* - `true` generates `export type { Type } from './path'`
|
|
969
|
+
* - `false` generates `export { Type } from './path'`
|
|
970
|
+
*/
|
|
971
|
+
isTypeOnly?: boolean | null;
|
|
972
|
+
/**
|
|
973
|
+
* Export as an aliased namespace.
|
|
974
|
+
* - `true` generates `export * as aliasName from './path'`
|
|
975
|
+
* - `false` generates a standard export
|
|
976
|
+
*/
|
|
977
|
+
asAlias?: boolean | null;
|
|
978
|
+
};
|
|
979
|
+
/**
|
|
980
|
+
* Represents a fragment of source code within a file.
|
|
981
|
+
*
|
|
982
|
+
* @example Named exportable source
|
|
983
|
+
* ```ts
|
|
984
|
+
* createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true, isIndexable: true })
|
|
985
|
+
* ```
|
|
986
|
+
*
|
|
987
|
+
* @example Inline unnamed code block
|
|
988
|
+
* ```ts
|
|
989
|
+
* createSource({ nodes: [createText('const x = 1')] })
|
|
990
|
+
* ```
|
|
991
|
+
*/
|
|
992
|
+
type SourceNode = BaseNode & {
|
|
993
|
+
kind: 'Source';
|
|
994
|
+
/**
|
|
995
|
+
* Optional name identifying this source (used for deduplication and barrel generation).
|
|
996
|
+
*/
|
|
997
|
+
name?: string | null;
|
|
998
|
+
/**
|
|
999
|
+
* Mark this source as a type-only export.
|
|
1000
|
+
*/
|
|
1001
|
+
isTypeOnly?: boolean | null;
|
|
1002
|
+
/**
|
|
1003
|
+
* Include the `export` keyword in the generated source.
|
|
1004
|
+
*/
|
|
1005
|
+
isExportable?: boolean | null;
|
|
1006
|
+
/**
|
|
1007
|
+
* Include this source in barrel/index file generation.
|
|
1008
|
+
*/
|
|
1009
|
+
isIndexable?: boolean | null;
|
|
1010
|
+
/**
|
|
1011
|
+
* Child nodes that make up this source fragment, in DOM order.
|
|
1012
|
+
* Use a {@link TextNode} for raw string content.
|
|
1013
|
+
*/
|
|
1014
|
+
nodes?: Array<CodeNode>;
|
|
1015
|
+
};
|
|
1016
|
+
/**
|
|
1017
|
+
* Represents a fully resolved file in the AST.
|
|
1018
|
+
*
|
|
1019
|
+
* Created via `createFile()`, which computes the `id`, `name`, and `extname` from the input
|
|
1020
|
+
* and deduplicates `imports`, `exports`, and `sources`.
|
|
1021
|
+
*
|
|
1022
|
+
* @example
|
|
1023
|
+
* ```ts
|
|
1024
|
+
* const file = createFile({
|
|
1025
|
+
* baseName: 'petStore.ts',
|
|
1026
|
+
* path: 'src/models/petStore.ts',
|
|
1027
|
+
* sources: [createSource({ name: 'Pet', nodes: [createText('export type Pet = { id: number }')], isExportable: true })],
|
|
1028
|
+
* imports: [createImport({ name: ['z'], path: 'zod' })],
|
|
1029
|
+
* exports: [createExport({ name: ['Pet'], path: './petStore' })],
|
|
1030
|
+
* })
|
|
1031
|
+
* // file.id = SHA256 hash of the path
|
|
1032
|
+
* // file.name = 'petStore'
|
|
1033
|
+
* // file.extname = '.ts'
|
|
1034
|
+
* ```
|
|
1035
|
+
*/
|
|
1036
|
+
type FileNode<TMeta extends object = object> = BaseNode & {
|
|
1037
|
+
kind: 'File';
|
|
1038
|
+
/**
|
|
1039
|
+
* Unique identifier derived from a SHA256 hash of the file path. `createFile`
|
|
1040
|
+
* computes it, so callers do not need to provide it.
|
|
1041
|
+
*/
|
|
1042
|
+
id: string;
|
|
1043
|
+
/**
|
|
1044
|
+
* File name without extension, derived from `baseName`.
|
|
1045
|
+
*
|
|
1046
|
+
* @see https://nodejs.org/api/path.html#pathformatpathobject
|
|
1047
|
+
*/
|
|
1048
|
+
name: string;
|
|
1049
|
+
/**
|
|
1050
|
+
* File base name, including extension, shaped like `${name}${extname}`.
|
|
1051
|
+
*
|
|
1052
|
+
* @see https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
1053
|
+
*/
|
|
1054
|
+
baseName: `${string}.${string}`;
|
|
1055
|
+
/**
|
|
1056
|
+
* Full qualified path to the file.
|
|
1057
|
+
*/
|
|
1058
|
+
path: string;
|
|
1059
|
+
/**
|
|
1060
|
+
* File extension extracted from `baseName`.
|
|
1061
|
+
*/
|
|
1062
|
+
extname: Extname;
|
|
1063
|
+
/**
|
|
1064
|
+
* Deduplicated list of source code fragments.
|
|
1065
|
+
*/
|
|
1066
|
+
sources: Array<SourceNode>;
|
|
1067
|
+
/**
|
|
1068
|
+
* Deduplicated list of import declarations.
|
|
1069
|
+
*/
|
|
1070
|
+
imports: Array<ImportNode>;
|
|
1071
|
+
/**
|
|
1072
|
+
* Deduplicated list of export declarations.
|
|
1073
|
+
*/
|
|
1074
|
+
exports: Array<ExportNode>;
|
|
1075
|
+
/**
|
|
1076
|
+
* Optional metadata attached to this file, read by plugins during barrel generation.
|
|
1077
|
+
*/
|
|
1078
|
+
meta?: TMeta;
|
|
1079
|
+
/**
|
|
1080
|
+
* Optional banner prepended to the generated file content.
|
|
1081
|
+
* Accepts `null` so `resolver.default.banner()` results can be passed directly.
|
|
1082
|
+
*/
|
|
1083
|
+
banner?: string | null;
|
|
1084
|
+
/**
|
|
1085
|
+
* Optional footer appended to the generated file content.
|
|
1086
|
+
* Accepts `null` so `resolver.default.footer()` results can be passed directly.
|
|
1087
|
+
*/
|
|
1088
|
+
footer?: string | null;
|
|
1089
|
+
/**
|
|
1090
|
+
* Absolute on-disk path to copy verbatim into the output, bypassing the parser.
|
|
1091
|
+
*
|
|
1092
|
+
* Use to emit a real source file shipped inside a package (a template) into the generated
|
|
1093
|
+
* folder without reformatting or import reordering. Only `banner` and `footer` are applied
|
|
1094
|
+
* around the copied content. When set, `copy` provides the file content and any `sources`
|
|
1095
|
+
* nodes are ignored for output; `sources` may still carry `name`/`isExportable`/`isIndexable`
|
|
1096
|
+
* so barrel generation treats the file the same as a rendered one.
|
|
1097
|
+
*/
|
|
1098
|
+
copy?: string | null;
|
|
1099
|
+
};
|
|
1100
|
+
//#endregion
|
|
1101
|
+
//#region src/jsxRenderer.d.ts
|
|
1102
|
+
/**
|
|
1103
|
+
* Factory for a renderer that walks the JSX tree in a single recursive pass,
|
|
1104
|
+
* with no React reconciler or scheduler. Pass it as the `renderer` property on
|
|
1105
|
+
* `defineGenerator`. Kubb core calls the factory once per render cycle and stays
|
|
1106
|
+
* generic, with no hard dependency on `@kubb/renderer-jsx`.
|
|
1107
|
+
*
|
|
1108
|
+
* Every component must be a pure function. Hooks, suspense, and class
|
|
1109
|
+
* components are not supported.
|
|
1110
|
+
*
|
|
1111
|
+
* @example Wire up a JSX generator
|
|
1112
|
+
* ```tsx
|
|
533
1113
|
* import { defineGenerator } from '@kubb/core'
|
|
1114
|
+
* import { jsxRenderer } from '@kubb/renderer-jsx'
|
|
534
1115
|
*
|
|
535
1116
|
* export const myGenerator = defineGenerator<PluginTs>({
|
|
536
|
-
* name: '
|
|
1117
|
+
* name: 'types',
|
|
537
1118
|
* renderer: jsxRenderer,
|
|
538
|
-
* schema(node,
|
|
539
|
-
* return
|
|
1119
|
+
* schema(node, ctx) {
|
|
1120
|
+
* return (
|
|
1121
|
+
* <File baseName="output.ts" path={`${ctx.root}/output.ts`}>
|
|
1122
|
+
* <Type node={node} resolver={ctx.resolver} />
|
|
1123
|
+
* </File>
|
|
1124
|
+
* )
|
|
540
1125
|
* },
|
|
541
1126
|
* })
|
|
542
1127
|
* ```
|
|
543
1128
|
*/
|
|
544
1129
|
declare const jsxRenderer: () => {
|
|
545
1130
|
render(element: KubbReactElement): Promise<void>;
|
|
546
|
-
readonly files:
|
|
547
|
-
|
|
1131
|
+
readonly files: FileNode[];
|
|
1132
|
+
[Symbol.dispose](): void;
|
|
548
1133
|
};
|
|
549
1134
|
//#endregion
|
|
550
|
-
export { Const, File, Function,
|
|
1135
|
+
export { Callout, Const, File, Frontmatter, Function, Heading, Jsx, List, Paragraph, Type, jsxRenderer };
|
|
551
1136
|
//# sourceMappingURL=index.d.ts.map
|