ms-vite-plugin 1.4.58 → 1.4.60

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/media.md +22 -0
  49. package/docs/apicn/media.md +22 -0
  50. package/docs/apilua/action.md +2 -27
  51. package/docs/apilua/appleocr.md +41 -126
  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 +2 -44
  60. package/docs/apilua/hotUpdate.md +2 -3
  61. package/docs/apilua/http.md +2 -7
  62. package/docs/apilua/image.md +16 -107
  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 +4 -30
  70. package/docs/apilua/paddleocr.md +20 -126
  71. package/docs/apilua/pip.md +2 -12
  72. package/docs/apilua/system.md +2 -40
  73. package/docs/apilua/tomatoocr.md +2 -16
  74. package/docs/apilua/tts.md +2 -9
  75. package/docs/apilua/ui.md +3 -22
  76. package/docs/apilua/utils.md +2 -9
  77. package/docs/apilua/yolo.md +25 -119
  78. package/docs/apilua/yolocls.md +2 -5
  79. package/docs/apipython/media.md +20 -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=o;const s=require("./visit");function u(t){let r={type:"StringLiteral",value:t[0]};for(let n=1;n<t.length;n+=1)r={type:"BinaryExpr",op:"..",left:r,right:{type:"StringLiteral",value:t[n]}};return{type:"ParenExpr",exp:r}}function c(t,r){if(t.length<4)return[t];const n=r%2+2,e=Math.max(1,Math.ceil(t.length/n)),i=[];for(let l=0;l<t.length;l+=e)i.push(t.slice(l,l+e));return i}function o(t,r){let n=0;(0,s.mapChunk)(t,e=>{if(e.type!=="StringLiteral"||e.encoded||e.value.length<4)return e;n+=1;const i=c(e.value,r+n);return i.length<2?e:u(i)})}
