vite-plugin-singlefile-compression 1.2.0 → 1.2.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/dist/index.js +11 -20
- package/dist/template-base128.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -21,21 +21,11 @@ export function singleFileCompression(opt) {
|
|
|
21
21
|
htmlMinifierTerser: opt.htmlMinifierTerser == null || opt.htmlMinifierTerser === true
|
|
22
22
|
? defaultHtmlMinifierTerserOptions
|
|
23
23
|
: opt.htmlMinifierTerser,
|
|
24
|
-
tryInlineHtmlAssets: opt.tryInlineHtmlAssets
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
: opt.removeInlinedAssetFiles,
|
|
30
|
-
tryInlineHtmlPublicIcon: opt.tryInlineHtmlPublicIcon == null
|
|
31
|
-
? true
|
|
32
|
-
: opt.tryInlineHtmlPublicIcon,
|
|
33
|
-
removeInlinedPublicIconFiles: opt.removeInlinedPublicIconFiles == null
|
|
34
|
-
? true
|
|
35
|
-
: opt.removeInlinedPublicIconFiles,
|
|
36
|
-
useBase128: opt.useBase128 == null
|
|
37
|
-
? true
|
|
38
|
-
: opt.useBase128,
|
|
24
|
+
tryInlineHtmlAssets: opt.tryInlineHtmlAssets ?? true,
|
|
25
|
+
removeInlinedAssetFiles: opt.removeInlinedAssetFiles ?? true,
|
|
26
|
+
tryInlineHtmlPublicIcon: opt.tryInlineHtmlPublicIcon ?? true,
|
|
27
|
+
removeInlinedPublicIconFiles: opt.removeInlinedPublicIconFiles ?? true,
|
|
28
|
+
useBase128: opt.useBase128 ?? true,
|
|
39
29
|
};
|
|
40
30
|
let conf;
|
|
41
31
|
return {
|
|
@@ -56,15 +46,16 @@ function bufferToDataURL(name, b) {
|
|
|
56
46
|
? svgToTinyDataUri(b.toString())
|
|
57
47
|
: `data:${mime.getType(name)};base64,${b.toString('base64')}`;
|
|
58
48
|
}
|
|
59
|
-
function
|
|
49
|
+
function gzip(buf) {
|
|
60
50
|
return zlib.gzipSync(buf, {
|
|
61
51
|
level: zlib.constants.Z_BEST_COMPRESSION,
|
|
62
|
-
})
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function gzipToBase64(buf) {
|
|
55
|
+
return gzip(buf).toString('base64');
|
|
63
56
|
}
|
|
64
57
|
function gzipToBase128(buf) {
|
|
65
|
-
return base128.
|
|
66
|
-
level: zlib.constants.Z_BEST_COMPRESSION,
|
|
67
|
-
})));
|
|
58
|
+
return base128.encode(Uint8Array.from(gzip(buf))).toJSTemplateLiterals();
|
|
68
59
|
}
|
|
69
60
|
function KiB(size) {
|
|
70
61
|
return `${Math.ceil(size / 10.24) / 100} KiB`;
|
package/dist/template-base128.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function l(
|
|
1
|
+
function l(i){let n=new TextEncoder().encode(i),t=new Uint8Array(Math.ceil((n.length-1)/8)*7);for(let r=1,o=0;r<n.length;){let e=BigInt(n[r++]||0)<<49n;e|=BigInt(n[r++]||0)<<42n,e|=BigInt(n[r++]||0)<<35n,e|=BigInt(n[r++]||0)<<28n,e|=BigInt(n[r++]||0)<<21n,e|=BigInt(n[r++]||0)<<14n,e|=BigInt(n[r++]||0)<<7n,e|=BigInt(n[r++]||0),t[o++]=Number(e>>48n),t[o++]=Number(e>>40n&255n),t[o++]=Number(e>>32n&255n),t[o++]=Number(e>>24n&255n),t[o++]=Number(e>>16n&255n),t[o++]=Number(e>>8n&255n),t[o++]=Number(e&255n)}let u=n[0]-48;return u?t.slice(0,u-7):t}new Response(new ReadableStream({start(i){i.enqueue(l("<script>")),i.close()}}).pipeThrough(new DecompressionStream("gzip")),{headers:{"Content-Type":"text/javascript"}}).blob().then(i=>import(i=URL.createObjectURL(i)).finally(()=>URL.revokeObjectURL(i)))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-singlefile-compression",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@types/html-minifier-terser": "^7.0.2",
|
|
44
44
|
"@types/node": "^22.9.3",
|
|
45
|
-
"base128-ascii": "^0.0
|
|
45
|
+
"base128-ascii": "^1.0.0",
|
|
46
46
|
"esbuild": "^0.24.0",
|
|
47
47
|
"html-minifier-terser": "^7.2.0",
|
|
48
48
|
"mime": "^4.0.4",
|