@kubb/fabric-core 0.11.7 → 0.12.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 (110) hide show
  1. package/dist/{Fabric-BoTE1-WX.d.cts → Fabric-BbVC650D.d.cts} +86 -15
  2. package/dist/{Fabric-CWquRFa2.d.ts → Fabric-eh92yS1R.d.ts} +86 -15
  3. package/dist/Root-BT59jU0W.js +931 -0
  4. package/dist/Root-BT59jU0W.js.map +1 -0
  5. package/dist/Root-SC_lWG_q.cjs +1057 -0
  6. package/dist/Root-SC_lWG_q.cjs.map +1 -0
  7. package/dist/{defaultParser-CFIT3sEE.cjs → defaultParser-2ym3KiZd.cjs} +3 -4
  8. package/dist/{defaultParser-CFIT3sEE.cjs.map → defaultParser-2ym3KiZd.cjs.map} +1 -1
  9. package/dist/{defaultParser-DZ2kzujH.js → defaultParser-DDFR9BTS.js} +2 -2
  10. package/dist/{defaultParser-DZ2kzujH.js.map → defaultParser-DDFR9BTS.js.map} +1 -1
  11. package/dist/{getRelativePath-y7WcYR5C.js → getRelativePath-COUEoqbz.js} +11 -2
  12. package/dist/getRelativePath-COUEoqbz.js.map +1 -0
  13. package/dist/{getRelativePath-BllDunh0.cjs → getRelativePath-jYLCpluV.cjs} +16 -1
  14. package/dist/getRelativePath-jYLCpluV.cjs.map +1 -0
  15. package/dist/index.cjs +129 -448
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +54 -90
  18. package/dist/index.d.ts +54 -90
  19. package/dist/index.js +92 -416
  20. package/dist/index.js.map +1 -1
  21. package/dist/parsers/typescript.cjs +7 -107
  22. package/dist/parsers/typescript.d.cts +1 -1
  23. package/dist/parsers/typescript.d.ts +1 -1
  24. package/dist/parsers/typescript.js +2 -101
  25. package/dist/parsers.cjs +7 -8
  26. package/dist/parsers.cjs.map +1 -1
  27. package/dist/parsers.d.cts +1 -1
  28. package/dist/parsers.d.ts +1 -1
  29. package/dist/parsers.js +3 -3
  30. package/dist/plugins.cjs +103 -9
  31. package/dist/plugins.cjs.map +1 -1
  32. package/dist/plugins.d.cts +32 -9
  33. package/dist/plugins.d.ts +32 -9
  34. package/dist/plugins.js +96 -3
  35. package/dist/plugins.js.map +1 -1
  36. package/dist/types-BI7rICUP.d.cts +31 -0
  37. package/dist/types-DpITKjSb.d.ts +32 -0
  38. package/dist/types.cjs +6 -0
  39. package/dist/types.cjs.map +1 -1
  40. package/dist/types.d.cts +4 -3
  41. package/dist/types.d.ts +4 -3
  42. package/dist/types.js +1 -1
  43. package/dist/types.js.map +1 -1
  44. package/dist/typescriptParser-DyosyI_A.js +101 -0
  45. package/dist/typescriptParser-DyosyI_A.js.map +1 -0
  46. package/dist/typescriptParser-qjzb2pIh.cjs +137 -0
  47. package/dist/typescriptParser-qjzb2pIh.cjs.map +1 -0
  48. package/dist/{TreeNode-DomNP5og.d.cts → useNodeTree-CmXKaRqq.d.cts} +10 -3
  49. package/dist/{TreeNode-C1VnIF0o.d.ts → useNodeTree-DUdlgys5.d.ts} +10 -3
  50. package/package.json +3 -2
  51. package/src/Fabric.ts +13 -5
  52. package/src/KubbFile.ts +3 -11
  53. package/src/components/App.ts +6 -5
  54. package/src/components/Br.ts +11 -0
  55. package/src/components/Const.ts +6 -5
  56. package/src/components/Dedent.ts +10 -0
  57. package/src/components/File.ts +21 -16
  58. package/src/components/Function.ts +17 -13
  59. package/src/components/Indent.ts +7 -0
  60. package/src/components/Root.ts +6 -5
  61. package/src/components/Type.ts +6 -5
  62. package/src/components/__snapshots__/arrow_function_with_generics.ts +3 -3
  63. package/src/components/__snapshots__/async_arrow_function.ts +3 -3
  64. package/src/components/__snapshots__/async_function.ts +2 -2
  65. package/src/components/__snapshots__/async_function_with_Promise_return_type.ts +2 -2
  66. package/src/components/__snapshots__/basic_arrow_function.ts +3 -3
  67. package/src/components/__snapshots__/basic_export.ts +1 -0
  68. package/src/components/__snapshots__/basic_function.ts +2 -2
  69. package/src/components/__snapshots__/basic_import.ts +1 -0
  70. package/src/components/__snapshots__/default_exported_arrow_function.ts +3 -3
  71. package/src/components/__snapshots__/default_exported_function.ts +2 -2
  72. package/src/components/__snapshots__/exported_arrow_function.ts +3 -3
  73. package/src/components/__snapshots__/exported_function.ts +2 -2
  74. package/src/components/__snapshots__/function_with_JSDoc.ts +2 -2
  75. package/src/components/__snapshots__/function_with_generics.ts +2 -2
  76. package/src/components/__snapshots__/function_with_parameters.ts +2 -2
  77. package/src/components/__snapshots__/function_with_return_type.ts +2 -2
  78. package/src/components/__snapshots__/matches_with_root_import.ts +1 -0
  79. package/src/components/__snapshots__/named_export.ts +1 -0
  80. package/src/components/__snapshots__/named_export_(object_advanced).ts +1 -0
  81. package/src/components/__snapshots__/named_import.ts +1 -0
  82. package/src/components/__snapshots__/named_import_(object).ts +1 -0
  83. package/src/components/__snapshots__/named_import_(object_advanced).ts +1 -0
  84. package/src/components/__snapshots__/named_typed_export.ts +1 -0
  85. package/src/components/__snapshots__/named_typed_import.ts +1 -0
  86. package/src/components/__snapshots__/typed_export.ts +1 -0
  87. package/src/components/__snapshots__/typed_import.ts +1 -0
  88. package/src/contexts/RenderContext.ts +13 -0
  89. package/src/createComponent.ts +34 -0
  90. package/src/index.ts +9 -9
  91. package/src/intrinsic.ts +143 -0
  92. package/src/plugins/fsxPlugin/Runtime.ts +96 -0
  93. package/src/plugins/fsxPlugin/fsxPlugin.ts +45 -0
  94. package/src/plugins/index.ts +1 -0
  95. package/src/types.ts +4 -1
  96. package/dist/TreeNode-CC3a0Bae.js +0 -447
  97. package/dist/TreeNode-CC3a0Bae.js.map +0 -1
  98. package/dist/TreeNode-CFchatCw.cjs +0 -494
  99. package/dist/TreeNode-CFchatCw.cjs.map +0 -1
  100. package/dist/defineParser-CVCxqqzB.cjs +0 -18
  101. package/dist/defineParser-CVCxqqzB.cjs.map +0 -1
  102. package/dist/defineParser-Lco7nlj0.js +0 -13
  103. package/dist/defineParser-Lco7nlj0.js.map +0 -1
  104. package/dist/getRelativePath-BllDunh0.cjs.map +0 -1
  105. package/dist/getRelativePath-y7WcYR5C.js.map +0 -1
  106. package/dist/parsers/typescript.cjs.map +0 -1
  107. package/dist/parsers/typescript.js.map +0 -1
  108. package/dist/types-DYepTJ6F.d.cts +0 -82
  109. package/dist/types-yNaQHNUB.d.ts +0 -83
  110. package/src/components/Text.ts +0 -27
