donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
28 lines • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.InteractableElementSchema = exports.ScrollDirectionEnum = void 0;
exports.interactableElementsToPrettyJson = interactableElementsToPrettyJson;
const v4_1 = require("zod/v4");
exports.ScrollDirectionEnum = v4_1.z.enum(['UP', 'DOWN', 'LEFT', 'RIGHT']);
/**
* A handle to an HTML element that has been marked up via the {@link PageInspector.attributeInteractableElements} method.
*/
exports.InteractableElementSchema = v4_1.z.object({
donobuAttributeValue: v4_1.z
.string()
.describe("The value for this element's `PageInspector.interactableElementAttribute`"),
htmlSnippet: v4_1.z.string().describe('A short HTML snippet of the element.'),
scrollable: exports.ScrollDirectionEnum.array().describe('Live scroll directions available on the element (empty = no scrolling possible).'),
});
function interactableElementsToPrettyJson(elements) {
// Create an object maintaining insertion order.
const result = {};
for (const e of elements) {
result[e.donobuAttributeValue] = {
htmlSnippet: e.htmlSnippet,
...(e.scrollable.length > 0 ? { scrollable: e.scrollable } : {}),
};
}
return JSON.stringify(result, null, 2);
}
//# sourceMappingURL=InteractableElement.js.map