@kubb/react-fabric 0.9.5 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/{devtools-D6dZodXp.js → devtools-8_UKWDTl.js} +1 -1
  2. package/dist/{devtools-D6dZodXp.js.map → devtools-8_UKWDTl.js.map} +1 -1
  3. package/dist/{devtools-CRkwwngz.cjs → devtools-BOpUJhc_.cjs} +1 -1
  4. package/dist/{devtools-CRkwwngz.cjs.map → devtools-BOpUJhc_.cjs.map} +1 -1
  5. package/dist/devtools.cjs +1 -1
  6. package/dist/devtools.js +1 -1
  7. package/dist/globals.d.cts +1 -1
  8. package/dist/globals.d.ts +1 -1
  9. package/dist/index.cjs +88 -60
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +209 -57
  12. package/dist/index.d.ts +191 -39
  13. package/dist/index.js +73 -55
  14. package/dist/index.js.map +1 -1
  15. package/dist/jsx-dev-runtime.d.cts +2 -2
  16. package/dist/jsx-dev-runtime.d.ts +2 -2
  17. package/dist/{jsx-namespace-CCPa1Nut.d.cts → jsx-namespace-BnoysbjP.d.cts} +2 -2
  18. package/dist/{jsx-namespace-BAkGpU6g.d.ts → jsx-namespace-D0a66_uR.d.ts} +2 -2
  19. package/dist/{jsx-runtime-BEVcoJUm.cjs → jsx-runtime-Cq39dA50.cjs} +1 -1
  20. package/dist/{jsx-runtime-BEVcoJUm.cjs.map → jsx-runtime-Cq39dA50.cjs.map} +1 -1
  21. package/dist/{jsx-runtime-DDu0mFTI.js → jsx-runtime-Isgf9orn.js} +1 -1
  22. package/dist/{jsx-runtime-DDu0mFTI.js.map → jsx-runtime-Isgf9orn.js.map} +1 -1
  23. package/dist/jsx-runtime.cjs +1 -1
  24. package/dist/jsx-runtime.d.cts +2 -2
  25. package/dist/jsx-runtime.d.ts +2 -2
  26. package/dist/jsx-runtime.js +1 -1
  27. package/dist/plugins.cjs +2 -2
  28. package/dist/plugins.js +2 -2
  29. package/dist/{reactPlugin-CXaAO13f.cjs → reactPlugin-D4SmGYbm.cjs} +52 -59
  30. package/dist/reactPlugin-D4SmGYbm.cjs.map +1 -0
  31. package/dist/{reactPlugin-ixOr00MK.js → reactPlugin-DT9toQPK.js} +53 -48
  32. package/dist/reactPlugin-DT9toQPK.js.map +1 -0
  33. package/dist/{types-CSUzVTpn.d.ts → types-BL7PkfqA.d.ts} +7 -5
  34. package/dist/{types-DP2mgqeb.d.cts → types-BdOHT5YF.d.cts} +7 -5
  35. package/dist/types.d.cts +1 -1
  36. package/dist/types.d.ts +1 -1
  37. package/package.json +3 -3
  38. package/src/components/App.tsx +7 -14
  39. package/src/components/Const.tsx +3 -0
  40. package/src/components/File.tsx +39 -22
  41. package/src/components/Function.tsx +10 -0
  42. package/src/components/Indent.tsx +3 -0
  43. package/src/components/Root.tsx +13 -14
  44. package/src/components/Type.tsx +4 -0
  45. package/src/composables/useApp.ts +1 -15
  46. package/src/composables/useFile.ts +1 -12
  47. package/src/composables/useLifecycle.tsx +7 -8
  48. package/src/index.ts +5 -1
  49. package/src/types.ts +0 -4
  50. package/src/utils/createJSDoc.ts +1 -8
  51. package/dist/reactPlugin-CXaAO13f.cjs.map +0 -1
  52. package/dist/reactPlugin-ixOr00MK.js.map +0 -1
package/dist/index.d.cts 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-C61uYmUy.cjs";
2
- import { a as JSDoc, d as KubbNode, g as FunctionParams, o as Key, y as createFunctionParams } from "./types-DP2mgqeb.cjs";
2
+ import { a as Key, h as FunctionParams, u as KubbNode, v as createFunctionParams, y as JSDoc } from "./types-BdOHT5YF.cjs";
3
3
  import { t as Options$1 } from "./reactPlugin-B4xarQJX.cjs";
4
- import * as react3 from "react";
4
+ import * as react7 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>): react3.JSX.Element;
174
+ }: Props$4<TMeta>): react7.ReactNode;
40
175
  declare namespace App {
41
- var Context: react3.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): react3.JSX.Element;
214
+ }: Props$3): react7.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>): react3.JSX.Element;
255
+ }: Props$2<TMeta>): react7.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: react3.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): react3.JSX.Element;
278
+ }: FileSourceProps): react7.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): react3.JSX.Element;
296
+ }: FileExportProps): react7.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): react3.JSX.Element;
314
+ }: FileImportProps): react7.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): react3.JSX.Element;
371
+ }: Props$1): react7.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): react3.JSX.Element;
399
+ }: ArrowFunctionProps): react7.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): react3.JSX.Element;
447
+ }: Props): react7.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
- * `useLifecycle` will return some helpers to exit/restart the generation.
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 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;
500
+ declare const useState: typeof react7.useState;
501
+ declare const createContext: typeof react7.createContext;
502
+ declare const createElement: typeof react7.createElement;
503
+ declare const Fragment: react7.ExoticComponent<react7.FragmentProps>;
504
+ declare const use: typeof react7.use;
505
+ declare const useContext: typeof react7.useContext;
506
+ declare const useEffect: typeof react7.useEffect;
507
+ declare const useReducer: typeof react7.useReducer;
508
+ declare const useRef: typeof react7.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.cts.map