@kubb/fabric-core 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 (57) hide show
  1. package/README.md +5 -1
  2. package/dist/{Fabric-BfnUdEpq.d.cts → Fabric-AmREkq58.d.ts} +108 -63
  3. package/dist/{Fabric-CxMkO4Rt.d.ts → Fabric-CBrTERuf.d.cts} +108 -63
  4. package/dist/{defineProperty-CspRhtP3.cjs → defineProperty-Dlhh3lSJ.cjs} +58 -44
  5. package/dist/defineProperty-Dlhh3lSJ.cjs.map +1 -0
  6. package/dist/{defineProperty-BtekiGIK.js → defineProperty-_FBdEen_.js} +53 -39
  7. package/dist/defineProperty-_FBdEen_.js.map +1 -0
  8. package/dist/index.cjs +102 -60
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +25 -3
  11. package/dist/index.d.ts +25 -3
  12. package/dist/index.js +102 -60
  13. package/dist/index.js.map +1 -1
  14. package/dist/parsers/typescript.d.cts +2 -2
  15. package/dist/parsers/typescript.d.ts +2 -2
  16. package/dist/parsers.cjs.map +1 -1
  17. package/dist/parsers.d.cts +2 -2
  18. package/dist/parsers.d.ts +2 -2
  19. package/dist/parsers.js.map +1 -1
  20. package/dist/plugins.cjs +98 -104
  21. package/dist/plugins.cjs.map +1 -1
  22. package/dist/plugins.d.cts +30 -40
  23. package/dist/plugins.d.ts +30 -40
  24. package/dist/plugins.js +94 -100
  25. package/dist/plugins.js.map +1 -1
  26. package/dist/types.cjs.map +1 -1
  27. package/dist/types.d.cts +2 -3
  28. package/dist/types.d.ts +2 -3
  29. package/dist/types.js.map +1 -1
  30. package/dist/{typescriptParser-Dz9T1BQ1.d.cts → typescriptParser-C3B3dzh_.d.cts} +2 -2
  31. package/dist/typescriptParser-CNHO6H2_.cjs.map +1 -1
  32. package/dist/typescriptParser-CWT7zCJy.js.map +1 -1
  33. package/dist/{typescriptParser-DypTa1AN.d.ts → typescriptParser-DaOfAlmM.d.ts} +2 -2
  34. package/package.json +1 -1
  35. package/src/Fabric.ts +102 -52
  36. package/src/FileManager.ts +23 -6
  37. package/src/FileProcessor.ts +3 -4
  38. package/src/KubbFile.ts +0 -2
  39. package/src/createFile.ts +90 -74
  40. package/src/defineFabric.ts +53 -28
  41. package/src/index.ts +3 -3
  42. package/src/parsers/tsxParser.ts +1 -1
  43. package/src/parsers/types.ts +1 -1
  44. package/src/parsers/typescriptParser.ts +1 -1
  45. package/src/plugins/barrelPlugin.ts +13 -21
  46. package/src/plugins/fsPlugin.ts +8 -16
  47. package/src/plugins/graphPlugin.ts +8 -9
  48. package/src/plugins/index.ts +2 -3
  49. package/src/plugins/progressPlugin.ts +6 -6
  50. package/src/plugins/types.ts +1 -1
  51. package/src/types.ts +1 -2
  52. package/src/utils/AsyncEventEmitter.ts +29 -8
  53. package/dist/defineFabric-CR1OjcoI.d.ts +0 -9
  54. package/dist/defineFabric-TvKfRefj.d.cts +0 -9
  55. package/dist/defineProperty-BtekiGIK.js.map +0 -1
  56. package/dist/defineProperty-CspRhtP3.cjs.map +0 -1
  57. package/src/utils/EventEmitter.ts +0 -31
package/README.md CHANGED
@@ -43,7 +43,7 @@ Below is a minimal example showing how `createFabric` works together with plugin
43
43
  ```ts
44
44
  import { createFabric } from '@kubb/fabric-core'
45
45
  import { fsPlugin } from '@kubb/fabric-core/plugins'
46
- import { typescriptParser, createParser } from '@kubb/fabric-core/parsers'
46
+ import { typescriptParser } from '@kubb/fabric-core/parsers'
47
47
 
48
48
  const fabric = createFabric()
49
49
 
@@ -66,7 +66,11 @@ await fabric.addFile({
66
66
  })
67
67
 
68
68
  await fabric.write()
69
+ ```
69
70
 
71
+ Creates a file `generated/index.ts` with the following content:
72
+ ```ts
73
+ export const x = 1
70
74
  ```
71
75
 
72
76
  # API Reference
@@ -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 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 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 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 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 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 { FabricOptions as a, Parser as c, UserPlugin as d, Extname as f, ResolvedFile as h, FabricMode as i, UserParser as l, KubbFile_d_exports as m, FabricConfig as n, FileManager as o, File as p, FabricContext as r, FileProcessor as s, Fabric as t, Plugin as u };
318
- //# sourceMappingURL=Fabric-BfnUdEpq.d.cts.map
362
+ export { FabricOptions as a, FileManager as c, UserParser as d, Extname as f, ResolvedFile as h, FabricMode as i, FileProcessor as l, KubbFile_d_exports as m, FabricConfig as n, Plugin as o, File as p, FabricContext as r, UserPlugin as s, Fabric as t, Parser as u };
363
+ //# sourceMappingURL=Fabric-AmREkq58.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 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 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 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 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 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 { FabricOptions as a, Parser as c, UserPlugin as d, Extname as f, ResolvedFile as h, FabricMode as i, UserParser as l, KubbFile_d_exports as m, FabricConfig as n, FileManager as o, File as p, FabricContext as r, FileProcessor as s, Fabric as t, Plugin as u };
318
- //# sourceMappingURL=Fabric-CxMkO4Rt.d.ts.map
362
+ export { FabricOptions as a, FileManager as c, UserParser as d, Extname as f, ResolvedFile as h, FabricMode as i, FileProcessor as l, KubbFile_d_exports as m, FabricConfig as n, Plugin as o, File as p, FabricContext as r, UserPlugin as s, Fabric as t, Parser as u };
363
+ //# sourceMappingURL=Fabric-CBrTERuf.d.cts.map