agent-device 0.21.18 → 0.21.20
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.18.apk → agent-device-android-ime-helper-0.21.20.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.20.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.18.manifest.json → agent-device-android-ime-helper-0.21.20.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.18.apk → agent-device-android-snapshot-helper-0.21.20.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.20.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.18.manifest.json → agent-device-android-snapshot-helper-0.21.20.manifest.json} +6 -6
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +12 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +1 -14
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +14 -16
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +40 -14
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotModels.swift +20 -5
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationProjection.swift +2 -15
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFold.swift +10 -25
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFoldProjection.swift +1 -18
- package/dist/src/adapter.js +1 -1
- package/dist/src/adb-executor.js +2 -2
- package/dist/src/adb-failure.js +2 -1
- package/dist/src/agent-browser-lifecycle.js +1 -1
- package/dist/src/agent-browser-process-record.js +1 -1
- package/dist/src/agent-browser-provider.js +1 -1
- package/dist/src/agent-browser-tool.js +1 -1
- package/dist/src/agent-device-client.js +2 -2
- package/dist/src/ai-sdk.js +1 -1
- package/dist/src/alert-runtime.js +1 -1
- package/dist/src/alert.js +1 -0
- package/dist/src/android-input-ownership.js +1 -1
- package/dist/src/android.js +1 -1
- package/dist/src/app-launch.js +2 -2
- package/dist/src/app-lifecycle.js +1 -1
- package/dist/src/app-log-runtime2.js +1 -1
- package/dist/src/app-resolution.js +2 -2
- package/dist/src/apple-runner-platform.js +1 -1
- package/dist/src/archive.js +2 -2
- package/dist/src/browser-launch.js +1 -1
- package/dist/src/cache.js +1 -1
- package/dist/src/catalog.js +1 -1
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +287 -301
- package/dist/src/cli-runner.js +1 -1
- package/dist/src/cli.js +4 -4
- package/dist/src/client-metro-companion.js +1 -1
- package/dist/src/client-metro.js +1 -1
- package/dist/src/client-types.d.ts +25 -6
- package/dist/src/{scroll-command.d.ts → cloud-artifacts.d.ts} +242 -238
- package/dist/src/command-metadata.js +1 -1
- package/dist/src/command-schema.js +3 -3
- package/dist/src/command-tools.js +2 -2
- package/dist/src/command.js +1 -1
- package/dist/src/config.js +1 -1
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/contracts.js +1 -1
- package/dist/src/daemon-client-lease-beat.js +1 -1
- package/dist/src/daemon-client-lifecycle.js +1 -1
- package/dist/src/daemon-client-transport.js +1 -1
- package/dist/src/daemon-policy-file.js +1 -1
- package/dist/src/daemon-registration.js +1 -1
- package/dist/src/debug-symbols-facade.js +3 -3
- package/dist/src/device-claim-inspection.js +1 -1
- package/dist/src/device-claim-rule.js +1 -1
- package/dist/src/device-inventory-context.js +1 -1
- package/dist/src/device-rotation.js +1 -1
- package/dist/src/device-session.js +1 -1
- package/dist/src/devicectl.js +1 -1
- package/dist/src/diagnostics.js +1 -1
- package/dist/src/diagnostics2.js +1 -1
- package/dist/src/display-inventory.js +1 -1
- package/dist/src/durable-resource.js +1 -1
- package/dist/src/engine-eval-script.js +1 -1
- package/dist/src/error.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/generic-settle.js +1 -1
- package/dist/src/gesture-runtime.js +1 -1
- package/dist/src/hdc.js +1 -1
- package/dist/src/helper.js +2 -2
- package/dist/src/host.js +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.js +1 -1
- package/dist/src/input-actions2.js +2 -2
- package/dist/src/install-source-network-transport.js +1 -1
- 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.js +5 -5
- package/dist/src/interactor2.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.js +1 -1
- package/dist/src/ios-snapshot-acquisition.js +1 -1
- package/dist/src/ios-snapshot-engine.js +1 -1
- package/dist/src/launch-confirmation.js +1 -0
- package/dist/src/lease.js +1 -1
- package/dist/src/limrun-runtime-dependencies.js +1 -1
- package/dist/src/limrun.d.ts +50 -42
- package/dist/src/local-interactor-operation-set.js +1 -1
- package/dist/src/mechanics.js +16 -17
- package/dist/src/mobile-snapshot-semantics.js +1 -1
- package/dist/src/observe-until.js +1 -0
- package/dist/src/overlay.js +2 -2
- package/dist/src/owner-identity.js +1 -1
- package/dist/src/parameterized-recorded-fill.js +1 -1
- package/dist/src/perf-facade.js +1 -1
- package/dist/src/perf-runtime-operation-builder.js +1 -1
- package/dist/src/perf-runtime-plan.js +1 -1
- package/dist/src/perf-target.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-android-adb-host.js +1 -1
- package/dist/src/platform-runtime-app-log-process.js +1 -1
- package/dist/src/platform-runtime-host.js +1 -1
- package/dist/src/platform-runtime-managed-owner.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-apple-simulator-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-process-host.js +1 -1
- package/dist/src/platform-runtime.js +1 -1
- package/dist/src/platform-runtime2.js +1 -1
- package/dist/src/png-worker-client.js +1 -1
- package/dist/src/provider-device-admission.js +1 -0
- package/dist/src/provider-session-ownership.js +1 -1
- package/dist/src/provider-webdriver.js +1 -1
- package/dist/src/proxy.js +1 -1
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/registry.js +52 -36
- package/dist/src/replay-divergence.js +1 -1
- 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 +3 -3
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-dev-tools-security.js +1 -1
- package/dist/src/runner-device-readiness.js +1 -1
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-error-classification.js +3 -3
- package/dist/src/runner-exchange.js +1 -1
- package/dist/src/runner-operations-facade.js +1 -1
- package/dist/src/runner-session-types.js +1 -1
- package/dist/src/runner-start-budget.js +1 -1
- package/dist/src/runner-startup-transport.js +1 -1
- package/dist/src/runner-xctestrun.js +1 -1
- package/dist/src/runner.js +1 -1
- package/dist/src/runtime-admission.js +1 -0
- package/dist/src/runtime.js +1 -1
- package/dist/src/runtime10.js +2 -2
- package/dist/src/runtime2.js +2 -2
- package/dist/src/runtime3.js +1 -1
- 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-resource-recovery.js +1 -1
- package/dist/src/screenshot-result.js +1 -1
- package/dist/src/screenshot-runtime.js +1 -1
- package/dist/src/screenshot3.js +1 -1
- package/dist/src/script.js +1 -1
- package/dist/src/scroll-gesture.js +1 -1
- package/dist/src/sdk-batch-runner.js +2 -2
- package/dist/src/sdk-batch.js +1 -1
- package/dist/src/sdk-contracts.d.ts +18 -2
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-selectors.d.ts +13 -4
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selection.js +0 -0
- package/dist/src/selector-pipeline-policy.js +1 -0
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/server.js +1 -1
- package/dist/src/session-runtime-admission.js +1 -1
- package/dist/src/session-snapshot.js +1 -1
- package/dist/src/session-store.js +3 -3
- package/dist/src/session2.js +5 -5
- package/dist/src/simulator-boot.js +1 -1
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-desktop-projection.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/target-evidence.js +1 -1
- package/dist/src/text-entry-focus.js +1 -1
- package/dist/src/tool-provider.js +3 -3
- package/dist/src/tool-provider2.js +1 -1
- package/dist/src/tool-provider3.js +1 -1
- package/dist/src/toolchain-probe.js +1 -1
- package/dist/src/touch-runtime.js +1 -1
- package/dist/src/touch-runtime2.js +1 -0
- package/dist/src/tree.js +1 -1
- package/dist/src/type-text-runtime.js +1 -1
- package/dist/src/update-check.js +1 -1
- package/dist/src/video.js +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.18.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.18.apk.sha256 +0 -1
- package/dist/src/runner-command-traits.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{q as e}from"../sdk-contracts.js";import{r as t,t as n}from"../png.js";import{n as r,r as i,t as a}from"../png-worker-contract.js";import{t as o}from"../png-crop-bytes.js";import{parentPort as s}from"node:worker_threads";async function c(e){switch(e.kind){case`decode`:{let t=n(a(e.png),e.label);return{kind:`decode`,width:t.width,height:t.height,data:t.data}}case`decode-image`:{let{decodeScreenshotImage:t}=await import(`../screenshot-image.js`),n=t(a(e.image),e.label);return{kind:`decode-image`,width:n.width,height:n.height,data:n.data}}case`encode`:{let n=new t.PNG({width:e.width,height:e.height});return n.data=a(e.data),{kind:`encode`,png:t.PNG.sync.write(n)}}case`crop`:return{kind:`crop`,png:o(a(e.png),e.box,e.label)};case`rgb-difference`:{let t=n(a(e.firstPng),e.label),i=n(a(e.secondPng),e.label);return{kind:`rgb-difference`,...r(t,i)}}case`diff-pixels`:return{kind:`diff-pixels`,...i(e)};case`jpeg-to-png`:{let{transcodeScreenshotToPng:t}=await import(`../screenshot-image.js`);return{kind:`jpeg-to-png`,png:t(a(e.image),e.label)}}}}function l(e){return e.buffer instanceof ArrayBuffer&&e.byteOffset===0&&e.byteLength===e.buffer.byteLength}function u(e){return d(e).filter(l).map(e=>e.buffer)}function d(e){switch(e.kind){case`decode`:case`decode-image`:return[e.data];case`encode`:return[e.png];case`crop`:return e.png===null?[]:[e.png];case`rgb-difference`:return[];case`diff-pixels`:return[e.diffData,e.diffMask];case`jpeg-to-png`:return[e.png]}}const f=s;f&&f.on(`message`,async t=>{let n;try{n={id:t.id,ok:!0,result:await c(t)}}catch(r){n={id:t.id,ok:!1,error:e(r)}}f.postMessage(n,n.ok?u(n.result):[])});export{u as resultTransferList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Lr as e,Yr as t}from"./sdk-batch.js";const n={"appium-source":{producer:`appium-source`,acquisitionDepth:{rawTraversal:{kind:`incomplete`},regularPresented:{kind:`incomplete`}},hittabilityEvidence:`unavailable`},"limrun-ios-tree":{producer:`limrun-ios-tree`,acquisitionDepth:{rawTraversal:{kind:`incomplete`},regularPresented:{kind:`incomplete`}},hittabilityEvidence:`unavailable`}},r={"apple-runner":`available`,"simulator-ax-bridge":`available`,"appium-source":`unavailable`,"limrun-ios-tree":`unavailable`};function i(e){return r[e]}function a(e,t){let n=[];return e.hittabilityEvidence===`unavailable`&&n.push({kind:`unavailable-fact`,fact:`hittability`}),(e.acquisitionDepth.rawTraversal.kind===`incomplete`||e.acquisitionDepth.regularPresented.kind===`incomplete`)&&n.push({kind:`unavailable-fact`,fact:`acquisition-depth`}),i(e.producer)===`unavailable`&&n.push({kind:`unavailable-fact`,fact:`truncation`}),t.kind===`missing`&&n.push({kind:`missing-viewport`,reason:t.reason}),Object.freeze(n)}function o(e){let t=n[e.producer];return{stage:`acquired`,acquisition:{producer:e.producer,intent:`full`,nodes:e.nodes,viewport:e.viewport,lineage:e.lineage,residue:a(t,e.viewport)}}}function s(e,n={}){let r=e.filter(c),i=[...r.length>0||n.fallbackToLargestRoot!==!0?r:e].sort(l)[0];if(i)return t(i.rect)?{kind:`reported`,rect:i.rect}:{kind:`missing`,reason:i.rectStatus===`invalid`||i.rectStatus===void 0&&i.rect!==void 0?`invalid`:`not-provided`}}function c(t){let n=e(t.type??``);return n===`application`||n===`window`}function l(e,t){return u(t.rectStatus)-u(e.rectStatus)||d(t.rect)-d(e.rect)}function u(e){return e===`reported`?2:+(e===`invalid`)}function d(e){return e&&t(e)?e.width*e.height:0}export{i as n,s as r,o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e}from"./sdk-contracts.js";import{Ir as t,Jr as n,Kr as r,Mr as i,Qr as a,Yr as o,Zr as s,qr as c}from"./sdk-batch.js";import{n as l,t as u}from"./scroll-indicator.js";import{a as d,i as f,o as p,r as m}from"./react-native-overlay.js";import{t as h}from"./rect-center.js";import{i as g,n as _,t as ee}from"./ios-snapshot-planning.js";import{_ as te,a as v,c as y,d as ne,f as b,g as x,h as re,i as S,l as ie,m as C,n as w,o as T,p as E,r as ae,t as D,u as oe}from"./tree.js";function se(e,t){let n=v(t.sourceNodesByIndex.values());for(let r of e)ce(r,t.sourceNodesByIndex,n)&&C(t.replacements,r,{type:`Cell`})}function ce(e,n,r){return!(t(e.type??``)!==`other`||e.enabled===!1||!e.rect||!de(e.label)||!T(e,n,ue)||!le(e)||oe(e.rect,r))}function le(e){return e.rect?e.rect.height>=44&&e.rect.height<=160&&e.rect.width>=120:!1}function ue(e){let n=t(e.type??``);return n===`scrollview`||n===`scrollarea`}function de(e){let t=e?.trim();return!(!t||/^(toolbar|window|application)$/i.test(t)||t.startsWith(`!,`)||/debugger|fast refresh/i.test(t))}function fe(e,t){let n=new Set;for(let r of e)pe(t.replacements.get(r.index)??r)&&me(r,t.sourceNodesByIndex,t,n);_e(e,t,n)}function pe(e){let t=e.label?.trim();return!!(t&&l(t))}function me(e,t,n,r){let i=!b(e.type)||n.isSuppressed(e),a=u(e.label?.trim()??``,e.value),o=a?ge(e,t):void 0;i&&n.suppressNode(e,o?[o]:[]),o&&a&&Te(n,o,e,a)&&r.add(o.index)}function O(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function he(e,t){return e.rect!=null&&t.rect!=null&&k(e.rect,t.rect)}function ge(e,t){if(b(e.type))return null;let n=O(e,t);for(;n&&!b(n.type);){let e=O(n,t);if(!e||!he(n,e))return null;n=e}return n??null}function _e(e,t,n){let r=new Map;for(let i of e){let e=r.get(i.parentIndex??-1),a=e?.clip,o=t.replacements.get(i.index)??i,s=we(o.rect,a),c=ve(o,a,s),l=ye(e,c,o);be(t,i,o,a,s,c,l),r.set(i.index,xe(i,o,a,s,l,n))}}function ve(e,t,r){return!!(t&&n(e.rect)&&!n(r))}function ye(e,t,n){return!!(e?.projectedOut||t&&Ce(n))}function be(e,t,n,r,i,a,o){o||a?e.suppressNode(t,[]):r&&i&&!k(n.rect,i)&&C(e.replacements,t,{rect:i})}function xe(e,t,n,r,i,a){return{projectedOut:i,...Se(e,t,n,r,a)?{clip:r}:n?{clip:n}:{}}}function Se(e,t,r,i,a){return!!(n(i)&&(a.has(e.index)||r!==void 0&&b(t.type)))}function Ce(e){return e.type?.trim().toLowerCase()===`cell`||b(e.type)}function we(e,t){if(!e||!t)return e;let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return{x:n,y:r,width:Math.max(0,i-n),height:Math.max(0,a-r)}}function k(e,t){return!!(e&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height)}function Te(e,t,n,r){let i=Ee((e.replacements.get(t.index)??t).rect,n.rect);return te(e.replacements,t,e=>({rect:i??e.rect,hiddenContentAbove:A(e.hiddenContentAbove,r.above),hiddenContentBelow:A(e.hiddenContentBelow,r.below)})),!!i}function A(e,t){return e===!0||t?!0:void 0}function Ee(e,t){if(!(!e||!t)&&!(t.height<=0||t.height>=e.height)&&!(t.y<e.y||t.y>e.y+e.height))return{...e,y:t.y,height:Math.min(t.height,e.y+e.height-t.y)}}function j(e,n){for(let r=0;r<e.length;r+=1){let i=e[r],a=i?.label?.trim();i&&a&&t(i.type??``)===`other`&&n(i,a,r)}}function De(e,t){j(e,(n,r,i)=>{if(!d(r)||!n.rect)return;let a=S(e,i,e=>!!e.rect&&p(e.label?.trim()??``));if(!a?.rect)return;let o=ke(n.rect,a.rect);if(!o)return;let s=Oe(e,i,o);C(t,n,{rect:s}),y(e,i,e=>{d(e.label?.trim()??``)&&C(t,e,{rect:s})})})}function Oe(e,t,n){let r=n;return y(e,t,e=>{let t=e.label?.trim()??``;!e.rect||!d(t)||a(n,e.rect)&&s(e.rect)<s(r)&&(r=e.rect)}),r}function ke(e,t){let n=e.x+e.width,r=t.x+t.width,i={x:t.x,y:e.y,width:n-t.x,height:e.height};if(t.x>e.x&&h(t,i))return{...e,width:t.x-e.x};let a={x:e.x,y:e.y,width:r-e.x,height:e.height};if(r<n&&h(t,a))return{...e,x:r,width:n-r}}function Ae(e,t){j(e,(n,r,i)=>{m(n)&&f(n,M(e,i))&&t.suppressNode(n,M(e,i))})}function M(e,t){let n=[];return y(e,t,e=>{n.push(e)}),n}function je(e,t){let n=v(e),r=n?n.y+n.height:null;if(r!==null)for(let n=0;n<e.length;n+=1){let i=e[n];!i||!Me(i,r)||(t.suppressNode(i,[]),Ne(i,t,r),y(e,n,e=>{t.suppressNode(e,[])}))}}function Me(e,n){return!e.rect||t(e.type??``)!==`keyboard`?!1:e.rect.y>=n}function Ne(e,t,n){let r=typeof e.parentIndex==`number`?t.sourceNodesByIndex.get(e.parentIndex):void 0;for(;r?.rect&&r.rect.y>=n;)t.suppressNode(r,[]),r=typeof r.parentIndex==`number`?t.sourceNodesByIndex.get(r.parentIndex):void 0}function Pe(e,n){for(let r=0;r<e.length;r+=1){let i=e[r];if(!i)continue;if(Fe(i)){N(e,r,i,n);continue}if(!Ie(i))continue;let a=S(e,r,e=>t(e.type??``)===`searchfield`&&e.label===`Search`);a&&(n.suppressNode(i,[a]),Le(i,a,n),N(e,r,a,n))}}function Fe(e){return t(e.type??``)===`searchfield`&&e.label===`Search`}function Ie(e){let n=t(e.type??``);return e.label===`Toolbar`&&(n===`toolbar`||n===`searchfield`)}function N(e,t,n,r){y(e,t,e=>{e.index!==n.index&&Re(e)&&r.suppressNode(e,[n])})}function Le(e,t,n){let r=e;for(;typeof r.parentIndex==`number`;){let e=n.sourceNodesByIndex.get(r.parentIndex);if(!e||e.label!==`Toolbar`)return;n.suppressNode(e,[t]),r=e}}function Re(e){let n=t(e.type??``);return n===`button`?!1:n===`image`||e.label===`Search`}function ze(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?.label?.trim();!r||t.isSuppressed(r)||!i||Be(e,n,r,i,t)}}function Be(e,n,r,i,a){let o=t(r.type??``);if(o===`statictext`||o===`link`){P(e,n,i,r,a);return}if(o!==`other`)return;let s=Ve(e,n,i);if(s){a.suppressNode(r,[s]);return}P(e,n,i,r,a)}function Ve(e,n,r){return S(e,n,e=>{let n=t(e.type??``);return(n===`link`||n===`searchfield`||b(e.type))&&e.label?.trim()===r})}function P(e,t,n,r,i){y(e,t,e=>{!i.semanticRepresentativeIndexes.has(e.index)&&ne(e,n)&&i.suppressNode(e,[r])})}function He(e,t){j(e,(n,r,i)=>{let a=S(e,i,e=>E(e)&&e.label?.trim()===r&&(h(e.rect,n.rect)||Ue(n,e)));a&&t.suppressNode(n,[a])})}function Ue(e,n){if(n.label?.trim()!==e.label?.trim())return!1;let r=t(n.type??``);return We(e,r)||r===`textfield`||Ge(e,r,n)}function We(e,t){let n=e.label?.trim();return t===`button`&&(n===`Dismiss`||n===`Back`)}function Ge(e,t,n){return t!==`button`||!e.rect||!n.rect?!1:e.rect.x===0&&e.rect.y===0&&e.rect.width>=300&&e.rect.height>=600&&n.rect.width<e.rect.width}function Ke(e,n){let r=D(e);for(let i of e){if(t(i.type??``)!==`other`||i.hittable===!0||i.label?.trim()||i.value?.trim()||!i.identifier?.trim())continue;let e=ae(i,r);(e.length!==0||i.hittable===!1)&&n.suppressNode(i,e)}}function qe(e,t){je(e,t),Ke(e,t),fe(e,t),Pe(e,t),He(e,t),De(e,t.replacements),Ae(e,t),ze(e,t)}function Je(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?Ye(e,n,r,t):void 0;!r?.rect||!i||Qe(e,n,r,i,t)}}function Ye(e,n,r,i){let a=r.label?.trim();if(t(r.type??``)!==`cell`||a&&!Xe(a,r.identifier)&&!l(a))return a;let o=w(e,n).find(Ze),s=o?.label?.trim();return!o||!s?a:(C(i.replacements,r,{label:s}),i.suppressNode(o,[r]),s)}function Xe(e,t){return t?.trim()===e&&/^[A-Z_$][A-Za-z0-9_$]*Cell$/.test(e)}function Ze(e){if(!e.label?.trim())return!1;let n=t(e.type??``);return n===`statictext`||n===`text`||n===`textview`}function Qe(e,n,r,i,a){let o=t(r.type??``);if(o===`button`){F(w(e,n),i,a,r);return}if(o!==`cell`)return;let s=w(e,n);$e(s,r,i,a)||et(s,r,i,a)}function $e(e,t,n,r){let i=e.find(e=>nt(e,t,n));if(!i)return!1;let a=e.find(e=>I(e,t,n)),o=i.identifier?void 0:a?.identifier??t.identifier;return o&&C(r.replacements,i,{identifier:o}),r.suppressNode(t,[i]),tt(e,t,n,i,r),!0}function et(e,t,n,r){let i=e.find(e=>I(e,t,n));if(!i){e.some(ie)&&F(e,n,r,t);return}!t.identifier&&i.identifier&&C(r.replacements,t,{identifier:i.identifier}),r.suppressNode(i,[t]),F(e.filter(e=>e.index!==i.index),n,r,t)}function tt(e,t,n,r,i){for(let a of e)a.index!==r.index&&(I(a,t,n)||L(a,t)||rt(a,r)||x(a,n))&&i.suppressNode(a,[r])}function F(e,t,n,r){for(let i of e)(x(i,t)||r&&L(i,r))&&n.suppressNode(i,r?[r]:[])}function I(e,n,r){if(t(e.type??``)!==`button`)return!1;let i=n.identifier?.trim(),a=e.identifier?.trim();return i&&a&&i===a?!0:e.label?.trim()===r&&h(e.rect,n.rect)}function L(e,n){return t(e.type??``)===`button`&&!e.label?.trim()&&!e.value?.trim()&&h(e.rect,n.rect)}function nt(e,n,r){if(t(e.type??``)!==`switch`)return!1;let i=n.identifier?.trim(),a=e.identifier?.trim();return i&&a&&i===a?!0:e.label?.trim()===r}function rt(e,n){if(t(e.type??``)!==`switch`||e.index===n.index)return!1;let r=e.label?.trim();return r===n.value?.trim()||r===`0`||r===`1`}const R=1.15;function it(e,t,n){let r=new Map(e.map((e,t)=>[e.index,t]));for(let[i,a]of e.entries()){let s=at(e,r,t,a,n);if(!s)continue;B(e,i,n);let c=V(s.shelfRect,2);for(let t of s.intermediateSiblings){if(mt(t)||!t.rect||!o(t.rect,c))continue;let i=r.get(t.index);i!==void 0&&B(e,i,n)}}}function at(e,t,n,r,i){let a=ot(r,n,i.sourceNodesByIndex);if(!a)return;let o=lt(e,t,a.siblings,a.position,a.parent);if(!(o<0))return{shelfRect:a.rect,intermediateSiblings:a.siblings.slice(a.position+1,o)}}function ot(e,t,n){let r=ut(e,z(t,e.index));if(!r)return;let i=ct(e,n);if(!i||!i.rect)return;let a=z(t,i.index),o=a.findIndex(t=>t.index===e.index);if(st(a,o,e,r))return{rect:r.rect,parent:i,siblings:a,position:o}}function z(e,t){return e.get(t)??[]}function st(e,t,n,r){if(t<1)return!1;let i=dt(e,t,n);return i?!r.childActionsPresented||!ft(i,r.actionButtons):!1}function ct(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function lt(e,t,n,r,i){return n.findIndex((n,a)=>a>r&&pt(e,t.get(n.index),n,i))}function ut(e,n){if(!b(e.type)||!e.rect)return;let r=e.rect,i=n.filter(e=>t(e.type??``)===`button`&&e.rect);if(i.length===0&&e.hiddenContentBelow===!0)return{rect:r,childActionsPresented:!1,actionButtons:i};if(i.length<3)return;let o=i.map(e=>e.rect.x+e.rect.width/2);if(o.every((e,t)=>t===0||e>o[t-1]))return{rect:r,childActionsPresented:i.some(e=>a(r,e.rect)),actionButtons:i}}function dt(e,t,n){if(!(!n.rect||t<1))for(let r=t-1;r>=0;--r){let t=e[r];if(!(!t.rect||!E(t))&&t.rect.x+t.rect.width/2<n.rect.x&&ht(t.rect,V(n.rect,2)))return t}}function ft(e,t){if(!e.rect||t.length===0)return!1;let n=Math.max(...t.map(e=>e.rect?.width??0)),r=Math.max(...t.map(e=>e.rect?.height??0));return e.rect.width>n*R||e.rect.height>r*R}function pt(e,n,r,i){return n!==void 0&&t(r.type??``)===`other`&&h(r.rect,i.rect)&&!!S(e,n,E)}function B(e,t,n){let r=e[t];if(r){n.suppressNode(r,[]);for(let r of w(e,t))n.suppressNode(r,[])}}function mt(e){let n=t(e.type??``);return n===`textfield`||n===`securetextfield`||n===`searchfield`||n===`textview`}function V(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function ht(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function gt(e,t){let n=D(e);it(e,n,t),_t(e,n,t)}function _t(e,n,r){for(let i of e){if(t(i.type??``)!==`navigationbar`||!i.rect)continue;let e=n.get(i.index)??[],a=e.flatMap(t=>vt(t,e,i.rect));if(a.length!==1)continue;let{field:o,title:s,image:c,label:l}=a[0];C(r.replacements,o,{type:`Button`,label:l,enabled:!0,hittable:void 0,rect:Ct([c.rect,o.rect,s.rect])}),r.semanticRepresentativeIndexes.add(o.index),r.suppressNode(s,[o]),r.suppressNode(c,[o])}}function vt(e,t,n){let r=i(e);if(!yt(e,r))return[];let a=H(t,e=>bt(e,r)),o=H(t,xt);return a?.rect&&o?.rect&&St(o.rect,e.rect,a.rect,n)?[{field:e,title:a,image:o,label:r}]:[]}function yt(e,n){return t(e.type??``)===`textfield`&&e.enabled===!1&&!!e.rect&&!!n&&e.value?.trim()===n}function bt(e,n){return t(e.type??``)===`statictext`&&e.label?.trim()===n&&!!e.rect}function xt(e){return t(e.type??``)===`image`&&!!e.identifier?.trim()&&!!e.rect}function H(e,t){let n=e.filter(t);return n.length===1?n[0]:void 0}function St(e,t,n,r){let i=t.x-(e.x+e.width),o=n.x-(t.x+t.width);return a(r,e)&&a(r,t)&&a(r,n)&&i>=0&&i<=12&&o>=0&&o<=12&&U(e,t)&&U(t,n)}function U(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function Ct(e){let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.width)),i=Math.max(...e.map(e=>e.y+e.height));return{x:t,y:n,width:r-t,height:i-n}}function wt(e,n){let r=D(e);for(let i of e){if(t(i.type??``)===`element(58)`){C(n.replacements,i,{type:`WebView`});continue}let e=Tt(i,n.sourceNodesByIndex,r);if(e?.kind===`suppress`){n.suppressNode(i,[]);continue}e&&(C(n.replacements,i,{type:e.type,...e.type===`Heading`?{value:void 0}:{}}),n.semanticRepresentativeIndexes.add(i.index))}}function Tt(e,n,r){if(t(e.type??``)!==`other`)return null;let i=T(e,n,Ot),a=e.label?.trim();return!i||!a?null:Dt(e,i,a)?{kind:`suppress`}:Et(e,a,r)?{kind:`semantic`,type:W(e.value)?`Heading`:`StaticText`}:null}function Et(e,n,r){let i=r.get(e.index);if(i?.length!==1)return!1;let a=i[0];return t(a.type??``)===`statictext`&&a.label?.trim()===n&&!r.has(a.index)}function Dt(e,t,n){return e.parentIndex===t.index&&t.label?.trim()===n&&!W(e.value)}function Ot(e){let n=t(e.type??``);return n===`webview`||n===`element(58)`}function W(e){return/^[1-6]$/.test(e?.trim()??``)}const kt=[wt,gt,se,Je,qe];function G(e){if(e.length===0)return{nodes:e,presentedIndexesBySourceIndex:new Map};let t=new Map,n=new Map,r=new Set,i=new Map(e.map(e=>[e.index,e])),a=new Set,o={replacements:t,semanticRepresentativeIndexes:r,sourceNodesByIndex:i,isSuppressed:e=>a.has(e.index),suppressNode(e,t){if(a.add(e.index),t.length===0)return;let r=n.get(e.index)??new Set;for(let e of t)r.add(e.index);n.set(e.index,r)}};for(let t of kt)t(e,o);if(a.size===0&&t.size===0)return{nodes:e,presentedIndexesBySourceIndex:new Map(e.map(e=>[e.index,[e.index]]))};let s=e.filter(e=>!a.has(e.index)).map(e=>t.get(e.index)??e),c=re(s,a,e),l=new Map(s.map((e,t)=>[e.index,c[t].index]));return{nodes:c,presentedIndexesBySourceIndex:new Map(e.map(e=>[e.index,At(e.index,l,n)]))}}function At(e,t,n,r=new Set){let i=t.get(e);if(i!==void 0)return[i];if(r.has(e))return[];r.add(e);let a=new Set;for(let i of n.get(e)??[])for(let e of At(i,t,n,r))a.add(e);return[...a].sort((e,t)=>e-t)}var K=class extends Error{code=`IOS_SNAPSHOT_ENGINE_FAILED`;reason;details;constructor(e,t,n={}){super(t),this.name=`IosSnapshotEngineError`,this.reason=e,this.details=n}};function jt(e){return{reason:e.reason,...e.details}}function q(e){let t=new Map;for(let[n,r]of e.entries()){if(!Number.isInteger(r.index)||r.index<0||t.has(r.index))throw new K(`malformed-graph`,`iOS snapshot graph contains a duplicate or invalid node index`,{index:r.index});if(t.set(r.index,n),r.depth!==void 0&&(!Number.isInteger(r.depth)||r.depth<0))throw new K(`malformed-graph`,`iOS snapshot graph contains an invalid node depth`,{index:r.index,field:`depth`})}for(let[n,r]of e.entries()){if(r.parentIndex===void 0)continue;let e=t.get(r.parentIndex);if(e===void 0||e>=n)throw new K(`malformed-graph`,`iOS snapshot graph parent must precede its child`,{index:r.index,parentIndex:r.parentIndex})}}const J=new Set([`collectionview`,`scrollview`,`table`]),Mt=new Set([`application`,`window`]);function Nt(){return{projectedOut:!1}}function Pt(e,r,i,a,o,s){let c=s===`cursor-projected`?r.ancestorClip:void 0,l=Ft(e.rect,i,c),u=n(Y(e.rect)),d=n(l),f=t(e.type??``),p=It(s,r.projectedOut,u,d,f,o),m=Ut(e,Lt(s,r.projectedOut,u,d)&&!Rt(e,u,s),a,s),h=Ht(f,m,d,o),g=Bt(s,r.projectedOut,u,d,e);return{isIncluded:m,descendants:zt(s,p,c,l,h),effectiveRect:l,...g?{hiddenContentFrame:g}:{},establishesScrollAnchor:h}}function Ft(e,t,n){let r=Y(e);if(!r)return;let i=qt(r,t);return n&&(i=qt(i,n)),i}function It(e,t,n,r,i,a){return e===`plain-viewport`?!r:t||n&&!r&&Vt(i,a)}function Lt(e,t,n,r){return e===`plain-viewport`?r:!t&&(!n||r)}function Rt(e,t,n){return n!==`cursor-projected`||e.parentIndex===void 0||Wt(e)||!t?!1:Gt(e.rect)<=1||Kt(e.rect)<=1}function zt(e,t,n,r,i){return{projectedOut:t,...e===`cursor-projected`&&i?{ancestorClip:r}:{ancestorClip:n}}}function Bt(e,t,n,r,i){if(!(e!==`cursor-projected`||t||!n||r))return Y(i.rect)}function Vt(e,t){return t&&(e===`cell`||J.has(e))}function Ht(e,t,n,r){return t&&n&&r&&J.has(e)}function Ut(e,n,r,i){if(e.parentIndex===void 0)return!0;let a=t(e.type??``);return i===`plain-viewport`&&r&&!n&&a!==`application`?!1:Mt.has(a)||n}function Wt(e){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.trim().length>0)}function Y(e){if(e&&[e.x,e.y,e.width,e.height].every(Number.isFinite)&&!(e.width<0||e.height<0))return{...e,width:Math.max(0,e.width),height:Math.max(0,e.height)}}function Gt(e){return Y(e)?.width??0}function Kt(e){return Y(e)?.height??0}function qt(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return i<=n||a<=r?{x:e.x,y:e.y,width:0,height:0}:{x:i>n?n:e.x,y:a>r?r:e.y,width:i-n,height:a-r}}function Jt(e){let t=D(e),n=new Set;for(let e of t.values()){let r=Yt(e,t);if(r){for(let i of e.slice(0,-1))if(Xt(r,i)){n.add(i.index);for(let e of ae(i,t))n.add(e.index)}}}return n}function Yt(e,t){let r=e.at(-1);if(!r||!Zt(r))return;let i=(t.get(r.index)??[]).find(Qt);if(!(i?.userInteractionEnabled!==!0||!n(i.rect)))return{container:r,dimmingRect:i.rect}}function Xt(e,t){return Zt(t)&&n(t.rect)&&a(e.dimmingRect,t.rect)}function Zt(e){return $t(e,`uitransitionview`)}function Qt(e){return $t(e,`uidimmingview`)}function $t(e,n){return t(e.role??``)===n}function en(e,t,n,r,i={}){q(e);let a=Jt(e),o=e.filter(e=>!a.has(e.index)),s=tn(o),c=new Map,l=[],u=new Map,d=0;for(let e of o){let a=nn(e,c,()=>{d+=1}),o=a?.traversal??Nt(),f=r===`cursor-projected`?a?.anchor:void 0,p=Pt(e,o,t,n,s.has(e.index),r);rn(p,f,u);let m=an(e,p,a,l,t,i),h=sn(p,f,m.keptIndex);c.set(e.index,{traversal:p.descendants,anchor:h,keptIndex:m.keptIndex,keptDepth:m.keptDepth})}let f=ln(u,l);return{nodes:f,stats:{presentedNodeCount:f.length,sourceNodeCount:e.length,parentClipLookups:d,modalContainedNodeCount:a.size}}}function tn(e){let t=new Set;for(let n of e)n.parentIndex!==void 0&&t.add(n.parentIndex);return t}function nn(e,t,n){if(e.parentIndex!==void 0)return n(),t.get(e.parentIndex)}function rn(e,t,n){e.hiddenContentFrame&&t&&cn(e.hiddenContentFrame,t,n)}function an(e,t,n,r,i,a){let o=n?.keptIndex,s=n?.keptDepth??-1;if(!t.isIncluded)return{keptIndex:o,keptDepth:s};let c=r.length;s+=1;let{hittable:l,...u}=e;return r.push({raw:{...u,index:c,depth:s,parentIndex:o,...on(l,e.parentIndex!==void 0,t.effectiveRect,e.enabled!==!1,i,a)},sourceIndex:e.index,...t.effectiveRect?{effectiveRect:t.effectiveRect}:{}}),o=c,{keptIndex:o,keptDepth:s}}function on(e,t,n,r,i,a){return a.hittabilityAvailable===!1?e===!1||!r?{hittable:!1}:{}:{hittable:t&&e===!0&&c(r,n,i)}}function sn(e,t,n){return e.establishesScrollAnchor&&n!==void 0&&e.effectiveRect?{index:n,rect:e.effectiveRect}:t}function cn(e,t,n){let r=n.get(t.index)??{above:!1,below:!1};e.y+e.height<=t.rect.y?r.above=!0:e.y>=t.rect.y+t.rect.height&&(r.below=!0),n.set(t.index,r)}function ln(e,t){return t.map(t=>{let n=e.get(t.raw.index);if(!n)return t;let r=t.raw;return{...t,raw:{...r,hiddenContentAbove:r.hiddenContentAbove===!0||n.above?!0:void 0,hiddenContentBelow:r.hiddenContentBelow===!0||n.below?!0:void 0}}})}const un=new Set([`collectionview`,`scrollview`,`table`]);function dn(e){return fn(e.viewport)}function fn(e){if(e.kind===`missing`)throw new K(e.reason===`invalid`?`invalid-viewport`:`missing-viewport`,`regular iOS snapshot presentation requires a valid viewport`,{field:`viewport`});if(!n(e.rect))throw new K(`invalid-viewport`,`regular iOS snapshot presentation requires a positive finite viewport`,{field:`viewport`});return e.rect}function pn(e,t,r,i=!0){q(e);let a=new Map,o=0;for(let s of e){let e=mn(s,a,t,()=>{o+=1}),c=bn(s.rect);if(hn(s,i),!c||!n(c)){gn(s,c),a.set(s.index,e);continue}_n(s,c,e),vn(s,c,t),a.set(s.index,yn(s,c,e,r))}return{parentClipLookups:o}}function mn(e,t,n,r){if(e.parentIndex===void 0)return n;r();let i=t.get(e.parentIndex);if(!i)throw new K(`invalid-presented-payload`,`regular iOS snapshot payload refers to a parent outside the payload`,{index:e.index,parentIndex:e.parentIndex});return i}function hn(e,t){if(!(e.hittable!==!0||t))throw new K(`invalid-presented-payload`,`iOS snapshot payload marked a node actionable without hittability evidence`,{index:e.index})}function gn(e,t){if(e.hittable===!0)throw new K(`regular-degenerate-actionable-node`,`regular iOS snapshot node with a missing or degenerate frame is actionable`,{index:e.index,frame:t??e.rect})}function _n(e,t,n){if(!xn(t,n))throw new K(`regular-node-outside-cumulative-clip`,`regular iOS snapshot node escaped its cumulative clip`,{index:e.index,frame:t,clip:n})}function vn(e,t,n){if(!(e.hittable!==!0||e.enabled!==!1&&r(n,t.x+t.width/2,t.y+t.height/2)))throw new K(`invalid-presented-payload`,`regular iOS snapshot payload marked a disabled or off-viewport node actionable`,{index:e.index,frame:t})}function yn(e,n,r,i){return i===`cursor-projected`&&un.has(t(e.type??``))?n:r}function X(e,t,n,r,i=!0){if(t===`raw`)return q(e),{parentClipLookups:0};if(!n)throw new K(`missing-viewport`,`regular iOS snapshot payload cannot be validated without a viewport`,{field:`viewport`});try{return pn(e,n,r,i)}catch(e){throw e instanceof K&&e.code===`IOS_SNAPSHOT_ENGINE_FAILED`&&e.reason===`malformed-graph`?new K(`invalid-presented-payload`,e.message,e.details):e}}function bn(e){if(!(!e||![e.x,e.y,e.width,e.height].every(Number.isFinite))&&!(e.width<0||e.height<0))return{...e,width:Math.max(0,e.width),height:Math.max(0,e.height)}}function xn(e,t){let n=1e-4;return a({x:t.x-n,y:t.y-n,width:t.width+n*2,height:t.height+n*2},e)}const Sn=new Set([`button`,`cell`,`checkbox`,`collectionview`,`link`,`menuitem`,`picker`,`searchfield`,`securetextfield`,`segmentedcontrol`,`slider`,`scrollview`,`stepper`,`switch`,`tabbar`,`table`,`textfield`,`textview`,`webview`]);function Cn(e){let t=Fn(e.nodes),n=Tn(e,t);return e.projection===`raw`?En(n,e.depth,t):Dn(n,e.depth)}function Z(e){let t=Fn(e.nodes);return e.projection===`raw`?En(e.nodes,e.depth,t):Dn(e.nodes,e.depth)}function wn(e){return e.parentIndex===void 0||Sn.has(t(e.type??``))||In(e)}function Tn(e,t){let n=e.scope?.trim().toLowerCase();if(!n)return[...e.nodes];for(let r=0;r<e.nodes.length;r+=1){let i=e.nodes[r];if(!i||!Nn(i.raw,n))continue;let a=Pn(e.nodes,r,t);if(!(e.projection===`raw`||a.some(t=>wn(e.nodes[t].raw))))continue;let o=a.map(t=>e.nodes[t]);return Mn(e.projection===`raw`&&e.depth!==null?o.filter(n=>Q(n,t)-Q(i,t)<=e.depth):o,Q(i,t),t)}return[]}function En(e,t,n){let r=t===null?[...e]:e.filter(e=>Q(e,n)<=t);return{nodes:r.map(e=>({...e.raw,rect:e.raw.rect})),sourceIndexes:r.map(e=>e.sourceIndex)}}function Dn(e,t){let n=[],r=[],i=new Map;for(let a of e){let e=On(a,i),o=kn(a,e,t,n.length);if(!o){jn(a,e,i);continue}n.push(o),r.push(a.sourceIndex),i.set(a.raw.index,o)}return{nodes:n,sourceIndexes:r}}function On(e,t){return e.raw.parentIndex===void 0?void 0:t.get(e.raw.parentIndex)}function kn(e,t,n,r){if(!wn(e.raw))return;let i=t?(t.depth??0)+1:0;if(n!==null&&i>n)return;let a=An(e);return{...e.raw,index:r,depth:i,parentIndex:t?.index,...e.effectiveRect?{rect:e.effectiveRect}:{rect:void 0},...a===void 0?{}:{hittable:a}}}function An(e){if(e.raw.hittable!==void 0)return!!(e.raw.hittable===!0&&e.effectiveRect&&e.effectiveRect.width>0&&e.effectiveRect.height>0)}function jn(e,t,n){t&&n.set(e.raw.index,t)}function Mn(e,t,n){let r=new Map(e.map((e,t)=>[e.raw.index,t]));return e.map((e,i)=>({...e,raw:{...e.raw,index:i,depth:Math.max(0,Q(e,n)-t),parentIndex:e.raw.parentIndex===void 0?void 0:r.get(e.raw.parentIndex)}}))}function Nn(e,t){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.toLowerCase().includes(t))}function Pn(e,t,n){let r=Q(e[t],n),i=[];for(let a=t;a<e.length&&!(a>t&&Q(e[a],n)<=r);a+=1)i.push(a);return i}function Q(e,t){return Math.max(0,e.raw.depth??t?.get(e.raw.index)??0)}function Fn(e){let t=new Map;for(let n of e){let e=(n.raw.parentIndex===void 0?-1:t.get(n.raw.parentIndex)??-1)+1;t.set(n.raw.index,n.raw.depth===void 0?e:Math.max(0,n.raw.depth))}return t}function In(e){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.trim().length>0)}function Ln(e,t,n=`cursor-projected`){Rn(e,t);let r=e.validation.presentationKey.projection,i=r===`regular`?fn(e.validation.viewport):void 0,a=e.validation.hittability.kind===`available`,o=zn(e,r,i,n,a),s=Bn(e.presentation.payload.nodes,r,t),c=Vn(s.nodes,r,i,n,a,o);return{nodes:s.nodes,...e.presentation.qualityPayload?{qualityNodes:[...e.presentation.qualityPayload.nodes]}:{},presentedIndexesBySourceIndex:s.presentedIndexesBySourceIndex,stats:{presentedNodeCount:s.nodes.length,sourceNodeCount:e.presentation.payload.nodes.length,parentClipLookups:c.parentClipLookups,modalContainedNodeCount:0}}}function Rn(e,t){if(!Hn(_(t),e.validation.presentationKey))throw new K(`projection-mismatch`,`presented iOS snapshot does not match the requested presentation key`,{projection:e.validation.presentationKey.projection});if(e.presentation.intent!==t.acquisitionIntent)throw new K(`projection-mismatch`,`presented iOS snapshot does not match the requested acquisition intent`,{field:`acquisitionIntent`})}function zn(e,t,n,r,i){let a=X(e.presentation.payload.nodes,t,n,r,i);if(e.presentation.qualityPayload)try{X(e.presentation.qualityPayload.nodes,t,n,r,i)}catch(e){throw e instanceof K?new K(`invalid-quality-payload`,e.message,e.details):e}return a}function Bn(e,t,n){return t===`regular`&&n.interactiveOnly?G([...e]):{nodes:[...e],presentedIndexesBySourceIndex:Un(e)}}function Vn(e,t,n,r,i,a){return t!==`regular`||!n?a:X(e,t,n,r,i)}function Hn(e,t){return e.projection===t.projection&&e.interactiveOnly===t.interactiveOnly&&e.depth===t.depth&&e.scope===t.scope&&e.customActions===t.customActions}function Un(e){return new Map(e.map(e=>[e.index,[e.index]]))}function Wn(t,n,r={}){let i=Gn(t,n,r),a=t.stage===`presented`?t.validation.presentationKey:_(n),o=t.stage===`acquired`?t.acquisition.truncated:t.presentation.payload.truncated;return{payload:{nodes:e(i.nodes),...o===void 0?{}:{truncated:o}},presentationKey:a,comparisonIdentity:ee(t,n),residue:t.stage===`acquired`?[...t.acquisition.residue]:[...t.validation.residue]}}function Gn(e,t,n={}){let r=n.foldPolicy??`cursor-projected`;return e.stage===`acquired`?Kn(e.acquisition,t,r):Ln(e,t,r)}function Kn(e,t,n){if(Jn(e,g(t)),t.projection===`raw`){q(e.nodes);let r=e.nodes.map(e=>({raw:e,sourceIndex:e.index})),i=Cn({nodes:r,projection:`raw`,scope:t.scope,depth:t.depth,foldPolicy:n}),a=t.scope===null?void 0:Z({nodes:r,projection:`raw`,depth:null,foldPolicy:n}).nodes;return{nodes:i.nodes,...a?{qualityNodes:a}:{},presentedIndexesBySourceIndex:$(e.nodes,i.nodes,i.sourceIndexes,Yn(i.nodes)),stats:{presentedNodeCount:i.nodes.length,sourceNodeCount:e.nodes.length,parentClipLookups:0,modalContainedNodeCount:0}}}let r=dn(e),i=!qn(e.residue),a=en(e.nodes,r,t.interactiveOnly,n,{hittabilityAvailable:i}),o=Cn({nodes:a.nodes,projection:`regular`,scope:t.scope,depth:t.depth,foldPolicy:n}),s=t.interactiveOnly?G(o.nodes):{nodes:o.nodes,presentedIndexesBySourceIndex:Yn(o.nodes)},c=X(s.nodes,`regular`,r,n,i),l=t.scope===null?void 0:Z({nodes:a.nodes,projection:`regular`,depth:null,foldPolicy:n}).nodes;return{nodes:s.nodes,...l?{qualityNodes:l}:{},presentedIndexesBySourceIndex:$(e.nodes,o.nodes,o.sourceIndexes,s.presentedIndexesBySourceIndex),stats:{presentedNodeCount:s.nodes.length,sourceNodeCount:e.nodes.length,parentClipLookups:a.stats.parentClipLookups+c.parentClipLookups,modalContainedNodeCount:a.stats.modalContainedNodeCount}}}function qn(e){return e.some(e=>e.kind===`unavailable-fact`&&e.fact===`hittability`)}function Jn(e,t){let n=e.hint;if(n.projection!==t.projection||n.rawTraversalDepth!==t.rawTraversalDepth||n.regularPresentedDepth!==t.regularPresentedDepth||n.interactiveOnly!==t.interactiveOnly||n.customActions!==t.customActions||n.acquisitionIntent!==t.acquisitionIntent)throw new K(`projection-mismatch`,`acquired iOS snapshot does not match the requested capture hint`,{projection:n.projection})}function Yn(e){return new Map(e.map(e=>[e.index,[e.index]]))}function $(e,t,n,r){let i=new Map(t.map((e,t)=>[e.index,n[t]])),a=new Map(e.map(e=>[e.index,[]]));for(let[e,t]of r){let n=i.get(e);n!==void 0&&a.set(n,t)}return a}export{G as a,jt as i,Ln as n,K as r,Wn as t};
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{$r as t,Jr as n,Lr as r,Nr as i,Qr as a,Xr as o,Yr as s,qr as c}from"./sdk-batch.js";import{n as l,t as u}from"./scroll-indicator.js";import{a as d,i as f,o as p,r as m}from"./react-native-overlay.js";import{t as h}from"./rect-center.js";import{i as g,n as _,t as ee}from"./ios-snapshot-planning.js";import{_ as te,a as v,c as y,d as ne,f as b,g as x,h as re,i as S,l as ie,m as C,n as w,o as T,p as E,r as ae,t as D,u as oe}from"./tree.js";function se(e,t){let n=v(t.sourceNodesByIndex.values());for(let r of e)ce(r,t.sourceNodesByIndex,n)&&C(t.replacements,r,{type:`Cell`})}function ce(e,t,n){return!(r(e.type??``)!==`other`||e.enabled===!1||!e.rect||!de(e.label)||!T(e,t,ue)||!le(e)||oe(e.rect,n))}function le(e){return e.rect?e.rect.height>=44&&e.rect.height<=160&&e.rect.width>=120:!1}function ue(e){let t=r(e.type??``);return t===`scrollview`||t===`scrollarea`}function de(e){let t=e?.trim();return!(!t||/^(toolbar|window|application)$/i.test(t)||t.startsWith(`!,`)||/debugger|fast refresh/i.test(t))}function fe(e,t){let n=new Set;for(let r of e)pe(t.replacements.get(r.index)??r)&&me(r,t.sourceNodesByIndex,t,n);_e(e,t,n)}function pe(e){let t=e.label?.trim();return!!(t&&l(t))}function me(e,t,n,r){let i=!b(e.type)||n.isSuppressed(e),a=u(e.label?.trim()??``,e.value),o=a?ge(e,t):void 0;i&&n.suppressNode(e,o?[o]:[]),o&&a&&Te(n,o,e,a)&&r.add(o.index)}function O(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function he(e,t){return e.rect!=null&&t.rect!=null&&k(e.rect,t.rect)}function ge(e,t){if(b(e.type))return null;let n=O(e,t);for(;n&&!b(n.type);){let e=O(n,t);if(!e||!he(n,e))return null;n=e}return n??null}function _e(e,t,n){let r=new Map;for(let i of e){let e=r.get(i.parentIndex??-1),a=e?.clip,o=t.replacements.get(i.index)??i,s=we(o.rect,a),c=ve(o,a,s),l=ye(e,c,o);be(t,i,o,a,s,c,l),r.set(i.index,xe(i,o,a,s,l,n))}}function ve(e,t,n){return!!(t&&s(e.rect)&&!s(n))}function ye(e,t,n){return!!(e?.projectedOut||t&&Ce(n))}function be(e,t,n,r,i,a,o){o||a?e.suppressNode(t,[]):r&&i&&!k(n.rect,i)&&C(e.replacements,t,{rect:i})}function xe(e,t,n,r,i,a){return{projectedOut:i,...Se(e,t,n,r,a)?{clip:r}:n?{clip:n}:{}}}function Se(e,t,n,r,i){return!!(s(r)&&(i.has(e.index)||n!==void 0&&b(t.type)))}function Ce(e){return e.type?.trim().toLowerCase()===`cell`||b(e.type)}function we(e,t){if(!e||!t)return e;let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return{x:n,y:r,width:Math.max(0,i-n),height:Math.max(0,a-r)}}function k(e,t){return!!(e&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height)}function Te(e,t,n,r){let i=Ee((e.replacements.get(t.index)??t).rect,n.rect);return te(e.replacements,t,e=>({rect:i??e.rect,hiddenContentAbove:A(e.hiddenContentAbove,r.above),hiddenContentBelow:A(e.hiddenContentBelow,r.below)})),!!i}function A(e,t){return e===!0||t?!0:void 0}function Ee(e,t){if(!(!e||!t)&&!(t.height<=0||t.height>=e.height)&&!(t.y<e.y||t.y>e.y+e.height))return{...e,y:t.y,height:Math.min(t.height,e.y+e.height-t.y)}}function j(e,t){for(let n=0;n<e.length;n+=1){let i=e[n],a=i?.label?.trim();i&&a&&r(i.type??``)===`other`&&t(i,a,n)}}function De(e,t){j(e,(n,r,i)=>{if(!d(r)||!n.rect)return;let a=S(e,i,e=>!!e.rect&&p(e.label?.trim()??``));if(!a?.rect)return;let o=ke(n.rect,a.rect);if(!o)return;let s=Oe(e,i,o);C(t,n,{rect:s}),y(e,i,e=>{d(e.label?.trim()??``)&&C(t,e,{rect:s})})})}function Oe(e,n,r){let i=r;return y(e,n,e=>{let n=e.label?.trim()??``;!e.rect||!d(n)||t(r,e.rect)&&a(e.rect)<a(i)&&(i=e.rect)}),i}function ke(e,t){let n=e.x+e.width,r=t.x+t.width,i={x:t.x,y:e.y,width:n-t.x,height:e.height};if(t.x>e.x&&h(t,i))return{...e,width:t.x-e.x};let a={x:e.x,y:e.y,width:r-e.x,height:e.height};if(r<n&&h(t,a))return{...e,x:r,width:n-r}}function Ae(e,t){j(e,(n,r,i)=>{m(n)&&f(n,M(e,i))&&t.suppressNode(n,M(e,i))})}function M(e,t){let n=[];return y(e,t,e=>{n.push(e)}),n}function je(e,t){let n=v(e),r=n?n.y+n.height:null;if(r!==null)for(let n=0;n<e.length;n+=1){let i=e[n];!i||!Me(i,r)||(t.suppressNode(i,[]),Ne(i,t,r),y(e,n,e=>{t.suppressNode(e,[])}))}}function Me(e,t){return!e.rect||r(e.type??``)!==`keyboard`?!1:e.rect.y>=t}function Ne(e,t,n){let r=typeof e.parentIndex==`number`?t.sourceNodesByIndex.get(e.parentIndex):void 0;for(;r?.rect&&r.rect.y>=n;)t.suppressNode(r,[]),r=typeof r.parentIndex==`number`?t.sourceNodesByIndex.get(r.parentIndex):void 0}function Pe(e,t){for(let n=0;n<e.length;n+=1){let i=e[n];if(!i)continue;if(Fe(i)){N(e,n,i,t);continue}if(!Ie(i))continue;let a=S(e,n,e=>r(e.type??``)===`searchfield`&&e.label===`Search`);a&&(t.suppressNode(i,[a]),Le(i,a,t),N(e,n,a,t))}}function Fe(e){return r(e.type??``)===`searchfield`&&e.label===`Search`}function Ie(e){let t=r(e.type??``);return e.label===`Toolbar`&&(t===`toolbar`||t===`searchfield`)}function N(e,t,n,r){y(e,t,e=>{e.index!==n.index&&Re(e)&&r.suppressNode(e,[n])})}function Le(e,t,n){let r=e;for(;typeof r.parentIndex==`number`;){let e=n.sourceNodesByIndex.get(r.parentIndex);if(!e||e.label!==`Toolbar`)return;n.suppressNode(e,[t]),r=e}}function Re(e){let t=r(e.type??``);return t===`button`?!1:t===`image`||e.label===`Search`}function ze(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?.label?.trim();!r||t.isSuppressed(r)||!i||Be(e,n,r,i,t)}}function Be(e,t,n,i,a){let o=r(n.type??``);if(o===`statictext`||o===`link`){P(e,t,i,n,a);return}if(o!==`other`)return;let s=Ve(e,t,i);if(s){a.suppressNode(n,[s]);return}P(e,t,i,n,a)}function Ve(e,t,n){return S(e,t,e=>{let t=r(e.type??``);return(t===`link`||t===`searchfield`||b(e.type))&&e.label?.trim()===n})}function P(e,t,n,r,i){y(e,t,e=>{!i.semanticRepresentativeIndexes.has(e.index)&&ne(e,n)&&i.suppressNode(e,[r])})}function He(e,t){j(e,(n,r,i)=>{let a=S(e,i,e=>E(e)&&e.label?.trim()===r&&(h(e.rect,n.rect)||Ue(n,e)));a&&t.suppressNode(n,[a])})}function Ue(e,t){if(t.label?.trim()!==e.label?.trim())return!1;let n=r(t.type??``);return We(e,n)||n===`textfield`||Ge(e,n,t)}function We(e,t){let n=e.label?.trim();return t===`button`&&(n===`Dismiss`||n===`Back`)}function Ge(e,t,n){return t!==`button`||!e.rect||!n.rect?!1:e.rect.x===0&&e.rect.y===0&&e.rect.width>=300&&e.rect.height>=600&&n.rect.width<e.rect.width}function Ke(e,t){let n=D(e);for(let i of e){if(r(i.type??``)!==`other`||i.hittable===!0||i.label?.trim()||i.value?.trim()||!i.identifier?.trim())continue;let e=ae(i,n);(e.length!==0||i.hittable===!1)&&t.suppressNode(i,e)}}function qe(e,t){je(e,t),Ke(e,t),fe(e,t),Pe(e,t),He(e,t),De(e,t.replacements),Ae(e,t),ze(e,t)}function Je(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?Ye(e,n,r,t):void 0;!r?.rect||!i||Qe(e,n,r,i,t)}}function Ye(e,t,n,i){let a=n.label?.trim();if(r(n.type??``)!==`cell`||a&&!Xe(a,n.identifier)&&!l(a))return a;let o=w(e,t).find(Ze),s=o?.label?.trim();return!o||!s?a:(C(i.replacements,n,{label:s}),i.suppressNode(o,[n]),s)}function Xe(e,t){return t?.trim()===e&&/^[A-Z_$][A-Za-z0-9_$]*Cell$/.test(e)}function Ze(e){if(!e.label?.trim())return!1;let t=r(e.type??``);return t===`statictext`||t===`text`||t===`textview`}function Qe(e,t,n,i,a){let o=r(n.type??``);if(o===`button`){F(w(e,t),i,a,n);return}if(o!==`cell`)return;let s=w(e,t);$e(s,n,i,a)||et(s,n,i,a)}function $e(e,t,n,r){let i=e.find(e=>nt(e,t,n));if(!i)return!1;let a=e.find(e=>I(e,t,n)),o=i.identifier?void 0:a?.identifier??t.identifier;return o&&C(r.replacements,i,{identifier:o}),r.suppressNode(t,[i]),tt(e,t,n,i,r),!0}function et(e,t,n,r){let i=e.find(e=>I(e,t,n));if(!i){e.some(ie)&&F(e,n,r,t);return}!t.identifier&&i.identifier&&C(r.replacements,t,{identifier:i.identifier}),r.suppressNode(i,[t]),F(e.filter(e=>e.index!==i.index),n,r,t)}function tt(e,t,n,r,i){for(let a of e)a.index!==r.index&&(I(a,t,n)||L(a,t)||rt(a,r)||x(a,n))&&i.suppressNode(a,[r])}function F(e,t,n,r){for(let i of e)(x(i,t)||r&&L(i,r))&&n.suppressNode(i,r?[r]:[])}function I(e,t,n){if(r(e.type??``)!==`button`)return!1;let i=t.identifier?.trim(),a=e.identifier?.trim();return i&&a&&i===a?!0:e.label?.trim()===n&&h(e.rect,t.rect)}function L(e,t){return r(e.type??``)===`button`&&!e.label?.trim()&&!e.value?.trim()&&h(e.rect,t.rect)}function nt(e,t,n){if(r(e.type??``)!==`switch`)return!1;let i=t.identifier?.trim(),a=e.identifier?.trim();return i&&a&&i===a?!0:e.label?.trim()===n}function rt(e,t){if(r(e.type??``)!==`switch`||e.index===t.index)return!1;let n=e.label?.trim();return n===t.value?.trim()||n===`0`||n===`1`}const R=1.15;function it(e,t,n){let r=new Map(e.map((e,t)=>[e.index,t]));for(let[i,a]of e.entries()){let s=at(e,r,t,a,n);if(!s)continue;B(e,i,n);let c=V(s.shelfRect,2);for(let t of s.intermediateSiblings){if(mt(t)||!t.rect||!o(t.rect,c))continue;let i=r.get(t.index);i!==void 0&&B(e,i,n)}}}function at(e,t,n,r,i){let a=ot(r,n,i.sourceNodesByIndex);if(!a)return;let o=lt(e,t,a.siblings,a.position,a.parent);if(!(o<0))return{shelfRect:a.rect,intermediateSiblings:a.siblings.slice(a.position+1,o)}}function ot(e,t,n){let r=ut(e,z(t,e.index));if(!r)return;let i=ct(e,n);if(!i||!i.rect)return;let a=z(t,i.index),o=a.findIndex(t=>t.index===e.index);if(st(a,o,e,r))return{rect:r.rect,parent:i,siblings:a,position:o}}function z(e,t){return e.get(t)??[]}function st(e,t,n,r){if(t<1)return!1;let i=dt(e,t,n);return i?!r.childActionsPresented||!ft(i,r.actionButtons):!1}function ct(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function lt(e,t,n,r,i){return n.findIndex((n,a)=>a>r&&pt(e,t.get(n.index),n,i))}function ut(e,n){if(!b(e.type)||!e.rect)return;let i=e.rect,a=n.filter(e=>r(e.type??``)===`button`&&e.rect);if(a.length===0&&e.hiddenContentBelow===!0)return{rect:i,childActionsPresented:!1,actionButtons:a};if(a.length<3)return;let o=a.map(e=>e.rect.x+e.rect.width/2);if(o.every((e,t)=>t===0||e>o[t-1]))return{rect:i,childActionsPresented:a.some(e=>t(i,e.rect)),actionButtons:a}}function dt(e,t,n){if(!(!n.rect||t<1))for(let r=t-1;r>=0;--r){let t=e[r];if(!(!t.rect||!E(t))&&t.rect.x+t.rect.width/2<n.rect.x&&ht(t.rect,V(n.rect,2)))return t}}function ft(e,t){if(!e.rect||t.length===0)return!1;let n=Math.max(...t.map(e=>e.rect?.width??0)),r=Math.max(...t.map(e=>e.rect?.height??0));return e.rect.width>n*R||e.rect.height>r*R}function pt(e,t,n,i){return t!==void 0&&r(n.type??``)===`other`&&h(n.rect,i.rect)&&!!S(e,t,E)}function B(e,t,n){let r=e[t];if(r){n.suppressNode(r,[]);for(let r of w(e,t))n.suppressNode(r,[])}}function mt(e){let t=r(e.type??``);return t===`textfield`||t===`securetextfield`||t===`searchfield`||t===`textview`}function V(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function ht(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function gt(e,t){let n=D(e);it(e,n,t),_t(e,n,t)}function _t(e,t,n){for(let i of e){if(r(i.type??``)!==`navigationbar`||!i.rect)continue;let e=t.get(i.index)??[],a=e.flatMap(t=>vt(t,e,i.rect));if(a.length!==1)continue;let{field:o,title:s,image:c,label:l}=a[0];C(n.replacements,o,{type:`Button`,label:l,enabled:!0,hittable:void 0,rect:Ct([c.rect,o.rect,s.rect])}),n.semanticRepresentativeIndexes.add(o.index),n.suppressNode(s,[o]),n.suppressNode(c,[o])}}function vt(e,t,n){let r=i(e);if(!yt(e,r))return[];let a=H(t,e=>bt(e,r)),o=H(t,xt);return a?.rect&&o?.rect&&St(o.rect,e.rect,a.rect,n)?[{field:e,title:a,image:o,label:r}]:[]}function yt(e,t){return r(e.type??``)===`textfield`&&e.enabled===!1&&!!e.rect&&!!t&&e.value?.trim()===t}function bt(e,t){return r(e.type??``)===`statictext`&&e.label?.trim()===t&&!!e.rect}function xt(e){return r(e.type??``)===`image`&&!!e.identifier?.trim()&&!!e.rect}function H(e,t){let n=e.filter(t);return n.length===1?n[0]:void 0}function St(e,n,r,i){let a=n.x-(e.x+e.width),o=r.x-(n.x+n.width);return t(i,e)&&t(i,n)&&t(i,r)&&a>=0&&a<=12&&o>=0&&o<=12&&U(e,n)&&U(n,r)}function U(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function Ct(e){let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.width)),i=Math.max(...e.map(e=>e.y+e.height));return{x:t,y:n,width:r-t,height:i-n}}function wt(e,t){let n=D(e);for(let i of e){if(r(i.type??``)===`element(58)`){C(t.replacements,i,{type:`WebView`});continue}let e=Tt(i,t.sourceNodesByIndex,n);if(e?.kind===`suppress`){t.suppressNode(i,[]);continue}e&&(C(t.replacements,i,{type:e.type,...e.type===`Heading`?{value:void 0}:{}}),t.semanticRepresentativeIndexes.add(i.index))}}function Tt(e,t,n){if(r(e.type??``)!==`other`)return null;let i=T(e,t,Ot),a=e.label?.trim();return!i||!a?null:Dt(e,i,a)?{kind:`suppress`}:Et(e,a,n)?{kind:`semantic`,type:W(e.value)?`Heading`:`StaticText`}:null}function Et(e,t,n){let i=n.get(e.index);if(i?.length!==1)return!1;let a=i[0];return r(a.type??``)===`statictext`&&a.label?.trim()===t&&!n.has(a.index)}function Dt(e,t,n){return e.parentIndex===t.index&&t.label?.trim()===n&&!W(e.value)}function Ot(e){let t=r(e.type??``);return t===`webview`||t===`element(58)`}function W(e){return/^[1-6]$/.test(e?.trim()??``)}const kt=[wt,gt,se,Je,qe];function G(e){if(e.length===0)return{nodes:e,presentedIndexesBySourceIndex:new Map};let t=new Map,n=new Map,r=new Set,i=new Map(e.map(e=>[e.index,e])),a=new Set,o={replacements:t,semanticRepresentativeIndexes:r,sourceNodesByIndex:i,isSuppressed:e=>a.has(e.index),suppressNode(e,t){if(a.add(e.index),t.length===0)return;let r=n.get(e.index)??new Set;for(let e of t)r.add(e.index);n.set(e.index,r)}};for(let t of kt)t(e,o);if(a.size===0&&t.size===0)return{nodes:e,presentedIndexesBySourceIndex:new Map(e.map(e=>[e.index,[e.index]]))};let s=e.filter(e=>!a.has(e.index)).map(e=>t.get(e.index)??e),c=re(s,a,e),l=new Map(s.map((e,t)=>[e.index,c[t].index]));return{nodes:c,presentedIndexesBySourceIndex:new Map(e.map(e=>[e.index,At(e.index,l,n)]))}}function At(e,t,n,r=new Set){let i=t.get(e);if(i!==void 0)return[i];if(r.has(e))return[];r.add(e);let a=new Set;for(let i of n.get(e)??[])for(let e of At(i,t,n,r))a.add(e);return[...a].sort((e,t)=>e-t)}var K=class extends Error{code=`IOS_SNAPSHOT_ENGINE_FAILED`;reason;details;constructor(e,t,n={}){super(t),this.name=`IosSnapshotEngineError`,this.reason=e,this.details=n}};function jt(e){return{reason:e.reason,...e.details}}function q(e){let t=new Map;for(let[n,r]of e.entries()){if(!Number.isInteger(r.index)||r.index<0||t.has(r.index))throw new K(`malformed-graph`,`iOS snapshot graph contains a duplicate or invalid node index`,{index:r.index});if(t.set(r.index,n),r.depth!==void 0&&(!Number.isInteger(r.depth)||r.depth<0))throw new K(`malformed-graph`,`iOS snapshot graph contains an invalid node depth`,{index:r.index,field:`depth`})}for(let[n,r]of e.entries()){if(r.parentIndex===void 0)continue;let e=t.get(r.parentIndex);if(e===void 0||e>=n)throw new K(`malformed-graph`,`iOS snapshot graph parent must precede its child`,{index:r.index,parentIndex:r.parentIndex})}}const J=new Set([`collectionview`,`scrollview`,`table`]),Mt=new Set([`application`,`window`]);function Nt(){return{projectedOut:!1}}function Pt(e,t,n,i,a,o){let c=o===`cursor-projected`?t.ancestorClip:void 0,l=Ft(e.rect,n,c),u=s(Y(e.rect)),d=s(l),f=r(e.type??``),p=It(o,t.projectedOut,u,d,f,a),m=Ut(e,Lt(o,t.projectedOut,u,d)&&!Rt(e,u,o),i,o),h=Ht(f,m,d,a),g=Bt(o,t.projectedOut,u,d,e);return{isIncluded:m,descendants:zt(o,p,c,l,h),effectiveRect:l,...g?{hiddenContentFrame:g}:{},establishesScrollAnchor:h}}function Ft(e,t,n){let r=Y(e);if(!r)return;let i=qt(r,t);return n&&(i=qt(i,n)),i}function It(e,t,n,r,i,a){return e===`plain-viewport`?!r:t||n&&!r&&Vt(i,a)}function Lt(e,t,n,r){return e===`plain-viewport`?r:!t&&(!n||r)}function Rt(e,t,n){return n!==`cursor-projected`||e.parentIndex===void 0||Wt(e)||!t?!1:Gt(e.rect)<=1||Kt(e.rect)<=1}function zt(e,t,n,r,i){return{projectedOut:t,...e===`cursor-projected`&&i?{ancestorClip:r}:{ancestorClip:n}}}function Bt(e,t,n,r,i){if(!(e!==`cursor-projected`||t||!n||r))return Y(i.rect)}function Vt(e,t){return t&&(e===`cell`||J.has(e))}function Ht(e,t,n,r){return t&&n&&r&&J.has(e)}function Ut(e,t,n,i){if(e.parentIndex===void 0)return!0;let a=r(e.type??``);return i===`plain-viewport`&&n&&!t&&a!==`application`?!1:Mt.has(a)||t}function Wt(e){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.trim().length>0)}function Y(e){if(e&&[e.x,e.y,e.width,e.height].every(Number.isFinite)&&!(e.width<0||e.height<0))return{...e,width:Math.max(0,e.width),height:Math.max(0,e.height)}}function Gt(e){return Y(e)?.width??0}function Kt(e){return Y(e)?.height??0}function qt(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return i<=n||a<=r?{x:e.x,y:e.y,width:0,height:0}:{x:i>n?n:e.x,y:a>r?r:e.y,width:i-n,height:a-r}}function Jt(e){let t=D(e),n=new Set;for(let e of t.values()){let r=Yt(e,t);if(r){for(let i of e.slice(0,-1))if(Xt(r,i)){n.add(i.index);for(let e of ae(i,t))n.add(e.index)}}}return n}function Yt(e,t){let n=e.at(-1);if(!n||!Zt(n))return;let r=(t.get(n.index)??[]).find(Qt);if(!(r?.userInteractionEnabled!==!0||!s(r.rect)))return{container:n,dimmingRect:r.rect}}function Xt(e,n){return Zt(n)&&s(n.rect)&&t(e.dimmingRect,n.rect)}function Zt(e){return $t(e,`uitransitionview`)}function Qt(e){return $t(e,`uidimmingview`)}function $t(e,t){return r(e.role??``)===t}function en(e,t,n,r,i={}){q(e);let a=Jt(e),o=e.filter(e=>!a.has(e.index)),s=tn(o),c=new Map,l=[],u=new Map,d=0;for(let e of o){let a=nn(e,c,()=>{d+=1}),o=a?.traversal??Nt(),f=r===`cursor-projected`?a?.anchor:void 0,p=Pt(e,o,t,n,s.has(e.index),r);rn(p,f,u);let m=an(e,p,a,l,t,i),h=sn(p,f,m.keptIndex);c.set(e.index,{traversal:p.descendants,anchor:h,keptIndex:m.keptIndex,keptDepth:m.keptDepth})}let f=ln(u,l);return{nodes:f,stats:{presentedNodeCount:f.length,sourceNodeCount:e.length,parentClipLookups:d,modalContainedNodeCount:a.size}}}function tn(e){let t=new Set;for(let n of e)n.parentIndex!==void 0&&t.add(n.parentIndex);return t}function nn(e,t,n){if(e.parentIndex!==void 0)return n(),t.get(e.parentIndex)}function rn(e,t,n){e.hiddenContentFrame&&t&&cn(e.hiddenContentFrame,t,n)}function an(e,t,n,r,i,a){let o=n?.keptIndex,s=n?.keptDepth??-1;if(!t.isIncluded)return{keptIndex:o,keptDepth:s};let c=r.length;s+=1;let{hittable:l,...u}=e;return r.push({raw:{...u,index:c,depth:s,parentIndex:o,...on(l,e.parentIndex!==void 0,t.effectiveRect,e.enabled!==!1,i,a)},sourceIndex:e.index,...t.effectiveRect?{effectiveRect:t.effectiveRect}:{}}),o=c,{keptIndex:o,keptDepth:s}}function on(e,t,r,i,a,o){return o.hittabilityAvailable===!1?e===!1||!i?{hittable:!1}:{}:{hittable:t&&e===!0&&n(i,r,a)}}function sn(e,t,n){return e.establishesScrollAnchor&&n!==void 0&&e.effectiveRect?{index:n,rect:e.effectiveRect}:t}function cn(e,t,n){let r=n.get(t.index)??{above:!1,below:!1};e.y+e.height<=t.rect.y?r.above=!0:e.y>=t.rect.y+t.rect.height&&(r.below=!0),n.set(t.index,r)}function ln(e,t){return t.map(t=>{let n=e.get(t.raw.index);if(!n)return t;let r=t.raw;return{...t,raw:{...r,hiddenContentAbove:r.hiddenContentAbove===!0||n.above?!0:void 0,hiddenContentBelow:r.hiddenContentBelow===!0||n.below?!0:void 0}}})}const un=new Set([`collectionview`,`scrollview`,`table`]);function dn(e){return fn(e.viewport)}function fn(e){if(e.kind===`missing`)throw new K(e.reason===`invalid`?`invalid-viewport`:`missing-viewport`,`regular iOS snapshot presentation requires a valid viewport`,{field:`viewport`});if(!s(e.rect))throw new K(`invalid-viewport`,`regular iOS snapshot presentation requires a positive finite viewport`,{field:`viewport`});return e.rect}function pn(e,t,n,r=!0){q(e);let i=new Map,a=0;for(let o of e){let e=mn(o,i,t,()=>{a+=1}),c=bn(o.rect);if(hn(o,r),!c||!s(c)){gn(o,c),i.set(o.index,e);continue}_n(o,c,e),vn(o,c,t),i.set(o.index,yn(o,c,e,n))}return{parentClipLookups:a}}function mn(e,t,n,r){if(e.parentIndex===void 0)return n;r();let i=t.get(e.parentIndex);if(!i)throw new K(`invalid-presented-payload`,`regular iOS snapshot payload refers to a parent outside the payload`,{index:e.index,parentIndex:e.parentIndex});return i}function hn(e,t){if(!(e.hittable!==!0||t))throw new K(`invalid-presented-payload`,`iOS snapshot payload marked a node actionable without hittability evidence`,{index:e.index})}function gn(e,t){if(e.hittable===!0)throw new K(`regular-degenerate-actionable-node`,`regular iOS snapshot node with a missing or degenerate frame is actionable`,{index:e.index,frame:t??e.rect})}function _n(e,t,n){if(!xn(t,n))throw new K(`regular-node-outside-cumulative-clip`,`regular iOS snapshot node escaped its cumulative clip`,{index:e.index,frame:t,clip:n})}function vn(e,t,n){if(!(e.hittable!==!0||e.enabled!==!1&&c(n,t.x+t.width/2,t.y+t.height/2)))throw new K(`invalid-presented-payload`,`regular iOS snapshot payload marked a disabled or off-viewport node actionable`,{index:e.index,frame:t})}function yn(e,t,n,i){return i===`cursor-projected`&&un.has(r(e.type??``))?t:n}function X(e,t,n,r,i=!0){if(t===`raw`)return q(e),{parentClipLookups:0};if(!n)throw new K(`missing-viewport`,`regular iOS snapshot payload cannot be validated without a viewport`,{field:`viewport`});try{return pn(e,n,r,i)}catch(e){throw e instanceof K&&e.code===`IOS_SNAPSHOT_ENGINE_FAILED`&&e.reason===`malformed-graph`?new K(`invalid-presented-payload`,e.message,e.details):e}}function bn(e){if(!(!e||![e.x,e.y,e.width,e.height].every(Number.isFinite))&&!(e.width<0||e.height<0))return{...e,width:Math.max(0,e.width),height:Math.max(0,e.height)}}function xn(e,n){let r=1e-4;return t({x:n.x-r,y:n.y-r,width:n.width+r*2,height:n.height+r*2},e)}const Sn=new Set([`button`,`cell`,`checkbox`,`collectionview`,`link`,`menuitem`,`picker`,`searchfield`,`securetextfield`,`segmentedcontrol`,`slider`,`scrollview`,`stepper`,`switch`,`tabbar`,`table`,`textfield`,`textview`,`webview`]);function Cn(e){let t=Fn(e.nodes),n=Tn(e,t);return e.projection===`raw`?En(n,e.depth,t):Dn(n,e.depth)}function Z(e){let t=Fn(e.nodes);return e.projection===`raw`?En(e.nodes,e.depth,t):Dn(e.nodes,e.depth)}function wn(e){return e.parentIndex===void 0||Sn.has(r(e.type??``))||In(e)}function Tn(e,t){let n=e.scope?.trim().toLowerCase();if(!n)return[...e.nodes];for(let r=0;r<e.nodes.length;r+=1){let i=e.nodes[r];if(!i||!Nn(i.raw,n))continue;let a=Pn(e.nodes,r,t);if(!(e.projection===`raw`||a.some(t=>wn(e.nodes[t].raw))))continue;let o=a.map(t=>e.nodes[t]);return Mn(e.projection===`raw`&&e.depth!==null?o.filter(n=>Q(n,t)-Q(i,t)<=e.depth):o,Q(i,t),t)}return[]}function En(e,t,n){let r=t===null?[...e]:e.filter(e=>Q(e,n)<=t);return{nodes:r.map(e=>({...e.raw,rect:e.raw.rect})),sourceIndexes:r.map(e=>e.sourceIndex)}}function Dn(e,t){let n=[],r=[],i=new Map;for(let a of e){let e=On(a,i),o=kn(a,e,t,n.length);if(!o){jn(a,e,i);continue}n.push(o),r.push(a.sourceIndex),i.set(a.raw.index,o)}return{nodes:n,sourceIndexes:r}}function On(e,t){return e.raw.parentIndex===void 0?void 0:t.get(e.raw.parentIndex)}function kn(e,t,n,r){if(!wn(e.raw))return;let i=t?(t.depth??0)+1:0;if(n!==null&&i>n)return;let a=An(e);return{...e.raw,index:r,depth:i,parentIndex:t?.index,...e.effectiveRect?{rect:e.effectiveRect}:{rect:void 0},...a===void 0?{}:{hittable:a}}}function An(e){if(e.raw.hittable!==void 0)return!!(e.raw.hittable===!0&&e.effectiveRect&&e.effectiveRect.width>0&&e.effectiveRect.height>0)}function jn(e,t,n){t&&n.set(e.raw.index,t)}function Mn(e,t,n){let r=new Map(e.map((e,t)=>[e.raw.index,t]));return e.map((e,i)=>({...e,raw:{...e.raw,index:i,depth:Math.max(0,Q(e,n)-t),parentIndex:e.raw.parentIndex===void 0?void 0:r.get(e.raw.parentIndex)}}))}function Nn(e,t){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.toLowerCase().includes(t))}function Pn(e,t,n){let r=Q(e[t],n),i=[];for(let a=t;a<e.length&&!(a>t&&Q(e[a],n)<=r);a+=1)i.push(a);return i}function Q(e,t){return Math.max(0,e.raw.depth??t?.get(e.raw.index)??0)}function Fn(e){let t=new Map;for(let n of e){let e=(n.raw.parentIndex===void 0?-1:t.get(n.raw.parentIndex)??-1)+1;t.set(n.raw.index,n.raw.depth===void 0?e:Math.max(0,n.raw.depth))}return t}function In(e){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.trim().length>0)}function Ln(e,t,n=`cursor-projected`){Rn(e,t);let r=e.validation.presentationKey.projection,i=r===`regular`?fn(e.validation.viewport):void 0,a=e.validation.hittability.kind===`available`,o=zn(e,r,i,n,a),s=Bn(e.presentation.payload.nodes,r,t),c=Vn(s.nodes,r,i,n,a,o);return{nodes:s.nodes,...e.presentation.qualityPayload?{qualityNodes:[...e.presentation.qualityPayload.nodes]}:{},presentedIndexesBySourceIndex:s.presentedIndexesBySourceIndex,stats:{presentedNodeCount:s.nodes.length,sourceNodeCount:e.presentation.payload.nodes.length,parentClipLookups:c.parentClipLookups,modalContainedNodeCount:0}}}function Rn(e,t){if(!Hn(_(t),e.validation.presentationKey))throw new K(`projection-mismatch`,`presented iOS snapshot does not match the requested presentation key`,{projection:e.validation.presentationKey.projection});if(e.presentation.intent!==t.acquisitionIntent)throw new K(`projection-mismatch`,`presented iOS snapshot does not match the requested acquisition intent`,{field:`acquisitionIntent`})}function zn(e,t,n,r,i){let a=X(e.presentation.payload.nodes,t,n,r,i);if(e.presentation.qualityPayload)try{X(e.presentation.qualityPayload.nodes,t,n,r,i)}catch(e){throw e instanceof K?new K(`invalid-quality-payload`,e.message,e.details):e}return a}function Bn(e,t,n){return t===`regular`&&n.interactiveOnly?G([...e]):{nodes:[...e],presentedIndexesBySourceIndex:Un(e)}}function Vn(e,t,n,r,i,a){return t!==`regular`||!n?a:X(e,t,n,r,i)}function Hn(e,t){return e.projection===t.projection&&e.interactiveOnly===t.interactiveOnly&&e.depth===t.depth&&e.scope===t.scope&&e.customActions===t.customActions}function Un(e){return new Map(e.map(e=>[e.index,[e.index]]))}function Wn(t,n,r={}){let i=Gn(t,n,r),a=t.stage===`presented`?t.validation.presentationKey:_(n),o=t.stage===`acquired`?t.acquisition.truncated:t.presentation.payload.truncated;return{payload:{nodes:e(i.nodes),...o===void 0?{}:{truncated:o}},presentationKey:a,comparisonIdentity:ee(t,n),residue:t.stage===`acquired`?[...t.acquisition.residue]:[...t.validation.residue]}}function Gn(e,t,n={}){let r=n.foldPolicy??`cursor-projected`;return e.stage===`acquired`?Kn(e.acquisition,t,r):Ln(e,t,r)}function Kn(e,t,n){if(Jn(e,g(t)),t.projection===`raw`){q(e.nodes);let r=e.nodes.map(e=>({raw:e,sourceIndex:e.index})),i=Cn({nodes:r,projection:`raw`,scope:t.scope,depth:t.depth,foldPolicy:n}),a=t.scope===null?void 0:Z({nodes:r,projection:`raw`,depth:null,foldPolicy:n}).nodes;return{nodes:i.nodes,...a?{qualityNodes:a}:{},presentedIndexesBySourceIndex:$(e.nodes,i.nodes,i.sourceIndexes,Yn(i.nodes)),stats:{presentedNodeCount:i.nodes.length,sourceNodeCount:e.nodes.length,parentClipLookups:0,modalContainedNodeCount:0}}}let r=dn(e),i=!qn(e.residue),a=en(e.nodes,r,t.interactiveOnly,n,{hittabilityAvailable:i}),o=Cn({nodes:a.nodes,projection:`regular`,scope:t.scope,depth:t.depth,foldPolicy:n}),s=t.interactiveOnly?G(o.nodes):{nodes:o.nodes,presentedIndexesBySourceIndex:Yn(o.nodes)},c=X(s.nodes,`regular`,r,n,i),l=t.scope===null?void 0:Z({nodes:a.nodes,projection:`regular`,depth:null,foldPolicy:n}).nodes;return{nodes:s.nodes,...l?{qualityNodes:l}:{},presentedIndexesBySourceIndex:$(e.nodes,o.nodes,o.sourceIndexes,s.presentedIndexesBySourceIndex),stats:{presentedNodeCount:s.nodes.length,sourceNodeCount:e.nodes.length,parentClipLookups:a.stats.parentClipLookups+c.parentClipLookups,modalContainedNodeCount:a.stats.modalContainedNodeCount}}}function qn(e){return e.some(e=>e.kind===`unavailable-fact`&&e.fact===`hittability`)}function Jn(e,t){let n=e.hint;if(n.projection!==t.projection||n.rawTraversalDepth!==t.rawTraversalDepth||n.regularPresentedDepth!==t.regularPresentedDepth||n.interactiveOnly!==t.interactiveOnly||n.customActions!==t.customActions||n.acquisitionIntent!==t.acquisitionIntent)throw new K(`projection-mismatch`,`acquired iOS snapshot does not match the requested capture hint`,{projection:n.projection})}function Yn(e){return new Map(e.map(e=>[e.index,[e.index]]))}function $(e,t,n,r){let i=new Map(t.map((e,t)=>[e.index,n[t]])),a=new Map(e.map(e=>[e.index,[]]));for(let[e,t]of r){let n=i.get(e);n!==void 0&&a.set(n,t)}return a}export{G as a,jt as i,Ln as n,K as r,Wn as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{N as e}from"./sdk-contracts.js";import{rn as t}from"./sdk-batch.js";import{r as n}from"./diagnostics.js";import"./diagnostics2.js";import{s as r}from"./app-resolution.js";import{n as i}from"./alert.js";const a=`launch_confirmation_foreign_app`,o=/^Open in [“"].+[”"]\?$/u,s=1e4;async function c(t){let r=await l(t);if(`outcome`in r)return r;if(!r.alert)return{outcome:`absent`};if(!f(r.alert))return n({level:`warn`,phase:`ios_launch_confirmation_unanswered`,data:{reason:`alert-unrecognized`,title:r.alert.message,buttons:r.alert.items}}),{outcome:`unanswered`,reason:`alert-unrecognized`};let i=await u(t);if(`outcome`in i)return i;if(i.owner===void 0)return m(`url-owner-unresolved`,{}),{outcome:`unanswered`,reason:`url-owner-unresolved`};if(i.owner!==t.appBundleId)throw new e(`COMMAND_FAILED`,`The launch URL asks to open ${i.owner} instead.`,{reason:a,foreignAppBundleId:i.owner,sessionAppBundleId:t.appBundleId,hint:`iOS is asking whether to open ${i.owner}. Answer it with alert accept or alert dismiss, and pass a launch URL whose scheme belongs to the session app.`});return await t.acceptAlert().then(d,p(`alert-accept`))}async function l(e){return await e.readAlert().then(e=>({alert:e}),p(`alert-read`))}async function u(e){return await e.resolveUrlOwner().then(e=>({owner:e}),p(`url-owner`))}function d(){return{outcome:`accepted`}}function f(e){let t=e.message;return typeof t==`string`&&o.test(t)}function p(t){return n=>(m(`step-failed`,{step:t,code:n instanceof e?n.code:void 0}),{outcome:`unreadable`,step:t})}function m(e,t){n({level:`debug`,phase:`ios_launch_confirmation_unanswered`,data:{reason:e,...t}})}async function h(e,t,n,r){let i=await n.then(e=>({interactor:e}),p(`runner`));return`outcome`in i?i:await c(g(e,t,i.interactor,r))}function g(e,{url:n,appBundleId:a},o,c){let l=o.readAlert?.bind(o),u=o.acceptAlert?.bind(o);if(!l||!u)throw t(`Apple interactor has no alert read or accept leg`);let d={appBundleId:a,surface:`app`};return Object.freeze({appBundleId:a,readAlert:async()=>await i(l(d)),acceptAlert:async()=>await u(d),resolveUrlOwner:async()=>await r(e,n,{timeoutMs:s,signal:c})})}export{a as LAUNCH_CONFIRMATION_FOREIGN_APP_REASON,s as URL_OWNER_LOOKUP_TIMEOUT_MS,c as answerLaunchConfirmation,h as answerSimulatorLaunchConfirmation,g as createLaunchConfirmationPort};
|
package/dist/src/lease.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as e,
|
|
1
|
+
import{F as e,N as t,V as n}from"./sdk-contracts.js";import{f as r,i,s as a,u as o}from"./lease-scope.js";import{in as s}from"./sdk-batch.js";import{n as c}from"./catalog.js";import{i as l,r as u}from"./request-cancel.js";import"./request.js";import{a as d,n as f}from"./provider-session-ownership.js";import{n as p,r as m}from"./lease-context.js";async function h(e){let{req:t,sessionName:n,sessionStore:i,leaseRegistry:d,providerRuntimeIds:f,providerRuntimeRequiredIds:h,leaseLifecycleProvider:y,cloudArtifactProvider:b}=e,w=p(t);switch(t.command){case c.artifacts:return{ok:!0,data:await C(t,m(t,i.get(n)),d,b)};case`lease_allocate`:{S(w.leaseProvider,f,h);let e=d.allocateLease(a(w));return await d.runDeviceMutation(e,async()=>{let n;try{n=await y?.allocate?.(e,{...x(t),signal:u(t.meta?.requestId),deadline:Date.now()+s}),k(d,e,n)}catch(t){throw d.releaseLease(g(e)),t}if(l(t.meta?.requestId))throw await v(e,y,d);return{ok:!0,data:{lease:e,...n?{provider:n}:{}}}})}case`lease_heartbeat`:{let e=d.heartbeatLease(o(w)),n=await y?.heartbeat?.(e,x(t));return{ok:!0,data:{lease:e,...n?{provider:n}:{}}}}case`lease_release`:{let e=r(w),n=d.getLease(e),i=await d.runDeviceMutation(n,async()=>await _(d,y,n,e,x(t)));return{ok:!0,data:{released:i.registryReleased,...i.provider?{provider:i.provider}:{}}}}default:return null}}function g(e){return r({leaseId:e.leaseId,tenantId:e.tenantId,runId:e.runId,leaseBackend:e.backend,leaseProvider:e.leaseProvider,deviceKey:e.deviceKey,clientId:e.clientId})}async function _(e,t,n,r,i){let a=n?await t?.release?.(n,i):void 0;return n&&k(e,n,a),{registryReleased:e.releaseLease(r).released,provider:a}}async function v(e,t,r){let i=g(e),a,o;try{a=await _(r,t,e,i)}catch(e){o=n(e),a={registryReleased:r.releaseLease(i).released}}return y(e,a,o)}function y(t,n,r){let i=n.provider?.providerSessionId,a=Array.isArray(n.provider?.warnings)?n.provider.warnings:[],o=n.registryReleased&&r===void 0&&a.length===0;return e({leaseId:t.leaseId,leaseProvider:t.leaseProvider,released:o,registryReleased:n.registryReleased,providerSessionId:i,...a.length>0?{warnings:a}:{},...r===void 0?{}:{releaseError:r},hint:b(o,t.leaseId,i)})}function b(e,t,n){return e?`The lease request was canceled while the provider was still allocating; the session it produced was released.`:`The lease request was canceled while the provider was still allocating, and the session it produced could NOT be confirmed released — it may still be running and billing. Stop provider session ${String(n??`(unknown)`)} for lease ${t} by hand.`}function x(e){return{flags:e.flags,...typeof e.flags?.providerApp==`string`?{initialApp:e.flags.providerApp}:{},cwd:typeof e.meta?.cwd==`string`?e.meta.cwd:void 0,...e.internal?.publicNetworkOnly?{publicNetworkOnly:!0}:{}}}function S(e,n,r){if(!(!e||n===void 0||r===void 0||!r.includes(e)||n.includes(e)))throw new t(`UNSUPPORTED_OPERATION`,`Provider "${e}" is not available in this daemon runtime.`,{provider:e,hint:`Restart the daemon with ${e} configured, then retry lease allocation.`})}async function C(e,t,n,r){let i=O(e.flags,`providerSessionId`);return w(t,i)?await T(t.tenantId):await E(t,i,n,r)}function w(e,t){return i(e)||!e.leaseProvider&&!t}async function T(e){let t=await d(e);return{source:`daemon`,status:`ready`,artifacts:t,...t.length===0?{message:`No daemon artifacts available.`}:{}}}async function E(e,n,r,i){if(!e.leaseProvider)throw new t(`INVALID_ARGS`,`artifacts requires --provider for provider session lookup or an active cloud connection.`);if(!e.leaseId&&!n)throw new t(`INVALID_ARGS`,`artifacts requires an active cloud lease or --provider-session <id>.`);let a=D(r,e,n),o=await i?.listCloudArtifacts?.({provider:e.leaseProvider,leaseId:a?.leaseId??e.leaseId,providerSessionId:n});if(!o)throw new t(`UNSUPPORTED_OPERATION`,`Cloud artifacts are not available for provider "${e.leaseProvider}".`);return o}function D(e,n,r){if(!r)return;let i=e.resolveProviderSession({provider:n.leaseProvider,providerSessionId:r,tenantId:n.tenantId});if(i)return i;throw new t(`UNAUTHORIZED`,`Provider session is not owned by the request tenant`,{reason:`PROVIDER_SESSION_NOT_OWNED`})}function O(e,t){let n=e?.[t];return typeof n==`string`&&n.trim().length>0?n.trim():void 0}function k(e,t,n){let r=f(n);r&&e.recordProviderSession(t,r)}export{h as handleLeaseCommands};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{N as t}from"./sdk-contracts.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{N as t}from"./sdk-contracts.js";import{l as n,r}from"./exec.js";import"./command.js";import{a as i}from"./version.js";import{_ as a}from"./adb-executor.js";import{i as o,o as s,r as c}from"./adb-transport.js";import"./mechanics.js";import"./platform-runtime-android-adb-host.js";import{n as l}from"./android.js";var u=e({createLimrunRuntimeDependencies:()=>d});function d(){return{clientVersion:i(),android:{createInteractor:(e,t)=>l(e,t),createPortReverse:async e=>{let{createAndroidPortReverseManager:t}=await import(`./mechanics.js`).then(e=>e.r);return t(e)},inferAppName:async e=>{let{inferAndroidAppName:t}=await import(`./mechanics.js`).then(e=>e.r);return t(e)},listApps:async(e,t)=>{let{listAndroidAppsWithAdb:n}=await import(`./mechanics.js`).then(e=>e.r);return(await n(e,{filter:t,target:`mobile`})).map(e=>({id:e.package,name:e.name}))},getForegroundApp:async(e,t,n)=>{let{getAndroidAppStateWithAdb:r}=await import(`./platform-runtime.js`).then(e=>e.a),i=await r(async(e,r)=>await t(e,{...r,signal:n}),n);return i.package?{appId:i.package,activity:i.activity}:void 0},getKeyboardState:async e=>{let{getAndroidKeyboardStatusWithAdb:t}=await import(`./mechanics.js`).then(e=>e.r);return await t(e)},dismissKeyboard:async e=>{let{dismissAndroidKeyboardWithAdb:t}=await import(`./mechanics.js`).then(e=>e.r);return await t(e)},readLogs:async(e,t)=>{let{captureAndroidLogcatWithAdb:n}=await import(`./mechanics.js`).then(e=>e.r);return await n(e,{lines:t,timeoutMs:5e3})},forceStopApp:async(e,t,n)=>{let{runAdbShell:r}=await import(`./mechanics.js`).then(e=>e.r);await r(async(t,r)=>await e(t,{...r,signal:n}),[`am`,`force-stop`,t],{allowFailure:!0})},deviceAdbInvocation:(e,t)=>o(s(e),t),hostAdbInvocation:e=>o(c(),e),adbError:async(e,t,n)=>{let{androidAdbResultError:r,serializeAndroidAdbInvocation:i}=await import(`./mechanics.js`).then(e=>e.r);return r(e,t,n?{command:`adb ${i(n).join(` `)}`}:void 0)}},host:{runAdb:async(e,t)=>await a(e,t),downloadFile:async e=>{let{downloadLimrunFile:t}=await import(`./limrun-download-file.js`);await t(e)},archiveDirectory:async({sourceDirectory:e,entryName:i,archivePath:a})=>{let o=[`-qr`,a,i],s=await n(`zip`,o,{cwd:e,timeoutMs:12e4});if(s.exitCode!==0)throw new t(`COMMAND_FAILED`,`Failed to package iOS .app for Limrun install`,{command:[`zip`,...o].join(` `),...r(s)})}},ios:{resolveAppAlias:async e=>{let{resolveIosAppAlias:t}=await import(`./app-resolution-facade.js`);return t(e)},readBundleAppName:async e=>{let{readIosBundleInfo:t}=await import(`./install-artifact-facade.js`);return(await t(e)).appName}}}}export{u as n,d as t};
|
package/dist/src/limrun.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { A as Rect, D as IosTargetActivation, F as SnapshotOptions$1, I as SnapshotProvenance, N as SnapshotKeyboardBandFact, O as Point, S as DeviceTarget, b as DeviceInfo, f as LeaseBackend, k as RawSnapshotNode, w as PlatformSelector, x as DeviceKind } from "./sdk-contracts.js";
|
|
2
2
|
import { s as AppsFilter, t as GesturePlan } from "./gesture-plan-types.js";
|
|
3
|
-
import { A as SessionSurface, E as BackendSnapshotResult, b as ScrollDirection, c as BackMode, h as SettingOptions, i as DeviceRotation, m as ReadableSetting, n as ScrollExecutionOptions, p as ReadSettingResult, r as TvRemoteButton, v as CloudArtifactProvider } from "./scroll-command.js";
|
|
4
3
|
import { d as AndroidAdbProvider, m as AppStateRuntimeResult, n as AndroidKeyboardState, s as AndroidInputOwner, t as AndroidKeyboardDismissResult } from "./device-input-state.js";
|
|
4
|
+
import { A as BackMode, E as DeviceRotation, a as BackendSnapshotResult, b as ScrollExecutionOptions, g as SettingOptions, h as ReadableSetting, l as SessionSurface, m as ReadSettingResult, n as CloudArtifactProvider, v as TvRemoteButton, x as ScrollDirection } from "./cloud-artifacts.js";
|
|
5
5
|
//#region packages/contracts/src/device-inventory.d.ts
|
|
6
6
|
type DeviceInventoryRequest = {
|
|
7
7
|
platform?: PlatformSelector;
|
|
@@ -23,46 +23,6 @@ type DeviceInventoryRequest = {
|
|
|
23
23
|
};
|
|
24
24
|
type ProviderDeviceInventoryRequest = Omit<DeviceInventoryRequest, 'booted' | 'kind'>;
|
|
25
25
|
//#endregion
|
|
26
|
-
//#region packages/contracts/src/device-provider.d.ts
|
|
27
|
-
type DeviceLease = {
|
|
28
|
-
leaseId: string;
|
|
29
|
-
tenantId: string;
|
|
30
|
-
runId: string;
|
|
31
|
-
backend: LeaseBackend;
|
|
32
|
-
leaseProvider?: string;
|
|
33
|
-
deviceKey?: string;
|
|
34
|
-
clientId?: string;
|
|
35
|
-
createdAt: number;
|
|
36
|
-
heartbeatAt: number;
|
|
37
|
-
expiresAt: number;
|
|
38
|
-
};
|
|
39
|
-
type LeaseLifecycleContext = {
|
|
40
|
-
flags?: Readonly<Record<string, unknown>>;
|
|
41
|
-
initialApp?: string;
|
|
42
|
-
cwd?: string;
|
|
43
|
-
publicNetworkOnly?: boolean;
|
|
44
|
-
/** Request-bound cancellation (explicit cancel or client disconnect). */
|
|
45
|
-
signal?: AbortSignal;
|
|
46
|
-
/**
|
|
47
|
-
* Epoch-ms deadline by which `allocate` must have settled; derived from the
|
|
48
|
-
* same budget as the client's `lease_allocate` envelope, so a provider that
|
|
49
|
-
* fits its remote phases within it is never abandoned by a client first.
|
|
50
|
-
*/
|
|
51
|
-
deadline?: number;
|
|
52
|
-
};
|
|
53
|
-
type LeaseLifecycleProvider = {
|
|
54
|
-
allocate?: (lease: DeviceLease, context?: LeaseLifecycleContext) => Promise<Record<string, unknown> | undefined>;
|
|
55
|
-
heartbeat?: (lease: DeviceLease, context?: LeaseLifecycleContext) => Promise<Record<string, unknown> | undefined>;
|
|
56
|
-
release?: (lease: DeviceLease, context?: LeaseLifecycleContext) => Promise<Record<string, unknown> | undefined>;
|
|
57
|
-
};
|
|
58
|
-
type DeviceInventoryProvider = (request: ProviderDeviceInventoryRequest, signal?: AbortSignal) => Promise<DeviceInfo[] | null | undefined>;
|
|
59
|
-
type ProviderAppCatalogQuery = Readonly<{
|
|
60
|
-
provider: string;
|
|
61
|
-
platform: 'android' | 'ios';
|
|
62
|
-
publicNetworkOnly?: boolean;
|
|
63
|
-
}>;
|
|
64
|
-
type ProviderAppCatalogHandler = (query: ProviderAppCatalogQuery, signal?: AbortSignal) => Promise<readonly string[]>;
|
|
65
|
-
//#endregion
|
|
66
26
|
//#region packages/contracts/src/ios-system-surface.d.ts
|
|
67
27
|
/**
|
|
68
28
|
* iOS out-of-process system surfaces that agent-device observes and drives IN PLACE, never by
|
|
@@ -200,6 +160,14 @@ type ScreenshotOptions = {
|
|
|
200
160
|
skipIosSimulatorBootCheck?: boolean;
|
|
201
161
|
captureBackend?: 'runner';
|
|
202
162
|
};
|
|
163
|
+
/**
|
|
164
|
+
* What the capture owner observed while writing the image. `displayRotation` is the rotation the display
|
|
165
|
+
* rendered the pixels in, so a landscape value pairs with a landscape image; it is absent when the
|
|
166
|
+
* owner has no rotation reading it can stand behind for this capture.
|
|
167
|
+
*/
|
|
168
|
+
type ScreenshotCaptureFacts = Readonly<{
|
|
169
|
+
displayRotation?: DeviceRotation;
|
|
170
|
+
}>;
|
|
203
171
|
type ElementSelectorKey = 'id' | 'label' | 'text' | 'value';
|
|
204
172
|
type ElementSelectorTapOptions = {
|
|
205
173
|
key: ElementSelectorKey;
|
|
@@ -397,7 +365,7 @@ type Interactor = {
|
|
|
397
365
|
}): Promise<Record<string, unknown> | void>;
|
|
398
366
|
fillRef?(ref: string, text: string, delayMs?: number): Promise<Record<string, unknown> | void>;
|
|
399
367
|
scroll(direction: ScrollDirection, options?: ScrollExecutionOptions): Promise<Record<string, unknown> | void>;
|
|
400
|
-
screenshot(outPath: string, options?: ScreenshotOptions): Promise<void>;
|
|
368
|
+
screenshot(outPath: string, options?: ScreenshotOptions): Promise<ScreenshotCaptureFacts | void>;
|
|
401
369
|
setViewport?(width: number, height: number): Promise<Record<string, unknown> | void>;
|
|
402
370
|
snapshot(options?: SnapshotOptions): Promise<SnapshotRuntimeResult>;
|
|
403
371
|
/**
|
|
@@ -508,6 +476,46 @@ type AlertInteractorOptions = {
|
|
|
508
476
|
surface?: SessionSurface;
|
|
509
477
|
};
|
|
510
478
|
//#endregion
|
|
479
|
+
//#region packages/contracts/src/device-provider.d.ts
|
|
480
|
+
type DeviceLease = {
|
|
481
|
+
leaseId: string;
|
|
482
|
+
tenantId: string;
|
|
483
|
+
runId: string;
|
|
484
|
+
backend: LeaseBackend;
|
|
485
|
+
leaseProvider?: string;
|
|
486
|
+
deviceKey?: string;
|
|
487
|
+
clientId?: string;
|
|
488
|
+
createdAt: number;
|
|
489
|
+
heartbeatAt: number;
|
|
490
|
+
expiresAt: number;
|
|
491
|
+
};
|
|
492
|
+
type LeaseLifecycleContext = {
|
|
493
|
+
flags?: Readonly<Record<string, unknown>>;
|
|
494
|
+
initialApp?: string;
|
|
495
|
+
cwd?: string;
|
|
496
|
+
publicNetworkOnly?: boolean;
|
|
497
|
+
/** Request-bound cancellation (explicit cancel or client disconnect). */
|
|
498
|
+
signal?: AbortSignal;
|
|
499
|
+
/**
|
|
500
|
+
* Epoch-ms deadline by which `allocate` must have settled; derived from the
|
|
501
|
+
* same budget as the client's `lease_allocate` envelope, so a provider that
|
|
502
|
+
* fits its remote phases within it is never abandoned by a client first.
|
|
503
|
+
*/
|
|
504
|
+
deadline?: number;
|
|
505
|
+
};
|
|
506
|
+
type LeaseLifecycleProvider = {
|
|
507
|
+
allocate?: (lease: DeviceLease, context?: LeaseLifecycleContext) => Promise<Record<string, unknown> | undefined>;
|
|
508
|
+
heartbeat?: (lease: DeviceLease, context?: LeaseLifecycleContext) => Promise<Record<string, unknown> | undefined>;
|
|
509
|
+
release?: (lease: DeviceLease, context?: LeaseLifecycleContext) => Promise<Record<string, unknown> | undefined>;
|
|
510
|
+
};
|
|
511
|
+
type DeviceInventoryProvider = (request: ProviderDeviceInventoryRequest, signal?: AbortSignal) => Promise<DeviceInfo[] | null | undefined>;
|
|
512
|
+
type ProviderAppCatalogQuery = Readonly<{
|
|
513
|
+
provider: string;
|
|
514
|
+
platform: 'android' | 'ios';
|
|
515
|
+
publicNetworkOnly?: boolean;
|
|
516
|
+
}>;
|
|
517
|
+
type ProviderAppCatalogHandler = (query: ProviderAppCatalogQuery, signal?: AbortSignal) => Promise<readonly string[]>;
|
|
518
|
+
//#endregion
|
|
511
519
|
//#region packages/contracts/src/provider-device-runtime.d.ts
|
|
512
520
|
type ProviderDeviceInstallResult = {
|
|
513
521
|
bundleId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{nn as e}from"./sdk-batch.js";import{E as t,K as n,L as r,O as i,P as a,j as o}from"./alert-runtime.js";import{t as s}from"./touch-runtime.js";import{t as c}from"./interactor-operation-catalog.js";function l(l){let{facts:u,pause:d}=l,f={device:l.device,signal:l.signal,resolveInteractor:l.resolveInteractor};return{...u.captureScreenshot.available?n(f):{},...u.focusPoint.available?r(f):{},...a({...f,facts:u}),...u.scrollDirection.available?o(f):{},...u.typeText.available?i(f):{},...u.readTextAtPoint.available?t(f):{},...e(u.tapPoint,()=>s({...f,facts:u,pause:d})),...c({...f,facts:u})}}export{l as t};
|