@kubb/fabric-core 0.12.4 → 0.12.5

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 (68) hide show
  1. package/README.md +43 -310
  2. package/dist/{Fabric-yRxItrhk.d.cts → Fabric-AvRgCzm8.d.cts} +32 -7
  3. package/dist/{Fabric-dUuj_QO6.d.ts → Fabric-Bl1azmsw.d.ts} +32 -7
  4. package/dist/{Root-Y8o5WxXY.js → Root-Bh8iUdbp.js} +22 -4
  5. package/dist/{Root-Y8o5WxXY.js.map → Root-Bh8iUdbp.js.map} +1 -1
  6. package/dist/{Root-DvQofGOy.cjs → Root-DfLpnQ7E.cjs} +22 -4
  7. package/dist/{Root-DvQofGOy.cjs.map → Root-DfLpnQ7E.cjs.map} +1 -1
  8. package/dist/{defaultParser-DCYPZf5F.js → defaultParser-BGDkOZaO.js} +2 -2
  9. package/dist/{defaultParser-DCYPZf5F.js.map → defaultParser-BGDkOZaO.js.map} +1 -1
  10. package/dist/{defaultParser-2ym3KiZd.cjs → defaultParser-BLkEJRCl.cjs} +2 -2
  11. package/dist/{defaultParser-2ym3KiZd.cjs.map → defaultParser-BLkEJRCl.cjs.map} +1 -1
  12. package/dist/{getRelativePath-DlmBsdV8.js → getRelativePath-B46cm-1j.js} +24 -1
  13. package/dist/getRelativePath-B46cm-1j.js.map +1 -0
  14. package/dist/{getRelativePath-jYLCpluV.cjs → getRelativePath-d_IC-HuZ.cjs} +24 -1
  15. package/dist/getRelativePath-d_IC-HuZ.cjs.map +1 -0
  16. package/dist/index.cjs +218 -22
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +303 -55
  19. package/dist/index.d.ts +303 -55
  20. package/dist/index.js +218 -22
  21. package/dist/index.js.map +1 -1
  22. package/dist/parsers/typescript.cjs +1 -1
  23. package/dist/parsers/typescript.d.cts +1 -1
  24. package/dist/parsers/typescript.d.ts +1 -1
  25. package/dist/parsers/typescript.js +1 -1
  26. package/dist/parsers.cjs +3 -3
  27. package/dist/parsers.d.cts +24 -1
  28. package/dist/parsers.d.ts +24 -1
  29. package/dist/parsers.js +3 -3
  30. package/dist/plugins.cjs +25 -2
  31. package/dist/plugins.cjs.map +1 -1
  32. package/dist/plugins.d.cts +25 -2
  33. package/dist/plugins.d.ts +25 -2
  34. package/dist/plugins.js +25 -2
  35. package/dist/plugins.js.map +1 -1
  36. package/dist/{types-_X71gVe5.d.ts → types-CBanr3Jl.d.ts} +3 -3
  37. package/dist/{types-DHjLDbT5.d.cts → types-DzHuERQS.d.cts} +3 -3
  38. package/dist/types.cjs.map +1 -1
  39. package/dist/types.d.cts +3 -3
  40. package/dist/types.d.ts +3 -3
  41. package/dist/types.js.map +1 -1
  42. package/dist/{typescriptParser-D8rhO8nO.js → typescriptParser-DgNVqRUG.js} +2 -2
  43. package/dist/{typescriptParser-D8rhO8nO.js.map → typescriptParser-DgNVqRUG.js.map} +1 -1
  44. package/dist/{typescriptParser-3Mjce6yD.cjs → typescriptParser-qas7awdJ.cjs} +2 -2
  45. package/dist/{typescriptParser-3Mjce6yD.cjs.map → typescriptParser-qas7awdJ.cjs.map} +1 -1
  46. package/dist/{useNodeTree-vLaKh36n.d.ts → useNodeTree-C4eD1DaF.d.ts} +18 -2
  47. package/dist/{useNodeTree-CdlPBTwH.d.cts → useNodeTree-DzNHKTXu.d.cts} +18 -2
  48. package/package.json +3 -3
  49. package/src/KubbFile.ts +31 -6
  50. package/src/components/App.ts +17 -3
  51. package/src/components/Br.ts +11 -0
  52. package/src/components/Const.ts +21 -6
  53. package/src/components/Dedent.ts +15 -1
  54. package/src/components/File.ts +56 -13
  55. package/src/components/Function.ts +36 -9
  56. package/src/components/Indent.ts +17 -0
  57. package/src/components/Root.ts +32 -6
  58. package/src/components/Type.ts +14 -4
  59. package/src/composables/useApp.ts +11 -2
  60. package/src/composables/useFile.ts +14 -3
  61. package/src/composables/useFileManager.ts +18 -0
  62. package/src/composables/useLifecycle.ts +15 -3
  63. package/src/composables/useNodeTree.ts +16 -0
  64. package/src/createFabric.ts +23 -2
  65. package/src/parsers/defineParser.ts +23 -0
  66. package/src/plugins/definePlugin.ts +23 -0
  67. package/dist/getRelativePath-DlmBsdV8.js.map +0 -1
  68. package/dist/getRelativePath-jYLCpluV.cjs.map +0 -1
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  <div align="center">
2
- <h1>Fabric Core</h1>
3
- <a href="https://kubb.dev" target="_blank" rel="noopener noreferrer">
4
- <img width="180" src="https://raw.githubusercontent.com/kubb-labs/fabric/main/assets/logo.png" alt="Kubb fabric logo">
2
+ <a href="https://kubb.dev/fabric" target="_blank" rel="noopener noreferrer">
3
+ <img width="180" src="https://raw.githubusercontent.com/kubb-labs/fabric/main/assets/logo.png" alt="Fabric logo">
5
4
  </a>
