@kubb/fabric-core 0.5.5 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -85,22 +85,54 @@ Returns a Fabric instance with:
85
85
 
86
86
 
87
87
  ### Events (emitted by the core during processing)
88
- - `lifecycle:start`
89
- - `lifecycle:end`
90
- - `lifecycle:render { fabric }`
91
- - `files:added { files }`
92
- - `files:writing:start { files }`
93
- - `files:writing:end { files }`
94
- - `file:processing:start { file, index, total }`
95
- - `file:processing:end { file, index, total }`
96
- - `files:processing:start { files }`
97
- - `files:processing:update { file, source, processed, percentage, total }`
98
- - `files:processing:end { files }`
88
+
89
+ Fabric emits events throughout its lifecycle that plugins and custom code can listen to. These events provide hooks for monitoring progress, transforming files, and performing custom operations.
90
+
91
+ #### Lifecycle Events
92
+ - **`lifecycle:start`** Emitted when Fabric begins execution
93
+ - **`lifecycle:end`** Emitted when Fabric completes execution
94
+ - **`lifecycle:render { fabric }`** Emitted when rendering starts (with reactPlugin)
95
+
96
+ #### File Management Events
97
+ - **`files:added { files }`** Emitted when files are added to the FileManager cache
98
+ - **`file:resolve:path { file }`** — Emitted during file path resolution (allows modification)
99
+ - **`file:resolve:name { file }`** — Emitted during file name resolution (allows modification)
100
+
101
+ #### File Writing Events
102
+ - **`files:writing:start { files }`** — Emitted before writing files to disk
103
+ - **`files:writing:end { files }`** — Emitted after files are written to disk
104
+
105
+ #### File Processing Events
106
+ - **`files:processing:start { files }`** — Emitted before processing begins
107
+ - **`file:processing:start { file, index, total }`** — Emitted when each file starts processing
108
+ - **`file:processing:end { file, index, total }`** — Emitted when each file finishes processing
109
+ - **`file:processing:update { file, source, processed, percentage, total }`** — Emitted with progress updates
110
+ - **`files:processing:end { files }`** — Emitted when all processing completes
111
+
112
+ #### Listening to Events
113
+
114
+ You can listen to events using the Fabric context:
115
+
116
+ ```ts
117
+ const fabric = createFabric()
118
+
119
+ fabric.context.on('lifecycle:start', async () => {
120
+ console.log('Starting Fabric...')
121
+ })
122
+
123
+ fabric.context.on('file:processing:update', async ({ processed, total, percentage }) => {
124
+ console.log(`Progress: ${percentage.toFixed(1)}% (${processed}/${total})`)
125
+ })
126
+
127
+ fabric.context.on('lifecycle:end', async () => {
128
+ console.log('Fabric completed!')
129
+ })
130
+ ```
99
131
 
100
132
 
101
133
  ## Plugins
102
134
  #### `fsPlugin`
103
- Writes files to disk on `files:processing:update`, supports dry runs and cleaning an output folder before writing.
135
+ Writes files to disk on `file:processing:update`, supports dry runs and cleaning an output folder before writing.
104
136
 
