@kubb/react-fabric 0.2.14 → 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.
Files changed (66) hide show
  1. package/README.md +5 -1
  2. package/dist/{Fabric-mFmfnVJp.d.ts → Fabric-C3xWWIb6.d.ts} +108 -63
  3. package/dist/{Fabric-B8W5_3xv.d.cts → Fabric-MsFHiZXy.d.cts} +108 -63
  4. package/dist/{devtools-D4p2T_2t.cjs → devtools-CLhxB1Hr.cjs} +3 -3
  5. package/dist/devtools-CLhxB1Hr.cjs.map +1 -0
  6. package/dist/{devtools-Cb1pMQYm.js → devtools-wdFpV122.js} +2 -2
  7. package/dist/devtools-wdFpV122.js.map +1 -0
  8. package/dist/devtools.cjs +1 -1
  9. package/dist/devtools.js +1 -1
  10. package/dist/globals.d.cts +2 -2
  11. package/dist/globals.d.ts +2 -2
  12. package/dist/index.cjs +5 -5
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +34 -12
  15. package/dist/index.d.ts +34 -12
  16. package/dist/index.js +4 -4
  17. package/dist/index.js.map +1 -1
  18. package/dist/jsx-dev-runtime.d.cts +3 -3
  19. package/dist/jsx-dev-runtime.d.ts +3 -3
  20. package/dist/{jsx-namespace-Czey9R9N.d.ts → jsx-namespace-Cz6OfCDG.d.ts} +2 -2
  21. package/dist/{jsx-namespace-c3pSYEW1.d.cts → jsx-namespace-laCWw619.d.cts} +2 -2
  22. package/dist/{jsx-runtime-CVfJARUD.js → jsx-runtime-Dm0btT2y.js} +1 -1
  23. package/dist/jsx-runtime.cjs +1 -1
  24. package/dist/jsx-runtime.d.cts +3 -3
  25. package/dist/jsx-runtime.d.ts +4 -4
  26. package/dist/jsx-runtime.js +1 -1
  27. package/dist/parsers.d.cts +1 -1
  28. package/dist/parsers.d.ts +1 -1
  29. package/dist/plugins.cjs +2 -2
  30. package/dist/plugins.d.cts +31 -41
  31. package/dist/plugins.d.ts +31 -41
  32. package/dist/plugins.js +2 -2
  33. package/dist/{reactPlugin-DCuv3mQy.js → reactPlugin-BmBx9cO3.js} +36 -36
  34. package/dist/reactPlugin-BmBx9cO3.js.map +1 -0
  35. package/dist/{reactPlugin-DJqKlTY6.d.ts → reactPlugin-D8rqKtK0.d.cts} +2 -9
  36. package/dist/{reactPlugin-wV1eBuBU.d.cts → reactPlugin-DY-MH4LN.d.ts} +2 -9
  37. package/dist/{reactPlugin-DN7FaU4S.cjs → reactPlugin-Dj5m_pqf.cjs} +36 -36
  38. package/dist/reactPlugin-Dj5m_pqf.cjs.map +1 -0
  39. package/dist/{types-DAb8l-KJ.d.ts → types-CJRSKjOD.d.ts} +3 -8
  40. package/dist/{types-kzoLNjog.d.cts → types-g8BNi4jj.d.cts} +3 -8
  41. package/dist/types.d.cts +3 -3
  42. package/dist/types.d.ts +3 -3
  43. package/package.json +2 -2
  44. package/src/Renderer.ts +1 -2
  45. package/src/Runtime.tsx +2 -2
  46. package/src/components/File.tsx +1 -2
  47. package/src/components/Function.tsx +1 -1
  48. package/src/composables/useFile.ts +1 -3
  49. package/src/createReactFabric.ts +3 -4
  50. package/src/devtools.ts +1 -2
  51. package/src/globals.ts +1 -1
  52. package/src/index.ts +5 -9
  53. package/src/jsx-dev-runtime.ts +1 -2
  54. package/src/jsx-runtime.ts +2 -2
  55. package/src/plugins/reactPlugin.ts +6 -16
  56. package/src/types.ts +3 -3
  57. package/src/utils/processFiles.ts +5 -6
  58. package/src/utils/squashExportNodes.ts +1 -2
  59. package/src/utils/squashImportNodes.ts +1 -2
  60. package/src/utils/squashSourceNodes.ts +1 -2
  61. package/src/utils/squashTextNodes.ts +1 -1
  62. package/dist/devtools-Cb1pMQYm.js.map +0 -1
  63. package/dist/devtools-D4p2T_2t.cjs.map +0 -1
  64. package/dist/reactPlugin-DCuv3mQy.js.map +0 -1
  65. package/dist/reactPlugin-DN7FaU4S.cjs.map +0 -1
  66. package/dist/{jsx-runtime-CpPZNgzW.cjs → jsx-runtime-CywUjp4I.cjs} +2 -2
