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 >Choose .html file...</label
> >
<br /> <br />
<span><label>Minify:&nbsp;</label><input type="checkbox" oninput="globalThis.doShronk = this.checked"> <span>
&nbsp;&nbsp;&nbsp;<label>EaglerForge:&nbsp;</label><input checked type="checkbox" oninput="globalThis.doEaglerforge = this.checked"> <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> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code id="status">Awaiting input...</code></span>
<br /><br /> <br /><br />
<button class="btn btn-primary" id="giveme">Make modded client</button> <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\>` \<script id="__eaglerforgeinjector_installation_flag__"\>console.log("Thank you for using EaglerForge!");\<\/script\>`
); );
backgroundLog("[HTML] Injecting script files"); 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"); backgroundLog("[HTML] Injecting title");
patchedFile = patchedFile.replaceAll(/main\(\);\s*?}/gm, (match) => { patchedFile = patchedFile.replaceAll(/main\(\);\s*?}/gm, (match) => {
return match.replace("main();", "main();ModAPI.hooks._postInit();"); return match.replace("main();", "main();ModAPI.hooks._postInit();");

View File

@ -1,23 +1,17 @@
// Babel plugin to transform functions and calls const MINIFY = function () {
const ASYNC_PLUGIN_1 = function ({ types: t }) {
return { return {
visitor: { visitor: {
FunctionDeclaration(path) { Identifier(path) {
console.log(path); if (path.node.name === "$ptr") {
path.node.async = true; path.node.name = "r";
},
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)
);
} }
} 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, { const output = Babel.transform(code, {
plugins: [] plugins: globalThis.doShronkPlus ? [
MINIFY()
] : []
}); });
scriptTag.textContent = output.code; scriptTag.textContent = output.code;
await wait(10); await wait(10);