spana-test 0.8.0 → 0.9.0

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 (55) hide show
  1. package/dist/agent/index.d.ts +2 -2
  2. package/dist/agent/index.js +5 -5
  3. package/dist/{app-CgbLADmF.d.ts → app-DSh1ejLh.d.ts} +97 -22
  4. package/dist/{chunk-NS2HLJO4.js → chunk-2KRVN4WN.js} +3 -3
  5. package/dist/{chunk-AJCSETN6.js → chunk-3UVSUVHW.js} +619 -174
  6. package/dist/chunk-3UVSUVHW.js.map +1 -0
  7. package/dist/{chunk-3FXDOTFI.js → chunk-ALPQES3J.js} +187 -36
  8. package/dist/chunk-ALPQES3J.js.map +1 -0
  9. package/dist/{chunk-PMXSU5MS.js → chunk-FP6PVHHR.js} +2 -2
  10. package/dist/{chunk-WKVU24B6.js → chunk-IGTK5MHB.js} +4 -4
  11. package/dist/{chunk-2T4K7BJ3.js → chunk-JZZ2W2XH.js} +3 -2
  12. package/dist/chunk-JZZ2W2XH.js.map +1 -0
  13. package/dist/{chunk-SNL4X67N.js → chunk-UEWZ2EXL.js} +352 -111
  14. package/dist/chunk-UEWZ2EXL.js.map +1 -0
  15. package/dist/{chunk-QP4MDUBY.js → chunk-VP6V4XEJ.js} +2 -2
  16. package/dist/{chunk-RKYKRGHB.js → chunk-Z6K4QQAR.js} +128 -6
  17. package/dist/chunk-Z6K4QQAR.js.map +1 -0
  18. package/dist/cli.js +9 -9
  19. package/dist/config-loader-F5YAY7RP.js +9 -0
  20. package/dist/{daemon-manager-DDYQITPD.js → daemon-manager-2EQDVUVM.js} +8 -2
  21. package/dist/{doctor-command-HEQQOYUR.js → doctor-command-YTCQ2SC7.js} +4 -4
  22. package/dist/{flow-Md5xLwbX.d.ts → flow-CSMwD9Fh.d.ts} +1 -1
  23. package/dist/gherkin/steps.d.ts +2 -2
  24. package/dist/index.d.ts +38 -8
  25. package/dist/index.js +25 -9
  26. package/dist/index.js.map +1 -1
  27. package/dist/{installer-IYGMG7LS.js → installer-5UHTYQTB.js} +3 -3
  28. package/dist/{server-JPNH33MX.js → server-4YLBAZEM.js} +6 -6
  29. package/dist/{server-4PEREPHY.js → server-IS4K5FCT.js} +2 -2
  30. package/dist/{session-D9e30RVS.d.ts → session-CgvT-Oso.d.ts} +3 -1
  31. package/dist/{session-V4PYJXNB.js → session-K7FCRKOC.js} +6 -6
  32. package/dist/{studio-command-JOIFCOHC.js → studio-command-RFPV2DS7.js} +2 -2
  33. package/dist/{test-command-JCO2HPYI.js → test-command-UEJG5AI6.js} +11 -9
  34. package/dist/test-command-UEJG5AI6.js.map +1 -0
  35. package/native/win32-x64/spana_native.dll +0 -0
  36. package/package.json +1 -1
  37. package/dist/chunk-2T4K7BJ3.js.map +0 -1
  38. package/dist/chunk-3FXDOTFI.js.map +0 -1
  39. package/dist/chunk-AJCSETN6.js.map +0 -1
  40. package/dist/chunk-RKYKRGHB.js.map +0 -1
  41. package/dist/chunk-SNL4X67N.js.map +0 -1
  42. package/dist/config-loader-5FU45FXK.js +0 -9
  43. package/dist/test-command-JCO2HPYI.js.map +0 -1
  44. /package/dist/{chunk-NS2HLJO4.js.map → chunk-2KRVN4WN.js.map} +0 -0
  45. /package/dist/{chunk-PMXSU5MS.js.map → chunk-FP6PVHHR.js.map} +0 -0
  46. /package/dist/{chunk-WKVU24B6.js.map → chunk-IGTK5MHB.js.map} +0 -0
  47. /package/dist/{chunk-QP4MDUBY.js.map → chunk-VP6V4XEJ.js.map} +0 -0
  48. /package/dist/{config-loader-5FU45FXK.js.map → config-loader-F5YAY7RP.js.map} +0 -0
  49. /package/dist/{daemon-manager-DDYQITPD.js.map → daemon-manager-2EQDVUVM.js.map} +0 -0
  50. /package/dist/{doctor-command-HEQQOYUR.js.map → doctor-command-YTCQ2SC7.js.map} +0 -0
  51. /package/dist/{installer-IYGMG7LS.js.map → installer-5UHTYQTB.js.map} +0 -0
  52. /package/dist/{server-JPNH33MX.js.map → server-4YLBAZEM.js.map} +0 -0
  53. /package/dist/{server-4PEREPHY.js.map → server-IS4K5FCT.js.map} +0 -0
  54. /package/dist/{session-V4PYJXNB.js.map → session-K7FCRKOC.js.map} +0 -0
  55. /package/dist/{studio-command-JOIFCOHC.js.map → studio-command-RFPV2DS7.js.map} +0 -0
