@divriots/jampack 0.23.2 → 0.23.4

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/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -219,19 +219,14 @@ For more options see [CLI options](https://jampack.divriots.com/cli-options/).
219
219
 
220
220
  ## `jampack` used in the wild
221
221
 
222
- - [divRIOTS.com](https://divRIOTS.com)
223
- - [Backlight.dev](https://backlight.dev)
224
- - [story.to.design](https://story.to.design)
225
- - [html.to.design](https://html.to.design/docs)
226
- - [WebComponents.dev](https://WebComponents.dev)
227
- - [LWC.studio](https://lwc.studio)
228
- - [Components.studio](https://components.studio)
222
+ - Powering all [‹div›RIOTS](https://divRIOTS.com)' websites
229
223
  - [keycloak.ch](https://keycloak.ch)
230
224
  - [bayjs.org](https://bayjs.org/)
231
225
  - [qwind.pages.dev](https://qwind.pages.dev/)
232
226
  - [Bloycey's Blog](https://bloycey.blog/)
233
227
  - [gxanshu.in](https://gxanshu.in/)
234
-
228
+ - [cloudcannon.com](https://cloudcannon.com)
229
+ - [groupsync.app](https://groupsync.app)
235
230
  > Add yours here
236
231
 
237
232
  ## Why is it called `jampack`?
@@ -53,6 +53,7 @@ const default_options = {
53
53
  },
54
54
  svg: {
55
55
  optimization: true,
56
+ add_width_and_height: false,
56
57
  },
57
58
  },
58
59
  misc: {
@@ -1,3 +1,4 @@
1
+ import type { UrlTransformer } from 'unpic';
1
2
  export type WebpOptions = {
2
3
  effort: number;
3
4
  mode: 'lossless' | 'lossly';
@@ -32,6 +33,7 @@ export type Options = {
32
33
  process: 'off' | 'optimize';
33
34
  src_include: RegExp;
34
35
  src_exclude: RegExp | null;
36
+ transformer?: UrlTransformer;
35
37
  };
36
38
  compress: boolean;
37
39
  jpeg: {
@@ -51,6 +53,7 @@ export type Options = {
51
53
  };
52
54
  svg: {
53
55
  optimization: boolean;
56
+ add_width_and_height: boolean;
54
57
  };
55
58
  };
56
59
  misc: {
package/dist/index.js CHANGED
File without changes
package/dist/optimize.js CHANGED
@@ -275,10 +275,13 @@ async function processImage(htmlfile, img, isAboveTheFold) {
275
275
  case 'off':
276
276
  break;
277
277
  case 'optimize':
278
- const canonical = getCanonicalCdnForUrl(attrib_src);
279
- if (!canonical)
280
- break;
281
- const cdnTransformer = getTransformer(canonical.cdn);
278
+ let cdnTransformer = config.image.cdn.transformer;
279
+ if (!cdnTransformer) {
280
+ const canonical = getCanonicalCdnForUrl(attrib_src);
281
+ if (!canonical)
282
+ break;
283
+ cdnTransformer = getTransformer(canonical.cdn);
284
+ }
282
285
  if (!cdnTransformer)
283
286
  break;
284
287
  if (!isIncluded(attrib_src, config.image.cdn.src_include, config.image.cdn.src_exclude))
@@ -647,6 +650,10 @@ async function setImageSize(htmlfile, img, image) {
647
650
  let height = img.attr('height');
648
651
  let width_new = undefined;
649
652
  let height_new = undefined;
653
+ const img_fmt = await image.getExt();
654
+ if (img_fmt === 'svg' && !config.image.svg.add_width_and_height) {
655
+ return [];
656
+ }
650
657
  // Check valid values
651
658
  if (width !== undefined) {
652
659
  if (!isNumeric(width)) {
@@ -693,7 +700,7 @@ async function setImageSize(htmlfile, img, image) {
693
700
  }
694
701
  else {
695
702
  // No width or height provided - set both to image size
696
- if ((await image.getExt()) === 'svg') {
703
+ if (img_fmt === 'svg') {
697
704
  // svg with no height and width has special sizing by browsers
698
705
  // They size it inside 300x150 unless they have width and height
699
706
  // attributes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divriots/jampack",
3
- "version": "0.23.2",
3
+ "version": "0.23.4",
4
4
  "cache-version": {
5
5
  "img": "v1",
6
6
  "img-ext": "v1"
@@ -58,17 +58,18 @@
58
58
  "tslib": "^2.6.2",
59
59
  "typescript": "^5.3.3"
60
60
  },
61
- "engines": {
62
- "node": ">=14.0.0"
63
- },
64
- "bugs": "https://github.com/divriots/jampack/issues",
65
- "keywords": [],
66
- "types": "dist/index.d.ts",
67
61
  "scripts": {
68
62
  "watch": "pnpm build --watch",
69
63
  "try": "shx rm -fr demo && cp -R demo_drc demo && node ./dist/index.js ./demo --nocache",
70
64
  "build": "shx rm -rf dist && tsc -b",
71
65
  "lint": "eslint . --ext .ts --config .eslintrc",
66
+ "prepublishOnly": "pnpm build",
72
67
  "cleanAllDotJampack": "find -s . | grep '.jampack$' | xargs rm -fr"
73
- }
74
- }
68
+ },
69
+ "engines": {
70
+ "node": ">=14.0.0"
71
+ },
72
+ "bugs": "https://github.com/divriots/jampack/issues",
73
+ "keywords": [],
74
+ "types": "dist/index.d.ts"
75
+ }