105
137
  ```
106
138
  import { fsPlugin } from '@kubb/fabric-core/plugins'
@@ -109,7 +141,7 @@ import { fsPlugin } from '@kubb/fabric-core/plugins'
109
141
  | Option | Type | Default | Description |
110
142
  |---|----------------------------------------------------------------------|---|-----------------------------------------------------------------------|
111
143
  | dryRun | `boolean` | `false` | If true, do not write files to disk. |
112
- | onBeforeWrite | `(path: string, data: string \| undefined) => void \| Promise<void>` | — | Called right before each file write on `files:processing:update`. |
144
+ | onBeforeWrite | `(path: string, data: string \| undefined) => void \| Promise<void>` | — | Called right before each file write on `file:processing:update`. |
113
145
  | clean | `{ path: string }` | — | If provided, removes the directory at `path` before writing any files. |
114
146
 
115
147
  Injected `fabric.write` options (via `fsPlugin`):
@@ -251,61 +251,153 @@ interface FabricOptions {
251
251
  type FabricMode = 'sequential' | 'parallel';
252
252
  /**
253
253
  * Event definitions emitted during the Fabric lifecycle.
254
+ *
255
+ * These events allow plugins and external code to hook into different stages
256
+ * of the file generation process. All events are asynchronous and can be
257
+ * listened to using `fabric.context.on()` or `fabric.context.onOnce()`.
258
+ *
259
+ * @example
260
+ * ```ts
261
+ * fabric.context.on('lifecycle:start', async () => {
262
+ * console.log('Fabric started!')
263
+ * })
264
+ * ```
254
265
  */
255
266
  interface FabricEvents {
256
- /** Called at the beginning of the app lifecycle. */
267
+ /**
268
+ * Emitted when the Fabric application lifecycle begins.
269
+ * This is typically the first event fired when starting a Fabric run.
270
+ * Use this to perform initial setup or logging.
271
+ */
257
272
  'lifecycle:start': [];
258
- /** Called at the end of the app lifecycle. */
273
+ /**
274
+ * Emitted when the Fabric application lifecycle completes.
275
+ * This is typically the last event fired after all processing is done.
276
+ * Use this for cleanup tasks or final reporting.
277
+ */
259
278
  'lifecycle:end': [];
260
- /** Called when Fabric is rendering. Provides the Fabric instance. */
279
+ /**
280
+ * Emitted when Fabric starts rendering (used with reactPlugin).
281
+ * Provides access to the Fabric instance for render-time operations.
282
+ *
283
+ * @property fabric - The current Fabric instance being rendered
284
+ */
261
285
  'lifecycle:render': [{
262
286
  fabric: Fabric;
263
287
  }];
264
- /** Called once before any files are processed. Provides all files that will be processed. */
288
+ /**
289
+ * Emitted once before file processing begins.
290
+ * Provides the complete list of files that will be processed.
291
+ * Use this to prepare for batch operations or display initial file counts.
292
+ *
293
+ * @property files - Array of all files queued for processing
294
+ */
265
295
  'files:processing:start': [{
266
296
  files: ResolvedFile[];
267
297
  }];
268
- /** Called when FileManager is adding files to its cache. */
298
+ /**
299
+ * Emitted when files are successfully added to the FileManager's internal cache.
300
+ * This happens after files pass through path and name resolution.
301
+ * Use this to track which files have been registered.
302
+ *
303
+ * @property files - Array of files that were just added to the cache
304
+ */
269
305
  'files:added': [{
270
306
  files: ResolvedFile[];
271
307
  }];
272
- /** Called when resolving a file's path. Allows modification of the file path. */
273
- 'file:path:resolving': [{
308
+ /**
309
+ * Emitted during file path resolution, before a file is cached.
310
+ * Listeners can modify the file's path property to customize output location.
311
+ * This is called for each file being added via `addFile()` or `upsertFile()`.
312
+ *
313
+ * @property file - The file whose path is being resolved (mutable)
314
+ */
315
+ 'file:resolve:path': [{
274
316
  file: File;
275
317
  }];
276
- /** Called when resolving a file's name. Allows modification of the file name. */
277
- 'file:name:resolving': [{
318
+ /**
319
+ * Emitted during file name resolution, before a file is cached.
320
+ * Listeners can modify the file's name-related properties to customize naming.
321
+ * This is called for each file being added via `addFile()` or `upsertFile()`.
322
+ *
323
+ * @property file - The file whose name is being resolved (mutable)
324
+ */
325
+ 'file:resolve:name': [{
278
326
  file: File;
279
327
  }];
280
- /** Called before writing files to disk. Provides all files that will be written. */
328
+ /**
329
+ * Emitted just before files are written to disk.
330
+ * Provides all files that will be written in this batch.
331
+ * Use this to perform pre-write operations like creating directories.
332
+ *
333
+ * @property files - Array of files about to be written to disk
334
+ */
281
335
  'files:writing:start': [{
282
336
  files: ResolvedFile[];
283
337
  }];
284
- /** Called after writing files to disk. Provides all files that were written. */
338
+ /**
339
+ * Emitted after all files have been successfully written to disk.
340
+ * Provides all files that were written in this batch.
341
+ * Use this for post-write operations like running formatters or reporting.
342
+ *
343
+ * @property files - Array of files that were written to disk
344
+ */
285
345
  'files:writing:end': [{
286
346
  files: ResolvedFile[];
287
347
  }];
288
- /** Called when processing of an individual file begins. Provides file, current index, and total count. */
348
+ /**
349
+ * Emitted when an individual file starts being processed.
350
+ * This happens for each file in the queue, before parsing.
351
+ * Use this for per-file setup or detailed logging.
352
+ *
353
+ * @property file - The file starting processing
354
+ * @property index - Zero-based position of this file in the queue
355
+ * @property total - Total number of files to process
356
+ */
289
357
  'file:processing:start': [{
290
358
  file: ResolvedFile;
291
359
  index: number;
292
360
  total: number;
293
361
  }];
294
- /** Called when processing of an individual file completes. Provides file, current index, and total count. */
362
+ /**
363
+ * Emitted when an individual file completes processing.
364
+ * This happens after the file has been parsed and handled.
365
+ * Use this for per-file cleanup or progress tracking.
366
+ *
367
+ * @property file - The file that finished processing
368
+ * @property index - Zero-based position of this file in the queue
369
+ * @property total - Total number of files to process
370
+ */
295
371
  'file:processing:end': [{
296
372
  file: ResolvedFile;
297
373
  index: number;
298
374
  total: number;
299
375
  }];
300
- /** Called periodically to indicate processing progress. Useful for progress bars or logging. */
301
- 'files:processing:update': [{
376
+ /**
377
+ * Emitted after each file is processed, providing progress metrics.
378
+ * This is the primary event for implementing progress bars or tracking.
379
+ * Plugins like fsPlugin use this to write files to disk.
380
+ *
381
+ * @property processed - Number of files processed so far
382
+ * @property total - Total number of files to process
383
+ * @property percentage - Completion percentage (0-100)
384
+ * @property source - Optional parsed source code of the file
385
+ * @property file - The file that was just processed
386
+ */
387
+ 'file:processing:update': [{
302
388
  processed: number;
303
389
  total: number;
304
390
  percentage: number;
305
391
  source?: string;
306
392
  file: ResolvedFile;
307
393
  }];
308
- /** Called once all files have been processed successfully. */
394
+ /**
395
+ * Emitted once all files have been successfully processed.
396
+ * This marks the completion of the processing phase.
397
+ * Use this to perform batch operations on all processed files.
398
+ *
399
+ * @property files - Array of all files that were processed
400
+ */
309
401
  'files:processing:end': [{
310
402
  files: ResolvedFile[];
311
403
  }];
@@ -371,4 +463,4 @@ interface Fabric<T extends FabricOptions = FabricOptions> extends Kubb.Fabric {
371
463
  }
372
464
  //#endregion
373
465
  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 };
374
- //# sourceMappingURL=Fabric-CtqeUUFU.d.ts.map
466
+ //# sourceMappingURL=Fabric-CEVrEuYU.d.ts.map
@@ -251,61 +251,153 @@ interface FabricOptions {
251
251
  type FabricMode = 'sequential' | 'parallel';
252
252
  /**
253
253
  * Event definitions emitted during the Fabric lifecycle.
254
+ *
255
+ * These events allow plugins and external code to hook into different stages
256
+ * of the file generation process. All events are asynchronous and can be
257
+ * listened to using `fabric.context.on()` or `fabric.context.onOnce()`.
258
+ *
259
+ * @example
260
+ * ```ts
261
+ * fabric.context.on('lifecycle:start', async () => {
262
+ * console.log('Fabric started!')
263
+ * })
264
+ * ```
254
265
  */
255
266
  interface FabricEvents {
256
- /** Called at the beginning of the app lifecycle. */
267
+ /**
268
+ * Emitted when the Fabric application lifecycle begins.
269
+ * This is typically the first event fired when starting a Fabric run.
270
+ * Use this to perform initial setup or logging.
271
+ */
257
272
  'lifecycle:start': [];
258
- /** Called at the end of the app lifecycle. */
273
+ /**
274
+ * Emitted when the Fabric application lifecycle completes.
275
+ * This is typically the last event fired after all processing is done.
276
+ * Use this for cleanup tasks or final reporting.
277
+ */
259
278
  'lifecycle:end': [];
260
- /** Called when Fabric is rendering. Provides the Fabric instance. */
279
+ /**
280
+ * Emitted when Fabric starts rendering (used with reactPlugin).
281
+ * Provides access to the Fabric instance for render-time operations.
282
+ *
283
+ * @property fabric - The current Fabric instance being rendered
284
+ */
261
285
  'lifecycle:render': [{
262
286
  fabric: Fabric;
263
287
  }];
264
- /** Called once before any files are processed. Provides all files that will be processed. */
288
+ /**
289
+ * Emitted once before file processing begins.
290
+ * Provides the complete list of files that will be processed.
291
+ * Use this to prepare for batch operations or display initial file counts.
292
+ *
293
+ * @property files - Array of all files queued for processing
294
+ */
265
295
  'files:processing:start': [{
266
296
  files: ResolvedFile[];
267
297
  }];
268
- /** Called when FileManager is adding files to its cache. */
298
+ /**
299
+ * Emitted when files are successfully added to the FileManager's internal cache.
300
+ * This happens after files pass through path and name resolution.
301
+ * Use this to track which files have been registered.
302
+ *
303
+ * @property files - Array of files that were just added to the cache
304
+ */
269
305
  'files:added': [{
270
306
  files: ResolvedFile[];
271
307
  }];
272
- /** Called when resolving a file's path. Allows modification of the file path. */
273
- 'file:path:resolving': [{
308
+ /**
309
+ * Emitted during file path resolution, before a file is cached.
310
+ * Listeners can modify the file's path property to customize output location.
311
+ * This is called for each file being added via `addFile()` or `upsertFile()`.
312
+ *
313
+ * @property file - The file whose path is being resolved (mutable)
314
+ */
315
+ 'file:resolve:path': [{
274
316
  file: File;
275
317
  }];
276
- /** Called when resolving a file's name. Allows modification of the file name. */
277
- 'file:name:resolving': [{
318
+ /**
319
+ * Emitted during file name resolution, before a file is cached.
320
+ * Listeners can modify the file's name-related properties to customize naming.
321
+ * This is called for each file being added via `addFile()` or `upsertFile()`.
322
+ *
323
+ * @property file - The file whose name is being resolved (mutable)
324
+ */
325
+ 'file:resolve:name': [{
278
326
  file: File;
279
327
  }];
280
- /** Called before writing files to disk. Provides all files that will be written. */
328
+ /**
329
+ * Emitted just before files are written to disk.
330
+ * Provides all files that will be written in this batch.
331
+ * Use this to perform pre-write operations like creating directories.
332
+ *
333
+ * @property files - Array of files about to be written to disk
334
+ */
281
335
  'files:writing:start': [{
282
336
  files: ResolvedFile[];
283
337
  }];
284
- /** Called after writing files to disk. Provides all files that were written. */
338
+ /**
339
+ * Emitted after all files have been successfully written to disk.
340
+ * Provides all files that were written in this batch.
341
+ * Use this for post-write operations like running formatters or reporting.
342
+ *
343
+ * @property files - Array of files that were written to disk
344
+ */
285
345
  'files:writing:end': [{
286
346
  files: ResolvedFile[];
287
347
  }];
288
- /** Called when processing of an individual file begins. Provides file, current index, and total count. */
348
+ /**
349
+ * Emitted when an individual file starts being processed.
350
+ * This happens for each file in the queue, before parsing.
351
+ * Use this for per-file setup or detailed logging.
352
+ *
353
+ * @property file - The file starting processing
354
+ * @property index - Zero-based position of this file in the queue
355
+ * @property total - Total number of files to process
356
+ */
289
357
  'file:processing:start': [{
290
358
  file: ResolvedFile;
291
359
  index: number;
292
360
  total: number;
293
361
  }];
294
- /** Called when processing of an individual file completes. Provides file, current index, and total count. */
362
+ /**
363
+ * Emitted when an individual file completes processing.
364
+ * This happens after the file has been parsed and handled.
365
+ * Use this for per-file cleanup or progress tracking.
366
+ *
367
+ * @property file - The file that finished processing
368
+ * @property index - Zero-based position of this file in the queue
369
+ * @property total - Total number of files to process
370
+ */
295
371
  'file:processing:end': [{
296
372
  file: ResolvedFile;
297
373
  index: number;
298
374
  total: number;
299
375
  }];
300
- /** Called periodically to indicate processing progress. Useful for progress bars or logging. */
301
- 'files:processing:update': [{
376
+ /**
377
+ * Emitted after each file is processed, providing progress metrics.
378
+ * This is the primary event for implementing progress bars or tracking.
379
+ * Plugins like fsPlugin use this to write files to disk.
380
+ *
381
+ * @property processed - Number of files processed so far
382
+ * @property total - Total number of files to process
383
+ * @property percentage - Completion percentage (0-100)
384
+ * @property source - Optional parsed source code of the file
385
+ * @property file - The file that was just processed
386
+ */
387
+ 'file:processing:update': [{
302
388
  processed: number;
303
389
  total: number;
304
390
  percentage: number;
305
391
  source?: string;
306
392
  file: ResolvedFile;
307
393
  }];
308
- /** Called once all files have been processed successfully. */
394
+ /**
395
+ * Emitted once all files have been successfully processed.
396
+ * This marks the completion of the processing phase.
397
+ * Use this to perform batch operations on all processed files.
398
+ *
399
+ * @property files - Array of all files that were processed
400
+ */
309
401
  'files:processing:end': [{
310
402
  files: ResolvedFile[];
311
403
  }];
@@ -371,4 +463,4 @@ interface Fabric<T extends FabricOptions = FabricOptions> extends Kubb.Fabric {
371
463
  }
372
464
  //#endregion
373
465
  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 };
374
- //# sourceMappingURL=Fabric-DlBN6CDR.d.cts.map
466
+ //# sourceMappingURL=Fabric-CVnHPMqM.d.cts.map
package/dist/index.cjs CHANGED
@@ -100,7 +100,7 @@ var FileProcessor = class {
100
100
  });
101
101
  const currentProcessed = ++processed;
102
102
  const percentage = currentProcessed / total * 100;
103
- await this.events.emit("files:processing:update", {
103
+ await this.events.emit("file:processing:update", {
104
104
  file: resolvedFile,
105
105
  source,
106
106
  processed: currentProcessed,
@@ -260,11 +260,11 @@ var FileManager = class {
260
260
  }
261
261
  };
262
262
  function _resolvePath(file) {
263
- this.events.emit("file:path:resolving", { file });
263
+ this.events.emit("file:resolve:path", { file });
264
264
  return file;
265
265
  }
266
266
  function _resolveName(file) {
267
- this.events.emit("file:name:resolving", { file });
267
+ this.events.emit("file:resolve:name", { file });
268
268
  return file;
269
269
  }
270
270
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["e","NodeEventEmitter","errors: Error[]","defaultParser","resolvedFiles: Array<KubbFile.ResolvedFile>","createFile","trimExtName","files: Array<KubbFile.ResolvedFile>","context: FabricContext<T>","fabric: Fabric<T>","isFunction"],"sources":["../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/isFunction-BJjFuZR7.js","../src/utils/AsyncEventEmitter.ts","../src/FileProcessor.ts","../src/utils/Cache.ts","../src/FileManager.ts","../src/createFabric.ts"],"sourcesContent":["const e=e=>typeof e==`function`;export{e as isFunction};\n//# sourceMappingURL=isFunction-BJjFuZR7.js.map","import { EventEmitter as NodeEventEmitter } from 'node:events'\nimport type { FabricMode } from '../Fabric.ts'\n\ntype Options = {\n mode?: FabricMode\n maxListener?: number\n}\n\nexport class AsyncEventEmitter<TEvents extends Record<string, any>> {\n constructor({ maxListener = 100, mode = 'sequential' }: Options = {}) {\n this.#emitter.setMaxListeners(maxListener)\n this.#mode = mode\n }\n\n #emitter = new NodeEventEmitter()\n #mode: FabricMode\n\n async emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> {\n const listeners = this.#emitter.listeners(eventName) as Array<(...args: TEvents[TEventName]) => any>\n\n if (listeners.length === 0) {\n return\n }\n\n const errors: Error[] = []\n\n if (this.#mode === 'sequential') {\n // Run listeners one by one, in order\n for (const listener of listeners) {\n try {\n await listener(...eventArgs)\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err))\n errors.push(error)\n }\n }\n } else {\n // Run all listeners concurrently\n const promises = listeners.map(async (listener) => {\n try {\n await listener(...eventArgs)\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err))\n errors.push(error)\n }\n })\n await Promise.all(promises)\n }\n\n if (errors.length === 1) {\n throw errors[0]\n }\n\n if (errors.length > 1) {\n throw new AggregateError(errors, `Errors in async listeners for \"${eventName}\"`)\n }\n }\n\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.on(eventName, handler as any)\n }\n\n onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void {\n const wrapper = (...args: TEvents[TEventName]) => {\n this.off(eventName, wrapper)\n handler(...args)\n }\n this.on(eventName, wrapper)\n }\n\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.off(eventName, handler as any)\n }\n\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n","import pLimit from 'p-limit'\nimport type { FabricEvents, FabricMode } from './Fabric.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport { defaultParser } from './parsers/defaultParser.ts'\nimport type { Parser } from './parsers/types.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\n\nexport type ProcessFilesProps = {\n parsers?: Map<KubbFile.Extname, Parser>\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n /**\n * @default 'sequential'\n */\n mode?: FabricMode\n}\n\ntype GetParseOptions = {\n parsers?: Map<KubbFile.Extname, Parser>\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n}\n\ntype Options = {\n events?: AsyncEventEmitter<FabricEvents>\n}\n\nexport class FileProcessor {\n #limit = pLimit(100)\n events: AsyncEventEmitter<FabricEvents>\n\n constructor({ events = new AsyncEventEmitter<FabricEvents>() }: Options = {}) {\n this.events = events\n\n return this\n }\n\n async parse(file: KubbFile.ResolvedFile, { parsers, extension }: GetParseOptions = {}): Promise<string> {\n const parseExtName = extension?.[file.extname] || undefined\n\n if (!parsers) {\n console.warn('No parsers provided, using default parser. If you want to use a specific parser, please provide it in the options.')\n\n return defaultParser.parse(file, { extname: parseExtName })\n }\n\n if (!file.extname) {\n return defaultParser.parse(file, { extname: parseExtName })\n }\n\n const parser = parsers.get(file.extname)\n\n if (!parser) {\n return defaultParser.parse(file, { extname: parseExtName })\n }\n\n return parser.parse(file, { extname: parseExtName })\n }\n\n async run(\n files: Array<KubbFile.ResolvedFile>,\n { parsers, mode = 'sequential', dryRun, extension }: ProcessFilesProps = {},\n ): Promise<KubbFile.ResolvedFile[]> {\n await this.events.emit('files:processing:start', { files })\n\n const total = files.length\n let processed = 0\n\n const processOne = async (resolvedFile: KubbFile.ResolvedFile, index: number) => {\n await this.events.emit('file:processing:start', { file: resolvedFile, index, total })\n\n const source = dryRun ? undefined : await this.parse(resolvedFile, { extension, parsers })\n\n const currentProcessed = ++processed\n const percentage = (currentProcessed / total) * 100\n\n await this.events.emit('files:processing:update', {\n file: resolvedFile,\n source,\n processed: currentProcessed,\n percentage,\n total,\n })\n\n await this.events.emit('file:processing:end', { file: resolvedFile, index, total })\n }\n\n if (mode === 'sequential') {\n async function* asyncFiles() {\n for (let index = 0; index < files.length; index++) {\n yield [files[index], index] as const\n }\n }\n\n for await (const [file, index] of asyncFiles()) {\n if (file) {\n await processOne(file, index)\n }\n }\n } else {\n const promises = files.map((resolvedFile, index) => this.#limit(() => processOne(resolvedFile, index)))\n await Promise.all(promises)\n }\n\n await this.events.emit('files:processing:end', { files })\n\n return files\n }\n}\n","export class Cache<T> {\n #buffer = new Map<string, T>()\n\n get(key: string): T | null {\n return this.#buffer.get(key) ?? null\n }\n\n set(key: string, value: T): void {\n this.#buffer.set(key, value)\n }\n\n delete(key: string): void {\n this.#buffer.delete(key)\n }\n\n clear(): void {\n this.#buffer.clear()\n }\n\n keys(): string[] {\n return [...this.#buffer.keys()]\n }\n\n values(): Array<T> {\n return [...this.#buffer.values()]\n }\n\n flush(): void {\n // No-op for base cache\n }\n}\n","import { orderBy } from 'natural-orderby'\nimport { createFile } from './createFile.ts'\nimport type { FabricEvents } from './Fabric.ts'\nimport { FileProcessor, type ProcessFilesProps } from './FileProcessor.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\nimport { Cache } from './utils/Cache.ts'\nimport { trimExtName } from './utils/trimExtName.ts'\n\nfunction mergeFile<TMeta extends object = object>(a: KubbFile.File<TMeta>, b: KubbFile.File<TMeta>): KubbFile.File<TMeta> {\n return {\n ...a,\n sources: [...(a.sources || []), ...(b.sources || [])],\n imports: [...(a.imports || []), ...(b.imports || [])],\n exports: [...(a.exports || []), ...(b.exports || [])],\n }\n}\n\ntype Options = {\n events?: AsyncEventEmitter<FabricEvents>\n}\n\nexport class FileManager {\n #cache = new Cache<KubbFile.ResolvedFile>()\n #filesCache: Array<KubbFile.ResolvedFile> | null = null\n events: AsyncEventEmitter<FabricEvents>\n processor: FileProcessor\n\n constructor({ events = new AsyncEventEmitter<FabricEvents>() }: Options = {}) {\n this.processor = new FileProcessor({ events })\n\n this.events = events\n return this\n }\n\n #resolvePath(file: KubbFile.File): KubbFile.File {\n this.events.emit('file:path:resolving', { file })\n\n return file\n }\n\n #resolveName(file: KubbFile.File): KubbFile.File {\n this.events.emit('file:name:resolving', { file })\n\n return file\n }\n\n async add(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (let file of mergedFiles.values()) {\n file = this.#resolveName(file)\n file = this.#resolvePath(file)\n\n const resolvedFile = createFile(file)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n await this.events.emit('files:added', { files: resolvedFiles })\n\n return resolvedFiles\n }\n\n async upsert(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (let file of mergedFiles.values()) {\n const existing = this.#cache.get(file.path)\n\n file = this.#resolveName(file)\n file = this.#resolvePath(file)\n\n const merged = existing ? mergeFile(existing, file) : file\n const resolvedFile = createFile(merged)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n await this.events.emit('files:added', { files: resolvedFiles })\n\n return resolvedFiles\n }\n\n flush() {\n this.#filesCache = null\n this.#cache.flush()\n }\n\n getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | null {\n return this.#cache.get(path)\n }\n\n deleteByPath(path: KubbFile.Path): void {\n this.#cache.delete(path)\n this.#filesCache = null\n }\n\n clear(): void {\n this.#cache.clear()\n this.#filesCache = null\n }\n\n get files(): Array<KubbFile.ResolvedFile> {\n if (this.#filesCache) {\n return this.#filesCache\n }\n\n const cachedKeys = this.#cache.keys()\n\n // order by path length and if file is a barrel file\n const keys = orderBy(cachedKeys, [(v) => v.length, (v) => trimExtName(v).endsWith('index')])\n\n const files: Array<KubbFile.ResolvedFile> = []\n\n for (const key of keys) {\n const file = this.#cache.get(key)\n if (file) {\n files.push(file)\n }\n }\n\n this.#filesCache = files\n\n return files\n }\n\n //TODO add test and check if write of FileManager contains the newly added file\n async write(options: ProcessFilesProps): Promise<KubbFile.ResolvedFile[]> {\n await this.events.emit('files:writing:start', { files: this.files })\n\n const resolvedFiles = await this.processor.run(this.files, options)\n\n this.clear()\n\n await this.events.emit('files:writing:end', { files: resolvedFiles })\n\n return resolvedFiles\n }\n}\n","import { isFunction } from 'remeda'\nimport type { Fabric, FabricConfig, FabricContext, FabricEvents, FabricOptions } from './Fabric.ts'\nimport { FileManager } from './FileManager.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport type { Parser } from './parsers/types.ts'\nimport type { Plugin } from './plugins/types.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\n\n/**\n * Creates a new Fabric instance\n *\n * @example\n * const fabric = createFabric()\n * fabric.use(myPlugin())\n */\nexport function createFabric<T extends FabricOptions>(config: FabricConfig<T> = { mode: 'sequential' } as FabricConfig<T>): Fabric<T> {\n const events = new AsyncEventEmitter<FabricEvents>()\n const installedPlugins = new Set<Plugin<any>>()\n const installedParsers = new Map<KubbFile.Extname, Parser<any>>()\n const installedParserNames = new Set<string>()\n const fileManager = new FileManager({ events })\n\n const context: FabricContext<T> = {\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n config,\n fileManager,\n installedPlugins,\n installedParsers,\n on: events.on.bind(events),\n off: events.off.bind(events),\n onOnce: events.onOnce.bind(events),\n removeAll: events.removeAll.bind(events),\n emit: events.emit.bind(events),\n } as FabricContext<T>\n\n const fabric: Fabric<T> = {\n context,\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n async upsertFile(...files) {\n await fileManager.upsert(...files)\n },\n async use(pluginOrParser, ...options) {\n if (pluginOrParser.type === 'plugin') {\n if (installedPlugins.has(pluginOrParser)) {\n console.warn(`Plugin \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedPlugins.add(pluginOrParser)\n }\n\n if (isFunction(pluginOrParser.inject)) {\n const injecter = pluginOrParser.inject\n\n const injected = (injecter as any)(context, ...options)\n Object.assign(fabric, injected)\n }\n }\n\n if (pluginOrParser.type === 'parser') {\n if (installedParserNames.has(pluginOrParser.name)) {\n console.warn(`Parser \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedParserNames.add(pluginOrParser.name)\n }\n\n if (pluginOrParser.extNames) {\n for (const extName of pluginOrParser.extNames) {\n const existing = installedParsers.get(extName)\n if (existing && existing.name !== pluginOrParser.name) {\n console.warn(`Parser \"${pluginOrParser.name}\" is overriding parser \"${existing.name}\" for extension \"${extName}\".`)\n }\n installedParsers.set(extName, pluginOrParser)\n }\n }\n }\n\n if (isFunction(pluginOrParser.install)) {\n const installer = pluginOrParser.install\n\n await (installer as any)(context, ...options)\n }\n\n return fabric\n },\n } as Fabric<T>\n\n return fabric\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;AAAA,MAAM,KAAE,QAAG,OAAOA,OAAG;;;;;;ACQrB,IAAa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YAAY,SAAS,SAAS,eAAe,KAC/C,SAAQ,KAAK,WAAW,eAAe,KAAK,0BAA0B,SAAS,KAAK,mBAAmB,QAAQ,IAAI;AAErH,sBAAiB,IAAI,SAAS,eAAe;;;AAKnD,OAAIA,EAAW,eAAe,QAAQ,EAAE;IACtC,MAAM,YAAY,eAAe;AAEjC,UAAO,UAAkB,SAAS,GAAG,QAAQ;;AAG/C,UAAO;;EAEV;AAED,QAAO"}
1
+ {"version":3,"file":"index.cjs","names":["e","NodeEventEmitter","errors: Error[]","defaultParser","resolvedFiles: Array<KubbFile.ResolvedFile>","createFile","trimExtName","files: Array<KubbFile.ResolvedFile>","context: FabricContext<T>","fabric: Fabric<T>","isFunction"],"sources":["../../../node_modules/.pnpm/remeda@2.32.0/node_modules/remeda/dist/isFunction-BJjFuZR7.js","../src/utils/AsyncEventEmitter.ts","../src/FileProcessor.ts","../src/utils/Cache.ts","../src/FileManager.ts","../src/createFabric.ts"],"sourcesContent":["const e=e=>typeof e==`function`;export{e as isFunction};\n//# sourceMappingURL=isFunction-BJjFuZR7.js.map","import { EventEmitter as NodeEventEmitter } from 'node:events'\nimport type { FabricMode } from '../Fabric.ts'\n\ntype Options = {\n mode?: FabricMode\n maxListener?: number\n}\n\nexport class AsyncEventEmitter<TEvents extends Record<string, any>> {\n constructor({ maxListener = 100, mode = 'sequential' }: Options = {}) {\n this.#emitter.setMaxListeners(maxListener)\n this.#mode = mode\n }\n\n #emitter = new NodeEventEmitter()\n #mode: FabricMode\n\n async emit<TEventName extends keyof TEvents & string>(eventName: TEventName, ...eventArgs: TEvents[TEventName]): Promise<void> {\n const listeners = this.#emitter.listeners(eventName) as Array<(...args: TEvents[TEventName]) => any>\n\n if (listeners.length === 0) {\n return\n }\n\n const errors: Error[] = []\n\n if (this.#mode === 'sequential') {\n // Run listeners one by one, in order\n for (const listener of listeners) {\n try {\n await listener(...eventArgs)\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err))\n errors.push(error)\n }\n }\n } else {\n // Run all listeners concurrently\n const promises = listeners.map(async (listener) => {\n try {\n await listener(...eventArgs)\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err))\n errors.push(error)\n }\n })\n await Promise.all(promises)\n }\n\n if (errors.length === 1) {\n throw errors[0]\n }\n\n if (errors.length > 1) {\n throw new AggregateError(errors, `Errors in async listeners for \"${eventName}\"`)\n }\n }\n\n on<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.on(eventName, handler as any)\n }\n\n onOnce<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArgs: TEvents[TEventName]) => void): void {\n const wrapper = (...args: TEvents[TEventName]) => {\n this.off(eventName, wrapper)\n handler(...args)\n }\n this.on(eventName, wrapper)\n }\n\n off<TEventName extends keyof TEvents & string>(eventName: TEventName, handler: (...eventArg: TEvents[TEventName]) => void): void {\n this.#emitter.off(eventName, handler as any)\n }\n\n removeAll(): void {\n this.#emitter.removeAllListeners()\n }\n}\n","import pLimit from 'p-limit'\nimport type { FabricEvents, FabricMode } from './Fabric.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport { defaultParser } from './parsers/defaultParser.ts'\nimport type { Parser } from './parsers/types.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\n\nexport type ProcessFilesProps = {\n parsers?: Map<KubbFile.Extname, Parser>\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n dryRun?: boolean\n /**\n * @default 'sequential'\n */\n mode?: FabricMode\n}\n\ntype GetParseOptions = {\n parsers?: Map<KubbFile.Extname, Parser>\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n}\n\ntype Options = {\n events?: AsyncEventEmitter<FabricEvents>\n}\n\nexport class FileProcessor {\n #limit = pLimit(100)\n events: AsyncEventEmitter<FabricEvents>\n\n constructor({ events = new AsyncEventEmitter<FabricEvents>() }: Options = {}) {\n this.events = events\n\n return this\n }\n\n async parse(file: KubbFile.ResolvedFile, { parsers, extension }: GetParseOptions = {}): Promise<string> {\n const parseExtName = extension?.[file.extname] || undefined\n\n if (!parsers) {\n console.warn('No parsers provided, using default parser. If you want to use a specific parser, please provide it in the options.')\n\n return defaultParser.parse(file, { extname: parseExtName })\n }\n\n if (!file.extname) {\n return defaultParser.parse(file, { extname: parseExtName })\n }\n\n const parser = parsers.get(file.extname)\n\n if (!parser) {\n return defaultParser.parse(file, { extname: parseExtName })\n }\n\n return parser.parse(file, { extname: parseExtName })\n }\n\n async run(\n files: Array<KubbFile.ResolvedFile>,\n { parsers, mode = 'sequential', dryRun, extension }: ProcessFilesProps = {},\n ): Promise<KubbFile.ResolvedFile[]> {\n await this.events.emit('files:processing:start', { files })\n\n const total = files.length\n let processed = 0\n\n const processOne = async (resolvedFile: KubbFile.ResolvedFile, index: number) => {\n await this.events.emit('file:processing:start', { file: resolvedFile, index, total })\n\n const source = dryRun ? undefined : await this.parse(resolvedFile, { extension, parsers })\n\n const currentProcessed = ++processed\n const percentage = (currentProcessed / total) * 100\n\n await this.events.emit('file:processing:update', {\n file: resolvedFile,\n source,\n processed: currentProcessed,\n percentage,\n total,\n })\n\n await this.events.emit('file:processing:end', { file: resolvedFile, index, total })\n }\n\n if (mode === 'sequential') {\n async function* asyncFiles() {\n for (let index = 0; index < files.length; index++) {\n yield [files[index], index] as const\n }\n }\n\n for await (const [file, index] of asyncFiles()) {\n if (file) {\n await processOne(file, index)\n }\n }\n } else {\n const promises = files.map((resolvedFile, index) => this.#limit(() => processOne(resolvedFile, index)))\n await Promise.all(promises)\n }\n\n await this.events.emit('files:processing:end', { files })\n\n return files\n }\n}\n","export class Cache<T> {\n #buffer = new Map<string, T>()\n\n get(key: string): T | null {\n return this.#buffer.get(key) ?? null\n }\n\n set(key: string, value: T): void {\n this.#buffer.set(key, value)\n }\n\n delete(key: string): void {\n this.#buffer.delete(key)\n }\n\n clear(): void {\n this.#buffer.clear()\n }\n\n keys(): string[] {\n return [...this.#buffer.keys()]\n }\n\n values(): Array<T> {\n return [...this.#buffer.values()]\n }\n\n flush(): void {\n // No-op for base cache\n }\n}\n","import { orderBy } from 'natural-orderby'\nimport { createFile } from './createFile.ts'\nimport type { FabricEvents } from './Fabric.ts'\nimport { FileProcessor, type ProcessFilesProps } from './FileProcessor.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\nimport { Cache } from './utils/Cache.ts'\nimport { trimExtName } from './utils/trimExtName.ts'\n\nfunction mergeFile<TMeta extends object = object>(a: KubbFile.File<TMeta>, b: KubbFile.File<TMeta>): KubbFile.File<TMeta> {\n return {\n ...a,\n sources: [...(a.sources || []), ...(b.sources || [])],\n imports: [...(a.imports || []), ...(b.imports || [])],\n exports: [...(a.exports || []), ...(b.exports || [])],\n }\n}\n\ntype Options = {\n events?: AsyncEventEmitter<FabricEvents>\n}\n\nexport class FileManager {\n #cache = new Cache<KubbFile.ResolvedFile>()\n #filesCache: Array<KubbFile.ResolvedFile> | null = null\n events: AsyncEventEmitter<FabricEvents>\n processor: FileProcessor\n\n constructor({ events = new AsyncEventEmitter<FabricEvents>() }: Options = {}) {\n this.processor = new FileProcessor({ events })\n\n this.events = events\n return this\n }\n\n #resolvePath(file: KubbFile.File): KubbFile.File {\n this.events.emit('file:resolve:path', { file })\n\n return file\n }\n\n #resolveName(file: KubbFile.File): KubbFile.File {\n this.events.emit('file:resolve:name', { file })\n\n return file\n }\n\n async add(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (let file of mergedFiles.values()) {\n file = this.#resolveName(file)\n file = this.#resolvePath(file)\n\n const resolvedFile = createFile(file)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n await this.events.emit('files:added', { files: resolvedFiles })\n\n return resolvedFiles\n }\n\n async upsert(...files: Array<KubbFile.File>) {\n const resolvedFiles: Array<KubbFile.ResolvedFile> = []\n\n const mergedFiles = new Map<string, KubbFile.File>()\n\n files.forEach((file) => {\n const existing = mergedFiles.get(file.path)\n if (existing) {\n mergedFiles.set(file.path, mergeFile(existing, file))\n } else {\n mergedFiles.set(file.path, file)\n }\n })\n\n for (let file of mergedFiles.values()) {\n const existing = this.#cache.get(file.path)\n\n file = this.#resolveName(file)\n file = this.#resolvePath(file)\n\n const merged = existing ? mergeFile(existing, file) : file\n const resolvedFile = createFile(merged)\n\n this.#cache.set(resolvedFile.path, resolvedFile)\n this.flush()\n\n resolvedFiles.push(resolvedFile)\n }\n\n await this.events.emit('files:added', { files: resolvedFiles })\n\n return resolvedFiles\n }\n\n flush() {\n this.#filesCache = null\n this.#cache.flush()\n }\n\n getByPath(path: KubbFile.Path): KubbFile.ResolvedFile | null {\n return this.#cache.get(path)\n }\n\n deleteByPath(path: KubbFile.Path): void {\n this.#cache.delete(path)\n this.#filesCache = null\n }\n\n clear(): void {\n this.#cache.clear()\n this.#filesCache = null\n }\n\n get files(): Array<KubbFile.ResolvedFile> {\n if (this.#filesCache) {\n return this.#filesCache\n }\n\n const cachedKeys = this.#cache.keys()\n\n // order by path length and if file is a barrel file\n const keys = orderBy(cachedKeys, [(v) => v.length, (v) => trimExtName(v).endsWith('index')])\n\n const files: Array<KubbFile.ResolvedFile> = []\n\n for (const key of keys) {\n const file = this.#cache.get(key)\n if (file) {\n files.push(file)\n }\n }\n\n this.#filesCache = files\n\n return files\n }\n\n //TODO add test and check if write of FileManager contains the newly added file\n async write(options: ProcessFilesProps): Promise<KubbFile.ResolvedFile[]> {\n await this.events.emit('files:writing:start', { files: this.files })\n\n const resolvedFiles = await this.processor.run(this.files, options)\n\n this.clear()\n\n await this.events.emit('files:writing:end', { files: resolvedFiles })\n\n return resolvedFiles\n }\n}\n","import { isFunction } from 'remeda'\nimport type { Fabric, FabricConfig, FabricContext, FabricEvents, FabricOptions } from './Fabric.ts'\nimport { FileManager } from './FileManager.ts'\nimport type * as KubbFile from './KubbFile.ts'\nimport type { Parser } from './parsers/types.ts'\nimport type { Plugin } from './plugins/types.ts'\nimport { AsyncEventEmitter } from './utils/AsyncEventEmitter.ts'\n\n/**\n * Creates a new Fabric instance\n *\n * @example\n * const fabric = createFabric()\n * fabric.use(myPlugin())\n */\nexport function createFabric<T extends FabricOptions>(config: FabricConfig<T> = { mode: 'sequential' } as FabricConfig<T>): Fabric<T> {\n const events = new AsyncEventEmitter<FabricEvents>()\n const installedPlugins = new Set<Plugin<any>>()\n const installedParsers = new Map<KubbFile.Extname, Parser<any>>()\n const installedParserNames = new Set<string>()\n const fileManager = new FileManager({ events })\n\n const context: FabricContext<T> = {\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n config,\n fileManager,\n installedPlugins,\n installedParsers,\n on: events.on.bind(events),\n off: events.off.bind(events),\n onOnce: events.onOnce.bind(events),\n removeAll: events.removeAll.bind(events),\n emit: events.emit.bind(events),\n } as FabricContext<T>\n\n const fabric: Fabric<T> = {\n context,\n get files() {\n return fileManager.files\n },\n async addFile(...files) {\n await fileManager.add(...files)\n },\n async upsertFile(...files) {\n await fileManager.upsert(...files)\n },\n async use(pluginOrParser, ...options) {\n if (pluginOrParser.type === 'plugin') {\n if (installedPlugins.has(pluginOrParser)) {\n console.warn(`Plugin \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedPlugins.add(pluginOrParser)\n }\n\n if (isFunction(pluginOrParser.inject)) {\n const injecter = pluginOrParser.inject\n\n const injected = (injecter as any)(context, ...options)\n Object.assign(fabric, injected)\n }\n }\n\n if (pluginOrParser.type === 'parser') {\n if (installedParserNames.has(pluginOrParser.name)) {\n console.warn(`Parser \"${pluginOrParser.name}\" already applied.`)\n } else {\n installedParserNames.add(pluginOrParser.name)\n }\n\n if (pluginOrParser.extNames) {\n for (const extName of pluginOrParser.extNames) {\n const existing = installedParsers.get(extName)\n if (existing && existing.name !== pluginOrParser.name) {\n console.warn(`Parser \"${pluginOrParser.name}\" is overriding parser \"${existing.name}\" for extension \"${extName}\".`)\n }\n installedParsers.set(extName, pluginOrParser)\n }\n }\n }\n\n if (isFunction(pluginOrParser.install)) {\n const installer = pluginOrParser.install\n\n await (installer as any)(context, ...options)\n }\n\n return fabric\n },\n } as Fabric<T>\n\n return fabric\n}\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;AAAA,MAAM,KAAE,QAAG,OAAOA,OAAG;;;;;;ACQrB,IAAa,oBAAb,MAAoE;CAClE,YAAY,EAAE,cAAc,KAAK,OAAO,iBAA0B,EAAE,EAAE;oEAK3D,IAAIC,0BAAkB;;AAJ/B,+DAAa,CAAC,gBAAgB,YAAY;AAC1C,6DAAa,KAAI;;CAMnB,MAAM,KAAgD,WAAuB,GAAG,WAA+C;EAC7H,MAAM,oEAAY,KAAa,CAAC,UAAU,UAAU;AAEpD,MAAI,UAAU,WAAW,EACvB;EAGF,MAAMC,SAAkB,EAAE;AAE1B,2DAAI,KAAU,KAAK,aAEjB,MAAK,MAAM,YAAY,UACrB,KAAI;AACF,SAAM,SAAS,GAAG,UAAU;WACrB,KAAK;GACZ,MAAM,QAAQ,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,IAAI,CAAC;AACjE,UAAO,KAAK,MAAM;;OAGjB;GAEL,MAAM,WAAW,UAAU,IAAI,OAAO,aAAa;AACjD,QAAI;AACF,WAAM,SAAS,GAAG,UAAU;aACrB,KAAK;KACZ,MAAM,QAAQ,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,IAAI,CAAC;AACjE,YAAO,KAAK,MAAM;;KAEpB;AACF,SAAM,QAAQ,IAAI,SAAS;;AAG7B,MAAI,OAAO,WAAW,EACpB,OAAM,OAAO;AAGf,MAAI,OAAO,SAAS,EAClB,OAAM,IAAI,eAAe,QAAQ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Ae;AAGtC,QAAIC,EAAW,eAAe,OAAO,EAAE;KACrC,MAAM,WAAW,eAAe;KAEhC,MAAM,WAAY,SAAiB,SAAS,GAAG,QAAQ;AACvD,YAAO,OAAO,QAAQ,SAAS;;;AAInC,OAAI,eAAe,SAAS,UAAU;AACpC,QAAI,qBAAqB,IAAI,eAAe,KAAK,CAC/C,SAAQ,KAAK,WAAW,eAAe,KAAK,oBAAoB;QAEhE,sBAAqB,IAAI,eAAe,KAAK;AAG/C,QAAI,eAAe,SACjB,MAAK,MAAM,WAAW,eAAe,UAAU;KAC7C,MAAM,WAAW,iBAAiB,IAAI,QAAQ;AAC9C,SAAI,YAAY,SAAS,SAAS,eAAe,KAC/C,SAAQ,KAAK,WAAW,eAAe,KAAK,0BAA0B,SAAS,KAAK,mBAAmB,QAAQ,IAAI;AAErH,sBAAiB,IAAI,SAAS,eAAe;;;AAKnD,OAAIA,EAAW,eAAe,QAAQ,EAAE;IACtC,MAAM,YAAY,eAAe;AAEjC,UAAO,UAAkB,SAAS,GAAG,QAAQ;;AAG/C,UAAO;;EAEV;AAED,QAAO"}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as FabricOptions, c as FileManager, h as ResolvedFile, l as FileProcessor, n as FabricConfig, p as File, t as Fabric } from "./Fabric-DlBN6CDR.cjs";
1
+ import { a as FabricOptions, c as FileManager, h as ResolvedFile, l as FileProcessor, n as FabricConfig, p as File, t as Fabric } from "./Fabric-CVnHPMqM.cjs";
2
2
 
