@burdenoff/ui-engine 2026.1127.1 → 2026.1127.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -3
- package/dist/capture.js +3 -2
- package/dist/dom-runtime/actions.d.ts +65 -0
- package/dist/dom-runtime/iife.d.ts +1 -0
- package/dist/dom-runtime/index.d.ts +7 -0
- package/dist/dom-runtime/runtime.d.ts +79 -0
- package/dist/dom-runtime.d.ts +2 -0
- package/dist/dom-runtime.iife.js +1 -0
- package/dist/dom-runtime.js +535 -0
- package/dist/{index-05zgh18g.js → index-2kgsgn1c.js} +1 -1
- package/dist/{index-phd8yhyg.js → index-bnvmt4wf.js} +7 -5
- package/dist/{index-c6pmt2rg.js → index-cs6acyjn.js} +6 -59
- package/dist/index-mgztm37r.js +57 -0
- package/dist/index-q1b0j9yr.js +1349 -0
- package/dist/index-zwrxw3zp.js +1988 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +180 -6
- package/dist/recording.js +1 -1
- package/dist/replay.js +2 -2
- package/dist/script/adapters/browser-action-contract.d.ts +22 -0
- package/dist/script/adapters/from-browser-action.d.ts +7 -0
- package/dist/script/adapters/from-remote-browser.d.ts +7 -0
- package/dist/script/adapters/recording.d.ts +25 -0
- package/dist/script/adapters/to-browser-action.d.ts +8 -0
- package/dist/script/canonical.d.ts +6 -0
- package/dist/script/capabilities.d.ts +29 -0
- package/dist/script/describe.d.ts +83 -0
- package/dist/script/fingerprint.d.ts +9 -0
- package/dist/script/hash.d.ts +3 -0
- package/dist/script/index.d.ts +22 -0
- package/dist/script/json-schema.d.ts +4 -0
- package/dist/script/limits.d.ts +61 -0
- package/dist/script/parse.d.ts +31 -0
- package/dist/script/schema.d.ts +87 -0
- package/dist/script/types.d.ts +489 -0
- package/dist/script/walk.d.ts +29 -0
- package/dist/script.d.ts +2 -0
- package/dist/script.js +175 -0
- package/dist/target/aria.d.ts +31 -0
- package/dist/target/dom.d.ts +35 -0
- package/dist/target/index.d.ts +13 -0
- package/dist/target/markers.d.ts +18 -0
- package/dist/target/methods.d.ts +52 -0
- package/dist/target/resolve.d.ts +46 -0
- package/dist/target/snapshot.d.ts +57 -0
- package/dist/target/text.d.ts +23 -0
- package/dist/target/types.d.ts +88 -0
- package/dist/target.d.ts +2 -0
- package/dist/target.js +92 -0
- package/dist/testing/fixtures/ambiguous.d.ts +7 -0
- package/dist/testing/fixtures/iframe.d.ts +6 -0
- package/dist/testing/fixtures/index.d.ts +26 -0
- package/dist/testing/fixtures/invoices-v2.d.ts +8 -0
- package/dist/testing/fixtures/invoices-v3.d.ts +7 -0
- package/dist/testing/fixtures/invoices.d.ts +6 -0
- package/dist/testing/fixtures/login.d.ts +6 -0
- package/dist/testing/fixtures/shadow.d.ts +7 -0
- package/dist/testing/index.d.ts +6 -0
- package/dist/testing/mount.d.ts +18 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +324 -0
- package/package.json +28 -5
- package/schema/ui-script-v1.schema.json +8199 -0
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sameText2,
|
|
3
|
+
visibleText2,
|
|
4
|
+
parentAcrossShadow2,
|
|
5
|
+
isElementEnabled2,
|
|
6
|
+
isSensitiveElement2,
|
|
7
|
+
resolveWebTarget2,
|
|
8
|
+
serializeTreeSnapshot2
|
|
9
|
+
} from "./index-q1b0j9yr.js";
|
|
10
|
+
|
|
11
|
+
// src/dom-runtime/actions.ts
|
|
12
|
+
var MAX_READ_TEXT = 65536;
|
|
13
|
+
var MAX_TYPED_TEXT = 65536;
|
|
14
|
+
var READ_ACTIONS = new Set(["getText", "getValue", "getAttribute", "exists"]);
|
|
15
|
+
var POINTER_ACTIONS = new Set(["click", "doubleClick", "hover", "check"]);
|
|
16
|
+
function viewOf(element) {
|
|
17
|
+
return element.ownerDocument.defaultView;
|
|
18
|
+
}
|
|
19
|
+
var BUTTONS = { left: 0, middle: 1, right: 2 };
|
|
20
|
+
var PRESSED = { left: 1, middle: 4, right: 2 };
|
|
21
|
+
function pointerInit(element, view, button) {
|
|
22
|
+
const rect = element.getBoundingClientRect();
|
|
23
|
+
return {
|
|
24
|
+
bubbles: true,
|
|
25
|
+
cancelable: true,
|
|
26
|
+
composed: true,
|
|
27
|
+
view,
|
|
28
|
+
button: BUTTONS[button],
|
|
29
|
+
buttons: 0,
|
|
30
|
+
clientX: rect.x + rect.width / 2,
|
|
31
|
+
clientY: rect.y + rect.height / 2,
|
|
32
|
+
pointerId: 1,
|
|
33
|
+
pointerType: "mouse",
|
|
34
|
+
isPrimary: true
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function pointerArrives(element, view, init) {
|
|
38
|
+
const PointerCtor = typeof view.PointerEvent === "function" ? view.PointerEvent : view.MouseEvent;
|
|
39
|
+
const entered = [];
|
|
40
|
+
for (let current = element;current; current = parentAcrossShadow2(current))
|
|
41
|
+
entered.unshift(current);
|
|
42
|
+
const enter = { ...init, bubbles: false };
|
|
43
|
+
element.dispatchEvent(new PointerCtor("pointerover", init));
|
|
44
|
+
for (const target of entered)
|
|
45
|
+
target.dispatchEvent(new PointerCtor("pointerenter", enter));
|
|
46
|
+
element.dispatchEvent(new view.MouseEvent("mouseover", init));
|
|
47
|
+
for (const target of entered)
|
|
48
|
+
target.dispatchEvent(new view.MouseEvent("mouseenter", enter));
|
|
49
|
+
}
|
|
50
|
+
var FOCUSABLE = 'a[href], area[href], button, input, select, textarea, iframe, summary, [tabindex], [contenteditable]:not([contenteditable="false"])';
|
|
51
|
+
function focusOnPress(element, view) {
|
|
52
|
+
for (let current = element;current; current = parentAcrossShadow2(current)) {
|
|
53
|
+
if (current.matches(FOCUSABLE) && isElementEnabled2(current) && current instanceof view.HTMLElement) {
|
|
54
|
+
current.focus();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const active = element.ownerDocument.activeElement;
|
|
59
|
+
if (active instanceof view.HTMLElement && active !== element.ownerDocument.body)
|
|
60
|
+
active.blur();
|
|
61
|
+
}
|
|
62
|
+
function pointerSequence(element, view, init, button, count) {
|
|
63
|
+
const PointerCtor = typeof view.PointerEvent === "function" ? view.PointerEvent : view.MouseEvent;
|
|
64
|
+
const pressed = { ...init, buttons: PRESSED[button], detail: count };
|
|
65
|
+
const released = { ...init, detail: count };
|
|
66
|
+
pointerArrives(element, view, init);
|
|
67
|
+
const pointerProceeds = element.dispatchEvent(new PointerCtor("pointerdown", pressed));
|
|
68
|
+
const mouseProceeds = pointerProceeds && element.dispatchEvent(new view.MouseEvent("mousedown", pressed));
|
|
69
|
+
if (mouseProceeds)
|
|
70
|
+
focusOnPress(element, view);
|
|
71
|
+
element.dispatchEvent(new PointerCtor("pointerup", released));
|
|
72
|
+
if (pointerProceeds)
|
|
73
|
+
element.dispatchEvent(new view.MouseEvent("mouseup", released));
|
|
74
|
+
}
|
|
75
|
+
function click(element, view, button, count = 1) {
|
|
76
|
+
const init = pointerInit(element, view, button);
|
|
77
|
+
pointerSequence(element, view, init, button, count);
|
|
78
|
+
const terminal = button === "left" ? "click" : button === "right" ? "contextmenu" : "auxclick";
|
|
79
|
+
element.dispatchEvent(new view.MouseEvent(terminal, { ...init, detail: count }));
|
|
80
|
+
}
|
|
81
|
+
function isTextField(element, view) {
|
|
82
|
+
if (element instanceof view.HTMLTextAreaElement)
|
|
83
|
+
return true;
|
|
84
|
+
if (!(element instanceof view.HTMLInputElement))
|
|
85
|
+
return false;
|
|
86
|
+
return !["button", "submit", "reset", "image", "checkbox", "radio", "file", "range", "color", "hidden"].includes(element.type);
|
|
87
|
+
}
|
|
88
|
+
function setFieldValue(element, view, value) {
|
|
89
|
+
const prototype = element instanceof view.HTMLTextAreaElement ? view.HTMLTextAreaElement.prototype : view.HTMLInputElement.prototype;
|
|
90
|
+
const setter = Object.getOwnPropertyDescriptor(prototype, "value")?.set;
|
|
91
|
+
if (setter)
|
|
92
|
+
setter.call(element, value);
|
|
93
|
+
else
|
|
94
|
+
element.value = value;
|
|
95
|
+
element.dispatchEvent(new view.Event("input", { bubbles: true, composed: true }));
|
|
96
|
+
element.dispatchEvent(new view.Event("change", { bubbles: true }));
|
|
97
|
+
}
|
|
98
|
+
function isEditableRegion(element, view) {
|
|
99
|
+
if (!(element instanceof view.HTMLElement))
|
|
100
|
+
return false;
|
|
101
|
+
if (element.isContentEditable)
|
|
102
|
+
return true;
|
|
103
|
+
const editable = element.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();
|
|
104
|
+
return editable === "" || editable === "true" || editable === "plaintext-only";
|
|
105
|
+
}
|
|
106
|
+
function typeInto(element, view, text, append) {
|
|
107
|
+
if (text.length > MAX_TYPED_TEXT)
|
|
108
|
+
return { ok: false, problem: "INVALID_ACTION" };
|
|
109
|
+
if (isTextField(element, view)) {
|
|
110
|
+
if (element.readOnly)
|
|
111
|
+
return { ok: false, problem: "NOT_EDITABLE" };
|
|
112
|
+
element.focus();
|
|
113
|
+
setFieldValue(element, view, append ? `${element.value}${text}` : text);
|
|
114
|
+
return { ok: true };
|
|
115
|
+
}
|
|
116
|
+
if (isEditableRegion(element, view)) {
|
|
117
|
+
element.focus();
|
|
118
|
+
element.textContent = append ? `${element.textContent ?? ""}${text}` : text;
|
|
119
|
+
element.dispatchEvent(new view.Event("input", { bubbles: true, composed: true }));
|
|
120
|
+
return { ok: true };
|
|
121
|
+
}
|
|
122
|
+
return { ok: false, problem: "NOT_EDITABLE" };
|
|
123
|
+
}
|
|
124
|
+
function optionLabel(option) {
|
|
125
|
+
const label = option.getAttribute("label");
|
|
126
|
+
return label !== null && label.trim() !== "" ? label : option.textContent ?? "";
|
|
127
|
+
}
|
|
128
|
+
function selectOption(element, view, action) {
|
|
129
|
+
if (!(element instanceof view.HTMLSelectElement))
|
|
130
|
+
return { ok: false, problem: "NOT_SELECTABLE" };
|
|
131
|
+
const options = Array.from(element.options);
|
|
132
|
+
const option = action.value !== undefined ? options.find((candidate) => candidate.value === action.value) : action.label !== undefined ? options.find((candidate) => sameText2(optionLabel(candidate), action.label)) : action.index !== undefined ? options[action.index] : undefined;
|
|
133
|
+
if (!option || option.disabled || option.closest("optgroup")?.hasAttribute("disabled")) {
|
|
134
|
+
return { ok: false, problem: "OPTION_NOT_FOUND" };
|
|
135
|
+
}
|
|
136
|
+
element.focus();
|
|
137
|
+
option.selected = true;
|
|
138
|
+
element.dispatchEvent(new view.Event("input", { bubbles: true, composed: true }));
|
|
139
|
+
element.dispatchEvent(new view.Event("change", { bubbles: true }));
|
|
140
|
+
return { ok: true };
|
|
141
|
+
}
|
|
142
|
+
function setChecked(element, view, checked) {
|
|
143
|
+
if (element instanceof view.HTMLInputElement && (element.type === "checkbox" || element.type === "radio")) {
|
|
144
|
+
if (element.checked !== checked) {
|
|
145
|
+
if (element.type === "radio" && !checked)
|
|
146
|
+
return { ok: false, problem: "NOT_CHECKABLE" };
|
|
147
|
+
click(element, view, "left");
|
|
148
|
+
}
|
|
149
|
+
return element.checked === checked ? { ok: true } : { ok: false, problem: "STATE_NOT_CHANGED" };
|
|
150
|
+
}
|
|
151
|
+
const role = element.getAttribute("role");
|
|
152
|
+
if (role === "checkbox" || role === "switch" || role === "radio" || role === "menuitemcheckbox") {
|
|
153
|
+
const isChecked = () => element.getAttribute("aria-checked") === "true";
|
|
154
|
+
if (isChecked() !== checked)
|
|
155
|
+
click(element, view, "left");
|
|
156
|
+
return isChecked() === checked ? { ok: true } : { ok: false, problem: "STATE_NOT_CHANGED" };
|
|
157
|
+
}
|
|
158
|
+
return { ok: false, problem: "NOT_CHECKABLE" };
|
|
159
|
+
}
|
|
160
|
+
var KEY = /^(?:[\s\S]|[A-Z][A-Za-z0-9]{1,23})$/u;
|
|
161
|
+
function activatesOnEnter(element, view) {
|
|
162
|
+
if (element instanceof view.HTMLButtonElement)
|
|
163
|
+
return true;
|
|
164
|
+
if (element instanceof view.HTMLInputElement)
|
|
165
|
+
return ["submit", "button", "reset", "image"].includes(element.type);
|
|
166
|
+
const tag = element.localName;
|
|
167
|
+
return tag === "a" && element.hasAttribute("href") || tag === "summary";
|
|
168
|
+
}
|
|
169
|
+
function activatesOnSpace(element, view) {
|
|
170
|
+
if (element instanceof view.HTMLButtonElement)
|
|
171
|
+
return true;
|
|
172
|
+
if (element instanceof view.HTMLInputElement) {
|
|
173
|
+
return ["submit", "button", "reset", "image", "checkbox", "radio"].includes(element.type);
|
|
174
|
+
}
|
|
175
|
+
return element.localName === "summary";
|
|
176
|
+
}
|
|
177
|
+
function keyboardClick(element, view) {
|
|
178
|
+
element.dispatchEvent(new view.MouseEvent("click", { bubbles: true, cancelable: true, composed: true, view, detail: 0 }));
|
|
179
|
+
}
|
|
180
|
+
function pressKey(element, view, key) {
|
|
181
|
+
if (!KEY.test(key))
|
|
182
|
+
return { ok: false, problem: "INVALID_ACTION" };
|
|
183
|
+
const eventKey = key === "Space" ? " " : key;
|
|
184
|
+
if (element instanceof view.HTMLElement)
|
|
185
|
+
element.focus();
|
|
186
|
+
const init = { key: eventKey, bubbles: true, cancelable: true, composed: true };
|
|
187
|
+
const downProceeds = element.dispatchEvent(new view.KeyboardEvent("keydown", init));
|
|
188
|
+
if (eventKey === "Enter" && downProceeds) {
|
|
189
|
+
if (activatesOnEnter(element, view))
|
|
190
|
+
keyboardClick(element, view);
|
|
191
|
+
else if (element instanceof view.HTMLInputElement && isTextField(element, view) && element.form) {
|
|
192
|
+
implicitSubmit(element.form, view);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const upProceeds = element.dispatchEvent(new view.KeyboardEvent("keyup", init));
|
|
196
|
+
if (eventKey === " " && downProceeds && upProceeds && activatesOnSpace(element, view))
|
|
197
|
+
keyboardClick(element, view);
|
|
198
|
+
return { ok: true };
|
|
199
|
+
}
|
|
200
|
+
var SUBMIT_INPUTS = new Set(["submit", "image"]);
|
|
201
|
+
var BLOCKING_INPUTS = new Set([
|
|
202
|
+
"text",
|
|
203
|
+
"search",
|
|
204
|
+
"url",
|
|
205
|
+
"tel",
|
|
206
|
+
"email",
|
|
207
|
+
"password",
|
|
208
|
+
"date",
|
|
209
|
+
"month",
|
|
210
|
+
"week",
|
|
211
|
+
"time",
|
|
212
|
+
"datetime-local",
|
|
213
|
+
"number"
|
|
214
|
+
]);
|
|
215
|
+
function implicitSubmit(form, view) {
|
|
216
|
+
const controls = Array.from(form.elements);
|
|
217
|
+
const root = form.getRootNode();
|
|
218
|
+
const defaultButton = Array.from(root.querySelectorAll("button, input")).find((control) => (control instanceof view.HTMLButtonElement && control.type === "submit" || control instanceof view.HTMLInputElement && SUBMIT_INPUTS.has(control.type)) && control.form === form);
|
|
219
|
+
if (defaultButton) {
|
|
220
|
+
if (isElementEnabled2(defaultButton))
|
|
221
|
+
keyboardClick(defaultButton, view);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const blocking = controls.filter((control) => control instanceof view.HTMLInputElement && BLOCKING_INPUTS.has(control.type));
|
|
225
|
+
if (blocking.length === 1)
|
|
226
|
+
form.requestSubmit();
|
|
227
|
+
}
|
|
228
|
+
function readValue(element, view) {
|
|
229
|
+
if (element instanceof view.HTMLInputElement && (element.type === "checkbox" || element.type === "radio")) {
|
|
230
|
+
return element.checked;
|
|
231
|
+
}
|
|
232
|
+
if (element instanceof view.HTMLInputElement || element instanceof view.HTMLTextAreaElement || element instanceof view.HTMLSelectElement) {
|
|
233
|
+
return element.value.slice(0, MAX_READ_TEXT);
|
|
234
|
+
}
|
|
235
|
+
const checked = element.getAttribute("aria-checked");
|
|
236
|
+
if (checked === "true" || checked === "false")
|
|
237
|
+
return checked === "true";
|
|
238
|
+
return element.getAttribute("aria-valuenow") ?? element.getAttribute("aria-valuetext");
|
|
239
|
+
}
|
|
240
|
+
var ATTRIBUTE_NAME = /^[A-Za-z_][\w:.-]{0,127}$/;
|
|
241
|
+
function performDomAction(element, action) {
|
|
242
|
+
const view = viewOf(element);
|
|
243
|
+
if (!view)
|
|
244
|
+
return { ok: false, problem: "INVALID_ACTION" };
|
|
245
|
+
switch (action.kind) {
|
|
246
|
+
case "click":
|
|
247
|
+
click(element, view, action.button ?? "left");
|
|
248
|
+
return { ok: true };
|
|
249
|
+
case "doubleClick":
|
|
250
|
+
click(element, view, "left", 1);
|
|
251
|
+
click(element, view, "left", 2);
|
|
252
|
+
element.dispatchEvent(new view.MouseEvent("dblclick", { ...pointerInit(element, view, "left"), detail: 2 }));
|
|
253
|
+
return { ok: true };
|
|
254
|
+
case "hover": {
|
|
255
|
+
const init = pointerInit(element, view, "left");
|
|
256
|
+
const PointerCtor = typeof view.PointerEvent === "function" ? view.PointerEvent : view.MouseEvent;
|
|
257
|
+
pointerArrives(element, view, init);
|
|
258
|
+
element.dispatchEvent(new PointerCtor("pointermove", init));
|
|
259
|
+
element.dispatchEvent(new view.MouseEvent("mousemove", init));
|
|
260
|
+
return { ok: true };
|
|
261
|
+
}
|
|
262
|
+
case "focus":
|
|
263
|
+
if (element instanceof view.HTMLElement)
|
|
264
|
+
element.focus();
|
|
265
|
+
return { ok: true };
|
|
266
|
+
case "type":
|
|
267
|
+
return typeof action.text === "string" ? typeInto(element, view, action.text, action.append === true) : { ok: false, problem: "INVALID_ACTION" };
|
|
268
|
+
case "clear":
|
|
269
|
+
return typeInto(element, view, "", false);
|
|
270
|
+
case "select":
|
|
271
|
+
return selectOption(element, view, action);
|
|
272
|
+
case "check":
|
|
273
|
+
return setChecked(element, view, action.checked === true);
|
|
274
|
+
case "pressKey":
|
|
275
|
+
return typeof action.key === "string" ? pressKey(element, view, action.key) : { ok: false, problem: "INVALID_ACTION" };
|
|
276
|
+
case "scroll":
|
|
277
|
+
element.scrollBy?.({ left: Number(action.dx ?? 0) || 0, top: Number(action.dy ?? 0) || 0 });
|
|
278
|
+
return { ok: true };
|
|
279
|
+
case "scrollIntoView":
|
|
280
|
+
element.scrollIntoView?.({ block: "center", inline: "nearest" });
|
|
281
|
+
return { ok: true };
|
|
282
|
+
case "getText":
|
|
283
|
+
if (isSensitiveElement2(element))
|
|
284
|
+
return { ok: false, problem: "SENSITIVE_ELEMENT" };
|
|
285
|
+
return { ok: true, value: visibleText2(element).slice(0, MAX_READ_TEXT) };
|
|
286
|
+
case "getValue":
|
|
287
|
+
if (isSensitiveElement2(element))
|
|
288
|
+
return { ok: false, problem: "SENSITIVE_ELEMENT" };
|
|
289
|
+
return { ok: true, value: readValue(element, view) };
|
|
290
|
+
case "getAttribute": {
|
|
291
|
+
if (typeof action.name !== "string" || !ATTRIBUTE_NAME.test(action.name))
|
|
292
|
+
return { ok: false, problem: "INVALID_ACTION" };
|
|
293
|
+
const name = action.name.toLowerCase();
|
|
294
|
+
if (isSensitiveElement2(element))
|
|
295
|
+
return { ok: false, problem: "SENSITIVE_ELEMENT" };
|
|
296
|
+
return { ok: true, value: element.getAttribute(name)?.slice(0, MAX_READ_TEXT) ?? null };
|
|
297
|
+
}
|
|
298
|
+
case "exists":
|
|
299
|
+
return { ok: true, value: true };
|
|
300
|
+
default:
|
|
301
|
+
return { ok: false, problem: "INVALID_ACTION" };
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// src/dom-runtime/runtime.ts
|
|
306
|
+
var DOM_RUNTIME_VERSION = 1;
|
|
307
|
+
var DOM_RUNTIME_GLOBAL = "__burdenoffUiRuntime";
|
|
308
|
+
var MAX_HIGHLIGHT_MS = 60000;
|
|
309
|
+
var HIGHLIGHT_HOST_TAG = "fg-ui-highlight";
|
|
310
|
+
var METHOD_KINDS = new Set(["role", "css", "testId", "xpath", "fuzzy", "anchor", "text"]);
|
|
311
|
+
function isRuntimeTarget(value) {
|
|
312
|
+
if (!value || typeof value !== "object")
|
|
313
|
+
return false;
|
|
314
|
+
const target = value;
|
|
315
|
+
if (!Array.isArray(target.methods) || target.methods.length === 0 || target.methods.length > 8)
|
|
316
|
+
return false;
|
|
317
|
+
if (target.frame !== undefined && !(Array.isArray(target.frame) && target.frame.every((item) => typeof item === "string"))) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
return target.methods.every((method) => !!method && typeof method === "object" && METHOD_KINDS.has(String(method.kind)));
|
|
321
|
+
}
|
|
322
|
+
function invalidTarget() {
|
|
323
|
+
return { status: "failed", code: "ELEMENT_NOT_FOUND", candidates: [], candidateCount: 0, attempts: [] };
|
|
324
|
+
}
|
|
325
|
+
function withoutElement(found) {
|
|
326
|
+
return {
|
|
327
|
+
status: found.status,
|
|
328
|
+
method: found.method,
|
|
329
|
+
methodIndex: found.methodIndex,
|
|
330
|
+
fallback: found.fallback,
|
|
331
|
+
candidate: found.candidate,
|
|
332
|
+
attempts: found.attempts
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function frameElementOf(document) {
|
|
336
|
+
try {
|
|
337
|
+
return document.defaultView?.frameElement ?? null;
|
|
338
|
+
} catch {
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function coveredAt(current, x, y, labels) {
|
|
343
|
+
const root = current.getRootNode();
|
|
344
|
+
if (typeof root.elementFromPoint !== "function")
|
|
345
|
+
return null;
|
|
346
|
+
const top = root.elementFromPoint(x, y);
|
|
347
|
+
if (!top)
|
|
348
|
+
return "offscreen";
|
|
349
|
+
if (top === current || current.contains(top))
|
|
350
|
+
return null;
|
|
351
|
+
return labels.some((label) => label.contains(top)) ? null : "covered";
|
|
352
|
+
}
|
|
353
|
+
function coverage(element, rect) {
|
|
354
|
+
let x = rect.x + rect.width / 2;
|
|
355
|
+
let y = rect.y + rect.height / 2;
|
|
356
|
+
const labels = Array.from(element.labels ?? []);
|
|
357
|
+
let current = element;
|
|
358
|
+
for (let hop = 0;hop < 32; hop += 1) {
|
|
359
|
+
const blocked = coveredAt(current, x, y, hop === 0 ? labels : []);
|
|
360
|
+
if (blocked)
|
|
361
|
+
return blocked;
|
|
362
|
+
const root = current.getRootNode();
|
|
363
|
+
if (root && "host" in root) {
|
|
364
|
+
current = root.host;
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
const frame = frameElementOf(current.ownerDocument);
|
|
368
|
+
if (!frame)
|
|
369
|
+
return null;
|
|
370
|
+
const box = frame.getBoundingClientRect();
|
|
371
|
+
x += box.x + frame.clientLeft;
|
|
372
|
+
y += box.y + frame.clientTop;
|
|
373
|
+
current = frame;
|
|
374
|
+
}
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
function outsideViewport(element, rect) {
|
|
378
|
+
const view = element.ownerDocument.defaultView;
|
|
379
|
+
if (!view)
|
|
380
|
+
return false;
|
|
381
|
+
const x = rect.x + rect.width / 2;
|
|
382
|
+
const y = rect.y + rect.height / 2;
|
|
383
|
+
return x < 0 || y < 0 || x >= view.innerWidth || y >= view.innerHeight;
|
|
384
|
+
}
|
|
385
|
+
function pointerBlock(element) {
|
|
386
|
+
const view = element.ownerDocument.defaultView;
|
|
387
|
+
if (view && view.getComputedStyle(element).pointerEvents === "none")
|
|
388
|
+
return "noPointerEvents";
|
|
389
|
+
let rect = element.getBoundingClientRect();
|
|
390
|
+
if (rect.width <= 0 || rect.height <= 0)
|
|
391
|
+
return null;
|
|
392
|
+
if (outsideViewport(element, rect) && typeof element.scrollIntoView === "function") {
|
|
393
|
+
element.scrollIntoView({ block: "center", inline: "center" });
|
|
394
|
+
rect = element.getBoundingClientRect();
|
|
395
|
+
}
|
|
396
|
+
return coverage(element, rect);
|
|
397
|
+
}
|
|
398
|
+
function createDomRuntime(document, options = {}) {
|
|
399
|
+
const root = options.root ?? document;
|
|
400
|
+
const probe = {
|
|
401
|
+
...options.rectOf ? { rectOf: options.rectOf } : {},
|
|
402
|
+
...options.isVisible ? { isVisible: options.isVisible } : {}
|
|
403
|
+
};
|
|
404
|
+
let overlay = null;
|
|
405
|
+
let clearTimer = null;
|
|
406
|
+
const clearHighlight = () => {
|
|
407
|
+
if (clearTimer !== null) {
|
|
408
|
+
clearTimeout(clearTimer);
|
|
409
|
+
clearTimer = null;
|
|
410
|
+
}
|
|
411
|
+
overlay?.remove();
|
|
412
|
+
overlay = null;
|
|
413
|
+
};
|
|
414
|
+
const resolveRaw = (target, state) => {
|
|
415
|
+
clearHighlight();
|
|
416
|
+
return resolveWebTarget2(root, target, { ...probe, ...state ? { state } : {} });
|
|
417
|
+
};
|
|
418
|
+
const resolve = (target, resolveOptions = {}) => {
|
|
419
|
+
if (!isRuntimeTarget(target))
|
|
420
|
+
return invalidTarget();
|
|
421
|
+
const result = resolveRaw(target, resolveOptions.state);
|
|
422
|
+
return result.status === "found" ? withoutElement(result) : result;
|
|
423
|
+
};
|
|
424
|
+
const act = (target, action, actOptions = {}) => {
|
|
425
|
+
if (!action || typeof action !== "object" || typeof action.kind !== "string") {
|
|
426
|
+
return { ok: false, code: "INVALID_ACTION" };
|
|
427
|
+
}
|
|
428
|
+
if (!isRuntimeTarget(target)) {
|
|
429
|
+
return { ok: false, code: "ELEMENT_NOT_FOUND", resolution: invalidTarget() };
|
|
430
|
+
}
|
|
431
|
+
const state = actOptions.state ?? (READ_ACTIONS.has(action.kind) ? "visible" : "interactable");
|
|
432
|
+
const result = resolveRaw(target, state);
|
|
433
|
+
if (result.status !== "found") {
|
|
434
|
+
if (action.kind === "exists" && result.code === "ELEMENT_NOT_FOUND") {
|
|
435
|
+
return { ok: true, value: false, resolution: result };
|
|
436
|
+
}
|
|
437
|
+
return { ok: false, code: result.code, resolution: result };
|
|
438
|
+
}
|
|
439
|
+
const resolution = withoutElement(result);
|
|
440
|
+
const blocked = POINTER_ACTIONS.has(action.kind) ? pointerBlock(result.element) : null;
|
|
441
|
+
if (blocked) {
|
|
442
|
+
return {
|
|
443
|
+
ok: false,
|
|
444
|
+
code: "ELEMENT_NOT_INTERACTABLE",
|
|
445
|
+
reason: blocked,
|
|
446
|
+
resolution: {
|
|
447
|
+
status: "failed",
|
|
448
|
+
code: "ELEMENT_NOT_INTERACTABLE",
|
|
449
|
+
candidates: [result.candidate],
|
|
450
|
+
candidateCount: 1,
|
|
451
|
+
attempts: result.attempts
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
const outcome = performDomAction(result.element, action);
|
|
456
|
+
if (!outcome.ok)
|
|
457
|
+
return { ok: false, code: outcome.problem, resolution };
|
|
458
|
+
return outcome.value === undefined ? { ok: true, resolution } : { ok: true, resolution, value: outcome.value };
|
|
459
|
+
};
|
|
460
|
+
const drawBoxes = (boxes, label, numbered) => {
|
|
461
|
+
const host = document.createElement(HIGHLIGHT_HOST_TAG);
|
|
462
|
+
host.setAttribute("aria-hidden", "true");
|
|
463
|
+
host.setAttribute("style", "all: initial; position: fixed; inset: 0; pointer-events: none; z-index: 2147483647;");
|
|
464
|
+
const shadow = host.attachShadow({ mode: "closed" });
|
|
465
|
+
boxes.forEach((box, index) => {
|
|
466
|
+
const frame = document.createElement("div");
|
|
467
|
+
frame.setAttribute("style", `position: fixed; left: ${box.bounds.x - 3}px; top: ${box.bounds.y - 3}px; width: ${box.bounds.width + 6}px; height: ${box.bounds.height + 6}px; outline: 3px solid Highlight; border-radius: 4px; box-sizing: border-box;`);
|
|
468
|
+
const caption = numbered ? `${index + 1}${label ? ` ${label}` : ""}` : label;
|
|
469
|
+
if (caption) {
|
|
470
|
+
const tag = document.createElement("span");
|
|
471
|
+
tag.textContent = caption.slice(0, 120);
|
|
472
|
+
tag.setAttribute("style", "position: absolute; left: 0; top: 100%; margin-top: 4px; padding: 2px 6px; font: 600 11px system-ui, sans-serif; background: Highlight; color: HighlightText; border-radius: 3px; white-space: nowrap;");
|
|
473
|
+
frame.appendChild(tag);
|
|
474
|
+
}
|
|
475
|
+
shadow.appendChild(frame);
|
|
476
|
+
});
|
|
477
|
+
document.documentElement.appendChild(host);
|
|
478
|
+
overlay = host;
|
|
479
|
+
};
|
|
480
|
+
const highlight = (target, highlightOptions = {}) => {
|
|
481
|
+
if (!isRuntimeTarget(target))
|
|
482
|
+
return invalidTarget();
|
|
483
|
+
const result = resolveRaw(target, highlightOptions.state ?? "visible");
|
|
484
|
+
if (result.status === "found")
|
|
485
|
+
drawBoxes([result.candidate], highlightOptions.label, false);
|
|
486
|
+
else if (result.candidates.length > 0)
|
|
487
|
+
drawBoxes(result.candidates, highlightOptions.label, true);
|
|
488
|
+
const duration = Math.min(MAX_HIGHLIGHT_MS, Math.max(0, Number(highlightOptions.durationMs ?? 0) || 0));
|
|
489
|
+
if (overlay && duration > 0)
|
|
490
|
+
clearTimer = setTimeout(clearHighlight, duration);
|
|
491
|
+
return result.status === "found" ? withoutElement(result) : result;
|
|
492
|
+
};
|
|
493
|
+
return {
|
|
494
|
+
version: DOM_RUNTIME_VERSION,
|
|
495
|
+
resolve,
|
|
496
|
+
act,
|
|
497
|
+
highlight,
|
|
498
|
+
clearHighlight,
|
|
499
|
+
snapshot: (snapshotOptions = {}) => {
|
|
500
|
+
clearHighlight();
|
|
501
|
+
return serializeTreeSnapshot2(document, {
|
|
502
|
+
...probe,
|
|
503
|
+
...snapshotOptions.maxNodes ? { maxNodes: snapshotOptions.maxNodes } : {}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
function installDomRuntime(scope, document) {
|
|
509
|
+
const existing = Reflect.get(scope, DOM_RUNTIME_GLOBAL);
|
|
510
|
+
if (existing && typeof existing === "object" && typeof existing.version === "number" && existing.version >= DOM_RUNTIME_VERSION) {
|
|
511
|
+
return existing;
|
|
512
|
+
}
|
|
513
|
+
const runtime = Object.freeze(createDomRuntime(document));
|
|
514
|
+
Object.defineProperty(scope, DOM_RUNTIME_GLOBAL, {
|
|
515
|
+
value: runtime,
|
|
516
|
+
configurable: true,
|
|
517
|
+
enumerable: false,
|
|
518
|
+
writable: false
|
|
519
|
+
});
|
|
520
|
+
return runtime;
|
|
521
|
+
}
|
|
522
|
+
export {
|
|
523
|
+
DOM_RUNTIME_GLOBAL,
|
|
524
|
+
DOM_RUNTIME_VERSION,
|
|
525
|
+
HIGHLIGHT_HOST_TAG,
|
|
526
|
+
MAX_HIGHLIGHT_MS,
|
|
527
|
+
MAX_READ_TEXT,
|
|
528
|
+
MAX_TYPED_TEXT,
|
|
529
|
+
POINTER_ACTIONS,
|
|
530
|
+
READ_ACTIONS,
|
|
531
|
+
createDomRuntime,
|
|
532
|
+
installDomRuntime,
|
|
533
|
+
isRuntimeTarget,
|
|
534
|
+
performDomAction
|
|
535
|
+
};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RECORDING_VERSION2,
|
|
3
|
+
targetFingerprint2,
|
|
4
|
+
parseRecording2
|
|
5
|
+
} from "./index-cs6acyjn.js";
|
|
1
6
|
import {
|
|
2
7
|
REDACTED2,
|
|
3
8
|
redactCredentials2,
|
|
4
9
|
containsCredential,
|
|
5
10
|
decodeUriText,
|
|
6
|
-
containsCredentialInUrl
|
|
7
|
-
|
|
8
|
-
targetFingerprint2,
|
|
9
|
-
parseRecording2
|
|
10
|
-
} from "./index-c6pmt2rg.js";
|
|
11
|
+
containsCredentialInUrl
|
|
12
|
+
} from "./index-mgztm37r.js";
|
|
11
13
|
|
|
12
14
|
// src/capture.ts
|
|
13
15
|
var SECRET_FIELD = /password|passcode|passwd|\bpin\b|otp|one[\s-]?time|verification|security code|auth(?:entication)? code|\bcvv\b|\bcvc\b|card number|secret|token|recovery/i;
|
|
@@ -1,65 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
containsCredential,
|
|
3
|
+
containsCredentialInUrl
|
|
4
|
+
} from "./index-mgztm37r.js";
|
|
5
|
+
|
|
1
6
|
// src/recording.ts
|
|
2
7
|
import { sha256 as nobleSha256 } from "@noble/hashes/sha2.js";
|
|
3
8
|
import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js";
|
|
4
9
|
import { z } from "zod";
|
|
5
|
-
|
|
6
|
-
// src/redact-credentials.ts
|
|
7
|
-
var REDACTED2 = "[REDACTED]";
|
|
8
|
-
var CREDENTIAL_PATTERNS = [
|
|
9
|
-
/\b(?:Bearer|Basic)\s+[^\s"'`,;)\]}]+/gi,
|
|
10
|
-
/\b(?:sk|pk|rk|xai)-[^\s"'`,;)\]}]+/gi,
|
|
11
|
-
/\b(?:gsk|hf|ghp|gho|ghs|ghu|glpat)_[^\s"'`,;)\]}]+/gi,
|
|
12
|
-
/\bAIza[\w-]{10,}/g,
|
|
13
|
-
/\b(?:AKIA|ASIA)[0-9A-Z]{12,}/g
|
|
14
|
-
];
|
|
15
|
-
var SEPARATORS = /([\s"'`,;:=()[\]{}]+)/;
|
|
16
|
-
var SECRET_KEY = /^(?:api[_-]?key|access[_-]?key|secret|secret[_-]?key|client[_-]?secret|token|password)$/i;
|
|
17
|
-
function isMaskedFragment(word) {
|
|
18
|
-
const ellipsis = word.indexOf("…");
|
|
19
|
-
return word.includes("***") || ellipsis !== -1 && ellipsis < word.length - 1;
|
|
20
|
-
}
|
|
21
|
-
function redactWords(text) {
|
|
22
|
-
const parts = text.split(SEPARATORS);
|
|
23
|
-
for (let index = 0;index < parts.length; index += 2) {
|
|
24
|
-
const word = parts[index] ?? "";
|
|
25
|
-
if (word && word !== REDACTED2 && isMaskedFragment(word))
|
|
26
|
-
parts[index] = REDACTED2;
|
|
27
|
-
const separator = parts[index + 1] ?? "";
|
|
28
|
-
const next = parts[index + 2];
|
|
29
|
-
if (next && SECRET_KEY.test(word) && /[:=]/.test(separator))
|
|
30
|
-
parts[index + 2] = REDACTED2;
|
|
31
|
-
}
|
|
32
|
-
return parts.join("");
|
|
33
|
-
}
|
|
34
|
-
function redactCredentials2(text) {
|
|
35
|
-
if (!text)
|
|
36
|
-
return text;
|
|
37
|
-
let redacted = text;
|
|
38
|
-
for (const pattern of CREDENTIAL_PATTERNS) {
|
|
39
|
-
redacted = redacted.replace(pattern, REDACTED2);
|
|
40
|
-
}
|
|
41
|
-
redacted = redactWords(redacted);
|
|
42
|
-
return redacted.replace(/(?:\[REDACTED\]){2,}/g, REDACTED2);
|
|
43
|
-
}
|
|
44
|
-
var MARKER_PROBE = "";
|
|
45
|
-
function containsCredential(text) {
|
|
46
|
-
if (!text)
|
|
47
|
-
return false;
|
|
48
|
-
const probe = text.replaceAll(REDACTED2, MARKER_PROBE);
|
|
49
|
-
return redactCredentials2(probe).replaceAll(MARKER_PROBE, REDACTED2) !== text;
|
|
50
|
-
}
|
|
51
|
-
function decodeUriText(text) {
|
|
52
|
-
try {
|
|
53
|
-
return decodeURIComponent(text.replaceAll("+", " "));
|
|
54
|
-
} catch {
|
|
55
|
-
return text;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function containsCredentialInUrl(text) {
|
|
59
|
-
return containsCredential(decodeUriText(text).replace(/[/?&#]/g, " "));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// src/recording.ts
|
|
63
10
|
function sha256Hex2(text) {
|
|
64
11
|
return bytesToHex(nobleSha256(utf8ToBytes(text)));
|
|
65
12
|
}
|
|
@@ -210,4 +157,4 @@ function isSavedStepAuthor2(value) {
|
|
|
210
157
|
return typeof value === "string" && SAVED_STEP_AUTHORS2.includes(value);
|
|
211
158
|
}
|
|
212
159
|
|
|
213
|
-
export {
|
|
160
|
+
export { sha256Hex2, RECORDING_VERSION2, MAX_RECORDED_STEPS2, SAVED_STEP_AUTHORS2, REPLAYABLE_ACTIONS2, recordedTargetSchema2, recordedStepSchema2, recordingSchema2, targetFingerprint2, RecordingError2, parseRecording2, isSavedStepAuthor2 };
|