@kubb/react-fabric 0.1.8 → 0.2.1

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 (76) hide show
  1. package/README.md +273 -26
  2. package/dist/{App-D7ehObix.d.ts → Fabric-nxgJyzWH.d.cts} +27 -27
  3. package/dist/{App-CbT7rbmH.d.cts → Fabric-tVWTpMR5.d.ts} +27 -27
  4. package/dist/{KubbFile-D4gyyfL-.d.ts → KubbFile-DFnA3mmn.d.ts} +1 -1
  5. package/dist/{KubbFile-FGXV713i.d.cts → KubbFile-DHCtBOpy.d.cts} +1 -1
  6. package/dist/chunk-CVmoYqME.js +27 -0
  7. package/dist/chunk-DWy1uDak.cjs +39 -0
  8. package/dist/devtools-DPye8o33.js +11448 -0
  9. package/dist/devtools-DPye8o33.js.map +1 -0
  10. package/dist/devtools-DnQsy6Us.cjs +11456 -0
  11. package/dist/devtools-DnQsy6Us.cjs.map +1 -0
  12. package/dist/devtools.cjs +2 -10885
  13. package/dist/devtools.d.cts +11 -1
  14. package/dist/devtools.d.ts +11 -1
  15. package/dist/devtools.js +2 -10885
  16. package/dist/{globals-BRG2DOJd.d.cts → globals-C7dPa-nz.d.cts} +3 -3
  17. package/dist/{globals-D_1Lfe9-.d.ts → globals-CxZEi_Pn.d.ts} +3 -3
  18. package/dist/globals.d.cts +3 -3
  19. package/dist/globals.d.ts +3 -3
  20. package/dist/index.cjs +34 -23
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +16 -9
  23. package/dist/index.d.ts +16 -9
  24. package/dist/index.js +15 -5
  25. package/dist/index.js.map +1 -1
  26. package/dist/jsx-dev-runtime.cjs +8 -0
  27. package/dist/jsx-dev-runtime.js +5 -0
  28. package/dist/jsx-runtime-9ohe6OS2.cjs +36 -0
  29. package/dist/jsx-runtime-9ohe6OS2.cjs.map +1 -0
  30. package/dist/{react-BBkwFtZV.js → jsx-runtime-BOrVcbIT.cjs} +253 -42
  31. package/dist/jsx-runtime-BOrVcbIT.cjs.map +1 -0
  32. package/dist/{react-Bq0UOw6S.cjs → jsx-runtime-CFd_ktZn.js} +239 -57
  33. package/dist/jsx-runtime-CFd_ktZn.js.map +1 -0
  34. package/dist/jsx-runtime-CvGZkcTo.js +13 -0
  35. package/dist/jsx-runtime-CvGZkcTo.js.map +1 -0
  36. package/dist/jsx-runtime.cjs +6 -15
  37. package/dist/jsx-runtime.d.cts +3 -3
  38. package/dist/jsx-runtime.d.ts +3 -3
  39. package/dist/jsx-runtime.js +3 -12
  40. package/dist/parsers.d.cts +2 -2
  41. package/dist/parsers.d.ts +2 -2
  42. package/dist/{Runtime-JI640uK4.cjs → plugins-CEGJdkpj.cjs} +115 -81
  43. package/dist/plugins-CEGJdkpj.cjs.map +1 -0
  44. package/dist/{Runtime-DWlDUeLZ.js → plugins-aZCNhIC8.js} +90 -63
  45. package/dist/plugins-aZCNhIC8.js.map +1 -0
  46. package/dist/plugins.cjs +4 -35
  47. package/dist/plugins.d.cts +16 -49
  48. package/dist/plugins.d.ts +16 -49
  49. package/dist/plugins.js +3 -33
  50. package/dist/reactPlugin-B47Guoya.d.ts +38 -0
  51. package/dist/reactPlugin-CLgWWifj.d.cts +38 -0
  52. package/dist/{types-C3p0Ljxf.d.cts → types-DoYRYV1C.d.cts} +1 -1
  53. package/dist/{types-Brnyan9B.d.ts → types-u_NEi07i.d.ts} +1 -1
  54. package/dist/types.d.cts +1 -1
  55. package/dist/types.d.ts +1 -1
  56. package/package.json +11 -7
  57. package/src/Renderer.ts +26 -22
  58. package/src/Runtime.tsx +8 -7
  59. package/src/createReactFabric.ts +17 -0
  60. package/src/devtools.ts +106 -111
  61. package/src/index.ts +2 -1
  62. package/src/plugins/reactPlugin.ts +4 -3
  63. package/dist/Runtime-DWlDUeLZ.js.map +0 -1
  64. package/dist/Runtime-JI640uK4.cjs.map +0 -1
  65. package/dist/devtools.cjs.map +0 -1
  66. package/dist/devtools.js.map +0 -1
  67. package/dist/jsx-runtime-Dg-pJBHd.js +0 -228
  68. package/dist/jsx-runtime-Dg-pJBHd.js.map +0 -1
  69. package/dist/jsx-runtime-d2dmYscH.cjs +0 -233
  70. package/dist/jsx-runtime-d2dmYscH.cjs.map +0 -1
  71. package/dist/jsx-runtime.cjs.map +0 -1
  72. package/dist/jsx-runtime.js.map +0 -1
  73. package/dist/plugins.cjs.map +0 -1
  74. package/dist/plugins.js.map +0 -1
  75. package/dist/react-BBkwFtZV.js.map +0 -1
  76. package/dist/react-Bq0UOw6S.cjs.map +0 -1
