@kubb/renderer-jsx 5.0.0-alpha.34 → 5.0.0-alpha.36

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.
@@ -9,7 +9,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
9
  var __getOwnPropNames = Object.getOwnPropertyNames;
10
10
  var __getProtoOf = Object.getPrototypeOf;
11
11
  var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
12
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
13
13
  var __copyProps = (to, from, except, desc) => {
14
14
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
15
  key = keys[i];
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_jsx_runtime = require("./jsx-runtime-CeMde2cR.cjs");
2
+ const require_jsx_runtime = require("./jsx-runtime-Dnd1wztY.cjs");
3
3
  const require_jsx_runtime$1 = require("./jsx-runtime.cjs");
4
4
  let _kubb_ast = require("@kubb/ast");
5
5
  //#region ../../internals/utils/src/context.ts
@@ -109,6 +109,21 @@ function onProcessExit(callback) {
109
109
  //#region src/components/Const.tsx
110
110
  /**
111
111
  * Generates a TypeScript constant declaration.
112
+ *
113
+ * @example Named export with type annotation
114
+ * ```tsx
115
+ * <Const export name="petSchema" type="z.ZodType<Pet>">
116
+ * {`z.object({ id: z.number() })`}
117
+ * </Const>
118
+ * // export const petSchema: z.ZodType<Pet> = z.object({ id: z.number() })
119
+ * ```
120
+ *
121
+ * @example With JSDoc and const assertion
122
+ * ```tsx
123
+ * <Const name="HTTP_METHODS" asConst JSDoc={{ comments: ['@description Supported HTTP methods.'] }}>
124
+ * {`['GET', 'POST', 'PUT', 'DELETE']`}
125
+ * </Const>
126
+ * ```
112
127
  */
113
128
  function Const({ children, ...props }) {
114
129
  const { name, export: canExport, type, JSDoc, asConst } = props;
@@ -125,7 +140,20 @@ Const.displayName = "Const";
125
140
  //#endregion
126
141
  //#region src/components/File.tsx
127
142
  /**
128
- * Adds files to the FileManager
143
+ * Declares a generated file entry to be collected by the renderer.
144
+ *
145
+ * When both `baseName` and `path` are provided, the component registers a new
146
+ * `FileNode` and passes its children through as source blocks.
147
+ * When either is omitted the children are rendered inline without creating a file entry.
148
+ *
149
+ * @example Basic file with a source block
150
+ * ```tsx
151
+ * <File baseName="petStore.ts" path="src/models/petStore.ts">
152
+ * <File.Source name="Pet" isExportable isIndexable>
153
+ * {`export type Pet = { id: number; name: string }`}
154
+ * </File.Source>
155
+ * </File>
156
+ * ```
129
157
  */
130
158
  function File({ children, ...props }) {
131
159
  const { baseName, path } = props;
@@ -137,10 +165,24 @@ function File({ children, ...props }) {
137
165
  }
138
166
  File.displayName = "File";
139
167
  /**
140
- * File.Source
168
+ * Marks a block of source text to be associated with the enclosing {@link File}.
169
+ *
170
+ * Children are treated as the source string. When `isExportable` is `true` the
171
+ * `name` is used for deduplication and barrel generation.
172
+ *
173
+ * @example Exportable, indexable source block
174
+ * ```tsx
175
+ * <File.Source name="Pet" isExportable isIndexable>
176
+ * {`export type Pet = { id: number; name: string }`}
177
+ * </File.Source>
178
+ * ```
141
179
  *
142
- * Marks a block of source text to be associated with the current file when
143
- * rendering with the FileCollector. Children are treated as the source string.
180
+ * @example Type-only source block
181
+ * ```tsx
182
+ * <File.Source name="PetId" isTypeOnly isExportable>
183
+ * {`export type PetId = string`}
184
+ * </File.Source>
185
+ * ```
144
186
  */
145
187
  function FileSource({ children, ...props }) {
146
188
  const { name, isExportable, isIndexable, isTypeOnly } = props;
@@ -154,10 +196,21 @@ function FileSource({ children, ...props }) {
154
196
  }
155
197
  FileSource.displayName = "FileSource";
156
198
  /**
157
- * File.Export
199
+ * Declares an export entry for the enclosing {@link File}.
158
200
  *
159
- * Declares an export entry for the current file. This will be collected by
160
- * the FileCollector for later emission.
201
+ * The export is collected by the renderer and emitted at the top of the generated file.
202
+ *
203
+ * @example Named export
204
+ * ```tsx
205
+ * <File.Export name={['Pet']} path="./models/petStore" />
206
+ * // export { Pet } from './models/petStore'
207
+ * ```
208
+ *
209
+ * @example Type-only wildcard export
210
+ * ```tsx
211
+ * <File.Export path="./models/petStore" isTypeOnly />
212
+ * // export type * from './models/petStore'
213
+ * ```
161
214
  */
162
215
  function FileExport(props) {
163
216
  const { name, path, isTypeOnly, asAlias } = props;
@@ -170,9 +223,27 @@ function FileExport(props) {
170
223
  }
171
224
  FileExport.displayName = "FileExport";
172
225
  /**
173
- * File.Import
226
+ * Declares an import entry for the enclosing {@link File}.
227
+ *
228
+ * The import is collected by the renderer and emitted at the top of the generated file.
174
229
  *
175
- * Declares an import entry for the current file.
230
+ * @example Named import
231
+ * ```tsx
232
+ * <File.Import name={['useState']} path="react" />
233
+ * // import { useState } from 'react'
234
+ * ```
235
+ *
236
+ * @example Type-only import
237
+ * ```tsx
238
+ * <File.Import name={['Pet']} path="./models" isTypeOnly />
239
+ * // import type { Pet } from './models'
240
+ * ```
241
+ *
242
+ * @example Namespace import
243
+ * ```tsx
244
+ * <File.Import name="z" path="zod" isNameSpace />
245
+ * // import * as z from 'zod'
246
+ * ```
176
247
  */
177
248
  function FileImport(props) {
178
249
  const { name, root, path, isTypeOnly, isNameSpace } = props;
@@ -192,6 +263,16 @@ File.Source = FileSource;
192
263
  //#region src/components/Function.tsx
193
264
  /**
194
265
  * Generates a TypeScript function declaration.
266
+ *
267
+ * @example Async exported function with generics
268
+ * ```tsx
269
+ * <Function export async name="getPet" generics={['TData = Pet']} params="petId: string" returnType="TData">
270
+ * {`return client.get(\`/pets/\${petId}\`)`}
271
+ * </Function>
272
+ * // export async function getPet<TData = Pet>(petId: string): Promise<TData> {
273
+ * // return client.get(`/pets/${petId}`)
274
+ * // }
275
+ * ```
195
276
  */
196
277
  function Function$1({ children, ...props }) {
197
278
  const { name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc } = props;
@@ -210,10 +291,17 @@ function Function$1({ children, ...props }) {
210
291
  require_jsx_runtime.__name(Function$1, "Function");
211
292
  Function$1.displayName = "Function";
212
293
  /**
213
- * ArrowFunction
294
+ * Generates an arrow function expression assigned to a `const`.
295
+ * Supports the same flags as {@link Function}.
296
+ * Use `singleLine` to render the body as a concise expression rather than a block.
214
297
  *
215
- * Renders an arrow function definition. Supports the same flags as `Function`.
216
- * Use `singleLine` to render the body as a single-line expression.
298
+ * @example Single-line arrow function
299
+ * ```tsx
300
+ * <Function.Arrow export name="double" params="n: number" returnType="number" singleLine>
301
+ * {`n * 2`}
302
+ * </Function.Arrow>
303
+ * // export const double = (n: number): number => n * 2
304
+ * ```
217
305
  */
218
306
  function ArrowFunction({ children, ...props }) {
219
307
  const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine } = props;
@@ -271,7 +359,10 @@ var ErrorBoundary = class extends import_react.Component {
271
359
  }
272
360
  };
273
361
  /**
274
- * This component provides the root behavior for the Kubb runtime.
362
+ * Root component for the Kubb renderer tree.
363
+ *
364
+ * Wraps all children in an `ErrorBoundary` so that render errors are caught
365
+ * and forwarded to `onError` rather than crashing the process.
275
366
  */
276
367
  function Root({ onError, children }) {
277
368
  return /* @__PURE__ */ require_jsx_runtime$1.jsx(ErrorBoundary, {
@@ -285,7 +376,25 @@ Root.displayName = "Root";
285
376
  //#endregion
286
377
  //#region src/components/Type.tsx
287
378
  /**
288
- * Generates a TypeScript type declaration.
379
+ * Generates a TypeScript type alias declaration.
380
+ *
381
+ * Throws if `name` does not start with an uppercase letter — TypeScript type aliases
382
+ * should follow PascalCase naming conventions.
383
+ *
384
+ * @example Simple exported type alias
385
+ * ```tsx
386
+ * <Type export name="PetId">
387
+ * {`string | number`}
388
+ * </Type>
389
+ * // export type PetId = string | number
390
+ * ```
391
+ *
392
+ * @example Type alias with JSDoc
393
+ * ```tsx
394
+ * <Type export name="Pet" JSDoc={{ comments: ['@description A pet in the store.'] }}>
395
+ * {`{ id: number; name: string }`}
396
+ * </Type>
397
+ * ```
289
398
  */
290
399
  function Type({ children, ...props }) {
291
400
  const { name, export: canExport, JSDoc } = props;
@@ -351,11 +460,42 @@ var require_react_reconciler_constants_development = /* @__PURE__ */ require_jsx
351
460
  "production" !== process.env.NODE_ENV && (exports.ConcurrentRoot = 1, exports.ContinuousEventPriority = 8, exports.DefaultEventPriority = 32, exports.DiscreteEventPriority = 2, exports.IdleEventPriority = 268435456, exports.LegacyRoot = 0, exports.NoEventPriority = 0);
352
461
  }));
353
462
  //#endregion
354
- //#region src/dom.ts
463
+ //#region src/constants.ts
355
464
  var import_constants = (/* @__PURE__ */ require_jsx_runtime.__commonJSMin(((exports, module) => {
356
465
  if (process.env.NODE_ENV === "production") module.exports = require_react_reconciler_constants_production();
357
466
  else module.exports = require_react_reconciler_constants_development();
358
467
  })))();
468
+ /**
469
+ * Name used for text-node entries in the virtual DOM.
470
+ */
471
+ const TEXT_NODE_NAME = "#text";
472
+ /**
473
+ * Set of all element names recognized by the Kubb renderer.
474
+ * Used to distinguish Kubb-owned elements from unrecognized or text nodes during tree traversal.
475
+ */
476
+ const nodeNames = new Set([
477
+ "kubb-export",
478
+ "kubb-file",
479
+ "kubb-source",
480
+ "kubb-import",
481
+ "kubb-function",
482
+ "kubb-arrow-function",
483
+ "kubb-const",
484
+ "kubb-type",
485
+ "kubb-jsx",
486
+ "kubb-text",
487
+ "kubb-root",
488
+ "kubb-app",
489
+ "br",
490
+ "indent",
491
+ "dedent"
492
+ ]);
493
+ //#endregion
494
+ //#region src/dom.ts
495
+ /**
496
+ * Create a new, empty {@link DOMElement} with the given node name.
497
+ * The element has no attributes, no children, and no parent.
498
+ */
359
499
  const createNode = (nodeName) => {
360
500
  return {
361
501
  nodeName,
@@ -364,6 +504,13 @@ const createNode = (nodeName) => {
364
504
  parentNode: void 0
365
505
  };
366
506
  };
507
+ /**
508
+ * Append `childNode` as the last child of `node`.
509
+ *
510
+ * If `childNode` already has a parent, it is removed from that parent first
511
+ * (matching standard DOM move semantics).
512
+ * Text nodes (`nodeName === '#text'`) are silently ignored.
513
+ */
367
514
  const appendChildNode = (node, childNode) => {
368
515
  if (childNode.parentNode) removeChildNode(childNode.parentNode, childNode);
369
516
  if (node.nodeName !== "#text") {
@@ -371,6 +518,12 @@ const appendChildNode = (node, childNode) => {
371
518
  node.childNodes.push(childNode);
372
519
  }
373
520
  };
521
+ /**
522
+ * Insert `newChildNode` before `beforeChildNode` in `node`'s child list.
523
+ *
524
+ * If `newChildNode` already has a parent, it is removed from that parent first.
525
+ * If `beforeChildNode` is not found, `newChildNode` is appended at the end.
526
+ */
374
527
  const insertBeforeNode = (node, newChildNode, beforeChildNode) => {
375
528
  if (newChildNode.parentNode) removeChildNode(newChildNode.parentNode, newChildNode);
376
529
  newChildNode.parentNode = node;
@@ -381,44 +534,41 @@ const insertBeforeNode = (node, newChildNode, beforeChildNode) => {
381
534
  }
382
535
  node.childNodes.push(newChildNode);
383
536
  };
537
+ /**
538
+ * Remove `removeNode` from `node`'s child list and clear its `parentNode` reference.
539
+ * Does nothing if `removeNode` is not a direct child of `node`.
540
+ */
384
541
  const removeChildNode = (node, removeNode) => {
385
542
  removeNode.parentNode = void 0;
386
543
  const index = node.childNodes.indexOf(removeNode);
387
544
  if (index >= 0) node.childNodes.splice(index, 1);
388
545
  };
546
+ /**
547
+ * Set an attribute on `node`, storing it in the node's `attributes` map.
548
+ */
389
549
  const setAttribute = (node, key, value) => {
390
550
  node.attributes.set(key, value);
391
551
  };
552
+ /**
553
+ * Create a new {@link TextNode} with the given text value.
554
+ */
392
555
  const createTextNode = (text) => {
393
556
  const node = {
394
- nodeName: "#text",
557
+ nodeName: TEXT_NODE_NAME,
395
558
  nodeValue: text,
396
559
  parentNode: void 0
397
560
  };
398
561
  setTextNodeValue(node, text);
399
562
  return node;
400
563
  };
564
+ /**
565
+ * Update the `nodeValue` of an existing {@link TextNode}.
566
+ * Non-string values are coerced to strings via `String(text)`.
567
+ */
401
568
  const setTextNodeValue = (node, text) => {
402
569
  if (typeof text !== "string") text = String(text);
403
570
  node.nodeValue = text;
404
571
  };
405
- const nodeNames = new Set([
406
- "kubb-export",
407
- "kubb-file",
408
- "kubb-source",
409
- "kubb-import",
410
- "kubb-function",
411
- "kubb-arrow-function",
412
- "kubb-const",
413
- "kubb-type",
414
- "kubb-jsx",
415
- "kubb-text",
416
- "kubb-root",
417
- "kubb-app",
418
- "br",
419
- "indent",
420
- "dedent"
421
- ]);
422
572
  //#endregion
423
573
  //#region ../../node_modules/.pnpm/scheduler@0.27.0/node_modules/scheduler/cjs/scheduler.production.js
424
574
  /**
@@ -17723,7 +17873,7 @@ const Renderer = (0, import_react_reconciler.default)({
17723
17873
  },
17724
17874
  getCurrentUpdatePriority: () => currentUpdatePriority,
17725
17875
  resolveUpdatePriority() {
17726
- if (currentUpdatePriority !== 0) return currentUpdatePriority;
17876
+ if (currentUpdatePriority !== import_constants.NoEventPriority) return currentUpdatePriority;
17727
17877
  return import_constants.DefaultEventPriority;
17728
17878
  },
17729
17879
  maySuspendCommit() {
@@ -17756,8 +17906,10 @@ const Renderer = (0, import_react_reconciler.default)({
17756
17906
  //#region src/utils.ts
17757
17907
  /**
17758
17908
  * Collect the text and nested AST-node children of a single kubb-* element.
17759
- * `#text` children become raw strings; nested kubb-function/const/type children
17760
- * become their respective {@link CodeNode}s. Other DOM elements are skipped.
17909
+ *
17910
+ * `#text` children become raw {@link TextNode}s; nested `kubb-function`, `kubb-const`,
17911
+ * `kubb-type`, and similar elements are converted into their respective {@link CodeNode}s.
17912
+ * Any unrecognized DOM elements are silently skipped.
17761
17913
  */
17762
17914
  function collectChildNodes(element) {
17763
17915
  const result = [];
@@ -17825,6 +17977,17 @@ function collectChildNodes(element) {
17825
17977
  }
17826
17978
  return result;
17827
17979
  }
17980
+ /**
17981
+ * Traverse `node` and collect all `<kubb-source>` elements into a `Set<SourceNode>`.
17982
+ *
17983
+ * Elements whose `nodeName` is in `ignores` are skipped entirely (including their subtrees).
17984
+ * This is used to collect source blocks from a file node while excluding import/export subtrees.
17985
+ *
17986
+ * @example Collect sources while ignoring export and import elements
17987
+ * ```ts
17988
+ * const sources = squashSourceNodes(fileElement, ['kubb-export', 'kubb-import'])
17989
+ * ```
17990
+ */
17828
17991
  function squashSourceNodes(node, ignores) {
17829
17992
  const ignoreSet = new Set(ignores);
17830
17993
  const sources = /* @__PURE__ */ new Set();
@@ -17833,70 +17996,12 @@ function squashSourceNodes(node, ignores) {
17833
17996
  if (!child) continue;
17834
17997
  if (child.nodeName !== "#text" && ignoreSet.has(child.nodeName)) continue;
17835
17998
  if (child.nodeName === "kubb-source") {
17836
- const orderedNodes = [];
17837
- for (const c of child.childNodes) {
17838
- if (!c) continue;
17839
- if (c.nodeName === "#text") {
17840
- const text = c.nodeValue;
17841
- if (text && text.trim().length > 0) orderedNodes.push((0, _kubb_ast.createText)(text));
17842
- } else if (c.nodeName === "br") orderedNodes.push((0, _kubb_ast.createBreak)());
17843
- else if (c.nodeName === "kubb-function") {
17844
- const attrs = c.attributes;
17845
- orderedNodes.push((0, _kubb_ast.createFunction)({
17846
- name: attrs.get("name"),
17847
- params: attrs.get("params"),
17848
- export: attrs.get("export"),
17849
- default: attrs.get("default"),
17850
- async: attrs.get("async"),
17851
- generics: attrs.get("generics"),
17852
- returnType: attrs.get("returnType"),
17853
- JSDoc: attrs.get("JSDoc"),
17854
- nodes: collectChildNodes(c)
17855
- }));
17856
- } else if (c.nodeName === "kubb-arrow-function") {
17857
- const attrs = c.attributes;
17858
- orderedNodes.push((0, _kubb_ast.createArrowFunction)({
17859
- name: attrs.get("name"),
17860
- params: attrs.get("params"),
17861
- export: attrs.get("export"),
17862
- default: attrs.get("default"),
17863
- async: attrs.get("async"),
17864
- generics: attrs.get("generics"),
17865
- returnType: attrs.get("returnType"),
17866
- singleLine: attrs.get("singleLine"),
17867
- JSDoc: attrs.get("JSDoc"),
17868
- nodes: collectChildNodes(c)
17869
- }));
17870
- } else if (c.nodeName === "kubb-const") {
17871
- const attrs = c.attributes;
17872
- orderedNodes.push((0, _kubb_ast.createConst)({
17873
- name: attrs.get("name"),
17874
- type: attrs.get("type"),
17875
- export: attrs.get("export"),
17876
- asConst: attrs.get("asConst"),
17877
- JSDoc: attrs.get("JSDoc"),
17878
- nodes: collectChildNodes(c)
17879
- }));
17880
- } else if (c.nodeName === "kubb-type") {
17881
- const attrs = c.attributes;
17882
- orderedNodes.push((0, _kubb_ast.createType)({
17883
- name: attrs.get("name"),
17884
- export: attrs.get("export"),
17885
- JSDoc: attrs.get("JSDoc"),
17886
- nodes: collectChildNodes(c)
17887
- }));
17888
- } else if (c.nodeName === "kubb-jsx") {
17889
- const textChild = c.childNodes[0];
17890
- const value = textChild?.nodeName === "#text" ? textChild.nodeValue : "";
17891
- if (value) orderedNodes.push((0, _kubb_ast.createJsx)(value));
17892
- }
17893
- }
17894
17999
  const source = (0, _kubb_ast.createSource)({
17895
18000
  name: child.attributes.get("name")?.toString(),
17896
18001
  isTypeOnly: child.attributes.get("isTypeOnly") ?? false,
17897
18002
  isExportable: child.attributes.get("isExportable") ?? false,
17898
18003
  isIndexable: child.attributes.get("isIndexable") ?? false,
17899
- nodes: orderedNodes
18004
+ nodes: collectChildNodes(child)
17900
18005
  });
17901
18006
  sources.add(source);
17902
18007
  continue;
@@ -17907,47 +18012,60 @@ function squashSourceNodes(node, ignores) {
17907
18012
  walk(node);
17908
18013
  return sources;
17909
18014
  }
18015
+ /**
18016
+ * Traverse `node` and collect all `<kubb-export>` elements into a `Set<ExportNode>`.
18017
+ */
17910
18018
  function squashExportNodes(node) {
17911
18019
  const exports = /* @__PURE__ */ new Set();
17912
18020
  const walk = (current) => {
17913
18021
  for (const child of current.childNodes) {
17914
18022
  if (!child) continue;
17915
18023
  if (child.nodeName !== "#text" && nodeNames.has(child.nodeName)) walk(child);
17916
- if (child.nodeName === "kubb-export") exports.add({
18024
+ if (child.nodeName === "kubb-export") exports.add((0, _kubb_ast.createExport)({
17917
18025
  name: child.attributes.get("name"),
17918
18026
  path: child.attributes.get("path"),
17919
18027
  isTypeOnly: child.attributes.get("isTypeOnly") ?? false,
17920
18028
  asAlias: child.attributes.get("asAlias") ?? false
17921
- });
18029
+ }));
17922
18030
  }
17923
18031
  };
17924
18032
  walk(node);
17925
18033
  return exports;
17926
18034
  }
18035
+ /**
18036
+ * Traverse `node` and collect all `<kubb-import>` elements into a `Set<ImportNode>`.
18037
+ */
17927
18038
  function squashImportNodes(node) {
17928
18039
  const imports = /* @__PURE__ */ new Set();
17929
18040
  const walk = (current) => {
17930
18041
  for (const child of current.childNodes) {
17931
18042
  if (!child) continue;
17932
18043
  if (child.nodeName !== "#text" && nodeNames.has(child.nodeName)) walk(child);
17933
- if (child.nodeName === "kubb-import") imports.add({
18044
+ if (child.nodeName === "kubb-import") imports.add((0, _kubb_ast.createImport)({
17934
18045
  name: child.attributes.get("name"),
17935
18046
  path: child.attributes.get("path"),
17936
18047
  root: child.attributes.get("root"),
17937
18048
  isTypeOnly: child.attributes.get("isTypeOnly") ?? false,
17938
18049
  isNameSpace: child.attributes.get("isNameSpace") ?? false
17939
- });
18050
+ }));
17940
18051
  }
17941
18052
  };
17942
18053
  walk(node);
17943
18054
  return imports;
17944
18055
  }
17945
- async function processFiles(node) {
18056
+ /**
18057
+ * Walk the virtual DOM tree rooted at `node` and convert every `<kubb-file>` element
18058
+ * into a {@link FileNode}, collecting its source blocks, imports, and exports.
18059
+ *
18060
+ * Returns the list of file nodes in document order. Nested files are supported —
18061
+ * the walker descends into non-file elements and recurses through them.
18062
+ */
18063
+ function processFiles(node) {
17946
18064
  const collected = [];
17947
- async function walk(current) {
18065
+ function walk(current) {
17948
18066
  for (const child of current.childNodes) {
17949
18067
  if (!child) continue;
17950
- if (child.nodeName !== "#text" && child.nodeName !== "kubb-file" && nodeNames.has(child.nodeName)) await walk(child);
18068
+ if (child.nodeName !== "#text" && child.nodeName !== "kubb-file" && nodeNames.has(child.nodeName)) walk(child);
17951
18069
  if (child.nodeName === "kubb-file") {
17952
18070
  if (child.attributes.has("baseName") && child.attributes.has("path")) {
17953
18071
  const sources = squashSourceNodes(child, ["kubb-export", "kubb-import"]);
@@ -17965,7 +18083,7 @@ async function processFiles(node) {
17965
18083
  }
17966
18084
  }
17967
18085
  }
17968
- await walk(node);
18086
+ walk(node);
17969
18087
  return collected;
17970
18088
  }
17971
18089
  //#endregion
@@ -18002,12 +18120,13 @@ var Runtime = class {
18002
18120
  rejectExitPromise = () => {};
18003
18121
  unsubscribeExit = () => {};
18004
18122
  onRender = () => {
18005
- this.#renderPromise = this.#renderPromise.catch(() => {}).then(async () => {
18123
+ const task = this.#renderPromise.catch(() => {}).then(() => {
18006
18124
  if (this.#isUnmounted) return;
18007
- const files = await processFiles(this.#rootNode);
18125
+ const files = processFiles(this.#rootNode);
18008
18126
  this.nodes.push(...files);
18009
18127
  if (!this.#options?.debug) return;
18010
- }).catch((error) => {
18128
+ });
18129
+ this.#renderPromise = task.catch((error) => {
18011
18130
  this.onError(error);
18012
18131
  });
18013
18132
  return this.#renderPromise;
@@ -18058,6 +18177,28 @@ var Runtime = class {
18058
18177
  };
18059
18178
  //#endregion
18060
18179
  //#region src/createRenderer.tsx
18180
+ /**
18181
+ * Create a Kubb JSX renderer.
18182
+ *
18183
+ * The renderer converts a React JSX element tree — built from the components in this
18184
+ * package — into an array of {@link FileNode} entries representing the generated files.
18185
+ *
18186
+ * @example Basic usage
18187
+ * ```ts
18188
+ * import { createRenderer, File } from '@kubb/renderer-jsx'
18189
+ *
18190
+ * const renderer = createRenderer()
18191
+ * await renderer.render(
18192
+ * <File baseName="pet.ts" path="src/models/pet.ts">
18193
+ * <File.Source name="Pet" isExportable isIndexable>
18194
+ * {`export type Pet = { id: number; name: string }`}
18195
+ * </File.Source>
18196
+ * </File>
18197
+ * )
18198
+ * console.log(renderer.files) // [FileNode]
18199
+ * renderer.unmount()
18200
+ * ```
18201
+ */
18061
18202
  function createRenderer(options = {}) {
18062
18203
  const runtime = new Runtime(options);
18063
18204
  return {
@@ -18072,6 +18213,28 @@ function createRenderer(options = {}) {
18072
18213
  }
18073
18214
  };
18074
18215
  }
18216
+ /**
18217
+ * A renderer factory for generators that produce JSX output.
18218
+ *
18219
+ * Pass this as the `renderer` property of a `defineGenerator` call so that
18220
+ * core can render the JSX element tree returned by your generator methods
18221
+ * without a hard dependency on `@kubb/renderer-jsx`.
18222
+ *
18223
+ * @example
18224
+ * ```ts
18225
+ * import { jsxRenderer } from '@kubb/renderer-jsx'
18226
+ * import { defineGenerator } from '@kubb/core'
18227
+ *
18228
+ * export const myGenerator = defineGenerator<PluginTs>({
18229
+ * name: 'my-generator',
18230
+ * renderer: jsxRenderer,
18231
+ * schema(node, options) {
18232
+ * return <File baseName="output.ts" path="src/output.ts">...</File>
18233
+ * },
18234
+ * })
18235
+ * ```
18236
+ */
18237
+ const jsxRenderer = () => createRenderer();
18075
18238
  //#endregion
18076
18239
  exports.Const = Const;
18077
18240
  exports.File = File;
@@ -18084,6 +18247,7 @@ exports.Type = Type;
18084
18247
  exports.createContext = createContext;
18085
18248
  exports.createRenderer = createRenderer;
18086
18249
  exports.inject = inject;
18250
+ exports.jsxRenderer = jsxRenderer;
18087
18251
  exports.provide = provide;
18088
18252
  exports.unprovide = unprovide;
18089
18253