@kubb/renderer-jsx 5.10.1 → 5.10.3
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 +0 -1
- package/dist/index.d.cts +487 -0
- package/dist/index.d.ts +1 -2
- package/dist/jsx-dev-runtime.d.cts +2 -0
- package/dist/jsx-runtime.cjs +0 -1
- package/dist/jsx-runtime.d.cts +81 -0
- package/dist/jsx-runtime.d.ts +1 -2
- package/dist/{types-CVtBr_H8.d.ts → types-BQObETlT.d.cts} +1 -2
- package/dist/types-BQObETlT.d.ts +37 -0
- package/package.json +26 -11
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
import { i as KubbReactNode, n as Key, r as KubbReactElement, t as JSDoc } from "./types-BQObETlT.cjs";
|
|
2
|
+
import { ast } from "@kubb/ast";
|
|
3
|
+
//#region src/components/md/Callout.d.ts
|
|
4
|
+
declare const CALLOUT_LABEL: {
|
|
5
|
+
readonly tip: "TIP";
|
|
6
|
+
readonly note: "NOTE";
|
|
7
|
+
readonly important: "IMPORTANT";
|
|
8
|
+
readonly warning: "WARNING";
|
|
9
|
+
readonly caution: "CAUTION";
|
|
10
|
+
};
|
|
11
|
+
type CalloutType = keyof typeof CALLOUT_LABEL;
|
|
12
|
+
type Props$7 = {
|
|
13
|
+
key?: Key;
|
|
14
|
+
/**
|
|
15
|
+
* Callout kind. Maps to the uppercase label inside the `> [!TYPE]` marker.
|
|
16
|
+
*/
|
|
17
|
+
type: CalloutType;
|
|
18
|
+
/**
|
|
19
|
+
* Optional title rendered on the same line as the marker.
|
|
20
|
+
*/
|
|
21
|
+
title?: string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Body text. Each line is quoted with `> ` so multi-line content stays
|
|
24
|
+
* inside the callout block.
|
|
25
|
+
*/
|
|
26
|
+
children: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Renders a GitHub-style alert callout using the `> [!TYPE]` blockquote syntax.
|
|
30
|
+
*
|
|
31
|
+
* Emits a `<File.Source>` block containing `> [!TYPE] Title` followed by the
|
|
32
|
+
* body with every line prefixed by `> `.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```tsx
|
|
36
|
+
* <Callout type="tip">Run `kubb start --watch` to keep the generator hot.</Callout>
|
|
37
|
+
* // > [!TIP]
|
|
38
|
+
* // > Run `kubb start --watch` to keep the generator hot.
|
|
39
|
+
*
|
|
40
|
+
* <Callout type="warning" title="Heads up">Breaking change in v6.</Callout>
|
|
41
|
+
* // > [!WARNING] Heads up
|
|
42
|
+
* // > Breaking change in v6.
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function Callout({ type, title, children }: Props$7): KubbReactElement;
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/components/js/Const.d.ts
|
|
48
|
+
type ConstProps = Omit<ast.ConstNode, 'kind' | 'nodes'> & {
|
|
49
|
+
key?: Key;
|
|
50
|
+
/**
|
|
51
|
+
* Child nodes rendered as the initializer expression of the constant.
|
|
52
|
+
*/
|
|
53
|
+
children?: KubbReactNode;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Generates a TypeScript constant declaration.
|
|
57
|
+
*
|
|
58
|
+
* @example Named export with type annotation
|
|
59
|
+
* ```tsx
|
|
60
|
+
* <Const export name="petSchema" type="z.ZodType<Pet>">
|
|
61
|
+
* {`z.object({ id: z.number() })`}
|
|
62
|
+
* </Const>
|
|
63
|
+
* // export const petSchema: z.ZodType<Pet> = z.object({ id: z.number() })
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @example With JSDoc and const assertion
|
|
67
|
+
* ```tsx
|
|
68
|
+
* <Const name="HTTP_METHODS" asConst JSDoc={{ comments: ['@description Supported HTTP methods.'] }}>
|
|
69
|
+
* {`['GET', 'POST', 'PUT', 'DELETE']`}
|
|
70
|
+
* </Const>
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function Const({ children, ...props }: ConstProps): KubbReactElement;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/components/File.d.ts
|
|
76
|
+
type BasePropsWithBaseName = {
|
|
77
|
+
/**
|
|
78
|
+
* Base file name including extension, derived from the input path.
|
|
79
|
+
* Based on UNIX basename convention: `${name}${extname}`.
|
|
80
|
+
*
|
|
81
|
+
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* `baseName: 'petStore.ts'`
|
|
85
|
+
*/
|
|
86
|
+
baseName: `${string}.${string}`;
|
|
87
|
+
/**
|
|
88
|
+
* Fully qualified path to the generated file.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* `path: 'src/models/petStore.ts'`
|
|
92
|
+
*/
|
|
93
|
+
path: string;
|
|
94
|
+
};
|
|
95
|
+
type BasePropsWithoutBaseName = {
|
|
96
|
+
baseName?: never;
|
|
97
|
+
/**
|
|
98
|
+
* Fully qualified path to the generated file.
|
|
99
|
+
* Optional when `baseName` is omitted, the component renders its children inline.
|
|
100
|
+
*/
|
|
101
|
+
path?: string | null;
|
|
102
|
+
};
|
|
103
|
+
type BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName;
|
|
104
|
+
type Props$6<TMeta> = BaseProps & {
|
|
105
|
+
key?: Key;
|
|
106
|
+
/**
|
|
107
|
+
* Arbitrary metadata attached to the file node for plugins to read.
|
|
108
|
+
*/
|
|
109
|
+
meta?: TMeta | null;
|
|
110
|
+
/**
|
|
111
|
+
* Text prepended to the generated file content before any source blocks.
|
|
112
|
+
* Accepts `null` so `resolver.default.banner()` results can be passed directly.
|
|
113
|
+
*/
|
|
114
|
+
banner?: string | null;
|
|
115
|
+
/**
|
|
116
|
+
* Text appended to the generated file content after all source blocks.
|
|
117
|
+
* Accepts `null` so `resolver.default.footer()` results can be passed directly.
|
|
118
|
+
*/
|
|
119
|
+
footer?: string | null;
|
|
120
|
+
/**
|
|
121
|
+
* Absolute on-disk path to copy into the output, through the parser's `copy` hook when it has
|
|
122
|
+
* one. Use to emit a real source file shipped inside a package (a template) into the generated
|
|
123
|
+
* folder. Child source blocks are ignored for output but still drive barrel generation.
|
|
124
|
+
*/
|
|
125
|
+
copy?: string | null;
|
|
126
|
+
/**
|
|
127
|
+
* Child nodes rendered as the content of this file (source blocks, imports, exports).
|
|
128
|
+
*/
|
|
129
|
+
children?: KubbReactNode;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Declares a generated file entry to be collected by the renderer.
|
|
133
|
+
*
|
|
134
|
+
* When both `baseName` and `path` are provided, the component registers a new
|
|
135
|
+
* `FileNode` and passes its children through as source blocks.
|
|
136
|
+
* When either is omitted the children are rendered inline without creating a file entry.
|
|
137
|
+
*
|
|
138
|
+
* @example Basic file with a source block
|
|
139
|
+
* ```tsx
|
|
140
|
+
* <File baseName="petStore.ts" path="src/models/petStore.ts">
|
|
141
|
+
* <File.Source name="Pet" isExportable isIndexable>
|
|
142
|
+
* {`export type Pet = { id: number; name: string }`}
|
|
143
|
+
* </File.Source>
|
|
144
|
+
* </File>
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export declare function File<TMeta extends object = object>({ children, ...props }: Props$6<TMeta>): KubbReactElement;
|
|
148
|
+
export declare namespace File {
|
|
149
|
+
var Export: typeof FileExport;
|
|
150
|
+
var Import: typeof FileImport;
|
|
151
|
+
var Source: typeof FileSource;
|
|
152
|
+
}
|
|
153
|
+
type FileSourceProps = Omit<ast.SourceNode, 'kind' | 'value'> & {
|
|
154
|
+
key?: Key;
|
|
155
|
+
/**
|
|
156
|
+
* Child nodes rendered as the source content of this block.
|
|
157
|
+
*/
|
|
158
|
+
children?: KubbReactNode;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Marks a block of source text to be associated with the enclosing {@link File}.
|
|
162
|
+
*
|
|
163
|
+
* Children are treated as the source string. `isExportable` prepends the `export` keyword,
|
|
164
|
+
* `isIndexable` includes the source in barrel/index generation, and `name` keys deduplication.
|
|
165
|
+
*
|
|
166
|
+
* @example Exportable, indexable source block
|
|
167
|
+
* ```tsx
|
|
168
|
+
* <File.Source name="Pet" isExportable isIndexable>
|
|
169
|
+
* {`export type Pet = { id: number; name: string }`}
|
|
170
|
+
* </File.Source>
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @example Type-only source block
|
|
174
|
+
* ```tsx
|
|
175
|
+
* <File.Source name="PetId" isTypeOnly isExportable>
|
|
176
|
+
* {`export type PetId = string`}
|
|
177
|
+
* </File.Source>
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
declare function FileSource({ children, ...props }: FileSourceProps): KubbReactElement;
|
|
181
|
+
type FileExportProps = Omit<ast.ExportNode, 'kind'> & {
|
|
182
|
+
key?: Key;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Declares an export entry for the enclosing {@link File}.
|
|
186
|
+
*
|
|
187
|
+
* The export is collected by the renderer and emitted at the top of the generated file.
|
|
188
|
+
*
|
|
189
|
+
* @example Named export
|
|
190
|
+
* ```tsx
|
|
191
|
+
* <File.Export name={['Pet']} path="./models/petStore" />
|
|
192
|
+
* // export { Pet } from './models/petStore'
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* @example Type-only wildcard export
|
|
196
|
+
* ```tsx
|
|
197
|
+
* <File.Export path="./models/petStore" isTypeOnly />
|
|
198
|
+
* // export type * from './models/petStore'
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
declare function FileExport(props: FileExportProps): KubbReactElement;
|
|
202
|
+
type FileImportProps = Omit<ast.ImportNode, 'kind'> & {
|
|
203
|
+
key?: Key;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Declares an import entry for the enclosing {@link File}.
|
|
207
|
+
*
|
|
208
|
+
* The import is collected by the renderer and emitted at the top of the generated file.
|
|
209
|
+
*
|
|
210
|
+
* @example Named import
|
|
211
|
+
* ```tsx
|
|
212
|
+
* <File.Import name={['useState']} path="react" />
|
|
213
|
+
* // import { useState } from 'react'
|
|
214
|
+
* ```
|
|
215
|
+
*
|
|
216
|
+
* @example Type-only import
|
|
217
|
+
* ```tsx
|
|
218
|
+
* <File.Import name={['Pet']} path="./models" isTypeOnly />
|
|
219
|
+
* // import type { Pet } from './models'
|
|
220
|
+
* ```
|
|
221
|
+
*
|
|
222
|
+
* @example Namespace import
|
|
223
|
+
* ```tsx
|
|
224
|
+
* <File.Import name="z" path="zod" isNameSpace />
|
|
225
|
+
* // import * as z from 'zod'
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
declare function FileImport(props: FileImportProps): KubbReactElement;
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/components/md/Frontmatter.d.ts
|
|
231
|
+
type Props$5 = {
|
|
232
|
+
key?: Key;
|
|
233
|
+
/**
|
|
234
|
+
* Plain object serialized as YAML between `---` fences.
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* `{ title: 'Pets', layout: 'doc' }`
|
|
238
|
+
*/
|
|
239
|
+
data: Record<string, unknown>;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Emits a YAML frontmatter envelope at the top of a generated markdown file.
|
|
243
|
+
*
|
|
244
|
+
* Renders a `<File.Source>` block containing `---\n<yaml>\n---`. Place it as
|
|
245
|
+
* the first child of `<File>` so it appears at the top of the output. Pair with
|
|
246
|
+
* `parserMd` to write `.md` files whose frontmatter downstream tooling can read.
|
|
247
|
+
*
|
|
248
|
+
* @example Page frontmatter at the top of a generated markdown file
|
|
249
|
+
* ```tsx
|
|
250
|
+
* <File baseName="pets.md" path="src/pets.md">
|
|
251
|
+
* <Frontmatter data={{ title: 'Pets', layout: 'doc' }} />
|
|
252
|
+
* <File.Source>
|
|
253
|
+
* {'# Pets\n\nList of pets.'}
|
|
254
|
+
* </File.Source>
|
|
255
|
+
* </File>
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
export declare function Frontmatter({ data }: Props$5): KubbReactElement;
|
|
259
|
+
//#endregion
|
|
260
|
+
//#region src/components/js/Function.d.ts
|
|
261
|
+
type Props$4 = Omit<ast.FunctionNode, 'kind' | 'nodes'> & {
|
|
262
|
+
key?: Key;
|
|
263
|
+
/**
|
|
264
|
+
* Child nodes rendered as the body of the function.
|
|
265
|
+
*/
|
|
266
|
+
children?: KubbReactNode;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Generates a TypeScript function declaration.
|
|
270
|
+
*
|
|
271
|
+
* @example Async exported function with generics
|
|
272
|
+
* ```tsx
|
|
273
|
+
* <Function export async name="getPet" generics={['TData = Pet']} params="petId: string" returnType="TData">
|
|
274
|
+
* {`return client.get(\`/pets/\${petId}\`)`}
|
|
275
|
+
* </Function>
|
|
276
|
+
* // export async function getPet<TData = Pet>(petId: string): Promise<TData> {
|
|
277
|
+
* // return client.get(`/pets/${petId}`)
|
|
278
|
+
* // }
|
|
279
|
+
* ```
|
|
280
|
+
*/
|
|
281
|
+
export declare function Function({ children, ...props }: Props$4): KubbReactElement;
|
|
282
|
+
export declare namespace Function {
|
|
283
|
+
var Arrow: typeof ArrowFunction;
|
|
284
|
+
}
|
|
285
|
+
type ArrowFunctionProps = Omit<ast.ArrowFunctionNode, 'kind' | 'nodes'> & {
|
|
286
|
+
key?: Key;
|
|
287
|
+
/**
|
|
288
|
+
* Child nodes rendered as the body of the function.
|
|
289
|
+
*/
|
|
290
|
+
children?: KubbReactNode;
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* Generates an arrow function expression assigned to a `const`.
|
|
294
|
+
* Supports the same flags as {@link Function}.
|
|
295
|
+
* Use `singleLine` to render the body as a concise expression rather than a block.
|
|
296
|
+
*
|
|
297
|
+
* @example Single-line arrow function
|
|
298
|
+
* ```tsx
|
|
299
|
+
* <Function.Arrow export name="double" params="n: number" returnType="number" singleLine>
|
|
300
|
+
* {`n * 2`}
|
|
301
|
+
* </Function.Arrow>
|
|
302
|
+
* // export const double = (n: number): number => n * 2
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
declare function ArrowFunction({ children, ...props }: ArrowFunctionProps): KubbReactElement;
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/components/md/Heading.d.ts
|
|
308
|
+
type Level = 1 | 2 | 3 | 4 | 5 | 6;
|
|
309
|
+
type Props$3 = {
|
|
310
|
+
key?: Key;
|
|
311
|
+
/**
|
|
312
|
+
* Heading depth, `1` through `6`. Matches the number of `#` characters
|
|
313
|
+
* prefixed to the heading text.
|
|
314
|
+
*/
|
|
315
|
+
level: Level;
|
|
316
|
+
/**
|
|
317
|
+
* Heading text. Inline markdown (links, emphasis) is passed through verbatim.
|
|
318
|
+
*/
|
|
319
|
+
children: string;
|
|
320
|
+
};
|
|
321
|
+
/**
|
|
322
|
+
* Renders an ATX-style markdown heading.
|
|
323
|
+
*
|
|
324
|
+
* Emits a `<File.Source>` block containing `${'#'.repeat(level)} ${children}`.
|
|
325
|
+
* Use inside a `<File>` rendered by `parserMd`.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```tsx
|
|
329
|
+
* <Heading level={2}>Installation</Heading>
|
|
330
|
+
* // ## Installation
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
export declare function Heading({ level, children }: Props$3): KubbReactElement;
|
|
334
|
+
//#endregion
|
|
335
|
+
//#region src/components/jsx/Jsx.d.ts
|
|
336
|
+
type Props$2 = {
|
|
337
|
+
key?: Key;
|
|
338
|
+
/**
|
|
339
|
+
* Raw JSX string embedded verbatim in the generated code, including
|
|
340
|
+
* fragments (`<>…</>`).
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```tsx
|
|
344
|
+
* <Jsx>{'<>\n <a href={href}>Open</a>\n</>'}</Jsx>
|
|
345
|
+
* ```
|
|
346
|
+
*/
|
|
347
|
+
children?: string;
|
|
348
|
+
};
|
|
349
|
+
/**
|
|
350
|
+
* Embeds a raw JSX string verbatim in the generated source code.
|
|
351
|
+
*
|
|
352
|
+
* Use this component to include JSX markup (including fragments `<>…</>`) in the
|
|
353
|
+
* body of a generated function or component. The `children` prop must be a plain
|
|
354
|
+
* string. Write expression attributes that reference runtime values as template
|
|
355
|
+
* literals.
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```tsx
|
|
359
|
+
* <Function name="MyComponent" export>
|
|
360
|
+
* <Jsx>{'return (\n <>\n <div>Hello</div>\n </>\n)'}</Jsx>
|
|
361
|
+
* </Function>
|
|
362
|
+
* ```
|
|
363
|
+
*/
|
|
364
|
+
export declare function Jsx({ children }: Props$2): KubbReactElement;
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region src/components/md/List.d.ts
|
|
367
|
+
type Props$1 = {
|
|
368
|
+
key?: Key;
|
|
369
|
+
/**
|
|
370
|
+
* When `true`, emits a numbered list (`1. …`). When `false` or omitted,
|
|
371
|
+
* emits a bullet list (`- …`).
|
|
372
|
+
*
|
|
373
|
+
* @default false
|
|
374
|
+
*/
|
|
375
|
+
ordered?: boolean | null;
|
|
376
|
+
/**
|
|
377
|
+
* One entry per line. Inline markdown is passed through verbatim.
|
|
378
|
+
*/
|
|
379
|
+
items: ReadonlyArray<string>;
|
|
380
|
+
};
|
|
381
|
+
/**
|
|
382
|
+
* Renders a markdown list.
|
|
383
|
+
*
|
|
384
|
+
* Emits a `<File.Source>` block containing one entry per line, prefixed with
|
|
385
|
+
* `1.` / `2.` … when `ordered`, or `-` otherwise.
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```tsx
|
|
389
|
+
* <List items={['Add the parser', 'Render the page']} />
|
|
390
|
+
* // - Add the parser
|
|
391
|
+
* // - Render the page
|
|
392
|
+
*
|
|
393
|
+
* <List ordered items={['First', 'Second']} />
|
|
394
|
+
* // 1. First
|
|
395
|
+
* // 2. Second
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
398
|
+
export declare function List({ ordered, items }: Props$1): KubbReactElement;
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region src/components/md/Paragraph.d.ts
|
|
401
|
+
type Props = {
|
|
402
|
+
key?: Key;
|
|
403
|
+
/**
|
|
404
|
+
* Paragraph text. Inline markdown (links, emphasis, code spans) is passed
|
|
405
|
+
* through verbatim.
|
|
406
|
+
*/
|
|
407
|
+
children: string;
|
|
408
|
+
};
|
|
409
|
+
/**
|
|
410
|
+
* Renders a markdown paragraph.
|
|
411
|
+
*
|
|
412
|
+
* Emits a `<File.Source>` block containing the text as-is. Paragraphs are
|
|
413
|
+
* separated from surrounding blocks by blank lines via the parser's source
|
|
414
|
+
* joining.
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* ```tsx
|
|
418
|
+
* <Paragraph>{'A pet object with `id` and `name` fields.'}</Paragraph>
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
export declare function Paragraph({ children }: Props): KubbReactElement;
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region src/components/js/Type.d.ts
|
|
424
|
+
type TypeProps = Omit<ast.TypeNode, 'kind' | 'nodes'> & {
|
|
425
|
+
key?: Key;
|
|
426
|
+
/**
|
|
427
|
+
* Child nodes rendered as the type expression on the right-hand side of the alias.
|
|
428
|
+
*/
|
|
429
|
+
children?: KubbReactNode;
|
|
430
|
+
};
|
|
431
|
+
/**
|
|
432
|
+
* Generates a TypeScript type alias declaration.
|
|
433
|
+
*
|
|
434
|
+
* Throws if `name` does not start with an uppercase letter. TypeScript type aliases
|
|
435
|
+
* should follow PascalCase naming conventions.
|
|
436
|
+
*
|
|
437
|
+
* @example Simple exported type alias
|
|
438
|
+
* ```tsx
|
|
439
|
+
* <Type export name="PetId">
|
|
440
|
+
* {`string | number`}
|
|
441
|
+
* </Type>
|
|
442
|
+
* // export type PetId = string | number
|
|
443
|
+
* ```
|
|
444
|
+
*
|
|
445
|
+
* @example Type alias with JSDoc
|
|
446
|
+
* ```tsx
|
|
447
|
+
* <Type export name="Pet" JSDoc={{ comments: ['@description A pet in the store.'] }}>
|
|
448
|
+
* {`{ id: number; name: string }`}
|
|
449
|
+
* </Type>
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
export declare function Type({ children, ...props }: TypeProps): KubbReactElement;
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region src/jsxRenderer.d.ts
|
|
455
|
+
/**
|
|
456
|
+
* Factory for a renderer that walks the JSX tree in a single recursive pass,
|
|
457
|
+
* with no React reconciler or scheduler. Pass it as the `renderer` property on
|
|
458
|
+
* `defineGenerator`. Kubb core calls the factory once per render cycle and stays
|
|
459
|
+
* generic, with no hard dependency on `@kubb/renderer-jsx`. Every component must be a pure
|
|
460
|
+
* function. Hooks, suspense and class components are not supported.
|
|
461
|
+
*
|
|
462
|
+
* @example Wire up a JSX generator
|
|
463
|
+
* ```tsx
|
|
464
|
+
* import { defineGenerator } from '@kubb/core'
|
|
465
|
+
* import { jsxRenderer } from '@kubb/renderer-jsx'
|
|
466
|
+
*
|
|
467
|
+
* export const myGenerator = defineGenerator<PluginTs>({
|
|
468
|
+
* name: 'types',
|
|
469
|
+
* renderer: jsxRenderer,
|
|
470
|
+
* schema(node, ctx) {
|
|
471
|
+
* return (
|
|
472
|
+
* <File baseName="output.ts" path={`${ctx.root}/output.ts`}>
|
|
473
|
+
* <Type node={node} resolver={ctx.resolver} />
|
|
474
|
+
* </File>
|
|
475
|
+
* )
|
|
476
|
+
* },
|
|
477
|
+
* })
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
export declare const jsxRenderer: () => {
|
|
481
|
+
render(element: KubbReactElement): Promise<void>;
|
|
482
|
+
readonly files: ast.FileNode[];
|
|
483
|
+
[Symbol.dispose](): void;
|
|
484
|
+
};
|
|
485
|
+
//#endregion
|
|
486
|
+
export type { JSDoc, Key, KubbReactElement, KubbReactNode };
|
|
487
|
+
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { i as KubbReactNode, n as Key, r as KubbReactElement, t as JSDoc } from "./types-CVtBr_H8.js";
|
|
1
|
+
import { i as KubbReactNode, n as Key, r as KubbReactElement, t as JSDoc } from "./types-BQObETlT.js";
|
|
3
2
|
import { ast } from "@kubb/ast";
|
|
4
3
|
//#region src/components/md/Callout.d.ts
|
|
5
4
|
declare const CALLOUT_LABEL: {
|
package/dist/jsx-runtime.cjs
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { i as KubbReactNode, n as Key, r as KubbReactElement } from "./types-BQObETlT.cjs";
|
|
2
|
+
import { ast } from "@kubb/ast";
|
|
3
|
+
//#region src/jsx-namespace.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* JSX contract for `@kubb/renderer-jsx`, resolved through `jsxImportSource`.
|
|
6
|
+
*
|
|
7
|
+
* It is self-contained and does not extend `React.JSX`. The renderer only emits
|
|
8
|
+
* the custom `kubb-*` hosts plus `br`, and supports pure function components, so
|
|
9
|
+
* the HTML element and class-component machinery from `@types/react` is not needed.
|
|
10
|
+
*/
|
|
11
|
+
declare namespace JSX {
|
|
12
|
+
type ElementType = string | ((props: never) => KubbReactNode);
|
|
13
|
+
type Element = KubbReactElement;
|
|
14
|
+
interface ElementChildrenAttribute {
|
|
15
|
+
children: {};
|
|
16
|
+
}
|
|
17
|
+
interface IntrinsicAttributes {
|
|
18
|
+
key?: Key | null;
|
|
19
|
+
}
|
|
20
|
+
interface IntrinsicElements {
|
|
21
|
+
['kubb-jsx']: {
|
|
22
|
+
children?: string;
|
|
23
|
+
};
|
|
24
|
+
['kubb-file']: {
|
|
25
|
+
id?: string | null;
|
|
26
|
+
children?: KubbReactNode;
|
|
27
|
+
baseName: ast.FileNode['baseName'];
|
|
28
|
+
path: string;
|
|
29
|
+
banner?: string | null;
|
|
30
|
+
footer?: string | null;
|
|
31
|
+
/**
|
|
32
|
+
* Absolute on-disk path to copy into the output, through the parser's `copy` hook when it has
|
|
33
|
+
* one. Use to emit a real source file shipped inside a package (a template) into the generated folder.
|
|
34
|
+
*/
|
|
35
|
+
copy?: string | null;
|
|
36
|
+
meta?: ast.FileNode['meta'] | null;
|
|
37
|
+
};
|
|
38
|
+
['kubb-source']: Omit<ast.SourceNode, 'kind'> & {
|
|
39
|
+
children?: KubbReactNode;
|
|
40
|
+
};
|
|
41
|
+
['kubb-import']: Omit<ast.ImportNode, 'kind'> & {};
|
|
42
|
+
['kubb-export']: Omit<ast.ExportNode, 'kind'> & {};
|
|
43
|
+
['kubb-function']: Omit<ast.FunctionNode, 'kind'> & {
|
|
44
|
+
children?: KubbReactNode;
|
|
45
|
+
};
|
|
46
|
+
['kubb-arrow-function']: Omit<ast.ArrowFunctionNode, 'kind'> & {
|
|
47
|
+
children?: KubbReactNode;
|
|
48
|
+
};
|
|
49
|
+
['kubb-const']: Omit<ast.ConstNode, 'kind'> & {
|
|
50
|
+
children?: KubbReactNode;
|
|
51
|
+
};
|
|
52
|
+
['kubb-type']: Omit<ast.TypeNode, 'kind'> & {
|
|
53
|
+
children?: KubbReactNode;
|
|
54
|
+
};
|
|
55
|
+
br: {};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/jsx-runtime.d.ts
|
|
60
|
+
/**
|
|
61
|
+
* Fragment marker. A `<>…</>` compiles to `jsx(Fragment, …)`, and the renderer
|
|
62
|
+
* unwraps it while walking the tree.
|
|
63
|
+
*/
|
|
64
|
+
export declare const Fragment: unique symbol;
|
|
65
|
+
/**
|
|
66
|
+
* Create a Kubb JSX element. The automatic JSX runtime calls this for every tag,
|
|
67
|
+
* so the renderer never depends on React at runtime. The `type` is a host
|
|
68
|
+
* string, a function component, or `Fragment`, and children are folded into
|
|
69
|
+
* `props`.
|
|
70
|
+
*/
|
|
71
|
+
declare function createElement(type: unknown, props: Record<string, unknown> | null, key?: Key | null): KubbReactElement;
|
|
72
|
+
/**
|
|
73
|
+
* Returns `true` when `value` is an element this runtime created.
|
|
74
|
+
*/
|
|
75
|
+
export declare function isKubbElement(value: unknown): value is KubbReactElement;
|
|
76
|
+
export declare const jsx: typeof createElement;
|
|
77
|
+
export declare const jsxs: typeof createElement;
|
|
78
|
+
export declare const jsxDEV: typeof createElement;
|
|
79
|
+
//#endregion
|
|
80
|
+
export type { JSX };
|
|
81
|
+
//# sourceMappingURL=jsx-runtime.d.cts.map
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as KubbReactNode, n as Key, r as KubbReactElement } from "./types-CVtBr_H8.js";
|
|
1
|
+
import { i as KubbReactNode, n as Key, r as KubbReactElement } from "./types-BQObETlT.js";
|
|
3
2
|
import { ast } from "@kubb/ast";
|
|
4
3
|
//#region src/jsx-namespace.d.ts
|
|
5
4
|
/**
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
1
|
import { ast } from "@kubb/ast";
|
|
3
2
|
//#region src/types.d.ts
|
|
4
3
|
/**
|
|
@@ -35,4 +34,4 @@ type KubbReactNode = KubbReactElement | string | number | bigint | boolean | nul
|
|
|
35
34
|
type JSDoc = ast.JSDocNode;
|
|
36
35
|
//#endregion
|
|
37
36
|
export { KubbReactNode as i, Key as n, KubbReactElement as r, JSDoc as t };
|
|
38
|
-
//# sourceMappingURL=types-
|
|
37
|
+
//# sourceMappingURL=types-BQObETlT.d.cts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ast } from "@kubb/ast";
|
|
2
|
+
//#region src/types.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Unique key for a Kubb JSX element in lists or conditional renders.
|
|
5
|
+
*/
|
|
6
|
+
type Key = string | number | bigint;
|
|
7
|
+
/**
|
|
8
|
+
* Element produced by a Kubb JSX component. The renderer walks these at runtime,
|
|
9
|
+
* so the fields stay opaque to type-checking.
|
|
10
|
+
*/
|
|
11
|
+
type KubbReactElement = {
|
|
12
|
+
/**
|
|
13
|
+
* Brand set by the JSX runtime, so the renderer only walks elements it created.
|
|
14
|
+
*/
|
|
15
|
+
$$typeof: symbol;
|
|
16
|
+
type: unknown;
|
|
17
|
+
props: unknown;
|
|
18
|
+
key: Key | null;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Anything a Kubb JSX component accepts as children: an element, a primitive
|
|
22
|
+
* rendered as text, a nullish value that is skipped, or an array of nodes.
|
|
23
|
+
*/
|
|
24
|
+
type KubbReactNode = KubbReactElement | string | number | bigint | boolean | null | undefined | ReadonlyArray<KubbReactNode>;
|
|
25
|
+
/**
|
|
26
|
+
* JSDoc comment block to attach to a generated declaration.
|
|
27
|
+
* Each string in `comments` becomes one line inside the `/** … *\/` block.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* { comments: ['@description A pet object.', '@deprecated Use PetV2 instead.'] }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
type JSDoc = ast.JSDocNode;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { KubbReactNode as i, Key as n, KubbReactElement as r, JSDoc as t };
|
|
37
|
+
//# sourceMappingURL=types-BQObETlT.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/renderer-jsx",
|
|
3
|
-
"version": "5.10.
|
|
3
|
+
"version": "5.10.3",
|
|
4
4
|
"description": "Self-contained synchronous JSX renderer for Kubb. Turns JSX into FileNodes with built-in components (File, Function, Type, Const). An alternative for the ast.factory syntax.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codegen",
|
|
@@ -58,19 +58,34 @@
|
|
|
58
58
|
},
|
|
59
59
|
"exports": {
|
|
60
60
|
".": {
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
"import": {
|
|
62
|
+
"types": "./dist/index.d.ts",
|
|
63
|
+
"default": "./dist/index.js"
|
|
64
|
+
},
|
|
65
|
+
"require": {
|
|
66
|
+
"types": "./dist/index.d.cts",
|
|
67
|
+
"default": "./dist/index.cjs"
|
|
68
|
+
}
|
|
64
69
|
},
|
|
65
70
|
"./jsx-dev-runtime": {
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
"import": {
|
|
72
|
+
"types": "./dist/jsx-dev-runtime.d.ts",
|
|
73
|
+
"default": "./dist/jsx-dev-runtime.js"
|
|
74
|
+
},
|
|
75
|
+
"require": {
|
|
76
|
+
"types": "./dist/jsx-dev-runtime.d.cts",
|
|
77
|
+
"default": "./dist/jsx-dev-runtime.cjs"
|
|
78
|
+
}
|
|
69
79
|
},
|
|
70
80
|
"./jsx-runtime": {
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
"import": {
|
|
82
|
+
"types": "./dist/jsx-runtime.d.ts",
|
|
83
|
+
"default": "./dist/jsx-runtime.js"
|
|
84
|
+
},
|
|
85
|
+
"require": {
|
|
86
|
+
"types": "./dist/jsx-runtime.d.cts",
|
|
87
|
+
"default": "./dist/jsx-runtime.cjs"
|
|
88
|
+
}
|
|
74
89
|
},
|
|
75
90
|
"./package.json": "./package.json"
|
|
76
91
|
},
|
|
@@ -79,7 +94,7 @@
|
|
|
79
94
|
"registry": "https://registry.npmjs.org/"
|
|
80
95
|
},
|
|
81
96
|
"dependencies": {
|
|
82
|
-
"@kubb/ast": "5.10.
|
|
97
|
+
"@kubb/ast": "5.10.3",
|
|
83
98
|
"yaml": "^2.9.1"
|
|
84
99
|
},
|
|
85
100
|
"engines": {
|