@kubb/react-fabric 0.10.0 → 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.
Files changed (90) hide show
  1. package/dist/{Fabric-DitK3IEP.d.ts → Fabric-BELBf-bX.d.cts} +5 -5
  2. package/dist/{Fabric-C61uYmUy.d.cts → Fabric-DbJhvsCq.d.ts} +5 -5
  3. package/dist/globals.d.cts +2 -2
  4. package/dist/globals.d.ts +2 -2
  5. package/dist/index.cjs +99 -34
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +3 -511
  8. package/dist/index.d.ts +3 -511
  9. package/dist/index.js +100 -35
  10. package/dist/index.js.map +1 -1
  11. package/dist/jsx-dev-runtime.d.cts +5 -5
  12. package/dist/jsx-dev-runtime.d.ts +3 -3
  13. package/dist/{jsx-namespace-D0a66_uR.d.ts → jsx-namespace-CBOEkCmJ.d.ts} +2 -2
  14. package/dist/{jsx-namespace-BnoysbjP.d.cts → jsx-namespace-od7sqrmY.d.cts} +2 -2
  15. package/dist/jsx-runtime.d.cts +5 -5
  16. package/dist/jsx-runtime.d.ts +3 -3
  17. package/dist/parsers.d.cts +1 -1
  18. package/dist/parsers.d.ts +1 -1
  19. package/dist/plugins.cjs +1 -1
  20. package/dist/plugins.d.cts +2 -2
  21. package/dist/plugins.d.ts +2 -2
  22. package/dist/plugins.js +1 -1
  23. package/dist/{reactPlugin-D4SmGYbm.cjs → reactPlugin-B8F6jVb5.cjs} +33 -13
  24. package/dist/reactPlugin-B8F6jVb5.cjs.map +1 -0
  25. package/dist/{reactPlugin-DT9toQPK.js → reactPlugin-CAtVV84d.js} +34 -14
  26. package/dist/reactPlugin-CAtVV84d.js.map +1 -0
  27. package/dist/types-C3ODUOKN.d.cts +675 -0
  28. package/dist/types-DwaohVJS.d.ts +675 -0
  29. package/dist/types.d.cts +3 -3
  30. package/dist/types.d.ts +3 -3
  31. package/package.json +2 -2
  32. package/src/Runtime.tsx +22 -12
  33. package/src/components/App.tsx +23 -7
  34. package/src/components/Const.tsx +17 -4
  35. package/src/components/File.tsx +83 -24
  36. package/src/components/Function.tsx +28 -7
  37. package/src/components/Root.tsx +23 -16
  38. package/src/components/Type.tsx +17 -4
  39. package/src/components/__snapshots__/arrow_function.ts +3 -0
  40. package/src/components/__snapshots__/arrow_function_default.ts +3 -0
  41. package/src/components/__snapshots__/arrow_function_generics.ts +3 -0
  42. package/src/components/__snapshots__/arrow_function_single_line.ts +1 -0
  43. package/src/components/__snapshots__/arrow_function_with_generics.ts +3 -0
  44. package/src/components/__snapshots__/async_arrow_function.ts +3 -0
  45. package/src/components/__snapshots__/async_function.ts +3 -0
  46. package/src/components/__snapshots__/async_function_with_Promise_return_type.ts +3 -0
  47. package/src/components/__snapshots__/basic_arrow_function.ts +3 -0
  48. package/src/components/__snapshots__/basic_const.ts +1 -0
  49. package/src/components/__snapshots__/basic_export.ts +1 -0
  50. package/src/components/__snapshots__/basic_function.ts +3 -0
  51. package/src/components/__snapshots__/basic_import.ts +1 -0
  52. package/src/components/__snapshots__/basic_type.ts +1 -0
  53. package/src/components/__snapshots__/const_with_JSDoc.ts +4 -0
  54. package/src/components/__snapshots__/const_with_as_const.ts +1 -0
  55. package/src/components/__snapshots__/const_with_type.ts +1 -0
  56. package/src/components/__snapshots__/default_exported_arrow_function.ts +3 -0
  57. package/src/components/__snapshots__/default_exported_function.ts +3 -0
  58. package/src/components/__snapshots__/exported_arrow_function.ts +3 -0
  59. package/src/components/__snapshots__/exported_const.ts +1 -0
  60. package/src/components/__snapshots__/exported_function.ts +3 -0
  61. package/src/components/__snapshots__/exported_type.ts +1 -0
  62. package/src/components/__snapshots__/function_generics.ts +3 -0
  63. package/src/components/__snapshots__/function_with_JSDoc.ts +6 -0
  64. package/src/components/__snapshots__/function_with_comments.ts +6 -0
  65. package/src/components/__snapshots__/function_with_generics.ts +3 -0
  66. package/src/components/__snapshots__/function_with_parameters.ts +3 -0
  67. package/src/components/__snapshots__/function_with_params.ts +3 -0
  68. package/src/components/__snapshots__/function_with_returnType.ts +3 -0
  69. package/src/components/__snapshots__/function_with_return_type.ts +3 -0
  70. package/src/components/__snapshots__/matches_with_root_import.ts +1 -0
  71. package/src/components/__snapshots__/multiple_functions.ts +3 -0
  72. package/src/components/__snapshots__/named_export.ts +1 -0
  73. package/src/components/__snapshots__/named_export_(object_advanced).ts +1 -0
  74. package/src/components/__snapshots__/named_import.ts +1 -0
  75. package/src/components/__snapshots__/named_import_(object).ts +1 -0
  76. package/src/components/__snapshots__/named_import_(object_advanced).ts +1 -0
  77. package/src/components/__snapshots__/named_typed_export.ts +1 -0
  78. package/src/components/__snapshots__/named_typed_import.ts +1 -0
  79. package/src/components/__snapshots__/single_line_arrow_function.ts +1 -0
  80. package/src/components/__snapshots__/type_with_JSDoc.ts +4 -0
  81. package/src/components/__snapshots__/typed_export.ts +1 -0
  82. package/src/components/__snapshots__/typed_import.ts +1 -0
  83. package/src/composables/useLifecycle.tsx +1 -1
  84. package/src/plugins/reactPlugin.ts +7 -6
  85. package/dist/reactPlugin-4-kcMKwZ.d.ts +0 -31
  86. package/dist/reactPlugin-B4xarQJX.d.cts +0 -31
  87. package/dist/reactPlugin-D4SmGYbm.cjs.map +0 -1
  88. package/dist/reactPlugin-DT9toQPK.js.map +0 -1
  89. package/dist/types-BL7PkfqA.d.ts +0 -106
  90. package/dist/types-BdOHT5YF.d.cts +0 -106
