@kubb/renderer-jsx 5.23.1 → 5.23.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/README.md CHANGED
@@ -49,12 +49,12 @@ const renderer = jsxRenderer()
49
49
 
50
50
  await renderer.render(
51
51
  <File baseName="petStore.ts" path="src/gen/petStore.ts">
52
- <File.Source>
53
- <Type name="Pet">{'{ id: number; name: string }'}</Type>
54
- <Function name="getPet" async>
55
- {"return fetch('/pets')"}
56
- </Function>
57
- </File.Source>
52
+ <Type export name="Pet">
53
+ {'{ id: number; name: string }'}
54
+ </Type>
55
+ <Function export name="getPet" async>
56
+ {"return fetch('/pets')"}
57
+ </Function>
58
58
  </File>,
59
59
  )
60
60
 
@@ -66,7 +66,9 @@ const files = renderer.files
66
66
  | Component | Description |
67
67
  | --------------- | --------------------------------------------------------------------------- |
68
68
  | `<File>` | Declares a generated output file with its path and optional imports/exports |
69
- | `<File.Source>` | The source content block inside a `<File>` |
69
+ | `<Code>` | A printed declaration inside a `<File>`, with `name`, `export` and `type` |
70
+ | `<Raw>` | Text inside a `<File>` that declares nothing, such as a statement or JSON |
71
+ | `<Origin>` | Sets the input location of the sources inside it, such as a JSON pointer |
70
72
  | `<Function>` | Generates a TypeScript function declaration |
71
73
  | `<Type>` | Generates a TypeScript type alias |
72
74
  | `<Const>` | Generates a `const` variable declaration |
package/dist/index.cjs CHANGED
@@ -32,7 +32,19 @@ function Callout({ type, title, children }) {
32
32
  const label = CALLOUT_LABEL[type];
33
33
  const header = title ? `> [!${label}] ${title}` : `> [!${label}]`;
34
34
  const quoted = children.trimEnd().split("\n").map((line) => line.length > 0 ? `> ${line}` : ">").join("\n");
35
- return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-source", { children: `${header}\n${quoted}` });
35
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-raw", { children: `${header}\n${quoted}` });
36
+ }
37
+ // src/components/Code.tsx
38
+ /**
39
+ * A printed declaration in a `File`, in any language. For a declaration written in JSX, or a TypeScript type, use `Const`, `Type` or `Function`.
40
+ */
41
+ function Code({ children, name, export: canExport, default: isDefault }) {
42
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-code", {
43
+ name,
44
+ export: !!canExport,
45
+ default: isDefault,
46
+ children
47
+ });
36
48
  }
37
49
  // src/components/js/Const.tsx
38
50
  /**
@@ -70,9 +82,9 @@ function Const({ children, ...props }) {
70
82
  * @example Basic file with a source block
71
83
  * ```tsx
72
84
  * <File baseName="petStore.ts" path="src/models/petStore.ts">
73
- * <File.Source name="Pet" isExportable isIndexable>
74
- * {`export type Pet = { id: number; name: string }`}
75
- * </File.Source>
85
+ * <Code name="petSchema" export>
86
+ * {`export const petSchema = z.object({ id: z.number() })`}
87
+ * </Code>
76
88
  * </File>
77
89
  * ```
78
90
  */
@@ -84,31 +96,21 @@ function File({ children, ...props }) {
84
96
  });
85
97
  }
86
98
  /**
87
- * Marks a block of source text to be associated with the enclosing {@link File}.
88
- *
89
- * @deprecated Put `Const`, `Type` or `Function` directly in `File`. They take `inline` too. Removed in Kubb v6.
90
- *
91
- * Children are treated as the source string. `isExportable` marks the source as an exported declaration,
92
- * `isIndexable` includes the source in barrel/index generation, and `name` keys deduplication.
93
- *
94
- * @example Exportable, indexable source block
95
- * ```tsx
96
- * <File.Source name="Pet" isExportable isIndexable>
97
- * {`export type Pet = { id: number; name: string }`}
98
- * </File.Source>
99
- * ```
99
+ * A block of source text in the enclosing {@link File}.
100
100
  *
101
- * @example Type-only source block
102
- * ```tsx
103
- * <File.Source name="PetId" isTypeOnly isExportable>
104
- * {`export type PetId = string`}
105
- * </File.Source>
106
- * ```
101
+ * @deprecated Use `Code` or `Raw`, or put `Const`, `Type` or `Function` directly in `File`. Removed in Kubb v6.
107
102
  */
108
- function FileSource({ children, ...props }) {
109
- return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-source", {
110
- ...props,
111
- children
103
+ function FileSource({ children, name, pointer, export: isExport, default: isDefault, isIndexable, isTypeOnly, inline }) {
104
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-origin", {
105
+ pointer,
106
+ children: /* @__PURE__ */ require_jsx_runtime.jsx("kubb-code", {
107
+ name,
108
+ export: isExport ?? isIndexable,
109
+ default: isDefault,
110
+ isTypeOnly,
111
+ inline,
112
+ children
113
+ })
112
114
  });
113
115
  }
114
116
  /**
@@ -159,7 +161,7 @@ function FileImport(props) {
159
161
  }
160
162
  File.Export = FileExport;
161
163
  File.Import = FileImport;
162
- /** @deprecated Put `Const`, `Type` or `Function` directly in `File`. They take `inline` too. Removed in Kubb v6. */
164
+ /** @deprecated Use `Code` or `Raw`, or put `Const`, `Type` or `Function` directly in `File`. Removed in Kubb v6. */
163
165
  File.Source = FileSource;
164
166
  // src/components/md/Frontmatter.tsx
165
167
  /**
@@ -181,7 +183,7 @@ File.Source = FileSource;
181
183
  */
182
184
  function Frontmatter({ data }) {
183
185
  const envelope = Object.keys(data).length === 0 ? "" : `---\n${(0, yaml.stringify)(data).trimEnd()}\n---`;
184
- return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-source", { children: envelope });
186
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-raw", { children: envelope });
185
187
  }
186
188
  // src/components/js/Function.tsx
187
189
  /**
@@ -237,7 +239,7 @@ Function.Arrow = ArrowFunction;
237
239
  * ```
238
240
  */
239
241
  function Heading({ level, children }) {
240
- return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-source", { children: `${"#".repeat(level)} ${children}` });
242
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-raw", { children: `${"#".repeat(level)} ${children}` });
241
243
  }
242
244
  // src/components/jsx/Jsx.tsx
243
245
  /**
@@ -278,7 +280,17 @@ function Jsx({ children }) {
278
280
  */
