@divriots/jampack 0.14.0 → 0.15.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.
@@ -19,8 +19,6 @@ export async function compressImage(data, options) {
19
19
  }
20
20
  // Load modifiable toFormat
21
21
  let toFormat = options.toFormat || 'unchanged';
22
- if (!config.image.compress)
23
- return undefined;
24
22
  let sharpFile = await sharp(data, { animated: true });
25
23
  const meta = await sharpFile.metadata();
26
24
  if (meta.pages && meta.pages > 1) {
@@ -30,6 +28,8 @@ export async function compressImage(data, options) {
30
28
  let outputFormat;
31
29
  // Special case for svg
32
30
  if (meta.format === 'svg') {
31
+ if (!config.image.svg.optimization)
32
+ return undefined;
33
33
  try {
34
34
  const output = svgo(data.toString(), {
35
35
  multipass: true,
@@ -36,6 +36,9 @@ const default_options = {
36
36
  mode: 'lossly',
37
37
  },
38
38
  },
39
+ svg: {
40
+ optimization: true,
41
+ },
39
42
  },
40
43
  };
41
44
  export default default_options;
@@ -21,6 +21,9 @@ const fast_options_override = {
21
21
  effort: 0,
22
22
  },
23
23
  },
24
+ svg: {
25
+ optimization: false,
26
+ },
24
27
  },
25
28
  };
26
29
  export default fast_options_override;
@@ -33,5 +33,8 @@ export type Options = {
33
33
  options_lossless: WebpOptions;
34
34
  options_lossly: WebpOptions;
35
35
  };
36
+ svg: {
37
+ optimization: boolean;
38
+ };
36
39
  };
37
40
  };
package/dist/config.js CHANGED
@@ -10,7 +10,7 @@ export function fast() {
10
10
  export async function loadConfig() {
11
11
  const proload = await load('jampack', { mustExist: false });
12
12
  if (proload) {
13
- console.log('Overriding default config with:');
13
+ console.log('Merging default config with:');
14
14
  console.log(JSON.stringify(proload.value, null, 2));
15
15
  Object.assign(options, deepmerge(options, proload.value));
16
16
  }
package/dist/optimize.js CHANGED
@@ -252,10 +252,12 @@ async function processImage(htmlfile, $, imgElement, isAboveTheFold) {
252
252
  ? 'unchanged'
253
253
  : 'webp';
254
254
  }
255
- newImage = await compressImage(await originalImage.getData(), {
256
- toFormat: srcToFormat,
257
- resize: { width: config.image.srcset_max_width },
258
- });
255
+ if (config.image.compress) {
256
+ newImage = await compressImage(await originalImage.getData(), {
257
+ toFormat: srcToFormat,
258
+ resize: { width: config.image.srcset_max_width },
259
+ });
260
+ }
259
261
  if ((newImage === null || newImage === void 0 ? void 0 : newImage.data) &&
260
262
  (newImage.data.length < (await originalImage.getLen()) ||
261
263
  srcToFormat === 'jpeg+progressive') // Progressive override all even if worse
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divriots/jampack",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "cache-version": {
5
5
  "img": "v1",
6
6
  "img-ext": "v1"
@@ -22,29 +22,29 @@
22
22
  "dependencies": {
23
23
  "@divriots/cheerio": "1.0.0-rc.12",
24
24
  "@proload/core": "^0.3.3",
25
- "@swc/core": "^1.3.57",
25
+ "@swc/core": "^1.3.80",
26
26
  "commander": "^10.0.1",
27
27
  "deepmerge": "^4.3.1",
28
- "file-type": "^18.4.0",
29
- "globby": "^13.1.4",
28
+ "file-type": "^18.5.0",
29
+ "globby": "^13.2.2",
30
30
  "hasha": "^5.2.2",
31
31
  "html-minifier-terser": "^7.2.0",
32
32
  "kleur": "^4.1.5",
33
- "lightningcss": "^1.20.0",
33
+ "lightningcss": "^1.21.5",
34
34
  "mini-svg-data-uri": "^1.4.4",
35
- "ora": "^6.3.0",
35
+ "ora": "^7.0.1",
36
36
  "sharp": "^0.32.5",
37
37
  "svgo": "^3.0.2",
38
38
  "table": "^6.8.1",
39
- "undici": "^5.22.1"
39
+ "undici": "^5.23.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/html-minifier-terser": "^7.0.0",
43
- "@types/node": "^16.18.28",
43
+ "@types/node": "^20.5.7",
44
44
  "shx": "^0.3.3",
45
45
  "ts-node": "^10.2.1",
46
- "tslib": "^2.5.0",
47
- "typescript": "^5.0.4"
46
+ "tslib": "^2.6.2",
47
+ "typescript": "^5.2.2"
48
48
  },
49
49
  "scripts": {
50
50
  "watch": "pnpm build --watch",