package/dist/index.d.cts CHANGED
@@ -1,511 +1,3 @@
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 Key, h as FunctionParams, u as KubbNode, v as createFunctionParams, y as JSDoc } from "./types-BdOHT5YF.cjs";
3
- import { t as Options$1 } from "./reactPlugin-B4xarQJX.cjs";
4
- import * as react7 from "react";
5
- import React, { ReactNode } from "react";
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
136
- //#region ../fabric-core/src/createFabric.d.ts
137
- /**
138
- * Creates a new Fabric instance
139
- *
140
- * @example
141
- * const fabric = createFabric()
142
- * fabric.use(myPlugin())
143
- */
144
- declare function createFabric<T extends FabricOptions>(config?: FabricConfig<T>): Fabric<T>;
145
- //#endregion
146
- //#region ../fabric-core/src/createFile.d.ts
147
- /**
148
- * Helper to create a file with name and id set
149
- */
150
- declare function createFile<TMeta extends object = object>(file: File$1<TMeta>): ResolvedFile<TMeta>;
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
162
- //#region src/components/App.d.ts
163
- type Props$4<TMeta = unknown> = {
164
- readonly children?: KubbNode;
165
- readonly meta: TMeta;
166
- };
167
- /**
168
- * Provides the current app context (meta and exit) to descendants.
169
- * This component mirrors the Fabric app container in React.
170
- */
171
- declare function App<TMeta = unknown>({
172
- meta,
173
- children
174
- }: Props$4<TMeta>): react7.ReactNode;
175
- declare namespace App {
176
- var displayName: string;
177
- }
178
- //#endregion
179
- //#region src/components/Const.d.ts
180
- type Props$3 = {
181
- key?: Key;
182
- /**
183
- * Name of the const
184
- */
185
- name: string;
186
- /**
187
- * Does this type need to be exported.
188
- */
189
- export?: boolean;
190
- /**
191
- * Type to make the const being typed
192
- */
193
- type?: string;
194
- /**
195
- * Options for JSdocs.
196
- */
197
- JSDoc?: JSDoc;
198
- /**
199
- * Use of `const` assertions
200
- */
201
- asConst?: boolean;
202
- children?: KubbNode;
203
- };
204
- /**
205
- * Renders a constant declaration. Supports optional export, type and JSDoc.
206
- */
207
- declare function Const({
208
- name,
209
- export: canExport,
210
- type,
211
- JSDoc,
212
- asConst,
213
- children
214
- }: Props$3): react7.JSX.Element;
215
- declare namespace Const {
216
- var displayName: string;
217
- }
218
- //#endregion
219
- //#region src/components/File.d.ts
220
- type BasePropsWithBaseName = {
221
- /**
222
- * Name to be used to dynamicly create the baseName(based on input.path).
223
- * Based on UNIX basename
224
- * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
225
- */
226
- baseName: BaseName;
227
- /**
228
- * Path will be full qualified path to a specified file.
229
- */
230
- path: Path;
231
- };
232
- type BasePropsWithoutBaseName = {
233
- baseName?: never;
234
- /**
235
- * Path will be full qualified path to a specified file.
236
- */
237
- path?: Path;
238
- };
239
- type BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName;
240
- type Props$2<TMeta> = BaseProps & {
241
- key?: Key;
242
- meta?: TMeta;
243
- banner?: string;
244
- footer?: string;
245
- children?: KubbNode;
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
- */
252
- declare function File<TMeta extends object = object>({
253
- children,
254
- ...rest
255
- }: Props$2<TMeta>): react7.JSX.Element;
256
- declare namespace File {
257
- var displayName: string;
258
- var Export: typeof FileExport;
259
- var Import: typeof FileImport;
260
- var Source: typeof FileSource;
261
- }
262
- type FileSourceProps = Omit<Source, 'value'> & {
263
- key?: Key;
264
- children?: KubbNode;
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
- */
272
- declare function FileSource({
273
- isTypeOnly,
274
- name,
275
- isExportable,
276
- isIndexable,
277
- children
278
- }: FileSourceProps): react7.JSX.Element;
279
- declare namespace FileSource {
280
- var displayName: string;
281
- }
282
- type FileExportProps = Export & {
283
- key?: Key;
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
- */
291
- declare function FileExport({
292
- name,
293
- path,
294
- isTypeOnly,
295
- asAlias
296
- }: FileExportProps): react7.JSX.Element;
297
- declare namespace FileExport {
298
- var displayName: string;
299
- }
300
- type FileImportProps = Import & {
301
- key?: Key;
302
- };
303
- /**
304
- * File.Import
305
- *
306
- * Declares an import entry for the current file.
307
- */
308
- declare function FileImport({
309
- name,
310
- root,
311
- path,
312
- isTypeOnly,
313
- isNameSpace
314
- }: FileImportProps): react7.JSX.Element;
315
- declare namespace FileImport {
316
- var displayName: string;
317
- }
318
- //#endregion
319
- //#region src/components/Function.d.ts
320
- type Props$1 = {
321
- key?: Key;
322
- /**
323
- * Name of the function.
324
- */
325
- name: string;
326
- /**
327
- * Add default when export is being used
328
- */
329
- default?: boolean;
330
- /**
331
- * Parameters/options/props that need to be used.
332
- */
333
- params?: string;
334
- /**
335
- * Does this function need to be exported.
336
- */
337
- export?: boolean;
338
- /**
339
- * Does the function has async/promise behaviour.
340
- * This will also add `Promise<returnType>` as the returnType.
341
- */
342
- async?: boolean;
343
- /**
344
- * Generics that needs to be added for TypeScript.
345
- */
346
- generics?: string | string[];
347
- /**
348
- * ReturnType(see async for adding Promise type).
349
- */
350
- returnType?: string;
351
- /**
352
- * Options for JSdocs.
353
- */
354
- JSDoc?: JSDoc;
355
- children?: KubbNode;
356
- };
357
- /**
358
- * Renders a function definition using the Fabric templating primitives.
359
- * Supports optional export/default/async flags, generics, params and JSDoc.
360
- */
361
- declare function Function({
362
- name,
363
- default: isDefault,
364
- export: canExport,
365
- async,
366
- generics,
367
- params,
368
- returnType,
369
- JSDoc,
370
- children
371
- }: Props$1): react7.JSX.Element;
372
- declare namespace Function {
373
- var displayName: string;
374
- var Arrow: typeof ArrowFunction;
375
- }
376
- type ArrowFunctionProps = Props$1 & {
377
- /**
378
- * Create Arrow function in one line
379
- */
380
- singleLine?: boolean;
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
- */
388
- declare function ArrowFunction({
389
- name,
390
- default: isDefault,
391
- export: canExport,
392
- async,
393
- generics,
394
- params,
395
- returnType,
396
- JSDoc,
397
- singleLine,
398
- children
399
- }: ArrowFunctionProps): react7.JSX.Element;
400
- declare namespace ArrowFunction {
401
- var displayName: string;
402
- }
403
- //#endregion
404
- //#region src/components/Indent.d.ts
405
- type IndentProps = {
406
- size?: number;
407
- children?: React.ReactNode;
408
- };
409
- /**
410
- * Indents all children by `size` spaces.
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.
415
- */
416
- declare function Indent({
417
- size,
418
- children
419
- }: IndentProps): React.JSX.Element | null;
420
- //#endregion
421
- //#region src/components/Type.d.ts
422
- type Props = {
423
- key?: Key;
424
- /**
425
- * Name of the type, this needs to start with a capital letter.
426
- */
427
- name: string;
428
- /**
429
- * Does this type need to be exported.
430
- */
431
- export?: boolean;
432
- /**
433
- * Options for JSdocs.
434
- */
435
- JSDoc?: JSDoc;
436
- children?: KubbNode;
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
- */
442
- declare function Type({
443
- name,
444
- export: canExport,
445
- JSDoc,
446
- children
447
- }: Props): react7.JSX.Element;
448
- declare namespace Type {
449
- var displayName: string;
450
- }
451
- //#endregion
452
- //#region src/composables/useLifecycle.d.ts
453
- /**
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.
457
- */
458
- declare function useLifecycle(): {
459
- exit: () => void;
460
- };
461
- //#endregion
462
- //#region src/createReactFabric.d.ts
463
- declare function createReactFabric(config?: FabricConfig<Options$1 & {
464
- mode?: FabricMode;
465
- devtools?: boolean;
466
- }>): Fabric<Options$1 & {
467
- mode?: FabricMode;
468
- devtools?: boolean;
469
- }>;
470
- //#endregion
471
- //#region src/Runtime.d.ts
472
- type Options = {
473
- fileManager: FileManager;
474
- stdout?: NodeJS.WriteStream;
475
- stdin?: NodeJS.ReadStream;
476
- stderr?: NodeJS.WriteStream;
477
- /**
478
- * Set this to true to always see the result of the render in the console(line per render)
479
- */
480
- debug?: boolean;
481
- };
482
- declare class Runtime {
483
- #private;
484
- exitPromise?: Promise<void>;
485
- constructor(options: Options);
486
- get fileManager(): FileManager;
487
- resolveExitPromise: () => void;
488
- rejectExitPromise: (reason?: Error) => void;
489
- unsubscribeExit: () => void;
490
- onRender: () => Promise<void>;
491
- onError(error: Error): void;
492
- onExit(error?: Error): void;
493
- render(node: ReactNode): Promise<void>;
494
- renderToString(node: ReactNode): Promise<string>;
495
- unmount(error?: Error | number | null): void;
496
- waitUntilExit(): Promise<void>;
497
- }
498
- //#endregion
499
- //#region src/index.d.ts
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;
509
- //#endregion
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 };
511
- //# sourceMappingURL=index.d.cts.map
1
+ import { c as FileManager, l as FileProcessor, t as Fabric } from "./Fabric-BELBf-bX.cjs";
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-C3ODUOKN.cjs";
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 };