agent-device 0.21.13 → 0.21.15
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.13.apk → agent-device-android-ime-helper-0.21.15.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.15.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.13.manifest.json → agent-device-android-ime-helper-0.21.15.manifest.json} +4 -4
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.15.apk +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.15.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.13.manifest.json → agent-device-android-snapshot-helper-0.21.15.manifest.json} +6 -6
- package/apple/snapshot-bridge/SnapshotBridgeRuntime.m +11 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +110 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +4 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerMainOwnedState.swift +27 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedTextEntry.h +8 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedTextEntry.m +26 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +12 -19
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +59 -20
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AlertObservation.swift +2 -3
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandDispatch.swift +179 -91
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +21 -24
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +1 -1
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+GestureExecution.swift +9 -13
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +36 -49
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+MainThreadWork.swift +11 -15
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +136 -29
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +20 -21
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+PrivateAXPresentation.swift +3 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScreenRecorder.swift +6 -5
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollDragExecution.swift +12 -24
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +22 -42
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +15 -18
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotAcquisition.swift +73 -31
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +20 -11
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCaptureTarget.swift +9 -7
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotExecution.swift +5 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotTiming.swift +2 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +51 -19
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +5 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedTextEntry.swift +78 -10
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +32 -2
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntryFocus.swift +7 -4
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextTyping.swift +23 -0
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +17 -10
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +8 -9
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TypeExecution.swift +9 -15
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +12 -11
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotCoordinateSpace.swift +16 -19
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotGeometry.swift +24 -9
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotModels.swift +66 -10
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationInvariant.swift +12 -10
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotPresentationProjection.swift +1 -0
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFold.swift +27 -5
- package/dist/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotVisibilityFoldProjection.swift +1 -0
- package/dist/src/adapter.js +1 -1
- package/dist/src/adb-executor.js +1 -1
- package/dist/src/adb-failure.js +1 -1
- package/dist/src/adb-transport.js +1 -1
- package/dist/src/agent-browser-provider.js +1 -1
- package/dist/src/agent-browser-tool.js +1 -1
- package/dist/src/agent-device-client.js +2 -2
- package/dist/src/ai-sdk.js +1 -1
- package/dist/src/alert-runtime.js +1 -1
- package/dist/src/android-adb.d.ts +1 -8
- package/dist/src/android-input-ownership.js +1 -1
- package/dist/src/android-snapshot-quality.js +1 -0
- package/dist/src/android-system-chrome.js +1 -1
- package/dist/src/android.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 +1 -1
- package/dist/src/app-lifecycle2.js +1 -1
- package/dist/src/app-log-files.js +1 -1
- package/dist/src/app-log-runtime2.js +1 -1
- package/dist/src/app-resolution.js +2 -2
- package/dist/src/apple-runner-platform.js +1 -1
- package/dist/src/application-lifecycle-interaction.js +1 -1
- package/dist/src/archive.js +1 -1
- package/dist/src/artifact-download.js +1 -1
- package/dist/src/auth-session.js +1 -1
- package/dist/src/auth.js +1 -1
- package/dist/src/backend-snapshot-options.js +1 -1
- package/dist/src/boot-diagnostics.js +1 -1
- package/dist/src/capture-disclosure.js +1 -1
- package/dist/src/capture.js +1 -1
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +2 -2
- package/dist/src/cli.js +4 -4
- package/dist/src/click-button.js +1 -1
- package/dist/src/client-metro.js +1 -1
- package/dist/src/client-types.d.ts +102 -95
- package/dist/src/clipboard-shell-response.js +1 -1
- package/dist/src/command-schema.js +1 -1
- package/dist/src/command-tools.js +3 -3
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/connection.js +1 -1
- package/dist/src/contracts.d.ts +1 -1
- package/dist/src/contracts.js +1 -1
- package/dist/src/daemon-client-lifecycle.js +1 -1
- package/dist/src/daemon.js +1 -1
- package/dist/src/debug-symbols-facade.js +1 -1
- package/dist/src/device-claim-rule.js +2 -2
- package/dist/src/device-input-state.d.ts +15 -2
- package/dist/src/device-inventory-context.js +1 -1
- package/dist/src/device-rotation.js +1 -1
- package/dist/src/device-selection-resolver.js +1 -1
- package/dist/src/device-session.js +1 -1
- package/dist/src/device-shell.js +1 -1
- package/dist/src/device2.js +1 -1
- package/dist/src/devicectl.js +1 -1
- package/dist/src/diagnostics.js +1 -1
- package/dist/src/dispatch-resolve.js +1 -1
- package/dist/src/doctor2.js +1 -1
- package/dist/src/engine-eval-script.js +1 -1
- package/dist/src/error.js +1 -1
- package/dist/src/exec.js +1 -1
- package/dist/src/file.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/format.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/harmonyos.js +1 -1
- package/dist/src/helper.js +2 -2
- package/dist/src/human-control-contract.js +1 -1
- package/dist/src/human-control.js +1 -1
- package/dist/src/index.d.ts +7 -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-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 +4 -4
- package/dist/src/interactor2.js +1 -1
- package/dist/src/interactors.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/internal/daemon.js +2 -2
- package/dist/src/internal/png-worker.js +1 -1
- package/dist/src/internal/run-script-http-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-snapshot-acquisition.js +1 -1
- package/dist/src/ios-snapshot-engine.js +1 -0
- package/dist/src/ios-snapshot-runtime.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/limrun-download-file.js +1 -1
- package/dist/src/limrun-runtime-dependencies.js +1 -1
- package/dist/src/limrun.d.ts +16 -3
- package/dist/src/linux.js +1 -1
- package/dist/src/location-coordinates.js +1 -1
- package/dist/src/managed-device-scope.js +1 -1
- package/dist/src/mechanics.js +17 -17
- package/dist/src/mobile-snapshot-semantics.js +1 -1
- package/dist/src/multitouch-support.js +1 -1
- package/dist/src/native-build-cache.js +1 -0
- package/dist/src/observation.js +1 -1
- package/dist/src/overlay.js +3 -0
- 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-host.js +1 -1
- package/dist/src/platform-runtime-managed-owner.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +4 -4
- package/dist/src/platform-runtime-runtime-hints.js +1 -1
- package/dist/src/platform-runtime-screen-recording-apple-simulator-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-finalizer-host.js +1 -1
- package/dist/src/platform-runtime-screen-recording-process-host.js +1 -1
- package/dist/src/platform-runtime.js +1 -1
- package/dist/src/platform-runtime2.js +1 -1
- package/dist/src/png-crop-bytes.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/prepare-kind.js +1 -1
- package/dist/src/provider-session-ownership.js +1 -1
- package/dist/src/provider-webdriver.js +1 -1
- package/dist/src/proxy.js +1 -1
- package/dist/src/quality-warnings.js +1 -1
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/recording.js +1 -1
- package/dist/src/rect-center.js +1 -1
- package/dist/src/register-builtins.js +1 -1
- package/dist/src/registry.js +36 -36
- package/dist/src/remote-config2.js +1 -1
- package/dist/src/replay-divergence.js +1 -1
- package/dist/src/replay.js +1 -1
- package/dist/src/reporting.js +1 -1
- package/dist/src/request-admission.js +1 -1
- package/dist/src/request-cancel.js +1 -1
- package/dist/src/request-runtime-binding.js +1 -1
- package/dist/src/retry.js +1 -1
- package/dist/src/runner-cache-metadata.js +1 -1
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-dev-tools-security.js +1 -1
- package/dist/src/runner-device-readiness.js +1 -1
- package/dist/src/runner-disposal.js +1 -1
- package/dist/src/runner-error-classification.js +1 -1
- package/dist/src/runner.js +1 -1
- package/dist/src/runtime-transport-hints.js +1 -1
- package/dist/src/runtime.js +1 -3
- package/dist/src/runtime10.js +2 -2
- package/dist/src/runtime2.js +4 -4
- package/dist/src/runtime3.js +1 -1
- package/dist/src/runtime4.js +5 -5
- package/dist/src/runtime5.js +1 -1
- package/dist/src/runtime6.js +1 -1
- package/dist/src/runtime7.js +1 -1
- package/dist/src/runtime8.js +1 -1
- package/dist/src/runtime9.js +1 -1
- package/dist/src/screen-recording-admission-ledger.js +1 -1
- 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/screenshot-density.js +1 -1
- package/dist/src/screenshot-image.js +1 -1
- package/dist/src/screenshot-overlay-draw.js +1 -1
- package/dist/src/screenshot-runtime.js +1 -1
- package/dist/src/screenshot.js +1 -1
- package/dist/src/screenshot3.js +1 -1
- package/dist/src/script.js +1 -1
- package/dist/src/scroll-command.d.ts +13 -6
- package/dist/src/scroll-command.js +1 -1
- package/dist/src/scroll-gesture.js +1 -1
- package/dist/src/sdk-batch-runner.js +2 -2
- package/dist/src/sdk-batch.js +2 -2
- package/dist/src/sdk-contracts.d.ts +59 -12
- 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-io.js +1 -1
- package/dist/src/sdk-remote-config.js +1 -1
- package/dist/src/sdk-selectors.d.ts +1 -1
- package/dist/src/selection.js +0 -0
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/server.js +1 -1
- package/dist/src/session-allocation.js +1 -1
- package/dist/src/session-routing.js +1 -1
- package/dist/src/session-runtime-admission.js +1 -1
- package/dist/src/session-snapshot.js +1 -1
- package/dist/src/session-store.js +1 -1
- package/dist/src/session.js +1 -1
- package/dist/src/session2.js +4 -4
- package/dist/src/settings.js +1 -1
- package/dist/src/settings2.js +1 -0
- package/dist/src/simctl.js +1 -1
- package/dist/src/simulator-state.js +1 -1
- package/dist/src/simulator.js +1 -1
- package/dist/src/snapshot-capture-annotations.js +1 -1
- package/dist/src/snapshot-desktop-projection.js +1 -1
- package/dist/src/snapshot-runtime-binding.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot-state.js +1 -1
- package/dist/src/snapshot2.js +1 -1
- package/dist/src/snapshot3.js +1 -1
- package/dist/src/snapshot4.js +1 -1
- package/dist/src/src.js +1 -1
- package/dist/src/src4.js +1 -1
- package/dist/src/src7.js +1 -1
- package/dist/src/src8.js +1 -1
- package/dist/src/string-enum.js +1 -1
- package/dist/src/surface-snapshot.js +1 -1
- package/dist/src/takeover.js +1 -1
- package/dist/src/text-entry-focus.js +1 -1
- package/dist/src/tool-provider-facade.js +1 -1
- package/dist/src/tool-provider.js +2 -2
- package/dist/src/tool-provider2.js +1 -1
- package/dist/src/touch-runtime.js +1 -1
- package/dist/src/transport.js +1 -1
- package/dist/src/tree.js +1 -1
- package/dist/src/tv-remote.js +1 -1
- package/dist/src/type-text-runtime.js +1 -1
- package/dist/src/verified-file.js +1 -1
- package/dist/src/video.js +1 -1
- package/dist/src/viewport.js +1 -1
- package/dist/src/web.js +1 -1
- package/dist/src/web2.js +1 -1
- package/dist/src/webdriver-source.js +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.13.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.13.apk +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.13.apk.sha256 +0 -1
- package/dist/src/absence-observation-errors.js +0 -1
- package/dist/src/runner-presentation.js +0 -1
- package/dist/src/semantic-index.js +0 -1
- package/dist/src/snapshot-process.js +0 -1
- package/dist/src/snapshot-scope.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`);o=t.pop()??``;for(let e of t)await T(r,w(`${e}\n`,a))};return{write:async e=>await u(async()=>await d(
|
|
3
|
-
`);return d<0?``:u.slice(d+1)}function C(e,t){return
|
|
1
|
+
import{A as e}from"./sdk-contracts.js";import{D as t,d as n,f as r,h as i}from"./sdk-device.js";import{n as a}from"./session.js";import{r as o}from"./diagnostics.js";import{C as s}from"./owner-identity.js";import{i as c,r as l}from"./verified-file.js";import{c as u,h as d,u as ee}from"./exec.js";import"./file.js";import"./diagnostics2.js";import"./command.js";import"./process.js";import{t as f}from"./platform-runtime-android-mechanics.js";import{t as p}from"./perf-runtime.js";import{a as m,n as h}from"./durable-resource.js";import{n as te}from"./async-lifecycle.js";import{m as g}from"./src7.js";import{r as ne}from"./device-inventory-context.js";import{t as re}from"./app-log-files.js";import{n as ie,r as ae,t as _}from"./platform-runtime-app-log-process.js";import{createTemporaryTextFile as v,n as oe,r as se,t as ce}from"./platform-runtime-host.js";import{i as y,n as b,t as x}from"./platform-runtime-screen-recording-process-host.js";import S from"node:fs";import{setTimeout as le}from"node:timers/promises";async function ue(e,t){t=C(e,t),re(t);let n=l(t),r;try{r=S.createWriteStream(t,{fd:n,autoClose:!0})}catch(e){throw S.closeSync(n),e}let i;r.on(`error`,e=>{i??=e});let a=fe(),o=``,s=Promise.resolve(),c,u=e=>{let t=s.then(e);return s=t.catch(()=>void 0),t},d=async e=>{let t=`${o}${e}`.split(`
|
|
2
|
+
`);o=t.pop()??``;for(let e of t)await T(r,w(`${e}\n`,a))};return{write:async e=>await u(async()=>await d(pe(e))),[Symbol.asyncDispose]:async()=>{c??=u(async()=>{if(o&&=(await T(r,w(o,a)),``),await me(r),i)throw i}),await c}}}async function de(e,t,n){if(t=C(e,t),!Number.isInteger(n)||n<1||n>1048576)throw TypeError(`App-log tail size must be between 1 byte and 1 MiB`);let r=c(t);if(r===void 0)return``;let i=S.fstatSync(r).size,a=Math.min(i,n),o=i-a,s=+(o>0),l=Buffer.alloc(a+s);try{S.readSync(r,l,0,l.length,o-s)}finally{S.closeSync(r)}let u=l.subarray(s).toString(`utf8`);if(s===0||l[0]===10)return u;let d=u.indexOf(`
|
|
3
|
+
`);return d<0?``:u.slice(d+1)}function C(e,t){return ae({sessionsDir:e,pathname:t,basename:`app.log`,label:`App-log output`})}function fe(){return(process.env.AGENT_DEVICE_APP_LOG_REDACT_PATTERNS??``).split(`,`).map(e=>e.trim()).filter(Boolean).flatMap(e=>{try{return[new RegExp(e,`gi`)]}catch{return[]}})}function w(e,t){return t.reduce((e,t)=>e.replace(t,`[REDACTED]`),e)}function pe(e){return typeof e==`string`?e:Buffer.from(e).toString(`utf8`)}async function T(e,t){t&&await new Promise((n,r)=>{e.write(t,e=>e?r(e):n())})}async function me(e){e.closed||await new Promise((t,n)=>{e.once(`error`,n),e.end(()=>{e.off(`error`,n),t()})})}function he(e){return Object.freeze({appLogs:Object.freeze({resolveSession:e.resolveSessionArtifacts,readRecent:async(t,n)=>{let{outputPath:r}=e.resolveSessionArtifacts(t);return ge(r,n)},readProcessMarker:async t=>{let{pidPath:n}=e.resolveSessionArtifacts(t);return await e.processes.readMarker(n)}}),networkTransports:Object.freeze({resolve:e.resolveTransport})})}function ge(e,t){if(!Number.isInteger(t)||t<1||t>2e4)throw TypeError(`Network app-log scan lines must be between 1 and 20000`);let n=c(e);if(n===void 0)return Object.freeze({path:e,exists:!1,text:``,skippedLines:0});try{let r=E(S.readFileSync(n,`utf8`),t);return Object.freeze({path:e,exists:!0,...r})}finally{S.closeSync(n)}}function E(e,t){let n=e.split(`
|
|
4
4
|
`),r=Math.max(0,n.length-t);return Object.freeze({text:n.slice(r).join(`
|
|
5
|
-
`),skippedLines:r})}function E(e={}){let t=Object.freeze({resolve:async e=>{let{createAndroidScreenRecordingTransport:t}=await import(`./platform-runtime-screen-recording-android-host.js`);return await t(e)}}),n=Object.freeze({resolve:async e=>{let{resolveWebScreenRecordingTransport:t}=await import(`./platform-runtime-screen-recording-web-host.js`);return await t(e)}}),r=Object.freeze({prepare:async e=>{let{createScreenRecordingOutputHost:t}=await import(`./platform-runtime-screen-recording-output-host.js`);await t().prepare(e)},copy:async e=>{let{createScreenRecordingOutputHost:t}=await import(`./platform-runtime-screen-recording-output-host.js`);await t().copy(e)},remove:async e=>{let{createScreenRecordingOutputHost:t}=await import(`./platform-runtime-screen-recording-output-host.js`);return await t().remove(e)}}),i=Object.freeze({sniff:async e=>{let{createScreenRecordingFinalizer:t}=await import(`./platform-runtime-screen-recording-finalizer-host.js`);await t().sniff(e)},complete:async(e,t)=>{let{createScreenRecordingFinalizer:n}=await import(`./platform-runtime-screen-recording-finalizer-host.js`);return await n().complete(e,t)}}),a=e.ownedProcesses??Object.freeze({replace:()=>{},clear:()=>{}});return Object.freeze({apple:D(),android:t,harmony:O(),web:n,outputs:r,finalize:i,ownedProcesses:a})}function D(){let e=async()=>{let{createAppleScreenRecordingHost:e}=await import(`./platform-runtime-screen-recording-apple-host.js`);return e()};return Object.freeze({availability:async t=>(await e()).availability(t),runRunner:async(t,n,r)=>await(await e()).runRunner(t,n,r),startSimulator:async(t,n,r)=>await(await e()).startSimulator(t,n,r),inspectProcess:async t=>await(await e()).inspectProcess(t),terminateProcess:async t=>await(await e()).terminateProcess(t),inspectRunner:async(t,n,r)=>await(await e()).inspectRunner(t,n,r),retrieveRunnerRecording:async(t,n,r,i)=>await(await e()).retrieveRunnerRecording(t,n,r,i),captureClockAnchor:async(t,n,r)=>await(await e()).captureClockAnchor(t,n,r),isRunnerBundleId:async t=>await(await e()).isRunnerBundleId(t)})}function O(){let e=async()=>{let{createHarmonyScreenRecordingHost:e}=await import(`./platform-runtime-screen-recording-harmony-host.js`);return e()};return Object.freeze({start:async(t,n,r)=>await(await e()).start(t,n,r),stop:async(t,n)=>await(await e()).stop(t,n),findMedia:async(t,n,r)=>await(await e()).findMedia(t,n,r),stageMedia:async(t,n,r)=>await(await e()).stageMedia(t,n,r),stagedFileSize:async(t,n,r)=>await(await e()).stagedFileSize(t,n,r),pull:async(t,n,r)=>await(await e()).pull(t,n,r),remove:async(t,n,r)=>await(await e()).remove(t,n,r),removeMedia:async(t,n,r)=>await(await e()).removeMedia(t,n,r)})}function k(e={}){let t=e.ownedProcesses??Object.freeze({replace:()=>{},clear:()=>{}});return Object.freeze({hostCapture:Object.freeze({info:Object.freeze({source:`system-audio`,backend:`macos-screencapturekit`,sourceCount:1,notes:A}),start:async e=>{let{startMacOsAudioProbeProcess:t}=await import(`./macos-facade.js`),n=await t(e),r=await y(n.child.pid??void 0);return Object.freeze({...r===void 0?{}:{marker:r},wait:n.wait,terminate:async()=>{n.child.kill(`SIGTERM`),await n.wait.catch(()=>{})}})},inspectProcess:async e=>b(e),terminateProcess:async e=>await v([e])}),web:Object.freeze({resolve:async e=>{if(e.platform!==`web`)return;let{resolveWebProvider:t}=await import(`./src6.js`).then(e=>e.i),n=await t(),r=n.probeAudio?.bind(n);if(r)return Object.freeze({probe:async e=>await r({action:e.action,durationMs:e.durationMs,bucketMs:e.bucketMs})})}}),ownedProcesses:t})}function A(e){return[`Audio probe samples host system audio through ScreenCaptureKit for this ${n(e)?`iOS simulator`:e.platform===`android`?`Android emulator`:`macOS session`}; it is not app-instrumented audio.`,`Screen Recording permission is required for host system audio capture.`,`Other audible host apps can contribute to the measured buckets.`]}const j=f,M=async()=>await import(`./perf-facade.js`),N=Object.freeze({resourceKind:p,version:1,encode:e=>e,decode:we});async function P(t,n,r){if(r.kind!==`xctrace`)throw H(`Apple`,`xctrace`,r.kind);let i=r.template??(r.mode===`cpu-profile`?`Time Profiler`:`Animation Hitches`),a=await M(),o=await a.startAppleXctracePerfCapture({device:t,appBundleId:r.appId,mode:r.mode,template:i,outPath:r.outPath}),s=await y(o.child.pid??void 0);if(!s)throw await a.cleanupAppleXctracePerfCapture(o).catch(()=>{}),new e(`COMMAND_FAILED`,`Apple xctrace exposed no exact process identity`);return I(t,n,r,{family:`apple`,marker:s,capture:Se(o)},L(o),z(`started`,o))}async function F(e,t,n){let r=await j(),i;if(n.mode===`cpu-profile`){if(n.kind!==`simpleperf`)throw H(`Android`,`simpleperf`,n.kind);i=await r.startAndroidSimpleperfProfile(e,n.appId,n.outPath)}else{if(n.kind!==`perfetto`)throw H(`Android`,`perfetto`,n.kind);i=await r.startAndroidPerfettoTrace(e,n.appId,n.outPath)}return I(e,t,n,{family:`android`,capture:i},_e(e,i),B(i))}function I(e,n,r,i,a,o){return Object.freeze({pendingHandle:new h(a),envelope:m({resourceKind:p,sessionId:r.sessionId,device:t(e),owner:n,fence:r.fence,lifecycle:`open`,descriptor:ee(N,i)}),response:o})}function L(e){return R({initialOutPath:e.outPath,inspect:()=>z(`started`,e),finish:async t=>await M().then(async n=>z(`stopped`,await n.stopAppleXctracePerfCapture(e,t))),cleanup:async()=>await M().then(async t=>{await t.cleanupAppleXctracePerfCapture(e)})})}function _e(e,t){return R({initialOutPath:t.outPath,inspect:()=>B(t),finish:async n=>{let r=await j();return B(t.kind===`simpleperf`?await r.stopAndroidSimpleperfProfile(e,t,n):await r.stopAndroidPerfettoTrace(e,t,n))},cleanup:async()=>{await(await j()).cleanupAndroidNativePerfSession(e,t)}})}function R(e){let t=e.initialOutPath,n,r,i=async()=>await e.cleanup().then(()=>({status:`cleaned`}),V);return Object.freeze({inspect:e.inspect,setOutputPath:e=>{t=e},finish:async()=>n??=e.finish(t).then(e=>({status:`completed`,result:e}),e=>{throw n=void 0,e}),forceCleanup:async()=>r??=i(),[Symbol.asyncDispose]:async()=>{Ce(await(r??=i()))}})}async function ve(e){let t=g(e,N);if(t.status!==`decoded`||t.descriptor.family!==`apple`)return{status:`cleanup-pending`,reason:`manual-recovery-required`};let n=await b(t.descriptor.marker);if(n===`ownership-lost`)return{status:`cleanup-pending`,reason:`ownership-fence-lost`};if(n===`missing`)return{status:`already-missing`};let r=await v([t.descriptor.marker]);return r===`terminated`?{status:`cleaned`}:r===`already-missing`?{status:`already-missing`}:{status:`cleanup-pending`,reason:`ownership-fence-lost`}}async function ye(e){let t=g(e,N);if(t.status!==`decoded`)return t;if(t.descriptor.family!==`apple`)return{status:`unreattachable`,reason:`descriptor-invalid`};let n=await b(t.descriptor.marker);return n===`owned-alive`?{status:`unreattachable`,reason:`transport-not-reattachable`}:n===`ownership-lost`?{status:`unreattachable`,reason:`ownership-fence-lost`}:{status:`missing`}}async function be(e){let t=g(e,N);return t.status===`decoded`?t.descriptor.family===`android`?{status:`unreattachable`,reason:`transport-not-reattachable`}:{status:`unreattachable`,reason:`descriptor-invalid`}:t}async function xe(e,t){let n=g(t,N);if(n.status!==`decoded`||n.descriptor.family!==`android`)return{status:`cleanup-pending`,reason:`manual-recovery-required`};try{return await(await j()).cleanupAndroidNativePerfSession(e,n.descriptor.capture),{status:`cleaned`}}catch(e){return V(e)}}function Se(e){let{child:t,wait:n,...r}=e;return r}function z(e,t){return{perf:e,kind:t.kind,mode:t.mode,template:t.template,outPath:t.outPath,appBundleId:t.appBundleId,deviceId:t.deviceId,platform:t.platform,targetPids:t.targetPids,targetProcesses:t.targetProcesses,startedAt:t.startedAt,endedAt:t.endedAt}}function B(e){let t={action:e.action,platform:`android`,type:e.type,packageName:e.packageName,appPid:e.appPid,profilerPid:e.profilerPid,state:e.state,startedAt:new Date(e.startedAt).toISOString(),stoppedAt:typeof e.stoppedAt==`number`?new Date(e.stoppedAt).toISOString():void 0,outPath:e.outPath,sizeBytes:e.sizeBytes,remotePath:e.remotePath,method:e.method,message:e.message,...e.action===`stop`?{durationMs:e.durationMs,summary:e.summary}:{}};return e.kind===`simpleperf`?{...t,kind:`simpleperf`,mode:`cpu-profile`}:{...t,kind:`perfetto`,mode:`trace`}}function V(e){return{status:`cleanup-pending`,reason:`cleanup-unconfirmed`,message:e instanceof Error?e.message:String(e)}}function Ce(t){if(t.status===`cleanup-pending`)throw new e(`COMMAND_FAILED`,t.message??`Perf capture cleanup could not be confirmed`,{reason:t.reason})}function H(t,n,r){return new e(`INVALID_ARGS`,`${t} native perf requires --kind ${n}, not ${r}`)}function we(e){return e.family===`android`&&Te(e.capture)?{status:`decoded`,descriptor:{family:`android`,capture:e.capture}}:e.family===`apple`&&Oe(e.capture)&&Me(e.marker)?{status:`decoded`,descriptor:{family:`apple`,capture:e.capture,marker:e.marker}}:{status:`invalid`,message:`Perf capture descriptor body is invalid`}}function Te(e){return W(e)?Ee(e.kind,e.type)&&U(e,[`packageName`,`appPid`,`profilerPid`,`remotePath`,`outPath`])&&typeof e.startedAt==`number`&&De(e.state)&&ke(e,[`stoppedAt`,`sizeBytes`]):!1}function Ee(e,t){return e===`simpleperf`&&t===`cpu-profile`||e===`perfetto`&&t===`trace`}function De(e){return e===`running`||e===`stopped`}function Oe(e){return W(e)&&e.kind===`xctrace`&&(e.mode===`cpu-profile`||e.mode===`trace`)&&U(e,[`template`,`outPath`,`appBundleId`,`deviceId`,`startedAt`])&&i(e.platform)&&Ae(e.targetProcesses)&&je(e.targetPids)}function U(e,t){return t.every(t=>typeof e[t]==`string`)}function ke(e,t){return t.every(t=>e[t]===void 0||typeof e[t]==`number`)}function Ae(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function je(e){return Array.isArray(e)&&e.every(e=>typeof e==`number`)}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Me(e){return W(e)&&typeof e.pid==`number`&&typeof e.startTime==`string`&&typeof e.command==`string`}const G=f,Ne=f,K=f,q=async()=>await import(`./perf-facade.js`),J=async()=>await import(`./perf-facade.js`),Pe=async()=>await import(`./perf-facade.js`),Fe=async()=>await import(`./src4.js`).then(e=>e.b);function Ie(){let e=Object.freeze({sampleFrames:async(e,t)=>await(await q()).sampleAppleFramePerf(e,t),frameSampling:async e=>(await J()).buildAppleFrameSamplingMetadata(e),sampleMemory:async(e,t)=>await(await q()).sampleAppleMemoryPerf(e,t),memorySampling:async e=>(await J()).buildAppleMemorySamplingMetadata(e),memorySnapshotSupport:async e=>(await J()).buildAppleMemorySnapshotSupport(e),captureMemorySnapshot:async(e,t,n)=>await(await q()).captureAppleMemorySnapshot(e,t,n),start:async(e,t,n)=>await P(e,t,n),reattach:async(e,{envelope:t})=>await ye(t),cleanup:async(e,{envelope:t})=>await ve(t),writeProfileReport:async e=>await(await Pe()).writeAppleXctracePerfReport({tracePath:e.tracePath,outPath:e.outPath,template:e.template,appBundleId:e.appId})}),t=Object.freeze({sampleFrames:async(e,t)=>await(await Ne()).sampleAndroidFramePerf(e,t),sampleMemory:async(e,t)=>await(await G()).sampleAndroidMemoryPerf(e,t),captureMemorySnapshot:async(e,t,n)=>await(await G()).captureAndroidHeapSnapshot(e,t,n),start:async(e,t,n)=>await F(e,t,n),reattach:async(e,{envelope:t})=>await be(t),cleanup:async(e,{envelope:t})=>await xe(e,t),writeProfileReport:async(e,t)=>await(await K()).writeAndroidSimpleperfReport(e,Le(t.profile,t.tracePath),t.outPath)}),n=Object.freeze({sampleMemory:async(e,t)=>await(await Fe()).sampleHarmonyMemoryPerf(e,t)});return Object.freeze({apple:e,android:t,harmony:n})}function Le(t,n){if(t?.kind!==`simpleperf`||t.type!==`cpu-profile`||t.mode!==`cpu-profile`)throw new e(`INVALID_ARGS`,`Stopped Simpleperf profile metadata is malformed.`);return{type:`cpu-profile`,kind:`simpleperf`,packageName:t.packageName,appPid:t.appPid,profilerPid:t.profilerPid,remotePath:t.remotePath,outPath:n,startedAt:t.startedAt?Date.parse(t.startedAt):Date.now(),state:`stopped`,...t.stoppedAt?{stoppedAt:Date.parse(t.stoppedAt)}:{},...t.sizeBytes===void 0?{}:{sizeBytes:t.sizeBytes}}}function Re(){return Object.freeze({ensureConnected:async(e,t)=>{t.throwIfAborted();try{let{resolveIosPhysicalDeviceControl:n}=await import(`./physical-device-facade.js`);await n(e).ensureReady(e,t),t.throwIfAborted()}catch(e){throw t.throwIfAborted(),e}}})}function ze(){return Object.freeze({keepHot:e=>{import(`./runner-operations-facade.js`).then(({prewarmAppleRunnerCache:t})=>t(e,{})).catch(()=>{})},wasRecentlyObservedBooted:async e=>{let{wasSimulatorRecentlyObservedBooted:t}=await import(`./simulator-facade.js`);return t(e)},markBooted:e=>{import(`./simulator-facade.js`).then(({markSimulatorBooted:t})=>t(e)).catch(()=>{})}})}function Be(){return Object.freeze({discover:async(e,t)=>{t.throwIfAborted();let n=await _(e);return t.throwIfAborted(),n},launch:(e,t)=>{let n=[`-avd`,e];return t&&n.push(`-no-window`,`-no-audio`),d(`emulator`,n)},terminate:async e=>{await o({pids:[e],termTimeoutMs:1500,killTimeoutMs:1500})}})}function Ve(e,t){let n,r,i=async()=>(n??=t.apple({appleTools:e.appleTools}),await n),a=async()=>(r??=t.android({commands:e.commands}),await r),o=Object.freeze({shutdownTarget:async(e,t)=>await(await i()).shutdownTarget(e,t)}),s=Object.freeze({shutdownTarget:async(e,t)=>await(await a()).shutdownTarget(e,t)}),c=Object.freeze({canShutdownTarget:async e=>await He(e,i,a),shutdownTarget:async e=>await Ue(e,i,a)});return Object.freeze({apple:o,android:s,close:c})}async function He(e,t,n){return e.platform===`apple`?(await t()).canShutdownTarget(e):e.platform===`android`&&(await n()).canShutdownTarget(e)}async function Ue(e,t,n){let r=new AbortController().signal;return e.platform===`apple`?await(await t()).shutdownTarget(e,r):e.platform===`android`?await(await n()).shutdownTarget(e,r):{success:!1,exitCode:-1,stdout:``,stderr:`Cannot shut down unsupported device ${e.platform}/${e.kind}`}}function We(){return Object.freeze({withInvalidatedAppResolutionCache:async(e,t)=>{let{invalidateIosAppResolutionCache:n}=await import(`./app-resolution-facade.js`);return await n(e,t)},prepareArtifact:async(e,t)=>{let{prepareIosInstallArtifact:n}=await import(`./install-artifact-facade.js`);return await n(e.source,t)},resolveAppBundleId:async(e,t)=>{let{resolveIosApp:n}=await import(`./app-resolution-facade.js`);return await n(e,t)}})}function Ge(){return Object.freeze({bundletoolJar:process.env.AGENT_DEVICE_BUNDLETOOL_JAR?.trim()||void 0,withInvalidatedAppResolutionCache:async(e,t)=>{let{withAndroidAppResolutionCacheInvalidated:n}=await f();return await n(e,t)},prepareArtifact:async(e,t)=>{let{prepareAndroidInstallArtifact:n}=await f();return await n(e.source,t)},resolveAppPackage:async(e,t)=>{let{resolveAndroidApp:n}=await f(),r=await n(e,t);if(r.type===`intent`){let{AppError:e}=await import(`./sdk-contracts.js`).then(e=>e.M);throw new e(`INVALID_ARGS`,`App uninstall requires a package name, not an intent`)}return r.value}})}function Ke(){return Object.freeze({probeClipboardShellSupport:async(e,t)=>{try{let{runAndroidShell:n,androidClipboardShellSupportForResult:r}=await f();return await r(await n(e,[`cmd`,`clipboard`,`get`,`text`],{allowFailure:!0,signal:t}))}catch{return`probe-failed`}},runAdb:async(e,t,n,r)=>{let{runAndroidAdb:i}=await f(),a=await i(e,t,{allowFailure:n.allowFailure,timeoutMs:n.timeoutMs,signal:r});return{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode}},installPackage:async(e,t,n,r)=>{let{resolveAndroidAdbProvider:i}=await f(),a=i(e),o=a.install?await a.install(t,{replace:n.replace,signal:r}):await a.exec([`install`,...n.replace?[`-r`]:[],t],{signal:r});return{stdout:o.stdout,stderr:o.stderr,exitCode:o.exitCode}},installBundle:async(e,t,n,r)=>{let{resolveAndroidAdbProvider:i}=await f(),a=i(e).installBundle;return a?(await a(t,{mode:n,signal:r}),!0):!1}})}let qe;const Y=()=>qe??=import(`./runner-operations-facade.js`);let Je;const X=()=>Je??=import(`./platform-runtime-runtime-hints.js`);let Ye;const Xe=()=>Ye??=import(`./platform-runtime-open-target.js`).then(e=>e.t);let Ze;const Qe=()=>Ze??=import(`./app-resolution-facade.js`);let $e;const Z=()=>$e??=import(`./macos-facade.js`);let et;const tt=()=>et??=import(`./retry.js`).then(e=>e.t);function nt(){return Object.freeze({resolveOpenTarget:async(e,t)=>await rt(e,t),prewarmRunnerCache:async(e,t,n)=>{let{prewarmAppleRunnerCache:r}=await Y();await r(e,Q(t,n))},prewarmRunnerSession:async(e,t,n,r,i)=>{let{prewarmIosRunnerSession:a}=await Y();await a(e,{...Q(t,n),propagateError:r,...i})},notifyRunnerAppRelaunched:async(e,t,n)=>{let{notifyIosRunnerAppRelaunched:r}=await Y();await r(e,Q(t,n))},stopRunnerSession:async e=>{let{stopIosRunnerSession:t}=await Y();await t(e)},hasLiveRunnerSession:async(e,t)=>{let{hasLiveIosRunnerSession:n}=await Y();return n(e,{requestId:t.requestId})},releaseSpeculativeRunner:async(e,t)=>{let{releaseSpeculativeIosRunnerSessionFor:n}=await Y();return await n(e,{requestId:t.requestId})},releaseRunnerOnClose:async(e,t)=>{let{releaseIosRunnerOnClose:n}=await Y();await n(e,t)},prepareRunner:async(e,t,n)=>{let{Deadline:r}=await tt(),{prepareIosRunner:i}=await Y(),a=Date.now();return await i(e,{...Q(t.execution,n),cleanStaleBundles:!0,buildTimeoutMs:t.timeoutMs,healthTimeoutMs:t.timeoutMs,prepareDeadline:r.fromTimeoutMs(t.timeoutMs,a),startupTimeoutMs:t.timeoutMs})},applyRuntimeHints:async(e,t)=>{let{applyRuntimeHintValues:n}=await X();await n({device:e,...t})},clearRuntimeHints:async(e,t)=>{let{clearRuntimeHintValues:n}=await X();await n({device:e,...t})},dismissCloseAlerts:async(e,t)=>await ot(e,t),detachRunnerSessionsForShutdown:async()=>{let{detachIosRunnerSessionsForShutdown:e}=await Y();await e()},finalizeRunnerSessionsForShutdown:async()=>{let{stopAllIosRunnerSessions:e}=await Y();await e()}})}async function rt(t,n){if(n.foreground){let n=await it(t);if(n)return n;throw new e(`AMBIGUOUS_MATCH`,`open --foreground requires exactly one running app on the selected iOS simulator.`,{reason:`foreground_app_ambiguous`,hint:`Pass an explicit app instead: agent-device open <app> --platform ios.`})}let r=await at(t,n.surface),{resolveSessionAppBundleIdForTarget:i}=await Xe();return{appBundleId:r.appBundleId??await i(t,n.target,n.currentAppBundleId),appName:r.appName??n.target}}async function it(e){if(!n(e)||e.kind!==`simulator`)return;let{detectSoleRunningIosSimulatorApp:t}=await Qe(),r=await t(e);return r?{appBundleId:r.bundleId,appName:r.name}:void 0}async function at(e,t){if(!r(e)||t===`app`||t===`desktop`||t===`menubar`)return{};let{resolveFrontmostMacOsApp:n}=await Z(),i=await n();return{appBundleId:i.bundleId,appName:i.appName}}function Q(e,t){return{requestId:e.requestId,logPath:e.logPath,traceLogPath:e.traceLogPath,verbose:e.verbose,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,runnerLeaseContext:e.runnerLeaseContext,signal:t}}async function ot(e,t){if(!r(e))return;let{runMacOsAlertAction:n}=await Z();await n(`dismiss`,t.surface===`frontmost-app`?{surface:`frontmost-app`}:t.appBundleId?{bundleId:t.appBundleId}:{})}let st;const ct=()=>st??=import(`./platform-runtime-open-target.js`).then(e=>e.t);let lt;const $=()=>lt??=import(`./platform-runtime-runtime-hints.js`);function ut(){return Object.freeze({resolveOpenTarget:async(e,t)=>await dt(e,t),inferOpenedAppBundleId:async(e,t,n)=>{if(n)return n;try{let{inferAndroidPackageAfterOpen:r}=await f();return await r(e,t,n)}catch{return n}},resetFramePerfStats:async(e,t)=>{let{resetAndroidFramePerfStats:n}=await f();await n(e,t)},applyRuntimeHints:async(e,t)=>{let{applyRuntimeHintValues:n}=await $();await n({device:e,...t})},clearRuntimeHints:async(e,t)=>{let{clearRuntimeHintValues:n}=await $();await n({device:e,...t})},activateTestIme:async(t,n)=>{let{activateAndroidTestIme:r}=await f(),i=await r(t,n);if(i.outcome===`helper-unavailable`){a({level:`warn`,phase:`android_test_ime_activate_failed`,data:{device:t.id,error:i.reason,...i.hint===void 0?{}:{hint:i.hint}}});return}if(i.persistFailed&&!(!i.alreadyActive&&!i.activated))throw new e(`COMMAND_FAILED`,`Android test IME recovery records could not be persisted for ${t.name??t.id}.`,{reason:`android_test_ime_recovery_fence_failed`,deviceId:t.id})},restoreTestIme:async(t,n)=>{let{restoreAndroidTestIme:r}=await f();if((await r(t,{stateDir:n.stateDir})).reason===`set-failed`)throw new e(`COMMAND_FAILED`,`Android test IME could not be restored on ${t.name??t.id}.`,{reason:`android_test_ime_restore_incomplete`,deviceId:t.id})},recoverTestImeStartup:async e=>{let{listAndroidAdbSerialsQuick:t,restoreOrphanedAndroidTestImeOnDaemonStartup:n}=await f();await n({stateDir:e.stateDir,listSerials:t})},hasTestImeRecoveryEvidence:async e=>{let{readAndroidTestImeRecoveryMarkers:t}=await f();return(await t(e)).length>0}})}async function dt(e,t){let{resolveSessionAppBundleIdForTarget:n}=await ct();return{appBundleId:await n(e,t.target,t.currentAppBundleId),appName:t.target}}function ft(){return Object.freeze({resolve:async(e,t)=>{let{getLocalInteractor:n}=await import(`./interactors.js`).then(e=>e.n);return await n(e,t)}})}function pt(e){return Object.freeze({recoverStartupResources:async t=>{await e.android.hasTestImeRecoveryEvidence(t.stateDir)&&await e.android.recoverTestImeStartup(t)},detachForDaemonShutdown:async()=>await e.apple.detachRunnerSessionsForShutdown(),finalizeDaemonShutdown:async()=>await e.apple.finalizeRunnerSessionsForShutdown()})}function mt(e){return Object.freeze({captureSurface:async(t,n,r)=>t.platform===`linux`?await e.linux(n,r):(ht(t),await e.macos(n,r)),presentIosAcquisition:async(e,t)=>{let{presentIosSnapshotAcquisition:n}=await import(`./ios-snapshot-runtime.js`);return await n(e,t)}})}function ht(e){if(e.platform!==`apple`||e.appleOs!==`macos`)throw TypeError(`Apple surface capture requires a non-app macOS surface`)}async function gt(e,t){let{captureMacOsSurfaceSnapshot:n}=await import(`./macos-facade.js`);return await n(e??{},t)}function _t(e){let t=ie(e.sessionsDir),n=Object.freeze({mode:`local`,start:t.start}),r=se(),i=Object.freeze({which:async e=>await u(e)?e:void 0,run:async(e,t)=>{let n=await l(e.executable,ce(e),{allowFailure:e.allowFailure,cwd:e.cwd,env:e.env?{...process.env,...e.env}:void 0,signal:t,timeoutMs:e.timeoutMs});return{stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode}}}),a=me({resolveSessionArtifacts:e.resolveSessionArtifacts,processes:t,resolveTransport:async e=>{if(e.platform!==`web`)return Object.freeze({mode:`local`});let{resolveWebNetworkTransport:t}=await import(`./platform-runtime-network-web-transport.js`);return await t(e)}}),o=nt(),s=ut();return Object.freeze({commands:i,appleTools:r,toolchains:oe(),artifacts:Object.freeze({resolveSession:e.resolveSessionArtifacts}),outputs:Object.freeze({openAppend:async t=>await ue(e.sessionsDir,t),readTail:async(t,n)=>await S(e.sessionsDir,t,n)}),processes:t,processTransports:Object.freeze({resolve:async t=>{if(t.platform!==`android`)return n;let{resolveAndroidAppLogProcessTransport:r}=await import(`./platform-runtime-app-log-android-transport.js`);return r(e.sessionsDir,t,n)}}),...a,appleDeployment:We(),androidDeployment:Ge(),androidTools:Ke(),temporaryFiles:Object.freeze({create:async e=>await ae(e)}),deviceReadiness:Object.freeze({applePhysical:Re(),appleAutomation:ze(),androidEmulator:Be()}),deviceShutdown:Ve({appleTools:r,commands:i},e.shutdownLoaders),screenRecording:E({ownedProcesses:e.ownedProcesses}),audioProbe:k({ownedProcesses:e.ownedProcesses}),perf:Ie(),snapshot:e.snapshot,localInteractors:ft(),appleApplications:o,androidApplications:s,applicationResources:pt({android:s,apple:o}),clock:Object.freeze({now:()=>Date.now(),sleep:async(e,t)=>{await le(e,void 0,t?{signal:t}:void 0)}})})}export{_t as createPlatformRuntimeHost,mt as createSnapshotRuntimeHost,gt as loadMacOsSurfaceSnapshot,ne as recoverLegacyAppLogMarkersAfterDaemonLock};
|
|
5
|
+
`),skippedLines:r})}function D(e={}){let t=Object.freeze({resolve:async e=>{let{createAndroidScreenRecordingTransport:t}=await import(`./platform-runtime-screen-recording-android-host.js`);return await t(e)}}),n=Object.freeze({resolve:async e=>{let{resolveWebScreenRecordingTransport:t}=await import(`./platform-runtime-screen-recording-web-host.js`);return await t(e)}}),r=Object.freeze({prepare:async e=>{let{createScreenRecordingOutputHost:t}=await import(`./platform-runtime-screen-recording-output-host.js`);await t().prepare(e)},copy:async e=>{let{createScreenRecordingOutputHost:t}=await import(`./platform-runtime-screen-recording-output-host.js`);await t().copy(e)},remove:async e=>{let{createScreenRecordingOutputHost:t}=await import(`./platform-runtime-screen-recording-output-host.js`);return await t().remove(e)}}),i=Object.freeze({sniff:async e=>{let{createScreenRecordingFinalizer:t}=await import(`./platform-runtime-screen-recording-finalizer-host.js`);await t().sniff(e)},complete:async(e,t)=>{let{createScreenRecordingFinalizer:n}=await import(`./platform-runtime-screen-recording-finalizer-host.js`);return await n().complete(e,t)}}),a=e.ownedProcesses??Object.freeze({replace:()=>{},clear:()=>{}});return Object.freeze({apple:O(),android:t,harmony:k(),web:n,outputs:r,finalize:i,ownedProcesses:a})}function O(){let e=async()=>{let{createAppleScreenRecordingHost:e}=await import(`./platform-runtime-screen-recording-apple-host.js`);return e()};return Object.freeze({availability:async t=>(await e()).availability(t),runRunner:async(t,n,r)=>await(await e()).runRunner(t,n,r),startSimulator:async(t,n,r)=>await(await e()).startSimulator(t,n,r),inspectProcess:async t=>await(await e()).inspectProcess(t),terminateProcess:async t=>await(await e()).terminateProcess(t),inspectRunner:async(t,n,r)=>await(await e()).inspectRunner(t,n,r),retrieveRunnerRecording:async(t,n,r,i)=>await(await e()).retrieveRunnerRecording(t,n,r,i),captureClockAnchor:async(t,n,r)=>await(await e()).captureClockAnchor(t,n,r),isRunnerBundleId:async t=>await(await e()).isRunnerBundleId(t)})}function k(){let e=async()=>{let{createHarmonyScreenRecordingHost:e}=await import(`./platform-runtime-screen-recording-harmony-host.js`);return e()};return Object.freeze({start:async(t,n,r)=>await(await e()).start(t,n,r),stop:async(t,n)=>await(await e()).stop(t,n),findMedia:async(t,n,r)=>await(await e()).findMedia(t,n,r),stageMedia:async(t,n,r)=>await(await e()).stageMedia(t,n,r),stagedFileSize:async(t,n,r)=>await(await e()).stagedFileSize(t,n,r),pull:async(t,n,r)=>await(await e()).pull(t,n,r),remove:async(t,n,r)=>await(await e()).remove(t,n,r),removeMedia:async(t,n,r)=>await(await e()).removeMedia(t,n,r)})}function A(e={}){let t=e.ownedProcesses??Object.freeze({replace:()=>{},clear:()=>{}});return Object.freeze({hostCapture:Object.freeze({info:Object.freeze({source:`system-audio`,backend:`macos-screencapturekit`,sourceCount:1,notes:j}),start:async e=>{let{startMacOsAudioProbeProcess:t}=await import(`./macos-facade.js`),n=await t(e),r=await b(n.child.pid??void 0);return Object.freeze({...r===void 0?{}:{marker:r},wait:n.wait,terminate:async()=>{n.child.kill(`SIGTERM`),await n.wait.catch(()=>{})}})},inspectProcess:async e=>x(e),terminateProcess:async e=>await y([e])}),web:Object.freeze({resolve:async e=>{if(e.platform!==`web`)return;let{resolveWebProvider:t}=await import(`./src6.js`).then(e=>e.i),n=await t(),r=n.probeAudio?.bind(n);if(r)return Object.freeze({probe:async e=>await r({action:e.action,durationMs:e.durationMs,bucketMs:e.bucketMs})})}}),ownedProcesses:t})}function j(e){return[`Audio probe samples host system audio through ScreenCaptureKit for this ${n(e)?`iOS simulator`:e.platform===`android`?`Android emulator`:`macOS session`}; it is not app-instrumented audio.`,`Screen Recording permission is required for host system audio capture.`,`Other audible host apps can contribute to the measured buckets.`]}const M=f,N=async()=>await import(`./perf-facade.js`),P=Object.freeze({resourceKind:p,version:1,encode:e=>e,decode:Te});async function F(t,n,r){if(r.kind!==`xctrace`)throw H(`Apple`,`xctrace`,r.kind);let i=r.template??(r.mode===`cpu-profile`?`Time Profiler`:`Animation Hitches`),a=await N(),o=await a.startAppleXctracePerfCapture({device:t,appBundleId:r.appId,mode:r.mode,template:i,outPath:r.outPath}),s=await b(o.child.pid??void 0);if(!s)throw await a.cleanupAppleXctracePerfCapture(o).catch(()=>{}),new e(`COMMAND_FAILED`,`Apple xctrace exposed no exact process identity`);return L(t,n,r,{family:`apple`,marker:s,capture:Ce(o)},_e(o),z(`started`,o))}async function I(e,t,n){let r=await M(),i;if(n.mode===`cpu-profile`){if(n.kind!==`simpleperf`)throw H(`Android`,`simpleperf`,n.kind);i=await r.startAndroidSimpleperfProfile(e,n.appId,n.outPath)}else{if(n.kind!==`perfetto`)throw H(`Android`,`perfetto`,n.kind);i=await r.startAndroidPerfettoTrace(e,n.appId,n.outPath)}return L(e,t,n,{family:`android`,capture:i},ve(e,i),B(i))}function L(e,n,r,i,a,o){return Object.freeze({pendingHandle:new te(a),envelope:h({resourceKind:p,sessionId:r.sessionId,device:t(e),owner:n,fence:r.fence,lifecycle:`open`,descriptor:m(P,i)}),response:o})}function _e(e){return R({initialOutPath:e.outPath,inspect:()=>z(`started`,e),finish:async t=>await N().then(async n=>z(`stopped`,await n.stopAppleXctracePerfCapture(e,t))),cleanup:async()=>await N().then(async t=>{await t.cleanupAppleXctracePerfCapture(e)})})}function ve(e,t){return R({initialOutPath:t.outPath,inspect:()=>B(t),finish:async n=>{let r=await M();return B(t.kind===`simpleperf`?await r.stopAndroidSimpleperfProfile(e,t,n):await r.stopAndroidPerfettoTrace(e,t,n))},cleanup:async()=>{await(await M()).cleanupAndroidNativePerfSession(e,t)}})}function R(e){let t=e.initialOutPath,n,r,i=async()=>await e.cleanup().then(()=>({status:`cleaned`}),V);return Object.freeze({inspect:e.inspect,setOutputPath:e=>{t=e},finish:async()=>n??=e.finish(t).then(e=>({status:`completed`,result:e}),e=>{throw n=void 0,e}),forceCleanup:async()=>r??=i(),[Symbol.asyncDispose]:async()=>{we(await(r??=i()))}})}async function ye(e){let t=g(e,P);if(t.status!==`decoded`||t.descriptor.family!==`apple`)return{status:`cleanup-pending`,reason:`manual-recovery-required`};let n=await x(t.descriptor.marker);if(n===`ownership-lost`)return{status:`cleanup-pending`,reason:`ownership-fence-lost`};if(n===`missing`)return{status:`already-missing`};let r=await y([t.descriptor.marker]);return r===`terminated`?{status:`cleaned`}:r===`already-missing`?{status:`already-missing`}:{status:`cleanup-pending`,reason:`ownership-fence-lost`}}async function be(e){let t=g(e,P);if(t.status!==`decoded`)return t;if(t.descriptor.family!==`apple`)return{status:`unreattachable`,reason:`descriptor-invalid`};let n=await x(t.descriptor.marker);return n===`owned-alive`?{status:`unreattachable`,reason:`transport-not-reattachable`}:n===`ownership-lost`?{status:`unreattachable`,reason:`ownership-fence-lost`}:{status:`missing`}}async function xe(e){let t=g(e,P);return t.status===`decoded`?t.descriptor.family===`android`?{status:`unreattachable`,reason:`transport-not-reattachable`}:{status:`unreattachable`,reason:`descriptor-invalid`}:t}async function Se(e,t){let n=g(t,P);if(n.status!==`decoded`||n.descriptor.family!==`android`)return{status:`cleanup-pending`,reason:`manual-recovery-required`};try{return await(await M()).cleanupAndroidNativePerfSession(e,n.descriptor.capture),{status:`cleaned`}}catch(e){return V(e)}}function Ce(e){let{child:t,wait:n,...r}=e;return r}function z(e,t){return{perf:e,kind:t.kind,mode:t.mode,template:t.template,outPath:t.outPath,appBundleId:t.appBundleId,deviceId:t.deviceId,platform:t.platform,targetPids:t.targetPids,targetProcesses:t.targetProcesses,startedAt:t.startedAt,endedAt:t.endedAt}}function B(e){let t={action:e.action,platform:`android`,type:e.type,packageName:e.packageName,appPid:e.appPid,profilerPid:e.profilerPid,state:e.state,startedAt:new Date(e.startedAt).toISOString(),stoppedAt:typeof e.stoppedAt==`number`?new Date(e.stoppedAt).toISOString():void 0,outPath:e.outPath,sizeBytes:e.sizeBytes,remotePath:e.remotePath,method:e.method,message:e.message,...e.action===`stop`?{durationMs:e.durationMs,summary:e.summary}:{}};return e.kind===`simpleperf`?{...t,kind:`simpleperf`,mode:`cpu-profile`}:{...t,kind:`perfetto`,mode:`trace`}}function V(e){return{status:`cleanup-pending`,reason:`cleanup-unconfirmed`,message:e instanceof Error?e.message:String(e)}}function we(t){if(t.status===`cleanup-pending`)throw new e(`COMMAND_FAILED`,t.message??`Perf capture cleanup could not be confirmed`,{reason:t.reason})}function H(t,n,r){return new e(`INVALID_ARGS`,`${t} native perf requires --kind ${n}, not ${r}`)}function Te(e){return e.family===`android`&&Ee(e.capture)?{status:`decoded`,descriptor:{family:`android`,capture:e.capture}}:e.family===`apple`&&ke(e.capture)&&Me(e.marker)?{status:`decoded`,descriptor:{family:`apple`,capture:e.capture,marker:e.marker}}:{status:`invalid`,message:`Perf capture descriptor body is invalid`}}function Ee(e){return G(e)?De(e.kind,e.type)&&U(e,[`packageName`,`appPid`,`profilerPid`,`remotePath`,`outPath`])&&typeof e.startedAt==`number`&&Oe(e.state)&&Ae(e,[`stoppedAt`,`sizeBytes`]):!1}function De(e,t){return e===`simpleperf`&&t===`cpu-profile`||e===`perfetto`&&t===`trace`}function Oe(e){return e===`running`||e===`stopped`}function ke(e){return G(e)&&e.kind===`xctrace`&&(e.mode===`cpu-profile`||e.mode===`trace`)&&U(e,[`template`,`outPath`,`appBundleId`,`deviceId`,`startedAt`])&&i(e.platform)&&je(e.targetProcesses)&&W(e.targetPids)}function U(e,t){return t.every(t=>typeof e[t]==`string`)}function Ae(e,t){return t.every(t=>e[t]===void 0||typeof e[t]==`number`)}function je(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function W(e){return Array.isArray(e)&&e.every(e=>typeof e==`number`)}function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Me(e){return G(e)&&typeof e.pid==`number`&&typeof e.startTime==`string`&&typeof e.command==`string`}const K=f,Ne=f,Pe=f,q=async()=>await import(`./perf-facade.js`),J=async()=>await import(`./perf-facade.js`),Fe=async()=>await import(`./perf-facade.js`),Ie=async()=>await import(`./src4.js`).then(e=>e.b);function Le(){let e=Object.freeze({sampleFrames:async(e,t)=>await(await q()).sampleAppleFramePerf(e,t),frameSampling:async e=>(await J()).buildAppleFrameSamplingMetadata(e),sampleMemory:async(e,t)=>await(await q()).sampleAppleMemoryPerf(e,t),memorySampling:async e=>(await J()).buildAppleMemorySamplingMetadata(e),memorySnapshotSupport:async e=>(await J()).buildAppleMemorySnapshotSupport(e),captureMemorySnapshot:async(e,t,n)=>await(await q()).captureAppleMemorySnapshot(e,t,n),start:async(e,t,n)=>await F(e,t,n),reattach:async(e,{envelope:t})=>await be(t),cleanup:async(e,{envelope:t})=>await ye(t),writeProfileReport:async e=>await(await Fe()).writeAppleXctracePerfReport({tracePath:e.tracePath,outPath:e.outPath,template:e.template,appBundleId:e.appId})}),t=Object.freeze({sampleFrames:async(e,t)=>await(await Ne()).sampleAndroidFramePerf(e,t),sampleMemory:async(e,t)=>await(await K()).sampleAndroidMemoryPerf(e,t),captureMemorySnapshot:async(e,t,n)=>await(await K()).captureAndroidHeapSnapshot(e,t,n),start:async(e,t,n)=>await I(e,t,n),reattach:async(e,{envelope:t})=>await xe(t),cleanup:async(e,{envelope:t})=>await Se(e,t),writeProfileReport:async(e,t)=>await(await Pe()).writeAndroidSimpleperfReport(e,Re(t.profile,t.tracePath),t.outPath)}),n=Object.freeze({sampleMemory:async(e,t)=>await(await Ie()).sampleHarmonyMemoryPerf(e,t)});return Object.freeze({apple:e,android:t,harmony:n})}function Re(t,n){if(t?.kind!==`simpleperf`||t.type!==`cpu-profile`||t.mode!==`cpu-profile`)throw new e(`INVALID_ARGS`,`Stopped Simpleperf profile metadata is malformed.`);return{type:`cpu-profile`,kind:`simpleperf`,packageName:t.packageName,appPid:t.appPid,profilerPid:t.profilerPid,remotePath:t.remotePath,outPath:n,startedAt:t.startedAt?Date.parse(t.startedAt):Date.now(),state:`stopped`,...t.stoppedAt?{stoppedAt:Date.parse(t.stoppedAt)}:{},...t.sizeBytes===void 0?{}:{sizeBytes:t.sizeBytes}}}function ze(){return Object.freeze({ensureConnected:async(e,t)=>{t.throwIfAborted();try{let{resolveIosPhysicalDeviceControl:n}=await import(`./physical-device-facade.js`);await n(e).ensureReady(e,t),t.throwIfAborted()}catch(e){throw t.throwIfAborted(),e}}})}function Be(){return Object.freeze({keepHot:e=>{import(`./runner-operations-facade.js`).then(({prewarmAppleRunnerCache:t})=>t(e,{})).catch(()=>{})},wasRecentlyObservedBooted:async e=>{let{wasSimulatorRecentlyObservedBooted:t}=await import(`./simulator-facade.js`);return t(e)},markBooted:e=>{import(`./simulator-facade.js`).then(({markSimulatorBooted:t})=>t(e)).catch(()=>{})}})}function Ve(){return Object.freeze({discover:async(e,t)=>{t.throwIfAborted();let n=await ne(e);return t.throwIfAborted(),n},launch:(e,t)=>{let n=[`-avd`,e];return t&&n.push(`-no-window`,`-no-audio`),ee(`emulator`,n)},terminate:async e=>{await s({pids:[e],termTimeoutMs:1500,killTimeoutMs:1500})}})}function He(e,t){let n,r,i=async()=>(n??=t.apple({appleTools:e.appleTools}),await n),a=async()=>(r??=t.android({commands:e.commands}),await r),o=Object.freeze({shutdownTarget:async(e,t)=>await(await i()).shutdownTarget(e,t)}),s=Object.freeze({shutdownTarget:async(e,t)=>await(await a()).shutdownTarget(e,t)}),c=Object.freeze({canShutdownTarget:async e=>await Ue(e,i,a),shutdownTarget:async e=>await We(e,i,a)});return Object.freeze({apple:o,android:s,close:c})}async function Ue(e,t,n){return e.platform===`apple`?(await t()).canShutdownTarget(e):e.platform===`android`&&(await n()).canShutdownTarget(e)}async function We(e,t,n){let r=new AbortController().signal;return e.platform===`apple`?await(await t()).shutdownTarget(e,r):e.platform===`android`?await(await n()).shutdownTarget(e,r):{success:!1,exitCode:-1,stdout:``,stderr:`Cannot shut down unsupported device ${e.platform}/${e.kind}`}}function Ge(){return Object.freeze({withInvalidatedAppResolutionCache:async(e,t)=>{let{invalidateIosAppResolutionCache:n}=await import(`./app-resolution-facade.js`);return await n(e,t)},prepareArtifact:async(e,t)=>{let{prepareIosInstallArtifact:n}=await import(`./install-artifact-facade.js`);return await n(e.source,t)},resolveAppBundleId:async(e,t)=>{let{resolveIosApp:n}=await import(`./app-resolution-facade.js`);return await n(e,t)}})}function Ke(){return Object.freeze({bundletoolJar:process.env.AGENT_DEVICE_BUNDLETOOL_JAR?.trim()||void 0,withInvalidatedAppResolutionCache:async(e,t)=>{let{withAndroidAppResolutionCacheInvalidated:n}=await f();return await n(e,t)},prepareArtifact:async(e,t)=>{let{prepareAndroidInstallArtifact:n}=await f();return await n(e.source,t)},resolveAppPackage:async(e,t)=>{let{resolveAndroidApp:n}=await f(),r=await n(e,t);if(r.type===`intent`){let{AppError:e}=await import(`./sdk-contracts.js`).then(e=>e.F);throw new e(`INVALID_ARGS`,`App uninstall requires a package name, not an intent`)}return r.value}})}function qe(){return Object.freeze({probeClipboardShellSupport:async(e,t)=>{try{let{runAndroidShell:n,androidClipboardShellSupportForResult:r}=await f();return await r(await n(e,[`cmd`,`clipboard`,`get`,`text`],{allowFailure:!0,signal:t}))}catch{return`probe-failed`}},runAdb:async(e,t,n,r)=>{let{runAndroidAdb:i}=await f(),a=await i(e,t,{allowFailure:n.allowFailure,timeoutMs:n.timeoutMs,signal:r});return{stdout:a.stdout,stderr:a.stderr,exitCode:a.exitCode}},installPackage:async(e,t,n,r)=>{let{resolveAndroidAdbProvider:i}=await f(),a=i(e),o=a.install?await a.install(t,{replace:n.replace,signal:r}):await a.exec([`install`,...n.replace?[`-r`]:[],t],{signal:r});return{stdout:o.stdout,stderr:o.stderr,exitCode:o.exitCode}},installBundle:async(e,t,n,r)=>{let{resolveAndroidAdbProvider:i}=await f(),a=i(e).installBundle;return a?(await a(t,{mode:n,signal:r}),!0):!1}})}let Je;const Y=()=>Je??=import(`./runner-operations-facade.js`);let Ye;const X=()=>Ye??=import(`./platform-runtime-runtime-hints.js`);let Xe;const Ze=()=>Xe??=import(`./platform-runtime-open-target.js`).then(e=>e.t);let Qe;const $e=()=>Qe??=import(`./app-resolution-facade.js`);let et;const Z=()=>et??=import(`./macos-facade.js`);let tt;const nt=()=>tt??=import(`./retry.js`).then(e=>e.t);function rt(){return Object.freeze({resolveOpenTarget:async(e,t)=>await it(e,t),prewarmRunnerCache:async(e,t,n)=>{let{prewarmAppleRunnerCache:r}=await Y();await r(e,Q(t,n))},prewarmRunnerSession:async(e,t,n,r,i)=>{let{prewarmIosRunnerSession:a}=await Y();await a(e,{...Q(t,n),propagateError:r,...i})},notifyRunnerAppRelaunched:async(e,t,n)=>{let{notifyIosRunnerAppRelaunched:r}=await Y();await r(e,Q(t,n))},stopRunnerSession:async e=>{let{stopIosRunnerSession:t}=await Y();await t(e)},hasLiveRunnerSession:async(e,t)=>{let{hasLiveIosRunnerSession:n}=await Y();return n(e,{requestId:t.requestId})},releaseSpeculativeRunner:async(e,t)=>{let{releaseSpeculativeIosRunnerSessionFor:n}=await Y();return await n(e,{requestId:t.requestId})},releaseRunnerOnClose:async(e,t)=>{let{releaseIosRunnerOnClose:n}=await Y();await n(e,t)},prepareRunner:async(e,t,n)=>{let{Deadline:r}=await nt(),{prepareIosRunner:i}=await Y(),a=Date.now();return await i(e,{...Q(t.execution,n),cleanStaleBundles:!0,buildTimeoutMs:t.timeoutMs,healthTimeoutMs:t.timeoutMs,prepareDeadline:r.fromTimeoutMs(t.timeoutMs,a),startupTimeoutMs:t.timeoutMs})},applyRuntimeHints:async(e,t)=>{let{applyRuntimeHintValues:n}=await X();await n({device:e,...t})},clearRuntimeHints:async(e,t)=>{let{clearRuntimeHintValues:n}=await X();await n({device:e,...t})},dismissCloseAlerts:async(e,t)=>await st(e,t),detachRunnerSessionsForShutdown:async()=>{let{detachIosRunnerSessionsForShutdown:e}=await Y();await e()},finalizeRunnerSessionsForShutdown:async()=>{let{stopAllIosRunnerSessions:e}=await Y();await e()}})}async function it(t,n){if(n.foreground){let n=await at(t);if(n)return n;throw new e(`AMBIGUOUS_MATCH`,`open --foreground requires exactly one running app on the selected iOS simulator.`,{reason:`foreground_app_ambiguous`,hint:`Pass an explicit app instead: agent-device open <app> --platform ios.`})}let r=await ot(t,n.surface),{resolveSessionAppBundleIdForTarget:i}=await Ze();return{appBundleId:r.appBundleId??await i(t,n.target,n.currentAppBundleId),appName:r.appName??n.target}}async function at(e){if(!n(e)||e.kind!==`simulator`)return;let{detectSoleRunningIosSimulatorApp:t}=await $e(),r=await t(e);return r?{appBundleId:r.bundleId,appName:r.name}:void 0}async function ot(e,t){if(!r(e)||t===`app`||t===`desktop`||t===`menubar`)return{};let{resolveFrontmostMacOsApp:n}=await Z(),i=await n();return{appBundleId:i.bundleId,appName:i.appName}}function Q(e,t){return{requestId:e.requestId,logPath:e.logPath,traceLogPath:e.traceLogPath,verbose:e.verbose,iosXctestrunFile:e.iosXctestrunFile,iosXctestDerivedDataPath:e.iosXctestDerivedDataPath,iosXctestEnvDir:e.iosXctestEnvDir,runnerLeaseContext:e.runnerLeaseContext,signal:t}}async function st(e,t){if(!r(e))return;let{runMacOsAlertAction:n}=await Z();await n(`dismiss`,t.surface===`frontmost-app`?{surface:`frontmost-app`}:t.appBundleId?{bundleId:t.appBundleId}:{})}let ct;const lt=()=>ct??=import(`./platform-runtime-open-target.js`).then(e=>e.t);let ut;const $=()=>ut??=import(`./platform-runtime-runtime-hints.js`);function dt(){return Object.freeze({resolveOpenTarget:async(e,t)=>await ft(e,t),inferOpenedAppBundleId:async(e,t,n)=>{if(n)return n;try{let{inferAndroidPackageAfterOpen:r}=await f();return await r(e,t,n)}catch{return n}},resetFramePerfStats:async(e,t)=>{let{resetAndroidFramePerfStats:n}=await f();await n(e,t)},applyRuntimeHints:async(e,t)=>{let{applyRuntimeHintValues:n}=await $();await n({device:e,...t})},clearRuntimeHints:async(e,t)=>{let{clearRuntimeHintValues:n}=await $();await n({device:e,...t})},activateTestIme:async(t,n)=>{let{activateAndroidTestIme:r}=await f(),i=await r(t,n);if(i.outcome===`helper-unavailable`){o({level:`warn`,phase:`android_test_ime_activate_failed`,data:{device:t.id,error:i.reason,...i.hint===void 0?{}:{hint:i.hint}}});return}if(i.persistFailed&&!(!i.alreadyActive&&!i.activated))throw new e(`COMMAND_FAILED`,`Android test IME recovery records could not be persisted for ${t.name??t.id}.`,{reason:`android_test_ime_recovery_fence_failed`,deviceId:t.id})},restoreTestIme:async(t,n)=>{let{restoreAndroidTestIme:r}=await f();if((await r(t,{stateDir:n.stateDir})).reason===`set-failed`)throw new e(`COMMAND_FAILED`,`Android test IME could not be restored on ${t.name??t.id}.`,{reason:`android_test_ime_restore_incomplete`,deviceId:t.id})},recoverTestImeStartup:async e=>{let{listAndroidAdbSerialsQuick:t,restoreOrphanedAndroidTestImeOnDaemonStartup:n}=await f();await n({stateDir:e.stateDir,listSerials:t})},hasTestImeRecoveryEvidence:async e=>{let{readAndroidTestImeRecoveryMarkers:t}=await f();return(await t(e)).length>0}})}async function ft(e,t){let{resolveSessionAppBundleIdForTarget:n}=await lt();return{appBundleId:await n(e,t.target,t.currentAppBundleId),appName:t.target}}function pt(){return Object.freeze({resolve:async(e,t)=>{let{getLocalInteractor:n}=await import(`./interactors.js`).then(e=>e.n);return await n(e,t)}})}function mt(e){return Object.freeze({recoverStartupResources:async t=>{await e.android.hasTestImeRecoveryEvidence(t.stateDir)&&await e.android.recoverTestImeStartup(t)},detachForDaemonShutdown:async()=>await e.apple.detachRunnerSessionsForShutdown(),finalizeDaemonShutdown:async()=>await e.apple.finalizeRunnerSessionsForShutdown()})}function ht(e){return Object.freeze({captureSurface:async(t,n,r)=>t.platform===`linux`?await e.linux(n,r):(gt(t),await e.macos(n,r)),presentIosAcquisition:async(e,t)=>{let{presentIosSnapshotAcquisition:n}=await import(`./ios-snapshot-runtime.js`);return await n(e,t)}})}function gt(e){if(e.platform!==`apple`||e.appleOs!==`macos`)throw TypeError(`Apple surface capture requires a non-app macOS surface`)}async function _t(e,t){let n=a(e?.surface);if(!n)throw TypeError(`Apple surface capture requires a helper-routed macOS surface`);let{captureMacOsSurfaceSnapshot:r}=await import(`./macos-facade.js`);return await r({...e,surface:n},t)}function vt(e){let t=_(e.sessionsDir),n=Object.freeze({mode:`local`,start:t.start}),r=se(),i=Object.freeze({which:async e=>await d(e)?e:void 0,run:async(e,t)=>{let n=await u(e.executable,ce(e),{allowFailure:e.allowFailure,cwd:e.cwd,env:e.env?{...process.env,...e.env}:void 0,signal:t,timeoutMs:e.timeoutMs});return{stdout:n.stdout,stderr:n.stderr,exitCode:n.exitCode}}}),a=he({resolveSessionArtifacts:e.resolveSessionArtifacts,processes:t,resolveTransport:async e=>{if(e.platform!==`web`)return Object.freeze({mode:`local`});let{resolveWebNetworkTransport:t}=await import(`./platform-runtime-network-web-transport.js`);return await t(e)}}),o=rt(),s=dt();return Object.freeze({commands:i,appleTools:r,toolchains:oe(),artifacts:Object.freeze({resolveSession:e.resolveSessionArtifacts}),outputs:Object.freeze({openAppend:async t=>await ue(e.sessionsDir,t),readTail:async(t,n)=>await de(e.sessionsDir,t,n)}),processes:t,processTransports:Object.freeze({resolve:async t=>{if(t.platform!==`android`)return n;let{resolveAndroidAppLogProcessTransport:r}=await import(`./platform-runtime-app-log-android-transport.js`);return r(e.sessionsDir,t,n)}}),...a,appleDeployment:Ge(),androidDeployment:Ke(),androidTools:qe(),temporaryFiles:Object.freeze({create:async e=>await v(e)}),deviceReadiness:Object.freeze({applePhysical:ze(),appleAutomation:Be(),androidEmulator:Ve()}),deviceShutdown:He({appleTools:r,commands:i},e.shutdownLoaders),screenRecording:D({ownedProcesses:e.ownedProcesses}),audioProbe:A({ownedProcesses:e.ownedProcesses}),perf:Le(),snapshot:e.snapshot,localInteractors:pt(),appleApplications:o,androidApplications:s,applicationResources:mt({android:s,apple:o}),clock:Object.freeze({now:()=>Date.now(),sleep:async(e,t)=>{await le(e,void 0,t?{signal:t}:void 0)}})})}export{vt as createPlatformRuntimeHost,ht as createSnapshotRuntimeHost,_t as loadMacOsSurfaceSnapshot,ie as recoverLegacyAppLogMarkersAfterDaemonLock};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as e,j as t}from"./sdk-contracts.js";import{d as n}from"./sdk-device.js";import{n as r}from"./exec.js";import"./command.js";import{n as i}from"./device-shell.js";import{t as a}from"./platform-runtime-android-mechanics.js";import{n as o}from"./entities.js";const s=`debug_http_host`,c=`dev_server_https`,l=`RCT_jsLocation`,u=`RCT_packager_scheme`,d=`React Native runtime hints require adb run-as access to the app sandbox. Verify the app is debuggable and the selected package/device are correct.`,f=[`<?xml version="1.0" encoding="utf-8" standalone="yes" ?>`,`<map>`,`</map>`,``].join(`
|
|
2
2
|
`);async function p(e){let{device:t,appId:r,values:i}=e;if(!r)return;let a=h(i);if(a){if(t.platform===`android`){await S(t,r,a);return}n(t)&&t.kind===`simulator`&&await j(t,r,a)}}async function m(e){let{device:t,appId:r}=e;if(r){if(t.platform===`android`){await C(t,r);return}n(t)&&t.kind===`simulator`&&await M(t,r)}}function h(e){let t=g(_(e,`bundleUrl`)),n=_(e,`metroHost`)??t?.host,r=v(e,`metroPort`)??t?.port,i=t?.scheme??`http`;return n&&r?{host:n,port:r,scheme:i}:void 0}function g(t){if(!t)return;let n;try{n=new URL(t)}catch(n){throw new e(`INVALID_ARGS`,`Invalid runtime bundle URL: ${t}`,{},n)}if(n.protocol===`http:`||n.protocol===`https:`)return{host:y(n.hostname),port:b(n.port.length>0?Number(n.port):n.protocol===`https:`?443:80),scheme:n.protocol===`https:`?`https`:`http`}}function _(e,t){return y(e[t])}function v(e,t){let n=_(e,t);return n===void 0?void 0:b(Number(n))}function y(e){let t=e?.trim();return t&&t.length>0?t:void 0}function b(e){return Number.isInteger(e)&&e>0&&e<=65535?e:void 0}function x(e){return[`shared_prefs/${e}_preferences.xml`,`shared_prefs/ReactNativeDevPrefs.xml`]}async function S(e,t,n){await z(t);let r=[];for(let i of x(t)){let a=F(await T(e,t,i),s,`${n.host}:${n.port}`);a=I(a,c,n.scheme===`https`),r.push({path:i,xml:a})}await E(e,t,r)}async function C(e,t){await z(t);let n=[];for(let r of x(t)){let i=await T(e,t,r),a=R(R(i,s),c);a!==i&&n.push({path:r,xml:a})}n.length!==0&&await E(e,t,n)}async function w(e,t,n){let{runAndroidAdb:r}=await a();return await r(e,t,n)}async function T(e,t,n){let r=await w(e,i(`adb`,`shell`,[`run-as`,t,`cat`,n]),{allowFailure:!0});return r.exitCode===0?P(r.stdout):f}async function E(e,t,n){await D(e,t);try{await k(e,t,n)}catch(e){throw A(e,t)}}async function D(e,t){let n=i(`adb`,`shell`,[`run-as`,t,`id`]),r=await w(e,n,{allowFailure:!0});if(r.exitCode!==0)throw O(r,t,n)}function O(t,n,i){let a=V(t.stdout,t.stderr);return new e(`COMMAND_FAILED`,a?`Failed to access Android app sandbox for ${n}`:`Failed to probe Android app sandbox for ${n}`,r(t,{package:n,cmd:`adb`,args:i,hint:a?d:`adb shell run-as probe failed. Check adb connectivity and that the device is reachable. Inspect stderr/details for more information.`}))}async function k(e,t,n){await w(e,i(`adb`,`shell`,[`run-as`,t,`mkdir`,`-p`,`shared_prefs`]));for(let r of n)await w(e,i(`adb`,`shell`,[`run-as`,t,`tee`,r.path]),{stdin:r.xml.trimEnd()})}function A(n,r){let i=t(n);if(i.code===`TOOL_MISSING`)return i;let a=V(typeof i.details?.stdout==`string`?i.details.stdout:``,typeof i.details?.stderr==`string`?i.details.stderr:``);return new e(`COMMAND_FAILED`,a?`Failed to access Android app sandbox for ${r}`:`Failed to write Android runtime hints for ${r}`,{...i.details??{},package:r,cmd:`adb`,phase:`write-runtime-hints`,hint:a?d:`adb run-as succeeded, but writing React Native dev-server preferences failed. Inspect stderr/details for the failing shell command.`},i)}async function j(e,t,n){await N(e,[`spawn`,e.id,`defaults`,`write`,t,l,`-string`,`${n.host}:${n.port}`]),await N(e,[`spawn`,e.id,`defaults`,`write`,t,u,`-string`,n.scheme])}async function M(e,t){await N(e,[`spawn`,e.id,`defaults`,`delete`,t,l],{allowFailure:!0}),await N(e,[`spawn`,e.id,`defaults`,`delete`,t,u],{allowFailure:!0})}async function N(e,t,n){let[{buildSimctlArgsForDevice:r},{runXcrun:i}]=await Promise.all([import(`./simctl-facade.js`),import(`./tool-provider-facade.js`)]);await i(r(e,t),n)}function P(e){let t=e.trim();return!t.includes(`<map`)||!t.includes(`</map>`)?f:`${t}\n`}function F(e,t,n){let r=` <string name="${o(t)}">${o(n)}</string>`;return L(R(e,t),r)}function I(e,t,n){let r=` <boolean name="${o(t)}" value="${n?`true`:`false`}" />`;return L(R(e,t),r)}function L(e,t){return P(e).replace(`</map>`,`${t}\n</map>`)}function R(e,t){let n=B(t);return P(e).replace(RegExp(`^\\s*<string name="${n}">[\\s\\S]*?<\\/string>\\n?`,`m`),``).replace(RegExp(`^\\s*<boolean name="${n}" value="(?:true|false)"\\s*\\/?>\\n?`,`m`),``)}async function z(t){let{classifyAndroidAppTarget:n,formatAndroidInstalledPackageRequiredMessage:r}=await a();if(n(t)!==`binary`)return;let i=r(t);throw new e(`INVALID_ARGS`,i,{package:t,hint:i})}function B(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}function V(e,t){let n=`${e}\n${t}`.toLowerCase();return[`run-as: package not debuggable`,`run-as: permission denied`,`run-as: package is unknown`,`run-as: unknown package`,`is unknown`,`is not an application`,`could not set capabilities`].some(e=>n.includes(e))}export{p as applyRuntimeHintValues,m as clearRuntimeHintValues};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as e}from"./sdk-contracts.js";import{n as t}from"./exec.js";import"./command.js";import{i as n,n as r,r as i,t as a}from"./platform-runtime-screen-recording-process-host.js";import o from"node:fs";const s=(e,t)=>{if(e===t)return!0;let n=/^(?:\S*\/)?xcrun simctl (.+)$/.exec(e)?.[1],r=/^(?:\S*\/)?simctl (.+)$/.exec(t)?.[1];return n!==void 0&&n===r&&/^(?:--set .+ )?io \S+ recordVideo .+$/.test(n)};async function c(e,t,a){let{resolveAppleSimulatorScreenRecordingTransport:c}=await import(`./platform-runtime-screen-recording-apple-transport.js`);a?.throwIfAborted();let p;try{p=await u(c().start({device:e,outputPath:t,signal:a}),a),a?.throwIfAborted()}catch(e){throw p&&await d(p),o.rmSync(t,{force:!0}),a?.throwIfAborted(),e}if(!p)throw Error(`simctl recordVideo acquisition did not return a process`);let m;try{if(m=await l(p.child.pid,p.wait,a),!m)throw Error(`simctl recordVideo did not expose a complete process identity`)}catch(e){throw await d(p),a?.throwIfAborted(),e}try{await h(t,p.wait,a);let e=await r(m.pid)??m,n=await i(e);return f(p,n)}catch(e){throw await n([m],p,s).catch(()=>{}),await p.wait.catch(()=>void 0),o.rmSync(t,{force:!0}),a?.throwIfAborted(),e}}async function l(e,t,n){let i=g(t),a=e===void 0?0:80;for(let t=0;t<=a;t+=1){n?.throwIfAborted();let o=await r(e);if(o)return o;let s=await Promise.race([i,t<a?v(25,n).then(()=>void 0):Promise.resolve(void 0)]);if(s)throw _(s)}}async function u(e,t){let n=Promise.resolve(e);if(!t)return await n;if(t.aborted)throw`child`in e?await d(e):n.then(d).catch(()=>void 0),t.reason;let r=()=>{},i=new Promise((e,n)=>{let i=()=>n(t.reason);t.addEventListener(`abort`,i,{once:!0}),r=()=>t.removeEventListener(`abort`,i),t.aborted&&i()});try{return await Promise.race([n,i])}catch(e){throw t.aborted?(n.then(d).catch(()=>void 0),t.reason):e}finally{r()}}async function d(e){e.child.kill(`SIGINT`);let t=new AbortController;await Promise.race([e.wait.then(()=>!0,()=>!0),v(5e3,t.signal).then(()=>!1)]).finally(()=>t.abort())||(e.child.kill(`SIGKILL`),await e.wait.catch(()=>void 0))}function f(e,t){let r,i=!1,a=()=>n(t,e,s).then(e=>{if(e===`ownership-lost`)throw Error(`simctl recordVideo process ownership changed before cleanup`);i=e===`terminated`}),o=()=>(r??=a().catch(e=>{throw r=void 0,e}),r),c=e.wait.then(async e=>{let t=r;return t&&await t.catch(()=>void 0),i&&e.exitCode!==0?{...e,exitCode:0}:e});return Object.freeze({markers:Object.freeze([...t]),wait:c,terminate:o})}function p(e){return a(e,s)}async function m(e){return await n([e],void 0,s)}async function h(e,t,n){let r=g(t),i;r.then(e=>{i=e}),await Promise.resolve();for(let t=0;t<=60;t+=1){if(n?.throwIfAborted(),i)throw _(i);if(o.existsSync(e)){let e=await Promise.race([r,v(50,n).then(()=>void 0)]);if(e)throw _(e);return}if(t===60)throw Error(`simctl recordVideo did not create its output within 15000ms`);let a=await Promise.race([r,v(250,n).then(()=>void 0)]);if(a)throw _(a)}}function g(e){return e.then(e=>({kind:`exited`,result:e}),e=>({kind:`failed`,error:e}))}function _(n){if(n.kind===`failed`)return n.error instanceof Error?n.error:Error(String(n.error));let{exitCode:r}=n.result;return r===16?new e(`DEVICE_IN_USE`,`CoreSimulator host recording is already in progress`,t({...n.result,exitCode:r},{reason:`apple_simulator_recording_busy`,retriable:!1,hint:`Stop the active recording with record stop in its owning session. If a previous recorder died and no recording is active, ask the host operator to restart the CoreSimulator stream service before retrying.`})):Error(`simctl recordVideo exited with code ${r}`)}function v(e,t){return t?.throwIfAborted(),new Promise((n,r)=>{let i=e=>{clearTimeout(a),t?.removeEventListener(`abort`,o),e===void 0?n():r(e)},a=setTimeout(()=>i(),e);if(!t)return;let o=()=>i(t.reason);t.addEventListener(`abort`,o,{once:!0}),t.aborted&&o()})}export{p as inspectAppleSimulatorRecordingProcess,c as startAppleSimulatorRecording,m as terminateAppleSimulatorRecordingProcess};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as e}from"./sdk-contracts.js";import{t}from"./recording-export-quality.js";import{c as n}from"./exec.js";import"./command.js";import{r}from"./version.js";import{t as i}from"./screen-recording-runtime.js";import{n as a}from"./telemetry.js";import{a as o,c as s,i as c,n as l,o as u,s as d,t as f}from"./video.js";import p from"node:path";import m from"node:fs";function h(e=process.platform){if(e!==`darwin`)return`touch overlay burn-in is only available on macOS hosts; returning raw video plus gesture telemetry`}let g,_;function v(){return g??=s(`recording-overlay.swift`,r()),g}function y(){return _??=s(`RecordingExportSupport.swift`,r()),_}async function b(t){let{videoPath:r,scriptPath:i,scriptArgs:a,commandDescription:s}=t;await o(r),await c(r);let l=x(r);try{let e=await d({sourcePath:i,extraSourcePaths:[y()]});await n(e,[`--input`,r,`--output`,l,...a],{timeoutMs:12e4,env:u()}),await c(l),m.renameSync(l,r)}catch(t){let n=t instanceof e?t:new e(`COMMAND_FAILED`,String(t),void 0,t instanceof Error?t:void 0);throw new e(`COMMAND_FAILED`,s,{...n.details,videoPath:r,script:i},n)}finally{m.rmSync(l,{force:!0})}}function x(e){let t=p.parse(e),n=`${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;return p.join(t.dir,`.${t.name}.agent-device-${n}${t.ext||`.mp4`}`)}async function S(e){let{videoPath:n,telemetryPath:r,exportQuality:i=t,targetLabel:a=`recording`}=e;await b({videoPath:n,scriptPath:v(),scriptArgs:[`--events`,r,`--quality`,i],commandDescription:`Failed to add touch overlays to the ${a}`})}function C(){return Object.freeze({sniff:w,complete:T})}async function w(e){if(!await f(e.outputPath))throw D(e.outputPath)}async function T(e){if(await o(e.outputPath),await c(e.outputPath),!await l(e.outputPath))throw D(e.outputPath);let t=a({recording:{outPath:e.outputPath,gestureEvents:[...e.gestureEvents]}});return!e.showTouches||e.gestureEvents.length===0?{telemetryPath:t}:await E(e,t)}async function E(e,t){let n=h();if(n)return{telemetryPath:t,overlayWarning:n};try{if(await S({videoPath:e.outputPath,telemetryPath:t,exportQuality:e.exportQuality,targetLabel:e.targetLabel}),!await l(e.outputPath))throw Error(`recording post-processing produced an unplayable video`);return{telemetryPath:t}}catch(e){return{telemetryPath:t,overlayWarning:`failed to overlay recording touches: ${e instanceof Error?e.message:String(e)}`}}}function D(t){return new e(`COMMAND_FAILED`,`recording was not finalized into a playable video: ${t}`,{reason:i,retriable:!0,hint:`Run record stop again: a recorder that is still finalizing its file is playable on the next stop, and the recording keeps its evidence either way. If the recorder died before writing a video, close this session to release the device and record again.`})}export{C as createScreenRecordingFinalizer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{P as e}from"./sdk-contracts.js";import{r as t}from"./diagnostics.js";import{S as n,b as r,g as i,h as a,o,p as s,w as c,x as l,y as u}from"./owner-identity.js";import"./diagnostics2.js";import"./process.js";const d=2e3,f=(e,t)=>e===t;async function p(e){if(e===void 0)return;let[t,n]=await Promise.all([Promise.resolve(l(e)),Promise.resolve(u(e))]);return t&&n?Object.freeze({pid:e,startTime:t,command:n}):void 0}async function m(e){let t=await h(e.pid),n=o([e.pid],t),r=(await Promise.all(n.map(async e=>await p(e.pid)))).filter(e=>e!==void 0);return Object.freeze([e,...r.filter(t=>t.pid!==e.pid)])}async function h(n){try{return await i({timeoutMs:5e3})}catch(r){return t({level:`warn`,phase:`screen_recording_process_tree_unreadable`,data:{rootPid:n,reason:e(r)}}),[]}}function g(e,t=f){return!s(e.pid)||a(e.pid)?`missing`:S(e,t)?`owned-alive`:`ownership-lost`}async function _(e,t){if(!s(e.pid))return`gone`;let n=await r(e.pid,5e3);return n.zombie===!0?`gone`:e.startTime.length===0||e.command.length===0?`not-ours`:n.startTime===null||n.command===null?`unprovable`:n.startTime===e.startTime&&t(e.command,n.command)?`ours`:`not-ours`}async function v(e,t,n=f){let r=t?.child.pid,i=async e=>({marker:e,evidence:await _(e,n)}),a=({marker:e,evidence:t})=>t===`ours`||t===`unprovable`&&e.pid===r,o=await Promise.all(e.map(i)),s=o[0],c=new Set(e.map(({pid:e})=>e)),l=s!==void 0&&a(s)?await m(s.marker):[],u=await Promise.all(l.filter(({pid:e})=>!c.has(e)).map(async e=>await i(e))),p=[...o,...u],h=p.filter(a).map(({marker:e})=>e);if(h.length===0)return y(p.map(({evidence:e})=>e));let g=new Set(h.map(({pid:e})=>e)),v=p.filter(({marker:e,evidence:t})=>!g.has(e.pid)&&t!==`gone`);for(let[e,r]of[[`SIGINT`,5e3],[`SIGTERM`,d],[`SIGKILL`,d]])if(b(h,e,t),await x(h,r,t,n))return v.length===0?`terminated`:`ownership-lost`;return`ownership-lost`}function y(e){return e.every(e=>e===`gone`)?`already-missing`:`ownership-lost`}function b(e,t,r){let i=r?.child.pid;n(e.map(({pid:e})=>e).filter(e=>e!==i),t),i!==void 0&&e.some(({pid:e})=>e===i)&&r?.child.kill(t)}async function x(e,t,n,r){let i=n?.child.pid,a=n?await C(n.wait,t):!1;return await Promise.all(e.filter(({pid:e})=>!a||e!==i).map(async({pid:e})=>await c(e,t))),e.every(e=>a&&e.pid===i||g(e,r)===`missing`)}function S(e,t){let n=u(e.pid);return e.startTime.length>0&&e.command.length>0&&l(e.pid)===e.startTime&&n!==null&&t(e.command,n)}async function C(e,t){return await Promise.race([e.then(()=>!0,()=>!0),new Promise(e=>setTimeout(()=>e(!1),t))])}export{v as i,p as n,m as r,g as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{D as t}from"./sdk-contracts.js";import{A as n,D as r,j as i,k as a,l as o}from"./sdk-device.js";import{$t as s,Qt as c,en as l,k as u}from"./sdk-batch.js";import{i as d,o as f,t as p}from"./device.js";import{t as ee}from"./startup-recovery-fence.js";import{i as m,n as h,r as g}from"./src2.js";import{n as _,t as v}from"./src3.js";import{i as te,m as ne}from"./src4.js";import{c as re,g as y,n as b}from"./src5.js";import{r as x,t as S}from"./src6.js";import{n as C,r as ie,t as w}from"./platform-runtime-unavailable.js";const T=Object.freeze({family:`android`});function ae(e){let t,n=()=>(t??=import(`./observation.js`).then(({createAndroidObservationAdapter:t})=>t(e)),t);return Object.freeze({readAppState:async(...e)=>await(await n()).readAppState(...e),readBlockingDialog:async(...e)=>await(await n()).readBlockingDialog(...e),readAppFocus:async(...e)=>await(await n()).readAppFocus(...e),readSnapshotNodes:async(...e)=>await(await n()).readSnapshotNodes(...e),tap:async(...e)=>await(await n()).tap(...e),openApp:async(...e)=>await(await n()).openApp(...e),readScreenSize:async(...e)=>await(await n()).readScreenSize(...e),isPermissionPackage:async(...e)=>await(await n()).isPermissionPackage(...e)})}async function oe(e,t){let{readAndroidAppStateWithExecutor:n}=await import(`./app-state.js`);return await n(e,t)}function se(e){return Object.freeze({...T,loadRuntime:async t=>{await e.bindAdbHost();let{createAndroidPlatformRuntime:n}=await import(`./runtime2.js`);return n(t)}})}function ce(e){let t=Object.freeze({sdkRoots:Object.freeze([...new Set(e.sdkRoots.map(e=>e.trim()).filter(Boolean))])});return Object.freeze({...T,loadInventory:async e=>{let{createAndroidInventory:n}=await import(`./inventory.js`);return n(e,t)}})}async function le(e){let{createAndroidShutdownRuntime:t}=await import(`./runtime3.js`);return t(e)}function ue(e){let t=new Map,n=new Map;for(let r of e.providerModules??[]){let{runtime:e,module:i}=r,a=s(i.owner);if(i.owner.provider!==e.provider)throw z(`Provider platform runtime metadata is invalid: ${a}`);if(t.has(a))throw z(`Duplicate platform runtime owner: ${a}`);if(n.has(e))throw z(`Duplicate platform module registration for ${e.provider}`);t.set(a,r),n.set(e,i)}let r=new Map;for(let t of e.managedOwners??[]){let e=s(t);if(r.has(e))throw z(`Duplicate platform runtime owner: ${e}`);r.set(e,t)}let i=new Map,a=new Map,o=new Map,c=new Map,u,d=async()=>{u??=e.loadHost();try{return await u}catch(e){throw u=void 0,e}},f,p,m=Object.freeze({recoverStartupResources:async e=>{await ee(e.stateDir,async()=>{await(await d()).applicationResources.recoverStartupResources(e)})},detachForDaemonShutdown:async()=>{f??=d().then(async e=>await e.applicationResources.detachForDaemonShutdown()),await f},finalizeDaemonShutdown:async()=>{p??=d().then(async e=>await e.applicationResources.finalizeDaemonShutdown()),await p}}),h=e=>{let t=s(e.owner),n=c.get(t);if(n&&n!==e)throw z(`Duplicate platform runtime owner: ${t}`);return c.set(t,e),e},g=async t=>{let n=i.get(t);if(n)return await n;let r=e.modules.get(t);if(!r)throw z(`Missing platform runtime module for ${t}`);if(r.family!==t)throw z(`Platform runtime module registered for ${t} declares ${r.family}`);let a=d().then(async e=>{let n=await r.loadRuntime(e);if(n.owner.kind!==`local-family`||n.owner.family!==t)throw z(`Platform runtime module for ${t} returned a different local owner`);return h(n)});i.set(t,a);try{return await a}catch(e){throw i.get(t)===a&&i.delete(t),e}},_=async e=>{let t=a.get(e);if(t)return await t;let n=d().then(async t=>{let n=await e.loadRuntime(t);if(!l(n.owner,e.owner))throw z(`Provider platform runtime returned a different advertised owner`);return h(n)});a.set(e,n);try{return await n}catch(t){throw a.get(e)===n&&a.delete(e),t}},v=async e=>{let t=s(e),n=r.get(t);if(!n)throw R(e);let i=o.get(t);if(i)return i;let{createManagedLocalRuntimeOwner:a}=await import(`./platform-runtime-managed-owner.js`),c=h(a({owner:n,loadLocal:g}));return o.set(t,c),c};return Object.freeze({applicationLifecycle:m,inspectFacts:async t=>{let r=E(e.providerRuntimes,t);if(r){let e=n.get(r);return e?await D(await _(e),t):L(r,t)}return await D(await g(t.platform),t)},bind:async r=>{if(r.intent.kind===`exact-owner`)return await O(await P(r.intent.owner,t,_,g,v),r);let i=E(e.providerRuntimes,r.device);if(i){let e=n.get(i);return e?await O(await _(e),r):I(i,r.device)}return await O(await g(r.device.platform),r)},shutdown:async()=>{await Promise.allSettled([...c.values()].map(async e=>await e.shutdown())),c.clear(),i.clear(),a.clear(),o.clear()}})}function E(e,t){let n=(e??[]).filter(e=>e.ownsDevice(t));if(n.length>1)throw z(`Multiple provider runtimes claim the selected device`);return n[0]}async function D(e,t){let n=await e.inspectFacts(t);if(!M(t,e.owner,n))throw z(`Platform runtime facts do not match the selected device and owner`);return n}async function O(e,t){let n=await e.bind(t),r=k(e,n,t);if(!r)return n;let i;try{await n[Symbol.asyncDispose]()}catch(e){i=e instanceof Error?e.message:String(e)}throw z(r,i)}function k(e,t,i){if(!l(t.owner,e.owner))return`Platform binding returned a different owner than the selected runtime`;if(!A(t.owner,i))return`Exact platform binding returned a different persisted owner`;if(!n(r(t.device),r(i.device)))return`Platform binding returned a different device identity`;if(!j(t))return`Platform binding facts do not match its device and owner`}function A(e,t){return t.intent.kind!==`exact-owner`||l(e,t.intent.owner)}function j(e){return M(e.device,e.owner,e.facts)}function M(e,t,n){return i(n.device,a(e))&&N(n.device.providerMode,t)}function N(e,t){switch(t.kind){case`local-family`:return e===`local`||e===`transport-composed`;case`managed-local`:return e===`local`||e===`transport-composed`;case`provider-runtime`:return e===`provider-runtime`}}async function P(e,t,n,r,i){switch(e.kind){case`local-family`:{let t=await r(e.family);if(l(t.owner,e))return t;throw R(e)}case`managed-local`:return await i(e);case`provider-runtime`:{let r=t.get(s(e));if(r)return await n(r.module);throw R(e)}}}const F=Object.freeze({available:!1,reason:`unsupported-provider-mode`});function I(e,t){let n=c(e.provider,`default`);return C(t,n,w(F))}function L(e,t){return ie(t,c(e.provider,`default`),w(F))}function R(e){return new t(`UNSUPPORTED_OPERATION`,`The exact platform runtime owner is unavailable.`,{reason:`owner-unavailable`,owner:s(e)})}function z(e,n){return new t(`COMMAND_FAILED`,e,{reason:`runtime-contract-invalid`,...n?{cleanupError:n}:{}})}function B(e){let t=V(e.registry,e.loadHost),n=e.provider,r=n?async(e,r)=>{r.signal.throwIfAborted();let i=await n.discover(f(e),r.signal);return r.signal.throwIfAborted(),ge(i),i.kind===`inventory`?{devices:d(i.devices.map(e=>({...e})),e),source:`provider`}:{devices:await t.discover(e,r),source:`local`}}:async(e,n)=>({devices:await t.discover(e,n),source:`local`}),i=Object.freeze({discover:async(e,t)=>(await r(e,t)).devices,discoverWithSource:r});return Object.freeze({providerFirst:i,localOnly:t,findInstalledApp:async(e,t)=>{let{findIosSimulatorInstalledApp:n}=await import(`./app-resolution-facade.js`);return await n(e,t)}})}function V(e,t){let n,r=async()=>{n??=t();try{return await n}catch(e){throw n=void 0,e}},i=new Map,a=async t=>{let n=i.get(t);if(n)return await n;let a=H(e.get(t),r);i.set(t,a);try{return await a}catch(e){throw i.get(t)===a&&i.delete(t),e}};return Object.freeze({discover:async(e,t)=>{if(t.signal.throwIfAborted(),e.platform)return await W(a,G(e.platform),e,t);let n=await Promise.all(p.map(async n=>{try{let r=await W(a,G(n),{...e,platform:n},t);return Array.isArray(r)?r:[]}catch{return[]}}));return t.signal.throwIfAborted(),n.flat()}})}async function H(e,t){switch(e.family){case`apple`:return await e.loadInventory(U(await t()));case`android`:return await e.loadInventory(de(await t()));case`harmonyos`:return await e.loadInventory(fe(await t()));case`vega`:return await e.loadInventory(pe(await t()));case`linux`:return await e.loadInventory(me(await t()));case`web`:return await e.loadInventory()}}function U(e){return Object.freeze({appleTools:e.appleTools,files:e.files,hostName:e.hostName,hostOs:e.hostOs,observations:e.observations})}function de(e){return Object.freeze({commands:e.commands,files:e.files,homeDirectory:e.homeDirectory,toolchains:e.toolchains})}function fe(e){return Object.freeze({commands:e.commands,files:e.files,toolchains:e.toolchains})}function pe(e){return Object.freeze({commands:e.commands,files:e.files,homeDirectory:e.homeDirectory})}function me(e){return Object.freeze({hostName:e.hostName,hostOs:e.hostOs})}async function W(e,t,n,r){let i=await e(t);r.signal.throwIfAborted();let a=await i.discover(n,r);return r.signal.throwIfAborted(),he(t,a),d(a,n)}function G(e){return o(e)?`apple`:e}function he(e,n){let r=n.find(t=>t.platform!==e);if(r)throw new t(`COMMAND_FAILED`,`Platform inventory source ${e} returned a ${r.platform} device.`,{expectedFamily:e,actualFamily:r.platform,deviceId:r.id})}function ge(e){if(typeof e==`object`&&e){let t=e;if(t.kind===`declined`&&!(`devices`in t)||t.kind===`inventory`&&Array.isArray(t.devices))return}throw new t(`COMMAND_FAILED`,`Provider device inventory returned an invalid outcome.`,{reason:`provider_inventory_contract_violation`})}function _e(){return Object.freeze({async runAdb(e,t,n){let{runAndroidAdb:r}=await K(),i=await r(e,t,n);return{exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr}},async readSnapshotNodes(e){let{snapshotAndroid:t,androidSnapshotPublicationInput:n}=await K(),{buildSnapshotState:r}=await import(`./snapshot-state.js`).then(e=>e.n);return r(n(await t(e,{interactiveOnly:!1})),void 0).nodes},async openApp(e,t){let{openAndroidApp:n}=await K();await n(e,t)}})}async function K(){let{loadAndroidMechanics:e}=await import(`./platform-runtime-android-mechanics.js`).then(e=>e.n);return await e()}var ve=e({androidObservation:()=>J,createPlatformDeviceInventoryGateways:()=>X,createPlatformRuntimeGateway:()=>Q,createRequestPlatformProviders:()=>$,getAndroidAppStateWithAdb:()=>ye,platformModuleRegistry:()=>Y,platformRuntimeModules:()=>Z});async function ye(e,t){return await oe(e,t)}const q=ce({sdkRoots:Ce(process.env.ANDROID_SDK_ROOT,process.env.ANDROID_HOME)}),J=ae(_e()),be=Object.freeze({apple:async e=>await g(e),android:async e=>await le(e)}),xe=te({hdcSdkPath:process.env.HDC_SDK_PATH,devecoSdkHome:process.env.DEVECO_SDK_HOME,commandLineToolsHome:process.env.HARMONYOS_COMMAND_LINE_TOOLS}),Y=u([h,q,xe,v,re,S]);function X(e){return B({registry:Y,loadHost:async()=>{let{createDeviceInventoryHost:e}=await import(`./platform-runtime-host.js`);return e()},provider:e})}const Se=se({bindAdbHost:async()=>{await import(`./platform-runtime-android-adb-host.js`).then(e=>e.t)}}),Z=new Map([[`apple`,m],[`android`,Se],[`harmonyos`,ne],[`vega`,_],[`linux`,y],[`web`,x]]);function Q(e){return ue({modules:Z,loadHost:async()=>{let{createPlatformRuntimeHost:t,createSnapshotRuntimeHost:n,loadMacOsSurfaceSnapshot:r}=await import(`./platform-runtime-operation-host.js`);return t({sessionsDir:e.sessionsDir,resolveSessionArtifacts:e.resolveSessionArtifacts,shutdownLoaders:be,snapshot:n({linux:b,macos:r}),ownedProcesses:e.ownedProcesses})},providerRuntimes:e.providerRuntimes,providerModules:e.providerModules})}function $(e={}){let t,n=()=>(t??=import(`./request-providers.js`).then(({createComposedRequestPlatformProviders:t})=>t(e)),t);return Object.freeze({hasConfiguredResolvers:Object.values(e.providers??{}).some(Boolean),run:async(e,t)=>await(await n()).run(e,t)})}function Ce(...e){return e.flatMap(e=>{let t=e?.trim();return t?[t]:[]})}export{ve as a,$ as i,X as n,Q as r,J as t};
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{A as t}from"./sdk-contracts.js";import{A as n,D as r,j as i,k as a,l as o}from"./sdk-device.js";import{$t as s,Qt as c,en as l,k as u}from"./sdk-batch.js";import{i as d,o as f,t as p}from"./device.js";import{t as ee}from"./startup-recovery-fence.js";import{i as m,n as h,r as g}from"./src2.js";import{n as _,t as v}from"./src3.js";import{i as te,m as ne}from"./src4.js";import{c as re,g as y,n as b}from"./src5.js";import{r as x,t as S}from"./src6.js";import{n as C,r as ie,t as w}from"./platform-runtime-unavailable.js";const T=Object.freeze({family:`android`});function ae(e){let t,n=()=>(t??=import(`./observation.js`).then(({createAndroidObservationAdapter:t})=>t(e)),t);return Object.freeze({readAppState:async(...e)=>await(await n()).readAppState(...e),readBlockingDialog:async(...e)=>await(await n()).readBlockingDialog(...e),readAppFocus:async(...e)=>await(await n()).readAppFocus(...e),readSnapshotNodes:async(...e)=>await(await n()).readSnapshotNodes(...e),tap:async(...e)=>await(await n()).tap(...e),openApp:async(...e)=>await(await n()).openApp(...e),readScreenSize:async(...e)=>await(await n()).readScreenSize(...e),isPermissionPackage:async(...e)=>await(await n()).isPermissionPackage(...e)})}async function oe(e,t){let{readAndroidAppStateWithExecutor:n}=await import(`./app-state.js`);return await n(e,t)}function se(e){return Object.freeze({...T,loadRuntime:async t=>{await e.bindAdbHost();let{createAndroidPlatformRuntime:n}=await import(`./runtime2.js`);return n(t)}})}function ce(e){let t=Object.freeze({sdkRoots:Object.freeze([...new Set(e.sdkRoots.map(e=>e.trim()).filter(Boolean))])});return Object.freeze({...T,loadInventory:async e=>{let{createAndroidInventory:n}=await import(`./inventory.js`);return n(e,t)}})}async function le(e){let{createAndroidShutdownRuntime:t}=await import(`./runtime3.js`);return t(e)}function ue(e){let t=new Map,n=new Map;for(let r of e.providerModules??[]){let{runtime:e,module:i}=r,a=s(i.owner);if(i.owner.provider!==e.provider)throw z(`Provider platform runtime metadata is invalid: ${a}`);if(t.has(a))throw z(`Duplicate platform runtime owner: ${a}`);if(n.has(e))throw z(`Duplicate platform module registration for ${e.provider}`);t.set(a,r),n.set(e,i)}let r=new Map;for(let t of e.managedOwners??[]){let e=s(t);if(r.has(e))throw z(`Duplicate platform runtime owner: ${e}`);r.set(e,t)}let i=new Map,a=new Map,o=new Map,c=new Map,u,d=async()=>{u??=e.loadHost();try{return await u}catch(e){throw u=void 0,e}},f,p,m=Object.freeze({recoverStartupResources:async e=>{await ee(e.stateDir,async()=>{await(await d()).applicationResources.recoverStartupResources(e)})},detachForDaemonShutdown:async()=>{f??=d().then(async e=>await e.applicationResources.detachForDaemonShutdown()),await f},finalizeDaemonShutdown:async()=>{p??=d().then(async e=>await e.applicationResources.finalizeDaemonShutdown()),await p}}),h=e=>{let t=s(e.owner),n=c.get(t);if(n&&n!==e)throw z(`Duplicate platform runtime owner: ${t}`);return c.set(t,e),e},g=async t=>{let n=i.get(t);if(n)return await n;let r=e.modules.get(t);if(!r)throw z(`Missing platform runtime module for ${t}`);if(r.family!==t)throw z(`Platform runtime module registered for ${t} declares ${r.family}`);let a=d().then(async e=>{let n=await r.loadRuntime(e);if(n.owner.kind!==`local-family`||n.owner.family!==t)throw z(`Platform runtime module for ${t} returned a different local owner`);return h(n)});i.set(t,a);try{return await a}catch(e){throw i.get(t)===a&&i.delete(t),e}},_=async e=>{let t=a.get(e);if(t)return await t;let n=d().then(async t=>{let n=await e.loadRuntime(t);if(!l(n.owner,e.owner))throw z(`Provider platform runtime returned a different advertised owner`);return h(n)});a.set(e,n);try{return await n}catch(t){throw a.get(e)===n&&a.delete(e),t}},v=async e=>{let t=s(e),n=r.get(t);if(!n)throw R(e);let i=o.get(t);if(i)return i;let{createManagedLocalRuntimeOwner:a}=await import(`./platform-runtime-managed-owner.js`),c=h(a({owner:n,loadLocal:g}));return o.set(t,c),c};return Object.freeze({applicationLifecycle:m,inspectFacts:async t=>{let r=E(e.providerRuntimes,t);if(r){let e=n.get(r);return e?await D(await _(e),t):L(r,t)}return await D(await g(t.platform),t)},bind:async r=>{if(r.intent.kind===`exact-owner`)return await O(await P(r.intent.owner,t,_,g,v),r);let i=E(e.providerRuntimes,r.device);if(i){let e=n.get(i);return e?await O(await _(e),r):I(i,r.device)}return await O(await g(r.device.platform),r)},shutdown:async()=>{await Promise.allSettled([...c.values()].map(async e=>await e.shutdown())),c.clear(),i.clear(),a.clear(),o.clear()}})}function E(e,t){let n=(e??[]).filter(e=>e.ownsDevice(t));if(n.length>1)throw z(`Multiple provider runtimes claim the selected device`);return n[0]}async function D(e,t){let n=await e.inspectFacts(t);if(!M(t,e.owner,n))throw z(`Platform runtime facts do not match the selected device and owner`);return n}async function O(e,t){let n=await e.bind(t),r=k(e,n,t);if(!r)return n;let i;try{await n[Symbol.asyncDispose]()}catch(e){i=e instanceof Error?e.message:String(e)}throw z(r,i)}function k(e,t,i){if(!l(t.owner,e.owner))return`Platform binding returned a different owner than the selected runtime`;if(!A(t.owner,i))return`Exact platform binding returned a different persisted owner`;if(!n(r(t.device),r(i.device)))return`Platform binding returned a different device identity`;if(!j(t))return`Platform binding facts do not match its device and owner`}function A(e,t){return t.intent.kind!==`exact-owner`||l(e,t.intent.owner)}function j(e){return M(e.device,e.owner,e.facts)}function M(e,t,n){return i(n.device,a(e))&&N(n.device.providerMode,t)}function N(e,t){switch(t.kind){case`local-family`:return e===`local`||e===`transport-composed`;case`managed-local`:return e===`local`||e===`transport-composed`;case`provider-runtime`:return e===`provider-runtime`}}async function P(e,t,n,r,i){switch(e.kind){case`local-family`:{let t=await r(e.family);if(l(t.owner,e))return t;throw R(e)}case`managed-local`:return await i(e);case`provider-runtime`:{let r=t.get(s(e));if(r)return await n(r.module);throw R(e)}}}const F=Object.freeze({available:!1,reason:`unsupported-provider-mode`});function I(e,t){let n=c(e.provider,`default`);return C(t,n,w(F))}function L(e,t){return ie(t,c(e.provider,`default`),w(F))}function R(e){return new t(`UNSUPPORTED_OPERATION`,`The exact platform runtime owner is unavailable.`,{reason:`owner-unavailable`,owner:s(e)})}function z(e,n){return new t(`COMMAND_FAILED`,e,{reason:`runtime-contract-invalid`,...n?{cleanupError:n}:{}})}function B(e){let t=V(e.registry,e.loadHost),n=e.provider,r=n?async(e,r)=>{r.signal.throwIfAborted();let i=await n.discover(f(e),r.signal);return r.signal.throwIfAborted(),ge(i),i.kind===`inventory`?{devices:d(i.devices.map(e=>({...e})),e),source:`provider`}:{devices:await t.discover(e,r),source:`local`}}:async(e,n)=>({devices:await t.discover(e,n),source:`local`}),i=Object.freeze({discover:async(e,t)=>(await r(e,t)).devices,discoverWithSource:r});return Object.freeze({providerFirst:i,localOnly:t,findInstalledApp:async(e,t)=>{let{findIosSimulatorInstalledApp:n}=await import(`./app-resolution-facade.js`);return await n(e,t)}})}function V(e,t){let n,r=async()=>{n??=t();try{return await n}catch(e){throw n=void 0,e}},i=new Map,a=async t=>{let n=i.get(t);if(n)return await n;let a=H(e.get(t),r);i.set(t,a);try{return await a}catch(e){throw i.get(t)===a&&i.delete(t),e}};return Object.freeze({discover:async(e,t)=>{if(t.signal.throwIfAborted(),e.platform)return await W(a,G(e.platform),e,t);let n=await Promise.all(p.map(async n=>{try{let r=await W(a,G(n),{...e,platform:n},t);return Array.isArray(r)?r:[]}catch{return[]}}));return t.signal.throwIfAborted(),n.flat()}})}async function H(e,t){switch(e.family){case`apple`:return await e.loadInventory(U(await t()));case`android`:return await e.loadInventory(de(await t()));case`harmonyos`:return await e.loadInventory(fe(await t()));case`vega`:return await e.loadInventory(pe(await t()));case`linux`:return await e.loadInventory(me(await t()));case`web`:return await e.loadInventory()}}function U(e){return Object.freeze({appleTools:e.appleTools,files:e.files,hostName:e.hostName,hostOs:e.hostOs,observations:e.observations})}function de(e){return Object.freeze({commands:e.commands,files:e.files,homeDirectory:e.homeDirectory,toolchains:e.toolchains})}function fe(e){return Object.freeze({commands:e.commands,files:e.files,toolchains:e.toolchains})}function pe(e){return Object.freeze({commands:e.commands,files:e.files,homeDirectory:e.homeDirectory})}function me(e){return Object.freeze({hostName:e.hostName,hostOs:e.hostOs})}async function W(e,t,n,r){let i=await e(t);r.signal.throwIfAborted();let a=await i.discover(n,r);return r.signal.throwIfAborted(),he(t,a),d(a,n)}function G(e){return o(e)?`apple`:e}function he(e,n){let r=n.find(t=>t.platform!==e);if(r)throw new t(`COMMAND_FAILED`,`Platform inventory source ${e} returned a ${r.platform} device.`,{expectedFamily:e,actualFamily:r.platform,deviceId:r.id})}function ge(e){if(typeof e==`object`&&e){let t=e;if(t.kind===`declined`&&!(`devices`in t)||t.kind===`inventory`&&Array.isArray(t.devices))return}throw new t(`COMMAND_FAILED`,`Provider device inventory returned an invalid outcome.`,{reason:`provider_inventory_contract_violation`})}function _e(){return Object.freeze({async runAdb(e,t,n){let{runAndroidAdb:r}=await K(),i=await r(e,t,n);return{exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr}},async readSnapshotNodes(e){let{snapshotAndroid:t,androidSnapshotPublicationInput:n}=await K(),{buildSnapshotState:r}=await import(`./snapshot-state.js`).then(e=>e.n);return r(n(await t(e,{interactiveOnly:!1})),void 0).nodes},async openApp(e,t){let{openAndroidApp:n}=await K();await n(e,t)}})}async function K(){let{loadAndroidMechanics:e}=await import(`./platform-runtime-android-mechanics.js`).then(e=>e.n);return await e()}var ve=e({androidObservation:()=>J,createPlatformDeviceInventoryGateways:()=>X,createPlatformRuntimeGateway:()=>Q,createRequestPlatformProviders:()=>$,getAndroidAppStateWithAdb:()=>ye,platformModuleRegistry:()=>Y,platformRuntimeModules:()=>Z});async function ye(e,t){return await oe(e,t)}const q=ce({sdkRoots:Ce(process.env.ANDROID_SDK_ROOT,process.env.ANDROID_HOME)}),J=ae(_e()),be=Object.freeze({apple:async e=>await g(e),android:async e=>await le(e)}),xe=te({hdcSdkPath:process.env.HDC_SDK_PATH,devecoSdkHome:process.env.DEVECO_SDK_HOME,commandLineToolsHome:process.env.HARMONYOS_COMMAND_LINE_TOOLS}),Y=u([h,q,xe,v,re,S]);function X(e){return B({registry:Y,loadHost:async()=>{let{createDeviceInventoryHost:e}=await import(`./platform-runtime-host.js`);return e()},provider:e})}const Se=se({bindAdbHost:async()=>{await import(`./platform-runtime-android-adb-host.js`).then(e=>e.t)}}),Z=new Map([[`apple`,m],[`android`,Se],[`harmonyos`,ne],[`vega`,_],[`linux`,y],[`web`,x]]);function Q(e){return ue({modules:Z,loadHost:async()=>{let{createPlatformRuntimeHost:t,createSnapshotRuntimeHost:n,loadMacOsSurfaceSnapshot:r}=await import(`./platform-runtime-operation-host.js`);return t({sessionsDir:e.sessionsDir,resolveSessionArtifacts:e.resolveSessionArtifacts,shutdownLoaders:be,snapshot:n({linux:b,macos:r}),ownedProcesses:e.ownedProcesses})},providerRuntimes:e.providerRuntimes,providerModules:e.providerModules})}function $(e={}){let t,n=()=>(t??=import(`./request-providers.js`).then(({createComposedRequestPlatformProviders:t})=>t(e)),t);return Object.freeze({hasConfiguredResolvers:Object.values(e.providers??{}).some(Boolean),run:async(e,t)=>await(await n()).run(e,t)})}function Ce(...e){return e.flatMap(e=>{let t=e?.trim();return t?[t]:[]})}export{ve as a,$ as i,X as n,Q as r,J as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e}from"./sdk-contracts.js";import{en as t,tn as n}from"./sdk-batch.js";import{n as r,t as i}from"./application-lifecycle-runtime.js";import{A as a,B as o,C as s,F as c,G as ee,I as te,J as l,M as u,N as ne,R as d,U as f,d as p,h as m,k as h,n as g,o as _,q as v,s as y,w as re,x as ie,z as ae}from"./alert-runtime.js";import{i as oe,n as se}from"./touch-runtime.js";import{r as b}from"./platform-runtime-unavailable.js";import{r as ce,t as le}from"./capabilities.js";import{n as ue}from"./src7.js";import{r as de}from"./gesture-admission.js";import{n as fe}from"./interactor-operation-catalog.js";import{r as pe,t as me}from"./application-lifecycle-interaction.js";function he(e){return me({owner:`WebDriver`,openTargetIdentity:`bundle-id`,closeBeforeRelaunch:!0,binding:pe({device:e.device,signal:e.signal,resolveInteractor:t=>e.getInteractor(e.device,t)})})}const x=Object.freeze({available:!0}),S=Object.freeze({available:!1,reason:`unsupported-provider-mode`}),C=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose screen recording.`}),w=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Headless boot is unavailable for provider-owned devices.`}),T=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`WebDriver provider runtimes do not expose app inventory.`}),E=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose app deployment.`}),D=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Push notifications are unavailable for WebDriver provider-owned devices.`}),O=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`The WebDriver provider session is no longer active for this device.`}),k=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose snapshot capture for this device.`}),A=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose screenshot capture for this device.`}),j=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose iOS simulator custom snapshot actions.`}),M=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose viewport resizing.`}),N=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose focus for this device.`}),P=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose text entry for this device.`}),F=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose gestures for this device.`}),I=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose scrolling for this device.`}),L=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:de}),R=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes read element text from the captured tree only.`}),z=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose back for this device.`}),ge=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose home for this device.`}),B=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose orientation for this device.`}),V=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose tv-remote.`}),_e=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose keyboard actions.`}),H=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose clipboard access for this device.`}),ve=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose the app switcher for this device.`}),U=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`No WebDriver backend presses this system button.`}),W=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`fold runs a HID helper through simctl spawn inside a foldable iPhone simulator on the daemon host; a WebDriver backend has no such simulator.`}),G=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose native alert handling.`}),K=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose device settings.`}),q=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose app-event delivery for this device.`}),ye=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose a foreground app-state operation.`}),J=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose the audio probe.`}),be=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Apple runner preparation is unavailable for WebDriver-owned devices.`}),xe=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver open is supported only for its owned iOS or Android mobile-device sessions.`}),Se=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver close is supported only for its owned iOS or Android mobile-device sessions.`}),Y=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Runtime hints are not applied to provider-owned devices.`}),Ce=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose port reverse.`});function X(e){let t=e.platform===`android`&&e.kind===`device`&&e.target===`mobile`||e.platform===`apple`&&e.kind===`device`&&e.target===`mobile`&&e.appleOs===`ios`,n=t?x:xe,r=t?x:Se;return i({resolveOpenTarget:n,prepareApplicationOpen:n,openApplication:n,applyRuntimeHints:Y,clearRuntimeHints:Y,closeApplication:r,finalizeApplicationClose:r,prepareAppleRunner:be,configureProviderPortReverse:Ce})}function we(n){return Object.freeze({owner:n.owner,ownsDevice:n.ownsDevice,inspectFacts:async e=>Q(n,e),bind:async r=>{if(r.intent.kind===`exact-owner`&&!t(r.intent.owner,n.owner))throw new e(`UNSUPPORTED_OPERATION`,`WebDriver runtime owner identity does not match`);if(!n.ownsDevice(r.device))throw new e(`UNSUPPORTED_PLATFORM`,`WebDriver runtime does not own this device`);if(!$(n,r.device))throw new e(`UNSUPPORTED_OPERATION`,`The WebDriver provider session is no longer active for this device.`);return Ee(n,r.device,r.scope.signal)},shutdown:async()=>void 0})}function Te(e,t,r,i){let a={device:t,signal:r,resolveInteractor:n=>e.getInteractor?.(t,n),presentIosAcquisition:e.host.snapshot.presentIosAcquisition};return{...i.operations.captureSnapshot.available?f(a):{},...i.operations.captureScreenshot.available?v(a):{},...i.operations.focusPoint.available?d(a):{},...i.operations.typeText.available?h(a):{},...c({...a,facts:i.operations}),...i.operations.scrollDirection.available?u(a):{},...fe({...a,facts:i.operations}),...n(i.operations.tapPoint,()=>se({...a,facts:i.operations,pause:async t=>await e.host.clock.sleep(t,r)}))}}function Ee(e,t,n){let i=t.platform===`apple`?`ios-device`:`android`,a=Q(e,t),o=a.operations.deployApp,s=Object.freeze({ensureReady:async()=>({...t,booted:!0}),bootTarget:async()=>({...t,booted:!0}),...r(he({device:t,signal:n,getInteractor:(t,n)=>e.getInteractor?.(t,n)}),a.operations),...Te(e,t,n,a),networkDump:async t=>{let n=await e.host.appLogs.readRecent(t.sessionId,t.maxScanLines),{dump:r}=ue(n.text,{...t,path:n.path,exists:n.exists,lineNumberOffset:n.skippedLines,backend:i});return Object.freeze({source:`app-log`,backend:i,dump:r,notes:Object.freeze(r.entries.length===0?[`No HTTP(s) entries were found in recent session app logs.`]:[])})},...o.available&&e.deployment?{deployApp:async r=>await e.deployment.deployApp(t,r,n),materializeAppSource:async r=>await Ae(e.host,t,r,n),deployMaterializedApp:async r=>await e.deployment.deployMaterializedApp(t,r,n)}:{}});return Object.freeze({device:t,owner:e.owner,facts:a,operations:s,[Symbol.asyncDispose]:async()=>void 0})}function Z(e,t){return e?x:t}function De(e){return e.reachable?le(e.capabilities,e.operation)?x:Object.freeze({available:!1,reason:`owner-capability-missing`,hint:ce(e.capabilities,e.operation)}):e.whenUnreachable}function Q(e,t){if(!$(e,t))return b(t,e.owner,{appLog:O,appDeployment:O,network:O,screenRecording:O,screenshot:O,viewport:O,focus:O,gesture:O,scroll:O,typeText:O,touch:O,elementText:O,back:O,orientation:O,tvRemote:O,keyboard:O,clipboard:O,systemButton:O,fold:W,triggerAppEvent:O,settings:O,readAlert:O,awaitAlert:O,acceptAlert:O,dismissAlert:O,audioProbeCapture:O,audioProbeQuery:O,perf:O,lifecycle:i({resolveOpenTarget:O,prepareApplicationOpen:O,openApplication:O,applyRuntimeHints:O,clearRuntimeHints:O,closeApplication:O,finalizeApplicationClose:O,prepareAppleRunner:O,configureProviderPortReverse:O})});let n=e.deployment?.fact(t)??E,r=b(t,e.owner,{appLog:S,appDeployment:E,network:S,screenRecording:C,screenshot:A,viewport:M,focus:N,gesture:F,scroll:I,typeText:P,touch:P,elementText:R,back:z,orientation:B,tvRemote:V,keyboard:_e,clipboard:H,systemButton:U,fold:W,triggerAppEvent:q,settings:K,readAlert:G,awaitAlert:G,acceptAlert:G,dismissAlert:G,audioProbeCapture:J,audioProbeQuery:J,perf:J,lifecycle:X(t)}),c=e.getInteractor!==void 0&&ke(t),u=c&&e.snapshotAvailable!==!1?x:k,d=c&&e.screenshotAvailable!==!1?x:A,f=(t,n)=>De({reachable:c,capabilities:e.capabilities,operation:t,whenUnreachable:n});return Object.freeze({device:r.device,operations:{...r.operations,deployApp:n,materializeAppSource:n,deployMaterializedApp:n,sendPushNotification:D,appState:ye,networkDump:x,...ee({capture:u,customActions:j,withoutActiveApp:u}),...l({capture:d}),...ae({focus:Z(c,N)}),...a({type:f(`type`,P)}),...oe({unsupported:N,tap:f(`tap`,N),longPress:f(`longPress`,N),fill:f(`fill`,P),fillRef:P}),...te({unsupported:F,plan:Z(c,F),directionalFling:Z(c,F),multiTouch:Oe(t,c),targetAuthoredDrag:Z(c,F),viewport:Z(c,F)}),...ne({scroll:f(`scroll`,I)}),...re({back:f(`back`,z)}),...s({orientation:f(`orientation`,B)}),...ie({tvRemote:V}),...m({unsupported:H,read:f(`clipboard.read`,H),write:f(`clipboard.write`,H)}),...p({unsupported:U,home:f(`home`,ge),appSwitcher:f(`appSwitcher`,ve)}),setFoldPose:W,...y({triggerAppEvent:Z(c,q)}),..._({setSetting:K,readSetting:K}),...g({read:G,wait:G,accept:G,dismiss:G}),...o({setViewport:M}),ensureReady:x,bootTarget:x,bootTargetHeadless:w,listApps:T,shutdownTarget:{available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver owns the target lifecycle for provider-owned devices.`}}})}function Oe(e,t){return t?e.platform===`apple`?L:x:F}function ke(e){return e.kind===`device`&&e.target===`mobile`&&(e.platform===`android`||e.platform===`apple`&&e.appleOs===`ios`)}function $(e,t){return e.isSessionActive?.(t)??e.ownsDevice(t)}async function Ae(e,t,n,r){return t.platform===`apple`?await e.appleDeployment.prepareArtifact(n,{signal:r}):await e.androidDeployment.prepareArtifact(n,{signal:r})}export{we as createWebDriverPlatformRuntimeOwner};
|
|
1
|
+
import{A as e}from"./sdk-contracts.js";import{en as t,tn as n}from"./sdk-batch.js";import{n as r,t as i}from"./application-lifecycle-runtime.js";import{A as a,B as o,C as s,F as c,G as ee,I as te,J as l,M as u,N as ne,R as d,U as f,d as p,h as m,k as h,n as g,o as _,q as v,s as y,w as re,x as ie,z as ae}from"./alert-runtime.js";import{i as oe,n as se}from"./touch-runtime.js";import{r as b}from"./platform-runtime-unavailable.js";import{r as ce,t as le}from"./capabilities.js";import{n as ue}from"./src7.js";import{r as de}from"./gesture-admission.js";import{n as fe}from"./interactor-operation-catalog.js";import{r as pe,t as me}from"./application-lifecycle-interaction.js";function he(e){return me({owner:`WebDriver`,openTargetIdentity:`bundle-id`,closeBeforeRelaunch:!0,binding:pe({device:e.device,signal:e.signal,resolveInteractor:t=>e.getInteractor(e.device,t)})})}const x=Object.freeze({available:!0}),S=Object.freeze({available:!1,reason:`unsupported-provider-mode`}),C=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose screen recording.`}),w=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Headless boot is unavailable for provider-owned devices.`}),T=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`WebDriver provider runtimes do not expose app inventory.`}),E=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose app deployment.`}),D=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Push notifications are unavailable for WebDriver provider-owned devices.`}),O=Object.freeze({available:!1,reason:`owner-capability-missing`,hint:`The WebDriver provider session is no longer active for this device.`}),k=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose snapshot capture for this device.`}),A=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose screenshot capture for this device.`}),j=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose iOS simulator custom snapshot actions.`}),M=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose viewport resizing.`}),N=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose focus for this device.`}),P=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose text entry for this device.`}),F=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose gestures for this device.`}),I=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose scrolling for this device.`}),L=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:de}),R=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes read element text from the captured tree only.`}),z=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose back for this device.`}),ge=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose home for this device.`}),B=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose orientation for this device.`}),V=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose tv-remote.`}),_e=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose keyboard actions.`}),H=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose clipboard access for this device.`}),ve=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose the app switcher for this device.`}),U=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`No WebDriver backend presses this system button.`}),W=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`fold runs a HID helper through simctl spawn inside a foldable iPhone simulator on the daemon host; a WebDriver backend has no such simulator.`}),G=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose native alert handling.`}),K=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose device settings.`}),q=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose app-event delivery for this device.`}),ye=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose a foreground app-state operation.`}),J=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`This WebDriver provider runtime does not expose the audio probe.`}),be=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Apple runner preparation is unavailable for WebDriver-owned devices.`}),xe=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver open is supported only for its owned iOS or Android mobile-device sessions.`}),Se=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver close is supported only for its owned iOS or Android mobile-device sessions.`}),Y=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`Runtime hints are not applied to provider-owned devices.`}),Ce=Object.freeze({available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver provider runtimes do not expose port reverse.`});function X(e){let t=e.platform===`android`&&e.kind===`device`&&e.target===`mobile`||e.platform===`apple`&&e.kind===`device`&&e.target===`mobile`&&e.appleOs===`ios`,n=t?x:xe,r=t?x:Se;return i({resolveOpenTarget:n,prepareApplicationOpen:n,openApplication:n,applyRuntimeHints:Y,clearRuntimeHints:Y,closeApplication:r,finalizeApplicationClose:r,prepareAppleRunner:be,configureProviderPortReverse:Ce})}function we(n){return Object.freeze({owner:n.owner,ownsDevice:n.ownsDevice,inspectFacts:async e=>Q(n,e),bind:async r=>{if(r.intent.kind===`exact-owner`&&!t(r.intent.owner,n.owner))throw new e(`UNSUPPORTED_OPERATION`,`WebDriver runtime owner identity does not match`);if(!n.ownsDevice(r.device))throw new e(`UNSUPPORTED_PLATFORM`,`WebDriver runtime does not own this device`);if(!$(n,r.device))throw new e(`UNSUPPORTED_OPERATION`,`The WebDriver provider session is no longer active for this device.`);return Ee(n,r.device,r.scope.signal)},shutdown:async()=>void 0})}function Te(e,t,r,i){let a={device:t,signal:r,resolveInteractor:n=>e.getInteractor?.(t,n),presentIosAcquisition:e.host.snapshot.presentIosAcquisition};return{...i.operations.captureSnapshot.available?f(a):{},...i.operations.captureScreenshot.available?v(a):{},...i.operations.focusPoint.available?d(a):{},...i.operations.typeText.available?h(a):{},...c({...a,facts:i.operations}),...i.operations.scrollDirection.available?u(a):{},...fe({...a,facts:i.operations}),...n(i.operations.tapPoint,()=>se({...a,facts:i.operations,pause:async t=>await e.host.clock.sleep(t,r)}))}}function Ee(e,t,n){let i=t.platform===`apple`?`ios-device`:`android`,a=Q(e,t),o=a.operations.deployApp,s=Object.freeze({ensureReady:async()=>({...t,booted:!0}),bootTarget:async()=>({...t,booted:!0}),...r(he({device:t,signal:n,getInteractor:(t,n)=>e.getInteractor?.(t,n)}),a.operations),...Te(e,t,n,a),networkDump:async t=>{let n=await e.host.appLogs.readRecent(t.sessionId,t.maxScanLines),{dump:r}=ue(n.text,{...t,path:n.path,exists:n.exists,lineNumberOffset:n.skippedLines,backend:i});return Object.freeze({source:`app-log`,backend:i,dump:r,notes:Object.freeze(r.entries.length===0?[`No HTTP(s) entries were found in recent session app logs.`]:[])})},...o.available&&e.deployment?{deployApp:async r=>await e.deployment.deployApp(t,r,n),materializeAppSource:async r=>await Ae(e.host,t,r,n),deployMaterializedApp:async r=>await e.deployment.deployMaterializedApp(t,r,n)}:{}});return Object.freeze({device:t,owner:e.owner,facts:a,operations:s,[Symbol.asyncDispose]:async()=>void 0})}function Z(e,t){return e?x:t}function De(e){return e.reachable?le(e.capabilities,e.operation)?x:Object.freeze({available:!1,reason:`owner-capability-missing`,hint:ce(e.capabilities,e.operation)}):e.whenUnreachable}function Q(e,t){if(!$(e,t))return b(t,e.owner,{appLog:O,appDeployment:O,network:O,screenRecording:O,screenshot:O,viewport:O,focus:O,gesture:O,scroll:O,typeText:O,touch:O,elementText:O,back:O,orientation:O,tvRemote:O,keyboard:O,clipboard:O,systemButton:O,fold:W,triggerAppEvent:O,settings:O,readAlert:O,awaitAlert:O,acceptAlert:O,dismissAlert:O,audioProbeCapture:O,audioProbeQuery:O,perf:O,lifecycle:i({resolveOpenTarget:O,prepareApplicationOpen:O,openApplication:O,applyRuntimeHints:O,clearRuntimeHints:O,closeApplication:O,finalizeApplicationClose:O,prepareAppleRunner:O,configureProviderPortReverse:O})});let n=e.deployment?.fact(t)??E,r=b(t,e.owner,{appLog:S,appDeployment:E,network:S,screenRecording:C,screenshot:A,viewport:M,focus:N,gesture:F,scroll:I,typeText:P,touch:P,elementText:R,back:z,orientation:B,tvRemote:V,keyboard:_e,clipboard:H,systemButton:U,fold:W,triggerAppEvent:q,settings:K,readAlert:G,awaitAlert:G,acceptAlert:G,dismissAlert:G,audioProbeCapture:J,audioProbeQuery:J,perf:J,lifecycle:X(t)}),c=e.getInteractor!==void 0&&ke(t),u=c&&e.snapshotAvailable!==!1?x:k,d=c&&e.screenshotAvailable!==!1?x:A,f=(t,n)=>De({reachable:c,capabilities:e.capabilities,operation:t,whenUnreachable:n});return Object.freeze({device:r.device,operations:{...r.operations,deployApp:n,materializeAppSource:n,deployMaterializedApp:n,sendPushNotification:D,appState:ye,networkDump:x,...ee({capture:u,customActions:j,withoutActiveApp:u}),...l({capture:d}),...ae({focus:Z(c,N)}),...a({type:f(`type`,P)}),...oe({unsupported:N,tap:f(`tap`,N),longPress:f(`longPress`,N),fill:f(`fill`,P),fillRef:P}),...te({unsupported:F,plan:Z(c,F),directionalFling:Z(c,F),multiTouch:Oe(t,c),targetAuthoredDrag:Z(c,F),viewport:Z(c,F)}),...ne({scroll:f(`scroll`,I)}),...re({back:f(`back`,z)}),...s({orientation:f(`orientation`,B)}),...ie({tvRemote:V}),...m({unsupported:H,read:f(`clipboard.read`,H),write:f(`clipboard.write`,H)}),...p({unsupported:U,home:f(`home`,ge),appSwitcher:f(`appSwitcher`,ve)}),setFoldPose:W,...y({triggerAppEvent:Z(c,q)}),..._({setSetting:K,readSetting:K}),...g({read:G,wait:G,accept:G,dismiss:G}),...o({setViewport:M}),ensureReady:x,bootTarget:x,bootTargetHeadless:w,listApps:T,shutdownTarget:{available:!1,reason:`unsupported-provider-mode`,hint:`WebDriver owns the target lifecycle for provider-owned devices.`}}})}function Oe(e,t){return t?e.platform===`apple`?L:x:F}function ke(e){return e.kind===`device`&&e.target===`mobile`&&(e.platform===`android`||e.platform===`apple`&&e.appleOs===`ios`)}function $(e,t){return e.isSessionActive?.(t)??e.ownsDevice(t)}async function Ae(e,t,n,r){return t.platform===`apple`?await e.appleDeployment.prepareArtifact(n,{signal:r}):await e.androidDeployment.prepareArtifact(n,{signal:r})}export{we as createWebDriverPlatformRuntimeOwner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{A as t}from"./sdk-contracts.js";import{r as n,t as r}from"./png.js";import{t as i}from"./png-encode.js";import a from"node:zlib";const o=[137,80,78,71,13,10,26,10],s=[`IHDR`,`PLTE`,`IDAT`,`IEND`],c=/^[A-Za-z]{4}$/;function l(e){return!c.test(e)||e[0]<=`Z`&&!s.includes(e)}function u(e){return o.every((t,n)=>e[n]===t)}function d(e){if(e.length<33||!u(e))return null;let t=Buffer.from(e.buffer,e.byteOffset,e.byteLength);if(t.readUInt32BE(8)!==13||t.toString(`ascii`,12,16)!==`IHDR`)return null;let n=t.subarray(12,29);return t.readUInt32BE(29)===a.crc32(n)>>>0?{width:t.readUInt32BE(16),height:t.readUInt32BE(20),bitDepth:e[24],colorType:e[25],compressionMethod:e[26],filterMethod:e[27],interlace:e[28]}:null}function f(e){return e===2?3:e===6?4:null}function p(e){if(!u(e))return null;let t=Buffer.from(e.buffer,e.byteOffset,e.byteLength),n=[],r=8;for(;r+12<=e.length;){let i=t.readUInt32BE(r);if(i>2147483647||r+12+i>e.length)return null;let o=t.subarray(r+4,r+8+i);if(t.readUInt32BE(r+8+i)!==a.crc32(o)>>>0)return null;let s=t.toString(`ascii`,r+4,r+8);if(l(s))return null;if(n.push({type:s,data:t.subarray(r+8,r+8+i)}),s===`IEND`)return r+12+i===e.length?n:null;r+=12+i}return null}const m=[0,1,2,3,4];function h(e,t,n,r){switch(e){case 1:return t;case 2:return n;case 3:return t+n>>1;case 4:return g(t,n,r);default:return 0}}function g(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}function _(e,t){return e+t&255}function v(e){let t=d(e);return t===null||t.bitDepth!==8||t.compressionMethod!==0||t.filterMethod!==0||t.interlace!==0||f(t.colorType)===null?null:t}function y(e,t,n){let r=f(t.colorType);if(r===null)return null;let i=D(e);if(i===null)return null;let a=t.width*r,o=t.height*(a+1),s=E(i,o);if(s===null||s.length<o)return null;for(let e=0;e<n.y+n.height;e+=1)if(!b(s,e,a,r))return null;if(!C(s,n.y+n.height,t.height,a))return null;let c=r===4&&!w(s,n,a)?4:3;return{width:n.width,height:n.height,channels:c,pixels:T(s,n,a,r,c)}}function b(e,t,n,r){let i=t*(n+1)+1,a=e[i-1];return m.includes(a)?a===0?!0:t===0?x(e,i,n,r,a):S(e,i,n,r,a):!1}function x(e,t,n,r,i){let a=t+n;if(i===1||i===4){for(let n=t+r;n<a;n+=1)e[n]=_(e[n],e[n-r]);return!0}for(let n=t;n<a;n+=1){let a=n>=t+r?e[n-r]:0;e[n]=_(e[n],h(i,a,0,0))}return!0}function S(e,t,n,r,i){let a=t+n,o=t-(n+1);if(i===1){for(let n=t+r;n<a;n+=1)e[n]=_(e[n],e[n-r]);return!0}if(i===2){for(let n=t;n<a;n+=1)e[n]=_(e[n],e[o+(n-t)]);return!0}for(let n=t;n<a;n+=1){let a=n-t,s=n>=t+r?e[n-r]:0;e[n]=_(e[n],h(i,s,e[o+a],n>=t+r?e[o+a-r]:0))}return!0}function C(e,t,n,r){for(let i=t;i<n;i+=1)if(!m.includes(e[i*(r+1)]))return!1;return!0}function w(e,t,n){let r=255;for(let i=t.y;i<t.y+t.height&&r===255;i+=1){let a=i*(n+1)+4;for(let n=0;n<t.width;n+=1)r&=e[a+(t.x+n)*4]}return r===255}function T(e,t,n,r,i){let a=t.width*i,o=new Uint8Array(t.height*a);for(let s=0;s<t.height;s+=1){let c=(s+t.y)*(n+1)+1+t.x*r,l=s*a;if(r===i)o.set(e.subarray(c,c+t.width*r),l);else for(let n=0;n<t.width;n+=1){let t=c+n*r,a=l+n*i;o[a]=e[t],o[a+1]=e[t+1],o[a+2]=e[t+2]}}return o}function E(e,t){try{return a.inflateSync(e,{maxOutputLength:t})}catch{return null}}function D(e){let t=p(e);if(t===null)return null;let n=[];for(let e of t){if(e.type===`PLTE`||e.type===`tRNS`)return null;e.type===`IDAT`&&n.push(e.data)}return n.length===0?null:Buffer.concat(n)}var O=e({cropPngBytes:()=>k});function k(e,t,n){let r=v(e);if(r!==null&&!N(t,r.width,r.height)){M(t,r.width,r.height);let n=y(e,r,t);if(n!==null)return i(n.pixels,n.width,n.height,n.channels)}return A(e,t,n)}function A(e,t,i){let a=r(e,i);return M(t,a.width,a.height),N(t,a.width,a.height)?null:n.PNG.sync.write(j(a,t))}function j(e,t){let r=new n.PNG({width:t.width,height:t.height});for(let n=0;n<t.height;n+=1){let i=((n+t.y)*e.width+t.x)*4;e.data.copy(r.data,n*r.width*4,i,i+t.width*4)}return r}function M(e,n,r){if(e.x+e.width>n||e.y+e.height>r)throw new t(`INVALID_ARGS`,`Screenshot crop box ${e.width}x${e.height} at (${e.x}, ${e.y}) exceeds the ${n}x${r} image`)}function N(e,t,n){return e.x===0&&e.y===0&&e.width===t&&e.height===n}export{O as n,k as t};
|
package/dist/src/png-size.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as e}from"./sdk-contracts.js";import{promises as t}from"node:fs";async function n(n){let r=await t.open(n,`r`);try{let t=Buffer.alloc(24),{bytesRead:n}=await r.read(t,0,t.length,0);if(n<t.length||t.toString(`ascii`,12,16)!==`IHDR`)throw new e(`COMMAND_FAILED`,`Screenshot file is not a valid PNG`);return{width:t.readUInt32BE(16),height:t.readUInt32BE(20)}}finally{await r.close()}}export{n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{A as t,q as n}from"./sdk-contracts.js";import{r}from"./diagnostics.js";import"./diagnostics2.js";import{n as i,r as a,t as o}from"./png.js";import{n as s,r as c,t as l}from"./png-worker-contract.js";import u from"node:path";import d from"node:fs";import{fileURLToPath as f}from"node:url";import{Worker as p}from"node:worker_threads";function m(e,t){try{let n=f(e),r=u.extname(n)||`.js`;return[u.join(u.dirname(n),`${t}${r}`),u.join(u.dirname(n),`internal`,`${t}${r}`)].find(e=>d.existsSync(e))??null}catch{return null}}var h=e({computePngRgbDifferenceAsync:()=>L,computeScreenshotDiffPixelsAsync:()=>R,cropPngBytesAsync:()=>I,decodePngAsync:()=>M,decodeScreenshotImageAsync:()=>N,encodePngAsync:()=>F,prewarmPngWorker:()=>A,terminatePngWorker:()=>j,transcodeScreenshotToPngAsync:()=>z}),g=class extends Error{};let _=null,v=!1,y=!1,b=0;const x=new Map;function S(e){v=!0,!y&&(y=!0,r({level:`warn`,phase:`png_worker_unavailable`,data:{reason:e}}),process.emitWarning(`PNG worker unavailable, falling back to in-process PNG processing: ${e}`))}function C(e){let r=x.get(e.id);r&&(x.delete(e.id),E(),e.ok?r.resolve(e.result):r.reject(new t(n(e.error.code),e.error.message,e.error.details)))}function w(e,t){_===e&&(S(t.message),_=null,e.terminate().catch(()=>{}),T(new g(`PNG worker failed: ${t.message}`)))}function T(e){let t=[...x.values()];x.clear();for(let n of t)n.reject(e)}function E(){_&&(x.size>0?_.ref():_.unref())}function D(){if(v)return null;if(_)return _;let e=m(import.meta.url,`png-worker`);if(!e)return S(`worker entry module not found next to the current module`),null;try{let t=new p(e,{execArgv:e.endsWith(`.ts`)?[`--experimental-strip-types`]:[]});return t.on(`message`,C),t.on(`error`,e=>{w(t,e)}),t.on(`exit`,e=>{w(t,Error(`PNG worker exited with code ${e}`))}),t.unref(),_=t,t}catch(e){return S(`failed to spawn worker: ${e instanceof Error?e.message:String(e)}`),null}}function O(e){let t=D();if(!t)return Promise.reject(new g(`PNG worker is unavailable`));b+=1;let n=b;return new Promise((r,i)=>{x.set(n,{resolve:r,reject:i}),E();try{t.postMessage({...e,id:n})}catch(e){x.delete(n),E(),i(new g(`failed to post job to PNG worker: ${e instanceof Error?e.message:String(e)}`))}})}async function k(e,t){try{return await O(e)}catch(e){if(e instanceof g)return await t();throw e}}function A(){D()}async function j(){let e=_;_=null,T(new g(`PNG worker terminated`)),e&&await e.terminate()}async function M(e,t){return P(await k({kind:`decode`,png:e,label:t},()=>{let n=o(e,t);return{kind:`decode`,width:n.width,height:n.height,data:n.data}}))}async function N(e,t){return P(await k({kind:`decode-image`,image:e,label:t},async()=>{let{decodeScreenshotImage:n}=await import(`./screenshot-image.js`),r=n(e,t);return{kind:`decode-image`,width:r.width,height:r.height,data:r.data}}))}function P(e){let t=new a.PNG({width:e.width,height:e.height});return t.data=l(e.data),t}async function F(e){let t=await k({kind:`encode`,width:e.width,height:e.height,data:e.data},()=>({kind:`encode`,png:a.PNG.sync.write(e)}));return l(t.png)}async function I(e,t,n){let r=await k({kind:`crop`,png:e,label:n,box:t},async()=>{let{cropPngBytes:r}=await import(`./png-crop-bytes.js`).then(e=>e.n);return{kind:`crop`,png:r(e,t,n)}});return r.png===null?null:l(r.png)}async function L(e,t,n){let{kind:r,...i}=await k({kind:`rgb-difference`,firstPng:e,secondPng:t,label:n},()=>({kind:`rgb-difference`,...s(o(e,n),o(t,n))}));return i}async function R(e){let{kind:t,...n}=await k({kind:`diff-pixels`,...e},()=>({kind:`diff-pixels`,...c(e)}));return{...n,diffData:l(n.diffData)}}async function z(e,t){if(i(e))return e;let n=await k({kind:`jpeg-to-png`,image:e,label:t},async()=>{let{transcodeScreenshotToPng:n}=await import(`./screenshot-image.js`);return{kind:`jpeg-to-png`,png:n(e,t)}});return l(n.png)}export{N as a,A as c,M as i,j as l,R as n,F as o,I as r,h as s,L as t};
|
package/dist/src/png.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./rolldown-runtime.js";import{D as n}from"./sdk-contracts.js";var r=t(((t,n)=>{let r=e(`util`),i=e(`stream`),a=n.exports=function(){i.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding=`utf8`,this.writable=!0};r.inherits(a,i),a.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t}),process.nextTick(function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit(`drain`))}.bind(this))},a.prototype.write=function(e,t){if(!this.writable)return this.emit(`error`,Error(`Stream not writable`)),!1;let n;return n=Buffer.isBuffer(e)?e:Buffer.from(e,t||this._encoding),this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&this._reads.length===0&&(this._paused=!0),this.writable&&!this._paused},a.prototype.end=function(e,t){e&&this.write(e,t),this.writable=!1,this._buffers&&(this._buffers.length===0?this._end():(this._buffers.push(null),this._process()))},a.prototype.destroySoon=a.prototype.end,a.prototype._end=function(){this._reads.length>0&&this.emit(`error`,Error(`Unexpected end of input`)),this.destroy()},a.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit(`close`))},a.prototype._processReadAllowingLess=function(e){this._reads.shift();let t=this._buffers[0];t.length>e.length?(this._buffered-=e.length,this._buffers[0]=t.slice(e.length),e.func.call(this,t.slice(0,e.length))):(this._buffered-=t.length,this._buffers.shift(),e.func.call(this,t))},a.prototype._processRead=function(e){this._reads.shift();let t=0,n=0,r=Buffer.alloc(e.length);for(;t<e.length;){let i=this._buffers[n++],a=Math.min(i.length,e.length-t);i.copy(r,t,0,a),t+=a,a!==i.length&&(this._buffers[--n]=i.slice(a))}n>0&&this._buffers.splice(0,n),this._buffered-=e.length,e.func.call(this,r)},a.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let e=this._reads[0];if(e.allowLess)this._processReadAllowingLess(e);else if(this._buffered>=e.length)this._processRead(e);else break}this._buffers&&!this.writable&&this._end()}catch(e){this.emit(`error`,e)}}})),i=t((e=>{let t=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];e.getImagePasses=function(e,n){let r=[],i=e%8,a=n%8,o=(e-i)/8,s=(n-a)/8;for(let e=0;e<t.length;e++){let n=t[e],c=o*n.x.length,l=s*n.y.length;for(let e=0;e<n.x.length&&n.x[e]<i;e++)c++;for(let e=0;e<n.y.length&&n.y[e]<a;e++)l++;c>0&&l>0&&r.push({width:c,height:l,index:e})}return r},e.getInterlaceIterator=function(e){return function(n,r,i){let a=n%t[i].x.length,o=(n-a)/t[i].x.length*8+t[i].x[a],s=r%t[i].y.length,c=(r-s)/t[i].y.length*8+t[i].y[s];return o*4+c*e*4}}})),a=t(((e,t)=>{t.exports=function(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}})),o=t(((e,t)=>{let n=i(),r=a();function o(e,t,n){let r=e*t;return n!==8&&(r=Math.ceil(r/(8/n))),r}let s=t.exports=function(e,t){let r=e.width,i=e.height,a=e.interlace,s=e.bpp,c=e.depth;if(this.read=t.read,this.write=t.write,this.complete=t.complete,this._imageIndex=0,this._images=[],a){let e=n.getImagePasses(r,i);for(let t=0;t<e.length;t++)this._images.push({byteWidth:o(e[t].width,s,c),height:e[t].height,lineIndex:0})}else this._images.push({byteWidth:o(r,s,c),height:i,lineIndex:0});this._xComparison=c===8?s:c===16?s*2:1};s.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},s.prototype._unFilterType1=function(e,t,n){let r=this._xComparison,i=r-1;for(let a=0;a<n;a++){let n=e[1+a],o=a>i?t[a-r]:0;t[a]=n+o}},s.prototype._unFilterType2=function(e,t,n){let r=this._lastLine;for(let i=0;i<n;i++){let n=e[1+i],a=r?r[i]:0;t[i]=n+a}},s.prototype._unFilterType3=function(e,t,n){let r=this._xComparison,i=r-1,a=this._lastLine;for(let o=0;o<n;o++){let n=e[1+o],s=a?a[o]:0,c=o>i?t[o-r]:0,l=Math.floor((c+s)/2);t[o]=n+l}},s.prototype._unFilterType4=function(e,t,n){let i=this._xComparison,a=i-1,o=this._lastLine;for(let s=0;s<n;s++){let n=e[1+s],c=o?o[s]:0,l=s>a?t[s-i]:0,u=s>a&&o?o[s-i]:0,d=r(l,c,u);t[s]=n+d}},s.prototype._reverseFilterLine=function(e){let t=e[0],n,r=this._images[this._imageIndex],i=r.byteWidth;if(t===0)n=e.slice(1,i+1);else switch(n=Buffer.alloc(i),t){case 1:this._unFilterType1(e,n,i);break;case 2:this._unFilterType2(e,n,i);break;case 3:this._unFilterType3(e,n,i);break;case 4:this._unFilterType4(e,n,i);break;default:throw Error(`Unrecognised filter type - `+t)}this.write(n),r.lineIndex++,r.lineIndex>=r.height?(this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex]):this._lastLine=n,r?this.read(r.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}})),s=t(((t,n)=>{let i=e(`util`),a=r(),s=o(),c=n.exports=function(e){a.call(this);let t=[],n=this;this._filter=new s(e,{read:this.read.bind(this),write:function(e){t.push(e)},complete:function(){n.emit(`complete`,Buffer.concat(t))}}),this._filter.start()};i.inherits(c,a)})),c=t(((e,t)=>{t.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}})),l=t(((e,t)=>{let n=[];(function(){for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t>>>=1;n[e]=t}})();let r=t.exports=function(){this._crc=-1};r.prototype.write=function(e){for(let t=0;t<e.length;t++)this._crc=n[(this._crc^e[t])&255]^this._crc>>>8;return!0},r.prototype.crc32=function(){return this._crc^-1},r.crc32=function(e){let t=-1;for(let r=0;r<e.length;r++)t=n[(t^e[r])&255]^t>>>8;return t^-1}})),u=t(((e,t)=>{let n=c(),r=l(),i=t.exports=function(e,t){this._options=e,e.checkCRC=e.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[n.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[n.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[n.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[n.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[n.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[n.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=t.read,this.error=t.error,this.metadata=t.metadata,this.gamma=t.gamma,this.transColor=t.transColor,this.palette=t.palette,this.parsed=t.parsed,this.inflateData=t.inflateData,this.finished=t.finished,this.simpleTransparency=t.simpleTransparency,this.headersFinished=t.headersFinished||function(){}};i.prototype.start=function(){this.read(n.PNG_SIGNATURE.length,this._parseSignature.bind(this))},i.prototype._parseSignature=function(e){let t=n.PNG_SIGNATURE;for(let n=0;n<t.length;n++)if(e[n]!==t[n]){this.error(Error(`Invalid file signature`));return}this.read(8,this._parseChunkBegin.bind(this))},i.prototype._parseChunkBegin=function(e){let t=e.readUInt32BE(0),i=e.readUInt32BE(4),a=``;for(let t=4;t<8;t++)a+=String.fromCharCode(e[t]);let o=!!(e[4]&32);if(!this._hasIHDR&&i!==n.TYPE_IHDR){this.error(Error(`Expected IHDR on beggining`));return}if(this._crc=new r,this._crc.write(Buffer.from(a)),this._chunks[i])return this._chunks[i](t);if(!o){this.error(Error(`Unsupported critical chunk type `+a));return}this.read(t+4,this._skipChunk.bind(this))},i.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))},i.prototype._parseChunkEnd=function(e){let t=e.readInt32BE(0),n=this._crc.crc32();if(this._options.checkCRC&&n!==t){this.error(Error(`Crc error - `+t+` - `+n));return}this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleIHDR=function(e){this.read(e,this._parseIHDR.bind(this))},i.prototype._parseIHDR=function(e){this._crc.write(e);let t=e.readUInt32BE(0),r=e.readUInt32BE(4),i=e[8],a=e[9],o=e[10],s=e[11],c=e[12];if(i!==8&&i!==4&&i!==2&&i!==1&&i!==16){this.error(Error(`Unsupported bit depth `+i));return}if(!(a in n.COLORTYPE_TO_BPP_MAP)){this.error(Error(`Unsupported color type`));return}if(o!==0){this.error(Error(`Unsupported compression method`));return}if(s!==0){this.error(Error(`Unsupported filter method`));return}if(c!==0&&c!==1){this.error(Error(`Unsupported interlace method`));return}this._colorType=a;let l=n.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:t,height:r,depth:i,interlace:!!c,palette:!!(a&n.COLORTYPE_PALETTE),color:!!(a&n.COLORTYPE_COLOR),alpha:!!(a&n.COLORTYPE_ALPHA),bpp:l,colorType:a}),this._handleChunkEnd()},i.prototype._handlePLTE=function(e){this.read(e,this._parsePLTE.bind(this))},i.prototype._parsePLTE=function(e){this._crc.write(e);let t=Math.floor(e.length/3);for(let n=0;n<t;n++)this._palette.push([e[n*3],e[n*3+1],e[n*3+2],255]);this.palette(this._palette),this._handleChunkEnd()},i.prototype._handleTRNS=function(e){this.simpleTransparency(),this.read(e,this._parseTRNS.bind(this))},i.prototype._parseTRNS=function(e){if(this._crc.write(e),this._colorType===n.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(Error(`Transparency chunk must be after palette`));return}if(e.length>this._palette.length){this.error(Error(`More transparent colors than palette size`));return}for(let t=0;t<e.length;t++)this._palette[t][3]=e[t];this.palette(this._palette)}this._colorType===n.COLORTYPE_GRAYSCALE&&this.transColor([e.readUInt16BE(0)]),this._colorType===n.COLORTYPE_COLOR&&this.transColor([e.readUInt16BE(0),e.readUInt16BE(2),e.readUInt16BE(4)]),this._handleChunkEnd()},i.prototype._handleGAMA=function(e){this.read(e,this._parseGAMA.bind(this))},i.prototype._parseGAMA=function(e){this._crc.write(e),this.gamma(e.readUInt32BE(0)/n.GAMMA_DIVISION),this._handleChunkEnd()},i.prototype._handleIDAT=function(e){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-e,this._parseIDAT.bind(this,e))},i.prototype._parseIDAT=function(e,t){if(this._crc.write(t),this._colorType===n.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw Error(`Expected palette not found`);this.inflateData(t);let r=e-t.length;r>0?this._handleIDAT(r):this._handleChunkEnd()},i.prototype._handleIEND=function(e){this.read(e,this._parseIEND.bind(this))},i.prototype._parseIEND=function(e){this._crc.write(e),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}})),d=t((e=>{let t=i(),n=[function(){},function(e,t,n,r){if(r===t.length)throw Error(`Ran out of data`);let i=t[r];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=255},function(e,t,n,r){if(r+1>=t.length)throw Error(`Ran out of data`);let i=t[r];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=t[r+1]},function(e,t,n,r){if(r+2>=t.length)throw Error(`Ran out of data`);e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=255},function(e,t,n,r){if(r+3>=t.length)throw Error(`Ran out of data`);e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=t[r+3]}],r=[function(){},function(e,t,n,r){let i=t[0];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=r},function(e,t,n){let r=t[0];e[n]=r,e[n+1]=r,e[n+2]=r,e[n+3]=t[1]},function(e,t,n,r){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=r},function(e,t,n){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=t[3]}];function a(e,t){let n=[],r=0;function i(){if(r===e.length)throw Error(`Ran out of data`);let i=e[r];r++;let a,o,s,c,l,u,d,f;switch(t){default:throw Error(`unrecognised depth`);case 16:d=e[r],r++,n.push((i<<8)+d);break;case 4:d=i&15,f=i>>4,n.push(f,d);break;case 2:l=i&3,u=i>>2&3,d=i>>4&3,f=i>>6&3,n.push(f,d,u,l);break;case 1:a=i&1,o=i>>1&1,s=i>>2&1,c=i>>3&1,l=i>>4&1,u=i>>5&1,d=i>>6&1,f=i>>7&1,n.push(f,d,u,l,c,s,o,a)}}return{get:function(e){for(;n.length<e;)i();let t=n.slice(0,e);return n=n.slice(e),t},resetAfterLine:function(){n.length=0},end:function(){if(r!==e.length)throw Error(`extra data found`)}}}function o(e,t,r,i,a,o){let s=e.width,c=e.height,l=e.index;for(let e=0;e<c;e++)for(let c=0;c<s;c++){let s=r(c,e,l);n[i](t,a,s,o),o+=i}return o}function s(e,t,n,i,a,o){let s=e.width,c=e.height,l=e.index;for(let e=0;e<c;e++){for(let c=0;c<s;c++){let s=a.get(i),u=n(c,e,l);r[i](t,s,u,o)}a.resetAfterLine()}}e.dataToBitMap=function(e,n){let r=n.width,i=n.height,c=n.depth,l=n.bpp,u=n.interlace,d;c!==8&&(d=a(e,c));let f;f=c<=8?Buffer.alloc(r*i*4):new Uint16Array(r*i*4);let p=2**c-1,m=0,h,g;if(u)h=t.getImagePasses(r,i),g=t.getInterlaceIterator(r,i);else{let e=0;g=function(){let t=e;return e+=4,t},h=[{width:r,height:i}]}for(let t=0;t<h.length;t++)c===8?m=o(h[t],f,g,l,e,m):s(h[t],f,g,l,d,p);if(c===8){if(m!==e.length)throw Error(`extra data found`)}else d.end();return f}})),f=t(((e,t)=>{function n(e,t,n,r,i){let a=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){let n=i[e[a]];if(!n)throw Error(`index `+e[a]+` not in palette`);for(let e=0;e<4;e++)t[a+e]=n[e];a+=4}}function r(e,t,n,r,i){let a=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){let n=!1;if(i.length===1?i[0]===e[a]&&(n=!0):i[0]===e[a]&&i[1]===e[a+1]&&i[2]===e[a+2]&&(n=!0),n)for(let e=0;e<4;e++)t[a+e]=0;a+=4}}function i(e,t,n,r,i){let a=2**i-1,o=0;for(let i=0;i<r;i++)for(let r=0;r<n;r++){for(let n=0;n<4;n++)t[o+n]=Math.floor(e[o+n]*255/a+.5);o+=4}}t.exports=function(e,t,a=!1){let o=t.depth,s=t.width,c=t.height,l=t.colorType,u=t.transColor,d=t.palette,f=e;return l===3?n(e,f,s,c,d):(u&&r(e,f,s,c,u),o!==8&&!a&&(o===16&&(f=Buffer.alloc(s*c*4)),i(e,f,s,c,o))),f}})),p=t(((t,n)=>{let i=e(`util`),a=e(`zlib`),o=r(),c=s(),l=u(),p=d(),m=f(),h=n.exports=function(e){o.call(this),this._parser=new l(e,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,`gamma`),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=e,this.writable=!0,this._parser.start()};i.inherits(h,o),h.prototype._handleError=function(e){this.emit(`error`,e),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on(`error`,function(){})),this.errord=!0},h.prototype._inflateData=function(e){if(!this._inflate){if(this._bitmapInfo.interlace)this._inflate=a.createInflate(),this._inflate.on(`error`,this.emit.bind(this,`error`)),this._filter.on(`complete`,this._complete.bind(this)),this._inflate.pipe(this._filter);else{let e=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,t=Math.max(e,a.Z_MIN_CHUNK);this._inflate=a.createInflate({chunkSize:t});let n=e,r=this.emit.bind(this,`error`);this._inflate.on(`error`,function(e){n&&r(e)}),this._filter.on(`complete`,this._complete.bind(this));let i=this._filter.write.bind(this._filter);this._inflate.on(`data`,function(e){n&&(e.length>n&&(e=e.slice(0,n)),n-=e.length,i(e))}),this._inflate.on(`end`,this._filter.end.bind(this._filter))}}this._inflate.write(e)},h.prototype._handleMetaData=function(e){this._metaData=e,this._bitmapInfo=Object.create(e),this._filter=new c(this._bitmapInfo)},h.prototype._handleTransColor=function(e){this._bitmapInfo.transColor=e},h.prototype._handlePalette=function(e){this._bitmapInfo.palette=e},h.prototype._simpleTransparency=function(){this._metaData.alpha=!0},h.prototype._headersFinished=function(){this.emit(`metadata`,this._metaData)},h.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit(`error`,`No Inflate block`))},h.prototype._complete=function(e){if(this.errord)return;let t;try{let n=p.dataToBitMap(e,this._bitmapInfo);t=m(n,this._bitmapInfo,this._options.skipRescale),n=null}catch(e){this._handleError(e);return}this.emit(`parsed`,t)}})),m=t(((e,t)=>{let n=c();t.exports=function(e,t,r,i){let a=[n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(i.colorType)!==-1;if(i.colorType===i.inputColorType){let t=(function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]!==256})();if(i.bitDepth===8||i.bitDepth===16&&t)return e}let o=i.bitDepth===16?new Uint16Array(e.buffer):e,s=255,c=n.COLORTYPE_TO_BPP_MAP[i.inputColorType];c===4&&!i.inputHasAlpha&&(c=3);let l=n.COLORTYPE_TO_BPP_MAP[i.colorType];i.bitDepth===16&&(s=65535,l*=2);let u=Buffer.alloc(t*r*l),d=0,f=0,p=i.bgColor||{};p.red===void 0&&(p.red=s),p.green===void 0&&(p.green=s),p.blue===void 0&&(p.blue=s);function m(){let e,t,r,c=s;switch(i.inputColorType){case n.COLORTYPE_COLOR_ALPHA:c=o[d+3],e=o[d],t=o[d+1],r=o[d+2];break;case n.COLORTYPE_COLOR:e=o[d],t=o[d+1],r=o[d+2];break;case n.COLORTYPE_ALPHA:c=o[d+1],e=o[d],t=e,r=e;break;case n.COLORTYPE_GRAYSCALE:e=o[d],t=e,r=e;break;default:throw Error(`input color type:`+i.inputColorType+` is not supported at present`)}return i.inputHasAlpha&&(a||(c/=s,e=Math.min(Math.max(Math.round((1-c)*p.red+c*e),0),s),t=Math.min(Math.max(Math.round((1-c)*p.green+c*t),0),s),r=Math.min(Math.max(Math.round((1-c)*p.blue+c*r),0),s))),{red:e,green:t,blue:r,alpha:c}}for(let e=0;e<r;e++)for(let e=0;e<t;e++){let e=m(o,d);switch(i.colorType){case n.COLORTYPE_COLOR_ALPHA:case n.COLORTYPE_COLOR:i.bitDepth===8?(u[f]=e.red,u[f+1]=e.green,u[f+2]=e.blue,a&&(u[f+3]=e.alpha)):(u.writeUInt16BE(e.red,f),u.writeUInt16BE(e.green,f+2),u.writeUInt16BE(e.blue,f+4),a&&u.writeUInt16BE(e.alpha,f+6));break;case n.COLORTYPE_ALPHA:case n.COLORTYPE_GRAYSCALE:{let t=(e.red+e.green+e.blue)/3;i.bitDepth===8?(u[f]=t,a&&(u[f+1]=e.alpha)):(u.writeUInt16BE(t,f),a&&u.writeUInt16BE(e.alpha,f+2));break}default:throw Error(`unrecognised color Type `+i.colorType)}d+=c,f+=l}return u}})),h=t(((e,t)=>{let n=a();function r(e,t,n,r,i){for(let a=0;a<n;a++)r[i+a]=e[t+a]}function i(e,t,n){let r=0,i=t+n;for(let n=t;n<i;n++)r+=Math.abs(e[n]);return r}function o(e,t,n,r,i,a){for(let o=0;o<n;o++){let n=o>=a?e[t+o-a]:0,s=e[t+o]-n;r[i+o]=s}}function s(e,t,n,r){let i=0;for(let a=0;a<n;a++){let n=a>=r?e[t+a-r]:0,o=e[t+a]-n;i+=Math.abs(o)}return i}function c(e,t,n,r,i){for(let a=0;a<n;a++){let o=t>0?e[t+a-n]:0,s=e[t+a]-o;r[i+a]=s}}function l(e,t,n){let r=0,i=t+n;for(let a=t;a<i;a++){let i=t>0?e[a-n]:0,o=e[a]-i;r+=Math.abs(o)}return r}function u(e,t,n,r,i,a){for(let o=0;o<n;o++){let s=o>=a?e[t+o-a]:0,c=t>0?e[t+o-n]:0,l=e[t+o]-(s+c>>1);r[i+o]=l}}function d(e,t,n,r){let i=0;for(let a=0;a<n;a++){let o=a>=r?e[t+a-r]:0,s=t>0?e[t+a-n]:0,c=e[t+a]-(o+s>>1);i+=Math.abs(c)}return i}function f(e,t,r,i,a,o){for(let s=0;s<r;s++){let c=s>=o?e[t+s-o]:0,l=t>0?e[t+s-r]:0,u=t>0&&s>=o?e[t+s-(r+o)]:0,d=e[t+s]-n(c,l,u);i[a+s]=d}}function p(e,t,r,i){let a=0;for(let o=0;o<r;o++){let s=o>=i?e[t+o-i]:0,c=t>0?e[t+o-r]:0,l=t>0&&o>=i?e[t+o-(r+i)]:0,u=e[t+o]-n(s,c,l);a+=Math.abs(u)}return a}let m={0:r,1:o,2:c,3:u,4:f},h={0:i,1:s,2:l,3:d,4:p};t.exports=function(e,t,n,r,i){let a;if(!(`filterType`in r)||r.filterType===-1)a=[0,1,2,3,4];else if(typeof r.filterType==`number`)a=[r.filterType];else throw Error(`unrecognised filter types`);r.bitDepth===16&&(i*=2);let o=t*i,s=0,c=0,l=Buffer.alloc((o+1)*n),u=a[0];for(let t=0;t<n;t++){if(a.length>1){let t=1/0;for(let n=0;n<a.length;n++){let r=h[a[n]](e,c,o,i);r<t&&(u=a[n],t=r)}}l[s]=u,s++,m[u](e,c,o,l,s,i),s+=o,c+=o}return l}})),g=t(((t,n)=>{let r=c(),i=l(),a=m(),o=h(),s=e(`zlib`),u=n.exports=function(e){if(this._options=e,e.deflateChunkSize=e.deflateChunkSize||32768,e.deflateLevel=e.deflateLevel==null?9:e.deflateLevel,e.deflateStrategy=e.deflateStrategy==null?3:e.deflateStrategy,e.inputHasAlpha=e.inputHasAlpha==null||e.inputHasAlpha,e.deflateFactory=e.deflateFactory||s.createDeflate,e.bitDepth=e.bitDepth||8,e.colorType=typeof e.colorType==`number`?e.colorType:r.COLORTYPE_COLOR_ALPHA,e.inputColorType=typeof e.inputColorType==`number`?e.inputColorType:r.COLORTYPE_COLOR_ALPHA,[r.COLORTYPE_GRAYSCALE,r.COLORTYPE_COLOR,r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(e.colorType)===-1)throw Error(`option color type:`+e.colorType+` is not supported at present`);if([r.COLORTYPE_GRAYSCALE,r.COLORTYPE_COLOR,r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(e.inputColorType)===-1)throw Error(`option input color type:`+e.inputColorType+` is not supported at present`);if(e.bitDepth!==8&&e.bitDepth!==16)throw Error(`option bit depth:`+e.bitDepth+` is not supported at present`)};u.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},u.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},u.prototype.filterData=function(e,t,n){let i=a(e,t,n,this._options),s=r.COLORTYPE_TO_BPP_MAP[this._options.colorType];return o(i,t,n,this._options,s)},u.prototype._packChunk=function(e,t){let n=t?t.length:0,r=Buffer.alloc(n+12);return r.writeUInt32BE(n,0),r.writeUInt32BE(e,4),t&&t.copy(r,8),r.writeInt32BE(i.crc32(r.slice(4,r.length-4)),r.length-4),r},u.prototype.packGAMA=function(e){let t=Buffer.alloc(4);return t.writeUInt32BE(Math.floor(e*r.GAMMA_DIVISION),0),this._packChunk(r.TYPE_gAMA,t)},u.prototype.packIHDR=function(e,t){let n=Buffer.alloc(13);return n.writeUInt32BE(e,0),n.writeUInt32BE(t,4),n[8]=this._options.bitDepth,n[9]=this._options.colorType,n[10]=0,n[11]=0,n[12]=0,this._packChunk(r.TYPE_IHDR,n)},u.prototype.packIDAT=function(e){return this._packChunk(r.TYPE_IDAT,e)},u.prototype.packIEND=function(){return this._packChunk(r.TYPE_IEND,null)}})),_=t(((t,n)=>{let r=e(`util`),i=e(`stream`),a=c(),o=g(),s=n.exports=function(e){i.call(this);let t=e||{};this._packer=new o(t),this._deflate=this._packer.createDeflate(),this.readable=!0};r.inherits(s,i),s.prototype.pack=function(e,t,n,r){this.emit(`data`,Buffer.from(a.PNG_SIGNATURE)),this.emit(`data`,this._packer.packIHDR(t,n)),r&&this.emit(`data`,this._packer.packGAMA(r));let i=this._packer.filterData(e,t,n);this._deflate.on(`error`,this.emit.bind(this,`error`)),this._deflate.on(`data`,function(e){this.emit(`data`,this._packer.packIDAT(e))}.bind(this)),this._deflate.on(`end`,function(){this.emit(`data`,this._packer.packIEND()),this.emit(`end`)}.bind(this)),this._deflate.end(i)}})),v=t(((t,n)=>{let r=e(`assert`).ok,i=e(`zlib`),a=e(`util`),o=e(`buffer`).kMaxLength;function s(e){if(!(this instanceof s))return new s(e);e&&e.chunkSize<i.Z_MIN_CHUNK&&(e.chunkSize=i.Z_MIN_CHUNK),i.Inflate.call(this,e),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,e&&e.maxLength!=null&&(this._maxLength=e.maxLength)}function c(e){return new s(e)}function l(e,t){t&&process.nextTick(t),e._handle&&=(e._handle.close(),null)}s.prototype._processChunk=function(e,t,n){if(typeof n==`function`)return i.Inflate._processChunk.call(this,e,t,n);let a=this,s=e&&e.length,c=this._chunkSize-this._offset,u=this._maxLength,d=0,f=[],p=0,m;this.on(`error`,function(e){m=e});function h(e,t){if(a._hadError)return;let n=c-t;if(r(n>=0,`have should not go down`),n>0){let e=a._buffer.slice(a._offset,a._offset+n);if(a._offset+=n,e.length>u&&(e=e.slice(0,u)),f.push(e),p+=e.length,u-=e.length,u===0)return!1}return(t===0||a._offset>=a._chunkSize)&&(c=a._chunkSize,a._offset=0,a._buffer=Buffer.allocUnsafe(a._chunkSize)),t===0&&(d+=s-e,s=e,!0)}r(this._handle,`zlib binding closed`);let g;do g=this._handle.writeSync(t,e,d,s,this._buffer,this._offset,c),g||=this._writeState;while(!this._hadError&&h(g[0],g[1]));if(this._hadError)throw m;if(p>=o)throw l(this),RangeError(`Cannot create final Buffer. It would be larger than 0x`+o.toString(16)+` bytes`);let _=Buffer.concat(f,p);return l(this),_},a.inherits(s,i.Inflate);function u(e,t){if(typeof t==`string`&&(t=Buffer.from(t)),!(t instanceof Buffer))throw TypeError(`Not a string or buffer`);let n=e._finishFlushFlag;return n??=i.Z_FINISH,e._processChunk(t,n)}function d(e,t){return u(new s(t),e)}n.exports=t=d,t.Inflate=s,t.createInflate=c,t.inflateSync=d})),y=t(((e,t)=>{let n=t.exports=function(e){this._buffer=e,this._reads=[]};n.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t})},n.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let e=this._reads[0];if(this._buffer.length&&(this._buffer.length>=e.length||e.allowLess)){this._reads.shift();let t=this._buffer;this._buffer=t.slice(e.length),e.func.call(this,t.slice(0,e.length))}else break}if(this._reads.length>0)throw Error(`There are some read requests waitng on finished stream`);if(this._buffer.length>0)throw Error(`unrecognised content at end of stream`)}})),b=t((e=>{let t=y(),n=o();e.process=function(e,r){let i=[],a=new t(e);return new n(r,{read:a.read.bind(a),write:function(e){i.push(e)},complete:function(){}}).start(),a.process(),Buffer.concat(i)}})),x=t(((t,n)=>{let r=!0,i=e(`zlib`),a=v();i.deflateSync||(r=!1);let o=y(),s=b(),c=u(),l=d(),p=f();n.exports=function(e,t){if(!r)throw Error(`To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0`);let n;function u(e){n=e}let d;function f(e){d=e}function m(e){d.transColor=e}function h(e){d.palette=e}function g(){d.alpha=!0}let _;function v(e){_=e}let y=[];function b(e){y.push(e)}let x=new o(e);if(new c(t,{read:x.read.bind(x),error:u,metadata:f,gamma:v,palette:h,transColor:m,inflateData:b,simpleTransparency:g}).start(),x.process(),n)throw n;let S=Buffer.concat(y);y.length=0;let C;if(d.interlace)C=i.inflateSync(S);else{let e=((d.width*d.bpp*d.depth+7>>3)+1)*d.height;C=a(S,{chunkSize:e,maxLength:e})}if(S=null,!C||!C.length)throw Error(`bad png - invalid inflate data response`);let w=s.process(C,d);S=null;let T=l.dataToBitMap(w,d);w=null;let E=p(T,d,t.skipRescale);return d.data=E,d.gamma=_||0,d}})),S=t(((t,n)=>{let r=!0,i=e(`zlib`);i.deflateSync||(r=!1);let a=c(),o=g();n.exports=function(e,t){if(!r)throw Error(`To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0`);let n=new o(t||{}),s=[];s.push(Buffer.from(a.PNG_SIGNATURE)),s.push(n.packIHDR(e.width,e.height)),e.gamma&&s.push(n.packGAMA(e.gamma));let c=n.filterData(e.data,e.width,e.height),l=i.deflateSync(c,n.getDeflateOptions());if(c=null,!l||!l.length)throw Error(`bad png - invalid compressed data response`);return s.push(n.packIDAT(l)),s.push(n.packIEND()),Buffer.concat(s)}})),C=t((e=>{let t=x(),n=S();e.read=function(e,n){return t(e,n||{})},e.write=function(e,t){return n(e,t)}})),w=t((t=>{let n=e(`util`),r=e(`stream`),i=p(),a=_(),o=C(),s=t.PNG=function(e){r.call(this),e||={},this.width=e.width|0,this.height=e.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,e.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new i(e),this._parser.on(`error`,this.emit.bind(this,`error`)),this._parser.on(`close`,this._handleClose.bind(this)),this._parser.on(`metadata`,this._metadata.bind(this)),this._parser.on(`gamma`,this._gamma.bind(this)),this._parser.on(`parsed`,function(e){this.data=e,this.emit(`parsed`,e)}.bind(this)),this._packer=new a(e),this._packer.on(`data`,this.emit.bind(this,`data`)),this._packer.on(`end`,this.emit.bind(this,`end`)),this._parser.on(`close`,this._handleClose.bind(this)),this._packer.on(`error`,this.emit.bind(this,`error`))};n.inherits(s,r),s.sync=o,s.prototype.pack=function(){return!this.data||!this.data.length?(this.emit(`error`,`No data provided`),this):(process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this)},s.prototype.parse=function(e,t){if(t){let e,n;e=function(e){this.removeListener(`error`,n),this.data=e,t(null,this)}.bind(this),n=function(n){this.removeListener(`parsed`,e),t(n,null)}.bind(this),this.once(`parsed`,e),this.once(`error`,n)}return this.end(e),this},s.prototype.write=function(e){return this._parser.write(e),!0},s.prototype.end=function(e){this._parser.end(e)},s.prototype._metadata=function(e){this.width=e.width,this.height=e.height,this.emit(`metadata`,e)},s.prototype._gamma=function(e){this.gamma=e},s.prototype._handleClose=function(){!this._parser.writable&&!this._packer.readable&&this.emit(`close`)},s.bitblt=function(e,t,n,r,i,a,o,s){if(n|=0,r|=0,i|=0,a|=0,o|=0,s|=0,n>e.width||r>e.height||n+i>e.width||r+a>e.height)throw Error(`bitblt reading outside image`);if(o>t.width||s>t.height||o+i>t.width||s+a>t.height)throw Error(`bitblt writing outside image`);for(let c=0;c<a;c++)e.data.copy(t.data,(s+c)*t.width+o<<2,(r+c)*e.width+n<<2,(r+c)*e.width+n+i<<2)},s.prototype.bitblt=function(e,t,n,r,i,a,o){return s.bitblt(this,e,t,n,r,i,a,o),this},s.adjustGamma=function(e){if(e.gamma){for(let t=0;t<e.height;t++)for(let n=0;n<e.width;n++){let r=e.width*t+n<<2;for(let t=0;t<3;t++){let n=e.data[r+t]/255;n**=1/2.2/e.gamma,e.data[r+t]=Math.round(n*255)}}e.gamma=0}},s.prototype.adjustGamma=function(){s.adjustGamma(this)}}))();const T=Buffer.from([137,80,78,71,13,10,26,10]);function E(e){return e.subarray(0,T.length).equals(T)}function D(e,t){try{return w.PNG.sync.read(e)}catch(e){throw new n(`COMMAND_FAILED`,`Failed to decode ${t} as PNG`,{label:t,reason:e instanceof Error?e.message:String(e)})}}export{E as n,w as r,D as t};
|
|
1
|
+
import{i as e,t}from"./rolldown-runtime.js";import{A as n}from"./sdk-contracts.js";var r=t(((t,n)=>{let r=e(`util`),i=e(`stream`),a=n.exports=function(){i.call(this),this._buffers=[],this._buffered=0,this._reads=[],this._paused=!1,this._encoding=`utf8`,this.writable=!0};r.inherits(a,i),a.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t}),process.nextTick(function(){this._process(),this._paused&&this._reads&&this._reads.length>0&&(this._paused=!1,this.emit(`drain`))}.bind(this))},a.prototype.write=function(e,t){if(!this.writable)return this.emit(`error`,Error(`Stream not writable`)),!1;let n;return n=Buffer.isBuffer(e)?e:Buffer.from(e,t||this._encoding),this._buffers.push(n),this._buffered+=n.length,this._process(),this._reads&&this._reads.length===0&&(this._paused=!0),this.writable&&!this._paused},a.prototype.end=function(e,t){e&&this.write(e,t),this.writable=!1,this._buffers&&(this._buffers.length===0?this._end():(this._buffers.push(null),this._process()))},a.prototype.destroySoon=a.prototype.end,a.prototype._end=function(){this._reads.length>0&&this.emit(`error`,Error(`Unexpected end of input`)),this.destroy()},a.prototype.destroy=function(){this._buffers&&(this.writable=!1,this._reads=null,this._buffers=null,this.emit(`close`))},a.prototype._processReadAllowingLess=function(e){this._reads.shift();let t=this._buffers[0];t.length>e.length?(this._buffered-=e.length,this._buffers[0]=t.slice(e.length),e.func.call(this,t.slice(0,e.length))):(this._buffered-=t.length,this._buffers.shift(),e.func.call(this,t))},a.prototype._processRead=function(e){this._reads.shift();let t=0,n=0,r=Buffer.alloc(e.length);for(;t<e.length;){let i=this._buffers[n++],a=Math.min(i.length,e.length-t);i.copy(r,t,0,a),t+=a,a!==i.length&&(this._buffers[--n]=i.slice(a))}n>0&&this._buffers.splice(0,n),this._buffered-=e.length,e.func.call(this,r)},a.prototype._process=function(){try{for(;this._buffered>0&&this._reads&&this._reads.length>0;){let e=this._reads[0];if(e.allowLess)this._processReadAllowingLess(e);else if(this._buffered>=e.length)this._processRead(e);else break}this._buffers&&!this.writable&&this._end()}catch(e){this.emit(`error`,e)}}})),i=t((e=>{let t=[{x:[0],y:[0]},{x:[4],y:[0]},{x:[0,4],y:[4]},{x:[2,6],y:[0,4]},{x:[0,2,4,6],y:[2,6]},{x:[1,3,5,7],y:[0,2,4,6]},{x:[0,1,2,3,4,5,6,7],y:[1,3,5,7]}];e.getImagePasses=function(e,n){let r=[],i=e%8,a=n%8,o=(e-i)/8,s=(n-a)/8;for(let e=0;e<t.length;e++){let n=t[e],c=o*n.x.length,l=s*n.y.length;for(let e=0;e<n.x.length&&n.x[e]<i;e++)c++;for(let e=0;e<n.y.length&&n.y[e]<a;e++)l++;c>0&&l>0&&r.push({width:c,height:l,index:e})}return r},e.getInterlaceIterator=function(e){return function(n,r,i){let a=n%t[i].x.length,o=(n-a)/t[i].x.length*8+t[i].x[a],s=r%t[i].y.length,c=(r-s)/t[i].y.length*8+t[i].y[s];return o*4+c*e*4}}})),a=t(((e,t)=>{t.exports=function(e,t,n){let r=e+t-n,i=Math.abs(r-e),a=Math.abs(r-t),o=Math.abs(r-n);return i<=a&&i<=o?e:a<=o?t:n}})),o=t(((e,t)=>{let n=i(),r=a();function o(e,t,n){let r=e*t;return n!==8&&(r=Math.ceil(r/(8/n))),r}let s=t.exports=function(e,t){let r=e.width,i=e.height,a=e.interlace,s=e.bpp,c=e.depth;if(this.read=t.read,this.write=t.write,this.complete=t.complete,this._imageIndex=0,this._images=[],a){let e=n.getImagePasses(r,i);for(let t=0;t<e.length;t++)this._images.push({byteWidth:o(e[t].width,s,c),height:e[t].height,lineIndex:0})}else this._images.push({byteWidth:o(r,s,c),height:i,lineIndex:0});this._xComparison=c===8?s:c===16?s*2:1};s.prototype.start=function(){this.read(this._images[this._imageIndex].byteWidth+1,this._reverseFilterLine.bind(this))},s.prototype._unFilterType1=function(e,t,n){let r=this._xComparison,i=r-1;for(let a=0;a<n;a++){let n=e[1+a],o=a>i?t[a-r]:0;t[a]=n+o}},s.prototype._unFilterType2=function(e,t,n){let r=this._lastLine;for(let i=0;i<n;i++){let n=e[1+i],a=r?r[i]:0;t[i]=n+a}},s.prototype._unFilterType3=function(e,t,n){let r=this._xComparison,i=r-1,a=this._lastLine;for(let o=0;o<n;o++){let n=e[1+o],s=a?a[o]:0,c=o>i?t[o-r]:0,l=Math.floor((c+s)/2);t[o]=n+l}},s.prototype._unFilterType4=function(e,t,n){let i=this._xComparison,a=i-1,o=this._lastLine;for(let s=0;s<n;s++){let n=e[1+s],c=o?o[s]:0,l=s>a?t[s-i]:0,u=s>a&&o?o[s-i]:0,d=r(l,c,u);t[s]=n+d}},s.prototype._reverseFilterLine=function(e){let t=e[0],n,r=this._images[this._imageIndex],i=r.byteWidth;if(t===0)n=e.slice(1,i+1);else switch(n=Buffer.alloc(i),t){case 1:this._unFilterType1(e,n,i);break;case 2:this._unFilterType2(e,n,i);break;case 3:this._unFilterType3(e,n,i);break;case 4:this._unFilterType4(e,n,i);break;default:throw Error(`Unrecognised filter type - `+t)}this.write(n),r.lineIndex++,r.lineIndex>=r.height?(this._lastLine=null,this._imageIndex++,r=this._images[this._imageIndex]):this._lastLine=n,r?this.read(r.byteWidth+1,this._reverseFilterLine.bind(this)):(this._lastLine=null,this.complete())}})),s=t(((t,n)=>{let i=e(`util`),a=r(),s=o(),c=n.exports=function(e){a.call(this);let t=[],n=this;this._filter=new s(e,{read:this.read.bind(this),write:function(e){t.push(e)},complete:function(){n.emit(`complete`,Buffer.concat(t))}}),this._filter.start()};i.inherits(c,a)})),c=t(((e,t)=>{t.exports={PNG_SIGNATURE:[137,80,78,71,13,10,26,10],TYPE_IHDR:1229472850,TYPE_IEND:1229278788,TYPE_IDAT:1229209940,TYPE_PLTE:1347179589,TYPE_tRNS:1951551059,TYPE_gAMA:1732332865,COLORTYPE_GRAYSCALE:0,COLORTYPE_PALETTE:1,COLORTYPE_COLOR:2,COLORTYPE_ALPHA:4,COLORTYPE_PALETTE_COLOR:3,COLORTYPE_COLOR_ALPHA:6,COLORTYPE_TO_BPP_MAP:{0:1,2:3,3:1,4:2,6:4},GAMMA_DIVISION:1e5}})),l=t(((e,t)=>{let n=[];(function(){for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t&1?t=3988292384^t>>>1:t>>>=1;n[e]=t}})();let r=t.exports=function(){this._crc=-1};r.prototype.write=function(e){for(let t=0;t<e.length;t++)this._crc=n[(this._crc^e[t])&255]^this._crc>>>8;return!0},r.prototype.crc32=function(){return this._crc^-1},r.crc32=function(e){let t=-1;for(let r=0;r<e.length;r++)t=n[(t^e[r])&255]^t>>>8;return t^-1}})),u=t(((e,t)=>{let n=c(),r=l(),i=t.exports=function(e,t){this._options=e,e.checkCRC=e.checkCRC!==!1,this._hasIHDR=!1,this._hasIEND=!1,this._emittedHeadersFinished=!1,this._palette=[],this._colorType=0,this._chunks={},this._chunks[n.TYPE_IHDR]=this._handleIHDR.bind(this),this._chunks[n.TYPE_IEND]=this._handleIEND.bind(this),this._chunks[n.TYPE_IDAT]=this._handleIDAT.bind(this),this._chunks[n.TYPE_PLTE]=this._handlePLTE.bind(this),this._chunks[n.TYPE_tRNS]=this._handleTRNS.bind(this),this._chunks[n.TYPE_gAMA]=this._handleGAMA.bind(this),this.read=t.read,this.error=t.error,this.metadata=t.metadata,this.gamma=t.gamma,this.transColor=t.transColor,this.palette=t.palette,this.parsed=t.parsed,this.inflateData=t.inflateData,this.finished=t.finished,this.simpleTransparency=t.simpleTransparency,this.headersFinished=t.headersFinished||function(){}};i.prototype.start=function(){this.read(n.PNG_SIGNATURE.length,this._parseSignature.bind(this))},i.prototype._parseSignature=function(e){let t=n.PNG_SIGNATURE;for(let n=0;n<t.length;n++)if(e[n]!==t[n]){this.error(Error(`Invalid file signature`));return}this.read(8,this._parseChunkBegin.bind(this))},i.prototype._parseChunkBegin=function(e){let t=e.readUInt32BE(0),i=e.readUInt32BE(4),a=``;for(let t=4;t<8;t++)a+=String.fromCharCode(e[t]);let o=!!(e[4]&32);if(!this._hasIHDR&&i!==n.TYPE_IHDR){this.error(Error(`Expected IHDR on beggining`));return}if(this._crc=new r,this._crc.write(Buffer.from(a)),this._chunks[i])return this._chunks[i](t);if(!o){this.error(Error(`Unsupported critical chunk type `+a));return}this.read(t+4,this._skipChunk.bind(this))},i.prototype._skipChunk=function(){this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleChunkEnd=function(){this.read(4,this._parseChunkEnd.bind(this))},i.prototype._parseChunkEnd=function(e){let t=e.readInt32BE(0),n=this._crc.crc32();if(this._options.checkCRC&&n!==t){this.error(Error(`Crc error - `+t+` - `+n));return}this._hasIEND||this.read(8,this._parseChunkBegin.bind(this))},i.prototype._handleIHDR=function(e){this.read(e,this._parseIHDR.bind(this))},i.prototype._parseIHDR=function(e){this._crc.write(e);let t=e.readUInt32BE(0),r=e.readUInt32BE(4),i=e[8],a=e[9],o=e[10],s=e[11],c=e[12];if(i!==8&&i!==4&&i!==2&&i!==1&&i!==16){this.error(Error(`Unsupported bit depth `+i));return}if(!(a in n.COLORTYPE_TO_BPP_MAP)){this.error(Error(`Unsupported color type`));return}if(o!==0){this.error(Error(`Unsupported compression method`));return}if(s!==0){this.error(Error(`Unsupported filter method`));return}if(c!==0&&c!==1){this.error(Error(`Unsupported interlace method`));return}this._colorType=a;let l=n.COLORTYPE_TO_BPP_MAP[this._colorType];this._hasIHDR=!0,this.metadata({width:t,height:r,depth:i,interlace:!!c,palette:!!(a&n.COLORTYPE_PALETTE),color:!!(a&n.COLORTYPE_COLOR),alpha:!!(a&n.COLORTYPE_ALPHA),bpp:l,colorType:a}),this._handleChunkEnd()},i.prototype._handlePLTE=function(e){this.read(e,this._parsePLTE.bind(this))},i.prototype._parsePLTE=function(e){this._crc.write(e);let t=Math.floor(e.length/3);for(let n=0;n<t;n++)this._palette.push([e[n*3],e[n*3+1],e[n*3+2],255]);this.palette(this._palette),this._handleChunkEnd()},i.prototype._handleTRNS=function(e){this.simpleTransparency(),this.read(e,this._parseTRNS.bind(this))},i.prototype._parseTRNS=function(e){if(this._crc.write(e),this._colorType===n.COLORTYPE_PALETTE_COLOR){if(this._palette.length===0){this.error(Error(`Transparency chunk must be after palette`));return}if(e.length>this._palette.length){this.error(Error(`More transparent colors than palette size`));return}for(let t=0;t<e.length;t++)this._palette[t][3]=e[t];this.palette(this._palette)}this._colorType===n.COLORTYPE_GRAYSCALE&&this.transColor([e.readUInt16BE(0)]),this._colorType===n.COLORTYPE_COLOR&&this.transColor([e.readUInt16BE(0),e.readUInt16BE(2),e.readUInt16BE(4)]),this._handleChunkEnd()},i.prototype._handleGAMA=function(e){this.read(e,this._parseGAMA.bind(this))},i.prototype._parseGAMA=function(e){this._crc.write(e),this.gamma(e.readUInt32BE(0)/n.GAMMA_DIVISION),this._handleChunkEnd()},i.prototype._handleIDAT=function(e){this._emittedHeadersFinished||(this._emittedHeadersFinished=!0,this.headersFinished()),this.read(-e,this._parseIDAT.bind(this,e))},i.prototype._parseIDAT=function(e,t){if(this._crc.write(t),this._colorType===n.COLORTYPE_PALETTE_COLOR&&this._palette.length===0)throw Error(`Expected palette not found`);this.inflateData(t);let r=e-t.length;r>0?this._handleIDAT(r):this._handleChunkEnd()},i.prototype._handleIEND=function(e){this.read(e,this._parseIEND.bind(this))},i.prototype._parseIEND=function(e){this._crc.write(e),this._hasIEND=!0,this._handleChunkEnd(),this.finished&&this.finished()}})),d=t((e=>{let t=i(),n=[function(){},function(e,t,n,r){if(r===t.length)throw Error(`Ran out of data`);let i=t[r];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=255},function(e,t,n,r){if(r+1>=t.length)throw Error(`Ran out of data`);let i=t[r];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=t[r+1]},function(e,t,n,r){if(r+2>=t.length)throw Error(`Ran out of data`);e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=255},function(e,t,n,r){if(r+3>=t.length)throw Error(`Ran out of data`);e[n]=t[r],e[n+1]=t[r+1],e[n+2]=t[r+2],e[n+3]=t[r+3]}],r=[function(){},function(e,t,n,r){let i=t[0];e[n]=i,e[n+1]=i,e[n+2]=i,e[n+3]=r},function(e,t,n){let r=t[0];e[n]=r,e[n+1]=r,e[n+2]=r,e[n+3]=t[1]},function(e,t,n,r){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=r},function(e,t,n){e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=t[3]}];function a(e,t){let n=[],r=0;function i(){if(r===e.length)throw Error(`Ran out of data`);let i=e[r];r++;let a,o,s,c,l,u,d,f;switch(t){default:throw Error(`unrecognised depth`);case 16:d=e[r],r++,n.push((i<<8)+d);break;case 4:d=i&15,f=i>>4,n.push(f,d);break;case 2:l=i&3,u=i>>2&3,d=i>>4&3,f=i>>6&3,n.push(f,d,u,l);break;case 1:a=i&1,o=i>>1&1,s=i>>2&1,c=i>>3&1,l=i>>4&1,u=i>>5&1,d=i>>6&1,f=i>>7&1,n.push(f,d,u,l,c,s,o,a)}}return{get:function(e){for(;n.length<e;)i();let t=n.slice(0,e);return n=n.slice(e),t},resetAfterLine:function(){n.length=0},end:function(){if(r!==e.length)throw Error(`extra data found`)}}}function o(e,t,r,i,a,o){let s=e.width,c=e.height,l=e.index;for(let e=0;e<c;e++)for(let c=0;c<s;c++){let s=r(c,e,l);n[i](t,a,s,o),o+=i}return o}function s(e,t,n,i,a,o){let s=e.width,c=e.height,l=e.index;for(let e=0;e<c;e++){for(let c=0;c<s;c++){let s=a.get(i),u=n(c,e,l);r[i](t,s,u,o)}a.resetAfterLine()}}e.dataToBitMap=function(e,n){let r=n.width,i=n.height,c=n.depth,l=n.bpp,u=n.interlace,d;c!==8&&(d=a(e,c));let f;f=c<=8?Buffer.alloc(r*i*4):new Uint16Array(r*i*4);let p=2**c-1,m=0,h,g;if(u)h=t.getImagePasses(r,i),g=t.getInterlaceIterator(r,i);else{let e=0;g=function(){let t=e;return e+=4,t},h=[{width:r,height:i}]}for(let t=0;t<h.length;t++)c===8?m=o(h[t],f,g,l,e,m):s(h[t],f,g,l,d,p);if(c===8){if(m!==e.length)throw Error(`extra data found`)}else d.end();return f}})),f=t(((e,t)=>{function n(e,t,n,r,i){let a=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){let n=i[e[a]];if(!n)throw Error(`index `+e[a]+` not in palette`);for(let e=0;e<4;e++)t[a+e]=n[e];a+=4}}function r(e,t,n,r,i){let a=0;for(let o=0;o<r;o++)for(let r=0;r<n;r++){let n=!1;if(i.length===1?i[0]===e[a]&&(n=!0):i[0]===e[a]&&i[1]===e[a+1]&&i[2]===e[a+2]&&(n=!0),n)for(let e=0;e<4;e++)t[a+e]=0;a+=4}}function i(e,t,n,r,i){let a=2**i-1,o=0;for(let i=0;i<r;i++)for(let r=0;r<n;r++){for(let n=0;n<4;n++)t[o+n]=Math.floor(e[o+n]*255/a+.5);o+=4}}t.exports=function(e,t,a=!1){let o=t.depth,s=t.width,c=t.height,l=t.colorType,u=t.transColor,d=t.palette,f=e;return l===3?n(e,f,s,c,d):(u&&r(e,f,s,c,u),o!==8&&!a&&(o===16&&(f=Buffer.alloc(s*c*4)),i(e,f,s,c,o))),f}})),p=t(((t,n)=>{let i=e(`util`),a=e(`zlib`),o=r(),c=s(),l=u(),p=d(),m=f(),h=n.exports=function(e){o.call(this),this._parser=new l(e,{read:this.read.bind(this),error:this._handleError.bind(this),metadata:this._handleMetaData.bind(this),gamma:this.emit.bind(this,`gamma`),palette:this._handlePalette.bind(this),transColor:this._handleTransColor.bind(this),finished:this._finished.bind(this),inflateData:this._inflateData.bind(this),simpleTransparency:this._simpleTransparency.bind(this),headersFinished:this._headersFinished.bind(this)}),this._options=e,this.writable=!0,this._parser.start()};i.inherits(h,o),h.prototype._handleError=function(e){this.emit(`error`,e),this.writable=!1,this.destroy(),this._inflate&&this._inflate.destroy&&this._inflate.destroy(),this._filter&&(this._filter.destroy(),this._filter.on(`error`,function(){})),this.errord=!0},h.prototype._inflateData=function(e){if(!this._inflate){if(this._bitmapInfo.interlace)this._inflate=a.createInflate(),this._inflate.on(`error`,this.emit.bind(this,`error`)),this._filter.on(`complete`,this._complete.bind(this)),this._inflate.pipe(this._filter);else{let e=((this._bitmapInfo.width*this._bitmapInfo.bpp*this._bitmapInfo.depth+7>>3)+1)*this._bitmapInfo.height,t=Math.max(e,a.Z_MIN_CHUNK);this._inflate=a.createInflate({chunkSize:t});let n=e,r=this.emit.bind(this,`error`);this._inflate.on(`error`,function(e){n&&r(e)}),this._filter.on(`complete`,this._complete.bind(this));let i=this._filter.write.bind(this._filter);this._inflate.on(`data`,function(e){n&&(e.length>n&&(e=e.slice(0,n)),n-=e.length,i(e))}),this._inflate.on(`end`,this._filter.end.bind(this._filter))}}this._inflate.write(e)},h.prototype._handleMetaData=function(e){this._metaData=e,this._bitmapInfo=Object.create(e),this._filter=new c(this._bitmapInfo)},h.prototype._handleTransColor=function(e){this._bitmapInfo.transColor=e},h.prototype._handlePalette=function(e){this._bitmapInfo.palette=e},h.prototype._simpleTransparency=function(){this._metaData.alpha=!0},h.prototype._headersFinished=function(){this.emit(`metadata`,this._metaData)},h.prototype._finished=function(){this.errord||(this._inflate?this._inflate.end():this.emit(`error`,`No Inflate block`))},h.prototype._complete=function(e){if(this.errord)return;let t;try{let n=p.dataToBitMap(e,this._bitmapInfo);t=m(n,this._bitmapInfo,this._options.skipRescale),n=null}catch(e){this._handleError(e);return}this.emit(`parsed`,t)}})),m=t(((e,t)=>{let n=c();t.exports=function(e,t,r,i){let a=[n.COLORTYPE_COLOR_ALPHA,n.COLORTYPE_ALPHA].indexOf(i.colorType)!==-1;if(i.colorType===i.inputColorType){let t=(function(){let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]!==256})();if(i.bitDepth===8||i.bitDepth===16&&t)return e}let o=i.bitDepth===16?new Uint16Array(e.buffer):e,s=255,c=n.COLORTYPE_TO_BPP_MAP[i.inputColorType];c===4&&!i.inputHasAlpha&&(c=3);let l=n.COLORTYPE_TO_BPP_MAP[i.colorType];i.bitDepth===16&&(s=65535,l*=2);let u=Buffer.alloc(t*r*l),d=0,f=0,p=i.bgColor||{};p.red===void 0&&(p.red=s),p.green===void 0&&(p.green=s),p.blue===void 0&&(p.blue=s);function m(){let e,t,r,c=s;switch(i.inputColorType){case n.COLORTYPE_COLOR_ALPHA:c=o[d+3],e=o[d],t=o[d+1],r=o[d+2];break;case n.COLORTYPE_COLOR:e=o[d],t=o[d+1],r=o[d+2];break;case n.COLORTYPE_ALPHA:c=o[d+1],e=o[d],t=e,r=e;break;case n.COLORTYPE_GRAYSCALE:e=o[d],t=e,r=e;break;default:throw Error(`input color type:`+i.inputColorType+` is not supported at present`)}return i.inputHasAlpha&&(a||(c/=s,e=Math.min(Math.max(Math.round((1-c)*p.red+c*e),0),s),t=Math.min(Math.max(Math.round((1-c)*p.green+c*t),0),s),r=Math.min(Math.max(Math.round((1-c)*p.blue+c*r),0),s))),{red:e,green:t,blue:r,alpha:c}}for(let e=0;e<r;e++)for(let e=0;e<t;e++){let e=m(o,d);switch(i.colorType){case n.COLORTYPE_COLOR_ALPHA:case n.COLORTYPE_COLOR:i.bitDepth===8?(u[f]=e.red,u[f+1]=e.green,u[f+2]=e.blue,a&&(u[f+3]=e.alpha)):(u.writeUInt16BE(e.red,f),u.writeUInt16BE(e.green,f+2),u.writeUInt16BE(e.blue,f+4),a&&u.writeUInt16BE(e.alpha,f+6));break;case n.COLORTYPE_ALPHA:case n.COLORTYPE_GRAYSCALE:{let t=(e.red+e.green+e.blue)/3;i.bitDepth===8?(u[f]=t,a&&(u[f+1]=e.alpha)):(u.writeUInt16BE(t,f),a&&u.writeUInt16BE(e.alpha,f+2));break}default:throw Error(`unrecognised color Type `+i.colorType)}d+=c,f+=l}return u}})),h=t(((e,t)=>{let n=a();function r(e,t,n,r,i){for(let a=0;a<n;a++)r[i+a]=e[t+a]}function i(e,t,n){let r=0,i=t+n;for(let n=t;n<i;n++)r+=Math.abs(e[n]);return r}function o(e,t,n,r,i,a){for(let o=0;o<n;o++){let n=o>=a?e[t+o-a]:0,s=e[t+o]-n;r[i+o]=s}}function s(e,t,n,r){let i=0;for(let a=0;a<n;a++){let n=a>=r?e[t+a-r]:0,o=e[t+a]-n;i+=Math.abs(o)}return i}function c(e,t,n,r,i){for(let a=0;a<n;a++){let o=t>0?e[t+a-n]:0,s=e[t+a]-o;r[i+a]=s}}function l(e,t,n){let r=0,i=t+n;for(let a=t;a<i;a++){let i=t>0?e[a-n]:0,o=e[a]-i;r+=Math.abs(o)}return r}function u(e,t,n,r,i,a){for(let o=0;o<n;o++){let s=o>=a?e[t+o-a]:0,c=t>0?e[t+o-n]:0,l=e[t+o]-(s+c>>1);r[i+o]=l}}function d(e,t,n,r){let i=0;for(let a=0;a<n;a++){let o=a>=r?e[t+a-r]:0,s=t>0?e[t+a-n]:0,c=e[t+a]-(o+s>>1);i+=Math.abs(c)}return i}function f(e,t,r,i,a,o){for(let s=0;s<r;s++){let c=s>=o?e[t+s-o]:0,l=t>0?e[t+s-r]:0,u=t>0&&s>=o?e[t+s-(r+o)]:0,d=e[t+s]-n(c,l,u);i[a+s]=d}}function p(e,t,r,i){let a=0;for(let o=0;o<r;o++){let s=o>=i?e[t+o-i]:0,c=t>0?e[t+o-r]:0,l=t>0&&o>=i?e[t+o-(r+i)]:0,u=e[t+o]-n(s,c,l);a+=Math.abs(u)}return a}let m={0:r,1:o,2:c,3:u,4:f},h={0:i,1:s,2:l,3:d,4:p};t.exports=function(e,t,n,r,i){let a;if(!(`filterType`in r)||r.filterType===-1)a=[0,1,2,3,4];else if(typeof r.filterType==`number`)a=[r.filterType];else throw Error(`unrecognised filter types`);r.bitDepth===16&&(i*=2);let o=t*i,s=0,c=0,l=Buffer.alloc((o+1)*n),u=a[0];for(let t=0;t<n;t++){if(a.length>1){let t=1/0;for(let n=0;n<a.length;n++){let r=h[a[n]](e,c,o,i);r<t&&(u=a[n],t=r)}}l[s]=u,s++,m[u](e,c,o,l,s,i),s+=o,c+=o}return l}})),g=t(((t,n)=>{let r=c(),i=l(),a=m(),o=h(),s=e(`zlib`),u=n.exports=function(e){if(this._options=e,e.deflateChunkSize=e.deflateChunkSize||32768,e.deflateLevel=e.deflateLevel==null?9:e.deflateLevel,e.deflateStrategy=e.deflateStrategy==null?3:e.deflateStrategy,e.inputHasAlpha=e.inputHasAlpha==null||e.inputHasAlpha,e.deflateFactory=e.deflateFactory||s.createDeflate,e.bitDepth=e.bitDepth||8,e.colorType=typeof e.colorType==`number`?e.colorType:r.COLORTYPE_COLOR_ALPHA,e.inputColorType=typeof e.inputColorType==`number`?e.inputColorType:r.COLORTYPE_COLOR_ALPHA,[r.COLORTYPE_GRAYSCALE,r.COLORTYPE_COLOR,r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(e.colorType)===-1)throw Error(`option color type:`+e.colorType+` is not supported at present`);if([r.COLORTYPE_GRAYSCALE,r.COLORTYPE_COLOR,r.COLORTYPE_COLOR_ALPHA,r.COLORTYPE_ALPHA].indexOf(e.inputColorType)===-1)throw Error(`option input color type:`+e.inputColorType+` is not supported at present`);if(e.bitDepth!==8&&e.bitDepth!==16)throw Error(`option bit depth:`+e.bitDepth+` is not supported at present`)};u.prototype.getDeflateOptions=function(){return{chunkSize:this._options.deflateChunkSize,level:this._options.deflateLevel,strategy:this._options.deflateStrategy}},u.prototype.createDeflate=function(){return this._options.deflateFactory(this.getDeflateOptions())},u.prototype.filterData=function(e,t,n){let i=a(e,t,n,this._options),s=r.COLORTYPE_TO_BPP_MAP[this._options.colorType];return o(i,t,n,this._options,s)},u.prototype._packChunk=function(e,t){let n=t?t.length:0,r=Buffer.alloc(n+12);return r.writeUInt32BE(n,0),r.writeUInt32BE(e,4),t&&t.copy(r,8),r.writeInt32BE(i.crc32(r.slice(4,r.length-4)),r.length-4),r},u.prototype.packGAMA=function(e){let t=Buffer.alloc(4);return t.writeUInt32BE(Math.floor(e*r.GAMMA_DIVISION),0),this._packChunk(r.TYPE_gAMA,t)},u.prototype.packIHDR=function(e,t){let n=Buffer.alloc(13);return n.writeUInt32BE(e,0),n.writeUInt32BE(t,4),n[8]=this._options.bitDepth,n[9]=this._options.colorType,n[10]=0,n[11]=0,n[12]=0,this._packChunk(r.TYPE_IHDR,n)},u.prototype.packIDAT=function(e){return this._packChunk(r.TYPE_IDAT,e)},u.prototype.packIEND=function(){return this._packChunk(r.TYPE_IEND,null)}})),_=t(((t,n)=>{let r=e(`util`),i=e(`stream`),a=c(),o=g(),s=n.exports=function(e){i.call(this);let t=e||{};this._packer=new o(t),this._deflate=this._packer.createDeflate(),this.readable=!0};r.inherits(s,i),s.prototype.pack=function(e,t,n,r){this.emit(`data`,Buffer.from(a.PNG_SIGNATURE)),this.emit(`data`,this._packer.packIHDR(t,n)),r&&this.emit(`data`,this._packer.packGAMA(r));let i=this._packer.filterData(e,t,n);this._deflate.on(`error`,this.emit.bind(this,`error`)),this._deflate.on(`data`,function(e){this.emit(`data`,this._packer.packIDAT(e))}.bind(this)),this._deflate.on(`end`,function(){this.emit(`data`,this._packer.packIEND()),this.emit(`end`)}.bind(this)),this._deflate.end(i)}})),v=t(((t,n)=>{let r=e(`assert`).ok,i=e(`zlib`),a=e(`util`),o=e(`buffer`).kMaxLength;function s(e){if(!(this instanceof s))return new s(e);e&&e.chunkSize<i.Z_MIN_CHUNK&&(e.chunkSize=i.Z_MIN_CHUNK),i.Inflate.call(this,e),this._offset=this._offset===void 0?this._outOffset:this._offset,this._buffer=this._buffer||this._outBuffer,e&&e.maxLength!=null&&(this._maxLength=e.maxLength)}function c(e){return new s(e)}function l(e,t){t&&process.nextTick(t),e._handle&&=(e._handle.close(),null)}s.prototype._processChunk=function(e,t,n){if(typeof n==`function`)return i.Inflate._processChunk.call(this,e,t,n);let a=this,s=e&&e.length,c=this._chunkSize-this._offset,u=this._maxLength,d=0,f=[],p=0,m;this.on(`error`,function(e){m=e});function h(e,t){if(a._hadError)return;let n=c-t;if(r(n>=0,`have should not go down`),n>0){let e=a._buffer.slice(a._offset,a._offset+n);if(a._offset+=n,e.length>u&&(e=e.slice(0,u)),f.push(e),p+=e.length,u-=e.length,u===0)return!1}return(t===0||a._offset>=a._chunkSize)&&(c=a._chunkSize,a._offset=0,a._buffer=Buffer.allocUnsafe(a._chunkSize)),t===0&&(d+=s-e,s=e,!0)}r(this._handle,`zlib binding closed`);let g;do g=this._handle.writeSync(t,e,d,s,this._buffer,this._offset,c),g||=this._writeState;while(!this._hadError&&h(g[0],g[1]));if(this._hadError)throw m;if(p>=o)throw l(this),RangeError(`Cannot create final Buffer. It would be larger than 0x`+o.toString(16)+` bytes`);let _=Buffer.concat(f,p);return l(this),_},a.inherits(s,i.Inflate);function u(e,t){if(typeof t==`string`&&(t=Buffer.from(t)),!(t instanceof Buffer))throw TypeError(`Not a string or buffer`);let n=e._finishFlushFlag;return n??=i.Z_FINISH,e._processChunk(t,n)}function d(e,t){return u(new s(t),e)}n.exports=t=d,t.Inflate=s,t.createInflate=c,t.inflateSync=d})),y=t(((e,t)=>{let n=t.exports=function(e){this._buffer=e,this._reads=[]};n.prototype.read=function(e,t){this._reads.push({length:Math.abs(e),allowLess:e<0,func:t})},n.prototype.process=function(){for(;this._reads.length>0&&this._buffer.length;){let e=this._reads[0];if(this._buffer.length&&(this._buffer.length>=e.length||e.allowLess)){this._reads.shift();let t=this._buffer;this._buffer=t.slice(e.length),e.func.call(this,t.slice(0,e.length))}else break}if(this._reads.length>0)throw Error(`There are some read requests waitng on finished stream`);if(this._buffer.length>0)throw Error(`unrecognised content at end of stream`)}})),b=t((e=>{let t=y(),n=o();e.process=function(e,r){let i=[],a=new t(e);return new n(r,{read:a.read.bind(a),write:function(e){i.push(e)},complete:function(){}}).start(),a.process(),Buffer.concat(i)}})),x=t(((t,n)=>{let r=!0,i=e(`zlib`),a=v();i.deflateSync||(r=!1);let o=y(),s=b(),c=u(),l=d(),p=f();n.exports=function(e,t){if(!r)throw Error(`To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0`);let n;function u(e){n=e}let d;function f(e){d=e}function m(e){d.transColor=e}function h(e){d.palette=e}function g(){d.alpha=!0}let _;function v(e){_=e}let y=[];function b(e){y.push(e)}let x=new o(e);if(new c(t,{read:x.read.bind(x),error:u,metadata:f,gamma:v,palette:h,transColor:m,inflateData:b,simpleTransparency:g}).start(),x.process(),n)throw n;let S=Buffer.concat(y);y.length=0;let C;if(d.interlace)C=i.inflateSync(S);else{let e=((d.width*d.bpp*d.depth+7>>3)+1)*d.height;C=a(S,{chunkSize:e,maxLength:e})}if(S=null,!C||!C.length)throw Error(`bad png - invalid inflate data response`);let w=s.process(C,d);S=null;let T=l.dataToBitMap(w,d);w=null;let E=p(T,d,t.skipRescale);return d.data=E,d.gamma=_||0,d}})),S=t(((t,n)=>{let r=!0,i=e(`zlib`);i.deflateSync||(r=!1);let a=c(),o=g();n.exports=function(e,t){if(!r)throw Error(`To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0`);let n=new o(t||{}),s=[];s.push(Buffer.from(a.PNG_SIGNATURE)),s.push(n.packIHDR(e.width,e.height)),e.gamma&&s.push(n.packGAMA(e.gamma));let c=n.filterData(e.data,e.width,e.height),l=i.deflateSync(c,n.getDeflateOptions());if(c=null,!l||!l.length)throw Error(`bad png - invalid compressed data response`);return s.push(n.packIDAT(l)),s.push(n.packIEND()),Buffer.concat(s)}})),C=t((e=>{let t=x(),n=S();e.read=function(e,n){return t(e,n||{})},e.write=function(e,t){return n(e,t)}})),w=t((t=>{let n=e(`util`),r=e(`stream`),i=p(),a=_(),o=C(),s=t.PNG=function(e){r.call(this),e||={},this.width=e.width|0,this.height=e.height|0,this.data=this.width>0&&this.height>0?Buffer.alloc(4*this.width*this.height):null,e.fill&&this.data&&this.data.fill(0),this.gamma=0,this.readable=this.writable=!0,this._parser=new i(e),this._parser.on(`error`,this.emit.bind(this,`error`)),this._parser.on(`close`,this._handleClose.bind(this)),this._parser.on(`metadata`,this._metadata.bind(this)),this._parser.on(`gamma`,this._gamma.bind(this)),this._parser.on(`parsed`,function(e){this.data=e,this.emit(`parsed`,e)}.bind(this)),this._packer=new a(e),this._packer.on(`data`,this.emit.bind(this,`data`)),this._packer.on(`end`,this.emit.bind(this,`end`)),this._parser.on(`close`,this._handleClose.bind(this)),this._packer.on(`error`,this.emit.bind(this,`error`))};n.inherits(s,r),s.sync=o,s.prototype.pack=function(){return!this.data||!this.data.length?(this.emit(`error`,`No data provided`),this):(process.nextTick(function(){this._packer.pack(this.data,this.width,this.height,this.gamma)}.bind(this)),this)},s.prototype.parse=function(e,t){if(t){let e,n;e=function(e){this.removeListener(`error`,n),this.data=e,t(null,this)}.bind(this),n=function(n){this.removeListener(`parsed`,e),t(n,null)}.bind(this),this.once(`parsed`,e),this.once(`error`,n)}return this.end(e),this},s.prototype.write=function(e){return this._parser.write(e),!0},s.prototype.end=function(e){this._parser.end(e)},s.prototype._metadata=function(e){this.width=e.width,this.height=e.height,this.emit(`metadata`,e)},s.prototype._gamma=function(e){this.gamma=e},s.prototype._handleClose=function(){!this._parser.writable&&!this._packer.readable&&this.emit(`close`)},s.bitblt=function(e,t,n,r,i,a,o,s){if(n|=0,r|=0,i|=0,a|=0,o|=0,s|=0,n>e.width||r>e.height||n+i>e.width||r+a>e.height)throw Error(`bitblt reading outside image`);if(o>t.width||s>t.height||o+i>t.width||s+a>t.height)throw Error(`bitblt writing outside image`);for(let c=0;c<a;c++)e.data.copy(t.data,(s+c)*t.width+o<<2,(r+c)*e.width+n<<2,(r+c)*e.width+n+i<<2)},s.prototype.bitblt=function(e,t,n,r,i,a,o){return s.bitblt(this,e,t,n,r,i,a,o),this},s.adjustGamma=function(e){if(e.gamma){for(let t=0;t<e.height;t++)for(let n=0;n<e.width;n++){let r=e.width*t+n<<2;for(let t=0;t<3;t++){let n=e.data[r+t]/255;n**=1/2.2/e.gamma,e.data[r+t]=Math.round(n*255)}}e.gamma=0}},s.prototype.adjustGamma=function(){s.adjustGamma(this)}}))();const T=Buffer.from([137,80,78,71,13,10,26,10]);function E(e){return e.subarray(0,T.length).equals(T)}function D(e,t){try{return w.PNG.sync.read(e)}catch(e){throw new n(`COMMAND_FAILED`,`Failed to decode ${t} as PNG`,{label:t,reason:e instanceof Error?e.message:String(e)})}}export{E as n,w as r,D as t};
|
package/dist/src/prepare-kind.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as e}from"./sdk-contracts.js";const t=[`auto`,`react-native`,`expo`,`repack`];function n(n){if(n!==void 0){if(t.includes(n))return n;throw new e(`INVALID_ARGS`,`metro prepare --kind must be auto, react-native, expo, or repack`)}}export{n as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{A as e}from"./sdk-contracts.js";import{c as t}from"./exec.js";import"./command.js";import n from"node:path";import r from"node:fs";import i from"node:crypto";import a from"node:os";function o(t,n){return new e(`COMMAND_FAILED`,`${t.label} not found or expired: ${n}`,{reason:`RESOURCE_EXPIRED`,hint:t.expiredHint})}function s(t,n,r,i){let a=t.get(n);if(!a)throw o(i,n);if(a.tenantId&&a.tenantId!==r)throw new e(`UNAUTHORIZED`,`${i.label} ${i.plural?`belong`:`belongs`} to a different tenant`);return a}const c=9e5,l={label:`Artifact`,expiredHint:`Downloadable artifacts are removed after download or after ${c/6e4} minutes. Re-run the command that produced the artifact and download it again.`},u=new Map;function d(e){let t=i.randomUUID(),n=Date.now(),r=setTimeout(()=>{C(t)},c);return r.unref(),u.set(t,{artifactPath:e.artifactPath,tenantId:e.tenantId,artifactType:e.artifactType,fileName:e.fileName,deleteAfterDownload:e.deleteAfterDownload!==!1,createdAt:n,timer:r}),t}async function f(t,n){let{entry:r,stat:i}=h(t,n),a=await g(t,r,i);if(!a)throw new e(`COMMAND_FAILED`,`Artifact path is not a regular file or directory: ${r.artifactPath}`);return a}async function p(e){let t=[];for(let[n,i]of u){if(!b(i,e))continue;let a;try{a=r.statSync(i.artifactPath)}catch{C(n);continue}let o=await m(n,i,a);o&&t.push({id:n,...i.artifactType===void 0?{}:{artifactType:i.artifactType},filename:o.fileName??n,mimeType:o.mimeType,sizeBytes:o.sizeBytes,createdAt:new Date(i.createdAt).toISOString(),expiresAt:new Date(i.createdAt+c).toISOString()})}return t}async function m(e,t,n){try{return await g(e,t,n)}catch{return null}}function h(t,n){let i=s(u,t,n,l),a;try{a=r.statSync(i.artifactPath)}catch{throw C(t),new e(`COMMAND_FAILED`,`Artifact file is missing: ${i.artifactPath}`)}return{entry:i,stat:a}}async function g(e,t,n){if(n.isFile())return{artifactPath:t.artifactPath,fileName:x(t.fileName,e),mimeType:`application/octet-stream`,sizeBytes:n.size};if(!n.isDirectory())return null;let r=await _(e,t);return{artifactPath:r.archivePath,fileName:r.fileName,mimeType:`application/gzip`,sizeBytes:r.sizeBytes}}async function _(e,t){if(t.directoryArchive&&r.existsSync(t.directoryArchive.archivePath))return t.directoryArchive;if(t.directoryArchivePromise)return await t.directoryArchivePromise;let n=v(e,t);t.directoryArchivePromise=n;try{return await n}finally{t.directoryArchivePromise===n&&(t.directoryArchivePromise=void 0)}}async function v(s,c){w(c);let d=y(x(c.fileName,n.basename(c.artifactPath)||s)),f=r.mkdtempSync(n.join(a.tmpdir(),`agent-device-download-${i.randomUUID()}-`)),p=n.join(f,d);try{await t(`tar`,[`czf`,p,`-C`,n.dirname(c.artifactPath),`--`,n.basename(c.artifactPath)],{env:{...process.env,COPYFILE_DISABLE:`1`}});let e={archivePath:p,tempDir:f,fileName:d,sizeBytes:r.statSync(p).size};if(u.get(s)!==c)throw r.rmSync(f,{recursive:!0,force:!0}),o(l,s);return c.directoryArchive=e,e}catch(t){throw r.rmSync(f,{recursive:!0,force:!0}),t instanceof e?t:new e(`COMMAND_FAILED`,`Failed to archive downloadable artifact: ${c.artifactPath}`,{artifactPath:c.artifactPath},t instanceof Error?t:void 0)}}function y(e){let t=e.toLowerCase();return t.endsWith(`.tar.gz`)||t.endsWith(`.tgz`)?e:`${e}.tar.gz`}function b(e,t){return!e.tenantId||e.tenantId===t}function x(e,t){let n=e?.trim();return n&&!S(n)?n:t}function S(e){return e.includes(`/`)||e.includes(`\\`)||e.includes(`\0`)||e.includes(`\r`)||e.includes(`
|
|
2
2
|
`)}function C(e){let t=u.get(e);if(t&&(clearTimeout(t.timer),u.delete(e),w(t),t.deleteAfterDownload))try{r.rmSync(t.artifactPath,{recursive:!0,force:!0})}catch{}}function w(e){if(e.directoryArchive)try{r.rmSync(e.directoryArchive.tempDir,{recursive:!0,force:!0})}catch{}finally{e.directoryArchive=void 0}}const T=3e5,E={label:`Uploaded artifact`,expiredHint:`Uploaded artifacts expire ${T/6e4} minutes after upload. Upload the file again and retry with the new upload id.`},D=new Map;function O(e){let t=i.randomUUID(),n=setTimeout(()=>{A(t)},T);return n.unref(),D.set(t,{artifactPath:e.artifactPath,tempDir:e.tempDir,tenantId:e.tenantId,timer:n}),t}function k(e,t){let n=s(D,e,t,E);return clearTimeout(n.timer),n.artifactPath}function A(e){let t=D.get(e);t&&(clearTimeout(t.timer),D.delete(e),r.rmSync(t.tempDir,{recursive:!0,force:!0}))}function j(e){let t=e?.providerSessionId;return typeof t==`string`&&t.trim().length>0?t.trim():void 0}var M=class{records=new Map;now;retentionMs;constructor(e={}){this.now=e.now??(()=>Date.now()),this.retentionMs=Number.isInteger(e.retentionMs)?Math.max(0,Number(e.retentionMs)):3e5}record(e,t){let n=e.leaseProvider?.trim(),r=t.trim();if(!n||!r)return;this.prune();let i={provider:n,providerSessionId:r,leaseId:e.leaseId,tenantId:e.tenantId};this.records.set(this.key(n,r),i)}markLeaseReleased(e,t=this.now()){let n=e.leaseProvider?.trim();if(!n)return;this.prune();let r=t+this.retentionMs;for(let[t,i]of this.records)i.provider===n&&i.leaseId===e.leaseId&&this.records.set(t,{...i,retainedUntil:r})}resolve(e){let t=e.provider?.trim(),n=e.providerSessionId?.trim(),r=e.tenantId?.trim();if(!t||!n||!r)return;this.prune();let i=this.records.get(this.key(t,n));if(!(!i||i.tenantId!==r))return{...i}}prune(){let e=this.now();for(let[t,n]of this.records)n.retainedUntil!==void 0&&n.retainedUntil<=e&&this.records.delete(t)}key(e,t){return JSON.stringify([e,t])}};export{p as a,d as c,A as i,O as l,j as n,f as o,C as r,k as s,M as t,s as u};
|