279
281
  function List({ ordered, items }) {
280
282
  const body = items.map((item, index) => `${ordered ? `${index + 1}.` : "-"} ${item}`).join("\n");
281
- return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-source", { children: body });
283
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-raw", { children: body });
284
+ }
285
+ // src/components/Origin.tsx
286
+ /**
287
+ * Sets the input location of every source inside it. An inner `Origin` wins.
288
+ */
289
+ function Origin({ pointer, children }) {
290
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-origin", {
291
+ pointer,
292
+ children
293
+ });
282
294
  }
283
295
  // src/components/md/Paragraph.tsx
284
296
  /**
@@ -294,7 +306,17 @@ function List({ ordered, items }) {
294
306
  * ```
295
307
  */
296
308
  function Paragraph({ children }) {
297
- return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-source", { children });
309
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-raw", { children });
310
+ }
311
+ // src/components/Raw.tsx
312
+ /**
313
+ * Text in a `File` that declares nothing, such as a statement, JSON or markdown. Barrels leave it out.
314
+ */
315
+ function Raw({ children, name }) {
316
+ return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-raw", {
317
+ name,
318
+ children
319
+ });
298
320
  }
299
321
  // src/components/Schema.tsx
300
322
  /**
@@ -416,26 +438,45 @@ function collectCodeNodes(element) {
416
438
  });
417
439
  return nodes;
418
440
  }
441
+ /**
442
+ * Gives each source without a pointer the one of the enclosing `Origin`, so the innermost `Origin` wins.
443
+ */
444
+ function withOrigin(sources, pointer) {
445
+ if (!pointer) return sources;
446
+ return sources.map((source) => source.pointer ? source : {
447
+ ...source,
448
+ pointer
449
+ });
450
+ }
419
451
  function collectFileChildren(element) {
420
452
  const sources = [];
421
453
  const exports = [];
422
454
  const imports = [];
423
455
  walkElement(element, (text) => {
424
- if (text.trim()) throw new Error(`[jsx] '${text}' should be part of <File.Source> component when using the <File/> component`);
456
+ if (text.trim()) throw new Error(`[jsx] '${text}' should be part of a <Code> or <Raw> component when using the <File/> component`);
425
457
  }, (host) => {
426
- if (host.type === "kubb-source") {
427
- const { name, pointer, isTypeOnly, isExportable, isIndexable, inline, children } = host.props;
458
+ if (host.type === "kubb-code") {
459
+ const { name, isTypeOnly, export: isExport, default: isDefault, inline, children } = host.props;
428
460
  sources.push(_kubb_ast.ast.factory.createSource({
429
461
  name: name?.toString(),
430
- ...pointer !== void 0 ? { pointer } : {},
431
462
  isTypeOnly: !!isTypeOnly,
432
- isExportable: !!isExportable,
433
- isIndexable: !!isIndexable,
463
+ export: !!isExport,
464
+ ...isDefault ? { default: true } : {},
434
465
  ...inline ? { inline } : {},
435
466
  nodes: collectCodeNodes(children)
436
467
  }));
437
468
  return;
438
469
  }
470
+ if (host.type === "kubb-raw") {
471
+ const { name, children } = host.props;
472
+ sources.push(_kubb_ast.ast.factory.createSource({
473
+ name: name?.toString(),
474
+ isTypeOnly: false,
475
+ export: false,
476
+ nodes: collectCodeNodes(children)
477
+ }));
478
+ return;
479
+ }
439
480
  if (host.type === "kubb-export") {
440
481
  const { name, path, isTypeOnly, asAlias } = host.props;
441
482
  exports.push(_kubb_ast.ast.factory.createExport({
@@ -464,15 +505,15 @@ function collectFileChildren(element) {
464
505
  sources.push(_kubb_ast.ast.factory.createSource({
465
506
  name,
466
507
  isTypeOnly: host.type === "kubb-type",
467
- isExportable: !!canExport,
468
- isIndexable: !!canExport && !isDefault,
508
+ export: !!canExport,
509
+ ...isDefault ? { default: true } : {},
469
510
  ...inline && "nodes" in node ? { inline: { expression: _kubb_ast.ast.node.getText(node.nodes) } } : {},
470
511
  nodes: [node]
471
512
  }));
472
513
  return;
473
514
  }
474
515
  const nested = collectFileChildren(childrenOf(host));
475
- sources.push(...nested.sources);
516
+ sources.push(...host.type === "kubb-origin" ? withOrigin(nested.sources, host.props.pointer) : nested.sources);
476
517
  exports.push(...nested.exports);
477
518
  imports.push(...nested.imports);
478
519
  });
@@ -491,6 +532,7 @@ function createFileNode(props) {
491
532
  footer: props.footer,
492
533
  banner: props.banner,
493
534
  copy: props.copy,
535
+ inline: props.inline,
494
536
  sources,
495
537
  exports,
496
538
  imports
@@ -505,7 +547,7 @@ function createFileNode(props) {
505
547
  *
506
548
  * @example Wire up a JSX generator
507
549
  * ```tsx
508
- * import { defineGenerator } from '@kubb/core'
550
+ * import { defineGenerator } from '@kubb/kit'
509
551
  * import { jsxRenderer } from '@kubb/renderer-jsx'
510
552
  *
511
553
  * export const myGenerator = defineGenerator<PluginTs>({
@@ -543,6 +585,7 @@ const jsxRenderer = () => {
543
585
  };
544
586
  };
545
587
  exports.Callout = Callout;
588
+ exports.Code = Code;
546
589
  exports.Const = Const;
547
590
  exports.File = File;
548
591
  exports.Frontmatter = Frontmatter;
@@ -550,7 +593,9 @@ exports.Function = Function;
550
593
  exports.Heading = Heading;
551
594
  exports.Jsx = Jsx;
552
595
  exports.List = List;
596
+ exports.Origin = Origin;
553
597
  exports.Paragraph = Paragraph;
598
+ exports.Raw = Raw;
554
599
  exports.Schema = Schema;
555
600
  exports.Type = Type;
556
601
  exports.jsxRenderer = jsxRenderer;
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as KubbReactNode, n as Key, r as KubbReactElement, t as JSDoc } from "./types-D_u8uaRO.cjs";
1
+ import { i as KubbReactNode, n as Key, r as KubbReactElement, t as JSDoc } from "./types-CpFFjEcD.cjs";
2
2
  import { ast } from "@kubb/ast";
3
3
  declare const CALLOUT_LABEL: {
4
4
  readonly tip: 'TIP';
@@ -8,7 +8,7 @@ declare const CALLOUT_LABEL: {
8
8
  readonly caution: 'CAUTION';
9
9
  };
10
10
  type CalloutType = keyof typeof CALLOUT_LABEL;
11
- type Props$8 = {
11
+ type Props$11 = {
12
12
  key?: Key;
13
13
  /**
14
14
  * Callout kind. Maps to the uppercase label inside the `> [!TYPE]` marker.
@@ -41,10 +41,32 @@ type Props$8 = {
41
41
  * // > Breaking change in v6.
42
42
  * ```
43
43
  */
44
- export declare function Callout({ type, title, children }: Props$8): KubbReactElement;
44
+ export declare function Callout({ type, title, children }: Props$11): KubbReactElement;
45
+ type Props$10 = {
46
+ key?: Key;
47
+ name: string;
48
+ /**
49
+ * Lists the declaration in barrels. The text still needs its own `export` keyword.
50
+ */
51
+ export?: boolean;
52
+ /**
53
+ * Marks an exported declaration as the default export, which barrels skip.
54
+ */
55
+ default?: boolean;
56
+ children?: KubbReactNode;
57
+ };
58
+ /**
59
+ * A printed declaration in a `File`, in any language. For a declaration written in JSX, or a TypeScript type, use `Const`, `Type` or `Function`.
60
+ */
61
+ export declare function Code({ children, name, export: canExport, default: isDefault }: Props$10): KubbReactElement;
45
62
  type ConstProps = Omit<ast.ConstNode, 'kind' | 'nodes'> & {
46
63
  key?: Key;
47
- /** Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File`. */
64
+ /**
65
+ * Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File` that sets `inline`,
66
+ * or, without it, when every source in that file is inline.
67
+ *
68
+ * @deprecated Set `inline` on the `File`. Removed in Kubb v6.
69
+ */
48
70
  inline?: boolean;
49
71
  /**
50
72
  * Child nodes rendered as the initializer expression of the constant.
@@ -80,7 +102,7 @@ type BasePropsWithoutBaseName = {
80
102
  path?: string | null;
81
103
  };
82
104
  type BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName;
83
- type Props$7<TMeta extends object> = BaseProps & Pick<ast.UserFileNode<TMeta>, 'banner' | 'footer' | 'copy'> & {
105
+ type Props$9<TMeta extends object> = BaseProps & Pick<ast.UserFileNode<TMeta>, 'banner' | 'footer' | 'copy' | 'inline'> & {
84
106
  key?: Key;
85
107
  /**
86
108
  * Arbitrary metadata attached to the file node for plugins to read.
@@ -101,19 +123,19 @@ type Props$7<TMeta extends object> = BaseProps & Pick<ast.UserFileNode<TMeta>, '
101
123
  * @example Basic file with a source block
102
124
  * ```tsx
103
125
  * <File baseName="petStore.ts" path="src/models/petStore.ts">
104
- * <File.Source name="Pet" isExportable isIndexable>
105
- * {`export type Pet = { id: number; name: string }`}
106
- * </File.Source>
126
+ * <Code name="petSchema" export>
127
+ * {`export const petSchema = z.object({ id: z.number() })`}
128
+ * </Code>
107
129
  * </File>
108
130
  * ```
109
131
  */
110
- export declare function File<TMeta extends object = object>({ children, ...props }: Props$7<TMeta>): KubbReactElement;
132
+ export declare function File<TMeta extends object = object>({ children, ...props }: Props$9<TMeta>): KubbReactElement;
111
133
  export declare namespace File {
112
134
  export { FileExport as Export };
113
135
  export { FileImport as Import };
114
136
  export { FileSource as Source };
115
137
  }
116
- type FileSourceProps = Omit<ast.SourceNode, 'kind' | 'value'> & {
138
+ type FileSourceProps = Omit<ast.SourceNode, 'kind' | 'value' | 'nodes'> & {
117
139
  key?: Key;
118
140
  /**
119
141
  * Child nodes rendered as the source content of this block.
@@ -121,28 +143,11 @@ type FileSourceProps = Omit<ast.SourceNode, 'kind' | 'value'> & {
121
143
  children?: KubbReactNode;
122
144
  };
123
145
  /**
124
- * Marks a block of source text to be associated with the enclosing {@link File}.
146
+ * A block of source text in the enclosing {@link File}.
125
147
  *
126
- * @deprecated Put `Const`, `Type` or `Function` directly in `File`. They take `inline` too. Removed in Kubb v6.
127
- *
128
- * Children are treated as the source string. `isExportable` marks the source as an exported declaration,
129
- * `isIndexable` includes the source in barrel/index generation, and `name` keys deduplication.
130
- *
131
- * @example Exportable, indexable source block
132
- * ```tsx
133
- * <File.Source name="Pet" isExportable isIndexable>
134
- * {`export type Pet = { id: number; name: string }`}
135
- * </File.Source>
136
- * ```
137
- *
138
- * @example Type-only source block
139
- * ```tsx
140
- * <File.Source name="PetId" isTypeOnly isExportable>
141
- * {`export type PetId = string`}
142
- * </File.Source>
143
- * ```
148
+ * @deprecated Use `Code` or `Raw`, or put `Const`, `Type` or `Function` directly in `File`. Removed in Kubb v6.
144
149
  */
145
- declare function FileSource({ children, ...props }: FileSourceProps): KubbReactElement;
150
+ declare function FileSource({ children, name, pointer, export: isExport, default: isDefault, isIndexable, isTypeOnly, inline }: FileSourceProps): KubbReactElement;
146
151
  type FileExportProps = Omit<ast.ExportNode, 'kind'> & {
147
152
  key?: Key;
148
153
  };
@@ -191,7 +196,7 @@ type FileImportProps = Omit<ast.ImportNode, 'kind'> & {
191
196
  * ```
192
197
  */
193
198
  declare function FileImport(props: FileImportProps): KubbReactElement;
194
- type Props$6 = {
199
+ type Props$8 = {
195
200
  key?: Key;
196
201
  /**
197
202
  * Plain object serialized as YAML between `---` fences.
@@ -218,10 +223,15 @@ type Props$6 = {
218
223
  * </File>
219
224
  * ```
220
225
  */
221
- export declare function Frontmatter({ data }: Props$6): KubbReactElement;
222
- type Props$5 = Omit<ast.FunctionNode, 'kind' | 'nodes'> & {
226
+ export declare function Frontmatter({ data }: Props$8): KubbReactElement;
227
+ type Props$7 = Omit<ast.FunctionNode, 'kind' | 'nodes'> & {
223
228
  key?: Key;
224
- /** Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File`. */
229
+ /**
230
+ * Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File` that sets `inline`,
231
+ * or, without it, when every source in that file is inline.
232
+ *
233
+ * @deprecated Set `inline` on the `File`. Removed in Kubb v6.
234
+ */
225
235
  inline?: boolean;
226
236
  /**
227
237
  * Child nodes rendered as the body of the function.
@@ -241,13 +251,18 @@ type Props$5 = Omit<ast.FunctionNode, 'kind' | 'nodes'> & {
241
251
  * // }
242
252
  * ```
243
253
  */
244
- export declare function Function({ children, ...props }: Props$5): KubbReactElement;
254
+ export declare function Function({ children, ...props }: Props$7): KubbReactElement;
245
255
  export declare namespace Function {
246
256
  export { ArrowFunction as Arrow };
247
257
  }
248
258
  type ArrowFunctionProps = Omit<ast.ArrowFunctionNode, 'kind' | 'nodes'> & {
249
259
  key?: Key;
250
- /** Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File`. */
260
+ /**
261
+ * Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File` that sets `inline`,
262
+ * or, without it, when every source in that file is inline.
263
+ *
264
+ * @deprecated Set `inline` on the `File`. Removed in Kubb v6.
265
+ */
251
266
  inline?: boolean;
252
267
  /**
253
268
  * Child nodes rendered as the body of the function.
@@ -269,7 +284,7 @@ type ArrowFunctionProps = Omit<ast.ArrowFunctionNode, 'kind' | 'nodes'> & {
269
284
  */
270
285
  declare function ArrowFunction({ children, ...props }: ArrowFunctionProps): KubbReactElement;
271
286
  type Level = 1 | 2 | 3 | 4 | 5 | 6;
272
- type Props$4 = {
287
+ type Props$6 = {
273
288
  key?: Key;
274
289
  /**
275
290
  * Heading depth, `1` through `6`. Matches the number of `#` characters
@@ -293,8 +308,8 @@ type Props$4 = {
293
308
  * // ## Installation
294
309
  * ```
295
310
  */
296
- export declare function Heading({ level, children }: Props$4): KubbReactElement;
297
- type Props$3 = {
311
+ export declare function Heading({ level, children }: Props$6): KubbReactElement;
312
+ type Props$5 = {
298
313
  key?: Key;
299
314
  /**
300
315
  * Raw JSX string embedded verbatim in the generated code, including
@@ -322,8 +337,8 @@ type Props$3 = {
322
337
  * </Function>
323
338
  * ```
324
339
  */
325
- export declare function Jsx({ children }: Props$3): KubbReactElement;
326
- type Props$2 = {
340
+ export declare function Jsx({ children }: Props$5): KubbReactElement;
341
+ type Props$4 = {
327
342
  key?: Key;
328
343
  /**
329
344
  * When `true`, emits a numbered list (`1. …`). When `false` or omitted,
@@ -354,8 +369,19 @@ type Props$2 = {
354
369
  * // 2. Second
355
370
  * ```
356
371
  */
357
- export declare function List({ ordered, items }: Props$2): KubbReactElement;
358
- type Props$1 = {
372
+ export declare function List({ ordered, items }: Props$4): KubbReactElement;
373
+ type Props$3 = {
374
+ /**
375
+ * The input location, in the form the adapter reads, such as `#/components/schemas/Pet`.
376
+ */
377
+ pointer?: string;
378
+ children?: KubbReactNode;
379
+ };
380
+ /**
381
+ * Sets the input location of every source inside it. An inner `Origin` wins.
382
+ */
383
+ export declare function Origin({ pointer, children }: Props$3): KubbReactElement;
384
+ type Props$2 = {
359
385
  key?: Key;
360
386
  /**
361
387
  * Paragraph text. Inline markdown (links, emphasis, code spans) is passed
@@ -375,7 +401,19 @@ type Props$1 = {
375
401
  * <Paragraph>{'A pet object with `id` and `name` fields.'}</Paragraph>
376
402
  * ```
377
403
  */
378
- export declare function Paragraph({ children }: Props$1): KubbReactElement;
404
+ export declare function Paragraph({ children }: Props$2): KubbReactElement;
405
+ type Props$1 = {
406
+ key?: Key;
407
+ /**
408
+ * Dedupes the block when several generators add it to one file.
409
+ */
410
+ name?: string;
411
+ children?: KubbReactNode;
412
+ };
413
+ /**
414
+ * Text in a `File` that declares nothing, such as a statement, JSON or markdown. Barrels leave it out.
415
+ */
416
+ export declare function Raw({ children, name }: Props$1): KubbReactElement;
379
417
  type Props<TOutput> = {
380
418
  node: ast.SchemaNode;
381
419
  printer: Pick<ast.Printer, 'drainImports'> & {
@@ -394,7 +432,12 @@ type Props<TOutput> = {
394
432
  export declare function Schema<TOutput>({ node, printer, children }: Props<TOutput>): KubbReactElement | null;
395
433
  type TypeProps = Omit<ast.TypeNode, 'kind' | 'nodes'> & {
396
434
  key?: Key;
397
- /** Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File`. */
435
+ /**
436
+ * Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File` that sets `inline`,
437
+ * or, without it, when every source in that file is inline.
438
+ *
439
+ * @deprecated Set `inline` on the `File`. Removed in Kubb v6.
440
+ */
398
441
  inline?: boolean;
399
442
  /**
400
443
  * Child nodes rendered as the type expression on the right-hand side of the alias.
@@ -432,7 +475,7 @@ export declare function Type({ children, ...props }: TypeProps): KubbReactElemen
432
475
  *
433
476
  * @example Wire up a JSX generator
434
477
  * ```tsx
435
- * import { defineGenerator } from '@kubb/core'
478
+ * import { defineGenerator } from '@kubb/kit'
436
479
  * import { jsxRenderer } from '@kubb/renderer-jsx'
437
480
  *
438
481
  * export const myGenerator = defineGenerator<PluginTs>({
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as KubbReactNode, n as Key, r as KubbReactElement, t as JSDoc } from "./types-D_u8uaRO.js";
1
+ import { i as KubbReactNode, n as Key, r as KubbReactElement, t as JSDoc } from "./types-BiISTVBi.js";
2
2
  import { ast } from "@kubb/ast";
3
3
  declare const CALLOUT_LABEL: {
4
4
  readonly tip: 'TIP';
@@ -8,7 +8,7 @@ declare const CALLOUT_LABEL: {
8
8
  readonly caution: 'CAUTION';
9
9
  };
10
10
  type CalloutType = keyof typeof CALLOUT_LABEL;
11
- type Props$8 = {
11
+ type Props$11 = {
12
12
  key?: Key;
13
13
  /**
14
14
  * Callout kind. Maps to the uppercase label inside the `> [!TYPE]` marker.
@@ -41,10 +41,32 @@ type Props$8 = {
41
41
  * // > Breaking change in v6.
42
42
  * ```
43
43
  */
44
- export declare function Callout({ type, title, children }: Props$8): KubbReactElement;
44
+ export declare function Callout({ type, title, children }: Props$11): KubbReactElement;
45
+ type Props$10 = {
46
+ key?: Key;
47
+ name: string;
48
+ /**
49
+ * Lists the declaration in barrels. The text still needs its own `export` keyword.
50
+ */
51
+ export?: boolean;
52
+ /**
53
+ * Marks an exported declaration as the default export, which barrels skip.
54
+ */
55
+ default?: boolean;
56
+ children?: KubbReactNode;
57
+ };
58
+ /**
59
+ * A printed declaration in a `File`, in any language. For a declaration written in JSX, or a TypeScript type, use `Const`, `Type` or `Function`.
60
+ */
61
+ export declare function Code({ children, name, export: canExport, default: isDefault }: Props$10): KubbReactElement;
45
62
  type ConstProps = Omit<ast.ConstNode, 'kind' | 'nodes'> & {
46
63
  key?: Key;
47
- /** Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File`. */
64
+ /**
65
+ * Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File` that sets `inline`,
66
+ * or, without it, when every source in that file is inline.
67
+ *
68
+ * @deprecated Set `inline` on the `File`. Removed in Kubb v6.
69
+ */
48
70
  inline?: boolean;
49
71
  /**
50
72
  * Child nodes rendered as the initializer expression of the constant.
@@ -80,7 +102,7 @@ type BasePropsWithoutBaseName = {
80
102
  path?: string | null;
81
103
  };
82
104
  type BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName;
83
- type Props$7<TMeta extends object> = BaseProps & Pick<ast.UserFileNode<TMeta>, 'banner' | 'footer' | 'copy'> & {
105
+ type Props$9<TMeta extends object> = BaseProps & Pick<ast.UserFileNode<TMeta>, 'banner' | 'footer' | 'copy' | 'inline'> & {
84
106
  key?: Key;
85
107
  /**
86
108
  * Arbitrary metadata attached to the file node for plugins to read.
@@ -101,19 +123,19 @@ type Props$7<TMeta extends object> = BaseProps & Pick<ast.UserFileNode<TMeta>, '
101
123
  * @example Basic file with a source block
102
124
  * ```tsx
103
125
  * <File baseName="petStore.ts" path="src/models/petStore.ts">
104
- * <File.Source name="Pet" isExportable isIndexable>
105
- * {`export type Pet = { id: number; name: string }`}
106
- * </File.Source>
126
+ * <Code name="petSchema" export>
127
+ * {`export const petSchema = z.object({ id: z.number() })`}
128
+ * </Code>
107
129
  * </File>
108
130
  * ```
109
131
  */
110
- export declare function File<TMeta extends object = object>({ children, ...props }: Props$7<TMeta>): KubbReactElement;
132
+ export declare function File<TMeta extends object = object>({ children, ...props }: Props$9<TMeta>): KubbReactElement;
111
133
  export declare namespace File {
112
134
  export { FileExport as Export };
113
135
  export { FileImport as Import };
114
136
  export { FileSource as Source };
115
137
  }
116
- type FileSourceProps = Omit<ast.SourceNode, 'kind' | 'value'> & {
138
+ type FileSourceProps = Omit<ast.SourceNode, 'kind' | 'value' | 'nodes'> & {
117
139
  key?: Key;
118
140
  /**
119
141
  * Child nodes rendered as the source content of this block.
@@ -121,28 +143,11 @@ type FileSourceProps = Omit<ast.SourceNode, 'kind' | 'value'> & {
121
143
  children?: KubbReactNode;
122
144
  };
123
145
  /**
124
- * Marks a block of source text to be associated with the enclosing {@link File}.
146
+ * A block of source text in the enclosing {@link File}.
125
147
  *
126
- * @deprecated Put `Const`, `Type` or `Function` directly in `File`. They take `inline` too. Removed in Kubb v6.
127
- *
128
- * Children are treated as the source string. `isExportable` marks the source as an exported declaration,
129
- * `isIndexable` includes the source in barrel/index generation, and `name` keys deduplication.
130
- *
131
- * @example Exportable, indexable source block
132
- * ```tsx
133
- * <File.Source name="Pet" isExportable isIndexable>
134
- * {`export type Pet = { id: number; name: string }`}
135
- * </File.Source>
136
- * ```
137
- *
138
- * @example Type-only source block
139
- * ```tsx
140
- * <File.Source name="PetId" isTypeOnly isExportable>
141
- * {`export type PetId = string`}
142
- * </File.Source>
143
- * ```
148
+ * @deprecated Use `Code` or `Raw`, or put `Const`, `Type` or `Function` directly in `File`. Removed in Kubb v6.
144
149
  */
145
- declare function FileSource({ children, ...props }: FileSourceProps): KubbReactElement;
150
+ declare function FileSource({ children, name, pointer, export: isExport, default: isDefault, isIndexable, isTypeOnly, inline }: FileSourceProps): KubbReactElement;
146
151
  type FileExportProps = Omit<ast.ExportNode, 'kind'> & {
147
152
  key?: Key;
148
153
  };
@@ -191,7 +196,7 @@ type FileImportProps = Omit<ast.ImportNode, 'kind'> & {
191
196
  * ```
192
197
  */
193
198
  declare function FileImport(props: FileImportProps): KubbReactElement;
194
- type Props$6 = {
199
+ type Props$8 = {
195
200
  key?: Key;
196
201
  /**
197
202
  * Plain object serialized as YAML between `---` fences.
@@ -218,10 +223,15 @@ type Props$6 = {
218
223
  * </File>
219
224
  * ```
220
225
  */
221
- export declare function Frontmatter({ data }: Props$6): KubbReactElement;
222
- type Props$5 = Omit<ast.FunctionNode, 'kind' | 'nodes'> & {
226
+ export declare function Frontmatter({ data }: Props$8): KubbReactElement;
227
+ type Props$7 = Omit<ast.FunctionNode, 'kind' | 'nodes'> & {
223
228
  key?: Key;
224
- /** Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File`. */
229
+ /**
230
+ * Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File` that sets `inline`,
231
+ * or, without it, when every source in that file is inline.
232
+ *
233
+ * @deprecated Set `inline` on the `File`. Removed in Kubb v6.
234
+ */
225
235
  inline?: boolean;
226
236
  /**
227
237
  * Child nodes rendered as the body of the function.
@@ -241,13 +251,18 @@ type Props$5 = Omit<ast.FunctionNode, 'kind' | 'nodes'> & {
241
251
  * // }
242
252
  * ```
243
253
  */
244
- export declare function Function({ children, ...props }: Props$5): KubbReactElement;
254
+ export declare function Function({ children, ...props }: Props$7): KubbReactElement;
245
255
  export declare namespace Function {
246
256
  export { ArrowFunction as Arrow };
247
257
  }
248
258
  type ArrowFunctionProps = Omit<ast.ArrowFunctionNode, 'kind' | 'nodes'> & {
249
259
  key?: Key;
250
- /** Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File`. */
260
+ /**
261
+ * Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File` that sets `inline`,
262
+ * or, without it, when every source in that file is inline.
263
+ *
264
+ * @deprecated Set `inline` on the `File`. Removed in Kubb v6.
265
+ */
251
266
  inline?: boolean;
252
267
  /**
253
268
  * Child nodes rendered as the body of the function.
@@ -269,7 +284,7 @@ type ArrowFunctionProps = Omit<ast.ArrowFunctionNode, 'kind' | 'nodes'> & {
269
284
  */
270
285
  declare function ArrowFunction({ children, ...props }: ArrowFunctionProps): KubbReactElement;
271
286
  type Level = 1 | 2 | 3 | 4 | 5 | 6;
272
- type Props$4 = {
287
+ type Props$6 = {
273
288
  key?: Key;
274
289
  /**
275
290
  * Heading depth, `1` through `6`. Matches the number of `#` characters
@@ -293,8 +308,8 @@ type Props$4 = {
293
308
  * // ## Installation
294
309
  * ```
295
310
  */
296
- export declare function Heading({ level, children }: Props$4): KubbReactElement;
297
- type Props$3 = {
311
+ export declare function Heading({ level, children }: Props$6): KubbReactElement;
312
+ type Props$5 = {
298
313
  key?: Key;
299
314
  /**
300
315
  * Raw JSX string embedded verbatim in the generated code, including
@@ -322,8 +337,8 @@ type Props$3 = {
322
337
  * </Function>
323
338
  * ```
324
339
  */
325
- export declare function Jsx({ children }: Props$3): KubbReactElement;
326
- type Props$2 = {
340
+ export declare function Jsx({ children }: Props$5): KubbReactElement;
341
+ type Props$4 = {
327
342
  key?: Key;
328
343
  /**
329
344
  * When `true`, emits a numbered list (`1. …`). When `false` or omitted,
@@ -354,8 +369,19 @@ type Props$2 = {
354
369
  * // 2. Second
355
370
  * ```
356
371
  */
357
- export declare function List({ ordered, items }: Props$2): KubbReactElement;
358
- type Props$1 = {
372
+ export declare function List({ ordered, items }: Props$4): KubbReactElement;
373
+ type Props$3 = {
374
+ /**
375
+ * The input location, in the form the adapter reads, such as `#/components/schemas/Pet`.
376
+ */
377
+ pointer?: string;
378
+ children?: KubbReactNode;
379
+ };
380
+ /**
381
+ * Sets the input location of every source inside it. An inner `Origin` wins.
382
+ */
383
+ export declare function Origin({ pointer, children }: Props$3): KubbReactElement;
384
+ type Props$2 = {
359
385
  key?: Key;
360
386
  /**
361
387
  * Paragraph text. Inline markdown (links, emphasis, code spans) is passed
@@ -375,7 +401,19 @@ type Props$1 = {
375
401
  * <Paragraph>{'A pet object with `id` and `name` fields.'}</Paragraph>
376
402
  * ```
377
403
  */
378
- export declare function Paragraph({ children }: Props$1): KubbReactElement;
404
+ export declare function Paragraph({ children }: Props$2): KubbReactElement;
405
+ type Props$1 = {
406
+ key?: Key;
407
+ /**
408
+ * Dedupes the block when several generators add it to one file.
409
+ */
410
+ name?: string;
411
+ children?: KubbReactNode;
412
+ };
413
+ /**
414
+ * Text in a `File` that declares nothing, such as a statement, JSON or markdown. Barrels leave it out.
415
+ */
416
+ export declare function Raw({ children, name }: Props$1): KubbReactElement;
379
417
  type Props<TOutput> = {
380
418
  node: ast.SchemaNode;
381
419
  printer: Pick<ast.Printer, 'drainImports'> & {
@@ -394,7 +432,12 @@ type Props<TOutput> = {
394
432
  export declare function Schema<TOutput>({ node, printer, children }: Props<TOutput>): KubbReactElement | null;
395
433
  type TypeProps = Omit<ast.TypeNode, 'kind' | 'nodes'> & {
396
434
  key?: Key;
397
- /** Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File`. */
435
+ /**
436
+ * Lets importing files use the body in place of the name. Read when the declaration sits directly in a `File` that sets `inline`,
437
+ * or, without it, when every source in that file is inline.
438
+ *
439
+ * @deprecated Set `inline` on the `File`. Removed in Kubb v6.
440
+ */
398
441
  inline?: boolean;
399
442
  /**
400
443
  * Child nodes rendered as the type expression on the right-hand side of the alias.
@@ -432,7 +475,7 @@ export declare function Type({ children, ...props }: TypeProps): KubbReactElemen
432
475
  *
433
476
  * @example Wire up a JSX generator
434
477
  * ```tsx
435
- * import { defineGenerator } from '@kubb/core'
478
+ * import { defineGenerator } from '@kubb/kit'
436
479
  * import { jsxRenderer } from '@kubb/renderer-jsx'
437
480
  *
438
481
  * export const myGenerator = defineGenerator<PluginTs>({
package/dist/index.js CHANGED
@@ -31,7 +31,19 @@ function Callout({ type, title, children }) {
31
31
  const label = CALLOUT_LABEL[type];
32
32
  const header = title ? `> [!${label}] ${title}` : `> [!${label}]`;
33
33
  const quoted = children.trimEnd().split("\n").map((line) => line.length > 0 ? `> ${line}` : ">").join("\n");
34
- return /* @__PURE__ */ jsx("kubb-source", { children: `${header}\n${quoted}` });
34
+ return /* @__PURE__ */ jsx("kubb-raw", { children: `${header}\n${quoted}` });
35
+ }
36
+ // src/components/Code.tsx
37
+ /**
38
+ * A printed declaration in a `File`, in any language. For a declaration written in JSX, or a TypeScript type, use `Const`, `Type` or `Function`.
39
+ */
40
+ function Code({ children, name, export: canExport, default: isDefault }) {
41
+ return /* @__PURE__ */ jsx("kubb-code", {
42
+ name,
43
+ export: !!canExport,
44
+ default: isDefault,
45
+ children
46
+ });
35
47
  }
36
48
  // src/components/js/Const.tsx
37
49
  /**
@@ -69,9 +81,9 @@ function Const({ children, ...props }) {
69
81
  * @example Basic file with a source block
70
82
  * ```tsx
71
83
  * <File baseName="petStore.ts" path="src/models/petStore.ts">
72
- * <File.Source name="Pet" isExportable isIndexable>
73
- * {`export type Pet = { id: number; name: string }`}
74
- * </File.Source>
84
+ * <Code name="petSchema" export>
85
+ * {`export const petSchema = z.object({ id: z.number() })`}
86
+ * </Code>
75
87
  * </File>
76
88
  * ```
77
89
  */
@@ -83,31 +95,21 @@ function File({ children, ...props }) {
83
95
  });
84
96
  }
85
97
  /**
86
- * Marks a block of source text to be associated with the enclosing {@link File}.
87
- *
88
- * @deprecated Put `Const`, `Type` or `Function` directly in `File`. They take `inline` too. Removed in Kubb v6.
89
- *
90
- * Children are treated as the source string. `isExportable` marks the source as an exported declaration,
91
- * `isIndexable` includes the source in barrel/index generation, and `name` keys deduplication.
92
- *
93
- * @example Exportable, indexable source block
94
- * ```tsx
95
- * <File.Source name="Pet" isExportable isIndexable>
96
- * {`export type Pet = { id: number; name: string }`}
97
- * </File.Source>
98
- * ```
98
+ * A block of source text in the enclosing {@link File}.
99
99
  *
100
- * @example Type-only source block
101
- * ```tsx
102
- * <File.Source name="PetId" isTypeOnly isExportable>
103
- * {`export type PetId = string`}
104
- * </File.Source>
105
- * ```
100
+ * @deprecated Use `Code` or `Raw`, or put `Const`, `Type` or `Function` directly in `File`. Removed in Kubb v6.
106
101
  */
107
- function FileSource({ children, ...props }) {
108
- return /* @__PURE__ */ jsx("kubb-source", {
109
- ...props,
110
- children
102
+ function FileSource({ children, name, pointer, export: isExport, default: isDefault, isIndexable, isTypeOnly, inline }) {
103
+ return /* @__PURE__ */ jsx("kubb-origin", {
104
+ pointer,
105
+ children: /* @__PURE__ */ jsx("kubb-code", {
106
+ name,
107
+ export: isExport ?? isIndexable,
108
+ default: isDefault,
109
+ isTypeOnly,
110
+ inline,
111
+ children
112
+ })
111
113
  });
112
114
  }
113
115
  /**
@@ -158,7 +160,7 @@ function FileImport(props) {
158
160
  }
159
161
  File.Export = FileExport;
160
162
  File.Import = FileImport;
161
- /** @deprecated Put `Const`, `Type` or `Function` directly in `File`. They take `inline` too. Removed in Kubb v6. */
163
+ /** @deprecated Use `Code` or `Raw`, or put `Const`, `Type` or `Function` directly in `File`. Removed in Kubb v6. */
162
164
  File.Source = FileSource;
163
165
  // src/components/md/Frontmatter.tsx
164
166
  /**
@@ -180,7 +182,7 @@ File.Source = FileSource;
180
182
  */
181
183
  function Frontmatter({ data }) {
182
184
  const envelope = Object.keys(data).length === 0 ? "" : `---\n${stringify(data).trimEnd()}\n---`;
183
- return /* @__PURE__ */ jsx("kubb-source", { children: envelope });
185
+ return /* @__PURE__ */ jsx("kubb-raw", { children: envelope });
184
186
  }
185
187
  // src/components/js/Function.tsx
186
188
  /**
@@ -236,7 +238,7 @@ Function.Arrow = ArrowFunction;
236
238
  * ```
237
239
  */
238
240
  function Heading({ level, children }) {
239
- return /* @__PURE__ */ jsx("kubb-source", { children: `${"#".repeat(level)} ${children}` });
241
+ return /* @__PURE__ */ jsx("kubb-raw", { children: `${"#".repeat(level)} ${children}` });
240
242
  }
241
243
  // src/components/jsx/Jsx.tsx
242
244
  /**
@@ -277,7 +279,17 @@ function Jsx({ children }) {
277
279
  */
278
280
  function List({ ordered, items }) {
279
281
  const body = items.map((item, index) => `${ordered ? `${index + 1}.` : "-"} ${item}`).join("\n");
280
- return /* @__PURE__ */ jsx("kubb-source", { children: body });
282
+ return /* @__PURE__ */ jsx("kubb-raw", { children: body });
283
+ }
284
+ // src/components/Origin.tsx
285
+ /**
286
+ * Sets the input location of every source inside it. An inner `Origin` wins.
287
+ */
288
+ function Origin({ pointer, children }) {
289
+ return /* @__PURE__ */ jsx("kubb-origin", {
290
+ pointer,
291
+ children
292
+ });
281
293
  }
282
294
  // src/components/md/Paragraph.tsx
283
295
  /**
@@ -293,7 +305,17 @@ function List({ ordered, items }) {
293
305
  * ```
294
306
  */
295
307
  function Paragraph({ children }) {
296
- return /* @__PURE__ */ jsx("kubb-source", { children });
308
+ return /* @__PURE__ */ jsx("kubb-raw", { children });
309
+ }
310
+ // src/components/Raw.tsx
311
+ /**
312
+ * Text in a `File` that declares nothing, such as a statement, JSON or markdown. Barrels leave it out.
313
+ */
314
+ function Raw({ children, name }) {
315
+ return /* @__PURE__ */ jsx("kubb-raw", {
316
+ name,
317
+ children
318
+ });
297
319
  }
298
320
  // src/components/Schema.tsx
299
321
  /**
@@ -415,26 +437,45 @@ function collectCodeNodes(element) {
415
437
  });
416
438
  return nodes;
417
439
  }
440
+ /**
441
+ * Gives each source without a pointer the one of the enclosing `Origin`, so the innermost `Origin` wins.
442
+ */
443
+ function withOrigin(sources, pointer) {
444
+ if (!pointer) return sources;
445
+ return sources.map((source) => source.pointer ? source : {
446
+ ...source,
447
+ pointer
448
+ });
449
+ }
418
450
  function collectFileChildren(element) {
419
451
  const sources = [];
420
452
  const exports = [];
421
453
  const imports = [];
422
454
  walkElement(element, (text) => {
423
- if (text.trim()) throw new Error(`[jsx] '${text}' should be part of <File.Source> component when using the <File/> component`);
455
+ if (text.trim()) throw new Error(`[jsx] '${text}' should be part of a <Code> or <Raw> component when using the <File/> component`);
424
456
  }, (host) => {
425
- if (host.type === "kubb-source") {
426
- const { name, pointer, isTypeOnly, isExportable, isIndexable, inline, children } = host.props;
457
+ if (host.type === "kubb-code") {
458
+ const { name, isTypeOnly, export: isExport, default: isDefault, inline, children } = host.props;
427
459
  sources.push(ast.factory.createSource({
428
460
  name: name?.toString(),
429
- ...pointer !== void 0 ? { pointer } : {},
430
461
  isTypeOnly: !!isTypeOnly,
431
- isExportable: !!isExportable,
432
- isIndexable: !!isIndexable,
462
+ export: !!isExport,
463
+ ...isDefault ? { default: true } : {},
433
464
  ...inline ? { inline } : {},
434
465
  nodes: collectCodeNodes(children)
435
466
  }));
436
467
  return;
437
468
  }
469
+ if (host.type === "kubb-raw") {
470
+ const { name, children } = host.props;
471
+ sources.push(ast.factory.createSource({
472
+ name: name?.toString(),
473
+ isTypeOnly: false,
474
+ export: false,
475
+ nodes: collectCodeNodes(children)
476
+ }));
477
+ return;
478
+ }
438
479
  if (host.type === "kubb-export") {
439
480
  const { name, path, isTypeOnly, asAlias } = host.props;
440
481
  exports.push(ast.factory.createExport({
@@ -463,15 +504,15 @@ function collectFileChildren(element) {
463
504
  sources.push(ast.factory.createSource({
464
505
  name,
465
506
  isTypeOnly: host.type === "kubb-type",
466
- isExportable: !!canExport,
467
- isIndexable: !!canExport && !isDefault,
507
+ export: !!canExport,
508
+ ...isDefault ? { default: true } : {},
468
509
  ...inline && "nodes" in node ? { inline: { expression: ast.node.getText(node.nodes) } } : {},
469
510
  nodes: [node]
470
511
  }));
471
512
  return;
472
513
  }
473
514
  const nested = collectFileChildren(childrenOf(host));
474
- sources.push(...nested.sources);
515
+ sources.push(...host.type === "kubb-origin" ? withOrigin(nested.sources, host.props.pointer) : nested.sources);
475
516
  exports.push(...nested.exports);
476
517
  imports.push(...nested.imports);
477
518
  });
@@ -490,6 +531,7 @@ function createFileNode(props) {
490
531
  footer: props.footer,
491
532
  banner: props.banner,
492
533
  copy: props.copy,
534
+ inline: props.inline,
493
535
  sources,
494
536
  exports,
495
537
  imports
@@ -504,7 +546,7 @@ function createFileNode(props) {
504
546
  *
505
547
  * @example Wire up a JSX generator
506
548
  * ```tsx
507
- * import { defineGenerator } from '@kubb/core'
549
+ * import { defineGenerator } from '@kubb/kit'
508
550
  * import { jsxRenderer } from '@kubb/renderer-jsx'
509
551
  *
510
552
  * export const myGenerator = defineGenerator<PluginTs>({
@@ -541,6 +583,6 @@ const jsxRenderer = () => {
541
583
  [Symbol.dispose]() {}
542
584
  };
543
585
  };
544
- export { Callout, Const, File, Frontmatter, Function, Heading, Jsx, List, Paragraph, Schema, Type, jsxRenderer };
586
+ export { Callout, Code, Const, File, Frontmatter, Function, Heading, Jsx, List, Origin, Paragraph, Raw, Schema, Type, jsxRenderer };
545
587
 
546
588
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { i as KubbReactNode, n as Key, r as KubbReactElement } from "./types-D_u8uaRO.cjs";
1
+ import { i as KubbReactNode, n as Key, r as KubbReactElement } from "./types-CpFFjEcD.cjs";
2
2
  import { ast } from "@kubb/ast";
3
3
  /**
4
4
  * JSX contract for `@kubb/renderer-jsx`, resolved through `jsxImportSource`.
@@ -25,7 +25,13 @@ declare namespace JSX {
25
25
  id?: string | null;
26
26
  children?: KubbReactNode;
27
27
  };
28
- ['kubb-source']: Omit<ast.SourceNode, 'kind'> & {
28
+ ['kubb-origin']: Pick<ast.SourceNode, 'pointer'> & {
29
+ children?: KubbReactNode;
30
+ };
31
+ ['kubb-code']: Pick<ast.SourceNode, 'name' | 'export' | 'default' | 'isTypeOnly' | 'inline'> & {
32
+ children?: KubbReactNode;
33
+ };
34
+ ['kubb-raw']: Pick<ast.SourceNode, 'name'> & {
29
35
  children?: KubbReactNode;
30
36
  };
31
37
  ['kubb-import']: Omit<ast.ImportNode, 'kind'> & {};
@@ -1,4 +1,4 @@
1
- import { i as KubbReactNode, n as Key, r as KubbReactElement } from "./types-D_u8uaRO.js";
1
+ import { i as KubbReactNode, n as Key, r as KubbReactElement } from "./types-BiISTVBi.js";
2
2
  import { ast } from "@kubb/ast";
3
3
  /**
4
4
  * JSX contract for `@kubb/renderer-jsx`, resolved through `jsxImportSource`.
@@ -25,7 +25,13 @@ declare namespace JSX {
25
25
  id?: string | null;
26
26
  children?: KubbReactNode;
27
27
  };
28
- ['kubb-source']: Omit<ast.SourceNode, 'kind'> & {
28
+ ['kubb-origin']: Pick<ast.SourceNode, 'pointer'> & {
29
+ children?: KubbReactNode;
30
+ };
31
+ ['kubb-code']: Pick<ast.SourceNode, 'name' | 'export' | 'default' | 'isTypeOnly' | 'inline'> & {
32
+ children?: KubbReactNode;
33
+ };
34
+ ['kubb-raw']: Pick<ast.SourceNode, 'name'> & {
29
35
  children?: KubbReactNode;
30
36
  };
31
37
  ['kubb-import']: Omit<ast.ImportNode, 'kind'> & {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/renderer-jsx",
3
- "version": "5.23.1",
3
+ "version": "5.23.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",
@@ -94,7 +94,7 @@
94
94
  "registry": "https://registry.npmjs.org/"
95
95
  },
96
96
  "dependencies": {
97
- "@kubb/ast": "^5.23.1",
97
+ "@kubb/ast": "^5.23.3",
98
98
  "yaml": "^2.9.1"
99
99
  },
100
100
  "engines": {