maests
Version:
An executable compiler for creating Maestro's yaml-flows with typescript.
65 lines (64 loc) • 1.18 kB
JavaScript
import { stringify } from "yaml";
import { addOut } from "../out.mjs";
const tapOn = (id, options = {}) => {
const commands = [
{
tapOn: {
id,
retryTapIfNoChange: !0,
...options
}
}
];
addOut(stringify(commands));
}, tapOnText = (text, options = {}) => {
const command = [
{
tapOn: {
text,
retryTapIfNoChange: !0,
...options
}
}
];
addOut(stringify(command));
}, tapOnPoint = (point, options = {}) => {
const { x, y } = point, command = [
{
tapOn: {
point: `${x},${y}`,
retryTapIfNoChange: !0,
...options
}
}
];
addOut(stringify(command));
}, waitForAndTapOn = (id, options = {}) => {
const { maxWait = 5e3 } = options;
let command = `- extendedWaitUntil:
visible:
id: "${id}"
timeout: ${maxWait}
`;
const cmd = {
extendedWaitUntil: {
visible: {
id
},
timeout: maxWait
}
}, cmd2 = {
tapOn: {
id,
retryTapIfNoChange: !0,
...options
}
};
addOut(stringify([cmd, cmd2]));
};
export {
tapOn,
tapOnPoint,
tapOnText,
waitForAndTapOn
};