@vesk/vesk-cli 0.2.66 → 0.2.67
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/dist/cli.js +18 -8
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -36725,6 +36725,7 @@ var init_static = __esm({
|
|
|
36725
36725
|
// ../adapter/dist/image-pipeline.js
|
|
36726
36726
|
var image_pipeline_exports = {};
|
|
36727
36727
|
__export(image_pipeline_exports, {
|
|
36728
|
+
collectImageRefs: () => collectImageRefs,
|
|
36728
36729
|
optimizeImages: () => optimizeImages
|
|
36729
36730
|
});
|
|
36730
36731
|
import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync9, readFileSync as readFileSync18, existsSync as existsSync18, readdirSync as readdirSync4, statSync as statSync9 } from "node:fs";
|
|
@@ -36791,21 +36792,29 @@ async function processImage(srcPath, outDir, baseName) {
|
|
|
36791
36792
|
const image = sharpFn ? sharpFn(srcPath) : null;
|
|
36792
36793
|
if (!image) {
|
|
36793
36794
|
const original = readFileSync18(srcPath);
|
|
36795
|
+
const ext = extname5(srcPath);
|
|
36796
|
+
const written = [];
|
|
36794
36797
|
for (const w of OUTPUT_WIDTHS) {
|
|
36795
|
-
const outputPath = resolve16(outDir, `${baseName}-${w}w`);
|
|
36798
|
+
const outputPath = resolve16(outDir, `${baseName}-${w}w${ext}`);
|
|
36796
36799
|
mkdirSync8(dirname12(outputPath), { recursive: true });
|
|
36797
36800
|
writeFileSync9(outputPath, original);
|
|
36801
|
+
written.push(outputPath);
|
|
36798
36802
|
}
|
|
36799
|
-
return
|
|
36803
|
+
return written;
|
|
36800
36804
|
}
|
|
36801
36805
|
const meta = await image.metadata();
|
|
36802
36806
|
const originalWidth = meta.width || 1920;
|
|
36803
36807
|
const generated = [];
|
|
36804
36808
|
for (const w of OUTPUT_WIDTHS) {
|
|
36805
|
-
|
|
36809
|
+
const base = `${baseName}-${w}w`;
|
|
36810
|
+
if (w >= originalWidth) {
|
|
36811
|
+
const copyPath = resolve16(outDir, `${base}${extname5(srcPath)}`);
|
|
36812
|
+
mkdirSync8(dirname12(copyPath), { recursive: true });
|
|
36813
|
+
writeFileSync9(copyPath, readFileSync18(srcPath));
|
|
36814
|
+
generated.push(copyPath);
|
|
36806
36815
|
continue;
|
|
36816
|
+
}
|
|
36807
36817
|
const resized = image.clone().resize({ width: w, withoutEnlargement: true });
|
|
36808
|
-
const base = `${baseName}-${w}w`;
|
|
36809
36818
|
const jpgPath = resolve16(outDir, `${base}${extname5(srcPath)}`);
|
|
36810
36819
|
mkdirSync8(dirname12(jpgPath), { recursive: true });
|
|
36811
36820
|
await resized.toFile(jpgPath);
|
|
@@ -36834,9 +36843,9 @@ function collectImageRefs(appDir) {
|
|
|
36834
36843
|
if (entry.startsWith("."))
|
|
36835
36844
|
continue;
|
|
36836
36845
|
walk9(full);
|
|
36837
|
-
} else if (entry
|
|
36846
|
+
} else if (entry.endsWith(".vsk")) {
|
|
36838
36847
|
const src2 = readFileSync18(full, "utf-8");
|
|
36839
|
-
const imgRegex = /<Image\s
|
|
36848
|
+
const imgRegex = /<Image\s[^>]*src=["']([^"']+)["']/g;
|
|
36840
36849
|
let m;
|
|
36841
36850
|
while ((m = imgRegex.exec(src2)) !== null) {
|
|
36842
36851
|
refs.push({ source: full, src: m[1] });
|
|
@@ -36848,8 +36857,7 @@ function collectImageRefs(appDir) {
|
|
|
36848
36857
|
return refs;
|
|
36849
36858
|
}
|
|
36850
36859
|
async function optimizeImages(appDir, outDir) {
|
|
36851
|
-
|
|
36852
|
-
mkdirSync8(imageOutDir, { recursive: true });
|
|
36860
|
+
mkdirSync8(resolve16(outDir, "static", "public"), { recursive: true });
|
|
36853
36861
|
const refs = collectImageRefs(appDir);
|
|
36854
36862
|
if (refs.length === 0) {
|
|
36855
36863
|
console.error("vesk images: no <Image> refs found");
|
|
@@ -36882,6 +36890,8 @@ async function optimizeImages(appDir, outDir) {
|
|
|
36882
36890
|
continue;
|
|
36883
36891
|
}
|
|
36884
36892
|
const baseName = ref2.src.replace(/^\//, "").replace(extname5(ref2.src), "");
|
|
36893
|
+
const imageOutDir = resolve16(outDir, "static", "public");
|
|
36894
|
+
mkdirSync8(imageOutDir, { recursive: true });
|
|
36885
36895
|
const files = await processImage(srcPath, imageOutDir, baseName);
|
|
36886
36896
|
results.push({ src: ref2.src, baseName, files, widths: OUTPUT_WIDTHS });
|
|
36887
36897
|
console.error(`vesk images: ${ref2.src} \u2192 ${files.length} variants`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/vesk-cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.67",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vesk — compiler-first framework for the post-VDOM web. vesk dev, vesk build.",
|
|
6
6
|
"bin": {
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
},
|
|
9
9
|
"main": "./dist/cli.js",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@vesk/adapter": "^0.2.
|
|
12
|
-
"@vesk/compiler": "^0.2.
|
|
13
|
-
"@vesk/plugin-tailwind": "^0.2.
|
|
14
|
-
"@vesk/runtime": "^0.2.
|
|
11
|
+
"@vesk/adapter": "^0.2.67",
|
|
12
|
+
"@vesk/compiler": "^0.2.67",
|
|
13
|
+
"@vesk/plugin-tailwind": "^0.2.67",
|
|
14
|
+
"@vesk/runtime": "^0.2.67",
|
|
15
15
|
"esrap": "^2.3.0",
|
|
16
16
|
"typescript": "^5.8.0",
|
|
17
17
|
"ws": "^8.18.0",
|