ms-vite-plugin 1.4.79 → 1.4.81

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/dist/build.js CHANGED
@@ -1 +1 @@
1
- "use strict";var x=Object.create;var M=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var C=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of N(e))!z.call(t,r)&&r!==o&&M(t,r,{get:()=>e[r],enumerable:!(s=$(e,r))||s.enumerable});return t};var W=(t,e,o)=>(o=t!=null?x(q(t)):{},C(e||!t||!t.__esModule?M(o,"default",{value:t,enumerable:!0}):o,t));var K=exports&&exports.__createBinding||(Object.create?(function(t,e,o,s){s===void 0&&(s=o);var r=Object.getOwnPropertyDescriptor(e,o);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,s,r)}):(function(t,e,o,s){s===void 0&&(s=o),t[s]=e[o]})),A=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),O=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(o){var s=[];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(s[s.length]=r);return s},t(e)};return function(e){if(e&&e.__esModule)return e;var o={};if(e!=null)for(var s=t(e),r=0;r<s.length;r++)s[r]!=="default"&&K(o,e,s[r]);return A(o,e),o}})(),D=exports&&exports.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildAll=void 0;const T=D(require("archiver")),E=require("child_process"),i=O(require("fs-extra")),F=O(require("os")),n=O(require("path")),B=require("./stopGuardPlugin"),G=require("./luaBundle"),L=require("./scriptProtect"),H=D(require("vite-plugin-bundle-obfuscator"));async function R(t,e){const o=(0,T.default)("zip",{zlib:{level:9}}),s=i.createWriteStream(e);return new Promise((r,c)=>{o.directory(t,!1).on("error",a=>c(a)).pipe(s),s.on("close",()=>r()),o.finalize()})}async function I(t,e){const o=[];async function s(r){const c=await i.readdir(r,{withFileTypes:!0});for(const a of c){const f=n.resolve(r,a.name);a.isDirectory()?await s(f):a.isFile()&&(/^main\.(js|ts)$/.test(a.name)||/_thread\.(js|ts)$/.test(a.name))&&o.push(n.relative(e,f))}}return await s(t),o}function Q(){const t=[{cmd:n.join(F.homedir(),".KuaiJSDevloper","python","python.exe"),args:["--version"]},{cmd:n.join(F.homedir(),".KuaiJSDevloper","python","bin","python"),args:["--version"]},{cmd:"python",args:["--version"]},{cmd:"python3",args:["--version"]},{cmd:"python3.14",args:["--version"]}];for(const e of t)try{const o=(0,E.spawnSync)(e.cmd,e.args,{encoding:"utf8"}),s=(o.stdout||o.stderr||"").trim();if(s&&/Python\s+3\.14(\.\d+)?/i.test(s))return{ok:!0,path:e.cmd,version:s}}catch{}return{ok:!1}}async function U(t){async function e(o){const s=await i.readdir(o,{withFileTypes:!0});for(const r of s){const c=n.join(o,r.name);if(r.isDirectory())if(r.name==="__pycache__"){const a=await i.readdir(c,{withFileTypes:!0});for(const f of a){const P=n.join(c,f.name);if(f.isFile()&&f.name.endsWith(".cpython-314.pyc")){const S=n.dirname(c),b=f.name.replace(/\.cpython-314\.pyc$/,".pyc"),j=n.join(S,b);await i.move(P,j,{overwrite:!0})}}try{await i.remove(c)}catch{}}else await e(c);else if(r.isFile())if(r.name.endsWith(".cpython-314.pyc")){const a=c.replace(".cpython-314.pyc",".pyc");await i.move(c,a,{overwrite:!0})}else r.name.endsWith(".py")&&await i.remove(c)}}await e(t)}const V=["Minify","Weak","Medium","Strong"];async function X(t){const e=n.join(t,"obfuscator.json");if(!await i.pathExists(e))return{enabled:!0,preset:"Medium",bundle:!0};try{const o=await i.readJSON(e),s=o?.enabled!==!1,r=o?.bundle!==!1,c=Y(o?.preset);return{enabled:s,preset:c,bundle:r}}catch(o){return console.error("\u274C \u65E0\u6CD5\u8BFB\u53D6 obfuscator.json"),console.error(o instanceof Error?o.message:String(o)),process.exit(1),{enabled:!0,preset:"Medium",bundle:!0}}}function Y(t){if(typeof t!="string")return"Medium";const e=V.find(o=>o.toLowerCase()===t.trim().toLowerCase());return e||(console.warn(`\u26A0\uFE0F obfuscator.json \u7684 preset \u65E0\u6548: ${t}\uFF0C\u5DF2\u6539\u7528 Medium`),"Medium")}function Z(t){return[n.join(t,"node_modules/@gamely/prometheus-cli/bin/cli.js"),n.join(t,"node_modules/ms-vite-plugin/node_modules/@gamely/prometheus-cli/bin/cli.js"),n.resolve(process.cwd(),"node_modules/@gamely/prometheus-cli/bin/cli.js")].find(o=>i.pathExistsSync(o))}const k=async(t=!0,e)=>{const o=n.join(e,"scripts"),s=await i.pathExists(n.join(o,"main.js"))||await i.pathExists(n.join(o,"main.ts")),r=await i.pathExists(n.join(o,"main.py")),c=await i.pathExists(n.join(o,"main.lua"));if(s){console.log("\u{1F680} \u5F00\u59CB\u6784\u5EFAJavaScript\u9879\u76EE...");const{build:l}=await import("vite"),u=n.join(e,"obfuscator.json");await i.pathExists(u)||(console.error("\u274C \u9519\u8BEF: \u5F53\u524D\u76EE\u5F55\u4E0D\u662F\u6709\u6548\u7684 \u5FEB\u70B9JS \u9879\u76EE"),console.error("\u8BF7\u786E\u4FDD\u76EE\u5F55\u5305\u542B\u4EE5\u4E0B\u6587\u4EF6:"),console.error(" - obfuscator.json"),process.exit(1));const g=await i.readJSON(u),m=g.scriptProtect===!0,{enabled:_,scriptProtect:y,...p}=g,d=n.join(e,t?"dist":"msbundle"),h=await I(o,o);await i.remove(d);const w=!t&&m?(0,L.createScriptProtectHelpers)():[];!t&&m&&console.log("\u{1F510} \u5DF2\u542F\u7528 JS \u539F\u751F\u4FDD\u62A4\uFF08scriptProtect=true\uFF09");for(const v of h)await l({root:e,build:{lib:{entry:{[n.basename(v,n.extname(v))]:`./scripts/${v}`},fileName:()=>v.replace(/\.ts$/,".js"),formats:["iife"],name:"KuaiJS"},outDir:t?"dist/scripts":"msbundle/scripts",emptyOutDir:!1,sourcemap:t,minify:!t,target:"safari15"},plugins:[(0,B.createStopGuardPlugin)(),...t?[]:[...m?[(0,L.createScriptProtectPlugin)(w)]:[],_?(0,H.default)({autoExcludeNodeModules:!0,threadPool:!0,options:{...p,target:"browser",debugProtection:!1,disableConsoleOutput:!1,domainLock:[],selfDefending:!1,renameGlobals:!1,renameProperties:!1,reservedNames:[...p.reservedNames||[],...w]}}):[],...m?[(0,L.createKjstEmbedPlugin)()]:[]]]})}if(t)return;const a=n.join(e,"msbundle");if(await i.ensureDir(a),(r||c)&&await i.copy(n.join(e,"scripts"),n.join(a,"scripts")),r){const l=Q();if(l.ok){console.log(`\u2705 \u68C0\u6D4B\u5230 ${l.version} (${l.path})`);const u=(0,E.spawnSync)(l.path,["-m","compileall","scripts"],{encoding:"utf8",cwd:a});u.status===0?(console.log("\u2705 \u6210\u529F\u7F16\u8BD1\u6240\u6709 Python \u6587\u4EF6"),await U(n.join(a,"scripts"))):(console.error("\u274C \u7F16\u8BD1 Python \u6587\u4EF6\u5931\u8D25"),console.error(u.stderr),process.exit(1))}else console.warn("\u26A0\uFE0F \u672A\u68C0\u6D4B\u5230 Python 3.14\uFF0C\u8BF7\u786E\u4FDD\u5728\u76EE\u6807\u8FD0\u884C\u73AF\u5883\u5B89\u88C5 Python 3.14")}else if(c){const l=await X(e),u=n.join(a,"scripts");if(l.bundle?await(0,G.bundleLuaScripts)(u):console.log("\u2139\uFE0F \u5DF2\u5173\u95ED Lua \u5355\u6587\u4EF6\u5408\u5E76\uFF08obfuscator.json bundle=false\uFF09"),!l.enabled)console.log("\u2139\uFE0F \u5DF2\u5173\u95ED Lua \u6DF7\u6DC6\uFF08obfuscator.json enabled=false\uFF09");else{const g=[],m=async y=>{const p=await i.readdir(y,{withFileTypes:!0});for(const d of p){const h=n.join(y,d.name);d.isDirectory()?await m(h):d.isFile()&&d.name.endsWith(".lua")&&g.push(h)}};await m(u);const _=Z(e);_||(console.error("\u274C \u672A\u627E\u5230 @gamely/prometheus-cli\uFF0C\u65E0\u6CD5\u6DF7\u6DC6 Lua"),process.exit(1));for(const y of g){const p=n.relative(u,y);console.log(`\u{1F6E0}\uFE0F \u6DF7\u6DC6 Lua: ${p} (preset=${l.preset})`);const d=(0,E.spawnSync)(process.execPath,[_,p,"--preset",l.preset],{cwd:u,encoding:"utf8"});d.status!==0&&(console.error("\u274C \u6DF7\u6DC6 Lua \u5931\u8D25:",p),console.error(d.stderr||d.stdout||""),process.exit(1));const h=p.replace(/\.lua$/,".obfuscated.lua"),w=n.join(u,h);await i.pathExists(w)&&(await i.remove(y),await i.move(w,y,{overwrite:!0}))}console.log("\u2705 Lua \u6DF7\u6DC6\u5B8C\u6210")}}await i.copy(n.join(e,"res"),n.join(a,"res")),await i.copy(n.join(e,"ui"),n.join(a,"ui"));for(const l of["logo.jpg","logo.png"]){const u=n.join(e,l);await i.pathExists(u)&&await i.copy(u,n.join(a,l))}const f=n.join(e,"dist"),P=n.join(e,"package.json"),S=n.join(a,"package.json"),b=await i.readJSON(P);delete b.scripts,delete b.devDependencies,delete b.dependencies,await i.writeJSON(S,b,{spaces:2}),await i.emptyDir(f);const j=n.join(f,"ms.zip"),J=n.join(f,"ms.msbundle");await R(a,j),await i.rename(j,J),await i.remove(a)};exports.buildAll=k;
1
+ "use strict";var F=Object.create;var J=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var C=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of N(e))!z.call(t,r)&&r!==o&&J(t,r,{get:()=>e[r],enumerable:!(s=$(e,r))||s.enumerable});return t};var W=(t,e,o)=>(o=t!=null?F(q(t)):{},C(e||!t||!t.__esModule?J(o,"default",{value:t,enumerable:!0}):o,t));var K=exports&&exports.__createBinding||(Object.create?(function(t,e,o,s){s===void 0&&(s=o);var r=Object.getOwnPropertyDescriptor(e,o);(!r||("get"in r?!e.__esModule:r.writable||r.configurable))&&(r={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,s,r)}):(function(t,e,o,s){s===void 0&&(s=o),t[s]=e[o]})),T=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),E=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(o){var s=[];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(s[s.length]=r);return s},t(e)};return function(e){if(e&&e.__esModule)return e;var o={};if(e!=null)for(var s=t(e),r=0;r<s.length;r++)s[r]!=="default"&&K(o,e,s[r]);return T(o,e),o}})(),L=exports&&exports.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildAll=void 0;const A=L(require("archiver")),P=require("child_process"),i=E(require("fs-extra")),M=E(require("os")),n=E(require("path")),B=require("./stopGuardPlugin"),G=require("./luaBundle"),x=require("./scriptProtect"),H=L(require("vite-plugin-bundle-obfuscator"));async function R(t,e){const o=(0,A.default)("zip",{zlib:{level:9}}),s=i.createWriteStream(e);return new Promise((r,c)=>{o.directory(t,!1).on("error",a=>c(a)).pipe(s),s.on("close",()=>r()),o.finalize()})}function I(t){const e=n.join(t,"node_modules","typescript","lib","tsc.js");return i.pathExistsSync(e)?e:void 0}function Q(t){const e=n.join(t,"tsconfig.json");i.pathExistsSync(e)||(console.error("\u274C \u672A\u627E\u5230 tsconfig.json\uFF0C\u65E0\u6CD5\u8FDB\u884C\u7C7B\u578B\u6821\u9A8C"),process.exit(1));const o=I(t);o||(console.error("\u274C \u672A\u627E\u5230 typescript\uFF0C\u8BF7\u5B89\u88C5\u540E\u91CD\u8BD5"),process.exit(1)),console.log("\u{1F50E} \u6B63\u5728\u8FDB\u884C\u7C7B\u578B\u6821\u9A8C...");const s=(0,P.spawnSync)(process.execPath,[o,"--noEmit","--pretty","--allowJs","--checkJs"],{cwd:t,stdio:"inherit"});s.status!==0&&(console.error("\u274C \u7C7B\u578B\u6821\u9A8C\u5931\u8D25"),process.exit(s.status??1)),console.log("\u2705 \u7C7B\u578B\u6821\u9A8C\u901A\u8FC7")}async function U(t,e){const o=[];async function s(r){const c=await i.readdir(r,{withFileTypes:!0});for(const a of c){const f=n.resolve(r,a.name);a.isDirectory()?await s(f):a.isFile()&&(/^main\.(js|ts)$/.test(a.name)||/_thread\.(js|ts)$/.test(a.name))&&o.push(n.relative(e,f))}}return await s(t),o}function V(){const t=[{cmd:n.join(M.homedir(),".KuaiJSDevloper","python","python.exe"),args:["--version"]},{cmd:n.join(M.homedir(),".KuaiJSDevloper","python","bin","python"),args:["--version"]},{cmd:"python",args:["--version"]},{cmd:"python3",args:["--version"]},{cmd:"python3.14",args:["--version"]}];for(const e of t)try{const o=(0,P.spawnSync)(e.cmd,e.args,{encoding:"utf8"}),s=(o.stdout||o.stderr||"").trim();if(s&&/Python\s+3\.14(\.\d+)?/i.test(s))return{ok:!0,path:e.cmd,version:s}}catch{}return{ok:!1}}async function X(t){async function e(o){const s=await i.readdir(o,{withFileTypes:!0});for(const r of s){const c=n.join(o,r.name);if(r.isDirectory())if(r.name==="__pycache__"){const a=await i.readdir(c,{withFileTypes:!0});for(const f of a){const S=n.join(c,f.name);if(f.isFile()&&f.name.endsWith(".cpython-314.pyc")){const O=n.dirname(c),b=f.name.replace(/\.cpython-314\.pyc$/,".pyc"),w=n.join(O,b);await i.move(S,w,{overwrite:!0})}}try{await i.remove(c)}catch{}}else await e(c);else if(r.isFile())if(r.name.endsWith(".cpython-314.pyc")){const a=c.replace(".cpython-314.pyc",".pyc");await i.move(c,a,{overwrite:!0})}else r.name.endsWith(".py")&&await i.remove(c)}}await e(t)}const Y=["Minify","Weak","Medium","Strong"];async function Z(t){const e=n.join(t,"obfuscator.json");if(!await i.pathExists(e))return{enabled:!0,preset:"Medium",bundle:!0};try{const o=await i.readJSON(e),s=o?.enabled!==!1,r=o?.bundle!==!1,c=k(o?.preset);return{enabled:s,preset:c,bundle:r}}catch(o){return console.error("\u274C \u65E0\u6CD5\u8BFB\u53D6 obfuscator.json"),console.error(o instanceof Error?o.message:String(o)),process.exit(1),{enabled:!0,preset:"Medium",bundle:!0}}}function k(t){if(typeof t!="string")return"Medium";const e=Y.find(o=>o.toLowerCase()===t.trim().toLowerCase());return e||(console.warn(`\u26A0\uFE0F obfuscator.json \u7684 preset \u65E0\u6548: ${t}\uFF0C\u5DF2\u6539\u7528 Medium`),"Medium")}function ee(t){return[n.join(t,"node_modules/@gamely/prometheus-cli/bin/cli.js"),n.join(t,"node_modules/ms-vite-plugin/node_modules/@gamely/prometheus-cli/bin/cli.js"),n.resolve(process.cwd(),"node_modules/@gamely/prometheus-cli/bin/cli.js")].find(o=>i.pathExistsSync(o))}const te=async(t=!0,e)=>{const o=n.join(e,"scripts"),s=await i.pathExists(n.join(o,"main.js"))||await i.pathExists(n.join(o,"main.ts")),r=await i.pathExists(n.join(o,"main.py")),c=await i.pathExists(n.join(o,"main.lua"));if(s){console.log("\u{1F680} \u5F00\u59CB\u6784\u5EFAJavaScript\u9879\u76EE..."),Q(e);const{build:l}=await import("vite"),u=n.join(e,"obfuscator.json");await i.pathExists(u)||(console.error("\u274C \u9519\u8BEF: \u5F53\u524D\u76EE\u5F55\u4E0D\u662F\u6709\u6548\u7684 \u5FEB\u70B9JS \u9879\u76EE"),console.error("\u8BF7\u786E\u4FDD\u76EE\u5F55\u5305\u542B\u4EE5\u4E0B\u6587\u4EF6:"),console.error(" - obfuscator.json"),process.exit(1));const j=await i.readJSON(u),m=j.scriptProtect===!0,{enabled:_,scriptProtect:y,...p}=j,d=n.join(e,t?"dist":"msbundle"),h=await U(o,o);await i.remove(d);const g=!t&&m?(0,x.createScriptProtectHelpers)():[];!t&&m&&console.log("\u{1F510} \u5DF2\u542F\u7528 JS \u539F\u751F\u4FDD\u62A4\uFF08scriptProtect=true\uFF09");for(const v of h)await l({root:e,build:{lib:{entry:{[n.basename(v,n.extname(v))]:`./scripts/${v}`},fileName:()=>v.replace(/\.ts$/,".js"),formats:["iife"],name:"KuaiJS"},outDir:t?"dist/scripts":"msbundle/scripts",emptyOutDir:!1,sourcemap:t,minify:!t,target:"safari15"},plugins:[(0,B.createStopGuardPlugin)(),...t?[]:[...m?[(0,x.createScriptProtectPlugin)(g)]:[],_?(0,H.default)({autoExcludeNodeModules:!0,threadPool:!0,options:{...p,target:"browser",debugProtection:!1,disableConsoleOutput:!1,domainLock:[],selfDefending:!1,renameGlobals:!1,renameProperties:!1,reservedNames:[...p.reservedNames||[],...g]}}):[],...m?[(0,x.createKjstEmbedPlugin)()]:[]]]})}if(t)return;const a=n.join(e,"msbundle");if(await i.ensureDir(a),(r||c)&&await i.copy(n.join(e,"scripts"),n.join(a,"scripts")),r){const l=V();if(l.ok){console.log(`\u2705 \u68C0\u6D4B\u5230 ${l.version} (${l.path})`);const u=(0,P.spawnSync)(l.path,["-m","compileall","scripts"],{encoding:"utf8",cwd:a});u.status===0?(console.log("\u2705 \u6210\u529F\u7F16\u8BD1\u6240\u6709 Python \u6587\u4EF6"),await X(n.join(a,"scripts"))):(console.error("\u274C \u7F16\u8BD1 Python \u6587\u4EF6\u5931\u8D25"),console.error(u.stderr),process.exit(1))}else console.warn("\u26A0\uFE0F \u672A\u68C0\u6D4B\u5230 Python 3.14\uFF0C\u8BF7\u786E\u4FDD\u5728\u76EE\u6807\u8FD0\u884C\u73AF\u5883\u5B89\u88C5 Python 3.14")}else if(c){const l=await Z(e),u=n.join(a,"scripts");if(l.bundle?await(0,G.bundleLuaScripts)(u):console.log("\u2139\uFE0F \u5DF2\u5173\u95ED Lua \u5355\u6587\u4EF6\u5408\u5E76\uFF08obfuscator.json bundle=false\uFF09"),!l.enabled)console.log("\u2139\uFE0F \u5DF2\u5173\u95ED Lua \u6DF7\u6DC6\uFF08obfuscator.json enabled=false\uFF09");else{const j=[],m=async y=>{const p=await i.readdir(y,{withFileTypes:!0});for(const d of p){const h=n.join(y,d.name);d.isDirectory()?await m(h):d.isFile()&&d.name.endsWith(".lua")&&j.push(h)}};await m(u);const _=ee(e);_||(console.error("\u274C \u672A\u627E\u5230 @gamely/prometheus-cli\uFF0C\u65E0\u6CD5\u6DF7\u6DC6 Lua"),process.exit(1));for(const y of j){const p=n.relative(u,y);console.log(`\u{1F6E0}\uFE0F \u6DF7\u6DC6 Lua: ${p} (preset=${l.preset})`);const d=(0,P.spawnSync)(process.execPath,[_,p,"--preset",l.preset],{cwd:u,encoding:"utf8"});d.status!==0&&(console.error("\u274C \u6DF7\u6DC6 Lua \u5931\u8D25:",p),console.error(d.stderr||d.stdout||""),process.exit(1));const h=p.replace(/\.lua$/,".obfuscated.lua"),g=n.join(u,h);await i.pathExists(g)&&(await i.remove(y),await i.move(g,y,{overwrite:!0}))}console.log("\u2705 Lua \u6DF7\u6DC6\u5B8C\u6210")}}await i.copy(n.join(e,"res"),n.join(a,"res")),await i.copy(n.join(e,"ui"),n.join(a,"ui"));for(const l of["logo.jpg","logo.png"]){const u=n.join(e,l);await i.pathExists(u)&&await i.copy(u,n.join(a,l))}const f=n.join(e,"dist"),S=n.join(e,"package.json"),O=n.join(a,"package.json"),b=await i.readJSON(S);delete b.scripts,delete b.devDependencies,delete b.dependencies,await i.writeJSON(O,b,{spaces:2}),await i.emptyDir(f);const w=n.join(f,"ms.zip"),D=n.join(f,"ms.msbundle");await R(a,w),await i.rename(w,D),await i.remove(a)};exports.buildAll=te;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addVararg=c;function s(r){r.vararg=!0,t(r.body.body)}function a(r){switch(r.type){case"FuncExpr":s(r);break;case"UnaryExpr":a(r.arg);break;case"BinaryExpr":a(r.left),a(r.right);break;case"TableExpr":for(const e of r.fields)e.kind==="index"&&a(e.key),a(e.value);break;case"IndexExpr":a(r.object),a(r.index);break;case"MemberExpr":a(r.object);break;case"CallExpr":a(r.callee);for(const e of r.args)a(e);break;case"MethodCallExpr":a(r.object);for(const e of r.args)a(e);break;case"ParenExpr":a(r.exp);break;default:break}}function t(r){for(const e of r)switch(e.type){case"DoStat":case"WhileStat":case"RepeatStat":case"ForNumStat":case"ForInStat":if(e.type==="WhileStat"&&a(e.cond),e.type==="RepeatStat"&&a(e.cond),e.type==="ForNumStat"&&(a(e.start),a(e.end),e.step&&a(e.step)),e.type==="ForInStat")for(const o of e.exps)a(o);t(e.body.body);break;case"IfStat":for(const o of e.clauses)a(o.cond),t(o.body.body);e.elseBody&&t(e.elseBody.body);break;case"FuncStat":case"LocalFuncStat":s(e.func);break;case"LocalStat":if(e.exps)for(const o of e.exps)a(o);break;case"AssignStat":for(const o of e.vars)a(o);for(const o of e.exps)a(o);break;case"CallStat":a(e.exp);break;case"ReturnStat":for(const o of e.exps)a(o);break;default:break}}function c(r){t(r.body)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addVararg=c;function s(o){o.vararg=!0,t(o.body.body)}function a(o){switch(o.type){case"FuncExpr":s(o);break;case"UnaryExpr":a(o.arg);break;case"BinaryExpr":a(o.left),a(o.right);break;case"TableExpr":for(const e of o.fields)e.kind==="index"&&a(e.key),a(e.value);break;case"IndexExpr":a(o.object),a(o.index);break;case"MemberExpr":a(o.object);break;case"CallExpr":a(o.callee);for(const e of o.args)a(e);break;case"MethodCallExpr":a(o.object);for(const e of o.args)a(e);break;case"ParenExpr":a(o.exp);break;default:break}}function t(o){for(const e of o)switch(e.type){case"DoStat":case"WhileStat":case"RepeatStat":case"ForNumStat":case"ForInStat":if(e.type==="WhileStat"&&a(e.cond),e.type==="RepeatStat"&&a(e.cond),e.type==="ForNumStat"&&(a(e.start),a(e.end),e.step&&a(e.step)),e.type==="ForInStat")for(const r of e.exps)a(r);t(e.body.body);break;case"IfStat":for(const r of e.clauses)a(r.cond),t(r.body.body);e.elseBody&&t(e.elseBody.body);break;case"FuncStat":case"LocalFuncStat":s(e.func);break;case"LocalStat":if(e.exps)for(const r of e.exps)a(r);break;case"AssignStat":for(const r of e.vars)a(r);for(const r of e.exps)a(r);break;case"CallStat":a(e.exp);break;case"ReturnStat":for(const r of e.exps)a(r);break;default:break}}function c(o){t(o.body)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.flattenControlFlow=C;function m(t){return{type:"NumberLiteral",raw:String(t),value:t}}function p(t){return{type:"NameExpr",name:t}}function f(t,n){return{type:"AssignStat",vars:t.map(e=>p(e)),exps:n}}function u(t,n){return f([t.stateName],[typeof n=="number"?m(n):n])}function k(t,n,e){return{type:"BinaryExpr",op:"or",left:{type:"BinaryExpr",op:"and",left:p(t),right:m(n)},right:m(e)}}function E(t,n,e){return{type:"BinaryExpr",op:t,left:n,right:e}}function S(t){const n=`__t${t.nextTemp}`;return t.nextTemp+=1,t.temps.push(n),n}function x(t){const n=t.nextState;return t.nextState+=1,t.states.set(n,[]),n}function o(t,n,e){t.states.get(n).push(e)}function F(t,n){for(const e of t)if(e.type==="LocalStat")for(const a of e.names)n.push(a.name);else if(e.type==="LocalFuncStat")n.push(e.name);else if(e.type==="ForNumStat")n.push(e.name),F(e.body.body,n);else if(e.type==="ForInStat")n.push(...e.names),F(e.body.body,n);else if(e.type==="DoStat"||e.type==="WhileStat"||e.type==="RepeatStat")F(e.body.body,n);else if(e.type==="IfStat"){for(const a of e.clauses)F(a.body.body,n);e.elseBody&&F(e.elseBody.body,n)}}function h(t,n,e,a){if(t.length===0)return n;const y=t.map(()=>x(e));for(let s=0;s<t.length;s+=1){const r=t[s];r.type==="LabelStat"&&e.userLabels.set(r.name,y[s])}for(let s=0;s<t.length;s+=1){const r=s+1<t.length?y[s+1]:n;I(e,y[s],t[s],r,a)}return y[0]}function I(t,n,e,a,y){switch(e.type){case"EmptyStat":case"LabelStat":o(t,n,u(t,a));return;case"AssignStat":case"CallStat":case"FuncStat":o(t,n,e),o(t,n,u(t,a));return;case"LocalStat":e.exps&&e.exps.length>0&&o(t,n,f(e.names.map(s=>s.name),e.exps)),o(t,n,u(t,a));return;case"LocalFuncStat":o(t,n,f([e.name],[e.func])),o(t,n,u(t,a));return;case"ReturnStat":o(t,n,e);return;case"BreakStat":o(t,n,u(t,y));return;case"GotoStat":{const s=t.userLabels.get(e.name);if(s===void 0)throw new Error(`goto \u672A\u5B9A\u4E49\u6807\u7B7E ::${e.name}::`);o(t,n,u(t,s));return}case"DoStat":o(t,n,u(t,h(e.body.body,a,t,y)));return;case"IfStat":{const s=S(t);let r=n;for(let l=0;l<e.clauses.length;l+=1){const b=l===e.clauses.length-1,d=h(e.clauses[l].body.body,a,t,y);let i=a;b?e.elseBody&&(i=h(e.elseBody.body,a,t,y)):i=x(t),o(t,r,f([s],[e.clauses[l].cond])),o(t,r,u(t,k(s,d,i))),b||(r=i)}e.clauses.length===0&&o(t,n,u(t,a));return}case"WhileStat":{const s=S(t),r=h(e.body.body,n,t,a);o(t,n,f([s],[e.cond])),o(t,n,u(t,k(s,r,a)));return}case"RepeatStat":{const s=S(t),r=x(t),l=h(e.body.body,r,t,a);o(t,n,u(t,l)),o(t,r,f([s],[e.cond])),o(t,r,u(t,k(s,a,l)));return}case"ForNumStat":{const s=e.name,r=S(t),l=S(t),b=S(t),d=x(t),i=x(t),L=x(t),g=x(t),N=h(e.body.body,g,t,a);o(t,n,f([s],[e.start])),o(t,n,f([r],[e.end])),o(t,n,f([l],[e.step??m(1)])),o(t,n,u(t,d)),o(t,d,f([b],[E(">=",p(l),m(0))])),o(t,d,u(t,k(b,i,L))),o(t,i,f([b],[E("<=",p(s),p(r))])),o(t,i,u(t,k(b,N,a))),o(t,L,f([b],[E(">=",p(s),p(r))])),o(t,L,u(t,k(b,N,a))),o(t,g,f([s],[E("+",p(s),p(l))])),o(t,g,u(t,d));return}case"ForInStat":{const s=S(t),r=S(t),l=S(t),b=S(t),d=x(t),i=[f([l],[p(e.names[0])]),...e.body.body],L=h(i,d,t,a),g=e.exps.slice();for(;g.length<3;)g.push({type:"NilLiteral"});o(t,n,f([s,r,l],g.slice(0,3))),o(t,n,u(t,d)),o(t,d,{type:"AssignStat",vars:e.names.map(N=>p(N)),exps:[{type:"CallExpr",callee:p(s),args:[p(r),p(l)]}]}),o(t,d,f([b],[E("~=",p(e.names[0]),{type:"NilLiteral"})])),o(t,d,u(t,k(b,L,a)));return}default:o(t,n,u(t,a))}}function v(t,n){const e=t.slice();let a=n>>>0||1;for(let y=e.length-1;y>0;y-=1){a=Math.imul(a,1664525)+1013904223>>>0;const s=a%(y+1),r=e[y];e[y]=e[s],e[s]=r}return e}function w(t,n){if(t.length===0)return t;const e={states:new Map,temps:[],nextState:1,nextTemp:1,stateName:"__s",userLabels:new Map},a=[];F(t,a);const y=h(t,0,e,0),s=[...new Set([...a,...e.temps,e.stateName])],r=v([...e.states.keys()],n).map(l=>({cond:E("==",p(e.stateName),m(l)),body:{type:"Block",body:e.states.get(l)}}));return[{type:"LocalStat",names:s.map(l=>({name:l}))},f([e.stateName],[m(y)]),{type:"WhileStat",cond:E("~=",p(e.stateName),m(0)),body:{type:"Block",body:[{type:"IfStat",clauses:r}]}}]}function c(t,n){switch(t.type){case"FuncExpr":B(t.body.body,n),t.body.body=w(t.body.body,n);break;case"UnaryExpr":c(t.arg,n);break;case"BinaryExpr":c(t.left,n),c(t.right,n);break;case"TableExpr":for(const e of t.fields)e.kind==="index"&&c(e.key,n),c(e.value,n);break;case"IndexExpr":c(t.object,n),c(t.index,n);break;case"MemberExpr":c(t.object,n);break;case"CallExpr":c(t.callee,n);for(const e of t.args)c(e,n);break;case"MethodCallExpr":c(t.object,n);for(const e of t.args)c(e,n);break;case"ParenExpr":c(t.exp,n);break;default:break}}function B(t,n){for(const e of t)switch(e.type){case"DoStat":case"WhileStat":case"RepeatStat":case"ForNumStat":case"ForInStat":if((e.type==="WhileStat"||e.type==="RepeatStat")&&c(e.cond,n),e.type==="ForNumStat"&&(c(e.start,n),c(e.end,n),e.step&&c(e.step,n)),e.type==="ForInStat")for(const a of e.exps)c(a,n);B(e.body.body,n);break;case"IfStat":for(const a of e.clauses)c(a.cond,n),B(a.body.body,n);e.elseBody&&B(e.elseBody.body,n);break;case"FuncStat":case"LocalFuncStat":B(e.func.body.body,n),e.func.body.body=w(e.func.body.body,n);break;case"LocalStat":if(e.exps)for(const a of e.exps)c(a,n);break;case"AssignStat":for(const a of e.vars)c(a,n);for(const a of e.exps)c(a,n);break;case"CallStat":c(e.exp,n);break;case"ReturnStat":for(const a of e.exps)c(a,n);break;default:break}}function C(t,n){B(t.body,n),t.body=w(t.body,n)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.flattenControlFlow=C;function m(t){return{type:"NumberLiteral",raw:String(t),value:t}}function p(t){return{type:"NameExpr",name:t}}function f(t,o){return{type:"AssignStat",vars:t.map(e=>p(e)),exps:o}}function u(t,o){return f([t.stateName],[typeof o=="number"?m(o):o])}function k(t,o,e){return{type:"BinaryExpr",op:"or",left:{type:"BinaryExpr",op:"and",left:p(t),right:m(o)},right:m(e)}}function E(t,o,e){return{type:"BinaryExpr",op:t,left:o,right:e}}function S(t){const o=`__t${t.nextTemp}`;return t.nextTemp+=1,t.temps.push(o),o}function x(t){const o=t.nextState;return t.nextState+=1,t.states.set(o,[]),o}function s(t,o,e){t.states.get(o).push(e)}function F(t,o){for(const e of t)if(e.type==="LocalStat")for(const a of e.names)o.push(a.name);else if(e.type==="LocalFuncStat")o.push(e.name);else if(e.type==="ForNumStat")o.push(e.name),F(e.body.body,o);else if(e.type==="ForInStat")o.push(...e.names),F(e.body.body,o);else if(e.type==="DoStat"||e.type==="WhileStat"||e.type==="RepeatStat")F(e.body.body,o);else if(e.type==="IfStat"){for(const a of e.clauses)F(a.body.body,o);e.elseBody&&F(e.elseBody.body,o)}}function h(t,o,e,a){if(t.length===0)return o;const y=t.map(()=>x(e));for(let n=0;n<t.length;n+=1){const r=t[n];r.type==="LabelStat"&&e.userLabels.set(r.name,y[n])}for(let n=0;n<t.length;n+=1){const r=n+1<t.length?y[n+1]:o;I(e,y[n],t[n],r,a)}return y[0]}function I(t,o,e,a,y){switch(e.type){case"EmptyStat":case"LabelStat":s(t,o,u(t,a));return;case"AssignStat":case"CallStat":case"FuncStat":s(t,o,e),s(t,o,u(t,a));return;case"LocalStat":e.exps&&e.exps.length>0&&s(t,o,f(e.names.map(n=>n.name),e.exps)),s(t,o,u(t,a));return;case"LocalFuncStat":s(t,o,f([e.name],[e.func])),s(t,o,u(t,a));return;case"ReturnStat":s(t,o,e);return;case"BreakStat":s(t,o,u(t,y));return;case"GotoStat":{const n=t.userLabels.get(e.name);if(n===void 0)throw new Error(`goto \u672A\u5B9A\u4E49\u6807\u7B7E ::${e.name}::`);s(t,o,u(t,n));return}case"DoStat":s(t,o,u(t,h(e.body.body,a,t,y)));return;case"IfStat":{const n=S(t);let r=o;for(let l=0;l<e.clauses.length;l+=1){const b=l===e.clauses.length-1,d=h(e.clauses[l].body.body,a,t,y);let i=a;b?e.elseBody&&(i=h(e.elseBody.body,a,t,y)):i=x(t),s(t,r,f([n],[e.clauses[l].cond])),s(t,r,u(t,k(n,d,i))),b||(r=i)}e.clauses.length===0&&s(t,o,u(t,a));return}case"WhileStat":{const n=S(t),r=h(e.body.body,o,t,a);s(t,o,f([n],[e.cond])),s(t,o,u(t,k(n,r,a)));return}case"RepeatStat":{const n=S(t),r=x(t),l=h(e.body.body,r,t,a);s(t,o,u(t,l)),s(t,r,f([n],[e.cond])),s(t,r,u(t,k(n,a,l)));return}case"ForNumStat":{const n=e.name,r=S(t),l=S(t),b=S(t),d=x(t),i=x(t),L=x(t),g=x(t),N=h(e.body.body,g,t,a);s(t,o,f([n],[e.start])),s(t,o,f([r],[e.end])),s(t,o,f([l],[e.step??m(1)])),s(t,o,u(t,d)),s(t,d,f([b],[E(">=",p(l),m(0))])),s(t,d,u(t,k(b,i,L))),s(t,i,f([b],[E("<=",p(n),p(r))])),s(t,i,u(t,k(b,N,a))),s(t,L,f([b],[E(">=",p(n),p(r))])),s(t,L,u(t,k(b,N,a))),s(t,g,f([n],[E("+",p(n),p(l))])),s(t,g,u(t,d));return}case"ForInStat":{const n=S(t),r=S(t),l=S(t),b=S(t),d=x(t),i=[f([l],[p(e.names[0])]),...e.body.body],L=h(i,d,t,a),g=e.exps.slice();for(;g.length<3;)g.push({type:"NilLiteral"});s(t,o,f([n,r,l],g.slice(0,3))),s(t,o,u(t,d)),s(t,d,{type:"AssignStat",vars:e.names.map(N=>p(N)),exps:[{type:"CallExpr",callee:p(n),args:[p(r),p(l)]}]}),s(t,d,f([b],[E("~=",p(e.names[0]),{type:"NilLiteral"})])),s(t,d,u(t,k(b,L,a)));return}default:s(t,o,u(t,a))}}function v(t,o){const e=t.slice();let a=o>>>0||1;for(let y=e.length-1;y>0;y-=1){a=Math.imul(a,1664525)+1013904223>>>0;const n=a%(y+1),r=e[y];e[y]=e[n],e[n]=r}return e}function w(t,o){if(t.length===0)return t;const e={states:new Map,temps:[],nextState:1,nextTemp:1,stateName:"__s",userLabels:new Map},a=[];F(t,a);const y=h(t,0,e,0),n=[...new Set([...a,...e.temps,e.stateName])],r=v([...e.states.keys()],o).map(l=>({cond:E("==",p(e.stateName),m(l)),body:{type:"Block",body:e.states.get(l)}}));return[{type:"LocalStat",names:n.map(l=>({name:l}))},f([e.stateName],[m(y)]),{type:"WhileStat",cond:E("~=",p(e.stateName),m(0)),body:{type:"Block",body:[{type:"IfStat",clauses:r}]}}]}function c(t,o){switch(t.type){case"FuncExpr":B(t.body.body,o),t.body.body=w(t.body.body,o);break;case"UnaryExpr":c(t.arg,o);break;case"BinaryExpr":c(t.left,o),c(t.right,o);break;case"TableExpr":for(const e of t.fields)e.kind==="index"&&c(e.key,o),c(e.value,o);break;case"IndexExpr":c(t.object,o),c(t.index,o);break;case"MemberExpr":c(t.object,o);break;case"CallExpr":c(t.callee,o);for(const e of t.args)c(e,o);break;case"MethodCallExpr":c(t.object,o);for(const e of t.args)c(e,o);break;case"ParenExpr":c(t.exp,o);break;default:break}}function B(t,o){for(const e of t)switch(e.type){case"DoStat":case"WhileStat":case"RepeatStat":case"ForNumStat":case"ForInStat":if((e.type==="WhileStat"||e.type==="RepeatStat")&&c(e.cond,o),e.type==="ForNumStat"&&(c(e.start,o),c(e.end,o),e.step&&c(e.step,o)),e.type==="ForInStat")for(const a of e.exps)c(a,o);B(e.body.body,o);break;case"IfStat":for(const a of e.clauses)c(a.cond,o),B(a.body.body,o);e.elseBody&&B(e.elseBody.body,o);break;case"FuncStat":case"LocalFuncStat":B(e.func.body.body,o),e.func.body.body=w(e.func.body.body,o);break;case"LocalStat":if(e.exps)for(const a of e.exps)c(a,o);break;case"AssignStat":for(const a of e.vars)c(a,o);for(const a of e.exps)c(a,o);break;case"CallStat":c(e.exp,o);break;case"ReturnStat":for(const a of e.exps)c(a,o);break;default:break}}function C(t,o){B(t.body,o),t.body=w(t.body,o)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.shortName=a,exports.renameLocals=c;const u=require("./reserved"),d=require("./scope"),l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function a(r){let e=r,t="";do t=l[e%l.length]+t,e=Math.floor(e/l.length)-1;while(e>=0);return u.luaKeywords.has(t)?`_${t}`:t}function c(r){let e=0;const t=new Set;(0,d.collectAndRename)(r,(o,s)=>{if(o.newName!==o.original)return;let n=a(e);for(e+=1;s.has(n)||t.has(n)||u.luaKeywords.has(n);)n=a(e),e+=1;o.newName=n,t.add(n),s.add(n)})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.shortName=r,exports.renameLocals=c;const u=require("./reserved"),d=require("./scope"),l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function r(a){let e=a,t="";do t=l[e%l.length]+t,e=Math.floor(e/l.length)-1;while(e>=0);return u.luaKeywords.has(t)?`_${t}`:t}function c(a){let e=0;const t=new Set;(0,d.collectAndRename)(a,(o,s)=>{if(o.newName!==o.original)return;let n=r(e);for(e+=1;s.has(n)||t.has(n)||u.luaKeywords.has(n);)n=r(e),e+=1;o.newName=n,t.add(n),s.add(n)})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveLocal=i,exports.collectAndRename=x;function i(t,c){let r=t;for(;r;){const e=r.locals.get(c);if(e)return e;r=r.parent}}function o(t){return{parent:t,locals:new Map}}function f(t,c){const r=t.locals.get(c);if(r)return r;const e={original:c,newName:c};return t.locals.set(c,e),e}function x(t,c){const r=new Set,e={locals:new Map};d(t.body,e,r,c)}function l(t,c,r,e){d(t.body,c,r,e)}function d(t,c,r,e){for(const s of t)b(s,c,r,e)}function m(t,c,r,e){const s=o(c),a=t.params.slice();for(let u=0;u<a.length;u+=1){const p=f(s,a[u]);e(p,r),t.params[u]=p.newName}l(t.body,s,r,e)}function b(t,c,r,e){switch(t.type){case"EmptyStat":case"BreakStat":case"GotoStat":case"LabelStat":return;case"DoStat":l(t.body,o(c),r,e);return;case"WhileStat":n(t.cond,c,r,e),l(t.body,o(c),r,e);return;case"RepeatStat":{const s=o(c);l(t.body,s,r,e),n(t.cond,s,r,e);return}case"IfStat":for(const s of t.clauses)n(s.cond,c,r,e),l(s.body,o(c),r,e);t.elseBody&&l(t.elseBody,o(c),r,e);return;case"ForNumStat":{n(t.start,c,r,e),n(t.end,c,r,e),t.step&&n(t.step,c,r,e);const s=o(c),a=f(s,t.name);e(a,r),t.name=a.newName,l(t.body,s,r,e);return}case"ForInStat":{for(const a of t.exps)n(a,c,r,e);const s=o(c);for(let a=0;a<t.names.length;a+=1){const u=f(s,t.names[a]);e(u,r),t.names[a]=u.newName}l(t.body,s,r,e);return}case"FuncStat":{const s=i(c,t.name.base);s&&(t.name.base=s.newName),m(t.func,c,r,e);return}case"LocalFuncStat":{const s=f(c,t.name);e(s,r),t.name=s.newName,m(t.func,c,r,e);return}case"LocalStat":if(t.exps)for(const s of t.exps)n(s,c,r,e);for(let s=0;s<t.names.length;s+=1){const a=f(c,t.names[s].name);e(a,r),t.names[s].name=a.newName}return;case"AssignStat":for(const s of t.vars)n(s,c,r,e);for(const s of t.exps)n(s,c,r,e);return;case"CallStat":n(t.exp,c,r,e);return;case"ReturnStat":for(const s of t.exps)n(s,c,r,e);return}}function n(t,c,r,e){switch(t.type){case"NilLiteral":case"BoolLiteral":case"NumberLiteral":case"StringLiteral":case"VarargExpr":return;case"NameExpr":{const s=i(c,t.name);s&&(t.name=s.newName);return}case"UnaryExpr":n(t.arg,c,r,e);return;case"BinaryExpr":n(t.left,c,r,e),n(t.right,c,r,e);return;case"FuncExpr":m(t,c,r,e);return;case"TableExpr":for(const s of t.fields)s.kind==="index"&&n(s.key,c,r,e),n(s.value,c,r,e);return;case"IndexExpr":n(t.object,c,r,e),n(t.index,c,r,e);return;case"MemberExpr":n(t.object,c,r,e);return;case"CallExpr":n(t.callee,c,r,e);for(const s of t.args)n(s,c,r,e);return;case"MethodCallExpr":n(t.object,c,r,e);for(const s of t.args)n(s,c,r,e);return;case"ParenExpr":n(t.exp,c,r,e);return}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveLocal=i,exports.collectAndRename=x;function i(t,o){let r=t;for(;r;){const e=r.locals.get(o);if(e)return e;r=r.parent}}function s(t){return{parent:t,locals:new Map}}function f(t,o){const r=t.locals.get(o);if(r)return r;const e={original:o,newName:o};return t.locals.set(o,e),e}function x(t,o){const r=new Set,e={locals:new Map};d(t.body,e,r,o)}function l(t,o,r,e){d(t.body,o,r,e)}function d(t,o,r,e){for(const c of t)b(c,o,r,e)}function m(t,o,r,e){const c=s(o),a=t.params.slice();for(let u=0;u<a.length;u+=1){const p=f(c,a[u]);e(p,r),t.params[u]=p.newName}l(t.body,c,r,e)}function b(t,o,r,e){switch(t.type){case"EmptyStat":case"BreakStat":case"GotoStat":case"LabelStat":return;case"DoStat":l(t.body,s(o),r,e);return;case"WhileStat":n(t.cond,o,r,e),l(t.body,s(o),r,e);return;case"RepeatStat":{const c=s(o);l(t.body,c,r,e),n(t.cond,c,r,e);return}case"IfStat":for(const c of t.clauses)n(c.cond,o,r,e),l(c.body,s(o),r,e);t.elseBody&&l(t.elseBody,s(o),r,e);return;case"ForNumStat":{n(t.start,o,r,e),n(t.end,o,r,e),t.step&&n(t.step,o,r,e);const c=s(o),a=f(c,t.name);e(a,r),t.name=a.newName,l(t.body,c,r,e);return}case"ForInStat":{for(const a of t.exps)n(a,o,r,e);const c=s(o);for(let a=0;a<t.names.length;a+=1){const u=f(c,t.names[a]);e(u,r),t.names[a]=u.newName}l(t.body,c,r,e);return}case"FuncStat":{const c=i(o,t.name.base);c&&(t.name.base=c.newName),m(t.func,o,r,e);return}case"LocalFuncStat":{const c=f(o,t.name);e(c,r),t.name=c.newName,m(t.func,o,r,e);return}case"LocalStat":if(t.exps)for(const c of t.exps)n(c,o,r,e);for(let c=0;c<t.names.length;c+=1){const a=f(o,t.names[c].name);e(a,r),t.names[c].name=a.newName}return;case"AssignStat":for(const c of t.vars)n(c,o,r,e);for(const c of t.exps)n(c,o,r,e);return;case"CallStat":n(t.exp,o,r,e);return;case"ReturnStat":for(const c of t.exps)n(c,o,r,e);return}}function n(t,o,r,e){switch(t.type){case"NilLiteral":case"BoolLiteral":case"NumberLiteral":case"StringLiteral":case"VarargExpr":return;case"NameExpr":{const c=i(o,t.name);c&&(t.name=c.newName);return}case"UnaryExpr":n(t.arg,o,r,e);return;case"BinaryExpr":n(t.left,o,r,e),n(t.right,o,r,e);return;case"FuncExpr":m(t,o,r,e);return;case"TableExpr":for(const c of t.fields)c.kind==="index"&&n(c.key,o,r,e),n(c.value,o,r,e);return;case"IndexExpr":n(t.object,o,r,e),n(t.index,o,r,e);return;case"MemberExpr":n(t.object,o,r,e);return;case"CallExpr":n(t.callee,o,r,e);for(const c of t.args)n(c,o,r,e);return;case"MethodCallExpr":n(t.object,o,r,e);for(const c of t.args)n(c,o,r,e);return;case"ParenExpr":n(t.exp,o,r,e);return}}
package/docs/api/ui.md CHANGED
@@ -74,7 +74,7 @@ UI 模块提供了 WebView 相关功能,支持事件通信和 JavaScript 交
74
74
 
75
75
  ```typescript
76
76
  function onEvent(
77
- onEvent: ((event: string, data: Record<string, any>) => void) | null
77
+ onEvent: ((event: string, data: Record<string, any>) => void) | null,
78
78
  ): void;
79
79
  ```
80
80
 
@@ -82,9 +82,9 @@ function onEvent(
82
82
 
83
83
  **参数:**
84
84
 
85
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
86
- | --------- | -------------------------------------------------- | -------- | ------ | ------------------------------------ |
87
- | `onEvent` | ((event: string, data: Record<string, any>) => void) 或 null | 是 | | 事件回调函数,用于处理来自网页的事件,传 `null` 取消监听 |
85
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
86
+ | --------- | ------------------------------------------------------------ | -------- | ------ | -------------------------------------------------------- |
87
+ | `onEvent` | ((event: string, data: Record<string, any>) => void) 或 null | 是 | | 事件回调函数,用于处理来自网页的事件,传 `null` 取消监听 |
88
88
 
89
89
  **示例:**
90
90
 
@@ -255,7 +255,7 @@ ui.alert("操作完成", "脚本执行完成,共处理了100个项目");
255
255
  ```typescript
256
256
  declare function registerUIFunc(
257
257
  name: string,
258
- func: (data: Record<string, any>) => void
258
+ func: (data: Record<string, any>) => void,
259
259
  ): void;
260
260
  ```
261
261
 
@@ -281,9 +281,8 @@ declare function registerUIFunc(
281
281
  <script>
282
282
  // 注册供主进程调用的函数
283
283
  ms.registerUIFunc("updateStatus", function (data) {
284
- document.getElementById(
285
- "status"
286
- ).textContent = `状态: ${data.status}, 进度: ${data.progress}%`;
284
+ document.getElementById("status").textContent =
285
+ `状态: ${data.status}, 进度: ${data.progress}%`;
287
286
  });
288
287
 
289
288
  ms.registerUIFunc("loadData", function (data) {
@@ -656,35 +655,6 @@ ms.getDeviceID()
656
655
  });
657
656
  ```
658
657
 
659
- #### getServerDeviceId - 获取服务器设备 ID
660
-
661
- ```typescript
662
- declare function getServerDeviceId(): Promise<string>;
663
- ```
664
-
665
- **返回值:**
666
-
667
- | 类型 | 描述 |
668
- | ----------------- | ------------- |
669
- | `Promise<string>` | 服务器设备 ID |
670
-
671
- **说明:**
672
-
673
- 获取当前运行脚本的服务器设备 ID。
674
-
675
- **网页端示例:**
676
-
677
- ```javascript
678
- // 获取服务器设备ID
679
- ms.getServerDeviceId()
680
- .then((deviceId) => {
681
- console.log("当前服务器设备ID:", deviceId);
682
- })
683
- .catch((error) => {
684
- console.error("获取服务器设备ID出错:", error);
685
- });
686
- ```
687
-
688
658
  #### getAuthCardNo - 获取缓存的授权卡密
689
659
 
690
660
  ```typescript
@@ -693,8 +663,8 @@ declare function getAuthCardNo(): Promise<string>;
693
663
 
694
664
  **返回值:**
695
665
 
696
- | 类型 | 描述 |
697
- | ----------------- | ------------------------------------ |
666
+ | 类型 | 描述 |
667
+ | ----------------- | -------------------------------------------------- |
698
668
  | `Promise<string>` | 有缓存的授权卡密时返回卡密字符串,否则返回空字符串 |
699
669
 
700
670
  **说明:**
package/docs/apicn/ui.md CHANGED
@@ -62,7 +62,7 @@ UI 模块提供了 WebView 相关功能,支持事件通信和 JavaScript 交
62
62
 
63
63
  ```typescript
64
64
  function 监听事件回调(
65
- 回调函数: ((事件名称: 字符串, 数据: 字典<任意类型>) => 无返回值) | null
65
+ 回调函数: ((事件名称: 字符串, 数据: 字典<任意类型>) => 无返回值) | null,
66
66
  ): 无返回值;
67
67
  ```
68
68
 
@@ -70,9 +70,9 @@ function 监听事件回调(
70
70
 
71
71
  **参数:**
72
72
 
73
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
74
- | ---------- | ---------------------------------------------------- | -------- | ------ | ------------------------------------ |
75
- | `回调函数` | ((事件名称: 字符串, 数据: 字典<任意类型>) => 无返回值) 或 null | 是 | | 事件回调函数,用于处理来自网页的事件,传 `null` 取消监听 |
73
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
74
+ | ---------- | -------------------------------------------------------------- | -------- | ------ | -------------------------------------------------------- |
75
+ | `回调函数` | ((事件名称: 字符串, 数据: 字典<任意类型>) => 无返回值) 或 null | 是 | | 事件回调函数,用于处理来自网页的事件,传 `null` 取消监听 |
76
76
 
77
77
  **示例:**
78
78
 
@@ -243,7 +243,7 @@ $视图.显示警告对话框("操作完成", "脚本执行完成,共处理了
243
243
  ```typescript
244
244
  declare function registerUIFunc(
245
245
  name: string,
246
- func: (data: Record<string, any>) => void
246
+ func: (data: Record<string, any>) => void,
247
247
  ): void;
248
248
  ```
249
249
 
@@ -269,9 +269,8 @@ declare function registerUIFunc(
269
269
  <script>
270
270
  // 注册供主进程调用的函数
271
271
  ms.registerUIFunc("updateStatus", function (data) {
272
- document.getElementById(
273
- "status"
274
- ).textContent = `状态: ${data.status}, 进度: ${data.progress}%`;
272
+ document.getElementById("status").textContent =
273
+ `状态: ${data.status}, 进度: ${data.progress}%`;
275
274
  });
276
275
 
277
276
  ms.registerUIFunc("loadData", function (data) {
@@ -644,35 +643,6 @@ ms.getDeviceID()
644
643
  });
645
644
  ```
646
645
 
647
- #### getServerDeviceId() - 获取服务器设备 ID
648
-
649
- ```typescript
650
- declare function getServerDeviceId(): Promise<string>;
651
- ```
652
-
653
- **返回值:**
654
-
655
- | 类型 | 描述 |
656
- | ----------------- | ------------- |
657
- | `Promise<string>` | 服务器设备 ID |
658
-
659
- **说明:**
660
-
661
- 获取当前运行脚本的服务器设备 ID。
662
-
663
- **网页端示例:**
664
-
665
- ```javascript
666
- // 获取服务器设备ID
667
- ms.getServerDeviceId()
668
- .then((deviceId) => {
669
- console.log("当前服务器设备ID:", deviceId);
670
- })
671
- .catch((error) => {
672
- console.error("获取服务器设备ID出错:", error);
673
- });
674
- ```
675
-
676
646
  #### getAuthCardNo() - 获取缓存的授权卡密
677
647
 
678
648
  ```typescript
@@ -681,8 +651,8 @@ declare function getAuthCardNo(): Promise<string>;
681
651
 
682
652
  **返回值:**
683
653
 
684
- | 类型 | 描述 |
685
- | ----------------- | ------------------------------------ |
654
+ | 类型 | 描述 |
655
+ | ----------------- | -------------------------------------------------- |
686
656
  | `Promise<string>` | 有缓存的授权卡密时返回卡密字符串,否则返回空字符串 |
687
657
 
688
658
  **说明:**
@@ -781,7 +751,9 @@ ms.openURL("https://www.baidu.com")
781
751
  <div class="panel">
782
752
  <h3>快点 Agent 控制</h3>
783
753
  <p>快点 Agent 状态: <span id="agent-status">检查中...</span></p>
784
- <button class="button" onclick="startAgentService()">启动 快点 Agent</button>
754
+ <button class="button" onclick="startAgentService()">
755
+ 启动 快点 Agent
756
+ </button>
785
757
  <button class="button" onclick="checkAgentStatus()">检查状态</button>
786
758
  </div>
787
759
 
package/docs/apilua/ui.md CHANGED
@@ -73,7 +73,6 @@ UI 模块提供了 WebView 相关功能,支持事件通信和 JavaScript 交
73
73
 
74
74
  ## 核心方法
75
75
 
76
-
77
76
  ### show - 显示 WebView。
78
77
 
79
78
  ```lua
@@ -117,7 +116,6 @@ function eval(code) end
117
116
  ui.eval("document.title = 'KuaiJS'")
118
117
  ```
119
118
 
120
-
121
119
  ### onEvent - 设置事件回调函数
122
120
 
123
121
  ```lua
@@ -129,9 +127,9 @@ function onEvent(onEvent) end
129
127
 
130
128
  **参数:**
131
129
 
132
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
133
- | --------- | -------------------------------------------------- | -------- | ------ | ------------------------------------ |
134
- | `onEvent` | ((event: string, data: table) => void) 或 nil | 是 | | 事件回调函数,用于处理来自网页的事件,传 `nil` 取消监听 |
130
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
131
+ | --------- | --------------------------------------------- | -------- | ------ | ------------------------------------------------------- |
132
+ | `onEvent` | ((event: string, data: table) => void) 或 nil | 是 | | 事件回调函数,用于处理来自网页的事件,传 `nil` 取消监听 |
135
133
 
136
134
  **示例:**
137
135
 
@@ -152,10 +150,10 @@ function call(key, data) end
152
150
 
153
151
  **参数:**
154
152
 
155
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
156
- | ------ | ------------------- | -------- | ------ | ----------------- |
157
- | `key` | string | 是 | | JavaScript 方法名 |
158
- | `data` | table | 是 | | 传递给方法的参数 |
153
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
154
+ | ------ | ------ | -------- | ------ | ----------------- |
155
+ | `key` | string | 是 | | JavaScript 方法名 |
156
+ | `data` | table | 是 | | 传递给方法的参数 |
159
157
 
160
158
  **示例:**
161
159
 
@@ -307,7 +305,7 @@ ui.alert("操作完成", "脚本执行完成,共处理了100个项目")
307
305
  ```typescript
308
306
  declare function registerUIFunc(
309
307
  name: string,
310
- func: (data: Record<string, any>) => void
308
+ func: (data: Record<string, any>) => void,
311
309
  ): void;
312
310
  ```
313
311
 
@@ -333,9 +331,8 @@ declare function registerUIFunc(
333
331
  <script>
334
332
  // 注册供主进程调用的函数
335
333
  ms.registerUIFunc("updateStatus", function (data) {
336
- document.getElementById(
337
- "status"
338
- ).textContent = `状态: ${data.status}, 进度: ${data.progress}%`;
334
+ document.getElementById("status").textContent =
335
+ `状态: ${data.status}, 进度: ${data.progress}%`;
339
336
  });
340
337
 
341
338
  ms.registerUIFunc("loadData", function (data) {
@@ -708,35 +705,6 @@ ms.getDeviceID()
708
705
  });
709
706
  ```
710
707
 
711
- #### getServerDeviceId - 获取服务器设备 ID
712
-
713
- ```typescript
714
- declare function getServerDeviceId(): Promise<string>;
715
- ```
716
-
717
- **返回值:**
718
-
719
- | 类型 | 描述 |
720
- | ----------------- | ------------- |
721
- | `Promise<string>` | 服务器设备 ID |
722
-
723
- **说明:**
724
-
725
- 获取当前运行脚本的服务器设备 ID。
726
-
727
- **网页端示例:**
728
-
729
- ```javascript
730
- // 获取服务器设备ID
731
- ms.getServerDeviceId()
732
- .then((deviceId) => {
733
- console.log("当前服务器设备ID:", deviceId);
734
- })
735
- .catch((error) => {
736
- console.error("获取服务器设备ID出错:", error);
737
- });
738
- ```
739
-
740
708
  #### getAuthCardNo - 获取缓存的授权卡密
741
709
 
742
710
  ```typescript
@@ -745,8 +713,8 @@ declare function getAuthCardNo(): Promise<string>;
745
713
 
746
714
  **返回值:**
747
715
 
748
- | 类型 | 描述 |
749
- | ----------------- | ------------------------------------ |
716
+ | 类型 | 描述 |
717
+ | ----------------- | -------------------------------------------------- |
750
718
  | `Promise<string>` | 有缓存的授权卡密时返回卡密字符串,否则返回空字符串 |
751
719
 
752
720
  **说明:**
@@ -82,9 +82,9 @@ def onEvent(callback: Callable[[str, Any], None] | None) -> None
82
82
 
83
83
  **参数:**
84
84
 
85
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
86
- | ---------- | ---------------------------- | -------- | ------ | ------------------------------------ |
87
- | `callback` | `Callable[[str, Any], None]` 或 `None` | 是 | | 事件回调函数,用于处理来自网页的事件,传 `None` 取消监听 |
85
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
86
+ | ---------- | -------------------------------------- | -------- | ------ | -------------------------------------------------------- |
87
+ | `callback` | `Callable[[str, Any], None]` 或 `None` | 是 | | 事件回调函数,用于处理来自网页的事件,传 `None` 取消监听 |
88
88
 
89
89
  **示例:**
90
90
 
@@ -268,7 +268,7 @@ ui.alert("操作完成", "脚本执行完成,共处理了100个项目")
268
268
  ```typescript
269
269
  declare function registerUIFunc(
270
270
  name: string,
271
- func: (data: Record<string, any>) => void
271
+ func: (data: Record<string, any>) => void,
272
272
  ): void;
273
273
  ```
274
274
 
@@ -294,9 +294,8 @@ declare function registerUIFunc(
294
294
  <script>
295
295
  // 注册供主进程调用的函数
296
296
  ms.registerUIFunc("updateStatus", function (data) {
297
- document.getElementById(
298
- "status"
299
- ).textContent = `状态: ${data.status}, 进度: ${data.progress}%`;
297
+ document.getElementById("status").textContent =
298
+ `状态: ${data.status}, 进度: ${data.progress}%`;
300
299
  });
301
300
 
302
301
  ms.registerUIFunc("loadData", function (data) {
@@ -669,35 +668,6 @@ ms.getDeviceID()
669
668
  });
670
669
  ```
671
670
 
672
- #### getServerDeviceId - 获取服务器设备 ID
673
-
674
- ```typescript
675
- declare function getServerDeviceId(): Promise<string>;
676
- ```
677
-
678
- **返回值:**
679
-
680
- | 类型 | 描述 |
681
- | ----------------- | ------------- |
682
- | `Promise<string>` | 服务器设备 ID |
683
-
684
- **说明:**
685
-
686
- 获取当前运行脚本的服务器设备 ID。
687
-
688
- **网页端示例:**
689
-
690
- ```javascript
691
- // 获取服务器设备ID
692
- ms.getServerDeviceId()
693
- .then((deviceId) => {
694
- console.log("当前服务器设备ID:", deviceId);
695
- })
696
- .catch((error) => {
697
- console.error("获取服务器设备ID出错:", error);
698
- });
699
- ```
700
-
701
671
  #### openURL - 调用浏览器打开 URL
702
672
 
703
673
  ```typescript
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-vite-plugin",
3
- "version": "1.4.79",
3
+ "version": "1.4.81",
4
4
  "type": "commonjs",
5
5
  "license": "MIT",
6
6
  "publishConfig": {