ms-vite-plugin 1.4.59 → 1.4.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/luaBundle.js +1 -1
  2. package/dist/luaObfuscator/addVararg.d.ts +2 -0
  3. package/dist/luaObfuscator/addVararg.js +1 -0
  4. package/dist/luaObfuscator/antiTamper.d.ts +2 -0
  5. package/dist/luaObfuscator/antiTamper.js +26 -0
  6. package/dist/luaObfuscator/ast.d.ts +191 -0
  7. package/dist/luaObfuscator/ast.js +1 -0
  8. package/dist/luaObfuscator/cipher.d.ts +10 -0
  9. package/dist/luaObfuscator/cipher.js +28 -0
  10. package/dist/luaObfuscator/compiler.d.ts +31 -0
  11. package/dist/luaObfuscator/compiler.js +1 -0
  12. package/dist/luaObfuscator/constantArray.d.ts +5 -0
  13. package/dist/luaObfuscator/constantArray.js +1 -0
  14. package/dist/luaObfuscator/flatten.d.ts +2 -0
  15. package/dist/luaObfuscator/flatten.js +1 -0
  16. package/dist/luaObfuscator/index.d.ts +6 -0
  17. package/dist/luaObfuscator/index.js +1 -0
  18. package/dist/luaObfuscator/lexer.d.ts +14 -0
  19. package/dist/luaObfuscator/lexer.js +10 -0
  20. package/dist/luaObfuscator/minify.d.ts +3 -0
  21. package/dist/luaObfuscator/minify.js +1 -0
  22. package/dist/luaObfuscator/numbers.d.ts +2 -0
  23. package/dist/luaObfuscator/numbers.js +1 -0
  24. package/dist/luaObfuscator/opcodes.d.ts +3 -0
  25. package/dist/luaObfuscator/opcodes.js +1 -0
  26. package/dist/luaObfuscator/parser.d.ts +8 -0
  27. package/dist/luaObfuscator/parser.js +1 -0
  28. package/dist/luaObfuscator/rename.d.ts +3 -0
  29. package/dist/luaObfuscator/rename.js +1 -0
  30. package/dist/luaObfuscator/reserved.d.ts +5 -0
  31. package/dist/luaObfuscator/reserved.js +1 -0
  32. package/dist/luaObfuscator/scope.d.ts +11 -0
  33. package/dist/luaObfuscator/scope.js +1 -0
  34. package/dist/luaObfuscator/selftest.d.ts +1 -0
  35. package/dist/luaObfuscator/selftest.js +39 -0
  36. package/dist/luaObfuscator/splitStrings.d.ts +2 -0
  37. package/dist/luaObfuscator/splitStrings.js +1 -0
  38. package/dist/luaObfuscator/strings.d.ts +4 -0
  39. package/dist/luaObfuscator/strings.js +1 -0
  40. package/dist/luaObfuscator/visit.d.ts +5 -0
  41. package/dist/luaObfuscator/visit.js +1 -0
  42. package/dist/luaObfuscator/vmEmit.d.ts +2 -0
  43. package/dist/luaObfuscator/vmEmit.js +281 -0
  44. package/dist/luaObfuscator/wrapInFunction.d.ts +2 -0
  45. package/dist/luaObfuscator/wrapInFunction.js +1 -0
  46. package/docs/AGENTS.md +1 -1
  47. package/docs/SKILL.md +1 -1
  48. package/docs/api/hid.md +21 -0
  49. package/docs/apicn/hid.md +21 -0
  50. package/docs/apilua/action.md +2 -27
  51. package/docs/apilua/appleocr.md +2 -6
  52. package/docs/apilua/cloud.md +2 -6
  53. package/docs/apilua/config.md +2 -6
  54. package/docs/apilua/cryptoUtils.md +2 -7
  55. package/docs/apilua/device.md +2 -19
  56. package/docs/apilua/dotocr.md +2 -5
  57. package/docs/apilua/file.md +2 -17
  58. package/docs/apilua/global.md +1 -1
  59. package/docs/apilua/hid.md +25 -44
  60. package/docs/apilua/hotUpdate.md +2 -3
  61. package/docs/apilua/http.md +2 -7
  62. package/docs/apilua/image.md +2 -20
  63. package/docs/apilua/ime.md +2 -10
  64. package/docs/apilua/logger.md +3 -9
  65. package/docs/apilua/media.md +2 -9
  66. package/docs/apilua/mysql.md +2 -10
  67. package/docs/apilua/netCard.md +2 -6
  68. package/docs/apilua/node.md +2 -3
  69. package/docs/apilua/opencv.md +1 -27
  70. package/docs/apilua/paddleocr.md +2 -7
  71. package/docs/apilua/pip.md +2 -12
  72. package/docs/apilua/system.md +2 -23
  73. package/docs/apilua/tomatoocr.md +2 -16
  74. package/docs/apilua/tts.md +2 -9
  75. package/docs/apilua/ui.md +3 -9
  76. package/docs/apilua/utils.md +2 -9
  77. package/docs/apilua/yolo.md +2 -4
  78. package/docs/apilua/yolocls.md +2 -5
  79. package/docs/apipython/hid.md +22 -0
  80. package/docs/mcp-agent-description.md +1 -1
  81. package/docs/quick/vscode/createProject.md +1 -1
  82. package/docs/quick/vscode/packProject.md +1 -1
  83. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.splitStrings=p;const u=require("./visit");function a(e){let r={type:"StringLiteral",value:e[0]};for(let n=1;n<e.length;n+=1)r={type:"BinaryExpr",op:"..",left:r,right:{type:"StringLiteral",value:e[n]}};return{type:"ParenExpr",exp:r}}function o(e,r){if(e.length<4)return[e];const n=r%2+2,t=Math.max(1,Math.ceil(e.length/n)),l=[];for(let i=0;i<e.length;i+=t)l.push(e.slice(i,i+t));return l}function p(e,r){let n=0;(0,u.mapChunk)(e,t=>{if(t.type!=="StringLiteral"||t.encoded||t.value.length<4)return t;n+=1;const l=o(t.value,r+n);return l.length<2?t:a(l)})}
