@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.
- 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 +1 -1
- package/dist/globals.d.ts +1 -1
- package/dist/index.cjs +93 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +209 -57
- package/dist/index.d.ts +209 -57
- package/dist/index.js +78 -61
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.d.cts +4 -4
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/{jsx-namespace-CCPa1Nut.d.cts → jsx-namespace-BnoysbjP.d.cts} +2 -2
- package/dist/{jsx-namespace-BAkGpU6g.d.ts → jsx-namespace-D0a66_uR.d.ts} +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 +4 -4
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.js +1 -1
- package/dist/plugins.cjs +2 -2
- package/dist/plugins.js +2 -2
- package/dist/{reactPlugin-CXaAO13f.cjs → reactPlugin-D4SmGYbm.cjs} +52 -59
- package/dist/reactPlugin-D4SmGYbm.cjs.map +1 -0
- package/dist/{reactPlugin-ixOr00MK.js → reactPlugin-DT9toQPK.js} +53 -48
- package/dist/reactPlugin-DT9toQPK.js.map +1 -0
- package/dist/{types-CSUzVTpn.d.ts → types-BL7PkfqA.d.ts} +7 -5
- package/dist/{types-DP2mgqeb.d.cts → types-BdOHT5YF.d.cts} +7 -5
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/App.tsx +7 -14
- package/src/components/Const.tsx +3 -0
- package/src/components/File.tsx +39 -22
- package/src/components/Function.tsx +10 -0
- package/src/components/Indent.tsx +3 -0
- package/src/components/Root.tsx +13 -14
- package/src/components/Type.tsx +4 -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/types.ts +0 -4
- package/src/utils/createJSDoc.ts +1 -8
- package/src/utils/getFunctionParams.ts +12 -8
- package/dist/reactPlugin-CXaAO13f.cjs.map +0 -1
- package/dist/reactPlugin-ixOr00MK.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,139 @@
|
|
|
1
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-DitK3IEP.js";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as Key, h as FunctionParams, u as KubbNode, v as createFunctionParams, y as JSDoc } from "./types-BL7PkfqA.js";
|
|
3
3
|
import { t as Options$1 } from "./reactPlugin-4-kcMKwZ.js";
|
|
4
|
-
import * as
|
|
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
|
+
//#region ../fabric-core/src/contexts/AppContext.d.ts
|
|
33
|
+
type AppContextProps<TMeta = unknown> = {
|
|
34
|
+
/**
|
|
35
|
+
* Exit (unmount)
|
|
36
|
+
*/
|
|
37
|
+
readonly exit: (error?: Error) => void;
|
|
38
|
+
readonly meta: TMeta;
|
|
39
|
+
};
|
|
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
|
+
//#endregion
|
|
46
|
+
//#region ../fabric-core/src/composables/useApp.d.ts
|
|
47
|
+
/**
|
|
48
|
+
* `useApp` will return the current App with meta and exit function.
|
|
49
|
+
*
|
|
50
|
+
* Throws an error when there is no AppContext available.
|
|
51
|
+
*/
|
|
52
|
+
declare function useApp<TMeta = unknown>(): AppContextProps<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
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region ../fabric-core/src/composables/useFile.d.ts
|
|
109
|
+
/**
|
|
110
|
+
* `useFile` will return the current FileCollector for registering files.
|
|
111
|
+
*
|
|
112
|
+
* Throws when no FileCollector is present in context — ensure a Fabric that
|
|
113
|
+
* provides a FileCollector is mounted before calling this hook.
|
|
114
|
+
*/
|
|
115
|
+
declare function useFile(): FileCollector;
|
|
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>;
|
|
135
|
+
//#endregion
|
|
7
136
|
//#region ../fabric-core/src/createFabric.d.ts
|
|
8
|
-
|
|
9
137
|
/**
|
|
10
138
|
* Creates a new Fabric instance
|
|
11
139
|
*
|
|
@@ -21,24 +149,30 @@ declare function createFabric<T extends FabricOptions>(config?: FabricConfig<T>)
|
|
|
21
149
|
*/
|
|
22
150
|
declare function createFile<TMeta extends object = object>(file: File$1<TMeta>): ResolvedFile<TMeta>;
|
|
23
151
|
//#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
|
|
24
162
|
//#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
163
|
type Props$4<TMeta = unknown> = {
|
|
33
164
|
readonly children?: KubbNode;
|
|
34
165
|
readonly meta: TMeta;
|
|
35
166
|
};
|
|
167
|
+
/**
|
|
168
|
+
* Provides the current app context (meta and exit) to descendants.
|
|
169
|
+
* This component mirrors the Fabric app container in React.
|
|
170
|
+
*/
|
|
36
171
|
declare function App<TMeta = unknown>({
|
|
37
172
|
meta,
|
|
38
173
|
children
|
|
39
|
-
}: Props$4<TMeta>):
|
|
174
|
+
}: Props$4<TMeta>): react3.ReactNode;
|
|
40
175
|
declare namespace App {
|
|
41
|
-
var Context: react4.Context<AppContextProps<unknown> | undefined>;
|
|
42
176
|
var displayName: string;
|
|
43
177
|
}
|
|
44
178
|
//#endregion
|
|
@@ -67,6 +201,9 @@ type Props$3 = {
|
|
|
67
201
|
asConst?: boolean;
|
|
68
202
|
children?: KubbNode;
|
|
69
203
|
};
|
|
204
|
+
/**
|
|
205
|
+
* Renders a constant declaration. Supports optional export, type and JSDoc.
|
|
206
|
+
*/
|
|
70
207
|
declare function Const({
|
|
71
208
|
name,
|
|
72
209
|
export: canExport,
|
|
@@ -74,25 +211,12 @@ declare function Const({
|
|
|
74
211
|
JSDoc,
|
|
75
212
|
asConst,
|
|
76
213
|
children
|
|
77
|
-
}: Props$3):
|
|
214
|
+
}: Props$3): react3.JSX.Element;
|
|
78
215
|
declare namespace Const {
|
|
79
216
|
var displayName: string;
|
|
80
217
|
}
|
|
81
218
|
//#endregion
|
|
82
219
|
//#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
220
|
type BasePropsWithBaseName = {
|
|
97
221
|
/**
|
|
98
222
|
* Name to be used to dynamicly create the baseName(based on input.path).
|
|
@@ -120,53 +244,74 @@ type Props$2<TMeta> = BaseProps & {
|
|
|
120
244
|
footer?: string;
|
|
121
245
|
children?: KubbNode;
|
|
122
246
|
};
|
|
247
|
+
/**
|
|
248
|
+
* Registers a file in the FileCollector context and provides a scoped collector
|
|
249
|
+
* for children. When `baseName` and `path` are provided the file will be
|
|
250
|
+
* registered so it can be emitted by the collector later.
|
|
251
|
+
*/
|
|
123
252
|
declare function File<TMeta extends object = object>({
|
|
124
253
|
children,
|
|
125
254
|
...rest
|
|
126
|
-
}: Props$2<TMeta>):
|
|
255
|
+
}: Props$2<TMeta>): react3.JSX.Element;
|
|
127
256
|
declare namespace File {
|
|
128
257
|
var displayName: string;
|
|
129
258
|
var Export: typeof FileExport;
|
|
130
259
|
var Import: typeof FileImport;
|
|
131
260
|
var Source: typeof FileSource;
|
|
132
|
-
var Context: react4.Context<FileContextProps<object>>;
|
|
133
261
|
}
|
|
134
262
|
type FileSourceProps = Omit<Source, 'value'> & {
|
|
135
263
|
key?: Key;
|
|
136
264
|
children?: KubbNode;
|
|
137
265
|
};
|
|
266
|
+
/**
|
|
267
|
+
* File.Source
|
|
268
|
+
*
|
|
269
|
+
* Marks a block of source text to be associated with the current file when
|
|
270
|
+
* rendering with the FileCollector. Children are treated as the source string.
|
|
271
|
+
*/
|
|
138
272
|
declare function FileSource({
|
|
139
273
|
isTypeOnly,
|
|
140
274
|
name,
|
|
141
275
|
isExportable,
|
|
142
276
|
isIndexable,
|
|
143
277
|
children
|
|
144
|
-
}: FileSourceProps):
|
|
278
|
+
}: FileSourceProps): react3.JSX.Element;
|
|
145
279
|
declare namespace FileSource {
|
|
146
280
|
var displayName: string;
|
|
147
281
|
}
|
|
148
282
|
type FileExportProps = Export & {
|
|
149
283
|
key?: Key;
|
|
150
284
|
};
|
|
285
|
+
/**
|
|
286
|
+
* File.Export
|
|
287
|
+
*
|
|
288
|
+
* Declares an export entry for the current file. This will be collected by
|
|
289
|
+
* the FileCollector for later emission.
|
|
290
|
+
*/
|
|
151
291
|
declare function FileExport({
|
|
152
292
|
name,
|
|
153
293
|
path,
|
|
154
294
|
isTypeOnly,
|
|
155
295
|
asAlias
|
|
156
|
-
}: FileExportProps):
|
|
296
|
+
}: FileExportProps): react3.JSX.Element;
|
|
157
297
|
declare namespace FileExport {
|
|
158
298
|
var displayName: string;
|
|
159
299
|
}
|
|
160
300
|
type FileImportProps = Import & {
|
|
161
301
|
key?: Key;
|
|
162
302
|
};
|
|
303
|
+
/**
|
|
304
|
+
* File.Import
|
|
305
|
+
*
|
|
306
|
+
* Declares an import entry for the current file.
|
|
307
|
+
*/
|
|
163
308
|
declare function FileImport({
|
|
164
309
|
name,
|
|
165
310
|
root,
|
|
166
311
|
path,
|
|
167
312
|
isTypeOnly,
|
|
168
313
|
isNameSpace
|
|
169
|
-
}: FileImportProps):
|
|
314
|
+
}: FileImportProps): react3.JSX.Element;
|
|
170
315
|
declare namespace FileImport {
|
|
171
316
|
var displayName: string;
|
|
172
317
|
}
|
|
@@ -209,6 +354,10 @@ type Props$1 = {
|
|
|
209
354
|
JSDoc?: JSDoc;
|
|
210
355
|
children?: KubbNode;
|
|
211
356
|
};
|
|
357
|
+
/**
|
|
358
|
+
* Renders a function definition using the Fabric templating primitives.
|
|
359
|
+
* Supports optional export/default/async flags, generics, params and JSDoc.
|
|
360
|
+
*/
|
|
212
361
|
declare function Function({
|
|
213
362
|
name,
|
|
214
363
|
default: isDefault,
|
|
@@ -219,7 +368,7 @@ declare function Function({
|
|
|
219
368
|
returnType,
|
|
220
369
|
JSDoc,
|
|
221
370
|
children
|
|
222
|
-
}: Props$1):
|
|
371
|
+
}: Props$1): react3.JSX.Element;
|
|
223
372
|
declare namespace Function {
|
|
224
373
|
var displayName: string;
|
|
225
374
|
var Arrow: typeof ArrowFunction;
|
|
@@ -230,6 +379,12 @@ type ArrowFunctionProps = Props$1 & {
|
|
|
230
379
|
*/
|
|
231
380
|
singleLine?: boolean;
|
|
232
381
|
};
|
|
382
|
+
/**
|
|
383
|
+
* ArrowFunction
|
|
384
|
+
*
|
|
385
|
+
* Renders an arrow function definition. Supports the same flags as `Function`.
|
|
386
|
+
* Use `singleLine` to render the body as a single-line expression.
|
|
387
|
+
*/
|
|
233
388
|
declare function ArrowFunction({
|
|
234
389
|
name,
|
|
235
390
|
default: isDefault,
|
|
@@ -241,7 +396,7 @@ declare function ArrowFunction({
|
|
|
241
396
|
JSDoc,
|
|
242
397
|
singleLine,
|
|
243
398
|
children
|
|
244
|
-
}: ArrowFunctionProps):
|
|
399
|
+
}: ArrowFunctionProps): react3.JSX.Element;
|
|
245
400
|
declare namespace ArrowFunction {
|
|
246
401
|
var displayName: string;
|
|
247
402
|
}
|
|
@@ -254,6 +409,9 @@ type IndentProps = {
|
|
|
254
409
|
/**
|
|
255
410
|
* Indents all children by `size` spaces.
|
|
256
411
|
* Collapses consecutive <br /> tags to at most 2.
|
|
412
|
+
*
|
|
413
|
+
* Indent will dedent and re-indent string children and will prefix
|
|
414
|
+
* non-string children with the requested number of spaces.
|
|
257
415
|
*/
|
|
258
416
|
declare function Indent({
|
|
259
417
|
size,
|
|
@@ -277,31 +435,25 @@ type Props = {
|
|
|
277
435
|
JSDoc?: JSDoc;
|
|
278
436
|
children?: KubbNode;
|
|
279
437
|
};
|
|
438
|
+
/**
|
|
439
|
+
* Renders a TypeScript type alias. Validates that the provided name starts
|
|
440
|
+
* with a capital letter and optionally emits JSDoc comments.
|
|
441
|
+
*/
|
|
280
442
|
declare function Type({
|
|
281
443
|
name,
|
|
282
444
|
export: canExport,
|
|
283
445
|
JSDoc,
|
|
284
446
|
children
|
|
285
|
-
}: Props):
|
|
447
|
+
}: Props): react3.JSX.Element;
|
|
286
448
|
declare namespace Type {
|
|
287
449
|
var displayName: string;
|
|
288
450
|
}
|
|
289
451
|
//#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
452
|
//#region src/composables/useLifecycle.d.ts
|
|
303
453
|
/**
|
|
304
|
-
*
|
|
454
|
+
* Provides lifecycle helpers that integrate with the Fabric runtime. The
|
|
455
|
+
* `exit` helper schedules a call to the RootContext exit function on the
|
|
456
|
+
* next tick to allow React to complete its render cycle first.
|
|
305
457
|
*/
|
|
306
458
|
declare function useLifecycle(): {
|
|
307
459
|
exit: () => void;
|
|
@@ -345,15 +497,15 @@ declare class Runtime {
|
|
|
345
497
|
}
|
|
346
498
|
//#endregion
|
|
347
499
|
//#region src/index.d.ts
|
|
348
|
-
declare const useState: typeof
|
|
349
|
-
declare const createContext: typeof
|
|
350
|
-
declare const createElement: typeof
|
|
351
|
-
declare const Fragment:
|
|
352
|
-
declare const use: typeof
|
|
353
|
-
declare const useContext: typeof
|
|
354
|
-
declare const useEffect: typeof
|
|
355
|
-
declare const useReducer: typeof
|
|
356
|
-
declare const useRef: typeof
|
|
500
|
+
declare const useState: typeof react3.useState;
|
|
501
|
+
declare const createContext: typeof react3.createContext;
|
|
502
|
+
declare const createElement: typeof react3.createElement;
|
|
503
|
+
declare const Fragment: react3.ExoticComponent<react3.FragmentProps>;
|
|
504
|
+
declare const use: typeof react3.use;
|
|
505
|
+
declare const useContext: typeof react3.useContext;
|
|
506
|
+
declare const useEffect: typeof react3.useEffect;
|
|
507
|
+
declare const useReducer: typeof react3.useReducer;
|
|
508
|
+
declare const useRef: typeof react3.useRef;
|
|
357
509
|
//#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 };
|
|
510
|
+
export { App, AppContext, Const, type Context, type Fabric, File, FileCollector, FileCollectorContext, FileManager, FileProcessor, Fragment, Function, FunctionParams, Indent, Root, RootContext, Runtime, Type, createContext, createElement, createFabric, createFile, createFunctionParams, createJSDoc, createReactFabric, inject, provide, unprovide, use, useApp, useContext, useEffect, useFile, useLifecycle, useReducer, useRef, useState };
|
|
359
511
|
//# sourceMappingURL=index.d.ts.map
|
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-DT9toQPK.js";
|
|
6
|
+
import { AppContext, FileCollector, FileCollectorContext, RootContext, createFabric, createJSDoc, provide, useApp, useContext as useContext$1, useFile } from "@kubb/fabric-core";
|
|
7
7
|
import dedent from "dedent";
|
|
8
8
|
import { orderBy } from "natural-orderby";
|
|
9
9
|
|
|
@@ -11,30 +11,25 @@ export * from "@kubb/fabric-core"
|
|
|
11
11
|
|
|
12
12
|
//#region src/components/App.tsx
|
|
13
13
|
var import_react = /* @__PURE__ */ __toESM(require_react());
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Provides the current app context (meta and exit) to descendants.
|
|
16
|
+
* This component mirrors the Fabric app container in React.
|
|
17
|
+
*/
|
|
15
18
|
function App({ meta, children }) {
|
|
16
|
-
const { exit } =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
meta
|
|
21
|
-
},
|
|
22
|
-
children
|
|
19
|
+
const { exit } = useContext$1(RootContext);
|
|
20
|
+
provide(AppContext, {
|
|
21
|
+
exit,
|
|
22
|
+
meta
|
|
23
23
|
});
|
|
24
|
+
return children;
|
|
24
25
|
}
|
|
25
|
-
App.Context = AppContext;
|
|
26
26
|
App.displayName = "KubbApp";
|
|
27
27
|
|
|
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
28
|
//#endregion
|
|
37
29
|
//#region src/components/Const.tsx
|
|
30
|
+
/**
|
|
31
|
+
* Renders a constant declaration. Supports optional export, type and JSDoc.
|
|
32
|
+
*/
|
|
38
33
|
function Const({ name, export: canExport, type, JSDoc, asConst, children }) {
|
|
39
34
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
40
35
|
(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", {})] }),
|
|
@@ -56,22 +51,37 @@ Const.displayName = "KubbConst";
|
|
|
56
51
|
|
|
57
52
|
//#endregion
|
|
58
53
|
//#region src/components/File.tsx
|
|
59
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Registers a file in the FileCollector context and provides a scoped collector
|
|
56
|
+
* for children. When `baseName` and `path` are provided the file will be
|
|
57
|
+
* registered so it can be emitted by the collector later.
|
|
58
|
+
*/
|
|
60
59
|
function File({ children, ...rest }) {
|
|
60
|
+
const collector = useContext$1(FileCollectorContext, new FileCollector());
|
|
61
|
+
provide(FileCollectorContext, collector);
|
|
61
62
|
if (!rest.baseName || !rest.path) return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
63
|
+
collector.add({
|
|
64
|
+
baseName: rest.baseName,
|
|
65
|
+
path: rest.path,
|
|
66
|
+
meta: rest.meta || {},
|
|
67
|
+
banner: rest.banner,
|
|
68
|
+
footer: rest.footer,
|
|
69
|
+
sources: [],
|
|
70
|
+
imports: [],
|
|
71
|
+
exports: []
|
|
72
|
+
});
|
|
62
73
|
return /* @__PURE__ */ jsx("kubb-file", {
|
|
63
74
|
...rest,
|
|
64
|
-
children
|
|
65
|
-
value: {
|
|
66
|
-
baseName: rest.baseName,
|
|
67
|
-
path: rest.path,
|
|
68
|
-
meta: rest.meta
|
|
69
|
-
},
|
|
70
|
-
children
|
|
71
|
-
})
|
|
75
|
+
children
|
|
72
76
|
});
|
|
73
77
|
}
|
|
74
78
|
File.displayName = "KubbFile";
|
|
79
|
+
/**
|
|
80
|
+
* File.Source
|
|
81
|
+
*
|
|
82
|
+
* Marks a block of source text to be associated with the current file when
|
|
83
|
+
* rendering with the FileCollector. Children are treated as the source string.
|
|
84
|
+
*/
|
|
75
85
|
function FileSource({ isTypeOnly, name, isExportable, isIndexable, children }) {
|
|
76
86
|
return /* @__PURE__ */ jsx("kubb-source", {
|
|
77
87
|
name,
|
|
@@ -82,6 +92,12 @@ function FileSource({ isTypeOnly, name, isExportable, isIndexable, children }) {
|
|
|
82
92
|
});
|
|
83
93
|
}
|
|
84
94
|
FileSource.displayName = "KubbFileSource";
|
|
95
|
+
/**
|
|
96
|
+
* File.Export
|
|
97
|
+
*
|
|
98
|
+
* Declares an export entry for the current file. This will be collected by
|
|
99
|
+
* the FileCollector for later emission.
|
|
100
|
+
*/
|
|
85
101
|
function FileExport({ name, path, isTypeOnly, asAlias }) {
|
|
86
102
|
return /* @__PURE__ */ jsx("kubb-export", {
|
|
87
103
|
name,
|
|
@@ -91,6 +107,11 @@ function FileExport({ name, path, isTypeOnly, asAlias }) {
|
|
|
91
107
|
});
|
|
92
108
|
}
|
|
93
109
|
FileExport.displayName = "KubbFileExport";
|
|
110
|
+
/**
|
|
111
|
+
* File.Import
|
|
112
|
+
*
|
|
113
|
+
* Declares an import entry for the current file.
|
|
114
|
+
*/
|
|
94
115
|
function FileImport({ name, root, path, isTypeOnly, isNameSpace }) {
|
|
95
116
|
return /* @__PURE__ */ jsx("kubb-import", {
|
|
96
117
|
name,
|
|
@@ -104,7 +125,6 @@ FileImport.displayName = "KubbFileImport";
|
|
|
104
125
|
File.Export = FileExport;
|
|
105
126
|
File.Import = FileImport;
|
|
106
127
|
File.Source = FileSource;
|
|
107
|
-
File.Context = FileContext;
|
|
108
128
|
|
|
109
129
|
//#endregion
|
|
110
130
|
//#region ../../node_modules/.pnpm/indent-string@5.0.0/node_modules/indent-string/index.js
|
|
@@ -124,6 +144,9 @@ function indentString(string, count = 1, options = {}) {
|
|
|
124
144
|
/**
|
|
125
145
|
* Indents all children by `size` spaces.
|
|
126
146
|
* Collapses consecutive <br /> tags to at most 2.
|
|
147
|
+
*
|
|
148
|
+
* Indent will dedent and re-indent string children and will prefix
|
|
149
|
+
* non-string children with the requested number of spaces.
|
|
127
150
|
*/
|
|
128
151
|
function Indent({ size = 2, children }) {
|
|
129
152
|
if (!children) return null;
|
|
@@ -150,6 +173,10 @@ function Indent({ size = 2, children }) {
|
|
|
150
173
|
|
|
151
174
|
//#endregion
|
|
152
175
|
//#region src/components/Function.tsx
|
|
176
|
+
/**
|
|
177
|
+
* Renders a function definition using the Fabric templating primitives.
|
|
178
|
+
* Supports optional export/default/async flags, generics, params and JSDoc.
|
|
179
|
+
*/
|
|
153
180
|
function Function({ name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, children }) {
|
|
154
181
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
155
182
|
(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", {})] }),
|
|
@@ -184,6 +211,12 @@ function Function({ name, default: isDefault, export: canExport, async, generics
|
|
|
184
211
|
] });
|
|
185
212
|
}
|
|
186
213
|
Function.displayName = "KubbFunction";
|
|
214
|
+
/**
|
|
215
|
+
* ArrowFunction
|
|
216
|
+
*
|
|
217
|
+
* Renders an arrow function definition. Supports the same flags as `Function`.
|
|
218
|
+
* Use `singleLine` to render the body as a single-line expression.
|
|
219
|
+
*/
|
|
187
220
|
function ArrowFunction({ name, default: isDefault, export: canExport, async, generics, params, returnType, JSDoc, singleLine, children }) {
|
|
188
221
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
189
222
|
(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", {})] }),
|
|
@@ -231,6 +264,10 @@ Function.Arrow = ArrowFunction;
|
|
|
231
264
|
|
|
232
265
|
//#endregion
|
|
233
266
|
//#region src/components/Type.tsx
|
|
267
|
+
/**
|
|
268
|
+
* Renders a TypeScript type alias. Validates that the provided name starts
|
|
269
|
+
* with a capital letter and optionally emits JSDoc comments.
|
|
270
|
+
*/
|
|
234
271
|
function Type({ name, export: canExport, JSDoc, children }) {
|
|
235
272
|
if (name.charAt(0).toUpperCase() !== name.charAt(0)) throw new Error("Name should start with a capital letter(see TypeScript types)");
|
|
236
273
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
@@ -244,36 +281,17 @@ function Type({ name, export: canExport, JSDoc, children }) {
|
|
|
244
281
|
}
|
|
245
282
|
Type.displayName = "KubbType";
|
|
246
283
|
|
|
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
284
|
//#endregion
|
|
268
285
|
//#region src/composables/useLifecycle.tsx
|
|
269
286
|
/**
|
|
270
|
-
*
|
|
287
|
+
* Provides lifecycle helpers that integrate with the Fabric runtime. The
|
|
288
|
+
* `exit` helper schedules a call to the RootContext exit function on the
|
|
289
|
+
* next tick to allow React to complete its render cycle first.
|
|
271
290
|
*/
|
|
272
291
|
function useLifecycle() {
|
|
273
|
-
const { exit } = (
|
|
292
|
+
const { exit } = useContext$1(RootContext, { exit: () => {} });
|
|
274
293
|
return { exit: () => {
|
|
275
|
-
|
|
276
|
-
clearTimeout(timeout);
|
|
294
|
+
setTimeout(() => {
|
|
277
295
|
exit();
|
|
278
296
|
}, 0);
|
|
279
297
|
} };
|
|
@@ -297,12 +315,11 @@ function createReactFabric(config = {}) {
|
|
|
297
315
|
//#region src/utils/getFunctionParams.ts
|
|
298
316
|
function order(items) {
|
|
299
317
|
return orderBy(items.filter(Boolean), [([_key, item]) => {
|
|
300
|
-
if (item === null || item === void 0 ? void 0 : item.children) return;
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}], ["desc", "desc"]);
|
|
318
|
+
if (item === null || item === void 0 ? void 0 : item.children) return 0;
|
|
319
|
+
if (item === null || item === void 0 ? void 0 : item.optional) return 1;
|
|
320
|
+
if (item === null || item === void 0 ? void 0 : item.default) return 2;
|
|
321
|
+
return 0;
|
|
322
|
+
}], ["asc"]);
|
|
306
323
|
}
|
|
307
324
|
function parseChild(key, item, options) {
|
|
308
325
|
const entries = order(Object.entries(item.children));
|