@kubb/react-fabric 0.9.4 → 0.10.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.
Files changed (53) hide show
  1. package/dist/{devtools-D6dZodXp.js → devtools-8_UKWDTl.js} +1 -1
  2. package/dist/{devtools-D6dZodXp.js.map → devtools-8_UKWDTl.js.map} +1 -1
  3. package/dist/{devtools-CRkwwngz.cjs → devtools-BOpUJhc_.cjs} +1 -1
  4. package/dist/{devtools-CRkwwngz.cjs.map → devtools-BOpUJhc_.cjs.map} +1 -1
  5. package/dist/devtools.cjs +1 -1
  6. package/dist/devtools.js +1 -1
  7. package/dist/globals.d.cts +1 -1
  8. package/dist/globals.d.ts +1 -1
  9. package/dist/index.cjs +93 -66
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +209 -57
  12. package/dist/index.d.ts +209 -57
  13. package/dist/index.js +78 -61
  14. package/dist/index.js.map +1 -1
  15. package/dist/jsx-dev-runtime.d.cts +4 -4
  16. package/dist/jsx-dev-runtime.d.ts +2 -2
  17. package/dist/{jsx-namespace-CCPa1Nut.d.cts → jsx-namespace-BnoysbjP.d.cts} +2 -2
  18. package/dist/{jsx-namespace-BAkGpU6g.d.ts → jsx-namespace-D0a66_uR.d.ts} +2 -2
  19. package/dist/{jsx-runtime-BEVcoJUm.cjs → jsx-runtime-Cq39dA50.cjs} +1 -1
  20. package/dist/{jsx-runtime-BEVcoJUm.cjs.map → jsx-runtime-Cq39dA50.cjs.map} +1 -1
  21. package/dist/{jsx-runtime-DDu0mFTI.js → jsx-runtime-Isgf9orn.js} +1 -1
  22. package/dist/{jsx-runtime-DDu0mFTI.js.map → jsx-runtime-Isgf9orn.js.map} +1 -1
  23. package/dist/jsx-runtime.cjs +1 -1
  24. package/dist/jsx-runtime.d.cts +4 -4
  25. package/dist/jsx-runtime.d.ts +2 -2
  26. package/dist/jsx-runtime.js +1 -1
  27. package/dist/plugins.cjs +2 -2
  28. package/dist/plugins.js +2 -2
  29. package/dist/{reactPlugin-CXaAO13f.cjs → reactPlugin-D4SmGYbm.cjs} +52 -59
  30. package/dist/reactPlugin-D4SmGYbm.cjs.map +1 -0
  31. package/dist/{reactPlugin-ixOr00MK.js → reactPlugin-DT9toQPK.js} +53 -48
  32. package/dist/reactPlugin-DT9toQPK.js.map +1 -0
  33. package/dist/{types-CSUzVTpn.d.ts → types-BL7PkfqA.d.ts} +7 -5
  34. package/dist/{types-DP2mgqeb.d.cts → types-BdOHT5YF.d.cts} +7 -5
  35. package/dist/types.d.cts +1 -1
  36. package/dist/types.d.ts +1 -1
  37. package/package.json +3 -3
  38. package/src/components/App.tsx +7 -14
  39. package/src/components/Const.tsx +3 -0
  40. package/src/components/File.tsx +39 -22
  41. package/src/components/Function.tsx +10 -0
  42. package/src/components/Indent.tsx +3 -0
  43. package/src/components/Root.tsx +13 -14
  44. package/src/components/Type.tsx +4 -0
  45. package/src/composables/useApp.ts +1 -15
  46. package/src/composables/useFile.ts +1 -12
  47. package/src/composables/useLifecycle.tsx +7 -8
  48. package/src/index.ts +5 -1
  49. package/src/types.ts +0 -4
  50. package/src/utils/createJSDoc.ts +1 -8
  51. package/src/utils/getFunctionParams.ts +12 -8
  52. package/dist/reactPlugin-CXaAO13f.cjs.map +0 -1
  53. package/dist/reactPlugin-ixOr00MK.js.map +0 -1
@@ -1,6 +1,11 @@
1
1
  import { b as Source, g as Import, h as File, p as Export } from "./Fabric-DitK3IEP.js";
2
2
  import React, { JSX, Key, ReactNode } from "react";
3
3
 
4
+ //#region ../fabric-core/src/types.d.ts
5
+ type JSDoc = {
6
+ comments: string[];
7
+ };
8
+ //#endregion
4
9
  //#region src/utils/getFunctionParams.d.ts
