ms-vite-plugin 1.4.77 → 1.4.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/luaObfuscator/addVararg.js +1 -1
- package/dist/luaObfuscator/flatten.js +1 -1
- package/dist/luaObfuscator/rename.js +1 -1
- package/dist/luaObfuscator/scope.js +1 -1
- package/docs/api/global.md +0 -134
- package/docs/api/image.md +72 -111
- package/docs/apicn/global.md +0 -103
- package/docs/apicn/image.md +63 -104
- package/docs/apilua/global.md +0 -52
- package/docs/apilua/image.md +79 -81
- package/docs/apipython/g.md +0 -128
- package/docs/apipython/image.md +61 -103
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addVararg=c;function s(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addVararg=c;function s(r){r.vararg=!0,t(r.body.body)}function a(r){switch(r.type){case"FuncExpr":s(r);break;case"UnaryExpr":a(r.arg);break;case"BinaryExpr":a(r.left),a(r.right);break;case"TableExpr":for(const e of r.fields)e.kind==="index"&&a(e.key),a(e.value);break;case"IndexExpr":a(r.object),a(r.index);break;case"MemberExpr":a(r.object);break;case"CallExpr":a(r.callee);for(const e of r.args)a(e);break;case"MethodCallExpr":a(r.object);for(const e of r.args)a(e);break;case"ParenExpr":a(r.exp);break;default:break}}function t(r){for(const e of r)switch(e.type){case"DoStat":case"WhileStat":case"RepeatStat":case"ForNumStat":case"ForInStat":if(e.type==="WhileStat"&&a(e.cond),e.type==="RepeatStat"&&a(e.cond),e.type==="ForNumStat"&&(a(e.start),a(e.end),e.step&&a(e.step)),e.type==="ForInStat")for(const o of e.exps)a(o);t(e.body.body);break;case"IfStat":for(const o of e.clauses)a(o.cond),t(o.body.body);e.elseBody&&t(e.elseBody.body);break;case"FuncStat":case"LocalFuncStat":s(e.func);break;case"LocalStat":if(e.exps)for(const o of e.exps)a(o);break;case"AssignStat":for(const o of e.vars)a(o);for(const o of e.exps)a(o);break;case"CallStat":a(e.exp);break;case"ReturnStat":for(const o of e.exps)a(o);break;default:break}}function c(r){t(r.body)}
|
|
@@ -1 +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,
|
|
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=
|
|
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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveLocal=i,exports.collectAndRename=x;function i(t,
|
|
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}}
|
package/docs/api/global.md
CHANGED
|
@@ -307,55 +307,6 @@ takeMeToFront();
|
|
|
307
307
|
logi("应用已切换到前台");
|
|
308
308
|
```
|
|
309
309
|
|
|
310
|
-
### setAgentFastMode
|
|
311
|
-
|
|
312
|
-
设置 Agent 快速模式(兼容旧接口)。开启对应模式 `1`,关闭对应模式 `0`。推荐改用 `setAgentTouchMode`。设置会持久化。
|
|
313
|
-
|
|
314
|
-
```typescript
|
|
315
|
-
function setAgentFastMode(enabled: boolean): boolean;
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
**参数:**
|
|
319
|
-
|
|
320
|
-
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
321
|
-
| --------- | --------- | -------- | ------ | ---------------- |
|
|
322
|
-
| `enabled` | `boolean` | 是 | - | 是否开启快速模式 |
|
|
323
|
-
|
|
324
|
-
**返回值:**
|
|
325
|
-
|
|
326
|
-
| 类型 | 描述 |
|
|
327
|
-
| --------- | -------------------- |
|
|
328
|
-
| `boolean` | 实际是否开启快速模式 |
|
|
329
|
-
|
|
330
|
-
**示例:**
|
|
331
|
-
|
|
332
|
-
```javascript
|
|
333
|
-
const enabled = setAgentFastMode(true);
|
|
334
|
-
logi(`Agent 快速模式: ${enabled}`);
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
### getAgentFastMode
|
|
338
|
-
|
|
339
|
-
获取 Agent 快速模式当前状态(兼容旧接口)。
|
|
340
|
-
|
|
341
|
-
```typescript
|
|
342
|
-
function getAgentFastMode(): boolean;
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
**返回值:**
|
|
346
|
-
|
|
347
|
-
| 类型 | 描述 |
|
|
348
|
-
| --------- | -------------------- |
|
|
349
|
-
| `boolean` | 当前是否开启快速模式 |
|
|
350
|
-
|
|
351
|
-
**示例:**
|
|
352
|
-
|
|
353
|
-
```javascript
|
|
354
|
-
if (getAgentFastMode()) {
|
|
355
|
-
logi("Agent 快速模式已开启");
|
|
356
|
-
}
|
|
357
|
-
```
|
|
358
|
-
|
|
359
310
|
### setAgentTouchMode
|
|
360
311
|
|
|
361
312
|
设置 Agent 触控模式。默认 `1`,设置会持久化。
|
|
@@ -598,91 +549,6 @@ setExceptionCallback(() => {
|
|
|
598
549
|
});
|
|
599
550
|
```
|
|
600
551
|
|
|
601
|
-
### loadDex
|
|
602
|
-
|
|
603
|
-
加载 dex、apk 文件 (仅安卓可用)。
|
|
604
|
-
|
|
605
|
-
```typescript
|
|
606
|
-
function loadDex(path: string): boolean;
|
|
607
|
-
```
|
|
608
|
-
|
|
609
|
-
**参数:**
|
|
610
|
-
|
|
611
|
-
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
612
|
-
| ------ | ------ | -------- | ------ | ----------------- |
|
|
613
|
-
| `path` | string | 是 | - | dex、apk 文件路径 |
|
|
614
|
-
|
|
615
|
-
**返回值:**
|
|
616
|
-
|
|
617
|
-
| 类型 | 描述 |
|
|
618
|
-
| --------- | ------------ |
|
|
619
|
-
| `boolean` | 是否加载成功 |
|
|
620
|
-
|
|
621
|
-
**示例:**
|
|
622
|
-
|
|
623
|
-
```javascript
|
|
624
|
-
const isLoaded = loadDex("/sdcard/classes.dex");
|
|
625
|
-
if (isLoaded) {
|
|
626
|
-
logi("dex 文件加载成功");
|
|
627
|
-
} else {
|
|
628
|
-
loge("dex 文件加载失败");
|
|
629
|
-
}
|
|
630
|
-
```
|
|
631
|
-
|
|
632
|
-
### getContext
|
|
633
|
-
|
|
634
|
-
获取安卓上下文 (仅安卓可用)。
|
|
635
|
-
|
|
636
|
-
```typescript
|
|
637
|
-
function getContext(): any;
|
|
638
|
-
```
|
|
639
|
-
|
|
640
|
-
**返回值:**
|
|
641
|
-
|
|
642
|
-
| 类型 | 描述 |
|
|
643
|
-
| ----- | -------------- |
|
|
644
|
-
| `any` | 当前安卓上下文 |
|
|
645
|
-
|
|
646
|
-
**示例:**
|
|
647
|
-
|
|
648
|
-
```javascript
|
|
649
|
-
const context = getContext();
|
|
650
|
-
logi(`当前安卓上下文: ${context}`);
|
|
651
|
-
```
|
|
652
|
-
|
|
653
|
-
### importClass
|
|
654
|
-
|
|
655
|
-
导入 Java 类 (仅安卓可用)。
|
|
656
|
-
|
|
657
|
-
```typescript
|
|
658
|
-
function importClass(className: string): any;
|
|
659
|
-
```
|
|
660
|
-
|
|
661
|
-
**参数:**
|
|
662
|
-
|
|
663
|
-
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
664
|
-
| ----------- | ------ | -------- | ------ | --------- |
|
|
665
|
-
| `className` | string | 是 | - | Java 类名 |
|
|
666
|
-
|
|
667
|
-
**返回值:**
|
|
668
|
-
|
|
669
|
-
| 类型 | 描述 |
|
|
670
|
-
| ----- | -------------- |
|
|
671
|
-
| `any` | 导入的 Java 类 |
|
|
672
|
-
|
|
673
|
-
**示例:**
|
|
674
|
-
|
|
675
|
-
```javascript
|
|
676
|
-
// 大部分情况下,不需要导入 Java 类,直接使用即可
|
|
677
|
-
const B = new com.a.B();
|
|
678
|
-
logi(`B 类的实例: ${B}`);
|
|
679
|
-
|
|
680
|
-
// 只有在无法直接使用类时,才需要导入 Java 类
|
|
681
|
-
const C = importClass("xxx.a.C");
|
|
682
|
-
const c = new C();
|
|
683
|
-
logi(`创建了 C 类的实例: ${c}`);
|
|
684
|
-
```
|
|
685
|
-
|
|
686
552
|
## 全局日志函数
|
|
687
553
|
|
|
688
554
|
全局日志函数是 `logger` 模块对应方法的便捷别名,可以直接调用而无需 `logger.` 前缀。
|
package/docs/api/image.md
CHANGED
|
@@ -410,18 +410,18 @@ function countColor(
|
|
|
410
410
|
|
|
411
411
|
**参数:**
|
|
412
412
|
|
|
413
|
-
| 参数名 | 类型 | 是否必填 | 默认值 | 描述
|
|
414
|
-
| ----------- | ------ | -------- | ------ |
|
|
415
|
-
| `imageId` | string | 是 | - | 图片 ID,支持 `"screen"`、图片文件路径、HTTP 图片地址或已加载的图片 ID
|
|
413
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
414
|
+
| ----------- | ------ | -------- | ------ | --------------------------------------------------------------------------------- |
|
|
415
|
+
| `imageId` | string | 是 | - | 图片 ID,支持 `"screen"`、图片文件路径、HTTP 图片地址或已加载的图片 ID |
|
|
416
416
|
| `colors` | string | 是 | - | 颜色列表,支持 `主色-偏色\|主色-偏色` 格式,如 `#0A0A0A-#101010\|#FFFFFF-#101010` |
|
|
417
|
-
| `threshold` | number | 是 | - | 颜色匹配阈值 (0.0-1.0),数值越大匹配越严格
|
|
418
|
-
| `x, y` | number | 是 | - | 统计区域左上角坐标
|
|
419
|
-
| `ex, ey` | number | 是 | - | 统计区域右下角坐标;传 `0` 表示延伸到图片右侧或底部边界
|
|
417
|
+
| `threshold` | number | 是 | - | 颜色匹配阈值 (0.0-1.0),数值越大匹配越严格 |
|
|
418
|
+
| `x, y` | number | 是 | - | 统计区域左上角坐标 |
|
|
419
|
+
| `ex, ey` | number | 是 | - | 统计区域右下角坐标;传 `0` 表示延伸到图片右侧或底部边界 |
|
|
420
420
|
|
|
421
421
|
**返回值:**
|
|
422
422
|
|
|
423
|
-
| 类型 | 描述
|
|
424
|
-
| -------- |
|
|
423
|
+
| 类型 | 描述 |
|
|
424
|
+
| -------- | ---------------------------------------------------------------------------------- |
|
|
425
425
|
| `number` | 命中目标颜色的像素数量;图片加载失败、颜色为空、颜色格式无效或区域不合法时返回 `0` |
|
|
426
426
|
|
|
427
427
|
**示例:**
|
|
@@ -524,29 +524,29 @@ function findImage(
|
|
|
524
524
|
|
|
525
525
|
**参数:**
|
|
526
526
|
|
|
527
|
-
| 参数名 | 类型 | 是否必填 | 默认值 | 描述
|
|
528
|
-
| ---------------------- | --------- | -------- | --------------------------- |
|
|
529
|
-
| `imageId` | string | 是 | - | `"screen"`-当前屏幕截图, `string`-图片文件路径或 URL ,`imageId`-图片 ID(通过 image 模块获取)
|
|
530
|
-
| `templateImageId` | string | 是 | - | `"screen"`-当前屏幕截图, `string`-图片文件路径或 URL ,`imageId`-图片 ID(通过 image 模块获取)支持按\|分割,多个图片按顺序查找
|
|
531
|
-
| `x, y` | number | 是 | - | 搜索区域左上角坐标
|
|
532
|
-
| `ex, ey` | number | 是 | - | 搜索区域右下角坐标;传 `0` 表示延伸到图片右侧或底部边界
|
|
533
|
-
| `threshold` | number | 是 | - | 匹配阈值 (0.0-1.0)。method `0`/`99` 建议 `0.5`–`0.6`;普通模板匹配(`1`/`3`/`5`)建议 `0.9`–`0.995`
|
|
534
|
-
| `limit` | number | 是 | - | 最大查找数量,每个模板图片最多找 limit 个匹配结果
|
|
535
|
-
| `method` | number | 是 | - | 匹配方法,见下方说明
|
|
536
|
-
| `rgb` | boolean | 否 | `false` | 是否使用 RGB 找图,默认 `false` 会自动转灰度找图
|
|
537
|
-
| `options` | object | 否 | - | 额外选项。`scaleFactors` 仅 method=`99` 生效;`orz` 用于按方向取结果
|
|
538
|
-
| `options.scaleFactors` | number\[] | 否 | `[1.0, 0.9, 1.1, 0.8, 1.2]` | 仅 method=`99` 生效。模板相对当前图的缩放比列表(**不是** `device.getScreenScale()`)。应按 baseScale 动态计算,见下方详解;默认值只适合尺寸接近时的盲扫
|
|
527
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
528
|
+
| ---------------------- | --------- | -------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
529
|
+
| `imageId` | string | 是 | - | `"screen"`-当前屏幕截图, `string`-图片文件路径或 URL ,`imageId`-图片 ID(通过 image 模块获取) |
|
|
530
|
+
| `templateImageId` | string | 是 | - | `"screen"`-当前屏幕截图, `string`-图片文件路径或 URL ,`imageId`-图片 ID(通过 image 模块获取)支持按\|分割,多个图片按顺序查找 |
|
|
531
|
+
| `x, y` | number | 是 | - | 搜索区域左上角坐标 |
|
|
532
|
+
| `ex, ey` | number | 是 | - | 搜索区域右下角坐标;传 `0` 表示延伸到图片右侧或底部边界 |
|
|
533
|
+
| `threshold` | number | 是 | - | 匹配阈值 (0.0-1.0)。method `0`/`99` 建议 `0.5`–`0.6`;普通模板匹配(`1`/`3`/`5`)建议 `0.9`–`0.995` |
|
|
534
|
+
| `limit` | number | 是 | - | 最大查找数量,每个模板图片最多找 limit 个匹配结果 |
|
|
535
|
+
| `method` | number | 是 | - | 匹配方法,见下方说明 |
|
|
536
|
+
| `rgb` | boolean | 否 | `false` | 是否使用 RGB 找图,默认 `false` 会自动转灰度找图 |
|
|
537
|
+
| `options` | object | 否 | - | 额外选项。`scaleFactors` 仅 method=`99` 生效;`orz` 用于按方向取结果 |
|
|
538
|
+
| `options.scaleFactors` | number\[] | 否 | `[1.0, 0.9, 1.1, 0.8, 1.2]` | 仅 method=`99` 生效。模板相对当前图的缩放比列表(**不是** `device.getScreenScale()`)。应按 baseScale 动态计算,见下方详解;默认值只适合尺寸接近时的盲扫 |
|
|
539
539
|
| `options.orz` | number | 否 | 不传 | 查找方向(1-8),与找色 `orz` 相同。不传或非 1-8 时仍按相似度从高到低返回。传入 1-8 时按该方向取前 `limit` 个达标结果;`limit=1` 时只返回该方向第一个,不会把其余命中都找出来。method `0`(SIFT)会先完成匹配再按方向排序截取 |
|
|
540
540
|
|
|
541
541
|
#### method 匹配方法说明
|
|
542
542
|
|
|
543
|
-
| method | 名称
|
|
544
|
-
| ------ |
|
|
545
|
-
| `5` | TM_CCOEFF_NORMED
|
|
546
|
-
| `3` | TM_CCORR_NORMED
|
|
547
|
-
| `1` | TM_SQDIFF_NORMED
|
|
548
|
-
| `0` | SIFT 全分辨率
|
|
549
|
-
| `99` | 全分辨率缩放匹配法
|
|
543
|
+
| method | 名称 | 原理简述 | 适用场景 | 速度 |
|
|
544
|
+
| ------ | ------------------ | ------------------------------------------------------------------------------------------------ | ------------------------------------------------ | -------- |
|
|
545
|
+
| `5` | TM_CCOEFF_NORMED | 标准模板匹配(归一化相关系数),模板必须与目标**像素尺寸一致** | 同分辨率、同尺寸截图模板,最常用 | 快 |
|
|
546
|
+
| `3` | TM_CCORR_NORMED | 标准模板匹配(归一化相关) | 同尺寸模板;PNG 透明模板带 mask 时内部会优先用它 | 快 |
|
|
547
|
+
| `1` | TM_SQDIFF_NORMED | 标准模板匹配(归一化平方差),分数越小越像,引擎已换算为越大越像 | 同尺寸模板 | 快 |
|
|
548
|
+
| `0` | SIFT 全分辨率 | 提取 SIFT 特征点做匹配,对旋转、轻微形变更鲁棒,不要求模板与目标同尺寸 | 目标可能旋转/形变,或跨分辨率找图 | 较慢 |
|
|
549
|
+
| `99` | 全分辨率缩放匹配法 | 把**模板**按多个比例缩放后,再做 `TM_CCOEFF_NORMED` 模板匹配(有透明通道时用 `TM_CCORR_NORMED`) | 目标与模板尺寸不完全一致,但形状相同 | 中等偏慢 |
|
|
550
550
|
|
|
551
551
|
#### 什么是「缩放」全分辨率找图(method = 99)
|
|
552
552
|
|
|
@@ -605,21 +605,20 @@ baseScale = 屏幕上目标高度(px) / 模板高度(px)
|
|
|
605
605
|
|
|
606
606
|
**数值例子:**
|
|
607
607
|
|
|
608
|
-
| 截模板设备 | 当前运行设备
|
|
609
|
-
| -------------- |
|
|
610
|
-
| iPhone 8 750px | 同机
|
|
611
|
-
| 750 宽 | 1170 宽
|
|
612
|
-
| 1170 宽 | 750 宽
|
|
613
|
-
|
|
|
614
|
-
| 模板按钮 120px | 屏上按钮 96px | 96 / 120 | `0.8` |
|
|
608
|
+
| 截模板设备 | 当前运行设备 | 计算 | baseScale |
|
|
609
|
+
| -------------- | ------------- | ---------- | --------- |
|
|
610
|
+
| iPhone 8 750px | 同机 | 750 / 750 | `1.0` |
|
|
611
|
+
| 750 宽 | 1170 宽 | 1170 / 750 | `1.56` |
|
|
612
|
+
| 1170 宽 | 750 宽 | 750 / 1170 | `0.641` |
|
|
613
|
+
| 模板按钮 120px | 屏上按钮 96px | 96 / 120 | `0.8` |
|
|
615
614
|
|
|
616
615
|
含义对照:
|
|
617
616
|
|
|
618
|
-
| baseScale | 含义
|
|
619
|
-
| --------- |
|
|
620
|
-
| `1.0` | 当前目标与模板同尺寸
|
|
621
|
-
| `0.64` | 当前目标大约是模板的 64%(高分屏模板跑低分)
|
|
622
|
-
| `1.56` | 当前目标大约是模板的 156%(低分屏模板跑高分) | 放大到 156% 再匹配
|
|
617
|
+
| baseScale | 含义 | 引擎会对模板做什么 |
|
|
618
|
+
| --------- | --------------------------------------------- | ------------------ |
|
|
619
|
+
| `1.0` | 当前目标与模板同尺寸 | 不缩放 |
|
|
620
|
+
| `0.64` | 当前目标大约是模板的 64%(高分屏模板跑低分) | 缩到 64% 再匹配 |
|
|
621
|
+
| `1.56` | 当前目标大约是模板的 156%(低分屏模板跑高分) | 放大到 156% 再匹配 |
|
|
623
622
|
|
|
624
623
|
##### 2. 再围绕 baseScale 生成搜索列表
|
|
625
624
|
|
|
@@ -634,14 +633,14 @@ scaleFactors ≈ [ baseScale,
|
|
|
634
633
|
|
|
635
634
|
推荐参数:
|
|
636
635
|
|
|
637
|
-
| 项目 | 建议
|
|
638
|
-
| -------------- |
|
|
639
|
-
| 中心值 | 算出来的 `baseScale`
|
|
640
|
-
| 步进 `step` | `0.05`~`0.1`
|
|
641
|
-
| 半宽度 | `±0.1`~`±0.2`(约 ±10%~20%)
|
|
642
|
-
| 总档数 | 3~7 个
|
|
643
|
-
| 阈值 threshold | `0.5`~`0.6` 起调
|
|
644
|
-
| 顺序 | **baseScale 最先**,再左右交替扩开
|
|
636
|
+
| 项目 | 建议 | 原因 |
|
|
637
|
+
| -------------- | ---------------------------------- | ---------------------------------- |
|
|
638
|
+
| 中心值 | 算出来的 `baseScale` | 最可能命中,必须放第一位 |
|
|
639
|
+
| 步进 `step` | `0.05`~`0.1` | 太疏容易跳过真实尺寸;太密浪费时间 |
|
|
640
|
+
| 半宽度 | `±0.1`~`±0.2`(约 ±10%~20%) | 覆盖状态栏/安全区/轻微布局差 |
|
|
641
|
+
| 总档数 | 3~7 个 | 每多一档就多跑一轮全图模板匹配 |
|
|
642
|
+
| 阈值 threshold | `0.5`~`0.6` 起调 | 缩放插值会降低相关分数,别用 0.9+ |
|
|
643
|
+
| 顺序 | **baseScale 最先**,再左右交替扩开 | 找满 limit 会提前结束 |
|
|
645
644
|
|
|
646
645
|
生成示例(伪代码思路):
|
|
647
646
|
|
|
@@ -670,14 +669,14 @@ const scaleFactors = buildScaleFactors(baseScale);
|
|
|
670
669
|
|
|
671
670
|
##### 3. 按场景怎么选
|
|
672
671
|
|
|
673
|
-
| 场景
|
|
674
|
-
|
|
|
675
|
-
| 模板就是本机截的,尺寸确定一致
|
|
676
|
-
| 已知截图机型与当前机型分辨率
|
|
677
|
-
| 多机型跑同一套模板,分辨率跨度大
|
|
678
|
-
| 完全不知道模板来源分辨率
|
|
679
|
-
| 只要微调(系统字体/显示缩放导致差几像素) | `[1.0, 0.95, 1.05, 0.9, 1.1]`
|
|
680
|
-
| 横竖屏切换 / 目标会旋转
|
|
672
|
+
| 场景 | 怎么设 `scaleFactors` | threshold |
|
|
673
|
+
| ----------------------------------------- | ----------------------------------------------------------------- | --------------- |
|
|
674
|
+
| 模板就是本机截的,尺寸确定一致 | 不必用 99,直接 method `5`;若坚持用 99 则 `[1.0]` | `0.9+` / `0.55` |
|
|
675
|
+
| 已知截图机型与当前机型分辨率 | 算 `baseScale`,再 `±0.05`~`±0.1` 扩 3~5 档 | `0.5`~`0.6` |
|
|
676
|
+
| 多机型跑同一套模板,分辨率跨度大 | 按每台设备运行时动态算 baseScale,不要写死默认那组 | `0.5`~`0.6` |
|
|
677
|
+
| 完全不知道模板来源分辨率 | 先用 method `0`(SIFT);或宽范围粗扫(慢,如 0.5~2.0 步进 0.1) | `0.5` 左右 |
|
|
678
|
+
| 只要微调(系统字体/显示缩放导致差几像素) | `[1.0, 0.95, 1.05, 0.9, 1.1]` | `0.55`~`0.65` |
|
|
679
|
+
| 横竖屏切换 / 目标会旋转 | method `99` **不够**,改用 method `0` SIFT | `0.5`~`0.6` |
|
|
681
680
|
|
|
682
681
|
默认值 `[1.0, 0.9, 1.1, 0.8, 1.2]` 的定位:
|
|
683
682
|
|
|
@@ -707,15 +706,15 @@ const scaleFactors = buildScaleFactors(baseScale);
|
|
|
707
706
|
|
|
708
707
|
##### 5. 与 method `0`(SIFT)怎么选
|
|
709
708
|
|
|
710
|
-
| | method `99` 缩放匹配 | method `0` SIFT
|
|
711
|
-
| -------------- | ---------------------------------- |
|
|
712
|
-
| 尺寸变化 | 支持(靠你提供的比例穷举) | 支持(特征点,不靠固定比例)
|
|
713
|
-
| 你需要知道比例 | 最好先算 baseScale | 不需要
|
|
714
|
-
| 旋转 / 形变 | 基本不支持 | 较鲁棒
|
|
715
|
-
| 阈值建议 | `0.5`–`0.6` | `0.5`–`0.6`
|
|
716
|
-
| 透明 PNG 模板 | 支持(alpha 作权重 mask) | 支持(alpha 作特征掩码)
|
|
717
|
-
| 性能 | 与 factor 数量近似成正比,通常更快 | 特征提取重,通常更慢
|
|
718
|
-
| 推荐 | 比例可估算的跨分辨率找图 | 比例未知、或有旋转/透视时
|
|
709
|
+
| | method `99` 缩放匹配 | method `0` SIFT |
|
|
710
|
+
| -------------- | ---------------------------------- | ---------------------------- |
|
|
711
|
+
| 尺寸变化 | 支持(靠你提供的比例穷举) | 支持(特征点,不靠固定比例) |
|
|
712
|
+
| 你需要知道比例 | 最好先算 baseScale | 不需要 |
|
|
713
|
+
| 旋转 / 形变 | 基本不支持 | 较鲁棒 |
|
|
714
|
+
| 阈值建议 | `0.5`–`0.6` | `0.5`–`0.6` |
|
|
715
|
+
| 透明 PNG 模板 | 支持(alpha 作权重 mask) | 支持(alpha 作特征掩码) |
|
|
716
|
+
| 性能 | 与 factor 数量近似成正比,通常更快 | 特征提取重,通常更慢 |
|
|
717
|
+
| 推荐 | 比例可估算的跨分辨率找图 | 比例未知、或有旋转/透视时 |
|
|
719
718
|
|
|
720
719
|
**返回值:**
|
|
721
720
|
|
|
@@ -781,7 +780,9 @@ function buildScaleFactors(base, step = 0.05, halfRange = 2) {
|
|
|
781
780
|
|
|
782
781
|
const scaleFactors = buildScaleFactors(baseScale);
|
|
783
782
|
// 750 → 1170 时约等于 [1.56, 1.51, 1.61, 1.46, 1.66]
|
|
784
|
-
logi(
|
|
783
|
+
logi(
|
|
784
|
+
`baseScale=${baseScale.toFixed(3)} scaleFactors=${JSON.stringify(scaleFactors)}`,
|
|
785
|
+
);
|
|
785
786
|
|
|
786
787
|
const scaled = image.findImage(
|
|
787
788
|
"screen",
|
|
@@ -836,15 +837,15 @@ function findImageEx(
|
|
|
836
837
|
|
|
837
838
|
**参数:**
|
|
838
839
|
|
|
839
|
-
| 参数名
|
|
840
|
-
|
|
|
841
|
-
| `imageId`
|
|
842
|
-
| `kjstPath`
|
|
840
|
+
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
841
|
+
| ---------- | ------ | -------- | ------ | ------------------------------------------------------------------------------------- |
|
|
842
|
+
| `imageId` | string | 是 | - | `"screen"`-当前屏幕截图,或图片 ID / 路径,语义与 `findImage` 相同 |
|
|
843
|
+
| `kjstPath` | string | 是 | - | `res` 下的 kjst 文件名,例如 `"login.kjst"`。不要带 `res/` 前缀,也不要传手机绝对路径 |
|
|
843
844
|
|
|
844
845
|
**返回值:**
|
|
845
846
|
|
|
846
|
-
| 类型 | 描述
|
|
847
|
-
| ------- |
|
|
847
|
+
| 类型 | 描述 |
|
|
848
|
+
| ------- | -------------------------------------------------------------------------------------------- |
|
|
848
849
|
| `array` | 命中矩形数组,字段与 `findImage` 相同。OCR 命中额外含 `text`。未找到或 kjst 无效时返回空数组 |
|
|
849
850
|
|
|
850
851
|
**说明:**
|
|
@@ -1153,43 +1154,3 @@ if (imageId) {
|
|
|
1153
1154
|
image.release(imageId);
|
|
1154
1155
|
}
|
|
1155
1156
|
```
|
|
1156
|
-
|
|
1157
|
-
## 安卓独有方法
|
|
1158
|
-
|
|
1159
|
-
### getBitmap - 获取安卓的Bitmap对象
|
|
1160
|
-
|
|
1161
|
-
此方法仅在安卓可用,用于获取图片的 Bitmap 对象。
|
|
1162
|
-
|
|
1163
|
-
```typescript
|
|
1164
|
-
function getBitmap(imageId: string): any;
|
|
1165
|
-
```
|
|
1166
|
-
|
|
1167
|
-
**参数:**
|
|
1168
|
-
|
|
1169
|
-
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
1170
|
-
| --------- | ------ | -------- | ------ | --------- |
|
|
1171
|
-
| `imageId` | string | 是 | - | 原图片 ID |
|
|
1172
|
-
|
|
1173
|
-
**返回值:**
|
|
1174
|
-
|
|
1175
|
-
| 类型 | 描述 |
|
|
1176
|
-
| ----- | ---------------- |
|
|
1177
|
-
| `any` | 安卓的Bitmap对象 |
|
|
1178
|
-
|
|
1179
|
-
**示例:**
|
|
1180
|
-
|
|
1181
|
-
```javascript
|
|
1182
|
-
const imageId = image.captureScreen();
|
|
1183
|
-
if (imageId) {
|
|
1184
|
-
const bitmap = image.getBitmap(imageId);
|
|
1185
|
-
logi(`Bitmap 对象: ${bitmap}`);
|
|
1186
|
-
// 注意:使用完 Bitmap 后,需要调用 recycle() 方法释放内存
|
|
1187
|
-
bitmap.recycle();
|
|
1188
|
-
image.release(imageId);
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
// 快捷获取截屏bitmap
|
|
1192
|
-
const bitmap = image.getBitmap("screen");
|
|
1193
|
-
logi(`Bitmap 对象: ${bitmap}`);
|
|
1194
|
-
bitmap.recycle();
|
|
1195
|
-
```
|
package/docs/apicn/global.md
CHANGED
|
@@ -308,55 +308,6 @@ $APP切入前台();
|
|
|
308
308
|
$打印信息日志("应用已切换到前台");
|
|
309
309
|
```
|
|
310
310
|
|
|
311
|
-
### $设置 Agent 快速模式
|
|
312
|
-
|
|
313
|
-
设置 Agent 快速模式(兼容旧接口)。开启对应模式 `1`,关闭对应模式 `0`。推荐改用 `$设置Agent触控模式`。设置会持久化。
|
|
314
|
-
|
|
315
|
-
```typescript
|
|
316
|
-
declare function $设置Agent快速模式(是否开启: 布尔值): 布尔值;
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
**参数:**
|
|
320
|
-
|
|
321
|
-
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
322
|
-
| ---------- | -------- | -------- | ------ | ---------------- |
|
|
323
|
-
| `是否开启` | `布尔值` | 是 | - | 是否开启快速模式 |
|
|
324
|
-
|
|
325
|
-
**返回值:**
|
|
326
|
-
|
|
327
|
-
| 类型 | 描述 |
|
|
328
|
-
| -------- | -------------------- |
|
|
329
|
-
| `布尔值` | 实际是否开启快速模式 |
|
|
330
|
-
|
|
331
|
-
**示例:**
|
|
332
|
-
|
|
333
|
-
```javascript
|
|
334
|
-
const 是否开启 = $设置Agent快速模式(true);
|
|
335
|
-
$打印信息日志(`Agent 快速模式: ${是否开启}`);
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
### $获取 Agent 快速模式
|
|
339
|
-
|
|
340
|
-
获取 Agent 快速模式当前状态(兼容旧接口)。
|
|
341
|
-
|
|
342
|
-
```typescript
|
|
343
|
-
declare function $获取Agent快速模式(): 布尔值;
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
**返回值:**
|
|
347
|
-
|
|
348
|
-
| 类型 | 描述 |
|
|
349
|
-
| -------- | -------------------- |
|
|
350
|
-
| `布尔值` | 当前是否开启快速模式 |
|
|
351
|
-
|
|
352
|
-
**示例:**
|
|
353
|
-
|
|
354
|
-
```javascript
|
|
355
|
-
if ($获取Agent快速模式()) {
|
|
356
|
-
$打印信息日志("Agent 快速模式已开启");
|
|
357
|
-
}
|
|
358
|
-
```
|
|
359
|
-
|
|
360
311
|
### $设置 Agent 触控模式
|
|
361
312
|
|
|
362
313
|
设置 Agent 触控模式。默认 `1`,设置会持久化。
|
|
@@ -625,60 +576,6 @@ if (是否加载成功) {
|
|
|
625
576
|
}
|
|
626
577
|
```
|
|
627
578
|
|
|
628
|
-
### $获取上下文
|
|
629
|
-
|
|
630
|
-
获取安卓上下文 (仅安卓可用)。
|
|
631
|
-
|
|
632
|
-
```typescript
|
|
633
|
-
declare function $获取上下文(): 任意类型;
|
|
634
|
-
```
|
|
635
|
-
|
|
636
|
-
**返回值:**
|
|
637
|
-
|
|
638
|
-
| 类型 | 描述 |
|
|
639
|
-
| ------------ | -------------- |
|
|
640
|
-
| `上下文对象` | 当前上下文对象 |
|
|
641
|
-
|
|
642
|
-
**示例:**
|
|
643
|
-
|
|
644
|
-
```javascript
|
|
645
|
-
const 上下文 = $获取上下文();
|
|
646
|
-
$打印调试日志(`当前上下文: ${JSON.stringify(上下文)}`);
|
|
647
|
-
```
|
|
648
|
-
|
|
649
|
-
### $导入类
|
|
650
|
-
|
|
651
|
-
导入指定的类。
|
|
652
|
-
|
|
653
|
-
```typescript
|
|
654
|
-
declare function $导入类(类名: 字符串): 任意类型;
|
|
655
|
-
```
|
|
656
|
-
|
|
657
|
-
**参数:**
|
|
658
|
-
|
|
659
|
-
| 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
|
|
660
|
-
| ------ | ------ | -------- | ------ | ------------ |
|
|
661
|
-
| `类名` | 字符串 | 是 | - | 要导入的类名 |
|
|
662
|
-
|
|
663
|
-
**返回值:**
|
|
664
|
-
|
|
665
|
-
| 类型 | 描述 |
|
|
666
|
-
| -------- | ------------ |
|
|
667
|
-
| `类对象` | 导入的类对象 |
|
|
668
|
-
|
|
669
|
-
**示例:**
|
|
670
|
-
|
|
671
|
-
```javascript
|
|
672
|
-
// 大部分情况下,不需要导入 Java 类,直接使用即可
|
|
673
|
-
const B = new com.a.B();
|
|
674
|
-
logi(`B 类的实例: ${B}`);
|
|
675
|
-
|
|
676
|
-
// 只有在无法直接使用类时,才需要导入 Java 类
|
|
677
|
-
const C = $导入类("xxx.a.C");
|
|
678
|
-
const c = new C();
|
|
679
|
-
logi(`创建了 C 类的实例: ${c}`);
|
|
680
|
-
```
|
|
681
|
-
|
|
682
579
|
## 全局日志函数
|
|
683
580
|
|
|
684
581
|
全局日志函数是 `logger` 模块对应方法的便捷别名,可以直接调用而无需 `logger.` 前缀。
|