()
| 4 | import { resolveWebProvider } from '../../platforms/web/provider.ts'; |
| 5 | |
| 6 | export function createWebInteractor(): Interactor { |
| 7 | const provider = () => resolveWebProvider(); |
| 8 | return { |
| 9 | open: (target, options) => provider().open(options?.url ?? target, { url: options?.url }), |
| 10 | openDevice: () => provider().open('about:blank'), |
| 11 | close: (target) => provider().close(target), |
| 12 | tap: (x, y) => provider().click(x, y), |
| 13 | doubleTap: () => unsupportedWebOperation('doubleTap'), |
| 14 | swipe: () => unsupportedWebOperation('swipe'), |
| 15 | pan: () => unsupportedWebOperation('pan'), |
| 16 | fling: () => unsupportedWebOperation('fling'), |
| 17 | longPress: () => unsupportedWebOperation('longPress'), |
| 18 | focus: (x, y) => provider().click(x, y), |
| 19 | type: (text, delayMs) => provider().typeText(text, { delayMs }), |
| 20 | fill: (x, y, text, delayMs) => provider().fill(x, y, text, { delayMs }), |
| 21 | scroll: (direction, options) => provider().scroll(direction, options), |
| 22 | pinch: () => unsupportedWebOperation('pinch'), |
| 23 | screenshot: (outPath, options) => provider().screenshot(outPath, options), |
| 24 | setViewport: (width, height) => provider().setViewport(width, height), |
| 25 | snapshot: async (options) => { |
| 26 | const result = await withDiagnosticTimer( |
| 27 | 'snapshot_capture', |
| 28 | async () => await provider().snapshot(options), |
| 29 | { backend: 'web' }, |
| 30 | ); |
| 31 | return { |
| 32 | nodes: result.nodes, |
| 33 | truncated: result.truncated ?? false, |
| 34 | backend: 'web', |
| 35 | }; |
| 36 | }, |
| 37 | back: () => unsupportedWebOperation('back'), |
| 38 | home: () => unsupportedWebOperation('home'), |
| 39 | rotate: () => unsupportedWebOperation('rotate'), |
| 40 | rotateGesture: () => unsupportedWebOperation('rotateGesture'), |
| 41 | transformGesture: () => unsupportedWebOperation('transformGesture'), |
| 42 | appSwitcher: () => unsupportedWebOperation('appSwitcher'), |
| 43 | readClipboard: () => unsupportedWebOperation('readClipboard'), |
| 44 | writeClipboard: () => unsupportedWebOperation('writeClipboard'), |
| 45 | setSetting: () => unsupportedWebOperation('setSetting'), |
| 46 | }; |
| 47 | } |
| 48 | |
| 49 | async function unsupportedWebOperation(operation: string): Promise<never> { |
| 50 | throw new AppError('UNSUPPORTED_OPERATION', `${operation} is not supported on web`); |
no test coverage detected