@divriots/jampack 0.23.1 → 0.23.3
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-types.d.ts +2 -0
- package/dist/index.js +0 -0
- package/dist/optimize.js +7 -4
- package/dist/optimizers/prefetch-links.js +7 -8
- package/package.json +9 -10
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
File without changes
|
package/dist/config-types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { UrlTransformer } from 'unpic';
|
|
1
2
|
export type WebpOptions = {
|
|
2
3
|
effort: number;
|
|
3
4
|
mode: 'lossless' | 'lossly';
|
|
@@ -32,6 +33,7 @@ export type Options = {
|
|
|
32
33
|
process: 'off' | 'optimize';
|
|
33
34
|
src_include: RegExp;
|
|
34
35
|
src_exclude: RegExp | null;
|
|
36
|
+
transformer?: UrlTransformer;
|
|
35
37
|
};
|
|
36
38
|
compress: boolean;
|
|
37
39
|
jpeg: {
|
package/dist/index.js
CHANGED
|
File without changes
|
package/dist/optimize.js
CHANGED
|
@@ -275,10 +275,13 @@ async function processImage(htmlfile, img, isAboveTheFold) {
|
|
|
275
275
|
case 'off':
|
|
276
276
|
break;
|
|
277
277
|
case 'optimize':
|
|
278
|
-
|
|
279
|
-
if (!
|
|
280
|
-
|
|
281
|
-
|
|
278
|
+
let cdnTransformer = config.image.cdn.transformer;
|
|
279
|
+
if (!cdnTransformer) {
|
|
280
|
+
const canonical = getCanonicalCdnForUrl(attrib_src);
|
|
281
|
+
if (!canonical)
|
|
282
|
+
break;
|
|
283
|
+
cdnTransformer = getTransformer(canonical.cdn);
|
|
284
|
+
}
|
|
282
285
|
if (!cdnTransformer)
|
|
283
286
|
break;
|
|
284
287
|
if (!isIncluded(attrib_src, config.image.cdn.src_include, config.image.cdn.src_exclude))
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import $state from '../state.js';
|
|
2
2
|
import * as fs from 'fs/promises';
|
|
3
3
|
import * as path from 'path';
|
|
4
|
-
import
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
5
6
|
const src_filename = 'quicklink.mjs';
|
|
6
7
|
const folder = `/_jampack/quicklink-2.3.0`;
|
|
7
8
|
const url_loader = `${folder}/loader.js`;
|
|
8
|
-
const url_quicklink = `${folder}/${src_filename}`;
|
|
9
|
-
let payloadStored = false;
|
|
10
9
|
export async function prefetch_links_in_viewport(html_file) {
|
|
11
10
|
const path_html = path.dirname('/' + html_file);
|
|
11
|
+
const quickLinkDestination = path.join($state.dir, folder, src_filename);
|
|
12
|
+
const payloadStored = await fs.access(quickLinkDestination).catch(() => false);
|
|
12
13
|
if (!payloadStored) {
|
|
13
14
|
const path_loader = path.join($state.dir, url_loader);
|
|
14
15
|
await fs.mkdir(path.join($state.dir, folder), { recursive: true });
|
|
15
16
|
// Write loader
|
|
16
|
-
const code_loader = `import { listen } from "
|
|
17
|
+
const code_loader = `import { listen } from "./${src_filename}";
|
|
17
18
|
listen();`;
|
|
18
19
|
await fs.writeFile(path_loader, code_loader);
|
|
19
20
|
// Write quicklink code
|
|
20
|
-
const source =
|
|
21
|
-
await fs.copyFile(source,
|
|
22
|
-
// We don't need to store them anymore
|
|
23
|
-
payloadStored = true;
|
|
21
|
+
const source = require.resolve(`quicklink/dist/${src_filename}`);
|
|
22
|
+
await fs.copyFile(source, quickLinkDestination);
|
|
24
23
|
}
|
|
25
24
|
return `<script type="module" src="${path.relative(path_html, url_loader)}"></script>`;
|
|
26
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@divriots/jampack",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.3",
|
|
4
4
|
"cache-version": {
|
|
5
5
|
"img": "v1",
|
|
6
6
|
"img-ext": "v1"
|
|
@@ -58,18 +58,17 @@
|
|
|
58
58
|
"tslib": "^2.6.2",
|
|
59
59
|
"typescript": "^5.3.3"
|
|
60
60
|
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=14.0.0"
|
|
63
|
+
},
|
|
64
|
+
"bugs": "https://github.com/divriots/jampack/issues",
|
|
65
|
+
"keywords": [],
|
|
66
|
+
"types": "dist/index.d.ts",
|
|
61
67
|
"scripts": {
|
|
62
68
|
"watch": "pnpm build --watch",
|
|
63
69
|
"try": "shx rm -fr demo && cp -R demo_drc demo && node ./dist/index.js ./demo --nocache",
|
|
64
70
|
"build": "shx rm -rf dist && tsc -b",
|
|
65
71
|
"lint": "eslint . --ext .ts --config .eslintrc",
|
|
66
|
-
"prepublishOnly": "pnpm build",
|
|
67
72
|
"cleanAllDotJampack": "find -s . | grep '.jampack$' | xargs rm -fr"
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
"node": ">=14.0.0"
|
|
71
|
-
},
|
|
72
|
-
"bugs": "https://github.com/divriots/jampack/issues",
|
|
73
|
-
"keywords": [],
|
|
74
|
-
"types": "dist/index.d.ts"
|
|
75
|
-
}
|
|
73
|
+
}
|
|
74
|
+
}
|