UNPKG

agent-device

Version:

Open source device layer for AI coding agents: a CLI, MCP server, and typed Node.js API to control mobile, web, TV, and desktop apps on devices and simulators, locally or in the cloud.

1 lines • 801 B
import{v as e}from"./sdk-contracts.js";import{w as t}from"./sdk-device.js";import{t as n}from"./png-size.js";function r(t,n){if(!(n===void 0||s(t)))throw new e(`UNSUPPORTED_OPERATION`,`--pixel-density is currently supported only on iOS-family simulators`)}function i(e,t,n){let r=o(n);if(t!==r)return{width:Math.max(1,Math.round(e.width/t*r)),height:Math.max(1,Math.round(e.height/t*r))}}async function a(e){let t=s(e.device),r;try{r=await n(e.path)}catch(e){if(t)throw e;return{}}let i={width:r.width,height:r.height};if(!t||e.scale!==void 0&&e.scale!==1)return i;let a=o(e.requestedPixelDensity);return{...i,logicalWidth:Math.round(r.width/a),logicalHeight:Math.round(r.height/a),pixelDensity:a}}function o(e){return e??1}function s(e){return t(e)&&e.kind===`simulator`}export{i as n,a as r,r as t};