package/README.md CHANGED
@@ -21,32 +21,279 @@
21
21
  </div>
22
22
  <br />
23
23
 
24
- ## Supporting Kubb
24
+ Kubb Fabric is a language-agnostic toolkit for generating code and files using JSX and TypeScript.
25
+ It offers a lightweight layer for file generation while orchestrating the overall process of creating and managing files.
25
26
 
26
- 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:
27
+ > [!WARNING]
28
+ > 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.
27
29
 
28
- - [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
29
30
 
30
- <p align="center">
31
- <a href="https://github.com/sponsors/stijnvanhulle">
32
- <img src="https://raw.githubusercontent.com/stijnvanhulle/sponsors/main/sponsors.svg" alt="My sponsors" />
33
- </a>
34
- </p>
35
-
36
-
37
- <!-- Badges -->
38
-
39
- [npm-version-src]: https://img.shields.io/npm/v/@kubb/react-fabric?flat&colorA=18181B&colorB=f58517
40
- [npm-version-href]: https://npmjs.com/package/@kubb/react-fabric
41
- [npm-downloads-src]: https://img.shields.io/npm/dm/@kubb/react-fabric?flat&colorA=18181B&colorB=f58517
42
- [npm-downloads-href]: https://npmjs.com/package/@kubb/react-fabric
43
- [license-src]: https://img.shields.io/github/license/kubb-labs/kubb.svg?flat&colorA=18181B&colorB=f58517
44
- [license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
45
- [build-src]: https://img.shields.io/github/actions/workflow/status/kubb-labs/kubb/ci.yaml?style=flat&colorA=18181B&colorB=f58517
46
- [build-href]: https://www.npmjs.com/package/@kubb/react-fabric
47
- [minified-src]: https://img.shields.io/bundlephobia/min/@kubb/react-fabric?style=flat&colorA=18181B&colorB=f58517
48
- [minified-href]: https://www.npmjs.com/package/@kubb/react-fabric
49
- [coverage-src]: https://img.shields.io/codecov/c/github/kubb-labs/kubb?style=flat&colorA=18181B&colorB=f58517
50
- [coverage-href]: https://www.npmjs.com/package/@kubb/react-fabric
51
- [sponsors-src]: https://img.shields.io/github/sponsors/stijnvanhulle?style=flat&colorA=18181B&colorB=f58517
52
- [sponsors-href]: https://github.com/sponsors/stijnvanhulle/
31
+ # Features
32
+
33
+ - 🎨 Declarative file generation — Create files effortlessly using JSX or JavaScript syntax.
34
+ - 📦 Cross-runtime support — Works seamlessly with Node.js and Bun.
35
+ - 🧩 Built-in debugging utilities — Simplify development and inspect generation flows with ease.
36
+ - ⚡ Fast and lightweight — Minimal overhead, maximum performance.
37
+
38
+ ## Write a TypeScript file
39
+
40
+ Below is a minimal example showing how `createFabric` works together with plugins and parsers via `fabric.use`.
41
+
42
+ ```ts
43
+ import { createFabric } from '@kubb/fabric-core'
44
+ import { fsPlugin } from '@kubb/fabric-core/plugins'
45
+ import { typescriptParser, createParser } from '@kubb/fabric-core/parsers'
46
+
47
+ const fabric = createFabric()
48
+
49
+ fabric.use(fsPlugin, {
50
+ dryRun: false,
51
+ onBeforeWrite: (path, data) => {
52
+ console.log('About to write:', path)
53
+ },
54
+ clean: { path: './generated' },
55
+ })
56
+
57
+ fabric.use(typescriptParser)
58
+
59
+ await fabric.addFile({
60
+ baseName: 'index.ts',
61
+ path: './generated/index.ts',
62
+ sources: [
63
+ { value: 'export const x = 1', isExportable: true },
64
+ ],
65
+ })
66
+
67
+ await fabric.write()
68
+
69
+ ```
70
+
71
+ # API Reference
72
+
73
+ ## Core
74
+ ### `createFabric(options?): Fabric`
75
+ Returns a Fabric instance with:
76
+ - `fabric.use(pluginOrParser, ...options) => Fabric` — register plugins and parsers.
77
+ - `fabric.addFile(...files)` — queue in-memory files to generate.
78
+ - `fabric.files` — getter with all queued files.
79
+ - `fabric.context` — internal context holding events, options, FileManager, installed plugins/parsers.
80
+
81
+ ### `defineFabric(instance?): () => Fabric`
82
+ Factory to create your own `createFabric` with an optional bootstrap `instance(fabric)` called on creation.
83
+
84
+ ### Events (emitted by the core during processing)
85
+ - `start`
86
+ - `end`
87
+ - `render { fabric }`
88
+ - `file:add { files }`
89
+ - `write:start { files }`
90
+ - `write:end { files }`
91
+ - `file:start { file, index, total }`
92
+ - `file:end { file, index, total }`
93
+ - `process:start { files }`
94
+ - `process:progress { file, source, processed, percentage, total }`
95
+ - `process:end { files }`
96
+
97
+
98
+ ## Plugins
99
+ #### `fsPlugin`
100
+ Writes files to disk on `process:progress`, supports dry runs and cleaning an output folder before writing.
101
+
102
+ ```
103
+ import { fsPlugin } from '@kubb/fabric-core/plugins'
104
+ ```
105
+
106
+ | Option | Type | Default | Description |
107
+ |---|----------------------------------------------------------------------|---|-----------------------------------------------------------------------|
108
+ | dryRun | `boolean` | `false` | If true, do not write files to disk. |
109
+ | onBeforeWrite | `(path: string, data: string \| undefined) => void \| Promise<void>` | — | Called right before each file write on `process:progress`. |
110
+ | clean | `{ path: string }` | — | If provided, removes the directory at `path` before writing any files. |
111
+
112
+ Injected `fabric.write` options (via `fsPlugin`):
113
+
114
+ | Option | Type | Default | Description |
115
+ |---|----------------------------------|---|---|
116
+ | extension | `Record<Extname, Extname \| ''>` | — | Maps input file extensions to output extensions. When set, the matching parser (by extNames) is used. |
117
+
118
+ #### `barrelPlugin`
119
+ Generates `index.ts` barrel files per folder at `process:end`. `writeEntry` creates a single entry barrel at `root`.
120
+
121
+ ```
122
+ import { barrelPlugin } from '@kubb/fabric-core/plugins'
123
+ ```
124
+
125
+ | Option | Type | Default | Description |
126
+ |---|--------------------------------------------|---|---|
127
+ | root | `string` | — | Root directory to generate barrel files for. |
128
+ | mode | `'all' \| 'named' \| 'propagate' \| false` | — | Controls how exports are generated: all exports, only named exports, propagate (skip barrels), or disabled. |
129
+ | dryRun | `boolean` | `false` | If true, computes barrels but skips writing. |
130
+
131
+ Injected `fabric.writeEntry` parameters (via `barrelPlugin`):
132
+
133
+ | Param | Type | Description |
134
+ |---|--------------------------------------------|---|
135
+ | root | `string` | Root directory where the entry `index.ts` should be created. |
136
+ | mode | `'all' \| 'named' \| 'propagate' \| false` | Controls which export style to use for the entry barrel. |
137
+
138
+ #### `progressPlugin`
139
+ Shows a CLI progress bar by listening to core events.
140
+
141
+ ```
142
+ import { progressPlugin } from '@kubb/fabric-core/plugins'
143
+ ```
144
+
145
+ | Option | Type | Default | Description |
146
+ |---|---|---|-----------------------------------------------------------------------------------------|
147
+ | — | — | — | This plugin has no options, it displays a CLI progress bar by listening to core events. |
148
+
149
+
150
+ #### `graphPlugin`
151
+ Shows a graph of all files
152
+
153
+ ```
154
+ import { graphPlugin } from '@kubb/fabric-core/plugins'
155
+ ```
156
+
157
+ | Option | Type | Default | Description |
158
+ |--------|-----------|---------|-----------------------------------------------|
159
+ | root | `string` | | Root directory where to start searching from. |
160
+ | open | `boolean` | false | Open a webpage with the generated graph |
161
+
162
+
163
+ #### `reactPlugin`
164
+ Enables rendering React components to the terminal or to a string. Useful for CLI UIs and templating.
165
+
166
+ ```
167
+ import { reactPlugin } from '@kubb/react-fabric/plugins'
168
+ ```
169
+
170
+ | Option | Type | Default | Description |
171
+ |---|---|---|---|
172
+ | stdout | `NodeJS.WriteStream` | — | Optional output stream used to print the rendered content while the app is running. If set, the output is written progressively. |
173
+ | stdin | `NodeJS.ReadStream` | — | Optional input stream for interactive components. |
174
+ | stderr | `NodeJS.WriteStream` | — | Optional error output stream. |
175
+ | debug | `boolean` | — | When true, logs render/unmount information to the console to aid debugging. |
176
+
177
+ Injected methods (via `reactPlugin`):
178
+
179
+ | Method | Signature | Description |
180
+ |---|---|----------------------------------------------------------------------------------------------------|
181
+ | `render` | `(App: React.ElementType) => Promise<void> \| void` | Render a React component tree to the terminal and emit the core `start` event. |
182
+ | `renderToString` | `(App: React.ElementType) => Promise<string> \| string` | Render a React component tree and return the final output as a string (without writing to stdout). |
183
+ | `waitUntilExit` | `() => Promise<void>` | Wait until the rendered app exits, resolves when unmounted and emits the core `end` event. |
184
+
185
+ #### `createPlugin`
186
+
187
+ Factory to declare a plugin that can be registered via `fabric.use`.
188
+
189
+ | Field | Required | Description |
190
+ |----------------------------|---|------------------------------------------------------------------------------------------------------------------------------|
191
+ | `name` | Yes | String identifier of your plugin. |
192
+ | `install(fabric, options)` | Yes | Called when the plugin is registered. You can subscribe to core events and perform side effects here. |
193
+ | `inject?(fabric, options)` | No | Return synchronously the runtime methods/properties to merge into `fabric` (e.g. `write`, `render`). This must not be async. |
194
+
195
+ Example:
196
+
197
+ ```ts
198
+ import { createFabric } from '@kubb/fabric-core'
199
+ import { createPlugin } from '@kubb/fabric-core/plugins'
200
+
201
+ const helloPlugin = createPlugin<{ name?: string }, { sayHello: (msg?: string) => void }>({
202
+ name: 'helloPlugin',
203
+ install(fabric, options) {
204
+ fabric.context.events.on('start', () => {
205
+ console.log('Fabric started')
206
+ })
207
+ },
208
+ inject(fabric, options) {
209
+ return {
210
+ sayHello(msg = options?.name ?? 'world') {
211
+ console.log(`Hello ${msg}!`)
212
+ },
213
+ }
214
+ },
215
+ })
216
+
217
+ const fabric = createFabric()
218
+ await fabric.use(helloPlugin, { name: 'Fabric' })
219
+ fabric.sayHello() // -> Hello Fabric!
220
+ ```
221
+
222
+ ## Parsers
223
+ #### `typescriptParser`
224
+
225
+ Prints TS/JS imports/exports and sources, supports extname mapping for generated import/export paths.
226
+
227
+ ```
228
+ import { typescriptParser } from '@kubb/fabric-core/parsers'
229
+ ```
230
+
231
+ | Option | Type | Default | Description |
232
+ |---|---|---|---------------------------------------------------------------------------------------------|
233
+ | file | `KubbFile.File` | -| File that will be used to be parsed. |
234
+ | extname | `string` | `'.ts'` | Extension to use when emitting import/export paths (e.g., rewrite `./file` to `./file.ts`). |
235
+
236
+ #### `tsxParser`
237
+
238
+ Delegates to `typescriptParser` with TSX printing settings.
239
+
240
+ ```
241
+ import { tsxParser } from '@kubb/fabric-core/parsers'
242
+ ```
243
+
244
+ | Option | Type | Default | Description |
245
+ |---|---|---|---|
246
+ | file | `KubbFile.File` | -| File that will be used to be parsed. |
247
+ | extname | `string` | `'.tsx'` | Extension to use when emitting import/export paths for TSX/JSX files. |
248
+
249
+ #### `defaultParser`
250
+
251
+ Fallback parser used when no extension mapping is provided to `fabric.write`.
252
+
253
+ ```
254
+ import { defaultParser } @kubb/fabric-core/parsers`
255
+ ```
256
+
257
+ | Option | Type | Default | Description |
258
+ |---|---|---|--------------------------------------------------------------------------|
259
+ | file | `KubbFile.File` | -| File that will be used to be parsed. |
260
+
261
+ #### `createParser`
262
+ Factory to declare a parser that can be registered via `fabric.use` and selected by `extNames` during `fabirc.write`.
263
+
264
+ | Field | Required | Description |
265
+ |----------------------------|---|-----------------------------------------------------------------------------------------------------------------|
266
+ | `name` | Yes | String identifier of your parser. |
267
+ | `extNames` | Yes | List of file extensions this parser can handle (e.g. ['.ts']). Use `undefined` for the default parser fallback. |
268
+ | `install(fabric, options)` | No | Optional setup when the parser is registered (subscribe to events, set state, etc.). |
269
+ | `parse(file, { extname })` | Yes | Must return the final string that will be written for the given file. |
270
+
271
+ Example:
272
+
273
+ ```ts
274
+ import { createFabric } from '@kubb/fabric-core'
275
+ import { createParser } from '@kubb/fabric-core/parsers'
276
+
277
+ const vueParser = createParser<{ banner?: string }>({
278
+ name: 'vueParser',
279
+ extNames: ['.vue'],
280
+ async install(fabric, options) {
281
+ // Optional setup
282
+ },
283
+ async parse(file, { extname }) {
284
+ const banner = file.options?.banner ?? ''
285
+ const sources = file.sources.map(s => s.value).join('\n')
286
+ return `${banner}\n${sources}`
287
+ },
288
+ })
289
+
290
+ const fabric = createFabric()
291
+ fabric.use(vueParser)
292
+ fabric.use(fsPlugin); // make it possible to write to the filesystem
293
+
294
+ fabric.write({ extension: { '.vue': '.ts' } })
295
+ ```
296
+
297
+ > [!NOTE]
298
+ > - `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.
299
+ > - 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.
@@ -1,7 +1,7 @@
1
- import { i as File, o as Path, r as Extname, s as ResolvedFile } from "./KubbFile-D4gyyfL-.js";
1
+ import { i as File, o as Path, r as Extname, s as ResolvedFile } from "./KubbFile-DHCtBOpy.cjs";
2
2
 
3
3
  //#region ../fabric-core/src/plugins/types.d.ts
4
- type Plugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = {
4
+ type Plugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = {
5
5
  name: string;
6
6
  type: 'plugin';
7
7
  install: Install<TOptions>;
@@ -10,15 +10,15 @@ type Plugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}
10
10
  * Merged into the app instance after install.
11
11
  * This cannot be async
12
12
  */
13
- inject?: Inject<TOptions, TAppExtension$1>;
13
+ inject?: Inject<TOptions, TAppExtension>;
14
14
  };
15
- type UserPlugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension$1>, 'type'>;
15
+ type UserPlugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension>, 'type'>;
16
16
  //#endregion
17
17
  //#region ../fabric-core/src/parsers/types.d.ts
18
18
  type PrintOptions = {
19
19
  extname?: Extname;
20
20
  };
21
- type Parser<TOptions = unknown, TMeta$1 extends object = any> = {
21
+ type Parser<TOptions = unknown, TMeta extends object = any> = {
22
22
  name: string;
23
23
  type: 'parser';
24
24
  /**
@@ -29,9 +29,9 @@ type Parser<TOptions = unknown, TMeta$1 extends object = any> = {
29
29
  /**
30
30
  * Convert a file to string
31
31
  */
32
- parse(file: ResolvedFile<TMeta$1>, options: PrintOptions): Promise<string>;
32
+ parse(file: ResolvedFile<TMeta>, options: PrintOptions): Promise<string>;
33
33
  };
34
- type UserParser<TOptions = unknown, TMeta$1 extends object = any> = Omit<Parser<TOptions, TMeta$1>, 'type'>;
34
+ type UserParser<TOptions = unknown, TMeta extends object = any> = Omit<Parser<TOptions, TMeta>, 'type'>;
35
35
  //#endregion
36
36
  //#region ../fabric-core/src/utils/AsyncEventEmitter.d.ts
37
37
  declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
@@ -52,18 +52,18 @@ type ProcessFilesProps = {
52
52
  /**
53
53
  * @default 'sequential'
54
54
  */
55
- mode?: AppMode;
55
+ mode?: FabricMode;
56
56
  };
57
57
  type GetParseOptions = {
58
58
  parsers?: Set<Parser>;
59
59
  extension?: Record<Extname, Extname | ''>;
60
60
  };
61
61
  type Options$1 = {
62
- events?: AsyncEventEmitter<AppEvents>;
62
+ events?: AsyncEventEmitter<FabricEvents>;
63
63
  };
64
64
  declare class FileProcessor {
65
65
  #private;
66
- events: AsyncEventEmitter<AppEvents>;
66
+ events: AsyncEventEmitter<FabricEvents>;
67
67
  constructor({
68
68
  events
69
69
  }?: Options$1);
@@ -81,11 +81,11 @@ declare class FileProcessor {
81
81
  //#endregion
82
82
  //#region ../fabric-core/src/FileManager.d.ts
83
83
  type Options = {
84
- events?: AsyncEventEmitter<AppEvents>;
84
+ events?: AsyncEventEmitter<FabricEvents>;
85
85
  };
86
86
  declare class FileManager {
87
87
  #private;
88
- events: AsyncEventEmitter<AppEvents>;
88
+ events: AsyncEventEmitter<FabricEvents>;
89
89
  processor: FileProcessor;
90
90
  constructor({
91
91
  events
@@ -99,19 +99,19 @@ declare class FileManager {
99
99
  write(options: ProcessFilesProps): Promise<ResolvedFile[]>;
100
100
  }
101
101
  //#endregion
102
- //#region ../fabric-core/src/App.d.ts
102
+ //#region ../fabric-core/src/Fabric.d.ts
103
103
  declare global {
104
104
  namespace Kubb {
105
- interface App {}
105
+ interface Fabric {}
106
106
  }
107
107
  }
108
- type AppOptions = {
108
+ type FabricOptions = {
109
109
  /**
110
110
  * @default 'sequential'
111
111
  */
112
- mode?: AppMode;
112
+ mode?: FabricMode;
113
113
  };
114
- type AppEvents = {
114
+ type FabricEvents = {
115
115
  /**
116
116
  * Called in the beginning of the app lifecycle.
117
117
  */
@@ -124,7 +124,7 @@ type AppEvents = {
124
124
  * Called when being rendered
125
125
  */
126
126
  render: [{
127
- app: App;
127
+ fabric: Fabric;
128
128
  }];
129
129
  /**
130
130
  * Called once before processing any files.
@@ -178,23 +178,23 @@ type AppEvents = {
178
178
  files: ResolvedFile[];
179
179
  }];
180
180
  };
181
- type AppContext<TOptions extends AppOptions> = {
181
+ type FabricContext<TOptions extends FabricOptions> = {
182
182
  options?: TOptions;
183
- events: AsyncEventEmitter<AppEvents>;
183
+ events: AsyncEventEmitter<FabricEvents>;
184
184
  fileManager: FileManager;
185
185
  installedPlugins: Set<Plugin>;
186
186
  installedParsers: Set<Parser>;
187
187
  };
188
- type AppMode = 'sequential' | 'parallel';
188
+ type FabricMode = 'sequential' | 'parallel';
189
189
  type AllOptional<T> = {} extends T ? true : false;
190
- 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>;
191
- 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>;
192
- interface App<TOptions extends AppOptions = AppOptions> extends Kubb.App {
193
- context: AppContext<TOptions>;
190
+ 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>;
191
+ 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>;
192
+ interface Fabric<TOptions extends FabricOptions = FabricOptions> extends Kubb.Fabric {
193
+ context: FabricContext<TOptions>;
194
194
  files: Array<ResolvedFile>;
195
195
  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>;
196
196
  addFile(...files: Array<File>): Promise<void>;
197
197
  }
198
198
  //#endregion
199
- export { UserParser as a, Parser as i, AppOptions as n, Plugin as o, FileManager as r, UserPlugin as s, App as t };
200
- //# sourceMappingURL=App-D7ehObix.d.ts.map
199
+ export { Parser as a, UserPlugin as c, FileManager as i, FabricMode as n, UserParser as o, FabricOptions as r, Plugin as s, Fabric as t };
200
+ //# sourceMappingURL=Fabric-nxgJyzWH.d.cts.map
@@ -1,7 +1,7 @@
1
- import { i as File, o as Path, r as Extname, s as ResolvedFile } from "./KubbFile-FGXV713i.cjs";
1
+ import { i as File, o as Path, r as Extname, s as ResolvedFile } from "./KubbFile-DFnA3mmn.js";
2
2
 
3
3
  //#region ../fabric-core/src/plugins/types.d.ts
4
- type Plugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = {
4
+ type Plugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = {
5
5
  name: string;
6
6
  type: 'plugin';
7
7
  install: Install<TOptions>;
@@ -10,15 +10,15 @@ type Plugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}
10
10
  * Merged into the app instance after install.
11
11
  * This cannot be async
12
12
  */
13
- inject?: Inject<TOptions, TAppExtension$1>;
13
+ inject?: Inject<TOptions, TAppExtension>;
14
14
  };
15
- type UserPlugin<TOptions = unknown, TAppExtension$1 extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension$1>, 'type'>;
15
+ type UserPlugin<TOptions = unknown, TAppExtension extends Record<string, any> = {}> = Omit<Plugin<TOptions, TAppExtension>, 'type'>;
16
16
  //#endregion
17
17
  //#region ../fabric-core/src/parsers/types.d.ts
18
18
  type PrintOptions = {
19
19
  extname?: Extname;
20
20
  };
21
- type Parser<TOptions = unknown, TMeta$1 extends object = any> = {
21
+ type Parser<TOptions = unknown, TMeta extends object = any> = {
22
22
  name: string;
23
23
  type: 'parser';
24
24
  /**
@@ -29,9 +29,9 @@ type Parser<TOptions = unknown, TMeta$1 extends object = any> = {
29
29
  /**
30
30
  * Convert a file to string
31
31
  */
32
- parse(file: ResolvedFile<TMeta$1>, options: PrintOptions): Promise<string>;
32
+ parse(file: ResolvedFile<TMeta>, options: PrintOptions): Promise<string>;
33
33
  };
34
- type UserParser<TOptions = unknown, TMeta$1 extends object = any> = Omit<Parser<TOptions, TMeta$1>, 'type'>;
34
+ type UserParser<TOptions = unknown, TMeta extends object = any> = Omit<Parser<TOptions, TMeta>, 'type'>;
35
35
  //#endregion
36
36
  //#region ../fabric-core/src/utils/AsyncEventEmitter.d.ts
37
37
  declare class AsyncEventEmitter<TEvents extends Record<string, any>> {
@@ -52,18 +52,18 @@ type ProcessFilesProps = {
52
52
  /**
53
53
  * @default 'sequential'
54
54
  */
55
- mode?: AppMode;
55
+ mode?: FabricMode;
56
56
  };
57
57
  type GetParseOptions = {
58
58
  parsers?: Set<Parser>;
59
59
  extension?: Record<Extname, Extname | ''>;
60
60
  };
61
61
  type Options$1 = {
62
- events?: AsyncEventEmitter<AppEvents>;
62
+ events?: AsyncEventEmitter<FabricEvents>;
63
63
  };
64
64
  declare class FileProcessor {
65
65
  #private;
66
- events: AsyncEventEmitter<AppEvents>;
66
+ events: AsyncEventEmitter<FabricEvents>;
67
67
  constructor({
68
68
  events
69
69
  }?: Options$1);
@@ -81,11 +81,11 @@ declare class FileProcessor {
81
81
  //#endregion
82
82
  //#region ../fabric-core/src/FileManager.d.ts
83
83
  type Options = {
84
- events?: AsyncEventEmitter<AppEvents>;
84
+ events?: AsyncEventEmitter<FabricEvents>;
85
85
  };
86
86
  declare class FileManager {
87
87
  #private;
88
- events: AsyncEventEmitter<AppEvents>;
88
+ events: AsyncEventEmitter<FabricEvents>;
89
89
  processor: FileProcessor;
90
90
  constructor({
91
91
  events
@@ -99,19 +99,19 @@ declare class FileManager {
99
99
  write(options: ProcessFilesProps): Promise<ResolvedFile[]>;
100
100
  }
101
101
  //#endregion
102
- //#region ../fabric-core/src/App.d.ts
102
+ //#region ../fabric-core/src/Fabric.d.ts
103
103
  declare global {
104
104
  namespace Kubb {
105
- interface App {}
105
+ interface Fabric {}
106
106
  }
107
107
  }
108
- type AppOptions = {
108
+ type FabricOptions = {
109
109
  /**
110
110
  * @default 'sequential'
111
111
  */
112
- mode?: AppMode;
112
+ mode?: FabricMode;
113
113
  };
114
- type AppEvents = {
114
+ type FabricEvents = {
115
115
  /**
116
116
  * Called in the beginning of the app lifecycle.
117
117
  */
@@ -124,7 +124,7 @@ type AppEvents = {
124
124
  * Called when being rendered
125
125
  */
126
126
  render: [{
127
- app: App;
127
+ fabric: Fabric;
128
128
  }];
129
129
  /**
130
130
  * Called once before processing any files.
@@ -178,23 +178,23 @@ type AppEvents = {
178
178
  files: ResolvedFile[];
179
179
  }];
180
180
  };
181
- type AppContext<TOptions extends AppOptions> = {
181
+ type FabricContext<TOptions extends FabricOptions> = {
182
182
  options?: TOptions;
183
- events: AsyncEventEmitter<AppEvents>;
183
+ events: AsyncEventEmitter<FabricEvents>;
184
184
  fileManager: FileManager;
185
185
  installedPlugins: Set<Plugin>;
186
186
  installedParsers: Set<Parser>;
187
187
  };
188
- type AppMode = 'sequential' | 'parallel';
188
+ type FabricMode = 'sequential' | 'parallel';
189
189
  type AllOptional<T> = {} extends T ? true : false;
190
- 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>;
191
- 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>;
192
- interface App<TOptions extends AppOptions = AppOptions> extends Kubb.App {
193
- context: AppContext<TOptions>;
190
+ 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>;
191
+ 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>;
192
+ interface Fabric<TOptions extends FabricOptions = FabricOptions> extends Kubb.Fabric {
193
+ context: FabricContext<TOptions>;
194
194
  files: Array<ResolvedFile>;
195
195
  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>;
196
196
  addFile(...files: Array<File>): Promise<void>;
197
197
  }
198
198
  //#endregion
199
- export { UserParser as a, Parser as i, AppOptions as n, Plugin as o, FileManager as r, UserPlugin as s, App as t };
200
- //# sourceMappingURL=App-CbT7rbmH.d.cts.map
199
+ export { Parser as a, UserPlugin as c, FileManager as i, FabricMode as n, UserParser as o, FabricOptions as r, Plugin as s, Fabric as t };
200
+ //# sourceMappingURL=Fabric-tVWTpMR5.d.ts.map
@@ -112,4 +112,4 @@ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
112
112
  };
113
113
  //#endregion
114
114
  export { Import as a, Source as c, File as i, Export as n, Path as o, Extname as r, ResolvedFile as s, BaseName as t };
115
- //# sourceMappingURL=KubbFile-D4gyyfL-.d.ts.map
115
+ //# sourceMappingURL=KubbFile-DFnA3mmn.d.ts.map
@@ -112,4 +112,4 @@ type ResolvedFile<TMeta extends object = object> = File<TMeta> & {
112
112
  };
113
113
  //#endregion
114
114
  export { Import as a, Source as c, File as i, Export as n, Path as o, Extname as r, ResolvedFile as s, BaseName as t };
115
- //# sourceMappingURL=KubbFile-FGXV713i.d.cts.map
115
+ //# sourceMappingURL=KubbFile-DHCtBOpy.d.cts.map
@@ -0,0 +1,27 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
13
+ key = keys[i];
14
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
22
+ value: mod,
23
+ enumerable: true
24
+ }) : target, mod));
25
+
26
+ //#endregion
27
+ export { __toESM as n, __commonJS as t };