@divriots/jampack 0.28.0 → 0.30.1

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
package/dist/compress.js CHANGED
@@ -80,7 +80,7 @@ export async function compressFolder(state, exclude) {
80
80
  spinner.text = getProgressText(state);
81
81
  }
82
82
  }
83
- if (!state.options.misc.sequential_compress) {
83
+ if (!state.args.sequential_compress) {
84
84
  // "Parallel" processing
85
85
  await Promise.all(paths.map(compressFile));
86
86
  }
@@ -3,7 +3,7 @@ const default_options = {
3
3
  browserslist: 'defaults', // defaults = '> 0.5%, last 2 versions, Firefox ESR, not dead'
4
4
  },
5
5
  html: {
6
- add_css_reset_as: 'inline',
6
+ add_css_reset_as: 'off',
7
7
  sort_attributes: false,
8
8
  },
9
9
  css: {
@@ -61,7 +61,6 @@ const default_options = {
61
61
  },
62
62
  misc: {
63
63
  prefetch_links: 'off',
64
- sequential_compress: false,
65
64
  },
66
65
  };
67
66
  export default default_options;
@@ -61,6 +61,5 @@ export type Options = {
61
61
  };
62
62
  misc: {
63
63
  prefetch_links: 'in-viewport' | 'off';
64
- sequential_compress: boolean;
65
64
  };
66
65
  };
package/dist/index.js CHANGED
@@ -39,6 +39,7 @@ program
39
39
  .option('--onlyoptim', 'Only optimize (PASS 1).')
40
40
  .option('--onlycomp', 'Only compress (PASS 2).')
41
41
  .option('--cache_folder <cache_folder>', 'Default: .jampack/cache')
42
+ .option('--sequential_compress', 'Whether to perform folder compression sequentially. Reduces memoru footprint on compress. Default: false')
42
43
  .option('--cleancache', 'Clean cache before running')
43
44
  .option('--nocache', 'Run with no use of cache')
44
45
  .action(async (dir, options) => {
@@ -85,6 +86,7 @@ program
85
86
  if (options.fail && state.issues.size > 0) {
86
87
  exit(1);
87
88
  }
89
+ exit(0);
88
90
  });
89
91
  program.parse();
90
92
  function printSummary($state) {
package/dist/optimize.js CHANGED
@@ -433,6 +433,11 @@ async function processImage(state, htmlfile, img, isAboveTheFold) {
433
433
  const ifmt = imageToEmbed.format;
434
434
  switch (ifmt) {
435
435
  case 'svg':
436
+ // When embedded, if the SVG file has width and height attributes (or viewBox without corresponding width/height),
437
+ // the browser respects those attributes over the external <img> tag attributes.
438
+ // TODO update the SVG - meanwhile don't embed it if there are attributes
439
+ if (img.attr('width') || img.attr('height'))
440
+ break;
436
441
  datauri = svgToMiniDataURI(imageToEmbed.data.toString());
437
442
  break;
438
443
  case 'webp':
package/dist/state.d.ts CHANGED
@@ -2,6 +2,7 @@ export type Args = {
2
2
  nowrite?: boolean;
3
3
  nocache?: boolean;
4
4
  cache_folder?: string;
5
+ sequential_compress?: boolean;
5
6
  };
6
7
  export type ReportItem = {
7
8
  action: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divriots/jampack",
3
- "version": "0.28.0",
3
+ "version": "0.30.1",
4
4
  "cache-version": {
5
5
  "img": "v1",
6
6
  "img-ext": "v1"
@@ -59,17 +59,18 @@
59
59
  "tslib": "^2.6.2",
60
60
  "typescript": "^5.4.5"
61
61
  },
62
- "engines": {
63
- "node": ">=14.0.0"
64
- },
65
- "bugs": "https://github.com/divriots/jampack/issues",
66
- "keywords": [],
67
- "types": "dist/index.d.ts",
68
62
  "scripts": {
69
63
  "watch": "pnpm build --watch",
70
64
  "try": "shx rm -fr demo && cp -R demo_drc demo && node ./dist/index.js ./demo --nocache",
71
65
  "build": "shx rm -rf dist && tsc -b",
72
66
  "lint": "eslint . --ext .ts --config .eslintrc",
67
+ "prepublishOnly": "pnpm build",
73
68
  "cleanAllDotJampack": "find -s . | grep '.jampack$' | xargs rm -fr"
74
- }
75
- }
69
+ },
70
+ "engines": {
71
+ "node": ">=14.0.0"
72
+ },
73
+ "bugs": "https://github.com/divriots/jampack/issues",
74
+ "keywords": [],
75
+ "types": "dist/index.d.ts"
76
+ }