@kubb/fabric-core 0.5.5 → 0.7.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,64 +251,108 @@ 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. */
261
- 'lifecycle:render': [{
262
- fabric: Fabric;
263
- }];
264
- /** Called once before any files are processed. Provides all files that will be processed. */
265
- 'files:processing:start': [{
266
- files: ResolvedFile[];
267
- }];
268
- /** Called when FileManager is adding files to its cache. */
269
- 'files:added': [{
270
- files: ResolvedFile[];
271
- }];
272
- /** Called when resolving a file's path. Allows modification of the file path. */
273
- 'file:path:resolving': [{
274
- file: File;
275
- }];
276
- /** Called when resolving a file's name. Allows modification of the file name. */
277
- 'file:name:resolving': [{
278
- file: File;
279
- }];
280
- /** Called before writing files to disk. Provides all files that will be written. */
281
- 'files:writing:start': [{
282
- files: ResolvedFile[];
283
- }];
284
- /** Called after writing files to disk. Provides all files that were written. */
285
- 'files:writing:end': [{
286
- files: ResolvedFile[];
287
- }];
288
- /** Called when processing of an individual file begins. Provides file, current index, and total count. */
289
- 'file:processing:start': [{
290
- file: ResolvedFile;
291
- index: number;
292
- total: number;
293
- }];
294
- /** Called when processing of an individual file completes. Provides file, current index, and total count. */
295
- 'file:processing:end': [{
296
- file: ResolvedFile;
297
- index: number;
298
- total: number;
299
- }];
300
- /** Called periodically to indicate processing progress. Useful for progress bars or logging. */
301
- 'files:processing:update': [{
279
+ /**
280
+ * Emitted when Fabric starts rendering (used with reactPlugin).
281
+ * Provides access to the Fabric instance for render-time operations.
282
+ */
283
+ 'lifecycle:render': [fabric: Fabric];
284
+ /**
285
+ * Emitted once before file processing begins.
286
+ * Provides the complete list of files that will be processed.
287
+ * Use this to prepare for batch operations or display initial file counts.
288
+ */
289
+ 'files:processing:start': [files: Array<ResolvedFile>];
290
+ /**
291
+ * Emitted when files are successfully added to the FileManager's internal cache.
292
+ * This happens after files pass through path and name resolution.
293
+ * Use this to track which files have been registered.
294
+ */
295
+ 'files:added': [files: Array<ResolvedFile>];
296
+ /**
297
+ * Emitted during file path resolution, before a file is cached.
298
+ * Listeners can modify the file's path property to customize output location.
299
+ * This is called for each file being added via `addFile()` or `upsertFile()`.
300
+ */
301
+ 'file:resolve:path': [file: File];
302
+ /**
303
+ * Emitted during file name resolution, before a file is cached.
304
+ * Listeners can modify the file's name-related properties to customize naming.
305
+ * This is called for each file being added via `addFile()` or `upsertFile()`.
306
+ */
307
+ 'file:resolve:name': [file: File];
308
+ /**
309
+ * Emitted just before files are written to disk.
310
+ * Provides all files that will be written in this batch.
311
+ * Use this to perform pre-write operations like creating directories.
312
+ */
313
+ 'files:writing:start': [files: Array<ResolvedFile>];
314
+ /**
315
+ * Emitted after all files have been successfully written to disk.
316
+ * Provides all files that were written in this batch.
317
+ * Use this for post-write operations like running formatters or reporting.
318
+ */
319
+ 'files:writing:end': [files: Array<ResolvedFile>];
320
+ /**
321
+ * Emitted when an individual file starts being processed.
322
+ * This happens for each file in the queue, before parsing.
323
+ * Use this for per-file setup or detailed logging.
324
+ */
325
+ 'file:processing:start': [file: ResolvedFile, index: number, total: number];
326
+ /**
327
+ * Emitted when an individual file completes processing.
328
+ * This happens after the file has been parsed and handled.
329
+ * Use this for per-file cleanup or progress tracking.
330
+ */
331
+ 'file:processing:end': [file: ResolvedFile, index: number, total: number];
332
+ /**
333
+ * Emitted after each file is processed, providing progress metrics.
334
+ * This is the primary event for implementing progress bars or tracking.
335
+ * Plugins like fsPlugin use this to write files to disk.
336
+ *
337
+ * @property processed - Number of files processed so far
338
+ * @property total - Total number of files to process
339
+ * @property percentage - Completion percentage (0-100)
340
+ * @property source - Optional parsed source code of the file
341
+ * @property file - The file that was just processed
342
+ */
343
+ 'file:processing:update': [{
302
344
  processed: number;
303
345
  total: number;
304
346
  percentage: number;
305
347
  source?: string;
306
348
  file: ResolvedFile;
307
349
  }];
308
- /** Called once all files have been processed successfully. */
309
- 'files:processing:end': [{
310
- files: ResolvedFile[];
311
- }];
350
+ /**
351
+ * Emitted once all files have been successfully processed.
352
+ * This marks the completion of the processing phase.
353
+ * Use this to perform batch operations on all processed files.
354
+ */
355
+ 'files:processing:end': [files: Array<ResolvedFile>];
312
356
  }
313
357
  /**
314
358
  * Shared context passed to all plugins, parsers, and Fabric internals.
@@ -371,4 +415,4 @@ interface Fabric<T extends FabricOptions = FabricOptions> extends Kubb.Fabric {
371
415
  }
372
416
  //#endregion
373
417
  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
418
+ //# sourceMappingURL=Fabric-BXYWK9V4.d.cts.map
@@ -251,64 +251,108 @@ 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. */
261
- 'lifecycle:render': [{
262
- fabric: Fabric;
263
- }];
264
- /** Called once before any files are processed. Provides all files that will be processed. */
265
- 'files:processing:start': [{
266
- files: ResolvedFile[];
267
- }];
268
- /** Called when FileManager is adding files to its cache. */
269
- 'files:added': [{
270
- files: ResolvedFile[];
271
- }];
272
- /** Called when resolving a file's path. Allows modification of the file path. */
273
- 'file:path:resolving': [{
274
- file: File;
275
- }];
276
- /** Called when resolving a file's name. Allows modification of the file name. */
277
- 'file:name:resolving': [{
278
- file: File;
279
- }];
280
- /** Called before writing files to disk. Provides all files that will be written. */
281
- 'files:writing:start': [{
282
- files: ResolvedFile[];
283
- }];
284
- /** Called after writing files to disk. Provides all files that were written. */
285
- 'files:writing:end': [{
286
- files: ResolvedFile[];
287
- }];
288
- /** Called when processing of an individual file begins. Provides file, current index, and total count. */
289
- 'file:processing:start': [{
290
- file: ResolvedFile;
291
- index: number;
292
- total: number;
293
- }];
294
- /** Called when processing of an individual file completes. Provides file, current index, and total count. */
295
- 'file:processing:end': [{
296
- file: ResolvedFile;
297
- index: number;
298
- total: number;
299
- }];
300
- /** Called periodically to indicate processing progress. Useful for progress bars or logging. */
301
- 'files:processing:update': [{
279
+ /**
280
+ * Emitted when Fabric starts rendering (used with reactPlugin).
281
+ * Provides access to the Fabric instance for render-time operations.
282
+ */
283
+ 'lifecycle:render': [fabric: Fabric];
284
+ /**
285
+ * Emitted once before file processing begins.
286
+ * Provides the complete list of files that will be processed.
287
+ * Use this to prepare for batch operations or display initial file counts.
288
+ */
289
+ 'files:processing:start': [files: Array<ResolvedFile>];
290
+ /**
291
+ * Emitted when files are successfully added to the FileManager's internal cache.
292
+ * This happens after files pass through path and name resolution.
293
+ * Use this to track which files have been registered.
294
+ */
295
+ 'files:added': [files: Array<ResolvedFile>];
296
+ /**
297
+ * Emitted during file path resolution, before a file is cached.
298
+ * Listeners can modify the file's path property to customize output location.
299
+ * This is called for each file being added via `addFile()` or `upsertFile()`.
300
+ */
301
+ 'file:resolve:path': [file: File];
302
+ /**
303
+ * Emitted during file name resolution, before a file is cached.
304
+ * Listeners can modify the file's name-related properties to customize naming.
305
+ * This is called for each file being added via `addFile()` or `upsertFile()`.
306
+ */
307
+ 'file:resolve:name': [file: File];
308
+ /**
309
+ * Emitted just before files are written to disk.
310
+ * Provides all files that will be written in this batch.
311
+ * Use this to perform pre-write operations like creating directories.
312
+ */
313
+ 'files:writing:start': [files: Array<ResolvedFile>];
314
+ /**
315
+ * Emitted after all files have been successfully written to disk.
316
+ * Provides all files that were written in this batch.
317
+ * Use this for post-write operations like running formatters or reporting.
318
+ */
319
+ 'files:writing:end': [files: Array<ResolvedFile>];
320
+ /**
321
+ * Emitted when an individual file starts being processed.
322
+ * This happens for each file in the queue, before parsing.
323
+ * Use this for per-file setup or detailed logging.
324
+ */
325
+ 'file:processing:start': [file: ResolvedFile, index: number, total: number];
326
+ /**
327
+ * Emitted when an individual file completes processing.
328
+ * This happens after the file has been parsed and handled.
329
+ * Use this for per-file cleanup or progress tracking.
330
+ */
331
+ 'file:processing:end': [file: ResolvedFile, index: number, total: number];
332
+ /**
333
+ * Emitted after each file is processed, providing progress metrics.
334
+ * This is the primary event for implementing progress bars or tracking.
335
+ * Plugins like fsPlugin use this to write files to disk.
336
+ *
337
+ * @property processed - Number of files processed so far
338
+ * @property total - Total number of files to process
339
+ * @property percentage - Completion percentage (0-100)
340
+ * @property source - Optional parsed source code of the file
341
+ * @property file - The file that was just processed
342
+ */
343
+ 'file:processing:update': [{
302
344
  processed: number;
303
345
  total: number;
304
346
  percentage: number;
305
347
  source?: string;
306
348
  file: ResolvedFile;
307
349
  }];
308
- /** Called once all files have been processed successfully. */
309
- 'files:processing:end': [{
310
- files: ResolvedFile[];
311
- }];
350
+ /**
351
+ * Emitted once all files have been successfully processed.
352
+ * This marks the completion of the processing phase.
353
+ * Use this to perform batch operations on all processed files.
354
+ */
355
+ 'files:processing:end': [files: Array<ResolvedFile>];
312
356
  }
313
357
  /**
314
358
  * Shared context passed to all plugins, parsers, and Fabric internals.
@@ -371,4 +415,4 @@ interface Fabric<T extends FabricOptions = FabricOptions> extends Kubb.Fabric {
371
415
  }
372
416
  //#endregion
373
417
  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
418
+ //# sourceMappingURL=Fabric-CDFwTDyP.d.ts.map
package/dist/index.cjs CHANGED
@@ -85,33 +85,25 @@ var FileProcessor = class {
85
85
  return parser.parse(file, { extname: parseExtName });
86
86
  }
87
87
  async run(files, { parsers, mode = "sequential", dryRun, extension } = {}) {
88
- await this.events.emit("files:processing:start", { files });
88
+ await this.events.emit("files:processing:start", files);
89
89
  const total = files.length;
90
90
  let processed = 0;
91
91
  const processOne = async (resolvedFile, index) => {
92
- await this.events.emit("file:processing:start", {
93
- file: resolvedFile,
94
- index,
95
- total
96
- });
92
+ await this.events.emit("file:processing:start", resolvedFile, index, total);
97
93
  const source = dryRun ? void 0 : await this.parse(resolvedFile, {
98
94
  extension,
99
95
  parsers
100
96
  });
101
97
  const currentProcessed = ++processed;
102
98
  const percentage = currentProcessed / total * 100;
103
- await this.events.emit("files:processing:update", {
99
+ await this.events.emit("file:processing:update", {
104
100
  file: resolvedFile,
105
101
  source,
106
102
  processed: currentProcessed,
107
103
  percentage,
108
104
  total
109
105
  });
110
- await this.events.emit("file:processing:end", {
111
- file: resolvedFile,
112
- index,
113
- total
114
- });
106
+ await this.events.emit("file:processing:end", resolvedFile, index, total);
115
107
  };
116
108
  if (mode === "sequential") {
117
109
  async function* asyncFiles() {
@@ -122,7 +114,7 @@ var FileProcessor = class {
122
114
  const promises = files.map((resolvedFile, index) => require_defineProperty._classPrivateFieldGet2(_limit, this).call(this, () => processOne(resolvedFile, index)));
123
115
  await Promise.all(promises);
124
116
  }
125
- await this.events.emit("files:processing:end", { files });
117
+ await this.events.emit("files:processing:end", files);
126
118
  return files;
127
119
  }
128
120
  };
@@ -202,7 +194,7 @@ var FileManager = class {
202
194
  this.flush();
203
195
  resolvedFiles.push(resolvedFile);
204
196
  }
205
- await this.events.emit("files:added", { files: resolvedFiles });
197
+ await this.events.emit("files:added", resolvedFiles);
206
198
  return resolvedFiles;
207
199
  }
208
200
  async upsert(...files) {
@@ -222,7 +214,7 @@ var FileManager = class {
222
214
  this.flush();
223
215
  resolvedFiles.push(resolvedFile);
224
216
  }
225
- await this.events.emit("files:added", { files: resolvedFiles });
217
+ await this.events.emit("files:added", resolvedFiles);
226
218
  return resolvedFiles;
227
219
  }
228
220
  flush() {
@@ -252,19 +244,19 @@ var FileManager = class {
252
244
  return files;
253
245
  }
254
246
  async write(options) {
255
- await this.events.emit("files:writing:start", { files: this.files });
247
+ await this.events.emit("files:writing:start", this.files);
256
248
  const resolvedFiles = await this.processor.run(this.files, options);
257
249
  this.clear();
258
- await this.events.emit("files:writing:end", { files: resolvedFiles });
250
+ await this.events.emit("files:writing:end", resolvedFiles);
259
251
  return resolvedFiles;
260
252
  }
261
253
  };
262
254
  function _resolvePath(file) {
263
- this.events.emit("file:path:resolving", { file });
255
+ this.events.emit("file:resolve:path", file);
264
256
  return file;
265
257
  }
266
258
  function _resolveName(file) {
267
- this.events.emit("file:name:resolving", { file });
259
+ this.events.emit("file:resolve:name", file);
268
260
  return file;
269
261
  }
270
262
 
@@ -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,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,KAA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,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', 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', 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', 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', 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', 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', 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,kCAAkC,UAAU,GAAG;;CAIpF,GAA8C,WAAuB,SAA2D;AAC9H,+DAAa,CAAC,GAAG,WAAW,QAAe;;CAG7C,OAAkD,WAAuB,SAA4D;EACnI,MAAM,WAAW,GAAG,SAA8B;AAChD,QAAK,IAAI,WAAW,QAAQ;AAC5B,WAAQ,G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7C,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-BXYWK9V4.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-CDFwTDyP.js";
2
2
 
3
3
  //#region src/createFabric.d.ts
4
4