(params: SelectorRuntimeDeviceParams)
| 91 | } |
| 92 | |
| 93 | function createSelectorBackend(params: SelectorRuntimeDeviceParams): AgentDeviceBackend { |
| 94 | const { req, session, device, logPath, sessionName, sessionStore } = params; |
| 95 | const captureRuntime = createSelectorCaptureRuntime({ |
| 96 | device, |
| 97 | session, |
| 98 | sessionStore, |
| 99 | sessionName, |
| 100 | req, |
| 101 | logPath, |
| 102 | }); |
| 103 | return { |
| 104 | platform: publicPlatformString(device), |
| 105 | captureSnapshot: async (_context, options): Promise<BackendSnapshotResult> => { |
| 106 | const flags = { |
| 107 | ...req.flags, |
| 108 | ...snapshotFlagOverrides(options), |
| 109 | }; |
| 110 | const includeRects = options?.includeRects === true; |
| 111 | const snapshotScope = options?.scope ?? req.flags?.snapshotScope; |
| 112 | const needsFreshSnapshot = |
| 113 | req.command === 'wait' || |
| 114 | req.command === 'find' || |
| 115 | (includeRects && device.platform === 'web'); |
| 116 | return await captureRuntime.capture({ |
| 117 | flags, |
| 118 | snapshotScope, |
| 119 | includeRects, |
| 120 | cache: { |
| 121 | forceFresh: needsFreshSnapshot, |
| 122 | useSessionSnapshot: true, |
| 123 | bypassForPostGestureStabilization: true, |
| 124 | }, |
| 125 | }); |
| 126 | }, |
| 127 | readText: async (_context, node: SnapshotNode) => ({ |
| 128 | text: await readTextForNode({ |
| 129 | device, |
| 130 | node, |
| 131 | flags: req.flags, |
| 132 | appBundleId: session?.appBundleId, |
| 133 | traceOutPath: session?.trace?.outPath, |
| 134 | surface: session?.surface, |
| 135 | contextFromFlags: |
| 136 | params.contextFromFlags ?? |
| 137 | ((flags, appBundleId, traceLogPath) => |
| 138 | contextFromFlags(logPath ?? '', flags, appBundleId, traceLogPath)), |
| 139 | }), |
| 140 | }), |
| 141 | findText: async (_context, text) => ({ |
| 142 | found: await findText(params, text), |
| 143 | }), |
| 144 | }; |
| 145 | } |
| 146 | |
| 147 | function snapshotFlagOverrides(options: BackendSnapshotOptions | undefined): SnapshotFlagOverrides { |
| 148 | const flags: SnapshotFlagOverrides = {}; |
no test coverage detected