vite-plugin-singlefile-compression 2.1.1 → 2.1.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 +9 -9
- package/dist/index.js +5 -4
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -4,7 +4,9 @@ Compress all assets and embeds them into `dist/index.html`, making it convenient
|
|
|
4
4
|
|
|
5
5
|
The recipient can open it directly in the browser without manually unzipping the file.
|
|
6
6
|
|
|
7
|
-
Using [DecompressionStream](https://developer.mozilla.org/docs/Web/API/DecompressionStream) + [base128-ascii](https://www.npmjs.com/package/base128-ascii).
|
|
7
|
+
Using [DecompressionStream](https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream) + [base128-ascii](https://www.npmjs.com/package/base128-ascii).
|
|
8
|
+
|
|
9
|
+
Preview: https://bddjr.github.io/vite-plugin-singlefile-compression/
|
|
8
10
|
|
|
9
11
|
## Setup
|
|
10
12
|
|
|
@@ -43,7 +45,7 @@ singleFileCompression({
|
|
|
43
45
|
}),
|
|
44
46
|
```
|
|
45
47
|
|
|
46
|
-
More
|
|
48
|
+
More options see [src/options.ts](src/options.ts)
|
|
47
49
|
|
|
48
50
|
```ts
|
|
49
51
|
export interface Options {
|
|
@@ -125,25 +127,23 @@ export interface Options {
|
|
|
125
127
|
Preview: https://bddjr.github.io/vite-plugin-singlefile-compression/
|
|
126
128
|
|
|
127
129
|
```
|
|
128
|
-
vite v8.0.
|
|
130
|
+
vite v8.0.1 building client environment for production...
|
|
129
131
|
✓ 42 modules transformed.
|
|
130
132
|
rendering chunks (1)...
|
|
131
133
|
|
|
132
|
-
vite-plugin-singlefile-compression 2.1.
|
|
134
|
+
vite-plugin-singlefile-compression 2.1.2 deflate-raw base128-ascii
|
|
133
135
|
|
|
134
136
|
file:///D:/code/js/vite-plugin-singlefile-compression/test/dist/index.html
|
|
135
|
-
|
|
137
|
+
123.867 kB -> 50.297 kB
|
|
136
138
|
|
|
137
139
|
Finish.
|
|
138
140
|
|
|
139
141
|
computing gzip size...
|
|
140
|
-
dist/index.html 50.
|
|
142
|
+
dist/index.html 50.29 kB │ gzip: 43.81 kB
|
|
141
143
|
|
|
142
|
-
✓ built in
|
|
144
|
+
✓ built in 318ms
|
|
143
145
|
```
|
|
144
146
|
|
|
145
|
-

|
|
146
|
-
|
|
147
147
|
## Clone
|
|
148
148
|
|
|
149
149
|
```
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import zlib from "zlib";
|
|
|
9
9
|
import svgToTinyDataUri from "mini-svg-data-uri";
|
|
10
10
|
import mime from "mime";
|
|
11
11
|
//#region _dist/getVersion.js
|
|
12
|
-
var version = "2.1.
|
|
12
|
+
var version = "2.1.2";
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region _dist/compress.js
|
|
15
15
|
const compressors = {
|
|
@@ -60,7 +60,7 @@ function compress(format, buf, useBase128, compressor) {
|
|
|
60
60
|
//#region _dist/templateRaw.js
|
|
61
61
|
var raw = {
|
|
62
62
|
"assets": "{let e={\"\":\"\"};for(let o in e)for(let s of document.querySelectorAll(`[src=\"data:${o}\"]`))s.src=e[o]}",
|
|
63
|
-
"base128": "var a=\"<script>\",
|
|
63
|
+
"base128": "var a=\"<script>\",c=a.length,r=new Uint8Array(c/8*7),p=0,n=0,e,t=o=>(e=a.charCodeAt(p++))>127?e=0:e,i=Response;for(;p<c;)r[n++]=t()<<1|t()>>6,r[n++]=e<<2|t()>>5,r[n++]=e<<3|t()>>4,r[n++]=e<<4|t()>>3,r[n++]=e<<5|t()>>2,r[n++]=e<<6|t()>>1,r[n++]=e<<7|t();new i(new i(r).body.pipeThrough(new DecompressionStream(\"<format>\")),{headers:{\"Content-Type\":\"text/javascript\"}}).blob().then(o=>(import(o=URL.createObjectURL(o)),URL.revokeObjectURL(o)))",
|
|
64
64
|
"base64": "fetch(\"data:;base64,<script>\").then(e=>new Response(e.body.pipeThrough(new DecompressionStream(\"<format>\")),{headers:{\"Content-Type\":\"text/javascript\"}}).blob()).then(e=>(import(e=URL.createObjectURL(e)),URL.revokeObjectURL(e)))",
|
|
65
65
|
"css": "document.head.appendChild(document.createElement(\"style\")).innerHTML=\"<style>\"",
|
|
66
66
|
"icon": "document.querySelector(\"link[rel=icon]\").href=\"<icon>\"",
|
|
@@ -108,7 +108,8 @@ function bufferToDataURL(name, b) {
|
|
|
108
108
|
//#endregion
|
|
109
109
|
//#region _dist/kB.js
|
|
110
110
|
function kB(size) {
|
|
111
|
-
|
|
111
|
+
const s = String(size).padStart(4, "0");
|
|
112
|
+
return `${s.slice(0, -3)}.${s.slice(-3)} kB`;
|
|
112
113
|
}
|
|
113
114
|
//#endregion
|
|
114
115
|
//#region _dist/options.js
|
|
@@ -175,7 +176,7 @@ function setConfig(opt, config, env) {
|
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
async function generateBundle(bundle, config, options) {
|
|
178
|
-
console.log(pc.reset("\n\n") + pc.cyan("vite-plugin-singlefile-compression " + version) + " " + (options.enableCompress ? pc.green(options.compressFormat + " " + (options.useBase128 ? "base128-ascii" : "base64")) : pc.red("disable
|
|
179
|
+
console.log(pc.reset("\n\n") + pc.cyan("vite-plugin-singlefile-compression " + version) + " " + (options.enableCompress ? pc.green(options.compressFormat + " " + (options.useBase128 ? "base128-ascii" : "base64")) : pc.red("disable-compress")));
|
|
179
180
|
if (options.rename && options.rename != "index.html" && Object.prototype.hasOwnProperty.call(bundle, "index.html") && !Object.prototype.hasOwnProperty.call(bundle, options.rename)) {
|
|
180
181
|
bundle[options.rename] = bundle["index.html"];
|
|
181
182
|
bundle[options.rename].fileName = options.rename;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-singlefile-compression",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"author": "bddjr",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Compress all assets and embeds them into dist/index.html, making it convenient to share as a single HTML file.",
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"jsdom": ">=28.1.0",
|
|
54
54
|
"mime": ">=4.1.0",
|
|
55
55
|
"mini-svg-data-uri": ">=1.4.4",
|
|
56
|
-
"picocolors": ">=1.1.1"
|
|
56
|
+
"picocolors": ">=1.1.1",
|
|
57
|
+
"vite": ">=3.0.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@types/jsdom": ">=28.0.0",
|
|
@@ -64,7 +65,6 @@
|
|
|
64
65
|
"rolldown": ">=1.0.0-rc.9",
|
|
65
66
|
"rolldown-plugin-dts": "^0.22.5",
|
|
66
67
|
"rollup": ">=4.59.0",
|
|
67
|
-
"typescript": ">=5.9.3"
|
|
68
|
-
"vite": ">=8.0.0"
|
|
68
|
+
"typescript": ">=5.9.3"
|
|
69
69
|
}
|
|
70
|
-
}
|
|
70
|
+
}
|