@kubb/fabric-core 0.0.0-canary-20251024133602 → 0.0.0-canary-20251027095849

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +273 -26
  2. package/dist/{App-ztRQpZS9.d.ts → Fabric-CCPgegwe.d.cts} +29 -29
  3. package/dist/{App-Cjd-lGfW.d.cts → Fabric-Cu_YHe4S.d.ts} +29 -29
  4. package/dist/index-BUculP1D.d.cts +18 -0
  5. package/dist/index-CvkyZHXK.d.ts +18 -0
  6. package/dist/index.cjs +17 -17
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +3 -3
  9. package/dist/index.d.ts +3 -3
  10. package/dist/index.js +16 -16
  11. package/dist/index.js.map +1 -1
  12. package/dist/parsers/typescript.d.cts +2 -2
  13. package/dist/parsers/typescript.d.ts +2 -2
  14. package/dist/parsers.d.cts +2 -2
  15. package/dist/parsers.d.ts +2 -2
  16. package/dist/plugins.cjs +54 -30
  17. package/dist/plugins.cjs.map +1 -1
  18. package/dist/plugins.d.cts +5 -5
  19. package/dist/plugins.d.ts +5 -5
  20. package/dist/plugins.js +54 -29
  21. package/dist/plugins.js.map +1 -1
  22. package/dist/types.d.cts +3 -3
  23. package/dist/types.d.ts +3 -3
  24. package/dist/{typescriptParser-DDr_EXfe.d.ts → typescriptParser-CCbr9PD6.d.cts} +2 -2
  25. package/dist/{typescriptParser-CBt00C7L.d.cts → typescriptParser-DHu674Vq.d.ts} +2 -2
  26. package/package.json +3 -5
  27. package/src/{App.ts → Fabric.ts} +16 -16
  28. package/src/FileManager.ts +4 -4
  29. package/src/FileProcessor.ts +5 -5
  30. package/src/createFabric.ts +3 -0
  31. package/src/{defineApp.ts → defineFabric.ts} +19 -19
  32. package/src/index.ts +3 -3
  33. package/src/parsers/types.ts +1 -1
  34. package/src/plugins/barrelPlugin.ts +2 -2
  35. package/src/plugins/fsPlugin.ts +48 -55
  36. package/src/plugins/graphPlugin.ts +1 -1
  37. package/src/plugins/types.ts +1 -1
  38. package/src/types.ts +2 -4
  39. package/src/utils/TreeNode.ts +1 -0
  40. package/src/utils/open.ts +36 -0
  41. package/dist/index-BUERYeq7.d.cts +0 -18
  42. package/dist/index-DfaD7Pj_.d.ts +0 -18
  43. package/src/createApp.ts +0 -3
package/README.md CHANGED
@@ -22,32 +22,279 @@
22
22
 
23
23
  <br />
24
24
 
25
- ## Supporting Kubb
25
+ Kubb Fabric is a language-agnostic toolkit for generating code and files using JSX and TypeScript.
26
+ It offers a lightweight layer for file generation while orchestrating the overall process of creating and managing files.
26
27
 
27
- Kubb uses an MIT-licensed open source project with its ongoing development made possible entirely by the support of Sponsors. If you would like to become a sponsor, please consider:
28
+ > [!WARNING]
29
+ > Fabric is under active development. Until a stable 1.0 release, minor versions may occasionally include breaking changes. Please check release notes and PR titles for breaking changes.
28
30
 
