@weapp-vite/miniprogram-automator 1.2.13 → 1.2.15

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/README.md CHANGED
@@ -107,6 +107,25 @@ await button?.tap()
107
107
  await page.waitFor(500)
108
108
  ```
109
109
 
110
+ ### 4.5 App-Service 降级(route fallback)能力边界
111
+
112
+ 部分 DevTools 版本(如 `2.01.2510290`)的 page-frame 定向协议失效,表现为 `Page.*` RPC 全部超时。此时本库自动切换到 App-Service 降级通道(`App.callFunction` + `wx.createSelectorQuery`),无需任何配置。
113
+
114
+ 降级模式下各能力可用性:
115
+
116
+ | 能力 | 状态 | 说明 |
117
+ | --------------------------------------------------------- | ----------- | ---------------------------------------------------------------------------------------------- |
118
+ | `page.$` / `page.$$` | ✅ | 经 route 查询返回降级元素 |
119
+ | `page.data()` / `page.setData()` / `page.callMethod()` | ✅ | 经 App-Service 读写页面数据、调用页面方法 |
120
+ | `element.offset()` / `element.size()` / `element.style()` | ✅ | 实时经 `createSelectorQuery` 读取 rect 与 computedStyle(每次读取都重新查询,不缓存) |
121
+ | `element.attribute('id')` / `element.attribute('data-*')` | ✅ | 经快照读取 id 与 dataset |
122
+ | `element.$()` / `element.$$()` | ❌ 明确报错 | 元素级查询依赖 page-frame 协议;请改用 `page.$()` / `page.$$()` |
123
+ | `element.text()` | ❌ 明确报错 | `SelectorQuery` 无法读取 `innerText`;请改用 `page.data()` 或 `page.callMethod()` 断言文案来源 |
124
+ | `element.tap()` / `trigger()` 等真实交互 | ❌ 明确报错 | AppService 无法合成真实触摸事件;请改用 `page.callMethod()` 或 `evaluate` 间接触发页面逻辑 |
125
+ | `scroll-view` 容器滚动 | ❌ | 需 page-frame 协议支持,降级模式不可用 |
126
+
127
+ > 降级元素上的不支持操作会**立即抛出带替代建议的错误**,不会再像旧版那样挂起 30s 才超时。
128
+
110
129
  ## 5. 主要导出
111
130
 
112
131
  | 导出 | 说明 |
package/dist/index.d.mts CHANGED
@@ -94,6 +94,12 @@ interface IElementOptions {
94
94
  videoId?: string;
95
95
  pageId: number;
96
96
  routeFallback?: boolean;
97
+ /** route 降级元素的定位信息:用于只读方法经 App-service 实时重查快照。 */
98
+ routeFallbackSelector?: string;
99
+ routeFallbackIndex?: number;
100
+ routeFallbackRoute?: string;
101
+ routeFallbackQuery?: Record<string, any>;
102
+ routeFallbackScopeSelectors?: string[];
97
103
  tagName: string;
98
104
  }
99
105
  /** ITouch 的类型定义。 */
@@ -123,7 +129,7 @@ interface ElementQueryOptions {
123
129
  }
124
130
  /** Element 的实现。 */
125
131
  declare class Element {
126
- private connection;
132
+ protected readonly connection: Connection;
127
133
  private elementMap;
128
134
  tagName: string;
129
135
  protected nodeId: string | null;
@@ -345,10 +351,10 @@ declare class MiniProgram extends EventEmitter {
345
351
  close(): Promise<void>;
346
352
  remote(auto?: boolean): Promise<void>;
347
353
  disconnect(): void;
348
- enableLog(): Promise<void>;
354
+ enableLog(timeout?: number): Promise<void>;
349
355
  on(event: string | symbol, listener: (...args: any[]) => void): this;
350
356
  exposeFunction(name: string, bindingFunction: AutomatorCallable): Promise<void>;
351
- checkVersion(): Promise<void>;
357
+ checkVersion(timeout?: number): Promise<void>;
352
358
  /**
353
359
  * @description 等待小程序 App 域协议可用,避免返回半就绪自动化会话。
354
360
  */