assistsx-js 0.2.2 → 0.2.4

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/index.js CHANGED
@@ -149,6 +149,7 @@ var CallMethod = {
149
149
  performLinearGesture: "performLinearGesture",
150
150
  longPressGestureAutoPaste: "longPressGestureAutoPaste",
151
151
  getAppInfo: "getAppInfo",
152
+ getCurrentPlugin: "getCurrentPlugin",
152
153
  getMacAddress: "getMacAddress",
153
154
  getAndroidID: "getAndroidID",
154
155
  getUniqueDeviceId: "getUniqueDeviceId",
@@ -269,6 +270,52 @@ var AppInfo = class _AppInfo {
269
270
  }
270
271
  };
271
272
 
273
+ // src/plugin-info.ts
274
+ var PluginInfo = class _PluginInfo {
275
+ constructor(id = "", name = "", packageName = "", versionName = "", versionCode = 0, description = "", path = "", index = "", port = 0, needScreenCapture = false) {
276
+ this.id = id;
277
+ this.name = name;
278
+ this.packageName = packageName;
279
+ this.versionName = versionName;
280
+ this.versionCode = versionCode;
281
+ this.description = description;
282
+ this.path = path;
283
+ this.index = index;
284
+ this.port = port;
285
+ this.needScreenCapture = needScreenCapture;
286
+ }
287
+ static fromJSON(data) {
288
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
289
+ const record = data != null ? data : {};
290
+ return new _PluginInfo(
291
+ String((_a2 = record.id) != null ? _a2 : ""),
292
+ String((_b = record.name) != null ? _b : ""),
293
+ String((_c = record.packageName) != null ? _c : ""),
294
+ String((_d = record.versionName) != null ? _d : ""),
295
+ Number((_e = record.versionCode) != null ? _e : 0),
296
+ String((_f = record.description) != null ? _f : ""),
297
+ String((_g = record.path) != null ? _g : ""),
298
+ String((_h = record.index) != null ? _h : ""),
299
+ Number((_i = record.port) != null ? _i : 0),
300
+ Boolean((_j = record.needScreenCapture) != null ? _j : false)
301
+ );
302
+ }
303
+ toJSON() {
304
+ return {
305
+ id: this.id,
306
+ name: this.name,
307
+ packageName: this.packageName,
308
+ versionName: this.versionName,
309
+ versionCode: this.versionCode,
310
+ description: this.description,
311
+ path: this.path,
312
+ index: this.index,
313
+ port: this.port,
314
+ needScreenCapture: this.needScreenCapture
315
+ };
316
+ }
317
+ };
318
+
272
319
  // src/device-info.ts