@@ -0,0 +1,4 @@
1
+ import type { Chunk } from "./ast";
2
+ import { createFoldMixParams, foldDecrypt, foldEncrypt, type FoldMixParams } from "./cipher";
3
+ export declare function encryptStrings(chunk: Chunk, seed: number): void;
4
+ export { createFoldMixParams, foldDecrypt, foldEncrypt, type FoldMixParams, };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.foldEncrypt=exports.foldDecrypt=exports.createFoldMixParams=void 0,exports.encryptStrings=y;const a=require("./cipher");Object.defineProperty(exports,"createFoldMixParams",{enumerable:!0,get:function(){return a.createFoldMixParams}}),Object.defineProperty(exports,"foldDecrypt",{enumerable:!0,get:function(){return a.foldDecrypt}}),Object.defineProperty(exports,"foldEncrypt",{enumerable:!0,get:function(){return a.foldEncrypt}});const u=require("./parser"),i=require("./visit"),o="__d";function d(t,l){let e=2166136261^l;for(let r=0;r<t.length;r+=1)e=Math.imul(e^t.charCodeAt(r),16777619);return e>>>0||1}function p(t,l,e){const r=(0,a.foldEncrypt)(t,l,e);return{type:"CallExpr",callee:{type:"NameExpr",name:o},args:[{type:"StringLiteral",value:r,encoded:!0},{type:"NumberLiteral",raw:String(e),value:e}]}}function y(t,l){const e=(0,a.createFoldMixParams)(l);let r=0;(0,i.mapChunk)(t,n=>n.type!=="StringLiteral"||n.encoded||n.value.length===0?n:(r+=1,p(n.value,e,d(n.value,r))));const c=(0,u.parseLua)((0,a.emitFoldDecoderLua)(e,o));t.body.unshift(...c.body)}
@@ -0,0 +1,5 @@
1
+ import type { Chunk, Expression, FuncExpr, Statement } from "./ast";
2
+ export declare function mapExp(exp: Expression, fn: (e: Expression) => Expression): Expression;
3
+ export declare function mapFunc(fnExpr: FuncExpr, fn: (e: Expression) => Expression): void;
4
+ export declare function mapStats(stats: Statement[], fn: (e: Expression) => Expression): void;
5
+ export declare function mapChunk(chunk: Chunk, fn: (e: Expression) => Expression): void;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.mapExp=s,exports.mapFunc=b,exports.mapStats=o,exports.mapChunk=p;function s(r,e){switch(r.type){case"UnaryExpr":r.arg=s(r.arg,e);break;case"BinaryExpr":r.left=s(r.left,e),r.right=s(r.right,e);break;case"FuncExpr":b(r,e);break;case"TableExpr":for(const a of r.fields)a.kind==="index"&&(a.key=s(a.key,e)),a.value=s(a.value,e);break;case"IndexExpr":r.object=s(r.object,e),r.index=s(r.index,e);break;case"MemberExpr":r.object=s(r.object,e);break;case"CallExpr":r.callee=s(r.callee,e),r.args=r.args.map(a=>s(a,e));break;case"MethodCallExpr":r.object=s(r.object,e),r.args=r.args.map(a=>s(a,e));break;case"ParenExpr":r.exp=s(r.exp,e);break;default:break}return e(r)}function b(r,e){o(r.body.body,e)}function o(r,e){for(const a of r)switch(a.type){case"DoStat":o(a.body.body,e);break;case"WhileStat":a.cond=s(a.cond,e),o(a.body.body,e);break;case"RepeatStat":o(a.body.body,e),a.cond=s(a.cond,e);break;case"IfStat":for(const c of a.clauses)c.cond=s(c.cond,e),o(c.body.body,e);a.elseBody&&o(a.elseBody.body,e);break;case"ForNumStat":a.start=s(a.start,e),a.end=s(a.end,e),a.step&&(a.step=s(a.step,e)),o(a.body.body,e);break;case"ForInStat":a.exps=a.exps.map(c=>s(c,e)),o(a.body.body,e);break;case"FuncStat":b(a.func,e);break;case"LocalFuncStat":b(a.func,e);break;case"LocalStat":a.exps&&(a.exps=a.exps.map(c=>s(c,e)));break;case"AssignStat":a.vars=a.vars.map(c=>s(c,e)),a.exps=a.exps.map(c=>s(c,e));break;case"CallStat":a.exp=s(a.exp,e);break;case"ReturnStat":a.exps=a.exps.map(c=>s(c,e));break;default:break}}function p(r,e){o(r.body,e)}
@@ -0,0 +1,2 @@
1
+ import type { Proto } from "./compiler";
2
+ export declare function emitVm(root: Proto): string;
@@ -0,0 +1,281 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.emitVm=j;const p=require("./cipher"),d=require("./minify"),s=require("./opcodes");function h(e){let n=2166136261^e.code.length;return n=Math.imul(n,16777619)^e.consts.length,n>>>0}function b(e,n,l){if(e.t==="nil")return"nil";if(e.t==="bool")return e.v?"true":"false";if(e.t==="num")return e.raw;const a=(0,p.foldEncrypt)(e.v,n,l);return`D(${(0,d.escapeLuaString)(a)},${l})`}function u(e,n,l,a){const i=e.code.map((t,o)=>{const r=e.ops[o];return`{${n[r]},${t[1]},${t[2]},${t[3]}}`}).join(","),c=e.consts.map((t,o)=>b(t,l,a+o*131>>>0||1)).join(","),R=e.protos.map((t,o)=>u(t,n,l,a+(o+1)*4099>>>0)).join(","),f=e.upvals.map(t=>`{${t.inStack?1:0},${t.index}}`).join(",");return`{p={${i}},k={${c}},t={${R}},u={${f}},n=${e.numparams},v=${e.isVararg?"true":"false"}}`}function j(e){const n=h(e)||1,l=(0,s.shuffleOpcodes)(n),a=(0,p.createFoldMixParams)(n),i=s.OPCODE_NAMES.join(","),c=s.OPCODE_NAMES.map(f=>String(l[f])).join(","),R=u(e,l,a,n);return`(function()
2
+ ${(0,p.emitFoldDecoderLua)(a,"D")}
3
+ local ${i}=${c}
4
+ local function G(u)
5
+ if u.R then
6
+ return u.R[u.i]
7
+ end
8
+ return u.v
9
+ end
10
+ local function S(u,x)
11
+ if u.R then
12
+ u.R[u.i]=x
13
+ else
14
+ u.v=x
15
+ end
16
+ end
17
+ local function C(u)
18
+ if u.R then
19
+ u.v=u.R[u.i]
20
+ u.R=nil
21
+ u.i=nil
22
+ end
23
+ end
24
+ local function V(P,U,A)
25
+ local R={}
26
+ local K=P.k
27
+ local code=P.p
28
+ local top=0
29
+ local pc=1
30
+ local open={}
31
+ for i=1,P.n do
32
+ R[i]=A[i]
33
+ end
34
+ local VA={}
35
+ if P.v then
36
+ for i=P.n+1,A.n do
37
+ VA[#VA+1]=A[i]
38
+ end
39
+ end
40
+ local function rk(x)
41
+ if x<0 then
42
+ return K[-x]
43
+ end
44
+ return R[x]
45
+ end
46
+ while true do
47
+ local i=code[pc]
48
+ if not i then
49
+ return
50
+ end
51
+ local op=i[1]
52
+ local a=i[2]
53
+ local b=i[3]
54
+ local c=i[4]
55
+ pc=pc+1
56
+ if op==MOVE then
57
+ R[a]=R[b]
58
+ elseif op==LOADK then
59
+ R[a]=K[b]
60
+ elseif op==LOADBOOL then
61
+ R[a]=b~=0
62
+ elseif op==LOADNIL then
63
+ R[a]=nil
64
+ elseif op==GETGLOBAL then
65
+ R[a]=_ENV[K[b]]
66
+ elseif op==SETGLOBAL then
67
+ _ENV[K[b]]=R[a]
68
+ elseif op==GETTABLE then
69
+ R[a]=R[b][rk(c)]
70
+ elseif op==SETTABLE then
71
+ R[a][rk(b)]=rk(c)
72
+ elseif op==NEWTABLE then
73
+ R[a]={}
74
+ elseif op==SELF then
75
+ R[a+1]=R[b]
76
+ R[a]=R[b][rk(c)]
77
+ elseif op==ADD then
78
+ R[a]=R[b]+R[c]
79
+ elseif op==SUB then
80
+ R[a]=R[b]-R[c]
81
+ elseif op==MUL then
82
+ R[a]=R[b]*R[c]
83
+ elseif op==DIV then
84
+ R[a]=R[b]/R[c]
85
+ elseif op==IDIV then
86
+ R[a]=R[b]//R[c]
87
+ elseif op==MOD then
88
+ R[a]=R[b]%R[c]
89
+ elseif op==POW then
90
+ R[a]=R[b]^R[c]
91
+ elseif op==BAND then
92
+ R[a]=R[b]&R[c]
93
+ elseif op==BOR then
94
+ R[a]=R[b]|R[c]
95
+ elseif op==BXOR then
96
+ R[a]=R[b]~R[c]
97
+ elseif op==SHL then
98
+ R[a]=R[b]<<R[c]
99
+ elseif op==SHR then
100
+ R[a]=R[b]>>R[c]
101
+ elseif op==UNM then
102
+ R[a]=-R[b]
103
+ elseif op==BNOT then
104
+ R[a]=~R[b]
105
+ elseif op==NOT then
106
+ R[a]=not R[b]
107
+ elseif op==LEN then
108
+ R[a]=#R[b]
109
+ elseif op==CONCAT then
110
+ R[a]=R[b]..R[c]
111
+ elseif op==JMP then
112
+ pc=pc+b
113
+ elseif op==EQ then
114
+ local eq=R[a]==R[b]
115
+ local want=c==0
116
+ if eq==want then
117
+ pc=pc+1
118
+ end
119
+ elseif op==LT then
120
+ local lt=R[a]<R[b]
121
+ local want=c==0
122
+ if lt==want then
123
+ pc=pc+1
124
+ end
125
+ elseif op==LE then
126
+ local le=R[a]<=R[b]
127
+ local want=c==0
128
+ if le==want then
129
+ pc=pc+1
130
+ end
131
+ elseif op==TEST then
132
+ -- C=0\uFF1A\u771F\u5219\u8DF3\u8FC7 JMP\uFF1BC=1\uFF1A\u5047\u5219\u8DF3\u8FC7\uFF08or\uFF09\u3002\u4E0D\u7528 and/or\uFF0C\u65B9\u4FBF\u518D\u7F16\u8BD1\u3002
133
+ local take=false
134
+ if c==0 then
135
+ if R[a] then
136
+ take=true
137
+ end
138
+ else
139
+ if not R[a] then
140
+ take=true
141
+ end
142
+ end
143
+ if take then
144
+ pc=pc+1
145
+ end
146
+ elseif op==CALL then
147
+ local n=b
148
+ local args={}
149
+ local an=n
150
+ if n<0 then
151
+ an=0
152
+ local last=top
153
+ if last<a then
154
+ last=a
155
+ end
156
+ for j=a+1,last do
157
+ an=an+1
158
+ args[an]=R[j]
159
+ end
160
+ else
161
+ for j=1,n do
162
+ args[j]=R[a+j]
163
+ end
164
+ end
165
+ local rets=table.pack(R[a](table.unpack(args,1,an)))
166
+ if c==0 then
167
+ elseif c<0 then
168
+ for j=1,rets.n do
169
+ R[a+j-1]=rets[j]
170
+ end
171
+ top=a+rets.n-1
172
+ else
173
+ for j=1,c do
174
+ R[a+j-1]=rets[j]
175
+ end
176
+ top=a+c-1
177
+ end
178
+ elseif op==RETURN then
179
+ for _,u in pairs(open) do
180
+ C(u)
181
+ end
182
+ if b==0 then
183
+ return
184
+ end
185
+ if b<0 then
186
+ return table.unpack(R,a,top)
187
+ end
188
+ return table.unpack(R,a,a+b-1)
189
+ elseif op==FORPREP then
190
+ R[a]=R[a]-R[a+2]
191
+ pc=pc+b
192
+ elseif op==FORLOOP then
193
+ R[a]=R[a]+R[a+2]
194
+ local idx=R[a]
195
+ local lim=R[a+1]
196
+ local step=R[a+2]
197
+ local cont=false
198
+ if step>=0 then
199
+ if idx<=lim then
200
+ cont=true
201
+ end
202
+ else
203
+ if idx>=lim then
204
+ cont=true
205
+ end
206
+ end
207
+ if cont then
208
+ R[a+3]=idx
209
+ pc=pc+b
210
+ end
211
+ elseif op==TFORCALL then
212
+ local rets=table.pack(R[a](R[a+1],R[a+2]))
213
+ for j=1,b do
214
+ R[a+2+j]=rets[j]
215
+ end
216
+ elseif op==TFORLOOP then
217
+ if R[a+3]~=nil then
218
+ R[a+2]=R[a+3]
219
+ else
220
+ pc=pc+b
221
+ end
222
+ elseif op==CLOSURE then
223
+ local Q=P.t[b]
224
+ local nu={}
225
+ for j=1,#Q.u do
226
+ local sp=Q.u[j]
227
+ if sp[1]==1 then
228
+ local rg=sp[2]
229
+ if not open[rg] then
230
+ open[rg]={R=R,i=rg}
231
+ end
232
+ nu[j]=open[rg]
233
+ else
234
+ nu[j]=U[sp[2]]
235
+ end
236
+ end
237
+ R[a]=function(...)
238
+ return V(Q,nu,table.pack(...))
239
+ end
240
+ elseif op==VARARG then
241
+ if b<0 then
242
+ for j=1,#VA do
243
+ R[a+j-1]=VA[j]
244
+ end
245
+ top=a+#VA-1
246
+ else
247
+ for j=1,b do
248
+ R[a+j-1]=VA[j]
249
+ end
250
+ end
251
+ elseif op==SETLIST then
252
+ for j=1,c do
253
+ R[a][j]=R[b+j-1]
254
+ end
255
+ elseif op==GETUPVAL then
256
+ R[a]=G(U[b])
257
+ elseif op==SETUPVAL then
258
+ S(U[b],R[a])
259
+ elseif op==CLOSE then
260
+ if open[a] then
261
+ C(open[a])
262
+ open[a]=nil
263
+ end
264
+ local v=R[a]
265
+ if type(v)=="table" then
266
+ local mt=getmetatable(v)
267
+ local cl=v.close
268
+ if not cl then
269
+ if mt then
270
+ cl=mt.__close
271
+ end
272
+ end
273
+ if cl then
274
+ pcall(cl,v)
275
+ end
276
+ end
277
+ end
278
+ end
279
+ end
280
+ V(${R},{},table.pack())
281
+ end)()`}
@@ -0,0 +1,2 @@
1
+ import type { Chunk } from "./ast";
2
+ export declare function wrapInFunction(chunk: Chunk): void;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.wrapInFunction=t;function t(e){const r=e.body;e.body=[{type:"CallStat",exp:{type:"CallExpr",callee:{type:"ParenExpr",exp:{type:"FuncExpr",params:[],vararg:!0,body:{type:"Block",body:r}}},args:[{type:"VarargExpr"}]}}]}
package/docs/AGENTS.md CHANGED
@@ -13,7 +13,7 @@
13
13
  - Lua 项目使用 Lua 文档与写法。
