@opentiny/next-sdk 0.4.1 → 0.4.2
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/{SimulatorMask-BHVXyogh-iNUb4dyF.js → SimulatorMask-BHVXyogh-CARX3Rff.js} +1 -1
- package/dist/core.js +1 -1
- package/dist/{index-CXK8CcKq.js → index-R_HIbfUX.js} +1698 -1170
- package/dist/index.d.ts +11 -0
- package/dist/index.js +69 -50
- package/dist/{initialize-builtin-WebMCP-rALfqS-o.js → initialize-builtin-WebMCP-JaoKwVlm.js} +355 -346
- package/dist/page-tools/a11y/build.d.ts +3 -4
- package/dist/page-tools/a11y/config.d.ts +96 -0
- package/dist/page-tools/a11y/constants.d.ts +2 -0
- package/dist/page-tools/a11y/search.d.ts +1 -1
- package/dist/page-tools/a11y/types.d.ts +13 -22
- package/dist/page-tools/a11y/utils.d.ts +32 -11
- package/dist/page-tools/a11y/vnode.d.ts +14 -11
- package/dist/page-tools/a11y-tree.d.ts +1 -0
- package/dist/page-tools/configs/console-cloud.d.ts +6 -0
- package/dist/page-tools/constants.d.ts +5 -17
- package/dist/page-tools/context.d.ts +12 -0
- package/dist/page-tools/handlers/searchTree.d.ts +2 -1
- package/dist/page-tools/page-agent-highlight/index.d.ts +12 -0
- package/dist/page-tools/page-agent-mask/SimulatorMask.d.ts +2 -0
- package/dist/page-tools/page-agent-tool-event.d.ts +26 -0
- package/dist/page-tools/schema.d.ts +1 -0
- package/dist/page-tools/tool-config.d.ts +50 -0
- package/dist/runtime.d.ts +4 -1
- package/dist/runtime.js +37 -49
- package/dist/vitest.config.d.ts +2 -0
- package/index.ts +35 -0
- package/package.json +21 -16
- package/page-tools/a11y/build.ts +38 -34
- package/page-tools/a11y/config.ts +465 -0
- package/page-tools/a11y/constants.ts +21 -0
- package/page-tools/a11y/search.ts +1 -3
- package/page-tools/a11y/types.ts +14 -17
- package/page-tools/a11y/utils.ts +129 -156
- package/page-tools/a11y/vnode.ts +277 -67
- package/page-tools/a11y-tree.ts +1 -0
- package/page-tools/bridge.ts +22 -2
- package/page-tools/configs/console-cloud.ts +172 -0
- package/page-tools/constants.ts +5 -65
- package/page-tools/context.ts +38 -1
- package/page-tools/handlers/click.ts +6 -2
- package/page-tools/handlers/fill.ts +10 -5
- package/page-tools/handlers/searchTree.ts +7 -10
- package/page-tools/handlers/select.ts +10 -5
- package/page-tools/page-agent-highlight/index.ts +66 -19
- package/page-tools/page-agent-mask/SimulatorMask.ts +42 -22
- package/page-tools/page-agent-mask/hauwei.svg +25 -0
- package/page-tools/page-agent-prompt.md +1 -1
- package/page-tools/page-agent-tool-event.ts +113 -0
- package/page-tools/page-agent-tool.ts +85 -53
- package/page-tools/schema.ts +1 -0
- package/page-tools/tool-config.ts +100 -0
- package/page-tools/utils/dom.ts +6 -3
- package/runtime.ts +37 -6
- package/test/page-tools/a11y/build.test.ts +638 -0
- package/test/page-tools/a11y/config.test.ts +370 -0
- package/test/page-tools/configs/console-cloud.test.ts +168 -0
- package/test/page-tools/page-agent-highlight.test.ts +110 -0
- package/test/page-tools/page-agent-tool-dispatch.test.ts +208 -0
- package/test/page-tools/page-agent-tool.test.ts +102 -0
- package/test/page-tools/tool-config.test.ts +112 -0
- package/test/page-tools/utils/dom.test.ts +122 -0
- package/vite.config.runtime.ts +1 -1
- package/vitest.config.ts +10 -0
|
@@ -6,7 +6,7 @@ import "@modelcontextprotocol/sdk/shared/uriTemplate.js";
|
|
|
6
6
|
import "@modelcontextprotocol/sdk/server/completable.js";
|
|
7
7
|
import "@modelcontextprotocol/sdk/shared/metadataUtils.js";
|
|
8
8
|
import "@modelcontextprotocol/sdk/inMemory.js";
|
|
9
|
-
import { i as initializeBuiltinWebMCP } from "./initialize-builtin-WebMCP-
|
|
9
|
+
import { i as initializeBuiltinWebMCP } from "./initialize-builtin-WebMCP-JaoKwVlm.js";
|
|
10
10
|
import QRCodePck from "qrcode";
|
|
11
11
|
import { tool } from "ai";
|
|
12
12
|
import { ZodFirstPartyTypeKind } from "zod/v3";
|
|
@@ -97,9 +97,9 @@ class Tooltip {
|
|
|
97
97
|
this.applyStyle(this.calcStyle("top"));
|
|
98
98
|
}
|
|
99
99
|
calcStyle(e) {
|
|
100
|
-
const n = this.el.getBoundingClientRect(), i = this.tip.getBoundingClientRect(), r = window.pageYOffset || document.documentElement.scrollTop, o = window.pageXOffset || document.documentElement.scrollLeft, a = 6, [
|
|
101
|
-
let
|
|
102
|
-
return
|
|
100
|
+
const n = this.el.getBoundingClientRect(), i = this.tip.getBoundingClientRect(), r = window.pageYOffset || document.documentElement.scrollTop, o = window.pageXOffset || document.documentElement.scrollLeft, a = 6, [s, c = "center"] = e.split("-");
|
|
101
|
+
let d = 0, u = 0;
|
|
102
|
+
return s === "top" ? d = n.top + r - i.height - a : s === "bottom" ? d = n.bottom + r + a : s === "left" ? u = n.left + o - i.width - a : s === "right" && (u = n.right + o + a), (s === "top" || s === "bottom") && (c === "start" ? u = n.left + o : c === "end" ? u = n.right + o - i.width : u = (n.left + n.right) / 2 + o - i.width / 2), (s === "left" || s === "right") && (c === "start" ? d = n.top + r : c === "end" ? d = n.bottom + r - i.height : d = (n.top + n.bottom) / 2 + r - i.height / 2), { top: Math.round(d), left: Math.round(u) };
|
|
103
103
|
}
|
|
104
104
|
applyStyle({ top: e, left: n }) {
|
|
105
105
|
Object.assign(this.tip.style, {
|
|
@@ -880,14 +880,14 @@ async function parseSkillFrontMatter(t) {
|
|
|
880
880
|
if (typeof t != "string" && typeof t != "function") return null;
|
|
881
881
|
const n = (typeof t == "string" ? t : await t()).match(FRONT_MATTER_BLOCK_REG);
|
|
882
882
|
if (!n?.[1]) return null;
|
|
883
|
-
const i = n[1], r = i.match(/^name:\s*(.+)$/m), o = i.match(/^description:\s*(.+)$/m), a = r?.[1]?.trim(),
|
|
884
|
-
return a &&
|
|
883
|
+
const i = n[1], r = i.match(/^name:\s*(.+)$/m), o = i.match(/^description:\s*(.+)$/m), a = r?.[1]?.trim(), s = o?.[1]?.trim();
|
|
884
|
+
return a && s ? { name: a, description: s } : null;
|
|
885
885
|
}
|
|
886
886
|
async function normalizeSkillModuleKeys(t) {
|
|
887
887
|
const e = {};
|
|
888
888
|
for (const [n, i] of Object.entries(t)) {
|
|
889
|
-
const r = n.replace(/\\/g, "/"), o = r.lastIndexOf("skills/"), a = o >= 0 ? r.slice(o + 7) : r,
|
|
890
|
-
e[
|
|
889
|
+
const r = n.replace(/\\/g, "/"), o = r.lastIndexOf("skills/"), a = o >= 0 ? r.slice(o + 7) : r, s = a.startsWith("./") ? a : `./${a}`, c = typeof i == "string" ? i : await i();
|
|
890
|
+
e[s] = c;
|
|
891
891
|
}
|
|
892
892
|
return e;
|
|
893
893
|
}
|
|
@@ -929,8 +929,8 @@ async function getMainSkillPathByName(t, e) {
|
|
|
929
929
|
for (const o of i) {
|
|
930
930
|
const a = n[o];
|
|
931
931
|
if (a) {
|
|
932
|
-
const
|
|
933
|
-
if (
|
|
932
|
+
const s = await parseSkillFrontMatter(a);
|
|
933
|
+
if (s && s.name === e)
|
|
934
934
|
return o;
|
|
935
935
|
}
|
|
936
936
|
}
|
|
@@ -952,37 +952,37 @@ function createSkillTools(t) {
|
|
|
952
952
|
inputSchema: SKILL_INPUT_SCHEMA,
|
|
953
953
|
execute: async (r) => {
|
|
954
954
|
e || (n = await normalizeSkillModuleKeys(t), e = !0);
|
|
955
|
-
const o = n, { skillName: a, path:
|
|
956
|
-
let
|
|
957
|
-
if (
|
|
955
|
+
const o = n, { skillName: a, path: s, currentPath: c } = r;
|
|
956
|
+
let d, u = "";
|
|
957
|
+
if (s) {
|
|
958
958
|
let p = ".";
|
|
959
959
|
if (c) {
|
|
960
|
-
const
|
|
961
|
-
|
|
960
|
+
const y = c.lastIndexOf("/");
|
|
961
|
+
y >= 0 && (p = c.slice(0, y));
|
|
962
962
|
}
|
|
963
|
-
const
|
|
964
|
-
if (
|
|
965
|
-
const
|
|
966
|
-
if (
|
|
967
|
-
const
|
|
968
|
-
|
|
963
|
+
const h = `http://localhost/${p}/`;
|
|
964
|
+
if (u = "." + new URL(s, h).pathname, d = await getSkillMdContent(o, u), d === void 0 && (s.startsWith("./") || s.startsWith("../")) && c) {
|
|
965
|
+
const y = c.split("/");
|
|
966
|
+
if (y.length >= 2) {
|
|
967
|
+
const C = `http://localhost/${y[1]}/`, m = "." + new URL(s, C).pathname;
|
|
968
|
+
d = await getSkillMdContent(o, m), d && (u = m);
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
|
-
if (
|
|
972
|
-
const
|
|
973
|
-
|
|
971
|
+
if (d && !o[u]) {
|
|
972
|
+
const y = u.replace(/^\.?\//, "/"), T = Object.keys(o).find((C) => C.endsWith(y));
|
|
973
|
+
T && (u = T);
|
|
974
974
|
}
|
|
975
975
|
} else if (a) {
|
|
976
976
|
const p = await getMainSkillPathByName(o, a);
|
|
977
|
-
p && (
|
|
977
|
+
p && (u = p, d = await getSkillMdContent(o, p));
|
|
978
978
|
}
|
|
979
|
-
return
|
|
979
|
+
return d === void 0 ? {
|
|
980
980
|
error: "未找到对应技能文档",
|
|
981
981
|
skillName: a,
|
|
982
|
-
path:
|
|
982
|
+
path: s,
|
|
983
983
|
providedCurrentPath: c,
|
|
984
|
-
attemptedPath:
|
|
985
|
-
} : { content:
|
|
984
|
+
attemptedPath: u
|
|
985
|
+
} : { content: d, path: u };
|
|
986
986
|
}
|
|
987
987
|
})
|
|
988
988
|
};
|
|
@@ -1186,7 +1186,7 @@ function parseIntersectionDef(t, e) {
|
|
|
1186
1186
|
else {
|
|
1187
1187
|
let a = o;
|
|
1188
1188
|
if ("additionalProperties" in o && o.additionalProperties === !1) {
|
|
1189
|
-
const { additionalProperties:
|
|
1189
|
+
const { additionalProperties: s, ...c } = o;
|
|
1190
1190
|
a = c;
|
|
1191
1191
|
} else
|
|
1192
1192
|
i = void 0;
|
|
@@ -1402,7 +1402,7 @@ function stringifyRegExpWithFlags(t, e) {
|
|
|
1402
1402
|
s: t.flags.includes("s")
|
|
1403
1403
|
// `.` matches newlines
|
|
1404
1404
|
}, i = n.i ? t.source.toLowerCase() : t.source;
|
|
1405
|
-
let r = "", o = !1, a = !1,
|
|
1405
|
+
let r = "", o = !1, a = !1, s = !1;
|
|
1406
1406
|
for (let c = 0; c < i.length; c++) {
|
|
1407
1407
|
if (o) {
|
|
1408
1408
|
r += i[c], o = !1;
|
|
@@ -1411,7 +1411,7 @@ function stringifyRegExpWithFlags(t, e) {
|
|
|
1411
1411
|
if (n.i) {
|
|
1412
1412
|
if (a) {
|
|
1413
1413
|
if (i[c].match(/[a-z]/)) {
|
|
1414
|
-
|
|
1414
|
+
s ? (r += i[c], r += `${i[c - 2]}-${i[c]}`.toUpperCase(), s = !1) : i[c + 1] === "-" && i[c + 2]?.match(/[a-z]/) ? (r += i[c], s = !0) : r += `${i[c]}${i[c].toUpperCase()}`;
|
|
1415
1415
|
continue;
|
|
1416
1416
|
}
|
|
1417
1417
|
} else if (i[c].match(/[a-z]/)) {
|
|
@@ -1576,7 +1576,7 @@ function parseUnionDef(t, e) {
|
|
|
1576
1576
|
}
|
|
1577
1577
|
}, []);
|
|
1578
1578
|
if (i.length === n.length) {
|
|
1579
|
-
const r = i.filter((o, a,
|
|
1579
|
+
const r = i.filter((o, a, s) => s.indexOf(o) === a);
|
|
1580
1580
|
return {
|
|
1581
1581
|
type: r.length > 1 ? r : r[0],
|
|
1582
1582
|
enum: n.reduce((o, a) => o.includes(a._def.value) ? o : [...o, a._def.value], [])
|
|
@@ -1651,18 +1651,18 @@ function parseObjectDef(t, e) {
|
|
|
1651
1651
|
type: "object",
|
|
1652
1652
|
properties: {}
|
|
1653
1653
|
}, r = [], o = t.shape();
|
|
1654
|
-
for (const
|
|
1655
|
-
let c = o[
|
|
1654
|
+
for (const s in o) {
|
|
1655
|
+
let c = o[s];
|
|
1656
1656
|
if (c === void 0 || c._def === void 0)
|
|
1657
1657
|
continue;
|
|
1658
|
-
let
|
|
1659
|
-
|
|
1660
|
-
const
|
|
1658
|
+
let d = safeIsOptional(c);
|
|
1659
|
+
d && n && (c._def.typeName === "ZodOptional" && (c = c._def.innerType), c.isNullable() || (c = c.nullable()), d = !1);
|
|
1660
|
+
const u = parseDef(c._def, {
|
|
1661
1661
|
...e,
|
|
1662
|
-
currentPath: [...e.currentPath, "properties",
|
|
1663
|
-
propertyPath: [...e.currentPath, "properties",
|
|
1662
|
+
currentPath: [...e.currentPath, "properties", s],
|
|
1663
|
+
propertyPath: [...e.currentPath, "properties", s]
|
|
1664
1664
|
});
|
|
1665
|
-
|
|
1665
|
+
u !== void 0 && (i.properties[s] = u, d || r.push(s));
|
|
1666
1666
|
}
|
|
1667
1667
|
r.length && (i.required = r);
|
|
1668
1668
|
const a = decideAdditionalProperties(t, e);
|
|
@@ -1843,21 +1843,21 @@ const parseReadonlyDef = (t, e) => parseDef(t.innerType._def, e), selectParser =
|
|
|
1843
1843
|
function parseDef(t, e, n = !1) {
|
|
1844
1844
|
const i = e.seen.get(t);
|
|
1845
1845
|
if (e.override) {
|
|
1846
|
-
const
|
|
1847
|
-
if (
|
|
1848
|
-
return
|
|
1846
|
+
const s = e.override?.(t, e, i, n);
|
|
1847
|
+
if (s !== ignoreOverride)
|
|
1848
|
+
return s;
|
|
1849
1849
|
}
|
|
1850
1850
|
if (i && !n) {
|
|
1851
|
-
const
|
|
1852
|
-
if (
|
|
1853
|
-
return
|
|
1851
|
+
const s = get$ref(i, e);
|
|
1852
|
+
if (s !== void 0)
|
|
1853
|
+
return s;
|
|
1854
1854
|
}
|
|
1855
1855
|
const r = { def: t, path: e.currentPath, jsonSchema: void 0 };
|
|
1856
1856
|
e.seen.set(t, r);
|
|
1857
1857
|
const o = selectParser(t, t.typeName, e), a = typeof o == "function" ? parseDef(o(), e) : o;
|
|
1858
1858
|
if (a && addMeta(t, e, a), e.postProcess) {
|
|
1859
|
-
const
|
|
1860
|
-
return r.jsonSchema = a,
|
|
1859
|
+
const s = e.postProcess(a, t, e);
|
|
1860
|
+
return r.jsonSchema = a, s;
|
|
1861
1861
|
}
|
|
1862
1862
|
return r.jsonSchema = a, a;
|
|
1863
1863
|
}
|
|
@@ -1950,7 +1950,7 @@ const get$ref = (t, e) => {
|
|
|
1950
1950
|
- \`- role #N [token1] [token2] "accessible name"\`
|
|
1951
1951
|
- \`role\`:ARIA 语义角色(如 button/link/radio/heading/listitem/generic 等)
|
|
1952
1952
|
- \`#N\`:可交互元素的唯一操作索引,**只有带 \`#N\` 的节点才能被操作**,操作时将 N 作为 \`index\` 参数传入
|
|
1953
|
-
- \`[token]\`:可选 token,包括状态标记(如 \`[checked]\` \`[selected]\` \`[disabled]\` \`[cursor=pointer]\`)和定制属性(如 \`[cf-uba="..."]\`)
|
|
1953
|
+
- \`[token]\`:可选 token,包括状态标记(如 \`[checked]\` \`[selected]\` \`[pressed]\` \`[current]\` \`[expanded]\` \`[disabled]\` \`[readonly]\` \`[required]\` \`[invalid]\` \`[busy]\` \`[error]\` \`[warning]\` \`[cursor=pointer]\`)和定制属性(如 \`[cf-uba="..."]\`)
|
|
1954
1954
|
- \`"accessible name"\`:元素的语义化名称,**用双引号包裹**(通过 aria-label/aria-labelledby/innerText 等计算得出);无名称的节点此字段省略
|
|
1955
1955
|
- 缩进表示父子关系
|
|
1956
1956
|
|
|
@@ -2116,26 +2116,26 @@ async function clickElement(t) {
|
|
|
2116
2116
|
await enablePassThrough();
|
|
2117
2117
|
const a = o.elementFromPoint(i, r);
|
|
2118
2118
|
await disablePassThrough();
|
|
2119
|
-
const
|
|
2119
|
+
const s = a instanceof HTMLElement && t.contains(a) ? a : t, c = {
|
|
2120
2120
|
bubbles: !0,
|
|
2121
2121
|
cancelable: !0,
|
|
2122
2122
|
clientX: i,
|
|
2123
2123
|
clientY: r,
|
|
2124
2124
|
pointerType: "mouse"
|
|
2125
|
-
},
|
|
2125
|
+
}, d = {
|
|
2126
2126
|
bubbles: !0,
|
|
2127
2127
|
cancelable: !0,
|
|
2128
2128
|
clientX: i,
|
|
2129
2129
|
clientY: r,
|
|
2130
2130
|
button: 0
|
|
2131
2131
|
};
|
|
2132
|
-
|
|
2132
|
+
s.dispatchEvent(new PointerEvent("pointerover", c)), s.dispatchEvent(new PointerEvent("pointerenter", {
|
|
2133
2133
|
...c,
|
|
2134
2134
|
bubbles: !1
|
|
2135
|
-
})),
|
|
2136
|
-
...
|
|
2135
|
+
})), s.dispatchEvent(new MouseEvent("mouseover", d)), s.dispatchEvent(new MouseEvent("mouseenter", {
|
|
2136
|
+
...d,
|
|
2137
2137
|
bubbles: !1
|
|
2138
|
-
})),
|
|
2138
|
+
})), s.dispatchEvent(new PointerEvent("pointerdown", c)), s.dispatchEvent(new MouseEvent("mousedown", d)), t.focus({ preventScroll: !0 }), s.dispatchEvent(new PointerEvent("pointerup", c)), s.dispatchEvent(new MouseEvent("mouseup", d)), s.click(), await waitFor(0.2);
|
|
2139
2139
|
}
|
|
2140
2140
|
async function inputTextElement(t, e) {
|
|
2141
2141
|
const n = t.isContentEditable;
|
|
@@ -2183,93 +2183,93 @@ async function scrollIntoViewIfNeeded(t) {
|
|
|
2183
2183
|
async function scrollVertically(t, e) {
|
|
2184
2184
|
if (e) {
|
|
2185
2185
|
const a = e;
|
|
2186
|
-
let
|
|
2187
|
-
const
|
|
2188
|
-
for (;
|
|
2189
|
-
const
|
|
2190
|
-
if (
|
|
2191
|
-
const
|
|
2192
|
-
let
|
|
2193
|
-
|
|
2194
|
-
const
|
|
2195
|
-
if (Math.abs(
|
|
2196
|
-
c = !0,
|
|
2186
|
+
let s = a, c = !1, d = null, u = 0, p = 0;
|
|
2187
|
+
const h = t;
|
|
2188
|
+
for (; s && p < 10; ) {
|
|
2189
|
+
const g = window.getComputedStyle(s), y = /(auto|scroll|overlay)/.test(g.overflowY) || g.scrollbarWidth && g.scrollbarWidth !== "auto" || g.scrollbarGutter && g.scrollbarGutter !== "auto", T = s.scrollHeight > s.clientHeight;
|
|
2190
|
+
if (y && T) {
|
|
2191
|
+
const C = s.scrollTop, f = s.scrollHeight - s.clientHeight;
|
|
2192
|
+
let m = h / 3;
|
|
2193
|
+
m > 0 ? m = Math.min(m, f - C) : m = Math.max(m, -C), s.scrollTop = C + m;
|
|
2194
|
+
const E = s.scrollTop - C;
|
|
2195
|
+
if (Math.abs(E) > 0.5) {
|
|
2196
|
+
c = !0, d = s, u = E;
|
|
2197
2197
|
break;
|
|
2198
2198
|
}
|
|
2199
2199
|
}
|
|
2200
|
-
if (
|
|
2201
|
-
|
|
2200
|
+
if (s === document.body || s === document.documentElement) break;
|
|
2201
|
+
s = s.parentElement, p++;
|
|
2202
2202
|
}
|
|
2203
|
-
return c ? `Scrolled container (${
|
|
2203
|
+
return c ? `Scrolled container (${d?.tagName}) by ${u}px` : `No scrollable container found for element (${a.tagName})`;
|
|
2204
2204
|
}
|
|
2205
2205
|
const n = t, i = (a) => a.clientHeight >= window.innerHeight * 0.5, r = (a) => !!(a && /(auto|scroll|overlay)/.test(getComputedStyle(a).overflowY) && a.scrollHeight > a.clientHeight && i(a));
|
|
2206
2206
|
let o = document.activeElement;
|
|
2207
2207
|
for (; o && !r(o) && o !== document.body; ) o = o.parentElement;
|
|
2208
2208
|
if (o = r(o) ? o : Array.from(document.querySelectorAll("*")).find(r) || document.scrollingElement || document.documentElement, o === document.scrollingElement || o === document.documentElement || o === document.body) {
|
|
2209
|
-
const a = window.scrollY,
|
|
2209
|
+
const a = window.scrollY, s = document.documentElement.scrollHeight - window.innerHeight;
|
|
2210
2210
|
window.scrollBy(0, n);
|
|
2211
|
-
const c = window.scrollY,
|
|
2212
|
-
if (Math.abs(
|
|
2213
|
-
const
|
|
2214
|
-
return
|
|
2211
|
+
const c = window.scrollY, d = c - a;
|
|
2212
|
+
if (Math.abs(d) < 1) return n > 0 ? "⚠️ Already at the bottom of the page, cannot scroll down further." : "⚠️ Already at the top of the page, cannot scroll up further.";
|
|
2213
|
+
const u = n > 0 && c >= s - 1, p = n < 0 && c <= 1;
|
|
2214
|
+
return u ? `✅ Scrolled page by ${d}px. Reached the bottom of the page.` : p ? `✅ Scrolled page by ${d}px. Reached the top of the page.` : `✅ Scrolled page by ${d}px.`;
|
|
2215
2215
|
} else {
|
|
2216
2216
|
const a = "The document is not scrollable. Falling back to container scroll.";
|
|
2217
2217
|
console.log(`[PageController] ${a}`);
|
|
2218
|
-
const
|
|
2218
|
+
const s = o.scrollTop, c = o.scrollHeight - o.clientHeight;
|
|
2219
2219
|
o.scrollBy({
|
|
2220
2220
|
top: n,
|
|
2221
2221
|
behavior: "smooth"
|
|
2222
2222
|
}), await waitFor(0.1);
|
|
2223
|
-
const
|
|
2224
|
-
if (Math.abs(
|
|
2225
|
-
const p = n > 0 &&
|
|
2226
|
-
return p ? `✅ ${a} Scrolled container (${o.tagName}) by ${
|
|
2223
|
+
const d = o.scrollTop, u = d - s;
|
|
2224
|
+
if (Math.abs(u) < 1) return n > 0 ? `⚠️ ${a} Already at the bottom of container (${o.tagName}), cannot scroll down further.` : `⚠️ ${a} Already at the top of container (${o.tagName}), cannot scroll up further.`;
|
|
2225
|
+
const p = n > 0 && d >= c - 1, h = n < 0 && d <= 1;
|
|
2226
|
+
return p ? `✅ ${a} Scrolled container (${o.tagName}) by ${u}px. Reached the bottom.` : h ? `✅ ${a} Scrolled container (${o.tagName}) by ${u}px. Reached the top.` : `✅ ${a} Scrolled container (${o.tagName}) by ${u}px.`;
|
|
2227
2227
|
}
|
|
2228
2228
|
}
|
|
2229
2229
|
async function scrollHorizontally(t, e) {
|
|
2230
2230
|
if (e) {
|
|
2231
2231
|
const a = e;
|
|
2232
|
-
let
|
|
2233
|
-
const
|
|
2234
|
-
for (;
|
|
2235
|
-
const
|
|
2236
|
-
if (
|
|
2237
|
-
const
|
|
2238
|
-
let
|
|
2239
|
-
|
|
2240
|
-
const
|
|
2241
|
-
if (Math.abs(
|
|
2242
|
-
c = !0,
|
|
2232
|
+
let s = a, c = !1, d = null, u = 0, p = 0;
|
|
2233
|
+
const h = t;
|
|
2234
|
+
for (; s && p < 10; ) {
|
|
2235
|
+
const g = window.getComputedStyle(s), y = /(auto|scroll|overlay)/.test(g.overflowX) || g.scrollbarWidth && g.scrollbarWidth !== "auto" || g.scrollbarGutter && g.scrollbarGutter !== "auto", T = s.scrollWidth > s.clientWidth;
|
|
2236
|
+
if (y && T) {
|
|
2237
|
+
const C = s.scrollLeft, f = s.scrollWidth - s.clientWidth;
|
|
2238
|
+
let m = h / 3;
|
|
2239
|
+
m > 0 ? m = Math.min(m, f - C) : m = Math.max(m, -C), s.scrollLeft = C + m;
|
|
2240
|
+
const E = s.scrollLeft - C;
|
|
2241
|
+
if (Math.abs(E) > 0.5) {
|
|
2242
|
+
c = !0, d = s, u = E;
|
|
2243
2243
|
break;
|
|
2244
2244
|
}
|
|
2245
2245
|
}
|
|
2246
|
-
if (
|
|
2247
|
-
|
|
2246
|
+
if (s === document.body || s === document.documentElement) break;
|
|
2247
|
+
s = s.parentElement, p++;
|
|
2248
2248
|
}
|
|
2249
|
-
return c ? `Scrolled container (${
|
|
2249
|
+
return c ? `Scrolled container (${d?.tagName}) horizontally by ${u}px` : `No horizontally scrollable container found for element (${a.tagName})`;
|
|
2250
2250
|
}
|
|
2251
2251
|
const n = t, i = (a) => a.clientWidth >= window.innerWidth * 0.5, r = (a) => !!(a && /(auto|scroll|overlay)/.test(getComputedStyle(a).overflowX) && a.scrollWidth > a.clientWidth && i(a));
|
|
2252
2252
|
let o = document.activeElement;
|
|
2253
2253
|
for (; o && !r(o) && o !== document.body; ) o = o.parentElement;
|
|
2254
2254
|
if (o = r(o) ? o : Array.from(document.querySelectorAll("*")).find(r) || document.scrollingElement || document.documentElement, o === document.scrollingElement || o === document.documentElement || o === document.body) {
|
|
2255
|
-
const a = window.scrollX,
|
|
2255
|
+
const a = window.scrollX, s = document.documentElement.scrollWidth - window.innerWidth;
|
|
2256
2256
|
window.scrollBy(n, 0);
|
|
2257
|
-
const c = window.scrollX,
|
|
2258
|
-
if (Math.abs(
|
|
2259
|
-
const
|
|
2260
|
-
return
|
|
2257
|
+
const c = window.scrollX, d = c - a;
|
|
2258
|
+
if (Math.abs(d) < 1) return n > 0 ? "⚠️ Already at the right edge of the page, cannot scroll right further." : "⚠️ Already at the left edge of the page, cannot scroll left further.";
|
|
2259
|
+
const u = n > 0 && c >= s - 1, p = n < 0 && c <= 1;
|
|
2260
|
+
return u ? `✅ Scrolled page by ${d}px. Reached the right edge of the page.` : p ? `✅ Scrolled page by ${d}px. Reached the left edge of the page.` : `✅ Scrolled page horizontally by ${d}px.`;
|
|
2261
2261
|
} else {
|
|
2262
2262
|
const a = "The document is not scrollable. Falling back to container scroll.";
|
|
2263
2263
|
console.log(`[PageController] ${a}`);
|
|
2264
|
-
const
|
|
2264
|
+
const s = o.scrollLeft, c = o.scrollWidth - o.clientWidth;
|
|
2265
2265
|
o.scrollBy({
|
|
2266
2266
|
left: n,
|
|
2267
2267
|
behavior: "smooth"
|
|
2268
2268
|
}), await waitFor(0.1);
|
|
2269
|
-
const
|
|
2270
|
-
if (Math.abs(
|
|
2271
|
-
const p = n > 0 &&
|
|
2272
|
-
return p ? `✅ ${a} Scrolled container (${o.tagName}) by ${
|
|
2269
|
+
const d = o.scrollLeft, u = d - s;
|
|
2270
|
+
if (Math.abs(u) < 1) return n > 0 ? `⚠️ ${a} Already at the right edge of container (${o.tagName}), cannot scroll right further.` : `⚠️ ${a} Already at the left edge of container (${o.tagName}), cannot scroll left further.`;
|
|
2271
|
+
const p = n > 0 && d >= c - 1, h = n < 0 && d <= 1;
|
|
2272
|
+
return p ? `✅ ${a} Scrolled container (${o.tagName}) by ${u}px. Reached the right edge.` : h ? `✅ ${a} Scrolled container (${o.tagName}) by ${u}px. Reached the left edge.` : `✅ ${a} Scrolled container (${o.tagName}) horizontally by ${u}px.`;
|
|
2273
2273
|
}
|
|
2274
2274
|
}
|
|
2275
2275
|
var dom_tree_default = (t = {
|
|
@@ -2287,51 +2287,51 @@ var dom_tree_default = (t = {
|
|
|
2287
2287
|
highlightOpacity: 0.1,
|
|
2288
2288
|
highlightLabelOpacity: 0.5
|
|
2289
2289
|
}) => {
|
|
2290
|
-
const { interactiveBlacklist: e, interactiveWhitelist: n, highlightOpacity: i, highlightLabelOpacity: r } = t, { doHighlightElements: o, focusHighlightIndex: a, viewportExpansion:
|
|
2291
|
-
let
|
|
2292
|
-
const
|
|
2293
|
-
function p(
|
|
2294
|
-
!
|
|
2295
|
-
...
|
|
2290
|
+
const { interactiveBlacklist: e, interactiveWhitelist: n, highlightOpacity: i, highlightLabelOpacity: r } = t, { doHighlightElements: o, focusHighlightIndex: a, viewportExpansion: s, debugMode: c } = t;
|
|
2291
|
+
let d = 0;
|
|
2292
|
+
const u = /* @__PURE__ */ new WeakMap();
|
|
2293
|
+
function p(l, b) {
|
|
2294
|
+
!l || l.nodeType !== Node.ELEMENT_NODE || u.set(l, {
|
|
2295
|
+
...u.get(l),
|
|
2296
2296
|
...b
|
|
2297
2297
|
});
|
|
2298
2298
|
}
|
|
2299
|
-
const
|
|
2299
|
+
const h = {
|
|
2300
2300
|
boundingRects: /* @__PURE__ */ new WeakMap(),
|
|
2301
2301
|
clientRects: /* @__PURE__ */ new WeakMap(),
|
|
2302
2302
|
computedStyles: /* @__PURE__ */ new WeakMap(),
|
|
2303
2303
|
clearCache: () => {
|
|
2304
|
-
|
|
2304
|
+
h.boundingRects = /* @__PURE__ */ new WeakMap(), h.clientRects = /* @__PURE__ */ new WeakMap(), h.computedStyles = /* @__PURE__ */ new WeakMap();
|
|
2305
2305
|
}
|
|
2306
2306
|
};
|
|
2307
|
-
function
|
|
2308
|
-
if (!
|
|
2309
|
-
if (
|
|
2310
|
-
const b =
|
|
2311
|
-
return b &&
|
|
2312
|
-
}
|
|
2313
|
-
function
|
|
2314
|
-
if (!
|
|
2315
|
-
if (
|
|
2316
|
-
const b = window.getComputedStyle(
|
|
2317
|
-
return b &&
|
|
2318
|
-
}
|
|
2319
|
-
function
|
|
2320
|
-
if (!
|
|
2321
|
-
if (
|
|
2322
|
-
const b =
|
|
2323
|
-
return b &&
|
|
2324
|
-
}
|
|
2325
|
-
const
|
|
2326
|
-
function
|
|
2327
|
-
if (!
|
|
2307
|
+
function g(l) {
|
|
2308
|
+
if (!l) return null;
|
|
2309
|
+
if (h.boundingRects.has(l)) return h.boundingRects.get(l);
|
|
2310
|
+
const b = l.getBoundingClientRect();
|
|
2311
|
+
return b && h.boundingRects.set(l, b), b;
|
|
2312
|
+
}
|
|
2313
|
+
function y(l) {
|
|
2314
|
+
if (!l) return null;
|
|
2315
|
+
if (h.computedStyles.has(l)) return h.computedStyles.get(l);
|
|
2316
|
+
const b = window.getComputedStyle(l);
|
|
2317
|
+
return b && h.computedStyles.set(l, b), b;
|
|
2318
|
+
}
|
|
2319
|
+
function T(l) {
|
|
2320
|
+
if (!l) return null;
|
|
2321
|
+
if (h.clientRects.has(l)) return h.clientRects.get(l);
|
|
2322
|
+
const b = l.getClientRects();
|
|
2323
|
+
return b && h.clientRects.set(l, b), b;
|
|
2324
|
+
}
|
|
2325
|
+
const C = {}, f = { current: 0 }, m = "playwright-highlight-container";
|
|
2326
|
+
function E(l, b, R = null) {
|
|
2327
|
+
if (!l) return b;
|
|
2328
2328
|
const w = [];
|
|
2329
|
-
let _ = null,
|
|
2329
|
+
let _ = null, D = 20, x = 16, P = null;
|
|
2330
2330
|
try {
|
|
2331
|
-
let k = document.getElementById(
|
|
2332
|
-
k || (k = document.createElement("div"), k.id =
|
|
2333
|
-
const
|
|
2334
|
-
if (!
|
|
2331
|
+
let k = document.getElementById(m);
|
|
2332
|
+
k || (k = document.createElement("div"), k.id = m, k.style.position = "fixed", k.style.pointerEvents = "none", k.style.top = "0", k.style.left = "0", k.style.width = "100%", k.style.height = "100%", k.style.zIndex = "2147483640", k.style.backgroundColor = "transparent", document.body.appendChild(k));
|
|
2333
|
+
const I = l.getClientRects();
|
|
2334
|
+
if (!I || I.length === 0) return b;
|
|
2335
2335
|
const Y = [
|
|
2336
2336
|
"#FF0000",
|
|
2337
2337
|
"#00FF00",
|
|
@@ -2346,60 +2346,60 @@ var dom_tree_default = (t = {
|
|
|
2346
2346
|
"#DC143C",
|
|
2347
2347
|
"#4682B4"
|
|
2348
2348
|
];
|
|
2349
|
-
let
|
|
2350
|
-
const
|
|
2351
|
-
|
|
2349
|
+
let V = Y[b % Y.length];
|
|
2350
|
+
const K = V + Math.floor(i * 255).toString(16).padStart(2, "0");
|
|
2351
|
+
V = V + Math.floor(r * 255).toString(16).padStart(2, "0");
|
|
2352
2352
|
let j = {
|
|
2353
2353
|
x: 0,
|
|
2354
2354
|
y: 0
|
|
2355
2355
|
};
|
|
2356
|
-
if (
|
|
2357
|
-
const H =
|
|
2356
|
+
if (R) {
|
|
2357
|
+
const H = R.getBoundingClientRect();
|
|
2358
2358
|
j.x = H.left, j.y = H.top;
|
|
2359
2359
|
}
|
|
2360
2360
|
const ae = document.createDocumentFragment();
|
|
2361
|
-
for (const H of
|
|
2361
|
+
for (const H of I) {
|
|
2362
2362
|
if (H.width === 0 || H.height === 0) continue;
|
|
2363
2363
|
const U = document.createElement("div");
|
|
2364
|
-
U.style.position = "fixed", U.style.border = `2px solid ${
|
|
2365
|
-
const
|
|
2366
|
-
U.style.top = `${
|
|
2364
|
+
U.style.position = "fixed", U.style.border = `2px solid ${V}`, U.style.backgroundColor = K, U.style.pointerEvents = "none", U.style.boxSizing = "border-box";
|
|
2365
|
+
const $ = H.top + j.y, X = H.left + j.x;
|
|
2366
|
+
U.style.top = `${$}px`, U.style.left = `${X}px`, U.style.width = `${H.width}px`, U.style.height = `${H.height}px`, ae.appendChild(U), w.push({
|
|
2367
2367
|
element: U,
|
|
2368
2368
|
initialRect: H
|
|
2369
2369
|
});
|
|
2370
2370
|
}
|
|
2371
|
-
const ie =
|
|
2372
|
-
_ = document.createElement("div"), _.className = "playwright-highlight-label", _.style.position = "fixed", _.style.background =
|
|
2371
|
+
const ie = I[0];
|
|
2372
|
+
_ = document.createElement("div"), _.className = "playwright-highlight-label", _.style.position = "fixed", _.style.background = V, _.style.color = "white", _.style.padding = "1px 4px", _.style.borderRadius = "4px", _.style.fontSize = `${Math.min(12, Math.max(8, ie.height / 2))}px`, _.textContent = b.toString(), D = _.offsetWidth > 0 ? _.offsetWidth : D, x = _.offsetHeight > 0 ? _.offsetHeight : x;
|
|
2373
2373
|
const de = ie.top + j.y, ue = ie.left + j.x;
|
|
2374
|
-
let se = de + 2, re = ue + ie.width -
|
|
2375
|
-
(ie.width <
|
|
2374
|
+
let se = de + 2, re = ue + ie.width - D - 2;
|
|
2375
|
+
(ie.width < D + 4 || ie.height < x + 4) && (se = de - x - 2, re = ue + ie.width - D, re < j.x && (re = ue)), se = Math.max(0, Math.min(se, window.innerHeight - x)), re = Math.max(0, Math.min(re, window.innerWidth - D)), _.style.top = `${se}px`, _.style.left = `${re}px`, ae.appendChild(_);
|
|
2376
2376
|
const le = ((H, U) => {
|
|
2377
|
-
let
|
|
2378
|
-
return (...
|
|
2377
|
+
let $ = 0;
|
|
2378
|
+
return (...X) => {
|
|
2379
2379
|
const q = performance.now();
|
|
2380
|
-
if (!(q -
|
|
2381
|
-
return
|
|
2380
|
+
if (!(q - $ < U))
|
|
2381
|
+
return $ = q, H(...X);
|
|
2382
2382
|
};
|
|
2383
2383
|
})(() => {
|
|
2384
|
-
const H =
|
|
2384
|
+
const H = l.getClientRects();
|
|
2385
2385
|
let U = {
|
|
2386
2386
|
x: 0,
|
|
2387
2387
|
y: 0
|
|
2388
2388
|
};
|
|
2389
|
-
if (
|
|
2390
|
-
const
|
|
2391
|
-
U.x =
|
|
2389
|
+
if (R) {
|
|
2390
|
+
const $ = R.getBoundingClientRect();
|
|
2391
|
+
U.x = $.left, U.y = $.top;
|
|
2392
2392
|
}
|
|
2393
|
-
if (w.forEach((
|
|
2394
|
-
if (
|
|
2395
|
-
const q = H[
|
|
2396
|
-
|
|
2397
|
-
} else
|
|
2398
|
-
}), H.length < w.length) for (let
|
|
2393
|
+
if (w.forEach(($, X) => {
|
|
2394
|
+
if (X < H.length) {
|
|
2395
|
+
const q = H[X], oe = q.top + U.y, ne = q.left + U.x;
|
|
2396
|
+
$.element.style.top = `${oe}px`, $.element.style.left = `${ne}px`, $.element.style.width = `${q.width}px`, $.element.style.height = `${q.height}px`, $.element.style.display = q.width === 0 || q.height === 0 ? "none" : "block";
|
|
2397
|
+
} else $.element.style.display = "none";
|
|
2398
|
+
}), H.length < w.length) for (let $ = H.length; $ < w.length; $++) w[$].element.style.display = "none";
|
|
2399
2399
|
if (_ && H.length > 0) {
|
|
2400
|
-
const
|
|
2401
|
-
let oe =
|
|
2402
|
-
(
|
|
2400
|
+
const $ = H[0], X = $.top + U.y, q = $.left + U.x;
|
|
2401
|
+
let oe = X + 2, ne = q + $.width - D - 2;
|
|
2402
|
+
($.width < D + 4 || $.height < x + 4) && (oe = X - x - 2, ne = q + $.width - D, ne < U.x && (ne = q)), oe = Math.max(0, Math.min(oe, window.innerHeight - x)), ne = Math.max(0, Math.min(ne, window.innerWidth - D)), _.style.top = `${oe}px`, _.style.left = `${ne}px`, _.style.display = "block";
|
|
2403
2403
|
} else _ && (_.style.display = "none");
|
|
2404
2404
|
}, 16);
|
|
2405
2405
|
return window.addEventListener("scroll", le, !0), window.addEventListener("resize", le), P = () => {
|
|
@@ -2409,69 +2409,69 @@ var dom_tree_default = (t = {
|
|
|
2409
2409
|
P && (window._highlightCleanupFunctions = window._highlightCleanupFunctions || []).push(P);
|
|
2410
2410
|
}
|
|
2411
2411
|
}
|
|
2412
|
-
function
|
|
2413
|
-
if (!
|
|
2414
|
-
const b =
|
|
2412
|
+
function v(l) {
|
|
2413
|
+
if (!l || l.nodeType !== Node.ELEMENT_NODE) return null;
|
|
2414
|
+
const b = y(l);
|
|
2415
2415
|
if (!b) return null;
|
|
2416
|
-
const
|
|
2417
|
-
if (
|
|
2418
|
-
const w = b.overflowX, _ = b.overflowY,
|
|
2419
|
-
if (!
|
|
2420
|
-
const k =
|
|
2421
|
-
if (k < Y &&
|
|
2422
|
-
const
|
|
2423
|
-
top:
|
|
2424
|
-
right:
|
|
2425
|
-
bottom:
|
|
2426
|
-
left:
|
|
2416
|
+
const R = b.display;
|
|
2417
|
+
if (R === "inline" || R === "inline-block") return null;
|
|
2418
|
+
const w = b.overflowX, _ = b.overflowY, D = b.scrollbarWidth && b.scrollbarWidth !== "auto" || b.scrollbarGutter && b.scrollbarGutter !== "auto", x = w === "auto" || w === "scroll", P = _ === "auto" || _ === "scroll";
|
|
2419
|
+
if (!x && !P && !D) return null;
|
|
2420
|
+
const k = l.scrollWidth - l.clientWidth, I = l.scrollHeight - l.clientHeight, Y = 4;
|
|
2421
|
+
if (k < Y && I < Y || !P && !D && k < Y || !x && !D && I < Y) return null;
|
|
2422
|
+
const V = l.scrollTop, K = l.scrollLeft, j = {
|
|
2423
|
+
top: V,
|
|
2424
|
+
right: l.scrollWidth - l.clientWidth - l.scrollLeft,
|
|
2425
|
+
bottom: l.scrollHeight - l.clientHeight - l.scrollTop,
|
|
2426
|
+
left: K
|
|
2427
2427
|
};
|
|
2428
|
-
return p(
|
|
2428
|
+
return p(l, {
|
|
2429
2429
|
scrollable: !0,
|
|
2430
2430
|
scrollData: j
|
|
2431
2431
|
}), j;
|
|
2432
2432
|
}
|
|
2433
|
-
function
|
|
2433
|
+
function L(l) {
|
|
2434
2434
|
try {
|
|
2435
|
-
if (
|
|
2436
|
-
const
|
|
2437
|
-
if (!
|
|
2435
|
+
if (s === -1) {
|
|
2436
|
+
const x = l.parentElement;
|
|
2437
|
+
if (!x) return !1;
|
|
2438
2438
|
try {
|
|
2439
|
-
return
|
|
2439
|
+
return x.checkVisibility({
|
|
2440
2440
|
checkOpacity: !0,
|
|
2441
2441
|
checkVisibilityCSS: !0
|
|
2442
2442
|
});
|
|
2443
2443
|
} catch {
|
|
2444
|
-
const k = window.getComputedStyle(
|
|
2444
|
+
const k = window.getComputedStyle(x);
|
|
2445
2445
|
return k.display !== "none" && k.visibility !== "hidden" && k.opacity !== "0";
|
|
2446
2446
|
}
|
|
2447
2447
|
}
|
|
2448
2448
|
const b = document.createRange();
|
|
2449
|
-
b.selectNodeContents(
|
|
2450
|
-
const
|
|
2451
|
-
if (!
|
|
2449
|
+
b.selectNodeContents(l);
|
|
2450
|
+
const R = b.getClientRects();
|
|
2451
|
+
if (!R || R.length === 0) return !1;
|
|
2452
2452
|
let w = !1, _ = !1;
|
|
2453
|
-
for (const
|
|
2453
|
+
for (const x of R) if (x.width > 0 && x.height > 0 && (w = !0, !(x.bottom < -s || x.top > window.innerHeight + s || x.right < -s || x.left > window.innerWidth + s))) {
|
|
2454
2454
|
_ = !0;
|
|
2455
2455
|
break;
|
|
2456
2456
|
}
|
|
2457
2457
|
if (!w || !_) return !1;
|
|
2458
|
-
const
|
|
2459
|
-
if (!
|
|
2458
|
+
const D = l.parentElement;
|
|
2459
|
+
if (!D) return !1;
|
|
2460
2460
|
try {
|
|
2461
|
-
return
|
|
2461
|
+
return D.checkVisibility({
|
|
2462
2462
|
checkOpacity: !0,
|
|
2463
2463
|
checkVisibilityCSS: !0
|
|
2464
2464
|
});
|
|
2465
2465
|
} catch {
|
|
2466
|
-
const P = window.getComputedStyle(
|
|
2466
|
+
const P = window.getComputedStyle(D);
|
|
2467
2467
|
return P.display !== "none" && P.visibility !== "hidden" && P.opacity !== "0";
|
|
2468
2468
|
}
|
|
2469
2469
|
} catch (b) {
|
|
2470
2470
|
return console.warn("Error checking text node visibility:", b), !1;
|
|
2471
2471
|
}
|
|
2472
2472
|
}
|
|
2473
|
-
function
|
|
2474
|
-
if (!
|
|
2473
|
+
function S(l) {
|
|
2474
|
+
if (!l || !l.tagName) return !1;
|
|
2475
2475
|
const b = /* @__PURE__ */ new Set([
|
|
2476
2476
|
"body",
|
|
2477
2477
|
"div",
|
|
@@ -2481,8 +2481,8 @@ var dom_tree_default = (t = {
|
|
|
2481
2481
|
"nav",
|
|
2482
2482
|
"header",
|
|
2483
2483
|
"footer"
|
|
2484
|
-
]),
|
|
2485
|
-
return b.has(
|
|
2484
|
+
]), R = l.tagName.toLowerCase();
|
|
2485
|
+
return b.has(R) ? !0 : !(/* @__PURE__ */ new Set([
|
|
2486
2486
|
"svg",
|
|
2487
2487
|
"script",
|
|
2488
2488
|
"style",
|
|
@@ -2490,16 +2490,16 @@ var dom_tree_default = (t = {
|
|
|
2490
2490
|
"meta",
|
|
2491
2491
|
"noscript",
|
|
2492
2492
|
"template"
|
|
2493
|
-
])).has(
|
|
2493
|
+
])).has(R);
|
|
2494
2494
|
}
|
|
2495
|
-
function
|
|
2496
|
-
const b =
|
|
2497
|
-
return
|
|
2495
|
+
function A(l) {
|
|
2496
|
+
const b = y(l);
|
|
2497
|
+
return l.offsetWidth > 0 && l.offsetHeight > 0 && b?.visibility !== "hidden" && b?.display !== "none";
|
|
2498
2498
|
}
|
|
2499
|
-
function
|
|
2500
|
-
if (!
|
|
2501
|
-
if (n.includes(
|
|
2502
|
-
const b =
|
|
2499
|
+
function N(l) {
|
|
2500
|
+
if (!l || l.nodeType !== Node.ELEMENT_NODE || e.includes(l)) return !1;
|
|
2501
|
+
if (n.includes(l)) return !0;
|
|
2502
|
+
const b = l.tagName.toLowerCase(), R = y(l), w = /* @__PURE__ */ new Set([
|
|
2503
2503
|
"pointer",
|
|
2504
2504
|
"move",
|
|
2505
2505
|
"text",
|
|
@@ -2537,11 +2537,11 @@ var dom_tree_default = (t = {
|
|
|
2537
2537
|
"initial",
|
|
2538
2538
|
"inherit"
|
|
2539
2539
|
]);
|
|
2540
|
-
function
|
|
2541
|
-
return
|
|
2540
|
+
function D(V) {
|
|
2541
|
+
return V.tagName.toLowerCase() === "html" ? !1 : !!(R?.cursor && w.has(R.cursor));
|
|
2542
2542
|
}
|
|
2543
|
-
if (
|
|
2544
|
-
const
|
|
2543
|
+
if (D(l)) return !0;
|
|
2544
|
+
const x = /* @__PURE__ */ new Set([
|
|
2545
2545
|
"a",
|
|
2546
2546
|
"button",
|
|
2547
2547
|
"input",
|
|
@@ -2555,13 +2555,13 @@ var dom_tree_default = (t = {
|
|
|
2555
2555
|
"fieldset",
|
|
2556
2556
|
"legend"
|
|
2557
2557
|
]), P = /* @__PURE__ */ new Set(["disabled", "readonly"]);
|
|
2558
|
-
if (
|
|
2559
|
-
if (
|
|
2560
|
-
for (const
|
|
2561
|
-
return !(
|
|
2558
|
+
if (x.has(b)) {
|
|
2559
|
+
if (R?.cursor && _.has(R.cursor)) return !1;
|
|
2560
|
+
for (const V of P) if (l.hasAttribute(V) || l.getAttribute(V) === "true" || l.getAttribute(V) === "") return !1;
|
|
2561
|
+
return !(l.disabled || l.readOnly || l.inert);
|
|
2562
2562
|
}
|
|
2563
|
-
const k =
|
|
2564
|
-
if (
|
|
2563
|
+
const k = l.getAttribute("role"), I = l.getAttribute("aria-role");
|
|
2564
|
+
if (l.getAttribute("contenteditable") === "true" || l.isContentEditable || l.classList && (l.classList.contains("button") || l.classList.contains("dropdown-toggle") || l.getAttribute("data-index") || l.getAttribute("data-toggle") === "dropdown" || l.getAttribute("aria-haspopup") === "true")) return !0;
|
|
2565
2565
|
const Y = /* @__PURE__ */ new Set([
|
|
2566
2566
|
"button",
|
|
2567
2567
|
"menu",
|
|
@@ -2582,20 +2582,20 @@ var dom_tree_default = (t = {
|
|
|
2582
2582
|
"option",
|
|
2583
2583
|
"scrollbar"
|
|
2584
2584
|
]);
|
|
2585
|
-
if (
|
|
2585
|
+
if (x.has(b) || k && Y.has(k) || I && Y.has(I)) return !0;
|
|
2586
2586
|
try {
|
|
2587
2587
|
if (typeof getEventListeners == "function") {
|
|
2588
|
-
const
|
|
2588
|
+
const K = getEventListeners(l);
|
|
2589
2589
|
for (const j of [
|
|
2590
2590
|
"click",
|
|
2591
2591
|
"mousedown",
|
|
2592
2592
|
"mouseup",
|
|
2593
2593
|
"dblclick"
|
|
2594
|
-
]) if (
|
|
2594
|
+
]) if (K[j] && K[j].length > 0) return !0;
|
|
2595
2595
|
}
|
|
2596
|
-
const
|
|
2597
|
-
if (typeof
|
|
2598
|
-
const
|
|
2596
|
+
const V = l?.ownerDocument?.defaultView?.getEventListenersForNode || window.getEventListenersForNode;
|
|
2597
|
+
if (typeof V == "function") {
|
|
2598
|
+
const K = V(l);
|
|
2599
2599
|
for (const j of [
|
|
2600
2600
|
"click",
|
|
2601
2601
|
"mousedown",
|
|
@@ -2607,69 +2607,69 @@ var dom_tree_default = (t = {
|
|
|
2607
2607
|
"input",
|
|
2608
2608
|
"focus",
|
|
2609
2609
|
"blur"
|
|
2610
|
-
]) for (const ae of
|
|
2610
|
+
]) for (const ae of K) if (ae.type === j) return !0;
|
|
2611
2611
|
}
|
|
2612
|
-
for (const
|
|
2612
|
+
for (const K of [
|
|
2613
2613
|
"onclick",
|
|
2614
2614
|
"onmousedown",
|
|
2615
2615
|
"onmouseup",
|
|
2616
2616
|
"ondblclick"
|
|
2617
|
-
]) if (
|
|
2617
|
+
]) if (l.hasAttribute(K) || typeof l[K] == "function") return !0;
|
|
2618
2618
|
} catch {
|
|
2619
2619
|
}
|
|
2620
|
-
return !!
|
|
2620
|
+
return !!v(l);
|
|
2621
2621
|
}
|
|
2622
|
-
function
|
|
2623
|
-
if (
|
|
2624
|
-
const b =
|
|
2622
|
+
function M(l) {
|
|
2623
|
+
if (s === -1) return !0;
|
|
2624
|
+
const b = T(l);
|
|
2625
2625
|
if (!b || b.length === 0) return !1;
|
|
2626
|
-
let
|
|
2627
|
-
for (const
|
|
2628
|
-
|
|
2626
|
+
let R = !1;
|
|
2627
|
+
for (const x of b) if (x.width > 0 && x.height > 0 && !(x.bottom < -s || x.top > window.innerHeight + s || x.right < -s || x.left > window.innerWidth + s)) {
|
|
2628
|
+
R = !0;
|
|
2629
2629
|
break;
|
|
2630
2630
|
}
|
|
2631
|
-
if (!
|
|
2632
|
-
if (
|
|
2633
|
-
let w = Array.from(b).find((
|
|
2631
|
+
if (!R) return !1;
|
|
2632
|
+
if (l.ownerDocument !== window.document) return !0;
|
|
2633
|
+
let w = Array.from(b).find((x) => x.width > 0 && x.height > 0);
|
|
2634
2634
|
if (!w) return !1;
|
|
2635
|
-
const _ =
|
|
2635
|
+
const _ = l.getRootNode();
|
|
2636
2636
|
if (_ instanceof ShadowRoot) {
|
|
2637
|
-
const
|
|
2637
|
+
const x = w.left + w.width / 2, P = w.top + w.height / 2;
|
|
2638
2638
|
try {
|
|
2639
|
-
const k = _.elementFromPoint(
|
|
2639
|
+
const k = _.elementFromPoint(x, P);
|
|
2640
2640
|
if (!k) return !1;
|
|
2641
|
-
let
|
|
2642
|
-
for (;
|
|
2643
|
-
if (
|
|
2644
|
-
|
|
2641
|
+
let I = k;
|
|
2642
|
+
for (; I && I !== _; ) {
|
|
2643
|
+
if (I === l) return !0;
|
|
2644
|
+
I = I.parentElement;
|
|
2645
2645
|
}
|
|
2646
2646
|
return !1;
|
|
2647
2647
|
} catch {
|
|
2648
2648
|
return !0;
|
|
2649
2649
|
}
|
|
2650
2650
|
}
|
|
2651
|
-
const
|
|
2651
|
+
const D = 5;
|
|
2652
2652
|
return [
|
|
2653
2653
|
{
|
|
2654
2654
|
x: w.left + w.width / 2,
|
|
2655
2655
|
y: w.top + w.height / 2
|
|
2656
2656
|
},
|
|
2657
2657
|
{
|
|
2658
|
-
x: w.left +
|
|
2659
|
-
y: w.top +
|
|
2658
|
+
x: w.left + D,
|
|
2659
|
+
y: w.top + D
|
|
2660
2660
|
},
|
|
2661
2661
|
{
|
|
2662
|
-
x: w.right -
|
|
2663
|
-
y: w.bottom -
|
|
2662
|
+
x: w.right - D,
|
|
2663
|
+
y: w.bottom - D
|
|
2664
2664
|
}
|
|
2665
|
-
].some(({ x
|
|
2665
|
+
].some(({ x, y: P }) => {
|
|
2666
2666
|
try {
|
|
2667
|
-
const k = document.elementFromPoint(
|
|
2667
|
+
const k = document.elementFromPoint(x, P);
|
|
2668
2668
|
if (!k) return !1;
|
|
2669
|
-
let
|
|
2670
|
-
for (;
|
|
2671
|
-
if (
|
|
2672
|
-
|
|
2669
|
+
let I = k;
|
|
2670
|
+
for (; I && I !== document.documentElement; ) {
|
|
2671
|
+
if (I === l) return !0;
|
|
2672
|
+
I = I.parentElement;
|
|
2673
2673
|
}
|
|
2674
2674
|
return !1;
|
|
2675
2675
|
} catch {
|
|
@@ -2677,19 +2677,19 @@ var dom_tree_default = (t = {
|
|
|
2677
2677
|
}
|
|
2678
2678
|
});
|
|
2679
2679
|
}
|
|
2680
|
-
function
|
|
2680
|
+
function O(l, b) {
|
|
2681
2681
|
if (b === -1) return !0;
|
|
2682
|
-
const
|
|
2683
|
-
if (!
|
|
2684
|
-
const w =
|
|
2682
|
+
const R = l.getClientRects();
|
|
2683
|
+
if (!R || R.length === 0) {
|
|
2684
|
+
const w = g(l);
|
|
2685
2685
|
return !w || w.width === 0 || w.height === 0 ? !1 : !(w.bottom < -b || w.top > window.innerHeight + b || w.right < -b || w.left > window.innerWidth + b);
|
|
2686
2686
|
}
|
|
2687
|
-
for (const w of
|
|
2687
|
+
for (const w of R)
|
|
2688
2688
|
if (!(w.width === 0 || w.height === 0) && !(w.bottom < -b || w.top > window.innerHeight + b || w.right < -b || w.left > window.innerWidth + b))
|
|
2689
2689
|
return !0;
|
|
2690
2690
|
return !1;
|
|
2691
2691
|
}
|
|
2692
|
-
const
|
|
2692
|
+
const F = [
|
|
2693
2693
|
"aria-expanded",
|
|
2694
2694
|
"aria-checked",
|
|
2695
2695
|
"aria-selected",
|
|
@@ -2704,13 +2704,13 @@ var dom_tree_default = (t = {
|
|
|
2704
2704
|
"aria-valuemin",
|
|
2705
2705
|
"aria-autocomplete"
|
|
2706
2706
|
];
|
|
2707
|
-
function B(
|
|
2708
|
-
for (let b = 0; b <
|
|
2707
|
+
function B(l) {
|
|
2708
|
+
for (let b = 0; b < F.length; b++) if (l.hasAttribute(F[b])) return !0;
|
|
2709
2709
|
return !1;
|
|
2710
2710
|
}
|
|
2711
|
-
function
|
|
2712
|
-
if (!
|
|
2713
|
-
const b =
|
|
2711
|
+
function J(l) {
|
|
2712
|
+
if (!l || l.nodeType !== Node.ELEMENT_NODE) return !1;
|
|
2713
|
+
const b = l.tagName.toLowerCase();
|
|
2714
2714
|
return (/* @__PURE__ */ new Set([
|
|
2715
2715
|
"a",
|
|
2716
2716
|
"button",
|
|
@@ -2720,9 +2720,9 @@ var dom_tree_default = (t = {
|
|
|
2720
2720
|
"details",
|
|
2721
2721
|
"summary",
|
|
2722
2722
|
"label"
|
|
2723
|
-
])).has(b) ? !0 :
|
|
2723
|
+
])).has(b) ? !0 : l.hasAttribute("onclick") || l.hasAttribute("role") || l.hasAttribute("tabindex") || B(l) || l.hasAttribute("data-action") || l.getAttribute("contenteditable") === "true";
|
|
2724
2724
|
}
|
|
2725
|
-
const
|
|
2725
|
+
const G = /* @__PURE__ */ new Set([
|
|
2726
2726
|
"a",
|
|
2727
2727
|
"button",
|
|
2728
2728
|
"input",
|
|
@@ -2733,7 +2733,7 @@ var dom_tree_default = (t = {
|
|
|
2733
2733
|
"label",
|
|
2734
2734
|
"option",
|
|
2735
2735
|
"li"
|
|
2736
|
-
]),
|
|
2736
|
+
]), Q = /* @__PURE__ */ new Set([
|
|
2737
2737
|
"button",
|
|
2738
2738
|
"link",
|
|
2739
2739
|
"menuitem",
|
|
@@ -2755,20 +2755,20 @@ var dom_tree_default = (t = {
|
|
|
2755
2755
|
"option",
|
|
2756
2756
|
"scrollbar"
|
|
2757
2757
|
]);
|
|
2758
|
-
function ee(
|
|
2759
|
-
if (!
|
|
2760
|
-
const b =
|
|
2761
|
-
return (
|
|
2762
|
-
}
|
|
2763
|
-
function te(
|
|
2764
|
-
if (!
|
|
2765
|
-
const b =
|
|
2766
|
-
if (b === "iframe" ||
|
|
2758
|
+
function ee(l) {
|
|
2759
|
+
if (!l || l.nodeType !== Node.ELEMENT_NODE || !A(l)) return !1;
|
|
2760
|
+
const b = l.hasAttribute("role") || l.hasAttribute("tabindex") || l.hasAttribute("onclick") || typeof l.onclick == "function", R = /\b(btn|clickable|menu|item|entry|link)\b/i.test(l.className || ""), w = !!l.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'), _ = [...l.children].some(A), D = l.parentElement && l.parentElement.isSameNode(document.body);
|
|
2761
|
+
return (N(l) || b || R) && _ && w && !D;
|
|
2762
|
+
}
|
|
2763
|
+
function te(l) {
|
|
2764
|
+
if (!l || l.nodeType !== Node.ELEMENT_NODE) return !1;
|
|
2765
|
+
const b = l.tagName.toLowerCase(), R = l.getAttribute("role");
|
|
2766
|
+
if (b === "iframe" || G.has(b) || R && Q.has(R) || l.isContentEditable || l.getAttribute("contenteditable") === "true" || l.hasAttribute("data-testid") || l.hasAttribute("data-cy") || l.hasAttribute("data-test") || l.hasAttribute("onclick") || typeof l.onclick == "function" || B(l)) return !0;
|
|
2767
2767
|
try {
|
|
2768
|
-
const w =
|
|
2768
|
+
const w = l?.ownerDocument?.defaultView?.getEventListenersForNode || window.getEventListenersForNode;
|
|
2769
2769
|
if (typeof w == "function") {
|
|
2770
|
-
const _ = w(
|
|
2771
|
-
for (const
|
|
2770
|
+
const _ = w(l);
|
|
2771
|
+
for (const D of [
|
|
2772
2772
|
"click",
|
|
2773
2773
|
"mousedown",
|
|
2774
2774
|
"mouseup",
|
|
@@ -2779,7 +2779,7 @@ var dom_tree_default = (t = {
|
|
|
2779
2779
|
"input",
|
|
2780
2780
|
"focus",
|
|
2781
2781
|
"blur"
|
|
2782
|
-
]) for (const
|
|
2782
|
+
]) for (const x of _) if (x.type === D) return !0;
|
|
2783
2783
|
}
|
|
2784
2784
|
if ([
|
|
2785
2785
|
"onmousedown",
|
|
@@ -2791,119 +2791,119 @@ var dom_tree_default = (t = {
|
|
|
2791
2791
|
"oninput",
|
|
2792
2792
|
"onfocus",
|
|
2793
2793
|
"onblur"
|
|
2794
|
-
].some((_) =>
|
|
2794
|
+
].some((_) => l.hasAttribute(_))) return !0;
|
|
2795
2795
|
} catch {
|
|
2796
2796
|
}
|
|
2797
|
-
return !!(ee(
|
|
2797
|
+
return !!(ee(l) || u.get(l)?.scrollable);
|
|
2798
2798
|
}
|
|
2799
|
-
function
|
|
2800
|
-
if (!
|
|
2799
|
+
function W(l, b, R, w) {
|
|
2800
|
+
if (!l.isInteractive) return !1;
|
|
2801
2801
|
let _ = !1;
|
|
2802
|
-
return w ? te(b) ? _ = !0 : _ = !1 : _ = !0, _ && (
|
|
2802
|
+
return w ? te(b) ? _ = !0 : _ = !1 : _ = !0, _ && (l.isInViewport = O(b, s), (l.isInViewport || s === -1) && (l.highlightIndex = d++, o)) ? (a >= 0 ? a === l.highlightIndex && E(b, l.highlightIndex, R) : E(b, l.highlightIndex, R), !0) : !1;
|
|
2803
2803
|
}
|
|
2804
|
-
function
|
|
2805
|
-
if (!
|
|
2806
|
-
if (
|
|
2807
|
-
const
|
|
2804
|
+
function Z(l, b = null, R = !1) {
|
|
2805
|
+
if (!l || l.id === m || l.nodeType !== Node.ELEMENT_NODE && l.nodeType !== Node.TEXT_NODE || !l || l.id === m || l.dataset?.browserUseIgnore === "true" || l.dataset?.pageAgentIgnore === "true" || l.getAttribute && l.getAttribute("aria-hidden") === "true") return null;
|
|
2806
|
+
if (l === document.body) {
|
|
2807
|
+
const x = {
|
|
2808
2808
|
tagName: "body",
|
|
2809
2809
|
attributes: {},
|
|
2810
2810
|
xpath: "/body",
|
|
2811
2811
|
children: []
|
|
2812
2812
|
};
|
|
2813
|
-
for (const k of
|
|
2814
|
-
const
|
|
2815
|
-
|
|
2813
|
+
for (const k of l.childNodes) {
|
|
2814
|
+
const I = Z(k, b, !1);
|
|
2815
|
+
I && x.children.push(I);
|
|
2816
2816
|
}
|
|
2817
|
-
const P = `${
|
|
2818
|
-
return
|
|
2817
|
+
const P = `${f.current++}`;
|
|
2818
|
+
return C[P] = x, P;
|
|
2819
2819
|
}
|
|
2820
|
-
if (
|
|
2821
|
-
if (
|
|
2822
|
-
const
|
|
2823
|
-
if (!
|
|
2824
|
-
const P =
|
|
2820
|
+
if (l.nodeType !== Node.ELEMENT_NODE && l.nodeType !== Node.TEXT_NODE) return null;
|
|
2821
|
+
if (l.nodeType === Node.TEXT_NODE) {
|
|
2822
|
+
const x = l.textContent?.trim();
|
|
2823
|
+
if (!x) return null;
|
|
2824
|
+
const P = l.parentElement;
|
|
2825
2825
|
if (!P || P.tagName.toLowerCase() === "script") return null;
|
|
2826
|
-
const k = `${
|
|
2827
|
-
return
|
|
2826
|
+
const k = `${f.current++}`;
|
|
2827
|
+
return C[k] = {
|
|
2828
2828
|
type: "TEXT_NODE",
|
|
2829
|
-
text:
|
|
2830
|
-
isVisible:
|
|
2829
|
+
text: x,
|
|
2830
|
+
isVisible: L(l)
|
|
2831
2831
|
}, k;
|
|
2832
2832
|
}
|
|
2833
|
-
if (
|
|
2834
|
-
if (
|
|
2835
|
-
const
|
|
2836
|
-
if (!
|
|
2833
|
+
if (l.nodeType === Node.ELEMENT_NODE && !S(l)) return null;
|
|
2834
|
+
if (s !== -1 && !l.shadowRoot) {
|
|
2835
|
+
const x = g(l), P = y(l), k = P && (P.position === "fixed" || P.position === "sticky"), I = l.offsetWidth > 0 || l.offsetHeight > 0;
|
|
2836
|
+
if (!x || !k && !I && (x.bottom < -s || x.top > window.innerHeight + s || x.right < -s || x.left > window.innerWidth + s)) return null;
|
|
2837
2837
|
}
|
|
2838
2838
|
const w = {
|
|
2839
|
-
tagName:
|
|
2839
|
+
tagName: l.tagName.toLowerCase(),
|
|
2840
2840
|
attributes: {},
|
|
2841
2841
|
/**
|
|
2842
2842
|
* @edit no need for xpath
|
|
2843
2843
|
*/
|
|
2844
2844
|
children: []
|
|
2845
2845
|
};
|
|
2846
|
-
if (
|
|
2847
|
-
const
|
|
2848
|
-
for (const P of
|
|
2849
|
-
const k =
|
|
2846
|
+
if (J(l) || l.tagName.toLowerCase() === "iframe" || l.tagName.toLowerCase() === "body") {
|
|
2847
|
+
const x = l.getAttributeNames?.() || [];
|
|
2848
|
+
for (const P of x) {
|
|
2849
|
+
const k = l.getAttribute(P);
|
|
2850
2850
|
w.attributes[P] = k;
|
|
2851
2851
|
}
|
|
2852
|
-
|
|
2852
|
+
l.tagName.toLowerCase() === "input" && (l.type === "checkbox" || l.type === "radio") && (w.attributes.checked = l.checked ? "true" : "false");
|
|
2853
2853
|
}
|
|
2854
2854
|
let _ = !1;
|
|
2855
|
-
if (
|
|
2856
|
-
w.isTopElement =
|
|
2857
|
-
const
|
|
2858
|
-
if ((w.isTopElement || P) && (w.isInteractive =
|
|
2859
|
-
const k =
|
|
2860
|
-
for (const
|
|
2861
|
-
const Y =
|
|
2862
|
-
w.attributes[
|
|
2855
|
+
if (l.nodeType === Node.ELEMENT_NODE && (w.isVisible = A(l), w.isVisible)) {
|
|
2856
|
+
w.isTopElement = M(l);
|
|
2857
|
+
const x = l.getAttribute("role"), P = x === "menu" || x === "menubar" || x === "listbox";
|
|
2858
|
+
if ((w.isTopElement || P) && (w.isInteractive = N(l), _ = W(w, l, b, R), w.ref = l, w.isInteractive && Object.keys(w.attributes).length === 0)) {
|
|
2859
|
+
const k = l.getAttributeNames?.() || [];
|
|
2860
|
+
for (const I of k) {
|
|
2861
|
+
const Y = l.getAttribute(I);
|
|
2862
|
+
w.attributes[I] = Y;
|
|
2863
2863
|
}
|
|
2864
2864
|
}
|
|
2865
2865
|
}
|
|
2866
|
-
if (
|
|
2867
|
-
const
|
|
2868
|
-
if (
|
|
2869
|
-
const P =
|
|
2866
|
+
if (l.tagName) {
|
|
2867
|
+
const x = l.tagName.toLowerCase();
|
|
2868
|
+
if (x === "iframe") try {
|
|
2869
|
+
const P = l.contentDocument || l.contentWindow?.document;
|
|
2870
2870
|
if (P) for (const k of P.childNodes) {
|
|
2871
|
-
const
|
|
2872
|
-
|
|
2871
|
+
const I = Z(k, l, !1);
|
|
2872
|
+
I && w.children.push(I);
|
|
2873
2873
|
}
|
|
2874
2874
|
} catch (P) {
|
|
2875
2875
|
console.warn("Unable to access iframe:", P);
|
|
2876
2876
|
}
|
|
2877
|
-
else if (
|
|
2878
|
-
const k =
|
|
2877
|
+
else if (l.isContentEditable || l.getAttribute("contenteditable") === "true" || l.id === "tinymce" || l.classList.contains("mce-content-body") || x === "body" && l.getAttribute("data-id")?.startsWith("mce_")) for (const P of l.childNodes) {
|
|
2878
|
+
const k = Z(P, b, _);
|
|
2879
2879
|
k && w.children.push(k);
|
|
2880
2880
|
}
|
|
2881
2881
|
else {
|
|
2882
|
-
if (
|
|
2882
|
+
if (l.shadowRoot) {
|
|
2883
2883
|
w.shadowRoot = !0;
|
|
2884
|
-
for (const P of
|
|
2885
|
-
const k =
|
|
2884
|
+
for (const P of l.shadowRoot.childNodes) {
|
|
2885
|
+
const k = Z(P, b, _);
|
|
2886
2886
|
k && w.children.push(k);
|
|
2887
2887
|
}
|
|
2888
2888
|
}
|
|
2889
|
-
for (const P of
|
|
2890
|
-
const k =
|
|
2889
|
+
for (const P of l.childNodes) {
|
|
2890
|
+
const k = Z(P, b, _ || R);
|
|
2891
2891
|
k && w.children.push(k);
|
|
2892
2892
|
}
|
|
2893
2893
|
}
|
|
2894
2894
|
}
|
|
2895
2895
|
if (w.tagName === "a" && w.children.length === 0 && !w.attributes.href) {
|
|
2896
|
-
const
|
|
2897
|
-
if (!(
|
|
2896
|
+
const x = g(l);
|
|
2897
|
+
if (!(x && x.width > 0 && x.height > 0 || l.offsetWidth > 0 || l.offsetHeight > 0)) return null;
|
|
2898
2898
|
}
|
|
2899
|
-
w.extra =
|
|
2900
|
-
const
|
|
2901
|
-
return
|
|
2899
|
+
w.extra = u.get(l) || null;
|
|
2900
|
+
const D = `${f.current++}`;
|
|
2901
|
+
return C[D] = w, D;
|
|
2902
2902
|
}
|
|
2903
|
-
const ce =
|
|
2904
|
-
return
|
|
2903
|
+
const ce = Z(document.body);
|
|
2904
|
+
return h.clearCache(), {
|
|
2905
2905
|
rootId: ce,
|
|
2906
|
-
map:
|
|
2906
|
+
map: C
|
|
2907
2907
|
};
|
|
2908
2908
|
}, DEFAULT_VIEWPORT_EXPANSION = -1;
|
|
2909
2909
|
function resolveViewportExpansion(t) {
|
|
@@ -2933,10 +2933,10 @@ function getFlatTree(t) {
|
|
|
2933
2933
|
highlightLabelOpacity: t.highlightLabelOpacity ?? 0.1
|
|
2934
2934
|
}), o = window.location.href;
|
|
2935
2935
|
for (const a in r.map) {
|
|
2936
|
-
const
|
|
2937
|
-
if (
|
|
2938
|
-
const c =
|
|
2939
|
-
newElementsCache.has(c) || (newElementsCache.set(c, o),
|
|
2936
|
+
const s = r.map[a];
|
|
2937
|
+
if (s.isInteractive && s.ref) {
|
|
2938
|
+
const c = s.ref;
|
|
2939
|
+
newElementsCache.has(c) || (newElementsCache.set(c, o), s.isNew = !0);
|
|
2940
2940
|
}
|
|
2941
2941
|
}
|
|
2942
2942
|
return r;
|
|
@@ -2983,99 +2983,99 @@ function flatTreeToString(t, e = [], n = !1) {
|
|
|
2983
2983
|
"aria-controls",
|
|
2984
2984
|
"aria-owns",
|
|
2985
2985
|
"contenteditable"
|
|
2986
|
-
], r = [...e, ...i], o = (
|
|
2987
|
-
const
|
|
2988
|
-
if (!
|
|
2989
|
-
if (
|
|
2990
|
-
const
|
|
2986
|
+
], r = [...e, ...i], o = (h, g) => h.length > g ? h.substring(0, g) + "..." : h, a = (h) => {
|
|
2987
|
+
const g = t.map[h];
|
|
2988
|
+
if (!g) return null;
|
|
2989
|
+
if (g.type === "TEXT_NODE") {
|
|
2990
|
+
const y = g;
|
|
2991
2991
|
return {
|
|
2992
2992
|
type: "text",
|
|
2993
|
-
text:
|
|
2994
|
-
isVisible:
|
|
2993
|
+
text: y.text,
|
|
2994
|
+
isVisible: y.isVisible,
|
|
2995
2995
|
parent: null,
|
|
2996
2996
|
children: []
|
|
2997
2997
|
};
|
|
2998
2998
|
} else {
|
|
2999
|
-
const
|
|
3000
|
-
if (
|
|
3001
|
-
const
|
|
3002
|
-
|
|
2999
|
+
const y = g, T = [];
|
|
3000
|
+
if (y.children) for (const C of y.children) {
|
|
3001
|
+
const f = a(C);
|
|
3002
|
+
f && (f.parent = null, T.push(f));
|
|
3003
3003
|
}
|
|
3004
3004
|
return {
|
|
3005
3005
|
type: "element",
|
|
3006
|
-
tagName:
|
|
3007
|
-
attributes:
|
|
3008
|
-
isVisible:
|
|
3009
|
-
isInteractive:
|
|
3010
|
-
isTopElement:
|
|
3011
|
-
isNew:
|
|
3012
|
-
highlightIndex:
|
|
3006
|
+
tagName: y.tagName,
|
|
3007
|
+
attributes: y.attributes ?? {},
|
|
3008
|
+
isVisible: y.isVisible ?? !1,
|
|
3009
|
+
isInteractive: y.isInteractive ?? !1,
|
|
3010
|
+
isTopElement: y.isTopElement ?? !1,
|
|
3011
|
+
isNew: y.isNew ?? !1,
|
|
3012
|
+
highlightIndex: y.highlightIndex,
|
|
3013
3013
|
parent: null,
|
|
3014
|
-
children:
|
|
3015
|
-
extra:
|
|
3014
|
+
children: T,
|
|
3015
|
+
extra: y.extra ?? {}
|
|
3016
3016
|
};
|
|
3017
3017
|
}
|
|
3018
|
-
},
|
|
3019
|
-
|
|
3020
|
-
for (const
|
|
3018
|
+
}, s = (h, g = null) => {
|
|
3019
|
+
h.parent = g;
|
|
3020
|
+
for (const y of h.children) s(y, h);
|
|
3021
3021
|
}, c = a(t.rootId);
|
|
3022
3022
|
if (!c) return "";
|
|
3023
|
-
|
|
3024
|
-
const
|
|
3025
|
-
let
|
|
3026
|
-
for (;
|
|
3027
|
-
if (
|
|
3028
|
-
|
|
3023
|
+
s(c);
|
|
3024
|
+
const d = (h) => {
|
|
3025
|
+
let g = h.parent;
|
|
3026
|
+
for (; g; ) {
|
|
3027
|
+
if (g.type === "element" && g.highlightIndex !== void 0) return !0;
|
|
3028
|
+
g = g.parent;
|
|
3029
3029
|
}
|
|
3030
3030
|
return !1;
|
|
3031
|
-
},
|
|
3032
|
-
let
|
|
3033
|
-
const
|
|
3034
|
-
if (
|
|
3035
|
-
const
|
|
3036
|
-
if (
|
|
3037
|
-
|
|
3038
|
-
const
|
|
3039
|
-
let
|
|
3040
|
-
if (r.length > 0 &&
|
|
3041
|
-
const
|
|
3042
|
-
if (
|
|
3043
|
-
const
|
|
3044
|
-
for (const
|
|
3045
|
-
const B =
|
|
3046
|
-
B.length > 5 && (B in
|
|
3031
|
+
}, u = (h, g, y) => {
|
|
3032
|
+
let T = g;
|
|
3033
|
+
const C = " ".repeat(g);
|
|
3034
|
+
if (h.type === "element") {
|
|
3035
|
+
const f = n && h.tagName && SEMANTIC_TAGS.has(h.tagName);
|
|
3036
|
+
if (h.highlightIndex !== void 0) {
|
|
3037
|
+
T += 1;
|
|
3038
|
+
const v = getAllTextTillNextClickableElement(h);
|
|
3039
|
+
let L = "";
|
|
3040
|
+
if (r.length > 0 && h.attributes) {
|
|
3041
|
+
const A = matchAttributes(h.attributes, r), N = Object.keys(A);
|
|
3042
|
+
if (N.length > 1) {
|
|
3043
|
+
const M = /* @__PURE__ */ new Set(), O = {};
|
|
3044
|
+
for (const F of N) {
|
|
3045
|
+
const B = A[F];
|
|
3046
|
+
B.length > 5 && (B in O ? M.add(F) : O[B] = F);
|
|
3047
3047
|
}
|
|
3048
|
-
for (const
|
|
3048
|
+
for (const F of M) delete A[F];
|
|
3049
3049
|
}
|
|
3050
|
-
|
|
3051
|
-
for (const
|
|
3050
|
+
A.role === h.tagName && delete A.role;
|
|
3051
|
+
for (const M of [
|
|
3052
3052
|
"aria-label",
|
|
3053
3053
|
"placeholder",
|
|
3054
3054
|
"title"
|
|
3055
|
-
])
|
|
3056
|
-
Object.keys(
|
|
3055
|
+
]) A[M] && A[M].toLowerCase().trim() === v.toLowerCase().trim() && delete A[M];
|
|
3056
|
+
Object.keys(A).length > 0 && (L = Object.entries(A).map(([M, O]) => `${M}=${o(O, 20)}`).join(" "));
|
|
3057
3057
|
}
|
|
3058
|
-
let
|
|
3059
|
-
if (
|
|
3060
|
-
let
|
|
3061
|
-
|
|
3058
|
+
let S = `${C}${h.isNew ? `*[${h.highlightIndex}]` : `[${h.highlightIndex}]`}<${h.tagName ?? ""}`;
|
|
3059
|
+
if (L && (S += ` ${L}`), h.extra && h.extra.scrollable) {
|
|
3060
|
+
let A = "";
|
|
3061
|
+
h.extra.scrollData?.left && (A += `left=${h.extra.scrollData.left}, `), h.extra.scrollData?.top && (A += `top=${h.extra.scrollData.top}, `), h.extra.scrollData?.right && (A += `right=${h.extra.scrollData.right}, `), h.extra.scrollData?.bottom && (A += `bottom=${h.extra.scrollData.bottom}`), S += ` data-scrollable="${A}"`;
|
|
3062
3062
|
}
|
|
3063
|
-
if (
|
|
3064
|
-
const
|
|
3065
|
-
|
|
3066
|
-
} else
|
|
3067
|
-
|
|
3063
|
+
if (v) {
|
|
3064
|
+
const A = v.trim();
|
|
3065
|
+
L || (S += " "), S += `>${A}`;
|
|
3066
|
+
} else L || (S += " ");
|
|
3067
|
+
S += " />", y.push(S);
|
|
3068
3068
|
}
|
|
3069
|
-
const
|
|
3070
|
-
|
|
3071
|
-
for (const
|
|
3072
|
-
|
|
3073
|
-
} else if (
|
|
3074
|
-
if (
|
|
3075
|
-
|
|
3069
|
+
const m = f && h.highlightIndex === void 0, E = m ? y.length : -1;
|
|
3070
|
+
m && (y.push(`${C}<${h.tagName}>`), T += 1);
|
|
3071
|
+
for (const v of h.children) u(v, T, y);
|
|
3072
|
+
m && (y.length === E + 1 ? y.pop() : y.push(`${C}</${h.tagName}>`));
|
|
3073
|
+
} else if (h.type === "text") {
|
|
3074
|
+
if (d(h)) return;
|
|
3075
|
+
h.parent && h.parent.type === "element" && h.parent.isVisible && h.parent.isTopElement && y.push(`${C}${h.text ?? ""}`);
|
|
3076
3076
|
}
|
|
3077
3077
|
}, p = [];
|
|
3078
|
-
return
|
|
3078
|
+
return u(c, 0, p), p.join(`
|
|
3079
3079
|
`);
|
|
3080
3080
|
}
|
|
3081
3081
|
var getAllTextTillNextClickableElement = (t, e = -1) => {
|
|
@@ -3133,7 +3133,7 @@ else {
|
|
|
3133
3133
|
}, 500);
|
|
3134
3134
|
}
|
|
3135
3135
|
function getPageInfo() {
|
|
3136
|
-
const t = window.innerWidth, e = window.innerHeight, n = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth || 0), i = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight || 0), r = window.scrollX || window.pageXOffset || document.documentElement.scrollLeft || 0, o = window.scrollY || window.pageYOffset || document.documentElement.scrollTop || 0, a = Math.max(0, i - (window.innerHeight + o)),
|
|
3136
|
+
const t = window.innerWidth, e = window.innerHeight, n = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth || 0), i = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight || 0), r = window.scrollX || window.pageXOffset || document.documentElement.scrollLeft || 0, o = window.scrollY || window.pageYOffset || document.documentElement.scrollTop || 0, a = Math.max(0, i - (window.innerHeight + o)), s = Math.max(0, n - (window.innerWidth + r));
|
|
3137
3137
|
return {
|
|
3138
3138
|
viewport_width: t,
|
|
3139
3139
|
viewport_height: e,
|
|
@@ -3148,7 +3148,7 @@ function getPageInfo() {
|
|
|
3148
3148
|
total_pages: e > 0 ? i / e : 0,
|
|
3149
3149
|
current_page_position: o / Math.max(1, i - e),
|
|
3150
3150
|
pixels_left: r,
|
|
3151
|
-
pixels_right:
|
|
3151
|
+
pixels_right: s
|
|
3152
3152
|
};
|
|
3153
3153
|
}
|
|
3154
3154
|
function patchReact(t) {
|
|
@@ -3186,7 +3186,7 @@ var PageController = class extends EventTarget {
|
|
|
3186
3186
|
*/
|
|
3187
3187
|
initMask() {
|
|
3188
3188
|
this.maskReady === null && (this.maskReady = (async () => {
|
|
3189
|
-
const { SimulatorMask: t } = await import("./SimulatorMask-BHVXyogh-
|
|
3189
|
+
const { SimulatorMask: t } = await import("./SimulatorMask-BHVXyogh-CARX3Rff.js");
|
|
3190
3190
|
this.mask = new t();
|
|
3191
3191
|
})());
|
|
3192
3192
|
}
|
|
@@ -3380,7 +3380,7 @@ ${n.pixels_above > 4 && i !== -1 ? `... ${n.pixels_above} pixels above (${n.page
|
|
|
3380
3380
|
cleanUpHighlights(), this.flatTree = null, this.selectorMap.clear(), this.elementTextMap.clear(), this.simplifiedHTML = "<EMPTY>", this.isIndexed = !1, this.mask?.dispose(), this.mask = null;
|
|
3381
3381
|
}
|
|
3382
3382
|
};
|
|
3383
|
-
const DEFAULT_ERROR_SELECTORS
|
|
3383
|
+
const DEFAULT_ERROR_SELECTORS = [
|
|
3384
3384
|
'[role="alert"]',
|
|
3385
3385
|
'[aria-invalid="true"]',
|
|
3386
3386
|
".ti3-unifyvalid-error",
|
|
@@ -3410,6 +3410,24 @@ const DEFAULT_ERROR_SELECTORS$1 = [
|
|
|
3410
3410
|
".warning-text",
|
|
3411
3411
|
".is-warning",
|
|
3412
3412
|
".has-warning"
|
|
3413
|
+
], DEFAULT_DIALOG_SELECTORS = [
|
|
3414
|
+
// W3C ARIA 标准
|
|
3415
|
+
'[role="dialog"]',
|
|
3416
|
+
'[role="alertdialog"]',
|
|
3417
|
+
// Tiny3 / Lego(云控制台)
|
|
3418
|
+
'[class*="ti3-modal"]',
|
|
3419
|
+
'[class*="ti3-message-box"]',
|
|
3420
|
+
// Element UI / Element Plus
|
|
3421
|
+
'[class*="el-dialog"]',
|
|
3422
|
+
'[class*="el-message-box"]',
|
|
3423
|
+
// Ant Design
|
|
3424
|
+
'[class*="ant-modal"]',
|
|
3425
|
+
// Bootstrap
|
|
3426
|
+
'[class*="modal-content"]',
|
|
3427
|
+
// Vuetify
|
|
3428
|
+
'[class*="v-dialog"]',
|
|
3429
|
+
// Naive UI
|
|
3430
|
+
'[class*="n-modal"]'
|
|
3413
3431
|
], TAG_ROLE_MAP = {
|
|
3414
3432
|
a: "link",
|
|
3415
3433
|
article: "article",
|
|
@@ -3488,7 +3506,210 @@ const DEFAULT_ERROR_SELECTORS$1 = [
|
|
|
3488
3506
|
tel: "textbox",
|
|
3489
3507
|
text: "textbox",
|
|
3490
3508
|
url: "textbox"
|
|
3491
|
-
};
|
|
3509
|
+
}, RESOLVED_A11Y_BRAND = Symbol.for("@opentiny/next-sdk:ResolvedA11yConfig");
|
|
3510
|
+
function markResolved(t) {
|
|
3511
|
+
return Object.assign(t, { [RESOLVED_A11Y_BRAND]: !0 });
|
|
3512
|
+
}
|
|
3513
|
+
function isResolvedA11yConfig(t) {
|
|
3514
|
+
return !!t && t[RESOLVED_A11Y_BRAND] === !0;
|
|
3515
|
+
}
|
|
3516
|
+
const STANDARD_STATE_NAMES = [
|
|
3517
|
+
"checked",
|
|
3518
|
+
"selected",
|
|
3519
|
+
"pressed",
|
|
3520
|
+
"current",
|
|
3521
|
+
"expanded",
|
|
3522
|
+
"hasPopup",
|
|
3523
|
+
"disabled",
|
|
3524
|
+
"readonly",
|
|
3525
|
+
"required",
|
|
3526
|
+
"invalid",
|
|
3527
|
+
"busy",
|
|
3528
|
+
"error",
|
|
3529
|
+
"warning"
|
|
3530
|
+
], DEFAULT_SELECTED_CLASS_RE = /\b(is-active|isActive|is-selected|isSelected|is-current|isCurrent|active-item|activeItem|tab-active|tabActive|active|selected|current)\b/;
|
|
3531
|
+
function defaultSelectedMatch(t) {
|
|
3532
|
+
const e = typeof t.className == "string" ? t.className : "";
|
|
3533
|
+
if (!e || !DEFAULT_SELECTED_CLASS_RE.test(e)) return !1;
|
|
3534
|
+
const n = t.getAttribute("role") || t.tagName.toLowerCase();
|
|
3535
|
+
return ["button", "option", "a", "li", "generic"].includes(n) || n.startsWith("tab");
|
|
3536
|
+
}
|
|
3537
|
+
const DEFAULT_A11Y_CONFIG = markResolved({
|
|
3538
|
+
roles: [],
|
|
3539
|
+
states: {
|
|
3540
|
+
selected: [
|
|
3541
|
+
{ match: defaultSelectedMatch },
|
|
3542
|
+
// Tiny3 按钮组/单选按钮组:选中 class 在容器上(.ti3-btn-item-container.ti3-active),
|
|
3543
|
+
// 内部 button 自身无 aria-selected / ti3-active,需靠 closest 命中
|
|
3544
|
+
{ selector: ".ti3-btn-item-container.ti3-active" }
|
|
3545
|
+
],
|
|
3546
|
+
error: [{ selector: DEFAULT_ERROR_SELECTORS }],
|
|
3547
|
+
warning: [{ selector: DEFAULT_WARNING_SELECTORS }]
|
|
3548
|
+
},
|
|
3549
|
+
whitelist: [],
|
|
3550
|
+
blacklist: [],
|
|
3551
|
+
exposedAttributes: [],
|
|
3552
|
+
dialogSelectors: DEFAULT_DIALOG_SELECTORS
|
|
3553
|
+
});
|
|
3554
|
+
function normalizeSelector(t) {
|
|
3555
|
+
return t && (Array.isArray(t) ? t.filter(Boolean).join(", ") : t) || void 0;
|
|
3556
|
+
}
|
|
3557
|
+
function matchesRule(t, e) {
|
|
3558
|
+
if (e.match)
|
|
3559
|
+
try {
|
|
3560
|
+
return !!e.match(t);
|
|
3561
|
+
} catch {
|
|
3562
|
+
return !1;
|
|
3563
|
+
}
|
|
3564
|
+
const n = normalizeSelector(e.selector);
|
|
3565
|
+
if (n)
|
|
3566
|
+
try {
|
|
3567
|
+
return !!t.closest(n);
|
|
3568
|
+
} catch {
|
|
3569
|
+
return !1;
|
|
3570
|
+
}
|
|
3571
|
+
return !1;
|
|
3572
|
+
}
|
|
3573
|
+
function matchesRoleRule(t, e) {
|
|
3574
|
+
if (e.match)
|
|
3575
|
+
try {
|
|
3576
|
+
return !!e.match(t);
|
|
3577
|
+
} catch {
|
|
3578
|
+
return !1;
|
|
3579
|
+
}
|
|
3580
|
+
const n = normalizeSelector(e.selector);
|
|
3581
|
+
if (n)
|
|
3582
|
+
try {
|
|
3583
|
+
return !!t.matches(n);
|
|
3584
|
+
} catch {
|
|
3585
|
+
return !1;
|
|
3586
|
+
}
|
|
3587
|
+
return !1;
|
|
3588
|
+
}
|
|
3589
|
+
function matchesAnyRule(t, e) {
|
|
3590
|
+
return e ? (Array.isArray(e) ? e : [e]).some((i) => matchesRule(t, i)) : !1;
|
|
3591
|
+
}
|
|
3592
|
+
function extractSelectors(t) {
|
|
3593
|
+
return t ? (Array.isArray(t) ? t : [t]).flatMap((n) => Array.isArray(n.selector) ? n.selector.filter(Boolean) : n.selector ? [n.selector] : []) : [];
|
|
3594
|
+
}
|
|
3595
|
+
function concatArr(t, e) {
|
|
3596
|
+
return [...t ?? [], ...e ?? []];
|
|
3597
|
+
}
|
|
3598
|
+
function normalizeMatcherList(t) {
|
|
3599
|
+
return t ? Array.isArray(t) ? t : [t] : [];
|
|
3600
|
+
}
|
|
3601
|
+
function mergeStates(t, e) {
|
|
3602
|
+
const n = {}, i = /* @__PURE__ */ new Set([...Object.keys(t ?? {}), ...Object.keys(e ?? {})]);
|
|
3603
|
+
for (const r of i)
|
|
3604
|
+
n[r] = [...normalizeMatcherList(t?.[r]), ...normalizeMatcherList(e?.[r])];
|
|
3605
|
+
return n;
|
|
3606
|
+
}
|
|
3607
|
+
function mergeA11yConfigs(t, e) {
|
|
3608
|
+
return markResolved({
|
|
3609
|
+
roles: concatArr(t.roles, e.roles),
|
|
3610
|
+
states: mergeStates(t.states, e.states),
|
|
3611
|
+
whitelist: concatArr(t.whitelist, e.whitelist),
|
|
3612
|
+
blacklist: concatArr(t.blacklist, e.blacklist),
|
|
3613
|
+
exposedAttributes: concatArr(t.exposedAttributes, e.exposedAttributes),
|
|
3614
|
+
dialogSelectors: concatArr(t.dialogSelectors, e.dialogSelectors)
|
|
3615
|
+
});
|
|
3616
|
+
}
|
|
3617
|
+
function mergeA11yConfig(t) {
|
|
3618
|
+
return isResolvedA11yConfig(t) ? t : mergeA11yConfigs(DEFAULT_A11Y_CONFIG, t ?? {});
|
|
3619
|
+
}
|
|
3620
|
+
function ensureResolvedA11yConfig(t) {
|
|
3621
|
+
return isResolvedA11yConfig(t) ? t : mergeA11yConfig(t);
|
|
3622
|
+
}
|
|
3623
|
+
function defineA11yConfig(t) {
|
|
3624
|
+
return t;
|
|
3625
|
+
}
|
|
3626
|
+
function computeRole(t, e) {
|
|
3627
|
+
const n = t.getAttribute("role"), i = !!n && n !== "presentation" && n !== "none";
|
|
3628
|
+
for (const o of e.roles)
|
|
3629
|
+
if (!(i && !o.force) && matchesRoleRule(t, o))
|
|
3630
|
+
return o.role;
|
|
3631
|
+
if (i) return n;
|
|
3632
|
+
const r = t.tagName.toLowerCase();
|
|
3633
|
+
if (r === "input") {
|
|
3634
|
+
const o = t.type?.toLowerCase() ?? "text";
|
|
3635
|
+
return INPUT_TYPE_ROLE[o] ?? "textbox";
|
|
3636
|
+
}
|
|
3637
|
+
return TAG_ROLE_MAP[r] ?? "generic";
|
|
3638
|
+
}
|
|
3639
|
+
function computeStates(t, e) {
|
|
3640
|
+
const n = [], i = (m) => t.getAttribute(m), r = e.states, o = (m) => matchesAnyRule(t, r[m]), a = i("aria-checked");
|
|
3641
|
+
if (a === "true")
|
|
3642
|
+
n.push("checked");
|
|
3643
|
+
else if (a === "mixed")
|
|
3644
|
+
n.push("checked=mixed");
|
|
3645
|
+
else if (a === "false")
|
|
3646
|
+
n.push("unchecked");
|
|
3647
|
+
else {
|
|
3648
|
+
const m = t.tagName.toLowerCase();
|
|
3649
|
+
let E;
|
|
3650
|
+
if (m === "input" && (t.type === "checkbox" || t.type === "radio"))
|
|
3651
|
+
E = t.checked;
|
|
3652
|
+
else if (m === "label" && t.hasAttribute("for")) {
|
|
3653
|
+
const v = document.getElementById(t.getAttribute("for"));
|
|
3654
|
+
v instanceof HTMLInputElement && (v.type === "checkbox" || v.type === "radio") && (E = v.checked);
|
|
3655
|
+
}
|
|
3656
|
+
E !== void 0 ? n.push(E ? "checked" : "unchecked") : o("checked") && n.push("checked");
|
|
3657
|
+
}
|
|
3658
|
+
(i("aria-selected") === "true" || o("selected")) && n.push("selected");
|
|
3659
|
+
const s = i("aria-pressed");
|
|
3660
|
+
s === "true" ? n.push("pressed") : s === "mixed" ? n.push("pressed=mixed") : s !== "false" && o("pressed") && n.push("pressed");
|
|
3661
|
+
const c = i("aria-current");
|
|
3662
|
+
c && c !== "false" ? n.push(c === "true" ? "current" : `current=${c}`) : o("current") && n.push("current"), (i("aria-disabled") === "true" || t.disabled || o("disabled")) && n.push("disabled");
|
|
3663
|
+
const d = i("aria-haspopup");
|
|
3664
|
+
(d && d !== "false" || o("hasPopup")) && n.push("hasPopup"), (i("aria-expanded") === "true" || o("expanded")) && n.push("expanded");
|
|
3665
|
+
const u = i("aria-invalid");
|
|
3666
|
+
u && u !== "false" ? n.push(u === "true" ? "invalid" : `invalid=${u}`) : o("invalid") && n.push("invalid"), (i("aria-readonly") === "true" || t.readOnly || o("readonly")) && n.push("readonly"), (i("aria-required") === "true" || t.required || o("required")) && n.push("required"), (i("aria-busy") === "true" || o("busy")) && n.push("busy");
|
|
3667
|
+
const p = i("aria-orientation");
|
|
3668
|
+
p && n.push(`orientation=${p}`);
|
|
3669
|
+
const h = i("aria-sort");
|
|
3670
|
+
h && h !== "none" && n.push(`sort=${h}`), i("aria-multiselectable") === "true" && n.push("multiselectable");
|
|
3671
|
+
const g = t.tagName.match(/^H([1-6])$/);
|
|
3672
|
+
g && n.push(`level=${g[1]}`);
|
|
3673
|
+
const y = i("aria-level");
|
|
3674
|
+
y && !g && n.push(`level=${y}`);
|
|
3675
|
+
try {
|
|
3676
|
+
window.getComputedStyle(t).cursor === "pointer" && n.push("cursor=pointer");
|
|
3677
|
+
} catch {
|
|
3678
|
+
}
|
|
3679
|
+
const T = t.tagName.toLowerCase();
|
|
3680
|
+
if (T === "input" || T === "textarea" || T === "select") {
|
|
3681
|
+
const m = t.value;
|
|
3682
|
+
m !== void 0 && m !== "" && n.push(`value="${m}"`);
|
|
3683
|
+
}
|
|
3684
|
+
const C = i("aria-valuenow");
|
|
3685
|
+
C && n.push(`valuenow="${C}"`);
|
|
3686
|
+
const f = i("aria-valuetext");
|
|
3687
|
+
if (f && n.push(`valuetext="${f}"`), T === "a") {
|
|
3688
|
+
const m = i("target");
|
|
3689
|
+
m && n.push(`target=${m}`);
|
|
3690
|
+
}
|
|
3691
|
+
o("error") ? n.push("error") : o("warning") && n.push("warning");
|
|
3692
|
+
for (const m of Object.keys(r))
|
|
3693
|
+
STANDARD_STATE_NAMES.includes(m) || matchesAnyRule(t, r[m]) && n.push(m);
|
|
3694
|
+
for (const m of e.exposedAttributes) {
|
|
3695
|
+
const E = t.getAttribute(m);
|
|
3696
|
+
E !== null && n.push(`${m}="${E}"`);
|
|
3697
|
+
}
|
|
3698
|
+
return Array.from(new Set(n));
|
|
3699
|
+
}
|
|
3700
|
+
function resolveA11yRole(t, e) {
|
|
3701
|
+
return computeRole(t, ensureResolvedA11yConfig(e));
|
|
3702
|
+
}
|
|
3703
|
+
function resolveA11yStates(t, e) {
|
|
3704
|
+
return computeStates(t, ensureResolvedA11yConfig(e));
|
|
3705
|
+
}
|
|
3706
|
+
function resolveA11yInfo(t, e) {
|
|
3707
|
+
const n = ensureResolvedA11yConfig(e);
|
|
3708
|
+
return {
|
|
3709
|
+
role: computeRole(t, n),
|
|
3710
|
+
tokens: computeStates(t, n)
|
|
3711
|
+
};
|
|
3712
|
+
}
|
|
3492
3713
|
var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([inert]):not([inert] *)", "textarea:not([inert]):not([inert] *)", "a[href]:not([inert]):not([inert] *)", "area[href]:not([inert]):not([inert] *)", "button:not([inert]):not([inert] *)", "[tabindex]:not(slot):not([inert]):not([inert] *)", "audio[controls]:not([inert]):not([inert] *)", "video[controls]:not([inert]):not([inert] *)", '[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)', "details>summary:first-of-type:not([inert]):not([inert] *)", "details:not([inert]):not([inert] *)"], candidateSelector = /* @__PURE__ */ candidateSelectors.join(","), NoElement = typeof Element > "u", matches = NoElement ? function() {
|
|
3493
3714
|
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, getRootNode = !NoElement && Element.prototype.getRootNode ? function(t) {
|
|
3494
3715
|
var e;
|
|
@@ -3520,8 +3741,8 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
|
|
|
3520
3741
|
}, isTabbableRadio = function t(e) {
|
|
3521
3742
|
if (!e.name)
|
|
3522
3743
|
return !0;
|
|
3523
|
-
var n = e.form || getRootNode(e), i = function(
|
|
3524
|
-
return n.querySelectorAll('input[type="radio"][name="' +
|
|
3744
|
+
var n = e.form || getRootNode(e), i = function(s) {
|
|
3745
|
+
return n.querySelectorAll('input[type="radio"][name="' + s + '"]');
|
|
3525
3746
|
}, r;
|
|
3526
3747
|
if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
|
|
3527
3748
|
r = i(window.CSS.escape(e.name));
|
|
@@ -3540,10 +3761,10 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
|
|
|
3540
3761
|
}, isNodeAttached = function t(e) {
|
|
3541
3762
|
var n, i = e && getRootNode(e), r = (n = i) === null || n === void 0 ? void 0 : n.host, o = !1;
|
|
3542
3763
|
if (i && i !== e) {
|
|
3543
|
-
var a,
|
|
3544
|
-
for (o = !!((a = r) !== null && a !== void 0 && (
|
|
3545
|
-
var
|
|
3546
|
-
i = getRootNode(r), r = (
|
|
3764
|
+
var a, s, c;
|
|
3765
|
+
for (o = !!((a = r) !== null && a !== void 0 && (s = a.ownerDocument) !== null && s !== void 0 && s.contains(r) || e != null && (c = e.ownerDocument) !== null && c !== void 0 && c.contains(e)); !o && r; ) {
|
|
3766
|
+
var d, u, p;
|
|
3767
|
+
i = getRootNode(r), r = (d = i) === null || d === void 0 ? void 0 : d.host, o = !!((u = r) !== null && u !== void 0 && (p = u.ownerDocument) !== null && p !== void 0 && p.contains(r));
|
|
3547
3768
|
}
|
|
3548
3769
|
}
|
|
3549
3770
|
return o;
|
|
@@ -3568,23 +3789,23 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
|
|
|
3568
3789
|
});
|
|
3569
3790
|
return !o;
|
|
3570
3791
|
}
|
|
3571
|
-
var a = getComputedStyle(e),
|
|
3572
|
-
if (
|
|
3792
|
+
var a = getComputedStyle(e), s = a.visibility;
|
|
3793
|
+
if (s === "hidden" || s === "collapse")
|
|
3573
3794
|
return !0;
|
|
3574
|
-
var c = matches.call(e, "details>summary:first-of-type"),
|
|
3575
|
-
if (matches.call(
|
|
3795
|
+
var c = matches.call(e, "details>summary:first-of-type"), d = c ? e.parentElement : e;
|
|
3796
|
+
if (matches.call(d, "details:not([open]) *"))
|
|
3576
3797
|
return !0;
|
|
3577
3798
|
if (!i || i === "full" || // full-native can run this branch when it falls through in case
|
|
3578
3799
|
// Element#checkVisibility is unsupported
|
|
3579
3800
|
i === "full-native" || i === "legacy-full") {
|
|
3580
3801
|
if (typeof r == "function") {
|
|
3581
|
-
for (var
|
|
3582
|
-
var p = e.parentElement,
|
|
3802
|
+
for (var u = e; e; ) {
|
|
3803
|
+
var p = e.parentElement, h = getRootNode(e);
|
|
3583
3804
|
if (p && !p.shadowRoot && r(p) === !0)
|
|
3584
3805
|
return isZeroArea(e);
|
|
3585
|
-
e.assignedSlot ? e = e.assignedSlot : !p &&
|
|
3806
|
+
e.assignedSlot ? e = e.assignedSlot : !p && h !== e.ownerDocument ? e = h.host : e = p;
|
|
3586
3807
|
}
|
|
3587
|
-
e =
|
|
3808
|
+
e = u;
|
|
3588
3809
|
}
|
|
3589
3810
|
if (isNodeAttached(e))
|
|
3590
3811
|
return !e.getClientRects().length;
|
|
@@ -3617,98 +3838,178 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
|
|
|
3617
3838
|
throw new Error("No node provided");
|
|
3618
3839
|
return matches.call(e, candidateSelector) === !1 ? !1 : isNodeMatchingSelectorTabbable(n, e);
|
|
3619
3840
|
};
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3841
|
+
const DEFAULT_PAGE_AGENT_TOOL_CONFIG = {
|
|
3842
|
+
enableHighlight: !1,
|
|
3843
|
+
removeMaskAfterToolCall: !0,
|
|
3844
|
+
a11yConfig: DEFAULT_A11Y_CONFIG
|
|
3845
|
+
};
|
|
3846
|
+
function getPageAgentToolConfig() {
|
|
3847
|
+
return typeof window < "u" && window.__webmcpcli_toolConfig ? window.__webmcpcli_toolConfig : {
|
|
3848
|
+
enableHighlight: DEFAULT_PAGE_AGENT_TOOL_CONFIG.enableHighlight,
|
|
3849
|
+
removeMaskAfterToolCall: DEFAULT_PAGE_AGENT_TOOL_CONFIG.removeMaskAfterToolCall,
|
|
3850
|
+
a11yConfig: mergeA11yConfig()
|
|
3851
|
+
};
|
|
3630
3852
|
}
|
|
3631
|
-
function
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3853
|
+
function resolvePatch(t, e) {
|
|
3854
|
+
return {
|
|
3855
|
+
enableHighlight: t.enableHighlight ?? e.enableHighlight,
|
|
3856
|
+
removeMaskAfterToolCall: t.removeMaskAfterToolCall ?? e.removeMaskAfterToolCall,
|
|
3857
|
+
a11yConfig: mergeA11yConfigs(e.a11yConfig, t.a11yConfig ?? {})
|
|
3858
|
+
};
|
|
3859
|
+
}
|
|
3860
|
+
function setPageAgentToolConfig(t, e) {
|
|
3861
|
+
const n = e?.mode ?? "merge", i = getPageAgentToolConfig(), r = typeof t == "function" ? resolvePatch(t(i), DEFAULT_PAGE_AGENT_TOOL_CONFIG) : resolvePatch(t, n === "replace" ? DEFAULT_PAGE_AGENT_TOOL_CONFIG : i);
|
|
3862
|
+
return typeof window < "u" && (window.__webmcpcli_toolConfig = r), r;
|
|
3863
|
+
}
|
|
3864
|
+
function isInShadowDom(t) {
|
|
3865
|
+
return t.getRootNode() instanceof ShadowRoot;
|
|
3866
|
+
}
|
|
3867
|
+
function dispatchComposedEvents(t, ...e) {
|
|
3868
|
+
for (const n of e)
|
|
3869
|
+
t.dispatchEvent(new Event(n, { bubbles: !0, composed: !0 }));
|
|
3870
|
+
}
|
|
3871
|
+
function deepQuerySelectorAll(t, e = document) {
|
|
3872
|
+
const n = Array.from(e.querySelectorAll(t)), i = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, null);
|
|
3873
|
+
let r = i.currentNode;
|
|
3874
|
+
for (; r; )
|
|
3875
|
+
r.shadowRoot && n.push(...deepQuerySelectorAll(t, r.shadowRoot)), r = i.nextNode();
|
|
3876
|
+
return n;
|
|
3877
|
+
}
|
|
3878
|
+
function waitForDomSettled(t = 600, e = 150) {
|
|
3879
|
+
return new Promise((n) => {
|
|
3880
|
+
let i = !1, r;
|
|
3881
|
+
const o = () => {
|
|
3882
|
+
i || (i = !0, a.disconnect(), r && clearTimeout(r), n());
|
|
3883
|
+
}, a = new MutationObserver(() => {
|
|
3884
|
+
r && clearTimeout(r), r = setTimeout(o, e);
|
|
3885
|
+
});
|
|
3886
|
+
r = setTimeout(o, e), setTimeout(o, t), a.observe(document.body, {
|
|
3887
|
+
childList: !0,
|
|
3888
|
+
subtree: !0,
|
|
3889
|
+
attributes: !0,
|
|
3890
|
+
attributeFilter: ["class", "style", "hidden"]
|
|
3891
|
+
});
|
|
3892
|
+
});
|
|
3893
|
+
}
|
|
3894
|
+
function detectPageDialog() {
|
|
3895
|
+
const t = /* @__PURE__ */ new Set(), e = [], n = getPageAgentToolConfig().a11yConfig.dialogSelectors;
|
|
3896
|
+
for (const i of n)
|
|
3897
|
+
try {
|
|
3898
|
+
for (const r of deepQuerySelectorAll(i)) {
|
|
3899
|
+
if (t.has(r) || r.id?.includes("page-agent-runtime") || r.closest("#page-agent-runtime_simulator-mask")) continue;
|
|
3900
|
+
const o = r.getBoundingClientRect();
|
|
3901
|
+
if (o.width < 50 || o.height < 50) continue;
|
|
3902
|
+
const a = window.getComputedStyle(r);
|
|
3903
|
+
if (a.display === "none" || a.visibility === "hidden") continue;
|
|
3904
|
+
const s = a.position === "fixed" || a.position === "absolute", c = parseInt(a.zIndex || "0", 10);
|
|
3905
|
+
if (!s || c < 100) continue;
|
|
3906
|
+
const d = window.innerWidth, u = window.innerHeight;
|
|
3907
|
+
if (!(o.left < d * 0.6 && o.right > d * 0.4 && o.top < u * 0.6 && o.bottom > u * 0.4)) continue;
|
|
3908
|
+
t.add(r);
|
|
3909
|
+
const h = (r.textContent || "").trim().replace(/\s+/g, " ");
|
|
3910
|
+
if (h.length > 5) {
|
|
3911
|
+
const g = r.querySelectorAll('button, [role="button"], a'), y = Array.from(g).map((C) => (C.textContent || "").trim()).filter((C) => C.length > 0 && C.length < 20).slice(0, 5), T = y.length ? ` [可操作按钮: ${y.join(" / ")}]` : "";
|
|
3912
|
+
e.push(`${h.substring(0, 300)}${T}`);
|
|
3913
|
+
}
|
|
3914
|
+
}
|
|
3915
|
+
} catch {
|
|
3916
|
+
}
|
|
3917
|
+
return e.length === 0 ? "" : `
|
|
3918
|
+
[页面弹窗检测] 检测到 ${e.length} 个模态弹窗,请优先处理:
|
|
3919
|
+
${e.map((i, r) => `${r + 1}. ${i}`).join(`
|
|
3920
|
+
`)}
|
|
3921
|
+
`;
|
|
3922
|
+
}
|
|
3923
|
+
function detectValidationErrors() {
|
|
3924
|
+
const t = /* @__PURE__ */ new Set(), e = [], n = extractSelectors(getPageAgentToolConfig().a11yConfig.states.error);
|
|
3925
|
+
for (const i of n)
|
|
3926
|
+
try {
|
|
3927
|
+
for (const r of deepQuerySelectorAll(i)) {
|
|
3928
|
+
if (t.has(r) || Array.from(t).some((c) => c.contains(r))) continue;
|
|
3929
|
+
const o = r.getBoundingClientRect();
|
|
3930
|
+
if (o.width < 1 || o.height < 1) continue;
|
|
3931
|
+
const a = window.getComputedStyle(r);
|
|
3932
|
+
if (a.display === "none" || a.visibility === "hidden") continue;
|
|
3933
|
+
const s = (r.textContent || "").trim().replace(/\s+/g, " ");
|
|
3934
|
+
s.length > 2 && s.length < 200 && (t.add(r), e.push(s));
|
|
3935
|
+
}
|
|
3936
|
+
} catch {
|
|
3645
3937
|
}
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3938
|
+
return e.length === 0 ? "" : `
|
|
3939
|
+
[校验提示] 检测到 ${e.length} 个表单校验错误,请先修复后再继续:
|
|
3940
|
+
${e.map((i, r) => `${r + 1}. ${i}`).join(`
|
|
3941
|
+
`)}
|
|
3942
|
+
`;
|
|
3943
|
+
}
|
|
3944
|
+
const NON_CONTENT_TAGS = /* @__PURE__ */ new Set([
|
|
3945
|
+
"script",
|
|
3946
|
+
"style",
|
|
3947
|
+
"noscript",
|
|
3948
|
+
"template",
|
|
3949
|
+
"link",
|
|
3950
|
+
"meta",
|
|
3951
|
+
"head",
|
|
3952
|
+
"title"
|
|
3953
|
+
]);
|
|
3954
|
+
function isNonContentElement(t) {
|
|
3955
|
+
return NON_CONTENT_TAGS.has(t.tagName.toLowerCase());
|
|
3956
|
+
}
|
|
3957
|
+
function hasOwnPointerCursor(t) {
|
|
3655
3958
|
try {
|
|
3656
|
-
window.getComputedStyle(t).cursor
|
|
3959
|
+
if (window.getComputedStyle(t).cursor !== "pointer") return !1;
|
|
3960
|
+
const e = t.parentElement;
|
|
3961
|
+
return e ? window.getComputedStyle(e).cursor !== "pointer" : !0;
|
|
3657
3962
|
} catch {
|
|
3963
|
+
return !1;
|
|
3658
3964
|
}
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
"is-active",
|
|
3668
|
-
"isActive",
|
|
3669
|
-
"is-selected",
|
|
3670
|
-
"isSelected",
|
|
3671
|
-
"is-current",
|
|
3672
|
-
"isCurrent",
|
|
3673
|
-
"active-item",
|
|
3674
|
-
"activeItem",
|
|
3675
|
-
"tab-active",
|
|
3676
|
-
"tabActive",
|
|
3677
|
-
// 仅当作为独立 class 词或有连字符前缀时匹配 "active",避免误匹配 "interactive" 等
|
|
3678
|
-
/\bactive\b/,
|
|
3679
|
-
/\bselected\b/,
|
|
3680
|
-
/\bcurrent\b/
|
|
3681
|
-
].some(
|
|
3682
|
-
(v) => typeof v == "string" ? m.split(/\s+/).includes(v) : v.test(m)
|
|
3683
|
-
), x = (t.getAttribute("role") || t.tagName.toLowerCase()).split(/\s+/).some((v) => ["button", "option", "a", "li", "generic"].includes(v) || v.startsWith("tab"));
|
|
3684
|
-
S && x && !r.includes("checked") && !r.includes("selected") && r.push("active");
|
|
3685
|
-
const T = Array.isArray(n) ? n.join(", ") : n || DEFAULT_ERROR_SELECTORS$1.join(", "), L = Array.isArray(i) ? i.join(", ") : i || DEFAULT_WARNING_SELECTORS.join(", ");
|
|
3686
|
-
let A = null;
|
|
3687
|
-
if (T)
|
|
3688
|
-
try {
|
|
3689
|
-
A = t.closest(T);
|
|
3690
|
-
} catch {
|
|
3965
|
+
}
|
|
3966
|
+
const INTERACTION_PSEUDO_RE = /:(hover|focus|focus-visible|focus-within|active)\b/gi;
|
|
3967
|
+
function collectInteractivePointerSelectors(t, e) {
|
|
3968
|
+
for (const n of Array.from(t)) {
|
|
3969
|
+
const i = n, r = n;
|
|
3970
|
+
if (!i.selectorText && r.cssRules) {
|
|
3971
|
+
collectInteractivePointerSelectors(r.cssRules, e);
|
|
3972
|
+
continue;
|
|
3691
3973
|
}
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3974
|
+
const o = i.selectorText;
|
|
3975
|
+
if (!(!o || !i.style || i.style.cursor !== "pointer") && /:(hover|focus|focus-visible|focus-within|active)\b/i.test(o))
|
|
3976
|
+
for (const a of o.split(",")) {
|
|
3977
|
+
const s = a.replace(INTERACTION_PSEUDO_RE, "").trim();
|
|
3978
|
+
s && s !== "*" && e.add(s);
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
function collectHoverPointerElements(t) {
|
|
3983
|
+
const e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
3984
|
+
try {
|
|
3985
|
+
for (const r of Array.from(document.styleSheets)) {
|
|
3986
|
+
let o = null;
|
|
3697
3987
|
try {
|
|
3698
|
-
|
|
3988
|
+
o = r.cssRules;
|
|
3699
3989
|
} catch {
|
|
3990
|
+
continue;
|
|
3700
3991
|
}
|
|
3701
|
-
|
|
3702
|
-
}
|
|
3703
|
-
if (e)
|
|
3704
|
-
for (const v of e) {
|
|
3705
|
-
const y = t.getAttribute(v);
|
|
3706
|
-
y !== null && r.push(`${v}="${y}"`);
|
|
3992
|
+
o && collectInteractivePointerSelectors(o, n);
|
|
3707
3993
|
}
|
|
3708
|
-
|
|
3994
|
+
} catch {
|
|
3995
|
+
return e;
|
|
3996
|
+
}
|
|
3997
|
+
if (n.size === 0) return e;
|
|
3998
|
+
const i = Array.from(n);
|
|
3999
|
+
try {
|
|
4000
|
+
for (const r of deepQuerySelectorAll(i.join(", "), t)) e.add(r);
|
|
4001
|
+
return e;
|
|
4002
|
+
} catch {
|
|
4003
|
+
for (const r of i)
|
|
4004
|
+
try {
|
|
4005
|
+
for (const o of deepQuerySelectorAll(r, t)) e.add(o);
|
|
4006
|
+
} catch {
|
|
4007
|
+
}
|
|
4008
|
+
}
|
|
4009
|
+
return e;
|
|
3709
4010
|
}
|
|
3710
4011
|
function isHidden$1(t) {
|
|
3711
|
-
if (t.getAttribute("aria-hidden") === "true" || t.hidden) return !0;
|
|
4012
|
+
if (isNonContentElement(t) || t.getAttribute("aria-hidden") === "true" || t.hidden) return !0;
|
|
3712
4013
|
try {
|
|
3713
4014
|
const e = window.getComputedStyle(t);
|
|
3714
4015
|
if (e.display === "none" || e.visibility === "hidden" || e.opacity === "0") return !0;
|
|
@@ -3718,29 +4019,30 @@ function isHidden$1(t) {
|
|
|
3718
4019
|
}
|
|
3719
4020
|
return !1;
|
|
3720
4021
|
}
|
|
3721
|
-
function
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
4022
|
+
function collectTitleLabel(t) {
|
|
4023
|
+
const e = t.getAttribute("title")?.trim();
|
|
4024
|
+
if (e) return e;
|
|
4025
|
+
const i = t.querySelector("[title]")?.getAttribute("title")?.trim();
|
|
4026
|
+
return i || "";
|
|
4027
|
+
}
|
|
4028
|
+
function collectDescendantText(t, e) {
|
|
4029
|
+
let n = "";
|
|
4030
|
+
const i = (r) => {
|
|
4031
|
+
if (r.nodeType === Node.TEXT_NODE)
|
|
4032
|
+
n += (r.textContent ?? "") + " ";
|
|
4033
|
+
else if (r.nodeType === Node.ELEMENT_NODE) {
|
|
4034
|
+
const o = r;
|
|
4035
|
+
if (o !== t && isNonContentElement(o) || isHidden$1(o) && o !== t || o === t && isNonContentElement(o)) return;
|
|
4036
|
+
if (o !== t) {
|
|
4037
|
+
const a = o.tagName.toLowerCase(), s = resolveA11yRole(o, e), c = ["button", "a", "input", "select", "textarea", "li", "option"].includes(a), d = ["button", "link", "checkbox", "radio", "textbox", "listitem", "option", "combobox", "listbox"].includes(s), u = isTabbable(o), p = hasOwnPointerCursor(o);
|
|
4038
|
+
if (u && !(s === "generic" && !p) || c || d)
|
|
3737
4039
|
return;
|
|
3738
4040
|
}
|
|
3739
|
-
for (const
|
|
3740
|
-
|
|
4041
|
+
for (const a of Array.from(o.childNodes))
|
|
4042
|
+
i(a);
|
|
3741
4043
|
}
|
|
3742
4044
|
};
|
|
3743
|
-
return
|
|
4045
|
+
return i(t), n.trim().replace(/\s+/g, " ");
|
|
3744
4046
|
}
|
|
3745
4047
|
function getComposedChildren(t) {
|
|
3746
4048
|
const e = t.shadowRoot ? t.shadowRoot.children : t.children, n = [];
|
|
@@ -3769,8 +4071,8 @@ function arrayFrom(t, e) {
|
|
|
3769
4071
|
var n = Array, i = Object(t);
|
|
3770
4072
|
if (t == null)
|
|
3771
4073
|
throw new TypeError("Array.from requires an array-like object - not null or undefined");
|
|
3772
|
-
for (var r = toLength(i.length), o = isCallable(n) ? Object(new n(r)) : new Array(r), a = 0,
|
|
3773
|
-
|
|
4074
|
+
for (var r = toLength(i.length), o = isCallable(n) ? Object(new n(r)) : new Array(r), a = 0, s; a < r; )
|
|
4075
|
+
s = i[a], o[a] = s, a += 1;
|
|
3774
4076
|
return o.length = r, o;
|
|
3775
4077
|
}
|
|
3776
4078
|
function _typeof$1(t) {
|
|
@@ -4175,105 +4477,105 @@ function getSlotContents(t) {
|
|
|
4175
4477
|
return e.length === 0 ? arrayFrom(t.childNodes) : e;
|
|
4176
4478
|
}
|
|
4177
4479
|
function computeTextAlternative(t) {
|
|
4178
|
-
var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = new SetLike$1(), i = safeWindow(t), r = e.compute, o = r === void 0 ? "name" : r, a = e.computedStyleSupportsPseudoElements,
|
|
4179
|
-
function f
|
|
4180
|
-
var
|
|
4181
|
-
if (isElement(
|
|
4182
|
-
var
|
|
4183
|
-
|
|
4480
|
+
var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = new SetLike$1(), i = safeWindow(t), r = e.compute, o = r === void 0 ? "name" : r, a = e.computedStyleSupportsPseudoElements, s = a === void 0 ? e.getComputedStyle !== void 0 : a, c = e.getComputedStyle, d = c === void 0 ? i.getComputedStyle.bind(i) : c, u = e.hidden, p = u === void 0 ? !1 : u;
|
|
4481
|
+
function h(f, m) {
|
|
4482
|
+
var E = "";
|
|
4483
|
+
if (isElement(f) && s) {
|
|
4484
|
+
var v = d(f, "::before"), L = getTextualContent(v);
|
|
4485
|
+
E = "".concat(L, " ").concat(E);
|
|
4184
4486
|
}
|
|
4185
|
-
var
|
|
4186
|
-
if (
|
|
4187
|
-
var
|
|
4188
|
-
isEmbeddedInLabel:
|
|
4487
|
+
var S = isHTMLSlotElement(f) ? getSlotContents(f) : arrayFrom(f.childNodes).concat(queryIdRefs(f, "aria-owns"));
|
|
4488
|
+
if (S.forEach(function(M) {
|
|
4489
|
+
var O = C(M, {
|
|
4490
|
+
isEmbeddedInLabel: m.isEmbeddedInLabel,
|
|
4189
4491
|
isReferenced: !1,
|
|
4190
4492
|
recursion: !0
|
|
4191
|
-
}),
|
|
4192
|
-
|
|
4193
|
-
}), isElement(
|
|
4194
|
-
var
|
|
4195
|
-
|
|
4493
|
+
}), F = isElement(M) ? d(M).getPropertyValue("display") : "inline", B = F !== "inline" ? " " : "";
|
|
4494
|
+
E += "".concat(B).concat(O).concat(B);
|
|
4495
|
+
}), isElement(f) && s) {
|
|
4496
|
+
var A = d(f, "::after"), N = getTextualContent(A);
|
|
4497
|
+
E = "".concat(E, " ").concat(N);
|
|
4196
4498
|
}
|
|
4197
|
-
return
|
|
4499
|
+
return E.trim();
|
|
4198
4500
|
}
|
|
4199
|
-
function
|
|
4200
|
-
var
|
|
4201
|
-
return
|
|
4501
|
+
function g(f, m) {
|
|
4502
|
+
var E = f.getAttributeNode(m);
|
|
4503
|
+
return E !== null && !n.has(E) && E.value.trim() !== "" ? (n.add(E), E.value) : null;
|
|
4202
4504
|
}
|
|
4203
|
-
function
|
|
4204
|
-
return isElement(
|
|
4505
|
+
function y(f) {
|
|
4506
|
+
return isElement(f) ? g(f, "title") : null;
|
|
4205
4507
|
}
|
|
4206
|
-
function
|
|
4207
|
-
if (!isElement(
|
|
4508
|
+
function T(f) {
|
|
4509
|
+
if (!isElement(f))
|
|
4208
4510
|
return null;
|
|
4209
|
-
if (isHTMLFieldSetElement(
|
|
4210
|
-
n.add(
|
|
4211
|
-
for (var
|
|
4212
|
-
var
|
|
4213
|
-
if (isHTMLLegendElement(
|
|
4214
|
-
return
|
|
4511
|
+
if (isHTMLFieldSetElement(f)) {
|
|
4512
|
+
n.add(f);
|
|
4513
|
+
for (var m = arrayFrom(f.childNodes), E = 0; E < m.length; E += 1) {
|
|
4514
|
+
var v = m[E];
|
|
4515
|
+
if (isHTMLLegendElement(v))
|
|
4516
|
+
return C(v, {
|
|
4215
4517
|
isEmbeddedInLabel: !1,
|
|
4216
4518
|
isReferenced: !1,
|
|
4217
4519
|
recursion: !1
|
|
4218
4520
|
});
|
|
4219
4521
|
}
|
|
4220
|
-
} else if (isHTMLTableElement(
|
|
4221
|
-
n.add(
|
|
4222
|
-
for (var
|
|
4223
|
-
var
|
|
4224
|
-
if (isHTMLTableCaptionElement(
|
|
4225
|
-
return
|
|
4522
|
+
} else if (isHTMLTableElement(f)) {
|
|
4523
|
+
n.add(f);
|
|
4524
|
+
for (var L = arrayFrom(f.childNodes), S = 0; S < L.length; S += 1) {
|
|
4525
|
+
var A = L[S];
|
|
4526
|
+
if (isHTMLTableCaptionElement(A))
|
|
4527
|
+
return C(A, {
|
|
4226
4528
|
isEmbeddedInLabel: !1,
|
|
4227
4529
|
isReferenced: !1,
|
|
4228
4530
|
recursion: !1
|
|
4229
4531
|
});
|
|
4230
4532
|
}
|
|
4231
|
-
} else if (isSVGSVGElement(
|
|
4232
|
-
n.add(
|
|
4233
|
-
for (var
|
|
4234
|
-
var
|
|
4235
|
-
if (isSVGTitleElement(
|
|
4236
|
-
return
|
|
4533
|
+
} else if (isSVGSVGElement(f)) {
|
|
4534
|
+
n.add(f);
|
|
4535
|
+
for (var N = arrayFrom(f.childNodes), M = 0; M < N.length; M += 1) {
|
|
4536
|
+
var O = N[M];
|
|
4537
|
+
if (isSVGTitleElement(O))
|
|
4538
|
+
return O.textContent;
|
|
4237
4539
|
}
|
|
4238
4540
|
return null;
|
|
4239
|
-
} else if (getLocalName(
|
|
4240
|
-
var
|
|
4241
|
-
if (
|
|
4242
|
-
return
|
|
4243
|
-
} else if (isHTMLOptGroupElement(
|
|
4244
|
-
var B =
|
|
4541
|
+
} else if (getLocalName(f) === "img" || getLocalName(f) === "area") {
|
|
4542
|
+
var F = g(f, "alt");
|
|
4543
|
+
if (F !== null)
|
|
4544
|
+
return F;
|
|
4545
|
+
} else if (isHTMLOptGroupElement(f)) {
|
|
4546
|
+
var B = g(f, "label");
|
|
4245
4547
|
if (B !== null)
|
|
4246
4548
|
return B;
|
|
4247
4549
|
}
|
|
4248
|
-
if (isHTMLInputElement(
|
|
4249
|
-
var
|
|
4250
|
-
if (
|
|
4251
|
-
return
|
|
4252
|
-
if (
|
|
4550
|
+
if (isHTMLInputElement(f) && (f.type === "button" || f.type === "submit" || f.type === "reset")) {
|
|
4551
|
+
var J = g(f, "value");
|
|
4552
|
+
if (J !== null)
|
|
4553
|
+
return J;
|
|
4554
|
+
if (f.type === "submit")
|
|
4253
4555
|
return "Submit";
|
|
4254
|
-
if (
|
|
4556
|
+
if (f.type === "reset")
|
|
4255
4557
|
return "Reset";
|
|
4256
4558
|
}
|
|
4257
|
-
var
|
|
4258
|
-
if (
|
|
4259
|
-
return n.add(
|
|
4260
|
-
return
|
|
4559
|
+
var G = getLabels(f);
|
|
4560
|
+
if (G !== null && G.length !== 0)
|
|
4561
|
+
return n.add(f), arrayFrom(G).map(function(W) {
|
|
4562
|
+
return C(W, {
|
|
4261
4563
|
isEmbeddedInLabel: !0,
|
|
4262
4564
|
isReferenced: !1,
|
|
4263
4565
|
recursion: !0
|
|
4264
4566
|
});
|
|
4265
|
-
}).filter(function(
|
|
4266
|
-
return
|
|
4567
|
+
}).filter(function(W) {
|
|
4568
|
+
return W.length > 0;
|
|
4267
4569
|
}).join(" ");
|
|
4268
|
-
if (isHTMLInputElement(
|
|
4269
|
-
var
|
|
4270
|
-
if (
|
|
4271
|
-
return
|
|
4272
|
-
var ee =
|
|
4570
|
+
if (isHTMLInputElement(f) && f.type === "image") {
|
|
4571
|
+
var Q = g(f, "alt");
|
|
4572
|
+
if (Q !== null)
|
|
4573
|
+
return Q;
|
|
4574
|
+
var ee = g(f, "title");
|
|
4273
4575
|
return ee !== null ? ee : "Submit Query";
|
|
4274
4576
|
}
|
|
4275
|
-
if (hasAnyConcreteRoles(
|
|
4276
|
-
var te = f
|
|
4577
|
+
if (hasAnyConcreteRoles(f, ["button"])) {
|
|
4578
|
+
var te = h(f, {
|
|
4277
4579
|
isEmbeddedInLabel: !1
|
|
4278
4580
|
});
|
|
4279
4581
|
if (te !== "")
|
|
@@ -4281,16 +4583,16 @@ function computeTextAlternative(t) {
|
|
|
4281
4583
|
}
|
|
4282
4584
|
return null;
|
|
4283
4585
|
}
|
|
4284
|
-
function
|
|
4285
|
-
if (n.has(
|
|
4586
|
+
function C(f, m) {
|
|
4587
|
+
if (n.has(f))
|
|
4286
4588
|
return "";
|
|
4287
|
-
if (!p && isHidden(
|
|
4288
|
-
return n.add(
|
|
4289
|
-
var
|
|
4290
|
-
if (o === "name" && !
|
|
4291
|
-
return n.add(
|
|
4292
|
-
return
|
|
4293
|
-
isEmbeddedInLabel:
|
|
4589
|
+
if (!p && isHidden(f, d) && !m.isReferenced)
|
|
4590
|
+
return n.add(f), "";
|
|
4591
|
+
var E = isElement(f) ? f.getAttributeNode("aria-labelledby") : null, v = E !== null && !n.has(E) ? queryIdRefs(f, "aria-labelledby") : [];
|
|
4592
|
+
if (o === "name" && !m.isReferenced && v.length > 0)
|
|
4593
|
+
return n.add(E), v.map(function(F) {
|
|
4594
|
+
return C(F, {
|
|
4595
|
+
isEmbeddedInLabel: m.isEmbeddedInLabel,
|
|
4294
4596
|
isReferenced: !0,
|
|
4295
4597
|
// this isn't recursion as specified, otherwise we would skip
|
|
4296
4598
|
// `aria-label` in
|
|
@@ -4298,53 +4600,53 @@ function computeTextAlternative(t) {
|
|
|
4298
4600
|
recursion: !1
|
|
4299
4601
|
});
|
|
4300
4602
|
}).join(" ");
|
|
4301
|
-
var
|
|
4302
|
-
if (!
|
|
4303
|
-
var
|
|
4304
|
-
if (
|
|
4305
|
-
return n.add(
|
|
4306
|
-
if (!isMarkedPresentational(
|
|
4307
|
-
var
|
|
4308
|
-
if (
|
|
4309
|
-
return n.add(
|
|
4603
|
+
var L = m.recursion && isControl(f) && o === "name";
|
|
4604
|
+
if (!L) {
|
|
4605
|
+
var S = (isElement(f) && f.getAttribute("aria-label") || "").trim();
|
|
4606
|
+
if (S !== "" && o === "name")
|
|
4607
|
+
return n.add(f), S;
|
|
4608
|
+
if (!isMarkedPresentational(f)) {
|
|
4609
|
+
var A = T(f);
|
|
4610
|
+
if (A !== null)
|
|
4611
|
+
return n.add(f), A;
|
|
4310
4612
|
}
|
|
4311
4613
|
}
|
|
4312
|
-
if (hasAnyConcreteRoles(
|
|
4313
|
-
return n.add(
|
|
4314
|
-
if (
|
|
4315
|
-
if (hasAnyConcreteRoles(
|
|
4316
|
-
n.add(
|
|
4317
|
-
var
|
|
4318
|
-
return
|
|
4319
|
-
return
|
|
4320
|
-
isEmbeddedInLabel:
|
|
4614
|
+
if (hasAnyConcreteRoles(f, ["menu"]))
|
|
4615
|
+
return n.add(f), "";
|
|
4616
|
+
if (L || m.isEmbeddedInLabel || m.isReferenced) {
|
|
4617
|
+
if (hasAnyConcreteRoles(f, ["combobox", "listbox"])) {
|
|
4618
|
+
n.add(f);
|
|
4619
|
+
var N = querySelectedOptions(f);
|
|
4620
|
+
return N.length === 0 ? isHTMLInputElement(f) ? f.value : "" : arrayFrom(N).map(function(F) {
|
|
4621
|
+
return C(F, {
|
|
4622
|
+
isEmbeddedInLabel: m.isEmbeddedInLabel,
|
|
4321
4623
|
isReferenced: !1,
|
|
4322
4624
|
recursion: !0
|
|
4323
4625
|
});
|
|
4324
4626
|
}).join(" ");
|
|
4325
4627
|
}
|
|
4326
|
-
if (hasAbstractRole(
|
|
4327
|
-
return n.add(
|
|
4328
|
-
if (hasAnyConcreteRoles(
|
|
4329
|
-
return n.add(
|
|
4628
|
+
if (hasAbstractRole(f, "range"))
|
|
4629
|
+
return n.add(f), f.hasAttribute("aria-valuetext") ? f.getAttribute("aria-valuetext") : f.hasAttribute("aria-valuenow") ? f.getAttribute("aria-valuenow") : f.getAttribute("value") || "";
|
|
4630
|
+
if (hasAnyConcreteRoles(f, ["textbox"]))
|
|
4631
|
+
return n.add(f), getValueOfTextbox(f);
|
|
4330
4632
|
}
|
|
4331
|
-
if (allowsNameFromContent(
|
|
4332
|
-
var
|
|
4333
|
-
isEmbeddedInLabel:
|
|
4633
|
+
if (allowsNameFromContent(f) || isElement(f) && m.isReferenced || isNativeHostLanguageTextAlternativeElement(f) || isDescendantOfNativeHostLanguageTextAlternativeElement()) {
|
|
4634
|
+
var M = h(f, {
|
|
4635
|
+
isEmbeddedInLabel: m.isEmbeddedInLabel
|
|
4334
4636
|
});
|
|
4335
|
-
if (
|
|
4336
|
-
return n.add(
|
|
4637
|
+
if (M !== "")
|
|
4638
|
+
return n.add(f), M;
|
|
4337
4639
|
}
|
|
4338
|
-
if (
|
|
4339
|
-
return n.add(
|
|
4340
|
-
if (
|
|
4341
|
-
return n.add(
|
|
4342
|
-
isEmbeddedInLabel:
|
|
4640
|
+
if (f.nodeType === f.TEXT_NODE)
|
|
4641
|
+
return n.add(f), f.textContent || "";
|
|
4642
|
+
if (m.recursion)
|
|
4643
|
+
return n.add(f), h(f, {
|
|
4644
|
+
isEmbeddedInLabel: m.isEmbeddedInLabel
|
|
4343
4645
|
});
|
|
4344
|
-
var
|
|
4345
|
-
return
|
|
4646
|
+
var O = y(f);
|
|
4647
|
+
return O !== null ? (n.add(f), O) : (n.add(f), "");
|
|
4346
4648
|
}
|
|
4347
|
-
return asFlatString(
|
|
4649
|
+
return asFlatString(C(t, {
|
|
4348
4650
|
isEmbeddedInLabel: !1,
|
|
4349
4651
|
// by spec computeAccessibleDescription starts with the referenced elements as roots
|
|
4350
4652
|
isReferenced: o === "description",
|
|
@@ -4358,42 +4660,88 @@ function computeAccessibleName(t) {
|
|
|
4358
4660
|
var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
4359
4661
|
return prohibitsNaming(t) ? "" : computeTextAlternative(t, e);
|
|
4360
4662
|
}
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4663
|
+
const INTERACTIVE_ROLES = /* @__PURE__ */ new Set([
|
|
4664
|
+
"button",
|
|
4665
|
+
"link",
|
|
4666
|
+
"textbox",
|
|
4667
|
+
"searchbox",
|
|
4668
|
+
"combobox",
|
|
4669
|
+
"listbox",
|
|
4670
|
+
"checkbox",
|
|
4671
|
+
"radio",
|
|
4672
|
+
"switch",
|
|
4673
|
+
"slider",
|
|
4674
|
+
"spinbutton",
|
|
4675
|
+
"menuitem",
|
|
4676
|
+
"menuitemcheckbox",
|
|
4677
|
+
"menuitemradio",
|
|
4678
|
+
"tab",
|
|
4679
|
+
"treeitem"
|
|
4680
|
+
]);
|
|
4681
|
+
function buildVNode(t, e, n, i, r, o, a = /* @__PURE__ */ new Set()) {
|
|
4682
|
+
if (isNonContentElement(t) || isHidden$1(t) || i.has(t)) return null;
|
|
4683
|
+
const { role: s, tokens: c } = resolveA11yInfo(t, o);
|
|
4684
|
+
let d = computeAccessibleName(t);
|
|
4685
|
+
const u = isTabbable(t), p = c.includes("cursor=pointer"), h = hasOwnPointerCursor(t) || a.has(t), g = r.has(t), y = t.tagName.toLowerCase() === "label" && t.hasAttribute("for");
|
|
4686
|
+
if (!d.trim()) {
|
|
4687
|
+
const A = t.tagName.toLowerCase();
|
|
4688
|
+
if (!(A === "select" || s === "combobox" || s === "listbox")) {
|
|
4689
|
+
const M = ["button", "a", "input", "textarea", "li", "label"].includes(A);
|
|
4690
|
+
(u || g || p || h || M || s === "listitem" || s === "option") && (d = collectDescendantText(t, o));
|
|
4371
4691
|
}
|
|
4372
4692
|
}
|
|
4373
|
-
if (!p.trim() && !(getComposedChildren(t).length > 0)) {
|
|
4374
|
-
const
|
|
4375
|
-
|
|
4376
|
-
}
|
|
4377
|
-
const
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4693
|
+
if (!d.trim() && (u || g || p || h || s === "button") && (d = collectTitleLabel(t)), !d.trim() && ["tab", "menuitem", "option", "treeitem", "button"].includes(s) && (d = collectVisiblePlainText(t)), !d.trim() && !(getComposedChildren(t).length > 0)) {
|
|
4694
|
+
const N = collectDescendantText(t, o);
|
|
4695
|
+
N && (d = N);
|
|
4696
|
+
}
|
|
4697
|
+
const T = t.tagName.toLowerCase(), C = T === "a" && t.hasAttribute("href") || ["button", "input", "select", "textarea"].includes(T) && !t.hasAttribute("disabled"), f = u && !(s === "generic" && !h), m = c.includes("disabled"), E = !m && f || g || y || C || !m && INTERACTIVE_ROLES.has(s) || // hasClickableCursor 已排除 CSS 继承(hasOwnPointerCursor)并覆盖 hover 态手势,
|
|
4698
|
+
// 无需再要求 role≠generic 或 name≠''——否则无文本的图标按钮(tp-icon.common-icon 等)
|
|
4699
|
+
// 虽是真正的可点击边界,仍会因 generic+空名被漏判。
|
|
4700
|
+
!m && h;
|
|
4701
|
+
let v;
|
|
4702
|
+
E && (v = e.value, n.set(v, t), e.value++);
|
|
4703
|
+
const L = [];
|
|
4704
|
+
for (const A of getComposedChildren(t)) {
|
|
4705
|
+
const N = buildVNode(
|
|
4706
|
+
A,
|
|
4384
4707
|
e,
|
|
4385
4708
|
n,
|
|
4386
4709
|
i,
|
|
4387
4710
|
r,
|
|
4388
4711
|
o,
|
|
4389
|
-
a
|
|
4390
|
-
l,
|
|
4391
|
-
// 将当前节点的交互性向下传递,子节点据此决定是否抑制 cursor=pointer
|
|
4392
|
-
T || c
|
|
4712
|
+
a
|
|
4393
4713
|
);
|
|
4394
|
-
|
|
4714
|
+
N && L.push(N);
|
|
4715
|
+
}
|
|
4716
|
+
const S = { role: s, name: d, tokens: c, ref: v, el: t, children: L };
|
|
4717
|
+
return hasInteractiveDescendant(S) && (S.name = getOwnDeclaredName(t)), S;
|
|
4718
|
+
}
|
|
4719
|
+
function getOwnDeclaredName(t) {
|
|
4720
|
+
return t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby") ? computeAccessibleName(t).trim() : "";
|
|
4721
|
+
}
|
|
4722
|
+
function isStaticBranch(t) {
|
|
4723
|
+
return t.ref === void 0 && !hasInteractiveDescendant(t);
|
|
4724
|
+
}
|
|
4725
|
+
function collectVisiblePlainText(t) {
|
|
4726
|
+
return collectDescendantText(t).replace(/\s+/g, " ").trim();
|
|
4727
|
+
}
|
|
4728
|
+
function getStaticDisplayText(t) {
|
|
4729
|
+
const e = t.children.length > 0 ? t.children.map(getStaticDisplayText).filter(Boolean).join(" ").replace(/\s+/g, " ").trim() : "", n = t.children.length === 0 ? collectVisiblePlainText(t.el) : "", i = t.name.trim(), r = [];
|
|
4730
|
+
if (i && !isNoiseAccessibleName(i) && r.push(i), e && !isNoiseAccessibleName(e)) {
|
|
4731
|
+
const o = i.replace(/\s+/g, " ").trim(), a = e.replace(/\s+/g, " ").trim();
|
|
4732
|
+
(!o || a !== o && !o.includes(a)) && r.push(e);
|
|
4395
4733
|
}
|
|
4396
|
-
return
|
|
4734
|
+
return r.length === 0 && n && !isNoiseAccessibleName(n) && r.push(n), r.join(" ").replace(/\s+/g, " ").trim();
|
|
4735
|
+
}
|
|
4736
|
+
function isNoiseAccessibleName(t) {
|
|
4737
|
+
const e = t.trim();
|
|
4738
|
+
return e ? !!(/@font-face\b/i.test(e) || /data:(?:font|application|image)\//i.test(e) || /base64,[A-Za-z0-9+/=]{80,}/.test(e)) : !1;
|
|
4739
|
+
}
|
|
4740
|
+
function canOmitStaticChild(t, e, n) {
|
|
4741
|
+
const i = getStaticDisplayText(t);
|
|
4742
|
+
if (!i || !e.trim()) return !1;
|
|
4743
|
+
const r = e.replace(/\s+/g, " ").trim(), o = i.replace(/\s+/g, " ").trim();
|
|
4744
|
+
return n ? o === r : r.includes(o);
|
|
4397
4745
|
}
|
|
4398
4746
|
function hasValue(t) {
|
|
4399
4747
|
return t.ref !== void 0 || t.name.trim() !== "" ? !0 : t.children.some(hasValue);
|
|
@@ -4410,23 +4758,35 @@ function findSingleRefDescendant(t) {
|
|
|
4410
4758
|
function shouldPassThrough(t, e) {
|
|
4411
4759
|
return !(!e.pruneUnnamed || e.preserveRoles.includes(t.role) || t.ref !== void 0 || t.name.trim() !== "");
|
|
4412
4760
|
}
|
|
4761
|
+
function formatNameAttr(t) {
|
|
4762
|
+
const e = t.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"').trim();
|
|
4763
|
+
return e ? ` "${e}"` : "";
|
|
4764
|
+
}
|
|
4413
4765
|
function serializeVNode(t, e, n) {
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4766
|
+
const i = hasInteractiveDescendant(t), r = n.preserveRoles.includes(t.role), o = " ".repeat(e), a = t.ref !== void 0 ? ` #${t.ref}` : "", s = t.tokens.map((m) => m.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"')), c = s.length > 0 ? ` [${s.join(" ")}]` : "";
|
|
4767
|
+
if (!i && !r) {
|
|
4768
|
+
if (shouldPassThrough(t, n))
|
|
4769
|
+
return t.children.filter((E) => hasValue(E)).flatMap((E) => serializeVNode(E, e, n));
|
|
4770
|
+
let m = t.name.trim();
|
|
4771
|
+
return !m && t.children.length > 0 && (m = collectVisiblePlainText(t.el)), isNoiseAccessibleName(m) && (m = ""), [`${o}- ${t.role}${a}${c}${formatNameAttr(m)}`];
|
|
4772
|
+
}
|
|
4773
|
+
if (!i && r) {
|
|
4774
|
+
const m = getOwnDeclaredName(t.el), E = `${o}- ${t.role}${a}${c}${formatNameAttr(m)}`, v = t.children.flatMap((L) => serializeVNode(L, e + 1, n));
|
|
4775
|
+
return [E, ...v];
|
|
4776
|
+
}
|
|
4777
|
+
const d = getOwnDeclaredName(t.el), u = d !== "", p = t.children.filter(isStaticBranch), h = p.map(getStaticDisplayText).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
4778
|
+
let g = u ? d : h;
|
|
4779
|
+
if (isNoiseAccessibleName(g) && (g = ""), !u && isNoiseAccessibleName(t.name) && (g = h && !isNoiseAccessibleName(h) ? h : ""), !(t.ref !== void 0 || g !== "" || r || !n.pruneUnnamed))
|
|
4780
|
+
return t.children.filter((m) => hasValue(m)).flatMap((m) => serializeVNode(m, e, n));
|
|
4417
4781
|
if (t.ref !== void 0) {
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
const p = findSingleRefDescendant(t);
|
|
4423
|
-
if (p && p.role === "generic" && !hasInteractiveDescendant(p)) {
|
|
4424
|
-
const f = (t.name.trim() || p.name.trim()).replace(/[\r\n]+/g, " ").replace(/"/g, '\\"'), m = f ? ` "${f}"` : "";
|
|
4425
|
-
return [`${i}- ${t.role}${r}${a}${m}`];
|
|
4782
|
+
const m = findSingleRefDescendant(t);
|
|
4783
|
+
if (m && m.role === "generic" && !hasInteractiveDescendant(m) && p.length === 0) {
|
|
4784
|
+
const E = g.trim() || m.name.trim(), v = m.ref !== void 0 ? ` #${m.ref}` : a;
|
|
4785
|
+
return [`${o}- ${t.role}${v}${c}${formatNameAttr(E)}`];
|
|
4426
4786
|
}
|
|
4427
4787
|
}
|
|
4428
|
-
const
|
|
4429
|
-
return [
|
|
4788
|
+
const T = t.children.filter((m) => isStaticBranch(m) ? !canOmitStaticChild(m, g, u) : !0), C = `${o}- ${t.role}${a}${c}${formatNameAttr(g)}`, f = T.flatMap((m) => serializeVNode(m, e + 1, n));
|
|
4789
|
+
return [C, ...f];
|
|
4430
4790
|
}
|
|
4431
4791
|
const HIGHLIGHT_CONTAINER_ID = "webmcpcli-highlight-container", HIGHLIGHT_CONTAINER_STYLE_ID = "webmcpcli-highlight-container-style", colors = [
|
|
4432
4792
|
"#FF0000",
|
|
@@ -4468,10 +4828,34 @@ const HIGHLIGHT_CONTAINER_ID = "webmcpcli-highlight-container", HIGHLIGHT_CONTAI
|
|
|
4468
4828
|
padding: 0 2px;
|
|
4469
4829
|
border-radius: 4px;
|
|
4470
4830
|
}
|
|
4471
|
-
|
|
4472
|
-
function
|
|
4831
|
+
`, MAX_ICON_FALLBACK_SIZE = 48;
|
|
4832
|
+
function resolveHighlightRect(t) {
|
|
4473
4833
|
const e = t.getBoundingClientRect();
|
|
4474
|
-
|
|
4834
|
+
if (e.width > 0 && e.height > 0)
|
|
4835
|
+
return { top: e.top, left: e.left, width: e.width, height: e.height };
|
|
4836
|
+
let n = t.parentElement;
|
|
4837
|
+
for (let i = 0; i < 3 && n; i++) {
|
|
4838
|
+
const r = n.getBoundingClientRect();
|
|
4839
|
+
if (r.width > 0 && r.height > 0 && r.width <= MAX_ICON_FALLBACK_SIZE && r.height <= MAX_ICON_FALLBACK_SIZE)
|
|
4840
|
+
return { top: r.top, left: r.left, width: r.width, height: r.height };
|
|
4841
|
+
n = n.parentElement;
|
|
4842
|
+
}
|
|
4843
|
+
if (e.width > 0 || e.height > 0)
|
|
4844
|
+
try {
|
|
4845
|
+
const i = parseFloat(getComputedStyle(t).fontSize) || 16, r = e.width > 0 ? e.width : i, o = e.height > 0 ? e.height : i;
|
|
4846
|
+
return {
|
|
4847
|
+
top: e.height > 0 ? e.top : e.top - (o - e.height) / 2,
|
|
4848
|
+
left: e.width > 0 ? e.left : e.left - (r - e.width) / 2,
|
|
4849
|
+
width: r,
|
|
4850
|
+
height: o
|
|
4851
|
+
};
|
|
4852
|
+
} catch {
|
|
4853
|
+
}
|
|
4854
|
+
return null;
|
|
4855
|
+
}
|
|
4856
|
+
function isRectInViewport(t) {
|
|
4857
|
+
const e = window.innerHeight || document.documentElement.clientHeight, n = window.innerWidth || document.documentElement.clientWidth;
|
|
4858
|
+
return t.top < e && t.top + t.height > 0 && t.left < n && t.left + t.width > 0;
|
|
4475
4859
|
}
|
|
4476
4860
|
const doHighlight = (t, e = null) => {
|
|
4477
4861
|
if (!document.head.querySelector(`#${HIGHLIGHT_CONTAINER_STYLE_ID}`)) {
|
|
@@ -4487,25 +4871,24 @@ const doHighlight = (t, e = null) => {
|
|
|
4487
4871
|
}
|
|
4488
4872
|
const r = document.createDocumentFragment();
|
|
4489
4873
|
for (const [o, a] of t.entries()) {
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
m.style.backgroundColor = c, m.style.height = `${u.height - 4}px`, m.style.lineHeight = `${u.height - 4}px`, m.textContent = o.toString(), d.appendChild(m), r.appendChild(d);
|
|
4874
|
+
const s = resolveHighlightRect(a);
|
|
4875
|
+
if (!s) continue;
|
|
4876
|
+
const c = s.top + i.y, d = s.left + i.x, u = { top: c, left: d, width: s.width, height: s.height };
|
|
4877
|
+
if (!isRectInViewport(u)) continue;
|
|
4878
|
+
const h = colors[o % colors.length] + opacity, g = document.createElement("div");
|
|
4879
|
+
g.style.border = `2px solid ${h}`, g.dataset.refIndex = String(o), g.style.top = `${c}px`, g.style.left = `${d}px`, g.style.width = `${s.width}px`, g.style.height = `${s.height}px`;
|
|
4880
|
+
const y = document.createElement("span");
|
|
4881
|
+
y.style.backgroundColor = h, y.style.height = `${Math.max(s.height - 4, 0)}px`, y.style.lineHeight = `${Math.max(s.height - 4, 0)}px`, y.textContent = o.toString(), g.appendChild(y), r.appendChild(g);
|
|
4499
4882
|
}
|
|
4500
4883
|
n.appendChild(r);
|
|
4501
4884
|
}, highlight = (t, e = null) => {
|
|
4502
4885
|
doHighlight(t, e);
|
|
4503
|
-
const r = ((
|
|
4504
|
-
let
|
|
4505
|
-
return (...
|
|
4886
|
+
const r = ((s, c) => {
|
|
4887
|
+
let d = 0;
|
|
4888
|
+
return (...u) => {
|
|
4506
4889
|
const p = performance.now();
|
|
4507
|
-
if (!(p -
|
|
4508
|
-
return
|
|
4890
|
+
if (!(p - d < c))
|
|
4891
|
+
return d = p, s(...u);
|
|
4509
4892
|
};
|
|
4510
4893
|
})(() => doHighlight(t, e), 16);
|
|
4511
4894
|
window.addEventListener("scroll", r, !0), window.addEventListener("resize", r);
|
|
@@ -4539,87 +4922,84 @@ const doHighlight = (t, e = null) => {
|
|
|
4539
4922
|
window.location.href !== e && (e = window.location.href, unhighlight());
|
|
4540
4923
|
}, 500);
|
|
4541
4924
|
}
|
|
4542
|
-
}, DEFAULT_OPTIONS = {
|
|
4543
|
-
pruneUnnamed: !0,
|
|
4544
|
-
preserveRoles: [],
|
|
4545
|
-
exposedAttributes: [],
|
|
4546
|
-
errorSelectors: DEFAULT_ERROR_SELECTORS$1,
|
|
4547
|
-
warningSelectors: DEFAULT_WARNING_SELECTORS
|
|
4548
4925
|
};
|
|
4549
|
-
function
|
|
4550
|
-
const
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4926
|
+
function resolveElementList(t, e) {
|
|
4927
|
+
const n = /* @__PURE__ */ new Set();
|
|
4928
|
+
for (const i of t)
|
|
4929
|
+
if (typeof i == "string")
|
|
4930
|
+
try {
|
|
4931
|
+
for (const r of deepQuerySelectorAll(i, e)) n.add(r);
|
|
4932
|
+
} catch {
|
|
4933
|
+
}
|
|
4934
|
+
else i && n.add(i);
|
|
4935
|
+
return n;
|
|
4936
|
+
}
|
|
4937
|
+
function buildA11yTree(t = document.body, e) {
|
|
4938
|
+
const { pruneUnnamed: n = !0, preserveRoles: i = [], ...r } = e ?? {}, o = ensureResolvedA11yConfig(r), a = { pruneUnnamed: n, preserveRoles: i }, s = { value: 0 }, c = /* @__PURE__ */ new Map(), d = resolveElementList(o.blacklist, t), u = resolveElementList(o.whitelist, t), p = [], h = document.getElementById(HIGHLIGHT_CONTAINER_ID);
|
|
4939
|
+
h && d.add(h);
|
|
4940
|
+
const g = collectHoverPointerElements(t);
|
|
4941
|
+
for (const T of getComposedChildren(t)) {
|
|
4942
|
+
const C = buildVNode(T, s, c, d, u, o, g);
|
|
4943
|
+
C && p.push(...serializeVNode(C, 0, a));
|
|
4564
4944
|
}
|
|
4565
4945
|
return {
|
|
4566
|
-
yaml: "```yaml\n" +
|
|
4946
|
+
yaml: "```yaml\n" + p.join(`
|
|
4567
4947
|
`) + "\n```",
|
|
4568
|
-
refMap:
|
|
4569
|
-
interactiveCount:
|
|
4570
|
-
lines:
|
|
4948
|
+
refMap: c,
|
|
4949
|
+
interactiveCount: c.size,
|
|
4950
|
+
lines: p
|
|
4571
4951
|
};
|
|
4572
4952
|
}
|
|
4573
|
-
function searchA11yTree(t, e = document.body, n
|
|
4953
|
+
function searchA11yTree(t, e = document.body, n) {
|
|
4574
4954
|
const {
|
|
4575
|
-
contextLines:
|
|
4576
|
-
caseInsensitive:
|
|
4577
|
-
maxMatches:
|
|
4578
|
-
...
|
|
4579
|
-
} =
|
|
4580
|
-
for (let
|
|
4581
|
-
let
|
|
4582
|
-
|
|
4583
|
-
}
|
|
4584
|
-
const
|
|
4585
|
-
let
|
|
4586
|
-
for (const
|
|
4587
|
-
const
|
|
4588
|
-
if (N &&
|
|
4589
|
-
N.end = Math.max(N.end,
|
|
4955
|
+
contextLines: i = 2,
|
|
4956
|
+
caseInsensitive: r = !0,
|
|
4957
|
+
maxMatches: o = 20,
|
|
4958
|
+
...a
|
|
4959
|
+
} = n ?? {}, s = Math.max(0, i), c = Math.max(1, o), { lines: d, refMap: u, yaml: p } = buildA11yTree(e, a), h = r ? t.toLowerCase() : t, g = d.length, T = /^#\d+$/.test(t) ? new RegExp(`\\s${t}(?:\\s|[\\[]|$)`) : null, C = [];
|
|
4960
|
+
for (let L = 0; L < d.length; L++) {
|
|
4961
|
+
let S = !1;
|
|
4962
|
+
T ? S = T.test(d[L]) : S = (r ? d[L].toLowerCase() : d[L]).includes(h), S && C.push(L);
|
|
4963
|
+
}
|
|
4964
|
+
const f = [];
|
|
4965
|
+
let m = !1;
|
|
4966
|
+
for (const L of C) {
|
|
4967
|
+
const S = Math.max(0, L - s), A = Math.min(g - 1, L + s), N = f[f.length - 1];
|
|
4968
|
+
if (N && S <= N.end + 1)
|
|
4969
|
+
N.end = Math.max(N.end, A), N.hits.push(L);
|
|
4590
4970
|
else {
|
|
4591
|
-
if (
|
|
4592
|
-
|
|
4971
|
+
if (f.length >= c) {
|
|
4972
|
+
m = !0;
|
|
4593
4973
|
break;
|
|
4594
4974
|
}
|
|
4595
|
-
|
|
4975
|
+
f.push({ start: S, end: A, hits: [L] });
|
|
4596
4976
|
}
|
|
4597
4977
|
}
|
|
4598
|
-
const
|
|
4599
|
-
lineNumber:
|
|
4600
|
-
line:
|
|
4601
|
-
context: Array.from({ length:
|
|
4602
|
-
lineNumber:
|
|
4603
|
-
line:
|
|
4978
|
+
const E = f.map((L) => ({
|
|
4979
|
+
lineNumber: L.hits[0] + 1,
|
|
4980
|
+
line: d[L.hits[0]],
|
|
4981
|
+
context: Array.from({ length: L.end - L.start + 1 }, (S, A) => ({
|
|
4982
|
+
lineNumber: L.start + A + 1,
|
|
4983
|
+
line: d[L.start + A]
|
|
4604
4984
|
}))
|
|
4605
4985
|
})), v = [
|
|
4606
|
-
`无障碍树搜索结果 — 关键词: "${t}" | 总行数: ${
|
|
4986
|
+
`无障碍树搜索结果 — 关键词: "${t}" | 总行数: ${g} | 命中: ${C.length} 行 | 返回分组: ${E.length}`,
|
|
4607
4987
|
""
|
|
4608
4988
|
];
|
|
4609
|
-
return
|
|
4610
|
-
const
|
|
4611
|
-
v.push(`── 分组 ${
|
|
4612
|
-
const
|
|
4613
|
-
v.push(
|
|
4989
|
+
return E.length === 0 ? v.push("(未找到匹配项)") : (E.forEach((L, S) => {
|
|
4990
|
+
const A = f[S];
|
|
4991
|
+
v.push(`── 分组 ${S + 1}(第 ${A.start + 1}–${A.end + 1} 行)──`), L.context.forEach(({ lineNumber: N, line: M }) => {
|
|
4992
|
+
const O = A.hits.includes(N - 1), F = String(N).padStart(4);
|
|
4993
|
+
v.push(O ? `>>>${F} | ${M}` : ` ${F} | ${M}`);
|
|
4614
4994
|
}), v.push("");
|
|
4615
|
-
}),
|
|
4995
|
+
}), m && v.push(`⚠️ 命中过多,已截断至前 ${c} 个分组,建议缩小搜索范围`), v.push("提示:如需操作命中元素,使用其 #N 索引;如需查看完整树,请使用 browserState。")), {
|
|
4616
4996
|
text: v.join(`
|
|
4617
4997
|
`),
|
|
4618
|
-
matches:
|
|
4619
|
-
totalLines:
|
|
4620
|
-
matchCount:
|
|
4621
|
-
refMap:
|
|
4622
|
-
yaml:
|
|
4998
|
+
matches: E,
|
|
4999
|
+
totalLines: g,
|
|
5000
|
+
matchCount: C.length,
|
|
5001
|
+
refMap: u,
|
|
5002
|
+
yaml: p
|
|
4623
5003
|
};
|
|
4624
5004
|
}
|
|
4625
5005
|
function Diff() {
|
|
@@ -4629,54 +5009,54 @@ Diff.prototype = {
|
|
|
4629
5009
|
var i, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, o = r.callback;
|
|
4630
5010
|
typeof r == "function" && (o = r, r = {});
|
|
4631
5011
|
var a = this;
|
|
4632
|
-
function
|
|
4633
|
-
return
|
|
4634
|
-
o(
|
|
4635
|
-
}, 0), !0) :
|
|
5012
|
+
function s(v) {
|
|
5013
|
+
return v = a.postProcess(v, r), o ? (setTimeout(function() {
|
|
5014
|
+
o(v);
|
|
5015
|
+
}, 0), !0) : v;
|
|
4636
5016
|
}
|
|
4637
5017
|
e = this.castInput(e, r), n = this.castInput(n, r), e = this.removeEmpty(this.tokenize(e, r)), n = this.removeEmpty(this.tokenize(n, r));
|
|
4638
|
-
var c = n.length,
|
|
5018
|
+
var c = n.length, d = e.length, u = 1, p = c + d;
|
|
4639
5019
|
r.maxEditLength != null && (p = Math.min(p, r.maxEditLength));
|
|
4640
|
-
var
|
|
5020
|
+
var h = (i = r.timeout) !== null && i !== void 0 ? i : 1 / 0, g = Date.now() + h, y = [{
|
|
4641
5021
|
oldPos: -1,
|
|
4642
5022
|
lastComponent: void 0
|
|
4643
|
-
}],
|
|
4644
|
-
if (
|
|
4645
|
-
return
|
|
4646
|
-
var
|
|
4647
|
-
function
|
|
4648
|
-
for (var
|
|
4649
|
-
var
|
|
4650
|
-
|
|
4651
|
-
var
|
|
4652
|
-
if (
|
|
4653
|
-
var
|
|
4654
|
-
|
|
5023
|
+
}], T = this.extractCommon(y[0], n, e, 0, r);
|
|
5024
|
+
if (y[0].oldPos + 1 >= d && T + 1 >= c)
|
|
5025
|
+
return s(buildValues(a, y[0].lastComponent, n, e, a.useLongestToken));
|
|
5026
|
+
var C = -1 / 0, f = 1 / 0;
|
|
5027
|
+
function m() {
|
|
5028
|
+
for (var v = Math.max(C, -u); v <= Math.min(f, u); v += 2) {
|
|
5029
|
+
var L = void 0, S = y[v - 1], A = y[v + 1];
|
|
5030
|
+
S && (y[v - 1] = void 0);
|
|
5031
|
+
var N = !1;
|
|
5032
|
+
if (A) {
|
|
5033
|
+
var M = A.oldPos - v;
|
|
5034
|
+
N = A && 0 <= M && M < c;
|
|
4655
5035
|
}
|
|
4656
|
-
var
|
|
4657
|
-
if (!
|
|
4658
|
-
|
|
5036
|
+
var O = S && S.oldPos + 1 < d;
|
|
5037
|
+
if (!N && !O) {
|
|
5038
|
+
y[v] = void 0;
|
|
4659
5039
|
continue;
|
|
4660
5040
|
}
|
|
4661
|
-
if (!
|
|
4662
|
-
return
|
|
4663
|
-
|
|
5041
|
+
if (!O || N && S.oldPos < A.oldPos ? L = a.addToPath(A, !0, !1, 0, r) : L = a.addToPath(S, !1, !0, 1, r), T = a.extractCommon(L, n, e, v, r), L.oldPos + 1 >= d && T + 1 >= c)
|
|
5042
|
+
return s(buildValues(a, L.lastComponent, n, e, a.useLongestToken));
|
|
5043
|
+
y[v] = L, L.oldPos + 1 >= d && (f = Math.min(f, v - 1)), T + 1 >= c && (C = Math.max(C, v + 1));
|
|
4664
5044
|
}
|
|
4665
|
-
|
|
5045
|
+
u++;
|
|
4666
5046
|
}
|
|
4667
5047
|
if (o)
|
|
4668
|
-
(function
|
|
5048
|
+
(function v() {
|
|
4669
5049
|
setTimeout(function() {
|
|
4670
|
-
if (
|
|
5050
|
+
if (u > p || Date.now() > g)
|
|
4671
5051
|
return o();
|
|
4672
|
-
|
|
5052
|
+
m() || v();
|
|
4673
5053
|
}, 0);
|
|
4674
5054
|
})();
|
|
4675
5055
|
else
|
|
4676
|
-
for (;
|
|
4677
|
-
var
|
|
4678
|
-
if (
|
|
4679
|
-
return
|
|
5056
|
+
for (; u <= p && Date.now() <= g; ) {
|
|
5057
|
+
var E = m();
|
|
5058
|
+
if (E)
|
|
5059
|
+
return E;
|
|
4680
5060
|
}
|
|
4681
5061
|
},
|
|
4682
5062
|
addToPath: function t(e, n, i, r, o) {
|
|
@@ -4700,19 +5080,19 @@ Diff.prototype = {
|
|
|
4700
5080
|
};
|
|
4701
5081
|
},
|
|
4702
5082
|
extractCommon: function t(e, n, i, r, o) {
|
|
4703
|
-
for (var a = n.length,
|
|
4704
|
-
|
|
5083
|
+
for (var a = n.length, s = i.length, c = e.oldPos, d = c - r, u = 0; d + 1 < a && c + 1 < s && this.equals(i[c + 1], n[d + 1], o); )
|
|
5084
|
+
d++, c++, u++, o.oneChangePerToken && (e.lastComponent = {
|
|
4705
5085
|
count: 1,
|
|
4706
5086
|
previousComponent: e.lastComponent,
|
|
4707
5087
|
added: !1,
|
|
4708
5088
|
removed: !1
|
|
4709
5089
|
});
|
|
4710
|
-
return
|
|
4711
|
-
count:
|
|
5090
|
+
return u && !o.oneChangePerToken && (e.lastComponent = {
|
|
5091
|
+
count: u,
|
|
4712
5092
|
previousComponent: e.lastComponent,
|
|
4713
5093
|
added: !1,
|
|
4714
5094
|
removed: !1
|
|
4715
|
-
}), e.oldPos = c,
|
|
5095
|
+
}), e.oldPos = c, d;
|
|
4716
5096
|
},
|
|
4717
5097
|
equals: function t(e, n, i) {
|
|
4718
5098
|
return i.comparator ? i.comparator(e, n) : e === n || i.ignoreCase && e.toLowerCase() === n.toLowerCase();
|
|
@@ -4739,20 +5119,20 @@ function buildValues(t, e, n, i, r) {
|
|
|
4739
5119
|
for (var o = [], a; e; )
|
|
4740
5120
|
o.push(e), a = e.previousComponent, delete e.previousComponent, e = a;
|
|
4741
5121
|
o.reverse();
|
|
4742
|
-
for (var
|
|
4743
|
-
var p = o[
|
|
5122
|
+
for (var s = 0, c = o.length, d = 0, u = 0; s < c; s++) {
|
|
5123
|
+
var p = o[s];
|
|
4744
5124
|
if (p.removed)
|
|
4745
|
-
p.value = t.join(i.slice(
|
|
5125
|
+
p.value = t.join(i.slice(u, u + p.count)), u += p.count;
|
|
4746
5126
|
else {
|
|
4747
5127
|
if (!p.added && r) {
|
|
4748
|
-
var
|
|
4749
|
-
|
|
4750
|
-
var
|
|
4751
|
-
return
|
|
4752
|
-
}), p.value = t.join(
|
|
5128
|
+
var h = n.slice(d, d + p.count);
|
|
5129
|
+
h = h.map(function(g, y) {
|
|
5130
|
+
var T = i[u + y];
|
|
5131
|
+
return T.length > g.length ? T : g;
|
|
5132
|
+
}), p.value = t.join(h);
|
|
4753
5133
|
} else
|
|
4754
|
-
p.value = t.join(n.slice(
|
|
4755
|
-
|
|
5134
|
+
p.value = t.join(n.slice(d, d + p.count));
|
|
5135
|
+
d += p.count, p.added || (u += p.count);
|
|
4756
5136
|
}
|
|
4757
5137
|
}
|
|
4758
5138
|
return o;
|
|
@@ -4807,10 +5187,10 @@ function overlapCount(t, e) {
|
|
|
4807
5187
|
e[a] == e[o] && o++;
|
|
4808
5188
|
}
|
|
4809
5189
|
o = 0;
|
|
4810
|
-
for (var
|
|
4811
|
-
for (; o > 0 && t[
|
|
5190
|
+
for (var s = n; s < t.length; s++) {
|
|
5191
|
+
for (; o > 0 && t[s] != e[o]; )
|
|
4812
5192
|
o = r[o];
|
|
4813
|
-
t[
|
|
5193
|
+
t[s] == e[o] && o++;
|
|
4814
5194
|
}
|
|
4815
5195
|
return o;
|
|
4816
5196
|
}
|
|
@@ -4848,28 +5228,28 @@ wordDiff.postProcess = function(t, e) {
|
|
|
4848
5228
|
};
|
|
4849
5229
|
function dedupeWhitespaceInChangeObjects(t, e, n, i) {
|
|
4850
5230
|
if (e && n) {
|
|
4851
|
-
var r = e.value.match(/^\s*/)[0], o = e.value.match(/\s*$/)[0], a = n.value.match(/^\s*/)[0],
|
|
5231
|
+
var r = e.value.match(/^\s*/)[0], o = e.value.match(/\s*$/)[0], a = n.value.match(/^\s*/)[0], s = n.value.match(/\s*$/)[0];
|
|
4852
5232
|
if (t) {
|
|
4853
5233
|
var c = longestCommonPrefix(r, a);
|
|
4854
5234
|
t.value = replaceSuffix(t.value, a, c), e.value = removePrefix(e.value, c), n.value = removePrefix(n.value, c);
|
|
4855
5235
|
}
|
|
4856
5236
|
if (i) {
|
|
4857
|
-
var
|
|
4858
|
-
i.value = replacePrefix(i.value,
|
|
5237
|
+
var d = longestCommonSuffix(o, s);
|
|
5238
|
+
i.value = replacePrefix(i.value, s, d), e.value = removeSuffix(e.value, d), n.value = removeSuffix(n.value, d);
|
|
4859
5239
|
}
|
|
4860
5240
|
} else if (n)
|
|
4861
5241
|
t && (n.value = n.value.replace(/^\s*/, "")), i && (i.value = i.value.replace(/^\s*/, ""));
|
|
4862
5242
|
else if (t && i) {
|
|
4863
|
-
var
|
|
4864
|
-
e.value = removePrefix(e.value,
|
|
4865
|
-
var
|
|
4866
|
-
e.value = removeSuffix(e.value,
|
|
5243
|
+
var u = i.value.match(/^\s*/)[0], p = e.value.match(/^\s*/)[0], h = e.value.match(/\s*$/)[0], g = longestCommonPrefix(u, p);
|
|
5244
|
+
e.value = removePrefix(e.value, g);
|
|
5245
|
+
var y = longestCommonSuffix(removePrefix(u, g), h);
|
|
5246
|
+
e.value = removeSuffix(e.value, y), i.value = replacePrefix(i.value, u, y), t.value = replaceSuffix(t.value, u, u.slice(0, u.length - y.length));
|
|
4867
5247
|
} else if (i) {
|
|
4868
|
-
var
|
|
4869
|
-
e.value = removeSuffix(e.value,
|
|
5248
|
+
var T = i.value.match(/^\s*/)[0], C = e.value.match(/\s*$/)[0], f = maximumOverlap(C, T);
|
|
5249
|
+
e.value = removeSuffix(e.value, f);
|
|
4870
5250
|
} else if (t) {
|
|
4871
|
-
var
|
|
4872
|
-
e.value = removePrefix(e.value,
|
|
5251
|
+
var m = t.value.match(/\s*$/)[0], E = e.value.match(/^\s*/)[0], v = maximumOverlap(m, E);
|
|
5252
|
+
e.value = removePrefix(e.value, v);
|
|
4873
5253
|
}
|
|
4874
5254
|
}
|
|
4875
5255
|
var wordWithSpaceDiff = new Diff();
|
|
@@ -4941,11 +5321,11 @@ function canonicalize(t, e, n, i, r) {
|
|
|
4941
5321
|
}
|
|
4942
5322
|
if (t && t.toJSON && (t = t.toJSON()), _typeof(t) === "object" && t !== null) {
|
|
4943
5323
|
e.push(t), a = {}, n.push(a);
|
|
4944
|
-
var
|
|
5324
|
+
var s = [], c;
|
|
4945
5325
|
for (c in t)
|
|
4946
|
-
Object.prototype.hasOwnProperty.call(t, c) &&
|
|
4947
|
-
for (
|
|
4948
|
-
c =
|
|
5326
|
+
Object.prototype.hasOwnProperty.call(t, c) && s.push(c);
|
|
5327
|
+
for (s.sort(), o = 0; o < s.length; o += 1)
|
|
5328
|
+
c = s[o], a[c] = canonicalize(t[c], e, n, i, c);
|
|
4949
5329
|
e.pop(), n.pop();
|
|
4950
5330
|
} else
|
|
4951
5331
|
a = t;
|
|
@@ -4973,18 +5353,18 @@ class PageStateCache {
|
|
|
4973
5353
|
*/
|
|
4974
5354
|
update(e, n) {
|
|
4975
5355
|
const i = this.isFullRefresh(e), r = this.prev?.url ?? "";
|
|
4976
|
-
let o = 0, a = 0,
|
|
5356
|
+
let o = 0, a = 0, s = "";
|
|
4977
5357
|
if (!i && this.prev) {
|
|
4978
|
-
const c = diffLines(this.prev.yaml, n),
|
|
4979
|
-
c.forEach((
|
|
4980
|
-
if (!
|
|
4981
|
-
const p =
|
|
5358
|
+
const c = diffLines(this.prev.yaml, n), d = [];
|
|
5359
|
+
c.forEach((u) => {
|
|
5360
|
+
if (!u.added && !u.removed) return;
|
|
5361
|
+
const p = u.value.split(`
|
|
4982
5362
|
`).filter(Boolean);
|
|
4983
|
-
|
|
4984
|
-
}),
|
|
5363
|
+
u.added ? (o += p.length, p.forEach((h) => d.push(`+ ${h}`))) : (a += p.length, p.forEach((h) => d.push(`- ${h}`)));
|
|
5364
|
+
}), s = d.join(`
|
|
4985
5365
|
`);
|
|
4986
5366
|
}
|
|
4987
|
-
return this.prev = { url: e, yaml: n }, { isFullRefresh: i, prevUrl: r, addedLines: o, removedLines: a, diffText:
|
|
5367
|
+
return this.prev = { url: e, yaml: n }, { isFullRefresh: i, prevUrl: r, addedLines: o, removedLines: a, diffText: s };
|
|
4988
5368
|
}
|
|
4989
5369
|
/** 强制清空缓存(页面刷新 / 手动重置场景) */
|
|
4990
5370
|
invalidate() {
|
|
@@ -4992,114 +5372,114 @@ class PageStateCache {
|
|
|
4992
5372
|
}
|
|
4993
5373
|
}
|
|
4994
5374
|
function computeBorderGeometry(t, e, n, i) {
|
|
4995
|
-
const r = Math.max(1, Math.min(t, e)), o = Math.min(n, 20),
|
|
5375
|
+
const r = Math.max(1, Math.min(t, e)), o = Math.min(n, 20), s = Math.min(o + i, r), c = Math.min(s, Math.floor(t / 2)), d = Math.min(s, Math.floor(e / 2)), u = (b) => b / t * 2 - 1, p = (b) => b / e * 2 - 1, h = 0, g = t, y = 0, T = e, C = c, f = t - c, m = d, E = e - d, v = u(h), L = u(g), S = p(y), A = p(T), N = u(C), M = u(f), O = p(m), F = p(E), B = 0, J = 0, G = 1, Q = 1, ee = c / t, te = 1 - c / t, W = d / e, Z = 1 - d / e, ce = new Float32Array([
|
|
4996
5376
|
// Top strip
|
|
5377
|
+
v,
|
|
5378
|
+
S,
|
|
4997
5379
|
L,
|
|
5380
|
+
S,
|
|
4998
5381
|
v,
|
|
4999
|
-
|
|
5382
|
+
O,
|
|
5000
5383
|
v,
|
|
5384
|
+
O,
|
|
5001
5385
|
L,
|
|
5002
|
-
|
|
5386
|
+
S,
|
|
5003
5387
|
L,
|
|
5004
|
-
|
|
5005
|
-
A,
|
|
5006
|
-
v,
|
|
5007
|
-
A,
|
|
5008
|
-
N,
|
|
5388
|
+
O,
|
|
5009
5389
|
// Bottom strip
|
|
5390
|
+
v,
|
|
5391
|
+
F,
|
|
5010
5392
|
L,
|
|
5011
|
-
|
|
5393
|
+
F,
|
|
5394
|
+
v,
|
|
5395
|
+
A,
|
|
5396
|
+
v,
|
|
5012
5397
|
A,
|
|
5013
|
-
$,
|
|
5014
5398
|
L,
|
|
5015
|
-
|
|
5399
|
+
F,
|
|
5016
5400
|
L,
|
|
5017
|
-
y,
|
|
5018
|
-
A,
|
|
5019
|
-
$,
|
|
5020
5401
|
A,
|
|
5021
|
-
y,
|
|
5022
5402
|
// Left strip
|
|
5023
|
-
|
|
5403
|
+
v,
|
|
5404
|
+
O,
|
|
5024
5405
|
N,
|
|
5025
|
-
|
|
5406
|
+
O,
|
|
5407
|
+
v,
|
|
5408
|
+
F,
|
|
5409
|
+
v,
|
|
5410
|
+
F,
|
|
5026
5411
|
N,
|
|
5412
|
+
O,
|
|
5413
|
+
N,
|
|
5414
|
+
F,
|
|
5415
|
+
// Right strip
|
|
5416
|
+
M,
|
|
5417
|
+
O,
|
|
5027
5418
|
L,
|
|
5028
|
-
|
|
5029
|
-
L,
|
|
5030
|
-
$,
|
|
5419
|
+
O,
|
|
5031
5420
|
M,
|
|
5032
|
-
|
|
5421
|
+
F,
|
|
5033
5422
|
M,
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
R,
|
|
5041
|
-
$,
|
|
5042
|
-
R,
|
|
5043
|
-
$,
|
|
5044
|
-
A,
|
|
5045
|
-
N,
|
|
5046
|
-
A,
|
|
5047
|
-
$
|
|
5048
|
-
]), s = new Float32Array([
|
|
5423
|
+
F,
|
|
5424
|
+
L,
|
|
5425
|
+
O,
|
|
5426
|
+
L,
|
|
5427
|
+
F
|
|
5428
|
+
]), l = new Float32Array([
|
|
5049
5429
|
// Top strip
|
|
5050
5430
|
B,
|
|
5051
|
-
|
|
5052
|
-
W,
|
|
5053
|
-
K,
|
|
5054
|
-
B,
|
|
5431
|
+
J,
|
|
5055
5432
|
G,
|
|
5433
|
+
J,
|
|
5056
5434
|
B,
|
|
5057
|
-
G,
|
|
5058
5435
|
W,
|
|
5059
|
-
|
|
5436
|
+
B,
|
|
5060
5437
|
W,
|
|
5061
5438
|
G,
|
|
5439
|
+
J,
|
|
5440
|
+
G,
|
|
5441
|
+
W,
|
|
5062
5442
|
// Bottom strip
|
|
5063
5443
|
B,
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5444
|
+
Z,
|
|
5445
|
+
G,
|
|
5446
|
+
Z,
|
|
5067
5447
|
B,
|
|
5068
|
-
|
|
5448
|
+
Q,
|
|
5069
5449
|
B,
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5450
|
+
Q,
|
|
5451
|
+
G,
|
|
5452
|
+
Z,
|
|
5453
|
+
G,
|
|
5454
|
+
Q,
|
|
5075
5455
|
// Left strip
|
|
5076
5456
|
B,
|
|
5077
|
-
|
|
5457
|
+
W,
|
|
5078
5458
|
ee,
|
|
5079
|
-
|
|
5459
|
+
W,
|
|
5080
5460
|
B,
|
|
5081
|
-
|
|
5461
|
+
Z,
|
|
5082
5462
|
B,
|
|
5083
|
-
|
|
5463
|
+
Z,
|
|
5084
5464
|
ee,
|
|
5085
|
-
|
|
5465
|
+
W,
|
|
5086
5466
|
ee,
|
|
5087
|
-
|
|
5467
|
+
Z,
|
|
5088
5468
|
// Right strip
|
|
5089
5469
|
te,
|
|
5090
|
-
G,
|
|
5091
5470
|
W,
|
|
5092
5471
|
G,
|
|
5472
|
+
W,
|
|
5093
5473
|
te,
|
|
5094
|
-
|
|
5474
|
+
Z,
|
|
5095
5475
|
te,
|
|
5096
|
-
|
|
5097
|
-
W,
|
|
5476
|
+
Z,
|
|
5098
5477
|
G,
|
|
5099
5478
|
W,
|
|
5100
|
-
|
|
5479
|
+
G,
|
|
5480
|
+
Z
|
|
5101
5481
|
]);
|
|
5102
|
-
return { positions: ce, uvs:
|
|
5482
|
+
return { positions: ce, uvs: l };
|
|
5103
5483
|
}
|
|
5104
5484
|
function compileShader(t, e, n) {
|
|
5105
5485
|
const i = t.createShader(e);
|
|
@@ -5298,23 +5678,23 @@ class Motion {
|
|
|
5298
5678
|
resize(e, n, i) {
|
|
5299
5679
|
if (this.disposed) throw new Error("Motion instance has been disposed.");
|
|
5300
5680
|
if (this.options.width = e, this.options.height = n, i && (this.options.ratio = i), !this.running) return;
|
|
5301
|
-
const { gl: r, program: o, vao: a, positionBuffer:
|
|
5302
|
-
this.canvas.style.width = `${e}px`, this.canvas.style.height = `${n}px`, (this.canvas.width !== p || this.canvas.height !==
|
|
5303
|
-
const { positions:
|
|
5681
|
+
const { gl: r, program: o, vao: a, positionBuffer: s, uvBuffer: c, uResolution: d } = this.glr, u = i ?? this.options.ratio ?? window.devicePixelRatio ?? 1, p = Math.max(1, Math.floor(e * u)), h = Math.max(1, Math.floor(n * u));
|
|
5682
|
+
this.canvas.style.width = `${e}px`, this.canvas.style.height = `${n}px`, (this.canvas.width !== p || this.canvas.height !== h) && (this.canvas.width = p, this.canvas.height = h), r.viewport(0, 0, this.canvas.width, this.canvas.height), this.checkGLError(r, "resize: after viewport setup");
|
|
5683
|
+
const { positions: g, uvs: y } = computeBorderGeometry(
|
|
5304
5684
|
this.canvas.width,
|
|
5305
5685
|
this.canvas.height,
|
|
5306
|
-
this.options.borderWidth *
|
|
5307
|
-
this.options.glowWidth *
|
|
5686
|
+
this.options.borderWidth * u,
|
|
5687
|
+
this.options.glowWidth * u
|
|
5308
5688
|
);
|
|
5309
|
-
r.bindVertexArray(a), r.bindBuffer(r.ARRAY_BUFFER,
|
|
5310
|
-
const
|
|
5311
|
-
r.enableVertexAttribArray(
|
|
5312
|
-
const
|
|
5313
|
-
r.enableVertexAttribArray(
|
|
5314
|
-
const
|
|
5315
|
-
this.lastTime =
|
|
5316
|
-
const
|
|
5317
|
-
this.render(
|
|
5689
|
+
r.bindVertexArray(a), r.bindBuffer(r.ARRAY_BUFFER, s), r.bufferData(r.ARRAY_BUFFER, g, r.STATIC_DRAW);
|
|
5690
|
+
const T = r.getAttribLocation(o, "aPosition");
|
|
5691
|
+
r.enableVertexAttribArray(T), r.vertexAttribPointer(T, 2, r.FLOAT, !1, 0, 0), this.checkGLError(r, "resize: after position buffer update"), r.bindBuffer(r.ARRAY_BUFFER, c), r.bufferData(r.ARRAY_BUFFER, y, r.STATIC_DRAW);
|
|
5692
|
+
const C = r.getAttribLocation(o, "aUV");
|
|
5693
|
+
r.enableVertexAttribArray(C), r.vertexAttribPointer(C, 2, r.FLOAT, !1, 0, 0), this.checkGLError(r, "resize: after UV buffer update"), r.useProgram(o), r.uniform2f(d, this.canvas.width, this.canvas.height), r.uniform1f(this.glr.uBorderWidth, this.options.borderWidth * u), r.uniform1f(this.glr.uGlowWidth, this.options.glowWidth * u), r.uniform1f(this.glr.uBorderRadius, this.options.borderRadius * u), this.checkGLError(r, "resize: after uniform updates");
|
|
5694
|
+
const f = performance.now();
|
|
5695
|
+
this.lastTime = f;
|
|
5696
|
+
const m = (f - this.startTime) * 1e-3;
|
|
5697
|
+
this.render(m);
|
|
5318
5698
|
}
|
|
5319
5699
|
/**
|
|
5320
5700
|
* Automatically resizes the canvas to match the dimensions of the given element.
|
|
@@ -5388,36 +5768,36 @@ class Motion {
|
|
|
5388
5768
|
this.checkGLError(e, "setupGL: after createProgram");
|
|
5389
5769
|
const i = e.createVertexArray();
|
|
5390
5770
|
e.bindVertexArray(i), this.checkGLError(e, "setupGL: after VAO creation");
|
|
5391
|
-
const r = this.canvas.width || 2, o = this.canvas.height || 2, { positions: a, uvs:
|
|
5771
|
+
const r = this.canvas.width || 2, o = this.canvas.height || 2, { positions: a, uvs: s } = computeBorderGeometry(
|
|
5392
5772
|
r,
|
|
5393
5773
|
o,
|
|
5394
5774
|
this.options.borderWidth,
|
|
5395
5775
|
this.options.glowWidth
|
|
5396
5776
|
), c = e.createBuffer();
|
|
5397
5777
|
e.bindBuffer(e.ARRAY_BUFFER, c), e.bufferData(e.ARRAY_BUFFER, a, e.STATIC_DRAW);
|
|
5398
|
-
const
|
|
5399
|
-
e.enableVertexAttribArray(
|
|
5400
|
-
const
|
|
5401
|
-
e.bindBuffer(e.ARRAY_BUFFER,
|
|
5778
|
+
const d = e.getAttribLocation(n, "aPosition");
|
|
5779
|
+
e.enableVertexAttribArray(d), e.vertexAttribPointer(d, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after position buffer setup");
|
|
5780
|
+
const u = e.createBuffer();
|
|
5781
|
+
e.bindBuffer(e.ARRAY_BUFFER, u), e.bufferData(e.ARRAY_BUFFER, s, e.STATIC_DRAW);
|
|
5402
5782
|
const p = e.getAttribLocation(n, "aUV");
|
|
5403
5783
|
e.enableVertexAttribArray(p), e.vertexAttribPointer(p, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after UV buffer setup");
|
|
5404
|
-
const
|
|
5405
|
-
e.useProgram(n), e.uniform1f(
|
|
5406
|
-
const
|
|
5407
|
-
for (let
|
|
5408
|
-
e.uniform3f(e.getUniformLocation(n, `uColors[${
|
|
5784
|
+
const h = e.getUniformLocation(n, "uResolution"), g = e.getUniformLocation(n, "uTime"), y = e.getUniformLocation(n, "uBorderWidth"), T = e.getUniformLocation(n, "uGlowWidth"), C = e.getUniformLocation(n, "uBorderRadius"), f = e.getUniformLocation(n, "uColors"), m = e.getUniformLocation(n, "uGlowExponent"), E = e.getUniformLocation(n, "uGlowFactor");
|
|
5785
|
+
e.useProgram(n), e.uniform1f(y, this.options.borderWidth), e.uniform1f(T, this.options.glowWidth), e.uniform1f(C, this.options.borderRadius), this.options.mode === "dark" ? (e.uniform1f(m, 2), e.uniform1f(E, 1.8)) : (e.uniform1f(m, 1), e.uniform1f(E, 1));
|
|
5786
|
+
const v = (this.options.colors || DEFAULT_COLORS).map(parseColor);
|
|
5787
|
+
for (let L = 0; L < v.length; L++)
|
|
5788
|
+
e.uniform3f(e.getUniformLocation(n, `uColors[${L}]`), ...v[L]);
|
|
5409
5789
|
this.checkGLError(e, "setupGL: after uniform setup"), e.bindVertexArray(null), e.bindBuffer(e.ARRAY_BUFFER, null), this.glr = {
|
|
5410
5790
|
gl: e,
|
|
5411
5791
|
program: n,
|
|
5412
5792
|
vao: i,
|
|
5413
5793
|
positionBuffer: c,
|
|
5414
|
-
uvBuffer:
|
|
5415
|
-
uResolution:
|
|
5416
|
-
uTime:
|
|
5417
|
-
uBorderWidth:
|
|
5418
|
-
uGlowWidth:
|
|
5419
|
-
uBorderRadius:
|
|
5420
|
-
uColors:
|
|
5794
|
+
uvBuffer: u,
|
|
5795
|
+
uResolution: h,
|
|
5796
|
+
uTime: g,
|
|
5797
|
+
uBorderWidth: y,
|
|
5798
|
+
uGlowWidth: T,
|
|
5799
|
+
uBorderRadius: C,
|
|
5800
|
+
uColors: f
|
|
5421
5801
|
};
|
|
5422
5802
|
}
|
|
5423
5803
|
render(e) {
|
|
@@ -5507,31 +5887,15 @@ const injectStyles = `
|
|
|
5507
5887
|
z-index: 10000;
|
|
5508
5888
|
}
|
|
5509
5889
|
|
|
5510
|
-
.webmcp-page-agent-cursorBorder {
|
|
5511
|
-
position: absolute;
|
|
5512
|
-
width: 100%;
|
|
5513
|
-
height: 100%;
|
|
5514
|
-
background: linear-gradient(45deg, rgb(57, 182, 255), rgb(189, 69, 251));
|
|
5515
|
-
mask-image: url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");
|
|
5516
|
-
mask-size: 100% 100%;
|
|
5517
|
-
mask-repeat: no-repeat;
|
|
5518
|
-
|
|
5519
|
-
transform-origin: center;
|
|
5520
|
-
transform: rotate(-90deg) scale(0.8);
|
|
5521
|
-
margin-left: -10px;
|
|
5522
|
-
margin-top: -18px;
|
|
5523
|
-
}
|
|
5524
|
-
|
|
5525
5890
|
.webmcp-page-agent-cursorFilling {
|
|
5526
5891
|
position: absolute;
|
|
5527
5892
|
width: 100%;
|
|
5528
5893
|
height: 100%;
|
|
5529
|
-
background: url("data:image/svg+xml,%
|
|
5530
|
-
|
|
5894
|
+
background: url("data:image/svg+xml,%3Csvg%20viewBox%3D%270%200%2079.0834%2079.4553%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20%20width%3D%2779.083374%27%20height%3D%2779.455322%27%20fill%3D%27none%27%20%3E--%3Cdefs%3E%3Cfilter%20id%3D%27filter_0%27%20width%3D%2779.083374%27%20height%3D%2779.455322%27%20x%3D%270.000000%27%20y%3D%270.000000%27%20filterUnits%3D%27userSpaceOnUse%27%20%20color-interpolation-filters%3D%27sRGB%27%3E%3CfeFlood%20flood-opacity%3D%270%27%20result%3D%27BackgroundImageFix%27%20%2F%3E%3CfeOffset%20dx%3D%276.000000%27%20dy%3D%276.000000%27%20in%3D%27SourceAlpha%27%20%2F%3E%3CfeGaussianBlur%20stdDeviation%3D%276.66666651%27%20%2F%3E%3CfeColorMatrix%20type%3D%27matrix%27%20values%3D%270%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200.18%200%20%27%20%2F%3E%3CfeBlend%20result%3D%27effect_dropShadow_1%27%20in2%3D%27BackgroundImageFix%27%20mode%3D%27normal%27%20%2F%3E%3CfeBlend%20result%3D%27shape%27%20in%3D%27SourceGraphic%27%20in2%3D%27effect_dropShadow_1%27%20mode%3D%27normal%27%20%2F%3E%3C%2Ffilter%3E%3ClinearGradient%20id%3D%27paint_linear_0%27%20x1%3D%2718.4743214%27%20x2%3D%2718.4213886%27%20y1%3D%27-1.86264515e-09%27%20y2%3D%2734.9221306%27%20gradientUnits%3D%27userSpaceOnUse%27%3E%3Cstop%20stop-color%3D%27rgb%28255%2C181%2C96%29%27%20offset%3D%270%27%20stop-opacity%3D%271%27%20%2F%3E%3Cstop%20stop-color%3D%27rgb%28255%2C120%2C114%29%27%20offset%3D%270.5%27%20stop-opacity%3D%271%27%20%2F%3E%3Cstop%20stop-color%3D%27rgb%28241%2C109%2C237%29%27%20offset%3D%271%27%20stop-opacity%3D%271%27%20%2F%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Cg%20filter%3D%27url%28%23filter_0%29%27%3E%3Cpath%20d%3D%27M20.2632%203.57771L34.6257%2032.3027C35.4444%2033.9402%2033.8152%2035.7258%2032.1097%2035.0603L19.2014%2030.0229C18.7339%2029.8404%2018.2148%2029.8404%2017.7472%2030.0229L4.83891%2035.0603C3.13343%2035.7258%201.50423%2033.9402%202.32297%2032.3027L16.6855%203.57771C17.4225%202.10361%2019.5261%202.10361%2020.2632%203.57771Z%27%20fill%3D%27url%28%23paint_linear_0%29%27%20fill-rule%3D%27evenodd%27%20transform%3D%27matrix%280.719908%2C-0.69407%2C0.69407%2C0.719908%2C2.00256%2C28.0095%29%27%20%2F%3E%3Cpath%20d%3D%27M37.2169%2032.6848C37.1578%2032.189%2037.0096%2031.7039%2036.7723%2031.2294L22.4098%202.5044C22.1973%202.07946%2021.9328%201.70554%2021.6163%201.38261C21.3524%201.11342%2021.0524%200.879671%2020.7162%200.681366C20.3925%200.490407%2020.0558%200.34434%2019.7061%200.243163C19.312%200.129145%2018.9014%200.0721366%2018.4743%200.0721366C18.0472%200.0721366%2017.6367%200.129145%2017.2426%200.243163C16.8929%200.34434%2016.5562%200.490407%2016.2324%200.681366C15.8962%200.879671%2015.5962%201.11342%2015.3323%201.38261C15.0158%201.70553%2014.7513%202.07946%2014.5388%202.5044L0.176342%2031.2294C-0.0609121%2031.7039%20-0.209128%2032.189%20-0.268305%2032.6848C-0.316251%2033.0865%20-0.305747%2033.4951%20-0.236792%2033.9108C-0.171059%2034.307%20-0.0570567%2034.6809%200.105216%2035.0326C0.292784%2035.4391%200.544845%2035.8158%200.861397%2036.1627C1.17794%2036.5097%201.53001%2036.7951%201.91761%2037.0191C2.25297%2037.2128%202.61492%2037.3606%203.00348%2037.4623C3.41106%2037.5689%203.81704%2037.6168%204.22142%2037.6058C4.72053%2037.5922%205.21719%2037.4889%205.71141%2037.2961L18.4743%2032.3154L31.2372%2037.2961C31.7315%2037.4889%2032.2281%2037.5922%2032.7272%2037.6058C33.1316%2037.6168%2033.5376%2037.5689%2033.9452%2037.4623C34.3337%2037.3606%2034.6957%2037.2128%2035.0311%2037.0191C35.4187%2036.7951%2035.7707%2036.5097%2036.0873%2036.1627C36.4038%2035.8158%2036.6558%2035.4391%2036.8434%2035.0327C37.0057%2034.681%2037.1197%2034.307%2037.1854%2033.9108C37.2544%2033.4951%2037.2649%2033.0865%2037.2169%2032.6848ZM34.6257%2032.3027L20.2632%203.57771C19.5261%202.10361%2017.4225%202.10361%2016.6855%203.57771L2.32297%2032.3027C1.50423%2033.9402%203.13343%2035.7258%204.83891%2035.0603L17.7472%2030.0229C18.2148%2029.8404%2018.7339%2029.8404%2019.2014%2030.0229L32.1097%2035.0603C33.8152%2035.7258%2035.4444%2033.9402%2034.6257%2032.3027Z%27%20fill%3D%27rgb%28255%2C255%2C255%29%27%20fill-rule%3D%27evenodd%27%20transform%3D%27matrix%280.719908%2C-0.69407%2C0.69407%2C0.719908%2C2.00256%2C28.0095%29%27%20%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E");
|
|
5895
|
+
background-size: 100% 100%;
|
|
5531
5896
|
background-repeat: no-repeat;
|
|
5532
5897
|
|
|
5533
5898
|
transform-origin: center;
|
|
5534
|
-
transform: rotate(-90deg) scale(0.8);
|
|
5535
5899
|
margin-left: -10px;
|
|
5536
5900
|
margin-top: -18px;
|
|
5537
5901
|
}
|
|
@@ -5591,7 +5955,10 @@ class SimulatorMask extends EventTarget {
|
|
|
5591
5955
|
try {
|
|
5592
5956
|
const a = new Motion({
|
|
5593
5957
|
mode: isPageDark() ? "dark" : "light",
|
|
5594
|
-
styles: { position: "absolute", inset: "0" }
|
|
5958
|
+
styles: { position: "absolute", inset: "0" },
|
|
5959
|
+
glowWidth: 80,
|
|
5960
|
+
borderWidth: 8,
|
|
5961
|
+
colors: ["rgb(121, 216, 247)", "rgb(171, 219, 110)", "rgb(252, 188, 114)", "rgb(235, 117, 231)"]
|
|
5595
5962
|
});
|
|
5596
5963
|
this.motion = a, this.wrapper.appendChild(a.element), a.autoResize(this.wrapper);
|
|
5597
5964
|
} catch (a) {
|
|
@@ -5604,8 +5971,8 @@ class SimulatorMask extends EventTarget {
|
|
|
5604
5971
|
(a) => this.wrapper.addEventListener(a, e)
|
|
5605
5972
|
), this.#s(), document.body.appendChild(this.wrapper), this.#a();
|
|
5606
5973
|
const n = (a) => {
|
|
5607
|
-
const { x:
|
|
5608
|
-
this.setCursorPosition(
|
|
5974
|
+
const { x: s, y: c } = a.detail;
|
|
5975
|
+
this.setCursorPosition(s, c);
|
|
5609
5976
|
}, i = () => {
|
|
5610
5977
|
this.triggerClickAnimation();
|
|
5611
5978
|
}, r = () => {
|
|
@@ -5628,9 +5995,7 @@ class SimulatorMask extends EventTarget {
|
|
|
5628
5995
|
const e = document.createElement("div");
|
|
5629
5996
|
e.className = "webmcp-page-agent-cursorRipple", this.#e.appendChild(e);
|
|
5630
5997
|
const n = document.createElement("div");
|
|
5631
|
-
n.className = "webmcp-page-agent-cursorFilling", this.#e.appendChild(n);
|
|
5632
|
-
const i = document.createElement("div");
|
|
5633
|
-
i.className = "webmcp-page-agent-cursorBorder", this.#e.appendChild(i), this.wrapper.appendChild(this.#e);
|
|
5998
|
+
n.className = "webmcp-page-agent-cursorFilling", this.#e.appendChild(n), this.wrapper.appendChild(this.#e);
|
|
5634
5999
|
}
|
|
5635
6000
|
#a() {
|
|
5636
6001
|
if (this.#i) return;
|
|
@@ -5656,55 +6021,18 @@ class SimulatorMask extends EventTarget {
|
|
|
5656
6021
|
dispose() {
|
|
5657
6022
|
this.#i = !0, this.motion?.dispose(), this.wrapper.remove(), this.dispatchEvent(new Event("dispose"));
|
|
5658
6023
|
}
|
|
6024
|
+
// 根据目标元素大小,在 wrapper 添加绝对定位边框:2px 宽、与目标间距 2px,对角渐变 (0,0 → 1,1)
|
|
6025
|
+
borderElement(e) {
|
|
6026
|
+
if (!e) return;
|
|
6027
|
+
this.wrapper.querySelector(".webmcp-page-agent-border")?.remove();
|
|
6028
|
+
const n = e.getBoundingClientRect(), i = 2, r = 2, o = i + r, a = document.createElement("div");
|
|
6029
|
+
a.className = "webmcp-page-agent-border", a.style.position = "absolute", a.style.left = `${n.left - o}px`, a.style.top = `${n.top - o}px`, a.style.width = `${n.width + o * 2}px`, a.style.height = `${n.height + o * 2}px`, a.style.boxSizing = "border-box", a.style.pointerEvents = "none", a.style.zIndex = "10000", a.style.border = `${r}px solid transparent`, a.style.borderImageSource = "linear-gradient(to bottom right, #79D8F7, #ABDB6E, #FCBC72, #FA8682, #EB75E7)", a.style.borderImageSlice = "1", a.style.borderImageWidth = `${r}px`, this.wrapper.appendChild(a);
|
|
6030
|
+
}
|
|
6031
|
+
removeBorderElement() {
|
|
6032
|
+
this.wrapper.querySelector(".webmcp-page-agent-border")?.remove();
|
|
6033
|
+
}
|
|
5659
6034
|
}
|
|
5660
|
-
const
|
|
5661
|
-
// W3C ARIA 标准(最可靠,框架无关)
|
|
5662
|
-
'[role="alert"]',
|
|
5663
|
-
'[aria-invalid="true"]',
|
|
5664
|
-
// Tiny3 / Lego(华为云)
|
|
5665
|
-
".ti3-unifyvalid-error",
|
|
5666
|
-
".ti3-error",
|
|
5667
|
-
".ti-error",
|
|
5668
|
-
".lego-text-error",
|
|
5669
|
-
".lego-error",
|
|
5670
|
-
// Element UI / Element Plus
|
|
5671
|
-
".el-form-item__error",
|
|
5672
|
-
// Ant Design
|
|
5673
|
-
".ant-form-item-explain-error",
|
|
5674
|
-
// Bootstrap
|
|
5675
|
-
".is-invalid",
|
|
5676
|
-
".invalid-feedback",
|
|
5677
|
-
// Angular
|
|
5678
|
-
".ng-invalid",
|
|
5679
|
-
// 通用命名约定
|
|
5680
|
-
".error-msg",
|
|
5681
|
-
".error-message",
|
|
5682
|
-
".error-text",
|
|
5683
|
-
".field-error",
|
|
5684
|
-
".form-error",
|
|
5685
|
-
".is-error",
|
|
5686
|
-
".has-error",
|
|
5687
|
-
".validate-error",
|
|
5688
|
-
".valid-error"
|
|
5689
|
-
], DEFAULT_DIALOG_SELECTORS = [
|
|
5690
|
-
// W3C ARIA 标准
|
|
5691
|
-
'[role="dialog"]',
|
|
5692
|
-
'[role="alertdialog"]',
|
|
5693
|
-
// Tiny3 / Lego(华为云)
|
|
5694
|
-
'[class*="ti3-modal"]',
|
|
5695
|
-
'[class*="ti3-message-box"]',
|
|
5696
|
-
// Element UI / Element Plus
|
|
5697
|
-
'[class*="el-dialog"]',
|
|
5698
|
-
'[class*="el-message-box"]',
|
|
5699
|
-
// Ant Design
|
|
5700
|
-
'[class*="ant-modal"]',
|
|
5701
|
-
// Bootstrap
|
|
5702
|
-
'[class*="modal-content"]',
|
|
5703
|
-
// Vuetify
|
|
5704
|
-
'[class*="v-dialog"]',
|
|
5705
|
-
// Naive UI
|
|
5706
|
-
'[class*="n-modal"]'
|
|
5707
|
-
], inputSchema = z.object({
|
|
6035
|
+
const inputSchema = z.object({
|
|
5708
6036
|
action: z.enum(["browserState", "click", "fill", "select", "scroll", "executeJavascript", "searchTree"]).describe(`执行的动作名称, 每一次执行 'click', 'fill', 'select'动作之前,**必须**要先调用 'browserState' 去获取页面的最新状态。
|
|
5709
6037
|
browserState: '查询整个页面的浏览器状态;返回页面的标题、URL、YAML格式的语义化页面树',
|
|
5710
6038
|
click: '根据元素索引点击;',
|
|
@@ -5729,86 +6057,90 @@ const DEFAULT_ERROR_SELECTORS = [
|
|
|
5729
6057
|
responseMode: z.enum(["full", "diff", "both"]).optional().default("diff").describe(
|
|
5730
6058
|
"返回浏览器状态的模式。full: 仅返回当前全量 A11y 树;diff: 仅返回与上一次状态的增量差异;both: 同时返回全量 A11y 树与增量差异。默认值为 diff。"
|
|
5731
6059
|
)
|
|
5732
|
-
});
|
|
5733
|
-
function
|
|
5734
|
-
return t.
|
|
5735
|
-
}
|
|
5736
|
-
function
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
const n =
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
let i = !1, r;
|
|
5750
|
-
const o = () => {
|
|
5751
|
-
i || (i = !0, a.disconnect(), r && clearTimeout(r), n());
|
|
5752
|
-
}, a = new MutationObserver(() => {
|
|
5753
|
-
r && clearTimeout(r), r = setTimeout(o, e);
|
|
5754
|
-
});
|
|
5755
|
-
r = setTimeout(o, e), setTimeout(o, t), a.observe(document.body, {
|
|
5756
|
-
childList: !0,
|
|
5757
|
-
subtree: !0,
|
|
5758
|
-
attributes: !0,
|
|
5759
|
-
attributeFilter: ["class", "style", "hidden"]
|
|
5760
|
-
});
|
|
5761
|
-
});
|
|
5762
|
-
}
|
|
5763
|
-
function detectPageDialog() {
|
|
5764
|
-
const t = /* @__PURE__ */ new Set(), e = [], n = window.__webmcpcli_dialogSelectors ?? DEFAULT_DIALOG_SELECTORS;
|
|
5765
|
-
for (const i of n)
|
|
5766
|
-
try {
|
|
5767
|
-
for (const r of deepQuerySelectorAll(i)) {
|
|
5768
|
-
if (t.has(r) || r.id?.includes("page-agent-runtime") || r.closest("#page-agent-runtime_simulator-mask")) continue;
|
|
5769
|
-
const o = r.getBoundingClientRect();
|
|
5770
|
-
if (o.width < 50 || o.height < 50) continue;
|
|
5771
|
-
const a = window.getComputedStyle(r);
|
|
5772
|
-
if (a.display === "none" || a.visibility === "hidden") continue;
|
|
5773
|
-
const l = a.position === "fixed" || a.position === "absolute", c = parseInt(a.zIndex || "0", 10);
|
|
5774
|
-
if (!l || c < 100) continue;
|
|
5775
|
-
const u = window.innerWidth, d = window.innerHeight;
|
|
5776
|
-
if (!(o.left < u * 0.6 && o.right > u * 0.4 && o.top < d * 0.6 && o.bottom > d * 0.4)) continue;
|
|
5777
|
-
t.add(r);
|
|
5778
|
-
const f = (r.textContent || "").trim().replace(/\s+/g, " ");
|
|
5779
|
-
if (f.length > 5) {
|
|
5780
|
-
const m = r.querySelectorAll('button, [role="button"], a'), g = Array.from(m).map((E) => (E.textContent || "").trim()).filter((E) => E.length > 0 && E.length < 20).slice(0, 5), S = g.length ? ` [可操作按钮: ${g.join(" / ")}]` : "";
|
|
5781
|
-
e.push(`${f.substring(0, 300)}${S}`);
|
|
6060
|
+
}), PAGE_AGENT_TOOL_CALL_EVENT = "page-agent-tool-call", PAGE_AGENT_TOOL_RESULT_EVENT = "page-agent-tool-result", PAGE_AGENT_CHAT_END_EVENT = "page-agent-chat-end";
|
|
6061
|
+
function isPageAgentToolErrorResult(t) {
|
|
6062
|
+
return typeof t == "object" && t !== null && "isError" in t && t.isError === !0 && "error" in t && typeof t.error == "string";
|
|
6063
|
+
}
|
|
6064
|
+
function dispatchPageAgentToolResult(t) {
|
|
6065
|
+
window.dispatchEvent(new CustomEvent(PAGE_AGENT_TOOL_RESULT_EVENT, { detail: t }));
|
|
6066
|
+
}
|
|
6067
|
+
function setupPageAgentToolEventBridge(t, e) {
|
|
6068
|
+
window.__nextSdkPageAgentToolEventCleanup?.();
|
|
6069
|
+
const n = async (r) => {
|
|
6070
|
+
const o = r.detail, a = o?.requestId;
|
|
6071
|
+
if (!a) {
|
|
6072
|
+
dispatchPageAgentToolResult({
|
|
6073
|
+
requestId: "",
|
|
6074
|
+
data: {
|
|
6075
|
+
success: !1,
|
|
6076
|
+
error: "缺少 requestId"
|
|
5782
6077
|
}
|
|
5783
|
-
}
|
|
5784
|
-
|
|
6078
|
+
});
|
|
6079
|
+
return;
|
|
5785
6080
|
}
|
|
5786
|
-
return e.length === 0 ? "" : `
|
|
5787
|
-
[页面弹窗检测] 检测到 ${e.length} 个模态弹窗,请优先处理:
|
|
5788
|
-
${e.map((i, r) => `${r + 1}. ${i}`).join(`
|
|
5789
|
-
`)}
|
|
5790
|
-
`;
|
|
5791
|
-
}
|
|
5792
|
-
function detectValidationErrors() {
|
|
5793
|
-
const t = /* @__PURE__ */ new Set(), e = [], n = window.__webmcpcli_errorSelectors ?? DEFAULT_ERROR_SELECTORS;
|
|
5794
|
-
for (const i of n)
|
|
5795
6081
|
try {
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
6082
|
+
const s = inputSchema.parse(o.data), c = await t(s);
|
|
6083
|
+
if (isPageAgentToolErrorResult(c)) {
|
|
6084
|
+
dispatchPageAgentToolResult({
|
|
6085
|
+
requestId: a,
|
|
6086
|
+
data: {
|
|
6087
|
+
success: !1,
|
|
6088
|
+
error: c.error,
|
|
6089
|
+
result: c
|
|
6090
|
+
}
|
|
6091
|
+
});
|
|
6092
|
+
return;
|
|
5804
6093
|
}
|
|
6094
|
+
dispatchPageAgentToolResult({
|
|
6095
|
+
requestId: a,
|
|
6096
|
+
data: {
|
|
6097
|
+
success: !0,
|
|
6098
|
+
result: c
|
|
6099
|
+
}
|
|
6100
|
+
});
|
|
6101
|
+
} catch (s) {
|
|
6102
|
+
dispatchPageAgentToolResult({
|
|
6103
|
+
requestId: a,
|
|
6104
|
+
data: {
|
|
6105
|
+
success: !1,
|
|
6106
|
+
error: s instanceof Error ? s.message : String(s)
|
|
6107
|
+
}
|
|
6108
|
+
});
|
|
6109
|
+
}
|
|
6110
|
+
}, i = async () => {
|
|
6111
|
+
try {
|
|
6112
|
+
await e.hideMask();
|
|
5805
6113
|
} catch {
|
|
5806
6114
|
}
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
6115
|
+
};
|
|
6116
|
+
window.addEventListener(PAGE_AGENT_TOOL_CALL_EVENT, n), window.addEventListener(PAGE_AGENT_CHAT_END_EVENT, i), window.__nextSdkPageAgentToolEventCleanup = () => {
|
|
6117
|
+
window.removeEventListener(PAGE_AGENT_TOOL_CALL_EVENT, n), window.removeEventListener(PAGE_AGENT_CHAT_END_EVENT, i), window.__nextSdkPageAgentToolEventCleanup = void 0;
|
|
6118
|
+
};
|
|
6119
|
+
}
|
|
6120
|
+
async function createActionErrorResult(t, e) {
|
|
6121
|
+
try {
|
|
6122
|
+
const n = await e("full");
|
|
6123
|
+
return {
|
|
6124
|
+
isError: !0,
|
|
6125
|
+
error: t,
|
|
6126
|
+
content: [{ type: "text", text: `${t}
|
|
6127
|
+
|
|
6128
|
+
${n.content[0].text}` }]
|
|
6129
|
+
};
|
|
6130
|
+
} catch (n) {
|
|
6131
|
+
return {
|
|
6132
|
+
isError: !0,
|
|
6133
|
+
error: t,
|
|
6134
|
+
content: [
|
|
6135
|
+
{
|
|
6136
|
+
type: "text",
|
|
6137
|
+
text: `${t}
|
|
6138
|
+
|
|
6139
|
+
获取最新浏览器状态失败: ${n instanceof Error ? n.message : String(n)}`
|
|
6140
|
+
}
|
|
6141
|
+
]
|
|
6142
|
+
};
|
|
6143
|
+
}
|
|
5812
6144
|
}
|
|
5813
6145
|
async function handleBrowserState(t, e) {
|
|
5814
6146
|
if (window.__webmcpcli_beforeGetBrowserState)
|
|
@@ -5821,9 +6153,12 @@ async function handleBrowserState(t, e) {
|
|
|
5821
6153
|
}
|
|
5822
6154
|
async function handleClick(t, e) {
|
|
5823
6155
|
const n = t.responseMode ?? "diff";
|
|
5824
|
-
if (t.index === void 0) return e.
|
|
6156
|
+
if (t.index === void 0) return e.actionError("点击结果: 缺少元素索引");
|
|
5825
6157
|
const i = e.getRefMap().get(t.index);
|
|
5826
|
-
if (!i)
|
|
6158
|
+
if (!i)
|
|
6159
|
+
return e.actionError(
|
|
6160
|
+
`点击失败: ref 索引 ${t.index} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。`
|
|
6161
|
+
);
|
|
5827
6162
|
let r = i;
|
|
5828
6163
|
if (i.shadowRoot && !(i instanceof HTMLButtonElement) && !(i instanceof HTMLAnchorElement)) {
|
|
5829
6164
|
const o = i.shadowRoot.querySelector(
|
|
@@ -5835,9 +6170,13 @@ async function handleClick(t, e) {
|
|
|
5835
6170
|
}
|
|
5836
6171
|
async function handleFill(t, e) {
|
|
5837
6172
|
const n = t.responseMode ?? "diff";
|
|
5838
|
-
if (t.index === void 0 || typeof t.text != "string")
|
|
6173
|
+
if (t.index === void 0 || typeof t.text != "string")
|
|
6174
|
+
return e.actionError("填写结果: 缺少元素索引或文本内容");
|
|
5839
6175
|
const i = e.getRefMap().get(t.index);
|
|
5840
|
-
if (!i)
|
|
6176
|
+
if (!i)
|
|
6177
|
+
return e.actionError(
|
|
6178
|
+
`填写失败: ref 索引 ${t.index} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。`
|
|
6179
|
+
);
|
|
5841
6180
|
let r = i;
|
|
5842
6181
|
if (!(r instanceof HTMLInputElement) && !(r instanceof HTMLTextAreaElement)) {
|
|
5843
6182
|
const o = i.querySelector("input, textarea") ?? i.shadowRoot?.querySelector("input, textarea");
|
|
@@ -5850,23 +6189,27 @@ async function handleFill(t, e) {
|
|
|
5850
6189
|
try {
|
|
5851
6190
|
await inputTextElement(r, t.text), o = !0;
|
|
5852
6191
|
} catch {
|
|
5853
|
-
const
|
|
6192
|
+
const s = Object.getOwnPropertyDescriptor(
|
|
5854
6193
|
(r instanceof HTMLTextAreaElement ? HTMLTextAreaElement : HTMLInputElement).prototype,
|
|
5855
6194
|
"value"
|
|
5856
6195
|
)?.set;
|
|
5857
|
-
|
|
6196
|
+
s && (r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement) && (s.call(r, t.text), r.dispatchEvent(new Event("focus", { bubbles: !0, composed: !0 })), r.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), r.dispatchEvent(new Event("blur", { bubbles: !0, composed: !0 })), o = !0);
|
|
5858
6197
|
}
|
|
5859
6198
|
if (!o)
|
|
5860
|
-
return e.
|
|
6199
|
+
return e.actionError(`填写结果: 无法填写元素 ${t.index},元素不是 input、textarea 或 contenteditable`);
|
|
5861
6200
|
isInShadowDom(r) && dispatchComposedEvents(r, "input", "change");
|
|
5862
6201
|
}
|
|
5863
6202
|
return await waitForDomSettled(), e.buildBrowserStateResponse(n);
|
|
5864
6203
|
}
|
|
5865
6204
|
async function handleSelect(t, e) {
|
|
5866
6205
|
const n = t.responseMode ?? "diff";
|
|
5867
|
-
if (t.index === void 0 || typeof t.text != "string")
|
|
6206
|
+
if (t.index === void 0 || typeof t.text != "string")
|
|
6207
|
+
return e.actionError("选择结果: 缺少元素索引或文本内容");
|
|
5868
6208
|
let i = e.getRefMap().get(t.index);
|
|
5869
|
-
if (!i)
|
|
6209
|
+
if (!i)
|
|
6210
|
+
return e.actionError(
|
|
6211
|
+
`选择失败: ref 索引 ${t.index} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。`
|
|
6212
|
+
);
|
|
5870
6213
|
let r = null;
|
|
5871
6214
|
if (i instanceof HTMLSelectElement)
|
|
5872
6215
|
r = i;
|
|
@@ -5874,7 +6217,7 @@ async function handleSelect(t, e) {
|
|
|
5874
6217
|
const o = i.querySelector("select") ?? i.shadowRoot?.querySelector("select");
|
|
5875
6218
|
o && (r = o);
|
|
5876
6219
|
}
|
|
5877
|
-
return r ? (await selectOptionElement(r, t.text), isInShadowDom(r) && dispatchComposedEvents(r, "change"), await waitForDomSettled(), e.buildBrowserStateResponse(n)) : e.
|
|
6220
|
+
return r ? (await selectOptionElement(r, t.text), isInShadowDom(r) && dispatchComposedEvents(r, "change"), await waitForDomSettled(), e.buildBrowserStateResponse(n)) : e.actionError(`选择结果: 无法选择元素 ${t.index},未找到对应的 <select> 元素`);
|
|
5878
6221
|
}
|
|
5879
6222
|
function getScrollInfo(t = window) {
|
|
5880
6223
|
if (t === window) {
|
|
@@ -5915,8 +6258,8 @@ function waitForScrollEnd(t, e = 2e3) {
|
|
|
5915
6258
|
return new Promise((n) => {
|
|
5916
6259
|
let i = !1;
|
|
5917
6260
|
const r = t === window ? document : t, o = () => {
|
|
5918
|
-
i || (i = !0, r.removeEventListener("scrollend", a), clearTimeout(
|
|
5919
|
-
}, a = () => o(),
|
|
6261
|
+
i || (i = !0, r.removeEventListener("scrollend", a), clearTimeout(s), n());
|
|
6262
|
+
}, a = () => o(), s = setTimeout(o, e);
|
|
5920
6263
|
r.addEventListener("scrollend", a, { once: !0 });
|
|
5921
6264
|
});
|
|
5922
6265
|
}
|
|
@@ -5925,33 +6268,33 @@ async function handleScroll(t, e) {
|
|
|
5925
6268
|
if (t.down === void 0 && t.right === void 0) return e.errContent("滚动结果: 缺少滚动方向参数");
|
|
5926
6269
|
let i = window;
|
|
5927
6270
|
if (t.index !== void 0) {
|
|
5928
|
-
const
|
|
5929
|
-
if (!
|
|
5930
|
-
i =
|
|
6271
|
+
const g = e.getRefMap().get(t.index);
|
|
6272
|
+
if (!g) return e.refreshOnStaleRef("滚动", t.index);
|
|
6273
|
+
i = g;
|
|
5931
6274
|
}
|
|
5932
6275
|
const r = getScrollInfo(i);
|
|
5933
6276
|
if (t.right !== void 0) {
|
|
5934
|
-
const
|
|
5935
|
-
i.scrollBy({ left: t.right ?
|
|
6277
|
+
const g = t.pixels ?? 300;
|
|
6278
|
+
i.scrollBy({ left: t.right ? g : -g, behavior: "smooth" });
|
|
5936
6279
|
} else {
|
|
5937
|
-
const
|
|
5938
|
-
i.scrollBy({ top: t.down ?
|
|
6280
|
+
const g = t.pixels ?? Math.round((t.numPages ?? 1) * window.innerHeight);
|
|
6281
|
+
i.scrollBy({ top: t.down ? g : -g, behavior: "smooth" });
|
|
5939
6282
|
}
|
|
5940
6283
|
await waitForScrollEnd(i);
|
|
5941
|
-
const o = getScrollInfo(i), a = Math.round(o.scrollY - r.scrollY),
|
|
5942
|
-
let
|
|
5943
|
-
if (Math.abs(a) < 1 && Math.abs(
|
|
5944
|
-
c ?
|
|
6284
|
+
const o = getScrollInfo(i), a = Math.round(o.scrollY - r.scrollY), s = Math.round(o.scrollX - r.scrollX), c = t.right !== void 0;
|
|
6285
|
+
let d;
|
|
6286
|
+
if (Math.abs(a) < 1 && Math.abs(s) < 1)
|
|
6287
|
+
c ? d = t.right ? "⚠️ 已到达右边界,无法继续向右滚动" : "⚠️ 已到达左边界,无法继续向左滚动" : d = t.down ? "⚠️ 已到达底部,无法继续向下滚动" : "⚠️ 已到达顶部,无法继续向上滚动";
|
|
5945
6288
|
else {
|
|
5946
|
-
const
|
|
5947
|
-
let
|
|
5948
|
-
c ? t.right && o.atRight ?
|
|
6289
|
+
const g = c ? `水平滚动 ${s}px` : `垂直滚动 ${a}px`;
|
|
6290
|
+
let y = "";
|
|
6291
|
+
c ? t.right && o.atRight ? y = ",已到达右边界" : !t.right && o.atLeft && (y = ",已到达左边界") : t.down && o.atBottom ? y = ",已到达底部" : !t.down && o.atTop && (y = ",已到达顶部"), d = `✅ ${g}${y}`;
|
|
5949
6292
|
}
|
|
5950
|
-
const
|
|
5951
|
-
${
|
|
5952
|
-
return
|
|
6293
|
+
const u = t.right !== void 0 ? `当前水平滚动位置: scrollX=${Math.round(o.scrollX)}px,左侧 ${o.pagesAbove.toFixed(1)} 屏,右侧 ${o.pagesBelow.toFixed(1)} 屏` : `当前滚动位置: scrollY=${Math.round(o.scrollY)}px,上方 ${o.pagesAbove.toFixed(1)} 屏,下方 ${o.pagesBelow.toFixed(1)} 屏`, p = `[滚动结果] ${d}
|
|
6294
|
+
${u}`, h = await e.buildBrowserStateResponse(n);
|
|
6295
|
+
return h.content[0].text = `${p}
|
|
5953
6296
|
|
|
5954
|
-
${
|
|
6297
|
+
${h.content[0].text}`, h;
|
|
5955
6298
|
}
|
|
5956
6299
|
async function handleExecuteJavascript(t, e) {
|
|
5957
6300
|
if (!t.script) return e.errContent("脚本执行异常: 缺少javascript代码");
|
|
@@ -5967,110 +6310,295 @@ async function handleExecuteJavascript(t, e) {
|
|
|
5967
6310
|
}
|
|
5968
6311
|
async function handleSearchTree(t, e) {
|
|
5969
6312
|
if (!t.query) return e.errContent("搜索失败: 缺少 query 参数");
|
|
5970
|
-
const n =
|
|
6313
|
+
const n = searchA11yTree(t.query, document.body, {
|
|
6314
|
+
...getPageAgentToolConfig().a11yConfig,
|
|
5971
6315
|
contextLines: t.contextLines,
|
|
5972
|
-
maxMatches: t.maxMatches
|
|
5973
|
-
exposedAttributes: r,
|
|
5974
|
-
errorSelectors: (window.__webmcpcli_errorSelectors ?? DEFAULT_ERROR_SELECTORS).join(", ")
|
|
6316
|
+
maxMatches: t.maxMatches
|
|
5975
6317
|
});
|
|
5976
|
-
e.setRefMap(
|
|
5977
|
-
const
|
|
6318
|
+
e.setRefMap(n.refMap), e.stateCache.update(window.location.href, n.yaml), await e.pageController.hideMask();
|
|
6319
|
+
const i = detectPageDialog(), r = detectValidationErrors(), o = `${i}${r}`;
|
|
5978
6320
|
return {
|
|
5979
|
-
content: [{ type: "text", text:
|
|
5980
|
-
${
|
|
6321
|
+
content: [{ type: "text", text: o ? `${o}
|
|
6322
|
+
${n.text}` : n.text }]
|
|
5981
6323
|
};
|
|
5982
6324
|
}
|
|
5983
6325
|
function registerPageAgentTool(t = {}) {
|
|
5984
|
-
initializeBuiltinWebMCP(),
|
|
6326
|
+
initializeBuiltinWebMCP(), setPageAgentToolConfig(t, { mode: "replace" }), window.__webmcpcli_beforeGetBrowserState = window.__webmcpcli_beforeGetBrowserState || null;
|
|
5985
6327
|
const e = new PageController({ enableMask: !1 });
|
|
5986
6328
|
e.maskReady = (async () => {
|
|
5987
6329
|
e.mask = new SimulatorMask();
|
|
5988
6330
|
})();
|
|
5989
6331
|
const n = new PageStateCache();
|
|
5990
6332
|
let i = /* @__PURE__ */ new Map();
|
|
5991
|
-
async function r(
|
|
5992
|
-
return
|
|
6333
|
+
async function r(u) {
|
|
6334
|
+
return { content: [{ type: "text", text: u }] };
|
|
6335
|
+
}
|
|
6336
|
+
async function o(u) {
|
|
6337
|
+
const p = await createActionErrorResult(u, s);
|
|
6338
|
+
return t.removeMaskAfterToolCall && await e.hideMask(), p;
|
|
5993
6339
|
}
|
|
5994
|
-
async function
|
|
5995
|
-
const
|
|
6340
|
+
async function a(u, p) {
|
|
6341
|
+
const h = await s("full");
|
|
5996
6342
|
return {
|
|
5997
|
-
content: [{ type: "text", text: `⚠️ ${
|
|
5998
|
-
` +
|
|
6343
|
+
content: [{ type: "text", text: `⚠️ ${u}失败: ref 索引 ${p} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。
|
|
6344
|
+
` + h.content[0].text }]
|
|
5999
6345
|
};
|
|
6000
6346
|
}
|
|
6001
|
-
async function
|
|
6002
|
-
const
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
const E = n.update(u, g);
|
|
6008
|
-
await e.hideMask();
|
|
6009
|
-
const h = detectPageDialog(), x = detectValidationErrors();
|
|
6010
|
-
let T = "";
|
|
6011
|
-
return c === "full" ? T = g : c === "diff" ? T = E.isFullRefresh ? g : E.diffText : c === "both" && (T = `【全量页面树】:
|
|
6347
|
+
async function s(u = "diff") {
|
|
6348
|
+
const p = window.location.href, h = document.title, { yaml: g, refMap: y } = buildA11yTree(document.body, getPageAgentToolConfig().a11yConfig);
|
|
6349
|
+
i = y, getPageAgentToolConfig().enableHighlight && (highlight(y), globalRemoveListener());
|
|
6350
|
+
const T = n.update(p, g), C = detectPageDialog(), f = detectValidationErrors();
|
|
6351
|
+
let m = "";
|
|
6352
|
+
return u === "full" ? m = g : u === "diff" ? m = T.isFullRefresh ? g : T.diffText : u === "both" && (m = `【全量页面树】:
|
|
6012
6353
|
${g}
|
|
6013
6354
|
|
|
6014
6355
|
【增量差异】:
|
|
6015
|
-
${
|
|
6016
|
-
url:
|
|
6017
|
-
title:
|
|
6018
|
-
content:
|
|
6019
|
-
})}${
|
|
6356
|
+
${T.isFullRefresh ? "(首次/刷新,无增量差异)" : T.diffText}`), { content: [{ type: "text", text: `浏览器状态: ${JSON.stringify({
|
|
6357
|
+
url: p,
|
|
6358
|
+
title: h,
|
|
6359
|
+
content: m
|
|
6360
|
+
})}${C}${f}` }] };
|
|
6020
6361
|
}
|
|
6021
|
-
const
|
|
6362
|
+
const c = {
|
|
6022
6363
|
pageController: e,
|
|
6023
6364
|
stateCache: n,
|
|
6024
6365
|
getRefMap: () => i,
|
|
6025
|
-
setRefMap: (
|
|
6026
|
-
i =
|
|
6366
|
+
setRefMap: (u) => {
|
|
6367
|
+
i = u;
|
|
6027
6368
|
},
|
|
6028
|
-
buildBrowserStateResponse:
|
|
6029
|
-
refreshOnStaleRef:
|
|
6030
|
-
errContent: r
|
|
6369
|
+
buildBrowserStateResponse: s,
|
|
6370
|
+
refreshOnStaleRef: a,
|
|
6371
|
+
errContent: r,
|
|
6372
|
+
actionError: o
|
|
6031
6373
|
};
|
|
6374
|
+
async function d(u) {
|
|
6375
|
+
try {
|
|
6376
|
+
let p;
|
|
6377
|
+
switch (u.action) {
|
|
6378
|
+
case "browserState":
|
|
6379
|
+
p = await handleBrowserState(u, c);
|
|
6380
|
+
break;
|
|
6381
|
+
case "click":
|
|
6382
|
+
await e.showMask(), e.mask.borderElement(i.get(u.index)), p = await handleClick(u, c), e.mask.removeBorderElement(), t.removeMaskAfterToolCall && await e.hideMask();
|
|
6383
|
+
break;
|
|
6384
|
+
case "fill":
|
|
6385
|
+
await e.showMask(), e.mask.borderElement(i.get(u.index)), p = await handleFill(u, c), e.mask.removeBorderElement(), t.removeMaskAfterToolCall && await e.hideMask();
|
|
6386
|
+
break;
|
|
6387
|
+
case "select":
|
|
6388
|
+
await e.showMask(), e.mask.borderElement(i.get(u.index)), p = await handleSelect(u, c), e.mask.removeBorderElement(), t.removeMaskAfterToolCall && await e.hideMask();
|
|
6389
|
+
break;
|
|
6390
|
+
case "scroll":
|
|
6391
|
+
await e.showMask(), p = await handleScroll(u, c), t.removeMaskAfterToolCall && await e.hideMask();
|
|
6392
|
+
break;
|
|
6393
|
+
case "executeJavascript":
|
|
6394
|
+
p = await handleExecuteJavascript(u, c);
|
|
6395
|
+
break;
|
|
6396
|
+
case "searchTree":
|
|
6397
|
+
p = await handleSearchTree(u, c);
|
|
6398
|
+
break;
|
|
6399
|
+
default:
|
|
6400
|
+
p = { content: [{ type: "text", text: `未知操作: ${u.action}` }] };
|
|
6401
|
+
}
|
|
6402
|
+
return p;
|
|
6403
|
+
} catch (p) {
|
|
6404
|
+
const h = {
|
|
6405
|
+
click: "点击",
|
|
6406
|
+
fill: "填写",
|
|
6407
|
+
select: "选择"
|
|
6408
|
+
};
|
|
6409
|
+
if (u.action in h)
|
|
6410
|
+
return o(
|
|
6411
|
+
`${h[u.action]}执行异常: ${p instanceof Error ? p.message : String(p)}`
|
|
6412
|
+
);
|
|
6413
|
+
throw t.removeMaskAfterToolCall && await e.hideMask(), p;
|
|
6414
|
+
}
|
|
6415
|
+
}
|
|
6032
6416
|
document.modelContext.registerTool({
|
|
6033
6417
|
name: "page-agent-tool",
|
|
6034
6418
|
description: pageAgentPrompt,
|
|
6035
6419
|
// @ts-ignore
|
|
6036
6420
|
inputSchema: zodToJsonSchema(inputSchema),
|
|
6037
|
-
async execute(
|
|
6038
|
-
await e.showMask();
|
|
6421
|
+
async execute(u) {
|
|
6039
6422
|
try {
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
case "click":
|
|
6044
|
-
return await handleClick(c, l);
|
|
6045
|
-
case "fill":
|
|
6046
|
-
return await handleFill(c, l);
|
|
6047
|
-
case "select":
|
|
6048
|
-
return await handleSelect(c, l);
|
|
6049
|
-
case "scroll":
|
|
6050
|
-
return await handleScroll(c, l);
|
|
6051
|
-
case "executeJavascript":
|
|
6052
|
-
return await handleExecuteJavascript(c, l);
|
|
6053
|
-
case "searchTree":
|
|
6054
|
-
return await handleSearchTree(c, l);
|
|
6055
|
-
default:
|
|
6056
|
-
return await e.hideMask(), { content: [{ type: "text", text: `未知操作: ${c.action}` }] };
|
|
6057
|
-
}
|
|
6058
|
-
} catch (u) {
|
|
6059
|
-
return await e.hideMask(), { content: [{ type: "text", text: `异常: ${String(u)}` }] };
|
|
6423
|
+
return d(u);
|
|
6424
|
+
} catch (p) {
|
|
6425
|
+
return { content: [{ type: "text", text: `异常: ${String(p)}` }] };
|
|
6060
6426
|
}
|
|
6061
6427
|
}
|
|
6062
|
-
});
|
|
6428
|
+
}), setupPageAgentToolEventBridge(d, e);
|
|
6429
|
+
}
|
|
6430
|
+
const consoleCloudPageAgentToolOptions = {
|
|
6431
|
+
enableHighlight: !1,
|
|
6432
|
+
a11yConfig: {
|
|
6433
|
+
roles: [
|
|
6434
|
+
// Tiny3 Tabs:真正可聚焦/可点击的是内部 .ti3-tabs-text(tabindex=0)
|
|
6435
|
+
{ role: "tablist", selector: "ul.ti3-tabs" },
|
|
6436
|
+
{ role: "tab", selector: ".ti3-tabs-text" },
|
|
6437
|
+
{ role: "tabpanel", selector: ["ti-tab.ti3-tab-pane", ".ti3-tab-pane"] },
|
|
6438
|
+
// 自定义下拉 / 区域选择触发器
|
|
6439
|
+
{
|
|
6440
|
+
role: "combobox",
|
|
6441
|
+
selector: [
|
|
6442
|
+
".ti3-select-dominator-container",
|
|
6443
|
+
".selected-label",
|
|
6444
|
+
".sort-select",
|
|
6445
|
+
".service-select",
|
|
6446
|
+
".region-select",
|
|
6447
|
+
'[cf-uba="searchableRegion..open"]'
|
|
6448
|
+
]
|
|
6449
|
+
},
|
|
6450
|
+
// 图标型 / 无语义按钮
|
|
6451
|
+
{
|
|
6452
|
+
role: "button",
|
|
6453
|
+
selector: [
|
|
6454
|
+
".modules-service-list-menu-service-icon-container",
|
|
6455
|
+
".ti3-btn-only-icon-noborder",
|
|
6456
|
+
".ti3-select-dominator-dropdown-btn",
|
|
6457
|
+
".modules-right-sidebar-icon-item-wrapper",
|
|
6458
|
+
".modules-right-sidebar-hide-state-plugin",
|
|
6459
|
+
".components-service-list-container-service-list-input-service-close",
|
|
6460
|
+
".modules-searchable-region-region-panel-close",
|
|
6461
|
+
".modules-searchable-region-region-panel-search-btn",
|
|
6462
|
+
'[cf-uba="rightSidebar..hideBtn"]',
|
|
6463
|
+
// Tiny3 图标组件:帮助中心固定/全屏/关闭等(ti-icon / tp-icon 无原生 button 语义)
|
|
6464
|
+
".ti-global-help-panel-header-icon",
|
|
6465
|
+
"ti-icon[name]",
|
|
6466
|
+
"tp-icon[name]",
|
|
6467
|
+
// 无 name 的箭头/操作图标(如 latest news 区 common-icon 展开箭头)
|
|
6468
|
+
"tp-icon.common-icon",
|
|
6469
|
+
"ti-icon.common-icon",
|
|
6470
|
+
"ti-icon.ti3-icon-full-screen",
|
|
6471
|
+
"ti-icon.ti3-icon-close",
|
|
6472
|
+
"tp-icon.ti3-icon-full-screen",
|
|
6473
|
+
"tp-icon.ti3-icon-close"
|
|
6474
|
+
]
|
|
6475
|
+
},
|
|
6476
|
+
// 服务列表侧栏分类 / 顶栏菜单项
|
|
6477
|
+
{
|
|
6478
|
+
role: "menuitem",
|
|
6479
|
+
selector: [
|
|
6480
|
+
".components-service-list-left-box-sidebar-visit-panel > li",
|
|
6481
|
+
".modules-menus-menu-item",
|
|
6482
|
+
".components-menu-wrapper-menu-text"
|
|
6483
|
+
]
|
|
6484
|
+
},
|
|
6485
|
+
// 区域筛选项 / 下拉选项
|
|
6486
|
+
{
|
|
6487
|
+
role: "option",
|
|
6488
|
+
selector: [
|
|
6489
|
+
".region-selector-item",
|
|
6490
|
+
".modules-searchable-region-project-item-region-item",
|
|
6491
|
+
".modules-searchable-region-region-panel-recent-region-item",
|
|
6492
|
+
".ti3-multiselect-box-cell"
|
|
6493
|
+
]
|
|
6494
|
+
}
|
|
6495
|
+
],
|
|
6496
|
+
states: {
|
|
6497
|
+
// 选中态:挂在容器 class 上,用 selector + closest 即可命中内部交互节点
|
|
6498
|
+
selected: [
|
|
6499
|
+
{ selector: "li.ti3-tab-li.ti3-tab-active" },
|
|
6500
|
+
// Tiny3 按钮组(计费模式等):ti3-active 在 .ti3-btn-item-container 上,不在 button 上
|
|
6501
|
+
{ selector: ".ti3-btn-item-container.ti3-active" },
|
|
6502
|
+
{ selector: ".components-service-list-left-box-active" },
|
|
6503
|
+
{
|
|
6504
|
+
selector: [
|
|
6505
|
+
".modules-searchable-region-project-item-region-item-selected",
|
|
6506
|
+
".components-search-content-search-select-search-select-selected"
|
|
6507
|
+
]
|
|
6508
|
+
}
|
|
6509
|
+
],
|
|
6510
|
+
hasPopup: [
|
|
6511
|
+
{
|
|
6512
|
+
selector: [
|
|
6513
|
+
".ti3-select-dominator-container",
|
|
6514
|
+
".selected-label",
|
|
6515
|
+
".sort-select",
|
|
6516
|
+
".service-select",
|
|
6517
|
+
".region-select",
|
|
6518
|
+
'[cf-uba="searchableRegion..open"]',
|
|
6519
|
+
'[cf-uba="serviceList..open"]',
|
|
6520
|
+
'[cf-uba="userinfo"]'
|
|
6521
|
+
]
|
|
6522
|
+
}
|
|
6523
|
+
],
|
|
6524
|
+
disabled: [{ selector: ".ti3-disabled" }],
|
|
6525
|
+
// 展开态:需结合计算样式,选择器表达不了「可见」
|
|
6526
|
+
expanded: [
|
|
6527
|
+
{
|
|
6528
|
+
match: (t) => {
|
|
6529
|
+
try {
|
|
6530
|
+
if (!t.matches(
|
|
6531
|
+
".modules-layout-module-sidebar-panel, .modules-searchable-region-region-panel, .ti3-dropdown-container"
|
|
6532
|
+
))
|
|
6533
|
+
return !1;
|
|
6534
|
+
const e = window.getComputedStyle(t);
|
|
6535
|
+
return e.display !== "none" && e.visibility !== "hidden" && e.opacity !== "0";
|
|
6536
|
+
} catch {
|
|
6537
|
+
return !1;
|
|
6538
|
+
}
|
|
6539
|
+
}
|
|
6540
|
+
}
|
|
6541
|
+
]
|
|
6542
|
+
},
|
|
6543
|
+
// exposedAttributes 输出属性 token;带 name 的 ti-icon/tp-icon 可交互性由 roles/whitelist 中 ti-icon[name] 等规则判定。
|
|
6544
|
+
exposedAttributes: ["cf-uba", "data-qa-id", "name"],
|
|
6545
|
+
whitelist: [
|
|
6546
|
+
".modules-service-list-menu-service-icon-container",
|
|
6547
|
+
".ti3-tabs-text",
|
|
6548
|
+
'[cf-uba="cloudShell"]',
|
|
6549
|
+
'[cf-uba="messageBox"]',
|
|
6550
|
+
'[cf-uba="helpFeedback"]',
|
|
6551
|
+
'[cf-uba="globalMessage"]',
|
|
6552
|
+
'[cf-uba="rightSidebar..hideBtn"]',
|
|
6553
|
+
// 帮助中心等区域的 ti-icon / tp-icon 图标按钮
|
|
6554
|
+
".ti-global-help-panel-header-icon",
|
|
6555
|
+
"ti-icon[name]",
|
|
6556
|
+
"tp-icon[name]",
|
|
6557
|
+
"tp-icon.common-icon",
|
|
6558
|
+
"ti-icon.common-icon",
|
|
6559
|
+
"ti-icon.ti3-icon-full-screen"
|
|
6560
|
+
],
|
|
6561
|
+
blacklist: ["noscript", "pan-gu", "#J_header"],
|
|
6562
|
+
dialogSelectors: [
|
|
6563
|
+
'[class*="ti3-modal"]',
|
|
6564
|
+
'[class*="ti3-message-box"]',
|
|
6565
|
+
'[class*="drawer"]',
|
|
6566
|
+
".modules-layout-module-sidebar-panel"
|
|
6567
|
+
]
|
|
6568
|
+
}
|
|
6569
|
+
};
|
|
6570
|
+
function isConsoleCloudHost(t = typeof location < "u" ? location.hostname : "") {
|
|
6571
|
+
return /(^|\.)console\.huaweicloud\.com$/i.test(t);
|
|
6063
6572
|
}
|
|
6064
6573
|
export {
|
|
6574
|
+
DEFAULT_PAGE_AGENT_TOOL_CONFIG as D,
|
|
6065
6575
|
Motion as M,
|
|
6576
|
+
PAGE_AGENT_TOOL_CALL_EVENT as P,
|
|
6066
6577
|
QrCode as Q,
|
|
6067
6578
|
getSkillMdContent as a,
|
|
6068
6579
|
getMainSkillPaths as b,
|
|
6069
6580
|
getMainSkillPathByName as c,
|
|
6070
6581
|
createSkillTools as d,
|
|
6071
|
-
|
|
6582
|
+
PAGE_AGENT_TOOL_RESULT_EVENT as e,
|
|
6072
6583
|
formatSkillsForSystemPrompt as f,
|
|
6073
6584
|
getSkillOverviews as g,
|
|
6585
|
+
getPageAgentToolConfig as h,
|
|
6586
|
+
consoleCloudPageAgentToolOptions as i,
|
|
6587
|
+
isConsoleCloudHost as j,
|
|
6588
|
+
DEFAULT_A11Y_CONFIG as k,
|
|
6589
|
+
defineA11yConfig as l,
|
|
6590
|
+
resolveA11yInfo as m,
|
|
6591
|
+
resolveA11yRole as n,
|
|
6592
|
+
resolveA11yStates as o,
|
|
6074
6593
|
parseSkillFrontMatter as p,
|
|
6075
|
-
|
|
6594
|
+
mergeA11yConfig as q,
|
|
6595
|
+
registerPageAgentTool as r,
|
|
6596
|
+
setPageAgentToolConfig as s,
|
|
6597
|
+
mergeA11yConfigs as t,
|
|
6598
|
+
ensureResolvedA11yConfig as u,
|
|
6599
|
+
isResolvedA11yConfig as v,
|
|
6600
|
+
extractSelectors as w,
|
|
6601
|
+
buildA11yTree as x,
|
|
6602
|
+
searchA11yTree as y,
|
|
6603
|
+
createRemoter as z
|
|
6076
6604
|
};
|