5
10
  type Param = {
6
11
  /**
@@ -79,9 +84,6 @@ type DOMElement = {
79
84
  type NodeNames = ElementNames | TextName;
80
85
  type KubbNode = ReactNode;
81
86
  type KubbElement = JSX.Element;
82
- type JSDoc = {
83
- comments: string[];
84
- };
85
87
  type KubbTextProps = {
86
88
  children?: KubbNode;
87
89
  };
@@ -100,5 +102,5 @@ type KubbImportProps = Import;
100
102
  type KubbExportProps = Export;
101
103
  type LineBreakProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
102
104
  //#endregion
103
- export { Param as _, JSDoc as a, KubbExportProps as c, KubbNode as d, KubbSourceProps as f, FunctionParams as g, TextNode as h, ElementNames as i, KubbFileProps as l, LineBreakProps as m, DOMNode as n, Key as o, KubbTextProps as p, DOMNodeAttribute as r, KubbElement as s, DOMElement as t, KubbImportProps as u, Params as v, createFunctionParams as y };
104
- //# sourceMappingURL=types-CSUzVTpn.d.ts.map
105
+ export { Params as _, Key as a, KubbFileProps as c, KubbSourceProps as d, KubbTextProps as f, Param as g, FunctionParams as h, ElementNames as i, KubbImportProps as l, TextNode as m, DOMNode as n, KubbElement as o, LineBreakProps as p, DOMNodeAttribute as r, KubbExportProps as s, DOMElement as t, KubbNode as u, createFunctionParams as v, JSDoc as y };
106
+ //# sourceMappingURL=types-BL7PkfqA.d.ts.map
@@ -1,6 +1,11 @@
1
1
  import { b as Source, g as Import, h as File, p as Export } from "./Fabric-C61uYmUy.cjs";
2
2
  import React, { JSX, Key, ReactNode } from "react";
3
3
 
4
+ //#region ../fabric-core/src/types.d.ts
5
+ type JSDoc = {
6
+ comments: string[];
7
+ };
8
+ //#endregion
4
9
  //#region src/utils/getFunctionParams.d.ts
5
10
  type Param = {
6
11
  /**
@@ -79,9 +84,6 @@ type DOMElement = {
79
84
  type NodeNames = ElementNames | TextName;
80
85
  type KubbNode = ReactNode;
81
86
  type KubbElement = JSX.Element;
82
- type JSDoc = {
83
- comments: string[];
84
- };
85
87
  type KubbTextProps = {
86
88
  children?: KubbNode;
87
89
  };
@@ -100,5 +102,5 @@ type KubbImportProps = Import;
100
102
  type KubbExportProps = Export;
101
103
  type LineBreakProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
102
104
  //#endregion
103
- export { Param as _, JSDoc as a, KubbExportProps as c, KubbNode as d, KubbSourceProps as f, FunctionParams as g, TextNode as h, ElementNames as i, KubbFileProps as l, LineBreakProps as m, DOMNode as n, Key as o, KubbTextProps as p, DOMNodeAttribute as r, KubbElement as s, DOMElement as t, KubbImportProps as u, Params as v, createFunctionParams as y };
104
- //# sourceMappingURL=types-DP2mgqeb.d.cts.map
105
+ export { Params as _, Key as a, KubbFileProps as c, KubbSourceProps as d, KubbTextProps as f, Param as g, FunctionParams as h, ElementNames as i, KubbImportProps as l, TextNode as m, DOMNode as n, KubbElement as o, LineBreakProps as p, DOMNodeAttribute as r, KubbExportProps as s, DOMElement as t, KubbNode as u, createFunctionParams as v, JSDoc as y };
106
+ //# sourceMappingURL=types-BdOHT5YF.d.cts.map
package/dist/types.d.cts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { _ as KubbFile_d_exports, a as FabricOptions, i as FabricMode, n as FabricConfig, r as FabricContext } from "./Fabric-C61uYmUy.cjs";
2
- import { _ as Param, a as JSDoc, c as KubbExportProps, d as KubbNode, f as KubbSourceProps, h as TextNode, i as ElementNames, l as KubbFileProps, m as LineBreakProps, n as DOMNode, o as Key, p as KubbTextProps, r as DOMNodeAttribute, s as KubbElement, t as DOMElement, u as KubbImportProps, v as Params } from "./types-DP2mgqeb.cjs";
2
+ import { _ as Params, a as Key, c as KubbFileProps, d as KubbSourceProps, f as KubbTextProps, g as Param, i as ElementNames, l as KubbImportProps, m as TextNode, n as DOMNode, o as KubbElement, p as LineBreakProps, r as DOMNodeAttribute, s as KubbExportProps, t as DOMElement, u as KubbNode, y as JSDoc } from "./types-BdOHT5YF.cjs";
3
3
  export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, FabricConfig, FabricContext, FabricMode, FabricOptions, JSDoc, Key, KubbElement, KubbExportProps, KubbFile_d_exports as KubbFile, KubbFileProps, KubbImportProps, KubbNode, KubbSourceProps, KubbTextProps, LineBreakProps, Param, Params, TextNode };
package/dist/types.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { _ as KubbFile_d_exports, a as FabricOptions, i as FabricMode, n as FabricConfig, r as FabricContext } from "./Fabric-DitK3IEP.js";
2
- import { _ as Param, a as JSDoc, c as KubbExportProps, d as KubbNode, f as KubbSourceProps, h as TextNode, i as ElementNames, l as KubbFileProps, m as LineBreakProps, n as DOMNode, o as Key, p as KubbTextProps, r as DOMNodeAttribute, s as KubbElement, t as DOMElement, u as KubbImportProps, v as Params } from "./types-CSUzVTpn.js";
2
+ import { _ as Params, a as Key, c as KubbFileProps, d as KubbSourceProps, f as KubbTextProps, g as Param, i as ElementNames, l as KubbImportProps, m as TextNode, n as DOMNode, o as KubbElement, p as LineBreakProps, r as DOMNodeAttribute, s as KubbExportProps, t as DOMElement, u as KubbNode, y as JSDoc } from "./types-BL7PkfqA.js";
3
3
  export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, FabricConfig, FabricContext, FabricMode, FabricOptions, JSDoc, Key, KubbElement, KubbExportProps, KubbFile_d_exports as KubbFile, KubbFileProps, KubbImportProps, KubbNode, KubbSourceProps, KubbTextProps, LineBreakProps, Param, Params, TextNode };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/react-fabric",
3
- "version": "0.9.4",
3
+ "version": "0.10.0",
4
4
  "description": "React integration for Kubb, providing JSX runtime support and React component generation capabilities for code generation plugins.",
5
5
  "keywords": [
6
6
  "react",
@@ -111,10 +111,10 @@
111
111
  "react-devtools-core": "6.1.2",
112
112
  "signal-exit": "^4.1.0",
113
113
  "ws": "8.18.0",
114
- "@kubb/fabric-core": "0.9.4"
114
+ "@kubb/fabric-core": "0.10.0"
115
115
  },
116
116
  "devDependencies": {
117
- "@types/react": "^19.2.7",
117
+ "@types/react": "^19.2.8",
118
118
  "@types/react-reconciler": "0.32.0",
119
119
  "@types/ws": "^8.18.1",
120
120
  "react": "19.2.1",
@@ -1,27 +1,20 @@
1
- import { createContext, useContext } from 'react'
1
+ import { AppContext, provide, RootContext, useContext } from '@kubb/fabric-core'
2
2
  import type { KubbNode } from '../types.ts'
3
- import { RootContext } from './Root.tsx'
4
-
5
- export type AppContextProps<TMeta = unknown> = {
6
- /**
7
- * Exit (unmount)
8
- */
9
- readonly exit: (error?: Error) => void
10
- readonly meta: TMeta
11
- }
12
-
13
- const AppContext = createContext<AppContextProps | undefined>(undefined)
14
3
 
