mobileboost-cli 0.2.2 → 0.2.3
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/.output/nitro.json +1 -1
- package/.output/public/assets/index-wAXRnbNo.js +520 -0
- package/.output/public/assets/{main-BbUrvuLL.js → main-CeoNGsUp.js} +1 -1
- package/.output/server/chunks/_/{_tanstack-start-manifest_v-CCgm5JAL.mjs → _tanstack-start-manifest_v-DA-9ufHl.mjs} +1 -1
- package/.output/server/chunks/_/actions-CszEX8Wv.mjs +1 -0
- package/.output/server/chunks/_/{agent-CUyzfc4e.mjs → agent-CYjOntOE.mjs} +1 -1
- package/.output/server/chunks/_/ai-client-B037VO11.mjs +1 -0
- package/.output/server/chunks/_/{appium-CMKpXGap.mjs → appium-CB7q1F7-.mjs} +1 -1
- package/.output/server/chunks/_/appium-client-NLCErNZG.mjs +1 -0
- package/.output/server/chunks/_/{client-CM5hUS2d.mjs → client-B14sS6WP.mjs} +1 -1
- package/.output/server/chunks/_/{describe-BfbyupMJ.mjs → describe-BN5m4F-F.mjs} +1 -1
- package/.output/server/chunks/_/device-CFbX4Slf.mjs +1 -0
- package/.output/server/chunks/_/files-D27pPBly.mjs +1 -0
- package/.output/server/chunks/_/hierarchy-RZUZWmuO.mjs +1 -0
- package/.output/server/chunks/_/hierarchy-helpers-CR7kKS69.mjs +3 -0
- package/.output/server/chunks/_/index-BwPMhGOi.mjs +502 -0
- package/.output/server/chunks/_/{router-DYcFhNaL.mjs → router-BkeWjFXo.mjs} +1 -1
- package/.output/server/chunks/_/{screenshot-Csbvymnl.mjs → screenshot-BR2gF_yP.mjs} +1 -1
- package/.output/server/chunks/_/server.mjs +3 -3
- package/.output/server/chunks/_/step-BuczzV1F.mjs +1 -0
- package/.output/server/chunks/_/stores-k5WcYw_y.mjs +1 -0
- package/.output/server/index.mjs +4 -4
- package/.output/server/package.json +2 -0
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/package.json +2 -1
- package/.output/public/assets/index-D7JF4301.js +0 -492
- package/.output/server/chunks/_/actions-CvabQsJo.mjs +0 -1
- package/.output/server/chunks/_/ai-client-waGeh-P8.mjs +0 -1
- package/.output/server/chunks/_/appium-client-DiTTrl8p.mjs +0 -1
- package/.output/server/chunks/_/device-CWFVkH1s.mjs +0 -1
- package/.output/server/chunks/_/files-CB9WpUb0.mjs +0 -1
- package/.output/server/chunks/_/hierarchy-DfPTUh7F.mjs +0 -1
- package/.output/server/chunks/_/hierarchy-helpers-BaGN7WBn.mjs +0 -3
- package/.output/server/chunks/_/index-BZ9EyYaV.mjs +0 -474
- package/.output/server/chunks/_/step-D2WQqd4J.mjs +0 -1
- package/.output/server/chunks/_/stores-2rWNmXVj.mjs +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as a,a as t}from"./server.mjs";import{x as p,r as f,u,l as S,S as _,d as b,b as h}from"./device-CWFVkH1s.mjs";import{performDeepLink as $,performScroll as l,getPageSource as g,performSwipe as x,performTap as y,performType as P,performZoom as v}from"./appium-client-DiTTrl8p.mjs";import{V as w,N as F,X as T}from"./hierarchy-helpers-BaGN7WBn.mjs";import"@tanstack/history";import"@tanstack/router-core/ssr/client";import"@tanstack/router-core";import"node:async_hooks";import"@tanstack/router-core/ssr/server";import"../../index.mjs";import"node:http";import"node:stream";import"node:https";import"node:http2";import"node:fs";import"node:url";import"node:path";import"tiny-invariant";import"seroval";import"react/jsx-runtime";import"@tanstack/react-router/ssr/server";import"@tanstack/react-router";import"zod";import"./step-D2WQqd4J.mjs";import"webdriverio";import"xml2js";import"linkedom";const V=a("605c05774def700303f9889c0f8a28fed026e0b5c36a1563cff2835ee01d26b1",(e,r)=>O.__executeServer(e,r)),O=t({method:"POST"}).inputValidator(_).handler(V,async({data:e})=>(console.log(`Performing tap at ${e.x}, ${e.y}`),await y(e),{success:!0})),k=a("07e23aa87e88d53c6c9e3d8e88de788d27d7b10930150bc4fd510d4447aaf3de",(e,r)=>L.__executeServer(e,r)),L=t({method:"POST"}).inputValidator(b).handler(k,async({data:e})=>(console.log(`Performing type: "${e.text}"`),await P(e),{success:!0})),z=a("5c526b678a7596f28beca76784df0ac58acd292627c5770c0c8029e38e4681ec",(e,r)=>I.__executeServer(e,r)),I=t({method:"POST"}).inputValidator(f).handler(z,async({data:e})=>(console.log(`Performing scroll: ${e.direction}`),await l(e),{success:!0})),N=a("2b4a002699960d578addbcf4dd83fedcec62444d7da4bf7c2359be991ed6207e",(e,r)=>A.__executeServer(e,r)),A=t({method:"POST"}).inputValidator(S).handler(N,async({data:e})=>(console.log(`Performing swipe: ${e.x1},${e.y1} -> ${e.x2},${e.y2}`),await x(e),{success:!0})),D=a("10b616f4aacf11bb275166e4ae03f441f1d7c9a68a670dfadb03b74e1d012900",(e,r)=>U.__executeServer(e,r)),U=t({method:"POST"}).inputValidator(u).handler(D,async({data:e})=>{console.log(`Performing scroll until: text="${e.text}", id="${e.elementId}", dir=${e.direction}`);for(let r=0;r<(e.maxScrolls??15);r++){console.log(`Scroll Until Loop: ${r+1}/${e.maxScrolls}`);const m=await g(),d=await w(m);let i=d.hierarchy?.node?.[0];const n=d.hierarchy?.node;if(n){const c=n.find(s=>s.$&&s.$.package!=="com.android.systemui");c&&(i=c)}let o=!1;if(e.elementId&&F(i,e.elementId)&&(o=!0),!o&&e.text&&T(i,e.text)&&(o=!0),o)return console.log("Target found!"),{success:!0,scrolls:r};r<(e.maxScrolls??15)-1&&(await l({direction:e.direction}),await new Promise(c=>setTimeout(c,1e3)))}return console.log("Target NOT found after max scrolls"),{success:!1}}),Z=a("c23cd3196f54848abd64a8b8d4660d7826a70cf44169d7bf29fc82e74a2cf612",(e,r)=>B.__executeServer(e,r)),B=t({method:"POST"}).inputValidator(h).handler(Z,async({data:e})=>(console.log(`Performing zoom: ${e.direction}`),await v(e),{success:!0})),C=a("566ee4344553ab6300f847f5de346e037f92d986cb824ba1c313346e62345fbe",(e,r)=>E.__executeServer(e,r)),E=t({method:"POST"}).inputValidator(p).handler(C,async({data:e})=>(console.log(`Performing deep link: "${e.url}"`),await $(e.url),{success:!0}));export{C as deepLinkFn_createServerFn_handler,z as scrollFn_createServerFn_handler,D as scrollUntilFn_createServerFn_handler,N as swipeFn_createServerFn_handler,V as tapFn_createServerFn_handler,k as typeFn_createServerFn_handler,Z as zoomFn_createServerFn_handler};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{z as e}from"zod";import C from"node:fs";import v from"node:path";import $ from"sharp";import{R as r}from"./constants-Dh9o88yr.mjs";const N=e.object({fullImage:e.string(),croppedImage:e.string(),targetImage:e.string(),type:e.enum(["interaction","assert","tap"]).optional()}),P=e.object({base64_screenshot:e.string(),instruction:e.string(),action_history:e.array(e.any()).optional(),executionId:e.string().optional(),elementId:e.string().optional(),uiHierarchy:e.array(e.any()).optional()});function j(){const t=v.join(process.cwd(),"mobileboost.config.json");if(!C.existsSync(t))throw new Error('mobileboost.config.json not found. Run "mobileboost init" first.');const s=C.readFileSync(t,"utf-8");return JSON.parse(s)}function x(t){return t.replace(/^data:image\/\w+;base64,/,"")}async function F(t){const{fullImage:s,croppedImage:g,targetImage:u,type:f}=t,o=j().apiKey;if(!o)throw new Error("apiKey not configured in mobileboost.config.json");const c=f==="assert"?"assert":"interaction",l={org_id:o,full_image:x(s),cropped_image:x(g),target_image:x(u),type:c},n=await fetch("https://api.mobileboost.io/cli/describe_interaction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!n.ok){const d=await n.text();throw new Error(`Describe interaction failed: ${n.status} ${d}`)}const i=await n.json();return i.description||i.assertion_description||JSON.stringify(i)}async function H(t){const s="https://api.mobileboost.io/call_lambda",g=j().apiKey;if(!g)throw new Error("apiKey not configured in mobileboost.config.json");const u=Buffer.from(t.base64_screenshot,"base64"),f=await $(u).metadata(),o=f.width??1080,c=f.height??1920,l=Math.round(o/r),n=await $(u).resize({width:l,withoutEnlargement:!0}).toBuffer(),i=await $(n).metadata(),d=i.width??l,h=i.height??c*(l/o),I=r,A=r;console.log(`[AI Client] Resized screenshot: ${o}x${c} -> ${d}x${h} (Scale: ${I.toFixed(2)})`);const S={lambda_flow:"get_next_step",current_date:new Date().toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"}),base64_screenshot:n.toString("base64"),getUI_elements:[],uiHierarchy:t.uiHierarchy??[],test_task_string:JSON.stringify([{id:"step-1",text:`1. ${t.instruction}`,plainText:t.instruction}]),image_width:d,image_height:h,action_history:t.action_history??[],orgKey:g,template_images:{},model_provider:"vellum",model_version:"claude-agent",fallbackModel:"claude-agent",utilize_fullTextAnnotation:!1,enableSortingOCR:!0,enableActionHistoryCut:!0,removeOverlappingText:!1,currentAndPreviousScreenMatch:!1,popupDetectionEnabled:!0,ocrProvider:"gcp",modelResponseDoubleCheckEnabled:!1,modelResponseDoubleCheckModel:"claude-3-5-sonnet-20240620"};console.log(`[AI Client] Sending payload with dimensions: ${d}x${h} (Original: ${o}x${c})`),console.log("[AI Client] Payload:",{payload:S});const a=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":"230948209348203948203948203948"},body:JSON.stringify(S)});if(!a.ok){const m=await a.text();throw console.error(`[AI Client] Backend error (${a.status}):`,m),new Error(`AI Backend Error: ${a.status} ${a.statusText}`)}const p=await a.json();console.log("[AI Client] Raw response from backend:",JSON.stringify(p,null,2)),console.log(`[AI Client] Applying scale factors: X=${I.toFixed(4)}, Y=${A.toFixed(4)}`);const O=m=>m.match(/([xy])=(\d+)/)?m.replace(/([xy])=(\d+)/g,(k,y,b)=>{const w=parseInt(b,10),_=Math.round(w*r);return`${y}=${_}`}):m.replace(/(^|;)(\d+);(\d+)(;|$)/,(k,y,b,w,_)=>{const E=parseInt(b,10),T=parseInt(w,10),z=Math.round(E*r),R=Math.round(T*r);return`${y}${z};${R}${_}`});return p.appetizeCommands&&(p.appetizeCommands=p.appetizeCommands.map(O)),p}export{P as F,F as K,N as P,H as W};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{remote as g}from"webdriverio";let n=null;function M(e,t){return!(!n||n.platform!==e||t&&n.deviceId!==t)}function x(){return n?.platform??null}function I(){return n?.windowSize}async function m(){if(n){console.log("Invalidating current Appium session...");try{await n.client.deleteSession()}catch{}n=null}}async function $(){if(!n)return!1;try{const e=await n.client.getWindowRect();return typeof e.width=="number"&&typeof e.height=="number"}catch{return!1}}async function S(e=n?.platform??"android",t){const i=t??n?.deviceId;if(n&&n.platform===e&&(!i||n.deviceId===i)){if(await $())return n.client;console.log("Session expired or invalid, creating new session..."),await m()}n&&(console.log("Switching session from",n.platform,"to",e),await m()),console.log(`Initializing Appium session for ${e} ${i?`(${i})`:""}...`);const o={platformName:"Android","appium:automationName":"UiAutomator2","appium:ensureWebviewsHavePages":!0,"appium:nativeWebScreenshot":!0,"appium:newCommandTimeout":3600,...i?{"appium:udid":i}:{}},s={platformName:"iOS","appium:automationName":"XCUITest","appium:newCommandTimeout":3600,...i?{"appium:udid":i}:{}};try{const a=await g({protocol:"http",hostname:"127.0.0.1",port:4723,path:"/",capabilities:e==="ios"?s:o}),c=await a.getWindowRect();return n={client:a,platform:e,deviceId:i,windowSize:{width:c.width,height:c.height}},console.log("Appium session initialized"),a}catch(a){throw console.error("Failed to initialize Appium session:",a),a}}function h(e){const t=[],i=o=>{if(!o)return;const s=typeof o=="string"?o:JSON.stringify(o);t.push(s)};return i(e?.message),i(e?.cause?.message),i(e?.body?.value?.message),i(e?.body?.value?.error),i(e?.stack),t.filter(Boolean).join(" | ")}function w(e){const t=h(e).toLowerCase(),i=e?.statusCode||e?.status,o=(e?.body?.value?.error||"").toLowerCase();return i===404||o==="invalid session id"||o==="no such session"||t.includes("404")||t.includes("session not found")||t.includes("no such session")||t.includes("invalid session id")||t.includes("a session is either terminated or not started")||t.includes("instrumentation process is not running")||t.includes("ended")||t.includes("closed")||t.includes("connection refused")||t.includes("econnrefused")||t.includes("econnreset")||t.includes("socket hang up")||t.includes("does not exist")||t.includes("timeout")}async function u(e,t,i,o){const s=i??n?.platform??"android",a=o??n?.deviceId,c=async(r=3)=>{let p;for(let d=0;d<r;d++)try{const l=await S(s,a);if(!l.sessionId)throw new Error("No active sessionId after ensureAppiumSession");return l}catch(l){p=l;const f=Math.min(2e3,250*Math.pow(2,d));d<r-1&&(console.warn(`[${t}] Failed to create/verify session (attempt ${d+1}/${r}). Retrying in ${f}ms...`),await new Promise(y=>setTimeout(y,f)))}throw p};try{const r=await c();if(!r.sessionId)throw new Error("Session appears invalid (missing sessionId)");return await e(r)}catch(r){if(w(r)){console.warn(`[${t}] Session error detected: "${h(r)}". Invalidating and retrying...`),await m();const p=await c(4);try{return await e(p)}catch(d){throw w(d)&&console.error(`[${t}] Action failed again after session refresh: ${h(d)}`),d}}throw r}}async function b(e){await u(async t=>{let i=Math.round(e.x),o=Math.round(e.y);const s=e.platform??"android";if(console.log(`[Tap] Platform: ${s}, Input: ${i},${o}, Screen: ${e.screenWidth}x${e.screenHeight}`),s==="ios"){const a=n?.windowSize;if(console.log(`[Tap] Window Size: ${a?.width}x${a?.height}`),e.screenWidth&&a?.width){const c=e.screenWidth/a.width,r=e.screenHeight?e.screenHeight/a.height:c;console.log(`[Tap] Calculated Scale: X=${c.toFixed(2)}, Y=${r.toFixed(2)}`),i=Math.round(i/c),o=Math.round(o/r),console.log(`[iOS] Scaling tap: ${e.x},${e.y} (px) -> ${i},${o} (pt)`)}else console.warn("[Tap] Missing screenWidth or windowSize, skipping scale calculation."),a&&(i>a.width||o>a.height)&&(i=Math.round(i/3),o=Math.round(o/3),console.log(`[iOS] Scaling tap (heuristic 3x): ${e.x},${e.y} -> ${i},${o}`))}await t.performActions([{type:"pointer",id:"finger1",parameters:{pointerType:"touch"},actions:[{type:"pointerMove",duration:0,x:i,y:o},{type:"pointerDown",button:0},{type:"pause",duration:100},{type:"pointerUp",button:0}]}])},"performTap",e.platform,e.deviceId)}async function T(e){await u(async t=>{await t.keys(e.text.split(""))},"performType",e.platform,e.deviceId)}async function A(e){await u(async t=>{const i=n?.windowSize,o=i?.width??1080,s=i?.height??1920,a=Math.round(o/2),c=e.direction==="down"?Math.round(s*.75):Math.round(s*.25),r=e.direction==="down"?Math.round(s*.25):Math.round(s*.75);await t.performActions([{type:"pointer",id:"finger1",parameters:{pointerType:"touch"},actions:[{type:"pointerMove",duration:0,x:a,y:c},{type:"pointerDown",button:0},{type:"pause",duration:100},{type:"pointerMove",duration:500,x:a,y:r},{type:"pointerUp",button:0}]}])},"performScroll",e.platform,e.deviceId)}async function z(e){await u(async t=>{await t.performActions([{type:"pointer",id:"finger1",parameters:{pointerType:"touch"},actions:[{type:"pointerMove",duration:0,x:Math.round(e.x1),y:Math.round(e.y1)},{type:"pointerDown",button:0},{type:"pause",duration:100},{type:"pointerMove",duration:e.duration??500,x:Math.round(e.x2),y:Math.round(e.y2)},{type:"pointerUp",button:0}]}])},"performSwipe",e.platform,e.deviceId)}async function W(e){await u(async t=>{await t.execute("mobile: deepLink",{url:e.url})},"performDeepLink",e.platform,e.deviceId)}async function C(){return await u(async e=>await e.getPageSource(),"getPageSource")}async function k(e){await u(async t=>{const{width:i,height:o}=n?.windowSize||await t.getWindowRect(),s=Math.floor(i/2),a=Math.floor(o/2),c=Math.floor(i*.2),r=Math.floor(o*.2),p={left:s-c,top:a-r,width:c*2,height:r*2,percent:1,speed:1500};console.log(`[Zoom] dir=${e.direction} center=(${s},${a}) area=(${p.left},${p.top}) ${p.width}x${p.height}`),e.direction==="in"?await t.executeScript("mobile: pinchOpenGesture",[{...p,percent:.5,speed:800}]):await t.executeScript("mobile: pinchCloseGesture",[p])},"performZoom",e.platform,e.deviceId)}export{S as ensureAppiumSession,I as getDeviceSize,C as getPageSource,x as getPlatform,M as isAppiumConnected,W as performDeepLink,A as performScroll,z as performSwipe,b as performTap,T as performType,k as performZoom};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{z as e}from"zod";import{r as t,c as n,m as o,o as d,t as r,a as p,s as m}from"./step-D2WQqd4J.mjs";const a=e.object({platform:e.enum(["android","ios"]).optional().default("android"),deviceId:e.string().optional()}),u=d.extend(a.shape),x=r.extend(a.shape),b=n.extend(a.shape),h=e.object({x1:e.number(),y1:e.number(),x2:e.number(),y2:e.number(),duration:e.number().optional().default(500)}).extend(a.shape),l=p.extend(a.shape),c=o.extend(a.shape),f=t.extend(a.shape);m.extend(a.shape);e.object({mode:e.enum(["adb","appium"])});export{u as S,a,l as b,x as d,h as l,b as r,c as u,f as x};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c,a as s}from"./server.mjs";import o from"node:path";import{readFile as w}from"node:fs/promises";import n from"fs-extra";import{z as r}from"zod";import u from"dotenv";import{B as b}from"./stores-2rWNmXVj.mjs";import"@tanstack/history";import"@tanstack/router-core/ssr/client";import"@tanstack/router-core";import"node:async_hooks";import"@tanstack/router-core/ssr/server";import"../../index.mjs";import"node:http";import"node:stream";import"node:https";import"node:http2";import"node:fs";import"node:url";import"tiny-invariant";import"seroval";import"react/jsx-runtime";import"@tanstack/react-router/ssr/server";import"@tanstack/react-router";import"@tanstack/react-store";import"./step-D2WQqd4J.mjs";async function h(){const e=o.join(process.cwd(),"mobileboost.config.json");let t="./tests";if(await n.pathExists(e))try{const a=await n.readJSON(e);a.testDir&&(t=a.testDir)}catch(a){console.error("Error reading config, using default testDir",a)}return o.resolve(process.cwd(),t)}async function f(e){const t=await h(),a=o.resolve(t,e);if(!a.startsWith(t))throw new Error("Invalid path: must be within test directory");return a}r.object({name:r.string(),type:r.enum(["file","directory"]),path:r.string()});const v=c("00fb1fe03e9689cf8c179ba0d5cadc5eeaa6879def224ac38037d70a1a51300d",(e,t)=>y.__executeServer(e,t)),y=s({method:"GET"}).handler(v,async()=>{const e=await h();await n.ensureDir(e);async function t(a){let i=[];const p=await n.readdir(a,{withFileTypes:!0});for(const d of p){const l=o.join(a,d.name),m=o.relative(e,l);d.isDirectory()?(i.push({name:d.name,type:"directory",path:m}),i=i.concat(await t(l))):i.push({name:d.name,type:"file",path:m})}return i}return{files:await t(e)}}),_=r.record(r.string(),r.string()).optional().default({});r.object({testDir:r.string(),driver:r.string(),port:r.number(),apiKey:r.string(),variables:_});const F=c("54b0d7153f4ee4f963b29e7c835e76cedaaf345527fdc912c49030ea79353b5e",(e,t)=>S.__executeServer(e,t)),S=s({method:"GET"}).handler(F,async()=>{let e={};const t=o.join(process.cwd(),"mobileboost.config.json"),a=o.join(process.cwd(),".env");if(await n.pathExists(t))try{e={...(await n.readJSON(t)).variables}}catch{}if(await n.pathExists(a))try{const i=await w(a,"utf-8"),p=u.parse(i);e={...e,...p}}catch{}return e}),g=r.object({name:r.string(),type:r.enum(["file","directory"]),parentPath:r.string().optional()}),j=c("ac7bf7f1d727949cd28713a8f36bb77e7bd8fc0e48854ed8cb1ee93ce80fb6d0",(e,t)=>P.__executeServer(e,t)),P=s({method:"POST"}).inputValidator(g).handler(j,async({data:e})=>{const t=await h(),a=e.parentPath?o.join(t,e.parentPath):t;if(!o.resolve(a).startsWith(t))throw new Error("Invalid parent path");const i=o.join(a,e.name);if(e.type==="directory")await n.ensureDir(i);else{if(await n.pathExists(i))throw new Error("File already exists");await n.writeJSON(i,[],{spaces:2})}return{success:!0}}),x=r.object({path:r.string()}),E=c("b41e844ce533c224e7c720e69d821468deffcbf208fc008a7f5af83cb0596b15",(e,t)=>O.__executeServer(e,t)),O=s({method:"POST"}).inputValidator(x).handler(E,async({data:e})=>{const t=await f(e.path);try{return{content:await n.readJSON(t),path:e.path}}catch(a){throw console.error("Failed to read file",a),new Error("Failed to read file or invalid format")}}),D=r.object({path:r.string(),content:b}),T=c("1b2a0d276d9ce90b2a1d72134c1bf95b9f6b7b049a8f415e8f0da3e6fc5ce4ae",(e,t)=>V.__executeServer(e,t)),V=s({method:"POST"}).inputValidator(r.unknown()).handler(T,async({data:e})=>{const t=D.parse(e),a=await f(t.path);return await n.writeJSON(a,t.content,{spaces:2}),{success:!0}}),J=r.object({oldPath:r.string(),newPath:r.string()}),N=c("098d52adf25ea567d43facba347871f887828c6ab804021bbfa0f2759209c0c6",(e,t)=>I.__executeServer(e,t)),I=s({method:"POST"}).inputValidator(J).handler(N,async({data:e})=>{const t=await f(e.oldPath),a=await h(),i=o.resolve(a,e.newPath);if(!i.startsWith(a))throw new Error("Invalid new path");return await n.rename(t,i),{success:!0}}),W=r.object({sourcePath:r.string(),targetPath:r.string()}),k=c("efbbc22c41cf491631b07076417c9ec65d5ac71debfcc00b5a7e0d368772104f",(e,t)=>G.__executeServer(e,t)),G=s({method:"POST"}).inputValidator(W).handler(k,async({data:e})=>{const t=await f(e.sourcePath),a=await h(),i=o.resolve(a,e.targetPath);if(!i.startsWith(a))throw new Error("Invalid target path");await n.ensureDir(i);const p=o.basename(t),d=o.join(i,p);return await n.move(t,d,{overwrite:!1}),{success:!0}});export{j as createFileFn_createServerFn_handler,v as fetchFilesFn_createServerFn_handler,F as fetchVariablesFn_createServerFn_handler,k as moveFileFn_createServerFn_handler,E as readFileFn_createServerFn_handler,N as renameFileFn_createServerFn_handler,T as saveFileFn_createServerFn_handler};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as d,a as m}from"./server.mjs";import{s as f,n as u}from"./step-D2WQqd4J.mjs";import{getPageSource as s,getDeviceSize as p,getPlatform as g}from"./appium-client-DiTTrl8p.mjs";import{V as c,H as I,N as h,K as $,L as _,q as b,Y as x,_ as y,z as S,j as D}from"./hierarchy-helpers-BaGN7WBn.mjs";import"@tanstack/history";import"@tanstack/router-core/ssr/client";import"@tanstack/router-core";import"node:async_hooks";import"@tanstack/router-core/ssr/server";import"../../index.mjs";import"node:http";import"node:stream";import"node:https";import"node:http2";import"node:fs";import"node:url";import"node:path";import"tiny-invariant";import"seroval";import"react/jsx-runtime";import"@tanstack/react-router/ssr/server";import"@tanstack/react-router";import"zod";import"webdriverio";import"xml2js";import"linkedom";const F=d("1ed4d2aa14be99e8c5a81eefbece63cea629a89f75862c60f9ff19c4d4dc67c5",(e,t)=>v.__executeServer(e,t)),v=m().handler(F,async()=>{const e=await s(),t=g(),r=p(),n=t==="ios"?D(e):x(e),o=y({elements:n,deviceDimensions:r,allowNonClickableItems:!0,ignoredElements:[]}),i=S({items:o});return{...r,elements:i}}),w=d("05faf0772038a170c70083fd8de4a8b77a40e4ec46e0bbf6878670f02621b5df",(e,t)=>E.__executeServer(e,t)),E=m({method:"POST"}).inputValidator(u).handler(w,async({data:e})=>{console.log(`Getting element ID at ${e.x}, ${e.y}`);const t=await s(),r=(await c(t))?.hierarchy?.node?.[0];if(!r)return console.log("No root node found in hierarchy"),{elementId:""};const n=_(r,e.x,e.y);if(!n)return console.log("No element found at coordinates"),{elementId:""};if(n.$&&n.$["resource-id"]?.trim()){let o=n.$["resource-id"];const i=b(r,n,o);return i>=0?(o=`${o}[${i}]`,console.log(`Found duplicate IDs, using indexed ID: ${o}`)):console.log("Found unique element ID:",o),{elementId:o}}return console.log("Element found but has no resource-id"),{elementId:""}}),P=d("9bcbf5303827d2a25f347c2054b0121655a82322fa07108653f43246875348f7",(e,t)=>V.__executeServer(e,t)),V=m({method:"POST"}).inputValidator(f).handler(P,async({data:e})=>{console.log(`Looking for element with ID: ${e.elementId}`);const t=await s(),r=(await c(t))?.hierarchy?.node?.[0];if(!r)return{found:!1};let n=e.elementId,o=null;const i=e.elementId.match(/^(.+)\[(\d+)\]$/);i&&(n=i[1],o=parseInt(i[2]),console.log(`Parsed indexed ID: base="${n}", index=${o}`));let a=null;if(o!==null){const l=I(r,n);o<l.length&&(a=l[o],console.log(`Found element at index ${o}`))}else a=h(r,e.elementId);if(a){const l=$(a);if(l)return console.log(`Found element at center: ${l.x}, ${l.y}`),{found:!0,x:l.x,y:l.y}}return console.log("Element not found or no bounds"),{found:!1}});export{P as findElementByIdFn_createServerFn_handler,w as getElementIdFn_createServerFn_handler,F as getVisibleElements_createServerFn_handler};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import L from"xml2js";import{DOMParser as F}from"linkedom";async function j(e){return new Promise((n,u)=>{L.parseString(e,(o,i)=>{o?u(o):n(i)})})}function C(e){if(!e)return null;const n=e.match(/\[(\d+),(\d+)\]\[(\d+),(\d+)\]/);return n?{x1:parseInt(n[1]),y1:parseInt(n[2]),x2:parseInt(n[3]),y2:parseInt(n[4])}:null}function X(e,n,u){if(!e)return null;if(e.$&&e.$.bounds){const i=C(e.$.bounds);if(i&&(n<i.x1||n>i.x2||u<i.y1||u>i.y2))return null}let o=null;if(e.node)for(const i of e.node){const l=X(i,n,u);l&&(o=l)}return o??e}function N(e,n){if(!e)return null;if(e.$&&e.$["resource-id"]===n)return e;if(e.node)for(const u of e.node){const o=N(u,n);if(o)return o}return null}function K(e,n){if(!e)return null;const u=e.$?.text??"",o=e.$?.["content-desc"]??"";if(u&&u.toLowerCase().includes(n.toLowerCase())||o&&o.toLowerCase().includes(n.toLowerCase()))return e;if(e.node)for(const i of e.node){const l=K(i,n);if(l)return l}return null}function q(e,n){const u=[];function o(i){if(i&&(i.$&&i.$["resource-id"]===n&&u.push(i),i.node))for(const l of i.node)o(l)}return o(e),u}function z(e,n,u){const o=q(e,u);return o.length<=1?-1:o.indexOf(n)}function H(e){if(!e.$||!e.$.bounds)return null;const n=C(e.$.bounds);return n?{x:Math.round((n.x1+n.x2)/2),y:Math.round((n.y1+n.y2)/2)}:null}const R=e=>{const n=e.replace(/\\"/g,'"').replace(/\\n/g,`
|
|
2
|
-
`),u=t=>{try{const r=parseFloat(t.getAttribute("x")??"0"),s=parseFloat(t.getAttribute("y")??"0"),a=parseFloat(t.getAttribute("width")??"0"),c=parseFloat(t.getAttribute("height")??"0");return{x:r,y:s,width:a,height:c}}catch(r){console.error("Error parsing bounds:",r);return}},o=t=>{const r=t.getAttribute("type")??"",s=t.getAttribute("name")??"",a=t.getAttribute("label")??"";return{text:t.getAttribute("value")??"","resource-id":s,"content-desc":a,hintText:"",accessibilityText:a,visible:t.getAttribute("visible")==="true",index:t.getAttribute("index")??"0",type:r}},i=new F().parseFromString(n,"text/xml"),l=i.querySelector("parsererror");if(l!=null)return console.error("XML parsing error:",l),[];const g=i.querySelector("XCUIElementTypeApplication");if(g==null)return console.error("No application element found in XML"),[];const f=(t,r=0,s=[],a=!1)=>{const c=u(t),h=o(t),d=t.getAttribute("type")??"",b=t.getAttribute("name")??"",x=t.getAttribute("accessible")==="true",w=t.getAttribute("enabled")==="true",p=t.getAttribute("index")??"0",y=Array.from(t.children).filter(I=>I.nodeType===1&&I.nodeName.startsWith("XCUIElementType")&&!["AXFrame"].includes(I.nodeName)),m=h.type==="XCUIElementTypeKeyboard",A=y.map(I=>f(I,r+1,[...s,p],a||m)),P=b.length>0&&(b.includes("button")||d.includes("Button")||d.includes("Control")),M=d.includes("TextField")||d.includes("SearchField")||d.includes("TextInput"),T=x&&w||P||d.includes("Button")||M,k={attributes:h,clickable:T,enabled:t.getAttribute("enabled")==="true",focused:t.getAttribute("focused")==="true",checked:t.getAttribute("checked")==="true",selected:t.getAttribute("selected")==="true",bounds:c,drawingOrderPath:[...s,p],isKeyboardElement:a,isKeyboardParent:m};return A.length>0&&(k.children=A),k};return E(f(g),[])},V=e=>{const n=e.replace(/\\"/g,'"').replace(/\\n/g,`
|
|
3
|
-
`),u=r=>{try{const s=r.match(/\[(\d+),(\d+)\]\[(\d+),(\d+)\]/);if(s==null)return;const[a,c,h,d,b]=s.map(Number);return{x:c,y:h,width:d-c,height:b-h}}catch(s){console.error("Error parsing bounds:",s);return}},o=r=>({text:r.getAttribute("text")??"","resource-id":r.getAttribute("resource-id")??"","content-desc":r.getAttribute("content-desc")??"",hintText:"",hint:r.getAttribute("hint")??"",accessibilityText:r.getAttribute("content-desc")??"",visible:r.getAttribute("displayed")==="true",index:r.getAttribute("index")??"0",class:r.getAttribute("class")??"",package:r.getAttribute("package")??""}),i=(r,s=[],a=[],c=0)=>{const h=r.getAttribute("bounds"),d=h?u(h):void 0;d||console.warn(`Element with missing/invalid bounds: ${r.getAttribute("class")??"unknown"} with resource-id: ${r.getAttribute("resource-id")??"none"}`);const b=o(r),x=r.getAttribute("drawing-order")??"0",w=r.getAttribute("index")??"0",p=[...a,w],y=parseInt(x)*1e3+c,m=[...s,y.toString()],A=Array.from(r.children).filter(M=>M.nodeType===1).map((M,T)=>i(M,m,p,T)),P={attributes:b,clickable:r.getAttribute("clickable")==="true",enabled:r.getAttribute("enabled")==="true",focused:r.getAttribute("focused")==="true",checked:r.getAttribute("checked")==="true",selected:r.getAttribute("selected")==="true",bounds:d,drawingOrderPath:m,indexPath:p,drawingOrder:y};return A.length>0&&(P.children=A),P},l=new F().parseFromString(n,"text/xml"),g=l.querySelector("parsererror");if(g!=null)return console.error("XML parsing error:",g),[];const f=l.querySelector("hierarchy");if(f==null)return console.error("No hierarchy element found in XML"),[];const t=i(f);return E(t,[])},E=(e,n,u)=>{u?.clickable&&!e.clickable&&(e.clickable=!0),((u?.isFixed??!1)||(e.attributes?.type?.includes("NavigationBar")??!1))&&(e.isFixed=!0),e.children!=null&&e.children.forEach(l=>{E(l,n,e)});const{children:o,...i}=e;return n.push(i),n},Y=({elements:e,deviceDimensions:n,allowNonClickableItems:u=!1,allowFullScreenItems:o=!1,shouldIncludeKeyboardParentElement:i=!1,ignoredElements:l})=>{const g=n?.width??0,f=n?.height??0;return e.filter(t=>{const r=t.clickable??!1,s=t.attributes?.visible!==!1,a=t.attributes?.text!==""?t.attributes?.text:void 0,c=t.attributes?.accessibilityText??t.attributes?.["content-desc"]??t.attributes?.accessibilityLabel,h=t.attributes?.["resource-id"]??t.attributes?.accessibilityIdentifier;if(l.includes(h))return!1;const d=[a,c,h].some(v=>v!=null&&v.trim()?.length>0),b=t.bounds?.x??0,x=t.bounds?.width??0,w=b+x,p=Math.max(0,b),y=Math.min(g,w),m=Math.max(0,y-p),A=t.bounds?.y??0,P=t.bounds?.height??0,M=A+P,T=Math.max(0,A),k=Math.min(f,M),I=Math.max(0,k-T),O=m>0&&I>0,S=t.bounds?.height===n?.height&&t.bounds?.width===n?.width;return(o||!S)&&(u||r)&&s&&(d||i&&t.isKeyboardParent)&&O}).map(t=>{const r=t.bounds?.x??0,s=t.bounds?.width??0,a=r+s,c=Math.max(0,r),h=Math.min(g,a),d=Math.max(0,h-c),b=t.bounds?.y??0,x=t.bounds?.height??0,w=b+x,p=Math.max(0,b),y=Math.min(f,w),m=Math.max(0,y-p);return{...t,bounds:{x:c,y:p,width:d,height:m}}})},_=({items:e,allItems:n})=>e.filter(u=>u.isFixed?!0:!B({targetElement:u,allElements:n??e,occlusionThreshold:.6})),B=({targetElement:e,allElements:n,occlusionThreshold:u=1})=>{const{x:o,y:i,width:l,height:g}=e.bounds,f=l*g;return n.find(t=>{if(t.bounds==null||t===e||$({potentialChild:e,potentialParent:t})||$({potentialChild:t,potentialParent:e})||!(D(t,e)>0||t.isFixed))return!1;const r=Math.max(o,t.bounds.x),s=Math.max(i,t.bounds.y),a=Math.min(o+l,t.bounds.x+t.bounds.width),c=Math.min(i+g,t.bounds.y+t.bounds.height);if(a<=r||c<=s)return!1;const h=a-r,d=c-s,b=h*d/f,x=b>=u;return x&&console.log("coverageRatio",b),x})??null},$=({potentialChild:e,potentialParent:n})=>{const u=e.drawingOrderPath??e.indexPath??[],o=n.drawingOrderPath??n.indexPath??[];return u.length<=o.length?!1:o.every((i,l)=>i===u[l])},D=(e,n)=>{if(!e.bounds&&!n.bounds)return 0;if(!e.bounds)return-1;if(!n.bounds)return 1;const u=e.drawingOrderPath??e.indexPath??[],o=n.drawingOrderPath??n.indexPath??[];for(let i=0;i<Math.min(u.length,o.length);i++){const l=parseInt(u[i]),g=parseInt(o[i]);if(l!==g)return l-g}return u.length!==o.length?u.length-o.length:n.bounds.width*n.bounds.height-e.bounds.width*e.bounds.height};export{q as H,H as K,X as L,N,j as V,K as X,V as Y,Y as _,R as j,z as q,_ as z};
|