@midscene/web 1.17.3 → 1.17.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.
Files changed (35) hide show
  1. package/dist/es/bridge-mode/io-client.mjs +1 -1
  2. package/dist/es/bridge-mode/io-server.mjs +2 -2
  3. package/dist/es/bridge-mode/page-browser-side.mjs +1 -1
  4. package/dist/es/chrome-extension/page.mjs +2 -2
  5. package/dist/es/chrome-extension/page.mjs.map +1 -1
  6. package/dist/es/cli.mjs +1 -1
  7. package/dist/es/common/input-scripts.mjs +10 -1
  8. package/dist/es/common/input-scripts.mjs.map +1 -1
  9. package/dist/es/puppeteer/base-page.mjs +17 -2
  10. package/dist/es/puppeteer/base-page.mjs.map +1 -1
  11. package/dist/es/web-element.mjs.map +1 -1
  12. package/dist/es/web-page.mjs +7 -1
  13. package/dist/es/web-page.mjs.map +1 -1
  14. package/dist/lib/bridge-mode/io-client.js +1 -1
  15. package/dist/lib/bridge-mode/io-server.js +2 -2
  16. package/dist/lib/bridge-mode/page-browser-side.js +1 -1
  17. package/dist/lib/chrome-extension/page.js +2 -2
  18. package/dist/lib/chrome-extension/page.js.map +1 -1
  19. package/dist/lib/cli.js +1 -1
  20. package/dist/lib/common/input-scripts.js +12 -0
  21. package/dist/lib/common/input-scripts.js.map +1 -1
  22. package/dist/lib/puppeteer/base-page.js +16 -1
  23. package/dist/lib/puppeteer/base-page.js.map +1 -1
  24. package/dist/lib/web-element.js.map +1 -1
  25. package/dist/lib/web-page.js +7 -1
  26. package/dist/lib/web-page.js.map +1 -1
  27. package/dist/types/agent-init-args.d.ts +2 -2
  28. package/dist/types/chrome-extension/page.d.ts.map +1 -1
  29. package/dist/types/common/input-scripts.d.ts +1 -0
  30. package/dist/types/common/input-scripts.d.ts.map +1 -1
  31. package/dist/types/puppeteer/base-page.d.ts.map +1 -1
  32. package/dist/types/web-element.d.ts +2 -2
  33. package/dist/types/web-element.d.ts.map +1 -1
  34. package/dist/types/web-page.d.ts.map +1 -1
  35. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"web-page.mjs","sources":["../../src/web-page.ts"],"sourcesContent":["import type { Point } from '@midscene/core';\nimport { z } from '@midscene/core';\nimport {\n AbstractInterface,\n type BrowserInputPrimitives,\n type DeviceAction,\n type InputStrategy,\n defineAction,\n defineActionsFromInputPrimitives,\n resolveTextInputOptions,\n sendTextSequentially,\n} from '@midscene/core/device';\n\nimport { sleep } from '@midscene/core/utils';\nimport type { ElementInfo } from '@midscene/shared/extractor';\nimport { transformHotkeyInput } from '@midscene/shared/us-keyboard-layout';\n\nconst navigateParamSchema = z.object({\n url: z\n .string()\n .describe(\n 'The URL to navigate to. Must start with https://, file://, or a similar protocol.',\n ),\n});\n\nfunction normalizeKeyInputs(value: string | string[]): string[] {\n const inputs = Array.isArray(value) ? value : [value];\n const result: string[] = [];\n\n for (const input of inputs) {\n if (typeof input !== 'string') {\n result.push(input as unknown as string);\n continue;\n }\n\n const trimmed = input.trim();\n if (!trimmed) {\n result.push(input);\n continue;\n }\n\n let normalized = trimmed;\n if (normalized.length > 1 && normalized.includes('+')) {\n normalized = normalized.replace(/\\s*\\+\\s*/g, ' ');\n }\n if (/\\s/.test(normalized)) {\n normalized = normalized.replace(/\\s+/g, ' ');\n }\n\n const transformed = transformHotkeyInput(normalized);\n if (transformed.length === 1 && transformed[0] === '' && trimmed !== '') {\n result.push(input);\n continue;\n }\n if (transformed.length === 0) {\n result.push(input);\n continue;\n }\n\n result.push(...transformed);\n }\n\n return result;\n}\n\nexport function getKeyCommands(\n value: string | string[],\n): Array<{ key: string; command?: string }> {\n const keys = normalizeKeyInputs(value);\n\n return keys.reduce((acc: Array<{ key: string; command?: string }>, k) => {\n const includeMeta = keys.includes('Meta') || keys.includes('Control');\n if (includeMeta && (k === 'a' || k === 'A')) {\n return acc.concat([{ key: k, command: 'SelectAll' }]);\n }\n if (includeMeta && (k === 'c' || k === 'C')) {\n return acc.concat([{ key: k, command: 'Copy' }]);\n }\n if (includeMeta && (k === 'v' || k === 'V')) {\n return acc.concat([{ key: k, command: 'Paste' }]);\n }\n return acc.concat([{ key: k }]);\n }, []);\n}\n\n// this is copied from puppeteer, but we don't want to import puppeteer here\nexport declare type KeyInput =\n | '0'\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | '8'\n | '9'\n | 'Power'\n | 'Eject'\n | 'Abort'\n | 'Help'\n | 'Backspace'\n | 'Tab'\n | 'Numpad5'\n | 'NumpadEnter'\n | 'Enter'\n | '\\r'\n | '\\n'\n | 'ShiftLeft'\n | 'ShiftRight'\n | 'ControlLeft'\n | 'ControlRight'\n | 'AltLeft'\n | 'AltRight'\n | 'Pause'\n | 'CapsLock'\n | 'Escape'\n | 'Convert'\n | 'NonConvert'\n | 'Space'\n | 'Numpad9'\n | 'PageUp'\n | 'Numpad3'\n | 'PageDown'\n | 'End'\n | 'Numpad1'\n | 'Home'\n | 'Numpad7'\n | 'ArrowLeft'\n | 'Numpad4'\n | 'Numpad8'\n | 'ArrowUp'\n | 'ArrowRight'\n | 'Numpad6'\n | 'Numpad2'\n | 'ArrowDown'\n | 'Select'\n | 'Open'\n | 'PrintScreen'\n | 'Insert'\n | 'Numpad0'\n | 'Delete'\n | 'NumpadDecimal'\n | 'Digit0'\n | 'Digit1'\n | 'Digit2'\n | 'Digit3'\n | 'Digit4'\n | 'Digit5'\n | 'Digit6'\n | 'Digit7'\n | 'Digit8'\n | 'Digit9'\n | 'KeyA'\n | 'KeyB'\n | 'KeyC'\n | 'KeyD'\n | 'KeyE'\n | 'KeyF'\n | 'KeyG'\n | 'KeyH'\n | 'KeyI'\n | 'KeyJ'\n | 'KeyK'\n | 'KeyL'\n | 'KeyM'\n | 'KeyN'\n | 'KeyO'\n | 'KeyP'\n | 'KeyQ'\n | 'KeyR'\n | 'KeyS'\n | 'KeyT'\n | 'KeyU'\n | 'KeyV'\n | 'KeyW'\n | 'KeyX'\n | 'KeyY'\n | 'KeyZ'\n | 'MetaLeft'\n | 'MetaRight'\n | 'ContextMenu'\n | 'NumpadMultiply'\n | 'NumpadAdd'\n | 'NumpadSubtract'\n | 'NumpadDivide'\n | 'F1'\n | 'F2'\n | 'F3'\n | 'F4'\n | 'F5'\n | 'F6'\n | 'F7'\n | 'F8'\n | 'F9'\n | 'F10'\n | 'F11'\n | 'F12'\n | 'F13'\n | 'F14'\n | 'F15'\n | 'F16'\n | 'F17'\n | 'F18'\n | 'F19'\n | 'F20'\n | 'F21'\n | 'F22'\n | 'F23'\n | 'F24'\n | 'NumLock'\n | 'ScrollLock'\n | 'AudioVolumeMute'\n | 'AudioVolumeDown'\n | 'AudioVolumeUp'\n | 'MediaTrackNext'\n | 'MediaTrackPrevious'\n | 'MediaStop'\n | 'MediaPlayPause'\n | 'Semicolon'\n | 'Equal'\n | 'NumpadEqual'\n | 'Comma'\n | 'Minus'\n | 'Period'\n | 'Slash'\n | 'Backquote'\n | 'BracketLeft'\n | 'Backslash'\n | 'BracketRight'\n | 'Quote'\n | 'AltGraph'\n | 'Props'\n | 'Cancel'\n | 'Clear'\n | 'Shift'\n | 'Control'\n | 'Alt'\n | 'Accept'\n | 'ModeChange'\n | ' '\n | 'Print'\n | 'Execute'\n | '\\u0000'\n | 'a'\n | 'b'\n | 'c'\n | 'd'\n | 'e'\n | 'f'\n | 'g'\n | 'h'\n | 'i'\n | 'j'\n | 'k'\n | 'l'\n | 'm'\n | 'n'\n | 'o'\n | 'p'\n | 'q'\n | 'r'\n | 's'\n | 't'\n | 'u'\n | 'v'\n | 'w'\n | 'x'\n | 'y'\n | 'z'\n | 'Meta'\n | '*'\n | '+'\n | '-'\n | '/'\n | ';'\n | '='\n | ','\n | '.'\n | '`'\n | '['\n | '\\\\'\n | ']'\n | \"'\"\n | 'Attn'\n | 'CrSel'\n | 'ExSel'\n | 'EraseEof'\n | 'Play'\n | 'ZoomOut'\n | ')'\n | '!'\n | '@'\n | '#'\n | '$'\n | '%'\n | '^'\n | '&'\n | '('\n | 'A'\n | 'B'\n | 'C'\n | 'D'\n | 'E'\n | 'F'\n | 'G'\n | 'H'\n | 'I'\n | 'J'\n | 'K'\n | 'L'\n | 'M'\n | 'N'\n | 'O'\n | 'P'\n | 'Q'\n | 'R'\n | 'S'\n | 'T'\n | 'U'\n | 'V'\n | 'W'\n | 'X'\n | 'Y'\n | 'Z'\n | ':'\n | '<'\n | '_'\n | '>'\n | '?'\n | '~'\n | '{'\n | '|'\n | '}'\n | '\"'\n | 'SoftLeft'\n | 'SoftRight'\n | 'Camera'\n | 'Call'\n | 'EndCall'\n | 'VolumeDown'\n | 'VolumeUp';\n\nexport type MouseButton = 'left' | 'right' | 'middle';\n\nexport interface MouseAction {\n click: (\n x: number,\n y: number,\n options: { button: MouseButton; count?: number },\n ) => Promise<void>;\n wheel: (deltaX: number, deltaY: number) => Promise<void>;\n move: (x: number, y: number) => Promise<void>;\n drag: (\n from: { x: number; y: number },\n to: { x: number; y: number },\n ) => Promise<void>;\n}\n\nexport interface KeyboardAction {\n type: (text: string, options?: { delay?: number }) => Promise<void>;\n insertText: (text: string) => Promise<void>;\n press: (\n action:\n | { key: KeyInput; command?: string }\n | { key: KeyInput; command?: string }[],\n ) => Promise<void>;\n}\n\nexport interface ChromePageDestroyOptions {\n closeTab?: boolean; // should close the tab when the page object is destroyed\n}\n\nexport abstract class AbstractWebPage extends AbstractInterface {\n readonly keyboardTypeDelay?: number;\n readonly inputStrategy?: InputStrategy;\n navigate?(url: string): Promise<void>;\n reload?(): Promise<void>;\n goBack?(): Promise<void>;\n goForward?(): Promise<void>;\n stopLoading?(): Promise<void>;\n navigationState?(): Promise<{ isLoading: boolean }>;\n flushPendingVisualUpdate?(force?: boolean): Promise<void>;\n schedulePendingVisualUpdate?(force?: boolean): void;\n waitForDomQuiet?(opts?: {\n quietMs?: number;\n timeoutMs?: number;\n target?: ElementInfo;\n }): Promise<void>;\n\n get mouse(): MouseAction {\n return {\n click: async (\n x: number,\n y: number,\n options: { button: MouseButton },\n ) => {},\n wheel: async (deltaX: number, deltaY: number) => {},\n move: async (x: number, y: number) => {},\n drag: async (\n from: { x: number; y: number },\n to: { x: number; y: number },\n ) => {},\n };\n }\n\n get keyboard(): KeyboardAction {\n return {\n type: async (text: string, options?: { delay?: number }) => {},\n insertText: async (text: string) => {},\n press: async (\n action:\n | { key: KeyInput; command?: string }\n | { key: KeyInput; command?: string }[],\n ) => {},\n };\n }\n\n async clearInput(element?: ElementInfo): Promise<void> {}\n\n async selectAllInput(element?: ElementInfo): Promise<void> {\n throw new Error('Bulk text input is not supported by this web page');\n }\n\n abstract scrollUntilTop(startingPoint?: Point): Promise<void>;\n abstract scrollUntilBottom(startingPoint?: Point): Promise<void>;\n abstract scrollUntilLeft(startingPoint?: Point): Promise<void>;\n abstract scrollUntilRight(startingPoint?: Point): Promise<void>;\n abstract scrollUp(distance?: number, startingPoint?: Point): Promise<void>;\n abstract scrollDown(distance?: number, startingPoint?: Point): Promise<void>;\n abstract scrollLeft(distance?: number, startingPoint?: Point): Promise<void>;\n abstract scrollRight(distance?: number, startingPoint?: Point): Promise<void>;\n abstract longPress(x: number, y: number, duration?: number): Promise<void>;\n abstract swipe(\n from: { x: number; y: number },\n to: { x: number; y: number },\n duration?: number,\n ): Promise<void>;\n abstract pinch(\n centerX: number,\n centerY: number,\n startDistance: number,\n endDistance: number,\n duration?: number,\n ): Promise<void>;\n}\n\nconst scheduleWebVisualUpdate = (\n page: AbstractWebPage,\n force = false,\n): void => {\n if (page.schedulePendingVisualUpdate) {\n if (force) {\n page.schedulePendingVisualUpdate(true);\n } else {\n page.schedulePendingVisualUpdate();\n }\n return;\n }\n\n const pendingRefresh = force\n ? page.flushPendingVisualUpdate?.(true)\n : page.flushPendingVisualUpdate?.();\n void pendingRefresh?.catch(() => undefined);\n};\n\nexport function createWebInputPrimitives(\n page: AbstractWebPage,\n): BrowserInputPrimitives {\n const scheduleVisualUpdate = () => scheduleWebVisualUpdate(page);\n\n return {\n pointer: {\n tap: async ({ x, y }) => {\n await page.mouse.click(x, y, { button: 'left' });\n scheduleVisualUpdate();\n },\n rightClick: async ({ x, y }) => {\n await page.mouse.click(x, y, { button: 'right' });\n scheduleVisualUpdate();\n },\n doubleClick: async ({ x, y }) => {\n await page.mouse.click(x, y, { button: 'left', count: 2 });\n scheduleVisualUpdate();\n },\n hover: async ({ x, y }) => {\n await page.mouse.move(x, y);\n scheduleVisualUpdate();\n },\n dragAndDrop: async (from, to) => {\n await page.mouse.drag(from, to);\n scheduleVisualUpdate();\n },\n longPress: async ({ x, y }, opts) => {\n await page.longPress(x, y, opts?.duration);\n scheduleVisualUpdate();\n },\n },\n keyboard: {\n typeText: async (value, opts) => {\n const element = opts?.target;\n const { inputStrategy, keyboardTypeDelay } = resolveTextInputOptions(\n opts,\n page,\n );\n if (element && opts?.replace !== false) {\n if (inputStrategy === 'bulk') {\n // Keep the current value selected so insertText replaces it in one\n // input operation instead of emitting a separate empty value.\n await page.selectAllInput(element as ElementInfo);\n } else {\n await page.clearInput(element as ElementInfo);\n // Frameworks (React/Vue/etc.) often re-render in response to\n // the `input` event fired by clearing. If that re-render lands\n // between clearInput returning and the first typed character,\n // the keypresses can be dropped. Wait for the DOM to settle\n // before starting to type.\n await page.waitForDomQuiet?.({ target: element as ElementInfo });\n }\n } else if (element && opts?.focusOnly) {\n const target = element as ElementInfo;\n await page.mouse.click(target.center[0], target.center[1], {\n button: 'left',\n });\n await page.keyboard.press([{ key: 'End' }]);\n }\n\n if (opts?.focusOnly) {\n return;\n }\n\n if (inputStrategy === 'bulk') {\n await page.keyboard.insertText(value);\n } else if (inputStrategy === 'sequential') {\n await sendTextSequentially(\n value,\n {\n // The shared loop owns the inter-character delay. Explicitly\n // disable the page default so action-level zero remains\n // effective and positive delays are not applied twice.\n sendCharacter: (character) =>\n page.keyboard.type(character, { delay: 0 }),\n wait: sleep,\n },\n { delayMs: keyboardTypeDelay },\n );\n } else {\n const keyboardTypeOptions =\n keyboardTypeDelay === undefined\n ? undefined\n : { delay: keyboardTypeDelay };\n await page.keyboard.type(value, keyboardTypeOptions);\n }\n scheduleVisualUpdate();\n },\n keyboardPress: async (keyName, opts) => {\n const element = opts?.target as\n | { center: [number, number] }\n | undefined;\n if (element) {\n await page.mouse.click(element.center[0], element.center[1], {\n button: 'left',\n });\n }\n\n const keys = getKeyCommands(keyName);\n await page.keyboard.press(keys as any);\n scheduleVisualUpdate();\n },\n cursorMove: async (direction, times = 1) => {\n const arrowKey = direction === 'left' ? 'ArrowLeft' : 'ArrowRight';\n for (let i = 0; i < times; i++) {\n await page.keyboard.press([{ key: arrowKey as any }]);\n await sleep(100);\n }\n },\n clearInput: async (target) => {\n await page.clearInput(target as ElementInfo | undefined);\n },\n },\n touch: {\n pinch: async ({ x, y }, opts) => {\n await page.pinch(\n x,\n y,\n opts.startDistance,\n opts.endDistance,\n opts.duration,\n );\n },\n swipe: async (from, to, opts) => {\n await page.swipe(from, to, opts?.duration);\n },\n },\n scroll: {\n scroll: async (param) => {\n const element = param.locate;\n const startingPoint = element\n ? {\n left: element.center[0],\n top: element.center[1],\n }\n : undefined;\n const scrollToEventName = param?.scrollType;\n if (scrollToEventName === 'scrollToTop') {\n await page.scrollUntilTop(startingPoint);\n } else if (scrollToEventName === 'scrollToBottom') {\n await page.scrollUntilBottom(startingPoint);\n } else if (scrollToEventName === 'scrollToRight') {\n await page.scrollUntilRight(startingPoint);\n } else if (scrollToEventName === 'scrollToLeft') {\n await page.scrollUntilLeft(startingPoint);\n } else if (scrollToEventName === 'singleAction' || !scrollToEventName) {\n if (param?.direction === 'down' || !param || !param.direction) {\n await page.scrollDown(param?.distance || undefined, startingPoint);\n } else if (param.direction === 'up') {\n await page.scrollUp(param.distance || undefined, startingPoint);\n } else if (param.direction === 'left') {\n await page.scrollLeft(param.distance || undefined, startingPoint);\n } else if (param.direction === 'right') {\n await page.scrollRight(param.distance || undefined, startingPoint);\n } else {\n throw new Error(`Unknown scroll direction: ${param.direction}`);\n }\n await sleep(500);\n } else {\n throw new Error(\n `Unknown scroll event type: ${scrollToEventName}, param: ${JSON.stringify(\n param,\n )}`,\n );\n }\n scheduleVisualUpdate();\n },\n },\n };\n}\n\nexport const commonWebActionsForWebPage = <T extends AbstractWebPage>(\n page: T,\n includeTouchEvents = false,\n): DeviceAction<any>[] => {\n const input = createWebInputPrimitives(page);\n return [\n ...defineActionsFromInputPrimitives(input, {\n size: () => page.size(),\n includeSwipe: includeTouchEvents,\n }),\n\n defineAction<typeof navigateParamSchema, { url: string }>({\n name: 'Navigate',\n description:\n 'Navigate the browser to a specified URL. Opens the URL in the current tab.',\n paramSchema: navigateParamSchema,\n sample: {\n url: 'https://www.example.com',\n },\n call: async (param) => {\n if (!page.navigate) {\n throw new Error(\n 'Navigate operation is not supported on this page type',\n );\n }\n await page.navigate(param.url);\n scheduleWebVisualUpdate(page, true);\n },\n }),\n\n defineAction({\n name: 'Reload',\n supportedBySystemOne: true,\n description: 'Reload the current page',\n call: async () => {\n if (!page.reload) {\n throw new Error(\n 'Reload operation is not supported on this page type',\n );\n }\n await page.reload();\n scheduleWebVisualUpdate(page, true);\n },\n }),\n\n defineAction({\n name: 'GoBack',\n supportedBySystemOne: true,\n description: 'Navigate back in browser history',\n call: async () => {\n if (!page.goBack) {\n throw new Error(\n 'GoBack operation is not supported on this page type',\n );\n }\n await page.goBack();\n scheduleWebVisualUpdate(page, true);\n },\n }),\n defineAction({\n name: 'GoForward',\n supportedBySystemOne: true,\n description: 'Navigate forward in browser history',\n call: async () => {\n if (!page.goForward) {\n throw new Error(\n 'GoForward operation is not supported on this page type',\n );\n }\n await page.goForward();\n scheduleWebVisualUpdate(page, true);\n },\n }),\n ];\n};\n"],"names":["navigateParamSchema","z","normalizeKeyInputs","value","inputs","Array","result","input","trimmed","normalized","transformed","transformHotkeyInput","getKeyCommands","keys","acc","k","includeMeta","AbstractWebPage","AbstractInterface","x","y","options","deltaX","deltaY","from","to","text","action","element","Error","scheduleWebVisualUpdate","page","force","pendingRefresh","undefined","createWebInputPrimitives","scheduleVisualUpdate","opts","inputStrategy","keyboardTypeDelay","resolveTextInputOptions","target","sendTextSequentially","character","sleep","keyboardTypeOptions","keyName","direction","times","arrowKey","i","param","startingPoint","scrollToEventName","JSON","commonWebActionsForWebPage","includeTouchEvents","defineActionsFromInputPrimitives","defineAction"],"mappings":";;;;;;;;;;;;;;AAiBA,MAAMA,sBAAsBC,EAAE,MAAM,CAAC;IACnC,KAAKA,EAAAA,MACI,GACN,QAAQ,CACP;AAEN;AAEA,SAASC,mBAAmBC,KAAwB;IAClD,MAAMC,SAASC,MAAM,OAAO,CAACF,SAASA,QAAQ;QAACA;KAAM;IACrD,MAAMG,SAAmB,EAAE;IAE3B,KAAK,MAAMC,SAASH,OAAQ;QAC1B,IAAI,AAAiB,YAAjB,OAAOG,OAAoB;YAC7BD,OAAO,IAAI,CAACC;YACZ;QACF;QAEA,MAAMC,UAAUD,MAAM,IAAI;QAC1B,IAAI,CAACC,SAAS;YACZF,OAAO,IAAI,CAACC;YACZ;QACF;QAEA,IAAIE,aAAaD;QACjB,IAAIC,WAAW,MAAM,GAAG,KAAKA,WAAW,QAAQ,CAAC,MAC/CA,aAAaA,WAAW,OAAO,CAAC,aAAa;QAE/C,IAAI,KAAK,IAAI,CAACA,aACZA,aAAaA,WAAW,OAAO,CAAC,QAAQ;QAG1C,MAAMC,cAAcC,qBAAqBF;QACzC,IAAIC,AAAuB,MAAvBA,YAAY,MAAM,IAAUA,AAAmB,OAAnBA,WAAW,CAAC,EAAE,IAAWF,AAAY,OAAZA,SAAgB;YACvEF,OAAO,IAAI,CAACC;YACZ;QACF;QACA,IAAIG,AAAuB,MAAvBA,YAAY,MAAM,EAAQ;YAC5BJ,OAAO,IAAI,CAACC;YACZ;QACF;QAEAD,OAAO,IAAI,IAAII;IACjB;IAEA,OAAOJ;AACT;AAEO,SAASM,eACdT,KAAwB;IAExB,MAAMU,OAAOX,mBAAmBC;IAEhC,OAAOU,KAAK,MAAM,CAAC,CAACC,KAA+CC;QACjE,MAAMC,cA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BACJ,IAAI,CAAC3B,KAAK,SAAS,EACjB,MAAM,IAAIF,MACR;gBAGJ,MAAME,KAAK,SAAS;gBACpBD,wBAAwBC,MAAM;YAChC;QACF;KACD;AACH"}
1
+ {"version":3,"file":"web-page.mjs","sources":["../../src/web-page.ts"],"sourcesContent":["import type { Point } from '@midscene/core';\nimport { z } from '@midscene/core';\nimport {\n AbstractInterface,\n type BrowserInputPrimitives,\n type DeviceAction,\n type InputStrategy,\n defineAction,\n defineActionsFromInputPrimitives,\n resolveTextInputOptions,\n sendTextSequentially,\n} from '@midscene/core/device';\n\nimport { sleep } from '@midscene/core/utils';\nimport type { ElementInfo } from '@midscene/shared/extractor';\nimport { transformHotkeyInput } from '@midscene/shared/us-keyboard-layout';\n\nconst navigateParamSchema = z.object({\n url: z\n .string()\n .describe(\n 'The URL to navigate to. Must start with https://, file://, or a similar protocol.',\n ),\n});\n\nfunction normalizeKeyInputs(value: string | string[]): string[] {\n const inputs = Array.isArray(value) ? value : [value];\n const result: string[] = [];\n\n for (const input of inputs) {\n if (typeof input !== 'string') {\n result.push(input as unknown as string);\n continue;\n }\n\n const trimmed = input.trim();\n if (!trimmed) {\n result.push(input);\n continue;\n }\n\n let normalized = trimmed;\n if (normalized.length > 1 && normalized.includes('+')) {\n normalized = normalized.replace(/\\s*\\+\\s*/g, ' ');\n }\n if (/\\s/.test(normalized)) {\n normalized = normalized.replace(/\\s+/g, ' ');\n }\n\n const transformed = transformHotkeyInput(normalized);\n if (transformed.length === 1 && transformed[0] === '' && trimmed !== '') {\n result.push(input);\n continue;\n }\n if (transformed.length === 0) {\n result.push(input);\n continue;\n }\n\n result.push(...transformed);\n }\n\n return result;\n}\n\nexport function getKeyCommands(\n value: string | string[],\n): Array<{ key: string; command?: string }> {\n const keys = normalizeKeyInputs(value);\n\n return keys.reduce((acc: Array<{ key: string; command?: string }>, k) => {\n const includeMeta = keys.includes('Meta') || keys.includes('Control');\n if (includeMeta && (k === 'a' || k === 'A')) {\n return acc.concat([{ key: k, command: 'SelectAll' }]);\n }\n if (includeMeta && (k === 'c' || k === 'C')) {\n return acc.concat([{ key: k, command: 'Copy' }]);\n }\n if (includeMeta && (k === 'v' || k === 'V')) {\n return acc.concat([{ key: k, command: 'Paste' }]);\n }\n return acc.concat([{ key: k }]);\n }, []);\n}\n\n// this is copied from puppeteer, but we don't want to import puppeteer here\nexport declare type KeyInput =\n | '0'\n | '1'\n | '2'\n | '3'\n | '4'\n | '5'\n | '6'\n | '7'\n | '8'\n | '9'\n | 'Power'\n | 'Eject'\n | 'Abort'\n | 'Help'\n | 'Backspace'\n | 'Tab'\n | 'Numpad5'\n | 'NumpadEnter'\n | 'Enter'\n | '\\r'\n | '\\n'\n | 'ShiftLeft'\n | 'ShiftRight'\n | 'ControlLeft'\n | 'ControlRight'\n | 'AltLeft'\n | 'AltRight'\n | 'Pause'\n | 'CapsLock'\n | 'Escape'\n | 'Convert'\n | 'NonConvert'\n | 'Space'\n | 'Numpad9'\n | 'PageUp'\n | 'Numpad3'\n | 'PageDown'\n | 'End'\n | 'Numpad1'\n | 'Home'\n | 'Numpad7'\n | 'ArrowLeft'\n | 'Numpad4'\n | 'Numpad8'\n | 'ArrowUp'\n | 'ArrowRight'\n | 'Numpad6'\n | 'Numpad2'\n | 'ArrowDown'\n | 'Select'\n | 'Open'\n | 'PrintScreen'\n | 'Insert'\n | 'Numpad0'\n | 'Delete'\n | 'NumpadDecimal'\n | 'Digit0'\n | 'Digit1'\n | 'Digit2'\n | 'Digit3'\n | 'Digit4'\n | 'Digit5'\n | 'Digit6'\n | 'Digit7'\n | 'Digit8'\n | 'Digit9'\n | 'KeyA'\n | 'KeyB'\n | 'KeyC'\n | 'KeyD'\n | 'KeyE'\n | 'KeyF'\n | 'KeyG'\n | 'KeyH'\n | 'KeyI'\n | 'KeyJ'\n | 'KeyK'\n | 'KeyL'\n | 'KeyM'\n | 'KeyN'\n | 'KeyO'\n | 'KeyP'\n | 'KeyQ'\n | 'KeyR'\n | 'KeyS'\n | 'KeyT'\n | 'KeyU'\n | 'KeyV'\n | 'KeyW'\n | 'KeyX'\n | 'KeyY'\n | 'KeyZ'\n | 'MetaLeft'\n | 'MetaRight'\n | 'ContextMenu'\n | 'NumpadMultiply'\n | 'NumpadAdd'\n | 'NumpadSubtract'\n | 'NumpadDivide'\n | 'F1'\n | 'F2'\n | 'F3'\n | 'F4'\n | 'F5'\n | 'F6'\n | 'F7'\n | 'F8'\n | 'F9'\n | 'F10'\n | 'F11'\n | 'F12'\n | 'F13'\n | 'F14'\n | 'F15'\n | 'F16'\n | 'F17'\n | 'F18'\n | 'F19'\n | 'F20'\n | 'F21'\n | 'F22'\n | 'F23'\n | 'F24'\n | 'NumLock'\n | 'ScrollLock'\n | 'AudioVolumeMute'\n | 'AudioVolumeDown'\n | 'AudioVolumeUp'\n | 'MediaTrackNext'\n | 'MediaTrackPrevious'\n | 'MediaStop'\n | 'MediaPlayPause'\n | 'Semicolon'\n | 'Equal'\n | 'NumpadEqual'\n | 'Comma'\n | 'Minus'\n | 'Period'\n | 'Slash'\n | 'Backquote'\n | 'BracketLeft'\n | 'Backslash'\n | 'BracketRight'\n | 'Quote'\n | 'AltGraph'\n | 'Props'\n | 'Cancel'\n | 'Clear'\n | 'Shift'\n | 'Control'\n | 'Alt'\n | 'Accept'\n | 'ModeChange'\n | ' '\n | 'Print'\n | 'Execute'\n | '\\u0000'\n | 'a'\n | 'b'\n | 'c'\n | 'd'\n | 'e'\n | 'f'\n | 'g'\n | 'h'\n | 'i'\n | 'j'\n | 'k'\n | 'l'\n | 'm'\n | 'n'\n | 'o'\n | 'p'\n | 'q'\n | 'r'\n | 's'\n | 't'\n | 'u'\n | 'v'\n | 'w'\n | 'x'\n | 'y'\n | 'z'\n | 'Meta'\n | '*'\n | '+'\n | '-'\n | '/'\n | ';'\n | '='\n | ','\n | '.'\n | '`'\n | '['\n | '\\\\'\n | ']'\n | \"'\"\n | 'Attn'\n | 'CrSel'\n | 'ExSel'\n | 'EraseEof'\n | 'Play'\n | 'ZoomOut'\n | ')'\n | '!'\n | '@'\n | '#'\n | '$'\n | '%'\n | '^'\n | '&'\n | '('\n | 'A'\n | 'B'\n | 'C'\n | 'D'\n | 'E'\n | 'F'\n | 'G'\n | 'H'\n | 'I'\n | 'J'\n | 'K'\n | 'L'\n | 'M'\n | 'N'\n | 'O'\n | 'P'\n | 'Q'\n | 'R'\n | 'S'\n | 'T'\n | 'U'\n | 'V'\n | 'W'\n | 'X'\n | 'Y'\n | 'Z'\n | ':'\n | '<'\n | '_'\n | '>'\n | '?'\n | '~'\n | '{'\n | '|'\n | '}'\n | '\"'\n | 'SoftLeft'\n | 'SoftRight'\n | 'Camera'\n | 'Call'\n | 'EndCall'\n | 'VolumeDown'\n | 'VolumeUp';\n\nexport type MouseButton = 'left' | 'right' | 'middle';\n\nexport interface MouseAction {\n click: (\n x: number,\n y: number,\n options: { button: MouseButton; count?: number },\n ) => Promise<void>;\n wheel: (deltaX: number, deltaY: number) => Promise<void>;\n move: (x: number, y: number) => Promise<void>;\n drag: (\n from: { x: number; y: number },\n to: { x: number; y: number },\n ) => Promise<void>;\n}\n\nexport interface KeyboardAction {\n type: (text: string, options?: { delay?: number }) => Promise<void>;\n insertText: (text: string) => Promise<void>;\n press: (\n action:\n | { key: KeyInput; command?: string }\n | { key: KeyInput; command?: string }[],\n ) => Promise<void>;\n}\n\nexport interface ChromePageDestroyOptions {\n closeTab?: boolean; // should close the tab when the page object is destroyed\n}\n\nexport abstract class AbstractWebPage extends AbstractInterface {\n readonly keyboardTypeDelay?: number;\n readonly inputStrategy?: InputStrategy;\n navigate?(url: string): Promise<void>;\n reload?(): Promise<void>;\n goBack?(): Promise<void>;\n goForward?(): Promise<void>;\n stopLoading?(): Promise<void>;\n navigationState?(): Promise<{ isLoading: boolean }>;\n flushPendingVisualUpdate?(force?: boolean): Promise<void>;\n schedulePendingVisualUpdate?(force?: boolean): void;\n waitForDomQuiet?(opts?: {\n quietMs?: number;\n timeoutMs?: number;\n target?: ElementInfo;\n }): Promise<void>;\n\n get mouse(): MouseAction {\n return {\n click: async (\n x: number,\n y: number,\n options: { button: MouseButton },\n ) => {},\n wheel: async (deltaX: number, deltaY: number) => {},\n move: async (x: number, y: number) => {},\n drag: async (\n from: { x: number; y: number },\n to: { x: number; y: number },\n ) => {},\n };\n }\n\n get keyboard(): KeyboardAction {\n return {\n type: async (text: string, options?: { delay?: number }) => {},\n insertText: async (text: string) => {},\n press: async (\n action:\n | { key: KeyInput; command?: string }\n | { key: KeyInput; command?: string }[],\n ) => {},\n };\n }\n\n async clearInput(element?: ElementInfo): Promise<void> {}\n\n async selectAllInput(element?: ElementInfo): Promise<void> {\n throw new Error('Bulk text input is not supported by this web page');\n }\n\n abstract scrollUntilTop(startingPoint?: Point): Promise<void>;\n abstract scrollUntilBottom(startingPoint?: Point): Promise<void>;\n abstract scrollUntilLeft(startingPoint?: Point): Promise<void>;\n abstract scrollUntilRight(startingPoint?: Point): Promise<void>;\n abstract scrollUp(distance?: number, startingPoint?: Point): Promise<void>;\n abstract scrollDown(distance?: number, startingPoint?: Point): Promise<void>;\n abstract scrollLeft(distance?: number, startingPoint?: Point): Promise<void>;\n abstract scrollRight(distance?: number, startingPoint?: Point): Promise<void>;\n abstract longPress(x: number, y: number, duration?: number): Promise<void>;\n abstract swipe(\n from: { x: number; y: number },\n to: { x: number; y: number },\n duration?: number,\n ): Promise<void>;\n abstract pinch(\n centerX: number,\n centerY: number,\n startDistance: number,\n endDistance: number,\n duration?: number,\n ): Promise<void>;\n}\n\nconst scheduleWebVisualUpdate = (\n page: AbstractWebPage,\n force = false,\n): void => {\n if (page.schedulePendingVisualUpdate) {\n if (force) {\n page.schedulePendingVisualUpdate(true);\n } else {\n page.schedulePendingVisualUpdate();\n }\n return;\n }\n\n const pendingRefresh = force\n ? page.flushPendingVisualUpdate?.(true)\n : page.flushPendingVisualUpdate?.();\n void pendingRefresh?.catch(() => undefined);\n};\n\nexport function createWebInputPrimitives(\n page: AbstractWebPage,\n): BrowserInputPrimitives {\n const scheduleVisualUpdate = () => scheduleWebVisualUpdate(page);\n\n return {\n pointer: {\n tap: async ({ x, y }) => {\n await page.mouse.click(x, y, { button: 'left' });\n scheduleVisualUpdate();\n },\n middleClick: async ({ x, y }) => {\n await page.mouse.click(x, y, { button: 'middle' });\n scheduleVisualUpdate();\n },\n rightClick: async ({ x, y }) => {\n await page.mouse.click(x, y, { button: 'right' });\n scheduleVisualUpdate();\n },\n doubleClick: async ({ x, y }) => {\n await page.mouse.click(x, y, { button: 'left', count: 2 });\n scheduleVisualUpdate();\n },\n hover: async ({ x, y }) => {\n await page.mouse.move(x, y);\n scheduleVisualUpdate();\n },\n dragAndDrop: async (from, to) => {\n await page.mouse.drag(from, to);\n scheduleVisualUpdate();\n },\n longPress: async ({ x, y }, opts) => {\n await page.longPress(x, y, opts?.duration);\n scheduleVisualUpdate();\n },\n },\n keyboard: {\n typeText: async (value, opts) => {\n const element = opts?.target;\n const { inputStrategy, keyboardTypeDelay } = resolveTextInputOptions(\n opts,\n page,\n );\n if (element && opts?.replace !== false) {\n if (inputStrategy === 'bulk') {\n // Keep the current value selected so insertText replaces it in one\n // input operation instead of emitting a separate empty value.\n await page.selectAllInput(element as ElementInfo);\n } else {\n await page.clearInput(element as ElementInfo);\n // Frameworks (React/Vue/etc.) often re-render in response to\n // the `input` event fired by clearing. If that re-render lands\n // between clearInput returning and the first typed character,\n // the keypresses can be dropped. Wait for the DOM to settle\n // before starting to type.\n await page.waitForDomQuiet?.({ target: element as ElementInfo });\n }\n } else if (element && opts?.focusOnly) {\n const target = element as ElementInfo;\n await page.mouse.click(target.center[0], target.center[1], {\n button: 'left',\n });\n await page.keyboard.press([{ key: 'End' }]);\n } else if (!element && opts?.replace !== false && !opts?.focusOnly) {\n // Replace within the current focus without a preliminary click or\n // a separate empty input event that could trigger an autosave.\n await page.selectAllInput();\n }\n\n if (opts?.focusOnly) {\n return;\n }\n\n if (inputStrategy === 'bulk') {\n await page.keyboard.insertText(value);\n } else if (inputStrategy === 'sequential') {\n await sendTextSequentially(\n value,\n {\n // The shared loop owns the inter-character delay. Explicitly\n // disable the page default so action-level zero remains\n // effective and positive delays are not applied twice.\n sendCharacter: (character) =>\n page.keyboard.type(character, { delay: 0 }),\n wait: sleep,\n },\n { delayMs: keyboardTypeDelay },\n );\n } else {\n const keyboardTypeOptions =\n keyboardTypeDelay === undefined\n ? undefined\n : { delay: keyboardTypeDelay };\n await page.keyboard.type(value, keyboardTypeOptions);\n }\n scheduleVisualUpdate();\n },\n keyboardPress: async (keyName, opts) => {\n const element = opts?.target as\n | { center: [number, number] }\n | undefined;\n if (element) {\n await page.mouse.click(element.center[0], element.center[1], {\n button: 'left',\n });\n }\n\n const keys = getKeyCommands(keyName);\n await page.keyboard.press(keys as any);\n scheduleVisualUpdate();\n },\n cursorMove: async (direction, times = 1) => {\n const arrowKey = direction === 'left' ? 'ArrowLeft' : 'ArrowRight';\n for (let i = 0; i < times; i++) {\n await page.keyboard.press([{ key: arrowKey as any }]);\n await sleep(100);\n }\n },\n clearInput: async (target) => {\n await page.clearInput(target as ElementInfo | undefined);\n },\n },\n touch: {\n pinch: async ({ x, y }, opts) => {\n await page.pinch(\n x,\n y,\n opts.startDistance,\n opts.endDistance,\n opts.duration,\n );\n },\n swipe: async (from, to, opts) => {\n await page.swipe(from, to, opts?.duration);\n },\n },\n scroll: {\n scroll: async (param) => {\n const element = param.locate;\n const startingPoint = element\n ? {\n left: element.center[0],\n top: element.center[1],\n }\n : undefined;\n const scrollToEventName = param?.scrollType;\n if (scrollToEventName === 'scrollToTop') {\n await page.scrollUntilTop(startingPoint);\n } else if (scrollToEventName === 'scrollToBottom') {\n await page.scrollUntilBottom(startingPoint);\n } else if (scrollToEventName === 'scrollToRight') {\n await page.scrollUntilRight(startingPoint);\n } else if (scrollToEventName === 'scrollToLeft') {\n await page.scrollUntilLeft(startingPoint);\n } else if (scrollToEventName === 'singleAction' || !scrollToEventName) {\n if (param?.direction === 'down' || !param || !param.direction) {\n await page.scrollDown(param?.distance || undefined, startingPoint);\n } else if (param.direction === 'up') {\n await page.scrollUp(param.distance || undefined, startingPoint);\n } else if (param.direction === 'left') {\n await page.scrollLeft(param.distance || undefined, startingPoint);\n } else if (param.direction === 'right') {\n await page.scrollRight(param.distance || undefined, startingPoint);\n } else {\n throw new Error(`Unknown scroll direction: ${param.direction}`);\n }\n await sleep(500);\n } else {\n throw new Error(\n `Unknown scroll event type: ${scrollToEventName}, param: ${JSON.stringify(\n param,\n )}`,\n );\n }\n scheduleVisualUpdate();\n },\n },\n };\n}\n\nexport const commonWebActionsForWebPage = <T extends AbstractWebPage>(\n page: T,\n includeTouchEvents = false,\n): DeviceAction<any>[] => {\n const input = createWebInputPrimitives(page);\n return [\n ...defineActionsFromInputPrimitives(input, {\n size: () => page.size(),\n includeSwipe: includeTouchEvents,\n }),\n\n defineAction<typeof navigateParamSchema, { url: string }>({\n name: 'Navigate',\n description:\n 'Navigate the browser to a specified URL. Opens the URL in the current tab.',\n paramSchema: navigateParamSchema,\n sample: {\n url: 'https://www.example.com',\n },\n call: async (param) => {\n if (!page.navigate) {\n throw new Error(\n 'Navigate operation is not supported on this page type',\n );\n }\n await page.navigate(param.url);\n scheduleWebVisualUpdate(page, true);\n },\n }),\n\n defineAction({\n name: 'Reload',\n supportedBySystemOne: true,\n description: 'Reload the current page',\n call: async () => {\n if (!page.reload) {\n throw new Error(\n 'Reload operation is not supported on this page type',\n );\n }\n await page.reload();\n scheduleWebVisualUpdate(page, true);\n },\n }),\n\n defineAction({\n name: 'GoBack',\n supportedBySystemOne: true,\n description: 'Navigate back in browser history',\n call: async () => {\n if (!page.goBack) {\n throw new Error(\n 'GoBack operation is not supported on this page type',\n );\n }\n await page.goBack();\n scheduleWebVisualUpdate(page, true);\n },\n }),\n defineAction({\n name: 'GoForward',\n supportedBySystemOne: true,\n description: 'Navigate forward in browser history',\n call: async () => {\n if (!page.goForward) {\n throw new Error(\n 'GoForward operation is not supported on this page type',\n );\n }\n await page.goForward();\n scheduleWebVisualUpdate(page, true);\n },\n }),\n ];\n};\n"],"names":["navigateParamSchema","z","normalizeKeyInputs","value","inputs","Array","result","input","trimmed","normalized","transformed","transformHotkeyInput","getKeyCommands","keys","acc","k","includeMeta","AbstractWebPage","AbstractInterface","x","y","options","deltaX","deltaY","from","to","text","action","element","Error","scheduleWebVisualUpdate","page","force","pendingRefresh","undefined","createWebInputPrimitives","scheduleVisualUpdate","opts","inputStrategy","keyboardTypeDelay","resolveTextInputOptions","target","sendTextSequentially","character","sleep","keyboardTypeOptions","keyName","direction","times","arrowKey","i","param","startingPoint","scrollToEventName","JSON","commonWebActionsForWebPage","includeTouchEvents","defineActionsFromInputPrimitives","defineAction"],"mappings":";;;;;;;;;;;;;;AAiBA,MAAMA,sBAAsBC,EAAE,MAAM,CAAC;IACnC,KAAKA,EAAAA,MACI,GACN,QAAQ,CACP;AAEN;AAEA,SAASC,mBAAmBC,KAAwB;IAClD,MAAMC,SAASC,MAAM,OAAO,CAACF,SAASA,QAAQ;QAACA;KAAM;IACrD,MAAMG,SAAmB,EAAE;IAE3B,KAAK,MAAMC,SAASH,OAAQ;QAC1B,IAAI,AAAiB,YAAjB,OAAOG,OAAoB;YAC7BD,OAAO,IAAI,CAACC;YACZ;QACF;QAEA,MAAMC,UAAUD,MAAM,IAAI;QAC1B,IAAI,CAACC,SAAS;YACZF,OAAO,IAAI,CAACC;YACZ;QACF;QAEA,IAAIE,aAAaD;QACjB,IAAIC,WAAW,MAAM,GAAG,KAAKA,WAAW,QAAQ,CAAC,MAC/CA,aAAaA,WAAW,OAAO,CAAC,aAAa;QAE/C,IAAI,KAAK,IAAI,CAACA,aACZA,aAAaA,WAAW,OAAO,CAAC,QAAQ;QAG1C,MAAMC,cAAcC,qBAAqBF;QACzC,IAAIC,AAAuB,MAAvBA,YAAY,MAAM,IAAUA,AAAmB,OAAnBA,WAAW,CAAC,EAAE,IAAWF,AAAY,OAAZA,SAAgB;YACvEF,OAAO,IAAI,CAACC;YACZ;QACF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,QAAQ,CAACoB,MAAM,GAAG;gBAC7BrB,wBAAwBC,MAAM;YAChC;QACF;QAEA2B,aAAa;YACX,MAAM;YACN,sBAAsB;YACtB,aAAa;YACb,MAAM;gBACJ,IAAI,CAAC3B,KAAK,MAAM,EACd,MAAM,IAAIF,MACR;gBAGJ,MAAME,KAAK,MAAM;gBACjBD,wBAAwBC,MAAM;YAChC;QACF;QAEA2B,aAAa;YACX,MAAM;YACN,sBAAsB;YACtB,aAAa;YACb,MAAM;gBACJ,IAAI,CAAC3B,KAAK,MAAM,EACd,MAAM,IAAIF,MACR;gBAGJ,MAAME,KAAK,MAAM;gBACjBD,wBAAwBC,MAAM;YAChC;QACF;QACA2B,aAAa;YACX,MAAM;YACN,sBAAsB;YACtB,aAAa;YACb,MAAM;gBACJ,IAAI,CAAC3B,KAAK,SAAS,EACjB,MAAM,IAAIF,MACR;gBAGJ,MAAME,KAAK,SAAS;gBACpBD,wBAAwBC,MAAM;YAChC;QACF;KACD;AACH"}
@@ -51,7 +51,7 @@ class BridgeClient {
51
51
  ]
52
52
  } : {},
53
53
  query: {
54
- version: "1.17.3"
54
+ version: "1.17.4"
55
55
  }
56
56
  });
57
57
  const timeout = setTimeout(()=>{
@@ -130,7 +130,7 @@ class BridgeServer {
130
130
  (0, shared_utils_namespaceObject.logMsg)('one client connected');
131
131
  this.socket = socket;
132
132
  const clientVersion = socket.handshake.query.version;
133
- (0, shared_utils_namespaceObject.logMsg)(`Bridge connected, cli-side version v1.17.3, browser-side version v${clientVersion}`);
133
+ (0, shared_utils_namespaceObject.logMsg)(`Bridge connected, cli-side version v1.17.4, browser-side version v${clientVersion}`);
134
134
  socket.on(external_common_js_namespaceObject.BridgeEvent.CallResponse, (params)=>{
135
135
  const id = params.id;
136
136
  const response = params.response;
@@ -154,7 +154,7 @@ class BridgeServer {
154
154
  setTimeout(()=>{
155
155
  this.onConnect?.();
156
156
  const payload = {
157
- version: "1.17.3"
157
+ version: "1.17.4"
158
158
  };
159
159
  socket.emit(external_common_js_namespaceObject.BridgeEvent.Connected, payload);
160
160
  Promise.resolve().then(()=>{
@@ -138,7 +138,7 @@ class ExtensionBridgePageBrowserSide extends page_js_default() {
138
138
  throw new Error('Connection denied by user');
139
139
  }
140
140
  }
141
- this.onLogMessage(`Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v1.17.3`, 'log');
141
+ this.onLogMessage(`Bridge connected, cli-side version v${this.bridgeClient.serverVersion}, browser-side version v1.17.4`, 'log');
142
142
  }
143
143
  async connect() {
144
144
  return await this.setupBridgeClient();
@@ -580,13 +580,13 @@ class ChromeExtensionProxyPage {
580
580
  });
581
581
  }
582
582
  async selectAllInput(element) {
583
- if (!element) throw new Error('Bulk replace input requires a target element');
584
- await this.mouse.click(element.center[0], element.center[1]);
583
+ if (element) await this.mouse.click(element.center[0], element.center[1]);
585
584
  const selectionResult = await this.sendCommandToDebugger('Runtime.evaluate', {
586
585
  expression: input_scripts_js_namespaceObject.selectAllInputScript,
587
586
  returnByValue: true
588
587
  });
589
588
  if (selectionResult?.result?.value === true) return;
589
+ if (!element) throw new Error('Replacing text requires a focused editable field');
590
590
  await this.sendCommandToDebugger('Input.dispatchKeyEvent', {
591
591
  type: 'keyDown',
592
592
  commands: [
@@ -1 +1 @@
1
- {"version":3,"file":"chrome-extension/page.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/chrome-extension/page.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/// <reference types=\"chrome\" />\n\n/*\n It is used to interact with the page tab from the chrome extension.\n The page must be active when interacting with it.\n*/\n\nimport { limitOpenNewTabScript } from '@/web-element';\nimport type {\n ElementCacheFeature,\n ElementTreeNode,\n Point,\n Rect,\n Size,\n} from '@midscene/core';\nimport type {\n AbstractInterface,\n DeviceAction,\n FileChooserHandler,\n FileChooserRegistration,\n TextInputOptions,\n} from '@midscene/core/device';\nimport type { ElementInfo } from '@midscene/shared/extractor';\nimport { treeToList } from '@midscene/shared/extractor';\nimport { createImgBase64ByFormat } from '@midscene/shared/img';\nimport { getDebug } from '@midscene/shared/logger';\nimport { assert } from '@midscene/shared/utils';\nimport type { Protocol as CDPTypes } from 'devtools-protocol';\nimport {\n type CacheFeatureOptions,\n type WebElementCacheFeature,\n buildRectFromElementInfo,\n judgeOrderSensitive,\n sanitizeXpaths,\n} from '../common/cache-helper';\nimport { selectAllInputScript } from '../common/input-scripts';\nimport {\n type KeyInput,\n type MouseButton,\n commonWebActionsForWebPage,\n} from '../web-page';\nimport { CdpKeyboard } from './cdpInput';\nimport {\n getHtmlElementScript,\n injectStopWaterFlowAnimation,\n injectWaterFlowAnimation,\n} from './dynamic-scripts';\n\nconst debug = getDebug('web:chrome-extension:page');\n\nfunction sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nconst NAVIGATION_COMPLETE_TIMEOUT_MS = 30_000;\n\nfunction isBlankUrl(url: string | undefined): boolean {\n if (!url) return true;\n return url === 'about:blank' || url.startsWith('chrome://newtab');\n}\n\n/**\n * Wait for the browser target to settle before sending CDP commands to it.\n *\n * A cross-origin redirect can replace the target after `tabs.update()`\n * resolves. Sending `Runtime.evaluate` during that hand-off intermittently\n * fails because Chrome has detached the debugger from the old target.\n */\nfunction waitForTabNavigationComplete(\n tabId: number,\n targetUrl: string,\n updatedTab?: chrome.tabs.Tab,\n timeoutMs = NAVIGATION_COMPLETE_TIMEOUT_MS,\n): Promise<void> {\n return new Promise((resolve) => {\n let settled = false;\n const finish = () => {\n if (settled) return;\n settled = true;\n chrome.tabs.onUpdated.removeListener(onUpdated);\n clearTimeout(timer);\n resolve();\n };\n\n const isTargetTab = (tab: chrome.tabs.Tab | undefined): boolean => {\n if (!tab) return false;\n return tab.url === targetUrl || tab.pendingUrl === targetUrl;\n };\n\n const isReady = (\n tab: chrome.tabs.Tab | undefined,\n navigationUpdateObserved: boolean,\n ): boolean => {\n if (!tab || tab.status !== 'complete') return false;\n const currentUrl = tab.url || tab.pendingUrl || '';\n const isExpectedUrlKind = isBlankUrl(targetUrl)\n ? isBlankUrl(currentUrl)\n : !isBlankUrl(currentUrl);\n return (\n isExpectedUrlKind && (navigationUpdateObserved || isTargetTab(tab))\n );\n };\n\n const onUpdated = (\n id: number,\n info: chrome.tabs.TabChangeInfo,\n tab: chrome.tabs.Tab,\n ) => {\n // This listener is registered after tabs.update(), so a completion\n // event received here belongs to the navigation we initiated.\n if (id === tabId && isReady(tab, info.status === 'complete')) finish();\n };\n\n chrome.tabs.onUpdated.addListener(onUpdated);\n const timer = setTimeout(finish, timeoutMs);\n\n // tabs.update() returns the updated target. A completed returned tab is\n // already a settled result of this navigation, including a fast redirect.\n if (isReady(updatedTab, true)) {\n finish();\n return;\n }\n\n // The tab may have completed before the listener was added. Only accept\n // the requested target here: a previous complete HTTPS page is not proof\n // that this navigation has settled.\n chrome.tabs\n .get(tabId)\n .then((tab) => {\n if (isReady(tab, false)) finish();\n })\n .catch(() => {});\n });\n}\n\nfunction hasFlatNodeAttribute(\n attributes: string[] | undefined,\n name: string,\n): boolean {\n if (!attributes) return false;\n for (let i = 0; i < attributes.length; i += 2) {\n if (attributes[i] === name) return true;\n }\n return false;\n}\n\nfunction serializeError(error: Error): {\n message: string;\n name?: string;\n stack?: string;\n} {\n return {\n message: error.message,\n name: error.name,\n stack: error.stack,\n };\n}\n\nexport default class ChromeExtensionProxyPage implements AbstractInterface {\n interfaceType = 'chrome-extension-proxy';\n\n public forceSameTabNavigation: boolean;\n\n readonly keyboardTypeDelay?: number;\n\n readonly inputStrategy?: TextInputOptions['inputStrategy'];\n\n private viewportSize?: Size;\n\n private activeTabId: number | null = null;\n\n private destroyed = false;\n\n private fileChooserEventHandler?: Parameters<\n typeof chrome.debugger.onEvent.addListener\n >[0];\n\n private fileChooserRegistrationVersion = 0;\n\n private bridgeFileChooserDispose?: () => void;\n\n private bridgeFileChooserGetError?: FileChooserRegistration['getError'];\n\n private isMobileEmulation: boolean | null = null;\n\n protected waterFlowAnimationEnabled = true;\n\n public _continueWhenFailedToAttachDebugger = false;\n\n constructor(\n forceSameTabNavigation: boolean,\n inputOptions?: TextInputOptions,\n ) {\n this.forceSameTabNavigation = forceSameTabNavigation;\n this.keyboardTypeDelay = inputOptions?.keyboardTypeDelay;\n this.inputStrategy = inputOptions?.inputStrategy;\n }\n\n actionSpace(): DeviceAction[] {\n return commonWebActionsForWebPage(this);\n }\n\n /**\n * Set the tab currently used by Midscene and optionally activate it in Chrome.\n */\n public async setActiveTabId(\n tabId: number,\n options: { activate?: boolean } = {},\n ) {\n if (this.activeTabId) {\n throw new Error(\n `Active tab id is already set, which is ${this.activeTabId}, cannot set it to ${tabId}`,\n );\n }\n if (options.activate !== false) {\n await chrome.tabs.update(tabId, { active: true });\n }\n this.activeTabId = tabId;\n }\n\n public async getActiveTabId() {\n return this.activeTabId;\n }\n\n /**\n * Get a list of current tabs\n * @returns {Promise<Array<{id: number, title: string, url: string}>>}\n */\n public async getBrowserTabList(): Promise<\n { id: string; title: string; url: string; currentActiveTab: boolean }[]\n > {\n const tabs = await chrome.tabs.query({ currentWindow: true });\n return tabs\n .map((tab) => ({\n id: `${tab.id}`,\n title: tab.title,\n url: tab.url,\n currentActiveTab: tab.active,\n }))\n .filter((tab) => tab.id && tab.title && tab.url) as {\n id: string;\n title: string;\n url: string;\n currentActiveTab: boolean;\n }[];\n }\n\n public async getTabIdOrConnectToCurrentTab() {\n if (this.activeTabId) {\n // Always reuse the controlled tab to avoid switching to a tab activated later by the user.\n return this.activeTabId;\n }\n const tabId = await chrome.tabs\n .query({ active: true, currentWindow: true })\n .then((tabs) => tabs[0]?.id);\n this.activeTabId = tabId || 0;\n return this.activeTabId;\n }\n\n /**\n * Ensure debugger is attached to the current tab.\n * Uses lazy attach pattern - only attaches when needed.\n */\n private async ensureDebuggerAttached() {\n assert(!this.destroyed, 'Page is destroyed');\n\n const url = await this.url();\n if (url.startsWith('chrome://')) {\n throw new Error(\n 'Cannot attach debugger to chrome:// pages, please use Midscene in a normal page with http://, https:// or file://',\n );\n }\n\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n\n try {\n await chrome.debugger.attach({ tabId }, '1.3');\n console.log('Debugger attached to tab:', tabId);\n } catch (error) {\n const errorMsg = (error as Error)?.message || '';\n // Already attached is OK, we can continue\n if (errorMsg.includes('Another debugger is already attached')) {\n console.log('Debugger already attached to tab:', tabId);\n return;\n }\n\n if (this._continueWhenFailedToAttachDebugger) {\n console.warn(\n 'Failed to attach debugger, but continuing due to _continueWhenFailedToAttachDebugger flag',\n error,\n );\n return;\n }\n\n throw error;\n }\n\n // Wait for debugger banner in Chrome to appear\n await sleep(500);\n\n // Enable water flow animation. Non-fatal: this is a purely visual\n // overlay, and Chrome can briefly detach the debugger between\n // attach() and the eval below (cross-origin navigation / Site\n // Isolation race). If we awaited it and it threw \"Debugger is not\n // attached\", the error would propagate out of the catch block in\n // sendCommandToDebugger, preventing the actual CDP command from\n // ever being retried. Fire-and-forget here so the lazy-attach\n // retry can succeed even when the animation fails.\n this.enableWaterFlowAnimation().catch((err) => {\n console.warn('Failed to enable water flow animation:', err);\n });\n }\n\n private async showMousePointer(x: number, y: number) {\n if (!this.waterFlowAnimationEnabled) return;\n\n // update mouse pointer while redirecting\n const pointerScript = `(() => {\n if(typeof window.midsceneWaterFlowAnimation !== 'undefined') {\n window.midsceneWaterFlowAnimation.enable();\n window.midsceneWaterFlowAnimation.showMousePointer(${x}, ${y});\n } else {\n console.log('midsceneWaterFlowAnimation is not defined');\n }\n })()`;\n\n await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `${pointerScript}`,\n });\n }\n\n private async hideMousePointer() {\n await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `(() => {\n if(typeof window.midsceneWaterFlowAnimation !== 'undefined') {\n window.midsceneWaterFlowAnimation.hideMousePointer();\n }\n })()`,\n });\n }\n\n /**\n * Public method to detach debugger without destroying the page instance.\n * Useful for error recovery scenarios where we want to remove the debugger banner\n * without completely destroying the page.\n */\n public async detachDebugger(tabId?: number) {\n const tabIdToDetach = tabId || (await this.getTabIdOrConnectToCurrentTab());\n console.log('detaching debugger from tab:', tabIdToDetach);\n\n try {\n await this.disableWaterFlowAnimation(tabIdToDetach);\n await sleep(200); // wait for the animation to stop\n } catch (error) {\n console.warn('Failed to disable water flow animation', error);\n }\n\n try {\n await chrome.debugger.detach({ tabId: tabIdToDetach });\n console.log('Debugger detached successfully from tab:', tabIdToDetach);\n } catch (error) {\n // Tab might be closed or debugger already detached - this is OK\n console.warn(\n 'Failed to detach debugger (may already be detached):',\n error,\n );\n }\n }\n\n private async enableWaterFlowAnimation() {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n\n // limit open page in new tab\n if (this.forceSameTabNavigation) {\n await chrome.debugger.sendCommand({ tabId }, 'Runtime.evaluate', {\n expression: limitOpenNewTabScript,\n });\n }\n\n if (!this.waterFlowAnimationEnabled) {\n return;\n }\n\n const script = await injectWaterFlowAnimation();\n // we will call this function in sendCommandToDebugger, so we have to use the chrome.debugger.sendCommand\n await chrome.debugger.sendCommand({ tabId }, 'Runtime.evaluate', {\n expression: script,\n });\n }\n\n private async disableWaterFlowAnimation(tabId: number) {\n const script = await injectStopWaterFlowAnimation();\n\n await chrome.debugger.sendCommand({ tabId }, 'Runtime.evaluate', {\n expression: script,\n });\n }\n\n public async setWaterFlowAnimationEnabled(enabled: boolean) {\n this.waterFlowAnimationEnabled = enabled;\n if (!enabled) {\n const script = await injectStopWaterFlowAnimation();\n await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: script,\n });\n }\n }\n\n /**\n * Returns the current water-flow animation enabled flag.\n */\n public getWaterFlowAnimationEnabled(): boolean {\n return this.waterFlowAnimationEnabled;\n }\n\n /**\n * Send a command to the debugger with automatic attach and retry on detachment.\n * Uses lazy attach pattern - will automatically attach if not already attached.\n */\n private async sendCommandToDebugger<ResponseType = any, RequestType = any>(\n command: string,\n params: RequestType,\n retryCount = 0,\n ): Promise<ResponseType> {\n const MAX_RETRIES = 2;\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n\n try {\n // Try to send command directly first\n const result = (await chrome.debugger.sendCommand(\n { tabId },\n command,\n params as any,\n )) as ResponseType;\n\n // Enable water flow animation after successful command (don't await)\n this.enableWaterFlowAnimation().catch((err) => {\n console.warn('Failed to enable water flow animation:', err);\n });\n\n return result;\n } catch (error) {\n // If command failed, check if it's because debugger is not attached\n const errorMsg = (error as Error)?.message || '';\n const isDetachError =\n errorMsg.includes('Debugger is not attached') ||\n errorMsg.includes('Cannot access a Target') ||\n errorMsg.includes('No target with given id');\n\n if (isDetachError && retryCount < MAX_RETRIES) {\n console.log(\n `Debugger not attached for command \"${command}\", attempting to attach (retry ${retryCount + 1}/${MAX_RETRIES})`,\n );\n\n // Try to attach and retry\n await this.ensureDebuggerAttached();\n\n return this.sendCommandToDebugger<ResponseType, RequestType>(\n command,\n params,\n retryCount + 1,\n );\n }\n\n // Not a detach error or out of retries\n throw error;\n }\n }\n\n private async getPageContentByCDP() {\n const script = await getHtmlElementScript();\n\n // check tab url\n await this.sendCommandToDebugger<\n CDPTypes.Runtime.EvaluateResponse,\n CDPTypes.Runtime.EvaluateRequest\n >('Runtime.evaluate', {\n expression: script,\n });\n\n const expression = () => {\n const tree = (\n window as any\n ).midscene_element_inspector.webExtractNodeTree();\n\n return {\n tree,\n size: {\n width: document.documentElement.clientWidth,\n height: document.documentElement.clientHeight,\n },\n };\n };\n const returnValue = await this.sendCommandToDebugger<\n CDPTypes.Runtime.EvaluateResponse,\n CDPTypes.Runtime.EvaluateRequest\n >('Runtime.evaluate', {\n expression: `(${expression.toString()})()`,\n returnByValue: true,\n });\n\n if (!returnValue.result.value) {\n const errorDescription =\n returnValue.exceptionDetails?.exception?.description || '';\n if (!errorDescription) {\n console.error('returnValue from cdp', returnValue);\n }\n throw new Error(\n `Failed to get page content from page, error: ${errorDescription}`,\n );\n }\n\n return returnValue.result.value as {\n tree: ElementTreeNode<ElementInfo>;\n size: Size;\n };\n }\n\n public async evaluateJavaScript(script: string) {\n return this.sendCommandToDebugger('Runtime.evaluate', {\n expression: script,\n awaitPromise: true,\n });\n }\n\n async registerFileChooserListener(\n handler: (chooser: FileChooserHandler) => Promise<void>,\n ): Promise<FileChooserRegistration> {\n const registrationVersion = ++this.fileChooserRegistrationVersion;\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n\n await this.ensureDebuggerAttached();\n await this.sendCommandToDebugger('Page.enable', {});\n await this.sendCommandToDebugger('DOM.enable', {});\n await this.sendCommandToDebugger('Page.setInterceptFileChooserDialog', {\n enabled: true,\n });\n\n if (this.fileChooserEventHandler) {\n chrome.debugger.onEvent.removeListener(this.fileChooserEventHandler);\n this.fileChooserEventHandler = undefined;\n }\n\n let capturedError: Error | undefined;\n let pendingFileChooserHandling = Promise.resolve();\n\n const fileChooserEventHandler: Parameters<\n typeof chrome.debugger.onEvent.addListener\n >[0] = (source, method, params) => {\n if (source.tabId !== tabId || method !== 'Page.fileChooserOpened') {\n return;\n }\n\n const event = params as CDPTypes.Page.FileChooserOpenedEvent;\n if (event.backendNodeId === undefined) {\n debug(\n 'chrome extension file chooser opened without backendNodeId, skip',\n );\n return;\n }\n\n const currentFileChooserHandling = (async () => {\n try {\n await handler({\n accept: async (files: string[]) => {\n const { node } = await this.sendCommandToDebugger<\n CDPTypes.DOM.DescribeNodeResponse,\n CDPTypes.DOM.DescribeNodeRequest\n >('DOM.describeNode', {\n backendNodeId: event.backendNodeId,\n });\n\n const hasWebkitDirectory =\n hasFlatNodeAttribute(node.attributes, 'webkitdirectory') ||\n hasFlatNodeAttribute(node.attributes, 'directory');\n if (hasWebkitDirectory) {\n throw new Error(\n 'Directory upload (webkitdirectory) is not supported in Chrome extension bridge mode. Please use Playwright instead, which supports directory upload since version 1.45.',\n );\n }\n\n if (\n files.length > 1 &&\n !hasFlatNodeAttribute(node.attributes, 'multiple')\n ) {\n throw new Error(\n 'Non-multiple file input can only accept single file',\n );\n }\n\n await this.sendCommandToDebugger('DOM.setFileInputFiles', {\n files,\n backendNodeId: event.backendNodeId,\n });\n },\n });\n } catch (error) {\n capturedError =\n error instanceof Error ? error : new Error(String(error));\n }\n })();\n const previousFileChooserHandling = pendingFileChooserHandling;\n pendingFileChooserHandling = Promise.all([\n previousFileChooserHandling,\n currentFileChooserHandling,\n ]).then(() => {});\n };\n\n this.fileChooserEventHandler = fileChooserEventHandler;\n chrome.debugger.onEvent.addListener(fileChooserEventHandler);\n\n return {\n dispose: () => {\n if (this.fileChooserEventHandler !== fileChooserEventHandler) {\n return;\n }\n chrome.debugger.onEvent.removeListener(fileChooserEventHandler);\n this.fileChooserEventHandler = undefined;\n Promise.resolve()\n .then(() => {\n if (this.fileChooserRegistrationVersion !== registrationVersion) {\n return;\n }\n return this.sendCommandToDebugger(\n 'Page.setInterceptFileChooserDialog',\n {\n enabled: false,\n },\n );\n })\n .catch((error) => {\n debug('failed to disable file chooser interception: %O', error);\n });\n },\n getError: async () => {\n await pendingFileChooserHandling;\n return capturedError;\n },\n };\n }\n\n async registerFileChooserAccept(files: string[]): Promise<void> {\n this.clearFileChooserAccept();\n const { dispose, getError } = await this.registerFileChooserListener(\n async (chooser) => {\n await chooser.accept(files);\n },\n );\n this.bridgeFileChooserDispose = dispose;\n this.bridgeFileChooserGetError = getError;\n }\n\n clearFileChooserAccept(): void {\n this.bridgeFileChooserDispose?.();\n this.bridgeFileChooserDispose = undefined;\n this.bridgeFileChooserGetError = undefined;\n }\n\n async getFileChooserError(): Promise<\n { message: string; name?: string; stack?: string } | undefined\n > {\n const error = await this.bridgeFileChooserGetError?.();\n return error ? serializeError(error) : undefined;\n }\n\n async beforeInvokeAction(): Promise<void> {\n // current implementation is wait until domReadyState is complete\n try {\n await this.waitUntilNetworkIdle();\n } catch (error) {\n // console.warn('Failed to wait until network idle', error);\n }\n }\n\n private async waitUntilNetworkIdle() {\n const timeout = 10000;\n const startTime = Date.now();\n let lastReadyState = '';\n while (Date.now() - startTime < timeout) {\n let result: any;\n try {\n result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: 'document.readyState',\n });\n } catch (error) {\n // Navigation can replace the target between tabs.update() and this\n // probe. Chrome occasionally reports that race as an empty object,\n // which cannot be recognised by sendCommandToDebugger's message-based\n // detach detection. Reattach and keep waiting for the settled page.\n debug('Failed to probe document readyState; retrying after attach', {\n error,\n });\n try {\n await this.ensureDebuggerAttached();\n } catch (attachError) {\n debug('Failed to reattach debugger while waiting for navigation', {\n error: attachError,\n });\n }\n await sleep(300);\n continue;\n }\n lastReadyState = result.result.value;\n if (lastReadyState === 'complete') {\n await new Promise((resolve) => setTimeout(resolve, 300));\n return;\n }\n await new Promise((resolve) => setTimeout(resolve, 300));\n }\n throw new Error(\n `Failed to wait until network idle, last readyState: ${lastReadyState}`,\n );\n }\n\n // @deprecated\n async getElementsInfo() {\n const tree = await this.getElementsNodeTree();\n return treeToList(tree);\n }\n\n async getXpathsByPoint(point: Point, isOrderSensitive = false) {\n const script = await getHtmlElementScript();\n\n await this.sendCommandToDebugger<\n CDPTypes.Runtime.EvaluateResponse,\n CDPTypes.Runtime.EvaluateRequest\n >('Runtime.evaluate', {\n expression: script,\n });\n\n const result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `window.midscene_element_inspector.getXpathsByPoint({left: ${point.left}, top: ${point.top}}, ${isOrderSensitive})`,\n returnByValue: true,\n });\n return result.result.value;\n }\n\n async getElementInfoByXpath(xpath: string) {\n const script = await getHtmlElementScript();\n\n // check tab url\n await this.sendCommandToDebugger<\n CDPTypes.Runtime.EvaluateResponse,\n CDPTypes.Runtime.EvaluateRequest\n >('Runtime.evaluate', {\n expression: script,\n });\n const result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `window.midscene_element_inspector.getElementInfoByXpath(${JSON.stringify(xpath)})`,\n returnByValue: true,\n });\n return result.result.value;\n }\n\n async cacheFeatureForPoint(\n center: [number, number],\n options?: CacheFeatureOptions,\n ): Promise<ElementCacheFeature> {\n const point: Point = { left: center[0], top: center[1] };\n\n try {\n const isOrderSensitive = await judgeOrderSensitive(options, debug);\n const xpaths = await this.getXpathsByPoint(point, isOrderSensitive);\n return { xpaths: sanitizeXpaths(xpaths) };\n } catch (error) {\n debug('cacheFeatureForPoint failed: %O', error);\n return { xpaths: [] };\n }\n }\n\n async rectMatchesCacheFeature(feature: ElementCacheFeature): Promise<Rect> {\n const xpaths = sanitizeXpaths((feature as WebElementCacheFeature).xpaths);\n\n for (const xpath of xpaths) {\n try {\n const elementInfo = await this.getElementInfoByXpath(xpath);\n if (elementInfo?.rect) {\n return buildRectFromElementInfo(elementInfo);\n }\n } catch (error) {\n debug('rectMatchesCacheFeature failed for xpath %s: %O', xpath, error);\n }\n }\n\n throw new Error(\n `No matching element rect found for cache feature (tried ${xpaths.length} xpath(s))`,\n );\n }\n\n async getElementsNodeTree() {\n await this.hideMousePointer();\n const content = await this.getPageContentByCDP();\n if (content?.size) {\n this.viewportSize = content.size;\n }\n\n return content?.tree || { node: null, children: [] };\n }\n\n async size() {\n if (this.viewportSize) return this.viewportSize;\n\n const result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: '({width: window.innerWidth, height: window.innerHeight})',\n returnByValue: true,\n });\n\n const sizeInfo: Size = result.result.value;\n console.log('sizeInfo', sizeInfo);\n\n this.viewportSize = sizeInfo;\n return sizeInfo;\n }\n\n async screenshotBase64() {\n // screenshot by cdp\n await this.hideMousePointer();\n const format = 'jpeg';\n const base64 = await this.sendCommandToDebugger('Page.captureScreenshot', {\n format,\n quality: 90,\n });\n return createImgBase64ByFormat(format, base64.data);\n }\n\n async url() {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n const url = await chrome.tabs.get(tabId).then((tab) => tab.url);\n return url || '';\n }\n\n async navigate(url: string): Promise<void> {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n const updatedTab = await chrome.tabs.update(tabId, { url });\n await waitForTabNavigationComplete(tabId, url, updatedTab);\n // Wait for navigation to complete. The tab-level wait above avoids sending\n // CDP commands during cross-origin target replacement.\n await this.waitUntilNetworkIdle();\n }\n\n async reload(): Promise<void> {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n await chrome.tabs.reload(tabId);\n // Wait for reload to complete\n await this.waitUntilNetworkIdle();\n }\n\n async goBack(): Promise<void> {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n await chrome.tabs.goBack(tabId);\n // Wait for navigation to complete\n await this.waitUntilNetworkIdle();\n }\n\n async goForward(): Promise<void> {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n await chrome.tabs.goForward(tabId);\n // Wait for navigation to complete\n await this.waitUntilNetworkIdle();\n }\n\n async stopLoading(): Promise<void> {\n await this.sendCommandToDebugger('Page.stopLoading', {});\n }\n\n async navigationState(): Promise<{ isLoading: boolean }> {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n const tab = await chrome.tabs.get(tabId);\n return { isLoading: tab.status === 'loading' };\n }\n\n async scrollUntilTop(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(0, -9999999);\n }\n\n async scrollUntilBottom(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(0, 9999999);\n }\n\n async scrollUntilLeft(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(-9999999, 0);\n }\n\n async scrollUntilRight(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(9999999, 0);\n }\n\n async scrollUp(distance?: number, startingPoint?: Point) {\n const { height } = await this.size();\n const scrollDistance = distance || height * 0.7;\n return this.mouse.wheel(\n 0,\n -scrollDistance,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async scrollDown(distance?: number, startingPoint?: Point) {\n const { height } = await this.size();\n const scrollDistance = distance || height * 0.7;\n return this.mouse.wheel(\n 0,\n scrollDistance,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async scrollLeft(distance?: number, startingPoint?: Point) {\n const { width } = await this.size();\n const scrollDistance = distance || width * 0.7;\n return this.mouse.wheel(\n -scrollDistance,\n 0,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async scrollRight(distance?: number, startingPoint?: Point) {\n const { width } = await this.size();\n const scrollDistance = distance || width * 0.7;\n return this.mouse.wheel(\n scrollDistance,\n 0,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async clearInput(element: ElementInfo) {\n if (!element) {\n console.warn('No element to clear input');\n return;\n }\n\n await this.mouse.click(element.center[0], element.center[1]);\n\n await this.sendCommandToDebugger('Input.dispatchKeyEvent', {\n type: 'keyDown',\n commands: ['selectAll'],\n });\n\n await this.sendCommandToDebugger('Input.dispatchKeyEvent', {\n type: 'keyUp',\n commands: ['selectAll'],\n });\n\n await sleep(100);\n\n await this.keyboard.press({\n key: 'Backspace',\n });\n }\n\n async selectAllInput(element?: ElementInfo) {\n if (!element) {\n throw new Error('Bulk replace input requires a target element');\n }\n\n await this.mouse.click(element.center[0], element.center[1]);\n const selectionResult = await this.sendCommandToDebugger(\n 'Runtime.evaluate',\n {\n expression: selectAllInputScript,\n returnByValue: true,\n },\n );\n if (selectionResult?.result?.value === true) {\n return;\n }\n\n await this.sendCommandToDebugger('Input.dispatchKeyEvent', {\n type: 'keyDown',\n commands: ['selectAll'],\n });\n await this.sendCommandToDebugger('Input.dispatchKeyEvent', {\n type: 'keyUp',\n commands: ['selectAll'],\n });\n }\n\n private latestMouseX = 100;\n private latestMouseY = 100;\n\n mouse = {\n click: async (\n x: number,\n y: number,\n options?: { button?: MouseButton; count?: number },\n ) => {\n const { button = 'left', count = 1 } = options || {};\n await this.mouse.move(x, y);\n // detect if the page is in mobile emulation mode\n if (this.isMobileEmulation === null) {\n const result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `(() => {\n return /Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent);\n })()`,\n returnByValue: true,\n });\n this.isMobileEmulation = result?.result?.value;\n }\n\n if (this.isMobileEmulation && button === 'left') {\n // in mobile emulation mode, directly inject click event\n const touchPoints = [{ x: Math.round(x), y: Math.round(y) }];\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchStart',\n touchPoints,\n modifiers: 0,\n });\n\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchEnd',\n touchPoints: [],\n modifiers: 0,\n });\n } else {\n // standard mousePressed + mouseReleased\n for (let i = 0; i < count; i++) {\n const clickCount = i + 1;\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mousePressed',\n x,\n y,\n button,\n clickCount,\n });\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseReleased',\n x,\n y,\n button,\n clickCount,\n });\n if (i < count - 1) {\n await sleep(50);\n }\n }\n }\n },\n wheel: async (\n deltaX: number,\n deltaY: number,\n startX?: number,\n startY?: number,\n ) => {\n const finalX = startX || this.latestMouseX;\n const finalY = startY || this.latestMouseY;\n await this.showMousePointer(finalX, finalY);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseWheel',\n x: finalX,\n y: finalY,\n deltaX,\n deltaY,\n });\n this.latestMouseX = finalX;\n this.latestMouseY = finalY;\n },\n move: async (x: number, y: number) => {\n await this.showMousePointer(x, y);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseMoved',\n x,\n y,\n });\n this.latestMouseX = x;\n this.latestMouseY = y;\n },\n drag: async (\n from: { x: number; y: number },\n to: { x: number; y: number },\n ) => {\n await this.mouse.move(from.x, from.y);\n\n await sleep(200);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mousePressed',\n x: from.x,\n y: from.y,\n button: 'left',\n // CDP uses `buttons` to represent the currently pressed mouse buttons.\n // HTML5 drag/drop needs this state to treat following moves as dragging.\n buttons: 1,\n clickCount: 1,\n });\n\n await sleep(300);\n\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseMoved',\n x: to.x,\n y: to.y,\n button: 'left',\n buttons: 1,\n });\n\n await sleep(500);\n\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseReleased',\n x: to.x,\n y: to.y,\n button: 'left',\n buttons: 0,\n clickCount: 1,\n });\n\n await sleep(200);\n\n await this.mouse.move(to.x, to.y);\n },\n };\n\n keyboard = {\n type: async (text: string) => {\n const cdpKeyboard = new CdpKeyboard({\n send: this.sendCommandToDebugger.bind(this),\n });\n await cdpKeyboard.type(text, { delay: 0 });\n },\n insertText: async (text: string) => {\n await this.sendCommandToDebugger('Input.insertText', { text });\n },\n press: async (\n action:\n | { key: KeyInput; command?: string }\n | { key: KeyInput; command?: string }[],\n ) => {\n const cdpKeyboard = new CdpKeyboard({\n send: this.sendCommandToDebugger.bind(this),\n });\n const keys = Array.isArray(action) ? action : [action];\n for (const k of keys) {\n const commands = k.command ? [k.command] : [];\n await cdpKeyboard.down(k.key, { commands });\n }\n for (const k of [...keys].reverse()) {\n await cdpKeyboard.up(k.key);\n }\n },\n };\n\n async destroy(): Promise<void> {\n this.destroyed = true;\n this.clearFileChooserAccept();\n const tabIdToDetach = this.activeTabId;\n this.activeTabId = null;\n if (tabIdToDetach) {\n await this.detachDebugger(tabIdToDetach);\n }\n }\n\n async longPress(x: number, y: number, duration?: number) {\n duration = duration || 500;\n // Keep a lower bound so the press is registered as a long press rather than\n // a click, but never cap the upper bound: the duration is the caller's\n // intent (e.g. \"hold for 6 seconds\").\n const MIN_LONG_PRESS_DURATION = 300;\n if (duration < MIN_LONG_PRESS_DURATION) {\n duration = MIN_LONG_PRESS_DURATION;\n }\n await this.mouse.move(x, y);\n\n if (this.isMobileEmulation === null) {\n const result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `(() => {\n return /Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent);\n })()`,\n returnByValue: true,\n });\n this.isMobileEmulation = result?.result?.value;\n }\n\n if (this.isMobileEmulation) {\n const touchPoints = [{ x: Math.round(x), y: Math.round(y) }];\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchStart',\n touchPoints,\n modifiers: 0,\n });\n await new Promise((res) => setTimeout(res, duration));\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchEnd',\n touchPoints: [],\n modifiers: 0,\n });\n } else {\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mousePressed',\n x,\n y,\n button: 'left',\n clickCount: 1,\n });\n await new Promise((res) => setTimeout(res, duration));\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseReleased',\n x,\n y,\n button: 'left',\n clickCount: 1,\n });\n }\n this.latestMouseX = x;\n this.latestMouseY = y;\n }\n\n async swipe(\n from: { x: number; y: number },\n to: { x: number; y: number },\n duration?: number,\n ) {\n const LONG_PRESS_THRESHOLD = 500;\n const MIN_PRESS_THRESHOLD = 150;\n duration = duration || 300;\n if (duration < MIN_PRESS_THRESHOLD) {\n duration = MIN_PRESS_THRESHOLD;\n }\n if (duration > LONG_PRESS_THRESHOLD) {\n duration = LONG_PRESS_THRESHOLD;\n }\n\n if (this.isMobileEmulation === null) {\n const result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `(() => {\n return /Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent);\n })()`,\n returnByValue: true,\n });\n this.isMobileEmulation = result?.result?.value;\n }\n\n const steps = 30;\n const delay = duration / steps;\n\n if (this.isMobileEmulation) {\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchStart',\n touchPoints: [{ x: Math.round(from.x), y: Math.round(from.y) }],\n modifiers: 0,\n });\n\n for (let i = 1; i <= steps; i++) {\n const x = from.x + (to.x - from.x) * (i / steps);\n const y = from.y + (to.y - from.y) * (i / steps);\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchMove',\n touchPoints: [{ x: Math.round(x), y: Math.round(y) }],\n modifiers: 0,\n });\n await new Promise((res) => setTimeout(res, delay));\n }\n\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchEnd',\n touchPoints: [],\n modifiers: 0,\n });\n } else {\n await this.mouse.move(from.x, from.y);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mousePressed',\n x: from.x,\n y: from.y,\n button: 'left',\n clickCount: 1,\n });\n\n for (let i = 1; i <= steps; i++) {\n const x = from.x + (to.x - from.x) * (i / steps);\n const y = from.y + (to.y - from.y) * (i / steps);\n await this.mouse.move(x, y);\n await new Promise((res) => setTimeout(res, delay));\n }\n\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseReleased',\n x: to.x,\n y: to.y,\n button: 'left',\n clickCount: 1,\n });\n }\n\n this.latestMouseX = to.x;\n this.latestMouseY = to.y;\n }\n\n async pinch(\n centerX: number,\n centerY: number,\n startDistance: number,\n endDistance: number,\n duration = 500,\n ): Promise<void> {\n const steps = 30;\n const delay = duration / steps;\n\n const halfStart = startDistance / 2;\n const halfEnd = endDistance / 2;\n\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchStart',\n touchPoints: [\n {\n x: Math.round(centerX),\n y: Math.round(centerY - halfStart),\n id: 0,\n },\n {\n x: Math.round(centerX),\n y: Math.round(centerY + halfStart),\n id: 1,\n },\n ],\n modifiers: 0,\n });\n\n for (let i = 1; i <= steps; i++) {\n const progress = i / steps;\n const currentHalf = halfStart + (halfEnd - halfStart) * progress;\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchMove',\n touchPoints: [\n {\n x: Math.round(centerX),\n y: Math.round(centerY - currentHalf),\n id: 0,\n },\n {\n x: Math.round(centerX),\n y: Math.round(centerY + currentHalf),\n id: 1,\n },\n ],\n modifiers: 0,\n });\n await new Promise((res) => setTimeout(res, delay));\n }\n\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchEnd',\n touchPoints: [],\n modifiers: 0,\n });\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debug","getDebug","sleep","ms","Promise","resolve","setTimeout","NAVIGATION_COMPLETE_TIMEOUT_MS","isBlankUrl","url","waitForTabNavigationComplete","tabId","targetUrl","updatedTab","timeoutMs","settled","finish","chrome","onUpdated","clearTimeout","timer","isTargetTab","tab","isReady","navigationUpdateObserved","currentUrl","isExpectedUrlKind","id","info","hasFlatNodeAttribute","attributes","name","i","serializeError","error","ChromeExtensionProxyPage","commonWebActionsForWebPage","options","Error","tabs","assert","console","errorMsg","err","x","y","pointerScript","tabIdToDetach","limitOpenNewTabScript","script","injectWaterFlowAnimation","injectStopWaterFlowAnimation","enabled","command","params","retryCount","MAX_RETRIES","result","isDetachError","getHtmlElementScript","expression","tree","window","document","returnValue","errorDescription","handler","registrationVersion","undefined","capturedError","pendingFileChooserHandling","fileChooserEventHandler","source","method","event","currentFileChooserHandling","files","node","hasWebkitDirectory","String","previousFileChooserHandling","dispose","getError","chooser","timeout","startTime","Date","lastReadyState","attachError","treeToList","point","isOrderSensitive","xpath","JSON","center","judgeOrderSensitive","xpaths","sanitizeXpaths","feature","elementInfo","buildRectFromElementInfo","content","sizeInfo","format","base64","createImgBase64ByFormat","startingPoint","distance","height","scrollDistance","width","element","selectionResult","selectAllInputScript","duration","MIN_LONG_PRESS_DURATION","touchPoints","Math","res","from","to","LONG_PRESS_THRESHOLD","MIN_PRESS_THRESHOLD","steps","delay","centerX","centerY","startDistance","endDistance","halfStart","halfEnd","progress","currentHalf","forceSameTabNavigation","inputOptions","button","count","clickCount","deltaX","deltaY","startX","startY","finalX","finalY","text","cdpKeyboard","CdpKeyboard","action","keys","Array","k","commands"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;ACDA;;;;;;;;;;AA2CA,MAAMI,QAAQC,AAAAA,IAAAA,uBAAAA,QAAAA,AAAAA,EAAS;AAEvB,SAASC,MAAMC,EAAU;IACvB,OAAO,IAAIC,QAAQ,CAACC,UAAYC,WAAWD,SAASF;AACtD;AAEA,MAAMI,iCAAiC;AAEvC,SAASC,WAAWC,GAAuB;IACzC,IAAI,CAACA,KAAK,OAAO;IACjB,OAAOA,AAAQ,kBAARA,OAAyBA,IAAI,UAAU,CAAC;AACjD;AASA,SAASC,6BACPC,KAAa,EACbC,SAAiB,EACjBC,UAA4B,EAC5BC,YAAYP,8BAA8B;IAE1C,OAAO,IAAIH,QAAQ,CAACC;QAClB,IAAIU,UAAU;QACd,MAAMC,SAAS;YACb,IAAID,SA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iBAAiB,GAAGC,cAAc;QACvC,IAAI,CAAC,aAAa,GAAGA,cAAc;IACrC;AA8oCF"}
1
+ {"version":3,"file":"chrome-extension/page.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/chrome-extension/page.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/// <reference types=\"chrome\" />\n\n/*\n It is used to interact with the page tab from the chrome extension.\n The page must be active when interacting with it.\n*/\n\nimport { limitOpenNewTabScript } from '@/web-element';\nimport type {\n ElementCacheFeature,\n ElementTreeNode,\n Point,\n Rect,\n Size,\n} from '@midscene/core';\nimport type {\n AbstractInterface,\n DeviceAction,\n FileChooserHandler,\n FileChooserRegistration,\n TextInputOptions,\n} from '@midscene/core/device';\nimport type { ElementInfo } from '@midscene/shared/extractor';\nimport { treeToList } from '@midscene/shared/extractor';\nimport { createImgBase64ByFormat } from '@midscene/shared/img';\nimport { getDebug } from '@midscene/shared/logger';\nimport { assert } from '@midscene/shared/utils';\nimport type { Protocol as CDPTypes } from 'devtools-protocol';\nimport {\n type CacheFeatureOptions,\n type WebElementCacheFeature,\n buildRectFromElementInfo,\n judgeOrderSensitive,\n sanitizeXpaths,\n} from '../common/cache-helper';\nimport { selectAllInputScript } from '../common/input-scripts';\nimport {\n type KeyInput,\n type MouseButton,\n commonWebActionsForWebPage,\n} from '../web-page';\nimport { CdpKeyboard } from './cdpInput';\nimport {\n getHtmlElementScript,\n injectStopWaterFlowAnimation,\n injectWaterFlowAnimation,\n} from './dynamic-scripts';\n\nconst debug = getDebug('web:chrome-extension:page');\n\nfunction sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nconst NAVIGATION_COMPLETE_TIMEOUT_MS = 30_000;\n\nfunction isBlankUrl(url: string | undefined): boolean {\n if (!url) return true;\n return url === 'about:blank' || url.startsWith('chrome://newtab');\n}\n\n/**\n * Wait for the browser target to settle before sending CDP commands to it.\n *\n * A cross-origin redirect can replace the target after `tabs.update()`\n * resolves. Sending `Runtime.evaluate` during that hand-off intermittently\n * fails because Chrome has detached the debugger from the old target.\n */\nfunction waitForTabNavigationComplete(\n tabId: number,\n targetUrl: string,\n updatedTab?: chrome.tabs.Tab,\n timeoutMs = NAVIGATION_COMPLETE_TIMEOUT_MS,\n): Promise<void> {\n return new Promise((resolve) => {\n let settled = false;\n const finish = () => {\n if (settled) return;\n settled = true;\n chrome.tabs.onUpdated.removeListener(onUpdated);\n clearTimeout(timer);\n resolve();\n };\n\n const isTargetTab = (tab: chrome.tabs.Tab | undefined): boolean => {\n if (!tab) return false;\n return tab.url === targetUrl || tab.pendingUrl === targetUrl;\n };\n\n const isReady = (\n tab: chrome.tabs.Tab | undefined,\n navigationUpdateObserved: boolean,\n ): boolean => {\n if (!tab || tab.status !== 'complete') return false;\n const currentUrl = tab.url || tab.pendingUrl || '';\n const isExpectedUrlKind = isBlankUrl(targetUrl)\n ? isBlankUrl(currentUrl)\n : !isBlankUrl(currentUrl);\n return (\n isExpectedUrlKind && (navigationUpdateObserved || isTargetTab(tab))\n );\n };\n\n const onUpdated = (\n id: number,\n info: chrome.tabs.TabChangeInfo,\n tab: chrome.tabs.Tab,\n ) => {\n // This listener is registered after tabs.update(), so a completion\n // event received here belongs to the navigation we initiated.\n if (id === tabId && isReady(tab, info.status === 'complete')) finish();\n };\n\n chrome.tabs.onUpdated.addListener(onUpdated);\n const timer = setTimeout(finish, timeoutMs);\n\n // tabs.update() returns the updated target. A completed returned tab is\n // already a settled result of this navigation, including a fast redirect.\n if (isReady(updatedTab, true)) {\n finish();\n return;\n }\n\n // The tab may have completed before the listener was added. Only accept\n // the requested target here: a previous complete HTTPS page is not proof\n // that this navigation has settled.\n chrome.tabs\n .get(tabId)\n .then((tab) => {\n if (isReady(tab, false)) finish();\n })\n .catch(() => {});\n });\n}\n\nfunction hasFlatNodeAttribute(\n attributes: string[] | undefined,\n name: string,\n): boolean {\n if (!attributes) return false;\n for (let i = 0; i < attributes.length; i += 2) {\n if (attributes[i] === name) return true;\n }\n return false;\n}\n\nfunction serializeError(error: Error): {\n message: string;\n name?: string;\n stack?: string;\n} {\n return {\n message: error.message,\n name: error.name,\n stack: error.stack,\n };\n}\n\nexport default class ChromeExtensionProxyPage implements AbstractInterface {\n interfaceType = 'chrome-extension-proxy';\n\n public forceSameTabNavigation: boolean;\n\n readonly keyboardTypeDelay?: number;\n\n readonly inputStrategy?: TextInputOptions['inputStrategy'];\n\n private viewportSize?: Size;\n\n private activeTabId: number | null = null;\n\n private destroyed = false;\n\n private fileChooserEventHandler?: Parameters<\n typeof chrome.debugger.onEvent.addListener\n >[0];\n\n private fileChooserRegistrationVersion = 0;\n\n private bridgeFileChooserDispose?: () => void;\n\n private bridgeFileChooserGetError?: FileChooserRegistration['getError'];\n\n private isMobileEmulation: boolean | null = null;\n\n protected waterFlowAnimationEnabled = true;\n\n public _continueWhenFailedToAttachDebugger = false;\n\n constructor(\n forceSameTabNavigation: boolean,\n inputOptions?: TextInputOptions,\n ) {\n this.forceSameTabNavigation = forceSameTabNavigation;\n this.keyboardTypeDelay = inputOptions?.keyboardTypeDelay;\n this.inputStrategy = inputOptions?.inputStrategy;\n }\n\n actionSpace(): DeviceAction[] {\n return commonWebActionsForWebPage(this);\n }\n\n /**\n * Set the tab currently used by Midscene and optionally activate it in Chrome.\n */\n public async setActiveTabId(\n tabId: number,\n options: { activate?: boolean } = {},\n ) {\n if (this.activeTabId) {\n throw new Error(\n `Active tab id is already set, which is ${this.activeTabId}, cannot set it to ${tabId}`,\n );\n }\n if (options.activate !== false) {\n await chrome.tabs.update(tabId, { active: true });\n }\n this.activeTabId = tabId;\n }\n\n public async getActiveTabId() {\n return this.activeTabId;\n }\n\n /**\n * Get a list of current tabs\n * @returns {Promise<Array<{id: number, title: string, url: string}>>}\n */\n public async getBrowserTabList(): Promise<\n { id: string; title: string; url: string; currentActiveTab: boolean }[]\n > {\n const tabs = await chrome.tabs.query({ currentWindow: true });\n return tabs\n .map((tab) => ({\n id: `${tab.id}`,\n title: tab.title,\n url: tab.url,\n currentActiveTab: tab.active,\n }))\n .filter((tab) => tab.id && tab.title && tab.url) as {\n id: string;\n title: string;\n url: string;\n currentActiveTab: boolean;\n }[];\n }\n\n public async getTabIdOrConnectToCurrentTab() {\n if (this.activeTabId) {\n // Always reuse the controlled tab to avoid switching to a tab activated later by the user.\n return this.activeTabId;\n }\n const tabId = await chrome.tabs\n .query({ active: true, currentWindow: true })\n .then((tabs) => tabs[0]?.id);\n this.activeTabId = tabId || 0;\n return this.activeTabId;\n }\n\n /**\n * Ensure debugger is attached to the current tab.\n * Uses lazy attach pattern - only attaches when needed.\n */\n private async ensureDebuggerAttached() {\n assert(!this.destroyed, 'Page is destroyed');\n\n const url = await this.url();\n if (url.startsWith('chrome://')) {\n throw new Error(\n 'Cannot attach debugger to chrome:// pages, please use Midscene in a normal page with http://, https:// or file://',\n );\n }\n\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n\n try {\n await chrome.debugger.attach({ tabId }, '1.3');\n console.log('Debugger attached to tab:', tabId);\n } catch (error) {\n const errorMsg = (error as Error)?.message || '';\n // Already attached is OK, we can continue\n if (errorMsg.includes('Another debugger is already attached')) {\n console.log('Debugger already attached to tab:', tabId);\n return;\n }\n\n if (this._continueWhenFailedToAttachDebugger) {\n console.warn(\n 'Failed to attach debugger, but continuing due to _continueWhenFailedToAttachDebugger flag',\n error,\n );\n return;\n }\n\n throw error;\n }\n\n // Wait for debugger banner in Chrome to appear\n await sleep(500);\n\n // Enable water flow animation. Non-fatal: this is a purely visual\n // overlay, and Chrome can briefly detach the debugger between\n // attach() and the eval below (cross-origin navigation / Site\n // Isolation race). If we awaited it and it threw \"Debugger is not\n // attached\", the error would propagate out of the catch block in\n // sendCommandToDebugger, preventing the actual CDP command from\n // ever being retried. Fire-and-forget here so the lazy-attach\n // retry can succeed even when the animation fails.\n this.enableWaterFlowAnimation().catch((err) => {\n console.warn('Failed to enable water flow animation:', err);\n });\n }\n\n private async showMousePointer(x: number, y: number) {\n if (!this.waterFlowAnimationEnabled) return;\n\n // update mouse pointer while redirecting\n const pointerScript = `(() => {\n if(typeof window.midsceneWaterFlowAnimation !== 'undefined') {\n window.midsceneWaterFlowAnimation.enable();\n window.midsceneWaterFlowAnimation.showMousePointer(${x}, ${y});\n } else {\n console.log('midsceneWaterFlowAnimation is not defined');\n }\n })()`;\n\n await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `${pointerScript}`,\n });\n }\n\n private async hideMousePointer() {\n await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `(() => {\n if(typeof window.midsceneWaterFlowAnimation !== 'undefined') {\n window.midsceneWaterFlowAnimation.hideMousePointer();\n }\n })()`,\n });\n }\n\n /**\n * Public method to detach debugger without destroying the page instance.\n * Useful for error recovery scenarios where we want to remove the debugger banner\n * without completely destroying the page.\n */\n public async detachDebugger(tabId?: number) {\n const tabIdToDetach = tabId || (await this.getTabIdOrConnectToCurrentTab());\n console.log('detaching debugger from tab:', tabIdToDetach);\n\n try {\n await this.disableWaterFlowAnimation(tabIdToDetach);\n await sleep(200); // wait for the animation to stop\n } catch (error) {\n console.warn('Failed to disable water flow animation', error);\n }\n\n try {\n await chrome.debugger.detach({ tabId: tabIdToDetach });\n console.log('Debugger detached successfully from tab:', tabIdToDetach);\n } catch (error) {\n // Tab might be closed or debugger already detached - this is OK\n console.warn(\n 'Failed to detach debugger (may already be detached):',\n error,\n );\n }\n }\n\n private async enableWaterFlowAnimation() {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n\n // limit open page in new tab\n if (this.forceSameTabNavigation) {\n await chrome.debugger.sendCommand({ tabId }, 'Runtime.evaluate', {\n expression: limitOpenNewTabScript,\n });\n }\n\n if (!this.waterFlowAnimationEnabled) {\n return;\n }\n\n const script = await injectWaterFlowAnimation();\n // we will call this function in sendCommandToDebugger, so we have to use the chrome.debugger.sendCommand\n await chrome.debugger.sendCommand({ tabId }, 'Runtime.evaluate', {\n expression: script,\n });\n }\n\n private async disableWaterFlowAnimation(tabId: number) {\n const script = await injectStopWaterFlowAnimation();\n\n await chrome.debugger.sendCommand({ tabId }, 'Runtime.evaluate', {\n expression: script,\n });\n }\n\n public async setWaterFlowAnimationEnabled(enabled: boolean) {\n this.waterFlowAnimationEnabled = enabled;\n if (!enabled) {\n const script = await injectStopWaterFlowAnimation();\n await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: script,\n });\n }\n }\n\n /**\n * Returns the current water-flow animation enabled flag.\n */\n public getWaterFlowAnimationEnabled(): boolean {\n return this.waterFlowAnimationEnabled;\n }\n\n /**\n * Send a command to the debugger with automatic attach and retry on detachment.\n * Uses lazy attach pattern - will automatically attach if not already attached.\n */\n private async sendCommandToDebugger<ResponseType = any, RequestType = any>(\n command: string,\n params: RequestType,\n retryCount = 0,\n ): Promise<ResponseType> {\n const MAX_RETRIES = 2;\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n\n try {\n // Try to send command directly first\n const result = (await chrome.debugger.sendCommand(\n { tabId },\n command,\n params as any,\n )) as ResponseType;\n\n // Enable water flow animation after successful command (don't await)\n this.enableWaterFlowAnimation().catch((err) => {\n console.warn('Failed to enable water flow animation:', err);\n });\n\n return result;\n } catch (error) {\n // If command failed, check if it's because debugger is not attached\n const errorMsg = (error as Error)?.message || '';\n const isDetachError =\n errorMsg.includes('Debugger is not attached') ||\n errorMsg.includes('Cannot access a Target') ||\n errorMsg.includes('No target with given id');\n\n if (isDetachError && retryCount < MAX_RETRIES) {\n console.log(\n `Debugger not attached for command \"${command}\", attempting to attach (retry ${retryCount + 1}/${MAX_RETRIES})`,\n );\n\n // Try to attach and retry\n await this.ensureDebuggerAttached();\n\n return this.sendCommandToDebugger<ResponseType, RequestType>(\n command,\n params,\n retryCount + 1,\n );\n }\n\n // Not a detach error or out of retries\n throw error;\n }\n }\n\n private async getPageContentByCDP() {\n const script = await getHtmlElementScript();\n\n // check tab url\n await this.sendCommandToDebugger<\n CDPTypes.Runtime.EvaluateResponse,\n CDPTypes.Runtime.EvaluateRequest\n >('Runtime.evaluate', {\n expression: script,\n });\n\n const expression = () => {\n const tree = (\n window as any\n ).midscene_element_inspector.webExtractNodeTree();\n\n return {\n tree,\n size: {\n width: document.documentElement.clientWidth,\n height: document.documentElement.clientHeight,\n },\n };\n };\n const returnValue = await this.sendCommandToDebugger<\n CDPTypes.Runtime.EvaluateResponse,\n CDPTypes.Runtime.EvaluateRequest\n >('Runtime.evaluate', {\n expression: `(${expression.toString()})()`,\n returnByValue: true,\n });\n\n if (!returnValue.result.value) {\n const errorDescription =\n returnValue.exceptionDetails?.exception?.description || '';\n if (!errorDescription) {\n console.error('returnValue from cdp', returnValue);\n }\n throw new Error(\n `Failed to get page content from page, error: ${errorDescription}`,\n );\n }\n\n return returnValue.result.value as {\n tree: ElementTreeNode<ElementInfo>;\n size: Size;\n };\n }\n\n public async evaluateJavaScript(script: string) {\n return this.sendCommandToDebugger('Runtime.evaluate', {\n expression: script,\n awaitPromise: true,\n });\n }\n\n async registerFileChooserListener(\n handler: (chooser: FileChooserHandler) => Promise<void>,\n ): Promise<FileChooserRegistration> {\n const registrationVersion = ++this.fileChooserRegistrationVersion;\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n\n await this.ensureDebuggerAttached();\n await this.sendCommandToDebugger('Page.enable', {});\n await this.sendCommandToDebugger('DOM.enable', {});\n await this.sendCommandToDebugger('Page.setInterceptFileChooserDialog', {\n enabled: true,\n });\n\n if (this.fileChooserEventHandler) {\n chrome.debugger.onEvent.removeListener(this.fileChooserEventHandler);\n this.fileChooserEventHandler = undefined;\n }\n\n let capturedError: Error | undefined;\n let pendingFileChooserHandling = Promise.resolve();\n\n const fileChooserEventHandler: Parameters<\n typeof chrome.debugger.onEvent.addListener\n >[0] = (source, method, params) => {\n if (source.tabId !== tabId || method !== 'Page.fileChooserOpened') {\n return;\n }\n\n const event = params as CDPTypes.Page.FileChooserOpenedEvent;\n if (event.backendNodeId === undefined) {\n debug(\n 'chrome extension file chooser opened without backendNodeId, skip',\n );\n return;\n }\n\n const currentFileChooserHandling = (async () => {\n try {\n await handler({\n accept: async (files: string[]) => {\n const { node } = await this.sendCommandToDebugger<\n CDPTypes.DOM.DescribeNodeResponse,\n CDPTypes.DOM.DescribeNodeRequest\n >('DOM.describeNode', {\n backendNodeId: event.backendNodeId,\n });\n\n const hasWebkitDirectory =\n hasFlatNodeAttribute(node.attributes, 'webkitdirectory') ||\n hasFlatNodeAttribute(node.attributes, 'directory');\n if (hasWebkitDirectory) {\n throw new Error(\n 'Directory upload (webkitdirectory) is not supported in Chrome extension bridge mode. Please use Playwright instead, which supports directory upload since version 1.45.',\n );\n }\n\n if (\n files.length > 1 &&\n !hasFlatNodeAttribute(node.attributes, 'multiple')\n ) {\n throw new Error(\n 'Non-multiple file input can only accept single file',\n );\n }\n\n await this.sendCommandToDebugger('DOM.setFileInputFiles', {\n files,\n backendNodeId: event.backendNodeId,\n });\n },\n });\n } catch (error) {\n capturedError =\n error instanceof Error ? error : new Error(String(error));\n }\n })();\n const previousFileChooserHandling = pendingFileChooserHandling;\n pendingFileChooserHandling = Promise.all([\n previousFileChooserHandling,\n currentFileChooserHandling,\n ]).then(() => {});\n };\n\n this.fileChooserEventHandler = fileChooserEventHandler;\n chrome.debugger.onEvent.addListener(fileChooserEventHandler);\n\n return {\n dispose: () => {\n if (this.fileChooserEventHandler !== fileChooserEventHandler) {\n return;\n }\n chrome.debugger.onEvent.removeListener(fileChooserEventHandler);\n this.fileChooserEventHandler = undefined;\n Promise.resolve()\n .then(() => {\n if (this.fileChooserRegistrationVersion !== registrationVersion) {\n return;\n }\n return this.sendCommandToDebugger(\n 'Page.setInterceptFileChooserDialog',\n {\n enabled: false,\n },\n );\n })\n .catch((error) => {\n debug('failed to disable file chooser interception: %O', error);\n });\n },\n getError: async () => {\n await pendingFileChooserHandling;\n return capturedError;\n },\n };\n }\n\n async registerFileChooserAccept(files: string[]): Promise<void> {\n this.clearFileChooserAccept();\n const { dispose, getError } = await this.registerFileChooserListener(\n async (chooser) => {\n await chooser.accept(files);\n },\n );\n this.bridgeFileChooserDispose = dispose;\n this.bridgeFileChooserGetError = getError;\n }\n\n clearFileChooserAccept(): void {\n this.bridgeFileChooserDispose?.();\n this.bridgeFileChooserDispose = undefined;\n this.bridgeFileChooserGetError = undefined;\n }\n\n async getFileChooserError(): Promise<\n { message: string; name?: string; stack?: string } | undefined\n > {\n const error = await this.bridgeFileChooserGetError?.();\n return error ? serializeError(error) : undefined;\n }\n\n async beforeInvokeAction(): Promise<void> {\n // current implementation is wait until domReadyState is complete\n try {\n await this.waitUntilNetworkIdle();\n } catch (error) {\n // console.warn('Failed to wait until network idle', error);\n }\n }\n\n private async waitUntilNetworkIdle() {\n const timeout = 10000;\n const startTime = Date.now();\n let lastReadyState = '';\n while (Date.now() - startTime < timeout) {\n let result: any;\n try {\n result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: 'document.readyState',\n });\n } catch (error) {\n // Navigation can replace the target between tabs.update() and this\n // probe. Chrome occasionally reports that race as an empty object,\n // which cannot be recognised by sendCommandToDebugger's message-based\n // detach detection. Reattach and keep waiting for the settled page.\n debug('Failed to probe document readyState; retrying after attach', {\n error,\n });\n try {\n await this.ensureDebuggerAttached();\n } catch (attachError) {\n debug('Failed to reattach debugger while waiting for navigation', {\n error: attachError,\n });\n }\n await sleep(300);\n continue;\n }\n lastReadyState = result.result.value;\n if (lastReadyState === 'complete') {\n await new Promise((resolve) => setTimeout(resolve, 300));\n return;\n }\n await new Promise((resolve) => setTimeout(resolve, 300));\n }\n throw new Error(\n `Failed to wait until network idle, last readyState: ${lastReadyState}`,\n );\n }\n\n // @deprecated\n async getElementsInfo() {\n const tree = await this.getElementsNodeTree();\n return treeToList(tree);\n }\n\n async getXpathsByPoint(point: Point, isOrderSensitive = false) {\n const script = await getHtmlElementScript();\n\n await this.sendCommandToDebugger<\n CDPTypes.Runtime.EvaluateResponse,\n CDPTypes.Runtime.EvaluateRequest\n >('Runtime.evaluate', {\n expression: script,\n });\n\n const result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `window.midscene_element_inspector.getXpathsByPoint({left: ${point.left}, top: ${point.top}}, ${isOrderSensitive})`,\n returnByValue: true,\n });\n return result.result.value;\n }\n\n async getElementInfoByXpath(xpath: string) {\n const script = await getHtmlElementScript();\n\n // check tab url\n await this.sendCommandToDebugger<\n CDPTypes.Runtime.EvaluateResponse,\n CDPTypes.Runtime.EvaluateRequest\n >('Runtime.evaluate', {\n expression: script,\n });\n const result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `window.midscene_element_inspector.getElementInfoByXpath(${JSON.stringify(xpath)})`,\n returnByValue: true,\n });\n return result.result.value;\n }\n\n async cacheFeatureForPoint(\n center: [number, number],\n options?: CacheFeatureOptions,\n ): Promise<ElementCacheFeature> {\n const point: Point = { left: center[0], top: center[1] };\n\n try {\n const isOrderSensitive = await judgeOrderSensitive(options, debug);\n const xpaths = await this.getXpathsByPoint(point, isOrderSensitive);\n return { xpaths: sanitizeXpaths(xpaths) };\n } catch (error) {\n debug('cacheFeatureForPoint failed: %O', error);\n return { xpaths: [] };\n }\n }\n\n async rectMatchesCacheFeature(feature: ElementCacheFeature): Promise<Rect> {\n const xpaths = sanitizeXpaths((feature as WebElementCacheFeature).xpaths);\n\n for (const xpath of xpaths) {\n try {\n const elementInfo = await this.getElementInfoByXpath(xpath);\n if (elementInfo?.rect) {\n return buildRectFromElementInfo(elementInfo);\n }\n } catch (error) {\n debug('rectMatchesCacheFeature failed for xpath %s: %O', xpath, error);\n }\n }\n\n throw new Error(\n `No matching element rect found for cache feature (tried ${xpaths.length} xpath(s))`,\n );\n }\n\n async getElementsNodeTree() {\n await this.hideMousePointer();\n const content = await this.getPageContentByCDP();\n if (content?.size) {\n this.viewportSize = content.size;\n }\n\n return content?.tree || { node: null, children: [] };\n }\n\n async size() {\n if (this.viewportSize) return this.viewportSize;\n\n const result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: '({width: window.innerWidth, height: window.innerHeight})',\n returnByValue: true,\n });\n\n const sizeInfo: Size = result.result.value;\n console.log('sizeInfo', sizeInfo);\n\n this.viewportSize = sizeInfo;\n return sizeInfo;\n }\n\n async screenshotBase64() {\n // screenshot by cdp\n await this.hideMousePointer();\n const format = 'jpeg';\n const base64 = await this.sendCommandToDebugger('Page.captureScreenshot', {\n format,\n quality: 90,\n });\n return createImgBase64ByFormat(format, base64.data);\n }\n\n async url() {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n const url = await chrome.tabs.get(tabId).then((tab) => tab.url);\n return url || '';\n }\n\n async navigate(url: string): Promise<void> {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n const updatedTab = await chrome.tabs.update(tabId, { url });\n await waitForTabNavigationComplete(tabId, url, updatedTab);\n // Wait for navigation to complete. The tab-level wait above avoids sending\n // CDP commands during cross-origin target replacement.\n await this.waitUntilNetworkIdle();\n }\n\n async reload(): Promise<void> {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n await chrome.tabs.reload(tabId);\n // Wait for reload to complete\n await this.waitUntilNetworkIdle();\n }\n\n async goBack(): Promise<void> {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n await chrome.tabs.goBack(tabId);\n // Wait for navigation to complete\n await this.waitUntilNetworkIdle();\n }\n\n async goForward(): Promise<void> {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n await chrome.tabs.goForward(tabId);\n // Wait for navigation to complete\n await this.waitUntilNetworkIdle();\n }\n\n async stopLoading(): Promise<void> {\n await this.sendCommandToDebugger('Page.stopLoading', {});\n }\n\n async navigationState(): Promise<{ isLoading: boolean }> {\n const tabId = await this.getTabIdOrConnectToCurrentTab();\n const tab = await chrome.tabs.get(tabId);\n return { isLoading: tab.status === 'loading' };\n }\n\n async scrollUntilTop(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(0, -9999999);\n }\n\n async scrollUntilBottom(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(0, 9999999);\n }\n\n async scrollUntilLeft(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(-9999999, 0);\n }\n\n async scrollUntilRight(startingPoint?: Point) {\n if (startingPoint) {\n await this.mouse.move(startingPoint.left, startingPoint.top);\n }\n return this.mouse.wheel(9999999, 0);\n }\n\n async scrollUp(distance?: number, startingPoint?: Point) {\n const { height } = await this.size();\n const scrollDistance = distance || height * 0.7;\n return this.mouse.wheel(\n 0,\n -scrollDistance,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async scrollDown(distance?: number, startingPoint?: Point) {\n const { height } = await this.size();\n const scrollDistance = distance || height * 0.7;\n return this.mouse.wheel(\n 0,\n scrollDistance,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async scrollLeft(distance?: number, startingPoint?: Point) {\n const { width } = await this.size();\n const scrollDistance = distance || width * 0.7;\n return this.mouse.wheel(\n -scrollDistance,\n 0,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async scrollRight(distance?: number, startingPoint?: Point) {\n const { width } = await this.size();\n const scrollDistance = distance || width * 0.7;\n return this.mouse.wheel(\n scrollDistance,\n 0,\n startingPoint?.left,\n startingPoint?.top,\n );\n }\n\n async clearInput(element: ElementInfo) {\n if (!element) {\n console.warn('No element to clear input');\n return;\n }\n\n await this.mouse.click(element.center[0], element.center[1]);\n\n await this.sendCommandToDebugger('Input.dispatchKeyEvent', {\n type: 'keyDown',\n commands: ['selectAll'],\n });\n\n await this.sendCommandToDebugger('Input.dispatchKeyEvent', {\n type: 'keyUp',\n commands: ['selectAll'],\n });\n\n await sleep(100);\n\n await this.keyboard.press({\n key: 'Backspace',\n });\n }\n\n async selectAllInput(element?: ElementInfo) {\n if (element) {\n await this.mouse.click(element.center[0], element.center[1]);\n }\n const selectionResult = await this.sendCommandToDebugger(\n 'Runtime.evaluate',\n {\n expression: selectAllInputScript,\n returnByValue: true,\n },\n );\n if (selectionResult?.result?.value === true) {\n return;\n }\n\n if (!element) {\n throw new Error('Replacing text requires a focused editable field');\n }\n\n await this.sendCommandToDebugger('Input.dispatchKeyEvent', {\n type: 'keyDown',\n commands: ['selectAll'],\n });\n await this.sendCommandToDebugger('Input.dispatchKeyEvent', {\n type: 'keyUp',\n commands: ['selectAll'],\n });\n }\n\n private latestMouseX = 100;\n private latestMouseY = 100;\n\n mouse = {\n click: async (\n x: number,\n y: number,\n options?: { button?: MouseButton; count?: number },\n ) => {\n const { button = 'left', count = 1 } = options || {};\n await this.mouse.move(x, y);\n // detect if the page is in mobile emulation mode\n if (this.isMobileEmulation === null) {\n const result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `(() => {\n return /Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent);\n })()`,\n returnByValue: true,\n });\n this.isMobileEmulation = result?.result?.value;\n }\n\n if (this.isMobileEmulation && button === 'left') {\n // in mobile emulation mode, directly inject click event\n const touchPoints = [{ x: Math.round(x), y: Math.round(y) }];\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchStart',\n touchPoints,\n modifiers: 0,\n });\n\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchEnd',\n touchPoints: [],\n modifiers: 0,\n });\n } else {\n // standard mousePressed + mouseReleased\n for (let i = 0; i < count; i++) {\n const clickCount = i + 1;\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mousePressed',\n x,\n y,\n button,\n clickCount,\n });\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseReleased',\n x,\n y,\n button,\n clickCount,\n });\n if (i < count - 1) {\n await sleep(50);\n }\n }\n }\n },\n wheel: async (\n deltaX: number,\n deltaY: number,\n startX?: number,\n startY?: number,\n ) => {\n const finalX = startX || this.latestMouseX;\n const finalY = startY || this.latestMouseY;\n await this.showMousePointer(finalX, finalY);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseWheel',\n x: finalX,\n y: finalY,\n deltaX,\n deltaY,\n });\n this.latestMouseX = finalX;\n this.latestMouseY = finalY;\n },\n move: async (x: number, y: number) => {\n await this.showMousePointer(x, y);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseMoved',\n x,\n y,\n });\n this.latestMouseX = x;\n this.latestMouseY = y;\n },\n drag: async (\n from: { x: number; y: number },\n to: { x: number; y: number },\n ) => {\n await this.mouse.move(from.x, from.y);\n\n await sleep(200);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mousePressed',\n x: from.x,\n y: from.y,\n button: 'left',\n // CDP uses `buttons` to represent the currently pressed mouse buttons.\n // HTML5 drag/drop needs this state to treat following moves as dragging.\n buttons: 1,\n clickCount: 1,\n });\n\n await sleep(300);\n\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseMoved',\n x: to.x,\n y: to.y,\n button: 'left',\n buttons: 1,\n });\n\n await sleep(500);\n\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseReleased',\n x: to.x,\n y: to.y,\n button: 'left',\n buttons: 0,\n clickCount: 1,\n });\n\n await sleep(200);\n\n await this.mouse.move(to.x, to.y);\n },\n };\n\n keyboard = {\n type: async (text: string) => {\n const cdpKeyboard = new CdpKeyboard({\n send: this.sendCommandToDebugger.bind(this),\n });\n await cdpKeyboard.type(text, { delay: 0 });\n },\n insertText: async (text: string) => {\n await this.sendCommandToDebugger('Input.insertText', { text });\n },\n press: async (\n action:\n | { key: KeyInput; command?: string }\n | { key: KeyInput; command?: string }[],\n ) => {\n const cdpKeyboard = new CdpKeyboard({\n send: this.sendCommandToDebugger.bind(this),\n });\n const keys = Array.isArray(action) ? action : [action];\n for (const k of keys) {\n const commands = k.command ? [k.command] : [];\n await cdpKeyboard.down(k.key, { commands });\n }\n for (const k of [...keys].reverse()) {\n await cdpKeyboard.up(k.key);\n }\n },\n };\n\n async destroy(): Promise<void> {\n this.destroyed = true;\n this.clearFileChooserAccept();\n const tabIdToDetach = this.activeTabId;\n this.activeTabId = null;\n if (tabIdToDetach) {\n await this.detachDebugger(tabIdToDetach);\n }\n }\n\n async longPress(x: number, y: number, duration?: number) {\n duration = duration || 500;\n // Keep a lower bound so the press is registered as a long press rather than\n // a click, but never cap the upper bound: the duration is the caller's\n // intent (e.g. \"hold for 6 seconds\").\n const MIN_LONG_PRESS_DURATION = 300;\n if (duration < MIN_LONG_PRESS_DURATION) {\n duration = MIN_LONG_PRESS_DURATION;\n }\n await this.mouse.move(x, y);\n\n if (this.isMobileEmulation === null) {\n const result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `(() => {\n return /Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent);\n })()`,\n returnByValue: true,\n });\n this.isMobileEmulation = result?.result?.value;\n }\n\n if (this.isMobileEmulation) {\n const touchPoints = [{ x: Math.round(x), y: Math.round(y) }];\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchStart',\n touchPoints,\n modifiers: 0,\n });\n await new Promise((res) => setTimeout(res, duration));\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchEnd',\n touchPoints: [],\n modifiers: 0,\n });\n } else {\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mousePressed',\n x,\n y,\n button: 'left',\n clickCount: 1,\n });\n await new Promise((res) => setTimeout(res, duration));\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseReleased',\n x,\n y,\n button: 'left',\n clickCount: 1,\n });\n }\n this.latestMouseX = x;\n this.latestMouseY = y;\n }\n\n async swipe(\n from: { x: number; y: number },\n to: { x: number; y: number },\n duration?: number,\n ) {\n const LONG_PRESS_THRESHOLD = 500;\n const MIN_PRESS_THRESHOLD = 150;\n duration = duration || 300;\n if (duration < MIN_PRESS_THRESHOLD) {\n duration = MIN_PRESS_THRESHOLD;\n }\n if (duration > LONG_PRESS_THRESHOLD) {\n duration = LONG_PRESS_THRESHOLD;\n }\n\n if (this.isMobileEmulation === null) {\n const result = await this.sendCommandToDebugger('Runtime.evaluate', {\n expression: `(() => {\n return /Android|iPhone|iPad|iPod|Mobile/i.test(navigator.userAgent);\n })()`,\n returnByValue: true,\n });\n this.isMobileEmulation = result?.result?.value;\n }\n\n const steps = 30;\n const delay = duration / steps;\n\n if (this.isMobileEmulation) {\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchStart',\n touchPoints: [{ x: Math.round(from.x), y: Math.round(from.y) }],\n modifiers: 0,\n });\n\n for (let i = 1; i <= steps; i++) {\n const x = from.x + (to.x - from.x) * (i / steps);\n const y = from.y + (to.y - from.y) * (i / steps);\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchMove',\n touchPoints: [{ x: Math.round(x), y: Math.round(y) }],\n modifiers: 0,\n });\n await new Promise((res) => setTimeout(res, delay));\n }\n\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchEnd',\n touchPoints: [],\n modifiers: 0,\n });\n } else {\n await this.mouse.move(from.x, from.y);\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mousePressed',\n x: from.x,\n y: from.y,\n button: 'left',\n clickCount: 1,\n });\n\n for (let i = 1; i <= steps; i++) {\n const x = from.x + (to.x - from.x) * (i / steps);\n const y = from.y + (to.y - from.y) * (i / steps);\n await this.mouse.move(x, y);\n await new Promise((res) => setTimeout(res, delay));\n }\n\n await this.sendCommandToDebugger('Input.dispatchMouseEvent', {\n type: 'mouseReleased',\n x: to.x,\n y: to.y,\n button: 'left',\n clickCount: 1,\n });\n }\n\n this.latestMouseX = to.x;\n this.latestMouseY = to.y;\n }\n\n async pinch(\n centerX: number,\n centerY: number,\n startDistance: number,\n endDistance: number,\n duration = 500,\n ): Promise<void> {\n const steps = 30;\n const delay = duration / steps;\n\n const halfStart = startDistance / 2;\n const halfEnd = endDistance / 2;\n\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchStart',\n touchPoints: [\n {\n x: Math.round(centerX),\n y: Math.round(centerY - halfStart),\n id: 0,\n },\n {\n x: Math.round(centerX),\n y: Math.round(centerY + halfStart),\n id: 1,\n },\n ],\n modifiers: 0,\n });\n\n for (let i = 1; i <= steps; i++) {\n const progress = i / steps;\n const currentHalf = halfStart + (halfEnd - halfStart) * progress;\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchMove',\n touchPoints: [\n {\n x: Math.round(centerX),\n y: Math.round(centerY - currentHalf),\n id: 0,\n },\n {\n x: Math.round(centerX),\n y: Math.round(centerY + currentHalf),\n id: 1,\n },\n ],\n modifiers: 0,\n });\n await new Promise((res) => setTimeout(res, delay));\n }\n\n await this.sendCommandToDebugger('Input.dispatchTouchEvent', {\n type: 'touchEnd',\n touchPoints: [],\n modifiers: 0,\n });\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debug","getDebug","sleep","ms","Promise","resolve","setTimeout","NAVIGATION_COMPLETE_TIMEOUT_MS","isBlankUrl","url","waitForTabNavigationComplete","tabId","targetUrl","updatedTab","timeoutMs","settled","finish","chrome","onUpdated","clearTimeout","timer","isTargetTab","tab","isReady","navigationUpdateObserved","currentUrl","isExpectedUrlKind","id","info","hasFlatNodeAttribute","attributes","name","i","serializeError","error","ChromeExtensionProxyPage","commonWebActionsForWebPage","options","Error","tabs","assert","console","errorMsg","err","x","y","pointerScript","tabIdToDetach","limitOpenNewTabScript","script","injectWaterFlowAnimation","injectStopWaterFlowAnimation","enabled","command","params","retryCount","MAX_RETRIES","result","isDetachError","getHtmlElementScript","expression","tree","window","document","returnValue","errorDescription","handler","registrationVersion","undefined","capturedError","pendingFileChooserHandling","fileChooserEventHandler","source","method","event","currentFileChooserHandling","files","node","hasWebkitDirectory","String","previousFileChooserHandling","dispose","getError","chooser","timeout","startTime","Date","lastReadyState","attachError","treeToList","point","isOrderSensitive","xpath","JSON","center","judgeOrderSensitive","xpaths","sanitizeXpaths","feature","elementInfo","buildRectFromElementInfo","content","sizeInfo","format","base64","createImgBase64ByFormat","startingPoint","distance","height","scrollDistance","width","element","selectionResult","selectAllInputScript","duration","MIN_LONG_PRESS_DURATION","touchPoints","Math","res","from","to","LONG_PRESS_THRESHOLD","MIN_PRESS_THRESHOLD","steps","delay","centerX","centerY","startDistance","endDistance","halfStart","halfEnd","progress","currentHalf","forceSameTabNavigation","inputOptions","button","count","clickCount","deltaX","deltaY","startX","startY","finalX","finalY","text","cdpKeyboard","CdpKeyboard","action","keys","Array","k","commands"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO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A,OAAO,OACLG;gBAIA,MAAMF,cAAc,IAAIC,qCAAAA,WAAWA,CAAC;oBAClC,MAAM,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI;gBAC5C;gBACA,MAAME,OAAOC,MAAM,OAAO,CAACF,UAAUA,SAAS;oBAACA;iBAAO;gBACtD,KAAK,MAAMG,KAAKF,KAAM;oBACpB,MAAMG,WAAWD,EAAE,OAAO,GAAG;wBAACA,EAAE,OAAO;qBAAC,GAAG,EAAE;oBAC7C,MAAML,YAAY,IAAI,CAACK,EAAE,GAAG,EAAE;wBAAEC;oBAAS;gBAC3C;gBACA,KAAK,MAAMD,KAAK;uBAAIF;iBAAK,CAAC,OAAO,GAC/B,MAAMH,YAAY,EAAE,CAACK,EAAE,GAAG;YAE9B;QACF;QAr8BE,IAAI,CAAC,sBAAsB,GAAGjB;QAC9B,IAAI,CAAC,iBAAiB,GAAGC,cAAc;QACvC,IAAI,CAAC,aAAa,GAAGA,cAAc;IACrC;AAgpCF"}
package/dist/lib/cli.js CHANGED
@@ -42,7 +42,7 @@ Promise.resolve().then(()=>{
42
42
  return (0, cli_namespaceObject.runToolsCLI)(tools, 'midscene-web', {
43
43
  stripPrefix: 'web_',
44
44
  argv: parsedOptions.argv,
45
- version: "1.17.3",
45
+ version: "1.17.4",
46
46
  extraCommands: (0, core_namespaceObject.createReportCliCommands)()
47
47
  });
48
48
  }).catch((e)=>{
@@ -24,8 +24,18 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
+ focusedInputFrameScript: ()=>focusedInputFrameScript,
27
28
  selectAllInputScript: ()=>selectAllInputScript
28
29
  });
30
+ const focusedInputFrameScript = `(() => {
31
+ let element = document.activeElement;
32
+ while (element?.shadowRoot?.activeElement) {
33
+ element = element.shadowRoot.activeElement;
34
+ }
35
+ return element instanceof HTMLIFrameElement || element instanceof HTMLFrameElement
36
+ ? element
37
+ : null;
38
+ })()`;
29
39
  const selectAllInputScript = `(() => {
30
40
  let activeElement = document.activeElement;
31
41
  while (activeElement?.shadowRoot?.activeElement) {
@@ -56,8 +66,10 @@ const selectAllInputScript = `(() => {
56
66
 
57
67
  return false;
58
68
  })()`;
69
+ exports.focusedInputFrameScript = __webpack_exports__.focusedInputFrameScript;
59
70
  exports.selectAllInputScript = __webpack_exports__.selectAllInputScript;
60
71
  for(var __rspack_i in __webpack_exports__)if (-1 === [
72
+ "focusedInputFrameScript",
61
73
  "selectAllInputScript"
62
74
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
63
75
  Object.defineProperty(exports, '__esModule', {
@@ -1 +1 @@
1
- {"version":3,"file":"common/input-scripts.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/common/input-scripts.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * Select all editable content in the currently focused element.\n *\n * Keep this as source text instead of a closure: both Playwright/Puppeteer and\n * the Chrome extension execute it in a browser realm where Node-side coverage\n * counters and module bindings do not exist.\n */\nexport const selectAllInputScript = `(() => {\n let activeElement = document.activeElement;\n while (activeElement?.shadowRoot?.activeElement) {\n activeElement = activeElement.shadowRoot.activeElement;\n }\n\n if (\n activeElement instanceof HTMLInputElement ||\n activeElement instanceof HTMLTextAreaElement\n ) {\n try {\n activeElement.select();\n return true;\n } catch {\n return false;\n }\n }\n\n if (activeElement instanceof HTMLElement && activeElement.isContentEditable) {\n const selection = window.getSelection();\n if (!selection) return false;\n const range = document.createRange();\n range.selectNodeContents(activeElement);\n selection.removeAllRanges();\n selection.addRange(range);\n return true;\n }\n\n return false;\n})()`;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","selectAllInputScript"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;ACCO,MAAMI,uBAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6BjC,CAAC"}
1
+ {"version":3,"file":"common/input-scripts.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/common/input-scripts.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/**\n * Select all editable content in the currently focused element.\n *\n * Keep this as source text instead of a closure: both Playwright/Puppeteer and\n * the Chrome extension execute it in a browser realm where Node-side coverage\n * counters and module bindings do not exist.\n */\nexport const focusedInputFrameScript = `(() => {\n let element = document.activeElement;\n while (element?.shadowRoot?.activeElement) {\n element = element.shadowRoot.activeElement;\n }\n return element instanceof HTMLIFrameElement || element instanceof HTMLFrameElement\n ? element\n : null;\n})()`;\n\nexport const selectAllInputScript = `(() => {\n let activeElement = document.activeElement;\n while (activeElement?.shadowRoot?.activeElement) {\n activeElement = activeElement.shadowRoot.activeElement;\n }\n\n if (\n activeElement instanceof HTMLInputElement ||\n activeElement instanceof HTMLTextAreaElement\n ) {\n try {\n activeElement.select();\n return true;\n } catch {\n return false;\n }\n }\n\n if (activeElement instanceof HTMLElement && activeElement.isContentEditable) {\n const selection = window.getSelection();\n if (!selection) return false;\n const range = document.createRange();\n range.selectNodeContents(activeElement);\n selection.removeAllRanges();\n selection.addRange(range);\n return true;\n }\n\n return false;\n})()`;\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","focusedInputFrameScript","selectAllInputScript"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;ACCO,MAAMI,0BAA0B,CAAC;;;;;;;;IAQpC,CAAC;AAEE,MAAMC,uBAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6BjC,CAAC"}