@kubb/renderer-jsx 5.5.5 → 5.6.0

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./rolldown-runtime-C0LytTxp.js";
2
- import { Fragment, jsx } from "./jsx-runtime.js";
2
+ import { Fragment, isKubbElement, jsx } from "./jsx-runtime.js";
3
3
  import { stringify } from "yaml";
4
4
  import { ast } from "@kubb/kit";
5
5
  //#region src/components/md/Callout.tsx
@@ -36,7 +36,6 @@ function Callout({ type, title, children }) {
36
36
  children: `${header}\n${quoted}`
37
37
  });
38
38
  }
39
- Callout.displayName = "Callout";
40
39
  //#endregion
41
40
  //#region src/components/js/Const.tsx
42
41
  /**
@@ -57,8 +56,7 @@ Callout.displayName = "Callout";
57
56
  * </Const>
58
57
  * ```
59
58
  */
60
- function Const({ children, ...props }) {
61
- const { name, export: canExport, type, JSDoc, asConst } = props;
59
+ function Const({ children, name, export: canExport, type, JSDoc, asConst }) {
62
60
  return /* @__PURE__ */ jsx("kubb-const", {
63
61
  name,
64
62
  type,
@@ -68,7 +66,6 @@ function Const({ children, ...props }) {
68
66
  children
69
67
  });
70
68
  }
71
- Const.displayName = "Const";
72
69
  //#endregion
73
70
  //#region src/components/File.tsx
74
71
  /**
@@ -88,14 +85,12 @@ Const.displayName = "Const";
88
85
  * ```
89
86
  */
90
87
  function File({ children, ...props }) {
91
- const { baseName, path } = props;
92
- if (!baseName || !path) return /* @__PURE__ */ jsx(Fragment, { children });
88
+ if (!props.baseName || !props.path) return /* @__PURE__ */ jsx(Fragment, { children });
93
89
  return /* @__PURE__ */ jsx("kubb-file", {
94
90
  ...props,
95
91
  children
96
92
  });
97
93
  }
98
- File.displayName = "File";
99
94
  /**
100
95
  * Marks a block of source text to be associated with the enclosing {@link File}.
101
96
  *
@@ -117,16 +112,11 @@ File.displayName = "File";
117
112
  * ```
118
113
  */
119
114
  function FileSource({ children, ...props }) {
120
- const { name, isExportable, isIndexable, isTypeOnly } = props;
121
115
  return /* @__PURE__ */ jsx("kubb-source", {
122
- name,
123
- isTypeOnly,
124
- isExportable,
125
- isIndexable,
116
+ ...props,
126
117
  children
127
118
  });
128
119
  }
129
- FileSource.displayName = "FileSource";
130
120
  /**
131
121
  * Declares an export entry for the enclosing {@link File}.
132
122
  *
@@ -145,15 +135,8 @@ FileSource.displayName = "FileSource";
145
135
  * ```
146
136
  */
147
137
  function FileExport(props) {
148
- const { name, path, isTypeOnly, asAlias } = props;
149
- return /* @__PURE__ */ jsx("kubb-export", {
150
- name,
151
- path,
152
- isTypeOnly,
153
- asAlias
154
- });
138
+ return /* @__PURE__ */ jsx("kubb-export", { ...props });
155
139
  }
156
- FileExport.displayName = "FileExport";
157
140
  /**
158
141
  * Declares an import entry for the enclosing {@link File}.
159
142
  *
@@ -178,16 +161,8 @@ FileExport.displayName = "FileExport";
178
161
  * ```
179
162
  */
180
163
  function FileImport(props) {
181
- const { name, root, path, isTypeOnly, isNameSpace } = props;
182
- return /* @__PURE__ */ jsx("kubb-import", {
183
- name,
184
- root,
185
- path,
186
- isNameSpace,
187
- isTypeOnly
188
- });
164
+ return /* @__PURE__ */ jsx("kubb-import", { ...props });
189
165
  }
190
- FileImport.displayName = "FileImport";
191
166
  File.Export = FileExport;
192
167
  File.Import = FileImport;
193
168
  File.Source = FileSource;
@@ -217,7 +192,6 @@ function Frontmatter({ data }) {
217
192
  children: envelope
218
193
  });
219
194
  }
