@kubb/fabric-core 0.2.14 → 0.2.16
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 +5 -1
- package/dist/{Fabric-BfnUdEpq.d.cts → Fabric-AmREkq58.d.ts} +108 -63
- package/dist/{Fabric-CxMkO4Rt.d.ts → Fabric-CBrTERuf.d.cts} +108 -63
- package/dist/{defineProperty-CspRhtP3.cjs → defineProperty-Dlhh3lSJ.cjs} +58 -44
- package/dist/defineProperty-Dlhh3lSJ.cjs.map +1 -0
- package/dist/{defineProperty-BtekiGIK.js → defineProperty-_FBdEen_.js} +53 -39
- package/dist/defineProperty-_FBdEen_.js.map +1 -0
- package/dist/index.cjs +102 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -3
- package/dist/index.d.ts +25 -3
- package/dist/index.js +102 -60
- package/dist/index.js.map +1 -1
- package/dist/parsers/typescript.d.cts +2 -2
- package/dist/parsers/typescript.d.ts +2 -2
- package/dist/parsers.cjs.map +1 -1
- package/dist/parsers.d.cts +2 -2
- package/dist/parsers.d.ts +2 -2
- package/dist/parsers.js.map +1 -1
- package/dist/plugins.cjs +98 -104
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +30 -40
- package/dist/plugins.d.ts +30 -40
- package/dist/plugins.js +94 -100
- package/dist/plugins.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +2 -3
- package/dist/types.d.ts +2 -3
- package/dist/types.js.map +1 -1
- package/dist/{typescriptParser-Dz9T1BQ1.d.cts → typescriptParser-C3B3dzh_.d.cts} +2 -2
- package/dist/typescriptParser-CNHO6H2_.cjs.map +1 -1
- package/dist/typescriptParser-CWT7zCJy.js.map +1 -1
- package/dist/{typescriptParser-DypTa1AN.d.ts → typescriptParser-DaOfAlmM.d.ts} +2 -2
- package/package.json +1 -1
- package/src/Fabric.ts +102 -52
- package/src/FileManager.ts +23 -6
- package/src/FileProcessor.ts +3 -4
- package/src/KubbFile.ts +0 -2
- package/src/createFile.ts +90 -74
- package/src/defineFabric.ts +53 -28
- package/src/index.ts +3 -3
- package/src/parsers/tsxParser.ts +1 -1
- package/src/parsers/types.ts +1 -1
- package/src/parsers/typescriptParser.ts +1 -1
- package/src/plugins/barrelPlugin.ts +13 -21
- package/src/plugins/fsPlugin.ts +8 -16
- package/src/plugins/graphPlugin.ts +8 -9
- package/src/plugins/index.ts +2 -3
- package/src/plugins/progressPlugin.ts +6 -6
- package/src/plugins/types.ts +1 -1
- package/src/types.ts +1 -2
- package/src/utils/AsyncEventEmitter.ts +29 -8
- package/dist/defineFabric-CR1OjcoI.d.ts +0 -9
- package/dist/defineFabric-TvKfRefj.d.cts +0 -9
- package/dist/defineProperty-BtekiGIK.js.map +0 -1
- package/dist/defineProperty-CspRhtP3.cjs.map +0 -1
- package/src/utils/EventEmitter.ts +0 -31
package/dist/plugins.cjs
CHANGED
|
@@ -1,84 +1,21 @@
|
|
|
1
1
|
const require_trimExtName = require('./trimExtName-Bb4zGVF1.cjs');
|
|
2
|
-
const require_defineProperty = require('./defineProperty-
|
|
2
|
+
const require_defineProperty = require('./defineProperty-Dlhh3lSJ.cjs');
|
|
3
3
|
const require_getRelativePath = require('./getRelativePath-C6lvNCs7.cjs');
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_trimExtName.__toESM(node_path);
|
|
6
6
|
let fs_extra = require("fs-extra");
|
|
7
7
|
fs_extra = require_trimExtName.__toESM(fs_extra);
|
|
8
|
-
let cli_progress = require("cli-progress");
|
|
9
|
-
cli_progress = require_trimExtName.__toESM(cli_progress);
|
|
10
|
-
let node_process = require("node:process");
|
|
11
|
-
node_process = require_trimExtName.__toESM(node_process);
|
|
12
8
|
let node_http = require("node:http");
|
|
13
9
|
node_http = require_trimExtName.__toESM(node_http);
|
|
14
10
|
let serve_handler = require("serve-handler");
|
|
15
11
|
serve_handler = require_trimExtName.__toESM(serve_handler);
|
|
16
12
|
let node_child_process = require("node:child_process");
|
|
17
13
|
node_child_process = require_trimExtName.__toESM(node_child_process);
|
|
14
|
+
let node_process = require("node:process");
|
|
15
|
+
node_process = require_trimExtName.__toESM(node_process);
|
|
16
|
+
let cli_progress = require("cli-progress");
|
|
17
|
+
cli_progress = require_trimExtName.__toESM(cli_progress);
|
|
18
18
|
|
|
19
|
-
//#region src/plugins/createPlugin.ts
|
|
20
|
-
function createPlugin(plugin) {
|
|
21
|
-
return {
|
|
22
|
-
type: "plugin",
|
|
23
|
-
...plugin
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/plugins/fsPlugin.ts
|
|
29
|
-
async function write(path$2, data, options = {}) {
|
|
30
|
-
if (typeof Bun !== "undefined") {
|
|
31
|
-
if (!data || (data === null || data === void 0 ? void 0 : data.trim()) === "") return;
|
|
32
|
-
await Bun.write((0, node_path.resolve)(path$2), data.trim());
|
|
33
|
-
if (options === null || options === void 0 ? void 0 : options.sanity) {
|
|
34
|
-
const savedData = await Bun.file((0, node_path.resolve)(path$2)).text();
|
|
35
|
-
if ((savedData === null || savedData === void 0 ? void 0 : savedData.toString()) !== (data === null || data === void 0 ? void 0 : data.toString())) throw new Error(`Sanity check failed for ${path$2}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
36
|
-
return savedData;
|
|
37
|
-
}
|
|
38
|
-
return data;
|
|
39
|
-
}
|
|
40
|
-
if (!data || (data === null || data === void 0 ? void 0 : data.trim()) === "") return;
|
|
41
|
-
try {
|
|
42
|
-
const oldContent = await fs_extra.default.readFile((0, node_path.resolve)(path$2), { encoding: "utf-8" });
|
|
43
|
-
if ((oldContent === null || oldContent === void 0 ? void 0 : oldContent.toString()) === (data === null || data === void 0 ? void 0 : data.toString())) return;
|
|
44
|
-
} catch (_err) {}
|
|
45
|
-
await fs_extra.default.outputFile((0, node_path.resolve)(path$2), data.trim(), { encoding: "utf-8" });
|
|
46
|
-
if (options === null || options === void 0 ? void 0 : options.sanity) {
|
|
47
|
-
const savedData = await fs_extra.default.readFile((0, node_path.resolve)(path$2), { encoding: "utf-8" });
|
|
48
|
-
if ((savedData === null || savedData === void 0 ? void 0 : savedData.toString()) !== (data === null || data === void 0 ? void 0 : data.toString())) throw new Error(`Sanity check failed for ${path$2}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
49
|
-
return savedData;
|
|
50
|
-
}
|
|
51
|
-
return data;
|
|
52
|
-
}
|
|
53
|
-
const fsPlugin = createPlugin({
|
|
54
|
-
name: "fs",
|
|
55
|
-
install(app, options = {}) {
|
|
56
|
-
if (options.clean) fs_extra.default.removeSync(options.clean.path);
|
|
57
|
-
app.context.events.on("process:progress", async ({ file, source }) => {
|
|
58
|
-
if (options.onBeforeWrite) await options.onBeforeWrite(file.path, source);
|
|
59
|
-
await write(file.path, source, { sanity: false });
|
|
60
|
-
});
|
|
61
|
-
},
|
|
62
|
-
inject(app, { dryRun } = {}) {
|
|
63
|
-
return { async write(options = { extension: { ".ts": ".ts" } }) {
|
|
64
|
-
var _app$context$config;
|
|
65
|
-
await app.context.fileManager.write({
|
|
66
|
-
mode: (_app$context$config = app.context.config) === null || _app$context$config === void 0 || (_app$context$config = _app$context$config.options) === null || _app$context$config === void 0 ? void 0 : _app$context$config.mode,
|
|
67
|
-
extension: options.extension,
|
|
68
|
-
dryRun,
|
|
69
|
-
parsers: app.context.installedParsers
|
|
70
|
-
});
|
|
71
|
-
} };
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
//#endregion
|
|
76
|
-
//#region \0@oxc-project+runtime@0.95.0/helpers/classPrivateFieldSet2.js
|
|
77
|
-
function _classPrivateFieldSet2(s, a, r) {
|
|
78
|
-
return s.set(require_defineProperty._assertClassBrand(s, a), r), r;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
//#endregion
|
|
82
19
|
//#region src/utils/TreeNode.ts
|
|
83
20
|
var _cachedLeaves = /* @__PURE__ */ new WeakMap();
|
|
84
21
|
var TreeNode = class TreeNode {
|
|
@@ -93,7 +30,7 @@ var TreeNode = class TreeNode {
|
|
|
93
30
|
addChild(data) {
|
|
94
31
|
const child = new TreeNode(data, this);
|
|
95
32
|
this.children.push(child);
|
|
96
|
-
_classPrivateFieldSet2(_cachedLeaves, this, void 0);
|
|
33
|
+
require_defineProperty._classPrivateFieldSet2(_cachedLeaves, this, void 0);
|
|
97
34
|
return child;
|
|
98
35
|
}
|
|
99
36
|
get leaves() {
|
|
@@ -103,7 +40,7 @@ var TreeNode = class TreeNode {
|
|
|
103
40
|
const result = [];
|
|
104
41
|
for (const node of stack) if (node.children.length) for (const child of node.children) stack.push(child);
|
|
105
42
|
else result.push(node);
|
|
106
|
-
_classPrivateFieldSet2(_cachedLeaves, this, result);
|
|
43
|
+
require_defineProperty._classPrivateFieldSet2(_cachedLeaves, this, result);
|
|
107
44
|
return result;
|
|
108
45
|
}
|
|
109
46
|
forEach(callback) {
|
|
@@ -173,6 +110,15 @@ var TreeNode = class TreeNode {
|
|
|
173
110
|
}
|
|
174
111
|
};
|
|
175
112
|
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region src/plugins/createPlugin.ts
|
|
115
|
+
function createPlugin(plugin) {
|
|
116
|
+
return {
|
|
117
|
+
type: "plugin",
|
|
118
|
+
...plugin
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
176
122
|
//#endregion
|
|
177
123
|
//#region src/plugins/barrelPlugin.ts
|
|
178
124
|
function getBarrelFiles({ files, root, mode }) {
|
|
@@ -236,29 +182,29 @@ function getBarrelFiles({ files, root, mode }) {
|
|
|
236
182
|
}
|
|
237
183
|
const barrelPlugin = createPlugin({
|
|
238
184
|
name: "barrel",
|
|
239
|
-
install(
|
|
185
|
+
install(ctx, options) {
|
|
240
186
|
if (!options) throw new Error("Barrel plugin requires options.root and options.mode");
|
|
241
187
|
if (!options.mode) return;
|
|
242
|
-
|
|
188
|
+
ctx.on("write:start", async ({ files }) => {
|
|
243
189
|
const root = options.root;
|
|
244
190
|
const barrelFiles = getBarrelFiles({
|
|
245
191
|
files,
|
|
246
192
|
root,
|
|
247
193
|
mode: options.mode
|
|
248
194
|
});
|
|
249
|
-
await
|
|
195
|
+
await ctx.fileManager.add(...barrelFiles);
|
|
250
196
|
});
|
|
251
197
|
},
|
|
252
|
-
inject(
|
|
198
|
+
inject(ctx, options) {
|
|
253
199
|
if (!options) throw new Error("Barrel plugin requires options.root and options.mode");
|
|
254
200
|
return { async writeEntry({ root, mode }) {
|
|
255
|
-
var
|
|
201
|
+
var _ctx$config;
|
|
256
202
|
if (!mode || mode === "propagate") return;
|
|
257
203
|
const rootPath = node_path.default.resolve(root, "index.ts");
|
|
258
204
|
const entryFile = require_defineProperty.createFile({
|
|
259
205
|
path: rootPath,
|
|
260
206
|
baseName: "index.ts",
|
|
261
|
-
exports:
|
|
207
|
+
exports: ctx.files.filter((file) => {
|
|
262
208
|
return file.sources.some((source) => source.isIndexable);
|
|
263
209
|
}).flatMap((file) => {
|
|
264
210
|
var _file$sources;
|
|
@@ -274,39 +220,61 @@ const barrelPlugin = createPlugin({
|
|
|
274
220
|
}).filter(Boolean),
|
|
275
221
|
sources: []
|
|
276
222
|
});
|
|
277
|
-
await
|
|
278
|
-
await
|
|
279
|
-
mode: (
|
|
223
|
+
await ctx.addFile(entryFile);
|
|
224
|
+
await ctx.fileManager.write({
|
|
225
|
+
mode: (_ctx$config = ctx.config) === null || _ctx$config === void 0 || (_ctx$config = _ctx$config.options) === null || _ctx$config === void 0 ? void 0 : _ctx$config.mode,
|
|
280
226
|
dryRun: options.dryRun,
|
|
281
|
-
parsers:
|
|
227
|
+
parsers: ctx.installedParsers
|
|
282
228
|
});
|
|
283
229
|
} };
|
|
284
230
|
}
|
|
285
231
|
});
|
|
286
232
|
|
|
287
233
|
//#endregion
|
|
288
|
-
//#region src/plugins/
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
234
|
+
//#region src/plugins/fsPlugin.ts
|
|
235
|
+
async function write(path$2, data, options = {}) {
|
|
236
|
+
if (typeof Bun !== "undefined") {
|
|
237
|
+
if (!data || (data === null || data === void 0 ? void 0 : data.trim()) === "") return;
|
|
238
|
+
await Bun.write((0, node_path.resolve)(path$2), data.trim());
|
|
239
|
+
if (options === null || options === void 0 ? void 0 : options.sanity) {
|
|
240
|
+
const savedData = await Bun.file((0, node_path.resolve)(path$2)).text();
|
|
241
|
+
if ((savedData === null || savedData === void 0 ? void 0 : savedData.toString()) !== (data === null || data === void 0 ? void 0 : data.toString())) throw new Error(`Sanity check failed for ${path$2}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
242
|
+
return savedData;
|
|
243
|
+
}
|
|
244
|
+
return data;
|
|
245
|
+
}
|
|
246
|
+
if (!data || (data === null || data === void 0 ? void 0 : data.trim()) === "") return;
|
|
247
|
+
try {
|
|
248
|
+
const oldContent = await fs_extra.default.readFile((0, node_path.resolve)(path$2), { encoding: "utf-8" });
|
|
249
|
+
if ((oldContent === null || oldContent === void 0 ? void 0 : oldContent.toString()) === (data === null || data === void 0 ? void 0 : data.toString())) return;
|
|
250
|
+
} catch (_err) {}
|
|
251
|
+
await fs_extra.default.outputFile((0, node_path.resolve)(path$2), data.trim(), { encoding: "utf-8" });
|
|
252
|
+
if (options === null || options === void 0 ? void 0 : options.sanity) {
|
|
253
|
+
const savedData = await fs_extra.default.readFile((0, node_path.resolve)(path$2), { encoding: "utf-8" });
|
|
254
|
+
if ((savedData === null || savedData === void 0 ? void 0 : savedData.toString()) !== (data === null || data === void 0 ? void 0 : data.toString())) throw new Error(`Sanity check failed for ${path$2}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
255
|
+
return savedData;
|
|
256
|
+
}
|
|
257
|
+
return data;
|
|
258
|
+
}
|
|
259
|
+
const fsPlugin = createPlugin({
|
|
260
|
+
name: "fs",
|
|
261
|
+
install(ctx, options = {}) {
|
|
262
|
+
if (options.clean) fs_extra.default.removeSync(options.clean.path);
|
|
263
|
+
ctx.on("process:progress", async ({ file, source }) => {
|
|
264
|
+
if (options.onBeforeWrite) await options.onBeforeWrite(file.path, source);
|
|
265
|
+
await write(file.path, source, { sanity: false });
|
|
309
266
|
});
|
|
267
|
+
},
|
|
268
|
+
inject(ctx, { dryRun } = {}) {
|
|
269
|
+
return { async write(options = { extension: { ".ts": ".ts" } }) {
|
|
270
|
+
var _ctx$config;
|
|
271
|
+
await ctx.fileManager.write({
|
|
272
|
+
mode: (_ctx$config = ctx.config) === null || _ctx$config === void 0 || (_ctx$config = _ctx$config.options) === null || _ctx$config === void 0 ? void 0 : _ctx$config.mode,
|
|
273
|
+
extension: options.extension,
|
|
274
|
+
dryRun,
|
|
275
|
+
parsers: ctx.installedParsers
|
|
276
|
+
});
|
|
277
|
+
} };
|
|
310
278
|
}
|
|
311
279
|
});
|
|
312
280
|
|
|
@@ -399,9 +367,9 @@ async function serve(root) {
|
|
|
399
367
|
}
|
|
400
368
|
const graphPlugin = createPlugin({
|
|
401
369
|
name: "graph",
|
|
402
|
-
install(
|
|
370
|
+
install(ctx, options) {
|
|
403
371
|
if (!options) throw new Error("Graph plugin requires options.root and options.mode");
|
|
404
|
-
|
|
372
|
+
ctx.on("write:start", async ({ files }) => {
|
|
405
373
|
const root = options.root;
|
|
406
374
|
const graph = getGraph({
|
|
407
375
|
files,
|
|
@@ -424,12 +392,38 @@ const graphPlugin = createPlugin({
|
|
|
424
392
|
value: html
|
|
425
393
|
}]
|
|
426
394
|
});
|
|
427
|
-
await
|
|
395
|
+
await ctx.addFile(graphFile, graphHtmlFile);
|
|
428
396
|
if (options.open) await serve(root);
|
|
429
397
|
});
|
|
430
398
|
}
|
|
431
399
|
});
|
|
432
400
|
|
|
401
|
+
//#endregion
|
|
402
|
+
//#region src/plugins/progressPlugin.ts
|
|
403
|
+
const progressPlugin = createPlugin({
|
|
404
|
+
name: "progress",
|
|
405
|
+
install(ctx) {
|
|
406
|
+
const progressBar = new cli_progress.SingleBar({
|
|
407
|
+
format: "{bar} {percentage}% | {value}/{total} | {message}",
|
|
408
|
+
barCompleteChar: "█",
|
|
409
|
+
barIncompleteChar: "░",
|
|
410
|
+
hideCursor: true,
|
|
411
|
+
clearOnComplete: true
|
|
412
|
+
}, cli_progress.Presets.shades_grey);
|
|
413
|
+
ctx.on("process:start", async ({ files }) => {
|
|
414
|
+
progressBar.start(files.length, 0, { message: "Starting..." });
|
|
415
|
+
});
|
|
416
|
+
ctx.on("process:progress", async ({ file }) => {
|
|
417
|
+
const message = `Writing ${(0, node_path.relative)(node_process.default.cwd(), file.path)}`;
|
|
418
|
+
progressBar.increment(1, { message });
|
|
419
|
+
});
|
|
420
|
+
ctx.on("process:end", async ({ files }) => {
|
|
421
|
+
progressBar.update(files.length, { message: "Done ✅" });
|
|
422
|
+
progressBar.stop();
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
|
|
433
427
|
//#endregion
|
|
434
428
|
exports.barrelPlugin = barrelPlugin;
|
|
435
429
|
exports.createPlugin = createPlugin;
|
package/dist/plugins.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.cjs","names":["path","fs","stack: Array<TreeNode<TData>>","result: Array<TreeNode<TData>>","nodes: Array<{ id: string; label: string }>","edges: Array<{ from: string; to: string }>","next: TreeNode<BarrelData> | undefined","path","createFile","getRelativePath","SingleBar","Presets","process","path","http","createFile","path"],"sources":["../src/plugins/createPlugin.ts","../src/plugins/fsPlugin.ts","../src/utils/TreeNode.ts","../src/plugins/barrelPlugin.ts","../src/plugins/progressPlugin.ts","../src/utils/open.ts","../src/plugins/graphPlugin.ts"],"sourcesContent":["import type { Plugin, UserPlugin } from './types.ts'\n\nexport function createPlugin<Options = unknown, TAppExtension extends Record<string, any> = {}>(\n plugin: UserPlugin<Options, TAppExtension>,\n): Plugin<Options, TAppExtension> {\n return {\n type: 'plugin',\n ...plugin,\n }\n}\n","import { createPlugin } from './createPlugin.ts'\nimport fs from 'fs-extra'\nimport { resolve } from 'node:path'\nimport type * as KubbFile from '../KubbFile.ts'\n\ntype WriteOptions = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n}\n\ntype Options = {\n dryRun?: boolean\n /**\n * Optional callback that is invoked whenever a file is written by the plugin.\n * Useful for tests to observe write operations without spying on internal functions.\n */\n onBeforeWrite?: (path: string, data: string | undefined) => void | Promise<void>\n clean?: {\n path: string\n }\n}\n\ntype ExtendOptions = {\n write(options?: WriteOptions): Promise<void>\n}\n\nexport async function write(path: string, data: string | undefined, options: { sanity?: boolean } = {}): Promise<string | undefined> {\n if (typeof Bun !== 'undefined') {\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n await Bun.write(resolve(path), data.trim())\n\n if (options?.sanity) {\n const file = Bun.file(resolve(path))\n const savedData = await file.text()\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n }\n\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n try {\n const oldContent = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n if (oldContent?.toString() === data?.toString()) {\n return\n }\n } catch (_err) {\n /* empty */\n }\n\n await fs.outputFile(resolve(path), data.trim(), { encoding: 'utf-8' })\n\n if (options?.sanity) {\n const savedData = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n}\n\n// biome-ignore lint/suspicious/noTsIgnore: production ready\n// @ts-ignore\ndeclare module '@kubb/fabric-core' {\n interface Fabric {\n write(options?: WriteOptions): Promise<void>\n }\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n write(options?: WriteOptions): Promise<void>\n }\n }\n}\n\nexport const fsPlugin = createPlugin<Options, ExtendOptions>({\n name: 'fs',\n install(app, options = {}) {\n if (options.clean) {\n fs.removeSync(options.clean.path)\n }\n\n app.context.events.on('process:progress', async ({ file, source }) => {\n if (options.onBeforeWrite) {\n await options.onBeforeWrite(file.path, source)\n }\n await write(file.path, source, { sanity: false })\n })\n },\n inject(app, { dryRun } = {}) {\n return {\n async write(\n options = {\n extension: { '.ts': '.ts' },\n },\n ) {\n await app.context.fileManager.write({\n mode: app.context.config?.options?.mode,\n extension: options.extension,\n dryRun,\n parsers: app.context.installedParsers,\n })\n },\n }\n },\n})\n","import type * as KubbFile from '../KubbFile.ts'\n\ntype BarrelData = {\n file?: KubbFile.File\n path: string\n name: string\n}\n\nexport type Graph = {\n nodes: Array<{ id: string; label: string }>\n edges: Array<{ from: string; to: string }>\n}\n\nexport class TreeNode<TData = unknown> {\n data: TData\n parent?: TreeNode<TData>\n children: Array<TreeNode<TData>> = []\n #cachedLeaves?: Array<TreeNode<TData>>\n\n constructor(data: TData, parent?: TreeNode<TData>) {\n this.data = data\n this.parent = parent\n }\n\n addChild(data: TData): TreeNode<TData> {\n const child = new TreeNode(data, this)\n this.children.push(child)\n this.#cachedLeaves = undefined // invalidate cached leaves\n return child\n }\n\n get leaves(): Array<TreeNode<TData>> {\n if (this.#cachedLeaves) return this.#cachedLeaves\n if (this.children.length === 0) return [this]\n\n const stack: Array<TreeNode<TData>> = [...this.children]\n const result: Array<TreeNode<TData>> = []\n\n for (const node of stack) {\n if (node.children.length) {\n for (const child of node.children) stack.push(child)\n } else {\n result.push(node)\n }\n }\n\n this.#cachedLeaves = result\n return result\n }\n\n forEach(callback: (node: TreeNode<TData>) => void): this {\n const stack: Array<TreeNode<TData>> = [this]\n\n for (const node of stack) {\n callback(node)\n if (node.children.length) {\n for (const child of node.children) stack.push(child)\n }\n }\n return this\n }\n\n findDeep(predicate: (node: TreeNode<TData>) => boolean): TreeNode<TData> | undefined {\n for (const leaf of this.leaves) {\n if (predicate(leaf)) return leaf\n }\n return undefined\n }\n\n static toGraph(root: TreeNode<BarrelData>): Graph {\n const nodes: Array<{ id: string; label: string }> = []\n const edges: Array<{ from: string; to: string }> = []\n\n root.forEach((node) => {\n nodes.push({\n id: node.data.path,\n label: node.data.name,\n })\n\n for (const child of node.children) {\n edges.push({\n from: node.data.path,\n to: child.data.path,\n })\n }\n })\n\n return { nodes, edges }\n }\n\n static fromFiles(files: Array<KubbFile.File>, rootFolder = ''): TreeNode<BarrelData> | null {\n const normalizePath = (p: string): string => p.replace(/\\\\/g, '/')\n const normalizedRoot = normalizePath(rootFolder)\n const rootPrefix = normalizedRoot.endsWith('/') ? normalizedRoot : `${normalizedRoot}/`\n\n const filteredFiles = files.filter((file) => {\n const filePath = normalizePath(file.path)\n\n return !filePath.endsWith('.json') && (!rootFolder || filePath.startsWith(rootPrefix))\n })\n\n if (filteredFiles.length === 0) {\n return null\n }\n\n const treeNode = new TreeNode<BarrelData>({\n name: rootFolder || '',\n path: rootFolder || '',\n file: undefined,\n })\n\n for (const file of filteredFiles) {\n const relPath = normalizePath(file.path).slice(rootPrefix.length)\n const parts = relPath.split('/')\n\n let current = treeNode\n let currentPath = rootFolder\n\n for (const [index, part] of parts.entries()) {\n const isLast = index === parts.length - 1\n currentPath += (currentPath.endsWith('/') ? '' : '/') + part\n\n let next: TreeNode<BarrelData> | undefined\n for (const child of current.children) {\n if ((child.data as BarrelData).name === part) {\n next = child\n break\n }\n }\n\n if (!next) {\n next = current.addChild({\n name: part,\n path: currentPath,\n file: isLast ? file : undefined,\n })\n }\n\n current = next\n }\n }\n\n return treeNode\n }\n}\n","/** biome-ignore-all lint/suspicious/useIterableCallbackReturn: not needed */\n\nimport { createPlugin } from './createPlugin.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { TreeNode } from '../utils/TreeNode.ts'\nimport path from 'node:path'\nimport { getRelativePath } from '../utils/getRelativePath.ts'\nimport { createFile } from '../createFile.ts'\n\ntype Mode = 'all' | 'named' | 'propagate' | false\n\ntype Options = {\n root: string\n mode: Mode\n dryRun?: boolean\n}\n\ntype WriteEntryOptions = {\n root: string\n mode: Mode\n}\n\ntype ExtendOptions = {\n writeEntry(options: WriteEntryOptions): Promise<void>\n}\n\n// biome-ignore lint/suspicious/noTsIgnore: production ready\n// @ts-ignore\ndeclare module '@kubb/fabric-core' {\n interface Fabric {\n writeEntry(options: WriteEntryOptions): Promise<void>\n }\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n writeEntry(options: WriteEntryOptions): Promise<void>\n }\n }\n}\n\ntype GetBarrelFilesOptions = {\n files: KubbFile.File[]\n root: string\n mode: Mode\n}\n\nexport function getBarrelFiles({ files, root, mode }: GetBarrelFilesOptions): Array<KubbFile.File> {\n // Do not generate when propagating or disabled\n if (mode === 'propagate' || mode === false) {\n return []\n }\n\n const cachedFiles = new Map<KubbFile.Path, KubbFile.File>()\n const dedupe = new Map<KubbFile.Path, Set<string>>()\n\n const treeNode = TreeNode.fromFiles(files, root)\n\n if (!treeNode) {\n return []\n }\n\n treeNode.forEach((node) => {\n // Only create a barrel for directory-like nodes that have a parent with a path\n if (!node?.children || !node.parent?.data.path) {\n return\n }\n\n const parentPath = node.parent.data.path as KubbFile.Path\n const barrelPath = path.join(parentPath, 'index.ts') as KubbFile.Path\n\n let barrelFile = cachedFiles.get(barrelPath)\n if (!barrelFile) {\n barrelFile = createFile({\n path: barrelPath,\n baseName: 'index.ts',\n exports: [],\n sources: [],\n })\n cachedFiles.set(barrelPath, barrelFile)\n dedupe.set(barrelPath, new Set<string>())\n }\n\n const seen = dedupe.get(barrelPath)!\n\n // Collect all leaves under the current directory node\n node.leaves.forEach((leaf) => {\n const file = leaf.data.file\n if (!file) {\n return\n }\n\n const sources = file.sources || []\n sources.forEach((source) => {\n if (!file.path || !source.isIndexable || !source.name) {\n return\n }\n\n const key = `${source.name}|${source.isTypeOnly ? '1' : '0'}`\n if (seen.has(key)) {\n return\n }\n seen.add(key)\n\n // Always compute relative path from the parent directory to the file path\n barrelFile!.exports!.push({\n name: [source.name],\n path: getRelativePath(parentPath, file.path),\n isTypeOnly: source.isTypeOnly,\n })\n\n barrelFile!.sources.push({\n name: source.name,\n isTypeOnly: source.isTypeOnly,\n value: '', // TODO use parser to generate import\n isExportable: mode === 'all' || mode === 'named',\n isIndexable: mode === 'all' || mode === 'named',\n })\n })\n })\n })\n\n const result = [...cachedFiles.values()]\n\n if (mode === 'all') {\n return result.map((file) => ({\n ...file,\n exports: file.exports?.map((e) => ({ ...e, name: undefined })),\n }))\n }\n\n return result\n}\n\nexport const barrelPlugin = createPlugin<Options, ExtendOptions>({\n name: 'barrel',\n install(app, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n if (!options.mode) {\n return undefined\n }\n\n app.context.events.on('write:start', async ({ files }) => {\n const root = options.root\n const barrelFiles = getBarrelFiles({ files, root, mode: options.mode })\n\n await app.context.fileManager.add(...barrelFiles)\n })\n },\n inject(app, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n return {\n async writeEntry({ root, mode }) {\n if (!mode || mode === 'propagate') {\n return undefined\n }\n\n const rootPath = path.resolve(root, 'index.ts')\n\n const barrelFiles = app.files.filter((file) => {\n return file.sources.some((source) => source.isIndexable)\n })\n\n const entryFile = createFile({\n path: rootPath,\n baseName: 'index.ts',\n exports: barrelFiles\n .flatMap((file) => {\n const containsOnlyTypes = file.sources.every((source) => source.isTypeOnly)\n\n return file.sources\n ?.map((source) => {\n if (!file.path || !source.isIndexable) {\n return undefined\n }\n\n return {\n name: mode === 'all' ? undefined : [source.name],\n path: getRelativePath(rootPath, file.path),\n isTypeOnly: mode === 'all' ? containsOnlyTypes : source.isTypeOnly,\n } as KubbFile.Export\n })\n .filter(Boolean)\n })\n .filter(Boolean),\n sources: [],\n })\n\n await app.context.fileManager.add(entryFile)\n\n await app.context.fileManager.write({\n mode: app.context.config?.options?.mode,\n dryRun: options.dryRun,\n parsers: app.context.installedParsers,\n })\n },\n }\n },\n})\n","import { Presets, SingleBar } from 'cli-progress'\nimport { createPlugin } from './createPlugin.ts'\nimport { relative } from 'node:path'\nimport process from 'node:process'\n\nexport const progressPlugin = createPlugin({\n name: 'progress',\n install(app) {\n const progressBar = new SingleBar(\n {\n format: '{bar} {percentage}% | {value}/{total} | {message}',\n barCompleteChar: '█',\n barIncompleteChar: '░',\n hideCursor: true,\n clearOnComplete: true,\n },\n Presets.shades_grey,\n )\n\n app.context.events.on('process:start', async ({ files }) => {\n progressBar.start(files.length, 0, { message: 'Starting...' })\n })\n\n app.context.events.on('process:progress', async ({ file }) => {\n const message = `Writing ${relative(process.cwd(), file.path)}`\n progressBar.increment(1, { message })\n })\n\n app.context.events.on('process:end', async ({ files }) => {\n progressBar.update(files.length, { message: 'Done ✅' })\n progressBar.stop()\n })\n },\n})\n","import { spawn } from 'node:child_process'\n\nconst spawnBin = (bin: string, args: string[]): Promise<boolean> => {\n return new Promise((resolve) => {\n const process = spawn(bin, args, {\n detached: true,\n shell: false,\n windowsHide: true,\n })\n\n process.on('close', (code) => {\n resolve(!code)\n })\n })\n}\n\ntype Options = {\n app?: string\n}\n\nexport async function open(path: string, options?: Options): Promise<boolean> {\n const app = options?.app\n\n if (process.platform === 'win32') {\n return spawnBin('cmd.exe', ['/c', 'start', app || '', path.replace(/[&^]/g, '^$&')])\n }\n\n if (process.platform === 'linux') {\n return spawnBin(app || 'xdg-open', [path])\n }\n if (process.platform === 'darwin') {\n return spawnBin('open', app ? ['-a', app, path] : [path])\n }\n\n throw new Error(`Unsupported platform, could not open \"${path}\"`)\n}\n","import { createPlugin } from './createPlugin.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { type Graph, TreeNode } from '../utils/TreeNode.ts'\nimport path from 'node:path'\nimport http from 'node:http'\nimport type { AddressInfo } from 'node:net'\nimport handler from 'serve-handler'\nimport { open } from '../utils/open.ts'\n\nimport { createFile } from '../createFile.ts'\n\ntype Options = {\n root: string\n /**\n * @default false\n */\n open?: boolean\n}\n\ntype GetGraphOptions = {\n files: KubbFile.File[]\n root: string\n}\n\nexport function getGraph({ files, root }: GetGraphOptions): Graph | undefined {\n const treeNode = TreeNode.fromFiles(files, root)\n\n if (!treeNode) {\n return undefined\n }\n\n return TreeNode.toGraph(treeNode)\n}\nconst html = `\n <!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <title>File Graph</title>\n <script type=\"module\">\n import { Network } from 'https://cdn.jsdelivr.net/npm/vis-network/standalone/esm/vis-network.min.js'\n\n async function main() {\n const res = await fetch('./graph.json')\n const { nodes, edges } = await res.json()\n const container = document.getElementById('graph')\n\n const network = new Network(\n container,\n { nodes, edges },\n {\n layout: { hierarchical: { direction: 'UD', sortMethod: 'directed' } },\n nodes: { shape: 'box', font: { face: 'monospace' } },\n edges: { arrows: 'to' },\n physics: false,\n },\n )\n }\n\n main()\n </script>\n <style>\n html, body, #graph { height: 100%; margin: 0; }\n </style>\n </head>\n <body>\n <div id=\"graph\"></div>\n </body>\n</html>\n`\n\nasync function serve(root: string) {\n const server = http.createServer((req, res) => {\n return handler(req, res, {\n public: root,\n cleanUrls: true,\n })\n })\n\n server.listen(0, async () => {\n const { port } = server.address() as AddressInfo\n console.log(`Running on http://localhost:${port}/graph.html`)\n\n await open(`http://localhost:${port}/graph.html`)\n })\n}\n\nexport const graphPlugin = createPlugin<Options>({\n name: 'graph',\n install(app, options) {\n if (!options) {\n throw new Error('Graph plugin requires options.root and options.mode')\n }\n\n app.context.events.on('write:start', async ({ files }) => {\n const root = options.root\n\n const graph = getGraph({ files, root })\n\n if (!graph) {\n return undefined\n }\n\n const graphFile = createFile({\n baseName: 'graph.json',\n path: path.join(root, 'graph.json'),\n sources: [\n {\n name: 'graph',\n value: JSON.stringify(graph, null, 2),\n },\n ],\n })\n\n const graphHtmlFile = createFile({\n baseName: 'graph.html',\n path: path.join(root, 'graph.html'),\n sources: [\n {\n name: 'graph',\n value: html,\n },\n ],\n })\n\n await app.context.fileManager.add(graphFile, graphHtmlFile)\n\n if (options.open) {\n await serve(root)\n }\n })\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAEA,SAAgB,aACd,QACgC;AAChC,QAAO;EACL,MAAM;EACN,GAAG;EACJ;;;;;ACiBH,eAAsB,MAAM,QAAc,MAA0B,UAAgC,EAAE,EAA+B;AACnI,KAAI,OAAO,QAAQ,aAAa;AAC9B,MAAI,CAAC,qDAAQ,KAAM,MAAM,MAAK,GAC5B;AAGF,QAAM,IAAI,6BAAcA,OAAK,EAAE,KAAK,MAAM,CAAC;AAE3C,wDAAI,QAAS,QAAQ;GAEnB,MAAM,YAAY,MADL,IAAI,4BAAaA,OAAK,CAAC,CACP,MAAM;AAEnC,8DAAI,UAAW,UAAU,mDAAK,KAAM,UAAU,EAC5C,OAAM,IAAI,MAAM,2BAA2BA,OAAK,WAAW,KAAK,OAAO,MAAM,KAAK,YAAY,UAAU,OAAO,MAAM,UAAU,IAAI;AAGrI,UAAO;;AAGT,SAAO;;AAGT,KAAI,CAAC,qDAAQ,KAAM,MAAM,MAAK,GAC5B;AAGF,KAAI;EACF,MAAM,aAAa,MAAMC,iBAAG,gCAAiBD,OAAK,EAAE,EAClD,UAAU,SACX,CAAC;AACF,+DAAI,WAAY,UAAU,mDAAK,KAAM,UAAU,EAC7C;UAEK,MAAM;AAIf,OAAMC,iBAAG,kCAAmBD,OAAK,EAAE,KAAK,MAAM,EAAE,EAAE,UAAU,SAAS,CAAC;AAEtE,uDAAI,QA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Ac,KAAK,QAAQ;AAC7C,oCAAe,KAAK,KAAK;GACvB,QAAQ;GACR,WAAW;GACZ,CAAC;GACF;AAEF,QAAO,OAAO,GAAG,YAAY;EAC3B,MAAM,EAAE,SAAS,OAAO,SAAS;AACjC,UAAQ,IAAI,+BAA+B,KAAK,aAAa;AAE7D,QAAM,KAAK,oBAAoB,KAAK,aAAa;GACjD;;AAGJ,MAAa,cAAc,aAAsB;CAC/C,MAAM;CACN,QAAQ,KAAK,SAAS;AACpB,MAAI,CAAC,QACH,OAAM,IAAI,MAAM,sDAAsD;AAGxE,MAAI,QAAQ,OAAO,GAAG,eAAe,OAAO,EAAE,YAAY;GACxD,MAAM,OAAO,QAAQ;GAErB,MAAM,QAAQ,SAAS;IAAE;IAAO;IAAM,CAAC;AAEvC,OAAI,CAAC,MACH;GAGF,MAAM,YAAYC,kCAAW;IAC3B,UAAU;IACV,MAAMC,kBAAK,KAAK,MAAM,aAAa;IACnC,SAAS,CACP;KACE,MAAM;KACN,OAAO,KAAK,UAAU,OAAO,MAAM,EAAE;KACtC,CACF;IACF,CAAC;GAEF,MAAM,gBAAgBD,kCAAW;IAC/B,UAAU;IACV,MAAMC,kBAAK,KAAK,MAAM,aAAa;IACnC,SAAS,CACP;KACE,MAAM;KACN,OAAO;KACR,CACF;IACF,CAAC;AAEF,SAAM,IAAI,QAAQ,YAAY,IAAI,WAAW,cAAc;AAE3D,OAAI,QAAQ,KACV,OAAM,MAAM,KAAK;IAEnB;;CAEL,CAAC"}
|
|
1
|
+
{"version":3,"file":"plugins.cjs","names":["stack: Array<TreeNode<TData>>","result: Array<TreeNode<TData>>","nodes: Array<{ id: string; label: string }>","edges: Array<{ from: string; to: string }>","next: TreeNode<BarrelData> | undefined","path","createFile","getRelativePath","path","fs","path","http","createFile","path","SingleBar","Presets","process"],"sources":["../src/utils/TreeNode.ts","../src/plugins/createPlugin.ts","../src/plugins/barrelPlugin.ts","../src/plugins/fsPlugin.ts","../src/utils/open.ts","../src/plugins/graphPlugin.ts","../src/plugins/progressPlugin.ts"],"sourcesContent":["import type * as KubbFile from '../KubbFile.ts'\n\ntype BarrelData = {\n file?: KubbFile.File\n path: string\n name: string\n}\n\nexport type Graph = {\n nodes: Array<{ id: string; label: string }>\n edges: Array<{ from: string; to: string }>\n}\n\nexport class TreeNode<TData = unknown> {\n data: TData\n parent?: TreeNode<TData>\n children: Array<TreeNode<TData>> = []\n #cachedLeaves?: Array<TreeNode<TData>>\n\n constructor(data: TData, parent?: TreeNode<TData>) {\n this.data = data\n this.parent = parent\n }\n\n addChild(data: TData): TreeNode<TData> {\n const child = new TreeNode(data, this)\n this.children.push(child)\n this.#cachedLeaves = undefined // invalidate cached leaves\n return child\n }\n\n get leaves(): Array<TreeNode<TData>> {\n if (this.#cachedLeaves) return this.#cachedLeaves\n if (this.children.length === 0) return [this]\n\n const stack: Array<TreeNode<TData>> = [...this.children]\n const result: Array<TreeNode<TData>> = []\n\n for (const node of stack) {\n if (node.children.length) {\n for (const child of node.children) stack.push(child)\n } else {\n result.push(node)\n }\n }\n\n this.#cachedLeaves = result\n return result\n }\n\n forEach(callback: (node: TreeNode<TData>) => void): this {\n const stack: Array<TreeNode<TData>> = [this]\n\n for (const node of stack) {\n callback(node)\n if (node.children.length) {\n for (const child of node.children) stack.push(child)\n }\n }\n return this\n }\n\n findDeep(predicate: (node: TreeNode<TData>) => boolean): TreeNode<TData> | undefined {\n for (const leaf of this.leaves) {\n if (predicate(leaf)) return leaf\n }\n return undefined\n }\n\n static toGraph(root: TreeNode<BarrelData>): Graph {\n const nodes: Array<{ id: string; label: string }> = []\n const edges: Array<{ from: string; to: string }> = []\n\n root.forEach((node) => {\n nodes.push({\n id: node.data.path,\n label: node.data.name,\n })\n\n for (const child of node.children) {\n edges.push({\n from: node.data.path,\n to: child.data.path,\n })\n }\n })\n\n return { nodes, edges }\n }\n\n static fromFiles(files: Array<KubbFile.File>, rootFolder = ''): TreeNode<BarrelData> | null {\n const normalizePath = (p: string): string => p.replace(/\\\\/g, '/')\n const normalizedRoot = normalizePath(rootFolder)\n const rootPrefix = normalizedRoot.endsWith('/') ? normalizedRoot : `${normalizedRoot}/`\n\n const filteredFiles = files.filter((file) => {\n const filePath = normalizePath(file.path)\n\n return !filePath.endsWith('.json') && (!rootFolder || filePath.startsWith(rootPrefix))\n })\n\n if (filteredFiles.length === 0) {\n return null\n }\n\n const treeNode = new TreeNode<BarrelData>({\n name: rootFolder || '',\n path: rootFolder || '',\n file: undefined,\n })\n\n for (const file of filteredFiles) {\n const relPath = normalizePath(file.path).slice(rootPrefix.length)\n const parts = relPath.split('/')\n\n let current = treeNode\n let currentPath = rootFolder\n\n for (const [index, part] of parts.entries()) {\n const isLast = index === parts.length - 1\n currentPath += (currentPath.endsWith('/') ? '' : '/') + part\n\n let next: TreeNode<BarrelData> | undefined\n for (const child of current.children) {\n if ((child.data as BarrelData).name === part) {\n next = child\n break\n }\n }\n\n if (!next) {\n next = current.addChild({\n name: part,\n path: currentPath,\n file: isLast ? file : undefined,\n })\n }\n\n current = next\n }\n }\n\n return treeNode\n }\n}\n","import type { Plugin, UserPlugin } from './types.ts'\n\nexport function createPlugin<Options = unknown, TAppExtension extends Record<string, any> = {}>(\n plugin: UserPlugin<Options, TAppExtension>,\n): Plugin<Options, TAppExtension> {\n return {\n type: 'plugin',\n ...plugin,\n }\n}\n","/** biome-ignore-all lint/suspicious/useIterableCallbackReturn: not needed */\n\nimport path from 'node:path'\nimport { createFile } from '../createFile.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { getRelativePath } from '../utils/getRelativePath.ts'\nimport { TreeNode } from '../utils/TreeNode.ts'\nimport { createPlugin } from './createPlugin.ts'\n\ntype Mode = 'all' | 'named' | 'propagate' | false\n\ntype Options = {\n root: string\n mode: Mode\n dryRun?: boolean\n}\n\ntype WriteEntryOptions = {\n root: string\n mode: Mode\n}\n\ntype ExtendOptions = {\n writeEntry(options: WriteEntryOptions): Promise<void>\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n writeEntry(options: WriteEntryOptions): Promise<void>\n }\n }\n}\n\ntype GetBarrelFilesOptions = {\n files: KubbFile.File[]\n root: string\n mode: Mode\n}\n\nexport function getBarrelFiles({ files, root, mode }: GetBarrelFilesOptions): Array<KubbFile.File> {\n // Do not generate when propagating or disabled\n if (mode === 'propagate' || mode === false) {\n return []\n }\n\n const cachedFiles = new Map<KubbFile.Path, KubbFile.File>()\n const dedupe = new Map<KubbFile.Path, Set<string>>()\n\n const treeNode = TreeNode.fromFiles(files, root)\n\n if (!treeNode) {\n return []\n }\n\n treeNode.forEach((node) => {\n // Only create a barrel for directory-like nodes that have a parent with a path\n if (!node?.children || !node.parent?.data.path) {\n return\n }\n\n const parentPath = node.parent.data.path as KubbFile.Path\n const barrelPath = path.join(parentPath, 'index.ts') as KubbFile.Path\n\n let barrelFile = cachedFiles.get(barrelPath)\n if (!barrelFile) {\n barrelFile = createFile({\n path: barrelPath,\n baseName: 'index.ts',\n exports: [],\n sources: [],\n })\n cachedFiles.set(barrelPath, barrelFile)\n dedupe.set(barrelPath, new Set<string>())\n }\n\n const seen = dedupe.get(barrelPath)!\n\n // Collect all leaves under the current directory node\n node.leaves.forEach((leaf) => {\n const file = leaf.data.file\n if (!file) {\n return\n }\n\n const sources = file.sources || []\n sources.forEach((source) => {\n if (!file.path || !source.isIndexable || !source.name) {\n return\n }\n\n const key = `${source.name}|${source.isTypeOnly ? '1' : '0'}`\n if (seen.has(key)) {\n return\n }\n seen.add(key)\n\n // Always compute relative path from the parent directory to the file path\n barrelFile!.exports!.push({\n name: [source.name],\n path: getRelativePath(parentPath, file.path),\n isTypeOnly: source.isTypeOnly,\n })\n\n barrelFile!.sources.push({\n name: source.name,\n isTypeOnly: source.isTypeOnly,\n value: '', // TODO use parser to generate import\n isExportable: mode === 'all' || mode === 'named',\n isIndexable: mode === 'all' || mode === 'named',\n })\n })\n })\n })\n\n const result = [...cachedFiles.values()]\n\n if (mode === 'all') {\n return result.map((file) => ({\n ...file,\n exports: file.exports?.map((e) => ({ ...e, name: undefined })),\n }))\n }\n\n return result\n}\n\nexport const barrelPlugin = createPlugin<Options, ExtendOptions>({\n name: 'barrel',\n install(ctx, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n if (!options.mode) {\n return undefined\n }\n\n ctx.on('write:start', async ({ files }) => {\n const root = options.root\n const barrelFiles = getBarrelFiles({ files, root, mode: options.mode })\n\n await ctx.fileManager.add(...barrelFiles)\n })\n },\n inject(ctx, options) {\n if (!options) {\n throw new Error('Barrel plugin requires options.root and options.mode')\n }\n\n return {\n async writeEntry({ root, mode }) {\n if (!mode || mode === 'propagate') {\n return undefined\n }\n\n const rootPath = path.resolve(root, 'index.ts')\n\n const barrelFiles = ctx.files.filter((file) => {\n return file.sources.some((source) => source.isIndexable)\n })\n\n const entryFile = createFile({\n path: rootPath,\n baseName: 'index.ts',\n exports: barrelFiles\n .flatMap((file) => {\n const containsOnlyTypes = file.sources.every((source) => source.isTypeOnly)\n\n return file.sources\n ?.map((source) => {\n if (!file.path || !source.isIndexable) {\n return undefined\n }\n\n return {\n name: mode === 'all' ? undefined : [source.name],\n path: getRelativePath(rootPath, file.path),\n isTypeOnly: mode === 'all' ? containsOnlyTypes : source.isTypeOnly,\n } as KubbFile.Export\n })\n .filter(Boolean)\n })\n .filter(Boolean),\n sources: [],\n })\n\n await ctx.addFile(entryFile)\n\n await ctx.fileManager.write({\n mode: ctx.config?.options?.mode,\n dryRun: options.dryRun,\n parsers: ctx.installedParsers,\n })\n },\n }\n },\n})\n","import { resolve } from 'node:path'\nimport fs from 'fs-extra'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { createPlugin } from './createPlugin.ts'\n\ntype WriteOptions = {\n extension?: Record<KubbFile.Extname, KubbFile.Extname | ''>\n}\n\ntype Options = {\n dryRun?: boolean\n /**\n * Optional callback that is invoked whenever a file is written by the plugin.\n * Useful for tests to observe write operations without spying on internal functions.\n */\n onBeforeWrite?: (path: string, data: string | undefined) => void | Promise<void>\n clean?: {\n path: string\n }\n}\n\ntype ExtendOptions = {\n write(options?: WriteOptions): Promise<void>\n}\n\nexport async function write(path: string, data: string | undefined, options: { sanity?: boolean } = {}): Promise<string | undefined> {\n if (typeof Bun !== 'undefined') {\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n await Bun.write(resolve(path), data.trim())\n\n if (options?.sanity) {\n const file = Bun.file(resolve(path))\n const savedData = await file.text()\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n }\n\n if (!data || data?.trim() === '') {\n return undefined\n }\n\n try {\n const oldContent = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n if (oldContent?.toString() === data?.toString()) {\n return\n }\n } catch (_err) {\n /* empty */\n }\n\n await fs.outputFile(resolve(path), data.trim(), { encoding: 'utf-8' })\n\n if (options?.sanity) {\n const savedData = await fs.readFile(resolve(path), {\n encoding: 'utf-8',\n })\n\n if (savedData?.toString() !== data?.toString()) {\n throw new Error(`Sanity check failed for ${path}\\n\\nData[${data.length}]:\\n${data}\\n\\nSaved[${savedData.length}]:\\n${savedData}\\n`)\n }\n\n return savedData\n }\n\n return data\n}\n\ndeclare global {\n namespace Kubb {\n interface Fabric {\n write(options?: WriteOptions): Promise<void>\n }\n }\n}\n\nexport const fsPlugin = createPlugin<Options, ExtendOptions>({\n name: 'fs',\n install(ctx, options = {}) {\n if (options.clean) {\n fs.removeSync(options.clean.path)\n }\n\n ctx.on('process:progress', async ({ file, source }) => {\n if (options.onBeforeWrite) {\n await options.onBeforeWrite(file.path, source)\n }\n await write(file.path, source, { sanity: false })\n })\n },\n inject(ctx, { dryRun } = {}) {\n return {\n async write(\n options = {\n extension: { '.ts': '.ts' },\n },\n ) {\n await ctx.fileManager.write({\n mode: ctx.config?.options?.mode,\n extension: options.extension,\n dryRun,\n parsers: ctx.installedParsers,\n })\n },\n }\n },\n})\n","import { spawn } from 'node:child_process'\n\nconst spawnBin = (bin: string, args: string[]): Promise<boolean> => {\n return new Promise((resolve) => {\n const process = spawn(bin, args, {\n detached: true,\n shell: false,\n windowsHide: true,\n })\n\n process.on('close', (code) => {\n resolve(!code)\n })\n })\n}\n\ntype Options = {\n app?: string\n}\n\nexport async function open(path: string, options?: Options): Promise<boolean> {\n const app = options?.app\n\n if (process.platform === 'win32') {\n return spawnBin('cmd.exe', ['/c', 'start', app || '', path.replace(/[&^]/g, '^$&')])\n }\n\n if (process.platform === 'linux') {\n return spawnBin(app || 'xdg-open', [path])\n }\n if (process.platform === 'darwin') {\n return spawnBin('open', app ? ['-a', app, path] : [path])\n }\n\n throw new Error(`Unsupported platform, could not open \"${path}\"`)\n}\n","import http from 'node:http'\nimport type { AddressInfo } from 'node:net'\nimport path from 'node:path'\nimport handler from 'serve-handler'\nimport { createFile } from '../createFile.ts'\nimport type * as KubbFile from '../KubbFile.ts'\nimport { open } from '../utils/open.ts'\nimport { type Graph, TreeNode } from '../utils/TreeNode.ts'\nimport { createPlugin } from './createPlugin.ts'\n\ntype Options = {\n root: string\n /**\n * @default false\n */\n open?: boolean\n}\n\ntype GetGraphOptions = {\n files: KubbFile.File[]\n root: string\n}\n\nexport function getGraph({ files, root }: GetGraphOptions): Graph | undefined {\n const treeNode = TreeNode.fromFiles(files, root)\n\n if (!treeNode) {\n return undefined\n }\n\n return TreeNode.toGraph(treeNode)\n}\nconst html = `\n <!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <title>File Graph</title>\n <script type=\"module\">\n import { Network } from 'https://cdn.jsdelivr.net/npm/vis-network/standalone/esm/vis-network.min.js'\n\n async function main() {\n const res = await fetch('./graph.json')\n const { nodes, edges } = await res.json()\n const container = document.getElementById('graph')\n\n const network = new Network(\n container,\n { nodes, edges },\n {\n layout: { hierarchical: { direction: 'UD', sortMethod: 'directed' } },\n nodes: { shape: 'box', font: { face: 'monospace' } },\n edges: { arrows: 'to' },\n physics: false,\n },\n )\n }\n\n main()\n </script>\n <style>\n html, body, #graph { height: 100%; margin: 0; }\n </style>\n </head>\n <body>\n <div id=\"graph\"></div>\n </body>\n</html>\n`\n\nasync function serve(root: string) {\n const server = http.createServer((req, res) => {\n return handler(req, res, {\n public: root,\n cleanUrls: true,\n })\n })\n\n server.listen(0, async () => {\n const { port } = server.address() as AddressInfo\n console.log(`Running on http://localhost:${port}/graph.html`)\n\n await open(`http://localhost:${port}/graph.html`)\n })\n}\n\nexport const graphPlugin = createPlugin<Options>({\n name: 'graph',\n install(ctx, options) {\n if (!options) {\n throw new Error('Graph plugin requires options.root and options.mode')\n }\n\n ctx.on('write:start', async ({ files }) => {\n const root = options.root\n\n const graph = getGraph({ files, root })\n\n if (!graph) {\n return undefined\n }\n\n const graphFile = createFile({\n baseName: 'graph.json',\n path: path.join(root, 'graph.json'),\n sources: [\n {\n name: 'graph',\n value: JSON.stringify(graph, null, 2),\n },\n ],\n })\n\n const graphHtmlFile = createFile({\n baseName: 'graph.html',\n path: path.join(root, 'graph.html'),\n sources: [\n {\n name: 'graph',\n value: html,\n },\n ],\n })\n\n await ctx.addFile(graphFile, graphHtmlFile)\n\n if (options.open) {\n await serve(root)\n }\n })\n },\n})\n","import { relative } from 'node:path'\nimport process from 'node:process'\nimport { Presets, SingleBar } from 'cli-progress'\nimport { createPlugin } from './createPlugin.ts'\n\nexport const progressPlugin = createPlugin({\n name: 'progress',\n install(ctx) {\n const progressBar = new SingleBar(\n {\n format: '{bar} {percentage}% | {value}/{total} | {message}',\n barCompleteChar: '█',\n barIncompleteChar: '░',\n hideCursor: true,\n clearOnComplete: true,\n },\n Presets.shades_grey,\n )\n\n ctx.on('process:start', async ({ files }) => {\n progressBar.start(files.length, 0, { message: 'Starting...' })\n })\n\n ctx.on('process:progress', async ({ file }) => {\n const message = `Writing ${relative(process.cwd(), file.path)}`\n progressBar.increment(1, { message })\n })\n\n ctx.on('process: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B;GACjB,mBAAmB;GACnB,YAAY;GACZ,iBAAiB;GAClB,EACDC,qBAAQ,YACT;AAED,MAAI,GAAG,iBAAiB,OAAO,EAAE,YAAY;AAC3C,eAAY,MAAM,MAAM,QAAQ,GAAG,EAAE,SAAS,eAAe,CAAC;IAC9D;AAEF,MAAI,GAAG,oBAAoB,OAAO,EAAE,WAAW;GAC7C,MAAM,UAAU,mCAAoBC,qBAAQ,KAAK,EAAE,KAAK,KAAK;AAC7D,eAAY,UAAU,GAAG,EAAE,SAAS,CAAC;IACrC;AAEF,MAAI,GAAG,eAAe,OAAO,EAAE,YAAY;AACzC,eAAY,OAAO,MAAM,QAAQ,EAAE,SAAS,UAAU,CAAC;AACvD,eAAY,MAAM;IAClB;;CAEL,CAAC"}
|
package/dist/plugins.d.cts
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as Extname, o as Plugin, s as UserPlugin } from "./Fabric-CBrTERuf.cjs";
|
|
2
2
|
|
|
3
|
+
//#region src/plugins/barrelPlugin.d.ts
|
|
4
|
+
type Mode = 'all' | 'named' | 'propagate' | false;
|
|
5
|
+
type Options$2 = {
|
|
6
|
+
root: string;
|
|
7
|
+
mode: Mode;
|
|
8
|
+
dryRun?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type WriteEntryOptions = {
|
|
11
|
+
root: string;
|
|
12
|
+
mode: Mode;
|
|
13
|
+
};
|
|
14
|
+
type ExtendOptions$1 = {
|
|
15
|
+
writeEntry(options: WriteEntryOptions): Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
declare global {
|
|
18
|
+
namespace Kubb {
|
|
19
|
+
interface Fabric {
|
|
20
|
+
writeEntry(options: WriteEntryOptions): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
declare const barrelPlugin: Plugin<Options$2, ExtendOptions$1>;
|
|
25
|
+
//#endregion
|
|
3
26
|
//#region src/plugins/createPlugin.d.ts
|
|
4
27
|
declare function createPlugin<Options$3 = unknown, TAppExtension extends Record<string, any> = {}>(plugin: UserPlugin<Options$3, TAppExtension>): Plugin<Options$3, TAppExtension>;
|
|
5
28
|
//#endregion
|
|
@@ -7,7 +30,7 @@ declare function createPlugin<Options$3 = unknown, TAppExtension extends Record<
|
|
|
7
30
|
type WriteOptions = {
|
|
8
31
|
extension?: Record<Extname, Extname | ''>;
|
|
9
32
|
};
|
|
10
|
-
type Options$
|
|
33
|
+
type Options$1 = {
|
|
11
34
|
dryRun?: boolean;
|
|
12
35
|
/**
|
|
13
36
|
* Optional callback that is invoked whenever a file is written by the plugin.
|
|
@@ -18,14 +41,9 @@ type Options$2 = {
|
|
|
18
41
|
path: string;
|
|
19
42
|
};
|
|
20
43
|
};
|
|
21
|
-
type ExtendOptions
|
|
44
|
+
type ExtendOptions = {
|
|
22
45
|
write(options?: WriteOptions): Promise<void>;
|
|
23
46
|
};
|
|
24
|
-
declare module '@kubb/fabric-core' {
|
|
25
|
-
interface Fabric {
|
|
26
|
-
write(options?: WriteOptions): Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
47
|
declare global {
|
|
30
48
|
namespace Kubb {
|
|
31
49
|
interface Fabric {
|
|
@@ -33,38 +51,7 @@ declare global {
|
|
|
33
51
|
}
|
|
34
52
|
}
|
|
35
53
|
}
|
|
36
|
-
declare const fsPlugin: Plugin<Options$
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/plugins/barrelPlugin.d.ts
|
|
39
|
-
type Mode = 'all' | 'named' | 'propagate' | false;
|
|
40
|
-
type Options$1 = {
|
|
41
|
-
root: string;
|
|
42
|
-
mode: Mode;
|
|
43
|
-
dryRun?: boolean;
|
|
44
|
-
};
|
|
45
|
-
type WriteEntryOptions = {
|
|
46
|
-
root: string;
|
|
47
|
-
mode: Mode;
|
|
48
|
-
};
|
|
49
|
-
type ExtendOptions = {
|
|
50
|
-
writeEntry(options: WriteEntryOptions): Promise<void>;
|
|
51
|
-
};
|
|
52
|
-
declare module '@kubb/fabric-core' {
|
|
53
|
-
interface Fabric {
|
|
54
|
-
writeEntry(options: WriteEntryOptions): Promise<void>;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
declare global {
|
|
58
|
-
namespace Kubb {
|
|
59
|
-
interface Fabric {
|
|
60
|
-
writeEntry(options: WriteEntryOptions): Promise<void>;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
declare const barrelPlugin: Plugin<Options$1, ExtendOptions>;
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/plugins/progressPlugin.d.ts
|
|
67
|
-
declare const progressPlugin: Plugin<[], {}>;
|
|
54
|
+
declare const fsPlugin: Plugin<Options$1, ExtendOptions>;
|
|
68
55
|
//#endregion
|
|
69
56
|
//#region src/plugins/graphPlugin.d.ts
|
|
70
57
|
type Options = {
|
|
@@ -76,5 +63,8 @@ type Options = {
|
|
|
76
63
|
};
|
|
77
64
|
declare const graphPlugin: Plugin<Options, {}>;
|
|
78
65
|
//#endregion
|
|
66
|
+
//#region src/plugins/progressPlugin.d.ts
|
|
67
|
+
declare const progressPlugin: Plugin<[], {}>;
|
|
68
|
+
//#endregion
|
|
79
69
|
export { barrelPlugin, createPlugin, fsPlugin, graphPlugin, progressPlugin };
|
|
80
70
|
//# sourceMappingURL=plugins.d.cts.map
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { f as Extname, o as Plugin, s as UserPlugin } from "./Fabric-AmREkq58.js";
|
|
2
2
|
|
|
3
|
+
//#region src/plugins/barrelPlugin.d.ts
|
|
4
|
+
type Mode = 'all' | 'named' | 'propagate' | false;
|
|
5
|
+
type Options$2 = {
|
|
6
|
+
root: string;
|
|
7
|
+
mode: Mode;
|
|
8
|
+
dryRun?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type WriteEntryOptions = {
|
|
11
|
+
root: string;
|
|
12
|
+
mode: Mode;
|
|
13
|
+
};
|
|
14
|
+
type ExtendOptions$1 = {
|
|
15
|
+
writeEntry(options: WriteEntryOptions): Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
declare global {
|
|
18
|
+
namespace Kubb {
|
|
19
|
+
interface Fabric {
|
|
20
|
+
writeEntry(options: WriteEntryOptions): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
declare const barrelPlugin: Plugin<Options$2, ExtendOptions$1>;
|
|
25
|
+
//#endregion
|
|
3
26
|
//#region src/plugins/createPlugin.d.ts
|
|
4
27
|
declare function createPlugin<Options$3 = unknown, TAppExtension extends Record<string, any> = {}>(plugin: UserPlugin<Options$3, TAppExtension>): Plugin<Options$3, TAppExtension>;
|
|
5
28
|
//#endregion
|
|
@@ -7,7 +30,7 @@ declare function createPlugin<Options$3 = unknown, TAppExtension extends Record<
|
|
|
7
30
|
type WriteOptions = {
|
|
8
31
|
extension?: Record<Extname, Extname | ''>;
|
|
9
32
|
};
|
|
10
|
-
type Options$
|
|
33
|
+
type Options$1 = {
|
|
11
34
|
dryRun?: boolean;
|
|
12
35
|
/**
|
|
13
36
|
* Optional callback that is invoked whenever a file is written by the plugin.
|
|
@@ -18,14 +41,9 @@ type Options$2 = {
|
|
|
18
41
|
path: string;
|
|
19
42
|
};
|
|
20
43
|
};
|
|
21
|
-
type ExtendOptions
|
|
44
|
+
type ExtendOptions = {
|
|
22
45
|
write(options?: WriteOptions): Promise<void>;
|
|
23
46
|
};
|
|
24
|
-
declare module '@kubb/fabric-core' {
|
|
25
|
-
interface Fabric {
|
|
26
|
-
write(options?: WriteOptions): Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
47
|
declare global {
|
|
30
48
|
namespace Kubb {
|
|
31
49
|
interface Fabric {
|
|
@@ -33,38 +51,7 @@ declare global {
|
|
|
33
51
|
}
|
|
34
52
|
}
|
|
35
53
|
}
|
|
36
|
-
declare const fsPlugin: Plugin<Options$
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/plugins/barrelPlugin.d.ts
|
|
39
|
-
type Mode = 'all' | 'named' | 'propagate' | false;
|
|
40
|
-
type Options$1 = {
|
|
41
|
-
root: string;
|
|
42
|
-
mode: Mode;
|
|
43
|
-
dryRun?: boolean;
|
|
44
|
-
};
|
|
45
|
-
type WriteEntryOptions = {
|
|
46
|
-
root: string;
|
|
47
|
-
mode: Mode;
|
|
48
|
-
};
|
|
49
|
-
type ExtendOptions = {
|
|
50
|
-
writeEntry(options: WriteEntryOptions): Promise<void>;
|
|
51
|
-
};
|
|
52
|
-
declare module '@kubb/fabric-core' {
|
|
53
|
-
interface Fabric {
|
|
54
|
-
writeEntry(options: WriteEntryOptions): Promise<void>;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
declare global {
|
|
58
|
-
namespace Kubb {
|
|
59
|
-
interface Fabric {
|
|
60
|
-
writeEntry(options: WriteEntryOptions): Promise<void>;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
declare const barrelPlugin: Plugin<Options$1, ExtendOptions>;
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/plugins/progressPlugin.d.ts
|
|
67
|
-
declare const progressPlugin: Plugin<[], {}>;
|
|
54
|
+
declare const fsPlugin: Plugin<Options$1, ExtendOptions>;
|
|
68
55
|
//#endregion
|
|
69
56
|
//#region src/plugins/graphPlugin.d.ts
|
|
70
57
|
type Options = {
|
|
@@ -76,5 +63,8 @@ type Options = {
|
|
|
76
63
|
};
|
|
77
64
|
declare const graphPlugin: Plugin<Options, {}>;
|
|
78
65
|
//#endregion
|
|
66
|
+
//#region src/plugins/progressPlugin.d.ts
|
|
67
|
+
declare const progressPlugin: Plugin<[], {}>;
|
|
68
|
+
//#endregion
|
|
79
69
|
export { barrelPlugin, createPlugin, fsPlugin, graphPlugin, progressPlugin };
|
|
80
70
|
//# sourceMappingURL=plugins.d.ts.map
|