@divriots/jampack 0.11.5 → 0.11.7

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
File without changes
@@ -5,6 +5,11 @@ const default_options = {
5
5
  image: {
6
6
  embed_size: 1500,
7
7
  srcset_min_width: 640,
8
+ external: {
9
+ process: 'off',
10
+ src_include: /^.*$/,
11
+ src_exclude: null,
12
+ },
8
13
  compress: true,
9
14
  jpeg: {
10
15
  options: {
@@ -10,6 +10,11 @@ export type Options = {
10
10
  image: {
11
11
  embed_size: number;
12
12
  srcset_min_width: number;
13
+ external: {
14
+ process: 'download' | 'cdn-srcset-when-possible' | 'add-dimensions-only' | 'off';
15
+ src_include: RegExp;
16
+ src_exclude: RegExp | null;
17
+ };
13
18
  compress: boolean;
14
19
  jpeg: {
15
20
  options: {
package/dist/index.js CHANGED
File without changes
package/dist/optimize.js CHANGED
@@ -80,7 +80,7 @@ async function analyse(file) {
80
80
  }
81
81
  // Add CSS to head
82
82
  if (config.html.add_css_reset_as === 'inline') {
83
- const CSS = `<style>:where(img){height:auto;width:auto}</style>`;
83
+ const CSS = `<style>:where(img){height:auto;}</style>`;
84
84
  const heads = $('head');
85
85
  if (heads.length > 0) {
86
86
  heads.prepend(CSS);
@@ -184,9 +184,24 @@ async function processImage(htmlfile, $, imgElement, isAboveTheFold) {
184
184
  * Attribute 'decoding'
185
185
  */
186
186
  img.attr('decoding', 'async');
187
+ /*
188
+ * Check for external images
189
+ */
187
190
  if (!isLocal(attrib_src)) {
188
- // Image not local, don't touch it
189
- return;
191
+ switch (config.image.external.process) {
192
+ case 'off':
193
+ // Don't process external images
194
+ return;
195
+ case 'download':
196
+ // Download external image for local processing
197
+ break;
198
+ case 'cdn-srcset-when-possible':
199
+ // Use unpic to use CDN capabilities
200
+ throw new Error('External images with `cdn-srcset-when-possible` is not implemented yet.');
201
+ case 'add-dimensions-only':
202
+ // Only add dimensions of image
203
+ throw new Error('External images with `add-dimensions-only` is not implemented yet.');
204
+ }
190
205
  }
191
206
  /*
192
207
  * Loading image
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divriots/jampack",
3
- "version": "0.11.5",
3
+ "version": "0.11.7",
4
4
  "description": "Packer for static websites",
5
5
  "author": "Georges Gomes @georges-gomes",
6
6
  "bin": {
@@ -41,16 +41,16 @@
41
41
  "tslib": "^2.5.0",
42
42
  "typescript": "^5.0.4"
43
43
  },
44
- "engines": {
45
- "node": ">=14.0.0"
46
- },
47
- "bugs": "https://github.com/divriots/jampack/issues",
48
- "keywords": [],
49
- "types": "dist/index.d.ts",
50
44
  "scripts": {
51
45
  "watch": "pnpm build --watch",
52
46
  "try": "shx rm -fr demo && cp -R demo_rf demo && node ./dist/index.js ./demo --nocache --onlyoptim",
53
47
  "build": "shx rm -rf dist && tsc -b",
54
48
  "lint": "eslint . --ext .ts --config .eslintrc"
55
- }
56
- }
49
+ },
50
+ "engines": {
51
+ "node": ">=14.0.0"
52
+ },
53
+ "bugs": "https://github.com/divriots/jampack/issues",
54
+ "keywords": [],
55
+ "types": "dist/index.d.ts"
56
+ }