@jackwener/browsermcp 0.0.39-embedded.0 → 0.0.40-embedded.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/CHANGELOG.md +12 -0
- package/README.md +6 -2
- package/dist/docs/api-reference.md +10 -3
- package/dist/docs/api-use.md +15 -3
- package/dist/docs/instructions.md +1 -1
- package/dist/src/api/browser.js +2 -0
- package/dist/src/api/browser.js.map +1 -1
- package/dist/src/api/commands.d.ts +8 -0
- package/dist/src/api/content-wait.d.ts +18 -0
- package/dist/src/api/content-wait.js +48 -0
- package/dist/src/api/content-wait.js.map +1 -0
- package/dist/src/api/tab.d.ts +18 -0
- package/dist/src/api/tab.js +14 -2
- package/dist/src/api/tab.js.map +1 -1
- package/dist/src/backends/extension-page.js +2 -2
- package/dist/src/backends/extension-page.js.map +1 -1
- package/dist/src/electron/backend.js +2 -0
- package/dist/src/electron/backend.js.map +1 -1
- package/dist/src/electron/driver.d.ts +4 -0
- package/dist/src/electron/driver.js +23 -1
- package/dist/src/electron/driver.js.map +1 -1
- package/dist/src/electron/page.js +231 -35
- package/dist/src/protocol.d.ts +9 -0
- package/dist/src/protocol.js.map +1 -1
- package/dist/src/shared/api-contract.d.ts +2 -2
- package/dist/src/shared/aria-tree.js +7 -1
- package/dist/src/shared/aria-tree.js.map +1 -1
- package/dist/src/shared/closed-shadow.d.ts +10 -0
- package/dist/src/shared/closed-shadow.js +50 -0
- package/dist/src/shared/closed-shadow.js.map +1 -0
- package/dist/src/shared/engine.d.ts +12 -0
- package/dist/src/shared/engine.js +97 -30
- package/dist/src/shared/engine.js.map +1 -1
- package/dist/src/shared/inflight.d.ts +14 -0
- package/dist/src/shared/inflight.js +50 -0
- package/dist/src/shared/inflight.js.map +1 -0
- package/dist/src/shared/injected-source.js +2 -2
- package/dist/src/shared/injected-source.js.map +1 -1
- package/dist/src/shared/page-contract.d.ts +21 -5
- package/docs/api-reference.md +10 -3
- package/docs/api-use.md +15 -3
- package/docs/instructions.md +1 -1
- package/extension/dist/background.js +195 -47
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/page.js +231 -35
- package/package.json +2 -2
|
@@ -94,8 +94,8 @@
|
|
|
94
94
|
const el = refToEl.get(ref)?.deref();
|
|
95
95
|
return el?.isConnected && el.ownerDocument === document ? el : void 0;
|
|
96
96
|
}
|
|
97
|
-
function pageError(code, message, hint) {
|
|
98
|
-
return Object.assign(new Error(message), { code, hint });
|
|
97
|
+
function pageError(code, message, hint, data) {
|
|
98
|
+
return Object.assign(new Error(message), { code, hint, ...data && { data } });
|
|
99
99
|
}
|
|
100
100
|
function requireRef(ref) {
|
|
101
101
|
const el = liveElement(ref);
|
|
@@ -121,7 +121,29 @@
|
|
|
121
121
|
function ariaRefOf(el) {
|
|
122
122
|
return stableRefOf(el);
|
|
123
123
|
}
|
|
124
|
-
var
|
|
124
|
+
var REGION_ROLES = /* @__PURE__ */ new Set(["form", "dialog", "alertdialog", "region", "navigation", "main", "complementary", "banner", "contentinfo", "search", "group", "listitem", "row", "article", "tabpanel", "menu", "list", "table"]);
|
|
125
|
+
function regionOf(el) {
|
|
126
|
+
for (let n = el; ; ) {
|
|
127
|
+
const parent = n.parentElement;
|
|
128
|
+
if (!parent) {
|
|
129
|
+
const root = n.getRootNode();
|
|
130
|
+
if (!(root instanceof ShadowRoot)) return "page";
|
|
131
|
+
const host = root.host;
|
|
132
|
+
const label = host.getAttribute("aria-label");
|
|
133
|
+
return `shadow root of <${host.localName}${host.id ? `#${host.id}` : ""}>${label ? ` "${label.slice(0, 60)}"` : ""}`;
|
|
134
|
+
}
|
|
135
|
+
n = parent;
|
|
136
|
+
const role = roleOf(n);
|
|
137
|
+
const name = REGION_ROLES.has(role) ? nameOf(n).replace(/\s+/g, " ").trim().slice(0, 60) : "";
|
|
138
|
+
if (name || ["form", "dialog", "alertdialog", "navigation", "main", "search"].includes(role)) return `${role}${name ? ` "${name}"` : ""}`;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
var candidate = (el) => ({ ref: ariaRefOf(el), role: roleOf(el), name: nameOf(el).replace(/\s+/g, " ").trim().slice(0, 80), within: regionOf(el), tag: el.tagName.toLowerCase(), text: text(el).slice(0, 80), visible: is(el, "visible"), box: box(el) });
|
|
142
|
+
function ambiguity(n, selector, visibleN, matches) {
|
|
143
|
+
const candidates = matches.slice(0, 8).map(candidate);
|
|
144
|
+
const list = candidates.map((c) => `[ref=${c.ref}] ${c.role || c.tag}${c.name ? ` "${c.name}"` : ""} in ${c.within}${c.visible ? "" : " (hidden)"}`).join("; ");
|
|
145
|
+
return { code: "selector_ambiguous", message: `${n} elements match ${selector}${visibleN ? ` (${visibleN} visible)` : ""}: ${list}${n > 8 ? `; \u2026${n - 8} more` : ""}`, hint: "Act on one of these refs, or scope the locator with within (a container ref or selector).", candidates };
|
|
146
|
+
}
|
|
125
147
|
var actionElement = null;
|
|
126
148
|
function actionTarget() {
|
|
127
149
|
const el = actionElement;
|
|
@@ -148,7 +170,7 @@
|
|
|
148
170
|
if (matches.length > 1 && strict) {
|
|
149
171
|
const visible = matches.filter((m) => is(m, "visible"));
|
|
150
172
|
if (visible.length === 1) el = visible[0];
|
|
151
|
-
else return { error:
|
|
173
|
+
else return { error: ambiguity(matches.length, selector, visible.length, visible.length > 1 ? visible : matches), retry: false };
|
|
152
174
|
}
|
|
153
175
|
for (const st of states) {
|
|
154
176
|
const r = stateOf(el, st);
|
|
@@ -306,27 +328,118 @@
|
|
|
306
328
|
const el = actEl();
|
|
307
329
|
return el instanceof HTMLInputElement ? el.files?.length ?? 0 : 0;
|
|
308
330
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
331
|
+
var nativeShadowRoot = Object.getOwnPropertyDescriptor(Element.prototype, "shadowRoot").get;
|
|
332
|
+
var adoptedRoots = /* @__PURE__ */ new WeakMap();
|
|
333
|
+
Object.defineProperty(Element.prototype, "shadowRoot", {
|
|
334
|
+
configurable: true,
|
|
335
|
+
enumerable: true,
|
|
336
|
+
get() {
|
|
337
|
+
return nativeShadowRoot.call(this) ?? adoptedRoots.get(this) ?? null;
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
var SHADOW_HOST_TAGS = /* @__PURE__ */ new Set(["ARTICLE", "ASIDE", "BLOCKQUOTE", "BODY", "DIV", "FOOTER", "H1", "H2", "H3", "H4", "H5", "H6", "HEADER", "MAIN", "NAV", "P", "SECTION", "SPAN"]);
|
|
341
|
+
var shadowChecked = /* @__PURE__ */ new WeakSet();
|
|
342
|
+
var MAX_SHADOW_CANDIDATES = 40;
|
|
343
|
+
function closedShadowCandidates() {
|
|
344
|
+
const out = [];
|
|
345
|
+
const visit = (root) => {
|
|
346
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT);
|
|
347
|
+
for (let n = walker.nextNode(); n && out.length < MAX_SHADOW_CANDIDATES; n = walker.nextNode()) {
|
|
348
|
+
const shadow = n.shadowRoot;
|
|
349
|
+
if (shadow) {
|
|
350
|
+
visit(shadow);
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
if (shadowChecked.has(n)) continue;
|
|
354
|
+
const custom = n.localName.includes("-");
|
|
355
|
+
if (custom) {
|
|
356
|
+
if (!n.matches(":defined")) continue;
|
|
357
|
+
} else if (!SHADOW_HOST_TAGS.has(n.tagName) || n.childElementCount || (n.textContent ?? "").trim()) continue;
|
|
358
|
+
else {
|
|
359
|
+
const r = n.getBoundingClientRect();
|
|
360
|
+
if (!r.width || !r.height) continue;
|
|
361
|
+
}
|
|
362
|
+
shadowChecked.add(n);
|
|
363
|
+
out.push(n);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
visit(document);
|
|
367
|
+
return out;
|
|
368
|
+
}
|
|
369
|
+
function adoptShadowRoot(root) {
|
|
370
|
+
if (!(root instanceof ShadowRoot) || !root.host || nativeShadowRoot.call(root.host)) return false;
|
|
371
|
+
adoptedRoots.set(root.host, root);
|
|
372
|
+
watchDocument(root, true);
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
var OWN_LAYERS = /* @__PURE__ */ new Set(["browsermcp-overlay-root", "browsermcp-annotate"]);
|
|
376
|
+
var STYLE_REPEAT_MS = 200;
|
|
377
|
+
var activityState = { n: 0, last: performance.now(), installed: performance.now() };
|
|
378
|
+
var watchedDocuments = /* @__PURE__ */ new WeakSet();
|
|
379
|
+
var styledAt = /* @__PURE__ */ new WeakMap();
|
|
380
|
+
var ownLayer = (node) => node instanceof Element && OWN_LAYERS.has(node.id);
|
|
381
|
+
function bump(at) {
|
|
382
|
+
activityState.n++;
|
|
383
|
+
activityState.last = at;
|
|
384
|
+
}
|
|
385
|
+
function watchDocument(doc, counted) {
|
|
386
|
+
if (watchedDocuments.has(doc)) return;
|
|
387
|
+
watchedDocuments.add(doc);
|
|
388
|
+
if (counted) bump(performance.now());
|
|
389
|
+
new MutationObserver((records) => {
|
|
390
|
+
const now = performance.now();
|
|
391
|
+
let real = false;
|
|
392
|
+
for (const r of records) {
|
|
393
|
+
if (ownLayer(r.target) || [...r.addedNodes, ...r.removedNodes].some(ownLayer)) continue;
|
|
394
|
+
if (r.type === "attributes") {
|
|
395
|
+
const target2 = r.target;
|
|
396
|
+
if (r.oldValue === target2.getAttributeNS(r.attributeNamespace, r.attributeName)) continue;
|
|
397
|
+
if (r.attributeName === "style") {
|
|
398
|
+
const previous = styledAt.get(target2);
|
|
399
|
+
styledAt.set(target2, now);
|
|
400
|
+
if (previous === void 0 ? now - activityState.installed < STYLE_REPEAT_MS : now - previous <= STYLE_REPEAT_MS) continue;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
real = true;
|
|
404
|
+
}
|
|
405
|
+
if (real) bump(now);
|
|
406
|
+
}).observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, characterData: true });
|
|
407
|
+
for (const type of doc instanceof Document ? ["input", "change", "scroll"] : ["scroll"]) doc.addEventListener(type, () => bump(performance.now()), true);
|
|
408
|
+
}
|
|
409
|
+
function watchShadowRoots(root, counted) {
|
|
410
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT);
|
|
411
|
+
for (let n = walker.nextNode(); n; n = walker.nextNode()) {
|
|
412
|
+
const shadow = n.shadowRoot;
|
|
413
|
+
if (!shadow) continue;
|
|
414
|
+
watchDocument(shadow, counted);
|
|
415
|
+
watchShadowRoots(shadow, counted);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
function watchFrames(doc, counted) {
|
|
419
|
+
for (const frame of doc.querySelectorAll("iframe,frame")) {
|
|
420
|
+
let child = null;
|
|
421
|
+
try {
|
|
422
|
+
child = frame.contentDocument;
|
|
423
|
+
} catch {
|
|
424
|
+
child = null;
|
|
425
|
+
}
|
|
426
|
+
if (!child) continue;
|
|
427
|
+
watchDocument(child, counted);
|
|
428
|
+
watchFrames(child, counted);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
watchDocument(document, false);
|
|
432
|
+
watchFrames(document, false);
|
|
433
|
+
function contentProbe() {
|
|
434
|
+
const text2 = (document.body?.innerText ?? "").replace(/\s+/g, " ").trim();
|
|
435
|
+
return { href: location.href, ready: document.readyState, chars: text2.length, head: text2.slice(0, 200) };
|
|
436
|
+
}
|
|
437
|
+
var documentId = () => String(performance.timeOrigin);
|
|
438
|
+
function activity(args = {}) {
|
|
439
|
+
watchFrames(document, true);
|
|
440
|
+
if (args.scan) watchShadowRoots(document, false);
|
|
441
|
+
const now = performance.now();
|
|
442
|
+
return { n: activityState.n, idleMs: Math.round(now - activityState.last), ready: document.readyState, url: location.href, doc: documentId() };
|
|
330
443
|
}
|
|
331
444
|
var probedFrame = null;
|
|
332
445
|
function frameElement() {
|
|
@@ -384,7 +497,7 @@
|
|
|
384
497
|
if (matches.length > 1) {
|
|
385
498
|
const visible = matches.filter((m) => is(m, "visible"));
|
|
386
499
|
if (visible.length === 1) el = visible[0];
|
|
387
|
-
else return { error:
|
|
500
|
+
else return { error: ambiguity(matches.length, args.selector, visible.length, visible.length > 1 ? visible : matches), retry: false };
|
|
388
501
|
}
|
|
389
502
|
const enabled = stateOf(el, "enabled");
|
|
390
503
|
if (!enabled.matches) return { error: { code: "not_enabled", message: `element is not enabled${enabled.received.startsWith("error:") ? ` (${enabled.received.slice(6)})` : ""}`, candidates: [candidate(el)] }, retry: true };
|
|
@@ -441,7 +554,15 @@
|
|
|
441
554
|
}
|
|
442
555
|
return best;
|
|
443
556
|
}
|
|
557
|
+
function inClosedDetails(node) {
|
|
558
|
+
let child = node;
|
|
559
|
+
for (let parent = node.parentNode; parent; child = parent, parent = parent.parentNode ?? parent.host ?? null) {
|
|
560
|
+
if (parent instanceof HTMLDetailsElement && !parent.open && child.nodeName !== "SUMMARY") return true;
|
|
561
|
+
}
|
|
562
|
+
return false;
|
|
563
|
+
}
|
|
444
564
|
function skipRead(el, visible) {
|
|
565
|
+
if (el && inClosedDetails(el)) return true;
|
|
445
566
|
while (el) {
|
|
446
567
|
const tag = el.tagName;
|
|
447
568
|
if (tag === "SCRIPT" || tag === "STYLE" || tag === "NOSCRIPT") return true;
|
|
@@ -451,7 +572,7 @@
|
|
|
451
572
|
if (cached === false) return true;
|
|
452
573
|
if (cached === void 0) {
|
|
453
574
|
const style = getComputedStyle(el);
|
|
454
|
-
const shown = style.display !== "none" && style.visibility !== "hidden" && style.visibility !== "collapse";
|
|
575
|
+
const shown = style.display !== "none" && style.visibility !== "hidden" && style.visibility !== "collapse" && style.opacity !== "0";
|
|
455
576
|
visible.set(el, shown);
|
|
456
577
|
if (!shown) return true;
|
|
457
578
|
}
|
|
@@ -459,12 +580,41 @@
|
|
|
459
580
|
}
|
|
460
581
|
return false;
|
|
461
582
|
}
|
|
583
|
+
function shownText(root) {
|
|
584
|
+
if (skipRead(root, /* @__PURE__ */ new WeakMap())) return "";
|
|
585
|
+
const parts = [];
|
|
586
|
+
const visit = (node, textShown) => {
|
|
587
|
+
for (const n of node.childNodes) {
|
|
588
|
+
if (node instanceof HTMLDetailsElement && !node.open && n.nodeName !== "SUMMARY") continue;
|
|
589
|
+
if (n.nodeType === Node.TEXT_NODE) {
|
|
590
|
+
if (textShown) parts.push(n.textContent ?? "");
|
|
591
|
+
continue;
|
|
592
|
+
}
|
|
593
|
+
if (!(n instanceof Element) || /^(SCRIPT|STYLE|NOSCRIPT|TEMPLATE)$/.test(n.tagName) || n.id === "browsermcp-annotate" || n.hasAttribute("hidden")) continue;
|
|
594
|
+
const style = getComputedStyle(n);
|
|
595
|
+
if (style.display === "none" || style.opacity === "0") continue;
|
|
596
|
+
const shown = style.visibility !== "hidden" && style.visibility !== "collapse";
|
|
597
|
+
const block = n.tagName === "BR" || style.display !== "inline" && style.display !== "contents";
|
|
598
|
+
if (block) parts.push(" ");
|
|
599
|
+
visit(n, shown);
|
|
600
|
+
if (n.shadowRoot) visit(n.shadowRoot, shown);
|
|
601
|
+
if (block) parts.push(" ");
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
visit(root, true);
|
|
605
|
+
if (root.shadowRoot) visit(root.shadowRoot, true);
|
|
606
|
+
return parts.join("").replace(/\s+/g, " ").trim();
|
|
607
|
+
}
|
|
608
|
+
function shownElement(el) {
|
|
609
|
+
return is(el, "visible") && !skipRead(el, /* @__PURE__ */ new WeakMap());
|
|
610
|
+
}
|
|
462
611
|
function pageLines() {
|
|
463
612
|
const out = [];
|
|
464
613
|
if (!document.body) return out;
|
|
465
614
|
const visible = /* @__PURE__ */ new WeakMap();
|
|
466
615
|
const visit = (root) => {
|
|
467
616
|
for (const n of root.childNodes) {
|
|
617
|
+
if (root instanceof HTMLDetailsElement && !root.open && n.nodeName !== "SUMMARY") continue;
|
|
468
618
|
if (n.nodeType === Node.TEXT_NODE) {
|
|
469
619
|
const parent = n.parentElement ?? n.getRootNode().host;
|
|
470
620
|
if (!skipRead(parent, visible)) {
|
|
@@ -575,11 +725,50 @@
|
|
|
575
725
|
if (!matches.length) throw pageError("not_found", `No element matches ${args.selector}`, "Observe the page or find the container again.");
|
|
576
726
|
if (matches.length > 1) {
|
|
577
727
|
const visible = matches.filter((el) => is(el, "visible"));
|
|
578
|
-
if (visible.length !== 1)
|
|
728
|
+
if (visible.length !== 1) {
|
|
729
|
+
const a = ambiguity(matches.length, args.selector, visible.length, visible.length > 1 ? visible : matches);
|
|
730
|
+
throw pageError(a.code, a.message, a.hint, { candidates: a.candidates });
|
|
731
|
+
}
|
|
579
732
|
matches = visible;
|
|
580
733
|
}
|
|
581
734
|
return matches[0];
|
|
582
735
|
}
|
|
736
|
+
var SLOT_TAGS = /* @__PURE__ */ new Set(["P", "SPAN", "DIV", "DD", "TD", "EM", "STRONG", "B", "SMALL", "LABEL", "TIME", "DATA", "OUTPUT"]);
|
|
737
|
+
function isEmptySlot(el) {
|
|
738
|
+
if (!SLOT_TAGS.has(el.tagName) || el.children.length || (el.textContent ?? "").trim()) return false;
|
|
739
|
+
const box2 = el.getBoundingClientRect();
|
|
740
|
+
return !(box2.width > 0 && box2.height > 0);
|
|
741
|
+
}
|
|
742
|
+
function namingTokens(el) {
|
|
743
|
+
const tokens = [...el.classList].filter((t) => t.length <= 32 && /^[a-z][a-z0-9]*(?:[-_]{1,2}[a-z0-9]+)*$/i.test(t) && !/\d{3}|^(?:css|sc|jsx|svelte|emotion)-/i.test(t));
|
|
744
|
+
return el.id && !/\d{3}/.test(el.id) ? [`#${el.id}`, ...tokens] : tokens;
|
|
745
|
+
}
|
|
746
|
+
var SELECTED_TOKEN = /^(?:.*[-_])?(?:cur|current|active|actived|selected|checked|on)$/i;
|
|
747
|
+
function stateHints(el, empty) {
|
|
748
|
+
let out = "";
|
|
749
|
+
if (empty) {
|
|
750
|
+
const names = namingTokens(el);
|
|
751
|
+
out += names.length ? ` [empty ${names[0].startsWith("#") ? `id="${names[0].slice(1)}"` : `class="${names.slice(0, 2).join(" ")}"`}]` : " [empty]";
|
|
752
|
+
}
|
|
753
|
+
const details = el.tagName === "SUMMARY" && el.parentElement instanceof HTMLDetailsElement ? el.parentElement : null;
|
|
754
|
+
if (details && !el.hasAttribute("aria-expanded")) out += details.open ? " [expanded]" : " [collapsed]";
|
|
755
|
+
const current = el.getAttribute("aria-current");
|
|
756
|
+
if (current && current !== "false") out += current === "true" ? " [current]" : ` [current=${current}]`;
|
|
757
|
+
else if (!["aria-selected", "aria-pressed", "aria-checked"].some((a) => el.hasAttribute(a)) && !(el instanceof HTMLInputElement)) {
|
|
758
|
+
const token = selectionToken(el);
|
|
759
|
+
if (token) out += ` [selected? class="${token}"]`;
|
|
760
|
+
}
|
|
761
|
+
return out;
|
|
762
|
+
}
|
|
763
|
+
function selectionToken(el) {
|
|
764
|
+
const parent = el.parentElement;
|
|
765
|
+
if (!parent) return null;
|
|
766
|
+
const siblings = [...parent.children].filter((s) => s.tagName === el.tagName);
|
|
767
|
+
if (siblings.length < 2 || siblings.length > 50) return null;
|
|
768
|
+
const marked = siblings.filter((s) => [...s.classList].some((t) => SELECTED_TOKEN.test(t)));
|
|
769
|
+
if (marked.length !== 1 || marked[0] !== el) return null;
|
|
770
|
+
return [...el.classList].find((t) => SELECTED_TOKEN.test(t));
|
|
771
|
+
}
|
|
583
772
|
function aria(args = {}) {
|
|
584
773
|
const root = observationRoot(args);
|
|
585
774
|
const i = injected();
|
|
@@ -616,8 +805,11 @@
|
|
|
616
805
|
continue;
|
|
617
806
|
}
|
|
618
807
|
const el = elements.get(m[2]);
|
|
619
|
-
|
|
620
|
-
|
|
808
|
+
const empty = !m[4] && !m[1].includes(' "') && isEmptySlot(el);
|
|
809
|
+
const hints = stateHints(el, empty);
|
|
810
|
+
const closing = hints && m[3].endsWith("'") ? m[3].slice(0, -1) + hints + "'" : m[3] + hints;
|
|
811
|
+
let rline = m[1] + stableRefOf(el) + closing + (m[4] ?? "");
|
|
812
|
+
if (args.viewport && !args.ref && !intersectsViewport(empty && el.parentElement ? el.parentElement : el)) {
|
|
621
813
|
dropBelow = indent;
|
|
622
814
|
continue;
|
|
623
815
|
}
|
|
@@ -698,7 +890,7 @@ Focused: [ref=${focusRef}]` : "");
|
|
|
698
890
|
if (!matches.length) return { error: { code: "not_found", message: `no element matches ${args.selector}`, hint: "Observe or find the target again." } };
|
|
699
891
|
if (matches.length > 1) {
|
|
700
892
|
const visible = matches.filter((el2) => is(el2, "visible"));
|
|
701
|
-
if (visible.length !== 1) return { error:
|
|
893
|
+
if (visible.length !== 1) return { error: ambiguity(matches.length, args.selector, visible.length, visible.length > 1 ? visible : matches) };
|
|
702
894
|
matches = visible;
|
|
703
895
|
}
|
|
704
896
|
const el = matches[0];
|
|
@@ -778,6 +970,7 @@ Focused: [ref=${focusRef}]` : "");
|
|
|
778
970
|
function unannotate() {
|
|
779
971
|
document.getElementById(ANNOTATE_ID)?.remove();
|
|
780
972
|
}
|
|
973
|
+
var fold = (value) => value.replace(/\s+/g, " ").trim().toLowerCase();
|
|
781
974
|
function check(args) {
|
|
782
975
|
const failed = [];
|
|
783
976
|
const actual = {};
|
|
@@ -787,11 +980,14 @@ Focused: [ref=${focusRef}]` : "");
|
|
|
787
980
|
if (!matches.length && args.fallback) matches = query(args.fallback);
|
|
788
981
|
if (matches.length > 1) {
|
|
789
982
|
const visible = matches.filter((el) => is(el, "visible"));
|
|
790
|
-
if (visible.length !== 1)
|
|
983
|
+
if (visible.length !== 1) {
|
|
984
|
+
const a = ambiguity(matches.length, args.selector, visible.length, visible.length > 1 ? visible : matches);
|
|
985
|
+
throw Object.assign(new Error(a.message), { code: a.code, hint: a.hint, data: { candidates: a.candidates } });
|
|
986
|
+
}
|
|
791
987
|
matches = visible;
|
|
792
988
|
}
|
|
793
989
|
element = matches[0];
|
|
794
|
-
actual.visible = !!element &&
|
|
990
|
+
actual.visible = !!element && shownElement(element) && (args.targetText === void 0 || fold(shownText(element)).includes(fold(args.targetText)));
|
|
795
991
|
const visibilityOnly = ["text", "notText", "value", "checked", "selected", "enabled"].every((key) => args[key] === void 0);
|
|
796
992
|
if (args.visible !== void 0 || visibilityOnly) {
|
|
797
993
|
if (actual.visible !== (args.visible ?? true)) failed.push(`visible is ${actual.visible}, expected ${args.visible ?? true}`);
|
|
@@ -800,7 +996,7 @@ Focused: [ref=${focusRef}]` : "");
|
|
|
800
996
|
}
|
|
801
997
|
if (args.selector === void 0 || element) {
|
|
802
998
|
const root = element ?? document.body;
|
|
803
|
-
const content = element && isCredentialField(element) ? "<redacted>" :
|
|
999
|
+
const content = element && isCredentialField(element) ? "<redacted>" : root ? shownText(root) : "";
|
|
804
1000
|
if (args.text !== void 0 || args.notText !== void 0) {
|
|
805
1001
|
actual.text = content.slice(0, 1e3);
|
|
806
1002
|
if (args.text !== void 0 && !content.includes(args.text)) failed.push(`text does not include "${args.text}"`);
|
|
@@ -829,6 +1025,6 @@ Focused: [ref=${focusRef}]` : "");
|
|
|
829
1025
|
if (args.title !== void 0 && !document.title.includes(args.title)) failed.push(`title "${document.title}" does not include "${args.title}"`);
|
|
830
1026
|
return { ok: failed.length === 0, failed, url: location.href, title: document.title, actual };
|
|
831
1027
|
}
|
|
832
|
-
var api = { check, resolve, resolveUpload, fileSelectionCount, pointInfo, focus, readValue, fill, isChecked, select, caretToEnd, actionTarget, clearActionTarget,
|
|
1028
|
+
var api = { check, resolve, resolveUpload, fileSelectionCount, pointInfo, focus, readValue, fill, isChecked, select, caretToEnd, actionTarget, clearActionTarget, activity, contentProbe, closedShadowCandidates, adoptShadowRoot, frameProbe, frameElement, clearFrameProbe, aria, observeFrame, visibleDom, readElement, find, findByQuery, elementAt, annotate, unannotate, armClickProbe, readClickProbe, domClick, readText };
|
|
833
1029
|
globalThis[PAGE_GLOBAL] = api;
|
|
834
1030
|
})();
|
package/dist/src/protocol.d.ts
CHANGED
|
@@ -88,6 +88,7 @@ export interface Command {
|
|
|
88
88
|
/** act */
|
|
89
89
|
act?: ActSpec;
|
|
90
90
|
}
|
|
91
|
+
export type ActionEffect = 'navigated' | 'changed' | 'none' | 'unknown';
|
|
91
92
|
export type ActKind = 'click' | 'dblclick' | 'hover' | 'focus' | 'fill' | 'type' | 'press' | 'check' | 'uncheck' | 'select' | 'scroll' | 'upload' | 'drag';
|
|
92
93
|
export interface ActTarget {
|
|
93
94
|
ref?: number | string; /** raw Playwright selector, e.g. the `selector` returned by find */
|
|
@@ -109,6 +110,8 @@ export interface ActSpec {
|
|
|
109
110
|
target: ActTarget;
|
|
110
111
|
value?: string;
|
|
111
112
|
timeoutMs?: number;
|
|
113
|
+
/** The caller chose timeoutMs (transports fill in a default): a missing target is then waited for the whole time. */
|
|
114
|
+
explicitTimeout?: boolean;
|
|
112
115
|
settleMs?: number;
|
|
113
116
|
cursor?: boolean;
|
|
114
117
|
force?: boolean;
|
|
@@ -166,6 +169,12 @@ export interface ActResult {
|
|
|
166
169
|
};
|
|
167
170
|
/** Playwright-generated selector for locating the same element again. */
|
|
168
171
|
selector?: string;
|
|
172
|
+
/** What the page did in response: a new document or URL, a DOM/form/scroll change, no change, or unknown (the page could not be read afterwards). */
|
|
173
|
+
effect?: ActionEffect;
|
|
174
|
+
/** Present when the page was still changing or loading when the settle wait ended. */
|
|
175
|
+
settled?: false;
|
|
176
|
+
/** Requests the action started that were still in flight when the settle wait ended. */
|
|
177
|
+
pendingRequests?: number;
|
|
169
178
|
/** set when the action triggered a navigation that has now finished */
|
|
170
179
|
navigated?: boolean;
|
|
171
180
|
url?: string;
|
package/dist/src/protocol.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAyMH,iGAAiG;AACjG,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAOnC,MAAM,CAAC,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AACtD,oDAAoD;AACpD,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,CAAC"}
|
|
@@ -31,8 +31,8 @@ export declare const userTabInfo: z.ZodObject<{
|
|
|
31
31
|
lastAccessed: z.ZodOptional<z.ZodNumber>;
|
|
32
32
|
lifecycle: z.ZodOptional<z.ZodEnum<{
|
|
33
33
|
ready: "ready";
|
|
34
|
-
dormant: "dormant";
|
|
35
34
|
loading: "loading";
|
|
35
|
+
dormant: "dormant";
|
|
36
36
|
}>>;
|
|
37
37
|
availability: z.ZodOptional<z.ZodEnum<{
|
|
38
38
|
ready: "ready";
|
|
@@ -66,8 +66,8 @@ export declare const discoveryResult: z.ZodObject<{
|
|
|
66
66
|
lastAccessed: z.ZodOptional<z.ZodNumber>;
|
|
67
67
|
lifecycle: z.ZodOptional<z.ZodEnum<{
|
|
68
68
|
ready: "ready";
|
|
69
|
-
dormant: "dormant";
|
|
70
69
|
loading: "loading";
|
|
70
|
+
dormant: "dormant";
|
|
71
71
|
}>>;
|
|
72
72
|
availability: z.ZodOptional<z.ZodEnum<{
|
|
73
73
|
ready: "ready";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const SEPARATOR_TEXT = /^- text: (?:"[\s|·•,;:()[\]\/\\\-–—]*"|[\s|·•,;:()[\]\/\\\-–—]+)$/;
|
|
1
2
|
/** Compact a serialized ARIA tree without discarding unique names or control state. */
|
|
2
3
|
export function compactAria(text) {
|
|
3
4
|
const root = { line: '', indent: -1, children: [] };
|
|
@@ -12,7 +13,12 @@ export function compactAria(text) {
|
|
|
12
13
|
}
|
|
13
14
|
const normalize = (s) => s.replace(/\s+/g, ' ').trim();
|
|
14
15
|
function render(node, depth) {
|
|
15
|
-
|
|
16
|
+
// Inert wrappers print no line; their children move up a level. Unnamed cells and row groups are layout (HN's
|
|
17
|
+
// nested tables spent a third of the snapshot on them); a row stays, it groups a record.
|
|
18
|
+
const unnamed = /^- (generic|group|rowgroup|cell)(?: \[ref=[^\]]+\])?:?$/.test(node.line);
|
|
19
|
+
// An empty row and a separator-only text ("|", "·", "(") carry nothing.
|
|
20
|
+
if (!node.children.length && (/^- row(?: \[ref=[^\]]+\])?$/.test(node.line) || SEPARATOR_TEXT.test(node.line)))
|
|
21
|
+
return { lines: [], text: '' };
|
|
16
22
|
const children = node.children.map(child => render(child, depth + (unnamed ? 0 : 1)));
|
|
17
23
|
const childText = normalize(children.map(child => child.text).join(' '));
|
|
18
24
|
let line = node.line;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aria-tree.js","sourceRoot":"","sources":["../../../src/shared/aria-tree.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,UAAU,WAAW,CAAC,IAAY;IAEtC,MAAM,IAAI,GAAS,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC1D,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC;IACrB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,2DAA2D,EAAE,CAAC,IAAI,EAAE,GAAW,EAAE,KAAa,EAAE,IAAY,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QAC9M,MAAM,IAAI,GAAS,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;Q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ACzE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ShadowIO {
|
|
2
|
+
/** Evaluate in the frame's engine world and return a remote object id (undefined for null/undefined results). */
|
|
3
|
+
evaluateHandle(expression: string): Promise<string | undefined>;
|
|
4
|
+
/** A CDP command on the session that owns the frame. */
|
|
5
|
+
cdp(method: string, params: Record<string, unknown>): Promise<any>;
|
|
6
|
+
/** The engine world's execution context id on that session. */
|
|
7
|
+
engineContextId(): Promise<number>;
|
|
8
|
+
}
|
|
9
|
+
/** Adopt the closed shadow roots of new candidate hosts. Returns how many were adopted; never throws. */
|
|
10
|
+
export declare function adoptClosedShadowRoots(io: ShadowIO): Promise<number>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hand closed shadow roots to the engine world (see closedShadowCandidates/adoptShadowRoot in the page module).
|
|
3
|
+
* Shared by every backend that owns a CDP session for the frame: the extension and the embedded Electron driver.
|
|
4
|
+
*/
|
|
5
|
+
import { PAGE_GLOBAL } from './page-contract.js';
|
|
6
|
+
/** Nested closed roots appear only after their parent root is adopted. */
|
|
7
|
+
const MAX_ROUNDS = 4;
|
|
8
|
+
/** Adopt the closed shadow roots of new candidate hosts. Returns how many were adopted; never throws. */
|
|
9
|
+
export async function adoptClosedShadowRoots(io) {
|
|
10
|
+
let adopted = 0;
|
|
11
|
+
try {
|
|
12
|
+
for (let round = 0; round < MAX_ROUNDS; round++) {
|
|
13
|
+
const list = await io.evaluateHandle(`(() => { const c = globalThis.${PAGE_GLOBAL}.closedShadowCandidates?.(); return c && c.length ? c : null; })()`);
|
|
14
|
+
if (!list)
|
|
15
|
+
break;
|
|
16
|
+
let found = 0;
|
|
17
|
+
const handles = [list];
|
|
18
|
+
try {
|
|
19
|
+
const { result } = await io.cdp('Runtime.getProperties', { objectId: list, ownProperties: true });
|
|
20
|
+
const hosts = result.filter(p => /^\d+$/.test(p.name) && p.value?.objectId).map(p => p.value.objectId);
|
|
21
|
+
handles.push(...hosts);
|
|
22
|
+
let context;
|
|
23
|
+
for (const host of hosts) {
|
|
24
|
+
const { node } = await io.cdp('DOM.describeNode', { objectId: host, depth: 0, pierce: true });
|
|
25
|
+
for (const root of node.shadowRoots ?? []) {
|
|
26
|
+
if (root.shadowRootType !== 'closed')
|
|
27
|
+
continue;
|
|
28
|
+
context ??= await io.engineContextId();
|
|
29
|
+
const { object } = await io.cdp('DOM.resolveNode', { backendNodeId: root.backendNodeId, executionContextId: context });
|
|
30
|
+
if (!object.objectId)
|
|
31
|
+
continue;
|
|
32
|
+
handles.push(object.objectId);
|
|
33
|
+
const r = await io.cdp('Runtime.callFunctionOn', { objectId: object.objectId, functionDeclaration: `function () { return globalThis.${PAGE_GLOBAL}.adoptShadowRoot(this); }`, returnByValue: true });
|
|
34
|
+
if (r.result?.value === true)
|
|
35
|
+
found++;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
await Promise.all(handles.map(objectId => io.cdp('Runtime.releaseObject', { objectId }).catch(() => { })));
|
|
41
|
+
}
|
|
42
|
+
adopted += found;
|
|
43
|
+
if (!found)
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch { /* best effort: a page without access or a navigating frame keeps working without closed roots */ }
|
|
48
|
+
return adopted;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=closed-shadow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closed-shadow.js","sourceRoot":"","sources":["../../../src/shared/closed-shadow.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAWjD,0EAA0E;AAC1E,MAAM,UAAU,GAAG,CAAC,CAAC;AAErB,yGAAyG;AACzG,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,EAAY;IACvD,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,CAAC;QAC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,EAAE,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,iBAAiB,EAAE,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAsC,CAAC;wBAC5J,IAAI,CAAC,MAAM,CAAC,QAAQ;4BAAE,SAAS;wBAC/B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;wBAC9B,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,wBAAwB,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,mBAAmB,EAAE,mCAAmC,WAAW,2BAA2B,EAAE,aAAa,EAAE,IAAI,EAAE,CAAqC,CAAC;wBACzO,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,KAAK,IAAI;4BAAE,KAAK,EAAE,CAAC;oBACxC,CAAC;gBACH,CAAC;YACH,CAAC;oBAAS,CAAC;gBACT,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,uBAAuB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5G,CAAC;YACD,OAAO,IAAI,KAAK,CAAC;YACjB,IAAI,CAAC,KAAK;gBAAE,MAAM;QACpB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC,CAAC,iGAAiG,CAAC,CAAC;IAC7G,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -46,5 +46,17 @@ export interface ActIO {
|
|
|
46
46
|
x: number;
|
|
47
47
|
y: number;
|
|
48
48
|
};
|
|
49
|
+
/** When the world is a child frame: call the same page-module function in the top document. */
|
|
50
|
+
callTop?(fn: string, args?: unknown, timeoutMs?: number): Promise<unknown>;
|
|
51
|
+
/** Requests started at or after `since` (Date.now() ms) still in flight, and ms since their last event. */
|
|
52
|
+
network?(since: number): Promise<{
|
|
53
|
+
pending: number;
|
|
54
|
+
idleMs: number;
|
|
55
|
+
}> | {
|
|
56
|
+
pending: number;
|
|
57
|
+
idleMs: number;
|
|
58
|
+
};
|
|
49
59
|
}
|
|
60
|
+
/** Upper bound of the post-action wait. A quiet page ends it after QUIET_MS; only a busy page waits this long. */
|
|
61
|
+
export declare const DEFAULT_SETTLE_MS = 1000;
|
|
50
62
|
export declare function performAct(io: ActIO, spec: ActSpec): Promise<ActResult>;
|