@burdenoff/ui-engine 2026.1127.3 → 2026.1127.4

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.
Files changed (40) hide show
  1. package/README.md +45 -5
  2. package/dist/dom-runtime.iife.js +1 -1
  3. package/dist/dom-runtime.js +27 -532
  4. package/dist/drivers/dom-driver.d.ts +44 -0
  5. package/dist/drivers/index.d.ts +7 -0
  6. package/dist/drivers/snapshot-driver.d.ts +59 -0
  7. package/dist/drivers.d.ts +2 -0
  8. package/dist/drivers.js +170 -0
  9. package/dist/index-3f1j8386.js +334 -0
  10. package/dist/index-3jymbm5t.js +315 -0
  11. package/dist/{index-q1b0j9yr.js → index-5k26keah.js} +58 -592
  12. package/dist/index-77pcz6n3.js +303 -0
  13. package/dist/index-895kscx3.js +741 -0
  14. package/dist/index-ct2xctrq.js +229 -0
  15. package/dist/index-h88y5qgv.js +400 -0
  16. package/dist/{index-zwrxw3zp.js → index-pm13mvvc.js} +24 -1009
  17. package/dist/index-vg8r40y7.js +220 -0
  18. package/dist/index-ycs2bz1a.js +589 -0
  19. package/dist/index-zzhysbkj.js +1731 -0
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.js +123 -37
  22. package/dist/interpret/compile.d.ts +58 -0
  23. package/dist/interpret/driver.d.ts +171 -0
  24. package/dist/interpret/errors.d.ts +194 -0
  25. package/dist/interpret/events.d.ts +73 -0
  26. package/dist/interpret/expr.d.ts +35 -0
  27. package/dist/interpret/index.d.ts +13 -0
  28. package/dist/interpret/run.d.ts +77 -0
  29. package/dist/interpret.d.ts +2 -0
  30. package/dist/interpret.js +84 -0
  31. package/dist/script/adapters/browser-action-contract.d.ts +5 -2
  32. package/dist/script/limits.d.ts +2 -0
  33. package/dist/script.js +44 -38
  34. package/dist/target/index.d.ts +1 -1
  35. package/dist/target/resolve.d.ts +18 -1
  36. package/dist/target.js +23 -19
  37. package/dist/testing/fake-web-driver.d.ts +28 -0
  38. package/dist/testing/index.d.ts +3 -2
  39. package/dist/testing.js +55 -0
  40. package/package.json +11 -3
