@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.
- package/README.md +43 -310
- package/dist/{Fabric-yRxItrhk.d.cts → Fabric-AvRgCzm8.d.cts} +32 -7
- package/dist/{Fabric-dUuj_QO6.d.ts → Fabric-Bl1azmsw.d.ts} +32 -7
- package/dist/{Root-Y8o5WxXY.js → Root-Bh8iUdbp.js} +22 -4
- package/dist/{Root-Y8o5WxXY.js.map → Root-Bh8iUdbp.js.map} +1 -1
- package/dist/{Root-DvQofGOy.cjs → Root-DfLpnQ7E.cjs} +22 -4
- package/dist/{Root-DvQofGOy.cjs.map → Root-DfLpnQ7E.cjs.map} +1 -1
- package/dist/{defaultParser-DCYPZf5F.js → defaultParser-BGDkOZaO.js} +2 -2
- package/dist/{defaultParser-DCYPZf5F.js.map → defaultParser-BGDkOZaO.js.map} +1 -1
- package/dist/{defaultParser-2ym3KiZd.cjs → defaultParser-BLkEJRCl.cjs} +2 -2
- package/dist/{defaultParser-2ym3KiZd.cjs.map → defaultParser-BLkEJRCl.cjs.map} +1 -1
- package/dist/{getRelativePath-DlmBsdV8.js → getRelativePath-B46cm-1j.js} +24 -1
- package/dist/getRelativePath-B46cm-1j.js.map +1 -0
- package/dist/{getRelativePath-jYLCpluV.cjs → getRelativePath-d_IC-HuZ.cjs} +24 -1
- package/dist/getRelativePath-d_IC-HuZ.cjs.map +1 -0
- package/dist/index.cjs +218 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +303 -55
- package/dist/index.d.ts +303 -55
- package/dist/index.js +218 -22
- package/dist/index.js.map +1 -1
- package/dist/parsers/typescript.cjs +1 -1
- package/dist/parsers/typescript.d.cts +1 -1
- package/dist/parsers/typescript.d.ts +1 -1
- package/dist/parsers/typescript.js +1 -1
- package/dist/parsers.cjs +3 -3
- package/dist/parsers.d.cts +24 -1
- package/dist/parsers.d.ts +24 -1
- package/dist/parsers.js +3 -3
- package/dist/plugins.cjs +25 -2
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +25 -2
- package/dist/plugins.d.ts +25 -2
- package/dist/plugins.js +25 -2
- package/dist/plugins.js.map +1 -1
- package/dist/{types-_X71gVe5.d.ts → types-CBanr3Jl.d.ts} +3 -3
- package/dist/{types-DHjLDbT5.d.cts → types-DzHuERQS.d.cts} +3 -3
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +3 -3
- package/dist/types.d.ts +3 -3
- package/dist/types.js.map +1 -1
- package/dist/{typescriptParser-D8rhO8nO.js → typescriptParser-DgNVqRUG.js} +2 -2
- package/dist/{typescriptParser-D8rhO8nO.js.map → typescriptParser-DgNVqRUG.js.map} +1 -1
- package/dist/{typescriptParser-3Mjce6yD.cjs → typescriptParser-qas7awdJ.cjs} +2 -2
- package/dist/{typescriptParser-3Mjce6yD.cjs.map → typescriptParser-qas7awdJ.cjs.map} +1 -1
- package/dist/{useNodeTree-vLaKh36n.d.ts → useNodeTree-C4eD1DaF.d.ts} +18 -2
- package/dist/{useNodeTree-CdlPBTwH.d.cts → useNodeTree-DzNHKTXu.d.cts} +18 -2
- package/package.json +3 -3
- package/src/KubbFile.ts +31 -6
- package/src/components/App.ts +17 -3
- package/src/components/Br.ts +11 -0
- package/src/components/Const.ts +21 -6
- package/src/components/Dedent.ts +15 -1
- package/src/components/File.ts +56 -13
- package/src/components/Function.ts +36 -9
- package/src/components/Indent.ts +17 -0
- package/src/components/Root.ts +32 -6
- package/src/components/Type.ts +14 -4
- package/src/composables/useApp.ts +11 -2
- package/src/composables/useFile.ts +14 -3
- package/src/composables/useFileManager.ts +18 -0
- package/src/composables/useLifecycle.ts +15 -3
- package/src/composables/useNodeTree.ts +16 -0
- package/src/createFabric.ts +23 -2
- package/src/parsers/defineParser.ts +23 -0
- package/src/plugins/definePlugin.ts +23 -0
- package/dist/getRelativePath-DlmBsdV8.js.map +0 -1
- package/dist/getRelativePath-jYLCpluV.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<
|
|
3
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
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
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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
|
-
|
|
50
|
+
<!-- markdownlint-restore -->
|
|
51
|
+
<!-- prettier-ignore-end -->
|
|
310
52
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
53
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
54
|
+
<!-- prettier-ignore-start -->
|
|
55
|
+
<!-- markdownlint-disable -->
|
|
314
56
|
|
|
315
|
-
|
|
316
|
-
|
|
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
|
-
|
|
329
|
-
fabric.use(vueParser)
|
|
330
|
-
fabric.use(fsPlugin); // make it possible to write to the filesystem
|
|
60
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
331
61
|
|
|
332
|
-
|
|
333
|
-
```
|
|
62
|
+
## Star History
|
|
334
63
|
|
|
335
|
-
>
|
|
336
|
-
>
|
|
337
|
-
|
|
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
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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-
|
|
515
|
+
//# sourceMappingURL=Fabric-AvRgCzm8.d.cts.map
|
|
@@ -21,9 +21,18 @@ type Import = {
|
|
|
21
21
|
*/
|
|
22
22
|
path: string;
|
|
23
23
|
/**
|
|
24
|
-
* Add
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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-
|
|
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-
|
|
3
|
-
import { t as defaultParser } from "./defaultParser-
|
|
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
|
-
*
|
|
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-
|
|
843
|
+
//# sourceMappingURL=Root-Bh8iUdbp.js.map
|