@gui-agent/operator-aio
Version:
AIO (All-in-One) operator for GUI Agent
1 lines • 1.97 kB
Source Map (JSON)
{"version":3,"file":"utils.mjs","sources":["webpack://@gui-agent/operator-aio/./src/utils.ts"],"sourcesContent":["/*\n * Copyright (c) 2025 Bytedance, Inc. and its affiliates.\n * SPDX-License-Identifier: Apache-2.0\n */\nexport const parseBoxToScreenCoords = ({\n boxStr,\n screenWidth,\n screenHeight,\n factors = [1000, 1000],\n}: {\n boxStr: string; // the box string has been normalized, the value is the percentage of the actual width and height\n screenWidth: number;\n screenHeight: number;\n factors?: [number, number];\n}) => {\n if (!boxStr) {\n return { x: null, y: null };\n }\n const coords = boxStr\n .replace('[', '')\n .replace(']', '')\n .split(',')\n .map((num) => parseFloat(num.trim()));\n\n const [x1, y1, x2 = x1, y2 = y1] = coords;\n // console.log('parseBoxToScreenCoords x1, y1, x2, y2:', x1, y1, x2, y2);\n\n const [widthFactor, heightFactor] = factors;\n // console.log('parseBoxToScreenCoords widthFactor, heightFactor:', widthFactor, heightFactor);\n\n return {\n x: Math.round(((x1 + x2) / 2) * screenWidth * widthFactor) / widthFactor,\n y: Math.round(((y1 + y2) / 2) * screenHeight * heightFactor) / heightFactor,\n percentX: x1,\n percentY: y1,\n };\n};\n"],"names":["parseBoxToScreenCoords","boxStr","screenWidth","screenHeight","factors","coords","num","parseFloat","x1","y1","x2","y2","widthFactor","heightFactor","Math"],"mappings":";;;;AAIO,MAAMA,yBAAyB,CAAC,EACrCC,MAAM,EACNC,WAAW,EACXC,YAAY,EACZC,UAAU;IAAC;IAAM;CAAK,EAMvB;IACC,IAAI,CAACH,QACH,OAAO;QAAE,GAAG;QAAM,GAAG;IAAK;IAE5B,MAAMI,SAASJ,OACZ,OAAO,CAAC,KAAK,IACb,OAAO,CAAC,KAAK,IACb,KAAK,CAAC,KACN,GAAG,CAAC,CAACK,MAAQC,WAAWD,IAAI,IAAI;IAEnC,MAAM,CAACE,IAAIC,IAAIC,KAAKF,EAAE,EAAEG,KAAKF,EAAE,CAAC,GAAGJ;IAGnC,MAAM,CAACO,aAAaC,aAAa,GAAGT;IAGpC,OAAO;QACL,GAAGU,KAAK,KAAK,CAAGN,AAAAA,CAAAA,KAAKE,EAAC,IAAK,IAAKR,cAAcU,eAAeA;QAC7D,GAAGE,KAAK,KAAK,CAAGL,AAAAA,CAAAA,KAAKE,EAAC,IAAK,IAAKR,eAAeU,gBAAgBA;QAC/D,UAAUL;QACV,UAAUC;IACZ;AACF"}