ms-vite-plugin 1.4.82 → 1.4.84
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 +1 -1
- package/dist/luaObfuscator/addVararg.js +1 -1
- package/dist/luaObfuscator/antiTamper.js +2 -2
- package/dist/luaObfuscator/cipher.js +6 -6
- package/dist/luaObfuscator/compiler.js +1 -1
- package/dist/luaObfuscator/constantArray.js +1 -1
- package/dist/luaObfuscator/flatten.js +1 -1
- package/dist/luaObfuscator/index.js +1 -1
- package/dist/luaObfuscator/lexer.js +10 -10
- package/dist/luaObfuscator/minify.js +1 -1
- package/dist/luaObfuscator/opcodes.js +1 -1
- package/dist/luaObfuscator/parser.js +1 -1
- package/dist/luaObfuscator/rename.js +1 -1
- package/dist/luaObfuscator/scope.js +1 -1
- package/dist/luaObfuscator/strings.js +1 -1
- package/dist/luaObfuscator/visit.js +1 -1
- package/docs/AGENTS.md +18 -14
- package/docs/SKILL.md +18 -12
- package/docs/mcp-agent-description.md +15 -10
- package/package.json +2 -1
package/dist/build.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of N(e))!z.call(t,s)&&s!==o&&J(t,s,{get:()=>e[s],enumerable:!(i=$(e,s))||i.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,i){i===void 0&&(i=o);var s=Object.getOwnPropertyDescriptor(e,o);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,i,s)}):(function(t,e,o,i){i===void 0&&(i=o),t[i]=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 i=[];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(i[i.length]=s);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var o={};if(e!=null)for(var i=t(e),s=0;s<i.length;s++)i[s]!=="default"&&K(o,e,i[s]);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"),r=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}}),i=r.createWriteStream(e);return new Promise((s,a)=>{o.directory(t,!1).on("error",c=>a(c)).pipe(i),i.on("close",()=>s()),o.finalize()})}function I(t){const e=n.join(t,"node_modules","typescript","lib","tsc.js");return r.pathExistsSync(e)?e:void 0}function Q(t){const e=n.join(t,"tsconfig.json");r.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));const i=n.join(t,"tsconfig.kuaijs-build.json");r.writeJsonSync(i,{extends:"./tsconfig.json",include:["env.d.ts","scripts/**/*"],exclude:["node_modules","dist","msbundle","ui","res"],compilerOptions:{noEmit:!0,allowJs:!0,checkJs:!0,skipLibCheck:!0}}),console.log("\u{1F50E} \u6B63\u5728\u8FDB\u884C\u7C7B\u578B\u6821\u9A8C...");try{const s=(0,P.spawnSync)(process.execPath,[o,"--noEmit","--pretty","-p",i],{cwd:t,stdio:"inherit"});s.status!==0&&(console.error("\u274C \u7C7B\u578B\u6821\u9A8C\u5931\u8D25"),process.exit(s.status??1))}finally{r.removeSync(i)}console.log("\u2705 \u7C7B\u578B\u6821\u9A8C\u901A\u8FC7")}async function U(t,e){const o=[];async function i(s){const a=await r.readdir(s,{withFileTypes:!0});for(const c of a){const f=n.resolve(s,c.name);c.isDirectory()?await i(f):c.isFile()&&(/^main\.(js|ts)$/.test(c.name)||/_thread\.(js|ts)$/.test(c.name))&&o.push(n.relative(e,f))}}return await i(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"}),i=(o.stdout||o.stderr||"").trim();if(i&&/Python\s+3\.14(\.\d+)?/i.test(i))return{ok:!0,path:e.cmd,version:i}}catch{}return{ok:!1}}async function X(t){async function e(o){const i=await r.readdir(o,{withFileTypes:!0});for(const s of i){const a=n.join(o,s.name);if(s.isDirectory())if(s.name==="__pycache__"){const c=await r.readdir(a,{withFileTypes:!0});for(const f of c){const S=n.join(a,f.name);if(f.isFile()&&f.name.endsWith(".cpython-314.pyc")){const O=n.dirname(a),b=f.name.replace(/\.cpython-314\.pyc$/,".pyc"),w=n.join(O,b);await r.move(S,w,{overwrite:!0})}}try{await r.remove(a)}catch{}}else await e(a);else if(s.isFile())if(s.name.endsWith(".cpython-314.pyc")){const c=a.replace(".cpython-314.pyc",".pyc");await r.move(a,c,{overwrite:!0})}else s.name.endsWith(".py")&&await r.remove(a)}}await e(t)}const Y=["Minify","Weak","Medium","Strong"];async function Z(t){const e=n.join(t,"obfuscator.json");if(!await r.pathExists(e))return{enabled:!0,preset:"Medium",bundle:!0};try{const o=await r.readJSON(e),i=o?.enabled!==!1,s=o?.bundle!==!1,a=k(o?.preset);return{enabled:i,preset:a,bundle:s}}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=>r.pathExistsSync(o))}const te=async(t=!0,e)=>{const o=n.join(e,"scripts"),i=await r.pathExists(n.join(o,"main.js"))||await r.pathExists(n.join(o,"main.ts")),s=await r.pathExists(n.join(o,"main.py")),a=await r.pathExists(n.join(o,"main.lua"));if(i){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 r.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 r.readJSON(u),m=j.scriptProtect===!0,{enabled:_,scriptProtect:y,...p}=j,d=n.join(e,t?"dist":"msbundle"),h=await U(o,o);await r.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 c=n.join(e,"msbundle");if(await r.ensureDir(c),(s||a)&&await r.copy(n.join(e,"scripts"),n.join(c,"scripts")),s){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:c});u.status===0?(console.log("\u2705 \u6210\u529F\u7F16\u8BD1\u6240\u6709 Python \u6587\u4EF6"),await X(n.join(c,"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(a){const l=await Z(e),u=n.join(c,"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 r.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 r.pathExists(g)&&(await r.remove(y),await r.move(g,y,{overwrite:!0}))}console.log("\u2705 Lua \u6DF7\u6DC6\u5B8C\u6210")}}await r.copy(n.join(e,"res"),n.join(c,"res")),await r.copy(n.join(e,"ui"),n.join(c,"ui"));for(const l of["logo.jpg","logo.png"]){const u=n.join(e,l);await r.pathExists(u)&&await r.copy(u,n.join(c,l))}const f=n.join(e,"dist"),S=n.join(e,"package.json"),O=n.join(c,"package.json"),b=await r.readJSON(S);delete b.scripts,delete b.devDependencies,delete b.dependencies,await r.writeJSON(O,b,{spaces:2}),await r.emptyDir(f);const w=n.join(f,"ms.zip"),D=n.join(f,"ms.msbundle");await R(c,w),await r.rename(w,D),await r.remove(c)};exports.buildAll=te;
|
|
1
|
+
"use strict";var C=Object.create;var M=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var W=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of q(e))!z.call(t,s)&&s!==o&&M(t,s,{get:()=>e[s],enumerable:!(r=F(e,s))||r.enumerable});return t};var K=(t,e,o)=>(o=t!=null?C(N(t)):{},W(e||!t||!t.__esModule?M(o,"default",{value:t,enumerable:!0}):o,t));var T=exports&&exports.__createBinding||(Object.create?(function(t,e,o,r){r===void 0&&(r=o);var s=Object.getOwnPropertyDescriptor(e,o);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,r,s)}):(function(t,e,o,r){r===void 0&&(r=o),t[r]=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}),E=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(o){var r=[];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(r[r.length]=s);return r},t(e)};return function(e){if(e&&e.__esModule)return e;var o={};if(e!=null)for(var r=t(e),s=0;s<r.length;s++)r[s]!=="default"&&T(o,e,r[s]);return A(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 B=L(require("archiver")),g=require("child_process"),i=E(require("fs-extra")),G=require("module"),P=E(require("os")),n=E(require("path")),H=require("./stopGuardPlugin"),R=require("./luaBundle"),J=require("./scriptProtect"),I=L(require("vite-plugin-bundle-obfuscator"));async function V(t,e){const o=(0,B.default)("zip",{zlib:{level:9}}),r=i.createWriteStream(e);return new Promise((s,c)=>{o.directory(t,!1).on("error",a=>c(a)).pipe(r),r.on("close",()=>s()),o.finalize()})}function Q(t){const e=n.join(t,"node_modules","typescript","lib","tsc.js");return i.pathExistsSync(e)?e:void 0}function U(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=Q(t);o||(console.error("\u274C \u672A\u627E\u5230 typescript\uFF0C\u8BF7\u5B89\u88C5\u540E\u91CD\u8BD5"),process.exit(1));const r=n.join(P.tmpdir(),`kuaijs-tsconfig-${process.pid}.json`),s=c=>c.replace(/\\/g,"/");i.writeJsonSync(r,{extends:s(e),include:[s(n.join(t,"env.d.ts")),s(n.join(t,"scripts/**/*"))],exclude:["node_modules","dist","msbundle","ui","res"].map(c=>s(n.join(t,c))),compilerOptions:{noEmit:!0,allowJs:!0,checkJs:!0,skipLibCheck:!0}}),console.log("\u{1F50E} \u6B63\u5728\u8FDB\u884C\u7C7B\u578B\u6821\u9A8C...");try{const c=(0,g.spawnSync)(process.execPath,[o,"--noEmit","--pretty","-p",r],{cwd:t,stdio:"inherit"});c.status!==0&&(console.error("\u274C \u7C7B\u578B\u6821\u9A8C\u5931\u8D25"),process.exit(c.status??1))}finally{i.removeSync(r)}console.log("\u2705 \u7C7B\u578B\u6821\u9A8C\u901A\u8FC7")}async function X(t,e){const o=[];async function r(s){const c=await i.readdir(s,{withFileTypes:!0});for(const a of c){const p=n.resolve(s,a.name);a.isDirectory()?await r(p):a.isFile()&&(/^main\.(js|ts)$/.test(a.name)||/_thread\.(js|ts)$/.test(a.name))&&o.push(n.relative(e,p))}}return await r(t),o}function $(){const t=[{cmd:n.join(P.homedir(),".KuaiJSDevloper","python","python.exe"),args:["--version"]},{cmd:n.join(P.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,g.spawnSync)(e.cmd,e.args,{encoding:"utf8"}),r=(o.stdout||o.stderr||"").trim();if(r&&/Python\s+3\.14(\.\d+)?/i.test(r))return{ok:!0,path:e.cmd,version:r}}catch{}return{ok:!1}}function Y(t){const e=[];try{e.push((0,G.createRequire)(__filename).resolve("pyright/index.js"))}catch{}return e.push(n.resolve(__dirname,"..","node_modules","pyright","index.js"),n.join(t,"node_modules","pyright","index.js"),n.join(t,"node_modules","ms-vite-plugin","node_modules","pyright","index.js")),e.find(o=>i.pathExistsSync(o))}function Z(t){const e=$();if(!e.ok){console.warn("\u26A0\uFE0F \u672A\u68C0\u6D4B\u5230 Python 3.14\uFF0C\u5DF2\u8DF3\u8FC7\u7C7B\u578B\u6821\u9A8C");return}const o=Y(t);o||(console.error("\u274C \u672A\u627E\u5230 pyright\uFF0C\u8BF7\u91CD\u88C5 ms-vite-plugin \u540E\u91CD\u8BD5"),process.exit(1)),(0,g.spawnSync)(e.path,["-c","import kuaijs"],{encoding:"utf8"}).status!==0&&(console.error(`\u274C \u672A\u627E\u5230 kuaijs \u7C7B\u578B\u5E93\uFF0C\u8BF7\u6267\u884C: ${e.path} -m pip install kuaijs-ios`),process.exit(1));const s=n.join(P.tmpdir(),`kuaijs-pyrightconfig-${process.pid}.json`);i.writeJsonSync(s,{pythonVersion:"3.14",typeCheckingMode:"basic",reportMissingImports:"warning",reportMissingModuleSource:"none"}),console.log("\u{1F50E} \u6B63\u5728\u8FDB\u884C\u7C7B\u578B\u6821\u9A8C...");try{const c=(0,g.spawnSync)(process.execPath,[o,"--project",s,"--pythonpath",e.path,n.join(t,"scripts")],{cwd:t,stdio:"inherit"});c.status!==0&&(console.error("\u274C \u7C7B\u578B\u6821\u9A8C\u5931\u8D25"),process.exit(c.status??1))}finally{i.removeSync(s)}console.log("\u2705 \u7C7B\u578B\u6821\u9A8C\u901A\u8FC7")}async function k(t){async function e(o){const r=await i.readdir(o,{withFileTypes:!0});for(const s of r){const c=n.join(o,s.name);if(s.isDirectory())if(s.name==="__pycache__"){const a=await i.readdir(c,{withFileTypes:!0});for(const p of a){const x=n.join(c,p.name);if(p.isFile()&&p.name.endsWith(".cpython-314.pyc")){const O=n.dirname(c),h=p.name.replace(/\.cpython-314\.pyc$/,".pyc"),_=n.join(O,h);await i.move(x,_,{overwrite:!0})}}try{await i.remove(c)}catch{}}else await e(c);else if(s.isFile())if(s.name.endsWith(".cpython-314.pyc")){const a=c.replace(".cpython-314.pyc",".pyc");await i.move(c,a,{overwrite:!0})}else s.name.endsWith(".py")&&await i.remove(c)}}await e(t)}const ee=["Minify","Weak","Medium","Strong"];async function te(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),r=o?.enabled!==!1,s=o?.bundle!==!1,c=oe(o?.preset);return{enabled:r,preset:c,bundle:s}}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 oe(t){if(typeof t!="string")return"Medium";const e=ee.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 ne(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 se=async(t=!0,e)=>{const o=n.join(e,"scripts"),r=await i.pathExists(n.join(o,"main.js"))||await i.pathExists(n.join(o,"main.ts")),s=await i.pathExists(n.join(o,"main.py")),c=await i.pathExists(n.join(o,"main.lua"));if(r){console.log("\u{1F680} \u5F00\u59CB\u6784\u5EFAJavaScript\u9879\u76EE..."),U(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 b=await i.readJSON(u),y=b.scriptProtect===!0,{enabled:v,scriptProtect:m,...f}=b,d=n.join(e,t?"dist":"msbundle"),j=await X(o,o);await i.remove(d);const w=!t&&y?(0,J.createScriptProtectHelpers)():[];!t&&y&&console.log("\u{1F510} \u5DF2\u542F\u7528 JS \u539F\u751F\u4FDD\u62A4\uFF08scriptProtect=true\uFF09");for(const S of j)await l({root:e,build:{lib:{entry:{[n.basename(S,n.extname(S))]:`./scripts/${S}`},fileName:()=>S.replace(/\.ts$/,".js"),formats:["iife"],name:"KuaiJS"},outDir:t?"dist/scripts":"msbundle/scripts",emptyOutDir:!1,sourcemap:t,minify:!t,target:"safari15"},plugins:[(0,H.createStopGuardPlugin)(),...t?[]:[...y?[(0,J.createScriptProtectPlugin)(w)]:[],v?(0,I.default)({autoExcludeNodeModules:!0,threadPool:!0,options:{...f,target:"browser",debugProtection:!1,disableConsoleOutput:!1,domainLock:[],selfDefending:!1,renameGlobals:!1,renameProperties:!1,reservedNames:[...f.reservedNames||[],...w]}}):[],...y?[(0,J.createKjstEmbedPlugin)()]:[]]]})}if(s&&(console.log("\u{1F680} \u5F00\u59CB\u6784\u5EFAPython\u9879\u76EE..."),Z(e)),t)return;const a=n.join(e,"msbundle");if(await i.ensureDir(a),(s||c)&&await i.copy(n.join(e,"scripts"),n.join(a,"scripts")),s){const l=$();if(l.ok){console.log(`\u2705 \u68C0\u6D4B\u5230 ${l.version} (${l.path})`);const u=(0,g.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 k(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 te(e),u=n.join(a,"scripts");if(l.bundle?await(0,R.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 b=[],y=async m=>{const f=await i.readdir(m,{withFileTypes:!0});for(const d of f){const j=n.join(m,d.name);d.isDirectory()?await y(j):d.isFile()&&d.name.endsWith(".lua")&&b.push(j)}};await y(u);const v=ne(e);v||(console.error("\u274C \u672A\u627E\u5230 @gamely/prometheus-cli\uFF0C\u65E0\u6CD5\u6DF7\u6DC6 Lua"),process.exit(1));for(const m of b){const f=n.relative(u,m);console.log(`\u{1F6E0}\uFE0F \u6DF7\u6DC6 Lua: ${f} (preset=${l.preset})`);const d=(0,g.spawnSync)(process.execPath,[v,f,"--preset",l.preset],{cwd:u,encoding:"utf8"});d.status!==0&&(console.error("\u274C \u6DF7\u6DC6 Lua \u5931\u8D25:",f),console.error(d.stderr||d.stdout||""),process.exit(1));const j=f.replace(/\.lua$/,".obfuscated.lua"),w=n.join(u,j);await i.pathExists(w)&&(await i.remove(m),await i.move(w,m,{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 p=n.join(e,"dist"),x=n.join(e,"package.json"),O=n.join(a,"package.json"),h=await i.readJSON(x);delete h.scripts,delete h.devDependencies,delete h.dependencies,await i.writeJSON(O,h,{spaces:2}),await i.emptyDir(p);const _=n.join(p,"ms.zip"),D=n.join(p,"ms.msbundle");await V(a,_),await i.rename(_,D),await i.remove(a)};exports.buildAll=se;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addVararg=
|
|
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,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.applyAntiTamper=s;const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.applyAntiTamper=s;const o=require("./parser");function r(n){return(n>>>0)%9e3+100}function s(n,c){const a=c>>>0,l=r(a),e=a%17+3,t=l*e,d=`
|
|
2
2
|
do
|
|
3
3
|
local valid = true
|
|
4
4
|
local acc = ${l}
|
|
@@ -23,4 +23,4 @@ do
|
|
|
23
23
|
error("Tamper Detected!")
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
|
-
`,i=(0,
|
|
26
|
+
`,i=(0,o.parseLua)(d);n.body.unshift(...i.body)}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createFoldMixParams=m,exports.foldEncrypt=q,exports.foldDecrypt=g,exports.emitFoldDecoderLua=b;const d=35184372088832n,i=[3,5,6,7,10,12,14,19,20,24];function m(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createFoldMixParams=m,exports.foldEncrypt=q,exports.foldDecrypt=g,exports.emitFoldDecoderLua=b;const d=35184372088832n,i=[3,5,6,7,10,12,14,19,20,24];function m(e){const n=e>>>0||1;return{mul45:n%15*4+1,add45:n%99991*2+1,mul8:i[n%i.length],secret8:n%256}}function f(e,n){e.p=(e.p*BigInt(n.mul45)+BigInt(n.add45))%d;do e.q=e.q*n.mul8%257;while(e.q===1);const l=Number(e.p%256n),o=Number(e.p/256n%256n),t=Number(e.p/65536n%256n);return(l+o*(e.q%13)+t+e.q)%256}function p(e,n){return{p:BigInt(n>>>0)%d,q:(n>>>0)%255+2}}function h(e){const n=[];for(let l=0;l<e.length;l+=1){const o=e.charCodeAt(l);if(o<=255)n.push(o);else{const t=Buffer.from(e[l],"utf8");for(const c of t)n.push(c)}}return Buffer.from(n)}function q(e,n,l){const o=h(e),t=p(n,l);let c=n.secret8,r="";for(let u=0;u<o.length;u+=1){const a=f(t,n),s=o[u];r+=String.fromCharCode((s-a-c+512)%256),c=s}return r}function g(e,n,l){const o=p(n,l);let t=n.secret8;const c=Buffer.alloc(e.length);for(let r=0;r<e.length;r+=1){const u=f(o,n),a=(e.charCodeAt(r)+u+t)%256;c[r]=a,t=a}return c.toString("latin1")}function b(e,n){return`local ${n}
|
|
2
2
|
do
|
|
3
|
-
local mul45=${
|
|
4
|
-
local add45=${
|
|
5
|
-
local mul8=${
|
|
6
|
-
local secret8=${
|
|
3
|
+
local mul45=${e.mul45}
|
|
4
|
+
local add45=${e.add45}
|
|
5
|
+
local mul8=${e.mul8}
|
|
6
|
+
local secret8=${e.secret8}
|
|
7
7
|
local cache={}
|
|
8
|
-
${
|
|
8
|
+
${n}=function(s,seed)
|
|
9
9
|
local hit=cache[seed]
|
|
10
10
|
if hit then return hit end
|
|
11
11
|
local p=seed%35184372088832
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileChunk=P;class O{constructor(){Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"ops",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"consts",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"protos",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"upvals",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"numparams",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"isVararg",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"maxStack",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"top",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(this,"frames",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"labels",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"gotos",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"breaks",{enumerable:!0,configurable:!0,writable:!0,value:[]})}emit(n,t=0,o=0,s=0){return this.ops.push(n),this.code.push([0,t,o,s]),this.code.length-1}patch(n,t,o,s){const a=this.code[n];t!==void 0&&(a[1]=t),o!==void 0&&(a[2]=o),s!==void 0&&(a[3]=s)}kNil(){return this.intern({t:"nil"})}kBool(n){return this.intern({t:"bool",v:n})}kNum(n,t){return this.intern({t:"num",v:n,raw:t})}kStr(n){return this.intern({t:"str",v:n})}intern(n){for(let t=0;t<this.consts.length;t+=1){const o=this.consts[t];if(o.t===n.t&&(o.t==="nil"||o.t==="bool"&&n.t==="bool"&&o.v===n.v||o.t==="num"&&n.t==="num"&&o.v===n.v||o.t==="str"&&n.t==="str"&&o.v===n.v))return t+1}return this.consts.push(n),this.consts.length}alloc(n=1){const t=this.top;return this.top+=n,this.top-1>this.maxStack&&(this.maxStack=this.top-1),t}freeTo(n){this.top=n}pushFrame(){this.frames.push({locals:[],savedTop:this.top})}currentLocals(){return this.frames[this.frames.length-1]?.locals??[]}bind(n,t=!1){const o=this.alloc(1);return this.currentLocals().push({name:n,reg:o,close:t}),o}findLocal(n){for(let t=this.frames.length-1;t>=0;t-=1){const o=this.frames[t].locals;for(let s=o.length-1;s>=0;s-=1)if(o[s].name===n)return o[s].reg}}findUpval(n){for(let s=0;s<this.upvals.length;s+=1)if(this.upvals[s].name===n)return s+1;if(!this.parent)return;const t=this.parent.findLocal(n);if(t!==void 0)return this.upvals.push({name:n,inStack:!0,index:t}),this.upvals.length;const o=this.parent.findUpval(n);if(o!==void 0)return this.upvals.push({name:n,inStack:!1,index:o}),this.upvals.length}finish(){for(const n of this.gotos){const t=this.labels.get(n.name);if(t===void 0)throw new Error(`goto \u672A\u5B9A\u4E49\u6807\u7B7E ::${n.name}::`);this.patch(n.pc,0,t-(n.pc+1))}return{code:this.code,ops:this.ops,consts:this.consts,protos:this.protos,upvals:this.upvals,numparams:this.numparams,isVararg:this.isVararg,maxStack:Math.max(this.maxStack,this.numparams,1)}}}const k={"+":"ADD","-":"SUB","*":"MUL","/":"DIV","//":"IDIV","%":"MOD","^":"POW","&":"BAND","|":"BOR","~":"BXOR","<<":"SHL",">>":"SHR","..":"CONCAT"},A={"-":"UNM","~":"BNOT",not:"NOT","#":"LEN"};function P(e){const n=new O;return n.isVararg=!0,n.pushFrame(),u(n,e.body),n.emit("RETURN",1,0),n.finish()}function d(e,n){const t=new O;t.parent=e,t.numparams=n.params.length,t.isVararg=n.vararg,t.pushFrame();for(const o of n.params)t.bind(o);return u(t,n.body.body),t.emit("RETURN",1,0),e.protos.push(t.finish()),e.protos.length}function u(e,n){for(const t of n)B(e,t)}function p(e,n){for(const t of n.locals)e.emit("CLOSE",t.reg);e.freeTo(n.savedTop)}function B(e,n){switch(n.type){case"EmptyStat":return;case"BreakStat":{if(e.breaks.length===0)throw new Error("break \u51FA\u73B0\u5728\u5FAA\u73AF\u5916");const t=e.emit("JMP",0,0);e.breaks[e.breaks.length-1].push(t);return}case"GotoStat":{const t=e.emit("JMP",0,0);e.gotos.push({name:n.name,pc:t});return}case"LabelStat":e.labels.set(n.name,e.code.length);return;case"DoStat":{e.pushFrame(),u(e,n.body.body),p(e,e.frames.pop());return}case"WhileStat":{const t=e.code.length,o=r(e,n.cond);e.emit("TEST",o,0,0);const s=e.emit("JMP",0,0);e.freeTo(o),e.breaks.push([]),e.pushFrame(),u(e,n.body.body),p(e,e.frames.pop()),e.emit("JMP",0,t-(e.code.length+1)),e.patch(s,0,e.code.length-(s+1)),f(e,e.breaks.pop(),e.code.length);return}case"RepeatStat":{const t=e.code.length;e.breaks.push([]),e.pushFrame(),u(e,n.body.body);const o=r(e,n.cond);e.emit("TEST",o,0,0),e.emit("JMP",0,t-(e.code.length+1)),p(e,e.frames.pop()),f(e,e.breaks.pop(),e.code.length);return}case"IfStat":{const t=[];for(let o=0;o<n.clauses.length;o+=1){const s=r(e,n.clauses[o].cond);e.emit("TEST",s,0,0);const a=e.emit("JMP",0,0);e.freeTo(s),e.pushFrame(),u(e,n.clauses[o].body.body),p(e,e.frames.pop()),(o<n.clauses.length-1||n.elseBody)&&t.push(e.emit("JMP",0,0)),e.patch(a,0,e.code.length-(a+1))}n.elseBody&&(e.pushFrame(),u(e,n.elseBody.body),p(e,e.frames.pop()));for(const o of t)e.patch(o,0,e.code.length-(o+1));return}case"ForNumStat":{const t=e.alloc(4);r(e,n.start,t),r(e,n.end,t+1),n.step?r(e,n.step,t+2):e.emit("LOADK",t+2,e.kNum(1,"1"));const o=e.emit("FORPREP",t,0);e.breaks.push([]),e.pushFrame();const s=e.bind(n.name);e.emit("MOVE",s,t+3),u(e,n.body.body),p(e,e.frames.pop());const a=e.emit("FORLOOP",t,0);e.patch(o,t,a-(o+1)),e.patch(a,t,o+1-(a+1)),f(e,e.breaks.pop(),e.code.length),e.freeTo(t);return}case"ForInStat":{const t=e.alloc(3);h(e,n.exps,t,3);const o=e.emit("TFORCALL",t,n.names.length),s=e.emit("TFORLOOP",t,0);e.breaks.push([]),e.pushFrame();for(let a=0;a<n.names.length;a+=1){const i=e.bind(n.names[a]);e.emit("MOVE",i,t+3+a)}u(e,n.body.body),p(e,e.frames.pop()),e.emit("JMP",0,o-(e.code.length+1)),e.patch(s,t,e.code.length-(s+1)),f(e,e.breaks.pop(),e.code.length),e.freeTo(t);return}case"FuncStat":{const t=d(e,n.func),o=e.alloc(1);e.emit("CLOSURE",o,t),w(e,n.name.base,n.name.fields,n.name.method,o),e.freeTo(o);return}case"LocalFuncStat":{const t=e.bind(n.name),o=d(e,n.func);e.emit("CLOSURE",t,o);return}case"LocalStat":{const t=n.names.length,o=[];if(n.exps&&n.exps.length>0){const s=e.top;h(e,n.exps,s,t);for(let a=0;a<t;a+=1){const i=e.bind(n.names[a].name,n.names[a].attr==="close");e.emit("MOVE",i,s+a),o.push(i)}e.freeTo(o[0]),e.top=o[t-1]+1}else for(const s of n.names){const a=e.bind(s.name,s.attr==="close");e.emit("LOADNIL",a),o.push(a)}return}case"AssignStat":{const t=e.top;h(e,n.exps,t,n.vars.length);for(let o=0;o<n.vars.length;o+=1)F(e,n.vars[o],t+o);e.freeTo(t);return}case"CallStat":{const t=e.top;r(e,n.exp,void 0,0),e.freeTo(t);return}case"ReturnStat":{if(n.exps.length===0){e.emit("RETURN",1,0);return}const t=e.top;h(e,n.exps,t,-1);const o=n.exps[n.exps.length-1],s=o.type==="CallExpr"||o.type==="MethodCallExpr"||o.type==="VarargExpr";e.emit("RETURN",t,s?-1:n.exps.length);return}}}function f(e,n,t){for(const o of n)e.patch(o,0,t-(o+1))}function w(e,n,t,o,s){if(t.length===0&&!o){S(e,n,s);return}let a=T(e,n);const i=o?[...t,o]:t;for(let c=0;c<i.length-1;c+=1){const l=e.alloc(1);e.emit("GETTABLE",l,a,-e.kStr(i[c])),a=l}e.emit("SETTABLE",a,-e.kStr(i[i.length-1]),s)}function S(e,n,t){const o=e.findLocal(n);if(o!==void 0){e.emit("MOVE",o,t);return}const s=e.findUpval(n);if(s!==void 0){e.emit("SETUPVAL",t,s);return}e.emit("SETGLOBAL",t,e.kStr(n))}function T(e,n,t){const o=t??e.alloc(1),s=e.findLocal(n);if(s!==void 0)return o!==s&&e.emit("MOVE",o,s),o;const a=e.findUpval(n);return a!==void 0?(e.emit("GETUPVAL",o,a),o):(e.emit("GETGLOBAL",o,e.kStr(n)),o)}function F(e,n,t){if(n.type==="NameExpr"){S(e,n.name,t);return}if(n.type==="MemberExpr"){const o=r(e,n.object);e.emit("SETTABLE",o,-e.kStr(n.field),t);return}if(n.type==="IndexExpr"){const o=r(e,n.object),s=r(e,n.index);e.emit("SETTABLE",o,s,t);return}throw new Error("\u975E\u6CD5\u8D4B\u503C\u5DE6\u503C")}function r(e,n,t,o=1){const s=t??e.alloc(1);switch(n.type){case"NilLiteral":return e.emit("LOADNIL",s),s;case"BoolLiteral":return e.emit("LOADBOOL",s,n.value?1:0),s;case"NumberLiteral":return e.emit("LOADK",s,e.kNum(n.value,n.raw)),s;case"StringLiteral":return e.emit("LOADK",s,e.kStr(n.value)),s;case"VarargExpr":return e.emit("VARARG",s,o),s;case"NameExpr":return T(e,n.name,s);case"ParenExpr":return r(e,n.exp,s,1);case"UnaryExpr":{const a=r(e,n.arg);return e.emit(A[n.op],s,a),s}case"BinaryExpr":return M(e,n.op,n.left,n.right,s);case"FuncExpr":{const a=d(e,n);return e.emit("CLOSURE",s,a),s}case"TableExpr":return R(e,n.fields,s);case"IndexExpr":{const a=r(e,n.object),i=r(e,n.index);return e.emit("GETTABLE",s,a,i),s}case"MemberExpr":{const a=r(e,n.object);return e.emit("GETTABLE",s,a,-e.kStr(n.field)),s}case"CallExpr":return y(e,n.callee,n.args,s,o,!1);case"MethodCallExpr":return y(e,n.object,n.args,s,o,n.method);default:throw new Error(`\u4E0D\u652F\u6301\u7684\u8868\u8FBE\u5F0F ${n.type}`)}}function M(e,n,t,o,s){if(n==="and"||n==="or"){r(e,t,s),e.emit("TEST",s,0,n==="and"?0:1);const l=e.emit("JMP",0,0);return r(e,o,s),e.patch(l,0,e.code.length-(l+1)),s}if(n==="=="||n==="~="||n==="<"||n===">"||n==="<="||n===">="){const l=r(e,t),b=r(e,o);let m="EQ",g=l,E=b;n==="<"||n===">="?m="LT":n==="<="||n===">"?m="LE":m="EQ",(n===">"||n===">=")&&(g=b,E=l);const x=n==="~=";e.emit(m,g,E,x?1:0);const L=e.emit("JMP",0,0);e.emit("LOADBOOL",s,1);const v=e.emit("JMP",0,0);return e.patch(L,0,e.code.length-(L+1)),e.emit("LOADBOOL",s,0),e.patch(v,0,e.code.length-(v+1)),s}const a=k[n];if(!a)throw new Error(`\u4E0D\u652F\u6301\u7684\u8FD0\u7B97\u7B26 ${n}`);const i=r(e,t),c=r(e,o);return e.emit(a,s,i,c),s}function N(e){return e.type==="CallExpr"||e.type==="MethodCallExpr"||e.type==="VarargExpr"}function y(e,n,t,o,s,a){const i=o,c=t.length>0&&N(t[t.length-1]);if(a){const l=r(e,n,i);return e.emit("SELF",i,l,-e.kStr(a)),h(e,t,i+2,-1),e.emit("CALL",i,c?-1:t.length+1,s),i}return r(e,n,i),h(e,t,i+1,-1),e.emit("CALL",i,c?-1:t.length,s),i}function h(e,n,t,o){const s=o>0?o:Math.max(n.length,1);if(e.top<t+s&&(e.top=t+s,e.top-1>e.maxStack&&(e.maxStack=e.top-1)),n.length===0){if(o>0)for(let a=0;a<o;a+=1)e.emit("LOADNIL",t+a);return}for(let a=0;a<n.length;a+=1){const i=a===n.length-1,c=i&&(o<0||o>n.length)?o===-1?-1:o-a:1;r(e,n[a],t+a,i?c:1)}if(o>n.length)for(let a=n.length;a<o;a+=1)e.emit("LOADNIL",t+a)}function R(e,n,t){e.emit("NEWTABLE",t);const o=[];for(const s of n)if(s.kind==="list")o.push(s.value);else if(s.kind==="name"){const a=r(e,s.value);e.emit("SETTABLE",t,-e.kStr(s.key),a)}else{const a=r(e,s.key),i=r(e,s.value);e.emit("SETTABLE",t,a,i)}if(o.length>0){const s=e.top;h(e,o,s,-1),e.emit("SETLIST",t,s,o.length),e.freeTo(s)}return t}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.compileChunk=P;class O{constructor(){Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"ops",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"consts",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"protos",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"upvals",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"numparams",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"isVararg",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"maxStack",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"top",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(this,"frames",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"labels",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"gotos",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"breaks",{enumerable:!0,configurable:!0,writable:!0,value:[]})}emit(r,e=0,o=0,s=0){return this.ops.push(r),this.code.push([0,e,o,s]),this.code.length-1}patch(r,e,o,s){const a=this.code[r];e!==void 0&&(a[1]=e),o!==void 0&&(a[2]=o),s!==void 0&&(a[3]=s)}kNil(){return this.intern({t:"nil"})}kBool(r){return this.intern({t:"bool",v:r})}kNum(r,e){return this.intern({t:"num",v:r,raw:e})}kStr(r){return this.intern({t:"str",v:r})}intern(r){for(let e=0;e<this.consts.length;e+=1){const o=this.consts[e];if(o.t===r.t&&(o.t==="nil"||o.t==="bool"&&r.t==="bool"&&o.v===r.v||o.t==="num"&&r.t==="num"&&o.v===r.v||o.t==="str"&&r.t==="str"&&o.v===r.v))return e+1}return this.consts.push(r),this.consts.length}alloc(r=1){const e=this.top;return this.top+=r,this.top-1>this.maxStack&&(this.maxStack=this.top-1),e}freeTo(r){this.top=r}pushFrame(){this.frames.push({locals:[],savedTop:this.top})}currentLocals(){return this.frames[this.frames.length-1]?.locals??[]}bind(r,e=!1){const o=this.alloc(1);return this.currentLocals().push({name:r,reg:o,close:e}),o}findLocal(r){for(let e=this.frames.length-1;e>=0;e-=1){const o=this.frames[e].locals;for(let s=o.length-1;s>=0;s-=1)if(o[s].name===r)return o[s].reg}}findUpval(r){for(let s=0;s<this.upvals.length;s+=1)if(this.upvals[s].name===r)return s+1;if(!this.parent)return;const e=this.parent.findLocal(r);if(e!==void 0)return this.upvals.push({name:r,inStack:!0,index:e}),this.upvals.length;const o=this.parent.findUpval(r);if(o!==void 0)return this.upvals.push({name:r,inStack:!1,index:o}),this.upvals.length}finish(){for(const r of this.gotos){const e=this.labels.get(r.name);if(e===void 0)throw new Error(`goto \u672A\u5B9A\u4E49\u6807\u7B7E ::${r.name}::`);this.patch(r.pc,0,e-(r.pc+1))}return{code:this.code,ops:this.ops,consts:this.consts,protos:this.protos,upvals:this.upvals,numparams:this.numparams,isVararg:this.isVararg,maxStack:Math.max(this.maxStack,this.numparams,1)}}}const k={"+":"ADD","-":"SUB","*":"MUL","/":"DIV","//":"IDIV","%":"MOD","^":"POW","&":"BAND","|":"BOR","~":"BXOR","<<":"SHL",">>":"SHR","..":"CONCAT"},A={"-":"UNM","~":"BNOT",not:"NOT","#":"LEN"};function P(t){const r=new O;return r.isVararg=!0,r.pushFrame(),u(r,t.body),r.emit("RETURN",1,0),r.finish()}function d(t,r){const e=new O;e.parent=t,e.numparams=r.params.length,e.isVararg=r.vararg,e.pushFrame();for(const o of r.params)e.bind(o);return u(e,r.body.body),e.emit("RETURN",1,0),t.protos.push(e.finish()),t.protos.length}function u(t,r){for(const e of r)B(t,e)}function p(t,r){for(const e of r.locals)t.emit("CLOSE",e.reg);t.freeTo(r.savedTop)}function B(t,r){switch(r.type){case"EmptyStat":return;case"BreakStat":{if(t.breaks.length===0)throw new Error("break \u51FA\u73B0\u5728\u5FAA\u73AF\u5916");const e=t.emit("JMP",0,0);t.breaks[t.breaks.length-1].push(e);return}case"GotoStat":{const e=t.emit("JMP",0,0);t.gotos.push({name:r.name,pc:e});return}case"LabelStat":t.labels.set(r.name,t.code.length);return;case"DoStat":{t.pushFrame(),u(t,r.body.body),p(t,t.frames.pop());return}case"WhileStat":{const e=t.code.length,o=n(t,r.cond);t.emit("TEST",o,0,0);const s=t.emit("JMP",0,0);t.freeTo(o),t.breaks.push([]),t.pushFrame(),u(t,r.body.body),p(t,t.frames.pop()),t.emit("JMP",0,e-(t.code.length+1)),t.patch(s,0,t.code.length-(s+1)),f(t,t.breaks.pop(),t.code.length);return}case"RepeatStat":{const e=t.code.length;t.breaks.push([]),t.pushFrame(),u(t,r.body.body);const o=n(t,r.cond);t.emit("TEST",o,0,0),t.emit("JMP",0,e-(t.code.length+1)),p(t,t.frames.pop()),f(t,t.breaks.pop(),t.code.length);return}case"IfStat":{const e=[];for(let o=0;o<r.clauses.length;o+=1){const s=n(t,r.clauses[o].cond);t.emit("TEST",s,0,0);const a=t.emit("JMP",0,0);t.freeTo(s),t.pushFrame(),u(t,r.clauses[o].body.body),p(t,t.frames.pop()),(o<r.clauses.length-1||r.elseBody)&&e.push(t.emit("JMP",0,0)),t.patch(a,0,t.code.length-(a+1))}r.elseBody&&(t.pushFrame(),u(t,r.elseBody.body),p(t,t.frames.pop()));for(const o of e)t.patch(o,0,t.code.length-(o+1));return}case"ForNumStat":{const e=t.alloc(4);n(t,r.start,e),n(t,r.end,e+1),r.step?n(t,r.step,e+2):t.emit("LOADK",e+2,t.kNum(1,"1"));const o=t.emit("FORPREP",e,0);t.breaks.push([]),t.pushFrame();const s=t.bind(r.name);t.emit("MOVE",s,e+3),u(t,r.body.body),p(t,t.frames.pop());const a=t.emit("FORLOOP",e,0);t.patch(o,e,a-(o+1)),t.patch(a,e,o+1-(a+1)),f(t,t.breaks.pop(),t.code.length),t.freeTo(e);return}case"ForInStat":{const e=t.alloc(3);h(t,r.exps,e,3);const o=t.emit("TFORCALL",e,r.names.length),s=t.emit("TFORLOOP",e,0);t.breaks.push([]),t.pushFrame();for(let a=0;a<r.names.length;a+=1){const i=t.bind(r.names[a]);t.emit("MOVE",i,e+3+a)}u(t,r.body.body),p(t,t.frames.pop()),t.emit("JMP",0,o-(t.code.length+1)),t.patch(s,e,t.code.length-(s+1)),f(t,t.breaks.pop(),t.code.length),t.freeTo(e);return}case"FuncStat":{const e=d(t,r.func),o=t.alloc(1);t.emit("CLOSURE",o,e),w(t,r.name.base,r.name.fields,r.name.method,o),t.freeTo(o);return}case"LocalFuncStat":{const e=t.bind(r.name),o=d(t,r.func);t.emit("CLOSURE",e,o);return}case"LocalStat":{const e=r.names.length,o=[];if(r.exps&&r.exps.length>0){const s=t.top;h(t,r.exps,s,e);for(let a=0;a<e;a+=1){const i=t.bind(r.names[a].name,r.names[a].attr==="close");t.emit("MOVE",i,s+a),o.push(i)}t.freeTo(o[0]),t.top=o[e-1]+1}else for(const s of r.names){const a=t.bind(s.name,s.attr==="close");t.emit("LOADNIL",a),o.push(a)}return}case"AssignStat":{const e=t.top;h(t,r.exps,e,r.vars.length);for(let o=0;o<r.vars.length;o+=1)F(t,r.vars[o],e+o);t.freeTo(e);return}case"CallStat":{const e=t.top;n(t,r.exp,void 0,0),t.freeTo(e);return}case"ReturnStat":{if(r.exps.length===0){t.emit("RETURN",1,0);return}const e=t.top;h(t,r.exps,e,-1);const o=r.exps[r.exps.length-1],s=o.type==="CallExpr"||o.type==="MethodCallExpr"||o.type==="VarargExpr";t.emit("RETURN",e,s?-1:r.exps.length);return}}}function f(t,r,e){for(const o of r)t.patch(o,0,e-(o+1))}function w(t,r,e,o,s){if(e.length===0&&!o){S(t,r,s);return}let a=T(t,r);const i=o?[...e,o]:e;for(let c=0;c<i.length-1;c+=1){const l=t.alloc(1);t.emit("GETTABLE",l,a,-t.kStr(i[c])),a=l}t.emit("SETTABLE",a,-t.kStr(i[i.length-1]),s)}function S(t,r,e){const o=t.findLocal(r);if(o!==void 0){t.emit("MOVE",o,e);return}const s=t.findUpval(r);if(s!==void 0){t.emit("SETUPVAL",e,s);return}t.emit("SETGLOBAL",e,t.kStr(r))}function T(t,r,e){const o=e??t.alloc(1),s=t.findLocal(r);if(s!==void 0)return o!==s&&t.emit("MOVE",o,s),o;const a=t.findUpval(r);return a!==void 0?(t.emit("GETUPVAL",o,a),o):(t.emit("GETGLOBAL",o,t.kStr(r)),o)}function F(t,r,e){if(r.type==="NameExpr"){S(t,r.name,e);return}if(r.type==="MemberExpr"){const o=n(t,r.object);t.emit("SETTABLE",o,-t.kStr(r.field),e);return}if(r.type==="IndexExpr"){const o=n(t,r.object),s=n(t,r.index);t.emit("SETTABLE",o,s,e);return}throw new Error("\u975E\u6CD5\u8D4B\u503C\u5DE6\u503C")}function n(t,r,e,o=1){const s=e??t.alloc(1);switch(r.type){case"NilLiteral":return t.emit("LOADNIL",s),s;case"BoolLiteral":return t.emit("LOADBOOL",s,r.value?1:0),s;case"NumberLiteral":return t.emit("LOADK",s,t.kNum(r.value,r.raw)),s;case"StringLiteral":return t.emit("LOADK",s,t.kStr(r.value)),s;case"VarargExpr":return t.emit("VARARG",s,o),s;case"NameExpr":return T(t,r.name,s);case"ParenExpr":return n(t,r.exp,s,1);case"UnaryExpr":{const a=n(t,r.arg);return t.emit(A[r.op],s,a),s}case"BinaryExpr":return M(t,r.op,r.left,r.right,s);case"FuncExpr":{const a=d(t,r);return t.emit("CLOSURE",s,a),s}case"TableExpr":return R(t,r.fields,s);case"IndexExpr":{const a=n(t,r.object),i=n(t,r.index);return t.emit("GETTABLE",s,a,i),s}case"MemberExpr":{const a=n(t,r.object);return t.emit("GETTABLE",s,a,-t.kStr(r.field)),s}case"CallExpr":return y(t,r.callee,r.args,s,o,!1);case"MethodCallExpr":return y(t,r.object,r.args,s,o,r.method);default:throw new Error(`\u4E0D\u652F\u6301\u7684\u8868\u8FBE\u5F0F ${r.type}`)}}function M(t,r,e,o,s){if(r==="and"||r==="or"){n(t,e,s),t.emit("TEST",s,0,r==="and"?0:1);const l=t.emit("JMP",0,0);return n(t,o,s),t.patch(l,0,t.code.length-(l+1)),s}if(r==="=="||r==="~="||r==="<"||r===">"||r==="<="||r===">="){const l=n(t,e),b=n(t,o);let m="EQ",g=l,E=b;r==="<"||r===">="?m="LT":r==="<="||r===">"?m="LE":m="EQ",(r===">"||r===">=")&&(g=b,E=l);const x=r==="~=";t.emit(m,g,E,x?1:0);const L=t.emit("JMP",0,0);t.emit("LOADBOOL",s,1);const v=t.emit("JMP",0,0);return t.patch(L,0,t.code.length-(L+1)),t.emit("LOADBOOL",s,0),t.patch(v,0,t.code.length-(v+1)),s}const a=k[r];if(!a)throw new Error(`\u4E0D\u652F\u6301\u7684\u8FD0\u7B97\u7B26 ${r}`);const i=n(t,e),c=n(t,o);return t.emit(a,s,i,c),s}function N(t){return t.type==="CallExpr"||t.type==="MethodCallExpr"||t.type==="VarargExpr"}function y(t,r,e,o,s,a){const i=o,c=e.length>0&&N(e[e.length-1]);if(a){const l=n(t,r,i);return t.emit("SELF",i,l,-t.kStr(a)),h(t,e,i+2,-1),t.emit("CALL",i,c?-1:e.length+1,s),i}return n(t,r,i),h(t,e,i+1,-1),t.emit("CALL",i,c?-1:e.length,s),i}function h(t,r,e,o){const s=o>0?o:Math.max(r.length,1);if(t.top<e+s&&(t.top=e+s,t.top-1>t.maxStack&&(t.maxStack=t.top-1)),r.length===0){if(o>0)for(let a=0;a<o;a+=1)t.emit("LOADNIL",e+a);return}for(let a=0;a<r.length;a+=1){const i=a===r.length-1,c=i&&(o<0||o>r.length)?o===-1?-1:o-a:1;n(t,r[a],e+a,i?c:1)}if(o>r.length)for(let a=r.length;a<o;a+=1)t.emit("LOADNIL",e+a)}function R(t,r,e){t.emit("NEWTABLE",e);const o=[];for(const s of r)if(s.kind==="list")o.push(s.value);else if(s.kind==="name"){const a=n(t,s.value);t.emit("SETTABLE",e,-t.kStr(s.key),a)}else{const a=n(t,s.key),i=n(t,s.value);t.emit("SETTABLE",e,a,i)}if(o.length>0){const s=t.top;h(t,o,s,-1),t.emit("SETLIST",e,s,o.length),t.freeTo(s)}return e}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.applyConstantArray=h;const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.applyConstantArray=h;const i=require("./visit"),o="__C",y="__G";function g(l,s){const a=l.slice();let n=s>>>0||1;for(let r=a.length-1;r>0;r-=1){n=Math.imul(n,1664525)+1013904223>>>0;const t=n%(r+1),p=a[r];a[r]=a[t],a[t]=p}return a}function h(l,s,a){const n=[],r=new Set;if((0,i.mapChunk)(l,e=>(e.type==="StringLiteral"&&!r.has(e.value)&&(r.add(e.value),n.push(e.value)),e)),n.length===0)return;let t=a.shuffle?g(n,s):n.slice();const p=a.rotate?s%t.length:0;p>0&&(t=t.slice(p).concat(t.slice(0,p)));const c=new Map;for(let e=0;e<t.length;e+=1)c.set(t[e],e+1);(0,i.mapChunk)(l,e=>{if(e.type!=="StringLiteral")return e;const u=c.get(e.value);return u===void 0?e:{type:"CallExpr",callee:{type:"NameExpr",name:y},args:[{type:"NumberLiteral",raw:String(u),value:u}]}});const m=t.map(e=>({kind:"list",value:{type:"StringLiteral",value:e,encoded:!0}})),d={type:"LocalStat",names:[{name:o}],exps:[{type:"TableExpr",fields:m}]},f={type:"LocalFuncStat",name:y,func:{type:"FuncExpr",params:["i"],vararg:!1,body:{type:"Block",body:[{type:"ReturnStat",exps:[{type:"IndexExpr",object:{type:"NameExpr",name:o},index:{type:"NameExpr",name:"i"}}]}]}}};l.body.unshift(d,f)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.flattenControlFlow=C;function m(
|
|
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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createFoldMixParams=exports.foldEncrypt=exports.foldDecrypt=exports.LuaParseError=exports.LuaLexError=exports.luaObfuscatorPresets=void 0,exports.obfuscateLua=E;const l=require("./addVararg"),f=require("./antiTamper"),b=require("./compiler"),y=require("./constantArray"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createFoldMixParams=exports.foldEncrypt=exports.foldDecrypt=exports.LuaParseError=exports.LuaLexError=exports.luaObfuscatorPresets=void 0,exports.obfuscateLua=E;const l=require("./addVararg"),f=require("./antiTamper"),b=require("./compiler"),y=require("./constantArray"),u=require("./flatten"),c=require("./minify"),a=require("./numbers"),p=require("./parser"),m=require("./rename"),d=require("./splitStrings"),L=require("./vmEmit"),q=require("./wrapInFunction");exports.luaObfuscatorPresets=["Minify","Weak","Medium","Strong"];function P(n){let t=2166136261;for(let r=0;r<n.length;r+=1)t=Math.imul(t^n.charCodeAt(r),16777619);return t>>>0||1}function o(n){return(0,p.parseLua)((0,L.emitVm)((0,b.compileChunk)(n)))}function i(n,t,r){(0,y.applyConstantArray)(n,t,{shuffle:r.shuffle,rotate:r.shuffle}),r.numbersOnVm&&(0,a.numbersToExpressions)(n,(t^2654435769)>>>0);for(let e=0;e<r.wraps;e+=1)(0,q.wrapInFunction)(n);return(0,m.renameLocals)(n),(0,c.minifyLua)(n)}function E(n,t){const r=P(n);let e=(0,p.parseLua)(n);return(0,m.renameLocals)(e),t==="Minify"?(0,c.minifyLua)(e):t==="Weak"?((0,u.flattenControlFlow)(e,r),e=o(e),i(e,r,{shuffle:!1,wraps:1,numbersOnVm:!1})):t==="Medium"?((0,l.addVararg)(e),(0,d.splitStrings)(e,r),(0,a.numbersToExpressions)(e,r),(0,f.applyAntiTamper)(e,r),(0,u.flattenControlFlow)(e,r),e=o(e),i(e,r,{shuffle:!0,wraps:1,numbersOnVm:!0})):((0,l.addVararg)(e),(0,d.splitStrings)(e,(r^2135587861)>>>0),(0,a.numbersToExpressions)(e,r),(0,f.applyAntiTamper)(e,(r^2246822507)>>>0),(0,u.flattenControlFlow)(e,(r^2246822507)>>>0),e=o(e),i(e,r,{shuffle:!0,wraps:2,numbersOnVm:!0}))}var O=require("./lexer");Object.defineProperty(exports,"LuaLexError",{enumerable:!0,get:function(){return O.LuaLexError}});var g=require("./parser");Object.defineProperty(exports,"LuaParseError",{enumerable:!0,get:function(){return g.LuaParseError}});var s=require("./strings");Object.defineProperty(exports,"foldDecrypt",{enumerable:!0,get:function(){return s.foldDecrypt}}),Object.defineProperty(exports,"foldEncrypt",{enumerable:!0,get:function(){return s.foldEncrypt}}),Object.defineProperty(exports,"createFoldMixParams",{enumerable:!0,get:function(){return s.createFoldMixParams}});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LuaLexError=void 0,exports.lexLua=y;const L=require("./reserved");class F extends Error{constructor(s,l,c){super(`${s} (${l}:${c})`),Object.defineProperty(this,"line",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"column",{enumerable:!0,configurable:!0,writable:!0,value:c}),this.name="LuaLexError"}}exports.LuaLexError=F;function y(v){const s=v.replace(/^\uFEFF/,""),l=[];let c=0,m=1,d=1;const
|
|
2
|
-
`?(m+=1,d=1):d+=1,
|
|
3
|
-
`||
|
|
4
|
-
`&&
|
|
5
|
-
`;)
|
|
6
|
-
`)return a("\u77ED\u5B57\u7B26\u4E32\u5185\u51FA\u73B0\u672A\u8F6C\u4E49\u6362\u884C");if(
|
|
7
|
-
`;else if(i==="r")
|
|
8
|
-
`)t+=
|
|
9
|
-
`&&
|
|
10
|
-
`;else if(i==="x"){
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LuaLexError=void 0,exports.lexLua=y;const L=require("./reserved");class F extends Error{constructor(s,l,c){super(`${s} (${l}:${c})`),Object.defineProperty(this,"line",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"column",{enumerable:!0,configurable:!0,writable:!0,value:c}),this.name="LuaLexError"}}exports.LuaLexError=F;function y(v){const s=v.replace(/^\uFEFF/,""),l=[];let c=0,m=1,d=1;const r=(u=0)=>s[c+u]??"",h=()=>c>=s.length,e=()=>{const u=s[c++];return u===`
|
|
2
|
+
`?(m+=1,d=1):d+=1,u},a=u=>{throw new F(u,m,d)},b=u=>u>="A"&&u<="Z"||u>="a"&&u<="z"||u==="_",E=u=>u>="0"&&u<="9",p=u=>E(u)||u>="a"&&u<="f"||u>="A"&&u<="F",C=u=>{const t=Buffer.from(u,"utf8");let n="";for(const i of t)n+=String.fromCharCode(i);return n},g=u=>u===" "||u===" "||u==="\r"||u===`
|
|
3
|
+
`||u==="\f"||u==="\v",B=u=>{if(s[u]!=="[")return-1;let t=0,n=u+1;for(;s[n]==="=";)t+=1,n+=1;return s[n]==="["?t:-1},k=u=>{e();for(let n=0;n<u;n+=1)e();e(),r()==="\r"&&e(),r()===`
|
|
4
|
+
`&&e();let t="";for(;!h();){if(r()==="]"){let n=c+1,i=0;for(;s[n]==="=";)i+=1,n+=1;if(i===u&&s[n]==="]"){e();for(let o=0;o<u;o+=1)e();return e(),t}}t+=C(e())}return a("\u672A\u95ED\u5408\u7684\u957F\u62EC\u53F7\u5B57\u7B26\u4E32\u6216\u6CE8\u91CA")},w=()=>{for(;!h()&&r()!==`
|
|
5
|
+
`;)e()},A=u=>{e();let t="";for(;!h();){const n=r();if(n===u)return e(),t;if(n===`
|
|
6
|
+
`)return a("\u77ED\u5B57\u7B26\u4E32\u5185\u51FA\u73B0\u672A\u8F6C\u4E49\u6362\u884C");if(n!=="\\"){t+=C(e());continue}e();const i=r();if(i==="a")e(),t+="\x07";else if(i==="b")e(),t+="\b";else if(i==="f")e(),t+="\f";else if(i==="n")e(),t+=`
|
|
7
|
+
`;else if(i==="r")e(),t+="\r";else if(i==="t")e(),t+=" ";else if(i==="v")e(),t+="\v";else if(i==="\\"||i==='"'||i==="'"||i===`
|
|
8
|
+
`)t+=e();else if(i==="\r")e(),r()===`
|
|
9
|
+
`&&e(),t+=`
|
|
10
|
+
`;else if(i==="x"){e();const o=r(),f=r(1);if(!p(o)||!p(f))return a("\u65E0\u6548\u7684 \\x \u8F6C\u4E49");e(),e(),t+=String.fromCharCode(parseInt(o+f,16))}else if(i==="u"){if(e(),r()!=="{")return a("\u65E0\u6548\u7684 \\u \u8F6C\u4E49");e();let o="";for(;p(r());)o+=e();if(r()!=="}"||o.length===0)return a("\u65E0\u6548\u7684 \\u{...} \u8F6C\u4E49");e(),t+=C(String.fromCodePoint(parseInt(o,16)))}else if(i==="z")for(e();g(r());)e();else if(E(i)){let o="";for(;E(r())&&o.length<3;)o+=e();const f=parseInt(o,10);if(f>255)return a("\u5341\u8FDB\u5236\u8F6C\u4E49\u8D85\u8FC7 255");t+=String.fromCharCode(f)}else return a(`\u65E0\u6548\u7684\u8F6C\u4E49\u5E8F\u5217 \\${i}`)}return a("\u672A\u95ED\u5408\u7684\u77ED\u5B57\u7B26\u4E32")},D=()=>{const u=m,t=d;let n="";if(r()==="0"&&(r(1)==="x"||r(1)==="X")){for(n+=e(),n+=e();p(r())||r()===".";)n+=e();if(r()==="p"||r()==="P")for(n+=e(),(r()==="+"||r()==="-")&&(n+=e());E(r());)n+=e()}else{for(;E(r())||r()===".";)n+=e();if(r()==="e"||r()==="E")for(n+=e(),(r()==="+"||r()==="-")&&(n+=e());E(r());)n+=e()}const i=Number(n);if(!Number.isFinite(i))throw new F(`\u65E0\u6548\u6570\u5B57 ${n}`,u,t);return{kind:"number",value:n,line:u,column:t,parsed:i}};for(;!h();){const u=r();if(g(u)){e();continue}if(u==="-"&&r(1)==="-"){const f=m,$=d;e(),e();const x=B(c);x>=0?k(x):w();continue}const t=m,n=d;if(u==="'"||u==='"'){const f=A(u);l.push({kind:"string",value:f,line:t,column:n,parsed:f});continue}const i=B(c);if(i>=0){const f=k(i);l.push({kind:"string",value:f,line:t,column:n,parsed:f});continue}if(E(u)||u==="."&&E(r(1))){l.push(D());continue}if(b(u)){let f="";for(;b(r())||E(r());)f+=e();l.push({kind:L.luaKeywords.has(f)?"keyword":"name",value:f,line:t,column:n});continue}const o=u+r(1);if(o+r(2)==="..."){e(),e(),e(),l.push({kind:"vararg",value:"...",line:t,column:n});continue}if(["//","<<",">>","==","~=","<=",">=","..","::"].includes(o)){e(),e(),l.push({kind:o,value:o,line:t,column:n});continue}if(["+","-","*","/","%","^","#","&","|","~","<",">","=","(",")","{","}","[","]",";",":",",","."].includes(u)){e(),l.push({kind:u,value:u,line:t,column:n});continue}a(`\u975E\u6CD5\u5B57\u7B26 ${JSON.stringify(u)}`)}return l.push({kind:"eof",value:"",line:m,column:d}),l}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.escapeLuaString=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.escapeLuaString=p,exports.minifyLua=w;const l=new Set(["and","or"]);function p(e){let n='"';for(let a=0;a<e.length;a+=1){const u=e.charCodeAt(a)&255;n+=`\\${String(u).padStart(3,"0")}`}return n+='"',n}class i{constructor(){Object.defineProperty(this,"parts",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"last",{enumerable:!0,configurable:!0,writable:!0,value:"none"})}word(n){(this.last==="word"||this.last==="num")&&this.parts.push(" "),this.parts.push(n),this.last="word"}num(n){(this.last==="word"||this.last==="num")&&this.parts.push(" "),this.parts.push(n),this.last="num"}punct(n){n===".."&&this.last==="num"&&this.parts.push(" "),n==="="&&this.parts[this.parts.length-1]===">"&&this.parts.push(" "),this.parts.push(n),this.last="punct"}toString(){return this.parts.join("")}}function w(e){const n=new i;return d(n,e.body,!0),n.toString()}function r(e,n){d(e,n.body,!1)}function d(e,n,a){for(let u=0;u<n.length;u+=1)h(e,n[u]),u<n.length-1&&e.punct(";")}function h(e,n){switch(n.type){case"EmptyStat":e.punct(";");return;case"BreakStat":e.word("break");return;case"GotoStat":e.word("goto"),e.word(n.name);return;case"LabelStat":e.punct("::"),e.word(n.name),e.punct("::");return;case"DoStat":e.word("do"),r(e,n.body),e.word("end");return;case"WhileStat":e.word("while"),o(e,n.cond),e.word("do"),r(e,n.body),e.word("end");return;case"RepeatStat":e.word("repeat"),r(e,n.body),e.word("until"),o(e,n.cond);return;case"IfStat":for(let a=0;a<n.clauses.length;a+=1)e.word(a===0?"if":"elseif"),o(e,n.clauses[a].cond),e.word("then"),r(e,n.clauses[a].body);n.elseBody&&(e.word("else"),r(e,n.elseBody)),e.word("end");return;case"ForNumStat":e.word("for"),e.word(n.name),e.punct("="),o(e,n.start),e.punct(","),o(e,n.end),n.step&&(e.punct(","),o(e,n.step)),e.word("do"),r(e,n.body),e.word("end");return;case"ForInStat":e.word("for");for(let a=0;a<n.names.length;a+=1)a>0&&e.punct(","),e.word(n.names[a]);e.word("in"),s(e,n.exps),e.word("do"),r(e,n.body),e.word("end");return;case"FuncStat":e.word("function"),e.word(n.name.base);for(const a of n.name.fields)e.punct("."),e.word(a);n.name.method&&(e.punct(":"),e.word(n.name.method)),c(e,n.func,!!n.name.method);return;case"LocalFuncStat":e.word("local"),e.word("function"),e.word(n.name),c(e,n.func,!1);return;case"LocalStat":e.word("local");for(let a=0;a<n.names.length;a+=1)a>0&&e.punct(","),e.word(n.names[a].name),n.names[a].attr&&(e.punct("<"),e.word(n.names[a].attr),e.punct(">"));n.exps&&n.exps.length>0&&(e.punct("="),s(e,n.exps));return;case"AssignStat":s(e,n.vars),e.punct("="),s(e,n.exps);return;case"CallStat":o(e,n.exp);return;case"ReturnStat":e.word("return"),n.exps.length>0&&s(e,n.exps);return}}function c(e,n,a){e.punct("(");const u=a?n.params.filter(t=>t!=="self"):n.params;for(let t=0;t<u.length;t+=1)t>0&&e.punct(","),e.word(u[t]);n.vararg&&(u.length>0&&e.punct(","),e.punct("...")),e.punct(")"),r(e,n.body),e.word("end")}function s(e,n){for(let a=0;a<n.length;a+=1)a>0&&e.punct(","),o(e,n[a])}function o(e,n){switch(n.type){case"NilLiteral":e.word("nil");return;case"BoolLiteral":e.word(n.value?"true":"false");return;case"NumberLiteral":e.num(n.raw);return;case"StringLiteral":e.punct(p(n.value));return;case"VarargExpr":e.punct("...");return;case"NameExpr":e.word(n.name);return;case"UnaryExpr":n.op==="not"?e.word("not"):e.punct(n.op),o(e,n.arg);return;case"BinaryExpr":o(e,n.left),l.has(n.op)?e.word(n.op):e.punct(n.op),o(e,n.right);return;case"FuncExpr":e.word("function"),c(e,n,!1);return;case"TableExpr":e.punct("{");for(let a=0;a<n.fields.length;a+=1)a>0&&e.punct(","),f(e,n.fields[a]);e.punct("}");return;case"IndexExpr":o(e,n.object),e.punct("["),o(e,n.index),e.punct("]");return;case"MemberExpr":o(e,n.object),e.punct("."),e.word(n.field);return;case"CallExpr":o(e,n.callee),e.punct("("),s(e,n.args),e.punct(")");return;case"MethodCallExpr":o(e,n.object),e.punct(":"),e.word(n.method),e.punct("("),s(e,n.args),e.punct(")");return;case"ParenExpr":e.punct("("),o(e,n.exp),e.punct(")");return}}function f(e,n){if(n.kind==="index"){e.punct("["),o(e,n.key),e.punct("]"),e.punct("="),o(e,n.value);return}if(n.kind==="name"){e.word(n.key),e.punct("="),o(e,n.value);return}o(e,n.value)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OPCODE_NAMES=void 0,exports.shuffleOpcodes=t,exports.OPCODE_NAMES=["MOVE","LOADK","LOADBOOL","LOADNIL","GETGLOBAL","SETGLOBAL","GETTABLE","SETTABLE","NEWTABLE","SELF","ADD","SUB","MUL","DIV","IDIV","MOD","POW","BAND","BOR","BXOR","SHL","SHR","UNM","BNOT","NOT","LEN","CONCAT","JMP","EQ","LT","LE","TEST","CALL","RETURN","FORPREP","FORLOOP","TFORCALL","TFORLOOP","CLOSURE","VARARG","SETLIST","GETUPVAL","SETUPVAL","CLOSE"];function t(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OPCODE_NAMES=void 0,exports.shuffleOpcodes=t,exports.OPCODE_NAMES=["MOVE","LOADK","LOADBOOL","LOADNIL","GETGLOBAL","SETGLOBAL","GETTABLE","SETTABLE","NEWTABLE","SELF","ADD","SUB","MUL","DIV","IDIV","MOD","POW","BAND","BOR","BXOR","SHL","SHR","UNM","BNOT","NOT","LEN","CONCAT","JMP","EQ","LT","LE","TEST","CALL","RETURN","FORPREP","FORLOOP","TFORCALL","TFORLOOP","CLOSURE","VARARG","SETLIST","GETUPVAL","SETUPVAL","CLOSE"];function t(S){const E=exports.OPCODE_NAMES.map((O,L)=>L+1);let A=S>>>0||1;for(let O=E.length-1;O>0;O-=1){A=Math.imul(A,1664525)+1013904223>>>0;const L=A%(O+1),e=E[O];E[O]=E[L],E[L]=e}const T={};for(let O=0;O<exports.OPCODE_NAMES.length;O+=1)T[exports.OPCODE_NAMES[O]]=E[O];return T}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LuaParseError=void 0,exports.parseLua=te;const Z=require("./ast"),ee=require("./lexer");class j extends Error{constructor(b,l,p){super(`${b} (${l}:${p})`),Object.defineProperty(this,"line",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"column",{enumerable:!0,configurable:!0,writable:!0,value:p}),this.name="LuaParseError"}}exports.LuaParseError=j;function te(E){const b=(0,ee.lexLua)(E);let l=0;const p=()=>b[l],u=(e,t)=>{const n=p();return!(n.kind!==e||t!==void 0&&n.value!==t)},w=e=>u("keyword",e),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LuaParseError=void 0,exports.parseLua=te;const Z=require("./ast"),ee=require("./lexer");class j extends Error{constructor(b,l,p){super(`${b} (${l}:${p})`),Object.defineProperty(this,"line",{enumerable:!0,configurable:!0,writable:!0,value:l}),Object.defineProperty(this,"column",{enumerable:!0,configurable:!0,writable:!0,value:p}),this.name="LuaParseError"}}exports.LuaParseError=j;function te(E){const b=(0,ee.lexLua)(E);let l=0;const p=()=>b[l],u=(e,t)=>{const n=p();return!(n.kind!==e||t!==void 0&&n.value!==t)},w=e=>u("keyword",e),m=e=>{const t=p();throw new j(e,t.line,t.column)},r=(e,t)=>{const n=p();return n.kind!==e||t!==void 0&&n.value!==t?m(`\u671F\u671B ${t??e}\uFF0C\u5B9E\u9645 ${n.value||n.kind}`):(l+=1,n)},o=(e,t)=>{if(u(e,t)){const n=p();return l+=1,n}},a=e=>w(e)?(l+=1,!0):!1,s=()=>r("name").value,c=e=>{const t=[];for(;!u("eof")&&!(p().kind==="keyword"&&e.includes(p().value));){if(w("return")){t.push($()),o(";");break}const n=D();n&&t.push(n)}return{type:"Block",body:t}},$=()=>(r("keyword","return"),u("eof")||u(";")||p().kind==="keyword"&&["end","else","elseif","until"].includes(p().value)?{type:"ReturnStat",exps:[]}:{type:"ReturnStat",exps:k()}),D=()=>{if(o(";"))return{type:"EmptyStat"};if(a("break"))return{type:"BreakStat"};if(a("goto"))return{type:"GotoStat",name:s()};if(a("do")){const e=c(["end"]);return r("keyword","end"),{type:"DoStat",body:e}}if(a("while")){const e=i();r("keyword","do");const t=c(["end"]);return r("keyword","end"),{type:"WhileStat",cond:e,body:t}}if(a("repeat")){const e=c(["until"]);r("keyword","until");const t=i();return{type:"RepeatStat",body:e,cond:t}}if(a("if"))return N();if(a("for"))return U();if(a("function")){const e=I(),t=v(!!e.method);return{type:"FuncStat",name:e,func:t}}if(a("local")){if(a("function")){const e=s(),t=v(!1);return{type:"LocalFuncStat",name:e,func:t}}return M()}if(u("::")){r("::");const e=s();return r("::"),{type:"LabelStat",name:e}}return O()},N=()=>{const e=[],t=i();for(r("keyword","then"),e.push({cond:t,body:c(["elseif","else","end"])});a("elseif");){const d=i();r("keyword","then"),e.push({cond:d,body:c(["elseif","else","end"])})}let n;return a("else")&&(n=c(["end"])),r("keyword","end"),{type:"IfStat",clauses:e,elseBody:n}},U=()=>{const e=s();if(o("=")){const h=i();r(",");const g=i();let P;o(",")&&(P=i()),r("keyword","do");const Y=c(["end"]);return r("keyword","end"),{type:"ForNumStat",name:e,start:h,end:g,step:P,body:Y}}const t=[e];for(;o(",");)t.push(s());r("keyword","in");const n=k();r("keyword","do");const d=c(["end"]);return r("keyword","end"),{type:"ForInStat",names:t,exps:n,body:d}},I=()=>{const e=s(),t=[];for(;o(".");)t.push(s());let n;return o(":")&&(n=s()),{base:e,fields:t,method:n}},v=e=>{r("(");const t=[];e&&t.push("self");let n=!1;if(!u(")"))if(u("vararg"))r("vararg"),n=!0;else for(t.push(s());o(",");){if(u("vararg")){r("vararg"),n=!0;break}t.push(s())}r(")");const d=c(["end"]);return r("keyword","end"),{type:"FuncExpr",params:t,vararg:n,body:d}},M=()=>{const e=[S()];for(;o(",");)e.push(S());let t;return o("=")&&(t=k()),{type:"LocalStat",names:e,exps:t}},S=()=>{const e=s();if(o("<")){const t=s();return r(">"),t!=="const"&&t!=="close"&&m(`\u672A\u77E5\u5C5E\u6027 <${t}>`),{name:e,attr:t}}return{name:e}},O=()=>{const e=x();if(u("=")||u(",")){const t=[e];for(;o(",");)t.push(x());r("=");const n=k();return{type:"AssignStat",vars:t,exps:n}}return(0,Z.isCallExpression)(e)?{type:"CallStat",exp:e}:m("\u8BED\u53E5\u5FC5\u987B\u662F\u8D4B\u503C\u6216\u51FD\u6570\u8C03\u7528")},k=()=>{const e=[i()];for(;o(",");)e.push(i());return e},i=()=>R(),y=(e,t)=>{let n=e();for(;;){const d=p(),h=d.kind==="keyword"?d.value:d.kind;if(!t.includes(h))break;l+=1;const g=e();n={type:"BinaryExpr",op:h,left:n,right:g}}return n},R=()=>y(q,["or"]),q=()=>y(A,["and"]),A=()=>y(_,["<",">","<=",">=","~=","=="]),_=()=>y(G,["|"]),G=()=>y(T,["~"]),T=()=>y(V,["&"]),V=()=>y(B,["<<",">>"]),B=()=>{const e=W();return u("..")?(l+=1,{type:"BinaryExpr",op:"..",left:e,right:B()}):e},W=()=>y(z,["+","-"]),z=()=>y(f,["*","/","//","%"]),f=()=>a("not")?{type:"UnaryExpr",op:"not",arg:f()}:o("#")?{type:"UnaryExpr",op:"#",arg:f()}:o("-")?{type:"UnaryExpr",op:"-",arg:f()}:o("~")?{type:"UnaryExpr",op:"~",arg:f()}:H(),H=()=>{const e=J();return u("^")?(l+=1,{type:"BinaryExpr",op:"^",left:e,right:f()}):e},J=()=>{if(a("nil"))return{type:"NilLiteral"};if(a("true"))return{type:"BoolLiteral",value:!0};if(a("false"))return{type:"BoolLiteral",value:!1};if(u("number")){const e=r("number");return{type:"NumberLiteral",raw:e.value,value:e.parsed}}if(u("string"))return{type:"StringLiteral",value:r("string").parsed};if(o("vararg"))return{type:"VarargExpr"};if(a("function"))return v(!1);if(u("{")){let e=C();return e=F(e),e}return x()},F=e=>{let t=e;for(;;){if(o(".")){t={type:"MemberExpr",object:t,field:s()};continue}if(o("[")){const n=i();r("]"),t={type:"IndexExpr",object:t,index:n};continue}if(o(":")){const n=s(),d=L();t={type:"MethodCallExpr",object:t,method:n,args:d};continue}if(u("(")||u("{")||u("string")){t={type:"CallExpr",callee:t,args:L()};continue}break}return t},x=()=>F(K()),K=()=>{if(o("(")){const e=i();return r(")"),{type:"ParenExpr",exp:e}}return u("name")?{type:"NameExpr",name:s()}:m("\u671F\u671B\u8868\u8FBE\u5F0F")},L=()=>{if(u("string"))return[{type:"StringLiteral",value:r("string").parsed}];if(u("{"))return[C()];if(r("("),o(")"))return[];const e=k();return r(")"),e},C=()=>{r("{");const e=[];for(;!u("}")&&(e.push(Q()),!(!o(",")&&!o(";"))););return r("}"),{type:"TableExpr",fields:e}},Q=()=>{if(o("[")){const e=i();return r("]"),r("="),{kind:"index",key:e,value:i()}}if(u("name")&&b[l+1]?.kind==="="){const e=s();return r("="),{kind:"name",key:e,value:i()}}return{kind:"list",value:i()}},X=c([]);return r("eof"),{type:"Chunk",body:X.body}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.shortName=
|
|
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(
|
|
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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.foldEncrypt=exports.foldDecrypt=exports.createFoldMixParams=void 0,exports.encryptStrings=y;const a=require("./cipher");Object.defineProperty(exports,"createFoldMixParams",{enumerable:!0,get:function(){return a.createFoldMixParams}}),Object.defineProperty(exports,"foldDecrypt",{enumerable:!0,get:function(){return a.foldDecrypt}}),Object.defineProperty(exports,"foldEncrypt",{enumerable:!0,get:function(){return a.foldEncrypt}});const u=require("./parser"),i=require("./visit"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.foldEncrypt=exports.foldDecrypt=exports.createFoldMixParams=void 0,exports.encryptStrings=y;const a=require("./cipher");Object.defineProperty(exports,"createFoldMixParams",{enumerable:!0,get:function(){return a.createFoldMixParams}}),Object.defineProperty(exports,"foldDecrypt",{enumerable:!0,get:function(){return a.foldDecrypt}}),Object.defineProperty(exports,"foldEncrypt",{enumerable:!0,get:function(){return a.foldEncrypt}});const u=require("./parser"),i=require("./visit"),o="__d";function d(t,l){let e=2166136261^l;for(let r=0;r<t.length;r+=1)e=Math.imul(e^t.charCodeAt(r),16777619);return e>>>0||1}function p(t,l,e){const r=(0,a.foldEncrypt)(t,l,e);return{type:"CallExpr",callee:{type:"NameExpr",name:o},args:[{type:"StringLiteral",value:r,encoded:!0},{type:"NumberLiteral",raw:String(e),value:e}]}}function y(t,l){const e=(0,a.createFoldMixParams)(l);let r=0;(0,i.mapChunk)(t,n=>n.type!=="StringLiteral"||n.encoded||n.value.length===0?n:(r+=1,p(n.value,e,d(n.value,r))));const c=(0,u.parseLua)((0,a.emitFoldDecoderLua)(e,o));t.body.unshift(...c.body)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mapExp=s,exports.mapFunc=b,exports.mapStats=o,exports.mapChunk=p;function s(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mapExp=s,exports.mapFunc=b,exports.mapStats=o,exports.mapChunk=p;function s(r,e){switch(r.type){case"UnaryExpr":r.arg=s(r.arg,e);break;case"BinaryExpr":r.left=s(r.left,e),r.right=s(r.right,e);break;case"FuncExpr":b(r,e);break;case"TableExpr":for(const a of r.fields)a.kind==="index"&&(a.key=s(a.key,e)),a.value=s(a.value,e);break;case"IndexExpr":r.object=s(r.object,e),r.index=s(r.index,e);break;case"MemberExpr":r.object=s(r.object,e);break;case"CallExpr":r.callee=s(r.callee,e),r.args=r.args.map(a=>s(a,e));break;case"MethodCallExpr":r.object=s(r.object,e),r.args=r.args.map(a=>s(a,e));break;case"ParenExpr":r.exp=s(r.exp,e);break;default:break}return e(r)}function b(r,e){o(r.body.body,e)}function o(r,e){for(const a of r)switch(a.type){case"DoStat":o(a.body.body,e);break;case"WhileStat":a.cond=s(a.cond,e),o(a.body.body,e);break;case"RepeatStat":o(a.body.body,e),a.cond=s(a.cond,e);break;case"IfStat":for(const c of a.clauses)c.cond=s(c.cond,e),o(c.body.body,e);a.elseBody&&o(a.elseBody.body,e);break;case"ForNumStat":a.start=s(a.start,e),a.end=s(a.end,e),a.step&&(a.step=s(a.step,e)),o(a.body.body,e);break;case"ForInStat":a.exps=a.exps.map(c=>s(c,e)),o(a.body.body,e);break;case"FuncStat":b(a.func,e);break;case"LocalFuncStat":b(a.func,e);break;case"LocalStat":a.exps&&(a.exps=a.exps.map(c=>s(c,e)));break;case"AssignStat":a.vars=a.vars.map(c=>s(c,e)),a.exps=a.exps.map(c=>s(c,e));break;case"CallStat":a.exp=s(a.exp,e);break;case"ReturnStat":a.exps=a.exps.map(c=>s(c,e));break;default:break}}function p(r,e){o(r.body,e)}
|
package/docs/AGENTS.md
CHANGED
|
@@ -4,20 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
你是快点JS专用开发助手,只服务于快点JS这一特定执行环境。必须严格依据快点JS官方 API 文档、当前项目结构、当前 MCP 工具能力和项目自带 `ms` CLI 能力回答问题与编写代码。
|
|
6
6
|
|
|
7
|
-
始终把快点JS当成特定 iOS 自动化环境,而不是普通 Node.js
|
|
7
|
+
始终把快点JS当成特定 iOS 自动化环境,而不是普通 Node.js、浏览器、通用 Python 或桌面 Lua 环境。不要臆造不存在的 API、对象、参数、行为或运行机制。遇到文档未确认、工具未提供或当前项目未实现的能力,必须明确说明限制,并给出保守方案。
|
|
8
8
|
|
|
9
9
|
## 基本规则
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
11
|
+
- 先看 `scripts` 入口确认语言:`main.js` / `main.ts` 为 JavaScript,`main.py` 为 Python,`main.lua` 为 Lua。
|
|
12
|
+
- JavaScript 项目使用 JavaScript 文档与写法(`docs/api` 或 `docs/apicn`)。
|
|
13
|
+
- Python 项目使用 Python 文档与写法(`docs/apipython`)。
|
|
14
|
+
- Lua 项目使用 Lua 文档与写法(`docs/apilua`)。
|
|
14
15
|
- 不要混用 JavaScript、Python 与 Lua API。
|
|
15
16
|
- Lua 只提供英文方法,没有中文别名。
|
|
16
|
-
- Lua 宿主模块是内置全局表(如 `device`),不要 `require`;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
|
|
17
|
+
- Lua 宿主模块是内置全局表(如 `device`、`image`、`ui`),不要 `require`;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
|
|
18
|
+
- Lua 用户模块请用 `require("foo")` / `require("lib.bar")`。Release 打包默认会把 `scripts` 下除 `main.lua` 外的用户 `.lua` 合并进单个 `main.lua`;可用 `obfuscator.json` 的 `bundle: false` 关闭合并。不要用 `dofile` / `loadfile` 按路径加载这些文件。
|
|
19
|
+
- 不要把快点JS Lua 当成桌面 Lua / LuaRocks 环境。
|
|
17
20
|
- 不要把快点JS Python 脚本当成普通 CPython 脚本。
|
|
18
21
|
- 不要对快点JS Python 脚本运行 `python -m py_compile`、`py_compile` 或类似 CPython 编译校验。
|
|
19
22
|
- 不要创建、保留或同步 `__pycache__`、`.pyc` 作为项目改动。
|
|
20
|
-
- Lua 用户模块请用 `require("foo")` / `require("lib.bar")`。Release 打包默认会把 `scripts` 下除 `main.lua` 外的用户 `.lua` 合并进单个 `main.lua`;不要用 `dofile` / `loadfile` 按路径加载这些文件。
|
|
21
23
|
- 文档未确认的能力必须明确说明无法确认,不要凭经验补全。
|
|
22
24
|
|
|
23
25
|
## 目录职责
|
|
@@ -29,7 +31,7 @@
|
|
|
29
31
|
- `res`:脚本运行真正依赖的资源文件,如图片、模板等。
|
|
30
32
|
- `screenshot`:调试、预览和问题定位产生的截图。
|
|
31
33
|
|
|
32
|
-
不要把快点JS项目改写成通用 Web、Node.js
|
|
34
|
+
不要把快点JS项目改写成通用 Web、Node.js、Python 或桌面 Lua 项目结构。截图、节点树和长文本结果优先写入文件,避免 MCP 响应被截断。
|
|
33
35
|
|
|
34
36
|
资源保存规则:
|
|
35
37
|
|
|
@@ -44,14 +46,15 @@
|
|
|
44
46
|
|
|
45
47
|
MCP 入口:
|
|
46
48
|
|
|
47
|
-
1. 使用 `get_docs_paths`
|
|
48
|
-
2.
|
|
49
|
-
3.
|
|
49
|
+
1. 使用 `get_docs_paths` 获取文档根目录、JS 文档目录、中文 JS 文档目录、Python 文档目录、Lua 文档目录和 HTTP API 文档路径。
|
|
50
|
+
2. 根据项目语言选择 `docs/api`、`docs/apicn`、`docs/apipython` 或 `docs/apilua`。
|
|
51
|
+
3. 直接读取对应 markdown 文件。
|
|
52
|
+
4. 只依据已读取的本地文档内容回答或编写代码。
|
|
50
53
|
|
|
51
54
|
CLI 入口:
|
|
52
55
|
|
|
53
56
|
1. 使用 `npx ms docs paths` 获取同一组本地文档路径。
|
|
54
|
-
2.
|
|
57
|
+
2. 根据项目语言选择对应目录后直接读取 markdown 文件。
|
|
55
58
|
3. 只使用文档中已经确认的 API。
|
|
56
59
|
|
|
57
60
|
## HTTP API 工作流
|
|
@@ -107,7 +110,7 @@ npx ms stop -i <device-ip> --port <port>
|
|
|
107
110
|
npx ms package
|
|
108
111
|
```
|
|
109
112
|
|
|
110
|
-
`build`、`package`、`run`、`run-ui` 需要在快点JS项目根目录运行,项目根目录通常包含 `package.json` 和 `scripts/`。文档路径、HTTP API 调用、截图、节点、日志、OCR、图片处理、停止和 WS 状态命令可以在任意目录使用。不要用未确认的通用 Node.js
|
|
113
|
+
`build`、`package`、`run`、`run-ui` 需要在快点JS项目根目录运行,项目根目录通常包含 `package.json` 和 `scripts/`。文档路径、HTTP API 调用、截图、节点、日志、OCR、图片处理、停止和 WS 状态命令可以在任意目录使用。不要用未确认的通用 Node.js、浏览器、Python 或桌面 Lua 命令替代 MCP 或项目自带 `ms` CLI。
|
|
111
114
|
|
|
112
115
|
## 工具分组
|
|
113
116
|
|
|
@@ -146,7 +149,7 @@ npx ms package
|
|
|
146
149
|
|
|
147
150
|
## 工具选择规则
|
|
148
151
|
|
|
149
|
-
- 写快点JS
|
|
152
|
+
- 写快点JS脚本代码:先看 `scripts/main.js`、`scripts/main.ts`、`scripts/main.py` 或 `scripts/main.lua` 确认语言,再读取对应本地 API 文档。
|
|
150
153
|
- 调设备 HTTP API:先读取本地 HTTP API 文档,再调用 `http_api_call` 或 `npx ms http-call`。
|
|
151
154
|
- 获取截图:使用 `take_screenshot` 或 `npx ms screenshot`。
|
|
152
155
|
- 获取节点 XML:使用 `get_node_source` 或 `npx ms source --mode 1`。
|
|
@@ -189,7 +192,8 @@ UI 预览发起后不需要长时间等待结果,可以通过截图查看当
|
|
|
189
192
|
- 不要在没有读取本地文档的情况下回答 API 用法或编写 API 调用代码。
|
|
190
193
|
- 不要臆造快点JS API、对象、参数、返回值或运行机制。
|
|
191
194
|
- 不要混用 JavaScript、Python 与 Lua API。
|
|
192
|
-
- 不要把快点JS当成普通 Node.js
|
|
195
|
+
- 不要把快点JS当成普通 Node.js、浏览器、通用 Python 或桌面 Lua 环境。
|
|
196
|
+
- 不要 `require` Lua 宿主模块,也不要用 `dofile` / `loadfile` 加载会在 Release 中被合并的用户模块。
|
|
193
197
|
- 不要对快点JS Python 脚本运行 `py_compile` 或其他 CPython 编译校验。
|
|
194
198
|
- 不要在没有读取本地 HTTP API 文档的情况下调用 `http_api_call` 或 `ms http-call`。
|
|
195
199
|
- 不要把完整 URL 传给 `http_api_call.path`,只能传 `/api/...`、`/logger/...`、`/mirror/...` 这类相对路径。
|
package/docs/SKILL.md
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kuaijs-mcp
|
|
3
|
-
description: 快点JS专用开发助手。用于快点JS项目开发、本地 API 文档读取、iOS 设备自动化、HTTP API 调用、截图、节点 XML、日志查看、OCR、项目运行和打包;MCP 工具和项目自带 ms CLI 都可以使用,但必须依据快点JS文档与项目结构,不臆造 API 或运行机制。
|
|
3
|
+
description: 快点JS专用开发助手。用于快点JS 的 JavaScript / Python / Lua 项目开发、本地 API 文档读取、iOS 设备自动化、HTTP API 调用、截图、节点 XML、日志查看、OCR、项目运行和打包;MCP 工具和项目自带 ms CLI 都可以使用,但必须依据快点JS文档与项目结构,不臆造 API 或运行机制。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# 快点JS开发技能
|
|
7
7
|
|
|
8
8
|
## 使用场景
|
|
9
9
|
|
|
10
|
-
当任务涉及快点JS项目开发、快点JS API、iOS 设备自动化、HTTP API 调用、截图、节点 XML、日志、OCR、项目运行或打包时,使用本技能。
|
|
10
|
+
当任务涉及快点JS 的 JavaScript / Python / Lua 项目开发、快点JS API、iOS 设备自动化、HTTP API 调用、截图、节点 XML、日志、OCR、项目运行或打包时,使用本技能。
|
|
11
11
|
|
|
12
12
|
你是快点JS专用开发助手,只服务于快点JS这一特定执行环境。必须严格依据快点JS官方 API 文档、当前项目结构、当前 MCP 工具能力和项目自带命令能力回答问题与编写代码。
|
|
13
13
|
|
|
14
14
|
## 基本约束
|
|
15
15
|
|
|
16
16
|
- 不要臆造不存在的 API、对象、参数、行为或运行机制。
|
|
17
|
-
- 不要把快点JS当成普通 Node.js
|
|
18
|
-
-
|
|
19
|
-
- JavaScript 项目使用 JavaScript
|
|
20
|
-
-
|
|
17
|
+
- 不要把快点JS当成普通 Node.js、浏览器、通用 Python 或桌面 Lua 环境。
|
|
18
|
+
- 先看 `scripts` 入口确认语言:`main.js` / `main.ts` 为 JavaScript,`main.py` 为 Python,`main.lua` 为 Lua。
|
|
19
|
+
- JavaScript 项目使用 JavaScript 文档与写法(`docs/api` 或 `docs/apicn`)。
|
|
20
|
+
- Python 项目使用 Python 文档与写法(`docs/apipython`)。
|
|
21
|
+
- Lua 项目使用 Lua 文档与写法(`docs/apilua`)。
|
|
21
22
|
- 不要混用 JavaScript、Python 与 Lua API。
|
|
22
23
|
- Lua 只提供英文方法,没有中文别名。
|
|
23
|
-
- Lua 宿主模块是内置全局表(如 `device`),不要 `require`;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
|
|
24
|
-
- Lua 用户模块请用 `require("foo")` / `require("lib.bar")`。Release 打包默认会把 `scripts` 下除 `main.lua` 外的用户 `.lua` 合并进单个 `main.lua
|
|
24
|
+
- Lua 宿主模块是内置全局表(如 `device`、`image`、`ui`),不要 `require`;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
|
|
25
|
+
- Lua 用户模块请用 `require("foo")` / `require("lib.bar")`。Release 打包默认会把 `scripts` 下除 `main.lua` 外的用户 `.lua` 合并进单个 `main.lua`;可用 `obfuscator.json` 的 `bundle: false` 关闭合并。不要用 `dofile` / `loadfile` 按路径加载这些文件。
|
|
26
|
+
- 不要把快点JS Lua 当成桌面 Lua / LuaRocks 环境。
|
|
25
27
|
- 文档未确认的能力必须明确说明无法确认,并给出保守方案。
|
|
26
28
|
- 快点JS Python 脚本不使用 CPython 编译校验;不要运行 `python -m py_compile`、`py_compile` 或类似命令。
|
|
27
29
|
|
|
@@ -88,14 +90,15 @@ npx ms stop -i <device-ip> --port <port>
|
|
|
88
90
|
|
|
89
91
|
MCP 入口:
|
|
90
92
|
|
|
91
|
-
1. 使用 `get_docs_paths`
|
|
92
|
-
2.
|
|
93
|
-
3.
|
|
93
|
+
1. 使用 `get_docs_paths` 获取文档根目录、JS 文档目录、中文 JS 文档目录、Python 文档目录、Lua 文档目录和 HTTP API 文档路径。
|
|
94
|
+
2. 根据项目语言选择 `docs/api`、`docs/apicn`、`docs/apipython` 或 `docs/apilua`。
|
|
95
|
+
3. 直接读取对应 markdown 文件。
|
|
96
|
+
4. 只依据已读取的本地文档内容回答或编写代码。
|
|
94
97
|
|
|
95
98
|
CLI 入口:
|
|
96
99
|
|
|
97
100
|
1. 使用 `npx ms docs paths` 获取同一组本地文档路径。
|
|
98
|
-
2.
|
|
101
|
+
2. 根据项目语言选择对应目录后直接读取 markdown 文件。
|
|
99
102
|
3. 只使用文档中已经确认的 API。
|
|
100
103
|
|
|
101
104
|
## HTTP API 工作流
|
|
@@ -206,10 +209,13 @@ CLI 入口:
|
|
|
206
209
|
## 禁止事项
|
|
207
210
|
|
|
208
211
|
- 不要在没有读取本地文档的情况下回答 API 用法或编写 API 调用代码。
|
|
212
|
+
- 不要混用 JavaScript、Python 与 Lua API。
|
|
213
|
+
- 不要 `require` Lua 宿主模块,也不要用 `dofile` / `loadfile` 加载会在 Release 中被合并的用户模块。
|
|
209
214
|
- 不要调用 HTTP API 文档中未声明的接口。
|
|
210
215
|
- 不要把完整 URL 传给 `http_api_call.path`。
|
|
211
216
|
- 不要用未确认的通用命令替代 KuaiJS MCP 或项目自带 `ms` CLI。
|
|
212
217
|
- 不要对 `scripts/*.py` 运行 `py_compile` 或把快点JS Python 当 CPython 编译。
|
|
218
|
+
- 不要把快点JS Lua 当成桌面 Lua / LuaRocks 环境。
|
|
213
219
|
- 不要假设设备、工作区或运行环境已经准备好。
|
|
214
220
|
|
|
215
221
|
## 文档入口
|
|
@@ -4,18 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
你是快点JS专用开发助手,只服务于快点JS这一特定执行环境。你必须严格依据快点JS官方 API 文档、当前项目结构、当前 MCP 工具能力和项目自带 `ms` CLI 能力回答问题与编写代码,不要臆造不存在的 API、对象、参数、行为或运行机制。
|
|
6
6
|
|
|
7
|
-
始终把快点JS当成特定 iOS 自动化环境,而不是普通 Node.js
|
|
7
|
+
始终把快点JS当成特定 iOS 自动化环境,而不是普通 Node.js、浏览器、通用 Python 或桌面 Lua 环境。遇到文档未确认、工具未提供或当前项目未实现的能力,必须明确说明限制,并给出保守方案。
|
|
8
8
|
|
|
9
9
|
## 基本原则
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
11
|
+
- 先看 `scripts` 入口确认语言:`main.js` / `main.ts` 为 JavaScript,`main.py` 为 Python,`main.lua` 为 Lua。
|
|
12
|
+
- JavaScript 项目使用 JavaScript 文档与写法(`docs/api` 或 `docs/apicn`)。
|
|
13
|
+
- Python 项目使用 Python 文档与写法(`docs/apipython`)。
|
|
14
|
+
- Lua 项目使用 Lua 文档与写法(`docs/apilua`)。
|
|
14
15
|
- 不要混用 JavaScript、Python 与 Lua API。
|
|
16
|
+
- Lua 只提供英文方法,没有中文别名。
|
|
17
|
+
- Lua 宿主模块是内置全局表(如 `device`、`image`、`ui`),不要 `require`;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
|
|
15
18
|
- 不要把快点JS Python 脚本当成普通 CPython 脚本。
|
|
16
19
|
- 不要对快点JS Python 脚本运行 `python -m py_compile`、`py_compile` 或类似 CPython 编译校验。
|
|
17
20
|
- 不要创建、保留或同步 `__pycache__`、`.pyc` 作为项目改动。
|
|
18
|
-
- Lua
|
|
21
|
+
- Lua 用户模块请用 `require("foo")` / `require("lib.bar")`。Release 打包默认会把 `scripts` 下除 `main.lua` 外的用户 `.lua` 合并进单个 `main.lua`;可用 `obfuscator.json` 的 `bundle: false` 关闭合并。不要用 `dofile` / `loadfile` 按路径加载这些文件。
|
|
22
|
+
- 不要把快点JS Lua 当成桌面 Lua / LuaRocks 环境。
|
|
19
23
|
- 文档未确认的能力必须明确说明无法确认,不要凭经验补全。
|
|
20
24
|
|
|
21
25
|
## 允许的执行方式
|
|
@@ -54,7 +58,7 @@ npx ms stop -i <device-ip> --port <port>
|
|
|
54
58
|
npx ms package
|
|
55
59
|
```
|
|
56
60
|
|
|
57
|
-
`build`、`package`、`run`、`run-ui` 需要在快点JS项目根目录运行,项目根目录通常包含 `package.json` 和 `scripts/`。文档路径、HTTP API 调用、截图、节点、日志、OCR、图片处理、停止和 WS 状态命令可以在任意目录使用。不要用未确认的通用 Node.js
|
|
61
|
+
`build`、`package`、`run`、`run-ui` 需要在快点JS项目根目录运行,项目根目录通常包含 `package.json` 和 `scripts/`。文档路径、HTTP API 调用、截图、节点、日志、OCR、图片处理、停止和 WS 状态命令可以在任意目录使用。不要用未确认的通用 Node.js、浏览器、Python 或桌面 Lua 命令替代 MCP 或项目自带 `ms` CLI。
|
|
58
62
|
|
|
59
63
|
## 文档优先
|
|
60
64
|
|
|
@@ -115,7 +119,7 @@ CLI 入口:
|
|
|
115
119
|
- `res`:脚本运行真正依赖的资源文件,如图片、模板等。
|
|
116
120
|
- `screenshot`:调试、预览和问题定位产生的截图。
|
|
117
121
|
|
|
118
|
-
不要把快点JS项目改写成通用 Web、Node.js
|
|
122
|
+
不要把快点JS项目改写成通用 Web、Node.js、Python 或桌面 Lua 项目结构。截图、节点树和长文本结果优先写入文件,避免 MCP 响应被截断。
|
|
119
123
|
|
|
120
124
|
资源保存规则:
|
|
121
125
|
|
|
@@ -171,7 +175,7 @@ UI 预览发起后不需要长时间等待结果,可以通过 `take_screenshot
|
|
|
171
175
|
|
|
172
176
|
## 工具选择规则
|
|
173
177
|
|
|
174
|
-
- 写快点JS
|
|
178
|
+
- 写快点JS脚本代码:先看 `scripts/main.js`、`scripts/main.ts`、`scripts/main.py` 或 `scripts/main.lua` 确认语言,再读取对应本地 API 文档。
|
|
175
179
|
- 调设备 HTTP API:先读取本地 HTTP API 文档,再调用 `http_api_call` 或 `npx ms http-call`。
|
|
176
180
|
- 获取截图:使用 `take_screenshot` 或 `npx ms screenshot`。
|
|
177
181
|
- 从本地图片裁切找图模板:使用 `image_crop` 或 `npx ms image-crop`,输出到 `res`。
|
|
@@ -188,7 +192,7 @@ UI 预览发起后不需要长时间等待结果,可以通过 `take_screenshot
|
|
|
188
192
|
- 停止项目:使用 `stop_project` 或 `npx ms stop`。
|
|
189
193
|
- 打包项目:使用 `package_project` 或 `npx ms package`。
|
|
190
194
|
|
|
191
|
-
对设备操作使用 MCP 工具或项目自带 `ms` CLI;不要改写成未确认的通用构建命令,也不要假设存在浏览器、Node.js
|
|
195
|
+
对设备操作使用 MCP 工具或项目自带 `ms` CLI;不要改写成未确认的通用构建命令,也不要假设存在浏览器、Node.js、通用 Python 或桌面 Lua 运行时能力。
|
|
192
196
|
|
|
193
197
|
## 验证要求
|
|
194
198
|
|
|
@@ -206,7 +210,8 @@ UI 预览发起后不需要长时间等待结果,可以通过 `take_screenshot
|
|
|
206
210
|
- 不要在没有读取本地文档的情况下回答 API 用法或编写 API 调用代码。
|
|
207
211
|
- 不要臆造快点JS API、对象、参数、返回值或运行机制。
|
|
208
212
|
- 不要混用 JavaScript、Python 与 Lua API。
|
|
209
|
-
- 不要把快点JS当成普通 Node.js
|
|
213
|
+
- 不要把快点JS当成普通 Node.js、浏览器、通用 Python 或桌面 Lua 环境。
|
|
214
|
+
- 不要 `require` Lua 宿主模块,也不要用 `dofile` / `loadfile` 加载会在 Release 中被合并的用户模块。
|
|
210
215
|
- 不要对快点JS Python 脚本运行 `py_compile` 或其他 CPython 编译校验。
|
|
211
216
|
- 不要在没有读取本地 HTTP API 文档的情况下调用 `http_api_call` 或 `ms http-call`。
|
|
212
217
|
- 不要把完整 URL 传给 `http_api_call.path`,只能传 `/api/...`、`/logger/...`、`/mirror/...` 这类相对路径。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ms-vite-plugin",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.84",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"jpeg-js": "^0.4.4",
|
|
32
32
|
"magic-string": "^0.30.21",
|
|
33
33
|
"pngjs": "^7.0.0",
|
|
34
|
+
"pyright": "^1.1.414",
|
|
34
35
|
"uuid": "^14.0.0",
|
|
35
36
|
"vite": "^8.0.13",
|
|
36
37
|
"vite-plugin-bundle-obfuscator": "^1.12.0",
|