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.cjs CHANGED
@@ -29,6 +29,8 @@ __export(index_exports, {
29
29
  Bounds: () => Bounds,
30
30
  CallMethod: () => CallMethod,
31
31
  CallResponse: () => CallResponse,
32
+ Db: () => Db,
33
+ DbCallMethod: () => DbCallMethod,
32
34
  DeviceInfo: () => DeviceInfo,
33
35
  FileIO: () => FileIO,
34
36
  FileUtils: () => FileUtils,
@@ -50,6 +52,9 @@ __export(index_exports, {
50
52
  NodeAsync: () => NodeAsync,
51
53
  NodeClassValue: () => NodeClassValue,
52
54
  Path: () => Path,
55
+ PluginInfo: () => PluginInfo,
56
+ Screenshot: () => Screenshot,
57
+ ScreenshotCallMethod: () => ScreenshotCallMethod,
53
58
  Step: () => Step,
54
59
  StepAsync: () => StepAsync,
55
60
  StepError: () => StepError,
@@ -58,7 +63,9 @@ __export(index_exports, {
58
63
  accessibilityEventListeners: () => accessibilityEventListeners,
59
64
  barUtils: () => barUtils,
60
65
  callbacks: () => callbacks,
66
+ db: () => db,
61
67
  decodeBase64UTF8: () => decodeBase64UTF8,
68
+ ensureAssistsXPinia: () => ensureAssistsXPinia,
62
69
  fileIO: () => fileIO,
63
70
  fileUtils: () => fileUtils,
64
71
  float: () => float,
@@ -72,6 +79,7 @@ __export(index_exports, {
72
79
  mlkit: () => mlkit,
73
80
  pathUtils: () => pathUtils,
74
81
  screen: () => screen,
82
+ screenshot: () => screenshot,
75
83
  sleep: () => sleep,
76
84
  useStepStore: () => useStepStore
77
85
  });
@@ -228,6 +236,7 @@ var CallMethod = {
228
236
  performLinearGesture: "performLinearGesture",
229
237
  longPressGestureAutoPaste: "longPressGestureAutoPaste",
230
238
  getAppInfo: "getAppInfo",
239
+ getCurrentPlugin: "getCurrentPlugin",
231
240
  getMacAddress: "getMacAddress",
232
241
  getAndroidID: "getAndroidID",
233
242
  getUniqueDeviceId: "getUniqueDeviceId",
@@ -348,6 +357,52 @@ var AppInfo = class _AppInfo {
348
357
  }
349
358
  };
350
359
 
360
+ // src/plugin-info.ts
361
+ var PluginInfo = class _PluginInfo {
362
+ constructor(id = "", name = "", packageName = "", versionName = "", versionCode = 0, description = "", path = "", index = "", port = 0, needScreenCapture = false) {
363
+ this.id = id;
364
+ this.name = name;
365
+ this.packageName = packageName;
366
+ this.versionName = versionName;
367
+ this.versionCode = versionCode;
368
+ this.description = description;
369
+ this.path = path;
370
+ this.index = index;
371
+ this.port = port;
372
+ this.needScreenCapture = needScreenCapture;
373
+ }
374
+ static fromJSON(data) {
375
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
376
+ const record = data != null ? data : {};
377
+ return new _PluginInfo(
378
+ String((_a2 = record.id) != null ? _a2 : ""),
379
+ String((_b = record.name) != null ? _b : ""),
380
+ String((_c = record.packageName) != null ? _c : ""),
381
+ String((_d = record.versionName) != null ? _d : ""),
382
+ Number((_e = record.versionCode) != null ? _e : 0),
383
+ String((_f = record.description) != null ? _f : ""),
384
+ String((_g = record.path) != null ? _g : ""),
385
+ String((_h = record.index) != null ? _h : ""),
386
+ Number((_i = record.port) != null ? _i : 0),
387
+ Boolean((_j = record.needScreenCapture) != null ? _j : false)
388
+ );
389
+ }
390
+ toJSON() {
391
+ return {
392
+ id: this.id,
393
+ name: this.name,
394
+ packageName: this.packageName,
395
+ versionName: this.versionName,
396
+ versionCode: this.versionCode,
397
+ description: this.description,
398
+ path: this.path,
399
+ index: this.index,
400
+ port: this.port,
401
+ needScreenCapture: this.needScreenCapture
402
+ };
403
+ }
404
+ };
405
+
351
406
  // src/device-info.ts
352
407
  var DeviceInfo = class _DeviceInfo {
353
408
  constructor(uniqueDeviceId = "", androidID = "", macAddress = "", isDeviceRooted = false, manufacturer = "", model = "", sdkVersionCode = 0, sdkVersionName = "", abiList = [], isAdbEnabled = false, isDevelopmentSettingsEnabled = false, isEmulator = false, isTablet = false) {
@@ -411,6 +466,137 @@ var DeviceInfo = class _DeviceInfo {
411
466
  }
412
467
  };
413
468
 
469
+ // src/window-flags.ts
470
+ var _WindowFlags = class _WindowFlags {
471
+ // 0x1000000
472
+ /**
473
+ * 获取标志位的十六进制表示
474
+ * @param flag 标志位值
475
+ * @returns 十六进制字符串
476
+ */
477
+ static toHex(flag) {
478
+ return `0x${flag.toString(16).toUpperCase()}`;
479
+ }
480
+ /**
481
+ * 检查是否包含指定标志位
482
+ * @param flags 当前标志位组合
483
+ * @param flag 要检查的标志位
484
+ * @returns 是否包含该标志位
485
+ */
486
+ static hasFlag(flags, flag) {
487
+ return (flags & flag) === flag;
488
+ }
489
+ /**
490
+ * 添加标志位
491
+ * @param flags 当前标志位组合
492
+ * @param flag 要添加的标志位
493
+ * @returns 新的标志位组合
494
+ */
495
+ static addFlag(flags, flag) {
496
+ return flags | flag;
497
+ }
498
+ /**
499
+ * 移除标志位
500
+ * @param flags 当前标志位组合
501
+ * @param flag 要移除的标志位
502
+ * @returns 新的标志位组合
503
+ */
504
+ static removeFlag(flags, flag) {
505
+ return flags & ~flag;
506
+ }
507
+ /** 输入框获取焦点时使用的悬浮窗 flag 组合(不含 FLAG_NOT_FOCUSABLE) */
508
+ static getOverlayInputFocusFlagList() {
509
+ return [
510
+ _WindowFlags.FLAG_WATCH_OUTSIDE_TOUCH,
511
+ _WindowFlags.FLAG_NOT_TOUCH_MODAL,
512
+ _WindowFlags.FLAG_LAYOUT_NO_LIMITS,
513
+ _WindowFlags.FLAG_LAYOUT_IN_SCREEN
514
+ ];
515
+ }
516
+ /** 输入框失去焦点时使用的悬浮窗 flag 组合(含 FLAG_NOT_FOCUSABLE) */
517
+ static getOverlayInputBlurFlagList() {
518
+ return [
519
+ _WindowFlags.FLAG_WATCH_OUTSIDE_TOUCH,
520
+ _WindowFlags.FLAG_NOT_TOUCH_MODAL,
521
+ _WindowFlags.FLAG_LAYOUT_NO_LIMITS,
522
+ _WindowFlags.FLAG_NOT_FOCUSABLE,
523
+ _WindowFlags.FLAG_LAYOUT_IN_SCREEN
524
+ ];
525
+ }
526
+ /**
527
+ * 获取所有标志位的描述信息
528
+ * @returns 标志位描述对象数组
529
+ */
530
+ static getAllFlags() {
531
+ return [
532
+ { name: "FLAG_NOT_FOCUSABLE", value: this.FLAG_NOT_FOCUSABLE, hex: this.toHex(this.FLAG_NOT_FOCUSABLE), description: "\u4E0D\u83B7\u53D6\u7126\u70B9" },
533
+ { name: "FLAG_NOT_TOUCHABLE", value: this.FLAG_NOT_TOUCHABLE, hex: this.toHex(this.FLAG_NOT_TOUCHABLE), description: "\u4E0D\u54CD\u5E94\u89E6\u6478" },
534
+ { 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" },
535
+ { 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" },
536
+ { 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" },
537
+ { 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" },
538
+ { name: "FLAG_FULLSCREEN", value: this.FLAG_FULLSCREEN, hex: this.toHex(this.FLAG_FULLSCREEN), description: "\u5168\u5C4F\u663E\u793A" },
539
+ { name: "FLAG_DIM_BEHIND", value: this.FLAG_DIM_BEHIND, hex: this.toHex(this.FLAG_DIM_BEHIND), description: "\u80CC\u666F\u53D8\u6697" },
540
+ { name: "FLAG_SECURE", value: this.FLAG_SECURE, hex: this.toHex(this.FLAG_SECURE), description: "\u9632\u5F55\u5C4F\u9632\u622A\u56FE" },
541
+ { name: "FLAG_KEEP_SCREEN_ON", value: this.FLAG_KEEP_SCREEN_ON, hex: this.toHex(this.FLAG_KEEP_SCREEN_ON), description: "\u4FDD\u6301\u5E38\u4EAE" },
542
+ { 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" },
543
+ { name: "FLAG_DISMISS_KEYGUARD", value: this.FLAG_DISMISS_KEYGUARD, hex: this.toHex(this.FLAG_DISMISS_KEYGUARD), description: "\u89E3\u9501\u5C4F\u5E55" },
544
+ { name: "FLAG_TURN_SCREEN_ON", value: this.FLAG_TURN_SCREEN_ON, hex: this.toHex(this.FLAG_TURN_SCREEN_ON), description: "\u70B9\u4EAE\u5C4F\u5E55" },
545
+ { 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" },
546
+ { name: "FLAG_SHOW_WALLPAPER", value: this.FLAG_SHOW_WALLPAPER, hex: this.toHex(this.FLAG_SHOW_WALLPAPER), description: "\u663E\u793A\u5899\u7EB8" },
547
+ { name: "FLAG_HARDWARE_ACCELERATED", value: this.FLAG_HARDWARE_ACCELERATED, hex: this.toHex(this.FLAG_HARDWARE_ACCELERATED), description: "\u5F3A\u5236\u786C\u4EF6\u52A0\u901F" }
548
+ ];
549
+ }
550
+ };
551
+ /** 不获取焦点 */
552
+ _WindowFlags.FLAG_NOT_FOCUSABLE = 8;
553
+ // 0x08
554
+ /** 不响应触摸 */
555
+ _WindowFlags.FLAG_NOT_TOUCHABLE = 16;
556
+ // 0x10
557
+ /** 不拦截触摸 */
558
+ _WindowFlags.FLAG_NOT_TOUCH_MODAL = 32;
559
+ // 0x20
560
+ /** 监听窗外点击 */
561
+ _WindowFlags.FLAG_WATCH_OUTSIDE_TOUCH = 4;
562
+ // 0x04
563
+ /** 可绘制超出屏幕 */
564
+ _WindowFlags.FLAG_LAYOUT_NO_LIMITS = 512;
565
+ // 0x200
566
+ /** 屏幕全区域布局 */
567
+ _WindowFlags.FLAG_LAYOUT_IN_SCREEN = 256;
568
+ // 0x100
569
+ /** 全屏显示 */
570
+ _WindowFlags.FLAG_FULLSCREEN = 1024;
571
+ // 0x400
572
+ /** 背景变暗 */
573
+ _WindowFlags.FLAG_DIM_BEHIND = 2;
574
+ // 0x02
575
+ /** 防录屏防截图 */
576
+ _WindowFlags.FLAG_SECURE = 8192;
577
+ // 0x2000
578
+ /** 保持常亮 */
579
+ _WindowFlags.FLAG_KEEP_SCREEN_ON = 128;
580
+ // 0x80
581
+ /** 锁屏时可见 */
582
+ _WindowFlags.FLAG_SHOW_WHEN_LOCKED = 524288;
583
+ // 0x80000
584
+ /** 解锁屏幕 */
585
+ _WindowFlags.FLAG_DISMISS_KEYGUARD = 4194304;
586
+ // 0x400000
587
+ /** 点亮屏幕 */
588
+ _WindowFlags.FLAG_TURN_SCREEN_ON = 2097152;
589
+ // 0x200000
590
+ /** 自动锁屏(不常用) */
591
+ _WindowFlags.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 128;
592
+ // 0x80
593
+ /** 显示墙纸 */
594
+ _WindowFlags.FLAG_SHOW_WALLPAPER = 1048576;
595
+ // 0x100000
596
+ /** 强制硬件加速 */
597
+ _WindowFlags.FLAG_HARDWARE_ACCELERATED = 16777216;
598
+ var WindowFlags = _WindowFlags;
599
+
414
600
  // src/assistsx-async.ts
415
601
  var AssistsXAsync = class {
416
602
  /**
@@ -482,6 +668,18 @@ var AssistsXAsync = class {
482
668
  });
483
669
  return response.getDataOrDefault(false);
484
670
  }
671
+ /**
672
+ * 设置悬浮窗可获取焦点(WebView 内输入框 focus 时调用)
673
+ */
674
+ static async setOverlayInputFocus(timeout) {
675
+ return this.setOverlayFlagList(WindowFlags.getOverlayInputFocusFlagList(), timeout);
676
+ }
677
+ /**
678
+ * 取消悬浮窗焦点(WebView 内输入框 blur 时调用)
679
+ */
680
+ static async clearOverlayInputFocus(timeout) {
681
+ return this.setOverlayFlagList(WindowFlags.getOverlayInputBlurFlagList(), timeout);
682
+ }
485
683
  /**
486
684
  * 获取所有符合条件的节点
487
685
  * @param filterClass 类名过滤
@@ -1247,6 +1445,22 @@ var AssistsXAsync = class {
1247
1445
  });
1248
1446
  return AppInfo.fromJSON(response.getDataOrDefault({}));
1249
1447
  }
1448
+ /**
1449
+ * 获取当前运行的 AssistsX 插件信息(仅 AssistsX 宿主有效,否则返回 null)
1450
+ */
1451
+ static async getCurrentPlugin(timeout) {
1452
+ const response = await this.asyncCall(CallMethod.getCurrentPlugin, {
1453
+ timeout
1454
+ });
1455
+ if (!response.isSuccess()) {
1456
+ return null;
1457
+ }
1458
+ const data = response.getDataOrNull();
1459
+ if (!data) {
1460
+ return null;
1461
+ }
1462
+ return PluginInfo.fromJSON(data);
1463
+ }
1250
1464
  static async getUniqueDeviceId(timeout) {
1251
1465
  const response = await this.asyncCall(CallMethod.getUniqueDeviceId, {
1252
1466
  timeout
@@ -1486,6 +1700,17 @@ var useStepStore = (0, import_pinia.defineStore)("step", {
1486
1700
  }
1487
1701
  });
1488
1702
 
1703
+ // src/pinia-ensure.ts
1704
+ var import_pinia2 = require("pinia");
1705
+ var fallbackPinia = null;
1706
+ function ensureAssistsXPinia() {
1707
+ if ((0, import_pinia2.getActivePinia)() !== void 0) return;
1708
+ if (fallbackPinia === null) {
1709
+ fallbackPinia = (0, import_pinia2.createPinia)();
1710
+ }
1711
+ (0, import_pinia2.setActivePinia)(fallbackPinia);
1712
+ }
1713
+
1489
1714
  // src/step-error.ts
1490
1715
  var StepError = class extends Error {
1491
1716
  constructor(message, data, impl, tag, originalError, currentStep) {
@@ -1847,13 +2072,31 @@ var _Step = class _Step {
1847
2072
  this.delayMs = _Step.delayMsDefault;
1848
2073
  this.tag = tag;
1849
2074
  this.stepId = stepId;
1850
- this.data = data != null ? data : {};
2075
+ this.data = _Step.resolveStepData(data);
1851
2076
  this.impl = impl;
1852
2077
  this.delayMs = delayMs;
1853
2078
  this.repeatCountMax = repeatCountMax;
1854
2079
  this.exceptionRetryCountMax = exceptionRetryCountMax;
1855
2080
  this.isEnd = isEnd;
1856
2081
  }
2082
+ /**
2083
+ * 判断步骤数据是否有效(非空且为普通对象)
2084
+ */
2085
+ static isValidStepData(data) {
2086
+ return data !== null && data !== void 0 && typeof data === "object" && !Array.isArray(data);
2087
+ }
2088
+ /**
2089
+ * 解析步骤数据:优先使用传入值,否则使用当前值,均无效时返回空对象
2090
+ */
2091
+ static resolveStepData(provided, fallback) {
2092
+ if (provided !== void 0 && _Step.isValidStepData(provided)) {
2093
+ return provided;
2094
+ }
2095
+ if (fallback !== void 0 && _Step.isValidStepData(fallback)) {
2096
+ return fallback;
2097
+ }
2098
+ return {};
2099
+ }
1857
2100
  /**
1858
2101
  * 运行步骤实现
1859
2102
  * @param impl 步骤实现函数
@@ -1870,7 +2113,9 @@ var _Step = class _Step {
1870
2113
  } = {}) {
1871
2114
  var _a2, _b, _c, _d, _e, _f;
1872
2115
  this.exception = void 0;
2116
+ ensureAssistsXPinia();
1873
2117
  const stepStore = useStepStore();
2118
+ const resolvedData = _Step.resolveStepData(data);
1874
2119
  let implnName = impl.name;
1875
2120
  let currentStep;
1876
2121
  let nextStep;
@@ -1886,12 +2131,12 @@ var _Step = class _Step {
1886
2131
  console.log(`\u751F\u6210\u6B65\u9AA4ID: ${this._stepId}`);
1887
2132
  }
1888
2133
  }
1889
- stepStore.startStep(this._stepId, tag, data);
2134
+ stepStore.startStep(this._stepId, tag, resolvedData);
1890
2135
  currentStep = new _Step({
1891
2136
  stepId: this._stepId,
1892
2137
  impl,
1893
2138
  tag,
1894
- data,
2139
+ data: resolvedData,
1895
2140
  delayMs,
1896
2141
  exceptionRetryCountMax
1897
2142
  });
@@ -2000,7 +2245,7 @@ var _Step = class _Step {
2000
2245
  const errorMsg = JSON.stringify({
2001
2246
  impl: implnName,
2002
2247
  tag,
2003
- data,
2248
+ data: resolvedData,
2004
2249
  error: (_f = e == null ? void 0 : e.message) != null ? _f : String(e)
2005
2250
  });
2006
2251
  stepStore.setError(errorMsg);
@@ -2143,13 +2388,12 @@ var _Step = class _Step {
2143
2388
  repeatCountMax = _Step.repeatCountMaxDefault,
2144
2389
  exceptionRetryCountMax = _Step.exceptionRetryCountMaxDefault
2145
2390
  } = {}) {
2146
- var _a2;
2147
2391
  _Step.assert(this.stepId);
2148
2392
  return new _Step({
2149
2393
  stepId: this.stepId,
2150
2394
  impl,
2151
2395
  tag,
2152
- data: (_a2 = data != null ? data : this.data) != null ? _a2 : {},
2396
+ data: _Step.resolveStepData(data, this.data),
2153
2397
  delayMs,
2154
2398
  repeatCountMax,
2155
2399
  exceptionRetryCountMax
@@ -2162,13 +2406,12 @@ var _Step = class _Step {
2162
2406
  repeatCountMax = _Step.repeatCountMaxDefault,
2163
2407
  exceptionRetryCountMax = _Step.exceptionRetryCountMaxDefault
2164
2408
  } = {}) {
2165
- var _a2;
2166
2409
  _Step.assert(this.stepId);
2167
2410
  return new _Step({
2168
2411
  stepId: this.stepId,
2169
2412
  impl: void 0,
2170
2413
  tag,
2171
- data: (_a2 = data != null ? data : this.data) != null ? _a2 : {},
2414
+ data: _Step.resolveStepData(data, this.data),
2172
2415
  delayMs,
2173
2416
  repeatCountMax,
2174
2417
  exceptionRetryCountMax,
@@ -2186,7 +2429,7 @@ var _Step = class _Step {
2186
2429
  repeat({
2187
2430
  stepId = this.stepId,
2188
2431
  tag = this.tag,
2189
- data = ((_a2) => (_a2 = this.data) != null ? _a2 : {})(),
2432
+ data,
2190
2433
  delayMs = this.delayMs,
2191
2434
  repeatCountMax = this.repeatCountMax,
2192
2435
  exceptionRetryCountMax = this.exceptionRetryCountMax
@@ -2195,7 +2438,7 @@ var _Step = class _Step {
2195
2438
  this.repeatCount++;
2196
2439
  this.stepId = stepId;
2197
2440
  this.tag = tag;
2198
- this.data = data;
2441
+ this.data = _Step.resolveStepData(data, this.data);
2199
2442
  this.delayMs = delayMs;
2200
2443
  this.repeatCountMax = repeatCountMax;
2201
2444
  this.exceptionRetryCountMax = exceptionRetryCountMax;
@@ -3426,6 +3669,20 @@ var AssistsX2 = class {
3426
3669
  });
3427
3670
  return response.getDataOrDefault(false);
3428
3671
  }
3672
+ /**
3673
+ * 设置悬浮窗可获取焦点(WebView 内输入框 focus 时调用)
3674
+ * @returns 是否设置成功
3675
+ */
3676
+ static setOverlayInputFocus() {
3677
+ return this.setOverlayFlagList(WindowFlags.getOverlayInputFocusFlagList());
3678
+ }
3679
+ /**
3680
+ * 取消悬浮窗焦点(WebView 内输入框 blur 时调用)
3681
+ * @returns 是否设置成功
3682
+ */
3683
+ static clearOverlayInputFocus() {
3684
+ return this.setOverlayFlagList(WindowFlags.getOverlayInputBlurFlagList());
3685
+ }
3429
3686
  /**
3430
3687
  * 获取所有符合条件的节点
3431
3688
  * @param filterClass 类名过滤
@@ -4071,6 +4328,20 @@ var AssistsX2 = class {
4071
4328
  });
4072
4329
  return AppInfo.fromJSON(response.getDataOrDefault({}));
4073
4330
  }
4331
+ /**
4332
+ * 获取当前运行的 AssistsX 插件信息(仅 AssistsX 宿主有效,否则返回 null)
4333
+ */
4334
+ static getCurrentPlugin() {
4335
+ const response = this.call(CallMethod.getCurrentPlugin);
4336
+ if (!response.isSuccess()) {
4337
+ return null;
4338
+ }
4339
+ const data = response.getDataOrNull();
4340
+ if (!data) {
4341
+ return null;
4342
+ }
4343
+ return PluginInfo.fromJSON(data);
4344
+ }
4074
4345
  static getUniqueDeviceId() {
4075
4346
  const response = this.call(CallMethod.getUniqueDeviceId);
4076
4347
  return response.getDataOrDefault("");
@@ -4222,117 +4493,6 @@ var NodeClassValue = {
4222
4493
  FrameLayout: "android.widget.FrameLayout"
4223
4494
  };
4224
4495
 
4225
- // src/window-flags.ts
4226
- var WindowFlags = class {
4227
- // 0x1000000
4228
- /**
4229
- * 获取标志位的十六进制表示
4230
- * @param flag 标志位值
4231
- * @returns 十六进制字符串
4232
- */
4233
- static toHex(flag) {
4234
- return `0x${flag.toString(16).toUpperCase()}`;
4235
- }
4236
- /**
4237
- * 检查是否包含指定标志位
4238
- * @param flags 当前标志位组合
4239
- * @param flag 要检查的标志位
4240
- * @returns 是否包含该标志位
4241
- */
4242
- static hasFlag(flags, flag) {
4243
- return (flags & flag) === flag;
4244
- }
4245
- /**
4246
- * 添加标志位
4247
- * @param flags 当前标志位组合
4248
- * @param flag 要添加的标志位
4249
- * @returns 新的标志位组合
4250
- */
4251
- static addFlag(flags, flag) {
4252
- return flags | flag;
4253
- }
4254
- /**
4255
- * 移除标志位
4256
- * @param flags 当前标志位组合
4257
- * @param flag 要移除的标志位
4258
- * @returns 新的标志位组合
4259
- */
4260
- static removeFlag(flags, flag) {
4261
- return flags & ~flag;
4262
- }
4263
- /**
4264
- * 获取所有标志位的描述信息
4265
- * @returns 标志位描述对象数组
4266
- */
4267
- static getAllFlags() {
4268
- return [
4269
- { name: "FLAG_NOT_FOCUSABLE", value: this.FLAG_NOT_FOCUSABLE, hex: this.toHex(this.FLAG_NOT_FOCUSABLE), description: "\u4E0D\u83B7\u53D6\u7126\u70B9" },
4270
- { name: "FLAG_NOT_TOUCHABLE", value: this.FLAG_NOT_TOUCHABLE, hex: this.toHex(this.FLAG_NOT_TOUCHABLE), description: "\u4E0D\u54CD\u5E94\u89E6\u6478" },
4271
- { 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" },
4272
- { 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" },
4273
- { 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" },
4274
- { 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" },
4275
- { name: "FLAG_FULLSCREEN", value: this.FLAG_FULLSCREEN, hex: this.toHex(this.FLAG_FULLSCREEN), description: "\u5168\u5C4F\u663E\u793A" },
4276
- { name: "FLAG_DIM_BEHIND", value: this.FLAG_DIM_BEHIND, hex: this.toHex(this.FLAG_DIM_BEHIND), description: "\u80CC\u666F\u53D8\u6697" },
4277
- { name: "FLAG_SECURE", value: this.FLAG_SECURE, hex: this.toHex(this.FLAG_SECURE), description: "\u9632\u5F55\u5C4F\u9632\u622A\u56FE" },
4278
- { name: "FLAG_KEEP_SCREEN_ON", value: this.FLAG_KEEP_SCREEN_ON, hex: this.toHex(this.FLAG_KEEP_SCREEN_ON), description: "\u4FDD\u6301\u5E38\u4EAE" },
4279
- { 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" },
4280
- { name: "FLAG_DISMISS_KEYGUARD", value: this.FLAG_DISMISS_KEYGUARD, hex: this.toHex(this.FLAG_DISMISS_KEYGUARD), description: "\u89E3\u9501\u5C4F\u5E55" },
4281
- { name: "FLAG_TURN_SCREEN_ON", value: this.FLAG_TURN_SCREEN_ON, hex: this.toHex(this.FLAG_TURN_SCREEN_ON), description: "\u70B9\u4EAE\u5C4F\u5E55" },
4282
- { 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" },
4283
- { name: "FLAG_SHOW_WALLPAPER", value: this.FLAG_SHOW_WALLPAPER, hex: this.toHex(this.FLAG_SHOW_WALLPAPER), description: "\u663E\u793A\u5899\u7EB8" },
4284
- { name: "FLAG_HARDWARE_ACCELERATED", value: this.FLAG_HARDWARE_ACCELERATED, hex: this.toHex(this.FLAG_HARDWARE_ACCELERATED), description: "\u5F3A\u5236\u786C\u4EF6\u52A0\u901F" }
4285
- ];
4286
- }
4287
- };
4288
- /** 不获取焦点 */
4289
- WindowFlags.FLAG_NOT_FOCUSABLE = 8;
4290
- // 0x08
4291
- /** 不响应触摸 */
4292
- WindowFlags.FLAG_NOT_TOUCHABLE = 16;
4293
- // 0x10
4294
- /** 不拦截触摸 */
4295
- WindowFlags.FLAG_NOT_TOUCH_MODAL = 32;
4296
- // 0x20
4297
- /** 监听窗外点击 */
4298
- WindowFlags.FLAG_WATCH_OUTSIDE_TOUCH = 4;
4299
- // 0x04
4300
- /** 可绘制超出屏幕 */
4301
- WindowFlags.FLAG_LAYOUT_NO_LIMITS = 512;
4302
- // 0x200
4303
- /** 屏幕全区域布局 */
4304
- WindowFlags.FLAG_LAYOUT_IN_SCREEN = 256;
4305
- // 0x100
4306
- /** 全屏显示 */
4307
- WindowFlags.FLAG_FULLSCREEN = 1024;
4308
- // 0x400
4309
- /** 背景变暗 */
4310
- WindowFlags.FLAG_DIM_BEHIND = 2;
4311
- // 0x02
4312
- /** 防录屏防截图 */
4313
- WindowFlags.FLAG_SECURE = 8192;
4314
- // 0x2000
4315
- /** 保持常亮 */
4316
- WindowFlags.FLAG_KEEP_SCREEN_ON = 128;
4317
- // 0x80
4318
- /** 锁屏时可见 */
4319
- WindowFlags.FLAG_SHOW_WHEN_LOCKED = 524288;
4320
- // 0x80000
4321
- /** 解锁屏幕 */
4322
- WindowFlags.FLAG_DISMISS_KEYGUARD = 4194304;
4323
- // 0x400000
4324
- /** 点亮屏幕 */
4325
- WindowFlags.FLAG_TURN_SCREEN_ON = 2097152;
4326
- // 0x200000
4327
- /** 自动锁屏(不常用) */
4328
- WindowFlags.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 128;
4329
- // 0x80
4330
- /** 显示墙纸 */
4331
- WindowFlags.FLAG_SHOW_WALLPAPER = 1048576;
4332
- // 0x100000
4333
- /** 强制硬件加速 */
4334
- WindowFlags.FLAG_HARDWARE_ACCELERATED = 16777216;
4335
-
4336
4496
  // src/accessibility-event-filter.ts
4337
4497
  var AccessibilityEventFilter = class _AccessibilityEventFilter {
4338
4498
  constructor(config = {}) {
@@ -7125,6 +7285,342 @@ var Mlkit = class {
7125
7285
  };
7126
7286
  var mlkit = new Mlkit();
7127
7287
 
7288
+ // src/screenshot/screenshot-call-method.ts
7289
+ var ScreenshotCallMethod = {
7290
+ /** 截取全屏并返回 Base64 */
7291
+ takeScreenshotBase64: "takeScreenshotBase64",
7292
+ /** 截取指定节点区域并返回 Base64,需传 node.nodeId */
7293
+ takeNodeScreenshotBase64: "takeNodeScreenshotBase64",
7294
+ /** 批量截取节点区域并返回 Base64 数组,nodes 为空时返回全屏 */
7295
+ takeScreenshotNodesBase64: "takeScreenshotNodesBase64"
7296
+ };
7297
+
7298
+ // src/screenshot/screenshot.ts
7299
+ var callbacks10 = /* @__PURE__ */ new Map();
7300
+ if (typeof window !== "undefined" && !window.assistsxScreenshotCallback) {
7301
+ window.assistsxScreenshotCallback = (data) => {
7302
+ let callbackId;
7303
+ try {
7304
+ const json = decodeBase64UTF8(data);
7305
+ const response = JSON.parse(json);
7306
+ callbackId = response.callbackId;
7307
+ if (callbackId) {
7308
+ const callback = callbacks10.get(callbackId);
7309
+ if (callback) {
7310
+ callback(json);
7311
+ }
7312
+ }
7313
+ } catch (e) {
7314
+ console.error("Screenshot callback error:", e);
7315
+ } finally {
7316
+ if (callbackId) {
7317
+ callbacks10.delete(callbackId);
7318
+ }
7319
+ }
7320
+ };
7321
+ }
7322
+ function createNodeStub(nodeId) {
7323
+ return { nodeId };
7324
+ }
7325
+ function parseScreenshotBase64Data(data) {
7326
+ if (!data || typeof data !== "object") {
7327
+ return null;
7328
+ }
7329
+ const record = data;
7330
+ const base64 = typeof record.base64 === "string" ? record.base64 : "";
7331
+ const mimeType = typeof record.mimeType === "string" ? record.mimeType : "image/png";
7332
+ const dataUrl = typeof record.dataUrl === "string" ? record.dataUrl : `data:${mimeType};base64,${base64}`;
7333
+ if (!base64) {
7334
+ return null;
7335
+ }
7336
+ return { base64, dataUrl, mimeType };
7337
+ }
7338
+ var Screenshot = class {
7339
+ /**
7340
+ * 执行异步调用
7341
+ */
7342
+ async asyncCall(method, {
7343
+ args,
7344
+ node,
7345
+ nodes,
7346
+ timeout = 30
7347
+ } = {}) {
7348
+ const uuid = generateUUID();
7349
+ const params = {
7350
+ method,
7351
+ arguments: args ? args : void 0,
7352
+ node: node ? node : void 0,
7353
+ nodes: nodes ? nodes : void 0,
7354
+ callbackId: uuid
7355
+ };
7356
+ const promise = new Promise((resolve) => {
7357
+ callbacks10.set(uuid, (data) => {
7358
+ resolve(data);
7359
+ });
7360
+ setTimeout(() => {
7361
+ callbacks10.delete(uuid);
7362
+ resolve(JSON.stringify(new CallResponse(0, null, uuid)));
7363
+ }, timeout * 1e3);
7364
+ });
7365
+ window.assistsxScreenshot.call(JSON.stringify(params));
7366
+ const promiseResult = await promise;
7367
+ if (typeof promiseResult === "string") {
7368
+ const responseData = JSON.parse(promiseResult);
7369
+ return new CallResponse(
7370
+ responseData.code,
7371
+ responseData.data,
7372
+ responseData.callbackId
7373
+ );
7374
+ }
7375
+ throw new Error("Screenshot call failed");
7376
+ }
7377
+ buildScreenshotArgs(options = {}) {
7378
+ const {
7379
+ overlayHiddenScreenshotDelayMillis = 250,
7380
+ format = "PNG",
7381
+ withDataUrlPrefix = true
7382
+ } = options;
7383
+ return {
7384
+ overlayHiddenScreenshotDelayMillis,
7385
+ format,
7386
+ withDataUrlPrefix
7387
+ };
7388
+ }
7389
+ /**
7390
+ * 截取全屏并返回 Base64
7391
+ */
7392
+ async takeScreenshotBase64(options = {}) {
7393
+ const { timeout = 30, ...rest } = options;
7394
+ const response = await this.asyncCall(ScreenshotCallMethod.takeScreenshotBase64, {
7395
+ args: this.buildScreenshotArgs(rest),
7396
+ timeout
7397
+ });
7398
+ if (!response.isSuccess()) {
7399
+ return null;
7400
+ }
7401
+ return parseScreenshotBase64Data(response.getDataOrNull());
7402
+ }
7403
+ /**
7404
+ * 截取指定节点区域并返回 Base64
7405
+ */
7406
+ async takeNodeScreenshotBase64(nodeId, options = {}) {
7407
+ if (!nodeId) {
7408
+ throw new Error("nodeId is required");
7409
+ }
7410
+ const { timeout = 30, ...rest } = options;
7411
+ const response = await this.asyncCall(ScreenshotCallMethod.takeNodeScreenshotBase64, {
7412
+ args: this.buildScreenshotArgs(rest),
7413
+ node: createNodeStub(nodeId),
7414
+ timeout
7415
+ });
7416
+ if (!response.isSuccess()) {
7417
+ return null;
7418
+ }
7419
+ return parseScreenshotBase64Data(response.getDataOrNull());
7420
+ }
7421
+ /**
7422
+ * 批量截取节点区域;nodeIds 为空时返回全屏截图
7423
+ */
7424
+ async takeScreenshotNodesBase64(nodeIds = [], options = {}) {
7425
+ const { timeout = 30, ...rest } = options;
7426
+ const nodes = nodeIds.map((nodeId) => createNodeStub(nodeId));
7427
+ const response = await this.asyncCall(ScreenshotCallMethod.takeScreenshotNodesBase64, {
7428
+ args: this.buildScreenshotArgs(rest),
7429
+ nodes,
7430
+ timeout
7431
+ });
7432
+ if (!response.isSuccess()) {
7433
+ return [];
7434
+ }
7435
+ const data = response.getDataOrNull();
7436
+ return Array.isArray(data == null ? void 0 : data.images) ? data.images : [];
7437
+ }
7438
+ };
7439
+ var screenshot = new Screenshot();
7440
+
7441
+ // src/db/db-call-method.ts
7442
+ var DbCallMethod = {
7443
+ exec: "exec",
7444
+ query: "query",
7445
+ execBatch: "execBatch",
7446
+ close: "close"
7447
+ };
7448
+
7449
+ // src/db/db.ts
7450
+ var callbacks11 = /* @__PURE__ */ new Map();
7451
+ if (typeof window !== "undefined" && !window.assistsxDbCallback) {
7452
+ window.assistsxDbCallback = (data) => {
7453
+ let callbackId;
7454
+ try {
7455
+ const json = decodeBase64UTF8(data);
7456
+ const response = JSON.parse(json);
7457
+ callbackId = response.callbackId;
7458
+ if (callbackId) {
7459
+ const callback = callbacks11.get(callbackId);
7460
+ if (callback) {
7461
+ callback(json);
7462
+ }
7463
+ }
7464
+ } catch (e) {
7465
+ console.error("Db callback error:", e);
7466
+ } finally {
7467
+ if (callbackId) {
7468
+ callbacks11.delete(callbackId);
7469
+ }
7470
+ }
7471
+ };
7472
+ }
7473
+ function buildDbArguments(target, extra) {
7474
+ const args = { ...extra };
7475
+ if (target.dbPath) {
7476
+ args.dbPath = target.dbPath;
7477
+ }
7478
+ if (target.dbName) {
7479
+ args.dbName = target.dbName;
7480
+ }
7481
+ return args;
7482
+ }
7483
+ function normalizeBindArgs(bindArgs) {
7484
+ if (!bindArgs || bindArgs.length === 0) {
7485
+ return void 0;
7486
+ }
7487
+ return bindArgs.map((value) => {
7488
+ if (value === null) {
7489
+ return null;
7490
+ }
7491
+ return String(value);
7492
+ });
7493
+ }
7494
+ function parseExecResult(data) {
7495
+ var _a2, _b;
7496
+ const record = data != null ? data : {};
7497
+ return {
7498
+ rowsAffected: Number((_a2 = record.rowsAffected) != null ? _a2 : 0),
7499
+ lastInsertRowId: Number((_b = record.lastInsertRowId) != null ? _b : 0)
7500
+ };
7501
+ }
7502
+ function parseQueryResult(data) {
7503
+ var _a2;
7504
+ const record = data != null ? data : {};
7505
+ const columns = Array.isArray(record.columns) ? record.columns.map((item) => String(item)) : [];
7506
+ const rows = Array.isArray(record.rows) ? record.rows : [];
7507
+ return {
7508
+ columns,
7509
+ rows,
7510
+ rowCount: Number((_a2 = record.rowCount) != null ? _a2 : rows.length)
7511
+ };
7512
+ }
7513
+ function parseExecBatchResult(data) {
7514
+ var _a2;
7515
+ const record = data != null ? data : {};
7516
+ const results = Array.isArray(record.results) ? record.results.map((item) => parseExecResult(item)) : [];
7517
+ return {
7518
+ count: Number((_a2 = record.count) != null ? _a2 : results.length),
7519
+ results
7520
+ };
7521
+ }
7522
+ var Db = class {
7523
+ /**
7524
+ * 执行异步调用
7525
+ */
7526
+ async asyncCall(method, args, timeout = 30) {
7527
+ const uuid = generateUUID();
7528
+ const params = {
7529
+ method,
7530
+ arguments: args ? args : void 0,
7531
+ callbackId: uuid
7532
+ };
7533
+ const promise = new Promise((resolve) => {
7534
+ callbacks11.set(uuid, (data) => {
7535
+ resolve(data);
7536
+ });
7537
+ setTimeout(() => {
7538
+ callbacks11.delete(uuid);
7539
+ resolve(JSON.stringify(new CallResponse(0, null, uuid)));
7540
+ }, timeout * 1e3);
7541
+ });
7542
+ window.assistsxDb.call(JSON.stringify(params));
7543
+ const promiseResult = await promise;
7544
+ if (typeof promiseResult !== "string") {
7545
+ throw new Error("Db call failed");
7546
+ }
7547
+ const responseData = JSON.parse(promiseResult);
7548
+ if (responseData.code !== 0) {
7549
+ throw new Error(responseData.message || "Db call failed");
7550
+ }
7551
+ return new CallResponse(
7552
+ responseData.code,
7553
+ responseData.data,
7554
+ responseData.callbackId
7555
+ );
7556
+ }
7557
+ /**
7558
+ * 将 query 结果中的 Base64 BLOB 字段解码为 Uint8Array
7559
+ */
7560
+ decodeBlobBase64(base64) {
7561
+ const binary = atob(base64);
7562
+ const bytes = new Uint8Array(binary.length);
7563
+ for (let i = 0; i < binary.length; i++) {
7564
+ bytes[i] = binary.charCodeAt(i);
7565
+ }
7566
+ return bytes;
7567
+ }
7568
+ /**
7569
+ * 执行非查询 SQL
7570
+ */
7571
+ async exec(sql, options) {
7572
+ const { timeout = 30, bindArgs, ...target } = options;
7573
+ const response = await this.asyncCall(
7574
+ DbCallMethod.exec,
7575
+ buildDbArguments(target, {
7576
+ sql,
7577
+ bindArgs: normalizeBindArgs(bindArgs)
7578
+ }),
7579
+ timeout
7580
+ );
7581
+ return parseExecResult(response.getDataOrNull());
7582
+ }
7583
+ /**
7584
+ * 执行查询 SQL
7585
+ */
7586
+ async query(sql, options) {
7587
+ const { timeout = 30, bindArgs, ...target } = options;
7588
+ const response = await this.asyncCall(
7589
+ DbCallMethod.query,
7590
+ buildDbArguments(target, {
7591
+ sql,
7592
+ bindArgs: normalizeBindArgs(bindArgs)
7593
+ }),
7594
+ timeout
7595
+ );
7596
+ return parseQueryResult(response.getDataOrNull());
7597
+ }
7598
+ /**
7599
+ * 事务内批量执行多条 SQL
7600
+ */
7601
+ async execBatch(statements, options) {
7602
+ const { timeout = 30, ...target } = options;
7603
+ const response = await this.asyncCall(
7604
+ DbCallMethod.execBatch,
7605
+ buildDbArguments(target, { statements }),
7606
+ timeout
7607
+ );
7608
+ return parseExecBatchResult(response.getDataOrNull());
7609
+ }
7610
+ /**
7611
+ * 关闭并释放指定数据库连接
7612
+ */
7613
+ async close(options) {
7614
+ const { timeout = 30, ...target } = options;
7615
+ await this.asyncCall(
7616
+ DbCallMethod.close,
7617
+ buildDbArguments(target),
7618
+ timeout
7619
+ );
7620
+ }
7621
+ };
7622
+ var db = new Db();
7623
+
7128
7624
  // src/barutils/bar-utils-call-method.ts
7129
7625
  var BarUtilsCallMethod = {
7130
7626
  // Status bar
@@ -7150,7 +7646,7 @@ var BarUtilsCallMethod = {
7150
7646
  };
7151
7647
 
7152
7648
  // src/barutils/bar-utils.ts
7153
- var callbacks10 = /* @__PURE__ */ new Map();
7649
+ var callbacks12 = /* @__PURE__ */ new Map();
7154
7650
  if (typeof window !== "undefined" && !window.assistsxBarUtilsCallback) {
7155
7651
  window.assistsxBarUtilsCallback = (data) => {
7156
7652
  let callbackId;
@@ -7159,7 +7655,7 @@ if (typeof window !== "undefined" && !window.assistsxBarUtilsCallback) {
7159
7655
  const response = JSON.parse(json);
7160
7656
  callbackId = response.callbackId;
7161
7657
  if (callbackId) {
7162
- const callback = callbacks10.get(callbackId);
7658
+ const callback = callbacks12.get(callbackId);
7163
7659
  if (callback) {
7164
7660
  callback(json);
7165
7661
  }
@@ -7168,7 +7664,7 @@ if (typeof window !== "undefined" && !window.assistsxBarUtilsCallback) {
7168
7664
  console.error("BarUtils callback error:", e);
7169
7665
  } finally {
7170
7666
  if (callbackId) {
7171
- callbacks10.delete(callbackId);
7667
+ callbacks12.delete(callbackId);
7172
7668
  }
7173
7669
  }
7174
7670
  };
@@ -7182,11 +7678,11 @@ var BarUtils = class {
7182
7678
  callbackId: uuid
7183
7679
  };
7184
7680
  const promise = new Promise((resolve) => {
7185
- callbacks10.set(uuid, (data) => {
7681
+ callbacks12.set(uuid, (data) => {
7186
7682
  resolve(data);
7187
7683
  });
7188
7684
  setTimeout(() => {
7189
- callbacks10.delete(uuid);
7685
+ callbacks12.delete(uuid);
7190
7686
  resolve(
7191
7687
  JSON.stringify(
7192
7688
  new CallResponse(-1, { message: "Timeout" }, uuid)
@@ -7467,7 +7963,7 @@ var FloatCallMethod = {
7467
7963
  };
7468
7964
 
7469
7965
  // src/floatingwindow/float.ts
7470
- var callbacks11 = /* @__PURE__ */ new Map();
7966
+ var callbacks13 = /* @__PURE__ */ new Map();
7471
7967
  if (typeof window !== "undefined" && !window.assistsxFloatCallback) {
7472
7968
  window.assistsxFloatCallback = (data) => {
7473
7969
  let callbackId;
@@ -7476,7 +7972,7 @@ if (typeof window !== "undefined" && !window.assistsxFloatCallback) {
7476
7972
  const response = JSON.parse(json);
7477
7973
  callbackId = response.callbackId;
7478
7974
  if (callbackId) {
7479
- const callback = callbacks11.get(callbackId);
7975
+ const callback = callbacks13.get(callbackId);
7480
7976
  if (callback) {
7481
7977
  callback(json);
7482
7978
  }
@@ -7485,7 +7981,7 @@ if (typeof window !== "undefined" && !window.assistsxFloatCallback) {
7485
7981
  console.error("Float callback error:", e);
7486
7982
  } finally {
7487
7983
  if (callbackId) {
7488
- callbacks11.delete(callbackId);
7984
+ callbacks13.delete(callbackId);
7489
7985
  }
7490
7986
  }
7491
7987
  };
@@ -7499,11 +7995,11 @@ var Float = class {
7499
7995
  callbackId: uuid
7500
7996
  };
7501
7997
  const promise = new Promise((resolve) => {
7502
- callbacks11.set(uuid, (data) => {
7998
+ callbacks13.set(uuid, (data) => {
7503
7999
  resolve(data);
7504
8000
  });
7505
8001
  setTimeout(() => {
7506
- callbacks11.delete(uuid);
8002
+ callbacks13.delete(uuid);
7507
8003
  resolve(
7508
8004
  JSON.stringify(
7509
8005
  new CallResponse(-1, { message: "Timeout" }, uuid)
@@ -7665,7 +8161,9 @@ var LogCallMethod = {
7665
8161
  unsubscribe: "unsubscribe",
7666
8162
  uploadLogs: "uploadLogs",
7667
8163
  /** 获取日志服务当前域名(origin,无路径;与上传、管理后台同源),对应 AssistsLogDiagnostics.adminWebBaseUrl() */
7668
- getLogServiceBaseUrl: "getLogServiceBaseUrl"
8164
+ getLogServiceBaseUrl: "getLogServiceBaseUrl",
8165
+ /** 解析日志文件绝对路径(不创建文件) */
8166
+ resolveLogPath: "resolveLogPath"
7669
8167
  };
7670
8168
  var LogStream = {
7671
8169
  latestLine: "latestLine",
@@ -7676,6 +8174,26 @@ var LogStream = {
7676
8174
  var pendingCallbacks = /* @__PURE__ */ new Map();
7677
8175
  var streamHandlers = /* @__PURE__ */ new Map();
7678
8176
  var subscriptionIdToCallbackId = /* @__PURE__ */ new Map();
8177
+ function buildLogArguments(target, extra) {
8178
+ const args = { ...extra };
8179
+ if ((target == null ? void 0 : target.dirPath) !== void 0) {
8180
+ args.dirPath = target.dirPath;
8181
+ }
8182
+ if ((target == null ? void 0 : target.fileName) !== void 0) {
8183
+ args.fileName = target.fileName;
8184
+ }
8185
+ return Object.keys(args).length > 0 ? args : void 0;
8186
+ }
8187
+ function resolveTimeout(timeoutOrOptions, fallback = 30) {
8188
+ var _a2;
8189
+ if (typeof timeoutOrOptions === "number") {
8190
+ return { timeout: timeoutOrOptions };
8191
+ }
8192
+ return {
8193
+ timeout: (_a2 = timeoutOrOptions == null ? void 0 : timeoutOrOptions.timeout) != null ? _a2 : fallback,
8194
+ target: timeoutOrOptions
8195
+ };
8196
+ }
7679
8197
  if (typeof window !== "undefined" && !window.assistsxLogCallback) {
7680
8198
  window.assistsxLogCallback = (data) => {
7681
8199
  try {
@@ -7751,11 +8269,12 @@ var Log = class {
7751
8269
  throw new Error("Log bridge call failed");
7752
8270
  }
7753
8271
  /** 读取当前日志全文 */
7754
- async readAllText(timeout) {
8272
+ async readAllText(timeoutOrOptions) {
7755
8273
  var _a2;
8274
+ const { timeout, target } = resolveTimeout(timeoutOrOptions);
7756
8275
  const res = await this.asyncCall(
7757
8276
  LogCallMethod.readAllText,
7758
- void 0,
8277
+ buildLogArguments(target),
7759
8278
  timeout
7760
8279
  );
7761
8280
  const d = res.getDataOrNull();
@@ -7775,51 +8294,92 @@ var Log = class {
7775
8294
  const d = res.getDataOrNull();
7776
8295
  return (_a2 = d == null ? void 0 : d.baseUrl) != null ? _a2 : "";
7777
8296
  }
8297
+ /**
8298
+ * 解析日志文件绝对路径(不创建文件)。
8299
+ * AssistsX 插件环境下会经原生拦截追加 log-{packageName} 子目录。
8300
+ */
8301
+ async resolveLogPath(targetOrOptions) {
8302
+ var _a2;
8303
+ const { timeout, target } = resolveTimeout(targetOrOptions);
8304
+ const res = await this.asyncCall(
8305
+ LogCallMethod.resolveLogPath,
8306
+ buildLogArguments(target),
8307
+ timeout
8308
+ );
8309
+ const d = res.getDataOrNull();
8310
+ return (_a2 = d == null ? void 0 : d.logFilePath) != null ? _a2 : "";
8311
+ }
7778
8312
  /** 清空日志 */
7779
- async clear(timeout) {
8313
+ async clear(timeoutOrOptions) {
8314
+ const { timeout, target } = resolveTimeout(timeoutOrOptions);
7780
8315
  const res = await this.asyncCall(
7781
8316
  LogCallMethod.clear,
7782
- void 0,
8317
+ buildLogArguments(target),
7783
8318
  timeout
7784
8319
  );
7785
8320
  return res.isSuccess();
7786
8321
  }
7787
8322
  /** 从文件重新加载到内存 Flow */
7788
- async refreshFromFile(timeout) {
8323
+ async refreshFromFile(timeoutOrOptions) {
8324
+ const { timeout, target } = resolveTimeout(timeoutOrOptions);
7789
8325
  const res = await this.asyncCall(
7790
8326
  LogCallMethod.refreshFromFile,
7791
- void 0,
8327
+ buildLogArguments(target),
7792
8328
  timeout
7793
8329
  );
7794
8330
  return res.isSuccess();
7795
8331
  }
7796
8332
  /** 追加一行 */
7797
- async appendLine(line, maxLength, timeout) {
7798
- const args = { line };
7799
- if (maxLength !== void 0) {
7800
- args.maxLength = maxLength;
8333
+ async appendLine(line, maxLengthOrOptions, timeout) {
8334
+ var _a2;
8335
+ let options;
8336
+ if (typeof maxLengthOrOptions === "number") {
8337
+ options = { maxLength: maxLengthOrOptions, timeout };
8338
+ } else {
8339
+ options = maxLengthOrOptions;
8340
+ }
8341
+ const args = (_a2 = buildLogArguments(options, { line })) != null ? _a2 : { line };
8342
+ if ((options == null ? void 0 : options.maxLength) !== void 0) {
8343
+ args.maxLength = options.maxLength;
7801
8344
  }
7802
8345
  const res = await this.asyncCall(
7803
8346
  LogCallMethod.appendLine,
7804
8347
  args,
7805
- timeout
8348
+ options == null ? void 0 : options.timeout
7806
8349
  );
7807
8350
  return res.isSuccess();
7808
8351
  }
7809
8352
  /** 追加带时间戳的条目 */
7810
- async appendTimestampedEntry(message, timeout) {
8353
+ async appendTimestampedEntry(message, timeoutOrOptions) {
8354
+ var _a2;
8355
+ const { timeout, target } = resolveTimeout(timeoutOrOptions);
8356
+ const args = (_a2 = buildLogArguments(target, { message })) != null ? _a2 : { message };
7811
8357
  const res = await this.asyncCall(
7812
8358
  LogCallMethod.appendTimestampedEntry,
7813
- { message },
8359
+ args,
7814
8360
  timeout
7815
8361
  );
7816
8362
  return res.isSuccess();
7817
8363
  }
8364
+ /**
8365
+ * 追加日志(appendTimestampedEntry / appendLine 简写)。
8366
+ * 默认带时间戳;`timestamped: false` 时走 appendLine。
8367
+ */
8368
+ async append(text, options) {
8369
+ const { timestamped = true, maxLength, timeout, ...target } = options != null ? options : {};
8370
+ if (timestamped) {
8371
+ return this.appendTimestampedEntry(text, { ...target, timeout });
8372
+ }
8373
+ return this.appendLine(text, { ...target, maxLength, timeout });
8374
+ }
7818
8375
  /** 替换全部内容 */
7819
- async replaceAll(content, timeout) {
8376
+ async replaceAll(content, timeoutOrOptions) {
8377
+ var _a2;
8378
+ const { timeout, target } = resolveTimeout(timeoutOrOptions);
8379
+ const args = (_a2 = buildLogArguments(target, { content })) != null ? _a2 : { content };
7820
8380
  const res = await this.asyncCall(
7821
8381
  LogCallMethod.replaceAll,
7822
- { content },
8382
+ args,
7823
8383
  timeout
7824
8384
  );
7825
8385
  return res.isSuccess();
@@ -7829,10 +8389,11 @@ var Log = class {
7829
8389
  * resolve 后请保留 dispose 或调用 unsubscribe(subscriptionId) 以释放原生协程与 JS 回调。
7830
8390
  */
7831
8391
  async subscribe(stream, onUpdate, options) {
7832
- var _a2;
8392
+ var _a2, _b;
7833
8393
  const self = this;
7834
8394
  const callbackId = generateUUID();
7835
8395
  const timeoutSec = (_a2 = options == null ? void 0 : options.timeout) != null ? _a2 : 30;
8396
+ const subscribeArgs = (_b = buildLogArguments(options, { stream })) != null ? _b : { stream };
7836
8397
  return new Promise((resolve, reject) => {
7837
8398
  let settled = false;
7838
8399
  const timer = setTimeout(() => {
@@ -7843,7 +8404,7 @@ var Log = class {
7843
8404
  }
7844
8405
  }, timeoutSec * 1e3);
7845
8406
  streamHandlers.set(callbackId, (raw) => {
7846
- var _a3, _b, _c;
8407
+ var _a3, _b2, _c;
7847
8408
  let response;
7848
8409
  try {
7849
8410
  response = JSON.parse(raw);
@@ -7882,9 +8443,10 @@ var Log = class {
7882
8443
  }
7883
8444
  if ((data == null ? void 0 : data.event) === "update" && data.subscriptionId) {
7884
8445
  onUpdate({
7885
- text: (_b = data.text) != null ? _b : "",
8446
+ text: (_b2 = data.text) != null ? _b2 : "",
7886
8447
  stream: (_c = data.stream) != null ? _c : stream,
7887
- subscriptionId: data.subscriptionId
8448
+ subscriptionId: data.subscriptionId,
8449
+ logFilePath: data.logFilePath
7888
8450
  });
7889
8451
  }
7890
8452
  });
@@ -7892,7 +8454,7 @@ var Log = class {
7892
8454
  this.getBridge().call(
7893
8455
  JSON.stringify({
7894
8456
  method: LogCallMethod.subscribe,
7895
- arguments: { stream },
8457
+ arguments: subscribeArgs,
7896
8458
  callbackId
7897
8459
  })
7898
8460
  );
@@ -7936,6 +8498,12 @@ var Log = class {
7936
8498
  if (args.uploadKey !== void 0) {
7937
8499
  payload.uploadKey = args.uploadKey;
7938
8500
  }
8501
+ if (args.dirPath !== void 0) {
8502
+ payload.dirPath = args.dirPath;
8503
+ }
8504
+ if (args.fileName !== void 0) {
8505
+ payload.fileName = args.fileName;
8506
+ }
7939
8507
  const uuid = generateUUID();
7940
8508
  const params = {
7941
8509
  method: LogCallMethod.uploadLogs,
@@ -7991,6 +8559,8 @@ var log = new Log();
7991
8559
  Bounds,
7992
8560
  CallMethod,
7993
8561
  CallResponse,
8562
+ Db,
8563
+ DbCallMethod,
7994
8564
  DeviceInfo,
7995
8565
  FileIO,
7996
8566
  FileUtils,
@@ -8012,6 +8582,9 @@ var log = new Log();
8012
8582
  NodeAsync,
8013
8583
  NodeClassValue,
8014
8584
  Path,
8585
+ PluginInfo,
8586
+ Screenshot,
8587
+ ScreenshotCallMethod,
8015
8588
  Step,
8016
8589
  StepAsync,
8017
8590
  StepError,
@@ -8020,7 +8593,9 @@ var log = new Log();
8020
8593
  accessibilityEventListeners,
8021
8594
  barUtils,
8022
8595
  callbacks,
8596
+ db,
8023
8597
  decodeBase64UTF8,
8598
+ ensureAssistsXPinia,
8024
8599
  fileIO,
8025
8600
  fileUtils,
8026
8601
  float,
@@ -8034,6 +8609,7 @@ var log = new Log();
8034
8609
  mlkit,
8035
8610
  pathUtils,
8036
8611
  screen,
8612
+ screenshot,
8037
8613
  sleep,
8038
8614
  useStepStore
8039
8615
  });