ms-vite-plugin 1.4.71 → 1.4.73

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addVararg=c;function s(r){r.vararg=!0,t(r.body.body)}function a(r){switch(r.type){case"FuncExpr":s(r);break;case"UnaryExpr":a(r.arg);break;case"BinaryExpr":a(r.left),a(r.right);break;case"TableExpr":for(const e of r.fields)e.kind==="index"&&a(e.key),a(e.value);break;case"IndexExpr":a(r.object),a(r.index);break;case"MemberExpr":a(r.object);break;case"CallExpr":a(r.callee);for(const e of r.args)a(e);break;case"MethodCallExpr":a(r.object);for(const e of r.args)a(e);break;case"ParenExpr":a(r.exp);break;default:break}}function t(r){for(const e of r)switch(e.type){case"DoStat":case"WhileStat":case"RepeatStat":case"ForNumStat":case"ForInStat":if(e.type==="WhileStat"&&a(e.cond),e.type==="RepeatStat"&&a(e.cond),e.type==="ForNumStat"&&(a(e.start),a(e.end),e.step&&a(e.step)),e.type==="ForInStat")for(const o of e.exps)a(o);t(e.body.body);break;case"IfStat":for(const o of e.clauses)a(o.cond),t(o.body.body);e.elseBody&&t(e.elseBody.body);break;case"FuncStat":case"LocalFuncStat":s(e.func);break;case"LocalStat":if(e.exps)for(const o of e.exps)a(o);break;case"AssignStat":for(const o of e.vars)a(o);for(const o of e.exps)a(o);break;case"CallStat":a(e.exp);break;case"ReturnStat":for(const o of e.exps)a(o);break;default:break}}function c(r){t(r.body)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addVararg=c;function s(o){o.vararg=!0,t(o.body.body)}function a(o){switch(o.type){case"FuncExpr":s(o);break;case"UnaryExpr":a(o.arg);break;case"BinaryExpr":a(o.left),a(o.right);break;case"TableExpr":for(const e of o.fields)e.kind==="index"&&a(e.key),a(e.value);break;case"IndexExpr":a(o.object),a(o.index);break;case"MemberExpr":a(o.object);break;case"CallExpr":a(o.callee);for(const e of o.args)a(e);break;case"MethodCallExpr":a(o.object);for(const e of o.args)a(e);break;case"ParenExpr":a(o.exp);break;default:break}}function t(o){for(const e of o)switch(e.type){case"DoStat":case"WhileStat":case"RepeatStat":case"ForNumStat":case"ForInStat":if(e.type==="WhileStat"&&a(e.cond),e.type==="RepeatStat"&&a(e.cond),e.type==="ForNumStat"&&(a(e.start),a(e.end),e.step&&a(e.step)),e.type==="ForInStat")for(const r of e.exps)a(r);t(e.body.body);break;case"IfStat":for(const r of e.clauses)a(r.cond),t(r.body.body);e.elseBody&&t(e.elseBody.body);break;case"FuncStat":case"LocalFuncStat":s(e.func);break;case"LocalStat":if(e.exps)for(const r of e.exps)a(r);break;case"AssignStat":for(const r of e.vars)a(r);for(const r of e.exps)a(r);break;case"CallStat":a(e.exp);break;case"ReturnStat":for(const r of e.exps)a(r);break;default:break}}function c(o){t(o.body)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.flattenControlFlow=C;function m(t){return{type:"NumberLiteral",raw:String(t),value:t}}function p(t){return{type:"NameExpr",name:t}}function f(t,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 n(t,s,e){t.states.get(s).push(e)}function F(t,s){for(const e of t)if(e.type==="LocalStat")for(const a of e.names)s.push(a.name);else if(e.type==="LocalFuncStat")s.push(e.name);else if(e.type==="ForNumStat")s.push(e.name),F(e.body.body,s);else if(e.type==="ForInStat")s.push(...e.names),F(e.body.body,s);else if(e.type==="DoStat"||e.type==="WhileStat"||e.type==="RepeatStat")F(e.body.body,s);else if(e.type==="IfStat"){for(const a of e.clauses)F(a.body.body,s);e.elseBody&&F(e.elseBody.body,s)}}function h(t,s,e,a){if(t.length===0)return s;const y=t.map(()=>x(e));for(let o=0;o<t.length;o+=1){const r=t[o];r.type==="LabelStat"&&e.userLabels.set(r.name,y[o])}for(let o=0;o<t.length;o+=1){const r=o+1<t.length?y[o+1]:s;I(e,y[o],t[o],r,a)}return y[0]}function I(t,s,e,a,y){switch(e.type){case"EmptyStat":case"LabelStat":n(t,s,u(t,a));return;case"AssignStat":case"CallStat":case"FuncStat":n(t,s,e),n(t,s,u(t,a));return;case"LocalStat":e.exps&&e.exps.length>0&&n(t,s,f(e.names.map(o=>o.name),e.exps)),n(t,s,u(t,a));return;case"LocalFuncStat":n(t,s,f([e.name],[e.func])),n(t,s,u(t,a));return;case"ReturnStat":n(t,s,e);return;case"BreakStat":n(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}::`);n(t,s,u(t,o));return}case"DoStat":n(t,s,u(t,h(e.body.body,a,t,y)));return;case"IfStat":{const o=S(t);let r=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,a,t,y);let i=a;b?e.elseBody&&(i=h(e.elseBody.body,a,t,y)):i=x(t),n(t,r,f([o],[e.clauses[l].cond])),n(t,r,u(t,k(o,d,i))),b||(r=i)}e.clauses.length===0&&n(t,s,u(t,a));return}case"WhileStat":{const o=S(t),r=h(e.body.body,s,t,a);n(t,s,f([o],[e.cond])),n(t,s,u(t,k(o,r,a)));return}case"RepeatStat":{const o=S(t),r=x(t),l=h(e.body.body,r,t,a);n(t,s,u(t,l)),n(t,r,f([o],[e.cond])),n(t,r,u(t,k(o,a,l)));return}case"ForNumStat":{const o=e.name,r=S(t),l=S(t),b=S(t),d=x(t),i=x(t),L=x(t),g=x(t),N=h(e.body.body,g,t,a);n(t,s,f([o],[e.start])),n(t,s,f([r],[e.end])),n(t,s,f([l],[e.step??m(1)])),n(t,s,u(t,d)),n(t,d,f([b],[E(">=",p(l),m(0))])),n(t,d,u(t,k(b,i,L))),n(t,i,f([b],[E("<=",p(o),p(r))])),n(t,i,u(t,k(b,N,a))),n(t,L,f([b],[E(">=",p(o),p(r))])),n(t,L,u(t,k(b,N,a))),n(t,g,f([o],[E("+",p(o),p(l))])),n(t,g,u(t,d));return}case"ForInStat":{const o=S(t),r=S(t),l=S(t),b=S(t),d=x(t),i=[f([l],[p(e.names[0])]),...e.body.body],L=h(i,d,t,a),g=e.exps.slice();for(;g.length<3;)g.push({type:"NilLiteral"});n(t,s,f([o,r,l],g.slice(0,3))),n(t,s,u(t,d)),n(t,d,{type:"AssignStat",vars:e.names.map(N=>p(N)),exps:[{type:"CallExpr",callee:p(o),args:[p(r),p(l)]}]}),n(t,d,f([b],[E("~=",p(e.names[0]),{type:"NilLiteral"})])),n(t,d,u(t,k(b,L,a)));return}default:n(t,s,u(t,a))}}function v(t,s){const e=t.slice();let a=s>>>0||1;for(let y=e.length-1;y>0;y-=1){a=Math.imul(a,1664525)+1013904223>>>0;const o=a%(y+1),r=e[y];e[y]=e[o],e[o]=r}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},a=[];F(t,a);const y=h(t,0,e,0),o=[...new Set([...a,...e.temps,e.stateName])],r=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:r}]}}]}function c(t,s){switch(t.type){case"FuncExpr":B(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 B(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 a of e.exps)c(a,s);B(e.body.body,s);break;case"IfStat":for(const a of e.clauses)c(a.cond,s),B(a.body.body,s);e.elseBody&&B(e.elseBody.body,s);break;case"FuncStat":case"LocalFuncStat":B(e.func.body.body,s),e.func.body.body=w(e.func.body.body,s);break;case"LocalStat":if(e.exps)for(const a of e.exps)c(a,s);break;case"AssignStat":for(const a of e.vars)c(a,s);for(const a of e.exps)c(a,s);break;case"CallStat":c(e.exp,s);break;case"ReturnStat":for(const a of e.exps)c(a,s);break;default:break}}function C(t,s){B(t.body,s),t.body=w(t.body,s)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.flattenControlFlow=C;function m(t){return{type:"NumberLiteral",raw:String(t),value:t}}function p(t){return{type:"NameExpr",name:t}}function f(t,n){return{type:"AssignStat",vars:t.map(e=>p(e)),exps:n}}function u(t,n){return f([t.stateName],[typeof n=="number"?m(n):n])}function k(t,n,e){return{type:"BinaryExpr",op:"or",left:{type:"BinaryExpr",op:"and",left:p(t),right:m(n)},right:m(e)}}function E(t,n,e){return{type:"BinaryExpr",op:t,left:n,right:e}}function S(t){const n=`__t${t.nextTemp}`;return t.nextTemp+=1,t.temps.push(n),n}function x(t){const n=t.nextState;return t.nextState+=1,t.states.set(n,[]),n}function o(t,n,e){t.states.get(n).push(e)}function F(t,n){for(const e of t)if(e.type==="LocalStat")for(const a of e.names)n.push(a.name);else if(e.type==="LocalFuncStat")n.push(e.name);else if(e.type==="ForNumStat")n.push(e.name),F(e.body.body,n);else if(e.type==="ForInStat")n.push(...e.names),F(e.body.body,n);else if(e.type==="DoStat"||e.type==="WhileStat"||e.type==="RepeatStat")F(e.body.body,n);else if(e.type==="IfStat"){for(const a of e.clauses)F(a.body.body,n);e.elseBody&&F(e.elseBody.body,n)}}function h(t,n,e,a){if(t.length===0)return n;const y=t.map(()=>x(e));for(let s=0;s<t.length;s+=1){const r=t[s];r.type==="LabelStat"&&e.userLabels.set(r.name,y[s])}for(let s=0;s<t.length;s+=1){const r=s+1<t.length?y[s+1]:n;I(e,y[s],t[s],r,a)}return y[0]}function I(t,n,e,a,y){switch(e.type){case"EmptyStat":case"LabelStat":o(t,n,u(t,a));return;case"AssignStat":case"CallStat":case"FuncStat":o(t,n,e),o(t,n,u(t,a));return;case"LocalStat":e.exps&&e.exps.length>0&&o(t,n,f(e.names.map(s=>s.name),e.exps)),o(t,n,u(t,a));return;case"LocalFuncStat":o(t,n,f([e.name],[e.func])),o(t,n,u(t,a));return;case"ReturnStat":o(t,n,e);return;case"BreakStat":o(t,n,u(t,y));return;case"GotoStat":{const s=t.userLabels.get(e.name);if(s===void 0)throw new Error(`goto \u672A\u5B9A\u4E49\u6807\u7B7E ::${e.name}::`);o(t,n,u(t,s));return}case"DoStat":o(t,n,u(t,h(e.body.body,a,t,y)));return;case"IfStat":{const s=S(t);let r=n;for(let l=0;l<e.clauses.length;l+=1){const b=l===e.clauses.length-1,d=h(e.clauses[l].body.body,a,t,y);let i=a;b?e.elseBody&&(i=h(e.elseBody.body,a,t,y)):i=x(t),o(t,r,f([s],[e.clauses[l].cond])),o(t,r,u(t,k(s,d,i))),b||(r=i)}e.clauses.length===0&&o(t,n,u(t,a));return}case"WhileStat":{const s=S(t),r=h(e.body.body,n,t,a);o(t,n,f([s],[e.cond])),o(t,n,u(t,k(s,r,a)));return}case"RepeatStat":{const s=S(t),r=x(t),l=h(e.body.body,r,t,a);o(t,n,u(t,l)),o(t,r,f([s],[e.cond])),o(t,r,u(t,k(s,a,l)));return}case"ForNumStat":{const s=e.name,r=S(t),l=S(t),b=S(t),d=x(t),i=x(t),L=x(t),g=x(t),N=h(e.body.body,g,t,a);o(t,n,f([s],[e.start])),o(t,n,f([r],[e.end])),o(t,n,f([l],[e.step??m(1)])),o(t,n,u(t,d)),o(t,d,f([b],[E(">=",p(l),m(0))])),o(t,d,u(t,k(b,i,L))),o(t,i,f([b],[E("<=",p(s),p(r))])),o(t,i,u(t,k(b,N,a))),o(t,L,f([b],[E(">=",p(s),p(r))])),o(t,L,u(t,k(b,N,a))),o(t,g,f([s],[E("+",p(s),p(l))])),o(t,g,u(t,d));return}case"ForInStat":{const s=S(t),r=S(t),l=S(t),b=S(t),d=x(t),i=[f([l],[p(e.names[0])]),...e.body.body],L=h(i,d,t,a),g=e.exps.slice();for(;g.length<3;)g.push({type:"NilLiteral"});o(t,n,f([s,r,l],g.slice(0,3))),o(t,n,u(t,d)),o(t,d,{type:"AssignStat",vars:e.names.map(N=>p(N)),exps:[{type:"CallExpr",callee:p(s),args:[p(r),p(l)]}]}),o(t,d,f([b],[E("~=",p(e.names[0]),{type:"NilLiteral"})])),o(t,d,u(t,k(b,L,a)));return}default:o(t,n,u(t,a))}}function v(t,n){const e=t.slice();let a=n>>>0||1;for(let y=e.length-1;y>0;y-=1){a=Math.imul(a,1664525)+1013904223>>>0;const s=a%(y+1),r=e[y];e[y]=e[s],e[s]=r}return e}function w(t,n){if(t.length===0)return t;const e={states:new Map,temps:[],nextState:1,nextTemp:1,stateName:"__s",userLabels:new Map},a=[];F(t,a);const y=h(t,0,e,0),s=[...new Set([...a,...e.temps,e.stateName])],r=v([...e.states.keys()],n).map(l=>({cond:E("==",p(e.stateName),m(l)),body:{type:"Block",body:e.states.get(l)}}));return[{type:"LocalStat",names:s.map(l=>({name:l}))},f([e.stateName],[m(y)]),{type:"WhileStat",cond:E("~=",p(e.stateName),m(0)),body:{type:"Block",body:[{type:"IfStat",clauses:r}]}}]}function c(t,n){switch(t.type){case"FuncExpr":B(t.body.body,n),t.body.body=w(t.body.body,n);break;case"UnaryExpr":c(t.arg,n);break;case"BinaryExpr":c(t.left,n),c(t.right,n);break;case"TableExpr":for(const e of t.fields)e.kind==="index"&&c(e.key,n),c(e.value,n);break;case"IndexExpr":c(t.object,n),c(t.index,n);break;case"MemberExpr":c(t.object,n);break;case"CallExpr":c(t.callee,n);for(const e of t.args)c(e,n);break;case"MethodCallExpr":c(t.object,n);for(const e of t.args)c(e,n);break;case"ParenExpr":c(t.exp,n);break;default:break}}function B(t,n){for(const e of t)switch(e.type){case"DoStat":case"WhileStat":case"RepeatStat":case"ForNumStat":case"ForInStat":if((e.type==="WhileStat"||e.type==="RepeatStat")&&c(e.cond,n),e.type==="ForNumStat"&&(c(e.start,n),c(e.end,n),e.step&&c(e.step,n)),e.type==="ForInStat")for(const a of e.exps)c(a,n);B(e.body.body,n);break;case"IfStat":for(const a of e.clauses)c(a.cond,n),B(a.body.body,n);e.elseBody&&B(e.elseBody.body,n);break;case"FuncStat":case"LocalFuncStat":B(e.func.body.body,n),e.func.body.body=w(e.func.body.body,n);break;case"LocalStat":if(e.exps)for(const a of e.exps)c(a,n);break;case"AssignStat":for(const a of e.vars)c(a,n);for(const a of e.exps)c(a,n);break;case"CallStat":c(e.exp,n);break;case"ReturnStat":for(const a of e.exps)c(a,n);break;default:break}}function C(t,n){B(t.body,n),t.body=w(t.body,n)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.shortName=a,exports.renameLocals=c;const u=require("./reserved"),d=require("./scope"),l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function a(r){let e=r,t="";do t=l[e%l.length]+t,e=Math.floor(e/l.length)-1;while(e>=0);return u.luaKeywords.has(t)?`_${t}`:t}function c(r){let e=0;const t=new Set;(0,d.collectAndRename)(r,(o,s)=>{if(o.newName!==o.original)return;let n=a(e);for(e+=1;s.has(n)||t.has(n)||u.luaKeywords.has(n);)n=a(e),e+=1;o.newName=n,t.add(n),s.add(n)})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.shortName=r,exports.renameLocals=c;const u=require("./reserved"),d=require("./scope"),l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function r(a){let e=a,t="";do t=l[e%l.length]+t,e=Math.floor(e/l.length)-1;while(e>=0);return u.luaKeywords.has(t)?`_${t}`:t}function c(a){let e=0;const t=new Set;(0,d.collectAndRename)(a,(o,s)=>{if(o.newName!==o.original)return;let n=r(e);for(e+=1;s.has(n)||t.has(n)||u.luaKeywords.has(n);)n=r(e),e+=1;o.newName=n,t.add(n),s.add(n)})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveLocal=i,exports.collectAndRename=x;function i(t,s){let r=t;for(;r;){const e=r.locals.get(s);if(e)return e;r=r.parent}}function c(t){return{parent:t,locals:new Map}}function f(t,s){const r=t.locals.get(s);if(r)return r;const e={original:s,newName:s};return t.locals.set(s,e),e}function x(t,s){const r=new Set,e={locals:new Map};d(t.body,e,r,s)}function l(t,s,r,e){d(t.body,s,r,e)}function d(t,s,r,e){for(const o of t)b(o,s,r,e)}function m(t,s,r,e){const o=c(s),a=t.params.slice();for(let u=0;u<a.length;u+=1){const p=f(o,a[u]);e(p,r),t.params[u]=p.newName}l(t.body,o,r,e)}function b(t,s,r,e){switch(t.type){case"EmptyStat":case"BreakStat":case"GotoStat":case"LabelStat":return;case"DoStat":l(t.body,c(s),r,e);return;case"WhileStat":n(t.cond,s,r,e),l(t.body,c(s),r,e);return;case"RepeatStat":{const o=c(s);l(t.body,o,r,e),n(t.cond,o,r,e);return}case"IfStat":for(const o of t.clauses)n(o.cond,s,r,e),l(o.body,c(s),r,e);t.elseBody&&l(t.elseBody,c(s),r,e);return;case"ForNumStat":{n(t.start,s,r,e),n(t.end,s,r,e),t.step&&n(t.step,s,r,e);const o=c(s),a=f(o,t.name);e(a,r),t.name=a.newName,l(t.body,o,r,e);return}case"ForInStat":{for(const a of t.exps)n(a,s,r,e);const o=c(s);for(let a=0;a<t.names.length;a+=1){const u=f(o,t.names[a]);e(u,r),t.names[a]=u.newName}l(t.body,o,r,e);return}case"FuncStat":{const o=i(s,t.name.base);o&&(t.name.base=o.newName),m(t.func,s,r,e);return}case"LocalFuncStat":{const o=f(s,t.name);e(o,r),t.name=o.newName,m(t.func,s,r,e);return}case"LocalStat":if(t.exps)for(const o of t.exps)n(o,s,r,e);for(let o=0;o<t.names.length;o+=1){const a=f(s,t.names[o].name);e(a,r),t.names[o].name=a.newName}return;case"AssignStat":for(const o of t.vars)n(o,s,r,e);for(const o of t.exps)n(o,s,r,e);return;case"CallStat":n(t.exp,s,r,e);return;case"ReturnStat":for(const o of t.exps)n(o,s,r,e);return}}function n(t,s,r,e){switch(t.type){case"NilLiteral":case"BoolLiteral":case"NumberLiteral":case"StringLiteral":case"VarargExpr":return;case"NameExpr":{const o=i(s,t.name);o&&(t.name=o.newName);return}case"UnaryExpr":n(t.arg,s,r,e);return;case"BinaryExpr":n(t.left,s,r,e),n(t.right,s,r,e);return;case"FuncExpr":m(t,s,r,e);return;case"TableExpr":for(const o of t.fields)o.kind==="index"&&n(o.key,s,r,e),n(o.value,s,r,e);return;case"IndexExpr":n(t.object,s,r,e),n(t.index,s,r,e);return;case"MemberExpr":n(t.object,s,r,e);return;case"CallExpr":n(t.callee,s,r,e);for(const o of t.args)n(o,s,r,e);return;case"MethodCallExpr":n(t.object,s,r,e);for(const o of t.args)n(o,s,r,e);return;case"ParenExpr":n(t.exp,s,r,e);return}}
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}}
@@ -84,31 +84,6 @@ const uuid = device.getDeviceID();
84
84
  logi(`设备ID: ${uuid}`);
85
85
  ```
86
86
 
87
- ### getServerDeviceId - 获取服务器设备 ID。
88
-
89
- **注意事项:**
90
-
91
- - 这个 ID 卸载重装后,只要签名没变,就不会改变。
92
- - 如果要取唯一 ID 建议使用这个。
93
-
94
- ```typescript
95
- function getServerDeviceId(): string;
96
- ```
97
-
98
- **返回值:**
99
-
100
- | 类型 | 描述 |
101
- | -------- | ------------------- |
102
- | `string` | 服务器分配的设备 ID |
103
-
104
- **示例:**
105
-
106
- ```typescript
107
- // 获取服务器设备ID
108
- const serverDeviceId = device.getServerDeviceId();
109
- logi(`服务器设备ID: ${serverDeviceId}`);
110
- ```
111
-
112
87
  ### getECID - 获取设备 ECID。
113
88
 
114
89
  ```typescript
@@ -365,11 +340,6 @@ device.setVolume(0.5);
365
340
 
366
341
  ### getOrientation - 获取屏幕方向。
367
342
 
368
- **注意事项**
369
-
370
- - 该方法返回的方向,是靠截屏方法来更新的,如果没有截屏,该方法返回的方向可能是不准确的。
371
- - 该方法取到的方向可能不准,建议使用截屏,靠截屏的图片宽高来确定方向
372
-
373
343
  ```typescript
374
344
  function getOrientation(): "PORTRAIT" | "LANDSCAPE";
375
345
  ```
package/docs/api/image.md CHANGED
@@ -809,6 +809,66 @@ if (scaled.length > 0) {
809
809
  // const baseScale = expectedTargetWidthPx / templateWidthPx;
810
810
  ```
811
811
 
812
+ ### findImageEx - 按 kjst 找图
813
+
814
+ 用图色工具 Ex 导出的 `.kjst` 在大图上查找目标。模板、预处理、搜索区域和工作分辨率都写在 kjst 里,脚本只传大图和文件名。
815
+
816
+ 适合跨机分辨率:kjst 保存了制作时的工作宽高,运行时把当前图先缩放到该尺寸再匹配,返回的坐标已经换算回传入图(`screen` 即屏幕)像素,可直接 `action.click`。
817
+
818
+ ```typescript
819
+ function findImageEx(
820
+ imageId: string,
821
+ kjstPath: string,
822
+ ): {
823
+ index: number;
824
+ x: number;
825
+ y: number;
826
+ width: number;
827
+ height: number;
828
+ confidence: number;
829
+ centerX: number;
830
+ centerY: number;
831
+ ex: number;
832
+ ey: number;
833
+ text?: string; // 仅 OCR 命中
834
+ }[];
835
+ ```
836
+
837
+ **参数:**
838
+
839
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
840
+ | ----------- | ------ | -------- | ------ | -------------------------------------------------------------------------------------------- |
841
+ | `imageId` | string | 是 | - | `"screen"`-当前屏幕截图,或图片 ID / 路径,语义与 `findImage` 相同 |
842
+ | `kjstPath` | string | 是 | - | `res` 下的 kjst 文件名,例如 `"login.kjst"`。不要带 `res/` 前缀,也不要传手机绝对路径 |
843
+
844
+ **返回值:**
845
+
846
+ | 类型 | 描述 |
847
+ | ------- | --------------------------------------------------------------------------------------------- |
848
+ | `array` | 命中矩形数组,字段与 `findImage` 相同。OCR 命中额外含 `text`。未找到或 kjst 无效时返回空数组 |
849
+
850
+ **说明:**
851
+
852
+ - 在 VS Code 图色工具 Ex 里制作 kjst,保存到项目 `res`。
853
+ - kjst 内可包含灰度、二值化、颜色反转、区域过滤,以及模板匹配 / OCR。预处理按顺序作用在图上;遇到模板匹配或 OCR 时,有命中立刻返回,没有命中才继续后面的步骤。
854
+ - 不要把 kjst 当普通图片路径传给 `findImage`。
855
+
856
+ **示例:**
857
+
858
+ ```javascript
859
+ const hits = image.findImageEx("screen", "login.kjst");
860
+ if (hits.length > 0) {
861
+ const hit = hits[0];
862
+ logi(hit.x, hit.y, hit.confidence);
863
+ action.click(hit.centerX, hit.centerY, 100, false);
864
+ }
865
+
866
+ const ocrHits = image.findImageEx("screen", "code.kjst");
867
+ if (ocrHits.length > 0 && ocrHits[0].text) {
868
+ logi(ocrHits[0].text);
869
+ }
870
+ ```
871
+
812
872
  ## 图像处理
813
873
 
814
874
  ### clip - 裁剪图片。
package/docs/api/ui.md CHANGED
@@ -627,6 +627,35 @@ setInterval(checkAgentStatus, 5000);
627
627
 
628
628
  ### 系统功能
629
629
 
630
+ #### getDeviceID - 获取设备 ID
631
+
632
+ ```typescript
633
+ declare function getDeviceID(): Promise<string>;
634
+ ```
635
+
636
+ **返回值:**
637
+
638
+ | 类型 | 描述 |
639
+ | ----------------- | ---------------- |
640
+ | `Promise<string>` | 设备的唯一标识符 |
641
+
642
+ **说明:**
643
+
644
+ 获取当前设备的唯一标识符。卸载重装 APP 后会改变,更新 APP 后不会改变。
645
+
646
+ **网页端示例:**
647
+
648
+ ```javascript
649
+ // 获取设备ID
650
+ ms.getDeviceID()
651
+ .then((deviceId) => {
652
+ console.log("当前设备ID:", deviceId);
653
+ })
654
+ .catch((error) => {
655
+ console.error("获取设备ID出错:", error);
656
+ });
657
+ ```
658
+
630
659
  #### getServerDeviceId - 获取服务器设备 ID
631
660
 
632
661
  ```typescript
package/docs/api/yolo.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # YOLO 目标检测模块 (YOLO)
2
2
 
3
- YOLO 模块基于 YOLOV8/YOLO11/YOLO26 算法和 NCNN 框架,提供高性能的实时目标检测功能,支持多种输入源和自定义模型,可用于物体识别、位置定位等应用场景。
3
+ YOLO 模块基于 YOLOV5/YOLOV8/YOLO11/YOLO26 算法和 NCNN 框架,提供高性能的实时目标检测功能,支持多种输入源和自定义模型,可用于物体识别、位置定位等应用场景。
4
4
 
5
5
  ## 数据标注
6
6
 
@@ -8,7 +8,7 @@ YOLO 模块基于 YOLOV8/YOLO11/YOLO26 算法和 NCNN 框架,提供高性能
8
8
 
9
9
  ## 功能概览
10
10
 
11
- - **模型管理**: YOLOV8/YOLOV11/YOLOV26 模型加载和资源管理
11
+ - **模型管理**: YOLOV5/YOLOV8/YOLOV11/YOLOV26 模型加载和资源管理
12
12
  - **目标检测**: 实时物体检测和位置识别
13
13
  - **多源输入**: 支持屏幕截图、图片文件、URL 等多种输入源
14
14
  - **结果处理**: 完整的检测结果信息和坐标数据
@@ -59,7 +59,7 @@ interface YoloResult {
59
59
 
60
60
  ### 模型管理
61
61
 
62
- #### load - 加载 YOLO 模型(支持版本 8/11/26)
62
+ #### load - 加载 YOLO 模型(支持版本 5/8/11/26)
63
63
 
64
64
  加载模型是使用目标检测功能的前提。
65
65
 
@@ -80,7 +80,7 @@ function load(
80
80
  | `paramPath` | string | 是 | | NCNN 模型的 param 文件绝对路径 |
81
81
  | `binPath` | string | 是 | | NCNN 模型的 bin 文件绝对路径 |
82
82
  | `nc` | number | 否 | 0 | 模型的标签数量;传 `0` 或省略时根据模型输出自动推断,显式传入但不匹配时检测返回空数组 |
83
- | `version` | number | 否 | 11 | YOLO 模型版本号(仅支持 8/11/26|
83
+ | `version` | number | 否 | 11 | YOLO 模型版本号(仅支持 5/8/11/26)。`5` 为官方 YOLOv5 6.0/6.2/7.0,兼容官方 export 单输出和三头原始特征 |
84
84
  | `useGpu` | boolean | 否 | false | 是否启用 GPU 加速 |
85
85
 
86
86
  **返回值:**
@@ -84,31 +84,6 @@ const uuid = $设备.获取设备ID();
84
84
  $打印信息日志(`设备ID: ${uuid}`);
85
85
  ```
86
86
 
87
- ### 获取服务器设备 ID
88
-
89
- **注意事项:**
90
-
91
- - 这个 ID 卸载重装后,只要签名没变,就不会改变。
92
- - 如果要取唯一 ID 建议使用这个。
93
-
94
- ```typescript
95
- function 获取服务器设备ID(): 字符串;
96
- ```
97
-
98
- **返回值:**
99
-
100
- | 类型 | 描述 |
101
- | -------- | ------------------- |
102
- | `字符串` | 服务器分配的设备 ID |
103
-
104
- **示例:**
105
-
106
- ```typescript
107
- // 获取服务器设备ID
108
- const serverDeviceId = $设备.获取服务器设备ID();
109
- $打印信息日志(`服务器设备ID: ${serverDeviceId}`);
110
- ```
111
-
112
87
  ### 获取 ECID
113
88
 
114
89
  ```typescript
@@ -820,6 +820,66 @@ if (缩放匹配.length > 0) {
820
820
  // const baseScale = 预期目标宽度px / 模板宽度px;
821
821
  ```
822
822
 
823
+ ### 找图Ex - 按 kjst 找图
824
+
825
+ 用图色工具 Ex 导出的 `.kjst` 在大图上查找目标。模板、预处理、搜索区域和工作分辨率都写在 kjst 里,脚本只传大图和文件名。
826
+
827
+ 适合跨机分辨率:kjst 保存了制作时的工作宽高,运行时把当前图先缩放到该尺寸再匹配,返回的坐标已经换算回传入图(`screen` 即屏幕)像素,可直接 `$动作.点击`。
828
+
829
+ ```typescript
830
+ function 找图Ex(
831
+ 图片ID: 字符串,
832
+ kjst路径: 字符串,
833
+ ): {
834
+ index: 数字;
835
+ x: 数字;
836
+ y: 数字;
837
+ width: 数字;
838
+ height: 数字;
839
+ confidence: 数字;
840
+ centerX: 数字;
841
+ centerY: 数字;
842
+ ex: 数字;
843
+ ey: 数字;
844
+ text?: 字符串; // 仅 OCR 命中
845
+ }[];
846
+ ```
847
+
848
+ **参数:**
849
+
850
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
851
+ | ---------- | ------ | -------- | ------ | ------------------------------------------------------------------------------------- |
852
+ | `图片ID` | 字符串 | 是 | - | `"screen"`-当前屏幕截图,或图片 ID / 路径,语义与 `找图` 相同 |
853
+ | `kjst路径` | 字符串 | 是 | - | `res` 下的 kjst 文件名,例如 `"login.kjst"`。不要带 `res/` 前缀,也不要传手机绝对路径 |
854
+
855
+ **返回值:**
856
+
857
+ | 类型 | 描述 |
858
+ | ------ | ------------------------------------------------------------------------------------------ |
859
+ | `数组` | 命中矩形数组,字段与 `找图` 相同。OCR 命中额外含 `text`。未找到或 kjst 无效时返回空数组 |
860
+
861
+ **说明:**
862
+
863
+ - 在 VS Code 图色工具 Ex 里制作 kjst,保存到项目 `res`。
864
+ - kjst 内可包含灰度、二值化、颜色反转、区域过滤,以及模板匹配 / OCR。预处理按顺序作用在图上;遇到模板匹配或 OCR 时,有命中立刻返回,没有命中才继续后面的步骤。
865
+ - 不要把 kjst 当普通图片路径传给 `找图`。
866
+
867
+ **示例:**
868
+
869
+ ```javascript
870
+ const 命中 = $图片.找图Ex("screen", "login.kjst");
871
+ if (命中.length > 0) {
872
+ const hit = 命中[0];
873
+ $打印信息日志(hit.x, hit.y, hit.confidence);
874
+ $动作.点击(hit.centerX, hit.centerY, 100, false);
875
+ }
876
+
877
+ const ocr命中 = $图片.找图Ex("screen", "code.kjst");
878
+ if (ocr命中.length > 0 && ocr命中[0].text) {
879
+ $打印信息日志(ocr命中[0].text);
880
+ }
881
+ ```
882
+
823
883
  ## 图像处理
824
884
 
825
885
  ### 裁剪图片
package/docs/apicn/ui.md CHANGED
@@ -615,6 +615,35 @@ setInterval(checkAgentStatus, 5000);
615
615
 
616
616
  ### 系统功能
617
617
 
618
+ #### getDeviceID() - 获取设备 ID
619
+
620
+ ```typescript
621
+ declare function getDeviceID(): Promise<string>;
622
+ ```
623
+
624
+ **返回值:**
625
+
626
+ | 类型 | 描述 |
627
+ | ----------------- | ---------------- |
628
+ | `Promise<string>` | 设备的唯一标识符 |
629
+
630
+ **说明:**
631
+
632
+ 获取当前设备的唯一标识符。卸载重装 APP 后会改变,更新 APP 后不会改变。
633
+
634
+ **网页端示例:**
635
+
636
+ ```javascript
637
+ // 获取设备ID
638
+ ms.getDeviceID()
639
+ .then((deviceId) => {
640
+ console.log("当前设备ID:", deviceId);
641
+ })
642
+ .catch((error) => {
643
+ console.error("获取设备ID出错:", error);
644
+ });
645
+ ```
646
+
618
647
  #### getServerDeviceId() - 获取服务器设备 ID
619
648
 
620
649
  ```typescript
@@ -1,6 +1,6 @@
1
1
  # YOLO 目标检测模块 ($YOLO)
2
2
 
3
- YOLO 模块基于 YOLOV8/YOLO11/YOLO26 算法和 NCNN 框架,提供高性能的实时目标检测功能,支持多种输入源和自定义模型,可用于物体识别、位置定位等应用场景。
3
+ YOLO 模块基于 YOLOV5/YOLOV8/YOLO11/YOLO26 算法和 NCNN 框架,提供高性能的实时目标检测功能,支持多种输入源和自定义模型,可用于物体识别、位置定位等应用场景。
4
4
 
5
5
  ## 数据标注
6
6
 
@@ -8,7 +8,7 @@ YOLO 模块基于 YOLOV8/YOLO11/YOLO26 算法和 NCNN 框架,提供高性能
8
8
 
9
9
  ## 功能概览
10
10
 
11
- - **模型管理**: YOLOV8/YOLOV11/YOLOV26 模型加载和资源管理
11
+ - **模型管理**: YOLOV5/YOLOV8/YOLOV11/YOLOV26 模型加载和资源管理
12
12
  - **目标检测**: 实时物体检测和位置识别
13
13
  - **多源输入**: 支持屏幕截图、图片文件、URL 等多种输入源
14
14
  - **结果处理**: 完整的检测结果信息和坐标数据
@@ -59,7 +59,7 @@ interface Yolo检测结果 {
59
59
 
60
60
  ### 模型管理
61
61
 
62
- #### 加载模型 - 加载 YOLO 模型(支持版本 8/11/26)
62
+ #### 加载模型 - 加载 YOLO 模型(支持版本 5/8/11/26)
63
63
 
64
64
  加载模型是使用目标检测功能的前提。
65
65
 
@@ -80,7 +80,7 @@ function 加载模型(
80
80
  | `ncnn模型的param文件路径` | 字符串 | 是 | | NCNN 模型的 param 文件绝对路径 |
81
81
  | `ncnn模型的bin文件路径` | 字符串 | 是 | | NCNN 模型的 bin 文件绝对路径 |
82
82
  | `标签数量` | 数字 | 否 | 0 | 模型的标签数量;传 `0` 或省略时根据模型输出自动推断,显式传入但不匹配时检测返回空数组 |
83
- | `模型版本` | 数字 | 否 | 11 | YOLO 模型版本号(仅支持 8/11/26|
83
+ | `模型版本` | 数字 | 否 | 11 | YOLO 模型版本号(仅支持 5/8/11/26)。`5` 为官方 YOLOv5 6.0/6.2/7.0,兼容官方 export 单输出和三头原始特征 |
84
84
  | `useGpu` | 布尔值 | 否 | false | 是否启用 GPU 加速 |
85
85
 
86
86
  **返回值:**
@@ -82,32 +82,6 @@ local uuid = device.getDeviceID()
82
82
  print("设备ID = " .. tostring(uuid))
83
83
  ```
84
84
 
85
- ### getServerDeviceId - 获取服务器设备 ID。
86
-
87
- **注意事项:**
88
-
89
- - 这个 ID 卸载重装后,只要签名没变,就不会改变。
90
- - 如果要取唯一 ID 建议使用这个。
91
-
92
- ```lua
93
- ---@return string
94
- function getServerDeviceId() end
95
- ```
96
-
97
- **返回值:**
98
-
99
- | 类型 | 描述 |
100
- | -------- | ------------------- |
101
- | `string` | 服务器分配的设备 ID |
102
-
103
- **示例:**
104
-
105
- ```lua
106
- -- 获取服务器设备ID
107
- local serverDeviceId = device.getServerDeviceId()
108
- print("服务器设备ID = " .. tostring(serverDeviceId))
109
- ```
110
-
111
85
  ### getECID - 获取设备 ECID。
112
86
 
113
87
  ```lua
@@ -371,11 +345,6 @@ device.setVolume(0.5)
371
345
 
372
346
  ### getOrientation - 获取屏幕方向。
373
347
 
374
- **注意事项**
375
-
376
- - 该方法返回的方向,是靠截屏方法来更新的,如果没有截屏,该方法返回的方向可能是不准确的。
377
- - 该方法取到的方向可能不准,建议使用截屏,靠截屏的图片宽高来确定方向
378
-
379
348
  ```lua
380
349
  ---@return string
381
350
  function getOrientation() end
@@ -819,6 +819,54 @@ end
819
819
  -- local baseScale = expectedTargetWidthPx / templateWidthPx
820
820
  ```
821
821
 
822
+ ### findImageEx - 按 kjst 找图
823
+
824
+ 用图色工具 Ex 导出的 `.kjst` 在大图上查找目标。模板、预处理、搜索区域和工作分辨率都写在 kjst 里,脚本只传大图和文件名。
825
+
826
+ 适合跨机分辨率:kjst 保存了制作时的工作宽高,运行时把当前图先缩放到该尺寸再匹配,返回的坐标已经换算回传入图(`screen` 即屏幕)像素,可直接 `action.click`。
827
+
828
+ ```lua
829
+ ---@param id string
830
+ ---@param kjstPath string
831
+ ---@return table
832
+ function findImageEx(id, kjstPath) end
833
+ ```
834
+
835
+ **参数:**
836
+
837
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
838
+ | ----------- | ------ | -------- | ------ | -------------------------------------------------------------------------------------------- |
839
+ | `id` | string | 是 | - | `"screen"`-当前屏幕截图,或图片 ID / 路径,语义与 `findImage` 相同 |
840
+ | `kjstPath` | string | 是 | - | `res` 下的 kjst 文件名,例如 `"login.kjst"`。不要带 `res/` 前缀,也不要传手机绝对路径 |
841
+
842
+ **返回值:**
843
+
844
+ | 类型 | 描述 |
845
+ | ------ | --------------------------------------------------------------------------------------------- |
846
+ | `table` | 命中矩形数组,字段与 `findImage` 相同。OCR 命中额外含 `text`。未找到或 kjst 无效时返回空表。下标从 1 开始 |
847
+
848
+ **说明:**
849
+
850
+ - 在 VS Code 图色工具 Ex 里制作 kjst,保存到项目 `res`。
851
+ - kjst 内可包含灰度、二值化、颜色反转、区域过滤,以及模板匹配 / OCR。预处理按顺序作用在图上;遇到模板匹配或 OCR 时,有命中立刻返回,没有命中才继续后面的步骤。
852
+ - 不要把 kjst 当普通图片路径传给 `findImage`。
853
+
854
+ **示例:**
855
+
856
+ ```lua
857
+ local hits = image.findImageEx("screen", "login.kjst")
858
+ if #hits > 0 then
859
+ local hit = hits[1]
860
+ print(hit.x, hit.y, hit.confidence)
861
+ action.click(hit.centerX, hit.centerY, 100, false)
862
+ end
863
+
864
+ local ocrHits = image.findImageEx("screen", "code.kjst")
865
+ if #ocrHits > 0 and ocrHits[1].text then
866
+ print(ocrHits[1].text)
867
+ end
868
+ ```
869
+
822
870
  ## 图像处理
823
871
 
824
872
  ### clip - 裁剪图片。
package/docs/apilua/ui.md CHANGED
@@ -679,6 +679,35 @@ setInterval(checkAgentStatus, 5000);
679
679
 
680
680
  ### 系统功能
681
681
 
682
+ #### getDeviceID - 获取设备 ID
683
+
684
+ ```typescript
685
+ declare function getDeviceID(): Promise<string>;
686
+ ```
687
+
688
+ **返回值:**
689
+
690
+ | 类型 | 描述 |
691
+ | ----------------- | ---------------- |
692
+ | `Promise<string>` | 设备的唯一标识符 |
693
+
694
+ **说明:**
695
+
696
+ 获取当前设备的唯一标识符。卸载重装 APP 后会改变,更新 APP 后不会改变。
697
+
698
+ **网页端示例:**
699
+
700
+ ```javascript
701
+ // 获取设备ID
702
+ ms.getDeviceID()
703
+ .then((deviceId) => {
704
+ console.log("当前设备ID:", deviceId);
705
+ })
706
+ .catch((error) => {
707
+ console.error("获取设备ID出错:", error);
708
+ });
709
+ ```
710
+
682
711
  #### getServerDeviceId - 获取服务器设备 ID
683
712
 
684
713
  ```typescript
@@ -2,7 +2,7 @@
2
2
 
3
3
  模块表是内置全局 `yolo`,直接调用即可。不要 `require` 宿主模块。
4
4
 
5
- YOLO 模块基于 YOLOV8/YOLO11/YOLO26 算法和 NCNN 框架,提供高性能的实时目标检测功能,支持多种输入源和自定义模型,可用于物体识别、位置定位等应用场景。
5
+ YOLO 模块基于 YOLOV5/YOLOV8/YOLO11/YOLO26 算法和 NCNN 框架,提供高性能的实时目标检测功能,支持多种输入源和自定义模型,可用于物体识别、位置定位等应用场景。
6
6
 
7
7
  ## 数据标注
8
8
 
@@ -10,7 +10,7 @@ YOLO 模块基于 YOLOV8/YOLO11/YOLO26 算法和 NCNN 框架,提供高性能
10
10
 
11
11
  ## 功能概览
12
12
 
13
- - **模型管理**: YOLOV8/YOLOV11/YOLOV26 模型加载和资源管理
13
+ - **模型管理**: YOLOV5/YOLOV8/YOLOV11/YOLOV26 模型加载和资源管理
14
14
  - **目标检测**: 实时物体检测和位置识别
15
15
  - **多源输入**: 支持屏幕截图、图片文件、URL 等多种输入源
16
16
  - **结果处理**: 完整的检测结果信息和坐标数据
@@ -60,7 +60,7 @@ YOLO 检测结果接口,包含检测到的物体的完整信息。
60
60
 
61
61
  ### 模型管理
62
62
 
63
- #### load - 加载 YOLO 模型(支持版本 8/11/26)。
63
+ #### load - 加载 YOLO 模型(支持版本 5/8/11/26)。
64
64
 
65
65
  加载模型是使用目标检测功能的前提。
66
66
 
@@ -81,7 +81,7 @@ function load(paramPath, binPath, nc, version, useGpu) end
81
81
  | `paramPath` | string | 是 | | NCNN 模型的 param 文件绝对路径 |
82
82
  | `binPath` | string | 是 | | NCNN 模型的 bin 文件绝对路径 |
83
83
  | `nc` | number | 否 | 0 | 模型的标签数量;传 `0` 或省略时根据模型输出自动推断,显式传入但不匹配时检测返回空数组 |
84
- | `version` | number | 否 | 11 | YOLO 模型版本号(仅支持 8/11/26|
84
+ | `version` | number | 否 | 11 | YOLO 模型版本号(仅支持 5/8/11/26)。`5` 为官方 YOLOv5 6.0/6.2/7.0,兼容官方 export 单输出和三头原始特征 |
85
85
  | `useGpu` | boolean | 否 | false | 是否启用 GPU 加速 |
86
86
 
87
87
  **返回值:**
@@ -92,29 +92,6 @@ from kuaijs import device
92
92
  print(device.getDeviceID())
93
93
  ```
94
94
 
95
- ### getServerDeviceId - 获取服务器设备 ID。
96
-
97
- ```python
98
- def getServerDeviceId() -> str
99
- ```
100
-
101
- **注意事项:**
102
-
103
- - 卸载重装后只要签名不变,该 ID 不变;如需唯一 ID 推荐使用此方法
104
-
105
- **返回值:**
106
-
107
- | 类型 | 描述 |
108
- | ----- | ----------------- |
109
- | `str` | 服务器分配设备 ID |
110
-
111
- **示例:**
112
-
113
- ```python
114
- from kuaijs import device
115
- print(device.getServerDeviceId())
116
- ```
117
-
118
95
  ### getECID - 获取设备 ECID。
119
96
 
120
97
  ```python
@@ -362,10 +339,6 @@ device.setVolume(0.5)
362
339
 
363
340
  ### getOrientation - 获取屏幕方向。
364
341
 
365
- **注意事项:**
366
-
367
- - 方向依赖截屏更新;若未截屏可能不准确。建议通过截屏宽高判断方向
368
-
369
342
  ```python
370
343
  from typing import Literal
371
344
 
@@ -752,6 +752,51 @@ if len(scaled) > 0:
752
752
  # base_scale = expected_target_width_px / template_width_px
753
753
  ```
754
754
 
755
+ ### findImageEx - 按 kjst 找图
756
+
757
+ 用图色工具 Ex 导出的 `.kjst` 在大图上查找目标。模板、预处理、搜索区域和工作分辨率都写在 kjst 里,脚本只传大图和文件名。
758
+
759
+ 适合跨机分辨率:kjst 保存了制作时的工作宽高,运行时把当前图先缩放到该尺寸再匹配,返回的坐标已经换算回传入图(`screen` 即屏幕)像素,可直接 `action.click`。
760
+
761
+ ```python
762
+ def findImageEx(id: str, kjstPath: str) -> List[Rect]
763
+ ```
764
+
765
+ **参数:**
766
+
767
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
768
+ | ----------- | ---- | -------- | ------ | -------------------------------------------------------------------------------------------- |
769
+ | `id` | str | 是 | <br /> | `"screen"`-当前屏幕截图,或图片 ID / 路径,语义与 `findImage` 相同 |
770
+ | `kjstPath` | str | 是 | <br /> | `res` 下的 kjst 文件名,例如 `"login.kjst"`。不要带 `res/` 前缀,也不要传手机绝对路径 |
771
+
772
+ **返回值:**
773
+
774
+ | 类型 | 描述 |
775
+ | ------------ | --------------------------------------------------------------------------------------------- |
776
+ | `List[Rect]` | 命中矩形列表,字段与 `findImage` 相同。OCR 命中额外含 `text`。未找到或 kjst 无效时返回空列表 |
777
+
778
+ **说明:**
779
+
780
+ - 在 VS Code 图色工具 Ex 里制作 kjst,保存到项目 `res`。
781
+ - kjst 内可包含灰度、二值化、颜色反转、区域过滤,以及模板匹配 / OCR。预处理按顺序作用在图上;遇到模板匹配或 OCR 时,有命中立刻返回,没有命中才继续后面的步骤。
782
+ - 不要把 kjst 当普通图片路径传给 `findImage`。
783
+
784
+ **示例:**
785
+
786
+ ```python
787
+ from kuaijs import image, action
788
+
789
+ hits = image.findImageEx("screen", "login.kjst")
790
+ if hits:
791
+ hit = hits[0]
792
+ print(hit.x, hit.y, hit.confidence)
793
+ action.click(hit.centerX, hit.centerY, 100, False)
794
+
795
+ ocr_hits = image.findImageEx("screen", "code.kjst")
796
+ if ocr_hits and ocr_hits[0].text:
797
+ print(ocr_hits[0].text)
798
+ ```
799
+
755
800
  ## 图像处理
756
801
 
757
802
  ### clip - 裁剪图片。
@@ -640,6 +640,35 @@ setInterval(checkAgentStatus, 5000);
640
640
 
641
641
  ### 系统功能
642
642
 
643
+ #### getDeviceID - 获取设备 ID
644
+
645
+ ```typescript
646
+ declare function getDeviceID(): Promise<string>;
647
+ ```
648
+
649
+ **返回值:**
650
+
651
+ | 类型 | 描述 |
652
+ | ----------------- | ---------------- |
653
+ | `Promise<string>` | 设备的唯一标识符 |
654
+
655
+ **说明:**
656
+
657
+ 获取当前设备的唯一标识符。卸载重装 APP 后会改变,更新 APP 后不会改变。
658
+
659
+ **网页端示例:**
660
+
661
+ ```javascript
662
+ // 获取设备ID
663
+ ms.getDeviceID()
664
+ .then((deviceId) => {
665
+ console.log("当前设备ID:", deviceId);
666
+ })
667
+ .catch((error) => {
668
+ console.error("获取设备ID出错:", error);
669
+ });
670
+ ```
671
+
643
672
  #### getServerDeviceId - 获取服务器设备 ID
644
673
 
645
674
  ```typescript
@@ -1,6 +1,6 @@
1
1
  # YOLO 目标检测模块 (YOLO)
2
2
 
3
- YOLO 模块基于 YOLOV8/YOLO11/YOLO26 算法和 NCNN 框架,提供高性能的实时目标检测功能,支持多种输入源和自定义模型,可用于物体识别、位置定位等应用场景。
3
+ YOLO 模块基于 YOLOV5/YOLOV8/YOLO11/YOLO26 算法和 NCNN 框架,提供高性能的实时目标检测功能,支持多种输入源和自定义模型,可用于物体识别、位置定位等应用场景。
4
4
 
5
5
  ## 数据标注
6
6
 
@@ -8,7 +8,7 @@ YOLO 模块基于 YOLOV8/YOLO11/YOLO26 算法和 NCNN 框架,提供高性能
8
8
 
9
9
  ## 功能概览
10
10
 
11
- - **模型管理**: YOLOV8/YOLOV11/YOLOV26 模型加载和资源管理
11
+ - **模型管理**: YOLOV5/YOLOV8/YOLOV11/YOLOV26 模型加载和资源管理
12
12
  - **目标检测**: 实时物体检测和位置识别
13
13
  - **多源输入**: 支持屏幕截图、图片文件、URL 等多种输入源
14
14
  - **结果处理**: 完整的检测结果信息和坐标数据
@@ -60,7 +60,7 @@ class YoloResult(KuaiJSNamespace):
60
60
 
61
61
  ### 模型管理
62
62
 
63
- #### load - 加载 YOLO 模型(支持版本 8/11/26)
63
+ #### load - 加载 YOLO 模型(支持版本 5/8/11/26)
64
64
 
65
65
  加载模型是使用目标检测功能的前提。
66
66
 
@@ -75,7 +75,7 @@ def load(paramPath: str, binPath: str, nc: int = 0, version: int = 11, useGpu: b
75
75
  | `paramPath` | str | 是 | - | NCNN 模型的 param 文件绝对路径 |
76
76
  | `binPath` | str | 是 | - | NCNN 模型的 bin 文件绝对路径 |
77
77
  | `nc` | int | 否 | 0 | 模型的标签数量;传 `0` 或省略时根据模型输出自动推断,显式传入但不匹配时检测返回空列表 |
78
- | `version` | int | 否 | 11 | YOLO 模型版本号(仅支持 8/11/26|
78
+ | `version` | int | 否 | 11 | YOLO 模型版本号(仅支持 5/8/11/26)。`5` 为官方 YOLOv5 6.0/6.2/7.0,兼容官方 export 单输出和三头原始特征 |
79
79
  | `useGpu` | bool | 否 | False | 是否启用 GPU 加速 |
80
80
 
81
81
  **返回值:**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-vite-plugin",
3
- "version": "1.4.71",
3
+ "version": "1.4.73",
4
4
  "type": "commonjs",
5
5
  "license": "MIT",
6
6
  "publishConfig": {