package/README.md CHANGED
@@ -42,7 +42,7 @@ Below is a minimal example showing how `createFabric` works together with plugin
42
42
  ```ts
43
43
  import { createFabric } from '@kubb/fabric-core'
44
44
  import { fsPlugin } from '@kubb/fabric-core/plugins'
45
- import { typescriptParser, createParser } from '@kubb/fabric-core/parsers'
45
+ import { typescriptParser } from '@kubb/fabric-core/parsers'
46
46
 
47
47
  const fabric = createFabric()
48
48
 
@@ -65,7 +65,11 @@ await fabric.addFile({
65
65
  })
66
66
 
67
67
  await fabric.write()
68
+ ```
68
69
 
70
+ Creates a file `generated/index.ts` with the following content:
71
+ ```ts
72
+ export const x = 1
69
73
  ```
70
74
 
71
75
  # API Reference
@@ -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
@@ -118,20 +117,6 @@ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
118
117
  exports: Array<ResolvedExport>;
119
118
  };
120
119
  //#endregion
121
- //#region ../fabric-core/src/plugins/types.d.ts
122
- type Plugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = {
123
- name: string;
124
- type: 'plugin';
125
- install: Install<TOptions>;
126
- /**
127
- * Runtime app overrides or extensions.
128
- * Merged into the app instance after install.
129
- * This cannot be async
130
- */
131
- inject?: Inject<TOptions, TAppExtension>;
132
- };
133
- type UserPlugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension>, 'type'>;
134
- //#endregion
135
120
  //#region ../fabric-core/src/parsers/types.d.ts
