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 • 2.14 kB
import{_i as e}from"./sdk-batch.js";function t(e,t={}){let r=e.type?.replace(/^XCUIElementType/,``),i=[`TextField`,`SecureTextField`,`SearchField`,`TextView`].includes(r??``),a=[`Switch`,`CheckBox`,`RadioButton`,`Toggle`].includes(r??``),s={};if(a&&e.checked===void 0){let t=n(e.value);t!==void 0&&(s.checked=t)}i&&(e.password===void 0&&(s.password=r===`SecureTextField`),e.editable===void 0&&(s.editable=!0));let c=Object.keys(s).length===0?e:{...e,...s};return t.reactNativeValue===!1?c:o(c)}function n(e){if(e===`1`||e===`true`)return!0;if(e===`0`||e===`false`)return!1}const r=new Set([`RCTView`,`RCTViewComponentView`]),i={alert:`alert`,checkbox:`checkbox`,"combo box":`combobox`,menu:`menu`,"menu bar":`menubar`,"menu item":`menuitem`,"progress bar":`progressbar`,"radio button":`radio`,"radio group":`radiogroup`,"scroll bar":`scrollbar`,"spin button":`spinbutton`,switch:`switch`,tab:`tab`,"tab list":`tablist`,timer:`timer`,"tool bar":`toolbar`},a={checked:{checked:!0},unchecked:{checked:!1},mixed:{checked:`mixed`},expanded:{expanded:!0},collapsed:{expanded:!1},busy:{busy:!0}};function o(e){if(e.iosValueSemantics||typeof e.value!=`string`||!s(e))return e;let t=l(e.value,e.role);return!t||!c(e,t)?e:{...e,iosValueSemantics:t,...e.checked===void 0&&typeof t.checked==`boolean`?{checked:t.checked}:{}}}function s(t){return e(t.type??``)!==`other`||t.editable||t.password?!1:r.has(t.role??``)?!0:t.role===void 0||e(t.role)===`other`}function c(e,t){let n=t.role===`checkbox`||t.role===`radio`;return t.role!==void 0&&!n&&e.role!==`RCTView`?!1:r.has(e.role??``)?!0:n&&t.checked!==void 0}function l(e,t){let n=e.split(`, `),r=n[0]??``,o=Object.hasOwn(i,r)?i[r]:void 0,s={source:`react-native-ios-value-heuristic`,encoding:`en`,...o===void 0?{}:{role:o}},c=0;for(let e of n.slice(o===void 0?0:1)){if(!Object.hasOwn(a,e))break;let n=a[e];if(Object.keys(n).some(e=>Object.hasOwn(s,e)))break;let r=u(n);if(t===`RCTViewComponentView`&&r<c)break;c=r,Object.assign(s,n)}return s.role!==void 0||s.checked!==void 0||s.expanded!==void 0||s.busy!==void 0?s:void 0}function u(e){return e.checked===void 0?e.expanded===void 0?3:2:1}export{t};