14
14
  - 不要混用 JavaScript、Python 与 Lua API。
15
15
  - Lua 只提供英文方法,没有中文别名。
16
- - Lua 模块通过 `require("device")` 加载;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
16
+ - Lua 宿主模块是内置全局表(如 `device`),不要 `require`;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
17
17
  - 不要把快点JS Python 脚本当成普通 CPython 脚本。
18
18
  - 不要对快点JS Python 脚本运行 `python -m py_compile`、`py_compile` 或类似 CPython 编译校验。
19
19
  - 不要创建、保留或同步 `__pycache__`、`.pyc` 作为项目改动。
package/docs/SKILL.md CHANGED
@@ -20,7 +20,7 @@ description: 快点JS专用开发助手。用于快点JS项目开发、本地 AP
20
20
  - Lua 项目使用 Lua 文档与写法。
21
21
  - 不要混用 JavaScript、Python 与 Lua API。
22
22
  - Lua 只提供英文方法,没有中文别名。
23
- - Lua 模块通过 `require("device")` 加载;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
23
+ - Lua 宿主模块是内置全局表(如 `device`),不要 `require`;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
24
24
  - Lua 用户模块请用 `require("foo")` / `require("lib.bar")`。Release 打包默认会把 `scripts` 下除 `main.lua` 外的用户 `.lua` 合并进单个 `main.lua`;不要用 `dofile` / `loadfile` 按路径加载这些文件。