136
121
  type PrintOptions = {
137
122
  extname?: Extname;
@@ -152,9 +137,16 @@ type Parser<TOptions = unknown, TMeta extends object = any> = {
152
137
  type UserParser<TOptions = unknown, TMeta extends object = any> = Omit<Parser<TOptions, TMeta>, 'type'>;
153
138
  //#endregion
154
139
  //#region ../fabric-core/src/utils/AsyncEventEmitter.d.ts
140
+ type Options$2 = {
141
+ mode?: FabricMode;
142
+ maxListener?: number;
143
+ };
155
144
  declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
156
145
  #private;
157
- constructor(maxListener?: number);
146
+ constructor({
147
+ maxListener,
148
+ mode
149
+ }?: Options$2);
158
150
  emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
159
151
  on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
160
152
  onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
@@ -217,42 +209,65 @@ declare class FileManager {
217
209
  write(options: ProcessFilesProps): Promise<ResolvedFile[]>;
218
210
  }
219
211
  //#endregion
212
+ //#region ../fabric-core/src/plugins/types.d.ts
213
+ type Plugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = {
214
+ name: string;
215
+ type: 'plugin';
216
+ install: Install<TOptions>;
217
+ /**
218
+ * Runtime app overrides or extensions.
219
+ * Merged into the app instance after install.
220
+ * This cannot be async
221
+ */
222
+ inject?: Inject<TOptions, TAppExtension>;
223
+ };
224
+ type UserPlugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension>, 'type'>;
225
+ //#endregion
220
226
  //#region ../fabric-core/src/Fabric.d.ts
221
227
  declare global {
222
228
  namespace Kubb {
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,33 +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> = {
300
- config?: FabricConfig<TOptions>;
301
- events: AsyncEventEmitter<FabricEvents>;
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. */
302
315
  fileManager: FileManager;
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. */
303
321
  installedPlugins: Set<Plugin>;
304
322
  installedParsers: Set<Parser>;
305
- };
306
- 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
+ */
307
334
  type AllOptional<T> = {} extends T ? true : false;
308
- type FabricConfig<TOptions extends FabricOptions> = {
309
- options: TOptions;
310
- };
311
- type Install<TOptions = unknown> = TOptions extends any[] ? (app: Fabric, ...options: TOptions) => void | Promise<void> : AllOptional<TOptions> extends true ? (app: Fabric, options: TOptions | undefined) => void | Promise<void> : (app: Fabric, options: TOptions) => void | Promise<void>;
312
- type Inject<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = TOptions extends any[] ? (app: Fabric, ...options: TOptions) => Partial<TAppExtension> : AllOptional<TOptions> extends true ? (app: Fabric, options: TOptions | undefined) => Partial<TAppExtension> : (app: Fabric, options: TOptions) => Partial<TAppExtension>;
313
- interface Fabric<TOptions extends FabricOptions = FabricOptions> extends Kubb.Fabric {
314
- context: FabricContext<TOptions>;
315
- files: Array<ResolvedFile>;
316
- 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>;
317
- 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>;
318
363
  }
319
364
  //#endregion
320
- export { KubbFile_d_exports as _, FabricOptions as a, Source as b, Parser as c, UserPlugin as d, BaseName as f, Import as g, File as h, FabricMode as i, UserParser as l, Extname as m, FabricConfig as n, FileManager as o, Export as p, FabricContext as r, FileProcessor as s, Fabric as t, Plugin as u, Path as v, ResolvedFile as y };
321
- //# sourceMappingURL=Fabric-mFmfnVJp.d.ts.map
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 };
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
@@ -115,20 +114,6 @@ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
115
114
  exports: Array<ResolvedExport>;
116
115
  };
117
116
  //#endregion
118
- //#region ../fabric-core/src/plugins/types.d.ts
119
- type Plugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = {
120
- name: string;
121
- type: 'plugin';
122
- install: Install<TOptions>;
123
- /**
124
- * Runtime app overrides or extensions.
125
- * Merged into the app instance after install.
126
- * This cannot be async
127
- */
128
- inject?: Inject<TOptions, TAppExtension>;
129
- };
130
- type UserPlugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension>, 'type'>;
131
- //#endregion
132
117
  //#region ../fabric-core/src/parsers/types.d.ts
133
118
  type PrintOptions = {
134
119
  extname?: Extname;
@@ -149,9 +134,16 @@ type Parser<TOptions = unknown, TMeta extends object = any> = {
149
134
  type UserParser<TOptions = unknown, TMeta extends object = any> = Omit<Parser<TOptions, TMeta>, 'type'>;
150
135
  //#endregion
151
136
  //#region ../fabric-core/src/utils/AsyncEventEmitter.d.ts
137
+ type Options$2 = {
138
+ mode?: FabricMode;
139
+ maxListener?: number;
140
+ };
152
141
  declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
153
142
  #private;
154
- constructor(maxListener?: number);
143
+ constructor({
144
+ maxListener,
145
+ mode
146
+ }?: Options$2);
155
147
  emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void>;
156
148
  on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void;
157
149
  onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void;
@@ -214,42 +206,65 @@ declare class FileManager {
214
206
  write(options: ProcessFilesProps): Promise<ResolvedFile[]>;
215
207
  }
216
208
  //#endregion
209
+ //#region ../fabric-core/src/plugins/types.d.ts
210
+ type Plugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = {
211
+ name: string;
212
+ type: 'plugin';
213
+ install: Install<TOptions>;
214
+ /**
215
+ * Runtime app overrides or extensions.
216
+ * Merged into the app instance after install.
217
+ * This cannot be async
218
+ */
219
+ inject?: Inject<TOptions, TAppExtension>;
220
+ };
221
+ type UserPlugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension>, 'type'>;
222
+ //#endregion
217
223
  //#region ../fabric-core/src/Fabric.d.ts
218
224
  declare global {
219
225
  namespace Kubb {
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,33 +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> = {
297
- config?: FabricConfig<TOptions>;
298
- events: AsyncEventEmitter<FabricEvents>;
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. */
299
312
  fileManager: FileManager;
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. */
300
318
  installedPlugins: Set<Plugin>;
301
319
  installedParsers: Set<Parser>;
302
- };
303
- 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
+ */
304
331
  type AllOptional<T> = {} extends T ? true : false;
305
- type FabricConfig<TOptions extends FabricOptions> = {
306
- options: TOptions;
307
- };
308
- type Install<TOptions = unknown> = TOptions extends any[] ? (app: Fabric, ...options: TOptions) => void | Promise<void> : AllOptional<TOptions> extends true ? (app: Fabric, options: TOptions | undefined) => void | Promise<void> : (app: Fabric, options: TOptions) => void | Promise<void>;
309
- type Inject<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = TOptions extends any[] ? (app: Fabric, ...options: TOptions) => Partial<TAppExtension> : AllOptional<TOptions> extends true ? (app: Fabric, options: TOptions | undefined) => Partial<TAppExtension> : (app: Fabric, options: TOptions) => Partial<TAppExtension>;
310
- interface Fabric<TOptions extends FabricOptions = FabricOptions> extends Kubb.Fabric {
311
- context: FabricContext<TOptions>;
312
- files: Array<ResolvedFile>;
313
- 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>;
314
- 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>;
315
360
  }
316
361
  //#endregion
317
- export { KubbFile_d_exports as _, FabricOptions as a, Source as b, Parser as c, UserPlugin as d, BaseName as f, Import as g, File as h, FabricMode as i, UserParser as l, Extname as m, FabricConfig as n, FileManager as o, Export as p, FabricContext as r, FileProcessor as s, Fabric as t, Plugin as u, Path as v, ResolvedFile as y };
318
- //# sourceMappingURL=Fabric-B8W5_3xv.d.cts.map
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 };
363
+ //# sourceMappingURL=Fabric-MsFHiZXy.d.cts.map
@@ -1,10 +1,10 @@
1
1
  const require_chunk = require('./chunk-CUT6urMc.cjs');
2
+ let execa = require("execa");
3
+ execa = require_chunk.__toESM(execa);
2
4
  let signal_exit = require("signal-exit");
3
5
  signal_exit = require_chunk.__toESM(signal_exit);
4
6
  let ws = require("ws");
5
7
  ws = require_chunk.__toESM(ws);
6
- let execa = require("execa");
7
- execa = require_chunk.__toESM(execa);
8
8
 
9
9
  //#region src/devtools.ts
10
10
  function open() {
@@ -99,4 +99,4 @@ Object.defineProperty(exports, 'open', {
99
99
  return open;
100
100
  }
101
101
  });
102
- //# sourceMappingURL=devtools-D4p2T_2t.cjs.map
102
+ //# sourceMappingURL=devtools-CLhxB1Hr.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devtools-CLhxB1Hr.cjs","names":[],"sources":["../src/devtools.ts"],"sourcesContent":["import { execa } from 'execa'\nimport { onExit } from 'signal-exit'\nimport ws from 'ws'\n\ndeclare global {\n var WebSocket: typeof WebSocket\n var self: any\n var window: any\n var isDevtoolsEnabled: any\n}\n\nexport function open() {\n // biome-ignore lint/suspicious/noTsIgnore: cannot find types\n // @ts-ignore\n import('react-devtools-core').then((devtools) => {\n // Filter out Kubbs's internal components from devtools for a cleaner view.\n // See https://github.com/facebook/react/blob/edf6eac8a181860fd8a2d076a43806f1237495a1/packages/react-devtools-shared/src/types.js#L24\n const customGlobal = global as any\n customGlobal.WebSocket ||= ws\n customGlobal.window ||= global\n customGlobal.self ||= global\n customGlobal.isDevtoolsEnabled = true\n customGlobal.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'Context.Provider',\n isEnabled: true,\n isValid: true,\n },\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'KubbRoot',\n isEnabled: true,\n isValid: true,\n },\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'KubbErrorBoundary',\n isEnabled: true,\n isValid: true,\n },\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'kubb-file',\n isEnabled: true,\n isValid: true,\n },\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'kubb-text',\n isEnabled: true,\n isValid: true,\n },\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'kubb-import',\n isEnabled: true,\n isValid: true,\n },\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'kubb-export',\n isEnabled: true,\n isValid: true,\n },\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'kubb-source',\n isEnabled: true,\n isValid: true,\n },\n ]\n\n console.info('Opening devtools')\n const controller = new AbortController()\n execa({\n stdio: 'pipe',\n preferLocal: true,\n cancelSignal: controller.signal,\n gracefulCancel: true,\n })`npx react-devtools`\n\n ;(devtools as any).initialize()\n console.info('Connecting devtools')\n\n try {\n ;(devtools as any).connectToDevTools({\n host: 'localhost',\n port: 8097,\n useHttps: false,\n isAppActive: () => true,\n })\n } catch (e) {\n console.error(e)\n console.info('Error when connecting the devtools')\n }\n\n onExit(\n () => {\n console.info('Disconnecting devtools')\n controller.abort()\n },\n { alwaysLast: false },\n )\n })\n}\n"],"mappings":";;;;;;;;;AAWA,SAAgB,OAAO;AAGrB,QAAO,uBAAuB,MAAM,aAAa;EAG/C,MAAM,eAAe;AACrB,eAAa,cAAb,aAAa,YAAc;AAC3B,eAAa,WAAb,aAAa,SAAW;AACxB,eAAa,SAAb,aAAa,OAAS;AACtB,eAAa,oBAAoB;AACjC,eAAa,OAAO,uCAAuC;GACzD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACF;AAED,UAAQ,KAAK,mBAAmB;EAChC,MAAM,aAAa,IAAI,iBAAiB;AACxC,mBAAM;GACJ,OAAO;GACP,aAAa;GACb,cAAc,WAAW;GACzB,gBAAgB;GACjB,CAAC;AAED,EAAC,SAAiB,YAAY;AAC/B,UAAQ,KAAK,sBAAsB;AAEnC,MAAI;AACD,GAAC,SAAiB,kBAAkB;IACnC,MAAM;IACN,MAAM;IACN,UAAU;IACV,mBAAmB;IACpB,CAAC;WACK,GAAG;AACV,WAAQ,MAAM,EAAE;AAChB,WAAQ,KAAK,qCAAqC;;AAGpD,gCACQ;AACJ,WAAQ,KAAK,yBAAyB;AACtC,cAAW,OAAO;KAEpB,EAAE,YAAY,OAAO,CACtB;GACD"}
@@ -1,6 +1,6 @@
1
+ import { execa } from "execa";
1
2
  import { onExit } from "signal-exit";
2
3
  import ws from "ws";
3
- import { execa } from "execa";
4
4
 
5
5
  //#region src/devtools.ts
6
6
  function open() {
@@ -90,4 +90,4 @@ function open() {
90
90
 
91
91
  //#endregion
92
92
  export { open as t };
93
- //# sourceMappingURL=devtools-Cb1pMQYm.js.map
93
+ //# sourceMappingURL=devtools-wdFpV122.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devtools-wdFpV122.js","names":[],"sources":["../src/devtools.ts"],"sourcesContent":["import { execa } from 'execa'\nimport { onExit } from 'signal-exit'\nimport ws from 'ws'\n\ndeclare global {\n var WebSocket: typeof WebSocket\n var self: any\n var window: any\n var isDevtoolsEnabled: any\n}\n\nexport function open() {\n // biome-ignore lint/suspicious/noTsIgnore: cannot find types\n // @ts-ignore\n import('react-devtools-core').then((devtools) => {\n // Filter out Kubbs's internal components from devtools for a cleaner view.\n // See https://github.com/facebook/react/blob/edf6eac8a181860fd8a2d076a43806f1237495a1/packages/react-devtools-shared/src/types.js#L24\n const customGlobal = global as any\n customGlobal.WebSocket ||= ws\n customGlobal.window ||= global\n customGlobal.self ||= global\n customGlobal.isDevtoolsEnabled = true\n customGlobal.window.__REACT_DEVTOOLS_COMPONENT_FILTERS__ = [\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'Context.Provider',\n isEnabled: true,\n isValid: true,\n },\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'KubbRoot',\n isEnabled: true,\n isValid: true,\n },\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'KubbErrorBoundary',\n isEnabled: true,\n isValid: true,\n },\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'kubb-file',\n isEnabled: true,\n isValid: true,\n },\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'kubb-text',\n isEnabled: true,\n isValid: true,\n },\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'kubb-import',\n isEnabled: true,\n isValid: true,\n },\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'kubb-export',\n isEnabled: true,\n isValid: true,\n },\n {\n // ComponentFilterDisplayName\n type: 2,\n value: 'kubb-source',\n isEnabled: true,\n isValid: true,\n },\n ]\n\n console.info('Opening devtools')\n const controller = new AbortController()\n execa({\n stdio: 'pipe',\n preferLocal: true,\n cancelSignal: controller.signal,\n gracefulCancel: true,\n })`npx react-devtools`\n\n ;(devtools as any).initialize()\n console.info('Connecting devtools')\n\n try {\n ;(devtools as any).connectToDevTools({\n host: 'localhost',\n port: 8097,\n useHttps: false,\n isAppActive: () => true,\n })\n } catch (e) {\n console.error(e)\n console.info('Error when connecting the devtools')\n }\n\n onExit(\n () => {\n console.info('Disconnecting devtools')\n controller.abort()\n },\n { alwaysLast: false },\n )\n })\n}\n"],"mappings":";;;;;AAWA,SAAgB,OAAO;AAGrB,QAAO,uBAAuB,MAAM,aAAa;EAG/C,MAAM,eAAe;AACrB,eAAa,cAAb,aAAa,YAAc;AAC3B,eAAa,WAAb,aAAa,SAAW;AACxB,eAAa,SAAb,aAAa,OAAS;AACtB,eAAa,oBAAoB;AACjC,eAAa,OAAO,uCAAuC;GACzD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACD;IAEE,MAAM;IACN,OAAO;IACP,WAAW;IACX,SAAS;IACV;GACF;AAED,UAAQ,KAAK,mBAAmB;EAChC,MAAM,aAAa,IAAI,iBAAiB;AACxC,QAAM;GACJ,OAAO;GACP,aAAa;GACb,cAAc,WAAW;GACzB,gBAAgB;GACjB,CAAC;AAED,EAAC,SAAiB,YAAY;AAC/B,UAAQ,KAAK,sBAAsB;AAEnC,MAAI;AACD,GAAC,SAAiB,kBAAkB;IACnC,MAAM;IACN,MAAM;IACN,UAAU;IACV,mBAAmB;IACpB,CAAC;WACK,GAAG;AACV,WAAQ,MAAM,EAAE;AAChB,WAAQ,KAAK,qCAAqC;;AAGpD,eACQ;AACJ,WAAQ,KAAK,yBAAyB;AACtC,cAAW,OAAO;KAEpB,EAAE,YAAY,OAAO,CACtB;GACD"}
package/dist/devtools.cjs CHANGED
@@ -1,3 +1,3 @@
1
- const require_devtools = require('./devtools-D4p2T_2t.cjs');
1
+ const require_devtools = require('./devtools-CLhxB1Hr.cjs');
2
2
 
3
3
  exports.open = require_devtools.open;
package/dist/devtools.js CHANGED
@@ -1,3 +1,3 @@
1
- import { t as open } from "./devtools-Cb1pMQYm.js";
1
+ import { t as open } from "./devtools-wdFpV122.js";
2
2
 
3
3
  export { open };
@@ -1,5 +1,5 @@
1
- import "./Fabric-B8W5_3xv.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-kzoLNjog.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-mFmfnVJp.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-DAb8l-KJ.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.cjs CHANGED
@@ -1,13 +1,13 @@
1
1
  const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const require_reactPlugin = require('./reactPlugin-DN7FaU4S.cjs');
3
- require('./jsx-runtime-CpPZNgzW.cjs');
4
- const require_devtools = require('./devtools-D4p2T_2t.cjs');
2
+ const require_reactPlugin = require('./reactPlugin-Dj5m_pqf.cjs');
3
+ require('./jsx-runtime-CywUjp4I.cjs');
4
+ const require_devtools = require('./devtools-CLhxB1Hr.cjs');
5
+ let __kubb_fabric_core = require("@kubb/fabric-core");
6
+ __kubb_fabric_core = require_chunk.__toESM(__kubb_fabric_core);
5
7
  let react = require("react");
6
8
  react = require_chunk.__toESM(react);
7
9
  let dedent = require("dedent");
8
10
  dedent = require_chunk.__toESM(dedent);
9
- let __kubb_fabric_core = require("@kubb/fabric-core");
10
- __kubb_fabric_core = require_chunk.__toESM(__kubb_fabric_core);
11
11
  let natural_orderby = require("natural-orderby");
12
12
  natural_orderby = require_chunk.__toESM(natural_orderby);
13
13
  let react_jsx_runtime = require("react/jsx-runtime");