@kubb/react-fabric 0.0.0 → 0.1.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 (50) hide show
  1. package/dist/devtools.cjs +154 -85
  2. package/dist/devtools.cjs.map +1 -1
  3. package/dist/devtools.js +154 -85
  4. package/dist/devtools.js.map +1 -1
  5. package/dist/{globals-C6rGETh5.d.ts → globals-BQ_tJj2b.d.ts} +3 -3
  6. package/dist/{globals-CnATk-Sl.d.cts → globals-C-9ezLk9.d.cts} +3 -3
  7. package/dist/globals.d.cts +2 -2
  8. package/dist/globals.d.ts +2 -2
  9. package/dist/index.cjs +47 -73
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +63 -52
  12. package/dist/index.d.ts +63 -52
  13. package/dist/index.js +47 -72
  14. package/dist/index.js.map +1 -1
  15. package/dist/jsx-runtime.cjs +15 -7
  16. package/dist/jsx-runtime.cjs.map +1 -0
  17. package/dist/{jsx-dev-runtime.d.ts → jsx-runtime.d.cts} +3 -3
  18. package/dist/{jsx-dev-runtime.d.cts → jsx-runtime.d.ts} +3 -3
  19. package/dist/jsx-runtime.js +12 -4
  20. package/dist/jsx-runtime.js.map +1 -0
  21. package/dist/{types-C3p0Ljxf.d.cts → types-CUKR3KZn.d.cts} +1 -1
  22. package/dist/{types-DEroxUW0.d.ts → types-D9OfSq91.d.ts} +1 -1
  23. package/dist/types.d.cts +1 -1
  24. package/dist/types.d.ts +1 -1
  25. package/package.json +9 -7
  26. package/src/ReactTemplate.tsx +22 -24
  27. package/src/components/Const.tsx +4 -17
  28. package/src/components/File.tsx +1 -1
  29. package/src/components/Function.tsx +6 -38
  30. package/src/components/Root.tsx +5 -9
  31. package/src/components/Type.tsx +1 -7
  32. package/src/{hooks → composables}/useApp.ts +2 -2
  33. package/src/createApp.ts +4 -9
  34. package/src/dom.ts +5 -3
  35. package/src/globals.ts +1 -1
  36. package/src/index.ts +3 -4
  37. package/src/utils/processFiles.ts +1 -1
  38. package/src/utils/squashExportNodes.ts +1 -1
  39. package/src/utils/squashImportNodes.ts +1 -1
  40. package/src/utils/squashSourceNodes.ts +1 -1
  41. package/dist/jsx-dev-runtime.cjs +0 -9
  42. package/dist/jsx-dev-runtime.js +0 -6
  43. package/dist/jsx-runtime-DmD5u6a-.js +0 -13
  44. package/dist/jsx-runtime-DmD5u6a-.js.map +0 -1
  45. package/dist/jsx-runtime-zKfRQHQD.cjs +0 -36
  46. package/dist/jsx-runtime-zKfRQHQD.cjs.map +0 -1
  47. package/src/components/Text.tsx +0 -31
  48. package/src/utils/throttle.ts +0 -30
  49. /package/src/{hooks → composables}/useFile.ts +0 -0
  50. /package/src/{hooks → composables}/useLifecycle.tsx +0 -0
package/dist/index.d.cts CHANGED
@@ -1,9 +1,29 @@
1
- import { a as Import, c as Source, i as File$1, n as Export, o as Path, r as Extname, s as ResolvedFile, t as BaseName } from "./globals-CnATk-Sl.cjs";
2
- import { a as JSDoc, f as createFunctionParams, l as FunctionParams, o as Key, s as KubbNode } from "./types-C3p0Ljxf.cjs";
1
+ import { a as Import, c as Source, i as File$1, n as Export, o as Path, r as Extname, s as ResolvedFile, t as BaseName } from "./globals-C-9ezLk9.cjs";
2
+ import { a as JSDoc, f as createFunctionParams, l as FunctionParams, o as Key, s as KubbNode } from "./types-CUKR3KZn.cjs";
3
3
  import * as react1 from "react";
4
- import React, { ElementType } from "react";
4
+ import React, { ReactNode } from "react";
5
5
  import * as react_jsx_runtime0 from "react/jsx-runtime";
