agent-device 0.16.7 → 0.16.8
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.16.7.apk → agent-device-android-multitouch-helper-0.16.8.apk} +0 -0
- package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.16.8.apk.sha256 +1 -0
- package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.16.7.manifest.json → agent-device-android-multitouch-helper-0.16.8.manifest.json} +4 -4
- package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.16.7.apk → agent-device-android-snapshot-helper-0.16.8.apk} +0 -0
- package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.16.8.apk.sha256 +1 -0
- package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.16.7.manifest.json → agent-device-android-snapshot-helper-0.16.8.manifest.json} +6 -6
- package/dist/src/1352.js +1 -1
- package/dist/src/2415.js +29 -29
- package/dist/src/2805.js +1 -1
- package/dist/src/6232.js +1 -0
- package/dist/src/7455.js +1 -0
- package/dist/src/8699.js +1 -1
- package/dist/src/940.js +1 -1
- package/dist/src/9471.js +1 -1
- package/dist/src/9533.js +1 -1
- package/dist/src/9542.js +1 -1
- package/dist/src/9818.js +1 -1
- package/dist/src/android-adb.d.ts +2 -0
- package/dist/src/android-snapshot-helper.d.ts +2 -0
- package/dist/src/args.js +5 -4
- package/dist/src/cli.js +6 -6
- package/dist/src/command-metadata.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/generic.js +10 -7
- package/dist/src/interaction.js +1 -1
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-trace.js +3 -3
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/session.js +9 -9
- package/dist/src/snapshot.js +2 -2
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +20 -6
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +178 -74
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +8 -33
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +71 -1
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +80 -10
- package/ios-runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +34 -6
- package/package.json +4 -6
- package/server.json +2 -2
- package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.16.7.apk.sha256 +0 -1
- package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.16.7.apk.sha256 +0 -1
- package/dist/src/5186.js +0 -1
package/dist/src/2805.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
let e={devices:"List available devices.",boot:"Boot or prepare a selected device without using CLI positional arguments.",apps:"List installed apps.",session:"List active sessions.",open:"Open an app, deep link, URL, or platform surface.",close:"Close an app or end the active session.",install:"Install an app binary.",reinstall:"Reinstall an app binary.","install-from-source":"Install an app from a structured source.",push:"Deliver a push payload.","trigger-app-event":"Trigger an app-defined event.",snapshot:"Capture an accessibility snapshot.",screenshot:"Capture a screenshot.",diff:"Diff accessibility snapshots.",wait:"Wait for duration, text, ref, or selector.",alert:"Inspect or handle platform alerts.",appstate:"Show foreground app or activity.",back:"Navigate back.",home:"Go to the home screen.",rotate:"Rotate device orientation.","app-switcher":"Open the app switcher.",keyboard:"Inspect or dismiss the keyboard.",clipboard:"Read or write clipboard text.","react-native":"Run supported React Native app automation helpers.",replay:"Replay a recorded session.",test:"Run one or more replay scripts.",perf:"Show session performance metrics.",logs:"Manage session app logs.",network:"Show recent HTTP traffic.",record:"Start or stop screen recording.",trace:"Start or stop trace capture.",settings:"Change OS settings and app permissions.",metro:"Prepare Metro runtime or reload React Native apps.",click:"Click or tap a semantic UI target by ref, selector, or point.",press:"Press a semantic UI target by ref, selector, or point.",fill:"Fill text into a semantic UI target by ref, selector, or point.",longpress:"Long press by ref, selector, or point.",swipe:"Swipe between two points.",focus:"Focus input at coordinates.",type:"Type text in the focused field.",scroll:"Scroll in a direction or to an edge.",get:"Get element text or attributes.",is:"Assert UI state.",find:"Find an element and optionally act on it.",gesture:"Run a structured gesture.",batch:"Run multiple structured command steps in one daemon request."};function t(t){let r=e[t];if(!r)throw Error(`Missing command description for ${t}`);return r}function r(){return Object.entries(e).map(([e,t])=>({name:e,description:t}))}export{r as listCommandDescriptionMetadata,t as requireCommandDescription};
|
package/dist/src/6232.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{withSuccessText as e,successText as a}from"./1998.js";function n(e){let a=e.appId??e.bundleId??e.packageName;return{session:e.session,appId:a,appBundleId:e.bundleId,package:e.packageName}}function i(e,a,n){return{deviceId:a,deviceName:n,..."android"===e?{serial:a}:"ios"===e?{udid:a}:{}}}function t(e,a={}){let n=a.includeAndroidSerial??!0;return{platform:e.platform,target:e.target,device:e.name,id:e.id,..."ios"===e.platform?{device_udid:e.ios?.udid??e.id,ios_simulator_device_set:e.ios?.simulatorSetPath??null}:{},..."android"===e.platform&&n?{serial:e.android?.serial??e.id}:{}}}function d(e){return{name:e.name,...t(e.device,{includeAndroidSerial:!1}),createdAt:e.createdAt}}function p(e){return{platform:e.platform,id:e.id,name:e.name,kind:e.kind,target:e.target,..."boolean"==typeof e.booted?{booted:e.booted}:{}}}function r(e){return e.bundleId??e.package??e.app}function l(a){return e({app:a.app,appPath:a.appPath,platform:a.platform,...a.appId?{appId:a.appId}:{},...a.bundleId?{bundleId:a.bundleId}:{},...a.package?{package:a.package}:{}},`Installed: ${r(a)}`)}function s(e){return e.appName??e.bundleId??e.packageName??e.launchTarget}function o(a){return e({launchTarget:a.launchTarget,...a.appName?{appName:a.appName}:{},...a.appId?{appId:a.appId}:{},...a.bundleId?{bundleId:a.bundleId}:{},...a.packageName?{package:a.packageName}:{},...a.installablePath?{installablePath:a.installablePath}:{},...a.archivePath?{archivePath:a.archivePath}:{},...a.materializationId?{materializationId:a.materializationId}:{},...a.materializationExpiresAt?{materializationExpiresAt:a.materializationExpiresAt}:{}},`Installed: ${s(a)}`)}function u(a){let n=a.appName??a.appBundleId??a.session;return e({session:a.session,...a.appName?{appName:a.appName}:{},...a.appBundleId?{appBundleId:a.appBundleId}:{},...a.startup?{startup:a.startup}:{},...a.runtime?{runtime:a.runtime}:{},...a.device?t(a.device):{}},n?`Opened: ${n}`:"Opened")}function c(e){return{session:e.session,...e.shutdown?{shutdown:e.shutdown}:{},...a(e.session?`Closed: ${e.session}`:"Closed")}}function m(e){return{nodes:e.nodes,truncated:e.truncated,...e.appName?{appName:e.appName}:{},...e.appBundleId?{appBundleId:e.appBundleId}:{},...e.visibility?{visibility:e.visibility}:{},...e.androidSnapshot?{androidSnapshot:e.androidSnapshot}:{},...e.warnings&&e.warnings.length>0?{warnings:e.warnings}:{},...e.unchanged?{unchanged:e.unchanged}:{}}}export{n as buildAppIdentifiers,i as buildDeviceIdentifiers,r as resolveDeployResultTarget,s as resolveInstallFromSourceResultTarget,c as serializeCloseResult,l as serializeDeployResult,p as serializeDevice,o as serializeInstallFromSourceResult,u as serializeOpenResult,d as serializeSessionListEntry,m as serializeSnapshotResult};
|
package/dist/src/7455.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{AppError as e}from"./9152.js";function n(n,r,t,i){let o=t(n[r]);if(void 0===o)throw new e("COMMAND_FAILED",i,{response:n});return o}function r(e,r){return n(e,r,c,`Daemon response is missing "${r}".`)}function t(e,n){return c(e[n])}function i(e,n){var r;let t;return r=c,null===(t=e[n])?null:r(t)}function o(e,r){return n(e,r,m,`Daemon response is missing numeric "${r}".`)}function u(e,r){return n(e,r,p,`Daemon response has invalid "${r}".`)}function d(e,r){return n(e,r,v,`Daemon response has invalid "${r}".`)}function f(e,n){return function(e){return"tv"===e||"mobile"===e||"desktop"===e?e:void 0}(e[n])??"mobile"}function s(e,n){let r=e[n];if(!g(r))return;let t=a(r,"x"),i=a(r,"y"),o=a(r,"width"),u=a(r,"height");if(void 0!==t&&void 0!==i&&void 0!==o&&void 0!==u)return{x:t,y:i,width:o,height:u}}function l(e,n){let r=e[n];if(!g(r))return;let t=a(r,"x"),i=a(r,"y");if(void 0!==t&&void 0!==i)return{x:t,y:i}}function a(e,n){let r=e[n];return"number"==typeof r?r:void 0}function c(e){return"string"==typeof e&&e.length>0?e:void 0}function m(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function p(e){return"ios"===e||"macos"===e||"android"===e||"linux"===e?e:void 0}function v(e){return"simulator"===e||"emulator"===e||"device"===e?e:void 0}function D(n){if(!g(n))throw new e("COMMAND_FAILED","Daemon returned an unexpected response shape.",{value:n});return n}function g(e){return"object"==typeof e&&null!==e}function h(e){let n={};for(let[r,t]of Object.entries(e))void 0!==t&&(n[r]=t);return n}function b(e){return e.split("\n").map(e=>e.trim()).filter(e=>e.length>0)}export{D as asRecord,g as isRecord,f as readDeviceTarget,i as readNullableString,t as readOptionalString,l as readPoint,s as readRect,d as readRequiredDeviceKind,o as readRequiredNumber,u as readRequiredPlatform,r as readRequiredString,b as splitNonEmptyTrimmedLines,h as stripUndefined};
|
package/dist/src/8699.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{screenshotFlagsFromOptions as e}from"./5310.js";import{AppError as t}from"./9152.js";import{readRequiredString as r,readRequiredPlatform as i,readRequiredDeviceKind as a,readNullableString as n,readDeviceTarget as o,readRect as s,asRecord as l,stripUndefined as u,isRecord as c,buildAppIdentifiers as d,buildDeviceIdentifiers as p,readRequiredNumber as f,readPoint as m,readOptionalString as h}from"./2805.js";import{INTERNAL_COMMANDS as g,BATCH_COMMAND_NAMES as y,PUBLIC_COMMANDS as v}from"./5792.js";import{assertResolvedAppsFilter as S}from"./1393.js";import{request as b,selectorSnapshotOptionsFromFlags as w,direct as A,requiredString as I,commonInputFromFlags as _,optionalString as N,readJsonObject as R,optionalNumber as M,optionalCliNumber as x,selectionOptionsFromFlags as k,commandNameSet as D,captureDaemonWriters as L,requiredDaemonString as q,splitRequiredSelector as P}from"./6085.js";import{parseDeviceRotation as C}from"./1998.js";import{compactRecord as V}from"./9404.js";import{interactionDaemonWriters as G}from"./8502.js";function E(e,t){let a=h(e,"bundleId"),n=h(e,"package");return{app:r(e,"app"),appPath:r(e,"appPath"),platform:i(e,"platform"),appId:a??n,bundleId:a,package:n,identifiers:d({session:t,bundleId:a,packageName:n})}}function U(e,r){let i=h(e,"bundleId"),a=h(e,"packageName"),n=i??a??h(e,"appId"),o=h(e,"launchTarget")??a??i??n;if(!o)throw new t("COMMAND_FAILED",'Daemon response is missing "launchTarget".',{response:e});return{appName:h(e,"appName"),appId:n,bundleId:i,packageName:a,launchTarget:o,installablePath:h(e,"installablePath"),archivePath:h(e,"archivePath"),materializationId:h(e,"materializationId"),materializationExpiresAt:h(e,"materializationExpiresAt"),identifiers:d({session:r,bundleId:i,packageName:a,appId:n})}}function $(e){return{released:!0===e.released,materializationId:r(e,"materializationId"),identifiers:{}}}function z(e){let{record:t,platform:r,id:i,name:n,target:o}=F(e,"name");return{platform:r,target:o,kind:a(t,"kind"),id:i,name:n,booted:"boolean"==typeof t.booted?t.booted:void 0,identifiers:p(r,i,n),...K(r,i)}}function T(e){let{record:t,platform:i,id:a,name:o,target:s}=F(e,"name"),l=r(t,"device"),u={session:o,...p(i,a,l)};return{name:o,createdAt:f(t,"createdAt"),device:{platform:i,target:s,id:a,name:l,identifiers:u,...K(i,a,n(t,"ios_simulator_device_set"))},identifiers:u}}function F(e,t){let a=l(e);return{record:a,platform:i(a,"platform"),id:r(a,"id"),name:r(a,t),target:o(a,"target")}}function K(e,t,r){return{ios:"ios"===e?{udid:t,...void 0!==r?{simulatorSetPath:r}:{}}:void 0,android:"android"===e?{serial:t}:void 0}}function B(e){if(!c(e))return;let t=e.platform,r=h(e,"metroHost"),i="number"==typeof e.metroPort?e.metroPort:void 0;return{platform:"ios"===t||"android"===t?t:void 0,metroHost:r,metroPort:i,bundleUrl:h(e,"bundleUrl"),launchUrl:h(e,"launchUrl")}}function O(e){let t=e.platform,r=h(e,"id"),i=h(e,"device");if("ios"!==t&&"macos"!==t&&"android"!==t&&"linux"!==t||!r||!i)return;let a=o(e,"target"),s=p(t,r,i);return{platform:t,target:a,id:r,name:i,identifiers:s,ios:"ios"===t?{udid:h(e,"device_udid")??r,simulatorSetPath:n(e,"ios_simulator_device_set")}:void 0,android:"android"===t?{serial:h(e,"serial")??r}:void 0}}function j(e){if(c(e)&&"number"==typeof e.durationMs&&"string"==typeof e.measuredAt&&"string"==typeof e.method)return{durationMs:e.durationMs,measuredAt:e.measuredAt,method:e.method,appTarget:h(e,"appTarget"),appBundleId:h(e,"appBundleId")}}function H(e){return Array.isArray(e)?e:[]}function J(e){let t=e.overlayRefs;if(!Array.isArray(t))return;let r=[];for(let e of t){if(!c(e))continue;let t=h(e,"ref"),i=s(e,"rect"),a=s(e,"overlayRect"),n=m(e,"center");t&&i&&a&&n&&r.push({ref:t,label:h(e,"label"),rect:i,overlayRect:a,center:n})}return r}function W(t){return u({stateDir:t.stateDir,daemonBaseUrl:t.daemonBaseUrl,daemonAuthToken:t.daemonAuthToken,daemonTransport:t.daemonTransport,daemonServerMode:t.daemonServerMode,tenant:t.tenant,sessionIsolation:t.sessionIsolation,runId:t.runId,leaseId:t.leaseId,leaseBackend:t.leaseBackend,platform:t.platform,target:t.target,device:t.device,udid:t.udid,serial:t.serial,iosSimulatorDeviceSet:t.iosSimulatorDeviceSet,androidDeviceAllowlist:t.androidDeviceAllowlist,surface:t.surface,activity:t.activity,launchConsole:t.launchConsole,launchArgs:t.launchArgs,relaunch:t.relaunch,shutdown:t.shutdown,saveScript:t.saveScript,noRecord:t.noRecord,backMode:t.backMode,metroHost:t.metroHost,metroPort:t.metroPort,bundleUrl:t.bundleUrl,launchUrl:t.launchUrl,snapshotInteractiveOnly:t.interactiveOnly,snapshotCompact:t.compact,snapshotDepth:t.depth,snapshotScope:t.scope,snapshotRaw:t.raw,snapshotForceFull:t.forceFull,...e(t),appsFilter:t.appsFilter,out:t.out,count:t.count,fps:t.fps,quality:t.quality,hideTouches:t.hideTouches,intervalMs:t.intervalMs,delayMs:t.delayMs,holdMs:t.holdMs,jitterPx:t.jitterPx,pixels:t.pixels,doubleTap:t.doubleTap,clickButton:t.clickButton,pauseMs:t.pauseMs,pattern:t.pattern,headless:t.headless,restart:t.restart,replayUpdate:t.replayUpdate,replayBackend:t.replayBackend,replayEnv:t.replayEnv,replayShellEnv:t.replayShellEnv,failFast:t.failFast,timeoutMs:t.timeoutMs,retries:t.retries,artifactsDir:t.artifactsDir,reportJunit:t.reportJunit,findFirst:t.findFirst,findLast:t.findLast,networkInclude:t.networkInclude,batchOnError:t.batchOnError,batchMaxSteps:t.batchMaxSteps,batchSteps:t.batchSteps,verbose:t.debug})}function Q(e){return u({requestId:e.requestId,cwd:e.cwd,debug:e.debug,lockPolicy:e.lockPolicy,lockPlatform:e.lockPlatform,tenantId:e.tenant,runId:e.runId,leaseId:e.leaseId,leaseBackend:e.leaseBackend,leaseTtlMs:e.leaseTtlMs,sessionIsolation:e.sessionIsolation,installSource:e.installSource,retainMaterializedPaths:e.retainMaterializedPaths,materializedPathRetentionMs:e.materializedPathRetentionMs,materializationId:e.materializationId})}function X(e){return e??"default"}function Y(e,r){if(!e||"object"!=typeof e||Array.isArray(e))throw new t("INVALID_ARGS",`${r} installSource must be an object.`);if("github-actions-artifact"!==et(e.type,`${r} installSource.type`))throw new t("INVALID_ARGS",`${r} installSource.type must be "github-actions-artifact".`);let{owner:i,repo:a}=ee(et(e.repo,`${r} installSource.repo`),`${r} installSource.repo`);return Z(i,a,e.artifact,`${r} installSource.artifact`)}function Z(e,r,i,a){var n;return"number"==typeof i||"string"==typeof(n=i)&&/^\d+$/.test(n.trim())?{kind:"github-actions-artifact",owner:e,repo:r,artifactId:function(e,r){let i="number"==typeof e?e:"string"==typeof e?Number(e):NaN;if(!Number.isInteger(i))throw new t("INVALID_ARGS",`${r} must be an integer.`);return i}(i,a)}:{kind:"github-actions-artifact",owner:e,repo:r,artifactName:et(i,a)}}function ee(e,r){let i=e.indexOf("/");if(i<=0||i===e.length-1||-1!==e.indexOf("/",i+1))throw new t("INVALID_ARGS",`${r} must use owner/repo.`);let a={owner:e.slice(0,i).trim(),repo:e.slice(i+1).trim()};if(!a.owner||!a.repo)throw new t("INVALID_ARGS",`${r} must use owner/repo.`);return a}function et(e,r){let i="string"==typeof e&&e.trim().length>0?e.trim():void 0;if(!i)throw new t("INVALID_ARGS",`${r} must be a non-empty string.`);return i}let er={devices:(e,t)=>_(t),apps:(e,t)=>({..._(t),appsFilter:S(t.appsFilter)}),session:(e,r)=>({..._(r),action:function(e){let r=e??"list";if("list"===r)return r;throw new t("INVALID_ARGS","session only supports list")}(e[0])}),boot:(e,t)=>({..._(t),headless:t.headless}),open:(e,t)=>({..._(t),app:e[0],url:e[1],surface:t.surface,activity:t.activity,launchConsole:t.launchConsole,launchArgs:t.launchArgs,relaunch:t.relaunch,saveScript:t.saveScript,noRecord:t.noRecord}),close:(e,t)=>({..._(t),app:e[0],shutdown:t.shutdown,saveScript:t.saveScript}),install:ea,reinstall:ea,"install-from-source":(e,r)=>({..._(r),source:function(e,r){let i=e[0]?.trim();if(e.length>1)throw new t("INVALID_ARGS","install-from-source accepts either one <url> positional or --github-actions-artifact");let a=r.githubActionsArtifact?function(e,r="--github-actions-artifact"){let i=e.indexOf(":");if(i<=0||i===e.length-1)throw new t("INVALID_ARGS",`${r} must use owner/repo:artifact, for example thymikee/RNCLI83:6635342232`);let{owner:a,repo:n}=ee(e.slice(0,i),r);return Z(a,n,e.slice(i+1),`${r} artifact`)}(r.githubActionsArtifact):void 0,n=r.installSource;if(1!=+!!i+ +!!a+ +!!n)throw new t("INVALID_ARGS","install-from-source requires exactly one source: <url>, --github-actions-artifact, or config installSource");if(!i&&r.header&&r.header.length>0)throw new t("INVALID_ARGS","install-from-source --header is only supported for URL sources");return a||n||{kind:"url",url:i,headers:function(e){if(!e||0===e.length)return;let r={};for(let i of e){let e=i.indexOf(":");if(e<=0)throw new t("INVALID_ARGS",`Invalid --header value "${i}". Expected "name:value".`);let a=i.slice(0,e).trim(),n=i.slice(e+1).trim();if(!a)throw new t("INVALID_ARGS",`Invalid --header value "${i}". Header name cannot be empty.`);r[a]=n}return r}(r.header)}}(e,r),retainPaths:r.retainPaths,retentionMs:r.retentionMs}),push:(e,t)=>({..._(t),app:I(e[0],"push requires bundleOrPackage"),payload:I(e[1],"push requires payloadOrJson")}),"trigger-app-event":(e,t)=>({..._(t),event:I(e[0],"trigger-app-event requires event"),payload:e[1]?R(e[1],"trigger-app-event payload"):void 0})},ei={devices:A(v.devices),boot:A(v.boot),apps:A(v.apps),open:A(v.open,function(e){return e.app?e.url?[e.app,e.url]:[e.app]:[]}),close:A(v.close,e=>N(e.app)),install:A(v.install,e=>en(e.app,e.appPath)),reinstall:A(v.reinstall,e=>en(e.app,e.appPath)),"install-from-source":e=>b(g.installSource,[],{...e,installSource:e.source,retainMaterializedPaths:e.retainPaths,materializedPathRetentionMs:e.retentionMs}),push:A(v.push,e=>{var t;return[(t=e).app,"string"==typeof t.payload?t.payload:JSON.stringify(t.payload)]}),"trigger-app-event":A(v.triggerAppEvent,e=>{var t;return[(t=e).event,...t.payload?[JSON.stringify(t.payload)]:[]]})};function ea(e,t,r="install"){return{..._(t),app:I(e[0],`${r} requires app`),appPath:I(e[1],`${r} requires path`)}}function en(e,t){return[q(e,"missing first positional"),q(t,"missing second positional")]}let eo={gesture:function(e,r){let i=e[0],a=e.slice(1),n=_(r);switch(i){case"pan":return{...n,kind:i,origin:{x:Number(a[0]),y:Number(a[1])},delta:{x:Number(a[2]),y:Number(a[3])},durationMs:x(a[4])};case"fling":return{...n,kind:i,direction:a[0],origin:{x:Number(a[1]),y:Number(a[2])},distance:x(a[3]),durationMs:x(a[4])};case"swipe":return{...n,kind:i,preset:a[0],durationMs:x(a[1])};case"pinch":return{...n,kind:i,scale:Number(a[0]),origin:void 0===a[1]||void 0===a[2]?void 0:{x:Number(a[1]),y:Number(a[2])}};case"rotate":return{...n,kind:i,degrees:Number(a[0]),origin:void 0===a[1]||void 0===a[2]?void 0:{x:Number(a[1]),y:Number(a[2])},velocity:x(a[3])};case"transform":return{...n,kind:i,origin:{x:Number(a[0]),y:Number(a[1])},delta:{x:Number(a[2]),y:Number(a[3])},scale:Number(a[4]),degrees:Number(a[5]),durationMs:x(a[6])};default:throw new t("INVALID_ARGS","gesture requires pan, fling, swipe, pinch, rotate, or transform")}}},es={gesture:A(v.gesture,function(e){switch(e.kind){case"pan":return["pan",String(e.origin?.x),String(e.origin?.y),String(e.delta?.x),String(e.delta?.y),...M(e.durationMs)];case"fling":return["fling",q(e.direction,"gesture fling requires direction"),String(e.origin?.x),String(e.origin?.y),...M(e.distance),...M(e.durationMs)];case"swipe":return el(e);case"pinch":return["pinch",String(e.scale),...M(e.origin?.x),...M(e.origin?.y)];case"rotate":return["rotate",String(e.degrees),...M(e.origin?.x),...M(e.origin?.y),...M(e.velocity)];case"transform":return["transform",String(e.origin?.x),String(e.origin?.y),String(e.delta?.x),String(e.delta?.y),String(e.scale),String(e.degrees),...M(e.durationMs)];default:throw new t("INVALID_ARGS","gesture requires pan, fling, swipe, pinch, rotate, or transform")}}),"gesture-pan":A(v.gesture,function(e){return["pan",String(e.x),String(e.y),String(e.dx),String(e.dy),...M(e.durationMs)]}),"gesture-fling":A(v.gesture,e=>{var t;let r;return r=void 0!==(t=e).durationMs?t.distance??180:t.distance,["fling",t.direction,String(t.x),String(t.y),...M(r),...M(t.durationMs)]}),"gesture-swipe":A(v.gesture,el),"gesture-pinch":A(v.gesture,function(e){return["pinch",String(e.scale),...M(e.x),...M(e.y)]}),"gesture-rotate":A(v.gesture,e=>(function(e){var r=e;if(void 0===r.x&&void 0!==r.y||void 0!==r.x&&void 0===r.y)throw new t("INVALID_ARGS","gesture rotate center requires both x and y");let i=void 0===e.x||void 0===e.y?[]:[String(e.x),String(e.y)];return["rotate",String(e.degrees),...i,...M(e.velocity)]})(e)),"gesture-transform":A(v.gesture,function(e){return["transform",String(e.x),String(e.y),String(e.dx),String(e.dy),String(e.scale),String(e.degrees),...M(e.durationMs)]})};function el(e){return["swipe",q(e.preset,"gesture swipe requires preset"),...M(e.durationMs)]}let eu={perf:(e,t)=>_(t),logs:(e,r)=>({..._(r),action:function(e){if(void 0!==e){if("path"===e||"start"===e||"stop"===e||"doctor"===e||"mark"===e||"clear"===e)return e;throw new t("INVALID_ARGS","logs requires path, start, stop, doctor, mark, or clear")}}(e[0]),message:e.slice(1).join(" ")||void 0,restart:r.restart}),network:(e,r)=>({..._(r),action:function(e){if(void 0!==e){if("dump"===e||"log"===e)return e;throw new t("INVALID_ARGS","network requires dump or log")}}(e[0]),limit:x(e[1]),include:r.networkInclude??function(e){if(void 0!==e){if("summary"===e||"headers"===e||"body"===e||"all"===e)return e;throw new t("INVALID_ARGS","network include mode must be summary, headers, body, or all")}}(e[2])}),record:(e,t)=>({..._(t),action:ep(e[0],"record"),path:e[1],fps:t.fps,quality:t.quality,hideTouches:t.hideTouches}),trace:(e,t)=>({..._(t),action:ep(e[0],"trace"),path:e[1]})},ec={perf:A(v.perf),logs:A(v.logs,e=>{var t;return[(t=e).action??"path",...N(t.message)]}),network:e=>{var t;return b(v.network,[...(t=e).action?[t.action]:[],...M(t.limit)],{...e,networkInclude:e.include})},record:A(v.record,e=>ed(e)),trace:A(v.trace,e=>ed(e))};function ed(e){return[e.action,...N(e.path)]}function ep(e,r){if("start"===e||"stop"===e)return e;throw new t("INVALID_ARGS",`${r} requires start|stop`)}let ef={replay:(e,t)=>({..._(t),path:I(e[0],"replay requires path"),update:t.replayUpdate,backend:t.replayMaestro?"maestro":void 0,env:t.replayEnv}),test:(e,t)=>({..._(t),paths:e,update:t.replayUpdate,backend:t.replayMaestro?"maestro":void 0,env:t.replayEnv,failFast:t.failFast,timeoutMs:t.timeoutMs,retries:t.retries,artifactsDir:t.artifactsDir,reportJunit:t.reportJunit})};function em(e){return e.backend??(!0===e.maestro?"maestro":void 0)}function eh(e){let t={};for(let[r,i]of Object.entries(e))"string"==typeof i&&r.startsWith("AD_VAR_")&&(t[r]=i);return t}let eg={find:(e,r)=>(function(e,r){var i;let a={...{depth:(i=r).snapshotDepth,raw:i.snapshotRaw},...k(r),first:r.findFirst,last:r.findLast},n=function(e){if("text"===e||"label"===e||"value"===e||"role"===e||"id"===e)return e}(e[0]),o=void 0!==n,s=o?e[1]:e[0],l=o?2:1,u=e[l];if(void 0===u)return{...a,locator:n,query:ev(s)};if("get"===u){let r=e[l+1];if("text"===r)return{...a,locator:n,query:ev(s),action:"getText"};if("attrs"===r)return{...a,locator:n,query:ev(s),action:"getAttrs"};throw new t("INVALID_ARGS","find get only supports text or attrs")}if("wait"===u)return{...a,locator:n,query:ev(s),action:"wait",timeoutMs:x(e[l+1])};if("fill"===u||"type"===u)return{...a,locator:n,query:ev(s),action:u,value:e.slice(l+1).join(" ")};if("click"===u||"focus"===u||"exists"===u)return{...a,locator:n,query:ev(s),action:u};throw new t("INVALID_ARGS",`Unsupported find action: ${u}`)})(e,r),is:(e,r)=>(function(e,r){let i={...w(r),...k(r)},a=e[0],n=P(e.slice(1),{preferTrailingValue:"text"===a});if("text"===a)return{...i,predicate:a,selector:n.selectorExpression,value:n.rest.join(" ")};if("visible"===a||"hidden"===a||"exists"===a||"editable"===a||"selected"===a)return{...i,predicate:a,selector:n.selectorExpression};throw new t("INVALID_ARGS","is requires predicate: visible|hidden|exists|editable|selected|text")})(e,r)},ey={is:A(v.is,e=>{var t;return[(t=e).predicate,t.selector,..."text"===t.predicate?[t.value]:[]]}),find:e=>b(v.find,function(e){let t=e.locator&&"any"!==e.locator?[e.locator,e.query]:[e.query];switch(e.action){case void 0:case"click":case"focus":case"exists":return e.action?[...t,e.action]:t;case"getText":return[...t,"get","text"];case"getAttrs":return[...t,"get","attrs"];case"wait":return[...t,"wait",...M(e.timeoutMs)];case"fill":case"type":return[...t,e.action,e.value]}}(e),{...e,findFirst:e.first,findLast:e.last})};function ev(e){if(void 0===e||""===e)throw new t("INVALID_ARGS","find requires query");return e}let eS={appstate:(e,t)=>_(t),home:(e,t)=>_(t),"app-switcher":(e,t)=>_(t),back:(e,t)=>({..._(t),mode:t.backMode}),rotate:(e,t)=>({..._(t),orientation:C(e[0])}),keyboard:(e,r)=>({..._(r),...function(e){if(e.length>1)throw new t("INVALID_ARGS","keyboard accepts at most one action argument.");return V({action:function(e){let r=e?.toLowerCase();if("get"===r)return"status";if(void 0===r||"status"===r||"dismiss"===r||"enter"===r||"return"===r)return r;throw new t("INVALID_ARGS","keyboard action must be status, get, dismiss, enter, or return.")}(e[0])})}(e)}),clipboard:(e,r)=>({..._(r),...function(e){let r=e[0]?.toLowerCase();if("read"!==r&&"write"!==r)throw new t("INVALID_ARGS","clipboard requires a subcommand: read or write.");if("read"===r){if(1!==e.length)throw new t("INVALID_ARGS","clipboard read does not accept additional arguments.");return{action:r}}if(e.length<2)throw new t("INVALID_ARGS","clipboard write requires text.");return{action:r,text:e.slice(1).join(" ")}}(e)}),"react-native":(e,r)=>({..._(r),action:function(e){if("dismiss-overlay"===e)return e;throw new t("INVALID_ARGS","react-native supports only: dismiss-overlay")}(e[0])})},eb={appstate:A(v.appState),back:e=>{var t;return b(v.back,[],{...e,backMode:"in-app"===(t=e.mode)||"system"===t?t:void 0})},home:A(v.home),rotate:A(v.rotate,e=>[q(e.orientation,"rotate requires orientation")]),"app-switcher":A(v.appSwitcher),keyboard:A(v.keyboard,e=>N(e.action)),clipboard:A(v.clipboard,e=>{var t;return"read"===(t=e).action?["read"]:["write",t.text]}),"react-native":A(v.reactNative,e=>[q(e.action,"react-native requires action")])},ew={...ei,...L,...G,...es,...ey,...ec,replay:e=>b(v.replay,[q(e.path,"replay requires path")],{...e,replayUpdate:e.update,replayBackend:em(e),replayEnv:e.env,replayShellEnv:eh(process.env)}),test:e=>b(v.test,e.paths??[],{...e,replayUpdate:e.update,replayBackend:em(e),replayEnv:e.env,replayShellEnv:eh(process.env)}),...eb,batch:e=>b(v.batch,[],{...e,batchSteps:function(e){if(!Array.isArray(e)||0===e.length)throw new t("INVALID_ARGS","batch requires a non-empty steps array.");return e.map((e,r)=>{var i;let a,n,o,s,l,u;return o=function(e,r){let i="string"==typeof e.command?e.command.trim().toLowerCase():"";if(eI.has(i))return i;throw new t("INVALID_ARGS",`Batch step ${r} command is not available through command batch: ${String(e.command)}`)}(n=function(e,r){if(!e||"object"!=typeof e||Array.isArray(e))throw new t("INVALID_ARGS",`Invalid batch step ${r}.`);return e}(e,i=r+1),i),s=function(e,r){let i=e.input;if(!i||"object"!=typeof i||Array.isArray(i))throw new t("INVALID_ARGS",`Batch step ${r} input must be an object.`);return i}(n,i),l=function(e,r){let i=e.runtime;if(void 0!==i&&(!i||"object"!=typeof i||Array.isArray(i)))throw new t("INVALID_ARGS",`Batch step ${r} runtime must be an object.`);return i}(n,i),{...u={command:(a=e_(o,s)).command,positionals:a.positionals,flags:W(a.options),runtime:a.options.runtime},runtime:l??u.runtime}})}(e.steps),batchOnError:e.onError,batchMaxSteps:e.maxSteps})},eA=y,eI=D(eA);function e_(e,t){return ew[e](t)}export{er as appCliReaders,eA as batchCommandNames,W as buildFlags,Q as buildMeta,eo as gestureCliReaders,E as normalizeDeployResult,z as normalizeDevice,U as normalizeInstallFromSourceResult,$ as normalizeMaterializationReleaseResult,O as normalizeOpenDevice,B as normalizeRuntimeHints,T as normalizeSession,j as normalizeStartupSample,eu as observabilityCliReaders,Y as parseInstallSourceConfig,e_ as prepareDaemonCommandRequest,J as readScreenshotOverlayRefs,H as readSnapshotNodes,ef as replayCliReaders,X as resolveSessionName,eg as selectorCliReaders,eS as systemCliReaders};
|
|
1
|
+
import{screenshotFlagsFromOptions as e}from"./5310.js";import{AppError as t}from"./9152.js";import{readRequiredString as r,readRequiredPlatform as i,readRequiredDeviceKind as a,readNullableString as n,readDeviceTarget as o,readRect as s,asRecord as l,stripUndefined as u,isRecord as c,readRequiredNumber as d,readPoint as p,readOptionalString as f}from"./7455.js";import{buildAppIdentifiers as m,buildDeviceIdentifiers as h}from"./6232.js";import{INTERNAL_COMMANDS as g,BATCH_COMMAND_NAMES as y,PUBLIC_COMMANDS as v}from"./5792.js";import{assertResolvedAppsFilter as S}from"./1393.js";import{request as b,selectorSnapshotOptionsFromFlags as w,direct as A,requiredString as I,commonInputFromFlags as _,optionalString as N,readJsonObject as R,optionalNumber as M,optionalCliNumber as x,selectionOptionsFromFlags as k,commandNameSet as D,captureDaemonWriters as L,requiredDaemonString as P,splitRequiredSelector as q}from"./6085.js";import{parseDeviceRotation as C}from"./1998.js";import{compactRecord as V}from"./9404.js";import{interactionDaemonWriters as G}from"./8502.js";function E(e,t){let a=f(e,"bundleId"),n=f(e,"package");return{app:r(e,"app"),appPath:r(e,"appPath"),platform:i(e,"platform"),appId:a??n,bundleId:a,package:n,identifiers:m({session:t,bundleId:a,packageName:n})}}function U(e,r){let i=f(e,"bundleId"),a=f(e,"packageName"),n=i??a??f(e,"appId"),o=f(e,"launchTarget")??a??i??n;if(!o)throw new t("COMMAND_FAILED",'Daemon response is missing "launchTarget".',{response:e});return{appName:f(e,"appName"),appId:n,bundleId:i,packageName:a,launchTarget:o,installablePath:f(e,"installablePath"),archivePath:f(e,"archivePath"),materializationId:f(e,"materializationId"),materializationExpiresAt:f(e,"materializationExpiresAt"),identifiers:m({session:r,bundleId:i,packageName:a,appId:n})}}function $(e){return{released:!0===e.released,materializationId:r(e,"materializationId"),identifiers:{}}}function z(e){let{record:t,platform:r,id:i,name:n,target:o}=T(e,"name");return{platform:r,target:o,kind:a(t,"kind"),id:i,name:n,booted:"boolean"==typeof t.booted?t.booted:void 0,identifiers:h(r,i,n),...F(r,i)}}function K(e){let{record:t,platform:i,id:a,name:o,target:s}=T(e,"name"),l=r(t,"device"),u={session:o,...h(i,a,l)};return{name:o,createdAt:d(t,"createdAt"),device:{platform:i,target:s,id:a,name:l,identifiers:u,...F(i,a,n(t,"ios_simulator_device_set"))},identifiers:u}}function T(e,t){let a=l(e);return{record:a,platform:i(a,"platform"),id:r(a,"id"),name:r(a,t),target:o(a,"target")}}function F(e,t,r){return{ios:"ios"===e?{udid:t,...void 0!==r?{simulatorSetPath:r}:{}}:void 0,android:"android"===e?{serial:t}:void 0}}function B(e){if(!c(e))return;let t=e.platform,r=f(e,"metroHost"),i="number"==typeof e.metroPort?e.metroPort:void 0;return{platform:"ios"===t||"android"===t?t:void 0,metroHost:r,metroPort:i,bundleUrl:f(e,"bundleUrl"),launchUrl:f(e,"launchUrl")}}function O(e){let t=e.platform,r=f(e,"id"),i=f(e,"device");if("ios"!==t&&"macos"!==t&&"android"!==t&&"linux"!==t||!r||!i)return;let a=o(e,"target"),s=h(t,r,i);return{platform:t,target:a,id:r,name:i,identifiers:s,ios:"ios"===t?{udid:f(e,"device_udid")??r,simulatorSetPath:n(e,"ios_simulator_device_set")}:void 0,android:"android"===t?{serial:f(e,"serial")??r}:void 0}}function H(e){if(c(e)&&"number"==typeof e.durationMs&&"string"==typeof e.measuredAt&&"string"==typeof e.method)return{durationMs:e.durationMs,measuredAt:e.measuredAt,method:e.method,appTarget:f(e,"appTarget"),appBundleId:f(e,"appBundleId")}}function j(e){return Array.isArray(e)?e:[]}function J(e){let t=e.overlayRefs;if(!Array.isArray(t))return;let r=[];for(let e of t){if(!c(e))continue;let t=f(e,"ref"),i=s(e,"rect"),a=s(e,"overlayRect"),n=p(e,"center");t&&i&&a&&n&&r.push({ref:t,label:f(e,"label"),rect:i,overlayRect:a,center:n})}return r}function W(t){return u({stateDir:t.stateDir,daemonBaseUrl:t.daemonBaseUrl,daemonAuthToken:t.daemonAuthToken,daemonTransport:t.daemonTransport,daemonServerMode:t.daemonServerMode,tenant:t.tenant,sessionIsolation:t.sessionIsolation,runId:t.runId,leaseId:t.leaseId,leaseBackend:t.leaseBackend,platform:t.platform,target:t.target,device:t.device,udid:t.udid,serial:t.serial,iosSimulatorDeviceSet:t.iosSimulatorDeviceSet,androidDeviceAllowlist:t.androidDeviceAllowlist,surface:t.surface,activity:t.activity,launchConsole:t.launchConsole,launchArgs:t.launchArgs,relaunch:t.relaunch,shutdown:t.shutdown,saveScript:t.saveScript,noRecord:t.noRecord,backMode:t.backMode,metroHost:t.metroHost,metroPort:t.metroPort,bundleUrl:t.bundleUrl,launchUrl:t.launchUrl,snapshotInteractiveOnly:t.interactiveOnly,snapshotCompact:t.compact,snapshotDepth:t.depth,snapshotScope:t.scope,snapshotRaw:t.raw,snapshotForceFull:t.forceFull,...e(t),appsFilter:t.appsFilter,out:t.out,count:t.count,fps:t.fps,quality:t.quality,hideTouches:t.hideTouches,intervalMs:t.intervalMs,delayMs:t.delayMs,holdMs:t.holdMs,jitterPx:t.jitterPx,pixels:t.pixels,doubleTap:t.doubleTap,clickButton:t.clickButton,pauseMs:t.pauseMs,pattern:t.pattern,headless:t.headless,restart:t.restart,replayUpdate:t.replayUpdate,replayBackend:t.replayBackend,replayEnv:t.replayEnv,replayShellEnv:t.replayShellEnv,failFast:t.failFast,timeoutMs:t.timeoutMs,retries:t.retries,artifactsDir:t.artifactsDir,reportJunit:t.reportJunit,findFirst:t.findFirst,findLast:t.findLast,networkInclude:t.networkInclude,batchOnError:t.batchOnError,batchMaxSteps:t.batchMaxSteps,batchSteps:t.batchSteps,verbose:t.debug})}function Q(e){return u({requestId:e.requestId,cwd:e.cwd,debug:e.debug,lockPolicy:e.lockPolicy,lockPlatform:e.lockPlatform,tenantId:e.tenant,runId:e.runId,leaseId:e.leaseId,leaseBackend:e.leaseBackend,leaseTtlMs:e.leaseTtlMs,sessionIsolation:e.sessionIsolation,installSource:e.installSource,retainMaterializedPaths:e.retainMaterializedPaths,materializedPathRetentionMs:e.materializedPathRetentionMs,materializationId:e.materializationId})}function X(e){return e??"default"}function Y(e,r){if(!e||"object"!=typeof e||Array.isArray(e))throw new t("INVALID_ARGS",`${r} installSource must be an object.`);if("github-actions-artifact"!==et(e.type,`${r} installSource.type`))throw new t("INVALID_ARGS",`${r} installSource.type must be "github-actions-artifact".`);let{owner:i,repo:a}=ee(et(e.repo,`${r} installSource.repo`),`${r} installSource.repo`);return Z(i,a,e.artifact,`${r} installSource.artifact`)}function Z(e,r,i,a){var n;return"number"==typeof i||"string"==typeof(n=i)&&/^\d+$/.test(n.trim())?{kind:"github-actions-artifact",owner:e,repo:r,artifactId:function(e,r){let i="number"==typeof e?e:"string"==typeof e?Number(e):NaN;if(!Number.isInteger(i))throw new t("INVALID_ARGS",`${r} must be an integer.`);return i}(i,a)}:{kind:"github-actions-artifact",owner:e,repo:r,artifactName:et(i,a)}}function ee(e,r){let i=e.indexOf("/");if(i<=0||i===e.length-1||-1!==e.indexOf("/",i+1))throw new t("INVALID_ARGS",`${r} must use owner/repo.`);let a={owner:e.slice(0,i).trim(),repo:e.slice(i+1).trim()};if(!a.owner||!a.repo)throw new t("INVALID_ARGS",`${r} must use owner/repo.`);return a}function et(e,r){let i="string"==typeof e&&e.trim().length>0?e.trim():void 0;if(!i)throw new t("INVALID_ARGS",`${r} must be a non-empty string.`);return i}let er={devices:(e,t)=>_(t),apps:(e,t)=>({..._(t),appsFilter:S(t.appsFilter)}),session:(e,r)=>({..._(r),action:function(e){let r=e??"list";if("list"===r)return r;throw new t("INVALID_ARGS","session only supports list")}(e[0])}),boot:(e,t)=>({..._(t),headless:t.headless}),open:(e,t)=>({..._(t),app:e[0],url:e[1],surface:t.surface,activity:t.activity,launchConsole:t.launchConsole,launchArgs:t.launchArgs,relaunch:t.relaunch,saveScript:t.saveScript,noRecord:t.noRecord}),close:(e,t)=>({..._(t),app:e[0],shutdown:t.shutdown,saveScript:t.saveScript}),install:ea,reinstall:ea,"install-from-source":(e,r)=>({..._(r),source:function(e,r){let i=e[0]?.trim();if(e.length>1)throw new t("INVALID_ARGS","install-from-source accepts either one <url> positional or --github-actions-artifact");let a=r.githubActionsArtifact?function(e,r="--github-actions-artifact"){let i=e.indexOf(":");if(i<=0||i===e.length-1)throw new t("INVALID_ARGS",`${r} must use owner/repo:artifact, for example thymikee/RNCLI83:6635342232`);let{owner:a,repo:n}=ee(e.slice(0,i),r);return Z(a,n,e.slice(i+1),`${r} artifact`)}(r.githubActionsArtifact):void 0,n=r.installSource;if(1!=+!!i+ +!!a+ +!!n)throw new t("INVALID_ARGS","install-from-source requires exactly one source: <url>, --github-actions-artifact, or config installSource");if(!i&&r.header&&r.header.length>0)throw new t("INVALID_ARGS","install-from-source --header is only supported for URL sources");return a||n||{kind:"url",url:i,headers:function(e){if(!e||0===e.length)return;let r={};for(let i of e){let e=i.indexOf(":");if(e<=0)throw new t("INVALID_ARGS",`Invalid --header value "${i}". Expected "name:value".`);let a=i.slice(0,e).trim(),n=i.slice(e+1).trim();if(!a)throw new t("INVALID_ARGS",`Invalid --header value "${i}". Header name cannot be empty.`);r[a]=n}return r}(r.header)}}(e,r),retainPaths:r.retainPaths,retentionMs:r.retentionMs}),push:(e,t)=>({..._(t),app:I(e[0],"push requires bundleOrPackage"),payload:I(e[1],"push requires payloadOrJson")}),"trigger-app-event":(e,t)=>({..._(t),event:I(e[0],"trigger-app-event requires event"),payload:e[1]?R(e[1],"trigger-app-event payload"):void 0})},ei={devices:A(v.devices),boot:A(v.boot),apps:A(v.apps),open:A(v.open,function(e){return e.app?e.url?[e.app,e.url]:[e.app]:[]}),close:A(v.close,e=>N(e.app)),install:A(v.install,e=>en(e.app,e.appPath)),reinstall:A(v.reinstall,e=>en(e.app,e.appPath)),"install-from-source":e=>b(g.installSource,[],{...e,installSource:e.source,retainMaterializedPaths:e.retainPaths,materializedPathRetentionMs:e.retentionMs}),push:A(v.push,e=>{var t;return[(t=e).app,"string"==typeof t.payload?t.payload:JSON.stringify(t.payload)]}),"trigger-app-event":A(v.triggerAppEvent,e=>{var t;return[(t=e).event,...t.payload?[JSON.stringify(t.payload)]:[]]})};function ea(e,t,r="install"){return{..._(t),app:I(e[0],`${r} requires app`),appPath:I(e[1],`${r} requires path`)}}function en(e,t){return[P(e,"missing first positional"),P(t,"missing second positional")]}let eo={gesture:function(e,r){let i=e[0],a=e.slice(1),n=_(r);switch(i){case"pan":return{...n,kind:i,origin:{x:Number(a[0]),y:Number(a[1])},delta:{x:Number(a[2]),y:Number(a[3])},durationMs:x(a[4])};case"fling":return{...n,kind:i,direction:a[0],origin:{x:Number(a[1]),y:Number(a[2])},distance:x(a[3]),durationMs:x(a[4])};case"swipe":return{...n,kind:i,preset:a[0],durationMs:x(a[1])};case"pinch":return{...n,kind:i,scale:Number(a[0]),origin:void 0===a[1]||void 0===a[2]?void 0:{x:Number(a[1]),y:Number(a[2])}};case"rotate":return{...n,kind:i,degrees:Number(a[0]),origin:void 0===a[1]||void 0===a[2]?void 0:{x:Number(a[1]),y:Number(a[2])},velocity:x(a[3])};case"transform":return{...n,kind:i,origin:{x:Number(a[0]),y:Number(a[1])},delta:{x:Number(a[2]),y:Number(a[3])},scale:Number(a[4]),degrees:Number(a[5]),durationMs:x(a[6])};default:throw new t("INVALID_ARGS","gesture requires pan, fling, swipe, pinch, rotate, or transform")}}},es={gesture:A(v.gesture,function(e){switch(e.kind){case"pan":return["pan",String(e.origin?.x),String(e.origin?.y),String(e.delta?.x),String(e.delta?.y),...M(e.durationMs)];case"fling":return["fling",P(e.direction,"gesture fling requires direction"),String(e.origin?.x),String(e.origin?.y),...M(e.distance),...M(e.durationMs)];case"swipe":return el(e);case"pinch":return["pinch",String(e.scale),...M(e.origin?.x),...M(e.origin?.y)];case"rotate":return["rotate",String(e.degrees),...M(e.origin?.x),...M(e.origin?.y),...M(e.velocity)];case"transform":return["transform",String(e.origin?.x),String(e.origin?.y),String(e.delta?.x),String(e.delta?.y),String(e.scale),String(e.degrees),...M(e.durationMs)];default:throw new t("INVALID_ARGS","gesture requires pan, fling, swipe, pinch, rotate, or transform")}}),"gesture-pan":A(v.gesture,function(e){return["pan",String(e.x),String(e.y),String(e.dx),String(e.dy),...M(e.durationMs)]}),"gesture-fling":A(v.gesture,e=>{var t;let r;return r=void 0!==(t=e).durationMs?t.distance??180:t.distance,["fling",t.direction,String(t.x),String(t.y),...M(r),...M(t.durationMs)]}),"gesture-swipe":A(v.gesture,el),"gesture-pinch":A(v.gesture,function(e){return["pinch",String(e.scale),...M(e.x),...M(e.y)]}),"gesture-rotate":A(v.gesture,e=>(function(e){var r=e;if(void 0===r.x&&void 0!==r.y||void 0!==r.x&&void 0===r.y)throw new t("INVALID_ARGS","gesture rotate center requires both x and y");let i=void 0===e.x||void 0===e.y?[]:[String(e.x),String(e.y)];return["rotate",String(e.degrees),...i,...M(e.velocity)]})(e)),"gesture-transform":A(v.gesture,function(e){return["transform",String(e.x),String(e.y),String(e.dx),String(e.dy),String(e.scale),String(e.degrees),...M(e.durationMs)]})};function el(e){return["swipe",P(e.preset,"gesture swipe requires preset"),...M(e.durationMs)]}let eu={perf:(e,t)=>_(t),logs:(e,r)=>({..._(r),action:function(e){if(void 0!==e){if("path"===e||"start"===e||"stop"===e||"doctor"===e||"mark"===e||"clear"===e)return e;throw new t("INVALID_ARGS","logs requires path, start, stop, doctor, mark, or clear")}}(e[0]),message:e.slice(1).join(" ")||void 0,restart:r.restart}),network:(e,r)=>({..._(r),action:function(e){if(void 0!==e){if("dump"===e||"log"===e)return e;throw new t("INVALID_ARGS","network requires dump or log")}}(e[0]),limit:x(e[1]),include:r.networkInclude??function(e){if(void 0!==e){if("summary"===e||"headers"===e||"body"===e||"all"===e)return e;throw new t("INVALID_ARGS","network include mode must be summary, headers, body, or all")}}(e[2])}),record:(e,t)=>({..._(t),action:ep(e[0],"record"),path:e[1],fps:t.fps,quality:t.quality,hideTouches:t.hideTouches}),trace:(e,t)=>({..._(t),action:ep(e[0],"trace"),path:e[1]})},ec={perf:A(v.perf),logs:A(v.logs,e=>{var t;return[(t=e).action??"path",...N(t.message)]}),network:e=>{var t;return b(v.network,[...(t=e).action?[t.action]:[],...M(t.limit)],{...e,networkInclude:e.include})},record:A(v.record,e=>ed(e)),trace:A(v.trace,e=>ed(e))};function ed(e){return[e.action,...N(e.path)]}function ep(e,r){if("start"===e||"stop"===e)return e;throw new t("INVALID_ARGS",`${r} requires start|stop`)}let ef={replay:(e,t)=>({..._(t),path:I(e[0],"replay requires path"),update:t.replayUpdate,backend:t.replayMaestro?"maestro":void 0,env:t.replayEnv}),test:(e,t)=>({..._(t),paths:e,update:t.replayUpdate,backend:t.replayMaestro?"maestro":void 0,env:t.replayEnv,failFast:t.failFast,timeoutMs:t.timeoutMs,retries:t.retries,artifactsDir:t.artifactsDir,reportJunit:t.reportJunit})};function em(e){return e.backend??(!0===e.maestro?"maestro":void 0)}function eh(e){let t={};for(let[r,i]of Object.entries(e))"string"==typeof i&&r.startsWith("AD_VAR_")&&(t[r]=i);return t}let eg={find:(e,r)=>(function(e,r){var i;let a={...{depth:(i=r).snapshotDepth,raw:i.snapshotRaw},...k(r),first:r.findFirst,last:r.findLast},n=function(e){if("text"===e||"label"===e||"value"===e||"role"===e||"id"===e)return e}(e[0]),o=void 0!==n,s=o?e[1]:e[0],l=o?2:1,u=e[l];if(void 0===u)return{...a,locator:n,query:ev(s)};if("get"===u){let r=e[l+1];if("text"===r)return{...a,locator:n,query:ev(s),action:"getText"};if("attrs"===r)return{...a,locator:n,query:ev(s),action:"getAttrs"};throw new t("INVALID_ARGS","find get only supports text or attrs")}if("wait"===u)return{...a,locator:n,query:ev(s),action:"wait",timeoutMs:x(e[l+1])};if("fill"===u||"type"===u)return{...a,locator:n,query:ev(s),action:u,value:e.slice(l+1).join(" ")};if("click"===u||"focus"===u||"exists"===u)return{...a,locator:n,query:ev(s),action:u};throw new t("INVALID_ARGS",`Unsupported find action: ${u}`)})(e,r),is:(e,r)=>(function(e,r){let i={...w(r),...k(r)},a=e[0],n=q(e.slice(1),{preferTrailingValue:"text"===a});if("text"===a)return{...i,predicate:a,selector:n.selectorExpression,value:n.rest.join(" ")};if("visible"===a||"hidden"===a||"exists"===a||"editable"===a||"selected"===a)return{...i,predicate:a,selector:n.selectorExpression};throw new t("INVALID_ARGS","is requires predicate: visible|hidden|exists|editable|selected|text")})(e,r)},ey={is:A(v.is,e=>{var t;return[(t=e).predicate,t.selector,..."text"===t.predicate?[t.value]:[]]}),find:e=>b(v.find,function(e){let t=e.locator&&"any"!==e.locator?[e.locator,e.query]:[e.query];switch(e.action){case void 0:case"click":case"focus":case"exists":return e.action?[...t,e.action]:t;case"getText":return[...t,"get","text"];case"getAttrs":return[...t,"get","attrs"];case"wait":return[...t,"wait",...M(e.timeoutMs)];case"fill":case"type":return[...t,e.action,e.value]}}(e),{...e,findFirst:e.first,findLast:e.last})};function ev(e){if(void 0===e||""===e)throw new t("INVALID_ARGS","find requires query");return e}let eS={appstate:(e,t)=>_(t),home:(e,t)=>_(t),"app-switcher":(e,t)=>_(t),back:(e,t)=>({..._(t),mode:t.backMode}),rotate:(e,t)=>({..._(t),orientation:C(e[0])}),keyboard:(e,r)=>({..._(r),...function(e){if(e.length>1)throw new t("INVALID_ARGS","keyboard accepts at most one action argument.");return V({action:function(e){let r=e?.toLowerCase();if("get"===r)return"status";if(void 0===r||"status"===r||"dismiss"===r||"enter"===r||"return"===r)return r;throw new t("INVALID_ARGS","keyboard action must be status, get, dismiss, enter, or return.")}(e[0])})}(e)}),clipboard:(e,r)=>({..._(r),...function(e){let r=e[0]?.toLowerCase();if("read"!==r&&"write"!==r)throw new t("INVALID_ARGS","clipboard requires a subcommand: read or write.");if("read"===r){if(1!==e.length)throw new t("INVALID_ARGS","clipboard read does not accept additional arguments.");return{action:r}}if(e.length<2)throw new t("INVALID_ARGS","clipboard write requires text.");return{action:r,text:e.slice(1).join(" ")}}(e)}),"react-native":(e,r)=>({..._(r),action:function(e){if("dismiss-overlay"===e)return e;throw new t("INVALID_ARGS","react-native supports only: dismiss-overlay")}(e[0])})},eb={appstate:A(v.appState),back:e=>{var t;return b(v.back,[],{...e,backMode:"in-app"===(t=e.mode)||"system"===t?t:void 0})},home:A(v.home),rotate:A(v.rotate,e=>[P(e.orientation,"rotate requires orientation")]),"app-switcher":A(v.appSwitcher),keyboard:A(v.keyboard,e=>N(e.action)),clipboard:A(v.clipboard,e=>{var t;return"read"===(t=e).action?["read"]:["write",t.text]}),"react-native":A(v.reactNative,e=>[P(e.action,"react-native requires action")])},ew={...ei,...L,...G,...es,...ey,...ec,replay:e=>b(v.replay,[P(e.path,"replay requires path")],{...e,replayUpdate:e.update,replayBackend:em(e),replayEnv:e.env,replayShellEnv:eh(process.env)}),test:e=>b(v.test,e.paths??[],{...e,replayUpdate:e.update,replayBackend:em(e),replayEnv:e.env,replayShellEnv:eh(process.env)}),...eb,batch:e=>b(v.batch,[],{...e,batchSteps:function(e){if(!Array.isArray(e)||0===e.length)throw new t("INVALID_ARGS","batch requires a non-empty steps array.");return e.map((e,r)=>{var i;let a,n,o,s,l,u;return o=function(e,r){let i="string"==typeof e.command?e.command.trim().toLowerCase():"";if(eI.has(i))return i;throw new t("INVALID_ARGS",`Batch step ${r} command is not available through command batch: ${String(e.command)}`)}(n=function(e,r){if(!e||"object"!=typeof e||Array.isArray(e))throw new t("INVALID_ARGS",`Invalid batch step ${r}.`);return e}(e,i=r+1),i),s=function(e,r){let i=e.input;if(!i||"object"!=typeof i||Array.isArray(i))throw new t("INVALID_ARGS",`Batch step ${r} input must be an object.`);return i}(n,i),l=function(e,r){let i=e.runtime;if(void 0!==i&&(!i||"object"!=typeof i||Array.isArray(i)))throw new t("INVALID_ARGS",`Batch step ${r} runtime must be an object.`);return i}(n,i),{...u={command:(a=e_(o,s)).command,positionals:a.positionals,flags:W(a.options),runtime:a.options.runtime},runtime:l??u.runtime}})}(e.steps),batchOnError:e.onError,batchMaxSteps:e.maxSteps})},eA=y,eI=D(eA);function e_(e,t){return ew[e](t)}export{er as appCliReaders,eA as batchCommandNames,W as buildFlags,Q as buildMeta,eo as gestureCliReaders,E as normalizeDeployResult,z as normalizeDevice,U as normalizeInstallFromSourceResult,$ as normalizeMaterializationReleaseResult,O as normalizeOpenDevice,B as normalizeRuntimeHints,K as normalizeSession,H as normalizeStartupSample,eu as observabilityCliReaders,Y as parseInstallSourceConfig,e_ as prepareDaemonCommandRequest,J as readScreenshotOverlayRefs,j as readSnapshotNodes,ef as replayCliReaders,X as resolveSessionName,eg as selectorCliReaders,eS as systemCliReaders};
|
package/dist/src/940.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AppError as e}from"./9152.js";import{normalizeText as t}from"./7556.js";let n=new Set(["id","role","text","label","value","appname","windowtitle"]),r=new Set(["visible","hidden","editable","selected","enabled","hittable"]),l=new Set([...n,...r]);function i(t){let n=t.trim();if(!n)throw new e("INVALID_ARGS","Selector expression cannot be empty");let r=function(t){let n=[],r="",l=null;for(let i=0;i<t.length;i+=1){let u=t[i];if(('"'===u||"'"===u)&&!h(t,i)){l=f(l,u),r+=u;continue}if(!l&&"|"===u&&"|"===t[i+1]){let l=r.trim();if(!l)throw new e("INVALID_ARGS",`Invalid selector fallback expression: ${t}`);n.push(l),r="",i+=1;continue}r+=u}let i=r.trim();if(!i)throw new e("INVALID_ARGS",`Invalid selector fallback expression: ${t}`);return n.push(i),n}(n);if(0===r.length)throw new e("INVALID_ARGS","Selector expression cannot be empty");return{raw:n,selectors:r.map(t=>(function(t){let n=t.trim();if(!n)throw new e("INVALID_ARGS","Selector segment cannot be empty");let r=function(t){let n=[],r="",l=null;for(let e=0;e<t.length;e+=1){let i=t.charAt(e);if(('"'===i||"'"===i)&&!h(t,e)){l=f(l,i),r+=i;continue}if(!l&&/\s/.test(i)){r.trim()&&n.push(r.trim()),r="";continue}r+=i}if(l)throw new e("INVALID_ARGS",`Unclosed quote in selector: ${t}`);return r.trim()&&n.push(r.trim()),n}(n);if(0===r.length)throw new e("INVALID_ARGS",`Invalid selector segment: ${t}`);return{raw:n,terms:r.map(s)}})(t))}}function u(e){try{return i(e)}catch{return null}}function o(e){let t=e.trim();if(!t)return!1;if("||"===t)return!0;let n=t.indexOf("=");if(-1!==n){let e=t.slice(0,n).trim().toLowerCase();return l.has(e)}return l.has(t.toLowerCase())}function a(e,t={}){if(0===e.length)return null;let n=t.preferTrailingValue??!1,r=0,l=[];for(;r<e.length;){let t=e[r];if(void 0===t||!o(t))break;r+=1;let n=e.slice(0,r).join(" ").trim();n&&u(n)&&l.push(r)}if(0===l.length)return null;let i=l.at(-1);if(void 0===i)return null;let c=i;if(n)for(let t=l.length-1;t>=0;t-=1){let n=l[t];if(void 0!==n&&n<e.length){c=n;break}}let s=e.slice(0,c).join(" ").trim();return s?{selectorExpression:s,rest:e.slice(c)}:null}function c(e){let t=e[0]??"",n=a(e.slice(1),{preferTrailingValue:"text"===t});return{predicate:t,split:n}}function s(t){let n=t.trim();if(!n)throw new e("INVALID_ARGS","Empty selector term");let i=n.indexOf("=");if(-1===i){let l=n.toLowerCase();if(!r.has(l))throw new e("INVALID_ARGS",`Invalid selector term "${t}", expected key=value`);return{key:l,value:!0}}let u=n.slice(0,i).trim().toLowerCase(),o=n.slice(i+1).trim();if(!l.has(u))throw new e("INVALID_ARGS",`Unknown selector key: ${u}`);if(!o)throw new e("INVALID_ARGS",`Missing selector value for key: ${u}`);if(r.has(u)){let t,n="true"===(t=d(o).toLowerCase())||"false"!==t&&null;if(null===n)throw new e("INVALID_ARGS",`Invalid boolean value for ${u}: ${o}`);return{key:u,value:n}}return{key:u,value:d(o)}}function f(e,t){return e?e===t?null:e:t}function d(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1).replace(/\\(["'])/g,"$1"):t}function h(e,t){let n=0;for(let r=t-1;r>=0&&"\\"===e[r];r-=1)n+=1;return n%2==1}function p(e){var t;let n,r=w(e.label),l=w(e.value),i=w(e.identifier),u=(t=i)&&!/^[\w.]+:id\/[\w.-]+$/i.test(t)&&!/^_?NS:\d+$/i.test(t)?i:"";return(n=x(e.type??"")).includes("textfield")||n.includes("securetextfield")||n.includes("searchfield")||n.includes("edittext")||n.includes("textview")||n.includes("textarea")?l||r||u:r||l||u}function m(e){let t=e.replace(/\s+/g," ").trim();return t.length<=48?t:`${t.slice(0,45)}...`}function b(e,t){var n;let r=p(e),l=function(e,t){if("text-view"===t||"text-field"===t||"search"===t)return!0;let n=x(e.type??""),r=`${e.role??""} ${e.subrole??""}`.toLowerCase();return n.includes("textview")||n.includes("textarea")||n.includes("textfield")||n.includes("securetextfield")||n.includes("searchfield")||n.includes("edittext")||r.includes("text area")||r.includes("text field")}(e,t);return{text:r,isLargeSurface:l,shouldSummarize:l&&!!(n=r)&&(n.length>80||/[\r\n]/.test(n))}}function w(e){return"string"==typeof e?e.trim():""}function x(e){let t=e.trim().replace(/XCUIElementType/gi,"").replace(/^AX/,"").toLowerCase(),n=Math.max(t.lastIndexOf("."),t.lastIndexOf("/"));return -1!==n&&(t=t.slice(n+1)),t}function g(e,t){let n=t.toLowerCase();return e.find(e=>{let t=(e.label??"").toLowerCase(),r=(e.value??"").toLowerCase(),l=(e.identifier??"").toLowerCase();return t.includes(n)||r.includes(n)||l.includes(n)})??null}function v(e,t){let n=[e.label,e.value,e.identifier].map(e=>"string"==typeof e?e.trim():"").find(e=>e&&e.length>0);return n&&S(n)?n:function(e,t){if(!e.rect)return;let n=e.rect.y+e.rect.height/2,r=null;for(let e of t){if(!e.rect)continue;let t=[e.label,e.value,e.identifier].map(e=>"string"==typeof e?e.trim():"").find(e=>e&&e.length>0);if(!t||!S(t))continue;let l=Math.abs(e.rect.y+e.rect.height/2-n);(!r||l<r.distance)&&(r={label:t,distance:l})}return r?.label}(e,t)??(n&&S(n)?n:void 0)}function S(e){let t=e.trim();return!(!t||/^(true|false)$/i.test(t)||/^\d+$/.test(t))}function I(e){let t=[],n=[];for(let r of e){let e=r.depth??0;for(;t.length>0&&e<=t[t.length-1];)t.pop();let l=x(r.type??""),i=[r.label,r.value,r.identifier].map(e=>"string"==typeof e?e.trim():"").find(e=>e&&e.length>0),u=!!i&&S(i);if(("group"===l||"ioscontentgroup"===l)&&!u){t.push(e);continue}let o=Math.max(0,e-t.length);n.push({...r,depth:o})}return n}function $(e,t){let n=x(e);return!n||("android"===t?n.includes("edittext")||n.includes("autocompletetextview"):n.includes("textfield")||n.includes("securetextfield")||n.includes("searchfield")||n.includes("textview")||n.includes("textarea")||"search"===n)}function A(e,t){return t.hittable?t:_(e,t,e=>!0===e.hittable)}function y(e){return new Map(e.map(e=>[e.index,e]))}function N(e,t,n,r){let l=t,i=new Set;for(;"number"==typeof l.parentIndex&&!i.has(l.index)&&(i.add(l.index),l=n.get(l.parentIndex)??e[l.parentIndex]);){let e=r(l);if(null!==e)return e}return null}function L(e,t,n,r){return!!N(e,t,r,e=>e===n||e.index===n.index?e:null)}function _(e,t,n){let r=y(e);return N(e,t,r,e=>n(e)?e:null)}function C(e){return[e.label,e.value,e.identifier].map(e=>"string"==typeof e?e.trim():"").filter(e=>e.length>0)[0]??""}function R(e){return p(e)}function V(e){return!0===e.hittable||!!e.rect&&e.rect.width>0&&e.rect.height>0}function D(e,t){return $(e.type??"",t)&&!1!==e.enabled}function G(e,t,n){return t.terms.every(t=>(function(e,t,n){switch(t.key){case"id":return T(e.identifier,String(t.value));case"role":return T(x(e.type??""),String(t.value));case"label":return T(e.label,String(t.value));case"value":return T(e.value,String(t.value));case"text":return T(C(e),String(t.value));case"appname":return T(e.appName,String(t.value));case"windowtitle":return T(e.windowTitle,String(t.value));case"visible":return V(e)===!!t.value;case"hidden":return!V(e)==!!t.value;case"editable":return D(e,n)===!!t.value;case"selected":return!0===e.selected==!!t.value;case"enabled":return!1!==e.enabled==!!t.value;case"hittable":return!0===e.hittable==!!t.value;default:return!1}})(e,t,n))}function T(e,n){return t(e??"")===t(n)}function k(e,t,n){let r=n.requireRect??!1,l=n.requireUnique??!0,i=[];for(let[u,o]of t.selectors.entries()){let t=function(e,t,n,r){let l=0,i=null,u=null,o=!1;for(let a of e){if(r&&!a.rect||!G(a,t,n))continue;if(l+=1,i??=a,!u){u=a;continue}let e=function(e,t){let n=e.depth??0,r=t.depth??0;if(n!==r)return n>r?1:-1;let l=O(e),i=O(t);return l!==i?l<i?1:-1:0}(a,u);e>0?(u=a,o=!1):0===e&&(o=!0)}return{count:l,firstNode:i,disambiguated:o?null:u}}(e,o,n.platform,r);if(i.push({selector:o.raw,matches:t.count}),0!==t.count&&t.firstNode){if(l&&1!==t.count){if(!n.disambiguateAmbiguous||!t.disambiguated)continue;return{node:t.disambiguated,selector:o,selectorIndex:u,matches:t.count,diagnostics:i}}return{node:t.firstNode,selector:o,selectorIndex:u,matches:t.count,diagnostics:i}}}return null}function M(e,t,n){let r=n.requireRect??!1,l=[];for(let[i,u]of t.selectors.entries()){let t=function(e,t,n,r){let l=0;for(let i of e)(!r||i.rect)&&G(i,t,n)&&(l+=1);return l}(e,u,n.platform,r);if(l.push({selector:u.raw,matches:t}),t>0)return{selectorIndex:i,selector:u,matches:t,diagnostics:l}}return null}function q(e,t,n){if(0===t.length)return`Selector did not match: ${e.raw}`;let r=t.map(e=>`${e.selector} -> ${e.matches}`).join(", ");return n.unique??!0?`Selector did not resolve uniquely (${r})`:`Selector did not match (${r})`}function O(e){return e.rect?e.rect.width*e.rect.height:1/0}function U(e,t,n={}){let r=[],l=x(e.type??""),i=F(e.identifier),u=F(e.label),o=F(e.value),a=F(C(e)),c="fill"===n.action;i&&r.push(`id=${E(i)}`),l&&u&&r.push(c?`role=${E(l)} label=${E(u)} editable=true`:`role=${E(l)} label=${E(u)}`),u&&r.push(c?`label=${E(u)} editable=true`:`label=${E(u)}`),o&&r.push(c?`value=${E(o)} editable=true`:`value=${E(o)}`),a&&a!==u&&a!==o&&r.push(c?`text=${E(a)} editable=true`:`text=${E(a)}`),l&&c&&!r.some(e=>e.includes("editable=true"))&&r.push(`role=${E(l)} editable=true`);let s=Array.from(new Set(r));return 0===s.length&&l&&s.push(c?`role=${E(l)} editable=true`:`role=${E(l)}`),0===s.length&&V(e)&&s.push("visible=true"),s}function E(e){return JSON.stringify(e)}function F(e){if(!e)return null;let t=e.trim();return t||null}export{U as buildSelectorChainForNode,y as buildSnapshotNodeByIndex,m as buildTextPreview,b as describeTextSurface,R as extractNodeReadText,C as extractNodeText,p as extractReadableText,_ as findNearestAncestor,A as findNearestHittableAncestor,g as findNodeByLabel,M as findSelectorChainMatch,N as findSnapshotAncestor,q as formatSelectorFailure,L as isDescendantOfSnapshotNode,$ as isFillableType,D as isNodeEditable,V as isNodeVisible,o as isSelectorToken,G as matchesSelector,x as normalizeType,i as parseSelectorChain,I as pruneGroupNodes,v as resolveRefLabel,k as resolveSelectorChain,c as splitIsSelectorArgs,a as splitSelectorFromArgs,w as trimText,u as tryParseSelectorChain};
|
|
1
|
+
import{AppError as e}from"./9152.js";import{normalizeText as t}from"./7556.js";let r=new Set(["id","role","text","label","value","appname","windowtitle"]),n=new Set(["visible","hidden","editable","selected","enabled","hittable"]),l=new Set([...r,...n]);function i(t){let r=t.trim();if(!r)throw new e("INVALID_ARGS","Selector expression cannot be empty");let n=function(t){let r=[],n="",l=null;for(let i=0;i<t.length;i+=1){let u=t[i];if(('"'===u||"'"===u)&&!h(t,i)){l=f(l,u),n+=u;continue}if(!l&&"|"===u&&"|"===t[i+1]){let l=n.trim();if(!l)throw new e("INVALID_ARGS",`Invalid selector fallback expression: ${t}`);r.push(l),n="",i+=1;continue}n+=u}let i=n.trim();if(!i)throw new e("INVALID_ARGS",`Invalid selector fallback expression: ${t}`);return r.push(i),r}(r);if(0===n.length)throw new e("INVALID_ARGS","Selector expression cannot be empty");return{raw:r,selectors:n.map(t=>(function(t){let r=t.trim();if(!r)throw new e("INVALID_ARGS","Selector segment cannot be empty");let n=function(t){let r=[],n="",l=null;for(let e=0;e<t.length;e+=1){let i=t.charAt(e);if(('"'===i||"'"===i)&&!h(t,e)){l=f(l,i),n+=i;continue}if(!l&&/\s/.test(i)){n.trim()&&r.push(n.trim()),n="";continue}n+=i}if(l)throw new e("INVALID_ARGS",`Unclosed quote in selector: ${t}`);return n.trim()&&r.push(n.trim()),r}(r);if(0===n.length)throw new e("INVALID_ARGS",`Invalid selector segment: ${t}`);return{raw:r,terms:n.map(s)}})(t))}}function u(e){try{return i(e)}catch{return null}}function o(e){let t=e.trim();if(!t)return!1;if("||"===t)return!0;let r=t.indexOf("=");if(-1!==r){let e=t.slice(0,r).trim().toLowerCase();return l.has(e)}return l.has(t.toLowerCase())}function a(e,t={}){if(0===e.length)return null;let r=t.preferTrailingValue??!1,n=0,l=[];for(;n<e.length;){let t=e[n];if(void 0===t||!o(t))break;n+=1;let r=e.slice(0,n).join(" ").trim();r&&u(r)&&l.push(n)}if(0===l.length)return null;let i=l.at(-1);if(void 0===i)return null;let c=i;if(r)for(let t=l.length-1;t>=0;t-=1){let r=l[t];if(void 0!==r&&r<e.length){c=r;break}}let s=e.slice(0,c).join(" ").trim();return s?{selectorExpression:s,rest:e.slice(c)}:null}function c(e){let t=e[0]??"",r=a(e.slice(1),{preferTrailingValue:"text"===t});return{predicate:t,split:r}}function s(t){let r=t.trim();if(!r)throw new e("INVALID_ARGS","Empty selector term");let i=r.indexOf("=");if(-1===i){let l=r.toLowerCase();if(!n.has(l))throw new e("INVALID_ARGS",`Invalid selector term "${t}", expected key=value`);return{key:l,value:!0}}let u=r.slice(0,i).trim().toLowerCase(),o=r.slice(i+1).trim();if(!l.has(u))throw new e("INVALID_ARGS",`Unknown selector key: ${u}`);if(!o)throw new e("INVALID_ARGS",`Missing selector value for key: ${u}`);if(n.has(u)){let t,r="true"===(t=d(o).toLowerCase())||"false"!==t&&null;if(null===r)throw new e("INVALID_ARGS",`Invalid boolean value for ${u}: ${o}`);return{key:u,value:r}}return{key:u,value:d(o)}}function f(e,t){return e?e===t?null:e:t}function d(e){let t=e.trim();return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")?t.slice(1,-1).replace(/\\(["'])/g,"$1"):t}function h(e,t){let r=0;for(let n=t-1;n>=0&&"\\"===e[n];n-=1)r+=1;return r%2==1}function p(e){var t;let r=w(e.label),n=w(e.value),l=w(e.identifier),i=(t=l)&&!/^[\w.]+:id\/[\w.-]+$/i.test(t)&&!/^_?NS:\d+$/i.test(t)?l:"";return g(e.type??"")?n||r||i:r||n||i}function m(e){let t=e.replace(/\s+/g," ").trim();return t.length<=48?t:`${t.slice(0,45)}...`}function b(e,t){var r;let n=p(e),l=function(e,t){if("text-view"===t||"text-field"===t||"search"===t)return!0;let r=x(e.type??""),n=`${e.role??""} ${e.subrole??""}`.toLowerCase();return r.includes("textview")||r.includes("textarea")||r.includes("textfield")||r.includes("securetextfield")||r.includes("searchfield")||r.includes("edittext")||n.includes("text area")||n.includes("text field")}(e,t);return{text:n,isLargeSurface:l,shouldSummarize:l&&!!(r=n)&&(r.length>80||/[\r\n]/.test(r))}}function w(e){return"string"==typeof e?e.trim():""}function x(e){let t=e.trim().replace(/XCUIElementType/gi,"").replace(/^AX/,"").toLowerCase(),r=Math.max(t.lastIndexOf("."),t.lastIndexOf("/"));return -1!==r&&(t=t.slice(r+1)),t}function g(e){let t=x(e);return t.includes("textfield")||t.includes("securetextfield")||t.includes("searchfield")||t.includes("edittext")||t.includes("textview")||t.includes("textarea")}function v(e,t){let r=t.toLowerCase();return e.find(e=>{let t=(e.label??"").toLowerCase(),n=(e.value??"").toLowerCase(),l=(e.identifier??"").toLowerCase();return t.includes(r)||n.includes(r)||l.includes(r)})??null}function S(e,t){let r=[e.label,e.value,e.identifier].map(e=>"string"==typeof e?e.trim():"").find(e=>e&&e.length>0);return r&&I(r)?r:function(e,t){if(!e.rect)return;let r=e.rect.y+e.rect.height/2,n=null;for(let e of t){if(!e.rect)continue;let t=[e.label,e.value,e.identifier].map(e=>"string"==typeof e?e.trim():"").find(e=>e&&e.length>0);if(!t||!I(t))continue;let l=Math.abs(e.rect.y+e.rect.height/2-r);(!n||l<n.distance)&&(n={label:t,distance:l})}return n?.label}(e,t)??(r&&I(r)?r:void 0)}function I(e){let t=e.trim();return!(!t||/^(true|false)$/i.test(t)||/^\d+$/.test(t))}function $(e){let t=[],r=[];for(let n of e){let e=n.depth??0;for(;t.length>0&&e<=t[t.length-1];)t.pop();let l=x(n.type??""),i=[n.label,n.value,n.identifier].map(e=>"string"==typeof e?e.trim():"").find(e=>e&&e.length>0),u=!!i&&I(i);if(("group"===l||"ioscontentgroup"===l)&&!u){t.push(e);continue}let o=Math.max(0,e-t.length);r.push({...n,depth:o})}return r}function A(e,t){let r=x(e);return!r||("android"===t?r.includes("edittext")||r.includes("autocompletetextview"):r.includes("textfield")||r.includes("securetextfield")||r.includes("searchfield")||r.includes("textview")||r.includes("textarea")||"search"===r)}function y(e,t){return t.hittable?t:C(e,t,e=>!0===e.hittable)}function N(e){return new Map(e.map(e=>[e.index,e]))}function L(e,t,r,n){let l=t,i=new Set;for(;"number"==typeof l.parentIndex&&!i.has(l.index)&&(i.add(l.index),l=r.get(l.parentIndex)??e[l.parentIndex]);){let e=n(l);if(null!==e)return e}return null}function _(e,t,r,n){return!!L(e,t,n,e=>e===r||e.index===r.index?e:null)}function C(e,t,r){let n=N(e);return L(e,t,n,e=>r(e)?e:null)}function R(e){return[e.label,e.value,e.identifier].map(e=>"string"==typeof e?e.trim():"").filter(e=>e.length>0)[0]??""}function V(e){return p(e)}function T(e){return!0===e.hittable||!!e.rect&&e.rect.width>0&&e.rect.height>0}function D(e,t){return A(e.type??"",t)&&!1!==e.enabled}function G(e,t,r){return t.terms.every(t=>(function(e,t,r){switch(t.key){case"id":return k(e.identifier,String(t.value));case"role":return k(x(e.type??""),String(t.value));case"label":return k(e.label,String(t.value));case"value":return k(e.value,String(t.value));case"text":return k(R(e),String(t.value));case"appname":return k(e.appName,String(t.value));case"windowtitle":return k(e.windowTitle,String(t.value));case"visible":return T(e)===!!t.value;case"hidden":return!T(e)==!!t.value;case"editable":return D(e,r)===!!t.value;case"selected":return!0===e.selected==!!t.value;case"enabled":return!1!==e.enabled==!!t.value;case"hittable":return!0===e.hittable==!!t.value;default:return!1}})(e,t,r))}function k(e,r){return t(e??"")===t(r)}function M(e,t,r){let n=r.requireRect??!1,l=r.requireUnique??!0,i=[];for(let[u,o]of t.selectors.entries()){let t=function(e,t,r,n){let l=0,i=null,u=null,o=!1;for(let a of e){if(n&&!a.rect||!G(a,t,r))continue;if(l+=1,i??=a,!u){u=a;continue}let e=function(e,t){let r=e.depth??0,n=t.depth??0;if(r!==n)return r>n?1:-1;let l=U(e),i=U(t);return l!==i?l<i?1:-1:0}(a,u);e>0?(u=a,o=!1):0===e&&(o=!0)}return{count:l,firstNode:i,disambiguated:o?null:u}}(e,o,r.platform,n);if(i.push({selector:o.raw,matches:t.count}),0!==t.count&&t.firstNode){if(l&&1!==t.count){if(!r.disambiguateAmbiguous||!t.disambiguated)continue;return{node:t.disambiguated,selector:o,selectorIndex:u,matches:t.count,diagnostics:i}}return{node:t.firstNode,selector:o,selectorIndex:u,matches:t.count,diagnostics:i}}}return null}function q(e,t,r){let n=r.requireRect??!1,l=[];for(let[i,u]of t.selectors.entries()){let t=function(e,t,r,n){let l=0;for(let i of e)(!n||i.rect)&&G(i,t,r)&&(l+=1);return l}(e,u,r.platform,n);if(l.push({selector:u.raw,matches:t}),t>0)return{selectorIndex:i,selector:u,matches:t,diagnostics:l}}return null}function O(e,t,r){if(0===t.length)return`Selector did not match: ${e.raw}`;let n=t.map(e=>`${e.selector} -> ${e.matches}`).join(", ");return r.unique??!0?`Selector did not resolve uniquely (${n})`:`Selector did not match (${n})`}function U(e){return e.rect?e.rect.width*e.rect.height:1/0}function E(e,t,r={}){let n=[],l=x(e.type??""),i=K(e.identifier),u=K(e.label),o=K(e.value),a=K(R(e)),c="fill"===r.action;i&&n.push(`id=${F(i)}`),l&&u&&n.push(c?`role=${F(l)} label=${F(u)} editable=true`:`role=${F(l)} label=${F(u)}`),u&&n.push(c?`label=${F(u)} editable=true`:`label=${F(u)}`),o&&n.push(c?`value=${F(o)} editable=true`:`value=${F(o)}`),a&&a!==u&&a!==o&&n.push(c?`text=${F(a)} editable=true`:`text=${F(a)}`),l&&c&&!n.some(e=>e.includes("editable=true"))&&n.push(`role=${F(l)} editable=true`);let s=Array.from(new Set(n));return 0===s.length&&l&&s.push(c?`role=${F(l)} editable=true`:`role=${F(l)}`),0===s.length&&T(e)&&s.push("visible=true"),s}function F(e){return JSON.stringify(e)}function K(e){if(!e)return null;let t=e.trim();return t||null}export{E as buildSelectorChainForNode,N as buildSnapshotNodeByIndex,m as buildTextPreview,b as describeTextSurface,V as extractNodeReadText,R as extractNodeText,p as extractReadableText,C as findNearestAncestor,y as findNearestHittableAncestor,v as findNodeByLabel,q as findSelectorChainMatch,L as findSnapshotAncestor,O as formatSelectorFailure,_ as isDescendantOfSnapshotNode,A as isFillableType,D as isNodeEditable,T as isNodeVisible,o as isSelectorToken,G as matchesSelector,x as normalizeType,i as parseSelectorChain,g as prefersValueForReadableText,$ as pruneGroupNodes,S as resolveRefLabel,M as resolveSelectorChain,c as splitIsSelectorArgs,a as splitSelectorFromArgs,w as trimText,u as tryParseSelectorChain};
|
package/dist/src/9471.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{setSessionSnapshot as e,
|
|
1
|
+
import{setSessionSnapshot as e,captureSnapshot as r,isNavigationSensitiveAction as t,markPendingInteractionOutcome as n,stripInternalInteractionOutcomeFlags as o,getSnapshotReferenceFrame as i,recordTouchVisualizationEvent as a,markAndroidSnapshotFreshness as c}from"./2415.js";import{successText as s}from"./1998.js";import{getAndroidScreenSize as d}from"./input-actions.js";import{emitDiagnostic as f}from"./7599.js";async function u(t,n,o,i,a){let c={...n??{},snapshotInteractiveOnly:a.interactiveOnly,snapshotCompact:a.interactiveOnly},s=i(c,t.appBundleId,t.trace?.outPath),{snapshot:d}=await r({device:t.device,session:t,flags:c,outPath:c.out,logPath:s.logPath??"",androidFreshnessMode:a.androidFreshnessMode});return e(t,d),o.set(t.name,t),d}function l(e){var r,t,n;let o,i,a,{data:c,fallbackX:d,fallbackY:f,referenceFrame:u,extra:l}=e,p=(r=l,t=d,n=f,o="string"==typeof r?.ref?r.ref:void 0,i="string"==typeof r?.button?r.button:void 0,a="string"==typeof r?.gesture?r.gesture:void 0,("string"==typeof r?.text?`Filled ${Array.from(r.text).length} chars`:o?"longpress"===a?`Long pressed @${o} (${t}, ${n})`:i&&"primary"!==i?`Clicked ${i} @${o} (${t}, ${n})`:`Tapped @${o} (${t}, ${n})`:void 0)??("string"==typeof c?.message?c.message:void 0));return{x:d,y:f,...u??{},...l??{},...c??{},...s(p)}}function p(e){let{session:r,sessionStore:i,command:s,positionals:d,retryPositionals:f,flags:u,result:l,responseData:p,actionStartedAt:h,actionFinishedAt:g,androidFreshnessBaseline:m}=e,_=o(u);return i.recordAction(r,{command:s,positionals:d,flags:_??{},result:l}),n({session:r,command:s,positionals:f??d,flags:u,preSnapshot:r.snapshot}),t(s)&&c(r,s,m??r.snapshot),a(r,s,d,l,_??{},h,g),{ok:!0,data:p}}async function h(e){let{session:r,flags:t,sessionStore:n,contextFromFlags:o,captureSnapshotForSession:a}=e;if(!r.recording)return;if(r.recording.touchReferenceFrame)return r.recording.touchReferenceFrame;if("android"===r.device.platform){let e=await d(r.device),t={referenceWidth:e.width,referenceHeight:e.height};return r.recording&&(r.recording.touchReferenceFrame=t),t}let c=i(r.snapshot);if(c)return r.recording&&(r.recording.touchReferenceFrame=c),c;if(!r.recording)return;let s=i(await a(r,t,n,o,{interactiveOnly:!0}));return s&&r.recording&&(r.recording.touchReferenceFrame=s),s}async function g(e){try{return await h(e)}catch(r){f({level:"warn",phase:"touch_reference_frame_resolve_failed",data:{platform:e.session.device.platform,error:r instanceof Error?r.message:String(r)}});return}}function m(e){return i({nodes:e,createdAt:0})}export{l as buildTouchVisualizationResult,p as finalizeTouchInteraction,u as interaction_snapshot_captureSnapshotForSession,m as readSnapshotNodesReferenceFrame,g as resolveDirectTouchReferenceFrameSafely};
|