@kubb/react-fabric 0.9.5 → 0.11.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.
- 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/{devtools-D6dZodXp.js → devtools-8_UKWDTl.js} +1 -1
- package/dist/{devtools-D6dZodXp.js.map → devtools-8_UKWDTl.js.map} +1 -1
- package/dist/{devtools-CRkwwngz.cjs → devtools-BOpUJhc_.cjs} +1 -1
- package/dist/{devtools-CRkwwngz.cjs.map → devtools-BOpUJhc_.cjs.map} +1 -1
- package/dist/devtools.cjs +1 -1
- package/dist/devtools.js +1 -1
- package/dist/globals.d.cts +2 -2
- package/dist/globals.d.ts +2 -2
- package/dist/index.cjs +166 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -359
- package/dist/index.d.ts +3 -359
- package/dist/index.js +151 -68
- 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-BAkGpU6g.d.ts → jsx-namespace-CBOEkCmJ.d.ts} +2 -2
- package/dist/{jsx-namespace-CCPa1Nut.d.cts → jsx-namespace-od7sqrmY.d.cts} +2 -2
- package/dist/{jsx-runtime-BEVcoJUm.cjs → jsx-runtime-Cq39dA50.cjs} +1 -1
- package/dist/{jsx-runtime-BEVcoJUm.cjs.map → jsx-runtime-Cq39dA50.cjs.map} +1 -1
- package/dist/{jsx-runtime-DDu0mFTI.js → jsx-runtime-Isgf9orn.js} +1 -1
- package/dist/{jsx-runtime-DDu0mFTI.js.map → jsx-runtime-Isgf9orn.js.map} +1 -1
- package/dist/jsx-runtime.cjs +1 -1
- package/dist/jsx-runtime.d.cts +5 -5
- package/dist/jsx-runtime.d.ts +3 -3
- package/dist/jsx-runtime.js +1 -1
- package/dist/parsers.d.cts +1 -1
- package/dist/parsers.d.ts +1 -1
- package/dist/plugins.cjs +2 -2
- package/dist/plugins.d.cts +2 -2
- package/dist/plugins.d.ts +2 -2
- package/dist/plugins.js +2 -2
- package/dist/{reactPlugin-CXaAO13f.cjs → reactPlugin-B8F6jVb5.cjs} +77 -64
- package/dist/reactPlugin-B8F6jVb5.cjs.map +1 -0
- package/dist/{reactPlugin-ixOr00MK.js → reactPlugin-CAtVV84d.js} +78 -53
- package/dist/reactPlugin-CAtVV84d.js.map +1 -0
- package/dist/types-C3ODUOKN.d.cts +675 -0
- package/dist/types-DwaohVJS.d.ts +675 -0
- package/dist/types.d.cts +3 -3
- package/dist/types.d.ts +3 -3
- package/package.json +3 -3
- package/src/Runtime.tsx +22 -12
- package/src/components/App.tsx +24 -15
- package/src/components/Const.tsx +19 -3
- package/src/components/File.tsx +107 -31
- package/src/components/Function.tsx +36 -5
- package/src/components/Indent.tsx +3 -0
- package/src/components/Root.tsx +26 -20
- package/src/components/Type.tsx +19 -2
- 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/useApp.ts +1 -15
- package/src/composables/useFile.ts +1 -12
- package/src/composables/useLifecycle.tsx +7 -8
- package/src/index.ts +5 -1
- package/src/plugins/reactPlugin.ts +7 -6
- package/src/types.ts +0 -4
- package/src/utils/createJSDoc.ts +1 -8
- package/dist/reactPlugin-4-kcMKwZ.d.ts +0 -31
- package/dist/reactPlugin-B4xarQJX.d.cts +0 -31
- package/dist/reactPlugin-CXaAO13f.cjs.map +0 -1
- package/dist/reactPlugin-ixOr00MK.js.map +0 -1
- package/dist/types-CSUzVTpn.d.ts +0 -104
- package/dist/types-DP2mgqeb.d.cts +0 -104
package/dist/index.d.ts
CHANGED
|
@@ -1,359 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import * as react3 from "react";
|
|
5
|
-
import React, { ReactNode } from "react";
|
|
6
|
-
|
|
7
|
-
//#region ../fabric-core/src/createFabric.d.ts
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Creates a new Fabric instance
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* const fabric = createFabric()
|
|
14
|
-
* fabric.use(myPlugin())
|
|
15
|
-
*/
|
|
16
|
-
declare function createFabric<T extends FabricOptions>(config?: FabricConfig<T>): Fabric<T>;
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region ../fabric-core/src/createFile.d.ts
|
|
19
|
-
/**
|
|
20
|
-
* Helper to create a file with name and id set
|
|
21
|
-
*/
|
|
22
|
-
declare function createFile<TMeta extends object = object>(file: File$1<TMeta>): ResolvedFile<TMeta>;
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/components/App.d.ts
|
|
25
|
-
type AppContextProps<TMeta = unknown> = {
|
|
26
|
-
/**
|
|
27
|
-
* Exit (unmount)
|
|
28
|
-
*/
|
|
29
|
-
readonly exit: (error?: Error) => void;
|
|
30
|
-
readonly meta: TMeta;
|
|
31
|
-
};
|
|
32
|
-
type Props$4<TMeta = unknown> = {
|
|
33
|
-
readonly children?: KubbNode;
|
|
34
|
-
readonly meta: TMeta;
|
|
35
|
-
};
|
|
36
|
-
declare function App<TMeta = unknown>({
|
|
37
|
-
meta,
|
|
38
|
-
children
|
|
39
|
-
}: Props$4<TMeta>): react3.JSX.Element;
|
|
40
|
-
declare namespace App {
|
|
41
|
-
var Context: react3.Context<AppContextProps<unknown> | undefined>;
|
|
42
|
-
var displayName: string;
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/components/Const.d.ts
|
|
46
|
-
type Props$3 = {
|
|
47
|
-
key?: Key;
|
|
48
|
-
/**
|
|
49
|
-
* Name of the const
|
|
50
|
-
*/
|
|
51
|
-
name: string;
|
|
52
|
-
/**
|
|
53
|
-
* Does this type need to be exported.
|
|
54
|
-
*/
|
|
55
|
-
export?: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Type to make the const being typed
|
|
58
|
-
*/
|
|
59
|
-
type?: string;
|
|
60
|
-
/**
|
|
61
|
-
* Options for JSdocs.
|
|
62
|
-
*/
|
|
63
|
-
JSDoc?: JSDoc;
|
|
64
|
-
/**
|
|
65
|
-
* Use of `const` assertions
|
|
66
|
-
*/
|
|
67
|
-
asConst?: boolean;
|
|
68
|
-
children?: KubbNode;
|
|
69
|
-
};
|
|
70
|
-
declare function Const({
|
|
71
|
-
name,
|
|
72
|
-
export: canExport,
|
|
73
|
-
type,
|
|
74
|
-
JSDoc,
|
|
75
|
-
asConst,
|
|
76
|
-
children
|
|
77
|
-
}: Props$3): react3.JSX.Element;
|
|
78
|
-
declare namespace Const {
|
|
79
|
-
var displayName: string;
|
|
80
|
-
}
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region src/components/File.d.ts
|
|
83
|
-
type FileContextProps<TMeta extends object = object> = {
|
|
84
|
-
/**
|
|
85
|
-
* Name to be used to dynamicly create the baseName(based on input.path).
|
|
86
|
-
* Based on UNIX basename
|
|
87
|
-
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
88
|
-
*/
|
|
89
|
-
baseName: BaseName;
|
|
90
|
-
/**
|
|
91
|
-
* Path will be full qualified path to a specified file.
|
|
92
|
-
*/
|
|
93
|
-
path: Path;
|
|
94
|
-
meta?: TMeta;
|
|
95
|
-
};
|
|
96
|
-
type BasePropsWithBaseName = {
|
|
97
|
-
/**
|
|
98
|
-
* Name to be used to dynamicly create the baseName(based on input.path).
|
|
99
|
-
* Based on UNIX basename
|
|
100
|
-
* @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
|
|
101
|
-
*/
|
|
102
|
-
baseName: BaseName;
|
|
103
|
-
/**
|
|
104
|
-
* Path will be full qualified path to a specified file.
|
|
105
|
-
*/
|
|
106
|
-
path: Path;
|
|
107
|
-
};
|
|
108
|
-
type BasePropsWithoutBaseName = {
|
|
109
|
-
baseName?: never;
|
|
110
|
-
/**
|
|
111
|
-
* Path will be full qualified path to a specified file.
|
|
112
|
-
*/
|
|
113
|
-
path?: Path;
|
|
114
|
-
};
|
|
115
|
-
type BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName;
|
|
116
|
-
type Props$2<TMeta> = BaseProps & {
|
|
117
|
-
key?: Key;
|
|
118
|
-
meta?: TMeta;
|
|
119
|
-
banner?: string;
|
|
120
|
-
footer?: string;
|
|
121
|
-
children?: KubbNode;
|
|
122
|
-
};
|
|
123
|
-
declare function File<TMeta extends object = object>({
|
|
124
|
-
children,
|
|
125
|
-
...rest
|
|
126
|
-
}: Props$2<TMeta>): react3.JSX.Element;
|
|
127
|
-
declare namespace File {
|
|
128
|
-
var displayName: string;
|
|
129
|
-
var Export: typeof FileExport;
|
|
130
|
-
var Import: typeof FileImport;
|
|
131
|
-
var Source: typeof FileSource;
|
|
132
|
-
var Context: react3.Context<FileContextProps<object>>;
|
|
133
|
-
}
|
|
134
|
-
type FileSourceProps = Omit<Source, 'value'> & {
|
|
135
|
-
key?: Key;
|
|
136
|
-
children?: KubbNode;
|
|
137
|
-
};
|
|
138
|
-
declare function FileSource({
|
|
139
|
-
isTypeOnly,
|
|
140
|
-
name,
|
|
141
|
-
isExportable,
|
|
142
|
-
isIndexable,
|
|
143
|
-
children
|
|
144
|
-
}: FileSourceProps): react3.JSX.Element;
|
|
145
|
-
declare namespace FileSource {
|
|
146
|
-
var displayName: string;
|
|
147
|
-
}
|
|
148
|
-
type FileExportProps = Export & {
|
|
149
|
-
key?: Key;
|
|
150
|
-
};
|
|
151
|
-
declare function FileExport({
|
|
152
|
-
name,
|
|
153
|
-
path,
|
|
154
|
-
isTypeOnly,
|
|
155
|
-
asAlias
|
|
156
|
-
}: FileExportProps): react3.JSX.Element;
|
|
157
|
-
declare namespace FileExport {
|
|
158
|
-
var displayName: string;
|
|
159
|
-
}
|
|
160
|
-
type FileImportProps = Import & {
|
|
161
|
-
key?: Key;
|
|
162
|
-
};
|
|
163
|
-
declare function FileImport({
|
|
164
|
-
name,
|
|
165
|
-
root,
|
|
166
|
-
path,
|
|
167
|
-
isTypeOnly,
|
|
168
|
-
isNameSpace
|
|
169
|
-
}: FileImportProps): react3.JSX.Element;
|
|
170
|
-
declare namespace FileImport {
|
|
171
|
-
var displayName: string;
|
|
172
|
-
}
|
|
173
|
-
//#endregion
|
|
174
|
-
//#region src/components/Function.d.ts
|
|
175
|
-
type Props$1 = {
|
|
176
|
-
key?: Key;
|
|
177
|
-
/**
|
|
178
|
-
* Name of the function.
|
|
179
|
-
*/
|
|
180
|
-
name: string;
|
|
181
|
-
/**
|
|
182
|
-
* Add default when export is being used
|
|
183
|
-
*/
|
|
184
|
-
default?: boolean;
|
|
185
|
-
/**
|
|
186
|
-
* Parameters/options/props that need to be used.
|
|
187
|
-
*/
|
|
188
|
-
params?: string;
|
|
189
|
-
/**
|
|
190
|
-
* Does this function need to be exported.
|
|
191
|
-
*/
|
|
192
|
-
export?: boolean;
|
|
193
|
-
/**
|
|
194
|
-
* Does the function has async/promise behaviour.
|
|
195
|
-
* This will also add `Promise<returnType>` as the returnType.
|
|
196
|
-
*/
|
|
197
|
-
async?: boolean;
|
|
198
|
-
/**
|
|
199
|
-
* Generics that needs to be added for TypeScript.
|
|
200
|
-
*/
|
|
201
|
-
generics?: string | string[];
|
|
202
|
-
/**
|
|
203
|
-
* ReturnType(see async for adding Promise type).
|
|
204
|
-
*/
|
|
205
|
-
returnType?: string;
|
|
206
|
-
/**
|
|
207
|
-
* Options for JSdocs.
|
|
208
|
-
*/
|
|
209
|
-
JSDoc?: JSDoc;
|
|
210
|
-
children?: KubbNode;
|
|
211
|
-
};
|
|
212
|
-
declare function Function({
|
|
213
|
-
name,
|
|
214
|
-
default: isDefault,
|
|
215
|
-
export: canExport,
|
|
216
|
-
async,
|
|
217
|
-
generics,
|
|
218
|
-
params,
|
|
219
|
-
returnType,
|
|
220
|
-
JSDoc,
|
|
221
|
-
children
|
|
222
|
-
}: Props$1): react3.JSX.Element;
|
|
223
|
-
declare namespace Function {
|
|
224
|
-
var displayName: string;
|
|
225
|
-
var Arrow: typeof ArrowFunction;
|
|
226
|
-
}
|
|
227
|
-
type ArrowFunctionProps = Props$1 & {
|
|
228
|
-
/**
|
|
229
|
-
* Create Arrow function in one line
|
|
230
|
-
*/
|
|
231
|
-
singleLine?: boolean;
|
|
232
|
-
};
|
|
233
|
-
declare function ArrowFunction({
|
|
234
|
-
name,
|
|
235
|
-
default: isDefault,
|
|
236
|
-
export: canExport,
|
|
237
|
-
async,
|
|
238
|
-
generics,
|
|
239
|
-
params,
|
|
240
|
-
returnType,
|
|
241
|
-
JSDoc,
|
|
242
|
-
singleLine,
|
|
243
|
-
children
|
|
244
|
-
}: ArrowFunctionProps): react3.JSX.Element;
|
|
245
|
-
declare namespace ArrowFunction {
|
|
246
|
-
var displayName: string;
|
|
247
|
-
}
|
|
248
|
-
//#endregion
|
|
249
|
-
//#region src/components/Indent.d.ts
|
|
250
|
-
type IndentProps = {
|
|
251
|
-
size?: number;
|
|
252
|
-
children?: React.ReactNode;
|
|
253
|
-
};
|
|
254
|
-
/**
|
|
255
|
-
* Indents all children by `size` spaces.
|
|
256
|
-
* Collapses consecutive <br /> tags to at most 2.
|
|
257
|
-
*/
|
|
258
|
-
declare function Indent({
|
|
259
|
-
size,
|
|
260
|
-
children
|
|
261
|
-
}: IndentProps): React.JSX.Element | null;
|
|
262
|
-
//#endregion
|
|
263
|
-
//#region src/components/Type.d.ts
|
|
264
|
-
type Props = {
|
|
265
|
-
key?: Key;
|
|
266
|
-
/**
|
|
267
|
-
* Name of the type, this needs to start with a capital letter.
|
|
268
|
-
*/
|
|
269
|
-
name: string;
|
|
270
|
-
/**
|
|
271
|
-
* Does this type need to be exported.
|
|
272
|
-
*/
|
|
273
|
-
export?: boolean;
|
|
274
|
-
/**
|
|
275
|
-
* Options for JSdocs.
|
|
276
|
-
*/
|
|
277
|
-
JSDoc?: JSDoc;
|
|
278
|
-
children?: KubbNode;
|
|
279
|
-
};
|
|
280
|
-
declare function Type({
|
|
281
|
-
name,
|
|
282
|
-
export: canExport,
|
|
283
|
-
JSDoc,
|
|
284
|
-
children
|
|
285
|
-
}: Props): react3.JSX.Element;
|
|
286
|
-
declare namespace Type {
|
|
287
|
-
var displayName: string;
|
|
288
|
-
}
|
|
289
|
-
//#endregion
|
|
290
|
-
//#region src/composables/useApp.d.ts
|
|
291
|
-
/**
|
|
292
|
-
* `useApp` will return the current App with plugin, pluginManager, fileManager and mode.
|
|
293
|
-
*/
|
|
294
|
-
declare function useApp<TMeta = unknown>(): AppContextProps<TMeta>;
|
|
295
|
-
//#endregion
|
|
296
|
-
//#region src/composables/useFile.d.ts
|
|
297
|
-
/**
|
|
298
|
-
* `useFile` will return the current file when <File/> is used.
|
|
299
|
-
*/
|
|
300
|
-
declare function useFile(): FileContextProps;
|
|
301
|
-
//#endregion
|
|
302
|
-
//#region src/composables/useLifecycle.d.ts
|
|
303
|
-
/**
|
|
304
|
-
* `useLifecycle` will return some helpers to exit/restart the generation.
|
|
305
|
-
*/
|
|
306
|
-
declare function useLifecycle(): {
|
|
307
|
-
exit: () => void;
|
|
308
|
-
};
|
|
309
|
-
//#endregion
|
|
310
|
-
//#region src/createReactFabric.d.ts
|
|
311
|
-
declare function createReactFabric(config?: FabricConfig<Options$1 & {
|
|
312
|
-
mode?: FabricMode;
|
|
313
|
-
devtools?: boolean;
|
|
314
|
-
}>): Fabric<Options$1 & {
|
|
315
|
-
mode?: FabricMode;
|
|
316
|
-
devtools?: boolean;
|
|
317
|
-
}>;
|
|
318
|
-
//#endregion
|
|
319
|
-
//#region src/Runtime.d.ts
|
|
320
|
-
type Options = {
|
|
321
|
-
fileManager: FileManager;
|
|
322
|
-
stdout?: NodeJS.WriteStream;
|
|
323
|
-
stdin?: NodeJS.ReadStream;
|
|
324
|
-
stderr?: NodeJS.WriteStream;
|
|
325
|
-
/**
|
|
326
|
-
* Set this to true to always see the result of the render in the console(line per render)
|
|
327
|
-
*/
|
|
328
|
-
debug?: boolean;
|
|
329
|
-
};
|
|
330
|
-
declare class Runtime {
|
|
331
|
-
#private;
|
|
332
|
-
exitPromise?: Promise<void>;
|
|
333
|
-
constructor(options: Options);
|
|
334
|
-
get fileManager(): FileManager;
|
|
335
|
-
resolveExitPromise: () => void;
|
|
336
|
-
rejectExitPromise: (reason?: Error) => void;
|
|
337
|
-
unsubscribeExit: () => void;
|
|
338
|
-
onRender: () => Promise<void>;
|
|
339
|
-
onError(error: Error): void;
|
|
340
|
-
onExit(error?: Error): void;
|
|
341
|
-
render(node: ReactNode): Promise<void>;
|
|
342
|
-
renderToString(node: ReactNode): Promise<string>;
|
|
343
|
-
unmount(error?: Error | number | null): void;
|
|
344
|
-
waitUntilExit(): Promise<void>;
|
|
345
|
-
}
|
|
346
|
-
//#endregion
|
|
347
|
-
//#region src/index.d.ts
|
|
348
|
-
declare const useState: typeof react3.useState;
|
|
349
|
-
declare const createContext: typeof react3.createContext;
|
|
350
|
-
declare const createElement: typeof react3.createElement;
|
|
351
|
-
declare const Fragment: react3.ExoticComponent<react3.FragmentProps>;
|
|
352
|
-
declare const use: typeof react3.use;
|
|
353
|
-
declare const useContext: typeof react3.useContext;
|
|
354
|
-
declare const useEffect: typeof react3.useEffect;
|
|
355
|
-
declare const useReducer: typeof react3.useReducer;
|
|
356
|
-
declare const useRef: typeof react3.useRef;
|
|
357
|
-
//#endregion
|
|
358
|
-
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 };
|
|
359
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
import { c as FileManager, l as FileProcessor, t as Fabric } from "./Fabric-DbJhvsCq.js";
|
|
2
|
+
import { $ as useApp, A as createFunctionParams, B as App, C as useEffect, D as FunctionParams, E as useState, F as Type, G as NodeTreeContext, H as createJSDoc, I as Indent, J as useFile, K as FileContext, L as Function, M as createReactFabric, P as useLifecycle, Q as unprovide, R as File, S as useContext, T as useRef, U as createFile, V as getRelativePath, W as createFabric, X as inject, Y as Context, Z as provide, at as TreeNode, b as createElement, et as AppContext, g as RootContext, it as useNodeTree, j as Runtime, nt as Root, q as useFileManager, tt as Text, v as Fragment, w as useReducer, x as use, y as createContext, z as Const } from "./types-DwaohVJS.js";
|
|
3
|
+
export { App, AppContext, Const, Context, Fabric, File, FileContext, FileManager, FileProcessor, Fragment, Function, FunctionParams, Indent, NodeTreeContext, Root, RootContext, Runtime, Text, TreeNode, Type, createContext, createElement, createFabric, createFile, createFunctionParams, createJSDoc, createReactFabric, getRelativePath, inject, provide, unprovide, use, useApp, useContext, useEffect, useFile, useFileManager, useLifecycle, useNodeTree, useReducer, useRef, useState };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { r as __toESM } from "./chunk-BCPZiDLE.js";
|
|
2
2
|
import { t as require_react } from "./react-DfIUVisP.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
6
|
-
import { createFabric } from "@kubb/fabric-core";
|
|
3
|
+
import { i as jsxs, n as jsx, t as Fragment$1 } from "./jsx-runtime-Isgf9orn.js";
|
|
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-CAtVV84d.js";
|
|
6
|
+
import { AppContext, FileContext, NodeTreeContext, RootContext, createFabric, 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
|
|
|
@@ -11,31 +11,37 @@ export * from "@kubb/fabric-core"
|
|
|
11
11
|
|
|
12
12
|
//#region src/components/App.tsx
|
|
13
13
|
var import_react = /* @__PURE__ */ __toESM(require_react());
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
/**
|
|
15
|
+
* App container containing the AppContext carrying `meta` and an `exit` hook.
|
|
16
|
+
*/
|
|
17
|
+
function App({ children, ...props }) {
|
|
18
|
+
const { meta = {} } = props;
|
|
19
|
+
const { exit } = useContext$1(RootContext);
|
|
20
|
+
const nodeTree = useNodeTree();
|
|
21
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
22
|
+
type: "App",
|
|
23
|
+
props
|
|
24
|
+
}));
|
|
25
|
+
provide(AppContext, {
|
|
26
|
+
exit,
|
|
27
|
+
meta
|
|
23
28
|
});
|
|
29
|
+
return children;
|
|
24
30
|
}
|
|
25
|
-
App.Context = AppContext;
|
|
26
31
|
App.displayName = "KubbApp";
|
|
27
32
|
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/utils/createJSDoc.ts
|
|
30
|
-
function createJSDoc({ comments }) {
|
|
31
|
-
const filtered = comments.filter((c) => c.trim());
|
|
32
|
-
if (!filtered.length) return "";
|
|
33
|
-
return `/**\n * ${filtered.join("\n * ")}\n */`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
33
|
//#endregion
|
|
37
34
|
//#region src/components/Const.tsx
|
|
38
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Generates a TypeScript constant declaration.
|
|
37
|
+
*/
|
|
38
|
+
function Const({ children, ...props }) {
|
|
39
|
+
const { name, export: canExport, type, JSDoc, asConst } = props;
|
|
40
|
+
const nodeTree = useNodeTree();
|
|
41
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
42
|
+
type: "Const",
|
|
43
|
+
props
|
|
44
|
+
}));
|
|
39
45
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
40
46
|
(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", {})] }),
|
|
41
47
|
canExport && /* @__PURE__ */ jsx(Fragment$1, { children: "export " }),
|
|
@@ -56,23 +62,49 @@ Const.displayName = "KubbConst";
|
|
|
56
62
|
|
|
57
63
|
//#endregion
|
|
58
64
|
//#region src/components/File.tsx
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Adds files to the FileManager
|
|
67
|
+
*/
|
|
68
|
+
function File({ children, ...props }) {
|
|
69
|
+
const { baseName, path, meta = {}, footer, banner } = props;
|
|
70
|
+
const fileManager = useFileManager();
|
|
71
|
+
const nodeTree = useNodeTree();
|
|
72
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
73
|
+
type: "File",
|
|
74
|
+
props
|
|
75
|
+
}));
|
|
76
|
+
if (!baseName || !path) return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
77
|
+
const file = {
|
|
78
|
+
baseName,
|
|
79
|
+
path,
|
|
80
|
+
meta,
|
|
81
|
+
banner,
|
|
82
|
+
footer,
|
|
83
|
+
sources: [],
|
|
84
|
+
imports: [],
|
|
85
|
+
exports: []
|
|
86
|
+
};
|
|
87
|
+
const [resolvedFile] = fileManager.add(file);
|
|
88
|
+
provide(FileContext, resolvedFile);
|
|
62
89
|
return /* @__PURE__ */ jsx("kubb-file", {
|
|
63
|
-
...
|
|
64
|
-
children
|
|
65
|
-
value: {
|
|
66
|
-
baseName: rest.baseName,
|
|
67
|
-
path: rest.path,
|
|
68
|
-
meta: rest.meta
|
|
69
|
-
},
|
|
70
|
-
children
|
|
71
|
-
})
|
|
90
|
+
...props,
|
|
91
|
+
children
|
|
72
92
|
});
|
|
73
93
|
}
|
|
74
94
|
File.displayName = "KubbFile";
|
|
75
|
-
|
|
95
|
+
/**
|
|
96
|
+
* File.Source
|
|
97
|
+
*
|
|
98
|
+
* Marks a block of source text to be associated with the current file when
|
|
99
|
+
* rendering with the FileCollector. Children are treated as the source string.
|
|
100
|
+
*/
|
|
101
|
+
function FileSource({ children, ...props }) {
|
|
102
|
+
const { name, isExportable, isIndexable, isTypeOnly } = props;
|
|
103
|
+
const nodeTree = useNodeTree();
|
|
104
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
105
|
+
type: "FileSource",
|
|
106
|
+
props
|
|
107
|
+
}));
|
|
76
108
|
return /* @__PURE__ */ jsx("kubb-source", {
|
|
77
109
|
name,
|
|
78
110
|
isTypeOnly,
|
|
@@ -82,29 +114,66 @@ function FileSource({ isTypeOnly, name, isExportable, isIndexable, children }) {
|
|
|
82
114
|
});
|
|
83
115
|
}
|
|
84
116
|
FileSource.displayName = "KubbFileSource";
|
|
85
|
-
|
|
117
|
+
/**
|
|
118
|
+
* File.Export
|
|
119
|
+
*
|
|
120
|
+
* Declares an export entry for the current file. This will be collected by
|
|
121
|
+
* the FileCollector for later emission.
|
|
122
|
+
*/
|
|
123
|
+
function FileExport(props) {
|
|
124
|
+
const { name, path, isTypeOnly, asAlias } = props;
|
|
125
|
+
const nodeTree = useNodeTree();
|
|
126
|
+
const file = useFile$1();
|
|
127
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
128
|
+
type: "FileExport",
|
|
129
|
+
props
|
|
130
|
+
}));
|
|
131
|
+
if (file) file.exports.push({
|
|
132
|
+
name,
|
|
133
|
+
path,
|
|
134
|
+
asAlias,
|
|
135
|
+
isTypeOnly
|
|
136
|
+
});
|
|
86
137
|
return /* @__PURE__ */ jsx("kubb-export", {
|
|
87
138
|
name,
|
|
88
139
|
path,
|
|
89
|
-
isTypeOnly
|
|
140
|
+
isTypeOnly,
|
|
90
141
|
asAlias
|
|
91
142
|
});
|
|
92
143
|
}
|
|
93
144
|
FileExport.displayName = "KubbFileExport";
|
|
94
|
-
|
|
145
|
+
/**
|
|
146
|
+
* File.Import
|
|
147
|
+
*
|
|
148
|
+
* Declares an import entry for the current file.
|
|
149
|
+
*/
|
|
150
|
+
function FileImport(props) {
|
|
151
|
+
const { name, root, path, isTypeOnly, isNameSpace } = props;
|
|
152
|
+
const nodeTree = useNodeTree();
|
|
153
|
+
const file = useFile$1();
|
|
154
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
155
|
+
type: "FileImport",
|
|
156
|
+
props
|
|
157
|
+
}));
|
|
158
|
+
if (file) file.imports.push({
|
|
159
|
+
name,
|
|
160
|
+
path,
|
|
161
|
+
root,
|
|
162
|
+
isNameSpace,
|
|
163
|
+
isTypeOnly
|
|
164
|
+
});
|
|
95
165
|
return /* @__PURE__ */ jsx("kubb-import", {
|
|
96
166
|
name,
|
|
97
167
|
root,
|
|
98
168
|
path,
|
|
99
169
|
isNameSpace,
|
|
100
|
-
isTypeOnly
|
|
170
|
+
isTypeOnly
|
|
101
171
|
});
|
|
102
172
|
}
|
|
103
173
|
FileImport.displayName = "KubbFileImport";
|
|
104
174
|
File.Export = FileExport;
|
|
105
175
|
File.Import = FileImport;
|
|
106
176
|
File.Source = FileSource;
|
|
107
|
-
File.Context = FileContext;
|
|
108
177
|
|
|
109
178
|
//#endregion
|
|
110
179
|
//#region ../../node_modules/.pnpm/indent-string@5.0.0/node_modules/indent-string/index.js
|
|
@@ -124,6 +193,9 @@ function indentString(string, count = 1, options = {}) {
|
|
|
124
193
|
/**
|
|
125
194
|
* Indents all children by `size` spaces.
|
|
126
195
|
* Collapses consecutive <br /> tags to at most 2.
|
|
196
|
+
*
|
|
197
|
+
* Indent will dedent and re-indent string children and will prefix
|
|
198
|
+
* non-string children with the requested number of spaces.
|
|
127
199
|
*/
|
|
128
200
|
function Indent({ size = 2, children }) {
|
|
129
201
|
if (!children) return null;
|
|
@@ -150,7 +222,16 @@ function Indent({ size = 2, children }) {
|
|
|
150
222
|
|
|
151
223
|
//#endregion
|
|
152
224
|
//#region src/components/Function.tsx
|
|
153
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Generates a TypeScript function declaration.
|
|
227
|
+
*/
|
|
228
|
+
function Function({ children, ...props }) {
|
|
229
|
+
const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc } = props;
|
|
230
|
+
const nodeTree = useNodeTree();
|
|
231
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
232
|
+
type: "Function",
|
|
233
|
+
props
|
|
234
|
+
}));
|
|
154
235
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
155
236
|
(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", {})] }),
|
|
156
237
|
canExport && /* @__PURE__ */ jsx(Fragment$1, { children: "export " }),
|
|
@@ -184,7 +265,19 @@ function Function({ name, default: isDefault, export: canExport, async, generics
|
|
|
184
265
|
] });
|
|
185
266
|
}
|
|
186
267
|
Function.displayName = "KubbFunction";
|
|
187
|
-
|
|
268
|
+
/**
|
|
269
|
+
* ArrowFunction
|
|
270
|
+
*
|
|
271
|
+
* Renders an arrow function definition. Supports the same flags as `Function`.
|
|
272
|
+
* Use `singleLine` to render the body as a single-line expression.
|
|
273
|
+
*/
|
|
274
|
+
function ArrowFunction({ children, ...props }) {
|
|
275
|
+
const { name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine } = props;
|
|
276
|
+
const nodeTree = useNodeTree();
|
|
277
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
278
|
+
type: "ArrowFunction",
|
|
279
|
+
props
|
|
280
|
+
}));
|
|
188
281
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
189
282
|
(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", {})] }),
|
|
190
283
|
canExport && /* @__PURE__ */ jsx(Fragment$1, { children: "export " }),
|
|
@@ -231,7 +324,16 @@ Function.Arrow = ArrowFunction;
|
|
|
231
324
|
|
|
232
325
|
//#endregion
|
|
233
326
|
//#region src/components/Type.tsx
|
|
234
|
-
|
|
327
|
+
/**
|
|
328
|
+
* Generates a TypeScript type declaration.
|
|
329
|
+
*/
|
|
330
|
+
function Type({ children, ...props }) {
|
|
331
|
+
const { name, export: canExport, JSDoc } = props;
|
|
332
|
+
const nodeTree = useNodeTree();
|
|
333
|
+
if (nodeTree) provide(NodeTreeContext, nodeTree.addChild({
|
|
334
|
+
type: "Type",
|
|
335
|
+
props
|
|
336
|
+
}));
|
|
235
337
|
if (name.charAt(0).toUpperCase() !== name.charAt(0)) throw new Error("Name should start with a capital letter(see TypeScript types)");
|
|
236
338
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
237
339
|
(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", {})] }),
|
|
@@ -244,36 +346,17 @@ function Type({ name, export: canExport, JSDoc, children }) {
|
|
|
244
346
|
}
|
|
245
347
|
Type.displayName = "KubbType";
|
|
246
348
|
|
|
247
|
-
//#endregion
|
|
248
|
-
//#region src/composables/useApp.ts
|
|
249
|
-
/**
|
|
250
|
-
* `useApp` will return the current App with plugin, pluginManager, fileManager and mode.
|
|
251
|
-
*/
|
|
252
|
-
function useApp() {
|
|
253
|
-
const app = (0, import_react.useContext)(App.Context);
|
|
254
|
-
if (!app) throw new Error("<App /> should be set");
|
|
255
|
-
return app;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
//#endregion
|
|
259
|
-
//#region src/composables/useFile.ts
|
|
260
|
-
/**
|
|
261
|
-
* `useFile` will return the current file when <File/> is used.
|
|
262
|
-
*/
|
|
263
|
-
function useFile() {
|
|
264
|
-
return (0, import_react.useContext)(File.Context);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
349
|
//#endregion
|
|
268
350
|
//#region src/composables/useLifecycle.tsx
|
|
269
351
|
/**
|
|
270
|
-
*
|
|
352
|
+
* Provides lifecycle helpers that integrate with the Fabric runtime. The
|
|
353
|
+
* `exit` helper schedules a call to the RootContext exit function on the
|
|
354
|
+
* next tick to allow React to complete its render cycle first.
|
|
271
355
|
*/
|
|
272
356
|
function useLifecycle() {
|
|
273
|
-
const { exit } =
|
|
357
|
+
const { exit } = useContext$1(RootContext);
|
|
274
358
|
return { exit: () => {
|
|
275
|
-
|
|
276
|
-
clearTimeout(timeout);
|
|
359
|
+
setTimeout(() => {
|
|
277
360
|
exit();
|
|
278
361
|
}, 0);
|
|
279
362
|
} };
|