6
5
 
7
6
 
@@ -10,331 +9,65 @@
10
9
  [![Coverage][coverage-src]][coverage-href]
11
10
  [![License][license-src]][license-href]
12
11
  [![Sponsors][sponsors-src]][sponsors-href]
13
-
14
12
  <h4>
15
- <a href="https://kubb.dev/" target="_blank">Documentation</a>
16
- <span> · </span>
17
- <a href="https://github.com/kubb-labs/fabric/issues/" target="_blank">Report Bug</a>
18
- <span> · </span>
19
- <a href="https://github.com/kubb-labs/fabric/issues/" target="_blank">Request Feature</a>
13
+ <a href="https://kubb.dev/fabric" target="_blank">Documentation</a>
14
+ <span> · </span>
15
+ <a href="https://github.com/kubb-labs/fabric/issues/" target="_blank">Report Bug</a>
16
+ <span> · </span>
17
+ <a href="https://github.com/kubb-labs/fabric/issues/" target="_blank">Request Feature</a>
20
18
  </h4>
21
19
  </div>
22
20
 
23
21
  <br />
24
22
 
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.
27
-
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.
30
-
31
-
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 } 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
- Creates a file `generated/index.ts` with the following content:
72
- ```ts
73
- export const x = 1
74
- ```
75
-
76
- # API Reference
77
-
78
- ## Core
79
- ### `createFabric(options?): Fabric`
80
- Returns a Fabric instance with:
81
- - `fabric.use(pluginOrParser, ...options) => Fabric` — register plugins and parsers.
82
- - `fabric.addFile(...files)` — queue in-memory files to generate.
83
- - `fabric.files` — getter with all queued files.
84
- - `fabric.context` — internal context holding events, options, FileManager, installed plugins/parsers.
85
-
86
-
87
- ### Events (emitted by the core during processing)
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
- ```
131
-
132
-
133
- ## Plugins
134
- #### `fsPlugin`
135
- Writes files to disk on `file:processing:update`, supports dry runs and cleaning an output folder before writing.
136
-
137
- ```
138
- import { fsPlugin } from '@kubb/fabric-core/plugins'
139
- ```
140
-
141
- | Option | Type | Default | Description |
142
- |---|----------------------------------------------------------------------|---|-----------------------------------------------------------------------|
143
- | dryRun | `boolean` | `false` | If true, do not write files to disk. |
144
- | onBeforeWrite | `(path: string, data: string \| undefined) => void \| Promise<void>` | — | Called right before each file write on `file:processing:update`. |
145
- | clean | `{ path: string }` | — | If provided, removes the directory at `path` before writing any files. |
146
-
147
- Injected `fabric.write` options (via `fsPlugin`):
148
-
149
- | Option | Type | Default | Description |
150
- |---|----------------------------------|---|---|
151
- | extension | `Record<Extname, Extname \| ''>` | — | Maps input file extensions to output extensions. When set, the matching parser (by extNames) is used. |
23
+ ## Features
24
+ - Language-agnostic toolkit for generating code and files using JSX and TypeScript.
25
+ - Works with Node.js 20+ and Bun.
26
+ - Plugin ecosystem with fsPlugin, barrelPlugin, loggerPlugin, graphPlugin, and reactPlugin.
27
+ - Parser system for TypeScript, TSX, and custom file formats.
28
+ - Event-driven architecture for file generation lifecycle.
29
+ - Built-in debugging utilities and progress tracking.
30
+ - And so much more ...
152
31
 
153
- #### `barrelPlugin`
154
- Generates `index.ts` barrel files per folder when `files:writing:start` is triggered. `writeEntry` creates a single entry barrel at `root`.
32
+ ## Supporting Fabric
155
33
 
156
- ```
157
- import { barrelPlugin } from '@kubb/fabric-core/plugins'
158
- ```
34
+ Fabric 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:
159
35
 
160
- | Option | Type | Default | Description |
161
- |---|--------------------------------------------|---|---|
162
- | root | `string` | — | Root directory to generate barrel files for. |
163
- | mode | `'all' \| 'named' \| 'propagate' \| false` | — | Controls how exports are generated: all exports, only named exports, propagate (skip barrels), or disabled. |
164
- | dryRun | `boolean` | `false` | If true, computes barrels but skips writing. |
36
+ - [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
165
37
 
166
- Injected `fabric.writeEntry` parameters (via `barrelPlugin`):
167
-
168
- | Param | Type | Description |
169
- |---|--------------------------------------------|---|
170
- | root | `string` | Root directory where the entry `index.ts` should be created. |
171
- | mode | `'all' \| 'named' \| 'propagate' \| false` | Controls which export style to use for the entry barrel. |
172
-
173
- #### `loggerPlugin`
174
- Streams Fabric lifecycle activity with beautiful @clack/prompts output, progress bars, and websocket messages that you can consume from custom tooling.
175
-
176
- ```
177
- import { loggerPlugin } from '@kubb/fabric-core/plugins'
178
- ```
179
-
180
- | Option | Type | Default | Description |
181
- |---|---|---|---|
182
- | progress | `boolean` | `true` | Enable/disable the integrated CLI progress bar. |
183
- | websocket | `boolean \| { host?: string; port?: number }` | `true` | Toggle or configure the websocket server that broadcasts Fabric events for future GUIs. |
184
-
185
- By default the plugin displays a beautiful progress bar using @clack/prompts, starts a websocket server on an ephemeral port, and announces the URL. Every key lifecycle hook (`start`, `process:*`, `file:*`, `write:*`, `end`) is logged with colored output and symbols, animated in the progress bar, and broadcast to connected clients—perfect for building dashboards on top of Fabric.
186
-
187
-
188
- #### `graphPlugin`
189
- Shows a graph of all files
190
-
191
- ```
192
- import { graphPlugin } from '@kubb/fabric-core/plugins'
193
- ```
194
-
195
- | Option | Type | Default | Description |
196
- |--------|-----------|---------|-----------------------------------------------|
197
- | root | `string` | | Root directory where to start searching from. |
198
- | open | `boolean` | false | Open a webpage with the generated graph |
199
-
200
-
201
- #### `reactPlugin`
202
- Enables rendering React components to the terminal or to a string. Useful for CLI UIs and templating.
203
-
204
- ```
205
- import { reactPlugin } from '@kubb/react-fabric/plugins'
206
- ```
207
-
208
- | Option | Type | Default | Description |
209
- |---|---|---|---|
210
- | stdout | `NodeJS.WriteStream` | — | Optional output stream used to print the rendered content while the app is running. If set, the output is written progressively. |
211
- | stdin | `NodeJS.ReadStream` | — | Optional input stream for interactive components. |
212
- | stderr | `NodeJS.WriteStream` | — | Optional error output stream. |
213
- | debug | `boolean` | — | When true, logs render/unmount information to the console to aid debugging. |
214
-
215
- Injected methods (via `reactPlugin`):
216
-
217
- | Method | Signature | Description |
218
- |---|---|----------------------------------------------------------------------------------------------------|
219
- | `render` | `(App: React.ElementType) => Promise<void> \| void` | Render a React component tree to the terminal and emit the core `start` event. |
220
- | `renderToString` | `(App: React.ElementType) => Promise<string> \| string` | Render a React component tree and return the final output as a string (without writing to stdout). |
221
- | `waitUntilExit` | `() => Promise<void>` | Wait until the rendered app exits, resolves when unmounted and emits the core `end` event. |
222
-
223
- #### `definePlugin`
224
-
225
- Factory to declare a plugin that can be registered via `fabric.use`.
226
-
227
- | Field | Required | Description |
228
- |----------------------------|---|------------------------------------------------------------------------------------------------------------------------------|
229
- | `name` | Yes | String identifier of your plugin. |
230
- | `install(fabric, options)` | Yes | Called when the plugin is registered. You can subscribe to core events and perform side effects here. |
231
- | `inject?(fabric, options)` | No | Return synchronously the runtime methods/properties to merge into `fabric` (e.g. `write`, `render`). This must not be async. |
232
-
233
- Example:
234
-
235
- ```ts
236
- import { createFabric } from '@kubb/fabric-core'
237
- import { definePlugin } from '@kubb/fabric-core/plugins'
238
-
239
- const helloPlugin = definePlugin<{ name?: string }, { sayHello: (msg?: string) => void }>({
240
- name: 'helloPlugin',
241
- install(fabric, options) {
242
- fabric.context.events.on('lifecycle:start', () => {
243
- console.log('Fabric started')
244
- })
245
- },
246
- inject(fabric, options) {
247
- return {
248
- sayHello(msg = options?.name ?? 'world') {
249
- console.log(`Hello ${msg}!`)
250
- },
251
- }
252
- },
253
- })
254
-
255
- const fabric = createFabric()
256
- await fabric.use(helloPlugin, { name: 'Fabric' })
257
- fabric.sayHello() // -> Hello Fabric!
258
- ```
259
-
260
- ## Parsers
261
- #### `typescriptParser`
262
-
263
- Prints TS/JS imports/exports and sources, supports extname mapping for generated import/export paths.
264
-
265
- ```
266
- import { typescriptParser } from '@kubb/fabric-core/parsers'
267
- ```
268
-
269
- | Option | Type | Default | Description |
270
- |---|---|---|---------------------------------------------------------------------------------------------|
271
- | file | `KubbFile.File` | -| File that will be used to be parsed. |
272
- | extname | `string` | `'.ts'` | Extension to use when emitting import/export paths (e.g., rewrite `./file` to `./file.ts`). |
273
-
274
- #### `tsxParser`
275
-
276
- Delegates to `typescriptParser` with TSX printing settings.
277
-
278
- ```
279
- import { tsxParser } from '@kubb/fabric-core/parsers'
280
- ```
281
-
282
- | Option | Type | Default | Description |
283
- |---|---|---|---|
284
- | file | `KubbFile.File` | -| File that will be used to be parsed. |
285
- | extname | `string` | `'.tsx'` | Extension to use when emitting import/export paths for TSX/JSX files. |
286
-
287
- #### `defaultParser`
288
-
289
- Fallback parser used when no extension mapping is provided to `fabric.write`.
290
-
291
- ```
292
- import { defaultParser } @kubb/fabric-core/parsers`
293
- ```
294
-
295
- | Option | Type | Default | Description |
296
- |---|---|---|--------------------------------------------------------------------------|
297
- | file | `KubbFile.File` | -| File that will be used to be parsed. |
38
+ <p align="center">
39
+ <a href="https://github.com/sponsors/stijnvanhulle">
40
+ <img src="https://raw.githubusercontent.com/stijnvanhulle/sponsors/main/sponsors.svg" alt="My sponsors" />
41
+ </a>
42
+ </p>
298
43
 
