@divriots/jampack 0.33.1 → 0.34.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
@@ -3,7 +3,6 @@ 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: 'off',
7
6
  sort_attributes: false,
8
7
  },
9
8
  css: {
@@ -9,7 +9,6 @@ export type Options = {
9
9
  browserslist: string;
10
10
  };
11
11
  html: {
12
- add_css_reset_as: 'inline' | 'off';
13
12
  sort_attributes: boolean;
14
13
  };
15
14
  js: {
package/dist/index.js CHANGED
File without changes
package/dist/optimize.js CHANGED
@@ -53,9 +53,8 @@ async function analyse(state, file) {
53
53
  const charsetElements$ = heads.find('meta[charset]');
54
54
  const wasCharsetFirst = !charsetElements$.prev().length;
55
55
  const { options } = state;
56
- if (options.html.add_css_reset_as === 'inline') {
57
- prependToHead += `<style>:where(img){height:auto;}</style>`;
58
- }
56
+ // Add a CSS reset for images that have been sized by jampack
57
+ prependToHead += `<style>@layer __jampack__ { :where(img[jampack-sized]){max-width:100%;height:auto;} }</style>`;
59
58
  if (prependToHead || appendToHead) {
60
59
  if (prependToHead)
61
60
  heads.prepend(prependToHead);
@@ -795,6 +794,7 @@ async function setImageSize(state, htmlfile, img, image) {
795
794
  const result_h = Math.round(height_new);
796
795
  img.attr('width', result_w.toFixed(0));
797
796
  img.attr('height', result_h.toFixed(0));
797
+ img.attr('jampack-sized', 'true');
798
798
  return [result_w, result_h];
799
799
  }
800
800
  // Something when wrong
@@ -108,7 +108,8 @@ export class Resource {
108
108
  if (!u.pathname) {
109
109
  throw new Error(`Invalid src format "${src}"`);
110
110
  }
111
- const relativePath = path.join(state.dir, src.startsWith('/') ? '' : path.dirname(relativeFile), u.pathname);
111
+ const pathname = decodeURIComponent(u.pathname);
112
+ const relativePath = path.join(state.dir, src.startsWith('/') ? '' : path.dirname(relativeFile), pathname);
112
113
  let absolutePath = path.resolve(relativePath);
113
114
  if (await fileExists(state, absolutePath)) {
114
115
  return new Resource(state, src, absolutePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divriots/jampack",
3
- "version": "0.33.1",
3
+ "version": "0.34.1",
4
4
  "cache-version": {
5
5
  "img": "v1",
6
6
  "img-ext": "v1"
@@ -60,17 +60,18 @@
60
60
  "tslib": "^2.6.2",
61
61
  "typescript": "^5.4.5"
62
62
  },
63
- "engines": {
64
- "node": ">=14.0.0"
65
- },
66
- "bugs": "https://github.com/divriots/jampack/issues",
67
- "keywords": [],
68
- "types": "dist/index.d.ts",
69
63
  "scripts": {
70
64
  "watch": "pnpm build --watch",
71
65
  "try": "shx rm -fr demo && cp -R demo_drc demo && node ./dist/index.js ./demo --nocache",
72
66
  "build": "shx rm -rf dist && tsc -b",
73
67
  "lint": "eslint . --ext .ts --config .eslintrc",
68
+ "prepublishOnly": "pnpm build",
74
69
  "cleanAllDotJampack": "find -s . | grep '.jampack$' | xargs rm -fr"
75
- }
76
- }
70
+ },
71
+ "engines": {
72
+ "node": ">=14.0.0"
73
+ },
74
+ "bugs": "https://github.com/divriots/jampack/issues",
75
+ "keywords": [],
76
+ "types": "dist/index.d.ts"
77
+ }