package/dist/index.d.ts CHANGED
@@ -1,8 +1,18 @@
1
1
  import { n as __name } from "./chunk-8X4u0d05.js";
2
- import { a as FabricOptions, b as Source, c as FileManager, f as BaseName, g as Import, h as File$1, l as FileProcessor, n as FabricConfig, p as Export, t as Fabric, v as Path, y as ResolvedFile } from "./Fabric-CWquRFa2.js";
3
- import { t as TreeNode } from "./TreeNode-C1VnIF0o.js";
4
- import { a as createContext, c as unprovide, i as Context, l as ComponentNode, n as RootContext, o as inject, s as provide, t as JSDoc, u as useNodeTree } from "./types-yNaQHNUB.js";
2
+ import { A as Path, D as File$1, M as Source, O as Import, T as Export, _ as inject, b as FileManager, c as FabricOptions, d as renderIndent, f as renderIntrinsic, g as createContext, h as Context, j as ResolvedFile, n as FabricComponent, p as RenderContext, r as FabricConfig, s as FabricNode, t as Fabric, v as provide, w as BaseName, x as FileProcessor, y as unprovide } from "./Fabric-eh92yS1R.js";
3
+ import { n as useNodeTree, r as TreeNode, t as ComponentNode } from "./useNodeTree-DUdlgys5.js";
4
+ import { n as RootContext, t as JSDoc } from "./types-DpITKjSb.js";
5
5
 
