@kubb/renderer-jsx 0.0.0-canary-20260817183954

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 ADDED
@@ -0,0 +1,672 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("./rolldown-runtime-ClG-MNz_.cjs");
3
+ const require_jsx_runtime = require("./jsx-runtime.cjs");
4
+ let yaml = require("yaml");
5
+ let _kubb_kit = require("@kubb/kit");
6
+ //#region src/components/md/Callout.tsx
7
+ const CALLOUT_LABEL = {
8
+ tip: "TIP",
9
+ note: "NOTE",
10
+ important: "IMPORTANT",
11
+ warning: "WARNING",
12
+ caution: "CAUTION"
13
+ };
14
+ /**
15
+ * Renders a GitHub-style alert callout using the `> [!TYPE]` blockquote syntax.
16
+ *
17
+ * Emits a `<File.Source>` block containing `> [!TYPE] Title` followed by the
18
+ * body with every line prefixed by `> `.
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * <Callout type="tip">Run `kubb start --watch` to keep the generator hot.</Callout>
23
+ * // > [!TIP]
24
+ * // > Run `kubb start --watch` to keep the generator hot.
25
+ *
26
+ * <Callout type="warning" title="Heads up">Breaking change in v6.</Callout>
27
+ * // > [!WARNING] Heads up
28
+ * // > Breaking change in v6.
29
+ * ```
30
+ */
31
+ function Callout({ type, title, children }) {
32
+ const label = CALLOUT_LABEL[type];
33
+ const header = title ? `> [!${label}] ${title}` : `> [!${label}]`;
34
+ const quoted = children.trimEnd().split("\n").map((line) => line.length > 0 ? `> ${line}` : ">").join("\n");
35
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-source", {
36
+ name: "callout",
37
+ children: `${header}\n${quoted}`
38
+ });
39
+ }
40
+ Callout.displayName = "Callout";
41
+ //#endregion
42
+ //#region src/components/js/Const.tsx
43
+ /**
44
+ * Generates a TypeScript constant declaration.
45
+ *
46
+ * @example Named export with type annotation
47
+ * ```tsx
48
+ * <Const export name="petSchema" type="z.ZodType<Pet>">
49
+ * {`z.object({ id: z.number() })`}
50
+ * </Const>
51
+ * // export const petSchema: z.ZodType<Pet> = z.object({ id: z.number() })
52
+ * ```
53
+ *
54
+ * @example With JSDoc and const assertion
55
+ * ```tsx
56
+ * <Const name="HTTP_METHODS" asConst JSDoc={{ comments: ['@description Supported HTTP methods.'] }}>
57
+ * {`['GET', 'POST', 'PUT', 'DELETE']`}
58
+ * </Const>
59
+ * ```
60
+ */
61
+ function Const({ children, ...props }) {
62
+ const { name, export: canExport, type, JSDoc, asConst } = props;
63
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-const", {
64
+ name,
65
+ type,
66
+ export: canExport,
67
+ asConst,
68
+ JSDoc,
69
+ children
70
+ });
71
+ }
72
+ Const.displayName = "Const";
73
+ //#endregion
74
+ //#region src/components/File.tsx
75
+ /**
76
+ * Declares a generated file entry to be collected by the renderer.
77
+ *
78
+ * When both `baseName` and `path` are provided, the component registers a new
79
+ * `FileNode` and passes its children through as source blocks.
80
+ * When either is omitted the children are rendered inline without creating a file entry.
81
+ *
82
+ * @example Basic file with a source block
83
+ * ```tsx
84
+ * <File baseName="petStore.ts" path="src/models/petStore.ts">
85
+ * <File.Source name="Pet" isExportable isIndexable>
86
+ * {`export type Pet = { id: number; name: string }`}
87
+ * </File.Source>
88
+ * </File>
89
+ * ```
90
+ */
91
+ function File({ children, ...props }) {
92
+ const { baseName, path } = props;
93
+ if (!baseName || !path) return /* @__PURE__ */ require_jsx_runtime.jsx(require_jsx_runtime.Fragment, { children });
94
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-file", {
95
+ ...props,
96
+ children
97
+ });
98
+ }
99
+ File.displayName = "File";
100
+ /**
101
+ * Marks a block of source text to be associated with the enclosing {@link File}.
102
+ *
103
+ * Children are treated as the source string. `isExportable` prepends the `export` keyword,
104
+ * `isIndexable` includes the source in barrel/index generation, and `name` keys deduplication.
105
+ *
106
+ * @example Exportable, indexable source block
107
+ * ```tsx
108
+ * <File.Source name="Pet" isExportable isIndexable>
109
+ * {`export type Pet = { id: number; name: string }`}
110
+ * </File.Source>
111
+ * ```
112
+ *
113
+ * @example Type-only source block
114
+ * ```tsx
115
+ * <File.Source name="PetId" isTypeOnly isExportable>
116
+ * {`export type PetId = string`}
117
+ * </File.Source>
118
+ * ```
119
+ */
120
+ function FileSource({ children, ...props }) {
121
+ const { name, isExportable, isIndexable, isTypeOnly } = props;
122
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-source", {
123
+ name,
124
+ isTypeOnly,
125
+ isExportable,
126
+ isIndexable,
127
+ children
128
+ });
129
+ }
130
+ FileSource.displayName = "FileSource";
131
+ /**
132
+ * Declares an export entry for the enclosing {@link File}.
133
+ *
134
+ * The export is collected by the renderer and emitted at the top of the generated file.
135
+ *
136
+ * @example Named export
137
+ * ```tsx
138
+ * <File.Export name={['Pet']} path="./models/petStore" />
139
+ * // export { Pet } from './models/petStore'
140
+ * ```
141
+ *
142
+ * @example Type-only wildcard export
143
+ * ```tsx
144
+ * <File.Export path="./models/petStore" isTypeOnly />
145
+ * // export type * from './models/petStore'
146
+ * ```
147
+ */
148
+ function FileExport(props) {
149
+ const { name, path, isTypeOnly, asAlias } = props;
150
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-export", {
151
+ name,
152
+ path,
153
+ isTypeOnly,
154
+ asAlias
155
+ });
156
+ }
157
+ FileExport.displayName = "FileExport";
158
+ /**
159
+ * Declares an import entry for the enclosing {@link File}.
160
+ *
161
+ * The import is collected by the renderer and emitted at the top of the generated file.
162
+ *
163
+ * @example Named import
164
+ * ```tsx
165
+ * <File.Import name={['useState']} path="react" />
166
+ * // import { useState } from 'react'
167
+ * ```
168
+ *
169
+ * @example Type-only import
170
+ * ```tsx
171
+ * <File.Import name={['Pet']} path="./models" isTypeOnly />
172
+ * // import type { Pet } from './models'
173
+ * ```
174
+ *
175
+ * @example Namespace import
176
+ * ```tsx
177
+ * <File.Import name="z" path="zod" isNameSpace />
178
+ * // import * as z from 'zod'
179
+ * ```
180
+ */
181
+ function FileImport(props) {
182
+ const { name, root, path, isTypeOnly, isNameSpace } = props;
183
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-import", {
184
+ name,
185
+ root,
186
+ path,
187
+ isNameSpace,
188
+ isTypeOnly
189
+ });
190
+ }
191
+ FileImport.displayName = "FileImport";
192
+ File.Export = FileExport;
193
+ File.Import = FileImport;
194
+ File.Source = FileSource;
195
+ //#endregion
196
+ //#region src/components/md/Frontmatter.tsx
197
+ /**
198
+ * Emits a YAML frontmatter envelope at the top of a generated markdown file.
199
+ *
200
+ * Renders a `<File.Source>` block containing `---\n<yaml>\n---`. Place it as
201
+ * the first child of `<File>` so it appears at the top of the output. Pair with
202
+ * `parserMd` to write `.md` files whose frontmatter downstream tooling can read.
203
+ *
204
+ * @example Page frontmatter at the top of a generated markdown file
205
+ * ```tsx
206
+ * <File baseName="pets.md" path="src/pets.md">
207
+ * <Frontmatter data={{ title: 'Pets', layout: 'doc' }} />
208
+ * <File.Source>
209
+ * {'# Pets\n\nList of pets.'}
210
+ * </File.Source>
211
+ * </File>
212
+ * ```
213
+ */
214
+ function Frontmatter({ data }) {
215
+ const envelope = Object.keys(data).length === 0 ? "" : `---\n${(0, yaml.stringify)(data).trimEnd()}\n---`;
216
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-source", {
217
+ name: "frontmatter",
218
+ children: envelope
219
+ });
220
+ }
221
+ Frontmatter.displayName = "Frontmatter";
222
+ //#endregion
223
+ //#region src/components/js/Function.tsx
224
+ /**
225
+ * Generates a TypeScript function declaration.
226
+ *
227
+ * @example Async exported function with generics
228
+ * ```tsx
229
+ * <Function export async name="getPet" generics={['TData = Pet']} params="petId: string" returnType="TData">
230
+ * {`return client.get(\`/pets/\${petId}\`)`}
231
+ * </Function>
232
+ * // export async function getPet<TData = Pet>(petId: string): Promise<TData> {
233
+ * // return client.get(`/pets/${petId}`)
234
+ * // }
235
+ * ```
236
+ */
237
+ function Function({ children, ...props }) {
238
+ const { name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc } = props;
239
+ const genericsString = Array.isArray(generics) ? generics.join(", ").trim() : generics;
240
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-function", {
241
+ name,
242
+ params,
243
+ export: canExport,
244
+ default: isDefault,
245
+ async: isAsync,
246
+ generics: genericsString,
247
+ returnType,
248
+ JSDoc,
249
+ children
250
+ });
251
+ }
252
+ Function.displayName = "Function";
253
+ /**
254
+ * Generates an arrow function expression assigned to a `const`.
255
+ * Supports the same flags as {@link Function}.
256
+ * Use `singleLine` to render the body as a concise expression rather than a block.
257
+ *
258
+ * @example Single-line arrow function
259
+ * ```tsx
260
+ * <Function.Arrow export name="double" params="n: number" returnType="number" singleLine>
261
+ * {`n * 2`}
262
+ * </Function.Arrow>
263
+ * // export const double = (n: number): number => n * 2
264
+ * ```
265
+ */
266
+ function ArrowFunction({ children, ...props }) {
267
+ const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine } = props;
268
+ const genericsString = Array.isArray(generics) ? generics.join(", ").trim() : generics;
269
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-arrow-function", {
270
+ name,
271
+ params,
272
+ export: canExport,
273
+ default: isDefault,
274
+ async,
275
+ generics: genericsString,
276
+ returnType,
277
+ singleLine,
278
+ JSDoc,
279
+ children
280
+ });
281
+ }
282
+ ArrowFunction.displayName = "ArrowFunction";
283
+ Function.Arrow = ArrowFunction;
284
+ //#endregion
285
+ //#region src/components/md/Heading.tsx
286
+ /**
287
+ * Renders an ATX-style markdown heading.
288
+ *
289
+ * Emits a `<File.Source>` block containing `${'#'.repeat(level)} ${children}`.
290
+ * Use inside a `<File>` rendered by `parserMd`.
291
+ *
292
+ * @example
293
+ * ```tsx
294
+ * <Heading level={2}>Installation</Heading>
295
+ * // ## Installation
296
+ * ```
297
+ */
298
+ function Heading({ level, children }) {
299
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-source", {
300
+ name: "heading",
301
+ children: `${"#".repeat(level)} ${children}`
302
+ });
303
+ }
304
+ Heading.displayName = "Heading";
305
+ //#endregion
306
+ //#region src/components/jsx/Jsx.tsx
307
+ /**
308
+ * Embeds a raw JSX string verbatim in the generated source code.
309
+ *
310
+ * Use this component to include JSX markup (including fragments `<>…</>`) in the
311
+ * body of a generated function or component. The `children` prop must be a plain
312
+ * string. Write expression attributes that reference runtime values as template
313
+ * literals.
314
+ *
315
+ * @example
316
+ * ```tsx
317
+ * <Function name="MyComponent" export>
318
+ * <Jsx>{'return (\n <>\n <div>Hello</div>\n </>\n)'}</Jsx>
319
+ * </Function>
320
+ * ```
321
+ */
322
+ function Jsx({ children }) {
323
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-jsx", { children });
324
+ }
325
+ Jsx.displayName = "Jsx";
326
+ //#endregion
327
+ //#region src/components/md/List.tsx
328
+ /**
329
+ * Renders a markdown list.
330
+ *
331
+ * Emits a `<File.Source>` block containing one entry per line, prefixed with
332
+ * `1.` / `2.` … when `ordered`, or `-` otherwise.
333
+ *
334
+ * @example
335
+ * ```tsx
336
+ * <List items={['Add the parser', 'Render the page']} />
337
+ * // - Add the parser
338
+ * // - Render the page
339
+ *
340
+ * <List ordered items={['First', 'Second']} />
341
+ * // 1. First
342
+ * // 2. Second
343
+ * ```
344
+ */
345
+ function List({ ordered, items }) {
346
+ const body = items.map((item, index) => `${ordered ? `${index + 1}.` : "-"} ${item}`).join("\n");
347
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-source", {
348
+ name: "list",
349
+ children: body
350
+ });
351
+ }
352
+ List.displayName = "List";
353
+ //#endregion
354
+ //#region src/components/md/Paragraph.tsx
355
+ /**
356
+ * Renders a markdown paragraph.
357
+ *
358
+ * Emits a `<File.Source>` block containing the text as-is. Paragraphs are
359
+ * separated from surrounding blocks by blank lines via the parser's source
360
+ * joining.
361
+ *
362
+ * @example
363
+ * ```tsx
364
+ * <Paragraph>{'A pet object with `id` and `name` fields.'}</Paragraph>
365
+ * ```
366
+ */
367
+ function Paragraph({ children }) {
368
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-source", {
369
+ name: "paragraph",
370
+ children
371
+ });
372
+ }
373
+ Paragraph.displayName = "Paragraph";
374
+ //#endregion
375
+ //#region src/components/js/Type.tsx
376
+ /**
377
+ * Generates a TypeScript type alias declaration.
378
+ *
379
+ * Throws if `name` does not start with an uppercase letter. TypeScript type aliases
380
+ * should follow PascalCase naming conventions.
381
+ *
382
+ * @example Simple exported type alias
383
+ * ```tsx
384
+ * <Type export name="PetId">
385
+ * {`string | number`}
386
+ * </Type>
387
+ * // export type PetId = string | number
388
+ * ```
389
+ *
390
+ * @example Type alias with JSDoc
391
+ * ```tsx
392
+ * <Type export name="Pet" JSDoc={{ comments: ['@description A pet in the store.'] }}>
393
+ * {`{ id: number; name: string }`}
394
+ * </Type>
395
+ * ```
396
+ */
397
+ function Type({ children, ...props }) {
398
+ const { name, export: canExport, JSDoc } = props;
399
+ if (name.charAt(0).toUpperCase() !== name.charAt(0)) throw new Error("Name should start with a capital letter(see TypeScript types)");
400
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-type", {
401
+ name,
402
+ export: canExport,
403
+ JSDoc,
404
+ children
405
+ });
406
+ }
407
+ Type.displayName = "Type";
408
+ //#endregion
409
+ //#region src/Runtime.tsx
410
+ /**
411
+ * Walks `element`, resolving arrays, Fragments, and function components, then
412
+ * calls `onText` for primitive values and `onHost` for each host element.
413
+ * Function components are called synchronously. Hooks and class components are
414
+ * not supported.
415
+ */
416
+ function walkElement(element, onText, onHost) {
417
+ if (element == null || typeof element === "boolean") return;
418
+ if (typeof element === "string" || typeof element === "number" || typeof element === "bigint") {
419
+ onText(String(element));
420
+ return;
421
+ }
422
+ if (Array.isArray(element)) {
423
+ for (const child of element) walkElement(child, onText, onHost);
424
+ return;
425
+ }
426
+ if (typeof element === "object" && "$$typeof" in element) {
427
+ const el = element;
428
+ const { type } = el;
429
+ const props = el.props;
430
+ if (type === require_jsx_runtime.Fragment) {
431
+ walkElement(props["children"], onText, onHost);
432
+ return;
433
+ }
434
+ if (typeof type === "function") {
435
+ walkElement(type(props), onText, onHost);
436
+ return;
437
+ }
438
+ if (typeof type === "string") onHost(type, props);
439
+ }
440
+ }
441
+ function collectCodeNodes(props) {
442
+ const nodes = [];
443
+ collectCode(props["children"], nodes);
444
+ return nodes;
445
+ }
446
+ function collectCode(element, nodes) {
447
+ walkElement(element, (text) => {
448
+ if (text.trim()) nodes.push(_kubb_kit.ast.factory.createText(text));
449
+ }, (type, props) => resolveCodeNode(type, props, nodes));
450
+ }
451
+ function resolveCodeNode(type, props, nodes) {
452
+ if (type === "br") {
453
+ nodes.push(_kubb_kit.ast.factory.createBreak());
454
+ return;
455
+ }
456
+ if (type === "kubb-jsx") {
457
+ let value = "";
458
+ walkElement(props["children"], (t) => {
459
+ value += t;
460
+ }, () => {});
461
+ if (value) nodes.push(_kubb_kit.ast.factory.createJsx(value));
462
+ return;
463
+ }
464
+ if (type === "kubb-function") {
465
+ nodes.push(_kubb_kit.ast.factory.createFunction({
466
+ name: props["name"],
467
+ params: props["params"],
468
+ export: props["export"],
469
+ default: props["default"],
470
+ async: props["async"],
471
+ generics: props["generics"],
472
+ returnType: props["returnType"],
473
+ JSDoc: props["JSDoc"],
474
+ nodes: collectCodeNodes(props)
475
+ }));
476
+ return;
477
+ }
478
+ if (type === "kubb-arrow-function") {
479
+ nodes.push(_kubb_kit.ast.factory.createArrowFunction({
480
+ name: props["name"],
481
+ params: props["params"],
482
+ export: props["export"],
483
+ default: props["default"],
484
+ async: props["async"],
485
+ generics: props["generics"],
486
+ returnType: props["returnType"],
487
+ singleLine: props["singleLine"],
488
+ JSDoc: props["JSDoc"],
489
+ nodes: collectCodeNodes(props)
490
+ }));
491
+ return;
492
+ }
493
+ if (type === "kubb-const") {
494
+ nodes.push(_kubb_kit.ast.factory.createConst({
495
+ name: props["name"],
496
+ type: props["type"],
497
+ export: props["export"],
498
+ asConst: props["asConst"],
499
+ JSDoc: props["JSDoc"],
500
+ nodes: collectCodeNodes(props)
501
+ }));
502
+ return;
503
+ }
504
+ if (type === "kubb-type") {
505
+ nodes.push(_kubb_kit.ast.factory.createType({
506
+ name: props["name"],
507
+ export: props["export"],
508
+ JSDoc: props["JSDoc"],
509
+ nodes: collectCodeNodes(props)
510
+ }));
511
+ return;
512
+ }
513
+ }
514
+ function collectFileChildren(element) {
515
+ const sources = [];
516
+ const exports = [];
517
+ const imports = [];
518
+ walkElement(element, (text) => {
519
+ if (text.trim()) throw new Error(`[jsx] '${text}' should be part of <File.Source> component when using the <File/> component`);
520
+ }, (type, props) => {
521
+ if (type === "kubb-source") {
522
+ sources.push(_kubb_kit.ast.factory.createSource({
523
+ name: props["name"]?.toString(),
524
+ isTypeOnly: !!props["isTypeOnly"],
525
+ isExportable: !!props["isExportable"],
526
+ isIndexable: !!props["isIndexable"],
527
+ nodes: collectCodeNodes(props)
528
+ }));
529
+ return;
530
+ }
531
+ if (type === "kubb-export") {
532
+ exports.push(_kubb_kit.ast.factory.createExport({
533
+ name: props["name"],
534
+ path: props["path"],
535
+ isTypeOnly: !!props["isTypeOnly"],
536
+ asAlias: !!props["asAlias"]
537
+ }));
538
+ return;
539
+ }
540
+ if (type === "kubb-import") {
541
+ imports.push(_kubb_kit.ast.factory.createImport({
542
+ name: props["name"],
543
+ path: props["path"],
544
+ root: props["root"],
545
+ isTypeOnly: !!props["isTypeOnly"],
546
+ isNameSpace: !!props["isNameSpace"]
547
+ }));
548
+ return;
549
+ }
550
+ const nested = collectFileChildren(props["children"]);
551
+ sources.push(...nested.sources);
552
+ exports.push(...nested.exports);
553
+ imports.push(...nested.imports);
554
+ });
555
+ return {
556
+ sources,
557
+ exports,
558
+ imports
559
+ };
560
+ }
561
+ function* walkFiles(element) {
562
+ if (element == null || typeof element === "boolean") return;
563
+ if (typeof element === "string" || typeof element === "number" || typeof element === "bigint") return;
564
+ if (Array.isArray(element)) {
565
+ for (const child of element) yield* walkFiles(child);
566
+ return;
567
+ }
568
+ if (typeof element === "object" && "$$typeof" in element) {
569
+ const el = element;
570
+ const { type } = el;
571
+ const props = el.props;
572
+ if (type === require_jsx_runtime.Fragment) {
573
+ yield* walkFiles(props["children"]);
574
+ return;
575
+ }
576
+ if (typeof type === "function") {
577
+ yield* walkFiles(type(props));
578
+ return;
579
+ }
580
+ if (typeof type === "string") if (type === "kubb-file" && props["baseName"] !== void 0 && props["path"] !== void 0) {
581
+ const { sources, exports, imports } = collectFileChildren(props["children"]);
582
+ yield {
583
+ baseName: props["baseName"],
584
+ path: props["path"],
585
+ meta: props["meta"] || {},
586
+ footer: props["footer"],
587
+ banner: props["banner"],
588
+ copy: props["copy"],
589
+ sources,
590
+ exports,
591
+ imports
592
+ };
593
+ } else yield* walkFiles(props["children"]);
594
+ }
595
+ }
596
+ /**
597
+ * Synchronous JSX renderer that walks the element tree in a single pass,
598
+ * producing {@link ast.FileNode} objects directly without an intermediate virtual
599
+ * DOM. No React fiber, scheduler, or work loop is involved.
600
+ *
601
+ * All components must be pure functions. Hooks and class components are not
602
+ * supported.
603
+ */
604
+ var Runtime = class {
605
+ /**
606
+ * Accumulated {@link ast.FileNode} results from every {@link render} call.
607
+ */
608
+ nodes = [];
609
+ /**
610
+ * Walks `element` synchronously, converts every `<kubb-file>` subtree into
611
+ * a {@link ast.FileNode} with no intermediate virtual DOM, and appends the results
612
+ * to {@link nodes}.
613
+ */
614
+ render(element) {
615
+ for (const file of walkFiles(element)) this.nodes.push(file);
616
+ }
617
+ };
618
+ //#endregion
619
+ //#region src/jsxRenderer.tsx
620
+ /**
621
+ * Factory for a renderer that walks the JSX tree in a single recursive pass,
622
+ * with no React reconciler or scheduler. Pass it as the `renderer` property on
623
+ * `defineGenerator`. Kubb core calls the factory once per render cycle and stays
624
+ * generic, with no hard dependency on `@kubb/renderer-jsx`.
625
+ *
626
+ * Every component must be a pure function. Hooks, suspense, and class
627
+ * components are not supported.
628
+ *
629
+ * @example Wire up a JSX generator
630
+ * ```tsx
631
+ * import { defineGenerator } from '@kubb/core'
632
+ * import { jsxRenderer } from '@kubb/renderer-jsx'
633
+ *
634
+ * export const myGenerator = defineGenerator<PluginTs>({
635
+ * name: 'types',
636
+ * renderer: jsxRenderer,
637
+ * schema(node, ctx) {
638
+ * return (
639
+ * <File baseName="output.ts" path={`${ctx.root}/output.ts`}>
640
+ * <Type node={node} resolver={ctx.resolver} />
641
+ * </File>
642
+ * )
643
+ * },
644
+ * })
645
+ * ```
646
+ */
647
+ const jsxRenderer = () => {
648
+ const runtime = new Runtime();
649
+ return {
650
+ async render(element) {
651
+ runtime.render(element);
652
+ },
653
+ get files() {
654
+ return runtime.nodes;
655
+ },
656
+ [Symbol.dispose]() {}
657
+ };
658
+ };
659
+ //#endregion
660
+ exports.Callout = Callout;
661
+ exports.Const = Const;
662
+ exports.File = File;
663
+ exports.Frontmatter = Frontmatter;
664
+ exports.Function = Function;
665
+ exports.Heading = Heading;
666
+ exports.Jsx = Jsx;
667
+ exports.List = List;
668
+ exports.Paragraph = Paragraph;
669
+ exports.Type = Type;
670
+ exports.jsxRenderer = jsxRenderer;
671
+
672
+ //# sourceMappingURL=index.cjs.map