@@ -1,3 +1,26 @@
1
+ import {
2
+ SENSITIVE_MARKERS2,
3
+ assignedSlotOf,
4
+ containerOf,
5
+ isMarkedSensitive,
6
+ MAX_COMPARED_TEXT2,
7
+ normaliseText2,
8
+ sameText2,
9
+ containsText2,
10
+ textSimilarity2,
11
+ clip2,
12
+ roleOf2,
13
+ isTypedContent2,
14
+ accessibleName2,
15
+ labelName2,
16
+ visibleText2,
17
+ matchesRoleAndName2,
18
+ isElementVisible2,
19
+ isElementEnabled2,
20
+ elementRect2,
21
+ elementsUnder2,
22
+ isSensitiveElement2
23
+ } from "./index-ycs2bz1a.js";
1
24
  import {
2
25
  REDACTED2,
3
26
  redactCredentials2,
@@ -11,594 +34,6 @@ var WEB_TARGET_ERROR_CODES2 = ["ELEMENT_NOT_FOUND", "ELEMENT_AMBIGUOUS", "ELEMEN
11
34
  var MAX_CANDIDATES2 = 5;
12
35
  var MAX_CANDIDATE_NAME2 = 200;
13
36
 
14
- // src/target/markers.ts
15
- var SENSITIVE_MARKERS2 = ["data-fg-sensitive", "data-sensitive", "data-private"];
16
- function hasSensitiveMarker2(element) {
17
- return SENSITIVE_MARKERS2.some((marker) => element.hasAttribute(marker));
18
- }
19
- function assignedSlotOf(element) {
20
- const native = element.assignedSlot;
21
- if (native !== undefined)
22
- return native;
23
- const shadow = element.parentElement?.shadowRoot;
24
- if (!shadow)
25
- return null;
26
- for (const slot of Array.from(shadow.querySelectorAll("slot"))) {
27
- const assigned = typeof slot.assignedNodes === "function" ? slot.assignedNodes() : [];
28
- if (assigned.includes(element))
29
- return slot;
30
- }
31
- return null;
32
- }
33
- function containerOf(element) {
34
- const slot = assignedSlotOf(element);
35
- if (slot)
36
- return slot;
37
- if (element.parentElement)
38
- return element.parentElement;
39
- const root = element.getRootNode();
40
- if (root && "host" in root)
41
- return root.host;
42
- try {
43
- return element.ownerDocument.defaultView?.frameElement ?? null;
44
- } catch {
45
- return null;
46
- }
47
- }
48
- function isMarkedSensitive(element) {
49
- for (let current = element;current; current = containerOf(current)) {
50
- if (hasSensitiveMarker2(current))
51
- return true;
52
- }
53
- return false;
54
- }
55
-
56
- // src/target/text.ts
57
- var MAX_COMPARED_TEXT2 = 256;
58
- function normaliseText2(value) {
59
- return (value ?? "").normalize("NFKC").replace(/\s+/g, " ").trim().toLowerCase();
60
- }
61
- function sameText2(a, b) {
62
- return normaliseText2(a) === normaliseText2(b);
63
- }
64
- function containsText2(haystack, needle) {
65
- const wanted = normaliseText2(needle);
66
- return wanted.length > 0 && normaliseText2(haystack).includes(wanted);
67
- }
68
- function editDistance2(a, b) {
69
- if (a === b)
70
- return 0;
71
- if (a.length === 0)
72
- return b.length;
73
- if (b.length === 0)
74
- return a.length;
75
- let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
76
- for (let i = 1;i <= a.length; i += 1) {
77
- const current = [i];
78
- for (let j = 1;j <= b.length; j += 1) {
79
- const cost = a[i - 1] === b[j - 1] ? 0 : 1;
80
- current[j] = Math.min((previous[j] ?? 0) + 1, (current[j - 1] ?? 0) + 1, (previous[j - 1] ?? 0) + cost);
81
- }
82
- previous = current;
83
- }
84
- return previous[b.length] ?? 0;
85
- }
86
- function textSimilarity2(a, b) {
87
- const left = normaliseText2(a).slice(0, MAX_COMPARED_TEXT2);
88
- const right = normaliseText2(b).slice(0, MAX_COMPARED_TEXT2);
89
- const longest = Math.max(left.length, right.length);
90
- if (longest === 0)
91
- return 0;
92
- return 1 - editDistance2(left, right) / longest;
93
- }
94
- function clip2(value, max) {
95
- return value.length <= max ? value : `${value.slice(0, Math.max(0, max - 1))}…`;
96
- }
97
-
98
- // src/target/aria.ts
99
- var MAX_NAME_LENGTH3 = 512;
100
- var MAX_VISIBLE_TEXT2 = 65536;
101
- var INPUT_ROLES = {
102
- button: "button",
103
- submit: "button",
104
- reset: "button",
105
- image: "button",
106
- checkbox: "checkbox",
107
- radio: "radio",
108
- range: "slider",
109
- number: "spinbutton",
110
- search: "searchbox",
111
- email: "textbox",
112
- tel: "textbox",
113
- text: "textbox",
114
- url: "textbox",
115
- password: "textbox",
116
- date: "textbox",
117
- "datetime-local": "textbox",
118
- month: "textbox",
119
- time: "textbox",
120
- week: "textbox",
121
- color: "textbox",
122
- file: "button"
123
- };
124
- var TAG_ROLES = {
125
- article: "article",
126
- aside: "complementary",
127
- button: "button",
128
- datalist: "listbox",
129
- dd: "definition",
130
- details: "group",
131
- dialog: "dialog",
132
- dt: "term",
133
- fieldset: "group",
134
- figure: "figure",
135
- h1: "heading",
136
- h2: "heading",
137
- h3: "heading",
138
- h4: "heading",
139
- h5: "heading",
140
- h6: "heading",
141
- hr: "separator",
142
- li: "listitem",
143
- main: "main",
144
- menu: "list",
145
- meter: "meter",
146
- nav: "navigation",
147
- ol: "list",
148
- optgroup: "group",
149
- option: "option",
150
- output: "status",
151
- p: "paragraph",
152
- progress: "progressbar",
153
- summary: "button",
154
- table: "table",
155
- tbody: "rowgroup",
156
- td: "cell",
157
- textarea: "textbox",
158
- tfoot: "rowgroup",
159
- thead: "rowgroup",
160
- tr: "row",
161
- ul: "list"
162
- };
163
- var NAME_FROM_CONTENT = new Set([
164
- "button",
165
- "cell",
166
- "checkbox",
167
- "columnheader",
168
- "gridcell",
169
- "heading",
170
- "link",
171
- "menuitem",
172
- "menuitemcheckbox",
173
- "menuitemradio",
174
- "option",
175
- "radio",
176
- "row",
177
- "rowheader",
178
- "switch",
179
- "tab",
180
- "tooltip",
181
- "treeitem"
182
- ]);
183
- var LABELABLE = new Set(["button", "input", "meter", "output", "progress", "select", "textarea"]);
184
- var SKIPPED_CONTENT = new Set(["script", "style", "noscript", "template", "head", "title", "meta", "link"]);
185
- function tagOf(element) {
186
- return element.localName.toLowerCase();
187
- }
188
- function hasSectioningAncestor(element) {
189
- return element.parentElement?.closest("article, aside, main, nav, section") != null;
190
- }
191
- function implicitRole(element) {
192
- const tag = tagOf(element);
193
- switch (tag) {
194
- case "a":
195
- case "area":
196
- return element.hasAttribute("href") ? "link" : "";
197
- case "input": {
198
- const type = (element.getAttribute("type") ?? "text").toLowerCase();
199
- if (type === "hidden")
200
- return "";
201
- if (element.hasAttribute("list") && ["text", "search", "email", "tel", "url"].includes(type))
202
- return "combobox";
203
- return INPUT_ROLES[type] ?? "textbox";
204
- }
205
- case "select": {
206
- const size = Number(element.getAttribute("size") ?? "0");
207
- return element.hasAttribute("multiple") || size > 1 ? "listbox" : "combobox";
208
- }
209
- case "img": {
210
- const alt = element.getAttribute("alt");
211
- return alt === "" ? "presentation" : "img";
212
- }
213
- case "th":
214
- return element.getAttribute("scope") === "row" ? "rowheader" : "columnheader";
215
- case "header":
216
- return hasSectioningAncestor(element) ? "" : "banner";
217
- case "footer":
218
- return hasSectioningAncestor(element) ? "" : "contentinfo";
219
- case "section":
220
- case "form":
221
- return element.hasAttribute("aria-label") || element.hasAttribute("aria-labelledby") ? tag === "form" ? "form" : "region" : "";
222
- default:
223
- return TAG_ROLES[tag] ?? "";
224
- }
225
- }
226
- function roleOf2(element) {
227
- const explicit = element.getAttribute("role")?.trim().split(/\s+/)[0];
228
- return explicit ? explicit.toLowerCase() : implicitRole(element);
229
- }
230
- function byId(element, id) {
231
- const root = element.getRootNode();
232
- return typeof root.getElementById === "function" ? root.getElementById(id) : null;
233
- }
234
- function isHiddenForName(element) {
235
- return element.hasAttribute("hidden") || element.getAttribute("aria-hidden") === "true";
236
- }
237
- function cssHiding(element) {
238
- const view = element.ownerDocument.defaultView;
239
- if (!view)
240
- return "none";
241
- const style = view.getComputedStyle(element);
242
- if (style.display === "none")
243
- return "subtree";
244
- return style.visibility === "hidden" || style.visibility === "collapse" ? "self" : "none";
245
- }
246
- function isEditingHost(element) {
247
- const value = element.getAttribute("contenteditable");
248
- if (value === null)
249
- return false;
250
- const normalised = value.trim().toLowerCase();
251
- return normalised === "" || normalised === "true" || normalised === "plaintext-only";
252
- }
253
- function renderedChildren(element) {
254
- if (element.shadowRoot)
255
- return Array.from(element.shadowRoot.childNodes);
256
- if (tagOf(element) === "slot") {
257
- const slot = element;
258
- const assigned = typeof slot.assignedNodes === "function" ? slot.assignedNodes({ flatten: true }) : [];
259
- if (assigned.length > 0)
260
- return assigned;
261
- }
262
- return Array.from(element.childNodes);
263
- }
264
- var BLOCK_TAGS = /^(div|p|li|tr|td|th|br|h[1-6]|section|article|header|footer)$/;
265
- function push(sink, text) {
266
- if (sink.remaining <= 0 || text.length === 0)
267
- return;
268
- const kept = text.slice(0, sink.remaining);
269
- sink.parts.push(kept);
270
- sink.remaining -= kept.length;
271
- }
272
- function collectText(node, depth, sink, probe, includeHidden, textHidden = false) {
273
- if (depth > 32 || sink.remaining <= 0)
274
- return;
275
- if (node.nodeType === 3) {
276
- if (!textHidden)
277
- push(sink, node.textContent ?? "");
278
- return;
279
- }
280
- if (node.nodeType !== 1)
281
- return;
282
- const element = node;
283
- const tag = tagOf(element);
284
- if (SKIPPED_CONTENT.has(tag) || hasSensitiveMarker2(element))
285
- return;
286
- if (!includeHidden && isHiddenForName(element))
287
- return;
288
- let hidden = false;
289
- if (depth > 0 && !includeHidden) {
290
- const visible = probe?.isVisible?.(element);
291
- if (visible === false)
292
- hidden = true;
293
- else if (visible === undefined) {
294
- const hiding = cssHiding(element);
295
- if (hiding === "subtree")
296
- return;
297
- hidden = hiding === "self";
298
- }
299
- }
300
- const label = element.getAttribute("aria-label")?.trim();
301
- if (label && depth > 0 && !hidden) {
302
- push(sink, ` ${label} `);
303
- return;
304
- }
305
- if (tag === "img" || tag === "input" && element.getAttribute("type") === "image") {
306
- if (!hidden)
307
- push(sink, ` ${element.getAttribute("alt") ?? ""} `);
308
- return;
309
- }
310
- if (tag === "input" || tag === "textarea" || tag === "select")
311
- return;
312
- if (depth > 0 && isEditingHost(element))
313
- return;
314
- const block = depth > 0 && BLOCK_TAGS.test(tag);
315
- if (block)
316
- push(sink, " ");
317
- for (const child of renderedChildren(element))
318
- collectText(child, depth + 1, sink, probe, includeHidden, hidden);
319
- if (block)
320
- push(sink, " ");
321
- }
322
- function isTypedContent2(element) {
323
- const tag = tagOf(element);
324
- if (tag === "textarea" || isEditingHost(element))
325
- return true;
326
- for (let current = containerOf(element);current; current = containerOf(current)) {
327
- if (tagOf(current) === "textarea" || isEditingHost(current))
328
- return true;
329
- }
330
- return false;
331
- }
332
- function isInsideFieldValue(element) {
333
- for (let current = containerOf(element);current; current = containerOf(current)) {
334
- const tag = tagOf(current);
335
- if (tag === "textarea" || tag === "select" || isEditingHost(current))
336
- return true;
337
- }
338
- return false;
339
- }
340
- function referencedText(label, probe, includeHidden = false) {
341
- const tag = tagOf(label);
342
- const isFieldValue = tag === "textarea" || tag === "select" || isEditingHost(label) || isInsideFieldValue(label);
343
- if (isFieldValue || isMarkedSensitive(label))
344
- return "";
345
- const ownLabel = collapse(label.getAttribute("aria-label") ?? "");
346
- return ownLabel || contentText(label, probe, MAX_NAME_LENGTH3, includeHidden);
347
- }
348
- function contentText(node, probe, max = MAX_NAME_LENGTH3, includeHidden = false) {
349
- if (node.nodeType === 1 && isMarkedSensitive(node))
350
- return "";
351
- const sink = { parts: [], remaining: max * 2 + 64 };
352
- collectText(node, 0, sink, probe, includeHidden);
353
- return collapse(sink.parts.join(""), max);
354
- }
355
- function collapse(text, max = MAX_NAME_LENGTH3) {
356
- return text.replace(/\s+/g, " ").trim().slice(0, max);
357
- }
358
- function labelsOf(element, probe) {
359
- const parts = [];
360
- const id = element.getAttribute("id");
361
- if (id) {
362
- const root = element.getRootNode();
363
- for (const label of Array.from(root.querySelectorAll("label"))) {
364
- if (label.getAttribute("for") === id)
365
- parts.push(referencedText(label, probe, true));
366
- }
367
- }
368
- const wrapping = element.closest("label");
369
- if (wrapping && !wrapping.hasAttribute("for"))
370
- parts.push(referencedText(wrapping, probe, true));
371
- return collapse(parts.join(" "));
372
- }
373
- function firstChildText(element, tag, probe) {
374
- const child = Array.from(element.children).find((candidate) => tagOf(candidate) === tag);
375
- return child ? referencedText(child, probe) : "";
376
- }
377
- function accessibleName2(element, probe) {
378
- return computeName(element, probe, true);
379
- }
380
- function labelName2(element, probe) {
381
- return computeName(element, probe, false);
382
- }
383
- function svgTitle(svg, probe) {
384
- const title = Array.from(svg.children).find((child) => tagOf(child) === "title");
385
- if (!title || isMarkedSensitive(title) || isInsideFieldValue(title))
386
- return "";
387
- return collapse(Array.from(title.childNodes).map((child) => contentText(child, probe)).join(" "));
388
- }
389
- function computeName(element, probe, fromContent) {
390
- const labelledBy = element.getAttribute("aria-labelledby");
391
- if (labelledBy) {
392
- const text = labelledBy.split(/\s+/).filter(Boolean).map((id) => byId(element, id)).filter((label) => label !== null).map((label) => referencedText(label, probe, true)).join(" ");
393
- if (collapse(text))
394
- return collapse(text);
395
- }
396
- const ariaLabel = element.getAttribute("aria-label");
397
- if (ariaLabel && collapse(ariaLabel))
398
- return collapse(ariaLabel);
399
- const tag = tagOf(element);
400
- if (LABELABLE.has(tag)) {
401
- const labels = labelsOf(element, probe);
402
- if (labels)
403
- return labels;
404
- }
405
- if (tag === "input") {
406
- const type = (element.getAttribute("type") ?? "text").toLowerCase();
407
- if (type === "button" || type === "submit" || type === "reset") {
408
- const value = element.getAttribute("value");
409
- if (value !== null)
410
- return collapse(value);
411
- return type === "submit" ? "Submit" : type === "reset" ? "Reset" : "";
412
- }
413
- if (type === "image")
414
- return collapse(element.getAttribute("alt") ?? "");
415
- }
416
- if (tag === "img" || tag === "area") {
417
- const alt = element.getAttribute("alt");
418
- if (alt)
419
- return collapse(alt);
420
- }
421
- if (tag === "svg") {
422
- const title = svgTitle(element, probe);
423
- if (title)
424
- return title;
425
- }
426
- if (tag === "fieldset") {
427
- const legend = firstChildText(element, "legend", probe);
428
- if (legend)
429
- return legend;
430
- }
431
- if (tag === "table") {
432
- const caption = firstChildText(element, "caption", probe);
433
- if (caption)
434
- return caption;
435
- }
436
- if (tag === "option") {
437
- const label = collapse(element.getAttribute("label") ?? "");
438
- if (label)
439
- return label;
440
- }
441
- if (tag === "figure") {
442
- const caption = firstChildText(element, "figcaption", probe);
443
- if (caption)
444
- return caption;
445
- }
446
- if (fromContent && NAME_FROM_CONTENT.has(roleOf2(element))) {
447
- const text = contentText(element, probe);
448
- if (text)
449
- return text;
450
- }
451
- const title = element.getAttribute("title");
452
- if (title && collapse(title))
453
- return collapse(title);
454
- const placeholder = element.getAttribute("placeholder");
455
- if (placeholder && collapse(placeholder))
456
- return collapse(placeholder);
457
- return "";
458
- }
459
- function visibleText2(element, probe) {
460
- const tag = tagOf(element);
461
- if (tag === "input") {
462
- const type = (element.getAttribute("type") ?? "text").toLowerCase();
463
- return type === "button" || type === "submit" || type === "reset" ? accessibleName2(element, probe) : "";
464
- }
465
- return contentText(element, probe, MAX_VISIBLE_TEXT2);
466
- }
467
- function matchesRoleAndName2(element, role, name, probe) {
468
- return roleOf2(element) === role.trim().toLowerCase() && normaliseText2(accessibleName2(element, probe)) === normaliseText2(name);
469
- }
470
-
471
- // src/target/dom.ts
472
- function viewOf(element) {
473
- return element.ownerDocument.defaultView;
474
- }
475
- function parentAcrossShadow2(element) {
476
- const slot = assignedSlotOf(element);
477
- if (slot)
478
- return slot;
479
- if (element.parentElement)
480
- return element.parentElement;
481
- const root = element.getRootNode();
482
- return root && "host" in root ? root.host : null;
483
- }
484
- function isElementVisible2(element, probe) {
485
- const override = probe?.isVisible?.(element);
486
- if (override !== undefined)
487
- return override;
488
- if (!element.isConnected)
489
- return false;
490
- const view = viewOf(element);
491
- let current = element;
492
- while (current) {
493
- if (current.hasAttribute("hidden"))
494
- return false;
495
- if (current.localName === "input" && current.getAttribute("type")?.toLowerCase() === "hidden")
496
- return false;
497
- if (view && view.getComputedStyle(current).display === "none")
498
- return false;
499
- current = parentAcrossShadow2(current);
500
- }
501
- if (view) {
502
- const style = view.getComputedStyle(element);
503
- if (style.visibility === "hidden" || style.visibility === "collapse")
504
- return false;
505
- if (style.display === "contents")
506
- return true;
507
- }
508
- const check = element.checkVisibility;
509
- return typeof check === "function" ? check.call(element) : true;
510
- }
511
- function isElementEnabled2(element) {
512
- for (let current = element;current; current = containerOf(current)) {
513
- if (current.getAttribute("aria-disabled") === "true" || current.hasAttribute("inert"))
514
- return false;
515
- }
516
- if (!FORM_CONTROLS.has(element.localName)) {
517
- const control = element.parentElement?.closest("button, select, option, optgroup, textarea");
518
- return control ? isElementEnabled2(control) : true;
519
- }
520
- if (element.hasAttribute("disabled"))
521
- return false;
522
- const fieldset = element.parentElement?.closest("fieldset[disabled]");
523
- if (fieldset) {
524
- const legend = Array.from(fieldset.children).find((child) => child.localName === "legend");
525
- if (!legend?.contains(element))
526
- return false;
527
- }
528
- try {
529
- return !element.matches(":disabled");
530
- } catch {
531
- return true;
532
- }
533
- }
534
- var FORM_CONTROLS = new Set(["button", "input", "select", "textarea", "optgroup", "option", "fieldset"]);
535
- function elementRect2(element, probe, offset) {
536
- const given = probe?.rectOf?.(element);
537
- const box = given ?? element.getBoundingClientRect();
538
- return {
539
- x: Math.round(box.x + (offset?.x ?? 0)),
540
- y: Math.round(box.y + (offset?.y ?? 0)),
541
- width: Math.round(box.width),
542
- height: Math.round(box.height)
543
- };
544
- }
545
- function elementsUnder2(root) {
546
- const all = Array.from(root.querySelectorAll("*"));
547
- return root.nodeType === 1 ? [root, ...all] : all;
548
- }
549
- 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;
550
- var SECRET_AUTOCOMPLETE = /password|one-time-code|^cc-/i;
551
- function isSecretFieldName2(name) {
552
- return SECRET_FIELD.test(name);
553
- }
554
- function isSensitiveElement2(element) {
555
- if (isMarkedSensitive(element))
556
- return true;
557
- if (isSensitiveField(element))
558
- return true;
559
- for (let current = containerOf(element);current; current = containerOf(current)) {
560
- if (isSensitiveField(current))
561
- return true;
562
- }
563
- return false;
564
- }
565
- function isSensitiveField(element) {
566
- const tag = element.localName;
567
- const editable = element.getAttribute("contenteditable");
568
- const isEditingHost = editable !== null && editable.trim().toLowerCase() !== "false";
569
- if (tag !== "input" && tag !== "textarea" && tag !== "select" && !isEditingHost)
570
- return false;
571
- if (element.getAttribute("type")?.toLowerCase() === "password")
572
- return true;
573
- const tokens = (element.getAttribute("autocomplete") ?? "").trim().split(/\s+/).filter(Boolean);
574
- if (tokens.some((token) => SECRET_AUTOCOMPLETE.test(token)))
575
- return true;
576
- return fieldHints(element).some((hint) => hint.length > 0 && isSecretFieldName2(hint.replace(/[-_]/g, " ")));
577
- }
578
- function fieldHints(element) {
579
- const raw = (value) => (value ?? "").slice(0, 512);
580
- const hints = [
581
- accessibleName2(element),
582
- raw(element.getAttribute("aria-label")),
583
- raw(element.getAttribute("placeholder")),
584
- raw(element.getAttribute("title")),
585
- raw(element.getAttribute("name")),
586
- raw(element.getAttribute("id"))
587
- ];
588
- const root = element.getRootNode();
589
- const byId = (id) => typeof root.getElementById === "function" ? root.getElementById(id) : null;
590
- for (const id of (element.getAttribute("aria-labelledby") ?? "").split(/\s+/).filter(Boolean)) {
591
- const target = byId(id);
592
- if (target)
593
- hints.push(raw(target.getAttribute("aria-label")), raw(target.textContent));
594
- }
595
- const id = element.getAttribute("id");
596
- const labels = Array.from(root.querySelectorAll("label")).filter((label) => id !== null && label.getAttribute("for") === id || !label.hasAttribute("for") && label.contains(element));
597
- for (const label of labels)
598
- hints.push(raw(label.getAttribute("aria-label")), raw(label.textContent));
599
- return hints;
600
- }
601
-
602
37
  // src/target/methods.ts
603
38
  var DEFAULT_FUZZY_THRESHOLD2 = 0.8;
604
39
  var FUZZY_MARGIN2 = 0.05;
@@ -977,6 +412,37 @@ function resolveWebTarget2(root, target, options = {}) {
977
412
  return failure("ELEMENT_NOT_INTERACTABLE", attempts, listed(blocked), blocked.elements.length);
978
413
  return failure("ELEMENT_NOT_FOUND", attempts);
979
414
  }
415
+ function resolveAllWebTargets2(root, target, options = {}) {
416
+ const state = options.state ?? "visible";
417
+ const entered = enterFrames2(root, target.frame, options);
418
+ if (!("root" in entered)) {
419
+ return failure("ELEMENT_NOT_FOUND", target.methods.map((method, index) => ({ index, method: method.kind, outcome: "notTried", matches: 0 })), [], 0, entered);
420
+ }
421
+ const attempts = [];
422
+ let found;
423
+ for (const [index, method] of target.methods.entries()) {
424
+ if (found || method.enabled === false) {
425
+ attempts.push({ index, method: method.kind, outcome: found ? "notTried" : "disabled", matches: 0 });
426
+ continue;
427
+ }
428
+ const keep = (element) => inState(element, state, entered, options);
429
+ const match = matchMethod2(method, { root: entered.root, probe: options, keep });
430
+ if (match.kind === "invalid" || match.kind === "unsupported") {
431
+ attempts.push({ index, method: method.kind, outcome: match.kind, matches: 0 });
432
+ continue;
433
+ }
434
+ const elements = match.kind === "list" ? match.elements.filter(keep) : [...match.scored].sort((a, b) => b.score - a.score).filter((item) => keep(item.element)).map((item) => item.element);
435
+ attempts.push({
436
+ index,
437
+ method: method.kind,
438
+ outcome: elements.length > 0 ? "found" : "none",
439
+ matches: elements.length
440
+ });
441
+ if (elements.length > 0)
442
+ found = { status: "found", elements, method: method.kind, methodIndex: index, attempts };
443
+ }
444
+ return found ?? failure("ELEMENT_NOT_FOUND", attempts);
445
+ }
980
446
 
981
447
  // src/target/snapshot.ts
982
448
  var UI_TREE_SNAPSHOT_VERSION2 = 1;
@@ -1025,13 +491,13 @@ var RESET_SEGMENT = /reset|recover|verify|verification|magic|confirm|activate|in
1025
491
  var TAG_NAME = /^[a-z][a-z0-9-]{0,63}$/;
1026
492
  var EMPTY_FRAME_DOCUMENT = "<!doctype html><html><head></head><body></body></html>";
1027
493
  var ATTRIBUTE_NAME2 = /^[a-z][a-z0-9_:.-]{0,127}$/;
1028
- function isEditingHost2(element) {
494
+ function isEditingHost(element) {
1029
495
  const value = element.getAttribute("contenteditable");
1030
496
  return value !== null && value.trim().toLowerCase() !== "false";
1031
497
  }
1032
498
  function hasFieldValueAncestor(element) {
1033
499
  for (let current = containerOf(element);current; current = containerOf(current)) {
1034
- if (current.localName === "textarea" || isEditingHost2(current))
500
+ if (current.localName === "textarea" || isEditingHost(current))
1035
501
  return true;
1036
502
  }
1037
503
  return false;
@@ -1215,7 +681,7 @@ function walkElement(element, state, depth, textAllowed, parentMarked) {
1215
681
  node.h = 1;
1216
682
  }
1217
683
  const sensitive = isSensitiveElement2(element);
1218
- const childText = textAllowed && !inFieldValue && !sensitive && !VALUE_CONTENT.has(tag) && !isEditingHost2(element);
684
+ const childText = textAllowed && !inFieldValue && !sensitive && !VALUE_CONTENT.has(tag) && !isEditingHost(element);
1219
685
  const childMarked = marked || !childText;
1220
686
  if (tag === "svg") {
1221
687
  const title = Array.from(element.children).find((child) => child.localName === "title");
@@ -1346,4 +812,4 @@ function hydrateTreeSnapshot2(document, snapshot) {
1346
812
  };
1347
813
  }
1348
814
 
1349
- export { WEB_TARGET_ERROR_CODES2, MAX_CANDIDATES2, MAX_CANDIDATE_NAME2, SENSITIVE_MARKERS2, hasSensitiveMarker2, MAX_COMPARED_TEXT2, normaliseText2, sameText2, containsText2, editDistance2, textSimilarity2, clip2, MAX_NAME_LENGTH3, MAX_VISIBLE_TEXT2, roleOf2, isTypedContent2, accessibleName2, labelName2, visibleText2, matchesRoleAndName2, parentAcrossShadow2, isElementVisible2, isElementEnabled2, elementRect2, elementsUnder2, isSecretFieldName2, isSensitiveElement2, DEFAULT_FUZZY_THRESHOLD2, FUZZY_MARGIN2, ANCHOR_MARGIN_PX2, MAX_XPATH_RESULTS2, INTERACTIVE_ROLES2, relationDistance2, matchMethod2, enterFrames2, describeCandidate2, resolveWebTarget2, UI_TREE_SNAPSHOT_VERSION2, DEFAULT_SNAPSHOT_MAX_NODES2, MAX_SNAPSHOT_DEPTH2, MAX_SNAPSHOT_TEXT2, snapshotUrl2, serializeTreeSnapshot2, hydrateTreeSnapshot2 };
815
+ export { WEB_TARGET_ERROR_CODES2, MAX_CANDIDATES2, MAX_CANDIDATE_NAME2, DEFAULT_FUZZY_THRESHOLD2, FUZZY_MARGIN2, ANCHOR_MARGIN_PX2, MAX_XPATH_RESULTS2, INTERACTIVE_ROLES2, relationDistance2, matchMethod2, enterFrames2, describeCandidate2, resolveWebTarget2, resolveAllWebTargets2, UI_TREE_SNAPSHOT_VERSION2, DEFAULT_SNAPSHOT_MAX_NODES2, MAX_SNAPSHOT_DEPTH2, MAX_SNAPSHOT_TEXT2, snapshotUrl2, serializeTreeSnapshot2, hydrateTreeSnapshot2 };