@kubb/fabric-core 0.5.4 → 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 +53 -23
- package/dist/{Fabric-BzIhBn8t.d.cts → Fabric-CEVrEuYU.d.ts} +113 -22
- package/dist/{Fabric-igvWKffO.d.ts → Fabric-CVnHPMqM.d.cts} +113 -22
- package/dist/{defaultParser-n9VW2iVf.cjs → defaultParser-CIF-0xIK.cjs} +3 -3
- package/dist/{defaultParser-n9VW2iVf.cjs.map → defaultParser-CIF-0xIK.cjs.map} +1 -1
- package/dist/{defaultParser-Csot2aaT.js → defaultParser-DPHcM2NR.js} +3 -3
- package/dist/{defaultParser-Csot2aaT.js.map → defaultParser-DPHcM2NR.js.map} +1 -1
- package/dist/defineParser-Bxv4mb-N.js +11 -0
- package/dist/{createParser-D_ANHZTa.js.map → defineParser-Bxv4mb-N.js.map} +1 -1
- package/dist/defineParser-DODGK4rM.cjs +17 -0
- package/dist/{createParser-C4IkyTs5.cjs.map → defineParser-DODGK4rM.cjs.map} +1 -1
- package/dist/index.cjs +73 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -22
- package/dist/index.d.ts +7 -22
- package/dist/index.js +74 -83
- package/dist/index.js.map +1 -1
- package/dist/parsers/typescript.cjs +2 -2
- package/dist/parsers/typescript.d.cts +2 -2
- package/dist/parsers/typescript.d.ts +2 -2
- package/dist/parsers/typescript.js +2 -2
- package/dist/parsers.cjs +5 -5
- package/dist/parsers.cjs.map +1 -1
- package/dist/parsers.d.cts +6 -6
- package/dist/parsers.d.ts +6 -6
- package/dist/parsers.js +5 -5
- package/dist/parsers.js.map +1 -1
- package/dist/plugins.cjs +32 -32
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +4 -4
- package/dist/plugins.d.ts +4 -4
- package/dist/plugins.js +32 -32
- package/dist/plugins.js.map +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/{typescriptParser-BN1vEX-I.d.ts → typescriptParser-9jJzfPj-.d.ts} +2 -2
- package/dist/{typescriptParser-Cw2wm0gX.js → typescriptParser-BLX7eX2k.js} +3 -3
- package/dist/{typescriptParser-Cw2wm0gX.js.map → typescriptParser-BLX7eX2k.js.map} +1 -1
- package/dist/{typescriptParser-BlRK18rx.d.cts → typescriptParser-DCFNN4BL.d.cts} +2 -2
- package/dist/{typescriptParser-DRdx9q2o.cjs → typescriptParser-OjFZ_DeI.cjs} +3 -3
- package/dist/{typescriptParser-DRdx9q2o.cjs.map → typescriptParser-OjFZ_DeI.cjs.map} +1 -1
- package/package.json +1 -1
- package/src/Fabric.ts +117 -21
- package/src/FileManager.ts +4 -4
- package/src/FileProcessor.ts +5 -5
- package/src/createFabric.ts +96 -2
- package/src/index.ts +0 -1
- package/src/parsers/defaultParser.ts +2 -2
- package/src/parsers/{createParser.ts → defineParser.ts} +1 -1
- package/src/parsers/index.ts +1 -2
- package/src/parsers/tsxParser.ts +2 -2
- package/src/parsers/typescriptParser.ts +2 -2
- package/src/plugins/barrelPlugin.ts +3 -3
- package/src/plugins/{createPlugin.ts → definePlugin.ts} +1 -1
- package/src/plugins/fsPlugin.ts +3 -3
- package/src/plugins/graphPlugin.ts +3 -3
- package/src/plugins/index.ts +1 -1
- package/src/plugins/loggerPlugin.ts +37 -27
- package/dist/createParser-C4IkyTs5.cjs +0 -17
- package/dist/createParser-D_ANHZTa.js +0 -11
- package/src/defineFabric.ts +0 -119
package/README.md
CHANGED
|
@@ -83,26 +83,56 @@ Returns a Fabric instance with:
|
|
|
83
83
|
- `fabric.files` — getter with all queued files.
|
|
84
84
|
- `fabric.context` — internal context holding events, options, FileManager, installed plugins/parsers.
|
|
85
85
|
|
|
86
|
-
### `defineFabric(instance?): () => Fabric`
|
|
87
|
-
Factory to create your own `createFabric` with an optional bootstrap `instance(fabric)` called on creation.
|
|
88
86
|
|
|
89
87
|
### Events (emitted by the core during processing)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
-
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
-
|
|
100
|
-
-
|
|
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
|
+
```
|
|
101
131
|
|
|
102
132
|
|
|
103
133
|
## Plugins
|
|
104
134
|
#### `fsPlugin`
|
|
105
|
-
Writes files to disk on `
|
|
135
|
+
Writes files to disk on `file:processing:update`, supports dry runs and cleaning an output folder before writing.
|
|
106
136
|
|
|
107
137
|
```
|
|
108
138
|
import { fsPlugin } from '@kubb/fabric-core/plugins'
|
|
@@ -111,7 +141,7 @@ import { fsPlugin } from '@kubb/fabric-core/plugins'
|
|
|
111
141
|
| Option | Type | Default | Description |
|
|
112
142
|
|---|----------------------------------------------------------------------|---|-----------------------------------------------------------------------|
|
|
113
143
|
| dryRun | `boolean` | `false` | If true, do not write files to disk. |
|
|
114
|
-
| onBeforeWrite | `(path: string, data: string \| undefined) => void \| Promise<void>` | — | Called right before each file write on `
|
|
144
|
+
| onBeforeWrite | `(path: string, data: string \| undefined) => void \| Promise<void>` | — | Called right before each file write on `file:processing:update`. |
|
|
115
145
|
| clean | `{ path: string }` | — | If provided, removes the directory at `path` before writing any files. |
|
|
116
146
|
|
|
117
147
|
Injected `fabric.write` options (via `fsPlugin`):
|
|
@@ -121,7 +151,7 @@ Injected `fabric.write` options (via `fsPlugin`):
|
|
|
121
151
|
| extension | `Record<Extname, Extname \| ''>` | — | Maps input file extensions to output extensions. When set, the matching parser (by extNames) is used. |
|
|
122
152
|
|
|
123
153
|
#### `barrelPlugin`
|
|
124
|
-
Generates `index.ts` barrel files per folder
|
|
154
|
+
Generates `index.ts` barrel files per folder when `files:writing:start` is triggered. `writeEntry` creates a single entry barrel at `root`.
|
|
125
155
|
|
|
126
156
|
```
|
|
127
157
|
import { barrelPlugin } from '@kubb/fabric-core/plugins'
|
|
@@ -191,7 +221,7 @@ Injected methods (via `reactPlugin`):
|
|
|
191
221
|
| `renderToString` | `(App: React.ElementType) => Promise<string> \| string` | Render a React component tree and return the final output as a string (without writing to stdout). |
|
|
192
222
|
| `waitUntilExit` | `() => Promise<void>` | Wait until the rendered app exits, resolves when unmounted and emits the core `end` event. |
|
|
193
223
|
|
|
194
|
-
#### `
|
|
224
|
+
#### `definePlugin`
|
|
195
225
|
|
|
196
226
|
Factory to declare a plugin that can be registered via `fabric.use`.
|
|
197
227
|
|
|
@@ -205,12 +235,12 @@ Example:
|
|
|
205
235
|
|
|
206
236
|
```ts
|
|
207
237
|
import { createFabric } from '@kubb/fabric-core'
|
|
208
|
-
import {
|
|
238
|
+
import { definePlugin } from '@kubb/fabric-core/plugins'
|
|
209
239
|
|
|
210
|
-
const helloPlugin =
|
|
240
|
+
const helloPlugin = definePlugin<{ name?: string }, { sayHello: (msg?: string) => void }>({
|
|
211
241
|
name: 'helloPlugin',
|
|
212
242
|
install(fabric, options) {
|
|
213
|
-
fabric.context.events.on('start', () => {
|
|
243
|
+
fabric.context.events.on('lifecycle:start', () => {
|
|
214
244
|
console.log('Fabric started')
|
|
215
245
|
})
|
|
216
246
|
},
|
|
@@ -267,7 +297,7 @@ import { defaultParser } @kubb/fabric-core/parsers`
|
|
|
267
297
|
|---|---|---|--------------------------------------------------------------------------|
|
|
268
298
|
| file | `KubbFile.File` | -| File that will be used to be parsed. |
|
|
269
299
|
|
|
270
|
-
#### `
|
|
300
|
+
#### `defineParser`
|
|
271
301
|
Factory to declare a parser that can be registered via `fabric.use` and selected by `extNames` during `fabirc.write`.
|
|
272
302
|
|
|
273
303
|
| Field | Required | Description |
|
|
@@ -281,9 +311,9 @@ Example:
|
|
|
281
311
|
|
|
282
312
|
```ts
|
|
283
313
|
import { createFabric } from '@kubb/fabric-core'
|
|
284
|
-
import {
|
|
314
|
+
import { defineParser } from '@kubb/fabric-core/parsers'
|
|
285
315
|
|
|
286
|
-
const vueParser =
|
|
316
|
+
const vueParser = defineParser<{ banner?: string }>({
|
|
287
317
|
name: 'vueParser',
|
|
288
318
|
extNames: ['.vue'],
|
|
289
319
|
async install(fabric, options) {
|
|
@@ -251,63 +251,154 @@ 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
|
-
/**
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
+
*/
|
|
272
|
+
'lifecycle:start': [];
|
|
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
|
+
*/
|
|
278
|
+
'lifecycle:end': [];
|
|
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
|
+
*/
|
|
285
|
+
'lifecycle:render': [{
|
|
262
286
|
fabric: Fabric;
|
|
263
287
|
}];
|
|
264
|
-
/**
|
|
265
|
-
|
|
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
|
+
*/
|
|
295
|
+
'files:processing:start': [{
|
|
266
296
|
files: ResolvedFile[];
|
|
267
297
|
}];
|
|
268
298
|
/**
|
|
269
|
-
*
|
|
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
|
|
270
304
|
*/
|
|
271
|
-
'
|
|
305
|
+
'files:added': [{
|
|
272
306
|
files: ResolvedFile[];
|
|
273
307
|
}];
|
|
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
|
+
*/
|
|
274
315
|
'file:resolve:path': [{
|
|
275
316
|
file: File;
|
|
276
317
|
}];
|
|
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
|
+
*/
|
|
277
325
|
'file:resolve:name': [{
|
|
278
326
|
file: File;
|
|
279
327
|
}];
|
|
280
|
-
|
|
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
|
+
*/
|
|
335
|
+
'files:writing:start': [{
|
|
281
336
|
files: ResolvedFile[];
|
|
282
337
|
}];
|
|
283
|
-
|
|
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
|
+
*/
|
|
345
|
+
'files:writing:end': [{
|
|
284
346
|
files: ResolvedFile[];
|
|
285
347
|
}];
|
|
286
|
-
/**
|
|
287
|
-
|
|
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
|
+
*/
|
|
357
|
+
'file:processing:start': [{
|
|
288
358
|
file: ResolvedFile;
|
|
289
359
|
index: number;
|
|
290
360
|
total: number;
|
|
291
361
|
}];
|
|
292
|
-
/**
|
|
293
|
-
|
|
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
|
+
*/
|
|
371
|
+
'file:processing:end': [{
|
|
294
372
|
file: ResolvedFile;
|
|
295
373
|
index: number;
|
|
296
374
|
total: number;
|
|
297
375
|
}];
|
|
298
376
|
/**
|
|
299
|
-
*
|
|
300
|
-
*
|
|
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
|
|
301
386
|
*/
|
|
302
|
-
'
|
|
387
|
+
'file:processing:update': [{
|
|
303
388
|
processed: number;
|
|
304
389
|
total: number;
|
|
305
390
|
percentage: number;
|
|
306
391
|
source?: string;
|
|
307
392
|
file: ResolvedFile;
|
|
308
393
|
}];
|
|
309
|
-
/**
|
|
310
|
-
|
|
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
|
+
*/
|
|
401
|
+
'files:processing:end': [{
|
|
311
402
|
files: ResolvedFile[];
|
|
312
403
|
}];
|
|
313
404
|
}
|
|
@@ -372,4 +463,4 @@ interface Fabric<T extends FabricOptions = FabricOptions> extends Kubb.Fabric {
|
|
|
372
463
|
}
|
|
373
464
|
//#endregion
|
|
374
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 };
|
|
375
|
-
//# sourceMappingURL=Fabric-
|
|
466
|
+
//# sourceMappingURL=Fabric-CEVrEuYU.d.ts.map
|
|
@@ -251,63 +251,154 @@ 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
|
-
/**
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
+
*/
|
|
272
|
+
'lifecycle:start': [];
|
|
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
|
+
*/
|
|
278
|
+
'lifecycle:end': [];
|
|
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
|
+
*/
|
|
285
|
+
'lifecycle:render': [{
|
|
262
286
|
fabric: Fabric;
|
|
263
287
|
}];
|
|
264
|
-
/**
|
|
265
|
-
|
|
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
|
+
*/
|
|
295
|
+
'files:processing:start': [{
|
|
266
296
|
files: ResolvedFile[];
|
|
267
297
|
}];
|
|
268
298
|
/**
|
|
269
|
-
*
|
|
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
|
|
270
304
|
*/
|
|
271
|
-
'
|
|
305
|
+
'files:added': [{
|
|
272
306
|
files: ResolvedFile[];
|
|
273
307
|
}];
|
|
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
|
+
*/
|
|
274
315
|
'file:resolve:path': [{
|
|
275
316
|
file: File;
|
|
276
317
|
}];
|
|
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
|
+
*/
|
|
277
325
|
'file:resolve:name': [{
|
|
278
326
|
file: File;
|
|
279
327
|
}];
|
|
280
|
-
|
|
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
|
+
*/
|
|
335
|
+
'files:writing:start': [{
|
|
281
336
|
files: ResolvedFile[];
|
|
282
337
|
}];
|
|
283
|
-
|
|
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
|
+
*/
|
|
345
|
+
'files:writing:end': [{
|
|
284
346
|
files: ResolvedFile[];
|
|
285
347
|
}];
|
|
286
|
-
/**
|
|
287
|
-
|
|
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
|
+
*/
|
|
357
|
+
'file:processing:start': [{
|
|
288
358
|
file: ResolvedFile;
|
|
289
359
|
index: number;
|
|
290
360
|
total: number;
|
|
291
361
|
}];
|
|
292
|
-
/**
|
|
293
|
-
|
|
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
|
+
*/
|
|
371
|
+
'file:processing:end': [{
|
|
294
372
|
file: ResolvedFile;
|
|
295
373
|
index: number;
|
|
296
374
|
total: number;
|
|
297
375
|
}];
|
|
298
376
|
/**
|
|
299
|
-
*
|
|
300
|
-
*
|
|
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
|
|
301
386
|
*/
|
|
302
|
-
'
|
|
387
|
+
'file:processing:update': [{
|
|
303
388
|
processed: number;
|
|
304
389
|
total: number;
|
|
305
390
|
percentage: number;
|
|
306
391
|
source?: string;
|
|
307
392
|
file: ResolvedFile;
|
|
308
393
|
}];
|
|
309
|
-
/**
|
|
310
|
-
|
|
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
|
+
*/
|
|
401
|
+
'files:processing:end': [{
|
|
311
402
|
files: ResolvedFile[];
|
|
312
403
|
}];
|
|
313
404
|
}
|
|
@@ -372,4 +463,4 @@ interface Fabric<T extends FabricOptions = FabricOptions> extends Kubb.Fabric {
|
|
|
372
463
|
}
|
|
373
464
|
//#endregion
|
|
374
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 };
|
|
375
|
-
//# sourceMappingURL=Fabric-
|
|
466
|
+
//# sourceMappingURL=Fabric-CVnHPMqM.d.cts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_defineParser = require('./defineParser-DODGK4rM.cjs');
|
|
2
2
|
|
|
3
3
|
//#region src/parsers/defaultParser.ts
|
|
4
|
-
const defaultParser =
|
|
4
|
+
const defaultParser = require_defineParser.defineParser({
|
|
5
5
|
name: "default",
|
|
6
6
|
extNames: [".json"],
|
|
7
7
|
install() {},
|
|
@@ -17,4 +17,4 @@ Object.defineProperty(exports, 'defaultParser', {
|
|
|
17
17
|
return defaultParser;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
//# sourceMappingURL=defaultParser-
|
|
20
|
+
//# sourceMappingURL=defaultParser-CIF-0xIK.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultParser-
|
|
1
|
+
{"version":3,"file":"defaultParser-CIF-0xIK.cjs","names":["defineParser"],"sources":["../src/parsers/defaultParser.ts"],"sourcesContent":["import { defineParser } from './defineParser.ts'\n\nexport const defaultParser = defineParser({\n name: 'default',\n extNames: ['.json'],\n install() {},\n async parse(file) {\n return file.sources.map((item) => item.value).join('\\n\\n')\n },\n})\n"],"mappings":";;;AAEA,MAAa,gBAAgBA,kCAAa;CACxC,MAAM;CACN,UAAU,CAAC,QAAQ;CACnB,UAAU;CACV,MAAM,MAAM,MAAM;AAChB,SAAO,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,CAAC,KAAK,OAAO;;CAE7D,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { t as defineParser } from "./defineParser-Bxv4mb-N.js";
|
|
2
2
|
|
|
3
3
|
//#region src/parsers/defaultParser.ts
|
|
4
|
-
const defaultParser =
|
|
4
|
+
const defaultParser = defineParser({
|
|
5
5
|
name: "default",
|
|
6
6
|
extNames: [".json"],
|
|
7
7
|
install() {},
|
|
@@ -12,4 +12,4 @@ const defaultParser = createParser({
|
|
|
12
12
|
|
|
13
13
|
//#endregion
|
|
14
14
|
export { defaultParser as t };
|
|
15
|
-
//# sourceMappingURL=defaultParser-
|
|
15
|
+
//# sourceMappingURL=defaultParser-DPHcM2NR.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultParser-
|
|
1
|
+
{"version":3,"file":"defaultParser-DPHcM2NR.js","names":[],"sources":["../src/parsers/defaultParser.ts"],"sourcesContent":["import { defineParser } from './defineParser.ts'\n\nexport const defaultParser = defineParser({\n name: 'default',\n extNames: ['.json'],\n install() {},\n async parse(file) {\n return file.sources.map((item) => item.value).join('\\n\\n')\n },\n})\n"],"mappings":";;;AAEA,MAAa,gBAAgB,aAAa;CACxC,MAAM;CACN,UAAU,CAAC,QAAQ;CACnB,UAAU;CACV,MAAM,MAAM,MAAM;AAChB,SAAO,KAAK,QAAQ,KAAK,SAAS,KAAK,MAAM,CAAC,KAAK,OAAO;;CAE7D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"defineParser-Bxv4mb-N.js","names":[],"sources":["../src/parsers/defineParser.ts"],"sourcesContent":["import type { Parser, UserParser } from './types.ts'\n\nexport function defineParser<TOptions = unknown, TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta> {\n return {\n type: 'parser',\n ...parser,\n }\n}\n"],"mappings":";AAEA,SAAgB,aAA6D,QAA8D;AACzI,QAAO;EACL,MAAM;EACN,GAAG;EACJ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/parsers/defineParser.ts
|
|
3
|
+
function defineParser(parser) {
|
|
4
|
+
return {
|
|
5
|
+
type: "parser",
|
|
6
|
+
...parser
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
Object.defineProperty(exports, 'defineParser', {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return defineParser;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=defineParser-DODGK4rM.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"defineParser-DODGK4rM.cjs","names":[],"sources":["../src/parsers/defineParser.ts"],"sourcesContent":["import type { Parser, UserParser } from './types.ts'\n\nexport function defineParser<TOptions = unknown, TMeta extends object = any>(parser: UserParser<TOptions, TMeta>): Parser<TOptions, TMeta> {\n return {\n type: 'parser',\n ...parser,\n }\n}\n"],"mappings":";;AAEA,SAAgB,aAA6D,QAA8D;AACzI,QAAO;EACL,MAAM;EACN,GAAG;EACJ"}
|