25
25
  - 文档未确认的能力必须明确说明无法确认,并给出保守方案。
26
26
  - 快点JS Python 脚本不使用 CPython 编译校验;不要运行 `python -m py_compile`、`py_compile` 或类似命令。
package/docs/api/hid.md CHANGED
@@ -289,6 +289,27 @@ function setJitterValue(value: number): void;
289
289
  hid.setJitterValue(5);
290
290
  ```
291
291
 
292
+ ### setActionDelay - 设置动作延迟
293
+
294
+ 设置连续点击/滑动之间的等待毫秒。不调用时用固件默认(相对 200ms / 绝对 100ms)。
295
+
296
+ ```typescript
297
+ function setActionDelay(milliseconds: number): boolean;
298
+ ```
299
+
300
+ **参数:**
301
+ | 参数 | 类型 | 必需 | 默认值 | 描述 |
302
+ | ---- | ---- | ---- | ------ | ---- |
303
+ | `milliseconds` | number | 是 | `-1` | `0` 关闭,`>0` 覆盖毫秒,`-1` 恢复默认 |
304
+
305
+ **示例:**
306
+
307
+ ```javascript
308
+ hid.setActionDelay(0);
309
+ hid.click(100, 200);
310
+ hid.click(300, 400);
311
+ ```
312
+
292
313
  ## 基础触摸操作
293
314
 
294
315
  ### click - 点击操作
package/docs/apicn/hid.md CHANGED
@@ -289,6 +289,27 @@ function 设置抖动值(抖动值: 数字): 无返回值;
289
289
  $HID.设置抖动值(5);
290
290
  ```
