agent-device 0.18.2 → 0.19.0
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-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.18.2.apk → agent-device-android-multitouch-helper-0.19.0.apk} +0 -0
- package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.19.0.apk.sha256 +1 -0
- package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.18.2.manifest.json → agent-device-android-multitouch-helper-0.19.0.manifest.json} +4 -4
- package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.18.2.apk → agent-device-android-snapshot-helper-0.19.0.apk} +0 -0
- package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.19.0.apk.sha256 +1 -0
- package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.18.2.manifest.json → agent-device-android-snapshot-helper-0.19.0.manifest.json} +6 -6
- package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTapPointPolicy.swift +28 -0
- package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +9 -120
- package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +132 -66
- package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +155 -0
- package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +67 -0
- package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +20 -74
- package/dist/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +64 -0
- package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +0 -177
- package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +81 -48
- package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +102 -129
- package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +208 -46
- package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +82 -11
- package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +72 -0
- package/dist/src/agent-browser-tool.js +1 -0
- package/dist/src/android-adb.d.ts +64 -234
- package/dist/src/android-adb.js +1 -1
- package/dist/src/android.js +1 -5
- package/dist/src/app-lifecycle.js +7 -0
- package/dist/src/apple-runner-options.js +1 -0
- package/dist/src/apps.js +5 -11
- package/dist/src/artifacts.d.ts +4 -3
- package/dist/src/artifacts.js +1 -1
- package/dist/src/audio-probe.js +1 -1
- package/dist/src/batch.d.ts +2 -177
- package/dist/src/batch.js +1 -1
- package/dist/src/cli-help.js +64 -38
- package/dist/src/cli-output.js +1 -1
- package/dist/src/cli-runner.js +2 -0
- package/dist/src/cli.js +12 -41
- package/dist/src/client-metro-companion.js +1 -0
- package/dist/src/client.js +3 -0
- package/dist/src/command-metadata.js +1 -0
- package/dist/src/command-schema.js +22 -0
- package/dist/src/command-surface.js +1 -1
- package/dist/src/contracts.d.ts +2 -213
- package/dist/src/contracts.js +1 -1
- package/dist/src/debug-symbols.js +5 -3
- package/dist/src/device-input-state.js +2 -0
- package/dist/src/device-rotation.js +14 -0
- package/dist/src/devices.js +1 -1
- package/dist/src/devices2.js +1 -0
- package/dist/src/devices3.js +1 -0
- package/dist/src/find.js +1 -1
- package/dist/src/finders.d.ts +2 -81
- package/dist/src/finders.js +1 -1
- package/dist/src/generic.js +1 -1
- package/dist/src/handler-utils.js +1 -1
- package/dist/src/helper.js +2 -0
- package/dist/src/host-process.js +2 -0
- package/dist/src/index.d.ts +1265 -1768
- package/dist/src/index.js +1 -1
- package/dist/src/input-actions.js +3 -1
- package/dist/src/input-actions2.js +1 -0
- package/dist/src/install-source.d.ts +13 -14
- package/dist/src/install-source.js +1 -1
- package/dist/src/install-source2.js +1 -0
- package/dist/src/interaction-snapshot.js +1 -0
- package/dist/src/interaction.js +1 -1
- package/dist/src/interactor.js +2 -1
- package/dist/src/internal/bin.d.ts +1 -1
- package/dist/src/internal/bin.js +2 -5
- package/dist/src/internal/companion-tunnel.d.ts +1 -1
- package/dist/src/internal/companion-tunnel.js +1 -1
- package/dist/src/internal/daemon.d.ts +1 -1
- package/dist/src/internal/daemon.js +16 -1
- package/dist/src/internal/png-worker.d.ts +29 -26
- package/dist/src/internal/png-worker.js +1 -1
- package/dist/src/internal/update-check-entry.d.ts +1 -1
- package/dist/src/internal/update-check-entry.js +1 -1
- package/dist/src/io.d.ts +2 -85
- package/dist/src/io.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/linux.js +1 -1
- package/dist/src/logcat.js +6 -0
- package/dist/src/manifest.js +1 -0
- package/dist/src/metro.d.ts +70 -113
- package/dist/src/metro.js +1 -1
- package/dist/src/metro2.js +1 -0
- package/dist/src/notifications.js +1 -1
- package/dist/src/output-path.js +1 -0
- package/dist/src/path-resolution.js +1 -0
- package/dist/src/png-worker-contract.js +1 -0
- package/dist/src/points.js +4 -0
- package/dist/src/project-runtime.js +1 -0
- package/dist/src/provider.js +1 -1
- package/dist/src/providers.js +1 -0
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-trace-recording.js +2 -5
- package/dist/src/record-trace.js +1 -1
- package/dist/src/recording-provider.js +1 -1
- package/dist/src/registry.js +37 -0
- package/dist/src/remote-config.d.ts +2 -83
- package/dist/src/reporting.js +9 -0
- package/dist/src/rolldown-runtime.js +1 -0
- package/dist/src/runner-client.js +1 -0
- package/dist/src/runner-provider.js +1 -0
- package/dist/src/runner-sequence.js +1 -1
- package/dist/src/runtime-transport.js +1 -0
- package/dist/src/runtime.js +3 -0
- package/dist/src/scoped-provider.js +1 -0
- package/dist/src/sdk-android-adb.d.ts +144 -0
- package/dist/src/sdk-android-adb.js +4 -0
- package/dist/src/sdk-app-inventory.d.ts +4 -0
- package/dist/src/sdk-app-inventory.js +1 -0
- package/dist/src/sdk-batch-runner.d.ts +40 -0
- package/dist/src/sdk-batch-runner.js +2 -0
- package/dist/src/sdk-batch.js +2 -0
- package/dist/src/sdk-contracts.d.ts +386 -0
- package/dist/src/sdk-contracts.js +2 -0
- package/dist/src/sdk-finders.d.ts +61 -0
- package/dist/src/sdk-finders.js +1 -0
- package/dist/src/sdk-io.d.ts +79 -0
- package/dist/src/sdk-io.js +1 -0
- package/dist/src/sdk-remote-config.d.ts +140 -0
- package/dist/src/sdk-remote-config.js +1 -0
- package/dist/src/sdk-selectors.js +1 -0
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/selectors.d.ts +39 -137
- package/dist/src/selectors.js +1 -1
- package/dist/src/selectors2.js +1 -0
- package/dist/src/server.js +3 -2
- package/dist/src/session.js +10 -11
- package/dist/src/setting-state.js +1 -0
- package/dist/src/simctl.js +1 -0
- package/dist/src/simulator.js +1 -2
- package/dist/src/snapshot-diagnostics.js +3 -0
- package/dist/src/snapshot-helper.js +5 -0
- package/dist/src/snapshot-quality.js +1 -0
- package/dist/src/snapshot.js +1 -2
- package/dist/src/snapshot2.js +2 -0
- package/dist/src/{5560.js → timeouts.js} +1 -1
- package/dist/src/tool-provider.js +3 -0
- package/dist/src/tool-provider2.js +1 -0
- package/dist/src/ttl-memo.js +1 -0
- package/dist/src/update-check.js +1 -0
- package/dist/src/url.js +1 -0
- package/dist/src/version.js +1 -0
- package/dist/src/web.js +1 -1
- package/dist/src/xml.js +2 -0
- package/package.json +12 -19
- package/server.json +2 -2
- package/skills/agent-device/SKILL.md +2 -0
- package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.18.2.apk.sha256 +0 -1
- package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.18.2.apk.sha256 +0 -1
- package/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +0 -443
- package/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +0 -169
- package/apple-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +0 -220
- package/dist/src/1404.js +0 -1
- package/dist/src/1986.js +0 -1
- package/dist/src/2748.js +0 -1
- package/dist/src/2948.js +0 -30
- package/dist/src/3006.js +0 -1
- package/dist/src/314.js +0 -1
- package/dist/src/3340.js +0 -8
- package/dist/src/4418.js +0 -1
- package/dist/src/4428.js +0 -3
- package/dist/src/485.js +0 -1
- package/dist/src/4917.js +0 -1
- package/dist/src/495.js +0 -5
- package/dist/src/5448.js +0 -3
- package/dist/src/5484.js +0 -1
- package/dist/src/5643.js +0 -1
- package/dist/src/587.js +0 -1
- package/dist/src/5913.js +0 -4
- package/dist/src/6849.js +0 -1
- package/dist/src/6918.js +0 -1
- package/dist/src/6967.js +0 -1
- package/dist/src/760.js +0 -1
- package/dist/src/7871.js +0 -1
- package/dist/src/8184.js +0 -1
- package/dist/src/8225.js +0 -1
- package/dist/src/8391.js +0 -1
- package/dist/src/8404.js +0 -2
- package/dist/src/8414.js +0 -2
- package/dist/src/8875.js +0 -4
- package/dist/src/893.js +0 -1
- package/dist/src/8936.js +0 -1
- package/dist/src/9414.js +0 -1
- package/dist/src/9581.js +0 -22
- package/dist/src/9612.js +0 -1
- package/dist/src/9624.js +0 -1
- package/dist/src/9722.js +0 -38
- package/dist/src/devices~1.js +0 -1
- package/dist/src/devices~2.js +0 -1
- package/dist/src/input-actions~1.js +0 -1
- package/dist/src/rslib-runtime.js +0 -1
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.pbxproj +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/xcshareddata/xcschemes/AgentDeviceRunner.xcscheme +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests-Bridging-Header.h +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests.entitlements +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerObjCExceptionCatcher.h +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerObjCExceptionCatcher.m +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Environment.swift +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Exceptions.swift +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScreenRecorder.swift +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests.xctestplan +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/RecordingScripts/recording-overlay.swift +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/RecordingScripts/recording-resize.swift +0 -0
- /package/{apple-runner → dist/apple-runner}/AgentDeviceRunner/RecordingScripts/recording-trim.swift +0 -0
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
//#region src/utils/screenshot-diff-pixels.d.ts
|
|
2
|
+
type ScreenshotDiffPixelsResult = {
|
|
3
|
+
diffData: Buffer;
|
|
4
|
+
diffMask: Uint8Array;
|
|
5
|
+
differentPixels: number;
|
|
6
|
+
};
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/utils/png-worker-contract.d.ts
|
|
9
|
+
type PngWorkerJobResult = {
|
|
10
|
+
kind: 'decode';
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
data: Uint8Array;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'encode';
|
|
16
|
+
png: Uint8Array;
|
|
17
|
+
} | ({
|
|
18
|
+
kind: 'diff-pixels';
|
|
19
|
+
} & ScreenshotDiffPixelsResult);
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/utils/png-worker.d.ts
|
|
22
|
+
/**
|
|
23
|
+
* Transfers result buffers instead of structured-cloning them, but only when a
|
|
24
|
+
* view fully owns its ArrayBuffer. Exported for direct unit coverage; the
|
|
25
|
+
* worker itself is the only runtime caller.
|
|
26
|
+
*/
|
|
27
|
+
declare function resultTransferList(result: PngWorkerJobResult): ArrayBuffer[];
|
|
28
|
+
//#endregion
|
|
29
|
+
export { resultTransferList };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{B as e}from"../sdk-contracts.js";import{i as t,n,r,t as i}from"../png-worker-contract.js";import{parentPort as a}from"node:worker_threads";function o(e){switch(e.kind){case`decode`:{let t=r(i(e.png),e.label);return{kind:`decode`,width:t.width,height:t.height,data:t.data}}case`encode`:{let n=new t({width:e.width,height:e.height,data:i(e.data)});return{kind:`encode`,png:t.sync.write(n)}}case`diff-pixels`:return{kind:`diff-pixels`,...n(e)}}}function s(e){return e.buffer instanceof ArrayBuffer&&e.byteOffset===0&&e.byteLength===e.buffer.byteLength}function c(e){return l(e).filter(s).map(e=>e.buffer)}function l(e){switch(e.kind){case`decode`:return[e.data];case`encode`:return[e.png];case`diff-pixels`:return[e.diffData,e.diffMask]}}const u=a;u&&u.on(`message`,t=>{let n;try{n={id:t.id,ok:!0,result:o(t)}}catch(r){n={id:t.id,ok:!1,error:e(r)}}u.postMessage(n,n.ok?c(n.result):[])});export{c as resultTransferList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { }
|
|
1
|
+
export { };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as e,r as t}from"../update-check.js";const n=e(process.argv.slice(2));n&&t(n).catch(()=>{process.exitCode=0});export{};
|
package/dist/src/io.d.ts
CHANGED
|
@@ -1,85 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
reserveOutput(ref: FileOutputRef | undefined, options: ReserveOutputOptions): Promise<ReservedOutputFile>;
|
|
4
|
-
createTempFile(options: CreateTempFileOptions): Promise<TemporaryFile>;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export declare type ArtifactDescriptor = {
|
|
8
|
-
kind: 'localPath';
|
|
9
|
-
field: string;
|
|
10
|
-
path: string;
|
|
11
|
-
fileName?: string;
|
|
12
|
-
metadata?: Record<string, unknown>;
|
|
13
|
-
} | {
|
|
14
|
-
kind: 'artifact';
|
|
15
|
-
field: string;
|
|
16
|
-
artifactId: string;
|
|
17
|
-
fileName?: string;
|
|
18
|
-
url?: string;
|
|
19
|
-
clientPath?: string;
|
|
20
|
-
metadata?: Record<string, unknown>;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export declare function createLocalArtifactAdapter(options?: LocalArtifactAdapterOptions): ArtifactAdapter;
|
|
24
|
-
|
|
25
|
-
export declare type CreateTempFileOptions = {
|
|
26
|
-
prefix: string;
|
|
27
|
-
ext: string;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export declare type FileInputRef = {
|
|
31
|
-
kind: 'path';
|
|
32
|
-
path: string;
|
|
33
|
-
} | {
|
|
34
|
-
kind: 'uploadedArtifact';
|
|
35
|
-
id: string;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export declare type FileOutputRef = {
|
|
39
|
-
kind: 'path';
|
|
40
|
-
path: string;
|
|
41
|
-
} | {
|
|
42
|
-
kind: 'downloadableArtifact';
|
|
43
|
-
clientPath?: string;
|
|
44
|
-
fileName?: string;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export declare type LocalArtifactAdapterOptions = {
|
|
48
|
-
cwd?: string;
|
|
49
|
-
tempDir?: string;
|
|
50
|
-
rootDir?: string;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export declare type OutputVisibility = 'client-visible' | 'internal';
|
|
54
|
-
|
|
55
|
-
export declare type ReservedOutputFile = {
|
|
56
|
-
path: string;
|
|
57
|
-
visibility: OutputVisibility;
|
|
58
|
-
publish: () => Promise<ArtifactDescriptor | undefined>;
|
|
59
|
-
cleanup?: () => Promise<void>;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export declare type ReserveOutputOptions = {
|
|
63
|
-
field: string;
|
|
64
|
-
ext: string;
|
|
65
|
-
requestedClientPath?: string;
|
|
66
|
-
visibility?: OutputVisibility;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export declare type ResolvedInputFile = {
|
|
70
|
-
path: string;
|
|
71
|
-
cleanup?: () => Promise<void>;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export declare type ResolveInputOptions = {
|
|
75
|
-
usage: string;
|
|
76
|
-
field?: string;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export declare type TemporaryFile = {
|
|
80
|
-
path: string;
|
|
81
|
-
visibility: 'internal';
|
|
82
|
-
cleanup: () => Promise<void>;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export { }
|
|
1
|
+
import { a as FileOutputRef, c as ReserveOutputOptions, d as ResolvedInputFile, f as TemporaryFile, i as FileInputRef, l as ReservedOutputFile, n as ArtifactDescriptor, o as LocalArtifactAdapterOptions, p as createLocalArtifactAdapter, r as CreateTempFileOptions, s as OutputVisibility, t as ArtifactAdapter, u as ResolveInputOptions } from "./sdk-io.js";
|
|
2
|
+
export { ArtifactAdapter, ArtifactDescriptor, CreateTempFileOptions, FileInputRef, FileOutputRef, LocalArtifactAdapterOptions, OutputVisibility, ReserveOutputOptions, ReservedOutputFile, ResolveInputOptions, ResolvedInputFile, TemporaryFile, createLocalArtifactAdapter };
|
package/dist/src/io.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{t as e}from"./sdk-io.js";export{e as createLocalArtifactAdapter};
|
package/dist/src/lease.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{F as e}from"./sdk-contracts.js";import{w as t}from"./sdk-batch.js";import{Cn as n,En as r,On as i,bn as a}from"./device-rotation.js";import{Lt as o,Rt as s,gn as c}from"./internal/daemon.js";async function l(e){let{req:a,sessionName:c,sessionStore:l,leaseRegistry:d,leaseLifecycleProvider:f,cloudArtifactProvider:p}=e,m=o(a);switch(a.command){case t.artifacts:return{ok:!0,data:await u(a,s(a,l.get(c)),p)};case`lease_allocate`:{let e=d.allocateLease(n(m)),t;try{t=await f?.allocate?.(e,{req:a})}catch(t){throw d.releaseLease(i({leaseId:e.leaseId,tenantId:e.tenantId,runId:e.runId,leaseBackend:e.backend,leaseProvider:e.leaseProvider,deviceKey:e.deviceKey,clientId:e.clientId})),t}return{ok:!0,data:{lease:e,...t?{provider:t}:{}}}}case`lease_heartbeat`:{let e=d.heartbeatLease(r(m)),t=await f?.heartbeat?.(e,{req:a});return{ok:!0,data:{lease:e,...t?{provider:t}:{}}}}case`lease_release`:{let e=d.releaseLease(i(m)),t=e.lease?await f?.release?.(e.lease,{req:a}):void 0;return{ok:!0,data:{released:e.released,...t?{provider:t}:{}}}}default:return null}}async function u(e,t,n){let r=m(e.flags,`providerSessionId`);return d(t,r)?await f(t.tenantId):await p(t,r,n)}function d(e,t){return a(e)||!e.leaseProvider&&!t}async function f(e){let t=await c(e);return{source:`daemon`,status:`ready`,artifacts:t,...t.length===0?{message:`No daemon artifacts available.`}:{}}}async function p(t,n,r){if(!t.leaseProvider)throw new e(`INVALID_ARGS`,`artifacts requires --provider for provider session lookup or an active cloud connection.`);if(!t.leaseId&&!n)throw new e(`INVALID_ARGS`,`artifacts requires an active cloud lease or --provider-session <id>.`);let i=await r?.listCloudArtifacts?.({provider:t.leaseProvider,leaseId:t.leaseId,providerSessionId:n});if(!i)throw new e(`UNSUPPORTED_OPERATION`,`Cloud artifacts are not available for provider "${t.leaseProvider}".`);return i}function m(e,t){let n=e?.[t];return typeof n==`string`&&n.length>0?n:void 0}export{l as handleLeaseCommands};
|
package/dist/src/linux.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{F as e}from"./sdk-contracts.js";import{F as t}from"./sdk-android-adb.js";import{t as n}from"./snapshot.js";import{t as r}from"./tool-provider2.js";import{doubleClickLinux as i,fillLinux as a,focusLinux as o,longPressLinux as s,pressLinux as c,scrollLinux as l,sendKey as u,swipeLinux as d,typeLinux as f}from"./input-actions2.js";async function p(e){await r().desktop.openTarget(e)}async function m(e){await r().desktop.closeApp(e)}async function h(){await u(`alt+Left`,[`56:1`,`105:1`,`105:0`,`56:0`])}async function g(){await u(`super+d`,[`125:1`,`32:1`,`32:0`,`125:0`])}async function _(){return await r().clipboard.readText()}async function v(e){await r().clipboard.writeText(e)}async function y(e,t){await r().screenshot.capture(e,t)}function b(){return{open:e=>p(e),openDevice:()=>Promise.resolve(),close:e=>m(e),tap:(e,t)=>c(e,t),doubleTap:(e,t)=>i(e,t),swipe:(e,t,n,r,i)=>d(e,t,n,r,i),pan:(e,t,n,r,i)=>d(e,t,n,r,i),fling:()=>{throw new e(`UNSUPPORTED_OPERATION`,`gesture fling not supported on Linux`)},longPress:(e,t,n)=>s(e,t,n),focus:(e,t)=>o(e,t),type:(e,t)=>f(e,t),fill:(e,t,n,r)=>a(e,t,n,r),scroll:(e,t)=>l(e,t),pinch:()=>{throw new e(`UNSUPPORTED_OPERATION`,`gesture pinch not supported on Linux`)},screenshot:(e,t)=>y(e,t),snapshot:async e=>{let r=await t(`snapshot_capture`,async()=>await n(e?.surface),{backend:`linux-atspi`});return{nodes:r.nodes??[],truncated:r.truncated??!1,backend:`linux-atspi`}},back:()=>h(),home:()=>g(),rotate:()=>{throw new e(`UNSUPPORTED_OPERATION`,`rotate not supported on Linux`)},rotateGesture:()=>{throw new e(`UNSUPPORTED_OPERATION`,`gesture rotate not supported on Linux`)},transformGesture:()=>{throw new e(`UNSUPPORTED_OPERATION`,`gesture transform not supported on Linux`)},appSwitcher:()=>{throw new e(`UNSUPPORTED_OPERATION`,`appSwitcher not yet supported on Linux`)},readClipboard:()=>_(),writeClipboard:e=>v(e),setSetting:()=>{throw new e(`UNSUPPORTED_OPERATION`,`setSetting not supported on Linux`)}}}export{b as createLinuxInteractor};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{t as e}from"./rolldown-runtime.js";import{F as t,I as n}from"./sdk-contracts.js";import{b as r,c as i,h as a,j as o,n as s,r as c,v as l,w as u}from"./sdk-android-adb.js";import{t as d}from"./timeouts.js";import{n as f,t as p}from"./manifest.js";import{n as m,t as h}from"./install-source2.js";import"node:fs";import g from"node:path";function _(e){let t=e.trim();if(!t||/\s/.test(t))return!1;let n=/^([A-Za-z][A-Za-z0-9+.-]*):(.+)$/.exec(t);if(!n)return!1;let r=n[1]?.toLowerCase(),i=n[2]??``;return r===`http`||r===`https`||r===`ws`||r===`wss`||r===`ftp`||r===`ftps`?i.startsWith(`//`):!0}function v(e){let t=e.trim().split(`:`)[0]?.toLowerCase();return t===`http`||t===`https`}function ee(e,t){let n=e?.trim();if(n)return n;if(v(t))return`com.apple.mobilesafari`}function te(e={}){let t=e.ttlMs??3e4,n=e.nowMs??Date.now,r=new Map,i=e=>{let t=ne(e);for(let e of r.keys())e.startsWith(t)&&r.delete(e)};return{get(e,t){let i=y(e,t),a=r.get(i);if(a){if(a.expiresAtMs<=n()){r.delete(i);return}return a.value}},set(e,i,a){return r.set(y(e,i),{value:a,expiresAtMs:n()+t}),a},clear(e){i(e)},async invalidateWhile(e,t){i(e);try{return await t()}finally{i(e)}}}}function y(e,t){return[e.platform,e.deviceId,e.variant??``,t.trim().toLowerCase()].join(`\0`)}function ne(e){return[e.platform,e.deviceId,``].join(`\0`)}function b(e){return[`1`,`true`,`yes`,`on`].includes((e??``).trim().toLowerCase())}const x={attempts:3,baseDelayMs:200,maxDelayMs:2e3,jitter:.2};var S=class e{startedAtMs;expiresAtMs;constructor(e,t){this.startedAtMs=e,this.expiresAtMs=e+Math.max(0,t)}static fromTimeoutMs(t,n=Date.now()){return new e(n,t)}remainingMs(e=Date.now()){return Math.max(0,this.expiresAtMs-e)}elapsedMs(e=Date.now()){return Math.max(0,e-this.startedAtMs)}isExpired(e=Date.now()){return this.remainingMs(e)<=0}};async function C(e,n={},r={}){let i={maxAttempts:n.maxAttempts??x.attempts,baseDelayMs:n.baseDelayMs??x.baseDelayMs,maxDelayMs:n.maxDelayMs??x.maxDelayMs,jitter:n.jitter??x.jitter,shouldRetry:n.shouldRetry},a;for(let n=1;n<=i.maxAttempts;n+=1){if(r.signal?.aborted)throw new t(`COMMAND_FAILED`,`request canceled`,{reason:`request_canceled`});if(r.deadline?.isExpired()&&n>1)break;try{let t=await e({attempt:n,maxAttempts:i.maxAttempts,deadline:r.deadline});return r.onEvent?.({phase:r.phase,event:`succeeded`,attempt:n,maxAttempts:i.maxAttempts,elapsedMs:r.deadline?.elapsedMs(),remainingMs:r.deadline?.remainingMs()}),T({phase:r.phase,event:`succeeded`,attempt:n,maxAttempts:i.maxAttempts,elapsedMs:r.deadline?.elapsedMs(),remainingMs:r.deadline?.remainingMs()}),t}catch(e){a=e;let t=r.classifyReason?.(e),o={phase:r.phase,event:`attempt_failed`,attempt:n,maxAttempts:i.maxAttempts,elapsedMs:r.deadline?.elapsedMs(),remainingMs:r.deadline?.remainingMs(),reason:t};if(r.onEvent?.(o),T(o),n>=i.maxAttempts||i.shouldRetry&&!i.shouldRetry(e,n))break;let s=ie(i.baseDelayMs,i.maxDelayMs,i.jitter,n),c=r.deadline?Math.min(s,r.deadline.remainingMs()):s;if(c<=0)break;let l={phase:r.phase,event:`retry_scheduled`,attempt:n,maxAttempts:i.maxAttempts,delayMs:c,elapsedMs:r.deadline?.elapsedMs(),remainingMs:r.deadline?.remainingMs(),reason:t};r.onEvent?.(l),T(l),await w(c,r.signal)}}let o={phase:r.phase,event:`exhausted`,attempt:i.maxAttempts,maxAttempts:i.maxAttempts,elapsedMs:r.deadline?.elapsedMs(),remainingMs:r.deadline?.remainingMs(),reason:r.classifyReason?.(a)};throw r.onEvent?.(o),T(o),a||new t(`COMMAND_FAILED`,`retry failed`)}async function re(e,t={}){return C(()=>e(),{maxAttempts:t.attempts,baseDelayMs:t.baseDelayMs,maxDelayMs:t.maxDelayMs,jitter:t.jitter,shouldRetry:t.shouldRetry})}function ie(e,t,n,r){let i=Math.min(t,e*2**(r-1)),a=i*n;return Math.max(0,i+(Math.random()*2-1)*a)}function w(e,t){return new Promise(n=>{if(t?.aborted){n();return}let r=!1,i=()=>{r||(r=!0,t&&t.removeEventListener(`abort`,o),n())},a=setTimeout(i,e);function o(){clearTimeout(a),i()}t&&t.addEventListener(`abort`,o,{once:!0})})}function T(e){o({level:e.event===`attempt_failed`||e.event===`exhausted`?`warn`:`debug`,phase:`retry`,data:{...e}})}function E(e){return e?.trim()||void 0}function ae(e){return E(e)}function D(e){return new Set(e.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean))}function O(e,t=process.env){let n=E(e)??E(t.AGENT_DEVICE_ANDROID_DEVICE_ALLOWLIST);if(n)return D(n)}const oe=new Set([`IOS_BOOT_TIMEOUT`,`IOS_RUNNER_CONNECT_TIMEOUT`,`IOS_TOOL_MISSING`,`ANDROID_BOOT_TIMEOUT`,`ADB_TRANSPORT_UNAVAILABLE`,`CI_RESOURCE_STARVATION_SUSPECTED`]);function se(e){return oe.has(e.toUpperCase())}function k(e){let t=e.error?n(e.error):null,r=e.context?.platform,i=e.context?.phase;if(t?.code===`TOOL_MISSING`)return r===`android`?`ADB_TRANSPORT_UNAVAILABLE`:`IOS_TOOL_MISSING`;let a=t?.details??{},o=typeof a.message==`string`?a.message:void 0,s=typeof a.stdout==`string`?a.stdout:void 0,c=typeof a.stderr==`string`?a.stderr:void 0,l=a.boot&&typeof a.boot==`object`?a.boot:null,u=a.bootstatus&&typeof a.bootstatus==`object`?a.bootstatus:null,d=[e.message,t?.message,e.stdout,e.stderr,o,s,c,typeof l?.stdout==`string`?l.stdout:void 0,typeof l?.stderr==`string`?l.stderr:void 0,typeof u?.stdout==`string`?u.stdout:void 0,typeof u?.stderr==`string`?u.stderr:void 0].filter(Boolean).join(`
|
|
2
|
+
`).toLowerCase();return r===`ios`&&(d.includes(`runner did not accept connection`)||i===`connect`&&(d.includes(`timed out`)||d.includes(`timeout`)||d.includes(`econnrefused`)||d.includes(`connection refused`)||d.includes(`fetch failed`)||d.includes(`socket hang up`)))?`IOS_RUNNER_CONNECT_TIMEOUT`:r===`ios`&&i===`boot`&&(d.includes(`timed out`)||d.includes(`timeout`))?`IOS_BOOT_TIMEOUT`:r===`android`&&i===`boot`&&(d.includes(`timed out`)||d.includes(`timeout`))?`ANDROID_BOOT_TIMEOUT`:d.includes(`resource temporarily unavailable`)||d.includes(`killed: 9`)||d.includes(`cannot allocate memory`)||d.includes(`system is low on memory`)?`CI_RESOURCE_STARVATION_SUSPECTED`:r===`android`&&(d.includes(`device not found`)||d.includes(`no devices`)||d.includes(`device offline`)||d.includes(`offline`)||d.includes(`unauthorized`)||d.includes(`not authorized`)||d.includes(`unable to locate device`)||d.includes(`invalid device`))?`ADB_TRANSPORT_UNAVAILABLE`:t?.code===`COMMAND_FAILED`||d.length>0?`BOOT_COMMAND_FAILED`:`UNKNOWN`}function A(e){switch(e){case`IOS_BOOT_TIMEOUT`:return`Retry simulator boot and inspect simctl bootstatus logs; in CI reduce parallel jobs or use a larger runner.`;case`IOS_RUNNER_CONNECT_TIMEOUT`:return`Retry runner startup, inspect xcodebuild logs, and verify simulator responsiveness before command execution.`;case`ANDROID_BOOT_TIMEOUT`:return`Retry emulator startup and verify sys.boot_completed reaches 1; consider increasing startup budget in CI.`;case`ADB_TRANSPORT_UNAVAILABLE`:return`Check adb server/device transport (adb devices -l), restart adb, and ensure the target device is online and authorized.`;case`CI_RESOURCE_STARVATION_SUSPECTED`:return`CI machine may be resource constrained; reduce parallel jobs or use a larger runner.`;case`IOS_TOOL_MISSING`:return`Xcode command-line tools are missing or not in PATH; run xcode-select --install and verify xcrun works.`;case`BOOT_COMMAND_FAILED`:return`Inspect command stderr/stdout for the failing boot phase and retry after environment validation.`;default:return`Retry once and inspect verbose logs for the failing phase.`}}var ce=e({ensureAndroidEmulatorBooted:()=>Z,listAndroidDevices:()=>K,parseAndroidAvdList:()=>J,parseAndroidEmulatorAvdNameOutput:()=>R,parseAndroidFeatureListForTv:()=>G,parseAndroidTargetFromCharacteristics:()=>W,resolveAndroidAvdName:()=>Y,resolveAndroidEmulatorAvdName:()=>U,waitForAndroidBoot:()=>Q});const j=1e3,M=1e4,le=[`android.software.leanback`,`android.software.leanback_only`,`android.hardware.type.television`];async function N(e,t,n){let r=Array(e.length),i=0,a=Math.min(t,e.length);return await Promise.all(Array.from({length:a},async()=>{for(;i<e.length;){let t=i;i+=1,r[t]=await n(e[t])}})),r}function P(e){return`${e.stdout}\n${e.stderr}`}function F(e,t){return[`-s`,e,...t]}function I(e){return e.startsWith(`emulator-`)}function L(e){return e.toLowerCase().replace(/_/g,` `).replace(/\s+/g,` `).trim()}function R(e){let t=e.split(`
|
|
3
|
+
`).map(e=>e.trim()).filter(e=>e.length>0);if(t.length!==0)return t.at(-1)===`OK`&&t.pop(),t.join(`
|
|
4
|
+
`).trim()||void 0}async function z(e,t=M){return l(`adb`,F(e,[`shell`,`getprop`,`sys.boot_completed`]),{allowFailure:!0,timeoutMs:t})}async function B(e,t){let n=t.replace(/_/g,` `).trim();if(!I(e))return n||e;let r=await U(e);return r?r.replace(/_/g,` `):n||e}async function V(e,t,r){try{return await r(`adb`,F(e,t),{allowFailure:!0,timeoutMs:1e4})}catch(e){if(H(n(e)))return;throw e}}function H(e){return e.code===`COMMAND_FAILED`&&typeof e.details?.timeoutMs==`number`}async function U(e,t=l){for(let n of[`ro.boot.qemu.avd_name`,`persist.sys.avd_name`]){let r=await V(e,[`shell`,`getprop`,n],t);if(!r)continue;let i=r.stdout.trim();if(r.exitCode===0&&i.length>0)return i}let n=await V(e,[`emu`,`avd`,`name`],t);if(!n)return;let r=R(n.stdout);if(n.exitCode===0&&r)return r}function W(e){let t=e.toLowerCase();return t.includes(`tv`)||t.includes(`leanback`)?`tv`:null}function G(e){return/feature:android\.(software\.leanback(_only)?|hardware\.type\.television)\b/i.test(e)}async function ue(e,t){let n=P(await l(`adb`,F(e,[`shell`,`cmd`,`package`,`has-feature`,t]),{allowFailure:!0,timeoutMs:M})).toLowerCase();return n.includes(`true`)?!0:n.includes(`false`)?!1:null}async function de(e){return(await N(le,2,async t=>await ue(e,t))).some(e=>e===!0)}async function fe(e){return W(P(await l(`adb`,F(e,[`shell`,`getprop`,`ro.build.characteristics`]),{allowFailure:!0,timeoutMs:M})))===`tv`||await de(e)||G(P(await l(`adb`,F(e,[`shell`,`pm`,`list`,`features`]),{allowFailure:!0,timeoutMs:M})))?`tv`:`mobile`}async function K(e={}){if(await f(),!await u(`adb`))throw new t(`TOOL_MISSING`,`adb not found in PATH`);let n=e.serialAllowlist??O(void 0),r=await N((await q()).filter(e=>!n||n.has(e.serial)),3,async({serial:e,rawModel:t})=>{let[n,r,i]=await Promise.all([B(e,t),ye(e),fe(e)]);return{platform:`android`,id:e,name:n,kind:I(e)?`emulator`:`device`,target:i,booted:r}});return[...r,...await me(r)]}function pe(e){return e.split(`
|
|
5
|
+
`).map(e=>e.trim()).filter(e=>e.length>0&&!e.startsWith(`List of devices`)).map(e=>e.split(/\s+/)).flatMap(e=>{let t=e[0];return t===void 0||e[1]!==`device`?[]:[{serial:t,rawModel:(e.find(e=>e.startsWith(`model:`))??``).replace(`model:`,``)}]})}async function q(){try{return pe((await l(`adb`,[`devices`,`-l`],{timeoutMs:M})).stdout)}catch(e){throw c(e)}}function J(e){return e.split(`
|
|
6
|
+
`).map(e=>e.trim()).filter(e=>e.length>0)}function Y(e,t){let n=e.find(e=>e===t);if(n)return n;let r=L(t);return e.find(e=>L(e)===r)}async function X(){return J(a(await l(`emulator`,[`-list-avds`],{allowFailure:!0,timeoutMs:M}),`Failed to list Android emulator AVDs`,{hint:`Verify Android emulator tooling is installed and available in PATH.`}).stdout)}async function me(e){let t=await X().catch(()=>[]),n=new Set(e.filter(e=>e.kind===`emulator`).map(e=>L(e.name)));return t.filter(e=>!n.has(L(e))).map(e=>({platform:`android`,id:e,name:e,kind:`emulator`,target:he(e),booted:!1}))}function he(e){return/\b(tv|television)\b/i.test(L(e))?`tv`:`mobile`}function ge(e,t,n){let r=L(t);return e.find(e=>e.platform!==`android`||e.kind!==`emulator`||n&&e.id!==n?!1:L(e.name)===r)}async function _e(e){let n=Date.now(),r=Math.min(1e3,Math.max(50,Math.floor(e.timeoutMs/20)));for(;Date.now()-n<e.timeoutMs;){try{let t=await ve(e.avdName,e.serial);if(t)return{platform:`android`,id:t,name:e.avdName,kind:`emulator`,target:`mobile`,booted:!1}}catch{}await d(r)}throw new t(`COMMAND_FAILED`,`Android emulator did not appear in time`,{avdName:e.avdName,serial:e.serial,timeoutMs:e.timeoutMs,hint:`Check emulator logs and verify the AVD can start from command line.`})}async function ve(e,t){let n=L(e),r=(await q()).filter(e=>t&&e.serial!==t?!1:I(e.serial));for(let e of r)if(L(e.rawModel)===n||L(await B(e.serial,e.rawModel))===n)return e.serial}async function ye(e){try{return(await z(e)).stdout.trim()===`1`}catch{return!1}}async function Z(e){await f();let n=e.avdName.trim();if(!n)throw new t(`INVALID_ARGS`,`Android emulator boot requires a non-empty AVD name.`);let i=e.timeoutMs??12e4;if(!await u(`adb`))throw new t(`TOOL_MISSING`,`adb not found in PATH`);if(!await u(`emulator`))throw new t(`TOOL_MISSING`,`emulator not found in PATH`);let a=await X(),o=Y(a,n);if(!o)throw new t(`DEVICE_NOT_FOUND`,`No Android emulator AVD named ${e.avdName}`,{requestedAvdName:n,availableAvds:a,hint:"Run `emulator -list-avds` and pass an existing AVD name to --device."});let s=Date.now(),c=ge(await K(),o,e.serial),l=c&&I(c.id)?c:void 0;if(!l){let t=[`-avd`,o];e.headless&&t.push(`-no-window`,`-no-audio`),r(`emulator`,t)}let d=l??await _e({avdName:o,serial:e.serial,timeoutMs:i}),p=Date.now()-s,m=Math.max(1e3,i-p);await Q(d.id,m);let h=(await K()).find(e=>e.id===d.id);return h?{...h,name:o,booted:!0}:{...d,name:o,booted:!0}}async function Q(e,r=6e4){let i=r,a=S.fromTimeoutMs(i),o=Math.max(1,Math.ceil(i/j)),s,c=!1;try{await C(async({deadline:n})=>{if(n?.isExpired())throw c=!0,new t(`COMMAND_FAILED`,`Android boot deadline exceeded`,{serial:e,timeoutMs:r,elapsedMs:a.elapsedMs(),message:`timeout`});let o=Math.max(1e3,n?.remainingMs()??i),l=await z(e,Math.min(o,M));if(s=l,l.stdout.trim()!==`1`)throw new t(`COMMAND_FAILED`,`Android device is still booting`,{serial:e,stdout:l.stdout,stderr:l.stderr,exitCode:l.exitCode})},{maxAttempts:o,baseDelayMs:j,maxDelayMs:j,jitter:0,shouldRetry:e=>{let t=k({error:e,stdout:s?.stdout,stderr:s?.stderr,context:{platform:`android`,phase:`boot`}});return t!==`ADB_TRANSPORT_UNAVAILABLE`&&t!==`ANDROID_BOOT_TIMEOUT`}},{deadline:a,phase:`boot`,classifyReason:e=>k({error:e,stdout:s?.stdout,stderr:s?.stderr,context:{platform:`android`,phase:`boot`}})})}catch(r){let o=n(r),l=s?.stdout,u=s?.stderr,d=s?.exitCode,f=k({error:r,stdout:l,stderr:u,context:{platform:`android`,phase:`boot`}});f===`BOOT_COMMAND_FAILED`&&o.message===`Android device is still booting`&&(f=`ANDROID_BOOT_TIMEOUT`);let p={serial:e,timeoutMs:i,elapsedMs:a.elapsedMs(),reason:f,hint:A(f),stdout:l,stderr:u,exitCode:d};throw c||f===`ANDROID_BOOT_TIMEOUT`?new t(`COMMAND_FAILED`,`Android device did not finish booting in time`,p):o.code===`TOOL_MISSING`?new t(`TOOL_MISSING`,o.message,{...p,...o.details??{}}):f===`ADB_TRANSPORT_UNAVAILABLE`?new t(`COMMAND_FAILED`,o.message,{...p,...o.details??{}}):new t(o.code,o.message,{...p,...o.details??{}},o.cause)}}async function be(e,t,n){return await i(e)(t,n)}function xe(e){return{platform:`android`,id:e,name:e,kind:e.startsWith(`emulator-`)?`emulator`:`device`,booted:!0}}function Se(e,t){let n=`${e}\n${t}`.toLowerCase();return n.includes(`no shell command implementation`)||n.includes(`unknown command`)}var Ce=e({prepareAndroidInstallArtifact:()=>$});async function $(e,t){let n=e.kind===`url`&&h(e.url),r=await m({source:e,isInstallablePath:(e,t)=>t.isFile()&&we(e),installableLabel:`Android installable (.apk or .aab)`,allowArchiveExtraction:e.kind!==`url`||n,signal:t?.signal});try{let e=t?.resolveIdentity===!1?{}:await Te(r.installablePath);return{archivePath:r.archivePath,installablePath:r.installablePath,packageName:e.packageName,cleanup:r.cleanup}}catch(e){throw await r.cleanup(),e}}function we(e){let t=g.extname(e).toLowerCase();return t===`.apk`||t===`.aab`}async function Te(e){let t=g.extname(e).toLowerCase();return t!==`.apk`&&t!==`.aab`?{}:{packageName:await p(e)}}async function Ee(e,t={}){let n=[`logcat`,`-d`,`-v`,`time`];t.lines!==void 0&&n.push(`-t`,String(Math.max(1,Math.floor(t.lines))));let r=await e(n,{allowFailure:!0,timeoutMs:t.timeoutMs,signal:t.signal});if(r.exitCode!==0)throw s(`Failed to capture Android logcat`,r);return r.stdout}function De(e,n={}){if(!e.spawn)throw new t(`UNSUPPORTED_OPERATION`,`Android ADB provider does not support streams`,{capability:`adb.spawn`});let r=[`logcat`,`-v`,`time`];n.pid&&r.push(`--pid`,n.pid);let i=e.spawn(r,{stdio:[`ignore`,`pipe`,`pipe`],signal:n.signal});return n.output&&i.stdout&&i.stdout.pipe(n.output,{end:!1}),i}export{ee as C,v as S,b as _,xe as a,te as b,ce as c,k as d,se as f,S as g,ae as h,$ as i,Q as l,O as m,De as n,Se as o,D as p,Ce as r,be as s,Ee as t,A as u,C as v,_ as x,re as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{m as e,v as t}from"./sdk-android-adb.js";import{promises as n}from"node:fs";import r from"node:os";import i from"node:path";import a from"node:fs/promises";import{TextDecoder as o}from"node:util";const s=[`emulator`,`platform-tools`,i.join(`cmdline-tools`,`latest`,`bin`),i.join(`cmdline-tools`,`tools`,`bin`)];function c(e){let t=new Set,n=[];for(let r of e){let e=r.trim();!e||t.has(e)||(t.add(e),n.push(e))}return n}function l(e=process.env){let t=e.ANDROID_SDK_ROOT?.trim(),n=e.ANDROID_HOME?.trim(),a=e.HOME?.trim()||r.homedir(),o=a?i.join(a,`Android`,`Sdk`):``;return c([t??``,n??``,o])}async function u(e){try{return await n.access(e,n.constants.X_OK),!0}catch{return!1}}async function d(e=process.env){let t=[],n;for(let r of l(e)){let e=[];for(let t of s){let n=i.join(r,t);await u(n)&&e.push(n)}e.length!==0&&(n||=r,t.push(...e))}if(n&&(e.ANDROID_SDK_ROOT=e.ANDROID_SDK_ROOT?.trim()||n,e.ANDROID_HOME=e.ANDROID_HOME?.trim()||n),t.length===0)return;let r=(e.PATH??``).split(i.delimiter).map(e=>e.trim()).filter(e=>e.length>0);e.PATH=c([...t,...r]).join(i.delimiter)}const f=new o(`utf-16le`);let p;async function m(e){for(let t of[`AndroidManifest.xml`,`base/manifest/AndroidManifest.xml`]){let n=await h(e,t);if(!n)continue;let r=g(n);if(r)return r}return await T(e)}async function h(e,n){try{let r=await t(`unzip`,[`-p`,e,n],{allowFailure:!0,binaryStdout:!0});return r.exitCode!==0||!r.stdoutBuffer||r.stdoutBuffer.length===0?void 0:r.stdoutBuffer}catch{return}}function g(e){return e.subarray(0,Math.min(e.length,128)).toString(`utf8`).trimStart().startsWith(`<`)?_(e.toString(`utf8`)):v(e)}function _(e){return e.match(/<manifest\b[^>]*\bpackage\s*=\s*["']([^"']+)["']/i)?.[1]}function v(e){if(e.length<8||e.readUInt16LE(0)!==3)return;let t;for(let n=e.readUInt16LE(2);n+8<=e.length;){let r=e.readUInt16LE(n),i=e.readUInt16LE(n+2),a=e.readUInt32LE(n+4);if(a<=0||n+a>e.length)return;if(r===1)t=b(e.subarray(n,n+a));else if(r===258&&t){let r=y(e,n,i,t);if(r)return r}n+=a}}function y(e,t,n,r){if(n<36||t+n>e.length||r[e.readUInt32LE(t+20)]!==`manifest`)return;let i=e.readUInt16LE(t+24),a=e.readUInt16LE(t+26),o=e.readUInt16LE(t+28),s=t+i;for(let t=0;t<o;t+=1){let n=s+t*a;if(n+20>e.length)return;if(r[e.readUInt32LE(n+4)]!==`package`)continue;let i=e.readUInt32LE(n+8);if(i!==4294967295)return r[i];let o=e.readUInt8(n+15),c=e.readUInt32LE(n+16);return o===3?r[c]:void 0}}function b(e){if(e.length<28)return[];let t=e.readUInt32LE(8),n=e.readUInt32LE(16),r=e.readUInt32LE(20),i=(n&256)!=0,a=[];for(let n=0;n<t;n+=1){let t=28+n*4;if(t+4>e.length)return a;let o=r+e.readUInt32LE(t);a.push(i?x(e,o):S(e,o))}return a}function x(e,t){let[,n]=C(e,t),[r,i]=C(e,t+n),a=t+n+i;return e.subarray(a,a+r).toString(`utf8`)}function S(e,t){let[n,r]=w(e,t),i=t+r;return f.decode(e.subarray(i,i+n*2))}function C(e,t){let n=e.readUInt8(t);if(!(n&128))return[n,1];let r=e.readUInt8(t+1);return[(n&127)<<8|r,2]}function w(e,t){let n=e.readUInt16LE(t);if(!(n&32768))return[n,2];let r=e.readUInt16LE(t+2);return[(n&32767)<<16|r,4]}async function T(e){let n=await E();if(!n)return;let r=await t(n,[`dump`,`badging`,e],{allowFailure:!0});if(r.exitCode===0)return r.stdout.match(/package:\s+name='([^']+)'/)?.[1]}async function E(){if(p!==void 0)return p??void 0;try{for(let t of l()){let n=i.join(t,`build-tools`);try{let t=(await a.readdir(n)).sort((e,t)=>t.localeCompare(e,void 0,{numeric:!0}));for(let r of t){let t=i.join(n,r,`aapt`);if(i.isAbsolute(t)&&await e(t))return p=t,t}}catch{}}}catch{}p=null}export{d as n,m as t};
|
package/dist/src/metro.d.ts
CHANGED
|
@@ -1,113 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
code?: number;
|
|
72
|
-
reason?: string;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
declare type MetroTunnelWebSocketFrameMessage = {
|
|
76
|
-
type: 'ws-frame';
|
|
77
|
-
streamId: string;
|
|
78
|
-
dataBase64: string;
|
|
79
|
-
binary: boolean;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
declare type MetroTunnelWebSocketOpenMessage = {
|
|
83
|
-
type: 'ws-open';
|
|
84
|
-
streamId: string;
|
|
85
|
-
path: string;
|
|
86
|
-
headers?: Record<string, string>;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
declare type MetroTunnelWebSocketOpenResultMessage = {
|
|
90
|
-
type: 'ws-open-result';
|
|
91
|
-
streamId: string;
|
|
92
|
-
success: boolean;
|
|
93
|
-
headers?: Record<string, string>;
|
|
94
|
-
error?: string;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export declare function normalizeBaseUrl(input: string): string;
|
|
98
|
-
|
|
99
|
-
export declare function resolveRuntimeTransport(runtime: SessionRuntimeHints | undefined): {
|
|
100
|
-
host: string;
|
|
101
|
-
port: number;
|
|
102
|
-
scheme: 'http' | 'https';
|
|
103
|
-
} | undefined;
|
|
104
|
-
|
|
105
|
-
declare type SessionRuntimeHints = {
|
|
106
|
-
platform?: 'ios' | 'android';
|
|
107
|
-
metroHost?: string;
|
|
108
|
-
metroPort?: number;
|
|
109
|
-
bundleUrl?: string;
|
|
110
|
-
launchUrl?: string;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export { }
|
|
1
|
+
import { y as SessionRuntimeHints } from "./sdk-contracts.js";
|
|
2
|
+
import { s as MetroBridgeDescriptor } from "./sdk-remote-config.js";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/url.d.ts
|
|
5
|
+
declare function normalizeBaseUrl(input: string): string;
|
|
6
|
+
declare function buildBundleUrl(baseUrl: string, platform: 'ios' | 'android'): string;
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/metro/metro.d.ts
|
|
9
|
+
declare function resolveRuntimeTransport(runtime: SessionRuntimeHints | undefined): {
|
|
10
|
+
host: string;
|
|
11
|
+
port: number;
|
|
12
|
+
scheme: 'http' | 'https';
|
|
13
|
+
} | undefined;
|
|
14
|
+
type MetroTunnelPingMessage = {
|
|
15
|
+
type: 'ping';
|
|
16
|
+
timestamp: number;
|
|
17
|
+
};
|
|
18
|
+
type MetroTunnelPongMessage = {
|
|
19
|
+
type: 'pong';
|
|
20
|
+
timestamp: number;
|
|
21
|
+
};
|
|
22
|
+
type MetroTunnelHttpRequestMessage = {
|
|
23
|
+
type: 'http-request';
|
|
24
|
+
requestId: string;
|
|
25
|
+
method: string;
|
|
26
|
+
path: string;
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
bodyBase64?: string;
|
|
29
|
+
};
|
|
30
|
+
type MetroTunnelHttpResponseMessage = {
|
|
31
|
+
type: 'http-response';
|
|
32
|
+
requestId: string;
|
|
33
|
+
status: number;
|
|
34
|
+
headers: Record<string, string>;
|
|
35
|
+
bodyBase64?: string;
|
|
36
|
+
};
|
|
37
|
+
type MetroTunnelHttpErrorMessage = {
|
|
38
|
+
type: 'http-error';
|
|
39
|
+
requestId: string;
|
|
40
|
+
message: string;
|
|
41
|
+
};
|
|
42
|
+
type MetroTunnelWebSocketOpenMessage = {
|
|
43
|
+
type: 'ws-open';
|
|
44
|
+
streamId: string;
|
|
45
|
+
path: string;
|
|
46
|
+
headers?: Record<string, string>;
|
|
47
|
+
};
|
|
48
|
+
type MetroTunnelWebSocketOpenResultMessage = {
|
|
49
|
+
type: 'ws-open-result';
|
|
50
|
+
streamId: string;
|
|
51
|
+
success: boolean;
|
|
52
|
+
headers?: Record<string, string>;
|
|
53
|
+
error?: string;
|
|
54
|
+
};
|
|
55
|
+
type MetroTunnelWebSocketFrameMessage = {
|
|
56
|
+
type: 'ws-frame';
|
|
57
|
+
streamId: string;
|
|
58
|
+
dataBase64: string;
|
|
59
|
+
binary: boolean;
|
|
60
|
+
};
|
|
61
|
+
type MetroTunnelWebSocketCloseMessage = {
|
|
62
|
+
type: 'ws-close';
|
|
63
|
+
streamId: string;
|
|
64
|
+
code?: number;
|
|
65
|
+
reason?: string;
|
|
66
|
+
};
|
|
67
|
+
type MetroTunnelRequestMessage = MetroTunnelPingMessage | MetroTunnelHttpRequestMessage | MetroTunnelWebSocketOpenMessage | MetroTunnelWebSocketFrameMessage | MetroTunnelWebSocketCloseMessage;
|
|
68
|
+
type MetroTunnelResponseMessage = MetroTunnelPongMessage | MetroTunnelHttpResponseMessage | MetroTunnelHttpErrorMessage | MetroTunnelWebSocketOpenResultMessage | MetroTunnelWebSocketFrameMessage | MetroTunnelWebSocketCloseMessage;
|
|
69
|
+
//#endregion
|
|
70
|
+
export { type MetroBridgeDescriptor, type MetroTunnelRequestMessage, type MetroTunnelResponseMessage, buildBundleUrl, normalizeBaseUrl, resolveRuntimeTransport };
|
package/dist/src/metro.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{n as e,t}from"./url.js";import{t as n}from"./metro2.js";export{t as buildBundleUrl,e as normalizeBaseUrl,n as resolveRuntimeTransport};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./client-metro-companion.js";import{t}from"./runtime-transport.js";function n(e){return t(e)}async function r(t){await e(t)}export{r as n,n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{F as e}from"./sdk-contracts.js";import{s as t}from"./logcat.js";async function n(n,i,a){let o=typeof a.action==`string`&&a.action.trim()?a.action.trim():`${i}.TEST_PUSH`,s=[`shell`,`am`,`broadcast`,`-a`,o,`-p`,i],c=typeof a.receiver==`string`?a.receiver.trim():``;c&&s.push(`-n`,c);let l=a.extras;if(l!==void 0&&(typeof l!=`object`||!l||Array.isArray(l)))throw new e(`INVALID_ARGS`,`Android push payload extras must be an object`);let u=l??{},d=0;for(let[e,t]of Object.entries(u))e&&(r(s,e,t),d+=1);return await t(n,s),{action:o,extrasCount:d}}function r(t,n,r){if(typeof r==`string`){t.push(`--es`,n,r);return}if(typeof r==`boolean`){t.push(`--ez`,n,r?`true`:`false`);return}if(typeof r==`number`&&Number.isFinite(r)){if(Number.isInteger(r)){t.push(`--ei`,n,String(r));return}t.push(`--ef`,n,String(r));return}throw new e(`INVALID_ARGS`,`Unsupported Android broadcast extra type for "${n}". Use string, boolean, or number.`)}export{n as pushAndroidNotification};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"node:path";const t=`.webm`;function n(e){return e===`web`?t:`.mp4`}function r(t,n){return e.extname(t)?t:`${t}${n}`}function i(e){return`./recording-${Date.now()}${n(e)}`}export{n as i,r as n,i as r,t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"node:os";import t from"node:path";function n(t){return t?.HOME?.trim()||e.homedir()}function r(e,r={}){return e===`~`?n(r.env):e.startsWith(`~/`)?t.join(n(r.env),e.slice(2)):e}function i(e,n={}){let i=r(e,n);return t.isAbsolute(i)?i:t.resolve(n.cwd??process.cwd(),i)}export{i as n,r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{F as e}from"./sdk-contracts.js";import{deflateSync as t,inflateSync as n}from"node:zlib";const r=Buffer.from([137,80,78,71,13,10,26,10]),i=new Map([[0,1],[2,3],[3,1],[4,2],[6,4]]),a=new Map([[0,new Set([1,2,4,8,16])],[2,new Set([8,16])],[3,new Set([1,2,4,8])],[4,new Set([8,16])],[6,new Set([8,16])]]),o=[{x:0,y:0,dx:8,dy:8},{x:4,y:0,dx:8,dy:8},{x:0,y:4,dx:4,dy:8},{x:2,y:0,dx:4,dy:4},{x:0,y:2,dx:2,dy:4},{x:1,y:0,dx:2,dy:2},{x:0,y:1,dx:1,dy:2}];var s=class{width;height;data;static sync={read:c,write:p};constructor(e){this.width=I(e.width,`width`),this.height=I(e.height,`height`);let t=this.width*this.height*4;if(this.data=e.data?Buffer.from(e.data):Buffer.alloc(t),this.data.length!==t)throw Error(`PNG data length must be ${t} bytes`)}};function c(e){let{metadata:t,idatChunks:n}=l(e);if(!t)throw Error(`PNG is missing IHDR`);if(n.length===0)throw Error(`PNG is missing IDAT`);let r=f(n,t);return new s({width:t.width,height:t.height,data:t.interlace===1?b(r,t):y(g(r,t),t)})}function l(e){let t,n=[];for(let r of d(e))if(r.type===`IHDR`?t=m(r.data):r.type===`IDAT`?n.push(Buffer.from(r.data)):t=u(r,t),r.type===`IEND`)break;return{metadata:t,idatChunks:n}}function u(e,t){if(e.type===`PLTE`){if(!t)throw Error(`PNG PLTE appeared before IHDR`);t.palette=Buffer.from(e.data)}else if(e.type===`tRNS`){if(!t)throw Error(`PNG tRNS appeared before IHDR`);t.transparency=Buffer.from(e.data)}return t}function*d(e){if(!e.subarray(0,r.length).equals(r))throw Error(`Invalid PNG signature`);let t=r.length;for(;t<e.length;){if(t+12>e.length)throw Error(`Truncated PNG chunk`);let n=e.readUInt32BE(t),r=e.toString(`ascii`,t+4,t+8),i=t+8,a=i+n;if(a+4>e.length)throw Error(`Truncated PNG ${r} chunk`);let o=e.subarray(i,a),s=e.readUInt32BE(a);if(P(e.subarray(t+4,a))!==s)throw Error(`Invalid PNG ${r} chunk CRC`);t=a+4,yield{type:r,data:o}}}function f(e,t){let r=x(t);try{let t=n(Buffer.concat(e),{maxOutputLength:r});if(t.length!==r)throw Error(`PNG pixel data is truncated`);return t}catch(e){throw L(e)?Error(`PNG pixel data exceeds expected length ${r}`):e}}function p(e){let n=e.width*4,i=Buffer.alloc((n+1)*e.height);for(let t=0;t<e.height;t+=1){let r=t*(n+1);i[r]=0,e.data.copy(i,r+1,t*n,(t+1)*n)}let a=Buffer.alloc(13);return a.writeUInt32BE(e.width,0),a.writeUInt32BE(e.height,4),a[8]=8,a[9]=6,a[10]=0,a[11]=0,a[12]=0,Buffer.concat([r,N(`IHDR`,a),N(`IDAT`,t(i)),N(`IEND`,Buffer.alloc(0))])}function m(e){if(e.length!==13)throw Error(`Invalid PNG IHDR length`);let t=e.readUInt32BE(0),n=e.readUInt32BE(4),r=e[8],i=e[9],o=e[10],s=e[11],c=e[12];if(!h(i))throw Error(`Unsupported PNG color type ${i}`);if(!a.get(i)?.has(r))throw Error(`Unsupported PNG color type ${i} with bit depth ${r}`);if(o!==0)throw Error(`Unsupported PNG compression method ${o}`);if(s!==0)throw Error(`Unsupported PNG filter method ${s}`);if(c!==0&&c!==1)throw Error(`Unsupported PNG interlace method ${c}`);return{width:I(t,`width`),height:I(n,`height`),bitDepth:r,colorType:i,interlace:c}}function h(e){return i.has(e)}function g(e,t){return _({inflated:e,offset:0,scanlineLength:O(t),height:t.height,bytesPerPixel:k(t)}).raw}function _(e){let{inflated:t,offset:n,scanlineLength:r,height:i,bytesPerPixel:a}=e,o=n+(r+1)*i;if(t.length<o)throw Error(`PNG pixel data is truncated`);let s=Buffer.alloc(r*i);for(let e=0;e<i;e+=1){let i=n+e*(r+1),o=e*r,c=t[i];for(let n=0;n<r;n+=1){let l=t[i+1+n],u=n>=a?s[o+n-a]:0,d=e>0?s[o+n-r]:0,f=e>0&&n>=a?s[o+n-r-a]:0;s[o+n]=v(c,l,u,d,f)}}return{raw:s,offset:o}}function v(e,t,n,r,i){if(e===0)return t;if(e===1)return t+n&255;if(e===2)return t+r&255;if(e===3)return t+Math.floor((n+r)/2)&255;if(e===4)return t+F(n,r,i)&255;throw Error(`Unsupported PNG filter type ${e}`)}function y(e,t){let n=Buffer.alloc(t.width*t.height*4),r=O(t);for(let i=0;i<t.height;i+=1){let a=e.subarray(i*r,(i+1)*r);for(let e=0;e<t.width;e+=1){let r=(i*t.width+e)*4,[o,s,c,l]=w(a,e,t);n[r]=o,n[r+1]=s,n[r+2]=c,n[r+3]=l}}return n}function b(e,t){let n=Buffer.alloc(t.width*t.height*4),r=0;for(let i of o){let a=C(t.width,i.x,i.dx),o=C(t.height,i.y,i.dy);if(a===0||o===0)continue;let s={...t,width:a,height:o,interlace:0},c=_({inflated:e,offset:r,scanlineLength:O(s),height:o,bytesPerPixel:k(s)});r=c.offset;let l=O(s);for(let e=0;e<o;e+=1){let r=c.raw.subarray(e*l,(e+1)*l);for(let o=0;o<a;o+=1){let a=i.x+o*i.dx,c=((i.y+e*i.dy)*t.width+a)*4,[l,u,d,f]=w(r,o,s);n[c]=l,n[c+1]=u,n[c+2]=d,n[c+3]=f}}}return n}function x(e){if(e.interlace===0)return S(e,e.height);let t=0;for(let n of o){let r=C(e.width,n.x,n.dx),i=C(e.height,n.y,n.dy);r===0||i===0||(t+=S({...e,width:r,height:i},i))}return t}function S(e,t){return(O(e)+1)*t}function C(e,t,n){return e<=t?0:Math.floor((e-t+n-1)/n)}function w(e,t,n){if(n.colorType===3)return T(e,t,n);if(n.bitDepth<8)return E(e,t,n);let r=n.bitDepth===16?2:1,a=t*i.get(n.colorType)*r,o=t=>n.bitDepth===16?e.readUInt16BE(a+t*2):e[a+t*r],s=e=>A(o(e),n.bitDepth);if(n.colorType===0){let e=s(0);return[e,e,e,j(o(0),n)?0:255]}if(n.colorType===2)return[s(0),s(1),s(2),M(o(0),o(1),o(2),n)?0:255];if(n.colorType===4){let e=s(0);return[e,e,e,s(1)]}return[s(0),s(1),s(2),s(3)]}function T(e,t,n){if(!n.palette)throw Error(`Indexed PNG is missing PLTE`);let r=D(e,t,n.bitDepth),i=r*3;if(i+2>=n.palette.length)throw Error(`Indexed PNG palette is invalid`);return[n.palette[i],n.palette[i+1],n.palette[i+2],n.transparency?.[r]??255]}function E(e,t,n){let r=D(e,t,n.bitDepth),i=(1<<n.bitDepth)-1,a=Math.round(r/i*255);return[a,a,a,n.transparency&&n.transparency.length>=2&&r===n.transparency.readUInt16BE(0)?0:255]}function D(e,t,n){let r=t*n;return e[Math.floor(r/8)]>>8-n-r%8&(1<<n)-1}function O(e){let t=i.get(e.colorType);return Math.ceil(e.width*t*e.bitDepth/8)}function k(e){let t=i.get(e.colorType);return Math.max(1,Math.ceil(t*e.bitDepth/8))}function A(e,t){return t===16?Math.round(e/65535*255):e}function j(e,t){return!t.transparency||t.transparency.length<2?!1:e===t.transparency.readUInt16BE(0)}function M(e,t,n,r){return!r.transparency||r.transparency.length<6?!1:e===r.transparency.readUInt16BE(0)&&t===r.transparency.readUInt16BE(2)&&n===r.transparency.readUInt16BE(4)}function N(e,t){let n=Buffer.from(e,`ascii`),r=Buffer.alloc(8+t.length+4);return r.writeUInt32BE(t.length,0),n.copy(r,4),t.copy(r,8),r.writeUInt32BE(P(Buffer.concat([n,t])),8+t.length),r}function P(e){let t=4294967295;for(let n of e){t^=n;for(let e=0;e<8;e+=1)t=t&1?3988292384^t>>>1:t>>>1}return(t^4294967295)>>>0}function F(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 I(e,t){if(!Number.isInteger(e)||e<1)throw Error(`PNG ${t} must be positive`);return e}function L(e){return e instanceof Error&&`code`in e&&e.code===`ERR_BUFFER_TOO_LARGE`}function R(t,n){try{return s.sync.read(t)}catch(t){throw new e(`COMMAND_FAILED`,`Failed to decode ${n} as PNG`,{label:n,reason:t instanceof Error?t.message:String(t)})}}const z=.78,B={r:220,g:0,b:0};function V(e){let{baselineData:t,currentData:n,maxColorDistance:r}=e,i=e.width*e.height,a=Buffer.alloc(i*4),o=new Uint8Array(i),s=0;for(let e=0,i=0;e<t.length;e+=4,i+=1){let c=t[e]-n[e],l=t[e+1]-n[e+1],u=t[e+2]-n[e+2];if(Math.sqrt(c**2+l**2+u**2)>r){s+=1,o[i]=1;let t=H(n,e);a[e]=U(t,B.r,z),a[e+1]=U(t,B.g,z),a[e+2]=U(t,B.b,z),a[e+3]=255;continue}let d=H(n,e);a[e]=d,a[e+1]=d,a[e+2]=d,a[e+3]=255}return{diffData:a,diffMask:o,differentPixels:s}}function H(e,t){return U(Math.round(e[t]*.299+e[t+1]*.587+e[t+2]*.114),255,.72)}function U(e,t,n){return Math.round(e*(1-n)+t*n)}function W(e){return Buffer.from(e.buffer,e.byteOffset,e.byteLength)}export{s as i,V as n,R as r,W as t};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{F as e,b as t,l as n}from"./sdk-contracts.js";import{Dt as r,Ot as i,a,fn as o}from"./device-rotation.js";import{a as s,f as c,i as ee,l,m as u,p as d,u as f}from"./providers.js";import p from"node:fs";import{parseAllDocuments as m,stringify as h}from"yaml";const g=/^[A-Z_][A-Z0-9_]*$/,_=/(\\\$\{)|\$\{([A-Za-z_][A-Za-z0-9_.]*)(?::-((?:[^}\\]|\\.)*))?\}/g;function v(e){return e.startsWith(`AD_`)}function y(t){return new e(`INVALID_ARGS`,`The AD_* namespace is reserved for built-in variables. Rename ${t} to avoid the AD_ prefix.`)}function te(e){let t={};if(e.builtins)for(let[n,r]of Object.entries(e.builtins))t[n]=r;let n=[e.fileEnv,e.shellEnv,e.cliEnv];for(let e of n)if(e)for(let[n,r]of Object.entries(e)){if(v(n))throw y(n);t[n]=r}return{values:t}}function ne(e,t){Object.assign(e.values,t)}function b(e){let t={};for(let[n,r]of Object.entries(e)){if(typeof r!=`string`||!n.startsWith(`AD_VAR_`))continue;let e=n.slice(7);e.length!==0&&g.test(e)&&(v(e)||(t[e]=r))}return t}function x(t){let n={};for(let r of t){let t=r.indexOf(`=`);if(t<=0)throw new e(`INVALID_ARGS`,`Invalid -e entry "${r}": expected KEY=VALUE.`);let i=r.slice(0,t);if(!g.test(i))throw new e(`INVALID_ARGS`,`Invalid -e key "${i}": keys must be uppercase letters, digits, and underscores (e.g. APP_ID).`);if(v(i))throw y(i);n[i]=r.slice(t+1)}return n}function S(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function C(e){if(e&&typeof e==`object`&&!Array.isArray(e)){let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&(t[n]=r);return t}return process.env}function w(t,n,r){return t.replace(_,(t,i,a,o)=>{if(i)return"${";if(!a)return t;if(Object.prototype.hasOwnProperty.call(n.values,a))return String(n.values[a]);if(o!==void 0)return o.replace(/\\(.)/g,`$1`);throw new e(`INVALID_ARGS`,`Unresolved variable \${${a}} at ${r.file}:${r.line}.`)})}function T(e,t,n){return{...e,positionals:(e.positionals??[]).map(e=>w(e,t,n)),flags:D(e.flags,t,n)??{},runtime:D(e.runtime,t,n),replayControl:E(e.replayControl,t,n)}}function E(e,t,n){if(!e)return e;switch(e.kind){case`maestroRunFlowWhen`:return{...e,selector:w(e.selector,t,n)};case`retry`:return e}return e}function D(e,t,n){return e&&O(e,t,n)}function O(e,t,n){return typeof e==`string`?w(e,t,n):Array.isArray(e)?e.map(e=>O(e,t,n)):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,r])=>[e,O(r,t,n)])):e}const k=new Set(n.filter(e=>e!==`web`)),A=new Set([`mobile`,`tv`,`desktop`]);function j(t){let n=[],r=[],i=t.split(/\r?\n/),a=!1;for(let[t,o]of i.entries()){let i=o.trim();if(i.length===0||i.startsWith(`#`))continue;if(N(i)){if(a)throw new e(`INVALID_ARGS`,`env directives must precede all actions (line ${t+1}).`);continue}let s=R(o);s&&(n.push(s),r.push(t+1),a=!0)}return{actions:n,actionLines:r}}function M(e){let t=e.split(/\r?\n/),n={};for(let[e,r]of t.entries()){let t=r.trim();if(t.length===0||t.startsWith(`#`))continue;if(N(t)){I(n,t,e+1);continue}if(!t.startsWith(`context `))break;let i=t.match(/(?:^|\s)platform=([^\s]+)/);if(i){let e=i[1];e&&k.has(e)&&L(n,`platform`,e)}let a=t.match(/(?:^|\s)target=([^\s]+)/);if(a){let e=a[1];e&&A.has(e)&&L(n,`target`,e)}let o=t.match(/(?:^|\s)timeout=(\d+)/);if(o){let e=Number(o[1]);Number.isFinite(e)&&e>=1&&L(n,`timeoutMs`,Math.floor(e))}let s=t.match(/(?:^|\s)retries=(\d+)/);if(s){let e=Number(s[1]);Number.isFinite(e)&&e>=0&&L(n,`retries`,Math.floor(e))}}return n}function N(e){return e===`env`||e.startsWith(`env `)||e.startsWith(`env `)}function P(t,n){let r=t.slice(3).replace(/^[\s]+/,``),i=r.indexOf(`=`);if(i<=0)throw new e(`INVALID_ARGS`,`Invalid env directive on line ${n}: expected "env KEY=VALUE".`);let a=r.slice(0,i);if(!g.test(a))throw new e(`INVALID_ARGS`,`Invalid env key "${a}" on line ${n}: keys must be uppercase letters, digits, and underscores (e.g. APP_ID).`);if(a.startsWith(`AD_`))throw new e(`INVALID_ARGS`,`Invalid env key "${a}" on line ${n}: the AD_* namespace is reserved for built-in variables. Rename ${a} to avoid the AD_ prefix.`);return{key:a,value:F(r.slice(i+1),n)}}function F(t,n){if(t.length===0)return``;if(t.startsWith(`"`))try{let e=JSON.parse(t);if(typeof e!=`string`)throw Error(`not a string literal`);return e}catch{throw new e(`INVALID_ARGS`,`Invalid quoted env value on line ${n}.`)}return t}function I(t,n,r){let{key:i,value:a}=P(n,r),o=t.env??{};if(Object.prototype.hasOwnProperty.call(o,i))throw new e(`INVALID_ARGS`,`Duplicate env directive "${i}" on line ${r}.`);o[i]=a,t.env=o}function L(t,n,r){let i=t[n];if(i!==void 0)throw new e(`INVALID_ARGS`,i===r?`Duplicate replay test metadata "${n}" in context header.`:`Conflicting replay test metadata "${n}" in context header: ${String(i)} vs ${String(r)}.`);t[n]=r}function R(e){let t=e.trim();if(t.length===0||t.startsWith(`#`))return null;let[n,...r]=V(t);if(n===void 0||n===`context`)return null;let i={ts:Date.now(),command:n,positionals:[],flags:{}};if(n===`snapshot`){i.positionals=[];for(let e=0;e<r.length;e+=1){let t=r[e];if(t===`-i`){i.flags.snapshotInteractiveOnly=!0;continue}if(t!==`-c`){if(t===`--raw`){i.flags.snapshotRaw=!0;continue}if(t===`--force-full`){i.flags.snapshotForceFull=!0;continue}if((t===`-d`||t===`--depth`)&&e+1<r.length){let t=Number(r[e+1]);Number.isFinite(t)&&t>=0&&(i.flags.snapshotDepth=Math.floor(t)),e+=1;continue}if((t===`-s`||t===`--scope`)&&e+1<r.length){i.flags.snapshotScope=r[e+1],e+=1;continue}if(t===`--backend`&&e+1<r.length){e+=1;continue}}}return i}if(n===`open`){let e=s(r);return i.positionals=e.positionals,Object.assign(i.flags,e.flags),i.runtime=e.runtime,i}if(n===`runtime`){let e=c(r);return i.positionals=e.positionals,Object.assign(i.flags,e.flags),i}if(f(n)){let e=d(n,r);Object.assign(i.flags,e.flags);let t=e.positionals[0];if(t===void 0)return i;if(t.startsWith(`@`))return i.positionals=[u(t)],e.positionals[1]&&(i.result={refLabel:e.positionals[1]}),i;let a=e.positionals[0],o=e.positionals[1];return B(a)&&B(o)&&e.positionals.length>=2?(i.positionals=[a,o],i):(i.positionals=[e.positionals.join(` `)],i)}if(n===`fill`){let e=d(n,r);if(Object.assign(i.flags,e.flags),!z(e.positionals))return i.positionals=e.positionals,i;let[t,a,...o]=e.positionals;if(t.startsWith(`@`)){let e=u(t);return o.length>0?(i.positionals=[e,o.join(` `)],i.result={refLabel:a},i):(i.positionals=[e,a],i)}return i.positionals=[t,[a,...o].join(` `)],i}if(n===`get`){let e=r[0],t=r[1];return e===void 0||t===void 0?(i.positionals=r,i):t.startsWith(`@`)?(i.positionals=[e,u(t)],r[2]&&(i.result={refLabel:r[2]}),i):(i.positionals=[e,r.slice(1).join(` `)],i)}if(n===`swipe`||n===`type`){let e=d(n,r);return Object.assign(i.flags,e.flags),i.positionals=e.positionals,i}if(n===`record`){let e=[];for(let t=0;t<r.length;t+=1){let n=r[t];if(n===`--hide-touches`){i.flags.hideTouches=!0;continue}if(n===`--fps`&&t+1<r.length){let e=Number(r[t+1]);Number.isFinite(e)&&(i.flags.fps=Math.floor(e)),t+=1;continue}if(n===`--quality`&&t+1<r.length){let e=r[t+1],n=a(e);n!==void 0&&(i.flags.quality=n),t+=1;continue}if(n===`--max-size`&&t+1<r.length){let e=Number(r[t+1]);Number.isFinite(e)&&(i.flags.screenshotMaxSize=Math.floor(e)),t+=1;continue}e.push(n)}return i.positionals=e,i}if(n===`screenshot`){let e=[];for(let t=0;t<r.length;t+=1){let n=r[t],a=o({args:r,index:t,flags:i.flags});if(a.handled){t=a.nextIndex;continue}e.push(n)}return i.positionals=e,i}return i.positionals=n===`wait`||n===`longpress`?r.map(e=>u(e)):r,i}function z(e){return e.length>=2}function B(e){return e?!Number.isNaN(Number(e)):!1}function V(e){let t=[],n=0;for(;n<e.length&&(n=H(e,n),!(n>=e.length));){let r=e[n]===`"`?U(e,n):W(e,n);t.push(r.value),n=r.nextCursor}return t}function H(e,t){let n=t;for(;n<e.length&&/\s/.test(e.charAt(n));)n+=1;return n}function U(t,n){let r=n+1,i=!1,a=r;for(;a<t.length;a+=1){let e=t.charAt(a);if(e===`"`&&!i)break;if(i){i=!1;continue}i=e===`\\`}if(a>=t.length)throw new e(`INVALID_ARGS`,`Invalid replay script line: ${t}`);return{value:JSON.parse(t.slice(n,a+1)),nextCursor:a+1}}function W(e,t){let n=t;for(;n<e.length&&!/\s/.test(e.charAt(n));)n+=1;return{value:e.slice(t,n),nextCursor:n}}function G(e,n,r){let i=[];if(r){let e=r.device.kind?` kind=${r.device.kind}`:``,n=r.device.target?` target=${r.device.target}`:``;i.push(`context platform=${t(r.device)}${n} device=${l(r.device.name)}${e} theme=unknown`)}for(let e of n)i.push(K(e));let a=`${i.join(`
|
|
2
|
+
`)}\n`,o=`${e}.tmp-${process.pid}-${Date.now()}`;p.writeFileSync(o,a),p.renameSync(o,e)}function K(e){return ee(e,{runtimeIncludeAllPositionals:!0})}function q(t){let n=m(t);for(let t of n)if(t.errors.length>0)throw new e(`INVALID_ARGS`,`Invalid Maestro YAML flow: ${t.errors[0]?.message??`Invalid Maestro YAML flow.`}`);return n.map(e=>e.toJSON()).filter(e=>e!==null)}function J(e){return`${e.map(e=>h(e).trimEnd()).join(`
|
|
3
|
+
---
|
|
4
|
+
`)}\n`}function Y(e,t=[],n){return{ts:Date.now(),command:e,positionals:t,flags:n??{}}}function X(e,t,n){let r=new Set(n),i=Object.keys(e).filter(e=>!r.has(e));if(i.length>0)throw $(`Maestro ${t} field "${i[0]}" is not supported yet.`)}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function re(t){return t.map((t,n)=>{if(typeof t==`string`||Z(t))return t;throw new e(`INVALID_ARGS`,`Unsupported Maestro command at index ${n+1}: expected a scalar or one-key map.`)})}function ie(e){if(e)return ue(e)}function ae(t,n){if(t==null)return{};if(!Z(t))throw new e(`INVALID_ARGS`,`${n} expects a map.`);let r={};for(let[e,n]of Object.entries(t))(typeof n==`string`||typeof n==`number`||typeof n==`boolean`)&&(r[e]=String(n));return r}function oe(e,t){return Z(e)&&typeof e.timeout==`number`&&Number.isFinite(e.timeout)?Math.max(0,Math.floor(e.timeout)):t}function se(t,n){if(t.appId)return t.appId;throw new e(`INVALID_ARGS`,`${n} requires appId in the Maestro flow config.`)}function Q(t,n){if(typeof n==`string`)return n;throw new e(`INVALID_ARGS`,`${t} expects a string value.`)}function ce(e,t){return e.replace(/\$\{([A-Za-z_][A-Za-z0-9_.]*)\}/g,(e,n)=>Object.prototype.hasOwnProperty.call(t.env,n)?String(t.env[n]):e)}function le(e){throw $(`Maestro command "${e}" is not supported yet.`)}function $(t){throw new e(`INVALID_ARGS`,`${t} See supported/unsupported Maestro compatibility at ${r}. If this syntax matters for your flows, comment there or open a focused issue at ${i}.`)}function ue(e){let t=e.trim().toLowerCase();if(t===`android`)return`android`;if(t===`ios`)return`ios`}function de(e,t){return`${e},${t}`}function fe(e){let t=e.match(/^(\d+),(\d+)$/);if(!t)throw $(`Only absolute Maestro point selectors like "100,200" are supported.`);return{x:Number(t[1]),y:Number(t[2])}}function pe(e){let t=e.match(/^\s*(\d+)\s*,\s*(\d+)\s*$/);if(t)return{kind:`absolute`,x:Number(t[1]),y:Number(t[2])};let n=e.match(/^\s*(\d+(?:\.\d+)?)%\s*,\s*(\d+(?:\.\d+)?)%\s*$/);if(n)return{kind:`percent`,x:Number(n[1]),y:Number(n[2])};throw $(`Only Maestro swipe coordinates like "100,200" or "50%,75%" are supported.`)}export{ne as C,T as D,C as E,b as S,S as T,J as _,X as a,G as b,ie as c,se as d,Q as f,q as g,$ as h,Y as i,ae as l,le as m,fe as n,Z as o,ce as p,pe as r,re as s,de as t,oe as u,j as v,x as w,te as x,M as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"node:fs";import t from"node:path";function n(e){let t=i(e);return t?r(t):`auto`}function r(e){let t={...e.dependencies??{},...e.devDependencies??{}};return typeof t.expo==`string`?`expo`:typeof t[`react-native`]==`string`?`react-native`:`auto`}function i(n){if(!n)return;let r=t.join(n,`package.json`);try{return JSON.parse(e.readFileSync(r,`utf8`))}catch{return}}export{r as n,i as r,n as t};
|
package/dist/src/provider.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"./rolldown-runtime.js";import{t}from"./scoped-provider.js";import{t as n}from"./internal/daemon.js";var r=e({resolveWebProvider:()=>a,withWebProvider:()=>o});const i=t(n());function a(e){return i.resolve(e)}async function o(e,t){return await i.run(e,t)}export{a as n,r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{N as e}from"./sdk-contracts.js";import{dn as t}from"./device-rotation.js";import n from"node:crypto";function r(t){return t.startsWith(`@`)?e(t)?.base??t:t}const i=/^-?\d+(\.\d+)?$/,a=/^[^\s"\\]+$/,o=new Map([[`--count`,`count`],[`--interval-ms`,`intervalMs`],[`--hold-ms`,`holdMs`],[`--jitter-px`,`jitterPx`]]),s=new Map([[`--count`,`count`],[`--pause-ms`,`pauseMs`]]),c=new Map([[`--delay-ms`,`delayMs`]]);function l(e){return e===`click`||e===`press`}function u(e){return l(e)||e===`longpress`}function d(e){return e===`type`||e===`fill`}function f(e){return h(e,g)}function p(e){return JSON.stringify(e)}function m(e){return h(e,_)}function h(e,t){return t(e)?e:p(e)}function g(e){return _(e)&&e.startsWith(`@`)||i.test(e)}function _(e){return a.test(e)}function v(e){let t=(e.positionals??[]).map(e=>f(e));return[e.command,...t].join(` `)}function y(e,t){let n=t.flags??{};if(l(t.command)){typeof n.count==`number`&&e.push(`--count`,String(n.count)),typeof n.intervalMs==`number`&&e.push(`--interval-ms`,String(n.intervalMs)),typeof n.holdMs==`number`&&e.push(`--hold-ms`,String(n.holdMs)),typeof n.jitterPx==`number`&&e.push(`--jitter-px`,String(n.jitterPx)),n.doubleTap===!0&&e.push(`--double-tap`);let t=n.clickButton;t&&t!==`primary`&&e.push(`--button`,t);return}if(t.command===`swipe`){typeof n.count==`number`&&e.push(`--count`,String(n.count)),typeof n.pauseMs==`number`&&e.push(`--pause-ms`,String(n.pauseMs)),(n.pattern===`one-way`||n.pattern===`ping-pong`)&&e.push(`--pattern`,n.pattern);return}d(t.command)&&typeof n.delayMs==`number`&&e.push(`--delay-ms`,String(n.delayMs))}function b(e,t){t&&((t.platform===`ios`||t.platform===`android`)&&e.push(`--platform`,t.platform),typeof t.metroHost==`string`&&t.metroHost.length>0&&e.push(`--metro-host`,m(t.metroHost)),typeof t.metroPort==`number`&&e.push(`--metro-port`,String(t.metroPort)),typeof t.bundleUrl==`string`&&t.bundleUrl.length>0&&e.push(`--bundle-url`,m(t.bundleUrl)),typeof t.launchUrl==`string`&&t.launchUrl.length>0&&e.push(`--launch-url`,m(t.launchUrl)))}function x(e,t){let[n,...r]=t.positionals??[];n&&e.push(m(n));for(let t of r)e.push(f(t));typeof t.flags?.fps==`number`&&e.push(`--fps`,String(t.flags.fps)),typeof t.flags?.screenshotMaxSize==`number`&&e.push(`--max-size`,String(t.flags.screenshotMaxSize)),(typeof t.flags?.quality==`number`||typeof t.flags?.quality==`string`)&&e.push(`--quality`,String(t.flags.quality)),t.flags?.hideTouches&&e.push(`--hide-touches`)}function S(e,t){t.flags?.snapshotInteractiveOnly&&e.push(`-i`),typeof t.flags?.snapshotDepth==`number`&&e.push(`-d`,String(t.flags.snapshotDepth)),t.flags?.snapshotScope&&e.push(`-s`,f(t.flags.snapshotScope)),t.flags?.snapshotRaw&&e.push(`--raw`)}function C(e,n){for(let t of n.positionals??[])e.push(f(t));t(e,n.flags)}function w(e,t,n={}){let r=t.positionals??[],i=n.includeAllPositionals?r:r.slice(0,1);for(let t of i)e.push(m(t));b(e,t.flags)}function T(e,t){for(let n of t.positionals??[])e.push(f(t.command===`wait`?r(n):n));y(e,t)}function E(e,t){let n=[],r={},i=l(e)?o:e===`swipe`?s:d(e)?c:void 0;for(let a=0;a<t.length;a+=1){let o=t[a];if(l(e)&&o===`--double-tap`){r.doubleTap=!0;continue}let s=t[a+1];if(l(e)&&o===`--button`&&s!==void 0){let e=s;(e===`primary`||e===`secondary`||e===`middle`)&&(r.clickButton=e),a+=1;continue}let c=i?.get(o);if(c&&s!==void 0){let e=O(s);if(e!==null){r[c]=e,a+=1;continue}}if(e===`swipe`&&o===`--pattern`&&s!==void 0){let e=s;(e===`one-way`||e===`ping-pong`)&&(r.pattern=e),a+=1;continue}n.push(o)}return{positionals:n,flags:r}}function D(e){let t=[],n={};for(let r=0;r<e.length;r+=1){let i=e[r],a=e[r+1];if(i===`--platform`&&a!==void 0){let e=a;(e===`ios`||e===`android`)&&(n.platform=e),r+=1;continue}if(i===`--metro-host`&&a!==void 0){n.metroHost=a,r+=1;continue}if(i===`--metro-port`&&a!==void 0){let e=O(a);e!==null&&(n.metroPort=e),r+=1;continue}if(i===`--bundle-url`&&a!==void 0){n.bundleUrl=a,r+=1;continue}if(i===`--launch-url`&&a!==void 0){n.launchUrl=a,r+=1;continue}t.push(i)}return{positionals:t,flags:n}}function O(e){if(!e)return null;let t=Number(e);return!Number.isFinite(t)||t<0?null:Math.floor(t)}function k(e,t){for(let n of t.positionals??[])e.push(f(n));t.flags?.relaunch&&e.push(`--relaunch`),b(e,t.runtime)}function A(e){let t=[],n={};for(let r of e){if(r===`--relaunch`){n.relaunch=!0;continue}t.push(r)}let r=D(t);return{positionals:r.positionals,flags:n,runtime:j(r.flags)?r.flags:void 0}}function j(e){return!!(e.platform||e.metroHost||e.metroPort!==void 0||e.bundleUrl||e.launchUrl)}function M(e,t={}){let n=[e.command];return e.command===`snapshot`?S(n,e):e.command===`open`?k(n,e):e.command===`runtime`?w(n,e,{includeAllPositionals:t.runtimeIncludeAllPositionals}):e.command===`record`?x(n,e):e.command===`screenshot`?C(n,e):T(n,e),n.join(` `)}function N(e,t){let r=n.createHash(`sha256`).update(e).digest(),i=n.createHash(`sha256`).update(t).digest();return n.timingSafeEqual(r,i)}const P={browserStack:`browserstack`,awsDeviceFarm:`aws-device-farm`},F=new Set(Object.values(P));function I(e){return e!==void 0&&F.has(e)}export{A as a,f as c,u as d,D as f,M as i,p as l,r as m,I as n,y as o,E as p,N as r,v as s,P as t,l as u};
|
package/dist/src/react-native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{B as e}from"./sdk-contracts.js";import{w as t}from"./sdk-batch.js";import{gn as n}from"./device-rotation.js";import{b as r}from"./sdk-batch-runner.js";import{t as i}from"./snapshot-quality.js";import{u as a}from"./runtime.js";import{Ht as o,Qt as s,Xt as c,Zt as l}from"./internal/daemon.js";import{i as u,n as d,t as f}from"./interaction-snapshot.js";async function p(n){let{req:r,sessionName:o,sessionStore:c}=n;if(r.command!==t.reactNative)return null;let u=m(r.positionals??[]);if(!u.ok)return u.response;let d=c.get(o);if(!d)return l();let p=s(t.reactNative,d.device,{message:`react-native dismiss-overlay is not supported on this device`});if(p)return p;try{let e=await f(d,r.flags,c,n.contextFromFlags,{interactiveOnly:!0});if(i(e.snapshotQuality))return g(e.snapshotQuality);let t=a(e.nodes),o=t.primaryAction;return o?await _(n,d,e,o):h(t.detected)}catch(t){return{ok:!1,error:e(t)}}}function m(e){return e.length===1&&e[0]===`dismiss-overlay`?{ok:!0}:{ok:!1,response:c(`INVALID_ARGS`,`react-native supports only: dismiss-overlay`)}}function h(e){return e?c(`COMMAND_FAILED`,`React Native overlay detected, but no safe dismiss target was found`,{hint:`Use screenshot --overlay-refs for visual evidence and report the overlay instead of pressing the warning body.`}):{ok:!0,data:{action:`dismiss-overlay`,detected:!1,dismissed:!1,...n(`No React Native overlay detected`)}}}function g(e){return c(`COMMAND_FAILED`,`React Native overlay state could not be determined because the accessibility tree is unreadable`,{reason:e.reason,hint:`The snapshot quality verdict is sparse. Use screenshot as visual truth; if an overlay is visible, report it or navigate with coordinates, then retry snapshot or dismiss-overlay on a readable screen.`})}async function _(e,t,i,a){let{req:s,sessionStore:c}=e,l=Date.now(),f=await o(t.device,`press`,[String(a.point.x),String(a.point.y)],s.flags?.out,e.contextFromFlags(s.flags,t.appBundleId,t.trace?.outPath))??{},p=Date.now(),m=await v(e,t),h=r({...d(i.nodes),...f,action:`dismiss-overlay`,overlayAction:a.action,x:a.point.x,y:a.point.y,ref:a.ref,label:a.label,warning:a.warning,dismissed:!0,verified:m.verified,verificationRequired:!m.verified,verificationWarning:m.verificationWarning,nextCommand:m.nextCommand,...n(y(m))});return u({session:t,sessionStore:c,command:s.command,positionals:s.positionals??[],flags:s.flags,result:h,responseData:h,actionStartedAt:l,actionFinishedAt:p})}async function v(e,t){let{req:n,sessionStore:r}=e,o=await f(t,n.flags,r,e.contextFromFlags,{interactiveOnly:!0});return i(o.snapshotQuality)?{verified:!1,verificationWarning:`React Native overlay dismissal could not be verified because the post-dismiss accessibility tree is unreadable. Use screenshot as visual truth.`,nextCommand:`agent-device screenshot`}:a(o.nodes).detected?{verified:!1,verificationWarning:`React Native overlay is still detected after dismissal. Use screenshot --overlay-refs for visual evidence and report the overlay instead of pressing the warning body.`,nextCommand:`agent-device screenshot --overlay-refs`}:{verified:!0}}function y(e){return e.verified?`React Native overlay dismiss action sent and verified gone`:`React Native overlay dismiss action sent, but verification still detects an overlay`}export{p as handleReactNativeCommands};
|