3
3
  //#region src/createFabric.d.ts
4
4
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as FabricOptions, c as FileManager, h as ResolvedFile, l as FileProcessor, n as FabricConfig, p as File, t as Fabric } from "./Fabric-CtqeUUFU.js";
1
+ import { a as FabricOptions, c as FileManager, h as ResolvedFile, l as FileProcessor, n as FabricConfig, p as File, t as Fabric } from "./Fabric-CEVrEuYU.js";
2
2
 
3
3
  //#region src/createFabric.d.ts
4
4
 
package/dist/index.js CHANGED
@@ -99,7 +99,7 @@ var FileProcessor = class {
99
99
  });
100
100
  const currentProcessed = ++processed;
101
101
  const percentage = currentProcessed / total * 100;
102
- await this.events.emit("files:processing:update", {
102
+ await this.events.emit("file:processing:update", {
103
103
  file: resolvedFile,
104
104
  source,
105
105
  processed: currentProcessed,
@@ -259,11 +259,11 @@ var FileManager = class {
259
259
  }
260
260
  };
261
261
  function _resolvePath(file) {
262
- this.events.emit("file:path:resolving", { file });
262
+ this.events.emit("file:resolve:path", { file });
263
263
  return file;
264
264
  }
265
265
  function _resolveName(file) {
266
- this.events.emit("file:name:resolving", { file });
266
+ this.events.emit("file:resolve:name", { file });
267
267
  return file;
268
268
  }
269
269