@skrillex1224/playwright-toolkit 2.1.232 → 2.1.233

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
@@ -23,7 +23,7 @@ import { usePlaywrightToolKit } from '@skrillex1224/playwright-toolkit';
23
23
  await Actor.init();
24
24
 
25
25
  // 初始化工具箱
26
- const { ApifyKit: KitHook, Launch, AntiCheat, Humanize, Captcha, LiveView, Constants } = usePlaywrightToolKit();
26
+ const { ApifyKit: KitHook, Launch, AntiCheat, DeviceInput, Humanize, Captcha, LiveView, Constants } = usePlaywrightToolKit();
27
27
 
28
28
  // ⚠️ ApifyKit 需要异步初始化
29
29
  const ApifyKit = await KitHook.useApifyKit();
@@ -107,13 +107,21 @@ await Actor.exit();
107
107
  | `Humanize` | `warmUpBrowsing(page, baseDuration?)` | 页面预热 (3500ms ±40%) |
108
108
  | `Humanize` | `simulateGaze(page, baseDurationMs?)` | 模拟注视 (2500ms ±40%) |
109
109
  | `Humanize` | `randomSleep(baseMs, jitterPercent?)` | 随机延迟 (±30% 抖动) |
110
- | `Humanize` | `M.click/focus/fill/type/clickPoint(...)` | Machine 机械化操作;用于必须保持非拟人化 click/focus/fill/type 的兼容路径 |
110
+ | `DeviceInput` | `click/clickPoint/move/focus/fill/type/press/drag(...)` | 机械输入适配层;根据 page runtime device 自动选择 desktop mouse/click 或 mobile touch/tap |
111
111
  | `Captcha` | `useCaptchaMonitor(page, options)` | 验证码监控 |
112
112
 
113
113
  ---
114
114
 
115
115
  ## 📦 模块详解
116
116
 
117
+ ### DeviceInput
118
+
119
+ `DeviceInput` 是非拟人化机械操作的统一入口。visitor 和 toolkit 内部如果需要执行“机械点击 / 坐标点击 / focus / fill / type / press / drag”,应调用 `DeviceInput`,不要直接调用 `page.mouse`、`page.touchscreen`、`locator.click()` 这类 Playwright 原生输入 API。
120
+
121
+ 它会读取 `RuntimeEnv.applyToPage()` 写入 page 的 `device` 状态:desktop 下使用 mouse/click 语义,mobile 下点击和拖拽优先使用 touch/tap 语义。`focus/fill/type/press` 这类 Playwright 本身跨设备一致的操作会保持原生语义。
122
+
123
+ 更多规则见 [DEVICE_INPUT.md](./DEVICE_INPUT.md)。
124
+
117
125
  ### ApifyKit
118
126
 
119
127
  **⚠️ 需要异步初始化**
@@ -219,7 +227,6 @@ await page.context().addCookies(cookies);
219
227
 
220
228
  // 全页面滚动截图 (自动检测所有滚动元素,强制展开后截图,默认会执行 watermarkify)
221
229
  // 默认会将返回的 base64 压缩到 5MiB 以内,避免 Apify/Crawlee dataset 单条 item 超限
222
- // 默认会额外保留一小段安全 buffer;如需精确贴边可传 { buffer: 0 }
223
230
  const base64Image = await Share.captureScreen(page);
224
231
 
225
232
  // 截图只使用当前页面运行时 viewport;移动端请通过 ActorInfo.device 切换,不再通过截图参数覆盖