agent-device 0.21.7 → 0.21.9
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/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.7.apk → agent-device-android-ime-helper-0.21.9.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.9.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.7.manifest.json → agent-device-android-ime-helper-0.21.9.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.7.apk → agent-device-android-snapshot-helper-0.21.9.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.9.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.7.manifest.json → agent-device-android-snapshot-helper-0.21.9.manifest.json} +6 -6
- package/apple/macos-helper/Package.swift +16 -1
- package/apple/macos-helper/Sources/AgentDeviceMacOSDeviceHub/DeviceHubPose.swift +47 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSDeviceHub/DeviceHubWindowInventory.swift +65 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubPose.swift +225 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubSidebar.swift +57 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/DeviceHubWindowDiscovery.swift +108 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSHelper/main.swift +66 -13
- package/apple/macos-helper/Sources/AgentDeviceMacOSInput/MouseClickDelivery.swift +116 -0
- package/apple/macos-helper/Sources/AgentDeviceMacOSInput/MouseClickSchedule.swift +61 -0
- package/apple/macos-helper/Tests/AgentDeviceMacOSDeviceHubTests/DeviceHubPoseTests.swift +30 -0
- package/apple/macos-helper/Tests/AgentDeviceMacOSDeviceHubTests/DeviceHubWindowInventoryTests.swift +65 -0
- package/apple/macos-helper/Tests/AgentDeviceMacOSInputTests/MouseClickScheduleTests.swift +58 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests-Bridging-Header.h +1 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAppScreenCapture.swift +175 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +10 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +42 -15
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +8 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +45 -22
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +39 -734
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Keyboard.swift +20 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +63 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +13 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +25 -10
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +5 -562
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotAcquisition.swift +566 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +5 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +594 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.h +35 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.m +160 -0
- package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/RecordingExportSupport.swift +3 -0
- package/dist/apple/runner/AgentDeviceRunner/RecordingScripts/recording-frames.swift +203 -0
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotCoordinateSpace.swift +5 -0
- package/dist/src/absence-observation-errors.js +1 -1
- package/dist/src/adapter.js +1 -1
- package/dist/src/agent-browser-lifecycle.js +1 -1
- package/dist/src/agent-browser-process-record.js +1 -1
- package/dist/src/agent-device-client.js +2 -2
- package/dist/src/alert-runtime.js +1 -1
- package/dist/src/android-adb.js +1 -1
- package/dist/src/android-input-ownership.js +1 -1
- package/dist/src/android.js +1 -1
- package/dist/src/app-launch.js +1 -1
- package/dist/src/app-log-runtime2.js +3 -3
- package/dist/src/app-resolution.js +2 -2
- package/dist/src/apple-runner-platform.js +1 -1
- package/dist/src/application-lifecycle-interaction.js +1 -1
- package/dist/src/artifact-paths.js +1 -0
- package/dist/src/back-mode.js +1 -1
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +15 -11
- package/dist/src/cli.js +4 -4
- package/dist/src/client-types.d.ts +51 -1
- package/dist/src/command-tools.js +3 -3
- package/dist/src/config.js +1 -1
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/device-claim-inspection.js +1 -1
- package/dist/src/device-claim-rule.js +2 -2
- package/dist/src/device-input-state.d.ts +1 -1
- package/dist/src/device-rotation.js +1 -1
- package/dist/src/device-selection-resolver.js +1 -1
- package/dist/src/device-session.js +1 -1
- package/dist/src/device.js +1 -1
- package/dist/src/device2.js +1 -1
- package/dist/src/devicectl.js +1 -1
- package/dist/src/dispatch-resolve.js +1 -1
- package/dist/src/display-inventory.js +1 -1
- package/dist/src/doctor-facade.js +1 -1
- package/dist/src/durable-resource.js +1 -1
- package/dist/src/exec.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/finders.js +1 -1
- package/dist/src/fold-runtime.js +1 -0
- package/dist/src/gesture-admission.js +1 -1
- package/dist/src/gesture-runtime.js +1 -1
- package/dist/src/harmonyos.js +1 -1
- package/dist/src/helper.js +2 -2
- package/dist/src/host.js +1 -0
- package/dist/src/interaction-positionals.js +1 -1
- package/dist/src/interaction-ref-policy.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/interaction2.js +1 -1
- package/dist/src/interactor-operation-binding.js +1 -0
- package/dist/src/interactor-operation-catalog.js +1 -1
- package/dist/src/interactor.js +4 -5
- package/dist/src/interactor2.js +1 -1
- package/dist/src/interactors.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/daemon.js +2 -2
- package/dist/src/internal/png-worker.d.ts +5 -0
- package/dist/src/internal/png-worker.js +1 -1
- package/dist/src/inventory2.js +1 -1
- package/dist/src/ios-snapshot-acquisition.js +1 -1
- package/dist/src/ios-snapshot-runtime.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/linux.js +1 -1
- package/dist/src/local-interactor-operation-set.js +1 -1
- package/dist/src/location-coordinates.js +1 -1
- package/dist/src/macos-facade.js +1 -1
- package/dist/src/managed-device-scope.js +1 -1
- package/dist/src/mechanics.js +17 -16
- package/dist/src/mobile-snapshot-semantics.js +1 -1
- package/dist/src/mp4-duration.js +1 -0
- package/dist/src/multitouch-support.js +1 -1
- package/dist/src/owner-identity.js +1 -1
- package/dist/src/parameterized-recorded-fill.js +1 -1
- package/dist/src/perf-facade.js +2 -2
- package/dist/src/perf-runtime-plan.js +1 -1
- package/dist/src/physical-device-control.js +1 -1
- package/dist/src/platform-request-scope.js +1 -1
- package/dist/src/platform-runtime-managed-owner.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +2 -2
- package/dist/src/platform-runtime-runtime-hints.js +1 -1
- package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
- package/dist/src/platform-runtime-unavailable.js +1 -1
- package/dist/src/platform-runtime.js +1 -1
- package/dist/src/platform-runtime2.js +1 -1
- package/dist/src/png-crop-bytes.js +1 -1
- package/dist/src/png-encode.js +1 -0
- package/dist/src/png-size.js +1 -0
- package/dist/src/png-worker-client.js +1 -1
- package/dist/src/provider-webdriver.js +1 -1
- package/dist/src/quality-warnings.js +1 -1
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/recording-export-quality.js +1 -1
- package/dist/src/recording-scope.js +1 -0
- package/dist/src/recording.js +3 -0
- package/dist/src/registry.js +35 -35
- package/dist/src/replay.js +1 -1
- package/dist/src/request-admission.js +1 -1
- package/dist/src/request-runtime-binding.js +1 -1
- package/dist/src/result-serialization.js +1 -1
- package/dist/src/runner-cache-metadata.js +2 -2
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-contract.js +3 -0
- package/dist/src/runner-dev-tools-security.js +1 -0
- package/dist/src/runner-device-readiness.js +1 -0
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-operations-facade.js +1 -1
- package/dist/src/runner-presentation.js +1 -1
- package/dist/src/runner.js +1 -1
- package/dist/src/runtime.js +2 -2
- package/dist/src/runtime10.js +2 -1
- package/dist/src/runtime2.js +4 -4
- package/dist/src/runtime4.js +5 -5
- package/dist/src/runtime5.js +1 -1
- package/dist/src/runtime6.js +1 -1
- package/dist/src/runtime7.js +1 -1
- package/dist/src/runtime8.js +1 -1
- package/dist/src/runtime9.js +1 -1
- package/dist/src/screen-recording-admission-ledger.js +1 -1
- package/dist/src/screen-recording-resource-recovery.js +1 -1
- package/dist/src/screen-recording-transport.js +1 -1
- package/dist/src/screenshot-density.js +1 -1
- package/dist/src/screenshot-image.js +1 -0
- package/dist/src/screenshot-overlay-draw.js +1 -0
- package/dist/src/screenshot-runtime.js +1 -1
- package/dist/src/script.js +1 -1
- package/dist/src/scroll-gesture.js +1 -1
- package/dist/src/sdk-batch.js +2 -2
- package/dist/src/sdk-contracts.d.ts +7 -5
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-selectors.d.ts +58 -6
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selection.js +0 -0
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/semantic-index.js +1 -1
- package/dist/src/session-routing.js +1 -1
- package/dist/src/session-snapshot.js +1 -1
- package/dist/src/session-store.js +3 -3
- package/dist/src/session2.js +3 -3
- package/dist/src/simctl.js +1 -1
- package/dist/src/simulator-boot.js +1 -1
- package/dist/src/simulator-facade.js +1 -1
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-runtime-binding.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-state.js +1 -1
- package/dist/src/snapshot4.js +1 -1
- package/dist/src/src.js +1 -1
- package/dist/src/src7.js +1 -1
- package/dist/src/src8.js +1 -1
- package/dist/src/stop-sequence.js +1 -1
- package/dist/src/text-entry-focus.js +1 -1
- package/dist/src/touch-runtime.js +1 -1
- package/dist/src/tree.js +1 -1
- package/dist/src/type-text-runtime.js +1 -1
- package/dist/src/video.js +2 -2
- package/dist/src/web2.js +1 -1
- package/package.json +3 -1
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.7.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.7.apk.sha256 +0 -1
- package/dist/src/png-transcode.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{O as e}from"./sdk-device.js";import{t}from"./application-lifecycle-runtime.js";import{A as n,D as r,G as i,H as a,I as o,L as s,N as c,R as l,a as u,b as d,g as f,o as p,p as m,t as h,u as g,v as _,w as v,x as y}from"./alert-runtime.js";import{n as b}from"./audio-probe-runtime.js";import{n as x}from"./perf-runtime.js";import{i as S}from"./touch-runtime.js";const C={appLog:!0,apps:!0,appDeployment:!0,appState:!0,network:!0,screenRecording:!0,screenshot:!0,snapshot:!0,viewport:!0,focus:!0,gesture:!0,scroll:!0,typeText:!0,touch:!0,elementText:!0,back:!0,orientation:!0,fold:!0,tvRemote:!0,keyboard:!0,clipboard:!0,systemButton:!0,triggerAppEvent:!0,settings:!0,readAlert:!0,awaitAlert:!0,acceptAlert:!0,dismissAlert:!0,audioProbeCapture:!0,audioProbeQuery:!0,perf:!0,readiness:!0,shutdown:!0};function w(e){let t={};for(let n of Object.keys(C))t[n]=e(n);return t}function T(e){return Object.freeze({...w(()=>e),lifecycle:t({resolveOpenTarget:e,prepareApplicationOpen:e,openApplication:e,applyRuntimeHints:e,clearRuntimeHints:e,closeApplication:e,finalizeApplicationClose:e,prepareAppleRunner:e,configureProviderPortReverse:e})})}function E(e,t,n){return Object.freeze({device:e,owner:t,facts:D(e,t,n),operations:Object.freeze({}),[Symbol.asyncDispose]:async()=>void 0})}function D(t,C,w){let T=k(w);return Object.freeze({device:{...e(t),providerMode:O(C)},operations:{appLogInspect:T.appLog,appLogDoctor:T.appLog,appLogStart:T.appLog,appLogReattach:T.appLog,appLogCleanup:T.appLog,listApps:T.apps,deployApp:T.appDeployment,materializeAppSource:T.appDeployment,deployMaterializedApp:T.appDeployment,sendPushNotification:T.appDeployment,appState:T.appState,networkDump:T.network,screenRecordingStart:T.screenRecording,screenRecordingReattach:T.screenRecording,screenRecordingCleanup:T.screenRecording,...i({capture:T.screenshot}),...a({capture:T.snapshot,customActions:T.snapshot,withoutActiveApp:T.snapshot}),...l({findText:T.snapshot}),...s({setViewport:T.viewport}),...o({focus:T.focus}),...c({unsupported:T.gesture}),...n({scroll:T.scroll}),...r({type:T.typeText}),...S({unsupported:T.touch,tap:T.touch,longPress:T.touch,fill:T.touch}),...v({readTextAtPoint:T.elementText}),...y({back:T.back}),...d({orientation:T.orientation}),setFoldPose:T.fold,..._({tvRemote:T.tvRemote}),...f({unsupported:T.keyboard}),...m({unsupported:T.clipboard}),...g({unsupported:T.systemButton}),...p({triggerAppEvent:T.triggerAppEvent}),...u({setSetting:T.settings,readSetting:T.settings}),...h({read:T.readAlert,wait:T.awaitAlert,accept:T.acceptAlert,dismiss:T.dismissAlert}),...b({capture:T.audioProbeCapture,query:T.audioProbeQuery}),...x({frames:T.perf,memorySample:T.perf,memorySnapshot:T.perf,nativeCapture:T.perf,profileReport:T.perf}),ensureReady:T.readiness,bootTarget:T.readiness,bootTargetHeadless:T.readiness,shutdownTarget:T.shutdown,...T.lifecycle}})}function O(e){switch(e.kind){case`local-family`:case`managed-local`:return`local`;case`provider-runtime`:return`provider-runtime`}}function k(e){return Object.freeze({...w(t=>Object.freeze({...e[t]??e.network})),lifecycle:t(e.lifecycle)})}export{E as n,D as r,T as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{D as t}from"./sdk-contracts.js";import{D as n,O as r,T as i,k as a,l as o}from"./sdk-device.js";import{Xt as s,Yt as c,Zt as l,k as u}from"./sdk-batch.js";import{i as d,o as f,t as p}from"./device.js";import{t as ee}from"./startup-recovery-fence.js";import{i as m,n as h,r as g}from"./src2.js";import{n as _,t as v}from"./src3.js";import{i as te,m as ne}from"./src4.js";import{c as re,g as y,n as b}from"./src5.js";import{r as x,t as S}from"./src6.js";import{n as C,r as ie,t as w}from"./platform-runtime-unavailable.js";const T=Object.freeze({family:`android`});function ae(e){let t,n=()=>(t??=import(`./observation.js`).then(({createAndroidObservationAdapter:t})=>t(e)),t);return Object.freeze({readAppState:async(...e)=>await(await n()).readAppState(...e),readBlockingDialog:async(...e)=>await(await n()).readBlockingDialog(...e),readAppFocus:async(...e)=>await(await n()).readAppFocus(...e),readSnapshotNodes:async(...e)=>await(await n()).readSnapshotNodes(...e),tap:async(...e)=>await(await n()).tap(...e),openApp:async(...e)=>await(await n()).openApp(...e),readScreenSize:async(...e)=>await(await n()).readScreenSize(...e),isPermissionPackage:async(...e)=>await(await n()).isPermissionPackage(...e)})}async function oe(e,t){let{readAndroidAppStateWithExecutor:n}=await import(`./app-state.js`);return await n(e,t)}function se(e){return Object.freeze({...T,loadRuntime:async t=>{await e.bindAdbHost();let{createAndroidPlatformRuntime:n}=await import(`./runtime2.js`);return n(t)}})}function ce(e){let t=Object.freeze({sdkRoots:Object.freeze([...new Set(e.sdkRoots.map(e=>e.trim()).filter(Boolean))])});return Object.freeze({...T,loadInventory:async e=>{let{createAndroidInventory:n}=await import(`./inventory.js`);return n(e,t)}})}async function le(e){let{createAndroidShutdownRuntime:t}=await import(`./runtime3.js`);return t(e)}function ue(e){let t=new Map,n=new Map;for(let r of e.providerModules??[]){let{runtime:e,module:i}=r,a=s(i.owner);if(i.owner.provider!==e.provider)throw z(`Provider platform runtime metadata is invalid: ${a}`);if(t.has(a))throw z(`Duplicate platform runtime owner: ${a}`);if(n.has(e))throw z(`Duplicate platform module registration for ${e.provider}`);t.set(a,r),n.set(e,i)}let r=new Map;for(let t of e.managedOwners??[]){let e=s(t);if(r.has(e))throw z(`Duplicate platform runtime owner: ${e}`);r.set(e,t)}let i=new Map,a=new Map,o=new Map,c=new Map,u,d=async()=>{u??=e.loadHost();try{return await u}catch(e){throw u=void 0,e}},f,p,m=Object.freeze({recoverStartupResources:async e=>{await ee(e.stateDir,async()=>{await(await d()).applicationResources.recoverStartupResources(e)})},detachForDaemonShutdown:async()=>{f??=d().then(async e=>await e.applicationResources.detachForDaemonShutdown()),await f},finalizeDaemonShutdown:async()=>{p??=d().then(async e=>await e.applicationResources.finalizeDaemonShutdown()),await p}}),h=e=>{let t=s(e.owner),n=c.get(t);if(n&&n!==e)throw z(`Duplicate platform runtime owner: ${t}`);return c.set(t,e),e},g=async t=>{let n=i.get(t);if(n)return await n;let r=e.modules.get(t);if(!r)throw z(`Missing platform runtime module for ${t}`);if(r.family!==t)throw z(`Platform runtime module registered for ${t} declares ${r.family}`);let a=d().then(async e=>{let n=await r.loadRuntime(e);if(n.owner.kind!==`local-family`||n.owner.family!==t)throw z(`Platform runtime module for ${t} returned a different local owner`);return h(n)});i.set(t,a);try{return await a}catch(e){throw i.get(t)===a&&i.delete(t),e}},_=async e=>{let t=a.get(e);if(t)return await t;let n=d().then(async t=>{let n=await e.loadRuntime(t);if(!l(n.owner,e.owner))throw z(`Provider platform runtime returned a different advertised owner`);return h(n)});a.set(e,n);try{return await n}catch(t){throw a.get(e)===n&&a.delete(e),t}},v=async e=>{let t=s(e),n=r.get(t);if(!n)throw R(e);let i=o.get(t);if(i)return i;let{createManagedLocalRuntimeOwner:a}=await import(`./platform-runtime-managed-owner.js`),c=h(a({owner:n,loadLocal:g}));return o.set(t,c),c};return Object.freeze({applicationLifecycle:m,inspectFacts:async t=>{let r=E(e.providerRuntimes,t);if(r){let e=n.get(r);return e?await D(await _(e),t):L(r,t)}return await D(await g(t.platform),t)},bind:async r=>{if(r.intent.kind===`exact-owner`)return await O(await P(r.intent.owner,t,_,g,v),r);let i=E(e.providerRuntimes,r.device);if(i){let e=n.get(i);return e?await O(await _(e),r):I(i,r.device)}return await O(await g(r.device.platform),r)},shutdown:async()=>{await Promise.allSettled([...c.values()].map(async e=>await e.shutdown())),c.clear(),i.clear(),a.clear(),o.clear()}})}function E(e,t){let n=(e??[]).filter(e=>e.ownsDevice(t));if(n.length>1)throw z(`Multiple provider runtimes claim the selected device`);return n[0]}async function D(e,t){let n=await e.inspectFacts(t);if(!M(t,e.owner,n))throw z(`Platform runtime facts do not match the selected device and owner`);return n}async function O(e,t){let n=await e.bind(t),r=k(e,n,t);if(!r)return n;let i;try{await n[Symbol.asyncDispose]()}catch(e){i=e instanceof Error?e.message:String(e)}throw z(r,i)}function k(e,t,n){if(!l(t.owner,e.owner))return`Platform binding returned a different owner than the selected runtime`;if(!A(t.owner,n))return`Exact platform binding returned a different persisted owner`;if(!r(i(t.device),i(n.device)))return`Platform binding returned a different device identity`;if(!j(t))return`Platform binding facts do not match its device and owner`}function A(e,t){return t.intent.kind!==`exact-owner`||l(e,t.intent.owner)}function j(e){return M(e.device,e.owner,e.facts)}function M(e,t,r){return a(r.device,n(e))&&N(r.device.providerMode,t)}function N(e,t){switch(t.kind){case`local-family`:return e===`local`||e===`transport-composed`;case`managed-local`:return e===`local`||e===`transport-composed`;case`provider-runtime`:return e===`provider-runtime`}}async function P(e,t,n,r,i){switch(e.kind){case`local-family`:{let t=await r(e.family);if(l(t.owner,e))return t;throw R(e)}case`managed-local`:return await i(e);case`provider-runtime`:{let r=t.get(s(e));if(r)return await n(r.module);throw R(e)}}}const F=Object.freeze({available:!1,reason:`unsupported-provider-mode`});function I(e,t){let n=c(e.provider,`default`);return C(t,n,w(F))}function L(e,t){return ie(t,c(e.provider,`default`),w(F))}function R(e){return new t(`UNSUPPORTED_OPERATION`,`The exact platform runtime owner is unavailable.`,{reason:`owner-unavailable`,owner:s(e)})}function z(e,n){return new t(`COMMAND_FAILED`,e,{reason:`runtime-contract-invalid`,...n?{cleanupError:n}:{}})}function B(e){let t=V(e.registry,e.loadHost),n=e.provider,r=n?async(e,r)=>{r.signal.throwIfAborted();let i=await n.discover(f(e),r.signal);return r.signal.throwIfAborted(),ge(i),i.kind===`inventory`?{devices:d(i.devices.map(e=>({...e})),e),source:`provider`}:{devices:await t.discover(e,r),source:`local`}}:async(e,n)=>({devices:await t.discover(e,n),source:`local`}),i=Object.freeze({discover:async(e,t)=>(await r(e,t)).devices,discoverWithSource:r});return Object.freeze({providerFirst:i,localOnly:t,findInstalledApp:async(e,t)=>{let{findIosSimulatorInstalledApp:n}=await import(`./app-resolution-facade.js`);return await n(e,t)}})}function V(e,t){let n,r=async()=>{n??=t();try{return await n}catch(e){throw n=void 0,e}},i=new Map,a=async t=>{let n=i.get(t);if(n)return await n;let a=H(e.get(t),r);i.set(t,a);try{return await a}catch(e){throw i.get(t)===a&&i.delete(t),e}};return Object.freeze({discover:async(e,t)=>{if(t.signal.throwIfAborted(),e.platform)return await W(a,G(e.platform),e,t);let n=await Promise.all(p.map(async n=>{try{let r=await W(a,G(n),{...e,platform:n},t);return Array.isArray(r)?r:[]}catch{return[]}}));return t.signal.throwIfAborted(),n.flat()}})}async function H(e,t){switch(e.family){case`apple`:return await e.loadInventory(U(await t()));case`android`:return await e.loadInventory(de(await t()));case`harmonyos`:return await e.loadInventory(fe(await t()));case`vega`:return await e.loadInventory(pe(await t()));case`linux`:return await e.loadInventory(me(await t()));case`web`:return await e.loadInventory()}}function U(e){return Object.freeze({appleTools:e.appleTools,files:e.files,hostName:e.hostName,hostOs:e.hostOs,observations:e.observations})}function de(e){return Object.freeze({commands:e.commands,files:e.files,homeDirectory:e.homeDirectory,toolchains:e.toolchains})}function fe(e){return Object.freeze({commands:e.commands,files:e.files,toolchains:e.toolchains})}function pe(e){return Object.freeze({commands:e.commands,files:e.files,homeDirectory:e.homeDirectory})}function me(e){return Object.freeze({hostName:e.hostName,hostOs:e.hostOs})}async function W(e,t,n,r){let i=await e(t);r.signal.throwIfAborted();let a=await i.discover(n,r);return r.signal.throwIfAborted(),he(t,a),d(a,n)}function G(e){return o(e)?`apple`:e}function he(e,n){let r=n.find(t=>t.platform!==e);if(r)throw new t(`COMMAND_FAILED`,`Platform inventory source ${e} returned a ${r.platform} device.`,{expectedFamily:e,actualFamily:r.platform,deviceId:r.id})}function ge(e){if(typeof e==`object`&&e){let t=e;if(t.kind===`declined`&&!(`devices`in t)||t.kind===`inventory`&&Array.isArray(t.devices))return}throw new t(`COMMAND_FAILED`,`Provider device inventory returned an invalid outcome.`,{reason:`provider_inventory_contract_violation`})}function _e(){return Object.freeze({async runAdb(e,t,n){let{runAndroidAdb:r}=await K(),i=await r(e,t,n);return{exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr}},async readSnapshotNodes(e){let{snapshotAndroid:t,androidSnapshotPublicationInput:n}=await K(),{buildSnapshotState:r}=await import(`./snapshot-state.js`).then(e=>e.n);return r(n(await t(e,{interactiveOnly:!1})),void 0).nodes},async openApp(e,t){let{openAndroidApp:n}=await K();await n(e,t)}})}async function K(){let{loadAndroidMechanics:e}=await import(`./platform-runtime-android-mechanics.js`).then(e=>e.n);return await e()}var ve=e({androidObservation:()=>J,createPlatformDeviceInventoryGateways:()=>X,createPlatformRuntimeGateway:()=>Q,createRequestPlatformProviders:()=>$,getAndroidAppStateWithAdb:()=>ye,platformModuleRegistry:()=>Y,platformRuntimeModules:()=>Z});async function ye(e,t){return await oe(e,t)}const q=ce({sdkRoots:Ce(process.env.ANDROID_SDK_ROOT,process.env.ANDROID_HOME)}),J=ae(_e()),be=Object.freeze({apple:async e=>await g(e),android:async e=>await le(e)}),xe=te({hdcSdkPath:process.env.HDC_SDK_PATH,devecoSdkHome:process.env.DEVECO_SDK_HOME,commandLineToolsHome:process.env.HARMONYOS_COMMAND_LINE_TOOLS}),Y=u([h,q,xe,v,re,S]);function X(e){return B({registry:Y,loadHost:async()=>{let{createDeviceInventoryHost:e}=await import(`./platform-runtime-host.js`);return e()},provider:e})}const Se=se({bindAdbHost:async()=>{await import(`./platform-runtime-android-adb-host.js`).then(e=>e.t)}}),Z=new Map([[`apple`,m],[`android`,Se],[`harmonyos`,ne],[`vega`,_],[`linux`,y],[`web`,x]]);function Q(e){return ue({modules:Z,loadHost:async()=>{let{createPlatformRuntimeHost:t,createSnapshotRuntimeHost:n,loadMacOsSurfaceSnapshot:r}=await import(`./platform-runtime-operation-host.js`);return t({sessionsDir:e.sessionsDir,resolveSessionArtifacts:e.resolveSessionArtifacts,shutdownLoaders:be,snapshot:n({linux:b,macos:r}),ownedProcesses:e.ownedProcesses})},providerRuntimes:e.providerRuntimes,providerModules:e.providerModules})}function $(e={}){let t,n=()=>(t??=import(`./request-providers.js`).then(({createComposedRequestPlatformProviders:t})=>t(e)),t);return Object.freeze({hasConfiguredResolvers:Object.values(e.providers??{}).some(Boolean),run:async(e,t)=>await(await n()).run(e,t)})}function Ce(...e){return e.flatMap(e=>{let t=e?.trim();return t?[t]:[]})}export{ve as a,$ as i,X as n,Q as r,J as t};
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{D as t}from"./sdk-contracts.js";import{A as n,E as r,O as i,k as a,l as o}from"./sdk-device.js";import{$t as s,Qt as c,en as l,k as u}from"./sdk-batch.js";import{i as d,o as f,t as p}from"./device.js";import{t as ee}from"./startup-recovery-fence.js";import{i as m,n as h,r as g}from"./src2.js";import{n as _,t as v}from"./src3.js";import{i as te,m as ne}from"./src4.js";import{c as re,g as y,n as b}from"./src5.js";import{r as x,t as S}from"./src6.js";import{n as C,r as ie,t as w}from"./platform-runtime-unavailable.js";const T=Object.freeze({family:`android`});function ae(e){let t,n=()=>(t??=import(`./observation.js`).then(({createAndroidObservationAdapter:t})=>t(e)),t);return Object.freeze({readAppState:async(...e)=>await(await n()).readAppState(...e),readBlockingDialog:async(...e)=>await(await n()).readBlockingDialog(...e),readAppFocus:async(...e)=>await(await n()).readAppFocus(...e),readSnapshotNodes:async(...e)=>await(await n()).readSnapshotNodes(...e),tap:async(...e)=>await(await n()).tap(...e),openApp:async(...e)=>await(await n()).openApp(...e),readScreenSize:async(...e)=>await(await n()).readScreenSize(...e),isPermissionPackage:async(...e)=>await(await n()).isPermissionPackage(...e)})}async function oe(e,t){let{readAndroidAppStateWithExecutor:n}=await import(`./app-state.js`);return await n(e,t)}function se(e){return Object.freeze({...T,loadRuntime:async t=>{await e.bindAdbHost();let{createAndroidPlatformRuntime:n}=await import(`./runtime2.js`);return n(t)}})}function ce(e){let t=Object.freeze({sdkRoots:Object.freeze([...new Set(e.sdkRoots.map(e=>e.trim()).filter(Boolean))])});return Object.freeze({...T,loadInventory:async e=>{let{createAndroidInventory:n}=await import(`./inventory.js`);return n(e,t)}})}async function le(e){let{createAndroidShutdownRuntime:t}=await import(`./runtime3.js`);return t(e)}function ue(e){let t=new Map,n=new Map;for(let r of e.providerModules??[]){let{runtime:e,module:i}=r,a=s(i.owner);if(i.owner.provider!==e.provider)throw z(`Provider platform runtime metadata is invalid: ${a}`);if(t.has(a))throw z(`Duplicate platform runtime owner: ${a}`);if(n.has(e))throw z(`Duplicate platform module registration for ${e.provider}`);t.set(a,r),n.set(e,i)}let r=new Map;for(let t of e.managedOwners??[]){let e=s(t);if(r.has(e))throw z(`Duplicate platform runtime owner: ${e}`);r.set(e,t)}let i=new Map,a=new Map,o=new Map,c=new Map,u,d=async()=>{u??=e.loadHost();try{return await u}catch(e){throw u=void 0,e}},f,p,m=Object.freeze({recoverStartupResources:async e=>{await ee(e.stateDir,async()=>{await(await d()).applicationResources.recoverStartupResources(e)})},detachForDaemonShutdown:async()=>{f??=d().then(async e=>await e.applicationResources.detachForDaemonShutdown()),await f},finalizeDaemonShutdown:async()=>{p??=d().then(async e=>await e.applicationResources.finalizeDaemonShutdown()),await p}}),h=e=>{let t=s(e.owner),n=c.get(t);if(n&&n!==e)throw z(`Duplicate platform runtime owner: ${t}`);return c.set(t,e),e},g=async t=>{let n=i.get(t);if(n)return await n;let r=e.modules.get(t);if(!r)throw z(`Missing platform runtime module for ${t}`);if(r.family!==t)throw z(`Platform runtime module registered for ${t} declares ${r.family}`);let a=d().then(async e=>{let n=await r.loadRuntime(e);if(n.owner.kind!==`local-family`||n.owner.family!==t)throw z(`Platform runtime module for ${t} returned a different local owner`);return h(n)});i.set(t,a);try{return await a}catch(e){throw i.get(t)===a&&i.delete(t),e}},_=async e=>{let t=a.get(e);if(t)return await t;let n=d().then(async t=>{let n=await e.loadRuntime(t);if(!l(n.owner,e.owner))throw z(`Provider platform runtime returned a different advertised owner`);return h(n)});a.set(e,n);try{return await n}catch(t){throw a.get(e)===n&&a.delete(e),t}},v=async e=>{let t=s(e),n=r.get(t);if(!n)throw R(e);let i=o.get(t);if(i)return i;let{createManagedLocalRuntimeOwner:a}=await import(`./platform-runtime-managed-owner.js`),c=h(a({owner:n,loadLocal:g}));return o.set(t,c),c};return Object.freeze({applicationLifecycle:m,inspectFacts:async t=>{let r=E(e.providerRuntimes,t);if(r){let e=n.get(r);return e?await D(await _(e),t):L(r,t)}return await D(await g(t.platform),t)},bind:async r=>{if(r.intent.kind===`exact-owner`)return await O(await P(r.intent.owner,t,_,g,v),r);let i=E(e.providerRuntimes,r.device);if(i){let e=n.get(i);return e?await O(await _(e),r):I(i,r.device)}return await O(await g(r.device.platform),r)},shutdown:async()=>{await Promise.allSettled([...c.values()].map(async e=>await e.shutdown())),c.clear(),i.clear(),a.clear(),o.clear()}})}function E(e,t){let n=(e??[]).filter(e=>e.ownsDevice(t));if(n.length>1)throw z(`Multiple provider runtimes claim the selected device`);return n[0]}async function D(e,t){let n=await e.inspectFacts(t);if(!M(t,e.owner,n))throw z(`Platform runtime facts do not match the selected device and owner`);return n}async function O(e,t){let n=await e.bind(t),r=k(e,n,t);if(!r)return n;let i;try{await n[Symbol.asyncDispose]()}catch(e){i=e instanceof Error?e.message:String(e)}throw z(r,i)}function k(e,t,n){if(!l(t.owner,e.owner))return`Platform binding returned a different owner than the selected runtime`;if(!A(t.owner,n))return`Exact platform binding returned a different persisted owner`;if(!a(r(t.device),r(n.device)))return`Platform binding returned a different device identity`;if(!j(t))return`Platform binding facts do not match its device and owner`}function A(e,t){return t.intent.kind!==`exact-owner`||l(e,t.intent.owner)}function j(e){return M(e.device,e.owner,e.facts)}function M(e,t,r){return n(r.device,i(e))&&N(r.device.providerMode,t)}function N(e,t){switch(t.kind){case`local-family`:return e===`local`||e===`transport-composed`;case`managed-local`:return e===`local`||e===`transport-composed`;case`provider-runtime`:return e===`provider-runtime`}}async function P(e,t,n,r,i){switch(e.kind){case`local-family`:{let t=await r(e.family);if(l(t.owner,e))return t;throw R(e)}case`managed-local`:return await i(e);case`provider-runtime`:{let r=t.get(s(e));if(r)return await n(r.module);throw R(e)}}}const F=Object.freeze({available:!1,reason:`unsupported-provider-mode`});function I(e,t){let n=c(e.provider,`default`);return C(t,n,w(F))}function L(e,t){return ie(t,c(e.provider,`default`),w(F))}function R(e){return new t(`UNSUPPORTED_OPERATION`,`The exact platform runtime owner is unavailable.`,{reason:`owner-unavailable`,owner:s(e)})}function z(e,n){return new t(`COMMAND_FAILED`,e,{reason:`runtime-contract-invalid`,...n?{cleanupError:n}:{}})}function B(e){let t=V(e.registry,e.loadHost),n=e.provider,r=n?async(e,r)=>{r.signal.throwIfAborted();let i=await n.discover(f(e),r.signal);return r.signal.throwIfAborted(),ge(i),i.kind===`inventory`?{devices:d(i.devices.map(e=>({...e})),e),source:`provider`}:{devices:await t.discover(e,r),source:`local`}}:async(e,n)=>({devices:await t.discover(e,n),source:`local`}),i=Object.freeze({discover:async(e,t)=>(await r(e,t)).devices,discoverWithSource:r});return Object.freeze({providerFirst:i,localOnly:t,findInstalledApp:async(e,t)=>{let{findIosSimulatorInstalledApp:n}=await import(`./app-resolution-facade.js`);return await n(e,t)}})}function V(e,t){let n,r=async()=>{n??=t();try{return await n}catch(e){throw n=void 0,e}},i=new Map,a=async t=>{let n=i.get(t);if(n)return await n;let a=H(e.get(t),r);i.set(t,a);try{return await a}catch(e){throw i.get(t)===a&&i.delete(t),e}};return Object.freeze({discover:async(e,t)=>{if(t.signal.throwIfAborted(),e.platform)return await W(a,G(e.platform),e,t);let n=await Promise.all(p.map(async n=>{try{let r=await W(a,G(n),{...e,platform:n},t);return Array.isArray(r)?r:[]}catch{return[]}}));return t.signal.throwIfAborted(),n.flat()}})}async function H(e,t){switch(e.family){case`apple`:return await e.loadInventory(U(await t()));case`android`:return await e.loadInventory(de(await t()));case`harmonyos`:return await e.loadInventory(fe(await t()));case`vega`:return await e.loadInventory(pe(await t()));case`linux`:return await e.loadInventory(me(await t()));case`web`:return await e.loadInventory()}}function U(e){return Object.freeze({appleTools:e.appleTools,files:e.files,hostName:e.hostName,hostOs:e.hostOs,observations:e.observations})}function de(e){return Object.freeze({commands:e.commands,files:e.files,homeDirectory:e.homeDirectory,toolchains:e.toolchains})}function fe(e){return Object.freeze({commands:e.commands,files:e.files,toolchains:e.toolchains})}function pe(e){return Object.freeze({commands:e.commands,files:e.files,homeDirectory:e.homeDirectory})}function me(e){return Object.freeze({hostName:e.hostName,hostOs:e.hostOs})}async function W(e,t,n,r){let i=await e(t);r.signal.throwIfAborted();let a=await i.discover(n,r);return r.signal.throwIfAborted(),he(t,a),d(a,n)}function G(e){return o(e)?`apple`:e}function he(e,n){let r=n.find(t=>t.platform!==e);if(r)throw new t(`COMMAND_FAILED`,`Platform inventory source ${e} returned a ${r.platform} device.`,{expectedFamily:e,actualFamily:r.platform,deviceId:r.id})}function ge(e){if(typeof e==`object`&&e){let t=e;if(t.kind===`declined`&&!(`devices`in t)||t.kind===`inventory`&&Array.isArray(t.devices))return}throw new t(`COMMAND_FAILED`,`Provider device inventory returned an invalid outcome.`,{reason:`provider_inventory_contract_violation`})}function _e(){return Object.freeze({async runAdb(e,t,n){let{runAndroidAdb:r}=await K(),i=await r(e,t,n);return{exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr}},async readSnapshotNodes(e){let{snapshotAndroid:t,androidSnapshotPublicationInput:n}=await K(),{buildSnapshotState:r}=await import(`./snapshot-state.js`).then(e=>e.n);return r(n(await t(e,{interactiveOnly:!1})),void 0).nodes},async openApp(e,t){let{openAndroidApp:n}=await K();await n(e,t)}})}async function K(){let{loadAndroidMechanics:e}=await import(`./platform-runtime-android-mechanics.js`).then(e=>e.n);return await e()}var ve=e({androidObservation:()=>J,createPlatformDeviceInventoryGateways:()=>X,createPlatformRuntimeGateway:()=>Q,createRequestPlatformProviders:()=>$,getAndroidAppStateWithAdb:()=>ye,platformModuleRegistry:()=>Y,platformRuntimeModules:()=>Z});async function ye(e,t){return await oe(e,t)}const q=ce({sdkRoots:Ce(process.env.ANDROID_SDK_ROOT,process.env.ANDROID_HOME)}),J=ae(_e()),be=Object.freeze({apple:async e=>await g(e),android:async e=>await le(e)}),xe=te({hdcSdkPath:process.env.HDC_SDK_PATH,devecoSdkHome:process.env.DEVECO_SDK_HOME,commandLineToolsHome:process.env.HARMONYOS_COMMAND_LINE_TOOLS}),Y=u([h,q,xe,v,re,S]);function X(e){return B({registry:Y,loadHost:async()=>{let{createDeviceInventoryHost:e}=await import(`./platform-runtime-host.js`);return e()},provider:e})}const Se=se({bindAdbHost:async()=>{await import(`./platform-runtime-android-adb-host.js`).then(e=>e.t)}}),Z=new Map([[`apple`,m],[`android`,Se],[`harmonyos`,ne],[`vega`,_],[`linux`,y],[`web`,x]]);function Q(e){return ue({modules:Z,loadHost:async()=>{let{createPlatformRuntimeHost:t,createSnapshotRuntimeHost:n,loadMacOsSurfaceSnapshot:r}=await import(`./platform-runtime-operation-host.js`);return t({sessionsDir:e.sessionsDir,resolveSessionArtifacts:e.resolveSessionArtifacts,shutdownLoaders:be,snapshot:n({linux:b,macos:r}),ownedProcesses:e.ownedProcesses})},providerRuntimes:e.providerRuntimes,providerModules:e.providerModules})}function $(e={}){let t,n=()=>(t??=import(`./request-providers.js`).then(({createComposedRequestPlatformProviders:t})=>t(e)),t);return Object.freeze({hasConfiguredResolvers:Object.values(e.providers??{}).some(Boolean),run:async(e,t)=>await(await n()).run(e,t)})}function Ce(...e){return e.flatMap(e=>{let t=e?.trim();return t?[t]:[]})}export{ve as a,$ as i,X as n,Q as r,J as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e}from"./sdk-contracts.js";import{Qt as t,Zt as n}from"./sdk-batch.js";import{n as r,t as i}from"./application-lifecycle-runtime.js";import{i as a,n as o}from"./touch-runtime.js";import{A as s,B as c,D as ee,E as l,F as u,G as te,H as d,I as f,L as p,M as m,N as h,W as g,a as _,b as v,d as y,g as ne,i as re,k as ie,s as ae,t as oe,v as se,x as ce}from"./alert-runtime.js";import{r as b}from"./platform-runtime-unavailable.js";import{r as le,t as ue}from"./capabilities.js";import{n as de}from"./src7.js";import{r as fe}from"./gesture-admission.js";import{n as pe}from"./interactor-operation-catalog.js";import{r as me,t as he}from"./application-lifecycle-interaction.js";function ge(e){return he({owner:`WebDriver`,openTargetIdentity:`bundle-id`,closeBeforeRelaunch:!0,binding:me({device:e.device,signal:e.signal,resolveInteractor:t=>e.getInteractor(e.device,t)})})}const x=Object.freeze({available:!0}),S=Object.freeze({available:!1,reason:`unsupported-provider-mode`}),C=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose screen recording.`}),w=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Headless boot is unavailable for provider-owned devices.`}),T=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`WebDriver provider runtimes do not expose app inventory.`}),E=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose app deployment.`}),D=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Push notifications are unavailable for WebDriver provider-owned devices.`}),O=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`The WebDriver provider session is no longer active for this device.`}),k=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose snapshot capture for this device.`}),A=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose screenshot capture for this device.`}),j=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose iOS simulator custom snapshot actions.`}),M=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose viewport resizing.`}),N=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose focus for this device.`}),P=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose text entry for this device.`}),F=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose gestures for this device.`}),I=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose scrolling for this device.`}),L=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:fe}),_e=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes read element text from the captured tree only.`}),R=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose back for this device.`}),z=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose home for this device.`}),B=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose orientation for this device.`}),V=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose tv-remote.`}),ve=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose keyboard actions.`}),H=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose clipboard access for this device.`}),U=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose the app switcher for this device.`}),W=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`action-button presses iPhone Action Button hardware, which no WebDriver backend exposes.`}),G=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose native alert handling.`}),K=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose device settings.`}),q=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose app-event delivery for this device.`}),ye=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose a foreground app-state operation.`}),J=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose the audio probe.`}),be=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Apple runner preparation is unavailable for WebDriver-owned devices.`}),xe=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver open is supported only for its owned iOS or Android mobile-device sessions.`}),Se=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver close is supported only for its owned iOS or Android mobile-device sessions.`}),Y=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Runtime hints are not applied to provider-owned devices.`}),Ce=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose port reverse.`});function X(e){let t=e.platform===`android`&&e.kind===`device`&&e.target===`mobile`||e.platform===`apple`&&e.kind===`device`&&e.target===`mobile`&&e.appleOs===`ios`,n=t?x:xe,r=t?x:Se;return i({resolveOpenTarget:n,prepareApplicationOpen:n,openApplication:n,applyRuntimeHints:Y,clearRuntimeHints:Y,closeApplication:r,finalizeApplicationClose:r,prepareAppleRunner:be,configureProviderPortReverse:Ce})}function we(t){return Object.freeze({owner:t.owner,ownsDevice:t.ownsDevice,inspectFacts:async e=>Q(t,e),bind:async r=>{if(r.intent.kind===`exact-owner`&&!n(r.intent.owner,t.owner))throw new e(`UNSUPPORTED_OPERATION`,`WebDriver runtime owner identity does not match`);if(!t.ownsDevice(r.device))throw new e(`UNSUPPORTED_PLATFORM`,`WebDriver runtime does not own this device`);if(!$(t,r.device))throw new e(`UNSUPPORTED_OPERATION`,`The WebDriver provider session is no longer active for this device.`);return Ee(t,r.device,r.scope.signal)},shutdown:async()=>void 0})}function Te(e,n,r,i){let a={device:n,signal:r,resolveInteractor:t=>e.getInteractor?.(n,t),presentIosAcquisition:e.host.snapshot.presentIosAcquisition};return{...i.operations.captureSnapshot.available?c(a):{},...i.operations.captureScreenshot.available?g(a):{},...i.operations.focusPoint.available?u(a):{},...i.operations.typeText.available?l(a):{},...m({...a,facts:i.operations}),...i.operations.scrollDirection.available?ie(a):{},...pe({...a,facts:i.operations}),...t(i.operations.tapPoint,()=>o({...a,facts:i.operations,pause:async t=>await e.host.clock.sleep(t,r)}))}}function Ee(e,t,n){let i=t.platform===`apple`?`ios-device`:`android`,a=Q(e,t),o=a.operations.deployApp,s=Object.freeze({ensureReady:async()=>({...t,booted:!0}),bootTarget:async()=>({...t,booted:!0}),...r(ge({device:t,signal:n,getInteractor:(t,n)=>e.getInteractor?.(t,n)}),a.operations),...Te(e,t,n,a),networkDump:async t=>{let n=await e.host.appLogs.readRecent(t.sessionId,t.maxScanLines),{dump:r}=de(n.text,{...t,path:n.path,exists:n.exists,lineNumberOffset:n.skippedLines,backend:i});return Object.freeze({source:`app-log`,backend:i,dump:r,notes:Object.freeze(r.entries.length===0?[`No HTTP(s) entries were found in recent session app logs.`]:[])})},...o.available&&e.deployment?{deployApp:async r=>await e.deployment.deployApp(t,r,n),materializeAppSource:async r=>await Ae(e.host,t,r,n),deployMaterializedApp:async r=>await e.deployment.deployMaterializedApp(t,r,n)}:{}});return Object.freeze({device:t,owner:e.owner,facts:a,operations:s,[Symbol.asyncDispose]:async()=>void 0})}function Z(e,t){return e?x:t}function De(e){return e.reachable?ue(e.capabilities,e.operation)?x:Object.freeze({available:!1,reason:`owner-capability-missing`,hint:le(e.capabilities,e.operation)}):e.whenUnreachable}function Q(e,t){if(!$(e,t))return b(t,e.owner,{appLog:O,appDeployment:O,network:O,screenRecording:O,screenshot:O,viewport:O,focus:O,gesture:O,scroll:O,typeText:O,touch:O,elementText:O,back:O,home:O,orientation:O,tvRemote:O,keyboard:O,clipboard:O,appSwitcher:O,actionButton:W,triggerAppEvent:O,setSetting:O,readAlert:O,awaitAlert:O,acceptAlert:O,dismissAlert:O,audioProbeCapture:O,audioProbeQuery:O,perf:O,lifecycle:i({resolveOpenTarget:O,prepareApplicationOpen:O,openApplication:O,applyRuntimeHints:O,clearRuntimeHints:O,closeApplication:O,finalizeApplicationClose:O,prepareAppleRunner:O,configureProviderPortReverse:O})});let n=e.deployment?.fact(t)??E,r=b(t,e.owner,{appLog:S,appDeployment:E,network:S,screenRecording:C,screenshot:A,viewport:M,focus:N,gesture:F,scroll:I,typeText:P,touch:P,elementText:_e,back:R,home:z,orientation:B,tvRemote:V,keyboard:ve,clipboard:H,appSwitcher:U,actionButton:W,triggerAppEvent:q,setSetting:K,readAlert:G,awaitAlert:G,acceptAlert:G,dismissAlert:G,audioProbeCapture:J,audioProbeQuery:J,perf:J,lifecycle:X(t)}),o=e.getInteractor!==void 0&&ke(t),c=o&&e.snapshotAvailable!==!1?x:k,l=o&&e.screenshotAvailable!==!1?x:A,u=(t,n)=>De({reachable:o,capabilities:e.capabilities,operation:t,whenUnreachable:n});return Object.freeze({device:r.device,operations:{...r.operations,deployApp:n,materializeAppSource:n,deployMaterializedApp:n,sendPushNotification:D,appState:ye,networkDump:x,...d({capture:c,customActions:j,withoutActiveApp:c}),...te({capture:l}),...f({focus:Z(o,N)}),...ee({type:u(`type`,P)}),...a({unsupported:N,tap:u(`tap`,N),longPress:u(`longPress`,N),fill:u(`fill`,P),fillRef:P}),...h({unsupported:F,plan:Z(o,F),directionalFling:Z(o,F),multiTouch:Oe(t,o),targetAuthoredDrag:Z(o,F),viewport:Z(o,F)}),...s({scroll:u(`scroll`,I)}),...ce({back:u(`back`,R)}),...v({home:u(`home`,z)}),...se({orientation:u(`orientation`,B)}),...ne({tvRemote:V}),...y({unsupported:H,read:u(`clipboard.read`,H),write:u(`clipboard.write`,H)}),...ae({appSwitcher:u(`appSwitcher`,U)}),actionButton:W,..._({triggerAppEvent:Z(o,q)}),...re({setSetting:K}),...oe({read:G,wait:G,accept:G,dismiss:G}),...p({setViewport:M}),ensureReady:x,bootTarget:x,bootTargetHeadless:w,listApps:T,shutdownTarget:{available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver owns the target lifecycle for provider-owned devices.`}}})}function Oe(e,t){return t?e.platform===`apple`?L:x:F}function ke(e){return e.kind===`device`&&e.target===`mobile`&&(e.platform===`android`||e.platform===`apple`&&e.appleOs===`ios`)}function $(e,t){return e.isSessionActive?.(t)??e.ownsDevice(t)}async function Ae(e,t,n,r){return t.platform===`apple`?await e.appleDeployment.prepareArtifact(n,{signal:r}):await e.androidDeployment.prepareArtifact(n,{signal:r})}export{we as createWebDriverPlatformRuntimeOwner};
|
|
1
|
+
import{D as e}from"./sdk-contracts.js";import{en as t,tn as n}from"./sdk-batch.js";import{n as r,t as i}from"./application-lifecycle-runtime.js";import{A as a,B as o,D as s,E as c,F as l,G as u,H as ee,I as te,L as d,M as f,N as p,W as m,a as h,b as g,k as _,o as v,p as y,t as ne,u as re,v as ie,x as ae}from"./alert-runtime.js";import{i as oe,n as se}from"./touch-runtime.js";import{r as b}from"./platform-runtime-unavailable.js";import{r as ce,t as le}from"./capabilities.js";import{n as ue}from"./src7.js";import{r as de}from"./gesture-admission.js";import{n as fe}from"./interactor-operation-catalog.js";import{r as pe,t as me}from"./application-lifecycle-interaction.js";function he(e){return me({owner:`WebDriver`,openTargetIdentity:`bundle-id`,closeBeforeRelaunch:!0,binding:pe({device:e.device,signal:e.signal,resolveInteractor:t=>e.getInteractor(e.device,t)})})}const x=Object.freeze({available:!0}),S=Object.freeze({available:!1,reason:`unsupported-provider-mode`}),C=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose screen recording.`}),w=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Headless boot is unavailable for provider-owned devices.`}),T=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`WebDriver provider runtimes do not expose app inventory.`}),E=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose app deployment.`}),D=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Push notifications are unavailable for WebDriver provider-owned devices.`}),O=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`The WebDriver provider session is no longer active for this device.`}),k=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose snapshot capture for this device.`}),A=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose screenshot capture for this device.`}),j=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose iOS simulator custom snapshot actions.`}),M=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose viewport resizing.`}),N=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose focus for this device.`}),P=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose text entry for this device.`}),F=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose gestures for this device.`}),I=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose scrolling for this device.`}),L=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:de}),R=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes read element text from the captured tree only.`}),z=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose back for this device.`}),ge=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose home for this device.`}),B=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose orientation for this device.`}),V=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose tv-remote.`}),_e=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose keyboard actions.`}),H=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose clipboard access for this device.`}),ve=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose the app switcher for this device.`}),U=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`No WebDriver backend presses this system button.`}),W=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`fold poses a foldable iPhone simulator through Xcode Device Hub, which no WebDriver backend exposes.`}),G=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose native alert handling.`}),K=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose device settings.`}),q=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose app-event delivery for this device.`}),ye=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose a foreground app-state operation.`}),J=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose the audio probe.`}),be=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Apple runner preparation is unavailable for WebDriver-owned devices.`}),xe=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver open is supported only for its owned iOS or Android mobile-device sessions.`}),Se=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver close is supported only for its owned iOS or Android mobile-device sessions.`}),Y=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Runtime hints are not applied to provider-owned devices.`}),Ce=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose port reverse.`});function X(e){let t=e.platform===`android`&&e.kind===`device`&&e.target===`mobile`||e.platform===`apple`&&e.kind===`device`&&e.target===`mobile`&&e.appleOs===`ios`,n=t?x:xe,r=t?x:Se;return i({resolveOpenTarget:n,prepareApplicationOpen:n,openApplication:n,applyRuntimeHints:Y,clearRuntimeHints:Y,closeApplication:r,finalizeApplicationClose:r,prepareAppleRunner:be,configureProviderPortReverse:Ce})}function we(n){return Object.freeze({owner:n.owner,ownsDevice:n.ownsDevice,inspectFacts:async e=>Q(n,e),bind:async r=>{if(r.intent.kind===`exact-owner`&&!t(r.intent.owner,n.owner))throw new e(`UNSUPPORTED_OPERATION`,`WebDriver runtime owner identity does not match`);if(!n.ownsDevice(r.device))throw new e(`UNSUPPORTED_PLATFORM`,`WebDriver runtime does not own this device`);if(!$(n,r.device))throw new e(`UNSUPPORTED_OPERATION`,`The WebDriver provider session is no longer active for this device.`);return Ee(n,r.device,r.scope.signal)},shutdown:async()=>void 0})}function Te(e,t,r,i){let a={device:t,signal:r,resolveInteractor:n=>e.getInteractor?.(t,n),presentIosAcquisition:e.host.snapshot.presentIosAcquisition};return{...i.operations.captureSnapshot.available?o(a):{},...i.operations.captureScreenshot.available?m(a):{},...i.operations.focusPoint.available?l(a):{},...i.operations.typeText.available?c(a):{},...f({...a,facts:i.operations}),...i.operations.scrollDirection.available?_(a):{},...fe({...a,facts:i.operations}),...n(i.operations.tapPoint,()=>se({...a,facts:i.operations,pause:async t=>await e.host.clock.sleep(t,r)}))}}function Ee(e,t,n){let i=t.platform===`apple`?`ios-device`:`android`,a=Q(e,t),o=a.operations.deployApp,s=Object.freeze({ensureReady:async()=>({...t,booted:!0}),bootTarget:async()=>({...t,booted:!0}),...r(he({device:t,signal:n,getInteractor:(t,n)=>e.getInteractor?.(t,n)}),a.operations),...Te(e,t,n,a),networkDump:async t=>{let n=await e.host.appLogs.readRecent(t.sessionId,t.maxScanLines),{dump:r}=ue(n.text,{...t,path:n.path,exists:n.exists,lineNumberOffset:n.skippedLines,backend:i});return Object.freeze({source:`app-log`,backend:i,dump:r,notes:Object.freeze(r.entries.length===0?[`No HTTP(s) entries were found in recent session app logs.`]:[])})},...o.available&&e.deployment?{deployApp:async r=>await e.deployment.deployApp(t,r,n),materializeAppSource:async r=>await Ae(e.host,t,r,n),deployMaterializedApp:async r=>await e.deployment.deployMaterializedApp(t,r,n)}:{}});return Object.freeze({device:t,owner:e.owner,facts:a,operations:s,[Symbol.asyncDispose]:async()=>void 0})}function Z(e,t){return e?x:t}function De(e){return e.reachable?le(e.capabilities,e.operation)?x:Object.freeze({available:!1,reason:`owner-capability-missing`,hint:ce(e.capabilities,e.operation)}):e.whenUnreachable}function Q(e,t){if(!$(e,t))return b(t,e.owner,{appLog:O,appDeployment:O,network:O,screenRecording:O,screenshot:O,viewport:O,focus:O,gesture:O,scroll:O,typeText:O,touch:O,elementText:O,back:O,orientation:O,tvRemote:O,keyboard:O,clipboard:O,systemButton:O,fold:W,triggerAppEvent:O,settings:O,readAlert:O,awaitAlert:O,acceptAlert:O,dismissAlert:O,audioProbeCapture:O,audioProbeQuery:O,perf:O,lifecycle:i({resolveOpenTarget:O,prepareApplicationOpen:O,openApplication:O,applyRuntimeHints:O,clearRuntimeHints:O,closeApplication:O,finalizeApplicationClose:O,prepareAppleRunner:O,configureProviderPortReverse:O})});let n=e.deployment?.fact(t)??E,r=b(t,e.owner,{appLog:S,appDeployment:E,network:S,screenRecording:C,screenshot:A,viewport:M,focus:N,gesture:F,scroll:I,typeText:P,touch:P,elementText:R,back:z,orientation:B,tvRemote:V,keyboard:_e,clipboard:H,systemButton:U,fold:W,triggerAppEvent:q,settings:K,readAlert:G,awaitAlert:G,acceptAlert:G,dismissAlert:G,audioProbeCapture:J,audioProbeQuery:J,perf:J,lifecycle:X(t)}),o=e.getInteractor!==void 0&&ke(t),c=o&&e.snapshotAvailable!==!1?x:k,l=o&&e.screenshotAvailable!==!1?x:A,f=(t,n)=>De({reachable:o,capabilities:e.capabilities,operation:t,whenUnreachable:n});return Object.freeze({device:r.device,operations:{...r.operations,deployApp:n,materializeAppSource:n,deployMaterializedApp:n,sendPushNotification:D,appState:ye,networkDump:x,...ee({capture:c,customActions:j,withoutActiveApp:c}),...u({capture:l}),...te({focus:Z(o,N)}),...s({type:f(`type`,P)}),...oe({unsupported:N,tap:f(`tap`,N),longPress:f(`longPress`,N),fill:f(`fill`,P),fillRef:P}),...p({unsupported:F,plan:Z(o,F),directionalFling:Z(o,F),multiTouch:Oe(t,o),targetAuthoredDrag:Z(o,F),viewport:Z(o,F)}),...a({scroll:f(`scroll`,I)}),...ae({back:f(`back`,z)}),...g({orientation:f(`orientation`,B)}),...ie({tvRemote:V}),...y({unsupported:H,read:f(`clipboard.read`,H),write:f(`clipboard.write`,H)}),...re({unsupported:U,home:f(`home`,ge),appSwitcher:f(`appSwitcher`,ve)}),setFoldPose:W,...v({triggerAppEvent:Z(o,q)}),...h({setSetting:K,readSetting:K}),...ne({read:G,wait:G,accept:G,dismiss:G}),...d({setViewport:M}),ensureReady:x,bootTarget:x,bootTargetHeadless:w,listApps:T,shutdownTarget:{available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver owns the target lifecycle for provider-owned devices.`}}})}function Oe(e,t){return t?e.platform===`apple`?L:x:F}function ke(e){return e.kind===`device`&&e.target===`mobile`&&(e.platform===`android`||e.platform===`apple`&&e.appleOs===`ios`)}function $(e,t){return e.isSessionActive?.(t)??e.ownsDevice(t)}async function Ae(e,t,n,r){return t.platform===`apple`?await e.appleDeployment.prepareArtifact(n,{signal:r}):await e.androidDeployment.prepareArtifact(n,{signal:r})}export{we as createWebDriverPlatformRuntimeOwner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{D as t}from"./sdk-contracts.js";import{r as n,t as r}from"./png.js";import i from"node:zlib";const
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{D as t}from"./sdk-contracts.js";import{r as n,t as r}from"./png.js";import{t as i}from"./png-encode.js";import a from"node:zlib";const o=[137,80,78,71,13,10,26,10],s=[`IHDR`,`PLTE`,`IDAT`,`IEND`],c=/^[A-Za-z]{4}$/;function l(e){return!c.test(e)||e[0]<=`Z`&&!s.includes(e)}function u(e){return o.every((t,n)=>e[n]===t)}function d(e){if(e.length<33||!u(e))return null;let t=Buffer.from(e.buffer,e.byteOffset,e.byteLength);if(t.readUInt32BE(8)!==13||t.toString(`ascii`,12,16)!==`IHDR`)return null;let n=t.subarray(12,29);return t.readUInt32BE(29)===a.crc32(n)>>>0?{width:t.readUInt32BE(16),height:t.readUInt32BE(20),bitDepth:e[24],colorType:e[25],compressionMethod:e[26],filterMethod:e[27],interlace:e[28]}:null}function f(e){return e===2?3:e===6?4:null}function p(e){if(!u(e))return null;let t=Buffer.from(e.buffer,e.byteOffset,e.byteLength),n=[],r=8;for(;r+12<=e.length;){let i=t.readUInt32BE(r);if(i>2147483647||r+12+i>e.length)return null;let o=t.subarray(r+4,r+8+i);if(t.readUInt32BE(r+8+i)!==a.crc32(o)>>>0)return null;let s=t.toString(`ascii`,r+4,r+8);if(l(s))return null;if(n.push({type:s,data:t.subarray(r+8,r+8+i)}),s===`IEND`)return r+12+i===e.length?n:null;r+=12+i}return null}const m=[0,1,2,3,4];function h(e,t,n,r){switch(e){case 1:return t;case 2:return n;case 3:return t+n>>1;case 4:return g(t,n,r);default:return 0}}function g(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}function _(e,t){return e+t&255}function v(e){let t=d(e);return t===null||t.bitDepth!==8||t.compressionMethod!==0||t.filterMethod!==0||t.interlace!==0||f(t.colorType)===null?null:t}function y(e,t,n){let r=f(t.colorType);if(r===null)return null;let i=D(e);if(i===null)return null;let a=t.width*r,o=t.height*(a+1),s=E(i,o);if(s===null||s.length<o)return null;for(let e=0;e<n.y+n.height;e+=1)if(!b(s,e,a,r))return null;if(!C(s,n.y+n.height,t.height,a))return null;let c=r===4&&!w(s,n,a)?4:3;return{width:n.width,height:n.height,channels:c,pixels:T(s,n,a,r,c)}}function b(e,t,n,r){let i=t*(n+1)+1,a=e[i-1];return m.includes(a)?a===0?!0:t===0?x(e,i,n,r,a):S(e,i,n,r,a):!1}function x(e,t,n,r,i){let a=t+n;if(i===1||i===4){for(let n=t+r;n<a;n+=1)e[n]=_(e[n],e[n-r]);return!0}for(let n=t;n<a;n+=1){let a=n>=t+r?e[n-r]:0;e[n]=_(e[n],h(i,a,0,0))}return!0}function S(e,t,n,r,i){let a=t+n,o=t-(n+1);if(i===1){for(let n=t+r;n<a;n+=1)e[n]=_(e[n],e[n-r]);return!0}if(i===2){for(let n=t;n<a;n+=1)e[n]=_(e[n],e[o+(n-t)]);return!0}for(let n=t;n<a;n+=1){let a=n-t,s=n>=t+r?e[n-r]:0;e[n]=_(e[n],h(i,s,e[o+a],n>=t+r?e[o+a-r]:0))}return!0}function C(e,t,n,r){for(let i=t;i<n;i+=1)if(!m.includes(e[i*(r+1)]))return!1;return!0}function w(e,t,n){let r=255;for(let i=t.y;i<t.y+t.height&&r===255;i+=1){let a=i*(n+1)+4;for(let n=0;n<t.width;n+=1)r&=e[a+(t.x+n)*4]}return r===255}function T(e,t,n,r,i){let a=t.width*i,o=new Uint8Array(t.height*a);for(let s=0;s<t.height;s+=1){let c=(s+t.y)*(n+1)+1+t.x*r,l=s*a;if(r===i)o.set(e.subarray(c,c+t.width*r),l);else for(let n=0;n<t.width;n+=1){let t=c+n*r,a=l+n*i;o[a]=e[t],o[a+1]=e[t+1],o[a+2]=e[t+2]}}return o}function E(e,t){try{return a.inflateSync(e,{maxOutputLength:t})}catch{return null}}function D(e){let t=p(e);if(t===null)return null;let n=[];for(let e of t){if(e.type===`PLTE`||e.type===`tRNS`)return null;e.type===`IDAT`&&n.push(e.data)}return n.length===0?null:Buffer.concat(n)}var O=e({cropPngBytes:()=>k});function k(e,t,n){let r=v(e);if(r!==null&&!N(t,r.width,r.height)){M(t,r.width,r.height);let n=y(e,r,t);if(n!==null)return i(n.pixels,n.width,n.height,n.channels)}return A(e,t,n)}function A(e,t,i){let a=r(e,i);return M(t,a.width,a.height),N(t,a.width,a.height)?null:n.PNG.sync.write(j(a,t))}function j(e,t){let r=new n.PNG({width:t.width,height:t.height});for(let n=0;n<t.height;n+=1){let i=((n+t.y)*e.width+t.x)*4;e.data.copy(r.data,n*r.width*4,i,i+t.width*4)}return r}function M(e,n,r){if(e.x+e.width>n||e.y+e.height>r)throw new t(`INVALID_ARGS`,`Screenshot crop box ${e.width}x${e.height} at (${e.x}, ${e.y}) exceeds the ${n}x${r} image`)}function N(e,t,n){return e.x===0&&e.y===0&&e.width===t&&e.height===n}export{O as n,k as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"node:zlib";const t=Uint8Array.from([137,80,78,71,13,10,26,10]),n=Buffer.from(`IHDR`,`ascii`),r=Buffer.from(`IDAT`,`ascii`),i=Buffer.from(`IEND`,`ascii`),a=new Uint8Array;function o(e,o,l,u){let d=Buffer.alloc(13);return d.writeUInt32BE(o,0),d.writeUInt32BE(l,4),d[8]=8,d[9]=u===3?2:6,Buffer.concat([t,c(n,d),c(r,s(e,o,l,u)),c(i,a)])}function s(t,n,r,i){let a=n*i,o=new Uint8Array(r*(a+1));for(let e=0;e<r;e+=1){let n=e*(a+1)+1;o.set(t.subarray(e*a,(e+1)*a),n)}return e.deflateSync(o,{level:6})}function c(t,n){let r=Buffer.allocUnsafe(12+n.length);return r.writeUInt32BE(n.length,0),r.set(t,4),r.set(n,8),r.writeUInt32BE(e.crc32(n,e.crc32(t))>>>0,8+n.length),r}export{o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D as e}from"./sdk-contracts.js";import{promises as t}from"node:fs";async function n(n){let r=await t.open(n,`r`);try{let t=Buffer.alloc(24),{bytesRead:n}=await r.read(t,0,t.length,0);if(n<t.length||t.toString(`ascii`,12,16)!==`IHDR`)throw new e(`COMMAND_FAILED`,`Screenshot file is not a valid PNG`);return{width:t.readUInt32BE(16),height:t.readUInt32BE(20)}}finally{await r.close()}}export{n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{D as t,U as n}from"./sdk-contracts.js";import{r}from"./diagnostics.js";import"./diagnostics2.js";import{n as i,r as a,t as o}from"./png.js";import{n as s,r as c,t as l}from"./png-worker-contract.js";import u from"node:path";import d from"node:fs";import{fileURLToPath as f}from"node:url";import{Worker as p}from"node:worker_threads";function m(e,t){try{let n=f(e),r=u.extname(n)||`.js`;return[u.join(u.dirname(n),`${t}${r}`),u.join(u.dirname(n),`internal`,`${t}${r}`)].find(e=>d.existsSync(e))??null}catch{return null}}var h=e({computePngRgbDifferenceAsync:()=>
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{D as t,U as n}from"./sdk-contracts.js";import{r}from"./diagnostics.js";import"./diagnostics2.js";import{n as i,r as a,t as o}from"./png.js";import{n as s,r as c,t as l}from"./png-worker-contract.js";import u from"node:path";import d from"node:fs";import{fileURLToPath as f}from"node:url";import{Worker as p}from"node:worker_threads";function m(e,t){try{let n=f(e),r=u.extname(n)||`.js`;return[u.join(u.dirname(n),`${t}${r}`),u.join(u.dirname(n),`internal`,`${t}${r}`)].find(e=>d.existsSync(e))??null}catch{return null}}var h=e({computePngRgbDifferenceAsync:()=>L,computeScreenshotDiffPixelsAsync:()=>R,cropPngBytesAsync:()=>I,decodePngAsync:()=>M,decodeScreenshotImageAsync:()=>N,encodePngAsync:()=>F,prewarmPngWorker:()=>A,terminatePngWorker:()=>j,transcodeScreenshotToPngAsync:()=>z}),g=class extends Error{};let _=null,v=!1,y=!1,b=0;const x=new Map;function S(e){v=!0,!y&&(y=!0,r({level:`warn`,phase:`png_worker_unavailable`,data:{reason:e}}),process.emitWarning(`PNG worker unavailable, falling back to in-process PNG processing: ${e}`))}function C(e){let r=x.get(e.id);r&&(x.delete(e.id),E(),e.ok?r.resolve(e.result):r.reject(new t(n(e.error.code),e.error.message,e.error.details)))}function w(e,t){_===e&&(S(t.message),_=null,e.terminate().catch(()=>{}),T(new g(`PNG worker failed: ${t.message}`)))}function T(e){let t=[...x.values()];x.clear();for(let n of t)n.reject(e)}function E(){_&&(x.size>0?_.ref():_.unref())}function D(){if(v)return null;if(_)return _;let e=m(import.meta.url,`png-worker`);if(!e)return S(`worker entry module not found next to the current module`),null;try{let t=new p(e,{execArgv:e.endsWith(`.ts`)?[`--experimental-strip-types`]:[]});return t.on(`message`,C),t.on(`error`,e=>{w(t,e)}),t.on(`exit`,e=>{w(t,Error(`PNG worker exited with code ${e}`))}),t.unref(),_=t,t}catch(e){return S(`failed to spawn worker: ${e instanceof Error?e.message:String(e)}`),null}}function O(e){let t=D();if(!t)return Promise.reject(new g(`PNG worker is unavailable`));b+=1;let n=b;return new Promise((r,i)=>{x.set(n,{resolve:r,reject:i}),E();try{t.postMessage({...e,id:n})}catch(e){x.delete(n),E(),i(new g(`failed to post job to PNG worker: ${e instanceof Error?e.message:String(e)}`))}})}async function k(e,t){try{return await O(e)}catch(e){if(e instanceof g)return await t();throw e}}function A(){D()}async function j(){let e=_;_=null,T(new g(`PNG worker terminated`)),e&&await e.terminate()}async function M(e,t){return P(await k({kind:`decode`,png:e,label:t},()=>{let n=o(e,t);return{kind:`decode`,width:n.width,height:n.height,data:n.data}}))}async function N(e,t){return P(await k({kind:`decode-image`,image:e,label:t},async()=>{let{decodeScreenshotImage:n}=await import(`./screenshot-image.js`),r=n(e,t);return{kind:`decode-image`,width:r.width,height:r.height,data:r.data}}))}function P(e){let t=new a.PNG({width:e.width,height:e.height});return t.data=l(e.data),t}async function F(e){let t=await k({kind:`encode`,width:e.width,height:e.height,data:e.data},()=>({kind:`encode`,png:a.PNG.sync.write(e)}));return l(t.png)}async function I(e,t,n){let r=await k({kind:`crop`,png:e,label:n,box:t},async()=>{let{cropPngBytes:r}=await import(`./png-crop-bytes.js`).then(e=>e.n);return{kind:`crop`,png:r(e,t,n)}});return r.png===null?null:l(r.png)}async function L(e,t,n){let{kind:r,...i}=await k({kind:`rgb-difference`,firstPng:e,secondPng:t,label:n},()=>({kind:`rgb-difference`,...s(o(e,n),o(t,n))}));return i}async function R(e){let{kind:t,...n}=await k({kind:`diff-pixels`,...e},()=>({kind:`diff-pixels`,...c(e)}));return{...n,diffData:l(n.diffData)}}async function z(e,t){if(i(e))return e;let n=await k({kind:`jpeg-to-png`,image:e,label:t},async()=>{let{transcodeScreenshotToPng:n}=await import(`./screenshot-image.js`);return{kind:`jpeg-to-png`,png:n(e,t)}});return l(n.png)}export{N as a,A as c,M as i,j as l,R as n,F as o,I as r,h as s,L as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e,j as t}from"./sdk-contracts.js";import{a as n,y as r}from"./sdk-device.js";import{Yt as i}from"./sdk-batch.js";import{d as a}from"./scroll-gesture.js";import{c as o}from"./sdk-remote-config.js";import"./device.js";import{i as s,r as c}from"./device-rotation.js";import{c as l}from"./exec.js";import"./command.js";import{r as u}from"./version.js";import{n as d,r as f,t as p}from"./capabilities.js";import{t as ee}from"./webdriver-source.js";import{t as m}from"./providers.js";import h from"node:path";import te from"node:fs";import g from"node:fs/promises";import{setTimeout as ne}from"node:timers/promises";function re(e,t){let n=e?.bundleId??t?.appIdentifierHint,r=e?.packageName??t?.packageNameHint;return{bundleId:n,packageName:r,appName:e?.appName,launchTarget:ae(e?.launchTarget,n,r)}}function ie(e){return e===`ios`?`xctest`:`android`}function ae(...e){return e.find(e=>e!==void 0)}function oe(e){let t=async(t,n,r,i,a)=>{let o=e.findSessionForDevice(t);if(!o)return;let s=await ce(e,o,t,n,r,i,a);return await o.client.installApp(s?.appReference??r,a),re(s,i)};return Object.freeze({fact:t=>se(e.findSessionForDevice(t)),installApp:t,installInstallablePath:async(e,n,r,i)=>await t(e,``,n,r,i),deployApp:async(e,n,r)=>_(await t(e,n.app,n.appPath,{relaunch:n.replaceExisting,appIdentifierHint:n.app,packageNameHint:n.app},r),n.app),deployMaterializedApp:async(e,n,r)=>_(await t(e,``,n.artifact.installablePath,{appIdentifierHint:n.artifact.bundleId,packageNameHint:n.artifact.packageName},r))})}function se(e){return e?p(e.capabilities,`install`)?Object.freeze({available:!0}):Object.freeze({available:!1,reason:`owner-capability-missing`,hint:f(e.capabilities,`install`)}):Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`The WebDriver provider session is no longer active for this device.`})}async function ce(t,n,i,a,o,s,c){if(!p(n.capabilities,`install`))throw new e(`UNSUPPORTED_OPERATION`,f(n.capabilities,`install`),{provider:t.provider,deviceId:i.id,platform:r(i)});let l=n.prepared.uploadApp??t.uploadApp;if(l)return await l({provider:t.provider,lease:n.lease,device:i,app:a,appPath:o,options:s,signal:c})}function _(t,n){if(!t)throw new e(`UNSUPPORTED_OPERATION`,`The WebDriver provider session no longer supports app deployment.`);return{...t.bundleId?{bundleId:t.bundleId}:{},...t.packageName?{packageName:t.packageName}:{},...t.appName?{appName:t.appName}:{},...t.launchTarget??n?{launchTarget:t.launchTarget??n}:{}}}function v(e){return{provider:e.provider,providerSessionId:e.providerSessionId,status:e.artifacts.length>0?`ready`:`pending`,cloudArtifacts:e.artifacts,...e.artifacts.length>0?{}:{message:e.pendingMessage}}}function le(e){return{provider:e.provider,providerSessionId:e.providerSessionId,status:`unavailable`,cloudArtifacts:[],message:e.error instanceof Error?e.error.message:String(e.error)}}function y(e){return{"x-agent-device-client":`agent-device-cli`,"x-agent-device-version":e}}async function ue(n,r){try{await r()}catch(r){n instanceof e&&(n.details={...n.details,cleanupError:t(r)})}}function de(e,t){return typeof e==`function`?e(t):e}function b(e){return`Basic ${Buffer.from(`${e.username}:${e.accessKey}`).toString(`base64`)}`}function fe(e){let t=0;for(;t<e.length&&e.charCodeAt(t)===47;)t+=1;return t===0?e:e.slice(t)}function pe(e){let t=e.length-1;for(;t>=0&&e.charCodeAt(t)===47;)--t;return t===e.length-1?e:e.slice(0,t+1)}function me(e){if(e.pathname.endsWith(`/`))return e;let t=new URL(e);return t.pathname=`${t.pathname}/`,t}const x=`webdriver_request_timeout`;function S(t){return t instanceof e&&t.details?.reason===x}var he=class{endpoint;headers;requestPolicy;constructor(e){this.endpoint=me(new URL(e.endpoint)),this.headers={...y(e.clientVersion),...e.auth?{Authorization:b(e.auth)}:{},...e.headers},this.requestPolicy={timeoutMs:e.requestPolicy?.timeoutMs??3e4,retryAttempts:e.requestPolicy?.retryAttempts??1,retryDelayMs:e.requestPolicy?.retryDelayMs??250}}async requestValue(e,t,n,r){return await this.requestValueWithRetries(e,t,n,{retryAttempts:r?.retryAttempts??this.requestPolicy.retryAttempts,timeoutMs:r?.timeoutMs??this.requestPolicy.timeoutMs,signal:r?.signal})}async requestValueWithRetries(e,t,n,r){let i;for(let a=0;a<=r.retryAttempts;a+=1)try{return await this.requestValueOnce(e,t,n,r.timeoutMs,r.signal)}catch(e){if(i=e,!ge(e,a,r.retryAttempts,r.signal))throw e;await ne(this.requestPolicy.retryDelayMs,void 0,{signal:r.signal})}throw i}async requestValueOnce(e,t,n,r,i){let{ok:a,status:o,text:s}=await this.fetchWebDriver(e,t,n,r,i),c=s?ve(s):{};if(!a)throw ye(o,c);return _e(c)}async fetchWebDriver(e,t,n,r,i){let a=AbortSignal.timeout(r),o=i?AbortSignal.any([i,a]):a;try{let r=await fetch(new URL(fe(t),this.endpoint),{method:e,headers:{Accept:`application/json`,...n===void 0?{}:{"Content-Type":`application/json`},...this.headers},body:n===void 0?void 0:JSON.stringify(n),signal:o});return{ok:r.ok,status:r.status,text:await r.text()}}catch(n){throw a.aborted&&!i?.aborted?be(e,t,r,n):n}}};function ge(e,t,n,r){return!r?.aborted&&xe(e)&&t<n}function _e(e){if(!e||typeof e!=`object`)return e;let t=e;return`value`in t?t.value:e}function ve(t){try{return JSON.parse(t)}catch(n){throw new e(`COMMAND_FAILED`,`WebDriver response was not valid JSON.`,{text:t},n)}}function ye(t,n){let r=n&&typeof n==`object`&&`value`in n?n.value:n,i=r&&typeof r==`object`&&typeof r.message==`string`?r.message:`WebDriver request failed with HTTP ${t}.`;return new e(`COMMAND_FAILED`,i,{status:t,response:n})}function be(t,n,r,i){return new e(`COMMAND_FAILED`,`WebDriver ${t} ${n} timed out after ${r}ms.`,{reason:x,method:t,path:n,timeoutMs:r},i instanceof Error?i:void 0)}function xe(t){if(S(t))return!0;if(t instanceof e){let e=t.details?.status;return typeof e==`number`&&e>=500}return t instanceof TypeError}var Se=class{transport;sessionCreateTimeoutMs;sessionId;constructor(e){this.transport=new he(e),this.sessionCreateTimeoutMs=e.requestPolicy?.sessionCreateTimeoutMs??18e4}async createSession(e,t){let n=we(await this.requestValue(`POST`,`/session`,{capabilities:Ce(e)},{retryAttempts:0,timeoutMs:Oe(this.sessionCreateTimeoutMs,t?.deadline)}));return this.sessionId=n.sessionId,n}async deleteSession(){let e=this.requireSessionId();await this.requestValue(`DELETE`,`/session/${e}`),this.sessionId=void 0}async installApp(e,t){await this.sessionRequest(`POST`,`/appium/device/install_app`,{appPath:e},{signal:t})}async activateApp(e){try{await this.sessionRequest(`POST`,`/appium/device/activate_app`,{appId:e})}catch{await this.executeScript(`mobile: activateApp`,[{appId:e,bundleId:e}])}}async terminateApp(e){try{await this.sessionRequest(`POST`,`/appium/device/terminate_app`,{appId:e})}catch{await this.executeScript(`mobile: terminateApp`,[{appId:e,bundleId:e}])}}async performActions(e){await this.sessionRequest(`POST`,`/actions`,{actions:e})}async releaseActions(){await this.sessionRequest(`DELETE`,`/actions`,void 0,{retryAttempts:0})}async sendKeys(e){await this.sessionRequest(`POST`,`/keys`,{value:Array.from(e)})}async hideKeyboard(){await this.sessionRequest(`POST`,`/appium/device/hide_keyboard`,void 0,{retryAttempts:0})}async isKeyboardShown(e){let t;try{t=await this.sessionRequest(`GET`,`/appium/device/is_keyboard_shown`,void 0,{retryAttempts:0,...e===void 0?{}:{timeoutMs:e}})}catch(e){if(O(e))return`unsupported`;throw e}return typeof t==`boolean`?t:`unsupported`}async activeElement(e){let t=e===void 0?void 0:Date.now()+e,n;try{n=De(await this.sessionRequest(`GET`,`/element/active`,void 0,T(t)))}catch(e){if(O(e))return`unsupported`;if(D(e))return`none`;throw e}if(n===void 0)return`unsupported`;try{let e=await this.sessionRequest(`GET`,`/element/${encodeURIComponent(n)}/rect`,void 0,T(t));return{id:n,rect:C(e)}}catch(e){if(O(e))return`unsupported`;if(D(e))return`none`;throw e}}async back(){await this.sessionRequest(`POST`,`/back`)}async setRotation(e){await this.sessionRequest(`POST`,`/rotation`,{x:0,y:0,z:e})}async setOrientation(e){await this.sessionRequest(`POST`,`/orientation`,{orientation:e})}async source(t){let n=await this.sessionRequest(`GET`,`/source`,void 0,t);if(typeof n!=`string`)throw new e(`COMMAND_FAILED`,`WebDriver source response was not a string`,{valueType:typeof n});return n}async screenshot(t){let n=await this.sessionRequest(`GET`,`/screenshot`);if(typeof n!=`string`)throw new e(`COMMAND_FAILED`,`WebDriver screenshot response was not base64 text`,{valueType:typeof n});await g.writeFile(t,Buffer.from(n,`base64`))}async windowRect(){return C(await this.sessionRequest(`GET`,`/window/rect`))}async executeScript(e,t=[]){return await this.sessionRequest(`POST`,`/execute/sync`,{script:e,args:t})}async sessionRequest(e,t,n,r){let i=this.requireSessionId();return await this.requestValue(e,`/session/${i}${t}`,n,r)}requireSessionId(){if(!this.sessionId)throw new e(`SESSION_NOT_FOUND`,`WebDriver session has not been created yet.`);return this.sessionId}async requestValue(e,t,n,r){return await this.transport.requestValue(e,t,n,r)}};function C(t){if(!t||typeof t!=`object`)throw new e(`COMMAND_FAILED`,`WebDriver window rect response was empty.`);let n=t,r={x:w(n,`x`),y:w(n,`y`),width:w(n,`width`),height:w(n,`height`)};if(r.x===void 0||r.y===void 0||r.width===void 0||r.height===void 0)throw new e(`COMMAND_FAILED`,`WebDriver window rect response was invalid.`,{response:n});return r}function w(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function Ce(e){return`alwaysMatch`in e||`firstMatch`in e?e:{alwaysMatch:e}}function we(t){if(!t||typeof t!=`object`)throw new e(`COMMAND_FAILED`,`WebDriver create-session response was empty.`);let n=t,r=typeof n.sessionId==`string`?n.sessionId:typeof n.session_id==`string`?n.session_id:void 0;if(!r)throw new e(`COMMAND_FAILED`,`WebDriver create-session response missed sessionId.`,{response:n});return{sessionId:r,capabilities:n.capabilities&&typeof n.capabilities==`object`?n.capabilities:{}}}const Te=new Set([405,501]),Ee=new Set([`unknown command`,`unknown method`]);function De(e){if(!e||typeof e!=`object`)return;let t=e,n=t[`element-6066-11e4-a52e-4f735466cecf`]??t.ELEMENT;return typeof n==`string`&&n.length>0?n:void 0}function T(e){return e===void 0?{retryAttempts:0}:{retryAttempts:0,timeoutMs:E(e)}}function Oe(e,t){return t===void 0?e:Math.min(e,E(t))}function E(e){return Math.max(0,e-Date.now())}function D(t){return t instanceof e&&k(t).toLowerCase()===`no such element`}function O(t){if(!(t instanceof e))return!1;let n=t.details?.status;return typeof n==`number`&&Te.has(n)?!0:Ee.has(k(t).toLowerCase())}function k(e){let t=e.details?.response,n=t&&typeof t==`object`?t.value:void 0,r=n&&typeof n==`object`?n.error:void 0;return typeof r==`string`?r:``}function A(e,t){return{type:`pointer`,id:e,parameters:{pointerType:`touch`},actions:t}}async function ke(e){return j(ee(e,`android`).nodes)}function Ae(e){return j(ee(e).nodes)}function j(e){let t=e.flatMap(e=>je(e)&&Me(e.rect)?[e.rect]:[]).sort((e,t)=>t.width*t.height-e.width*e.height)[0];return t?{x:t.x,y:t.y,width:t.width,height:t.height}:void 0}function je(e){let t=e.type?.toLowerCase()??``;return e.visibleToUser!==!1&&(t.includes(`scrollview`)||t.includes(`listview`)||t.includes(`recyclerview`))}function Me(e){return!!e&&e.width>=50&&e.height>=50}async function Ne(t,n,r){let i=[];for(let e of n===`android`?[`rotation`,`orientation`]:[`orientation`,`rotation`])try{await Re(t,e,r);return}catch(t){if(!Ie(t))throw t;i.push({transport:e,error:t instanceof Error?t.message:String(t)})}throw new e(`COMMAND_FAILED`,`Could not set device orientation to ${r} on the hosted WebDriver session.`,{hint:`The provider driver rejected both orientation endpoints. Set the orientation as a session capability instead, for example connect --provider-device-orientation portrait.`,rotation:r,attempts:i})}const Pe=new Set([`unknown command`,`unknown method`]),Fe=new Set([404,405]);function Ie(t){if(!(t instanceof e)||t.code===`SESSION_NOT_FOUND`)return!1;let n=Le(t.details?.response);if(n)return Pe.has(n);let r=t.details?.status;return typeof r==`number`&&Fe.has(r)}function Le(e){if(!e||typeof e!=`object`)return``;let t=e.value;if(!t||typeof t!=`object`)return``;let n=t.error;return typeof n==`string`?n:``}async function Re(e,t,n){if(t===`rotation`){await e.setRotation(s(n));return}await e.setOrientation(c(n))}const M=1500;function ze(e){return new Promise(t=>setTimeout(t,e))}function N(t,n,r){return new e(`COMMAND_FAILED`,`fill tapped (${t}, ${n}) but ${r}`,{reason:`text_entry_focus_not_observed`,x:t,y:n,hint:`The tap most likely missed the field. Re-check the target with snapshot -i and fill the element it reports, rather than retrying the same coordinates.`})}function Be(t,n){return new e(`COMMAND_FAILED`,`fill tapped (${t}, ${n}) but this driver reports neither the focused element nor keyboard state, so the text was not sent`,{reason:`text_entry_focus_unobservable`,x:t,y:n,hint:`This provider cannot confirm a field took focus. Use press <target> followed by type <text> to enter it anyway, accepting that nothing witnesses which field receives the keys.`})}function Ve(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function He(e){return new Ue(e.client,e.backend,e.capabilities,e.targetId)}var Ue=class{client;backend;capabilities;targetId;constructor(e,t,n,r){this.client=e,this.backend=t,this.capabilities=n,this.targetId=r}async open(e,t){if(t?.url){await this.client.executeScript(`mobile: deepLink`,[{url:t.url,package:e}]);return}let n=t?.appBundleId??e;n&&await this.client.activateApp(n)}async openDevice(){await this.client.executeScript(`mobile: activateApp`,[{}])}async close(e){e&&await this.client.terminateApp(e)}async tap(e,t){return this.requireSupport(`tap`),await this.pointerGesture(`tap`,[{type:`pointerMove`,duration:0,x:e,y:t},{type:`pointerDown`,button:0},{type:`pointerUp`,button:0}]),{backend:`webdriver`,x:e,y:t}}async doubleTap(e,t){return this.requireSupport(`doubleTap`),await this.pointerGesture(`doubleTap`,[{type:`pointerMove`,duration:0,x:e,y:t},{type:`pointerDown`,button:0},{type:`pointerUp`,button:0},{type:`pause`,duration:80},{type:`pointerDown`,button:0},{type:`pointerUp`,button:0}]),{backend:`webdriver`,x:e,y:t}}async swipe(e,t,n,r,i=400){return this.requireSupport(`swipe`),await this.pointerGesture(`swipe`,[{type:`pointerMove`,duration:0,x:e,y:t},{type:`pointerDown`,button:0},{type:`pointerMove`,duration:i,x:n,y:r},{type:`pointerUp`,button:0}]),{backend:`webdriver`,x1:e,y1:t,x2:n,y2:r,durationMs:i}}async longPress(e,t,n=600){return this.requireSupport(`longPress`),await this.pointerGesture(`longPress`,[{type:`pointerMove`,duration:0,x:e,y:t},{type:`pointerDown`,button:0},{type:`pause`,duration:n},{type:`pointerUp`,button:0}]),{backend:`webdriver`,x:e,y:t,durationMs:n}}async focus(e,t){return await this.tap(e,t)}async type(e){this.requireSupport(`type`),await this.client.sendKeys(e)}async fill(t,n,r,i){if(this.requireSupport(`fill`),r.length===0)throw new e(`UNSUPPORTED_OPERATION`,`fill with empty text (clear field) is not supported on the webdriver backend`,{hint:`Use a visible clear/reset control in the app, or fill the field with the intended replacement text directly.`});let a=await this.readTextEntryState();await this.tap(t,n);let o=await this.awaitTextEntryReadiness(a,t,n);return await this.type(r),{backend:`webdriver`,x:t,y:n,text:r,textEntryReadiness:o}}async scroll(e,t){this.requireSupport(`scroll`);let n=t?.durationMs??350;await this.client.hideKeyboard().catch(()=>void 0);let r=await this.scrollGestureFrame(),i=a({direction:e,amount:t?.amount,pixels:t?.pixels,referenceWidth:r.width,referenceHeight:r.height}),o={...i,x1:i.x1+r.x,y1:i.y1+r.y,x2:i.x2+r.x,y2:i.y2+r.y};return await this.swipe(o.x1,o.y1,o.x2,o.y2,n),{backend:`webdriver`,...o,distance:i.pixels,durationMs:n}}async gestureViewport(){return await this.scrollGestureFrame()}async performGesture(e){return this.requireSupport(Ge(e)),await this.client.performActions(e.pointers.map(e=>A(`gesture-pointer-${e.pointerId}`,We(e.samples)))),await this.client.releaseActions().catch(()=>void 0),{backend:`webdriver-w3c-actions`}}async screenshot(e,t){this.requireSupport(`screenshot`),await this.client.screenshot(e)}async snapshot(e){return this.requireSupport(`snapshot`),await this.captureSource(e?.signal)}async captureSource(e){let t=await this.readSource(e);if(this.backend===`xctest`){let{acquireWebDriverIosSnapshot:e}=await import(`./webdriver-ios-snapshot.js`);return e(t,this.targetId)}let{parseWebDriverSourceFacts:n}=await import(`./webdriver-source.js`).then(e=>e.n);return{backend:`android`,producer:`appium-source`,nodes:n(t,`android`).nodes}}async readSource(e){try{return await this.client.source(e===void 0?{}:{signal:e})}catch(e){throw S(e)?Ke(e):e}}async back(e){this.requireSupport(`back`),await this.client.back()}async home(){this.requireSupport(`home`),await this.client.executeScript(`mobile: pressButton`,[{name:`home`}])}async setOrientation(e){this.requireSupport(`orientation`),await Ne(this.client,this.backend,e)}async appSwitcher(){this.requireSupport(`appSwitcher`),await this.client.executeScript(`mobile: pressButton`,[{name:`appSwitch`}])}async tvRemote(e,t){this.unsupported(`tvRemote`)}async actionButton(){throw new e(`UNSUPPORTED_OPERATION`,`action-button presses iPhone Action Button hardware, which no WebDriver backend exposes`,{provider:this.capabilities.provider,platform:this.capabilities.platform,operation:`actionButton`,reason:`unsupported-provider-mode`})}async readClipboard(){this.requireSupport(`clipboard.read`);let e=await this.client.executeScript(`mobile: getClipboard`,[{}]);return typeof e==`string`?e:``}async writeClipboard(e){this.requireSupport(`clipboard.write`),await this.client.executeScript(`mobile: setClipboard`,[{content:e}])}async setSetting(e,t,n,r){this.unsupported(`settings`)}async readAlert(){this.unsupported(`alert`)}async awaitAlert(){this.unsupported(`alert`)}async acceptAlert(){this.unsupported(`alert`)}async dismissAlert(){this.unsupported(`alert`)}async awaitTextEntryReadiness(e,t,n){let r=e.keyboard,i=Date.now()+2e3,a=e.focusedElementId,o=await this.pollWithinBudget(i,async e=>{let r=await this.client.activeElement(e);return r===`unsupported`?`abandon`:r===`none`?`retry`:r.id!==a||Ve(r.rect,t,n)?`satisfied`:`retry`});if(o===`satisfied`)return`focused-element`;if(o===`expired`)throw N(t,n,`nothing there took text-entry focus, so the text was not sent`);if(r===`unsupported`)throw Be(t,n);if(r)throw N(t,n,`the keyboard was already up and this driver cannot report which field holds focus, so the text was not sent`);if(await this.pollWithinBudget(i,async e=>await this.client.isKeyboardShown(e)===!0?`satisfied`:`retry`)===`satisfied`)return`keyboard-shown`;throw N(t,n,`no keyboard appeared, so the text was not sent`)}async readTextEntryState(){let[e,t]=await Promise.all([this.client.isKeyboardShown(M),this.client.activeElement(M)]);return{keyboard:e,focusedElementId:t===`none`||t===`unsupported`?void 0:t.id}}async pollWithinBudget(e,t){let n=!1,r;for(;;){let i=e-Date.now();if(i<=0)break;try{let e=await t(Math.min(M,i));if(n=!0,e!==`retry`)return e}catch(e){r=e}let a=e-Date.now();if(a<=0)break;await ze(Math.min(100,a))}if(!n&&r!==void 0)throw r;return`expired`}async pointerGesture(e,t){await this.client.performActions([A(e,t)]),await this.client.releaseActions().catch(()=>void 0)}async scrollGestureFrame(){return await this.client.source().then(e=>this.backend===`xctest`?Ae(e):ke(e)).catch(()=>void 0)||await this.client.windowRect()}requireSupport(e){p(this.capabilities,e)||this.unsupported(e)}unsupported(t){throw new e(`UNSUPPORTED_OPERATION`,f(this.capabilities,t),{provider:this.capabilities.provider,platform:this.capabilities.platform,operation:t})}};function We(t){let n=t[0];if(!n)throw new e(`INVALID_ARGS`,`WebDriver gesture pointer requires samples`);let r=[{type:`pointerMove`,duration:0,x:n.point.x,y:n.point.y},{type:`pointerDown`,button:0}];for(let e=1;e<t.length;e+=1){let n=t[e-1],i=t[e];r.push({type:`pointerMove`,duration:i.offsetMs-n.offsetMs,x:i.point.x,y:i.point.y})}return r.push({type:`pointerUp`,button:0}),r}function Ge(e){if(e.topology===`single`)return`swipe`;switch(e.intent){case`pan`:case`transform`:return`transformGesture`;case`pinch`:return`pinch`;case`rotate`:return`rotateGesture`}}function Ke(t){return new e(`COMMAND_FAILED`,`The cloud driver did not finish reading the screen in its budget.`,{...t.details,hint:`A screen that never goes idle (looping video, live ticker, continuous animation) gives the driver no moment to read the UI tree. This read has the transport's own budget and does not grow with --timeout; take a screenshot, or drive the screen from refs an earlier snapshot already captured.`},t)}var qe=class{sessionsByLeaseId=new Map;ownedDeviceIds=new Set;releasedProviderSessionIdsByLeaseId=new Map;options;constructor(e){this.options=e}ownsDevice(e){return this.ownedDeviceIds.has(e.id)}findSessionForDevice(e){return[...this.sessionsByLeaseId.values()].find(t=>t.device.id===e.id)}findSessionForLease(e){return this.sessionsByLeaseId.get(e)}getInteractor(e){return this.findSessionForDevice(e)?.interactor}heartbeat(e){if(e.leaseProvider===this.options.provider&&this.sessionsByLeaseId.has(e.leaseId))return{provider:this.options.provider}}async allocate(e,t){if(e.leaseProvider!==this.options.provider)return;if(this.sessionsByLeaseId.has(e.leaseId))return this.heartbeat(e);let n=await this.prepareSession(e,t),r=new Se({clientVersion:this.options.clientVersion,endpoint:n.endpoint,auth:n.auth,headers:n.headers,requestPolicy:this.options.requestPolicy}),i=await this.createSessionWithPreparedCleanup(r,n,e,t),a=this.deviceForLease(e,n),o=n.providerSessionId??i.sessionId,s=d({provider:this.options.provider,platform:n.platform,overrides:this.options.capabilityOverrides});return this.sessionsByLeaseId.set(e.leaseId,Object.freeze({lease:e,device:a,client:r,prepared:n,capabilities:s,webDriverSessionId:i.sessionId,providerSessionId:o,interactor:He({client:r,backend:ie(n.platform),capabilities:s,targetId:a.id})})),this.ownedDeviceIds.add(a.id),{provider:this.options.provider,deviceId:a.id,sessionId:i.sessionId,providerSessionId:o,capabilities:s,...n.providerData}}async release(e){if(e.leaseProvider!==this.options.provider)return;let t=this.sessionsByLeaseId.get(e.leaseId);if(!t)return;this.sessionsByLeaseId.delete(e.leaseId),this.releasedProviderSessionIdsByLeaseId.set(e.leaseId,t.providerSessionId);let n=await this.closeSession(t),r=await this.safeListArtifacts(t);return{provider:this.options.provider,providerSessionId:t.providerSessionId,...n.cleanup,...n.warnings.length>0?{warnings:n.warnings}:{},...r?{cloudArtifacts:r}:{}}}async listCloudArtifacts(e){if(e.provider!==this.options.provider)return;let t=this.sessionsByLeaseId.get(e.leaseId??``);return t?await this.listActiveCloudArtifacts(t,e.providerSessionId):await this.listReleasedCloudArtifacts(e)}async listActiveCloudArtifacts(e,t){if(!(t&&t!==e.providerSessionId))return await this.safeListArtifacts(e)}async listReleasedCloudArtifacts(e){let t=this.releasedProviderSessionIdsByLeaseId.get(e.leaseId??``);if(!(!t||!this.options.listArtifacts)&&!(e.providerSessionId&&e.providerSessionId!==t))return await this.options.listArtifacts({provider:this.options.provider,providerSessionId:t})}async shutdown(){await Promise.allSettled([...this.sessionsByLeaseId.values()].map(async e=>await this.closeSession(e))),this.sessionsByLeaseId.clear(),this.ownedDeviceIds.clear()}async createSessionWithPreparedCleanup(e,t,n,r){try{return await e.createSession(t.webdriverCapabilities,{deadline:r?.deadline})}catch(e){let r=S(e)?Je(e,this.options.provider,n,t):e;throw await ue(r,()=>t.cleanup?.()),r}}async prepareSession(e,t){let n=this.baseSessionForLease(e);return this.options.prepareSession?await this.options.prepareSession({lease:e,req:t,base:n}):n}baseSessionForLease(e){let t=typeof this.options.webdriverCapabilities==`function`?this.options.webdriverCapabilities(e):this.options.webdriverCapabilities??{};return{provider:this.options.provider,endpoint:this.options.endpoint,platform:this.options.platform,deviceName:this.options.deviceName,auth:this.options.auth,headers:this.options.headers,webdriverCapabilities:P(this.options.platform,this.options.deviceName,t)}}deviceForLease(e,t){return{...n(t.platform),...t.platform===`ios`?{appleOs:`ios`}:{},id:t.deviceId??this.options.deviceId?.(e)??`${this.options.provider}:${t.platform}:${e.leaseId}`,name:t.deviceName,kind:`device`,target:`mobile`,booted:!0}}async closeSession(e){let n=[],r;try{await e.client.deleteSession()}catch(e){n.push({code:`WEBDRIVER_SESSION_DELETE_FAILED`,message:t(e)})}try{r=await e.prepared.cleanup?.()}catch(e){n.push({code:`PROVIDER_CLEANUP_FAILED`,message:t(e)})}return{cleanup:r,warnings:n}}async safeListArtifacts(e){let t=e.prepared.listArtifacts??this.options.listArtifacts;if(t)try{return await t({provider:this.options.provider,lease:e.lease,device:e.device,webDriverSessionId:e.webDriverSessionId,providerSessionId:e.providerSessionId})}catch(t){return le({provider:this.options.provider,providerSessionId:e.providerSessionId,error:t})}}};function P(e,t,n={}){return{platformName:e===`ios`?`iOS`:`Android`,"appium:deviceName":t,...n}}function Je(t,n,r,i){let a=t.details?.timeoutMs;return new e(`COMMAND_FAILED`,`${n} did not create the WebDriver session within ${String(a)}ms.`,{reason:`provider_session_create_timeout`,provider:n,leaseId:r.leaseId,runId:r.runId,timeoutMs:a,...i.providerSessionId?{providerSessionId:i.providerSessionId}:{},hint:`${n} may still finish creating the session after agent-device stopped waiting, and that session would keep billing until the provider reaps it. Before retrying, check ${n} for a running session created for lease ${r.leaseId} (run ${r.runId}) and stop it.`},t)}function F(e){return new Ye(e)}var Ye=class{provider;owner;leaseLifecycle;cloudArtifacts;deviceInventoryProvider;capabilities;platformRuntimeModule;sessions;deployment;constructor(e){this.provider=e.provider,this.owner=i(e.provider,e.platform),this.capabilities=d({provider:e.provider,platform:e.platform,overrides:e.capabilityOverrides}),this.sessions=new qe(e),this.deployment=oe({provider:e.provider,uploadApp:e.uploadApp,findSessionForDevice:e=>this.sessions.findSessionForDevice(e)}),this.platformRuntimeModule=Object.freeze({owner:this.owner,loadRuntime:async e=>await this.loadRuntime(e)}),this.leaseLifecycle={allocate:async(e,t)=>await this.sessions.allocate(e,t),heartbeat:async e=>this.sessions.heartbeat(e),release:async e=>await this.sessions.release(e)},this.cloudArtifacts={listCloudArtifacts:async e=>await this.sessions.listCloudArtifacts(e)},this.deviceInventoryProvider=async e=>{if(e.leaseProvider!==this.provider)return null;if(!e.leaseId)return[];let t=this.sessions.findSessionForLease(e.leaseId);return t?[t.device]:[]}}async loadRuntime(e){let{createWebDriverPlatformRuntimeOwner:t}=await import(`./platform-runtime2.js`);return t({host:e,owner:this.owner,ownsDevice:e=>this.ownsDevice(e),isSessionActive:e=>this.sessions.findSessionForDevice(e)!==void 0,deployment:this.deployment,capabilities:this.capabilities,snapshotAvailable:this.capabilities.operations.snapshot.support!==`unsupported`,screenshotAvailable:this.capabilities.operations.screenshot.support!==`unsupported`,getInteractor:e=>this.getInteractor(e)})}ownsDevice(e){return this.sessions.ownsDevice(e)}getInteractor(e){return this.sessions.getInteractor(e)}async installApp(e,t,n,r){return await this.deployment.installApp(e,t,n,r)}async installInstallablePath(e,t,n){return await this.deployment.installInstallablePath(e,t,n)}async shutdown(){await this.sessions.shutdown()}};async function I(e,t,n){return t?v({provider:e,providerSessionId:t,artifacts:(await Promise.all([n.listArtifacts(t,`FILE`),n.listArtifacts(t,`LOG`)])).flat().flatMap(n=>Ze(e,t,n)),pendingMessage:`AWS Device Farm artifacts are not ready yet.`}):void 0}function Xe(e){if(!e||typeof e!=`object`)return[];let t=e.artifacts;return Array.isArray(t)?t:[]}function Ze(e,t,n){let r=n.url;return typeof r!=`string`||r.length===0?[]:[{provider:e,providerSessionId:t,kind:Qe(n.type),name:n.name??n.type??`AWS Device Farm artifact`,url:r,providerArtifactId:n.arn,extension:n.extension,availability:`ready`,metadata:{awsType:n.type,...n.metadata?{awsMetadata:n.metadata}:{}}}]}function Qe(e){switch(e){case`VIDEO`:return`video`;case`APPIUM_SERVER_OUTPUT`:return`appium-log`;case`DEVICE_LOG`:return`device-log`;case`MESSAGE_LOG`:case`UNKNOWN`:return`automation-log`;default:return`raw`}}m.awsDeviceFarm;const $e={install:{support:`unsupported`,note:`Pass appArn when creating the remote access session; local artifact upload/install is not implemented.`},portReverse:{support:`unsupported`,note:`AWS Device Farm remote access does not expose agent-device port reverse.`},artifacts:{support:`supported`,note:`AWS Device Farm remote access exposes provider-hosted video, Appium logs, and device logs after session completion.`}};function L(e){let t=R(e);return{createRemoteAccessSession:async e=>z(await t(`create-remote-access-session`,[`--project-arn`,e.projectArn,`--device-arn`,e.deviceArn,`--name`,e.name,...e.appArn?[`--app-arn`,e.appArn]:[],...e.interactionMode?[`--interaction-mode`,e.interactionMode]:[],...e.configuration?[`--configuration`,JSON.stringify(e.configuration)]:[]])),getRemoteAccessSession:async e=>z(await t(`get-remote-access-session`,[`--arn`,e])),stopRemoteAccessSession:async e=>z(await t(`stop-remote-access-session`,[`--arn`,e])),listArtifacts:async(e,n)=>Xe(await t(`list-artifacts`,[`--arn`,e,`--type`,n]))}}function et(t){return async({lease:n,req:r,base:i})=>{let a=await t.client.createRemoteAccessSession({projectArn:t.projectArn,deviceArn:t.deviceArn,appArn:t.appArn,name:de(t.sessionName,n)??`agent-device-${n.leaseId}`,interactionMode:t.interactionMode,configuration:t.configuration}),o,s;try{if(o=await rt(a.arn,t,r),s=tt(o),!s)throw new e(`COMMAND_FAILED`,`AWS Device Farm did not expose a WebDriver endpoint.`,{sessionArn:o.arn,status:o.status})}catch(e){throw await ue(e,()=>t.client.stopRemoteAccessSession(a.arn)),e}let c=o.device?.name??t.deviceName,l=typeof t.webdriverCapabilities==`function`?t.webdriverCapabilities(n):t.webdriverCapabilities??{},u=t.platform===`android`?{"appium:autoLaunch":!1}:{};return{...i,endpoint:s,platform:t.platform,deviceName:c,webdriverCapabilities:P(t.platform,c,{...u,...l}),cleanup:async()=>(await t.client.stopRemoteAccessSession(o.arn),{awsDeviceFarmSessionArn:o.arn}),providerSessionId:o.arn,providerData:{awsDeviceFarmSessionArn:o.arn}}}}function tt(e){let t=e.endpoints&&typeof e.endpoints==`object`?Object.values(e.endpoints):[],n=[e.remoteDriverEndpoint,e.endpoint,...t,e.remoteDebugUrl,e.remoteRecordAppUrl].filter(e=>typeof e==`string`&&e.length>0).find(e=>!/^wss?:\/\//i.test(e));return n?nt(n):void 0}function nt(e){return/^https?:\/\//i.test(e)?e:`http://${e}`}async function rt(t,n,r){let i=n.pollIntervalMs??5e3,a=Date.now(),o=r?.deadline??a+(n.startupTimeoutMs??12e4),s=r?.signal,c=await n.client.getRemoteAccessSession(t);for(;Date.now()<o;){if(s?.throwIfAborted(),c.status===`RUNNING`)return c;at(c),await ne(i,void 0,{signal:s}).catch(()=>s?.throwIfAborted()),c=await n.client.getRemoteAccessSession(t)}throw new e(`COMMAND_FAILED`,`Timed out waiting for AWS Device Farm remote access.`,{sessionArn:t,status:c.status,result:c.result,timeoutMs:o-a})}const it=new Set([`ERRORED`,`STOPPED`,`COMPLETED`]);function at(t){if(!(!t.status||!it.has(t.status)))throw new e(`COMMAND_FAILED`,`AWS Device Farm remote access session did not start.`,{sessionArn:t.arn,status:t.status,result:t.result})}async function ot(t,n,r){let i=await t(n,r);try{return JSON.parse(i.stdout)}catch(t){throw new e(`COMMAND_FAILED`,`AWS Device Farm returned invalid JSON.`,void 0,t)}}function R(e){let t=e.region?[`--region`,e.region]:[],n=e.awsCommand??`aws`;return async(r,i)=>await ot(e.runHostCommand,n,[`devicefarm`,r,...t,...i,`--output`,`json`])}function z(t){if(!t||typeof t!=`object`)throw new e(`COMMAND_FAILED`,`AWS Device Farm response was not an object.`,{response:t});let n=t.remoteAccessSession;if(!n||typeof n!=`object`)throw new e(`COMMAND_FAILED`,`AWS Device Farm response missed remoteAccessSession.`,{response:t});return n}const B=[{field:`providerDeviceOrientation`,capability:`deviceOrientation`,flag:`--provider-device-orientation`,type:`enum`,enumValues:o},{field:`providerGeoLocation`,capability:`geoLocation`,flag:`--provider-geo-location`,type:`string`},{field:`providerTimezone`,capability:`timezone`,flag:`--provider-timezone`,type:`string`},{field:`providerAppiumVersion`,capability:`appiumVersion`,flag:`--provider-appium-version`,type:`string`},{field:`providerLanguage`,capability:`language`,flag:`--provider-language`,type:`string`},{field:`providerLocale`,capability:`locale`,flag:`--provider-locale`,type:`string`},{field:`providerNetworkProfile`,capability:`networkProfile`,flag:`--provider-network-profile`,type:`string`},{field:`providerCustomNetwork`,capability:`customNetwork`,flag:`--provider-custom-network`,type:`string`},{field:`providerNoResignApp`,capability:`resignApp`,flag:`--provider-no-resign-app`,type:`negated-boolean`,platform:`ios`}];function st(e,t){pt(e);let n={};for(let r of B){let i=e[r.field];i!==void 0&&i!==!1&&i!==``&&(ft(r,t),n[r.capability]=r.type!==`negated-boolean`&&i)}return n}function ct(e){return B.filter(t=>{let n=e?.[t.field];return n!==void 0&&n!==!1&&n!==``}).map(e=>e.flag)}function V(t,n){let r=ct(t);if(r.length===0)return;let i=r.length!==1;throw new e(`INVALID_ARGS`,`${r.join(`, `)} ${i?`are`:`is`} only supported by BrowserStack, not ${n}.`,{hint:`Drop ${i?`those flags`:`the flag`} or use the browserstack provider.`,provider:n,flags:r})}function lt(e){let t={};for(let n of B){let r=e?.[n.field];if(n.type===`negated-boolean`){r===!0&&(t.providerNoResignApp=!0);continue}typeof r==`string`&&r.length!==0&&ut(t,n,r)}return t}function ut(e,t,n){if(t.field===`providerDeviceOrientation`){e.providerDeviceOrientation=dt(t,n);return}t.field!==`providerNoResignApp`&&(e[t.field]=n)}function dt(t,n){let r=o.find(e=>e===n);if(r)return r;throw new e(`INVALID_ARGS`,`Invalid ${t.flag} value: ${n}.`,{hint:`Use ${o.join(`|`)}.`,flag:t.flag,capability:t.capability})}function ft(t,n){if(!(!t.platform||t.platform===n))throw new e(`INVALID_ARGS`,`${t.flag} applies to ${t.platform} sessions only, but the session platform is ${n}.`,{hint:`Drop ${t.flag} or connect with --platform ${t.platform}.`,flag:t.flag,capability:t.capability,platform:n})}function pt(t){if(!(!t.providerNetworkProfile||!t.providerCustomNetwork))throw new e(`INVALID_ARGS`,`BrowserStack accepts either a named network profile or a custom network shape, not both.`,{hint:`Pass only one of --provider-network-profile or --provider-custom-network.`,networkProfile:t.providerNetworkProfile,customNetwork:t.providerCustomNetwork})}m.browserStack;const mt={install:{support:`partial`,note:`Local app artifacts are uploaded to BrowserStack App Automate, then installed with Appium.`},portReverse:{support:`unsupported`,note:`Use BrowserStack Local for network tunneling; agent-device port reverse is not available.`},artifacts:{support:`supported`,note:`BrowserStack session details expose provider-hosted video, Appium logs, device logs, and dashboard links.`}};async function H(e,t,n){return t?v({provider:e,providerSessionId:t,artifacts:yt(e,t,await vt(t,n)),pendingMessage:`BrowserStack artifacts are not ready yet.`}):void 0}async function U(t,n,r){r?.throwIfAborted();let i=await g.readFile(t),a=new FormData;a.set(`file`,new Blob([i]),h.basename(t));let o=await fetch(n.endpoint??`https://api-cloud.browserstack.com/app-automate/upload`,{method:`POST`,headers:{...y(n.clientVersion),Authorization:b(n)},body:a,signal:r}),s=await o.json(),c=bt(s);if(!o.ok||!c)throw new e(`COMMAND_FAILED`,`BrowserStack app upload failed.`,{status:o.status,response:s});return c}function ht(e){return async({appPath:t,options:n,signal:r})=>({appReference:await U(t,e,r),bundleId:n?.appIdentifierHint,packageName:n?.packageNameHint,launchTarget:n?.appIdentifierHint??n?.packageNameHint})}function gt(e){let{"bstack:options":t,...n}=e.configured??{};return{"appium:deviceName":e.deviceName,"appium:platformVersion":e.osVersion,...e.app?{"appium:app":e.app}:{},...n,"bstack:options":{...e.projectName?{projectName:e.projectName}:{},buildName:e.buildName,sessionName:e.sessionName,...e.deviceFeatures??{},..._t(t)}}}function _t(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}async function vt(t,n){let r=new URL(`${pe(String(n.endpoint??`https://api-cloud.browserstack.com/app-automate/sessions`))}/${t}.json`),i=await fetch(r,{headers:{...y(n.clientVersion),Authorization:b(n)}}),a=await i.json();if(!i.ok||!a||typeof a!=`object`)throw new e(`COMMAND_FAILED`,`BrowserStack session details lookup failed.`,{status:i.status,response:a});let o=a.automation_session??a;return o&&typeof o==`object`?o:{}}function yt(e,t,n){return[W(e,t,n,`video_url`,`video`,`Session video`),W(e,t,n,`appium_logs_url`,`appium-log`,`Appium logs`),W(e,t,n,`device_logs_url`,`device-log`,`Device logs`),W(e,t,n,`browser_url`,`provider-session`,`BrowserStack dashboard`),W(e,t,n,`public_url`,`provider-session`,`Public session link`)].filter(e=>e!==void 0)}function W(e,t,n,r,i,a){let o=n[r];if(typeof o==`string`&&o.length!==0)return{provider:e,providerSessionId:t,kind:i,name:a,url:o,availability:`ready`}}function bt(e){if(!e||typeof e!=`object`)return;let t=e.app_url;return typeof t==`string`?t:void 0}function G(e){return/^arn:[^:]+:devicefarm:([^:]+):/.exec(e)?.[1]}async function xt(t,n){let r=R({runHostCommand:n,region:t.region}),[i,a,o]=await Promise.all([r(`get-project`,[`--arn`,t.projectArn]),r(`get-device`,[`--arn`,t.deviceArn]),t.appArn?r(`get-upload`,[`--arn`,t.appArn]):void 0]),s=K(i,`project`),c=K(a,`device`),l=Ct(c.platform);if(l!==t.platform)throw new e(`INVALID_ARGS`,`AWS Device Farm device "${q(c.name)??t.deviceArn}" is ${l}, not ${t.platform}.`);let u=t.appArn?St(K(o,`upload`),t):{status:`missing`,message:`No app upload is attached; AWS Device Farm does not support install after allocation. Reconnect with --aws-app-arn <arn>.`};return{provider:`aws-device-farm`,service:`AWS Device Farm`,verificationMessage:t.appArn?`Credentials, project, device, and app upload verified.`:`Credentials, project, and device verified.`,project:{name:q(s.name),reference:t.projectArn},device:{status:`verified`,name:q(c.name)??t.deviceArn,reference:t.deviceArn,platform:l,osVersion:q(c.os),availability:q(c.availability)},app:u}}function St(t,n){let r=q(t.status);if(r!==`SUCCEEDED`)throw new e(`COMMAND_FAILED`,`AWS Device Farm app upload is not ready (${r??`unknown status`}).`,{status:r,hint:`Wait for the upload to succeed or reconnect with a different --aws-app-arn.`});let i=n.platform===`android`?`ANDROID_APP`:`IOS_APP`,a=q(t.type);if(a!==i)throw new e(`INVALID_ARGS`,`AWS Device Farm app upload type is ${a??`unknown`}, expected ${i}.`);return{status:`verified`,name:q(t.name),reference:n.appArn}}function K(t,n){if(!t||typeof t!=`object`)throw new e(`COMMAND_FAILED`,`AWS Device Farm ${n} response was not an object.`);let r=t[n];if(!r||typeof r!=`object`||Array.isArray(r))throw new e(`COMMAND_FAILED`,`AWS Device Farm response missed ${n}.`);return r}function Ct(t){if(t===`ANDROID`)return`android`;if(t===`IOS`)return`ios`;throw new e(`UNSUPPORTED_PLATFORM`,`AWS Device Farm device platform is ${String(t)}.`)}function q(e){return typeof e==`string`&&e.length>0?e:void 0}async function wt(t,n){let r={username:t.username,accessKey:t.accessKey},i=Dt(await J(t.devicesEndpoint??`https://api-cloud.browserstack.com/app-automate/devices.json`,r,n)).find(e=>e.device===t.deviceName&&e.os.toLowerCase()===t.platform&&Et(e.osVersion,t.osVersion));if(!i)throw new e(`INVALID_ARGS`,`BrowserStack device "${t.deviceName}" with ${t.platform} ${t.osVersion} is not available.`,{hint:`Choose an exact device and OS version from the BrowserStack App Automate device list.`});let a=await Tt(t,r,n);return{provider:`browserstack`,service:`BrowserStack`,verificationMessage:a.status===`verified`?`Credentials, device, and uploaded app verified.`:`Credentials and device access verified; app availability is checked when the session is created.`,device:{status:`verified`,name:i.device,platform:t.platform,osVersion:i.osVersion},app:a}}async function Tt(e,t,n){let{app:r}=e;if(r.startsWith(`bs://`)){let i=Ot(await J(e.appsEndpoint??`https://api-cloud.browserstack.com/app-automate/recent_apps?limit=100`,t,n)).find(e=>e.reference===r);return i?{status:`verified`,...i}:{status:`configured`,reference:r,message:`App reference was not found in the 100 most recent uploads; BrowserStack validates it when creating the session.`}}return/^https?:\/\//i.test(r)?{status:`configured`,reference:r,message:`Public app URL configured; BrowserStack validates it when creating the session.`}:{status:`configured`,name:h.basename(r),reference:r,message:`Local app artifact is ready and will be uploaded when creating the session.`}}async function J(t,n,r){try{let i=await fetch(t,{headers:{...y(r),Authorization:b(n)},signal:AbortSignal.timeout(15e3)});if(!i.ok){let t=i.status===401||i.status===403;throw new e(t?`UNAUTHORIZED`:`COMMAND_FAILED`,`BrowserStack rejected connection verification.`,{status:i.status,hint:t?`Check BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY.`:`Retry connect or check the BrowserStack service status.`})}return await i.json()}catch(t){throw t instanceof e?t:new e(`COMMAND_FAILED`,`BrowserStack connection verification failed.`,{hint:`Check network access to api-cloud.browserstack.com and retry connect.`},t)}}function Et(e,t){let n=e=>e.replace(/(?:\.0)+$/,``);return n(e)===n(t)}function Dt(t){if(!Array.isArray(t))throw new e(`COMMAND_FAILED`,`BrowserStack device verification response was not a list.`);return t.flatMap(e=>{let t=Y(e),n=t?.os_version;return t&&typeof t.device==`string`&&typeof t.os==`string`&&(typeof n==`string`||typeof n==`number`)?[{device:t.device,os:t.os,osVersion:String(n)}]:[]})}function Ot(t){let n=Y(t);if(n&&Object.keys(n).length===0)return[];if(!Array.isArray(t))throw new e(`COMMAND_FAILED`,`BrowserStack app verification response was not a list.`);return t.flatMap(e=>{let t=Y(e);return!t||typeof t.app_url!=`string`?[]:[{reference:t.app_url,...typeof t.app_name==`string`?{name:t.app_name}:{},...typeof t.app_version==`string`?{version:t.app_version}:{}}]})}function Y(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}async function kt(e,t){return e.provider===`browserstack`?await wt(e,t.clientVersion):await xt(e,t.runHostCommand)}function At(e){return[{provider:m.browserStack,createRuntime:t=>F({clientVersion:e.clientVersion,provider:m.browserStack,platform:`android`,deviceName:`BrowserStack device`,endpoint:t.BROWSERSTACK_WEBDRIVER_ENDPOINT??`https://hub-cloud.browserstack.com/wd/hub/`,capabilityOverrides:mt,listArtifacts:async({provider:n,providerSessionId:r})=>{let i=$(t,`BROWSERSTACK_USERNAME`,`BrowserStack artifact lookup`),a=$(t,`BROWSERSTACK_ACCESS_KEY`,`BrowserStack artifact lookup`);return await H(n,r,{clientVersion:e.clientVersion,username:i,accessKey:a,endpoint:t.BROWSERSTACK_SESSION_DETAILS_ENDPOINT})},prepareSession:async({req:n,lease:r,base:i})=>{let a=X(n,`BrowserStack`),o=$(t,`BROWSERSTACK_USERNAME`,`BrowserStack`),s=$(t,`BROWSERSTACK_ACCESS_KEY`,`BrowserStack`),c=Nt(a,`BrowserStack`),l=Z(a,`device`,`BrowserStack requires --device <name>.`),u=Z(a,`providerOsVersion`,`BrowserStack requires --provider-os-version <version>.`),d=await jt({clientVersion:e.clientVersion,app:Z(a,`providerApp`,`BrowserStack requires --provider-app <bs://app-id-or-local-path>.`),cwd:a.cwd,username:o,accessKey:s,uploadEndpoint:t.BROWSERSTACK_APP_UPLOAD_ENDPOINT,signal:a.signal});return{...i,platform:c,deviceName:l,auth:{username:o,accessKey:s},uploadApp:ht({clientVersion:e.clientVersion,username:o,accessKey:s,endpoint:t.BROWSERSTACK_APP_UPLOAD_ENDPOINT??`https://api-cloud.browserstack.com/app-automate/upload`}),webdriverCapabilities:gt({deviceName:l,osVersion:u,app:d,projectName:Q(a,`providerProject`),buildName:Q(a,`providerBuild`)??r.runId,sessionName:Q(a,`providerSessionName`)??r.leaseId,deviceFeatures:st(lt(a.flags),c),configured:P(c,l)})}}}),listArtifactsFromEnv:async(t,n)=>{let r=$(n,`BROWSERSTACK_USERNAME`,`BrowserStack artifact lookup`),i=$(n,`BROWSERSTACK_ACCESS_KEY`,`BrowserStack artifact lookup`);return await H(m.browserStack,t,{clientVersion:e.clientVersion,username:r,accessKey:i,endpoint:n.BROWSERSTACK_SESSION_DETAILS_ENDPOINT})}},{provider:m.awsDeviceFarm,createRuntime:t=>F({clientVersion:e.clientVersion,provider:m.awsDeviceFarm,endpoint:`http://127.0.0.1/`,platform:`android`,deviceName:`AWS Device Farm device`,capabilityOverrides:$e,listArtifacts:async({provider:n,providerSessionId:r})=>await I(n,r,L({runHostCommand:e.runHostCommand,region:t.AWS_REGION??t.AWS_DEFAULT_REGION??G(r??``)})),prepareSession:async({req:n,lease:r,base:i})=>{let a=X(n,`AWS Device Farm`);V(a.flags,m.awsDeviceFarm);let o=Nt(a,`AWS Device Farm`);return await et({client:L({runHostCommand:e.runHostCommand,region:Q(a,`awsRegion`)??t.AWS_REGION??t.AWS_DEFAULT_REGION}),projectArn:Pt(a,t,`awsProjectArn`,`AGENT_DEVICE_AWS_DEVICE_FARM_PROJECT_ARN`,`AWS_DEVICE_FARM_PROJECT_ARN`),deviceArn:Pt(a,t,`awsDeviceArn`,`AGENT_DEVICE_AWS_DEVICE_FARM_DEVICE_ARN`,`AWS_DEVICE_FARM_DEVICE_ARN`),appArn:Q(a,`awsAppArn`)??t.AGENT_DEVICE_AWS_DEVICE_FARM_APP_ARN??t.AWS_DEVICE_FARM_APP_ARN,platform:o,deviceName:Q(a,`device`)??`AWS Device Farm device`,sessionName:Q(a,`providerSessionName`)??r.leaseId,interactionMode:Ft(a)})({lease:r,req:n,base:i})}}),listArtifactsFromEnv:async(t,n)=>{let r=L({runHostCommand:e.runHostCommand,region:n.AWS_REGION??n.AWS_DEFAULT_REGION??G(t)});return await I(m.awsDeviceFarm,t,r)}}]}async function jt(t){if(Mt(t.app))return t.app;let n=h.resolve(t.cwd??process.cwd(),t.app);if(!te.existsSync(n))throw new e(`INVALID_ARGS`,`BrowserStack --provider-app must be a bs:// app id, URL, or existing local app path.`,{providerApp:t.app});return await U(n,{clientVersion:t.clientVersion,username:t.username,accessKey:t.accessKey,endpoint:t.uploadEndpoint},t.signal)}function Mt(e){return e.startsWith(`bs://`)||/^https?:\/\//.test(e)}function X(t,n){if(t)return t;throw new e(`INVALID_ARGS`,`${n} lease allocation requires provider profile flags on the request.`)}function Nt(t,n){let r=t.flags?.platform;if(r===`android`||r===`ios`)return r;throw new e(`INVALID_ARGS`,`${n} requires --platform ios|android.`)}function Z(t,n,r){let i=Q(t,n);if(i)return i;throw new e(`INVALID_ARGS`,r)}function Q(e,t){let n=e.flags?.[t];return typeof n==`string`&&n.length>0?n:void 0}function $(t,n,r){let i=t[n];if(i)return i;throw new e(`INVALID_ARGS`,`${r} requires ${n} in the environment.`)}function Pt(t,n,r,i,a){let o=Q(t,r)??n[i]??n[a];if(o)return o;throw new e(`INVALID_ARGS`,`AWS Device Farm requires --${It(String(r))} or ${a}.`)}function Ft(e){let t=Q(e,`awsInteractionMode`);if(t===`INTERACTIVE`||t===`NO_VIDEO`||t===`VIDEO_ONLY`)return t}function It(e){return e.replaceAll(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function Lt(e){let t=At(e);return{providerIds:t.map(e=>e.provider),createDefaultRuntimes:(e=process.env)=>t.map(t=>t.createRuntime(e)),listArtifactsFromEnv:async(e,n)=>{if(e.providerSessionId)return await t.find(t=>t.provider===e.provider)?.listArtifactsFromEnv(e.providerSessionId,n)},verifyConnection:async t=>await kt(t,e)}}const Rt=Lt({clientVersion:u(),runHostCommand:async(e,t)=>({stdout:(await l(e,[...t],{maxBuffer:10485760,timeoutMs:3e4})).stdout})});export{G as n,V as r,Rt as t};
|
|
1
|
+
import{D as e,j as t}from"./sdk-contracts.js";import{a as n,b as r}from"./sdk-device.js";import{Qt as i}from"./sdk-batch.js";import{d as a}from"./scroll-gesture.js";import{c as o}from"./sdk-remote-config.js";import"./device.js";import{a as s,o as c}from"./device-rotation.js";import{c as l}from"./exec.js";import"./command.js";import{r as u}from"./version.js";import{n as d,r as f,t as p}from"./capabilities.js";import{t as ee}from"./webdriver-source.js";import{t as m}from"./providers.js";import h from"node:path";import te from"node:fs";import g from"node:fs/promises";import{setTimeout as ne}from"node:timers/promises";function re(e,t){let n=e?.bundleId??t?.appIdentifierHint,r=e?.packageName??t?.packageNameHint;return{bundleId:n,packageName:r,appName:e?.appName,launchTarget:ae(e?.launchTarget,n,r)}}function ie(e){return e===`ios`?`xctest`:`android`}function ae(...e){return e.find(e=>e!==void 0)}function oe(e){let t=async(t,n,r,i,a)=>{let o=e.findSessionForDevice(t);if(!o)return;let s=await ce(e,o,t,n,r,i,a);return await o.client.installApp(s?.appReference??r,a),re(s,i)};return Object.freeze({fact:t=>se(e.findSessionForDevice(t)),installApp:t,installInstallablePath:async(e,n,r,i)=>await t(e,``,n,r,i),deployApp:async(e,n,r)=>_(await t(e,n.app,n.appPath,{relaunch:n.replaceExisting,appIdentifierHint:n.app,packageNameHint:n.app},r),n.app),deployMaterializedApp:async(e,n,r)=>_(await t(e,``,n.artifact.installablePath,{appIdentifierHint:n.artifact.bundleId,packageNameHint:n.artifact.packageName},r))})}function se(e){return e?p(e.capabilities,`install`)?Object.freeze({available:!0}):Object.freeze({available:!1,reason:`owner-capability-missing`,hint:f(e.capabilities,`install`)}):Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`The WebDriver provider session is no longer active for this device.`})}async function ce(t,n,i,a,o,s,c){if(!p(n.capabilities,`install`))throw new e(`UNSUPPORTED_OPERATION`,f(n.capabilities,`install`),{provider:t.provider,deviceId:i.id,platform:r(i)});let l=n.prepared.uploadApp??t.uploadApp;if(l)return await l({provider:t.provider,lease:n.lease,device:i,app:a,appPath:o,options:s,signal:c})}function _(t,n){if(!t)throw new e(`UNSUPPORTED_OPERATION`,`The WebDriver provider session no longer supports app deployment.`);return{...t.bundleId?{bundleId:t.bundleId}:{},...t.packageName?{packageName:t.packageName}:{},...t.appName?{appName:t.appName}:{},...t.launchTarget??n?{launchTarget:t.launchTarget??n}:{}}}function v(e){return{provider:e.provider,providerSessionId:e.providerSessionId,status:e.artifacts.length>0?`ready`:`pending`,cloudArtifacts:e.artifacts,...e.artifacts.length>0?{}:{message:e.pendingMessage}}}function le(e){return{provider:e.provider,providerSessionId:e.providerSessionId,status:`unavailable`,cloudArtifacts:[],message:e.error instanceof Error?e.error.message:String(e.error)}}function y(e){return{"x-agent-device-client":`agent-device-cli`,"x-agent-device-version":e}}async function ue(n,r){try{await r()}catch(r){n instanceof e&&(n.details={...n.details,cleanupError:t(r)})}}function de(e,t){return typeof e==`function`?e(t):e}function b(e){return`Basic ${Buffer.from(`${e.username}:${e.accessKey}`).toString(`base64`)}`}function fe(e){let t=0;for(;t<e.length&&e.charCodeAt(t)===47;)t+=1;return t===0?e:e.slice(t)}function pe(e){let t=e.length-1;for(;t>=0&&e.charCodeAt(t)===47;)--t;return t===e.length-1?e:e.slice(0,t+1)}function me(e){if(e.pathname.endsWith(`/`))return e;let t=new URL(e);return t.pathname=`${t.pathname}/`,t}const x=`webdriver_request_timeout`;function S(t){return t instanceof e&&t.details?.reason===x}var he=class{endpoint;headers;requestPolicy;constructor(e){this.endpoint=me(new URL(e.endpoint)),this.headers={...y(e.clientVersion),...e.auth?{Authorization:b(e.auth)}:{},...e.headers},this.requestPolicy={timeoutMs:e.requestPolicy?.timeoutMs??3e4,retryAttempts:e.requestPolicy?.retryAttempts??1,retryDelayMs:e.requestPolicy?.retryDelayMs??250}}async requestValue(e,t,n,r){return await this.requestValueWithRetries(e,t,n,{retryAttempts:r?.retryAttempts??this.requestPolicy.retryAttempts,timeoutMs:r?.timeoutMs??this.requestPolicy.timeoutMs,signal:r?.signal})}async requestValueWithRetries(e,t,n,r){let i;for(let a=0;a<=r.retryAttempts;a+=1)try{return await this.requestValueOnce(e,t,n,r.timeoutMs,r.signal)}catch(e){if(i=e,!ge(e,a,r.retryAttempts,r.signal))throw e;await ne(this.requestPolicy.retryDelayMs,void 0,{signal:r.signal})}throw i}async requestValueOnce(e,t,n,r,i){let{ok:a,status:o,text:s}=await this.fetchWebDriver(e,t,n,r,i),c=s?ve(s):{};if(!a)throw ye(o,c);return _e(c)}async fetchWebDriver(e,t,n,r,i){let a=AbortSignal.timeout(r),o=i?AbortSignal.any([i,a]):a;try{let r=await fetch(new URL(fe(t),this.endpoint),{method:e,headers:{Accept:`application/json`,...n===void 0?{}:{"Content-Type":`application/json`},...this.headers},body:n===void 0?void 0:JSON.stringify(n),signal:o});return{ok:r.ok,status:r.status,text:await r.text()}}catch(n){throw a.aborted&&!i?.aborted?be(e,t,r,n):n}}};function ge(e,t,n,r){return!r?.aborted&&xe(e)&&t<n}function _e(e){if(!e||typeof e!=`object`)return e;let t=e;return`value`in t?t.value:e}function ve(t){try{return JSON.parse(t)}catch(n){throw new e(`COMMAND_FAILED`,`WebDriver response was not valid JSON.`,{text:t},n)}}function ye(t,n){let r=n&&typeof n==`object`&&`value`in n?n.value:n,i=r&&typeof r==`object`&&typeof r.message==`string`?r.message:`WebDriver request failed with HTTP ${t}.`;return new e(`COMMAND_FAILED`,i,{status:t,response:n})}function be(t,n,r,i){return new e(`COMMAND_FAILED`,`WebDriver ${t} ${n} timed out after ${r}ms.`,{reason:x,method:t,path:n,timeoutMs:r},i instanceof Error?i:void 0)}function xe(t){if(S(t))return!0;if(t instanceof e){let e=t.details?.status;return typeof e==`number`&&e>=500}return t instanceof TypeError}var Se=class{transport;sessionCreateTimeoutMs;sessionId;constructor(e){this.transport=new he(e),this.sessionCreateTimeoutMs=e.requestPolicy?.sessionCreateTimeoutMs??18e4}async createSession(e,t){let n=we(await this.requestValue(`POST`,`/session`,{capabilities:Ce(e)},{retryAttempts:0,timeoutMs:Oe(this.sessionCreateTimeoutMs,t?.deadline)}));return this.sessionId=n.sessionId,n}async deleteSession(){let e=this.requireSessionId();await this.requestValue(`DELETE`,`/session/${e}`),this.sessionId=void 0}async installApp(e,t){await this.sessionRequest(`POST`,`/appium/device/install_app`,{appPath:e},{signal:t})}async activateApp(e){try{await this.sessionRequest(`POST`,`/appium/device/activate_app`,{appId:e})}catch{await this.executeScript(`mobile: activateApp`,[{appId:e,bundleId:e}])}}async terminateApp(e){try{await this.sessionRequest(`POST`,`/appium/device/terminate_app`,{appId:e})}catch{await this.executeScript(`mobile: terminateApp`,[{appId:e,bundleId:e}])}}async performActions(e){await this.sessionRequest(`POST`,`/actions`,{actions:e})}async releaseActions(){await this.sessionRequest(`DELETE`,`/actions`,void 0,{retryAttempts:0})}async sendKeys(e){await this.sessionRequest(`POST`,`/keys`,{value:Array.from(e)})}async hideKeyboard(){await this.sessionRequest(`POST`,`/appium/device/hide_keyboard`,void 0,{retryAttempts:0})}async isKeyboardShown(e){let t;try{t=await this.sessionRequest(`GET`,`/appium/device/is_keyboard_shown`,void 0,{retryAttempts:0,...e===void 0?{}:{timeoutMs:e}})}catch(e){if(O(e))return`unsupported`;throw e}return typeof t==`boolean`?t:`unsupported`}async activeElement(e){let t=e===void 0?void 0:Date.now()+e,n;try{n=De(await this.sessionRequest(`GET`,`/element/active`,void 0,T(t)))}catch(e){if(O(e))return`unsupported`;if(D(e))return`none`;throw e}if(n===void 0)return`unsupported`;try{let e=await this.sessionRequest(`GET`,`/element/${encodeURIComponent(n)}/rect`,void 0,T(t));return{id:n,rect:C(e)}}catch(e){if(O(e))return`unsupported`;if(D(e))return`none`;throw e}}async back(){await this.sessionRequest(`POST`,`/back`)}async setRotation(e){await this.sessionRequest(`POST`,`/rotation`,{x:0,y:0,z:e})}async setOrientation(e){await this.sessionRequest(`POST`,`/orientation`,{orientation:e})}async source(t){let n=await this.sessionRequest(`GET`,`/source`,void 0,t);if(typeof n!=`string`)throw new e(`COMMAND_FAILED`,`WebDriver source response was not a string`,{valueType:typeof n});return n}async screenshot(t){let n=await this.sessionRequest(`GET`,`/screenshot`);if(typeof n!=`string`)throw new e(`COMMAND_FAILED`,`WebDriver screenshot response was not base64 text`,{valueType:typeof n});await g.writeFile(t,Buffer.from(n,`base64`))}async windowRect(){return C(await this.sessionRequest(`GET`,`/window/rect`))}async executeScript(e,t=[]){return await this.sessionRequest(`POST`,`/execute/sync`,{script:e,args:t})}async sessionRequest(e,t,n,r){let i=this.requireSessionId();return await this.requestValue(e,`/session/${i}${t}`,n,r)}requireSessionId(){if(!this.sessionId)throw new e(`SESSION_NOT_FOUND`,`WebDriver session has not been created yet.`);return this.sessionId}async requestValue(e,t,n,r){return await this.transport.requestValue(e,t,n,r)}};function C(t){if(!t||typeof t!=`object`)throw new e(`COMMAND_FAILED`,`WebDriver window rect response was empty.`);let n=t,r={x:w(n,`x`),y:w(n,`y`),width:w(n,`width`),height:w(n,`height`)};if(r.x===void 0||r.y===void 0||r.width===void 0||r.height===void 0)throw new e(`COMMAND_FAILED`,`WebDriver window rect response was invalid.`,{response:n});return r}function w(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function Ce(e){return`alwaysMatch`in e||`firstMatch`in e?e:{alwaysMatch:e}}function we(t){if(!t||typeof t!=`object`)throw new e(`COMMAND_FAILED`,`WebDriver create-session response was empty.`);let n=t,r=typeof n.sessionId==`string`?n.sessionId:typeof n.session_id==`string`?n.session_id:void 0;if(!r)throw new e(`COMMAND_FAILED`,`WebDriver create-session response missed sessionId.`,{response:n});return{sessionId:r,capabilities:n.capabilities&&typeof n.capabilities==`object`?n.capabilities:{}}}const Te=new Set([405,501]),Ee=new Set([`unknown command`,`unknown method`]);function De(e){if(!e||typeof e!=`object`)return;let t=e,n=t[`element-6066-11e4-a52e-4f735466cecf`]??t.ELEMENT;return typeof n==`string`&&n.length>0?n:void 0}function T(e){return e===void 0?{retryAttempts:0}:{retryAttempts:0,timeoutMs:E(e)}}function Oe(e,t){return t===void 0?e:Math.min(e,E(t))}function E(e){return Math.max(0,e-Date.now())}function D(t){return t instanceof e&&k(t).toLowerCase()===`no such element`}function O(t){if(!(t instanceof e))return!1;let n=t.details?.status;return typeof n==`number`&&Te.has(n)?!0:Ee.has(k(t).toLowerCase())}function k(e){let t=e.details?.response,n=t&&typeof t==`object`?t.value:void 0,r=n&&typeof n==`object`?n.error:void 0;return typeof r==`string`?r:``}function A(e,t){return{type:`pointer`,id:e,parameters:{pointerType:`touch`},actions:t}}async function ke(e){return j(ee(e,`android`).nodes)}function Ae(e){return j(ee(e).nodes)}function j(e){let t=e.flatMap(e=>je(e)&&Me(e.rect)?[e.rect]:[]).sort((e,t)=>t.width*t.height-e.width*e.height)[0];return t?{x:t.x,y:t.y,width:t.width,height:t.height}:void 0}function je(e){let t=e.type?.toLowerCase()??``;return e.visibleToUser!==!1&&(t.includes(`scrollview`)||t.includes(`listview`)||t.includes(`recyclerview`))}function Me(e){return!!e&&e.width>=50&&e.height>=50}async function Ne(t,n,r){let i=[];for(let e of n===`android`?[`rotation`,`orientation`]:[`orientation`,`rotation`])try{await Re(t,e,r);return}catch(t){if(!Ie(t))throw t;i.push({transport:e,error:t instanceof Error?t.message:String(t)})}throw new e(`COMMAND_FAILED`,`Could not set device orientation to ${r} on the hosted WebDriver session.`,{hint:`The provider driver rejected both orientation endpoints. Set the orientation as a session capability instead, for example connect --provider-device-orientation portrait.`,rotation:r,attempts:i})}const Pe=new Set([`unknown command`,`unknown method`]),Fe=new Set([404,405]);function Ie(t){if(!(t instanceof e)||t.code===`SESSION_NOT_FOUND`)return!1;let n=Le(t.details?.response);if(n)return Pe.has(n);let r=t.details?.status;return typeof r==`number`&&Fe.has(r)}function Le(e){if(!e||typeof e!=`object`)return``;let t=e.value;if(!t||typeof t!=`object`)return``;let n=t.error;return typeof n==`string`?n:``}async function Re(e,t,n){if(t===`rotation`){await e.setRotation(c(n));return}await e.setOrientation(s(n))}const M=1500;function ze(e){return new Promise(t=>setTimeout(t,e))}function N(t,n,r){return new e(`COMMAND_FAILED`,`fill tapped (${t}, ${n}) but ${r}`,{reason:`text_entry_focus_not_observed`,x:t,y:n,hint:`The tap most likely missed the field. Re-check the target with snapshot -i and fill the element it reports, rather than retrying the same coordinates.`})}function Be(t,n){return new e(`COMMAND_FAILED`,`fill tapped (${t}, ${n}) but this driver reports neither the focused element nor keyboard state, so the text was not sent`,{reason:`text_entry_focus_unobservable`,x:t,y:n,hint:`This provider cannot confirm a field took focus. Use press <target> followed by type <text> to enter it anyway, accepting that nothing witnesses which field receives the keys.`})}function Ve(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function He(e){return new Ue(e.client,e.backend,e.capabilities,e.targetId)}var Ue=class{client;backend;capabilities;targetId;constructor(e,t,n,r){this.client=e,this.backend=t,this.capabilities=n,this.targetId=r}async open(e,t){if(t?.url){await this.client.executeScript(`mobile: deepLink`,[{url:t.url,package:e}]);return}let n=t?.appBundleId??e;n&&await this.client.activateApp(n)}async openDevice(){await this.client.executeScript(`mobile: activateApp`,[{}])}async close(e){e&&await this.client.terminateApp(e)}async tap(e,t){return this.requireSupport(`tap`),await this.pointerGesture(`tap`,[{type:`pointerMove`,duration:0,x:e,y:t},{type:`pointerDown`,button:0},{type:`pointerUp`,button:0}]),{backend:`webdriver`,x:e,y:t}}async doubleTap(e,t){return this.requireSupport(`doubleTap`),await this.pointerGesture(`doubleTap`,[{type:`pointerMove`,duration:0,x:e,y:t},{type:`pointerDown`,button:0},{type:`pointerUp`,button:0},{type:`pause`,duration:80},{type:`pointerDown`,button:0},{type:`pointerUp`,button:0}]),{backend:`webdriver`,x:e,y:t}}async swipe(e,t,n,r,i=400){return this.requireSupport(`swipe`),await this.pointerGesture(`swipe`,[{type:`pointerMove`,duration:0,x:e,y:t},{type:`pointerDown`,button:0},{type:`pointerMove`,duration:i,x:n,y:r},{type:`pointerUp`,button:0}]),{backend:`webdriver`,x1:e,y1:t,x2:n,y2:r,durationMs:i}}async longPress(e,t,n=600){return this.requireSupport(`longPress`),await this.pointerGesture(`longPress`,[{type:`pointerMove`,duration:0,x:e,y:t},{type:`pointerDown`,button:0},{type:`pause`,duration:n},{type:`pointerUp`,button:0}]),{backend:`webdriver`,x:e,y:t,durationMs:n}}async focus(e,t){return await this.tap(e,t)}async type(e){this.requireSupport(`type`),await this.client.sendKeys(e)}async fill(t,n,r,i){if(this.requireSupport(`fill`),r.length===0)throw new e(`UNSUPPORTED_OPERATION`,`fill with empty text (clear field) is not supported on the webdriver backend`,{hint:`Use a visible clear/reset control in the app, or fill the field with the intended replacement text directly.`});let a=await this.readTextEntryState();await this.tap(t,n);let o=await this.awaitTextEntryReadiness(a,t,n);return await this.type(r),{backend:`webdriver`,x:t,y:n,text:r,textEntryReadiness:o}}async scroll(e,t){this.requireSupport(`scroll`);let n=t?.durationMs??350;await this.client.hideKeyboard().catch(()=>void 0);let r=await this.scrollGestureFrame(),i=a({direction:e,amount:t?.amount,pixels:t?.pixels,referenceWidth:r.width,referenceHeight:r.height}),o={...i,x1:i.x1+r.x,y1:i.y1+r.y,x2:i.x2+r.x,y2:i.y2+r.y};return await this.swipe(o.x1,o.y1,o.x2,o.y2,n),{backend:`webdriver`,...o,distance:i.pixels,durationMs:n}}async gestureViewport(){return await this.scrollGestureFrame()}async performGesture(e){return this.requireSupport(Ge(e)),await this.client.performActions(e.pointers.map(e=>A(`gesture-pointer-${e.pointerId}`,We(e.samples)))),await this.client.releaseActions().catch(()=>void 0),{backend:`webdriver-w3c-actions`}}async screenshot(e,t){this.requireSupport(`screenshot`),await this.client.screenshot(e)}async snapshot(e){return this.requireSupport(`snapshot`),await this.captureSource(e?.signal)}async captureSource(e){let t=await this.readSource(e);if(this.backend===`xctest`){let{acquireWebDriverIosSnapshot:e}=await import(`./webdriver-ios-snapshot.js`);return e(t,this.targetId)}let{parseWebDriverSourceFacts:n}=await import(`./webdriver-source.js`).then(e=>e.n);return{backend:`android`,producer:`appium-source`,nodes:n(t,`android`).nodes}}async readSource(e){try{return await this.client.source(e===void 0?{}:{signal:e})}catch(e){throw S(e)?Ke(e):e}}async back(e){this.requireSupport(`back`),await this.client.back()}async home(){this.requireSupport(`home`),await this.client.executeScript(`mobile: pressButton`,[{name:`home`}])}async setOrientation(e){this.requireSupport(`orientation`),await Ne(this.client,this.backend,e)}async appSwitcher(){this.requireSupport(`appSwitcher`),await this.client.executeScript(`mobile: pressButton`,[{name:`appSwitch`}])}async tvRemote(e,t){this.unsupported(`tvRemote`)}async readClipboard(){this.requireSupport(`clipboard.read`);let e=await this.client.executeScript(`mobile: getClipboard`,[{}]);return typeof e==`string`?e:``}async writeClipboard(e){this.requireSupport(`clipboard.write`),await this.client.executeScript(`mobile: setClipboard`,[{content:e}])}async setSetting(e,t,n,r){this.unsupported(`settings`)}async readAlert(){this.unsupported(`alert`)}async awaitAlert(){this.unsupported(`alert`)}async acceptAlert(){this.unsupported(`alert`)}async dismissAlert(){this.unsupported(`alert`)}async awaitTextEntryReadiness(e,t,n){let r=e.keyboard,i=Date.now()+2e3,a=e.focusedElementId,o=await this.pollWithinBudget(i,async e=>{let r=await this.client.activeElement(e);return r===`unsupported`?`abandon`:r===`none`?`retry`:r.id!==a||Ve(r.rect,t,n)?`satisfied`:`retry`});if(o===`satisfied`)return`focused-element`;if(o===`expired`)throw N(t,n,`nothing there took text-entry focus, so the text was not sent`);if(r===`unsupported`)throw Be(t,n);if(r)throw N(t,n,`the keyboard was already up and this driver cannot report which field holds focus, so the text was not sent`);if(await this.pollWithinBudget(i,async e=>await this.client.isKeyboardShown(e)===!0?`satisfied`:`retry`)===`satisfied`)return`keyboard-shown`;throw N(t,n,`no keyboard appeared, so the text was not sent`)}async readTextEntryState(){let[e,t]=await Promise.all([this.client.isKeyboardShown(M),this.client.activeElement(M)]);return{keyboard:e,focusedElementId:t===`none`||t===`unsupported`?void 0:t.id}}async pollWithinBudget(e,t){let n=!1,r;for(;;){let i=e-Date.now();if(i<=0)break;try{let e=await t(Math.min(M,i));if(n=!0,e!==`retry`)return e}catch(e){r=e}let a=e-Date.now();if(a<=0)break;await ze(Math.min(100,a))}if(!n&&r!==void 0)throw r;return`expired`}async pointerGesture(e,t){await this.client.performActions([A(e,t)]),await this.client.releaseActions().catch(()=>void 0)}async scrollGestureFrame(){return await this.client.source().then(e=>this.backend===`xctest`?Ae(e):ke(e)).catch(()=>void 0)||await this.client.windowRect()}requireSupport(e){p(this.capabilities,e)||this.unsupported(e)}unsupported(t){throw new e(`UNSUPPORTED_OPERATION`,f(this.capabilities,t),{provider:this.capabilities.provider,platform:this.capabilities.platform,operation:t})}};function We(t){let n=t[0];if(!n)throw new e(`INVALID_ARGS`,`WebDriver gesture pointer requires samples`);let r=[{type:`pointerMove`,duration:0,x:n.point.x,y:n.point.y},{type:`pointerDown`,button:0}];for(let e=1;e<t.length;e+=1){let n=t[e-1],i=t[e];r.push({type:`pointerMove`,duration:i.offsetMs-n.offsetMs,x:i.point.x,y:i.point.y})}return r.push({type:`pointerUp`,button:0}),r}function Ge(e){if(e.topology===`single`)return`swipe`;switch(e.intent){case`pan`:case`transform`:return`transformGesture`;case`pinch`:return`pinch`;case`rotate`:return`rotateGesture`}}function Ke(t){return new e(`COMMAND_FAILED`,`The cloud driver did not finish reading the screen in its budget.`,{...t.details,hint:`A screen that never goes idle (looping video, live ticker, continuous animation) gives the driver no moment to read the UI tree. This read has the transport's own budget and does not grow with --timeout; take a screenshot, or drive the screen from refs an earlier snapshot already captured.`},t)}var qe=class{sessionsByLeaseId=new Map;ownedDeviceIds=new Set;releasedProviderSessionIdsByLeaseId=new Map;options;constructor(e){this.options=e}ownsDevice(e){return this.ownedDeviceIds.has(e.id)}findSessionForDevice(e){return[...this.sessionsByLeaseId.values()].find(t=>t.device.id===e.id)}findSessionForLease(e){return this.sessionsByLeaseId.get(e)}getInteractor(e){return this.findSessionForDevice(e)?.interactor}heartbeat(e){if(e.leaseProvider===this.options.provider&&this.sessionsByLeaseId.has(e.leaseId))return{provider:this.options.provider}}async allocate(e,t){if(e.leaseProvider!==this.options.provider)return;if(this.sessionsByLeaseId.has(e.leaseId))return this.heartbeat(e);let n=await this.prepareSession(e,t),r=new Se({clientVersion:this.options.clientVersion,endpoint:n.endpoint,auth:n.auth,headers:n.headers,requestPolicy:this.options.requestPolicy}),i=await this.createSessionWithPreparedCleanup(r,n,e,t),a=this.deviceForLease(e,n),o=n.providerSessionId??i.sessionId,s=d({provider:this.options.provider,platform:n.platform,overrides:this.options.capabilityOverrides});return this.sessionsByLeaseId.set(e.leaseId,Object.freeze({lease:e,device:a,client:r,prepared:n,capabilities:s,webDriverSessionId:i.sessionId,providerSessionId:o,interactor:He({client:r,backend:ie(n.platform),capabilities:s,targetId:a.id})})),this.ownedDeviceIds.add(a.id),{provider:this.options.provider,deviceId:a.id,sessionId:i.sessionId,providerSessionId:o,capabilities:s,...n.providerData}}async release(e){if(e.leaseProvider!==this.options.provider)return;let t=this.sessionsByLeaseId.get(e.leaseId);if(!t)return;this.sessionsByLeaseId.delete(e.leaseId),this.releasedProviderSessionIdsByLeaseId.set(e.leaseId,t.providerSessionId);let n=await this.closeSession(t),r=await this.safeListArtifacts(t);return{provider:this.options.provider,providerSessionId:t.providerSessionId,...n.cleanup,...n.warnings.length>0?{warnings:n.warnings}:{},...r?{cloudArtifacts:r}:{}}}async listCloudArtifacts(e){if(e.provider!==this.options.provider)return;let t=this.sessionsByLeaseId.get(e.leaseId??``);return t?await this.listActiveCloudArtifacts(t,e.providerSessionId):await this.listReleasedCloudArtifacts(e)}async listActiveCloudArtifacts(e,t){if(!(t&&t!==e.providerSessionId))return await this.safeListArtifacts(e)}async listReleasedCloudArtifacts(e){let t=this.releasedProviderSessionIdsByLeaseId.get(e.leaseId??``);if(!(!t||!this.options.listArtifacts)&&!(e.providerSessionId&&e.providerSessionId!==t))return await this.options.listArtifacts({provider:this.options.provider,providerSessionId:t})}async shutdown(){await Promise.allSettled([...this.sessionsByLeaseId.values()].map(async e=>await this.closeSession(e))),this.sessionsByLeaseId.clear(),this.ownedDeviceIds.clear()}async createSessionWithPreparedCleanup(e,t,n,r){try{return await e.createSession(t.webdriverCapabilities,{deadline:r?.deadline})}catch(e){let r=S(e)?Je(e,this.options.provider,n,t):e;throw await ue(r,()=>t.cleanup?.()),r}}async prepareSession(e,t){let n=this.baseSessionForLease(e);return this.options.prepareSession?await this.options.prepareSession({lease:e,req:t,base:n}):n}baseSessionForLease(e){let t=typeof this.options.webdriverCapabilities==`function`?this.options.webdriverCapabilities(e):this.options.webdriverCapabilities??{};return{provider:this.options.provider,endpoint:this.options.endpoint,platform:this.options.platform,deviceName:this.options.deviceName,auth:this.options.auth,headers:this.options.headers,webdriverCapabilities:P(this.options.platform,this.options.deviceName,t)}}deviceForLease(e,t){return{...n(t.platform),...t.platform===`ios`?{appleOs:`ios`}:{},id:t.deviceId??this.options.deviceId?.(e)??`${this.options.provider}:${t.platform}:${e.leaseId}`,name:t.deviceName,kind:`device`,target:`mobile`,booted:!0}}async closeSession(e){let n=[],r;try{await e.client.deleteSession()}catch(e){n.push({code:`WEBDRIVER_SESSION_DELETE_FAILED`,message:t(e)})}try{r=await e.prepared.cleanup?.()}catch(e){n.push({code:`PROVIDER_CLEANUP_FAILED`,message:t(e)})}return{cleanup:r,warnings:n}}async safeListArtifacts(e){let t=e.prepared.listArtifacts??this.options.listArtifacts;if(t)try{return await t({provider:this.options.provider,lease:e.lease,device:e.device,webDriverSessionId:e.webDriverSessionId,providerSessionId:e.providerSessionId})}catch(t){return le({provider:this.options.provider,providerSessionId:e.providerSessionId,error:t})}}};function P(e,t,n={}){return{platformName:e===`ios`?`iOS`:`Android`,"appium:deviceName":t,...n}}function Je(t,n,r,i){let a=t.details?.timeoutMs;return new e(`COMMAND_FAILED`,`${n} did not create the WebDriver session within ${String(a)}ms.`,{reason:`provider_session_create_timeout`,provider:n,leaseId:r.leaseId,runId:r.runId,timeoutMs:a,...i.providerSessionId?{providerSessionId:i.providerSessionId}:{},hint:`${n} may still finish creating the session after agent-device stopped waiting, and that session would keep billing until the provider reaps it. Before retrying, check ${n} for a running session created for lease ${r.leaseId} (run ${r.runId}) and stop it.`},t)}function F(e){return new Ye(e)}var Ye=class{provider;owner;leaseLifecycle;cloudArtifacts;deviceInventoryProvider;capabilities;platformRuntimeModule;sessions;deployment;constructor(e){this.provider=e.provider,this.owner=i(e.provider,e.platform),this.capabilities=d({provider:e.provider,platform:e.platform,overrides:e.capabilityOverrides}),this.sessions=new qe(e),this.deployment=oe({provider:e.provider,uploadApp:e.uploadApp,findSessionForDevice:e=>this.sessions.findSessionForDevice(e)}),this.platformRuntimeModule=Object.freeze({owner:this.owner,loadRuntime:async e=>await this.loadRuntime(e)}),this.leaseLifecycle={allocate:async(e,t)=>await this.sessions.allocate(e,t),heartbeat:async e=>this.sessions.heartbeat(e),release:async e=>await this.sessions.release(e)},this.cloudArtifacts={listCloudArtifacts:async e=>await this.sessions.listCloudArtifacts(e)},this.deviceInventoryProvider=async e=>{if(e.leaseProvider!==this.provider)return null;if(!e.leaseId)return[];let t=this.sessions.findSessionForLease(e.leaseId);return t?[t.device]:[]}}async loadRuntime(e){let{createWebDriverPlatformRuntimeOwner:t}=await import(`./platform-runtime2.js`);return t({host:e,owner:this.owner,ownsDevice:e=>this.ownsDevice(e),isSessionActive:e=>this.sessions.findSessionForDevice(e)!==void 0,deployment:this.deployment,capabilities:this.capabilities,snapshotAvailable:this.capabilities.operations.snapshot.support!==`unsupported`,screenshotAvailable:this.capabilities.operations.screenshot.support!==`unsupported`,getInteractor:e=>this.getInteractor(e)})}ownsDevice(e){return this.sessions.ownsDevice(e)}getInteractor(e){return this.sessions.getInteractor(e)}async installApp(e,t,n,r){return await this.deployment.installApp(e,t,n,r)}async installInstallablePath(e,t,n){return await this.deployment.installInstallablePath(e,t,n)}async shutdown(){await this.sessions.shutdown()}};async function I(e,t,n){return t?v({provider:e,providerSessionId:t,artifacts:(await Promise.all([n.listArtifacts(t,`FILE`),n.listArtifacts(t,`LOG`)])).flat().flatMap(n=>Ze(e,t,n)),pendingMessage:`AWS Device Farm artifacts are not ready yet.`}):void 0}function Xe(e){if(!e||typeof e!=`object`)return[];let t=e.artifacts;return Array.isArray(t)?t:[]}function Ze(e,t,n){let r=n.url;return typeof r!=`string`||r.length===0?[]:[{provider:e,providerSessionId:t,kind:Qe(n.type),name:n.name??n.type??`AWS Device Farm artifact`,url:r,providerArtifactId:n.arn,extension:n.extension,availability:`ready`,metadata:{awsType:n.type,...n.metadata?{awsMetadata:n.metadata}:{}}}]}function Qe(e){switch(e){case`VIDEO`:return`video`;case`APPIUM_SERVER_OUTPUT`:return`appium-log`;case`DEVICE_LOG`:return`device-log`;case`MESSAGE_LOG`:case`UNKNOWN`:return`automation-log`;default:return`raw`}}m.awsDeviceFarm;const $e={install:{support:`unsupported`,note:`Pass appArn when creating the remote access session; local artifact upload/install is not implemented.`},portReverse:{support:`unsupported`,note:`AWS Device Farm remote access does not expose agent-device port reverse.`},artifacts:{support:`supported`,note:`AWS Device Farm remote access exposes provider-hosted video, Appium logs, and device logs after session completion.`}};function L(e){let t=R(e);return{createRemoteAccessSession:async e=>z(await t(`create-remote-access-session`,[`--project-arn`,e.projectArn,`--device-arn`,e.deviceArn,`--name`,e.name,...e.appArn?[`--app-arn`,e.appArn]:[],...e.interactionMode?[`--interaction-mode`,e.interactionMode]:[],...e.configuration?[`--configuration`,JSON.stringify(e.configuration)]:[]])),getRemoteAccessSession:async e=>z(await t(`get-remote-access-session`,[`--arn`,e])),stopRemoteAccessSession:async e=>z(await t(`stop-remote-access-session`,[`--arn`,e])),listArtifacts:async(e,n)=>Xe(await t(`list-artifacts`,[`--arn`,e,`--type`,n]))}}function et(t){return async({lease:n,req:r,base:i})=>{let a=await t.client.createRemoteAccessSession({projectArn:t.projectArn,deviceArn:t.deviceArn,appArn:t.appArn,name:de(t.sessionName,n)??`agent-device-${n.leaseId}`,interactionMode:t.interactionMode,configuration:t.configuration}),o,s;try{if(o=await rt(a.arn,t,r),s=tt(o),!s)throw new e(`COMMAND_FAILED`,`AWS Device Farm did not expose a WebDriver endpoint.`,{sessionArn:o.arn,status:o.status})}catch(e){throw await ue(e,()=>t.client.stopRemoteAccessSession(a.arn)),e}let c=o.device?.name??t.deviceName,l=typeof t.webdriverCapabilities==`function`?t.webdriverCapabilities(n):t.webdriverCapabilities??{},u=t.platform===`android`?{"appium:autoLaunch":!1}:{};return{...i,endpoint:s,platform:t.platform,deviceName:c,webdriverCapabilities:P(t.platform,c,{...u,...l}),cleanup:async()=>(await t.client.stopRemoteAccessSession(o.arn),{awsDeviceFarmSessionArn:o.arn}),providerSessionId:o.arn,providerData:{awsDeviceFarmSessionArn:o.arn}}}}function tt(e){let t=e.endpoints&&typeof e.endpoints==`object`?Object.values(e.endpoints):[],n=[e.remoteDriverEndpoint,e.endpoint,...t,e.remoteDebugUrl,e.remoteRecordAppUrl].filter(e=>typeof e==`string`&&e.length>0).find(e=>!/^wss?:\/\//i.test(e));return n?nt(n):void 0}function nt(e){return/^https?:\/\//i.test(e)?e:`http://${e}`}async function rt(t,n,r){let i=n.pollIntervalMs??5e3,a=Date.now(),o=r?.deadline??a+(n.startupTimeoutMs??12e4),s=r?.signal,c=await n.client.getRemoteAccessSession(t);for(;Date.now()<o;){if(s?.throwIfAborted(),c.status===`RUNNING`)return c;at(c),await ne(i,void 0,{signal:s}).catch(()=>s?.throwIfAborted()),c=await n.client.getRemoteAccessSession(t)}throw new e(`COMMAND_FAILED`,`Timed out waiting for AWS Device Farm remote access.`,{sessionArn:t,status:c.status,result:c.result,timeoutMs:o-a})}const it=new Set([`ERRORED`,`STOPPED`,`COMPLETED`]);function at(t){if(!(!t.status||!it.has(t.status)))throw new e(`COMMAND_FAILED`,`AWS Device Farm remote access session did not start.`,{sessionArn:t.arn,status:t.status,result:t.result})}async function ot(t,n,r){let i=await t(n,r);try{return JSON.parse(i.stdout)}catch(t){throw new e(`COMMAND_FAILED`,`AWS Device Farm returned invalid JSON.`,void 0,t)}}function R(e){let t=e.region?[`--region`,e.region]:[],n=e.awsCommand??`aws`;return async(r,i)=>await ot(e.runHostCommand,n,[`devicefarm`,r,...t,...i,`--output`,`json`])}function z(t){if(!t||typeof t!=`object`)throw new e(`COMMAND_FAILED`,`AWS Device Farm response was not an object.`,{response:t});let n=t.remoteAccessSession;if(!n||typeof n!=`object`)throw new e(`COMMAND_FAILED`,`AWS Device Farm response missed remoteAccessSession.`,{response:t});return n}const B=[{field:`providerDeviceOrientation`,capability:`deviceOrientation`,flag:`--provider-device-orientation`,type:`enum`,enumValues:o},{field:`providerGeoLocation`,capability:`geoLocation`,flag:`--provider-geo-location`,type:`string`},{field:`providerTimezone`,capability:`timezone`,flag:`--provider-timezone`,type:`string`},{field:`providerAppiumVersion`,capability:`appiumVersion`,flag:`--provider-appium-version`,type:`string`},{field:`providerLanguage`,capability:`language`,flag:`--provider-language`,type:`string`},{field:`providerLocale`,capability:`locale`,flag:`--provider-locale`,type:`string`},{field:`providerNetworkProfile`,capability:`networkProfile`,flag:`--provider-network-profile`,type:`string`},{field:`providerCustomNetwork`,capability:`customNetwork`,flag:`--provider-custom-network`,type:`string`},{field:`providerNoResignApp`,capability:`resignApp`,flag:`--provider-no-resign-app`,type:`negated-boolean`,platform:`ios`}];function st(e,t){pt(e);let n={};for(let r of B){let i=e[r.field];i!==void 0&&i!==!1&&i!==``&&(ft(r,t),n[r.capability]=r.type!==`negated-boolean`&&i)}return n}function ct(e){return B.filter(t=>{let n=e?.[t.field];return n!==void 0&&n!==!1&&n!==``}).map(e=>e.flag)}function V(t,n){let r=ct(t);if(r.length===0)return;let i=r.length!==1;throw new e(`INVALID_ARGS`,`${r.join(`, `)} ${i?`are`:`is`} only supported by BrowserStack, not ${n}.`,{hint:`Drop ${i?`those flags`:`the flag`} or use the browserstack provider.`,provider:n,flags:r})}function lt(e){let t={};for(let n of B){let r=e?.[n.field];if(n.type===`negated-boolean`){r===!0&&(t.providerNoResignApp=!0);continue}typeof r==`string`&&r.length!==0&&ut(t,n,r)}return t}function ut(e,t,n){if(t.field===`providerDeviceOrientation`){e.providerDeviceOrientation=dt(t,n);return}t.field!==`providerNoResignApp`&&(e[t.field]=n)}function dt(t,n){let r=o.find(e=>e===n);if(r)return r;throw new e(`INVALID_ARGS`,`Invalid ${t.flag} value: ${n}.`,{hint:`Use ${o.join(`|`)}.`,flag:t.flag,capability:t.capability})}function ft(t,n){if(!(!t.platform||t.platform===n))throw new e(`INVALID_ARGS`,`${t.flag} applies to ${t.platform} sessions only, but the session platform is ${n}.`,{hint:`Drop ${t.flag} or connect with --platform ${t.platform}.`,flag:t.flag,capability:t.capability,platform:n})}function pt(t){if(!(!t.providerNetworkProfile||!t.providerCustomNetwork))throw new e(`INVALID_ARGS`,`BrowserStack accepts either a named network profile or a custom network shape, not both.`,{hint:`Pass only one of --provider-network-profile or --provider-custom-network.`,networkProfile:t.providerNetworkProfile,customNetwork:t.providerCustomNetwork})}m.browserStack;const mt={install:{support:`partial`,note:`Local app artifacts are uploaded to BrowserStack App Automate, then installed with Appium.`},portReverse:{support:`unsupported`,note:`Use BrowserStack Local for network tunneling; agent-device port reverse is not available.`},artifacts:{support:`supported`,note:`BrowserStack session details expose provider-hosted video, Appium logs, device logs, and dashboard links.`}};async function H(e,t,n){return t?v({provider:e,providerSessionId:t,artifacts:yt(e,t,await vt(t,n)),pendingMessage:`BrowserStack artifacts are not ready yet.`}):void 0}async function U(t,n,r){r?.throwIfAborted();let i=await g.readFile(t),a=new FormData;a.set(`file`,new Blob([i]),h.basename(t));let o=await fetch(n.endpoint??`https://api-cloud.browserstack.com/app-automate/upload`,{method:`POST`,headers:{...y(n.clientVersion),Authorization:b(n)},body:a,signal:r}),s=await o.json(),c=bt(s);if(!o.ok||!c)throw new e(`COMMAND_FAILED`,`BrowserStack app upload failed.`,{status:o.status,response:s});return c}function ht(e){return async({appPath:t,options:n,signal:r})=>({appReference:await U(t,e,r),bundleId:n?.appIdentifierHint,packageName:n?.packageNameHint,launchTarget:n?.appIdentifierHint??n?.packageNameHint})}function gt(e){let{"bstack:options":t,...n}=e.configured??{};return{"appium:deviceName":e.deviceName,"appium:platformVersion":e.osVersion,...e.app?{"appium:app":e.app}:{},...n,"bstack:options":{...e.projectName?{projectName:e.projectName}:{},buildName:e.buildName,sessionName:e.sessionName,...e.deviceFeatures??{},..._t(t)}}}function _t(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}async function vt(t,n){let r=new URL(`${pe(String(n.endpoint??`https://api-cloud.browserstack.com/app-automate/sessions`))}/${t}.json`),i=await fetch(r,{headers:{...y(n.clientVersion),Authorization:b(n)}}),a=await i.json();if(!i.ok||!a||typeof a!=`object`)throw new e(`COMMAND_FAILED`,`BrowserStack session details lookup failed.`,{status:i.status,response:a});let o=a.automation_session??a;return o&&typeof o==`object`?o:{}}function yt(e,t,n){return[W(e,t,n,`video_url`,`video`,`Session video`),W(e,t,n,`appium_logs_url`,`appium-log`,`Appium logs`),W(e,t,n,`device_logs_url`,`device-log`,`Device logs`),W(e,t,n,`browser_url`,`provider-session`,`BrowserStack dashboard`),W(e,t,n,`public_url`,`provider-session`,`Public session link`)].filter(e=>e!==void 0)}function W(e,t,n,r,i,a){let o=n[r];if(typeof o==`string`&&o.length!==0)return{provider:e,providerSessionId:t,kind:i,name:a,url:o,availability:`ready`}}function bt(e){if(!e||typeof e!=`object`)return;let t=e.app_url;return typeof t==`string`?t:void 0}function G(e){return/^arn:[^:]+:devicefarm:([^:]+):/.exec(e)?.[1]}async function xt(t,n){let r=R({runHostCommand:n,region:t.region}),[i,a,o]=await Promise.all([r(`get-project`,[`--arn`,t.projectArn]),r(`get-device`,[`--arn`,t.deviceArn]),t.appArn?r(`get-upload`,[`--arn`,t.appArn]):void 0]),s=K(i,`project`),c=K(a,`device`),l=Ct(c.platform);if(l!==t.platform)throw new e(`INVALID_ARGS`,`AWS Device Farm device "${q(c.name)??t.deviceArn}" is ${l}, not ${t.platform}.`);let u=t.appArn?St(K(o,`upload`),t):{status:`missing`,message:`No app upload is attached; AWS Device Farm does not support install after allocation. Reconnect with --aws-app-arn <arn>.`};return{provider:`aws-device-farm`,service:`AWS Device Farm`,verificationMessage:t.appArn?`Credentials, project, device, and app upload verified.`:`Credentials, project, and device verified.`,project:{name:q(s.name),reference:t.projectArn},device:{status:`verified`,name:q(c.name)??t.deviceArn,reference:t.deviceArn,platform:l,osVersion:q(c.os),availability:q(c.availability)},app:u}}function St(t,n){let r=q(t.status);if(r!==`SUCCEEDED`)throw new e(`COMMAND_FAILED`,`AWS Device Farm app upload is not ready (${r??`unknown status`}).`,{status:r,hint:`Wait for the upload to succeed or reconnect with a different --aws-app-arn.`});let i=n.platform===`android`?`ANDROID_APP`:`IOS_APP`,a=q(t.type);if(a!==i)throw new e(`INVALID_ARGS`,`AWS Device Farm app upload type is ${a??`unknown`}, expected ${i}.`);return{status:`verified`,name:q(t.name),reference:n.appArn}}function K(t,n){if(!t||typeof t!=`object`)throw new e(`COMMAND_FAILED`,`AWS Device Farm ${n} response was not an object.`);let r=t[n];if(!r||typeof r!=`object`||Array.isArray(r))throw new e(`COMMAND_FAILED`,`AWS Device Farm response missed ${n}.`);return r}function Ct(t){if(t===`ANDROID`)return`android`;if(t===`IOS`)return`ios`;throw new e(`UNSUPPORTED_PLATFORM`,`AWS Device Farm device platform is ${String(t)}.`)}function q(e){return typeof e==`string`&&e.length>0?e:void 0}async function wt(t,n){let r={username:t.username,accessKey:t.accessKey},i=Dt(await J(t.devicesEndpoint??`https://api-cloud.browserstack.com/app-automate/devices.json`,r,n)).find(e=>e.device===t.deviceName&&e.os.toLowerCase()===t.platform&&Et(e.osVersion,t.osVersion));if(!i)throw new e(`INVALID_ARGS`,`BrowserStack device "${t.deviceName}" with ${t.platform} ${t.osVersion} is not available.`,{hint:`Choose an exact device and OS version from the BrowserStack App Automate device list.`});let a=await Tt(t,r,n);return{provider:`browserstack`,service:`BrowserStack`,verificationMessage:a.status===`verified`?`Credentials, device, and uploaded app verified.`:`Credentials and device access verified; app availability is checked when the session is created.`,device:{status:`verified`,name:i.device,platform:t.platform,osVersion:i.osVersion},app:a}}async function Tt(e,t,n){let{app:r}=e;if(r.startsWith(`bs://`)){let i=Ot(await J(e.appsEndpoint??`https://api-cloud.browserstack.com/app-automate/recent_apps?limit=100`,t,n)).find(e=>e.reference===r);return i?{status:`verified`,...i}:{status:`configured`,reference:r,message:`App reference was not found in the 100 most recent uploads; BrowserStack validates it when creating the session.`}}return/^https?:\/\//i.test(r)?{status:`configured`,reference:r,message:`Public app URL configured; BrowserStack validates it when creating the session.`}:{status:`configured`,name:h.basename(r),reference:r,message:`Local app artifact is ready and will be uploaded when creating the session.`}}async function J(t,n,r){try{let i=await fetch(t,{headers:{...y(r),Authorization:b(n)},signal:AbortSignal.timeout(15e3)});if(!i.ok){let t=i.status===401||i.status===403;throw new e(t?`UNAUTHORIZED`:`COMMAND_FAILED`,`BrowserStack rejected connection verification.`,{status:i.status,hint:t?`Check BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY.`:`Retry connect or check the BrowserStack service status.`})}return await i.json()}catch(t){throw t instanceof e?t:new e(`COMMAND_FAILED`,`BrowserStack connection verification failed.`,{hint:`Check network access to api-cloud.browserstack.com and retry connect.`},t)}}function Et(e,t){let n=e=>e.replace(/(?:\.0)+$/,``);return n(e)===n(t)}function Dt(t){if(!Array.isArray(t))throw new e(`COMMAND_FAILED`,`BrowserStack device verification response was not a list.`);return t.flatMap(e=>{let t=Y(e),n=t?.os_version;return t&&typeof t.device==`string`&&typeof t.os==`string`&&(typeof n==`string`||typeof n==`number`)?[{device:t.device,os:t.os,osVersion:String(n)}]:[]})}function Ot(t){let n=Y(t);if(n&&Object.keys(n).length===0)return[];if(!Array.isArray(t))throw new e(`COMMAND_FAILED`,`BrowserStack app verification response was not a list.`);return t.flatMap(e=>{let t=Y(e);return!t||typeof t.app_url!=`string`?[]:[{reference:t.app_url,...typeof t.app_name==`string`?{name:t.app_name}:{},...typeof t.app_version==`string`?{version:t.app_version}:{}}]})}function Y(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:void 0}async function kt(e,t){return e.provider===`browserstack`?await wt(e,t.clientVersion):await xt(e,t.runHostCommand)}function At(e){return[{provider:m.browserStack,createRuntime:t=>F({clientVersion:e.clientVersion,provider:m.browserStack,platform:`android`,deviceName:`BrowserStack device`,endpoint:t.BROWSERSTACK_WEBDRIVER_ENDPOINT??`https://hub-cloud.browserstack.com/wd/hub/`,capabilityOverrides:mt,listArtifacts:async({provider:n,providerSessionId:r})=>{let i=$(t,`BROWSERSTACK_USERNAME`,`BrowserStack artifact lookup`),a=$(t,`BROWSERSTACK_ACCESS_KEY`,`BrowserStack artifact lookup`);return await H(n,r,{clientVersion:e.clientVersion,username:i,accessKey:a,endpoint:t.BROWSERSTACK_SESSION_DETAILS_ENDPOINT})},prepareSession:async({req:n,lease:r,base:i})=>{let a=X(n,`BrowserStack`),o=$(t,`BROWSERSTACK_USERNAME`,`BrowserStack`),s=$(t,`BROWSERSTACK_ACCESS_KEY`,`BrowserStack`),c=Nt(a,`BrowserStack`),l=Z(a,`device`,`BrowserStack requires --device <name>.`),u=Z(a,`providerOsVersion`,`BrowserStack requires --provider-os-version <version>.`),d=await jt({clientVersion:e.clientVersion,app:Z(a,`providerApp`,`BrowserStack requires --provider-app <bs://app-id-or-local-path>.`),cwd:a.cwd,username:o,accessKey:s,uploadEndpoint:t.BROWSERSTACK_APP_UPLOAD_ENDPOINT,signal:a.signal});return{...i,platform:c,deviceName:l,auth:{username:o,accessKey:s},uploadApp:ht({clientVersion:e.clientVersion,username:o,accessKey:s,endpoint:t.BROWSERSTACK_APP_UPLOAD_ENDPOINT??`https://api-cloud.browserstack.com/app-automate/upload`}),webdriverCapabilities:gt({deviceName:l,osVersion:u,app:d,projectName:Q(a,`providerProject`),buildName:Q(a,`providerBuild`)??r.runId,sessionName:Q(a,`providerSessionName`)??r.leaseId,deviceFeatures:st(lt(a.flags),c),configured:P(c,l)})}}}),listArtifactsFromEnv:async(t,n)=>{let r=$(n,`BROWSERSTACK_USERNAME`,`BrowserStack artifact lookup`),i=$(n,`BROWSERSTACK_ACCESS_KEY`,`BrowserStack artifact lookup`);return await H(m.browserStack,t,{clientVersion:e.clientVersion,username:r,accessKey:i,endpoint:n.BROWSERSTACK_SESSION_DETAILS_ENDPOINT})}},{provider:m.awsDeviceFarm,createRuntime:t=>F({clientVersion:e.clientVersion,provider:m.awsDeviceFarm,endpoint:`http://127.0.0.1/`,platform:`android`,deviceName:`AWS Device Farm device`,capabilityOverrides:$e,listArtifacts:async({provider:n,providerSessionId:r})=>await I(n,r,L({runHostCommand:e.runHostCommand,region:t.AWS_REGION??t.AWS_DEFAULT_REGION??G(r??``)})),prepareSession:async({req:n,lease:r,base:i})=>{let a=X(n,`AWS Device Farm`);V(a.flags,m.awsDeviceFarm);let o=Nt(a,`AWS Device Farm`);return await et({client:L({runHostCommand:e.runHostCommand,region:Q(a,`awsRegion`)??t.AWS_REGION??t.AWS_DEFAULT_REGION}),projectArn:Pt(a,t,`awsProjectArn`,`AGENT_DEVICE_AWS_DEVICE_FARM_PROJECT_ARN`,`AWS_DEVICE_FARM_PROJECT_ARN`),deviceArn:Pt(a,t,`awsDeviceArn`,`AGENT_DEVICE_AWS_DEVICE_FARM_DEVICE_ARN`,`AWS_DEVICE_FARM_DEVICE_ARN`),appArn:Q(a,`awsAppArn`)??t.AGENT_DEVICE_AWS_DEVICE_FARM_APP_ARN??t.AWS_DEVICE_FARM_APP_ARN,platform:o,deviceName:Q(a,`device`)??`AWS Device Farm device`,sessionName:Q(a,`providerSessionName`)??r.leaseId,interactionMode:Ft(a)})({lease:r,req:n,base:i})}}),listArtifactsFromEnv:async(t,n)=>{let r=L({runHostCommand:e.runHostCommand,region:n.AWS_REGION??n.AWS_DEFAULT_REGION??G(t)});return await I(m.awsDeviceFarm,t,r)}}]}async function jt(t){if(Mt(t.app))return t.app;let n=h.resolve(t.cwd??process.cwd(),t.app);if(!te.existsSync(n))throw new e(`INVALID_ARGS`,`BrowserStack --provider-app must be a bs:// app id, URL, or existing local app path.`,{providerApp:t.app});return await U(n,{clientVersion:t.clientVersion,username:t.username,accessKey:t.accessKey,endpoint:t.uploadEndpoint},t.signal)}function Mt(e){return e.startsWith(`bs://`)||/^https?:\/\//.test(e)}function X(t,n){if(t)return t;throw new e(`INVALID_ARGS`,`${n} lease allocation requires provider profile flags on the request.`)}function Nt(t,n){let r=t.flags?.platform;if(r===`android`||r===`ios`)return r;throw new e(`INVALID_ARGS`,`${n} requires --platform ios|android.`)}function Z(t,n,r){let i=Q(t,n);if(i)return i;throw new e(`INVALID_ARGS`,r)}function Q(e,t){let n=e.flags?.[t];return typeof n==`string`&&n.length>0?n:void 0}function $(t,n,r){let i=t[n];if(i)return i;throw new e(`INVALID_ARGS`,`${r} requires ${n} in the environment.`)}function Pt(t,n,r,i,a){let o=Q(t,r)??n[i]??n[a];if(o)return o;throw new e(`INVALID_ARGS`,`AWS Device Farm requires --${It(String(r))} or ${a}.`)}function Ft(e){let t=Q(e,`awsInteractionMode`);if(t===`INTERACTIVE`||t===`NO_VIDEO`||t===`VIDEO_ONLY`)return t}function It(e){return e.replaceAll(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function Lt(e){let t=At(e);return{providerIds:t.map(e=>e.provider),createDefaultRuntimes:(e=process.env)=>t.map(t=>t.createRuntime(e)),listArtifactsFromEnv:async(e,n)=>{if(e.providerSessionId)return await t.find(t=>t.provider===e.provider)?.listArtifactsFromEnv(e.providerSessionId,n)},verifyConnection:async t=>await kt(t,e)}}const Rt=Lt({clientVersion:u(),runHostCommand:async(e,t)=>({stdout:(await l(e,[...t],{maxBuffer:10485760,timeoutMs:3e4})).stdout})});export{G as n,V as r,Rt as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e}from"./sdk-contracts.js";import{i as t}from"./capture.js";import{n}from"./snapshot-quality-backend-capabilities.js";import{
|
|
1
|
+
import{D as e}from"./sdk-contracts.js";import{i as t}from"./capture.js";import{n}from"./snapshot-quality-backend-capabilities.js";import{i as r,o as i}from"./png-worker-client.js";import{r as a}from"./png.js";import{promises as o}from"node:fs";const s=new Set([`healthy`,`recovered`,`sparse`]),c=new Set(Object.keys(n)),l=new Set([`ax-rejected`,`sparse-tree`,`budget`,`no-nodes`,`capture-failed`,`presentation-failed`,`deferred`,`requested-backend`]);function u(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.state!=`string`||!s.has(t.state)||typeof t.backend!=`string`||!c.has(t.backend))return;let n=d(t.timing);return{state:t.state,backend:t.backend,reason:typeof t.reason==`string`?t.reason:void 0,reasonCode:typeof t.reasonCode==`string`&&l.has(t.reasonCode)?t.reasonCode:void 0,customActions:f(t.customActions),effectiveDepth:typeof t.effectiveDepth==`number`?t.effectiveDepth:void 0,collapsedLeafIndexes:Array.isArray(t.collapsedLeafIndexes)?t.collapsedLeafIndexes.filter(e=>typeof e==`number`):void 0,...n?{timing:n}:{}}}function d(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.acquisitionMs==`number`&&typeof t.presentationMs==`number`)return{acquisitionMs:t.acquisitionMs,presentationMs:t.presentationMs}}function f(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.read==`number`&&typeof t.candidates==`number`)return{read:t.read,candidates:t.candidates,truncated:typeof t.truncated==`number`?t.truncated:0,blocked:t.blocked===!0}}function p(e){return e?.state===`sparse`}function m(e){return e?.backend===`private-ax`?`private-ax`:void 0}async function h(n,a){let{min:s,max:c}=t;if(!Number.isFinite(a)||a<s||a>c)throw new e(`INVALID_ARGS`,`Screenshot scale must be between ${s} and ${c}`);if(a===1)return;let l=await r(await o.readFile(n),`screenshot`),u=Math.max(1,Math.round(l.width*a)),d=Math.max(1,Math.round(l.height*a));await o.writeFile(n,await i(_(l,u,d)))}async function g(t,n,a){if(!Number.isInteger(n)||n<1||!Number.isInteger(a)||a<1)throw new e(`INVALID_ARGS`,`Screenshot resize dimensions must be positive integers`);let s=await r(await o.readFile(t),`screenshot`);(s.width!==n||s.height!==a)&&await o.writeFile(t,await i(_(s,n,a)))}function _(e,t,n){let r=new a.PNG({width:t,height:n});for(let i=0;i<n;i+=1){let a=i*e.height/n,o=(i+1)*e.height/n;for(let n=0;n<t;n+=1){let s=n*e.width/t,c=(n+1)*e.width/t,l=0,u=0,d=0,f=0,p=0;for(let t=Math.floor(a);t<Math.ceil(o);t+=1){let n=Math.min(t+1,o)-Math.max(t,a);for(let r=Math.floor(s);r<Math.ceil(c);r+=1){let i=n*(Math.min(r+1,c)-Math.max(r,s)),a=(t*e.width+r)*4;l+=(e.data[a]??0)*i,u+=(e.data[a+1]??0)*i,d+=(e.data[a+2]??0)*i,f+=(e.data[a+3]??0)*i,p+=i}}let m=(i*r.width+n)*4;r.data[m]=Math.round(l/p),r.data[m+1]=Math.round(u/p),r.data[m+2]=Math.round(d/p),r.data[m+3]=Math.round(f/p)}}return r}function v(e,t){return[...S(e),...y(e),...w(e),...T(e,t)]}function y(e){let t=e.customActions;if(!t)return[];let n=[];return t.blocked?n.push(`Custom actions were not read: an earlier accessibility read is still hung, so this capture skipped the read pass instead of queueing behind it. No element’s actions list is authoritative here. Reads resume once that call returns.`):t.read<t.candidates&&n.push(`Custom actions were read for ${t.read} of ${t.candidates} merged elements, on-screen ones first; the remaining ${t.candidates-t.read} were not read, so an absent actions list on those is not evidence that they have none. Scroll them into view and re-run to read them.`),t.truncated>0&&n.push(`${t.truncated} element(s) published more custom actions than are shown; those lists are clipped to the first 8 names, and long names are shortened.`),n}function b(e){return e===!0?[`This capture was cut at a backend limit, so elements later in the tree — footers, tab bars, items after a long list — may be missing even when they are on screen; their refs and selectors cannot be resolved from this snapshot. Navigate or scroll so fewer elements render and re-run, and use screenshot as visual truth for what is missing.`]:[]}function x(e){return`Detected an overly complex or slow accessibility tree. Fell back to the ${e} snapshot backend. It is OK to continue; use --json to inspect snapshotQuality.reason if you need recovery details.`}function S(e){return e.state===`recovered`?e.reasonCode===`deferred`||e.reasonCode===`requested-backend`?[]:e.reasonCode===`presentation-failed`?[`Agent Device could not safely present the captured accessibility tree and fell back to the ${e.backend} snapshot backend. This is an Agent Device runner bug, not an app accessibility-tree issue. Use screenshot as visual truth and report snapshotQuality.reason with the screenshot.`]:[x(e.backend)]:e.state===`sparse`?[`No snapshot backend could read this screen`+(e.reason?` (${e.reason})`:``)+`. Its refs and selectors are invalid. Use screenshot as visual truth and coordinate taps; retry snapshot after navigating.`,...C(e)]:[]}function C(e){return e.reasonCode===`sparse-tree`?[`This screen publishes no accessibility content at all; assistive technologies see the same empty tree, so it is worth flagging as an app accessibility bug rather than only an automation limitation.`]:[]}function w(e){return e.effectiveDepth===void 0?[]:[`Some deeper accessibility nodes were omitted; the accessibility backend capped this tree at depth ${e.effectiveDepth}. Navigate so the content you need sits higher in the tree, and use screenshot as visual truth for the rest.`]}function T(e,t){let n=[];for(let r of e.collapsedLeafIndexes??[]){let e=t.find(e=>e.index===r);if(!e)continue;let i=e.identifier?` (${e.identifier})`:``;n.push(`@${e.ref} [${e.type??`element`}]${i} merges many labels into a single accessibility element. The app likely marks a container as accessible, which hides every descendant from assistive tech and automation — the children cannot be addressed individually. Fix the app's accessibility (mark the rows, not the container); until then use screenshot as visual truth and coordinate taps.`)}return n}export{g as a,m as c,_ as i,u as l,v as n,h as o,b as r,p as s,x as t};
|
package/dist/src/react-native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{L as e,o as t,u as n}from"./sdk-contracts.js";import{O as r}from"./sdk-batch-runner.js";import{M as i,d as a,u as o}from"./session-snapshot.js";import{M as s}from"./runtime.js";import{n as c}from"./catalog.js";import{r as l}from"./success-text.js";import{n as u}from"./touch-reference-frame.js";import{
|
|
1
|
+
import{L as e,o as t,u as n}from"./sdk-contracts.js";import{O as r}from"./sdk-batch-runner.js";import{M as i,d as a,u as o}from"./session-snapshot.js";import{M as s}from"./runtime.js";import{n as c}from"./catalog.js";import{r as l}from"./success-text.js";import{n as u}from"./touch-reference-frame.js";import{s as d}from"./quality-warnings.js";import{o as f}from"./interaction-ref-policy.js";import{captureSnapshotForSession as p}from"./interaction.js";async function m(r){let{req:i,sessionName:o,sessionStore:l}=r;if(i.command!==c.reactNative)return null;let u=h(i.positionals??[]);if(!u.ok)return u.response;let f=l.get(o);if(!f)return n();let m=await a({device:f.device,command:`press`,requiresCapture:!1,inspectFacts:r.inspectFacts,bindDevice:r.bindDevice,unavailableResponse:e=>t(`UNSUPPORTED_OPERATION`,`react-native dismiss-overlay is not supported on this device`,void 0,e.hint?{hint:e.hint}:void 0)});if(!m.ok)return m.response;try{let e=await p(f,i.flags,l,r.contextFromFlags,{interactiveOnly:!0});if(d(e.snapshotQuality))return _(e.snapshotQuality);let t=s(e.nodes),n=t.primaryAction;return n?await v(r,f,e,n,m.runtime):g(t.detected)}catch(t){return{ok:!1,error:e(t)}}}function h(e){return e.length===1&&e[0]===`dismiss-overlay`?{ok:!0}:{ok:!1,response:t(`INVALID_ARGS`,`react-native supports only: dismiss-overlay`)}}function g(e){return e?t(`COMMAND_FAILED`,`React Native overlay detected, but no safe dismiss target was found`,{hint:`Use screenshot --overlay-refs for visual evidence and report the overlay instead of pressing the warning body.`}):{ok:!0,data:{action:`dismiss-overlay`,detected:!1,dismissed:!1,...l(`No React Native overlay detected`)}}}function _(e){return t(`COMMAND_FAILED`,`React Native overlay state could not be determined because the accessibility tree is unreadable`,{reason:e.reason,hint:`The snapshot quality verdict is sparse. Use screenshot as visual truth; if an overlay is visible, report it or navigate with coordinates, then retry snapshot or dismiss-overlay on a readable screen.`})}async function v(e,n,a,s,c){let{req:d,sessionStore:p}=e,m=e.contextFromFlags(d.flags,n.appBundleId,n.trace?.outPath),h=o(c,m).tapPoint;if(!h)return t(`UNSUPPORTED_OPERATION`,`react-native dismiss-overlay is not supported on this device`);let g=Date.now();i(n);let _=await h(s.point),v=Date.now(),x=await y(e,n),S=r({...u(a.nodes),..._,action:`dismiss-overlay`,overlayAction:s.action,x:s.point.x,y:s.point.y,ref:s.ref,label:s.label,warning:s.warning,dismissed:!0,verified:x.verified,verificationRequired:!x.verified,verificationWarning:x.verificationWarning,nextCommand:x.nextCommand,...l(b(x))});return f({session:n,sessionStore:p,command:d.command,positionals:d.positionals??[],flags:d.flags,result:S,responseData:S,actionStartedAt:g,actionFinishedAt:v})}async function y(e,t){let{req:n,sessionStore:r}=e,i=await p(t,n.flags,r,e.contextFromFlags,{interactiveOnly:!0});return d(i.snapshotQuality)?{verified:!1,verificationWarning:`React Native overlay dismissal could not be verified because the post-dismiss accessibility tree is unreadable. Use screenshot as visual truth.`,nextCommand:`agent-device screenshot`}:s(i.nodes).detected?{verified:!1,verificationWarning:`React Native overlay is still detected after dismissal. Use screenshot --overlay-refs for visual evidence and report the overlay instead of pressing the warning body.`,nextCommand:`agent-device screenshot --overlay-refs`}:{verified:!0}}function b(e){return e.verified?`React Native overlay dismiss action sent and verified gone`:`React Native overlay dismiss action sent, but verification still detects an overlay`}export{m as handleReactNativeCommands};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e,L as t}from"./sdk-contracts.js";import{c as n}from"./capture.js";import{g as r}from"./sdk-batch-runner.js";import{
|
|
1
|
+
import{D as e,L as t}from"./sdk-contracts.js";import{c as n}from"./capture.js";import{g as r}from"./sdk-batch-runner.js";import{E as i,k as a}from"./sdk-device.js";import{D as o,E as s,O as c}from"./sdk-batch.js";import{i as l,n as u}from"./recording-export-quality.js";import{n as d,r as f}from"./recording-scope.js";import{c as p}from"./session-store.js";import{r as m}from"./diagnostics.js";import"./diagnostics2.js";import{i as h}from"./output-path.js";import{i as ee,n as g}from"./recording-stop-observation.js";import{n as _}from"./request-runtime-binding.js";import{n as v}from"./dispatch-resolve.js";import"./screen-recording-admission-ledger.js";import{a as y,t as b}from"./session-routing.js";import{a as x,c as S,i as C,o as w,s as T,t as E}from"./screen-recording-resource-recovery.js";import{t as D}from"./telemetry.js";import O from"node:path";import k from"node:fs";const A=[`clientOutPath`,`telemetryPath`,`warning`,`overlayWarning`];function j(e){let{resourcePath:t,record:n}=N(e);if(n.status!==`decoded`)return{kind:`none`};if(P(e,n.envelope),n.envelope.lifecycle!==`completed`)return{kind:`open`,resourcePath:t};let r=F(n.envelope.metadata);return r===void 0?(m({level:`warn`,phase:`screen_recording_completed_manifest_unreplayable`,data:{resourcePath:t}}),{kind:`none`}):k.existsSync(r.outPath)?{kind:`completed`,completion:r}:{kind:`none`}}function M(e){let{record:t}=N(e);return t.status===`decoded`&&t.envelope.lifecycle===`completed`}function N(e){let t=S.resourcePath(e.sessionStore,e.sessionName);return{resourcePath:t,record:S.store.read(t)}}function P(t,n){if(n.sessionId!==t.sessionName)throw new e(`COMMAND_FAILED`,`Screen recording recovery record does not belong to the requested session`,{reason:`runtime-contract-invalid`});if(!a(n.device,i(t.device)))throw new e(`COMMAND_FAILED`,`Screen recording recovery device does not match the selected device`,{reason:`runtime-contract-invalid`})}function F(e){let t=e?.[C];if(!(!r(t)||!I(t)||!L(t)||!R(t)))return t}function I(e){return z(e.outPath)&&z(e.backend)&&V(e.startedAt)&&V(e.completedAt)&&(e.capturedDurationMs===void 0||V(e.capturedDurationMs))&&d(e.scope)&&typeof e.showTouches==`boolean`&&typeof e.recordOnlySession==`boolean`}function L(e){return A.every(t=>B(e[t]))&&te(e.activeSessionApp)&&W(e.chunks)}function R(e){return(e.stopObservation===void 0||g(e.stopObservation))&&(e.nativePathDisposition===void 0||ee(e.nativePathDisposition))}function z(e){return typeof e==`string`&&e.length>0}function B(e){return e===void 0||z(e)}function V(e){return typeof e==`number`&&Number.isFinite(e)}function H(e){return!r(e)||!z(e.bundleId)?!1:B(e.name)}function te(e){return e===void 0||H(e)}function U(e){return Array.isArray(e)&&e.every(e=>r(e)&&Number.isFinite(e.index)&&z(e.path)&&B(e.clientOutPath))}function W(e){return e===void 0||U(e)}function G(t){let r=n(`record`,t.flags);if(r)throw new e(`INVALID_ARGS`,r);let i=t.flags?.fps;if(i!==void 0&&(!Number.isInteger(i)||i<1||i>120))throw new e(`INVALID_ARGS`,`fps must be an integer between 1 and 120`);let a=l(t.flags?.quality);if(t.flags?.quality!==void 0&&a===void 0)throw new e(`INVALID_ARGS`,`quality must be one of: ${u.join(`, `)} (legacy numeric values 5-10 are accepted)`);return{scope:K(t.flags?.recordingScope),...i===void 0?{}:{fps:i},...a===void 0?{}:{exportQuality:a},showTouches:t.flags?.hideTouches!==!0,hideTouchesRequested:t.flags?.hideTouches===!0}}function K(t){if(t===void 0)return`app`;if(t===`app`||t===`device`||t===`system`)return t;throw new e(`INVALID_ARGS`,`record scope must be app, device, or system`)}function q(e){return{ok:!1,error:{code:`INVALID_ARGS`,message:b(e)?`record start with app scope and an explicit session requires an active app session; run open <app> first, or use --scope device to record the full screen`:`record start defaults to app scope and requires an active app session; run open <app> first, or use --scope device to record the full screen`}}}function J(e,t,n){return{ok:!0,data:{recording:`started`,outPath:e.clientOutPath??n,sessionStateDir:t,recordingBackend:e.backend,recordingScope:e.scope,recordOnlySession:e.recordOnlySession,activeSessionApp:e.activeSessionApp,showTouches:e.showTouches}}}function Y(e){return{action:`start`,...e.clientOutPath?{requestedFileName:O.basename(e.clientOutPath)}:{},showTouches:e.showTouches}}function X(e){return{ok:!1,error:{code:`UNSUPPORTED_OPERATION`,message:`record is not supported on this device`,hint:e.hint??`Select an Apple, Android, physical HarmonyOS, or web target that supports screen recording.`,details:{reason:e.reason}}}}function Z(e){let t=[Q(e)];if(e.chunks&&e.chunks.length>1&&t.push(...e.chunks.slice(1).map(e=>({field:`chunkPath`,artifactType:`screen-recording-chunk`,path:e.path,localPath:e.clientOutPath,fileName:O.basename(e.clientOutPath??e.path)}))),e.telemetryPath){let n=e.clientOutPath?D(e.clientOutPath):void 0;t.push({field:`telemetryPath`,artifactType:`screen-recording-telemetry`,path:e.telemetryPath,localPath:n,fileName:O.basename(e.telemetryPath)})}return{ok:!0,data:{recording:`stopped`,outPath:e.outPath,telemetryPath:e.telemetryPath,artifacts:t,recordingBackend:e.backend,recordingScope:e.scope,recordOnlySession:e.recordOnlySession,activeSessionApp:e.activeSessionApp,durationMs:Math.max(0,e.completedAt-e.startedAt),...e.capturedDurationMs===void 0?{}:{capturedDurationMs:e.capturedDurationMs},...e.stopObservation===void 0?{}:{recorder:e.stopObservation.recorder},...e.nativePathDisposition===void 0?{}:{nativePathDisposition:e.nativePathDisposition},showTouches:e.showTouches,warning:e.warning,overlayWarning:e.overlayWarning,chunks:e.chunks?.map(e=>({index:e.index,path:e.clientOutPath??e.path}))}}}function Q(e){return{field:`outPath`,artifactType:`screen-recording`,path:e.outPath,localPath:e.clientOutPath,fileName:O.basename(e.clientOutPath??e.outPath)}}async function ne(e){try{return await re(e)}catch(e){return{ok:!1,error:t(e)}}}async function re(e){let{req:t,sessionName:n,sessionStore:r}=e,i=r.get(n),{plan:a,scope:o}=ie(t,i);if(a.kind===`start`&&!f(o)&&!i)return q(t);let s=await ae(e,i),{session:c}=s;return a.kind===`start`?await oe(e,c,G(t),a.use,s.needsReadiness):await le(e,c,a.kind,s.needsReadiness)}function ie(e,t){let n=K(e.flags?.recordingScope);return{scope:n,plan:s({action:e.positionals?.[0],scope:n,hasLiveHandle:t?.screenRecording!==void 0})}}async function ae(e,t){let n=t?.device??await v(e.req.flags??{});return await e.retainDeviceExecutionLock(n.id),t?{session:t,needsReadiness:!1}:{session:fe(e,n),needsReadiness:!0}}async function oe(e,t,n,r,i){if(t.screenRecording)return{ok:!1,error:{code:`INVALID_ARGS`,message:`recording already in progress`}};let a=await e.bindDevice(t.device,o);i&&await _(a);let s=a.facts.screenRecordingStart;if(!s.available)return X(s);let c=await e.bindDevice(t.device,r),{fence:l,outputPaths:u}=$(e,t),d=await c.operations.screenRecordingStart(se(e,t,n,l,u.outputPath));await x({admissionLedger:e.admissionLedger,session:t,sessionName:e.sessionName,sessionStore:e.sessionStore,device:t.device,owner:c.owner,fence:l,...d,throwIfCanceled:e.throwIfCanceled});let f=e.sessionStore.get(e.sessionName)?.screenRecording;if(!f)throw TypeError(`Screen recording adoption did not publish a live handle`);let m=f.handle.inspect();return p(e.sessionStore,t,e.req,e.req.command,Y(m)),J(m,e.sessionStore.ensureSessionDir(e.sessionName),u.requestedPath)}function $(e,t){let n=S.resourcePath(e.sessionStore,e.sessionName);return{fence:S.createNextFence({admissionLedger:e.admissionLedger,resourcePath:n,device:t.device}),outputPaths:h({requestedPath:e.req.positionals?.[1],platform:t.device.platform,cwd:e.req.meta?.cwd})}}function se(e,t,n,r,i){return{sessionId:e.sessionName,outputPath:i,clientOutputPath:e.req.meta?.clientArtifactPaths?.outPath,scope:n.scope,showTouches:n.showTouches,hideTouchesRequested:n.hideTouchesRequested,recordOnlySession:t.recordOnlySession===!0,activeSessionApp:ce(t),exportQuality:n.exportQuality,fps:n.fps,fence:r}}function ce(e){if(e.appBundleId)return{bundleId:e.appBundleId,...e.appName?{name:e.appName}:{}}}async function le(e,t,n,r){let i;try{i=n===`stop-live`?{completion:await w({intent:`capture`,session:t,sessionName:e.sessionName,sessionStore:e.sessionStore}),recordsSessionAction:!0}:await de(e,t,r)}catch(n){throw ue(e,t),n}let a=i.completion,o=Z(a);return i.recordsSessionAction&&p(e.sessionStore,t,e.req,e.req.command,{action:`stop`,outPath:a.outPath,...a.clientOutPath?{requestedFileName:O.basename(a.clientOutPath)}:{},showTouches:a.showTouches}),t.recordOnlySession&&e.sessionStore.delete(e.sessionName),o}function ue(e,t){t.recordOnlySession&&M(e)&&e.sessionStore.delete(e.sessionName)}async function de(t,n,r){let i=j({sessionName:t.sessionName,sessionStore:t.sessionStore,device:n.device});if(i.kind===`completed`)return{completion:i.completion,recordsSessionAction:!1};if(i.kind===`none`)throw new e(`INVALID_ARGS`,`no active recording`);return{completion:await T({resourcePath:i.resourcePath,scope:t.requestScope,acquireControl:async(e,i)=>{let a=await t.bindExactDevice(n.device,e.owner,e.fence,c,i);return r&&await _(a),E({runtime:a,dispose:async()=>{}})}}),recordsSessionAction:!0}}function fe(e,t){return{name:e.sessionName,sessionScope:y(e.req),device:t,createdAt:Date.now(),recordOnlySession:!0,actions:[]}}export{ne as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=[`medium`,`high`],t=`medium`;function n(t){return e.includes(t)}function r(e){let t=typeof e==`number`?e:i(e);return t!==void 0&&Number.isInteger(t)&&t>=5&&t<=10?t:void 0}function i(e){return typeof e==`string`&&/^\d+$/.test(e)?Number(e):void 0}function a(e){if(n(e))return e;let t=r(e);if(t!==void 0)return t<=7?`medium`:`high`}export{e as n,
|
|
1
|
+
const e=[`medium`,`high`],t=`medium`;function n(t){return e.includes(t)}function r(e){let t=typeof e==`number`?e:i(e);return t!==void 0&&Number.isInteger(t)&&t>=5&&t<=10?t:void 0}function i(e){return typeof e==`string`&&/^\d+$/.test(e)?Number(e):void 0}function a(e){if(n(e))return e;let t=r(e);if(t!==void 0)return t<=7?`medium`:`high`}export{a as i,e as n,n as r,t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=[`app`,`device`,`system`];function t(t){return e.some(e=>e===t)}function n(e){return e===`device`||e===`system`}export{t as n,n as r,e as t};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{D as e}from"./sdk-contracts.js";import{n as t}from"./path-resolution.js";import"./file.js";import{t as n}from"./shared.js";const r=async({positionals:r,flags:o})=>{if(r[0]!==`contact-sheet`)return!1;if(r.length>2)throw new e(`INVALID_ARGS`,`record contact-sheet accepts one recording path: record contact-sheet <video.mp4> [--out <sheet.png>]`);let s=t(i(r[1])),c=typeof o.out==`string`?t(o.out):void 0,[{createAgentDevice:l,localCommandPolicy:u},{createLocalArtifactAdapter:d}]=await Promise.all([import(`./runtime10.js`),import(`./sdk-io.js`).then(e=>e.n)]),f=await l({backend:{platform:`ios`},artifacts:d(),sessions:{get:e=>({name:e}),set:()=>{}},policy:u()}).recording.contactSheet({video:{kind:`path`,path:s},...c?{out:{kind:`path`,path:c}}:{}});return await n(o,f,()=>a(f)),!0};function i(t){if(t)return t;throw new e(`INVALID_ARGS`,`record contact-sheet requires a recording path: record contact-sheet <video.mp4>`)}function a(e){let t=(e.durationMs/1e3).toFixed(e.durationMs%1e3==0?0:1),n=[e.path,`${e.cells.length} cells over ${t}s (${e.sampledFrameCount} sample times, ${e.decodedFrameCount} frames decoded)`];return e.warning?[...n,e.warning].join(`
|
|
2
|
+
`):n.join(`
|
|
3
|
+
`)}export{r as recordingCommand};
|