@macrulez/devtoolz 0.4.1 → 0.4.3
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 +16 -1
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/image-batch/cli.js +16 -0
- package/dist/commands/image-batch/cli.js.map +1 -1
- package/dist/commands/image-batch/config.d.ts +1 -0
- package/dist/commands/image-batch/config.js +11 -0
- package/dist/commands/image-batch/config.js.map +1 -1
- package/dist/commands/image-batch/run.d.ts +5 -1
- package/dist/commands/image-batch/run.js +7 -0
- package/dist/commands/image-batch/run.js.map +1 -1
- package/dist/commands/image-hash/sharp-loader.d.ts +3 -0
- package/dist/commands/image-hash/sharp-loader.js.map +1 -1
- package/dist/commands/ui/cli.d.ts +2 -0
- package/dist/commands/ui/cli.js +78 -0
- package/dist/commands/ui/cli.js.map +1 -0
- package/dist/commands/ui/fs-routes.d.ts +7 -0
- package/dist/commands/ui/fs-routes.js +135 -0
- package/dist/commands/ui/fs-routes.js.map +1 -0
- package/dist/commands/ui/http.d.ts +41 -0
- package/dist/commands/ui/http.js +81 -0
- package/dist/commands/ui/http.js.map +1 -0
- package/dist/commands/ui/jobs.d.ts +15 -0
- package/dist/commands/ui/jobs.js +73 -0
- package/dist/commands/ui/jobs.js.map +1 -0
- package/dist/commands/ui/modules/checks.d.ts +28 -0
- package/dist/commands/ui/modules/checks.js +556 -0
- package/dist/commands/ui/modules/checks.js.map +1 -0
- package/dist/commands/ui/modules/cleanup.d.ts +2 -0
- package/dist/commands/ui/modules/cleanup.js +305 -0
- package/dist/commands/ui/modules/cleanup.js.map +1 -0
- package/dist/commands/ui/modules/image-batch-backups.d.ts +2 -0
- package/dist/commands/ui/modules/image-batch-backups.js +116 -0
- package/dist/commands/ui/modules/image-batch-backups.js.map +1 -0
- package/dist/commands/ui/modules/image-batch-manage.d.ts +2 -0
- package/dist/commands/ui/modules/image-batch-manage.js +245 -0
- package/dist/commands/ui/modules/image-batch-manage.js.map +1 -0
- package/dist/commands/ui/modules/image-batch.d.ts +2 -0
- package/dist/commands/ui/modules/image-batch.js +225 -0
- package/dist/commands/ui/modules/image-batch.js.map +1 -0
- package/dist/commands/ui/modules/image-hash.d.ts +2 -0
- package/dist/commands/ui/modules/image-hash.js +158 -0
- package/dist/commands/ui/modules/image-hash.js.map +1 -0
- package/dist/commands/ui/modules/index.d.ts +2 -0
- package/dist/commands/ui/modules/index.js +11 -0
- package/dist/commands/ui/modules/index.js.map +1 -0
- package/dist/commands/ui/open-browser.d.ts +1 -0
- package/dist/commands/ui/open-browser.js +18 -0
- package/dist/commands/ui/open-browser.js.map +1 -0
- package/dist/commands/ui/scan.d.ts +20 -0
- package/dist/commands/ui/scan.js +57 -0
- package/dist/commands/ui/scan.js.map +1 -0
- package/dist/commands/ui/server.d.ts +18 -0
- package/dist/commands/ui/server.js +196 -0
- package/dist/commands/ui/server.js.map +1 -0
- package/dist/ui/assets/ChecksPage-Ia4QJkV3.js +1 -0
- package/dist/ui/assets/ChecksPage-VewKhd5A.css +1 -0
- package/dist/ui/assets/CleanupPage-DqqrgWSI.js +4 -0
- package/dist/ui/assets/CleanupPage-nxJE8S0P.css +1 -0
- package/dist/ui/assets/FolderBrowser-Cdzt7edI.js +1 -0
- package/dist/ui/assets/FolderBrowser-CkH9R4jg.css +1 -0
- package/dist/ui/assets/ImageBatchPage-9HgS9uVf.js +4 -0
- package/dist/ui/assets/ImageBatchPage-EhlvnXbP.css +1 -0
- package/dist/ui/assets/ImageHashPage-BT4S8t3Y.css +1 -0
- package/dist/ui/assets/ImageHashPage-C0ltmpOF.js +1 -0
- package/dist/ui/assets/SourcePicker-6fQmtLgo.css +1 -0
- package/dist/ui/assets/SourcePicker-xk00AG2e.js +1 -0
- package/dist/ui/assets/UiSegmented-BT3dOelo.css +1 -0
- package/dist/ui/assets/UiSegmented-CsTRUZoX.js +1 -0
- package/dist/ui/assets/core-DVezgdzc.js +12 -0
- package/dist/ui/assets/css-Z72CF80r.js +1 -0
- package/dist/ui/assets/engine-javascript-CNmxVhbB.js +141 -0
- package/dist/ui/assets/github-dark-DHJKELXO.js +1 -0
- package/dist/ui/assets/github-light-DAi9KRSo.js +1 -0
- package/dist/ui/assets/highlight-DT7vvdYt.js +2 -0
- package/dist/ui/assets/html-BlS82ilI.js +1 -0
- package/dist/ui/assets/index-Ch5kTxCO.css +1 -0
- package/dist/ui/assets/index-D8H-zVzo.js +11 -0
- package/dist/ui/assets/javascript-wDzz0qaB.js +1 -0
- package/dist/ui/assets/json-Cp-IABpG.js +1 -0
- package/dist/ui/assets/jsx-g9-lgVsj.js +1 -0
- package/dist/ui/assets/markdown-Cvjx9yec.js +1 -0
- package/dist/ui/assets/scss-Cw6XMfVs.js +1 -0
- package/dist/ui/assets/tsx-COt5Ahok.js +1 -0
- package/dist/ui/assets/typescript-BPQ3VLAy.js +1 -0
- package/dist/ui/assets/useCopy-i_vlQfC-.js +1 -0
- package/dist/ui/assets/vue-CwSeJimo.js +1 -0
- package/dist/ui/assets/yaml-Buea-lGh.js +1 -0
- package/dist/ui/index.html +17 -0
- package/package.json +17 -4
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, statSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import { ALL_TYPES, DEFAULT_BLURHASH_COMPONENTS, DEFAULT_EXPORT_NAME, DEFAULT_HAZEHASH_BUDGET, DEFAULT_IMAGE_EXTENSIONS, ImageHashUsageError, MAX_HAZEHASH_BUDGET, MIN_HAZEHASH_BUDGET, OUTPUT_FORMATS, parseBudget, parseComponents, parseFormat, parseTypes, validateExportName, withUpperCaseVariants, } from '../../image-hash/core.js';
|
|
4
|
+
import { runImageHash } from '../../image-hash/run.js';
|
|
5
|
+
import { forgetSharp, findSharp, resolveUserPath } from '../fs-routes.js';
|
|
6
|
+
import { HttpError, asObject, sendJson, } from '../http.js';
|
|
7
|
+
import { startJob } from '../jobs.js';
|
|
8
|
+
import { scanHandler, stringList } from '../scan.js';
|
|
9
|
+
const TYPE_INFO = {
|
|
10
|
+
hazehash: {
|
|
11
|
+
title: 'Hazehash',
|
|
12
|
+
description: 'A compact placeholder (7–48 bytes) that keeps the aspect ratio and, when needed, alpha.',
|
|
13
|
+
},
|
|
14
|
+
blurhash: {
|
|
15
|
+
title: 'Blurhash',
|
|
16
|
+
description: 'A short string that decodes to a blurred preview.',
|
|
17
|
+
},
|
|
18
|
+
thumbhash: {
|
|
19
|
+
title: 'Thumbhash',
|
|
20
|
+
description: 'A blurred preview that also keeps the aspect ratio and transparency.',
|
|
21
|
+
},
|
|
22
|
+
color: { title: 'Dominant color', description: 'The most common color as #rrggbb.' },
|
|
23
|
+
preview: { title: 'Tiny preview', description: 'A very small PNG as a data URI.' },
|
|
24
|
+
};
|
|
25
|
+
function usage(task) {
|
|
26
|
+
try {
|
|
27
|
+
return task();
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (error instanceof ImageHashUsageError)
|
|
31
|
+
throw new HttpError(400, error.message);
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function baseOf(paths, cwd) {
|
|
36
|
+
const first = paths[0];
|
|
37
|
+
if (first === undefined)
|
|
38
|
+
return cwd;
|
|
39
|
+
const abs = resolveUserPath(first, cwd);
|
|
40
|
+
const stat = statSync(abs, { throwIfNoEntry: false });
|
|
41
|
+
return stat?.isDirectory() ? abs : dirname(abs);
|
|
42
|
+
}
|
|
43
|
+
async function startRun(ctx) {
|
|
44
|
+
const body = asObject(await ctx.readBody());
|
|
45
|
+
const cwd = ctx.server.cwd;
|
|
46
|
+
const paths = stringList(body.paths, 'paths');
|
|
47
|
+
if (paths.length === 0)
|
|
48
|
+
throw new HttpError(400, 'add at least one folder or image');
|
|
49
|
+
const types = usage(() => parseTypes(stringList(body.types ?? ['both'], 'types').join(',')));
|
|
50
|
+
const components = typeof body.components === 'string'
|
|
51
|
+
? usage(() => parseComponents(body.components))
|
|
52
|
+
: undefined;
|
|
53
|
+
const budget = body.budget !== undefined ? usage(() => parseBudget(String(body.budget))) : undefined;
|
|
54
|
+
const format = usage(() => parseFormat(typeof body.format === 'string' ? body.format : 'json'));
|
|
55
|
+
const exportName = usage(() => validateExportName(typeof body.exportName === 'string' ? body.exportName : DEFAULT_EXPORT_NAME));
|
|
56
|
+
const ignoreGlobs = body.ignoreGlobs !== undefined ? stringList(body.ignoreGlobs, 'ignoreGlobs') : [];
|
|
57
|
+
const base = baseOf(paths, cwd);
|
|
58
|
+
const installSharp = body.installSharp === true;
|
|
59
|
+
const id = startJob(async (progress) => {
|
|
60
|
+
try {
|
|
61
|
+
const report = await runImageHash({
|
|
62
|
+
paths: paths.map((path) => resolveUserPath(path, cwd)),
|
|
63
|
+
cwd,
|
|
64
|
+
types,
|
|
65
|
+
recursive: body.recursive === true,
|
|
66
|
+
...(components ? { components } : {}),
|
|
67
|
+
...(budget !== undefined ? { budget } : {}),
|
|
68
|
+
format,
|
|
69
|
+
exportName,
|
|
70
|
+
keyBase: base,
|
|
71
|
+
ignoreGlobs,
|
|
72
|
+
assumeYes: installSharp,
|
|
73
|
+
concurrency: 4,
|
|
74
|
+
onProgress: progress,
|
|
75
|
+
});
|
|
76
|
+
forgetSharp();
|
|
77
|
+
const entries = report.entries.map((entry) => ({
|
|
78
|
+
...entry,
|
|
79
|
+
path: resolve(base, entry.file),
|
|
80
|
+
}));
|
|
81
|
+
return {
|
|
82
|
+
base,
|
|
83
|
+
filesScanned: report.filesScanned,
|
|
84
|
+
cached: report.cached,
|
|
85
|
+
errors: report.errors,
|
|
86
|
+
entries,
|
|
87
|
+
output: report.stdout,
|
|
88
|
+
format,
|
|
89
|
+
exitCode: report.exitCode,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
if (error instanceof ImageHashUsageError) {
|
|
94
|
+
throw new Error(error.message, { cause: error });
|
|
95
|
+
}
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
sendJson(ctx.res, 202, { jobId: id });
|
|
100
|
+
}
|
|
101
|
+
async function saveOutput(ctx) {
|
|
102
|
+
const body = asObject(await ctx.readBody());
|
|
103
|
+
if (typeof body.path !== 'string' || body.path.trim() === '') {
|
|
104
|
+
throw new HttpError(400, 'give a file path');
|
|
105
|
+
}
|
|
106
|
+
if (typeof body.content !== 'string')
|
|
107
|
+
throw new HttpError(400, 'content must be a string');
|
|
108
|
+
const path = resolveUserPath(body.path, ctx.server.cwd);
|
|
109
|
+
if (statSync(path, { throwIfNoEntry: false })?.isDirectory()) {
|
|
110
|
+
throw new HttpError(400, `${path} is a folder`);
|
|
111
|
+
}
|
|
112
|
+
if (existsSync(path) && body.overwrite !== true) {
|
|
113
|
+
sendJson(ctx.res, 409, { error: `${path} already exists`, exists: true, path });
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
117
|
+
writeFileSync(path, body.content);
|
|
118
|
+
sendJson(ctx.res, 200, { path });
|
|
119
|
+
}
|
|
120
|
+
const routes = [
|
|
121
|
+
{
|
|
122
|
+
method: 'GET',
|
|
123
|
+
path: '/api/image-hash/options',
|
|
124
|
+
handler: ({ res, server }) => {
|
|
125
|
+
sendJson(res, 200, {
|
|
126
|
+
types: ALL_TYPES.map((id) => ({ id, ...TYPE_INFO[id] })),
|
|
127
|
+
formats: OUTPUT_FORMATS,
|
|
128
|
+
budget: {
|
|
129
|
+
min: MIN_HAZEHASH_BUDGET,
|
|
130
|
+
max: MAX_HAZEHASH_BUDGET,
|
|
131
|
+
default: DEFAULT_HAZEHASH_BUDGET,
|
|
132
|
+
},
|
|
133
|
+
components: {
|
|
134
|
+
default: `${DEFAULT_BLURHASH_COMPONENTS.x}x${DEFAULT_BLURHASH_COMPONENTS.y}`,
|
|
135
|
+
auto: true,
|
|
136
|
+
},
|
|
137
|
+
exportName: DEFAULT_EXPORT_NAME,
|
|
138
|
+
extensions: DEFAULT_IMAGE_EXTENSIONS,
|
|
139
|
+
sharp: findSharp(server.cwd) !== null,
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{ method: 'POST', path: '/api/image-hash/run', handler: startRun },
|
|
144
|
+
{
|
|
145
|
+
method: 'POST',
|
|
146
|
+
path: '/api/image-hash/scan',
|
|
147
|
+
handler: scanHandler(withUpperCaseVariants(DEFAULT_IMAGE_EXTENSIONS)),
|
|
148
|
+
},
|
|
149
|
+
{ method: 'POST', path: '/api/image-hash/save', handler: saveOutput },
|
|
150
|
+
];
|
|
151
|
+
export const imageHashModule = {
|
|
152
|
+
id: 'image-hash',
|
|
153
|
+
title: 'Image Hash',
|
|
154
|
+
description: 'Blurhash, thumbhash and hazehash placeholders for your images.',
|
|
155
|
+
status: 'available',
|
|
156
|
+
routes,
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=image-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-hash.js","sourceRoot":"","sources":["../../../../src/commands/ui/modules/image-hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EACL,SAAS,EACT,2BAA2B,EAC3B,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,eAAe,EACf,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,qBAAqB,GAEtB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;A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AI;iBACX;gBACD,UAAU,EAAE,mBAAmB;gBAC/B,UAAU,EAAE,wBAAwB;gBACpC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI;aACtC,CAAC,CAAA;QACJ,CAAC;KACF;IACD,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,QAAQ,EAAE;IAClE;QACE,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,sBAAsB;QAC5B,OAAO,EAAE,WAAW,CAAC,qBAAqB,CAAC,wBAAwB,CAAC,CAAC;KACtE;IACD,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,UAAU,EAAE;CACtE,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAa;IACvC,EAAE,EAAE,YAAY;IAChB,KAAK,EAAE,YAAY;IACnB,WAAW,EAAE,gEAAgE;IAC7E,MAAM,EAAE,WAAW;IACnB,MAAM;CACP,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { checksModule } from './checks.js';
|
|
2
|
+
import { cleanupModule } from './cleanup.js';
|
|
3
|
+
import { imageBatchModule } from './image-batch.js';
|
|
4
|
+
import { imageHashModule } from './image-hash.js';
|
|
5
|
+
export const UI_MODULES = [
|
|
6
|
+
checksModule,
|
|
7
|
+
cleanupModule,
|
|
8
|
+
imageHashModule,
|
|
9
|
+
imageBatchModule,
|
|
10
|
+
];
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/ui/modules/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,CAAC,MAAM,UAAU,GAAe;IACpC,YAAY;IACZ,aAAa;IACb,eAAe;IACf,gBAAgB;CACjB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function openBrowser(url: string): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
export function openBrowser(url) {
|
|
3
|
+
const [command, args] = process.platform === 'win32'
|
|
4
|
+
? ['cmd', ['/c', 'start', '', url]]
|
|
5
|
+
: process.platform === 'darwin'
|
|
6
|
+
? ['open', [url]]
|
|
7
|
+
: ['xdg-open', [url]];
|
|
8
|
+
try {
|
|
9
|
+
const child = spawn(command, args, { detached: true, stdio: 'ignore', windowsHide: true });
|
|
10
|
+
child.on('error', () => undefined);
|
|
11
|
+
child.unref();
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=open-browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-browser.js","sourceRoot":"","sources":["../../../src/commands/ui/open-browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,GACnB,OAAO,CAAC,QAAQ,KAAK,OAAO;QAC1B,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;QACnC,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ;YAC7B,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;YACjB,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;IAC3B,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAA;QAC1F,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;QAClC,KAAK,CAAC,KAAK,EAAE,CAAA;QACb,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type RouteContext } from './http.js';
|
|
2
|
+
export interface ScanSource {
|
|
3
|
+
path: string;
|
|
4
|
+
exists: boolean;
|
|
5
|
+
kind: 'folder' | 'file' | 'missing';
|
|
6
|
+
files: number;
|
|
7
|
+
folders: number;
|
|
8
|
+
bytes: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ScanResult {
|
|
11
|
+
sources: ScanSource[];
|
|
12
|
+
total: {
|
|
13
|
+
files: number;
|
|
14
|
+
folders: number;
|
|
15
|
+
bytes: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare function stringList(value: unknown, name: string): string[];
|
|
19
|
+
export declare function scanPaths(paths: string[], cwd: string, extensions: string[], recursive: boolean): ScanResult;
|
|
20
|
+
export declare function scanHandler(extensions: string[]): (ctx: RouteContext) => Promise<void>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { statSync } from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { walk } from '../../utils/walk.js';
|
|
4
|
+
import { HttpError, asObject, sendJson } from './http.js';
|
|
5
|
+
import { resolveUserPath } from './fs-routes.js';
|
|
6
|
+
export function stringList(value, name) {
|
|
7
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== 'string')) {
|
|
8
|
+
throw new HttpError(400, `${name} must be a list of strings`);
|
|
9
|
+
}
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
export function scanPaths(paths, cwd, extensions, recursive) {
|
|
13
|
+
const seen = new Map();
|
|
14
|
+
const sources = [];
|
|
15
|
+
for (const path of paths) {
|
|
16
|
+
const abs = resolveUserPath(path, cwd);
|
|
17
|
+
const stat = statSync(abs, { throwIfNoEntry: false });
|
|
18
|
+
if (!stat) {
|
|
19
|
+
sources.push({ path, exists: false, kind: 'missing', files: 0, folders: 0, bytes: 0 });
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const files = walk([abs], { cwd, extensions, recursive });
|
|
23
|
+
const directories = new Set();
|
|
24
|
+
let bytes = 0;
|
|
25
|
+
for (const file of files) {
|
|
26
|
+
const size = statSync(file, { throwIfNoEntry: false })?.size ?? 0;
|
|
27
|
+
bytes += size;
|
|
28
|
+
directories.add(dirname(file));
|
|
29
|
+
seen.set(file, size);
|
|
30
|
+
}
|
|
31
|
+
sources.push({
|
|
32
|
+
path,
|
|
33
|
+
exists: true,
|
|
34
|
+
kind: stat.isDirectory() ? 'folder' : 'file',
|
|
35
|
+
files: files.length,
|
|
36
|
+
folders: directories.size,
|
|
37
|
+
bytes,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const allFolders = new Set([...seen.keys()].map((file) => dirname(file)));
|
|
41
|
+
return {
|
|
42
|
+
sources,
|
|
43
|
+
total: {
|
|
44
|
+
files: seen.size,
|
|
45
|
+
folders: allFolders.size,
|
|
46
|
+
bytes: [...seen.values()].reduce((sum, size) => sum + size, 0),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export function scanHandler(extensions) {
|
|
51
|
+
return async (ctx) => {
|
|
52
|
+
const body = asObject(await ctx.readBody());
|
|
53
|
+
const paths = stringList(body.paths, 'paths');
|
|
54
|
+
sendJson(ctx.res, 200, scanPaths(paths, ctx.server.cwd, extensions, body.recursive === true));
|
|
55
|
+
};
|
|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AAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,EAAE,CAAC,CAAC;SAC/D;KACF,CAAA;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,UAAoB;IAC9C,OAAO,KAAK,EAAE,GAAiB,EAAiB,EAAE;QAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC3C,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAC7C,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAA;IAC/F,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface UiServerHandle {
|
|
2
|
+
url: string;
|
|
3
|
+
port: number;
|
|
4
|
+
host: string;
|
|
5
|
+
token: string;
|
|
6
|
+
close: () => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export interface StartUiOptions {
|
|
9
|
+
cwd: string;
|
|
10
|
+
host?: string;
|
|
11
|
+
port?: number;
|
|
12
|
+
token?: string;
|
|
13
|
+
staticDir?: string;
|
|
14
|
+
version?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function defaultStaticDir(): string;
|
|
17
|
+
export declare function cookieName(port: number): string;
|
|
18
|
+
export declare function startUiServer(options: StartUiOptions): Promise<UiServerHandle>;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
3
|
+
import { createServer } from 'node:http';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { extname, join, resolve, sep } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { fsRoutes } from './fs-routes.js';
|
|
8
|
+
import { HttpError, matchRoute, readJsonBody, sendBytes, sendJson, } from './http.js';
|
|
9
|
+
import { jobRoutes } from './jobs.js';
|
|
10
|
+
import { UI_MODULES } from './modules/index.js';
|
|
11
|
+
const CONTENT_TYPES = {
|
|
12
|
+
'.html': 'text/html; charset=utf-8',
|
|
13
|
+
'.js': 'text/javascript; charset=utf-8',
|
|
14
|
+
'.css': 'text/css; charset=utf-8',
|
|
15
|
+
'.json': 'application/json; charset=utf-8',
|
|
16
|
+
'.svg': 'image/svg+xml',
|
|
17
|
+
'.png': 'image/png',
|
|
18
|
+
'.ico': 'image/x-icon',
|
|
19
|
+
'.woff2': 'font/woff2',
|
|
20
|
+
'.map': 'application/json; charset=utf-8',
|
|
21
|
+
};
|
|
22
|
+
export function defaultStaticDir() {
|
|
23
|
+
const candidates = ['../../ui', '../../../dist/ui'].map((relative) => fileURLToPath(new URL(relative, import.meta.url)));
|
|
24
|
+
return (candidates.find((path) => existsSync(join(path, 'index.html'))) ?? candidates[0]);
|
|
25
|
+
}
|
|
26
|
+
export function cookieName(port) {
|
|
27
|
+
return `devtoolz-ui-${port}`;
|
|
28
|
+
}
|
|
29
|
+
function readCookie(req, name) {
|
|
30
|
+
const header = req.headers.cookie;
|
|
31
|
+
if (!header)
|
|
32
|
+
return undefined;
|
|
33
|
+
for (const part of header.split(';')) {
|
|
34
|
+
const index = part.indexOf('=');
|
|
35
|
+
if (index > 0 && part.slice(0, index).trim() === name)
|
|
36
|
+
return part.slice(index + 1).trim();
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
function sameToken(given, expected) {
|
|
41
|
+
if (given === undefined)
|
|
42
|
+
return false;
|
|
43
|
+
const a = Buffer.from(given);
|
|
44
|
+
const b = Buffer.from(expected);
|
|
45
|
+
return a.length === b.length && timingSafeEqual(a, b);
|
|
46
|
+
}
|
|
47
|
+
function allRoutes() {
|
|
48
|
+
return [
|
|
49
|
+
...fsRoutes,
|
|
50
|
+
...jobRoutes,
|
|
51
|
+
...UI_MODULES.flatMap((module) => module.routes),
|
|
52
|
+
{
|
|
53
|
+
method: 'GET',
|
|
54
|
+
path: '/api/status',
|
|
55
|
+
handler: ({ res, server }) => {
|
|
56
|
+
sendJson(res, 200, {
|
|
57
|
+
version: server.version,
|
|
58
|
+
cwd: server.cwd,
|
|
59
|
+
home: homedir(),
|
|
60
|
+
platform: process.platform,
|
|
61
|
+
modules: UI_MODULES.map(({ id, title, description, status }) => ({
|
|
62
|
+
id,
|
|
63
|
+
title,
|
|
64
|
+
description,
|
|
65
|
+
status,
|
|
66
|
+
})),
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
function serveStatic(res, staticDir, pathname) {
|
|
73
|
+
if (!staticDir || !existsSync(join(staticDir, 'index.html'))) {
|
|
74
|
+
const message = 'The devtoolz UI is not built in this copy of the package. Run "npm run build" in the devtoolz repository.';
|
|
75
|
+
res.writeHead(503, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
76
|
+
res.end(message);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const root = resolve(staticDir);
|
|
80
|
+
const wanted = resolve(root, `.${pathname === '/' ? '/index.html' : pathname}`);
|
|
81
|
+
let file = wanted;
|
|
82
|
+
const inside = wanted === root || wanted.startsWith(root + sep);
|
|
83
|
+
if (!inside || !statSync(wanted, { throwIfNoEntry: false })?.isFile()) {
|
|
84
|
+
if (extname(pathname) !== '') {
|
|
85
|
+
res.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
86
|
+
res.end('not found');
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
file = join(root, 'index.html');
|
|
90
|
+
}
|
|
91
|
+
const type = CONTENT_TYPES[extname(file).toLowerCase()] ?? 'application/octet-stream';
|
|
92
|
+
const cache = file.includes(`${sep}assets${sep}`)
|
|
93
|
+
? 'public, max-age=31536000, immutable'
|
|
94
|
+
: 'no-cache';
|
|
95
|
+
sendBytes(res, type, readFileSync(file), cache);
|
|
96
|
+
}
|
|
97
|
+
export async function startUiServer(options) {
|
|
98
|
+
const host = options.host ?? '127.0.0.1';
|
|
99
|
+
const token = options.token ?? randomBytes(18).toString('hex');
|
|
100
|
+
const routes = allRoutes();
|
|
101
|
+
const state = {
|
|
102
|
+
cwd: resolve(options.cwd),
|
|
103
|
+
host,
|
|
104
|
+
port: options.port ?? 0,
|
|
105
|
+
token,
|
|
106
|
+
staticDir: options.staticDir ?? defaultStaticDir(),
|
|
107
|
+
version: options.version ?? '',
|
|
108
|
+
};
|
|
109
|
+
const server = createServer((req, res) => {
|
|
110
|
+
void handle(req, res).catch((error) => {
|
|
111
|
+
if (res.headersSent) {
|
|
112
|
+
res.end();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (error instanceof HttpError) {
|
|
116
|
+
sendJson(res, error.status, { error: error.message });
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
sendJson(res, 500, { error: error instanceof Error ? error.message : String(error) });
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
async function handle(req, res) {
|
|
123
|
+
const allowedHosts = new Set([
|
|
124
|
+
`${host}:${state.port}`,
|
|
125
|
+
`localhost:${state.port}`,
|
|
126
|
+
`127.0.0.1:${state.port}`,
|
|
127
|
+
`[::1]:${state.port}`,
|
|
128
|
+
]);
|
|
129
|
+
if (!allowedHosts.has((req.headers.host ?? '').toLowerCase())) {
|
|
130
|
+
throw new HttpError(403, 'unexpected Host header');
|
|
131
|
+
}
|
|
132
|
+
const url = new URL(req.url ?? '/', `http://${req.headers.host}`);
|
|
133
|
+
const cookie = cookieName(state.port);
|
|
134
|
+
if (req.method === 'GET' && url.pathname === '/' && url.searchParams.has('token')) {
|
|
135
|
+
if (!sameToken(url.searchParams.get('token') ?? undefined, token)) {
|
|
136
|
+
throw new HttpError(403, 'wrong token');
|
|
137
|
+
}
|
|
138
|
+
res.writeHead(302, {
|
|
139
|
+
Location: '/',
|
|
140
|
+
'Set-Cookie': `${cookie}=${token}; Path=/; HttpOnly; SameSite=Strict`,
|
|
141
|
+
'Cache-Control': 'no-store',
|
|
142
|
+
});
|
|
143
|
+
res.end();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const authorized = sameToken(readCookie(req, cookie), token);
|
|
147
|
+
if (url.pathname.startsWith('/api/')) {
|
|
148
|
+
if (!authorized)
|
|
149
|
+
throw new HttpError(401, 'open the address that devtoolz ui printed');
|
|
150
|
+
const origin = req.headers.origin;
|
|
151
|
+
if (origin !== undefined &&
|
|
152
|
+
!allowedHosts.has(origin.replace(/^https?:\/\//, '').toLowerCase())) {
|
|
153
|
+
throw new HttpError(403, 'unexpected Origin header');
|
|
154
|
+
}
|
|
155
|
+
const found = matchRoute(routes, req.method ?? 'GET', url.pathname);
|
|
156
|
+
if (!found)
|
|
157
|
+
throw new HttpError(404, 'no such endpoint');
|
|
158
|
+
await found.route.handler({
|
|
159
|
+
req,
|
|
160
|
+
res,
|
|
161
|
+
url,
|
|
162
|
+
params: found.params,
|
|
163
|
+
server: state,
|
|
164
|
+
readBody: () => readJsonBody(req),
|
|
165
|
+
});
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (req.method !== 'GET')
|
|
169
|
+
throw new HttpError(405, 'method not allowed');
|
|
170
|
+
if (!authorized) {
|
|
171
|
+
res.writeHead(401, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
172
|
+
res.end('Open the address that "devtoolz ui" printed in the terminal.');
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
serveStatic(res, state.staticDir, url.pathname);
|
|
176
|
+
}
|
|
177
|
+
await new Promise((resolveListen, rejectListen) => {
|
|
178
|
+
server.once('error', rejectListen);
|
|
179
|
+
server.listen(state.port, host, () => {
|
|
180
|
+
server.off('error', rejectListen);
|
|
181
|
+
resolveListen();
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
state.port = server.address().port;
|
|
185
|
+
return {
|
|
186
|
+
url: `http://${host === '::1' ? '[::1]' : host}:${state.port}/?token=${token}`,
|
|
187
|
+
port: state.port,
|
|
188
|
+
host,
|
|
189
|
+
token,
|
|
190
|
+
close: () => new Promise((resolveClose) => {
|
|
191
|
+
server.closeAllConnections();
|
|
192
|
+
server.close(() => resolveClose());
|
|
193
|
+
}),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/commands/ui/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC5D,OAAO,EAAE,YAAY,EAA0D,MAAM,WAAW,CAAA;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EACL,SAAS,EACT,UAAU,EACV,YAAY,EACZ,SAAS,EACT,QAAQ,GAGT,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/C,MAAM,aAAa,GAA2B;IAC5C,OAAO,EAAE,0BAA0B;IACnC,KAAK,EAAE,gCAAgC;IACvC,MAAM,EAAE,yBAAyB;I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