@adaptive-ds/assets-optimizer 0.6.0 → 0.7.0
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/.github/workflows/publish.yml +2 -2
- package/bun.lock +20 -20
- package/changelogs/2026-04-27_v0.6.1.md +9 -0
- package/changelogs/2026-05-26_v0.7.0.md +5 -0
- package/dist/image/buildExpectedImages.d.ts.map +1 -1
- package/dist/image/buildExpectedImages.js +3 -0
- package/dist/image/optimizeImages.js +1 -1
- package/dist/image/processImage.d.ts.map +1 -1
- package/dist/image/processImage.js +2 -1
- package/dist/list/generateImageList.d.ts +1 -1
- package/dist/list/generateImageList.d.ts.map +1 -1
- package/dist/list/generateImageList.js +27 -4
- package/package.json +1 -1
|
@@ -18,14 +18,14 @@ jobs:
|
|
|
18
18
|
ref: ${{ github.ref }}
|
|
19
19
|
|
|
20
20
|
# Setup Bun for installation, building, and testing
|
|
21
|
-
- uses: oven-sh/setup-bun@
|
|
21
|
+
- uses: oven-sh/setup-bun@v2
|
|
22
22
|
with:
|
|
23
23
|
bun-version: latest
|
|
24
24
|
|
|
25
25
|
# Setup Node.js only for npm publishing with OIDC until Bun adds support for it - https://github.com/oven-sh/bun/issues/15601
|
|
26
26
|
- uses: actions/setup-node@v4
|
|
27
27
|
with:
|
|
28
|
-
node-version: "
|
|
28
|
+
node-version: "24"
|
|
29
29
|
registry-url: "https://registry.npmjs.org"
|
|
30
30
|
|
|
31
31
|
# Use Bun for everything except publishing
|
package/bun.lock
CHANGED
|
@@ -18,23 +18,23 @@
|
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
20
|
"packages": {
|
|
21
|
-
"@biomejs/biome": ["@biomejs/biome@2.4.
|
|
21
|
+
"@biomejs/biome": ["@biomejs/biome@2.4.15", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.4.15", "@biomejs/cli-darwin-x64": "2.4.15", "@biomejs/cli-linux-arm64": "2.4.15", "@biomejs/cli-linux-arm64-musl": "2.4.15", "@biomejs/cli-linux-x64": "2.4.15", "@biomejs/cli-linux-x64-musl": "2.4.15", "@biomejs/cli-win32-arm64": "2.4.15", "@biomejs/cli-win32-x64": "2.4.15" }, "bin": { "biome": "bin/biome" } }, "sha512-j5VH3a/h/HXTKBM50MDMxRCzkeLv9S2XJcW2WgnZT1+xyisi+0bISrXR82gCX+8S9lvK0skEvHJRN+3Ktr2hlw=="],
|
|
22
22
|
|
|
23
|
-
"@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.4.
|
|
23
|
+
"@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.4.15", "", { "os": "darwin", "cpu": "arm64" }, "sha512-rF3PPqLq1yoST79zaQbDjVJwsuIeci/O+9bgNmC5QpgOqz6aqYuzA4abyAGx+mgyiDXn4A049xAN8gijbuR1Qg=="],
|
|
24
24
|
|
|
25
|
-
"@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.4.
|
|
25
|
+
"@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.4.15", "", { "os": "darwin", "cpu": "x64" }, "sha512-/5KHXYMfSJs1fNXiX30xFtI8JcCFV6zaVVLxOa0M2sfqBKHkpQhRTv94yxQWxeTY2lzo2OuTlNvPC+hDQt2wcQ=="],
|
|
26
26
|
|
|
27
|
-
"@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.4.
|
|
27
|
+
"@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.4.15", "", { "os": "linux", "cpu": "arm64" }, "sha512-owaAMZD/T4LrD0ELNCk0Km3qrRHuM0X6EAyVE1FSqGY0rbLoiDLrO4Us2tllm6cAeB2Ioa9C2C08NZPdr8+0Ug=="],
|
|
28
28
|
|
|
29
|
-
"@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.4.
|
|
29
|
+
"@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.4.15", "", { "os": "linux", "cpu": "arm64" }, "sha512-ZPcxznxm0pogHBLZhYntyR3sR+MrZjqJIKEr7ZqVen0Rl+P/4upVmfYXjftizi9RoqZntg33fv/1fbdhbYXpEQ=="],
|
|
30
30
|
|
|
31
|
-
"@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.4.
|
|
31
|
+
"@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.4.15", "", { "os": "linux", "cpu": "x64" }, "sha512-0jj7THz12GbUOLmMibktK6DZjqz2zV64KFxyBtcFTKPiiOIY0a7vns1elpO1dERvxpsZ5ik0oFfz0oGwFde1+g=="],
|
|
32
32
|
|
|
33
|
-
"@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.4.
|
|
33
|
+
"@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.4.15", "", { "os": "linux", "cpu": "x64" }, "sha512-CNq/9W38SYSH023lfcQ4KKU8K0YX8T//FZUhcgtMMRABDojx5XsMV7jlweAvGSl389wJQB29Qo6Zb/a+jdvt+w=="],
|
|
34
34
|
|
|
35
|
-
"@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.4.
|
|
35
|
+
"@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.4.15", "", { "os": "win32", "cpu": "arm64" }, "sha512-ouhkYdlhp/1GghEJPdWwD/Vi3gQ1nFxuSpMolWsbq3Lsq3QUR4jl6UdhhscdCugKU5vOEuMiJhvKj66O0OCq+w=="],
|
|
36
36
|
|
|
37
|
-
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.4.
|
|
37
|
+
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.4.15", "", { "os": "win32", "cpu": "x64" }, "sha512-zBrGq5mx5wwpnow4+2BxUvleDM+GNd4sLbPaMapsSLQLD0NGRCquqPBTgN+7XkUteHvj7M+BstuI8tmnV7+HgQ=="],
|
|
38
38
|
|
|
39
39
|
"@emnapi/runtime": ["@emnapi/runtime@1.10.0", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA=="],
|
|
40
40
|
|
|
@@ -98,9 +98,9 @@
|
|
|
98
98
|
|
|
99
99
|
"@pkgjs/parseargs": ["@pkgjs/parseargs@0.11.0", "", {}, "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg=="],
|
|
100
100
|
|
|
101
|
-
"@types/bun": ["@types/bun@1.3.
|
|
101
|
+
"@types/bun": ["@types/bun@1.3.14", "", { "dependencies": { "bun-types": "1.3.14" } }, "sha512-h1hFqFVcvAvD9j9K7ZW7vd82aSA+rTdznZa+5bwvCwqSB1jmmfLcbIWhOLx1/+boy/xmjgCs/OMUL8hRJSmnPw=="],
|
|
102
102
|
|
|
103
|
-
"@types/node": ["@types/node@25.
|
|
103
|
+
"@types/node": ["@types/node@25.9.1", "", { "dependencies": { "undici-types": ">=7.24.0 <7.24.7" } }, "sha512-xfrlY7UD5rMJk3ZVJP8BNzS28J36YJg+xp+LPXV1TdWxr8uMH5A860QNxYDGQe/ylDSgjxE52Q9VnO7p75tJxg=="],
|
|
104
104
|
|
|
105
105
|
"abbrev": ["abbrev@3.0.1", "", {}, "sha512-AO2ac6pjRB3SJmGJo+v5/aK6Omggp6fsLrs6wN9bd35ulu4cCwaAU9+7ZhXjeqHVkaHThLuzH0nZr0YpCDhygg=="],
|
|
106
106
|
|
|
@@ -114,11 +114,11 @@
|
|
|
114
114
|
|
|
115
115
|
"bindings": ["bindings@1.5.0", "", { "dependencies": { "file-uri-to-path": "1.0.0" } }, "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ=="],
|
|
116
116
|
|
|
117
|
-
"brace-expansion": ["brace-expansion@2.1.
|
|
117
|
+
"brace-expansion": ["brace-expansion@2.1.1", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-WR1cURNjuvBLMZBMbqM0UoE+WAfdUcEV1ccD8PVBVOI+Z3ND4+SZbN8RsfT2bMuG1qwz5RFvPukSZm5fF2D5eA=="],
|
|
118
118
|
|
|
119
119
|
"bufferstreams": ["bufferstreams@4.0.0", "", { "dependencies": { "readable-stream": "^3.4.0", "yerror": "^8.0.0" } }, "sha512-azX778/2VQ9K2uiYprSUKLgK2K6lR1KtJycJDsMg7u0+Cc994A9HyGaUKb01e/T+M8jse057429iKXurCaT35g=="],
|
|
120
120
|
|
|
121
|
-
"bun-types": ["bun-types@1.3.
|
|
121
|
+
"bun-types": ["bun-types@1.3.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-4N0ig0fEomHt5R0KCFWjovxow98rIoRwKolrYdCcknNwMekCXRnWEUvgu5soYV8QXtVsrUD8B95MBOZGPvr6KQ=="],
|
|
122
122
|
|
|
123
123
|
"cacache": ["cacache@19.0.1", "", { "dependencies": { "@npmcli/fs": "^4.0.0", "fs-minipass": "^3.0.0", "glob": "^10.2.2", "lru-cache": "^10.0.1", "minipass": "^7.0.3", "minipass-collect": "^2.0.1", "minipass-flush": "^1.0.5", "minipass-pipeline": "^1.2.4", "p-map": "^7.0.2", "ssri": "^12.0.0", "tar": "^7.4.3", "unique-filename": "^4.0.0" } }, "sha512-hdsUxulXCi5STId78vRVYEtDAjq99ICAUktLTeTYsLoTE6Z8dS0c8pWNCxwdrk9YfJeobDZc2Y186hD/5ZQgFQ=="],
|
|
124
124
|
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
|
|
131
131
|
"cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="],
|
|
132
132
|
|
|
133
|
-
"debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
|
|
133
|
+
"debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" }, "peerDependencies": { "supports-color": "*" }, "optionalPeers": ["supports-color"] }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
|
|
134
134
|
|
|
135
135
|
"detect-libc": ["detect-libc@2.1.2", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],
|
|
136
136
|
|
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
|
|
173
173
|
"inherits": ["inherits@2.0.4", "", {}, "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="],
|
|
174
174
|
|
|
175
|
-
"ip-address": ["ip-address@10.
|
|
175
|
+
"ip-address": ["ip-address@10.2.0", "", {}, "sha512-/+S6j4E9AHvW9SWMSEY9Xfy66O5PWvVEJ08O0y5JGyEKQpojb0K0GKpz/v5HJ/G0vi3D2sjGK78119oXZeE0qA=="],
|
|
176
176
|
|
|
177
177
|
"is-fullwidth-code-point": ["is-fullwidth-code-point@3.0.0", "", {}, "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg=="],
|
|
178
178
|
|
|
@@ -202,7 +202,7 @@
|
|
|
202
202
|
|
|
203
203
|
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
|
204
204
|
|
|
205
|
-
"nan": ["nan@2.
|
|
205
|
+
"nan": ["nan@2.27.0", "", {}, "sha512-hC+0LidcL3XE4rp1C4H54KujgXKzbfyTngZTwBByQxsOxCEKZT0MPQ4hOKUH2jU1OYstqdDH4onyHPDzcV0XdQ=="],
|
|
206
206
|
|
|
207
207
|
"negotiator": ["negotiator@1.0.0", "", {}, "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg=="],
|
|
208
208
|
|
|
@@ -232,7 +232,7 @@
|
|
|
232
232
|
|
|
233
233
|
"safer-buffer": ["safer-buffer@2.1.2", "", {}, "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="],
|
|
234
234
|
|
|
235
|
-
"semver": ["semver@7.
|
|
235
|
+
"semver": ["semver@7.8.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-rkVq3IXh+4FDGch+KwzX3aV9W3kO54GyEgpvBzSyctDA6Xtd7RJQV1xmXbeQp5v7+VzLOfVqiutSE6GICgPFvg=="],
|
|
236
236
|
|
|
237
237
|
"sharp": ["sharp@0.34.5", "", { "dependencies": { "@img/colour": "^1.0.0", "detect-libc": "^2.1.2", "semver": "^7.7.3" }, "optionalDependencies": { "@img/sharp-darwin-arm64": "0.34.5", "@img/sharp-darwin-x64": "0.34.5", "@img/sharp-libvips-darwin-arm64": "1.2.4", "@img/sharp-libvips-darwin-x64": "1.2.4", "@img/sharp-libvips-linux-arm": "1.2.4", "@img/sharp-libvips-linux-arm64": "1.2.4", "@img/sharp-libvips-linux-ppc64": "1.2.4", "@img/sharp-libvips-linux-riscv64": "1.2.4", "@img/sharp-libvips-linux-s390x": "1.2.4", "@img/sharp-libvips-linux-x64": "1.2.4", "@img/sharp-libvips-linuxmusl-arm64": "1.2.4", "@img/sharp-libvips-linuxmusl-x64": "1.2.4", "@img/sharp-linux-arm": "0.34.5", "@img/sharp-linux-arm64": "0.34.5", "@img/sharp-linux-ppc64": "0.34.5", "@img/sharp-linux-riscv64": "0.34.5", "@img/sharp-linux-s390x": "0.34.5", "@img/sharp-linux-x64": "0.34.5", "@img/sharp-linuxmusl-arm64": "0.34.5", "@img/sharp-linuxmusl-x64": "0.34.5", "@img/sharp-wasm32": "0.34.5", "@img/sharp-win32-arm64": "0.34.5", "@img/sharp-win32-ia32": "0.34.5", "@img/sharp-win32-x64": "0.34.5" } }, "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg=="],
|
|
238
238
|
|
|
@@ -244,7 +244,7 @@
|
|
|
244
244
|
|
|
245
245
|
"smart-buffer": ["smart-buffer@4.2.0", "", {}, "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg=="],
|
|
246
246
|
|
|
247
|
-
"socks": ["socks@2.8.
|
|
247
|
+
"socks": ["socks@2.8.9", "", { "dependencies": { "ip-address": "^10.1.1", "smart-buffer": "^4.2.0" } }, "sha512-LJhUYUvItdQ0LkJTmPeaEObWXAqFyfmP85x0tch/ez9cahmhlBBLbIqDFnvBnUJGagb0JbIQrkBs1wJ+yRYpEw=="],
|
|
248
248
|
|
|
249
249
|
"socks-proxy-agent": ["socks-proxy-agent@8.0.5", "", { "dependencies": { "agent-base": "^7.1.2", "debug": "^4.3.4", "socks": "^2.8.3" } }, "sha512-HehCEsotFqbPW9sJ8WVYB6UbmIMv7kUUORIF2Nncq4VQvBfNBLibW9YZR5dlYCSUhwcD628pRllm7n+E+YTzJw=="],
|
|
250
250
|
|
|
@@ -260,7 +260,7 @@
|
|
|
260
260
|
|
|
261
261
|
"strip-ansi-cjs": ["strip-ansi@6.0.1", "", { "dependencies": { "ansi-regex": "^5.0.1" } }, "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A=="],
|
|
262
262
|
|
|
263
|
-
"tar": ["tar@7.5.
|
|
263
|
+
"tar": ["tar@7.5.15", "", { "dependencies": { "@isaacs/fs-minipass": "^4.0.0", "chownr": "^3.0.0", "minipass": "^7.1.2", "minizlib": "^3.1.0", "yallist": "^5.0.0" } }, "sha512-dzGK0boVlC4W5QFuQN1EFSl3bIDYsk7Tj40U6eIBnK2k/8ml7TZ5agbI5j5+qnoVcAA+rNtBml8SEiLxZpNqRQ=="],
|
|
264
264
|
|
|
265
265
|
"tinyglobby": ["tinyglobby@0.2.16", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.4" } }, "sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg=="],
|
|
266
266
|
|
|
@@ -270,7 +270,7 @@
|
|
|
270
270
|
|
|
271
271
|
"typescript": ["typescript@6.0.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw=="],
|
|
272
272
|
|
|
273
|
-
"undici-types": ["undici-types@7.
|
|
273
|
+
"undici-types": ["undici-types@7.24.6", "", {}, "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg=="],
|
|
274
274
|
|
|
275
275
|
"unique-filename": ["unique-filename@4.0.0", "", { "dependencies": { "unique-slug": "^5.0.0" } }, "sha512-XSnEewXmQ+veP7xX2dS5Q4yZAvO40cBN2MWkJ7D/6sW4Dg6wYBNwM1Vrnz1FhH5AdeLIlUXRI9e28z1YZi71NQ=="],
|
|
276
276
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildExpectedImages.d.ts","sourceRoot":"","sources":["../../src/image/buildExpectedImages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAItE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAKvD,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,oBAAoB,EAC5B,mBAAmB,UAAQ,GAC1B,OAAO,CAAC,aAAa,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"buildExpectedImages.d.ts","sourceRoot":"","sources":["../../src/image/buildExpectedImages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAItE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAKvD,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,oBAAoB,EAC5B,mBAAmB,UAAQ,GAC1B,OAAO,CAAC,aAAa,EAAE,CAAC,CA8F1B"}
|
|
@@ -61,6 +61,9 @@ export async function buildExpectedImages(originalsDir, optimizedDir, result, al
|
|
|
61
61
|
}
|
|
62
62
|
for (const sourceFile of await walkFiles(entryPath)) {
|
|
63
63
|
const extension = path.extname(sourceFile).toLowerCase();
|
|
64
|
+
if (extension === ".md") {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
64
67
|
if (!supportedSourceExtensions.has(extension)) {
|
|
65
68
|
result.warnings.push(`Skipped unsupported source file: ${path.relative(originalsDir, sourceFile)}`);
|
|
66
69
|
console.warn(`Skipped unsupported source file: ${path.relative(originalsDir, sourceFile)}`);
|
|
@@ -30,7 +30,7 @@ export async function optimizeImages(options = {}) {
|
|
|
30
30
|
logger,
|
|
31
31
|
});
|
|
32
32
|
if (options.generateImageList !== false) {
|
|
33
|
-
await generateImageList(imageOptimizedDir, imageListOutputPath, undefined, logger);
|
|
33
|
+
await generateImageList(imageOptimizedDir, imageListOutputPath, undefined, logger, imageOriginalsDir);
|
|
34
34
|
}
|
|
35
35
|
printSummary(result, logger);
|
|
36
36
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processImage.d.ts","sourceRoot":"","sources":["../../src/image/processImage.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,wBAAsB,YAAY,CAChC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,aAAa,EACxB,OAAO,SAAiB,GACvB,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"processImage.d.ts","sourceRoot":"","sources":["../../src/image/processImage.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD,wBAAsB,YAAY,CAChC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,aAAa,EACxB,OAAO,SAAiB,GACvB,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
|
|
@@ -13,7 +13,8 @@ export async function processImage(sourceBuffer, outputPath, transform, quality
|
|
|
13
13
|
pipeline = pipeline.jpeg({ quality });
|
|
14
14
|
break;
|
|
15
15
|
case "png":
|
|
16
|
-
|
|
16
|
+
// PNG: use 100 to preserve original quality (lossless)
|
|
17
|
+
pipeline = pipeline.png({ quality: 100 });
|
|
17
18
|
break;
|
|
18
19
|
case "webp":
|
|
19
20
|
pipeline = pipeline.webp({ quality });
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Logger } from "../shared/logger.js";
|
|
2
|
-
export declare function generateImageList(imageDirectory: string, outputPath: string, imageTypeImportPath?: string, logger?: Logger): Promise<void>;
|
|
2
|
+
export declare function generateImageList(imageDirectory: string, outputPath: string, imageTypeImportPath?: string, logger?: Logger, altTextDirectory?: string): Promise<void>;
|
|
3
3
|
//# sourceMappingURL=generateImageList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateImageList.d.ts","sourceRoot":"","sources":["../../src/list/generateImageList.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAUjD,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,mBAAmB,CAAC,EAAE,MAAM,EAC5B,MAAM,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"generateImageList.d.ts","sourceRoot":"","sources":["../../src/list/generateImageList.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAUjD,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,mBAAmB,CAAC,EAAE,MAAM,EAC5B,MAAM,CAAC,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,IAAI,CAAC,CAYf"}
|
|
@@ -8,10 +8,11 @@ import { getAssetKey } from "./getAssetKey.js";
|
|
|
8
8
|
import { loadExistingAssetList } from "./loadExistingAssetList.js";
|
|
9
9
|
import { sortAssetMap } from "./sortAssetMap.js";
|
|
10
10
|
const IMAGE_EXTENSIONS = new Set([".jpg", ".jpeg", ".png", ".gif", ".webp", ".avif", ".tiff", ".svg"]);
|
|
11
|
-
export async function generateImageList(imageDirectory, outputPath, imageTypeImportPath, logger) {
|
|
11
|
+
export async function generateImageList(imageDirectory, outputPath, imageTypeImportPath, logger, altTextDirectory) {
|
|
12
12
|
const resolvedImageTypeImportPath = imageTypeImportPath ?? (await getOwnPackageName(import.meta.url));
|
|
13
13
|
const existingImages = await loadExistingAssetList(outputPath, "imageList");
|
|
14
|
-
const
|
|
14
|
+
const imageAlts = altTextDirectory ? await loadImageAlts(altTextDirectory, logger) : {};
|
|
15
|
+
const imageMap = await processImageFiles(imageDirectory, existingImages, imageAlts, logger);
|
|
15
16
|
const sorted = sortAssetMap(imageMap);
|
|
16
17
|
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
17
18
|
await Bun.write(outputPath, createGeneratedImageListContent(sorted, resolvedImageTypeImportPath));
|
|
@@ -19,7 +20,7 @@ export async function generateImageList(imageDirectory, outputPath, imageTypeImp
|
|
|
19
20
|
logger?.files(`generated image list: ${outputPath}`);
|
|
20
21
|
logger?.summary(`Generated ${Object.keys(sorted).length} images to ${outputPath}`);
|
|
21
22
|
}
|
|
22
|
-
async function processImageFiles(directory, existingImages, logger) {
|
|
23
|
+
async function processImageFiles(directory, existingImages, imageAlts, logger) {
|
|
23
24
|
const imageMap = {};
|
|
24
25
|
for (const filePath of await walkFiles(directory)) {
|
|
25
26
|
const extension = path.extname(filePath).toLowerCase();
|
|
@@ -39,7 +40,7 @@ async function processImageFiles(directory, existingImages, logger) {
|
|
|
39
40
|
path: relativePath,
|
|
40
41
|
width: dimensions.width,
|
|
41
42
|
height: dimensions.height,
|
|
42
|
-
alt: existingImages[key]?.alt || formatGeneratedImageAlt(fileName),
|
|
43
|
+
alt: imageAlts[key] || existingImages[key]?.alt || formatGeneratedImageAlt(fileName),
|
|
43
44
|
mimeType: getImageMimeType(extension),
|
|
44
45
|
};
|
|
45
46
|
}
|
|
@@ -49,12 +50,34 @@ async function processImageFiles(directory, existingImages, logger) {
|
|
|
49
50
|
}
|
|
50
51
|
return imageMap;
|
|
51
52
|
}
|
|
53
|
+
async function loadImageAlts(directory, logger) {
|
|
54
|
+
const imageAlts = {};
|
|
55
|
+
for (const filePath of await walkFiles(directory)) {
|
|
56
|
+
if (path.extname(filePath).toLowerCase() !== ".md") {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const key = normalizeGeneratedImageKey(getAssetKey(filePath));
|
|
61
|
+
const alt = formatMarkdownAlt(await fs.readFile(filePath, "utf-8"));
|
|
62
|
+
if (alt) {
|
|
63
|
+
imageAlts[key] = alt;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
logger?.error(`Error reading image alt ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return imageAlts;
|
|
71
|
+
}
|
|
52
72
|
function normalizeGeneratedImageKey(key) {
|
|
53
73
|
return key.replace(/_[0-9a-f]{8}$/i, "");
|
|
54
74
|
}
|
|
55
75
|
function formatGeneratedImageAlt(fileName) {
|
|
56
76
|
return normalizeGeneratedImageKey(fileName).replace(/[-_]/g, " ");
|
|
57
77
|
}
|
|
78
|
+
function formatMarkdownAlt(content) {
|
|
79
|
+
return content.replace(/\s+/g, " ").trim();
|
|
80
|
+
}
|
|
58
81
|
function createGeneratedImageListContent(imageMap, imageTypeImportPath) {
|
|
59
82
|
return `import type { ImageType } from "${imageTypeImportPath}"
|
|
60
83
|
|