@@ -97,8 +97,10 @@ function domMatchToElement(match, screenBounds) {
97
97
  return {
98
98
  ...match.id !== void 0 ? { id: match.id } : {},
99
99
  ...match.text !== void 0 ? { text: match.text } : {},
100
+ ...match.textContent !== void 0 ? { textContent: match.textContent } : {},
100
101
  ...match.value !== void 0 ? { value: match.value } : {},
101
102
  ...match.accessibilityLabel !== void 0 ? { accessibilityLabel: match.accessibilityLabel } : {},
103
+ ...match.accessibleDescription !== void 0 ? { accessibleDescription: match.accessibleDescription } : {},
102
104
  ...match.tag !== void 0 ? { elementType: match.tag } : {},
103
105
  bounds: screenBounds ?? {
104
106
  x: Math.round(match.rect.x),
@@ -195,6 +197,76 @@ var SHARED_DOM_TRAVERSAL_HELPERS = `
195
197
  }
196
198
  return "";
197
199
  }
200
+ function visibleTextOf(node, allowHiddenRoot, skipControl) {
201
+ if (!node) return "";
202
+ if (node.nodeType === 3) return node.nodeValue || "";
203
+ if (node.nodeType !== 1 && node.nodeType !== 11) return "";
204
+ if (node.nodeType === 1) {
205
+ if (skipControl && node === skipControl) return "";
206
+ var t = node.tagName ? node.tagName.toUpperCase() : "";
207
+ if (t === "SCRIPT" || t === "STYLE" || t === "NOSCRIPT" || t === "TEMPLATE") return "";
208
+ if (skipControl && (t === "SELECT" || t === "TEXTAREA" || t === "INPUT")) return "";
209
+ if (!allowHiddenRoot) {
210
+ if (node.getAttribute && node.getAttribute("aria-hidden") === "true") return "";
211
+ var win = (node.ownerDocument && node.ownerDocument.defaultView) || window;
212
+ if (win && win.getComputedStyle) {
213
+ var st = win.getComputedStyle(node);
214
+ if (st && (st.display === "none" || st.visibility === "hidden" || st.visibility === "collapse")) {
215
+ return "";
216
+ }
217
+ }
218
+ }
219
+ }
220
+ var out = [];
221
+ if (node.shadowRoot) {
222
+ var stxt = visibleTextOf(node.shadowRoot, false, skipControl);
223
+ if (stxt) out.push(stxt);
224
+ }
225
+ var kids = node.childNodes || [];
226
+ for (var i = 0; i < kids.length; i++) {
227
+ var k = visibleTextOf(kids[i], false, skipControl);
228
+ if (k) out.push(k);
229
+ }
230
+ return out.join(" ").replace(/\\s+/g, " ").trim();
231
+ }
232
+ function isAriaHidden(el) {
233
+ if (!el) return true;
234
+ var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;
235
+ var cur = el;
236
+ var guard = 0;
237
+ while (cur && guard++ < 32) {
238
+ if (cur.getAttribute) {
239
+ if (cur.getAttribute("aria-hidden") === "true") return true;
240
+ if (cur.hasAttribute && cur.hasAttribute("inert")) return true;
241
+ }
242
+ if (cur.nodeType === 1 && win && win.getComputedStyle) {
243
+ var cs = win.getComputedStyle(cur);
244
+ if (cs && cs.display === "none") return true;
245
+ }
246
+ var root = typeof cur.getRootNode === "function" ? cur.getRootNode() : null;
247
+ cur = cur.parentElement || (root && root.host) || null;
248
+ }
249
+ if (typeof el.checkVisibility === "function") {
250
+ try {
251
+ if (!el.checkVisibility({ visibilityProperty: true })) return true;
252
+ } catch (e) {}
253
+ } else if (win && win.getComputedStyle) {
254
+ var selfCs = win.getComputedStyle(el);
255
+ if (selfCs && (selfCs.visibility === "hidden" || selfCs.visibility === "collapse")) return true;
256
+ }
257
+ return false;
258
+ }
259
+ function headingLevelOf(el) {
260
+ if (!el) return null;
261
+ var explicit = el.getAttribute && el.getAttribute("aria-level");
262
+ if (explicit) {
263
+ var parsed = parseInt(explicit, 10);
264
+ if (!isNaN(parsed)) return parsed;
265
+ }
266
+ var tag = el.tagName ? el.tagName.toUpperCase() : "";
267
+ var m = /^H([1-6])$/.exec(tag);
268
+ return m ? parseInt(m[1], 10) : null;
269
+ }
198
270
  function getAccessibleName(el) {
199
271
  if (!el) return "";
200
272
  var doc = el.ownerDocument || document;
@@ -205,7 +277,7 @@ var SHARED_DOM_TRAVERSAL_HELPERS = `
205
277
  for (var i = 0; i < ids.length; i++) {
206
278
  var ref = doc.getElementById ? doc.getElementById(ids[i]) : null;
207
279
  if (ref) {
208
- var rt = (ref.innerText || ref.textContent || "").trim();
280
+ var rt = visibleTextOf(ref, true, null);
209
281
  if (rt) parts.push(rt);
210
282
  }
211
283
  }
@@ -220,16 +292,16 @@ var SHARED_DOM_TRAVERSAL_HELPERS = `
220
292
  var escId = typeof CSS !== "undefined" && CSS.escape ? CSS.escape(el.id) : el.id;
221
293
  var forLbl = doc.querySelector('label[for="' + escId + '"]');
222
294
  if (forLbl) {
223
- var ft = (forLbl.innerText || forLbl.textContent || "").trim();
224
- if (ft) return ft.replace(/\\s+/g, " ");
295
+ var ft = visibleTextOf(forLbl, false, el);
296
+ if (ft) return ft;
225
297
  }
226
298
  } catch (e) {}
227
299
  }
228
300
  if (el.closest) {
229
301
  var wrapLbl = el.closest("label");
230
302
  if (wrapLbl) {
231
- var wt = (wrapLbl.innerText || wrapLbl.textContent || "").trim();
232
- if (wt) return wt.replace(/\\s+/g, " ");
303
+ var wt = visibleTextOf(wrapLbl, false, el);
304
+ if (wt) return wt;
233
305
  }
234
306
  }
235
307
  var itype = tag === "INPUT" ? (el.getAttribute("type") || "text").toLowerCase() : "";
@@ -243,11 +315,36 @@ var SHARED_DOM_TRAVERSAL_HELPERS = `
243
315
  var alt = el.getAttribute && el.getAttribute("alt");
244
316
  if (alt && alt.trim()) return alt.trim();
245
317
  }
246
- var title = el.getAttribute && el.getAttribute("title");
247
- var txt = (el.innerText || el.textContent || "").replace(/\\s+/g, " ").trim();
318
+ var txt = visibleTextOf(el, false, null);
248
319
  if (txt) return txt;
320
+ var title = el.getAttribute && el.getAttribute("title");
249
321
  return title ? title.trim() : "";
250
322
  }
323
+ function getAccessibleDescription(el) {
324
+ if (!el) return "";
325
+ var doc = el.ownerDocument || document;
326
+ var describedBy = el.getAttribute && el.getAttribute("aria-describedby");
327
+ if (describedBy) {
328
+ var parts = [];
329
+ var ids = describedBy.trim().split(/\\s+/);
330
+ for (var i = 0; i < ids.length; i++) {
331
+ var ref = doc.getElementById ? doc.getElementById(ids[i]) : null;
332
+ if (ref) {
333
+ var rt = visibleTextOf(ref, true, null);
334
+ if (rt) parts.push(rt);
335
+ }
336
+ }
337
+ if (parts.length > 0) return parts.join(" ").replace(/\\s+/g, " ").trim();
338
+ }
339
+ var ariaDesc = el.getAttribute && el.getAttribute("aria-description");
340
+ if (ariaDesc && ariaDesc.trim()) return ariaDesc.trim();
341
+ var title = el.getAttribute && el.getAttribute("title");
342
+ if (title && title.trim()) {
343
+ var accName = getAccessibleName(el);
344
+ if (accName && accName !== title.trim()) return title.trim();
345
+ }
346
+ return "";
347
+ }
251
348
  function collectRoots(root, offsetX, offsetY, inShadow, inIframe, out) {
252
349
  if (!root) return;
253
350
  out.push({ root: root, offsetX: offsetX, offsetY: offsetY, inShadow: inShadow, inIframe: inIframe });
@@ -313,12 +410,14 @@ var SHARED_DOM_TRAVERSAL_HELPERS = `
313
410
  }
314
411
  }
315
412
  }
316
- function findRoleInRoot(root, roleLower, nameSpec, exact, ctx, pushHit) {
413
+ function findRoleInRoot(root, roleLower, nameSpec, exact, ctx, pushHit, includeHidden, level) {
317
414
  if (!root || !root.querySelectorAll) return;
318
415
  var candidates = root.querySelectorAll("*");
319
416
  for (var i = 0; i < candidates.length; i++) {
320
417
  var el = candidates[i];
321
418
  if (getImplicitRole(el) !== roleLower) continue;
419
+ if (!includeHidden && isAriaHidden(el)) continue;
420
+ if (level !== undefined && level !== null && headingLevelOf(el) !== Number(level)) continue;
322
421
  if (nameSpec !== undefined && nameSpec !== null) {
323
422
  var accName = getAccessibleName(el);
324
423
  if (!matchSpec(accName, nameSpec, Boolean(exact))) continue;
@@ -341,6 +440,16 @@ var SHARED_DOM_TRAVERSAL_HELPERS = `
341
440
  return !matchSpec(txt, sel.hasNotText, false);
342
441
  });