299
- #### `defineParser`
300
- Factory to declare a parser that can be registered via `fabric.use` and selected by `extNames` during `fabirc.write`.
44
+ ## Contributors [![Contributors][contributors-src]][contributors-href]
301
45
 
302
- | Field | Required | Description |
303
- |----------------------------|---|-----------------------------------------------------------------------------------------------------------------|
304
- | `name` | Yes | String identifier of your parser. |
305
- | `extNames` | Yes | List of file extensions this parser can handle (e.g. ['.ts']). Use `undefined` for the default parser fallback. |
306
- | `install(fabric, options)` | No | Optional setup when the parser is registered (subscribe to events, set state, etc.). |
307
- | `parse(file, { extname })` | Yes | Must return the final string that will be written for the given file. |
46
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
47
+ <!-- prettier-ignore-start -->
48
+ <!-- markdownlint-disable -->
308
49
 
309
- Example:
50
+ <!-- markdownlint-restore -->
51
+ <!-- prettier-ignore-end -->
310
52
 
311
- ```ts
312
- import { createFabric } from '@kubb/fabric-core'
313
- import { defineParser } from '@kubb/fabric-core/parsers'
53
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
54
+ <!-- prettier-ignore-start -->
55
+ <!-- markdownlint-disable -->
314
56
 
315
- const vueParser = defineParser<{ banner?: string }>({
316
- name: 'vueParser',
317
- extNames: ['.vue'],
318
- async install(fabric, options) {
319
- // Optional setup
320
- },
321
- async parse(file, { extname }) {
322
- const banner = file.options?.banner ?? ''
323
- const sources = file.sources.map(s => s.value).join('\n')
324
- return `${banner}\n${sources}`
325
- },
326
- })
57
+ <!-- markdownlint-restore -->
58
+ <!-- prettier-ignore-end -->
327
59
 
328
- const fabric = createFabric()
329
- fabric.use(vueParser)
330
- fabric.use(fsPlugin); // make it possible to write to the filesystem
60
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
331
61
 
332
- fabric.write({ extension: { '.vue': '.ts' } })
333
- ```
62
+ ## Star History
334
63
 
