spana-test 0.9.0 → 0.11.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.
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +11 -8
- package/dist/agent-fixture-5C4MCWRD.js +20 -0
- package/dist/{allure-RAEK4SIH.js → allure-FGVR5LND.js} +5 -1
- package/dist/allure-FGVR5LND.js.map +1 -0
- package/dist/app-RSDPDTKT.js +10 -0
- package/dist/cache-command-PANUAEMZ.js +12 -0
- package/dist/{chunk-Y2RZNOKU.js → chunk-26NJXP55.js} +2 -2
- package/dist/{chunk-ALPQES3J.js → chunk-3IZMPNE7.js} +549 -2002
- package/dist/chunk-3IZMPNE7.js.map +1 -0
- package/dist/chunk-4KK4E3N3.js +3587 -0
- package/dist/chunk-4KK4E3N3.js.map +1 -0
- package/dist/{chunk-IGTK5MHB.js → chunk-4SA7JK5D.js} +23 -15
- package/dist/chunk-4SA7JK5D.js.map +1 -0
- package/dist/{chunk-PLE7RFQE.js → chunk-64UZQP7Z.js} +52 -3
- package/dist/chunk-64UZQP7Z.js.map +1 -0
- package/dist/chunk-6PTUVG6A.js +127 -0
- package/dist/chunk-6PTUVG6A.js.map +1 -0
- package/dist/chunk-FPQAJNE3.js +2874 -0
- package/dist/chunk-FPQAJNE3.js.map +1 -0
- package/dist/{chunk-3UVSUVHW.js → chunk-FXBWACUT.js} +530 -3360
- package/dist/chunk-FXBWACUT.js.map +1 -0
- package/dist/chunk-OPTNFLBL.js +556 -0
- package/dist/chunk-OPTNFLBL.js.map +1 -0
- package/dist/chunk-S7MSBZ3F.js +72 -0
- package/dist/chunk-S7MSBZ3F.js.map +1 -0
- package/dist/chunk-SGZMO456.js +2125 -0
- package/dist/chunk-SGZMO456.js.map +1 -0
- package/dist/{chunk-2KRVN4WN.js → chunk-SIJJVN2D.js} +358 -3
- package/dist/chunk-SIJJVN2D.js.map +1 -0
- package/dist/{chunk-SF7UYW4I.js → chunk-VUNH4AJD.js} +4 -4
- package/dist/{chunk-UEWZ2EXL.js → chunk-WS2TVNMY.js} +107 -1976
- package/dist/chunk-WS2TVNMY.js.map +1 -0
- package/dist/{chunk-FP6PVHHR.js → chunk-WZAQANN6.js} +2 -2
- package/dist/{chunk-JZZ2W2XH.js → chunk-XA6LWLZQ.js} +65 -3
- package/dist/chunk-XA6LWLZQ.js.map +1 -0
- package/dist/cli.js +195 -17
- package/dist/cli.js.map +1 -1
- package/dist/config-loader-CNGIW2XK.js +9 -0
- package/dist/{console-BGAK7Z2L.js → console-DIYEJSSP.js} +9 -2
- package/dist/console-DIYEJSSP.js.map +1 -0
- package/dist/{discover-RLSKEBAX.js → discover-NKDMB4UI.js} +3 -3
- package/dist/{doctor-command-YTCQ2SC7.js → doctor-command-6ZVJWCW7.js} +5 -4
- package/dist/{doctor-command-YTCQ2SC7.js.map → doctor-command-6ZVJWCW7.js.map} +1 -1
- package/dist/{app-DSh1ejLh.d.ts → flow-DddAj1xv.d.ts} +1002 -355
- package/dist/gherkin/steps.d.ts +1 -2
- package/dist/{html-JO2YNRWX.js → html-FLMWPFQD.js} +2 -1
- package/dist/html-FLMWPFQD.js.map +1 -0
- package/dist/index.d.ts +498 -131
- package/dist/index.js +491 -278
- package/dist/index.js.map +1 -1
- package/dist/{junit-HLC62MK6.js → junit-CGB3LKHD.js} +3 -2
- package/dist/junit-CGB3LKHD.js.map +1 -0
- package/dist/local-DM3YBSV5.js +31 -0
- package/dist/{runner-TF4OKPYP.js → runner-WOVZWUQR.js} +6 -2
- package/dist/runner-WOVZWUQR.js.map +1 -0
- package/dist/{server-IS4K5FCT.js → server-ING5D5ZJ.js} +2 -2
- package/dist/server-ING5D5ZJ.js.map +1 -0
- package/dist/{server-4YLBAZEM.js → server-JNQ2PLCC.js} +17 -14
- package/dist/{server-4YLBAZEM.js.map → server-JNQ2PLCC.js.map} +1 -1
- package/dist/session-5TNWVGQQ.js +21 -0
- package/dist/session-5TNWVGQQ.js.map +1 -0
- package/dist/{session-CgvT-Oso.d.ts → session-uT8xL03K.d.ts} +5 -1
- package/dist/{studio-command-RFPV2DS7.js → studio-command-KK7A3KN6.js} +2 -2
- package/dist/{test-command-UEJG5AI6.js → test-command-QGIJBRH7.js} +278 -41
- package/dist/test-command-QGIJBRH7.js.map +1 -0
- package/dist/{validator-BLOLIHUY.js → validator-WO5IL7IY.js} +3 -3
- package/dist/validator-WO5IL7IY.js.map +1 -0
- package/package.json +10 -10
- package/dist/allure-RAEK4SIH.js.map +0 -1
- package/dist/chunk-2KRVN4WN.js.map +0 -1
- package/dist/chunk-3UVSUVHW.js.map +0 -1
- package/dist/chunk-ALPQES3J.js.map +0 -1
- package/dist/chunk-IGTK5MHB.js.map +0 -1
- package/dist/chunk-JZZ2W2XH.js.map +0 -1
- package/dist/chunk-PLE7RFQE.js.map +0 -1
- package/dist/chunk-UEWZ2EXL.js.map +0 -1
- package/dist/config-loader-F5YAY7RP.js +0 -9
- package/dist/console-BGAK7Z2L.js.map +0 -1
- package/dist/flow-CSMwD9Fh.d.ts +0 -69
- package/dist/html-JO2YNRWX.js.map +0 -1
- package/dist/junit-HLC62MK6.js.map +0 -1
- package/dist/session-K7FCRKOC.js +0 -18
- package/dist/test-command-UEJG5AI6.js.map +0 -1
- /package/dist/{config-loader-F5YAY7RP.js.map → agent-fixture-5C4MCWRD.js.map} +0 -0
- /package/dist/{discover-RLSKEBAX.js.map → app-RSDPDTKT.js.map} +0 -0
- /package/dist/{runner-TF4OKPYP.js.map → cache-command-PANUAEMZ.js.map} +0 -0
- /package/dist/{chunk-Y2RZNOKU.js.map → chunk-26NJXP55.js.map} +0 -0
- /package/dist/{chunk-SF7UYW4I.js.map → chunk-VUNH4AJD.js.map} +0 -0
- /package/dist/{chunk-FP6PVHHR.js.map → chunk-WZAQANN6.js.map} +0 -0
- /package/dist/{server-IS4K5FCT.js.map → config-loader-CNGIW2XK.js.map} +0 -0
- /package/dist/{session-K7FCRKOC.js.map → discover-NKDMB4UI.js.map} +0 -0
- /package/dist/{validator-BLOLIHUY.js.map → local-DM3YBSV5.js.map} +0 -0
- /package/dist/{studio-command-RFPV2DS7.js.map → studio-command-KK7A3KN6.js.map} +0 -0
|
@@ -160,7 +160,7 @@ declare const DeviceInfo: Schema.Struct<{
|
|
|
160
160
|
}>;
|
|
161
161
|
type DeviceInfo = typeof DeviceInfo.Type;
|
|
162
162
|
|
|
163
|
-
type DomChannelKind = "bridge" | "cdp" | "webkit-inspector" | "playwright";
|
|
163
|
+
type DomChannelKind = "bridge" | "cdp" | "webkit-inspector" | "playwright" | "bidi";
|
|
164
164
|
interface DomRect {
|
|
165
165
|
x: number;
|
|
166
166
|
y: number;
|
|
@@ -188,6 +188,10 @@ interface DomElementMatch {
|
|
|
188
188
|
enabled: boolean;
|
|
189
189
|
clickable: boolean;
|
|
190
190
|
focused?: boolean;
|
|
191
|
+
checked?: boolean;
|
|
192
|
+
editable?: boolean;
|
|
193
|
+
empty?: boolean;
|
|
194
|
+
className?: string;
|
|
191
195
|
attributes?: Record<string, string>;
|
|
192
196
|
/** True when the matched element lives inside a ShadowRoot */
|
|
193
197
|
inShadowDom?: boolean;
|
|
@@ -224,16 +228,18 @@ interface DomWaitForMatchOptions {
|
|
|
224
228
|
/** Max time to wait in ms. Default: 5000. */
|
|
225
229
|
timeoutMs?: number;
|
|
226
230
|
/** Assertion kind evaluated reactively inside the page via MutationObserver. */
|
|
227
|
-
kind: "text" | "containsText" | "matchesText" | "value" | "attribute" | "accessibilityLabel" | "accessibleName" | "accessibleDescription" | "focused" | "count" | "url";
|
|
231
|
+
kind: "text" | "containsText" | "matchesText" | "value" | "attribute" | "accessibilityLabel" | "accessibleName" | "accessibleDescription" | "focused" | "checked" | "class" | "css" | "editable" | "empty" | "count" | "url" | "title";
|
|
228
232
|
/** Expected value/substring (optional when `kind === "attribute"` or `"accessibilityLabel"` checks presence). */
|
|
229
233
|
expected?: string;
|
|
230
234
|
/** Expected element count when `kind === "count"`. */
|
|
231
235
|
expectedCount?: number;
|
|
232
236
|
/** Attribute name when `kind === "attribute"`. */
|
|
233
237
|
attributeName?: string;
|
|
234
|
-
/**
|
|
238
|
+
/** CSS property name when `kind === "css"`. */
|
|
239
|
+
cssProperty?: string;
|
|
240
|
+
/** RegExp source when `kind === "matchesText" | "accessibleName" | "accessibleDescription" | "class" | "css" | "url" | "title"`. */
|
|
235
241
|
patternSource?: string;
|
|
236
|
-
/** RegExp flags when `kind === "matchesText" | "accessibleName" | "accessibleDescription" | "url"`. */
|
|
242
|
+
/** RegExp flags when `kind === "matchesText" | "accessibleName" | "accessibleDescription" | "class" | "css" | "url" | "title"`. */
|
|
237
243
|
patternFlags?: string;
|
|
238
244
|
/** Invert the match condition (`expect(...).not.*`). */
|
|
239
245
|
negate?: boolean;
|
|
@@ -335,13 +341,40 @@ declare function buildDomFillScript(selector: Selector, value: string, opts?: Do
|
|
|
335
341
|
* Cuts per-action CDP `Runtime.evaluate` payload by ~100× (~8 KB → ~70 bytes)
|
|
336
342
|
* and lets V8 TurboFan JIT-compile the selector & actionability helpers once.
|
|
337
343
|
*/
|
|
338
|
-
declare const SPANA_INJECTED_RUNTIME_SCRIPT = "(function() {\n if (typeof window === \"undefined\" || window.__spanaRt) return true;\n \n function matchSpec(actual, spec, exact) {\n var str = String(actual || \"\");\n if (spec && typeof spec === \"object\" && typeof spec.__spanaRegex === \"string\") {\n try { return new RegExp(spec.__spanaRegex, spec.flags || \"\").test(str); } catch (e) { return false; }\n }\n var needle = String(spec == null ? \"\" : spec);\n if (exact) return str.trim() === needle.trim();\n return str.toLowerCase().indexOf(needle.toLowerCase()) !== -1;\n }\n function getImplicitRole(el) {\n if (!el || !el.getAttribute) return \"\";\n var explicit = (el.getAttribute(\"role\") || \"\").trim().toLowerCase();\n if (explicit) return explicit.split(/\\s+/)[0] || \"\";\n var tag = el.tagName ? el.tagName.toUpperCase() : \"\";\n if (tag === \"BUTTON\") return \"button\";\n if (tag === \"A\") return el.hasAttribute(\"href\") ? \"link\" : \"\";\n if (tag === \"TEXTAREA\") return \"textbox\";\n if (tag === \"SELECT\") return (el.hasAttribute(\"multiple\") || Number(el.getAttribute(\"size\") || 0) > 1) ? \"listbox\" : \"combobox\";\n if (tag === \"OPTION\") return \"option\";\n if (tag === \"IMG\") return el.getAttribute(\"alt\") === \"\" ? \"presentation\" : \"img\";\n if (tag === \"DIALOG\") return \"dialog\";\n if (tag === \"NAV\") return \"navigation\";\n if (tag === \"MAIN\") return \"main\";\n if (tag === \"HEADER\") return \"banner\";\n if (tag === \"FOOTER\") return \"contentinfo\";\n if (tag === \"ASIDE\") return \"complementary\";\n if (tag === \"UL\" || tag === \"OL\") return \"list\";\n if (tag === \"LI\") return \"listitem\";\n if (tag === \"TABLE\") return \"table\";\n if (tag === \"TR\") return \"row\";\n if (tag === \"TD\") return \"cell\";\n if (tag === \"TH\") return \"columnheader\";\n if (tag === \"ARTICLE\") return \"article\";\n if (tag === \"FORM\") return \"form\";\n if (tag === \"PROGRESS\") return \"progressbar\";\n if (tag === \"HR\") return \"separator\";\n if (tag === \"SECTION\") return (el.hasAttribute(\"aria-label\") || el.hasAttribute(\"aria-labelledby\")) ? \"region\" : \"\";\n if (/^H[1-6]$/.test(tag)) return \"heading\";\n if (tag === \"INPUT\") {\n var t = (el.getAttribute(\"type\") || \"text\").toLowerCase();\n if (t === \"button\" || t === \"submit\" || t === \"reset\" || t === \"image\") return \"button\";\n if (t === \"checkbox\") return \"checkbox\";\n if (t === \"radio\") return \"radio\";\n if (t === \"search\") return \"searchbox\";\n if (t === \"number\") return \"spinbutton\";\n if (t === \"range\") return \"slider\";\n if (t === \"hidden\") return \"\";\n return \"textbox\";\n }\n return \"\";\n }\n function visibleTextOf(node, allowHiddenRoot, skipControl) {\n if (!node) return \"\";\n if (node.nodeType === 3) return node.nodeValue || \"\";\n if (node.nodeType !== 1 && node.nodeType !== 11) return \"\";\n if (node.nodeType === 1) {\n if (skipControl && node === skipControl) return \"\";\n var t = node.tagName ? node.tagName.toUpperCase() : \"\";\n if (t === \"SCRIPT\" || t === \"STYLE\" || t === \"NOSCRIPT\" || t === \"TEMPLATE\") return \"\";\n if (skipControl && (t === \"SELECT\" || t === \"TEXTAREA\" || t === \"INPUT\")) return \"\";\n if (!allowHiddenRoot) {\n if (node.getAttribute && node.getAttribute(\"aria-hidden\") === \"true\") return \"\";\n var win = (node.ownerDocument && node.ownerDocument.defaultView) || window;\n if (win && win.getComputedStyle) {\n var st = win.getComputedStyle(node);\n if (st && (st.display === \"none\" || st.visibility === \"hidden\" || st.visibility === \"collapse\")) {\n return \"\";\n }\n }\n }\n }\n var out = [];\n if (node.shadowRoot) {\n var stxt = visibleTextOf(node.shadowRoot, false, skipControl);\n if (stxt) out.push(stxt);\n }\n var kids = node.childNodes || [];\n for (var i = 0; i < kids.length; i++) {\n var k = visibleTextOf(kids[i], false, skipControl);\n if (k) out.push(k);\n }\n return out.join(\" \").replace(/\\s+/g, \" \").trim();\n }\n function isAriaHidden(el) {\n if (!el) return true;\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var cur = el;\n var guard = 0;\n while (cur && guard++ < 32) {\n if (cur.getAttribute) {\n if (cur.getAttribute(\"aria-hidden\") === \"true\") return true;\n if (cur.hasAttribute && cur.hasAttribute(\"inert\")) return true;\n }\n if (cur.nodeType === 1 && win && win.getComputedStyle) {\n var cs = win.getComputedStyle(cur);\n if (cs && cs.display === \"none\") return true;\n }\n var root = typeof cur.getRootNode === \"function\" ? cur.getRootNode() : null;\n cur = cur.parentElement || (root && root.host) || null;\n }\n if (typeof el.checkVisibility === \"function\") {\n try {\n if (!el.checkVisibility({ visibilityProperty: true })) return true;\n } catch (e) {}\n } else if (win && win.getComputedStyle) {\n var selfCs = win.getComputedStyle(el);\n if (selfCs && (selfCs.visibility === \"hidden\" || selfCs.visibility === \"collapse\")) return true;\n }\n return false;\n }\n function headingLevelOf(el) {\n if (!el) return null;\n var explicit = el.getAttribute && el.getAttribute(\"aria-level\");\n if (explicit) {\n var parsed = parseInt(explicit, 10);\n if (!isNaN(parsed)) return parsed;\n }\n var tag = el.tagName ? el.tagName.toUpperCase() : \"\";\n var m = /^H([1-6])$/.exec(tag);\n return m ? parseInt(m[1], 10) : null;\n }\n function getAccessibleName(el) {\n if (!el) return \"\";\n var doc = el.ownerDocument || document;\n var labelledBy = el.getAttribute && el.getAttribute(\"aria-labelledby\");\n if (labelledBy) {\n var parts = [];\n var ids = labelledBy.trim().split(/\\s+/);\n for (var i = 0; i < ids.length; i++) {\n var ref = doc.getElementById ? doc.getElementById(ids[i]) : null;\n if (ref) {\n var rt = visibleTextOf(ref, true, null);\n if (rt) parts.push(rt);\n }\n }\n if (parts.length > 0) return parts.join(\" \").replace(/\\s+/g, \" \").trim();\n }\n var ariaLabel = el.getAttribute && el.getAttribute(\"aria-label\");\n if (ariaLabel && ariaLabel.trim()) return ariaLabel.trim();\n var tag = el.tagName ? el.tagName.toUpperCase() : \"\";\n if (tag === \"INPUT\" || tag === \"TEXTAREA\" || tag === \"SELECT\") {\n if (el.id && doc.querySelector) {\n try {\n var escId = typeof CSS !== \"undefined\" && CSS.escape ? CSS.escape(el.id) : el.id;\n var forLbl = doc.querySelector('label[for=\"' + escId + '\"]');\n if (forLbl) {\n var ft = visibleTextOf(forLbl, false, el);\n if (ft) return ft;\n }\n } catch (e) {}\n }\n if (el.closest) {\n var wrapLbl = el.closest(\"label\");\n if (wrapLbl) {\n var wt = visibleTextOf(wrapLbl, false, el);\n if (wt) return wt;\n }\n }\n var itype = tag === \"INPUT\" ? (el.getAttribute(\"type\") || \"text\").toLowerCase() : \"\";\n if ((itype === \"button\" || itype === \"submit\" || itype === \"reset\") && el.value) {\n return String(el.value).trim();\n }\n var ph = el.getAttribute && el.getAttribute(\"placeholder\");\n if (ph && ph.trim()) return ph.trim();\n }\n if (tag === \"IMG\") {\n var alt = el.getAttribute && el.getAttribute(\"alt\");\n if (alt && alt.trim()) return alt.trim();\n }\n var txt = visibleTextOf(el, false, null);\n if (txt) return txt;\n var title = el.getAttribute && el.getAttribute(\"title\");\n return title ? title.trim() : \"\";\n }\n function getAccessibleDescription(el) {\n if (!el) return \"\";\n var doc = el.ownerDocument || document;\n var describedBy = el.getAttribute && el.getAttribute(\"aria-describedby\");\n if (describedBy) {\n var parts = [];\n var ids = describedBy.trim().split(/\\s+/);\n for (var i = 0; i < ids.length; i++) {\n var ref = doc.getElementById ? doc.getElementById(ids[i]) : null;\n if (ref) {\n var rt = visibleTextOf(ref, true, null);\n if (rt) parts.push(rt);\n }\n }\n if (parts.length > 0) return parts.join(\" \").replace(/\\s+/g, \" \").trim();\n }\n var ariaDesc = el.getAttribute && el.getAttribute(\"aria-description\");\n if (ariaDesc && ariaDesc.trim()) return ariaDesc.trim();\n var title = el.getAttribute && el.getAttribute(\"title\");\n if (title && title.trim()) {\n var accName = getAccessibleName(el);\n if (accName && accName !== title.trim()) return title.trim();\n }\n return \"\";\n }\n function collectRoots(root, offsetX, offsetY, inShadow, inIframe, out) {\n if (!root) return;\n out.push({ root: root, offsetX: offsetX, offsetY: offsetY, inShadow: inShadow, inIframe: inIframe });\n if (root.shadowRoot) {\n collectRoots(root.shadowRoot, offsetX, offsetY, true, inIframe, out);\n }\n var nodes = root.querySelectorAll ? root.querySelectorAll(\"*\") : [];\n for (var i = 0; i < nodes.length; i++) {\n var el = nodes[i];\n if (el.shadowRoot) {\n collectRoots(el.shadowRoot, offsetX, offsetY, true, inIframe, out);\n }\n if (el.tagName === \"IFRAME\") {\n try {\n var frameDoc = el.contentDocument;\n if (frameDoc) {\n var frameRect = el.getBoundingClientRect();\n collectRoots(frameDoc, offsetX + frameRect.left, offsetY + frameRect.top, inShadow, true, out);\n }\n } catch (e) {}\n }\n }\n }\n function findTextInRoot(root, needle, exact, ctx, pushHit) {\n var doc = root.ownerDocument || (root.nodeType === 9 ? root : document);\n if (doc && typeof doc.createTreeWalker === \"function\" && typeof NodeFilter !== \"undefined\") {\n var walker = doc.createTreeWalker(root, NodeFilter.SHOW_TEXT);\n var txtNode;\n while ((txtNode = walker.nextNode())) {\n var rawVal = (txtNode.nodeValue || \"\").trim();\n var val = rawVal.toLowerCase();\n var ok = exact ? rawVal === needle : (val && val.indexOf(needle.toLowerCase()) !== -1);\n if (ok && txtNode.parentElement) {\n pushHit(txtNode.parentElement, ctx);\n }\n }\n if (typeof root.querySelectorAll === \"function\") {\n var inputs = root.querySelectorAll(\"input, button\");\n for (var ii = 0; ii < inputs.length; ii++) {\n var inp = inputs[ii];\n var rawInp = String(inp.value || \"\").trim();\n var inpOk = exact ? rawInp === needle : (rawInp && rawInp.toLowerCase().indexOf(needle.toLowerCase()) !== -1);\n if (inpOk) {\n pushHit(inp, ctx);\n }\n }\n }\n return;\n }\n var all = root.querySelectorAll ? root.querySelectorAll(\"*\") : [];\n for (var k = 0; k < all.length; k++) {\n var node = all[k];\n var directText = \"\";\n for (var c = 0; c < node.childNodes.length; c++) {\n if (node.childNodes[c].nodeType === 3) directText += node.childNodes[c].textContent || \"\";\n }\n var trimmedDirect = directText.trim();\n var inpVal = (node.tagName === \"INPUT\" || node.tagName === \"BUTTON\") ? String(node.value || \"\").trim() : \"\";\n var directOk = exact ? trimmedDirect === needle : (trimmedDirect && trimmedDirect.toLowerCase().indexOf(needle.toLowerCase()) !== -1);\n var inputOk = exact ? inpVal === needle : (inpVal && inpVal.toLowerCase().indexOf(needle.toLowerCase()) !== -1);\n if (directOk || inputOk) {\n pushHit(node, ctx);\n }\n }\n }\n function findRoleInRoot(root, roleLower, nameSpec, exact, ctx, pushHit, includeHidden, level) {\n if (!root || !root.querySelectorAll) return;\n var candidates = root.querySelectorAll(\"*\");\n for (var i = 0; i < candidates.length; i++) {\n var el = candidates[i];\n if (getImplicitRole(el) !== roleLower) continue;\n if (!includeHidden && isAriaHidden(el)) continue;\n if (level !== undefined && level !== null && headingLevelOf(el) !== Number(level)) continue;\n if (nameSpec !== undefined && nameSpec !== null) {\n var accName = getAccessibleName(el);\n if (!matchSpec(accName, nameSpec, Boolean(exact))) continue;\n }\n pushHit(el, ctx);\n }\n }\n function applyModifiersAndSlice(hits, sel) {\n if (!sel || typeof sel !== \"object\" || \"point\" in sel) return hits;\n var filtered = hits;\n if (sel.hasText !== undefined) {\n filtered = filtered.filter(function(h) {\n var txt = (h.el.innerText || h.el.textContent || h.el.value || getAccessibleName(h.el) || \"\");\n return matchSpec(txt, sel.hasText, false);\n });\n }\n if (sel.hasNotText !== undefined) {\n filtered = filtered.filter(function(h) {\n var txt = (h.el.innerText || h.el.textContent || h.el.value || getAccessibleName(h.el) || \"\");\n return !matchSpec(txt, sel.hasNotText, false);\n });\n }\n if (sel.has !== undefined) {\n filtered = filtered.filter(function(h) {\n return findInScope(sel.has, h.el, h.offsetX, h.offsetY, h.inShadow, h.inIframe).length > 0;\n });\n }\n if (sel.hasNot !== undefined) {\n filtered = filtered.filter(function(h) {\n return findInScope(sel.hasNot, h.el, h.offsetX, h.offsetY, h.inShadow, h.inIframe).length === 0;\n });\n }\n if (sel.first) return filtered.length > 0 ? [filtered[0]] : [];\n if (sel.last) return filtered.length > 0 ? [filtered[filtered.length - 1]] : [];\n if (typeof sel.nth === \"number\") {\n var idx = sel.nth < 0 ? filtered.length + sel.nth : sel.nth;\n return idx >= 0 && idx < filtered.length ? [filtered[idx]] : [];\n }\n return filtered;\n }\n function findInScope(sel, scopeRoot, baseOffsetX, baseOffsetY, baseInShadow, baseInIframe) {\n var hits = [];\n var seen = typeof Set !== \"undefined\" ? new Set() : null;\n function pushHit(el, ctx) {\n if (seen) {\n if (seen.has(el)) return;\n seen.add(el);\n }\n hits.push({ el: el, offsetX: ctx.offsetX, offsetY: ctx.offsetY, inShadow: ctx.inShadow, inIframe: ctx.inIframe });\n }\n if (typeof sel === \"object\" && sel !== null && \"point\" in sel) {\n var atPt = document.elementFromPoint(sel.point.x, sel.point.y);\n if (atPt) pushHit(atPt, { offsetX: 0, offsetY: 0, inShadow: false, inIframe: false });\n return hits;\n }\n // Frame scoping: find matching <iframe> first, then search inside its contentDocument\n if (typeof sel === \"object\" && sel !== null && sel.frame) {\n var frameHits = findInScope(sel.frame, scopeRoot, baseOffsetX, baseOffsetY, baseInShadow, baseInIframe);\n var innerSel = Object.assign({}, sel);\n delete innerSel.frame;\n for (var fi = 0; fi < frameHits.length; fi++) {\n var fEl = frameHits[fi].el;\n if (fEl && fEl.tagName === \"IFRAME\") {\n try {\n var fDoc = fEl.contentDocument;\n if (fDoc) {\n var fRect = fEl.getBoundingClientRect();\n var sub = findInScope(innerSel, fDoc, frameHits[fi].offsetX + fRect.left, frameHits[fi].offsetY + fRect.top, frameHits[fi].inShadow, true);\n for (var si = 0; si < sub.length; si++) pushHit(sub[si].el, sub[si]);\n }\n } catch (e) {}\n }\n }\n return hits;\n }\n // Parent scoping: resolve 'within' first, then search inside each matched container\n if (typeof sel === \"object\" && sel !== null && sel.within) {\n var parentHits = findInScope(sel.within, scopeRoot, baseOffsetX, baseOffsetY, baseInShadow, baseInIframe);\n var childSel = Object.assign({}, sel);\n delete childSel.within;\n delete childSel.hasText;\n delete childSel.hasNotText;\n delete childSel.has;\n delete childSel.hasNot;\n delete childSel.first;\n delete childSel.last;\n delete childSel.nth;\n var combined = [];\n var cSeen = typeof Set !== \"undefined\" ? new Set() : null;\n for (var pi = 0; pi < parentHits.length; pi++) {\n var ph = parentHits[pi];\n var subHits = findInScope(childSel, ph.el, ph.offsetX, ph.offsetY, ph.inShadow, ph.inIframe);\n for (var ci = 0; ci < subHits.length; ci++) {\n if (cSeen && cSeen.has(subHits[ci].el)) continue;\n if (cSeen) cSeen.add(subHits[ci].el);\n combined.push(subHits[ci]);\n }\n }\n return applyModifiersAndSlice(combined, sel);\n }\n // Logical OR composition (anyOf): union deduplicated hits across branches\n if (typeof sel === \"object\" && sel !== null && Array.isArray(sel.anyOf)) {\n for (var bi = 0; bi < sel.anyOf.length; bi++) {\n var branchHits = findInScope(sel.anyOf[bi], scopeRoot, baseOffsetX, baseOffsetY, baseInShadow, baseInIframe);\n for (var bh = 0; bh < branchHits.length; bh++) {\n pushHit(branchHits[bh].el, branchHits[bh]);\n }\n }\n return applyModifiersAndSlice(hits, sel);\n }\n\n var esc = function(v) {\n return typeof CSS !== \"undefined\" && CSS.escape ? CSS.escape(v) : String(v).replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"');\n };\n var mainCtx = { root: scopeRoot, offsetX: baseOffsetX, offsetY: baseOffsetY, inShadow: baseInShadow, inIframe: baseInIframe };\n 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\");\n\n // O(1)-ish Light-DOM fast path: avoids scanning thousands of nodes with querySelectorAll(\"*\")\n // unless Shadow DOM / iframe piercing is needed or no Light-DOM match exists.\n if (scopeRoot && scopeRoot.querySelectorAll && !hasModifiers) {\n if (typeof sel === \"object\" && sel !== null && \"testID\" in sel) {\n var fastTid = esc(sel.testID);\n var fastFound = scopeRoot.querySelectorAll('[data-testid=\"' + fastTid + '\"], [testID=\"' + fastTid + '\"]');\n if (fastFound.length > 0) {\n for (var fi2 = 0; fi2 < fastFound.length; fi2++) pushHit(fastFound[fi2], mainCtx);\n return hits;\n }\n } else if (typeof sel === \"object\" && sel !== null && \"css\" in sel) {\n try {\n var fastCss = scopeRoot.querySelectorAll(sel.css);\n if (fastCss.length > 0) {\n for (var fc = 0; fc < fastCss.length; fc++) pushHit(fastCss[fc], mainCtx);\n return hits;\n }\n } catch (e) {}\n } else if (typeof sel === \"object\" && sel !== null && \"accessibilityLabel\" in sel) {\n var fastLbl = esc(sel.accessibilityLabel);\n var fastFoundLbl = scopeRoot.querySelectorAll('[aria-label=\"' + fastLbl + '\"]');\n if (fastFoundLbl.length > 0) {\n for (var fj = 0; fj < fastFoundLbl.length; fj++) pushHit(fastFoundLbl[fj], mainCtx);\n return hits;\n }\n } else if (typeof sel === \"object\" && sel !== null && \"role\" in sel) {\n findRoleInRoot(scopeRoot, String(sel.role).toLowerCase(), sel.name, sel.exact, mainCtx, pushHit, sel.includeHidden, sel.level);\n if (hits.length > 0) return hits;\n } else if (typeof sel === \"string\" || (typeof sel === \"object\" && sel !== null && \"text\" in sel)) {\n var fastNeedle = typeof sel === \"string\" ? sel : sel.text;\n var fastExact = typeof sel === \"object\" && sel !== null && Boolean(sel.exact);\n findTextInRoot(scopeRoot, fastNeedle, fastExact, mainCtx, pushHit);\n if (hits.length > 0) return hits;\n }\n }\n\n var roots = [];\n collectRoots(scopeRoot, baseOffsetX, baseOffsetY, baseInShadow, baseInIframe, roots);\n for (var r = 0; r < roots.length; r++) {\n var ctx = roots[r];\n var root = ctx.root;\n if (!root || !root.querySelectorAll) continue;\n if (typeof sel === \"object\" && sel !== null && \"testID\" in sel) {\n var tid = esc(sel.testID);\n var found = root.querySelectorAll('[data-testid=\"' + tid + '\"], [testID=\"' + tid + '\"]');\n for (var i = 0; i < found.length; i++) pushHit(found[i], ctx);\n } else if (typeof sel === \"object\" && sel !== null && \"css\" in sel) {\n try {\n var foundCss = root.querySelectorAll(sel.css);\n for (var ci2 = 0; ci2 < foundCss.length; ci2++) pushHit(foundCss[ci2], ctx);\n } catch (e) {}\n } else if (typeof sel === \"object\" && sel !== null && \"accessibilityLabel\" in sel) {\n var lbl = esc(sel.accessibilityLabel);\n var foundLbl = root.querySelectorAll('[aria-label=\"' + lbl + '\"]');\n for (var j = 0; j < foundLbl.length; j++) pushHit(foundLbl[j], ctx);\n } else if (typeof sel === \"object\" && sel !== null && \"role\" in sel) {\n findRoleInRoot(root, String(sel.role).toLowerCase(), sel.name, sel.exact, ctx, pushHit, sel.includeHidden, sel.level);\n } else if (typeof sel === \"string\" || (typeof sel === \"object\" && sel !== null && \"text\" in sel)) {\n var needle = typeof sel === \"string\" ? sel : sel.text;\n var isExact = typeof sel === \"object\" && sel !== null && Boolean(sel.exact);\n findTextInRoot(root, needle, isExact, ctx, pushHit);\n }\n }\n return applyModifiersAndSlice(hits, sel);\n }\n function findAcrossRoots(sel) {\n return findInScope(sel, document, 0, 0, false, false);\n }\n function isClickable(el) {\n var tag = el.tagName;\n if (tag === \"BUTTON\" || tag === \"A\" || tag === \"INPUT\" || tag === \"SELECT\" || tag === \"TEXTAREA\") return true;\n var role = el.getAttribute && el.getAttribute(\"role\");\n if (role === \"button\" || role === \"link\" || role === \"tab\" || role === \"checkbox\" || role === \"switch\") return true;\n if (typeof el.onclick === \"function\") return true;\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var cursor = win.getComputedStyle(el).cursor;\n return cursor === \"pointer\";\n }\n function isAppReady() {\n var sig = typeof window !== \"undefined\" ? window.__SPANA_APP_READY__ : undefined;\n if (typeof sig === \"function\") {\n try { return Boolean(sig()); } catch (e) { return false; }\n }\n if (typeof sig === \"boolean\") return sig;\n return true;\n }\n function deepElementFromPoint(rootDoc, x, y) {\n if (!rootDoc || typeof rootDoc.elementFromPoint !== \"function\") return null;\n var el = rootDoc.elementFromPoint(x, y);\n var guard = 0;\n while (el && guard++ < 16) {\n if (el.shadowRoot && typeof el.shadowRoot.elementFromPoint === \"function\") {\n var inner = el.shadowRoot.elementFromPoint(x, y);\n if (inner && inner !== el) { el = inner; continue; }\n }\n if (el.tagName === \"IFRAME\") {\n try {\n var fdoc = el.contentDocument;\n if (fdoc && typeof fdoc.elementFromPoint === \"function\") {\n var fr = el.getBoundingClientRect();\n var fx = x - fr.left;\n var fy = y - fr.top;\n var fEl = fdoc.elementFromPoint(fx, fy);\n if (fEl && fEl !== el) { el = fEl; x = fx; y = fy; continue; }\n }\n } catch (e) {}\n }\n break;\n }\n return el;\n }\n function labelControlOf(node) {\n var cur = node;\n var guard = 0;\n while (cur && guard++ < 8) {\n if (cur.tagName === \"LABEL\") return cur.control || null;\n cur = cur.parentElement;\n }\n return null;\n }\n function isSameOrDescendant(target, candidate) {\n if (!target || !candidate) return false;\n if (target === candidate) return true;\n try {\n if (typeof target.contains === \"function\" && target.contains(candidate)) return true;\n } catch (e) {}\n if (labelControlOf(candidate) === target) return true;\n var cur = candidate;\n var guard = 0;\n while (cur && guard++ < 24) {\n if (cur === target) return true;\n var root = typeof cur.getRootNode === \"function\" ? cur.getRootNode() : null;\n if (root && root.host) {\n cur = root.host;\n } else {\n cur = cur.parentElement;\n }\n }\n return false;\n }\n function describeEl(el) {\n if (!el) return \"(unknown)\";\n var tag = el.tagName ? el.tagName.toLowerCase() : \"element\";\n var idPart = el.id ? \"#\" + el.id : \"\";\n var cls = typeof el.className === \"string\" ? el.className.trim().split(/\\s+/).filter(Boolean).slice(0, 3).join(\".\") : \"\";\n var clsPart = cls ? \".\" + cls : \"\";\n var txt = (el.innerText || el.textContent || \"\").replace(/\\s+/g, \" \").trim();\n if (txt.length > 40) txt = txt.slice(0, 37) + \"...\";\n return \"<\" + tag + idPart + clsPart + (txt ? \">\" + txt + \"</\" + tag + \">\" : \">\");\n }\n function getHitTestBlocker(hit) {\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var vw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0;\n var vh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0;\n var cx = rect.left + hit.offsetX + rect.width / 2;\n var cy = rect.top + hit.offsetY + rect.height / 2;\n if (vw > 0 && vh > 0 && (cx < 0 || cy < 0 || cx > vw || cy > vh)) {\n return \"outside viewport\";\n }\n var topEl = deepElementFromPoint(document, cx, cy);\n if (!topEl) return null;\n if (isSameOrDescendant(el, topEl)) return null;\n return describeEl(topEl);\n }\n function isHitTestClear(hit) {\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var vw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0;\n var vh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0;\n var cx = rect.left + hit.offsetX + rect.width / 2;\n var cy = rect.top + hit.offsetY + rect.height / 2;\n if (vw > 0 && vh > 0 && (cx < 0 || cy < 0 || cx > vw || cy > vh)) {\n return false;\n }\n var topEl = deepElementFromPoint(document, cx, cy);\n if (!topEl) return true;\n return isSameOrDescendant(el, topEl);\n }\n function ensureInViewport(hit) {\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var vw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0;\n var vh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0;\n var cx = rect.left + hit.offsetX + rect.width / 2;\n var cy = rect.top + hit.offsetY + rect.height / 2;\n if (vw > 0 && vh > 0 && (cx < 1 || cy < 1 || cx > vw - 1 || cy > vh - 1)) {\n if (typeof el.scrollIntoView === \"function\") {\n try { el.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"instant\" }); }\n catch (e) { try { el.scrollIntoView(true); } catch (e2) {} }\n }\n return true;\n }\n return false;\n }\n function scrollToUnobscure(hit) {\n var el = hit.el;\n if (typeof el.scrollIntoView !== \"function\") return false;\n var blocks = [\"center\", \"end\", \"start\", \"nearest\"];\n for (var i = 0; i < blocks.length; i++) {\n try {\n el.scrollIntoView({ block: blocks[i], inline: \"center\", behavior: \"instant\" });\n } catch (e) {\n try { el.scrollIntoView(true); } catch (e2) {}\n }\n if (isHitTestClear(hit)) return true;\n }\n return false;\n }\n function hasActiveAnimation(el) {\n var cur = el;\n var depth = 0;\n while (cur && depth++ < 8) {\n if (typeof cur.getAnimations === \"function\") {\n try {\n var anims = cur.getAnimations();\n for (var i = 0; i < anims.length; i++) {\n if (anims[i] && anims[i].playState === \"running\") return true;\n }\n } catch (e) {}\n }\n cur = cur.parentElement;\n }\n return false;\n }\n function isVisible(el, rect) {\n if (rect.width <= 0 || rect.height <= 0) return false;\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var style = win.getComputedStyle(el);\n if (style.display === \"none\" || style.visibility === \"hidden\" || parseFloat(style.opacity || \"1\") === 0) return false;\n return true;\n }\n function toMatch(hit) {\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var attrs = {};\n if (el.attributes) {\n for (var i = 0; i < el.attributes.length; i++) {\n attrs[el.attributes[i].name] = el.attributes[i].value;\n }\n }\n var tag = el.tagName ? el.tagName.toLowerCase() : undefined;\n var val = (el.tagName === \"INPUT\" || el.tagName === \"TEXTAREA\" || el.tagName === \"SELECT\")\n ? String(el.value ?? \"\")\n : undefined;\n var text = (el.innerText || el.textContent || \"\").trim() || undefined;\n var normTextContent = (el.textContent || \"\").replace(/\\s+/g, \" \").trim() || undefined;\n var accName = getAccessibleName(el) || undefined;\n var accDesc = getAccessibleDescription(el) || undefined;\n var role = getImplicitRole(el) || undefined;\n return {\n id: el.getAttribute(\"data-testid\") || el.getAttribute(\"testID\") || undefined,\n tag: tag,\n role: role,\n text: text,\n textContent: normTextContent,\n value: val,\n accessibilityLabel: el.getAttribute(\"aria-label\") || undefined,\n accessibleName: accName,\n accessibleDescription: accDesc,\n rect: { x: rect.x + hit.offsetX, y: rect.y + hit.offsetY, width: rect.width, height: rect.height },\n scrollX: window.scrollX || window.pageXOffset || 0,\n scrollY: window.scrollY || window.pageYOffset || 0,\n devicePixelRatio: window.devicePixelRatio || 1,\n viewportWidth: (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0,\n viewportHeight: (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0,\n visible: isVisible(el, rect),\n enabled: !el.hasAttribute(\"disabled\") && el.getAttribute(\"aria-disabled\") !== \"true\",\n clickable: isClickable(el),\n focused: document.activeElement === el,\n attributes: attrs,\n inShadowDom: hit.inShadow || undefined,\n inIframe: hit.inIframe || undefined\n };\n }\n\n\n function query(sel) {\n return findAcrossRoots(sel).map(toMatch);\n }\n\n function scrollIntoView(sel) {\n var hits = findAcrossRoots(sel);\n if (hits.length === 0) return null;\n var hit = hits[hits.length - 1];\n if (typeof hit.el.scrollIntoView === \"function\") {\n try { hit.el.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"instant\" }); }\n catch (e) { try { hit.el.scrollIntoView(true); } catch (e2) {} }\n }\n return toMatch(hit);\n }\n\n function tap(sel) {\n var hits = findAcrossRoots(sel);\n if (hits.length === 0) return false;\n var hit = hits[hits.length - 1];\n var el = hit.el;\n if (typeof el.scrollIntoView === \"function\") {\n try { el.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"instant\" }); } catch (e) {}\n }\n var rect = el.getBoundingClientRect();\n var cx = rect.left + rect.width / 2;\n var cy = rect.top + rect.height / 2;\n var init = { bubbles: true, cancelable: true, composed: true, clientX: cx, clientY: cy };\n try { el.dispatchEvent(new PointerEvent(\"pointerdown\", init)); } catch (e) {}\n try { el.dispatchEvent(new MouseEvent(\"mousedown\", init)); } catch (e) {}\n if (typeof el.focus === \"function\") { try { el.focus(); } catch (e) {} }\n try { el.dispatchEvent(new PointerEvent(\"pointerup\", init)); } catch (e) {}\n try { el.dispatchEvent(new MouseEvent(\"mouseup\", init)); } catch (e) {}\n if (typeof el.click === \"function\") { el.click(); }\n else { el.dispatchEvent(new MouseEvent(\"click\", init)); }\n return true;\n }\n\n function waitForSelector(sel, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n var forAction = Boolean(opts.forAction);\n var failFastWhenIdle = Boolean(opts.failFastWhenIdle);\n var idleQuietMs = Math.max(50, Math.round(opts.idleQuietMs != null ? opts.idleQuietMs : 250));\n var reqStableFrames = opts.stableFrames !== undefined ? Math.max(0, Math.round(opts.stableFrames)) : (forAction ? 2 : 0);\n var checkHitTest = opts.checkHitTest !== undefined ? Boolean(opts.checkHitTest) : forAction;\n var waitForAppReady = opts.waitForAppReady !== undefined ? Boolean(opts.waitForAppReady) : true;\n var instantAnim = Boolean(typeof document !== \"undefined\" && document.getElementById && document.getElementById(\"__spana_instant_anim\"));\n var explicitStableFrames = instantAnim ? 0 : reqStableFrames;\n\n function findCandidates() {\n if (waitForAppReady && !isAppReady()) return null;\n var rawHits = findAcrossRoots(sel);\n var ready = [];\n for (var i = 0; i < rawHits.length; i++) {\n var h = rawHits[i];\n var m = toMatch(h);\n if (!m.visible) continue;\n if (forAction && !m.enabled) continue;\n ready.push({ hit: h, match: m });\n }\n return ready.length > 0 ? ready : null;\n }\n\n function checkActionableNow() {\n var ready = findCandidates();\n if (!ready) return null;\n if (!forAction) return ready.map(function(r) { return r.match; });\n var target = ready[ready.length - 1];\n var didScroll = ensureInViewport(target.hit);\n if (checkHitTest && !isHitTestClear(target.hit)) {\n if (scrollToUnobscure(target.hit)) {\n didScroll = true;\n }\n if (!isHitTestClear(target.hit)) return null;\n }\n var updated = toMatch(target.hit);\n if (!updated.visible || !updated.enabled) return null;\n return { hits: ready, target: target, match: updated, didScroll: didScroll };\n }\n\n function neededStableFrames(candidate) {\n if (!forAction || typeof requestAnimationFrame !== \"function\") return 0;\n if (explicitStableFrames >= 0) return explicitStableFrames;\n if (hasActiveAnimation(candidate.target.hit.el)) return 2;\n if (candidate.didScroll) return 1;\n return 0;\n }\n\n var imm = checkActionableNow();\n if (imm) {\n if (!forAction) return imm;\n if (neededStableFrames(imm) <= 0) return [imm.match];\n }\n\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n var idleTimer = null;\n var rafId = null;\n var checkingStability = false;\n\n function finish(result) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n if (idleTimer) clearTimeout(idleTimer);\n if (rafId !== null && typeof cancelAnimationFrame === \"function\") {\n try { cancelAnimationFrame(rafId); } catch (e) {}\n }\n resolve(result);\n }\n\n function armIdleTimer() {\n if (!failFastWhenIdle) return;\n if (idleTimer) clearTimeout(idleTimer);\n idleTimer = setTimeout(function() {\n if (document.readyState === \"complete\" && (!waitForAppReady || isAppReady())) {\n var hit = checkActionableNow();\n finish(hit ? (forAction ? [hit.match] : hit) : []);\n } else {\n armIdleTimer();\n }\n }, idleQuietMs);\n }\n\n function verifyStability(candidate) {\n if (done || checkingStability) return;\n var framesToWait = neededStableFrames(candidate);\n if (!forAction || framesToWait <= 0 || typeof requestAnimationFrame !== \"function\") {\n finish(forAction ? [candidate.match] : candidate);\n return;\n }\n checkingStability = true;\n var el = candidate.target.hit.el;\n var lastRect = candidate.match.rect;\n var remainingFrames = framesToWait;\n\n function step() {\n if (done) return;\n if (!el.isConnected) { checkingStability = false; return; }\n if (checkHitTest && !isHitTestClear(candidate.target.hit)) { checkingStability = false; return; }\n var cur = toMatch(candidate.target.hit);\n if (!cur.visible || !cur.enabled) { checkingStability = false; return; }\n var dx = Math.abs(cur.rect.x - lastRect.x);\n var dy = Math.abs(cur.rect.y - lastRect.y);\n var dw = Math.abs(cur.rect.width - lastRect.width);\n var dh = Math.abs(cur.rect.height - lastRect.height);\n if (dx <= 1 && dy <= 1 && dw <= 1 && dh <= 1) {\n remainingFrames -= 1;\n if (remainingFrames <= 0) { finish([cur]); return; }\n } else {\n remainingFrames = framesToWait;\n lastRect = cur.rect;\n }\n rafId = requestAnimationFrame(step);\n }\n rafId = requestAnimationFrame(step);\n }\n\n function attempt() {\n if (done || checkingStability) return;\n var hit = checkActionableNow();\n if (hit) {\n if (forAction) verifyStability(hit);\n else finish(hit);\n return;\n }\n armIdleTimer();\n }\n\n var scheduled = false;\n function scheduleAttempt() {\n if (done || scheduled || checkingStability) return;\n scheduled = true;\n Promise.resolve().then(function() { scheduled = false; attempt(); });\n }\n\n timeoutTimer = setTimeout(function() {\n var finalHit = checkActionableNow();\n finish(finalHit ? (forAction ? [finalHit.match] : finalHit) : []);\n }, timeoutMs);\n fallbackInterval = setInterval(attempt, forAction ? 40 : 120);\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(scheduleAttempt);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n attempt();\n });\n }\n\n function waitForHidden(sel, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n function isHiddenNow() {\n var hits = findAcrossRoots(sel);\n for (var i = 0; i < hits.length; i++) {\n if (toMatch(hits[i]).visible) return false;\n }\n return true;\n }\n if (isHiddenNow()) return true;\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n function finish(val) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n resolve(val);\n }\n function onChange() { if (isHiddenNow()) finish(true); }\n timeoutTimer = setTimeout(function() { finish(isHiddenNow()); }, timeoutMs);\n fallbackInterval = setInterval(onChange, 120);\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(onChange);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n });\n }\n\n function waitForMatch(sel, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n var kind = opts.kind;\n var expected = opts.expected !== undefined ? opts.expected : null;\n var expectedCount = opts.expectedCount !== undefined ? opts.expectedCount : null;\n var attributeName = opts.attributeName !== undefined ? opts.attributeName : null;\n var patternSource = opts.patternSource !== undefined ? opts.patternSource : null;\n var patternFlags = opts.patternFlags || \"\";\n var negate = Boolean(opts.negate);\n var lastActual = undefined;\n var regex = patternSource !== null ? new RegExp(patternSource, patternFlags) : null;\n\n function evaluateMatch() {\n if (kind === \"url\") {\n var href = typeof window !== \"undefined\" && window.location ? String(window.location.href || \"\") : \"\";\n lastActual = href;\n var urlOk = regex\n ? regex.test(href)\n : (expected !== null && (href === expected || href.indexOf(String(expected)) !== -1));\n if (negate ? !urlOk : urlOk) return { matched: true, actual: href };\n return null;\n }\n\n var hits = findAcrossRoots(sel);\n\n if (kind === \"count\") {\n var visibleCount = 0;\n for (var ci = 0; ci < hits.length; ci++) {\n if (toMatch(hits[ci]).visible) visibleCount++;\n }\n lastActual = String(visibleCount);\n var countOk = expectedCount !== null && visibleCount === expectedCount;\n if (negate ? !countOk : countOk) {\n return { matched: true, actual: String(visibleCount) };\n }\n return null;\n }\n\n for (var i = hits.length - 1; i >= 0; i--) {\n var m = toMatch(hits[i]);\n if (!m.visible) continue;\n var matched = false;\n var actualVal = undefined;\n if (kind === \"text\") {\n var normTxt = m.textContent !== undefined ? m.textContent : (m.text || \"\");\n actualVal = normTxt;\n matched = normTxt === (expected !== null ? String(expected).replace(/\\s+/g, \" \").trim() : expected);\n } else if (kind === \"containsText\") {\n var actual = m.textContent !== undefined ? m.textContent : (m.text || \"\");\n actualVal = actual;\n matched = expected !== null && actual.toLowerCase().indexOf(String(expected).replace(/\\s+/g, \" \").trim().toLowerCase()) !== -1;\n } else if (kind === \"matchesText\") {\n var actualRe = m.textContent !== undefined ? m.textContent : (m.text || \"\");\n actualVal = actualRe;\n matched = Boolean(regex && regex.test(actualRe));\n } else if (kind === \"value\") {\n var val = m.value !== undefined ? m.value : \"\";\n actualVal = val;\n matched = val === expected;\n } else if (kind === \"attribute\" && attributeName !== null) {\n var attrVal = m.attributes ? m.attributes[attributeName] : undefined;\n actualVal = attrVal;\n matched = expected === null ? attrVal !== undefined : attrVal === expected;\n } else if (kind === \"accessibilityLabel\") {\n var lbl = m.accessibilityLabel;\n actualVal = lbl;\n matched = expected === null ? (lbl !== undefined && lbl.length > 0) : lbl === expected;\n } else if (kind === \"accessibleName\") {\n var accName = m.accessibleName || m.accessibilityLabel || m.text || \"\";\n actualVal = accName;\n matched = regex ? regex.test(accName) : (expected === null ? accName.length > 0 : accName.trim() === String(expected).trim());\n } else if (kind === \"accessibleDescription\") {\n var accDesc = m.accessibleDescription || \"\";\n actualVal = accDesc;\n matched = regex ? regex.test(accDesc) : (expected === null ? accDesc.length > 0 : accDesc.trim() === String(expected).trim());\n } else if (kind === \"focused\") {\n actualVal = m.focused ? \"focused\" : \"not focused\";\n matched = Boolean(m.focused);\n }\n lastActual = actualVal;\n if (negate ? !matched : matched) return { matched: true, actual: actualVal };\n }\n return null;\n }\n\n var immediate = evaluateMatch();\n if (immediate) return immediate;\n\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n var scheduled = false;\n function finish(res) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n if (typeof document !== \"undefined\") {\n document.removeEventListener(\"input\", onChange, true);\n document.removeEventListener(\"change\", onChange, true);\n document.removeEventListener(\"focusin\", onChange, true);\n document.removeEventListener(\"focusout\", onChange, true);\n }\n if (typeof window !== \"undefined\") {\n window.removeEventListener(\"popstate\", onChange);\n window.removeEventListener(\"hashchange\", onChange);\n }\n resolve(res);\n }\n function onChange() {\n if (done || scheduled) return;\n scheduled = true;\n Promise.resolve().then(function() {\n scheduled = false;\n if (done) return;\n var res = evaluateMatch();\n if (res) finish(res);\n });\n }\n timeoutTimer = setTimeout(function() {\n var finalRes = evaluateMatch();\n finish(finalRes || { matched: false, actual: lastActual });\n }, timeoutMs);\n fallbackInterval = setInterval(onChange, kind === \"url\" ? 50 : 120);\n if (typeof document !== \"undefined\") {\n document.addEventListener(\"input\", onChange, true);\n document.addEventListener(\"change\", onChange, true);\n document.addEventListener(\"focusin\", onChange, true);\n document.addEventListener(\"focusout\", onChange, true);\n }\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"popstate\", onChange);\n window.addEventListener(\"hashchange\", onChange);\n }\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(onChange);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n });\n }\n\n function fill(sel, val, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n var checkHitTest = opts.checkHitTest !== undefined ? Boolean(opts.checkHitTest) : true;\n function writeValue(el) {\n if (el.isContentEditable) return false;\n if (typeof el.focus === \"function\") { try { el.focus(); } catch (e) {} }\n var tag = el.tagName;\n if (tag === \"INPUT\" || tag === \"TEXTAREA\") {\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var proto = tag === \"TEXTAREA\"\n ? (win.HTMLTextAreaElement && win.HTMLTextAreaElement.prototype)\n : (win.HTMLInputElement && win.HTMLInputElement.prototype);\n var desc = proto ? Object.getOwnPropertyDescriptor(proto, \"value\") : null;\n if (desc && typeof desc.set === \"function\") desc.set.call(el, val);\n else el.value = val;\n if (el._valueTracker && typeof el._valueTracker.setValue === \"function\") {\n try { el._valueTracker.setValue(val === \"\" ? \" \" : \"\"); } catch (e) {}\n }\n } else if (tag === \"SELECT\") {\n el.value = val;\n } else {\n el.value = val;\n }\n try { el.dispatchEvent(new InputEvent(\"input\", { bubbles: true, cancelable: true, data: val, inputType: \"insertText\" })); }\n catch (e) { el.dispatchEvent(new Event(\"input\", { bubbles: true, cancelable: true })); }\n el.dispatchEvent(new Event(\"change\", { bubbles: true, cancelable: true }));\n return true;\n }\n function findEditableNow() {\n if (!isAppReady()) return null;\n var hits = findAcrossRoots(sel);\n for (var i = hits.length - 1; i >= 0; i--) {\n var h = hits[i];\n var m = toMatch(h);\n if (!m.visible || !m.enabled) continue;\n ensureInViewport(h);\n if (checkHitTest && !isHitTestClear(h)) {\n scrollToUnobscure(h);\n if (!isHitTestClear(h)) continue;\n }\n return h.el;\n }\n return null;\n }\n function verifyAndRetryFill(attemptsLeft) {\n var el = findEditableNow();\n if (!el || el.isContentEditable) return Promise.resolve(false);\n if (!writeValue(el)) return Promise.resolve(false);\n return new Promise(function(resolve) {\n setTimeout(function() {\n var latest = findEditableNow() || el;\n if (latest && latest.isConnected && String(latest.value == null ? \"\" : latest.value) === val) {\n resolve(true);\n return;\n }\n if (attemptsLeft > 1) {\n verifyAndRetryFill(attemptsLeft - 1).then(resolve);\n } else {\n resolve(false);\n }\n }, 12);\n });\n }\n var immEl = findEditableNow();\n if (immEl) {\n if (immEl.isContentEditable) return false;\n return verifyAndRetryFill(3);\n }\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n var scheduled = false;\n var filling = false;\n function finish(ok) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n resolve(ok);\n }\n function onChange() {\n if (done || scheduled || filling) return;\n scheduled = true;\n Promise.resolve().then(function() {\n scheduled = false;\n if (done || filling) return;\n var target = findEditableNow();\n if (!target) return;\n if (target.isContentEditable) { finish(false); return; }\n filling = true;\n verifyAndRetryFill(3).then(function(ok) { finish(ok); });\n });\n }\n timeoutTimer = setTimeout(function() {\n if (filling) return;\n var target = findEditableNow();\n if (!target || target.isContentEditable) { finish(false); return; }\n filling = true;\n verifyAndRetryFill(2).then(function(ok) { finish(ok); });\n }, timeoutMs);\n fallbackInterval = setInterval(onChange, 40);\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(onChange);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n });\n }\n\n window.__spanaRt = {\n query: query,\n scrollIntoView: scrollIntoView,\n tap: tap,\n waitForSelector: waitForSelector,\n waitForHidden: waitForHidden,\n waitForMatch: waitForMatch,\n fill: fill\n };\n return true;\n})();";
|
|
344
|
+
declare const SPANA_INJECTED_RUNTIME_SCRIPT = "(function() {\n if (typeof window === \"undefined\" || window.__spanaRt) return true;\n \n function matchSpec(actual, spec, exact) {\n var str = String(actual || \"\");\n if (spec && typeof spec === \"object\" && typeof spec.__spanaRegex === \"string\") {\n try { return new RegExp(spec.__spanaRegex, spec.flags || \"\").test(str); } catch (e) { return false; }\n }\n var needle = String(spec == null ? \"\" : spec);\n if (exact) return str.trim() === needle.trim();\n return str.toLowerCase().indexOf(needle.toLowerCase()) !== -1;\n }\n function getImplicitRole(el) {\n if (!el || !el.getAttribute) return \"\";\n var explicit = (el.getAttribute(\"role\") || \"\").trim().toLowerCase();\n if (explicit) return explicit.split(/\\s+/)[0] || \"\";\n var tag = el.tagName ? el.tagName.toUpperCase() : \"\";\n if (tag === \"BUTTON\") return \"button\";\n if (tag === \"A\") return el.hasAttribute(\"href\") ? \"link\" : \"\";\n if (tag === \"TEXTAREA\") return \"textbox\";\n if (tag === \"SELECT\") return (el.hasAttribute(\"multiple\") || Number(el.getAttribute(\"size\") || 0) > 1) ? \"listbox\" : \"combobox\";\n if (tag === \"OPTION\") return \"option\";\n if (tag === \"IMG\") return el.getAttribute(\"alt\") === \"\" ? \"presentation\" : \"img\";\n if (tag === \"DIALOG\") return \"dialog\";\n if (tag === \"NAV\") return \"navigation\";\n if (tag === \"MAIN\") return \"main\";\n if (tag === \"HEADER\") return \"banner\";\n if (tag === \"FOOTER\") return \"contentinfo\";\n if (tag === \"ASIDE\") return \"complementary\";\n if (tag === \"UL\" || tag === \"OL\") return \"list\";\n if (tag === \"LI\") return \"listitem\";\n if (tag === \"TABLE\") return \"table\";\n if (tag === \"TR\") return \"row\";\n if (tag === \"TD\") return \"cell\";\n if (tag === \"TH\") return \"columnheader\";\n if (tag === \"ARTICLE\") return \"article\";\n if (tag === \"FORM\") return \"form\";\n if (tag === \"PROGRESS\") return \"progressbar\";\n if (tag === \"HR\") return \"separator\";\n if (tag === \"SECTION\") return (el.hasAttribute(\"aria-label\") || el.hasAttribute(\"aria-labelledby\")) ? \"region\" : \"\";\n if (/^H[1-6]$/.test(tag)) return \"heading\";\n if (tag === \"INPUT\") {\n var t = (el.getAttribute(\"type\") || \"text\").toLowerCase();\n if (t === \"button\" || t === \"submit\" || t === \"reset\" || t === \"image\") return \"button\";\n if (t === \"checkbox\") return \"checkbox\";\n if (t === \"radio\") return \"radio\";\n if (t === \"search\") return \"searchbox\";\n if (t === \"number\") return \"spinbutton\";\n if (t === \"range\") return \"slider\";\n if (t === \"hidden\") return \"\";\n return \"textbox\";\n }\n return \"\";\n }\n function visibleTextOf(node, allowHiddenRoot, skipControl) {\n if (!node) return \"\";\n if (node.nodeType === 3) return node.nodeValue || \"\";\n if (node.nodeType !== 1 && node.nodeType !== 11) return \"\";\n if (node.nodeType === 1) {\n if (skipControl && node === skipControl) return \"\";\n var t = node.tagName ? node.tagName.toUpperCase() : \"\";\n if (t === \"SCRIPT\" || t === \"STYLE\" || t === \"NOSCRIPT\" || t === \"TEMPLATE\") return \"\";\n if (skipControl && (t === \"SELECT\" || t === \"TEXTAREA\" || t === \"INPUT\")) return \"\";\n if (!allowHiddenRoot) {\n if (node.getAttribute && node.getAttribute(\"aria-hidden\") === \"true\") return \"\";\n var win = (node.ownerDocument && node.ownerDocument.defaultView) || window;\n if (win && win.getComputedStyle) {\n var st = win.getComputedStyle(node);\n if (st && (st.display === \"none\" || st.visibility === \"hidden\" || st.visibility === \"collapse\")) {\n return \"\";\n }\n }\n }\n }\n var out = [];\n if (node.shadowRoot) {\n var stxt = visibleTextOf(node.shadowRoot, false, skipControl);\n if (stxt) out.push(stxt);\n }\n var kids = node.childNodes || [];\n for (var i = 0; i < kids.length; i++) {\n var k = visibleTextOf(kids[i], false, skipControl);\n if (k) out.push(k);\n }\n return out.join(\" \").replace(/\\s+/g, \" \").trim();\n }\n function isAriaHidden(el) {\n if (!el) return true;\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var cur = el;\n var guard = 0;\n while (cur && guard++ < 32) {\n if (cur.getAttribute) {\n if (cur.getAttribute(\"aria-hidden\") === \"true\") return true;\n if (cur.hasAttribute && cur.hasAttribute(\"inert\")) return true;\n }\n if (cur.nodeType === 1 && win && win.getComputedStyle) {\n var cs = win.getComputedStyle(cur);\n if (cs && cs.display === \"none\") return true;\n }\n var root = typeof cur.getRootNode === \"function\" ? cur.getRootNode() : null;\n cur = cur.parentElement || (root && root.host) || null;\n }\n if (typeof el.checkVisibility === \"function\") {\n try {\n if (!el.checkVisibility({ visibilityProperty: true })) return true;\n } catch (e) {}\n } else if (win && win.getComputedStyle) {\n var selfCs = win.getComputedStyle(el);\n if (selfCs && (selfCs.visibility === \"hidden\" || selfCs.visibility === \"collapse\")) return true;\n }\n return false;\n }\n function headingLevelOf(el) {\n if (!el) return null;\n var explicit = el.getAttribute && el.getAttribute(\"aria-level\");\n if (explicit) {\n var parsed = parseInt(explicit, 10);\n if (!isNaN(parsed)) return parsed;\n }\n var tag = el.tagName ? el.tagName.toUpperCase() : \"\";\n var m = /^H([1-6])$/.exec(tag);\n return m ? parseInt(m[1], 10) : null;\n }\n function getAccessibleName(el) {\n if (!el) return \"\";\n var doc = el.ownerDocument || document;\n var labelledBy = el.getAttribute && el.getAttribute(\"aria-labelledby\");\n if (labelledBy) {\n var parts = [];\n var ids = labelledBy.trim().split(/\\s+/);\n for (var i = 0; i < ids.length; i++) {\n var ref = doc.getElementById ? doc.getElementById(ids[i]) : null;\n if (ref) {\n var rt = visibleTextOf(ref, true, null);\n if (rt) parts.push(rt);\n }\n }\n if (parts.length > 0) return parts.join(\" \").replace(/\\s+/g, \" \").trim();\n }\n var ariaLabel = el.getAttribute && el.getAttribute(\"aria-label\");\n if (ariaLabel && ariaLabel.trim()) return ariaLabel.trim();\n var tag = el.tagName ? el.tagName.toUpperCase() : \"\";\n if (tag === \"INPUT\" || tag === \"TEXTAREA\" || tag === \"SELECT\") {\n if (el.id && doc.querySelector) {\n try {\n var escId = typeof CSS !== \"undefined\" && CSS.escape ? CSS.escape(el.id) : el.id;\n var forLbl = doc.querySelector('label[for=\"' + escId + '\"]');\n if (forLbl) {\n var ft = visibleTextOf(forLbl, false, el);\n if (ft) return ft;\n }\n } catch (e) {}\n }\n if (el.closest) {\n var wrapLbl = el.closest(\"label\");\n if (wrapLbl) {\n var wt = visibleTextOf(wrapLbl, false, el);\n if (wt) return wt;\n }\n }\n var itype = tag === \"INPUT\" ? (el.getAttribute(\"type\") || \"text\").toLowerCase() : \"\";\n if ((itype === \"button\" || itype === \"submit\" || itype === \"reset\") && el.value) {\n return String(el.value).trim();\n }\n var ph = el.getAttribute && el.getAttribute(\"placeholder\");\n if (ph && ph.trim()) return ph.trim();\n }\n if (tag === \"IMG\") {\n var alt = el.getAttribute && el.getAttribute(\"alt\");\n if (alt && alt.trim()) return alt.trim();\n }\n var txt = visibleTextOf(el, false, null);\n if (txt) return txt;\n var title = el.getAttribute && el.getAttribute(\"title\");\n return title ? title.trim() : \"\";\n }\n function getAccessibleDescription(el) {\n if (!el) return \"\";\n var doc = el.ownerDocument || document;\n var describedBy = el.getAttribute && el.getAttribute(\"aria-describedby\");\n if (describedBy) {\n var parts = [];\n var ids = describedBy.trim().split(/\\s+/);\n for (var i = 0; i < ids.length; i++) {\n var ref = doc.getElementById ? doc.getElementById(ids[i]) : null;\n if (ref) {\n var rt = visibleTextOf(ref, true, null);\n if (rt) parts.push(rt);\n }\n }\n if (parts.length > 0) return parts.join(\" \").replace(/\\s+/g, \" \").trim();\n }\n var ariaDesc = el.getAttribute && el.getAttribute(\"aria-description\");\n if (ariaDesc && ariaDesc.trim()) return ariaDesc.trim();\n var title = el.getAttribute && el.getAttribute(\"title\");\n if (title && title.trim()) {\n var accName = getAccessibleName(el);\n if (accName && accName !== title.trim()) return title.trim();\n }\n return \"\";\n }\n function collectRoots(root, offsetX, offsetY, inShadow, inIframe, out) {\n if (!root) return;\n out.push({ root: root, offsetX: offsetX, offsetY: offsetY, inShadow: inShadow, inIframe: inIframe });\n if (root.shadowRoot) {\n collectRoots(root.shadowRoot, offsetX, offsetY, true, inIframe, out);\n }\n var nodes = root.querySelectorAll ? root.querySelectorAll(\"*\") : [];\n for (var i = 0; i < nodes.length; i++) {\n var el = nodes[i];\n if (el.shadowRoot) {\n collectRoots(el.shadowRoot, offsetX, offsetY, true, inIframe, out);\n }\n if (el.tagName === \"IFRAME\") {\n try {\n var frameDoc = el.contentDocument;\n if (frameDoc) {\n var frameRect = el.getBoundingClientRect();\n collectRoots(frameDoc, offsetX + frameRect.left, offsetY + frameRect.top, inShadow, true, out);\n }\n } catch (e) {}\n }\n }\n }\n function findTextInRoot(root, needle, exact, ctx, pushHit) {\n var doc = root.ownerDocument || (root.nodeType === 9 ? root : document);\n if (doc && typeof doc.createTreeWalker === \"function\" && typeof NodeFilter !== \"undefined\") {\n var walker = doc.createTreeWalker(root, NodeFilter.SHOW_TEXT);\n var txtNode;\n while ((txtNode = walker.nextNode())) {\n var rawVal = (txtNode.nodeValue || \"\").trim();\n var val = rawVal.toLowerCase();\n var ok = exact ? rawVal === needle : (val && val.indexOf(needle.toLowerCase()) !== -1);\n if (ok && txtNode.parentElement) {\n pushHit(txtNode.parentElement, ctx);\n }\n }\n if (typeof root.querySelectorAll === \"function\") {\n var inputs = root.querySelectorAll(\"input, button\");\n for (var ii = 0; ii < inputs.length; ii++) {\n var inp = inputs[ii];\n var rawInp = String(inp.value || \"\").trim();\n var inpOk = exact ? rawInp === needle : (rawInp && rawInp.toLowerCase().indexOf(needle.toLowerCase()) !== -1);\n if (inpOk) {\n pushHit(inp, ctx);\n }\n }\n }\n return;\n }\n var all = root.querySelectorAll ? root.querySelectorAll(\"*\") : [];\n for (var k = 0; k < all.length; k++) {\n var node = all[k];\n var directText = \"\";\n for (var c = 0; c < node.childNodes.length; c++) {\n if (node.childNodes[c].nodeType === 3) directText += node.childNodes[c].textContent || \"\";\n }\n var trimmedDirect = directText.trim();\n var inpVal = (node.tagName === \"INPUT\" || node.tagName === \"BUTTON\") ? String(node.value || \"\").trim() : \"\";\n var directOk = exact ? trimmedDirect === needle : (trimmedDirect && trimmedDirect.toLowerCase().indexOf(needle.toLowerCase()) !== -1);\n var inputOk = exact ? inpVal === needle : (inpVal && inpVal.toLowerCase().indexOf(needle.toLowerCase()) !== -1);\n if (directOk || inputOk) {\n pushHit(node, ctx);\n }\n }\n }\n function findRoleInRoot(root, roleLower, nameSpec, exact, ctx, pushHit, includeHidden, level) {\n if (!root || !root.querySelectorAll) return;\n var candidates = root.querySelectorAll(\"*\");\n for (var i = 0; i < candidates.length; i++) {\n var el = candidates[i];\n if (getImplicitRole(el) !== roleLower) continue;\n if (!includeHidden && isAriaHidden(el)) continue;\n if (level !== undefined && level !== null && headingLevelOf(el) !== Number(level)) continue;\n if (nameSpec !== undefined && nameSpec !== null) {\n var accName = getAccessibleName(el);\n if (!matchSpec(accName, nameSpec, Boolean(exact))) continue;\n }\n pushHit(el, ctx);\n }\n }\n function applyModifiersAndSlice(hits, sel) {\n if (!sel || typeof sel !== \"object\" || \"point\" in sel) return hits;\n var filtered = hits;\n if (sel.hasText !== undefined) {\n filtered = filtered.filter(function(h) {\n var txt = (h.el.innerText || h.el.textContent || h.el.value || getAccessibleName(h.el) || \"\");\n return matchSpec(txt, sel.hasText, false);\n });\n }\n if (sel.hasNotText !== undefined) {\n filtered = filtered.filter(function(h) {\n var txt = (h.el.innerText || h.el.textContent || h.el.value || getAccessibleName(h.el) || \"\");\n return !matchSpec(txt, sel.hasNotText, false);\n });\n }\n if (sel.has !== undefined) {\n filtered = filtered.filter(function(h) {\n return findInScope(sel.has, h.el, h.offsetX, h.offsetY, h.inShadow, h.inIframe).length > 0;\n });\n }\n if (sel.hasNot !== undefined) {\n filtered = filtered.filter(function(h) {\n return findInScope(sel.hasNot, h.el, h.offsetX, h.offsetY, h.inShadow, h.inIframe).length === 0;\n });\n }\n if (sel.first) return filtered.length > 0 ? [filtered[0]] : [];\n if (sel.last) return filtered.length > 0 ? [filtered[filtered.length - 1]] : [];\n if (typeof sel.nth === \"number\") {\n var idx = sel.nth < 0 ? filtered.length + sel.nth : sel.nth;\n return idx >= 0 && idx < filtered.length ? [filtered[idx]] : [];\n }\n return filtered;\n }\n function findInScope(sel, scopeRoot, baseOffsetX, baseOffsetY, baseInShadow, baseInIframe) {\n var hits = [];\n var seen = typeof Set !== \"undefined\" ? new Set() : null;\n function pushHit(el, ctx) {\n if (seen) {\n if (seen.has(el)) return;\n seen.add(el);\n }\n hits.push({ el: el, offsetX: ctx.offsetX, offsetY: ctx.offsetY, inShadow: ctx.inShadow, inIframe: ctx.inIframe });\n }\n if (typeof sel === \"object\" && sel !== null && \"point\" in sel) {\n var atPt = document.elementFromPoint(sel.point.x, sel.point.y);\n if (atPt) pushHit(atPt, { offsetX: 0, offsetY: 0, inShadow: false, inIframe: false });\n return hits;\n }\n // Frame scoping: find matching <iframe> first, then search inside its contentDocument\n if (typeof sel === \"object\" && sel !== null && sel.frame) {\n var frameHits = findInScope(sel.frame, scopeRoot, baseOffsetX, baseOffsetY, baseInShadow, baseInIframe);\n var innerSel = Object.assign({}, sel);\n delete innerSel.frame;\n for (var fi = 0; fi < frameHits.length; fi++) {\n var fEl = frameHits[fi].el;\n if (fEl && fEl.tagName === \"IFRAME\") {\n try {\n var fDoc = fEl.contentDocument;\n if (fDoc) {\n var fRect = fEl.getBoundingClientRect();\n var sub = findInScope(innerSel, fDoc, frameHits[fi].offsetX + fRect.left, frameHits[fi].offsetY + fRect.top, frameHits[fi].inShadow, true);\n for (var si = 0; si < sub.length; si++) pushHit(sub[si].el, sub[si]);\n }\n } catch (e) {}\n }\n }\n return hits;\n }\n // Parent scoping: resolve 'within' first, then search inside each matched container\n if (typeof sel === \"object\" && sel !== null && sel.within) {\n var parentHits = findInScope(sel.within, scopeRoot, baseOffsetX, baseOffsetY, baseInShadow, baseInIframe);\n var childSel = Object.assign({}, sel);\n delete childSel.within;\n delete childSel.hasText;\n delete childSel.hasNotText;\n delete childSel.has;\n delete childSel.hasNot;\n delete childSel.first;\n delete childSel.last;\n delete childSel.nth;\n var combined = [];\n var cSeen = typeof Set !== \"undefined\" ? new Set() : null;\n for (var pi = 0; pi < parentHits.length; pi++) {\n var ph = parentHits[pi];\n var subHits = findInScope(childSel, ph.el, ph.offsetX, ph.offsetY, ph.inShadow, ph.inIframe);\n for (var ci = 0; ci < subHits.length; ci++) {\n if (cSeen && cSeen.has(subHits[ci].el)) continue;\n if (cSeen) cSeen.add(subHits[ci].el);\n combined.push(subHits[ci]);\n }\n }\n return applyModifiersAndSlice(combined, sel);\n }\n // Logical OR composition (anyOf): union deduplicated hits across branches\n if (typeof sel === \"object\" && sel !== null && Array.isArray(sel.anyOf)) {\n for (var bi = 0; bi < sel.anyOf.length; bi++) {\n var branchHits = findInScope(sel.anyOf[bi], scopeRoot, baseOffsetX, baseOffsetY, baseInShadow, baseInIframe);\n for (var bh = 0; bh < branchHits.length; bh++) {\n pushHit(branchHits[bh].el, branchHits[bh]);\n }\n }\n return applyModifiersAndSlice(hits, sel);\n }\n\n var esc = function(v) {\n return typeof CSS !== \"undefined\" && CSS.escape ? CSS.escape(v) : String(v).replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"');\n };\n var mainCtx = { root: scopeRoot, offsetX: baseOffsetX, offsetY: baseOffsetY, inShadow: baseInShadow, inIframe: baseInIframe };\n 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\");\n\n // O(1)-ish Light-DOM fast path: avoids scanning thousands of nodes with querySelectorAll(\"*\")\n // unless Shadow DOM / iframe piercing is needed or no Light-DOM match exists.\n if (scopeRoot && scopeRoot.querySelectorAll && !hasModifiers) {\n if (typeof sel === \"object\" && sel !== null && \"testID\" in sel) {\n var fastTid = esc(sel.testID);\n var fastFound = scopeRoot.querySelectorAll('[data-testid=\"' + fastTid + '\"], [testID=\"' + fastTid + '\"]');\n if (fastFound.length > 0) {\n for (var fi2 = 0; fi2 < fastFound.length; fi2++) pushHit(fastFound[fi2], mainCtx);\n return hits;\n }\n } else if (typeof sel === \"object\" && sel !== null && \"css\" in sel) {\n try {\n var fastCss = scopeRoot.querySelectorAll(sel.css);\n if (fastCss.length > 0) {\n for (var fc = 0; fc < fastCss.length; fc++) pushHit(fastCss[fc], mainCtx);\n return hits;\n }\n } catch (e) {}\n } else if (typeof sel === \"object\" && sel !== null && \"accessibilityLabel\" in sel) {\n var fastLbl = esc(sel.accessibilityLabel);\n var fastFoundLbl = scopeRoot.querySelectorAll('[aria-label=\"' + fastLbl + '\"]');\n if (fastFoundLbl.length > 0) {\n for (var fj = 0; fj < fastFoundLbl.length; fj++) pushHit(fastFoundLbl[fj], mainCtx);\n return hits;\n }\n } else if (typeof sel === \"object\" && sel !== null && \"role\" in sel) {\n findRoleInRoot(scopeRoot, String(sel.role).toLowerCase(), sel.name, sel.exact, mainCtx, pushHit, sel.includeHidden, sel.level);\n if (hits.length > 0) return hits;\n } else if (typeof sel === \"string\" || (typeof sel === \"object\" && sel !== null && \"text\" in sel)) {\n var fastNeedle = typeof sel === \"string\" ? sel : sel.text;\n var fastExact = typeof sel === \"object\" && sel !== null && Boolean(sel.exact);\n findTextInRoot(scopeRoot, fastNeedle, fastExact, mainCtx, pushHit);\n if (hits.length > 0) return hits;\n }\n }\n\n var roots = [];\n collectRoots(scopeRoot, baseOffsetX, baseOffsetY, baseInShadow, baseInIframe, roots);\n for (var r = 0; r < roots.length; r++) {\n var ctx = roots[r];\n var root = ctx.root;\n if (!root || !root.querySelectorAll) continue;\n if (typeof sel === \"object\" && sel !== null && \"testID\" in sel) {\n var tid = esc(sel.testID);\n var found = root.querySelectorAll('[data-testid=\"' + tid + '\"], [testID=\"' + tid + '\"]');\n for (var i = 0; i < found.length; i++) pushHit(found[i], ctx);\n } else if (typeof sel === \"object\" && sel !== null && \"css\" in sel) {\n try {\n var foundCss = root.querySelectorAll(sel.css);\n for (var ci2 = 0; ci2 < foundCss.length; ci2++) pushHit(foundCss[ci2], ctx);\n } catch (e) {}\n } else if (typeof sel === \"object\" && sel !== null && \"accessibilityLabel\" in sel) {\n var lbl = esc(sel.accessibilityLabel);\n var foundLbl = root.querySelectorAll('[aria-label=\"' + lbl + '\"]');\n for (var j = 0; j < foundLbl.length; j++) pushHit(foundLbl[j], ctx);\n } else if (typeof sel === \"object\" && sel !== null && \"role\" in sel) {\n findRoleInRoot(root, String(sel.role).toLowerCase(), sel.name, sel.exact, ctx, pushHit, sel.includeHidden, sel.level);\n } else if (typeof sel === \"string\" || (typeof sel === \"object\" && sel !== null && \"text\" in sel)) {\n var needle = typeof sel === \"string\" ? sel : sel.text;\n var isExact = typeof sel === \"object\" && sel !== null && Boolean(sel.exact);\n findTextInRoot(root, needle, isExact, ctx, pushHit);\n }\n }\n return applyModifiersAndSlice(hits, sel);\n }\n function findAcrossRoots(sel) {\n return findInScope(sel, document, 0, 0, false, false);\n }\n function isClickable(el) {\n var tag = el.tagName;\n if (tag === \"BUTTON\" || tag === \"A\" || tag === \"INPUT\" || tag === \"SELECT\" || tag === \"TEXTAREA\") return true;\n var role = el.getAttribute && el.getAttribute(\"role\");\n if (role === \"button\" || role === \"link\" || role === \"tab\" || role === \"checkbox\" || role === \"switch\") return true;\n if (typeof el.onclick === \"function\") return true;\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var cursor = win.getComputedStyle(el).cursor;\n return cursor === \"pointer\";\n }\n function isAppReady() {\n var sig = typeof window !== \"undefined\" ? window.__SPANA_APP_READY__ : undefined;\n if (typeof sig === \"function\") {\n try { return Boolean(sig()); } catch (e) { return false; }\n }\n if (typeof sig === \"boolean\") return sig;\n return true;\n }\n function deepElementFromPoint(rootDoc, x, y) {\n if (!rootDoc || typeof rootDoc.elementFromPoint !== \"function\") return null;\n var el = rootDoc.elementFromPoint(x, y);\n var guard = 0;\n while (el && guard++ < 16) {\n if (el.shadowRoot && typeof el.shadowRoot.elementFromPoint === \"function\") {\n var inner = el.shadowRoot.elementFromPoint(x, y);\n if (inner && inner !== el) { el = inner; continue; }\n }\n if (el.tagName === \"IFRAME\") {\n try {\n var fdoc = el.contentDocument;\n if (fdoc && typeof fdoc.elementFromPoint === \"function\") {\n var fr = el.getBoundingClientRect();\n var fx = x - fr.left;\n var fy = y - fr.top;\n var fEl = fdoc.elementFromPoint(fx, fy);\n if (fEl && fEl !== el) { el = fEl; x = fx; y = fy; continue; }\n }\n } catch (e) {}\n }\n break;\n }\n return el;\n }\n function labelControlOf(node) {\n var cur = node;\n var guard = 0;\n while (cur && guard++ < 8) {\n if (cur.tagName === \"LABEL\") return cur.control || null;\n cur = cur.parentElement;\n }\n return null;\n }\n function isSameOrDescendant(target, candidate) {\n if (!target || !candidate) return false;\n if (target === candidate) return true;\n try {\n if (typeof target.contains === \"function\" && target.contains(candidate)) return true;\n } catch (e) {}\n if (labelControlOf(candidate) === target) return true;\n var cur = candidate;\n var guard = 0;\n while (cur && guard++ < 24) {\n if (cur === target) return true;\n var root = typeof cur.getRootNode === \"function\" ? cur.getRootNode() : null;\n if (root && root.host) {\n cur = root.host;\n } else {\n cur = cur.parentElement;\n }\n }\n return false;\n }\n function describeEl(el) {\n if (!el) return \"(unknown)\";\n var tag = el.tagName ? el.tagName.toLowerCase() : \"element\";\n var idPart = el.id ? \"#\" + el.id : \"\";\n var cls = typeof el.className === \"string\" ? el.className.trim().split(/\\s+/).filter(Boolean).slice(0, 3).join(\".\") : \"\";\n var clsPart = cls ? \".\" + cls : \"\";\n var txt = (el.innerText || el.textContent || \"\").replace(/\\s+/g, \" \").trim();\n if (txt.length > 40) txt = txt.slice(0, 37) + \"...\";\n return \"<\" + tag + idPart + clsPart + (txt ? \">\" + txt + \"</\" + tag + \">\" : \">\");\n }\n function getHitTestBlocker(hit) {\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var vw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0;\n var vh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0;\n var cx = rect.left + hit.offsetX + rect.width / 2;\n var cy = rect.top + hit.offsetY + rect.height / 2;\n if (vw > 0 && vh > 0 && (cx < 0 || cy < 0 || cx > vw || cy > vh)) {\n return \"outside viewport\";\n }\n var topEl = deepElementFromPoint(document, cx, cy);\n if (!topEl) return null;\n if (isSameOrDescendant(el, topEl)) return null;\n return describeEl(topEl);\n }\n function isHitTestClear(hit) {\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var vw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0;\n var vh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0;\n var cx = rect.left + hit.offsetX + rect.width / 2;\n var cy = rect.top + hit.offsetY + rect.height / 2;\n if (vw > 0 && vh > 0 && (cx < 0 || cy < 0 || cx > vw || cy > vh)) {\n return false;\n }\n var topEl = deepElementFromPoint(document, cx, cy);\n if (!topEl) return true;\n return isSameOrDescendant(el, topEl);\n }\n function ensureInViewport(hit) {\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var vw = (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0;\n var vh = (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0;\n var cx = rect.left + hit.offsetX + rect.width / 2;\n var cy = rect.top + hit.offsetY + rect.height / 2;\n if (vw > 0 && vh > 0 && (cx < 1 || cy < 1 || cx > vw - 1 || cy > vh - 1)) {\n if (typeof el.scrollIntoView === \"function\") {\n try { el.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"instant\" }); }\n catch (e) { try { el.scrollIntoView(true); } catch (e2) {} }\n }\n return true;\n }\n return false;\n }\n function scrollToUnobscure(hit) {\n var el = hit.el;\n if (typeof el.scrollIntoView !== \"function\") return false;\n var blocks = [\"center\", \"end\", \"start\", \"nearest\"];\n for (var i = 0; i < blocks.length; i++) {\n try {\n el.scrollIntoView({ block: blocks[i], inline: \"center\", behavior: \"instant\" });\n } catch (e) {\n try { el.scrollIntoView(true); } catch (e2) {}\n }\n if (isHitTestClear(hit)) return true;\n }\n return false;\n }\n function hasActiveAnimation(el) {\n var cur = el;\n var depth = 0;\n while (cur && depth++ < 8) {\n if (typeof cur.getAnimations === \"function\") {\n try {\n var anims = cur.getAnimations();\n for (var i = 0; i < anims.length; i++) {\n if (anims[i] && anims[i].playState === \"running\") return true;\n }\n } catch (e) {}\n }\n cur = cur.parentElement;\n }\n return false;\n }\n function isVisible(el, rect) {\n if (rect.width <= 0 || rect.height <= 0) return false;\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var style = win.getComputedStyle(el);\n if (style.display === \"none\" || style.visibility === \"hidden\" || parseFloat(style.opacity || \"1\") === 0) return false;\n return true;\n }\n function toMatch(hit) {\n var el = hit.el;\n var rect = el.getBoundingClientRect();\n var attrs = {};\n if (el.attributes) {\n for (var i = 0; i < el.attributes.length; i++) {\n attrs[el.attributes[i].name] = el.attributes[i].value;\n }\n }\n var tag = el.tagName ? el.tagName.toLowerCase() : undefined;\n var val = (el.tagName === \"INPUT\" || el.tagName === \"TEXTAREA\" || el.tagName === \"SELECT\")\n ? String(el.value ?? \"\")\n : undefined;\n var text = (el.innerText || el.textContent || \"\").trim() || undefined;\n var normTextContent = (el.textContent || \"\").replace(/\\s+/g, \" \").trim() || undefined;\n var accName = getAccessibleName(el) || undefined;\n var accDesc = getAccessibleDescription(el) || undefined;\n var role = getImplicitRole(el) || undefined;\n var isChecked =\n el.tagName === \"INPUT\" && (el.type === \"checkbox\" || el.type === \"radio\")\n ? Boolean(el.checked)\n : el.getAttribute(\"aria-checked\") === \"true\"\n ? true\n : el.getAttribute(\"aria-checked\") === \"false\"\n ? false\n : undefined;\n var isEditable = Boolean(\n !el.hasAttribute(\"disabled\") &&\n el.getAttribute(\"aria-disabled\") !== \"true\" &&\n !el.hasAttribute(\"readonly\") &&\n el.getAttribute(\"aria-readonly\") !== \"true\" &&\n (el.isContentEditable ||\n el.tagName === \"TEXTAREA\" ||\n el.tagName === \"SELECT\" ||\n (el.tagName === \"INPUT\" &&\n [\"button\", \"submit\", \"reset\", \"image\", \"hidden\", \"checkbox\", \"radio\"].indexOf(\n String(el.type || \"text\").toLowerCase(),\n ) === -1)),\n );\n var isEmpty =\n el.tagName === \"INPUT\" || el.tagName === \"TEXTAREA\"\n ? String(el.value || \"\").length === 0\n : (el.textContent || \"\").trim().length === 0;\n var clsName = typeof el.className === \"string\" ? el.className : (el.getAttribute(\"class\") || \"\");\n return {\n id: el.getAttribute(\"data-testid\") || el.getAttribute(\"testID\") || undefined,\n tag: tag,\n role: role,\n text: text,\n textContent: normTextContent,\n value: val,\n accessibilityLabel: el.getAttribute(\"aria-label\") || undefined,\n accessibleName: accName,\n accessibleDescription: accDesc,\n rect: { x: rect.x + hit.offsetX, y: rect.y + hit.offsetY, width: rect.width, height: rect.height },\n scrollX: window.scrollX || window.pageXOffset || 0,\n scrollY: window.scrollY || window.pageYOffset || 0,\n devicePixelRatio: window.devicePixelRatio || 1,\n viewportWidth: (window.visualViewport && window.visualViewport.width) || window.innerWidth || document.documentElement.clientWidth || 0,\n viewportHeight: (window.visualViewport && window.visualViewport.height) || window.innerHeight || document.documentElement.clientHeight || 0,\n visible: isVisible(el, rect),\n enabled: !el.hasAttribute(\"disabled\") && el.getAttribute(\"aria-disabled\") !== \"true\",\n clickable: isClickable(el),\n focused: document.activeElement === el,\n checked: isChecked,\n editable: isEditable,\n empty: isEmpty,\n className: clsName || undefined,\n attributes: attrs,\n inShadowDom: hit.inShadow || undefined,\n inIframe: hit.inIframe || undefined\n };\n }\n\n\n function query(sel) {\n return findAcrossRoots(sel).map(toMatch);\n }\n\n function scrollIntoView(sel) {\n var hits = findAcrossRoots(sel);\n if (hits.length === 0) return null;\n var hit = hits[hits.length - 1];\n if (typeof hit.el.scrollIntoView === \"function\") {\n try { hit.el.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"instant\" }); }\n catch (e) { try { hit.el.scrollIntoView(true); } catch (e2) {} }\n }\n return toMatch(hit);\n }\n\n function tap(sel) {\n var hits = findAcrossRoots(sel);\n if (hits.length === 0) return false;\n var hit = hits[hits.length - 1];\n var el = hit.el;\n if (typeof el.scrollIntoView === \"function\") {\n try { el.scrollIntoView({ block: \"center\", inline: \"center\", behavior: \"instant\" }); } catch (e) {}\n }\n var rect = el.getBoundingClientRect();\n var cx = rect.left + rect.width / 2;\n var cy = rect.top + rect.height / 2;\n var init = { bubbles: true, cancelable: true, composed: true, clientX: cx, clientY: cy };\n try { el.dispatchEvent(new PointerEvent(\"pointerdown\", init)); } catch (e) {}\n try { el.dispatchEvent(new MouseEvent(\"mousedown\", init)); } catch (e) {}\n if (typeof el.focus === \"function\") { try { el.focus(); } catch (e) {} }\n try { el.dispatchEvent(new PointerEvent(\"pointerup\", init)); } catch (e) {}\n try { el.dispatchEvent(new MouseEvent(\"mouseup\", init)); } catch (e) {}\n if (typeof el.click === \"function\") { el.click(); }\n else { el.dispatchEvent(new MouseEvent(\"click\", init)); }\n return true;\n }\n\n function waitForSelector(sel, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n var forAction = Boolean(opts.forAction);\n var failFastWhenIdle = Boolean(opts.failFastWhenIdle);\n var idleQuietMs = Math.max(50, Math.round(opts.idleQuietMs != null ? opts.idleQuietMs : 250));\n var reqStableFrames = opts.stableFrames !== undefined ? Math.max(0, Math.round(opts.stableFrames)) : (forAction ? 2 : 0);\n var checkHitTest = opts.checkHitTest !== undefined ? Boolean(opts.checkHitTest) : forAction;\n var waitForAppReady = opts.waitForAppReady !== undefined ? Boolean(opts.waitForAppReady) : true;\n var instantAnim = Boolean(typeof document !== \"undefined\" && document.getElementById && document.getElementById(\"__spana_instant_anim\"));\n var explicitStableFrames = instantAnim ? 0 : reqStableFrames;\n\n function findCandidates() {\n if (waitForAppReady && !isAppReady()) return null;\n var rawHits = findAcrossRoots(sel);\n var ready = [];\n for (var i = 0; i < rawHits.length; i++) {\n var h = rawHits[i];\n var m = toMatch(h);\n if (!m.visible) continue;\n if (forAction && !m.enabled) continue;\n ready.push({ hit: h, match: m });\n }\n return ready.length > 0 ? ready : null;\n }\n\n function checkActionableNow() {\n var ready = findCandidates();\n if (!ready) return null;\n if (!forAction) return ready.map(function(r) { return r.match; });\n var target = ready[ready.length - 1];\n var didScroll = ensureInViewport(target.hit);\n if (checkHitTest && !isHitTestClear(target.hit)) {\n if (scrollToUnobscure(target.hit)) {\n didScroll = true;\n }\n if (!isHitTestClear(target.hit)) return null;\n }\n var updated = toMatch(target.hit);\n if (!updated.visible || !updated.enabled) return null;\n return { hits: ready, target: target, match: updated, didScroll: didScroll };\n }\n\n function neededStableFrames(candidate) {\n if (!forAction || typeof requestAnimationFrame !== \"function\") return 0;\n if (explicitStableFrames >= 0) return explicitStableFrames;\n if (hasActiveAnimation(candidate.target.hit.el)) return 2;\n if (candidate.didScroll) return 1;\n return 0;\n }\n\n var imm = checkActionableNow();\n if (imm) {\n if (!forAction) return imm;\n if (neededStableFrames(imm) <= 0) return [imm.match];\n }\n\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n var idleTimer = null;\n var rafId = null;\n var checkingStability = false;\n\n function finish(result) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n if (idleTimer) clearTimeout(idleTimer);\n if (rafId !== null && typeof cancelAnimationFrame === \"function\") {\n try { cancelAnimationFrame(rafId); } catch (e) {}\n }\n resolve(result);\n }\n\n function armIdleTimer() {\n if (!failFastWhenIdle) return;\n if (idleTimer) clearTimeout(idleTimer);\n idleTimer = setTimeout(function() {\n if (document.readyState === \"complete\" && (!waitForAppReady || isAppReady())) {\n var hit = checkActionableNow();\n finish(hit ? (forAction ? [hit.match] : hit) : []);\n } else {\n armIdleTimer();\n }\n }, idleQuietMs);\n }\n\n function verifyStability(candidate) {\n if (done || checkingStability) return;\n var framesToWait = neededStableFrames(candidate);\n if (!forAction || framesToWait <= 0 || typeof requestAnimationFrame !== \"function\") {\n finish(forAction ? [candidate.match] : candidate);\n return;\n }\n checkingStability = true;\n var el = candidate.target.hit.el;\n var lastRect = candidate.match.rect;\n var remainingFrames = framesToWait;\n\n function step() {\n if (done) return;\n if (!el.isConnected) { checkingStability = false; return; }\n if (checkHitTest && !isHitTestClear(candidate.target.hit)) { checkingStability = false; return; }\n var cur = toMatch(candidate.target.hit);\n if (!cur.visible || !cur.enabled) { checkingStability = false; return; }\n var dx = Math.abs(cur.rect.x - lastRect.x);\n var dy = Math.abs(cur.rect.y - lastRect.y);\n var dw = Math.abs(cur.rect.width - lastRect.width);\n var dh = Math.abs(cur.rect.height - lastRect.height);\n if (dx <= 1 && dy <= 1 && dw <= 1 && dh <= 1) {\n remainingFrames -= 1;\n if (remainingFrames <= 0) { finish([cur]); return; }\n } else {\n remainingFrames = framesToWait;\n lastRect = cur.rect;\n }\n rafId = requestAnimationFrame(step);\n }\n rafId = requestAnimationFrame(step);\n }\n\n function attempt() {\n if (done || checkingStability) return;\n var hit = checkActionableNow();\n if (hit) {\n if (forAction) verifyStability(hit);\n else finish(hit);\n return;\n }\n armIdleTimer();\n }\n\n var scheduled = false;\n function scheduleAttempt() {\n if (done || scheduled || checkingStability) return;\n scheduled = true;\n Promise.resolve().then(function() { scheduled = false; attempt(); });\n }\n\n timeoutTimer = setTimeout(function() {\n var finalHit = checkActionableNow();\n finish(finalHit ? (forAction ? [finalHit.match] : finalHit) : []);\n }, timeoutMs);\n fallbackInterval = setInterval(attempt, forAction ? 40 : 120);\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(scheduleAttempt);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n attempt();\n });\n }\n\n function waitForHidden(sel, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n function isHiddenNow() {\n var hits = findAcrossRoots(sel);\n for (var i = 0; i < hits.length; i++) {\n if (toMatch(hits[i]).visible) return false;\n }\n return true;\n }\n if (isHiddenNow()) return true;\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n function finish(val) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n resolve(val);\n }\n function onChange() { if (isHiddenNow()) finish(true); }\n timeoutTimer = setTimeout(function() { finish(isHiddenNow()); }, timeoutMs);\n fallbackInterval = setInterval(onChange, 120);\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(onChange);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n });\n }\n\n function waitForMatch(sel, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n var kind = opts.kind;\n var expected = opts.expected !== undefined ? opts.expected : null;\n var expectedCount = opts.expectedCount !== undefined ? opts.expectedCount : null;\n var attributeName = opts.attributeName !== undefined ? opts.attributeName : null;\n var cssProperty = opts.cssProperty !== undefined ? opts.cssProperty : null;\n var patternSource = opts.patternSource !== undefined ? opts.patternSource : null;\n var patternFlags = opts.patternFlags || \"\";\n var negate = Boolean(opts.negate);\n var lastActual = undefined;\n var regex = patternSource !== null ? new RegExp(patternSource, patternFlags) : null;\n\n function evaluateMatch() {\n if (kind === \"url\") {\n var href = typeof window !== \"undefined\" && window.location ? String(window.location.href || \"\") : \"\";\n lastActual = href;\n var urlOk = regex\n ? regex.test(href)\n : (expected !== null && (href === expected || href.indexOf(String(expected)) !== -1));\n if (negate ? !urlOk : urlOk) return { matched: true, actual: href };\n return null;\n }\n if (kind === \"title\") {\n var docTitle = String(typeof document !== \"undefined\" ? (document.title || \"\") : \"\");\n lastActual = docTitle;\n var titleOk = regex ? regex.test(docTitle) : (expected !== null && docTitle === String(expected));\n if (negate ? !titleOk : titleOk) return { matched: true, actual: docTitle };\n return null;\n }\n\n var hits = findAcrossRoots(sel);\n\n if (kind === \"count\") {\n var visibleCount = 0;\n for (var ci = 0; ci < hits.length; ci++) {\n if (toMatch(hits[ci]).visible) visibleCount++;\n }\n lastActual = String(visibleCount);\n var countOk = expectedCount !== null && visibleCount === expectedCount;\n if (negate ? !countOk : countOk) {\n return { matched: true, actual: String(visibleCount) };\n }\n return null;\n }\n\n for (var i = hits.length - 1; i >= 0; i--) {\n var m = toMatch(hits[i]);\n if (!m.visible) continue;\n var matched = false;\n var actualVal = undefined;\n if (kind === \"text\") {\n var normTxt = m.textContent !== undefined ? m.textContent : (m.text || \"\");\n actualVal = normTxt;\n matched = normTxt === (expected !== null ? String(expected).replace(/\\s+/g, \" \").trim() : expected);\n } else if (kind === \"containsText\") {\n var actual = m.textContent !== undefined ? m.textContent : (m.text || \"\");\n actualVal = actual;\n matched = expected !== null && actual.toLowerCase().indexOf(String(expected).replace(/\\s+/g, \" \").trim().toLowerCase()) !== -1;\n } else if (kind === \"matchesText\") {\n var actualRe = m.textContent !== undefined ? m.textContent : (m.text || \"\");\n actualVal = actualRe;\n matched = Boolean(regex && regex.test(actualRe));\n } else if (kind === \"value\") {\n var val = m.value !== undefined ? m.value : \"\";\n actualVal = val;\n matched = val === expected;\n } else if (kind === \"attribute\" && attributeName !== null) {\n var attrVal = m.attributes ? m.attributes[attributeName] : undefined;\n actualVal = attrVal;\n matched = expected === null ? attrVal !== undefined : attrVal === expected;\n } else if (kind === \"accessibilityLabel\") {\n var lbl = m.accessibilityLabel;\n actualVal = lbl;\n matched = expected === null ? (lbl !== undefined && lbl.length > 0) : lbl === expected;\n } else if (kind === \"accessibleName\") {\n var accName = m.accessibleName || m.accessibilityLabel || m.text || \"\";\n actualVal = accName;\n matched = regex ? regex.test(accName) : (expected === null ? accName.length > 0 : accName.trim() === String(expected).trim());\n } else if (kind === \"accessibleDescription\") {\n var accDesc = m.accessibleDescription || \"\";\n actualVal = accDesc;\n matched = regex ? regex.test(accDesc) : (expected === null ? accDesc.length > 0 : accDesc.trim() === String(expected).trim());\n } else if (kind === \"focused\") {\n actualVal = m.focused ? \"focused\" : \"not focused\";\n matched = Boolean(m.focused);\n } else if (kind === \"checked\") {\n actualVal = m.checked ? \"checked\" : \"unchecked\";\n matched = Boolean(m.checked);\n } else if (kind === \"editable\") {\n actualVal = m.editable ? \"editable\" : \"not editable\";\n matched = Boolean(m.editable);\n } else if (kind === \"empty\") {\n actualVal = m.empty ? \"empty\" : (m.value || m.textContent || \"non-empty\");\n matched = Boolean(m.empty);\n } else if (kind === \"class\") {\n var cls = m.className || \"\";\n actualVal = cls;\n if (regex) {\n matched = regex.test(cls);\n } else if (expected !== null) {\n var tokens = cls.trim().split(/\\s+/).filter(Boolean);\n var expectedTokens = String(expected).trim().split(/\\s+/).filter(Boolean);\n matched = expectedTokens.length > 0 && expectedTokens.every(function(tok) { return tokens.indexOf(tok) !== -1; });\n }\n } else if (kind === \"css\" && cssProperty !== null) {\n var elNode = hits[i].el;\n var winObj = (elNode.ownerDocument && elNode.ownerDocument.defaultView) || window;\n var cssVal = winObj && winObj.getComputedStyle ? winObj.getComputedStyle(elNode).getPropertyValue(cssProperty).trim() : \"\";\n actualVal = cssVal;\n matched = regex ? regex.test(cssVal) : (expected !== null && cssVal === String(expected).trim());\n }\n lastActual = actualVal;\n if (negate ? !matched : matched) return { matched: true, actual: actualVal };\n }\n return null;\n }\n\n var immediate = evaluateMatch();\n if (immediate) return immediate;\n\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n var scheduled = false;\n function finish(res) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n if (typeof document !== \"undefined\") {\n document.removeEventListener(\"input\", onChange, true);\n document.removeEventListener(\"change\", onChange, true);\n document.removeEventListener(\"focusin\", onChange, true);\n document.removeEventListener(\"focusout\", onChange, true);\n }\n if (typeof window !== \"undefined\") {\n window.removeEventListener(\"popstate\", onChange);\n window.removeEventListener(\"hashchange\", onChange);\n }\n resolve(res);\n }\n function onChange() {\n if (done || scheduled) return;\n scheduled = true;\n Promise.resolve().then(function() {\n scheduled = false;\n if (done) return;\n var res = evaluateMatch();\n if (res) finish(res);\n });\n }\n timeoutTimer = setTimeout(function() {\n var finalRes = evaluateMatch();\n finish(finalRes || { matched: false, actual: lastActual });\n }, timeoutMs);\n fallbackInterval = setInterval(onChange, kind === \"url\" ? 50 : 120);\n if (typeof document !== \"undefined\") {\n document.addEventListener(\"input\", onChange, true);\n document.addEventListener(\"change\", onChange, true);\n document.addEventListener(\"focusin\", onChange, true);\n document.addEventListener(\"focusout\", onChange, true);\n }\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"popstate\", onChange);\n window.addEventListener(\"hashchange\", onChange);\n }\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(onChange);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n });\n }\n\n function fill(sel, val, opts) {\n opts = opts || {};\n var timeoutMs = Math.max(10, Math.round(opts.timeoutMs != null ? opts.timeoutMs : 5000));\n var checkHitTest = opts.checkHitTest !== undefined ? Boolean(opts.checkHitTest) : true;\n function writeValue(el) {\n if (el.isContentEditable) return false;\n if (typeof el.focus === \"function\") { try { el.focus(); } catch (e) {} }\n var tag = el.tagName;\n if (tag === \"INPUT\" || tag === \"TEXTAREA\") {\n var win = (el.ownerDocument && el.ownerDocument.defaultView) || window;\n var proto = tag === \"TEXTAREA\"\n ? (win.HTMLTextAreaElement && win.HTMLTextAreaElement.prototype)\n : (win.HTMLInputElement && win.HTMLInputElement.prototype);\n var desc = proto ? Object.getOwnPropertyDescriptor(proto, \"value\") : null;\n if (desc && typeof desc.set === \"function\") desc.set.call(el, val);\n else el.value = val;\n if (el._valueTracker && typeof el._valueTracker.setValue === \"function\") {\n try { el._valueTracker.setValue(val === \"\" ? \" \" : \"\"); } catch (e) {}\n }\n } else if (tag === \"SELECT\") {\n el.value = val;\n } else {\n el.value = val;\n }\n try { el.dispatchEvent(new InputEvent(\"input\", { bubbles: true, cancelable: true, data: val, inputType: \"insertText\" })); }\n catch (e) { el.dispatchEvent(new Event(\"input\", { bubbles: true, cancelable: true })); }\n el.dispatchEvent(new Event(\"change\", { bubbles: true, cancelable: true }));\n return true;\n }\n function findEditableNow() {\n if (!isAppReady()) return null;\n var hits = findAcrossRoots(sel);\n for (var i = hits.length - 1; i >= 0; i--) {\n var h = hits[i];\n var m = toMatch(h);\n if (!m.visible || !m.enabled) continue;\n ensureInViewport(h);\n if (checkHitTest && !isHitTestClear(h)) {\n scrollToUnobscure(h);\n if (!isHitTestClear(h)) continue;\n }\n return h.el;\n }\n return null;\n }\n function verifyAndRetryFill(attemptsLeft) {\n var el = findEditableNow();\n if (!el || el.isContentEditable) return Promise.resolve(false);\n if (!writeValue(el)) return Promise.resolve(false);\n return new Promise(function(resolve) {\n setTimeout(function() {\n var latest = findEditableNow() || el;\n if (latest && latest.isConnected && String(latest.value == null ? \"\" : latest.value) === val) {\n resolve(true);\n return;\n }\n if (attemptsLeft > 1) {\n verifyAndRetryFill(attemptsLeft - 1).then(resolve);\n } else {\n resolve(false);\n }\n }, 12);\n });\n }\n var immEl = findEditableNow();\n if (immEl) {\n if (immEl.isContentEditable) return false;\n return verifyAndRetryFill(3);\n }\n return new Promise(function(resolve) {\n var done = false;\n var observer = null;\n var timeoutTimer = null;\n var fallbackInterval = null;\n var scheduled = false;\n var filling = false;\n function finish(ok) {\n if (done) return;\n done = true;\n if (observer) { try { observer.disconnect(); } catch (e) {} }\n if (timeoutTimer) clearTimeout(timeoutTimer);\n if (fallbackInterval) clearInterval(fallbackInterval);\n resolve(ok);\n }\n function onChange() {\n if (done || scheduled || filling) return;\n scheduled = true;\n Promise.resolve().then(function() {\n scheduled = false;\n if (done || filling) return;\n var target = findEditableNow();\n if (!target) return;\n if (target.isContentEditable) { finish(false); return; }\n filling = true;\n verifyAndRetryFill(3).then(function(ok) { finish(ok); });\n });\n }\n timeoutTimer = setTimeout(function() {\n if (filling) return;\n var target = findEditableNow();\n if (!target || target.isContentEditable) { finish(false); return; }\n filling = true;\n verifyAndRetryFill(2).then(function(ok) { finish(ok); });\n }, timeoutMs);\n fallbackInterval = setInterval(onChange, 40);\n if (typeof MutationObserver !== \"undefined\") {\n var root = document.documentElement || document.body || document;\n if (root) {\n observer = new MutationObserver(onChange);\n observer.observe(root, { childList: true, subtree: true, attributes: true, characterData: true });\n }\n }\n });\n }\n\n window.__spanaRt = {\n query: query,\n scrollIntoView: scrollIntoView,\n tap: tap,\n waitForSelector: waitForSelector,\n waitForHidden: waitForHidden,\n waitForMatch: waitForMatch,\n fill: fill\n };\n return true;\n})();";
|
|
339
345
|
type InjectedRuntimeMethod = "query" | "scrollIntoView" | "tap" | "waitForSelector" | "waitForHidden" | "waitForMatch" | "fill";
|
|
346
|
+
type SelectOptionInput = string | string[] | {
|
|
347
|
+
value?: string;
|
|
348
|
+
label?: string;
|
|
349
|
+
index?: number;
|
|
350
|
+
} | Array<{
|
|
351
|
+
value?: string;
|
|
352
|
+
label?: string;
|
|
353
|
+
index?: number;
|
|
354
|
+
}>;
|
|
340
355
|
/** Build an in-page diagnostic script reporting why an existing element failed actionability (covered/disabled/hidden). */
|
|
341
356
|
declare function buildDomActionabilityDiagScript(selector: Selector): string;
|
|
342
357
|
/** Build a ~70-byte call to the pre-injected `window.__spanaRt` runtime. */
|
|
343
358
|
declare function buildInjectedCallScript(method: InjectedRuntimeMethod, ...args: unknown[]): string;
|
|
344
359
|
|
|
360
|
+
interface Geolocation {
|
|
361
|
+
latitude: number;
|
|
362
|
+
longitude: number;
|
|
363
|
+
accuracy?: number;
|
|
364
|
+
}
|
|
365
|
+
type Orientation = "portrait" | "landscape";
|
|
366
|
+
interface PermissionOptions {
|
|
367
|
+
origin?: string;
|
|
368
|
+
}
|
|
369
|
+
type BiometricOptions = {
|
|
370
|
+
type: "faceId" | "touchId";
|
|
371
|
+
match?: boolean;
|
|
372
|
+
} | {
|
|
373
|
+
type: "fingerprint";
|
|
374
|
+
fingerId: number;
|
|
375
|
+
};
|
|
376
|
+
type PushPayload = Record<string, unknown>;
|
|
377
|
+
|
|
345
378
|
type RawHierarchy = string;
|
|
346
379
|
/**
|
|
347
380
|
* Per-launch device state overrides (language/locale/timeZone) applied at app
|
|
@@ -548,6 +581,28 @@ interface CdpSessionHandle {
|
|
|
548
581
|
/** Browser context ID when running in an isolated CDP Target.createBrowserContext. */
|
|
549
582
|
readonly browserContextId?: string;
|
|
550
583
|
}
|
|
584
|
+
interface BrowserDialogInfo {
|
|
585
|
+
type: "alert" | "confirm" | "prompt" | "beforeunload";
|
|
586
|
+
message: string;
|
|
587
|
+
defaultValue?: string;
|
|
588
|
+
accept(promptText?: string): Promise<void>;
|
|
589
|
+
dismiss(): Promise<void>;
|
|
590
|
+
}
|
|
591
|
+
type BrowserDialogHandler = (dialog: BrowserDialogInfo) => void | Promise<void>;
|
|
592
|
+
interface BrowserEmulationOptions {
|
|
593
|
+
colorScheme?: "light" | "dark" | "no-preference";
|
|
594
|
+
reducedMotion?: "reduce" | "no-preference";
|
|
595
|
+
locale?: string;
|
|
596
|
+
timezoneId?: string;
|
|
597
|
+
}
|
|
598
|
+
interface BrowserDownloadInfo {
|
|
599
|
+
suggestedFilename: string;
|
|
600
|
+
path: string;
|
|
601
|
+
url?: string;
|
|
602
|
+
text(): Promise<string>;
|
|
603
|
+
bytes(): Promise<Uint8Array>;
|
|
604
|
+
saveAs(destPath: string): Promise<void>;
|
|
605
|
+
}
|
|
551
606
|
interface RawDriverService<_T extends string = string, R extends string = string> {
|
|
552
607
|
readonly beginFlow?: (flowName: string) => Effect.Effect<void, DriverError>;
|
|
553
608
|
readonly getDriverLogs?: () => Effect.Effect<string[], DriverError>;
|
|
@@ -564,6 +619,27 @@ interface RawDriverService<_T extends string = string, R extends string = string
|
|
|
564
619
|
readonly hideKeyboard: () => Effect.Effect<void, DriverError>;
|
|
565
620
|
readonly takeScreenshot: () => Effect.Effect<Uint8Array, DriverError>;
|
|
566
621
|
readonly getDeviceInfo: () => Effect.Effect<DeviceInfo, DriverError>;
|
|
622
|
+
readonly setGeolocation?: (point: Geolocation) => Effect.Effect<void, DriverError>;
|
|
623
|
+
readonly setSystemTime?: (time: Date | number | string) => Effect.Effect<void, DriverError>;
|
|
624
|
+
readonly setPermission?: (appId: string, permission: string, state: "grant" | "deny", options?: PermissionOptions) => Effect.Effect<void, DriverError>;
|
|
625
|
+
readonly setOrientation?: (orientation: Orientation) => Effect.Effect<void, DriverError>;
|
|
626
|
+
readonly setViewport?: (size: {
|
|
627
|
+
width: number;
|
|
628
|
+
height: number;
|
|
629
|
+
deviceScaleFactor?: number;
|
|
630
|
+
mobile?: boolean;
|
|
631
|
+
}) => Effect.Effect<void, DriverError>;
|
|
632
|
+
readonly setEmulation?: (opts: BrowserEmulationOptions) => Effect.Effect<void, DriverError>;
|
|
633
|
+
readonly setDialogHandler?: (handler: BrowserDialogHandler | null) => Effect.Effect<void, DriverError>;
|
|
634
|
+
readonly dragAndDrop?: (startX: number, startY: number, endX: number, endY: number, steps?: number) => Effect.Effect<void, DriverError>;
|
|
635
|
+
readonly getClipboard?: () => Effect.Effect<string, DriverError>;
|
|
636
|
+
readonly setClipboard?: (text: string) => Effect.Effect<void, DriverError>;
|
|
637
|
+
readonly waitForDownload?: (trigger: () => Promise<unknown>, opts?: {
|
|
638
|
+
timeout?: number;
|
|
639
|
+
}) => Effect.Effect<BrowserDownloadInfo, DriverError>;
|
|
640
|
+
readonly setBiometricEnrollment?: (enabled: boolean) => Effect.Effect<void, DriverError>;
|
|
641
|
+
readonly simulateBiometric?: (options: BiometricOptions) => Effect.Effect<void, DriverError>;
|
|
642
|
+
readonly sendPushNotification?: (appId: string, payload: PushPayload) => Effect.Effect<void, DriverError>;
|
|
567
643
|
readonly launchApp: (bundleId: string, opts?: LaunchOptions<R>) => Effect.Effect<void, DriverError>;
|
|
568
644
|
readonly stopApp: (bundleId: string) => Effect.Effect<void, DriverError>;
|
|
569
645
|
readonly killApp: (bundleId: string) => Effect.Effect<void, DriverError>;
|
|
@@ -612,6 +688,9 @@ interface RawDriverService<_T extends string = string, R extends string = string
|
|
|
612
688
|
readonly getJSErrors?: () => Effect.Effect<BrowserJSError[], DriverError>;
|
|
613
689
|
readonly getHAR?: () => Effect.Effect<BrowserHAR, DriverError>;
|
|
614
690
|
readonly getRawPage?: () => unknown;
|
|
691
|
+
readonly getAriaSnapshot?: (selector: Selector, timeout?: number) => Effect.Effect<string, DriverError>;
|
|
692
|
+
readonly startJSCoverage?: () => Effect.Effect<void, DriverError>;
|
|
693
|
+
readonly stopJSCoverage?: () => Effect.Effect<unknown[], DriverError>;
|
|
615
694
|
readonly getCdpSession?: () => CdpSessionHandle | undefined;
|
|
616
695
|
readonly enableVirtualAuthenticator?: (opts?: VirtualAuthenticatorOptions) => Effect.Effect<string, DriverError>;
|
|
617
696
|
readonly removeVirtualAuthenticator?: (authenticatorId?: string) => Effect.Effect<void, DriverError>;
|
|
@@ -620,371 +699,191 @@ interface RawDriverService<_T extends string = string, R extends string = string
|
|
|
620
699
|
readonly clearVirtualCredentials?: (authenticatorId?: string) => Effect.Effect<void, DriverError>;
|
|
621
700
|
}
|
|
622
701
|
|
|
623
|
-
interface
|
|
624
|
-
/**
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
signingIdentity?: string;
|
|
628
|
-
}
|
|
629
|
-
interface BridgeConfig {
|
|
630
|
-
/** Enable the in-app spana-bridge WebSocket server. Default: auto-detected when port/url is set. */
|
|
631
|
-
enabled?: boolean;
|
|
632
|
-
/** Port for the runner's spana-bridge WebSocket server (default: 9333). */
|
|
633
|
-
port?: number;
|
|
634
|
-
/** Host to bind the bridge server on (default: "127.0.0.1"). */
|
|
635
|
-
host?: string;
|
|
636
|
-
/** Explicit external bridge URL if already running (e.g. ws://127.0.0.1:9333). */
|
|
637
|
-
url?: string;
|
|
638
|
-
/** Connection timeout in ms when waiting for the app bridge to connect (default: 5000). */
|
|
639
|
-
connectTimeout?: number;
|
|
640
|
-
}
|
|
641
|
-
interface WarmDaemonConfig {
|
|
642
|
-
/** Keep WDA / UiAutomator2 daemons alive across test runs and reuse them. Default: false. */
|
|
643
|
-
enabled?: boolean;
|
|
644
|
-
/** Reuse a single browser process across flows with fresh BrowserContexts. Default: true. */
|
|
645
|
-
reuseBrowserProcess?: boolean;
|
|
646
|
-
/** Reuse an active WDA/UiAutomator2 session across flows instead of recreating. Default: true when warm daemons enabled. */
|
|
647
|
-
reuseSession?: boolean;
|
|
648
|
-
/** Optional path to store warm daemon metadata. */
|
|
649
|
-
stateFile?: string;
|
|
650
|
-
}
|
|
651
|
-
interface AppConfig {
|
|
702
|
+
interface WebServerConfig {
|
|
703
|
+
/** Shell command to boot the dev/preview server (e.g. `"bun run dev"` or `"npm start"`). */
|
|
704
|
+
command: string;
|
|
705
|
+
/** HTTP(S) URL to poll until a response is received (e.g. `"http://127.0.0.1:3000/health"`). */
|
|
652
706
|
url?: string;
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
appPath?: string;
|
|
657
|
-
/** iOS code signing config for physical devices */
|
|
658
|
-
signing?: IOSSigningConfig;
|
|
659
|
-
/** Explicit WebKit Inspector URL or port for iOS WKWebView direct DOM access */
|
|
660
|
-
webkitInspectorUrl?: string;
|
|
661
|
-
webkitInspectorPort?: number;
|
|
662
|
-
/** Explicit CDP port for Android WebView or desktop targets */
|
|
663
|
-
cdpPort?: number;
|
|
664
|
-
/** Pin device locale (e.g. "en_US", "sv_SE") for predictable system UI labels */
|
|
665
|
-
locale?: string;
|
|
666
|
-
/** Optional spana-bridge override for this app target */
|
|
667
|
-
bridge?: BridgeConfig;
|
|
668
|
-
}
|
|
669
|
-
interface ElectronAppConfig {
|
|
670
|
-
/** Path to Electron main entry file or app directory (passed to Playwright _electron.launch) */
|
|
671
|
-
entry?: string;
|
|
672
|
-
/** Path to a packaged Electron executable */
|
|
673
|
-
executablePath?: string;
|
|
674
|
-
/** Extra CLI arguments passed to Electron */
|
|
675
|
-
args?: string[];
|
|
676
|
-
/** Working directory for Electron launch */
|
|
707
|
+
/** TCP port to poll on localhost when `url` is omitted. */
|
|
708
|
+
port?: number;
|
|
709
|
+
/** Working directory for the spawned server process (defaults to `process.cwd()`). */
|
|
677
710
|
cwd?: string;
|
|
678
|
-
/**
|
|
711
|
+
/** Extra environment variables merged into `process.env`. */
|
|
679
712
|
env?: Record<string, string>;
|
|
680
|
-
/**
|
|
681
|
-
|
|
682
|
-
/**
|
|
683
|
-
|
|
684
|
-
/**
|
|
713
|
+
/** Maximum ms to wait for the server to become ready (default: 60_000). */
|
|
714
|
+
timeout?: number;
|
|
715
|
+
/** If true (default when not in CI), skip spawning if `url`/`port` is already reachable. */
|
|
716
|
+
reuseExistingServer?: boolean;
|
|
717
|
+
/** Pipe server stdout (`"pipe"` captures silently, `"inherit"` streams to console). Default: `"pipe"`. */
|
|
718
|
+
stdout?: "pipe" | "ignore" | "inherit";
|
|
719
|
+
/** Pipe server stderr. Default: `"pipe"`. */
|
|
720
|
+
stderr?: "pipe" | "ignore" | "inherit";
|
|
721
|
+
/** Accept any HTTP status < 500 as ready instead of only 2xx-3xx (default: false). */
|
|
722
|
+
ignoreHTTPSErrors?: boolean;
|
|
723
|
+
/** Graceful shutdown timeout in ms before escalating to SIGKILL (default: 3_000). */
|
|
724
|
+
gracefulShutdownMs?: number;
|
|
725
|
+
}
|
|
726
|
+
interface RunningWebServer {
|
|
727
|
+
config: WebServerConfig;
|
|
685
728
|
url?: string;
|
|
686
|
-
|
|
687
|
-
|
|
729
|
+
port?: number;
|
|
730
|
+
reused: boolean;
|
|
731
|
+
pid?: number;
|
|
732
|
+
/** Stop the spawned server cleanly (no-op when reused). */
|
|
733
|
+
stop(): Promise<void>;
|
|
688
734
|
}
|
|
689
|
-
|
|
690
|
-
interface ElectrobunAppConfig {
|
|
691
|
-
/** Path to Electrobun binary or packaged .app/.exe */
|
|
692
|
-
executablePath?: string;
|
|
693
|
-
/** Path to Electrobun project root (containing electrobun.config.ts) */
|
|
694
|
-
appDir?: string;
|
|
695
|
-
/** Extra CLI arguments passed to the Electrobun process */
|
|
696
|
-
args?: string[];
|
|
697
|
-
/** Working directory for launch */
|
|
735
|
+
interface StartWebServersOptions {
|
|
698
736
|
cwd?: string;
|
|
699
|
-
/**
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
737
|
+
/** Override `process.env.CI` detection for `reuseExistingServer`. */
|
|
738
|
+
isCI?: boolean;
|
|
739
|
+
/** Poll interval in ms (default: 150). */
|
|
740
|
+
pollIntervalMs?: number;
|
|
741
|
+
}
|
|
742
|
+
declare function isTcpPortOpen(port: number, host?: string, timeoutMs?: number): Promise<boolean>;
|
|
743
|
+
declare function isHttpUrlReady(url: string, timeoutMs?: number): Promise<boolean>;
|
|
744
|
+
declare function checkServerReady(config: WebServerConfig): Promise<boolean>;
|
|
745
|
+
/**
|
|
746
|
+
* Start a single configured dev server, waiting until `url` or `port` becomes reachable.
|
|
747
|
+
* Respects `reuseExistingServer` (defaults to `!isCI`).
|
|
748
|
+
*/
|
|
749
|
+
declare function startWebServer(config: WebServerConfig, opts?: StartWebServersOptions): Promise<RunningWebServer>;
|
|
750
|
+
/**
|
|
751
|
+
* Start one or more configured web servers in sequence, rolling back already-started
|
|
752
|
+
* servers if a later one fails to become ready.
|
|
753
|
+
*/
|
|
754
|
+
declare function startWebServers(input: WebServerConfig | WebServerConfig[] | undefined, opts?: StartWebServersOptions): Promise<{
|
|
755
|
+
servers: RunningWebServer[];
|
|
756
|
+
stopAll(): Promise<void>;
|
|
757
|
+
}>;
|
|
758
|
+
|
|
759
|
+
interface ProjectConfig {
|
|
760
|
+
/** Unique project identifier (e.g. `"setup"`, `"chromium"`, `"mobile-safari"`, `"api"`). */
|
|
761
|
+
name: string;
|
|
762
|
+
/** Optional target platform override for this project. */
|
|
763
|
+
platform?: Platform;
|
|
764
|
+
/** Optional browser override when running on `"web"`. */
|
|
727
765
|
browser?: BrowserName;
|
|
728
|
-
/**
|
|
729
|
-
|
|
730
|
-
/**
|
|
731
|
-
cdpUrl?: string;
|
|
732
|
-
/** Connect to a remote Playwright server WebSocket (e.g. BrowserStack Automate Web `wss://cdp.browserstack.com/playwright?...`). */
|
|
733
|
-
wsEndpoint?: string;
|
|
734
|
-
/** Explicit browser executable path (e.g. system Chrome or custom Chromium binary). */
|
|
735
|
-
executablePath?: string;
|
|
736
|
-
/** Browser release channel (e.g. "chrome", "chrome-beta", "msedge"). */
|
|
737
|
-
channel?: string;
|
|
738
|
-
headless?: boolean;
|
|
739
|
-
/** Navigation readiness event for launchApp/openLink (default: "load"). */
|
|
740
|
-
waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
|
|
741
|
-
/** Collapse CSS transitions & animations to 0.001ms for faster deterministic runs. */
|
|
742
|
-
instantAnimations?: boolean;
|
|
743
|
-
/** Abort heavy asset requests ("image" | "font" | "media" | "stylesheet") during web runs. */
|
|
744
|
-
blockResources?: WebResourceBlockType[];
|
|
745
|
-
/** Reuse a persistent warm Chromium daemon across runs via CDP (chromium only). */
|
|
746
|
-
warmBrowser?: boolean;
|
|
747
|
-
/** Scope key for isolating warm Chromium daemons across concurrent repos/runs (defaults to cwd hash). */
|
|
748
|
-
warmBrowserScope?: string;
|
|
749
|
-
/** Create a fresh isolated BrowserContext per flow using pre-warmed context pooling + background teardown. */
|
|
750
|
-
freshContextPerFlow?: boolean;
|
|
751
|
-
/**
|
|
752
|
-
* Context isolation strategy when `freshContextPerFlow` is enabled (Direct CDP):
|
|
753
|
-
* - `"fresh"` (default): new `Target.createBrowserContext` per flow (strictest isolation).
|
|
754
|
-
* - `"hot-cache"`: keeps Chromium's HTTP & V8 bytecode cache hot while wiping cookies, localStorage,
|
|
755
|
-
* sessionStorage, IndexedDB, CacheStorage, and service workers between flows (~4 ms reset!).
|
|
756
|
-
*/
|
|
757
|
-
contextIsolation?: WebContextIsolation;
|
|
758
|
-
/** Max worker contexts sharing one Chromium browser process under `--parallel` (default: 2 to avoid CDP/IO contention). */
|
|
759
|
-
maxContextsPerBrowser?: number;
|
|
760
|
-
/** Automatically attach a CDP WebAuthn virtual authenticator (passkey) to every fresh context. */
|
|
761
|
-
virtualAuthenticator?: boolean | VirtualAuthenticatorOptions;
|
|
762
|
-
/** Optional Playwright storage state JSON file to preload for web runs */
|
|
766
|
+
/** Optional base URL override for web flows in this project. */
|
|
767
|
+
baseUrl?: string;
|
|
768
|
+
/** Optional storageState JSON file path loaded by flows in this project. */
|
|
763
769
|
storageState?: string;
|
|
764
|
-
/**
|
|
765
|
-
|
|
766
|
-
/**
|
|
767
|
-
|
|
770
|
+
/** Optional flow directory override relative to config file. */
|
|
771
|
+
flowDir?: string;
|
|
772
|
+
/** Only include flow files matching any of these substrings/globs/RegExps. */
|
|
773
|
+
testMatch?: Array<string | RegExp>;
|
|
774
|
+
/** Exclude flow files matching any of these substrings/globs/RegExps. */
|
|
775
|
+
testIgnore?: Array<string | RegExp>;
|
|
776
|
+
/** Only include flows carrying at least one of these tags. */
|
|
777
|
+
tags?: string[];
|
|
778
|
+
/** Optional substring filter against flow names. */
|
|
779
|
+
grep?: string;
|
|
780
|
+
/** Project names that must complete successfully before this project starts. */
|
|
781
|
+
dependencies?: string[];
|
|
782
|
+
/** Optional project name to run after this project completes (teardown). */
|
|
783
|
+
teardown?: string;
|
|
784
|
+
/** Per-project retry override. */
|
|
785
|
+
retries?: number;
|
|
786
|
+
/** Optional web execution overrides (e.g. headless, engine, colorScheme). */
|
|
787
|
+
use?: Partial<WebExecutionConfig> & {
|
|
788
|
+
viewport?: {
|
|
789
|
+
width: number;
|
|
790
|
+
height: number;
|
|
791
|
+
};
|
|
792
|
+
locale?: string;
|
|
793
|
+
timezoneId?: string;
|
|
794
|
+
};
|
|
768
795
|
}
|
|
769
|
-
interface
|
|
770
|
-
/**
|
|
771
|
-
|
|
772
|
-
/**
|
|
773
|
-
|
|
774
|
-
/**
|
|
775
|
-
|
|
796
|
+
interface ProjectExecutionPlan {
|
|
797
|
+
/** Projects grouped into topological waves; projects in the same wave can run in parallel. */
|
|
798
|
+
waves: ProjectConfig[][];
|
|
799
|
+
/** Flat execution order respecting all `dependencies`. */
|
|
800
|
+
ordered: ProjectConfig[];
|
|
801
|
+
/** Teardown projects paired with the projects that declared them. */
|
|
802
|
+
teardowns: ProjectConfig[];
|
|
776
803
|
}
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
804
|
+
/**
|
|
805
|
+
* Filter a list of loaded flows according to a `ProjectConfig`'s `testMatch`, `testIgnore`,
|
|
806
|
+
* `tags`, `grep`, and `platform` constraints.
|
|
807
|
+
*/
|
|
808
|
+
declare function filterFlowsForProject(flows: FlowDefinition[], project: ProjectConfig): FlowDefinition[];
|
|
809
|
+
/**
|
|
810
|
+
* Resolve named projects into topological execution waves, expanding `--project` selections
|
|
811
|
+
* to include all transitive `dependencies` and collecting any declared `teardown` projects.
|
|
812
|
+
* Throws a clear error on duplicate project names, missing dependencies, or dependency cycles.
|
|
813
|
+
*/
|
|
814
|
+
declare function resolveProjectExecutionPlan(projects: ProjectConfig[], selectedNames?: string[]): ProjectExecutionPlan;
|
|
815
|
+
|
|
816
|
+
interface WaitOptions {
|
|
817
|
+
timeout?: number;
|
|
818
|
+
pollInterval?: number;
|
|
819
|
+
settleTimeout?: number;
|
|
820
|
+
/** Starting poll interval for adaptive polling. Default: 50ms. Set equal to pollInterval to disable adaptive backoff. */
|
|
821
|
+
initialPollInterval?: number;
|
|
822
|
+
/** Tap dispatch mode when resolved via DOM channel: "native" (default, real touch) or "dom" (fast synthetic click). */
|
|
823
|
+
tapMode?: TapMode;
|
|
824
|
+
/** Platform hint for coordinate scaling (android physical px vs ios logical pt). */
|
|
825
|
+
platform?: Platform;
|
|
826
|
+
/** Fail early on web when DOM stays idle and document is complete instead of waiting full timeout. */
|
|
827
|
+
failFastWhenIdle?: boolean;
|
|
828
|
+
/** Quiet window in ms before failFastWhenIdle resolves empty. Default: 250. */
|
|
829
|
+
idleQuietMs?: number;
|
|
830
|
+
/** Consecutive stable animation frames required before pointer actions on web. Default: 2. */
|
|
831
|
+
actionStableFrames?: number;
|
|
780
832
|
}
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
833
|
+
|
|
834
|
+
type Direction = "up" | "down" | "left" | "right";
|
|
835
|
+
interface ScrollUntilVisibleOptions<_T extends string = string> extends WaitOptions {
|
|
836
|
+
/** Where the target is relative to the current viewport. Default: "down". */
|
|
837
|
+
direction?: Direction;
|
|
838
|
+
/** Max number of scroll gestures to attempt before failing. Default: 5. */
|
|
839
|
+
maxScrolls?: number;
|
|
786
840
|
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
841
|
+
type KeyboardDismissStrategy = "auto" | "driver" | "back";
|
|
842
|
+
interface DismissKeyboardOptions {
|
|
843
|
+
/** Default: "auto" (driver hideKeyboard, then Android back fallback). */
|
|
844
|
+
strategy?: KeyboardDismissStrategy;
|
|
791
845
|
}
|
|
792
|
-
interface
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
tunnelName?: string;
|
|
796
|
-
args?: string[];
|
|
846
|
+
interface BackUntilVisibleOptions<_T extends string = string> extends WaitOptions {
|
|
847
|
+
/** Max number of back actions to attempt before failing. Default: 3. */
|
|
848
|
+
maxBacks?: number;
|
|
797
849
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
/**
|
|
807
|
-
|
|
808
|
-
* matching platform runs. Useful when you want different `appium:deviceName`
|
|
809
|
-
* or `appium:platformVersion` for Android vs iOS.
|
|
810
|
-
*/
|
|
811
|
-
platformCapabilities?: {
|
|
812
|
-
android?: Record<string, unknown>;
|
|
813
|
-
ios?: Record<string, unknown>;
|
|
814
|
-
};
|
|
815
|
-
capabilitiesFile?: string;
|
|
816
|
-
reportToProvider?: boolean;
|
|
817
|
-
browserstack?: BrowserStackHelperConfig;
|
|
818
|
-
saucelabs?: SauceLabsHelperConfig;
|
|
819
|
-
/** Path to a custom cloud provider module (default export must conform to CloudProvider interface). */
|
|
820
|
-
cloudProvider?: string;
|
|
821
|
-
/**
|
|
822
|
-
* Opt in to having spana spawn a local `appium` subprocess for the
|
|
823
|
-
* duration of the test run. Requires `appium` to be on PATH. When true,
|
|
824
|
-
* `serverUrl` (if set) is ignored and a URL is assigned to the
|
|
825
|
-
* auto-started server instead. Off by default — spana never spawns
|
|
826
|
-
* background processes unless you ask.
|
|
827
|
-
*/
|
|
828
|
-
autoStart?: boolean;
|
|
829
|
-
/** Override the `appium` binary name. Default: "appium". */
|
|
830
|
-
autoStartBinary?: string;
|
|
831
|
-
/** Extra CLI args to forward to the spawned Appium process. */
|
|
832
|
-
autoStartArgs?: readonly string[];
|
|
833
|
-
}
|
|
834
|
-
interface ExecutionConfig {
|
|
835
|
-
mode?: "local" | "appium";
|
|
836
|
-
web?: WebExecutionConfig;
|
|
837
|
-
appium?: AppiumExecutionConfig;
|
|
838
|
-
/** In-app spana-bridge configuration shared across webview targets */
|
|
839
|
-
bridge?: BridgeConfig;
|
|
840
|
-
/** Warm daemon & process reuse settings for fast repeated runs */
|
|
841
|
-
warmDaemons?: WarmDaemonConfig;
|
|
842
|
-
}
|
|
843
|
-
interface ArtifactConfig {
|
|
844
|
-
outputDir?: string;
|
|
845
|
-
captureOnFailure?: boolean;
|
|
846
|
-
captureOnSuccess?: boolean;
|
|
847
|
-
captureSteps?: boolean;
|
|
848
|
-
screenshot?: boolean;
|
|
849
|
-
uiHierarchy?: boolean;
|
|
850
|
-
consoleLogs?: boolean;
|
|
851
|
-
jsErrors?: boolean;
|
|
852
|
-
har?: boolean;
|
|
853
|
-
/** Video / screencast recording mode: "off" (default), "on", or "retain-on-failure". */
|
|
854
|
-
video?: VideoRecordingMode;
|
|
855
|
-
/** Embed interactive step-by-step visual playback timeline inside report.html (auto-enabled when video !== "off"). */
|
|
856
|
-
playback?: boolean;
|
|
857
|
-
}
|
|
858
|
-
interface HookContext {
|
|
859
|
-
app: unknown;
|
|
860
|
-
expect?: unknown;
|
|
861
|
-
platform?: Platform;
|
|
862
|
-
result?: unknown;
|
|
863
|
-
summary?: unknown;
|
|
864
|
-
}
|
|
865
|
-
interface ProvConfig {
|
|
866
|
-
apps?: {
|
|
867
|
-
web?: AppConfig;
|
|
868
|
-
android?: AppConfig;
|
|
869
|
-
ios?: AppConfig;
|
|
870
|
-
electron?: ElectronAppConfig;
|
|
871
|
-
electrobun?: ElectrobunAppConfig;
|
|
872
|
-
};
|
|
873
|
-
defaults?: {
|
|
874
|
-
waitTimeout?: number;
|
|
875
|
-
pollInterval?: number;
|
|
876
|
-
settleTimeout?: number;
|
|
877
|
-
retries?: number;
|
|
878
|
-
/** Pause after each action (tap, scroll) to let the UI settle. Default: 0 (disabled). */
|
|
879
|
-
waitForIdleTimeout?: number;
|
|
880
|
-
/** Delay between each character when typing. Default: 0 (instant). */
|
|
881
|
-
typingDelay?: number;
|
|
882
|
-
/** Starting poll interval for adaptive backoff. Default: 50ms. Set equal to pollInterval to disable adaptive backoff. */
|
|
883
|
-
initialPollInterval?: number;
|
|
884
|
-
/** Max age in ms before cached hierarchy is stale. Default: 100. Set to 0 to disable. */
|
|
885
|
-
hierarchyCacheTtl?: number;
|
|
886
|
-
/** Max depth for UI hierarchy snapshots on iOS. Default: 100. */
|
|
887
|
-
snapshotMaxDepth?: number;
|
|
888
|
-
/** Delay in ms between retry attempts of a failed flow. Default: 0 (immediate). */
|
|
889
|
-
retryDelay?: number;
|
|
890
|
-
/** Max workers per platform when using --parallel. */
|
|
891
|
-
workers?: number;
|
|
892
|
-
/** Number of isolated OS worker processes sharing a dynamic longest-first flow queue (`--processes M`). */
|
|
893
|
-
processes?: number;
|
|
894
|
-
/** Max in-process workers before automatically sharding across multiple OS processes (default: 8). */
|
|
895
|
-
maxWorkersPerProcess?: number;
|
|
896
|
-
/** Default tap mode when a DOM channel resolves an element: "native" (real touch, default) or "dom" (fast synthetic click). */
|
|
897
|
-
tapMode?: TapMode;
|
|
898
|
-
/** Pin device locale across targets so system UI sheet labels stay deterministic. */
|
|
899
|
-
locale?: string;
|
|
900
|
-
/** Fail web element waits early when the page is idle & readyState === "complete" instead of waiting full waitTimeout. */
|
|
901
|
-
failFastWhenIdle?: boolean;
|
|
902
|
-
/** Consecutive stable animation frames required before pointer actions on web. Default: 2. Set 0 to disable. */
|
|
903
|
-
actionStableFrames?: number;
|
|
904
|
-
};
|
|
905
|
-
platforms?: Platform[];
|
|
906
|
-
/** Run platforms concurrently when they use independent resources. Default: false (serial). */
|
|
907
|
-
parallelPlatforms?: boolean;
|
|
908
|
-
flowDir?: string;
|
|
909
|
-
launchOptions?: LaunchOptions;
|
|
910
|
-
/**
|
|
911
|
-
* Reporter names or module paths. Built-in: "console", "json", "junit", "html", "allure".
|
|
912
|
-
* Custom reporters: provide a relative path (e.g., "./reporters/slack.ts") that default-exports
|
|
913
|
-
* a Reporter object or a `(options: { outputDir: string }) => Reporter` factory function.
|
|
914
|
-
*/
|
|
915
|
-
reporters?: string[];
|
|
916
|
-
hooks?: {
|
|
917
|
-
beforeAll?: (ctx: HookContext) => Promise<void>;
|
|
918
|
-
beforeEach?: (ctx: HookContext) => Promise<void>;
|
|
919
|
-
afterEach?: (ctx: HookContext) => Promise<void>;
|
|
920
|
-
afterAll?: (ctx: HookContext) => Promise<void>;
|
|
921
|
-
};
|
|
922
|
-
artifacts?: ArtifactConfig;
|
|
923
|
-
execution?: ExecutionConfig;
|
|
924
|
-
visualRegression?: {
|
|
925
|
-
threshold?: number;
|
|
926
|
-
maxDiffPixelRatio?: number;
|
|
927
|
-
baselinesDir?: string;
|
|
928
|
-
mode?: "pixel" | "layout-tolerant";
|
|
929
|
-
};
|
|
930
|
-
/** Pluggable CI filters evaluated when `--changed-since <ref>` is passed. */
|
|
931
|
-
filters?: Array<{
|
|
932
|
-
name: string;
|
|
933
|
-
filter: (flows: any[], context: any) => Promise<any> | any;
|
|
934
|
-
}>;
|
|
935
|
-
/** Verified replay cache settings for optional agentic steps (`.spana/cache/`). */
|
|
936
|
-
replayCache?: {
|
|
937
|
-
mode?: "read-write" | "strict" | "off";
|
|
938
|
-
dir?: string;
|
|
939
|
-
};
|
|
940
|
-
}
|
|
941
|
-
declare function defineConfig(config: ProvConfig): ProvConfig;
|
|
942
|
-
|
|
943
|
-
interface WaitOptions {
|
|
944
|
-
timeout?: number;
|
|
945
|
-
pollInterval?: number;
|
|
946
|
-
settleTimeout?: number;
|
|
947
|
-
/** Starting poll interval for adaptive polling. Default: 50ms. Set equal to pollInterval to disable adaptive backoff. */
|
|
948
|
-
initialPollInterval?: number;
|
|
949
|
-
/** Tap dispatch mode when resolved via DOM channel: "native" (default, real touch) or "dom" (fast synthetic click). */
|
|
950
|
-
tapMode?: TapMode;
|
|
951
|
-
/** Platform hint for coordinate scaling (android physical px vs ios logical pt). */
|
|
952
|
-
platform?: Platform;
|
|
953
|
-
/** Fail early on web when DOM stays idle and document is complete instead of waiting full timeout. */
|
|
954
|
-
failFastWhenIdle?: boolean;
|
|
955
|
-
/** Quiet window in ms before failFastWhenIdle resolves empty. Default: 250. */
|
|
956
|
-
idleQuietMs?: number;
|
|
957
|
-
/** Consecutive stable animation frames required before pointer actions on web. Default: 2. */
|
|
958
|
-
actionStableFrames?: number;
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
type Direction = "up" | "down" | "left" | "right";
|
|
962
|
-
interface ScrollUntilVisibleOptions<_T extends string = string> extends WaitOptions {
|
|
963
|
-
/** Where the target is relative to the current viewport. Default: "down". */
|
|
964
|
-
direction?: Direction;
|
|
965
|
-
/** Max number of scroll gestures to attempt before failing. Default: 5. */
|
|
966
|
-
maxScrolls?: number;
|
|
967
|
-
}
|
|
968
|
-
type KeyboardDismissStrategy = "auto" | "driver" | "back";
|
|
969
|
-
interface DismissKeyboardOptions {
|
|
970
|
-
/** Default: "auto" (driver hideKeyboard, then Android back fallback). */
|
|
971
|
-
strategy?: KeyboardDismissStrategy;
|
|
972
|
-
}
|
|
973
|
-
interface BackUntilVisibleOptions<_T extends string = string> extends WaitOptions {
|
|
974
|
-
/** Max number of back actions to attempt before failing. Default: 3. */
|
|
975
|
-
maxBacks?: number;
|
|
850
|
+
|
|
851
|
+
interface StorybookOpenOptions {
|
|
852
|
+
/** Override the Storybook base URL for this call. */
|
|
853
|
+
baseUrl?: string;
|
|
854
|
+
/** Storybook view mode. Defaults to "story". */
|
|
855
|
+
viewMode?: "story" | "docs";
|
|
856
|
+
/** Story args encoded into the Storybook iframe query string. */
|
|
857
|
+
args?: Record<string, StorybookValue>;
|
|
858
|
+
/** Story globals encoded into the Storybook iframe query string. */
|
|
859
|
+
globals?: Record<string, StorybookValue>;
|
|
976
860
|
}
|
|
977
861
|
|
|
978
|
-
interface
|
|
979
|
-
/**
|
|
980
|
-
|
|
981
|
-
/**
|
|
982
|
-
|
|
983
|
-
/**
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
862
|
+
interface DataSnapshotOptions {
|
|
863
|
+
/** Directory storing snapshot files (default: `.spana/snapshots`). */
|
|
864
|
+
snapshotsDir?: string;
|
|
865
|
+
/** Create or overwrite the snapshot baseline instead of failing on mismatch. */
|
|
866
|
+
updateBaselines?: boolean;
|
|
867
|
+
/** File extension override (auto-selects `.json` for non-string values and `.txt` for strings). */
|
|
868
|
+
extension?: string;
|
|
869
|
+
}
|
|
870
|
+
interface DataSnapshotResult {
|
|
871
|
+
matched: boolean;
|
|
872
|
+
created: boolean;
|
|
873
|
+
updated: boolean;
|
|
874
|
+
snapshotPath: string;
|
|
875
|
+
expected?: string;
|
|
876
|
+
actual: string;
|
|
877
|
+
diff?: string;
|
|
987
878
|
}
|
|
879
|
+
/**
|
|
880
|
+
* Compare an arbitrary string or JSON-serializable object against a disk snapshot baseline.
|
|
881
|
+
*/
|
|
882
|
+
declare function matchDataSnapshot(actualValue: unknown, name: string, options?: DataSnapshotOptions): DataSnapshotResult;
|
|
883
|
+
/**
|
|
884
|
+
* Assert that `actualValue` matches the persisted snapshot `name` (throws with line diff on mismatch).
|
|
885
|
+
*/
|
|
886
|
+
declare function assertDataSnapshot(actualValue: unknown, name: string, options?: DataSnapshotOptions): DataSnapshotResult;
|
|
988
887
|
|
|
989
888
|
interface NegatedPromiseExpectation {
|
|
990
889
|
toBeVisible(opts?: WaitOptions): Promise<void>;
|
|
@@ -998,6 +897,11 @@ interface NegatedPromiseExpectation {
|
|
|
998
897
|
toContainText(expected: string, opts?: WaitOptions): Promise<void>;
|
|
999
898
|
toHaveCount(expected: number, opts?: WaitOptions): Promise<void>;
|
|
1000
899
|
toBeFocused(opts?: WaitOptions): Promise<void>;
|
|
900
|
+
toBeChecked(opts?: WaitOptions): Promise<void>;
|
|
901
|
+
toBeEditable(opts?: WaitOptions): Promise<void>;
|
|
902
|
+
toBeEmpty(opts?: WaitOptions): Promise<void>;
|
|
903
|
+
toHaveClass(expected: string | RegExp, opts?: WaitOptions): Promise<void>;
|
|
904
|
+
toHaveCSS(property: string, expected: string | RegExp, opts?: WaitOptions): Promise<void>;
|
|
1001
905
|
toHaveAccessibleName(expected: string | RegExp, opts?: WaitOptions): Promise<void>;
|
|
1002
906
|
toHaveAccessibleDescription(expected: string | RegExp, opts?: WaitOptions): Promise<void>;
|
|
1003
907
|
}
|
|
@@ -1015,12 +919,25 @@ interface PromiseExpectation<T extends string = string> {
|
|
|
1015
919
|
toHaveCount(expected: number, opts?: WaitOptions): Promise<void>;
|
|
1016
920
|
/** Assert that the matched element currently has focus (`document.activeElement`). */
|
|
1017
921
|
toBeFocused(opts?: WaitOptions): Promise<void>;
|
|
922
|
+
/** Assert that a checkbox/radio/switch element is checked. */
|
|
923
|
+
toBeChecked(opts?: WaitOptions): Promise<void>;
|
|
924
|
+
/** Assert that the matched element is enabled and editable. */
|
|
925
|
+
toBeEditable(opts?: WaitOptions): Promise<void>;
|
|
926
|
+
/** Assert that the matched input/container has empty value/text. */
|
|
927
|
+
toBeEmpty(opts?: WaitOptions): Promise<void>;
|
|
928
|
+
/** Assert that the matched element has the expected CSS class token(s) or matches a RegExp. */
|
|
929
|
+
toHaveClass(expected: string | RegExp, opts?: WaitOptions): Promise<void>;
|
|
930
|
+
/** Assert that the matched element's computed CSS property matches expected value or RegExp. */
|
|
931
|
+
toHaveCSS(property: string, expected: string | RegExp, opts?: WaitOptions): Promise<void>;
|
|
1018
932
|
/** Assert that the matched element's computed accessible name matches string or RegExp. */
|
|
1019
933
|
toHaveAccessibleName(expected: string | RegExp, opts?: WaitOptions): Promise<void>;
|
|
1020
934
|
/** Assert that the matched element's computed accessible description matches string or RegExp. */
|
|
1021
935
|
toHaveAccessibleDescription(expected: string | RegExp, opts?: WaitOptions): Promise<void>;
|
|
1022
936
|
/** Negated assertion chain (`expect(selector).not.*`). */
|
|
1023
937
|
readonly not: NegatedPromiseExpectation;
|
|
938
|
+
toMatchAriaSnapshot(expected: string | {
|
|
939
|
+
path: string;
|
|
940
|
+
}, opts?: RetryAssertionOptions): Promise<void>;
|
|
1024
941
|
toMatchScreenshot(name: string, options?: {
|
|
1025
942
|
threshold?: number;
|
|
1026
943
|
maxDiffPixelRatio?: number;
|
|
@@ -1068,14 +985,23 @@ interface PollExpectation<V> extends PollMatchers<V> {
|
|
|
1068
985
|
interface PromiseExpectFn<T extends string = string> {
|
|
1069
986
|
(selector: ExtendedSelector<T>): PromiseExpectation<T>;
|
|
1070
987
|
(fn: () => unknown | Promise<unknown>): ToPassExpectation;
|
|
988
|
+
soft: ((selector: ExtendedSelector<T>) => PromiseExpectation<T>) & {
|
|
989
|
+
toHaveURL(expected: string | RegExp, opts?: WaitOptions): Promise<void>;
|
|
990
|
+
toHaveTitle(expected: string | RegExp, opts?: WaitOptions): Promise<void>;
|
|
991
|
+
};
|
|
1071
992
|
/** Assert that the current page URL matches a substring/exact string or RegExp. */
|
|
1072
993
|
toHaveURL(expected: string | RegExp, opts?: WaitOptions): Promise<void>;
|
|
1073
|
-
/**
|
|
994
|
+
/** Assert that the current document title matches exact string or RegExp. */
|
|
995
|
+
toHaveTitle(expected: string | RegExp, opts?: WaitOptions): Promise<void>;
|
|
996
|
+
/** Negated page-level matchers (`expect.not.toHaveURL(...)`, `expect.not.toHaveTitle(...)`). */
|
|
1074
997
|
readonly not: {
|
|
1075
998
|
toHaveURL(expected: string | RegExp, opts?: WaitOptions): Promise<void>;
|
|
999
|
+
toHaveTitle(expected: string | RegExp, opts?: WaitOptions): Promise<void>;
|
|
1076
1000
|
};
|
|
1077
1001
|
/** Poll an async/sync getter until the chained matcher passes (Playwright `expect.poll(fn)`). */
|
|
1078
1002
|
poll<V>(fn: () => V | Promise<V>, opts?: RetryAssertionOptions): PollExpectation<V>;
|
|
1003
|
+
/** Assert that a string or JSON-serializable object matches a persisted disk snapshot. */
|
|
1004
|
+
toMatchSnapshot(actual: unknown, name: string, opts?: DataSnapshotOptions): Promise<void>;
|
|
1079
1005
|
}
|
|
1080
1006
|
|
|
1081
1007
|
interface BrowserRequestOptions {
|
|
@@ -1123,6 +1049,12 @@ interface FrameScope<T extends string = string> {
|
|
|
1123
1049
|
} & WaitOptions): Promise<void>;
|
|
1124
1050
|
hover(selector: Selector<T>, opts?: WaitOptions): Promise<void>;
|
|
1125
1051
|
fill(selector: Selector<T>, value: string, opts?: WaitOptions): Promise<void>;
|
|
1052
|
+
clear(selector: Selector<T>, opts?: WaitOptions): Promise<void>;
|
|
1053
|
+
check(selector: Selector<T>, opts?: WaitOptions): Promise<void>;
|
|
1054
|
+
uncheck(selector: Selector<T>, opts?: WaitOptions): Promise<void>;
|
|
1055
|
+
selectOption(selector: Selector<T>, option: SelectOptionInput, opts?: WaitOptions): Promise<string[]>;
|
|
1056
|
+
focus(selector: Selector<T>, opts?: WaitOptions): Promise<void>;
|
|
1057
|
+
dragTo(source: Selector<T>, target: Selector<T>, opts?: WaitOptions): Promise<void>;
|
|
1126
1058
|
uploadFile(selector: Selector<T>, path: string | string[]): Promise<void>;
|
|
1127
1059
|
getText(selector: Selector<T>, opts?: WaitOptions): Promise<string>;
|
|
1128
1060
|
getAttribute(selector: Selector<T>, name: string, opts?: WaitOptions): Promise<string | undefined>;
|
|
@@ -1149,6 +1081,41 @@ interface PromiseApp<T extends string = string, R extends string = string> {
|
|
|
1149
1081
|
inputText(text: string): Promise<void>;
|
|
1150
1082
|
/** Atomic 1-round-trip form fill: waits for actionability, focuses, replaces value, and dispatches input/change. */
|
|
1151
1083
|
fill(selector: ExtendedSelector<T>, value: string, opts?: WaitOptions): Promise<void>;
|
|
1084
|
+
/** Clear the text value of an input, textarea, or contenteditable element. */
|
|
1085
|
+
clear(selector: ExtendedSelector<T>, opts?: WaitOptions): Promise<void>;
|
|
1086
|
+
/** Ensure a checkbox, radio button, or ARIA switch is checked (idempotent). */
|
|
1087
|
+
check(selector: ExtendedSelector<T>, opts?: WaitOptions): Promise<void>;
|
|
1088
|
+
/** Ensure a checkbox or ARIA switch is unchecked (idempotent). */
|
|
1089
|
+
uncheck(selector: ExtendedSelector<T>, opts?: WaitOptions): Promise<void>;
|
|
1090
|
+
/** Select one or more options in a `<select>` element by value, label, or index. Returns selected option values. */
|
|
1091
|
+
selectOption(selector: ExtendedSelector<T>, option: SelectOptionInput, opts?: WaitOptions): Promise<string[]>;
|
|
1092
|
+
/** Focus an element. */
|
|
1093
|
+
focus(selector: ExtendedSelector<T>, opts?: WaitOptions): Promise<void>;
|
|
1094
|
+
/** Drag a source element onto a target element. */
|
|
1095
|
+
dragTo(source: ExtendedSelector<T>, target: ExtendedSelector<T>, opts?: WaitOptions): Promise<void>;
|
|
1096
|
+
/** Resize the active browser viewport dynamically mid-flow. */
|
|
1097
|
+
setViewport(viewport: {
|
|
1098
|
+
width: number;
|
|
1099
|
+
height: number;
|
|
1100
|
+
deviceScaleFactor?: number;
|
|
1101
|
+
mobile?: boolean;
|
|
1102
|
+
}): Promise<void>;
|
|
1103
|
+
/** Emulate CSS media (`colorScheme`, `reducedMotion`), locale, or timezone dynamically mid-flow. */
|
|
1104
|
+
setEmulation(options: BrowserEmulationOptions): Promise<void>;
|
|
1105
|
+
/** Register a custom handler for JS alert/confirm/prompt/beforeunload dialogs (pass `null` to restore auto-handling). */
|
|
1106
|
+
onDialog(handler: BrowserDialogHandler | null): Promise<void>;
|
|
1107
|
+
/** Accept the next JS dialog (optionally passing prompt text) and resolve with the dialog metadata. */
|
|
1108
|
+
acceptNextDialog(promptText?: string): Promise<void>;
|
|
1109
|
+
/** Dismiss the next JS dialog. */
|
|
1110
|
+
dismissNextDialog(): Promise<void>;
|
|
1111
|
+
/** Read plain text from the browser clipboard. */
|
|
1112
|
+
getClipboard(): Promise<string>;
|
|
1113
|
+
/** Write plain text to the browser clipboard. */
|
|
1114
|
+
setClipboard(text: string): Promise<void>;
|
|
1115
|
+
/** Wait for a file download triggered by `triggerFn` and return rich download metadata & helpers. */
|
|
1116
|
+
waitForDownload(triggerFn: () => Promise<unknown>, opts?: {
|
|
1117
|
+
timeout?: number;
|
|
1118
|
+
}): Promise<BrowserDownloadInfo>;
|
|
1152
1119
|
pressKey(key: string): Promise<void>;
|
|
1153
1120
|
hideKeyboard(): Promise<void>;
|
|
1154
1121
|
dismissKeyboard(opts?: DismissKeyboardOptions): Promise<void>;
|
|
@@ -1180,6 +1147,14 @@ interface PromiseApp<T extends string = string, R extends string = string> {
|
|
|
1180
1147
|
takeScreenshot(name?: string): Promise<Uint8Array>;
|
|
1181
1148
|
evaluate<Result = unknown>(fn: ((...args: any[]) => Result) | string, ...args: any[]): Promise<Result>;
|
|
1182
1149
|
mockNetwork(matcher: BrowserRouteMatcher, response: BrowserMockResponse): Promise<void>;
|
|
1150
|
+
setGeolocation(point: Geolocation): Promise<void>;
|
|
1151
|
+
setSystemTime(time: Date | number | string): Promise<void>;
|
|
1152
|
+
grantPermission(permission: string, options?: PermissionOptions): Promise<void>;
|
|
1153
|
+
denyPermission(permission: string, options?: PermissionOptions): Promise<void>;
|
|
1154
|
+
setOrientation(orientation: Orientation): Promise<void>;
|
|
1155
|
+
setBiometricEnrollment(enabled: boolean): Promise<void>;
|
|
1156
|
+
simulateBiometric(options: BiometricOptions): Promise<void>;
|
|
1157
|
+
sendPushNotification(payload: PushPayload): Promise<void>;
|
|
1183
1158
|
blockNetwork(matcher: BrowserRouteMatcher): Promise<void>;
|
|
1184
1159
|
clearNetworkMocks(): Promise<void>;
|
|
1185
1160
|
setNetworkConditions(conditions: BrowserNetworkConditions): Promise<void>;
|
|
@@ -1263,4 +1238,676 @@ interface PromiseApp<T extends string = string, R extends string = string> {
|
|
|
1263
1238
|
switchToNativeApp(): Promise<void>;
|
|
1264
1239
|
}
|
|
1265
1240
|
|
|
1266
|
-
|
|
1241
|
+
/** A deterministic action recorded from an `agent.act(goal)` execution. */
|
|
1242
|
+
type RecordedAction = {
|
|
1243
|
+
kind: "tap";
|
|
1244
|
+
selector: ExtendedSelector;
|
|
1245
|
+
} | {
|
|
1246
|
+
kind: "doubleTap";
|
|
1247
|
+
selector: ExtendedSelector;
|
|
1248
|
+
} | {
|
|
1249
|
+
kind: "longPress";
|
|
1250
|
+
selector: ExtendedSelector;
|
|
1251
|
+
} | {
|
|
1252
|
+
kind: "inputText";
|
|
1253
|
+
text: string;
|
|
1254
|
+
} | {
|
|
1255
|
+
kind: "pressKey";
|
|
1256
|
+
key: string;
|
|
1257
|
+
} | {
|
|
1258
|
+
kind: "scroll";
|
|
1259
|
+
direction: "up" | "down" | "left" | "right";
|
|
1260
|
+
} | {
|
|
1261
|
+
kind: "scrollUntilVisible";
|
|
1262
|
+
selector: ExtendedSelector;
|
|
1263
|
+
} | {
|
|
1264
|
+
kind: "openLink";
|
|
1265
|
+
url: string;
|
|
1266
|
+
};
|
|
1267
|
+
interface ReplayCacheEntry {
|
|
1268
|
+
schemaVersion: 1;
|
|
1269
|
+
key: string;
|
|
1270
|
+
goal: string;
|
|
1271
|
+
flowName: string;
|
|
1272
|
+
platform: string;
|
|
1273
|
+
actions: RecordedAction[];
|
|
1274
|
+
recordedAt: string;
|
|
1275
|
+
verifiedBy: string;
|
|
1276
|
+
}
|
|
1277
|
+
type ReplayCacheMode = "read-write" | "strict" | "off";
|
|
1278
|
+
type CacheWriteStatus = "saved" | "kept" | "unconfirmed" | "evicted" | "skipped";
|
|
1279
|
+
interface ReplayStepOutcome {
|
|
1280
|
+
goal: string;
|
|
1281
|
+
key: string;
|
|
1282
|
+
status: "replayed" | "handed-off" | "missed" | "live";
|
|
1283
|
+
writeStatus?: CacheWriteStatus;
|
|
1284
|
+
actionCount: number;
|
|
1285
|
+
error?: string;
|
|
1286
|
+
}
|
|
1287
|
+
interface ReplayCacheSummary {
|
|
1288
|
+
replayed: number;
|
|
1289
|
+
handedOff: number;
|
|
1290
|
+
missed: number;
|
|
1291
|
+
saved: number;
|
|
1292
|
+
evicted: number;
|
|
1293
|
+
unconfirmed: number;
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Pluggable agent executor called ONLY on cache miss or self-healing handoff.
|
|
1297
|
+
* Returns the deterministic list of actions it executed to achieve `goal`.
|
|
1298
|
+
*/
|
|
1299
|
+
interface AgentActExecutor {
|
|
1300
|
+
act(input: {
|
|
1301
|
+
goal: string;
|
|
1302
|
+
app: PromiseApp;
|
|
1303
|
+
handoffReason?: string;
|
|
1304
|
+
}): Promise<{
|
|
1305
|
+
actions: RecordedAction[];
|
|
1306
|
+
}>;
|
|
1307
|
+
}
|
|
1308
|
+
/** Compute a stable cache key for a `(flowName, platform, goal)` tuple. */
|
|
1309
|
+
declare function buildReplayCacheKey(flowName: string, platform: string, goal: string): string;
|
|
1310
|
+
/** Disk-backed replay cache store (default directory: `.spana/cache`). */
|
|
1311
|
+
declare class ReplayCacheStore {
|
|
1312
|
+
readonly cacheDir: string;
|
|
1313
|
+
constructor(cacheDir?: string);
|
|
1314
|
+
private filePath;
|
|
1315
|
+
get(key: string): ReplayCacheEntry | null;
|
|
1316
|
+
set(entry: ReplayCacheEntry): void;
|
|
1317
|
+
delete(key: string): boolean;
|
|
1318
|
+
}
|
|
1319
|
+
/** Execute a single recorded deterministic action against `PromiseApp`. */
|
|
1320
|
+
declare function replayRecordedAction(app: PromiseApp, action: RecordedAction): Promise<void>;
|
|
1321
|
+
interface ReplaySessionOptions {
|
|
1322
|
+
flowName: string;
|
|
1323
|
+
platform: string;
|
|
1324
|
+
app: PromiseApp;
|
|
1325
|
+
store?: ReplayCacheStore;
|
|
1326
|
+
mode?: ReplayCacheMode;
|
|
1327
|
+
executor?: AgentActExecutor;
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Verified Replay Cache session inspired by `e2e-inc/e2e`:
|
|
1331
|
+
*
|
|
1332
|
+
* - On cache hit: replays deterministic `{ testID }` / `systemUI()` actions with ZERO LLM calls.
|
|
1333
|
+
* - In `strict` mode (`--strict-cache`): fails deterministically if a recording is missing or no longer matches.
|
|
1334
|
+
* - In `read-write` mode: hands off to `executor` on miss or mismatch (self-healing), and ONLY commits
|
|
1335
|
+
* new/healed recordings to `.spana/cache/` after `markVerified(verifierName)` is called by a real assertion!
|
|
1336
|
+
*/
|
|
1337
|
+
declare class ReplaySession {
|
|
1338
|
+
private readonly flowName;
|
|
1339
|
+
private readonly platform;
|
|
1340
|
+
private readonly app;
|
|
1341
|
+
private readonly store;
|
|
1342
|
+
private readonly mode;
|
|
1343
|
+
private readonly executor?;
|
|
1344
|
+
private pendingWrites;
|
|
1345
|
+
private replayedKeys;
|
|
1346
|
+
private outcomes;
|
|
1347
|
+
constructor(options: ReplaySessionOptions);
|
|
1348
|
+
/** Execute a natural-language goal using replay cache first, falling back to `executor`. */
|
|
1349
|
+
act(goal: string): Promise<ReplayStepOutcome>;
|
|
1350
|
+
private runLiveAndQueue;
|
|
1351
|
+
/**
|
|
1352
|
+
* Call when a real post-action assertion (`expect(...).toBeVisible()`, `toHaveText()`, etc.)
|
|
1353
|
+
* succeeds. Flushes all preceding pending recordings to disk in `read-write` mode.
|
|
1354
|
+
*/
|
|
1355
|
+
markVerified(verifierName: string): number;
|
|
1356
|
+
/**
|
|
1357
|
+
* Call when the flow attempt fails: evicts any replayed recordings involved in the
|
|
1358
|
+
* failure (in `read-write` mode) and discards unconfirmed recordings so broken paths
|
|
1359
|
+
* are never persisted.
|
|
1360
|
+
*/
|
|
1361
|
+
markFailed(): number;
|
|
1362
|
+
getOutcomes(): ReplayStepOutcome[];
|
|
1363
|
+
getSummary(): ReplayCacheSummary;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
/** Opaque handle representing a sensitive value that should never be printed in logs or cache files. */
|
|
1367
|
+
interface SecretValue {
|
|
1368
|
+
readonly __spanaSecret: true;
|
|
1369
|
+
readonly envVar?: string;
|
|
1370
|
+
reveal(): string;
|
|
1371
|
+
toString(): string;
|
|
1372
|
+
toJSON(): string;
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* Wrap a sensitive value (or read it from `process.env[name]`) so it is automatically masked
|
|
1376
|
+
* in step logs, error messages, and agent prompts (`***REDACTED***`).
|
|
1377
|
+
*/
|
|
1378
|
+
declare function secret(valueOrEnvName: string, opts?: {
|
|
1379
|
+
fromEnv?: boolean;
|
|
1380
|
+
}): SecretValue;
|
|
1381
|
+
declare function isSecretValue(value: unknown): value is SecretValue;
|
|
1382
|
+
/** Generate a collision-resistant unique identifier or email for isolated test runs. */
|
|
1383
|
+
declare function unique(prefix?: string, opts?: {
|
|
1384
|
+
domain?: string;
|
|
1385
|
+
}): string;
|
|
1386
|
+
interface AgentProviderConfig {
|
|
1387
|
+
/** Model ID (e.g. `"gpt-4o-mini"`, `"claude-3-5-sonnet-latest"`, `"gemini-2.5-flash"`). */
|
|
1388
|
+
model?: string;
|
|
1389
|
+
/** OpenAI-compatible Chat Completions endpoint base URL (default: `https://api.openai.com/v1`). */
|
|
1390
|
+
baseUrl?: string;
|
|
1391
|
+
/** Explicit API key (or read from `apiKeyEnv` / `SPANA_AGENT_API_KEY` / `OPENAI_API_KEY`). */
|
|
1392
|
+
apiKey?: string;
|
|
1393
|
+
/** Env var name holding the API key. */
|
|
1394
|
+
apiKeyEnv?: string;
|
|
1395
|
+
/** Maximum LLM planning turns per `act()` call (default: 6). */
|
|
1396
|
+
maxSteps?: number;
|
|
1397
|
+
/** Optional custom fetch implementation (handy for tests). */
|
|
1398
|
+
fetchFn?: typeof fetch;
|
|
1399
|
+
}
|
|
1400
|
+
interface FlowAgent {
|
|
1401
|
+
/**
|
|
1402
|
+
* Perform a natural-language goal using Spana's verified replay cache first (0 LLM calls on hit),
|
|
1403
|
+
* falling back to the configured LLM executor on cache miss or UI drift.
|
|
1404
|
+
*/
|
|
1405
|
+
act(goal: string, opts?: {
|
|
1406
|
+
secrets?: Record<string, SecretValue | string>;
|
|
1407
|
+
}): Promise<ReplayStepOutcome>;
|
|
1408
|
+
/**
|
|
1409
|
+
* Ask the agent to evaluate a natural-language assertion about the current screen.
|
|
1410
|
+
* Throws an Error if the assertion evaluates to false.
|
|
1411
|
+
*/
|
|
1412
|
+
verify(assertion: string): Promise<{
|
|
1413
|
+
passed: boolean;
|
|
1414
|
+
reason: string;
|
|
1415
|
+
}>;
|
|
1416
|
+
/**
|
|
1417
|
+
* Extract structured data from the current screen using a natural-language prompt.
|
|
1418
|
+
*/
|
|
1419
|
+
extract<T = Record<string, unknown>>(instruction: string): Promise<T>;
|
|
1420
|
+
/** Flush pending replay-cache writes once a real assertion succeeds. */
|
|
1421
|
+
markVerified(verifierName?: string): number;
|
|
1422
|
+
/** Called automatically by Spana's engine at the end of a flow run. */
|
|
1423
|
+
finalize(passed: boolean): void;
|
|
1424
|
+
/** Return replay cache hit/miss/save/evict counters for reporting. */
|
|
1425
|
+
getSummary(): ReplayCacheSummary;
|
|
1426
|
+
/** Return the list of step outcomes executed through this agent. */
|
|
1427
|
+
getOutcomes(): ReplayStepOutcome[];
|
|
1428
|
+
}
|
|
1429
|
+
interface CreateFlowAgentOptions {
|
|
1430
|
+
flowName: string;
|
|
1431
|
+
platform: string;
|
|
1432
|
+
app: PromiseApp;
|
|
1433
|
+
cacheDir?: string;
|
|
1434
|
+
cacheMode?: ReplayCacheMode;
|
|
1435
|
+
store?: ReplayCacheStore;
|
|
1436
|
+
executor?: AgentActExecutor;
|
|
1437
|
+
provider?: AgentProviderConfig;
|
|
1438
|
+
/** Optional custom verify/extract runner (for tests or custom LLM adapters). */
|
|
1439
|
+
askFn?: (input: {
|
|
1440
|
+
kind: "verify" | "extract";
|
|
1441
|
+
prompt: string;
|
|
1442
|
+
screenSummary: string;
|
|
1443
|
+
}) => Promise<unknown>;
|
|
1444
|
+
}
|
|
1445
|
+
/**
|
|
1446
|
+
* Create an OpenAI-compatible Chat Completions `AgentActExecutor` + verify/extract adapter.
|
|
1447
|
+
* Works with OpenAI, Anthropic OpenAI-compat proxies, OpenRouter, Gemini OpenAI-compat, and Ollama.
|
|
1448
|
+
*/
|
|
1449
|
+
declare function createOpenAICompatibleAgentProvider(config?: AgentProviderConfig): {
|
|
1450
|
+
executor: AgentActExecutor;
|
|
1451
|
+
ask: (input: {
|
|
1452
|
+
kind: "verify" | "extract";
|
|
1453
|
+
prompt: string;
|
|
1454
|
+
screenSummary: string;
|
|
1455
|
+
}) => Promise<unknown>;
|
|
1456
|
+
};
|
|
1457
|
+
/**
|
|
1458
|
+
* Create a first-class `FlowAgent` fixture backed by Spana's deterministic `ReplaySession`.
|
|
1459
|
+
*/
|
|
1460
|
+
declare function createFlowAgent(options: CreateFlowAgentOptions): FlowAgent;
|
|
1461
|
+
interface ExploreSessionResult {
|
|
1462
|
+
goal: string;
|
|
1463
|
+
actions: RecordedAction[];
|
|
1464
|
+
flowCode: string;
|
|
1465
|
+
}
|
|
1466
|
+
/**
|
|
1467
|
+
* Format recorded agent actions into a clean, deterministic TypeScript `.flow.ts` file
|
|
1468
|
+
* (used by `spana explore "<goal>"`).
|
|
1469
|
+
*/
|
|
1470
|
+
declare function formatActionsAsFlowCode(flowName: string, actions: RecordedAction[]): string;
|
|
1471
|
+
/**
|
|
1472
|
+
* Run an autonomous exploration session against a live `PromiseApp` and return both the
|
|
1473
|
+
* executed deterministic actions and a ready-to-commit `.flow.ts` source string.
|
|
1474
|
+
*/
|
|
1475
|
+
declare function runExploreSession(options: {
|
|
1476
|
+
goal: string;
|
|
1477
|
+
app: PromiseApp;
|
|
1478
|
+
flowName?: string;
|
|
1479
|
+
executor?: AgentActExecutor;
|
|
1480
|
+
provider?: AgentProviderConfig;
|
|
1481
|
+
}): Promise<ExploreSessionResult>;
|
|
1482
|
+
|
|
1483
|
+
interface IOSSigningConfig {
|
|
1484
|
+
/** Apple Development Team ID (from developer.apple.com or Xcode) */
|
|
1485
|
+
teamId: string;
|
|
1486
|
+
/** Code signing identity (default: "Apple Development") */
|
|
1487
|
+
signingIdentity?: string;
|
|
1488
|
+
}
|
|
1489
|
+
interface BridgeConfig {
|
|
1490
|
+
/** Enable the in-app spana-bridge WebSocket server. Default: auto-detected when port/url is set. */
|
|
1491
|
+
enabled?: boolean;
|
|
1492
|
+
/** Port for the runner's spana-bridge WebSocket server (default: 9333). */
|
|
1493
|
+
port?: number;
|
|
1494
|
+
/** Host to bind the bridge server on (default: "127.0.0.1"). */
|
|
1495
|
+
host?: string;
|
|
1496
|
+
/** Explicit external bridge URL if already running (e.g. ws://127.0.0.1:9333). */
|
|
1497
|
+
url?: string;
|
|
1498
|
+
/** Connection timeout in ms when waiting for the app bridge to connect (default: 5000). */
|
|
1499
|
+
connectTimeout?: number;
|
|
1500
|
+
}
|
|
1501
|
+
interface WarmDaemonConfig {
|
|
1502
|
+
/** Keep WDA / UiAutomator2 daemons alive across test runs and reuse them. Default: false. */
|
|
1503
|
+
enabled?: boolean;
|
|
1504
|
+
/** Reuse a single browser process across flows with fresh BrowserContexts. Default: true. */
|
|
1505
|
+
reuseBrowserProcess?: boolean;
|
|
1506
|
+
/** Reuse an active WDA/UiAutomator2 session across flows instead of recreating. Default: true when warm daemons enabled. */
|
|
1507
|
+
reuseSession?: boolean;
|
|
1508
|
+
/** Optional path to store warm daemon metadata. */
|
|
1509
|
+
stateFile?: string;
|
|
1510
|
+
}
|
|
1511
|
+
interface AppConfig {
|
|
1512
|
+
url?: string;
|
|
1513
|
+
packageName?: string;
|
|
1514
|
+
bundleId?: string;
|
|
1515
|
+
/** Path to .app or .ipa for auto-install on device/simulator */
|
|
1516
|
+
appPath?: string;
|
|
1517
|
+
/** iOS code signing config for physical devices */
|
|
1518
|
+
signing?: IOSSigningConfig;
|
|
1519
|
+
/** Explicit WebKit Inspector URL or port for iOS WKWebView direct DOM access */
|
|
1520
|
+
webkitInspectorUrl?: string;
|
|
1521
|
+
webkitInspectorPort?: number;
|
|
1522
|
+
/** Explicit CDP port for Android WebView or desktop targets */
|
|
1523
|
+
cdpPort?: number;
|
|
1524
|
+
/** Pin device locale (e.g. "en_US", "sv_SE") for predictable system UI labels */
|
|
1525
|
+
locale?: string;
|
|
1526
|
+
/** Optional spana-bridge override for this app target */
|
|
1527
|
+
bridge?: BridgeConfig;
|
|
1528
|
+
}
|
|
1529
|
+
interface ElectronAppConfig {
|
|
1530
|
+
/** Path to Electron main entry file or app directory (passed to Playwright _electron.launch) */
|
|
1531
|
+
entry?: string;
|
|
1532
|
+
/** Path to a packaged Electron executable */
|
|
1533
|
+
executablePath?: string;
|
|
1534
|
+
/** Extra CLI arguments passed to Electron */
|
|
1535
|
+
args?: string[];
|
|
1536
|
+
/** Working directory for Electron launch */
|
|
1537
|
+
cwd?: string;
|
|
1538
|
+
/** Additional environment variables for Electron */
|
|
1539
|
+
env?: Record<string, string>;
|
|
1540
|
+
/** Attach to an already-running Electron app over CDP instead of launching */
|
|
1541
|
+
cdpUrl?: string;
|
|
1542
|
+
/** Remote debugging port when launching or attaching over CDP */
|
|
1543
|
+
cdpPort?: number;
|
|
1544
|
+
/** Optional URL to navigate to after launch */
|
|
1545
|
+
url?: string;
|
|
1546
|
+
/** Optional spana-bridge config */
|
|
1547
|
+
bridge?: BridgeConfig;
|
|
1548
|
+
}
|
|
1549
|
+
type ElectrobunRenderer = "native" | "cef";
|
|
1550
|
+
interface ElectrobunAppConfig {
|
|
1551
|
+
/** Path to Electrobun binary or packaged .app/.exe */
|
|
1552
|
+
executablePath?: string;
|
|
1553
|
+
/** Path to Electrobun project root (containing electrobun.config.ts) */
|
|
1554
|
+
appDir?: string;
|
|
1555
|
+
/** Extra CLI arguments passed to the Electrobun process */
|
|
1556
|
+
args?: string[];
|
|
1557
|
+
/** Working directory for launch */
|
|
1558
|
+
cwd?: string;
|
|
1559
|
+
/** Additional environment variables */
|
|
1560
|
+
env?: Record<string, string>;
|
|
1561
|
+
/** Renderer engine used by the Electrobun build: "native" (WKWebView/WebView2/WebKitGTK) or "cef" */
|
|
1562
|
+
renderer?: ElectrobunRenderer;
|
|
1563
|
+
/** Attach to an already-running Electrobun CEF/WebView2 app over CDP */
|
|
1564
|
+
cdpUrl?: string;
|
|
1565
|
+
/** Remote debugging port (ELECTROBUN_CDP_PORT / WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS) */
|
|
1566
|
+
cdpPort?: number;
|
|
1567
|
+
/** WebKit Inspector port for macOS WKWebView or Linux WebKitGTK */
|
|
1568
|
+
webkitInspectorPort?: number;
|
|
1569
|
+
/** Optional URL to navigate to after launch */
|
|
1570
|
+
url?: string;
|
|
1571
|
+
/** Optional spana-bridge config */
|
|
1572
|
+
bridge?: BridgeConfig;
|
|
1573
|
+
}
|
|
1574
|
+
type BrowserName = "chromium" | "firefox" | "webkit";
|
|
1575
|
+
type WebBrowserEngine = "auto" | "playwright" | "cdp" | "lightpanda";
|
|
1576
|
+
type WebContextIsolation = "fresh" | "hot-cache";
|
|
1577
|
+
type WebResourceBlockType = "image" | "font" | "media" | "stylesheet";
|
|
1578
|
+
type VideoRecordingMode = "off" | "on" | "retain-on-failure";
|
|
1579
|
+
type StorybookValue = string | number | boolean | null;
|
|
1580
|
+
interface StorybookConfig {
|
|
1581
|
+
/** Optional dedicated Storybook URL (falls back to apps.web.url when omitted) */
|
|
1582
|
+
url?: string;
|
|
1583
|
+
/** Preview iframe path used to render isolated stories (default: /iframe.html) */
|
|
1584
|
+
iframePath?: string;
|
|
1585
|
+
}
|
|
1586
|
+
interface WebExecutionConfig {
|
|
1587
|
+
browser?: BrowserName;
|
|
1588
|
+
/** Browser engine backend: "playwright" (default), "cdp" (direct CDP WebSocket — zero Playwright pipe), or "lightpanda". */
|
|
1589
|
+
engine?: WebBrowserEngine;
|
|
1590
|
+
/** Connect to an existing CDP browser / Lightpanda endpoint (e.g. "http://127.0.0.1:9222"). */
|
|
1591
|
+
cdpUrl?: string;
|
|
1592
|
+
/** Connect to a remote Playwright server WebSocket (e.g. BrowserStack Automate Web `wss://cdp.browserstack.com/playwright?...`). */
|
|
1593
|
+
wsEndpoint?: string;
|
|
1594
|
+
/** Explicit browser executable path (e.g. system Chrome or custom Chromium binary). */
|
|
1595
|
+
executablePath?: string;
|
|
1596
|
+
/** Browser release channel (e.g. "chrome", "chrome-beta", "msedge"). */
|
|
1597
|
+
channel?: string;
|
|
1598
|
+
headless?: boolean;
|
|
1599
|
+
/** Navigation readiness event for launchApp/openLink (default: "load"). */
|
|
1600
|
+
waitUntil?: "domcontentloaded" | "load" | "networkidle" | "commit";
|
|
1601
|
+
/** Collapse CSS transitions & animations to 0.001ms for faster deterministic runs. */
|
|
1602
|
+
instantAnimations?: boolean;
|
|
1603
|
+
/** Abort heavy asset requests ("image" | "font" | "media" | "stylesheet") during web runs. */
|
|
1604
|
+
blockResources?: WebResourceBlockType[];
|
|
1605
|
+
/** Reuse a persistent warm Chromium daemon across runs via CDP (chromium only). */
|
|
1606
|
+
warmBrowser?: boolean;
|
|
1607
|
+
/** Scope key for isolating warm Chromium daemons across concurrent repos/runs (defaults to cwd hash). */
|
|
1608
|
+
warmBrowserScope?: string;
|
|
1609
|
+
/** Create a fresh isolated BrowserContext per flow using pre-warmed context pooling + background teardown. */
|
|
1610
|
+
freshContextPerFlow?: boolean;
|
|
1611
|
+
/**
|
|
1612
|
+
* Context isolation strategy when `freshContextPerFlow` is enabled (Direct CDP):
|
|
1613
|
+
* - `"fresh"` (default): new `Target.createBrowserContext` per flow (strictest isolation).
|
|
1614
|
+
* - `"hot-cache"`: keeps Chromium's HTTP & V8 bytecode cache hot while wiping cookies, localStorage,
|
|
1615
|
+
* sessionStorage, IndexedDB, CacheStorage, and service workers between flows (~4 ms reset!).
|
|
1616
|
+
*/
|
|
1617
|
+
contextIsolation?: WebContextIsolation;
|
|
1618
|
+
/** Max worker contexts sharing one Chromium browser process under `--parallel` (default: 2 to avoid CDP/IO contention). */
|
|
1619
|
+
maxContextsPerBrowser?: number;
|
|
1620
|
+
/** Automatically attach a CDP WebAuthn virtual authenticator (passkey) to every fresh context. */
|
|
1621
|
+
virtualAuthenticator?: boolean | VirtualAuthenticatorOptions;
|
|
1622
|
+
/** Optional Playwright storage state JSON file to preload for web runs */
|
|
1623
|
+
storageState?: string;
|
|
1624
|
+
/** Print verbose Playwright runtime events to stdout for local web debugging */
|
|
1625
|
+
verboseLogging?: boolean;
|
|
1626
|
+
/** Optional Storybook config for isolated component/story flows in the browser runtime */
|
|
1627
|
+
storybook?: StorybookConfig;
|
|
1628
|
+
/** Unpacked Chromium browser extension directories to load at launch. */
|
|
1629
|
+
extensions?: string[];
|
|
1630
|
+
/** Emulate `prefers-color-scheme` on web launch (`"dark"` | `"light"` | `"no-preference"`). */
|
|
1631
|
+
colorScheme?: "dark" | "light" | "no-preference";
|
|
1632
|
+
/** Emulate `prefers-reduced-motion` on web launch (`"reduce"` | `"no-preference"`). */
|
|
1633
|
+
reducedMotion?: "reduce" | "no-preference";
|
|
1634
|
+
/** Emulate IANA timezone ID on Chromium launch (e.g. `"America/New_York"`). */
|
|
1635
|
+
timezoneId?: string;
|
|
1636
|
+
}
|
|
1637
|
+
interface CloudAppReferenceConfig {
|
|
1638
|
+
/** Existing remote app reference, e.g. bs://... or storage:... */
|
|
1639
|
+
id?: string;
|
|
1640
|
+
/** Local file path to upload when the provider supports managed upload */
|
|
1641
|
+
path?: string;
|
|
1642
|
+
/** Override the uploaded file name when the provider supports it */
|
|
1643
|
+
name?: string;
|
|
1644
|
+
}
|
|
1645
|
+
interface BrowserStackAppConfig extends CloudAppReferenceConfig {
|
|
1646
|
+
/** Stable BrowserStack app alias */
|
|
1647
|
+
customId?: string;
|
|
1648
|
+
}
|
|
1649
|
+
interface BrowserStackLocalConfig {
|
|
1650
|
+
enabled?: boolean;
|
|
1651
|
+
binary?: string;
|
|
1652
|
+
identifier?: string;
|
|
1653
|
+
args?: string[];
|
|
1654
|
+
}
|
|
1655
|
+
interface BrowserStackHelperConfig {
|
|
1656
|
+
app?: BrowserStackAppConfig;
|
|
1657
|
+
local?: BrowserStackLocalConfig;
|
|
1658
|
+
options?: Record<string, unknown>;
|
|
1659
|
+
}
|
|
1660
|
+
interface SauceConnectConfig {
|
|
1661
|
+
enabled?: boolean;
|
|
1662
|
+
binary?: string;
|
|
1663
|
+
tunnelName?: string;
|
|
1664
|
+
args?: string[];
|
|
1665
|
+
}
|
|
1666
|
+
interface SauceLabsHelperConfig {
|
|
1667
|
+
app?: CloudAppReferenceConfig;
|
|
1668
|
+
connect?: SauceConnectConfig;
|
|
1669
|
+
options?: Record<string, unknown>;
|
|
1670
|
+
}
|
|
1671
|
+
interface AppiumExecutionConfig {
|
|
1672
|
+
serverUrl?: string;
|
|
1673
|
+
capabilities?: Record<string, unknown>;
|
|
1674
|
+
/**
|
|
1675
|
+
* Platform-specific capabilities merged on top of `capabilities` when the
|
|
1676
|
+
* matching platform runs. Useful when you want different `appium:deviceName`
|
|
1677
|
+
* or `appium:platformVersion` for Android vs iOS.
|
|
1678
|
+
*/
|
|
1679
|
+
platformCapabilities?: {
|
|
1680
|
+
android?: Record<string, unknown>;
|
|
1681
|
+
ios?: Record<string, unknown>;
|
|
1682
|
+
};
|
|
1683
|
+
capabilitiesFile?: string;
|
|
1684
|
+
reportToProvider?: boolean;
|
|
1685
|
+
browserstack?: BrowserStackHelperConfig;
|
|
1686
|
+
saucelabs?: SauceLabsHelperConfig;
|
|
1687
|
+
/** Path to a custom cloud provider module (default export must conform to CloudProvider interface). */
|
|
1688
|
+
cloudProvider?: string;
|
|
1689
|
+
/**
|
|
1690
|
+
* Opt in to having spana spawn a local `appium` subprocess for the
|
|
1691
|
+
* duration of the test run. Requires `appium` to be on PATH. When true,
|
|
1692
|
+
* `serverUrl` (if set) is ignored and a URL is assigned to the
|
|
1693
|
+
* auto-started server instead. Off by default — spana never spawns
|
|
1694
|
+
* background processes unless you ask.
|
|
1695
|
+
*/
|
|
1696
|
+
autoStart?: boolean;
|
|
1697
|
+
/** Override the `appium` binary name. Default: "appium". */
|
|
1698
|
+
autoStartBinary?: string;
|
|
1699
|
+
/** Extra CLI args to forward to the spawned Appium process. */
|
|
1700
|
+
autoStartArgs?: readonly string[];
|
|
1701
|
+
}
|
|
1702
|
+
interface ExecutionConfig {
|
|
1703
|
+
mode?: "local" | "appium";
|
|
1704
|
+
web?: WebExecutionConfig;
|
|
1705
|
+
appium?: AppiumExecutionConfig;
|
|
1706
|
+
/** In-app spana-bridge configuration shared across webview targets */
|
|
1707
|
+
bridge?: BridgeConfig;
|
|
1708
|
+
/** Warm daemon & process reuse settings for fast repeated runs */
|
|
1709
|
+
warmDaemons?: WarmDaemonConfig;
|
|
1710
|
+
}
|
|
1711
|
+
interface ArtifactConfig {
|
|
1712
|
+
outputDir?: string;
|
|
1713
|
+
captureOnFailure?: boolean;
|
|
1714
|
+
captureOnSuccess?: boolean;
|
|
1715
|
+
captureSteps?: boolean;
|
|
1716
|
+
screenshot?: boolean;
|
|
1717
|
+
uiHierarchy?: boolean;
|
|
1718
|
+
consoleLogs?: boolean;
|
|
1719
|
+
jsErrors?: boolean;
|
|
1720
|
+
har?: boolean;
|
|
1721
|
+
jsCoverage?: boolean;
|
|
1722
|
+
/** Video / screencast recording mode: "off" (default), "on", or "retain-on-failure". */
|
|
1723
|
+
video?: VideoRecordingMode;
|
|
1724
|
+
/** Embed interactive step-by-step visual playback timeline inside report.html (auto-enabled when video !== "off"). */
|
|
1725
|
+
playback?: boolean;
|
|
1726
|
+
/** Write Playwright-style interactive `trace.json` + `trace-viewer.html` bundle per flow. */
|
|
1727
|
+
trace?: boolean;
|
|
1728
|
+
/** Automatically attach Android `adb logcat` / iOS Simulator crash logs on native failure (default: true). */
|
|
1729
|
+
nativeLogs?: boolean;
|
|
1730
|
+
}
|
|
1731
|
+
interface HookContext {
|
|
1732
|
+
app: unknown;
|
|
1733
|
+
expect?: unknown;
|
|
1734
|
+
platform?: Platform;
|
|
1735
|
+
result?: unknown;
|
|
1736
|
+
summary?: unknown;
|
|
1737
|
+
}
|
|
1738
|
+
interface ProvConfig {
|
|
1739
|
+
apps?: {
|
|
1740
|
+
web?: AppConfig;
|
|
1741
|
+
android?: AppConfig;
|
|
1742
|
+
ios?: AppConfig;
|
|
1743
|
+
electron?: ElectronAppConfig;
|
|
1744
|
+
electrobun?: ElectrobunAppConfig;
|
|
1745
|
+
};
|
|
1746
|
+
defaults?: {
|
|
1747
|
+
waitTimeout?: number;
|
|
1748
|
+
pollInterval?: number;
|
|
1749
|
+
settleTimeout?: number;
|
|
1750
|
+
retries?: number;
|
|
1751
|
+
/** Pause after each action (tap, scroll) to let the UI settle. Default: 0 (disabled). */
|
|
1752
|
+
waitForIdleTimeout?: number;
|
|
1753
|
+
/** Delay between each character when typing. Default: 0 (instant). */
|
|
1754
|
+
typingDelay?: number;
|
|
1755
|
+
/** Starting poll interval for adaptive backoff. Default: 50ms. Set equal to pollInterval to disable adaptive backoff. */
|
|
1756
|
+
initialPollInterval?: number;
|
|
1757
|
+
/** Max age in ms before cached hierarchy is stale. Default: 100. Set to 0 to disable. */
|
|
1758
|
+
hierarchyCacheTtl?: number;
|
|
1759
|
+
/** Max depth for UI hierarchy snapshots on iOS. Default: 100. */
|
|
1760
|
+
snapshotMaxDepth?: number;
|
|
1761
|
+
/** Delay in ms between retry attempts of a failed flow. Default: 0 (immediate). */
|
|
1762
|
+
retryDelay?: number;
|
|
1763
|
+
/** Max workers per platform when using --parallel. */
|
|
1764
|
+
workers?: number;
|
|
1765
|
+
/** Number of isolated OS worker processes sharing a dynamic longest-first flow queue (`--processes M`). */
|
|
1766
|
+
processes?: number;
|
|
1767
|
+
/** Max in-process workers before automatically sharding across multiple OS processes (default: 8). */
|
|
1768
|
+
maxWorkersPerProcess?: number;
|
|
1769
|
+
/** Default tap mode when a DOM channel resolves an element: "native" (real touch, default) or "dom" (fast synthetic click). */
|
|
1770
|
+
tapMode?: TapMode;
|
|
1771
|
+
/** Pin device locale across targets so system UI sheet labels stay deterministic. */
|
|
1772
|
+
locale?: string;
|
|
1773
|
+
/** Fail web element waits early when the page is idle & readyState === "complete" instead of waiting full waitTimeout. */
|
|
1774
|
+
failFastWhenIdle?: boolean;
|
|
1775
|
+
/** Consecutive stable animation frames required before pointer actions on web. Default: 2. Set 0 to disable. */
|
|
1776
|
+
actionStableFrames?: number;
|
|
1777
|
+
};
|
|
1778
|
+
platforms?: Platform[];
|
|
1779
|
+
/** Run platforms concurrently when they use independent resources. Default: false (serial). */
|
|
1780
|
+
parallelPlatforms?: boolean;
|
|
1781
|
+
flowDir?: string;
|
|
1782
|
+
launchOptions?: LaunchOptions;
|
|
1783
|
+
/**
|
|
1784
|
+
* Reporter names or module paths. Built-in: "console", "json", "junit", "html", "allure".
|
|
1785
|
+
* Custom reporters: provide a relative path (e.g., "./reporters/slack.ts") that default-exports
|
|
1786
|
+
* a Reporter object or a `(options: { outputDir: string }) => Reporter` factory function.
|
|
1787
|
+
*/
|
|
1788
|
+
reporters?: string[];
|
|
1789
|
+
hooks?: {
|
|
1790
|
+
beforeAll?: (ctx: HookContext) => Promise<void>;
|
|
1791
|
+
beforeEach?: (ctx: HookContext) => Promise<void>;
|
|
1792
|
+
afterEach?: (ctx: HookContext) => Promise<void>;
|
|
1793
|
+
afterAll?: (ctx: HookContext) => Promise<void>;
|
|
1794
|
+
};
|
|
1795
|
+
artifacts?: ArtifactConfig;
|
|
1796
|
+
execution?: ExecutionConfig;
|
|
1797
|
+
visualRegression?: {
|
|
1798
|
+
threshold?: number;
|
|
1799
|
+
maxDiffPixelRatio?: number;
|
|
1800
|
+
baselinesDir?: string;
|
|
1801
|
+
mode?: "pixel" | "layout-tolerant";
|
|
1802
|
+
};
|
|
1803
|
+
/** Pluggable CI filters evaluated when `--changed-since <ref>` is passed. */
|
|
1804
|
+
filters?: Array<{
|
|
1805
|
+
name: string;
|
|
1806
|
+
filter: (flows: any[], context: any) => Promise<any> | any;
|
|
1807
|
+
}>;
|
|
1808
|
+
/** Verified replay cache settings for optional agentic steps (`.spana/cache/`). */
|
|
1809
|
+
replayCache?: {
|
|
1810
|
+
mode?: "read-write" | "strict" | "off";
|
|
1811
|
+
dir?: string;
|
|
1812
|
+
};
|
|
1813
|
+
/** Auto-boot one or more dev servers before tests run and tear them down cleanly afterwards. */
|
|
1814
|
+
webServer?: WebServerConfig | WebServerConfig[];
|
|
1815
|
+
/** Named test projects with dependency DAG (`dependencies`, `teardown`, per-project `storageState` / `browser` / `testMatch`). */
|
|
1816
|
+
projects?: ProjectConfig[];
|
|
1817
|
+
/** Optional LLM provider configuration for `agent.act()` / `agent.verify()` / `agent.extract()` and `spana explore`. */
|
|
1818
|
+
agent?: Omit<AgentProviderConfig, "fetchFn">;
|
|
1819
|
+
}
|
|
1820
|
+
declare function defineConfig(config: ProvConfig): ProvConfig;
|
|
1821
|
+
|
|
1822
|
+
interface SecondarySessionOptions {
|
|
1823
|
+
name: string;
|
|
1824
|
+
platform: "web";
|
|
1825
|
+
baseUrl?: string;
|
|
1826
|
+
headless?: boolean;
|
|
1827
|
+
browser?: BrowserName;
|
|
1828
|
+
storageState?: string;
|
|
1829
|
+
verboseLogging?: boolean;
|
|
1830
|
+
storybook?: StorybookConfig;
|
|
1831
|
+
}
|
|
1832
|
+
interface SecondarySession {
|
|
1833
|
+
readonly name: string;
|
|
1834
|
+
readonly platform: "web";
|
|
1835
|
+
readonly app: PromiseApp;
|
|
1836
|
+
readonly expect: PromiseExpectFn;
|
|
1837
|
+
disconnect(): Promise<void>;
|
|
1838
|
+
}
|
|
1839
|
+
interface Sessions {
|
|
1840
|
+
open(opts: SecondarySessionOptions): Promise<SecondarySession>;
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
interface WhenCondition {
|
|
1844
|
+
/** Only run on these platforms */
|
|
1845
|
+
platform?: Platform | Platform[];
|
|
1846
|
+
/** Only run when this environment variable is set */
|
|
1847
|
+
env?: string;
|
|
1848
|
+
}
|
|
1849
|
+
type FlowSkipCondition = boolean | (WhenCondition & {
|
|
1850
|
+
reason?: string;
|
|
1851
|
+
});
|
|
1852
|
+
interface FlowDefaults {
|
|
1853
|
+
waitTimeout?: number;
|
|
1854
|
+
pollInterval?: number;
|
|
1855
|
+
settleTimeout?: number;
|
|
1856
|
+
waitForIdleTimeout?: number;
|
|
1857
|
+
typingDelay?: number;
|
|
1858
|
+
/** Starting poll interval for adaptive backoff. Default: 50ms. */
|
|
1859
|
+
initialPollInterval?: number;
|
|
1860
|
+
/** Hierarchy cache TTL in ms. Default: 100. Set to 0 to disable. */
|
|
1861
|
+
hierarchyCacheTtl?: number;
|
|
1862
|
+
}
|
|
1863
|
+
interface FlowConfig<R extends string = string> {
|
|
1864
|
+
tags?: string[];
|
|
1865
|
+
platforms?: Platform[];
|
|
1866
|
+
timeout?: number;
|
|
1867
|
+
autoLaunch?: boolean;
|
|
1868
|
+
/** Per-flow launch defaults. Merged with project launchOptions and manual app.launch() calls. */
|
|
1869
|
+
launchOptions?: LaunchOptions<R>;
|
|
1870
|
+
artifacts?: ArtifactConfig;
|
|
1871
|
+
when?: WhenCondition;
|
|
1872
|
+
skip?: FlowSkipCondition;
|
|
1873
|
+
fixme?: FlowSkipCondition;
|
|
1874
|
+
only?: boolean;
|
|
1875
|
+
retries?: number;
|
|
1876
|
+
/** Per-flow overrides for timing defaults. Merged with global defaults. */
|
|
1877
|
+
defaults?: FlowDefaults;
|
|
1878
|
+
}
|
|
1879
|
+
interface FlowContext<T extends string = string, R extends string = string> {
|
|
1880
|
+
app: PromiseApp<T, R>;
|
|
1881
|
+
expect: PromiseExpectFn<T>;
|
|
1882
|
+
platform: Platform;
|
|
1883
|
+
sessions: Sessions;
|
|
1884
|
+
/** First-class verified replay-cache AI agent fixture (`agent.act()`, `agent.verify()`, `agent.extract()`). */
|
|
1885
|
+
agent?: FlowAgent;
|
|
1886
|
+
/** Group related actions into a named nested step in reports and Trace Viewer. */
|
|
1887
|
+
step?: <A>(name: string, fn: () => Promise<A>) => Promise<A>;
|
|
1888
|
+
}
|
|
1889
|
+
type FlowFn<T extends string = string, R extends string = string> = (ctx: FlowContext<T, R>) => Promise<void>;
|
|
1890
|
+
interface FlowDefinition<T extends string = string, R extends string = string> {
|
|
1891
|
+
name: string;
|
|
1892
|
+
fn: FlowFn<T, R>;
|
|
1893
|
+
config: FlowConfig<R>;
|
|
1894
|
+
sourcePath?: string;
|
|
1895
|
+
}
|
|
1896
|
+
declare function flow<T extends string = string, R extends string = string>(name: string, fn: FlowFn<T, R>): FlowDefinition<T, R>;
|
|
1897
|
+
declare function flow<T extends string = string, R extends string = string>(name: string, config: FlowConfig<R>, fn: FlowFn<T, R>): FlowDefinition<T, R>;
|
|
1898
|
+
declare namespace flow {
|
|
1899
|
+
const skip: {
|
|
1900
|
+
<T extends string = string, R extends string = string>(name: string, fn: FlowFn<T, R>): FlowDefinition<T, R>;
|
|
1901
|
+
<T extends string = string, R extends string = string>(name: string, config: FlowConfig<R>, fn: FlowFn<T, R>): FlowDefinition<T, R>;
|
|
1902
|
+
};
|
|
1903
|
+
const fixme: {
|
|
1904
|
+
<T extends string = string, R extends string = string>(name: string, fn: FlowFn<T, R>): FlowDefinition<T, R>;
|
|
1905
|
+
<T extends string = string, R extends string = string>(name: string, config: FlowConfig<R>, fn: FlowFn<T, R>): FlowDefinition<T, R>;
|
|
1906
|
+
};
|
|
1907
|
+
const only: {
|
|
1908
|
+
<T extends string = string, R extends string = string>(name: string, fn: FlowFn<T, R>): FlowDefinition<T, R>;
|
|
1909
|
+
<T extends string = string, R extends string = string>(name: string, config: FlowConfig<R>, fn: FlowFn<T, R>): FlowDefinition<T, R>;
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
export { type CdpSessionHandle as $, type AppiumExecutionConfig as A, type BrowserRouteMatcher as B, type BrowserHAR as C, DriverError as D, type ExtendedSelector as E, type FlowContext as F, type AgentActExecutor as G, type AgentProviderConfig as H, type ArtifactConfig as I, type BackUntilVisibleOptions as J, type BiometricOptions as K, type BridgeConfig as L, type BrowserCookie as M, type BrowserDialogHandler as N, type BrowserDialogInfo as O, type Platform as P, type BrowserDownloadInfo as Q, type RawDriverService as R, type Selector as S, type TapMode as T, type BrowserNetworkConditions as U, type VirtualAuthenticatorOptions as V, type BrowserRequestClient as W, type BrowserRequestOptions as X, type BrowserRequestResponse as Y, type BrowserResponseInfo as Z, type CacheWriteStatus as _, type DomElementMatch as a, buildDomFillScript as a$, type CreateFlowAgentOptions as a0, type DataSnapshotOptions as a1, type DataSnapshotResult as a2, DeviceInfo as a3, type DeviceStateConfig as a4, type DismissKeyboardOptions as a5, type DomChannelKind as a6, type DomRect as a7, type ElectronAppConfig as a8, type ExploreSessionResult as a9, type ReplayStepOutcome as aA, type RetryAssertionOptions as aB, type RunningWebServer as aC, SPANA_INJECTED_RUNTIME_SCRIPT as aD, type ScrollUntilVisibleOptions as aE, type SecondarySession as aF, type SecondarySessionOptions as aG, type SecretValue as aH, type SelectOptionInput as aI, type SelectorModifiers as aJ, type Sessions as aK, type StartWebServersOptions as aL, type StorybookConfig as aM, type StorybookOpenOptions as aN, type StorybookValue as aO, type ToPassExpectation as aP, type TouchAction as aQ, type TouchSequence as aR, type VideoRecordingMode as aS, type WarmDaemonConfig as aT, type WebBrowserEngine as aU, type WebContextIsolation as aV, type WebExecutionConfig as aW, type WebResourceBlockType as aX, type WebServerConfig as aY, assertDataSnapshot as aZ, buildDomActionabilityDiagScript as a_, type FlowAgent as aa, type FlowSkipCondition as ab, type FrameScope as ac, type Geolocation as ad, type InjectedRuntimeMethod as ae, type IsolatedBrowserContext as af, type LaunchOptions as ag, type NegatedPromiseExpectation as ah, type ObjectSelector as ai, type Orientation as aj, type PermissionOptions as ak, type PollExpectation as al, type PollMatchers as am, type ProjectConfig as an, type ProjectExecutionPlan as ao, type PromiseExpectFn as ap, type PromiseExpectation as aq, type PushPayload as ar, type RecordedAction as as, type RelativeSelector as at, type ReplayCacheEntry as au, type ReplayCacheMode as av, ReplayCacheStore as aw, type ReplayCacheSummary as ax, ReplaySession as ay, type ReplaySessionOptions as az, type ProvConfig as b, buildDomWaitForHiddenScript as b0, buildDomWaitForMatchScript as b1, buildDomWaitForSelectorScript as b2, buildInjectedCallScript as b3, buildReplayCacheKey as b4, byCss as b5, byRole as b6, checkServerReady as b7, createFlowAgent as b8, createOpenAICompatibleAgentProvider as b9, defineConfig as ba, filterFlowsForProject as bb, filterSelector as bc, first as bd, flow as be, formatActionsAsFlowCode as bf, inFrame as bg, isComposableDomSelector as bh, isHttpUrlReady as bi, isSecretValue as bj, isSystemUISelector as bk, isTcpPortOpen as bl, isTestIDSelector as bm, last as bn, matchDataSnapshot as bo, nth as bp, or as bq, replayRecordedAction as br, resolveProjectExecutionPlan as bs, runExploreSession as bt, secret as bu, startWebServer as bv, startWebServers as bw, systemUI as bx, unique as by, within as bz, type DomChannel as c, type DomTargetInfo as d, type DomWaitForSelectorOptions as e, type DomWaitForHiddenOptions as f, type DomWaitForMatchOptions as g, type DomWaitForMatchResult as h, type DomFillOptions as i, type BrowserMockResponse as j, type DomIdleOptions as k, type DomStorageEntries as l, type DomClearStorageOptions as m, type BrowserConsoleLog as n, type BrowserJSError as o, type BrowserName as p, type BrowserEmulationOptions as q, type FlowDefinition as r, type ElectrobunAppConfig as s, type ElectrobunRenderer as t, type AppConfig as u, type VirtualCredential as v, type FlowConfig as w, type VirtualCredentialInput as x, type PromiseApp as y, type FlowFn as z };
|