ms-vite-plugin 1.5.4 → 1.5.5

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.
Files changed (69) hide show
  1. package/dist/build/index.js +1 -0
  2. package/dist/cli.js +1 -1
  3. package/dist/device/project.js +1 -0
  4. package/dist/mcp/device-log.js +1 -1
  5. package/dist/mcp/image-tools.js +1 -1
  6. package/dist/mcp/runtime-tools.js +1 -1
  7. package/dist/mcp-server.js +1 -1
  8. package/dist/packaging/index.js +1 -0
  9. package/package.json +1 -1
  10. package/dist/build.js +0 -1
  11. package/dist/luaObfuscator/addVararg.d.ts +0 -2
  12. package/dist/luaObfuscator/addVararg.js +0 -1
  13. package/dist/luaObfuscator/antiTamper.d.ts +0 -2
  14. package/dist/luaObfuscator/antiTamper.js +0 -26
  15. package/dist/luaObfuscator/ast.d.ts +0 -191
  16. package/dist/luaObfuscator/ast.js +0 -1
  17. package/dist/luaObfuscator/cipher.d.ts +0 -10
  18. package/dist/luaObfuscator/cipher.js +0 -28
  19. package/dist/luaObfuscator/compiler.d.ts +0 -31
  20. package/dist/luaObfuscator/compiler.js +0 -1
  21. package/dist/luaObfuscator/constantArray.d.ts +0 -5
  22. package/dist/luaObfuscator/constantArray.js +0 -1
  23. package/dist/luaObfuscator/flatten.d.ts +0 -2
  24. package/dist/luaObfuscator/flatten.js +0 -1
  25. package/dist/luaObfuscator/index.d.ts +0 -6
  26. package/dist/luaObfuscator/index.js +0 -1
  27. package/dist/luaObfuscator/lexer.d.ts +0 -14
  28. package/dist/luaObfuscator/lexer.js +0 -10
  29. package/dist/luaObfuscator/minify.d.ts +0 -3
  30. package/dist/luaObfuscator/minify.js +0 -1
  31. package/dist/luaObfuscator/numbers.d.ts +0 -2
  32. package/dist/luaObfuscator/numbers.js +0 -1
  33. package/dist/luaObfuscator/opcodes.d.ts +0 -3
  34. package/dist/luaObfuscator/opcodes.js +0 -1
  35. package/dist/luaObfuscator/parser.d.ts +0 -8
  36. package/dist/luaObfuscator/parser.js +0 -1
  37. package/dist/luaObfuscator/rename.d.ts +0 -3
  38. package/dist/luaObfuscator/rename.js +0 -1
  39. package/dist/luaObfuscator/reserved.d.ts +0 -5
  40. package/dist/luaObfuscator/reserved.js +0 -1
  41. package/dist/luaObfuscator/scope.d.ts +0 -11
  42. package/dist/luaObfuscator/scope.js +0 -1
  43. package/dist/luaObfuscator/selftest.d.ts +0 -1
  44. package/dist/luaObfuscator/selftest.js +0 -39
  45. package/dist/luaObfuscator/splitStrings.d.ts +0 -2
  46. package/dist/luaObfuscator/splitStrings.js +0 -1
  47. package/dist/luaObfuscator/strings.d.ts +0 -4
  48. package/dist/luaObfuscator/strings.js +0 -1
  49. package/dist/luaObfuscator/visit.d.ts +0 -5
  50. package/dist/luaObfuscator/visit.js +0 -1
  51. package/dist/luaObfuscator/vmEmit.d.ts +0 -2
  52. package/dist/luaObfuscator/vmEmit.js +0 -281
  53. package/dist/luaObfuscator/wrapInFunction.d.ts +0 -2
  54. package/dist/luaObfuscator/wrapInFunction.js +0 -1
  55. package/dist/packager.js +0 -1
  56. package/dist/project.js +0 -1
  57. /package/dist/{build.d.ts → build/index.d.ts} +0 -0
  58. /package/dist/{luaBundle.d.ts → build/luaBundle.d.ts} +0 -0
  59. /package/dist/{luaBundle.js → build/luaBundle.js} +0 -0
  60. /package/dist/{scriptProtect.d.ts → build/scriptProtect.d.ts} +0 -0
  61. /package/dist/{scriptProtect.js → build/scriptProtect.js} +0 -0
  62. /package/dist/{stopGuardPlugin.d.ts → build/stopGuardPlugin.d.ts} +0 -0
  63. /package/dist/{stopGuardPlugin.js → build/stopGuardPlugin.js} +0 -0
  64. /package/dist/{project.d.ts → device/project.d.ts} +0 -0
  65. /package/dist/{usb-forward.d.ts → device/usb-forward.d.ts} +0 -0
  66. /package/dist/{usb-forward.js → device/usb-forward.js} +0 -0
  67. /package/dist/{ws-manager.d.ts → device/ws-manager.d.ts} +0 -0
  68. /package/dist/{ws-manager.js → device/ws-manager.js} +0 -0
  69. /package/dist/{packager.d.ts → packaging/index.d.ts} +0 -0
