@kubb/react-fabric 0.2.15 → 0.2.16

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.
@@ -2,7 +2,7 @@ import { createRequire } from "node:module";
2
2
 
3
3
  //#region rolldown:runtime
4
4
  declare namespace KubbFile_d_exports {
5
- export { AdvancedPath, BaseName, Export, Extname, File, Import, Mode, OptionalPath, Path, ResolvedExport, ResolvedFile, ResolvedImport, Source };
5
+ export { AdvancedPath, BaseName, Export, Extname, File, Import, Mode, Path, ResolvedExport, ResolvedFile, ResolvedImport, Source };
6
6
  }
7
7
  type BasePath<T extends string = string> = `${T}/`;
8
8
  type Import = {
@@ -79,7 +79,6 @@ type BaseName = `${string}.${string}`;
79
79
  */
80
80
  type Path = string;
81
81
  type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
82
- type OptionalPath = Path | undefined | null;
83
82
  type File<TMeta extends object = object> = {
84
83
  /**
85
84
  * Name to be used to create the path
@@ -138,9 +137,16 @@ type Parser<TOptions = unknown, TMeta extends object = any> = {
138
137
  type UserParser<TOptions = unknown, TMeta extends object = any> = Omit<Parser<TOptions, TMeta>, 'type'>;
139
138
  //#endregion
140
139
  //#region ../fabric-core/src/utils/AsyncEventEmitter.d.ts
140
+ type Options$2 = {
141
+ mode?: FabricMode;
142
+ maxListener?: number;
143
+ };
141
144
  declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
142
145
  #private;
143
- constructor(maxListener?: number);
146
+ constructor({
147
+ maxListener,
148
+ mode
149
+ }?: Options$2);
144
150
  emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
145
151
  on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
146
152
  onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
@@ -223,36 +229,45 @@ declare global {
223
229
  interface Fabric {}
224
230
  }
225
231
  }
226
- type FabricOptions = {
232
+ /**
233
+ * Component placeholder type.
234
+ * May later be extended to support specific runtime renderers.
235
+ */
236
+
237
+ /**
238
+ * Defines core runtime options for Fabric.
239
+ */
240
+ interface FabricOptions {
227
241
  /**
242
+ * Determines how Fabric processes files.
243
+ * - `sequential`: files are processed one by one
244
+ * - `parallel`: files are processed concurrently
245
+ *
228
246
  * @default 'sequential'
229
247
  */
230
248
  mode?: FabricMode;
231
- };
232
- type FabricEvents = {
233
- /**
234
- * Called in the beginning of the app lifecycle.
235
- */
249
+ }
250
+ /**
251
+ * Available modes for file processing.
252
+ */
253
+ type FabricMode = 'sequential' | 'parallel';
254
+ /**
255
+ * Event definitions emitted during the Fabric lifecycle.
256
+ */
257
+ interface FabricEvents {
258
+ /** Called at the beginning of the app lifecycle. */
236
259
  start: [];
237
- /**
238
- * Called in the end of the app lifecycle.
239
- */
260
+ /** Called at the end of the app lifecycle. */
240
261
  end: [];
241
- /**
242
- * Called when being rendered
243
- */
262
+ /** Called when Fabric is rendering. */
244
263
  render: [{
245
264
  fabric: Fabric;
246
265
  }];
247
- /**
248
- * Called once before processing any files.
249
- */
266
+ /** Called once before any files are processed. */
250
267
  'process:start': [{
251
268
  files: ResolvedFile[];
252
269
  }];
253
- /**
254
- * Called when FileManager is adding files to its cache
255
- */
270
+ /** Called when files are added to the FileManager cache. */
256
271
  'file:add': [{
257
272
  files: ResolvedFile[];
258
273
  }];
@@ -262,24 +277,20 @@ type FabricEvents = {
262
277
  'write:end': [{
263
278
  files: ResolvedFile[];
264
279
  }];
265
- /**
266
- * Called for each file when processing begins.
267
- */
280
+ /** Called for each file when processing begins. */
268
281
  'file:start': [{
269
282
  file: ResolvedFile;
270
283
  index: number;
271
284
  total: number;
272
285
  }];
273
- /**
274
- * Called for each file when processing finishes.
275
- */
286
+ /** Called for each file when processing completes. */
276
287
  'file:end': [{
277
288
  file: ResolvedFile;
278
289
  index: number;
279
290
  total: number;
280
291
  }];
281
292
  /**
282
- * Called periodically (or after each file) to indicate progress.
293
+ * Called periodically (or per file) to indicate progress.
283
294
  * Useful for progress bars or logging.
284
295
  */
285
296
  'process:progress': [{
@@ -289,34 +300,67 @@ type FabricEvents = {
289
300
  source?: string;
290
301
  file: ResolvedFile;
291
302
  }];
292
- /**
293
- * Called once all files have been processed successfully.
294
- */
303
+ /** Called once all files have been processed successfully. */
295
304
  'process:end': [{
296
305
  files: ResolvedFile[];
297
306
  }];
298
- };
299
- type FabricContext<TOptions extends FabricOptions = FabricOptions> = {
300
- config?: FabricConfig<TOptions>;
307
+ }
308
+ /**
309
+ * Shared context passed to all plugins, parsers, and Fabric internals.
310
+ */
311
+ interface FabricContext<T extends FabricOptions = FabricOptions> extends AsyncEventEmitter<FabricEvents> {
312
+ /** The active Fabric configuration. */
313
+ config?: FabricConfig<T>;
314
+ /** The internal file manager handling file creation, merging, and writing. */
301
315
  fileManager: FileManager;
302
- files: Array<ResolvedFile>;
303
- addFile(...files: Array<File>): Promise<void>;
316
+ /** List of files currently in memory. */
317
+ files: ResolvedFile[];
318
+ /** Add new files to the file manager. */
319
+ addFile(...files: File[]): Promise<void>;
320
+ /** Track installed plugins and parsers to prevent duplicates. */
304
321
  installedPlugins: Set<Plugin>;
305
322
  installedParsers: Set<Parser>;
306
- } & AsyncEventEmitter<FabricEvents>;
307
- type FabricMode = 'sequential' | 'parallel';
323
+ }
324
+ /**
325
+ * Base configuration object for Fabric.
326
+ */
327
+ interface FabricConfig<T extends FabricOptions = FabricOptions> {
328
+ /** The runtime options used to configure Fabric. */
329
+ options: T;
330
+ }
331
+ /**
332
+ * Utility type that checks whether all properties of `T` are optional.
333
+ */
308
334
  type AllOptional<T> = {} extends T ? true : false;
309
- type FabricConfig<TOptions extends FabricOptions> = {
310
- options: TOptions;
311
- };
312
- type Install<TOptions = unknown> = TOptions extends any[] ? (context: FabricContext, ...options: TOptions) => void | Promise<void> : AllOptional<TOptions> extends true ? (context: FabricContext, options: TOptions | undefined) => void | Promise<void> : (context: FabricContext, options: TOptions) => void | Promise<void>;
313
- type Inject<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = TOptions extends any[] ? (context: FabricContext, ...options: TOptions) => Partial<TAppExtension> : AllOptional<TOptions> extends true ? (context: FabricContext, options: TOptions | undefined) => Partial<TAppExtension> : (context: FabricContext, options: TOptions) => Partial<TAppExtension>;
314
- interface Fabric<TOptions extends FabricOptions = FabricOptions> extends Kubb.Fabric {
315
- context: FabricContext<TOptions>;
316
- files: Array<ResolvedFile>;
317
- 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>;
318
- addFile(...files: Array<File>): Promise<void>;
335
+ /**
336
+ * Defines the signature of a plugin or parser's `install` function.
337
+ */
338
+ type Install<TOptions = unknown> = TOptions extends any[] ? (context: FabricContext, ...options: TOptions) => void | Promise<void> : AllOptional<TOptions> extends true ? (context: FabricContext, options?: TOptions) => void | Promise<void> : (context: FabricContext, options: TOptions) => void | Promise<void>;
339
+ /**
340
+ * Defines the signature of a plugin or parser's `inject` function.
341
+ * Returns an object that extends the Fabric instance.
342
+ */
343
+ type Inject<TOptions = unknown, TExtension extends Record<string, any> = {}> = TOptions extends any[] ? (context: FabricContext, ...options: TOptions) => Partial<TExtension> : AllOptional<TOptions> extends true ? (context: FabricContext, options?: TOptions) => Partial<TExtension> : (context: FabricContext, options: TOptions) => Partial<TExtension>;
344
+ /**
345
+ * The main Fabric runtime interface.
346
+ * Provides access to the current context, registered plugins, files, and utility methods.
347
+ */
348
+ interface Fabric<T extends FabricOptions = FabricOptions> extends Kubb.Fabric {
349
+ /** The shared context for this Fabric instance. */
350
+ context: FabricContext<T>;
351
+ /** The files managed by this Fabric instance. */
352
+ files: ResolvedFile[];
353
+ /**
354
+ * Install a plugin or parser into Fabric.
355
+ *
356
+ * @param target - The plugin or parser to install.
357
+ * @param options - Optional configuration or arguments for the target.
358
+ * @returns A Fabric instance extended by the plugin (if applicable).
359
+ */
360
+ use<TPluginOptions = unknown, TMeta extends object = object, TExtension extends Record<string, any> = {}>(target: Plugin<TPluginOptions, TExtension> | Parser<TPluginOptions, TMeta>, ...options: TPluginOptions extends any[] ? NoInfer<TPluginOptions> : AllOptional<TPluginOptions> extends true ? [NoInfer<TPluginOptions>?] : [NoInfer<TPluginOptions>]): (this & TExtension) | Promise<this & TExtension>;
361
+ /** Add one or more files to the Fabric file manager. */
362
+ addFile(...files: File[]): Promise<void>;
319
363
  }
320
364
  //#endregion
321
365
  export { KubbFile_d_exports as _, FabricOptions as a, Source as b, FileManager as c, UserParser as d, BaseName as f, Import as g, File as h, FabricMode as i, FileProcessor as l, Extname as m, FabricConfig as n, Plugin as o, Export as p, FabricContext as r, UserPlugin as s, Fabric as t, Parser as u, Path as v, ResolvedFile as y };
322
- //# sourceMappingURL=Fabric-t9Xqe4Bx.d.ts.map
366
+ //# sourceMappingURL=Fabric-C3xWWIb6.d.ts.map
@@ -1,5 +1,5 @@
1
1
  declare namespace KubbFile_d_exports {
2
- export { AdvancedPath, BaseName, Export, Extname, File, Import, Mode, OptionalPath, Path, ResolvedExport, ResolvedFile, ResolvedImport, Source };
2
+ export { AdvancedPath, BaseName, Export, Extname, File, Import, Mode, Path, ResolvedExport, ResolvedFile, ResolvedImport, Source };
3
3
  }
4
4
  type BasePath<T extends string = string> = `${T}/`;
5
5
  type Import = {
@@ -76,7 +76,6 @@ type BaseName = `${string}.${string}`;
76
76
  */
77
77
  type Path = string;
78
78
  type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
79
- type OptionalPath = Path | undefined | null;
80
79
  type File<TMeta extends object = object> = {
81
80
  /**
82
81
  * Name to be used to create the path
@@ -135,9 +134,16 @@ type Parser<TOptions = unknown, TMeta extends object = any> = {
135
134
  type UserParser<TOptions = unknown, TMeta extends object = any> = Omit<Parser<TOptions, TMeta>, 'type'>;
136
135
  //#endregion
137
136
  //#region ../fabric-core/src/utils/AsyncEventEmitter.d.ts
137
+ type Options$2 = {
138
+ mode?: FabricMode;
139
+ maxListener?: number;
140
+ };
138
141
  declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
139
142
  #private;
140
- constructor(maxListener?: number);
143
+ constructor({
144
+ maxListener,
145
+ mode
146
+ }?: Options$2);
141
147
  emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
142
148
  on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
143
149
  onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
@@ -220,36 +226,45 @@ declare global {
220
226
  interface Fabric {}
221
227
  }
222
228
  }
223
- type FabricOptions = {
229
+ /**
230
+ * Component placeholder type.
231
+ * May later be extended to support specific runtime renderers.
232
+ */
233
+
234
+ /**
235
+ * Defines core runtime options for Fabric.
236
+ */
237
+ interface FabricOptions {
224
238
  /**
239
+ * Determines how Fabric processes files.
240
+ * - `sequential`: files are processed one by one
241
+ * - `parallel`: files are processed concurrently
242
+ *
225
243
  * @default 'sequential'
226
244
  */
227
245
  mode?: FabricMode;
228
- };
229
- type FabricEvents = {
230
- /**
231
- * Called in the beginning of the app lifecycle.
232
- */
246
+ }
247
+ /**
248
+ * Available modes for file processing.
249
+ */
250
+ type FabricMode = 'sequential' | 'parallel';
251
+ /**
252
+ * Event definitions emitted during the Fabric lifecycle.
253
+ */
254
+ interface FabricEvents {
255
+ /** Called at the beginning of the app lifecycle. */
233
256
  start: [];
234
- /**
235
- * Called in the end of the app lifecycle.
236
- */
257
+ /** Called at the end of the app lifecycle. */
237
258
  end: [];
238
- /**
239
- * Called when being rendered
240
- */
259
+ /** Called when Fabric is rendering. */
241
260
  render: [{
242
261
  fabric: Fabric;
243
262
  }];
244
- /**
245
- * Called once before processing any files.
246
- */
263
+ /** Called once before any files are processed. */
247
264
  'process:start': [{
248
265
  files: ResolvedFile[];
249
266
  }];
250
- /**
251
- * Called when FileManager is adding files to its cache
252
- */
267
+ /** Called when files are added to the FileManager cache. */
253
268
  'file:add': [{
254
269
  files: ResolvedFile[];
255
270
  }];
@@ -259,24 +274,20 @@ type FabricEvents = {
259
274
  'write:end': [{
260
275
  files: ResolvedFile[];
261
276
  }];
262
- /**
263
- * Called for each file when processing begins.
264
- */
277
+ /** Called for each file when processing begins. */
265
278
  'file:start': [{
266
279
  file: ResolvedFile;
267
280
  index: number;
268
281
  total: number;
269
282
  }];
270
- /**
271
- * Called for each file when processing finishes.
272
- */
283
+ /** Called for each file when processing completes. */
273
284
  'file:end': [{
274
285
  file: ResolvedFile;
275
286
  index: number;
276
287
  total: number;
277
288
  }];
278
289
  /**
279
- * Called periodically (or after each file) to indicate progress.
290
+ * Called periodically (or per file) to indicate progress.
280
291
  * Useful for progress bars or logging.
281
292
  */
282
293
  'process:progress': [{
@@ -286,34 +297,67 @@ type FabricEvents = {
286
297
  source?: string;
287
298
  file: ResolvedFile;
288
299
  }];
289
- /**
290
- * Called once all files have been processed successfully.
291
- */
300
+ /** Called once all files have been processed successfully. */
292
301
  'process:end': [{
293
302
  files: ResolvedFile[];
294
303
  }];
295
- };
296
- type FabricContext<TOptions extends FabricOptions = FabricOptions> = {
297
- config?: FabricConfig<TOptions>;
304
+ }
305
+ /**
306
+ * Shared context passed to all plugins, parsers, and Fabric internals.
307
+ */
308
+ interface FabricContext<T extends FabricOptions = FabricOptions> extends AsyncEventEmitter<FabricEvents> {
309
+ /** The active Fabric configuration. */
310
+ config?: FabricConfig<T>;
311
+ /** The internal file manager handling file creation, merging, and writing. */
298
312
  fileManager: FileManager;
299
- files: Array<ResolvedFile>;
300
- addFile(...files: Array<File>): Promise<void>;
313
+ /** List of files currently in memory. */
314
+ files: ResolvedFile[];
315
+ /** Add new files to the file manager. */
316
+ addFile(...files: File[]): Promise<void>;
317
+ /** Track installed plugins and parsers to prevent duplicates. */
301
318
  installedPlugins: Set<Plugin>;
302
319
  installedParsers: Set<Parser>;
303
- } & AsyncEventEmitter<FabricEvents>;
304
- type FabricMode = 'sequential' | 'parallel';
320
+ }
321
+ /**
322
+ * Base configuration object for Fabric.
323
+ */
324
+ interface FabricConfig<T extends FabricOptions = FabricOptions> {
325
+ /** The runtime options used to configure Fabric. */
326
+ options: T;
327
+ }
328
+ /**
329
+ * Utility type that checks whether all properties of `T` are optional.
330
+ */
305
331
  type AllOptional<T> = {} extends T ? true : false;
306
- type FabricConfig<TOptions extends FabricOptions> = {
307
- options: TOptions;
308
- };
309
- type Install<TOptions = unknown> = TOptions extends any[] ? (context: FabricContext, ...options: TOptions) => void | Promise<void> : AllOptional<TOptions> extends true ? (context: FabricContext, options: TOptions | undefined) => void | Promise<void> : (context: FabricContext, options: TOptions) => void | Promise<void>;
310
- type Inject<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = TOptions extends any[] ? (context: FabricContext, ...options: TOptions) => Partial<TAppExtension> : AllOptional<TOptions> extends true ? (context: FabricContext, options: TOptions | undefined) => Partial<TAppExtension> : (context: FabricContext, options: TOptions) => Partial<TAppExtension>;
311
- interface Fabric<TOptions extends FabricOptions = FabricOptions> extends Kubb.Fabric {
312
- context: FabricContext<TOptions>;
313
- files: Array<ResolvedFile>;
314
- 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>;
315
- addFile(...files: Array<File>): Promise<void>;
332
+ /**
333
+ * Defines the signature of a plugin or parser's `install` function.
334
+ */
335
+ type Install<TOptions = unknown> = TOptions extends any[] ? (context: FabricContext, ...options: TOptions) => void | Promise<void> : AllOptional<TOptions> extends true ? (context: FabricContext, options?: TOptions) => void | Promise<void> : (context: FabricContext, options: TOptions) => void | Promise<void>;
336
+ /**
337
+ * Defines the signature of a plugin or parser's `inject` function.
338
+ * Returns an object that extends the Fabric instance.
339
+ */
340
+ type Inject<TOptions = unknown, TExtension extends Record<string, any> = {}> = TOptions extends any[] ? (context: FabricContext, ...options: TOptions) => Partial<TExtension> : AllOptional<TOptions> extends true ? (context: FabricContext, options?: TOptions) => Partial<TExtension> : (context: FabricContext, options: TOptions) => Partial<TExtension>;
341
+ /**
342
+ * The main Fabric runtime interface.
343
+ * Provides access to the current context, registered plugins, files, and utility methods.
344
+ */
345
+ interface Fabric<T extends FabricOptions = FabricOptions> extends Kubb.Fabric {
346
+ /** The shared context for this Fabric instance. */
347
+ context: FabricContext<T>;
348
+ /** The files managed by this Fabric instance. */
349
+ files: ResolvedFile[];
350
+ /**
351
+ * Install a plugin or parser into Fabric.
352
+ *
353
+ * @param target - The plugin or parser to install.
354
+ * @param options - Optional configuration or arguments for the target.
355
+ * @returns A Fabric instance extended by the plugin (if applicable).
356
+ */
357
+ use<TPluginOptions = unknown, TMeta extends object = object, TExtension extends Record<string, any> = {}>(target: Plugin<TPluginOptions, TExtension> | Parser<TPluginOptions, TMeta>, ...options: TPluginOptions extends any[] ? NoInfer<TPluginOptions> : AllOptional<TPluginOptions> extends true ? [NoInfer<TPluginOptions>?] : [NoInfer<TPluginOptions>]): (this & TExtension) | Promise<this & TExtension>;
358
+ /** Add one or more files to the Fabric file manager. */
359
+ addFile(...files: File[]): Promise<void>;
316
360
  }
317
361
  //#endregion
318
362
  export { KubbFile_d_exports as _, FabricOptions as a, Source as b, FileManager as c, UserParser as d, BaseName as f, Import as g, File as h, FabricMode as i, FileProcessor as l, Extname as m, FabricConfig as n, Plugin as o, Export as p, FabricContext as r, UserPlugin as s, Fabric as t, Parser as u, Path as v, ResolvedFile as y };
319
- //# sourceMappingURL=Fabric-BPUyMklG.d.cts.map
363
+ //# sourceMappingURL=Fabric-MsFHiZXy.d.cts.map
@@ -1,5 +1,5 @@
1
- import "./Fabric-BPUyMklG.cjs";
2
- import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-CsFxfaSV.cjs";
1
+ import "./Fabric-MsFHiZXy.cjs";
2
+ import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-g8BNi4jj.cjs";
3
3
  import React from "react";
4
4
 
5
5
  //#region src/globals.d.ts
package/dist/globals.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import "./Fabric-t9Xqe4Bx.js";
2
- import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-wwcxhf6Y.js";
1
+ import "./Fabric-C3xWWIb6.js";
2
+ import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-CJRSKjOD.js";
3
3
  import React from "react";
4
4
 
5
5
  //#region src/globals.d.ts
package/dist/index.d.cts CHANGED
@@ -1,11 +1,33 @@
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-BPUyMklG.cjs";
2
- import { a as JSDoc, b as DefineFabric, d as KubbNode, g as FunctionParams, o as Key, x as defineFabric, y as createFunctionParams } from "./types-CsFxfaSV.cjs";
3
- import { t as Options$1 } from "./reactPlugin-DlGI8_Sh.cjs";
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-MsFHiZXy.cjs";
2
+ import { a as JSDoc, d as KubbNode, g as FunctionParams, o as Key, y as createFunctionParams } from "./types-g8BNi4jj.cjs";
3
+ import { t as Options$1 } from "./reactPlugin-D8rqKtK0.cjs";
4
4
  import * as react0 from "react";
5
5
  import React, { Fragment, ReactNode, createContext, createElement, use, useContext, useEffect, useReducer, useRef, useState } from "react";
6
6
 
7
+ //#region ../fabric-core/src/defineFabric.d.ts
8
+ /**
9
+ * Function that initializes the root Fabric instance.
10
+ *
11
+ * Used for setting up plugins, parsers, or performing side effects
12
+ * once the Fabric context is ready.
13
+ */
14
+ type FabricInitializer<T extends FabricOptions> = (fabric: Fabric<T>) => void | Promise<void>;
15
+ /**
16
+ * A function returned by {@link defineFabric} that creates a Fabric instance.
17
+ */
18
+ type CreateFabric<T extends FabricOptions> = (config?: FabricConfig<T>) => Fabric<T>;
19
+ /**
20
+ * Defines a new Fabric factory function.
21
+ *
22
+ * @example
23
+ * export const createFabric = defineFabric((fabric) => {
24
+ * fabric.use(myPlugin())
25
+ * })
26
+ */
27
+ declare function defineFabric<T extends FabricOptions>(init?: FabricInitializer<T>): CreateFabric<T>;
28
+ //#endregion
7
29
  //#region ../fabric-core/src/createFabric.d.ts
8
- declare const createFabric: DefineFabric<FabricOptions>;
30
+ declare const createFabric: CreateFabric<FabricOptions>;
9
31
  //#endregion
10
32
  //#region ../fabric-core/src/createFile.d.ts
11
33
  /**
package/dist/index.d.ts CHANGED
@@ -1,11 +1,33 @@
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-t9Xqe4Bx.js";
2
- import { a as JSDoc, b as DefineFabric, d as KubbNode, g as FunctionParams, o as Key, x as defineFabric, y as createFunctionParams } from "./types-wwcxhf6Y.js";
3
- import { t as Options$1 } from "./reactPlugin-DmnHX7Uj.js";
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-C3xWWIb6.js";
2
+ import { a as JSDoc, d as KubbNode, g as FunctionParams, o as Key, y as createFunctionParams } from "./types-CJRSKjOD.js";
3
+ import { t as Options$1 } from "./reactPlugin-DY-MH4LN.js";
4
4
  import * as react0 from "react";
5
5
  import React, { Fragment, ReactNode, createContext, createElement, use, useContext, useEffect, useReducer, useRef, useState } from "react";
6
6
 
7
+ //#region ../fabric-core/src/defineFabric.d.ts
8
+ /**
9
+ * Function that initializes the root Fabric instance.
10
+ *
11
+ * Used for setting up plugins, parsers, or performing side effects
12
+ * once the Fabric context is ready.
13
+ */
14
+ type FabricInitializer<T extends FabricOptions> = (fabric: Fabric<T>) => void | Promise<void>;
15
+ /**
16
+ * A function returned by {@link defineFabric} that creates a Fabric instance.
17
+ */
18
+ type CreateFabric<T extends FabricOptions> = (config?: FabricConfig<T>) => Fabric<T>;
19
+ /**
20
+ * Defines a new Fabric factory function.
21
+ *
22
+ * @example
23
+ * export const createFabric = defineFabric((fabric) => {
24
+ * fabric.use(myPlugin())
25
+ * })
26
+ */
27
+ declare function defineFabric<T extends FabricOptions>(init?: FabricInitializer<T>): CreateFabric<T>;
28
+ //#endregion
7
29
  //#region ../fabric-core/src/createFabric.d.ts
8
- declare const createFabric: DefineFabric<FabricOptions>;
30
+ declare const createFabric: CreateFabric<FabricOptions>;
9
31
  //#endregion
10
32
  //#region ../fabric-core/src/createFile.d.ts
11
33
  /**
@@ -1,6 +1,6 @@
1
- import "./Fabric-BPUyMklG.cjs";
2
- import { d as KubbNode, s as KubbElement } from "./types-CsFxfaSV.cjs";
3
- import { t as JSX } from "./jsx-namespace-YR433DXc.cjs";
1
+ import "./Fabric-MsFHiZXy.cjs";
2
+ import { d as KubbNode, s as KubbElement } from "./types-g8BNi4jj.cjs";
3
+ import { t as JSX } from "./jsx-namespace-laCWw619.cjs";
4
4
  import { Fragment, jsxDEV } from "react/jsx-dev-runtime";
5
5
 
6
6
  //#region src/jsx-dev-runtime.d.ts
@@ -1,6 +1,6 @@
1
- import "./Fabric-t9Xqe4Bx.js";
2
- import { d as KubbNode, s as KubbElement } from "./types-wwcxhf6Y.js";
3
- import { t as JSX } from "./jsx-namespace-PEMxmJ6z.js";
1
+ import "./Fabric-C3xWWIb6.js";
2
+ import { d as KubbNode, s as KubbElement } from "./types-CJRSKjOD.js";
3
+ import { t as JSX } from "./jsx-namespace-Cz6OfCDG.js";
4
4
  import { Fragment, jsxDEV } from "react/jsx-dev-runtime";
5
5
 
6
6
  //#region src/jsx-dev-runtime.d.ts
@@ -1,4 +1,4 @@
1
- import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-wwcxhf6Y.js";
1
+ import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-CJRSKjOD.js";
2
2
  import React from "react";
3
3
 
4
4
  //#region src/jsx-namespace.d.ts
@@ -28,4 +28,4 @@ declare namespace JSX$1 {
28
28
  }
29
29
  //#endregion
30
30
  export { JSX$1 as t };
31
- //# sourceMappingURL=jsx-namespace-PEMxmJ6z.d.ts.map
31
+ //# sourceMappingURL=jsx-namespace-Cz6OfCDG.d.ts.map
@@ -1,4 +1,4 @@
1
- import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-CsFxfaSV.cjs";
1
+ import { c as KubbExportProps, d as KubbNode, f as KubbSourceProps, l as KubbFileProps, m as LineBreakProps, p as KubbTextProps, s as KubbElement, u as KubbImportProps } from "./types-g8BNi4jj.cjs";
2
2
  import React from "react";
3
3
 
4
4
  //#region src/jsx-namespace.d.ts
@@ -28,4 +28,4 @@ declare namespace JSX$1 {
28
28
  }
29
29
  //#endregion
30
30
  export { JSX$1 as t };
31
- //# sourceMappingURL=jsx-namespace-YR433DXc.d.cts.map
31
+ //# sourceMappingURL=jsx-namespace-laCWw619.d.cts.map
@@ -1,6 +1,6 @@
1
- import "./Fabric-BPUyMklG.cjs";
2
- import { d as KubbNode, s as KubbElement } from "./types-CsFxfaSV.cjs";
3
- import { t as JSX } from "./jsx-namespace-YR433DXc.cjs";
1
+ import "./Fabric-MsFHiZXy.cjs";
2
+ import { d as KubbNode, s as KubbElement } from "./types-g8BNi4jj.cjs";
3
+ import { t as JSX } from "./jsx-namespace-laCWw619.cjs";
4
4
  import { jsxDEV } from "react/jsx-dev-runtime";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
 
@@ -1,6 +1,6 @@
1
- import "./Fabric-t9Xqe4Bx.js";
2
- import { d as KubbNode, s as KubbElement } from "./types-wwcxhf6Y.js";
3
- import { t as JSX } from "./jsx-namespace-PEMxmJ6z.js";
1
+ import "./Fabric-C3xWWIb6.js";
2
+ import { d as KubbNode, s as KubbElement } from "./types-CJRSKjOD.js";
3
+ import { t as JSX } from "./jsx-namespace-Cz6OfCDG.js";
4
4
  import { jsxDEV } from "react/jsx-dev-runtime";
5
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
 
@@ -1,4 +1,4 @@
1
- import { d as UserParser, u as Parser } from "./Fabric-BPUyMklG.cjs";
1
+ import { d as UserParser, u as Parser } from "./Fabric-MsFHiZXy.cjs";
2
2
 
3
3
  //#region ../fabric-core/src/parsers/createParser.d.ts
4
4
  declare function createParser<TOptions = unknown, TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta>;
package/dist/parsers.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { d as UserParser, u as Parser } from "./Fabric-t9Xqe4Bx.js";
1
+ import { d as UserParser, u as Parser } from "./Fabric-C3xWWIb6.js";
2
2
 
3
3
  //#region ../fabric-core/src/parsers/createParser.d.ts
4
4
  declare function createParser<TOptions = unknown, TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta>;
@@ -1,5 +1,5 @@
1
- import { m as Extname, o as Plugin, s as UserPlugin } from "./Fabric-BPUyMklG.cjs";
2
- import { n as reactPlugin } from "./reactPlugin-DlGI8_Sh.cjs";
1
+ import { m as Extname, o as Plugin, s as UserPlugin } from "./Fabric-MsFHiZXy.cjs";
2
+ import { n as reactPlugin } from "./reactPlugin-D8rqKtK0.cjs";
3
3
 
4
4
  //#region ../fabric-core/src/plugins/barrelPlugin.d.ts
5
5
  type Mode = 'all' | 'named' | 'propagate' | false;
@@ -15,11 +15,6 @@ type WriteEntryOptions = {
15
15
  type ExtendOptions$1 = {
16
16
  writeEntry(options: WriteEntryOptions): Promise<void>;
17
17
  };
18
- declare module '@kubb/fabric-core' {
19
- interface Fabric {
20
- writeEntry(options: WriteEntryOptions): Promise<void>;
21
- }
22
- }
23
18
  declare global {
24
19
  namespace Kubb {
25
20
  interface Fabric {
@@ -50,11 +45,6 @@ type Options$1 = {
50
45
  type ExtendOptions = {
51
46
  write(options?: WriteOptions): Promise<void>;
52
47
  };
53
- declare module '@kubb/fabric-core' {
54
- interface Fabric {
55
- write(options?: WriteOptions): Promise<void>;
56
- }
57
- }
58
48
  declare global {
59
49
  namespace Kubb {
60
50
  interface Fabric {
package/dist/plugins.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { m as Extname, o as Plugin, s as UserPlugin } from "./Fabric-t9Xqe4Bx.js";
2
- import { n as reactPlugin } from "./reactPlugin-DmnHX7Uj.js";
1
+ import { m as Extname, o as Plugin, s as UserPlugin } from "./Fabric-C3xWWIb6.js";
2
+ import { n as reactPlugin } from "./reactPlugin-DY-MH4LN.js";
3
3
 
4
4
  //#region ../fabric-core/src/plugins/barrelPlugin.d.ts
5
5
  type Mode = 'all' | 'named' | 'propagate' | false;
@@ -15,11 +15,6 @@ type WriteEntryOptions = {
15
15
  type ExtendOptions$1 = {
16
16
  writeEntry(options: WriteEntryOptions): Promise<void>;
17
17
  };
18
- declare module '@kubb/fabric-core' {
19
- interface Fabric {
20
- writeEntry(options: WriteEntryOptions): Promise<void>;
21
- }
22
- }
23
18
  declare global {
24
19
  namespace Kubb {
25
20
  interface Fabric {
@@ -50,11 +45,6 @@ type Options$1 = {
50
45
  type ExtendOptions = {
51
46
  write(options?: WriteOptions): Promise<void>;
52
47
  };
53
- declare module '@kubb/fabric-core' {
54
- interface Fabric {
55
- write(options?: WriteOptions): Promise<void>;
56
- }
57
- }
58
48
  declare global {
59
49
  namespace Kubb {
60
50
  interface Fabric {
@@ -1 +1 @@
1
- {"version":3,"file":"reactPlugin-BmBx9cO3.js","names":["onExit","node: TextNode","nodeNames: Array<ElementNames>","text","file: KubbFile.File"],"sources":["../src/components/Root.tsx","../src/dom.ts","../src/Renderer.ts","../src/utils/squashExportNodes.ts","../src/utils/squashImportNodes.ts","../src/utils/squashTextNodes.ts","../src/utils/squashSourceNodes.ts","../src/utils/processFiles.ts","../src/Runtime.tsx","../src/plugins/reactPlugin.ts"],"sourcesContent":["import { Component, createContext } from 'react'\n\nimport type { KubbNode } from '../types.ts'\n\ntype ErrorBoundaryProps = {\n onError: (error: Error) => void\n children?: KubbNode\n}\n\nclass ErrorBoundary extends Component<{\n onError: ErrorBoundaryProps['onError']\n children?: KubbNode\n}> {\n state = { hasError: false }\n\n static displayName = 'KubbErrorBoundary'\n static getDerivedStateFromError(_error: Error) {\n return { hasError: true }\n }\n\n componentDidCatch(error: Error) {\n if (error) {\n this.props.onError(error)\n }\n }\n\n render() {\n if (this.state.hasError) {\n return null\n }\n return this.props.children\n }\n}\n\nexport type RootContextProps = {\n /**\n * Exit (unmount) the whole Ink app.\n */\n readonly exit: (error?: Error) => void\n}\n\nexport const RootContext = createContext<RootContextProps>({\n exit: () => {},\n})\n\ntype RootProps = {\n /**\n * Exit (unmount) hook\n */\n readonly onExit: (error?: Error) => void\n /**\n * Error hook\n */\n readonly onError: (error: Error) => void\n readonly children?: KubbNode\n}\n\nexport function Root({ onError, onExit, children }: RootProps) {\n try {\n return (\n <ErrorBoundary\n onError={(error) => {\n onError(error)\n }}\n >\n <RootContext.Provider value={{ exit: onExit }}>{children}</RootContext.Provider>\n </ErrorBoundary>\n )\n } catch (_e) {\n return null\n }\n}\n\nRoot.Context = RootContext\nRoot.displayName = 'KubbRoot'\n","import type { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\n\nexport const createNode = (nodeName: string): DOMElement => {\n const node: DOMElement = {\n nodeName: nodeName as DOMElement['nodeName'],\n attributes: {},\n childNodes: [],\n parentNode: undefined,\n }\n\n return node\n}\n\nexport const appendChildNode = (node: DOMNode, childNode: DOMElement | DOMNode): void => {\n if (childNode.parentNode) {\n removeChildNode(childNode.parentNode, childNode)\n }\n\n if (node.nodeName !== '#text') {\n childNode.parentNode = node\n node.childNodes.push(childNode)\n }\n}\n\nexport const insertBeforeNode = (node: DOMElement, newChildNode: DOMNode, beforeChildNode: DOMNode): void => {\n if (newChildNode.parentNode) {\n removeChildNode(newChildNode.parentNode, newChildNode)\n }\n\n newChildNode.parentNode = node\n\n const index = node.childNodes.indexOf(beforeChildNode)\n if (index >= 0) {\n node.childNodes.splice(index, 0, newChildNode)\n\n return\n }\n\n node.childNodes.push(newChildNode)\n}\n\nexport const removeChildNode = (node: DOMElement, removeNode: DOMNode): void => {\n removeNode.parentNode = undefined\n\n const index = node.childNodes.indexOf(removeNode)\n if (index >= 0) {\n node.childNodes.splice(index, 1)\n }\n}\n\nexport const setAttribute = (node: DOMElement, key: string, value: DOMNodeAttribute): void => {\n node.attributes[key] = value\n}\n\nexport const createTextNode = (text: string): TextNode => {\n const node: TextNode = {\n nodeName: '#text',\n nodeValue: text,\n parentNode: undefined,\n }\n\n setTextNodeValue(node, text)\n\n return node\n}\n\nexport const setTextNodeValue = (node: TextNode, text: string): void => {\n if (typeof text !== 'string') {\n text = String(text)\n }\n\n node.nodeValue = text\n}\n\nexport const nodeNames: Array<ElementNames> = ['kubb-export', 'kubb-file', 'kubb-source', 'kubb-import', 'kubb-text']\n","import { createContext } from 'react'\nimport Reconciler, { type ReactContext } from 'react-reconciler'\nimport { DefaultEventPriority, NoEventPriority } from 'react-reconciler/constants.js'\nimport { appendChildNode, createNode, createTextNode, insertBeforeNode, removeChildNode, setAttribute, setTextNodeValue } from './dom.ts'\nimport type { KubbNode } from './types'\nimport type { DOMElement, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\n\ndeclare module 'react-reconciler' {\n // @ts-expect-error custom override\n interface Reconciler {\n updateContainerSync(element: KubbNode, container: unknown, parentComponent: any, callback?: null | (() => void)): void\n flushSyncWork(): void\n createContainer(\n containerInfo: unknown,\n tag: Reconciler.RootTag,\n hydrationCallbacks: null | Reconciler.SuspenseHydrationCallbacks<any>,\n isStrictMode: boolean,\n concurrentUpdatesByDefaultOverride: null | boolean,\n identifierPrefix: string,\n onUncaughtError: (error: Error) => void,\n onCaughtError: (error: Error) => void,\n onRecoverableError: (error: Error) => void,\n transitionCallbacks: null | Reconciler.TransitionTracingCallbacks,\n ): Reconciler.OpaqueRoot\n }\n}\n\ntype Props = Record<string, unknown>\n\ntype HostContext = {\n type: ElementNames\n isFile: boolean\n isSource: boolean\n}\n\nlet currentUpdatePriority = NoEventPriority\n\n/**\n * @link https://www.npmjs.com/package/react-devtools-inline\n * @link https://github.com/nitin42/Making-a-custom-React-renderer/blob/master/part-one.md\n * @link https://github.com/facebook/react/tree/main/packages/react-reconciler#practical-examples\n * @link https://github.com/vadimdemedes/ink\n * @link https://github.com/pixijs/pixi-react/tree/main/packages\n * @link https://github.com/diegomura/react-pdf/blob/master/packages/reconciler/src/reconciler-31.ts\n */\nexport const Renderer = Reconciler({\n getRootHostContext: () => ({\n type: 'kubb-root',\n isFile: false,\n isSource: false,\n }),\n prepareForCommit: () => {\n return null\n },\n preparePortalMount: () => null,\n clearContainer: () => false,\n resetAfterCommit(rootNode: DOMElement) {\n if (typeof rootNode.onRender === 'function') {\n rootNode.onRender()\n }\n },\n getChildHostContext(parentHostContext: HostContext, type: ElementNames) {\n const isInsideText = type === 'kubb-text'\n const isFile = type === 'kubb-file' || parentHostContext.isFile\n const isSource = type === 'kubb-source' || parentHostContext.isSource\n\n return { isInsideText, isFile, isSource, type }\n },\n shouldSetTextContent: () => false,\n createInstance(originalType: ElementNames, newProps: Props, _root: DOMElement) {\n const node = createNode(originalType)\n\n for (const [key, value] of Object.entries(newProps)) {\n if (key === 'children') {\n continue\n }\n\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n\n return node\n },\n createTextInstance(text: string, _root: DOMElement, hostContext: HostContext) {\n if (hostContext.isFile && !hostContext.isSource) {\n throw new Error(`[react] '${text}' should be part of <File.Source> component when using the <File/> component`)\n }\n\n return createTextNode(text)\n },\n resetTextContent() {},\n hideTextInstance(node: TextNode) {\n setTextNodeValue(node, '')\n },\n unhideTextInstance(node: TextNode, text: string) {\n setTextNodeValue(node, text)\n },\n getPublicInstance: (instance) => instance,\n appendInitialChild: appendChildNode,\n appendChild: appendChildNode,\n insertBefore: insertBeforeNode,\n finalizeInitialChildren(_node, _type, _props, _rootNode) {\n return false\n },\n supportsMutation: true,\n isPrimaryRenderer: true,\n supportsPersistence: false,\n supportsHydration: false,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n beforeActiveInstanceBlur() {},\n afterActiveInstanceBlur() {},\n detachDeletedInstance() {},\n getInstanceFromNode: () => null,\n prepareScopeUpdate() {},\n getInstanceFromScope: () => null,\n appendChildToContainer: appendChildNode,\n insertInContainerBefore: insertBeforeNode,\n removeChildFromContainer(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n commitMount() {},\n commitUpdate(node: DOMElement, _payload, _type, _oldProps: Props, newProps: Props) {\n const { props } = newProps\n\n if (props) {\n for (const [key, value] of Object.entries(props)) {\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n }\n },\n commitTextUpdate(node: TextNode, _oldText, newText) {\n setTextNodeValue(node, newText)\n },\n removeChild(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n setCurrentUpdatePriority: (newPriority: number) => {\n currentUpdatePriority = newPriority\n },\n getCurrentUpdatePriority: () => currentUpdatePriority,\n resolveUpdatePriority() {\n if (currentUpdatePriority !== NoEventPriority) {\n return currentUpdatePriority\n }\n\n return DefaultEventPriority\n },\n maySuspendCommit() {\n return false\n },\n // eslint-disable-next-line @typescript-eslint/naming-convention\n NotPendingTransition: undefined,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HostTransitionContext: createContext(null) as unknown as ReactContext<unknown>,\n resetFormInstance() {},\n requestPostPaintCallback() {},\n shouldAttemptEagerTransition() {\n return false\n },\n trackSchedulerEvent() {},\n resolveEventType() {\n return null\n },\n resolveEventTimeStamp() {\n return -1.1\n },\n preloadInstance() {\n return true\n },\n startSuspendingCommit() {},\n suspendInstance() {},\n waitForCommitToBeReady() {\n return null\n },\n})\n\nexport type { FiberRoot } from 'react-reconciler'\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashExportNodes(node: DOMElement): Set<KubbFile.ResolvedExport> {\n let exports = new Set<KubbFile.Export>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n exports = new Set([...exports, ...squashExportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n exports.add(attributes)\n }\n })\n\n return exports\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashImportNodes(node: DOMElement): Set<KubbFile.Import> {\n let imports = new Set<KubbFile.Import>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n imports = new Set([...imports, ...squashImportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n imports.add(attributes)\n }\n })\n\n return imports\n}\n","import { createExport, createImport, print } from '@kubb/fabric-core/parsers/typescript'\n\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashTextNodes(node: DOMElement): string {\n let text = ''\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n let nodeText = ''\n\n const getPrintText = (text: string): string => {\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n\n return print([\n createImport({\n name: attributes.name,\n path: attributes.path,\n root: attributes.root,\n isTypeOnly: attributes.isTypeOnly,\n }),\n ])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n if (attributes.path) {\n return print([\n createExport({\n name: attributes.name,\n path: attributes.path,\n isTypeOnly: attributes.isTypeOnly,\n asAlias: attributes.asAlias,\n }),\n ])\n }\n }\n\n if (childNode.nodeName === 'kubb-source') {\n return text\n }\n\n return text\n }\n\n if (childNode.nodeName === '#text') {\n nodeText = childNode.nodeValue\n } else {\n if (['kubb-text', 'kubb-file', 'kubb-source'].includes(childNode.nodeName)) {\n nodeText = squashTextNodes(childNode)\n }\n\n nodeText = getPrintText(nodeText)\n\n if (childNode.nodeName === 'br') {\n nodeText = '\\n'\n }\n\n // no kubb element or br\n if (![...nodeNames, 'br'].includes(childNode.nodeName)) {\n const attributes = Object.entries(childNode.attributes).reduce((acc, [key, value]) => {\n if (typeof value === 'string') {\n return `${acc} ${key}=\"${value}\"`\n }\n\n return `${acc} ${key}={${value}}`\n }, '')\n nodeText = `<${childNode.nodeName}${attributes}>${squashTextNodes(childNode)}</${childNode.nodeName}>`\n }\n }\n\n text += nodeText\n }\n\n return text\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement, ElementNames } from '../types.ts'\nimport { squashTextNodes } from './squashTextNodes.ts'\n\nexport function squashSourceNodes(node: DOMElement, ignores: Array<ElementNames>): Set<KubbFile.Source> {\n let sources = new Set<KubbFile.Source>()\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && ignores.includes(childNode.nodeName)) {\n continue\n }\n\n if (childNode.nodeName === 'kubb-source') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Source>\n const value = squashTextNodes(childNode)\n\n sources.add({\n ...attributes,\n // remove end enter\n value: value.trim().replace(/^\\s+|\\s+$/g, ''),\n })\n\n continue\n }\n\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n sources = new Set([...sources, ...squashSourceNodes(childNode, ignores)])\n }\n }\n\n return sources\n}\n","import type { FileManager } from '@kubb/fabric-core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\nimport { squashExportNodes } from './squashExportNodes.ts'\nimport { squashImportNodes } from './squashImportNodes.ts'\nimport { squashSourceNodes } from './squashSourceNodes.ts'\n\nexport function processFiles(node: DOMElement, fileManager: FileManager) {\n for (let index = 0; index < node.childNodes.length; index++) {\n const childNode = node.childNodes[index]\n\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && childNode.nodeName !== 'kubb-file' && nodeNames.includes(childNode.nodeName)) {\n processFiles(childNode, fileManager)\n }\n\n if (childNode.nodeName === 'kubb-file') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File>\n\n if (attributes.baseName && attributes.path) {\n const sources = squashSourceNodes(childNode, ['kubb-export', 'kubb-import'])\n\n const file: KubbFile.File = {\n baseName: attributes.baseName,\n path: attributes.path,\n sources: [...sources],\n exports: [...squashExportNodes(childNode)],\n imports: [...squashImportNodes(childNode)],\n meta: attributes.meta || {},\n footer: attributes.footer,\n banner: attributes.banner,\n }\n\n fileManager.add(file)\n }\n }\n }\n}\n","import process from 'node:process'\nimport type { FileManager } from '@kubb/fabric-core'\nimport type { ReactNode } from 'react'\nimport { ConcurrentRoot } from 'react-reconciler/constants.js'\nimport { onExit } from 'signal-exit'\nimport { Root } from './components/Root.tsx'\nimport { createNode } from './dom.ts'\nimport type { FiberRoot } from './Renderer.ts'\nimport { Renderer } from './Renderer.ts'\nimport type { DOMElement } from './types.ts'\nimport { processFiles } from './utils/processFiles.ts'\nimport { squashTextNodes } from './utils/squashTextNodes.ts'\n\ntype Options = {\n fileManager: FileManager\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\nexport class Runtime {\n readonly #options: Options\n // Ignore last render after unmounting a tree to prevent empty output before exit\n #isUnmounted: boolean\n\n exitPromise?: Promise<void>\n readonly #container: FiberRoot\n readonly #rootNode: DOMElement\n\n constructor(options: Options) {\n this.#options = options\n\n this.#rootNode = createNode('kubb-root')\n this.#rootNode.onRender = this.onRender\n this.#rootNode.onImmediateRender = this.onRender\n\n // Ignore last render after unmounting a tree to prevent empty output before exit\n this.#isUnmounted = false\n this.unmount.bind(this)\n\n const originalError = console.error\n console.error = (data: string | Error) => {\n const message = typeof data === 'string' ? data : data?.message\n\n if (message?.match(/Encountered two children with the same key/gi)) {\n return\n }\n if (message?.match(/React will try to recreat/gi)) {\n return\n }\n if (message?.match(/Each child in a list should have a unique/gi)) {\n return\n }\n if (message?.match(/The above error occurred in the <KubbErrorBoundary/gi)) {\n return\n }\n\n if (message?.match(/A React Element from an older version of React was render/gi)) {\n return\n }\n\n originalError(data)\n }\n\n // Report when an error was detected in a previous render\n // https://github.com/pmndrs/react-three-fiber/pull/2261\n const logRecoverableError =\n typeof reportError === 'function'\n ? // In modern browsers, reportError will dispatch an error event,\n // emulating an uncaught JavaScript error.\n reportError\n : // In older browsers and test environments, fallback to console.error.\n console.error\n\n const rootTag = ConcurrentRoot\n const hydrationCallbacks = null\n const isStrictMode = false\n const concurrentUpdatesByDefaultOverride = false\n const identifierPrefix = 'id'\n const onUncaughtError = logRecoverableError\n const onCaughtError = logRecoverableError\n const onRecoverableError = logRecoverableError\n const transitionCallbacks = null\n\n this.#container = Renderer.createContainer(\n this.#rootNode,\n rootTag,\n hydrationCallbacks,\n isStrictMode,\n concurrentUpdatesByDefaultOverride,\n identifierPrefix,\n onUncaughtError,\n onCaughtError,\n onRecoverableError,\n transitionCallbacks,\n )\n\n // Unmount when process exits\n this.unsubscribeExit = onExit(\n (code) => {\n this.unmount(code)\n },\n { alwaysLast: false },\n ).bind(this)\n\n Renderer.injectIntoDevTools({\n bundleType: 1, // 0 for PROD, 1 for DEV\n version: '19.1.0', // should be React version and not Kubb's custom version\n rendererPackageName: 'kubb', // package name\n })\n }\n\n get fileManager() {\n return this.#options.fileManager\n }\n\n resolveExitPromise: () => void = () => {}\n rejectExitPromise: (reason?: Error) => void = () => {}\n unsubscribeExit: () => void = () => {}\n onRender: () => void = async () => {\n if (this.#isUnmounted) {\n return\n }\n\n // TODO remove to allow multiple renders\n this.fileManager.clear()\n\n processFiles(this.#rootNode, this.fileManager)\n\n if (!this.#options?.debug && !this.#options?.stdout) {\n return\n }\n\n const output = await this.#getOutput(this.#rootNode)\n\n if (this.#options?.debug) {\n console.log('Rendering: \\n')\n console.log(output)\n }\n\n if (this.#options?.stdout && process.env.NODE_ENV !== 'test') {\n this.#options.stdout.clearLine(0)\n this.#options.stdout.cursorTo(0)\n this.#options.stdout.write(output)\n }\n }\n onError(error: Error): void {\n if (process.env.NODE_ENV === 'test') {\n console.warn(error)\n }\n\n throw error\n }\n onExit(error?: Error): void {\n this.unmount(error)\n }\n\n async #getOutput(node: DOMElement): Promise<string> {\n const text = squashTextNodes(node)\n const files = this.fileManager.files\n\n return files.length\n ? [...files]\n .flatMap((file) => [...file.sources].map((item) => item.value))\n .filter(Boolean)\n .join('\\n\\n')\n : text\n }\n\n render(node: ReactNode): void {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n }\n\n async renderToString(node: ReactNode): Promise<string> {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n\n this.fileManager.clear()\n\n return this.#getOutput(this.#rootNode)\n }\n\n unmount(error?: Error | number | null): void {\n if (this.#isUnmounted) {\n return\n }\n\n if (this.#options?.debug) {\n console.log('Unmount', error)\n }\n\n this.onRender()\n this.unsubscribeExit()\n\n this.#isUnmounted = true\n\n Renderer.updateContainerSync(null, this.#container, null, null)\n\n if (error instanceof Error) {\n this.rejectExitPromise(error)\n\n return\n }\n\n this.resolveExitPromise()\n }\n\n async waitUntilExit(): Promise<void> {\n if (!this.exitPromise) {\n this.exitPromise = new Promise((resolve, reject) => {\n this.resolveExitPromise = resolve\n this.rejectExitPromise = reject\n })\n }\n\n return this.exitPromise\n }\n}\n","import { createPlugin } from '@kubb/fabric-core/plugins'\nimport { createElement, type ElementType } from 'react'\nimport { Runtime } from '../Runtime.tsx'\n\nexport type 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 Fabric {\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 Fabric {\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(ctx, options = {}) {\n const runtime = new Runtime({ fileManager: ctx.fileManager, ...options })\n\n return {\n async render(App) {\n runtime.render(createElement(App))\n await ctx.emit('start')\n },\n async renderToString(App) {\n await ctx.emit('start')\n return runtime.renderToString(createElement(App))\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n\n await ctx.emit('end')\n },\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAM,gBAAN,cAA4B,UAGzB;;;wBACD,SAAQ,EAAE,UAAU,OAAO;;CAG3B,OAAO,yBAAyB,QAAe;AAC7C,SAAO,EAAE,UAAU,MAAM;;CAG3B,kBAAkB,OAAc;AAC9B,MAAI,MACF,MAAK,MAAM,QAAQ,MAAM;;CAI7B,SAAS;AACP,MAAI,KAAK,MAAM,SACb,QAAO;AAET,SAAO,KAAK,MAAM;;;+BAfb,eAAc;AA0BvB,MAAa,cAAc,cAAgC,EACzD,YAAY,IACb,CAAC;AAcF,SAAgB,KAAK,EAAE,SAAS,kBAAQ,YAAuB;AAC7D,KAAI;AACF,SACE,oBAAC;GACC,UAAU,UAAU;AAClB,YAAQ,MAAM;;aAGhB,oBAAC,YAAY;IAAS,OAAO,EAAE,MAAMA,UAAQ;IAAG;KAAgC;IAClE;UAEX,IAAI;AACX,SA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AExB,WAAS,oBAAoB,yCAAM,KAAe,EAAE,MAAM,KAAK;AAE/D,MAAI,iBAAiB,OAAO;AAC1B,QAAK,kBAAkB,MAAM;AAE7B;;AAGF,OAAK,oBAAoB;;CAG3B,MAAM,gBAA+B;AACnC,MAAI,CAAC,KAAK,YACR,MAAK,cAAc,IAAI,SAAS,SAAS,WAAW;AAClD,QAAK,qBAAqB;AAC1B,QAAK,oBAAoB;IACzB;AAGJ,SAAO,KAAK;;;AAvEd,0BAAiB,MAAmC;CAClD,MAAM,OAAO,gBAAgB,KAAK;CAClC,MAAM,QAAQ,KAAK,YAAY;AAE/B,QAAO,MAAM,SACT,CAAC,GAAG,MAAM,CACP,SAAS,SAAS,CAAC,GAAG,KAAK,QAAQ,CAAC,KAAK,SAAS,KAAK,MAAM,CAAC,CAC9D,OAAO,QAAQ,CACf,KAAK,OAAO,GACf;;;;;AClIR,MAAa,cAAc,aAAqC;CAC9D,MAAM;CACN,UAAU;CACV,OAAO,KAAK,UAAU,EAAE,EAAE;EACxB,MAAM,UAAU,IAAI,QAAQ;GAAE,aAAa,IAAI;GAAa,GAAG;GAAS,CAAC;AAEzE,SAAO;GACL,MAAM,OAAO,KAAK;AAChB,YAAQ,OAAO,cAAc,IAAI,CAAC;AAClC,UAAM,IAAI,KAAK,QAAQ;;GAEzB,MAAM,eAAe,KAAK;AACxB,UAAM,IAAI,KAAK,QAAQ;AACvB,WAAO,QAAQ,eAAe,cAAc,IAAI,CAAC;;GAEnD,MAAM,gBAAgB;AACpB,UAAM,QAAQ,eAAe;AAE7B,UAAM,IAAI,KAAK,MAAM;;GAExB;;CAEJ,CAAC"}
1
+ {"version":3,"file":"reactPlugin-BmBx9cO3.js","names":["onExit","node: TextNode","nodeNames: Array<ElementNames>","text","file: KubbFile.File"],"sources":["../src/components/Root.tsx","../src/dom.ts","../src/Renderer.ts","../src/utils/squashExportNodes.ts","../src/utils/squashImportNodes.ts","../src/utils/squashTextNodes.ts","../src/utils/squashSourceNodes.ts","../src/utils/processFiles.ts","../src/Runtime.tsx","../src/plugins/reactPlugin.ts"],"sourcesContent":["import { Component, createContext } from 'react'\n\nimport type { KubbNode } from '../types.ts'\n\ntype ErrorBoundaryProps = {\n onError: (error: Error) => void\n children?: KubbNode\n}\n\nclass ErrorBoundary extends Component<{\n onError: ErrorBoundaryProps['onError']\n children?: KubbNode\n}> {\n state = { hasError: false }\n\n static displayName = 'KubbErrorBoundary'\n static getDerivedStateFromError(_error: Error) {\n return { hasError: true }\n }\n\n componentDidCatch(error: Error) {\n if (error) {\n this.props.onError(error)\n }\n }\n\n render() {\n if (this.state.hasError) {\n return null\n }\n return this.props.children\n }\n}\n\nexport type RootContextProps = {\n /**\n * Exit (unmount) the whole Ink app.\n */\n readonly exit: (error?: Error) => void\n}\n\nexport const RootContext = createContext<RootContextProps>({\n exit: () => {},\n})\n\ntype RootProps = {\n /**\n * Exit (unmount) hook\n */\n readonly onExit: (error?: Error) => void\n /**\n * Error hook\n */\n readonly onError: (error: Error) => void\n readonly children?: KubbNode\n}\n\nexport function Root({ onError, onExit, children }: RootProps) {\n try {\n return (\n <ErrorBoundary\n onError={(error) => {\n onError(error)\n }}\n >\n <RootContext.Provider value={{ exit: onExit }}>{children}</RootContext.Provider>\n </ErrorBoundary>\n )\n } catch (_e) {\n return null\n }\n}\n\nRoot.Context = RootContext\nRoot.displayName = 'KubbRoot'\n","import type { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\n\nexport const createNode = (nodeName: string): DOMElement => {\n const node: DOMElement = {\n nodeName: nodeName as DOMElement['nodeName'],\n attributes: {},\n childNodes: [],\n parentNode: undefined,\n }\n\n return node\n}\n\nexport const appendChildNode = (node: DOMNode, childNode: DOMElement | DOMNode): void => {\n if (childNode.parentNode) {\n removeChildNode(childNode.parentNode, childNode)\n }\n\n if (node.nodeName !== '#text') {\n childNode.parentNode = node\n node.childNodes.push(childNode)\n }\n}\n\nexport const insertBeforeNode = (node: DOMElement, newChildNode: DOMNode, beforeChildNode: DOMNode): void => {\n if (newChildNode.parentNode) {\n removeChildNode(newChildNode.parentNode, newChildNode)\n }\n\n newChildNode.parentNode = node\n\n const index = node.childNodes.indexOf(beforeChildNode)\n if (index >= 0) {\n node.childNodes.splice(index, 0, newChildNode)\n\n return\n }\n\n node.childNodes.push(newChildNode)\n}\n\nexport const removeChildNode = (node: DOMElement, removeNode: DOMNode): void => {\n removeNode.parentNode = undefined\n\n const index = node.childNodes.indexOf(removeNode)\n if (index >= 0) {\n node.childNodes.splice(index, 1)\n }\n}\n\nexport const setAttribute = (node: DOMElement, key: string, value: DOMNodeAttribute): void => {\n node.attributes[key] = value\n}\n\nexport const createTextNode = (text: string): TextNode => {\n const node: TextNode = {\n nodeName: '#text',\n nodeValue: text,\n parentNode: undefined,\n }\n\n setTextNodeValue(node, text)\n\n return node\n}\n\nexport const setTextNodeValue = (node: TextNode, text: string): void => {\n if (typeof text !== 'string') {\n text = String(text)\n }\n\n node.nodeValue = text\n}\n\nexport const nodeNames: Array<ElementNames> = ['kubb-export', 'kubb-file', 'kubb-source', 'kubb-import', 'kubb-text']\n","import { createContext } from 'react'\nimport Reconciler, { type ReactContext } from 'react-reconciler'\nimport { DefaultEventPriority, NoEventPriority } from 'react-reconciler/constants.js'\nimport { appendChildNode, createNode, createTextNode, insertBeforeNode, removeChildNode, setAttribute, setTextNodeValue } from './dom.ts'\nimport type { KubbNode } from './types'\nimport type { DOMElement, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\n\ndeclare module 'react-reconciler' {\n // @ts-expect-error custom override\n interface Reconciler {\n updateContainerSync(element: KubbNode, container: unknown, parentComponent: any, callback?: null | (() => void)): void\n flushSyncWork(): void\n createContainer(\n containerInfo: unknown,\n tag: Reconciler.RootTag,\n hydrationCallbacks: null | Reconciler.SuspenseHydrationCallbacks<any>,\n isStrictMode: boolean,\n concurrentUpdatesByDefaultOverride: null | boolean,\n identifierPrefix: string,\n onUncaughtError: (error: Error) => void,\n onCaughtError: (error: Error) => void,\n onRecoverableError: (error: Error) => void,\n transitionCallbacks: null | Reconciler.TransitionTracingCallbacks,\n ): Reconciler.OpaqueRoot\n }\n}\n\ntype Props = Record<string, unknown>\n\ntype HostContext = {\n type: ElementNames\n isFile: boolean\n isSource: boolean\n}\n\nlet currentUpdatePriority = NoEventPriority\n\n/**\n * @link https://www.npmjs.com/package/react-devtools-inline\n * @link https://github.com/nitin42/Making-a-custom-React-renderer/blob/master/part-one.md\n * @link https://github.com/facebook/react/tree/main/packages/react-reconciler#practical-examples\n * @link https://github.com/vadimdemedes/ink\n * @link https://github.com/pixijs/pixi-react/tree/main/packages\n * @link https://github.com/diegomura/react-pdf/blob/master/packages/reconciler/src/reconciler-31.ts\n */\nexport const Renderer = Reconciler({\n getRootHostContext: () => ({\n type: 'kubb-root',\n isFile: false,\n isSource: false,\n }),\n prepareForCommit: () => {\n return null\n },\n preparePortalMount: () => null,\n clearContainer: () => false,\n resetAfterCommit(rootNode: DOMElement) {\n if (typeof rootNode.onRender === 'function') {\n rootNode.onRender()\n }\n },\n getChildHostContext(parentHostContext: HostContext, type: ElementNames) {\n const isInsideText = type === 'kubb-text'\n const isFile = type === 'kubb-file' || parentHostContext.isFile\n const isSource = type === 'kubb-source' || parentHostContext.isSource\n\n return { isInsideText, isFile, isSource, type }\n },\n shouldSetTextContent: () => false,\n createInstance(originalType: ElementNames, newProps: Props, _root: DOMElement) {\n const node = createNode(originalType)\n\n for (const [key, value] of Object.entries(newProps)) {\n if (key === 'children') {\n continue\n }\n\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n\n return node\n },\n createTextInstance(text: string, _root: DOMElement, hostContext: HostContext) {\n if (hostContext.isFile && !hostContext.isSource) {\n throw new Error(`[react] '${text}' should be part of <File.Source> component when using the <File/> component`)\n }\n\n return createTextNode(text)\n },\n resetTextContent() {},\n hideTextInstance(node: TextNode) {\n setTextNodeValue(node, '')\n },\n unhideTextInstance(node: TextNode, text: string) {\n setTextNodeValue(node, text)\n },\n getPublicInstance: (instance) => instance,\n appendInitialChild: appendChildNode,\n appendChild: appendChildNode,\n insertBefore: insertBeforeNode,\n finalizeInitialChildren(_node, _type, _props, _rootNode) {\n return false\n },\n supportsMutation: true,\n isPrimaryRenderer: true,\n supportsPersistence: false,\n supportsHydration: false,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n beforeActiveInstanceBlur() {},\n afterActiveInstanceBlur() {},\n detachDeletedInstance() {},\n getInstanceFromNode: () => null,\n prepareScopeUpdate() {},\n getInstanceFromScope: () => null,\n appendChildToContainer: appendChildNode,\n insertInContainerBefore: insertBeforeNode,\n removeChildFromContainer(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n commitMount() {},\n commitUpdate(node: DOMElement, _payload, _type, _oldProps: Props, newProps: Props) {\n const { props } = newProps\n\n if (props) {\n for (const [key, value] of Object.entries(props)) {\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n }\n },\n commitTextUpdate(node: TextNode, _oldText, newText) {\n setTextNodeValue(node, newText)\n },\n removeChild(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n setCurrentUpdatePriority: (newPriority: number) => {\n currentUpdatePriority = newPriority\n },\n getCurrentUpdatePriority: () => currentUpdatePriority,\n resolveUpdatePriority() {\n if (currentUpdatePriority !== NoEventPriority) {\n return currentUpdatePriority\n }\n\n return DefaultEventPriority\n },\n maySuspendCommit() {\n return false\n },\n // eslint-disable-next-line @typescript-eslint/naming-convention\n NotPendingTransition: undefined,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HostTransitionContext: createContext(null) as unknown as ReactContext<unknown>,\n resetFormInstance() {},\n requestPostPaintCallback() {},\n shouldAttemptEagerTransition() {\n return false\n },\n trackSchedulerEvent() {},\n resolveEventType() {\n return null\n },\n resolveEventTimeStamp() {\n return -1.1\n },\n preloadInstance() {\n return true\n },\n startSuspendingCommit() {},\n suspendInstance() {},\n waitForCommitToBeReady() {\n return null\n },\n})\n\nexport type { FiberRoot } from 'react-reconciler'\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashExportNodes(node: DOMElement): Set<KubbFile.ResolvedExport> {\n let exports = new Set<KubbFile.Export>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n exports = new Set([...exports, ...squashExportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n exports.add(attributes)\n }\n })\n\n return exports\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashImportNodes(node: DOMElement): Set<KubbFile.Import> {\n let imports = new Set<KubbFile.Import>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n imports = new Set([...imports, ...squashImportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n imports.add(attributes)\n }\n })\n\n return imports\n}\n","import { createExport, createImport, print } from '@kubb/fabric-core/parsers/typescript'\n\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashTextNodes(node: DOMElement): string {\n let text = ''\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n let nodeText = ''\n\n const getPrintText = (text: string): string => {\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n\n return print([\n createImport({\n name: attributes.name,\n path: attributes.path,\n root: attributes.root,\n isTypeOnly: attributes.isTypeOnly,\n }),\n ])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n if (attributes.path) {\n return print([\n createExport({\n name: attributes.name,\n path: attributes.path,\n isTypeOnly: attributes.isTypeOnly,\n asAlias: attributes.asAlias,\n }),\n ])\n }\n }\n\n if (childNode.nodeName === 'kubb-source') {\n return text\n }\n\n return text\n }\n\n if (childNode.nodeName === '#text') {\n nodeText = childNode.nodeValue\n } else {\n if (['kubb-text', 'kubb-file', 'kubb-source'].includes(childNode.nodeName)) {\n nodeText = squashTextNodes(childNode)\n }\n\n nodeText = getPrintText(nodeText)\n\n if (childNode.nodeName === 'br') {\n nodeText = '\\n'\n }\n\n // no kubb element or br\n if (![...nodeNames, 'br'].includes(childNode.nodeName)) {\n const attributes = Object.entries(childNode.attributes).reduce((acc, [key, value]) => {\n if (typeof value === 'string') {\n return `${acc} ${key}=\"${value}\"`\n }\n\n return `${acc} ${key}={${value}}`\n }, '')\n nodeText = `<${childNode.nodeName}${attributes}>${squashTextNodes(childNode)}</${childNode.nodeName}>`\n }\n }\n\n text += nodeText\n }\n\n return text\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement, ElementNames } from '../types.ts'\nimport { squashTextNodes } from './squashTextNodes.ts'\n\nexport function squashSourceNodes(node: DOMElement, ignores: Array<ElementNames>): Set<KubbFile.Source> {\n let sources = new Set<KubbFile.Source>()\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && ignores.includes(childNode.nodeName)) {\n continue\n }\n\n if (childNode.nodeName === 'kubb-source') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Source>\n const value = squashTextNodes(childNode)\n\n sources.add({\n ...attributes,\n // remove end enter\n value: value.trim().replace(/^\\s+|\\s+$/g, ''),\n })\n\n continue\n }\n\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n sources = new Set([...sources, ...squashSourceNodes(childNode, ignores)])\n }\n }\n\n return sources\n}\n","import type { FileManager } from '@kubb/fabric-core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\nimport { squashExportNodes } from './squashExportNodes.ts'\nimport { squashImportNodes } from './squashImportNodes.ts'\nimport { squashSourceNodes } from './squashSourceNodes.ts'\n\nexport function processFiles(node: DOMElement, fileManager: FileManager) {\n for (let index = 0; index < node.childNodes.length; index++) {\n const childNode = node.childNodes[index]\n\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && childNode.nodeName !== 'kubb-file' && nodeNames.includes(childNode.nodeName)) {\n processFiles(childNode, fileManager)\n }\n\n if (childNode.nodeName === 'kubb-file') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File>\n\n if (attributes.baseName && attributes.path) {\n const sources = squashSourceNodes(childNode, ['kubb-export', 'kubb-import'])\n\n const file: KubbFile.File = {\n baseName: attributes.baseName,\n path: attributes.path,\n sources: [...sources],\n exports: [...squashExportNodes(childNode)],\n imports: [...squashImportNodes(childNode)],\n meta: attributes.meta || {},\n footer: attributes.footer,\n banner: attributes.banner,\n }\n\n fileManager.add(file)\n }\n }\n }\n}\n","import process from 'node:process'\nimport type { FileManager } from '@kubb/fabric-core'\nimport type { ReactNode } from 'react'\nimport { ConcurrentRoot } from 'react-reconciler/constants.js'\nimport { onExit } from 'signal-exit'\nimport { Root } from './components/Root.tsx'\nimport { createNode } from './dom.ts'\nimport type { FiberRoot } from './Renderer.ts'\nimport { Renderer } from './Renderer.ts'\nimport type { DOMElement } from './types.ts'\nimport { processFiles } from './utils/processFiles.ts'\nimport { squashTextNodes } from './utils/squashTextNodes.ts'\n\ntype Options = {\n fileManager: FileManager\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\nexport class Runtime {\n readonly #options: Options\n // Ignore last render after unmounting a tree to prevent empty output before exit\n #isUnmounted: boolean\n\n exitPromise?: Promise<void>\n readonly #container: FiberRoot\n readonly #rootNode: DOMElement\n\n constructor(options: Options) {\n this.#options = options\n\n this.#rootNode = createNode('kubb-root')\n this.#rootNode.onRender = this.onRender\n this.#rootNode.onImmediateRender = this.onRender\n\n // Ignore last render after unmounting a tree to prevent empty output before exit\n this.#isUnmounted = false\n this.unmount.bind(this)\n\n const originalError = console.error\n console.error = (data: string | Error) => {\n const message = typeof data === 'string' ? data : data?.message\n\n if (message?.match(/Encountered two children with the same key/gi)) {\n return\n }\n if (message?.match(/React will try to recreat/gi)) {\n return\n }\n if (message?.match(/Each child in a list should have a unique/gi)) {\n return\n }\n if (message?.match(/The above error occurred in the <KubbErrorBoundary/gi)) {\n return\n }\n\n if (message?.match(/A React Element from an older version of React was render/gi)) {\n return\n }\n\n originalError(data)\n }\n\n // Report when an error was detected in a previous render\n // https://github.com/pmndrs/react-three-fiber/pull/2261\n const logRecoverableError =\n typeof reportError === 'function'\n ? // In modern browsers, reportError will dispatch an error event,\n // emulating an uncaught JavaScript error.\n reportError\n : // In older browsers and test environments, fallback to console.error.\n console.error\n\n const rootTag = ConcurrentRoot\n const hydrationCallbacks = null\n const isStrictMode = false\n const concurrentUpdatesByDefaultOverride = false\n const identifierPrefix = 'id'\n const onUncaughtError = logRecoverableError\n const onCaughtError = logRecoverableError\n const onRecoverableError = logRecoverableError\n const transitionCallbacks = null\n\n this.#container = Renderer.createContainer(\n this.#rootNode,\n rootTag,\n hydrationCallbacks,\n isStrictMode,\n concurrentUpdatesByDefaultOverride,\n identifierPrefix,\n onUncaughtError,\n onCaughtError,\n onRecoverableError,\n transitionCallbacks,\n )\n\n // Unmount when process exits\n this.unsubscribeExit = onExit(\n (code) => {\n this.unmount(code)\n },\n { alwaysLast: false },\n ).bind(this)\n\n Renderer.injectIntoDevTools({\n bundleType: 1, // 0 for PROD, 1 for DEV\n version: '19.1.0', // should be React version and not Kubb's custom version\n rendererPackageName: 'kubb', // package name\n })\n }\n\n get fileManager() {\n return this.#options.fileManager\n }\n\n resolveExitPromise: () => void = () => {}\n rejectExitPromise: (reason?: Error) => void = () => {}\n unsubscribeExit: () => void = () => {}\n onRender: () => void = async () => {\n if (this.#isUnmounted) {\n return\n }\n\n // TODO remove to allow multiple renders\n this.fileManager.clear()\n\n processFiles(this.#rootNode, this.fileManager)\n\n if (!this.#options?.debug && !this.#options?.stdout) {\n return\n }\n\n const output = await this.#getOutput(this.#rootNode)\n\n if (this.#options?.debug) {\n console.log('Rendering: \\n')\n console.log(output)\n }\n\n if (this.#options?.stdout && process.env.NODE_ENV !== 'test') {\n this.#options.stdout.clearLine(0)\n this.#options.stdout.cursorTo(0)\n this.#options.stdout.write(output)\n }\n }\n onError(error: Error): void {\n if (process.env.NODE_ENV === 'test') {\n console.warn(error)\n }\n\n throw error\n }\n onExit(error?: Error): void {\n this.unmount(error)\n }\n\n async #getOutput(node: DOMElement): Promise<string> {\n const text = squashTextNodes(node)\n const files = this.fileManager.files\n\n return files.length\n ? [...files]\n .flatMap((file) => [...file.sources].map((item) => item.value))\n .filter(Boolean)\n .join('\\n\\n')\n : text\n }\n\n render(node: ReactNode): void {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n }\n\n async renderToString(node: ReactNode): Promise<string> {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n\n this.fileManager.clear()\n\n return this.#getOutput(this.#rootNode)\n }\n\n unmount(error?: Error | number | null): void {\n if (this.#isUnmounted) {\n return\n }\n\n if (this.#options?.debug) {\n console.log('Unmount', error)\n }\n\n this.onRender()\n this.unsubscribeExit()\n\n this.#isUnmounted = true\n\n Renderer.updateContainerSync(null, this.#container, null, null)\n\n if (error instanceof Error) {\n this.rejectExitPromise(error)\n\n return\n }\n\n this.resolveExitPromise()\n }\n\n async waitUntilExit(): Promise<void> {\n if (!this.exitPromise) {\n this.exitPromise = new Promise((resolve, reject) => {\n this.resolveExitPromise = resolve\n this.rejectExitPromise = reject\n })\n }\n\n return this.exitPromise\n }\n}\n","import { createPlugin } from '@kubb/fabric-core/plugins'\nimport { createElement, type ElementType } from 'react'\nimport { Runtime } from '../Runtime.tsx'\n\nexport type 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 global {\n namespace Kubb {\n interface Fabric {\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(ctx, options = {}) {\n const runtime = new Runtime({ fileManager: ctx.fileManager, ...options })\n\n return {\n async render(App) {\n runtime.render(createElement(App))\n await ctx.emit('start')\n },\n async renderToString(App) {\n await ctx.emit('start')\n return runtime.renderToString(createElement(App))\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n\n await ctx.emit('end')\n },\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAM,gBAAN,cAA4B,UAGzB;;;wBACD,SAAQ,EAAE,UAAU,OAAO;;CAG3B,OAAO,yBAAyB,QAAe;AAC7C,SAAO,EAAE,UAAU,MAAM;;CAG3B,kBAAkB,OAAc;AAC9B,MAAI,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,QAAQ;AACvB,WAAO,QAAQ,eAAe,cAAc,IAAI,CAAC;;GAEnD,MAAM,gBAAgB;AACpB,UAAM,QAAQ,eAAe;AAE7B,UAAM,IAAI,KAAK,MAAM;;GAExB;;CAEJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import { o as Plugin } from "./Fabric-t9Xqe4Bx.js";
1
+ import { o as Plugin } from "./Fabric-MsFHiZXy.cjs";
2
2
  import { ElementType } from "react";
3
3
 
4
4
  //#region src/plugins/reactPlugin.d.ts
@@ -16,13 +16,6 @@ type ExtendOptions = {
16
16
  renderToString(App: ElementType): Promise<string> | string;
17
17
  waitUntilExit(): Promise<void>;
18
18
  };
19
- declare module '@kubb/fabric-core' {
20
- interface Fabric {
21
- render(App: ElementType): Promise<void> | void;
22
- renderToString(App: ElementType): Promise<string> | string;
23
- waitUntilExit(): Promise<void>;
24
- }
25
- }
26
19
  declare global {
27
20
  namespace Kubb {
28
21
  interface Fabric {
@@ -35,4 +28,4 @@ declare global {
35
28
  declare const reactPlugin: Plugin<Options, ExtendOptions>;
36
29
  //#endregion
37
30
  export { reactPlugin as n, Options as t };
38
- //# sourceMappingURL=reactPlugin-DmnHX7Uj.d.ts.map
31
+ //# sourceMappingURL=reactPlugin-D8rqKtK0.d.cts.map
@@ -1,4 +1,4 @@
1
- import { o as Plugin } from "./Fabric-BPUyMklG.cjs";
1
+ import { o as Plugin } from "./Fabric-C3xWWIb6.js";
2
2
  import { ElementType } from "react";
3
3
 
4
4
  //#region src/plugins/reactPlugin.d.ts
@@ -16,13 +16,6 @@ type ExtendOptions = {
16
16
  renderToString(App: ElementType): Promise<string> | string;
17
17
  waitUntilExit(): Promise<void>;
18
18
  };
19
- declare module '@kubb/fabric-core' {
20
- interface Fabric {
21
- render(App: ElementType): Promise<void> | void;
22
- renderToString(App: ElementType): Promise<string> | string;
23
- waitUntilExit(): Promise<void>;
24
- }
25
- }
26
19
  declare global {
27
20
  namespace Kubb {
28
21
  interface Fabric {
@@ -35,4 +28,4 @@ declare global {
35
28
  declare const reactPlugin: Plugin<Options, ExtendOptions>;
36
29
  //#endregion
37
30
  export { reactPlugin as n, Options as t };
38
- //# sourceMappingURL=reactPlugin-DlGI8_Sh.d.cts.map
31
+ //# sourceMappingURL=reactPlugin-DY-MH4LN.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reactPlugin-Dj5m_pqf.cjs","names":["Component","onExit","node: TextNode","nodeNames: Array<ElementNames>","NoEventPriority","DefaultEventPriority","exports","text","file: KubbFile.File","process","ConcurrentRoot"],"sources":["../src/components/Root.tsx","../src/dom.ts","../src/Renderer.ts","../src/utils/squashExportNodes.ts","../src/utils/squashImportNodes.ts","../src/utils/squashTextNodes.ts","../src/utils/squashSourceNodes.ts","../src/utils/processFiles.ts","../src/Runtime.tsx","../src/plugins/reactPlugin.ts"],"sourcesContent":["import { Component, createContext } from 'react'\n\nimport type { KubbNode } from '../types.ts'\n\ntype ErrorBoundaryProps = {\n onError: (error: Error) => void\n children?: KubbNode\n}\n\nclass ErrorBoundary extends Component<{\n onError: ErrorBoundaryProps['onError']\n children?: KubbNode\n}> {\n state = { hasError: false }\n\n static displayName = 'KubbErrorBoundary'\n static getDerivedStateFromError(_error: Error) {\n return { hasError: true }\n }\n\n componentDidCatch(error: Error) {\n if (error) {\n this.props.onError(error)\n }\n }\n\n render() {\n if (this.state.hasError) {\n return null\n }\n return this.props.children\n }\n}\n\nexport type RootContextProps = {\n /**\n * Exit (unmount) the whole Ink app.\n */\n readonly exit: (error?: Error) => void\n}\n\nexport const RootContext = createContext<RootContextProps>({\n exit: () => {},\n})\n\ntype RootProps = {\n /**\n * Exit (unmount) hook\n */\n readonly onExit: (error?: Error) => void\n /**\n * Error hook\n */\n readonly onError: (error: Error) => void\n readonly children?: KubbNode\n}\n\nexport function Root({ onError, onExit, children }: RootProps) {\n try {\n return (\n <ErrorBoundary\n onError={(error) => {\n onError(error)\n }}\n >\n <RootContext.Provider value={{ exit: onExit }}>{children}</RootContext.Provider>\n </ErrorBoundary>\n )\n } catch (_e) {\n return null\n }\n}\n\nRoot.Context = RootContext\nRoot.displayName = 'KubbRoot'\n","import type { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\n\nexport const createNode = (nodeName: string): DOMElement => {\n const node: DOMElement = {\n nodeName: nodeName as DOMElement['nodeName'],\n attributes: {},\n childNodes: [],\n parentNode: undefined,\n }\n\n return node\n}\n\nexport const appendChildNode = (node: DOMNode, childNode: DOMElement | DOMNode): void => {\n if (childNode.parentNode) {\n removeChildNode(childNode.parentNode, childNode)\n }\n\n if (node.nodeName !== '#text') {\n childNode.parentNode = node\n node.childNodes.push(childNode)\n }\n}\n\nexport const insertBeforeNode = (node: DOMElement, newChildNode: DOMNode, beforeChildNode: DOMNode): void => {\n if (newChildNode.parentNode) {\n removeChildNode(newChildNode.parentNode, newChildNode)\n }\n\n newChildNode.parentNode = node\n\n const index = node.childNodes.indexOf(beforeChildNode)\n if (index >= 0) {\n node.childNodes.splice(index, 0, newChildNode)\n\n return\n }\n\n node.childNodes.push(newChildNode)\n}\n\nexport const removeChildNode = (node: DOMElement, removeNode: DOMNode): void => {\n removeNode.parentNode = undefined\n\n const index = node.childNodes.indexOf(removeNode)\n if (index >= 0) {\n node.childNodes.splice(index, 1)\n }\n}\n\nexport const setAttribute = (node: DOMElement, key: string, value: DOMNodeAttribute): void => {\n node.attributes[key] = value\n}\n\nexport const createTextNode = (text: string): TextNode => {\n const node: TextNode = {\n nodeName: '#text',\n nodeValue: text,\n parentNode: undefined,\n }\n\n setTextNodeValue(node, text)\n\n return node\n}\n\nexport const setTextNodeValue = (node: TextNode, text: string): void => {\n if (typeof text !== 'string') {\n text = String(text)\n }\n\n node.nodeValue = text\n}\n\nexport const nodeNames: Array<ElementNames> = ['kubb-export', 'kubb-file', 'kubb-source', 'kubb-import', 'kubb-text']\n","import { createContext } from 'react'\nimport Reconciler, { type ReactContext } from 'react-reconciler'\nimport { DefaultEventPriority, NoEventPriority } from 'react-reconciler/constants.js'\nimport { appendChildNode, createNode, createTextNode, insertBeforeNode, removeChildNode, setAttribute, setTextNodeValue } from './dom.ts'\nimport type { KubbNode } from './types'\nimport type { DOMElement, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\n\ndeclare module 'react-reconciler' {\n // @ts-expect-error custom override\n interface Reconciler {\n updateContainerSync(element: KubbNode, container: unknown, parentComponent: any, callback?: null | (() => void)): void\n flushSyncWork(): void\n createContainer(\n containerInfo: unknown,\n tag: Reconciler.RootTag,\n hydrationCallbacks: null | Reconciler.SuspenseHydrationCallbacks<any>,\n isStrictMode: boolean,\n concurrentUpdatesByDefaultOverride: null | boolean,\n identifierPrefix: string,\n onUncaughtError: (error: Error) => void,\n onCaughtError: (error: Error) => void,\n onRecoverableError: (error: Error) => void,\n transitionCallbacks: null | Reconciler.TransitionTracingCallbacks,\n ): Reconciler.OpaqueRoot\n }\n}\n\ntype Props = Record<string, unknown>\n\ntype HostContext = {\n type: ElementNames\n isFile: boolean\n isSource: boolean\n}\n\nlet currentUpdatePriority = NoEventPriority\n\n/**\n * @link https://www.npmjs.com/package/react-devtools-inline\n * @link https://github.com/nitin42/Making-a-custom-React-renderer/blob/master/part-one.md\n * @link https://github.com/facebook/react/tree/main/packages/react-reconciler#practical-examples\n * @link https://github.com/vadimdemedes/ink\n * @link https://github.com/pixijs/pixi-react/tree/main/packages\n * @link https://github.com/diegomura/react-pdf/blob/master/packages/reconciler/src/reconciler-31.ts\n */\nexport const Renderer = Reconciler({\n getRootHostContext: () => ({\n type: 'kubb-root',\n isFile: false,\n isSource: false,\n }),\n prepareForCommit: () => {\n return null\n },\n preparePortalMount: () => null,\n clearContainer: () => false,\n resetAfterCommit(rootNode: DOMElement) {\n if (typeof rootNode.onRender === 'function') {\n rootNode.onRender()\n }\n },\n getChildHostContext(parentHostContext: HostContext, type: ElementNames) {\n const isInsideText = type === 'kubb-text'\n const isFile = type === 'kubb-file' || parentHostContext.isFile\n const isSource = type === 'kubb-source' || parentHostContext.isSource\n\n return { isInsideText, isFile, isSource, type }\n },\n shouldSetTextContent: () => false,\n createInstance(originalType: ElementNames, newProps: Props, _root: DOMElement) {\n const node = createNode(originalType)\n\n for (const [key, value] of Object.entries(newProps)) {\n if (key === 'children') {\n continue\n }\n\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n\n return node\n },\n createTextInstance(text: string, _root: DOMElement, hostContext: HostContext) {\n if (hostContext.isFile && !hostContext.isSource) {\n throw new Error(`[react] '${text}' should be part of <File.Source> component when using the <File/> component`)\n }\n\n return createTextNode(text)\n },\n resetTextContent() {},\n hideTextInstance(node: TextNode) {\n setTextNodeValue(node, '')\n },\n unhideTextInstance(node: TextNode, text: string) {\n setTextNodeValue(node, text)\n },\n getPublicInstance: (instance) => instance,\n appendInitialChild: appendChildNode,\n appendChild: appendChildNode,\n insertBefore: insertBeforeNode,\n finalizeInitialChildren(_node, _type, _props, _rootNode) {\n return false\n },\n supportsMutation: true,\n isPrimaryRenderer: true,\n supportsPersistence: false,\n supportsHydration: false,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n beforeActiveInstanceBlur() {},\n afterActiveInstanceBlur() {},\n detachDeletedInstance() {},\n getInstanceFromNode: () => null,\n prepareScopeUpdate() {},\n getInstanceFromScope: () => null,\n appendChildToContainer: appendChildNode,\n insertInContainerBefore: insertBeforeNode,\n removeChildFromContainer(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n commitMount() {},\n commitUpdate(node: DOMElement, _payload, _type, _oldProps: Props, newProps: Props) {\n const { props } = newProps\n\n if (props) {\n for (const [key, value] of Object.entries(props)) {\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n }\n },\n commitTextUpdate(node: TextNode, _oldText, newText) {\n setTextNodeValue(node, newText)\n },\n removeChild(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n setCurrentUpdatePriority: (newPriority: number) => {\n currentUpdatePriority = newPriority\n },\n getCurrentUpdatePriority: () => currentUpdatePriority,\n resolveUpdatePriority() {\n if (currentUpdatePriority !== NoEventPriority) {\n return currentUpdatePriority\n }\n\n return DefaultEventPriority\n },\n maySuspendCommit() {\n return false\n },\n // eslint-disable-next-line @typescript-eslint/naming-convention\n NotPendingTransition: undefined,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HostTransitionContext: createContext(null) as unknown as ReactContext<unknown>,\n resetFormInstance() {},\n requestPostPaintCallback() {},\n shouldAttemptEagerTransition() {\n return false\n },\n trackSchedulerEvent() {},\n resolveEventType() {\n return null\n },\n resolveEventTimeStamp() {\n return -1.1\n },\n preloadInstance() {\n return true\n },\n startSuspendingCommit() {},\n suspendInstance() {},\n waitForCommitToBeReady() {\n return null\n },\n})\n\nexport type { FiberRoot } from 'react-reconciler'\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashExportNodes(node: DOMElement): Set<KubbFile.ResolvedExport> {\n let exports = new Set<KubbFile.Export>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n exports = new Set([...exports, ...squashExportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n exports.add(attributes)\n }\n })\n\n return exports\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashImportNodes(node: DOMElement): Set<KubbFile.Import> {\n let imports = new Set<KubbFile.Import>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n imports = new Set([...imports, ...squashImportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n imports.add(attributes)\n }\n })\n\n return imports\n}\n","import { createExport, createImport, print } from '@kubb/fabric-core/parsers/typescript'\n\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashTextNodes(node: DOMElement): string {\n let text = ''\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n let nodeText = ''\n\n const getPrintText = (text: string): string => {\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n\n return print([\n createImport({\n name: attributes.name,\n path: attributes.path,\n root: attributes.root,\n isTypeOnly: attributes.isTypeOnly,\n }),\n ])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n if (attributes.path) {\n return print([\n createExport({\n name: attributes.name,\n path: attributes.path,\n isTypeOnly: attributes.isTypeOnly,\n asAlias: attributes.asAlias,\n }),\n ])\n }\n }\n\n if (childNode.nodeName === 'kubb-source') {\n return text\n }\n\n return text\n }\n\n if (childNode.nodeName === '#text') {\n nodeText = childNode.nodeValue\n } else {\n if (['kubb-text', 'kubb-file', 'kubb-source'].includes(childNode.nodeName)) {\n nodeText = squashTextNodes(childNode)\n }\n\n nodeText = getPrintText(nodeText)\n\n if (childNode.nodeName === 'br') {\n nodeText = '\\n'\n }\n\n // no kubb element or br\n if (![...nodeNames, 'br'].includes(childNode.nodeName)) {\n const attributes = Object.entries(childNode.attributes).reduce((acc, [key, value]) => {\n if (typeof value === 'string') {\n return `${acc} ${key}=\"${value}\"`\n }\n\n return `${acc} ${key}={${value}}`\n }, '')\n nodeText = `<${childNode.nodeName}${attributes}>${squashTextNodes(childNode)}</${childNode.nodeName}>`\n }\n }\n\n text += nodeText\n }\n\n return text\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement, ElementNames } from '../types.ts'\nimport { squashTextNodes } from './squashTextNodes.ts'\n\nexport function squashSourceNodes(node: DOMElement, ignores: Array<ElementNames>): Set<KubbFile.Source> {\n let sources = new Set<KubbFile.Source>()\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && ignores.includes(childNode.nodeName)) {\n continue\n }\n\n if (childNode.nodeName === 'kubb-source') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Source>\n const value = squashTextNodes(childNode)\n\n sources.add({\n ...attributes,\n // remove end enter\n value: value.trim().replace(/^\\s+|\\s+$/g, ''),\n })\n\n continue\n }\n\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n sources = new Set([...sources, ...squashSourceNodes(childNode, ignores)])\n }\n }\n\n return sources\n}\n","import type { FileManager } from '@kubb/fabric-core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\nimport { squashExportNodes } from './squashExportNodes.ts'\nimport { squashImportNodes } from './squashImportNodes.ts'\nimport { squashSourceNodes } from './squashSourceNodes.ts'\n\nexport function processFiles(node: DOMElement, fileManager: FileManager) {\n for (let index = 0; index < node.childNodes.length; index++) {\n const childNode = node.childNodes[index]\n\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && childNode.nodeName !== 'kubb-file' && nodeNames.includes(childNode.nodeName)) {\n processFiles(childNode, fileManager)\n }\n\n if (childNode.nodeName === 'kubb-file') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File>\n\n if (attributes.baseName && attributes.path) {\n const sources = squashSourceNodes(childNode, ['kubb-export', 'kubb-import'])\n\n const file: KubbFile.File = {\n baseName: attributes.baseName,\n path: attributes.path,\n sources: [...sources],\n exports: [...squashExportNodes(childNode)],\n imports: [...squashImportNodes(childNode)],\n meta: attributes.meta || {},\n footer: attributes.footer,\n banner: attributes.banner,\n }\n\n fileManager.add(file)\n }\n }\n }\n}\n","import process from 'node:process'\nimport type { FileManager } from '@kubb/fabric-core'\nimport type { ReactNode } from 'react'\nimport { ConcurrentRoot } from 'react-reconciler/constants.js'\nimport { onExit } from 'signal-exit'\nimport { Root } from './components/Root.tsx'\nimport { createNode } from './dom.ts'\nimport type { FiberRoot } from './Renderer.ts'\nimport { Renderer } from './Renderer.ts'\nimport type { DOMElement } from './types.ts'\nimport { processFiles } from './utils/processFiles.ts'\nimport { squashTextNodes } from './utils/squashTextNodes.ts'\n\ntype Options = {\n fileManager: FileManager\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\nexport class Runtime {\n readonly #options: Options\n // Ignore last render after unmounting a tree to prevent empty output before exit\n #isUnmounted: boolean\n\n exitPromise?: Promise<void>\n readonly #container: FiberRoot\n readonly #rootNode: DOMElement\n\n constructor(options: Options) {\n this.#options = options\n\n this.#rootNode = createNode('kubb-root')\n this.#rootNode.onRender = this.onRender\n this.#rootNode.onImmediateRender = this.onRender\n\n // Ignore last render after unmounting a tree to prevent empty output before exit\n this.#isUnmounted = false\n this.unmount.bind(this)\n\n const originalError = console.error\n console.error = (data: string | Error) => {\n const message = typeof data === 'string' ? data : data?.message\n\n if (message?.match(/Encountered two children with the same key/gi)) {\n return\n }\n if (message?.match(/React will try to recreat/gi)) {\n return\n }\n if (message?.match(/Each child in a list should have a unique/gi)) {\n return\n }\n if (message?.match(/The above error occurred in the <KubbErrorBoundary/gi)) {\n return\n }\n\n if (message?.match(/A React Element from an older version of React was render/gi)) {\n return\n }\n\n originalError(data)\n }\n\n // Report when an error was detected in a previous render\n // https://github.com/pmndrs/react-three-fiber/pull/2261\n const logRecoverableError =\n typeof reportError === 'function'\n ? // In modern browsers, reportError will dispatch an error event,\n // emulating an uncaught JavaScript error.\n reportError\n : // In older browsers and test environments, fallback to console.error.\n console.error\n\n const rootTag = ConcurrentRoot\n const hydrationCallbacks = null\n const isStrictMode = false\n const concurrentUpdatesByDefaultOverride = false\n const identifierPrefix = 'id'\n const onUncaughtError = logRecoverableError\n const onCaughtError = logRecoverableError\n const onRecoverableError = logRecoverableError\n const transitionCallbacks = null\n\n this.#container = Renderer.createContainer(\n this.#rootNode,\n rootTag,\n hydrationCallbacks,\n isStrictMode,\n concurrentUpdatesByDefaultOverride,\n identifierPrefix,\n onUncaughtError,\n onCaughtError,\n onRecoverableError,\n transitionCallbacks,\n )\n\n // Unmount when process exits\n this.unsubscribeExit = onExit(\n (code) => {\n this.unmount(code)\n },\n { alwaysLast: false },\n ).bind(this)\n\n Renderer.injectIntoDevTools({\n bundleType: 1, // 0 for PROD, 1 for DEV\n version: '19.1.0', // should be React version and not Kubb's custom version\n rendererPackageName: 'kubb', // package name\n })\n }\n\n get fileManager() {\n return this.#options.fileManager\n }\n\n resolveExitPromise: () => void = () => {}\n rejectExitPromise: (reason?: Error) => void = () => {}\n unsubscribeExit: () => void = () => {}\n onRender: () => void = async () => {\n if (this.#isUnmounted) {\n return\n }\n\n // TODO remove to allow multiple renders\n this.fileManager.clear()\n\n processFiles(this.#rootNode, this.fileManager)\n\n if (!this.#options?.debug && !this.#options?.stdout) {\n return\n }\n\n const output = await this.#getOutput(this.#rootNode)\n\n if (this.#options?.debug) {\n console.log('Rendering: \\n')\n console.log(output)\n }\n\n if (this.#options?.stdout && process.env.NODE_ENV !== 'test') {\n this.#options.stdout.clearLine(0)\n this.#options.stdout.cursorTo(0)\n this.#options.stdout.write(output)\n }\n }\n onError(error: Error): void {\n if (process.env.NODE_ENV === 'test') {\n console.warn(error)\n }\n\n throw error\n }\n onExit(error?: Error): void {\n this.unmount(error)\n }\n\n async #getOutput(node: DOMElement): Promise<string> {\n const text = squashTextNodes(node)\n const files = this.fileManager.files\n\n return files.length\n ? [...files]\n .flatMap((file) => [...file.sources].map((item) => item.value))\n .filter(Boolean)\n .join('\\n\\n')\n : text\n }\n\n render(node: ReactNode): void {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n }\n\n async renderToString(node: ReactNode): Promise<string> {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n\n this.fileManager.clear()\n\n return this.#getOutput(this.#rootNode)\n }\n\n unmount(error?: Error | number | null): void {\n if (this.#isUnmounted) {\n return\n }\n\n if (this.#options?.debug) {\n console.log('Unmount', error)\n }\n\n this.onRender()\n this.unsubscribeExit()\n\n this.#isUnmounted = true\n\n Renderer.updateContainerSync(null, this.#container, null, null)\n\n if (error instanceof Error) {\n this.rejectExitPromise(error)\n\n return\n }\n\n this.resolveExitPromise()\n }\n\n async waitUntilExit(): Promise<void> {\n if (!this.exitPromise) {\n this.exitPromise = new Promise((resolve, reject) => {\n this.resolveExitPromise = resolve\n this.rejectExitPromise = reject\n })\n }\n\n return this.exitPromise\n }\n}\n","import { createPlugin } from '@kubb/fabric-core/plugins'\nimport { createElement, type ElementType } from 'react'\nimport { Runtime } from '../Runtime.tsx'\n\nexport type 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 Fabric {\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 Fabric {\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(ctx, options = {}) {\n const runtime = new Runtime({ fileManager: ctx.fileManager, ...options })\n\n return {\n async render(App) {\n runtime.render(createElement(App))\n await ctx.emit('start')\n },\n async renderToString(App) {\n await ctx.emit('start')\n return runtime.renderToString(createElement(App))\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n\n await ctx.emit('end')\n },\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAM,gBAAN,cAA4BA,gBAGzB;;;wBACD,SAAQ,EAAE,UAAU,OAAO;;CAG3B,OAAO,yBAAyB,QAAe;AAC7C,SAAO,EAAE,UAAU,MAAM;;CAG3B,kBAAkB,OAAc;AAC9B,MAAI,MACF,MAAK,MAAM,QAAQ,MAAM;;CAI7B,SAAS;AACP,MAAI,KAAK,MAAM,SACb,QAAO;AAET,SAAO,KAAK,MAAM;;;+BAfb,eAAc;AA0BvB,MAAa,uCAA8C,EACzD,YAAY,IACb,CAAC;AAcF,SAAgB,KAAK,EAAE,SAAS,kBAAQ,YAAuB;AAC7D,KAAI;AACF,SACE,2CAAC;GACC,UAAU,UAAU;AAClB,YAAQ,MAAM;;aAGhB,2CAAC,YAAY;IAAS,OAAO,EAAE,MAAMC,UAAQ;IAAG;KAAgC;IAClE;UAEX,IAAI;AACX,SAAO;;;AAIX,KAAK,UAAU;AACf,KAAK,cAAc;;;;ACxEnB,MAAa,cAAc,aAAiC;AAQ1D,QAPyB;EACb;EACV,YAAY,EAAE;EACd,YAAY,EAAE;EACd,YAAY;EACb;;AAKH,MAAa,mBAAmB,MAAe,cAA0C;AACvF,KAAI,UAAU,WACZ,iBAAgB,UAAU,YAAY,UAAU;A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K,oBAAoB;IACzB;AAGJ,SAAO,KAAK;;;AAvEd,0BAAiB,MAAmC;CAClD,MAAM,OAAO,gBAAgB,KAAK;CAClC,MAAM,QAAQ,KAAK,YAAY;AAE/B,QAAO,MAAM,SACT,CAAC,GAAG,MAAM,CACP,SAAS,SAAS,CAAC,GAAG,KAAK,QAAQ,CAAC,KAAK,SAAS,KAAK,MAAM,CAAC,CAC9D,OAAO,QAAQ,CACf,KAAK,OAAO,GACf;;;;;AClIR,MAAa,2DAAmD;CAC9D,MAAM;CACN,UAAU;CACV,OAAO,KAAK,UAAU,EAAE,EAAE;EACxB,MAAM,UAAU,IAAI,QAAQ;GAAE,aAAa,IAAI;GAAa,GAAG;GAAS,CAAC;AAEzE,SAAO;GACL,MAAM,OAAO,KAAK;AAChB,YAAQ,gCAAqB,IAAI,CAAC;AAClC,UAAM,IAAI,KAAK,QAAQ;;GAEzB,MAAM,eAAe,KAAK;AACxB,UAAM,IAAI,KAAK,QAAQ;AACvB,WAAO,QAAQ,wCAA6B,IAAI,CAAC;;GAEnD,MAAM,gBAAgB;AACpB,UAAM,QAAQ,eAAe;AAE7B,UAAM,IAAI,KAAK,MAAM;;GAExB;;CAEJ,CAAC"}
1
+ {"version":3,"file":"reactPlugin-Dj5m_pqf.cjs","names":["Component","onExit","node: TextNode","nodeNames: Array<ElementNames>","NoEventPriority","DefaultEventPriority","exports","text","file: KubbFile.File","process","ConcurrentRoot"],"sources":["../src/components/Root.tsx","../src/dom.ts","../src/Renderer.ts","../src/utils/squashExportNodes.ts","../src/utils/squashImportNodes.ts","../src/utils/squashTextNodes.ts","../src/utils/squashSourceNodes.ts","../src/utils/processFiles.ts","../src/Runtime.tsx","../src/plugins/reactPlugin.ts"],"sourcesContent":["import { Component, createContext } from 'react'\n\nimport type { KubbNode } from '../types.ts'\n\ntype ErrorBoundaryProps = {\n onError: (error: Error) => void\n children?: KubbNode\n}\n\nclass ErrorBoundary extends Component<{\n onError: ErrorBoundaryProps['onError']\n children?: KubbNode\n}> {\n state = { hasError: false }\n\n static displayName = 'KubbErrorBoundary'\n static getDerivedStateFromError(_error: Error) {\n return { hasError: true }\n }\n\n componentDidCatch(error: Error) {\n if (error) {\n this.props.onError(error)\n }\n }\n\n render() {\n if (this.state.hasError) {\n return null\n }\n return this.props.children\n }\n}\n\nexport type RootContextProps = {\n /**\n * Exit (unmount) the whole Ink app.\n */\n readonly exit: (error?: Error) => void\n}\n\nexport const RootContext = createContext<RootContextProps>({\n exit: () => {},\n})\n\ntype RootProps = {\n /**\n * Exit (unmount) hook\n */\n readonly onExit: (error?: Error) => void\n /**\n * Error hook\n */\n readonly onError: (error: Error) => void\n readonly children?: KubbNode\n}\n\nexport function Root({ onError, onExit, children }: RootProps) {\n try {\n return (\n <ErrorBoundary\n onError={(error) => {\n onError(error)\n }}\n >\n <RootContext.Provider value={{ exit: onExit }}>{children}</RootContext.Provider>\n </ErrorBoundary>\n )\n } catch (_e) {\n return null\n }\n}\n\nRoot.Context = RootContext\nRoot.displayName = 'KubbRoot'\n","import type { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\n\nexport const createNode = (nodeName: string): DOMElement => {\n const node: DOMElement = {\n nodeName: nodeName as DOMElement['nodeName'],\n attributes: {},\n childNodes: [],\n parentNode: undefined,\n }\n\n return node\n}\n\nexport const appendChildNode = (node: DOMNode, childNode: DOMElement | DOMNode): void => {\n if (childNode.parentNode) {\n removeChildNode(childNode.parentNode, childNode)\n }\n\n if (node.nodeName !== '#text') {\n childNode.parentNode = node\n node.childNodes.push(childNode)\n }\n}\n\nexport const insertBeforeNode = (node: DOMElement, newChildNode: DOMNode, beforeChildNode: DOMNode): void => {\n if (newChildNode.parentNode) {\n removeChildNode(newChildNode.parentNode, newChildNode)\n }\n\n newChildNode.parentNode = node\n\n const index = node.childNodes.indexOf(beforeChildNode)\n if (index >= 0) {\n node.childNodes.splice(index, 0, newChildNode)\n\n return\n }\n\n node.childNodes.push(newChildNode)\n}\n\nexport const removeChildNode = (node: DOMElement, removeNode: DOMNode): void => {\n removeNode.parentNode = undefined\n\n const index = node.childNodes.indexOf(removeNode)\n if (index >= 0) {\n node.childNodes.splice(index, 1)\n }\n}\n\nexport const setAttribute = (node: DOMElement, key: string, value: DOMNodeAttribute): void => {\n node.attributes[key] = value\n}\n\nexport const createTextNode = (text: string): TextNode => {\n const node: TextNode = {\n nodeName: '#text',\n nodeValue: text,\n parentNode: undefined,\n }\n\n setTextNodeValue(node, text)\n\n return node\n}\n\nexport const setTextNodeValue = (node: TextNode, text: string): void => {\n if (typeof text !== 'string') {\n text = String(text)\n }\n\n node.nodeValue = text\n}\n\nexport const nodeNames: Array<ElementNames> = ['kubb-export', 'kubb-file', 'kubb-source', 'kubb-import', 'kubb-text']\n","import { createContext } from 'react'\nimport Reconciler, { type ReactContext } from 'react-reconciler'\nimport { DefaultEventPriority, NoEventPriority } from 'react-reconciler/constants.js'\nimport { appendChildNode, createNode, createTextNode, insertBeforeNode, removeChildNode, setAttribute, setTextNodeValue } from './dom.ts'\nimport type { KubbNode } from './types'\nimport type { DOMElement, DOMNodeAttribute, ElementNames, TextNode } from './types.ts'\n\ndeclare module 'react-reconciler' {\n // @ts-expect-error custom override\n interface Reconciler {\n updateContainerSync(element: KubbNode, container: unknown, parentComponent: any, callback?: null | (() => void)): void\n flushSyncWork(): void\n createContainer(\n containerInfo: unknown,\n tag: Reconciler.RootTag,\n hydrationCallbacks: null | Reconciler.SuspenseHydrationCallbacks<any>,\n isStrictMode: boolean,\n concurrentUpdatesByDefaultOverride: null | boolean,\n identifierPrefix: string,\n onUncaughtError: (error: Error) => void,\n onCaughtError: (error: Error) => void,\n onRecoverableError: (error: Error) => void,\n transitionCallbacks: null | Reconciler.TransitionTracingCallbacks,\n ): Reconciler.OpaqueRoot\n }\n}\n\ntype Props = Record<string, unknown>\n\ntype HostContext = {\n type: ElementNames\n isFile: boolean\n isSource: boolean\n}\n\nlet currentUpdatePriority = NoEventPriority\n\n/**\n * @link https://www.npmjs.com/package/react-devtools-inline\n * @link https://github.com/nitin42/Making-a-custom-React-renderer/blob/master/part-one.md\n * @link https://github.com/facebook/react/tree/main/packages/react-reconciler#practical-examples\n * @link https://github.com/vadimdemedes/ink\n * @link https://github.com/pixijs/pixi-react/tree/main/packages\n * @link https://github.com/diegomura/react-pdf/blob/master/packages/reconciler/src/reconciler-31.ts\n */\nexport const Renderer = Reconciler({\n getRootHostContext: () => ({\n type: 'kubb-root',\n isFile: false,\n isSource: false,\n }),\n prepareForCommit: () => {\n return null\n },\n preparePortalMount: () => null,\n clearContainer: () => false,\n resetAfterCommit(rootNode: DOMElement) {\n if (typeof rootNode.onRender === 'function') {\n rootNode.onRender()\n }\n },\n getChildHostContext(parentHostContext: HostContext, type: ElementNames) {\n const isInsideText = type === 'kubb-text'\n const isFile = type === 'kubb-file' || parentHostContext.isFile\n const isSource = type === 'kubb-source' || parentHostContext.isSource\n\n return { isInsideText, isFile, isSource, type }\n },\n shouldSetTextContent: () => false,\n createInstance(originalType: ElementNames, newProps: Props, _root: DOMElement) {\n const node = createNode(originalType)\n\n for (const [key, value] of Object.entries(newProps)) {\n if (key === 'children') {\n continue\n }\n\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n\n return node\n },\n createTextInstance(text: string, _root: DOMElement, hostContext: HostContext) {\n if (hostContext.isFile && !hostContext.isSource) {\n throw new Error(`[react] '${text}' should be part of <File.Source> component when using the <File/> component`)\n }\n\n return createTextNode(text)\n },\n resetTextContent() {},\n hideTextInstance(node: TextNode) {\n setTextNodeValue(node, '')\n },\n unhideTextInstance(node: TextNode, text: string) {\n setTextNodeValue(node, text)\n },\n getPublicInstance: (instance) => instance,\n appendInitialChild: appendChildNode,\n appendChild: appendChildNode,\n insertBefore: insertBeforeNode,\n finalizeInitialChildren(_node, _type, _props, _rootNode) {\n return false\n },\n supportsMutation: true,\n isPrimaryRenderer: true,\n supportsPersistence: false,\n supportsHydration: false,\n scheduleTimeout: setTimeout,\n cancelTimeout: clearTimeout,\n noTimeout: -1,\n beforeActiveInstanceBlur() {},\n afterActiveInstanceBlur() {},\n detachDeletedInstance() {},\n getInstanceFromNode: () => null,\n prepareScopeUpdate() {},\n getInstanceFromScope: () => null,\n appendChildToContainer: appendChildNode,\n insertInContainerBefore: insertBeforeNode,\n removeChildFromContainer(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n commitMount() {},\n commitUpdate(node: DOMElement, _payload, _type, _oldProps: Props, newProps: Props) {\n const { props } = newProps\n\n if (props) {\n for (const [key, value] of Object.entries(props)) {\n setAttribute(node, key, value as DOMNodeAttribute)\n }\n }\n },\n commitTextUpdate(node: TextNode, _oldText, newText) {\n setTextNodeValue(node, newText)\n },\n removeChild(node: DOMElement, removeNode: TextNode) {\n removeChildNode(node, removeNode)\n },\n setCurrentUpdatePriority: (newPriority: number) => {\n currentUpdatePriority = newPriority\n },\n getCurrentUpdatePriority: () => currentUpdatePriority,\n resolveUpdatePriority() {\n if (currentUpdatePriority !== NoEventPriority) {\n return currentUpdatePriority\n }\n\n return DefaultEventPriority\n },\n maySuspendCommit() {\n return false\n },\n // eslint-disable-next-line @typescript-eslint/naming-convention\n NotPendingTransition: undefined,\n // eslint-disable-next-line @typescript-eslint/naming-convention\n HostTransitionContext: createContext(null) as unknown as ReactContext<unknown>,\n resetFormInstance() {},\n requestPostPaintCallback() {},\n shouldAttemptEagerTransition() {\n return false\n },\n trackSchedulerEvent() {},\n resolveEventType() {\n return null\n },\n resolveEventTimeStamp() {\n return -1.1\n },\n preloadInstance() {\n return true\n },\n startSuspendingCommit() {},\n suspendInstance() {},\n waitForCommitToBeReady() {\n return null\n },\n})\n\nexport type { FiberRoot } from 'react-reconciler'\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashExportNodes(node: DOMElement): Set<KubbFile.ResolvedExport> {\n let exports = new Set<KubbFile.Export>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n exports = new Set([...exports, ...squashExportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n exports.add(attributes)\n }\n })\n\n return exports\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashImportNodes(node: DOMElement): Set<KubbFile.Import> {\n let imports = new Set<KubbFile.Import>()\n\n node.childNodes.filter(Boolean).forEach((childNode) => {\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n imports = new Set([...imports, ...squashImportNodes(childNode)])\n }\n\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n imports.add(attributes)\n }\n })\n\n return imports\n}\n","import { createExport, createImport, print } from '@kubb/fabric-core/parsers/typescript'\n\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\n\nexport function squashTextNodes(node: DOMElement): string {\n let text = ''\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n let nodeText = ''\n\n const getPrintText = (text: string): string => {\n if (childNode.nodeName === 'kubb-import') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Import>\n\n return print([\n createImport({\n name: attributes.name,\n path: attributes.path,\n root: attributes.root,\n isTypeOnly: attributes.isTypeOnly,\n }),\n ])\n }\n\n if (childNode.nodeName === 'kubb-export') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Export>\n if (attributes.path) {\n return print([\n createExport({\n name: attributes.name,\n path: attributes.path,\n isTypeOnly: attributes.isTypeOnly,\n asAlias: attributes.asAlias,\n }),\n ])\n }\n }\n\n if (childNode.nodeName === 'kubb-source') {\n return text\n }\n\n return text\n }\n\n if (childNode.nodeName === '#text') {\n nodeText = childNode.nodeValue\n } else {\n if (['kubb-text', 'kubb-file', 'kubb-source'].includes(childNode.nodeName)) {\n nodeText = squashTextNodes(childNode)\n }\n\n nodeText = getPrintText(nodeText)\n\n if (childNode.nodeName === 'br') {\n nodeText = '\\n'\n }\n\n // no kubb element or br\n if (![...nodeNames, 'br'].includes(childNode.nodeName)) {\n const attributes = Object.entries(childNode.attributes).reduce((acc, [key, value]) => {\n if (typeof value === 'string') {\n return `${acc} ${key}=\"${value}\"`\n }\n\n return `${acc} ${key}={${value}}`\n }, '')\n nodeText = `<${childNode.nodeName}${attributes}>${squashTextNodes(childNode)}</${childNode.nodeName}>`\n }\n }\n\n text += nodeText\n }\n\n return text\n}\n","import type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement, ElementNames } from '../types.ts'\nimport { squashTextNodes } from './squashTextNodes.ts'\n\nexport function squashSourceNodes(node: DOMElement, ignores: Array<ElementNames>): Set<KubbFile.Source> {\n let sources = new Set<KubbFile.Source>()\n\n for (const childNode of node.childNodes) {\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && ignores.includes(childNode.nodeName)) {\n continue\n }\n\n if (childNode.nodeName === 'kubb-source') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File.Source>\n const value = squashTextNodes(childNode)\n\n sources.add({\n ...attributes,\n // remove end enter\n value: value.trim().replace(/^\\s+|\\s+$/g, ''),\n })\n\n continue\n }\n\n if (childNode.nodeName !== '#text' && nodeNames.includes(childNode.nodeName)) {\n sources = new Set([...sources, ...squashSourceNodes(childNode, ignores)])\n }\n }\n\n return sources\n}\n","import type { FileManager } from '@kubb/fabric-core'\nimport type { KubbFile } from '@kubb/fabric-core/types'\nimport type React from 'react'\nimport type { File } from '../components/File.tsx'\nimport { nodeNames } from '../dom.ts'\nimport type { DOMElement } from '../types.ts'\nimport { squashExportNodes } from './squashExportNodes.ts'\nimport { squashImportNodes } from './squashImportNodes.ts'\nimport { squashSourceNodes } from './squashSourceNodes.ts'\n\nexport function processFiles(node: DOMElement, fileManager: FileManager) {\n for (let index = 0; index < node.childNodes.length; index++) {\n const childNode = node.childNodes[index]\n\n if (!childNode) {\n continue\n }\n\n if (childNode.nodeName !== '#text' && childNode.nodeName !== 'kubb-file' && nodeNames.includes(childNode.nodeName)) {\n processFiles(childNode, fileManager)\n }\n\n if (childNode.nodeName === 'kubb-file') {\n const attributes = childNode.attributes as React.ComponentProps<typeof File>\n\n if (attributes.baseName && attributes.path) {\n const sources = squashSourceNodes(childNode, ['kubb-export', 'kubb-import'])\n\n const file: KubbFile.File = {\n baseName: attributes.baseName,\n path: attributes.path,\n sources: [...sources],\n exports: [...squashExportNodes(childNode)],\n imports: [...squashImportNodes(childNode)],\n meta: attributes.meta || {},\n footer: attributes.footer,\n banner: attributes.banner,\n }\n\n fileManager.add(file)\n }\n }\n }\n}\n","import process from 'node:process'\nimport type { FileManager } from '@kubb/fabric-core'\nimport type { ReactNode } from 'react'\nimport { ConcurrentRoot } from 'react-reconciler/constants.js'\nimport { onExit } from 'signal-exit'\nimport { Root } from './components/Root.tsx'\nimport { createNode } from './dom.ts'\nimport type { FiberRoot } from './Renderer.ts'\nimport { Renderer } from './Renderer.ts'\nimport type { DOMElement } from './types.ts'\nimport { processFiles } from './utils/processFiles.ts'\nimport { squashTextNodes } from './utils/squashTextNodes.ts'\n\ntype Options = {\n fileManager: FileManager\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\nexport class Runtime {\n readonly #options: Options\n // Ignore last render after unmounting a tree to prevent empty output before exit\n #isUnmounted: boolean\n\n exitPromise?: Promise<void>\n readonly #container: FiberRoot\n readonly #rootNode: DOMElement\n\n constructor(options: Options) {\n this.#options = options\n\n this.#rootNode = createNode('kubb-root')\n this.#rootNode.onRender = this.onRender\n this.#rootNode.onImmediateRender = this.onRender\n\n // Ignore last render after unmounting a tree to prevent empty output before exit\n this.#isUnmounted = false\n this.unmount.bind(this)\n\n const originalError = console.error\n console.error = (data: string | Error) => {\n const message = typeof data === 'string' ? data : data?.message\n\n if (message?.match(/Encountered two children with the same key/gi)) {\n return\n }\n if (message?.match(/React will try to recreat/gi)) {\n return\n }\n if (message?.match(/Each child in a list should have a unique/gi)) {\n return\n }\n if (message?.match(/The above error occurred in the <KubbErrorBoundary/gi)) {\n return\n }\n\n if (message?.match(/A React Element from an older version of React was render/gi)) {\n return\n }\n\n originalError(data)\n }\n\n // Report when an error was detected in a previous render\n // https://github.com/pmndrs/react-three-fiber/pull/2261\n const logRecoverableError =\n typeof reportError === 'function'\n ? // In modern browsers, reportError will dispatch an error event,\n // emulating an uncaught JavaScript error.\n reportError\n : // In older browsers and test environments, fallback to console.error.\n console.error\n\n const rootTag = ConcurrentRoot\n const hydrationCallbacks = null\n const isStrictMode = false\n const concurrentUpdatesByDefaultOverride = false\n const identifierPrefix = 'id'\n const onUncaughtError = logRecoverableError\n const onCaughtError = logRecoverableError\n const onRecoverableError = logRecoverableError\n const transitionCallbacks = null\n\n this.#container = Renderer.createContainer(\n this.#rootNode,\n rootTag,\n hydrationCallbacks,\n isStrictMode,\n concurrentUpdatesByDefaultOverride,\n identifierPrefix,\n onUncaughtError,\n onCaughtError,\n onRecoverableError,\n transitionCallbacks,\n )\n\n // Unmount when process exits\n this.unsubscribeExit = onExit(\n (code) => {\n this.unmount(code)\n },\n { alwaysLast: false },\n ).bind(this)\n\n Renderer.injectIntoDevTools({\n bundleType: 1, // 0 for PROD, 1 for DEV\n version: '19.1.0', // should be React version and not Kubb's custom version\n rendererPackageName: 'kubb', // package name\n })\n }\n\n get fileManager() {\n return this.#options.fileManager\n }\n\n resolveExitPromise: () => void = () => {}\n rejectExitPromise: (reason?: Error) => void = () => {}\n unsubscribeExit: () => void = () => {}\n onRender: () => void = async () => {\n if (this.#isUnmounted) {\n return\n }\n\n // TODO remove to allow multiple renders\n this.fileManager.clear()\n\n processFiles(this.#rootNode, this.fileManager)\n\n if (!this.#options?.debug && !this.#options?.stdout) {\n return\n }\n\n const output = await this.#getOutput(this.#rootNode)\n\n if (this.#options?.debug) {\n console.log('Rendering: \\n')\n console.log(output)\n }\n\n if (this.#options?.stdout && process.env.NODE_ENV !== 'test') {\n this.#options.stdout.clearLine(0)\n this.#options.stdout.cursorTo(0)\n this.#options.stdout.write(output)\n }\n }\n onError(error: Error): void {\n if (process.env.NODE_ENV === 'test') {\n console.warn(error)\n }\n\n throw error\n }\n onExit(error?: Error): void {\n this.unmount(error)\n }\n\n async #getOutput(node: DOMElement): Promise<string> {\n const text = squashTextNodes(node)\n const files = this.fileManager.files\n\n return files.length\n ? [...files]\n .flatMap((file) => [...file.sources].map((item) => item.value))\n .filter(Boolean)\n .join('\\n\\n')\n : text\n }\n\n render(node: ReactNode): void {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n }\n\n async renderToString(node: ReactNode): Promise<string> {\n const element = (\n <Root onExit={this.onExit.bind(this)} onError={this.onError.bind(this)}>\n {node}\n </Root>\n )\n\n Renderer.updateContainerSync(element, this.#container, null, null)\n Renderer.flushSyncWork()\n\n this.fileManager.clear()\n\n return this.#getOutput(this.#rootNode)\n }\n\n unmount(error?: Error | number | null): void {\n if (this.#isUnmounted) {\n return\n }\n\n if (this.#options?.debug) {\n console.log('Unmount', error)\n }\n\n this.onRender()\n this.unsubscribeExit()\n\n this.#isUnmounted = true\n\n Renderer.updateContainerSync(null, this.#container, null, null)\n\n if (error instanceof Error) {\n this.rejectExitPromise(error)\n\n return\n }\n\n this.resolveExitPromise()\n }\n\n async waitUntilExit(): Promise<void> {\n if (!this.exitPromise) {\n this.exitPromise = new Promise((resolve, reject) => {\n this.resolveExitPromise = resolve\n this.rejectExitPromise = reject\n })\n }\n\n return this.exitPromise\n }\n}\n","import { createPlugin } from '@kubb/fabric-core/plugins'\nimport { createElement, type ElementType } from 'react'\nimport { Runtime } from '../Runtime.tsx'\n\nexport type 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 global {\n namespace Kubb {\n interface Fabric {\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(ctx, options = {}) {\n const runtime = new Runtime({ fileManager: ctx.fileManager, ...options })\n\n return {\n async render(App) {\n runtime.render(createElement(App))\n await ctx.emit('start')\n },\n async renderToString(App) {\n await ctx.emit('start')\n return runtime.renderToString(createElement(App))\n },\n async waitUntilExit() {\n await runtime.waitUntilExit()\n\n await ctx.emit('end')\n },\n }\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAM,gBAAN,cAA4BA,gBAGzB;;;wBACD,SAAQ,EAAE,UAAU,OAAO;;CAG3B,OAAO,yBAAyB,QAAe;AAC7C,SAAO,EAAE,UAAU,MAAM;;CAG3B,kBAAkB,OAAc;AAC9B,MAAI,MACF,MAAK,MAAM,QAAQ,MAAM;;CAI7B,SAAS;AACP,MAAI,KAAK,MAAM,SACb,QAAO;AAET,SAAO,KAAK,MAAM;;;+BAfb,eAAc;AA0BvB,MAAa,uCAA8C,EACzD,YAAY,IACb,CAAC;AAcF,SAAgB,KAAK,EAAE,SAAS,kBAAQ,YAA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qe4Bx.js";
1
+ import { b as Source, g as Import, h as File, p as Export } from "./Fabric-C3xWWIb6.js";
2
2
  import React, { JSX, Key, ReactNode } from "react";
3
3
 
4
- //#region ../fabric-core/src/defineFabric.d.ts
5
- type RootRenderFunction<TOptions extends FabricOptions> = (fabric: Fabric<TOptions>) => void | Promise<void>;
6
- type DefineFabric<TOptions extends FabricOptions> = (config?: FabricConfig<TOptions>) => Fabric<TOptions>;
7
- declare function defineFabric<TOptions extends FabricOptions>(instance?: RootRenderFunction<TOptions>): DefineFabric<TOptions>;
8
- //#endregion
9
4
  //#region src/utils/getFunctionParams.d.ts
10
5
  type Param = {
11
6
  /**
@@ -105,5 +100,5 @@ type KubbImportProps = Import;
105
100
  type KubbExportProps = Export;
106
101
  type LineBreakProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
107
102
  //#endregion
108
- export { Param as _, JSDoc as a, DefineFabric as b, KubbExportProps as c, KubbNode as d, KubbSourceProps as f, FunctionParams as g, TextNode as h, ElementNames as i, KubbFileProps as l, LineBreakProps as m, DOMNode as n, Key as o, KubbTextProps as p, DOMNodeAttribute as r, KubbElement as s, DOMElement as t, KubbImportProps as u, Params as v, defineFabric as x, createFunctionParams as y };
109
- //# sourceMappingURL=types-wwcxhf6Y.d.ts.map
103
+ export { Param as _, JSDoc as a, KubbExportProps as c, KubbNode as d, KubbSourceProps as f, FunctionParams as g, TextNode as h, ElementNames as i, KubbFileProps as l, LineBreakProps as m, DOMNode as n, Key as o, KubbTextProps as p, DOMNodeAttribute as r, KubbElement as s, DOMElement as t, KubbImportProps as u, Params as v, createFunctionParams as y };
104
+ //# sourceMappingURL=types-CJRSKjOD.d.ts.map
@@ -1,11 +1,6 @@
1
- import { a as FabricOptions, b as Source, g as Import, h as File, n as FabricConfig, p as Export, t as Fabric } from "./Fabric-BPUyMklG.cjs";
1
+ import { b as Source, g as Import, h as File, p as Export } from "./Fabric-MsFHiZXy.cjs";
2
2
  import React, { JSX, Key, ReactNode } from "react";
3
3
 
4
- //#region ../fabric-core/src/defineFabric.d.ts
5
- type RootRenderFunction<TOptions extends FabricOptions> = (fabric: Fabric<TOptions>) => void | Promise<void>;
6
- type DefineFabric<TOptions extends FabricOptions> = (config?: FabricConfig<TOptions>) => Fabric<TOptions>;
7
- declare function defineFabric<TOptions extends FabricOptions>(instance?: RootRenderFunction<TOptions>): DefineFabric<TOptions>;
8
- //#endregion
9
4
  //#region src/utils/getFunctionParams.d.ts
10
5
  type Param = {
11
6
  /**
@@ -105,5 +100,5 @@ type KubbImportProps = Import;
105
100
  type KubbExportProps = Export;
106
101
  type LineBreakProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLBRElement>, HTMLBRElement>;
107
102
  //#endregion
108
- export { Param as _, JSDoc as a, DefineFabric as b, KubbExportProps as c, KubbNode as d, KubbSourceProps as f, FunctionParams as g, TextNode as h, ElementNames as i, KubbFileProps as l, LineBreakProps as m, DOMNode as n, Key as o, KubbTextProps as p, DOMNodeAttribute as r, KubbElement as s, DOMElement as t, KubbImportProps as u, Params as v, defineFabric as x, createFunctionParams as y };
109
- //# sourceMappingURL=types-CsFxfaSV.d.cts.map
103
+ export { Param as _, JSDoc as a, KubbExportProps as c, KubbNode as d, KubbSourceProps as f, FunctionParams as g, TextNode as h, ElementNames as i, KubbFileProps as l, LineBreakProps as m, DOMNode as n, Key as o, KubbTextProps as p, DOMNodeAttribute as r, KubbElement as s, DOMElement as t, KubbImportProps as u, Params as v, createFunctionParams as y };
104
+ //# sourceMappingURL=types-g8BNi4jj.d.cts.map
package/dist/types.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- import { _ as KubbFile_d_exports, a as FabricOptions, i as FabricMode, n as FabricConfig, r as FabricContext } from "./Fabric-BPUyMklG.cjs";
2
- import { _ as Param, a as JSDoc, b as DefineFabric, c as KubbExportProps, d as KubbNode, f as KubbSourceProps, h as TextNode, i as ElementNames, l as KubbFileProps, m as LineBreakProps, n as DOMNode, o as Key, p as KubbTextProps, r as DOMNodeAttribute, s as KubbElement, t as DOMElement, u as KubbImportProps, v as Params } from "./types-CsFxfaSV.cjs";
3
- export { DOMElement, DOMNode, DOMNodeAttribute, DefineFabric, ElementNames, FabricConfig, FabricContext, FabricMode, FabricOptions, JSDoc, Key, KubbElement, KubbExportProps, KubbFile_d_exports as KubbFile, KubbFileProps, KubbImportProps, KubbNode, KubbSourceProps, KubbTextProps, LineBreakProps, Param, Params, TextNode };
1
+ import { _ as KubbFile_d_exports, a as FabricOptions, i as FabricMode, n as FabricConfig, r as FabricContext } from "./Fabric-MsFHiZXy.cjs";
2
+ import { _ as Param, a as JSDoc, c as KubbExportProps, d as KubbNode, f as KubbSourceProps, h as TextNode, i as ElementNames, l as KubbFileProps, m as LineBreakProps, n as DOMNode, o as Key, p as KubbTextProps, r as DOMNodeAttribute, s as KubbElement, t as DOMElement, u as KubbImportProps, v as Params } from "./types-g8BNi4jj.cjs";
3
+ export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, FabricConfig, FabricContext, FabricMode, FabricOptions, JSDoc, Key, KubbElement, KubbExportProps, KubbFile_d_exports as KubbFile, KubbFileProps, KubbImportProps, KubbNode, KubbSourceProps, KubbTextProps, LineBreakProps, Param, Params, TextNode };
package/dist/types.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { _ as KubbFile_d_exports, a as FabricOptions, i as FabricMode, n as FabricConfig, r as FabricContext } from "./Fabric-t9Xqe4Bx.js";
2
- import { _ as Param, a as JSDoc, b as DefineFabric, c as KubbExportProps, d as KubbNode, f as KubbSourceProps, h as TextNode, i as ElementNames, l as KubbFileProps, m as LineBreakProps, n as DOMNode, o as Key, p as KubbTextProps, r as DOMNodeAttribute, s as KubbElement, t as DOMElement, u as KubbImportProps, v as Params } from "./types-wwcxhf6Y.js";
3
- export { DOMElement, DOMNode, DOMNodeAttribute, DefineFabric, ElementNames, FabricConfig, FabricContext, FabricMode, FabricOptions, JSDoc, Key, KubbElement, KubbExportProps, KubbFile_d_exports as KubbFile, KubbFileProps, KubbImportProps, KubbNode, KubbSourceProps, KubbTextProps, LineBreakProps, Param, Params, TextNode };
1
+ import { _ as KubbFile_d_exports, a as FabricOptions, i as FabricMode, n as FabricConfig, r as FabricContext } from "./Fabric-C3xWWIb6.js";
2
+ import { _ as Param, a as JSDoc, c as KubbExportProps, d as KubbNode, f as KubbSourceProps, h as TextNode, i as ElementNames, l as KubbFileProps, m as LineBreakProps, n as DOMNode, o as Key, p as KubbTextProps, r as DOMNodeAttribute, s as KubbElement, t as DOMElement, u as KubbImportProps, v as Params } from "./types-CJRSKjOD.js";
3
+ export { DOMElement, DOMNode, DOMNodeAttribute, ElementNames, FabricConfig, FabricContext, FabricMode, FabricOptions, JSDoc, Key, KubbElement, KubbExportProps, KubbFile_d_exports as KubbFile, KubbFileProps, KubbImportProps, KubbNode, KubbSourceProps, KubbTextProps, LineBreakProps, Param, Params, TextNode };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/react-fabric",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
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",
@@ -113,7 +113,7 @@
113
113
  "react-reconciler": "0.32.0",
114
114
  "signal-exit": "^4.1.0",
115
115
  "ws": "8.18.0",
116
- "@kubb/fabric-core": "0.2.15"
116
+ "@kubb/fabric-core": "0.2.16"
117
117
  },
118
118
  "devDependencies": {
119
119
  "@types/react": "^19.2.2",
@@ -18,16 +18,6 @@ type ExtendOptions = {
18
18
  waitUntilExit(): Promise<void>
19
19
  }
20
20
 
21
- // biome-ignore lint/suspicious/noTsIgnore: production ready
22
- // @ts-ignore
23
- declare module '@kubb/fabric-core' {
24
- interface Fabric {
25
- render(App: ElementType): Promise<void> | void
26
- renderToString(App: ElementType): Promise<string> | string
27
- waitUntilExit(): Promise<void>
28
- }
29
- }
30
-
31
21
  declare global {
32
22
  namespace Kubb {
33
23
  interface Fabric {