273
320
  var DeviceInfo = class _DeviceInfo {
274
321
  constructor(uniqueDeviceId = "", androidID = "", macAddress = "", isDeviceRooted = false, manufacturer = "", model = "", sdkVersionCode = 0, sdkVersionName = "", abiList = [], isAdbEnabled = false, isDevelopmentSettingsEnabled = false, isEmulator = false, isTablet = false) {
@@ -332,6 +379,137 @@ var DeviceInfo = class _DeviceInfo {
332
379
  }
333
380
  };
334
381
 
382
+ // src/window-flags.ts
383
+ var _WindowFlags = class _WindowFlags {
384
+ // 0x1000000
385
+ /**
386
+ * 获取标志位的十六进制表示
387
+ * @param flag 标志位值
388
+ * @returns 十六进制字符串
389
+ */
390
+ static toHex(flag) {
391
+ return `0x${flag.toString(16).toUpperCase()}`;
392
+ }
393
+ /**
394
+ * 检查是否包含指定标志位
395
+ * @param flags 当前标志位组合
396
+ * @param flag 要检查的标志位
397
+ * @returns 是否包含该标志位
398
+ */
399
+ static hasFlag(flags, flag) {
400
+ return (flags & flag) === flag;
401
+ }
402
+ /**
403
+ * 添加标志位
404
+ * @param flags 当前标志位组合
405
+ * @param flag 要添加的标志位
406
+ * @returns 新的标志位组合
407
+ */
408
+ static addFlag(flags, flag) {
409
+ return flags | flag;
410
+ }
411
+ /**
412
+ * 移除标志位
413
+ * @param flags 当前标志位组合
414
+ * @param flag 要移除的标志位
415
+ * @returns 新的标志位组合
416
+ */
417
+ static removeFlag(flags, flag) {
418
+ return flags & ~flag;
419
+ }
420
+ /** 输入框获取焦点时使用的悬浮窗 flag 组合(不含 FLAG_NOT_FOCUSABLE) */
421
+ static getOverlayInputFocusFlagList() {
422
+ return [
423
+ _WindowFlags.FLAG_WATCH_OUTSIDE_TOUCH,
424
+ _WindowFlags.FLAG_NOT_TOUCH_MODAL,
425
+ _WindowFlags.FLAG_LAYOUT_NO_LIMITS,
426
+ _WindowFlags.FLAG_LAYOUT_IN_SCREEN
427
+ ];
428
+ }
429
+ /** 输入框失去焦点时使用的悬浮窗 flag 组合(含 FLAG_NOT_FOCUSABLE) */
430
+ static getOverlayInputBlurFlagList() {
431
+ return [
432
+ _WindowFlags.FLAG_WATCH_OUTSIDE_TOUCH,
433
+ _WindowFlags.FLAG_NOT_TOUCH_MODAL,
434
+ _WindowFlags.FLAG_LAYOUT_NO_LIMITS,
435
+ _WindowFlags.FLAG_NOT_FOCUSABLE,
436
+ _WindowFlags.FLAG_LAYOUT_IN_SCREEN
437
+ ];
438
+ }
439
+ /**
440
+ * 获取所有标志位的描述信息
441
+ * @returns 标志位描述对象数组
442
+ */
443
+ static getAllFlags() {
444
+ return [
445
+ { name: "FLAG_NOT_FOCUSABLE", value: this.FLAG_NOT_FOCUSABLE, hex: this.toHex(this.FLAG_NOT_FOCUSABLE), description: "\u4E0D\u83B7\u53D6\u7126\u70B9" },
446
+ { name: "FLAG_NOT_TOUCHABLE", value: this.FLAG_NOT_TOUCHABLE, hex: this.toHex(this.FLAG_NOT_TOUCHABLE), description: "\u4E0D\u54CD\u5E94\u89E6\u6478" },
447
+ { name: "FLAG_NOT_TOUCH_MODAL", value: this.FLAG_NOT_TOUCH_MODAL, hex: this.toHex(this.FLAG_NOT_TOUCH_MODAL), description: "\u4E0D\u62E6\u622A\u89E6\u6478" },
448
+ { name: "FLAG_WATCH_OUTSIDE_TOUCH", value: this.FLAG_WATCH_OUTSIDE_TOUCH, hex: this.toHex(this.FLAG_WATCH_OUTSIDE_TOUCH), description: "\u76D1\u542C\u7A97\u5916\u70B9\u51FB" },
449
+ { name: "FLAG_LAYOUT_NO_LIMITS", value: this.FLAG_LAYOUT_NO_LIMITS, hex: this.toHex(this.FLAG_LAYOUT_NO_LIMITS), description: "\u53EF\u7ED8\u5236\u8D85\u51FA\u5C4F\u5E55" },
450
+ { name: "FLAG_LAYOUT_IN_SCREEN", value: this.FLAG_LAYOUT_IN_SCREEN, hex: this.toHex(this.FLAG_LAYOUT_IN_SCREEN), description: "\u5C4F\u5E55\u5168\u533A\u57DF\u5E03\u5C40" },
451
+ { name: "FLAG_FULLSCREEN", value: this.FLAG_FULLSCREEN, hex: this.toHex(this.FLAG_FULLSCREEN), description: "\u5168\u5C4F\u663E\u793A" },
452
+ { name: "FLAG_DIM_BEHIND", value: this.FLAG_DIM_BEHIND, hex: this.toHex(this.FLAG_DIM_BEHIND), description: "\u80CC\u666F\u53D8\u6697" },
453
+ { name: "FLAG_SECURE", value: this.FLAG_SECURE, hex: this.toHex(this.FLAG_SECURE), description: "\u9632\u5F55\u5C4F\u9632\u622A\u56FE" },
454
+ { name: "FLAG_KEEP_SCREEN_ON", value: this.FLAG_KEEP_SCREEN_ON, hex: this.toHex(this.FLAG_KEEP_SCREEN_ON), description: "\u4FDD\u6301\u5E38\u4EAE" },
455
+ { name: "FLAG_SHOW_WHEN_LOCKED", value: this.FLAG_SHOW_WHEN_LOCKED, hex: this.toHex(this.FLAG_SHOW_WHEN_LOCKED), description: "\u9501\u5C4F\u65F6\u53EF\u89C1" },
456
+ { name: "FLAG_DISMISS_KEYGUARD", value: this.FLAG_DISMISS_KEYGUARD, hex: this.toHex(this.FLAG_DISMISS_KEYGUARD), description: "\u89E3\u9501\u5C4F\u5E55" },
457
+ { name: "FLAG_TURN_SCREEN_ON", value: this.FLAG_TURN_SCREEN_ON, hex: this.toHex(this.FLAG_TURN_SCREEN_ON), description: "\u70B9\u4EAE\u5C4F\u5E55" },
458
+ { name: "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON", value: this.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, hex: this.toHex(this.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON), description: "\u81EA\u52A8\u9501\u5C4F\uFF08\u4E0D\u5E38\u7528\uFF09" },
459
+ { name: "FLAG_SHOW_WALLPAPER", value: this.FLAG_SHOW_WALLPAPER, hex: this.toHex(this.FLAG_SHOW_WALLPAPER), description: "\u663E\u793A\u5899\u7EB8" },
460
+ { name: "FLAG_HARDWARE_ACCELERATED", value: this.FLAG_HARDWARE_ACCELERATED, hex: this.toHex(this.FLAG_HARDWARE_ACCELERATED), description: "\u5F3A\u5236\u786C\u4EF6\u52A0\u901F" }
461
+ ];
462
+ }
463
+ };
464
+ /** 不获取焦点 */
465
+ _WindowFlags.FLAG_NOT_FOCUSABLE = 8;
466
+ // 0x08
467
+ /** 不响应触摸 */
468
+ _WindowFlags.FLAG_NOT_TOUCHABLE = 16;
469
+ // 0x10
470
+ /** 不拦截触摸 */
471
+ _WindowFlags.FLAG_NOT_TOUCH_MODAL = 32;
472
+ // 0x20
473
+ /** 监听窗外点击 */
474
+ _WindowFlags.FLAG_WATCH_OUTSIDE_TOUCH = 4;
475
+ // 0x04
476
+ /** 可绘制超出屏幕 */
477
+ _WindowFlags.FLAG_LAYOUT_NO_LIMITS = 512;
478
+ // 0x200
479
+ /** 屏幕全区域布局 */
480
+ _WindowFlags.FLAG_LAYOUT_IN_SCREEN = 256;
481
+ // 0x100
482
+ /** 全屏显示 */
483
+ _WindowFlags.FLAG_FULLSCREEN = 1024;
484
+ // 0x400
485
+ /** 背景变暗 */
486
+ _WindowFlags.FLAG_DIM_BEHIND = 2;
487
+ // 0x02
488
+ /** 防录屏防截图 */
489
+ _WindowFlags.FLAG_SECURE = 8192;
490
+ // 0x2000
491
+ /** 保持常亮 */
492
+ _WindowFlags.FLAG_KEEP_SCREEN_ON = 128;
493
+ // 0x80
494
+ /** 锁屏时可见 */
495
+ _WindowFlags.FLAG_SHOW_WHEN_LOCKED = 524288;
496
+ // 0x80000
497
+ /** 解锁屏幕 */
498
+ _WindowFlags.FLAG_DISMISS_KEYGUARD = 4194304;
499
+ // 0x400000
500
+ /** 点亮屏幕 */
501
+ _WindowFlags.FLAG_TURN_SCREEN_ON = 2097152;
502
+ // 0x200000
503
+ /** 自动锁屏(不常用) */
504
+ _WindowFlags.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 128;
505
+ // 0x80
506
+ /** 显示墙纸 */
507
+ _WindowFlags.FLAG_SHOW_WALLPAPER = 1048576;
508
+ // 0x100000
509
+ /** 强制硬件加速 */
510
+ _WindowFlags.FLAG_HARDWARE_ACCELERATED = 16777216;
511
+ var WindowFlags = _WindowFlags;
512
+
335
513
  // src/assistsx-async.ts
336
514
  var AssistsXAsync = class {
337
515
  /**
@@ -403,6 +581,18 @@ var AssistsXAsync = class {
403
581
  });
404
582
  return response.getDataOrDefault(false);
405
583
  }
584
+ /**
585
+ * 设置悬浮窗可获取焦点(WebView 内输入框 focus 时调用)
586
+ */
587
+ static async setOverlayInputFocus(timeout) {
588
+ return this.setOverlayFlagList(WindowFlags.getOverlayInputFocusFlagList(), timeout);
589
+ }
590
+ /**
591
+ * 取消悬浮窗焦点(WebView 内输入框 blur 时调用)
592
+ */
593
+ static async clearOverlayInputFocus(timeout) {
594
+ return this.setOverlayFlagList(WindowFlags.getOverlayInputBlurFlagList(), timeout);
595
+ }
406
596
  /**
407
597
  * 获取所有符合条件的节点
408
598
  * @param filterClass 类名过滤
@@ -1168,6 +1358,22 @@ var AssistsXAsync = class {
1168
1358
  });
1169
1359
  return AppInfo.fromJSON(response.getDataOrDefault({}));
1170
1360
  }
1361
+ /**
1362
+ * 获取当前运行的 AssistsX 插件信息(仅 AssistsX 宿主有效,否则返回 null)
1363
+ */
1364
+ static async getCurrentPlugin(timeout) {
1365
+ const response = await this.asyncCall(CallMethod.getCurrentPlugin, {
1366
+ timeout
1367
+ });
1368
+ if (!response.isSuccess()) {
1369
+ return null;
1370
+ }
1371
+ const data = response.getDataOrNull();
1372
+ if (!data) {
1373
+ return null;
1374
+ }
1375
+ return PluginInfo.fromJSON(data);
1376
+ }
1171
1377
  static async getUniqueDeviceId(timeout) {
1172
1378
  const response = await this.asyncCall(CallMethod.getUniqueDeviceId, {
1173
1379
  timeout
@@ -1407,6 +1613,17 @@ var useStepStore = defineStore("step", {
1407
1613
  }
1408
1614
  });
1409
1615
 
1616
+ // src/pinia-ensure.ts
1617
+ import { createPinia, getActivePinia, setActivePinia } from "pinia";
1618
+ var fallbackPinia = null;
1619
+ function ensureAssistsXPinia() {
1620
+ if (getActivePinia() !== void 0) return;
1621
+ if (fallbackPinia === null) {
1622
+ fallbackPinia = createPinia();
1623
+ }
1624
+ setActivePinia(fallbackPinia);
1625
+ }
1626
+
1410
1627
  // src/step-error.ts
1411
1628
  var StepError = class extends Error {
1412
1629
  constructor(message, data, impl, tag, originalError, currentStep) {
@@ -1768,13 +1985,31 @@ var _Step = class _Step {
1768
1985
  this.delayMs = _Step.delayMsDefault;
1769
1986
  this.tag = tag;
1770
1987
  this.stepId = stepId;
1771
- this.data = data != null ? data : {};
1988
+ this.data = _Step.resolveStepData(data);
1772
1989
  this.impl = impl;
1773
1990
  this.delayMs = delayMs;
1774
1991
  this.repeatCountMax = repeatCountMax;
1775
1992
  this.exceptionRetryCountMax = exceptionRetryCountMax;
1776
1993
  this.isEnd = isEnd;
1777
1994
  }
1995
+ /**
1996
+ * 判断步骤数据是否有效(非空且为普通对象)
1997
+ */
1998
+ static isValidStepData(data) {
1999
+ return data !== null && data !== void 0 && typeof data === "object" && !Array.isArray(data);
2000
+ }
2001
+ /**
2002
+ * 解析步骤数据:优先使用传入值,否则使用当前值,均无效时返回空对象
2003
+ */
2004
+ static resolveStepData(provided, fallback) {
2005
+ if (provided !== void 0 && _Step.isValidStepData(provided)) {
2006
+ return provided;
2007
+ }
2008
+ if (fallback !== void 0 && _Step.isValidStepData(fallback)) {
2009
+ return fallback;
2010
+ }
2011
+ return {};
2012
+ }
1778
2013
  /**
1779
2014
  * 运行步骤实现
1780
2015
  * @param impl 步骤实现函数
@@ -1791,7 +2026,9 @@ var _Step = class _Step {
1791
2026
  } = {}) {
1792
2027
  var _a2, _b, _c, _d, _e, _f;
1793
2028
  this.exception = void 0;
2029
+ ensureAssistsXPinia();
1794
2030
  const stepStore = useStepStore();
2031
+ const resolvedData = _Step.resolveStepData(data);
1795
2032
  let implnName = impl.name;
1796
2033
  let currentStep;
1797
2034
  let nextStep;
@@ -1807,12 +2044,12 @@ var _Step = class _Step {
1807
2044
  console.log(`\u751F\u6210\u6B65\u9AA4ID: ${this._stepId}`);
1808
2045
  }
1809
2046
  }
1810
- stepStore.startStep(this._stepId, tag, data);
2047
+ stepStore.startStep(this._stepId, tag, resolvedData);
1811
2048
  currentStep = new _Step({
1812
2049
  stepId: this._stepId,
1813
2050
  impl,
1814
2051
  tag,
1815
- data,
2052
+ data: resolvedData,
1816
2053
  delayMs,
1817
2054
  exceptionRetryCountMax
1818
2055
  });
@@ -1921,7 +2158,7 @@ var _Step = class _Step {
1921
2158
  const errorMsg = JSON.stringify({
1922
2159
  impl: implnName,
1923
2160
  tag,
1924
- data,
2161
+ data: resolvedData,
1925
2162
  error: (_f = e == null ? void 0 : e.message) != null ? _f : String(e)
1926
2163
  });
1927
2164
  stepStore.setError(errorMsg);
@@ -2064,13 +2301,12 @@ var _Step = class _Step {
2064
2301
  repeatCountMax = _Step.repeatCountMaxDefault,
2065
2302
  exceptionRetryCountMax = _Step.exceptionRetryCountMaxDefault
2066
2303
  } = {}) {
2067
- var _a2;
2068
2304
  _Step.assert(this.stepId);
2069
2305
  return new _Step({
2070
2306
  stepId: this.stepId,
2071
2307
  impl,
2072
2308
  tag,
2073
- data: (_a2 = data != null ? data : this.data) != null ? _a2 : {},
2309
+ data: _Step.resolveStepData(data, this.data),
2074
2310
  delayMs,
2075
2311
  repeatCountMax,
2076
2312
  exceptionRetryCountMax
@@ -2083,13 +2319,12 @@ var _Step = class _Step {
2083
2319
  repeatCountMax = _Step.repeatCountMaxDefault,
2084
2320
  exceptionRetryCountMax = _Step.exceptionRetryCountMaxDefault
2085
2321
  } = {}) {
2086
- var _a2;
2087
2322
  _Step.assert(this.stepId);
2088
2323
  return new _Step({
2089
2324
  stepId: this.stepId,
2090
2325
  impl: void 0,
2091
2326
  tag,
2092
- data: (_a2 = data != null ? data : this.data) != null ? _a2 : {},
2327
+ data: _Step.resolveStepData(data, this.data),
2093
2328
  delayMs,
2094
2329
  repeatCountMax,
2095
2330
  exceptionRetryCountMax,
@@ -2107,7 +2342,7 @@ var _Step = class _Step {
2107
2342
  repeat({
2108
2343
  stepId = this.stepId,
2109
2344
  tag = this.tag,
2110
- data = ((_a2) => (_a2 = this.data) != null ? _a2 : {})(),
2345
+ data,
2111
2346
  delayMs = this.delayMs,
2112
2347
  repeatCountMax = this.repeatCountMax,
2113
2348
  exceptionRetryCountMax = this.exceptionRetryCountMax
@@ -2116,7 +2351,7 @@ var _Step = class _Step {
2116
2351
  this.repeatCount++;
2117
2352
  this.stepId = stepId;
2118
2353
  this.tag = tag;
2119
- this.data = data;
2354
+ this.data = _Step.resolveStepData(data, this.data);
2120
2355
  this.delayMs = delayMs;
2121
2356
  this.repeatCountMax = repeatCountMax;
2122
2357
  this.exceptionRetryCountMax = exceptionRetryCountMax;
@@ -3347,6 +3582,20 @@ var AssistsX2 = class {
3347
3582
  });
3348
3583
  return response.getDataOrDefault(false);
3349
3584
  }
3585
+ /**
3586
+ * 设置悬浮窗可获取焦点(WebView 内输入框 focus 时调用)
3587
+ * @returns 是否设置成功
3588
+ */
3589
+ static setOverlayInputFocus() {
3590
+ return this.setOverlayFlagList(WindowFlags.getOverlayInputFocusFlagList());
3591
+ }
3592
+ /**
3593
+ * 取消悬浮窗焦点(WebView 内输入框 blur 时调用)
3594
+ * @returns 是否设置成功
3595
+ */
3596
+ static clearOverlayInputFocus() {
3597
+ return this.setOverlayFlagList(WindowFlags.getOverlayInputBlurFlagList());
3598
+ }
3350
3599
  /**
3351
3600
  * 获取所有符合条件的节点
3352
3601
  * @param filterClass 类名过滤
@@ -3992,6 +4241,20 @@ var AssistsX2 = class {
3992
4241
  });
3993
4242
  return AppInfo.fromJSON(response.getDataOrDefault({}));
3994
4243
  }
4244
+ /**
4245
+ * 获取当前运行的 AssistsX 插件信息(仅 AssistsX 宿主有效,否则返回 null)
4246
+ */
4247
+ static getCurrentPlugin() {
4248
+ const response = this.call(CallMethod.getCurrentPlugin);
4249
+ if (!response.isSuccess()) {
4250
+ return null;
4251
+ }
4252
+ const data = response.getDataOrNull();
4253
+ if (!data) {
4254
+ return null;
4255
+ }
4256
+ return PluginInfo.fromJSON(data);
4257
+ }
3995
4258
  static getUniqueDeviceId() {
3996
4259
  const response = this.call(CallMethod.getUniqueDeviceId);
3997
4260
  return response.getDataOrDefault("");
@@ -4143,117 +4406,6 @@ var NodeClassValue = {
4143
4406
  FrameLayout: "android.widget.FrameLayout"
4144
4407
  };
4145
4408
 
4146
- // src/window-flags.ts
4147
- var WindowFlags = class {
4148
- // 0x1000000
4149
- /**
4150
- * 获取标志位的十六进制表示
4151
- * @param flag 标志位值
4152
- * @returns 十六进制字符串
4153
- */
4154
- static toHex(flag) {
4155
- return `0x${flag.toString(16).toUpperCase()}`;
4156
- }
4157
- /**
4158
- * 检查是否包含指定标志位
4159
- * @param flags 当前标志位组合
4160
- * @param flag 要检查的标志位
4161
- * @returns 是否包含该标志位
4162
- */
4163
- static hasFlag(flags, flag) {
4164
- return (flags & flag) === flag;
4165
- }
4166
- /**
4167
- * 添加标志位
4168
- * @param flags 当前标志位组合
4169
- * @param flag 要添加的标志位
4170
- * @returns 新的标志位组合
4171
- */
4172
- static addFlag(flags, flag) {
4173
- return flags | flag;
4174
- }
4175
- /**
4176
- * 移除标志位
4177
- * @param flags 当前标志位组合
4178
- * @param flag 要移除的标志位
4179
- * @returns 新的标志位组合
4180
- */
4181
- static removeFlag(flags, flag) {
4182
- return flags & ~flag;
4183
- }
4184
- /**
4185
- * 获取所有标志位的描述信息
4186
- * @returns 标志位描述对象数组
4187
- */
4188
- static getAllFlags() {
4189
- return [
4190
- { name: "FLAG_NOT_FOCUSABLE", value: this.FLAG_NOT_FOCUSABLE, hex: this.toHex(this.FLAG_NOT_FOCUSABLE), description: "\u4E0D\u83B7\u53D6\u7126\u70B9" },
4191
- { name: "FLAG_NOT_TOUCHABLE", value: this.FLAG_NOT_TOUCHABLE, hex: this.toHex(this.FLAG_NOT_TOUCHABLE), description: "\u4E0D\u54CD\u5E94\u89E6\u6478" },
4192
- { name: "FLAG_NOT_TOUCH_MODAL", value: this.FLAG_NOT_TOUCH_MODAL, hex: this.toHex(this.FLAG_NOT_TOUCH_MODAL), description: "\u4E0D\u62E6\u622A\u89E6\u6478" },
4193
- { name: "FLAG_WATCH_OUTSIDE_TOUCH", value: this.FLAG_WATCH_OUTSIDE_TOUCH, hex: this.toHex(this.FLAG_WATCH_OUTSIDE_TOUCH), description: "\u76D1\u542C\u7A97\u5916\u70B9\u51FB" },
4194
- { name: "FLAG_LAYOUT_NO_LIMITS", value: this.FLAG_LAYOUT_NO_LIMITS, hex: this.toHex(this.FLAG_LAYOUT_NO_LIMITS), description: "\u53EF\u7ED8\u5236\u8D85\u51FA\u5C4F\u5E55" },
4195
- { name: "FLAG_LAYOUT_IN_SCREEN", value: this.FLAG_LAYOUT_IN_SCREEN, hex: this.toHex(this.FLAG_LAYOUT_IN_SCREEN), description: "\u5C4F\u5E55\u5168\u533A\u57DF\u5E03\u5C40" },
4196
- { name: "FLAG_FULLSCREEN", value: this.FLAG_FULLSCREEN, hex: this.toHex(this.FLAG_FULLSCREEN), description: "\u5168\u5C4F\u663E\u793A" },
4197
- { name: "FLAG_DIM_BEHIND", value: this.FLAG_DIM_BEHIND, hex: this.toHex(this.FLAG_DIM_BEHIND), description: "\u80CC\u666F\u53D8\u6697" },
4198
- { name: "FLAG_SECURE", value: this.FLAG_SECURE, hex: this.toHex(this.FLAG_SECURE), description: "\u9632\u5F55\u5C4F\u9632\u622A\u56FE" },
4199
- { name: "FLAG_KEEP_SCREEN_ON", value: this.FLAG_KEEP_SCREEN_ON, hex: this.toHex(this.FLAG_KEEP_SCREEN_ON), description: "\u4FDD\u6301\u5E38\u4EAE" },
4200
- { name: "FLAG_SHOW_WHEN_LOCKED", value: this.FLAG_SHOW_WHEN_LOCKED, hex: this.toHex(this.FLAG_SHOW_WHEN_LOCKED), description: "\u9501\u5C4F\u65F6\u53EF\u89C1" },
4201
- { name: "FLAG_DISMISS_KEYGUARD", value: this.FLAG_DISMISS_KEYGUARD, hex: this.toHex(this.FLAG_DISMISS_KEYGUARD), description: "\u89E3\u9501\u5C4F\u5E55" },
4202
- { name: "FLAG_TURN_SCREEN_ON", value: this.FLAG_TURN_SCREEN_ON, hex: this.toHex(this.FLAG_TURN_SCREEN_ON), description: "\u70B9\u4EAE\u5C4F\u5E55" },
4203
- { name: "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON", value: this.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, hex: this.toHex(this.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON), description: "\u81EA\u52A8\u9501\u5C4F\uFF08\u4E0D\u5E38\u7528\uFF09" },
4204
- { name: "FLAG_SHOW_WALLPAPER", value: this.FLAG_SHOW_WALLPAPER, hex: this.toHex(this.FLAG_SHOW_WALLPAPER), description: "\u663E\u793A\u5899\u7EB8" },
4205
- { name: "FLAG_HARDWARE_ACCELERATED", value: this.FLAG_HARDWARE_ACCELERATED, hex: this.toHex(this.FLAG_HARDWARE_ACCELERATED), description: "\u5F3A\u5236\u786C\u4EF6\u52A0\u901F" }
4206
- ];
4207
- }
4208
- };
4209
- /** 不获取焦点 */
4210
- WindowFlags.FLAG_NOT_FOCUSABLE = 8;
4211
- // 0x08
4212
- /** 不响应触摸 */
4213
- WindowFlags.FLAG_NOT_TOUCHABLE = 16;
4214
- // 0x10
4215
- /** 不拦截触摸 */
4216
- WindowFlags.FLAG_NOT_TOUCH_MODAL = 32;
4217
- // 0x20
4218
- /** 监听窗外点击 */
4219
- WindowFlags.FLAG_WATCH_OUTSIDE_TOUCH = 4;
4220
- // 0x04
4221
- /** 可绘制超出屏幕 */
4222
- WindowFlags.FLAG_LAYOUT_NO_LIMITS = 512;
4223
- // 0x200
4224
- /** 屏幕全区域布局 */
4225
- WindowFlags.FLAG_LAYOUT_IN_SCREEN = 256;
4226
- // 0x100
4227
- /** 全屏显示 */
4228
- WindowFlags.FLAG_FULLSCREEN = 1024;
4229
- // 0x400
4230
- /** 背景变暗 */
4231
- WindowFlags.FLAG_DIM_BEHIND = 2;
4232
- // 0x02
4233
- /** 防录屏防截图 */
4234
- WindowFlags.FLAG_SECURE = 8192;
4235
- // 0x2000
4236
- /** 保持常亮 */
4237
- WindowFlags.FLAG_KEEP_SCREEN_ON = 128;
4238
- // 0x80
4239
- /** 锁屏时可见 */
4240
- WindowFlags.FLAG_SHOW_WHEN_LOCKED = 524288;
4241
- // 0x80000
4242
- /** 解锁屏幕 */
4243
- WindowFlags.FLAG_DISMISS_KEYGUARD = 4194304;
4244
- // 0x400000
4245
- /** 点亮屏幕 */
4246
- WindowFlags.FLAG_TURN_SCREEN_ON = 2097152;
4247
- // 0x200000
4248
- /** 自动锁屏(不常用) */
4249
- WindowFlags.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 128;
4250
- // 0x80
4251
- /** 显示墙纸 */
4252
- WindowFlags.FLAG_SHOW_WALLPAPER = 1048576;
4253
- // 0x100000
4254
- /** 强制硬件加速 */
4255
- WindowFlags.FLAG_HARDWARE_ACCELERATED = 16777216;
4256
-
4257
4409
  // src/accessibility-event-filter.ts
4258
4410
  var AccessibilityEventFilter = class _AccessibilityEventFilter {
4259
4411
  constructor(config = {}) {
@@ -7046,6 +7198,342 @@ var Mlkit = class {
7046
7198
  };
7047
7199
  var mlkit = new Mlkit();
7048
7200
 
7201
+ // src/screenshot/screenshot-call-method.ts
7202
+ var ScreenshotCallMethod = {
7203
+ /** 截取全屏并返回 Base64 */
7204
+ takeScreenshotBase64: "takeScreenshotBase64",
7205
+ /** 截取指定节点区域并返回 Base64,需传 node.nodeId */
7206
+ takeNodeScreenshotBase64: "takeNodeScreenshotBase64",
7207
+ /** 批量截取节点区域并返回 Base64 数组,nodes 为空时返回全屏 */
7208
+ takeScreenshotNodesBase64: "takeScreenshotNodesBase64"
7209
+ };
7210
+
7211
+ // src/screenshot/screenshot.ts
7212
+ var callbacks10 = /* @__PURE__ */ new Map();
7213
+ if (typeof window !== "undefined" && !window.assistsxScreenshotCallback) {
7214
+ window.assistsxScreenshotCallback = (data) => {
7215
+ let callbackId;
7216
+ try {
7217
+ const json = decodeBase64UTF8(data);
7218
+ const response = JSON.parse(json);
7219
+ callbackId = response.callbackId;
7220
+ if (callbackId) {
7221
+ const callback = callbacks10.get(callbackId);
7222
+ if (callback) {
7223
+ callback(json);
7224
+ }
7225
+ }
7226
+ } catch (e) {
7227
+ console.error("Screenshot callback error:", e);
7228
+ } finally {
7229
+ if (callbackId) {
7230
+ callbacks10.delete(callbackId);
7231
+ }
7232
+ }
7233
+ };
7234
+ }
7235
+ function createNodeStub(nodeId) {
7236
+ return { nodeId };
7237
+ }
7238
+ function parseScreenshotBase64Data(data) {
7239
+ if (!data || typeof data !== "object") {
7240
+ return null;
7241
+ }
7242
+ const record = data;
7243
+ const base64 = typeof record.base64 === "string" ? record.base64 : "";
7244
+ const mimeType = typeof record.mimeType === "string" ? record.mimeType : "image/png";
7245
+ const dataUrl = typeof record.dataUrl === "string" ? record.dataUrl : `data:${mimeType};base64,${base64}`;
7246
+ if (!base64) {
7247
+ return null;
7248
+ }
7249
+ return { base64, dataUrl, mimeType };
7250
+ }
7251
+ var Screenshot = class {
7252
+ /**
7253
+ * 执行异步调用
7254
+ */
7255
+ async asyncCall(method, {
7256
+ args,
7257
+ node,
7258
+ nodes,
7259
+ timeout = 30
7260
+ } = {}) {
7261
+ const uuid = generateUUID();
7262
+ const params = {
7263
+ method,
7264
+ arguments: args ? args : void 0,
7265
+ node: node ? node : void 0,
7266
+ nodes: nodes ? nodes : void 0,
7267
+ callbackId: uuid
7268
+ };
7269
+ const promise = new Promise((resolve) => {
7270
+ callbacks10.set(uuid, (data) => {
7271
+ resolve(data);
7272
+ });
7273
+ setTimeout(() => {
7274
+ callbacks10.delete(uuid);
7275
+ resolve(JSON.stringify(new CallResponse(0, null, uuid)));
7276
+ }, timeout * 1e3);
7277
+ });
7278
+ window.assistsxScreenshot.call(JSON.stringify(params));
7279
+ const promiseResult = await promise;
7280
+ if (typeof promiseResult === "string") {
7281
+ const responseData = JSON.parse(promiseResult);
7282
+ return new CallResponse(
7283
+ responseData.code,
7284
+ responseData.data,
7285
+ responseData.callbackId
7286
+ );
7287
+ }
7288
+ throw new Error("Screenshot call failed");
7289
+ }
7290
+ buildScreenshotArgs(options = {}) {
7291
+ const {
7292
+ overlayHiddenScreenshotDelayMillis = 250,
7293
+ format = "PNG",
7294
+ withDataUrlPrefix = true
7295
+ } = options;
7296
+ return {
7297
+ overlayHiddenScreenshotDelayMillis,
7298
+ format,
7299
+ withDataUrlPrefix
7300
+ };
7301
+ }
7302
+ /**
7303
+ * 截取全屏并返回 Base64
7304
+ */
7305
+ async takeScreenshotBase64(options = {}) {
7306
+ const { timeout = 30, ...rest } = options;
7307
+ const response = await this.asyncCall(ScreenshotCallMethod.takeScreenshotBase64, {
7308
+ args: this.buildScreenshotArgs(rest),
7309
+ timeout
7310
+ });
7311
+ if (!response.isSuccess()) {
7312
+ return null;
7313
+ }
7314
+ return parseScreenshotBase64Data(response.getDataOrNull());
7315
+ }
7316
+ /**
7317
+ * 截取指定节点区域并返回 Base64
7318
+ */
7319
+ async takeNodeScreenshotBase64(nodeId, options = {}) {
7320
+ if (!nodeId) {
7321
+ throw new Error("nodeId is required");
7322
+ }
7323
+ const { timeout = 30, ...rest } = options;
7324
+ const response = await this.asyncCall(ScreenshotCallMethod.takeNodeScreenshotBase64, {
7325
+ args: this.buildScreenshotArgs(rest),
7326
+ node: createNodeStub(nodeId),
7327
+ timeout
7328
+ });
7329
+ if (!response.isSuccess()) {
7330
+ return null;
7331
+ }
7332
+ return parseScreenshotBase64Data(response.getDataOrNull());
7333
+ }
7334
+ /**
7335
+ * 批量截取节点区域;nodeIds 为空时返回全屏截图
7336
+ */
7337
+ async takeScreenshotNodesBase64(nodeIds = [], options = {}) {
7338
+ const { timeout = 30, ...rest } = options;
7339
+ const nodes = nodeIds.map((nodeId) => createNodeStub(nodeId));
7340
+ const response = await this.asyncCall(ScreenshotCallMethod.takeScreenshotNodesBase64, {
7341
+ args: this.buildScreenshotArgs(rest),
7342
+ nodes,
7343
+ timeout
7344
+ });
7345
+ if (!response.isSuccess()) {
7346
+ return [];
7347
+ }
7348
+ const data = response.getDataOrNull();
7349
+ return Array.isArray(data == null ? void 0 : data.images) ? data.images : [];
7350
+ }
7351
+ };
7352
+ var screenshot = new Screenshot();
7353
+
7354
+ // src/db/db-call-method.ts
7355
+ var DbCallMethod = {
7356
+ exec: "exec",
7357
+ query: "query",
7358
+ execBatch: "execBatch",
7359
+ close: "close"
7360
+ };
7361
+
7362
+ // src/db/db.ts
7363
+ var callbacks11 = /* @__PURE__ */ new Map();
7364
+ if (typeof window !== "undefined" && !window.assistsxDbCallback) {
7365
+ window.assistsxDbCallback = (data) => {
7366
+ let callbackId;
7367
+ try {
7368
+ const json = decodeBase64UTF8(data);
7369
+ const response = JSON.parse(json);
7370
+ callbackId = response.callbackId;
7371
+ if (callbackId) {
7372
+ const callback = callbacks11.get(callbackId);
7373
+ if (callback) {
7374
+ callback(json);
7375
+ }
7376
+ }
7377
+ } catch (e) {
7378
+ console.error("Db callback error:", e);
7379
+ } finally {
7380
+ if (callbackId) {
7381
+ callbacks11.delete(callbackId);
7382
+ }
7383
+ }
7384
+ };
7385
+ }
7386
+ function buildDbArguments(target, extra) {
7387
+ const args = { ...extra };
7388
+ if (target.dbPath) {
7389
+ args.dbPath = target.dbPath;
7390
+ }
7391
+ if (target.dbName) {
7392
+ args.dbName = target.dbName;
7393
+ }
7394
+ return args;
7395
+ }
7396
+ function normalizeBindArgs(bindArgs) {
7397
+ if (!bindArgs || bindArgs.length === 0) {
7398
+ return void 0;
7399
+ }
7400
+ return bindArgs.map((value) => {
7401
+ if (value === null) {
7402
+ return null;
7403
+ }
7404
+ return String(value);
7405
+ });
7406
+ }
7407
+ function parseExecResult(data) {
7408
+ var _a2, _b;
7409
+ const record = data != null ? data : {};
7410
+ return {
7411
+ rowsAffected: Number((_a2 = record.rowsAffected) != null ? _a2 : 0),
7412
+ lastInsertRowId: Number((_b = record.lastInsertRowId) != null ? _b : 0)
7413
+ };
7414
+ }
7415
+ function parseQueryResult(data) {
7416
+ var _a2;
7417
+ const record = data != null ? data : {};
7418
+ const columns = Array.isArray(record.columns) ? record.columns.map((item) => String(item)) : [];
7419
+ const rows = Array.isArray(record.rows) ? record.rows : [];
7420
+ return {
7421
+ columns,
7422
+ rows,
7423
+ rowCount: Number((_a2 = record.rowCount) != null ? _a2 : rows.length)
7424
+ };
7425
+ }
7426
+ function parseExecBatchResult(data) {
7427
+ var _a2;
7428
+ const record = data != null ? data : {};
7429
+ const results = Array.isArray(record.results) ? record.results.map((item) => parseExecResult(item)) : [];
7430
+ return {
7431
+ count: Number((_a2 = record.count) != null ? _a2 : results.length),
7432
+ results
7433
+ };
7434
+ }
7435
+ var Db = class {
7436
+ /**
7437
+ * 执行异步调用
7438
+ */
7439
+ async asyncCall(method, args, timeout = 30) {
7440
+ const uuid = generateUUID();
7441
+ const params = {
7442
+ method,
7443
+ arguments: args ? args : void 0,
7444
+ callbackId: uuid
7445
+ };
7446
+ const promise = new Promise((resolve) => {
7447
+ callbacks11.set(uuid, (data) => {
7448
+ resolve(data);
7449
+ });
7450
+ setTimeout(() => {
7451
+ callbacks11.delete(uuid);
7452
+ resolve(JSON.stringify(new CallResponse(0, null, uuid)));
7453
+ }, timeout * 1e3);
7454
+ });
7455
+ window.assistsxDb.call(JSON.stringify(params));
7456
+ const promiseResult = await promise;
7457
+ if (typeof promiseResult !== "string") {
7458
+ throw new Error("Db call failed");
7459
+ }
7460
+ const responseData = JSON.parse(promiseResult);
7461
+ if (responseData.code !== 0) {
7462
+ throw new Error(responseData.message || "Db call failed");
7463
+ }
7464
+ return new CallResponse(
7465
+ responseData.code,
7466
+ responseData.data,
7467
+ responseData.callbackId
7468
+ );
7469
+ }
7470
+ /**
7471
+ * 将 query 结果中的 Base64 BLOB 字段解码为 Uint8Array
7472
+ */
7473
+ decodeBlobBase64(base64) {
7474
+ const binary = atob(base64);
7475
+ const bytes = new Uint8Array(binary.length);
7476
+ for (let i = 0; i < binary.length; i++) {
7477
+ bytes[i] = binary.charCodeAt(i);
7478
+ }
7479
+ return bytes;
7480
+ }
7481
+ /**
7482
+ * 执行非查询 SQL
7483
+ */
7484
+ async exec(sql, options) {
7485
+ const { timeout = 30, bindArgs, ...target } = options;
7486
+ const response = await this.asyncCall(
7487
+ DbCallMethod.exec,
7488
+ buildDbArguments(target, {
7489
+ sql,
7490
+ bindArgs: normalizeBindArgs(bindArgs)
7491
+ }),
7492
+ timeout
7493
+ );
7494
+ return parseExecResult(response.getDataOrNull());
7495
+ }
7496
+ /**
7497
+ * 执行查询 SQL
7498
+ */
7499
+ async query(sql, options) {
7500
+ const { timeout = 30, bindArgs, ...target } = options;
7501
+ const response = await this.asyncCall(
7502
+ DbCallMethod.query,
7503
+ buildDbArguments(target, {
7504
+ sql,
7505
+ bindArgs: normalizeBindArgs(bindArgs)
7506
+ }),
7507
+ timeout
7508
+ );
7509
+ return parseQueryResult(response.getDataOrNull());
7510
+ }
7511
+ /**
7512
+ * 事务内批量执行多条 SQL
7513
+ */
7514
+ async execBatch(statements, options) {
7515
+ const { timeout = 30, ...target } = options;
7516
+ const response = await this.asyncCall(
7517
+ DbCallMethod.execBatch,
7518
+ buildDbArguments(target, { statements }),
7519
+ timeout
7520
+ );
7521
+ return parseExecBatchResult(response.getDataOrNull());
7522
+ }
7523
+ /**
7524
+ * 关闭并释放指定数据库连接
7525
+ */
7526
+ async close(options) {
7527
+ const { timeout = 30, ...target } = options;
7528
+ await this.asyncCall(
7529
+ DbCallMethod.close,
7530
+ buildDbArguments(target),
7531
+ timeout
7532
+ );
7533
+ }
7534
+ };
7535
+ var db = new Db();
7536
+
7049
7537
  // src/barutils/bar-utils-call-method.ts
7050
7538
  var BarUtilsCallMethod = {
7051
7539
  // Status bar
@@ -7071,7 +7559,7 @@ var BarUtilsCallMethod = {
7071
7559
  };
7072
7560
 
7073
7561
  // src/barutils/bar-utils.ts
7074
- var callbacks10 = /* @__PURE__ */ new Map();
7562
+ var callbacks12 = /* @__PURE__ */ new Map();
7075
7563
  if (typeof window !== "undefined" && !window.assistsxBarUtilsCallback) {
7076
7564
  window.assistsxBarUtilsCallback = (data) => {
7077
7565
  let callbackId;
@@ -7080,7 +7568,7 @@ if (typeof window !== "undefined" && !window.assistsxBarUtilsCallback) {
7080
7568
  const response = JSON.parse(json);
7081
7569
  callbackId = response.callbackId;
7082
7570
  if (callbackId) {
7083
- const callback = callbacks10.get(callbackId);
7571
+ const callback = callbacks12.get(callbackId);
7084
7572
  if (callback) {
7085
7573
  callback(json);
7086
7574
  }
@@ -7089,7 +7577,7 @@ if (typeof window !== "undefined" && !window.assistsxBarUtilsCallback) {
7089
7577
  console.error("BarUtils callback error:", e);
7090
7578
  } finally {
7091
7579
  if (callbackId) {
7092
- callbacks10.delete(callbackId);
7580
+ callbacks12.delete(callbackId);
7093
7581
  }
7094
7582
  }
7095
7583
  };
@@ -7103,11 +7591,11 @@ var BarUtils = class {
7103
7591
  callbackId: uuid
7104
7592
  };
7105
7593
  const promise = new Promise((resolve) => {
7106
- callbacks10.set(uuid, (data) => {
7594
+ callbacks12.set(uuid, (data) => {
7107
7595
  resolve(data);
7108
7596
  });
7109
7597
  setTimeout(() => {
7110
- callbacks10.delete(uuid);
7598
+ callbacks12.delete(uuid);
7111
7599
  resolve(
7112
7600
  JSON.stringify(
7113
7601
  new CallResponse(-1, { message: "Timeout" }, uuid)
@@ -7388,7 +7876,7 @@ var FloatCallMethod = {
7388
7876
  };
7389
7877
 
7390
7878
  // src/floatingwindow/float.ts
7391
- var callbacks11 = /* @__PURE__ */ new Map();
7879
+ var callbacks13 = /* @__PURE__ */ new Map();
7392
7880
  if (typeof window !== "undefined" && !window.assistsxFloatCallback) {
7393
7881
  window.assistsxFloatCallback = (data) => {
7394
7882
  let callbackId;
@@ -7397,7 +7885,7 @@ if (typeof window !== "undefined" && !window.assistsxFloatCallback) {
7397
7885
  const response = JSON.parse(json);
7398
7886
  callbackId = response.callbackId;
7399
7887
  if (callbackId) {
7400
- const callback = callbacks11.get(callbackId);
7888
+ const callback = callbacks13.get(callbackId);
7401
7889
  if (callback) {
7402
7890
  callback(json);
7403
7891
  }
@@ -7406,7 +7894,7 @@ if (typeof window !== "undefined" && !window.assistsxFloatCallback) {
7406
7894
  console.error("Float callback error:", e);
7407
7895
  } finally {
7408
7896
  if (callbackId) {
7409
- callbacks11.delete(callbackId);
7897
+ callbacks13.delete(callbackId);
7410
7898
  }
7411
7899
  }
7412
7900
  };
@@ -7420,11 +7908,11 @@ var Float = class {
7420
7908
  callbackId: uuid
7421
7909
  };
7422
7910
  const promise = new Promise((resolve) => {
7423
- callbacks11.set(uuid, (data) => {
7911
+ callbacks13.set(uuid, (data) => {
7424
7912
  resolve(data);
7425
7913
  });
7426
7914
  setTimeout(() => {
7427
- callbacks11.delete(uuid);
7915
+ callbacks13.delete(uuid);
7428
7916
  resolve(
7429
7917
  JSON.stringify(
7430
7918
  new CallResponse(-1, { message: "Timeout" }, uuid)
@@ -7586,7 +8074,9 @@ var LogCallMethod = {
7586
8074
  unsubscribe: "unsubscribe",
7587
8075
  uploadLogs: "uploadLogs",
7588
8076
  /** 获取日志服务当前域名(origin,无路径;与上传、管理后台同源),对应 AssistsLogDiagnostics.adminWebBaseUrl() */
7589
- getLogServiceBaseUrl: "getLogServiceBaseUrl"
8077
+ getLogServiceBaseUrl: "getLogServiceBaseUrl",
8078
+ /** 解析日志文件绝对路径(不创建文件) */
8079
+ resolveLogPath: "resolveLogPath"
7590
8080
  };
7591
8081
  var LogStream = {
7592
8082
  latestLine: "latestLine",
@@ -7597,6 +8087,26 @@ var LogStream = {
7597
8087
  var pendingCallbacks = /* @__PURE__ */ new Map();
7598
8088
  var streamHandlers = /* @__PURE__ */ new Map();
7599
8089
  var subscriptionIdToCallbackId = /* @__PURE__ */ new Map();
8090
+ function buildLogArguments(target, extra) {
8091
+ const args = { ...extra };
8092
+ if ((target == null ? void 0 : target.dirPath) !== void 0) {
8093
+ args.dirPath = target.dirPath;
8094
+ }
8095
+ if ((target == null ? void 0 : target.fileName) !== void 0) {
8096
+ args.fileName = target.fileName;
8097
+ }
8098
+ return Object.keys(args).length > 0 ? args : void 0;
8099
+ }
8100
+ function resolveTimeout(timeoutOrOptions, fallback = 30) {
8101
+ var _a2;
8102
+ if (typeof timeoutOrOptions === "number") {
8103
+ return { timeout: timeoutOrOptions };
8104
+ }
8105
+ return {
8106
+ timeout: (_a2 = timeoutOrOptions == null ? void 0 : timeoutOrOptions.timeout) != null ? _a2 : fallback,
8107
+ target: timeoutOrOptions
8108
+ };
8109
+ }
7600
8110
  if (typeof window !== "undefined" && !window.assistsxLogCallback) {
7601
8111
  window.assistsxLogCallback = (data) => {
7602
8112
  try {
@@ -7672,11 +8182,12 @@ var Log = class {
7672
8182
  throw new Error("Log bridge call failed");
7673
8183
  }
7674
8184
  /** 读取当前日志全文 */
7675
- async readAllText(timeout) {
8185
+ async readAllText(timeoutOrOptions) {
7676
8186
  var _a2;
8187
+ const { timeout, target } = resolveTimeout(timeoutOrOptions);
7677
8188
  const res = await this.asyncCall(
7678
8189
  LogCallMethod.readAllText,
7679
- void 0,
8190
+ buildLogArguments(target),
7680
8191
  timeout
7681
8192
  );
7682
8193
  const d = res.getDataOrNull();
@@ -7696,51 +8207,92 @@ var Log = class {
7696
8207
  const d = res.getDataOrNull();
7697
8208
  return (_a2 = d == null ? void 0 : d.baseUrl) != null ? _a2 : "";
7698
8209
  }
8210
+ /**
8211
+ * 解析日志文件绝对路径(不创建文件)。
8212
+ * AssistsX 插件环境下会经原生拦截追加 log-{packageName} 子目录。
8213
+ */
8214
+ async resolveLogPath(targetOrOptions) {
8215
+ var _a2;
8216
+ const { timeout, target } = resolveTimeout(targetOrOptions);
8217
+ const res = await this.asyncCall(
8218
+ LogCallMethod.resolveLogPath,
8219
+ buildLogArguments(target),
8220
+ timeout
8221
+ );
8222
+ const d = res.getDataOrNull();
8223
+ return (_a2 = d == null ? void 0 : d.logFilePath) != null ? _a2 : "";
8224
+ }
7699
8225
  /** 清空日志 */
7700
- async clear(timeout) {
8226
+ async clear(timeoutOrOptions) {
8227
+ const { timeout, target } = resolveTimeout(timeoutOrOptions);
7701
8228
  const res = await this.asyncCall(
7702
8229
  LogCallMethod.clear,
7703
- void 0,
8230
+ buildLogArguments(target),
7704
8231
  timeout
7705
8232
  );
7706
8233
  return res.isSuccess();
7707
8234
  }
7708
8235
  /** 从文件重新加载到内存 Flow */
7709
- async refreshFromFile(timeout) {
8236
+ async refreshFromFile(timeoutOrOptions) {
8237
+ const { timeout, target } = resolveTimeout(timeoutOrOptions);
7710
8238
  const res = await this.asyncCall(
7711
8239
  LogCallMethod.refreshFromFile,
7712
- void 0,
8240
+ buildLogArguments(target),
7713
8241
  timeout
7714
8242
  );
7715
8243
  return res.isSuccess();
7716
8244
  }
7717
8245
  /** 追加一行 */
7718
- async appendLine(line, maxLength, timeout) {
7719
- const args = { line };
7720
- if (maxLength !== void 0) {
7721
- args.maxLength = maxLength;
8246
+ async appendLine(line, maxLengthOrOptions, timeout) {
8247
+ var _a2;
8248
+ let options;
8249
+ if (typeof maxLengthOrOptions === "number") {
8250
+ options = { maxLength: maxLengthOrOptions, timeout };
8251
+ } else {
8252
+ options = maxLengthOrOptions;
8253
+ }
8254
+ const args = (_a2 = buildLogArguments(options, { line })) != null ? _a2 : { line };
8255
+ if ((options == null ? void 0 : options.maxLength) !== void 0) {
8256
+ args.maxLength = options.maxLength;
7722
8257
  }
7723
8258
  const res = await this.asyncCall(
7724
8259
  LogCallMethod.appendLine,
7725
8260
  args,
7726
- timeout
8261
+ options == null ? void 0 : options.timeout
7727
8262
  );
7728
8263
  return res.isSuccess();
7729
8264
  }
7730
8265
  /** 追加带时间戳的条目 */
7731
- async appendTimestampedEntry(message, timeout) {
8266
+ async appendTimestampedEntry(message, timeoutOrOptions) {
8267
+ var _a2;
8268
+ const { timeout, target } = resolveTimeout(timeoutOrOptions);
8269
+ const args = (_a2 = buildLogArguments(target, { message })) != null ? _a2 : { message };
7732
8270
  const res = await this.asyncCall(
7733
8271
  LogCallMethod.appendTimestampedEntry,
7734
- { message },
8272
+ args,
7735
8273
  timeout
7736
8274
  );
7737
8275
  return res.isSuccess();
7738
8276
  }
8277
+ /**
8278
+ * 追加日志(appendTimestampedEntry / appendLine 简写)。
8279
+ * 默认带时间戳;`timestamped: false` 时走 appendLine。
8280
+ */
8281
+ async append(text, options) {
8282
+ const { timestamped = true, maxLength, timeout, ...target } = options != null ? options : {};
8283
+ if (timestamped) {
8284
+ return this.appendTimestampedEntry(text, { ...target, timeout });
8285
+ }
8286
+ return this.appendLine(text, { ...target, maxLength, timeout });
8287
+ }
7739
8288
  /** 替换全部内容 */
7740
- async replaceAll(content, timeout) {
8289
+ async replaceAll(content, timeoutOrOptions) {
8290
+ var _a2;
8291
+ const { timeout, target } = resolveTimeout(timeoutOrOptions);
8292
+ const args = (_a2 = buildLogArguments(target, { content })) != null ? _a2 : { content };
7741
8293
  const res = await this.asyncCall(
7742
8294
  LogCallMethod.replaceAll,
7743
- { content },
8295
+ args,
7744
8296
  timeout
7745
8297
  );
7746
8298
  return res.isSuccess();
@@ -7750,10 +8302,11 @@ var Log = class {
7750
8302
  * resolve 后请保留 dispose 或调用 unsubscribe(subscriptionId) 以释放原生协程与 JS 回调。
7751
8303
  */
7752
8304
  async subscribe(stream, onUpdate, options) {
7753
- var _a2;
8305
+ var _a2, _b;
7754
8306
  const self = this;
7755
8307
  const callbackId = generateUUID();
7756
8308
  const timeoutSec = (_a2 = options == null ? void 0 : options.timeout) != null ? _a2 : 30;
8309
+ const subscribeArgs = (_b = buildLogArguments(options, { stream })) != null ? _b : { stream };
7757
8310
  return new Promise((resolve, reject) => {
7758
8311
  let settled = false;
7759
8312
  const timer = setTimeout(() => {
@@ -7764,7 +8317,7 @@ var Log = class {
7764
8317
  }
7765
8318
  }, timeoutSec * 1e3);
7766
8319
  streamHandlers.set(callbackId, (raw) => {
7767
- var _a3, _b, _c;
8320
+ var _a3, _b2, _c;
7768
8321
  let response;
7769
8322
  try {
7770
8323
  response = JSON.parse(raw);
@@ -7803,9 +8356,10 @@ var Log = class {
7803
8356
  }
7804
8357
  if ((data == null ? void 0 : data.event) === "update" && data.subscriptionId) {
7805
8358
  onUpdate({
7806
- text: (_b = data.text) != null ? _b : "",
8359
+ text: (_b2 = data.text) != null ? _b2 : "",
7807
8360
  stream: (_c = data.stream) != null ? _c : stream,
7808
- subscriptionId: data.subscriptionId
8361
+ subscriptionId: data.subscriptionId,
8362
+ logFilePath: data.logFilePath
7809
8363
  });
7810
8364
  }
7811
8365
  });
@@ -7813,7 +8367,7 @@ var Log = class {
7813
8367
  this.getBridge().call(
7814
8368
  JSON.stringify({
7815
8369
  method: LogCallMethod.subscribe,
7816
- arguments: { stream },
8370
+ arguments: subscribeArgs,
7817
8371
  callbackId
7818
8372
  })
7819
8373
  );
@@ -7857,6 +8411,12 @@ var Log = class {
7857
8411
  if (args.uploadKey !== void 0) {
7858
8412
  payload.uploadKey = args.uploadKey;
7859
8413
  }
8414
+ if (args.dirPath !== void 0) {
8415
+ payload.dirPath = args.dirPath;
8416
+ }
8417
+ if (args.fileName !== void 0) {
8418
+ payload.fileName = args.fileName;
8419
+ }
7860
8420
  const uuid = generateUUID();
7861
8421
  const params = {
7862
8422
  method: LogCallMethod.uploadLogs,
@@ -7911,6 +8471,8 @@ export {
7911
8471
  Bounds,
7912
8472
  CallMethod,
7913
8473
  CallResponse,
8474
+ Db,
8475
+ DbCallMethod,
7914
8476
  DeviceInfo,
7915
8477
  FileIO,
7916
8478
  FileUtils,
@@ -7932,6 +8494,9 @@ export {
7932
8494
  NodeAsync,
7933
8495
  NodeClassValue,
7934
8496
  Path,
8497
+ PluginInfo,
8498
+ Screenshot,
8499
+ ScreenshotCallMethod,
7935
8500
  Step,
7936
8501
  StepAsync,
7937
8502
  StepError,
@@ -7940,7 +8505,9 @@ export {
7940
8505
  accessibilityEventListeners,
7941
8506
  barUtils,
7942
8507
  callbacks,
8508
+ db,
7943
8509
  decodeBase64UTF8,
8510
+ ensureAssistsXPinia,
7944
8511
  fileIO,
7945
8512
  fileUtils,
7946
8513
  float,
@@ -7954,6 +8521,7 @@ export {
7954
8521
  mlkit,
7955
8522
  pathUtils,
7956
8523
  screen,
8524
+ screenshot,
7957
8525
  sleep,
7958
8526
  useStepStore
7959
8527
  };