15
4
  type Props<TMeta = unknown> = {
16
5
  readonly children?: KubbNode
17
6
  readonly meta: TMeta
18
7
  }
19
8
 
9
+ /**
10
+ * Provides the current app context (meta and exit) to descendants.
11
+ * This component mirrors the Fabric app container in React.
12
+ */
20
13
  export function App<TMeta = unknown>({ meta, children }: Props<TMeta>) {
21
14
  const { exit } = useContext(RootContext)
15
+ provide(AppContext, { exit, meta })
22
16
 
23
- return <AppContext.Provider value={{ exit, meta }}>{children}</AppContext.Provider>
17
+ return children
24
18
  }
25
19
 
26
- App.Context = AppContext
27
20
  App.displayName = 'KubbApp'
@@ -27,6 +27,9 @@ type Props = {
27
27
  children?: KubbNode
28
28
  }
29
29
 
30
+ /**
31
+ * Renders a constant declaration. Supports optional export, type and JSDoc.
32
+ */
30
33
  export function Const({ name, export: canExport, type, JSDoc, asConst, children }: Props) {
31
34
  return (
32
35
  <>
@@ -1,22 +1,7 @@
1
+ import { FileCollector, FileCollectorContext, provide, useContext } from '@kubb/fabric-core'
1
2
  import type { KubbFile } from '@kubb/fabric-core/types'
2
- import { createContext } from 'react'
3
3
  import type { Key, KubbNode } from '../types.ts'
4
4
 
5
- export type FileContextProps<TMeta extends object = object> = {
6
- /**
7
- * Name to be used to dynamicly create the baseName(based on input.path).
8
- * Based on UNIX basename
9
- * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
10
- */
11
- baseName: KubbFile.BaseName
12
- /**
13
- * Path will be full qualified path to a specified file.
14
- */
15
- path: KubbFile.Path
16
- meta?: TMeta
17
- }
18
- const FileContext = createContext<FileContextProps>({} as FileContextProps)
19
-
20
5
  type BasePropsWithBaseName = {
21
6
  /**
22
7
  * Name to be used to dynamicly create the baseName(based on input.path).
@@ -48,16 +33,32 @@ type Props<TMeta> = BaseProps & {
48
33
  children?: KubbNode
49
34
  }
50
35
 
36
+ /**
37
+ * Registers a file in the FileCollector context and provides a scoped collector
38
+ * for children. When `baseName` and `path` are provided the file will be
39
+ * registered so it can be emitted by the collector later.
40
+ */
51
41
  export function File<TMeta extends object = object>({ children, ...rest }: Props<TMeta>) {
42
+ const collector = useContext(FileCollectorContext, new FileCollector())
43
+ provide(FileCollectorContext, collector)
44
+
52
45
  if (!rest.baseName || !rest.path) {
53
46
  return <>{children}</>
54
47
  }
55
48
 
56
- return (
57
- <kubb-file {...rest}>
58
- <FileContext.Provider value={{ baseName: rest.baseName, path: rest.path, meta: rest.meta }}>{children}</FileContext.Provider>
59
- </kubb-file>
60
- )
49
+ // Register this file with the collector
50
+ collector.add({
51
+ baseName: rest.baseName,
52
+ path: rest.path,
53
+ meta: rest.meta || ({} as TMeta),
54
+ banner: rest.banner,
55
+ footer: rest.footer,
56
+ sources: [],
57
+ imports: [],
58
+ exports: [],
59
+ })
60
+
61
+ return <kubb-file {...rest}>{children}</kubb-file>
61
62
  }
62
63
 
63
64
  File.displayName = 'KubbFile'
@@ -67,6 +68,12 @@ type FileSourceProps = Omit<KubbFile.Source, 'value'> & {
67
68
  children?: KubbNode
68
69
  }
69
70
 
71
+ /**
72
+ * File.Source
73
+ *
74
+ * Marks a block of source text to be associated with the current file when
75
+ * rendering with the FileCollector. Children are treated as the source string.
76
+ */
70
77
  function FileSource({ isTypeOnly, name, isExportable, isIndexable, children }: FileSourceProps) {
71
78
  return (
72
79
  <kubb-source name={name} isTypeOnly={isTypeOnly} isExportable={isExportable} isIndexable={isIndexable}>
@@ -79,6 +86,12 @@ FileSource.displayName = 'KubbFileSource'
79
86
 
80
87
  type FileExportProps = KubbFile.Export & { key?: Key }
81
88
 
89
+ /**
90
+ * File.Export
91
+ *
92
+ * Declares an export entry for the current file. This will be collected by
93
+ * the FileCollector for later emission.
94
+ */
82
95
  function FileExport({ name, path, isTypeOnly, asAlias }: FileExportProps) {
83
96
  return <kubb-export name={name} path={path} isTypeOnly={isTypeOnly || false} asAlias={asAlias} />
84
97
  }
@@ -87,6 +100,11 @@ FileExport.displayName = 'KubbFileExport'
87
100
 
88
101
  type FileImportProps = KubbFile.Import & { key?: Key }
89
102
 
103
+ /**
104
+ * File.Import
105
+ *
106
+ * Declares an import entry for the current file.
107
+ */
90
108
  function FileImport({ name, root, path, isTypeOnly, isNameSpace }: FileImportProps) {
91
109
  return <kubb-import name={name} root={root} path={path} isNameSpace={isNameSpace} isTypeOnly={isTypeOnly || false} />
92
110
  }
@@ -96,4 +114,3 @@ FileImport.displayName = 'KubbFileImport'
96
114
  File.Export = FileExport
97
115
  File.Import = FileImport
98
116
  File.Source = FileSource
99
- File.Context = FileContext
@@ -41,6 +41,10 @@ type Props = {
41
41
  children?: KubbNode
42
42
  }
43
43
 
44
+ /**
45
+ * Renders a function definition using the Fabric templating primitives.
46
+ * Supports optional export/default/async flags, generics, params and JSDoc.
47
+ */
44
48
  export function Function({ name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, children }: Props) {
45
49
  return (
46
50
  <>
@@ -87,6 +91,12 @@ type ArrowFunctionProps = Props & {
87
91
  singleLine?: boolean
88
92
  }
89
93
 
94
+ /**
95
+ * ArrowFunction
96
+ *
97
+ * Renders an arrow function definition. Supports the same flags as `Function`.
98
+ * Use `singleLine` to render the body as a single-line expression.
99
+ */
90
100
  function ArrowFunction({ name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine, children }: ArrowFunctionProps) {
91
101
  return (
92
102
  <>
@@ -10,6 +10,9 @@ type IndentProps = {
10
10
  /**
11
11
  * Indents all children by `size` spaces.
12
12
  * Collapses consecutive <br /> tags to at most 2.
13
+ *
14
+ * Indent will dedent and re-indent string children and will prefix
15
+ * non-string children with the requested number of spaces.
13
16
  */
14
17
  export function Indent({ size = 2, children }: IndentProps) {
15
18
  if (!children) return null
@@ -1,4 +1,5 @@
1
- import { Component, createContext } from 'react'
1
+ import { provide, RootContext } from '@kubb/fabric-core'
2
+ import { Component } from 'react'
2
3
 
3
4
  import type { KubbNode } from '../types.ts'
4
5
 
@@ -32,17 +33,6 @@ class ErrorBoundary extends Component<{
32
33
  }
33
34
  }
34
35
 
35
- export type RootContextProps = {
36
- /**
37
- * Exit (unmount) the whole Ink app.
38
- */
39
- readonly exit: (error?: Error) => void
40
- }
41
-
42
- export const RootContext = createContext<RootContextProps>({
43
- exit: () => {},
44
- })
45
-
46
36
  type RootProps = {
47
37
  /**
48
38
  * Exit (unmount) hook
@@ -55,17 +45,26 @@ type RootProps = {
55
45
  readonly children?: KubbNode
56
46
  }
57
47
 
48
+ /**
49
+ * Provides the root context (exit hook) and wraps children into an
50
+ * ErrorBoundary so errors can be forwarded to the `onError` handler.
51
+ *
52
+ * This component provides the root behaviour for the React Fabric runtime.
53
+ *
54
+ * Returns a React node tree representing the root of the Fabric app.
55
+ */
58
56
  export function Root({ onError, onExit, children }: RootProps) {
57
+ provide(RootContext, { exit: onExit })
58
+
59
59
  return (
60
60
  <ErrorBoundary
61
61
  onError={(error) => {
62
62
  onError(error)
63
63
  }}
64
64
  >
65
- <RootContext.Provider value={{ exit: onExit }}>{children}</RootContext.Provider>
65
+ {children}
66
66
  </ErrorBoundary>
67
67
  )
68
68
  }
69
69
 
70
- Root.Context = RootContext
71
70
  Root.displayName = 'KubbRoot'
@@ -18,6 +18,10 @@ type Props = {
18
18
  children?: KubbNode
19
19
  }
20
20
 
21
+ /**
22
+ * Renders a TypeScript type alias. Validates that the provided name starts
23
+ * with a capital letter and optionally emits JSDoc comments.
24
+ */
21
25
  export function Type({ name, export: canExport, JSDoc, children }: Props) {
22
26
  if (name.charAt(0).toUpperCase() !== name.charAt(0)) {
23
27
  throw new Error('Name should start with a capital letter(see TypeScript types)')
@@ -1,15 +1 @@
1
- import { useContext } from 'react'
2
- import { App, type AppContextProps } from '../components/App.tsx'
3
-
4
- /**
5
- * `useApp` will return the current App with plugin, pluginManager, fileManager and mode.
6
- */
7
- export function useApp<TMeta = unknown>(): AppContextProps<TMeta> {
8
- const app = useContext(App.Context)
9
-
10
- if (!app) {
11
- throw new Error('<App /> should be set')
12
- }
13
-
14
- return app as AppContextProps<TMeta>
15
- }
1
+ export { useApp } from '@kubb/fabric-core'
@@ -1,12 +1 @@
1
- import { useContext } from 'react'
2
- import type { FileContextProps } from '../components/File.tsx'
3
- import { File } from '../components/File.tsx'
4
-
5
- /**
6
- * `useFile` will return the current file when <File/> is used.
7
- */
8
- export function useFile(): FileContextProps {
9
- const file = useContext(File.Context)
10
-
11
- return file as FileContextProps
12
- }
1
+ export { useFile } from '@kubb/fabric-core'
@@ -1,18 +1,17 @@
1
- import { useContext } from 'react'
2
-
3
- import { Root } from '../components/Root.tsx'
1
+ import { RootContext, useContext } from '@kubb/fabric-core'
4
2
 
5
3
  /**
6
- * `useLifecycle` will return some helpers to exit/restart the generation.
4
+ * Provides lifecycle helpers that integrate with the Fabric runtime. The
5
+ * `exit` helper schedules a call to the RootContext exit function on the
6
+ * next tick to allow React to complete its render cycle first.
7
7
  */
8
8
  export function useLifecycle() {
9
- const { exit } = useContext(Root.Context)
9
+ const { exit } = useContext(RootContext, { exit: () => {} })
10
10
 
11
11
  return {
12
12
  exit: () => {
13
- const timeout = setTimeout(() => {
14
- clearTimeout(timeout)
15
-
13
+ // need this to let React finish its current render cycle
14
+ setTimeout(() => {
16
15
  exit()
17
16
  }, 0)
18
17
  },
package/src/index.ts CHANGED
@@ -14,16 +14,20 @@ export const useContext = React.useContext
14
14
  export const useEffect = React.useEffect
15
15
  export const useReducer = React.useReducer
16
16
  export const useRef = React.useRef
17
- // // components
17
+ // components
18
18
  export { App } from './components/App.tsx'
19
19
  export { Const } from './components/Const.tsx'
20
20
  export { File } from './components/File.tsx'
21
21
  export { Function } from './components/Function.tsx'
22
22
  export { Indent } from './components/Indent.tsx'
23
23
  export { Type } from './components/Type.tsx'
24
+
25
+ // composables
24
26
  export { useApp } from './composables/useApp.ts'
25
27
  export { useFile } from './composables/useFile.ts'
26
28
  export { useLifecycle } from './composables/useLifecycle.tsx'
29
+
30
+ // factories
27
31
  export { createReactFabric } from './createReactFabric.ts'
28
32
  export { Runtime } from './Runtime.tsx'
29
33
  // utils
package/src/types.ts CHANGED
@@ -50,10 +50,6 @@ export type KubbElement = JSX.Element
50
50
 
51
51
  export type { Key } from 'react'
52
52
 
53
- export type JSDoc = {
54
- comments: string[]
55
- }
56
-
57
53
  export type KubbTextProps = {
58
54
  children?: KubbNode
59
55
  }
@@ -1,8 +1 @@
1
- export function createJSDoc({ comments }: { comments: Array<string> }): string {
2
- const filtered = comments.filter((c) => c.trim())
3
- if (!filtered.length) {
4
- return ''
5
- }
6
-
7
- return `/**\n * ${filtered.join('\n * ')}\n */`
8
- }
1
+ export { createJSDoc } from '@kubb/fabric-core'
@@ -49,18 +49,22 @@ function order(items: Array<[key: string, item?: ParamItem]>) {
49
49
  [
50
50
  ([_key, item]) => {
51
51
  if (item?.children) {
52
- return undefined
52
+ return 0 // Treat items with children as required (they'll get = {} if all children are optional)
53
53
  }
54
- return !item?.default
55
- },
56
- ([_key, item]) => {
57
- if (item?.children) {
58
- return undefined
54
+ // Priority order: required (0) → optional (1) → default-only (2)
55
+ if (item?.optional) {
56
+ return 1 // Optional parameters (with or without default)
57
+ }
58
+ if (item?.default) {
59
+ // Parameters with default only (not marked as optional)
60
+ // Note: While the ParamItem type suggests optional and default are mutually exclusive,
61
+ // this handles the case where a parameter has a default value but isn't explicitly marked as optional
62
+ return 2
59
63
  }
60
- return !item?.optional
64
+ return 0 // Required parameters
61
65
  },
62
66
  ],
63
- ['desc', 'desc'],
67
+ ['asc'],
64
68
  )
65
69
  }
66
70