6
+ //#region src/createComponent.d.ts
7
+ type MakeChildrenOptional<T extends object> = T extends {
8
+ children?: any;
9
+ } ? Omit<T, 'children'> & Partial<Pick<T, 'children'>> : T;
10
+ type ComponentBuilder<T extends object> = {
11
+ (...args: unknown extends T ? [] : {} extends Omit<T, 'children'> ? [props?: MakeChildrenOptional<T>] : [props: MakeChildrenOptional<T>]): FabricComponent<T>;
12
+ displayName?: string | undefined;
13
+ };
14
+ declare function createComponent<TProps extends object>(type: string, Component: (props: TProps) => FabricNode): ComponentBuilder<TProps>;
15
+ //#endregion
6
16
  //#region src/components/App.d.ts
7
17
  type AppProps<TMeta extends Object = Object> = {
8
18
  /**
@@ -12,18 +22,18 @@ type AppProps<TMeta extends Object = Object> = {
12
22
  /**
13
23
  * Children nodes.
14
24
  */
15
- children?: string | (() => string | Array<string>);
25
+ children?: FabricNode;
16
26
  };
17
27
  /**
18
28
  * App container containing the AppContext carrying `meta` and an `exit` hook.
19
29
  */
20
- declare function App<TMeta extends Object = Object>({
21
- children,
22
- ...props
23
- }: AppProps<TMeta>): string;
24
- declare namespace App {
25
- var displayName: string;
26
- }
30
+ declare const App: ComponentBuilder<AppProps<Object>>;
31
+ //#endregion
32
+ //#region src/components/Br.d.ts
33
+ /**
34
+ * Generates a line break in the output.
35
+ */
36
+ declare const Br: ComponentBuilder<object>;
27
37
  //#endregion
28
38
  //#region src/components/Const.d.ts
