@kubb/renderer-jsx 5.9.2 → 5.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("./rolldown-runtime-ClG-MNz_.cjs");
3
3
  const require_jsx_runtime = require("./jsx-runtime.cjs");
4
4
  let yaml = require("yaml");
5
- let _kubb_kit = require("@kubb/kit");
5
+ let _kubb_ast = require("@kubb/ast");
6
6
  //#region src/components/md/Callout.tsx
7
7
  const CALLOUT_LABEL = {
8
8
  tip: "TIP",
@@ -57,13 +57,9 @@ function Callout({ type, title, children }) {
57
57
  * </Const>
58
58
  * ```
59
59
  */
60
- function Const({ children, name, export: canExport, type, JSDoc, asConst }) {
60
+ function Const({ children, ...props }) {
61
61
  return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-const", {
62
- name,
63
- type,
64
- export: canExport,
65
- asConst,
66
- JSDoc,
62
+ ...props,
67
63
  children
68
64
  });
69
65
  }
@@ -208,17 +204,9 @@ function Frontmatter({ data }) {
208
204
  * // }
209
205
  * ```
210
206
  */
211
- function Function({ children, name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc }) {
212
- const genericsString = Array.isArray(generics) ? generics.join(", ").trim() : generics;
207
+ function Function({ children, ...props }) {
213
208
  return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-function", {
214
- name,
215
- params,
216
- export: canExport,
217
- default: isDefault,
218
- async: isAsync,
219
- generics: genericsString,
220
- returnType,
221
- JSDoc,
209
+ ...props,
222
210
  children
223
211
  });
224
212
  }
@@ -235,18 +223,9 @@ function Function({ children, name, default: isDefault, export: canExport, async
235
223
  * // export const double = (n: number): number => n * 2
236
224
  * ```
237
225
  */
238
- function ArrowFunction({ children, name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine }) {
239
- const genericsString = Array.isArray(generics) ? generics.join(", ").trim() : generics;
226
+ function ArrowFunction({ children, ...props }) {
240
227
  return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-arrow-function", {
241
- name,
242
- params,
243
- export: canExport,
244
- default: isDefault,
245
- async,
246
- generics: genericsString,
247
- returnType,
248
- singleLine,
249
- JSDoc,
228
+ ...props,
250
229
  children
251
230
  });
252
231
  }
@@ -360,12 +339,10 @@ function Paragraph({ children }) {
360
339
  * </Type>
361
340
  * ```
362
341
  */
363
- function Type({ children, name, export: canExport, JSDoc }) {
364
- if (name.charAt(0).toUpperCase() !== name.charAt(0)) throw new Error("Name should start with a capital letter(see TypeScript types)");
342
+ function Type({ children, ...props }) {
343
+ if (props.name.charAt(0).toUpperCase() !== props.name.charAt(0)) throw new Error("Name should start with a capital letter(see TypeScript types)");
365
344
  return /* @__PURE__ */ require_jsx_runtime.jsx("kubb-type", {
366
- name,
367
- export: canExport,
368
- JSDoc,
345
+ ...props,
369
346
  children
370
347
  });
371
348
  }
@@ -404,10 +381,10 @@ function childrenOf(host) {
404
381
  return "children" in host.props ? host.props.children : void 0;
405
382
  }
406
383
  const codeFactories = {
407
- "kubb-function": _kubb_kit.ast.factory.createFunction,
408
- "kubb-arrow-function": _kubb_kit.ast.factory.createArrowFunction,
409
- "kubb-const": _kubb_kit.ast.factory.createConst,
410
- "kubb-type": _kubb_kit.ast.factory.createType
384
+ "kubb-function": _kubb_ast.ast.factory.createFunction,
385
+ "kubb-arrow-function": _kubb_ast.ast.factory.createArrowFunction,
386
+ "kubb-const": _kubb_ast.ast.factory.createConst,
387
+ "kubb-type": _kubb_ast.ast.factory.createType
411
388
  };
412
389
  function isCodeHost(host) {
413
390
  return host.type in codeFactories;
@@ -422,10 +399,10 @@ function createCodeNode(type, props) {
422
399
  function collectCodeNodes(element) {
423
400
  const nodes = [];
424
401
  walkElement(element, (text) => {
425
- if (text.trim()) nodes.push(_kubb_kit.ast.factory.createText(text));
402
+ if (text.trim()) nodes.push(_kubb_ast.ast.factory.createText(text));
426
403
  }, (host) => {
427
404
  if (host.type === "br") {
428
- nodes.push(_kubb_kit.ast.factory.createBreak());
405
+ nodes.push(_kubb_ast.ast.factory.createBreak());
429
406
  return;
430
407
  }
431
408
  if (host.type === "kubb-jsx") {
@@ -433,7 +410,7 @@ function collectCodeNodes(element) {
433
410
  walkElement(host.props.children, (t) => {
434
411
  value += t;
435
412
  }, () => {});
436
- if (value) nodes.push(_kubb_kit.ast.factory.createJsx(value));
413
+ if (value) nodes.push(_kubb_ast.ast.factory.createJsx(value));
437
414
  return;
438
415
  }
439
416
  if (isCodeHost(host)) nodes.push(createCodeNode(host.type, host.props));
@@ -449,7 +426,7 @@ function collectFileChildren(element) {
449
426
  }, (host) => {
450
427
  if (host.type === "kubb-source") {
451
428
  const { name, isTypeOnly, isExportable, isIndexable, children } = host.props;
452
- sources.push(_kubb_kit.ast.factory.createSource({
429
+ sources.push(_kubb_ast.ast.factory.createSource({
453
430
  name: name?.toString(),
454
431
  isTypeOnly: !!isTypeOnly,
455
432
  isExportable: !!isExportable,
@@ -460,7 +437,7 @@ function collectFileChildren(element) {
460
437
  }
461
438
  if (host.type === "kubb-export") {
462
439
  const { name, path, isTypeOnly, asAlias } = host.props;
463
- exports.push(_kubb_kit.ast.factory.createExport({
440
+ exports.push(_kubb_ast.ast.factory.createExport({
464
441
  name,
465
442
  path,
466
443
  isTypeOnly: !!isTypeOnly,
@@ -470,7 +447,7 @@ function collectFileChildren(element) {
470
447
  }
471
448
  if (host.type === "kubb-import") {
472
449
  const { name, path, root, isTypeOnly, isNameSpace } = host.props;
473
- imports.push(_kubb_kit.ast.factory.createImport({
450
+ imports.push(_kubb_ast.ast.factory.createImport({
474
451
  name,
475
452
  path,
476
453
  root,
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
- import { i as KubbReactNode, n as Key, r as KubbReactElement, t as JSDoc } from "./types-BbP7RtaT.js";
3
- import { ast } from "@kubb/kit";
2
+ import { i as KubbReactNode, n as Key, r as KubbReactElement, t as JSDoc } from "./types-CVtBr_H8.js";
3
+ import { ast } from "@kubb/ast";
4
4
  //#region src/components/md/Callout.d.ts
5
5
  declare const CALLOUT_LABEL: {
6
6
  readonly tip: "TIP";
@@ -46,39 +46,8 @@ type Props$7 = {
46
46
  export declare function Callout({ type, title, children }: Props$7): KubbReactElement;
47
47
  //#endregion
48
48
  //#region src/components/js/Const.d.ts
49
- type ConstProps = {
49
+ type ConstProps = Omit<ast.ConstNode, 'kind' | 'nodes'> & {
50
50
  key?: Key;
51
- /**
52
- * Identifier of the generated constant declaration.
53
- *
54
- * @example
55
- * `name: 'petSchema'`
56
- */
57
- name: string;
58
- /**
59
- * Emit the `export` keyword before the `const` declaration.
60
- * - `true` generates `export const name = …`
61
- * - `false` generates `const name = …`
62
- */
63
- export?: boolean | null;
64
- /**
65
- * TypeScript type annotation for the constant, written verbatim after `const name:`.
66
- *
67
- * @example
68
- * `type: 'Pet'` → `const pet: Pet = …`
69
- */
70
- type?: string | null;
71
- /**
72
- * JSDoc block to prepend to the constant declaration.
73
- * Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
74
- */
75
- JSDoc?: JSDoc | null;
76
- /**
77
- * Append `as const` after the initializer, enabling TypeScript const assertions.
78
- * - `true` generates `const name = … as const`
79
- * - `false` generates `const name = …`
80
- */
81
- asConst?: boolean | null;
82
51
  /**
83
52
  * Child nodes rendered as the initializer expression of the constant.
84
53
  */
@@ -102,7 +71,7 @@ type ConstProps = {
102
71
  * </Const>
103
72
  * ```
104
73
  */
105
- export declare function Const({ children, name, export: canExport, type, JSDoc, asConst }: ConstProps): KubbReactElement;
74
+ export declare function Const({ children, ...props }: ConstProps): KubbReactElement;
106
75
  //#endregion
107
76
  //#region src/components/File.d.ts
108
77
  type BasePropsWithBaseName = {
@@ -290,63 +259,8 @@ type Props$5 = {
290
259
  export declare function Frontmatter({ data }: Props$5): KubbReactElement;
291
260
  //#endregion
292
261
  //#region src/components/js/Function.d.ts
293
- type Props$4 = {
262
+ type Props$4 = Omit<ast.FunctionNode, 'kind' | 'nodes'> & {
294
263
  key?: Key;
295
- /**
296
- * Identifier of the generated function declaration.
297
- *
298
- * @example
299
- * `name: 'getPet'`
300
- */
301
- name: string;
302
- /**
303
- * Emit `default` after the `export` keyword, making this the module's default export.
304
- * Requires `export` to also be `true`.
305
- */
306
- default?: boolean | null;
307
- /**
308
- * Parameter list written verbatim between the function's parentheses.
309
- *
310
- * @example
311
- * `params: 'petId: string, options?: RequestOptions'`
312
- */
313
- params?: string | null;
314
- /**
315
- * Emit the `export` keyword before the function declaration.
316
- * - `true` generates `export function name(…) { … }`
317
- * - `false` generates `function name(…) { … }`
318
- */
319
- export?: boolean | null;
320
- /**
321
- * Emit the `async` keyword, making this an async function.
322
- * The return type is automatically wrapped in `Promise<returnType>` when both
323
- * `async` and `returnType` are set.
324
- */
325
- async?: boolean | null;
326
- /**
327
- * TypeScript generic type parameters written verbatim between `<` and `>`.
328
- * Pass an array to emit multiple parameters separated by commas.
329
- *
330
- * @example Single generic
331
- * `generics: 'TData'`
332
- *
333
- * @example Multiple generics
334
- * `generics: ['TData', 'TError = unknown']`
335
- */
336
- generics?: string | Array<string> | null;
337
- /**
338
- * TypeScript return type annotation written verbatim after `:`.
339
- * When `async` is `true`, the value is automatically wrapped in `Promise<…>`.
340
- *
341
- * @example
342
- * `returnType: 'Pet'`
343
- */
344
- returnType?: string | null;
345
- /**
346
- * JSDoc block to prepend to the function declaration.
347
- * Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
348
- */
349
- JSDoc?: JSDoc | null;
350
264
  /**
351
265
  * Child nodes rendered as the body of the function.
352
266
  */
@@ -365,17 +279,16 @@ type Props$4 = {
365
279
  * // }
366
280
  * ```
367
281
  */
368
- export declare function Function({ children, name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc }: Props$4): KubbReactElement;
282
+ export declare function Function({ children, ...props }: Props$4): KubbReactElement;
369
283
  export declare namespace Function {
370
284
  var Arrow: typeof ArrowFunction;
371
285
  }
372
- type ArrowFunctionProps = Props$4 & {
286
+ type ArrowFunctionProps = Omit<ast.ArrowFunctionNode, 'kind' | 'nodes'> & {
287
+ key?: Key;
373
288
  /**
374
- * Render the arrow function as a single-line expression (no braces around the body).
375
- * - `true` generates `const name = (…) => expression`
376
- * - `false` generates `const name = (…) => { … }`
289
+ * Child nodes rendered as the body of the function.
377
290
  */
378
- singleLine?: boolean | null;
291
+ children?: KubbReactNode;
379
292
  };
380
293
  /**
381
294
  * Generates an arrow function expression assigned to a `const`.
@@ -390,7 +303,7 @@ type ArrowFunctionProps = Props$4 & {
390
303
  * // export const double = (n: number): number => n * 2
391
304
  * ```
392
305
  */
393
- declare function ArrowFunction({ children, name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine }: ArrowFunctionProps): any;
306
+ declare function ArrowFunction({ children, ...props }: ArrowFunctionProps): KubbReactElement;
394
307
  //#endregion
395
308
  //#region src/components/md/Heading.d.ts
396
309
  type Level = 1 | 2 | 3 | 4 | 5 | 6;
@@ -509,27 +422,8 @@ type Props = {
509
422
  export declare function Paragraph({ children }: Props): KubbReactElement;
510
423
  //#endregion
511
424
  //#region src/components/js/Type.d.ts
512
- type TypeProps = {
425
+ type TypeProps = Omit<ast.TypeNode, 'kind' | 'nodes'> & {
513
426
  key?: Key;
514
- /**
515
- * Identifier of the generated type alias.
516
- * Must start with an uppercase letter to follow TypeScript naming conventions.
517
- *
518
- * @example
519
- * `name: 'Pet'`
520
- */
521
- name: string;
522
- /**
523
- * Emit the `export` keyword before the type alias declaration.
524
- * - `true` generates `export type Name = …`
525
- * - `false` generates `type Name = …`
526
- */
527
- export?: boolean | null;
528
- /**
529
- * JSDoc block to prepend to the type alias declaration.
530
- * Each entry in `comments` becomes one line inside the emitted `/** … *\/` block.
531
- */
532
- JSDoc?: JSDoc | null;
533
427
  /**
534
428
  * Child nodes rendered as the type expression on the right-hand side of the alias.
535
429
  */
@@ -556,7 +450,7 @@ type TypeProps = {
556
450
  * </Type>
557
451
  * ```
558
452
  */
559
- export declare function Type({ children, name, export: canExport, JSDoc }: TypeProps): KubbReactElement;
453
+ export declare function Type({ children, ...props }: TypeProps): KubbReactElement;
560
454
  //#endregion
561
455
  //#region src/jsxRenderer.d.ts
562
456
  /**
@@ -590,5 +484,5 @@ export declare const jsxRenderer: () => {
590
484
  [Symbol.dispose](): void;
591
485
  };
592
486
  //#endregion
593
- export {};
487
+ export type { JSDoc, Key, KubbReactElement, KubbReactNode };
594
488
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./rolldown-runtime-C0LytTxp.js";
2
2
  import { Fragment, isKubbElement, jsx } from "./jsx-runtime.js";
3
3
  import { stringify } from "yaml";
4
- import { ast } from "@kubb/kit";
4
+ import { ast } from "@kubb/ast";
5
5
  //#region src/components/md/Callout.tsx
6
6
  const CALLOUT_LABEL = {
7
7
  tip: "TIP",
@@ -56,13 +56,9 @@ function Callout({ type, title, children }) {
56
56
  * </Const>
57
57
  * ```
58
58
  */
59
- function Const({ children, name, export: canExport, type, JSDoc, asConst }) {
59
+ function Const({ children, ...props }) {
60
60
  return /* @__PURE__ */ jsx("kubb-const", {
61
- name,
62
- type,
63
- export: canExport,
64
- asConst,
65
- JSDoc,
61
+ ...props,
66
62
  children
67
63
  });
68
64
  }
@@ -207,17 +203,9 @@ function Frontmatter({ data }) {
207
203
  * // }
208
204
  * ```
209
205
  */
210
- function Function({ children, name, default: isDefault, export: canExport, async: isAsync, generics, params, returnType, JSDoc }) {
211
- const genericsString = Array.isArray(generics) ? generics.join(", ").trim() : generics;
206
+ function Function({ children, ...props }) {
212
207
  return /* @__PURE__ */ jsx("kubb-function", {
213
- name,
214
- params,
215
- export: canExport,
216
- default: isDefault,
217
- async: isAsync,
218
- generics: genericsString,
219
- returnType,
220
- JSDoc,
208
+ ...props,
221
209
  children
222
210
  });
223
211
  }
@@ -234,18 +222,9 @@ function Function({ children, name, default: isDefault, export: canExport, async
234
222
  * // export const double = (n: number): number => n * 2
235
223
  * ```
236
224
  */
237
- function ArrowFunction({ children, name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine }) {
238
- const genericsString = Array.isArray(generics) ? generics.join(", ").trim() : generics;
225
+ function ArrowFunction({ children, ...props }) {
239
226
  return /* @__PURE__ */ jsx("kubb-arrow-function", {
240
- name,
241
- params,
242
- export: canExport,
243
- default: isDefault,
244
- async,
245
- generics: genericsString,
246
- returnType,
247
- singleLine,
248
- JSDoc,
227
+ ...props,
249
228
  children
250
229
  });
251
230
  }
@@ -359,12 +338,10 @@ function Paragraph({ children }) {
359
338
  * </Type>
360
339
  * ```
361
340
  */
362
- function Type({ children, name, export: canExport, JSDoc }) {
363
- if (name.charAt(0).toUpperCase() !== name.charAt(0)) throw new Error("Name should start with a capital letter(see TypeScript types)");
341
+ function Type({ children, ...props }) {
342
+ if (props.name.charAt(0).toUpperCase() !== props.name.charAt(0)) throw new Error("Name should start with a capital letter(see TypeScript types)");
364
343
  return /* @__PURE__ */ jsx("kubb-type", {
365
- name,
366
- export: canExport,
367
- JSDoc,
344
+ ...props,
368
345
  children
369
346
  });
370
347
  }
@@ -1,6 +1,6 @@
1
1
  import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
- import { i as KubbReactNode, n as Key, r as KubbReactElement } from "./types-BbP7RtaT.js";
3
- import { ast } from "@kubb/kit";
2
+ import { i as KubbReactNode, n as Key, r as KubbReactElement } from "./types-CVtBr_H8.js";
3
+ import { ast } from "@kubb/ast";
4
4
  //#region src/jsx-namespace.d.ts
5
5
  /**
6
6
  * JSX contract for `@kubb/renderer-jsx`, resolved through `jsxImportSource`.
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
- import { ast } from "@kubb/kit";
2
+ import { ast } from "@kubb/ast";
3
3
  //#region src/types.d.ts
4
4
  /**
5
5
  * Unique key for a Kubb JSX element in lists or conditional renders.
@@ -35,4 +35,4 @@ type KubbReactNode = KubbReactElement | string | number | bigint | boolean | nul
35
35
  type JSDoc = ast.JSDocNode;
36
36
  //#endregion
37
37
  export { KubbReactNode as i, Key as n, KubbReactElement as r, JSDoc as t };
38
- //# sourceMappingURL=types-BbP7RtaT.d.ts.map
38
+ //# sourceMappingURL=types-CVtBr_H8.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/renderer-jsx",
3
- "version": "5.9.2",
3
+ "version": "5.9.4",
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",
@@ -53,9 +53,6 @@
53
53
  ],
54
54
  "jsx-runtime": [
55
55
  "./dist/jsx-runtime.d.ts"
56
- ],
57
- "types": [
58
- "./dist/types.d.ts"
59
56
  ]
60
57
  }
61
58
  },
@@ -75,11 +72,6 @@
75
72
  "import": "./dist/jsx-runtime.js",
76
73
  "require": "./dist/jsx-runtime.cjs"
77
74
  },
78
- "./types": {
79
- "types": "./dist/types.d.ts",
80
- "import": "./dist/types.js",
81
- "require": "./dist/types.cjs"
82
- },
83
75
  "./package.json": "./package.json"
84
76
  },
85
77
  "publishConfig": {
@@ -87,7 +79,7 @@
87
79
  "registry": "https://registry.npmjs.org/"
88
80
  },
89
81
  "dependencies": {
90
- "@kubb/kit": "5.9.2",
82
+ "@kubb/ast": "5.9.4",
91
83
  "yaml": "^2.9.1"
92
84
  },
93
85
  "engines": {
package/dist/types.cjs DELETED
File without changes
package/dist/types.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { i as KubbReactNode, n as Key, r as KubbReactElement, t as JSDoc } from "./types-BbP7RtaT.js";
2
- export { JSDoc, Key, KubbReactElement, KubbReactNode };
package/dist/types.js DELETED
@@ -1 +0,0 @@
1
- export {};