@kubb/react-fabric 0.11.0 → 0.11.2

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.
@@ -1,675 +0,0 @@
1
- import { a as FabricOptions, b as Source, c as FileManager, f as BaseName, g as Import, h as File$1, i as FabricMode, n as FabricConfig, o as Plugin, p as Export, t as Fabric, v as Path, y as ResolvedFile } from "./Fabric-BELBf-bX.cjs";
2
- import * as react3 from "react";
3
- import React, { ElementType, JSX, Key, ReactNode } from "react";
4
-
5
- //#region ../fabric-core/src/utils/TreeNode.d.ts
6
- type BarrelData = {
7
- file?: File$1;
8
- path: string;
9
- name: string;
10
- };
11
- type Graph = {
12
- nodes: Array<{
13
- id: string;
14
- label: string;
15
- }>;
16
- edges: Array<{
17
- from: string;
18
- to: string;
19
- }>;
20
- };
21
- declare class TreeNode<TData = unknown> {
22
- #private;
23
- data: TData;
24
- parent?: TreeNode<TData>;
25
- children: Array<TreeNode<TData>>;
26
- constructor(data: TData, parent?: TreeNode<TData>);
27
- addChild(data: TData): TreeNode<TData>;
28
- getChildByName(name: string): TreeNode<TData> | undefined;
29
- get leaves(): Array<TreeNode<TData>>;
30
- forEach(callback: (node: TreeNode<TData>) => void): this;
31
- findDeep(predicate: (node: TreeNode<TData>) => boolean): TreeNode<TData> | undefined;
32
- static toGraph(root: TreeNode<BarrelData>): Graph;
33
- static fromFiles(files: Array<File$1>, rootFolder?: string): TreeNode<BarrelData> | null;
34
- }
35
- //#endregion
36
- //#region ../fabric-core/src/composables/useNodeTree.d.ts
37
- type ComponentNode = {
38
- type: string;
39
- props: Record<string, unknown>;
40
- };
41
- declare function useNodeTree(): TreeNode<ComponentNode> | null;
42
- //#endregion
43
- //#region ../fabric-core/src/components/Root.d.ts
44
- type RootProps = {
45
- /**
46
- * Exit (unmount) the whole app.
47
- */
48
- onExit: (error?: Error) => void;
49
- /**
50
- * Error hook receiving runtime exceptions.
51
- */
52
- onError: (error: Error) => void;
53
- /**
54
- * TreeNode representing the tree structure of the app.
55
- */
56
- treeNode: TreeNode<ComponentNode>;
57
- /**
58
- * FileManager instance for managing files within the app.
59
- */
60
- fileManager: FileManager;
61
- /**
62
- * Children nodes.
63
- */
64
- children?: string | (() => string | Array<string> | undefined);
65
- };
66
- /**
67
- * This component provides the root behavior for the Fabric runtime.
68
- */
69
- declare function Root({
70
- onError,
71
- onExit,
72
- treeNode,
73
- fileManager,
74
- children
75
- }: RootProps): string;
76
- declare namespace Root {
77
- var displayName: string;
78
- }
79
- //#endregion
80
- //#region ../fabric-core/src/components/Text.d.ts
81
- type Props$2 = {
82
- /**
83
- * Children nodes.
84
- */
85
- children?: string | (() => string | Array<string> | undefined);
86
- };
87
- /**
88
- * Generates a text node from string or function returning string/array of strings.
89
- */
90
- declare function Text({
91
- children
92
- }: Props$2): string;
93
- //#endregion
94
- //#region ../fabric-core/src/contexts/AppContext.d.ts
95
- type AppContextProps<TMeta extends object = object> = {
96
- /**
97
- * Exit (unmount)
98
- */
99
- exit: (error?: Error) => void;
100
- meta: TMeta;
101
- };
102
- /**
103
- * Provides app-level metadata and lifecycle hooks (like `exit`) to
104
- * components and composables within a Fabric runtime.
105
- */
106
- declare const AppContext: Context<AppContextProps<object>>;
107
- //#endregion
108
- //#region ../fabric-core/src/composables/useApp.d.ts
109
- /**
110
- * `useApp` will return the current App with meta and exit function.
111
- *
112
- * Throws an error when there is no AppContext available.
113
- */
114
- declare function useApp<TMeta extends object = object>(): AppContextProps<TMeta>;
115
- //#endregion
116
- //#region ../fabric-core/src/context.d.ts
117
- /**
118
- * Context type that carries type information about its value
119
- * This is a branded symbol type that enables type-safe context usage
120
- */
121
- type Context<T> = symbol & {
122
- readonly __type: T;
123
- };
124
- /**
125
- * Provides a value to descendant components (Vue 3 style)
126
- *
127
- * @example
128
- * ```ts
129
- * const ThemeKey = Symbol('theme')
130
- * provide(ThemeKey, { color: 'blue' })
131
- * ```
132
- */
133
- declare function provide<T>(key: symbol | Context<T>, value: T): void;
134
- /**
135
- * Injects a value provided by an ancestor component (Vue 3 style)
136
- *
137
- * @example
138
- * ```ts
139
- * const theme = inject(ThemeKey, { color: 'default' })
140
- * ```
141
- */
142
- declare function inject<T>(key: symbol | Context<T>, defaultValue?: T): T;
143
- /**
144
- * Unprovides a value (for cleanup)
145
- * @internal
146
- */
147
- declare function unprovide<T>(key: symbol | Context<T>): void;
148
- //#endregion
149
- //#region ../fabric-core/src/composables/useFile.d.ts
150
- /**
151
- * `useFile` will return the current FileCollector for registering files.
152
- *
153
- * Throws when no FileCollector is present in context — ensure a Fabric that
154
- * provides a FileCollector is mounted before calling this hook.
155
- */
156
- declare function useFile(): ResolvedFile | null;
157
- //#endregion
158
- //#region ../fabric-core/src/composables/useFileManager.d.ts
159
- declare function useFileManager(): FileManager;
160
- //#endregion
161
- //#region ../fabric-core/src/contexts/FileContext.d.ts
162
- /**
163
- * Provides app-level metadata and lifecycle hooks (like `exit`) to
164
- * components and composables within a Fabric runtime.
165
- */
166
- declare const FileContext: Context<ResolvedFile<object> | null>;
167
- //#endregion
168
- //#region ../fabric-core/src/contexts/NodeTreeContext.d.ts
169
- /**
170
- * Context for having the current NodeTree
171
- */
172
- declare const NodeTreeContext: Context<TreeNode<ComponentNode> | null>;
173
- //#endregion
174
- //#region ../fabric-core/src/createFabric.d.ts
175
- /**
176
- * Creates a new Fabric instance
177
- *
178
- * @example
179
- * const fabric = createFabric()
180
- * fabric.use(myPlugin())
181
- */
182
- declare function createFabric<T extends FabricOptions>(config?: FabricConfig<T>): Fabric<T>;
183
- //#endregion
184
- //#region ../fabric-core/src/createFile.d.ts
185
- /**
186
- * Helper to create a file with name and id set
187
- */
188
- declare function createFile<TMeta extends object = object>(file: File$1<TMeta>): ResolvedFile<TMeta>;
189
- //#endregion
190
- //#region ../fabric-core/src/utils/createJSDoc.d.ts
191
- /**
192
- * Create JSDoc comment block from comments array
193
- */
194
- declare function createJSDoc({
195
- comments
196
- }: {
197
- comments: string[];
198
- }): string;
199
- //#endregion
200
- //#region ../fabric-core/src/utils/getRelativePath.d.ts
201
- declare function getRelativePath(rootDir?: string | null, filePath?: string | null, platform?: 'windows' | 'mac' | 'linux'): string;
202
- //#endregion
203
- //#region src/components/App.d.ts
204
- type AppProps<TMeta extends object = object> = {
205
- /**
206
- * Metadata associated with the App.
207
- */
208
- meta?: TMeta;
209
- /**
210
- * Children nodes.
211
- */
212
- children?: KubbNode;
213
- };
214
- /**
215
- * App container containing the AppContext carrying `meta` and an `exit` hook.
216
- */
217
- declare function App<TMeta extends object = object>({
218
- children,
219
- ...props
220
- }: AppProps<TMeta>): react3.ReactNode;
221
- declare namespace App {
222
- var displayName: string;
223
- }
224
- //#endregion
225
- //#region src/components/Const.d.ts
226
- type ConstProps = {
227
- key?: Key;
228
- /**
229
- * Name of the const
230
- */
231
- name: string;
232
- /**
233
- * Does this type need to be exported.
234
- */
235
- export?: boolean;
236
- /**
237
- * Type to make the const being typed
238
- */
239
- type?: string;
240
- /**
241
- * Options for JSdocs.
242
- */
243
- JSDoc?: JSDoc;
244
- /**
245
- * Use of `const` assertions
246
- */
247
- asConst?: boolean;
248
- /**
249
- * Children nodes.
250
- */
251
- children?: KubbNode;
252
- };
253
- /**
254
- * Generates a TypeScript constant declaration.
255
- */
256
- declare function Const({
257
- children,
258
- ...props
259
- }: ConstProps): react3.JSX.Element;
260
- declare namespace Const {
261
- var displayName: string;
262
- }
263
- //#endregion
264
- //#region src/components/File.d.ts
265
- type BasePropsWithBaseName = {
266
- /**
267
- * Name to be used to dynamicly create the baseName(based on input.path).
268
- * Based on UNIX basename
269
- * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
270
- */
271
- baseName: BaseName;
272
- /**
273
- * Path will be full qualified path to a specified file.
274
- */
275
- path: Path;
276
- };
277
- type BasePropsWithoutBaseName = {
278
- baseName?: never;
279
- /**
280
- * Path will be full qualified path to a specified file.
281
- */
282
- path?: Path;
283
- };
284
- type BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName;
285
- type Props$1<TMeta> = BaseProps & {
286
- key?: Key;
287
- meta?: TMeta;
288
- banner?: string;
289
- footer?: string;
290
- children?: KubbNode;
291
- };
292
- /**
293
- * Adds files to the FileManager
294
- */
295
- declare function File<TMeta extends object = object>({
296
- children,
297
- ...props
298
- }: Props$1<TMeta>): react3.JSX.Element;
299
- declare namespace File {
300
- var displayName: string;
301
- var Export: typeof FileExport;
302
- var Import: typeof FileImport;
303
- var Source: typeof FileSource;
304
- }
305
- type FileSourceProps = Omit<Source, 'value'> & {
306
- key?: Key;
307
- children?: KubbNode;
308
- };
309
- /**
310
- * File.Source
311
- *
312
- * Marks a block of source text to be associated with the current file when
313
- * rendering with the FileCollector. Children are treated as the source string.
314
- */
315
- declare function FileSource({
316
- children,
317
- ...props
318
- }: FileSourceProps): react3.JSX.Element;
319
- declare namespace FileSource {
320
- var displayName: string;
321
- }
322
- type FileExportProps = Export & {
323
- key?: Key;
324
- };
325
- /**
326
- * File.Export
327
- *
328
- * Declares an export entry for the current file. This will be collected by
329
- * the FileCollector for later emission.
330
- */
331
- declare function FileExport(props: FileExportProps): react3.JSX.Element;
332
- declare namespace FileExport {
333
- var displayName: string;
334
- }
335
- type FileImportProps = Import & {
336
- key?: Key;
337
- };
338
- /**
339
- * File.Import
340
- *
341
- * Declares an import entry for the current file.
342
- */
343
- declare function FileImport(props: FileImportProps): react3.JSX.Element;
344
- declare namespace FileImport {
345
- var displayName: string;
346
- }
347
- //#endregion
348
- //#region src/components/Function.d.ts
349
- type Props = {
350
- key?: Key;
351
- /**
352
- * Name of the function.
353
- */
354
- name: string;
355
- /**
356
- * Add default when export is being used
357
- */
358
- default?: boolean;
359
- /**
360
- * Parameters/options/props that need to be used.
361
- */
362
- params?: string;
363
- /**
364
- * Does this function need to be exported.
365
- */
366
- export?: boolean;
367
- /**
368
- * Does the function has async/promise behaviour.
369
- * This will also add `Promise<returnType>` as the returnType.
370
- */
371
- async?: boolean;
372
- /**
373
- * Generics that needs to be added for TypeScript.
374
- */
375
- generics?: string | string[];
376
- /**
377
- * ReturnType(see async for adding Promise type).
378
- */
379
- returnType?: string;
380
- /**
381
- * Options for JSdocs.
382
- */
383
- JSDoc?: JSDoc;
384
- /**
385
- * Children nodes.
386
- */
387
- children?: string;
388
- };
389
- /**
390
- * Generates a TypeScript function declaration.
391
- */
392
- declare function Function({
393
- children,
394
- ...props
395
- }: Props): react3.JSX.Element;
396
- declare namespace Function {
397
- var displayName: string;
398
- var Arrow: typeof ArrowFunction;
399
- }
400
- type ArrowFunctionProps = Props & {
401
- /**
402
- * Create Arrow function in one line
403
- */
404
- singleLine?: boolean;
405
- };
406
- /**
407
- * ArrowFunction
408
- *
409
- * Renders an arrow function definition. Supports the same flags as `Function`.
410
- * Use `singleLine` to render the body as a single-line expression.
411
- */
412
- declare function ArrowFunction({
413
- children,
414
- ...props
415
- }: ArrowFunctionProps): react3.JSX.Element;
416
- declare namespace ArrowFunction {
417
- var displayName: string;
418
- }
419
- //#endregion
420
- //#region src/components/Indent.d.ts
421
- type IndentProps = {
422
- size?: number;
423
- children?: React.ReactNode;
424
- };
425
- /**
426
- * Indents all children by `size` spaces.
427
- * Collapses consecutive <br /> tags to at most 2.
428
- *
429
- * Indent will dedent and re-indent string children and will prefix
430
- * non-string children with the requested number of spaces.
431
- */
432
- declare function Indent({
433
- size,
434
- children
435
- }: IndentProps): React.JSX.Element | null;
436
- //#endregion
437
- //#region src/components/Type.d.ts
438
- type TypeProps = {
439
- key?: Key;
440
- /**
441
- * Name of the type, this needs to start with a capital letter.
442
- */
443
- name: string;
444
- /**
445
- * Does this type need to be exported.
446
- */
447
- export?: boolean;
448
- /**
449
- * Options for JSdocs.
450
- */
451
- JSDoc?: JSDoc;
452
- /**
453
- * Children nodes.
454
- */
455
- children?: KubbNode;
456
- };
457
- /**
458
- * Generates a TypeScript type declaration.
459
- */
460
- declare function Type({
461
- children,
462
- ...props
463
- }: TypeProps): react3.JSX.Element;
464
- declare namespace Type {
465
- var displayName: string;
466
- }
467
- //#endregion
468
- //#region src/composables/useLifecycle.d.ts
469
- /**
470
- * Provides lifecycle helpers that integrate with the Fabric runtime. The
471
- * `exit` helper schedules a call to the RootContext exit function on the
472
- * next tick to allow React to complete its render cycle first.
473
- */
474
- declare function useLifecycle(): {
475
- exit: () => void;
476
- };
477
- //#endregion
478
- //#region src/plugins/reactPlugin.d.ts
479
- type Options$2 = {
480
- stdout?: NodeJS.WriteStream;
481
- stdin?: NodeJS.ReadStream;
482
- stderr?: NodeJS.WriteStream;
483
- /**
484
- * Set this to true to always see the result of the render in the console(line per render)
485
- */
486
- debug?: boolean;
487
- };
488
- type ExtendOptions = {
489
- render(App: KubbElement | ElementType): Promise<void>;
490
- renderToString(App: KubbElement | ElementType): Promise<string>;
491
- waitUntilExit(): Promise<void>;
492
- };
493
- declare global {
494
- namespace Kubb {
495
- interface Fabric {
496
- render(App: KubbElement | ElementType): Promise<void>;
497
- renderToString(App: KubbElement | ElementType): Promise<string>;
498
- waitUntilExit(): Promise<void>;
499
- }
500
- }
501
- }
502
- declare const reactPlugin: Plugin<Options$2, ExtendOptions>;
503
- //#endregion
504
- //#region src/createReactFabric.d.ts
505
- declare function createReactFabric(config?: FabricConfig<Options$2 & {
506
- mode?: FabricMode;
507
- devtools?: boolean;
508
- }>): Fabric<Options$2 & {
509
- mode?: FabricMode;
510
- devtools?: boolean;
511
- }>;
512
- //#endregion
513
- //#region src/Runtime.d.ts
514
- type Options$1 = {
515
- fileManager: FileManager;
516
- stdout?: NodeJS.WriteStream;
517
- stdin?: NodeJS.ReadStream;
518
- stderr?: NodeJS.WriteStream;
519
- /**
520
- * Set this to true to always see the result of the render in the console(line per render)
521
- */
522
- debug?: boolean;
523
- };
524
- declare class Runtime {
525
- #private;
526
- exitPromise?: Promise<void>;
527
- constructor(options: Options$1);
528
- get fileManager(): FileManager;
529
- resolveExitPromise: () => void;
530
- rejectExitPromise: (reason?: Error) => void;
531
- unsubscribeExit: () => void;
532
- onRender: () => Promise<void>;
533
- onError(error: Error): void;
534
- onExit(error?: Error): void;
535
- render(node: ReactNode): Promise<void>;
536
- renderToString(node: ReactNode): Promise<string>;
537
- unmount(error?: Error | number | null): void;
538
- waitUntilExit(): Promise<void>;
539
- }
540
- //#endregion
541
- //#region src/utils/getFunctionParams.d.ts
542
- type Param = {
543
- /**
544
- * `object` will return the pathParams as an object.
545
- *
546
- * `inline` will return the pathParams as comma separated params.
547
- * @default `'inline'`
548
- * @private
549
- */
550
- mode?: 'object' | 'inline' | 'inlineSpread';
551
- type?: 'string' | 'number' | (string & {});
552
- optional?: boolean;
553
- /**
554
- * @example test = "default"
555
- */
556
- default?: string;
557
- /**
558
- * Used for no TypeScript(with mode object)
559
- * @example test: "default"
560
- */
561
- value?: string;
562
- children?: Params;
563
- };
564
- type Params = Record<string, Param | undefined>;
565
- type Options = {
566
- type: 'constructor' | 'call' | 'object' | 'objectValue';
567
- transformName?: (name: string) => string;
568
- transformType?: (type: string) => string;
569
- };
570
- declare function createFunctionParams(params: Params): Params;
571
- declare class FunctionParams {
572
- #private;
573
- static factory(params: Params): FunctionParams;
574
- constructor(params: Params);
575
- get params(): Params;
576
- get flatParams(): Params;
577
- toCall({
578
- transformName,
579
- transformType
580
- }?: Pick<Options, 'transformName' | 'transformType'>): string;
581
- toObject(): string;
582
- toObjectValue(): string;
583
- toConstructor(): string;
584
- }
585
- //#endregion
586
- //#region src/index.d.ts
587
- declare const useState: typeof react3.useState;
588
- declare const createContext: typeof react3.createContext;
589
- declare const createElement: typeof react3.createElement;
590
- declare const Fragment: react3.ExoticComponent<react3.FragmentProps>;
591
- declare const use: typeof react3.use;
592
- declare const useContext: typeof react3.useContext;
593
- declare const useEffect: typeof react3.useEffect;
594
- declare const useReducer: typeof react3.useReducer;
595
- declare const useRef: typeof react3.useRef;
596
- //#endregion
597
- //#region ../fabric-core/src/contexts/RootContext.d.ts
598
- type RootContextProps = {
599
- /**
600
- * Exit (unmount) the whole app.
601
- */
602
- exit: (error?: Error) => void;
603
- /**
604
- * TreeNode representing the tree structure of the app.
605
- */
606
- treeNode: TreeNode<ComponentNode>;
607
- /**
608
- * FileManager instance for managing files within the app.
609
- */
610
- fileManager: FileManager;
611
- };
612
- /**
613
- * Context providing root-level functionalities such as exit hook, tree node structure, and file management.
614
- * Define in the `render` helper of the runtime.
615
- */
616
- declare const RootContext: Context<RootContextProps>;
617
- //#endregion
618
- //#region ../fabric-core/src/types.d.ts
619
- type JSDoc = {
620
- comments: string[];
621
- };
622
- //#endregion
623
- //#region src/types.d.ts
624
- type ReactElementNames = 'br' | 'div';
625
- type ElementNames = ReactElementNames | 'kubb-text' | 'kubb-file' | 'kubb-source' | 'kubb-import' | 'kubb-export' | 'kubb-root' | 'kubb-app';
626
- type Node = {
627
- parentNode: DOMElement | undefined;
628
- internal_static?: boolean;
629
- };
630
- type DOMNodeAttribute = boolean | string | number;
631
- type TextName = '#text';
632
- type TextNode = {
633
- nodeName: TextName;
634
- nodeValue: string;
635
- } & Node;
636
- type DOMNode<T = {
637
- nodeName: NodeNames;
638
- }> = T extends {
639
- nodeName: infer U;
640
- } ? U extends '#text' ? TextNode : DOMElement : never;
641
- type OutputTransformer = (s: string, index: number) => string;
642
- type DOMElement = {
643
- nodeName: ElementNames;
644
- attributes: Map<string, DOMNodeAttribute>;
645
- childNodes: DOMNode[];
646
- internal_transform?: OutputTransformer;
647
- isStaticDirty?: boolean;
648
- staticNode?: DOMElement;
649
- onComputeLayout?: () => void;
650
- onRender?: () => void;
651
- onImmediateRender?: () => void;
652
- } & Node;
653
- type NodeNames = ElementNames | TextName;
654
- type KubbNode = ReactNode;
655
- type KubbElement = JSX.Element;
656
- type KubbTextProps = {
657
- children?: KubbNode;
658
- };
659
- type KubbFileProps = {
660
- id?: string;
661
- children?: KubbNode;
662
- baseName: string;
663
- path: string;
664
- override?: boolean;
665
- meta?: File$1['meta'];
666
- };
667
- type KubbSourceProps = Source & {
668
- children?: KubbNode;
669
- };
670
- type KubbImportProps = Import;
671
- type KubbExportProps = Export;
672
- type LineBreakProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
673
- //#endregion
674
- export { useApp as $, createFunctionParams as A, App as B, useEffect as C, FunctionParams as D, useState as E, Type as F, NodeTreeContext as G, createJSDoc as H, Indent as I, useFile as J, FileContext as K, Function as L, createReactFabric as M, reactPlugin as N, Param as O, useLifecycle as P, unprovide as Q, File as R, useContext as S, useRef as T, createFile as U, getRelativePath as V, createFabric as W, inject as X, Context as Y, provide as Z, RootContextProps as _, Key as a, TreeNode as at, createElement as b, KubbFileProps as c, KubbSourceProps as d, AppContext as et, KubbTextProps as f, RootContext as g, JSDoc as h, ElementNames as i, useNodeTree as it, Runtime as j, Params as k, KubbImportProps as l, TextNode as m, DOMNode as n, Root as nt, KubbElement as o, LineBreakProps as p, useFileManager as q, DOMNodeAttribute as r, ComponentNode as rt, KubbExportProps as s, DOMElement as t, Text as tt, KubbNode as u, Fragment as v, useReducer as w, use as x, createContext as y, Const as z };
675
- //# sourceMappingURL=types-C3ODUOKN.d.cts.map