ms-vite-plugin 1.4.75 → 1.4.77
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/ai.md +11 -10
- package/docs/api/device.md +0 -29
- package/docs/apicn/ai.md +11 -10
- package/docs/apicn/device.md +0 -35
- package/docs/apilua/ai.md +10 -7
- package/docs/apilua/device.md +0 -27
- package/docs/apipython/ai.md +10 -7
- package/docs/apipython/device.md +2 -27
- 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(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,
|
|
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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.shortName=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.shortName=r,exports.renameLocals=c;const u=require("./reserved"),d=require("./scope"),l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function r(a){let e=a,t="";do t=l[e%l.length]+t,e=Math.floor(e/l.length)-1;while(e>=0);return u.luaKeywords.has(t)?`_${t}`:t}function c(a){let e=0;const t=new Set;(0,d.collectAndRename)(a,(o,s)=>{if(o.newName!==o.original)return;let n=r(e);for(e+=1;s.has(n)||t.has(n)||u.luaKeywords.has(n);)n=r(e),e+=1;o.newName=n,t.add(n),s.add(n)})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveLocal=i,exports.collectAndRename=x;function i(t,
|
|
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}}
|
package/docs/api/ai.md
CHANGED
|
@@ -6,9 +6,9 @@ AI 模块让脚本直接在手机上调用大模型:看图回答问题、做
|
|
|
6
6
|
|
|
7
7
|
| `protocol` | 适用服务 |
|
|
8
8
|
| ----------- | ------------------------------------------------------------------------------------- |
|
|
9
|
-
| `openai` |
|
|
10
|
-
| `anthropic` |
|
|
11
|
-
| `gemini` |
|
|
9
|
+
| `openai` | DeepSeek、通义千问、Kimi、智谱、SiliconFlow、本机 Ollama / vLLM 等 |
|
|
10
|
+
| `anthropic` | 国内一般走 openai 兼容口,不必单独配 |
|
|
11
|
+
| `gemini` | 国内一般走 openai 兼容口,不必单独配 |
|
|
12
12
|
|
|
13
13
|
模型配置(地址、Key、模型名)直接写在脚本里,脚本开头 `ai.setProvider` 一次即可;脚本停止后配置自动清空,不会存到手机上。
|
|
14
14
|
|
|
@@ -92,12 +92,13 @@ interface AiProvider {
|
|
|
92
92
|
id: string; // 供应商 id,不传时自动生成
|
|
93
93
|
name: string; // 展示名,例如 "DeepSeek",调用时可用它选模型
|
|
94
94
|
protocol: "openai" | "anthropic" | "gemini";
|
|
95
|
-
baseUrl: string; // 接口根地址,例如 https://api.
|
|
95
|
+
baseUrl: string; // 接口根地址,例如 https://api.deepseek.com
|
|
96
96
|
apiKey: string; // API Key;openai 协议连本机模型时可为空
|
|
97
97
|
model: string; // 默认模型名
|
|
98
98
|
headers: Record<string, string>; // 额外请求头,某些网关需要
|
|
99
99
|
temperature?: number; // 默认温度;不传则不发该字段,用模型自己的默认值
|
|
100
100
|
maxTokens?: number; // 默认最大输出 token;不传则不发,用模型默认值(Anthropic 必填,缺省 2048)
|
|
101
|
+
reasoningEffort?: "none" | "low" | "medium" | "high" | "xhigh"; // 思考级别,仅 openai 协议;不传不发,用服务商默认
|
|
101
102
|
supportsVision: boolean; // 是否支持图片输入,默认 true
|
|
102
103
|
isDefault: boolean; // 是否为默认供应商
|
|
103
104
|
}
|
|
@@ -200,13 +201,13 @@ ai.judge("是否出现弹窗?", { image: "screen", provider: "视觉" }); //
|
|
|
200
201
|
// 同一供应商只换模型,不必再登记
|
|
201
202
|
ai.ask("复杂推理题……", { model: "deepseek-v4-pro" });
|
|
202
203
|
|
|
203
|
-
//
|
|
204
|
+
// 智谱 GLM(OpenAI 兼容口)
|
|
204
205
|
ai.setProvider({
|
|
205
|
-
name: "
|
|
206
|
-
protocol: "
|
|
207
|
-
baseUrl: "https://
|
|
208
|
-
apiKey: "sk-
|
|
209
|
-
model: "
|
|
206
|
+
name: "智谱 GLM",
|
|
207
|
+
protocol: "openai",
|
|
208
|
+
baseUrl: "https://open.bigmodel.cn/api/paas/v4",
|
|
209
|
+
apiKey: "sk-xxxxxxxx",
|
|
210
|
+
model: "glm-5.3-flash",
|
|
210
211
|
});
|
|
211
212
|
|
|
212
213
|
// 本机 Ollama,不需要 Key
|
package/docs/api/device.md
CHANGED
|
@@ -166,35 +166,6 @@ logi(`设备型号: ${model}`);
|
|
|
166
166
|
|
|
167
167
|
## 屏幕信息
|
|
168
168
|
|
|
169
|
-
### getScreenSize - 获取屏幕尺寸(缩放后的)。
|
|
170
|
-
|
|
171
|
-
**注意事项:**
|
|
172
|
-
|
|
173
|
-
- 该方法返回的屏幕尺寸是根据当前设备的屏幕分辨率除以缩放比例计算得到的。
|
|
174
|
-
- 注意该方法只会返回竖屏分辨率。
|
|
175
|
-
|
|
176
|
-
```typescript
|
|
177
|
-
function getScreenSize(): {
|
|
178
|
-
width: number; // 屏幕宽度(像素)
|
|
179
|
-
height: number; // 屏幕高度(像素)
|
|
180
|
-
};
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
**返回值:**
|
|
184
|
-
|
|
185
|
-
| 参数名 | 类型 | 描述 |
|
|
186
|
-
| -------- | ------ | ---------------- |
|
|
187
|
-
| `width` | number | 屏幕宽度(像素) |
|
|
188
|
-
| `height` | number | 屏幕高度(像素) |
|
|
189
|
-
|
|
190
|
-
**示例:**
|
|
191
|
-
|
|
192
|
-
```typescript
|
|
193
|
-
// 获取屏幕尺寸
|
|
194
|
-
const screenSize = device.getScreenSize();
|
|
195
|
-
logi(`屏幕尺寸: ${screenSize.width} x ${screenSize.height}`);
|
|
196
|
-
```
|
|
197
|
-
|
|
198
169
|
### getScreenRealSize - 获取屏幕实际尺寸。
|
|
199
170
|
|
|
200
171
|
**注意事项:**
|
package/docs/apicn/ai.md
CHANGED
|
@@ -6,9 +6,9 @@ AI 模块让脚本直接在手机上调用大模型:看图回答问题、做
|
|
|
6
6
|
|
|
7
7
|
| `protocol` | 适用服务 |
|
|
8
8
|
| ----------- | ------------------------------------------------------------------------------------- |
|
|
9
|
-
| `openai` |
|
|
10
|
-
| `anthropic` |
|
|
11
|
-
| `gemini` |
|
|
9
|
+
| `openai` | DeepSeek、通义千问、Kimi、智谱、SiliconFlow、本机 Ollama / vLLM 等 |
|
|
10
|
+
| `anthropic` | 国内一般走 openai 兼容口,不必单独配 |
|
|
11
|
+
| `gemini` | 国内一般走 openai 兼容口,不必单独配 |
|
|
12
12
|
|
|
13
13
|
模型配置(地址、Key、模型名)直接写在脚本里,脚本开头 `$AI.设置模型` 一次即可;脚本停止后配置自动清空,不会存到手机上。
|
|
14
14
|
|
|
@@ -92,12 +92,13 @@ interface 模型供应商 {
|
|
|
92
92
|
id: 字符串; // 供应商 id,不传时自动生成
|
|
93
93
|
name: 字符串; // 展示名,例如 "DeepSeek",调用时可用它选模型
|
|
94
94
|
protocol: "openai" | "anthropic" | "gemini";
|
|
95
|
-
baseUrl: 字符串; // 接口根地址,例如 https://api.
|
|
95
|
+
baseUrl: 字符串; // 接口根地址,例如 https://api.deepseek.com
|
|
96
96
|
apiKey: 字符串; // API Key;openai 协议连本机模型时可为空
|
|
97
97
|
model: 字符串; // 默认模型名
|
|
98
98
|
headers: 字典<字符串>; // 额外请求头,某些网关需要
|
|
99
99
|
temperature?: 数字; // 默认温度;不传则不发该字段,用模型自己的默认值
|
|
100
100
|
maxTokens?: 数字; // 默认最大输出 token;不传则不发,用模型默认值(Anthropic 必填,缺省 2048)
|
|
101
|
+
reasoningEffort?: "none" | "low" | "medium" | "high" | "xhigh"; // 思考级别,仅 openai 协议;不传不发,用服务商默认
|
|
101
102
|
supportsVision: 布尔值; // 是否支持图片输入,默认 true
|
|
102
103
|
isDefault: 布尔值; // 是否为默认供应商
|
|
103
104
|
}
|
|
@@ -200,13 +201,13 @@ $AI.判断("是否出现弹窗?", { image: "screen", provider: "视觉" }); //
|
|
|
200
201
|
// 同一供应商只换模型,不必再登记
|
|
201
202
|
$AI.提问("复杂推理题……", { model: "deepseek-v4-pro" });
|
|
202
203
|
|
|
203
|
-
//
|
|
204
|
+
// 智谱 GLM(OpenAI 兼容口)
|
|
204
205
|
$AI.设置模型({
|
|
205
|
-
name: "
|
|
206
|
-
protocol: "
|
|
207
|
-
baseUrl: "https://
|
|
208
|
-
apiKey: "sk-
|
|
209
|
-
model: "
|
|
206
|
+
name: "智谱 GLM",
|
|
207
|
+
protocol: "openai",
|
|
208
|
+
baseUrl: "https://open.bigmodel.cn/api/paas/v4",
|
|
209
|
+
apiKey: "sk-xxxxxxxx",
|
|
210
|
+
model: "glm-5.3-flash",
|
|
210
211
|
});
|
|
211
212
|
|
|
212
213
|
// 本机 Ollama,不需要 Key
|
package/docs/apicn/device.md
CHANGED
|
@@ -166,41 +166,6 @@ $打印信息日志(`设备型号: ${model}`);
|
|
|
166
166
|
|
|
167
167
|
## 屏幕信息
|
|
168
168
|
|
|
169
|
-
### 获取屏幕宽高(缩放后的)
|
|
170
|
-
|
|
171
|
-
**注意事项:**
|
|
172
|
-
|
|
173
|
-
- 该方法返回的屏幕尺寸是根据当前设备的屏幕分辨率除以缩放比例计算得到的。
|
|
174
|
-
- 注意该方法只会返回竖屏分辨率。
|
|
175
|
-
|
|
176
|
-
```typescript
|
|
177
|
-
function 获取屏幕宽高(): {
|
|
178
|
-
/**
|
|
179
|
-
* 屏幕宽度
|
|
180
|
-
*/
|
|
181
|
-
width: 数字;
|
|
182
|
-
/**
|
|
183
|
-
* 屏幕高度
|
|
184
|
-
*/
|
|
185
|
-
height: 数字;
|
|
186
|
-
};
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
**返回值:**
|
|
190
|
-
|
|
191
|
-
| 参数名 | 类型 | 描述 |
|
|
192
|
-
| -------- | ---- | ---------------- |
|
|
193
|
-
| `width` | 数字 | 屏幕宽度(像素) |
|
|
194
|
-
| `height` | 数字 | 屏幕高度(像素) |
|
|
195
|
-
|
|
196
|
-
**示例:**
|
|
197
|
-
|
|
198
|
-
```typescript
|
|
199
|
-
// 获取屏幕尺寸
|
|
200
|
-
const screenSize = $设备.获取屏幕宽高();
|
|
201
|
-
$打印信息日志(`屏幕尺寸: ${screenSize.width} x ${screenSize.height}`);
|
|
202
|
-
```
|
|
203
|
-
|
|
204
169
|
### 获取屏幕实际宽高
|
|
205
170
|
|
|
206
171
|
**注意事项:**
|
package/docs/apilua/ai.md
CHANGED
|
@@ -8,9 +8,9 @@ AI 模块让脚本直接在手机上调用大模型:看图回答问题、做
|
|
|
8
8
|
|
|
9
9
|
| `protocol` | 适用服务 |
|
|
10
10
|
| ----------- | ------------------------------------------------------------------------------------- |
|
|
11
|
-
| `openai` |
|
|
12
|
-
| `anthropic` |
|
|
13
|
-
| `gemini` |
|
|
11
|
+
| `openai` | DeepSeek、通义千问、Kimi、智谱、SiliconFlow、本机 Ollama / vLLM 等 |
|
|
12
|
+
| `anthropic` | 国内一般走 openai 兼容口,不必单独配 |
|
|
13
|
+
| `gemini` | 国内一般走 openai 兼容口,不必单独配 |
|
|
14
14
|
|
|
15
15
|
模型配置(地址、Key、模型名)直接写在脚本里,脚本开头 `ai.setProvider` 一次即可;脚本停止后配置自动清空,不会存到手机上。
|
|
16
16
|
|
|
@@ -90,12 +90,13 @@ ai.judge("第二张图里有没有第一张图的图标?", { images = { "icon.
|
|
|
90
90
|
---@field id string 供应商 id,不传时自动生成
|
|
91
91
|
---@field name string 展示名,例如 "DeepSeek",调用时可用它选模型
|
|
92
92
|
---@field protocol "openai"|"anthropic"|"gemini"
|
|
93
|
-
---@field baseUrl string 接口根地址,例如 https://api.
|
|
93
|
+
---@field baseUrl string 接口根地址,例如 https://api.deepseek.com
|
|
94
94
|
---@field apiKey string API Key;openai 协议连本机模型时可为空
|
|
95
95
|
---@field model string 默认模型名
|
|
96
96
|
---@field headers table<string, string> 额外请求头,某些网关需要
|
|
97
97
|
---@field temperature number|nil 默认温度;不传则不发该字段,用模型自己的默认值
|
|
98
98
|
---@field maxTokens integer|nil 默认最大输出 token;不传则不发该字段,用模型自己的默认值(Anthropic 因接口必填仍默认 2048)
|
|
99
|
+
---@field reasoningEffort "none"|"low"|"medium"|"high"|"xhigh"|nil 思考级别,仅 openai 协议;不传不发,用服务商默认
|
|
99
100
|
---@field supportsVision boolean 是否支持图片输入,默认 true
|
|
100
101
|
---@field isDefault boolean 是否为默认供应商
|
|
101
102
|
```
|
|
@@ -187,9 +188,11 @@ ai.judge("是否出现弹窗?", { image = "screen", provider = "视觉" }) --
|
|
|
187
188
|
-- 同一供应商只换模型,不必再登记
|
|
188
189
|
ai.ask("复杂推理题……", { model = "deepseek-v4-pro" })
|
|
189
190
|
|
|
190
|
-
--
|
|
191
|
-
ai.setProvider({
|
|
192
|
-
|
|
191
|
+
-- 智谱 GLM(OpenAI 兼容口)
|
|
192
|
+
ai.setProvider({
|
|
193
|
+
name = "智谱 GLM", protocol = "openai", baseUrl = "https://open.bigmodel.cn/api/paas/v4",
|
|
194
|
+
apiKey = "sk-xxxxxxxx", model = "glm-5.3-flash",
|
|
195
|
+
})
|
|
193
196
|
|
|
194
197
|
-- 本机 Ollama,不需要 Key
|
|
195
198
|
ai.setProvider({ name = "本机", protocol = "openai", baseUrl = "http://192.168.1.10:11434/v1", model = "qwen3:8b" })
|
package/docs/apilua/device.md
CHANGED
|
@@ -168,33 +168,6 @@ print("设备型号: " .. tostring(model))
|
|
|
168
168
|
|
|
169
169
|
## 屏幕信息
|
|
170
170
|
|
|
171
|
-
### getScreenSize - 获取屏幕尺寸(缩放后的)。
|
|
172
|
-
|
|
173
|
-
**注意事项:**
|
|
174
|
-
|
|
175
|
-
- 该方法返回的屏幕尺寸是根据当前设备的屏幕分辨率除以缩放比例计算得到的。
|
|
176
|
-
- 注意该方法只会返回竖屏分辨率。
|
|
177
|
-
|
|
178
|
-
```lua
|
|
179
|
-
---@return any
|
|
180
|
-
function getScreenSize() end
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
**返回值:**
|
|
184
|
-
|
|
185
|
-
| 参数名 | 类型 | 描述 |
|
|
186
|
-
| -------- | ------ | ---------------- |
|
|
187
|
-
| `width` | number | 屏幕宽度(像素) |
|
|
188
|
-
| `height` | number | 屏幕高度(像素) |
|
|
189
|
-
|
|
190
|
-
**示例:**
|
|
191
|
-
|
|
192
|
-
```lua
|
|
193
|
-
-- 获取屏幕尺寸
|
|
194
|
-
local screenSize = device.getScreenSize()
|
|
195
|
-
print("屏幕尺寸: " .. tostring(screenSize.width) .. " x " .. tostring(screenSize.height))
|
|
196
|
-
```
|
|
197
|
-
|
|
198
171
|
### getScreenRealSize - 获取屏幕实际尺寸。
|
|
199
172
|
|
|
200
173
|
**注意事项:**
|
package/docs/apipython/ai.md
CHANGED
|
@@ -6,9 +6,9 @@ AI 模块让脚本直接在手机上调用大模型:看图回答问题、做
|
|
|
6
6
|
|
|
7
7
|
| `protocol` | 适用服务 |
|
|
8
8
|
| ----------- | ------------------------------------------------------------------------------------- |
|
|
9
|
-
| `openai` |
|
|
10
|
-
| `anthropic` |
|
|
11
|
-
| `gemini` |
|
|
9
|
+
| `openai` | DeepSeek、通义千问、Kimi、智谱、SiliconFlow、本机 Ollama / vLLM 等 |
|
|
10
|
+
| `anthropic` | 国内一般走 openai 兼容口,不必单独配 |
|
|
11
|
+
| `gemini` | 国内一般走 openai 兼容口,不必单独配 |
|
|
12
12
|
|
|
13
13
|
模型配置(地址、Key、模型名)直接写在脚本里,脚本开头 `ai.setProvider` 一次即可;脚本停止后配置自动清空,不会存到手机上。
|
|
14
14
|
|
|
@@ -94,12 +94,13 @@ class AiProvider(KuaiJSNamespace):
|
|
|
94
94
|
id: str # 供应商 id,不传时自动生成
|
|
95
95
|
name: str # 展示名,例如 "DeepSeek",调用时可用它选模型
|
|
96
96
|
protocol: str # "openai" / "anthropic" / "gemini"
|
|
97
|
-
baseUrl: str # 接口根地址,例如 https://api.
|
|
97
|
+
baseUrl: str # 接口根地址,例如 https://api.deepseek.com
|
|
98
98
|
apiKey: str # API Key;openai 协议连本机模型时可为空
|
|
99
99
|
model: str # 默认模型名
|
|
100
100
|
headers: Dict[str, str] # 额外请求头,某些网关需要
|
|
101
101
|
temperature: Optional[float] # 默认温度;不传则不发该字段,用模型自己的默认值
|
|
102
102
|
maxTokens: Optional[int] # 默认最大输出 token;不传则不发,用模型默认值(Anthropic 必填,缺省 2048)
|
|
103
|
+
reasoningEffort: Optional[str] # 思考级别 none/low/medium/high/xhigh,仅 openai;不传不发,用服务商默认
|
|
103
104
|
supportsVision: bool # 是否支持图片输入,默认 True
|
|
104
105
|
isDefault: bool # 是否为默认供应商
|
|
105
106
|
```
|
|
@@ -171,9 +172,11 @@ ai.judge("是否出现弹窗?", {"image": "screen", "provider": "视觉"}) #
|
|
|
171
172
|
# 同一供应商只换模型,不必再登记
|
|
172
173
|
ai.ask("复杂推理题……", {"model": "deepseek-v4-pro"})
|
|
173
174
|
|
|
174
|
-
#
|
|
175
|
-
ai.setProvider({
|
|
176
|
-
|
|
175
|
+
# 智谱 GLM(OpenAI 兼容口)
|
|
176
|
+
ai.setProvider({
|
|
177
|
+
"name": "智谱 GLM", "protocol": "openai", "baseUrl": "https://open.bigmodel.cn/api/paas/v4",
|
|
178
|
+
"apiKey": "sk-xxxxxxxx", "model": "glm-5.3-flash",
|
|
179
|
+
})
|
|
177
180
|
|
|
178
181
|
# 本机 Ollama,不需要 Key
|
|
179
182
|
ai.setProvider({"name": "本机", "protocol": "openai", "baseUrl": "http://192.168.1.10:11434/v1", "model": "qwen3:8b"})
|
package/docs/apipython/device.md
CHANGED
|
@@ -170,11 +170,11 @@ print(device.getDeviceModel())
|
|
|
170
170
|
|
|
171
171
|
## 屏幕信息
|
|
172
172
|
|
|
173
|
-
###
|
|
173
|
+
### getScreenRealSize - 获取屏幕实际尺寸。
|
|
174
174
|
|
|
175
175
|
**注意事项:**
|
|
176
176
|
|
|
177
|
-
-
|
|
177
|
+
- 返回实际分辨率;仅返回竖屏分辨率
|
|
178
178
|
|
|
179
179
|
```python
|
|
180
180
|
from kuaijs._types import KuaiJSNamespace
|
|
@@ -183,31 +183,6 @@ class ScreenSize(KuaiJSNamespace):
|
|
|
183
183
|
width: float # 屏幕宽度(像素)
|
|
184
184
|
height: float # 屏幕高度(像素)
|
|
185
185
|
|
|
186
|
-
def getScreenSize() -> ScreenSize:
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
**返回值:**
|
|
190
|
-
|
|
191
|
-
| 参数名 | 类型 | 描述 |
|
|
192
|
-
| -------- | ----- | ---------------- |
|
|
193
|
-
| `width` | float | 屏幕宽度(像素) |
|
|
194
|
-
| `height` | float | 屏幕高度(像素) |
|
|
195
|
-
|
|
196
|
-
**示例:**
|
|
197
|
-
|
|
198
|
-
```python
|
|
199
|
-
from kuaijs import device
|
|
200
|
-
size = device.getScreenSize()
|
|
201
|
-
print(f"屏幕尺寸: {size.width} x {size.height}")
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### getScreenRealSize - 获取屏幕实际尺寸。
|
|
205
|
-
|
|
206
|
-
**注意事项:**
|
|
207
|
-
|
|
208
|
-
- 返回实际分辨率;仅返回竖屏分辨率
|
|
209
|
-
|
|
210
|
-
```python
|
|
211
186
|
def getScreenRealSize() -> ScreenSize:
|
|
212
187
|
```
|
|
213
188
|
|