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 • 975 B
import{v as e}from"./sdk-contracts.js";import{n as t}from"./png.js";function n(e,n,a){a==null||a<=0||(t(e)?r(e,n,a):e[0]===255&&e[1]===216&&i(e,n,a))}function r(e,t,n){let r=8;for(;r+16<=e.length;){let i=e.readUInt32BE(r),a=e.toString(`ascii`,r+4,r+8);if(a===`IHDR`&&i>=8&&o(e.readUInt32BE(r+8),e.readUInt32BE(r+12),t,n),a===`IEND`)return;r+=i+12}}function i(e,t,n){for(let{marker:r,offset:i,length:s}of a(e))[192,193,194].includes(r)&&s>=8&&o(e.readUInt16BE(i+5),e.readUInt16BE(i+3),t,n)}function*a(e){let t=2;for(;t+3<e.length&&e[t]===255;){for(;e[t]===255;)t+=1;let n=e[t++];if(n===218||n===217||t+2>e.length)return;let r=e.readUInt16BE(t);if(r<2||t+r>e.length)return;yield{marker:n,offset:t,length:r},t+=r}}function o(t,n,r,i){let a=t*n;if(!Number.isSafeInteger(a)||a<1||i!=null&&i>0&&a>i)throw new e(`INVALID_ARGS`,`${r} is ${a} pixels, which exceeds the configured maxImagePixels limit of ${i}`)}export{n as validateScreenshotImagePixels,o as validateScreenshotPixels};