291
291
 
292
+ ### 设置动作延迟
293
+
294
+ 设置连续点击/滑动之间的等待毫秒。不调用时用固件默认(相对 200ms / 绝对 100ms)。
295
+
296
+ ```typescript
297
+ function 设置动作延迟(毫秒: 数字): 布尔值;
298
+ ```
299
+
300
+ **参数:**
301
+ | 参数 | 类型 | 必需 | 默认值 | 描述 |
302
+ | ---- | ---- | ---- | ------ | ---- |
303
+ | `毫秒` | 数字 | 是 | `-1` | `0` 关闭,`>0` 覆盖毫秒,`-1` 恢复默认 |
304
+
305
+ **示例:**
306
+
307
+ ```javascript
308
+ $HID.设置动作延迟(0);
309
+ $HID.点击(100, 200);
310
+ $HID.点击(300, 400);
311
+ ```
312
+
292
313
  ## 基础触摸操作
293
314
 
294
315
  ### 点击
@@ -1,5 +1,7 @@
1
1
  # 动作模块 (Action)
2
2
 
3
+ 模块表是内置全局 `action`,直接调用即可。不要 `require` 宿主模块。
4
+
3
5
  动作模块提供了丰富的触摸和按键操作功能,包括点击、滑动、长按滑动、返回首页、多点触摸等动作。