343
442
  }
443
+ if (sel.has !== undefined) {
444
+ filtered = filtered.filter(function(h) {
445
+ return findInScope(sel.has, h.el, h.offsetX, h.offsetY, h.inShadow, h.inIframe).length > 0;
446
+ });
447
+ }
448
+ if (sel.hasNot !== undefined) {
449
+ filtered = filtered.filter(function(h) {
450
+ return findInScope(sel.hasNot, h.el, h.offsetX, h.offsetY, h.inShadow, h.inIframe).length === 0;
451
+ });
452
+ }
344
453
  if (sel.first) return filtered.length > 0 ? [filtered[0]] : [];
345
454
  if (sel.last) return filtered.length > 0 ? [filtered[filtered.length - 1]] : [];
346
455
  if (typeof sel.nth === "number") {
@@ -391,6 +500,8 @@ var SHARED_DOM_TRAVERSAL_HELPERS = `
391
500
  delete childSel.within;
392
501
  delete childSel.hasText;
393
502
  delete childSel.hasNotText;
503
+ delete childSel.has;
504
+ delete childSel.hasNot;
394
505
  delete childSel.first;
395
506
  delete childSel.last;
396
507
  delete childSel.nth;
@@ -407,12 +518,22 @@ var SHARED_DOM_TRAVERSAL_HELPERS = `
407
518
  }
408
519
  return applyModifiersAndSlice(combined, sel);
409
520
  }
521
+ // Logical OR composition (anyOf): union deduplicated hits across branches
522
+ if (typeof sel === "object" && sel !== null && Array.isArray(sel.anyOf)) {
523
+ for (var bi = 0; bi < sel.anyOf.length; bi++) {
524
+ var branchHits = findInScope(sel.anyOf[bi], scopeRoot, baseOffsetX, baseOffsetY, baseInShadow, baseInIframe);
525
+ for (var bh = 0; bh < branchHits.length; bh++) {
526
+ pushHit(branchHits[bh].el, branchHits[bh]);
527
+ }
528
+ }
529
+ return applyModifiersAndSlice(hits, sel);
530
+ }
410
531
 
411
532
  var esc = function(v) {
412
533
  return typeof CSS !== "undefined" && CSS.escape ? CSS.escape(v) : String(v).replace(/\\\\/g, "\\\\\\\\").replace(/"/g, '\\\\"');
413
534
  };
414
535
  var mainCtx = { root: scopeRoot, offsetX: baseOffsetX, offsetY: baseOffsetY, inShadow: baseInShadow, inIframe: baseInIframe };
415
- var hasModifiers = typeof sel === "object" && sel !== null && (sel.hasText !== undefined || sel.hasNotText !== undefined || sel.first || sel.last || typeof sel.nth === "number");
536
+ var hasModifiers = typeof sel === "object" && sel !== null && (sel.hasText !== undefined || sel.hasNotText !== undefined || sel.has !== undefined || sel.hasNot !== undefined || sel.first || sel.last || typeof sel.nth === "number");
416
537
 
417
538
  // O(1)-ish Light-DOM fast path: avoids scanning thousands of nodes with querySelectorAll("*")
418
539
  // unless Shadow DOM / iframe piercing is needed or no Light-DOM match exists.
@@ -440,7 +561,7 @@ var SHARED_DOM_TRAVERSAL_HELPERS = `
440
561
  return hits;
441
562
  }
442
563
  } else if (typeof sel === "object" && sel !== null && "role" in sel) {
443
- findRoleInRoot(scopeRoot, String(sel.role).toLowerCase(), sel.name, sel.exact, mainCtx, pushHit);
564
+ findRoleInRoot(scopeRoot, String(sel.role).toLowerCase(), sel.name, sel.exact, mainCtx, pushHit, sel.includeHidden, sel.level);
444
565
  if (hits.length > 0) return hits;
445
566
  } else if (typeof sel === "string" || (typeof sel === "object" && sel !== null && "text" in sel)) {
446
567
  var fastNeedle = typeof sel === "string" ? sel : sel.text;
@@ -470,7 +591,7 @@ var SHARED_DOM_TRAVERSAL_HELPERS = `
470
591
  var foundLbl = root.querySelectorAll('[aria-label="' + lbl + '"]');
471
592
  for (var j = 0; j < foundLbl.length; j++) pushHit(foundLbl[j], ctx);
472
593
  } else if (typeof sel === "object" && sel !== null && "role" in sel) {
473
- findRoleInRoot(root, String(sel.role).toLowerCase(), sel.name, sel.exact, ctx, pushHit);
594
+ findRoleInRoot(root, String(sel.role).toLowerCase(), sel.name, sel.exact, ctx, pushHit, sel.includeHidden, sel.level);
474
595
  } else if (typeof sel === "string" || (typeof sel === "object" && sel !== null && "text" in sel)) {
475
596
  var needle = typeof sel === "string" ? sel : sel.text;
476
597
  var isExact = typeof sel === "object" && sel !== null && Boolean(sel.exact);
@@ -525,13 +646,22 @@ var SHARED_DOM_TRAVERSAL_HELPERS = `
525
646
  }
526
647
  return el;
527
648
  }
649
+ function labelControlOf(node) {
650
+ var cur = node;
651
+ var guard = 0;
652
+ while (cur && guard++ < 8) {
653
+ if (cur.tagName === "LABEL") return cur.control || null;
654
+ cur = cur.parentElement;
655
+ }
656
+ return null;
657
+ }
528
658
  function isSameOrDescendant(target, candidate) {
529
659
  if (!target || !candidate) return false;
530
660
  if (target === candidate) return true;
531
661
  try {
532
662
  if (typeof target.contains === "function" && target.contains(candidate)) return true;
533
- if (typeof candidate.contains === "function" && candidate.contains(target)) return true;
534
663
  } catch (e) {}
664
+ if (labelControlOf(candidate) === target) return true;
535
665
  var cur = candidate;
536
666
  var guard = 0;
537
667
  while (cur && guard++ < 24) {
@@ -545,6 +675,31 @@ var SHARED_DOM_TRAVERSAL_HELPERS = `
545
675
  }
546
676
  return false;
547
677
  }