6
6
 
7
+ //#region ../fabric-core/src/FileManager.d.ts
8
+ type WriteFilesProps = {
9
+ extension?: Record<Extname, Extname | ''>;
10
+ dryRun?: boolean;
11
+ };
12
+ declare class FileManager {
13
+ #private;
14
+ constructor();
15
+ add(...files: Array<File$1>): Promise<ResolvedFile<object>[]>;
16
+ flush(): void;
17
+ getByPath(path: Path): ResolvedFile | null;
18
+ deleteByPath(path: Path): void;
19
+ clear(): void;
20
+ getFiles(): Array<ResolvedFile>;
21
+ processFiles({
22
+ dryRun,
23
+ extension
24
+ }: WriteFilesProps): Promise<Array<ResolvedFile>>;
25
+ }
26
+ //#endregion
7
27
  //#region ../fabric-core/src/defineApp.d.ts
8
28
  type Component = any;
9
29
  type PluginInstallFunction<Options$1 = any[]> = Options$1 extends unknown[] ? (app: App$1, ...options: Options$1) => any : (app: App$1, options: Options$1) => any;
@@ -11,22 +31,29 @@ type ObjectPlugin<Options$1 = any[]> = {
11
31
  install: PluginInstallFunction<Options$1>;
12
32
  };
13
33
  type FunctionPlugin<Options$1 = any[]> = PluginInstallFunction<Options$1> & Partial<ObjectPlugin<Options$1>>;
34
+ type AppContext<TOptions = unknown> = {
35
+ options?: TOptions;
36
+ fileManager: FileManager;
37
+ addFile(...files: Array<File$1>): Promise<void>;
38
+ files: Array<ResolvedFile>;
39
+ clear: () => void;
40
+ };
14
41
  type Plugin<Options$1 = any[], P extends unknown[] = (Options$1 extends unknown[] ? Options$1 : [Options$1])> = FunctionPlugin<P> | ObjectPlugin<P>;