220
- Frontmatter.displayName = "Frontmatter";
221
195
  //#endregion
222
196
  //#region src/components/js/Function.tsx
223
197
  /**
@@ -233,8 +207,7 @@ Frontmatter.displayName = "Frontmatter";
233
207
  * // }
234
208
  * ```
235
209
  */
236
- function Function({ children, ...props }) {
237
- const { name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc } = props;
210
+ function Function({ children, name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc }) {
238
211
  const genericsString = Array.isArray(generics) ? generics.join(", ").trim() : generics;
239
212
  return /* @__PURE__ */ jsx("kubb-function", {
240
213
  name,
@@ -248,7 +221,6 @@ function Function({ children, ...props }) {
248
221
  children
249
222
  });
250
223
  }
251
- Function.displayName = "Function";
252
224
  /**
253
225
  * Generates an arrow function expression assigned to a `const`.
254
226
  * Supports the same flags as {@link Function}.
@@ -262,8 +234,7 @@ Function.displayName = "Function";
262
234
  * // export const double = (n: number): number => n * 2
263
235
  * ```
264
236
  */
265
- function ArrowFunction({ children, ...props }) {
266
- const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine } = props;
237
+ function ArrowFunction({ children, name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine }) {
267
238
  const genericsString = Array.isArray(generics) ? generics.join(", ").trim() : generics;
268
239
  return /* @__PURE__ */ jsx("kubb-arrow-function", {
269
240
  name,
@@ -278,7 +249,6 @@ function ArrowFunction({ children, ...props }) {
278
249
  children
279
250
  });
280
251
  }
281
- ArrowFunction.displayName = "ArrowFunction";
282
252
  Function.Arrow = ArrowFunction;
283
253
  //#endregion
284
254
  //#region src/components/md/Heading.tsx
@@ -300,7 +270,6 @@ function Heading({ level, children }) {
300
270
  children: `${"#".repeat(level)} ${children}`
301
271
  });
302
272
  }
303
- Heading.displayName = "Heading";
304
273
  //#endregion
305
274
  //#region src/components/jsx/Jsx.tsx
306
275
  /**
@@ -321,7 +290,6 @@ Heading.displayName = "Heading";
321
290
  function Jsx({ children }) {
322
291
  return /* @__PURE__ */ jsx("kubb-jsx", { children });
323
292
  }
324
- Jsx.displayName = "Jsx";
325
293
  //#endregion
326
294
  //#region src/components/md/List.tsx
327
295
  /**
@@ -348,7 +316,6 @@ function List({ ordered, items }) {
348
316
  children: body
349
317
  });
350
318
  }
351
- List.displayName = "List";
352
319
  //#endregion
353
320
  //#region src/components/md/Paragraph.tsx
354
321
  /**
@@ -369,7 +336,6 @@ function Paragraph({ children }) {
369
336
  children
370
337
  });
371
338
  }
372
- Paragraph.displayName = "Paragraph";
373
339
  //#endregion
374
340
  //#region src/components/js/Type.tsx
375
341
  /**
@@ -393,8 +359,7 @@ Paragraph.displayName = "Paragraph";
393
359
  * </Type>
394
360
  * ```
395
361
  */