678
+ function describeEl(el) {
679
+ if (!el) return "(unknown)";
680
+ var tag = el.tagName ? el.tagName.toLowerCase() : "element";
681
+ var idPart = el.id ? "#" + el.id : "";
682
+ var cls = typeof el.className === "string" ? el.className.trim().split(/\\s+/).filter(Boolean).slice(0, 3).join(".") : "";
683
+ var clsPart = cls ? "." + cls : "";
684
+ var txt = (el.innerText || el.textContent || "").replace(/\\s+/g, " ").trim();
685
+ if (txt.length > 40) txt = txt.slice(0, 37) + "...";
686
+ return "<" + tag + idPart + clsPart + (txt ? ">" + txt + "</" + tag + ">" : ">");
687
+ }
688
+ function getHitTestBlocker(hit) {
689
+ var el = hit.el;
690
+ var rect = el.getBoundingClientRect();
691
+ var vw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0;
692
+ var vh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0;
693
+ var cx = rect.left + hit.offsetX + rect.width / 2;
694
+ var cy = rect.top + hit.offsetY + rect.height / 2;
695
+ if (vw > 0 && vh > 0 && (cx < 0 || cy < 0 || cx > vw || cy > vh)) {
696
+ return "outside viewport";
697
+ }
698
+ var topEl = deepElementFromPoint(document, cx, cy);
699
+ if (!topEl) return null;
700
+ if (isSameOrDescendant(el, topEl)) return null;
701
+ return describeEl(topEl);
702
+ }
548
703
  function isHitTestClear(hit) {
549
704
  var el = hit.el;
550
705
  var rect = el.getBoundingClientRect();
@@ -575,6 +730,20 @@ var SHARED_DOM_TRAVERSAL_HELPERS = `
575
730
  }
576
731
  return false;
577
732
  }
733
+ function scrollToUnobscure(hit) {
734
+ var el = hit.el;
735
+ if (typeof el.scrollIntoView !== "function") return false;
736
+ var blocks = ["center", "end", "start", "nearest"];
737
+ for (var i = 0; i < blocks.length; i++) {
738
+ try {
739
+ el.scrollIntoView({ block: blocks[i], inline: "center", behavior: "instant" });
740
+ } catch (e) {
741
+ try { el.scrollIntoView(true); } catch (e2) {}
742
+ }
743
+ if (isHitTestClear(hit)) return true;
744
+ }
745
+ return false;
746
+ }
578
747
  function hasActiveAnimation(el) {
579
748
  var cur = el;
580
749
  var depth = 0;
@@ -612,16 +781,20 @@ var SHARED_DOM_TRAVERSAL_HELPERS = `
612
781
  ? String(el.value ?? "")
613
782
  : undefined;
614
783
  var text = (el.innerText || el.textContent || "").trim() || undefined;
784
+ var normTextContent = (el.textContent || "").replace(/\\s+/g, " ").trim() || undefined;
615
785
  var accName = getAccessibleName(el) || undefined;
786
+ var accDesc = getAccessibleDescription(el) || undefined;
616
787
  var role = getImplicitRole(el) || undefined;
617
788
  return {
618
789
  id: el.getAttribute("data-testid") || el.getAttribute("testID") || undefined,
619
790
  tag: tag,
620
791
  role: role,
621
792
  text: text,
793
+ textContent: normTextContent,
622
794
  value: val,
623
795
  accessibilityLabel: el.getAttribute("aria-label") || undefined,
624
796
  accessibleName: accName,
797
+ accessibleDescription: accDesc,
625
798
  rect: { x: rect.x + hit.offsetX, y: rect.y + hit.offsetY, width: rect.width, height: rect.height },
626
799
  scrollX: window.scrollX || window.pageXOffset || 0,
627
800
  scrollY: window.scrollY || window.pageYOffset || 0,
@@ -684,13 +857,21 @@ function buildDomTapScript(selector) {
684
857
  return true;
685
858
  })(${serialized})`;
686
859
  }
860
+ function defaultActionStableFrames() {
861
+ const envVal = process.env["SPANA_ACTION_STABLE_FRAMES"];
862
+ if (envVal !== void 0) {
863
+ const parsed = Number.parseInt(envVal, 10);
864
+ if (Number.isFinite(parsed) && parsed >= 0) return parsed;
865
+ }
866
+ return 2;
867
+ }
687
868
  function buildDomWaitForSelectorScript(selector, opts = {}) {
688
869
  const serialized = JSON.stringify(serializeSelectorForDom(selector));
689
870
  const timeoutMs = Math.max(10, Math.round(opts.timeoutMs ?? 5e3));
690
871
  const forAction = Boolean(opts.forAction);
691
872
  const failFastWhenIdle = Boolean(opts.failFastWhenIdle);
692
873
  const idleQuietMs = Math.max(50, Math.round(opts.idleQuietMs ?? 250));
693
- const stableFrames = opts.stableFrames !== void 0 ? Math.max(0, Math.round(opts.stableFrames)) : forAction ? -1 : 0;
874
+ const stableFrames = opts.stableFrames !== void 0 ? Math.max(0, Math.round(opts.stableFrames)) : forAction ? defaultActionStableFrames() : 0;
694
875
  const checkHitTest = opts.checkHitTest !== void 0 ? Boolean(opts.checkHitTest) : forAction;
695
876
  const waitForAppReady = opts.waitForAppReady !== void 0 ? Boolean(opts.waitForAppReady) : true;
696
877
  return `(function(sel, timeoutMs, forAction, failFastWhenIdle, idleQuietMs, reqStableFrames, checkHitTest, waitForAppReady) {
@@ -718,7 +899,12 @@ function buildDomWaitForSelectorScript(selector, opts = {}) {
718
899
  if (!forAction) return ready.map(function(r) { return r.match; });
719
900
  var target = ready[ready.length - 1];
720
901
  var didScroll = ensureInViewport(target.hit);
721
- if (checkHitTest && !isHitTestClear(target.hit)) return null;
902
+ if (checkHitTest && !isHitTestClear(target.hit)) {
903
+ if (scrollToUnobscure(target.hit)) {
904
+ didScroll = true;
905
+ }
906
+ if (!isHitTestClear(target.hit)) return null;
907
+ }
722
908
  var updated = toMatch(target.hit);
723
909
  if (!updated.visible || !updated.enabled) return null;
724
910
  return { hits: ready, target: target, match: updated, didScroll: didScroll };
@@ -937,7 +1123,8 @@ function buildDomWaitForMatchScript(selector, opts) {
937
1123
  const attributeName = JSON.stringify(opts.attributeName ?? null);
938
1124
  const patternSource = JSON.stringify(opts.patternSource ?? null);
939
1125
  const patternFlags = JSON.stringify(opts.patternFlags ?? "");
940
- return `(function(sel, timeoutMs, kind, expected, expectedCount, attributeName, patternSource, patternFlags) {
1126
+ const negate = Boolean(opts.negate);
1127
+ return `(function(sel, timeoutMs, kind, expected, expectedCount, attributeName, patternSource, patternFlags, negate) {
941
1128
  ${SHARED_DOM_TRAVERSAL_HELPERS}
942
1129
  var lastActual = undefined;
943
1130
  var regex = patternSource !== null ? new RegExp(patternSource, patternFlags) : null;
@@ -946,11 +1133,10 @@ function buildDomWaitForMatchScript(selector, opts) {
946
1133
  if (kind === "url") {
947
1134
  var href = String(window.location.href || "");
948
1135
  lastActual = href;
949
- if (regex) {
950
- if (regex.test(href)) return { matched: true, actual: href };
951
- } else if (expected !== null && (href === expected || href.indexOf(String(expected)) !== -1)) {
952
- return { matched: true, actual: href };
953
- }
1136
+ var urlOk = regex
1137
+ ? regex.test(href)
1138
+ : (expected !== null && (href === expected || href.indexOf(String(expected)) !== -1));
1139
+ if (negate ? !urlOk : urlOk) return { matched: true, actual: href };
954
1140
  return null;
955
1141
  }
956
1142
  var hits = findAcrossRoots(sel);
@@ -960,54 +1146,56 @@ function buildDomWaitForMatchScript(selector, opts) {
960
1146
  if (toMatch(hits[ci]).visible) visibleCount += 1;
961
1147
  }
962
1148
  lastActual = String(visibleCount);
963
- if (visibleCount === expectedCount) return { matched: true, actual: String(visibleCount) };
1149
+ var countOk = visibleCount === expectedCount;
1150
+ if (negate ? !countOk : countOk) return { matched: true, actual: String(visibleCount) };
964
1151
  return null;
965
1152
  }
1153
+ var anyVisible = false;
966
1154
  for (var i = hits.length - 1; i >= 0; i--) {
967
1155
  var m = toMatch(hits[i]);
968
1156
  if (!m.visible) continue;
1157
+ anyVisible = true;
1158
+ var matched = false;
1159
+ var actualVal = undefined;
969
1160
  if (kind === "focused") {
970
1161
  var isFoc = Boolean(m.focused);
971
- lastActual = isFoc ? "focused" : "not focused";
972
- if (isFoc) return { matched: true, actual: "focused" };
1162
+ actualVal = isFoc ? "focused" : "not focused";
1163
+ matched = isFoc;
973
1164
  } else if (kind === "accessibleName") {
974
1165
  var acc = m.accessibleName || "";
975
- lastActual = acc;
976
- if (regex ? regex.test(acc) : (expected === null ? acc.length > 0 : acc === expected)) {
977
- return { matched: true, actual: acc };
978
- }
1166
+ actualVal = acc;
1167
+ matched = regex ? regex.test(acc) : (expected === null ? acc.length > 0 : acc.trim() === String(expected).trim());
1168
+ } else if (kind === "accessibleDescription") {
1169
+ var accD = m.accessibleDescription || "";
1170
+ actualVal = accD;
1171
+ matched = regex ? regex.test(accD) : (expected === null ? accD.length > 0 : accD.trim() === String(expected).trim());
979
1172
  } else if (kind === "text") {
980
- lastActual = m.text;
981
- if (m.text === expected) return { matched: true, actual: m.text };
1173
+ var normTxt = m.textContent !== undefined ? m.textContent : (m.text || "");
1174
+ actualVal = normTxt;
1175
+ matched = normTxt === (expected !== null ? String(expected).replace(/\\s+/g, " ").trim() : expected);
982
1176
  } else if (kind === "containsText") {
983
- var actual = m.text || "";
984
- lastActual = m.text;
985
- if (expected !== null && actual.toLowerCase().indexOf(String(expected).toLowerCase()) !== -1) {
986
- return { matched: true, actual: m.text };
987
- }
1177
+ var actual = m.textContent !== undefined ? m.textContent : (m.text || "");
1178
+ actualVal = actual;
1179
+ matched = expected !== null && actual.toLowerCase().indexOf(String(expected).replace(/\\s+/g, " ").trim().toLowerCase()) !== -1;
988
1180
  } else if (kind === "matchesText") {
989
- var actualRe = m.text || "";
990
- lastActual = m.text;
991
- if (regex && regex.test(actualRe)) {
992
- return { matched: true, actual: m.text };
993
- }
1181
+ var actualRe = m.textContent !== undefined ? m.textContent : (m.text || "");
1182
+ actualVal = actualRe;
1183
+ matched = Boolean(regex && regex.test(actualRe));
994
1184
  } else if (kind === "value") {
995
1185
  var val = m.value !== undefined ? m.value : "";
996
- lastActual = val;
997
- if (val === expected) return { matched: true, actual: val };
1186
+ actualVal = val;
1187
+ matched = val === expected;
998
1188
  } else if (kind === "attribute" && attributeName !== null) {
999
1189
  var attrVal = m.attributes ? m.attributes[attributeName] : undefined;
1000
- lastActual = attrVal;
1001
- if (expected === null ? attrVal !== undefined : attrVal === expected) {
1002
- return { matched: true, actual: attrVal };
1003
- }
1190
+ actualVal = attrVal;
1191
+ matched = expected === null ? attrVal !== undefined : attrVal === expected;
1004
1192
  } else if (kind === "accessibilityLabel") {
1005
1193
  var lbl = m.accessibilityLabel;
1006
- lastActual = lbl;
1007
- if (expected === null ? (lbl !== undefined && lbl.length > 0) : lbl === expected) {
1008
- return { matched: true, actual: lbl };
1009
- }
1194
+ actualVal = lbl;
1195
+ matched = expected === null ? (lbl !== undefined && lbl.length > 0) : lbl === expected;
1010
1196
  }
1197
+ lastActual = actualVal;
1198
+ if (negate ? !matched : matched) return { matched: true, actual: actualVal };
1011
1199
  }
1012
1200
  return null;
1013
1201
  }
@@ -1081,7 +1269,7 @@ function buildDomWaitForMatchScript(selector, opts) {
1081
1269
  }
1082
1270
  }
1083
1271
  });
1084
- })(${serialized}, ${timeoutMs}, ${kind}, ${expected}, ${expectedCount}, ${attributeName}, ${patternSource}, ${patternFlags})`;
1272
+ })(${serialized}, ${timeoutMs}, ${kind}, ${expected}, ${expectedCount}, ${attributeName}, ${patternSource}, ${patternFlags}, ${negate})`;
1085
1273
  }