4
6
 
5
7
  **注意事项**
@@ -26,7 +28,6 @@ function setJitterValue(value) end
26
28
  **示例:**
27
29
 
28
30
  ```lua
29
- local action = require("action")
30
31
  -- 设置抖动值为5像素
31
32
  action.setJitterValue(5)
32
33
  ```
@@ -61,7 +62,6 @@ function click(x, y, duration, jitter) end
61
62
  **示例:**
62
63
 
63
64
  ```lua
64
- local action = require("action")
65
65
  -- 基础点击
66
66
  local success = action.click(100, 100, 20, false)
67
67
  if success then
@@ -105,7 +105,6 @@ function clickRandom(x1, y1, x2, y2, duration) end
105
105
  **示例:**
106
106
 
107
107
  ```lua
108
- local action = require("action")
109
108
  -- 在指定矩形区域内随机点击
110
109
  action.clickRandom(100, 100, 200, 200, 20)
111
110
  -- 在更大区域内随机点击
@@ -145,7 +144,6 @@ function doubleClick(x, y, duration, interval, jitter) end
145
144
  **示例:**
146
145
 
147
146
  ```lua
148
- local action = require("action")
149
147
  -- 基础双击
150
148
  local success = action.doubleClick(100, 100, 20, 20, false)
151
149
  if success then
@@ -190,7 +188,6 @@ function doubleClickRandom(x1, y1, x2, y2, duration, interval) end
190
188
  **示例:**
191
189
 
192
190
  ```lua
193
- local action = require("action")
194
191
  -- 在指定矩形区域内随机双击
195
192
  action.doubleClickRandom(100, 100, 200, 200, 20, 20)
196
193
  -- 慢速随机双击
@@ -232,7 +229,6 @@ function swipe(startX, startY, endX, endY, duration, jitter, steps) end
232
229
  **示例:**
233
230
 
234
231
  ```lua
235
- local action = require("action")
236
232
  -- 基础滑动(从左到右)
237
233
  action.swipe(100, 300, 400, 300, 500, false, 10)
238
234
  -- 向上滑动(滚动页面)
@@ -286,7 +282,6 @@ function pressAndSwipe(startX, startY, endX, endY, touch_down_duration, touch_mo
286
282
  **示例:**
287
283
 
288
284
  ```lua
289
- local action = require("action")
290
285
  -- 拖拽元素