29
- - [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
30
31
 
31
- <p align="center">
32
- <a href="https://github.com/sponsors/stijnvanhulle">
33
- <img src="https://raw.githubusercontent.com/stijnvanhulle/sponsors/main/sponsors.svg" alt="My sponsors" />
34
- </a>
35
- </p>
36
-
37
-
38
- <!-- Badges -->
39
-
40
- [npm-version-src]: https://img.shields.io/npm/v/@kubb/fabric-core?flat&colorA=18181B&colorB=f58517
41
- [npm-version-href]: https://npmjs.com/package/@kubb/fabric-core
42
- [npm-downloads-src]: https://img.shields.io/npm/dm/@kubb/fabric-core?flat&colorA=18181B&colorB=f58517
43
- [npm-downloads-href]: https://npmjs.com/package/@kubb/fabric-core
44
- [license-src]: https://img.shields.io/github/license/kubb-labs/kubb.svg?flat&colorA=18181B&colorB=f58517
45
- [license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
46
- [build-src]: https://img.shields.io/github/actions/workflow/status/kubb-labs/kubb/ci.yaml?style=flat&colorA=18181B&colorB=f58517
47
- [build-href]: https://www.npmjs.com/package/@kubb/fabric-core
48
- [minified-src]: https://img.shields.io/bundlephobia/min/@kubb/fabric-core?style=flat&colorA=18181B&colorB=f58517
49
- [minified-href]: https://www.npmjs.com/package/@kubb/fabric-core
50
- [coverage-src]: https://img.shields.io/codecov/c/github/kubb-labs/kubb?style=flat&colorA=18181B&colorB=f58517
51
- [coverage-href]: https://www.npmjs.com/package/@kubb/fabric-core
52
- [sponsors-src]: https://img.shields.io/github/sponsors/stijnvanhulle?style=flat&colorA=18181B&colorB=f58517
53
- [sponsors-href]: https://github.com/sponsors/stijnvanhulle/
32
+ # Features
33
+
34
+ - 🎨 Declarative file generation — Create files effortlessly using JSX or JavaScript syntax.
35
+ - 📦 Cross-runtime support — Works seamlessly with Node.js and Bun.
36
+ - 🧩 Built-in debugging utilities — Simplify development and inspect generation flows with ease.
37
+ - ⚡ Fast and lightweight — Minimal overhead, maximum performance.
38
+
39
+ ## Write a TypeScript file
40
+
41
+ Below is a minimal example showing how `createFabric` works together with plugins and parsers via `fabric.use`.
42
+
43
+ ```ts
44
+ import { createFabric } from '@kubb/fabric-core'
45
+ import { fsPlugin } from '@kubb/fabric-core/plugins'
46
+ import { typescriptParser, createParser } from '@kubb/fabric-core/parsers'
47
+
48
+ const fabric = createFabric()
49
+
50
+ fabric.use(fsPlugin, {
51
+ dryRun: false,
52
+ onBeforeWrite: (path, data) => {
53
+ console.log('About to write:', path)
54
+ },
55
+ clean: { path: './generated' },
56
+ })
57
+
58
+ fabric.use(typescriptParser)
59
+
60
+ await fabric.addFile({
61
+ baseName: 'index.ts',
62
+ path: './generated/index.ts',
63
+ sources: [
64
+ { value: 'export const x = 1', isExportable: true },
65
+ ],
66
+ })
67
+
68
+ await fabric.write()
69
+
70
+ ```
71
+
72
+ # API Reference
73
+
74
+ ## Core
75
+ ### `createFabric(options?): Fabric`
76
+ Returns a Fabric instance with:
77
+ - `fabric.use(pluginOrParser, ...options) => Fabric` — register plugins and parsers.
78
+ - `fabric.addFile(...files)` — queue in-memory files to generate.
79
+ - `fabric.files` — getter with all queued files.
80
+ - `fabric.context` — internal context holding events, options, FileManager, installed plugins/parsers.
81
+
82
+ ### `defineFabric(instance?): () => Fabric`
83
+ Factory to create your own `createFabric` with an optional bootstrap `instance(fabric)` called on creation.
84
+
85
+ ### Events (emitted by the core during processing)
86
+ - `start`
87
+ - `end`
88
+ - `render { fabric }`
89
+ - `file:add { files }`
90
+ - `write:start { files }`
91
+ - `write:end { files }`
92
+ - `file:start { file, index, total }`
93
+ - `file:end { file, index, total }`
94
+ - `process:start { files }`
95
+ - `process:progress { file, source, processed, percentage, total }`
96
+ - `process:end { files }`
97
+
98
+
99
+ ## Plugins
100
+ #### `fsPlugin`
101
+ Writes files to disk on `process:progress`, supports dry runs and cleaning an output folder before writing.
102
+
103
+ ```
104
+ import { fsPlugin } from '@kubb/fabric-core/plugins'
105
+ ```
106
+
107
+ | Option | Type | Default | Description |
108
+ |---|----------------------------------------------------------------------|---|-----------------------------------------------------------------------|
109
+ | dryRun | `boolean` | `false` | If true, do not write files to disk. |
110
+ | onBeforeWrite | `(path: string, data: string \| undefined) => void \| Promise<void>` | — | Called right before each file write on `process:progress`. |
111
+ | clean | `{ path: string }` | — | If provided, removes the directory at `path` before writing any files. |
112
+
113
+ Injected `fabric.write` options (via `fsPlugin`):
114
+
115
+ | Option | Type | Default | Description |
116
+ |---|----------------------------------|---|---|
117
+ | extension | `Record<Extname, Extname \| ''>` | — | Maps input file extensions to output extensions. When set, the matching parser (by extNames) is used. |
118
+
119
+ #### `barrelPlugin`
120
+ Generates `index.ts` barrel files per folder at `process:end`. `writeEntry` creates a single entry barrel at `root`.
121
+
122
+ ```
123
+ import { barrelPlugin } from '@kubb/fabric-core/plugins'
124
+ ```
125
+
126
+ | Option | Type | Default | Description |
127
+ |---|--------------------------------------------|---|---|
128
+ | root | `string` | — | Root directory to generate barrel files for. |
129
+ | mode | `'all' \| 'named' \| 'propagate' \| false` | — | Controls how exports are generated: all exports, only named exports, propagate (skip barrels), or disabled. |
130
+ | dryRun | `boolean` | `false` | If true, computes barrels but skips writing. |
131
+
132
+ Injected `fabric.writeEntry` parameters (via `barrelPlugin`):
133
+
134
+ | Param | Type | Description |
135
+ |---|--------------------------------------------|---|
136
+ | root | `string` | Root directory where the entry `index.ts` should be created. |
137
+ | mode | `'all' \| 'named' \| 'propagate' \| false` | Controls which export style to use for the entry barrel. |
138
+
139
+ #### `progressPlugin`
140
+ Shows a CLI progress bar by listening to core events.
141
+
142
+ ```
143
+ import { progressPlugin } from '@kubb/fabric-core/plugins'
144
+ ```
145
+
146
+ | Option | Type | Default | Description |
147
+ |---|---|---|-----------------------------------------------------------------------------------------|
148
+ | — | — | — | This plugin has no options, it displays a CLI progress bar by listening to core events. |
149
+
150
+
151
+ #### `graphPlugin`
152
+ Shows a graph of all files
153
+
154
+ ```
155
+ import { graphPlugin } from '@kubb/fabric-core/plugins'
156
+ ```
157
+
158
+ | Option | Type | Default | Description |
159
+ |--------|-----------|---------|-----------------------------------------------|
160
+ | root | `string` | | Root directory where to start searching from. |
161
+ | open | `boolean` | false | Open a webpage with the generated graph |
162
+
163
+
164
+ #### `reactPlugin`
165
+ Enables rendering React components to the terminal or to a string. Useful for CLI UIs and templating.
166
+
167
+ ```
168
+ import { reactPlugin } from '@kubb/react-fabric/plugins'
169
+ ```
170
+
171
+ | Option | Type | Default | Description |
172
+ |---|---|---|---|
173
+ | stdout | `NodeJS.WriteStream` | — | Optional output stream used to print the rendered content while the app is running. If set, the output is written progressively. |
174
+ | stdin | `NodeJS.ReadStream` | — | Optional input stream for interactive components. |
175
+ | stderr | `NodeJS.WriteStream` | — | Optional error output stream. |
176
+ | debug | `boolean` | — | When true, logs render/unmount information to the console to aid debugging. |
177
+
178
+ Injected methods (via `reactPlugin`):
179
+
180
+ | Method | Signature | Description |
181
+ |---|---|----------------------------------------------------------------------------------------------------|
182
+ | `render` | `(App: React.ElementType) => Promise<void> \| void` | Render a React component tree to the terminal and emit the core `start` event. |
183
+ | `renderToString` | `(App: React.ElementType) => Promise<string> \| string` | Render a React component tree and return the final output as a string (without writing to stdout). |
184
+ | `waitUntilExit` | `() => Promise<void>` | Wait until the rendered app exits, resolves when unmounted and emits the core `end` event. |
185
+
186
+ #### `createPlugin`
187
+
188
+ Factory to declare a plugin that can be registered via `fabric.use`.
189
+
190
+ | Field | Required | Description |
191
+ |----------------------------|---|------------------------------------------------------------------------------------------------------------------------------|
192
+ | `name` | Yes | String identifier of your plugin. |
193
+ | `install(fabric, options)` | Yes | Called when the plugin is registered. You can subscribe to core events and perform side effects here. |
194
+ | `inject?(fabric, options)` | No | Return synchronously the runtime methods/properties to merge into `fabric` (e.g. `write`, `render`). This must not be async. |
195
+
196
+ Example:
197
+
198
+ ```ts
199
+ import { createFabric } from '@kubb/fabric-core'
200
+ import { createPlugin } from '@kubb/fabric-core/plugins'
201
+
202
+ const helloPlugin = createPlugin<{ name?: string }, { sayHello: (msg?: string) => void }>({
203
+ name: 'helloPlugin',
204
+ install(fabric, options) {
205
+ fabric.context.events.on('start', () => {
206
+ console.log('Fabric started')
207
+ })
208
+ },
209
+ inject(fabric, options) {
210
+ return {
211
+ sayHello(msg = options?.name ?? 'world') {
212
+ console.log(`Hello ${msg}!`)
213
+ },
214
+ }
215
+ },
216
+ })
217
+
218
+ const fabric = createFabric()
219
+ await fabric.use(helloPlugin, { name: 'Fabric' })
220
+ fabric.sayHello() // -> Hello Fabric!
221
+ ```
222
+
223
+ ## Parsers
224
+ #### `typescriptParser`
225
+
226
+ Prints TS/JS imports/exports and sources, supports extname mapping for generated import/export paths.
227
+
228
+ ```
229
+ import { typescriptParser } from '@kubb/fabric-core/parsers'
230
+ ```
231
+
232
+ | Option | Type | Default | Description |
233
+ |---|---|---|---------------------------------------------------------------------------------------------|
234
+ | file | `KubbFile.File` | -| File that will be used to be parsed. |
235
+ | extname | `string` | `'.ts'` | Extension to use when emitting import/export paths (e.g., rewrite `./file` to `./file.ts`). |
236
+
237
+ #### `tsxParser`
238
+
239
+ Delegates to `typescriptParser` with TSX printing settings.
240
+
241
+ ```
242
+ import { tsxParser } from '@kubb/fabric-core/parsers'
243
+ ```
244
+
245
+ | Option | Type | Default | Description |
246
+ |---|---|---|---|
247
+ | file | `KubbFile.File` | -| File that will be used to be parsed. |
248
+ | extname | `string` | `'.tsx'` | Extension to use when emitting import/export paths for TSX/JSX files. |
249
+
250
+ #### `defaultParser`
251
+
252
+ Fallback parser used when no extension mapping is provided to `fabric.write`.
253
+
254
+ ```
255
+ import { defaultParser } @kubb/fabric-core/parsers`
256
+ ```
257
+
258
+ | Option | Type | Default | Description |
259
+ |---|---|---|--------------------------------------------------------------------------|
260
+ | file | `KubbFile.File` | -| File that will be used to be parsed. |
261
+
262
+ #### `createParser`
263
+ Factory to declare a parser that can be registered via `fabric.use` and selected by `extNames` during `fabirc.write`.
264
+
265
+ | Field | Required | Description |
266
+ |----------------------------|---|-----------------------------------------------------------------------------------------------------------------|
267
+ | `name` | Yes | String identifier of your parser. |
268
+ | `extNames` | Yes | List of file extensions this parser can handle (e.g. ['.ts']). Use `undefined` for the default parser fallback. |
269
+ | `install(fabric, options)` | No | Optional setup when the parser is registered (subscribe to events, set state, etc.). |
270
+ | `parse(file, { extname })` | Yes | Must return the final string that will be written for the given file. |
271
+
272
+ Example:
273
+
274
+ ```ts
275
+ import { createFabric } from '@kubb/fabric-core'
276
+ import { createParser } from '@kubb/fabric-core/parsers'
277
+
278
+ const vueParser = createParser<{ banner?: string }>({
279
+ name: 'vueParser',
280
+ extNames: ['.vue'],
281
+ async install(fabric, options) {
282
+ // Optional setup
283
+ },
284
+ async parse(file, { extname }) {
285
+ const banner = file.options?.banner ?? ''
286
+ const sources = file.sources.map(s => s.value).join('\n')
287
+ return `${banner}\n${sources}`
288
+ },
289
+ })
290
+
291
+ const fabric = createFabric()
292
+ fabric.use(vueParser)
293
+ fabric.use(fsPlugin); // make it possible to write to the filesystem
294
+
295
+ fabric.write({ extension: { '.vue': '.ts' } })
296
+ ```
297
+
298
+ > [!NOTE]
299
+ > - `fabric.use` accepts both plugins and parsers. The `fsPlugin` handles I/O and adds `fabric.write`. Parsers decide how files are converted to strings for specific extensions.
300
+ > - When extension mapping is provided to `fabric.write`, Fabric picks a parser whose `extNames` include the file’s extension. Otherwise, the default parser is used.
@@ -77,7 +77,7 @@ type BaseName = `${string}.${string}`;
77
77
  type Path = string;
78
78
  type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
79
79
  type OptionalPath = Path | undefined | null;
80
- type File<TMeta$1 extends object = object> = {
80
+ type File<TMeta extends object = object> = {
81
81
  /**
82
82
  * Name to be used to create the path
83
83
  * Based on UNIX basename, `${name}.extname`
@@ -94,13 +94,13 @@ type File<TMeta$1 extends object = object> = {
94
94
  /**
95
95
  * Use extra meta, this is getting used to generate the barrel/index files.
96
96
  */
97
- meta?: TMeta$1;
97
+ meta?: TMeta;
98
98
  banner?: string;
99
99
  footer?: string;
100
100
  };
101
101
  type ResolvedImport = Import;
102
102
  type ResolvedExport = Export;
103
- type ResolvedFile<TMeta$1 extends object = object> = File<TMeta$1> & {
103
+ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
104
104
  /**
105
105
  * @default hash
106
106
  */
@@ -116,7 +116,7 @@ type ResolvedFile<TMeta$1 extends object = object> = File<TMeta$1> & {
116
116
  };
117
117
  //#endregion
118
118
  //#region src/plugins/types.d.ts
119
- type Plugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = {
119
+ type Plugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = {
120
120
  name: string;
121
121
  type: 'plugin';
122
122
  install: Install<TOptions>;
@@ -125,15 +125,15 @@ type Plugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}
125
125
  * Merged into the app instance after install.
126
126
  * This cannot be async
127
127
  */
128
- inject?: Inject<TOptions, TAppExtension$1>;
128
+ inject?: Inject<TOptions, TAppExtension>;
129
129
  };
130
- type UserPlugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension$1>, 'type'>;
130
+ type UserPlugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension>, 'type'>;
131
131
  //#endregion
132
132
  //#region src/parsers/types.d.ts
133
133
  type PrintOptions = {
134
134
  extname?: Extname;
135
135
  };
136
- type Parser<TOptions = unknown, TMeta$1 extends object = any> = {
136
+ type Parser<TOptions = unknown, TMeta extends object = any> = {
137
137
  name: string;
138
138
  type: 'parser';
139
139
  /**
@@ -144,9 +144,9 @@ type Parser<TOptions = unknown, TMeta$1 extends object = any> = {
144
144
  /**
145
145
  * Convert a file to string
146
146
  */
147
- parse(file: ResolvedFile<TMeta$1>, options: PrintOptions): Promise<string>;
147
+ parse(file: ResolvedFile<TMeta>, options: PrintOptions): Promise<string>;
148
148
  };
149
- type UserParser<TOptions = unknown, TMeta$1 extends object = any> = Omit<Parser<TOptions, TMeta$1>, 'type'>;
149
+ type UserParser<TOptions = unknown, TMeta extends object = any> = Omit<Parser<TOptions, TMeta>, 'type'>;
150
150
  //#endregion
151
151
  //#region src/utils/AsyncEventEmitter.d.ts
152
152
  declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
@@ -167,18 +167,18 @@ type ProcessFilesProps = {
167
167
  /**
168
168
  * @default 'sequential'
169
169
  */
170
- mode?: AppMode;
170
+ mode?: FabricMode;
171
171
  };
172
172
  type GetParseOptions = {
173
173
  parsers?: Set<Parser>;
174
174
  extension?: Record<Extname, Extname | ''>;
175
175
  };
176
176
  type Options$1 = {
177
- events?: AsyncEventEmitter<AppEvents>;
177
+ events?: AsyncEventEmitter<FabricEvents>;
178
178
  };
179
179
  declare class FileProcessor {
180
180
  #private;
181
- events: AsyncEventEmitter<AppEvents>;
181
+ events: AsyncEventEmitter<FabricEvents>;
182
182
  constructor({
183
183
  events
184
184
  }?: Options$1);
@@ -196,11 +196,11 @@ declare class FileProcessor {
196
196
  //#endregion
197
197
  //#region src/FileManager.d.ts
198
198
  type Options = {
199
- events?: AsyncEventEmitter<AppEvents>;
199
+ events?: AsyncEventEmitter<FabricEvents>;
200
200
  };
201
201
  declare class FileManager {
202
202
  #private;
203
- events: AsyncEventEmitter<AppEvents>;
203
+ events: AsyncEventEmitter<FabricEvents>;
204
204
  processor: FileProcessor;
205
205
  constructor({
206
206
  events
@@ -214,19 +214,19 @@ declare class FileManager {
214
214
  write(options: ProcessFilesProps): Promise<ResolvedFile[]>;
215
215
  }
216
216
  //#endregion
217
- //#region src/App.d.ts
217
+ //#region src/Fabric.d.ts
218
218
  declare global {
219
219
  namespace Kubb {
220
- interface App {}
220
+ interface Fabric {}
221
221
  }
222
222
  }
223
- type AppOptions = {
223
+ type FabricOptions = {
224
224
  /**
225
225
  * @default 'sequential'
226
226
  */
227
- mode?: AppMode;
227
+ mode?: FabricMode;
228
228
  };
229
- type AppEvents = {
229
+ type FabricEvents = {
230
230
  /**
231
231
  * Called in the beginning of the app lifecycle.
232
232
  */
@@ -239,7 +239,7 @@ type AppEvents = {
239
239
  * Called when being rendered
240
240
  */
241
241
  render: [{
242
- app: App;
242
+ fabric: Fabric;
243
243
  }];
244
244
  /**
245
245
  * Called once before processing any files.
@@ -293,23 +293,23 @@ type AppEvents = {
293
293
  files: ResolvedFile[];
294
294
  }];
295
295
  };
296
- type AppContext<TOptions extends AppOptions> = {
296
+ type FabricContext<TOptions extends FabricOptions> = {
297
297
  options?: TOptions;
298
- events: AsyncEventEmitter<AppEvents>;
298
+ events: AsyncEventEmitter<FabricEvents>;
299
299
  fileManager: FileManager;
300
300
  installedPlugins: Set<Plugin>;
301
301
  installedParsers: Set<Parser>;
302
302
  };
303
- type AppMode = 'sequential' | 'parallel';
303
+ type FabricMode = 'sequential' | 'parallel';
304
304
  type AllOptional<T> = {} extends T ? true : false;
305
- type Install<TOptions = unknown> = TOptions extends any[] ? (app: App, ...options: TOptions) => void | Promise<void> : AllOptional<TOptions> extends true ? (app: App, options: TOptions | undefined) => void | Promise<void> : (app: App, options: TOptions) => void | Promise<void>;
306
- type Inject<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = TOptions extends any[] ? (app: App, ...options: TOptions) => Partial<TAppExtension$1> : AllOptional<TOptions> extends true ? (app: App, options: TOptions | undefined) => Partial<TAppExtension$1> : (app: App, options: TOptions) => Partial<TAppExtension$1>;
307
- interface App<TOptions extends AppOptions = AppOptions> extends Kubb.App {
308
- context: AppContext<TOptions>;
305
+ type Install<TOptions = unknown> = TOptions extends any[] ? (app: Fabric, ...options: TOptions) => void | Promise<void> : AllOptional<TOptions> extends true ? (app: Fabric, options: TOptions | undefined) => void | Promise<void> : (app: Fabric, options: TOptions) => void | Promise<void>;
306
+ type Inject<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = TOptions extends any[] ? (app: Fabric, ...options: TOptions) => Partial<TAppExtension> : AllOptional<TOptions> extends true ? (app: Fabric, options: TOptions | undefined) => Partial<TAppExtension> : (app: Fabric, options: TOptions) => Partial<TAppExtension>;
307
+ interface Fabric<TOptions extends FabricOptions = FabricOptions> extends Kubb.Fabric {
308
+ context: FabricContext<TOptions>;
309
309
  files: Array<ResolvedFile>;
310
310
  use<TPluginOptions = unknown, TMeta extends object = object, TAppExtension extends Record<string, any> = {}>(pluginOrParser: Plugin<TPluginOptions, TAppExtension> | Parser<TPluginOptions, TMeta>, ...options: TPluginOptions extends any[] ? NoInfer<TPluginOptions> : AllOptional<TPluginOptions> extends true ? [NoInfer<TPluginOptions>?] : [NoInfer<TPluginOptions>]): (this & TAppExtension) | Promise<this & TAppExtension>;
311
311
  addFile(...files: Array<File>): Promise<void>;
312
312
  }
313
313
  //#endregion
314
- export { FileProcessor as a, Plugin as c, File as d, KubbFile_d_exports as f, FileManager as i, UserPlugin as l, AppContext as n, Parser as o, ResolvedFile as p, AppOptions as r, UserParser as s, App as t, Extname as u };
315
- //# sourceMappingURL=App-ztRQpZS9.d.ts.map
314
+ export { FileManager as a, UserParser as c, Extname as d, File as f, FabricOptions as i, Plugin as l, ResolvedFile as m, FabricContext as n, FileProcessor as o, KubbFile_d_exports as p, FabricMode as r, Parser as s, Fabric as t, UserPlugin as u };
315
+ //# sourceMappingURL=Fabric-CCPgegwe.d.cts.map
@@ -77,7 +77,7 @@ type BaseName = `${string}.${string}`;
77
77
  type Path = string;
78
78
  type AdvancedPath<T extends BaseName = BaseName> = `${BasePath}${T}`;
79
79
  type OptionalPath = Path | undefined | null;
80
- type File<TMeta$1 extends object = object> = {
80
+ type File<TMeta extends object = object> = {
81
81
  /**
82
82
  * Name to be used to create the path
83
83
  * Based on UNIX basename, `${name}.extname`
@@ -94,13 +94,13 @@ type File<TMeta$1 extends object = object> = {
94
94
  /**
95
95
  * Use extra meta, this is getting used to generate the barrel/index files.
96
96
  */
97
- meta?: TMeta$1;
97
+ meta?: TMeta;
98
98
  banner?: string;
99
99
  footer?: string;
100
100
  };
101
101
  type ResolvedImport = Import;
102
102
  type ResolvedExport = Export;
103
- type ResolvedFile<TMeta$1 extends object = object> = File<TMeta$1> & {
103
+ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
104
104
  /**
105
105
  * @default hash
106
106
  */
@@ -116,7 +116,7 @@ type ResolvedFile<TMeta$1 extends object = object> = File<TMeta$1> & {
116
116
  };
117
117
  //#endregion
118
118
  //#region src/plugins/types.d.ts
119
- type Plugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = {
119
+ type Plugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = {
120
120
  name: string;
121
121
  type: 'plugin';
122
122
  install: Install<TOptions>;
@@ -125,15 +125,15 @@ type Plugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}
125
125
  * Merged into the app instance after install.
126
126
  * This cannot be async
127
127
  */
128
- inject?: Inject<TOptions, TAppExtension$1>;
128
+ inject?: Inject<TOptions, TAppExtension>;
129
129
  };
130
- type UserPlugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension$1>, 'type'>;
130
+ type UserPlugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension>, 'type'>;
131
131
  //#endregion
132
132
  //#region src/parsers/types.d.ts
133
133
  type PrintOptions = {
134
134
  extname?: Extname;
135
135
  };
136
- type Parser<TOptions = unknown, TMeta$1 extends object = any> = {
136
+ type Parser<TOptions = unknown, TMeta extends object = any> = {
137
137
  name: string;
138
138
  type: 'parser';
139
139
  /**
@@ -144,9 +144,9 @@ type Parser<TOptions = unknown, TMeta$1 extends object = any> = {
144
144
  /**
145
145
  * Convert a file to string
146
146
  */
147
- parse(file: ResolvedFile<TMeta$1>, options: PrintOptions): Promise<string>;
147
+ parse(file: ResolvedFile<TMeta>, options: PrintOptions): Promise<string>;
148
148
  };
149
- type UserParser<TOptions = unknown, TMeta$1 extends object = any> = Omit<Parser<TOptions, TMeta$1>, 'type'>;
149
+ type UserParser<TOptions = unknown, TMeta extends object = any> = Omit<Parser<TOptions, TMeta>, 'type'>;
150
150
  //#endregion
151
151
  //#region src/utils/AsyncEventEmitter.d.ts
152
152
  declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
@@ -167,18 +167,18 @@ type ProcessFilesProps = {
167
167
  /**
168
168
  * @default 'sequential'
169
169
  */
170
- mode?: AppMode;
170
+ mode?: FabricMode;
171
171
  };
172
172
  type GetParseOptions = {
173
173
  parsers?: Set<Parser>;
174
174
  extension?: Record<Extname, Extname | ''>;
175
175
  };
176
176
  type Options$1 = {
177
- events?: AsyncEventEmitter<AppEvents>;
177
+ events?: AsyncEventEmitter<FabricEvents>;
178
178
  };
179
179
  declare class FileProcessor {
180
180
  #private;
181
- events: AsyncEventEmitter<AppEvents>;
181
+ events: AsyncEventEmitter<FabricEvents>;
182
182
  constructor({
183
183
  events
184
184
  }?: Options$1);
@@ -196,11 +196,11 @@ declare class FileProcessor {
196
196
  //#endregion
197
197
  //#region src/FileManager.d.ts
198
198
  type Options = {
199
- events?: AsyncEventEmitter<AppEvents>;
199
+ events?: AsyncEventEmitter<FabricEvents>;
200
200
  };
201
201
  declare class FileManager {
202
202
  #private;
203
- events: AsyncEventEmitter<AppEvents>;
203
+ events: AsyncEventEmitter<FabricEvents>;
204
204
  processor: FileProcessor;
205
205
  constructor({
206
206
  events
@@ -214,19 +214,19 @@ declare class FileManager {
214
214
  write(options: ProcessFilesProps): Promise<ResolvedFile[]>;
215
215
  }
216
216
  //#endregion
217
- //#region src/App.d.ts
217
+ //#region src/Fabric.d.ts
218
218
  declare global {
219
219
  namespace Kubb {
220
- interface App {}
220
+ interface Fabric {}
221
221
  }
222
222
  }
223
- type AppOptions = {
223
+ type FabricOptions = {
224
224
  /**
225
225
  * @default 'sequential'
226
226
  */
227
- mode?: AppMode;
227
+ mode?: FabricMode;
228
228
  };
229
- type AppEvents = {
229
+ type FabricEvents = {
230
230
  /**
231
231
  * Called in the beginning of the app lifecycle.
232
232
  */
@@ -239,7 +239,7 @@ type AppEvents = {
239
239
  * Called when being rendered
240
240
  */
241
241
  render: [{
242
- app: App;
242
+ fabric: Fabric;
243
243
  }];
244
244
  /**
245
245
  * Called once before processing any files.
@@ -293,23 +293,23 @@ type AppEvents = {
293
293
  files: ResolvedFile[];
294
294
  }];
295
295
  };
296
- type AppContext<TOptions extends AppOptions> = {
296
+ type FabricContext<TOptions extends FabricOptions> = {
297
297
  options?: TOptions;
298
- events: AsyncEventEmitter<AppEvents>;
298
+ events: AsyncEventEmitter<FabricEvents>;
299
299
  fileManager: FileManager;
300
300
  installedPlugins: Set<Plugin>;
301
301
  installedParsers: Set<Parser>;
302
302
  };
303
- type AppMode = 'sequential' | 'parallel';
303
+ type FabricMode = 'sequential' | 'parallel';
304
304
  type AllOptional<T> = {} extends T ? true : false;
305
- type Install<TOptions = unknown> = TOptions extends any[] ? (app: App, ...options: TOptions) => void | Promise<void> : AllOptional<TOptions> extends true ? (app: App, options: TOptions | undefined) => void | Promise<void> : (app: App, options: TOptions) => void | Promise<void>;
306
- type Inject<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = TOptions extends any[] ? (app: App, ...options: TOptions) => Partial<TAppExtension$1> : AllOptional<TOptions> extends true ? (app: App, options: TOptions | undefined) => Partial<TAppExtension$1> : (app: App, options: TOptions) => Partial<TAppExtension$1>;
307
- interface App<TOptions extends AppOptions = AppOptions> extends Kubb.App {
308
- context: AppContext<TOptions>;
305
+ type Install<TOptions = unknown> = TOptions extends any[] ? (app: Fabric, ...options: TOptions) => void | Promise<void> : AllOptional<TOptions> extends true ? (app: Fabric, options: TOptions | undefined) => void | Promise<void> : (app: Fabric, options: TOptions) => void | Promise<void>;
306
+ type Inject<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = TOptions extends any[] ? (app: Fabric, ...options: TOptions) => Partial<TAppExtension> : AllOptional<TOptions> extends true ? (app: Fabric, options: TOptions | undefined) => Partial<TAppExtension> : (app: Fabric, options: TOptions) => Partial<TAppExtension>;
307
+ interface Fabric<TOptions extends FabricOptions = FabricOptions> extends Kubb.Fabric {
308
+ context: FabricContext<TOptions>;
309
309
  files: Array<ResolvedFile>;
310
310
  use<TPluginOptions = unknown, TMeta extends object = object, TAppExtension extends Record<string, any> = {}>(pluginOrParser: Plugin<TPluginOptions, TAppExtension> | Parser<TPluginOptions, TMeta>, ...options: TPluginOptions extends any[] ? NoInfer<TPluginOptions> : AllOptional<TPluginOptions> extends true ? [NoInfer<TPluginOptions>?] : [NoInfer<TPluginOptions>]): (this & TAppExtension) | Promise<this & TAppExtension>;
311
311
  addFile(...files: Array<File>): Promise<void>;
312
312
  }
313
313
  //#endregion
314
- export { FileProcessor as a, Plugin as c, File as d, KubbFile_d_exports as f, FileManager as i, UserPlugin as l, AppContext as n, Parser as o, ResolvedFile as p, AppOptions as r, UserParser as s, App as t, Extname as u };
315
- //# sourceMappingURL=App-Cjd-lGfW.d.cts.map
314
+ export { FileManager as a, UserParser as c, Extname as d, File as f, FabricOptions as i, Plugin as l, ResolvedFile as m, FabricContext as n, FileProcessor as o, KubbFile_d_exports as p, FabricMode as r, Parser as s, Fabric as t, UserPlugin as u };
315
+ //# sourceMappingURL=Fabric-Cu_YHe4S.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { f as File, i as FabricOptions, m as ResolvedFile, t as Fabric } from "./Fabric-CCPgegwe.cjs";
2
+
3
+ //#region src/defineFabric.d.ts
4
+ type RootRenderFunction<TOptions extends FabricOptions> = (fabric: Fabric<TOptions>) => void | Promise<void>;
5
+ type DefineFabric<TOptions> = (options?: TOptions) => Fabric;
6
+ declare function defineFabric<TOptions extends FabricOptions>(instance?: RootRenderFunction<TOptions>): DefineFabric<TOptions>;
7
+ //#endregion
8
+ //#region src/createFabric.d.ts
9
+ declare const createFabric: DefineFabric<FabricOptions>;
10
+ //#endregion
11
+ //#region src/createFile.d.ts
12
+ /**
13
+ * Helper to create a file with name and id set
14
+ */
15
+ declare function createFile<TMeta extends object = object>(file: File<TMeta>): ResolvedFile<TMeta>;
16
+ //#endregion
17
+ export { defineFabric as i, createFabric as n, DefineFabric as r, createFile as t };
18
+ //# sourceMappingURL=index-BUculP1D.d.cts.map