agent-device 0.21.37 → 0.21.38
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.37.apk → agent-device-android-ime-helper-0.21.38.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.38.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.37.manifest.json → agent-device-android-ime-helper-0.21.38.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.37.apk → agent-device-android-snapshot-helper-0.21.38.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.38.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.37.manifest.json → agent-device-android-snapshot-helper-0.21.38.manifest.json} +7 -7
- package/apple/fold-helper/Fold.m +8 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerKeyboardReturnKey.swift +53 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +42 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +26 -18
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +42 -11
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Keyboard.swift +123 -22
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +7 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +570 -53
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +41 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.h +7 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.m +17 -1
- package/dist/src/THIRD_PARTY_NOTICES.txt +2 -2
- package/dist/src/absence-observation-errors.js +1 -1
- package/dist/src/absence-observation.js +1 -1
- package/dist/src/adapter.js +1 -1
- package/dist/src/adb-executor.js +1 -1
- package/dist/src/adb-failure.js +2 -2
- package/dist/src/adb-transport.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-browser-provider.js +1 -1
- package/dist/src/agent-browser-tool.js +1 -1
- package/dist/src/ai-sdk.d.ts +1 -1
- package/dist/src/ai-sdk.js +1 -1
- package/dist/src/alert-contract.js +1 -1
- package/dist/src/alert-tree-driver.js +1 -1
- package/dist/src/alert.js +1 -1
- package/dist/src/android-adb.d.ts +1 -1
- package/dist/src/android.js +1 -1
- package/dist/src/android2.js +1 -1
- package/dist/src/app-backend.js +1 -1
- package/dist/src/app-catalog.js +1 -1
- package/dist/src/app-deployment-resolution.js +1 -1
- package/dist/src/app-inventory.js +1 -1
- package/dist/src/app-launch.js +1 -1
- package/dist/src/app-lifecycle.js +4 -4
- package/dist/src/app-lifecycle2.js +2 -2
- package/dist/src/app-log-files.js +1 -1
- package/dist/src/app-log-runtime2.js +2 -2
- package/dist/src/app-log-session-resource.js +1 -1
- package/dist/src/app-resolution.js +1 -1
- package/dist/src/app-state-read.js +1 -1
- package/dist/src/app-state-runtime.d.ts +1 -1
- package/dist/src/application-lifecycle-interaction.js +1 -1
- package/dist/src/archive.js +1 -1
- package/dist/src/args.js +1 -1
- package/dist/src/artifact-download.js +1 -1
- package/dist/src/artifact-tracking.js +1 -1
- package/dist/src/auth-session.js +1 -1
- package/dist/src/auth.js +1 -1
- package/dist/src/automation-helper-artifact.js +1 -1
- package/dist/src/automation-helper.js +1 -1
- package/dist/src/await-with-signal.js +1 -1
- package/dist/src/backend-snapshot-options.js +1 -1
- package/dist/src/boot-diagnostics.js +1 -1
- package/dist/src/bridge-source.js +1 -1
- package/dist/src/browser-launch.js +1 -1
- package/dist/src/browserstack-device-features.js +1 -1
- package/dist/src/browserstack.js +1 -1
- package/dist/src/cache.js +1 -1
- package/dist/src/capture-disclosure.js +1 -1
- package/dist/src/capture-lifecycle.js +1 -1
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +19 -16
- package/dist/src/cli-output.js +11 -11
- package/dist/src/cli-runner.js +1 -1
- package/dist/src/cli.js +2 -2
- package/dist/src/click-button.js +1 -1
- package/dist/src/client-metro-companion.js +1 -1
- package/dist/src/client-metro.js +1 -1
- package/dist/src/client-options.js +1 -1
- package/dist/src/client-port.d.ts +246 -208
- package/dist/src/clipboard-shell-response.js +1 -1
- package/dist/src/cloud-artifacts.d.ts +7 -2
- package/dist/src/code-signature-cache.js +1 -1
- package/dist/src/command-schema.js +6 -4
- package/dist/src/command-tools.js +3 -3
- package/dist/src/command.js +1 -1
- package/dist/src/composed-inventory-gateways.js +1 -1
- package/dist/src/composite-resource-admission.js +1 -1
- package/dist/src/config.js +1 -1
- package/dist/src/connection-lease-transaction.js +1 -1
- package/dist/src/connection-metro-runtime.js +1 -1
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/connection-verification.js +1 -1
- package/dist/src/connection.js +3 -3
- package/dist/src/context.js +1 -1
- package/dist/src/contract.d.ts +2 -1
- package/dist/src/contracts.d.ts +1 -1
- package/dist/src/contracts.js +1 -1
- package/dist/src/daemon-client-attach.js +1 -1
- package/dist/src/daemon-client-dispatch-disclosure.js +1 -1
- package/dist/src/daemon-client-ensure.js +1 -1
- package/dist/src/daemon-client-ensuring.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-liveness-probe.js +1 -1
- package/dist/src/daemon-client-remote-health-cache.js +1 -0
- package/dist/src/daemon-client-remote-health-recovery.js +1 -0
- package/dist/src/daemon-client-transport.js +1 -1
- package/dist/src/daemon-command-registry.js +1 -1
- package/dist/src/daemon-composition.js +1 -1
- package/dist/src/daemon-diagnostics-scope.js +1 -1
- package/dist/src/daemon-http.js +1 -1
- package/dist/src/daemon-launch-spec.js +1 -1
- package/dist/src/daemon-lifecycle-errors.js +1 -1
- package/dist/src/daemon-policy-file.js +1 -1
- package/dist/src/daemon-registration-owner.js +3 -3
- package/dist/src/daemon-registration.js +1 -1
- package/dist/src/daemon-resolution.js +1 -1
- package/dist/src/daemon-startup-diagnostics.js +1 -1
- package/dist/src/daemon-stop.js +1 -1
- package/dist/src/daemon.js +1 -1
- package/dist/src/debug-symbols-facade.js +3 -3
- package/dist/src/device-claim-admission.js +1 -0
- package/dist/src/device-claim-reconciliation.js +1 -0
- package/dist/src/device-claim-recovery.js +1 -1
- package/dist/src/device-claim-rule.js +1 -1
- package/dist/src/device-claims.js +1 -1
- package/dist/src/device-input-state.d.ts +1 -1
- package/dist/src/device-inventory-context.js +1 -1
- package/dist/src/device-selection-resolver.js +1 -1
- package/dist/src/device-session.js +1 -1
- package/dist/src/device-shell.js +1 -1
- package/dist/src/device.js +1 -1
- package/dist/src/device3.js +3 -3
- package/dist/src/devicectl.js +1 -1
- package/dist/src/diagnostics.js +1 -1
- package/dist/src/discovery.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/doctor2.js +1 -1
- package/dist/src/durable-capture-resource.js +1 -1
- package/dist/src/durable-capture.js +1 -1
- package/dist/src/durable-resource.js +1 -1
- package/dist/src/ended-lease.js +1 -1
- package/dist/src/engine-eval-script.js +1 -1
- package/dist/src/error.js +2 -2
- package/dist/src/errors.js +1 -1
- package/dist/src/explicit-session-resolution.js +1 -1
- package/dist/src/expo-dev-client-launch.js +1 -1
- package/dist/src/failure-output.js +1 -1
- package/dist/src/file.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/finders.js +1 -1
- package/dist/src/flag-registry.js +1 -1
- package/dist/src/focus-runtime.js +1 -1
- package/dist/src/fold-helper.js +1 -1
- package/dist/src/generic-settle.js +1 -1
- package/dist/src/generic.js +1 -1
- package/dist/src/gesture-admission.js +1 -1
- package/dist/src/gesture-plan-types.d.ts +1 -1
- package/dist/src/gesture-plan.js +1 -1
- package/dist/src/gesture-runtime.js +1 -1
- package/dist/src/hdc.js +1 -1
- package/dist/src/helper-artifacts.js +1 -1
- package/dist/src/helper.js +2 -2
- package/dist/src/host-file.js +1 -1
- package/dist/src/host.js +1 -1
- package/dist/src/host2.js +1 -1
- package/dist/src/host3.js +1 -1
- package/dist/src/host4.js +1 -1
- package/dist/src/host5.js +1 -1
- package/dist/src/host6.js +1 -1
- package/dist/src/human-control-contract.js +1 -1
- package/dist/src/human-control.js +1 -1
- package/dist/src/ime-rebind.js +1 -1
- package/dist/src/ime-settings-record.js +1 -1
- package/dist/src/ime-state.js +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.js +1 -1
- package/dist/src/input-actions.js +1 -1
- package/dist/src/input-actions2.js +1 -1
- package/dist/src/install-artifact-facade.js +1 -1
- package/dist/src/install-source-network-transport.js +1 -1
- package/dist/src/install-source2.js +1 -1
- package/dist/src/interaction-error.js +1 -1
- package/dist/src/interaction-positionals.js +1 -1
- package/dist/src/interaction-ref-policy.js +1 -1
- package/dist/src/interaction2.js +1 -1
- package/dist/src/interactor-operation-binding.js +1 -1
- package/dist/src/interactor.js +5 -5
- package/dist/src/interactor2.js +1 -1
- package/dist/src/interactor3.js +1 -1
- package/dist/src/interactor4.js +1 -1
- package/dist/src/interactor5.js +1 -1
- package/dist/src/interactors.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/companion-tunnel.js +1 -1
- package/dist/src/internal/daemon.js +1 -1
- package/dist/src/internal/png-worker.js +1 -1
- package/dist/src/internal/run-script-child.js +1 -1
- package/dist/src/inventory.js +1 -1
- package/dist/src/inventory2.js +1 -1
- package/dist/src/inventory3.js +1 -1
- package/dist/src/inventory5.js +1 -1
- package/dist/src/ios-node-interpretation.js +1 -1
- package/dist/src/ios-simulator-accessibility.js +1 -1
- package/dist/src/ios-snapshot-acquisition.js +1 -1
- package/dist/src/ios-snapshot-engine.js +1 -1
- package/dist/src/ios-snapshot-runtime.js +1 -1
- package/dist/src/launch-confirmation.js +1 -1
- package/dist/src/launch-services-registration.js +1 -1
- package/dist/src/lease-context.js +1 -1
- package/dist/src/lease-registry-scope.js +1 -1
- package/dist/src/lease-release2.js +1 -1
- package/dist/src/lease-scope.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/leased-recording-retention.js +1 -1
- package/dist/src/legacy.js +1 -1
- package/dist/src/limrun-download-file.js +1 -1
- package/dist/src/limrun-ios-files.js +1 -1
- package/dist/src/limrun-ios-runner.js +2 -2
- package/dist/src/limrun-runtime-dependencies.js +1 -1
- package/dist/src/limrun.d.ts +1 -1
- package/dist/src/local-interactor-operation-set.js +1 -1
- package/dist/src/local-simulator-apps.js +1 -1
- package/dist/src/local-simulator-files.js +1 -1
- package/dist/src/location-coordinates.js +1 -1
- package/dist/src/manifest.js +1 -1
- package/dist/src/mechanics.js +12 -12
- package/dist/src/merge-flags.js +1 -1
- package/dist/src/metro-reload-endpoints.js +1 -1
- package/dist/src/metro-session-hints.js +1 -1
- package/dist/src/metro.d.ts +1 -1
- package/dist/src/mobile-snapshot-semantics.js +1 -1
- package/dist/src/network-traffic.js +1 -1
- package/dist/src/node-http.js +1 -1
- package/dist/src/node-touch-point.js +1 -1
- package/dist/src/observation.js +1 -1
- package/dist/src/open-script.js +1 -1
- package/dist/src/open-target-device-resolution.js +1 -1
- package/dist/src/orientation.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 +2 -2
- package/dist/src/perf.js +1 -1
- package/dist/src/physical-device-control.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-apple-application-tools.js +1 -1
- package/dist/src/platform-runtime-claim-recovery.js +1 -1
- package/dist/src/platform-runtime-host.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +3 -3
- package/dist/src/platform-runtime-runtime-hints.js +1 -1
- package/dist/src/platform-runtime-screen-recording-apple-runner-transport.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-shutdown-error.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/plist.js +1 -1
- package/dist/src/plugins2.js +1 -1
- package/dist/src/png-crop-bytes.js +1 -1
- package/dist/src/png-resize.js +1 -1
- package/dist/src/png-size.js +1 -1
- package/dist/src/png-worker-client.js +1 -1
- package/dist/src/png.js +1 -1
- package/dist/src/post-gesture-stability.js +1 -1
- package/dist/src/process-executable-path.js +1 -0
- package/dist/src/process-exit.js +1 -1
- package/dist/src/provider-device-runtime.d.ts +2 -2
- package/dist/src/provider-limrun-credentials.js +1 -1
- package/dist/src/provider-plugin.d.ts +1 -1
- package/dist/src/provider-profile-fields.js +1 -1
- package/dist/src/provider-webdriver.js +1 -1
- package/dist/src/provider.js +1 -1
- package/dist/src/proxy.js +2 -2
- package/dist/src/react-devtools-connection.js +1 -1
- package/dist/src/react-devtools-inspect-command.js +1 -1
- package/dist/src/react-native-overlay2.js +2 -2
- package/dist/src/react-native.js +1 -1
- package/dist/src/react-profile-command.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/record-trace.js +1 -1
- package/dist/src/recording-gestures.js +1 -1
- package/dist/src/recording.js +1 -1
- package/dist/src/rect-center.js +1 -1
- package/dist/src/register-builtins.js +1 -1
- package/dist/src/registry.js +1 -1
- package/dist/src/remote-config-core.js +1 -1
- package/dist/src/remote-config-flags.js +1 -1
- package/dist/src/remote-connection-state.js +1 -1
- package/dist/src/replay-backend-host.js +1 -1
- package/dist/src/replay-divergence.js +1 -1
- package/dist/src/replay-maestro-backend.js +2 -2
- package/dist/src/replay.d.ts +1 -1
- package/dist/src/replay2.js +1 -1
- package/dist/src/reporting.js +1 -1
- package/dist/src/request-dispatch-disclosure.js +1 -1
- package/dist/src/request-ended-leases.js +1 -1
- package/dist/src/request-providers.js +1 -1
- package/dist/src/request-runtime-binding.js +1 -1
- package/dist/src/request.js +1 -1
- package/dist/src/result-serialization.js +2 -2
- package/dist/src/retry.js +1 -1
- package/dist/src/run-script-execution.js +6 -8
- package/dist/src/run-script-http.js +1 -1
- package/dist/src/runner-cache-metadata.js +1 -1
- package/dist/src/runner-cache-retention.js +1 -1
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-contract.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-device-set.js +1 -1
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-error-classification.js +2 -2
- package/dist/src/runner-exchange.js +1 -1
- package/dist/src/runner-io.js +1 -1
- package/dist/src/runner-launched-session.js +1 -1
- package/dist/src/runner-lease.js +1 -1
- package/dist/src/runner-lifecycle.js +1 -1
- package/dist/src/runner-operations-facade.js +1 -1
- package/dist/src/runner-panel.js +1 -1
- package/dist/src/runner-retention.js +1 -1
- package/dist/src/runner-runtime.js +1 -1
- package/dist/src/runner-selector-query.js +1 -1
- package/dist/src/runner-sequence.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-toolchain-identity.js +1 -1
- package/dist/src/runtime-admission.js +1 -1
- package/dist/src/runtime-deployment.js +1 -1
- package/dist/src/runtime-factory.js +1 -1
- package/dist/src/runtime-session.js +1 -1
- package/dist/src/runtime-transport-hints.js +1 -1
- package/dist/src/runtime.js +2 -2
- package/dist/src/runtime10.js +1 -1
- package/dist/src/runtime11.js +1 -1
- package/dist/src/runtime12.js +1 -1
- package/dist/src/runtime13.js +2 -2
- package/dist/src/runtime2.js +2 -2
- package/dist/src/runtime4.js +3 -3
- package/dist/src/runtime5.js +1 -1
- package/dist/src/runtime6.js +1 -1
- package/dist/src/runtime7.js +2 -2
- package/dist/src/runtime8.js +1 -1
- package/dist/src/runtime9.js +1 -1
- package/dist/src/screen-recording-admission-ledger.js +1 -0
- package/dist/src/screen-recording-completion.js +1 -1
- package/dist/src/screen-recording-options.js +1 -1
- package/dist/src/screen-recording-resource-recovery.js +1 -1
- package/dist/src/screen-recording-stop-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-size.js +1 -1
- package/dist/src/screenshot-image.js +1 -1
- package/dist/src/screenshot-runtime.js +1 -1
- package/dist/src/screenshot-runtime2.js +1 -1
- package/dist/src/screenshot.js +1 -1
- package/dist/src/screenshot2.js +1 -1
- package/dist/src/screenshot4.js +1 -1
- package/dist/src/script-source.js +1 -1
- package/dist/src/script.js +1 -1
- package/dist/src/scroll-command.js +1 -1
- package/dist/src/scroll-gesture.js +1 -1
- package/dist/src/sdk-batch-runner.d.ts +1 -1
- package/dist/src/sdk-batch-runner.js +2 -2
- package/dist/src/sdk-batch.js +2 -2
- package/dist/src/sdk-contracts.d.ts +26 -2
- package/dist/src/sdk-contracts.js +2 -2
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-finders.d.ts +1 -1
- package/dist/src/sdk-finders.js +1 -1
- package/dist/src/sdk-io.js +5 -5
- package/dist/src/sdk-remote-config.d.ts +1 -1
- package/dist/src/sdk-remote-config.js +1 -1
- package/dist/src/sdk-selectors.d.ts +9 -6
- package/dist/src/sdk-selectors.js +1 -1
- package/dist/src/selection.js +0 -0
- package/dist/src/selector-pipeline-policy.js +1 -1
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.js +1 -1
- package/dist/src/server-shutdown.js +1 -1
- package/dist/src/server-startup.js +2 -2
- package/dist/src/server.js +4 -4
- package/dist/src/session-allocation.js +1 -1
- package/dist/src/session-artifact-paths.js +1 -1
- package/dist/src/session-capture-binding.js +1 -1
- package/dist/src/session-device-resolution.js +1 -1
- package/dist/src/session-event-action.js +1 -1
- package/dist/src/session-open.js +1 -1
- package/dist/src/session-repair-tombstone.js +1 -1
- package/dist/src/session-replay-vars.js +1 -1
- package/dist/src/session-routing.js +1 -1
- package/dist/src/session-runtime-admission.js +1 -1
- package/dist/src/session-runtime.js +1 -1
- package/dist/src/session-script-destination.js +1 -0
- package/dist/src/session-selector.js +1 -1
- package/dist/src/session-store.js +3 -3
- package/dist/src/session-teardown.js +1 -1
- package/dist/src/session-tenant-scope.js +1 -1
- package/dist/src/session2.js +5 -5
- package/dist/src/settings-bluetooth.js +1 -1
- package/dist/src/settings-global-toggle.js +1 -1
- package/dist/src/settings.js +1 -1
- package/dist/src/settings2.js +1 -1
- package/dist/src/settle-observation-capture.js +1 -1
- package/dist/src/simctl-execution.js +1 -1
- package/dist/src/simctl-facade.js +1 -1
- package/dist/src/simctl.js +1 -1
- package/dist/src/simulator-app-budget.js +1 -1
- package/dist/src/simulator-boot.js +1 -1
- package/dist/src/simulator-facade.js +1 -1
- package/dist/src/simulator-state.js +1 -1
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-baseline.js +1 -1
- package/dist/src/snapshot-chrome.js +1 -1
- package/dist/src/snapshot-desktop-projection.js +1 -1
- package/dist/src/snapshot-diagnostics.js +1 -1
- package/dist/src/snapshot-helper-install.js +3 -3
- package/dist/src/snapshot-helper-session.js +1 -1
- package/dist/src/snapshot-lines.js +1 -1
- package/dist/src/snapshot-node-lookup.js +1 -1
- package/dist/src/snapshot-occlusion.js +1 -1
- package/dist/src/snapshot-private-evidence.js +1 -1
- package/dist/src/snapshot-runtime-binding.js +1 -1
- package/dist/src/snapshot-runtime-capture-input.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-state.js +1 -1
- package/dist/src/snapshot.js +1 -1
- package/dist/src/snapshot2.js +1 -1
- package/dist/src/snapshot3.js +2 -2
- package/dist/src/snapshot4.js +1 -1
- package/dist/src/source-channel.js +1 -1
- package/dist/src/src.js +1 -1
- package/dist/src/src10.js +1 -1
- package/dist/src/src11.js +1 -1
- package/dist/src/src2.js +1 -1
- package/dist/src/src3.js +5 -5
- package/dist/src/src4.js +2 -2
- package/dist/src/src5.js +1 -1
- package/dist/src/src6.js +1 -1
- package/dist/src/src8.js +1 -1
- package/dist/src/store-legacy.js +1 -1
- package/dist/src/store.js +1 -1
- package/dist/src/string-enum.js +1 -1
- package/dist/src/surface-snapshot.js +1 -1
- package/dist/src/surface-snapshot2.js +1 -1
- package/dist/src/sync-cache.js +1 -1
- package/dist/src/system-surface-foreground.js +2 -2
- package/dist/src/takeover.js +1 -1
- package/dist/src/tap-keyboard-occlusion.js +1 -1
- package/dist/src/target-evidence-tree.js +1 -1
- package/dist/src/target-evidence.js +1 -1
- package/dist/src/telephony-runtime.js +1 -1
- package/dist/src/tool-provider-facade.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 -1
- package/dist/src/transport.js +2 -2
- package/dist/src/tree.js +1 -1
- package/dist/src/tv-remote-runtime.js +1 -1
- package/dist/src/tv-remote.js +1 -1
- package/dist/src/type-text-runtime.js +1 -1
- package/dist/src/unsupported-interactor.js +1 -1
- package/dist/src/update-check.js +1 -1
- package/dist/src/validation.js +1 -1
- package/dist/src/vars.js +1 -1
- package/dist/src/vega-executable.js +1 -1
- package/dist/src/verified-file.js +1 -1
- package/dist/src/video.js +2 -2
- package/dist/src/viewport.js +1 -1
- package/dist/src/web.js +1 -1
- package/dist/src/webdriver-source.js +1 -1
- package/package.json +2 -2
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.37.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.37.apk.sha256 +0 -1
- package/dist/src/capture-output-ownership.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e,z as t}from"../sdk-contracts.js";import{N as n}from"../sdk-batch-runner.js";import{ct as r}from"../sdk-io.js";import"../command.js";import{n as i,t as a}from"../run-script-http.js";import{r as o,t as s}from"../run-script-execution.js";import c,{readFileSync as l}from"node:fs";import u from"node:vm";const d=1e3,f=a*6+1048576;function p(n){try{return{outputEnv:m(JSON.parse(n))}}catch(n){if(n instanceof e)return{error:{code:n.code,message:n.message,details:n.details}};let r=t(n);return{error:{code:r.code,message:r.message}}}}function m(r){let{scriptPath:i,env:a,publicNetworkOnly:o}=r,l=c.readFileSync(i,`utf8`),d=Object.create(null);try{u.runInNewContext(l,h(a,d,o),{filename:i,timeout:s})}catch(r){let a=t(r);throw new e(a.code,`Maestro runScript failed: ${a.message}`,n({...a.details??{},hint:a.hint,diagnosticId:a.diagnosticId,logPath:a.logPath,retriable:a.retriable,supportedOn:a.supportedOn,scriptPath:i}),r instanceof Error?r:void 0)}return S(d,i),Object.fromEntries(Object.entries(d).map(([e,t])=>[`output.${e}`,C(t)]))}function h(e,t,n){return{...e,output:t,json:g,http:{post:(e,t)=>v(`POST`,e,n,t)}}}function g(t){if(typeof t!=`string`)throw new e(`COMMAND_FAILED`,`Maestro runScript json() expected a string body, received ${typeof t}.`);if(t.trim().length===0)throw new e(`COMMAND_FAILED`,`Maestro runScript json() received an empty body.`,{hint:`Check the preceding HTTP response status and setup server output.`});try{return JSON.parse(t,_)}catch(n){throw new e(`COMMAND_FAILED`,`Maestro runScript json() could not parse response body: ${n instanceof Error?n.message:String(n)}`,{bodyPreview:t.slice(0,d)},n instanceof Error?n:void 0)}}function _(e,t){return e===`__proto__`||e===`constructor`||e===`prototype`?void 0:t}function v(t,n,a,o){let s=r(process.execPath,b(),{stdin:JSON.stringify(x(t,n,o,a)),timeoutMs:i+5e3,allowFailure:!0,maxBuffer:f}),c=y(s.stdout);if(c&&`response`in c)return c.response;throw c?new e(c.error.code,c.error.message,{...c.error.details,url:n}):s.exitCode===0?new e(`COMMAND_FAILED`,`Maestro runScript http.${t.toLowerCase()} returned invalid JSON for ${n}`,{stdout:s.stdout.slice(0,d),stderr:s.stderr.slice(0,d)}):new e(`COMMAND_FAILED`,`Maestro runScript http.${t.toLowerCase()} failed for ${n}: ${w(s.stderr)}`,{exitCode:s.exitCode,stderr:s.stderr})}function y(e){try{let t=JSON.parse(e);return t&&typeof t==`object`&&(`response`in t||`error`in t)?t:void 0}catch{return}}function b(){return o(`run-script-http-child`)}function x(e,t,n,r){return{method:e,url:t,headers:n?.headers??{},body:n?.body??``,publicNetworkOnly:r}}function S(t,n){for(let r of Object.keys(t))if(r.includes(`.`))throw new e(`INVALID_ARGS`,`Maestro runScript output key cannot contain ".": ${r}`,{scriptPath:n,key:r})}function C(e){return typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function w(e){let t=e.trim();return t.length>0?t.slice(0,d):`request process exited without stderr`}process.stdout.write(JSON.stringify(p(l(0,`utf8`))));export{};
|
package/dist/src/inventory.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e,x as t}from"./sdk-contracts.js";import{n,o as r}from"./device-shell.js";import{a as i,r as a}from"./adb-failure.js";import{a as o,c as s,i as c,l,n as u,o as d,r as f,s as p,t as m}from"./inventory-parsers.js";import h from"node:path";const g=1e4,_=r(`getprop ro.product.model; getprop ro.build.version.release`),v=[`android.software.leanback`,`android.software.leanback_only`,`android.hardware.type.television`,`amazon.hardware.fire_tv`];function y(e,t={sdkRoots:[]}){return{discover:async(n,r)=>await b(e,t,n,r)}}async function b(t,n,r,i){await t.toolchains.prepare(`android`);let a=[...n.sdkRoots,...t.homeDirectory===void 0?[]:[h.join(t.homeDirectory,`Android`,`Sdk`)]],o=await S(t,`adb`,a,[`platform-tools`,`adb`]);if(!o)throw new e(`TOOL_MISSING`,`adb not found in PATH`);let s={host:t,adb:o,emulator:await S(t,`emulator`,a,[`emulator`,`emulator`]),scope:i},c=x(r),l=await I((await C(s)).filter(e=>!c||c.has(e.serial)),3,async e=>await w(s,e));return[...l,...r.androidAvdSelection===`running-only`?[]:await j(s,l)]}function x(e){let t=e.serial?.trim(),n=e.androidSerialAllowlist;return t?n?new Set(n.includes(t)?[t]:[]):new Set([t]):n?new Set(n):void 0}async function S(e,t,n,r){for(let t of n){let n=h.join(t,...r);if(await e.files.isExecutable(n))return n}return await e.commands.which(t)}async function C(e){let t=await P(e,e.adb,[`devices`,`-l`]);if(t.exitCode!==0)throw a(`Failed to list Android devices`,t,"Verify adb is running and the device appears in `adb devices`.");return p(t.stdout)}async function w(e,t){let[n,r,i,a]=await Promise.all([E(e,t),k(e,t.serial),A(e,t.serial),T(e,t.serial)]);return{platform:`android`,id:t.serial,name:n,kind:f(t.serial)?`emulator`:`device`,target:i,...a,booted:r}}async function T(e,t){try{let n=await N(e,t,[_],2e3);return n.exitCode===0?d(n.stdout):{}}catch(t){if(e.scope.signal.aborted)throw t;return{}}}async function E(e,t){let n=t.rawModel.replaceAll(`_`,` `).trim();return f(t.serial)?(await D(e,t.serial))?.replaceAll(`_`,` `)||n||t.serial:n||t.serial}async function D(e,t){for(let n of[`ro.boot.qemu.avd_name`,`persist.sys.avd_name`]){let r=await O(e,M(t,[`getprop`,n])),i=r?.stdout.trim();if(r?.exitCode===0&&i)return i}let n=await O(e,[`-s`,t,`emu`,`avd`,`name`]),r=n&&s(n.stdout);return n?.exitCode===0?r:void 0}async function O(e,n){try{return await P(e,e.adb,n)}catch(e){let n=t(e);if(n.code===`COMMAND_FAILED`&&typeof n.details?.timeoutMs==`number`)return;throw e}}async function k(e,t){try{return(await N(e,t,[`getprop`,`sys.boot_completed`])).stdout.trim()===`1`}catch(t){if(e.scope.signal.aborted)throw t;return!1}}async function A(e,t){let n=await N(e,t,[`getprop`,`ro.build.characteristics`]);if(l(F(n))===`tv`||(await I(v,2,async n=>await N(e,t,[`cmd`,`package`,`has-feature`,n]))).some(e=>F(e).toLowerCase().includes(`true`)))return`tv`;let r=F(await N(e,t,[`pm`,`list`,`features`]));return v.some(e=>m(r,e))?`tv`:`mobile`}async function j(e,t){if(!e.emulator)return[];let n;try{n=await P(e,e.emulator,[`-list-avds`])}catch(t){if(e.scope.signal.aborted)throw t;return[]}if(n.exitCode!==0)return[];let r=new Set(t.filter(e=>e.kind===`emulator`).map(e=>c(e.name)));return o(n.stdout).filter(e=>!r.has(c(e))).map(e=>({platform:`android`,id:e,name:e,kind:`emulator`,target:u(e),booted:!1}))}function M(e,t){return n(`adb`,`shell`,t,[`-s`,e])}async function N(e,t,n,r=g){return await P(e,e.adb,M(t,n),r)}async function P(e,t,n,r=g){try{return await e.host.commands.run({executable:t,args:n,allowFailure:!0,timeoutMs:r},e.scope.signal)}catch(e){throw i(e)}}function F(e){return`${e.stdout}\n${e.stderr}`}async function I(e,t,n){let r=Array(e.length),i=0;return await Promise.all(Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let t=i++;r[t]=await n(e[t])}})),r}export{y as createAndroidInventory};
|
package/dist/src/inventory2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{W as t}from"./sdk-device.js";import{r as n}from"./physical-device-constants.js";import{l as r}from"./simctl.js";const i=/^(iphone|ipad|ipod|appletv|realitydevice)/i,a=/ipad/i,o=/\b(apple vision|vision pro|xros|visionos|realitydevice)\b/i,s=/\b(iphone|ipad|ipod)\b/i,c=/^appletv/i,l=[`apple tv`,`appletv`,`tvos`];function u(e){return(e??``).trim().toLowerCase()}function d(e){return e.includes(`tvos`)}function f(e){return e.includes(`xros`)||e.includes(`visionos`)}function p(e){return d(u(e))?`tv`:`mobile`}function m(e){let t=u(e);return t.includes(`ios`)||t.includes(`tvos`)||t.includes(`xros`)||t.includes(`visionos`)}function h(e){let t=u(e);return l.some(e=>t.includes(e))}function g(e){return s.test(e.trim())}function _(e){return h(e)?`tv`:g(e)||o.test(e)?`mobile`:null}function v(e,t){return e===`tv`?`tvos`:t.some(e=>o.test(e))?`visionos`:t.some(e=>a.test(e))?`ipados`:`ios`}function y(e){return i.test(e.trim())}function b(e){return c.test(e.trim())}function x(e){return[e.name??``,e.deviceProperties?.name??``,e.deviceProperties?.deviceType??``]}function S(e){return e.hardwareProperties?.productType??e.deviceProperties?.productType??``}function C(e){return d(u(e.hardwareProperties?.platform))||b(S(e))||x(e).some(h)?`tv`:`mobile`}function w(e){let t=u(e.hardwareProperties?.platform);return t.includes(`ios`)||d(t)||f(t)||y(S(e))?!0:x(e).some(h)}function T(e){if(!w(e))return null;let t=e.hardwareProperties?.udid??e.identifier??``,r=e.name??e.deviceProperties?.name??t;if(!t)return null;let i=C(e),a=e.hardwareProperties?.marketingName?.trim(),o=e.deviceProperties?.osVersionNumber?.trim();return{platform:`apple`,id:t,name:r,kind:`device`,target:i,appleOs:v(i,[S(e),...x(e)]),...a?{model:a}:{},...o?{osVersion:o}:{},iosPhysicalDeviceBackend:`coredevice`,booted:n(e.connectionProperties?.tunnelState)}}const E=/^==\s*(.+?)\s*==$/,D=/^(?<name>.+?)\s+(?:\[(?<idBracket>[^[\]]+)\]|\((?<osVersion>[^)]+)\)\s+\((?<idParen>[^)]+)\))\s*$/;function O(e){let t=[],n=null;for(let r of e.split(/\r?\n/)){let e=r.trim();if(!e)continue;let i=E.exec(e);if(i){n=i[1]?.trim()??null;continue}if(n!==`Devices`)continue;let a=k(e);a&&t.push(a)}return t}function k(e){let t=D.exec(e)?.groups;if(!t)return;let n=t.name?.trim(),r=t.idBracket?.trim()||t.idParen?.trim();if(!n||!r)return;let i=_(n);if(!i)return;let a=t.osVersion?.trim();return{platform:`apple`,id:r,name:n,kind:`device`,target:i,appleOs:v(i,a?[n,a]:[n]),...a?{osVersion:a}:{},iosPhysicalDeviceBackend:`xctest`,booted:!0}}async function A(e,t){let[n,r]=await Promise.all([j(e,t),M(e,t)]);return N(n,r)}async function j(e,t){let n;try{return n=await e.files.createTemporaryTextFile({prefix:`agent-device-devicectl-`,suffix:`.json`}),(await e.appleTools.run({tool:`devicectl`,args:[`list`,`devices`,`--json-output`,n.path],allowFailure:!0,timeoutMs:8e3},t.signal)).exitCode===0?(JSON.parse(await n.readText()).result?.devices??[]).flatMap(e=>{let t=T(e);return t?[t]:[]}):[]}catch{return t.signal.throwIfAborted(),[]}finally{try{await n?.[Symbol.asyncDispose]()}catch{}}}async function M(e,t){try{let n=await e.appleTools.run({tool:`xctrace`,args:[`list`,`devices`],allowFailure:!0},t.signal);return n.exitCode===0?O(n.stdout):[]}catch{return t.signal.throwIfAborted(),[]}}function N(e,t){let n=new Set(e.map(e=>e.id)),r=[...e];for(let e of t)n.has(e.id)||(n.add(e.id),r.push(e));return r}function P(e,t){let n=F(e),r=[];for(let[i,a]of Object.entries(e.devices))if(m(i))for(let e of a){if(!e.isAvailable)continue;let a=p(i);r.push({platform:`apple`,id:e.udid,name:e.name,kind:`simulator`,target:a,appleOs:v(a,[i,e.deviceTypeIdentifier??``,e.name]),...n(i,e),booted:e.state===`Booted`,...t?{simulatorSetPath:t}:{}})}return r}function F(e){let t=new Map(e.devicetypes?.map(e=>[e.identifier,e.name])),n=new Map(e.runtimes?.map(e=>[e.identifier,e.version]));return(e,r)=>{let i=t.get(r.deviceTypeIdentifier??``),a=n.get(e);return{...i?{model:i}:{},...a?{osVersion:a}:{}}}}async function I(n,i,a){let o=i.iosSimulatorSetPath?.trim()||void 0,s=await n.appleTools.run({tool:`simctl`,args:r(o),...i.booted===!0?{timeoutMs:3e3}:{}},a.signal),c;try{c=P(JSON.parse(s.stdout),o)}catch(t){throw new e(`COMMAND_FAILED`,`Failed to parse simctl devices JSON`,void 0,t)}for(let e of c)e.booted===!0&&await n.observations.deviceBooted(e);return t(c)}function L(e){return Object.freeze({discover:async(t,n)=>await R(e,t,n)})}async function R(n,r,i){if(z(r))return[H(n)];if(n.hostOs!==`darwin`)throw V(n.hostOs);if(!await n.appleTools.isXcrunAvailable(i.signal))throw new e(`TOOL_MISSING`,`xcrun not found in PATH`);let a=I(n,r,i);if(r.kind===`simulator`)return await a;if(r.iosSimulatorSetPath||r.udid){let e=await a,o=[...e,H(n)];if(r.iosSimulatorSetPath||e.some(e=>e.id===r.udid))return t(o);let s=await A(n,i);return t(U(o,s))}let[o,s]=await Promise.all([a,A(n,i)]),c=[...o,H(n)];return t(U(c,s))}function z(e){return e.platform===`macos`||e.platform===`apple`&&e.target===`desktop`}const B={darwin:`macOS`,linux:`Linux`,win32:`Windows`,other:`a non-macOS host`};function V(t){return new e(`UNSUPPORTED_PLATFORM`,`Apple tools are only available on macOS`,{supportedOn:`macOS`,hostOs:t,retriable:!1,hint:`This host runs ${B[t]}, so it cannot boot iOS Simulators or run macOS sessions. Drive Android here instead with the same command shape: agent-device devices --platform android to list targets, then agent-device open <app.apk> --platform android. To use an iOS Simulator from this machine, run agent-device on a macOS host and pass --daemon-base-url <that daemon URL>.`})}function H(e){return{platform:`apple`,id:`host-macos-local`,name:e.hostName,kind:`device`,target:`desktop`,appleOs:`macos`,booted:!0}}function U(e,t){let n=new Set(e.map(e=>e.id));return[...e,...t.filter(e=>!n.has(e.id)&&(n.add(e.id),!0))]}export{L as createAppleInventorySource};
|
package/dist/src/inventory3.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{n as t}from"./device-shell.js";import n from"node:path";function r(e,t={}){return{discover:async(n,r)=>await a(e,t,n,r)}}function i(e){return e.split(`
|
|
2
2
|
`).map(e=>e.trim()).filter(e=>e.length>0&&e!==`[Empty]`)}async function a(t,n,r,a){await t.toolchains.prepare(`harmonyos`);let u=await s(t,o(n));if(!u)throw new e(`TOOL_MISSING`,`hdc not found in PATH`,{hint:`Install HarmonyOS Command Line Tools, then add its sdk/default/openharmony/toolchains directory to PATH.`});let d=await l(t,u,[`list`,`targets`],a);if(d.exitCode!==0)throw new e(`COMMAND_FAILED`,`hdc list targets failed`,{stderr:d.stderr,hint:`Confirm the HarmonyOS emulator or device is running, then run hdc list targets.`});let f=i(d.stdout).filter(e=>!r.serial||r.serial===e);return await Promise.all(f.map(async e=>await c(t,u,e,a)))}function o(e){return[e.hdcSdkPath,e.devecoSdkHome&&n.join(e.devecoSdkHome,`default`,`openharmony`,`toolchains`),e.commandLineToolsHome&&n.join(e.commandLineToolsHome,`sdk`,`default`,`openharmony`,`toolchains`)].filter(e=>e!==void 0)}async function s(e,t){for(let r of t){let t=n.join(r,`hdc`);if(await e.files.isExecutable(t))return t}return await e.commands.which(`hdc`)}async function c(e,n,r,i){let[a,o]=await Promise.all([l(e,n,t(`hdc`,`shell`,[`param`,`get`,`const.product.name`],[`-t`,r]),i),l(e,n,t(`hdc`,`shell`,[`param`,`get`,`const.build.characteristics`],[`-t`,r]),i)]),s=a.exitCode===0?a.stdout.trim():``,c=s.toLowerCase()===`emulator`;return{platform:`harmonyos`,id:r,name:s||r,kind:c?`emulator`:`device`,target:o.stdout.toLowerCase().includes(`tv`)?`tv`:`mobile`,booted:!0}}async function l(e,t,n,r){return await e.commands.run({executable:t,args:n,allowFailure:!0,timeoutMs:1e4},r.signal)}export{r as createHarmonyInventory};
|
package/dist/src/inventory5.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{et as t}from"./sdk-io.js";import"./command.js";import{n}from"./vega-executable.js";const r=`VirtualDevice`;function i(e){return{discover:async(t,n)=>await o(e,n)}}function a(e){return u(e).some(l)?[{platform:`vega`,id:r,name:`Vega Virtual Device (${r})`,kind:`emulator`,target:`tv`,booted:!0}]:[]}async function o(t,n){let r=await s(t);if(!r)throw new e(`TOOL_MISSING`,`Vega CLI not found in PATH`,{hint:`Install Vega Developer Tools, source ~/vega/env, and retry devices.`});let i=await t.commands.run({executable:r,args:[`device`,`list`],allowFailure:!0,timeoutMs:1e4},n.signal);c(i);let o=a(i.stdout),l=u(i.stdout);if(o.length===0&&l.length>0)throw new e(`DEVICE_NOT_FOUND`,`Vega CLI found devices, but no supported Vega Virtual Device is running.`,{listedSerials:l,hint:`Start the Vega Virtual Device, then retry with --platform vega --target tv.`});return o}async function s(e){return await n({which:t=>e.commands.which(t),isExecutableFile:t=>e.files.isExecutable(t),homeDirectory:e.homeDirectory})}function c(e){t(e,`Failed to list Vega devices`)}function l(e){return e.toLowerCase()===`virtualdevice`}function u(e){let t=new Set;for(let n of e.split(/\r?\n/)){let e=/^\s*([^\s:]+)\s*:\s*\S/.exec(n)?.[1]?.trim();e&&t.add(e)}return[...t]}export{i as createVegaInventory};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{di as e}from"./sdk-batch.js";function t(e,t={}){let r=e.type?.replace(/^XCUIElementType/,``),i=[`TextField`,`SecureTextField`,`SearchField`,`TextView`].includes(r??``),a=[`Switch`,`CheckBox`,`RadioButton`,`Toggle`].includes(r??``),s={};if(a&&e.checked===void 0){let t=n(e.value);t!==void 0&&(s.checked=t)}i&&(e.password===void 0&&(s.password=r===`SecureTextField`),e.editable===void 0&&(s.editable=!0));let c=Object.keys(s).length===0?e:{...e,...s};return t.reactNativeValue===!1?c:o(c)}function n(e){if(e===`1`||e===`true`)return!0;if(e===`0`||e===`false`)return!1}const r=new Set([`RCTView`,`RCTViewComponentView`]),i={alert:`alert`,checkbox:`checkbox`,"combo box":`combobox`,menu:`menu`,"menu bar":`menubar`,"menu item":`menuitem`,"progress bar":`progressbar`,"radio button":`radio`,"radio group":`radiogroup`,"scroll bar":`scrollbar`,"spin button":`spinbutton`,switch:`switch`,tab:`tab`,"tab list":`tablist`,timer:`timer`,"tool bar":`toolbar`},a={checked:{checked:!0},unchecked:{checked:!1},mixed:{checked:`mixed`},expanded:{expanded:!0},collapsed:{expanded:!1},busy:{busy:!0}};function o(e){if(e.iosValueSemantics||typeof e.value!=`string`||!s(e))return e;let t=l(e.value,e.role);return!t||!c(e,t)?e:{...e,iosValueSemantics:t,...e.checked===void 0&&typeof t.checked==`boolean`?{checked:t.checked}:{}}}function s(t){return e(t.type??``)!==`other`||t.editable||t.password?!1:r.has(t.role??``)?!0:t.role===void 0||e(t.role)===`other`}function c(e,t){let n=t.role===`checkbox`||t.role===`radio`;return t.role!==void 0&&!n&&e.role!==`RCTView`?!1:r.has(e.role??``)?!0:n&&t.checked!==void 0}function l(e,t){let n=e.split(`, `),r=n[0]??``,o=Object.hasOwn(i,r)?i[r]:void 0,s={source:`react-native-ios-value-heuristic`,encoding:`en`,...o===void 0?{}:{role:o}},c=0;for(let e of n.slice(o===void 0?0:1)){if(!Object.hasOwn(a,e))break;let n=a[e];if(Object.keys(n).some(e=>Object.hasOwn(s,e)))break;let r=u(n);if(t===`RCTViewComponentView`&&r<c)break;c=r,Object.assign(s,n)}return s.role!==void 0||s.checked!==void 0||s.expanded!==void 0||s.busy!==void 0?s:void 0}function u(e){return e.checked===void 0?e.expanded===void 0?3:2:1}export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{z as e}from"./sdk-contracts.js";import{St as t}from"./sdk-io.js";import"./diagnostics.js";import{S as n}from"./sdk-device.js";import{f as r,g as i}from"./host-file.js";import{c as a,i as o}from"./tool-provider.js";import{d as s,r as c}from"./simctl.js";import{t as l}from"./plist.js";import u from"node:path";async function d(e){n(e)&&await a(c(e,[`spawn`,e.id,`defaults`,`write`,`com.apple.Accessibility`,`ApplicationAccessibilityEnabled`,`-bool`,`YES`]),{timeoutMs:2e3})}async function f(r){if(n(r)&&await p(r)!==`enabled`)try{await d(r)}catch(n){t({level:`warn`,phase:`ios_simulator_accessibility_prepare_failed`,data:{deviceId:r.id,error:e(n)}})}}async function p(e){if(o())return`unknown`;try{let{udid:t,simulatorSetPath:n}=s(e),a=n??u.join(r(),`Library/Developer/CoreSimulator/Devices`),o=u.join(a,t,`data/Library/Preferences/com.apple.Accessibility.plist`),c=await l(await i(o));if(!c)return`unknown`;let d=c.ApplicationAccessibilityEnabled;return d===void 0||d===!0||d===1?`enabled`:d===!1||d===0?`disabled`:`unknown`}catch{return`unknown`}}export{d as enableIosSimulatorAppAccessibility,f as prepareIosSimulatorAccessibility};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Mi as e,di as t,hi as n}from"./sdk-batch.js";function r(t,n,r){let i=[{kind:`unavailable-fact`,fact:`hittability`},{kind:`unavailable-fact`,fact:`acquisition-depth`}];return e[t].truncation===`unavailable`&&i.push({kind:`unavailable-fact`,fact:`truncation`}),n.kind===`missing`&&i.push({kind:`missing-viewport`,reason:n.reason}),r&&i.push({kind:`collapsed-tab-bar-probe-failed`,reason:r}),Object.freeze(i)}function i(e){return{stage:`acquired`,acquisition:{producer:e.producer,intent:`full`,nodes:e.nodes,viewport:e.viewport,...e.keyboard?{keyboard:e.keyboard}:{},lineage:e.lineage,residue:r(e.producer,e.viewport,e.collapsedTabBarProbeFailure)}}}function a(e,t={}){let r=e.filter(o),i=[...r.length>0||t.fallbackToLargestRoot!==!0?r:e].sort(s)[0];if(i)return n(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 o(e){let n=t(e.type??``);return n===`application`||n===`window`}function s(e,t){return c(t.rectStatus)-c(e.rectStatus)||l(t.rect)-l(e.rect)}function c(e){return e===`reported`?2:+(e===`invalid`)}function l(e){return e&&n(e)?e.width*e.height:0}export{a as n,i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{x as e}from"./sdk-contracts.js";import{Ai as t,Ei as n,Ii as r,Ni as i,Oi as a,Pi as o,ei as s,ki as c,ri as l,si as u}from"./sdk-batch.js";import{n as d}from"./rect-center.js";import{n as f,t as p}from"./scroll-indicator.js";import{i as m,n as h,t as g}from"./ios-snapshot-planning.js";import{_,a as v,c as y,d as ee,f as b,g as te,h as ne,i as x,l as re,m as S,n as C,o as w,p as T,r as E,t as D,u as ie}from"./tree.js";import{a as ae,i as oe,o as O,s as se}from"./react-native-overlay.js";function ce(e,t){let n=v(t.sourceNodesByIndex.values());for(let r of e)le(r,t.sourceNodesByIndex,n)&&S(t.replacements,r,{type:`Cell`})}function le(e,t,n){return!(u(e.type??``)!==`other`||e.enabled===!1||!e.rect||!fe(e.label)||!w(e,t,de)||!ue(e)||ie(e.rect,n))}function ue(e){return e.rect?e.rect.height>=44&&e.rect.height<=160&&e.rect.width>=120:!1}function de(e){let t=u(e.type??``);return t===`scrollview`||t===`scrollarea`}function fe(e){let t=e?.trim();return!(!t||/^(toolbar|window|application)$/i.test(t)||t.startsWith(`!,`)||/debugger|fast refresh/i.test(t))}function pe(e,t){let n=new Set;for(let r of e)me(t.replacements.get(r.index)??r)&&he(r,t.sourceNodesByIndex,t,n);ye(e,t,n)}function me(e){let t=e.label?.trim();return!!(t&&f(t))}function he(e,t,n,r){let i=!b(e.type)||n.isSuppressed(e),a=p(e.label?.trim()??``,e.value),o=a?ve(e,t):void 0;i&&n.suppressNode(e,o?[o]:[]),o&&a&&De(n,o,e,a)&&r.add(o.index)}function ge(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function _e(e,t){return e.rect!=null&&t.rect!=null&&k(e.rect,t.rect)}function ve(e,t){if(b(e.type))return null;let n=ge(e,t);for(;n&&!b(n.type);){let e=ge(n,t);if(!e||!_e(n,e))return null;n=e}return n??null}function ye(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=Ee(o.rect,a),c=be(o,a,s),l=xe(e,c,o);Se(t,i,o,a,s,c,l),r.set(i.index,Ce(i,o,a,s,l,n))}}function be(e,t,n){return!!(t&&c(e.rect)&&!c(n))}function xe(e,t,n){return!!(e?.projectedOut||t&&Te(n))}function Se(e,t,n,r,i,a,o){o||a?e.suppressNode(t,[]):r&&i&&!k(n.rect,i)&&S(e.replacements,t,{rect:i})}function Ce(e,t,n,r,i,a){return{projectedOut:i,...we(e,t,n,r,a)?{clip:r}:n?{clip:n}:{}}}function we(e,t,n,r,i){return!!(c(r)&&(i.has(e.index)||n!==void 0&&b(t.type)))}function Te(e){return e.type?.trim().toLowerCase()===`cell`||b(e.type)}function Ee(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 De(e,t,n,r){let i=Oe((e.replacements.get(t.index)??t).rect,n.rect);return _(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 Oe(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 r=e[n],i=r?.label?.trim();r&&i&&u(r.type??``)===`other`&&t(r,i,n)}}function ke(e,t){j(e,(n,r,i)=>{if(!O(r)||!n.rect)return;let a=x(e,i,e=>!!e.rect&&se(e.label?.trim()??``));if(!a?.rect)return;let o=je(n.rect,a.rect);if(!o)return;let s=Ae(e,i,o);S(t,n,{rect:s}),y(e,i,e=>{O(e.label?.trim()??``)&&S(t,e,{rect:s})})})}function Ae(e,t,n){let r=n;return y(e,t,e=>{let t=e.label?.trim()??``;!e.rect||!O(t)||o(n,e.rect)&&i(e.rect)<i(r)&&(r=e.rect)}),r}function je(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&&d(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&&d(t,a))return{...e,x:r,width:n-r}}function Me(e,t){j(e,(n,r,i)=>{oe(n)&&ae(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 Ne(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||!Pe(i,r)||(t.suppressNode(i,[]),Fe(i,t,r),y(e,n,e=>{t.suppressNode(e,[])}))}}function Pe(e,t){return!e.rect||u(e.type??``)!==`keyboard`?!1:e.rect.y>=t}function Fe(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 Ie(e,t){for(let n=0;n<e.length;n+=1){let r=e[n];if(!r)continue;if(Le(r)){ze(e,n,r,t);continue}if(!Re(r))continue;let i=x(e,n,e=>u(e.type??``)===`searchfield`&&e.label===`Search`);i&&(t.suppressNode(r,[i]),Be(r,i,t),ze(e,n,i,t))}}function Le(e){return u(e.type??``)===`searchfield`&&e.label===`Search`}function Re(e){let t=u(e.type??``);return e.label===`Toolbar`&&(t===`toolbar`||t===`searchfield`)}function ze(e,t,n,r){y(e,t,e=>{e.index!==n.index&&Ve(e)&&r.suppressNode(e,[n])})}function Be(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 Ve(e){let t=u(e.type??``);return t===`button`?!1:t===`image`||e.label===`Search`}function He(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?.label?.trim();!r||t.isSuppressed(r)||!i||Ue(e,n,r,i,t)}}function Ue(e,t,n,r,i){let a=u(n.type??``);if(a===`statictext`||a===`link`){N(e,t,r,n,i);return}if(a!==`other`)return;let o=!s(n)&&We(e,t,r);if(o){i.suppressNode(n,[o]);return}N(e,t,r,n,i)}function We(e,t,n){return x(e,t,e=>{let t=u(e.type??``);return(t===`link`||t===`searchfield`||b(e.type))&&e.label?.trim()===n})}function N(e,t,n,r,i){y(e,t,e=>{!i.semanticRepresentativeIndexes.has(e.index)&&ee(e,n)&&i.suppressNode(e,[r])})}function Ge(e,t){j(e,(n,r,i)=>{if(s(n))return;let a=x(e,i,e=>T(e)&&e.label?.trim()===r&&(d(e.rect,n.rect)||Ke(n,e)));a&&t.suppressNode(n,[a])})}function Ke(e,t){if(t.label?.trim()!==e.label?.trim())return!1;let n=u(t.type??``);return qe(e,n)||n===`textfield`||Je(e,n,t)}function qe(e,t){let n=e.label?.trim();return t===`button`&&(n===`Dismiss`||n===`Back`)}function Je(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 Ye(e,t){let n=D(e);for(let r of e){if(u(r.type??``)!==`other`||r.hittable===!0||r.label?.trim()||r.value?.trim()||!r.identifier?.trim())continue;let e=E(r,n);(e.length!==0||r.hittable===!1)&&t.suppressNode(r,e)}}function Xe(e,t){Ne(e,t),Ye(e,t),pe(e,t),Ie(e,t),Ge(e,t),ke(e,t.replacements),Me(e,t),He(e,t)}function Ze(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?Qe(e,n,r,t):void 0;!r?.rect||!i||tt(e,n,r,i,t)}}function Qe(e,t,n,r){let i=n.label?.trim();if(u(n.type??``)!==`cell`||i&&!$e(i,n.identifier)&&!f(i))return i;let a=C(e,t).find(et),o=a?.label?.trim();return!a||!o?i:(S(r.replacements,n,{label:o}),r.suppressNode(a,[n]),o)}function $e(e,t){return t?.trim()===e&&/^[A-Z_$][A-Za-z0-9_$]*Cell$/.test(e)}function et(e){if(!e.label?.trim())return!1;let t=u(e.type??``);return t===`statictext`||t===`text`||t===`textview`}function tt(e,t,n,r,i){let a=u(n.type??``);if(a===`button`){P(C(e,t),r,i,n);return}if(a!==`cell`)return;let o=C(e,t);nt(o,n,r,i)||rt(o,n,r,i)}function nt(e,t,n,r){let i=e.find(e=>ot(e,t,n));if(!i)return!1;let a=e.find(e=>F(e,t,n)),o=i.identifier?void 0:a?.identifier??t.identifier;return o&&S(r.replacements,i,{identifier:o}),r.suppressNode(t,[i]),it(e,t,n,i,r),!0}function rt(e,t,n,r){let i=e.find(e=>F(e,t,n));if(!i){e.some(re)&&P(e,n,r,t);return}!t.identifier&&i.identifier&&S(r.replacements,t,{identifier:i.identifier}),r.suppressNode(i,[t]),P(e.filter(e=>e.index!==i.index),n,r,t)}function it(e,t,n,r,i){for(let a of e)a.index!==r.index&&(F(a,t,n)||at(a,t)||st(a,r)||te(a,n))&&i.suppressNode(a,[r])}function P(e,t,n,r){for(let i of e)(te(i,t)||r&&at(i,r))&&n.suppressNode(i,r?[r]:[])}function F(e,t,n){if(u(e.type??``)!==`button`)return!1;let r=t.identifier?.trim(),i=e.identifier?.trim();return r&&i&&r===i?!0:e.label?.trim()===n&&d(e.rect,t.rect)}function at(e,t){return u(e.type??``)===`button`&&!e.label?.trim()&&!e.value?.trim()&&d(e.rect,t.rect)}function ot(e,t,n){if(u(e.type??``)!==`switch`)return!1;let r=t.identifier?.trim(),i=e.identifier?.trim();return r&&i&&r===i?!0:e.label?.trim()===n}function st(e,t){if(u(e.type??``)!==`switch`||e.index===t.index)return!1;let n=e.label?.trim();return n===t.value?.trim()||n===`0`||n===`1`}const I=1.15;function ct(e,n,r){let i=new Map(e.map((e,t)=>[e.index,t]));for(let[a,o]of e.entries()){let s=lt(e,i,n,o,r);if(!s)continue;R(e,a,r);let c=z(s.shelfRect,2);for(let n of s.intermediateSiblings){if(vt(n)||!n.rect||!t(n.rect,c))continue;let a=i.get(n.index);a!==void 0&&R(e,a,r)}}}function lt(e,t,n,r,i){let a=ut(r,n,i.sourceNodesByIndex);if(!a)return;let o=pt(e,t,a.siblings,a.position,a.parent);if(!(o<0))return{shelfRect:a.rect,intermediateSiblings:a.siblings.slice(a.position+1,o)}}function ut(e,t,n){let r=mt(e,L(t,e.index));if(!r)return;let i=ft(e,n);if(!i||!i.rect)return;let a=L(t,i.index),o=a.findIndex(t=>t.index===e.index);if(dt(a,o,e,r))return{rect:r.rect,parent:i,siblings:a,position:o}}function L(e,t){return e.get(t)??[]}function dt(e,t,n,r){if(t<1)return!1;let i=ht(e,t,n);return i?!r.childActionsPresented||!gt(i,r.actionButtons):!1}function ft(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function pt(e,t,n,r,i){return n.findIndex((n,a)=>a>r&&_t(e,t.get(n.index),n,i))}function mt(e,t){if(!b(e.type)||!e.rect)return;let n=e.rect,r=t.filter(e=>u(e.type??``)===`button`&&e.rect);if(r.length===0&&e.hiddenContentBelow===!0)return{rect:n,childActionsPresented:!1,actionButtons:r};if(r.length<3)return;let i=r.map(e=>e.rect.x+e.rect.width/2);if(i.every((e,t)=>t===0||e>i[t-1]))return{rect:n,childActionsPresented:r.some(e=>o(n,e.rect)),actionButtons:r}}function ht(e,t,n){if(!(!n.rect||t<1))for(let r=t-1;r>=0;--r){let t=e[r];if(!(!t.rect||!T(t))&&t.rect.x+t.rect.width/2<n.rect.x&&yt(t.rect,z(n.rect,2)))return t}}function gt(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*I||e.rect.height>r*I}function _t(e,t,n,r){return t!==void 0&&u(n.type??``)===`other`&&d(n.rect,r.rect)&&!!x(e,t,T)}function R(e,t,n){let r=e[t];if(r){n.suppressNode(r,[]);for(let r of C(e,t))n.suppressNode(r,[])}}function vt(e){let t=u(e.type??``);return t===`textfield`||t===`securetextfield`||t===`searchfield`||t===`textview`}function z(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function yt(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function bt(e,t){let n=D(e);ct(e,n,t),xt(e,n,t)}function xt(e,t,n){for(let i of e){if(u(i.type??``)!==`navigationbar`||!i.rect)continue;let e=t.get(i.index)??[],a=e.flatMap(t=>St(t,e,i.rect));if(a.length!==1)continue;let{field:o,title:s,image:c,label:l}=a[0];S(n.replacements,o,{type:`Button`,label:l,enabled:!0,hittable:void 0,rect:r([c.rect,o.rect,s.rect])}),n.semanticRepresentativeIndexes.add(o.index),n.suppressNode(s,[o]),n.suppressNode(c,[o])}}function St(e,t,n){let r=l(e);if(!Ct(e,r))return[];let i=B(t,e=>wt(e,r)),a=B(t,Tt);return i?.rect&&a?.rect&&Et(a.rect,e.rect,i.rect,n)?[{field:e,title:i,image:a,label:r}]:[]}function Ct(e,t){return u(e.type??``)===`textfield`&&e.enabled===!1&&!!e.rect&&!!t&&e.value?.trim()===t}function wt(e,t){return u(e.type??``)===`statictext`&&e.label?.trim()===t&&!!e.rect}function Tt(e){return u(e.type??``)===`image`&&!!e.identifier?.trim()&&!!e.rect}function B(e,t){let n=e.filter(t);return n.length===1?n[0]:void 0}function Et(e,t,n,r){let i=t.x-(e.x+e.width),a=n.x-(t.x+t.width);return o(r,e)&&o(r,t)&&o(r,n)&&i>=0&&i<=12&&a>=0&&a<=12&&V(e,t)&&V(t,n)}function V(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function Dt(e,t){let n=D(e);for(let r of e){if(u(r.type??``)===`element(58)`){S(t.replacements,r,{type:`WebView`});continue}let e=Ot(r,t.sourceNodesByIndex,n);if(e?.kind===`suppress`){t.suppressNode(r,[]);continue}e&&(S(t.replacements,r,{type:e.type,...e.type===`Heading`?{value:void 0}:{}}),t.semanticRepresentativeIndexes.add(r.index))}}function Ot(e,t,n){if(u(e.type??``)!==`other`)return null;let r=w(e,t,jt),i=e.label?.trim();return!r||!i?null:At(e,r,i)?{kind:`suppress`}:kt(e,i,n)?{kind:`semantic`,type:H(e.value)?`Heading`:`StaticText`}:null}function kt(e,t,n){let r=n.get(e.index);if(r?.length!==1)return!1;let i=r[0];return u(i.type??``)===`statictext`&&i.label?.trim()===t&&!n.has(i.index)}function At(e,t,n){return e.parentIndex===t.index&&t.label?.trim()===n&&!H(e.value)}function jt(e){let t=u(e.type??``);return t===`webview`||t===`element(58)`}function H(e){return/^[1-6]$/.test(e?.trim()??``)}const Mt=[Dt,bt,ce,Ze,Xe];function U(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 Mt)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=ne(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,W(e.index,l,n)]))}}function W(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 W(i,t,n,r))a.add(e);return[...a].sort((e,t)=>e-t)}var G=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 Nt(e){return{reason:e.reason,...e.details}}function K(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 G(`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 G(`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 G(`malformed-graph`,`iOS snapshot graph parent must precede its child`,{index:r.index,parentIndex:r.parentIndex})}}const q=new Set([`collectionview`,`scrollview`,`table`]),Pt=new Set([`application`,`window`]),Ft=new Set([`UITextEffectsWindow`,`UIRemoteKeyboardWindow`]),J=new Map([[`Sheet`,5],[`Drawer`,6],[`Alert`,7],[`Dialog`,8]]);function It(){return{projectedOut:!1}}function Lt(e,t,n,r,i,a){let o=a===`cursor-projected`?t.ancestorClip:void 0,s=Rt(e.rect,n,o),l=c(Y(e.rect)),d=c(s),f=u(e.type??``),p=zt(a,t.projectedOut,l,d,f,i),m=Kt(e,Bt(a,t.projectedOut,l,d)&&!Vt(e,l,a),r,a),h=Gt(f,m,d,i),g=Ut(a,t.projectedOut,l,d,e);return{isIncluded:m,descendants:Ht(a,p,o,s,h),effectiveRect:s,...g?{hiddenContentFrame:g}:{},establishesScrollAnchor:h}}function Rt(e,t,n){let r=Y(e);if(!r)return;let i=X(r,t);return n&&(i=X(i,n)),i}function zt(e,t,n,r,i,a){return e===`plain-viewport`?!r:t||n&&!r&&Wt(i,a)}function Bt(e,t,n,r){return e===`plain-viewport`?r:!t&&(!n||r)}function Vt(e,t,n){return n!==`cursor-projected`||e.parentIndex===void 0||qt(e)||!t?!1:Jt(e.rect)<=1||Yt(e.rect)<=1}function Ht(e,t,n,r,i){return{projectedOut:t,...e===`cursor-projected`&&i?{ancestorClip:r}:{ancestorClip:n}}}function Ut(e,t,n,r,i){if(!(e!==`cursor-projected`||t||!n||r))return Y(i.rect)}function Wt(e,t){return t&&(e===`cell`||q.has(e))}function Gt(e,t,n,r){return t&&n&&r&&q.has(e)}function Kt(e,t,n,r){if(e.parentIndex===void 0)return!0;let i=u(e.type??``);return r===`plain-viewport`&&n&&!t&&i!==`application`?!1:Pt.has(i)||t}function qt(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 Jt(e){return Y(e)?.width??0}function Yt(e){return Y(e)?.height??0}function X(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 Xt(e){let t=D(e),n=new Set;for(let e of t.values()){let r=Zt(e,t);if(r){for(let i of e.slice(0,-1))if(Qt(r,i)){n.add(i.index);for(let e of E(i,t))n.add(e.index)}}}return n}function Zt(e,t){let n=e.at(-1);if(!n||!Z(n))return;let r=(t.get(n.index)??[]).find($t);if(!(r?.userInteractionEnabled!==!0||!c(r.rect)))return{container:n,dimmingRect:r.rect}}function Qt(e,t){return Z(t)&&c(t.rect)&&o(e.dimmingRect,t.rect)}function Z(e){return en(e,`UITransitionView`)}function $t(e){return en(e,`UIDimmingView`)}function en(e,t){return u(e.role??``)===u(t)}function tn(e,t){let n=un(e),r=dn(e,n);if(e.some((e,t)=>r.has(t)&&nn(e)))return`presented`;if(t!==`complete`||n.length===0||!e.every(e=>e.role!==void 0)||!ln(e))return`unknown`;let i=n.filter(t=>!cn(e[t]));return i.length===1&&pn(e[i[0]],e).length===1?`absent`:`unknown`}function nn(e){return $t(e)||rn(e)||an(e)}function rn(e){let t=e.role;return t!==void 0&&u(t).startsWith(u(`_UIAlertController`))}function an(e){let t=e.type;if(!t)return!1;if(J.has(t))return!0;let n=on.exec(t);return n!==null&&sn.has(Number(n[1]))}const on=/^Element\((\d+)\)$/,sn=new Set(J.values());function cn(e){let t=e.role;if(t===void 0)return!1;let n=u(t);for(let e of Ft)if(u(e)===n)return!0;return!1}function ln(e){return new Set(e.map(e=>e.index)).size===e.length}function un(e){let t=[];for(let[n,r]of e.entries())r.parentIndex===void 0&&t.push(n);if(t.length!==1)return[];let n=e[t[0]].index,r=[];for(let[t,i]of e.entries())i.parentIndex===n&&r.push(t);return r}function dn(e,t){let n=new Map;for(let[t,r]of e.entries()){if(typeof r.parentIndex!=`number`)continue;let e=n.get(r.parentIndex)??[];e.push(t),n.set(r.parentIndex,e)}let r=new Set(e.map((e,t)=>t));for(let i of t)if(cn(e[i]))for(let t of fn(i,e,n))r.delete(t);return r}function fn(e,t,n){let r=[e],i=new Set([e]);for(let e=0;e<r.length;e+=1)for(let a of n.get(t[r[e]].index)??[])i.has(a)||(i.add(a),r.push(a));return r}function pn(e,t){return t.filter(t=>t.parentIndex===e.index&&Z(t))}function mn(e,t,n,r,i={}){K(e);let a=Xt(e),o=e.filter(e=>!a.has(e.index)),s=hn(o),l=new Map,u=[],d=new Map,f=0,p=0,m=0;for(let e of o){let a=gn(e,l,()=>{f+=1}),o=a?.traversal??It(),h=r===`cursor-projected`?a?.anchor:void 0,g=Lt(e,o,t,n,s.has(e.index),r);c(e.rect)&&(g.isIncluded&&g.effectiveRect&&!Cn(e.rect,g.effectiveRect)?p+=1:!g.isIncluded&&!c(g.effectiveRect)&&(m+=1)),_n(g,h,d);let _=vn(e,g,a,u,t,i),v=bn(g,h,_.keptIndex);l.set(e.index,{traversal:g.descendants,anchor:v,keptIndex:_.keptIndex,keptDepth:_.keptDepth})}let h=Sn(d,u);return{nodes:h,...p+m>0?{qualityNotes:[{code:`regular-geometry-clipped`,clippedNodeCount:p,droppedNodeCount:m}]}:{},stats:{presentedNodeCount:h.length,sourceNodeCount:e.length,parentClipLookups:f,modalContainedNodeCount:a.size}}}function hn(e){let t=new Set;for(let n of e)n.parentIndex!==void 0&&t.add(n.parentIndex);return t}function gn(e,t,n){if(e.parentIndex!==void 0)return n(),t.get(e.parentIndex)}function _n(e,t,n){e.hiddenContentFrame&&t&&xn(e.hiddenContentFrame,t,n)}function vn(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,...yn(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 yn(e,t,n,r,i,o){return o.hittabilityAvailable===!1?e===!1||!r?{hittable:!1}:{}:{hittable:t&&e===!0&&a(r,n,i)}}function bn(e,t,n){return e.establishesScrollAnchor&&n!==void 0&&e.effectiveRect?{index:n,rect:e.effectiveRect}:t}function xn(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 Sn(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}}})}function Cn(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}const wn=new Set([`collectionview`,`scrollview`,`table`]);function Tn(e){return En(e.viewport)}function En(e){if(e.kind===`missing`)throw new G(e.reason===`invalid`?`invalid-viewport`:`missing-viewport`,`regular iOS snapshot presentation requires a valid viewport`,{field:`viewport`});if(!c(e.rect))throw new G(`invalid-viewport`,`regular iOS snapshot presentation requires a positive finite viewport`,{field:`viewport`});return e.rect}function Dn(e,t,n,r=!0){K(e);let i=new Map,a=0;for(let o of e){let e=On(o,i,t,()=>{a+=1}),s=Pn(o.rect);if(kn(o,r),!s||!c(s)){An(o,s),i.set(o.index,e);continue}jn(o,s,e),Mn(o,s,t),i.set(o.index,Nn(o,s,e,n))}return{parentClipLookups:a}}function On(e,t,n,r){if(e.parentIndex===void 0)return n;r();let i=t.get(e.parentIndex);if(!i)throw new G(`invalid-presented-payload`,`regular iOS snapshot payload refers to a parent outside the payload`,{index:e.index,parentIndex:e.parentIndex});return i}function kn(e,t){if(!(e.hittable!==!0||t))throw new G(`invalid-presented-payload`,`iOS snapshot payload marked a node actionable without hittability evidence`,{index:e.index})}function An(e,t){if(e.hittable===!0)throw new G(`regular-degenerate-actionable-node`,`regular iOS snapshot node with a missing or degenerate frame is actionable`,{index:e.index,frame:t??e.rect})}function jn(e,t,n){if(!Fn(t,n))throw new G(`regular-node-outside-cumulative-clip`,`regular iOS snapshot node escaped its cumulative clip`,{index:e.index,frame:t,clip:n})}function Mn(e,t,r){if(!(e.hittable!==!0||e.enabled!==!1&&n(r,t.x+t.width/2,t.y+t.height/2)))throw new G(`invalid-presented-payload`,`regular iOS snapshot payload marked a disabled or off-viewport node actionable`,{index:e.index,frame:t})}function Nn(e,t,n,r){return r===`cursor-projected`&&wn.has(u(e.type??``))?t:n}function Q(e,t,n,r,i=!0){if(t===`raw`)return K(e),{parentClipLookups:0};if(!n)throw new G(`missing-viewport`,`regular iOS snapshot payload cannot be validated without a viewport`,{field:`viewport`});try{return Dn(e,n,r,i)}catch(e){throw e instanceof G&&e.code===`IOS_SNAPSHOT_ENGINE_FAILED`&&e.reason===`malformed-graph`?new G(`invalid-presented-payload`,e.message,e.details):e}}function Pn(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 Fn(e,t){let n=1e-4;return o({x:t.x-n,y:t.y-n,width:t.width+n*2,height:t.height+n*2},e)}const In=new Set([`button`,`cell`,`checkbox`,`collectionview`,`keyboard`,`link`,`menuitem`,`picker`,`searchfield`,`securetextfield`,`segmentedcontrol`,`slider`,`scrollview`,`stepper`,`switch`,`tabbar`,`table`,`textfield`,`textview`,`webview`]);function Ln(e){let t=Xn(e.nodes),n=Bn(e,t);return e.projection===`raw`?Vn(n,e.depth,t):Hn(n,e.depth)}function Rn(e){let t=Xn(e.nodes);return e.projection===`raw`?Vn(e.nodes,e.depth,t):Hn(e.nodes,e.depth)}function zn(e){return e.parentIndex===void 0||In.has(u(e.type??``))||Zn(e)}function Bn(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||!Jn(i.raw,n))continue;let a=Yn(e.nodes,r,t);if(!(e.projection===`raw`||a.some(t=>zn(e.nodes[t].raw))))continue;let o=a.map(t=>e.nodes[t]);return qn(e.projection===`raw`&&e.depth!==null?o.filter(n=>$(n,t)-$(i,t)<=e.depth):o,$(i,t),t)}return[]}function Vn(e,t,n){let r=t===null?[...e]:e.filter(e=>$(e,n)<=t);return{nodes:r.map(e=>({...e.raw,rect:e.raw.rect})),sourceIndexes:r.map(e=>e.sourceIndex)}}function Hn(e,t){let n=[],r=[],i=new Map;for(let a of e){let e=Un(a,i),o=Wn(a,e,t,n.length);if(!o){Kn(a,e,i);continue}n.push(o),r.push(a.sourceIndex),i.set(a.raw.index,o)}return{nodes:n,sourceIndexes:r}}function Un(e,t){return e.raw.parentIndex===void 0?void 0:t.get(e.raw.parentIndex)}function Wn(e,t,n,r){if(!zn(e.raw))return;let i=t?(t.depth??0)+1:0;if(n!==null&&i>n)return;let a=Gn(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 Gn(e){if(e.raw.hittable!==void 0)return!!(e.raw.hittable===!0&&e.effectiveRect&&e.effectiveRect.width>0&&e.effectiveRect.height>0)}function Kn(e,t,n){t&&n.set(e.raw.index,t)}function qn(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,$(e,n)-t),parentIndex:e.raw.parentIndex===void 0?void 0:r.get(e.raw.parentIndex)}}))}function Jn(e,t){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.toLowerCase().includes(t))}function Yn(e,t,n){let r=$(e[t],n),i=[];for(let a=t;a<e.length&&!(a>t&&$(e[a],n)<=r);a+=1)i.push(a);return i}function $(e,t){return Math.max(0,e.raw.depth??t?.get(e.raw.index)??0)}function Xn(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 Zn(e){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.trim().length>0)}function Qn(e,t,n=`cursor-projected`){$n(e,t);let r=e.validation.presentationKey.projection,i=r===`regular`?En(e.validation.viewport):void 0,a=e.validation.hittability.kind===`available`,o=er(e,r,i,n,a),s=tr(e.presentation.payload.nodes,r,t),c=s.compacted?nr(s.nodes,r,i,n,a,o):o;return{nodes:s.nodes,...i?{validatedViewport:i}:{},...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 $n(e,t){if(!rr(h(t),e.validation.presentationKey))throw new G(`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 G(`projection-mismatch`,`presented iOS snapshot does not match the requested acquisition intent`,{field:`acquisitionIntent`})}function er(e,t,n,r,i){let a=Q(e.presentation.payload.nodes,t,n,r,i);if(e.presentation.qualityPayload)try{Q(e.presentation.qualityPayload.nodes,t,n,r,i)}catch(e){throw e instanceof G?new G(`invalid-quality-payload`,e.message,e.details):e}return a}function tr(e,t,n){return t===`regular`&&n.interactiveOnly?{...U([...e]),compacted:!0}:{nodes:[...e],presentedIndexesBySourceIndex:ir(e),compacted:!1}}function nr(e,t,n,r,i,a){return t!==`regular`||!n?a:Q(e,t,n,r,i)}function rr(e,t){return e.projection===t.projection&&e.interactiveOnly===t.interactiveOnly&&e.depth===t.depth&&e.scope===t.scope&&e.customActions===t.customActions}function ir(e){return new Map(e.map(e=>[e.index,[e.index]]))}function ar(t,n,r={}){let i=sr(t,n,r),a=t.stage===`presented`?t.validation.presentationKey:h(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,...i.qualityNotes?{qualityNotes:i.qualityNotes}:{},comparisonIdentity:g(t,n),residue:t.stage===`acquired`?[...t.acquisition.residue]:[...t.validation.residue],...i.validatedViewport?{validatedViewport:i.validatedViewport}:{},...t.stage===`acquired`?{presentedSurface:tn(t.acquisition.nodes,or(t.acquisition))}:{}}}function or(e){return e.truncated===void 0?`unstated`:e.truncated?`capped`:`complete`}function sr(e,t,n={}){let r=n.foldPolicy??`cursor-projected`;return e.stage===`acquired`?cr(e.acquisition,t,r):Qn(e,t,r)}function cr(e,t,n){if(ur(e,m(t)),t.projection===`raw`){K(e.nodes);let r=e.nodes.map(e=>({raw:e,sourceIndex:e.index})),i=Ln({nodes:r,projection:`raw`,scope:t.scope,depth:t.depth,foldPolicy:n}),a=t.scope===null?void 0:Rn({nodes:r,projection:`raw`,depth:null,foldPolicy:n}).nodes;return{nodes:i.nodes,...a?{qualityNodes:a}:{},presentedIndexesBySourceIndex:fr(e.nodes,i.nodes,i.sourceIndexes,dr(i.nodes)),stats:{presentedNodeCount:i.nodes.length,sourceNodeCount:e.nodes.length,parentClipLookups:0,modalContainedNodeCount:0}}}let r=Tn(e),i=!lr(e.residue),a=mn(e.nodes,r,t.interactiveOnly,n,{hittabilityAvailable:i}),o=Ln({nodes:a.nodes,projection:`regular`,scope:t.scope,depth:t.depth,foldPolicy:n}),s=t.interactiveOnly?U(o.nodes):{nodes:o.nodes,presentedIndexesBySourceIndex:dr(o.nodes)},c=Q(s.nodes,`regular`,r,n,i),l=t.scope===null?void 0:Rn({nodes:a.nodes,projection:`regular`,depth:null,foldPolicy:n}).nodes;return{nodes:s.nodes,validatedViewport:r,...a.qualityNotes?{qualityNotes:a.qualityNotes}:{},...l?{qualityNodes:l}:{},presentedIndexesBySourceIndex:fr(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 lr(e){return e.some(e=>e.kind===`unavailable-fact`&&e.fact===`hittability`)}function ur(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 G(`projection-mismatch`,`acquired iOS snapshot does not match the requested capture hint`,{projection:n.projection})}function dr(e){return new Map(e.map(e=>[e.index,[e.index]]))}function fr(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{U as a,Nt as i,Qn as n,G as r,ar as t};
|
|
1
|
+
import{Si as e,bi as t,di as n,fi as r,gi as i,hi as a,ii as o,mi as s,si as c,yi as l}from"./sdk-batch.js";import{rt as u}from"./sdk-contracts.js";import{n as d}from"./rect-center.js";import{n as f,t as p}from"./scroll-indicator.js";import{i as m,n as h,t as g}from"./ios-snapshot-planning.js";import{_,a as v,c as y,d as ee,f as b,g as te,h as ne,i as x,l as re,m as S,n as C,o as w,p as T,r as E,t as D,u as ie}from"./tree.js";import{a as ae,i as oe,o as O,s as se}from"./react-native-overlay.js";function ce(e,t){let n=v(t.sourceNodesByIndex.values());for(let r of e)le(r,t.sourceNodesByIndex,n)&&S(t.replacements,r,{type:`Cell`})}function le(e,t,r){return!(n(e.type??``)!==`other`||e.enabled===!1||!e.rect||!fe(e.label)||!w(e,t,de)||!ue(e)||ie(e.rect,r))}function ue(e){return e.rect?e.rect.height>=44&&e.rect.height<=160&&e.rect.width>=120:!1}function de(e){let t=n(e.type??``);return t===`scrollview`||t===`scrollarea`}function fe(e){let t=e?.trim();return!(!t||/^(toolbar|window|application)$/i.test(t)||t.startsWith(`!,`)||/debugger|fast refresh/i.test(t))}function pe(e,t){let n=new Set;for(let r of e)me(t.replacements.get(r.index)??r)&&he(r,t.sourceNodesByIndex,t,n);ye(e,t,n)}function me(e){let t=e.label?.trim();return!!(t&&f(t))}function he(e,t,n,r){let i=!b(e.type)||n.isSuppressed(e),a=p(e.label?.trim()??``,e.value),o=a?ve(e,t):void 0;i&&n.suppressNode(e,o?[o]:[]),o&&a&&De(n,o,e,a)&&r.add(o.index)}function ge(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function _e(e,t){return e.rect!=null&&t.rect!=null&&k(e.rect,t.rect)}function ve(e,t){if(b(e.type))return null;let n=ge(e,t);for(;n&&!b(n.type);){let e=ge(n,t);if(!e||!_e(n,e))return null;n=e}return n??null}function ye(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=Ee(o.rect,a),c=be(o,a,s),l=xe(e,c,o);Se(t,i,o,a,s,c,l),r.set(i.index,Ce(i,o,a,s,l,n))}}function be(e,t,n){return!!(t&&a(e.rect)&&!a(n))}function xe(e,t,n){return!!(e?.projectedOut||t&&Te(n))}function Se(e,t,n,r,i,a,o){o||a?e.suppressNode(t,[]):r&&i&&!k(n.rect,i)&&S(e.replacements,t,{rect:i})}function Ce(e,t,n,r,i,a){return{projectedOut:i,...we(e,t,n,r,a)?{clip:r}:n?{clip:n}:{}}}function we(e,t,n,r,i){return!!(a(r)&&(i.has(e.index)||n!==void 0&&b(t.type)))}function Te(e){return e.type?.trim().toLowerCase()===`cell`||b(e.type)}function Ee(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 De(e,t,n,r){let i=Oe((e.replacements.get(t.index)??t).rect,n.rect);return _(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 Oe(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 r=0;r<e.length;r+=1){let i=e[r],a=i?.label?.trim();i&&a&&n(i.type??``)===`other`&&t(i,a,r)}}function ke(e,t){j(e,(n,r,i)=>{if(!O(r)||!n.rect)return;let a=x(e,i,e=>!!e.rect&&se(e.label?.trim()??``));if(!a?.rect)return;let o=je(n.rect,a.rect);if(!o)return;let s=Ae(e,i,o);S(t,n,{rect:s}),y(e,i,e=>{O(e.label?.trim()??``)&&S(t,e,{rect:s})})})}function Ae(e,n,r){let i=r;return y(e,n,e=>{let n=e.label?.trim()??``;!e.rect||!O(n)||t(r,e.rect)&&l(e.rect)<l(i)&&(i=e.rect)}),i}function je(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&&d(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&&d(t,a))return{...e,x:r,width:n-r}}function Me(e,t){j(e,(n,r,i)=>{oe(n)&&ae(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 Ne(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||!Pe(i,r)||(t.suppressNode(i,[]),Fe(i,t,r),y(e,n,e=>{t.suppressNode(e,[])}))}}function Pe(e,t){return!e.rect||n(e.type??``)!==`keyboard`?!1:e.rect.y>=t}function Fe(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 Ie(e,t){for(let r=0;r<e.length;r+=1){let i=e[r];if(!i)continue;if(Le(i)){ze(e,r,i,t);continue}if(!Re(i))continue;let a=x(e,r,e=>n(e.type??``)===`searchfield`&&e.label===`Search`);a&&(t.suppressNode(i,[a]),Be(i,a,t),ze(e,r,a,t))}}function Le(e){return n(e.type??``)===`searchfield`&&e.label===`Search`}function Re(e){let t=n(e.type??``);return e.label===`Toolbar`&&(t===`toolbar`||t===`searchfield`)}function ze(e,t,n,r){y(e,t,e=>{e.index!==n.index&&Ve(e)&&r.suppressNode(e,[n])})}function Be(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 Ve(e){let t=n(e.type??``);return t===`button`?!1:t===`image`||e.label===`Search`}function He(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?.label?.trim();!r||t.isSuppressed(r)||!i||Ue(e,n,r,i,t)}}function Ue(e,t,r,i,a){let s=n(r.type??``);if(s===`statictext`||s===`link`){N(e,t,i,r,a);return}if(s!==`other`)return;let c=!o(r)&&We(e,t,i);if(c){a.suppressNode(r,[c]);return}N(e,t,i,r,a)}function We(e,t,r){return x(e,t,e=>{let t=n(e.type??``);return(t===`link`||t===`searchfield`||b(e.type))&&e.label?.trim()===r})}function N(e,t,n,r,i){y(e,t,e=>{!i.semanticRepresentativeIndexes.has(e.index)&&ee(e,n)&&i.suppressNode(e,[r])})}function Ge(e,t){j(e,(n,r,i)=>{if(o(n))return;let a=x(e,i,e=>T(e)&&e.label?.trim()===r&&(d(e.rect,n.rect)||Ke(n,e)));a&&t.suppressNode(n,[a])})}function Ke(e,t){if(t.label?.trim()!==e.label?.trim())return!1;let r=n(t.type??``);return qe(e,r)||r===`textfield`||Je(e,r,t)}function qe(e,t){let n=e.label?.trim();return t===`button`&&(n===`Dismiss`||n===`Back`)}function Je(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 Ye(e,t){let r=D(e);for(let i of e){if(n(i.type??``)!==`other`||i.hittable===!0||i.label?.trim()||i.value?.trim()||!i.identifier?.trim())continue;let e=E(i,r);(e.length!==0||i.hittable===!1)&&t.suppressNode(i,e)}}function Xe(e,t){Ne(e,t),Ye(e,t),pe(e,t),Ie(e,t),Ge(e,t),ke(e,t.replacements),Me(e,t),He(e,t)}function Ze(e,t){for(let n=0;n<e.length;n+=1){let r=e[n],i=r?Qe(e,n,r,t):void 0;!r?.rect||!i||tt(e,n,r,i,t)}}function Qe(e,t,r,i){let a=r.label?.trim();if(n(r.type??``)!==`cell`||a&&!$e(a,r.identifier)&&!f(a))return a;let o=C(e,t).find(et),s=o?.label?.trim();return!o||!s?a:(S(i.replacements,r,{label:s}),i.suppressNode(o,[r]),s)}function $e(e,t){return t?.trim()===e&&/^[A-Z_$][A-Za-z0-9_$]*Cell$/.test(e)}function et(e){if(!e.label?.trim())return!1;let t=n(e.type??``);return t===`statictext`||t===`text`||t===`textview`}function tt(e,t,r,i,a){let o=n(r.type??``);if(o===`button`){P(C(e,t),i,a,r);return}if(o!==`cell`)return;let s=C(e,t);nt(s,r,i,a)||rt(s,r,i,a)}function nt(e,t,n,r){let i=e.find(e=>ot(e,t,n));if(!i)return!1;let a=e.find(e=>F(e,t,n)),o=i.identifier?void 0:a?.identifier??t.identifier;return o&&S(r.replacements,i,{identifier:o}),r.suppressNode(t,[i]),it(e,t,n,i,r),!0}function rt(e,t,n,r){let i=e.find(e=>F(e,t,n));if(!i){e.some(re)&&P(e,n,r,t);return}!t.identifier&&i.identifier&&S(r.replacements,t,{identifier:i.identifier}),r.suppressNode(i,[t]),P(e.filter(e=>e.index!==i.index),n,r,t)}function it(e,t,n,r,i){for(let a of e)a.index!==r.index&&(F(a,t,n)||at(a,t)||st(a,r)||te(a,n))&&i.suppressNode(a,[r])}function P(e,t,n,r){for(let i of e)(te(i,t)||r&&at(i,r))&&n.suppressNode(i,r?[r]:[])}function F(e,t,r){if(n(e.type??``)!==`button`)return!1;let i=t.identifier?.trim(),a=e.identifier?.trim();return i&&a&&i===a?!0:e.label?.trim()===r&&d(e.rect,t.rect)}function at(e,t){return n(e.type??``)===`button`&&!e.label?.trim()&&!e.value?.trim()&&d(e.rect,t.rect)}function ot(e,t,r){if(n(e.type??``)!==`switch`)return!1;let i=t.identifier?.trim(),a=e.identifier?.trim();return i&&a&&i===a?!0:e.label?.trim()===r}function st(e,t){if(n(e.type??``)!==`switch`||e.index===t.index)return!1;let r=e.label?.trim();return r===t.value?.trim()||r===`0`||r===`1`}const I=1.15;function ct(e,t,n){let r=new Map(e.map((e,t)=>[e.index,t]));for(let[a,o]of e.entries()){let s=lt(e,r,t,o,n);if(!s)continue;R(e,a,n);let c=z(s.shelfRect,2);for(let t of s.intermediateSiblings){if(vt(t)||!t.rect||!i(t.rect,c))continue;let a=r.get(t.index);a!==void 0&&R(e,a,n)}}}function lt(e,t,n,r,i){let a=ut(r,n,i.sourceNodesByIndex);if(!a)return;let o=pt(e,t,a.siblings,a.position,a.parent);if(!(o<0))return{shelfRect:a.rect,intermediateSiblings:a.siblings.slice(a.position+1,o)}}function ut(e,t,n){let r=mt(e,L(t,e.index));if(!r)return;let i=ft(e,n);if(!i||!i.rect)return;let a=L(t,i.index),o=a.findIndex(t=>t.index===e.index);if(dt(a,o,e,r))return{rect:r.rect,parent:i,siblings:a,position:o}}function L(e,t){return e.get(t)??[]}function dt(e,t,n,r){if(t<1)return!1;let i=ht(e,t,n);return i?!r.childActionsPresented||!gt(i,r.actionButtons):!1}function ft(e,t){return typeof e.parentIndex==`number`?t.get(e.parentIndex):void 0}function pt(e,t,n,r,i){return n.findIndex((n,a)=>a>r&&_t(e,t.get(n.index),n,i))}function mt(e,r){if(!b(e.type)||!e.rect)return;let i=e.rect,a=r.filter(e=>n(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 ht(e,t,n){if(!(!n.rect||t<1))for(let r=t-1;r>=0;--r){let t=e[r];if(!(!t.rect||!T(t))&&t.rect.x+t.rect.width/2<n.rect.x&&yt(t.rect,z(n.rect,2)))return t}}function gt(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*I||e.rect.height>r*I}function _t(e,t,r,i){return t!==void 0&&n(r.type??``)===`other`&&d(r.rect,i.rect)&&!!x(e,t,T)}function R(e,t,n){let r=e[t];if(r){n.suppressNode(r,[]);for(let r of C(e,t))n.suppressNode(r,[])}}function vt(e){let t=n(e.type??``);return t===`textfield`||t===`securetextfield`||t===`searchfield`||t===`textview`}function z(e,t){return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}function yt(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function bt(e,t){let n=D(e);ct(e,n,t),xt(e,n,t)}function xt(t,r,i){for(let a of t){if(n(a.type??``)!==`navigationbar`||!a.rect)continue;let t=r.get(a.index)??[],o=t.flatMap(e=>St(e,t,a.rect));if(o.length!==1)continue;let{field:s,title:c,image:l,label:u}=o[0];S(i.replacements,s,{type:`Button`,label:u,enabled:!0,hittable:void 0,rect:e([l.rect,s.rect,c.rect])}),i.semanticRepresentativeIndexes.add(s.index),i.suppressNode(c,[s]),i.suppressNode(l,[s])}}function St(e,t,n){let r=c(e);if(!Ct(e,r))return[];let i=B(t,e=>wt(e,r)),a=B(t,Tt);return i?.rect&&a?.rect&&Et(a.rect,e.rect,i.rect,n)?[{field:e,title:i,image:a,label:r}]:[]}function Ct(e,t){return n(e.type??``)===`textfield`&&e.enabled===!1&&!!e.rect&&!!t&&e.value?.trim()===t}function wt(e,t){return n(e.type??``)===`statictext`&&e.label?.trim()===t&&!!e.rect}function Tt(e){return n(e.type??``)===`image`&&!!e.identifier?.trim()&&!!e.rect}function B(e,t){let n=e.filter(t);return n.length===1?n[0]:void 0}function Et(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&&V(e,n)&&V(n,r)}function V(e,t){return Math.max(e.y,t.y)<=Math.min(e.y+e.height,t.y+t.height)}function Dt(e,t){let r=D(e);for(let i of e){if(n(i.type??``)===`element(58)`){S(t.replacements,i,{type:`WebView`});continue}let e=Ot(i,t.sourceNodesByIndex,r);if(e?.kind===`suppress`){t.suppressNode(i,[]);continue}e&&(S(t.replacements,i,{type:e.type,...e.type===`Heading`?{value:void 0}:{}}),t.semanticRepresentativeIndexes.add(i.index))}}function Ot(e,t,r){if(n(e.type??``)!==`other`)return null;let i=w(e,t,jt),a=e.label?.trim();return!i||!a?null:At(e,i,a)?{kind:`suppress`}:kt(e,a,r)?{kind:`semantic`,type:H(e.value)?`Heading`:`StaticText`}:null}function kt(e,t,r){let i=r.get(e.index);if(i?.length!==1)return!1;let a=i[0];return n(a.type??``)===`statictext`&&a.label?.trim()===t&&!r.has(a.index)}function At(e,t,n){return e.parentIndex===t.index&&t.label?.trim()===n&&!H(e.value)}function jt(e){let t=n(e.type??``);return t===`webview`||t===`element(58)`}function H(e){return/^[1-6]$/.test(e?.trim()??``)}const Mt=[Dt,bt,ce,Ze,Xe];function U(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 Mt)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=ne(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,W(e.index,l,n)]))}}function W(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 W(i,t,n,r))a.add(e);return[...a].sort((e,t)=>e-t)}var G=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 Nt(e){return{reason:e.reason,...e.details}}function K(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 G(`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 G(`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 G(`malformed-graph`,`iOS snapshot graph parent must precede its child`,{index:r.index,parentIndex:r.parentIndex})}}const q=new Set([`collectionview`,`scrollview`,`table`]),Pt=new Set([`application`,`window`]),Ft=new Set([`UITextEffectsWindow`,`UIRemoteKeyboardWindow`]),J=new Map([[`Sheet`,5],[`Drawer`,6],[`Alert`,7],[`Dialog`,8]]);function It(){return{projectedOut:!1}}function Lt(e,t,r,i,o,s){let c=s===`cursor-projected`?t.ancestorClip:void 0,l=Rt(e.rect,r,c),u=a(Y(e.rect)),d=a(l),f=n(e.type??``),p=zt(s,t.projectedOut,u,d,f,o),m=Kt(e,Bt(s,t.projectedOut,u,d)&&!Vt(e,u,s),i,s),h=Gt(f,m,d,o),g=Ut(s,t.projectedOut,u,d,e);return{isIncluded:m,descendants:Ht(s,p,c,l,h),effectiveRect:l,...g?{hiddenContentFrame:g}:{},establishesScrollAnchor:h}}function Rt(e,t,n){let r=Y(e);if(!r)return;let i=X(r,t);return n&&(i=X(i,n)),i}function zt(e,t,n,r,i,a){return e===`plain-viewport`?!r:t||n&&!r&&Wt(i,a)}function Bt(e,t,n,r){return e===`plain-viewport`?r:!t&&(!n||r)}function Vt(e,t,n){return n!==`cursor-projected`||e.parentIndex===void 0||qt(e)||!t?!1:Jt(e.rect)<=1||Yt(e.rect)<=1}function Ht(e,t,n,r,i){return{projectedOut:t,...e===`cursor-projected`&&i?{ancestorClip:r}:{ancestorClip:n}}}function Ut(e,t,n,r,i){if(!(e!==`cursor-projected`||t||!n||r))return Y(i.rect)}function Wt(e,t){return t&&(e===`cell`||q.has(e))}function Gt(e,t,n,r){return t&&n&&r&&q.has(e)}function Kt(e,t,r,i){if(e.parentIndex===void 0)return!0;let a=n(e.type??``);return i===`plain-viewport`&&r&&!t&&a!==`application`?!1:Pt.has(a)||t}function qt(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 Jt(e){return Y(e)?.width??0}function Yt(e){return Y(e)?.height??0}function X(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 Xt(e){let t=D(e),n=new Set;for(let e of t.values()){let r=Zt(e,t);if(r){for(let i of e.slice(0,-1))if(Qt(r,i)){n.add(i.index);for(let e of E(i,t))n.add(e.index)}}}return n}function Zt(e,t){let n=e.at(-1);if(!n||!Z(n))return;let r=(t.get(n.index)??[]).find($t);if(!(r?.userInteractionEnabled!==!0||!a(r.rect)))return{container:n,dimmingRect:r.rect}}function Qt(e,n){return Z(n)&&a(n.rect)&&t(e.dimmingRect,n.rect)}function Z(e){return en(e,`UITransitionView`)}function $t(e){return en(e,`UIDimmingView`)}function en(e,t){return n(e.role??``)===n(t)}function tn(e,t){let n=un(e),r=dn(e,n);if(e.some((e,t)=>r.has(t)&&nn(e)))return`presented`;if(t!==`complete`||n.length===0||!e.every(e=>e.role!==void 0)||!ln(e))return`unknown`;let i=n.filter(t=>!cn(e[t]));return i.length===1&&pn(e[i[0]],e).length===1?`absent`:`unknown`}function nn(e){return $t(e)||rn(e)||an(e)}function rn(e){let t=e.role;return t!==void 0&&n(t).startsWith(n(`_UIAlertController`))}function an(e){let t=e.type;if(!t)return!1;if(J.has(t))return!0;let n=on.exec(t);return n!==null&&sn.has(Number(n[1]))}const on=/^Element\((\d+)\)$/,sn=new Set(J.values());function cn(e){let t=e.role;if(t===void 0)return!1;let r=n(t);for(let e of Ft)if(n(e)===r)return!0;return!1}function ln(e){return new Set(e.map(e=>e.index)).size===e.length}function un(e){let t=[];for(let[n,r]of e.entries())r.parentIndex===void 0&&t.push(n);if(t.length!==1)return[];let n=e[t[0]].index,r=[];for(let[t,i]of e.entries())i.parentIndex===n&&r.push(t);return r}function dn(e,t){let n=new Map;for(let[t,r]of e.entries()){if(typeof r.parentIndex!=`number`)continue;let e=n.get(r.parentIndex)??[];e.push(t),n.set(r.parentIndex,e)}let r=new Set(e.map((e,t)=>t));for(let i of t)if(cn(e[i]))for(let t of fn(i,e,n))r.delete(t);return r}function fn(e,t,n){let r=[e],i=new Set([e]);for(let e=0;e<r.length;e+=1)for(let a of n.get(t[r[e]].index)??[])i.has(a)||(i.add(a),r.push(a));return r}function pn(e,t){return t.filter(t=>t.parentIndex===e.index&&Z(t))}function mn(e,t,n,r,i={}){K(e);let o=Xt(e),s=e.filter(e=>!o.has(e.index)),c=hn(s),l=new Map,u=[],d=new Map,f=0,p=0,m=0;for(let e of s){let o=gn(e,l,()=>{f+=1}),s=o?.traversal??It(),h=r===`cursor-projected`?o?.anchor:void 0,g=Lt(e,s,t,n,c.has(e.index),r);a(e.rect)&&(g.isIncluded&&g.effectiveRect&&!Cn(e.rect,g.effectiveRect)?p+=1:!g.isIncluded&&!a(g.effectiveRect)&&(m+=1)),_n(g,h,d);let _=vn(e,g,o,u,t,i),v=bn(g,h,_.keptIndex);l.set(e.index,{traversal:g.descendants,anchor:v,keptIndex:_.keptIndex,keptDepth:_.keptDepth})}let h=Sn(d,u);return{nodes:h,...p+m>0?{qualityNotes:[{code:`regular-geometry-clipped`,clippedNodeCount:p,droppedNodeCount:m}]}:{},stats:{presentedNodeCount:h.length,sourceNodeCount:e.length,parentClipLookups:f,modalContainedNodeCount:o.size}}}function hn(e){let t=new Set;for(let n of e)n.parentIndex!==void 0&&t.add(n.parentIndex);return t}function gn(e,t,n){if(e.parentIndex!==void 0)return n(),t.get(e.parentIndex)}function _n(e,t,n){e.hiddenContentFrame&&t&&xn(e.hiddenContentFrame,t,n)}function vn(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,...yn(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 yn(e,t,n,r,i,a){return a.hittabilityAvailable===!1?e===!1||!r?{hittable:!1}:{}:{hittable:t&&e===!0&&s(r,n,i)}}function bn(e,t,n){return e.establishesScrollAnchor&&n!==void 0&&e.effectiveRect?{index:n,rect:e.effectiveRect}:t}function xn(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 Sn(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}}})}function Cn(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}const wn=new Set([`collectionview`,`scrollview`,`table`]);function Tn(e){return En(e.viewport)}function En(e){if(e.kind===`missing`)throw new G(e.reason===`invalid`?`invalid-viewport`:`missing-viewport`,`regular iOS snapshot presentation requires a valid viewport`,{field:`viewport`});if(!a(e.rect))throw new G(`invalid-viewport`,`regular iOS snapshot presentation requires a positive finite viewport`,{field:`viewport`});return e.rect}function Dn(e,t,n,r=!0){K(e);let i=new Map,o=0;for(let s of e){let e=On(s,i,t,()=>{o+=1}),c=Pn(s.rect);if(kn(s,r),!c||!a(c)){An(s,c),i.set(s.index,e);continue}jn(s,c,e),Mn(s,c,t),i.set(s.index,Nn(s,c,e,n))}return{parentClipLookups:o}}function On(e,t,n,r){if(e.parentIndex===void 0)return n;r();let i=t.get(e.parentIndex);if(!i)throw new G(`invalid-presented-payload`,`regular iOS snapshot payload refers to a parent outside the payload`,{index:e.index,parentIndex:e.parentIndex});return i}function kn(e,t){if(!(e.hittable!==!0||t))throw new G(`invalid-presented-payload`,`iOS snapshot payload marked a node actionable without hittability evidence`,{index:e.index})}function An(e,t){if(e.hittable===!0)throw new G(`regular-degenerate-actionable-node`,`regular iOS snapshot node with a missing or degenerate frame is actionable`,{index:e.index,frame:t??e.rect})}function jn(e,t,n){if(!Fn(t,n))throw new G(`regular-node-outside-cumulative-clip`,`regular iOS snapshot node escaped its cumulative clip`,{index:e.index,frame:t,clip:n})}function Mn(e,t,n){if(!(e.hittable!==!0||e.enabled!==!1&&r(n,t.x+t.width/2,t.y+t.height/2)))throw new G(`invalid-presented-payload`,`regular iOS snapshot payload marked a disabled or off-viewport node actionable`,{index:e.index,frame:t})}function Nn(e,t,r,i){return i===`cursor-projected`&&wn.has(n(e.type??``))?t:r}function Q(e,t,n,r,i=!0){if(t===`raw`)return K(e),{parentClipLookups:0};if(!n)throw new G(`missing-viewport`,`regular iOS snapshot payload cannot be validated without a viewport`,{field:`viewport`});try{return Dn(e,n,r,i)}catch(e){throw e instanceof G&&e.code===`IOS_SNAPSHOT_ENGINE_FAILED`&&e.reason===`malformed-graph`?new G(`invalid-presented-payload`,e.message,e.details):e}}function Pn(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 Fn(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 In=new Set([`button`,`cell`,`checkbox`,`collectionview`,`keyboard`,`link`,`menuitem`,`picker`,`searchfield`,`securetextfield`,`segmentedcontrol`,`slider`,`scrollview`,`stepper`,`switch`,`tabbar`,`table`,`textfield`,`textview`,`webview`]);function Ln(e){let t=Xn(e.nodes),n=Bn(e,t);return e.projection===`raw`?Vn(n,e.depth,t):Hn(n,e.depth)}function Rn(e){let t=Xn(e.nodes);return e.projection===`raw`?Vn(e.nodes,e.depth,t):Hn(e.nodes,e.depth)}function zn(e){return e.parentIndex===void 0||In.has(n(e.type??``))||Zn(e)}function Bn(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||!Jn(i.raw,n))continue;let a=Yn(e.nodes,r,t);if(!(e.projection===`raw`||a.some(t=>zn(e.nodes[t].raw))))continue;let o=a.map(t=>e.nodes[t]);return qn(e.projection===`raw`&&e.depth!==null?o.filter(n=>$(n,t)-$(i,t)<=e.depth):o,$(i,t),t)}return[]}function Vn(e,t,n){let r=t===null?[...e]:e.filter(e=>$(e,n)<=t);return{nodes:r.map(e=>({...e.raw,rect:e.raw.rect})),sourceIndexes:r.map(e=>e.sourceIndex)}}function Hn(e,t){let n=[],r=[],i=new Map;for(let a of e){let e=Un(a,i),o=Wn(a,e,t,n.length);if(!o){Kn(a,e,i);continue}n.push(o),r.push(a.sourceIndex),i.set(a.raw.index,o)}return{nodes:n,sourceIndexes:r}}function Un(e,t){return e.raw.parentIndex===void 0?void 0:t.get(e.raw.parentIndex)}function Wn(e,t,n,r){if(!zn(e.raw))return;let i=t?(t.depth??0)+1:0;if(n!==null&&i>n)return;let a=Gn(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 Gn(e){if(e.raw.hittable!==void 0)return!!(e.raw.hittable===!0&&e.effectiveRect&&e.effectiveRect.width>0&&e.effectiveRect.height>0)}function Kn(e,t,n){t&&n.set(e.raw.index,t)}function qn(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,$(e,n)-t),parentIndex:e.raw.parentIndex===void 0?void 0:r.get(e.raw.parentIndex)}}))}function Jn(e,t){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.toLowerCase().includes(t))}function Yn(e,t,n){let r=$(e[t],n),i=[];for(let a=t;a<e.length&&!(a>t&&$(e[a],n)<=r);a+=1)i.push(a);return i}function $(e,t){return Math.max(0,e.raw.depth??t?.get(e.raw.index)??0)}function Xn(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 Zn(e){return[e.label,e.identifier,e.value].some(e=>typeof e==`string`&&e.trim().length>0)}function Qn(e,t,n=`cursor-projected`){$n(e,t);let r=e.validation.presentationKey.projection,i=r===`regular`?En(e.validation.viewport):void 0,a=e.validation.hittability.kind===`available`,o=er(e,r,i,n,a),s=tr(e.presentation.payload.nodes,r,t),c=s.compacted?nr(s.nodes,r,i,n,a,o):o;return{nodes:s.nodes,...i?{validatedViewport:i}:{},...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 $n(e,t){if(!rr(h(t),e.validation.presentationKey))throw new G(`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 G(`projection-mismatch`,`presented iOS snapshot does not match the requested acquisition intent`,{field:`acquisitionIntent`})}function er(e,t,n,r,i){let a=Q(e.presentation.payload.nodes,t,n,r,i);if(e.presentation.qualityPayload)try{Q(e.presentation.qualityPayload.nodes,t,n,r,i)}catch(e){throw e instanceof G?new G(`invalid-quality-payload`,e.message,e.details):e}return a}function tr(e,t,n){return t===`regular`&&n.interactiveOnly?{...U([...e]),compacted:!0}:{nodes:[...e],presentedIndexesBySourceIndex:ir(e),compacted:!1}}function nr(e,t,n,r,i,a){return t!==`regular`||!n?a:Q(e,t,n,r,i)}function rr(e,t){return e.projection===t.projection&&e.interactiveOnly===t.interactiveOnly&&e.depth===t.depth&&e.scope===t.scope&&e.customActions===t.customActions}function ir(e){return new Map(e.map(e=>[e.index,[e.index]]))}function ar(e,t,n={}){let r=sr(e,t,n),i=e.stage===`presented`?e.validation.presentationKey:h(t),a=e.stage===`acquired`?e.acquisition.truncated:e.presentation.payload.truncated;return{payload:{nodes:u(r.nodes),...a===void 0?{}:{truncated:a}},presentationKey:i,...r.qualityNotes?{qualityNotes:r.qualityNotes}:{},comparisonIdentity:g(e,t),residue:e.stage===`acquired`?[...e.acquisition.residue]:[...e.validation.residue],...r.validatedViewport?{validatedViewport:r.validatedViewport}:{},...e.stage===`acquired`?{presentedSurface:tn(e.acquisition.nodes,or(e.acquisition))}:{}}}function or(e){return e.truncated===void 0?`unstated`:e.truncated?`capped`:`complete`}function sr(e,t,n={}){let r=n.foldPolicy??`cursor-projected`;return e.stage===`acquired`?cr(e.acquisition,t,r):Qn(e,t,r)}function cr(e,t,n){if(ur(e,m(t)),t.projection===`raw`){K(e.nodes);let r=e.nodes.map(e=>({raw:e,sourceIndex:e.index})),i=Ln({nodes:r,projection:`raw`,scope:t.scope,depth:t.depth,foldPolicy:n}),a=t.scope===null?void 0:Rn({nodes:r,projection:`raw`,depth:null,foldPolicy:n}).nodes;return{nodes:i.nodes,...a?{qualityNodes:a}:{},presentedIndexesBySourceIndex:fr(e.nodes,i.nodes,i.sourceIndexes,dr(i.nodes)),stats:{presentedNodeCount:i.nodes.length,sourceNodeCount:e.nodes.length,parentClipLookups:0,modalContainedNodeCount:0}}}let r=Tn(e),i=!lr(e.residue),a=mn(e.nodes,r,t.interactiveOnly,n,{hittabilityAvailable:i}),o=Ln({nodes:a.nodes,projection:`regular`,scope:t.scope,depth:t.depth,foldPolicy:n}),s=t.interactiveOnly?U(o.nodes):{nodes:o.nodes,presentedIndexesBySourceIndex:dr(o.nodes)},c=Q(s.nodes,`regular`,r,n,i),l=t.scope===null?void 0:Rn({nodes:a.nodes,projection:`regular`,depth:null,foldPolicy:n}).nodes;return{nodes:s.nodes,validatedViewport:r,...a.qualityNotes?{qualityNotes:a.qualityNotes}:{},...l?{qualityNodes:l}:{},presentedIndexesBySourceIndex:fr(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 lr(e){return e.some(e=>e.kind===`unavailable-fact`&&e.fact===`hittability`)}function ur(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 G(`projection-mismatch`,`acquired iOS snapshot does not match the requested capture hint`,{projection:n.projection})}function dr(e){return new Map(e.map(e=>[e.index,[e.index]]))}function fr(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{U as a,Nt as i,Qn as n,G as r,ar as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Ii as e,ci as t,di as n,hi as r,xi as i}from"./sdk-batch.js";import{_ as a}from"./sdk-contracts.js";import{a as o,i as s}from"./snapshot-private-evidence.js";import{i as c,r as l}from"./ios-snapshot-planning.js";import{i as u,r as d,t as f}from"./ios-snapshot-engine.js";const p={"acquisition-depth":`iOS snapshot acquisition does not report hierarchy completeness; provider-side depth or child limits may omit nodes.`,hittability:`iOS snapshot acquisition does not provide hittability evidence; regular snapshots omit unverified hittability while raw snapshots preserve supplied facts.`,truncation:`iOS snapshot acquisition does not expose truncation metadata; tree completeness is not independently verified.`};function m(t,n){let r=l({raw:n?.raw,interactiveOnly:n?.interactiveOnly,depth:n?.depth,scope:n?.scope,customActions:n?.customActions,acquisitionIntent:t.acquisition.intent}),a=h(t,r);try{let n=v(t.acquisition),c=f(a,r),l=t.acquisition.viewport.kind===`reported`?i(c.validatedViewport):void 0,u=[...c.payload.nodes];return o(u,t.acquisition.viewport),n&&s(u,n),e({...c.qualityNotes?{qualityNotes:c.qualityNotes}:{},nodes:u,...t.acquisition.keyboard?{keyboard:t.acquisition.keyboard}:{},comparisonIdentity:c.comparisonIdentity,...t.acquisition.truncated===void 0?{}:{truncated:t.acquisition.truncated},...l?{viewport:l}:{},...c.presentedSurface?{presentedSurface:c.presentedSurface}:{},...g(t.acquisition.residue)},{backend:`xctest`,producer:t.acquisition.producer})}catch(e){_(e)}}function h(e,t){let n=c(t);return e.acquisition.intent===`full`?{stage:`acquired`,acquisition:{...e.acquisition,intent:`full`,hint:{...n,acquisitionIntent:`full`}}}:{stage:`acquired`,acquisition:{...e.acquisition,intent:`surface-observation`,hint:{...n,acquisitionIntent:`surface-observation`}}}}function g(e){let t=new Set(e.flatMap(e=>{if(e.kind===`missing-viewport`)return[`iOS snapshot acquisition did not provide a valid viewport (${e.reason}); retry with --raw to inspect the acquired tree, while regular presentation requires viewport evidence.`];if(e.kind===`collapsed-tab-bar-probe-failed`)return[`iOS snapshot could not read the tabs of a collapsed tab bar (${e.reason}); the bar is listed without its tabs.${e.reason===`budget-exhausted`?``:` Retry the snapshot.`}`];if(e.kind!==`unavailable-fact`)return[];let t=p[e.fact];return t?[t]:[]}));return t.size===0?{}:{warnings:[...t]}}function _(e){if(!(e instanceof d))throw e;let t=u(e),n=e.reason===`missing-viewport`||e.reason===`invalid-viewport`?`Use snapshot --raw to inspect the acquired iOS tree; regular presentation requires valid viewport evidence.`:void 0;throw new a(`COMMAND_FAILED`,e.message,{...t,...n?{hint:n}:{}},e)}function v(e){if(e.intent!==`full`||e.truncated!==!1||e.nodes.length===0||e.residue.some(e=>e.kind===`provider-pruned`||e.kind===`truncated`||e.kind===`unavailable-fact`&&e.fact===`acquisition-depth`))return;let i=[];for(let a of e.nodes)if([a.type,a.role].some(e=>{if(!e)return!1;let r=n(e).replaceAll(/[-_ ]/g,``);return r!==``&&(t(r,`ios`)||r===`textbox`||r===`searchbox`)})&&!(a.rect&&Object.values(a.rect).every(Number.isFinite)&&a.rect.width>=0&&a.rect.height>=0&&(a.rect.width===0||a.rect.height===0))){if(!r(a.rect))return;i.push({...a.rect})}return{rects:i}}export{m as presentIosSnapshotAcquisition};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e,w as t}from"./sdk-contracts.js";import{St as n}from"./sdk-io.js";import"./diagnostics.js";import{m as r}from"./alert-contract.js";import{i}from"./runner-contract.js";import{c as a}from"./runner-error-classification.js";import"./src8.js";import{o}from"./app-resolution.js";import{n as s}from"./alert.js";const c=`launch_confirmation_foreign_app`,l=1e4,u=2*(i+r);async function d(t){let r=await h(()=>t.awaitAlert());if(`outcome`in r)return r;let i=r.alert;if(!i)return{outcome:`absent`};if(!v(i))return n({level:`warn`,phase:`ios_launch_confirmation_unanswered`,data:{reason:`alert-unrecognized`,title:i.message,buttons:i.items}}),{outcome:`unanswered`,reason:`alert-unrecognized`};let a=await g(t);if(`outcome`in a)return a;if(a.owner===void 0)return b(`url-owner-unresolved`,{}),{outcome:`unanswered`,reason:`url-owner-unresolved`};if(a.owner!==t.appBundleId)throw new e(`COMMAND_FAILED`,`The launch URL asks to open ${a.owner} instead.`,{reason:c,foreignAppBundleId:a.owner,sessionAppBundleId:t.appBundleId,hint:`iOS is asking whether to open ${a.owner}. Answer it with alert accept or alert dismiss, and pass a launch URL whose scheme belongs to the session app.`});return await f(t,i)}async function f(e,t){for(;;){let r=await e.acceptAlert().then(()=>void 0,e=>({error:e}));if(!r)return _();let i=await m(e,t,r.error);if(i.outcome!==`unanswered`)return i;let o=p(e.deadlineAtMs);if(!a(r.error)||o<u)return b(`alert-still-present`,{}),i;n({level:`debug`,phase:`ios_launch_confirmation_reaccept`,data:{reason:`runner-main-thread-timeout`,remainingMs:o}})}}function p(e){return e===void 0?0:Math.max(0,e-Date.now())}async function m(e,t,n){let r=await h(()=>e.readAlert());return`outcome`in r?y(`alert-accept`)(n):r.alert&&v(r.alert)&&r.alert.message===t.message?{outcome:`unanswered`,reason:`alert-still-present`}:y(`alert-accept`)(n)}async function h(e){return await e().then(e=>({alert:e}),y(`alert-read`))}async function g(e){return await e.resolveUrlOwner().then(e=>({owner:e}),y(`url-owner`))}function _(){return{outcome:`accepted`}}function v(e){return e.launchConfirmationPrompt===!0}function y(t){return n=>(b(`step-failed`,{step:t,code:n instanceof e?n.code:void 0}),{outcome:`unreadable`,step:t})}function b(e,t){n({level:`debug`,phase:`ios_launch_confirmation_unanswered`,data:{reason:e,...t}})}async function x(e,t,n,r,i){let a=await n.then(e=>({interactor:e}),y(`runner`));return`outcome`in a?a:await d(S(e,t,a.interactor,r,i))}function S(e,{url:n,appBundleId:r},i,a,c){let u=i.awaitAlert?.bind(i),d=i.readAlert?.bind(i),f=i.acceptAlert?.bind(i);if(!u||!d||!f)throw t(`Apple interactor has no alert wait, read or accept leg`);let p={appBundleId:r,surface:`app`};return Object.freeze({appBundleId:r,deadlineAtMs:c,awaitAlert:async()=>await s(u({...p,timeoutMs:3e3})),readAlert:async()=>await s(d(p)),acceptAlert:async()=>await f(p),resolveUrlOwner:async()=>await o(e,n,{timeoutMs:l,signal:a})})}export{c as LAUNCH_CONFIRMATION_FOREIGN_APP_REASON,l as URL_OWNER_LOOKUP_TIMEOUT_MS,d as answerLaunchConfirmation,x as answerSimulatorLaunchConfirmation,S as createLaunchConfirmationPort};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{E as t,H as n,Q as r,St as i}from"./sdk-io.js";import"./diagnostics.js";import"./command.js";import"./retry.js";import a from"node:path";import{setTimeout as o}from"node:timers/promises";const s=`Contents/Info.plist`,c=/ASN:/;async function l(t,r){let a=n.fromTimeoutMs(2500);try{let e=await d(t,r,a);if(e===void 0)return;let n=await f(t,r,a);return n.size===0||!e&&!await u(t,r,[...n.values()].flat(),a)?void 0:n.size===1?[...n.keys()][0]:void 0}catch(t){i({level:`warn`,phase:`macos_launch_services_registration_probe_failed`,data:{bundleId:r,reason:t instanceof e?t.code:`probe_read_failed`}});return}}async function u(e,t,n,r){for(let i=0;i<10;i+=1){if(r.remainingMs()<300)return!1;await o(200);for(let i of n)if(await d(e,t,r,i)===!0)return!0}return!1}async function d(e,t,n,i){let a=_(n,1e3);if(a===void 0)return;let o;try{o=await e(`/usr/bin/lsappinfo`,[`find`,`bundleid=${t}`,...i===void 0?[]:[`pid=${i}`]],{allowFailure:!0,timeoutMs:a})}catch(e){if(r(e))return;throw e}if(o.exitCode===0)return c.test(o.stdout)}async function f(e,n,r){let o=_(r,2e3);if(o===void 0)return new Map;let c=await t({runCommand:e,timeoutMs:o});if(c.length===0)return i({level:`warn`,phase:`macos_launch_services_process_table_unreadable`,data:{bundleId:n}}),new Map;let l=new Map;for(let e of c){let t=p(e.command);if(t===void 0)continue;let n=l.get(t);n?n.push(e.pid):l.set(t,[e.pid])}if(l.size===0)return l;let u=Array.from(l.keys()),d=await m(e,u.map(e=>a.join(e,s)),r);return new Map(u.filter(e=>d.get(a.join(e,s))?.trim().toLowerCase()===n.toLowerCase()).map(e=>[e,l.get(e)]))}function p(e){if(!a.isAbsolute(e))return;let t=e.indexOf(`/Contents/MacOS/`);if(t<=0)return;let n=e.slice(0,t);return n.endsWith(`.app`)?n:void 0}async function m(e,t,n){let r=_(n,1500);if(r===void 0)return new Map;let i=await e(`plutil`,[`-extract`,`CFBundleIdentifier`,`raw`,...t],{allowFailure:!0,timeoutMs:r}),a=g(i.stdout).split(`
|
|
2
2
|
`),o=t.filter(e=>!h(i.stderr,e));if(a.length!==o.length)return new Map;let s=new Map;return o.forEach((e,t)=>{let n=a[t]?.trim();n&&s.set(e,n)}),s}function h(e,t){return e.split(`
|
|
3
3
|
`).some(e=>e.startsWith(t)&&e[t.length]===`:`)}function g(e){return e.endsWith(`
|
|
4
4
|
`)?e.slice(0,-1):e}function _(e,t){let n=e.remainingMs();return n<100?void 0:Math.min(t,n)}export{l as resolveListedRunningBundle};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{D as e}from"./sdk-batch.js";import{_ as t,v as n}from"./sdk-contracts.js";import{N as r}from"./sdk-batch-runner.js";import{h as i}from"./lease-scope.js";import{c as a}from"./request.js";function o(r,i){let a=e(r.command)?.command;throw new t(`UNSUPPORTED_OPERATION`,`${i} cannot run within a bounded composite`,{reason:n,shape:i,...a?{standaloneCommandName:a}:{},hint:`Run the original ${a??`refused`} operation separately with its original arguments and options, the same --session value, and the same private CLI context. Inspect completed steps before retrying the batch or replay.`,dispatched:`no`})}function s(e){return a(e.meta?.requestId)!==void 0}function c(e){return i(e)}function l(e,t){let n=c(e),i=n.leaseId??t?.leaseId,a=n.tenantId??t?.tenantId,o=n.runId??t?.runId;if(!(!a||!o||!i))return r({tenantId:a,runId:o,leaseId:i,leaseBackend:n.leaseBackend??t?.backend,leaseProvider:n.leaseProvider??t?.leaseProvider,deviceKey:n.deviceKey??t?.deviceKey,clientId:n.clientId??t?.clientId,expiresAt:t?.expiresAt})}function u(e,t){let n=c(e),i=t?.lease??t?.deviceLease??void 0;return r({tenantId:n.tenantId??i?.tenantId,runId:n.runId??i?.runId,leaseId:n.leaseId??i?.leaseId,leaseTtlMs:n.leaseTtlMs,leaseBackend:n.leaseBackend??i?.leaseBackend,leaseProvider:n.leaseProvider??i?.leaseProvider,deviceKey:n.deviceKey??i?.deviceKey,clientId:n.clientId??i?.clientId})}function d(e){let t=e.meta,n=r({leaseId:f(t?.leaseId),clientId:f(t?.clientId),tenantId:f(t?.tenantId),runId:f(t?.runId),leaseProvider:f(t?.leaseProvider),deviceKey:f(t?.deviceKey)});return Object.keys(n).length>0?n:void 0}function f(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}export{u as a,c as i,s as n,d as o,o as r,l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e,t}from"./sdk-contracts.js";import{b as n,p as r,r as i}from"./lease-scope.js";import{F as a}from"./device.js";import{S as o}from"./daemon-http.js";import s from"node:crypto";const c=`default`;function l(t){let n=Number.isInteger(t.defaultLeaseTtlMs)?Math.max(1,Number(t.defaultLeaseTtlMs)):6e4,r=Number.isInteger(t.minLeaseTtlMs)?Math.max(1,Number(t.minLeaseTtlMs)):i,a=Number.isInteger(t.maxLeaseTtlMs)?Math.max(r,Number(t.maxLeaseTtlMs)):6e5;return t=>{if(!Number.isInteger(t))return n;let i=Number(t);if(i<r||i>a)throw new e(`INVALID_ARGS`,`Lease ttlMs must be between ${r} and ${a}.`);return i}}function u(e){if(!e)return;let t=e.trim();if(t&&/^[a-zA-Z0-9._-]{1,128}$/.test(t))return t}function d(e){if(!e)return;let t=e.trim();if(t&&/^[a-f0-9]{16,128}$/i.test(t))return t.toLowerCase()}function f(t){let n=d(t);if(!n)throw new e(`INVALID_ARGS`,`Invalid lease id.`);return n}function p(n){let r=(n??``).trim().toLowerCase();if(!r)return`ios-simulator`;let i=t.find(e=>e===r);if(i)return i;throw new e(`INVALID_ARGS`,`Unsupported lease backend: ${n??``}`)}function m(t){if(t===void 0)return;let n=t.trim();if(!n||n.length>256||!/^[\u0020-\u007E]+$/.test(n))throw new e(`INVALID_ARGS`,`Invalid device key. Use 1-256 printable characters.`);return n}function h(e){return _(e,`client id`,128)}function g(e){return _(e,`lease provider`,64)}function _(t,n,r){if(t===void 0)return;let i=t.trim();if(!i||i.length>r||!/^[a-zA-Z0-9._-]+$/.test(i))throw new e(`INVALID_ARGS`,`Invalid ${n}. Use 1-${String(r)} chars: letters, numbers, dot, underscore, hyphen.`);return i}function v(t){let n=o(t);if(!n)throw new e(`INVALID_ARGS`,`Invalid tenant id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);return n}function y(t){let n=u(t);if(!n)throw new e(`INVALID_ARGS`,`Invalid run id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);return n}function b(e){return{backend:p(e.leaseBackend),leaseProvider:g(e.leaseProvider),deviceKey:m(e.deviceKey),clientId:h(e.clientId),tenantId:v(e.tenantId),runId:y(e.runId),ttlMs:e.ttlMs,retainOnClose:e.retainOnClose}}function x(e){return!!(e.leaseProvider??e.deviceKey??e.clientId)}function S(e,t){return!t.tenantId||!t.runId?!1:[[e.leaseProvider,t.leaseProvider],[e.deviceKey,t.deviceKey],[e.clientId,t.clientId]].every(([e,t])=>!e||!!t)}function C(t,n){let r=T(n);if(r.tenantId&&t.tenantId!==r.tenantId||r.runId&&t.runId!==r.runId||r.leaseBackend&&t.backend!==r.leaseBackend||r.leaseProvider&&t.leaseProvider!==r.leaseProvider||r.deviceKey&&t.deviceKey!==r.deviceKey||r.clientId&&t.clientId!==r.clientId)throw new e(`UNAUTHORIZED`,`Lease does not match tenant/run scope`,{reason:`LEASE_SCOPE_MISMATCH`})}function w(t){let n=p(t.leaseBackend),i=o(t.tenantId);if(!i)throw new e(`INVALID_ARGS`,`tenant isolation requires tenant id.`);let s=u(t.runId);if(!s)throw new e(`INVALID_ARGS`,`tenant isolation requires run id.`);let c=d(t.leaseId);if(!c){let n=r({leaseProvider:g(t.leaseProvider)});throw n&&!t.leaseId?.trim()?a(n):new e(`INVALID_ARGS`,`tenant isolation requires lease id.`,{hint:`Allocate a lease with leases.allocate and pass its leaseId.`})}return{...t,tenantId:i,runId:s,leaseId:c,leaseBackend:n}}function T(t){let n=o(t.tenantId),r=u(t.runId);if(t.tenantId&&!n)throw new e(`INVALID_ARGS`,`Invalid tenant id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);if(t.runId&&!r)throw new e(`INVALID_ARGS`,`Invalid run id. Use 1-128 chars: letters, numbers, dot, underscore, hyphen.`);return{tenantId:n,runId:r,leaseBackend:t.leaseBackend?p(t.leaseBackend):void 0,leaseProvider:g(t.leaseProvider),deviceKey:m(t.deviceKey),clientId:h(t.clientId)}}function E(t,n){if(x(t)&&!S(t,n))throw new e(`UNAUTHORIZED`,`Lease owner scope is required`,{reason:`LEASE_SCOPE_REQUIRED`})}function D(e,t){return e.tenantId===t.tenantId&&e.runId===t.runId&&e.backend===t.backend&&e.leaseProvider===t.leaseProvider&&e.deviceKey===t.deviceKey&&e.clientId===t.clientId}function O(e){if(e.deviceKey)return JSON.stringify([e.backend,e.leaseProvider??c,e.deviceKey])}function k(e){return JSON.stringify([e.tenantId,e.runId,e.backend,e.leaseProvider??c,e.deviceKey??`*`])}function A(e,t,n,r=s.randomBytes(16).toString(`hex`)){return{leaseId:r,tenantId:e.tenantId,runId:e.runId,backend:e.backend,...e.leaseProvider?{leaseProvider:e.leaseProvider}:{},...e.deviceKey?{deviceKey:e.deviceKey}:{},...e.clientId?{clientId:e.clientId}:{},...e.retainOnClose?{retainOnClose:!0}:{},createdAt:n,heartbeatAt:n,expiresAt:n+t}}function j(e){return e.expiresAt-e.heartbeatAt}function M(t){return new e(`DEVICE_IN_USE`,`Device is already leased`,{reason:`DEVICE_LEASE_BUSY`,deviceKey:t.deviceKey,backend:t.backend,leaseProvider:t.leaseProvider,expiresAt:t.expiresAt,hint:`Retry after the lease expires or close the owning session.`})}function N(e){return n({leaseId:e.leaseId,tenantId:e.tenantId,runId:e.runId,leaseBackend:e.backend,leaseProvider:e.leaseProvider,deviceKey:e.deviceKey,clientId:e.clientId})}export{f as _,M as a,j as c,b as d,m as f,g,d as h,l as i,N as l,p as m,C as n,D as o,w as p,A as r,O as s,E as t,k as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as e,_ as t}from"./sdk-contracts.js";import{n,s as r}from"./device2.js";import{t as i}from"./android.js";import{r as a}from"./client-options.js";import{CAPTURE_OPEN_BUDGET_MS as o}from"./capture-lifecycle.js";const s=12e4,c=3e4,l=45e3,u=o+1e4;async function d(e,t){let{awaitLimrunWithinBudget:n,joinOutcomeFailures:r,keepLimrunObserved:i,workOutstandingFailure:a}=await import(`./lifecycle-budget.js`).then(e=>e.n);if(!(await n(t.creation,s)).ok)return await p(e,t);let o=t.session?.instanceId??t.rentedInstanceId;if(o===void 0)return await m(e,t);let c=i(e.endCapture(t)),l=i(v(t)),d=await g(e,t,o),h=await x(l),_=await n(c,u);return{cleanup:d.cleanup,instanceId:o,failure:r(d.failure,r(h,f(_,a))),cause:d.cause,capture:_.ok?_.value:void 0}}function f(t,n){return t.ok?t.value?.closeFailure===void 0?void 0:`Capture close failed: ${t.value.closeFailure}`:`rejected`in t?`Capture record refused to be written: ${e(t.error)}`:n(`Capture record`,u)}async function p(e,t){let{joinOutcomeFailures:n,keepLimrunObserved:r,workOutstandingFailure:i}=await import(`./lifecycle-budget.js`).then(e=>e.n),a=r(h(e,t)),o=i(`Instance create for lease '${t.lease.leaseId}'`,s),c=t.rentedInstanceId;if(c===void 0)return{cleanup:`uncertain`,creationPending:!0,instanceId:void 0,failure:o,cause:void 0,capture:await a};let l=await g(e,t,c),u=await x(v(t));return{cleanup:l.cleanup,creationPending:!0,instanceId:c,failure:n(l.failure,u??o),cause:l.cause,capture:await a}}async function m(e,t){return{cleanup:`none`,instanceId:void 0,failure:void 0,cause:void 0,capture:await h(e,t)}}async function h(e,t){let{awaitLimrunWithinBudget:n}=await import(`./lifecycle-budget.js`).then(e=>e.n),r=await n(e.endCapture(t),u);return r.ok?r.value:void 0}async function g(e,t,n){let{awaitLimrunWithinBudget:r,workOutstandingFailure:i}=await import(`./lifecycle-budget.js`).then(e=>e.n);if(t.deletedInstanceId===n)return{cleanup:`confirmed`,failure:void 0,cause:void 0};if((t.session?.ownership??`created`)===`attached`)return{cleanup:`attached`,failure:void 0,cause:void 0};let a=t.pendingDelete?.instanceId===n?t.pendingDelete.requested:e.deleteInstance(t.platform,n);if(t.pendingDelete?.instanceId!==n){let e={instanceId:n,requested:a};t.pendingDelete=e;let r=()=>{t.pendingDelete===e&&(t.pendingDelete=void 0)};a.then(r,r)}let o=await r(a,c);return o.ok?(o.value.failure===void 0&&(t.deletedInstanceId=n),{cleanup:o.value.failure===void 0?`confirmed`:`uncertain`,failure:o.value.failure,cause:o.value.cause}):(a.then(e=>{e.failure===void 0&&_(t,n)},()=>void 0),{cleanup:`uncertain`,failure:`rejected`in o?`Delete of instance '${n}' could not be attempted`:i(`Delete of instance '${n}'`,c),cause:void 0})}function _(e,t){e.deletedInstanceId=t}function v(e){return e.localRelease??=y(e),e.localRelease}async function y(e){e.keepAlive&&clearInterval(e.keepAlive),e.keepAlive=void 0;let t=e.session??await b(e);if(t===void 0)return;let{awaitLimrunWithinBudget:n}=await import(`./lifecycle-budget.js`).then(e=>e.n),r=Promise.allSettled([t.syncCache?.dispose(),t.platform===`android`?i(t):t.runner.dispose()]).then(e=>{let t=e.find(e=>e.status===`rejected`);if(t?.status===`rejected`)throw t.reason}),a=n(r,l).then(()=>{t.client.disconnect()}),o=(await Promise.allSettled([r,a])).find(e=>e.status===`rejected`);if(o?.status===`rejected`)throw o.reason}async function b(e){return await e.creation.catch(()=>void 0),e.session}async function x(t){let{awaitLimrunWithinBudget:n,workOutstandingFailure:r}=await import(`./lifecycle-budget.js`).then(e=>e.n),i=await n(t,l);if(!i.ok)return`rejected`in i?`Local teardown refused to finish: ${e(i.error)}`:r(`Local teardown`,l)}async function S(e,t,n){if(n===void 0)return await C(e,t);let r=await n;if(r.cleanup===`uncertain`)throw T(t.leaseId,r);if(r.instanceId===void 0)return;let{networkArtifacts:i}=await import(`./network-har.js`);return{limrunInstanceId:r.instanceId,...r.failure===void 0?{}:{warnings:[{code:`LIMRUN_TEARDOWN_INCOMPLETE`,message:r.failure,limrunInstanceId:r.instanceId}]},...r.capture?{cloudArtifacts:i(r.capture)}:{}}}async function C(e,t){let i=r(t.backend);if(!i||!e)return;let o=`provider=${n},leaseId=${t.leaseId}`,s=(i===`ios`?await e.iosInstances.list({labelSelector:o}):await e.androidInstances.list({labelSelector:o})).getPaginatedItems().map(e=>e.metadata.id),{awaitLimrunWithinBudget:l,workOutstandingFailure:u}=await import(`./lifecycle-budget.js`).then(e=>e.n),d=[];for(let n of s){let r=await l(a(e,i,n),c),o=r.ok?r.value:{failure:u(`Delete of instance '${n}'`,c),cause:void 0};o.failure!==void 0&&k(`Recovery could not confirm instance '${n}' of lease '${t.leaseId}' deleted`,{limrunInstanceId:n,limrunInstanceIds:s},o.failure,w(s,d),o.cause),d.push(n)}if(s.length!==0)return{limrunInstanceId:s[0],limrunInstanceIds:s,limrunInstanceCount:s.length}}function w(e,t){let n=`Ask Limrun to delete: ${e.filter(e=>!t.includes(e)).join(`, `)}.`;return t.length===0?n:`${n} ${`${t.length>1?`Instances`:`Instance`} ${t.join(`, `)} ${t.length>1?`were`:`was`} confirmed deleted.`}`}function T(e,t){let{instanceId:n}=t;return k(`Limrun instance for lease '${e}' was not confirmed deleted`,n===void 0?{}:{limrunInstanceId:n},t.failure,n===void 0?`Release lease '${e}' again once its instance create names the instance it rented.`:`Release lease '${e}' again, or ask Limrun to delete instance '${n}'.`,t.cause)}function E(e,n,r){let{instanceId:i}=r,a=i===void 0?void 0:r.cleanup===`uncertain`?`The ${n} of this lease could not confirm instance '${i}' deleted. Release the lease again, or ask Limrun to delete it.`:r.cleanup===`attached`?`Instance '${i}' is the caller's own attached instance and was left running. Open a new lease.`:`Instance '${i}' was ended by the ${n} of this lease. Open a new lease.`;throw new t(`DEVICE_IN_USE`,`Limrun lease '${e.leaseId}' was released while its instance was being prepared`,{reason:`limrun_lease_released_mid_allocation`,...i===void 0?{hint:`Instance create for lease '${e.leaseId}' may still rent one. Check Limrun.`}:{limrunInstanceId:i,...a===void 0?{}:{hint:a}},...r.cleanup===`uncertain`?{retriable:!0,...r.failure===void 0?{}:{cause:r.failure}}:{}},r.cause)}function D(t,n,r){let{instanceId:i}=n;return k(`Limrun lease '${t.leaseId}' could not be allocated, and its instance could not be deleted`,i===void 0?{}:{limrunInstanceId:i},O(n.failure,r===void 0?void 0:`create failed: ${e(r)}`),i===void 0?`Ask Limrun what lease '${t.leaseId}' rented — this runtime could not name the instance.`:`Ask Limrun to delete instance '${i}' — this runtime could not confirm the delete.`,n.cause??r)}function O(e,t){return e===void 0?t:t===void 0?e:`${e}; ${t}`}function k(e,n,r,i,a){throw new t(`COMMAND_FAILED`,e,{reason:`limrun_instance_delete_unconfirmed`,retriable:!0,...n,...r===void 0?{}:{cause:r},hint:i},a)}function A(e){let t=e.map(e=>e.instanceId).filter(e=>e!==void 0),n=e.length===1?``:`s`;return k(`Limrun cleanup left ${String(e.length)} lease${n} unended, ${String(t.length)} with a known instance`,{limrunInstanceIds:t},j(e),t.length===0?M(e):`Ask Limrun to delete: ${t.join(`, `)}.`,e.find(e=>e.cause!==void 0)?.cause)}function j(e){if(!e.every(e=>e.failure===void 0))return e.map(e=>e.failure??`an unconfirmed delete`).join(`; `)}function M(e){return`Limrun may still bill work this runtime could not name: ${e.map(e=>e.failure??`an unconfirmed delete`).join(`; `)}.`}export{E as allocationRefusedForTake,A as cleanupLeftInstancesRunning,D as createLeftInstanceRunning,d as disposeLimrunLeaseOwner,S as releaseLimrunLease};
|
package/dist/src/lease-scope.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{_ as t}from"./sdk-contracts.js";import{N as n}from"./sdk-batch-runner.js";var r=e({CLOUD_LEASE_PROVIDER:()=>a,LEASE_DEVICE_SPEC_KEYS:()=>_,MIN_LEASE_WINDOW_MS:()=>M,PROVIDER_INSTANCE_ENDED:()=>I,REMOTE_LEASE_IDLE_TTL_MS:()=>N,buildDaemonRpcRequest:()=>V,deviceSpecInvalidError:()=>w,deviceSpecUnsupportedError:()=>C,findMissingProxyLeaseFields:()=>j,isInactiveLeaseError:()=>F,isProviderInstanceEndedError:()=>L,isProxyLeaseScope:()=>k,leaseDeviceKey:()=>D,leaseProviderRequiringRuntime:()=>A,leaseScopeFromOptions:()=>l,leaseScopeFromRequest:()=>c,leaseScopeToAllocateRequest:()=>f,leaseScopeToCommandFlags:()=>d,leaseScopeToConnectionMetadata:()=>E,leaseScopeToHeartbeatRequest:()=>p,leaseScopeToLeaseRpcParams:()=>h,leaseScopeToReleaseRequest:()=>m,leaseScopeToRequestMeta:()=>u,parseLeaseDeviceKey:()=>O,readEndedLeases:()=>R,readLeaseAllocateProviderFlags:()=>v,readLeaseDevice:()=>x,readLeaseDeviceSpec:()=>y,requireLeaseDeviceSpec:()=>b});const i=`proxy`,a=`cloud`,o=new Set([i,a]),s=[`leaseId`,`tenantId`,`runId`,`clientId`,`deviceKey`];function c(e){return n({tenantId:e.meta?.tenantId??B(e.flags,`tenant`),runId:e.meta?.runId??B(e.flags,`runId`),leaseId:e.meta?.leaseId??B(e.flags,`leaseId`),leaseTtlMs:e.meta?.leaseTtlMs,leaseRetainOnClose:e.meta?.leaseRetainOnClose,leaseBackend:e.meta?.leaseBackend,leaseProvider:e.meta?.leaseProvider??B(e.flags,`leaseProvider`)??B(e.flags,`provider`),deviceKey:e.meta?.deviceKey??B(e.flags,`deviceKey`),clientId:e.meta?.clientId??B(e.flags,`clientId`)})}function l(e){return n({tenantId:e.tenant,runId:e.runId,leaseId:e.leaseId,leaseTtlMs:e.leaseTtlMs??e.ttlMs,leaseRetainOnClose:e.retainOnClose,leaseBackend:e.leaseBackend,leaseProvider:e.leaseProvider??e.provider,deviceKey:e.deviceKey,clientId:e.clientId})}function u(e){return n({tenantId:e.tenantId,runId:e.runId,leaseId:e.leaseId,leaseTtlMs:e.leaseTtlMs,leaseRetainOnClose:e.leaseRetainOnClose,leaseBackend:e.leaseBackend,leaseProvider:e.leaseProvider,deviceKey:e.deviceKey,clientId:e.clientId})}function d(e){return n({tenant:e.tenantId,runId:e.runId,leaseId:e.leaseId,leaseBackend:e.leaseBackend,leaseProvider:e.leaseProvider,deviceKey:e.deviceKey,clientId:e.clientId})}function f(e){return n({tenantId:e.tenantId??``,runId:e.runId??``,leaseId:e.leaseId,leaseBackend:e.leaseBackend,leaseProvider:e.leaseProvider,deviceKey:e.deviceKey,clientId:e.clientId,ttlMs:e.leaseTtlMs,retainOnClose:e.leaseRetainOnClose})}function p(e){return z(e)}function m(e){let{ttlMs:t,...n}=z(e);return n}function h(e,t,r){let i=n({...r.includeTokenParam?{token:r.token}:{},session:r.session,tenantId:e.tenantId,runId:e.runId,leaseProvider:e.leaseProvider,clientId:e.clientId,deviceKey:e.deviceKey});switch(t){case`lease_allocate`:return{...i,...n({leaseId:e.leaseId,ttlMs:e.leaseTtlMs,retainOnClose:e.leaseRetainOnClose,backend:e.leaseBackend})};case`lease_heartbeat`:return{...i,...n({leaseId:e.leaseId,ttlMs:e.leaseTtlMs})};case`lease_release`:return{...i,...n({leaseId:e.leaseId})}}}const g=`platform.target.device.udid.serial.iosSimulatorDeviceSet.androidDeviceAllowlist.providerApp.providerOsVersion.providerDeviceType.providerProject.providerBuild.providerSessionName.providerDeviceOrientation.providerGeoLocation.providerTimezone.providerAppiumVersion.providerLanguage.providerLocale.providerNetworkProfile.providerCustomNetwork.providerNoResignApp.providerNetworkLogs.providerNetworkHosts.awsProjectArn.awsDeviceArn.awsAppArn.awsRegion.awsInteractionMode`.split(`.`),_=[`osVersion`,`imageTag`,`deviceMode`,`deviceBaseline`,`physical`];function v(e){let t={};for(let n of g){let r=e?.[n];(typeof r==`string`||typeof r==`boolean`)&&(t[n]=r)}let{spec:n,invalidKeys:r}=y(e);Object.assign(t,n);for(let n of r)t[n]=e?.[n];return t}function y(e){let t={},n=[];for(let r of _){let i=e?.[r];i!==void 0&&(typeof i==(r===`physical`?`boolean`:`string`)?i===!0?t[r]=!0:typeof i==`string`&&i.trim()&&(t[r]=i):n.push(r))}return{spec:t,keys:_.filter(e=>e in t),invalidKeys:n}}function b(e){let{spec:t,keys:n,invalidKeys:r}=y(e);if(r.length>0)throw w(r);return{spec:t,keys:n}}function x(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=T(t.model),r=T(t.osVersion);if(!n||!r||typeof t.physical!=`boolean`)return;let i=T(t.imageTag),a=T(t.deviceMode),o=S(t.baseline);return{model:n,osVersion:r,...i?{imageTag:i}:{},...a?{deviceMode:a}:{},...o?{baseline:o}:{},physical:t.physical}}function S(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n=typeof t.name==`string`&&t.name.trim().length>0?t.name:void 0,{version:r}=t;if(!(!n||typeof r!=`number`||!Number.isInteger(r)||r<1))return{name:n,version:r}}function C(e,n=`This daemon cannot pick a device by OS version, image tag, device mode, baseline, or physical/virtual class.`,r={}){return new t(`UNSUPPORTED_OPERATION`,n,{...r,reason:`device-spec-unsupported`,keys:[...e],hint:`Drop --os, --image-tag, --device-mode, --device-baseline and --physical, or connect through a proxy whose backend picks devices by spec.`})}function w(e){return new t(`INVALID_ARGS`,`osVersion, imageTag, deviceMode and deviceBaseline take a string, and physical takes a boolean.`,{reason:`device-spec-invalid`,keys:[...e]})}function T(e){return typeof e==`string`&&e.trim().length>0?e.trim():void 0}function E(e){let t=n({leaseProvider:e.leaseProvider,deviceKey:e.deviceKey,clientId:e.clientId});return Object.keys(t).length>0?t:void 0}function D(e){return`${e.platform}:${e.target??`mobile`}:${e.id}`}function O(e){let t=/^([^:]+):([^:]+):(.+)$/.exec(e??``);if(!t)return;let[,n,r,i]=t;return{platform:n,target:r,id:i}}function k(e){return e.leaseProvider===i}function A(e){let{leaseProvider:t}=e;return t===void 0||o.has(t)?void 0:t}function j(e){return k(e)?s.filter(t=>!e[t]):[]}const M=5e3,N=3e5,P=new Set([`LEASE_NOT_FOUND`,`LEASE_EXPIRED`,`LEASE_REVOKED`]);function F(e){return typeof e==`object`&&!!e&&e.code===`UNAUTHORIZED`&&P.has(e.details?.reason)}const I=`provider-instance-ended`;function L(e){return typeof e==`object`&&!!e&&e.code===`COMMAND_FAILED`&&e.details?.reason===`provider-instance-ended`}function R(e){let t=(e.ok?e.data:e.error.details)?.endedLeases;return Array.isArray(t)?t.flatMap(e=>{if(typeof e!=`object`||!e)return[];let{leaseId:t,outcome:n}=e;return typeof t==`string`&&n===`released`?[{leaseId:t,outcome:n}]:[]}):[]}function z(e){return n({leaseId:e.leaseId??``,tenantId:e.tenantId,runId:e.runId,leaseBackend:e.leaseBackend,leaseProvider:e.leaseProvider,deviceKey:e.deviceKey,clientId:e.clientId,ttlMs:e.leaseTtlMs})}function B(e,t){let n=e?.[t];return typeof n==`string`?n:void 0}function V(e,t){let{id:n}=t;return H(e.command)?{jsonrpc:`2.0`,id:n,method:U(e.command),params:{...W(e,e.command,t),...e.command===`lease_allocate`?v(e.flags):{},...e.command===`lease_allocate`&&e.meta?.devicePin?{devicePin:e.meta.devicePin}:{},...e.command===`lease_allocate`&&e.meta?.providerCredentialFingerprint?{providerCredentialFingerprint:e.meta.providerCredentialFingerprint}:{}}}:{jsonrpc:`2.0`,id:n,method:`agent_device.command`,params:e}}function H(e){return e===`lease_allocate`||e===`lease_heartbeat`||e===`lease_release`}function U(e){switch(e){case`lease_allocate`:return`agent_device.lease.allocate`;case`lease_heartbeat`:return`agent_device.lease.heartbeat`;case`lease_release`:return`agent_device.lease.release`}}function W(e,t,n){return h(c(e),t,{includeTokenParam:n.includeTokenParam,token:e.token,session:e.session})}export{O as C,y as D,x as E,b as O,r as S,v as T,d as _,V as a,m as b,j as c,k as d,D as f,f as g,c as h,N as i,F as l,l as m,_ as n,w as o,A as p,M as r,C as s,a as t,L as u,E as v,R as w,u as x,p as y};
|
package/dist/src/lease.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ct as e}from"./sdk-batch.js";import{A as t,S as n,_ as r,m as i}from"./sdk-contracts.js";import{St as a}from"./sdk-io.js";import"./diagnostics.js";import{R as o}from"./sdk-device.js";import{b as s,d as c,f as l,g as u,p as d,u as f,y as p}from"./lease-scope.js";import{n as m}from"./catalog.js";import{c as h}from"./device-shell.js";import{r as g}from"./artifact-tracking.js";import{_,f as v,g as y,l as b,m as x}from"./lease-registry-scope.js";import{d as S,f as C}from"./request.js";import{a as w,i as T}from"./lease-context.js";import{n as E}from"./context.js";import{n as D,r as O}from"./lease-release.js";async function k(t){let{req:n,sessionName:r,sessionStore:i,leaseRegistry:a,providerRuntimeIds:o,failedPlugins:c,providerCredentials:l,leaseLifecycleProvider:u,cloudArtifactProvider:d,endSessionsForLease:f}=t,p=T(n);switch(n.command){case m.artifacts:return{ok:!0,data:await V(n,w(n,i.get(r)),a,d,t.host.env)};case`lease_allocate`:{J(p.leaseBackend);let r=y(p.leaseProvider);z(r,o??[],c??[]),B({leaseProvider:r,leaseBackend:p.leaseBackend},n.meta?.providerCredentialFingerprint,l);let{lease:i,reused:s}=await A(n,{...p,leaseProvider:r},a,t.host),d=n.meta?.requestId;return await a.runDeviceMutation(i,async()=>{let r,o=u?.allocate?a.retainLeaseWork(i,()=>!C(d)):void 0;try{r=await u?.allocate?.(i,{...R(n,t.host),signal:S(d),deadline:Date.now()+e}),D(a,i,r)}catch(e){throw await N(i,s,d,u,a),e}finally{o?.release()}if(C(d))throw await P(i,u,a);return{ok:!0,data:{lease:a.getLease(b(i))??i,reused:s,...r?{provider:r}:{}}}})}case`lease_heartbeat`:return await F(t,p);case`lease_release`:{let e=s(p),r=a.getLease(e);q(r);let i=await a.runDeviceMutation(r,async()=>await O(a,u,r,e,R(n,t.host)));return r&&i.registryReleased&&await f?.(r.leaseId),{ok:!0,data:{released:i.registryReleased,...i.provider?{provider:i.provider}:{}}}}default:return null}}async function A(e,t,n,r){let i=u(t),a=e.meta?.devicePin&&c(t),o=a?void 0:n.renewRequestedLease(i);if(o)return{lease:o,reused:!0};let s=a&&t.leaseId?_(t.leaseId):void 0,l=s?n.listActiveLeases().find(e=>e.leaseId===s):void 0,d=await j(e,{...t,deviceKey:v(t.deviceKey)??l?.deviceKey},r.env),f=new Set(n.listActiveLeases().map(e=>e.leaseId)),p=n.allocateLease(d?{...i,deviceKey:d}:i);return{lease:p,reused:f.has(p.leaseId)}}async function j(e,t,n){let r=e.meta?.devicePin;if(!c(t)||t.deviceKey&&!r)return;let a=r?await import(`./device-selection-resolver.js`).then(e=>e.t):void 0,s=e.flags??{},u=r&&a?a.effectiveDevicePinSelector(r,s):s,d={platform:u.platform,target:s.target,device:u.device,udid:u.udid,serial:u.serial,iosSimulatorDeviceSet:s.iosSimulatorDeviceSet,androidDeviceAllowlist:s.androidDeviceAllowlist};if(t.deviceKey&&r)return await M(t.deviceKey,r,d,n);let{hasDeviceSelectionInput:f}=await import(`./device-selector-intent.js`).then(e=>e.t);if(!f(d))return;let{resolveTargetDevice:p}=await import(`./dispatch-resolve.js`).then(e=>e.n),m=await p({...d,platform:d.platform??(t.leaseBackend?i(t.leaseBackend):void 0)},{env:n});return r&&a&&a.assertDeviceHonorsPin(r,m,d),l({platform:o(m),target:m.target,id:m.id})}async function M(e,t,n,i){let{listDeviceInventory:a}=await import(`./device-inventory-context.js`).then(e=>e.t),{buildDeviceInventoryRequestFromFlags:s}=await import(`./dispatch-resolve.js`).then(e=>e.n),{assertDeviceHonorsPin:c}=await import(`./device-selection-resolver.js`).then(e=>e.t),u=(await a(s(n,i))).find(t=>l({...t,platform:o(t)})===e);if(!u)throw new r(`INVALID_ARGS`,`The lease device key does not match an available pinned device.`,{reason:`device_pin_conflict`,pin:t.selector,pinSource:`${t.source.kind===`project`?`project `:``}config file ${t.source.path}`,deviceKey:e});return c(t,u,n),e}async function N(e,t,n,r,i){if(!t){i.releaseLease(b(e));return}if(C(n))throw await P(e,r,i)}async function P(e,n,r){let i=b(e),a,o;try{a=await O(r,n,e,i)}catch(e){o=t(e),a={registryReleased:r.releaseLease(i).released}}return I(e,a,o)}async function F(e,n){let{leaseRegistry:i,leaseLifecycleProvider:o,req:s,endSessionsForLease:c}=e,l=i.heartbeatLease(p(n)),u,d;try{u=await o?.heartbeat?.(l,{...R(s,e.host),signal:S(s.meta?.requestId)})}catch(e){if(!(e instanceof r)||!f(e))throw e;i.endProviderLease(b(l)),d=e}if(d){try{await c?.(l.leaseId,`PROVIDER_INSTANCE_ENDED`)}catch(e){a({level:`warn`,phase:`lease_provider_ended_session_teardown_failed`,data:{leaseId:l.leaseId,error:t(e)}})}throw d}return{ok:!0,data:{lease:l,...u?{provider:u}:{}}}}function I(e,t,r){let i=t.provider?.providerSessionId,a=Array.isArray(t.provider?.warnings)?t.provider.warnings:[],o=t.registryReleased&&r===void 0&&a.length===0;return n({leaseId:e.leaseId,leaseProvider:e.leaseProvider,released:o,registryReleased:t.registryReleased,providerSessionId:i,...a.length>0?{warnings:a}:{},...r===void 0?{}:{releaseError:r},hint:L(o,e.leaseId,i)})}function L(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 R(e,t){return{flags:e.flags,...typeof e.flags?.providerApp==`string`?{initialApp:e.flags.providerApp}:{},cwd:E(e,t),...e.internal?.publicNetworkOnly?{publicNetworkOnly:!0}:{}}}function z(e,t,n){let i=d({leaseProvider:e});if(i===void 0||t.includes(i))return;let a=n.flatMap(e=>e.state===`failed`&&(e.provider===i||e.provider===void 0)?[{...e.provider===void 0?{}:{provider:e.provider},...e.package===void 0?{}:{package:e.package},code:e.error.code,...e.error.reason===void 0?{}:{reason:e.error.reason},message:e.error.message}]:[]);throw new r(`UNSUPPORTED_OPERATION`,`Provider "${i}" is not available in this daemon runtime.`,{reason:`provider-not-registered`,provider:i,registeredProviders:[...t],...a.length>0?{failedPlugins:a}:{},hint:a.length>0?`Fix the plugin that failed to register (see failedPlugins or agent-device daemon status), restart the daemon, then retry lease allocation.`:`Restart the daemon with ${i} configured, then retry lease allocation.`})}function B({leaseProvider:e,leaseBackend:t},n,i){if(!i||!e||!n)return;let a=i.fingerprint(e,t);if(n!==a)throw new r(`INVALID_ARGS`,a?`The running daemon holds different ${e} credentials than this shell.`:`The running daemon was started without the ${e} credentials this shell holds.`,{reason:`provider-credentials-changed`,provider:e,hint:`Stop it with agent-device daemon stop --state-dir ${h(i.stateDir)}, then rerun the command so a new daemon starts with this shell's environment.`})}async function V(e,t,n,r,i){let a=K(e.flags,`providerSessionId`);return H(t,a)?await U(t.tenantId,i):await W(t,a,n,r)}function H(e,t){return c(e)||!e.leaseProvider&&!t}async function U(e,t){let n=await g(e,t);return{source:`daemon`,status:`ready`,artifacts:n,...n.length===0?{message:`No daemon artifacts available.`}:{}}}async function W(e,t,n,i){if(!e.leaseProvider)throw new r(`INVALID_ARGS`,`artifacts requires --provider for provider session lookup or an active cloud connection.`);if(!e.leaseId&&!t)throw new r(`INVALID_ARGS`,`artifacts requires an active cloud lease or --provider-session <id>.`);let a=G(n,e,t),o=await i?.listCloudArtifacts?.({provider:e.leaseProvider,leaseId:a?.leaseId??e.leaseId,providerSessionId:t});if(!o)throw new r(`UNSUPPORTED_OPERATION`,`Cloud artifacts are not available for provider "${e.leaseProvider}".`);return o}function G(e,t,n){if(!n)return;let i=e.resolveProviderSession({provider:t.leaseProvider,providerSessionId:n,tenantId:t.tenantId});if(i)return i;throw new r(`UNAUTHORIZED`,`Provider session is not owned by the request tenant`,{reason:`PROVIDER_SESSION_NOT_OWNED`})}function K(e,t){let n=e?.[t];return typeof n==`string`&&n.trim().length>0?n.trim():void 0}function q(e){if(e?.backend===`macos-app`)throw new r(`UNAUTHORIZED`,`A macos-app lease is released by the host administrator.`,{reason:`MACOS_APP_LEASE_HOST_OWNED`,retriable:!1,hint:`Disconnect only drops the client connection; the host ends the lease.`})}function J(e){if(x(e)===`macos-app`)throw new r(`UNAUTHORIZED`,`A macos-app lease is allocated by the host administrator.`,{reason:`MACOS_APP_LEASE_HOST_ALLOCATED`,retriable:!1,hint:`Ask the host administrator for a macos-app lease and connect with its leaseId.`})}export{k as handleLeaseCommands};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as e}from"./sdk-contracts.js";import{St as t}from"./sdk-io.js";import"./diagnostics.js";import{o as n,t as r}from"./artifact-tracking.js";import{i}from"./session-tenant-scope.js";import{a,o}from"./record-runtime-response.js";import s from"node:fs";function c(s,c,u){let d=s.session.lease;if(!d||!a(c,u))return;let f=i(d.tenantId,s.address),p=o(c).filter(e=>typeof e.path==`string`),m=[];try{for(let e of p)m.push(n({artifactPath:e.path,tenantId:d.tenantId,artifactType:e.artifactType,fileName:e.fileName,sessionName:f}))}catch(n){for(let e of m)r(e);for(let e of p)l(e.path);t({level:`warn`,phase:`leased_session_recording_retention_failed`,data:{session:s.address,leaseId:d.leaseId,error:e(n)}});return}t({level:`info`,phase:`leased_session_recording_retained`,data:{session:s.address,sessionName:f,leaseId:d.leaseId,artifactIds:m}})}function l(e){try{s.rmSync(e,{force:!0})}catch{}}export{c as retainLeasedSessionRecording};
|
package/dist/src/legacy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as e}from"./sdk-contracts.js";import{y as t}from"./sdk-batch-runner.js";import{a as n}from"./manifest.js";import{t as r}from"./host5.js";import{pathToFileURL as i}from"node:url";function a(a,s,c){let l=a.agentDevicePlugin,u=async t=>{let r=await import(i(n(s,l.entry)).href);if(typeof r.default!=`function`)throw new e(`INVALID_ARGS`,`Plugin must export a default factory: ${a.name}`,{reason:`invalid_plugin`});return await r.default(t)},d=async(n,i)=>{let s=await u(r(n,c));try{let n=t(s)?s.connection:void 0;if(!t(n)||!o(n.resolve)||!o(n.verify))throw new e(`INVALID_ARGS`,`Plugin connection must provide resolve and verify: ${a.name}`,{reason:`invalid_plugin`});return await i(n)}finally{let e=t(s)?s.runtime:void 0;o(e?.shutdown)&&await Promise.allSettled([e.shutdown()])}};return{apiVersion:2,provider:l.provider,credentials:{variables:l.credentialVariables??[]},...l.connection?{connection:{capabilities:l.connection,resolve:async e=>await d(e.env,t=>t.resolve(e)),verify:async e=>await d(e.env,t=>t.verify(e))}}:{},setup:async e=>{let n=await u(e);return t(n)&&`webDriver`in n?{webDriver:n.webDriver}:n}}}function o(e){return typeof e==`function`}export{a as adaptLegacyPlugin};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{S as t,_ as n}from"./sdk-contracts.js";import r from"node:fs";import i from"node:path";import{Readable as a}from"node:stream";import{pipeline as o}from"node:stream/promises";var s=e({downloadLimrunFile:()=>c});async function c(e){let t=AbortSignal.timeout(e.timeoutMs),s=e.signal?AbortSignal.any([t,e.signal]):t;try{await r.promises.mkdir(i.dirname(e.destinationPath),{recursive:!0});let t=await fetch(e.url,{method:`GET`,headers:e.headers,signal:s});if(!t.ok)throw await l(t,e);if(!t.body)throw new n(`COMMAND_FAILED`,`Limrun download returned no body`,{url:e.url});await o(a.fromWeb(t.body),r.createWriteStream(e.destinationPath),{signal:s})}catch(n){throw await r.promises.rm(e.destinationPath,{force:!0}).catch(()=>{}),d(n,e,t,s)}}async function l(e,t){return new n(`COMMAND_FAILED`,`Limrun download failed with HTTP ${e.status}`,{url:t.url,statusCode:e.status,reason:`limrun_download_http_error`,body:await u(e)})}async function u(e){if(!e.body)return``;let t=e.body.getReader(),n=[],r=0;try{for(;r<500;){let{done:e,value:i}=await t.read();if(e)break;let a=500-r;n.push(i.subarray(0,a)),r+=i.byteLength}}finally{t.cancel().catch(()=>{})}return Buffer.concat(n).toString(`utf8`)}function d(e,r,i,a){if(e instanceof n)return e;if(r.signal?.aborted&&a.reason===r.signal.reason){let e=r.signal.reason;return e instanceof n?e:e instanceof Error&&e.name===`TimeoutError`?new n(`COMMAND_FAILED`,`Limrun download deadline expired`,{url:r.url,reason:`limrun_download_timeout`,timeoutMs:r.timeoutMs},e):t(void 0,e)}return i.aborted?new n(`COMMAND_FAILED`,`Limrun download timed out`,{url:r.url,timeoutMs:r.timeoutMs,reason:`limrun_download_timeout`}):new n(`COMMAND_FAILED`,`Limrun download failed`,{url:r.url,reason:`limrun_download_failed`,cause:e instanceof Error?e.message:String(e)})}export{s as n,c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{S as t,_ as n}from"./sdk-contracts.js";import"./tool-provider-facade.js";import{t as r}from"./limrun-download-file.js";import{randomUUID as i}from"node:crypto";import{promises as a}from"node:fs";import o from"node:os";import s from"node:path";var c=e({createLimrunSimulatorFiles:()=>l,readLimrunAppInfo:()=>u});function l(e,o,c){let l=e=>AbortSignal.any([o,c,e].filter(e=>!!e)),d=async(e,r)=>{let i=e.timeoutMs??15e3,a=AbortSignal.timeout(i),s=AbortSignal.any([o,e.requestCancellation===`ignore`?void 0:c,e.signal,a].filter(e=>!!e));try{return s.throwIfAborted(),await r(s)}catch(e){throw s.aborted?s.reason===a.reason&&a.aborted?new n(`COMMAND_FAILED`,`Remote simulator file operation timed out`,{timeoutMs:i}):s.reason instanceof n?s.reason:t(void 0,s.reason):e}},f=(t,n,r)=>{let i=new URL(`${e.apiUrl.replace(/\/$/,``)}/${t}`);return i.searchParams.set(t===`files/list`?`path`:`name`,n),r&&(i.searchParams.set(`bundleId`,r.bundleId),i.searchParams.set(`containerType`,r.containerType)),i},p=async(t,r,i,a)=>{i.throwIfAborted();let o=await fetch(r,{method:t,headers:{Authorization:`Bearer ${e.token}`,...a?{"Content-Type":`application/octet-stream`}:{}},body:a,signal:i,redirect:`error`});if(!o.ok)throw await o.body?.cancel(),new n(`COMMAND_FAILED`,`Limrun file ${t} failed (${o.status})`,{status:o.status});return o},m={copyToHost:async t=>{await r({url:f(`files`,t.sourcePath,t).href,headers:{Authorization:`Bearer ${e.token}`},destinationPath:t.destinationPath,timeoutMs:t.timeoutMs,signal:l(t.signal)})},openContainer:async e=>{let t=()=>d(e,async t=>(await(await p(`GET`,f(`files/list`,``,e),t)).json()).entries.map(e=>e.name));try{await t()}catch(e){if(e instanceof n&&e.details?.status===404)return null;throw e}return{list:t,remove:t=>d(e,async n=>{await(await p(`DELETE`,f(`files`,t,e),n)).body?.cancel()}),ensureDirectory:t=>d(e,async n=>{let r=`${t}/.agent-device-${i()}`;await(await p(`PUT`,f(`files`,r,e),n,new Uint8Array)).body?.cancel(),await(await p(`DELETE`,f(`files`,r,e),n)).body?.cancel()})}},stageFile:async(e,t)=>{let n=f(`files`,`agent-device-${i()}${s.extname(e)}`),r=()=>d({requestCancellation:`ignore`,timeoutMs:15e3},async e=>{await(await p(`DELETE`,n,e)).body?.cancel()});return{path:(await d({signal:t},async t=>await(await p(`PUT`,n,t,await a.readFile(e,{signal:t}))).json()).catch(async e=>{throw await r().catch(()=>{}),e})).path,[Symbol.asyncDispose]:r}}},h=new Map;return{simulatorFiles:m,readInfoPlist:async t=>{let n=t.bundleId;if(h.has(n))return h.get(n);let r=await u(e,t.bundleId,l(t.signal),t.timeoutMs);return h.set(n,r),r}}}async function u(e,t,i,c=15e3){let l=await a.mkdtemp(s.join(o.tmpdir(),`agent-device-app-plist-`));try{let n=s.join(l,`Info.plist`),o=new URL(`${e.apiUrl.replace(/\/$/,``)}/files`);o.search=new URLSearchParams({name:`Info.plist`,bundleId:t,containerType:`app`}).toString(),await r({url:o.href,headers:{Authorization:`Bearer ${e.token}`},destinationPath:n,timeoutMs:c,signal:i});let{parseApplePlist:u}=await import(`./tool-provider-facade.js`).then(e=>e.t);return await u(await a.readFile(n,{signal:i}))}catch(e){if(e instanceof n&&e.details?.statusCode===404)return null;throw e}finally{await a.rm(l,{recursive:!0,force:!0})}}export{c as n,l as t};
|