29
39
  type ConstProps = {
@@ -50,18 +60,18 @@ type ConstProps = {
50
60
  /**
51
61
  * Children nodes.
52
62
  */
53
- children?: string;
63
+ children?: FabricNode;
54
64
  };
55
65
  /**
56
66
  * Generates a TypeScript constant declaration.
57
67
  */
58
- declare function Const({
59
- children,
60
- ...props
61
- }: ConstProps): string;
62
- declare namespace Const {
63
- var displayName: string;
64
- }
68
+ declare const Const: ComponentBuilder<ConstProps>;
69
+ //#endregion
70
+ //#region src/components/Dedent.d.ts
71
+ /**
72
+ * Dedent component for reducing indentation level in rendered output.
73
+ */
74
+ declare const Dedent: ComponentBuilder<object>;
65
75
  //#endregion
66
76
  //#region src/components/File.d.ts
67
77
  type FileProps<TMeta extends object = object> = {
@@ -81,52 +91,43 @@ type FileProps<TMeta extends object = object> = {
81
91
  /**
82
92
  * Children nodes.
83
93
  */
84
- children?: string | (() => string | Array<string>);
94
+ children?: FabricNode;
85
95
  };
86
96
  /**
87
97
  * Adds files to the FileManager
88
98
  */
89
- declare function File<TMeta extends object = object>({
90
- children,
91
- ...props
92
- }: FileProps<TMeta>): string;
93
- declare namespace File {
94
- var Source: typeof FileSource;
95
- var Import: typeof FileImport;
96
- var Export: typeof FileExport;
97
- }
99
+ declare const File: ComponentBuilder<FileProps<object>> & {
100
+ Source: typeof FileSource;
101
+ Import: typeof FileImport;
102
+ Export: typeof FileExport;
103
+ };
98
104
  type FileSourceProps = Omit<Source, 'value'> & {
99
105
  /**
100
106
  * Children nodes.
101
107
  */
102
- children?: string | (() => string | Array<string>);
108
+ children?: FabricNode;
103
109
  };
104
110
  /**
105
111
  * FileSource - for adding source code to a file
106
112
  *
107
113
  * Returns the provided children string so the fsx renderer can collect it.
108
114
  */
109
- declare function FileSource({
110
- children,
111
- ...props
112
- }: FileSourceProps): string;
113
- type FileExportProps = Export;
115
+ declare const FileSource: ComponentBuilder<FileSourceProps>;
114
116
  /**
115
117
  * FileExport - for adding exports to a file
116
118
  *
117
119
  * No-op function used by renderers to record exports.
118
120
  */
119
- declare function FileExport(props: FileExportProps): string;
120
- type FileImportProps = Import;
121
+ declare const FileExport: ComponentBuilder<Export>;
121
122
  /**
122
123
  * FileImport - for adding imports to a file
123
124
  *
124
125
  * No-op function used by renderers to record imports.
125
126
  */
126
- declare function FileImport(props: FileImportProps): string;
127
+ declare const FileImport: ComponentBuilder<Import>;
127
128
  //#endregion
128
129
  //#region src/components/Function.d.ts
129
- type Props$1 = {
130
+ type FunctionProps = {
130
131
  /**
131
132
  * Name of the function.
132
133
  */
@@ -163,20 +164,15 @@ type Props$1 = {
163
164
  /**
164
165
  * Children nodes.
165
166
  */
166
- children?: string;
167
+ children?: FabricNode;
167
168
  };
168
169
  /**
169
170
  * Generates a TypeScript function declaration.
170
171
  */
171
- declare function Function({
172
- children,
173
- ...props
174
- }: Props$1): string;
175
- declare namespace Function {
176
- var displayName: string;
177
- var Arrow: typeof ArrowFunction;
178
- }
179
- type ArrowFunctionProps = Props$1 & {
172
+ declare const Function: ComponentBuilder<FunctionProps> & {
173
+ Arrow: typeof ArrowFunction;
174
+ };
175
+ type ArrowFunctionProps = FunctionProps & {
180
176
  /**
181
177
  * Create Arrow function in one line
182
178
  */
@@ -189,13 +185,10 @@ type ArrowFunctionProps = Props$1 & {
189
185
  * the same options as `Function`. Use `singleLine` to produce a one-line
190
186
  * arrow expression.
191
187
  */
192
- declare function ArrowFunction({
193
- children,
194
- ...props
195
- }: ArrowFunctionProps): string;
196
- declare namespace ArrowFunction {
197
- var displayName: string;
198
- }
188
+ declare const ArrowFunction: ComponentBuilder<ArrowFunctionProps>;
189
+ //#endregion
190
+ //#region src/components/Indent.d.ts
191
+ declare const Indent: ComponentBuilder<object>;
199
192
  //#endregion
200
193
  //#region src/components/Root.d.ts
201
194
  type RootProps = {
@@ -218,35 +211,12 @@ type RootProps = {
218
211
  /**
219
212
  * Children nodes.
220
213
  */
221
- children?: string | (() => string | Array<string> | undefined);
214
+ children?: FabricNode;
222
215
  };
223
216
  /**
224
217
  * This component provides the root behavior for the Fabric runtime.
225
218
  */
226
- declare function Root({
227
- onError,
228
- onExit,
229
- treeNode,
230
- fileManager,
231
- children
232
- }: RootProps): string;
233
- declare namespace Root {
234
- var displayName: string;
235
- }
236
- //#endregion
237
- //#region src/components/Text.d.ts
238
- type Props = {
239
- /**
240
- * Children nodes.
241
- */
242
- children?: string | (() => string | Array<string> | undefined);
243
- };
244
- /**
245
- * Generates a text node from string or function returning string/array of strings.
246
- */
247
- declare function Text({
248
- children
249
- }: Props): string;
219
+ declare const Root: ComponentBuilder<RootProps>;
250
220
  //#endregion
251
221
  //#region src/components/Type.d.ts
252
222
  type TypeProps = {
@@ -265,18 +235,12 @@ type TypeProps = {
265
235
  /**
266
236
  * Children nodes.
267
237
  */
268
- children?: string;
238
+ children?: FabricNode;
269
239
  };
270
240
  /**
271
241
  * Generates a TypeScript type declaration.
272
242
  */
273
- declare function Type({
274
- children,
275
- ...props
276
- }: TypeProps): string;
277
- declare namespace Type {
278
- var displayName: string;
279
- }
243
+ declare const Type: ComponentBuilder<TypeProps>;
280
244
  //#endregion
281
245
  //#region src/contexts/AppContext.d.ts
282
246
  type AppContextProps<TMeta extends object = object> = {
@@ -377,5 +341,5 @@ declare function createJSDoc({
377
341
  //#region src/utils/getRelativePath.d.ts
378
342
  declare function getRelativePath(rootDir?: string | null, filePath?: string | null, platform?: 'windows' | 'mac' | 'linux'): string;
379
343
  //#endregion
380
- export { App, AppContext, Const, type Context, type Fabric, File, FileContext, FileManager, FileProcessor, Function, NodeTreeContext, Root, RootContext, Text, TreeNode, Type, createContext, createFabric, createFile, createJSDoc, getRelativePath, inject, provide, unprovide, useApp, useContext, useFile, useFileManager, useLifecycle, useNodeTree };
344
+ export { App, AppContext, Br, Const, Dedent, File, FileContext, FileManager, FileProcessor, Function, Indent, NodeTreeContext, RenderContext, Root, RootContext, TreeNode, Type, createComponent, createContext, createFabric, createFile, createJSDoc, getRelativePath, inject, provide, renderIndent, renderIntrinsic, unprovide, useApp, useContext, useFile, useFileManager, useLifecycle, useNodeTree };
381
345
  //# sourceMappingURL=index.d.ts.map