@@ -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 i=require("./parser"),l=require("./visit"),c="__d";function d(t,o){let e=2166136261^o;for(let r=0;r<t.length;r+=1)e=Math.imul(e^t.charCodeAt(r),16777619);return e>>>0||1}function p(t,o,e){const r=(0,a.foldEncrypt)(t,o,e);return{type:"CallExpr",callee:{type:"NameExpr",name:c},args:[{type:"StringLiteral",value:r,encoded:!0},{type:"NumberLiteral",raw:String(e),value:e}]}}function y(t,o){const e=(0,a.createFoldMixParams)(o);let r=0;(0,l.mapChunk)(t,n=>n.type!=="StringLiteral"||n.encoded||n.value.length===0?n:(r+=1,p(n.value,e,d(n.value,r))));const u=(0,i.parseLua)((0,a.emitFoldDecoderLua)(e,c));t.body.unshift(...u.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=r,exports.mapFunc=o,exports.mapStats=c,exports.mapChunk=b;function r(t,e){switch(t.type){case"UnaryExpr":t.arg=r(t.arg,e);break;case"BinaryExpr":t.left=r(t.left,e),t.right=r(t.right,e);break;case"FuncExpr":o(t,e);break;case"TableExpr":for(const a of t.fields)a.kind==="index"&&(a.key=r(a.key,e)),a.value=r(a.value,e);break;case"IndexExpr":t.object=r(t.object,e),t.index=r(t.index,e);break;case"MemberExpr":t.object=r(t.object,e);break;case"CallExpr":t.callee=r(t.callee,e),t.args=t.args.map(a=>r(a,e));break;case"MethodCallExpr":t.object=r(t.object,e),t.args=t.args.map(a=>r(a,e));break;case"ParenExpr":t.exp=r(t.exp,e);break;default:break}return e(t)}function o(t,e){c(t.body.body,e)}function c(t,e){for(const a of t)switch(a.type){case"DoStat":c(a.body.body,e);break;case"WhileStat":a.cond=r(a.cond,e),c(a.body.body,e);break;case"RepeatStat":c(a.body.body,e),a.cond=r(a.cond,e);break;case"IfStat":for(const s of a.clauses)s.cond=r(s.cond,e),c(s.body.body,e);a.elseBody&&c(a.elseBody.body,e);break;case"ForNumStat":a.start=r(a.start,e),a.end=r(a.end,e),a.step&&(a.step=r(a.step,e)),c(a.body.body,e);break;case"ForInStat":a.exps=a.exps.map(s=>r(s,e)),c(a.body.body,e);break;case"FuncStat":o(a.func,e);break;case"LocalFuncStat":o(a.func,e);break;case"LocalStat":a.exps&&(a.exps=a.exps.map(s=>r(s,e)));break;case"AssignStat":a.vars=a.vars.map(s=>r(s,e)),a.exps=a.exps.map(s=>r(s,e));break;case"CallStat":a.exp=r(a.exp,e);break;case"ReturnStat":a.exps=a.exps.map(s=>r(s,e));break;default:break}}function b(t,e){c(t.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 s=require("./cipher"),h=require("./minify"),f=require("./opcodes");function u(e){let n=2166136261^e.code.length;return n=Math.imul(n,16777619)^e.consts.length,n>>>0}function b(e,n,o){if(e.t==="nil")return"nil";if(e.t==="bool")return e.v?"true":"false";if(e.t==="num")return e.raw;const l=(0,s.foldEncrypt)(e.v,n,o);return`D(${(0,h.escapeLuaString)(l)},${o})`}function r(e,n,o,l){const c=e.code.map((t,a)=>{const d=e.ops[a];return`{${n[d]},${t[1]},${t[2]},${t[3]}}`}).join(","),i=e.consts.map((t,a)=>b(t,o,l+a*131>>>0||1)).join(","),R=e.protos.map((t,a)=>r(t,n,o,l+(a+1)*4099>>>0)).join(","),p=e.upvals.map(t=>`{${t.inStack?1:0},${t.index}}`).join(",");return`{p={${c}},k={${i}},t={${R}},u={${p}},n=${e.numparams},v=${e.isVararg?"true":"false"}}`}function j(e){const n=u(e)||1,o=(0,f.shuffleOpcodes)(n),l=(0,s.createFoldMixParams)(n),c=f.OPCODE_NAMES.join(","),i=f.OPCODE_NAMES.map(t=>String(o[t])).join(","),R=r(e,o,l,n);return`(function()
2
+ ${(0,s.emitFoldDecoderLua)(l,"D")}
3
+ local ${c}=${i}
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/media.md CHANGED
@@ -245,3 +245,25 @@ if (played) {
245
245
  logi("播放失败或被系统音频中断");
246
246
  }
247
247
  ```
248
+
249
+ #### isMp3Playing - 当前是否正在播放 MP3。
250
+
251
+ ```typescript
252
+ function isMp3Playing(): boolean;
253
+ ```
254
+
255
+ **返回值:**
256
+
257
+ | 类型 | 描述 |
258
+ | --------- | -------------------------------- |
259
+ | `boolean` | 正在播放返回 `true`,否则 `false` |
260
+
261
+ **示例:**
262
+
263
+ ```javascript
264
+ if (media.isMp3Playing()) {
265
+ logi("正在播放");
266
+ } else {
267
+ logi("未播放");
268
+ }
269
+ ```
@@ -249,3 +249,25 @@ if (是否播放成功) {
249
249
  $打印错误日志("播放失败或被系统音频中断");
250
250
  }
251
251
  ```
252
+
253
+ #### 查询MP3音乐是否正在播放 - 当前是否正在播放 MP3。
254
+
255
+ ```typescript
256
+ function 查询MP3音乐是否正在播放(): 布尔值;
257
+ ```
258
+
259
+ **返回值:**
260
+
261
+ | 类型 | 描述 |
262
+ | -------- | ---------------------------------- |
263
+ | `布尔值` | 正在播放返回 `true`,否则 `false` |
264
+
265
+ **示例:**
266
+
267
+ ```javascript
268
+ if ($媒体.查询MP3音乐是否正在播放()) {
269
+ $打印信息日志("正在播放");
270
+ } else {
271
+ $打印信息日志("未播放");
272
+ }
273
+ ```
@@ -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
  -- 第一步:单击