15
- interface App$1<_THostElement = unknown> {
42
+ type WriteOptions = {
43
+ extension?: Record<Extname, Extname | ''>;
44
+ dryRun?: boolean;
45
+ };
46
+ interface App$1 {
16
47
  _component: Component;
17
48
  render(): Promise<void>;
18
49
  renderToString(): Promise<string>;
19
50
  getFiles(): Promise<Array<ResolvedFile>>;
20
51
  use<Options>(plugin: Plugin<Options>, options: NoInfer<Options>): this;
21
- write(): Promise<void>;
52
+ write(options?: WriteOptions): Promise<void>;
22
53
  addFile(...files: Array<File$1>): Promise<void>;
23
54
  waitUntilExit(): Promise<void>;
24
55
  }
25
- type DefineOptions = {
26
- extension?: Record<Extname, Extname | ''>;
27
- dryRun?: boolean;
28
- };
29
- type DefineApp<THostElement> = (rootComponent?: Component, options?: DefineOptions) => App$1<THostElement>;
56
+ type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App$1;
30
57
  //#endregion
31
58
  //#region src/components/App.d.ts
32
59
  type AppContextProps<TMeta = unknown> = {
@@ -36,21 +63,21 @@ type AppContextProps<TMeta = unknown> = {
36
63
  readonly exit: (error?: Error) => void;
37
64
  readonly meta: TMeta;
38
65
  };
39
- type Props$5<TMeta = unknown> = {
66
+ type Props$4<TMeta = unknown> = {
40
67
  readonly children?: KubbNode;
41
68
  readonly meta: TMeta;
42
69
  };
43
70
  declare function App<TMeta = unknown>({
44
71
  meta,
45
72
  children
46
- }: Props$5<TMeta>): react_jsx_runtime0.JSX.Element;
73
+ }: Props$4<TMeta>): react_jsx_runtime0.JSX.Element;
47
74
  declare namespace App {
48
75
  var Context: react1.Context<AppContextProps<unknown> | undefined>;
49
76
  var displayName: string;
50
77
  }
51
78
  //#endregion
52
79
  //#region src/components/Const.d.ts
53
- type Props$4 = {
80
+ type Props$3 = {
54
81
  key?: Key;
55
82
  /**
56
83
  * Name of the const
@@ -81,7 +108,7 @@ declare function Const({
81
108
  JSDoc,
82
109
  asConst,
83
110
  children
84
- }: Props$4): react_jsx_runtime0.JSX.Element;
111
+ }: Props$3): react_jsx_runtime0.JSX.Element;
85
112
  declare namespace Const {
86
113
  var displayName: string;
87
114
  }
@@ -120,7 +147,7 @@ type BasePropsWithoutBaseName = {
120
147
  path?: Path;
121
148
  };
122
149
  type BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName;
123
- type Props$3<TMeta> = BaseProps & {
150
+ type Props$2<TMeta> = BaseProps & {
124
151
  key?: Key;
125
152
  meta?: TMeta;
126
153
  banner?: string;
@@ -130,7 +157,7 @@ type Props$3<TMeta> = BaseProps & {
130
157
  declare function File<TMeta extends object = object>({
131
158
  children,
132
159
  ...rest
133
- }: Props$3<TMeta>): react_jsx_runtime0.JSX.Element;
160
+ }: Props$2<TMeta>): react_jsx_runtime0.JSX.Element;
134
161
  declare namespace File {
135
162
  var displayName: string;
136
163
  var Export: typeof FileExport;
@@ -179,7 +206,7 @@ declare namespace FileImport {
179
206
  }
180
207
  //#endregion
181
208
  //#region src/components/Function.d.ts
182
- type Props$2 = {
209
+ type Props$1 = {
183
210
  key?: Key;
184
211
  /**
185
212
  * Name of the function.
@@ -226,12 +253,12 @@ declare function Function({
226
253
  returnType,
227
254
  JSDoc,
228
255
  children
229
- }: Props$2): react_jsx_runtime0.JSX.Element;
256
+ }: Props$1): react_jsx_runtime0.JSX.Element;
230
257
  declare namespace Function {
231
258
  var displayName: string;
232
259
  var Arrow: typeof ArrowFunction;
233
260
  }
234
- type ArrowFunctionProps = Props$2 & {
261
+ type ArrowFunctionProps = Props$1 & {
235
262
  /**
236
263
  * Create Arrow function in one line
237
264
  */
@@ -267,33 +294,6 @@ declare function Indent({
267
294
  children
268
295
  }: IndentProps): react_jsx_runtime0.JSX.Element | null;
269
296
  //#endregion
270
- //#region src/components/Text.d.ts
271
- type Props$1 = {
272
- key?: Key;
273
- /**
274
- * Change the indent.
275
- * @default 0
276
- * @deprecated
277
- */
278
- indentSize?: number;
279
- children?: KubbNode;
280
- };
281
- /**
282
- * @deprecated
283
- */
284
- declare function Text({
285
- children
286
- }: Props$1): react_jsx_runtime0.JSX.Element;
287
- declare namespace Text {
288
- var displayName: string;
289
- var Space: typeof Space;
290
- }
291
- type SpaceProps = {};
292
- declare function Space({}: SpaceProps): react_jsx_runtime0.JSX.Element;
293
- declare namespace Space {
294
- var displayName: string;
295
- }
296
- //#endregion
297
297
  //#region src/components/Type.d.ts
298
298
  type Props = {
299
299
  key?: Key;
@@ -321,22 +321,33 @@ declare namespace Type {
321
321
  var displayName: string;
322
322
  }
323
323
  //#endregion
324
+ //#region src/ReactTemplate.d.ts
325
+ type ReactAppContext = AppContext<{
326
+ stdout?: NodeJS.WriteStream;
327
+ stdin?: NodeJS.ReadStream;
328
+ stderr?: NodeJS.WriteStream;
329
+ /**
330
+ * Set this to true to always see the result of the render in the console(line per render)
331
+ */
332
+ debug?: boolean;
333
+ }>;
334
+ //#endregion
324
335
  //#region src/createApp.d.ts
325
- declare const createApp: DefineApp<ElementType>;
336
+ declare const createApp: DefineApp<ReactAppContext>;
326
337
  //#endregion
327
- //#region src/hooks/useApp.d.ts
338
+ //#region src/composables/useApp.d.ts
328
339
  /**
329
340
  * `useApp` will return the current App with plugin, pluginManager, fileManager and mode.
330
341
  */
331
- declare function useApp(): AppContextProps;
342
+ declare function useApp<TMeta = unknown>(): AppContextProps<TMeta>;
332
343
  //#endregion
333
- //#region src/hooks/useFile.d.ts
344
+ //#region src/composables/useFile.d.ts
334
345
  /**
335
346
  * `useFile` will return the current file when <File/> is used.
336
347
  */
337
348
  declare function useFile(): FileContextProps;
338
349
  //#endregion
339
- //#region src/hooks/useLifecycle.d.ts
350
+ //#region src/composables/useLifecycle.d.ts
340
351
  /**
341
352
  * `useLifecycle` will return some helpers to exit/restart the generation.
342
353
  */
@@ -354,5 +365,5 @@ declare const useRef: typeof react1.useRef;
354
365
  declare const use: typeof react1.use;
355
366
  declare const useReducer: typeof react1.useReducer;
356
367
  //#endregion
357
- export { App, Const, File, Function, FunctionParams, Indent, Text, Type, createApp, createContext, createElement, createFunctionParams, use, useApp, useContext, useEffect, useFile, useLifecycle, useReducer, useRef, useState };
368
+ export { App, Const, File, Function, FunctionParams, Indent, Type, createApp, createContext, createElement, createFunctionParams, use, useApp, useContext, useEffect, useFile, useLifecycle, useReducer, useRef, useState };
358
369
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,9 +1,29 @@
1
- import { a as Import, c as Source, i as File$1, n as Export, o as Path, r as Extname, s as ResolvedFile, t as BaseName } from "./globals-C6rGETh5.js";
2
- import { a as JSDoc, f as createFunctionParams, l as FunctionParams, o as Key, s as KubbNode } from "./types-DEroxUW0.js";
1
+ import { a as Import, c as Source, i as File$1, n as Export, o as Path, r as Extname, s as ResolvedFile, t as BaseName } from "./globals-BQ_tJj2b.js";
2
+ import { a as JSDoc, f as createFunctionParams, l as FunctionParams, o as Key, s as KubbNode } from "./types-D9OfSq91.js";
3
3
  import * as react1 from "react";
4
- import React, { ElementType } from "react";
4
+ import React, { ReactNode } from "react";
5
5
  import * as react_jsx_runtime0 from "react/jsx-runtime";
6
6
 
7
+ //#region ../fabric-core/src/FileManager.d.ts
8
+ type WriteFilesProps = {
9
+ extension?: Record<Extname, Extname | ''>;
10
+ dryRun?: boolean;
11
+ };
12
+ declare class FileManager {
13
+ #private;
14
+ constructor();
15
+ add(...files: Array<File$1>): Promise<ResolvedFile<object>[]>;
16
+ flush(): void;
17
+ getByPath(path: Path): ResolvedFile | null;
18
+ deleteByPath(path: Path): void;
19
+ clear(): void;
20
+ getFiles(): Array<ResolvedFile>;
21
+ processFiles({
22
+ dryRun,
23
+ extension
24
+ }: WriteFilesProps): Promise<Array<ResolvedFile>>;
25
+ }
26
+ //#endregion
7
27
  //#region ../fabric-core/src/defineApp.d.ts
8
28
  type Component = any;
9
29
  type PluginInstallFunction<Options$1 = any[]> = Options$1 extends unknown[] ? (app: App$1, ...options: Options$1) => any : (app: App$1, options: Options$1) => any;
@@ -11,22 +31,29 @@ type ObjectPlugin<Options$1 = any[]> = {
11
31
  install: PluginInstallFunction<Options$1>;
12
32
  };
13
33
  type FunctionPlugin<Options$1 = any[]> = PluginInstallFunction<Options$1> & Partial<ObjectPlugin<Options$1>>;
34
+ type AppContext<TOptions = unknown> = {
35
+ options?: TOptions;
36
+ fileManager: FileManager;
37
+ addFile(...files: Array<File$1>): Promise<void>;
38
+ files: Array<ResolvedFile>;
39
+ clear: () => void;
40
+ };
14
41
  type Plugin<Options$1 = any[], P extends unknown[] = (Options$1 extends unknown[] ? Options$1 : [Options$1])> = FunctionPlugin<P> | ObjectPlugin<P>;
15
- interface App$1<_THostElement = unknown> {
42
+ type WriteOptions = {
43
+ extension?: Record<Extname, Extname | ''>;
44
+ dryRun?: boolean;
45
+ };
46
+ interface App$1 {
16
47
  _component: Component;
17
48
  render(): Promise<void>;
18
49
  renderToString(): Promise<string>;
19
50
  getFiles(): Promise<Array<ResolvedFile>>;
20
51
  use<Options>(plugin: Plugin<Options>, options: NoInfer<Options>): this;
21
- write(): Promise<void>;
52
+ write(options?: WriteOptions): Promise<void>;
22
53
  addFile(...files: Array<File$1>): Promise<void>;
23
54
  waitUntilExit(): Promise<void>;
24
55
  }
25
- type DefineOptions = {
26
- extension?: Record<Extname, Extname | ''>;
27
- dryRun?: boolean;
28
- };
29
- type DefineApp<THostElement> = (rootComponent?: Component, options?: DefineOptions) => App$1<THostElement>;
56
+ type DefineApp<TContext extends AppContext> = (rootComponent?: Component, options?: TContext['options']) => App$1;
30
57
  //#endregion
31
58
  //#region src/components/App.d.ts
32
59
  type AppContextProps<TMeta = unknown> = {
@@ -36,21 +63,21 @@ type AppContextProps<TMeta = unknown> = {
36
63
  readonly exit: (error?: Error) => void;
37
64
  readonly meta: TMeta;
38
65
  };
39
- type Props$5<TMeta = unknown> = {
66
+ type Props$4<TMeta = unknown> = {
40
67
  readonly children?: KubbNode;
41
68
  readonly meta: TMeta;
42
69
  };
43
70
  declare function App<TMeta = unknown>({
44
71
  meta,
45
72
  children
46
- }: Props$5<TMeta>): react_jsx_runtime0.JSX.Element;
73
+ }: Props$4<TMeta>): react_jsx_runtime0.JSX.Element;
47
74
  declare namespace App {
48
75
  var Context: react1.Context<AppContextProps<unknown> | undefined>;
49
76
  var displayName: string;
50
77
  }
51
78
  //#endregion
52
79
  //#region src/components/Const.d.ts
53
- type Props$4 = {
80
+ type Props$3 = {
54
81
  key?: Key;
55
82
  /**
56
83
  * Name of the const
@@ -81,7 +108,7 @@ declare function Const({
81
108
  JSDoc,
82
109
  asConst,
83
110
  children
84
- }: Props$4): react_jsx_runtime0.JSX.Element;
111
+ }: Props$3): react_jsx_runtime0.JSX.Element;
85
112
  declare namespace Const {
86
113
  var displayName: string;
87
114
  }
@@ -120,7 +147,7 @@ type BasePropsWithoutBaseName = {
120
147
  path?: Path;
121
148
  };
122
149
  type BaseProps = BasePropsWithBaseName | BasePropsWithoutBaseName;
123
- type Props$3<TMeta> = BaseProps & {
150
+ type Props$2<TMeta> = BaseProps & {
124
151
  key?: Key;
125
152
  meta?: TMeta;
126
153
  banner?: string;
@@ -130,7 +157,7 @@ type Props$3<TMeta> = BaseProps & {
130
157
  declare function File<TMeta extends object = object>({
131
158
  children,
132
159
  ...rest
133
- }: Props$3<TMeta>): react_jsx_runtime0.JSX.Element;
160
+ }: Props$2<TMeta>): react_jsx_runtime0.JSX.Element;
134
161
  declare namespace File {
135
162
  var displayName: string;
136
163
  var Export: typeof FileExport;
@@ -179,7 +206,7 @@ declare namespace FileImport {
179
206
  }
180
207
  //#endregion
181
208
  //#region src/components/Function.d.ts
182
- type Props$2 = {
209
+ type Props$1 = {
183
210
  key?: Key;
184
211
  /**
185
212
  * Name of the function.
@@ -226,12 +253,12 @@ declare function Function({
226
253
  returnType,
227
254
  JSDoc,
228
255
  children
229
- }: Props$2): react_jsx_runtime0.JSX.Element;
256
+ }: Props$1): react_jsx_runtime0.JSX.Element;
230
257
  declare namespace Function {
231
258
  var displayName: string;
232
259
  var Arrow: typeof ArrowFunction;
233
260
  }
234
- type ArrowFunctionProps = Props$2 & {
261
+ type ArrowFunctionProps = Props$1 & {
235
262
  /**
236
263
  * Create Arrow function in one line
237
264
  */
@@ -267,33 +294,6 @@ declare function Indent({
267
294
  children
268
295
  }: IndentProps): react_jsx_runtime0.JSX.Element | null;
269
296
  //#endregion
270
- //#region src/components/Text.d.ts
271
- type Props$1 = {
272
- key?: Key;
273
- /**
274
- * Change the indent.
275
- * @default 0
276
- * @deprecated
277
- */
278
- indentSize?: number;
279
- children?: KubbNode;
280
- };
281
- /**
282
- * @deprecated
283
- */
284
- declare function Text({
285
- children
286
- }: Props$1): react_jsx_runtime0.JSX.Element;
287
- declare namespace Text {
288
- var displayName: string;
289
- var Space: typeof Space;
290
- }
291
- type SpaceProps = {};
292
- declare function Space({}: SpaceProps): react_jsx_runtime0.JSX.Element;
293
- declare namespace Space {
294
- var displayName: string;
295
- }
296
- //#endregion
297
297
  //#region src/components/Type.d.ts
298
298
  type Props = {
299
299
  key?: Key;
@@ -321,22 +321,33 @@ declare namespace Type {
321
321
  var displayName: string;
322
322
  }
323
323
  //#endregion
324
+ //#region src/ReactTemplate.d.ts
325
+ type ReactAppContext = AppContext<{
326
+ stdout?: NodeJS.WriteStream;
327
+ stdin?: NodeJS.ReadStream;
328
+ stderr?: NodeJS.WriteStream;
329
+ /**
330
+ * Set this to true to always see the result of the render in the console(line per render)
331
+ */
332
+ debug?: boolean;
333
+ }>;
334
+ //#endregion
324
335
  //#region src/createApp.d.ts
325
- declare const createApp: DefineApp<ElementType>;
336
+ declare const createApp: DefineApp<ReactAppContext>;
326
337
  //#endregion
327
- //#region src/hooks/useApp.d.ts
338
+ //#region src/composables/useApp.d.ts
328
339
  /**
329
340
  * `useApp` will return the current App with plugin, pluginManager, fileManager and mode.
330
341
  */
331
- declare function useApp(): AppContextProps;
342
+ declare function useApp<TMeta = unknown>(): AppContextProps<TMeta>;
332
343
  //#endregion
333
- //#region src/hooks/useFile.d.ts
344
+ //#region src/composables/useFile.d.ts
334
345
  /**
335
346
  * `useFile` will return the current file when <File/> is used.
336
347
  */
337
348
  declare function useFile(): FileContextProps;
338
349
  //#endregion
339
- //#region src/hooks/useLifecycle.d.ts
350
+ //#region src/composables/useLifecycle.d.ts
340
351
  /**
341
352
  * `useLifecycle` will return some helpers to exit/restart the generation.
342
353
  */
@@ -354,5 +365,5 @@ declare const useRef: typeof react1.useRef;
354
365
  declare const use: typeof react1.use;
355
366
  declare const useReducer: typeof react1.useReducer;
356
367
  //#endregion
357
- export { App, Const, File, Function, FunctionParams, Indent, Text, Type, createApp, createContext, createElement, createFunctionParams, use, useApp, useContext, useEffect, useFile, useLifecycle, useReducer, useRef, useState };
368
+ export { App, Const, File, Function, FunctionParams, Indent, Type, createApp, createContext, createElement, createFunctionParams, use, useApp, useContext, useEffect, useFile, useLifecycle, useReducer, useRef, useState };
358
369
  //# sourceMappingURL=index.d.ts.map