@kubb/react-fabric 0.10.0 → 0.11.1
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/{Fabric-DitK3IEP.d.ts → Fabric-BELBf-bX.d.cts} +5 -5
- package/dist/{Fabric-C61uYmUy.d.cts → Fabric-DbJhvsCq.d.ts} +5 -5
- package/dist/globals.d.cts +2 -2
- package/dist/globals.d.ts +2 -2
- package/dist/index.cjs +123 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +71 -209
- package/dist/index.d.ts +59 -197
- package/dist/index.js +102 -39
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.d.cts +5 -5
- package/dist/jsx-dev-runtime.d.ts +3 -3
- package/dist/{jsx-namespace-BnoysbjP.d.cts → jsx-namespace-B6xgRlZE.d.cts} +2 -2
- package/dist/{jsx-namespace-D0a66_uR.d.ts → jsx-namespace-BNUcRr9S.d.ts} +2 -2
- package/dist/jsx-runtime.d.cts +5 -5
- package/dist/jsx-runtime.d.ts +3 -3
- package/dist/parsers.d.cts +1 -1
- package/dist/parsers.d.ts +1 -1
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.d.cts +3 -2
- package/dist/plugins.d.ts +3 -2
- package/dist/plugins.js +1 -1
- package/dist/{reactPlugin-4-kcMKwZ.d.ts → reactPlugin-9l7--xRt.d.ts} +7 -6
- package/dist/{reactPlugin-D4SmGYbm.cjs → reactPlugin-B8F6jVb5.cjs} +33 -13
- package/dist/reactPlugin-B8F6jVb5.cjs.map +1 -0
- package/dist/{reactPlugin-DT9toQPK.js → reactPlugin-CAtVV84d.js} +34 -14
- package/dist/reactPlugin-CAtVV84d.js.map +1 -0
- package/dist/{reactPlugin-B4xarQJX.d.cts → reactPlugin-DdQ8nZeK.d.cts} +7 -6
- package/dist/{types-BL7PkfqA.d.ts → types-QgmDVUxV.d.ts} +56 -3
- package/dist/{types-BdOHT5YF.d.cts → types-f5qVBVRo.d.cts} +56 -3
- package/dist/types.d.cts +3 -3
- package/dist/types.d.ts +3 -3
- package/package.json +2 -2
- package/src/Runtime.tsx +22 -12
- package/src/components/App.tsx +23 -7
- package/src/components/Const.tsx +17 -4
- package/src/components/File.tsx +83 -24
- package/src/components/Function.tsx +28 -7
- package/src/components/Root.tsx +23 -16
- package/src/components/Type.tsx +17 -4
- package/src/components/__snapshots__/arrow_function.ts +3 -0
- package/src/components/__snapshots__/arrow_function_default.ts +3 -0
- package/src/components/__snapshots__/arrow_function_generics.ts +3 -0
- package/src/components/__snapshots__/arrow_function_single_line.ts +1 -0
- package/src/components/__snapshots__/arrow_function_with_generics.ts +3 -0
- package/src/components/__snapshots__/async_arrow_function.ts +3 -0
- package/src/components/__snapshots__/async_function.ts +3 -0
- package/src/components/__snapshots__/async_function_with_Promise_return_type.ts +3 -0
- package/src/components/__snapshots__/basic_arrow_function.ts +3 -0
- package/src/components/__snapshots__/basic_const.ts +1 -0
- package/src/components/__snapshots__/basic_export.ts +1 -0
- package/src/components/__snapshots__/basic_function.ts +3 -0
- package/src/components/__snapshots__/basic_import.ts +1 -0
- package/src/components/__snapshots__/basic_type.ts +1 -0
- package/src/components/__snapshots__/const_with_JSDoc.ts +4 -0
- package/src/components/__snapshots__/const_with_as_const.ts +1 -0
- package/src/components/__snapshots__/const_with_type.ts +1 -0
- package/src/components/__snapshots__/default_exported_arrow_function.ts +3 -0
- package/src/components/__snapshots__/default_exported_function.ts +3 -0
- package/src/components/__snapshots__/exported_arrow_function.ts +3 -0
- package/src/components/__snapshots__/exported_const.ts +1 -0
- package/src/components/__snapshots__/exported_function.ts +3 -0
- package/src/components/__snapshots__/exported_type.ts +1 -0
- package/src/components/__snapshots__/function_generics.ts +3 -0
- package/src/components/__snapshots__/function_with_JSDoc.ts +6 -0
- package/src/components/__snapshots__/function_with_comments.ts +6 -0
- package/src/components/__snapshots__/function_with_generics.ts +3 -0
- package/src/components/__snapshots__/function_with_parameters.ts +3 -0
- package/src/components/__snapshots__/function_with_params.ts +3 -0
- package/src/components/__snapshots__/function_with_returnType.ts +3 -0
- package/src/components/__snapshots__/function_with_return_type.ts +3 -0
- package/src/components/__snapshots__/matches_with_root_import.ts +1 -0
- package/src/components/__snapshots__/multiple_functions.ts +3 -0
- package/src/components/__snapshots__/named_export.ts +1 -0
- package/src/components/__snapshots__/named_export_(object_advanced).ts +1 -0
- package/src/components/__snapshots__/named_import.ts +1 -0
- package/src/components/__snapshots__/named_import_(object).ts +1 -0
- package/src/components/__snapshots__/named_import_(object_advanced).ts +1 -0
- package/src/components/__snapshots__/named_typed_export.ts +1 -0
- package/src/components/__snapshots__/named_typed_import.ts +1 -0
- package/src/components/__snapshots__/single_line_arrow_function.ts +1 -0
- package/src/components/__snapshots__/type_with_JSDoc.ts +4 -0
- package/src/components/__snapshots__/typed_export.ts +1 -0
- package/src/components/__snapshots__/typed_import.ts +1 -0
- package/src/composables/useLifecycle.tsx +1 -1
- package/src/index.ts +1 -1
- package/src/plugins/reactPlugin.ts +7 -6
- package/dist/reactPlugin-D4SmGYbm.cjs.map +0 -1
- package/dist/reactPlugin-DT9toQPK.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,47 +1,17 @@
|
|
|
1
|
-
import { a as FabricOptions, b as Source, c as FileManager, f as BaseName, g as Import, h as File$1, i as FabricMode, l as FileProcessor, n as FabricConfig, p as Export, t as Fabric, v as Path, y as ResolvedFile } from "./Fabric-
|
|
2
|
-
import { a as Key, h as FunctionParams, u as KubbNode, v as createFunctionParams, y as JSDoc } from "./types-
|
|
3
|
-
import { t as Options$1 } from "./reactPlugin-
|
|
1
|
+
import { a as FabricOptions, b as Source, c as FileManager, f as BaseName, g as Import, h as File$1, i as FabricMode, l as FileProcessor, n as FabricConfig, p as Export, t as Fabric, v as Path, y as ResolvedFile } from "./Fabric-DbJhvsCq.js";
|
|
2
|
+
import { a as Key, h as FunctionParams, u as KubbNode, v as createFunctionParams, y as JSDoc } from "./types-QgmDVUxV.js";
|
|
3
|
+
import { t as Options$1 } from "./reactPlugin-9l7--xRt.js";
|
|
4
4
|
import * as react3 from "react";
|
|
5
5
|
import React, { ReactNode } from "react";
|
|
6
6
|
|
|
7
|
-
//#region ../fabric-core/src/components/Root.d.ts
|
|
8
|
-
type RootProps = {
|
|
9
|
-
/**
|
|
10
|
-
* Exit (unmount) hook
|
|
11
|
-
*/
|
|
12
|
-
readonly onExit: (error?: Error) => void;
|
|
13
|
-
/**
|
|
14
|
-
* Error hook
|
|
15
|
-
*/
|
|
16
|
-
readonly onError: (error: Error) => void;
|
|
17
|
-
readonly children?: string;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Top-level root for fsx renderers. Returns children content and ensures
|
|
21
|
-
* `onError` is called for runtime exceptions. Provides a RootContext with
|
|
22
|
-
* an `exit` hook for downstream consumers.
|
|
23
|
-
*/
|
|
24
|
-
declare function Root({
|
|
25
|
-
onError,
|
|
26
|
-
children
|
|
27
|
-
}: Omit<RootProps, 'onExit'>): string;
|
|
28
|
-
declare namespace Root {
|
|
29
|
-
var displayName: string;
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
7
|
//#region ../fabric-core/src/contexts/AppContext.d.ts
|
|
33
|
-
type AppContextProps<TMeta =
|
|
8
|
+
type AppContextProps<TMeta extends object = object> = {
|
|
34
9
|
/**
|
|
35
10
|
* Exit (unmount)
|
|
36
11
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
12
|
+
exit: (error?: Error) => void;
|
|
13
|
+
meta: TMeta;
|
|
39
14
|
};
|
|
40
|
-
/**
|
|
41
|
-
* Provides app-level metadata and lifecycle hooks (like `exit`) to
|
|
42
|
-
* components and composables within a Fabric runtime.
|
|
43
|
-
*/
|
|
44
|
-
declare const AppContext: Context<AppContextProps<unknown> | undefined>;
|
|
45
15
|
//#endregion
|
|
46
16
|
//#region ../fabric-core/src/composables/useApp.d.ts
|
|
47
17
|
/**
|
|
@@ -49,61 +19,7 @@ declare const AppContext: Context<AppContextProps<unknown> | undefined>;
|
|
|
49
19
|
*
|
|
50
20
|
* Throws an error when there is no AppContext available.
|
|
51
21
|
*/
|
|
52
|
-
declare function useApp<TMeta =
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region ../fabric-core/src/context.d.ts
|
|
55
|
-
/**
|
|
56
|
-
* Context type that carries type information about its value
|
|
57
|
-
* This is a branded symbol type that enables type-safe context usage
|
|
58
|
-
*/
|
|
59
|
-
type Context<T> = symbol & {
|
|
60
|
-
readonly __type: T;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Provides a value to descendant components (Vue 3 style)
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```ts
|
|
67
|
-
* const ThemeKey = Symbol('theme')
|
|
68
|
-
* provide(ThemeKey, { color: 'blue' })
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
declare function provide<T>(key: symbol | Context<T>, value: T): void;
|
|
72
|
-
/**
|
|
73
|
-
* Injects a value provided by an ancestor component (Vue 3 style)
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```ts
|
|
77
|
-
* const theme = inject(ThemeKey, { color: 'default' })
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
declare function inject<T>(key: symbol | Context<T>, defaultValue?: T): T;
|
|
81
|
-
/**
|
|
82
|
-
* Unprovides a value (for cleanup)
|
|
83
|
-
* @internal
|
|
84
|
-
*/
|
|
85
|
-
declare function unprovide<T>(key: symbol | Context<T>): void;
|
|
86
|
-
//#endregion
|
|
87
|
-
//#region ../fabric-core/src/utils/FileCollector.d.ts
|
|
88
|
-
/**
|
|
89
|
-
* FileCollector is used to collect files from components via context
|
|
90
|
-
* instead of walking the DOM tree.
|
|
91
|
-
*/
|
|
92
|
-
declare class FileCollector {
|
|
93
|
-
#private;
|
|
94
|
-
/**
|
|
95
|
-
* Add a file to the collector
|
|
96
|
-
*/
|
|
97
|
-
add(file: File$1): void;
|
|
98
|
-
/**
|
|
99
|
-
* Get all collected files
|
|
100
|
-
*/
|
|
101
|
-
get files(): Array<File$1>;
|
|
102
|
-
/**
|
|
103
|
-
* Clear all collected files
|
|
104
|
-
*/
|
|
105
|
-
clear(): void;
|
|
106
|
-
}
|
|
22
|
+
declare function useApp<TMeta extends object = object>(): AppContextProps<TMeta>;
|
|
107
23
|
//#endregion
|
|
108
24
|
//#region ../fabric-core/src/composables/useFile.d.ts
|
|
109
25
|
/**
|
|
@@ -112,26 +28,7 @@ declare class FileCollector {
|
|
|
112
28
|
* Throws when no FileCollector is present in context — ensure a Fabric that
|
|
113
29
|
* provides a FileCollector is mounted before calling this hook.
|
|
114
30
|
*/
|
|
115
|
-
declare function useFile():
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region ../fabric-core/src/contexts/FileCollectorContext.d.ts
|
|
118
|
-
/**
|
|
119
|
-
* Context for collecting files - provided by createFsxFabric
|
|
120
|
-
*/
|
|
121
|
-
declare const FileCollectorContext: Context<FileCollector | null>;
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region ../fabric-core/src/contexts/RootContext.d.ts
|
|
124
|
-
type RootContextProps = {
|
|
125
|
-
/**
|
|
126
|
-
* Exit (unmount) the whole app.
|
|
127
|
-
*/
|
|
128
|
-
readonly exit: (error?: Error) => void;
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* Provides a top-level lifecycle hook (`exit`) for terminating the Fabric
|
|
132
|
-
* runtime. This context is available at the root of a Fabric app.
|
|
133
|
-
*/
|
|
134
|
-
declare const RootContext: Context<RootContextProps>;
|
|
31
|
+
declare function useFile(): ResolvedFile | null;
|
|
135
32
|
//#endregion
|
|
136
33
|
//#region ../fabric-core/src/createFabric.d.ts
|
|
137
34
|
/**
|
|
@@ -149,35 +46,30 @@ declare function createFabric<T extends FabricOptions>(config?: FabricConfig<T>)
|
|
|
149
46
|
*/
|
|
150
47
|
declare function createFile<TMeta extends object = object>(file: File$1<TMeta>): ResolvedFile<TMeta>;
|
|
151
48
|
//#endregion
|
|
152
|
-
//#region ../fabric-core/src/utils/createJSDoc.d.ts
|
|
153
|
-
/**
|
|
154
|
-
* Create JSDoc comment block from comments array
|
|
155
|
-
*/
|
|
156
|
-
declare function createJSDoc({
|
|
157
|
-
comments
|
|
158
|
-
}: {
|
|
159
|
-
comments: string[];
|
|
160
|
-
}): string;
|
|
161
|
-
//#endregion
|
|
162
49
|
//#region src/components/App.d.ts
|
|
163
|
-
type
|
|
164
|
-
|
|
165
|
-
|
|
50
|
+
type AppProps<TMeta extends object = object> = {
|
|
51
|
+
/**
|
|
52
|
+
* Metadata associated with the App.
|
|
53
|
+
*/
|
|
54
|
+
meta?: TMeta;
|
|
55
|
+
/**
|
|
56
|
+
* Children nodes.
|
|
57
|
+
*/
|
|
58
|
+
children?: KubbNode;
|
|
166
59
|
};
|
|
167
60
|
/**
|
|
168
|
-
*
|
|
169
|
-
* This component mirrors the Fabric app container in React.
|
|
61
|
+
* App container containing the AppContext carrying `meta` and an `exit` hook.
|
|
170
62
|
*/
|
|
171
|
-
declare function App<TMeta =
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}:
|
|
63
|
+
declare function App<TMeta extends object = object>({
|
|
64
|
+
children,
|
|
65
|
+
...props
|
|
66
|
+
}: AppProps<TMeta>): react3.ReactNode;
|
|
175
67
|
declare namespace App {
|
|
176
68
|
var displayName: string;
|
|
177
69
|
}
|
|
178
70
|
//#endregion
|
|
179
71
|
//#region src/components/Const.d.ts
|
|
180
|
-
type
|
|
72
|
+
type ConstProps = {
|
|
181
73
|
key?: Key;
|
|
182
74
|
/**
|
|
183
75
|
* Name of the const
|
|
@@ -199,19 +91,18 @@ type Props$3 = {
|
|
|
199
91
|
* Use of `const` assertions
|
|
200
92
|
*/
|
|
201
93
|
asConst?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Children nodes.
|
|
96
|
+
*/
|
|
202
97
|
children?: KubbNode;
|
|
203
98
|
};
|
|
204
99
|
/**
|
|
205
|
-
*
|
|
100
|
+
* Generates a TypeScript constant declaration.
|
|
206
101
|
*/
|
|
207
102
|
declare function Const({
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
JSDoc,
|
|
212
|
-
asConst,
|
|
213
|
-
children
|
|
214
|
-
}: Props$3): react3.JSX.Element;
|
|
103
|
+
children,
|
|
104
|
+
...props
|
|
105
|
+
}: ConstProps): react3.JSX.Element;
|
|
215
106
|
declare namespace Const {
|
|
216
107
|
var displayName: string;
|
|
217
108
|
}
|
|
@@ -237,7 +128,7 @@ type BasePropsWithoutBaseName = {
|
|
|
237
128
|
path?: Path;
|
|
238
129
|
};
|
|
239
130
|
type BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName;
|
|
240
|
-
type Props$
|
|
131
|
+
type Props$1<TMeta> = BaseProps & {
|
|
241
132
|
key?: Key;
|
|
242
133
|
meta?: TMeta;
|
|
243
134
|
banner?: string;
|
|
@@ -245,14 +136,12 @@ type Props$2<TMeta> = BaseProps & {
|
|
|
245
136
|
children?: KubbNode;
|
|
246
137
|
};
|
|
247
138
|
/**
|
|
248
|
-
*
|
|
249
|
-
* for children. When `baseName` and `path` are provided the file will be
|
|
250
|
-
* registered so it can be emitted by the collector later.
|
|
139
|
+
* Adds files to the FileManager
|
|
251
140
|
*/
|
|
252
141
|
declare function File<TMeta extends object = object>({
|
|
253
142
|
children,
|
|
254
|
-
...
|
|
255
|
-
}: Props$
|
|
143
|
+
...props
|
|
144
|
+
}: Props$1<TMeta>): react3.JSX.Element;
|
|
256
145
|
declare namespace File {
|
|
257
146
|
var displayName: string;
|
|
258
147
|
var Export: typeof FileExport;
|
|
@@ -270,11 +159,8 @@ type FileSourceProps = Omit<Source, 'value'> & {
|
|
|
270
159
|
* rendering with the FileCollector. Children are treated as the source string.
|
|
271
160
|
*/
|
|
272
161
|
declare function FileSource({
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
isExportable,
|
|
276
|
-
isIndexable,
|
|
277
|
-
children
|
|
162
|
+
children,
|
|
163
|
+
...props
|
|
278
164
|
}: FileSourceProps): react3.JSX.Element;
|
|
279
165
|
declare namespace FileSource {
|
|
280
166
|
var displayName: string;
|
|
@@ -288,12 +174,7 @@ type FileExportProps = Export & {
|
|
|
288
174
|
* Declares an export entry for the current file. This will be collected by
|
|
289
175
|
* the FileCollector for later emission.
|
|
290
176
|
*/
|
|
291
|
-
declare function FileExport(
|
|
292
|
-
name,
|
|
293
|
-
path,
|
|
294
|
-
isTypeOnly,
|
|
295
|
-
asAlias
|
|
296
|
-
}: FileExportProps): react3.JSX.Element;
|
|
177
|
+
declare function FileExport(props: FileExportProps): react3.JSX.Element;
|
|
297
178
|
declare namespace FileExport {
|
|
298
179
|
var displayName: string;
|
|
299
180
|
}
|
|
@@ -305,19 +186,13 @@ type FileImportProps = Import & {
|
|
|
305
186
|
*
|
|
306
187
|
* Declares an import entry for the current file.
|
|
307
188
|
*/
|
|
308
|
-
declare function FileImport(
|
|
309
|
-
name,
|
|
310
|
-
root,
|
|
311
|
-
path,
|
|
312
|
-
isTypeOnly,
|
|
313
|
-
isNameSpace
|
|
314
|
-
}: FileImportProps): react3.JSX.Element;
|
|
189
|
+
declare function FileImport(props: FileImportProps): react3.JSX.Element;
|
|
315
190
|
declare namespace FileImport {
|
|
316
191
|
var displayName: string;
|
|
317
192
|
}
|
|
318
193
|
//#endregion
|
|
319
194
|
//#region src/components/Function.d.ts
|
|
320
|
-
type Props
|
|
195
|
+
type Props = {
|
|
321
196
|
key?: Key;
|
|
322
197
|
/**
|
|
323
198
|
* Name of the function.
|
|
@@ -352,28 +227,23 @@ type Props$1 = {
|
|
|
352
227
|
* Options for JSdocs.
|
|
353
228
|
*/
|
|
354
229
|
JSDoc?: JSDoc;
|
|
355
|
-
|
|
230
|
+
/**
|
|
231
|
+
* Children nodes.
|
|
232
|
+
*/
|
|
233
|
+
children?: string;
|
|
356
234
|
};
|
|
357
235
|
/**
|
|
358
|
-
*
|
|
359
|
-
* Supports optional export/default/async flags, generics, params and JSDoc.
|
|
236
|
+
* Generates a TypeScript function declaration.
|
|
360
237
|
*/
|
|
361
238
|
declare function Function({
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
async,
|
|
366
|
-
generics,
|
|
367
|
-
params,
|
|
368
|
-
returnType,
|
|
369
|
-
JSDoc,
|
|
370
|
-
children
|
|
371
|
-
}: Props$1): react3.JSX.Element;
|
|
239
|
+
children,
|
|
240
|
+
...props
|
|
241
|
+
}: Props): react3.JSX.Element;
|
|
372
242
|
declare namespace Function {
|
|
373
243
|
var displayName: string;
|
|
374
244
|
var Arrow: typeof ArrowFunction;
|
|
375
245
|
}
|
|
376
|
-
type ArrowFunctionProps = Props
|
|
246
|
+
type ArrowFunctionProps = Props & {
|
|
377
247
|
/**
|
|
378
248
|
* Create Arrow function in one line
|
|
379
249
|
*/
|
|
@@ -386,16 +256,8 @@ type ArrowFunctionProps = Props$1 & {
|
|
|
386
256
|
* Use `singleLine` to render the body as a single-line expression.
|
|
387
257
|
*/
|
|
388
258
|
declare function ArrowFunction({
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
export: canExport,
|
|
392
|
-
async,
|
|
393
|
-
generics,
|
|
394
|
-
params,
|
|
395
|
-
returnType,
|
|
396
|
-
JSDoc,
|
|
397
|
-
singleLine,
|
|
398
|
-
children
|
|
259
|
+
children,
|
|
260
|
+
...props
|
|
399
261
|
}: ArrowFunctionProps): react3.JSX.Element;
|
|
400
262
|
declare namespace ArrowFunction {
|
|
401
263
|
var displayName: string;
|
|
@@ -419,7 +281,7 @@ declare function Indent({
|
|
|
419
281
|
}: IndentProps): React.JSX.Element | null;
|
|
420
282
|
//#endregion
|
|
421
283
|
//#region src/components/Type.d.ts
|
|
422
|
-
type
|
|
284
|
+
type TypeProps = {
|
|
423
285
|
key?: Key;
|
|
424
286
|
/**
|
|
425
287
|
* Name of the type, this needs to start with a capital letter.
|
|
@@ -433,18 +295,18 @@ type Props = {
|
|
|
433
295
|
* Options for JSdocs.
|
|
434
296
|
*/
|
|
435
297
|
JSDoc?: JSDoc;
|
|
298
|
+
/**
|
|
299
|
+
* Children nodes.
|
|
300
|
+
*/
|
|
436
301
|
children?: KubbNode;
|
|
437
302
|
};
|
|
438
303
|
/**
|
|
439
|
-
*
|
|
440
|
-
* with a capital letter and optionally emits JSDoc comments.
|
|
304
|
+
* Generates a TypeScript type declaration.
|
|
441
305
|
*/
|
|
442
306
|
declare function Type({
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
children
|
|
447
|
-
}: Props): react3.JSX.Element;
|
|
307
|
+
children,
|
|
308
|
+
...props
|
|
309
|
+
}: TypeProps): react3.JSX.Element;
|
|
448
310
|
declare namespace Type {
|
|
449
311
|
var displayName: string;
|
|
450
312
|
}
|
|
@@ -507,5 +369,5 @@ declare const useEffect: typeof react3.useEffect;
|
|
|
507
369
|
declare const useReducer: typeof react3.useReducer;
|
|
508
370
|
declare const useRef: typeof react3.useRef;
|
|
509
371
|
//#endregion
|
|
510
|
-
export { App,
|
|
372
|
+
export { App, Const, type Fabric, File, FileManager, FileProcessor, Fragment, Function, FunctionParams, Indent, Runtime, Type, createContext, createElement, createFabric, createFile, createFunctionParams, createReactFabric, use, useApp, useContext, useEffect, useFile, useLifecycle, useReducer, useRef, useState };
|
|
511
373
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -2,21 +2,24 @@ import { r as __toESM } from "./chunk-BCPZiDLE.js";
|
|
|
2
2
|
import { t as require_react } from "./react-DfIUVisP.js";
|
|
3
3
|
import { i as jsxs, n as jsx, t as Fragment$1 } from "./jsx-runtime-Isgf9orn.js";
|
|
4
4
|
import { t as open } from "./devtools-8_UKWDTl.js";
|
|
5
|
-
import { a as _classPrivateFieldInitSpec, i as _classPrivateFieldGet2, n as Runtime, r as _classPrivateFieldSet2, t as reactPlugin } from "./reactPlugin-
|
|
6
|
-
import { AppContext,
|
|
5
|
+
import { a as _classPrivateFieldInitSpec, i as _classPrivateFieldGet2, n as Runtime, r as _classPrivateFieldSet2, t as reactPlugin } from "./reactPlugin-CAtVV84d.js";
|
|
6
|
+
import { AppContext, FileContext, FileManager, FileProcessor, NodeTreeContext, RootContext, createFabric, createFabric as createFabric$1, createFile, createJSDoc, provide, useApp, useContext as useContext$1, useFile, useFile as useFile$1, useFileManager, useNodeTree } from "@kubb/fabric-core";
|
|
7
7
|
import dedent from "dedent";
|
|
8
8
|
import { orderBy } from "natural-orderby";
|
|
9
9
|
|
|
10
|
-
export * from "@kubb/fabric-core"
|
|
11
|
-
|
|
12
10
|
//#region src/components/App.tsx
|
|
13
11
|
var import_react = /* @__PURE__ */ __toESM(require_react());
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
16
|
-
* This component mirrors the Fabric app container in React.
|
|
13
|
+
* App container containing the AppContext carrying `meta` and an `exit` hook.
|
|
17
14
|
*/
|
|
18
|
-
function App({
|
|
15
|
+
function App({ children, ...props }) {
|
|
16
|
+
const { meta = {} } = props;
|
|
19
17
|
const { exit } = useContext$1(RootContext);
|
|
18
|
+
const nodeTree = useNodeTree();
|
|
19
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
20
|
+
type: "App",
|
|
21
|
+
props
|
|
22
|
+
}));
|
|
20
23
|
provide(AppContext, {
|
|
21
24
|
exit,
|
|
22
25
|
meta
|
|
@@ -28,9 +31,15 @@ App.displayName = "KubbApp";
|
|
|
28
31
|
//#endregion
|
|
29
32
|
//#region src/components/Const.tsx
|
|
30
33
|
/**
|
|
31
|
-
*
|
|
34
|
+
* Generates a TypeScript constant declaration.
|
|
32
35
|
*/
|
|
33
|
-
function Const({
|
|
36
|
+
function Const({ children, ...props }) {
|
|
37
|
+
const { name, export: canExport, type, JSDoc, asConst } = props;
|
|
38
|
+
const nodeTree = useNodeTree();
|
|
39
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
40
|
+
type: "Const",
|
|
41
|
+
props
|
|
42
|
+
}));
|
|
34
43
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
35
44
|
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ jsxs(Fragment$1, { children: [createJSDoc({ comments: JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments }), /* @__PURE__ */ jsx("br", {})] }),
|
|
36
45
|
canExport && /* @__PURE__ */ jsx(Fragment$1, { children: "export " }),
|
|
@@ -52,26 +61,31 @@ Const.displayName = "KubbConst";
|
|
|
52
61
|
//#endregion
|
|
53
62
|
//#region src/components/File.tsx
|
|
54
63
|
/**
|
|
55
|
-
*
|
|
56
|
-
* for children. When `baseName` and `path` are provided the file will be
|
|
57
|
-
* registered so it can be emitted by the collector later.
|
|
64
|
+
* Adds files to the FileManager
|
|
58
65
|
*/
|
|
59
|
-
function File({ children, ...
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
function File({ children, ...props }) {
|
|
67
|
+
const { baseName, path, meta = {}, footer, banner } = props;
|
|
68
|
+
const fileManager = useFileManager();
|
|
69
|
+
const nodeTree = useNodeTree();
|
|
70
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
71
|
+
type: "File",
|
|
72
|
+
props
|
|
73
|
+
}));
|
|
74
|
+
if (!baseName || !path) return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
75
|
+
const file = {
|
|
76
|
+
baseName,
|
|
77
|
+
path,
|
|
78
|
+
meta,
|
|
79
|
+
banner,
|
|
80
|
+
footer,
|
|
69
81
|
sources: [],
|
|
70
82
|
imports: [],
|
|
71
83
|
exports: []
|
|
72
|
-
}
|
|
84
|
+
};
|
|
85
|
+
const [resolvedFile] = fileManager.add(file);
|
|
86
|
+
provide(FileContext, resolvedFile);
|
|
73
87
|
return /* @__PURE__ */ jsx("kubb-file", {
|
|
74
|
-
...
|
|
88
|
+
...props,
|
|
75
89
|
children
|
|
76
90
|
});
|
|
77
91
|
}
|
|
@@ -82,7 +96,13 @@ File.displayName = "KubbFile";
|
|
|
82
96
|
* Marks a block of source text to be associated with the current file when
|
|
83
97
|
* rendering with the FileCollector. Children are treated as the source string.
|
|
84
98
|
*/
|
|
85
|
-
function FileSource({
|
|
99
|
+
function FileSource({ children, ...props }) {
|
|
100
|
+
const { name, isExportable, isIndexable, isTypeOnly } = props;
|
|
101
|
+
const nodeTree = useNodeTree();
|
|
102
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
103
|
+
type: "FileSource",
|
|
104
|
+
props
|
|
105
|
+
}));
|
|
86
106
|
return /* @__PURE__ */ jsx("kubb-source", {
|
|
87
107
|
name,
|
|
88
108
|
isTypeOnly,
|
|
@@ -98,11 +118,24 @@ FileSource.displayName = "KubbFileSource";
|
|
|
98
118
|
* Declares an export entry for the current file. This will be collected by
|
|
99
119
|
* the FileCollector for later emission.
|
|
100
120
|
*/
|
|
101
|
-
function FileExport(
|
|
121
|
+
function FileExport(props) {
|
|
122
|
+
const { name, path, isTypeOnly, asAlias } = props;
|
|
123
|
+
const nodeTree = useNodeTree();
|
|
124
|
+
const file = useFile$1();
|
|
125
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
126
|
+
type: "FileExport",
|
|
127
|
+
props
|
|
128
|
+
}));
|
|
129
|
+
if (file) file.exports.push({
|
|
130
|
+
name,
|
|
131
|
+
path,
|
|
132
|
+
asAlias,
|
|
133
|
+
isTypeOnly
|
|
134
|
+
});
|
|
102
135
|
return /* @__PURE__ */ jsx("kubb-export", {
|
|
103
136
|
name,
|
|
104
137
|
path,
|
|
105
|
-
isTypeOnly
|
|
138
|
+
isTypeOnly,
|
|
106
139
|
asAlias
|
|
107
140
|
});
|
|
108
141
|
}
|
|
@@ -112,13 +145,27 @@ FileExport.displayName = "KubbFileExport";
|
|
|
112
145
|
*
|
|
113
146
|
* Declares an import entry for the current file.
|
|
114
147
|
*/
|
|
115
|
-
function FileImport(
|
|
148
|
+
function FileImport(props) {
|
|
149
|
+
const { name, root, path, isTypeOnly, isNameSpace } = props;
|
|
150
|
+
const nodeTree = useNodeTree();
|
|
151
|
+
const file = useFile$1();
|
|
152
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
153
|
+
type: "FileImport",
|
|
154
|
+
props
|
|
155
|
+
}));
|
|
156
|
+
if (file) file.imports.push({
|
|
157
|
+
name,
|
|
158
|
+
path,
|
|
159
|
+
root,
|
|
160
|
+
isNameSpace,
|
|
161
|
+
isTypeOnly
|
|
162
|
+
});
|
|
116
163
|
return /* @__PURE__ */ jsx("kubb-import", {
|
|
117
164
|
name,
|
|
118
165
|
root,
|
|
119
166
|
path,
|
|
120
167
|
isNameSpace,
|
|
121
|
-
isTypeOnly
|
|
168
|
+
isTypeOnly
|
|
122
169
|
});
|
|
123
170
|
}
|
|
124
171
|
FileImport.displayName = "KubbFileImport";
|
|
@@ -174,10 +221,15 @@ function Indent({ size = 2, children }) {
|
|
|
174
221
|
//#endregion
|
|
175
222
|
//#region src/components/Function.tsx
|
|
176
223
|
/**
|
|
177
|
-
*
|
|
178
|
-
* Supports optional export/default/async flags, generics, params and JSDoc.
|
|
224
|
+
* Generates a TypeScript function declaration.
|
|
179
225
|
*/
|
|
180
|
-
function Function({
|
|
226
|
+
function Function({ children, ...props }) {
|
|
227
|
+
const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc } = props;
|
|
228
|
+
const nodeTree = useNodeTree();
|
|
229
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
230
|
+
type: "Function",
|
|
231
|
+
props
|
|
232
|
+
}));
|
|
181
233
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
182
234
|
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ jsxs(Fragment$1, { children: [createJSDoc({ comments: JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments }), /* @__PURE__ */ jsx("br", {})] }),
|
|
183
235
|
canExport && /* @__PURE__ */ jsx(Fragment$1, { children: "export " }),
|
|
@@ -217,7 +269,13 @@ Function.displayName = "KubbFunction";
|
|
|
217
269
|
* Renders an arrow function definition. Supports the same flags as `Function`.
|
|
218
270
|
* Use `singleLine` to render the body as a single-line expression.
|
|
219
271
|
*/
|
|
220
|
-
function ArrowFunction({
|
|
272
|
+
function ArrowFunction({ children, ...props }) {
|
|
273
|
+
const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine } = props;
|
|
274
|
+
const nodeTree = useNodeTree();
|
|
275
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
276
|
+
type: "ArrowFunction",
|
|
277
|
+
props
|
|
278
|
+
}));
|
|
221
279
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
222
280
|
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ jsxs(Fragment$1, { children: [createJSDoc({ comments: JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments }), /* @__PURE__ */ jsx("br", {})] }),
|
|
223
281
|
canExport && /* @__PURE__ */ jsx(Fragment$1, { children: "export " }),
|
|
@@ -265,10 +323,15 @@ Function.Arrow = ArrowFunction;
|
|
|
265
323
|
//#endregion
|
|
266
324
|
//#region src/components/Type.tsx
|
|
267
325
|
/**
|
|
268
|
-
*
|
|
269
|
-
* with a capital letter and optionally emits JSDoc comments.
|
|
326
|
+
* Generates a TypeScript type declaration.
|
|
270
327
|
*/
|
|
271
|
-
function Type({
|
|
328
|
+
function Type({ children, ...props }) {
|
|
329
|
+
const { name, export: canExport, JSDoc } = props;
|
|
330
|
+
const nodeTree = useNodeTree();
|
|
331
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
332
|
+
type: "Type",
|
|
333
|
+
props
|
|
334
|
+
}));
|
|
272
335
|
if (name.charAt(0).toUpperCase() !== name.charAt(0)) throw new Error("Name should start with a capital letter(see TypeScript types)");
|
|
273
336
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
274
337
|
(JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments) && /* @__PURE__ */ jsxs(Fragment$1, { children: [createJSDoc({ comments: JSDoc === null || JSDoc === void 0 ? void 0 : JSDoc.comments }), /* @__PURE__ */ jsx("br", {})] }),
|
|
@@ -289,7 +352,7 @@ Type.displayName = "KubbType";
|
|
|
289
352
|
* next tick to allow React to complete its render cycle first.
|
|
290
353
|
*/
|
|
291
354
|
function useLifecycle() {
|
|
292
|
-
const { exit } = useContext$1(RootContext
|
|
355
|
+
const { exit } = useContext$1(RootContext);
|
|
293
356
|
return { exit: () => {
|
|
294
357
|
setTimeout(() => {
|
|
295
358
|
exit();
|
|
@@ -300,7 +363,7 @@ function useLifecycle() {
|
|
|
300
363
|
//#endregion
|
|
301
364
|
//#region src/createReactFabric.ts
|
|
302
365
|
function createReactFabric(config = {}) {
|
|
303
|
-
const fabric = createFabric({ mode: config.mode });
|
|
366
|
+
const fabric = createFabric$1({ mode: config.mode });
|
|
304
367
|
if (config.devtools) open();
|
|
305
368
|
fabric.use(reactPlugin, {
|
|
306
369
|
stdout: config.stdout,
|
|
@@ -438,5 +501,5 @@ const useReducer = import_react.useReducer;
|
|
|
438
501
|
const useRef = import_react.useRef;
|
|
439
502
|
|
|
440
503
|
//#endregion
|
|
441
|
-
export { App, Const, File, Fragment, Function, FunctionParams, Indent, Runtime, Type, createContext, createElement, createFunctionParams, createReactFabric, use, useApp, useContext, useEffect, useFile, useLifecycle, useReducer, useRef, useState };
|
|
504
|
+
export { App, Const, File, FileManager, FileProcessor, Fragment, Function, FunctionParams, Indent, Runtime, Type, createContext, createElement, createFabric, createFile, createFunctionParams, createReactFabric, use, useApp, useContext, useEffect, useFile, useLifecycle, useReducer, useRef, useState };
|
|
442
505
|
//# sourceMappingURL=index.js.map
|