1086
1274
  function buildDomFillScript(selector, value, opts = {}) {
1087
1275
  const serializedSel = JSON.stringify(serializeSelectorForDom(selector));
@@ -1129,7 +1317,10 @@ function buildDomFillScript(selector, value, opts = {}) {
1129
1317
  var m = toMatch(h);
1130
1318
  if (!m.visible || !m.enabled) continue;
1131
1319
  ensureInViewport(h);
1132
- if (checkHitTest && !isHitTestClear(h)) continue;
1320
+ if (checkHitTest && !isHitTestClear(h)) {
1321
+ scrollToUnobscure(h);
1322
+ if (!isHitTestClear(h)) continue;
1323
+ }
1133
1324
  return h.el;
1134
1325
  }
1135
1326
  return null;
@@ -1267,7 +1458,7 @@ var SPANA_INJECTED_RUNTIME_SCRIPT = `(function() {
1267
1458
  var forAction = Boolean(opts.forAction);
1268
1459
  var failFastWhenIdle = Boolean(opts.failFastWhenIdle);
1269
1460
  var idleQuietMs = Math.max(50, Math.round(opts.idleQuietMs != null ? opts.idleQuietMs : 250));
1270
- var reqStableFrames = opts.stableFrames !== undefined ? Math.max(0, Math.round(opts.stableFrames)) : (forAction ? -1 : 0);
1461
+ var reqStableFrames = opts.stableFrames !== undefined ? Math.max(0, Math.round(opts.stableFrames)) : (forAction ? 2 : 0);
1271
1462
  var checkHitTest = opts.checkHitTest !== undefined ? Boolean(opts.checkHitTest) : forAction;
1272
1463
  var waitForAppReady = opts.waitForAppReady !== undefined ? Boolean(opts.waitForAppReady) : true;
1273
1464
  var instantAnim = Boolean(typeof document !== "undefined" && document.getElementById && document.getElementById("__spana_instant_anim"));
@@ -1293,7 +1484,12 @@ var SPANA_INJECTED_RUNTIME_SCRIPT = `(function() {
1293
1484
  if (!forAction) return ready.map(function(r) { return r.match; });
1294
1485
  var target = ready[ready.length - 1];
1295
1486
  var didScroll = ensureInViewport(target.hit);
1296
- if (checkHitTest && !isHitTestClear(target.hit)) return null;
1487
+ if (checkHitTest && !isHitTestClear(target.hit)) {
1488
+ if (scrollToUnobscure(target.hit)) {
1489
+ didScroll = true;
1490
+ }
1491
+ if (!isHitTestClear(target.hit)) return null;
1492
+ }
1297
1493
  var updated = toMatch(target.hit);
1298
1494
  if (!updated.visible || !updated.enabled) return null;
1299
1495
  return { hits: ready, target: target, match: updated, didScroll: didScroll };
@@ -1462,6 +1658,7 @@ var SPANA_INJECTED_RUNTIME_SCRIPT = `(function() {
1462
1658
  var attributeName = opts.attributeName !== undefined ? opts.attributeName : null;
1463
1659
  var patternSource = opts.patternSource !== undefined ? opts.patternSource : null;
1464
1660
  var patternFlags = opts.patternFlags || "";
1661
+ var negate = Boolean(opts.negate);
1465
1662
  var lastActual = undefined;
1466
1663
  var regex = patternSource !== null ? new RegExp(patternSource, patternFlags) : null;
1467
1664
 
@@ -1469,13 +1666,10 @@ var SPANA_INJECTED_RUNTIME_SCRIPT = `(function() {
1469
1666
  if (kind === "url") {
1470
1667
  var href = typeof window !== "undefined" && window.location ? String(window.location.href || "") : "";
1471
1668
  lastActual = href;
1472
- if (regex) {
1473
- if (regex.test(href)) return { matched: true, actual: href };
1474
- } else if (expected !== null) {
1475
- if (href === expected || href.indexOf(String(expected)) !== -1) {
1476
- return { matched: true, actual: href };
1477
- }
1478
- }
1669
+ var urlOk = regex
1670
+ ? regex.test(href)
1671
+ : (expected !== null && (href === expected || href.indexOf(String(expected)) !== -1));
1672
+ if (negate ? !urlOk : urlOk) return { matched: true, actual: href };
1479
1673
  return null;
1480
1674
  }
1481
1675
 
@@ -1487,7 +1681,8 @@ var SPANA_INJECTED_RUNTIME_SCRIPT = `(function() {
1487
1681
  if (toMatch(hits[ci]).visible) visibleCount++;
1488
1682
  }
1489
1683
  lastActual = String(visibleCount);
1490
- if (expectedCount !== null && visibleCount === expectedCount) {
1684
+ var countOk = expectedCount !== null && visibleCount === expectedCount;
1685
+ if (negate ? !countOk : countOk) {
1491
1686
  return { matched: true, actual: String(visibleCount) };
1492
1687
  }
1493
1688
  return null;
@@ -1496,47 +1691,46 @@ var SPANA_INJECTED_RUNTIME_SCRIPT = `(function() {
1496
1691
  for (var i = hits.length - 1; i >= 0; i--) {
1497
1692
  var m = toMatch(hits[i]);
1498
1693
  if (!m.visible) continue;
1694
+ var matched = false;
1695
+ var actualVal = undefined;
1499
1696
  if (kind === "text") {
1500
- lastActual = m.text;
1501
- if (m.text === expected) return { matched: true, actual: m.text };
1697
+ var normTxt = m.textContent !== undefined ? m.textContent : (m.text || "");
1698
+ actualVal = normTxt;
1699
+ matched = normTxt === (expected !== null ? String(expected).replace(/\\s+/g, " ").trim() : expected);
1502
1700
  } else if (kind === "containsText") {
1503
- var actual = m.text || "";
1504
- lastActual = m.text;
1505
- if (expected !== null && actual.toLowerCase().indexOf(String(expected).toLowerCase()) !== -1) {
1506
- return { matched: true, actual: m.text };
1507
- }
1701
+ var actual = m.textContent !== undefined ? m.textContent : (m.text || "");
1702
+ actualVal = actual;
1703
+ matched = expected !== null && actual.toLowerCase().indexOf(String(expected).replace(/\\s+/g, " ").trim().toLowerCase()) !== -1;
1508
1704
  } else if (kind === "matchesText") {
1509
- var actualRe = m.text || "";
1510
- lastActual = m.text;
1511
- if (regex && regex.test(actualRe)) return { matched: true, actual: m.text };
1705
+ var actualRe = m.textContent !== undefined ? m.textContent : (m.text || "");
1706
+ actualVal = actualRe;
1707
+ matched = Boolean(regex && regex.test(actualRe));
1512
1708
  } else if (kind === "value") {
1513
1709
  var val = m.value !== undefined ? m.value : "";
1514
- lastActual = val;
1515
- if (val === expected) return { matched: true, actual: val };
1710
+ actualVal = val;
1711
+ matched = val === expected;
1516
1712
  } else if (kind === "attribute" && attributeName !== null) {
1517
1713
  var attrVal = m.attributes ? m.attributes[attributeName] : undefined;
1518
- lastActual = attrVal;
1519
- if (expected === null ? attrVal !== undefined : attrVal === expected) {
1520
- return { matched: true, actual: attrVal };
1521
- }
1714
+ actualVal = attrVal;
1715
+ matched = expected === null ? attrVal !== undefined : attrVal === expected;
1522
1716
  } else if (kind === "accessibilityLabel") {
1523
1717
  var lbl = m.accessibilityLabel;
1524
- lastActual = lbl;
1525
- if (expected === null ? (lbl !== undefined && lbl.length > 0) : lbl === expected) {
1526
- return { matched: true, actual: lbl };
1527
- }
1718
+ actualVal = lbl;
1719
+ matched = expected === null ? (lbl !== undefined && lbl.length > 0) : lbl === expected;
1528
1720
  } else if (kind === "accessibleName") {
1529
1721
  var accName = m.accessibleName || m.accessibilityLabel || m.text || "";
1530
- lastActual = accName;
1531
- if (regex) {
1532
- if (regex.test(accName)) return { matched: true, actual: accName };
1533
- } else if (expected === null ? accName.length > 0 : accName.trim() === String(expected).trim()) {
1534
- return { matched: true, actual: accName };
1535
- }
1722
+ actualVal = accName;
1723
+ matched = regex ? regex.test(accName) : (expected === null ? accName.length > 0 : accName.trim() === String(expected).trim());
1724
+ } else if (kind === "accessibleDescription") {
1725
+ var accDesc = m.accessibleDescription || "";
1726
+ actualVal = accDesc;
1727
+ matched = regex ? regex.test(accDesc) : (expected === null ? accDesc.length > 0 : accDesc.trim() === String(expected).trim());
1536
1728
  } else if (kind === "focused") {
1537
- lastActual = m.focused ? "focused" : "not focused";
1538
- if (m.focused) return { matched: true, actual: "focused" };
1729
+ actualVal = m.focused ? "focused" : "not focused";
1730
+ matched = Boolean(m.focused);
1539
1731
  }
1732
+ lastActual = actualVal;
1733
+ if (negate ? !matched : matched) return { matched: true, actual: actualVal };
1540
1734
  }
1541
1735
  return null;
1542
1736
  }
@@ -1640,7 +1834,10 @@ var SPANA_INJECTED_RUNTIME_SCRIPT = `(function() {
1640
1834
  var m = toMatch(h);
1641
1835
  if (!m.visible || !m.enabled) continue;
1642
1836
  ensureInViewport(h);
1643
- if (checkHitTest && !isHitTestClear(h)) continue;
1837
+ if (checkHitTest && !isHitTestClear(h)) {
1838
+ scrollToUnobscure(h);
1839
+ if (!isHitTestClear(h)) continue;
1840
+ }
1644
1841
  return h.el;
1645
1842
  }
1646
1843
  return null;
@@ -1726,6 +1923,20 @@ var SPANA_INJECTED_RUNTIME_SCRIPT = `(function() {
1726
1923
  };
1727
1924
  return true;
1728
1925
  })();`;
1926
+ function buildDomActionabilityDiagScript(selector) {
1927
+ const serialized = JSON.stringify(serializeSelectorForDom(selector));
1928
+ return `(function(sel) {
1929
+ ${SHARED_DOM_TRAVERSAL_HELPERS}
1930
+ var hits = findAcrossRoots(sel);
1931
+ if (hits.length === 0) return { found: false };
1932
+ var target = hits[hits.length - 1];
1933
+ var m = toMatch(target);
1934
+ if (!m.visible) return { found: true, visible: false, enabled: m.enabled };
1935
+ if (!m.enabled) return { found: true, visible: true, enabled: false };
1936
+ var blocker = getHitTestBlocker(target);
1937
+ return { found: true, visible: true, enabled: true, obstructedBy: blocker || undefined };
1938
+ })(${serialized})`;
1939
+ }
1729
1940
  function buildDomFindElementScript(selector) {
1730
1941
  const serialized = JSON.stringify(serializeSelectorForDom(selector));
1731
1942
  return `(function(sel) {
@@ -2067,20 +2278,21 @@ var CdpDomChannel = class {
2067
2278
  enableInjectedRuntime(enabled = true) {
2068
2279
  this.useInjectedRuntime = enabled;
2069
2280
  }
2070
- async invokeDom(sessionId, method, args, fallbackScript) {
2281
+ async invokeDom(sessionId, method, args, fallbackScript, timeoutMs) {
2071
2282
  if (!this.useInjectedRuntime) {
2072
- return this.evaluateOnSession(sessionId, fallbackScript());
2283
+ return this.evaluateOnSessionWithTimeout(sessionId, fallbackScript(), timeoutMs);
2073
2284
  }
2074
2285
  const callExpr = buildInjectedCallScript(method, ...args);
2075
- const res = await this.evaluateOnSession(
2286
+ const res = await this.evaluateOnSessionWithTimeout(
2076
2287
  sessionId,
2077
- callExpr
2288
+ callExpr,
2289
+ timeoutMs
2078
2290
  );
2079
2291
  if (res !== SPANA_RUNTIME_MISSING_SENTINEL) {
2080
2292
  return res;
2081
2293
  }
2082
- await this.evaluateOnSession(sessionId, SPANA_INJECTED_RUNTIME_SCRIPT);
2083
- return this.evaluateOnSession(sessionId, callExpr);
2294
+ await this.evaluateOnSessionWithTimeout(sessionId, SPANA_INJECTED_RUNTIME_SCRIPT, timeoutMs);
2295
+ return this.evaluateOnSessionWithTimeout(sessionId, callExpr, timeoutMs);
2084
2296
  }
2085
2297
  setFrameOffsetResolver(resolver) {
2086
2298
  this.frameOffsetResolver = resolver;
@@ -2110,18 +2322,19 @@ var CdpDomChannel = class {
2110
2322
  });
2111
2323
  });
2112
2324
  }
2113
- async sendCommand(method, params = {}, sessionId) {
2325
+ async sendCommand(method, params = {}, sessionId, timeoutMs) {
2114
2326
  if (!this.isConnected()) {
2115
2327
  await this.connect();
2116
2328
  }
2117
2329
  const ws = this.ws;
2118
2330
  const id = this.nextId++;
2119
2331
  const resolvedSessionId = sessionId === void 0 ? this.activeSessionId : sessionId;
2332
+ const effectiveTimeout = timeoutMs ?? this.timeoutMs;
2120
2333
  return new Promise((resolve, reject) => {
2121
2334
  const timer = setTimeout(() => {
2122
2335
  this.pending.delete(id);
2123
- reject(new Error(`CDP command "${method}" timed out after ${this.timeoutMs}ms`));
2124
- }, this.timeoutMs);
2336
+ reject(new Error(`CDP command "${method}" timed out after ${effectiveTimeout}ms`));
2337
+ }, effectiveTimeout);
2125
2338
  this.pending.set(id, { resolve, reject, timer });
2126
2339
  const payload = { id, method, params };
2127
2340
  if (resolvedSessionId) {
@@ -2130,7 +2343,7 @@ var CdpDomChannel = class {
2130
2343
  ws.send(JSON.stringify(payload));
2131
2344
  });
2132
2345
  }
2133
- async evaluateOnSession(sessionId, script, ...args) {
2346
+ async evaluateOnSessionWithTimeout(sessionId, script, timeoutMs, args = []) {
2134
2347
  const expression = buildEvaluateExpression(script, args);
2135
2348
  const response = await this.sendCommand(
2136
2349
  "Runtime.evaluate",
@@ -2139,7 +2352,8 @@ var CdpDomChannel = class {
2139
2352
  returnByValue: true,
2140
2353
  awaitPromise: true
2141
2354
  },
2142
- sessionId
2355
+ sessionId,
2356
+ timeoutMs
2143
2357
  );
2144
2358
  if (response?.exceptionDetails) {
2145
2359
  const detail = response.exceptionDetails.exception?.description ?? response.exceptionDetails.text ?? "Evaluation threw an exception";
@@ -2152,6 +2366,9 @@ var CdpDomChannel = class {
2152
2366
  }
2153
2367
  return response?.result?.value;
2154
2368
  }
2369
+ async evaluateOnSession(sessionId, script, ...args) {
2370
+ return this.evaluateOnSessionWithTimeout(sessionId, script, void 0, args);
2371
+ }
2155
2372
  async evaluate(script, ...args) {
2156
2373
  return this.evaluateOnSession(void 0, script, ...args);
2157
2374
  }
@@ -2191,13 +2408,15 @@ var CdpDomChannel = class {
2191
2408
  return [];
2192
2409
  }
2193
2410
  async waitForSelector(selector, opts) {
2411
+ const rpcTimeout = Math.max((opts?.timeoutMs ?? 5e3) + 5e3, this.timeoutMs);
2194
2412
  const fallback = () => buildDomWaitForSelectorScript(selector, opts);
2195
2413
  if (this.childSessions.size === 0) {
2196
2414
  const result = await this.invokeDom(
2197
2415
  void 0,
2198
2416
  "waitForSelector",
2199
2417
  [selector, opts ?? {}],
2200
- fallback
2418
+ fallback,
2419
+ rpcTimeout
2201
2420
  );
2202
2421
  return Array.isArray(result) ? result : [];
2203
2422
  }
@@ -2209,14 +2428,16 @@ var CdpDomChannel = class {
2209
2428
  void 0,
2210
2429
  "waitForSelector",
2211
2430
  [selector, opts ?? {}],
2212
- fallback
2431
+ fallback,
2432
+ rpcTimeout
2213
2433
  ).catch(() => []),
2214
2434
  ...Array.from(this.childSessions.values()).map(async (child) => {
2215
2435
  const res = await this.invokeDom(
2216
2436
  child.sessionId,
2217
2437
  "waitForSelector",
2218
2438
  [selector, opts ?? {}],
2219
- fallback
2439
+ fallback,
2440
+ rpcTimeout
2220
2441
  ).catch(() => []);
2221
2442
  return Array.isArray(res) && res.length > 0 ? this.applyChildOffset(res, child) : [];
2222
2443
  })
@@ -2242,9 +2463,16 @@ var CdpDomChannel = class {
2242
2463
  });
2243
2464
  }
2244
2465
  async waitForHidden(selector, opts) {
2466
+ const rpcTimeout = Math.max((opts?.timeoutMs ?? 5e3) + 5e3, this.timeoutMs);
2245
2467
  const fallback = () => buildDomWaitForHiddenScript(selector, opts);
2246
2468
  const mainHidden = Boolean(
2247
- await this.invokeDom(void 0, "waitForHidden", [selector, opts ?? {}], fallback)
2469
+ await this.invokeDom(
2470
+ void 0,
2471
+ "waitForHidden",
2472
+ [selector, opts ?? {}],
2473
+ fallback,
2474
+ rpcTimeout
2475
+ )
2248
2476
  );
2249
2477
  if (!mainHidden || this.childSessions.size === 0) return mainHidden;
2250
2478
  for (const child of this.childSessions.values()) {
@@ -2253,7 +2481,8 @@ var CdpDomChannel = class {
2253
2481
  child.sessionId,
2254
2482
  "waitForHidden",
2255
2483
  [selector, opts ?? {}],
2256
- fallback
2484
+ fallback,
2485
+ rpcTimeout
2257
2486
  ).catch(() => true)
2258
2487
  );
2259
2488
  if (!ok) return false;
@@ -2261,12 +2490,14 @@ var CdpDomChannel = class {
2261
2490
  return true;
2262
2491
  }
2263
2492
  async waitForMatch(selector, opts) {
2493
+ const rpcTimeout = Math.max((opts?.timeoutMs ?? 5e3) + 5e3, this.timeoutMs);
2264
2494
  const fallback = () => buildDomWaitForMatchScript(selector, opts);
2265
2495
  const result = await this.invokeDom(
2266
2496
  void 0,
2267
2497
  "waitForMatch",
2268
2498
  [selector, opts],
2269
- fallback
2499
+ fallback,
2500
+ rpcTimeout
2270
2501
  );
2271
2502
  if (result && typeof result === "object" && result.matched) return result;
2272
2503
  if (this.childSessions.size > 0) {
@@ -2275,7 +2506,8 @@ var CdpDomChannel = class {
2275
2506
  child.sessionId,
2276
2507
  "waitForMatch",
2277
2508
  [selector, opts],
2278
- fallback
2509
+ fallback,
2510
+ rpcTimeout
2279
2511
  ).catch(() => ({ matched: false }));
2280
2512
  if (childRes?.matched) return childRes;
2281
2513
  }
@@ -2283,9 +2515,16 @@ var CdpDomChannel = class {
2283
2515
  return result && typeof result === "object" ? result : { matched: false };
2284
2516
  }
2285
2517
  async fillDom(selector, value, opts) {
2518
+ const rpcTimeout = Math.max((opts?.timeoutMs ?? 5e3) + 5e3, this.timeoutMs);
2286
2519
  const fallback = () => buildDomFillScript(selector, value, opts);
2287
2520
  const mainFilled = Boolean(
2288
- await this.invokeDom(void 0, "fill", [selector, value, opts ?? {}], fallback)
2521
+ await this.invokeDom(
2522
+ void 0,
2523
+ "fill",
2524
+ [selector, value, opts ?? {}],
2525
+ fallback,
2526
+ rpcTimeout
2527
+ )
2289
2528
  );
2290
2529
  if (mainFilled || this.childSessions.size === 0) return mainFilled;
2291
2530
  for (const child of this.childSessions.values()) {
@@ -2294,7 +2533,8 @@ var CdpDomChannel = class {
2294
2533
  child.sessionId,
2295
2534
  "fill",
2296
2535
  [selector, value, opts ?? {}],
2297
- fallback
2536
+ fallback,
2537
+ rpcTimeout
2298
2538
  ).catch(() => false)
2299
2539
  );
2300
2540
  if (ok) return true;
@@ -4093,6 +4333,7 @@ export {
4093
4333
  buildDomWaitForMatchScript,
4094
4334
  buildDomFillScript,
4095
4335
  SPANA_INJECTED_RUNTIME_SCRIPT,
4336
+ buildDomActionabilityDiagScript,
4096
4337
  buildDomFindElementScript,
4097
4338
  buildInjectedCallScript,
4098
4339
  TARGET_CHANNEL_MATRIX,
@@ -4119,4 +4360,4 @@ export {
4119
4360
  resolveElectrobunLaunchPlan,
4120
4361
  makeElectrobunDriver
4121
4362
  };
4122
- //# sourceMappingURL=chunk-SNL4X67N.js.map
4363
+ //# sourceMappingURL=chunk-UEWZ2EXL.js.map