396
- function Type({ children, ...props }) {
397
- const { name, export: canExport, JSDoc } = props;
362
+ function Type({ children, name, export: canExport, JSDoc }) {
398
363
  if (name.charAt(0).toUpperCase() !== name.charAt(0)) throw new Error("Name should start with a capital letter(see TypeScript types)");
399
364
  return /* @__PURE__ */ jsx("kubb-type", {
400
365
  name,
@@ -403,15 +368,9 @@ function Type({ children, ...props }) {
403
368
  children
404
369
  });
405
370
  }
406
- Type.displayName = "Type";
407
371
  //#endregion
408
- //#region src/Runtime.tsx
409
- /**
410
- * Walks `element`, resolving arrays, Fragments, and function components, then
411
- * calls `onText` for primitive values and `onHost` for each host element.
412
- * Function components are called synchronously. Hooks and class components are
413
- * not supported.
414
- */
372
+ //#region src/jsxRenderer.ts
373
+ /** Walks `element` through arrays, Fragments and function components, calling `onText` and `onHost`. */
415
374
  function walkElement(element, onText, onHost) {
416
375
  if (element == null || typeof element === "boolean") return;
417
376
  if (typeof element === "string" || typeof element === "number" || typeof element === "bigint") {
@@ -422,10 +381,9 @@ function walkElement(element, onText, onHost) {
422
381
  for (const child of element) walkElement(child, onText, onHost);
423
382
  return;
424
383
  }
425
- if (typeof element === "object" && "$$typeof" in element) {
426
- const el = element;
427
- const { type } = el;
428
- const props = el.props;
384
+ if (isKubbElement(element)) {
385
+ const { type } = element;
386
+ const props = element.props;
429
387
  if (type === Fragment) {
430
388
  walkElement(props["children"], onText, onHost);
431
389
  return;
@@ -434,81 +392,52 @@ function walkElement(element, onText, onHost) {
434
392
  walkElement(type(props), onText, onHost);
435
393
  return;
436
394
  }
437
- if (typeof type === "string") onHost(type, props);
395
+ if (typeof type === "string") onHost({
396
+ type,
397
+ props
398
+ });
438
399
  }
439
400
  }
440
- function collectCodeNodes(props) {
441
- const nodes = [];
442
- collectCode(props["children"], nodes);
443
- return nodes;
401
+ /** Returns the `children` prop of a host element, or `undefined` for tags without one. */
402
+ function childrenOf(host) {
403
+ return "children" in host.props ? host.props.children : void 0;
404
+ }
405
+ const codeFactories = {
406
+ "kubb-function": ast.factory.createFunction,
407
+ "kubb-arrow-function": ast.factory.createArrowFunction,
408
+ "kubb-const": ast.factory.createConst,
409
+ "kubb-type": ast.factory.createType
410
+ };
411
+ function isCodeHost(host) {
412
+ return host.type in codeFactories;
444
413
  }
445
- function collectCode(element, nodes) {
414
+ function createCodeNode(type, props) {
415
+ const { children, ...rest } = props;
416
+ return codeFactories[type]({
417
+ ...rest,
418
+ nodes: collectCodeNodes(children)
419
+ });
420
+ }
421
+ function collectCodeNodes(element) {
422
+ const nodes = [];
446
423
  walkElement(element, (text) => {
447
424
  if (text.trim()) nodes.push(ast.factory.createText(text));
448
- }, (type, props) => resolveCodeNode(type, props, nodes));
449
- }
450
- function resolveCodeNode(type, props, nodes) {
451
- if (type === "br") {
452
- nodes.push(ast.factory.createBreak());
453
- return;
454
- }
455
- if (type === "kubb-jsx") {
456
- let value = "";
457
- walkElement(props["children"], (t) => {
458
- value += t;
459
- }, () => {});
460
- if (value) nodes.push(ast.factory.createJsx(value));
461
- return;
462
- }
463
- if (type === "kubb-function") {
464
- nodes.push(ast.factory.createFunction({
465
- name: props["name"],
466
- params: props["params"],
467
- export: props["export"],
468
- default: props["default"],
469
- async: props["async"],
470
- generics: props["generics"],
471
- returnType: props["returnType"],
472
- JSDoc: props["JSDoc"],
473
- nodes: collectCodeNodes(props)
474
- }));
475
- return;
476
- }
477
- if (type === "kubb-arrow-function") {
478
- nodes.push(ast.factory.createArrowFunction({
479
- name: props["name"],
480
- params: props["params"],
481
- export: props["export"],
482
- default: props["default"],
483
- async: props["async"],
484
- generics: props["generics"],
485
- returnType: props["returnType"],
486
- singleLine: props["singleLine"],
487
- JSDoc: props["JSDoc"],
488
- nodes: collectCodeNodes(props)
489
- }));
490
- return;
491
- }
492
- if (type === "kubb-const") {
493
- nodes.push(ast.factory.createConst({
494
- name: props["name"],
495
- type: props["type"],
496
- export: props["export"],
497
- asConst: props["asConst"],
498
- JSDoc: props["JSDoc"],
499
- nodes: collectCodeNodes(props)
500
- }));
501
- return;
502
- }
503
- if (type === "kubb-type") {
504
- nodes.push(ast.factory.createType({
505
- name: props["name"],
506
- export: props["export"],
507
- JSDoc: props["JSDoc"],
508
- nodes: collectCodeNodes(props)
509
- }));
510
- return;
511
- }
425
+ }, (host) => {
426
+ if (host.type === "br") {
427
+ nodes.push(ast.factory.createBreak());
428
+ return;
429
+ }
430
+ if (host.type === "kubb-jsx") {
431
+ let value = "";
432
+ walkElement(host.props.children, (t) => {
433
+ value += t;
434
+ }, () => {});
435
+ if (value) nodes.push(ast.factory.createJsx(value));
436
+ return;
437
+ }
438
+ if (isCodeHost(host)) nodes.push(createCodeNode(host.type, host.props));
439
+ });
440
+ return nodes;
512
441
  }
513
442
  function collectFileChildren(element) {
514
443
  const sources = [];
@@ -516,37 +445,40 @@ function collectFileChildren(element) {
516
445
  const imports = [];
517
446
  walkElement(element, (text) => {
518
447
  if (text.trim()) throw new Error(`[jsx] '${text}' should be part of <File.Source> component when using the <File/> component`);
519
- }, (type, props) => {
520
- if (type === "kubb-source") {
448
+ }, (host) => {
449
+ if (host.type === "kubb-source") {
450
+ const { name, isTypeOnly, isExportable, isIndexable, children } = host.props;
521
451
  sources.push(ast.factory.createSource({
522
- name: props["name"]?.toString(),
523
- isTypeOnly: !!props["isTypeOnly"],
524
- isExportable: !!props["isExportable"],
525
- isIndexable: !!props["isIndexable"],
526
- nodes: collectCodeNodes(props)
452
+ name: name?.toString(),
453
+ isTypeOnly: !!isTypeOnly,
454
+ isExportable: !!isExportable,
455
+ isIndexable: !!isIndexable,
456
+ nodes: collectCodeNodes(children)
527
457
  }));
528
458
  return;
529
459
  }
530
- if (type === "kubb-export") {
460
+ if (host.type === "kubb-export") {
461
+ const { name, path, isTypeOnly, asAlias } = host.props;
531
462
  exports.push(ast.factory.createExport({
532
- name: props["name"],
533
- path: props["path"],
534
- isTypeOnly: !!props["isTypeOnly"],
535
- asAlias: !!props["asAlias"]
463
+ name,
464
+ path,
465
+ isTypeOnly: !!isTypeOnly,
466
+ asAlias: !!asAlias
536
467
  }));
537
468
  return;
538
469
  }
539
- if (type === "kubb-import") {
470
+ if (host.type === "kubb-import") {
471
+ const { name, path, root, isTypeOnly, isNameSpace } = host.props;
540
472
  imports.push(ast.factory.createImport({
541
- name: props["name"],
542
- path: props["path"],
543
- root: props["root"],
544
- isTypeOnly: !!props["isTypeOnly"],
545
- isNameSpace: !!props["isNameSpace"]
473
+ name,
474
+ path,
475
+ root,
476
+ isTypeOnly: !!isTypeOnly,
477
+ isNameSpace: !!isNameSpace
546
478
  }));
547
479
  return;
548
480
  }
549
- const nested = collectFileChildren(props["children"]);
481
+ const nested = collectFileChildren(childrenOf(host));
550
482
  sources.push(...nested.sources);
551
483
  exports.push(...nested.exports);
552
484
  imports.push(...nested.imports);
@@ -557,75 +489,26 @@ function collectFileChildren(element) {
557
489
  imports
558
490
  };
559
491
  }
560
- function* walkFiles(element) {
561
- if (element == null || typeof element === "boolean") return;
562
- if (typeof element === "string" || typeof element === "number" || typeof element === "bigint") return;
563
- if (Array.isArray(element)) {
564
- for (const child of element) yield* walkFiles(child);
565
- return;
566
- }
567
- if (typeof element === "object" && "$$typeof" in element) {
568
- const el = element;
569
- const { type } = el;
570
- const props = el.props;
571
- if (type === Fragment) {
572
- yield* walkFiles(props["children"]);
573
- return;
574
- }
575
- if (typeof type === "function") {
576
- yield* walkFiles(type(props));
577
- return;
578
- }
579
- if (typeof type === "string") {
580
- 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
- }
492
+ function createFileNode(props) {
493
+ const { sources, exports, imports } = collectFileChildren(props.children);
494
+ return {
495
+ baseName: props.baseName,
496
+ path: props.path,
497
+ meta: props.meta || {},
498
+ footer: props.footer,
499
+ banner: props.banner,
500
+ copy: props.copy,
501
+ sources,
502
+ exports,
503
+ imports
504
+ };
596
505
  }
597
506
  /**
598
- * Synchronous JSX renderer that walks the element tree in a single pass,
599
- * producing {@link ast.FileNode} objects directly without an intermediate virtual
600
- * DOM. No React fiber, scheduler, or work loop is involved.
601
- *
602
- * All components must be pure functions. Hooks and class components are not
603
- * supported.
604
- */
605
- var Runtime = class {
606
- /**
607
- * Accumulated {@link ast.FileNode} results from every {@link render} call.
608
- */
609
- nodes = [];
610
- /**
611
- * Walks `element` synchronously, converts every `<kubb-file>` subtree into
612
- * a {@link ast.FileNode} with no intermediate virtual DOM, and appends the results
613
- * to {@link nodes}.
614
- */
615
- render(element) {
616
- for (const file of walkFiles(element)) this.nodes.push(file);
617
- }
618
- };
619
- //#endregion
620
- //#region src/jsxRenderer.tsx
621
- /**
622
507
  * Factory for a renderer that walks the JSX tree in a single recursive pass,
623
508
  * with no React reconciler or scheduler. Pass it as the `renderer` property on
624
509
  * `defineGenerator`. Kubb core calls the factory once per render cycle and stays
625
- * generic, with no hard dependency on `@kubb/renderer-jsx`.
626
- *
627
- * Every component must be a pure function. Hooks, suspense, and class
628
- * components are not supported.
510
+ * generic, with no hard dependency on `@kubb/renderer-jsx`. Every component must be a pure
511
+ * function. Hooks, suspense and class components are not supported.
629
512
  *
630
513
  * @example Wire up a JSX generator
631
514
  * ```tsx
@@ -646,13 +529,22 @@ var Runtime = class {
646
529
  * ```
647
530
  */
648
531
  const jsxRenderer = () => {
649
- const runtime = new Runtime();
532
+ const files = [];
533
+ function collectFiles(element) {
534
+ walkElement(element, () => {}, (host) => {
535
+ if (host.type === "kubb-file") {
536
+ files.push(createFileNode(host.props));
537
+ return;
538
+ }
539
+ collectFiles(childrenOf(host));
540
+ });
541
+ }
650
542
  return {
651
543
  async render(element) {
652
- runtime.render(element);
544
+ collectFiles(element);
653
545
  },
654
546
  get files() {
655
- return runtime.nodes;
547
+ return files;
656
548
  },
657
549
  [Symbol.dispose]() {}
658
550
  };
@@ -21,11 +21,18 @@ function createElement(type, props, key) {
21
21
  props: props ?? {}
22
22
  };
23
23
  }
24
+ /**
25
+ * Returns `true` when `value` is an element this runtime created.
26
+ */
27
+ function isKubbElement(value) {
28
+ return typeof value === "object" && value !== null && value.$$typeof === KUBB_ELEMENT;
29
+ }
24
30
  const jsx = createElement;
25
31
  const jsxs = createElement;
26
32
  const jsxDEV = createElement;
27
33
  //#endregion
28
34
  exports.Fragment = Fragment;
35
+ exports.isKubbElement = isKubbElement;
29
36
  exports.jsx = jsx;
30
37
  exports.jsxDEV = jsxDEV;
31
38
  exports.jsxs = jsxs;
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
- import { i as KubbReactNode, n as Key, r as KubbReactElement } from "./types-seYG0czS.js";
2
+ import { i as KubbReactNode, n as Key, r as KubbReactElement } from "./types-BbP7RtaT.js";
3
3
  import { ast } from "@kubb/kit";
4
4
  //#region src/jsx-namespace.d.ts
5
5
  /**
@@ -10,23 +10,14 @@ import { ast } from "@kubb/kit";
10
10
  * the HTML element and class-component machinery from `@types/react` is not needed.
11
11
  */
12
12
  declare namespace JSX {
13
- type ElementType = string | ((props: any) => KubbReactNode);
13
+ type ElementType = string | ((props: never) => KubbReactNode);
14
14
  type Element = KubbReactElement;
15
- interface ElementClass {
16
- render(): KubbReactNode;
17
- }
18
- interface ElementAttributesProperty {
19
- props: {};
20
- }
21
15
  interface ElementChildrenAttribute {
22
16
  children: {};
23
17
  }
24
18
  interface IntrinsicAttributes {
25
19
  key?: Key | null;
26
20
  }
27
- interface IntrinsicClassAttributes<T> {
28
- key?: Key | null;
29
- }
30
21
  interface IntrinsicElements {
31
22
  ['kubb-jsx']: {
32
23
  children?: string;
@@ -34,8 +25,10 @@ declare namespace JSX {
34
25
  ['kubb-file']: {
35
26
  id?: string | null;
36
27
  children?: KubbReactNode;
37
- baseName: string;
28
+ baseName: ast.FileNode['baseName'];
38
29
  path: string;
30
+ banner?: string | null;
31
+ footer?: string | null;
39
32
  /**
40
33
  * Absolute on-disk path to copy into the output, through the parser's `copy` hook when it has
41
34
  * one. Use to emit a real source file shipped inside a package (a template) into the generated folder.
@@ -62,7 +55,6 @@ declare namespace JSX {
62
55
  };
63
56
  br: {};
64
57
  }
65
- type LibraryManagedAttributes<C, P> = P;
66
58
  }
67
59
  //#endregion
68
60
  //#region src/jsx-runtime.d.ts
@@ -78,6 +70,10 @@ export declare const Fragment: unique symbol;
78
70
  * `props`.
79
71
  */
80
72
  declare function createElement(type: unknown, props: Record<string, unknown> | null, key?: Key | null): KubbReactElement;
73
+ /**
74
+ * Returns `true` when `value` is an element this runtime created.
75
+ */
76
+ export declare function isKubbElement(value: unknown): value is KubbReactElement;
81
77
  export declare const jsx: typeof createElement;
82
78
  export declare const jsxs: typeof createElement;
83
79
  export declare const jsxDEV: typeof createElement;
@@ -20,10 +20,16 @@ function createElement(type, props, key) {
20
20
  props: props ?? {}
21
21
  };
22
22
  }
23
+ /**
24
+ * Returns `true` when `value` is an element this runtime created.
25
+ */
26
+ function isKubbElement(value) {
27
+ return typeof value === "object" && value !== null && value.$$typeof === KUBB_ELEMENT;
28
+ }
23
29
  const jsx = createElement;
24
30
  const jsxs = createElement;
25
31
  const jsxDEV = createElement;
26
32
  //#endregion
27
- export { Fragment, jsx, jsxDEV, jsxs };
33
+ export { Fragment, isKubbElement, jsx, jsxDEV, jsxs };
28
34
 
29
35
  //# sourceMappingURL=jsx-runtime.js.map
@@ -1,4 +1,5 @@
1
1
  import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
+ import { ast } from "@kubb/kit";
2
3
  //#region src/types.d.ts
3
4
  /**
4
5
  * Unique key for a Kubb JSX element in lists or conditional renders.
@@ -9,15 +10,19 @@ type Key = string | number | bigint;
9
10
  * so the fields stay opaque to type-checking.
10
11
  */
11
12
  type KubbReactElement = {
13
+ /**
14
+ * Brand set by the JSX runtime, so the renderer only walks elements it created.
15
+ */
16
+ $$typeof: symbol;
12
17
  type: unknown;
13
18
  props: unknown;
14
19
  key: Key | null;
15
20
  };
16
21
  /**
17
22
  * Anything a Kubb JSX component accepts as children: an element, a primitive
18
- * rendered as text, a nullish value that is skipped, or an iterable of nodes.
23
+ * rendered as text, a nullish value that is skipped, or an array of nodes.
19
24
  */
20
- type KubbReactNode = KubbReactElement | string | number | bigint | boolean | null | undefined | Iterable<KubbReactNode>;
25
+ type KubbReactNode = KubbReactElement | string | number | bigint | boolean | null | undefined | ReadonlyArray<KubbReactNode>;
21
26
  /**
22
27
  * JSDoc comment block to attach to a generated declaration.
23
28
  * Each string in `comments` becomes one line inside the `/** … *\/` block.
@@ -25,20 +30,9 @@ type KubbReactNode = KubbReactElement | string | number | bigint | boolean | nul
25
30
  * @example
26
31
  * ```ts
27
32
  * { comments: ['@description A pet object.', '@deprecated Use PetV2 instead.'] }
28
- * // Emits:
29
- * // /**
30
- * // * @description A pet object.
31
- * // * @deprecated Use PetV2 instead.
32
- * // *\/
33
33
  * ```
34
34
  */
35
- type JSDoc = {
36
- /**
37
- * Lines to emit inside the JSDoc block, in source order.
38
- * Use standard JSDoc tags such as `@description`, `@deprecated`, `@see`, etc.
39
- */
40
- comments: Array<string>;
41
- };
35
+ type JSDoc = ast.JSDocNode;
42
36
  //#endregion
43
37
  export { KubbReactNode as i, Key as n, KubbReactElement as r, JSDoc as t };
44
- //# sourceMappingURL=types-seYG0czS.d.ts.map
38
+ //# sourceMappingURL=types-BbP7RtaT.d.ts.map
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { i as KubbReactNode, n as Key, r as KubbReactElement, t as JSDoc } from "./types-seYG0czS.js";
1
+ import { i as KubbReactNode, n as Key, r as KubbReactElement, t as JSDoc } from "./types-BbP7RtaT.js";
2
2
  export { JSDoc, Key, KubbReactElement, KubbReactNode };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/renderer-jsx",
3
- "version": "5.5.5",
3
+ "version": "5.6.0",
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",
@@ -87,7 +87,7 @@
87
87
  "registry": "https://registry.npmjs.org/"
88
88
  },
89
89
  "dependencies": {
90
- "@kubb/kit": "5.5.5",
90
+ "@kubb/kit": "5.6.0",
91
91
  "yaml": "^2.9.1"
92
92
  },
93
93
  "engines": {