compress-shader-literals 1.3.1 → 1.3.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 +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +6 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -107,7 +107,7 @@ Real shaders shipped by popular libraries, run through the built-in minifier:
|
|
|
107
107
|
| `postprocessing` | 136 | 179,705 B | 179,705 B | **0.0%** | — |
|
|
108
108
|
| **Total** | 3323 | 4,976,645 B | 3,929,415 B | **21.0%** | — |
|
|
109
109
|
|
|
110
|
-
_3323 shaders ·
|
|
110
|
+
_3323 shaders · 2477/3323 parseable shaders (GLSL + WGSL) verified valid after minify · [how this is measured](docs/stats.md) · 2026-07-08_
|
|
111
111
|
|
|
112
112
|
<!-- STATS:END -->
|
|
113
113
|
|
package/dist/index.cjs
CHANGED
|
@@ -6,4 +6,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
6
6
|
`:n+=n===``||n.endsWith(`
|
|
7
7
|
`)?e:` `+e,r=e.endsWith(`\\`);return r=!1,n=n.split(`
|
|
8
8
|
`).map(e=>{let t=e.startsWith(`#`)||r?e:e.replace(S,`$1`);return r=e.endsWith(`\\`),t}).join(`
|
|
9
|
-
`),n.trim()},E=(0,d.createUnplugin)((e={})=>{let t=e.tags||m,n=e.transform||T,r=(0,c.createFilter)(e.include||h,e.exclude||g),i=``,a
|
|
9
|
+
`),n.trim()},E=(0,d.createUnplugin)((e={})=>{let t=e.tags||m,n=e.transform||T,r=(0,c.createFilter)(e.include||h,e.exclude||g),i=``,a=``,o=0;return{name:`compress-shader-literals`,enforce:`pre`,transform(s,c){if(!r(c)||!t.some(e=>s.includes(e)))return null;let l=w(s,t);if(l.length===0)return null;e.debug&&console.log(`[compress-shader-literals] ${c}: ${l.length} literal(s) — ${l.map(e=>e.tag).join(`, `)}`);let d=new u.default(s),f=!1;for(let t of l){let r=n(t.value);t.value!==r&&(d.overwrite(t.start,t.end,`\`${r}\``),f=!0),e.outputRatio&&(i+=t.value,a+=r,o++)}return f?{code:d.toString(),map:d.generateMap({hires:!0,source:c})}:null},buildEnd(){if(e.outputRatio&&i){let e=`compress-shader-literals: ${o} shader literal${o===1?``:`s`}`;(0,l.diff)(l.snap.text(i),l.snap.text(a)).print(e)}}}});exports.compressShaderLiterals=E,exports.extractShaderLiterals=w,exports.minifyShader=T;
|
package/dist/index.js
CHANGED
|
@@ -61,7 +61,7 @@ var s = [
|
|
|
61
61
|
return r = e.endsWith("\\"), t;
|
|
62
62
|
}).join("\n"), n.trim();
|
|
63
63
|
}, y = i((i = {}) => {
|
|
64
|
-
let a = i.tags || s, o = i.transform || v, u = e(i.include || c, i.exclude || l), d = "", f = "";
|
|
64
|
+
let a = i.tags || s, o = i.transform || v, u = e(i.include || c, i.exclude || l), d = "", f = "", p = 0;
|
|
65
65
|
return {
|
|
66
66
|
name: "compress-shader-literals",
|
|
67
67
|
enforce: "pre",
|
|
@@ -73,7 +73,7 @@ var s = [
|
|
|
73
73
|
let s = new r(e), c = !1;
|
|
74
74
|
for (let e of n) {
|
|
75
75
|
let t = o(e.value);
|
|
76
|
-
e.value !== t && (s.overwrite(e.start, e.end, `\`${t}\``), c = !0), i.outputRatio && (d += e.value, f += t);
|
|
76
|
+
e.value !== t && (s.overwrite(e.start, e.end, `\`${t}\``), c = !0), i.outputRatio && (d += e.value, f += t, p++);
|
|
77
77
|
}
|
|
78
78
|
return c ? {
|
|
79
79
|
code: s.toString(),
|
|
@@ -84,7 +84,10 @@ var s = [
|
|
|
84
84
|
} : null;
|
|
85
85
|
},
|
|
86
86
|
buildEnd() {
|
|
87
|
-
i.outputRatio && d
|
|
87
|
+
if (i.outputRatio && d) {
|
|
88
|
+
let e = `compress-shader-literals: ${p} shader literal${p === 1 ? "" : "s"}`;
|
|
89
|
+
t(n.text(d), n.text(f)).print(e);
|
|
90
|
+
}
|
|
88
91
|
}
|
|
89
92
|
};
|
|
90
93
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "compress-shader-literals",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "✂️ Strip comments & whitespace from GLSL/WGSL shader literals in your JS/TS at build time — any bundler, no toolchain, no runtime cost.",
|
|
6
6
|
"main": "./dist/index.cjs",
|