@kubb/fabric-core 0.0.0-canary-20251205093336 → 0.0.0-canary-20251217095301
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-igvWKffO.d.ts → Fabric-BXYWK9V4.d.cts} +91 -48
- package/dist/{Fabric-BzIhBn8t.d.cts → Fabric-CDFwTDyP.d.ts} +91 -48
- 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 +75 -93
- 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 +76 -93
- 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 +34 -34
- 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 +34 -34
- package/dist/plugins.js.map +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- 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-BN1vEX-I.d.ts → typescriptParser-CPUUUA9z.d.ts} +2 -2
- package/dist/{typescriptParser-BlRK18rx.d.cts → typescriptParser-H0FvAP4t.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 +95 -23
- package/src/FileManager.ts +6 -6
- 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 +4 -4
- 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 +39 -29
- 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,65 +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. */
|
|
257
|
-
start: [];
|
|
258
|
-
/** Called at the end of the app lifecycle. */
|
|
259
|
-
end: [];
|
|
260
|
-
/** Called when Fabric is rendering. */
|
|
261
|
-
render: [{
|
|
262
|
-
fabric: Fabric;
|
|
263
|
-
}];
|
|
264
|
-
/** Called once before any files are processed. */
|
|
265
|
-
'process:start': [{
|
|
266
|
-
files: ResolvedFile[];
|
|
267
|
-
}];
|
|
268
267
|
/**
|
|
269
|
-
*
|
|
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.
|
|
270
271
|
*/
|
|
271
|
-
'
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
'
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
index: number;
|
|
290
|
-
total: number;
|
|
291
|
-
}];
|
|
292
|
-
/** Called for each file when processing completes. */
|
|
293
|
-
'file:end': [{
|
|
294
|
-
file: ResolvedFile;
|
|
295
|
-
index: number;
|
|
296
|
-
total: number;
|
|
297
|
-
}];
|
|
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
|
+
'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>];
|
|
298
290
|
/**
|
|
299
|
-
*
|
|
300
|
-
*
|
|
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.
|
|
301
294
|
*/
|
|
302
|
-
'
|
|
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': [{
|
|
303
344
|
processed: number;
|
|
304
345
|
total: number;
|
|
305
346
|
percentage: number;
|
|
306
347
|
source?: string;
|
|
307
348
|
file: ResolvedFile;
|
|
308
349
|
}];
|
|
309
|
-
/**
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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>];
|
|
313
356
|
}
|
|
314
357
|
/**
|
|
315
358
|
* Shared context passed to all plugins, parsers, and Fabric internals.
|
|
@@ -372,4 +415,4 @@ interface Fabric<T extends FabricOptions = FabricOptions> extends Kubb.Fabric {
|
|
|
372
415
|
}
|
|
373
416
|
//#endregion
|
|
374
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 };
|
|
375
|
-
//# sourceMappingURL=Fabric-
|
|
418
|
+
//# sourceMappingURL=Fabric-BXYWK9V4.d.cts.map
|
|
@@ -251,65 +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. */
|
|
257
|
-
start: [];
|
|
258
|
-
/** Called at the end of the app lifecycle. */
|
|
259
|
-
end: [];
|
|
260
|
-
/** Called when Fabric is rendering. */
|
|
261
|
-
render: [{
|
|
262
|
-
fabric: Fabric;
|
|
263
|
-
}];
|
|
264
|
-
/** Called once before any files are processed. */
|
|
265
|
-
'process:start': [{
|
|
266
|
-
files: ResolvedFile[];
|
|
267
|
-
}];
|
|
268
267
|
/**
|
|
269
|
-
*
|
|
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.
|
|
270
271
|
*/
|
|
271
|
-
'
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
'
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
index: number;
|
|
290
|
-
total: number;
|
|
291
|
-
}];
|
|
292
|
-
/** Called for each file when processing completes. */
|
|
293
|
-
'file:end': [{
|
|
294
|
-
file: ResolvedFile;
|
|
295
|
-
index: number;
|
|
296
|
-
total: number;
|
|
297
|
-
}];
|
|
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
|
+
'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>];
|
|
298
290
|
/**
|
|
299
|
-
*
|
|
300
|
-
*
|
|
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.
|
|
301
294
|
*/
|
|
302
|
-
'
|
|
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': [{
|
|
303
344
|
processed: number;
|
|
304
345
|
total: number;
|
|
305
346
|
percentage: number;
|
|
306
347
|
source?: string;
|
|
307
348
|
file: ResolvedFile;
|
|
308
349
|
}];
|
|
309
|
-
/**
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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>];
|
|
313
356
|
}
|
|
314
357
|
/**
|
|
315
358
|
* Shared context passed to all plugins, parsers, and Fabric internals.
|
|
@@ -372,4 +415,4 @@ interface Fabric<T extends FabricOptions = FabricOptions> extends Kubb.Fabric {
|
|
|
372
415
|
}
|
|
373
416
|
//#endregion
|
|
374
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 };
|
|
375
|
-
//# sourceMappingURL=Fabric-
|
|
418
|
+
//# sourceMappingURL=Fabric-CDFwTDyP.d.ts.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"}
|