@adaptive-ds/assets-optimizer 0.8.0 → 0.9.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/README.md +25 -0
- package/bun.lock +12 -12
- package/changelogs/2026-06-13_v0.9.0.md +9 -0
- package/dist/AssetsOptimizeOptions.d.ts +2 -0
- package/dist/AssetsOptimizeOptions.d.ts.map +1 -1
- package/dist/assetsOptimize.d.ts.map +1 -1
- package/dist/assetsOptimize.js +3 -1
- package/dist/font/optimizeFonts.d.ts.map +1 -1
- package/dist/font/optimizeFonts.js +2 -2
- package/dist/font/parseFontFilename.js +2 -2
- package/dist/image/OptimizeImagesOptions.d.ts +2 -0
- package/dist/image/OptimizeImagesOptions.d.ts.map +1 -1
- package/dist/image/ProcessImagesOptions.d.ts +1 -0
- package/dist/image/ProcessImagesOptions.d.ts.map +1 -1
- package/dist/image/buildExpectedImages.d.ts +1 -1
- package/dist/image/buildExpectedImages.d.ts.map +1 -1
- package/dist/image/buildExpectedImages.js +3 -3
- package/dist/image/createOutputHash.d.ts +1 -1
- package/dist/image/createOutputHash.d.ts.map +1 -1
- package/dist/image/createOutputHash.js +2 -2
- package/dist/image/createOutputHashForFile.d.ts +1 -1
- package/dist/image/createOutputHashForFile.d.ts.map +1 -1
- package/dist/image/createOutputHashForFile.js +2 -2
- package/dist/image/createRootImageTransform.js +1 -1
- package/dist/image/optimizeImages.d.ts.map +1 -1
- package/dist/image/optimizeImages.js +3 -1
- package/dist/image/processImages.d.ts.map +1 -1
- package/dist/image/processImages.js +2 -2
- package/dist/index.d.ts +11 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -11
- package/dist/list/generateFontList.d.ts.map +1 -1
- package/dist/list/generateFontList.js +2 -2
- package/dist/list/generateImageList.d.ts +1 -1
- package/dist/list/generateImageList.d.ts.map +1 -1
- package/dist/list/generateImageList.js +12 -12
- package/dist/rclone/bisync.d.ts.map +1 -1
- package/dist/rclone/bisync.js +1 -8
- package/dist/video/optimizeVideos.d.ts.map +1 -1
- package/dist/video/optimizeVideos.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -116,6 +116,31 @@ Video behavior:
|
|
|
116
116
|
- video filenames and relative paths are kept as-is
|
|
117
117
|
- stale processed videos are not deleted
|
|
118
118
|
|
|
119
|
+
## Hash Length
|
|
120
|
+
|
|
121
|
+
Output filenames are `<basename>_<hash>.<ext>`, where the hash defaults to 8 hex chars.
|
|
122
|
+
Set `imageHashLength` to use a shorter (or longer) suffix:
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
await assetsOptimize({
|
|
126
|
+
imageHashLength: 3,
|
|
127
|
+
})
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
```text
|
|
131
|
+
images/1920x1080_webp/ship_PYM.webp -> public/images/ship_PYM_a1b.webp
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The hash only busts cache when a single file's content changes — the basename already
|
|
135
|
+
distinguishes different images, so cross-file collisions never matter. The only risk of a
|
|
136
|
+
short hash is that an edited file re-hashes to the same suffix and its cache is not busted:
|
|
137
|
+
roughly `1 / 16^length` per edit (≈ 1/4096 at length 3). The generated `imageList.ts`
|
|
138
|
+
strips exactly `imageHashLength` hex chars to keep stable keys, so keep this value in sync
|
|
139
|
+
with the existing list.
|
|
140
|
+
|
|
141
|
+
`imageTypeImportPath` sets the `import type { ImageType } from "..."` line of the
|
|
142
|
+
generated `imageList.ts` (defaults to this package's name).
|
|
143
|
+
|
|
119
144
|
## Transform Folder Format
|
|
120
145
|
|
|
121
146
|
Folder names must use:
|
package/bun.lock
CHANGED
|
@@ -18,25 +18,25 @@
|
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
20
|
"packages": {
|
|
21
|
-
"@biomejs/biome": ["@biomejs/biome@2.
|
|
21
|
+
"@biomejs/biome": ["@biomejs/biome@2.5.0", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.5.0", "@biomejs/cli-darwin-x64": "2.5.0", "@biomejs/cli-linux-arm64": "2.5.0", "@biomejs/cli-linux-arm64-musl": "2.5.0", "@biomejs/cli-linux-x64": "2.5.0", "@biomejs/cli-linux-x64-musl": "2.5.0", "@biomejs/cli-win32-arm64": "2.5.0", "@biomejs/cli-win32-x64": "2.5.0" }, "bin": { "biome": "bin/biome" } }, "sha512-4kURkd9hAPrdDM3C9n82ycYgx8hvQcW6MjKTEejruj8rK0N8P3OPpdy8BvI8kt3KWY4ycF5XtDOrktetEfhfuw=="],
|
|
22
22
|
|
|
23
|
-
"@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.
|
|
23
|
+
"@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.5.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-Mn3Fwi3SA5fgmfCPqmzpWF2DLZnms3BVAhM088nTnGrTZmHS3wwIjcoZPqpXeNgd3DrrLH6xp8vTLIBuJoZiXw=="],
|
|
24
24
|
|
|
25
|
-
"@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.
|
|
25
|
+
"@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.5.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-rg3VPL5P8mYro6pqlXYXuJWph21slVp3SZtAqWSrkZs40d2gTzYmHF8E/X1iTID25btmNKltNDJ926sqVBp7DQ=="],
|
|
26
26
|
|
|
27
|
-
"@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.
|
|
27
|
+
"@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.5.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-tl+LW8fdD96/xdeWtWwc82LIOc5CoY7N2AsogLTp5R4ECErYt+8Jl/N68ezN9vzSiqPTxw6vjcihoLPYKZHrlw=="],
|
|
28
28
|
|
|
29
|
-
"@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.
|
|
29
|
+
"@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.5.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-vQdM4oSGaf7ZNeGO9w5+Y8SBtyser9M6znxYbm7Ec8wInxJu1WiKxFYZW5Auj2d80bcVvefuGGRxoFOE0eee8g=="],
|
|
30
30
|
|
|
31
|
-
"@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.
|
|
31
|
+
"@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.5.0", "", { "os": "linux", "cpu": "x64" }, "sha512-zpEGf4RQbFEh8Vt7OmavLyyOzRbtcE9osCqrS1kfvt8jDvxwhKXLSf7n0ebr/ov0RJ9ssP+lhs6C8a9WwFvrQA=="],
|
|
32
32
|
|
|
33
|
-
"@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.
|
|
33
|
+
"@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.5.0", "", { "os": "linux", "cpu": "x64" }, "sha512-+9hIcMngJ+yGUahXqZuZ8CoWKJE9SAZsFsM3QDvXpNsLbXZ9lqVzgBhOk/jTSYkOA0GLP9eu3teukqpLUojHMg=="],
|
|
34
34
|
|
|
35
|
-
"@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.
|
|
35
|
+
"@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.5.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-jB0wAvTLI4itx5VidqVUejPQFhRUxiZ9l9FvZ26D5fl6t3qme+ZB4PD3bTSeL1vZ8NI2Rx/zj6H9zcESuGHKGw=="],
|
|
36
36
|
|
|
37
|
-
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.
|
|
37
|
+
"@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.5.0", "", { "os": "win32", "cpu": "x64" }, "sha512-VT/lF+GId+67j8aDfLkxdxNoVApsPSTbyAtB3jJq0IWTrY77WXfbPfpngxq0bA6JCEv/7k8C9qWjDRKRznDlyw=="],
|
|
38
38
|
|
|
39
|
-
"@emnapi/runtime": ["@emnapi/runtime@1.11.
|
|
39
|
+
"@emnapi/runtime": ["@emnapi/runtime@1.11.1", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-vgj7R3y3Wgx24IQaGPA/R6YFXLHVMOZ0uVEyIQPaWs+rd1AzfEMXlAC22FYwO1XkKR6NPsq7mUandH8oIRdZFw=="],
|
|
40
40
|
|
|
41
41
|
"@img/colour": ["@img/colour@1.1.0", "", {}, "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ=="],
|
|
42
42
|
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
|
|
101
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.9.
|
|
103
|
+
"@types/node": ["@types/node@25.9.3", "", { "dependencies": { "undici-types": ">=7.24.0 <7.24.7" } }, "sha512-603BddQMv3pUcr4U2dhujk83N2tTDVr/34wII2B6bJy6g+8WD6yUb11jszNs0gdi4PesVWl7ABt8nYMVpnLUcg=="],
|
|
104
104
|
|
|
105
105
|
"abbrev": ["abbrev@3.0.1", "", {}, "sha512-AO2ac6pjRB3SJmGJo+v5/aK6Omggp6fsLrs6wN9bd35ulu4cCwaAU9+7ZhXjeqHVkaHThLuzH0nZr0YpCDhygg=="],
|
|
106
106
|
|
|
@@ -232,7 +232,7 @@
|
|
|
232
232
|
|
|
233
233
|
"safer-buffer": ["safer-buffer@2.1.2", "", {}, "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="],
|
|
234
234
|
|
|
235
|
-
"semver": ["semver@7.8.
|
|
235
|
+
"semver": ["semver@7.8.4", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-rUCObTnP32Q08R2uuIrt7r9PlEonuTmtuXYcW6s5kjdlj3xbnwe+21yXptAUYcMAABLkYYTtnmzb3w3EDZfueA=="],
|
|
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
|
|
|
@@ -5,6 +5,8 @@ export interface AssetsOptimizeOptions {
|
|
|
5
5
|
imageOriginalsDir?: string;
|
|
6
6
|
imageOptimizedDir?: string;
|
|
7
7
|
allowRootImageFiles?: boolean;
|
|
8
|
+
imageHashLength?: number;
|
|
9
|
+
imageTypeImportPath?: string;
|
|
8
10
|
imageListOutputPath?: string;
|
|
9
11
|
generateImageList?: boolean;
|
|
10
12
|
processVideos?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetsOptimizeOptions.d.ts","sourceRoot":"","sources":["../src/AssetsOptimizeOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACxB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B"}
|
|
1
|
+
{"version":3,"file":"AssetsOptimizeOptions.d.ts","sourceRoot":"","sources":["../src/AssetsOptimizeOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACxB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assetsOptimize.d.ts","sourceRoot":"","sources":["../src/assetsOptimize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAKrE,wBAAsB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,oBAAoB,CAAC,
|
|
1
|
+
{"version":3,"file":"assetsOptimize.d.ts","sourceRoot":"","sources":["../src/assetsOptimize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAKrE,wBAAsB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAyFvG"}
|
package/dist/assetsOptimize.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { optimizeFonts } from "./font/optimizeFonts.js";
|
|
1
2
|
import { optimizeImages } from "./image/optimizeImages.js";
|
|
2
3
|
import { optimizeVideos } from "./video/optimizeVideos.js";
|
|
3
|
-
import { optimizeFonts } from "./font/optimizeFonts.js";
|
|
4
4
|
export async function assetsOptimize(options = {}) {
|
|
5
5
|
const [imageResult, videoResult, fontResult] = await Promise.all([
|
|
6
6
|
options.processImages !== false
|
|
@@ -10,6 +10,8 @@ export async function assetsOptimize(options = {}) {
|
|
|
10
10
|
imageOriginalsDir: options.imageOriginalsDir,
|
|
11
11
|
imageOptimizedDir: options.imageOptimizedDir,
|
|
12
12
|
allowRootImageFiles: options.allowRootImageFiles,
|
|
13
|
+
imageHashLength: options.imageHashLength,
|
|
14
|
+
imageTypeImportPath: options.imageTypeImportPath,
|
|
13
15
|
imageListOutputPath: options.imageListOutputPath,
|
|
14
16
|
generateImageList: options.generateImageList,
|
|
15
17
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimizeFonts.d.ts","sourceRoot":"","sources":["../../src/font/optimizeFonts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"optimizeFonts.d.ts","sourceRoot":"","sources":["../../src/font/optimizeFonts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAMtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAsCrE,wBAAsB,aAAa,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAwCrG"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import ttf2woff2 from "ttf2woff2";
|
|
4
|
+
import { generateFontList } from "../list/generateFontList.js";
|
|
4
5
|
import { dirExists } from "../shared/dirExists.js";
|
|
5
6
|
import { createLogger } from "../shared/logger.js";
|
|
6
7
|
import { printSummary } from "../shared/printSummary.js";
|
|
7
8
|
import { walkFiles } from "../shared/walkFiles.js";
|
|
8
|
-
import { supportedFontOutputExtensions, supportedFontSourceExtensions } from "./supportedFontExtensions.js";
|
|
9
|
-
import { generateFontList } from "../list/generateFontList.js";
|
|
10
9
|
import { parseFontFilename } from "./parseFontFilename.js";
|
|
10
|
+
import { supportedFontOutputExtensions, supportedFontSourceExtensions } from "./supportedFontExtensions.js";
|
|
11
11
|
async function processFontFile(sourcePath, originalsDir, optimizedDir, result, logger) {
|
|
12
12
|
const extension = path.extname(sourcePath).toLowerCase();
|
|
13
13
|
const relativePath = path.relative(originalsDir, sourcePath);
|
|
@@ -41,7 +41,7 @@ export function parseFontFilename(filename) {
|
|
|
41
41
|
}
|
|
42
42
|
else if (second.match(/^\d{3}$/)) {
|
|
43
43
|
fontFamily = first;
|
|
44
|
-
fontWeight = parseInt(second, 10);
|
|
44
|
+
fontWeight = Number.parseInt(second, 10);
|
|
45
45
|
}
|
|
46
46
|
else if (second === "Italic") {
|
|
47
47
|
fontFamily = first;
|
|
@@ -61,7 +61,7 @@ export function parseFontFilename(filename) {
|
|
|
61
61
|
last = parts[parts.length - 1] ?? "";
|
|
62
62
|
}
|
|
63
63
|
if (last.match(/^\d{3}$/)) {
|
|
64
|
-
fontWeight = parseInt(last, 10);
|
|
64
|
+
fontWeight = Number.parseInt(last, 10);
|
|
65
65
|
parts.pop();
|
|
66
66
|
}
|
|
67
67
|
else if (last in weightMap) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptimizeImagesOptions.d.ts","sourceRoot":"","sources":["../../src/image/OptimizeImagesOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B"}
|
|
1
|
+
{"version":3,"file":"OptimizeImagesOptions.d.ts","sourceRoot":"","sources":["../../src/image/OptimizeImagesOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcessImagesOptions.d.ts","sourceRoot":"","sources":["../../src/image/ProcessImagesOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,MAAM,WAAW,oBAAoB;IACnC,iBAAiB,EAAE,MAAM,CAAA;IACzB,iBAAiB,EAAE,MAAM,CAAA;IACzB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,MAAM,EAAE,oBAAoB,CAAA;IAC5B,MAAM,EAAE,MAAM,CAAA;CACf"}
|
|
1
|
+
{"version":3,"file":"ProcessImagesOptions.d.ts","sourceRoot":"","sources":["../../src/image/ProcessImagesOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,MAAM,WAAW,oBAAoB;IACnC,iBAAiB,EAAE,MAAM,CAAA;IACzB,iBAAiB,EAAE,MAAM,CAAA;IACzB,mBAAmB,EAAE,OAAO,CAAA;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,oBAAoB,CAAA;IAC5B,MAAM,EAAE,MAAM,CAAA;CACf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { AssetsOptimizeResult } from "../AssetsOptimizeResult.js";
|
|
2
2
|
import { type ExpectedImage } from "./ExpectedImage.js";
|
|
3
|
-
export declare function buildExpectedImages(originalsDir: string, optimizedDir: string, result: AssetsOptimizeResult, allowRootImageFiles?: boolean): Promise<ExpectedImage[]>;
|
|
3
|
+
export declare function buildExpectedImages(originalsDir: string, optimizedDir: string, result: AssetsOptimizeResult, allowRootImageFiles?: boolean, hashLength?: number): Promise<ExpectedImage[]>;
|
|
4
4
|
//# sourceMappingURL=buildExpectedImages.d.ts.map
|
|
@@ -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,
|
|
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,EAC3B,UAAU,SAAI,GACb,OAAO,CAAC,aAAa,EAAE,CAAC,CA8F1B"}
|
|
@@ -7,7 +7,7 @@ import {} from "./ExpectedImage.js";
|
|
|
7
7
|
import { parseTransformSpec } from "./parseTransformSpec.js";
|
|
8
8
|
import { processImage } from "./processImage.js";
|
|
9
9
|
import { supportedSourceExtensions } from "./supportedSourceExtensions.js";
|
|
10
|
-
export async function buildExpectedImages(originalsDir, optimizedDir, result, allowRootImageFiles = false) {
|
|
10
|
+
export async function buildExpectedImages(originalsDir, optimizedDir, result, allowRootImageFiles = false, hashLength = 8) {
|
|
11
11
|
const dirEntries = await fs.readdir(originalsDir, { withFileTypes: true });
|
|
12
12
|
const expectedImages = [];
|
|
13
13
|
for (const entry of dirEntries) {
|
|
@@ -32,7 +32,7 @@ export async function buildExpectedImages(originalsDir, optimizedDir, result, al
|
|
|
32
32
|
console.warn(`Skipped root source file with unsupported output format: ${entry.name}`);
|
|
33
33
|
continue;
|
|
34
34
|
}
|
|
35
|
-
const hash = createOutputHash(sourceBuffer, transform.normalized);
|
|
35
|
+
const hash = createOutputHash(sourceBuffer, transform.normalized, hashLength);
|
|
36
36
|
const baseName = path.parse(entryPath).name;
|
|
37
37
|
const fileName = `${baseName}_${hash}.${transform.format}`;
|
|
38
38
|
const outputPath = path.join(optimizedDir, fileName);
|
|
@@ -70,7 +70,7 @@ export async function buildExpectedImages(originalsDir, optimizedDir, result, al
|
|
|
70
70
|
continue;
|
|
71
71
|
}
|
|
72
72
|
const sourceBuffer = await fs.readFile(sourceFile);
|
|
73
|
-
const hash = createOutputHash(sourceBuffer, transform.normalized);
|
|
73
|
+
const hash = createOutputHash(sourceBuffer, transform.normalized, hashLength);
|
|
74
74
|
const baseName = path.parse(sourceFile).name;
|
|
75
75
|
const fileName = `${baseName}_${hash}.${transform.format}`;
|
|
76
76
|
const outputPath = path.join(optimizedDir, fileName);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function createOutputHash(sourceBuffer: Buffer, transformSpec: string): string;
|
|
1
|
+
export declare function createOutputHash(sourceBuffer: Buffer, transformSpec: string, hashLength?: number): string;
|
|
2
2
|
//# sourceMappingURL=createOutputHash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOutputHash.d.ts","sourceRoot":"","sources":["../../src/image/createOutputHash.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"createOutputHash.d.ts","sourceRoot":"","sources":["../../src/image/createOutputHash.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,SAAI,GAAG,MAAM,CAEpG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
export function createOutputHash(sourceBuffer, transformSpec) {
|
|
3
|
-
return createHash("sha256").update(sourceBuffer).update(transformSpec).digest("hex").slice(0,
|
|
2
|
+
export function createOutputHash(sourceBuffer, transformSpec, hashLength = 8) {
|
|
3
|
+
return createHash("sha256").update(sourceBuffer).update(transformSpec).digest("hex").slice(0, hashLength);
|
|
4
4
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function createOutputHashForFile(sourcePath: string, transformSpec: string): Promise<string>;
|
|
1
|
+
export declare function createOutputHashForFile(sourcePath: string, transformSpec: string, hashLength?: number): Promise<string>;
|
|
2
2
|
//# sourceMappingURL=createOutputHashForFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createOutputHashForFile.d.ts","sourceRoot":"","sources":["../../src/image/createOutputHashForFile.ts"],"names":[],"mappings":"AAGA,wBAAsB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"createOutputHashForFile.d.ts","sourceRoot":"","sources":["../../src/image/createOutputHashForFile.ts"],"names":[],"mappings":"AAGA,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,UAAU,SAAI,GACb,OAAO,CAAC,MAAM,CAAC,CAajB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import fs from "node:fs";
|
|
3
|
-
export async function createOutputHashForFile(sourcePath, transformSpec) {
|
|
3
|
+
export async function createOutputHashForFile(sourcePath, transformSpec, hashLength = 8) {
|
|
4
4
|
const hash = createHash("sha256");
|
|
5
5
|
await new Promise((resolve, reject) => {
|
|
6
6
|
const stream = fs.createReadStream(sourcePath);
|
|
@@ -10,5 +10,5 @@ export async function createOutputHashForFile(sourcePath, transformSpec) {
|
|
|
10
10
|
stream.on("end", resolve);
|
|
11
11
|
stream.on("error", reject);
|
|
12
12
|
});
|
|
13
|
-
return hash.update(transformSpec).digest("hex").slice(0,
|
|
13
|
+
return hash.update(transformSpec).digest("hex").slice(0, hashLength);
|
|
14
14
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { imageSize } from "image-size";
|
|
2
1
|
import path from "node:path";
|
|
2
|
+
import { imageSize } from "image-size";
|
|
3
3
|
export function createRootImageTransform(sourceFile, sourceBuffer) {
|
|
4
4
|
const format = getOutputFormat(path.extname(sourceFile).toLowerCase());
|
|
5
5
|
if (!format) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimizeImages.d.ts","sourceRoot":"","sources":["../../src/image/optimizeImages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"optimizeImages.d.ts","sourceRoot":"","sources":["../../src/image/optimizeImages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAItE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAGvE,wBAAsB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA4CvG"}
|
|
@@ -8,6 +8,7 @@ export async function optimizeImages(options = {}) {
|
|
|
8
8
|
const imageOriginalsDir = path.resolve(cwd, options.imageOriginalsDir ?? "images");
|
|
9
9
|
const imageOptimizedDir = path.resolve(cwd, options.imageOptimizedDir ?? "public/images");
|
|
10
10
|
const imageListOutputPath = path.resolve(cwd, options.imageListOutputPath ?? "src/app/assets/imageList.ts");
|
|
11
|
+
const hashLength = options.imageHashLength ?? 8;
|
|
11
12
|
const logger = createLogger(options.logLevel);
|
|
12
13
|
const result = {
|
|
13
14
|
processed: [],
|
|
@@ -26,11 +27,12 @@ export async function optimizeImages(options = {}) {
|
|
|
26
27
|
imageOriginalsDir,
|
|
27
28
|
imageOptimizedDir,
|
|
28
29
|
allowRootImageFiles: options.allowRootImageFiles === true,
|
|
30
|
+
hashLength,
|
|
29
31
|
result,
|
|
30
32
|
logger,
|
|
31
33
|
});
|
|
32
34
|
if (options.generateImageList !== false) {
|
|
33
|
-
await generateImageList(imageOptimizedDir, imageListOutputPath,
|
|
35
|
+
await generateImageList(imageOptimizedDir, imageListOutputPath, options.imageTypeImportPath, logger, imageOriginalsDir, hashLength);
|
|
34
36
|
}
|
|
35
37
|
printSummary(result, logger);
|
|
36
38
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processImages.d.ts","sourceRoot":"","sources":["../../src/image/processImages.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAErE,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"processImages.d.ts","sourceRoot":"","sources":["../../src/image/processImages.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAErE,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBhF"}
|
|
@@ -3,10 +3,10 @@ import path from "node:path";
|
|
|
3
3
|
import { listLocalFiles } from "../shared/listLocalFiles.js";
|
|
4
4
|
import { buildExpectedImages } from "./buildExpectedImages.js";
|
|
5
5
|
export async function processImages(options) {
|
|
6
|
-
const { allowRootImageFiles, imageOptimizedDir, imageOriginalsDir, result } = options;
|
|
6
|
+
const { allowRootImageFiles, hashLength, imageOptimizedDir, imageOriginalsDir, result } = options;
|
|
7
7
|
await fs.mkdir(imageOriginalsDir, { recursive: true });
|
|
8
8
|
await fs.mkdir(imageOptimizedDir, { recursive: true });
|
|
9
|
-
const expectedImages = await buildExpectedImages(imageOriginalsDir, imageOptimizedDir, result, allowRootImageFiles);
|
|
9
|
+
const expectedImages = await buildExpectedImages(imageOriginalsDir, imageOptimizedDir, result, allowRootImageFiles, hashLength);
|
|
10
10
|
const expectedFileNames = new Set(expectedImages.map((image) => image.fileName));
|
|
11
11
|
const localOptimizedFiles = await listLocalFiles(imageOptimizedDir);
|
|
12
12
|
for (const localFile of localOptimizedFiles) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
export * from "./assetsOptimize.js";
|
|
2
1
|
export * from "./AssetsOptimizeOptions.js";
|
|
3
2
|
export * from "./AssetsOptimizeResult.js";
|
|
3
|
+
export * from "./assetsOptimize.js";
|
|
4
|
+
export * from "./font/OptimizeFontsOptions.js";
|
|
5
|
+
export * from "./font/optimizeFonts.js";
|
|
6
|
+
export * from "./font/ProcessFontsOptions.js";
|
|
7
|
+
export * from "./font/parseFontFilename.js";
|
|
8
|
+
export * from "./font/supportedFontExtensions.js";
|
|
4
9
|
export * from "./image/buildExpectedImages.js";
|
|
5
10
|
export * from "./image/createOutputHash.js";
|
|
6
11
|
export * from "./image/defaultQuality.js";
|
|
7
12
|
export * from "./image/ExpectedImage.js";
|
|
8
13
|
export * from "./image/ImageFormat.js";
|
|
9
|
-
export * from "./image/optimizeImages.js";
|
|
10
14
|
export * from "./image/OptimizeImagesOptions.js";
|
|
15
|
+
export * from "./image/optimizeImages.js";
|
|
16
|
+
export * from "./image/ProcessImagesOptions.js";
|
|
11
17
|
export * from "./image/parseTransformSpec.js";
|
|
12
18
|
export * from "./image/processImage.js";
|
|
13
19
|
export * from "./image/processImages.js";
|
|
14
|
-
export * from "./image/ProcessImagesOptions.js";
|
|
15
20
|
export * from "./image/supportedSourceExtensions.js";
|
|
16
21
|
export * from "./image/TransformSpec.js";
|
|
17
|
-
export * from "./font/OptimizeFontsOptions.js";
|
|
18
|
-
export * from "./font/optimizeFonts.js";
|
|
19
|
-
export * from "./font/parseFontFilename.js";
|
|
20
|
-
export * from "./font/ProcessFontsOptions.js";
|
|
21
|
-
export * from "./font/supportedFontExtensions.js";
|
|
22
22
|
export * from "./list/AssetListTypes.js";
|
|
23
23
|
export * from "./list/generateFontList.js";
|
|
24
24
|
export * from "./list/generateImageList.js";
|
|
25
25
|
export * from "./list/generateVideoList.js";
|
|
26
|
-
export * from "./process/processAssets.js";
|
|
27
26
|
export * from "./process/ProcessAssetsOptions.js";
|
|
27
|
+
export * from "./process/processAssets.js";
|
|
28
28
|
export * from "./process/utils/shouldBisync.js";
|
|
29
29
|
export * from "./rclone/bisync.js";
|
|
30
30
|
export * from "./rclone/runRclone.js";
|
|
@@ -35,8 +35,8 @@ export * from "./shared/printSummary.js";
|
|
|
35
35
|
export * from "./shared/walkFiles.js";
|
|
36
36
|
export * from "./video/createVideoPreviewPath.js";
|
|
37
37
|
export * from "./video/ensureVideoPreviews.js";
|
|
38
|
-
export * from "./video/optimizeVideos.js";
|
|
39
38
|
export * from "./video/OptimizeVideosOptions.js";
|
|
40
|
-
export * from "./video/
|
|
39
|
+
export * from "./video/optimizeVideos.js";
|
|
41
40
|
export * from "./video/ProcessVideosOptions.js";
|
|
41
|
+
export * from "./video/processVideos.js";
|
|
42
42
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,2BAA2B,CAAA;AACzC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,yBAAyB,CAAA;AACvC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,mCAAmC,CAAA;AACjD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,kCAAkC,CAAA;AAChD,cAAc,2BAA2B,CAAA;AACzC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,yBAAyB,CAAA;AACvC,cAAc,0BAA0B,CAAA;AACxC,cAAc,sCAAsC,CAAA;AACpD,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,mCAAmC,CAAA;AACjD,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,mCAAmC,CAAA;AACjD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,kCAAkC,CAAA;AAChD,cAAc,2BAA2B,CAAA;AACzC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,0BAA0B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
export * from "./assetsOptimize.js";
|
|
2
1
|
export * from "./AssetsOptimizeOptions.js";
|
|
3
2
|
export * from "./AssetsOptimizeResult.js";
|
|
3
|
+
export * from "./assetsOptimize.js";
|
|
4
|
+
export * from "./font/OptimizeFontsOptions.js";
|
|
5
|
+
export * from "./font/optimizeFonts.js";
|
|
6
|
+
export * from "./font/ProcessFontsOptions.js";
|
|
7
|
+
export * from "./font/parseFontFilename.js";
|
|
8
|
+
export * from "./font/supportedFontExtensions.js";
|
|
4
9
|
export * from "./image/buildExpectedImages.js";
|
|
5
10
|
export * from "./image/createOutputHash.js";
|
|
6
11
|
export * from "./image/defaultQuality.js";
|
|
7
12
|
export * from "./image/ExpectedImage.js";
|
|
8
13
|
export * from "./image/ImageFormat.js";
|
|
9
|
-
export * from "./image/optimizeImages.js";
|
|
10
14
|
export * from "./image/OptimizeImagesOptions.js";
|
|
15
|
+
export * from "./image/optimizeImages.js";
|
|
16
|
+
export * from "./image/ProcessImagesOptions.js";
|
|
11
17
|
export * from "./image/parseTransformSpec.js";
|
|
12
18
|
export * from "./image/processImage.js";
|
|
13
19
|
export * from "./image/processImages.js";
|
|
14
|
-
export * from "./image/ProcessImagesOptions.js";
|
|
15
20
|
export * from "./image/supportedSourceExtensions.js";
|
|
16
21
|
export * from "./image/TransformSpec.js";
|
|
17
|
-
export * from "./font/OptimizeFontsOptions.js";
|
|
18
|
-
export * from "./font/optimizeFonts.js";
|
|
19
|
-
export * from "./font/parseFontFilename.js";
|
|
20
|
-
export * from "./font/ProcessFontsOptions.js";
|
|
21
|
-
export * from "./font/supportedFontExtensions.js";
|
|
22
22
|
export * from "./list/AssetListTypes.js";
|
|
23
23
|
export * from "./list/generateFontList.js";
|
|
24
24
|
export * from "./list/generateImageList.js";
|
|
25
25
|
export * from "./list/generateVideoList.js";
|
|
26
|
-
export * from "./process/processAssets.js";
|
|
27
26
|
export * from "./process/ProcessAssetsOptions.js";
|
|
27
|
+
export * from "./process/processAssets.js";
|
|
28
28
|
export * from "./process/utils/shouldBisync.js";
|
|
29
29
|
export * from "./rclone/bisync.js";
|
|
30
30
|
export * from "./rclone/runRclone.js";
|
|
@@ -35,7 +35,7 @@ export * from "./shared/printSummary.js";
|
|
|
35
35
|
export * from "./shared/walkFiles.js";
|
|
36
36
|
export * from "./video/createVideoPreviewPath.js";
|
|
37
37
|
export * from "./video/ensureVideoPreviews.js";
|
|
38
|
-
export * from "./video/optimizeVideos.js";
|
|
39
38
|
export * from "./video/OptimizeVideosOptions.js";
|
|
40
|
-
export * from "./video/
|
|
39
|
+
export * from "./video/optimizeVideos.js";
|
|
41
40
|
export * from "./video/ProcessVideosOptions.js";
|
|
41
|
+
export * from "./video/processVideos.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateFontList.d.ts","sourceRoot":"","sources":["../../src/list/generateFontList.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateFontList.d.ts","sourceRoot":"","sources":["../../src/list/generateFontList.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAQjD,wBAAsB,gBAAgB,CACpC,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAUf"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { parseFontFilename } from "../font/parseFontFilename.js";
|
|
4
|
+
import { supportedFontOutputExtensions } from "../font/supportedFontExtensions.js";
|
|
3
5
|
import { getOwnPackageName } from "../shared/getOwnPackageName.js";
|
|
4
6
|
import { isMissingDirError } from "../shared/isMissingDirError.js";
|
|
5
7
|
import { walkFiles } from "../shared/walkFiles.js";
|
|
6
|
-
import { supportedFontOutputExtensions } from "../font/supportedFontExtensions.js";
|
|
7
8
|
import { formatGeneratedCodeFile } from "./formatGeneratedCodeFile.js";
|
|
8
9
|
import { getAssetKey } from "./getAssetKey.js";
|
|
9
10
|
import { loadExistingAssetList } from "./loadExistingAssetList.js";
|
|
10
11
|
import { sortAssetMap } from "./sortAssetMap.js";
|
|
11
|
-
import { parseFontFilename } from "../font/parseFontFilename.js";
|
|
12
12
|
export async function generateFontList(fontsDirectory, outputPath, fontTypeImportPath, logger) {
|
|
13
13
|
const resolvedFontTypeImportPath = fontTypeImportPath ?? (await getOwnPackageName(import.meta.url));
|
|
14
14
|
const existingFonts = await loadExistingAssetList(outputPath, "fontList");
|
|
@@ -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, altTextDirectory?: string): Promise<void>;
|
|
2
|
+
export declare function generateImageList(imageDirectory: string, outputPath: string, imageTypeImportPath?: string, logger?: Logger, altTextDirectory?: string, hashLength?: number): 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,EACf,gBAAgB,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,EACzB,UAAU,SAAI,GACb,OAAO,CAAC,IAAI,CAAC,CAYf"}
|
|
@@ -8,11 +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, altTextDirectory) {
|
|
11
|
+
export async function generateImageList(imageDirectory, outputPath, imageTypeImportPath, logger, altTextDirectory, hashLength = 8) {
|
|
12
12
|
const resolvedImageTypeImportPath = imageTypeImportPath ?? (await getOwnPackageName(import.meta.url));
|
|
13
13
|
const existingImages = await loadExistingAssetList(outputPath, "imageList");
|
|
14
|
-
const imageAlts = altTextDirectory ? await loadImageAlts(altTextDirectory, logger) : {};
|
|
15
|
-
const imageMap = await processImageFiles(imageDirectory, existingImages, imageAlts, logger);
|
|
14
|
+
const imageAlts = altTextDirectory ? await loadImageAlts(altTextDirectory, hashLength, logger) : {};
|
|
15
|
+
const imageMap = await processImageFiles(imageDirectory, existingImages, imageAlts, hashLength, logger);
|
|
16
16
|
const sorted = sortAssetMap(imageMap);
|
|
17
17
|
await fs.mkdir(path.dirname(outputPath), { recursive: true });
|
|
18
18
|
await Bun.write(outputPath, createGeneratedImageListContent(sorted, resolvedImageTypeImportPath));
|
|
@@ -20,7 +20,7 @@ export async function generateImageList(imageDirectory, outputPath, imageTypeImp
|
|
|
20
20
|
logger?.files(`generated image list: ${outputPath}`);
|
|
21
21
|
logger?.summary(`Generated ${Object.keys(sorted).length} images to ${outputPath}`);
|
|
22
22
|
}
|
|
23
|
-
async function processImageFiles(directory, existingImages, imageAlts, logger) {
|
|
23
|
+
async function processImageFiles(directory, existingImages, imageAlts, hashLength, logger) {
|
|
24
24
|
const imageMap = {};
|
|
25
25
|
for (const filePath of await walkFiles(directory)) {
|
|
26
26
|
const extension = path.extname(filePath).toLowerCase();
|
|
@@ -34,13 +34,13 @@ async function processImageFiles(directory, existingImages, imageAlts, logger) {
|
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
36
|
const relativePath = path.relative(directory, filePath);
|
|
37
|
-
const key = normalizeGeneratedImageKey(getAssetKey(filePath));
|
|
37
|
+
const key = normalizeGeneratedImageKey(getAssetKey(filePath), hashLength);
|
|
38
38
|
const fileName = path.basename(filePath, extension);
|
|
39
39
|
imageMap[key] = {
|
|
40
40
|
path: relativePath,
|
|
41
41
|
width: dimensions.width,
|
|
42
42
|
height: dimensions.height,
|
|
43
|
-
alt: imageAlts[key] || existingImages[key]?.alt || formatGeneratedImageAlt(fileName),
|
|
43
|
+
alt: imageAlts[key] || existingImages[key]?.alt || formatGeneratedImageAlt(fileName, hashLength),
|
|
44
44
|
mimeType: getImageMimeType(extension),
|
|
45
45
|
};
|
|
46
46
|
}
|
|
@@ -50,14 +50,14 @@ async function processImageFiles(directory, existingImages, imageAlts, logger) {
|
|
|
50
50
|
}
|
|
51
51
|
return imageMap;
|
|
52
52
|
}
|
|
53
|
-
async function loadImageAlts(directory, logger) {
|
|
53
|
+
async function loadImageAlts(directory, hashLength, logger) {
|
|
54
54
|
const imageAlts = {};
|
|
55
55
|
for (const filePath of await walkFiles(directory)) {
|
|
56
56
|
if (path.extname(filePath).toLowerCase() !== ".md") {
|
|
57
57
|
continue;
|
|
58
58
|
}
|
|
59
59
|
try {
|
|
60
|
-
const key = normalizeGeneratedImageKey(getAssetKey(filePath));
|
|
60
|
+
const key = normalizeGeneratedImageKey(getAssetKey(filePath), hashLength);
|
|
61
61
|
const alt = formatMarkdownAlt(await fs.readFile(filePath, "utf-8"));
|
|
62
62
|
if (alt) {
|
|
63
63
|
imageAlts[key] = alt;
|
|
@@ -69,11 +69,11 @@ async function loadImageAlts(directory, logger) {
|
|
|
69
69
|
}
|
|
70
70
|
return imageAlts;
|
|
71
71
|
}
|
|
72
|
-
function normalizeGeneratedImageKey(key) {
|
|
73
|
-
return key.replace(
|
|
72
|
+
function normalizeGeneratedImageKey(key, hashLength) {
|
|
73
|
+
return key.replace(new RegExp(`_[0-9a-f]{${hashLength}}$`, "i"), "");
|
|
74
74
|
}
|
|
75
|
-
function formatGeneratedImageAlt(fileName) {
|
|
76
|
-
return normalizeGeneratedImageKey(fileName).replace(/[-_]/g, " ");
|
|
75
|
+
function formatGeneratedImageAlt(fileName, hashLength) {
|
|
76
|
+
return normalizeGeneratedImageKey(fileName, hashLength).replace(/[-_]/g, " ");
|
|
77
77
|
}
|
|
78
78
|
function formatMarkdownAlt(content) {
|
|
79
79
|
return content.replace(/\s+/g, " ").trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bisync.d.ts","sourceRoot":"","sources":["../../src/rclone/bisync.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED;;GAEG;AACH,wBAAsB,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"bisync.d.ts","sourceRoot":"","sources":["../../src/rclone/bisync.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED;;GAEG;AACH,wBAAsB,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAa9G"}
|
package/dist/rclone/bisync.js
CHANGED
|
@@ -9,14 +9,7 @@ export async function bisync(localPath, remotePath, options = {}) {
|
|
|
9
9
|
const localDirExists = await dirExists(localPath);
|
|
10
10
|
await fs.mkdir(localPath, { recursive: true });
|
|
11
11
|
await runRclone(["mkdir", remotePath], cwd);
|
|
12
|
-
const args = [
|
|
13
|
-
"bisync",
|
|
14
|
-
localPath,
|
|
15
|
-
remotePath,
|
|
16
|
-
"--create-empty-src-dirs",
|
|
17
|
-
"--resilient",
|
|
18
|
-
"--recover",
|
|
19
|
-
];
|
|
12
|
+
const args = ["bisync", localPath, remotePath, "--create-empty-src-dirs", "--resilient", "--recover"];
|
|
20
13
|
if (options.resync === true || !localDirExists) {
|
|
21
14
|
args.push("--resync");
|
|
22
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optimizeVideos.d.ts","sourceRoot":"","sources":["../../src/video/optimizeVideos.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"optimizeVideos.d.ts","sourceRoot":"","sources":["../../src/video/optimizeVideos.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAStE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAkEvE,wBAAsB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAiCvG"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import fs from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { generateVideoList } from "../list/generateVideoList.js";
|
|
3
4
|
import { dirExists } from "../shared/dirExists.js";
|
|
4
5
|
import { createLogger } from "../shared/logger.js";
|
|
5
6
|
import { printSummary } from "../shared/printSummary.js";
|
|
6
|
-
import { supportedVideoSourceExtensions } from "./supportedVideoSourceExtensions.js";
|
|
7
7
|
import { walkFiles } from "../shared/walkFiles.js";
|
|
8
|
-
import { runFfmpeg } from "./runFfmpeg.js";
|
|
9
8
|
import { createVideoArgs } from "./createVideoArgs.js";
|
|
10
9
|
import { createVideoPreviewArgs } from "./createVideoPreviewArgs.js";
|
|
11
10
|
import { createVideoPreviewPath } from "./createVideoPreviewPath.js";
|
|
12
|
-
import {
|
|
11
|
+
import { runFfmpeg } from "./runFfmpeg.js";
|
|
12
|
+
import { supportedVideoSourceExtensions } from "./supportedVideoSourceExtensions.js";
|
|
13
13
|
async function processLocalVideos(videoOriginalsDir, videoOptimizedDir, cwd, result, logger) {
|
|
14
14
|
for (const sourceFile of await walkFiles(videoOriginalsDir)) {
|
|
15
15
|
const extension = path.extname(sourceFile).toLowerCase();
|