@divriots/jampack 0.33.0 → 0.34.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 +0 -0
- package/README.md +0 -0
- package/dist/config-default.js +0 -1
- package/dist/config-types.d.ts +0 -1
- package/dist/index.js +0 -0
- package/dist/optimize.js +3 -3
- package/dist/optimizers/process-iframe.js +2 -3
- package/dist/utils/resource.js +2 -1
- package/package.json +9 -8
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/dist/config-default.js
CHANGED
package/dist/config-types.d.ts
CHANGED
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
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
56
|
+
// Add a CSS reset for images that have been sized by jampack
|
|
57
|
+
prependToHead += `<style>: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
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { install_lozad } from '../utils/install-dep.js';
|
|
2
2
|
export async function processIframe(state, htmlfile, iframe, isAboveTheFold, appendToBody) {
|
|
3
|
-
// Reset loading attribute
|
|
4
|
-
iframe.removeAttr('loading');
|
|
5
3
|
const lazyloadOptions = state.options.iframe.lazyload;
|
|
6
|
-
if (lazyloadOptions.when === 'never') {
|
|
4
|
+
if (lazyloadOptions.when === 'never' || iframe.attr('loading') === 'eager') {
|
|
5
|
+
// If lazy loading is set to 'never' or 'eager', do not modify the iframe
|
|
7
6
|
return;
|
|
8
7
|
}
|
|
9
8
|
if (lazyloadOptions.when === 'always' ||
|
package/dist/utils/resource.js
CHANGED
|
@@ -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
|
|
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.
|
|
3
|
+
"version": "0.34.0",
|
|
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
|
-
}
|
|
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"
|
|
76
77
|
}
|