291
286
  action.pressAndSwipe(
292
287
  100,
@@ -350,7 +345,6 @@ function swipeCurve(startX, startY, midX, midY, endX, endY, duration) end
350
345
  **示例:**
351
346
 
352
347
  ```lua
353
- local action = require("action")
354
348
  -- 基础曲线滑动
355
349
  action.swipeCurve(100, 100, 200, 150, 300, 200, 1000)
356
350
  -- 弧形向上滑动
@@ -391,7 +385,6 @@ function input(text) end
391
385
  **示例:**
392
386
 
393
387
  ```lua
394
- local action = require("action")
395
388
  -- 输入文本
396
389
  local success = action.input("hello 快点JS")
397
390
  if success then
@@ -418,7 +411,6 @@ function inputSimple(text) end
418
411
  **示例:**
419
412
 
420
413
  ```lua
421
- local action = require("action")
422
414
  local success = action.inputSimple("hello_123")
423
415
  if success then
424
416
  print("成功输入文本")
@@ -448,7 +440,6 @@ function backspace(count) end
448
440
  **示例:**
449
441
 
450
442
  ```lua
451
- local action = require("action")
452
443
  -- 删除最后一个字符
453
444
  local success = action.backspace()
454
445
  if success then
@@ -477,7 +468,6 @@ function enter() end
477
468
  **示例:**
478
469
 
479
470
  ```lua
480
- local action = require("action")
481
471
  -- 调用回车
482
472
  local success = action.enter()
483
473
  if success then
@@ -503,7 +493,6 @@ function homeScreen() end
503
493
  **示例:**
504
494
 
505
495
  ```lua
506
- local action = require("action")
507
496
  -- 返回主屏幕
508
497
  local success = action.homeScreen()
509
498
  if success then
@@ -541,7 +530,6 @@ function pressButton(button) end
541
530
  **示例:**
542
531
 
543
532
  ```lua
544
- local action = require("action")
545
533
  -- 按下 Home 键
546
534
  action.pressButton("home")
547
535
  -- 调高音量
@@ -568,7 +556,6 @@ function sendKey(key) end
568
556
  **示例:**
569
557
 
570
558
  ```lua
571
- local action = require("action")
572
559
  action.sendKey({ "COMMAND", "c" })
573
560
  action.sendKey({ 0xe3, 0x06 })
574
561
  action.sendKey({ HidKey.COMMAND, "v" })
@@ -585,7 +572,6 @@ function w3cActions(json) end
585
572
  **示例:**
586
573
 
587
574
  ```lua
588
- local action = require("action")
589
575
  action.w3cActions({
590
576
  actions = {
591
577
  {
@@ -618,7 +604,6 @@ function createBuilder() end
618
604
  **示例:**
619
605
 
620
606
  ```lua
621
- local action = require("action")
622
607
  -- 创建构建器
623
608
  local builder = action.createBuilder()
624
609
  ```
@@ -650,7 +635,6 @@ function addPointer(id) end
650
635
  **示例:**
651
636
 
652
637
  ```lua
653
- local action = require("action")
654
638
  local builder = action.createBuilder()
655
639
  -- 添加第一个手指
656
640
  local pointer1 = builder:addPointer(1)
@@ -685,7 +669,6 @@ function singleTap(x, y, duration) end
685
669
  **示例:**
686
670
 
687
671
  ```lua
688
- local action = require("action")
689
672
  local builder = action.createBuilder()
690
673
  -- 快速单点点击
691
674
  builder:singleTap(100, 100, 50):execute()
@@ -718,7 +701,6 @@ function multiTap(points, duration) end
718
701
  **示例:**
719
702
 
720
703
  ```lua
721
- local action = require("action")
722
704
  local builder = action.createBuilder()
723
705
  -- 多点同时点击
724
706
  local points = { { x = 100, y = 100 },
@@ -753,7 +735,6 @@ function execute() end
753
735
  **示例:**
754
736
 
755
737
  ```lua
756
- local action = require("action")
757
738
  local builder = action.createBuilder()
758
739
  -- 执行构建的动作
759
740
  local success = builder
@@ -888,7 +869,6 @@ function done() end
888
869
  ### 单指滑动
889
870
 
890
871
  ```lua
891
- local action = require("action")
892
872
  -- 单指从左到右滑动
893
873
  local builder = action.createBuilder()
894
874
  builder
@@ -904,7 +884,6 @@ builder
904
884
  ### 双指缩放(放大)
905
885
 
906
886
  ```lua
907
- local action = require("action")
908
887
  -- 双指从中心向外扩展
909
888
  local builder = action.createBuilder()
910
889
  builder
@@ -926,7 +905,6 @@ builder
926
905
  ### 双指缩放(缩小)
927
906
 
928
907
  ```lua
929
- local action = require("action")
930
908
  -- 双指从外向中心收缩
931
909
  local builder = action.createBuilder()
932
910
  builder
@@ -948,7 +926,6 @@ builder
948
926
  ### 双指旋转
949
927
 
950
928
  ```lua
951
- local action = require("action")
952
929
  -- 双指围绕中心点旋转
953
930
  local builder = action.createBuilder()
954
931
  local centerX = 200,
@@ -976,7 +953,6 @@ builder
976
953
  ### 长按拖拽
977
954
 
978
955
  ```lua
979
- local action = require("action")
980
956
  -- 长按后拖拽元素
981
957
  local builder = action.createBuilder()
982
958
  builder
@@ -993,7 +969,6 @@ builder
993
969
  ### 复杂手势组合
994
970
 
995
971
  ```lua
996
- local action = require("action")
997
972
  -- 先点击,再滑动,最后双击
998
973
  local builder = action.createBuilder()
999
974
  -- 第一步:单击
@@ -1,5 +1,7 @@
1
1
  # AppleOCR 模块
2
2
 
3
+ 模块表是内置全局 `appleocr`,直接调用即可。不要 `require` 宿主模块。
4
+
3
5
  AppleOCR 模块基于 Apple Vision 框架,提供原生的光学字符识别(OCR)功能。该模块利用 iOS 系统内置的机器学习能力,无需额外模型文件,具有高效、准确的特点。
4
6
 
5
7
  <span style="color: red;">此模块仅支持 iOS 系统。</span>
@@ -95,8 +97,6 @@ function recognizeAbs(input, x, y, ex, ey, languages) end
95
97
  **示例:**
96
98
 
97
99
  ```lua
98
- local appleocr = require("appleocr")
99
- local action = require("action")
100
100
  local absResults = appleocr.recognizeAbs("screen", 100, 100, 500, 300)
101
101
  if #absResults > 0 then
102
102
  action.click(absResults[1].centerX, absResults[1].centerY)
@@ -141,8 +141,6 @@ function recognizeNumbersAbs(input, x, y, ex, ey) end
141
141
  **示例:**
142
142
 
143
143
  ```lua
144
- local appleocr = require("appleocr")
145
- local action = require("action")
146
144
  local absNumberResults = appleocr.recognizeNumbersAbs("screen", 100, 100, 500, 300)
147
145
  if #absNumberResults > 0 then
148
146
  action.click(absNumberResults[1].centerX, absNumberResults[1].centerY)
@@ -191,8 +189,6 @@ function findTextAbs(input, texts, x, y, ex, ey, languages, exactMatch) end
191
189
  **示例:**
192
190
 
193
191
  ```lua
194
- local appleocr = require("appleocr")
195
- local action = require("action")
196
192
  local absHits = appleocr.findTextAbs("screen", { "开始" }, 100, 100, 500, 400)
197
193
  if #absHits > 0 then
198
194
  action.click(absHits[1].centerX, absHits[1].centerY)
@@ -1,5 +1,7 @@
1
1
  # 云控模块 (Cloud)
2
2
 
3
+ 模块表是内置全局 `cloud`,直接调用即可。不要 `require` 宿主模块。
4
+
3
5
  云控模块用于在主脚本中使用内置云控 WebSocket 连接。脚本可以主动连接云控服务器、判断连接状态、断开连接、上报事件数据,并监听服务器事件数据。
4
6
 
5
7
  ## 注意事项
@@ -64,7 +66,6 @@ function connect(url, deviceNo) end
64
66
  **示例**
65
67
 
66
68
  ```lua
67
- local cloud = require("cloud")
68
69
  local accepted = cloud.connect("wss = //example.com/control", "device-001")
69
70
  print("云控连接请求:", accepted)
70
71
  ```
@@ -85,7 +86,6 @@ function isConnected() end
85
86
  **示例**
86
87
 
87
88
  ```lua
88
- local cloud = require("cloud")
89
89
  if cloud.isConnected() then
90
90
  cloud.report("status", { value = "ready" })
91
91
  end
@@ -102,7 +102,6 @@ function disconnect() end
102
102
  **示例**
103
103
 
104
104
  ```lua
105
- local cloud = require("cloud")
106
105
  cloud.disconnect()
107
106
  ```
108
107
 
@@ -131,7 +130,6 @@ function report(event, data) end
131
130
  **示例**
132
131
 
133
132
  ```lua
134
- local cloud = require("cloud")
135
133
  local ok = cloud.report("taskFinished", {
136
134
  taskId = "A-1001",
137
135
  success = true,
@@ -147,7 +145,6 @@ print("上报结果:", ok)
147
145
  `data` 的 key 必须使用云控端已经配置好的设备总览自定义字段名。上报了云控端未配置的多余字段时,协议仍可发送,但云控端设备总览不会显示这些字段。
148
146
 
149
147
  ```lua
150
- local cloud = require("cloud")
151
148
  cloud.report("cloud = status", {
152
149
  taskName = "巡检任务",
153
150
  progress = 80,
@@ -174,7 +171,6 @@ function onEvent(callback) end
174
171
  **示例**
175
172
 
176
173
  ```lua
177
- local cloud = require("cloud")
178
174
  cloud.onEvent(function(event, data)
179
175
  if event == "startTask" then
180
176
  print("任务参数:", data)