@kubb/fabric-core 0.12.11 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{Fabric-CrRJykMN.d.ts → Fabric-CE-4sqCG.d.ts} +1 -4
- package/dist/{Fabric-DMmgrLto.d.cts → Fabric-efyCO1t7.d.ts} +2 -2
- package/dist/{RootContext-Cf7WJM7r.d.cts → RootContext-BgiMS39h.d.ts} +3 -3
- package/dist/{RootContext-CvaGJ-4g.d.ts → RootContext-CA-zkTEp.d.ts} +3 -4
- package/dist/{chunk-BVHe6Par.js → chunk-BYypO7fO.js} +1 -5
- package/dist/{chunk-DVipidnM.cjs → chunk-uaV2rQ02.cjs} +0 -10
- package/dist/{defaultParser-BK-zOanQ.cjs → defaultParser-BAgmtMo_.cjs} +2 -3
- package/dist/{defaultParser-BK-zOanQ.cjs.map → defaultParser-BAgmtMo_.cjs.map} +1 -1
- package/dist/{defaultParser-BD_N68Bo.js → defaultParser-C1atU7yU.js} +2 -3
- package/dist/{defaultParser-BD_N68Bo.js.map → defaultParser-C1atU7yU.js.map} +1 -1
- package/dist/{getRelativePath-C4Au07ON.js → getRelativePath-BcieQL5M.js} +1 -2
- package/dist/{getRelativePath-C4Au07ON.js.map → getRelativePath-BcieQL5M.js.map} +1 -1
- package/dist/{getRelativePath-DpbA6qm5.cjs → getRelativePath-DVG8dIzW.cjs} +2 -2
- package/dist/{getRelativePath-DpbA6qm5.cjs.map → getRelativePath-DVG8dIzW.cjs.map} +1 -1
- package/dist/index.cjs +62 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +11 -5
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/dist/{Root-CKos-Ahf.cjs → onProcessExit-B7_bTfyR.cjs} +115 -213
- package/dist/onProcessExit-B7_bTfyR.cjs.map +1 -0
- package/dist/{Root-BQX3eHqb.js → onProcessExit-CF200hsz.js} +109 -190
- package/dist/onProcessExit-CF200hsz.js.map +1 -0
- package/dist/parsers/typescript.cjs +4 -4
- package/dist/parsers/typescript.cjs.map +1 -1
- package/dist/parsers/typescript.d.ts +1 -2
- package/dist/parsers/typescript.js +3 -4
- package/dist/parsers/typescript.js.map +1 -1
- package/dist/parsers.cjs +2 -3
- package/dist/parsers.cjs.map +1 -1
- package/dist/parsers.d.ts +1 -2
- package/dist/parsers.js +2 -3
- package/dist/parsers.js.map +1 -1
- package/dist/plugins.cjs +61 -305
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.ts +9 -40
- package/dist/plugins.js +58 -298
- package/dist/plugins.js.map +1 -1
- package/dist/types.cjs +1 -1
- package/dist/types.d.ts +3 -4
- package/dist/types.js +1 -1
- package/dist/{useNodeTree-CgEKFUV-.d.cts → useNodeTree-BpHR6gQx.d.ts} +2 -2
- package/dist/{useNodeTree-CamNuFQP.d.ts → useNodeTree-DuQ5Df0t.d.ts} +2 -3
- package/package.json +8 -18
- package/src/FileManager.ts +6 -2
- package/src/createFile.ts +12 -9
- package/src/index.ts +3 -2
- package/src/plugins/fsPlugin.ts +8 -6
- package/src/plugins/fsxPlugin/Runtime.ts +4 -7
- package/src/plugins/index.ts +0 -1
- package/src/plugins/loggerPlugin.ts +15 -192
- package/src/utils/onProcessExit.ts +35 -0
- package/dist/Root-BQX3eHqb.js.map +0 -1
- package/dist/Root-CKos-Ahf.cjs.map +0 -1
- package/dist/index.d.cts +0 -595
- package/dist/parsers/typescript.d.cts +0 -45
- package/dist/parsers.d.cts +0 -37
- package/dist/plugins.d.cts +0 -149
- package/dist/types.d.cts +0 -11
- package/src/plugins/graphPlugin.ts +0 -136
package/dist/plugins.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import http from "node:http";
|
|
8
|
-
import handler from "serve-handler";
|
|
9
|
-
import { spawn } from "node:child_process";
|
|
1
|
+
import { l as TreeNode, n as Root, p as createFile, t as onProcessExit } from "./onProcessExit-CF200hsz.js";
|
|
2
|
+
import { t as getRelativePath } from "./getRelativePath-BcieQL5M.js";
|
|
3
|
+
import path, { dirname, relative, resolve } from "node:path";
|
|
4
|
+
import { rmSync } from "node:fs";
|
|
5
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
6
|
+
import { styleText } from "node:util";
|
|
10
7
|
import * as clack from "@clack/prompts";
|
|
11
|
-
import pc from "picocolors";
|
|
12
|
-
import { WebSocket, WebSocketServer } from "ws";
|
|
13
8
|
|
|
14
9
|
//#region src/plugins/definePlugin.ts
|
|
15
10
|
/**
|
|
@@ -58,8 +53,7 @@ function getBarrelFiles({ files, root, mode }) {
|
|
|
58
53
|
const treeNode = TreeNode.fromFiles(files, root);
|
|
59
54
|
if (!treeNode) return [];
|
|
60
55
|
treeNode.forEach((node) => {
|
|
61
|
-
|
|
62
|
-
if (!(node === null || node === void 0 ? void 0 : node.children) || !((_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.data.path)) return;
|
|
56
|
+
if (!node?.children || !node.parent?.data.path) return;
|
|
63
57
|
const parentPath = node.parent.data.path;
|
|
64
58
|
const barrelPath = path.join(parentPath, "index.ts");
|
|
65
59
|
let barrelFile = cachedFiles.get(barrelPath);
|
|
@@ -100,16 +94,13 @@ function getBarrelFiles({ files, root, mode }) {
|
|
|
100
94
|
}
|
|
101
95
|
});
|
|
102
96
|
const result = [...cachedFiles.values()];
|
|
103
|
-
if (mode === "all") return result.map((file) => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
...
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}))
|
|
111
|
-
};
|
|
112
|
-
});
|
|
97
|
+
if (mode === "all") return result.map((file) => ({
|
|
98
|
+
...file,
|
|
99
|
+
exports: file.exports?.map((e) => ({
|
|
100
|
+
...e,
|
|
101
|
+
name: void 0
|
|
102
|
+
}))
|
|
103
|
+
}));
|
|
113
104
|
return result;
|
|
114
105
|
}
|
|
115
106
|
const barrelPlugin = definePlugin({
|
|
@@ -141,8 +132,7 @@ const barrelPlugin = definePlugin({
|
|
|
141
132
|
for (const file of barrelFiles) fileTypeCache.set(file, file.sources.every((source) => source.isTypeOnly));
|
|
142
133
|
const exports = [];
|
|
143
134
|
for (const file of barrelFiles) {
|
|
144
|
-
|
|
145
|
-
const containsOnlyTypes = (_fileTypeCache$get = fileTypeCache.get(file)) !== null && _fileTypeCache$get !== void 0 ? _fileTypeCache$get : false;
|
|
135
|
+
const containsOnlyTypes = fileTypeCache.get(file) ?? false;
|
|
146
136
|
for (const source of file.sources) {
|
|
147
137
|
if (!file.path || !source.isIndexable) continue;
|
|
148
138
|
exports.push({
|
|
@@ -173,24 +163,24 @@ const barrelPlugin = definePlugin({
|
|
|
173
163
|
//#region src/plugins/fsPlugin.ts
|
|
174
164
|
async function write(path, data, options = {}) {
|
|
175
165
|
if (typeof Bun !== "undefined") {
|
|
176
|
-
if (!data ||
|
|
166
|
+
if (!data || data?.trim() === "") return;
|
|
177
167
|
await Bun.write(resolve(path), data.trim());
|
|
178
|
-
if (options
|
|
168
|
+
if (options?.sanity) {
|
|
179
169
|
const savedData = await Bun.file(resolve(path)).text();
|
|
180
|
-
if (
|
|
170
|
+
if (savedData?.toString() !== data?.toString()) throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
181
171
|
return savedData;
|
|
182
172
|
}
|
|
183
173
|
return data;
|
|
184
174
|
}
|
|
185
|
-
if (!data ||
|
|
175
|
+
if (!data || data?.trim() === "") return;
|
|
186
176
|
try {
|
|
187
|
-
|
|
188
|
-
if ((oldContent === null || oldContent === void 0 ? void 0 : oldContent.toString()) === (data === null || data === void 0 ? void 0 : data.toString())) return;
|
|
177
|
+
if ((await readFile(resolve(path), { encoding: "utf-8" }))?.toString() === data?.toString()) return;
|
|
189
178
|
} catch (_err) {}
|
|
190
|
-
await
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
179
|
+
await mkdir(dirname(resolve(path)), { recursive: true });
|
|
180
|
+
await writeFile(resolve(path), data.trim(), { encoding: "utf-8" });
|
|
181
|
+
if (options?.sanity) {
|
|
182
|
+
const savedData = await readFile(resolve(path), { encoding: "utf-8" });
|
|
183
|
+
if (savedData?.toString() !== data?.toString()) throw new Error(`Sanity check failed for ${path}\n\nData[${data.length}]:\n${data}\n\nSaved[${savedData.length}]:\n${savedData}\n`);
|
|
194
184
|
return savedData;
|
|
195
185
|
}
|
|
196
186
|
return data;
|
|
@@ -198,7 +188,10 @@ async function write(path, data, options = {}) {
|
|
|
198
188
|
const fsPlugin = definePlugin({
|
|
199
189
|
name: "fs",
|
|
200
190
|
install(ctx, options = {}) {
|
|
201
|
-
if (options.clean)
|
|
191
|
+
if (options.clean) rmSync(options.clean.path, {
|
|
192
|
+
recursive: true,
|
|
193
|
+
force: true
|
|
194
|
+
});
|
|
202
195
|
ctx.on("file:processing:update", async ({ file, source }) => {
|
|
203
196
|
if (options.onBeforeWrite) await options.onBeforeWrite(file.path, source);
|
|
204
197
|
await write(file.path, source, { sanity: false });
|
|
@@ -219,24 +212,22 @@ const fsPlugin = definePlugin({
|
|
|
219
212
|
|
|
220
213
|
//#endregion
|
|
221
214
|
//#region src/plugins/fsxPlugin/Runtime.ts
|
|
222
|
-
var _options = /* @__PURE__ */ new WeakMap();
|
|
223
|
-
var _renderPromise = /* @__PURE__ */ new WeakMap();
|
|
224
215
|
var Runtime = class {
|
|
216
|
+
#options;
|
|
217
|
+
exitPromise;
|
|
225
218
|
constructor(options) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
_classPrivateFieldInitSpec(this, _renderPromise, Promise.resolve());
|
|
229
|
-
_defineProperty(this, "resolveExitPromise", () => {});
|
|
230
|
-
_defineProperty(this, "rejectExitPromise", () => {});
|
|
231
|
-
_defineProperty(this, "unsubscribeExit", () => {});
|
|
232
|
-
_classPrivateFieldSet2(_options, this, options);
|
|
233
|
-
this.unsubscribeExit = onExit((code) => {
|
|
219
|
+
this.#options = options;
|
|
220
|
+
this.unsubscribeExit = onProcessExit((code) => {
|
|
234
221
|
this.unmount(code);
|
|
235
|
-
}
|
|
222
|
+
});
|
|
236
223
|
}
|
|
237
224
|
get fileManager() {
|
|
238
|
-
return
|
|
225
|
+
return this.#options.fileManager;
|
|
239
226
|
}
|
|
227
|
+
#renderPromise = Promise.resolve();
|
|
228
|
+
resolveExitPromise = () => {};
|
|
229
|
+
rejectExitPromise = () => {};
|
|
230
|
+
unsubscribeExit = () => {};
|
|
240
231
|
onError(error) {
|
|
241
232
|
throw error;
|
|
242
233
|
}
|
|
@@ -246,7 +237,7 @@ var Runtime = class {
|
|
|
246
237
|
}, 0);
|
|
247
238
|
}
|
|
248
239
|
async render(node) {
|
|
249
|
-
const treeNode =
|
|
240
|
+
const treeNode = this.#options.treeNode || new TreeNode({
|
|
250
241
|
type: "Root",
|
|
251
242
|
props: {}
|
|
252
243
|
});
|
|
@@ -257,22 +248,20 @@ var Runtime = class {
|
|
|
257
248
|
onError: this.onError.bind(this)
|
|
258
249
|
};
|
|
259
250
|
try {
|
|
260
|
-
var _element;
|
|
261
251
|
treeNode.data.props = props;
|
|
262
252
|
const element = Root({
|
|
263
253
|
...props,
|
|
264
254
|
children: node
|
|
265
255
|
});
|
|
266
|
-
await
|
|
267
|
-
return
|
|
256
|
+
await this.#renderPromise;
|
|
257
|
+
return element()?.toString() || "";
|
|
268
258
|
} catch (e) {
|
|
269
259
|
props.onError(e);
|
|
270
260
|
return "";
|
|
271
261
|
}
|
|
272
262
|
}
|
|
273
263
|
unmount(error) {
|
|
274
|
-
|
|
275
|
-
if ((_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_options, this)) === null || _classPrivateFieldGet2$1 === void 0 ? void 0 : _classPrivateFieldGet2$1.debug) console.log("Unmount", error);
|
|
264
|
+
if (this.#options?.debug) console.log("Unmount", error);
|
|
276
265
|
this.unsubscribeExit();
|
|
277
266
|
if (error instanceof Error) {
|
|
278
267
|
this.rejectExitPromise(error);
|
|
@@ -311,146 +300,8 @@ const fsxPlugin = definePlugin({
|
|
|
311
300
|
}
|
|
312
301
|
});
|
|
313
302
|
|
|
314
|
-
//#endregion
|
|
315
|
-
//#region src/utils/open.ts
|
|
316
|
-
const spawnBin = (bin, args) => {
|
|
317
|
-
return new Promise((resolve) => {
|
|
318
|
-
spawn(bin, args, {
|
|
319
|
-
detached: true,
|
|
320
|
-
shell: false,
|
|
321
|
-
windowsHide: true
|
|
322
|
-
}).on("close", (code) => {
|
|
323
|
-
resolve(!code);
|
|
324
|
-
});
|
|
325
|
-
});
|
|
326
|
-
};
|
|
327
|
-
async function open(path, options) {
|
|
328
|
-
const app = options === null || options === void 0 ? void 0 : options.app;
|
|
329
|
-
if (process.platform === "win32") return spawnBin("cmd.exe", [
|
|
330
|
-
"/c",
|
|
331
|
-
"start",
|
|
332
|
-
app || "",
|
|
333
|
-
path.replace(/[&^]/g, "^$&")
|
|
334
|
-
]);
|
|
335
|
-
if (process.platform === "linux") return spawnBin(app || "xdg-open", [path]);
|
|
336
|
-
if (process.platform === "darwin") return spawnBin("open", app ? [
|
|
337
|
-
"-a",
|
|
338
|
-
app,
|
|
339
|
-
path
|
|
340
|
-
] : [path]);
|
|
341
|
-
throw new Error(`Unsupported platform, could not open "${path}"`);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
//#endregion
|
|
345
|
-
//#region src/plugins/graphPlugin.ts
|
|
346
|
-
function getGraph({ files, root }) {
|
|
347
|
-
const treeNode = TreeNode.fromFiles(files, root);
|
|
348
|
-
if (!treeNode) return;
|
|
349
|
-
return TreeNode.toGraph(treeNode);
|
|
350
|
-
}
|
|
351
|
-
const html = `
|
|
352
|
-
<!DOCTYPE html>
|
|
353
|
-
<html lang="en">
|
|
354
|
-
<head>
|
|
355
|
-
<meta charset="UTF-8" />
|
|
356
|
-
<title>File Graph</title>
|
|
357
|
-
<script type="module">
|
|
358
|
-
import { Network } from 'https://cdn.jsdelivr.net/npm/vis-network/standalone/esm/vis-network.min.js'
|
|
359
|
-
|
|
360
|
-
async function main() {
|
|
361
|
-
const res = await fetch('./graph.json')
|
|
362
|
-
const { nodes, edges } = await res.json()
|
|
363
|
-
const container = document.getElementById('graph')
|
|
364
|
-
|
|
365
|
-
const network = new Network(
|
|
366
|
-
container,
|
|
367
|
-
{ nodes, edges },
|
|
368
|
-
{
|
|
369
|
-
layout: { hierarchical: { direction: 'UD', sortMethod: 'directed' } },
|
|
370
|
-
nodes: { shape: 'box', font: { face: 'monospace' } },
|
|
371
|
-
edges: { arrows: 'to' },
|
|
372
|
-
physics: false,
|
|
373
|
-
},
|
|
374
|
-
)
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
main()
|
|
378
|
-
<\/script>
|
|
379
|
-
<style>
|
|
380
|
-
html, body, #graph { height: 100%; margin: 0; }
|
|
381
|
-
</style>
|
|
382
|
-
</head>
|
|
383
|
-
<body>
|
|
384
|
-
<div id="graph"></div>
|
|
385
|
-
</body>
|
|
386
|
-
</html>
|
|
387
|
-
`;
|
|
388
|
-
async function serve(root) {
|
|
389
|
-
const server = http.createServer((req, res) => {
|
|
390
|
-
return handler(req, res, {
|
|
391
|
-
public: root,
|
|
392
|
-
cleanUrls: true
|
|
393
|
-
});
|
|
394
|
-
});
|
|
395
|
-
server.listen(0, async () => {
|
|
396
|
-
const { port } = server.address();
|
|
397
|
-
console.log(`Running on http://localhost:${port}/graph.html`);
|
|
398
|
-
await open(`http://localhost:${port}/graph.html`);
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
const graphPlugin = definePlugin({
|
|
402
|
-
name: "graph",
|
|
403
|
-
install(ctx, options) {
|
|
404
|
-
if (!options) throw new Error("Graph plugin requires options.root and options.mode");
|
|
405
|
-
ctx.on("files:writing:start", async (files) => {
|
|
406
|
-
const root = options.root;
|
|
407
|
-
const graph = getGraph({
|
|
408
|
-
files,
|
|
409
|
-
root
|
|
410
|
-
});
|
|
411
|
-
if (!graph) return;
|
|
412
|
-
const graphFile = createFile({
|
|
413
|
-
baseName: "graph.json",
|
|
414
|
-
path: path.join(root, "graph.json"),
|
|
415
|
-
sources: [{
|
|
416
|
-
name: "graph",
|
|
417
|
-
value: JSON.stringify(graph, null, 2)
|
|
418
|
-
}],
|
|
419
|
-
imports: [],
|
|
420
|
-
exports: []
|
|
421
|
-
});
|
|
422
|
-
const graphHtmlFile = createFile({
|
|
423
|
-
baseName: "graph.html",
|
|
424
|
-
path: path.join(root, "graph.html"),
|
|
425
|
-
sources: [{
|
|
426
|
-
name: "graph",
|
|
427
|
-
value: html
|
|
428
|
-
}],
|
|
429
|
-
imports: [],
|
|
430
|
-
exports: []
|
|
431
|
-
});
|
|
432
|
-
await ctx.addFile(graphFile, graphHtmlFile);
|
|
433
|
-
if (options.open) await serve(root);
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
|
|
438
303
|
//#endregion
|
|
439
304
|
//#region src/plugins/loggerPlugin.ts
|
|
440
|
-
function normalizeAddress(address) {
|
|
441
|
-
return {
|
|
442
|
-
host: address.address === "::" ? "127.0.0.1" : address.address,
|
|
443
|
-
port: address.port
|
|
444
|
-
};
|
|
445
|
-
}
|
|
446
|
-
function serializeFile(file) {
|
|
447
|
-
return {
|
|
448
|
-
path: file.path,
|
|
449
|
-
baseName: file.baseName,
|
|
450
|
-
name: "name" in file ? file.name : void 0,
|
|
451
|
-
extname: "extname" in file ? file.extname : void 0
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
305
|
function pluralize(word, count) {
|
|
455
306
|
return `${count} ${word}${count === 1 ? "" : "s"}`;
|
|
456
307
|
}
|
|
@@ -458,7 +309,7 @@ const DEFAULT_PROGRESS_BAR_SIZE = 30;
|
|
|
458
309
|
const loggerPlugin = definePlugin({
|
|
459
310
|
name: "logger",
|
|
460
311
|
install(ctx, options = {}) {
|
|
461
|
-
const {
|
|
312
|
+
const { progress = true } = options;
|
|
462
313
|
const state = {
|
|
463
314
|
spinner: clack.spinner(),
|
|
464
315
|
isSpinning: false,
|
|
@@ -467,70 +318,24 @@ const loggerPlugin = definePlugin({
|
|
|
467
318
|
function formatPath(path) {
|
|
468
319
|
return relative(process.cwd(), path);
|
|
469
320
|
}
|
|
470
|
-
let server;
|
|
471
|
-
let wss;
|
|
472
|
-
const broadcast = (event, payload) => {
|
|
473
|
-
if (!wss) return;
|
|
474
|
-
const message = JSON.stringify({
|
|
475
|
-
event,
|
|
476
|
-
payload
|
|
477
|
-
});
|
|
478
|
-
for (const client of wss.clients) if (client.readyState === WebSocket.OPEN) client.send(message);
|
|
479
|
-
};
|
|
480
|
-
if (websocket) {
|
|
481
|
-
const { host = "127.0.0.1", port = 0 } = typeof websocket === "boolean" ? {} : websocket;
|
|
482
|
-
server = http.createServer();
|
|
483
|
-
wss = new WebSocketServer({ server });
|
|
484
|
-
server.listen(port, host, () => {
|
|
485
|
-
const addressInfo = server === null || server === void 0 ? void 0 : server.address();
|
|
486
|
-
if (addressInfo && typeof addressInfo === "object") {
|
|
487
|
-
const { host: resolvedHost, port: resolvedPort } = normalizeAddress(addressInfo);
|
|
488
|
-
const url = `ws://${resolvedHost}:${resolvedPort}`;
|
|
489
|
-
clack.log.info(`${pc.blue("ℹ")} Logger websocket listening on ${url}`);
|
|
490
|
-
broadcast("websocket:ready", { url });
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
wss.on("connection", (socket) => {
|
|
494
|
-
clack.log.info(`${pc.blue("ℹ")} Logger websocket client connected`);
|
|
495
|
-
socket.send(JSON.stringify({
|
|
496
|
-
event: "welcome",
|
|
497
|
-
payload: {
|
|
498
|
-
message: "Connected to Fabric log stream",
|
|
499
|
-
timestamp: Date.now()
|
|
500
|
-
}
|
|
501
|
-
}));
|
|
502
|
-
});
|
|
503
|
-
wss.on("error", (error) => {
|
|
504
|
-
clack.log.error(`${pc.red("✗")} Logger websocket error: ${error.message}`);
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
321
|
ctx.on("lifecycle:start", async () => {
|
|
508
|
-
clack.intro(`${
|
|
509
|
-
broadcast("lifecycle:start", { timestamp: Date.now() });
|
|
322
|
+
clack.intro(`${styleText("blue", "Fabric")} ${styleText("dim", "Starting run")}`);
|
|
510
323
|
});
|
|
511
324
|
ctx.on("lifecycle:render", async () => {
|
|
512
|
-
clack.log.info(`${
|
|
513
|
-
broadcast("lifecycle:render", { timestamp: Date.now() });
|
|
325
|
+
clack.log.info(`${styleText("blue", "ℹ")} Rendering application graph`);
|
|
514
326
|
});
|
|
515
327
|
ctx.on("files:added", async (files) => {
|
|
516
328
|
if (!files.length) return;
|
|
517
|
-
clack.log.info(`${
|
|
518
|
-
broadcast("files:added", { files: files.map(serializeFile) });
|
|
329
|
+
clack.log.info(`${styleText("blue", "ℹ")} Queued ${pluralize("file", files.length)}`);
|
|
519
330
|
});
|
|
520
331
|
ctx.on("file:resolve:path", async (file) => {
|
|
521
|
-
clack.log.step(`Resolving path for ${
|
|
522
|
-
broadcast("file:resolve:path", { file: serializeFile(file) });
|
|
332
|
+
clack.log.step(`Resolving path for ${styleText("dim", formatPath(file.path))}`);
|
|
523
333
|
});
|
|
524
334
|
ctx.on("file:resolve:name", async (file) => {
|
|
525
|
-
clack.log.step(`Resolving name for ${
|
|
526
|
-
broadcast("file:resolve:name", { file: serializeFile(file) });
|
|
335
|
+
clack.log.step(`Resolving name for ${styleText("dim", formatPath(file.path))}`);
|
|
527
336
|
});
|
|
528
337
|
ctx.on("files:processing:start", async (files) => {
|
|
529
|
-
clack.log.step(`Processing ${
|
|
530
|
-
broadcast("files:processing:start", {
|
|
531
|
-
total: files.length,
|
|
532
|
-
timestamp: Date.now()
|
|
533
|
-
});
|
|
338
|
+
clack.log.step(`Processing ${styleText("green", pluralize("file", files.length))}`);
|
|
534
339
|
if (progress) {
|
|
535
340
|
state.progressBar = clack.progress({
|
|
536
341
|
style: "block",
|
|
@@ -541,80 +346,35 @@ const loggerPlugin = definePlugin({
|
|
|
541
346
|
}
|
|
542
347
|
});
|
|
543
348
|
ctx.on("file:processing:start", async (file, index, total) => {
|
|
544
|
-
if (!state.progressBar) clack.log.step(`Processing ${
|
|
545
|
-
broadcast("file:processing:start", {
|
|
546
|
-
index,
|
|
547
|
-
total,
|
|
548
|
-
file: serializeFile(file)
|
|
549
|
-
});
|
|
349
|
+
if (!state.progressBar) clack.log.step(`Processing ${styleText("dim", `[${index + 1}/${total}]`)} ${formatPath(file.path)}`);
|
|
550
350
|
});
|
|
551
351
|
ctx.on("file:processing:update", async ({ processed, total, percentage, file }) => {
|
|
552
|
-
broadcast("file:processing:update", {
|
|
553
|
-
processed,
|
|
554
|
-
total,
|
|
555
|
-
percentage,
|
|
556
|
-
file: serializeFile(file)
|
|
557
|
-
});
|
|
558
352
|
if (state.progressBar) state.progressBar.advance(void 0, `Writing ${formatPath(file.path)}`);
|
|
559
353
|
else {
|
|
560
354
|
const formattedPercentage = Number.isFinite(percentage) ? percentage.toFixed(1) : "0.0";
|
|
561
|
-
clack.log.step(`Progress ${
|
|
355
|
+
clack.log.step(`Progress ${styleText("green", `${formattedPercentage}%`)} ${styleText("dim", `(${processed}/${total})`)} → ${formatPath(file.path)}`);
|
|
562
356
|
}
|
|
563
357
|
});
|
|
564
358
|
ctx.on("file:processing:end", async (file, index, total) => {
|
|
565
|
-
if (state.progressBar) state.progressBar.message(`${
|
|
566
|
-
else clack.log.success(`${
|
|
567
|
-
broadcast("file:processing:end", {
|
|
568
|
-
index,
|
|
569
|
-
total,
|
|
570
|
-
file: serializeFile(file)
|
|
571
|
-
});
|
|
572
|
-
});
|
|
573
|
-
ctx.on("files:writing:start", async (files) => {
|
|
574
|
-
broadcast("files:writing:start", { files: files.map(serializeFile) });
|
|
575
|
-
});
|
|
576
|
-
ctx.on("files:writing:end", async (files) => {
|
|
577
|
-
broadcast("files:writing:end", { files: files.map(serializeFile) });
|
|
359
|
+
if (state.progressBar) state.progressBar.message(`${styleText("green", "✓")} Finished ${styleText("dim", `[${index + 1}/${total}]`)} ${formatPath(file.path)}`);
|
|
360
|
+
else clack.log.success(`${styleText("green", "✓")} Finished ${styleText("dim", `[${index + 1}/${total}]`)} ${formatPath(file.path)}`);
|
|
578
361
|
});
|
|
579
362
|
ctx.on("files:processing:end", async (files) => {
|
|
580
363
|
if (state.progressBar) {
|
|
581
|
-
state.progressBar.stop(`${
|
|
364
|
+
state.progressBar.stop(`${styleText("green", "✓")} Processed ${pluralize("file", files.length)}`);
|
|
582
365
|
state.progressBar = void 0;
|
|
583
|
-
} else clack.log.success(`${
|
|
584
|
-
broadcast("files:processing:end", {
|
|
585
|
-
total: files.length,
|
|
586
|
-
timestamp: Date.now()
|
|
587
|
-
});
|
|
366
|
+
} else clack.log.success(`${styleText("green", "✓")} Processed ${pluralize("file", files.length)}`);
|
|
588
367
|
});
|
|
589
368
|
ctx.on("lifecycle:end", async () => {
|
|
590
369
|
if (state.progressBar) {
|
|
591
370
|
state.progressBar.stop();
|
|
592
371
|
state.progressBar = void 0;
|
|
593
372
|
}
|
|
594
|
-
clack.outro(`${
|
|
595
|
-
broadcast("lifecycle:end", { timestamp: Date.now() });
|
|
596
|
-
const closures = [];
|
|
597
|
-
if (wss) {
|
|
598
|
-
const wsServer = wss;
|
|
599
|
-
closures.push(new Promise((resolve) => {
|
|
600
|
-
for (const client of wsServer.clients) client.close();
|
|
601
|
-
wsServer.close(() => resolve());
|
|
602
|
-
}));
|
|
603
|
-
}
|
|
604
|
-
if (server) {
|
|
605
|
-
const httpServer = server;
|
|
606
|
-
closures.push(new Promise((resolve) => {
|
|
607
|
-
httpServer.close(() => resolve());
|
|
608
|
-
}));
|
|
609
|
-
}
|
|
610
|
-
if (closures.length) {
|
|
611
|
-
await Promise.allSettled(closures);
|
|
612
|
-
clack.log.info(`${pc.blue("ℹ")} Logger websocket closed`);
|
|
613
|
-
}
|
|
373
|
+
clack.outro(`${styleText("blue", "Fabric")} ${styleText("dim", "completed")}`);
|
|
614
374
|
});
|
|
615
375
|
}
|
|
616
376
|
});
|
|
617
377
|
|
|
618
378
|
//#endregion
|
|
619
|
-
export { barrelPlugin, definePlugin, fsPlugin, fsxPlugin,
|
|
379
|
+
export { barrelPlugin, definePlugin, fsPlugin, fsxPlugin, loggerPlugin };
|
|
620
380
|
//# sourceMappingURL=plugins.js.map
|