@kubb/react-fabric 0.1.4 → 0.1.6

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,24 +1,24 @@
1
1
  import { i as File, o as Path, r as Extname, s as ResolvedFile } from "./KubbFile-FGXV713i.cjs";
2
2
 
3
3
  //#region ../fabric-core/src/plugins/types.d.ts
4
- type Plugin<TOptions = any[], TAppExtension$1 extends Record<string, any> = {}> = {
4
+ type Plugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = {
5
5
  name: string;
6
6
  type: 'plugin';
7
- scope?: 'write' | 'read' | (string & {});
8
- install: Install<TOptions> | Promise<Install<TOptions>>;
7
+ install: Install<TOptions>;
9
8
  /**
10
9
  * Runtime app overrides or extensions.
11
10
  * Merged into the app instance after install.
11
+ * This cannot be async
12
12
  */
13
13
  inject?: Inject<TOptions, TAppExtension$1>;
14
14
  };
15
- type UserPlugin<TOptions = any[], TAppExtension$1 extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension$1>, 'type'>;
15
+ type UserPlugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension$1>, 'type'>;
16
16
  //#endregion
17
17
  //#region ../fabric-core/src/parsers/types.d.ts
18
18
  type PrintOptions = {
19
19
  extname?: Extname;
20
20
  };
21
- type Parser<TOptions = any[], TMeta$1 extends object = any> = {
21
+ type Parser<TOptions = unknown, TMeta$1 extends object = any> = {
22
22
  name: string;
23
23
  type: 'parser';
24
24
  /**
@@ -31,7 +31,7 @@ type Parser<TOptions = any[], TMeta$1 extends object = any> = {
31
31
  */
32
32
  parse(file: ResolvedFile<TMeta$1>, options: PrintOptions): Promise<string>;
33
33
  };
34
- type UserParser<TOptions = any[], TMeta$1 extends object = any> = Omit<Parser<TOptions, TMeta$1>, 'type'>;
34
+ type UserParser<TOptions = unknown, TMeta$1 extends object = any> = Omit<Parser<TOptions, TMeta$1>, 'type'>;
35
35
  //#endregion
36
36
  //#region ../fabric-core/src/utils/AsyncEventEmitter.d.ts
37
37
  declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
@@ -39,6 +39,7 @@ declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
39
39
  constructor(maxListener?: number);
40
40
  emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
41
41
  on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
42
+ onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
42
43
  off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
43
44
  removeAll(): void;
44
45
  }
@@ -79,6 +80,7 @@ type Options = {
79
80
  };
80
81
  declare class FileManager {
81
82
  #private;
83
+ events: AsyncEventEmitter<AppEvents>;
82
84
  processor: FileProcessor;
83
85
  constructor({
84
86
  events
@@ -93,20 +95,21 @@ declare class FileManager {
93
95
  }
94
96
  //#endregion
95
97
  //#region ../fabric-core/src/App.d.ts
98
+ declare global {
99
+ namespace Kubb {
100
+ interface App {}
101
+ }
102
+ }
96
103
  type Component = any;
97
104
  type AppEvents = {
98
105
  /**
99
106
  * Called in the beginning of the app lifecycle.
100
107
  */
101
- start: [{
102
- app: App;
103
- }];
108
+ start: [];
104
109
  /**
105
110
  * Called in the end of the app lifecycle.
106
111
  */
107
- end: [{
108
- app: App;
109
- }];
112
+ end: [];
110
113
  /**
111
114
  * Called when being rendered
112
115
  */
@@ -160,15 +163,15 @@ type AppContext<TOptions = unknown> = {
160
163
  installedPlugins: Set<Plugin>;
161
164
  installedParsers: Set<Parser>;
162
165
  };
163
- type Install<TOptions = any[] | object | undefined> = TOptions extends any[] ? (app: App, ...options: TOptions) => void : TOptions extends object ? (app: App, options?: TOptions) => void : (app: App) => void;
164
- type Inject<TOptions = any[] | object | undefined, TAppExtension$1 extends Record<string, any> = {}> = TOptions extends any[] ? (app: App, ...options: TOptions) => Partial<TAppExtension$1> : TOptions extends object ? (app: App, options?: TOptions) => Partial<TAppExtension$1> : (app: App) => Partial<TAppExtension$1>;
165
- interface App<TOptions = unknown> {
166
+ type AllOptional<T> = {} extends T ? true : false;
167
+ type Install<TOptions = unknown> = TOptions extends any[] ? (app: App, ...options: TOptions) => void | Promise<void> : AllOptional<TOptions> extends true ? (app: App, options: TOptions | undefined) => void | Promise<void> : (app: App, options: TOptions) => void | Promise<void>;
168
+ type Inject<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = TOptions extends any[] ? (app: App, ...options: TOptions) => Partial<TAppExtension$1> : AllOptional<TOptions> extends true ? (app: App, options: TOptions | undefined) => Partial<TAppExtension$1> : (app: App, options: TOptions) => Partial<TAppExtension$1>;
169
+ interface App<TOptions = unknown> extends Kubb.App {
166
170
  context: AppContext<TOptions>;
167
171
  files: Array<ResolvedFile>;
168
- use<TOptions extends any[] | object = any, TMeta extends object = object, TAppExtension extends Record<string, any> = {}>(pluginOrParser: Plugin<TOptions, TAppExtension> | Parser<TOptions, TMeta>, ...options: TOptions extends any[] ? NoInfer<TOptions> : [NoInfer<TOptions>]): this & TAppExtension;
169
- use<TOptions extends any[] | object = any, TMeta extends object = object, TAppExtension extends Record<string, any> = {}>(pluginOrParser: Plugin<TOptions, TAppExtension> | Parser<TOptions, TMeta>): this & TAppExtension;
172
+ use<TPluginOptions = unknown, TMeta extends object = object, TAppExtension extends Record<string, any> = {}>(pluginOrParser: Plugin<TPluginOptions, TAppExtension> | Parser<TPluginOptions, TMeta>, ...options: TPluginOptions extends any[] ? NoInfer<TPluginOptions> : AllOptional<TPluginOptions> extends true ? [NoInfer<TPluginOptions>?] : [NoInfer<TPluginOptions>]): (this & TAppExtension) | Promise<this & TAppExtension>;
170
173
  addFile(...files: Array<File>): Promise<void>;
171
174
  }
172
175
  //#endregion
173
176
  export { UserParser as a, Parser as i, Component as n, Plugin as o, FileManager as r, UserPlugin as s, App as t };
174
- //# sourceMappingURL=App-DwUtyfk9.d.cts.map
177
+ //# sourceMappingURL=App-Bqmn4Mqu.d.cts.map
@@ -1,24 +1,24 @@
1
1
  import { i as File, o as Path, r as Extname, s as ResolvedFile } from "./KubbFile-D4gyyfL-.js";
2
2
 
3
3
  //#region ../fabric-core/src/plugins/types.d.ts
4
- type Plugin<TOptions = any[], TAppExtension$1 extends Record<string, any> = {}> = {
4
+ type Plugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = {
5
5
  name: string;
6
6
  type: 'plugin';
7
- scope?: 'write' | 'read' | (string & {});
8
- install: Install<TOptions> | Promise<Install<TOptions>>;
7
+ install: Install<TOptions>;
9
8
  /**
10
9
  * Runtime app overrides or extensions.
11
10
  * Merged into the app instance after install.
11
+ * This cannot be async
12
12
  */
13
13
  inject?: Inject<TOptions, TAppExtension$1>;
14
14
  };
15
- type UserPlugin<TOptions = any[], TAppExtension$1 extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension$1>, 'type'>;
15
+ type UserPlugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension$1>, 'type'>;
16
16
  //#endregion
17
17
  //#region ../fabric-core/src/parsers/types.d.ts
18
18
  type PrintOptions = {
19
19
  extname?: Extname;
20
20
  };
21
- type Parser<TOptions = any[], TMeta$1 extends object = any> = {
21
+ type Parser<TOptions = unknown, TMeta$1 extends object = any> = {
22
22
  name: string;
23
23
  type: 'parser';
24
24
  /**
@@ -31,7 +31,7 @@ type Parser<TOptions = any[], TMeta$1 extends object = any> = {
31
31
  */
32
32
  parse(file: ResolvedFile<TMeta$1>, options: PrintOptions): Promise<string>;
33
33
  };
34
- type UserParser<TOptions = any[], TMeta$1 extends object = any> = Omit<Parser<TOptions, TMeta$1>, 'type'>;
34
+ type UserParser<TOptions = unknown, TMeta$1 extends object = any> = Omit<Parser<TOptions, TMeta$1>, 'type'>;
35
35
  //#endregion
36
36
  //#region ../fabric-core/src/utils/AsyncEventEmitter.d.ts
37
37
  declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
@@ -39,6 +39,7 @@ declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
39
39
  constructor(maxListener?: number);
40
40
  emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
41
41
  on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
42
+ onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
42
43
  off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
43
44
  removeAll(): void;
44
45
  }
@@ -79,6 +80,7 @@ type Options = {
79
80
  };
80
81
  declare class FileManager {
81
82
  #private;
83
+ events: AsyncEventEmitter<AppEvents>;
82
84
  processor: FileProcessor;
83
85
  constructor({
84
86
  events
@@ -93,20 +95,21 @@ declare class FileManager {
93
95
  }
94
96
  //#endregion
95
97
  //#region ../fabric-core/src/App.d.ts
98
+ declare global {
99
+ namespace Kubb {
100
+ interface App {}
101
+ }
102
+ }
96
103
  type Component = any;
97
104
  type AppEvents = {
98
105
  /**
99
106
  * Called in the beginning of the app lifecycle.
100
107
  */
101
- start: [{
102
- app: App;
103
- }];
108
+ start: [];
104
109
  /**
105
110
  * Called in the end of the app lifecycle.
106
111
  */
107
- end: [{
108
- app: App;
109
- }];
112
+ end: [];
110
113
  /**
111
114
  * Called when being rendered
112
115
  */
@@ -160,15 +163,15 @@ type AppContext<TOptions = unknown> = {
160
163
  installedPlugins: Set<Plugin>;
161
164
  installedParsers: Set<Parser>;
162
165
  };
163
- type Install<TOptions = any[] | object | undefined> = TOptions extends any[] ? (app: App, ...options: TOptions) => void : TOptions extends object ? (app: App, options?: TOptions) => void : (app: App) => void;
164
- type Inject<TOptions = any[] | object | undefined, TAppExtension$1 extends Record<string, any> = {}> = TOptions extends any[] ? (app: App, ...options: TOptions) => Partial<TAppExtension$1> : TOptions extends object ? (app: App, options?: TOptions) => Partial<TAppExtension$1> : (app: App) => Partial<TAppExtension$1>;
165
- interface App<TOptions = unknown> {
166
+ type AllOptional<T> = {} extends T ? true : false;
167
+ type Install<TOptions = unknown> = TOptions extends any[] ? (app: App, ...options: TOptions) => void | Promise<void> : AllOptional<TOptions> extends true ? (app: App, options: TOptions | undefined) => void | Promise<void> : (app: App, options: TOptions) => void | Promise<void>;
168
+ type Inject<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = TOptions extends any[] ? (app: App, ...options: TOptions) => Partial<TAppExtension$1> : AllOptional<TOptions> extends true ? (app: App, options: TOptions | undefined) => Partial<TAppExtension$1> : (app: App, options: TOptions) => Partial<TAppExtension$1>;
169
+ interface App<TOptions = unknown> extends Kubb.App {
166
170
  context: AppContext<TOptions>;
167
171
  files: Array<ResolvedFile>;
168
- use<TOptions extends any[] | object = any, TMeta extends object = object, TAppExtension extends Record<string, any> = {}>(pluginOrParser: Plugin<TOptions, TAppExtension> | Parser<TOptions, TMeta>, ...options: TOptions extends any[] ? NoInfer<TOptions> : [NoInfer<TOptions>]): this & TAppExtension;
169
- use<TOptions extends any[] | object = any, TMeta extends object = object, TAppExtension extends Record<string, any> = {}>(pluginOrParser: Plugin<TOptions, TAppExtension> | Parser<TOptions, TMeta>): this & TAppExtension;
172
+ use<TPluginOptions = unknown, TMeta extends object = object, TAppExtension extends Record<string, any> = {}>(pluginOrParser: Plugin<TPluginOptions, TAppExtension> | Parser<TPluginOptions, TMeta>, ...options: TPluginOptions extends any[] ? NoInfer<TPluginOptions> : AllOptional<TPluginOptions> extends true ? [NoInfer<TPluginOptions>?] : [NoInfer<TPluginOptions>]): (this & TAppExtension) | Promise<this & TAppExtension>;
170
173
  addFile(...files: Array<File>): Promise<void>;
171
174
  }
172
175
  //#endregion
173
176
  export { UserParser as a, Parser as i, Component as n, Plugin as o, FileManager as r, UserPlugin as s, App as t };
174
- //# sourceMappingURL=App-2SatilGX.d.ts.map
177
+ //# sourceMappingURL=App-DLp9W8mB.d.ts.map
package/dist/index.d.cts CHANGED
@@ -1,11 +1,14 @@
1
1
  import { a as Import, c as Source, n as Export, o as Path, t as BaseName } from "./KubbFile-FGXV713i.cjs";
2
- import { n as Component, r as FileManager, t as App$1 } from "./App-DwUtyfk9.cjs";
2
+ import { n as Component, r as FileManager, t as App$1 } from "./App-Bqmn4Mqu.cjs";
3
3
  import { a as JSDoc, f as createFunctionParams, l as FunctionParams, o as Key, s as KubbNode } from "./types-C3p0Ljxf.cjs";
4
4
  import "./globals-BRG2DOJd.cjs";
5
5
  import * as react1 from "react";
6
6
  import React, { ReactNode } from "react";
7
7
  import * as react_jsx_runtime0 from "react/jsx-runtime";
8
8
 
9
+ //#region ../fabric-core/src/createApp.d.ts
10
+ declare const createApp: DefineApp<unknown>;
11
+ //#endregion
9
12
  //#region ../fabric-core/src/defineApp.d.ts
10
13
  type DefineApp<TOptions> = (rootComponent?: Component, options?: TOptions) => App$1;
11
14
  //#endregion
@@ -295,9 +298,6 @@ declare function useLifecycle(): {
295
298
  exit: () => void;
296
299
  };
297
300
  //#endregion
298
- //#region ../fabric-core/src/createApp.d.ts
299
- declare const createApp: DefineApp<unknown>;
300
- //#endregion
301
301
  //#region src/Runtime.d.ts
302
302
  type Options = {
303
303
  fileManager: FileManager;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  import { a as Import, c as Source, n as Export, o as Path, t as BaseName } from "./KubbFile-D4gyyfL-.js";
2
- import { n as Component, r as FileManager, t as App$1 } from "./App-2SatilGX.js";
2
+ import { n as Component, r as FileManager, t as App$1 } from "./App-DLp9W8mB.js";
3
3
  import { a as JSDoc, f as createFunctionParams, l as FunctionParams, o as Key, s as KubbNode } from "./types-Brnyan9B.js";
4
4
  import "./globals-D_1Lfe9-.js";
5
5
  import * as react1 from "react";
6
6
  import React, { ReactNode } from "react";
7
7
  import * as react_jsx_runtime0 from "react/jsx-runtime";
8
8
 
9
+ //#region ../fabric-core/src/createApp.d.ts
10
+ declare const createApp: DefineApp<unknown>;
11
+ //#endregion
9
12
  //#region ../fabric-core/src/defineApp.d.ts
10
13
  type DefineApp<TOptions> = (rootComponent?: Component, options?: TOptions) => App$1;
11
14
  //#endregion
@@ -295,9 +298,6 @@ declare function useLifecycle(): {
295
298
  exit: () => void;
296
299
  };
297
300
  //#endregion
298
- //#region ../fabric-core/src/createApp.d.ts
299
- declare const createApp: DefineApp<unknown>;
300
- //#endregion
301
301
  //#region src/Runtime.d.ts
302
302
  type Options = {
303
303
  fileManager: FileManager;
@@ -1,8 +1,8 @@
1
1
  import "./KubbFile-FGXV713i.cjs";
2
- import { a as UserParser, i as Parser } from "./App-DwUtyfk9.cjs";
2
+ import { a as UserParser, i as Parser } from "./App-Bqmn4Mqu.cjs";
3
3
 
4
4
  //#region ../fabric-core/src/parsers/createParser.d.ts
5
- declare function createParser<TOptions = any[], TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta>;
5
+ declare function createParser<TOptions = unknown, TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta>;
6
6
  //#endregion
7
7
  //#region ../fabric-core/src/parsers/defaultParser.d.ts
8
8
  declare const defaultParser: Parser<[], any>;
package/dist/parsers.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import "./KubbFile-D4gyyfL-.js";
2
- import { a as UserParser, i as Parser } from "./App-2SatilGX.js";
2
+ import { a as UserParser, i as Parser } from "./App-DLp9W8mB.js";
3
3
 
4
4
  //#region ../fabric-core/src/parsers/createParser.d.ts
5
- declare function createParser<TOptions = any[], TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta>;
5
+ declare function createParser<TOptions = unknown, TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta>;
6
6
  //#endregion
7
7
  //#region ../fabric-core/src/parsers/defaultParser.d.ts
8
8
  declare const defaultParser: Parser<[], any>;
package/dist/plugins.cjs CHANGED
@@ -17,12 +17,14 @@ const reactPlugin = (0, __kubb_fabric_core_plugins.createPlugin)({
17
17
  return {
18
18
  async render(App) {
19
19
  runtime.render((0, import_react.createElement)(App));
20
+ await app.context.events.emit("start");
20
21
  },
21
22
  async renderToString(App) {
22
23
  return runtime.renderToString((0, import_react.createElement)(App));
23
24
  },
24
- waitUntilExit() {
25
- return runtime.waitUntilExit();
25
+ async waitUntilExit() {
26
+ await runtime.waitUntilExit();
27
+ await app.context.events.emit("end");
26
28
  }
27
29
  };
28
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.cjs","names":["Runtime"],"sources":["../src/plugins/reactPlugin.ts"],"sourcesContent":["import { createPlugin } from '@kubb/fabric-core/plugins'\nimport { Runtime } from '../Runtime.tsx'\nimport { createElement, type ElementType } from 'react'\n\ntype Options = {\n stdout?: NodeJS.WriteStream\n stdin?: NodeJS.ReadStream\n stderr?: NodeJS.WriteStream\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\ntype ExtendOptions = {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n}\n\ndeclare module '@kubb/fabric-core' {\n interface App {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n }\n}\n\nexport const reactPlugin = createPlugin<Options, ExtendOptions>({\n name: 'react',\n install() {},\n inject(app, options: Options = {}) {\n const runtime = new Runtime({ fileManager: app.context.fileManager, ...options })\n\n return {\n async render(App) {\n runtime.render(createElement(App))\n },\n async renderToString(App) {\n return runtime.renderToString(createElement(App))\n },\n waitUntilExit() {\n return runtime.waitUntilExit()\n },\n }\n },\n})\n"],"mappings":";;;;;;;;AA4BA,MAAa,2DAAmD;CAC9D,MAAM;CACN,UAAU;CACV,OAAO,KAAK,UAAmB,EAAE,EAAE;EACjC,MAAM,UAAU,IAAIA,wBAAQ;GAAE,aAAa,IAAI,QAAQ;GAAa,GAAG;GAAS,CAAC;AAEjF,SAAO;GACL,MAAM,OAAO,KAAK;AAChB,YAAQ,uCAAqB,IAAI,CAAC;;GAEpC,MAAM,eAAe,KAAK;AACxB,WAAO,QAAQ,+CAA6B,IAAI,CAAC;;GAEnD,gBAAgB;AACd,WAAO,QAAQ,eAAe;;GAEjC;;CAEJ,CAAC"}
1
+ {"version":3,"file":"plugins.cjs","names":["Runtime"],"sources":["../src/plugins/reactPlugin.ts"],"sourcesContent":["import { createPlugin } from '@kubb/fabric-core/plugins'\nimport { Runtime } from '../Runtime.tsx'\nimport { createElement, type ElementType } from 'react'\n\ntype Options = {\n stdout?: NodeJS.WriteStream\n stdin?: NodeJS.ReadStream\n stderr?: NodeJS.WriteStream\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\ntype ExtendOptions = {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n}\n\n// biome-ignore lint/suspicious/noTsIgnore: production ready\n// @ts-ignore\ndeclare module '@kubb/fabric-core' {\n interface App {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n }\n}\n\ndeclare global {\n namespace Kubb {\n interface App {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n }\n }\n}\n\nexport const reactPlugin = createPlugin<Options, ExtendOptions>({\n name: 'react',\n install() {},\n inject(app, options = {}) {\n const runtime = new Runtime({ fileManager: app.context.fileManager, ...options })\n\n return {\n async render(App) {\n runtime.render(createElement(App))\n await app.context.events.emit('start')\n },\n async renderToString(App) {\n return runtime.renderToString(createElement(App))\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n\n await app.context.events.emit('end')\n },\n }\n },\n})\n"],"mappings":";;;;;;;;AAwCA,MAAa,2DAAmD;CAC9D,MAAM;CACN,UAAU;CACV,OAAO,KAAK,UAAU,EAAE,EAAE;EACxB,MAAM,UAAU,IAAIA,wBAAQ;GAAE,aAAa,IAAI,QAAQ;GAAa,GAAG;GAAS,CAAC;AAEjF,SAAO;GACL,MAAM,OAAO,KAAK;AAChB,YAAQ,uCAAqB,IAAI,CAAC;AAClC,UAAM,IAAI,QAAQ,OAAO,KAAK,QAAQ;;GAExC,MAAM,eAAe,KAAK;AACxB,WAAO,QAAQ,+CAA6B,IAAI,CAAC;;GAEnD,MAAM,gBAAgB;AACpB,UAAM,QAAQ,eAAe;AAE7B,UAAM,IAAI,QAAQ,OAAO,KAAK,MAAM;;GAEvC;;CAEJ,CAAC"}
@@ -1,31 +1,64 @@
1
1
  import { r as Extname } from "./KubbFile-FGXV713i.cjs";
2
- import { o as Plugin, s as UserPlugin } from "./App-DwUtyfk9.cjs";
2
+ import { o as Plugin, s as UserPlugin } from "./App-Bqmn4Mqu.cjs";
3
3
  import { ElementType } from "react";
4
4
 
5
5
  //#region ../fabric-core/src/plugins/createPlugin.d.ts
6
- declare function createPlugin<Options$2 = any[], TAppExtension extends Record<string, any> = {}>(plugin: UserPlugin<Options$2, TAppExtension>): Plugin<Options$2, TAppExtension>;
6
+ declare function createPlugin<Options$3 = unknown, TAppExtension extends Record<string, any> = {}>(plugin: UserPlugin<Options$3, TAppExtension>): Plugin<Options$3, TAppExtension>;
7
7
  //#endregion
8
8
  //#region ../fabric-core/src/plugins/fsPlugin.d.ts
9
9
  type WriteOptions = {
10
10
  extension?: Record<Extname, Extname | ''>;
11
11
  dryRun?: boolean;
12
12
  };
13
- type Options$1 = {
13
+ type Options$2 = {
14
14
  /**
15
15
  * Optional callback that is invoked whenever a file is written by the plugin.
16
16
  * Useful for tests to observe write operations without spying on internal functions.
17
17
  */
18
18
  onWrite?: (path: string, data: string) => void | Promise<void>;
19
+ clean?: {
20
+ path: string;
21
+ };
19
22
  };
20
- type ExtendOptions$1 = {
23
+ type ExtendOptions$2 = {
21
24
  write(options?: WriteOptions): Promise<void>;
22
25
  };
23
- declare module '../index.ts' {
26
+ declare module '@kubb/fabric-core' {
24
27
  interface App {
25
28
  write(options?: WriteOptions): Promise<void>;
26
29
  }
27
30
  }
28
- declare const fsPlugin: Plugin<Options$1, ExtendOptions$1>;
31
+ declare global {
32
+ namespace Kubb {
33
+ interface App {
34
+ write(options?: WriteOptions): Promise<void>;
35
+ }
36
+ }
37
+ }
38
+ declare const fsPlugin: Plugin<Options$2, ExtendOptions$2>;
39
+ //#endregion
40
+ //#region ../fabric-core/src/plugins/barrelPlugin.d.ts
41
+ type Mode = 'all' | 'named' | 'propagate' | false;
42
+ type Options$1 = {
43
+ root: string;
44
+ mode: Mode;
45
+ };
46
+ type ExtendOptions$1 = {
47
+ writeEntry(options: Options$1): Promise<void>;
48
+ };
49
+ declare module '@kubb/fabric-core' {
50
+ interface App {
51
+ writeEntry(options: Options$1): Promise<void>;
52
+ }
53
+ }
54
+ declare global {
55
+ namespace Kubb {
56
+ interface App {
57
+ writeEntry(options: Options$1): Promise<void>;
58
+ }
59
+ }
60
+ }
61
+ declare const barrelPlugin: Plugin<Options$1, ExtendOptions$1>;
29
62
  //#endregion
30
63
  //#region src/plugins/reactPlugin.d.ts
31
64
  type Options = {
@@ -49,7 +82,16 @@ declare module '@kubb/fabric-core' {
49
82
  waitUntilExit(): Promise<void>;
50
83
  }
51
84
  }
85
+ declare global {
86
+ namespace Kubb {
87
+ interface App {
88
+ render(App: ElementType): Promise<void> | void;
89
+ renderToString(App: ElementType): Promise<string> | string;
90
+ waitUntilExit(): Promise<void>;
91
+ }
92
+ }
93
+ }
52
94
  declare const reactPlugin: Plugin<Options, ExtendOptions>;
53
95
  //#endregion
54
- export { createPlugin, fsPlugin, reactPlugin };
96
+ export { barrelPlugin, createPlugin, fsPlugin, reactPlugin };
55
97
  //# sourceMappingURL=plugins.d.cts.map
package/dist/plugins.d.ts CHANGED
@@ -1,31 +1,64 @@
1
1
  import { r as Extname } from "./KubbFile-D4gyyfL-.js";
2
- import { o as Plugin, s as UserPlugin } from "./App-2SatilGX.js";
2
+ import { o as Plugin, s as UserPlugin } from "./App-DLp9W8mB.js";
3
3
  import { ElementType } from "react";
4
4
 
5
5
  //#region ../fabric-core/src/plugins/createPlugin.d.ts
6
- declare function createPlugin<Options$2 = any[], TAppExtension extends Record<string, any> = {}>(plugin: UserPlugin<Options$2, TAppExtension>): Plugin<Options$2, TAppExtension>;
6
+ declare function createPlugin<Options$3 = unknown, TAppExtension extends Record<string, any> = {}>(plugin: UserPlugin<Options$3, TAppExtension>): Plugin<Options$3, TAppExtension>;
7
7
  //#endregion
8
8
  //#region ../fabric-core/src/plugins/fsPlugin.d.ts
9
9
  type WriteOptions = {
10
10
  extension?: Record<Extname, Extname | ''>;
11
11
  dryRun?: boolean;
12
12
  };
13
- type Options$1 = {
13
+ type Options$2 = {
14
14
  /**
15
15
  * Optional callback that is invoked whenever a file is written by the plugin.
16
16
  * Useful for tests to observe write operations without spying on internal functions.
17
17
  */
18
18
  onWrite?: (path: string, data: string) => void | Promise<void>;
19
+ clean?: {
20
+ path: string;
21
+ };
19
22
  };
20
- type ExtendOptions$1 = {
23
+ type ExtendOptions$2 = {
21
24
  write(options?: WriteOptions): Promise<void>;
22
25
  };
23
- declare module '../index.ts' {
26
+ declare module '@kubb/fabric-core' {
24
27
  interface App {
25
28
  write(options?: WriteOptions): Promise<void>;
26
29
  }
27
30
  }
28
- declare const fsPlugin: Plugin<Options$1, ExtendOptions$1>;
31
+ declare global {
32
+ namespace Kubb {
33
+ interface App {
34
+ write(options?: WriteOptions): Promise<void>;
35
+ }
36
+ }
37
+ }
38
+ declare const fsPlugin: Plugin<Options$2, ExtendOptions$2>;
39
+ //#endregion
40
+ //#region ../fabric-core/src/plugins/barrelPlugin.d.ts
41
+ type Mode = 'all' | 'named' | 'propagate' | false;
42
+ type Options$1 = {
43
+ root: string;
44
+ mode: Mode;
45
+ };
46
+ type ExtendOptions$1 = {
47
+ writeEntry(options: Options$1): Promise<void>;
48
+ };
49
+ declare module '@kubb/fabric-core' {
50
+ interface App {
51
+ writeEntry(options: Options$1): Promise<void>;
52
+ }
53
+ }
54
+ declare global {
55
+ namespace Kubb {
56
+ interface App {
57
+ writeEntry(options: Options$1): Promise<void>;
58
+ }
59
+ }
60
+ }
61
+ declare const barrelPlugin: Plugin<Options$1, ExtendOptions$1>;
29
62
  //#endregion
30
63
  //#region src/plugins/reactPlugin.d.ts
31
64
  type Options = {
@@ -49,7 +82,16 @@ declare module '@kubb/fabric-core' {
49
82
  waitUntilExit(): Promise<void>;
50
83
  }
51
84
  }
85
+ declare global {
86
+ namespace Kubb {
87
+ interface App {
88
+ render(App: ElementType): Promise<void> | void;
89
+ renderToString(App: ElementType): Promise<string> | string;
90
+ waitUntilExit(): Promise<void>;
91
+ }
92
+ }
93
+ }
52
94
  declare const reactPlugin: Plugin<Options, ExtendOptions>;
53
95
  //#endregion
54
- export { createPlugin, fsPlugin, reactPlugin };
96
+ export { barrelPlugin, createPlugin, fsPlugin, reactPlugin };
55
97
  //# sourceMappingURL=plugins.d.ts.map
package/dist/plugins.js CHANGED
@@ -18,12 +18,14 @@ const reactPlugin = createPlugin({
18
18
  return {
19
19
  async render(App) {
20
20
  runtime.render((0, import_react.createElement)(App));
21
+ await app.context.events.emit("start");
21
22
  },
22
23
  async renderToString(App) {
23
24
  return runtime.renderToString((0, import_react.createElement)(App));
24
25
  },
25
- waitUntilExit() {
26
- return runtime.waitUntilExit();
26
+ async waitUntilExit() {
27
+ await runtime.waitUntilExit();
28
+ await app.context.events.emit("end");
27
29
  }
28
30
  };
29
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.js","names":[],"sources":["../src/plugins/reactPlugin.ts"],"sourcesContent":["import { createPlugin } from '@kubb/fabric-core/plugins'\nimport { Runtime } from '../Runtime.tsx'\nimport { createElement, type ElementType } from 'react'\n\ntype Options = {\n stdout?: NodeJS.WriteStream\n stdin?: NodeJS.ReadStream\n stderr?: NodeJS.WriteStream\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\ntype ExtendOptions = {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n}\n\ndeclare module '@kubb/fabric-core' {\n interface App {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n }\n}\n\nexport const reactPlugin = createPlugin<Options, ExtendOptions>({\n name: 'react',\n install() {},\n inject(app, options: Options = {}) {\n const runtime = new Runtime({ fileManager: app.context.fileManager, ...options })\n\n return {\n async render(App) {\n runtime.render(createElement(App))\n },\n async renderToString(App) {\n return runtime.renderToString(createElement(App))\n },\n waitUntilExit() {\n return runtime.waitUntilExit()\n },\n }\n },\n})\n"],"mappings":";;;;;;;;;AA4BA,MAAa,cAAc,aAAqC;CAC9D,MAAM;CACN,UAAU;CACV,OAAO,KAAK,UAAmB,EAAE,EAAE;EACjC,MAAM,UAAU,IAAI,QAAQ;GAAE,aAAa,IAAI,QAAQ;GAAa,GAAG;GAAS,CAAC;AAEjF,SAAO;GACL,MAAM,OAAO,KAAK;AAChB,YAAQ,uCAAqB,IAAI,CAAC;;GAEpC,MAAM,eAAe,KAAK;AACxB,WAAO,QAAQ,+CAA6B,IAAI,CAAC;;GAEnD,gBAAgB;AACd,WAAO,QAAQ,eAAe;;GAEjC;;CAEJ,CAAC"}
1
+ {"version":3,"file":"plugins.js","names":[],"sources":["../src/plugins/reactPlugin.ts"],"sourcesContent":["import { createPlugin } from '@kubb/fabric-core/plugins'\nimport { Runtime } from '../Runtime.tsx'\nimport { createElement, type ElementType } from 'react'\n\ntype Options = {\n stdout?: NodeJS.WriteStream\n stdin?: NodeJS.ReadStream\n stderr?: NodeJS.WriteStream\n /**\n * Set this to true to always see the result of the render in the console(line per render)\n */\n debug?: boolean\n}\n\ntype ExtendOptions = {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n}\n\n// biome-ignore lint/suspicious/noTsIgnore: production ready\n// @ts-ignore\ndeclare module '@kubb/fabric-core' {\n interface App {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n }\n}\n\ndeclare global {\n namespace Kubb {\n interface App {\n render(App: ElementType): Promise<void> | void\n renderToString(App: ElementType): Promise<string> | string\n waitUntilExit(): Promise<void>\n }\n }\n}\n\nexport const reactPlugin = createPlugin<Options, ExtendOptions>({\n name: 'react',\n install() {},\n inject(app, options = {}) {\n const runtime = new Runtime({ fileManager: app.context.fileManager, ...options })\n\n return {\n async render(App) {\n runtime.render(createElement(App))\n await app.context.events.emit('start')\n },\n async renderToString(App) {\n return runtime.renderToString(createElement(App))\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n\n await app.context.events.emit('end')\n },\n }\n },\n})\n"],"mappings":";;;;;;;;;AAwCA,MAAa,cAAc,aAAqC;CAC9D,MAAM;CACN,UAAU;CACV,OAAO,KAAK,UAAU,EAAE,EAAE;EACxB,MAAM,UAAU,IAAI,QAAQ;GAAE,aAAa,IAAI,QAAQ;GAAa,GAAG;GAAS,CAAC;AAEjF,SAAO;GACL,MAAM,OAAO,KAAK;AAChB,YAAQ,uCAAqB,IAAI,CAAC;AAClC,UAAM,IAAI,QAAQ,OAAO,KAAK,QAAQ;;GAExC,MAAM,eAAe,KAAK;AACxB,WAAO,QAAQ,+CAA6B,IAAI,CAAC;;GAEnD,MAAM,gBAAgB;AACpB,UAAM,QAAQ,eAAe;AAE7B,UAAM,IAAI,QAAQ,OAAO,KAAK,MAAM;;GAEvC;;CAEJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/react-fabric",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "React integration for Kubb, providing JSX runtime support and React component generation capabilities for code generation plugins.",
5
5
  "keywords": [
6
6
  "react",
@@ -99,7 +99,7 @@
99
99
  "react-reconciler": "0.32.0",
100
100
  "signal-exit": "^4.1.0",
101
101
  "ws": "^8.18.3",
102
- "@kubb/fabric-core": "0.1.4"
102
+ "@kubb/fabric-core": "0.1.6"
103
103
  },
104
104
  "devDependencies": {
105
105
  "@types/react": "^19.2.2",
@@ -18,6 +18,8 @@ type ExtendOptions = {
18
18
  waitUntilExit(): Promise<void>
19
19
  }
20
20
 
21
+ // biome-ignore lint/suspicious/noTsIgnore: production ready
22
+ // @ts-ignore
21
23
  declare module '@kubb/fabric-core' {
22
24
  interface App {
23
25
  render(App: ElementType): Promise<void> | void
@@ -26,21 +28,34 @@ declare module '@kubb/fabric-core' {
26
28
  }
27
29
  }
28
30
 
31
+ declare global {
32
+ namespace Kubb {
33
+ interface App {
34
+ render(App: ElementType): Promise<void> | void
35
+ renderToString(App: ElementType): Promise<string> | string
36
+ waitUntilExit(): Promise<void>
37
+ }
38
+ }
39
+ }
40
+
29
41
  export const reactPlugin = createPlugin<Options, ExtendOptions>({
30
42
  name: 'react',
31
43
  install() {},
32
- inject(app, options: Options = {}) {
44
+ inject(app, options = {}) {
33
45
  const runtime = new Runtime({ fileManager: app.context.fileManager, ...options })
34
46
 
35
47
  return {
36
48
  async render(App) {
37
49
  runtime.render(createElement(App))
50
+ await app.context.events.emit('start')
38
51
  },
39
52
  async renderToString(App) {
40
53
  return runtime.renderToString(createElement(App))
41
54
  },
42
- waitUntilExit() {
43
- return runtime.waitUntilExit()
55
+ async waitUntilExit() {
56
+ await runtime.waitUntilExit()
57
+
58
+ await app.context.events.emit('end')
44
59
  },
45
60
  }
46
61
  },