@divriots/jampack 0.27.0 → 0.28.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/LICENSE CHANGED
File without changes
package/README.md CHANGED
File without changes
package/dist/compress.js CHANGED
@@ -74,13 +74,20 @@ export async function compressFolder(state, exclude) {
74
74
  if (exclude)
75
75
  globs.push('!' + exclude);
76
76
  const paths = await globby(globs, { cwd: state.dir, absolute: true });
77
- // "Parallel" processing
78
- await Promise.all(paths.map(async (file) => {
77
+ async function compressFile(file) {
79
78
  if (!state.compressedFiles.has(file)) {
80
79
  await processFile(state, file, await fs.stat(file));
81
80
  spinner.text = getProgressText(state);
82
81
  }
83
- }));
82
+ }
83
+ if (!state.options.misc.sequential_compress) {
84
+ // "Parallel" processing
85
+ await Promise.all(paths.map(compressFile));
86
+ }
87
+ else {
88
+ for (const file of paths)
89
+ await compressFile(file);
90
+ }
84
91
  spinner.text = getProgressText(state);
85
92
  spinner.succeed();
86
93
  }
@@ -16,6 +16,7 @@ const default_options = {
16
16
  embed_size: 1500,
17
17
  srcset_min_width: 390 * 2, // HiDPI phone
18
18
  srcset_max_width: 1920 * 2, // 4K
19
+ srcset_step: 300,
19
20
  max_width: 99999,
20
21
  src_include: /^.*$/,
21
22
  src_exclude: /^\/vercel\/image\?/, // Ignore /vervel/image? URLs because not local and most likely already optimized,
@@ -60,6 +61,7 @@ const default_options = {
60
61
  },
61
62
  misc: {
62
63
  prefetch_links: 'off',
64
+ sequential_compress: false,
63
65
  },
64
66
  };
65
67
  export default default_options;
@@ -23,6 +23,7 @@ export type Options = {
23
23
  embed_size: number;
24
24
  srcset_min_width: number;
25
25
  srcset_max_width: number;
26
+ srcset_step: number;
26
27
  max_width: number;
27
28
  src_include: RegExp;
28
29
  src_exclude: RegExp | null;
@@ -60,5 +61,6 @@ export type Options = {
60
61
  };
61
62
  misc: {
62
63
  prefetch_links: 'in-viewport' | 'off';
64
+ sequential_compress: boolean;
63
65
  };
64
66
  };
package/dist/index.js CHANGED
File without changes
package/dist/optimize.js CHANGED
@@ -564,7 +564,7 @@ async function _generateSrcSet({ options }, startSrc, imageWidth, imageHeight, t
564
564
  return null;
565
565
  }
566
566
  // Start reduction
567
- const step = 300; //px
567
+ const step = options.image.srcset_step; //px
568
568
  let valueW = !startSrc ? imageWidth : imageWidth - step;
569
569
  valueW = Math.min(valueW, options.image.srcset_max_width);
570
570
  while (valueW >= options.image.srcset_min_width) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divriots/jampack",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "cache-version": {
5
5
  "img": "v1",
6
6
  "img-ext": "v1"
@@ -59,18 +59,17 @@
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",
62
68
  "scripts": {
63
69
  "watch": "pnpm build --watch",
64
70
  "try": "shx rm -fr demo && cp -R demo_drc demo && node ./dist/index.js ./demo --nocache",
65
71
  "build": "shx rm -rf dist && tsc -b",
66
72
  "lint": "eslint . --ext .ts --config .eslintrc",
67
- "prepublishOnly": "pnpm build",
68
73
  "cleanAllDotJampack": "find -s . | grep '.jampack$' | xargs rm -fr"
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
- }
74
+ }
75
+ }