vite-plugin-singlefile-compression 1.2.0 → 1.2.2
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/README.md +4 -4
- package/dist/index.js +11 -20
- package/dist/template-base128.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -101,15 +101,15 @@ vite v6.0.6 building for production...
|
|
|
101
101
|
✓ 45 modules transformed.
|
|
102
102
|
rendering chunks (1)...
|
|
103
103
|
|
|
104
|
-
vite-plugin-singlefile-compression 1.2.
|
|
104
|
+
vite-plugin-singlefile-compression 1.2.2 building...
|
|
105
105
|
|
|
106
106
|
file:///D:/bddjr/Desktop/code/js/vite-plugin-singlefile-compression/test/dist/index.html
|
|
107
|
-
101.02 KiB -> 46.
|
|
107
|
+
101.02 KiB -> 46.54 KiB
|
|
108
108
|
|
|
109
109
|
Finish.
|
|
110
110
|
|
|
111
|
-
dist/index.html 47.
|
|
112
|
-
✓ built in
|
|
111
|
+
dist/index.html 47.65 kB
|
|
112
|
+
✓ built in 694ms
|
|
113
113
|
```
|
|
114
114
|
|
|
115
115
|
## Clone
|
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
|
|
1
|
+
function c(e){let l=0,o=0,n,r=new Uint8Array(Math.floor(e.length/8*7));function t(){return n=e.charCodeAt(l++)||0}for(;l<e.length;)r[o++]=t()<<1|t()>>6,r[o++]=n<<2|t()>>5,r[o++]=n<<3|t()>>4,r[o++]=n<<4|t()>>3,r[o++]=n<<5|t()>>2,r[o++]=n<<6|t()>>1,r[o++]=n<<7|t();return r}new Response(new ReadableStream({start(e){e.enqueue(c("<script>")),e.close()}}).pipeThrough(new DecompressionStream("gzip")),{headers:{"Content-Type":"text/javascript"}}).blob().then(e=>import(e=URL.createObjectURL(e)).finally(()=>URL.revokeObjectURL(e)))
|
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.2",
|
|
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": "^2.0.0",
|
|
46
46
|
"esbuild": "^0.24.0",
|
|
47
47
|
"html-minifier-terser": "^7.2.0",
|
|
48
48
|
"mime": "^4.0.4",
|