@@ -1,10 +0,0 @@
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,3 +0,0 @@
1
- import type { Chunk } from "./ast";
2
- export declare function escapeLuaString(value: string): string;
3
- export declare function minifyLua(chunk: Chunk): string;
@@ -1 +0,0 @@
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,2 +0,0 @@
1
- import type { Chunk } from "./ast";
2
- export declare function numbersToExpressions(chunk: Chunk, seed: number): void;
@@ -1 +0,0 @@
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,i=Math.floor(e/p),n=e-p*i,u={type:"BinaryExpr",op:"*",left:{type:"NumberLiteral",raw:String(p),value:p},right:{type:"NumberLiteral",raw:String(i),value:i}};return n===0?{type:"ParenExpr",exp:u}:{type:"ParenExpr",exp:{type:"BinaryExpr",op:"+",left:u,right:{type:"NumberLiteral",raw:String(n),value:n}}}}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,3 +0,0 @@
1
- export declare const OPCODE_NAMES: readonly ["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"];
2
- export type OpcodeName = (typeof OPCODE_NAMES)[number];
3
- export declare function shuffleOpcodes(seed: number): Record<OpcodeName, number>;
@@ -1 +0,0 @@
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,8 +0,0 @@
1
- import type { Chunk, UnaryOp } from "./ast";
2
- export declare class LuaParseError extends Error {
3
- readonly line: number;
4
- readonly column: number;
5
- constructor(message: string, line: number, column: number);
6
- }
7
- export declare function parseLua(source: string): Chunk;
8
- export type { UnaryOp };
@@ -1 +0,0 @@
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,3 +0,0 @@
1
- import type { Chunk } from "./ast";
2
- export declare function shortName(n: number): string;
3
- export declare function renameLocals(chunk: Chunk): void;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.shortName=a,exports.renameLocals=c;const u=require("./reserved"),d=require("./scope"),l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function a(r){let e=r,t="";do t=l[e%l.length]+t,e=Math.floor(e/l.length)-1;while(e>=0);return u.luaKeywords.has(t)?`_${t}`:t}function c(r){let e=0;const t=new Set;(0,d.collectAndRename)(r,(o,s)=>{if(o.newName!==o.original)return;let n=a(e);for(e+=1;s.has(n)||t.has(n)||u.luaKeywords.has(n);)n=a(e),e+=1;o.newName=n,t.add(n),s.add(n)})}
@@ -1,5 +0,0 @@
1
- export declare const luaKeywords: Set<string>;
2
- export declare const hostLuaModuleNames: Set<string>;
3
- export declare const hostLuaGlobals: Set<string>;
4
- export declare const luaStdlibNames: Set<string>;
5
- export declare function isReservedGlobal(name: string): boolean;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.luaStdlibNames=exports.hostLuaGlobals=exports.hostLuaModuleNames=exports.luaKeywords=void 0,exports.isReservedGlobal=t,exports.luaKeywords=new Set(["and","break","do","else","elseif","end","false","for","function","goto","if","in","local","nil","not","or","repeat","return","then","true","until","while"]),exports.hostLuaModuleNames=new Set(["action","appleocr","cloud","config","cryptoUtils","cv","device","dotocr","file","hid","hotupdate","http","image","ime","logger","media","mysql","netcard","node","paddleocr","pip","system","tomatoocr","tts","ui","utils","yolo","yolocls"]),exports.hostLuaGlobals=new Set(["IsDebug","RunMode","Platform","AppVersion","AppBuildNumber","AppName","AppBundleId","PackageJson","TakeMeToFront","RestartScript","Exit","SetStopCallback","SetExceptionCallback","Sleep","Time","ToJsonString","StartThread","StopThread","ShouldInterruptThread","SetAgentFastMode","GetAgentFastMode","SetAgentTouchMode","GetAgentTouchMode","SetCpuAutoThrottle","GetCpuAutoThrottle","SetCpuThrottleDelay","GetCpuThrottleDelay","logd","logi","logw","loge"]),exports.luaStdlibNames=new Set(["_G","_ENV","_VERSION","assert","collectgarbage","dofile","error","getmetatable","ipairs","load","loadfile","next","pairs","pcall","print","rawequal","rawget","rawlen","rawset","require","select","setmetatable","tonumber","tostring","type","warn","xpcall","coroutine","debug","io","math","os","package","string","table","utf8"]);function t(e){return exports.luaKeywords.has(e)||exports.hostLuaModuleNames.has(e)||exports.hostLuaGlobals.has(e)||exports.luaStdlibNames.has(e)}
@@ -1,11 +0,0 @@
1
- import type { Chunk } from "./ast";
2
- export interface Binding {
3
- original: string;
4
- newName: string;
5
- }
6
- export interface Scope {
7
- parent?: Scope;
8
- locals: Map<string, Binding>;
9
- }
10
- export declare function resolveLocal(scope: Scope, name: string): Binding | undefined;
11
- export declare function collectAndRename(chunk: Chunk, rename: (binding: Binding, used: Set<string>) => void): void;
@@ -1 +0,0 @@
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 +0,0 @@
1
- export {};
@@ -1,39 +0,0 @@
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
- local helper = require("device")
3
- local wait = 10
4
- Sleep(wait)
5
- helper.tap(1, 2)
6
- local function add(a, b)
7
- return a + b
8
- end
9
- if add(1, 2) == 3 then
10
- logi("ok")
11
- end
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
- for i=1,3 do n=n+i end
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
- local x <const> = 1
16
- local y = 10 // 3
17
- local z = y & 1 | 2
18
- goto skip
19
- ::skip::
20
- for i = 1, 2 do
21
- break
22
- end
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
- local env = setmetatable({
25
- require = function(n) _G.__req = n; return {} end,
26
- Sleep = function(ms) _G.__slept = ms end,
27
- string = string, table = table, math = math,
28
- getmetatable = getmetatable, pcall = pcall, error = error,
29
- }, {__index = _G})
30
- env._ENV = env
31
- local fn, err = load(${JSON.stringify(n)}, "obf", "t", env)
32
- if not fn then error(err) end
33
- fn()
34
- if _G.__req ~= "device" then error("require name "..tostring(_G.__req)) end
35
- if _G.__slept ~= 3 then error("Sleep "..tostring(_G.__slept)) end
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
- \u81EA\u68C0\u901A\u8FC7`);
@@ -1,2 +0,0 @@
1
- import type { Chunk } from "./ast";
2
- export declare function splitStrings(chunk: Chunk, seed: number): void;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.splitStrings=o;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 p(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 o(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=p(t.value,r+n);return l.length<2?t:a(l)})}
@@ -1,4 +0,0 @@
1
- import type { Chunk } from "./ast";
2
- import { createFoldMixParams, foldDecrypt, foldEncrypt, type FoldMixParams } from "./cipher";
3
- export declare function encryptStrings(chunk: Chunk, seed: number): void;
4
- export { createFoldMixParams, foldDecrypt, foldEncrypt, type FoldMixParams, };
@@ -1 +0,0 @@
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,5 +0,0 @@
1
- import type { Chunk, Expression, FuncExpr, Statement } from "./ast";
2
- export declare function mapExp(exp: Expression, fn: (e: Expression) => Expression): Expression;
3
- export declare function mapFunc(fnExpr: FuncExpr, fn: (e: Expression) => Expression): void;
4
- export declare function mapStats(stats: Statement[], fn: (e: Expression) => Expression): void;
5
- export declare function mapChunk(chunk: Chunk, fn: (e: Expression) => Expression): void;
@@ -1 +0,0 @@
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,2 +0,0 @@
1
- import type { Proto } from "./compiler";
2
- export declare function emitVm(root: Proto): string;
@@ -1,281 +0,0 @@
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
- local function G(u)
5
- if u.R then
6
- return u.R[u.i]
7
- end
8
- return u.v
9
- end
10
- local function S(u,x)
11
- if u.R then
12
- u.R[u.i]=x
13
- else
14
- u.v=x
15
- end
16
- end
17
- local function C(u)
18
- if u.R then
19
- u.v=u.R[u.i]
20
- u.R=nil
21
- u.i=nil
22
- end
23
- end
24
- local function V(P,U,A)
25
- local R={}
26
- local K=P.k
27
- local code=P.p
28
- local top=0
29
- local pc=1
30
- local open={}
31
- for i=1,P.n do
32
- R[i]=A[i]
33
- end
34
- local VA={}
35
- if P.v then
36
- for i=P.n+1,A.n do
37
- VA[#VA+1]=A[i]
38
- end
39
- end
40
- local function rk(x)
41
- if x<0 then
42
- return K[-x]
43
- end
44
- return R[x]
45
- end
46
- while true do
47
- local i=code[pc]
48
- if not i then
49
- return
50
- end
51
- local op=i[1]
52
- local a=i[2]
53
- local b=i[3]
54
- local c=i[4]
55
- pc=pc+1
56
- if op==MOVE then
57
- R[a]=R[b]
58
- elseif op==LOADK then
59
- R[a]=K[b]
60
- elseif op==LOADBOOL then
61
- R[a]=b~=0
62
- elseif op==LOADNIL then
63
- R[a]=nil
64
- elseif op==GETGLOBAL then
65
- R[a]=_ENV[K[b]]
66
- elseif op==SETGLOBAL then
67
- _ENV[K[b]]=R[a]
68
- elseif op==GETTABLE then
69
- R[a]=R[b][rk(c)]
70
- elseif op==SETTABLE then
71
- R[a][rk(b)]=rk(c)
72
- elseif op==NEWTABLE then
73
- R[a]={}
74
- elseif op==SELF then
75
- R[a+1]=R[b]
76
- R[a]=R[b][rk(c)]
77
- elseif op==ADD then
78
- R[a]=R[b]+R[c]
79
- elseif op==SUB then
80
- R[a]=R[b]-R[c]
81
- elseif op==MUL then
82
- R[a]=R[b]*R[c]
83
- elseif op==DIV then
84
- R[a]=R[b]/R[c]
85
- elseif op==IDIV then
86
- R[a]=R[b]//R[c]
87
- elseif op==MOD then
88
- R[a]=R[b]%R[c]
89
- elseif op==POW then
90
- R[a]=R[b]^R[c]
91
- elseif op==BAND then
92
- R[a]=R[b]&R[c]
93
- elseif op==BOR then
94
- R[a]=R[b]|R[c]
95
- elseif op==BXOR then
96
- R[a]=R[b]~R[c]
97
- elseif op==SHL then
98
- R[a]=R[b]<<R[c]
99
- elseif op==SHR then
100
- R[a]=R[b]>>R[c]
101
- elseif op==UNM then
102
- R[a]=-R[b]
103
- elseif op==BNOT then
104
- R[a]=~R[b]
105
- elseif op==NOT then
106
- R[a]=not R[b]
107
- elseif op==LEN then
108
- R[a]=#R[b]
109
- elseif op==CONCAT then
110
- R[a]=R[b]..R[c]
111
- elseif op==JMP then
112
- pc=pc+b
113
- elseif op==EQ then
114
- local eq=R[a]==R[b]
115
- local want=c==0
116
- if eq==want then
117
- pc=pc+1
118
- end
119
- elseif op==LT then
120
- local lt=R[a]<R[b]
121
- local want=c==0
122
- if lt==want then
123
- pc=pc+1
124
- end
125
- elseif op==LE then
126
- local le=R[a]<=R[b]
127
- local want=c==0
128
- if le==want then
129
- pc=pc+1
130
- end
131
- elseif op==TEST then
132
- -- C=0\uFF1A\u771F\u5219\u8DF3\u8FC7 JMP\uFF1BC=1\uFF1A\u5047\u5219\u8DF3\u8FC7\uFF08or\uFF09\u3002\u4E0D\u7528 and/or\uFF0C\u65B9\u4FBF\u518D\u7F16\u8BD1\u3002
133
- local take=false
134
- if c==0 then
135
- if R[a] then
136
- take=true
137
- end
138
- else
139
- if not R[a] then
140
- take=true
141
- end
142
- end
143
- if take then
144
- pc=pc+1
145
- end
146
- elseif op==CALL then
147
- local n=b
148
- local args={}
149
- local an=n
150
- if n<0 then
151
- an=0
152
- local last=top
153
- if last<a then
154
- last=a
155
- end
156
- for j=a+1,last do
157
- an=an+1
158
- args[an]=R[j]
159
- end
160
- else
161
- for j=1,n do
162
- args[j]=R[a+j]
163
- end
164
- end
165
- local rets=table.pack(R[a](table.unpack(args,1,an)))
166
- if c==0 then
167
- elseif c<0 then
168
- for j=1,rets.n do
169
- R[a+j-1]=rets[j]
170
- end
171
- top=a+rets.n-1
172
- else
173
- for j=1,c do
174
- R[a+j-1]=rets[j]
175
- end
176
- top=a+c-1
177
- end
178
- elseif op==RETURN then
179
- for _,u in pairs(open) do
180
- C(u)
181
- end
182
- if b==0 then
183
- return
184
- end
185
- if b<0 then
186
- return table.unpack(R,a,top)
187
- end
188
- return table.unpack(R,a,a+b-1)
189
- elseif op==FORPREP then
190
- R[a]=R[a]-R[a+2]
191
- pc=pc+b
192
- elseif op==FORLOOP then
193
- R[a]=R[a]+R[a+2]
194
- local idx=R[a]
195
- local lim=R[a+1]
196
- local step=R[a+2]
197
- local cont=false
198
- if step>=0 then
199
- if idx<=lim then
200
- cont=true
201
- end
202
- else
203
- if idx>=lim then
204
- cont=true
205
- end
206
- end
207
- if cont then
208
- R[a+3]=idx
209
- pc=pc+b
210
- end
211
- elseif op==TFORCALL then
212
- local rets=table.pack(R[a](R[a+1],R[a+2]))
213
- for j=1,b do
214
- R[a+2+j]=rets[j]
215
- end
216
- elseif op==TFORLOOP then
217
- if R[a+3]~=nil then
218
- R[a+2]=R[a+3]
219
- else
220
- pc=pc+b
221
- end
222
- elseif op==CLOSURE then
223
- local Q=P.t[b]
224
- local nu={}
225
- for j=1,#Q.u do
226
- local sp=Q.u[j]
227
- if sp[1]==1 then
228
- local rg=sp[2]
229
- if not open[rg] then
230
- open[rg]={R=R,i=rg}
231
- end
232
- nu[j]=open[rg]
233
- else
234
- nu[j]=U[sp[2]]
235
- end
236
- end
237
- R[a]=function(...)
238
- return V(Q,nu,table.pack(...))
239
- end
240
- elseif op==VARARG then
241
- if b<0 then
242
- for j=1,#VA do
243
- R[a+j-1]=VA[j]
244
- end
245
- top=a+#VA-1
246
- else
247
- for j=1,b do
248
- R[a+j-1]=VA[j]
249
- end
250
- end
251
- elseif op==SETLIST then
252
- for j=1,c do
253
- R[a][j]=R[b+j-1]
254
- end
255
- elseif op==GETUPVAL then
256
- R[a]=G(U[b])
257
- elseif op==SETUPVAL then
258
- S(U[b],R[a])
259
- elseif op==CLOSE then
260
- if open[a] then
261
- C(open[a])
262
- open[a]=nil
263
- end
264
- local v=R[a]
265
- if type(v)=="table" then
266
- local mt=getmetatable(v)
267
- local cl=v.close
268
- if not cl then
269
- if mt then
270
- cl=mt.__close
271
- end
272
- end
273
- if cl then
274
- pcall(cl,v)
275
- end
276
- end
277
- end
278
- end
279
- end
280
- V(${R},{},table.pack())
281
- end)()`}
@@ -1,2 +0,0 @@
1
- import type { Chunk } from "./ast";
2
- export declare function wrapInFunction(chunk: Chunk): void;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.wrapInFunction=t;function t(e){const r=e.body;e.body=[{type:"CallStat",exp:{type:"CallExpr",callee:{type:"ParenExpr",exp:{type:"FuncExpr",params:[],vararg:!0,body:{type:"Block",body:r}}},args:[{type:"VarargExpr"}]}}]}
package/dist/packager.js DELETED
@@ -1 +0,0 @@
1
- "use strict";var s=exports&&exports.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),f=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),u=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var r=[];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[r.length]=i);return r},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var r=t(e),i=0;i<r.length;i++)r[i]!=="default"&&s(n,e,r[i]);return f(n,e),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.packageProject=b;const l=require("child_process"),a=u(require("fs-extra")),c=u(require("path")),_=require("util"),d=require("./build"),E=(0,_.promisify)(l.execFile),o={ENCRYPT_TIMEOUT:3e4,BUNDLE_NAME:"ms.msbundle",ENCRYPTED_BUNDLE_NAME:"enc.msbundle"};function w(){return c.resolve(__dirname,"..")}function h(){const t=process.platform,e=process.arch;let n;if(t==="darwin")n=c.join("bin","mac","ms-bundle-enc");else if(t==="win32"&&e==="x64")n=c.join("bin","win","ms-bundle-enc.exe");else throw new Error(`\u4E0D\u652F\u6301\u7684\u7CFB\u7EDF\u5E73\u53F0: ${t}-${e}`);return c.join(w(),n)}async function p(t){const e=h();if(!await a.pathExists(e))throw new Error(`\u672A\u627E\u5230\u52A0\u5BC6\u5DE5\u5177: ${e}`);process.platform==="win32"||await a.chmod(e,493),await E(e,[t],{cwd:c.dirname(t),timeout:o.ENCRYPT_TIMEOUT});const r=c.join(c.dirname(t),o.ENCRYPTED_BUNDLE_NAME);if(!await a.pathExists(r))throw new Error("\u52A0\u5BC6\u5DE5\u5177\u672A\u751F\u6210 enc.msbundle \u6587\u4EF6");return await a.remove(t),r}async function b(t){await(0,d.buildAll)(!1,t);const e=c.join(t,"dist",o.BUNDLE_NAME);if(!await a.pathExists(e))throw new Error(`\u6784\u5EFA\u5931\u8D25\uFF0C\u672A\u627E\u5230 ${o.BUNDLE_NAME} \u6587\u4EF6`);return p(e)}
package/dist/project.js DELETED
@@ -1 +0,0 @@
1
- "use strict";var D=exports&&exports.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var s=Object.getOwnPropertyDescriptor(e,r);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,s)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),F=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),v=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var n=[];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[n.length]=s);return n},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var n=t(e),s=0;s<n.length;s++)n[s]!=="default"&&D(r,e,n[s]);return F(r,e),r}})(),I=exports&&exports.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getScreenshotOnDevice=C,exports.getScreenshotBase64OnDevice=U,exports.getSourceOnDevice=k,exports.getCurrentLogLinesOnDevice=A,exports.runOnDevice=z,exports.runUIOnDevice=G,exports.stopOnDevice=V;const f=v(require("fs-extra")),w=v(require("path")),T=require("./build"),N=I(require("crc")),h=require("./ws-manager");function g(t){const e=t.ip?.trim(),r=(t.port??"9800").trim(),n=Number.parseInt(r,10);if(!e)throw new Error("\u8BF7\u901A\u8FC7 --ip \u6307\u5B9A\u8BBE\u5907 IP \u5730\u5740");if(!Number.isInteger(n)||n<1||n>65535)throw new Error(`\u65E0\u6548\u7AEF\u53E3: ${r}`);return{ip:e,port:n}}function q(t){const e=(t.wsPort??"31111").trim(),r=(t.wsWaitMs??"30000").trim(),n=Number.parseInt(e,10),s=Number.parseInt(r,10);if(!Number.isInteger(n)||n<1||n>65535)throw new Error(`\u65E0\u6548 ws \u7AEF\u53E3: ${e}`);if(!Number.isInteger(s)||s<1)throw new Error(`\u65E0\u6548 ws \u7B49\u5F85\u65F6\u95F4: ${r}`);return{wsPort:n,wsWaitMs:s}}function d(t){const e=(t.transport??"http").trim().toLowerCase();if(e!=="http"&&e!=="ws")throw new Error(`\u65E0\u6548 transport: ${e}`);return e}async function j(t){const e=await f.readFile(t);return N.default.crc32(e).toString(16).padStart(8,"0")}async function b(t,e){const r=[];async function n(s){const c=await f.readdir(s,{withFileTypes:!0});for(const i of c){const o=w.join(s,i.name);if(i.isDirectory())await n(o);else if(i.isFile()){const a=w.relative(t,o).replace(/\\/g,"/"),l=await f.stat(o);r.push({path:o,bundlePath:`${e}/${a}`,size:l.size,crc32:await j(o)})}}}return await f.pathExists(t)&&await n(t),r}async function E(t){const e=w.join(t,"package.json"),r=await f.readJSON(e),n=r.name,s=r.appVersion;if(!n)throw new Error("\u8BF7\u5728 package.json \u4E2D\u6DFB\u52A0 name \u5B57\u6BB5");if(!s)throw new Error("\u8BF7\u5728 package.json \u4E2D\u6DFB\u52A0 appVersion \u5B57\u6BB5");return{projectName:n,appVersion:s,packageJsonPath:e}}async function _(t){let e=w.join(t,"dist","scripts");const r=await f.pathExists(w.join(t,"scripts","main.py")),n=await f.pathExists(w.join(t,"scripts","main.lua"));(r||n)&&(e=w.join(t,"scripts"));const s=w.join(t,"ui"),c=w.join(t,"res"),i=w.join(t,"package.json"),o=[{path:i,bundlePath:"package.json",size:(await f.stat(i)).size,crc32:await j(i)}],[a,l,u]=await Promise.all([b(e,"scripts"),b(s,"ui"),b(c,"res")]);return o.push(...a,...l,...u),o}async function O(t){await(0,T.buildAll)(!0,t)}async function B(t,e,r){const n=new URL(`http://${t}:${e}/api/files`);n.searchParams.set("projectName",r);const s=await fetch(n.toString(),{method:"GET"});if(!s.ok)throw new Error(`\u6587\u4EF6\u5217\u8868\u8BF7\u6C42\u5931\u8D25: ${s.statusText}`);const c=await s.json();return Array.isArray(c)?c:[]}async function L(t){const e=await h.WSManager.request("files",{projectName:t});if(!e.success)throw new Error(`\u6587\u4EF6\u5217\u8868\u8BF7\u6C42\u5931\u8D25: ${String(e.message??"unknown")}`);const r=e.data;return Array.isArray(r)?r:[]}async function M(t,e,r){const{projectName:n,appVersion:s}=await E(t);console.log("\u{1F50E} \u6B63\u5728\u83B7\u53D6\u8BBE\u5907\u6587\u4EF6\u5217\u8868...");const c=await B(e,r,n),i=new Map(c.map(u=>[u.path,u]));console.log("\u{1F4C2} \u6B63\u5728\u5206\u6790\u9879\u76EE\u6587\u4EF6...");const o=await _(t),a=[];for(const u of o){const p=i.get(u.bundlePath),y=u.bundlePath.includes("main.js")||u.bundlePath.includes("main.py")||u.bundlePath.includes("main.lua");if(!p){a.push(u);continue}const S=p.size!==u.size||p.crc32.toLowerCase()!==u.crc32.toLowerCase();(y||S)&&a.push(u)}if(console.log(`\u{1F4E6} \u53D1\u73B0 ${a.length} \u4E2A\u6587\u4EF6\u9700\u8981\u540C\u6B65`),a.length===0){console.log("\u2705 \u65E0\u9700\u540C\u6B65\u6587\u4EF6");return}let l=0;for(const u of a){l+=1,console.log(`\u2B06\uFE0F [${l}/${a.length}] \u540C\u6B65 ${u.bundlePath}`);const p=await f.readFile(u.path),y=new URL(`http://${e}:${r}/debug/patchSync`);y.searchParams.set("path",u.bundlePath),y.searchParams.set("projectName",n),y.searchParams.set("appVersion",s);const S=await fetch(y.toString(),{method:"POST",headers:{"Content-Type":"application/octet-stream"},body:p});if(!S.ok)throw new Error(`\u540C\u6B65\u5931\u8D25: ${u.bundlePath} (\u72B6\u6001\u7801: ${S.status})`)}console.log(`\u2705 \u540C\u6B65\u5B8C\u6210\uFF0C\u5171 ${a.length} \u4E2A\u6587\u4EF6`)}async function W(t){const{projectName:e,appVersion:r}=await E(t);console.log("\u{1F50E} \u6B63\u5728\u83B7\u53D6\u8BBE\u5907\u6587\u4EF6\u5217\u8868...");const n=await L(e),s=new Map(n.map(a=>[a.path,a]));console.log("\u{1F4C2} \u6B63\u5728\u5206\u6790\u9879\u76EE\u6587\u4EF6...");const c=await _(t),i=[];for(const a of c){const l=s.get(a.bundlePath),u=a.bundlePath.includes("main.js")||a.bundlePath.includes("main.py")||a.bundlePath.includes("main.lua");if(!l){i.push(a);continue}const p=l.size!==a.size||l.crc32.toLowerCase()!==a.crc32.toLowerCase();(u||p)&&i.push(a)}if(console.log(`\u{1F4E6} \u53D1\u73B0 ${i.length} \u4E2A\u6587\u4EF6\u9700\u8981\u540C\u6B65`),i.length===0){console.log("\u2705 \u65E0\u9700\u540C\u6B65\u6587\u4EF6");return}let o=0;for(const a of i){o+=1,console.log(`\u2B06\uFE0F [${o}/${i.length}] \u540C\u6B65 ${a.bundlePath}`);const l=await f.readFile(a.path),u=await h.WSManager.request("patchSync",{path:a.bundlePath,data:l.toString("base64"),projectName:e,appVersion:r});if(!u.success)throw new Error(`\u540C\u6B65\u5931\u8D25: ${a.bundlePath} ${String(u.message??"")}`)}console.log(`\u2705 \u540C\u6B65\u5B8C\u6210\uFF0C\u5171 ${i.length} \u4E2A\u6587\u4EF6`)}async function m(t,e,r){const n=`http://${e}:${r}/api/${t}`,s=await fetch(n,{method:"GET"});if(!s.ok)throw new Error(`${t} \u5931\u8D25\uFF0C\u72B6\u6001\u7801: ${s.status}`)}async function C(t){if(d(t)==="ws"){await $(t);const o=await h.WSManager.request("screenshot");if(!o.success||typeof o.data!="string")throw new Error(`\u622A\u56FE\u5931\u8D25: ${String(o.message??"unknown")}`);return Buffer.from(o.data,"base64")}const{ip:r,port:n}=g(t),s=`http://${r}:${n}/api/screenshot`,c=await fetch(s,{method:"GET"});if(!c.ok)throw new Error(`\u622A\u56FE\u5931\u8D25\uFF0C\u72B6\u6001\u7801: ${c.status}`);const i=await c.arrayBuffer();return Buffer.from(i)}async function U(t){if(d(t)==="ws"){await $(t);const o=await h.WSManager.request("screenshot");if(!o.success||typeof o.data!="string")throw new Error(`\u622A\u56FE(base64)\u5931\u8D25: ${String(o.message??"unknown")}`);return o.data}const{ip:r,port:n}=g(t),s=`http://${r}:${n}/api/screenshotBase64`,c=await fetch(s,{method:"GET"});if(!c.ok)throw new Error(`\u622A\u56FE(base64)\u5931\u8D25\uFF0C\u72B6\u6001\u7801: ${c.status}`);const i=await c.json();if(!i.success||typeof i.data!="string")throw new Error(`\u622A\u56FE(base64)\u5931\u8D25: ${String(i.message??"unknown")}`);return i.data}async function k(t,e=50,r=120,n=1){const s=d(t);if(!Number.isInteger(e)||e<1)throw new Error(`\u65E0\u6548 maxDepth: ${e}`);if(!Number.isInteger(r)||r<1)throw new Error(`\u65E0\u6548 timeout: ${r}`);if(!Number.isInteger(n)||n!==1&&n!==2&&n!==3)throw new Error(`\u65E0\u6548 mode: ${n}`);if(s==="ws"){await $(t);const l=await h.WSManager.request("source",{max_depth:e,timeout:r,maxDepth:e,mode:n});if(!l.success||typeof l.data!="string")throw new Error(`\u83B7\u53D6\u8282\u70B9\u5931\u8D25: ${String(l.message??"unknown")}`);return l.data}const{ip:c,port:i}=g(t),o=new URL(`http://${c}:${i}/api/source`);o.searchParams.set("max_depth",String(e)),o.searchParams.set("timeout",String(r)),o.searchParams.set("mode",String(n));const a=await fetch(o.toString(),{method:"GET"});if(!a.ok)throw new Error(`\u83B7\u53D6\u8282\u70B9\u5931\u8D25\uFF0C\u72B6\u6001\u7801: ${a.status}`);return a.text()}async function A(t,e=200){if(d(t)!=="http")throw new Error("\u83B7\u53D6\u65E5\u5FD7\u5931\u8D25: \u5F53\u524D\u65E5\u5FD7\u884C\u63A5\u53E3\u4EC5\u652F\u6301 http \u4F20\u8F93");if(!Number.isInteger(e)||e<1||e>5e3)throw new Error(`\u83B7\u53D6\u65E5\u5FD7\u5931\u8D25: \u65E0\u6548 count ${e}`);const{ip:n,port:s}=g(t),c=new URL(`http://${n}:${s}/logger/current/lines`);c.searchParams.set("count",String(e));const i=await fetch(c.toString(),{method:"GET"});if(i.status===404)return{lines:[],hasMore:!1};if(!i.ok)throw new Error(`\u83B7\u53D6\u65E5\u5FD7\u5931\u8D25\uFF0C\u72B6\u6001\u7801: ${i.status}`);const o=await i.json();return{lines:Array.isArray(o.lines)?o.lines.map(a=>String(a)):[],hasMore:o.hasMore===!0}}async function P(t){const e=await h.WSManager.request(t);if(!e.success)throw new Error(`${t} \u5931\u8D25: ${String(e.message??"unknown")}`)}async function $(t){const{wsPort:e,wsWaitMs:r}=q(t),n=h.WSManager.get();n.isStarted()||await n.start(e),h.WSManager.isConnected()||(console.log("\u231B \u7B49\u5F85\u8BBE\u5907\u901A\u8FC7 WS \u8FDE\u63A5..."),await n.waitForClient(r))}async function z(t){const e=t.workspacePath?w.resolve(t.workspacePath):process.cwd(),r=d(t);if(console.log(`\u{1F527} \u5F00\u59CB\u6784\u5EFA\u9879\u76EE: ${e}`),await O(e),r==="ws"){await $(t),console.log("\u{1F4E6} \u5F00\u59CB\u901A\u8FC7 WS \u540C\u6B65\u9879\u76EE\u5230\u8BBE\u5907"),await W(e),console.log("\u{1F680} \u5F00\u59CB\u901A\u8FC7 WS \u8FD0\u884C\u9879\u76EE"),await P("run"),console.log("\u2705 \u8FD0\u884C\u8BF7\u6C42\u5DF2\u53D1\u9001");return}const{ip:n,port:s}=g(t);console.log(`\u{1F4E6} \u5F00\u59CB\u540C\u6B65\u9879\u76EE\u5230\u8BBE\u5907: ${n}:${s}`),await M(e,n,s),console.log(`\u{1F680} \u5F00\u59CB\u8FD0\u884C\u9879\u76EE: ${n}:${s}`),await m("run",n,s),console.log("\u2705 \u8FD0\u884C\u8BF7\u6C42\u5DF2\u53D1\u9001")}async function G(t){const e=t.workspacePath?w.resolve(t.workspacePath):process.cwd(),r=d(t);if(console.log(`\u{1F527} \u5F00\u59CB\u6784\u5EFA\u9879\u76EE: ${e}`),await O(e),r==="ws"){await $(t),console.log("\u{1F4E6} \u5F00\u59CB\u901A\u8FC7 WS \u540C\u6B65\u9879\u76EE\u5230\u8BBE\u5907"),await W(e),console.log("\u{1F5BC}\uFE0F \u5F00\u59CB\u901A\u8FC7 WS \u9884\u89C8 UI"),await P("runUI"),console.log("\u2705 UI \u9884\u89C8\u8BF7\u6C42\u5DF2\u53D1\u9001");return}const{ip:n,port:s}=g(t);console.log(`\u{1F4E6} \u5F00\u59CB\u540C\u6B65\u9879\u76EE\u5230\u8BBE\u5907: ${n}:${s}`),await M(e,n,s),console.log(`\u{1F5BC}\uFE0F \u5F00\u59CB\u9884\u89C8 UI: ${n}:${s}`),await m("runUI",n,s),console.log("\u2705 UI \u9884\u89C8\u8BF7\u6C42\u5DF2\u53D1\u9001")}async function V(t){if(d(t)==="ws"){await $(t),console.log("\u{1F6D1} \u5F00\u59CB\u901A\u8FC7 WS \u505C\u6B62\u9879\u76EE"),await P("stop"),console.log("\u2705 \u505C\u6B62\u8BF7\u6C42\u5DF2\u53D1\u9001");return}const{ip:r,port:n}=g(t);console.log(`\u{1F6D1} \u5F00\u59CB\u505C\u6B62\u9879\u76EE: ${r}:${n}`),await m("stop",r,n),console.log("\u2705 \u505C\u6B62\u8BF7\u6C42\u5DF2\u53D1\u9001")}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes