@rpascene/web 0.30.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/bin/midscene-playground +3 -0
- package/dist/es/bin.mjs +26 -0
- package/dist/es/bin.mjs.map +1 -0
- package/dist/es/bridge-mode/agent-cli-side.mjs +117 -0
- package/dist/es/bridge-mode/agent-cli-side.mjs.map +1 -0
- package/dist/es/bridge-mode/browser.mjs +2 -0
- package/dist/es/bridge-mode/common.mjs +37 -0
- package/dist/es/bridge-mode/common.mjs.map +1 -0
- package/dist/es/bridge-mode/index.mjs +4 -0
- package/dist/es/bridge-mode/io-client.mjs +101 -0
- package/dist/es/bridge-mode/io-client.mjs.map +1 -0
- package/dist/es/bridge-mode/io-server.mjs +208 -0
- package/dist/es/bridge-mode/io-server.mjs.map +1 -0
- package/dist/es/bridge-mode/page-browser-side.mjs +103 -0
- package/dist/es/bridge-mode/page-browser-side.mjs.map +1 -0
- package/dist/es/chrome-extension/agent.mjs +9 -0
- package/dist/es/chrome-extension/agent.mjs.map +1 -0
- package/dist/es/chrome-extension/cdpInput.mjs +174 -0
- package/dist/es/chrome-extension/cdpInput.mjs.LICENSE.txt +5 -0
- package/dist/es/chrome-extension/cdpInput.mjs.map +1 -0
- package/dist/es/chrome-extension/dynamic-scripts.mjs +37 -0
- package/dist/es/chrome-extension/dynamic-scripts.mjs.map +1 -0
- package/dist/es/chrome-extension/index.mjs +5 -0
- package/dist/es/chrome-extension/page.mjs +633 -0
- package/dist/es/chrome-extension/page.mjs.map +1 -0
- package/dist/es/index.mjs +6 -0
- package/dist/es/playwright/ai-fixture.mjs +325 -0
- package/dist/es/playwright/ai-fixture.mjs.map +1 -0
- package/dist/es/playwright/index.mjs +23 -0
- package/dist/es/playwright/index.mjs.map +1 -0
- package/dist/es/playwright/page.mjs +9 -0
- package/dist/es/playwright/page.mjs.map +1 -0
- package/dist/es/playwright/reporter/index.mjs +90 -0
- package/dist/es/playwright/reporter/index.mjs.map +1 -0
- package/dist/es/puppeteer/agent-launcher.mjs +132 -0
- package/dist/es/puppeteer/agent-launcher.mjs.map +1 -0
- package/dist/es/puppeteer/base-page.mjs +491 -0
- package/dist/es/puppeteer/base-page.mjs.map +1 -0
- package/dist/es/puppeteer/index.mjs +17 -0
- package/dist/es/puppeteer/index.mjs.map +1 -0
- package/dist/es/puppeteer/page.mjs +9 -0
- package/dist/es/puppeteer/page.mjs.map +1 -0
- package/dist/es/static/index.mjs +3 -0
- package/dist/es/static/static-agent.mjs +10 -0
- package/dist/es/static/static-agent.mjs.map +1 -0
- package/dist/es/static/static-page.mjs +132 -0
- package/dist/es/static/static-page.mjs.map +1 -0
- package/dist/es/web-element.mjs +96 -0
- package/dist/es/web-element.mjs.map +1 -0
- package/dist/es/web-page.mjs +206 -0
- package/dist/es/web-page.mjs.map +1 -0
- package/dist/lib/bin.js +54 -0
- package/dist/lib/bin.js.map +1 -0
- package/dist/lib/bridge-mode/agent-cli-side.js +154 -0
- package/dist/lib/bridge-mode/agent-cli-side.js.map +1 -0
- package/dist/lib/bridge-mode/browser.js +38 -0
- package/dist/lib/bridge-mode/browser.js.map +1 -0
- package/dist/lib/bridge-mode/common.js +95 -0
- package/dist/lib/bridge-mode/common.js.map +1 -0
- package/dist/lib/bridge-mode/index.js +46 -0
- package/dist/lib/bridge-mode/index.js.map +1 -0
- package/dist/lib/bridge-mode/io-client.js +135 -0
- package/dist/lib/bridge-mode/io-client.js.map +1 -0
- package/dist/lib/bridge-mode/io-server.js +245 -0
- package/dist/lib/bridge-mode/io-server.js.map +1 -0
- package/dist/lib/bridge-mode/page-browser-side.js +147 -0
- package/dist/lib/bridge-mode/page-browser-side.js.map +1 -0
- package/dist/lib/chrome-extension/agent.js +43 -0
- package/dist/lib/chrome-extension/agent.js.map +1 -0
- package/dist/lib/chrome-extension/cdpInput.js +208 -0
- package/dist/lib/chrome-extension/cdpInput.js.LICENSE.txt +5 -0
- package/dist/lib/chrome-extension/cdpInput.js.map +1 -0
- package/dist/lib/chrome-extension/dynamic-scripts.js +77 -0
- package/dist/lib/chrome-extension/dynamic-scripts.js.map +1 -0
- package/dist/lib/chrome-extension/index.js +60 -0
- package/dist/lib/chrome-extension/index.js.map +1 -0
- package/dist/lib/chrome-extension/page.js +667 -0
- package/dist/lib/chrome-extension/page.js.map +1 -0
- package/dist/lib/index.js +60 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/playwright/ai-fixture.js +362 -0
- package/dist/lib/playwright/ai-fixture.js.map +1 -0
- package/dist/lib/playwright/index.js +66 -0
- package/dist/lib/playwright/index.js.map +1 -0
- package/dist/lib/playwright/page.js +43 -0
- package/dist/lib/playwright/page.js.map +1 -0
- package/dist/lib/playwright/reporter/index.js +124 -0
- package/dist/lib/playwright/reporter/index.js.map +1 -0
- package/dist/lib/puppeteer/agent-launcher.js +194 -0
- package/dist/lib/puppeteer/agent-launcher.js.map +1 -0
- package/dist/lib/puppeteer/base-page.js +531 -0
- package/dist/lib/puppeteer/base-page.js.map +1 -0
- package/dist/lib/puppeteer/index.js +57 -0
- package/dist/lib/puppeteer/index.js.map +1 -0
- package/dist/lib/puppeteer/page.js +43 -0
- package/dist/lib/puppeteer/page.js.map +1 -0
- package/dist/lib/static/index.js +52 -0
- package/dist/lib/static/index.js.map +1 -0
- package/dist/lib/static/static-agent.js +44 -0
- package/dist/lib/static/static-agent.js.map +1 -0
- package/dist/lib/static/static-page.js +166 -0
- package/dist/lib/static/static-page.js.map +1 -0
- package/dist/lib/web-element.js +136 -0
- package/dist/lib/web-element.js.map +1 -0
- package/dist/lib/web-page.js +256 -0
- package/dist/lib/web-page.js.map +1 -0
- package/dist/types/bin.d.ts +1 -0
- package/dist/types/bridge-mode/agent-cli-side.d.ts +32 -0
- package/dist/types/bridge-mode/browser.d.ts +2 -0
- package/dist/types/bridge-mode/common.d.ts +60 -0
- package/dist/types/bridge-mode/index.d.ts +4 -0
- package/dist/types/bridge-mode/io-client.d.ts +10 -0
- package/dist/types/bridge-mode/io-server.d.ts +26 -0
- package/dist/types/bridge-mode/page-browser-side.d.ts +18 -0
- package/dist/types/chrome-extension/agent.d.ts +5 -0
- package/dist/types/chrome-extension/cdpInput.d.ts +52 -0
- package/dist/types/chrome-extension/dynamic-scripts.d.ts +3 -0
- package/dist/types/chrome-extension/index.d.ts +5 -0
- package/dist/types/chrome-extension/page.d.ts +95 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/playwright/ai-fixture.d.ts +117 -0
- package/dist/types/playwright/index.d.ts +12 -0
- package/dist/types/playwright/page.d.ts +6 -0
- package/dist/types/playwright/reporter/index.d.ts +18 -0
- package/dist/types/puppeteer/agent-launcher.d.ts +29 -0
- package/dist/types/puppeteer/base-page.d.ts +90 -0
- package/dist/types/puppeteer/index.d.ts +9 -0
- package/dist/types/puppeteer/page.d.ts +6 -0
- package/dist/types/static/index.d.ts +2 -0
- package/dist/types/static/static-agent.d.ts +5 -0
- package/dist/types/static/static-page.d.ts +52 -0
- package/dist/types/web-element.d.ts +51 -0
- package/dist/types/web-page.d.ts +59 -0
- package/package.json +164 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-page.mjs","sources":["webpack://@rpascene/web/./src/web-page.ts"],"sourcesContent":["import assert from 'node:assert';\nimport type { Point } from '@rpascene/core';\nimport {\n AbstractInterface,\n type DeviceAction,\n defineActionClearInput,\n defineActionDoubleClick,\n defineActionDragAndDrop,\n defineActionHover,\n defineActionInput,\n defineActionKeyboardPress,\n defineActionLongPress,\n defineActionRightClick,\n defineActionScroll,\n defineActionSwipe,\n defineActionTap,\n} from '@rpascene/core/device';\n\nimport { sleep } from '@rpascene/core/utils';\nimport type { ElementInfo } from '@rpascene/shared/extractor';\nimport { getDebug } from '@rpascene/shared/logger';\nimport { transformHotkeyInput } from '@rpascene/shared/us-keyboard-layout';\n\nconst debug = getDebug('web:page');\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) => 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 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) => { },\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 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}\n// 通用页面操作\nexport const commonWebActionsForWebPage = <T extends AbstractWebPage>(\n page: T,\n): DeviceAction<any>[] => [\n defineActionTap(async (param) => {\n const element = param.locate;\n assert(element, 'Element not found, cannot tap');\n await page.mouse.click(element.center[0], element.center[1], {\n button: 'left',\n });\n }),\n defineActionRightClick(async (param) => {\n const element = param.locate;\n assert(element, 'Element not found, cannot right click');\n await page.mouse.click(element.center[0], element.center[1], {\n button: 'right',\n });\n }),\n defineActionDoubleClick(async (param) => {\n const element = param.locate;\n assert(element, 'Element not found, cannot double click');\n\n await page.mouse.click(element.center[0], element.center[1], {\n button: 'left',\n count: 2,\n });\n }),\n defineActionHover(async (param) => {\n const element = param.locate;\n assert(element, 'Element not found, cannot hover');\n await page.mouse.move(element.center[0], element.center[1]);\n }),\n defineActionInput(async (param) => {\n const element = param.locate;\n if (element && param.mode !== 'append') {\n await page.clearInput(element as unknown as ElementInfo);\n }\n\n if (param.mode === 'clear') {\n // Clear mode removes existing text without entering new characters\n return;\n }\n\n if (!param || !param.value) {\n return;\n }\n\n // Note: there is another implementation in AndroidDevicePage, which is more complex\n await page.keyboard.type(param.value);\n }),\n defineActionKeyboardPress(async (param) => {\n const element = param.locate;\n if (element) {\n await page.mouse.click(element.center[0], element.center[1], {\n button: 'left',\n });\n }\n\n const keys = getKeyCommands(param.keyName);\n await page.keyboard.press(keys as any); // TODO: fix this type error\n }),\n defineActionScroll(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 === 'untilTop') {\n await page.scrollUntilTop(startingPoint);\n } else if (scrollToEventName === 'untilBottom') {\n await page.scrollUntilBottom(startingPoint);\n } else if (scrollToEventName === 'untilRight') {\n await page.scrollUntilRight(startingPoint);\n } else if (scrollToEventName === 'untilLeft') {\n await page.scrollUntilLeft(startingPoint);\n } else if (scrollToEventName === 'once' || !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 // until mouse event is done\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 }),\n defineActionDragAndDrop(async (param) => {\n const from = param.from;\n const to = param.to;\n assert(from, 'missing \"from\" param for drag and drop');\n assert(to, 'missing \"to\" param for drag and drop');\n await page.mouse.drag(\n {\n x: from.center[0],\n y: from.center[1],\n },\n {\n x: to.center[0],\n y: to.center[1],\n },\n );\n }),\n\n defineActionLongPress(async (param) => {\n const element = param.locate;\n assert(element, 'Element not found, cannot long press');\n const duration = param?.duration;\n await page.longPress(element.center[0], element.center[1], duration);\n }),\n\n defineActionSwipe(async (param) => {\n const { width, height } = await page.size();\n const { start, end } = param;\n\n const startPoint = start\n ? {\n x: start.center[0],\n y: start.center[1],\n }\n : {\n x: width / 2,\n y: height / 2,\n };\n\n let endPoint: {\n x: number;\n y: number;\n };\n\n if (end) {\n endPoint = {\n x: end.center[0],\n y: end.center[1],\n };\n } else if (param.distance) {\n const direction = param.direction;\n if (!direction) {\n throw new Error('direction is required for swipe gesture');\n }\n\n endPoint = {\n x:\n startPoint.x +\n (direction === 'right'\n ? param.distance\n : direction === 'left'\n ? -param.distance\n : 0),\n y:\n startPoint.y +\n (direction === 'down'\n ? param.distance\n : direction === 'up'\n ? -param.distance\n : 0),\n };\n } else {\n throw new Error(\n 'Either end or distance must be specified for swipe gesture',\n );\n }\n\n // Ensure end coordinates are within bounds\n endPoint.x = Math.max(0, Math.min(endPoint.x, width));\n endPoint.y = Math.max(0, Math.min(endPoint.y, height));\n\n const duration = param.duration;\n\n debug(\n `swipe from ${startPoint.x}, ${startPoint.y} to ${endPoint.x}, ${endPoint.y} with duration ${duration}ms, repeat is set to ${param.repeat}`,\n );\n let repeat = typeof param.repeat === 'number' ? param.repeat : 1;\n if (repeat === 0) {\n repeat = 10; // 10 times is enough for infinite swipe\n }\n for (let i = 0; i < repeat; i++) {\n await page.swipe(startPoint, endPoint, duration);\n }\n }),\n\n defineActionClearInput(async (param) => {\n const element = param.locate;\n assert(element, 'Element not found, cannot clear input');\n await page.clearInput(element as unknown as ElementInfo);\n }),\n ];\n"],"names":["debug","getDebug","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","commonWebActionsForWebPage","page","defineActionTap","param","assert","defineActionRightClick","defineActionDoubleClick","defineActionHover","defineActionInput","defineActionKeyboardPress","defineActionScroll","startingPoint","undefined","scrollToEventName","Error","JSON","sleep","defineActionDragAndDrop","defineActionLongPress","duration","defineActionSwipe","width","height","start","end","startPoint","endPoint","direction","Math","repeat","i","defineActionClearInput"],"mappings":";;;;;AAuBA,MAAMA,QAAQC,SAAS;AAEvB,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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require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
var __webpack_exports__ = {};
|
|
24
|
+
const playground_namespaceObject = require("@rpascene/playground");
|
|
25
|
+
const external_cors_namespaceObject = require("cors");
|
|
26
|
+
var external_cors_default = /*#__PURE__*/ __webpack_require__.n(external_cors_namespaceObject);
|
|
27
|
+
const index_js_namespaceObject = require("./static/index.js");
|
|
28
|
+
require("dotenv/config");
|
|
29
|
+
const page = new index_js_namespaceObject.StaticPage({
|
|
30
|
+
tree: {
|
|
31
|
+
node: null,
|
|
32
|
+
children: []
|
|
33
|
+
},
|
|
34
|
+
size: {
|
|
35
|
+
width: 800,
|
|
36
|
+
height: 600
|
|
37
|
+
},
|
|
38
|
+
screenshotBase64: ''
|
|
39
|
+
});
|
|
40
|
+
const agent = new index_js_namespaceObject.StaticPageAgent(page);
|
|
41
|
+
const server = new playground_namespaceObject.PlaygroundServer(agent);
|
|
42
|
+
server.app.use(external_cors_default()({
|
|
43
|
+
origin: '*',
|
|
44
|
+
credentials: true
|
|
45
|
+
}));
|
|
46
|
+
Promise.resolve().then(()=>server.launch()).then(()=>{
|
|
47
|
+
console.log(`Rpascene playground server is running on http://localhost:${server.port}`);
|
|
48
|
+
});
|
|
49
|
+
for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
50
|
+
Object.defineProperty(exports, '__esModule', {
|
|
51
|
+
value: true
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=bin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sources":["webpack://@rpascene/web/webpack/runtime/compat_get_default_export","webpack://@rpascene/web/webpack/runtime/define_property_getters","webpack://@rpascene/web/webpack/runtime/has_own_property","webpack://@rpascene/web/./src/bin.ts"],"sourcesContent":["// getDefaultExport function for compatibility with non-ESM modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};\n","__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))","import { PlaygroundServer } from '@rpascene/playground';\nimport cors from 'cors';\nimport { StaticPage, StaticPageAgent } from './static';\nimport 'dotenv/config';\n\n// Create page and agent instances with minimal valid data\nconst page = new StaticPage({\n tree: {\n node: null,\n children: [],\n },\n size: { width: 800, height: 600 },\n screenshotBase64: '',\n});\nconst agent = new StaticPageAgent(page);\n\n// Create server with agent only\nconst server = new PlaygroundServer(agent);\n\n// Register CORS middleware\nserver.app.use(\n cors({\n origin: '*',\n credentials: true,\n }),\n);\n\nPromise.resolve()\n .then(() => server.launch())\n .then(() => {\n console.log(\n `Rpascene playground server is running on http://localhost:${server.port}`,\n );\n });\n"],"names":["__webpack_require__","module","getter","definition","key","Object","obj","prop","page","StaticPage","agent","StaticPageAgent","server","PlaygroundServer","cors","Promise","console"],"mappings":";;;IACAA,oBAAoB,CAAC,GAAG,CAACC;QACxB,IAAIC,SAASD,UAAUA,OAAO,UAAU,GACvC,IAAOA,MAAM,CAAC,UAAU,GACxB,IAAOA;QACRD,oBAAoB,CAAC,CAACE,QAAQ;YAAE,GAAGA;QAAO;QAC1C,OAAOA;IACR;;;ICPAF,oBAAoB,CAAC,GAAG,CAAC,UAASG;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGH,oBAAoB,CAAC,CAACG,YAAYC,QAAQ,CAACJ,oBAAoB,CAAC,CAAC,UAASI,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAJ,oBAAoB,CAAC,GAAG,CAACM,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;;;;;;ACMlF,MAAMC,OAAO,IAAIC,yBAAAA,UAAUA,CAAC;IAC1B,MAAM;QACJ,MAAM;QACN,UAAU,EAAE;IACd;IACA,MAAM;QAAE,OAAO;QAAK,QAAQ;IAAI;IAChC,kBAAkB;AACpB;AACA,MAAMC,QAAQ,IAAIC,yBAAAA,eAAeA,CAACH;AAGlC,MAAMI,SAAS,IAAIC,2BAAAA,gBAAgBA,CAACH;AAGpCE,OAAO,GAAG,CAAC,GAAG,CACZE,wBAAK;IACH,QAAQ;IACR,aAAa;AACf;AAGFC,QAAQ,OAAO,GACZ,IAAI,CAAC,IAAMH,OAAO,MAAM,IACxB,IAAI,CAAC;IACJI,QAAQ,GAAG,CACT,CAAC,0DAA0D,EAAEJ,OAAO,IAAI,EAAE;AAE9E"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
AgentOverChromeBridge: ()=>AgentOverChromeBridge,
|
|
28
|
+
getBridgePageInCliSide: ()=>getBridgePageInCliSide
|
|
29
|
+
});
|
|
30
|
+
const agent_namespaceObject = require("@rpascene/core/agent");
|
|
31
|
+
const utils_namespaceObject = require("@rpascene/shared/utils");
|
|
32
|
+
const external_web_page_js_namespaceObject = require("../web-page.js");
|
|
33
|
+
const external_common_js_namespaceObject = require("./common.js");
|
|
34
|
+
const external_io_server_js_namespaceObject = require("./io-server.js");
|
|
35
|
+
function _define_property(obj, key, value) {
|
|
36
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
37
|
+
value: value,
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true
|
|
41
|
+
});
|
|
42
|
+
else obj[key] = value;
|
|
43
|
+
return obj;
|
|
44
|
+
}
|
|
45
|
+
const sleep = (ms)=>new Promise((resolve)=>setTimeout(resolve, ms));
|
|
46
|
+
const getBridgePageInCliSide = (timeout, closeConflictServer)=>{
|
|
47
|
+
const server = new external_io_server_js_namespaceObject.BridgeServer(external_common_js_namespaceObject.DefaultBridgeServerPort, void 0, void 0, closeConflictServer);
|
|
48
|
+
server.listen({
|
|
49
|
+
timeout
|
|
50
|
+
});
|
|
51
|
+
const bridgeCaller = (method)=>async (...args)=>{
|
|
52
|
+
const response = await server.call(method, args);
|
|
53
|
+
return response;
|
|
54
|
+
};
|
|
55
|
+
const page = {
|
|
56
|
+
showStatusMessage: async (message)=>{
|
|
57
|
+
await server.call(external_common_js_namespaceObject.BridgeEvent.UpdateAgentStatus, [
|
|
58
|
+
message
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const proxyPage = new Proxy(page, {
|
|
63
|
+
get (target, prop, receiver) {
|
|
64
|
+
(0, utils_namespaceObject.assert)('string' == typeof prop, 'prop must be a string');
|
|
65
|
+
if ('toJSON' === prop) return ()=>({
|
|
66
|
+
interfaceType: external_common_js_namespaceObject.BridgePageType
|
|
67
|
+
});
|
|
68
|
+
if ('getContext' === prop) return;
|
|
69
|
+
if ('interfaceType' === prop) return external_common_js_namespaceObject.BridgePageType;
|
|
70
|
+
if ('actionSpace' === prop) return ()=>(0, external_web_page_js_namespaceObject.commonWebActionsForWebPage)(proxyPage);
|
|
71
|
+
if (Object.keys(page).includes(prop)) return page[prop];
|
|
72
|
+
if ('mouse' === prop) {
|
|
73
|
+
const mouse = {
|
|
74
|
+
click: bridgeCaller(external_common_js_namespaceObject.MouseEvent.Click),
|
|
75
|
+
wheel: bridgeCaller(external_common_js_namespaceObject.MouseEvent.Wheel),
|
|
76
|
+
move: bridgeCaller(external_common_js_namespaceObject.MouseEvent.Move),
|
|
77
|
+
drag: bridgeCaller(external_common_js_namespaceObject.MouseEvent.Drag)
|
|
78
|
+
};
|
|
79
|
+
return mouse;
|
|
80
|
+
}
|
|
81
|
+
if ('keyboard' === prop) {
|
|
82
|
+
const keyboard = {
|
|
83
|
+
type: bridgeCaller(external_common_js_namespaceObject.KeyboardEvent.Type),
|
|
84
|
+
press: bridgeCaller(external_common_js_namespaceObject.KeyboardEvent.Press)
|
|
85
|
+
};
|
|
86
|
+
return keyboard;
|
|
87
|
+
}
|
|
88
|
+
if ('destroy' === prop) return async (...args)=>{
|
|
89
|
+
try {
|
|
90
|
+
const caller = bridgeCaller('destroy');
|
|
91
|
+
await caller(...args);
|
|
92
|
+
} catch (e) {}
|
|
93
|
+
return server.close();
|
|
94
|
+
};
|
|
95
|
+
return bridgeCaller(prop);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return proxyPage;
|
|
99
|
+
};
|
|
100
|
+
class AgentOverChromeBridge extends agent_namespaceObject.Agent {
|
|
101
|
+
async setDestroyOptionsAfterConnect() {
|
|
102
|
+
if (this.destroyAfterDisconnectFlag) this.page.setDestroyOptions({
|
|
103
|
+
closeTab: true
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async connectNewTabWithUrl(url, options) {
|
|
107
|
+
await this.page.connectNewTabWithUrl(url, options);
|
|
108
|
+
await sleep(500);
|
|
109
|
+
await this.setDestroyOptionsAfterConnect();
|
|
110
|
+
}
|
|
111
|
+
async getBrowserTabList() {
|
|
112
|
+
return await this.page.getBrowserTabList();
|
|
113
|
+
}
|
|
114
|
+
async setActiveTabId(tabId) {
|
|
115
|
+
return await this.page.setActiveTabId(Number.parseInt(tabId));
|
|
116
|
+
}
|
|
117
|
+
async connectCurrentTab(options) {
|
|
118
|
+
await this.page.connectCurrentTab(options);
|
|
119
|
+
await sleep(500);
|
|
120
|
+
await this.setDestroyOptionsAfterConnect();
|
|
121
|
+
}
|
|
122
|
+
async aiAction(prompt, options) {
|
|
123
|
+
if (options) console.warn('the `options` parameter of aiAction is not supported in cli side');
|
|
124
|
+
return await super.aiAction(prompt);
|
|
125
|
+
}
|
|
126
|
+
async destroy(closeNewTabsAfterDisconnect) {
|
|
127
|
+
if ('boolean' == typeof closeNewTabsAfterDisconnect) await this.page.setDestroyOptions({
|
|
128
|
+
closeTab: closeNewTabsAfterDisconnect
|
|
129
|
+
});
|
|
130
|
+
await super.destroy();
|
|
131
|
+
}
|
|
132
|
+
constructor(opts){
|
|
133
|
+
const page = getBridgePageInCliSide(null == opts ? void 0 : opts.serverListeningTimeout);
|
|
134
|
+
const originalOnTaskStartTip = null == opts ? void 0 : opts.onTaskStartTip;
|
|
135
|
+
super(page, Object.assign(opts || {}, {
|
|
136
|
+
onTaskStartTip: (tip)=>{
|
|
137
|
+
this.page.showStatusMessage(tip);
|
|
138
|
+
if (originalOnTaskStartTip) null == originalOnTaskStartTip || originalOnTaskStartTip.call(this, tip);
|
|
139
|
+
}
|
|
140
|
+
})), _define_property(this, "destroyAfterDisconnectFlag", void 0);
|
|
141
|
+
this.destroyAfterDisconnectFlag = null == opts ? void 0 : opts.closeNewTabsAfterDisconnect;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.AgentOverChromeBridge = __webpack_exports__.AgentOverChromeBridge;
|
|
145
|
+
exports.getBridgePageInCliSide = __webpack_exports__.getBridgePageInCliSide;
|
|
146
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
147
|
+
"AgentOverChromeBridge",
|
|
148
|
+
"getBridgePageInCliSide"
|
|
149
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
150
|
+
Object.defineProperty(exports, '__esModule', {
|
|
151
|
+
value: true
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
//# sourceMappingURL=agent-cli-side.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-mode\\agent-cli-side.js","sources":["webpack://@rpascene/web/webpack/runtime/define_property_getters","webpack://@rpascene/web/webpack/runtime/has_own_property","webpack://@rpascene/web/webpack/runtime/make_namespace_object","webpack://@rpascene/web/./src/bridge-mode/agent-cli-side.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};","import { Agent, type AgentOpt } from '@rpascene/core/agent';\nimport { assert } from '@rpascene/shared/utils';\nimport { commonWebActionsForWebPage } from '../web-page';\nimport type { KeyboardAction, MouseAction } from '../web-page';\nimport {\n type BridgeConnectTabOptions,\n BridgeEvent,\n BridgePageType,\n DefaultBridgeServerPort,\n KeyboardEvent,\n MouseEvent,\n} from './common';\nimport { BridgeServer } from './io-server';\nimport type { ExtensionBridgePageBrowserSide } from './page-browser-side';\n\ninterface ChromeExtensionPageCliSide extends ExtensionBridgePageBrowserSide {\n showStatusMessage: (message: string) => Promise<void>;\n}\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\n// actually, this is a proxy to the page in browser side\nexport const getBridgePageInCliSide = (\n timeout?: number | false,\n closeConflictServer?: boolean,\n): ChromeExtensionPageCliSide => {\n const server = new BridgeServer(\n DefaultBridgeServerPort,\n undefined,\n undefined,\n closeConflictServer,\n );\n server.listen({\n timeout,\n });\n const bridgeCaller = (method: string) => {\n return async (...args: any[]) => {\n const response = await server.call(method, args);\n return response;\n };\n };\n const page = {\n showStatusMessage: async (message: string) => {\n await server.call(BridgeEvent.UpdateAgentStatus, [message]);\n },\n };\n\n const proxyPage = new Proxy(page, {\n get(target, prop, receiver) {\n assert(typeof prop === 'string', 'prop must be a string');\n\n if (prop === 'toJSON') {\n return () => {\n return {\n interfaceType: BridgePageType,\n };\n };\n }\n\n if (prop === 'getContext') {\n return undefined;\n }\n\n if (prop === 'interfaceType') {\n return BridgePageType;\n }\n\n if (prop === 'actionSpace') {\n return () => commonWebActionsForWebPage(proxyPage);\n }\n\n if (Object.keys(page).includes(prop)) {\n return page[prop as keyof typeof page];\n }\n\n if (prop === 'mouse') {\n const mouse: MouseAction = {\n click: bridgeCaller(MouseEvent.Click),\n wheel: bridgeCaller(MouseEvent.Wheel),\n move: bridgeCaller(MouseEvent.Move),\n drag: bridgeCaller(MouseEvent.Drag),\n };\n return mouse;\n }\n\n if (prop === 'keyboard') {\n const keyboard: KeyboardAction = {\n type: bridgeCaller(KeyboardEvent.Type),\n press: bridgeCaller(KeyboardEvent.Press),\n };\n return keyboard;\n }\n\n if (prop === 'destroy') {\n return async (...args: any[]) => {\n try {\n const caller = bridgeCaller('destroy');\n await caller(...args);\n } catch (e) {\n // console.error('error calling destroy', e);\n }\n return server.close();\n };\n }\n\n return bridgeCaller(prop);\n },\n }) as ChromeExtensionPageCliSide;\n\n return proxyPage;\n};\n\nexport class AgentOverChromeBridge extends Agent<ChromeExtensionPageCliSide> {\n private destroyAfterDisconnectFlag?: boolean;\n\n constructor(\n opts?: AgentOpt & {\n closeNewTabsAfterDisconnect?: boolean;\n serverListeningTimeout?: number | false;\n closeConflictServer?: boolean;\n },\n ) {\n const page = getBridgePageInCliSide(opts?.serverListeningTimeout);\n const originalOnTaskStartTip = opts?.onTaskStartTip;\n super(\n page,\n Object.assign(opts || {}, {\n onTaskStartTip: (tip: string) => {\n this.page.showStatusMessage(tip);\n if (originalOnTaskStartTip) {\n originalOnTaskStartTip?.call(this, tip);\n }\n },\n }),\n );\n this.destroyAfterDisconnectFlag = opts?.closeNewTabsAfterDisconnect;\n }\n\n async setDestroyOptionsAfterConnect() {\n if (this.destroyAfterDisconnectFlag) {\n this.page.setDestroyOptions({\n closeTab: true,\n });\n }\n }\n\n async connectNewTabWithUrl(url: string, options?: BridgeConnectTabOptions) {\n await this.page.connectNewTabWithUrl(url, options);\n await sleep(500);\n await this.setDestroyOptionsAfterConnect();\n }\n\n async getBrowserTabList() {\n return await this.page.getBrowserTabList();\n }\n\n async setActiveTabId(tabId: string) {\n return await this.page.setActiveTabId(Number.parseInt(tabId));\n }\n\n async connectCurrentTab(options?: BridgeConnectTabOptions) {\n await this.page.connectCurrentTab(options);\n await sleep(500);\n await this.setDestroyOptionsAfterConnect();\n }\n\n async aiAction(prompt: string, options?: any) {\n if (options) {\n console.warn(\n 'the `options` parameter of aiAction is not supported in cli side',\n );\n }\n return await super.aiAction(prompt);\n }\n\n async destroy(closeNewTabsAfterDisconnect?: boolean) {\n if (typeof closeNewTabsAfterDisconnect === 'boolean') {\n await this.page.setDestroyOptions({\n closeTab: closeNewTabsAfterDisconnect,\n });\n }\n await super.destroy();\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","sleep","ms","Promise","resolve","setTimeout","getBridgePageInCliSide","timeout","closeConflictServer","server","BridgeServer","DefaultBridgeServerPort","undefined","bridgeCaller","method","args","response","page","message","BridgeEvent","proxyPage","Proxy","target","receiver","assert","BridgePageType","commonWebActionsForWebPage","mouse","MouseEvent","keyboard","KeyboardEvent","caller","e","AgentOverChromeBridge","Agent","url","options","tabId","Number","prompt","console","closeNewTabsAfterDisconnect","opts","originalOnTaskStartTip","tip"],"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,OA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B;IAC1C;IAEA,MAAM,SAASsC,MAAc,EAAEH,OAAa,EAAE;QAC5C,IAAIA,SACFI,QAAQ,IAAI,CACV;QAGJ,OAAO,MAAM,KAAK,CAAC,SAASD;IAC9B;IAEA,MAAM,QAAQE,2BAAqC,EAAE;QACnD,IAAI,AAAuC,aAAvC,OAAOA,6BACT,MAAM,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC;YAChC,UAAUA;QACZ;QAEF,MAAM,KAAK,CAAC;IACd;IAnEA,YACEC,IAIC,CACD;QACA,MAAMzB,OAAOX,uBAAuBoC,QAAAA,OAAAA,KAAAA,IAAAA,KAAM,sBAAsB;QAChE,MAAMC,yBAAyBD,QAAAA,OAAAA,KAAAA,IAAAA,KAAM,cAAc;QACnD,KAAK,CACHzB,MACApB,OAAO,MAAM,CAAC6C,QAAQ,CAAC,GAAG;YACxB,gBAAgB,CAACE;gBACf,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAACA;gBAC5B,IAAID,wBACFA,QAAAA,0BAAAA,uBAAwB,IAAI,CAAC,IAAI,EAAEC;YAEvC;QACF,KApBJ,uBAAQ,8BAAR;QAsBE,IAAI,CAAC,0BAA0B,GAAGF,QAAAA,OAAAA,KAAAA,IAAAA,KAAM,2BAA2B;IACrE;AA+CF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
ExtensionBridgePageBrowserSide: ()=>external_page_browser_side_js_namespaceObject.ExtensionBridgePageBrowserSide
|
|
28
|
+
});
|
|
29
|
+
const external_page_browser_side_js_namespaceObject = require("./page-browser-side.js");
|
|
30
|
+
exports.ExtensionBridgePageBrowserSide = __webpack_exports__.ExtensionBridgePageBrowserSide;
|
|
31
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
32
|
+
"ExtensionBridgePageBrowserSide"
|
|
33
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
34
|
+
Object.defineProperty(exports, '__esModule', {
|
|
35
|
+
value: true
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-mode\\browser.js","sources":["webpack://@rpascene/web/webpack/runtime/define_property_getters","webpack://@rpascene/web/webpack/runtime/has_own_property","webpack://@rpascene/web/webpack/runtime/make_namespace_object"],"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};"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol"],"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"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
BridgeCallTimeout: ()=>BridgeCallTimeout,
|
|
28
|
+
BridgeErrorCodeNoClientConnected: ()=>BridgeErrorCodeNoClientConnected,
|
|
29
|
+
BridgeEvent: ()=>BridgeEvent,
|
|
30
|
+
BridgePageType: ()=>BridgePageType,
|
|
31
|
+
BridgeSignalKill: ()=>BridgeSignalKill,
|
|
32
|
+
DefaultBridgeServerPort: ()=>DefaultBridgeServerPort,
|
|
33
|
+
DefaultLocalEndpoint: ()=>DefaultLocalEndpoint,
|
|
34
|
+
KeyboardEvent: ()=>KeyboardEvent,
|
|
35
|
+
MouseEvent: ()=>MouseEvent
|
|
36
|
+
});
|
|
37
|
+
const DefaultBridgeServerPort = 3766;
|
|
38
|
+
const DefaultLocalEndpoint = `http://127.0.0.1:${DefaultBridgeServerPort}`;
|
|
39
|
+
const BridgeCallTimeout = 30000;
|
|
40
|
+
var BridgeEvent = /*#__PURE__*/ function(BridgeEvent) {
|
|
41
|
+
BridgeEvent["Call"] = "bridge-call";
|
|
42
|
+
BridgeEvent["CallResponse"] = "bridge-call-response";
|
|
43
|
+
BridgeEvent["UpdateAgentStatus"] = "bridge-update-agent-status";
|
|
44
|
+
BridgeEvent["Message"] = "bridge-message";
|
|
45
|
+
BridgeEvent["Connected"] = "bridge-connected";
|
|
46
|
+
BridgeEvent["Refused"] = "bridge-refused";
|
|
47
|
+
BridgeEvent["ConnectNewTabWithUrl"] = "connectNewTabWithUrl";
|
|
48
|
+
BridgeEvent["ConnectCurrentTab"] = "connectCurrentTab";
|
|
49
|
+
BridgeEvent["GetBrowserTabList"] = "getBrowserTabList";
|
|
50
|
+
BridgeEvent["SetDestroyOptions"] = "setDestroyOptions";
|
|
51
|
+
BridgeEvent["SetActiveTabId"] = "setActiveTabId";
|
|
52
|
+
return BridgeEvent;
|
|
53
|
+
}({});
|
|
54
|
+
const BridgeSignalKill = 'RPASCENE_BRIDGE_SIGNAL_KILL';
|
|
55
|
+
var MouseEvent = /*#__PURE__*/ function(MouseEvent) {
|
|
56
|
+
MouseEvent["PREFIX"] = "mouse.";
|
|
57
|
+
MouseEvent["Click"] = "mouse.click";
|
|
58
|
+
MouseEvent["Wheel"] = "mouse.wheel";
|
|
59
|
+
MouseEvent["Move"] = "mouse.move";
|
|
60
|
+
MouseEvent["Drag"] = "mouse.drag";
|
|
61
|
+
return MouseEvent;
|
|
62
|
+
}({});
|
|
63
|
+
var KeyboardEvent = /*#__PURE__*/ function(KeyboardEvent) {
|
|
64
|
+
KeyboardEvent["PREFIX"] = "keyboard.";
|
|
65
|
+
KeyboardEvent["Type"] = "keyboard.type";
|
|
66
|
+
KeyboardEvent["Press"] = "keyboard.press";
|
|
67
|
+
return KeyboardEvent;
|
|
68
|
+
}({});
|
|
69
|
+
const BridgePageType = 'page-over-chrome-extension-bridge';
|
|
70
|
+
const BridgeErrorCodeNoClientConnected = 'no-client-connected';
|
|
71
|
+
exports.BridgeCallTimeout = __webpack_exports__.BridgeCallTimeout;
|
|
72
|
+
exports.BridgeErrorCodeNoClientConnected = __webpack_exports__.BridgeErrorCodeNoClientConnected;
|
|
73
|
+
exports.BridgeEvent = __webpack_exports__.BridgeEvent;
|
|
74
|
+
exports.BridgePageType = __webpack_exports__.BridgePageType;
|
|
75
|
+
exports.BridgeSignalKill = __webpack_exports__.BridgeSignalKill;
|
|
76
|
+
exports.DefaultBridgeServerPort = __webpack_exports__.DefaultBridgeServerPort;
|
|
77
|
+
exports.DefaultLocalEndpoint = __webpack_exports__.DefaultLocalEndpoint;
|
|
78
|
+
exports.KeyboardEvent = __webpack_exports__.KeyboardEvent;
|
|
79
|
+
exports.MouseEvent = __webpack_exports__.MouseEvent;
|
|
80
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
81
|
+
"BridgeCallTimeout",
|
|
82
|
+
"BridgeErrorCodeNoClientConnected",
|
|
83
|
+
"BridgeEvent",
|
|
84
|
+
"BridgePageType",
|
|
85
|
+
"BridgeSignalKill",
|
|
86
|
+
"DefaultBridgeServerPort",
|
|
87
|
+
"DefaultLocalEndpoint",
|
|
88
|
+
"KeyboardEvent",
|
|
89
|
+
"MouseEvent"
|
|
90
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
91
|
+
Object.defineProperty(exports, '__esModule', {
|
|
92
|
+
value: true
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-mode\\common.js","sources":["webpack://@rpascene/web/webpack/runtime/define_property_getters","webpack://@rpascene/web/webpack/runtime/has_own_property","webpack://@rpascene/web/webpack/runtime/make_namespace_object","webpack://@rpascene/web/./src/bridge-mode/common.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};","export const DefaultBridgeServerPort = 3766;\nexport const DefaultLocalEndpoint = `http://127.0.0.1:${DefaultBridgeServerPort}`;\nexport const BridgeCallTimeout = 30000;\n\nexport enum BridgeEvent {\n Call = 'bridge-call',\n CallResponse = 'bridge-call-response',\n UpdateAgentStatus = 'bridge-update-agent-status',\n Message = 'bridge-message',\n Connected = 'bridge-connected',\n Refused = 'bridge-refused',\n ConnectNewTabWithUrl = 'connectNewTabWithUrl',\n ConnectCurrentTab = 'connectCurrentTab',\n GetBrowserTabList = 'getBrowserTabList',\n SetDestroyOptions = 'setDestroyOptions',\n SetActiveTabId = 'setActiveTabId',\n}\n\nexport const BridgeSignalKill = 'RPASCENE_BRIDGE_SIGNAL_KILL';\n\nexport interface BridgeConnectTabOptions {\n /**\n * If true, the page will always track the active tab.\n * @default true\n */\n forceSameTabNavigation?: boolean;\n}\n\nexport enum MouseEvent {\n PREFIX = 'mouse.',\n Click = 'mouse.click',\n Wheel = 'mouse.wheel',\n Move = 'mouse.move',\n Drag = 'mouse.drag',\n}\n\nexport enum KeyboardEvent {\n PREFIX = 'keyboard.',\n Type = 'keyboard.type',\n Press = 'keyboard.press',\n}\n\nexport const BridgePageType = 'page-over-chrome-extension-bridge';\n\nexport const BridgeErrorCodeNoClientConnected = 'no-client-connected';\n\nexport interface BridgeCall {\n method: string;\n args: any[];\n response: any;\n callTime: number;\n responseTime: number;\n callback: (error: Error | undefined, response: any) => void;\n error?: Error;\n}\n\nexport interface BridgeCallRequest {\n id: string;\n method: string;\n args: any[];\n}\n\nexport interface BridgeCallResponse {\n id: string;\n response: any;\n error?: any;\n}\n\nexport interface BridgeConnectedEventPayload {\n version: string;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","DefaultBridgeServerPort","DefaultLocalEndpoint","BridgeCallTimeout","BridgeEvent","BridgeSignalKill","MouseEvent","KeyboardEvent","BridgePageType","BridgeErrorCodeNoClientConnected"],"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;;;;;;;;;;;;;;;ACNO,MAAMI,0BAA0B;AAChC,MAAMC,uBAAuB,CAAC,iBAAiB,EAAED,yBAAyB;AAC1E,MAAME,oBAAoB;AAE1B,IAAKC,cAAAA,WAAAA,GAAAA,SAAAA,WAAW;;;;;;;;;;;;WAAXA;;AAcL,MAAMC,mBAAmB;AAUzB,IAAKC,aAAAA,WAAAA,GAAAA,SAAAA,UAAU;;;;;;WAAVA;;AAQL,IAAKC,gBAAAA,WAAAA,GAAAA,SAAAA,aAAa;;;;WAAbA;;AAML,MAAMC,iBAAiB;AAEvB,MAAMC,mCAAmC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
AgentOverChromeBridge: ()=>external_agent_cli_side_js_namespaceObject.AgentOverChromeBridge,
|
|
28
|
+
overrideAIConfig: ()=>env_namespaceObject.overrideAIConfig,
|
|
29
|
+
killRunningServer: ()=>external_io_server_js_namespaceObject.killRunningServer
|
|
30
|
+
});
|
|
31
|
+
const external_agent_cli_side_js_namespaceObject = require("./agent-cli-side.js");
|
|
32
|
+
const env_namespaceObject = require("@rpascene/shared/env");
|
|
33
|
+
const external_io_server_js_namespaceObject = require("./io-server.js");
|
|
34
|
+
exports.AgentOverChromeBridge = __webpack_exports__.AgentOverChromeBridge;
|
|
35
|
+
exports.killRunningServer = __webpack_exports__.killRunningServer;
|
|
36
|
+
exports.overrideAIConfig = __webpack_exports__.overrideAIConfig;
|
|
37
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
38
|
+
"AgentOverChromeBridge",
|
|
39
|
+
"killRunningServer",
|
|
40
|
+
"overrideAIConfig"
|
|
41
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
42
|
+
Object.defineProperty(exports, '__esModule', {
|
|
43
|
+
value: true
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge-mode\\index.js","sources":["webpack://@rpascene/web/webpack/runtime/define_property_getters","webpack://@rpascene/web/webpack/runtime/has_own_property","webpack://@rpascene/web/webpack/runtime/make_namespace_object"],"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};"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol"],"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"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
BridgeClient: ()=>BridgeClient
|
|
28
|
+
});
|
|
29
|
+
const utils_namespaceObject = require("@rpascene/shared/utils");
|
|
30
|
+
const external_socket_io_client_namespaceObject = require("socket.io-client");
|
|
31
|
+
const external_common_js_namespaceObject = require("./common.js");
|
|
32
|
+
function _define_property(obj, key, value) {
|
|
33
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
34
|
+
value: value,
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true
|
|
38
|
+
});
|
|
39
|
+
else obj[key] = value;
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
class BridgeClient {
|
|
43
|
+
async connect() {
|
|
44
|
+
return new Promise((resolve, reject)=>{
|
|
45
|
+
this.socket = (0, external_socket_io_client_namespaceObject.io)(this.endpoint, {
|
|
46
|
+
reconnection: false,
|
|
47
|
+
query: {
|
|
48
|
+
version: "0.30.8"
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
const timeout = setTimeout(()=>{
|
|
52
|
+
try {
|
|
53
|
+
var _this_socket, _this_socket1;
|
|
54
|
+
null == (_this_socket = this.socket) || _this_socket.offAny();
|
|
55
|
+
null == (_this_socket1 = this.socket) || _this_socket1.close();
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.warn('got error when offing socket', e);
|
|
58
|
+
}
|
|
59
|
+
this.socket = null;
|
|
60
|
+
reject(new Error('failed to connect to bridge server after timeout'));
|
|
61
|
+
}, 1000);
|
|
62
|
+
this.socket.on('disconnect', (reason)=>{
|
|
63
|
+
var _this_onDisconnect, _this;
|
|
64
|
+
this.socket = null;
|
|
65
|
+
null == (_this_onDisconnect = (_this = this).onDisconnect) || _this_onDisconnect.call(_this);
|
|
66
|
+
});
|
|
67
|
+
this.socket.on('connect_error', (e)=>{
|
|
68
|
+
console.error('bridge-connect-error', e);
|
|
69
|
+
reject(new Error(e || 'bridge connect error'));
|
|
70
|
+
});
|
|
71
|
+
this.socket.on(external_common_js_namespaceObject.BridgeEvent.Connected, (payload)=>{
|
|
72
|
+
clearTimeout(timeout);
|
|
73
|
+
this.serverVersion = (null == payload ? void 0 : payload.version) || 'unknown';
|
|
74
|
+
resolve(this.socket);
|
|
75
|
+
});
|
|
76
|
+
this.socket.on(external_common_js_namespaceObject.BridgeEvent.Refused, (e)=>{
|
|
77
|
+
console.error('bridge-refused', e);
|
|
78
|
+
try {
|
|
79
|
+
var _this_socket;
|
|
80
|
+
null == (_this_socket = this.socket) || _this_socket.disconnect();
|
|
81
|
+
} catch (e) {}
|
|
82
|
+
reject(new Error(e || 'bridge refused'));
|
|
83
|
+
});
|
|
84
|
+
this.socket.on(external_common_js_namespaceObject.BridgeEvent.Call, (call)=>{
|
|
85
|
+
const id = call.id;
|
|
86
|
+
(0, utils_namespaceObject.assert)(void 0 !== id, 'call id is required');
|
|
87
|
+
(async ()=>{
|
|
88
|
+
var _this_socket;
|
|
89
|
+
let response;
|
|
90
|
+
try {
|
|
91
|
+
response = await this.onBridgeCall(call.method, call.args);
|
|
92
|
+
} catch (e) {
|
|
93
|
+
var _this_socket1;
|
|
94
|
+
const errorContent = `Error from bridge client when calling, method: ${call.method}, args: ${call.args}, error: ${(null == e ? void 0 : e.message) || e}\n${(null == e ? void 0 : e.stack) || ''}`;
|
|
95
|
+
console.error(errorContent);
|
|
96
|
+
return null == (_this_socket1 = this.socket) ? void 0 : _this_socket1.emit(external_common_js_namespaceObject.BridgeEvent.CallResponse, {
|
|
97
|
+
id,
|
|
98
|
+
error: errorContent
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
null == (_this_socket = this.socket) || _this_socket.emit(external_common_js_namespaceObject.BridgeEvent.CallResponse, {
|
|
102
|
+
id,
|
|
103
|
+
response
|
|
104
|
+
});
|
|
105
|
+
})();
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
disconnect() {
|
|
110
|
+
var _this_socket;
|
|
111
|
+
null == (_this_socket = this.socket) || _this_socket.disconnect();
|
|
112
|
+
this.socket = null;
|
|
113
|
+
}
|
|
114
|
+
constructor(endpoint, onBridgeCall, onDisconnect){
|
|
115
|
+
_define_property(this, "endpoint", void 0);
|
|
116
|
+
_define_property(this, "onBridgeCall", void 0);
|
|
117
|
+
_define_property(this, "onDisconnect", void 0);
|
|
118
|
+
_define_property(this, "socket", void 0);
|
|
119
|
+
_define_property(this, "serverVersion", void 0);
|
|
120
|
+
this.endpoint = endpoint;
|
|
121
|
+
this.onBridgeCall = onBridgeCall;
|
|
122
|
+
this.onDisconnect = onDisconnect;
|
|
123
|
+
this.socket = null;
|
|
124
|
+
this.serverVersion = null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.BridgeClient = __webpack_exports__.BridgeClient;
|
|
128
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
129
|
+
"BridgeClient"
|
|
130
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
131
|
+
Object.defineProperty(exports, '__esModule', {
|
|
132
|
+
value: true
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=io-client.js.map
|