vite-plugin-singlefile-compression 2.2.4 → 2.3.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/README.md CHANGED
@@ -142,7 +142,7 @@ type: `boolean`
142
142
 
143
143
  Use import.meta polyfill.
144
144
 
145
- default: `true`
145
+ default: `false`
146
146
 
147
147
  type: `boolean`
148
148
 
@@ -156,17 +156,17 @@ vite v8.0.8 building client environment for production...
156
156
  ✓ 42 modules transformed.
157
157
  rendering chunks (1)...
158
158
 
159
- vite-plugin-singlefile-compression 2.2.4 deflate-raw base128-ascii
159
+ vite-plugin-singlefile-compression 2.3.1 deflate-raw base128-ascii
160
160
 
161
161
  file:///D:/code/js/vite-plugin-singlefile-compression/test/dist/index.html
162
- 122.750 kB -> 50.221 kB
162
+ 122.767 kB -> 50.111 kB
163
163
 
164
164
  Finish.
165
165
 
166
166
  computing gzip size...
167
- dist/index.html 50.22 kB │ gzip: 43.79 kB
167
+ dist/index.html 50.11 kB │ gzip: 43.67 kB
168
168
 
169
- ✓ built in 282ms
169
+ ✓ built in 269ms
170
170
  ```
171
171
 
172
172
  ## Clone
package/dist/index.d.ts CHANGED
@@ -81,7 +81,7 @@ interface Options {
81
81
  removeInlinedPublicIconFiles?: boolean;
82
82
  /**
83
83
  * Use import.meta polyfill.
84
- * @default true
84
+ * @default false
85
85
  */
86
86
  useImportMetaPolyfill?: boolean;
87
87
  }
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 { lookup } from "mrmime";
11
11
  //#region package.json
12
- var version = "2.2.4";
12
+ var version = "2.3.1";
13
13
  //#endregion
14
14
  //#region src/compress.ts
15
15
  const compressors = {
@@ -68,14 +68,14 @@ async function compress(format, buf, useBase128, compressor) {
68
68
  const files = {
69
69
  "assets": ["{let e=", ";for(let l in e)for(let r of document.querySelectorAll(`[src=\"data:${l}\"]`))r.src=e[l]}"],
70
70
  "base128": [
71
- "for(var e,t=",
72
- ",r=t.length,n=new Uint8Array(r/8*7),o=0,a=0,_=r=>(e=t.charCodeAt(o++))>127?e=0:e,p=Response;o<r;)n[a++]=_()<<1|_()>>6,n[a++]=e<<2|_()>>5,n[a++]=e<<3|_()>>4,n[a++]=e<<4|_()>>3,n[a++]=e<<5|_()>>2,n[a++]=e<<6|_()>>1,n[a++]=e<<7|_();new p(new p(n).body.pipeThrough(new DecompressionStream(",
73
- ")),{headers:{\"Content-Type\":\"text/javascript\"}}).blob().then(e=>(import(e=URL.createObjectURL(e)),URL.revokeObjectURL(e)))"
71
+ "for(var e,n=",
72
+ ",t=n.length,r=new Uint8Array(t/8*7),o=0,d=0,p=t=>(e=n.charCodeAt(o++))>127?e=0:e,_=Response,a=document.createElement(\"script\");o<t;)r[d++]=p()<<1|p()>>6,r[d++]=e<<2|p()>>5,r[d++]=e<<3|p()>>4,r[d++]=e<<4|p()>>3,r[d++]=e<<5|p()>>2,r[d++]=e<<6|p()>>1,r[d++]=e<<7|p();new _(new _(r).body.pipeThrough(new DecompressionStream(",
73
+ "))).text().then(e=>{a.type=\"module\",a.innerHTML=e,document.head.appendChild(a)})"
74
74
  ],
75
75
  "base64": [
76
76
  "fetch(\"data:;base64,",
77
77
  "\").then(e=>new Response(e.body.pipeThrough(new DecompressionStream(",
78
- ")),{headers:{\"Content-Type\":\"text/javascript\"}}).blob()).then(e=>(import(e=URL.createObjectURL(e)),URL.revokeObjectURL(e)))"
78
+ "))).text()).then(e=>{var t=document.createElement(\"script\");t.type=\"module\",t.innerHTML=e,document.head.appendChild(t)})"
79
79
  ],
80
80
  "css": "document.head.appendChild(document.createElement(\"style\")).innerHTML=",
81
81
  "icon": "document.querySelector(\"link[rel=icon]\").href=",
@@ -138,7 +138,7 @@ function getInnerOptions(opt) {
138
138
  removeInlinedAssetFiles: opt.removeInlinedAssetFiles ?? true,
139
139
  tryInlineHtmlPublicIcon: opt.tryInlineHtmlPublicIcon ?? true,
140
140
  removeInlinedPublicIconFiles: opt.removeInlinedPublicIconFiles ?? true,
141
- useImportMetaPolyfill: opt.useImportMetaPolyfill ?? true
141
+ useImportMetaPolyfill: opt.useImportMetaPolyfill ?? false
142
142
  };
143
143
  }
144
144
  //#endregion
@@ -307,9 +307,8 @@ async function generateBundle(bundle, config, options) {
307
307
  else newJSCode.push("var __VITE_PRELOAD__");
308
308
  newJSCode.push(code);
309
309
  } else inlineHtmlAssets();
310
- let outputScript = newJSCode.join(";");
310
+ let outputScript = newJSCode.join(";").replaceAll("<\/script", "<\\/script");
311
311
  if (options.enableCompress) outputScript = await template.base(outputScript, options.compressFormat, options.useBase128, options.compressor);
312
- else outputScript = outputScript.replaceAll("<\/script", "<\\/script");
313
312
  htmlChunk.source = htmlChunk.source.replace(fakeScript, () => outputScript);
314
313
  console.log(" " + pc.gray(kB(oldSize) + " -> ") + pc.cyanBright(kB(Buffer.byteLength(htmlChunk.source))) + "\n");
315
314
  for (const name of thisDel) globalDelete.add(name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-singlefile-compression",
3
- "version": "2.2.4",
3
+ "version": "2.3.1",
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.",
@@ -89,7 +89,7 @@
89
89
  },
90
90
  "dependencies": {
91
91
  "@types/html-minifier-terser": ">=7.0.2",
92
- "base128-ascii": "^2.1.12",
92
+ "base128-ascii": ">=3.0.0",
93
93
  "html-minifier-terser": ">=7.2.0",
94
94
  "jsdom": ">=29.0.2",
95
95
  "mini-svg-data-uri": ">=1.4.4",
@@ -98,11 +98,11 @@
98
98
  },
99
99
  "devDependencies": {
100
100
  "@types/jsdom": ">=28.0.1",
101
- "@types/node": "^22.19.17",
101
+ "@types/node": "^24.12.2",
102
102
  "rolldown": ">=1.0.0-rc.15",
103
- "rolldown-plugin-dts": ">=0.22.5",
103
+ "rolldown-plugin-dts": ">=0.23.2",
104
104
  "terser": ">=5.46.1",
105
105
  "typescript": ">=6.0.2",
106
106
  "vite": ">=8.0.8"
107
107
  }
108
- }
108
+ }