ms-vite-plugin 1.4.60 → 1.4.61
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/luaObfuscator/addVararg.js +1 -1
- package/dist/luaObfuscator/antiTamper.js +5 -5
- 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/numbers.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/selftest.js +8 -8
- package/dist/luaObfuscator/splitStrings.js +1 -1
- package/dist/luaObfuscator/strings.js +1 -1
- package/dist/luaObfuscator/visit.js +1 -1
- package/dist/luaObfuscator/vmEmit.js +3 -3
- package/docs/api/hid.md +21 -0
- package/docs/apicn/hid.md +21 -0
- package/docs/apilua/hid.md +23 -0
- package/docs/apipython/hid.md +22 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addVararg=c;function s(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addVararg=c;function s(r){r.vararg=!0,t(r.body.body)}function a(r){switch(r.type){case"FuncExpr":s(r);break;case"UnaryExpr":a(r.arg);break;case"BinaryExpr":a(r.left),a(r.right);break;case"TableExpr":for(const e of r.fields)e.kind==="index"&&a(e.key),a(e.value);break;case"IndexExpr":a(r.object),a(r.index);break;case"MemberExpr":a(r.object);break;case"CallExpr":a(r.callee);for(const e of r.args)a(e);break;case"MethodCallExpr":a(r.object);for(const e of r.args)a(e);break;case"ParenExpr":a(r.exp);break;default:break}}function t(r){for(const e of r)switch(e.type){case"DoStat":case"WhileStat":case"RepeatStat":case"ForNumStat":case"ForInStat":if(e.type==="WhileStat"&&a(e.cond),e.type==="RepeatStat"&&a(e.cond),e.type==="ForNumStat"&&(a(e.start),a(e.end),e.step&&a(e.step)),e.type==="ForInStat")for(const o of e.exps)a(o);t(e.body.body);break;case"IfStat":for(const o of e.clauses)a(o.cond),t(o.body.body);e.elseBody&&t(e.elseBody.body);break;case"FuncStat":case"LocalFuncStat":s(e.func);break;case"LocalStat":if(e.exps)for(const o of e.exps)a(o);break;case"AssignStat":for(const o of e.vars)a(o);for(const o of e.exps)a(o);break;case"CallStat":a(e.exp);break;case"ReturnStat":for(const o of e.exps)a(o);break;default:break}}function c(r){t(r.body)}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.applyAntiTamper=
|
|
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
|
-
local acc = ${
|
|
5
|
-
if acc * ${e} ~= ${
|
|
4
|
+
local acc = ${l}
|
|
5
|
+
if acc * ${e} ~= ${t} then
|
|
6
6
|
valid = false
|
|
7
7
|
end
|
|
8
8
|
local ok = pcall(function()
|
|
9
|
-
return acc * ${e} == ${
|
|
9
|
+
return acc * ${e} == ${t}
|
|
10
10
|
end)
|
|
11
11
|
if not ok then
|
|
12
12
|
valid = false
|
|
@@ -23,4 +23,4 @@ do
|
|
|
23
23
|
error("Tamper Detected!")
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
|
-
`,
|
|
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=
|
|
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=M;class T{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(t,r=0,o=0,i=0){return this.ops.push(t),this.code.push([0,r,o,i]),this.code.length-1}patch(t,r,o,i){const a=this.code[t];r!==void 0&&(a[1]=r),o!==void 0&&(a[2]=o),i!==void 0&&(a[3]=i)}kNil(){return this.intern({t:"nil"})}kBool(t){return this.intern({t:"bool",v:t})}kNum(t,r){return this.intern({t:"num",v:t,raw:r})}kStr(t){return this.intern({t:"str",v:t})}intern(t){for(let r=0;r<this.consts.length;r+=1){const o=this.consts[r];if(o.t===t.t&&(o.t==="nil"||o.t==="bool"&&t.t==="bool"&&o.v===t.v||o.t==="num"&&t.t==="num"&&o.v===t.v||o.t==="str"&&t.t==="str"&&o.v===t.v))return r+1}return this.consts.push(t),this.consts.length}alloc(t=1){const r=this.top;return this.top+=t,this.top-1>this.maxStack&&(this.maxStack=this.top-1),r}freeTo(t){this.top=t}pushFrame(){this.frames.push({locals:[],savedTop:this.top})}currentLocals(){return this.frames[this.frames.length-1]?.locals??[]}bind(t,r=!1){const o=this.alloc(1);return this.currentLocals().push({name:t,reg:o,close:r}),o}findLocal(t){for(let r=this.frames.length-1;r>=0;r-=1){const o=this.frames[r].locals;for(let i=o.length-1;i>=0;i-=1)if(o[i].name===t)return o[i].reg}}findUpval(t){for(let i=0;i<this.upvals.length;i+=1)if(this.upvals[i].name===t)return i+1;if(!this.parent)return;const r=this.parent.findLocal(t);if(r!==void 0)return this.upvals.push({name:t,inStack:!0,index:r}),this.upvals.length;const o=this.parent.findUpval(t);if(o!==void 0)return this.upvals.push({name:t,inStack:!1,index:o}),this.upvals.length}finish(){for(const t of this.gotos){const r=this.labels.get(t.name);if(r===void 0)throw new Error(`goto \u672A\u5B9A\u4E49\u6807\u7B7E ::${t.name}::`);this.patch(t.pc,0,r-(t.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 P={"+":"ADD","-":"SUB","*":"MUL","/":"DIV","//":"IDIV","%":"MOD","^":"POW","&":"BAND","|":"BOR","~":"BXOR","<<":"SHL",">>":"SHR","..":"CONCAT"},A={"-":"UNM","~":"BNOT",not:"NOT","#":"LEN"};function M(e){const t=new T;return t.isVararg=!0,t.pushFrame(),n(t,e.body),t.emit("RETURN",1,0),t.finish()}function g(e,t){const r=new T;r.parent=e,r.numparams=t.params.length,r.isVararg=t.vararg,r.pushFrame();for(const o of t.params)r.bind(o);return n(r,t.body.body),r.emit("RETURN",1,0),e.protos.push(r.finish()),e.protos.length}function n(e,t){for(const r of t)B(e,r)}function h(e,t){for(const r of t.locals)e.emit("CLOSE",r.reg);e.freeTo(t.savedTop)}function B(e,t){switch(t.type){case"EmptyStat":return;case"BreakStat":{if(e.breaks.length===0)throw new Error("break \u51FA\u73B0\u5728\u5FAA\u73AF\u5916");const r=e.emit("JMP",0,0);e.breaks[e.breaks.length-1].push(r);return}case"GotoStat":{const r=e.emit("JMP",0,0);e.gotos.push({name:t.name,pc:r});return}case"LabelStat":e.labels.set(t.name,e.code.length);return;case"DoStat":{e.pushFrame(),n(e,t.body.body),h(e,e.frames.pop());return}case"WhileStat":{const r=e.code.length,o=c(e,t.cond);e.emit("TEST",o,0,0);const i=e.emit("JMP",0,0);e.freeTo(o),e.breaks.push([]),e.pushFrame(),n(e,t.body.body),h(e,e.frames.pop()),e.emit("JMP",0,r-(e.code.length+1)),e.patch(i,0,e.code.length-(i+1)),b(e,e.breaks.pop(),e.code.length);return}case"RepeatStat":{const r=e.code.length;e.breaks.push([]),e.pushFrame(),n(e,t.body.body);const o=c(e,t.cond);e.emit("TEST",o,0,0),e.emit("JMP",0,r-(e.code.length+1)),h(e,e.frames.pop()),b(e,e.breaks.pop(),e.code.length);return}case"IfStat":{const r=[];for(let o=0;o<t.clauses.length;o+=1){const i=c(e,t.clauses[o].cond);e.emit("TEST",i,0,0);const a=e.emit("JMP",0,0);e.freeTo(i),e.pushFrame(),n(e,t.clauses[o].body.body),h(e,e.frames.pop()),(o<t.clauses.length-1||t.elseBody)&&r.push(e.emit("JMP",0,0)),e.patch(a,0,e.code.length-(a+1))}t.elseBody&&(e.pushFrame(),n(e,t.elseBody.body),h(e,e.frames.pop()));for(const o of r)e.patch(o,0,e.code.length-(o+1));return}case"ForNumStat":{const r=e.alloc(4);c(e,t.start,r),c(e,t.end,r+1),t.step?c(e,t.step,r+2):e.emit("LOADK",r+2,e.kNum(1,"1"));const o=e.emit("FORPREP",r,0);e.breaks.push([]),e.pushFrame();const i=e.bind(t.name);e.emit("MOVE",i,r+3),n(e,t.body.body),h(e,e.frames.pop());const a=e.emit("FORLOOP",r,0);e.patch(o,r,a-(o+1)),e.patch(a,r,o+1-(a+1)),b(e,e.breaks.pop(),e.code.length),e.freeTo(r);return}case"ForInStat":{const r=e.alloc(3);m(e,t.exps,r,3);const o=e.emit("TFORCALL",r,t.names.length),i=e.emit("TFORLOOP",r,0);e.breaks.push([]),e.pushFrame();for(let a=0;a<t.names.length;a+=1){const s=e.bind(t.names[a]);e.emit("MOVE",s,r+3+a)}n(e,t.body.body),h(e,e.frames.pop()),e.emit("JMP",0,o-(e.code.length+1)),e.patch(i,r,e.code.length-(i+1)),b(e,e.breaks.pop(),e.code.length),e.freeTo(r);return}case"FuncStat":{const r=g(e,t.func),o=e.alloc(1);e.emit("CLOSURE",o,r),N(e,t.name.base,t.name.fields,t.name.method,o),e.freeTo(o);return}case"LocalFuncStat":{const r=e.bind(t.name),o=g(e,t.func);e.emit("CLOSURE",r,o);return}case"LocalStat":{const r=t.names.length,o=[];if(t.exps&&t.exps.length>0){const i=e.top;m(e,t.exps,i,r);for(let a=0;a<r;a+=1){const s=e.bind(t.names[a].name,t.names[a].attr==="close");e.emit("MOVE",s,i+a),o.push(s)}e.freeTo(o[0]),e.top=o[r-1]+1}else for(const i of t.names){const a=e.bind(i.name,i.attr==="close");e.emit("LOADNIL",a),o.push(a)}return}case"AssignStat":{const r=e.top;m(e,t.exps,r,t.vars.length);for(let o=0;o<t.vars.length;o+=1)R(e,t.vars[o],r+o);e.freeTo(r);return}case"CallStat":{const r=e.top;c(e,t.exp,void 0,0),e.freeTo(r);return}case"ReturnStat":{if(t.exps.length===0){e.emit("RETURN",1,0);return}const r=e.top;m(e,t.exps,r,-1);const o=t.exps[t.exps.length-1],i=o.type==="CallExpr"||o.type==="MethodCallExpr"||o.type==="VarargExpr";e.emit("RETURN",r,i?-1:t.exps.length);return}}}function b(e,t,r){for(const o of t)e.patch(o,0,r-(o+1))}function N(e,t,r,o,i){if(r.length===0&&!o){y(e,t,i);return}let s=k(e,t);const l=o?[...r,o]:r;for(let u=0;u<l.length-1;u+=1){const p=e.alloc(1);e.emit("GETTABLE",p,s,-e.kStr(l[u])),s=p}e.emit("SETTABLE",s,-e.kStr(l[l.length-1]),i)}function y(e,t,r){const o=e.findLocal(t);if(o!==void 0){e.emit("MOVE",o,r);return}const i=e.findUpval(t);if(i!==void 0){e.emit("SETUPVAL",r,i);return}e.emit("SETGLOBAL",r,e.kStr(t))}function k(e,t,r){const o=r??e.alloc(1),i=e.findLocal(t);if(i!==void 0)return o!==i&&e.emit("MOVE",o,i),o;const a=e.findUpval(t);return a!==void 0?(e.emit("GETUPVAL",o,a),o):(e.emit("GETGLOBAL",o,e.kStr(t)),o)}function R(e,t,r){if(t.type==="NameExpr"){y(e,t.name,r);return}if(t.type==="MemberExpr"){const o=c(e,t.object);e.emit("SETTABLE",o,-e.kStr(t.field),r);return}if(t.type==="IndexExpr"){const o=c(e,t.object),i=c(e,t.index);e.emit("SETTABLE",o,i,r);return}throw new Error("\u975E\u6CD5\u8D4B\u503C\u5DE6\u503C")}function c(e,t,r,o=1){const i=r??e.alloc(1);switch(t.type){case"NilLiteral":return e.emit("LOADNIL",i),i;case"BoolLiteral":return e.emit("LOADBOOL",i,t.value?1:0),i;case"NumberLiteral":return e.emit("LOADK",i,e.kNum(t.value,t.raw)),i;case"StringLiteral":return e.emit("LOADK",i,e.kStr(t.value)),i;case"VarargExpr":return e.emit("VARARG",i,o),i;case"NameExpr":return k(e,t.name,i);case"ParenExpr":return c(e,t.exp,i,1);case"UnaryExpr":{const a=c(e,t.arg);return e.emit(A[t.op],i,a),i}case"BinaryExpr":return F(e,t.op,t.left,t.right,i);case"FuncExpr":{const a=g(e,t);return e.emit("CLOSURE",i,a),i}case"TableExpr":return x(e,t.fields,i);case"IndexExpr":{const a=c(e,t.object),s=c(e,t.index);return e.emit("GETTABLE",i,a,s),i}case"MemberExpr":{const a=c(e,t.object);return e.emit("GETTABLE",i,a,-e.kStr(t.field)),i}case"CallExpr":return v(e,t.callee,t.args,i,o,!1);case"MethodCallExpr":return v(e,t.object,t.args,i,o,t.method);default:throw new Error(`\u4E0D\u652F\u6301\u7684\u8868\u8FBE\u5F0F ${t.type}`)}}function F(e,t,r,o,i){if(t==="and"||t==="or"){c(e,r,i),e.emit("TEST",i,0,t==="and"?0:1);const u=e.emit("JMP",0,0);return c(e,o,i),e.patch(u,0,e.code.length-(u+1)),i}if(t==="=="||t==="~="||t==="<"||t===">"||t==="<="||t===">="){const u=c(e,r),p=c(e,o);let d="EQ",E=u,L=p;t==="<"||t===">="?d="LT":t==="<="||t===">"?d="LE":d="EQ",(t===">"||t===">=")&&(E=p,L=u);const j=t==="~=";e.emit(d,E,L,j?1:0);const O=e.emit("JMP",0,0);e.emit("LOADBOOL",i,1);const S=e.emit("JMP",0,0);return e.patch(O,0,e.code.length-(O+1)),e.emit("LOADBOOL",i,0),e.patch(S,0,e.code.length-(S+1)),i}const a=P[t];if(!a)throw new Error(`\u4E0D\u652F\u6301\u7684\u8FD0\u7B97\u7B26 ${t}`);const s=c(e,r),l=c(e,o);return e.emit(a,i,s,l),i}function w(e){return e.type==="CallExpr"||e.type==="MethodCallExpr"||e.type==="VarargExpr"}function v(e,t,r,o,i,a){const s=o,l=r.length>0&&w(r[r.length-1]);if(a){const u=c(e,t,s);return e.emit("SELF",s,u,-e.kStr(a)),m(e,r,s+2,-1),e.emit("CALL",s,l?-1:r.length+1,i),s}return c(e,t,s),m(e,r,s+1,-1),e.emit("CALL",s,l?-1:r.length,i),s}function m(e,t,r,o){const i=o>0?o:Math.max(t.length,1);if(e.top<r+i&&(e.top=r+i,e.top-1>e.maxStack&&(e.maxStack=e.top-1)),t.length===0){if(o>0)for(let a=0;a<o;a+=1)e.emit("LOADNIL",r+a);return}for(let a=0;a<t.length;a+=1){const s=a===t.length-1,l=s&&(o<0||o>t.length)?o===-1?-1:o-a:1;c(e,t[a],r+a,s?l:1)}if(o>t.length)for(let a=t.length;a<o;a+=1)e.emit("LOADNIL",r+a)}function x(e,t,r){e.emit("NEWTABLE",r);const o=[];for(const i of t)if(i.kind==="list")o.push(i.value);else if(i.kind==="name"){const a=c(e,i.value);e.emit("SETTABLE",r,-e.kStr(i.key),a)}else{const a=c(e,i.key),s=c(e,i.value);e.emit("SETTABLE",r,a,s)}if(o.length>0){const i=e.top;m(e,o,i,-1),e.emit("SETLIST",r,i,o.length),e.freeTo(i)}return r}
|
|
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,n=0,s=0){return this.ops.push(r),this.code.push([0,e,n,s]),this.code.length-1}patch(r,e,n,s){const o=this.code[r];e!==void 0&&(o[1]=e),n!==void 0&&(o[2]=n),s!==void 0&&(o[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 n=this.consts[e];if(n.t===r.t&&(n.t==="nil"||n.t==="bool"&&r.t==="bool"&&n.v===r.v||n.t==="num"&&r.t==="num"&&n.v===r.v||n.t==="str"&&r.t==="str"&&n.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 n=this.alloc(1);return this.currentLocals().push({name:r,reg:n,close:e}),n}findLocal(r){for(let e=this.frames.length-1;e>=0;e-=1){const n=this.frames[e].locals;for(let s=n.length-1;s>=0;s-=1)if(n[s].name===r)return n[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 n=this.parent.findUpval(r);if(n!==void 0)return this.upvals.push({name:r,inStack:!1,index:n}),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 n of r.params)e.bind(n);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,n=i(t,r.cond);t.emit("TEST",n,0,0);const s=t.emit("JMP",0,0);t.freeTo(n),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 n=i(t,r.cond);t.emit("TEST",n,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 n=0;n<r.clauses.length;n+=1){const s=i(t,r.clauses[n].cond);t.emit("TEST",s,0,0);const o=t.emit("JMP",0,0);t.freeTo(s),t.pushFrame(),u(t,r.clauses[n].body.body),p(t,t.frames.pop()),(n<r.clauses.length-1||r.elseBody)&&e.push(t.emit("JMP",0,0)),t.patch(o,0,t.code.length-(o+1))}r.elseBody&&(t.pushFrame(),u(t,r.elseBody.body),p(t,t.frames.pop()));for(const n of e)t.patch(n,0,t.code.length-(n+1));return}case"ForNumStat":{const e=t.alloc(4);i(t,r.start,e),i(t,r.end,e+1),r.step?i(t,r.step,e+2):t.emit("LOADK",e+2,t.kNum(1,"1"));const n=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 o=t.emit("FORLOOP",e,0);t.patch(n,e,o-(n+1)),t.patch(o,e,n+1-(o+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 n=t.emit("TFORCALL",e,r.names.length),s=t.emit("TFORLOOP",e,0);t.breaks.push([]),t.pushFrame();for(let o=0;o<r.names.length;o+=1){const a=t.bind(r.names[o]);t.emit("MOVE",a,e+3+o)}u(t,r.body.body),p(t,t.frames.pop()),t.emit("JMP",0,n-(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),n=t.alloc(1);t.emit("CLOSURE",n,e),w(t,r.name.base,r.name.fields,r.name.method,n),t.freeTo(n);return}case"LocalFuncStat":{const e=t.bind(r.name),n=d(t,r.func);t.emit("CLOSURE",e,n);return}case"LocalStat":{const e=r.names.length,n=[];if(r.exps&&r.exps.length>0){const s=t.top;h(t,r.exps,s,e);for(let o=0;o<e;o+=1){const a=t.bind(r.names[o].name,r.names[o].attr==="close");t.emit("MOVE",a,s+o),n.push(a)}t.freeTo(n[0]),t.top=n[e-1]+1}else for(const s of r.names){const o=t.bind(s.name,s.attr==="close");t.emit("LOADNIL",o),n.push(o)}return}case"AssignStat":{const e=t.top;h(t,r.exps,e,r.vars.length);for(let n=0;n<r.vars.length;n+=1)F(t,r.vars[n],e+n);t.freeTo(e);return}case"CallStat":{const e=t.top;i(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 n=r.exps[r.exps.length-1],s=n.type==="CallExpr"||n.type==="MethodCallExpr"||n.type==="VarargExpr";t.emit("RETURN",e,s?-1:r.exps.length);return}}}function f(t,r,e){for(const n of r)t.patch(n,0,e-(n+1))}function w(t,r,e,n,s){if(e.length===0&&!n){S(t,r,s);return}let o=T(t,r);const a=n?[...e,n]:e;for(let c=0;c<a.length-1;c+=1){const l=t.alloc(1);t.emit("GETTABLE",l,o,-t.kStr(a[c])),o=l}t.emit("SETTABLE",o,-t.kStr(a[a.length-1]),s)}function S(t,r,e){const n=t.findLocal(r);if(n!==void 0){t.emit("MOVE",n,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 n=e??t.alloc(1),s=t.findLocal(r);if(s!==void 0)return n!==s&&t.emit("MOVE",n,s),n;const o=t.findUpval(r);return o!==void 0?(t.emit("GETUPVAL",n,o),n):(t.emit("GETGLOBAL",n,t.kStr(r)),n)}function F(t,r,e){if(r.type==="NameExpr"){S(t,r.name,e);return}if(r.type==="MemberExpr"){const n=i(t,r.object);t.emit("SETTABLE",n,-t.kStr(r.field),e);return}if(r.type==="IndexExpr"){const n=i(t,r.object),s=i(t,r.index);t.emit("SETTABLE",n,s,e);return}throw new Error("\u975E\u6CD5\u8D4B\u503C\u5DE6\u503C")}function i(t,r,e,n=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,n),s;case"NameExpr":return T(t,r.name,s);case"ParenExpr":return i(t,r.exp,s,1);case"UnaryExpr":{const o=i(t,r.arg);return t.emit(A[r.op],s,o),s}case"BinaryExpr":return M(t,r.op,r.left,r.right,s);case"FuncExpr":{const o=d(t,r);return t.emit("CLOSURE",s,o),s}case"TableExpr":return R(t,r.fields,s);case"IndexExpr":{const o=i(t,r.object),a=i(t,r.index);return t.emit("GETTABLE",s,o,a),s}case"MemberExpr":{const o=i(t,r.object);return t.emit("GETTABLE",s,o,-t.kStr(r.field)),s}case"CallExpr":return y(t,r.callee,r.args,s,n,!1);case"MethodCallExpr":return y(t,r.object,r.args,s,n,r.method);default:throw new Error(`\u4E0D\u652F\u6301\u7684\u8868\u8FBE\u5F0F ${r.type}`)}}function M(t,r,e,n,s){if(r==="and"||r==="or"){i(t,e,s),t.emit("TEST",s,0,r==="and"?0:1);const l=t.emit("JMP",0,0);return i(t,n,s),t.patch(l,0,t.code.length-(l+1)),s}if(r==="=="||r==="~="||r==="<"||r===">"||r==="<="||r===">="){const l=i(t,e),b=i(t,n);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 o=k[r];if(!o)throw new Error(`\u4E0D\u652F\u6301\u7684\u8FD0\u7B97\u7B26 ${r}`);const a=i(t,e),c=i(t,n);return t.emit(o,s,a,c),s}function N(t){return t.type==="CallExpr"||t.type==="MethodCallExpr"||t.type==="VarargExpr"}function y(t,r,e,n,s,o){const a=n,c=e.length>0&&N(e[e.length-1]);if(o){const l=i(t,r,a);return t.emit("SELF",a,l,-t.kStr(o)),h(t,e,a+2,-1),t.emit("CALL",a,c?-1:e.length+1,s),a}return i(t,r,a),h(t,e,a+1,-1),t.emit("CALL",a,c?-1:e.length,s),a}function h(t,r,e,n){const s=n>0?n: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(n>0)for(let o=0;o<n;o+=1)t.emit("LOADNIL",e+o);return}for(let o=0;o<r.length;o+=1){const a=o===r.length-1,c=a&&(n<0||n>r.length)?n===-1?-1:n-o:1;i(t,r[o],e+o,a?c:1)}if(n>r.length)for(let o=r.length;o<n;o+=1)t.emit("LOADNIL",e+o)}function R(t,r,e){t.emit("NEWTABLE",e);const n=[];for(const s of r)if(s.kind==="list")n.push(s.value);else if(s.kind==="name"){const o=i(t,s.value);t.emit("SETTABLE",e,-t.kStr(s.key),o)}else{const o=i(t,s.key),a=i(t,s.value);t.emit("SETTABLE",e,o,a)}if(n.length>0){const s=t.top;h(t,n,s,-1),t.emit("SETLIST",e,s,n.length),t.freeTo(s)}return e}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.applyConstantArray=
|
|
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=
|
|
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,s){return{type:"AssignStat",vars:t.map(e=>p(e)),exps:s}}function u(t,s){return f([t.stateName],[typeof s=="number"?m(s):s])}function k(t,s,e){return{type:"BinaryExpr",op:"or",left:{type:"BinaryExpr",op:"and",left:p(t),right:m(s)},right:m(e)}}function E(t,s,e){return{type:"BinaryExpr",op:t,left:s,right:e}}function S(t){const s=`__t${t.nextTemp}`;return t.nextTemp+=1,t.temps.push(s),s}function x(t){const s=t.nextState;return t.nextState+=1,t.states.set(s,[]),s}function r(t,s,e){t.states.get(s).push(e)}function B(t,s){for(const e of t)if(e.type==="LocalStat")for(const n of e.names)s.push(n.name);else if(e.type==="LocalFuncStat")s.push(e.name);else if(e.type==="ForNumStat")s.push(e.name),B(e.body.body,s);else if(e.type==="ForInStat")s.push(...e.names),B(e.body.body,s);else if(e.type==="DoStat"||e.type==="WhileStat"||e.type==="RepeatStat")B(e.body.body,s);else if(e.type==="IfStat"){for(const n of e.clauses)B(n.body.body,s);e.elseBody&&B(e.elseBody.body,s)}}function h(t,s,e,n){if(t.length===0)return s;const y=t.map(()=>x(e));for(let o=0;o<t.length;o+=1){const a=t[o];a.type==="LabelStat"&&e.userLabels.set(a.name,y[o])}for(let o=0;o<t.length;o+=1){const a=o+1<t.length?y[o+1]:s;I(e,y[o],t[o],a,n)}return y[0]}function I(t,s,e,n,y){switch(e.type){case"EmptyStat":case"LabelStat":r(t,s,u(t,n));return;case"AssignStat":case"CallStat":case"FuncStat":r(t,s,e),r(t,s,u(t,n));return;case"LocalStat":e.exps&&e.exps.length>0&&r(t,s,f(e.names.map(o=>o.name),e.exps)),r(t,s,u(t,n));return;case"LocalFuncStat":r(t,s,f([e.name],[e.func])),r(t,s,u(t,n));return;case"ReturnStat":r(t,s,e);return;case"BreakStat":r(t,s,u(t,y));return;case"GotoStat":{const o=t.userLabels.get(e.name);if(o===void 0)throw new Error(`goto \u672A\u5B9A\u4E49\u6807\u7B7E ::${e.name}::`);r(t,s,u(t,o));return}case"DoStat":r(t,s,u(t,h(e.body.body,n,t,y)));return;case"IfStat":{const o=S(t);let a=s;for(let l=0;l<e.clauses.length;l+=1){const b=l===e.clauses.length-1,d=h(e.clauses[l].body.body,n,t,y);let i=n;b?e.elseBody&&(i=h(e.elseBody.body,n,t,y)):i=x(t),r(t,a,f([o],[e.clauses[l].cond])),r(t,a,u(t,k(o,d,i))),b||(a=i)}e.clauses.length===0&&r(t,s,u(t,n));return}case"WhileStat":{const o=S(t),a=h(e.body.body,s,t,n);r(t,s,f([o],[e.cond])),r(t,s,u(t,k(o,a,n)));return}case"RepeatStat":{const o=S(t),a=x(t),l=h(e.body.body,a,t,n);r(t,s,u(t,l)),r(t,a,f([o],[e.cond])),r(t,a,u(t,k(o,n,l)));return}case"ForNumStat":{const o=e.name,a=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,n);r(t,s,f([o],[e.start])),r(t,s,f([a],[e.end])),r(t,s,f([l],[e.step??m(1)])),r(t,s,u(t,d)),r(t,d,f([b],[E(">=",p(l),m(0))])),r(t,d,u(t,k(b,i,L))),r(t,i,f([b],[E("<=",p(o),p(a))])),r(t,i,u(t,k(b,N,n))),r(t,L,f([b],[E(">=",p(o),p(a))])),r(t,L,u(t,k(b,N,n))),r(t,g,f([o],[E("+",p(o),p(l))])),r(t,g,u(t,d));return}case"ForInStat":{const o=S(t),a=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,n),g=e.exps.slice();for(;g.length<3;)g.push({type:"NilLiteral"});r(t,s,f([o,a,l],g.slice(0,3))),r(t,s,u(t,d)),r(t,d,{type:"AssignStat",vars:e.names.map(N=>p(N)),exps:[{type:"CallExpr",callee:p(o),args:[p(a),p(l)]}]}),r(t,d,f([b],[E("~=",p(e.names[0]),{type:"NilLiteral"})])),r(t,d,u(t,k(b,L,n)));return}default:r(t,s,u(t,n))}}function v(t,s){const e=t.slice();let n=s>>>0||1;for(let y=e.length-1;y>0;y-=1){n=Math.imul(n,1664525)+1013904223>>>0;const o=n%(y+1),a=e[y];e[y]=e[o],e[o]=a}return e}function w(t,s){if(t.length===0)return t;const e={states:new Map,temps:[],nextState:1,nextTemp:1,stateName:"__s",userLabels:new Map},n=[];B(t,n);const y=h(t,0,e,0),o=[...new Set([...n,...e.temps,e.stateName])],a=v([...e.states.keys()],s).map(l=>({cond:E("==",p(e.stateName),m(l)),body:{type:"Block",body:e.states.get(l)}}));return[{type:"LocalStat",names:o.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:a}]}}]}function c(t,s){switch(t.type){case"FuncExpr":F(t.body.body,s),t.body.body=w(t.body.body,s);break;case"UnaryExpr":c(t.arg,s);break;case"BinaryExpr":c(t.left,s),c(t.right,s);break;case"TableExpr":for(const e of t.fields)e.kind==="index"&&c(e.key,s),c(e.value,s);break;case"IndexExpr":c(t.object,s),c(t.index,s);break;case"MemberExpr":c(t.object,s);break;case"CallExpr":c(t.callee,s);for(const e of t.args)c(e,s);break;case"MethodCallExpr":c(t.object,s);for(const e of t.args)c(e,s);break;case"ParenExpr":c(t.exp,s);break;default:break}}function F(t,s){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,s),e.type==="ForNumStat"&&(c(e.start,s),c(e.end,s),e.step&&c(e.step,s)),e.type==="ForInStat")for(const n of e.exps)c(n,s);F(e.body.body,s);break;case"IfStat":for(const n of e.clauses)c(n.cond,s),F(n.body.body,s);e.elseBody&&F(e.elseBody.body,s);break;case"FuncStat":case"LocalFuncStat":F(e.func.body.body,s),e.func.body.body=w(e.func.body.body,s);break;case"LocalStat":if(e.exps)for(const n of e.exps)c(n,s);break;case"AssignStat":for(const n of e.vars)c(n,s);for(const n of e.exps)c(n,s);break;case"CallStat":c(e.exp,s);break;case"ReturnStat":for(const n of e.exps)c(n,s);break;default:break}}function C(t,s){F(t.body,s),t.body=w(t.body,s)}
|
|
@@ -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=g;const
|
|
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=g;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 g(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 E=require("./lexer");Object.defineProperty(exports,"LuaLexError",{enumerable:!0,get:function(){return E.LuaLexError}});var O=require("./parser");Object.defineProperty(exports,"LuaParseError",{enumerable:!0,get:function(){return O.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=
|
|
2
|
-
`?(
|
|
3
|
-
`||
|
|
4
|
-
`&&
|
|
5
|
-
`;)
|
|
6
|
-
`)return a("\u77ED\u5B57\u7B26\u4E32\u5185\u51FA\u73B0\u672A\u8F6C\u4E49\u6362\u884C");if(
|
|
7
|
-
`;else if(
|
|
8
|
-
`)i+=
|
|
9
|
-
`&&
|
|
10
|
-
`;else if(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.LuaLexError=void 0,exports.lexLua=L;const D=require("./reserved");class F extends Error{constructor(l,s,c){super(`${l} (${s}:${c})`),Object.defineProperty(this,"line",{enumerable:!0,configurable:!0,writable:!0,value:s}),Object.defineProperty(this,"column",{enumerable:!0,configurable:!0,writable:!0,value:c}),this.name="LuaLexError"}}exports.LuaLexError=F;function L(v){const l=v.replace(/^\uFEFF/,""),s=[];let c=0,m=1,d=1;const r=(u=0)=>l[c+u]??"",h=()=>c>=l.length,e=()=>{const u=l[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 i=Buffer.from(u,"utf8");let n="";for(const t of i)n+=String.fromCharCode(t);return n},g=u=>u===" "||u===" "||u==="\r"||u===`
|
|
3
|
+
`||u==="\f"||u==="\v",B=u=>{if(l[u]!=="[")return-1;let i=0,n=u+1;for(;l[n]==="=";)i+=1,n+=1;return l[n]==="["?i:-1},k=u=>{e();for(let n=0;n<u;n+=1)e();e(),r()==="\r"&&e(),r()===`
|
|
4
|
+
`&&e();let i="";for(;!h();){if(r()==="]"){let n=c+1,t=0;for(;l[n]==="=";)t+=1,n+=1;if(t===u&&l[n]==="]"){e();for(let o=0;o<u;o+=1)e();return e(),i}}i+=C(e())}return a("\u672A\u95ED\u5408\u7684\u957F\u62EC\u53F7\u5B57\u7B26\u4E32\u6216\u6CE8\u91CA")},w=()=>{for(;!h()&&r()!==`
|
|
5
|
+
`;)e()},y=u=>{e();let i="";for(;!h();){const n=r();if(n===u)return e(),i;if(n===`
|
|
6
|
+
`)return a("\u77ED\u5B57\u7B26\u4E32\u5185\u51FA\u73B0\u672A\u8F6C\u4E49\u6362\u884C");if(n!=="\\"){i+=C(e());continue}e();const t=r();if(t==="a")e(),i+="\x07";else if(t==="b")e(),i+="\b";else if(t==="f")e(),i+="\f";else if(t==="n")e(),i+=`
|
|
7
|
+
`;else if(t==="r")e(),i+="\r";else if(t==="t")e(),i+=" ";else if(t==="v")e(),i+="\v";else if(t==="\\"||t==='"'||t==="'"||t===`
|
|
8
|
+
`)i+=e();else if(t==="\r")e(),r()===`
|
|
9
|
+
`&&e(),i+=`
|
|
10
|
+
`;else if(t==="x"){e();const o=r(),f=r(1);if(!p(o)||!p(f))return a("\u65E0\u6548\u7684 \\x \u8F6C\u4E49");e(),e(),i+=String.fromCharCode(parseInt(o+f,16))}else if(t==="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(),i+=C(String.fromCodePoint(parseInt(o,16)))}else if(t==="z")for(e();g(r());)e();else if(E(t)){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");i+=String.fromCharCode(f)}else return a(`\u65E0\u6548\u7684\u8F6C\u4E49\u5E8F\u5217 \\${t}`)}return a("\u672A\u95ED\u5408\u7684\u77ED\u5B57\u7B26\u4E32")},A=()=>{const u=m,i=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 t=Number(n);if(!Number.isFinite(t))throw new F(`\u65E0\u6548\u6570\u5B57 ${n}`,u,i);return{kind:"number",value:n,line:u,column:i,parsed:t}};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 i=m,n=d;if(u==="'"||u==='"'){const f=y(u);s.push({kind:"string",value:f,line:i,column:n,parsed:f});continue}const t=B(c);if(t>=0){const f=k(t);s.push({kind:"string",value:f,line:i,column:n,parsed:f});continue}if(E(u)||u==="."&&E(r(1))){s.push(A());continue}if(b(u)){let f="";for(;b(r())||E(r());)f+=e();s.push({kind:D.luaKeywords.has(f)?"keyword":"name",value:f,line:i,column:n});continue}const o=u+r(1);if(o+r(2)==="..."){e(),e(),e(),s.push({kind:"vararg",value:"...",line:i,column:n});continue}if(["//","<<",">>","==","~=","<=",">=","..","::"].includes(o)){e(),e(),s.push({kind:o,value:o,line:i,column:n});continue}if(["+","-","*","/","%","^","#","&","|","~","<",">","=","(",")","{","}","[","]",";",":",",","."].includes(u)){e(),s.push({kind:u,value:u,line:i,column:n});continue}a(`\u975E\u6CD5\u5B57\u7B26 ${JSON.stringify(u)}`)}return s.push({kind:"eof",value:"",line:m,column:d}),s}
|
|
@@ -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.numbersToExpressions=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.numbersToExpressions=o;const y=require("./visit");function l(e,a){const t=Math.abs(a)%9+2,r=e-t;if(e<0)return{type:"UnaryExpr",op:"-",arg:l(-e,a+3)};if(e<=2)return{type:"NumberLiteral",raw:String(e),value:e};if(a%3===0){const p=e%7+2,n=Math.floor(e/p),u=e-p*n,i={type:"BinaryExpr",op:"*",left:{type:"NumberLiteral",raw:String(p),value:p},right:{type:"NumberLiteral",raw:String(n),value:n}};return u===0?{type:"ParenExpr",exp:i}:{type:"ParenExpr",exp:{type:"BinaryExpr",op:"+",left:i,right:{type:"NumberLiteral",raw:String(u),value:u}}}}return{type:"ParenExpr",exp:{type:"BinaryExpr",op:"+",left:{type:"NumberLiteral",raw:String(t),value:t},right:{type:"NumberLiteral",raw:String(r),value:r}}}}function o(e,a){let t=0;(0,y.mapChunk)(e,r=>r.type!=="NumberLiteral"||!Number.isInteger(r.value)||!Number.isSafeInteger(r.value)?r:(t+=1,l(r.value,a+t*17)))}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OPCODE_NAMES=void 0,exports.shuffleOpcodes=
|
|
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(
|
|
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,p,l){super(`${b} (${p}:${l})`),Object.defineProperty(this,"line",{enumerable:!0,configurable:!0,writable:!0,value:p}),Object.defineProperty(this,"column",{enumerable:!0,configurable:!0,writable:!0,value:l}),this.name="LuaParseError"}}exports.LuaParseError=j;function te(E){const b=(0,ee.lexLua)(E);let p=0;const l=()=>b[p],u=(e,t)=>{const n=l();return!(n.kind!==e||t!==void 0&&n.value!==t)},w=e=>u("keyword",e),m=e=>{const t=l();throw new j(e,t.line,t.column)},r=(e,t)=>{const n=l();return n.kind!==e||t!==void 0&&n.value!==t?m(`\u671F\u671B ${t??e}\uFF0C\u5B9E\u9645 ${n.value||n.kind}`):(p+=1,n)},o=(e,t)=>{if(u(e,t)){const n=l();return p+=1,n}},a=e=>w(e)?(p+=1,!0):!1,s=()=>r("name").value,c=e=>{const t=[];for(;!u("eof")&&!(l().kind==="keyword"&&e.includes(l().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(";")||l().kind==="keyword"&&["end","else","elseif","until"].includes(l().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=l(),h=d.kind==="keyword"?d.value:d.kind;if(!t.includes(h))break;p+=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("..")?(p+=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("^")?(p+=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[p+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=n,exports.renameLocals=d;const u=require("./reserved"),c=require("./scope"),l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function n(r){let e=r,t="";do t=l[e%l.length]+t,e=Math.floor(e/l.length)-1;while(e>=0);return u.luaKeywords.has(t)?`_${t}`:t}function d(r){let e=0;const t=new Set;(0,c.collectAndRename)(r,(o,s)=>{if(o.newName!==o.original)return;let a=n(e);for(e+=1;s.has(a)||t.has(a)||u.luaKeywords.has(a);)a=n(e),e+=1;o.newName=a,t.add(a),s.add(a)})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveLocal=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveLocal=i,exports.collectAndRename=b;function i(e,c){let o=e;for(;o;){const s=o.locals.get(c);if(s)return s;o=o.parent}}function r(e){return{parent:e,locals:new Map}}function f(e,c){const o=e.locals.get(c);if(o)return o;const s={original:c,newName:c};return e.locals.set(c,s),s}function b(e,c){const o=new Set,s={locals:new Map};d(e.body,s,o,c)}function l(e,c,o,s){d(e.body,c,o,s)}function d(e,c,o,s){for(const n of e)x(n,c,o,s)}function m(e,c,o,s){const n=r(c),t=e.params.slice();for(let u=0;u<t.length;u+=1){const p=f(n,t[u]);s(p,o),e.params[u]=p.newName}l(e.body,n,o,s)}function x(e,c,o,s){switch(e.type){case"EmptyStat":case"BreakStat":case"GotoStat":case"LabelStat":return;case"DoStat":l(e.body,r(c),o,s);return;case"WhileStat":a(e.cond,c,o,s),l(e.body,r(c),o,s);return;case"RepeatStat":{const n=r(c);l(e.body,n,o,s),a(e.cond,n,o,s);return}case"IfStat":for(const n of e.clauses)a(n.cond,c,o,s),l(n.body,r(c),o,s);e.elseBody&&l(e.elseBody,r(c),o,s);return;case"ForNumStat":{a(e.start,c,o,s),a(e.end,c,o,s),e.step&&a(e.step,c,o,s);const n=r(c),t=f(n,e.name);s(t,o),e.name=t.newName,l(e.body,n,o,s);return}case"ForInStat":{for(const t of e.exps)a(t,c,o,s);const n=r(c);for(let t=0;t<e.names.length;t+=1){const u=f(n,e.names[t]);s(u,o),e.names[t]=u.newName}l(e.body,n,o,s);return}case"FuncStat":{const n=i(c,e.name.base);n&&(e.name.base=n.newName),m(e.func,c,o,s);return}case"LocalFuncStat":{const n=f(c,e.name);s(n,o),e.name=n.newName,m(e.func,c,o,s);return}case"LocalStat":if(e.exps)for(const n of e.exps)a(n,c,o,s);for(let n=0;n<e.names.length;n+=1){const t=f(c,e.names[n].name);s(t,o),e.names[n].name=t.newName}return;case"AssignStat":for(const n of e.vars)a(n,c,o,s);for(const n of e.exps)a(n,c,o,s);return;case"CallStat":a(e.exp,c,o,s);return;case"ReturnStat":for(const n of e.exps)a(n,c,o,s);return}}function a(e,c,o,s){switch(e.type){case"NilLiteral":case"BoolLiteral":case"NumberLiteral":case"StringLiteral":case"VarargExpr":return;case"NameExpr":{const n=i(c,e.name);n&&(e.name=n.newName);return}case"UnaryExpr":a(e.arg,c,o,s);return;case"BinaryExpr":a(e.left,c,o,s),a(e.right,c,o,s);return;case"FuncExpr":m(e,c,o,s);return;case"TableExpr":for(const n of e.fields)n.kind==="index"&&a(n.key,c,o,s),a(n.value,c,o,s);return;case"IndexExpr":a(e.object,c,o,s),a(e.index,c,o,s);return;case"MemberExpr":a(e.object,c,o,s);return;case"CallExpr":a(e.callee,c,o,s);for(const n of e.args)a(n,c,o,s);return;case"MethodCallExpr":a(e.object,c,o,s);for(const n of e.args)a(n,c,o,s);return;case"ParenExpr":a(e.exp,c,o,s);return}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const p=require("child_process"),c=require("./cipher"),F=require("./flatten"),a=require("./minify"),o=require("./parser"),r=require("./index");let s=0;function e(u,n){u?console.log(`\u2705 ${n}`):(s+=1,console.error(`\u274C ${n}`))}const l=`
|
|
2
2
|
local helper = require("device")
|
|
3
3
|
local wait = 10
|
|
4
4
|
Sleep(wait)
|
|
@@ -9,9 +9,9 @@ end
|
|
|
9
9
|
if add(1, 2) == 3 then
|
|
10
10
|
logi("ok")
|
|
11
11
|
end
|
|
12
|
-
`;function
|
|
12
|
+
`;function E(){const u=(0,c.createFoldMixParams)(42),n=["device","\u4F60\u597D","Sleep",""];for(const t of n){if(t.length===0)continue;const i=(0,c.foldEncrypt)(t,u,99),d=(0,c.foldDecrypt)(i,u,99),D=Buffer.from(t,"utf8").toString("latin1");e(d===D,`FoldMix \u5F80\u8FD4 ${t}`),e(!i.includes("device")||t!=="device","FoldMix \u8F7D\u8377\u4E0D\u542B\u660E\u6587 device")}}function C(){const u=(0,o.parseLua)(l),n=(0,a.minifyLua)(u),t=(0,o.parseLua)(n);e(t.body.length>0,"\u89E3\u6790\u5F80\u8FD4\u5F97\u5230\u975E\u7A7A AST"),e(n.includes("Sleep"),"Minify \u53D1\u5C04\u4FDD\u7559 Sleep")}function S(){const u=(0,r.obfuscateLua)(l,"Minify");e(u.includes("Sleep"),"Minify \u4E0D\u6539 Sleep"),e(u.includes("require"),"Minify \u4FDD\u7559 require"),e(!u.includes('"device"'),"Minify \u4E0D\u4FDD\u7559\u660E\u6587 device \u5B57\u9762\u91CF"),e(u.includes("\\100\\101\\118\\105\\099\\101"),"Minify \u7528\u5341\u8FDB\u5236\u8F6C\u4E49\u4FDD\u7559 device"),e(!/\bwait\b/.test(u),"Minify \u91CD\u547D\u540D\u5C40\u90E8 wait"),(0,o.parseLua)(u)}function _(){const u=(0,o.parseLua)(`local n=0
|
|
13
13
|
for i=1,3 do n=n+i end
|
|
14
|
-
if n==6 then Sleep(n) else Sleep(0) end`);(0,
|
|
14
|
+
if n==6 then Sleep(n) else Sleep(0) end`);(0,F.flattenControlFlow)(u,1);const n=(0,a.minifyLua)(u);e(n.includes("while"),"\u5C55\u5E73\u540E\u662F\u72B6\u6001\u673A\u5FAA\u73AF"),e(!/for\s+i\s*=\s*1\s*,\s*3/.test(n),"\u5C55\u5E73\u540E\u4E0D\u518D\u662F for i=1,3"),e(!/if\s+n\s*==\s*6/.test(n),"\u5C55\u5E73\u540E\u4E0D\u518D\u662F if n==6")}function b(){const u=(0,r.obfuscateLua)(l,"Weak");e(u.includes("function"),"Weak \u542B Vmify \u89E3\u91CA\u5668"),e(!u.includes("Sleep(wait)"),"Weak \u4E0D\u518D\u4FDD\u7559\u660E\u6587 Sleep(wait)"),e(!u.includes("helper.tap"),"Weak \u4E0D\u518D\u4FDD\u7559 helper.tap \u6E90\u7801\u7ED3\u6784"),e(!/\bhelper\b/.test(u),"Weak \u6539\u6389\u5C40\u90E8 helper"),(0,o.parseLua)(u),e(!0,"Weak \u4EA7\u7269\u53EF\u518D\u89E3\u6790")}function m(){const u=(0,r.obfuscateLua)(l,"Medium");e(u.includes("function"),"Medium \u542B\u865A\u62DF\u673A"),e(!u.includes('logi("ok")'),"Medium \u52A0\u5BC6\u7528\u6237\u5B57\u7B26\u4E32"),e(!u.includes("Tamper Detected!")||u.includes("pcall"),"Medium \u542B\u5B8C\u6574\u6027\u68C0\u67E5\u6216\u5DF2\u7F16\u8FDB VM"),(0,o.parseLua)(u),e(!0,"Medium \u4EA7\u7269\u53EF\u518D\u89E3\u6790")}function g(){const u=(0,r.obfuscateLua)('local d=require("device"); Sleep(1)',"Strong");e(u.includes("function"),"Strong \u542B\u89E3\u91CA\u5668\u51FD\u6570"),e(!u.includes("Sleep(1)"),"Strong \u4E0D\u518D\u4FDD\u7559\u660E\u6587 Sleep(1) \u8C03\u7528"),(0,o.parseLua)(u),e(!0,"Strong \u4EA7\u7269\u662F\u5408\u6CD5 Lua")}function y(){const u=(0,r.obfuscateLua)(`
|
|
15
15
|
local x <const> = 1
|
|
16
16
|
local y = 10 // 3
|
|
17
17
|
local z = y & 1 | 2
|
|
@@ -20,7 +20,7 @@ goto skip
|
|
|
20
20
|
for i = 1, 2 do
|
|
21
21
|
break
|
|
22
22
|
end
|
|
23
|
-
`,"Minify");(0,
|
|
23
|
+
`,"Minify");(0,o.parseLua)(u),e(u.includes("<const>"),"Minify \u4FDD\u7559 <const>"),e(u.includes("//"),"Minify \u4FDD\u7559\u6574\u9664")}function M(u){const n=["/opt/homebrew/bin/lua","lua5.4","lua54","lua"];for(const t of n){const i=(0,p.spawnSync)(t,["-e",u],{encoding:"utf8"});if(!i.error)return{ok:i.status===0,out:(i.stdout||"")+(i.stderr||"")}}return{ok:!1,out:""}}function f(u){const n=(0,r.obfuscateLua)('local m=require("device"); Sleep(3)',u),t=`
|
|
24
24
|
local env = setmetatable({
|
|
25
25
|
require = function(n) _G.__req = n; return {} end,
|
|
26
26
|
Sleep = function(ms) _G.__slept = ms end,
|
|
@@ -28,12 +28,12 @@ local env = setmetatable({
|
|
|
28
28
|
getmetatable = getmetatable, pcall = pcall, error = error,
|
|
29
29
|
}, {__index = _G})
|
|
30
30
|
env._ENV = env
|
|
31
|
-
local fn, err = load(${JSON.stringify(
|
|
31
|
+
local fn, err = load(${JSON.stringify(n)}, "obf", "t", env)
|
|
32
32
|
if not fn then error(err) end
|
|
33
33
|
fn()
|
|
34
34
|
if _G.__req ~= "device" then error("require name "..tostring(_G.__req)) end
|
|
35
35
|
if _G.__slept ~= 3 then error("Sleep "..tostring(_G.__slept)) end
|
|
36
|
-
print("${
|
|
37
|
-
`,
|
|
38
|
-
\u81EA\u68C0\u5931\u8D25 ${
|
|
36
|
+
print("${u}-ok")
|
|
37
|
+
`,i=M(t);if(!i.out&&i.ok===!1){console.log(`\u2139\uFE0F \u672C\u673A\u65E0 lua \u89E3\u91CA\u5668\uFF0C\u8DF3\u8FC7 ${u} \u8FD0\u884C\u65F6\u68C0\u67E5`);return}e(i.ok&&i.out.includes(`${u}-ok`),`${u} \u8FD0\u884C\u65F6\u8FD8\u539F require/Sleep: ${i.out.trim()}`)}E(),C(),S(),_(),b(),m(),g(),y(),f("Medium"),f("Strong"),s>0&&(console.error(`
|
|
38
|
+
\u81EA\u68C0\u5931\u8D25 ${s} \u9879`),process.exit(1)),console.log(`
|
|
39
39
|
\u81EA\u68C0\u901A\u8FC7`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.splitStrings=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.splitStrings=p;const u=require("./visit");function a(e){let r={type:"StringLiteral",value:e[0]};for(let n=1;n<e.length;n+=1)r={type:"BinaryExpr",op:"..",left:r,right:{type:"StringLiteral",value:e[n]}};return{type:"ParenExpr",exp:r}}function o(e,r){if(e.length<4)return[e];const n=r%2+2,t=Math.max(1,Math.ceil(e.length/n)),l=[];for(let i=0;i<e.length;i+=t)l.push(e.slice(i,i+t));return l}function p(e,r){let n=0;(0,u.mapChunk)(e,t=>{if(t.type!=="StringLiteral"||t.encoded||t.value.length<4)return t;n+=1;const l=o(t.value,r+n);return l.length<2?t:a(l)})}
|
|
@@ -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
|
|
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=
|
|
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)}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.emitVm=j;const
|
|
2
|
-
${(0,
|
|
3
|
-
local ${
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.emitVm=j;const p=require("./cipher"),d=require("./minify"),s=require("./opcodes");function h(e){let n=2166136261^e.code.length;return n=Math.imul(n,16777619)^e.consts.length,n>>>0}function b(e,n,l){if(e.t==="nil")return"nil";if(e.t==="bool")return e.v?"true":"false";if(e.t==="num")return e.raw;const a=(0,p.foldEncrypt)(e.v,n,l);return`D(${(0,d.escapeLuaString)(a)},${l})`}function u(e,n,l,a){const i=e.code.map((t,o)=>{const r=e.ops[o];return`{${n[r]},${t[1]},${t[2]},${t[3]}}`}).join(","),c=e.consts.map((t,o)=>b(t,l,a+o*131>>>0||1)).join(","),R=e.protos.map((t,o)=>u(t,n,l,a+(o+1)*4099>>>0)).join(","),f=e.upvals.map(t=>`{${t.inStack?1:0},${t.index}}`).join(",");return`{p={${i}},k={${c}},t={${R}},u={${f}},n=${e.numparams},v=${e.isVararg?"true":"false"}}`}function j(e){const n=h(e)||1,l=(0,s.shuffleOpcodes)(n),a=(0,p.createFoldMixParams)(n),i=s.OPCODE_NAMES.join(","),c=s.OPCODE_NAMES.map(f=>String(l[f])).join(","),R=u(e,l,a,n);return`(function()
|
|
2
|
+
${(0,p.emitFoldDecoderLua)(a,"D")}
|
|
3
|
+
local ${i}=${c}
|
|
4
4
|
local function G(u)
|
|
5
5
|
if u.R then
|
|
6
6
|
return u.R[u.i]
|
package/docs/api/hid.md
CHANGED
|
@@ -289,6 +289,27 @@ function setJitterValue(value: number): void;
|
|
|
289
289
|
hid.setJitterValue(5);
|
|
290
290
|
```
|
|
291
291
|
|
|
292
|
+
### setActionDelay - 设置动作延迟
|
|
293
|
+
|
|
294
|
+
设置连续点击/滑动之间的等待毫秒。不调用时用固件默认(相对 200ms / 绝对 100ms)。
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
function setActionDelay(milliseconds: number): boolean;
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
**参数:**
|
|
301
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
302
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
303
|
+
| `milliseconds` | number | 是 | `-1` | `0` 关闭,`>0` 覆盖毫秒,`-1` 恢复默认 |
|
|
304
|
+
|
|
305
|
+
**示例:**
|
|
306
|
+
|
|
307
|
+
```javascript
|
|
308
|
+
hid.setActionDelay(0);
|
|
309
|
+
hid.click(100, 200);
|
|
310
|
+
hid.click(300, 400);
|
|
311
|
+
```
|
|
312
|
+
|
|
292
313
|
## 基础触摸操作
|
|
293
314
|
|
|
294
315
|
### click - 点击操作
|
package/docs/apicn/hid.md
CHANGED
|
@@ -289,6 +289,27 @@ function 设置抖动值(抖动值: 数字): 无返回值;
|
|
|
289
289
|
$HID.设置抖动值(5);
|
|
290
290
|
```
|
|
291
291
|
|
|
292
|
+
### 设置动作延迟
|
|
293
|
+
|
|
294
|
+
设置连续点击/滑动之间的等待毫秒。不调用时用固件默认(相对 200ms / 绝对 100ms)。
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
function 设置动作延迟(毫秒: 数字): 布尔值;
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
**参数:**
|
|
301
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
302
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
303
|
+
| `毫秒` | 数字 | 是 | `-1` | `0` 关闭,`>0` 覆盖毫秒,`-1` 恢复默认 |
|
|
304
|
+
|
|
305
|
+
**示例:**
|
|
306
|
+
|
|
307
|
+
```javascript
|
|
308
|
+
$HID.设置动作延迟(0);
|
|
309
|
+
$HID.点击(100, 200);
|
|
310
|
+
$HID.点击(300, 400);
|
|
311
|
+
```
|
|
312
|
+
|
|
292
313
|
## 基础触摸操作
|
|
293
314
|
|
|
294
315
|
### 点击
|
package/docs/apilua/hid.md
CHANGED
|
@@ -258,6 +258,29 @@ function setJitterValue(value) end
|
|
|
258
258
|
hid.setJitterValue(5)
|
|
259
259
|
```
|
|
260
260
|
|
|
261
|
+
### setActionDelay - 设置动作延迟
|
|
262
|
+
|
|
263
|
+
设置连续点击/滑动之间的等待毫秒。不调用时用固件默认(相对 200ms / 绝对 100ms)。
|
|
264
|
+
|
|
265
|
+
```lua
|
|
266
|
+
---@param milliseconds number
|
|
267
|
+
---@return boolean
|
|
268
|
+
function setActionDelay(milliseconds) end
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**参数:**
|
|
272
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
273
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
274
|
+
| `milliseconds` | number | 是 | `-1` | `0` 关闭,`>0` 覆盖毫秒,`-1` 恢复默认 |
|
|
275
|
+
|
|
276
|
+
**示例:**
|
|
277
|
+
|
|
278
|
+
```lua
|
|
279
|
+
hid.setActionDelay(0)
|
|
280
|
+
hid.click(100, 200)
|
|
281
|
+
hid.click(300, 400)
|
|
282
|
+
```
|
|
283
|
+
|
|
261
284
|
## 基础触摸操作
|
|
262
285
|
|
|
263
286
|
### click - 点击操作
|
package/docs/apipython/hid.md
CHANGED
|
@@ -298,6 +298,28 @@ from kuaijs import hid
|
|
|
298
298
|
hid.setJitterValue(5)
|
|
299
299
|
```
|
|
300
300
|
|
|
301
|
+
### setActionDelay - 设置动作延迟
|
|
302
|
+
|
|
303
|
+
设置连续点击/滑动之间的等待毫秒。不调用时用固件默认(相对 200ms / 绝对 100ms)。
|
|
304
|
+
|
|
305
|
+
```python
|
|
306
|
+
def setActionDelay(milliseconds: int) -> bool
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
**参数:**
|
|
310
|
+
| 参数 | 类型 | 必需 | 默认值 | 描述 |
|
|
311
|
+
| ---- | ---- | ---- | ------ | ---- |
|
|
312
|
+
| `milliseconds` | int | 是 | `-1` | `0` 关闭,`>0` 覆盖毫秒,`-1` 恢复默认 |
|
|
313
|
+
|
|
314
|
+
**示例:**
|
|
315
|
+
|
|
316
|
+
```python
|
|
317
|
+
from kuaijs import hid
|
|
318
|
+
hid.setActionDelay(0)
|
|
319
|
+
hid.click(100, 200)
|
|
320
|
+
hid.click(300, 400)
|
|
321
|
+
```
|
|
322
|
+
|
|
301
323
|
## 基础触摸操作
|
|
302
324
|
|
|
303
325
|
### click - 点击操作
|