335
- > [!NOTE]
336
- > - `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.
337
- > - 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.
64
+ <a href="https://star-history.com/#kubb-labs/fabric&Date">
65
+ <picture>
66
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=kubb-labs/fabric&type=Date&theme=dark" />
67
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=kubb-labs/fabric&type=Date" />
68
+ <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=kubb-labs/fabric&type=Date" />
69
+ </picture>
70
+ </a>
338
71
 
339
72
 
340
73
  <!-- Badges -->
@@ -18,9 +18,18 @@ type Import = {
18
18
  */
19
19
  path: string;
20
20
  /**
21
- * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
21
+ * Add type-only import prefix.
22
+ * - `true` generates `import type { Type } from './path'`
23
+ * - `false` generates `import { Type } from './path'`
24
+ * @default false
22
25
  */
23
26
  isTypeOnly?: boolean;
27
+ /**
28
+ * Import entire module as namespace.
29
+ * - `true` generates `import * as Name from './path'`
30
+ * - `false` generates standard import
31
+ * @default false
32
+ */
24
33
  isNameSpace?: boolean;
25
34
  /**
26
35
  * When root is set it will get the path with relative getRelativePath(root, path).
@@ -30,14 +39,24 @@ type Import = {
30
39
  type Source = {
31
40
  name?: string;
32
41
  value?: string;
42
+ /**
43
+ * Make this source a type-only export.
44
+ * - `true` marks source as type export
45
+ * - `false` marks source as value export
46
+ * @default false
47
+ */
33
48
  isTypeOnly?: boolean;
34
49
  /**
35
- * Has const or type 'export'
50
+ * Include export keyword in source.
51
+ * - `true` generates exportable const or type
52
+ * - `false` generates internal declaration
36
53
  * @default false
37
54
  */
38
55
  isExportable?: boolean;
39
56
  /**
40
- * When set, barrel generation will add this
57
+ * Include in barrel file generation.
58
+ * - `true` adds to barrel exports
59
+ * - `false` excludes from barrel exports
41
60
  * @default false
42
61
  */
43
62
  isIndexable?: boolean;
@@ -55,18 +74,24 @@ type Export = {
55
74
  */
56
75
  path: string;
57
76
  /**
58
- * Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
77
+ * Add type-only export prefix.
78
+ * - `true` generates `export type { Type } from './path'`
79
+ * - `false` generates `export { Type } from './path'`
80
+ * @default false
59
81
  */
60
82
  isTypeOnly?: boolean;
61
83
  /**
62
- * Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
84
+ * Export as aliased namespace.
85
+ * - `true` generates `export * as aliasName from './path'`
86
+ * - `false` generates standard export
87
+ * @default false
63
88
  */
64
89
  asAlias?: boolean;
65
90
  };
66
91
  type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
67
92
  type Mode = 'single' | 'split';
68
93
  /**
69
- * Name to be used to dynamicly create the baseName(based on input.path)
94
+ * Name to be used to dynamically create the baseName(based on input.path)
70
95
  * Based on UNIX basename
71
96
  * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
72
97
  */
@@ -487,4 +512,4 @@ interface Fabric<T extends FabricOptions = FabricOptions> extends Kubb.Fabric {
487
512
  }
488
513
  //#endregion
489
514
  export { Path as A, UserParser as C, File as D, Extname as E, Source as M, __name as N, Import as O, Parser as S, Export as T, inject as _, FabricElement as a, FileManager as b, FabricOptions as c, renderIndent as d, renderIntrinsic as f, createContext as g, Context as h, FabricContext as i, ResolvedFile as j, KubbFile_d_exports as k, Plugin as l, RenderContextProps as m, FabricComponent as n, FabricMode as o, RenderContext as p, FabricConfig as r, FabricNode as s, Fabric as t, UserPlugin as u, provide as v, BaseName as w, FileProcessor as x, unprovide as y };
490
- //# sourceMappingURL=Fabric-yRxItrhk.d.cts.map
515
+ //# sourceMappingURL=Fabric-AvRgCzm8.d.cts.map
@@ -21,9 +21,18 @@ type Import = {
21
21
  */
22
22
  path: string;
23
23
  /**
24
- * Add `type` prefix to the import, this will result in: `import type { Type } from './path'`.
24
+ * Add type-only import prefix.
25
+ * - `true` generates `import type { Type } from './path'`
26
+ * - `false` generates `import { Type } from './path'`
27
+ * @default false
25
28
  */
26
29
  isTypeOnly?: boolean;
30
+ /**
31
+ * Import entire module as namespace.
32
+ * - `true` generates `import * as Name from './path'`
33
+ * - `false` generates standard import
34
+ * @default false
35
+ */
27
36
  isNameSpace?: boolean;
28
37
  /**
29
38
  * When root is set it will get the path with relative getRelativePath(root, path).
@@ -33,14 +42,24 @@ type Import = {
33
42
  type Source = {
34
43
  name?: string;
35
44
  value?: string;
45
+ /**
46
+ * Make this source a type-only export.
47
+ * - `true` marks source as type export
48
+ * - `false` marks source as value export
49
+ * @default false
50
+ */
36
51
  isTypeOnly?: boolean;
37
52
  /**
38
- * Has const or type 'export'
53
+ * Include export keyword in source.
54
+ * - `true` generates exportable const or type
55
+ * - `false` generates internal declaration
39
56
  * @default false
40
57
  */
41
58
  isExportable?: boolean;
42
59
  /**
43
- * When set, barrel generation will add this
60
+ * Include in barrel file generation.
61
+ * - `true` adds to barrel exports
62
+ * - `false` excludes from barrel exports
44
63
  * @default false
45
64
  */
46
65
  isIndexable?: boolean;
@@ -58,18 +77,24 @@ type Export = {
58
77
  */
59
78
  path: string;
60
79
  /**
61
- * Add `type` prefix to the export, this will result in: `export type { Type } from './path'`.
80
+ * Add type-only export prefix.
81
+ * - `true` generates `export type { Type } from './path'`
82
+ * - `false` generates `export { Type } from './path'`
83
+ * @default false
62
84
  */
63
85
  isTypeOnly?: boolean;
64
86
  /**
65
- * Make it possible to override the name, this will result in: `export * as aliasName from './path'`.
87
+ * Export as aliased namespace.
88
+ * - `true` generates `export * as aliasName from './path'`
89
+ * - `false` generates standard export
90
+ * @default false
66
91
  */
67
92
  asAlias?: boolean;
68
93
  };
69
94
  type Extname = '.ts' | '.js' | '.tsx' | '.json' | `.${string}`;
70
95
  type Mode = 'single' | 'split';
71
96
  /**
72
- * Name to be used to dynamicly create the baseName(based on input.path)
97
+ * Name to be used to dynamically create the baseName(based on input.path)
73
98
  * Based on UNIX basename
74
99
  * @link https://nodejs.org/api/path.html#pathbasenamepath-suffix
75
100
  */
@@ -490,4 +515,4 @@ interface Fabric<T extends FabricOptions = FabricOptions> extends Kubb.Fabric {
490
515
  }
491
516
  //#endregion
492
517
  export { Path as A, UserParser as C, File as D, Extname as E, Source as M, Import as O, Parser as S, Export as T, inject as _, FabricElement as a, FileManager as b, FabricOptions as c, renderIndent as d, renderIntrinsic as f, createContext as g, Context as h, FabricContext as i, ResolvedFile as j, KubbFile_d_exports as k, Plugin as l, RenderContextProps as m, FabricComponent as n, FabricMode as o, RenderContext as p, FabricConfig as r, FabricNode as s, Fabric as t, UserPlugin as u, provide as v, BaseName as w, FileProcessor as x, unprovide as y };
493
- //# sourceMappingURL=Fabric-dUuj_QO6.d.ts.map
518
+ //# sourceMappingURL=Fabric-Bl1azmsw.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { n as __name } from "./chunk-Cq_TCZj9.js";
2
- import { r as trimExtName } from "./getRelativePath-DlmBsdV8.js";
3
- import { t as defaultParser } from "./defaultParser-DCYPZf5F.js";
2
+ import { r as trimExtName } from "./getRelativePath-B46cm-1j.js";
3
+ import { t as defaultParser } from "./defaultParser-BGDkOZaO.js";
4
4
  import { orderBy } from "natural-orderby";
5
5
  import { createHash } from "node:crypto";
6
6
  import path from "node:path";
@@ -802,7 +802,25 @@ function createComponent(type, Component) {
802
802
  //#endregion
803
803
  //#region src/components/Root.ts
804
804
  /**
805
- * This component provides the root behavior for the Fabric runtime.
805
+ * Root component providing core Fabric runtime context.
806
+ *
807
+ * This component is typically used internally by the Fabric renderer.
808
+ * It provides the root context including FileManager, error handling,
809
+ * and lifecycle management.
810
+ *
811
+ * @example
812
+ * ```tsx
813
+ * <Root
814
+ * onExit={(error) => process.exit(error ? 1 : 0)}
815
+ * onError={(error) => console.error(error)}
816
+ * treeNode={treeNode}
817
+ * fileManager={fileManager}
818
+ * >
819
+ * <App>
820
+ * Your components here
821
+ * </App>
822
+ * </Root>
823
+ * ```
806
824
  */
807
825
  const Root = createComponent("Root", ({ onError, onExit, treeNode, fileManager, children }) => {
808
826
  provide(RootContext, {
@@ -822,4 +840,4 @@ Root.displayName = "KubbRoot";
822
840
 
823
841
  //#endregion
824
842
  export { NodeTreeContext as _, renderIntrinsic as a, provide as b, TreeNode as c, _defineProperty as d, AsyncEventEmitter as f, createFile as g, _classPrivateFieldInitSpec as h, renderIndent as i, FileManager as l, _classPrivateFieldGet2 as m, createComponent as n, RenderContext as o, _classPrivateFieldSet2 as p, createIntrinsic as r, RootContext as s, Root as t, FileProcessor as u, createContext as v, unprovide as x, inject as y };
825
- //# sourceMappingURL=Root-Y8o5WxXY.js.map
843
+ //# sourceMappingURL=Root-Bh8iUdbp.js.map