add minifyextras

This commit is contained in:
ZXMushroom63 2025-03-12 18:05:39 +08:00
parent ccdac07c05
commit 711263afec
3 changed files with 21 additions and 21 deletions

View File

@ -90,8 +90,12 @@
>Choose .html file...</label
>
<br />
<span><label>Minify:&nbsp;</label><input type="checkbox" oninput="globalThis.doShronk = this.checked">
&nbsp;&nbsp;&nbsp;<label>EaglerForge:&nbsp;</label><input checked type="checkbox" oninput="globalThis.doEaglerforge = this.checked">
<span>
<label>Minify:&nbsp;</label><input type="checkbox" oninput="globalThis.doShronk = this.checked">
&nbsp;&nbsp;&nbsp;
<label>MinifyExtras:&nbsp;</label><input type="checkbox" oninput="globalThis.doShronkPlus = this.checked">
&nbsp;&nbsp;&nbsp;
<label>EaglerForge:&nbsp;</label><input checked type="checkbox" oninput="globalThis.doEaglerforge = this.checked">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code id="status">Awaiting input...</code></span>
<br /><br />
<button class="btn btn-primary" id="giveme">Make modded client</button>

View File

@ -322,7 +322,7 @@ var main;(function(){`
\<script id="__eaglerforgeinjector_installation_flag__"\>console.log("Thank you for using EaglerForge!");\<\/script\>`
);
backgroundLog("[HTML] Injecting script files");
patchedFile = patchedFile.replace(`<title>EaglercraftX`, `<title>EFI ${globalThis.ModAPIVersion}`);
patchedFile = patchedFile.replace(`<title>EaglercraftX`, `<title>EFI ${globalThis.ModAPIVersion} on`);
backgroundLog("[HTML] Injecting title");
patchedFile = patchedFile.replaceAll(/main\(\);\s*?}/gm, (match) => {
return match.replace("main();", "main();ModAPI.hooks._postInit();");

View File

@ -1,23 +1,17 @@
// Babel plugin to transform functions and calls
const ASYNC_PLUGIN_1 = function ({ types: t }) {
const MINIFY = function () {
return {
visitor: {
FunctionDeclaration(path) {
console.log(path);
path.node.async = true;
},
ArrowFunctionExpression(path) {
console.log(path);
path.node.async = true;
},
CallExpression(path) {
console.log(path);
if (path.parent.type !== 'AwaitExpression') {
path.replaceWith(
t.awaitExpression(path.node)
);
Identifier(path) {
if (path.node.name === "$ptr") {
path.node.name = "r";
}
}
if (path.node.name === "$tmp") {
path.node.name = "m";
}
if (path.node.name === "$thread") {
path.node.name = "t";
}
},
}
};
};
@ -45,7 +39,9 @@ async function shronk(input) {
const output = Babel.transform(code, {
plugins: []
plugins: globalThis.doShronkPlus ? [
MINIFY()
] : []
});
scriptTag.textContent = output.code;
await wait(10);