@opentiny/next-sdk 0.4.1 → 0.4.3
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-CKmEDsYG.js} +1 -1
- package/dist/core.js +1 -1
- package/dist/{index-CXK8CcKq.js → index-CHMa2zG4.js} +1985 -1434
- 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 +99 -0
- package/dist/page-tools/a11y/constants.d.ts +22 -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 +46 -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 +7 -17
- package/dist/page-tools/context.d.ts +14 -0
- package/dist/page-tools/handlers/hover.d.ts +9 -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 +4 -3
- package/dist/page-tools/tool-config.d.ts +50 -0
- package/dist/page-tools/utils/dom.d.ts +8 -2
- package/dist/runtime.d.ts +4 -1
- package/dist/runtime.js +22 -187
- package/dist/vitest.config.d.ts +2 -0
- package/package.json +26 -16
- package/WebMcpClient.ts +0 -505
- package/WebMcpServer.ts +0 -447
- package/agent/AgentModelProvider.ts +0 -932
- package/agent/type.ts +0 -91
- package/agent/utils/generateReActPrompt.ts +0 -71
- package/agent/utils/getAISDKTools.ts +0 -34
- package/agent/utils/getBuiltinMcpTools.ts +0 -86
- package/agent/utils/parseReActAction.ts +0 -34
- package/core.ts +0 -26
- package/index.ts +0 -56
- package/page-tools/a11y/build.ts +0 -70
- package/page-tools/a11y/constants.ts +0 -110
- package/page-tools/a11y/search.ts +0 -129
- package/page-tools/a11y/types.ts +0 -108
- package/page-tools/a11y/utils.ts +0 -266
- package/page-tools/a11y/vnode.ts +0 -229
- package/page-tools/a11y-tree.ts +0 -13
- package/page-tools/bridge.ts +0 -702
- package/page-tools/constants.ts +0 -72
- package/page-tools/context.ts +0 -13
- package/page-tools/effects.ts +0 -345
- package/page-tools/handlers/browserState.ts +0 -12
- package/page-tools/handlers/click.ts +0 -26
- package/page-tools/handlers/executeJavascript.ts +0 -22
- package/page-tools/handlers/fill.ts +0 -60
- package/page-tools/handlers/scroll.ts +0 -66
- package/page-tools/handlers/searchTree.ts +0 -30
- package/page-tools/handlers/select.ts +0 -34
- package/page-tools/initialize-builtin-WebMCP.ts +0 -20
- package/page-tools/page-agent-highlight/index.ts +0 -198
- package/page-tools/page-agent-mask/SimulatorMask.module.css +0 -14
- package/page-tools/page-agent-mask/SimulatorMask.ts +0 -279
- package/page-tools/page-agent-mask/checkDarkMode.ts +0 -181
- package/page-tools/page-agent-mask/cursor-border.svg +0 -3
- package/page-tools/page-agent-mask/cursor-fill.svg +0 -5
- package/page-tools/page-agent-mask/cursor.module.css +0 -70
- package/page-tools/page-agent-prompt.md +0 -139
- package/page-tools/page-agent-tool.ts +0 -175
- package/page-tools/page-state-cache.ts +0 -78
- package/page-tools/schema.ts +0 -51
- package/page-tools/utils/dom.ts +0 -155
- package/page-tools/utils/scroll.ts +0 -58
- package/remoter/QrCode.ts +0 -54
- package/remoter/createRemoter.ts +0 -957
- package/remoter/svgs/chat.svg +0 -43
- package/remoter/svgs/icon-copy.svg +0 -25
- package/remoter/svgs/link.svg +0 -28
- package/remoter/svgs/logo.svg +0 -45
- package/remoter/svgs/qrcode.svg +0 -35
- package/remoter/svgs/scan.svg +0 -21
- package/remoter/tooltips.ts +0 -260
- package/runtime.html +0 -39
- package/runtime.ts +0 -13
- package/script/utils.ts +0 -26
- package/skills/index.ts +0 -287
- package/tsconfig.json +0 -16
- package/utils/builtinProxy.ts +0 -144
- package/utils/env.ts +0 -13
- package/utils/uuid.ts +0 -10
- package/vite.config.runtime.ts +0 -22
- package/vite.config.ts +0 -63
|
@@ -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,
|
|
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, s = 6, [a, c = "center"] = e.split("-");
|
|
101
|
+
let d = 0, u = 0;
|
|
102
|
+
return a === "top" ? d = n.top + r - i.height - s : a === "bottom" ? d = n.bottom + r + s : a === "left" ? u = n.left + o - i.width - s : a === "right" && (u = n.right + o + s), (a === "top" || a === "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), (a === "left" || a === "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, {
|
|
@@ -109,8 +109,8 @@ class Tooltip {
|
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
checkViewport({ top: e, left: n }) {
|
|
112
|
-
const r = window.innerWidth, o = window.innerHeight,
|
|
113
|
-
return n >= 5 && e >= 5 && n +
|
|
112
|
+
const r = window.innerWidth, o = window.innerHeight, s = this.tip.getBoundingClientRect();
|
|
113
|
+
return n >= 5 && e >= 5 && n + s.width <= r - 5 && e + s.height <= o - 5;
|
|
114
114
|
}
|
|
115
115
|
placementList(e) {
|
|
116
116
|
const n = {
|
|
@@ -330,8 +330,8 @@ class FloatingBlock {
|
|
|
330
330
|
const n = e.target, i = n.closest(".tiny-remoter-copy-icon");
|
|
331
331
|
if (i) {
|
|
332
332
|
e.stopPropagation();
|
|
333
|
-
const
|
|
334
|
-
|
|
333
|
+
const s = i.dataset.action;
|
|
334
|
+
s && this.handleAction(s);
|
|
335
335
|
return;
|
|
336
336
|
}
|
|
337
337
|
const o = n.closest(".tiny-remoter-dropdown-item")?.dataset.action;
|
|
@@ -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),
|
|
884
|
-
return
|
|
883
|
+
const i = n[1], r = i.match(/^name:\s*(.+)$/m), o = i.match(/^description:\s*(.+)$/m), s = r?.[1]?.trim(), a = o?.[1]?.trim();
|
|
884
|
+
return s && a ? { name: s, description: a } : 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/"),
|
|
890
|
-
e[
|
|
889
|
+
const r = n.replace(/\\/g, "/"), o = r.lastIndexOf("skills/"), s = o >= 0 ? r.slice(o + 7) : r, a = s.startsWith("./") ? s : `./${s}`, c = typeof i == "string" ? i : await i();
|
|
890
|
+
e[a] = c;
|
|
891
891
|
}
|
|
892
892
|
return e;
|
|
893
893
|
}
|
|
@@ -900,10 +900,10 @@ async function getSkillOverviews(t) {
|
|
|
900
900
|
for (const r of n) {
|
|
901
901
|
const o = e[r];
|
|
902
902
|
if (!o) continue;
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
name:
|
|
906
|
-
description:
|
|
903
|
+
const s = await parseSkillFrontMatter(o);
|
|
904
|
+
s && i.push({
|
|
905
|
+
name: s.name,
|
|
906
|
+
description: s.description,
|
|
907
907
|
path: r
|
|
908
908
|
});
|
|
909
909
|
}
|
|
@@ -920,17 +920,17 @@ ${t.map((n) => `- **${n.name}**: ${n.description}`).join(`
|
|
|
920
920
|
async function getSkillMdContent(t, e) {
|
|
921
921
|
const n = await normalizeSkillModuleKeys(t), i = n[e];
|
|
922
922
|
if (i) return i;
|
|
923
|
-
const r = e.replace(/^\.?\//, "/"), o = Object.keys(n).find((
|
|
923
|
+
const r = e.replace(/^\.?\//, "/"), o = Object.keys(n).find((s) => s.endsWith(r));
|
|
924
924
|
return o ? n[o] : void 0;
|
|
925
925
|
}
|
|
926
926
|
async function getMainSkillPathByName(t, e) {
|
|
927
927
|
const n = await normalizeSkillModuleKeys(t), i = await getMainSkillPaths(n), r = i.find((o) => o.startsWith(`./${e}/SKILL.md`));
|
|
928
928
|
if (r) return r;
|
|
929
929
|
for (const o of i) {
|
|
930
|
-
const
|
|
931
|
-
if (
|
|
932
|
-
const
|
|
933
|
-
if (
|
|
930
|
+
const s = n[o];
|
|
931
|
+
if (s) {
|
|
932
|
+
const a = await parseSkillFrontMatter(s);
|
|
933
|
+
if (a && a.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:
|
|
956
|
-
let
|
|
957
|
-
if (
|
|
958
|
-
let
|
|
955
|
+
const o = n, { skillName: s, path: a, currentPath: c } = r;
|
|
956
|
+
let d, u = "";
|
|
957
|
+
if (a) {
|
|
958
|
+
let h = ".";
|
|
959
959
|
if (c) {
|
|
960
960
|
const g = c.lastIndexOf("/");
|
|
961
|
-
g >= 0 && (
|
|
961
|
+
g >= 0 && (h = c.slice(0, g));
|
|
962
962
|
}
|
|
963
|
-
const
|
|
964
|
-
if (
|
|
963
|
+
const p = `http://localhost/${h}/`;
|
|
964
|
+
if (u = "." + new URL(a, p).pathname, d = await getSkillMdContent(o, u), d === void 0 && (a.startsWith("./") || a.startsWith("../")) && c) {
|
|
965
965
|
const g = c.split("/");
|
|
966
966
|
if (g.length >= 2) {
|
|
967
|
-
const
|
|
968
|
-
|
|
967
|
+
const L = `http://localhost/${g[1]}/`, b = "." + new URL(a, L).pathname;
|
|
968
|
+
d = await getSkillMdContent(o, b), d && (u = b);
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
|
-
if (
|
|
972
|
-
const g =
|
|
973
|
-
|
|
971
|
+
if (d && !o[u]) {
|
|
972
|
+
const g = u.replace(/^\.?\//, "/"), E = Object.keys(o).find((L) => L.endsWith(g));
|
|
973
|
+
E && (u = E);
|
|
974
974
|
}
|
|
975
|
-
} else if (
|
|
976
|
-
const
|
|
977
|
-
|
|
975
|
+
} else if (s) {
|
|
976
|
+
const h = await getMainSkillPathByName(o, s);
|
|
977
|
+
h && (u = h, d = await getSkillMdContent(o, h));
|
|
978
978
|
}
|
|
979
|
-
return
|
|
979
|
+
return d === void 0 ? {
|
|
980
980
|
error: "未找到对应技能文档",
|
|
981
|
-
skillName:
|
|
982
|
-
path:
|
|
981
|
+
skillName: s,
|
|
982
|
+
path: a,
|
|
983
983
|
providedCurrentPath: c,
|
|
984
|
-
attemptedPath:
|
|
985
|
-
} : { content:
|
|
984
|
+
attemptedPath: u
|
|
985
|
+
} : { content: d, path: u };
|
|
986
986
|
}
|
|
987
987
|
})
|
|
988
988
|
};
|
|
@@ -1184,13 +1184,13 @@ function parseIntersectionDef(t, e) {
|
|
|
1184
1184
|
if (isJsonSchema7AllOfType(o))
|
|
1185
1185
|
r.push(...o.allOf), o.unevaluatedProperties === void 0 && (i = void 0);
|
|
1186
1186
|
else {
|
|
1187
|
-
let
|
|
1187
|
+
let s = o;
|
|
1188
1188
|
if ("additionalProperties" in o && o.additionalProperties === !1) {
|
|
1189
|
-
const { additionalProperties:
|
|
1190
|
-
|
|
1189
|
+
const { additionalProperties: a, ...c } = o;
|
|
1190
|
+
s = c;
|
|
1191
1191
|
} else
|
|
1192
1192
|
i = void 0;
|
|
1193
|
-
r.push(
|
|
1193
|
+
r.push(s);
|
|
1194
1194
|
}
|
|
1195
1195
|
}), r.length ? {
|
|
1196
1196
|
allOf: r,
|
|
@@ -1402,16 +1402,16 @@ 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,
|
|
1405
|
+
let r = "", o = !1, s = !1, a = !1;
|
|
1406
1406
|
for (let c = 0; c < i.length; c++) {
|
|
1407
1407
|
if (o) {
|
|
1408
1408
|
r += i[c], o = !1;
|
|
1409
1409
|
continue;
|
|
1410
1410
|
}
|
|
1411
1411
|
if (n.i) {
|
|
1412
|
-
if (
|
|
1412
|
+
if (s) {
|
|
1413
1413
|
if (i[c].match(/[a-z]/)) {
|
|
1414
|
-
|
|
1414
|
+
a ? (r += i[c], r += `${i[c - 2]}-${i[c]}`.toUpperCase(), a = !1) : i[c + 1] === "-" && i[c + 2]?.match(/[a-z]/) ? (r += i[c], a = !0) : r += `${i[c]}${i[c].toUpperCase()}`;
|
|
1415
1415
|
continue;
|
|
1416
1416
|
}
|
|
1417
1417
|
} else if (i[c].match(/[a-z]/)) {
|
|
@@ -1431,12 +1431,12 @@ function stringifyRegExpWithFlags(t, e) {
|
|
|
1431
1431
|
}
|
|
1432
1432
|
}
|
|
1433
1433
|
if (n.s && i[c] === ".") {
|
|
1434
|
-
r +=
|
|
1434
|
+
r += s ? `${i[c]}\r
|
|
1435
1435
|
` : `[${i[c]}\r
|
|
1436
1436
|
]`;
|
|
1437
1437
|
continue;
|
|
1438
1438
|
}
|
|
1439
|
-
r += i[c], i[c] === "\\" ? o = !0 :
|
|
1439
|
+
r += i[c], i[c] === "\\" ? o = !0 : s && i[c] === "]" ? s = !1 : !s && i[c] === "[" && (s = !0);
|
|
1440
1440
|
}
|
|
1441
1441
|
try {
|
|
1442
1442
|
new RegExp(r);
|
|
@@ -1549,20 +1549,20 @@ function parseUnionDef(t, e) {
|
|
|
1549
1549
|
const n = t.options instanceof Map ? Array.from(t.options.values()) : t.options;
|
|
1550
1550
|
if (n.every((i) => i._def.typeName in primitiveMappings && (!i._def.checks || !i._def.checks.length))) {
|
|
1551
1551
|
const i = n.reduce((r, o) => {
|
|
1552
|
-
const
|
|
1553
|
-
return
|
|
1552
|
+
const s = primitiveMappings[o._def.typeName];
|
|
1553
|
+
return s && !r.includes(s) ? [...r, s] : r;
|
|
1554
1554
|
}, []);
|
|
1555
1555
|
return {
|
|
1556
1556
|
type: i.length > 1 ? i : i[0]
|
|
1557
1557
|
};
|
|
1558
1558
|
} else if (n.every((i) => i._def.typeName === "ZodLiteral" && !i.description)) {
|
|
1559
1559
|
const i = n.reduce((r, o) => {
|
|
1560
|
-
const
|
|
1561
|
-
switch (
|
|
1560
|
+
const s = typeof o._def.value;
|
|
1561
|
+
switch (s) {
|
|
1562
1562
|
case "string":
|
|
1563
1563
|
case "number":
|
|
1564
1564
|
case "boolean":
|
|
1565
|
-
return [...r,
|
|
1565
|
+
return [...r, s];
|
|
1566
1566
|
case "bigint":
|
|
1567
1567
|
return [...r, "integer"];
|
|
1568
1568
|
case "object":
|
|
@@ -1576,10 +1576,10 @@ function parseUnionDef(t, e) {
|
|
|
1576
1576
|
}
|
|
1577
1577
|
}, []);
|
|
1578
1578
|
if (i.length === n.length) {
|
|
1579
|
-
const r = i.filter((o,
|
|
1579
|
+
const r = i.filter((o, s, a) => a.indexOf(o) === s);
|
|
1580
1580
|
return {
|
|
1581
1581
|
type: r.length > 1 ? r : r[0],
|
|
1582
|
-
enum: n.reduce((o,
|
|
1582
|
+
enum: n.reduce((o, s) => o.includes(s._def.value) ? o : [...o, s._def.value], [])
|
|
1583
1583
|
};
|
|
1584
1584
|
}
|
|
1585
1585
|
} else if (n.every((i) => i._def.typeName === "ZodEnum"))
|
|
@@ -1651,22 +1651,22 @@ 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 a in o) {
|
|
1655
|
+
let c = o[a];
|
|
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", a],
|
|
1663
|
+
propertyPath: [...e.currentPath, "properties", a]
|
|
1664
1664
|
});
|
|
1665
|
-
|
|
1665
|
+
u !== void 0 && (i.properties[a] = u, d || r.push(a));
|
|
1666
1666
|
}
|
|
1667
1667
|
r.length && (i.required = r);
|
|
1668
|
-
const
|
|
1669
|
-
return
|
|
1668
|
+
const s = decideAdditionalProperties(t, e);
|
|
1669
|
+
return s !== void 0 && (i.additionalProperties = s), i;
|
|
1670
1670
|
}
|
|
1671
1671
|
function decideAdditionalProperties(t, e) {
|
|
1672
1672
|
if (t.catchall._def.typeName !== "ZodNever")
|
|
@@ -1843,23 +1843,23 @@ 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 a = e.override?.(t, e, i, n);
|
|
1847
|
+
if (a !== ignoreOverride)
|
|
1848
|
+
return a;
|
|
1849
1849
|
}
|
|
1850
1850
|
if (i && !n) {
|
|
1851
|
-
const
|
|
1852
|
-
if (
|
|
1853
|
-
return
|
|
1851
|
+
const a = get$ref(i, e);
|
|
1852
|
+
if (a !== void 0)
|
|
1853
|
+
return a;
|
|
1854
1854
|
}
|
|
1855
1855
|
const r = { def: t, path: e.currentPath, jsonSchema: void 0 };
|
|
1856
1856
|
e.seen.set(t, r);
|
|
1857
|
-
const o = selectParser(t, t.typeName, e),
|
|
1858
|
-
if (
|
|
1859
|
-
const
|
|
1860
|
-
return r.jsonSchema =
|
|
1857
|
+
const o = selectParser(t, t.typeName, e), s = typeof o == "function" ? parseDef(o(), e) : o;
|
|
1858
|
+
if (s && addMeta(t, e, s), e.postProcess) {
|
|
1859
|
+
const a = e.postProcess(s, t, e);
|
|
1860
|
+
return r.jsonSchema = s, a;
|
|
1861
1861
|
}
|
|
1862
|
-
return r.jsonSchema =
|
|
1862
|
+
return r.jsonSchema = s, s;
|
|
1863
1863
|
}
|
|
1864
1864
|
const get$ref = (t, e) => {
|
|
1865
1865
|
switch (e.$refStrategy) {
|
|
@@ -1890,7 +1890,7 @@ const get$ref = (t, e) => {
|
|
|
1890
1890
|
].join("/")
|
|
1891
1891
|
}
|
|
1892
1892
|
}));
|
|
1893
|
-
const
|
|
1893
|
+
const s = r === void 0 ? i ? {
|
|
1894
1894
|
...o,
|
|
1895
1895
|
[n.definitionPath]: i
|
|
1896
1896
|
} : o : {
|
|
@@ -1904,147 +1904,8 @@ const get$ref = (t, e) => {
|
|
|
1904
1904
|
[r]: o
|
|
1905
1905
|
}
|
|
1906
1906
|
};
|
|
1907
|
-
return n.target === "jsonSchema7" ?
|
|
1908
|
-
}, pageAgentPrompt =
|
|
1909
|
-
|
|
1910
|
-
你是浏览器页面的操作工具,你拥有识别网页内容,点击,填写,选择下拉框和滚动页面等功能。
|
|
1911
|
-
|
|
1912
|
-
在执行页面操作之前,你必须先调用\`browserState\`工具一次,根据最新的网页状态,再调用操作动作,比如 'click','fill','select' 等动作。
|
|
1913
|
-
|
|
1914
|
-
<intro>
|
|
1915
|
-
你擅长以下任务:
|
|
1916
|
-
1. 导航复杂网站并提取精确信息
|
|
1917
|
-
2. 自动化表单提交和交互式网页操作
|
|
1918
|
-
3. 收集和保存信息
|
|
1919
|
-
4. 在代理循环中有效运行
|
|
1920
|
-
5. 高效执行多样化的网页任务
|
|
1921
|
-
</intro>
|
|
1922
|
-
|
|
1923
|
-
<input>
|
|
1924
|
-
在每一步,你的输入将包括:
|
|
1925
|
-
1. <agent_history>:一个按时间顺序排列的事件流,包括你之前的操作及其结果。
|
|
1926
|
-
2. <agent_state>:当前的 <user_request> 和 <step_info>。
|
|
1927
|
-
3. <browser_state>:当前 URL、页面标题、可交互元素总数以及语义化 YAML 树。
|
|
1928
|
-
</input>
|
|
1929
|
-
|
|
1930
|
-
<browser_state>
|
|
1931
|
-
|
|
1932
|
-
浏览器状态包含以下内容:
|
|
1933
|
-
|
|
1934
|
-
- url: 当前查看页面的 URL。
|
|
1935
|
-
- title: 当前查看页面的标题。
|
|
1936
|
-
- 可交互元素总数:带有 \`#N\` 标记的元素数量。
|
|
1937
|
-
- YAML 树:页面的语义化结构,格式如下:
|
|
1938
|
-
|
|
1939
|
-
\`\`\`yaml
|
|
1940
|
-
- region:
|
|
1941
|
-
- main:
|
|
1942
|
-
- button #9 [cursor=pointer] "产品文档"
|
|
1943
|
-
- button #47 [selected] [cursor=pointer] "40元/月 2核CPU 2GB内存"
|
|
1944
|
-
- radio #53 [checked] [cursor=pointer] "自动生成密码"
|
|
1945
|
-
- button #74 [cursor=pointer] "立即购买"
|
|
1946
|
-
- generic #6 [cf-uba="serviceList..Flexus云服务"] "Flexus云服务"
|
|
1947
|
-
\`\`\`
|
|
1948
|
-
|
|
1949
|
-
节点格式说明:
|
|
1950
|
-
- \`- role #N [token1] [token2] "accessible name"\`
|
|
1951
|
-
- \`role\`:ARIA 语义角色(如 button/link/radio/heading/listitem/generic 等)
|
|
1952
|
-
- \`#N\`:可交互元素的唯一操作索引,**只有带 \`#N\` 的节点才能被操作**,操作时将 N 作为 \`index\` 参数传入
|
|
1953
|
-
- \`[token]\`:可选 token,包括状态标记(如 \`[checked]\` \`[selected]\` \`[disabled]\` \`[cursor=pointer]\`)和定制属性(如 \`[cf-uba="..."]\`)
|
|
1954
|
-
- \`"accessible name"\`:元素的语义化名称,**用双引号包裹**(通过 aria-label/aria-labelledby/innerText 等计算得出);无名称的节点此字段省略
|
|
1955
|
-
- 缩进表示父子关系
|
|
1956
|
-
|
|
1957
|
-
</browser_state>
|
|
1958
|
-
|
|
1959
|
-
<responseMode>
|
|
1960
|
-
|
|
1961
|
-
\`page-agent-tool\` 支持 \`responseMode\` 参数,用于控制操作后返回的页面状态形式:
|
|
1962
|
-
|
|
1963
|
-
- **\`diff\`**(默认):仅返回自上一次状态以来的增量 DOM 差异,极大节省 Token。
|
|
1964
|
-
- **\`full\`**:返回当前视口中完整的语义化 ARIA YAML 树。
|
|
1965
|
-
- **\`both\`**:同时返回全量树和增量差异。
|
|
1966
|
-
|
|
1967
|
-
执行 \`click\`、\`fill\`、\`select\`、\`scroll\` 操作后,工具默认自动以 \`diff\` 模式返回最新页面状态,无需再次手动调用 \`browserState\`。
|
|
1968
|
-
|
|
1969
|
-
</responseMode>
|
|
1970
|
-
|
|
1971
|
-
<browser_state_diff>
|
|
1972
|
-
|
|
1973
|
-
在交互过程中,为了提高效率和减少上下文占用,工具会生成页面的增量差异(Diff)信息。
|
|
1974
|
-
Diff 格式示例如下:
|
|
1975
|
-
\`\`\`diff
|
|
1976
|
-
- button #9: 产品文档
|
|
1977
|
-
+ button #9: 产品文档 (已点击)
|
|
1978
|
-
\`\`\`
|
|
1979
|
-
或者,当页面结构发生改变时,会展示新增或移除的节点差异。
|
|
1980
|
-
|
|
1981
|
-
### 页面状态获取四原则(重要,请严格遵守):
|
|
1982
|
-
|
|
1983
|
-
> 与业界 AI 编辑器(Cursor / Windsurf)按需读取文件而非全量加载的理念完全一致——**先精准搜索,再按需拉取全量**,将发送给大模型的 token 降至最低。
|
|
1984
|
-
|
|
1985
|
-
1. **按关键词精准搜索(最高优先级)**:当你已知要找什么类型的元素(如按钮、输入框、特定名称的链接)时,**优先使用 \`searchTree\` 动作**,传入 role 名称、元素文本或状态关键词搜索。它只返回命中行和上下文,token 消耗比全量树减少 80%+。
|
|
1986
|
-
- 示例:查找所有按钮 → \`{"action": "searchTree", "query": "button"}\`
|
|
1987
|
-
- 示例:查找含"提交"文本的节点 → \`{"action": "searchTree", "query": "提交"}\`
|
|
1988
|
-
- 示例:查找已勾选的复选框 → \`{"action": "searchTree", "query": "checked"}\`
|
|
1989
|
-
- 示例:精确定位某个 ref → \`{"action": "searchTree", "query": "#5"}\`
|
|
1990
|
-
2. **首次获取全量**:首次进入页面、页面发生重大刷新、或 \`searchTree\` 无法找到所需信息时,调用 \`browserState\` 并指定 \`responseMode\` 为 \`full\` 或 \`both\` 获取完整 A11y 树。
|
|
1991
|
-
3. **增量优先**:执行 \`click\`、\`fill\`、\`select\`、\`scroll\` 操作后,工具默认自动返回 \`diff\` 增量信息。优先阅读这些 Diff,以便快速确认操作是否生效。
|
|
1992
|
-
4. **按需拉取全量**:如果增量 Diff 不足以支持下一步操作,或需要寻找不在 Diff 中的 \`#N\` 节点,且 \`searchTree\` 也无法定位时,再显式调用 \`browserState\` 拉取完整树。
|
|
1993
|
-
|
|
1994
|
-
</browser_state_diff>
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
<browser_rules>
|
|
1999
|
-
在使用浏览器和浏览网页时严格遵守以下规则:
|
|
2000
|
-
|
|
2001
|
-
- 仅与分配有 \`#N\` 索引的元素进行交互,将 N 作为 \`index\` 参数传入。
|
|
2002
|
-
- 仅使用明确出现在树中的 \`#N\` 索引,切勿猜测或沿用过期索引。
|
|
2003
|
-
- 每次操作后 \`#N\` 索引会重新分配,不要使用旧的索引。
|
|
2004
|
-
- 如果页面在执行操作后发生变化(例如输入文本操作),分析是否需要与新元素进行交互,例如从列表中选择正确的选项。
|
|
2005
|
-
- 默认情况下,仅列出可见视口中的元素。如果你怀疑需要交互的相关内容在屏幕外,请使用滚动操作。仅在页面下方或上方还有更多像素时才滚动。
|
|
2006
|
-
- 你可以使用 num_pages 参数滚动特定页数(例如,0.5 表示半页,2.0 表示两页)。
|
|
2007
|
-
- 如果出现验证码,告诉用户你无法解决验证码。完成任务并请用户解决它。
|
|
2008
|
-
- 如果缺少预期元素,尝试滚动或导航回退。
|
|
2009
|
-
- 除非某些条件发生变化,否则不要重复同一操作超过 3 次。
|
|
2010
|
-
- 如果你向输入字段填充文本且操作序列被中断,通常意味着某些内容发生了变化,例如下拉建议弹出。
|
|
2011
|
-
- 如果 <user_request> 包含特定的页面信息,如产品类型、评分、价格、位置等,尝试应用过滤器以提高效率。
|
|
2012
|
-
- <user_request> 是最终目标。如果用户指定了明确的步骤,它们始终具有最高优先级。
|
|
2013
|
-
- 如果你向字段输入文本,可能需要按回车键、点击搜索按钮或从下拉列表中选择以完成操作。
|
|
2014
|
-
- **不要通过 executeJavascript 向页面插入 DOM 元素**(如创建 div 显示调试信息)。这会污染页面结构并影响后续操作。如需读取数据,使用 return 语句返回结果即可。
|
|
2015
|
-
- 如果操作返回中出现 \`[校验提示]\`,说明页面有表单校验错误未通过,请先根据提示修复错误后再继续操作。
|
|
2016
|
-
- 如果操作后页面没有发生预期变化,优先检查是否有 \`[校验提示]\` 或 \`[error]\` token 的错误信息,而非重复操作。
|
|
2017
|
-
- 如果不需要,不要登录页面。如果没有凭据,不要登录。
|
|
2018
|
-
- 有两种类型的任务,首先思考你正在处理哪种类型的请求:
|
|
2019
|
-
|
|
2020
|
-
1. 非常具体的逐步说明:
|
|
2021
|
-
|
|
2022
|
-
- 非常精确地遵循它们,不要跳过步骤。尝试按要求完成所有内容。
|
|
2023
|
-
|
|
2024
|
-
2. 开放式任务。自己规划,在实现目标时保持创造性。
|
|
2025
|
-
|
|
2026
|
-
- 如果在开放式任务中陷入困境(例如登录或验证码),可以重新评估任务并尝试替代方法,例如有时即使页面的某些部分可访问或通过 Web 搜索获取一些信息,也会意外弹出登录框。
|
|
2027
|
-
</browser_rules>
|
|
2028
|
-
|
|
2029
|
-
<capability>
|
|
2030
|
-
- 你只能处理单页应用。不要跳出当前页面。
|
|
2031
|
-
- 如果链接将在新页面中打开(例如,<a target="_blank">),不要点击该链接。
|
|
2032
|
-
- 任务失败是可以接受的。
|
|
2033
|
-
- 用户可能是错的。如果用户的请求无法实现、不适当,或者你没有足够的信息或工具来实现它。告诉用户提出更好的请求。
|
|
2034
|
-
- 网页可能已损坏。所有网页或应用都有 bug。有些 bug 会使你的工作变得困难。鼓励你告诉用户当前页面的问题。你的反馈(包括失败)对用户很有价值。
|
|
2035
|
-
- 过于努力可能有害。来回重复某些操作或在知识有限的情况下推动复杂程序可能导致不良结果和有害副作用。用户宁愿你以失败告终完成任务。
|
|
2036
|
-
- 如果你对当前网页或任务没有相关知识。你必须要求用户提供具体说明和详细步骤。
|
|
2037
|
-
</capability>
|
|
2038
|
-
|
|
2039
|
-
<task_completion_rules>
|
|
2040
|
-
你必须在以下情况时结束任务:
|
|
2041
|
-
|
|
2042
|
-
- 当你完全完成用户请求时。
|
|
2043
|
-
- 当你感到困惑或无法解决用户请求时。或者用户请求不清楚或包含不当内容。
|
|
2044
|
-
- 如果绝对不可能继续。
|
|
2045
|
-
|
|
2046
|
-
</task_completion_rules>
|
|
2047
|
-
`;
|
|
1907
|
+
return n.target === "jsonSchema7" ? s.$schema = "http://json-schema.org/draft-07/schema#" : (n.target === "jsonSchema2019-09" || n.target === "openAi") && (s.$schema = "https://json-schema.org/draft/2019-09/schema#"), n.target === "openAi" && ("anyOf" in s || "oneOf" in s || "allOf" in s || "type" in s && Array.isArray(s.type)) && console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."), s;
|
|
1908
|
+
}, pageAgentPrompt = '## 角色\n\n你是浏览器页面的操作工具,你拥有识别网页内容,点击,填写,选择下拉框、悬浮(hover)和滚动页面等功能。\n\n在执行页面操作之前,你必须先调用`browserState`工具一次,根据最新的网页状态,再调用操作动作,比如 \'click\',\'fill\',\'select\',\'hover\' 等动作。\n\n<intro>\n你擅长以下任务:\n1. 导航复杂网站并提取精确信息\n2. 自动化表单提交和交互式网页操作\n3. 收集和保存信息\n4. 在代理循环中有效运行\n5. 高效执行多样化的网页任务\n</intro>\n\n<input>\n在每一步,你的输入将包括:\n1. <agent_history>:一个按时间顺序排列的事件流,包括你之前的操作及其结果。\n2. <agent_state>:当前的 <user_request> 和 <step_info>。\n3. <browser_state>:当前 URL、页面标题、可交互元素总数以及语义化 YAML 树。\n</input>\n\n<browser_state>\n\n浏览器状态包含以下内容:\n\n- url: 当前查看页面的 URL。\n- title: 当前查看页面的标题。\n- content: 语义化 YAML 树(或增量 Diff,取决于 responseMode)。\n- dialogs(可选): 当前可见的模态弹窗列表,每项含 `text` 与 `buttons`;若存在请优先处理。\n- validationErrors(可选): 当前可见的表单校验错误文案列表;若存在请先修复。\n- tooltips(可选): 当前可见的 tooltip / 浮层提示文案列表(常见于 hover 后)。\n- 可交互元素总数:带有 `#N` 标记的元素数量。\n- YAML 树:页面的语义化结构,格式如下:\n\n```yaml\n- region:\n - main:\n - button #9 [cursor=pointer] "产品文档"\n - button #47 [selected] [cursor=pointer] "40元/月 2核CPU 2GB内存"\n - radio #53 [checked] [cursor=pointer] "自动生成密码"\n - button #74 [cursor=pointer] "立即购买"\n - generic #6 [cf-uba="serviceList..Flexus云服务"] "Flexus云服务"\n```\n\n节点格式说明:\n- `- role #N [token1] [token2] "accessible name"`\n- `role`:ARIA 语义角色(如 button/link/radio/heading/listitem/generic 等)\n- `#N`:可交互元素的唯一操作索引,**只有带 `#N` 的节点才能被操作**,操作时将 N 作为 `index` 参数传入\n- `[token]`:可选 token,包括状态标记(如 `[checked]` `[selected]` `[pressed]` `[current]` `[expanded]` `[hasPopup]` `[disabled]` `[readonly]` `[required]` `[invalid]` `[busy]` `[error]` `[warning]` `[cursor=pointer]` `[tooltip="帮助文本"]`)和定制属性(如 `[cf-uba="..."]`)\n- `"accessible name"`:元素的语义化名称,**用双引号包裹**(通过 aria-label/aria-labelledby/innerText 等计算得出);无名称的节点此字段省略\n- 缩进表示父子关系\n\n</browser_state>\n\n<responseMode>\n\n`page-agent-tool` 支持 `responseMode` 参数,用于控制操作后返回的页面状态形式:\n\n- **`diff`**(默认):仅返回自上一次状态以来的增量 DOM 差异,极大节省 Token。\n- **`full`**:返回当前视口中完整的语义化 ARIA YAML 树。\n- **`both`**:同时返回全量树和增量差异。\n\n执行 `click`、`fill`、`select`、`scroll` 操作后,工具默认自动以 `diff` 模式返回最新页面状态,无需再次手动调用 `browserState`。`hover` 动作返回重建后的页面状态(含 `tooltips` 等结构化字段)。\n\n</responseMode>\n\n<browser_state_diff>\n\n在交互过程中,为了提高效率和减少上下文占用,工具会生成页面的增量差异(Diff)信息。\nDiff 格式示例如下:\n```diff\n- button #9: 产品文档\n+ button #9: 产品文档 (已点击)\n```\n或者,当页面结构发生改变时,会展示新增或移除的节点差异。\n\n### 页面状态获取四原则(重要,请严格遵守):\n\n> 与业界 AI 编辑器(Cursor / Windsurf)按需读取文件而非全量加载的理念完全一致——**先精准搜索,再按需拉取全量**,将发送给大模型的 token 降至最低。\n\n1. **按关键词精准搜索(最高优先级)**:当你已知要找什么类型的元素(如按钮、输入框、特定名称的链接)时,**优先使用 `searchTree` 动作**,传入 role 名称、元素文本或状态关键词搜索。它只返回命中行和上下文,token 消耗比全量树减少 80%+。\n - 示例:查找所有按钮 → `{"action": "searchTree", "query": "button"}`\n - 示例:查找含"提交"文本的节点 → `{"action": "searchTree", "query": "提交"}`\n - 示例:查找已勾选的复选框 → `{"action": "searchTree", "query": "checked"}`\n - 示例:精确定位某个 ref → `{"action": "searchTree", "query": "#5"}`\n2. **首次获取全量**:首次进入页面、页面发生重大刷新、或 `searchTree` 无法找到所需信息时,调用 `browserState` 并指定 `responseMode` 为 `full` 或 `both` 获取完整 A11y 树。\n3. **增量优先**:执行 `click`、`fill`、`select`、`scroll` 操作后,工具默认自动返回 `diff` 增量信息。优先阅读这些 Diff,以便快速确认操作是否生效。\n4. **按需拉取全量**:如果增量 Diff 不足以支持下一步操作,或需要寻找不在 Diff 中的 `#N` 节点,且 `searchTree` 也无法定位时,再显式调用 `browserState` 拉取完整树。\n\n</browser_state_diff>\n\n\n\n<browser_rules>\n在使用浏览器和浏览网页时严格遵守以下规则:\n\n- 仅与分配有 `#N` 索引的元素进行交互,将 N 作为 `index` 参数传入。\n- 仅使用明确出现在树中的 `#N` 索引,切勿猜测或沿用过期索引。\n- 每次操作后 `#N` 索引会重新分配,不要使用旧的索引。\n- 如果页面在执行操作后发生变化(例如输入文本操作),分析是否需要与新元素进行交互,例如从列表中选择正确的选项。\n- 默认情况下,仅列出可见视口中的元素。如果你怀疑需要交互的相关内容在屏幕外,请使用滚动操作。仅在页面下方或上方还有更多像素时才滚动。\n- 你可以使用 num_pages 参数滚动特定页数(例如,0.5 表示半页,2.0 表示两页)。\n- 如果出现验证码,告诉用户你无法解决验证码。完成任务并请用户解决它。\n- 如果缺少预期元素,尝试滚动或导航回退。\n- 除非某些条件发生变化,否则不要重复同一操作超过 3 次。\n- 如果你向输入字段填充文本且操作序列被中断,通常意味着某些内容发生了变化,例如下拉建议弹出。\n- 如果 <user_request> 包含特定的页面信息,如产品类型、评分、价格、位置等,尝试应用过滤器以提高效率。\n- <user_request> 是最终目标。如果用户指定了明确的步骤,它们始终具有最高优先级。\n- 如果你向字段输入文本,可能需要按回车键、点击搜索按钮或从下拉列表中选择以完成操作。\n- 对于带有 `[tooltip="..."]` token 的元素,可以直接阅读提示文本。对于标记为 `tooltip [hasPopup]` 的元素(如帮助提示图标),tooltip 文本需 hover 才会动态出现——**使用 `hover` 动作并传入元素索引即可触发并获取 tooltip 内容**。hover 返回浮层提示文本 + 重建后的完整页面状态,`#N` 索引会更新,可继续操作新出现的交互元素。\n- **对 tooltip 触发元素优先使用 `hover` 而非 `click`**:click 可能触发标签页切换或 DOM 重建导致 ref 索引失效,而 hover 只触发 pointer/mouse 事件,安全且返回 tooltip 内容。\n- **不要通过 executeJavascript 向页面插入 DOM 元素**(如创建 div 显示调试信息)。这会污染页面结构并影响后续操作。如需读取数据,使用 return 语句返回结果即可。\n- 如果操作返回中出现 `[校验提示]`,说明页面有表单校验错误未通过,请先根据提示修复错误后再继续操作。\n- 如果操作后页面没有发生预期变化,优先检查是否有 `[校验提示]` 或 `[error]` token 的错误信息,而非重复操作。\n- 如果不需要,不要登录页面。如果没有凭据,不要登录。\n- 有两种类型的任务,首先思考你正在处理哪种类型的请求:\n\n1. 非常具体的逐步说明:\n\n- 非常精确地遵循它们,不要跳过步骤。尝试按要求完成所有内容。\n\n2. 开放式任务。自己规划,在实现目标时保持创造性。\n\n- 如果在开放式任务中陷入困境(例如登录或验证码),可以重新评估任务并尝试替代方法,例如有时即使页面的某些部分可访问或通过 Web 搜索获取一些信息,也会意外弹出登录框。\n </browser_rules>\n\n<capability>\n- 你只能处理单页应用。不要跳出当前页面。\n- 如果链接将在新页面中打开(例如,<a target="_blank">),不要点击该链接。\n- 任务失败是可以接受的。\n - 用户可能是错的。如果用户的请求无法实现、不适当,或者你没有足够的信息或工具来实现它。告诉用户提出更好的请求。\n - 网页可能已损坏。所有网页或应用都有 bug。有些 bug 会使你的工作变得困难。鼓励你告诉用户当前页面的问题。你的反馈(包括失败)对用户很有价值。\n - 过于努力可能有害。来回重复某些操作或在知识有限的情况下推动复杂程序可能导致不良结果和有害副作用。用户宁愿你以失败告终完成任务。\n- 如果你对当前网页或任务没有相关知识。你必须要求用户提供具体说明和详细步骤。\n</capability>\n\n<task_completion_rules>\n你必须在以下情况时结束任务:\n\n- 当你完全完成用户请求时。\n- 当你感到困惑或无法解决用户请求时。或者用户请求不清楚或包含不当内容。\n- 如果绝对不可能继续。\n\n</task_completion_rules>\n';
|
|
2048
1909
|
function isHTMLElement(t) {
|
|
2049
1910
|
return !!t && t.nodeType === 1;
|
|
2050
1911
|
}
|
|
@@ -2114,28 +1975,28 @@ async function clickElement(t) {
|
|
|
2114
1975
|
await movePointerToElement(t, i, r), await clickPointer(), await waitFor(0.1);
|
|
2115
1976
|
const o = t.ownerDocument;
|
|
2116
1977
|
await enablePassThrough();
|
|
2117
|
-
const
|
|
1978
|
+
const s = o.elementFromPoint(i, r);
|
|
2118
1979
|
await disablePassThrough();
|
|
2119
|
-
const
|
|
1980
|
+
const a = s instanceof HTMLElement && t.contains(s) ? s : t, c = {
|
|
2120
1981
|
bubbles: !0,
|
|
2121
1982
|
cancelable: !0,
|
|
2122
1983
|
clientX: i,
|
|
2123
1984
|
clientY: r,
|
|
2124
1985
|
pointerType: "mouse"
|
|
2125
|
-
},
|
|
1986
|
+
}, d = {
|
|
2126
1987
|
bubbles: !0,
|
|
2127
1988
|
cancelable: !0,
|
|
2128
1989
|
clientX: i,
|
|
2129
1990
|
clientY: r,
|
|
2130
1991
|
button: 0
|
|
2131
1992
|
};
|
|
2132
|
-
|
|
1993
|
+
a.dispatchEvent(new PointerEvent("pointerover", c)), a.dispatchEvent(new PointerEvent("pointerenter", {
|
|
2133
1994
|
...c,
|
|
2134
1995
|
bubbles: !1
|
|
2135
|
-
})),
|
|
2136
|
-
...
|
|
1996
|
+
})), a.dispatchEvent(new MouseEvent("mouseover", d)), a.dispatchEvent(new MouseEvent("mouseenter", {
|
|
1997
|
+
...d,
|
|
2137
1998
|
bubbles: !1
|
|
2138
|
-
})),
|
|
1999
|
+
})), a.dispatchEvent(new PointerEvent("pointerdown", c)), a.dispatchEvent(new MouseEvent("mousedown", d)), t.focus({ preventScroll: !0 }), a.dispatchEvent(new PointerEvent("pointerup", c)), a.dispatchEvent(new MouseEvent("mouseup", d)), a.click(), await waitFor(0.2);
|
|
2139
2000
|
}
|
|
2140
2001
|
async function inputTextElement(t, e) {
|
|
2141
2002
|
const n = t.isContentEditable;
|
|
@@ -2182,94 +2043,94 @@ async function scrollIntoViewIfNeeded(t) {
|
|
|
2182
2043
|
}
|
|
2183
2044
|
async function scrollVertically(t, e) {
|
|
2184
2045
|
if (e) {
|
|
2185
|
-
const
|
|
2186
|
-
let
|
|
2187
|
-
const
|
|
2188
|
-
for (;
|
|
2189
|
-
const m = window.getComputedStyle(
|
|
2190
|
-
if (g &&
|
|
2191
|
-
const
|
|
2192
|
-
let
|
|
2193
|
-
|
|
2194
|
-
const T =
|
|
2046
|
+
const s = e;
|
|
2047
|
+
let a = s, c = !1, d = null, u = 0, h = 0;
|
|
2048
|
+
const p = t;
|
|
2049
|
+
for (; a && h < 10; ) {
|
|
2050
|
+
const m = window.getComputedStyle(a), g = /(auto|scroll|overlay)/.test(m.overflowY) || m.scrollbarWidth && m.scrollbarWidth !== "auto" || m.scrollbarGutter && m.scrollbarGutter !== "auto", E = a.scrollHeight > a.clientHeight;
|
|
2051
|
+
if (g && E) {
|
|
2052
|
+
const L = a.scrollTop, f = a.scrollHeight - a.clientHeight;
|
|
2053
|
+
let b = p / 3;
|
|
2054
|
+
b > 0 ? b = Math.min(b, f - L) : b = Math.max(b, -L), a.scrollTop = L + b;
|
|
2055
|
+
const T = a.scrollTop - L;
|
|
2195
2056
|
if (Math.abs(T) > 0.5) {
|
|
2196
|
-
c = !0,
|
|
2057
|
+
c = !0, d = a, u = T;
|
|
2197
2058
|
break;
|
|
2198
2059
|
}
|
|
2199
2060
|
}
|
|
2200
|
-
if (
|
|
2201
|
-
|
|
2061
|
+
if (a === document.body || a === document.documentElement) break;
|
|
2062
|
+
a = a.parentElement, h++;
|
|
2202
2063
|
}
|
|
2203
|
-
return c ? `Scrolled container (${
|
|
2064
|
+
return c ? `Scrolled container (${d?.tagName}) by ${u}px` : `No scrollable container found for element (${s.tagName})`;
|
|
2204
2065
|
}
|
|
2205
|
-
const n = t, i = (
|
|
2066
|
+
const n = t, i = (s) => s.clientHeight >= window.innerHeight * 0.5, r = (s) => !!(s && /(auto|scroll|overlay)/.test(getComputedStyle(s).overflowY) && s.scrollHeight > s.clientHeight && i(s));
|
|
2206
2067
|
let o = document.activeElement;
|
|
2207
2068
|
for (; o && !r(o) && o !== document.body; ) o = o.parentElement;
|
|
2208
2069
|
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
|
|
2070
|
+
const s = window.scrollY, a = document.documentElement.scrollHeight - window.innerHeight;
|
|
2210
2071
|
window.scrollBy(0, n);
|
|
2211
|
-
const c = window.scrollY,
|
|
2212
|
-
if (Math.abs(
|
|
2213
|
-
const
|
|
2214
|
-
return
|
|
2072
|
+
const c = window.scrollY, d = c - s;
|
|
2073
|
+
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.";
|
|
2074
|
+
const u = n > 0 && c >= a - 1, h = n < 0 && c <= 1;
|
|
2075
|
+
return u ? `✅ Scrolled page by ${d}px. Reached the bottom of the page.` : h ? `✅ Scrolled page by ${d}px. Reached the top of the page.` : `✅ Scrolled page by ${d}px.`;
|
|
2215
2076
|
} else {
|
|
2216
|
-
const
|
|
2217
|
-
console.log(`[PageController] ${
|
|
2218
|
-
const
|
|
2077
|
+
const s = "The document is not scrollable. Falling back to container scroll.";
|
|
2078
|
+
console.log(`[PageController] ${s}`);
|
|
2079
|
+
const a = o.scrollTop, c = o.scrollHeight - o.clientHeight;
|
|
2219
2080
|
o.scrollBy({
|
|
2220
2081
|
top: n,
|
|
2221
2082
|
behavior: "smooth"
|
|
2222
2083
|
}), await waitFor(0.1);
|
|
2223
|
-
const
|
|
2224
|
-
if (Math.abs(
|
|
2225
|
-
const
|
|
2226
|
-
return
|
|
2084
|
+
const d = o.scrollTop, u = d - a;
|
|
2085
|
+
if (Math.abs(u) < 1) return n > 0 ? `⚠️ ${s} Already at the bottom of container (${o.tagName}), cannot scroll down further.` : `⚠️ ${s} Already at the top of container (${o.tagName}), cannot scroll up further.`;
|
|
2086
|
+
const h = n > 0 && d >= c - 1, p = n < 0 && d <= 1;
|
|
2087
|
+
return h ? `✅ ${s} Scrolled container (${o.tagName}) by ${u}px. Reached the bottom.` : p ? `✅ ${s} Scrolled container (${o.tagName}) by ${u}px. Reached the top.` : `✅ ${s} Scrolled container (${o.tagName}) by ${u}px.`;
|
|
2227
2088
|
}
|
|
2228
2089
|
}
|
|
2229
2090
|
async function scrollHorizontally(t, e) {
|
|
2230
2091
|
if (e) {
|
|
2231
|
-
const
|
|
2232
|
-
let
|
|
2233
|
-
const
|
|
2234
|
-
for (;
|
|
2235
|
-
const m = window.getComputedStyle(
|
|
2236
|
-
if (g &&
|
|
2237
|
-
const
|
|
2238
|
-
let
|
|
2239
|
-
|
|
2240
|
-
const T =
|
|
2092
|
+
const s = e;
|
|
2093
|
+
let a = s, c = !1, d = null, u = 0, h = 0;
|
|
2094
|
+
const p = t;
|
|
2095
|
+
for (; a && h < 10; ) {
|
|
2096
|
+
const m = window.getComputedStyle(a), g = /(auto|scroll|overlay)/.test(m.overflowX) || m.scrollbarWidth && m.scrollbarWidth !== "auto" || m.scrollbarGutter && m.scrollbarGutter !== "auto", E = a.scrollWidth > a.clientWidth;
|
|
2097
|
+
if (g && E) {
|
|
2098
|
+
const L = a.scrollLeft, f = a.scrollWidth - a.clientWidth;
|
|
2099
|
+
let b = p / 3;
|
|
2100
|
+
b > 0 ? b = Math.min(b, f - L) : b = Math.max(b, -L), a.scrollLeft = L + b;
|
|
2101
|
+
const T = a.scrollLeft - L;
|
|
2241
2102
|
if (Math.abs(T) > 0.5) {
|
|
2242
|
-
c = !0,
|
|
2103
|
+
c = !0, d = a, u = T;
|
|
2243
2104
|
break;
|
|
2244
2105
|
}
|
|
2245
2106
|
}
|
|
2246
|
-
if (
|
|
2247
|
-
|
|
2107
|
+
if (a === document.body || a === document.documentElement) break;
|
|
2108
|
+
a = a.parentElement, h++;
|
|
2248
2109
|
}
|
|
2249
|
-
return c ? `Scrolled container (${
|
|
2110
|
+
return c ? `Scrolled container (${d?.tagName}) horizontally by ${u}px` : `No horizontally scrollable container found for element (${s.tagName})`;
|
|
2250
2111
|
}
|
|
2251
|
-
const n = t, i = (
|
|
2112
|
+
const n = t, i = (s) => s.clientWidth >= window.innerWidth * 0.5, r = (s) => !!(s && /(auto|scroll|overlay)/.test(getComputedStyle(s).overflowX) && s.scrollWidth > s.clientWidth && i(s));
|
|
2252
2113
|
let o = document.activeElement;
|
|
2253
2114
|
for (; o && !r(o) && o !== document.body; ) o = o.parentElement;
|
|
2254
2115
|
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
|
|
2116
|
+
const s = window.scrollX, a = document.documentElement.scrollWidth - window.innerWidth;
|
|
2256
2117
|
window.scrollBy(n, 0);
|
|
2257
|
-
const c = window.scrollX,
|
|
2258
|
-
if (Math.abs(
|
|
2259
|
-
const
|
|
2260
|
-
return
|
|
2118
|
+
const c = window.scrollX, d = c - s;
|
|
2119
|
+
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.";
|
|
2120
|
+
const u = n > 0 && c >= a - 1, h = n < 0 && c <= 1;
|
|
2121
|
+
return u ? `✅ Scrolled page by ${d}px. Reached the right edge of the page.` : h ? `✅ Scrolled page by ${d}px. Reached the left edge of the page.` : `✅ Scrolled page horizontally by ${d}px.`;
|
|
2261
2122
|
} else {
|
|
2262
|
-
const
|
|
2263
|
-
console.log(`[PageController] ${
|
|
2264
|
-
const
|
|
2123
|
+
const s = "The document is not scrollable. Falling back to container scroll.";
|
|
2124
|
+
console.log(`[PageController] ${s}`);
|
|
2125
|
+
const a = o.scrollLeft, c = o.scrollWidth - o.clientWidth;
|
|
2265
2126
|
o.scrollBy({
|
|
2266
2127
|
left: n,
|
|
2267
2128
|
behavior: "smooth"
|
|
2268
2129
|
}), await waitFor(0.1);
|
|
2269
|
-
const
|
|
2270
|
-
if (Math.abs(
|
|
2271
|
-
const
|
|
2272
|
-
return
|
|
2130
|
+
const d = o.scrollLeft, u = d - a;
|
|
2131
|
+
if (Math.abs(u) < 1) return n > 0 ? `⚠️ ${s} Already at the right edge of container (${o.tagName}), cannot scroll right further.` : `⚠️ ${s} Already at the left edge of container (${o.tagName}), cannot scroll left further.`;
|
|
2132
|
+
const h = n > 0 && d >= c - 1, p = n < 0 && d <= 1;
|
|
2133
|
+
return h ? `✅ ${s} Scrolled container (${o.tagName}) by ${u}px. Reached the right edge.` : p ? `✅ ${s} Scrolled container (${o.tagName}) by ${u}px. Reached the left edge.` : `✅ ${s} Scrolled container (${o.tagName}) horizontally by ${u}px.`;
|
|
2273
2134
|
}
|
|
2274
2135
|
}
|
|
2275
2136
|
var dom_tree_default = (t = {
|
|
@@ -2287,51 +2148,51 @@ var dom_tree_default = (t = {
|
|
|
2287
2148
|
highlightOpacity: 0.1,
|
|
2288
2149
|
highlightLabelOpacity: 0.5
|
|
2289
2150
|
}) => {
|
|
2290
|
-
const { interactiveBlacklist: e, interactiveWhitelist: n, highlightOpacity: i, highlightLabelOpacity: r } = t, { doHighlightElements: o, focusHighlightIndex:
|
|
2291
|
-
let
|
|
2292
|
-
const
|
|
2293
|
-
function
|
|
2294
|
-
!
|
|
2295
|
-
...
|
|
2296
|
-
...
|
|
2151
|
+
const { interactiveBlacklist: e, interactiveWhitelist: n, highlightOpacity: i, highlightLabelOpacity: r } = t, { doHighlightElements: o, focusHighlightIndex: s, viewportExpansion: a, debugMode: c } = t;
|
|
2152
|
+
let d = 0;
|
|
2153
|
+
const u = /* @__PURE__ */ new WeakMap();
|
|
2154
|
+
function h(l, w) {
|
|
2155
|
+
!l || l.nodeType !== Node.ELEMENT_NODE || u.set(l, {
|
|
2156
|
+
...u.get(l),
|
|
2157
|
+
...w
|
|
2297
2158
|
});
|
|
2298
2159
|
}
|
|
2299
|
-
const
|
|
2160
|
+
const p = {
|
|
2300
2161
|
boundingRects: /* @__PURE__ */ new WeakMap(),
|
|
2301
2162
|
clientRects: /* @__PURE__ */ new WeakMap(),
|
|
2302
2163
|
computedStyles: /* @__PURE__ */ new WeakMap(),
|
|
2303
2164
|
clearCache: () => {
|
|
2304
|
-
|
|
2165
|
+
p.boundingRects = /* @__PURE__ */ new WeakMap(), p.clientRects = /* @__PURE__ */ new WeakMap(), p.computedStyles = /* @__PURE__ */ new WeakMap();
|
|
2305
2166
|
}
|
|
2306
2167
|
};
|
|
2307
|
-
function m(
|
|
2308
|
-
if (!
|
|
2309
|
-
if (
|
|
2310
|
-
const
|
|
2311
|
-
return
|
|
2312
|
-
}
|
|
2313
|
-
function g(
|
|
2314
|
-
if (!
|
|
2315
|
-
if (
|
|
2316
|
-
const
|
|
2317
|
-
return
|
|
2318
|
-
}
|
|
2319
|
-
function
|
|
2320
|
-
if (!
|
|
2321
|
-
if (
|
|
2322
|
-
const
|
|
2323
|
-
return
|
|
2324
|
-
}
|
|
2325
|
-
const
|
|
2326
|
-
function T(
|
|
2327
|
-
if (!
|
|
2328
|
-
const
|
|
2329
|
-
let _ = null,
|
|
2168
|
+
function m(l) {
|
|
2169
|
+
if (!l) return null;
|
|
2170
|
+
if (p.boundingRects.has(l)) return p.boundingRects.get(l);
|
|
2171
|
+
const w = l.getBoundingClientRect();
|
|
2172
|
+
return w && p.boundingRects.set(l, w), w;
|
|
2173
|
+
}
|
|
2174
|
+
function g(l) {
|
|
2175
|
+
if (!l) return null;
|
|
2176
|
+
if (p.computedStyles.has(l)) return p.computedStyles.get(l);
|
|
2177
|
+
const w = window.getComputedStyle(l);
|
|
2178
|
+
return w && p.computedStyles.set(l, w), w;
|
|
2179
|
+
}
|
|
2180
|
+
function E(l) {
|
|
2181
|
+
if (!l) return null;
|
|
2182
|
+
if (p.clientRects.has(l)) return p.clientRects.get(l);
|
|
2183
|
+
const w = l.getClientRects();
|
|
2184
|
+
return w && p.clientRects.set(l, w), w;
|
|
2185
|
+
}
|
|
2186
|
+
const L = {}, f = { current: 0 }, b = "playwright-highlight-container";
|
|
2187
|
+
function T(l, w, M = null) {
|
|
2188
|
+
if (!l) return w;
|
|
2189
|
+
const v = [];
|
|
2190
|
+
let _ = null, O = 20, x = 16, N = null;
|
|
2330
2191
|
try {
|
|
2331
|
-
let k = document.getElementById(
|
|
2332
|
-
k || (k = document.createElement("div"), k.id =
|
|
2333
|
-
const
|
|
2334
|
-
if (!
|
|
2192
|
+
let k = document.getElementById(b);
|
|
2193
|
+
k || (k = document.createElement("div"), k.id = b, 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));
|
|
2194
|
+
const I = l.getClientRects();
|
|
2195
|
+
if (!I || I.length === 0) return w;
|
|
2335
2196
|
const Y = [
|
|
2336
2197
|
"#FF0000",
|
|
2337
2198
|
"#00FF00",
|
|
@@ -2346,133 +2207,133 @@ var dom_tree_default = (t = {
|
|
|
2346
2207
|
"#DC143C",
|
|
2347
2208
|
"#4682B4"
|
|
2348
2209
|
];
|
|
2349
|
-
let
|
|
2350
|
-
const
|
|
2351
|
-
|
|
2210
|
+
let V = Y[w % Y.length];
|
|
2211
|
+
const K = V + Math.floor(i * 255).toString(16).padStart(2, "0");
|
|
2212
|
+
V = V + Math.floor(r * 255).toString(16).padStart(2, "0");
|
|
2352
2213
|
let j = {
|
|
2353
2214
|
x: 0,
|
|
2354
2215
|
y: 0
|
|
2355
2216
|
};
|
|
2356
|
-
if (
|
|
2357
|
-
const H =
|
|
2217
|
+
if (M) {
|
|
2218
|
+
const H = M.getBoundingClientRect();
|
|
2358
2219
|
j.x = H.left, j.y = H.top;
|
|
2359
2220
|
}
|
|
2360
|
-
const
|
|
2361
|
-
for (const H of
|
|
2221
|
+
const se = document.createDocumentFragment();
|
|
2222
|
+
for (const H of I) {
|
|
2362
2223
|
if (H.width === 0 || H.height === 0) continue;
|
|
2363
2224
|
const U = document.createElement("div");
|
|
2364
|
-
U.style.position = "fixed", U.style.border = `2px solid ${
|
|
2365
|
-
const
|
|
2366
|
-
U.style.top = `${
|
|
2225
|
+
U.style.position = "fixed", U.style.border = `2px solid ${V}`, U.style.backgroundColor = K, U.style.pointerEvents = "none", U.style.boxSizing = "border-box";
|
|
2226
|
+
const $ = H.top + j.y, X = H.left + j.x;
|
|
2227
|
+
U.style.top = `${$}px`, U.style.left = `${X}px`, U.style.width = `${H.width}px`, U.style.height = `${H.height}px`, se.appendChild(U), v.push({
|
|
2367
2228
|
element: U,
|
|
2368
2229
|
initialRect: H
|
|
2369
2230
|
});
|
|
2370
2231
|
}
|
|
2371
|
-
const ie =
|
|
2372
|
-
_ = document.createElement("div"), _.className = "playwright-highlight-label", _.style.position = "fixed", _.style.background =
|
|
2232
|
+
const ie = I[0];
|
|
2233
|
+
_ = 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 = w.toString(), O = _.offsetWidth > 0 ? _.offsetWidth : O, x = _.offsetHeight > 0 ? _.offsetHeight : x;
|
|
2373
2234
|
const de = ie.top + j.y, ue = ie.left + j.x;
|
|
2374
|
-
let
|
|
2375
|
-
(ie.width <
|
|
2235
|
+
let ae = de + 2, re = ue + ie.width - O - 2;
|
|
2236
|
+
(ie.width < O + 4 || ie.height < x + 4) && (ae = de - x - 2, re = ue + ie.width - O, re < j.x && (re = ue)), ae = Math.max(0, Math.min(ae, window.innerHeight - x)), re = Math.max(0, Math.min(re, window.innerWidth - O)), _.style.top = `${ae}px`, _.style.left = `${re}px`, se.appendChild(_);
|
|
2376
2237
|
const le = ((H, U) => {
|
|
2377
|
-
let
|
|
2378
|
-
return (...
|
|
2238
|
+
let $ = 0;
|
|
2239
|
+
return (...X) => {
|
|
2379
2240
|
const q = performance.now();
|
|
2380
|
-
if (!(q -
|
|
2381
|
-
return
|
|
2241
|
+
if (!(q - $ < U))
|
|
2242
|
+
return $ = q, H(...X);
|
|
2382
2243
|
};
|
|
2383
2244
|
})(() => {
|
|
2384
|
-
const H =
|
|
2245
|
+
const H = l.getClientRects();
|
|
2385
2246
|
let U = {
|
|
2386
2247
|
x: 0,
|
|
2387
2248
|
y: 0
|
|
2388
2249
|
};
|
|
2389
|
-
if (
|
|
2390
|
-
const
|
|
2391
|
-
U.x =
|
|
2250
|
+
if (M) {
|
|
2251
|
+
const $ = M.getBoundingClientRect();
|
|
2252
|
+
U.x = $.left, U.y = $.top;
|
|
2392
2253
|
}
|
|
2393
|
-
if (
|
|
2394
|
-
if (
|
|
2395
|
-
const q = H[
|
|
2396
|
-
|
|
2397
|
-
} else
|
|
2398
|
-
}), H.length <
|
|
2254
|
+
if (v.forEach(($, X) => {
|
|
2255
|
+
if (X < H.length) {
|
|
2256
|
+
const q = H[X], oe = q.top + U.y, ne = q.left + U.x;
|
|
2257
|
+
$.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";
|
|
2258
|
+
} else $.element.style.display = "none";
|
|
2259
|
+
}), H.length < v.length) for (let $ = H.length; $ < v.length; $++) v[$].element.style.display = "none";
|
|
2399
2260
|
if (_ && H.length > 0) {
|
|
2400
|
-
const
|
|
2401
|
-
let oe =
|
|
2402
|
-
(
|
|
2261
|
+
const $ = H[0], X = $.top + U.y, q = $.left + U.x;
|
|
2262
|
+
let oe = X + 2, ne = q + $.width - O - 2;
|
|
2263
|
+
($.width < O + 4 || $.height < x + 4) && (oe = X - x - 2, ne = q + $.width - O, ne < U.x && (ne = q)), oe = Math.max(0, Math.min(oe, window.innerHeight - x)), ne = Math.max(0, Math.min(ne, window.innerWidth - O)), _.style.top = `${oe}px`, _.style.left = `${ne}px`, _.style.display = "block";
|
|
2403
2264
|
} else _ && (_.style.display = "none");
|
|
2404
2265
|
}, 16);
|
|
2405
|
-
return window.addEventListener("scroll", le, !0), window.addEventListener("resize", le),
|
|
2406
|
-
window.removeEventListener("scroll", le, !0), window.removeEventListener("resize", le),
|
|
2407
|
-
}, k.appendChild(
|
|
2266
|
+
return window.addEventListener("scroll", le, !0), window.addEventListener("resize", le), N = () => {
|
|
2267
|
+
window.removeEventListener("scroll", le, !0), window.removeEventListener("resize", le), v.forEach((H) => H.element.remove()), _ && _.remove();
|
|
2268
|
+
}, k.appendChild(se), w + 1;
|
|
2408
2269
|
} finally {
|
|
2409
|
-
|
|
2270
|
+
N && (window._highlightCleanupFunctions = window._highlightCleanupFunctions || []).push(N);
|
|
2410
2271
|
}
|
|
2411
2272
|
}
|
|
2412
|
-
function
|
|
2413
|
-
if (!
|
|
2414
|
-
const
|
|
2415
|
-
if (!
|
|
2416
|
-
const
|
|
2417
|
-
if (
|
|
2418
|
-
const
|
|
2419
|
-
if (!
|
|
2420
|
-
const k =
|
|
2421
|
-
if (k < Y &&
|
|
2422
|
-
const
|
|
2423
|
-
top:
|
|
2424
|
-
right:
|
|
2425
|
-
bottom:
|
|
2426
|
-
left:
|
|
2273
|
+
function y(l) {
|
|
2274
|
+
if (!l || l.nodeType !== Node.ELEMENT_NODE) return null;
|
|
2275
|
+
const w = g(l);
|
|
2276
|
+
if (!w) return null;
|
|
2277
|
+
const M = w.display;
|
|
2278
|
+
if (M === "inline" || M === "inline-block") return null;
|
|
2279
|
+
const v = w.overflowX, _ = w.overflowY, O = w.scrollbarWidth && w.scrollbarWidth !== "auto" || w.scrollbarGutter && w.scrollbarGutter !== "auto", x = v === "auto" || v === "scroll", N = _ === "auto" || _ === "scroll";
|
|
2280
|
+
if (!x && !N && !O) return null;
|
|
2281
|
+
const k = l.scrollWidth - l.clientWidth, I = l.scrollHeight - l.clientHeight, Y = 4;
|
|
2282
|
+
if (k < Y && I < Y || !N && !O && k < Y || !x && !O && I < Y) return null;
|
|
2283
|
+
const V = l.scrollTop, K = l.scrollLeft, j = {
|
|
2284
|
+
top: V,
|
|
2285
|
+
right: l.scrollWidth - l.clientWidth - l.scrollLeft,
|
|
2286
|
+
bottom: l.scrollHeight - l.clientHeight - l.scrollTop,
|
|
2287
|
+
left: K
|
|
2427
2288
|
};
|
|
2428
|
-
return
|
|
2289
|
+
return h(l, {
|
|
2429
2290
|
scrollable: !0,
|
|
2430
2291
|
scrollData: j
|
|
2431
2292
|
}), j;
|
|
2432
2293
|
}
|
|
2433
|
-
function
|
|
2294
|
+
function C(l) {
|
|
2434
2295
|
try {
|
|
2435
|
-
if (
|
|
2436
|
-
const
|
|
2437
|
-
if (!
|
|
2296
|
+
if (a === -1) {
|
|
2297
|
+
const x = l.parentElement;
|
|
2298
|
+
if (!x) return !1;
|
|
2438
2299
|
try {
|
|
2439
|
-
return
|
|
2300
|
+
return x.checkVisibility({
|
|
2440
2301
|
checkOpacity: !0,
|
|
2441
2302
|
checkVisibilityCSS: !0
|
|
2442
2303
|
});
|
|
2443
2304
|
} catch {
|
|
2444
|
-
const k = window.getComputedStyle(
|
|
2305
|
+
const k = window.getComputedStyle(x);
|
|
2445
2306
|
return k.display !== "none" && k.visibility !== "hidden" && k.opacity !== "0";
|
|
2446
2307
|
}
|
|
2447
2308
|
}
|
|
2448
|
-
const
|
|
2449
|
-
|
|
2450
|
-
const
|
|
2451
|
-
if (!
|
|
2452
|
-
let
|
|
2453
|
-
for (const
|
|
2309
|
+
const w = document.createRange();
|
|
2310
|
+
w.selectNodeContents(l);
|
|
2311
|
+
const M = w.getClientRects();
|
|
2312
|
+
if (!M || M.length === 0) return !1;
|
|
2313
|
+
let v = !1, _ = !1;
|
|
2314
|
+
for (const x of M) if (x.width > 0 && x.height > 0 && (v = !0, !(x.bottom < -a || x.top > window.innerHeight + a || x.right < -a || x.left > window.innerWidth + a))) {
|
|
2454
2315
|
_ = !0;
|
|
2455
2316
|
break;
|
|
2456
2317
|
}
|
|
2457
|
-
if (!
|
|
2458
|
-
const
|
|
2459
|
-
if (!
|
|
2318
|
+
if (!v || !_) return !1;
|
|
2319
|
+
const O = l.parentElement;
|
|
2320
|
+
if (!O) return !1;
|
|
2460
2321
|
try {
|
|
2461
|
-
return
|
|
2322
|
+
return O.checkVisibility({
|
|
2462
2323
|
checkOpacity: !0,
|
|
2463
2324
|
checkVisibilityCSS: !0
|
|
2464
2325
|
});
|
|
2465
2326
|
} catch {
|
|
2466
|
-
const
|
|
2467
|
-
return
|
|
2327
|
+
const N = window.getComputedStyle(O);
|
|
2328
|
+
return N.display !== "none" && N.visibility !== "hidden" && N.opacity !== "0";
|
|
2468
2329
|
}
|
|
2469
|
-
} catch (
|
|
2470
|
-
return console.warn("Error checking text node visibility:",
|
|
2330
|
+
} catch (w) {
|
|
2331
|
+
return console.warn("Error checking text node visibility:", w), !1;
|
|
2471
2332
|
}
|
|
2472
2333
|
}
|
|
2473
|
-
function
|
|
2474
|
-
if (!
|
|
2475
|
-
const
|
|
2334
|
+
function S(l) {
|
|
2335
|
+
if (!l || !l.tagName) return !1;
|
|
2336
|
+
const w = /* @__PURE__ */ new Set([
|
|
2476
2337
|
"body",
|
|
2477
2338
|
"div",
|
|
2478
2339
|
"main",
|
|
@@ -2481,8 +2342,8 @@ var dom_tree_default = (t = {
|
|
|
2481
2342
|
"nav",
|
|
2482
2343
|
"header",
|
|
2483
2344
|
"footer"
|
|
2484
|
-
]),
|
|
2485
|
-
return
|
|
2345
|
+
]), M = l.tagName.toLowerCase();
|
|
2346
|
+
return w.has(M) ? !0 : !(/* @__PURE__ */ new Set([
|
|
2486
2347
|
"svg",
|
|
2487
2348
|
"script",
|
|
2488
2349
|
"style",
|
|
@@ -2490,16 +2351,16 @@ var dom_tree_default = (t = {
|
|
|
2490
2351
|
"meta",
|
|
2491
2352
|
"noscript",
|
|
2492
2353
|
"template"
|
|
2493
|
-
])).has(
|
|
2354
|
+
])).has(M);
|
|
2494
2355
|
}
|
|
2495
|
-
function
|
|
2496
|
-
const
|
|
2497
|
-
return
|
|
2356
|
+
function A(l) {
|
|
2357
|
+
const w = g(l);
|
|
2358
|
+
return l.offsetWidth > 0 && l.offsetHeight > 0 && w?.visibility !== "hidden" && w?.display !== "none";
|
|
2498
2359
|
}
|
|
2499
|
-
function
|
|
2500
|
-
if (!
|
|
2501
|
-
if (n.includes(
|
|
2502
|
-
const
|
|
2360
|
+
function D(l) {
|
|
2361
|
+
if (!l || l.nodeType !== Node.ELEMENT_NODE || e.includes(l)) return !1;
|
|
2362
|
+
if (n.includes(l)) return !0;
|
|
2363
|
+
const w = l.tagName.toLowerCase(), M = g(l), v = /* @__PURE__ */ new Set([
|
|
2503
2364
|
"pointer",
|
|
2504
2365
|
"move",
|
|
2505
2366
|
"text",
|
|
@@ -2537,11 +2398,11 @@ var dom_tree_default = (t = {
|
|
|
2537
2398
|
"initial",
|
|
2538
2399
|
"inherit"
|
|
2539
2400
|
]);
|
|
2540
|
-
function
|
|
2541
|
-
return
|
|
2401
|
+
function O(V) {
|
|
2402
|
+
return V.tagName.toLowerCase() === "html" ? !1 : !!(M?.cursor && v.has(M.cursor));
|
|
2542
2403
|
}
|
|
2543
|
-
if (
|
|
2544
|
-
const
|
|
2404
|
+
if (O(l)) return !0;
|
|
2405
|
+
const x = /* @__PURE__ */ new Set([
|
|
2545
2406
|
"a",
|
|
2546
2407
|
"button",
|
|
2547
2408
|
"input",
|
|
@@ -2554,14 +2415,14 @@ var dom_tree_default = (t = {
|
|
|
2554
2415
|
"optgroup",
|
|
2555
2416
|
"fieldset",
|
|
2556
2417
|
"legend"
|
|
2557
|
-
]),
|
|
2558
|
-
if (
|
|
2559
|
-
if (
|
|
2560
|
-
for (const
|
|
2561
|
-
return !(
|
|
2418
|
+
]), N = /* @__PURE__ */ new Set(["disabled", "readonly"]);
|
|
2419
|
+
if (x.has(w)) {
|
|
2420
|
+
if (M?.cursor && _.has(M.cursor)) return !1;
|
|
2421
|
+
for (const V of N) if (l.hasAttribute(V) || l.getAttribute(V) === "true" || l.getAttribute(V) === "") return !1;
|
|
2422
|
+
return !(l.disabled || l.readOnly || l.inert);
|
|
2562
2423
|
}
|
|
2563
|
-
const k =
|
|
2564
|
-
if (
|
|
2424
|
+
const k = l.getAttribute("role"), I = l.getAttribute("aria-role");
|
|
2425
|
+
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
2426
|
const Y = /* @__PURE__ */ new Set([
|
|
2566
2427
|
"button",
|
|
2567
2428
|
"menu",
|
|
@@ -2582,20 +2443,20 @@ var dom_tree_default = (t = {
|
|
|
2582
2443
|
"option",
|
|
2583
2444
|
"scrollbar"
|
|
2584
2445
|
]);
|
|
2585
|
-
if (
|
|
2446
|
+
if (x.has(w) || k && Y.has(k) || I && Y.has(I)) return !0;
|
|
2586
2447
|
try {
|
|
2587
2448
|
if (typeof getEventListeners == "function") {
|
|
2588
|
-
const
|
|
2449
|
+
const K = getEventListeners(l);
|
|
2589
2450
|
for (const j of [
|
|
2590
2451
|
"click",
|
|
2591
2452
|
"mousedown",
|
|
2592
2453
|
"mouseup",
|
|
2593
2454
|
"dblclick"
|
|
2594
|
-
]) if (
|
|
2455
|
+
]) if (K[j] && K[j].length > 0) return !0;
|
|
2595
2456
|
}
|
|
2596
|
-
const
|
|
2597
|
-
if (typeof
|
|
2598
|
-
const
|
|
2457
|
+
const V = l?.ownerDocument?.defaultView?.getEventListenersForNode || window.getEventListenersForNode;
|
|
2458
|
+
if (typeof V == "function") {
|
|
2459
|
+
const K = V(l);
|
|
2599
2460
|
for (const j of [
|
|
2600
2461
|
"click",
|
|
2601
2462
|
"mousedown",
|
|
@@ -2607,69 +2468,69 @@ var dom_tree_default = (t = {
|
|
|
2607
2468
|
"input",
|
|
2608
2469
|
"focus",
|
|
2609
2470
|
"blur"
|
|
2610
|
-
]) for (const
|
|
2471
|
+
]) for (const se of K) if (se.type === j) return !0;
|
|
2611
2472
|
}
|
|
2612
|
-
for (const
|
|
2473
|
+
for (const K of [
|
|
2613
2474
|
"onclick",
|
|
2614
2475
|
"onmousedown",
|
|
2615
2476
|
"onmouseup",
|
|
2616
2477
|
"ondblclick"
|
|
2617
|
-
]) if (
|
|
2478
|
+
]) if (l.hasAttribute(K) || typeof l[K] == "function") return !0;
|
|
2618
2479
|
} catch {
|
|
2619
2480
|
}
|
|
2620
|
-
return !!
|
|
2621
|
-
}
|
|
2622
|
-
function
|
|
2623
|
-
if (
|
|
2624
|
-
const
|
|
2625
|
-
if (!
|
|
2626
|
-
let
|
|
2627
|
-
for (const
|
|
2628
|
-
|
|
2481
|
+
return !!y(l);
|
|
2482
|
+
}
|
|
2483
|
+
function P(l) {
|
|
2484
|
+
if (a === -1) return !0;
|
|
2485
|
+
const w = E(l);
|
|
2486
|
+
if (!w || w.length === 0) return !1;
|
|
2487
|
+
let M = !1;
|
|
2488
|
+
for (const x of w) if (x.width > 0 && x.height > 0 && !(x.bottom < -a || x.top > window.innerHeight + a || x.right < -a || x.left > window.innerWidth + a)) {
|
|
2489
|
+
M = !0;
|
|
2629
2490
|
break;
|
|
2630
2491
|
}
|
|
2631
|
-
if (!
|
|
2632
|
-
if (
|
|
2633
|
-
let
|
|
2634
|
-
if (!
|
|
2635
|
-
const _ =
|
|
2492
|
+
if (!M) return !1;
|
|
2493
|
+
if (l.ownerDocument !== window.document) return !0;
|
|
2494
|
+
let v = Array.from(w).find((x) => x.width > 0 && x.height > 0);
|
|
2495
|
+
if (!v) return !1;
|
|
2496
|
+
const _ = l.getRootNode();
|
|
2636
2497
|
if (_ instanceof ShadowRoot) {
|
|
2637
|
-
const
|
|
2498
|
+
const x = v.left + v.width / 2, N = v.top + v.height / 2;
|
|
2638
2499
|
try {
|
|
2639
|
-
const k = _.elementFromPoint(
|
|
2500
|
+
const k = _.elementFromPoint(x, N);
|
|
2640
2501
|
if (!k) return !1;
|
|
2641
|
-
let
|
|
2642
|
-
for (;
|
|
2643
|
-
if (
|
|
2644
|
-
|
|
2502
|
+
let I = k;
|
|
2503
|
+
for (; I && I !== _; ) {
|
|
2504
|
+
if (I === l) return !0;
|
|
2505
|
+
I = I.parentElement;
|
|
2645
2506
|
}
|
|
2646
2507
|
return !1;
|
|
2647
2508
|
} catch {
|
|
2648
2509
|
return !0;
|
|
2649
2510
|
}
|
|
2650
2511
|
}
|
|
2651
|
-
const
|
|
2512
|
+
const O = 5;
|
|
2652
2513
|
return [
|
|
2653
2514
|
{
|
|
2654
|
-
x:
|
|
2655
|
-
y:
|
|
2515
|
+
x: v.left + v.width / 2,
|
|
2516
|
+
y: v.top + v.height / 2
|
|
2656
2517
|
},
|
|
2657
2518
|
{
|
|
2658
|
-
x:
|
|
2659
|
-
y:
|
|
2519
|
+
x: v.left + O,
|
|
2520
|
+
y: v.top + O
|
|
2660
2521
|
},
|
|
2661
2522
|
{
|
|
2662
|
-
x:
|
|
2663
|
-
y:
|
|
2523
|
+
x: v.right - O,
|
|
2524
|
+
y: v.bottom - O
|
|
2664
2525
|
}
|
|
2665
|
-
].some(({ x
|
|
2526
|
+
].some(({ x, y: N }) => {
|
|
2666
2527
|
try {
|
|
2667
|
-
const k = document.elementFromPoint(
|
|
2528
|
+
const k = document.elementFromPoint(x, N);
|
|
2668
2529
|
if (!k) return !1;
|
|
2669
|
-
let
|
|
2670
|
-
for (;
|
|
2671
|
-
if (
|
|
2672
|
-
|
|
2530
|
+
let I = k;
|
|
2531
|
+
for (; I && I !== document.documentElement; ) {
|
|
2532
|
+
if (I === l) return !0;
|
|
2533
|
+
I = I.parentElement;
|
|
2673
2534
|
}
|
|
2674
2535
|
return !1;
|
|
2675
2536
|
} catch {
|
|
@@ -2677,19 +2538,19 @@ var dom_tree_default = (t = {
|
|
|
2677
2538
|
}
|
|
2678
2539
|
});
|
|
2679
2540
|
}
|
|
2680
|
-
function
|
|
2681
|
-
if (
|
|
2682
|
-
const
|
|
2683
|
-
if (!
|
|
2684
|
-
const
|
|
2685
|
-
return !
|
|
2541
|
+
function R(l, w) {
|
|
2542
|
+
if (w === -1) return !0;
|
|
2543
|
+
const M = l.getClientRects();
|
|
2544
|
+
if (!M || M.length === 0) {
|
|
2545
|
+
const v = m(l);
|
|
2546
|
+
return !v || v.width === 0 || v.height === 0 ? !1 : !(v.bottom < -w || v.top > window.innerHeight + w || v.right < -w || v.left > window.innerWidth + w);
|
|
2686
2547
|
}
|
|
2687
|
-
for (const
|
|
2688
|
-
if (!(
|
|
2548
|
+
for (const v of M)
|
|
2549
|
+
if (!(v.width === 0 || v.height === 0) && !(v.bottom < -w || v.top > window.innerHeight + w || v.right < -w || v.left > window.innerWidth + w))
|
|
2689
2550
|
return !0;
|
|
2690
2551
|
return !1;
|
|
2691
2552
|
}
|
|
2692
|
-
const
|
|
2553
|
+
const F = [
|
|
2693
2554
|
"aria-expanded",
|
|
2694
2555
|
"aria-checked",
|
|
2695
2556
|
"aria-selected",
|
|
@@ -2704,13 +2565,13 @@ var dom_tree_default = (t = {
|
|
|
2704
2565
|
"aria-valuemin",
|
|
2705
2566
|
"aria-autocomplete"
|
|
2706
2567
|
];
|
|
2707
|
-
function B(
|
|
2708
|
-
for (let
|
|
2568
|
+
function B(l) {
|
|
2569
|
+
for (let w = 0; w < F.length; w++) if (l.hasAttribute(F[w])) return !0;
|
|
2709
2570
|
return !1;
|
|
2710
2571
|
}
|
|
2711
|
-
function
|
|
2712
|
-
if (!
|
|
2713
|
-
const
|
|
2572
|
+
function J(l) {
|
|
2573
|
+
if (!l || l.nodeType !== Node.ELEMENT_NODE) return !1;
|
|
2574
|
+
const w = l.tagName.toLowerCase();
|
|
2714
2575
|
return (/* @__PURE__ */ new Set([
|
|
2715
2576
|
"a",
|
|
2716
2577
|
"button",
|
|
@@ -2720,9 +2581,9 @@ var dom_tree_default = (t = {
|
|
|
2720
2581
|
"details",
|
|
2721
2582
|
"summary",
|
|
2722
2583
|
"label"
|
|
2723
|
-
])).has(
|
|
2584
|
+
])).has(w) ? !0 : l.hasAttribute("onclick") || l.hasAttribute("role") || l.hasAttribute("tabindex") || B(l) || l.hasAttribute("data-action") || l.getAttribute("contenteditable") === "true";
|
|
2724
2585
|
}
|
|
2725
|
-
const
|
|
2586
|
+
const G = /* @__PURE__ */ new Set([
|
|
2726
2587
|
"a",
|
|
2727
2588
|
"button",
|
|
2728
2589
|
"input",
|
|
@@ -2733,7 +2594,7 @@ var dom_tree_default = (t = {
|
|
|
2733
2594
|
"label",
|
|
2734
2595
|
"option",
|
|
2735
2596
|
"li"
|
|
2736
|
-
]),
|
|
2597
|
+
]), Q = /* @__PURE__ */ new Set([
|
|
2737
2598
|
"button",
|
|
2738
2599
|
"link",
|
|
2739
2600
|
"menuitem",
|
|
@@ -2755,20 +2616,20 @@ var dom_tree_default = (t = {
|
|
|
2755
2616
|
"option",
|
|
2756
2617
|
"scrollbar"
|
|
2757
2618
|
]);
|
|
2758
|
-
function ee(
|
|
2759
|
-
if (!
|
|
2760
|
-
const
|
|
2761
|
-
return (
|
|
2762
|
-
}
|
|
2763
|
-
function te(
|
|
2764
|
-
if (!
|
|
2765
|
-
const
|
|
2766
|
-
if (
|
|
2619
|
+
function ee(l) {
|
|
2620
|
+
if (!l || l.nodeType !== Node.ELEMENT_NODE || !A(l)) return !1;
|
|
2621
|
+
const w = l.hasAttribute("role") || l.hasAttribute("tabindex") || l.hasAttribute("onclick") || typeof l.onclick == "function", M = /\b(btn|clickable|menu|item|entry|link)\b/i.test(l.className || ""), v = !!l.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'), _ = [...l.children].some(A), O = l.parentElement && l.parentElement.isSameNode(document.body);
|
|
2622
|
+
return (D(l) || w || M) && _ && v && !O;
|
|
2623
|
+
}
|
|
2624
|
+
function te(l) {
|
|
2625
|
+
if (!l || l.nodeType !== Node.ELEMENT_NODE) return !1;
|
|
2626
|
+
const w = l.tagName.toLowerCase(), M = l.getAttribute("role");
|
|
2627
|
+
if (w === "iframe" || G.has(w) || M && Q.has(M) || 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
2628
|
try {
|
|
2768
|
-
const
|
|
2769
|
-
if (typeof
|
|
2770
|
-
const _ =
|
|
2771
|
-
for (const
|
|
2629
|
+
const v = l?.ownerDocument?.defaultView?.getEventListenersForNode || window.getEventListenersForNode;
|
|
2630
|
+
if (typeof v == "function") {
|
|
2631
|
+
const _ = v(l);
|
|
2632
|
+
for (const O of [
|
|
2772
2633
|
"click",
|
|
2773
2634
|
"mousedown",
|
|
2774
2635
|
"mouseup",
|
|
@@ -2779,7 +2640,7 @@ var dom_tree_default = (t = {
|
|
|
2779
2640
|
"input",
|
|
2780
2641
|
"focus",
|
|
2781
2642
|
"blur"
|
|
2782
|
-
]) for (const
|
|
2643
|
+
]) for (const x of _) if (x.type === O) return !0;
|
|
2783
2644
|
}
|
|
2784
2645
|
if ([
|
|
2785
2646
|
"onmousedown",
|
|
@@ -2791,119 +2652,119 @@ var dom_tree_default = (t = {
|
|
|
2791
2652
|
"oninput",
|
|
2792
2653
|
"onfocus",
|
|
2793
2654
|
"onblur"
|
|
2794
|
-
].some((_) =>
|
|
2655
|
+
].some((_) => l.hasAttribute(_))) return !0;
|
|
2795
2656
|
} catch {
|
|
2796
2657
|
}
|
|
2797
|
-
return !!(ee(
|
|
2658
|
+
return !!(ee(l) || u.get(l)?.scrollable);
|
|
2798
2659
|
}
|
|
2799
|
-
function
|
|
2800
|
-
if (!
|
|
2660
|
+
function W(l, w, M, v) {
|
|
2661
|
+
if (!l.isInteractive) return !1;
|
|
2801
2662
|
let _ = !1;
|
|
2802
|
-
return
|
|
2663
|
+
return v ? te(w) ? _ = !0 : _ = !1 : _ = !0, _ && (l.isInViewport = R(w, a), (l.isInViewport || a === -1) && (l.highlightIndex = d++, o)) ? (s >= 0 ? s === l.highlightIndex && T(w, l.highlightIndex, M) : T(w, l.highlightIndex, M), !0) : !1;
|
|
2803
2664
|
}
|
|
2804
|
-
function
|
|
2805
|
-
if (!
|
|
2806
|
-
if (
|
|
2807
|
-
const
|
|
2665
|
+
function Z(l, w = null, M = !1) {
|
|
2666
|
+
if (!l || l.id === b || l.nodeType !== Node.ELEMENT_NODE && l.nodeType !== Node.TEXT_NODE || !l || l.id === b || l.dataset?.browserUseIgnore === "true" || l.dataset?.pageAgentIgnore === "true" || l.getAttribute && l.getAttribute("aria-hidden") === "true") return null;
|
|
2667
|
+
if (l === document.body) {
|
|
2668
|
+
const x = {
|
|
2808
2669
|
tagName: "body",
|
|
2809
2670
|
attributes: {},
|
|
2810
2671
|
xpath: "/body",
|
|
2811
2672
|
children: []
|
|
2812
2673
|
};
|
|
2813
|
-
for (const k of
|
|
2814
|
-
const
|
|
2815
|
-
|
|
2674
|
+
for (const k of l.childNodes) {
|
|
2675
|
+
const I = Z(k, w, !1);
|
|
2676
|
+
I && x.children.push(I);
|
|
2816
2677
|
}
|
|
2817
|
-
const
|
|
2818
|
-
return
|
|
2678
|
+
const N = `${f.current++}`;
|
|
2679
|
+
return L[N] = x, N;
|
|
2819
2680
|
}
|
|
2820
|
-
if (
|
|
2821
|
-
if (
|
|
2822
|
-
const
|
|
2823
|
-
if (!
|
|
2824
|
-
const
|
|
2825
|
-
if (!
|
|
2826
|
-
const k = `${
|
|
2827
|
-
return
|
|
2681
|
+
if (l.nodeType !== Node.ELEMENT_NODE && l.nodeType !== Node.TEXT_NODE) return null;
|
|
2682
|
+
if (l.nodeType === Node.TEXT_NODE) {
|
|
2683
|
+
const x = l.textContent?.trim();
|
|
2684
|
+
if (!x) return null;
|
|
2685
|
+
const N = l.parentElement;
|
|
2686
|
+
if (!N || N.tagName.toLowerCase() === "script") return null;
|
|
2687
|
+
const k = `${f.current++}`;
|
|
2688
|
+
return L[k] = {
|
|
2828
2689
|
type: "TEXT_NODE",
|
|
2829
|
-
text:
|
|
2830
|
-
isVisible:
|
|
2690
|
+
text: x,
|
|
2691
|
+
isVisible: C(l)
|
|
2831
2692
|
}, k;
|
|
2832
2693
|
}
|
|
2833
|
-
if (
|
|
2834
|
-
if (
|
|
2835
|
-
const
|
|
2836
|
-
if (!
|
|
2694
|
+
if (l.nodeType === Node.ELEMENT_NODE && !S(l)) return null;
|
|
2695
|
+
if (a !== -1 && !l.shadowRoot) {
|
|
2696
|
+
const x = m(l), N = g(l), k = N && (N.position === "fixed" || N.position === "sticky"), I = l.offsetWidth > 0 || l.offsetHeight > 0;
|
|
2697
|
+
if (!x || !k && !I && (x.bottom < -a || x.top > window.innerHeight + a || x.right < -a || x.left > window.innerWidth + a)) return null;
|
|
2837
2698
|
}
|
|
2838
|
-
const
|
|
2839
|
-
tagName:
|
|
2699
|
+
const v = {
|
|
2700
|
+
tagName: l.tagName.toLowerCase(),
|
|
2840
2701
|
attributes: {},
|
|
2841
2702
|
/**
|
|
2842
2703
|
* @edit no need for xpath
|
|
2843
2704
|
*/
|
|
2844
2705
|
children: []
|
|
2845
2706
|
};
|
|
2846
|
-
if (
|
|
2847
|
-
const
|
|
2848
|
-
for (const
|
|
2849
|
-
const k =
|
|
2850
|
-
|
|
2707
|
+
if (J(l) || l.tagName.toLowerCase() === "iframe" || l.tagName.toLowerCase() === "body") {
|
|
2708
|
+
const x = l.getAttributeNames?.() || [];
|
|
2709
|
+
for (const N of x) {
|
|
2710
|
+
const k = l.getAttribute(N);
|
|
2711
|
+
v.attributes[N] = k;
|
|
2851
2712
|
}
|
|
2852
|
-
|
|
2713
|
+
l.tagName.toLowerCase() === "input" && (l.type === "checkbox" || l.type === "radio") && (v.attributes.checked = l.checked ? "true" : "false");
|
|
2853
2714
|
}
|
|
2854
2715
|
let _ = !1;
|
|
2855
|
-
if (
|
|
2856
|
-
|
|
2857
|
-
const
|
|
2858
|
-
if ((
|
|
2859
|
-
const k =
|
|
2860
|
-
for (const
|
|
2861
|
-
const Y =
|
|
2862
|
-
|
|
2716
|
+
if (l.nodeType === Node.ELEMENT_NODE && (v.isVisible = A(l), v.isVisible)) {
|
|
2717
|
+
v.isTopElement = P(l);
|
|
2718
|
+
const x = l.getAttribute("role"), N = x === "menu" || x === "menubar" || x === "listbox";
|
|
2719
|
+
if ((v.isTopElement || N) && (v.isInteractive = D(l), _ = W(v, l, w, M), v.ref = l, v.isInteractive && Object.keys(v.attributes).length === 0)) {
|
|
2720
|
+
const k = l.getAttributeNames?.() || [];
|
|
2721
|
+
for (const I of k) {
|
|
2722
|
+
const Y = l.getAttribute(I);
|
|
2723
|
+
v.attributes[I] = Y;
|
|
2863
2724
|
}
|
|
2864
2725
|
}
|
|
2865
2726
|
}
|
|
2866
|
-
if (
|
|
2867
|
-
const
|
|
2868
|
-
if (
|
|
2869
|
-
const
|
|
2870
|
-
if (
|
|
2871
|
-
const
|
|
2872
|
-
|
|
2727
|
+
if (l.tagName) {
|
|
2728
|
+
const x = l.tagName.toLowerCase();
|
|
2729
|
+
if (x === "iframe") try {
|
|
2730
|
+
const N = l.contentDocument || l.contentWindow?.document;
|
|
2731
|
+
if (N) for (const k of N.childNodes) {
|
|
2732
|
+
const I = Z(k, l, !1);
|
|
2733
|
+
I && v.children.push(I);
|
|
2873
2734
|
}
|
|
2874
|
-
} catch (
|
|
2875
|
-
console.warn("Unable to access iframe:",
|
|
2735
|
+
} catch (N) {
|
|
2736
|
+
console.warn("Unable to access iframe:", N);
|
|
2876
2737
|
}
|
|
2877
|
-
else if (
|
|
2878
|
-
const k =
|
|
2879
|
-
k &&
|
|
2738
|
+
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 N of l.childNodes) {
|
|
2739
|
+
const k = Z(N, w, _);
|
|
2740
|
+
k && v.children.push(k);
|
|
2880
2741
|
}
|
|
2881
2742
|
else {
|
|
2882
|
-
if (
|
|
2883
|
-
|
|
2884
|
-
for (const
|
|
2885
|
-
const k =
|
|
2886
|
-
k &&
|
|
2743
|
+
if (l.shadowRoot) {
|
|
2744
|
+
v.shadowRoot = !0;
|
|
2745
|
+
for (const N of l.shadowRoot.childNodes) {
|
|
2746
|
+
const k = Z(N, w, _);
|
|
2747
|
+
k && v.children.push(k);
|
|
2887
2748
|
}
|
|
2888
2749
|
}
|
|
2889
|
-
for (const
|
|
2890
|
-
const k =
|
|
2891
|
-
k &&
|
|
2750
|
+
for (const N of l.childNodes) {
|
|
2751
|
+
const k = Z(N, w, _ || M);
|
|
2752
|
+
k && v.children.push(k);
|
|
2892
2753
|
}
|
|
2893
2754
|
}
|
|
2894
2755
|
}
|
|
2895
|
-
if (
|
|
2896
|
-
const
|
|
2897
|
-
if (!(
|
|
2756
|
+
if (v.tagName === "a" && v.children.length === 0 && !v.attributes.href) {
|
|
2757
|
+
const x = m(l);
|
|
2758
|
+
if (!(x && x.width > 0 && x.height > 0 || l.offsetWidth > 0 || l.offsetHeight > 0)) return null;
|
|
2898
2759
|
}
|
|
2899
|
-
|
|
2900
|
-
const
|
|
2901
|
-
return
|
|
2760
|
+
v.extra = u.get(l) || null;
|
|
2761
|
+
const O = `${f.current++}`;
|
|
2762
|
+
return L[O] = v, O;
|
|
2902
2763
|
}
|
|
2903
|
-
const ce =
|
|
2904
|
-
return
|
|
2764
|
+
const ce = Z(document.body);
|
|
2765
|
+
return p.clearCache(), {
|
|
2905
2766
|
rootId: ce,
|
|
2906
|
-
map:
|
|
2767
|
+
map: L
|
|
2907
2768
|
};
|
|
2908
2769
|
}, DEFAULT_VIEWPORT_EXPANSION = -1;
|
|
2909
2770
|
function resolveViewportExpansion(t) {
|
|
@@ -2919,9 +2780,9 @@ var SEMANTIC_TAGS = /* @__PURE__ */ new Set([
|
|
|
2919
2780
|
]), newElementsCache = /* @__PURE__ */ new WeakMap();
|
|
2920
2781
|
function getFlatTree(t) {
|
|
2921
2782
|
const e = resolveViewportExpansion(t.viewportExpansion), n = [];
|
|
2922
|
-
for (const
|
|
2783
|
+
for (const s of t.interactiveBlacklist || []) typeof s == "function" ? n.push(s()) : n.push(s);
|
|
2923
2784
|
const i = [];
|
|
2924
|
-
for (const
|
|
2785
|
+
for (const s of t.interactiveWhitelist || []) typeof s == "function" ? i.push(s()) : i.push(s);
|
|
2925
2786
|
const r = dom_tree_default({
|
|
2926
2787
|
doHighlightElements: !0,
|
|
2927
2788
|
debugMode: !0,
|
|
@@ -2932,11 +2793,11 @@ function getFlatTree(t) {
|
|
|
2932
2793
|
highlightOpacity: t.highlightOpacity ?? 0,
|
|
2933
2794
|
highlightLabelOpacity: t.highlightLabelOpacity ?? 0.1
|
|
2934
2795
|
}), o = window.location.href;
|
|
2935
|
-
for (const
|
|
2936
|
-
const
|
|
2937
|
-
if (
|
|
2938
|
-
const c =
|
|
2939
|
-
newElementsCache.has(c) || (newElementsCache.set(c, o),
|
|
2796
|
+
for (const s in r.map) {
|
|
2797
|
+
const a = r.map[s];
|
|
2798
|
+
if (a.isInteractive && a.ref) {
|
|
2799
|
+
const c = a.ref;
|
|
2800
|
+
newElementsCache.has(c) || (newElementsCache.set(c, o), a.isNew = !0);
|
|
2940
2801
|
}
|
|
2941
2802
|
}
|
|
2942
2803
|
return r;
|
|
@@ -2983,8 +2844,8 @@ function flatTreeToString(t, e = [], n = !1) {
|
|
|
2983
2844
|
"aria-controls",
|
|
2984
2845
|
"aria-owns",
|
|
2985
2846
|
"contenteditable"
|
|
2986
|
-
], r = [...e, ...i], o = (
|
|
2987
|
-
const m = t.map[
|
|
2847
|
+
], r = [...e, ...i], o = (p, m) => p.length > m ? p.substring(0, m) + "..." : p, s = (p) => {
|
|
2848
|
+
const m = t.map[p];
|
|
2988
2849
|
if (!m) return null;
|
|
2989
2850
|
if (m.type === "TEXT_NODE") {
|
|
2990
2851
|
const g = m;
|
|
@@ -2996,10 +2857,10 @@ function flatTreeToString(t, e = [], n = !1) {
|
|
|
2996
2857
|
children: []
|
|
2997
2858
|
};
|
|
2998
2859
|
} else {
|
|
2999
|
-
const g = m,
|
|
3000
|
-
if (g.children) for (const
|
|
3001
|
-
const
|
|
3002
|
-
|
|
2860
|
+
const g = m, E = [];
|
|
2861
|
+
if (g.children) for (const L of g.children) {
|
|
2862
|
+
const f = s(L);
|
|
2863
|
+
f && (f.parent = null, E.push(f));
|
|
3003
2864
|
}
|
|
3004
2865
|
return {
|
|
3005
2866
|
type: "element",
|
|
@@ -3011,78 +2872,78 @@ function flatTreeToString(t, e = [], n = !1) {
|
|
|
3011
2872
|
isNew: g.isNew ?? !1,
|
|
3012
2873
|
highlightIndex: g.highlightIndex,
|
|
3013
2874
|
parent: null,
|
|
3014
|
-
children:
|
|
2875
|
+
children: E,
|
|
3015
2876
|
extra: g.extra ?? {}
|
|
3016
2877
|
};
|
|
3017
2878
|
}
|
|
3018
|
-
},
|
|
3019
|
-
|
|
3020
|
-
for (const g of
|
|
3021
|
-
}, c =
|
|
2879
|
+
}, a = (p, m = null) => {
|
|
2880
|
+
p.parent = m;
|
|
2881
|
+
for (const g of p.children) a(g, p);
|
|
2882
|
+
}, c = s(t.rootId);
|
|
3022
2883
|
if (!c) return "";
|
|
3023
|
-
|
|
3024
|
-
const
|
|
3025
|
-
let m =
|
|
2884
|
+
a(c);
|
|
2885
|
+
const d = (p) => {
|
|
2886
|
+
let m = p.parent;
|
|
3026
2887
|
for (; m; ) {
|
|
3027
2888
|
if (m.type === "element" && m.highlightIndex !== void 0) return !0;
|
|
3028
2889
|
m = m.parent;
|
|
3029
2890
|
}
|
|
3030
2891
|
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
|
|
2892
|
+
}, u = (p, m, g) => {
|
|
2893
|
+
let E = m;
|
|
2894
|
+
const L = " ".repeat(m);
|
|
2895
|
+
if (p.type === "element") {
|
|
2896
|
+
const f = n && p.tagName && SEMANTIC_TAGS.has(p.tagName);
|
|
2897
|
+
if (p.highlightIndex !== void 0) {
|
|
2898
|
+
E += 1;
|
|
2899
|
+
const y = getAllTextTillNextClickableElement(p);
|
|
2900
|
+
let C = "";
|
|
2901
|
+
if (r.length > 0 && p.attributes) {
|
|
2902
|
+
const A = matchAttributes(p.attributes, r), D = Object.keys(A);
|
|
2903
|
+
if (D.length > 1) {
|
|
2904
|
+
const P = /* @__PURE__ */ new Set(), R = {};
|
|
2905
|
+
for (const F of D) {
|
|
2906
|
+
const B = A[F];
|
|
2907
|
+
B.length > 5 && (B in R ? P.add(F) : R[B] = F);
|
|
3047
2908
|
}
|
|
3048
|
-
for (const
|
|
2909
|
+
for (const F of P) delete A[F];
|
|
3049
2910
|
}
|
|
3050
|
-
|
|
3051
|
-
for (const
|
|
2911
|
+
A.role === p.tagName && delete A.role;
|
|
2912
|
+
for (const P of [
|
|
3052
2913
|
"aria-label",
|
|
3053
2914
|
"placeholder",
|
|
3054
2915
|
"title"
|
|
3055
|
-
])
|
|
3056
|
-
Object.keys(
|
|
2916
|
+
]) A[P] && A[P].toLowerCase().trim() === y.toLowerCase().trim() && delete A[P];
|
|
2917
|
+
Object.keys(A).length > 0 && (C = Object.entries(A).map(([P, R]) => `${P}=${o(R, 20)}`).join(" "));
|
|
3057
2918
|
}
|
|
3058
|
-
let
|
|
3059
|
-
if (
|
|
3060
|
-
let
|
|
3061
|
-
|
|
2919
|
+
let S = `${L}${p.isNew ? `*[${p.highlightIndex}]` : `[${p.highlightIndex}]`}<${p.tagName ?? ""}`;
|
|
2920
|
+
if (C && (S += ` ${C}`), p.extra && p.extra.scrollable) {
|
|
2921
|
+
let A = "";
|
|
2922
|
+
p.extra.scrollData?.left && (A += `left=${p.extra.scrollData.left}, `), p.extra.scrollData?.top && (A += `top=${p.extra.scrollData.top}, `), p.extra.scrollData?.right && (A += `right=${p.extra.scrollData.right}, `), p.extra.scrollData?.bottom && (A += `bottom=${p.extra.scrollData.bottom}`), S += ` data-scrollable="${A}"`;
|
|
3062
2923
|
}
|
|
3063
|
-
if (
|
|
3064
|
-
const
|
|
3065
|
-
|
|
3066
|
-
} else
|
|
3067
|
-
|
|
2924
|
+
if (y) {
|
|
2925
|
+
const A = y.trim();
|
|
2926
|
+
C || (S += " "), S += `>${A}`;
|
|
2927
|
+
} else C || (S += " ");
|
|
2928
|
+
S += " />", g.push(S);
|
|
3068
2929
|
}
|
|
3069
|
-
const
|
|
3070
|
-
|
|
3071
|
-
for (const
|
|
3072
|
-
|
|
3073
|
-
} else if (
|
|
3074
|
-
if (
|
|
3075
|
-
|
|
2930
|
+
const b = f && p.highlightIndex === void 0, T = b ? g.length : -1;
|
|
2931
|
+
b && (g.push(`${L}<${p.tagName}>`), E += 1);
|
|
2932
|
+
for (const y of p.children) u(y, E, g);
|
|
2933
|
+
b && (g.length === T + 1 ? g.pop() : g.push(`${L}</${p.tagName}>`));
|
|
2934
|
+
} else if (p.type === "text") {
|
|
2935
|
+
if (d(p)) return;
|
|
2936
|
+
p.parent && p.parent.type === "element" && p.parent.isVisible && p.parent.isTopElement && g.push(`${L}${p.text ?? ""}`);
|
|
3076
2937
|
}
|
|
3077
|
-
},
|
|
3078
|
-
return
|
|
2938
|
+
}, h = [];
|
|
2939
|
+
return u(c, 0, h), h.join(`
|
|
3079
2940
|
`);
|
|
3080
2941
|
}
|
|
3081
2942
|
var getAllTextTillNextClickableElement = (t, e = -1) => {
|
|
3082
2943
|
const n = [], i = (r, o) => {
|
|
3083
2944
|
if (!(e !== -1 && o > e) && !(r.type === "element" && r !== t && r.highlightIndex !== void 0)) {
|
|
3084
2945
|
if (r.type === "text" && r.text) n.push(r.text);
|
|
3085
|
-
else if (r.type === "element") for (const
|
|
2946
|
+
else if (r.type === "element") for (const s of r.children) i(s, o + 1);
|
|
3086
2947
|
}
|
|
3087
2948
|
};
|
|
3088
2949
|
return i(t, 0), n.join(`
|
|
@@ -3133,7 +2994,7 @@ else {
|
|
|
3133
2994
|
}, 500);
|
|
3134
2995
|
}
|
|
3135
2996
|
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,
|
|
2997
|
+
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, s = Math.max(0, i - (window.innerHeight + o)), a = Math.max(0, n - (window.innerWidth + r));
|
|
3137
2998
|
return {
|
|
3138
2999
|
viewport_width: t,
|
|
3139
3000
|
viewport_height: e,
|
|
@@ -3142,13 +3003,13 @@ function getPageInfo() {
|
|
|
3142
3003
|
scroll_x: r,
|
|
3143
3004
|
scroll_y: o,
|
|
3144
3005
|
pixels_above: o,
|
|
3145
|
-
pixels_below:
|
|
3006
|
+
pixels_below: s,
|
|
3146
3007
|
pages_above: e > 0 ? o / e : 0,
|
|
3147
|
-
pages_below: e > 0 ?
|
|
3008
|
+
pages_below: e > 0 ? s / e : 0,
|
|
3148
3009
|
total_pages: e > 0 ? i / e : 0,
|
|
3149
3010
|
current_page_position: o / Math.max(1, i - e),
|
|
3150
3011
|
pixels_left: r,
|
|
3151
|
-
pixels_right:
|
|
3012
|
+
pixels_right: a
|
|
3152
3013
|
};
|
|
3153
3014
|
}
|
|
3154
3015
|
function patchReact(t) {
|
|
@@ -3186,7 +3047,7 @@ var PageController = class extends EventTarget {
|
|
|
3186
3047
|
*/
|
|
3187
3048
|
initMask() {
|
|
3188
3049
|
this.maskReady === null && (this.maskReady = (async () => {
|
|
3189
|
-
const { SimulatorMask: t } = await import("./SimulatorMask-BHVXyogh-
|
|
3050
|
+
const { SimulatorMask: t } = await import("./SimulatorMask-BHVXyogh-CKmEDsYG.js");
|
|
3190
3051
|
this.mask = new t();
|
|
3191
3052
|
})());
|
|
3192
3053
|
}
|
|
@@ -3380,14 +3241,9 @@ ${n.pixels_above > 4 && i !== -1 ? `... ${n.pixels_above} pixels above (${n.page
|
|
|
3380
3241
|
cleanUpHighlights(), this.flatTree = null, this.selectorMap.clear(), this.elementTextMap.clear(), this.simplifiedHTML = "<EMPTY>", this.isIndexed = !1, this.mask?.dispose(), this.mask = null;
|
|
3381
3242
|
}
|
|
3382
3243
|
};
|
|
3383
|
-
const DEFAULT_ERROR_SELECTORS
|
|
3244
|
+
const DEFAULT_ERROR_SELECTORS = [
|
|
3384
3245
|
'[role="alert"]',
|
|
3385
3246
|
'[aria-invalid="true"]',
|
|
3386
|
-
".ti3-unifyvalid-error",
|
|
3387
|
-
".ti3-error",
|
|
3388
|
-
".ti-error",
|
|
3389
|
-
".lego-text-error",
|
|
3390
|
-
".lego-error",
|
|
3391
3247
|
".el-form-item__error",
|
|
3392
3248
|
".ant-form-item-explain-error",
|
|
3393
3249
|
".is-invalid",
|
|
@@ -3403,13 +3259,40 @@ const DEFAULT_ERROR_SELECTORS$1 = [
|
|
|
3403
3259
|
".validate-error",
|
|
3404
3260
|
".valid-error"
|
|
3405
3261
|
], DEFAULT_WARNING_SELECTORS = [
|
|
3406
|
-
".ti3-warning",
|
|
3407
|
-
".ti-warning",
|
|
3408
|
-
".lego-text-warning",
|
|
3409
3262
|
".warning-msg",
|
|
3410
3263
|
".warning-text",
|
|
3411
3264
|
".is-warning",
|
|
3412
3265
|
".has-warning"
|
|
3266
|
+
], DEFAULT_DIALOG_SELECTORS = [
|
|
3267
|
+
// W3C ARIA 标准
|
|
3268
|
+
'[role="dialog"]',
|
|
3269
|
+
'[role="alertdialog"]',
|
|
3270
|
+
// Element UI / Element Plus
|
|
3271
|
+
'[class*="el-dialog"]',
|
|
3272
|
+
'[class*="el-message-box"]',
|
|
3273
|
+
// Ant Design
|
|
3274
|
+
'[class*="ant-modal"]',
|
|
3275
|
+
// Bootstrap
|
|
3276
|
+
'[class*="modal-content"]',
|
|
3277
|
+
// Vuetify
|
|
3278
|
+
'[class*="v-dialog"]',
|
|
3279
|
+
// Naive UI
|
|
3280
|
+
'[class*="n-modal"]'
|
|
3281
|
+
], DEFAULT_TOOLTIP_SELECTORS = [
|
|
3282
|
+
// W3C ARIA 标准
|
|
3283
|
+
'[role="tooltip"]',
|
|
3284
|
+
// Element Plus
|
|
3285
|
+
'[class*="el-tooltip-popper"]',
|
|
3286
|
+
'[class*="el-popper"]',
|
|
3287
|
+
// Ant Design
|
|
3288
|
+
'[class*="ant-tooltip"]',
|
|
3289
|
+
'[class*="ant-popover"]',
|
|
3290
|
+
// Naive UI
|
|
3291
|
+
'[class*="n-tooltip"]',
|
|
3292
|
+
'[class*="n-popover"]',
|
|
3293
|
+
// Vuetify
|
|
3294
|
+
'[class*="v-tooltip"]',
|
|
3295
|
+
'[class*="v-menu"]'
|
|
3413
3296
|
], TAG_ROLE_MAP = {
|
|
3414
3297
|
a: "link",
|
|
3415
3298
|
article: "article",
|
|
@@ -3472,7 +3355,7 @@ const DEFAULT_ERROR_SELECTORS$1 = [
|
|
|
3472
3355
|
time: "time",
|
|
3473
3356
|
tr: "row",
|
|
3474
3357
|
ul: "list"
|
|
3475
|
-
}, INPUT_TYPE_ROLE = {
|
|
3358
|
+
}, DEFAULT_ROLE_OVERRIDES = [], INPUT_TYPE_ROLE = {
|
|
3476
3359
|
button: "button",
|
|
3477
3360
|
checkbox: "checkbox",
|
|
3478
3361
|
color: "textbox",
|
|
@@ -3488,7 +3371,222 @@ const DEFAULT_ERROR_SELECTORS$1 = [
|
|
|
3488
3371
|
tel: "textbox",
|
|
3489
3372
|
text: "textbox",
|
|
3490
3373
|
url: "textbox"
|
|
3491
|
-
};
|
|
3374
|
+
}, RESOLVED_A11Y_BRAND = Symbol.for("@opentiny/next-sdk:ResolvedA11yConfig");
|
|
3375
|
+
function markResolved(t) {
|
|
3376
|
+
return Object.assign(t, { [RESOLVED_A11Y_BRAND]: !0 });
|
|
3377
|
+
}
|
|
3378
|
+
function isResolvedA11yConfig(t) {
|
|
3379
|
+
return !!t && t[RESOLVED_A11Y_BRAND] === !0;
|
|
3380
|
+
}
|
|
3381
|
+
const STANDARD_STATE_NAMES = [
|
|
3382
|
+
"checked",
|
|
3383
|
+
"selected",
|
|
3384
|
+
"pressed",
|
|
3385
|
+
"current",
|
|
3386
|
+
"expanded",
|
|
3387
|
+
"hasPopup",
|
|
3388
|
+
"disabled",
|
|
3389
|
+
"readonly",
|
|
3390
|
+
"required",
|
|
3391
|
+
"invalid",
|
|
3392
|
+
"busy",
|
|
3393
|
+
"error",
|
|
3394
|
+
"warning"
|
|
3395
|
+
], DEFAULT_SELECTED_CLASS_RE = /\b(is-active|isActive|is-selected|isSelected|is-current|isCurrent|active-item|activeItem|tab-active|tabActive|active|selected|current)\b/;
|
|
3396
|
+
function defaultSelectedMatch(t) {
|
|
3397
|
+
const e = typeof t.className == "string" ? t.className : "";
|
|
3398
|
+
if (!e || !DEFAULT_SELECTED_CLASS_RE.test(e)) return !1;
|
|
3399
|
+
const n = t.getAttribute("role") || t.tagName.toLowerCase();
|
|
3400
|
+
return ["button", "option", "a", "li", "generic"].includes(n) || n.startsWith("tab");
|
|
3401
|
+
}
|
|
3402
|
+
const DEFAULT_A11Y_CONFIG = markResolved({
|
|
3403
|
+
// 框架级 role 覆盖:Tiny3 Tabs、tp-helptip 等非标准 UI 组件(规则定义见 constants.ts)
|
|
3404
|
+
// + dialog/tooltip 选择器转为 role 规则,统一走 roles 通道做 role 推断与 DOM 检测
|
|
3405
|
+
roles: [
|
|
3406
|
+
...DEFAULT_ROLE_OVERRIDES,
|
|
3407
|
+
// Dialog:补齐缺失的 role="dialog"(如 Tiny3 ti3-modal、Element Plus el-dialog)
|
|
3408
|
+
...DEFAULT_DIALOG_SELECTORS.map((t) => ({ selector: t, role: "dialog" })),
|
|
3409
|
+
// Tooltip:补齐缺失的 role="tooltip"(如 Tiny3 ti3-tooltip、Element Plus el-tooltip-popper)
|
|
3410
|
+
...DEFAULT_TOOLTIP_SELECTORS.map((t) => ({ selector: t, role: "tooltip" }))
|
|
3411
|
+
],
|
|
3412
|
+
states: {
|
|
3413
|
+
selected: [
|
|
3414
|
+
{ match: defaultSelectedMatch },
|
|
3415
|
+
// Tiny3 按钮组/单选按钮组:选中 class 在容器上(.ti3-btn-item-container.ti3-active),
|
|
3416
|
+
// 内部 button 自身无 aria-selected / ti3-active,需靠 closest 命中
|
|
3417
|
+
{ selector: ".ti3-btn-item-container.ti3-active" }
|
|
3418
|
+
],
|
|
3419
|
+
error: [{ selector: DEFAULT_ERROR_SELECTORS }],
|
|
3420
|
+
warning: [{ selector: DEFAULT_WARNING_SELECTORS }]
|
|
3421
|
+
},
|
|
3422
|
+
whitelist: [],
|
|
3423
|
+
blacklist: [],
|
|
3424
|
+
exposedAttributes: []
|
|
3425
|
+
});
|
|
3426
|
+
function normalizeSelector(t) {
|
|
3427
|
+
return t && (Array.isArray(t) ? t.filter(Boolean).join(", ") : t) || void 0;
|
|
3428
|
+
}
|
|
3429
|
+
function getSelectorsForRole(t, e) {
|
|
3430
|
+
const n = [];
|
|
3431
|
+
for (const i of t)
|
|
3432
|
+
i.role !== e || !i.selector || (Array.isArray(i.selector) ? n.push(...i.selector.filter(Boolean)) : n.push(i.selector));
|
|
3433
|
+
return n;
|
|
3434
|
+
}
|
|
3435
|
+
function matchesRule(t, e) {
|
|
3436
|
+
if (e.match)
|
|
3437
|
+
try {
|
|
3438
|
+
return !!e.match(t);
|
|
3439
|
+
} catch {
|
|
3440
|
+
return !1;
|
|
3441
|
+
}
|
|
3442
|
+
const n = normalizeSelector(e.selector);
|
|
3443
|
+
if (n)
|
|
3444
|
+
try {
|
|
3445
|
+
return !!t.closest(n);
|
|
3446
|
+
} catch {
|
|
3447
|
+
return !1;
|
|
3448
|
+
}
|
|
3449
|
+
return !1;
|
|
3450
|
+
}
|
|
3451
|
+
function matchesRoleRule(t, e) {
|
|
3452
|
+
if (e.match)
|
|
3453
|
+
try {
|
|
3454
|
+
return !!e.match(t);
|
|
3455
|
+
} catch {
|
|
3456
|
+
return !1;
|
|
3457
|
+
}
|
|
3458
|
+
const n = normalizeSelector(e.selector);
|
|
3459
|
+
if (n)
|
|
3460
|
+
try {
|
|
3461
|
+
return !!t.matches(n);
|
|
3462
|
+
} catch {
|
|
3463
|
+
return !1;
|
|
3464
|
+
}
|
|
3465
|
+
return !1;
|
|
3466
|
+
}
|
|
3467
|
+
function matchesAnyRule(t, e) {
|
|
3468
|
+
return e ? (Array.isArray(e) ? e : [e]).some((i) => matchesRule(t, i)) : !1;
|
|
3469
|
+
}
|
|
3470
|
+
function extractSelectors(t) {
|
|
3471
|
+
return t ? (Array.isArray(t) ? t : [t]).flatMap((n) => Array.isArray(n.selector) ? n.selector.filter(Boolean) : n.selector ? [n.selector] : []) : [];
|
|
3472
|
+
}
|
|
3473
|
+
function concatArr(t, e) {
|
|
3474
|
+
return [...t ?? [], ...e ?? []];
|
|
3475
|
+
}
|
|
3476
|
+
function normalizeMatcherList(t) {
|
|
3477
|
+
return t ? Array.isArray(t) ? t : [t] : [];
|
|
3478
|
+
}
|
|
3479
|
+
function mergeStates(t, e) {
|
|
3480
|
+
const n = {}, i = /* @__PURE__ */ new Set([...Object.keys(t ?? {}), ...Object.keys(e ?? {})]);
|
|
3481
|
+
for (const r of i)
|
|
3482
|
+
n[r] = [...normalizeMatcherList(t?.[r]), ...normalizeMatcherList(e?.[r])];
|
|
3483
|
+
return n;
|
|
3484
|
+
}
|
|
3485
|
+
function mergeA11yConfigs(t, e) {
|
|
3486
|
+
return markResolved({
|
|
3487
|
+
roles: concatArr(t.roles, e.roles),
|
|
3488
|
+
states: mergeStates(t.states, e.states),
|
|
3489
|
+
whitelist: concatArr(t.whitelist, e.whitelist),
|
|
3490
|
+
blacklist: concatArr(t.blacklist, e.blacklist),
|
|
3491
|
+
exposedAttributes: concatArr(t.exposedAttributes, e.exposedAttributes)
|
|
3492
|
+
});
|
|
3493
|
+
}
|
|
3494
|
+
function mergeA11yConfig(t) {
|
|
3495
|
+
return isResolvedA11yConfig(t) ? t : mergeA11yConfigs(DEFAULT_A11Y_CONFIG, t ?? {});
|
|
3496
|
+
}
|
|
3497
|
+
function ensureResolvedA11yConfig(t) {
|
|
3498
|
+
return isResolvedA11yConfig(t) ? t : mergeA11yConfig(t);
|
|
3499
|
+
}
|
|
3500
|
+
function defineA11yConfig(t) {
|
|
3501
|
+
return t;
|
|
3502
|
+
}
|
|
3503
|
+
function computeRole(t, e) {
|
|
3504
|
+
const n = t.getAttribute("role"), i = !!n && n !== "presentation" && n !== "none";
|
|
3505
|
+
for (const o of e.roles)
|
|
3506
|
+
if (!(i && !o.force) && matchesRoleRule(t, o))
|
|
3507
|
+
return o.role;
|
|
3508
|
+
if (i) return n;
|
|
3509
|
+
const r = t.tagName.toLowerCase();
|
|
3510
|
+
if (r === "input") {
|
|
3511
|
+
const o = t.type?.toLowerCase() ?? "text";
|
|
3512
|
+
return INPUT_TYPE_ROLE[o] ?? "textbox";
|
|
3513
|
+
}
|
|
3514
|
+
return TAG_ROLE_MAP[r] ?? "generic";
|
|
3515
|
+
}
|
|
3516
|
+
function computeStates(t, e) {
|
|
3517
|
+
const n = [], i = (b) => t.getAttribute(b), r = e.states, o = (b) => matchesAnyRule(t, r[b]), s = i("aria-checked");
|
|
3518
|
+
if (s === "true")
|
|
3519
|
+
n.push("checked");
|
|
3520
|
+
else if (s === "mixed")
|
|
3521
|
+
n.push("checked=mixed");
|
|
3522
|
+
else if (s === "false")
|
|
3523
|
+
n.push("unchecked");
|
|
3524
|
+
else {
|
|
3525
|
+
const b = t.tagName.toLowerCase();
|
|
3526
|
+
let T;
|
|
3527
|
+
if (b === "input" && (t.type === "checkbox" || t.type === "radio"))
|
|
3528
|
+
T = t.checked;
|
|
3529
|
+
else if (b === "label" && t.hasAttribute("for")) {
|
|
3530
|
+
const y = document.getElementById(t.getAttribute("for"));
|
|
3531
|
+
y instanceof HTMLInputElement && (y.type === "checkbox" || y.type === "radio") && (T = y.checked);
|
|
3532
|
+
}
|
|
3533
|
+
T !== void 0 ? n.push(T ? "checked" : "unchecked") : o("checked") && n.push("checked");
|
|
3534
|
+
}
|
|
3535
|
+
(i("aria-selected") === "true" || o("selected")) && n.push("selected");
|
|
3536
|
+
const a = i("aria-pressed");
|
|
3537
|
+
a === "true" ? n.push("pressed") : a === "mixed" ? n.push("pressed=mixed") : a !== "false" && o("pressed") && n.push("pressed");
|
|
3538
|
+
const c = i("aria-current");
|
|
3539
|
+
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");
|
|
3540
|
+
const d = i("aria-haspopup");
|
|
3541
|
+
(d && d !== "false" || o("hasPopup")) && n.push("hasPopup"), (i("aria-expanded") === "true" || o("expanded")) && n.push("expanded");
|
|
3542
|
+
const u = i("aria-invalid");
|
|
3543
|
+
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");
|
|
3544
|
+
const h = i("aria-orientation");
|
|
3545
|
+
h && n.push(`orientation=${h}`);
|
|
3546
|
+
const p = i("aria-sort");
|
|
3547
|
+
p && p !== "none" && n.push(`sort=${p}`), i("aria-multiselectable") === "true" && n.push("multiselectable");
|
|
3548
|
+
const m = t.tagName.match(/^H([1-6])$/);
|
|
3549
|
+
m && n.push(`level=${m[1]}`);
|
|
3550
|
+
const g = i("aria-level");
|
|
3551
|
+
g && !m && n.push(`level=${g}`);
|
|
3552
|
+
try {
|
|
3553
|
+
window.getComputedStyle(t).cursor === "pointer" && n.push("cursor=pointer");
|
|
3554
|
+
} catch {
|
|
3555
|
+
}
|
|
3556
|
+
const E = t.tagName.toLowerCase();
|
|
3557
|
+
if (E === "input" || E === "textarea" || E === "select") {
|
|
3558
|
+
const b = t.value;
|
|
3559
|
+
b !== void 0 && b !== "" && n.push(`value="${b}"`);
|
|
3560
|
+
}
|
|
3561
|
+
const L = i("aria-valuenow");
|
|
3562
|
+
L && n.push(`valuenow="${L}"`);
|
|
3563
|
+
const f = i("aria-valuetext");
|
|
3564
|
+
if (f && n.push(`valuetext="${f}"`), E === "a") {
|
|
3565
|
+
const b = i("target");
|
|
3566
|
+
b && n.push(`target=${b}`);
|
|
3567
|
+
}
|
|
3568
|
+
o("error") ? n.push("error") : o("warning") && n.push("warning");
|
|
3569
|
+
for (const b of Object.keys(r))
|
|
3570
|
+
STANDARD_STATE_NAMES.includes(b) || matchesAnyRule(t, r[b]) && n.push(b);
|
|
3571
|
+
for (const b of e.exposedAttributes) {
|
|
3572
|
+
const T = t.getAttribute(b);
|
|
3573
|
+
T !== null && n.push(`${b}="${T}"`);
|
|
3574
|
+
}
|
|
3575
|
+
return Array.from(new Set(n));
|
|
3576
|
+
}
|
|
3577
|
+
function resolveA11yRole(t, e) {
|
|
3578
|
+
return computeRole(t, ensureResolvedA11yConfig(e));
|
|
3579
|
+
}
|
|
3580
|
+
function resolveA11yStates(t, e) {
|
|
3581
|
+
return computeStates(t, ensureResolvedA11yConfig(e));
|
|
3582
|
+
}
|
|
3583
|
+
function resolveA11yInfo(t, e) {
|
|
3584
|
+
const n = ensureResolvedA11yConfig(e);
|
|
3585
|
+
return {
|
|
3586
|
+
role: computeRole(t, n),
|
|
3587
|
+
tokens: computeStates(t, n)
|
|
3588
|
+
};
|
|
3589
|
+
}
|
|
3492
3590
|
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
3591
|
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, getRootNode = !NoElement && Element.prototype.getRootNode ? function(t) {
|
|
3494
3592
|
var e;
|
|
@@ -3520,16 +3618,16 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
|
|
|
3520
3618
|
}, isTabbableRadio = function t(e) {
|
|
3521
3619
|
if (!e.name)
|
|
3522
3620
|
return !0;
|
|
3523
|
-
var n = e.form || getRootNode(e), i = function(
|
|
3524
|
-
return n.querySelectorAll('input[type="radio"][name="' +
|
|
3621
|
+
var n = e.form || getRootNode(e), i = function(a) {
|
|
3622
|
+
return n.querySelectorAll('input[type="radio"][name="' + a + '"]');
|
|
3525
3623
|
}, r;
|
|
3526
3624
|
if (typeof window < "u" && typeof window.CSS < "u" && typeof window.CSS.escape == "function")
|
|
3527
3625
|
r = i(window.CSS.escape(e.name));
|
|
3528
3626
|
else
|
|
3529
3627
|
try {
|
|
3530
3628
|
r = i(e.name);
|
|
3531
|
-
} catch (
|
|
3532
|
-
return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",
|
|
3629
|
+
} catch (s) {
|
|
3630
|
+
return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", s.message), !1;
|
|
3533
3631
|
}
|
|
3534
3632
|
var o = getCheckedRadio(r, e.form);
|
|
3535
3633
|
return !o || o === e;
|
|
@@ -3540,10 +3638,10 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
|
|
|
3540
3638
|
}, isNodeAttached = function t(e) {
|
|
3541
3639
|
var n, i = e && getRootNode(e), r = (n = i) === null || n === void 0 ? void 0 : n.host, o = !1;
|
|
3542
3640
|
if (i && i !== e) {
|
|
3543
|
-
var
|
|
3544
|
-
for (o = !!((
|
|
3545
|
-
var
|
|
3546
|
-
i = getRootNode(r), r = (
|
|
3641
|
+
var s, a, c;
|
|
3642
|
+
for (o = !!((s = r) !== null && s !== void 0 && (a = s.ownerDocument) !== null && a !== void 0 && a.contains(r) || e != null && (c = e.ownerDocument) !== null && c !== void 0 && c.contains(e)); !o && r; ) {
|
|
3643
|
+
var d, u, h;
|
|
3644
|
+
i = getRootNode(r), r = (d = i) === null || d === void 0 ? void 0 : d.host, o = !!((u = r) !== null && u !== void 0 && (h = u.ownerDocument) !== null && h !== void 0 && h.contains(r));
|
|
3547
3645
|
}
|
|
3548
3646
|
}
|
|
3549
3647
|
return o;
|
|
@@ -3568,23 +3666,23 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
|
|
|
3568
3666
|
});
|
|
3569
3667
|
return !o;
|
|
3570
3668
|
}
|
|
3571
|
-
var
|
|
3572
|
-
if (
|
|
3669
|
+
var s = getComputedStyle(e), a = s.visibility;
|
|
3670
|
+
if (a === "hidden" || a === "collapse")
|
|
3573
3671
|
return !0;
|
|
3574
|
-
var c = matches.call(e, "details>summary:first-of-type"),
|
|
3575
|
-
if (matches.call(
|
|
3672
|
+
var c = matches.call(e, "details>summary:first-of-type"), d = c ? e.parentElement : e;
|
|
3673
|
+
if (matches.call(d, "details:not([open]) *"))
|
|
3576
3674
|
return !0;
|
|
3577
3675
|
if (!i || i === "full" || // full-native can run this branch when it falls through in case
|
|
3578
3676
|
// Element#checkVisibility is unsupported
|
|
3579
3677
|
i === "full-native" || i === "legacy-full") {
|
|
3580
3678
|
if (typeof r == "function") {
|
|
3581
|
-
for (var
|
|
3582
|
-
var
|
|
3583
|
-
if (
|
|
3679
|
+
for (var u = e; e; ) {
|
|
3680
|
+
var h = e.parentElement, p = getRootNode(e);
|
|
3681
|
+
if (h && !h.shadowRoot && r(h) === !0)
|
|
3584
3682
|
return isZeroArea(e);
|
|
3585
|
-
e.assignedSlot ? e = e.assignedSlot : !
|
|
3683
|
+
e.assignedSlot ? e = e.assignedSlot : !h && p !== e.ownerDocument ? e = p.host : e = h;
|
|
3586
3684
|
}
|
|
3587
|
-
e =
|
|
3685
|
+
e = u;
|
|
3588
3686
|
}
|
|
3589
3687
|
if (isNodeAttached(e))
|
|
3590
3688
|
return !e.getClientRects().length;
|
|
@@ -3617,98 +3715,193 @@ var candidateSelectors = ["input:not([inert]):not([inert] *)", "select:not([iner
|
|
|
3617
3715
|
throw new Error("No node provided");
|
|
3618
3716
|
return matches.call(e, candidateSelector) === !1 ? !1 : isNodeMatchingSelectorTabbable(n, e);
|
|
3619
3717
|
};
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
}
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3718
|
+
const DEFAULT_PAGE_AGENT_TOOL_CONFIG = {
|
|
3719
|
+
enableHighlight: !1,
|
|
3720
|
+
removeMaskAfterToolCall: !0,
|
|
3721
|
+
a11yConfig: DEFAULT_A11Y_CONFIG
|
|
3722
|
+
};
|
|
3723
|
+
function getPageAgentToolConfig() {
|
|
3724
|
+
return typeof window < "u" && window.__webmcpcli_toolConfig ? window.__webmcpcli_toolConfig : {
|
|
3725
|
+
enableHighlight: DEFAULT_PAGE_AGENT_TOOL_CONFIG.enableHighlight,
|
|
3726
|
+
removeMaskAfterToolCall: DEFAULT_PAGE_AGENT_TOOL_CONFIG.removeMaskAfterToolCall,
|
|
3727
|
+
a11yConfig: mergeA11yConfig()
|
|
3728
|
+
};
|
|
3729
|
+
}
|
|
3730
|
+
function resolvePatch(t, e) {
|
|
3731
|
+
return {
|
|
3732
|
+
enableHighlight: t.enableHighlight ?? e.enableHighlight,
|
|
3733
|
+
removeMaskAfterToolCall: t.removeMaskAfterToolCall ?? e.removeMaskAfterToolCall,
|
|
3734
|
+
a11yConfig: mergeA11yConfigs(e.a11yConfig, t.a11yConfig ?? {})
|
|
3735
|
+
};
|
|
3736
|
+
}
|
|
3737
|
+
function setPageAgentToolConfig(t, e) {
|
|
3738
|
+
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);
|
|
3739
|
+
return typeof window < "u" && (window.__webmcpcli_toolConfig = r), r;
|
|
3740
|
+
}
|
|
3741
|
+
function isInShadowDom(t) {
|
|
3742
|
+
return t.getRootNode() instanceof ShadowRoot;
|
|
3743
|
+
}
|
|
3744
|
+
function dispatchComposedEvents(t, ...e) {
|
|
3745
|
+
for (const n of e)
|
|
3746
|
+
t.dispatchEvent(new Event(n, { bubbles: !0, composed: !0 }));
|
|
3747
|
+
}
|
|
3748
|
+
function deepQuerySelectorAll(t, e = document) {
|
|
3749
|
+
const n = Array.from(e.querySelectorAll(t)), i = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, null);
|
|
3750
|
+
let r = i.currentNode;
|
|
3751
|
+
for (; r; )
|
|
3752
|
+
r.shadowRoot && n.push(...deepQuerySelectorAll(t, r.shadowRoot)), r = i.nextNode();
|
|
3753
|
+
return n;
|
|
3754
|
+
}
|
|
3755
|
+
function waitForDomSettled(t = 600, e = 150) {
|
|
3756
|
+
return new Promise((n) => {
|
|
3757
|
+
let i = !1, r;
|
|
3758
|
+
const o = () => {
|
|
3759
|
+
i || (i = !0, s.disconnect(), r && clearTimeout(r), n());
|
|
3760
|
+
}, s = new MutationObserver(() => {
|
|
3761
|
+
r && clearTimeout(r), r = setTimeout(o, e);
|
|
3762
|
+
});
|
|
3763
|
+
r = setTimeout(o, e), setTimeout(o, t), s.observe(document.body, {
|
|
3764
|
+
childList: !0,
|
|
3765
|
+
subtree: !0,
|
|
3766
|
+
attributes: !0,
|
|
3767
|
+
attributeFilter: ["class", "style", "hidden"]
|
|
3768
|
+
});
|
|
3769
|
+
});
|
|
3770
|
+
}
|
|
3771
|
+
function detectPageDialog() {
|
|
3772
|
+
const t = /* @__PURE__ */ new Set(), e = [], n = getSelectorsForRole(getPageAgentToolConfig().a11yConfig.roles, "dialog");
|
|
3773
|
+
for (const i of n)
|
|
3774
|
+
try {
|
|
3775
|
+
for (const r of deepQuerySelectorAll(i)) {
|
|
3776
|
+
if (t.has(r) || r.id?.includes("page-agent-runtime") || r.closest("#page-agent-runtime_simulator-mask")) continue;
|
|
3777
|
+
const o = r.getBoundingClientRect();
|
|
3778
|
+
if (o.width < 50 || o.height < 50) continue;
|
|
3779
|
+
const s = window.getComputedStyle(r);
|
|
3780
|
+
if (s.display === "none" || s.visibility === "hidden") continue;
|
|
3781
|
+
const a = s.position === "fixed" || s.position === "absolute", c = parseInt(s.zIndex || "0", 10);
|
|
3782
|
+
if (!a || c < 100) continue;
|
|
3783
|
+
const d = window.innerWidth, u = window.innerHeight;
|
|
3784
|
+
if (!(o.left < d * 0.6 && o.right > d * 0.4 && o.top < u * 0.6 && o.bottom > u * 0.4)) continue;
|
|
3785
|
+
t.add(r);
|
|
3786
|
+
const p = (r.textContent || "").trim().replace(/\s+/g, " ");
|
|
3787
|
+
if (p.length > 5) {
|
|
3788
|
+
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);
|
|
3789
|
+
e.push({ text: p.substring(0, 300), buttons: g });
|
|
3790
|
+
}
|
|
3791
|
+
}
|
|
3792
|
+
} catch {
|
|
3793
|
+
}
|
|
3794
|
+
return e;
|
|
3795
|
+
}
|
|
3796
|
+
function detectValidationErrors() {
|
|
3797
|
+
const t = /* @__PURE__ */ new Set(), e = [], n = extractSelectors(getPageAgentToolConfig().a11yConfig.states.error);
|
|
3798
|
+
for (const i of n)
|
|
3799
|
+
try {
|
|
3800
|
+
for (const r of deepQuerySelectorAll(i)) {
|
|
3801
|
+
if (t.has(r) || Array.from(t).some((c) => c.contains(r))) continue;
|
|
3802
|
+
const o = r.getBoundingClientRect();
|
|
3803
|
+
if (o.width < 1 || o.height < 1) continue;
|
|
3804
|
+
const s = window.getComputedStyle(r);
|
|
3805
|
+
if (s.display === "none" || s.visibility === "hidden") continue;
|
|
3806
|
+
const a = (r.textContent || "").trim().replace(/\s+/g, " ");
|
|
3807
|
+
a.length > 2 && a.length < 200 && (t.add(r), e.push(a));
|
|
3808
|
+
}
|
|
3809
|
+
} catch {
|
|
3645
3810
|
}
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
const
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3811
|
+
return e;
|
|
3812
|
+
}
|
|
3813
|
+
function getVisibleTooltipElements() {
|
|
3814
|
+
const t = /* @__PURE__ */ new Set(), e = [], n = getSelectorsForRole(getPageAgentToolConfig().a11yConfig.roles, "tooltip");
|
|
3815
|
+
for (const i of n)
|
|
3816
|
+
try {
|
|
3817
|
+
for (const r of deepQuerySelectorAll(i)) {
|
|
3818
|
+
if (t.has(r) || Array.from(t).some((c) => c.contains(r))) continue;
|
|
3819
|
+
const o = r.getBoundingClientRect();
|
|
3820
|
+
if (o.width < 1 || o.height < 1) continue;
|
|
3821
|
+
const s = window.getComputedStyle(r);
|
|
3822
|
+
if (s.display === "none" || s.visibility === "hidden" || s.opacity === "0") continue;
|
|
3823
|
+
const a = (r.textContent || "").trim().replace(/\s+/g, " ");
|
|
3824
|
+
if (a.length > 1) {
|
|
3825
|
+
if (r.querySelector?.('[name="cloudx-action-help"]')) continue;
|
|
3826
|
+
t.add(r), e.push({ el: r, text: a });
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
} catch {
|
|
3830
|
+
}
|
|
3831
|
+
return e;
|
|
3832
|
+
}
|
|
3833
|
+
function detectVisibleTooltips() {
|
|
3834
|
+
return getVisibleTooltipElements().map((t) => t.text);
|
|
3835
|
+
}
|
|
3836
|
+
const NON_CONTENT_TAGS = /* @__PURE__ */ new Set([
|
|
3837
|
+
"script",
|
|
3838
|
+
"style",
|
|
3839
|
+
"noscript",
|
|
3840
|
+
"template",
|
|
3841
|
+
"link",
|
|
3842
|
+
"meta",
|
|
3843
|
+
"head",
|
|
3844
|
+
"title"
|
|
3845
|
+
]);
|
|
3846
|
+
function isNonContentElement(t) {
|
|
3847
|
+
return NON_CONTENT_TAGS.has(t.tagName.toLowerCase());
|
|
3848
|
+
}
|
|
3849
|
+
function hasOwnPointerCursor(t) {
|
|
3655
3850
|
try {
|
|
3656
|
-
window.getComputedStyle(t).cursor
|
|
3851
|
+
if (window.getComputedStyle(t).cursor !== "pointer") return !1;
|
|
3852
|
+
const e = t.parentElement;
|
|
3853
|
+
return e ? window.getComputedStyle(e).cursor !== "pointer" : !0;
|
|
3657
3854
|
} catch {
|
|
3855
|
+
return !1;
|
|
3658
3856
|
}
|
|
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 {
|
|
3857
|
+
}
|
|
3858
|
+
const INTERACTION_PSEUDO_RE = /:(hover|focus|focus-visible|focus-within|active)\b/gi;
|
|
3859
|
+
function collectInteractivePointerSelectors(t, e) {
|
|
3860
|
+
for (const n of Array.from(t)) {
|
|
3861
|
+
const i = n, r = n;
|
|
3862
|
+
if (!i.selectorText && r.cssRules) {
|
|
3863
|
+
collectInteractivePointerSelectors(r.cssRules, e);
|
|
3864
|
+
continue;
|
|
3691
3865
|
}
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3866
|
+
const o = i.selectorText;
|
|
3867
|
+
if (!(!o || !i.style || i.style.cursor !== "pointer") && /:(hover|focus|focus-visible|focus-within|active)\b/i.test(o))
|
|
3868
|
+
for (const s of o.split(",")) {
|
|
3869
|
+
const a = s.replace(INTERACTION_PSEUDO_RE, "").trim();
|
|
3870
|
+
a && a !== "*" && e.add(a);
|
|
3871
|
+
}
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
function collectHoverPointerElements(t) {
|
|
3875
|
+
const e = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
|
|
3876
|
+
try {
|
|
3877
|
+
for (const r of Array.from(document.styleSheets)) {
|
|
3878
|
+
let o = null;
|
|
3697
3879
|
try {
|
|
3698
|
-
|
|
3880
|
+
o = r.cssRules;
|
|
3699
3881
|
} catch {
|
|
3882
|
+
continue;
|
|
3700
3883
|
}
|
|
3701
|
-
|
|
3702
|
-
}
|
|
3703
|
-
if (e)
|
|
3704
|
-
for (const v of e) {
|
|
3705
|
-
const y = t.getAttribute(v);
|
|
3706
|
-
y !== null && r.push(`${v}="${y}"`);
|
|
3884
|
+
o && collectInteractivePointerSelectors(o, n);
|
|
3707
3885
|
}
|
|
3708
|
-
|
|
3886
|
+
} catch {
|
|
3887
|
+
return e;
|
|
3888
|
+
}
|
|
3889
|
+
if (n.size === 0) return e;
|
|
3890
|
+
const i = Array.from(n);
|
|
3891
|
+
try {
|
|
3892
|
+
for (const r of deepQuerySelectorAll(i.join(", "), t)) e.add(r);
|
|
3893
|
+
return e;
|
|
3894
|
+
} catch {
|
|
3895
|
+
for (const r of i)
|
|
3896
|
+
try {
|
|
3897
|
+
for (const o of deepQuerySelectorAll(r, t)) e.add(o);
|
|
3898
|
+
} catch {
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
return e;
|
|
3709
3902
|
}
|
|
3710
3903
|
function isHidden$1(t) {
|
|
3711
|
-
if (t.getAttribute("aria-hidden") === "true" || t.hidden) return !0;
|
|
3904
|
+
if (isNonContentElement(t) || t.getAttribute("aria-hidden") === "true" || t.hidden) return !0;
|
|
3712
3905
|
try {
|
|
3713
3906
|
const e = window.getComputedStyle(t);
|
|
3714
3907
|
if (e.display === "none" || e.visibility === "hidden" || e.opacity === "0") return !0;
|
|
@@ -3718,29 +3911,30 @@ function isHidden$1(t) {
|
|
|
3718
3911
|
}
|
|
3719
3912
|
return !1;
|
|
3720
3913
|
}
|
|
3721
|
-
function
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3914
|
+
function collectTitleLabel(t) {
|
|
3915
|
+
const e = t.getAttribute("title")?.trim();
|
|
3916
|
+
if (e) return e;
|
|
3917
|
+
const i = t.querySelector("[title]")?.getAttribute("title")?.trim();
|
|
3918
|
+
return i || "";
|
|
3919
|
+
}
|
|
3920
|
+
function collectDescendantText(t, e) {
|
|
3921
|
+
let n = "";
|
|
3922
|
+
const i = (r) => {
|
|
3923
|
+
if (r.nodeType === Node.TEXT_NODE)
|
|
3924
|
+
n += (r.textContent ?? "") + " ";
|
|
3925
|
+
else if (r.nodeType === Node.ELEMENT_NODE) {
|
|
3926
|
+
const o = r;
|
|
3927
|
+
if (o !== t && isNonContentElement(o) || isHidden$1(o) && o !== t || o === t && isNonContentElement(o)) return;
|
|
3928
|
+
if (o !== t) {
|
|
3929
|
+
const s = o.tagName.toLowerCase(), a = resolveA11yRole(o, e), c = ["button", "a", "input", "select", "textarea", "li", "option"].includes(s), d = ["button", "link", "checkbox", "radio", "textbox", "listitem", "option", "combobox", "listbox"].includes(a), u = isTabbable(o), h = hasOwnPointerCursor(o);
|
|
3930
|
+
if (u && !(a === "generic" && !h) || c || d)
|
|
3737
3931
|
return;
|
|
3738
3932
|
}
|
|
3739
|
-
for (const
|
|
3740
|
-
|
|
3933
|
+
for (const s of Array.from(o.childNodes))
|
|
3934
|
+
i(s);
|
|
3741
3935
|
}
|
|
3742
3936
|
};
|
|
3743
|
-
return
|
|
3937
|
+
return i(t), n.trim().replace(/\s+/g, " ");
|
|
3744
3938
|
}
|
|
3745
3939
|
function getComposedChildren(t) {
|
|
3746
3940
|
const e = t.shadowRoot ? t.shadowRoot.children : t.children, n = [];
|
|
@@ -3752,6 +3946,37 @@ function getComposedChildren(t) {
|
|
|
3752
3946
|
n.push(i);
|
|
3753
3947
|
return n;
|
|
3754
3948
|
}
|
|
3949
|
+
function extractTooltipText(t) {
|
|
3950
|
+
const e = t.getAttribute("title");
|
|
3951
|
+
if (e && e.trim())
|
|
3952
|
+
return e.trim().replace(/"/g, '\\"').substring(0, 200);
|
|
3953
|
+
const n = t.getAttribute("aria-describedby");
|
|
3954
|
+
if (n)
|
|
3955
|
+
for (const o of n.split(/\s+/)) {
|
|
3956
|
+
const s = document.getElementById(o);
|
|
3957
|
+
if (s) {
|
|
3958
|
+
const a = (s.textContent || "").trim().replace(/\s+/g, " ");
|
|
3959
|
+
if (a)
|
|
3960
|
+
return a.replace(/"/g, '\\"').substring(0, 200);
|
|
3961
|
+
}
|
|
3962
|
+
}
|
|
3963
|
+
for (const o of ["data-tooltip", "data-tips", "data-tip"]) {
|
|
3964
|
+
const s = t.getAttribute(o);
|
|
3965
|
+
if (s && s.trim())
|
|
3966
|
+
return s.trim().replace(/"/g, '\\"').substring(0, 200);
|
|
3967
|
+
}
|
|
3968
|
+
const i = t.tagName.toLowerCase();
|
|
3969
|
+
if (i === "tp-helptip" || t.closest("tp-helptip")) {
|
|
3970
|
+
const s = (i === "tp-helptip" ? t : t.closest("tp-helptip")).querySelector('.tp-helptip-label, [class*="tp-helptip-label"]');
|
|
3971
|
+
if (s) {
|
|
3972
|
+
const a = (s.textContent || "").trim();
|
|
3973
|
+
if (a)
|
|
3974
|
+
return a.replace(/"/g, '\\"').substring(0, 200);
|
|
3975
|
+
}
|
|
3976
|
+
}
|
|
3977
|
+
const r = t.getAttribute("mattooltip") || t.getAttribute("matTooltip");
|
|
3978
|
+
return r && r.trim() ? r.trim().replace(/"/g, '\\"').substring(0, 200) : "";
|
|
3979
|
+
}
|
|
3755
3980
|
var toStr = Object.prototype.toString;
|
|
3756
3981
|
function isCallable(t) {
|
|
3757
3982
|
return typeof t == "function" || toStr.call(t) === "[object Function]";
|
|
@@ -3769,8 +3994,8 @@ function arrayFrom(t, e) {
|
|
|
3769
3994
|
var n = Array, i = Object(t);
|
|
3770
3995
|
if (t == null)
|
|
3771
3996
|
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),
|
|
3773
|
-
|
|
3997
|
+
for (var r = toLength(i.length), o = isCallable(n) ? Object(new n(r)) : new Array(r), s = 0, a; s < r; )
|
|
3998
|
+
a = i[s], o[s] = a, s += 1;
|
|
3774
3999
|
return o.length = r, o;
|
|
3775
4000
|
}
|
|
3776
4001
|
function _typeof$1(t) {
|
|
@@ -4175,105 +4400,105 @@ function getSlotContents(t) {
|
|
|
4175
4400
|
return e.length === 0 ? arrayFrom(t.childNodes) : e;
|
|
4176
4401
|
}
|
|
4177
4402
|
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,
|
|
4179
|
-
function f
|
|
4403
|
+
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, s = e.computedStyleSupportsPseudoElements, a = s === void 0 ? e.getComputedStyle !== void 0 : s, c = e.getComputedStyle, d = c === void 0 ? i.getComputedStyle.bind(i) : c, u = e.hidden, h = u === void 0 ? !1 : u;
|
|
4404
|
+
function p(f, b) {
|
|
4180
4405
|
var T = "";
|
|
4181
|
-
if (isElement(
|
|
4182
|
-
var
|
|
4183
|
-
T = "".concat(
|
|
4406
|
+
if (isElement(f) && a) {
|
|
4407
|
+
var y = d(f, "::before"), C = getTextualContent(y);
|
|
4408
|
+
T = "".concat(C, " ").concat(T);
|
|
4184
4409
|
}
|
|
4185
|
-
var
|
|
4186
|
-
if (
|
|
4187
|
-
var
|
|
4188
|
-
isEmbeddedInLabel:
|
|
4410
|
+
var S = isHTMLSlotElement(f) ? getSlotContents(f) : arrayFrom(f.childNodes).concat(queryIdRefs(f, "aria-owns"));
|
|
4411
|
+
if (S.forEach(function(P) {
|
|
4412
|
+
var R = L(P, {
|
|
4413
|
+
isEmbeddedInLabel: b.isEmbeddedInLabel,
|
|
4189
4414
|
isReferenced: !1,
|
|
4190
4415
|
recursion: !0
|
|
4191
|
-
}),
|
|
4192
|
-
T += "".concat(B).concat(
|
|
4193
|
-
}), isElement(
|
|
4194
|
-
var
|
|
4195
|
-
T = "".concat(T, " ").concat(
|
|
4416
|
+
}), F = isElement(P) ? d(P).getPropertyValue("display") : "inline", B = F !== "inline" ? " " : "";
|
|
4417
|
+
T += "".concat(B).concat(R).concat(B);
|
|
4418
|
+
}), isElement(f) && a) {
|
|
4419
|
+
var A = d(f, "::after"), D = getTextualContent(A);
|
|
4420
|
+
T = "".concat(T, " ").concat(D);
|
|
4196
4421
|
}
|
|
4197
4422
|
return T.trim();
|
|
4198
4423
|
}
|
|
4199
|
-
function m(
|
|
4200
|
-
var T =
|
|
4424
|
+
function m(f, b) {
|
|
4425
|
+
var T = f.getAttributeNode(b);
|
|
4201
4426
|
return T !== null && !n.has(T) && T.value.trim() !== "" ? (n.add(T), T.value) : null;
|
|
4202
4427
|
}
|
|
4203
|
-
function g(
|
|
4204
|
-
return isElement(
|
|
4428
|
+
function g(f) {
|
|
4429
|
+
return isElement(f) ? m(f, "title") : null;
|
|
4205
4430
|
}
|
|
4206
|
-
function
|
|
4207
|
-
if (!isElement(
|
|
4431
|
+
function E(f) {
|
|
4432
|
+
if (!isElement(f))
|
|
4208
4433
|
return null;
|
|
4209
|
-
if (isHTMLFieldSetElement(
|
|
4210
|
-
n.add(
|
|
4211
|
-
for (var
|
|
4212
|
-
var
|
|
4213
|
-
if (isHTMLLegendElement(
|
|
4214
|
-
return
|
|
4434
|
+
if (isHTMLFieldSetElement(f)) {
|
|
4435
|
+
n.add(f);
|
|
4436
|
+
for (var b = arrayFrom(f.childNodes), T = 0; T < b.length; T += 1) {
|
|
4437
|
+
var y = b[T];
|
|
4438
|
+
if (isHTMLLegendElement(y))
|
|
4439
|
+
return L(y, {
|
|
4215
4440
|
isEmbeddedInLabel: !1,
|
|
4216
4441
|
isReferenced: !1,
|
|
4217
4442
|
recursion: !1
|
|
4218
4443
|
});
|
|
4219
4444
|
}
|
|
4220
|
-
} else if (isHTMLTableElement(
|
|
4221
|
-
n.add(
|
|
4222
|
-
for (var
|
|
4223
|
-
var
|
|
4224
|
-
if (isHTMLTableCaptionElement(
|
|
4225
|
-
return
|
|
4445
|
+
} else if (isHTMLTableElement(f)) {
|
|
4446
|
+
n.add(f);
|
|
4447
|
+
for (var C = arrayFrom(f.childNodes), S = 0; S < C.length; S += 1) {
|
|
4448
|
+
var A = C[S];
|
|
4449
|
+
if (isHTMLTableCaptionElement(A))
|
|
4450
|
+
return L(A, {
|
|
4226
4451
|
isEmbeddedInLabel: !1,
|
|
4227
4452
|
isReferenced: !1,
|
|
4228
4453
|
recursion: !1
|
|
4229
4454
|
});
|
|
4230
4455
|
}
|
|
4231
|
-
} else if (isSVGSVGElement(
|
|
4232
|
-
n.add(
|
|
4233
|
-
for (var
|
|
4234
|
-
var
|
|
4235
|
-
if (isSVGTitleElement(
|
|
4236
|
-
return
|
|
4456
|
+
} else if (isSVGSVGElement(f)) {
|
|
4457
|
+
n.add(f);
|
|
4458
|
+
for (var D = arrayFrom(f.childNodes), P = 0; P < D.length; P += 1) {
|
|
4459
|
+
var R = D[P];
|
|
4460
|
+
if (isSVGTitleElement(R))
|
|
4461
|
+
return R.textContent;
|
|
4237
4462
|
}
|
|
4238
4463
|
return null;
|
|
4239
|
-
} else if (getLocalName(
|
|
4240
|
-
var
|
|
4241
|
-
if (
|
|
4242
|
-
return
|
|
4243
|
-
} else if (isHTMLOptGroupElement(
|
|
4244
|
-
var B = m(
|
|
4464
|
+
} else if (getLocalName(f) === "img" || getLocalName(f) === "area") {
|
|
4465
|
+
var F = m(f, "alt");
|
|
4466
|
+
if (F !== null)
|
|
4467
|
+
return F;
|
|
4468
|
+
} else if (isHTMLOptGroupElement(f)) {
|
|
4469
|
+
var B = m(f, "label");
|
|
4245
4470
|
if (B !== null)
|
|
4246
4471
|
return B;
|
|
4247
4472
|
}
|
|
4248
|
-
if (isHTMLInputElement(
|
|
4249
|
-
var
|
|
4250
|
-
if (
|
|
4251
|
-
return
|
|
4252
|
-
if (
|
|
4473
|
+
if (isHTMLInputElement(f) && (f.type === "button" || f.type === "submit" || f.type === "reset")) {
|
|
4474
|
+
var J = m(f, "value");
|
|
4475
|
+
if (J !== null)
|
|
4476
|
+
return J;
|
|
4477
|
+
if (f.type === "submit")
|
|
4253
4478
|
return "Submit";
|
|
4254
|
-
if (
|
|
4479
|
+
if (f.type === "reset")
|
|
4255
4480
|
return "Reset";
|
|
4256
4481
|
}
|
|
4257
|
-
var
|
|
4258
|
-
if (
|
|
4259
|
-
return n.add(
|
|
4260
|
-
return
|
|
4482
|
+
var G = getLabels(f);
|
|
4483
|
+
if (G !== null && G.length !== 0)
|
|
4484
|
+
return n.add(f), arrayFrom(G).map(function(W) {
|
|
4485
|
+
return L(W, {
|
|
4261
4486
|
isEmbeddedInLabel: !0,
|
|
4262
4487
|
isReferenced: !1,
|
|
4263
4488
|
recursion: !0
|
|
4264
4489
|
});
|
|
4265
|
-
}).filter(function(
|
|
4266
|
-
return
|
|
4490
|
+
}).filter(function(W) {
|
|
4491
|
+
return W.length > 0;
|
|
4267
4492
|
}).join(" ");
|
|
4268
|
-
if (isHTMLInputElement(
|
|
4269
|
-
var
|
|
4270
|
-
if (
|
|
4271
|
-
return
|
|
4272
|
-
var ee = m(
|
|
4493
|
+
if (isHTMLInputElement(f) && f.type === "image") {
|
|
4494
|
+
var Q = m(f, "alt");
|
|
4495
|
+
if (Q !== null)
|
|
4496
|
+
return Q;
|
|
4497
|
+
var ee = m(f, "title");
|
|
4273
4498
|
return ee !== null ? ee : "Submit Query";
|
|
4274
4499
|
}
|
|
4275
|
-
if (hasAnyConcreteRoles(
|
|
4276
|
-
var te = f
|
|
4500
|
+
if (hasAnyConcreteRoles(f, ["button"])) {
|
|
4501
|
+
var te = p(f, {
|
|
4277
4502
|
isEmbeddedInLabel: !1
|
|
4278
4503
|
});
|
|
4279
4504
|
if (te !== "")
|
|
@@ -4281,16 +4506,16 @@ function computeTextAlternative(t) {
|
|
|
4281
4506
|
}
|
|
4282
4507
|
return null;
|
|
4283
4508
|
}
|
|
4284
|
-
function
|
|
4285
|
-
if (n.has(
|
|
4509
|
+
function L(f, b) {
|
|
4510
|
+
if (n.has(f))
|
|
4286
4511
|
return "";
|
|
4287
|
-
if (!
|
|
4288
|
-
return n.add(
|
|
4289
|
-
var T = isElement(
|
|
4290
|
-
if (o === "name" && !
|
|
4291
|
-
return n.add(T),
|
|
4292
|
-
return
|
|
4293
|
-
isEmbeddedInLabel:
|
|
4512
|
+
if (!h && isHidden(f, d) && !b.isReferenced)
|
|
4513
|
+
return n.add(f), "";
|
|
4514
|
+
var T = isElement(f) ? f.getAttributeNode("aria-labelledby") : null, y = T !== null && !n.has(T) ? queryIdRefs(f, "aria-labelledby") : [];
|
|
4515
|
+
if (o === "name" && !b.isReferenced && y.length > 0)
|
|
4516
|
+
return n.add(T), y.map(function(F) {
|
|
4517
|
+
return L(F, {
|
|
4518
|
+
isEmbeddedInLabel: b.isEmbeddedInLabel,
|
|
4294
4519
|
isReferenced: !0,
|
|
4295
4520
|
// this isn't recursion as specified, otherwise we would skip
|
|
4296
4521
|
// `aria-label` in
|
|
@@ -4298,53 +4523,53 @@ function computeTextAlternative(t) {
|
|
|
4298
4523
|
recursion: !1
|
|
4299
4524
|
});
|
|
4300
4525
|
}).join(" ");
|
|
4301
|
-
var
|
|
4302
|
-
if (!
|
|
4303
|
-
var
|
|
4304
|
-
if (
|
|
4305
|
-
return n.add(
|
|
4306
|
-
if (!isMarkedPresentational(
|
|
4307
|
-
var
|
|
4308
|
-
if (
|
|
4309
|
-
return n.add(
|
|
4526
|
+
var C = b.recursion && isControl(f) && o === "name";
|
|
4527
|
+
if (!C) {
|
|
4528
|
+
var S = (isElement(f) && f.getAttribute("aria-label") || "").trim();
|
|
4529
|
+
if (S !== "" && o === "name")
|
|
4530
|
+
return n.add(f), S;
|
|
4531
|
+
if (!isMarkedPresentational(f)) {
|
|
4532
|
+
var A = E(f);
|
|
4533
|
+
if (A !== null)
|
|
4534
|
+
return n.add(f), A;
|
|
4310
4535
|
}
|
|
4311
4536
|
}
|
|
4312
|
-
if (hasAnyConcreteRoles(
|
|
4313
|
-
return n.add(
|
|
4314
|
-
if (
|
|
4315
|
-
if (hasAnyConcreteRoles(
|
|
4316
|
-
n.add(
|
|
4317
|
-
var
|
|
4318
|
-
return
|
|
4319
|
-
return
|
|
4320
|
-
isEmbeddedInLabel:
|
|
4537
|
+
if (hasAnyConcreteRoles(f, ["menu"]))
|
|
4538
|
+
return n.add(f), "";
|
|
4539
|
+
if (C || b.isEmbeddedInLabel || b.isReferenced) {
|
|
4540
|
+
if (hasAnyConcreteRoles(f, ["combobox", "listbox"])) {
|
|
4541
|
+
n.add(f);
|
|
4542
|
+
var D = querySelectedOptions(f);
|
|
4543
|
+
return D.length === 0 ? isHTMLInputElement(f) ? f.value : "" : arrayFrom(D).map(function(F) {
|
|
4544
|
+
return L(F, {
|
|
4545
|
+
isEmbeddedInLabel: b.isEmbeddedInLabel,
|
|
4321
4546
|
isReferenced: !1,
|
|
4322
4547
|
recursion: !0
|
|
4323
4548
|
});
|
|
4324
4549
|
}).join(" ");
|
|
4325
4550
|
}
|
|
4326
|
-
if (hasAbstractRole(
|
|
4327
|
-
return n.add(
|
|
4328
|
-
if (hasAnyConcreteRoles(
|
|
4329
|
-
return n.add(
|
|
4551
|
+
if (hasAbstractRole(f, "range"))
|
|
4552
|
+
return n.add(f), f.hasAttribute("aria-valuetext") ? f.getAttribute("aria-valuetext") : f.hasAttribute("aria-valuenow") ? f.getAttribute("aria-valuenow") : f.getAttribute("value") || "";
|
|
4553
|
+
if (hasAnyConcreteRoles(f, ["textbox"]))
|
|
4554
|
+
return n.add(f), getValueOfTextbox(f);
|
|
4330
4555
|
}
|
|
4331
|
-
if (allowsNameFromContent(
|
|
4332
|
-
var
|
|
4333
|
-
isEmbeddedInLabel:
|
|
4556
|
+
if (allowsNameFromContent(f) || isElement(f) && b.isReferenced || isNativeHostLanguageTextAlternativeElement(f) || isDescendantOfNativeHostLanguageTextAlternativeElement()) {
|
|
4557
|
+
var P = p(f, {
|
|
4558
|
+
isEmbeddedInLabel: b.isEmbeddedInLabel
|
|
4334
4559
|
});
|
|
4335
|
-
if (
|
|
4336
|
-
return n.add(
|
|
4560
|
+
if (P !== "")
|
|
4561
|
+
return n.add(f), P;
|
|
4337
4562
|
}
|
|
4338
|
-
if (
|
|
4339
|
-
return n.add(
|
|
4340
|
-
if (
|
|
4341
|
-
return n.add(
|
|
4342
|
-
isEmbeddedInLabel:
|
|
4563
|
+
if (f.nodeType === f.TEXT_NODE)
|
|
4564
|
+
return n.add(f), f.textContent || "";
|
|
4565
|
+
if (b.recursion)
|
|
4566
|
+
return n.add(f), p(f, {
|
|
4567
|
+
isEmbeddedInLabel: b.isEmbeddedInLabel
|
|
4343
4568
|
});
|
|
4344
|
-
var
|
|
4345
|
-
return
|
|
4569
|
+
var R = g(f);
|
|
4570
|
+
return R !== null ? (n.add(f), R) : (n.add(f), "");
|
|
4346
4571
|
}
|
|
4347
|
-
return asFlatString(
|
|
4572
|
+
return asFlatString(L(t, {
|
|
4348
4573
|
isEmbeddedInLabel: !1,
|
|
4349
4574
|
// by spec computeAccessibleDescription starts with the referenced elements as roots
|
|
4350
4575
|
isReferenced: o === "description",
|
|
@@ -4358,42 +4583,105 @@ function computeAccessibleName(t) {
|
|
|
4358
4583
|
var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
4359
4584
|
return prohibitsNaming(t) ? "" : computeTextAlternative(t, e);
|
|
4360
4585
|
}
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4586
|
+
const INTERACTIVE_ROLES = /* @__PURE__ */ new Set([
|
|
4587
|
+
"button",
|
|
4588
|
+
"link",
|
|
4589
|
+
"textbox",
|
|
4590
|
+
"searchbox",
|
|
4591
|
+
"combobox",
|
|
4592
|
+
"listbox",
|
|
4593
|
+
"checkbox",
|
|
4594
|
+
"radio",
|
|
4595
|
+
"switch",
|
|
4596
|
+
"slider",
|
|
4597
|
+
"spinbutton",
|
|
4598
|
+
"menuitem",
|
|
4599
|
+
"menuitemcheckbox",
|
|
4600
|
+
"menuitemradio",
|
|
4601
|
+
"tab",
|
|
4602
|
+
"treeitem"
|
|
4603
|
+
]);
|
|
4604
|
+
function buildVNode(t, e, n, i, r, o, s = /* @__PURE__ */ new Set()) {
|
|
4605
|
+
if (isNonContentElement(t) || isHidden$1(t) || i.has(t)) return null;
|
|
4606
|
+
const { role: a, tokens: c } = resolveA11yInfo(t, o), d = extractTooltipText(t);
|
|
4607
|
+
d && c.push(`tooltip="${d}"`);
|
|
4608
|
+
const u = c.some((P) => P.startsWith("tooltip="));
|
|
4609
|
+
let h = computeAccessibleName(t);
|
|
4610
|
+
const p = isTabbable(t), m = c.includes("cursor=pointer"), g = hasOwnPointerCursor(t) || s.has(t), E = r.has(t), L = t.tagName.toLowerCase() === "label" && t.hasAttribute("for");
|
|
4611
|
+
if (!h.trim()) {
|
|
4612
|
+
const P = t.tagName.toLowerCase();
|
|
4613
|
+
if (!(P === "select" || a === "combobox" || a === "listbox")) {
|
|
4614
|
+
const F = ["button", "a", "input", "textarea", "li", "label"].includes(P);
|
|
4615
|
+
(p || E || m || g || F || a === "listitem" || a === "option" || a === "button") && (h = collectDescendantText(t, o));
|
|
4371
4616
|
}
|
|
4372
4617
|
}
|
|
4373
|
-
if (!
|
|
4374
|
-
const
|
|
4375
|
-
|
|
4376
|
-
}
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4618
|
+
if (!h.trim() && (p || E || m || g || a === "button") && (h = collectTitleLabel(t)), !h.trim() && a === "button") {
|
|
4619
|
+
const P = t.getAttribute("name") || "";
|
|
4620
|
+
(P.includes("help") || P.includes("tip") || P.includes("info")) && (h = "帮助");
|
|
4621
|
+
}
|
|
4622
|
+
if (!h.trim() && u) {
|
|
4623
|
+
const P = c.find((R) => R.startsWith("tooltip="));
|
|
4624
|
+
P && (h = P.replace(/^tooltip="/, "").replace(/"$/, ""));
|
|
4625
|
+
}
|
|
4626
|
+
if (!h.trim() && ["tab", "menuitem", "option", "treeitem", "button"].includes(a) && (h = collectVisiblePlainText(t)), !h.trim() && !(getComposedChildren(t).length > 0)) {
|
|
4627
|
+
const R = collectDescendantText(t, o);
|
|
4628
|
+
R && (h = R);
|
|
4629
|
+
}
|
|
4630
|
+
const f = t.tagName.toLowerCase(), b = f === "a" && t.hasAttribute("href") || ["button", "input", "select", "textarea"].includes(f) && !t.hasAttribute("disabled") || a === "button" && m && !["button", "a", "input", "select", "textarea"].includes(f), T = p && !(a === "generic" && !g), y = c.includes("disabled"), C = !y && T || E || L || b || !y && INTERACTIVE_ROLES.has(a) || // hasClickableCursor 已排除 CSS 继承(hasOwnPointerCursor)并覆盖 hover 态手势,
|
|
4631
|
+
// 无需再要求 role≠generic 或 name≠''——否则无文本的图标按钮(tp-icon.common-icon 等)
|
|
4632
|
+
// 虽是真正的可点击边界,仍会因 generic+空名被漏判。
|
|
4633
|
+
!y && g || // 有 tooltip 的元素分配 ref,使 AI 能 hover 触发动态 tip
|
|
4634
|
+
u;
|
|
4635
|
+
let S;
|
|
4636
|
+
C && (S = e.value, n.set(S, t), e.value++);
|
|
4380
4637
|
const A = [];
|
|
4381
|
-
for (const
|
|
4382
|
-
const
|
|
4383
|
-
|
|
4638
|
+
for (const P of getComposedChildren(t)) {
|
|
4639
|
+
const R = buildVNode(
|
|
4640
|
+
P,
|
|
4384
4641
|
e,
|
|
4385
4642
|
n,
|
|
4386
4643
|
i,
|
|
4387
4644
|
r,
|
|
4388
4645
|
o,
|
|
4389
|
-
|
|
4390
|
-
l,
|
|
4391
|
-
// 将当前节点的交互性向下传递,子节点据此决定是否抑制 cursor=pointer
|
|
4392
|
-
T || c
|
|
4646
|
+
s
|
|
4393
4647
|
);
|
|
4394
|
-
|
|
4648
|
+
R && A.push(R);
|
|
4649
|
+
}
|
|
4650
|
+
const D = { role: a, name: h, tokens: c, ref: S, el: t, children: A };
|
|
4651
|
+
return hasInteractiveDescendant(D) && (D.name = getOwnDeclaredName(t)), D;
|
|
4652
|
+
}
|
|
4653
|
+
function getOwnDeclaredName(t) {
|
|
4654
|
+
return t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby") ? computeAccessibleName(t).trim() : "";
|
|
4655
|
+
}
|
|
4656
|
+
function isStaticBranch(t) {
|
|
4657
|
+
return t.ref === void 0 && !hasInteractiveDescendant(t);
|
|
4658
|
+
}
|
|
4659
|
+
function collectVisiblePlainText(t) {
|
|
4660
|
+
return collectDescendantText(t).replace(/\s+/g, " ").trim();
|
|
4661
|
+
}
|
|
4662
|
+
function collectDirectTextNodes(t) {
|
|
4663
|
+
let e = "";
|
|
4664
|
+
for (const n of Array.from(t.childNodes))
|
|
4665
|
+
n.nodeType === Node.TEXT_NODE && (e += (n.textContent ?? "") + " ");
|
|
4666
|
+
return e.replace(/\s+/g, " ").trim();
|
|
4667
|
+
}
|
|
4668
|
+
function getStaticDisplayText(t) {
|
|
4669
|
+
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 = [];
|
|
4670
|
+
if (i && !isNoiseAccessibleName(i) && r.push(i), e && !isNoiseAccessibleName(e)) {
|
|
4671
|
+
const o = i.replace(/\s+/g, " ").trim(), s = e.replace(/\s+/g, " ").trim();
|
|
4672
|
+
(!o || s !== o && !o.includes(s)) && r.push(e);
|
|
4395
4673
|
}
|
|
4396
|
-
return
|
|
4674
|
+
return r.length === 0 && n && !isNoiseAccessibleName(n) && r.push(n), r.join(" ").replace(/\s+/g, " ").trim();
|
|
4675
|
+
}
|
|
4676
|
+
function isNoiseAccessibleName(t) {
|
|
4677
|
+
const e = t.trim();
|
|
4678
|
+
return e ? !!(/@font-face\b/i.test(e) || /data:(?:font|application|image)\//i.test(e) || /base64,[A-Za-z0-9+/=]{80,}/.test(e)) : !1;
|
|
4679
|
+
}
|
|
4680
|
+
function canOmitStaticChild(t, e, n) {
|
|
4681
|
+
const i = getStaticDisplayText(t);
|
|
4682
|
+
if (!i || !e.trim()) return !1;
|
|
4683
|
+
const r = e.replace(/\s+/g, " ").trim(), o = i.replace(/\s+/g, " ").trim();
|
|
4684
|
+
return n ? o === r : r.includes(o);
|
|
4397
4685
|
}
|
|
4398
4686
|
function hasValue(t) {
|
|
4399
4687
|
return t.ref !== void 0 || t.name.trim() !== "" ? !0 : t.children.some(hasValue);
|
|
@@ -4410,23 +4698,35 @@ function findSingleRefDescendant(t) {
|
|
|
4410
4698
|
function shouldPassThrough(t, e) {
|
|
4411
4699
|
return !(!e.pruneUnnamed || e.preserveRoles.includes(t.role) || t.ref !== void 0 || t.name.trim() !== "");
|
|
4412
4700
|
}
|
|
4701
|
+
function formatNameAttr(t) {
|
|
4702
|
+
const e = t.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"').trim();
|
|
4703
|
+
return e ? ` "${e}"` : "";
|
|
4704
|
+
}
|
|
4413
4705
|
function serializeVNode(t, e, n) {
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4706
|
+
const i = hasInteractiveDescendant(t), r = n.preserveRoles.includes(t.role), o = " ".repeat(e), s = t.ref !== void 0 ? ` #${t.ref}` : "", a = t.tokens.map((y) => y.replace(/[\r\n]+/g, " ").replace(/"/g, '\\"')), c = a.length > 0 ? ` [${a.join(" ")}]` : "";
|
|
4707
|
+
if (!i && !r) {
|
|
4708
|
+
if (shouldPassThrough(t, n))
|
|
4709
|
+
return t.children.filter((C) => hasValue(C)).flatMap((C) => serializeVNode(C, e, n));
|
|
4710
|
+
let y = t.name.trim();
|
|
4711
|
+
return !y && t.children.length > 0 && (y = collectVisiblePlainText(t.el)), isNoiseAccessibleName(y) && (y = ""), [`${o}- ${t.role}${s}${c}${formatNameAttr(y)}`];
|
|
4712
|
+
}
|
|
4713
|
+
if (!i && r) {
|
|
4714
|
+
const y = getOwnDeclaredName(t.el), C = `${o}- ${t.role}${s}${c}${formatNameAttr(y)}`, S = t.children.flatMap((A) => serializeVNode(A, e + 1, n));
|
|
4715
|
+
return [C, ...S];
|
|
4716
|
+
}
|
|
4717
|
+
const d = getOwnDeclaredName(t.el), u = d !== "", h = t.children.filter(isStaticBranch), p = h.map(getStaticDisplayText).filter(Boolean).join(" ").replace(/\s+/g, " ").trim(), m = collectDirectTextNodes(t.el), g = [p, m].filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
4718
|
+
let E = u ? d : g;
|
|
4719
|
+
if (isNoiseAccessibleName(E) && (E = ""), !u && isNoiseAccessibleName(t.name) && (E = g && !isNoiseAccessibleName(g) ? g : ""), !(t.ref !== void 0 || E !== "" || r || !n.pruneUnnamed))
|
|
4720
|
+
return t.children.filter((y) => hasValue(y)).flatMap((y) => serializeVNode(y, e, n));
|
|
4417
4721
|
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}`];
|
|
4722
|
+
const y = findSingleRefDescendant(t);
|
|
4723
|
+
if (y && y.role === "generic" && !hasInteractiveDescendant(y) && h.length === 0) {
|
|
4724
|
+
const C = E.trim() || y.name.trim(), S = y.ref !== void 0 ? ` #${y.ref}` : s;
|
|
4725
|
+
return [`${o}- ${t.role}${S}${c}${formatNameAttr(C)}`];
|
|
4426
4726
|
}
|
|
4427
4727
|
}
|
|
4428
|
-
const
|
|
4429
|
-
return [
|
|
4728
|
+
const f = t.children.filter((y) => isStaticBranch(y) ? !canOmitStaticChild(y, E, u) : !0), b = `${o}- ${t.role}${s}${c}${formatNameAttr(E)}`, T = f.flatMap((y) => serializeVNode(y, e + 1, n));
|
|
4729
|
+
return [b, ...T];
|
|
4430
4730
|
}
|
|
4431
4731
|
const HIGHLIGHT_CONTAINER_ID = "webmcpcli-highlight-container", HIGHLIGHT_CONTAINER_STYLE_ID = "webmcpcli-highlight-container-style", colors = [
|
|
4432
4732
|
"#FF0000",
|
|
@@ -4468,10 +4768,34 @@ const HIGHLIGHT_CONTAINER_ID = "webmcpcli-highlight-container", HIGHLIGHT_CONTAI
|
|
|
4468
4768
|
padding: 0 2px;
|
|
4469
4769
|
border-radius: 4px;
|
|
4470
4770
|
}
|
|
4471
|
-
|
|
4472
|
-
function
|
|
4771
|
+
`, MAX_ICON_FALLBACK_SIZE = 48;
|
|
4772
|
+
function resolveHighlightRect(t) {
|
|
4473
4773
|
const e = t.getBoundingClientRect();
|
|
4474
|
-
|
|
4774
|
+
if (e.width > 0 && e.height > 0)
|
|
4775
|
+
return { top: e.top, left: e.left, width: e.width, height: e.height };
|
|
4776
|
+
let n = t.parentElement;
|
|
4777
|
+
for (let i = 0; i < 3 && n; i++) {
|
|
4778
|
+
const r = n.getBoundingClientRect();
|
|
4779
|
+
if (r.width > 0 && r.height > 0 && r.width <= MAX_ICON_FALLBACK_SIZE && r.height <= MAX_ICON_FALLBACK_SIZE)
|
|
4780
|
+
return { top: r.top, left: r.left, width: r.width, height: r.height };
|
|
4781
|
+
n = n.parentElement;
|
|
4782
|
+
}
|
|
4783
|
+
if (e.width > 0 || e.height > 0)
|
|
4784
|
+
try {
|
|
4785
|
+
const i = parseFloat(getComputedStyle(t).fontSize) || 16, r = e.width > 0 ? e.width : i, o = e.height > 0 ? e.height : i;
|
|
4786
|
+
return {
|
|
4787
|
+
top: e.height > 0 ? e.top : e.top - (o - e.height) / 2,
|
|
4788
|
+
left: e.width > 0 ? e.left : e.left - (r - e.width) / 2,
|
|
4789
|
+
width: r,
|
|
4790
|
+
height: o
|
|
4791
|
+
};
|
|
4792
|
+
} catch {
|
|
4793
|
+
}
|
|
4794
|
+
return null;
|
|
4795
|
+
}
|
|
4796
|
+
function isRectInViewport(t) {
|
|
4797
|
+
const e = window.innerHeight || document.documentElement.clientHeight, n = window.innerWidth || document.documentElement.clientWidth;
|
|
4798
|
+
return t.top < e && t.top + t.height > 0 && t.left < n && t.left + t.width > 0;
|
|
4475
4799
|
}
|
|
4476
4800
|
const doHighlight = (t, e = null) => {
|
|
4477
4801
|
if (!document.head.querySelector(`#${HIGHLIGHT_CONTAINER_STYLE_ID}`)) {
|
|
@@ -4486,33 +4810,32 @@ const doHighlight = (t, e = null) => {
|
|
|
4486
4810
|
i.x = o.left, i.y = o.top;
|
|
4487
4811
|
}
|
|
4488
4812
|
const r = document.createDocumentFragment();
|
|
4489
|
-
for (const [o,
|
|
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);
|
|
4813
|
+
for (const [o, s] of t.entries()) {
|
|
4814
|
+
const a = resolveHighlightRect(s);
|
|
4815
|
+
if (!a) continue;
|
|
4816
|
+
const c = a.top + i.y, d = a.left + i.x, u = { top: c, left: d, width: a.width, height: a.height };
|
|
4817
|
+
if (!isRectInViewport(u)) continue;
|
|
4818
|
+
const p = colors[o % colors.length] + opacity, m = document.createElement("div");
|
|
4819
|
+
m.style.border = `2px solid ${p}`, m.dataset.refIndex = String(o), m.style.top = `${c}px`, m.style.left = `${d}px`, m.style.width = `${a.width}px`, m.style.height = `${a.height}px`;
|
|
4820
|
+
const g = document.createElement("span");
|
|
4821
|
+
g.style.backgroundColor = p, g.style.height = `${Math.max(a.height - 4, 0)}px`, g.style.lineHeight = `${Math.max(a.height - 4, 0)}px`, g.textContent = o.toString(), m.appendChild(g), r.appendChild(m);
|
|
4499
4822
|
}
|
|
4500
4823
|
n.appendChild(r);
|
|
4501
4824
|
}, highlight = (t, e = null) => {
|
|
4502
4825
|
doHighlight(t, e);
|
|
4503
|
-
const r = ((
|
|
4504
|
-
let
|
|
4505
|
-
return (...
|
|
4506
|
-
const
|
|
4507
|
-
if (!(
|
|
4508
|
-
return
|
|
4826
|
+
const r = ((a, c) => {
|
|
4827
|
+
let d = 0;
|
|
4828
|
+
return (...u) => {
|
|
4829
|
+
const h = performance.now();
|
|
4830
|
+
if (!(h - d < c))
|
|
4831
|
+
return d = h, a(...u);
|
|
4509
4832
|
};
|
|
4510
4833
|
})(() => doHighlight(t, e), 16);
|
|
4511
4834
|
window.addEventListener("scroll", r, !0), window.addEventListener("resize", r);
|
|
4512
4835
|
const o = () => {
|
|
4513
4836
|
window.removeEventListener("scroll", r, !0), window.removeEventListener("resize", r);
|
|
4514
|
-
},
|
|
4515
|
-
(
|
|
4837
|
+
}, s = window;
|
|
4838
|
+
(s._highlightCleanupFunctions = s._highlightCleanupFunctions || []).push(o);
|
|
4516
4839
|
}, unhighlight = () => {
|
|
4517
4840
|
document.getElementById(HIGHLIGHT_CONTAINER_ID)?.remove();
|
|
4518
4841
|
const t = window._highlightCleanupFunctions || [];
|
|
@@ -4539,87 +4862,84 @@ const doHighlight = (t, e = null) => {
|
|
|
4539
4862
|
window.location.href !== e && (e = window.location.href, unhighlight());
|
|
4540
4863
|
}, 500);
|
|
4541
4864
|
}
|
|
4542
|
-
}, DEFAULT_OPTIONS = {
|
|
4543
|
-
pruneUnnamed: !0,
|
|
4544
|
-
preserveRoles: [],
|
|
4545
|
-
exposedAttributes: [],
|
|
4546
|
-
errorSelectors: DEFAULT_ERROR_SELECTORS$1,
|
|
4547
|
-
warningSelectors: DEFAULT_WARNING_SELECTORS
|
|
4548
4865
|
};
|
|
4549
|
-
function
|
|
4550
|
-
const
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4866
|
+
function resolveElementList(t, e) {
|
|
4867
|
+
const n = /* @__PURE__ */ new Set();
|
|
4868
|
+
for (const i of t)
|
|
4869
|
+
if (typeof i == "string")
|
|
4870
|
+
try {
|
|
4871
|
+
for (const r of deepQuerySelectorAll(i, e)) n.add(r);
|
|
4872
|
+
} catch {
|
|
4873
|
+
}
|
|
4874
|
+
else i && n.add(i);
|
|
4875
|
+
return n;
|
|
4876
|
+
}
|
|
4877
|
+
function buildA11yTree(t = document.body, e) {
|
|
4878
|
+
const { pruneUnnamed: n = !0, preserveRoles: i = [], ...r } = e ?? {}, o = ensureResolvedA11yConfig(r), s = { pruneUnnamed: n, preserveRoles: i }, a = { value: 0 }, c = /* @__PURE__ */ new Map(), d = resolveElementList(o.blacklist, t), u = resolveElementList(o.whitelist, t), h = [], p = document.getElementById(HIGHLIGHT_CONTAINER_ID);
|
|
4879
|
+
p && d.add(p);
|
|
4880
|
+
const m = collectHoverPointerElements(t);
|
|
4881
|
+
for (const E of getComposedChildren(t)) {
|
|
4882
|
+
const L = buildVNode(E, a, c, d, u, o, m);
|
|
4883
|
+
L && h.push(...serializeVNode(L, 0, s));
|
|
4564
4884
|
}
|
|
4565
4885
|
return {
|
|
4566
|
-
yaml: "```yaml\n" +
|
|
4886
|
+
yaml: "```yaml\n" + h.join(`
|
|
4567
4887
|
`) + "\n```",
|
|
4568
|
-
refMap:
|
|
4569
|
-
interactiveCount:
|
|
4570
|
-
lines:
|
|
4888
|
+
refMap: c,
|
|
4889
|
+
interactiveCount: c.size,
|
|
4890
|
+
lines: h
|
|
4571
4891
|
};
|
|
4572
4892
|
}
|
|
4573
|
-
function searchA11yTree(t, e = document.body, n
|
|
4893
|
+
function searchA11yTree(t, e = document.body, n) {
|
|
4574
4894
|
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 (
|
|
4589
|
-
|
|
4895
|
+
contextLines: i = 2,
|
|
4896
|
+
caseInsensitive: r = !0,
|
|
4897
|
+
maxMatches: o = 20,
|
|
4898
|
+
...s
|
|
4899
|
+
} = n ?? {}, a = Math.max(0, i), c = Math.max(1, o), { lines: d, refMap: u, yaml: h } = buildA11yTree(e, s), p = r ? t.toLowerCase() : t, m = d.length, E = /^#\d+$/.test(t) ? new RegExp(`\\s${t}(?:\\s|[\\[]|$)`) : null, L = [];
|
|
4900
|
+
for (let C = 0; C < d.length; C++) {
|
|
4901
|
+
let S = !1;
|
|
4902
|
+
E ? S = E.test(d[C]) : S = (r ? d[C].toLowerCase() : d[C]).includes(p), S && L.push(C);
|
|
4903
|
+
}
|
|
4904
|
+
const f = [];
|
|
4905
|
+
let b = !1;
|
|
4906
|
+
for (const C of L) {
|
|
4907
|
+
const S = Math.max(0, C - a), A = Math.min(m - 1, C + a), D = f[f.length - 1];
|
|
4908
|
+
if (D && S <= D.end + 1)
|
|
4909
|
+
D.end = Math.max(D.end, A), D.hits.push(C);
|
|
4590
4910
|
else {
|
|
4591
|
-
if (
|
|
4592
|
-
|
|
4911
|
+
if (f.length >= c) {
|
|
4912
|
+
b = !0;
|
|
4593
4913
|
break;
|
|
4594
4914
|
}
|
|
4595
|
-
|
|
4915
|
+
f.push({ start: S, end: A, hits: [C] });
|
|
4596
4916
|
}
|
|
4597
4917
|
}
|
|
4598
|
-
const
|
|
4599
|
-
lineNumber:
|
|
4600
|
-
line:
|
|
4601
|
-
context: Array.from({ length:
|
|
4602
|
-
lineNumber:
|
|
4603
|
-
line:
|
|
4918
|
+
const T = f.map((C) => ({
|
|
4919
|
+
lineNumber: C.hits[0] + 1,
|
|
4920
|
+
line: d[C.hits[0]],
|
|
4921
|
+
context: Array.from({ length: C.end - C.start + 1 }, (S, A) => ({
|
|
4922
|
+
lineNumber: C.start + A + 1,
|
|
4923
|
+
line: d[C.start + A]
|
|
4604
4924
|
}))
|
|
4605
|
-
})),
|
|
4606
|
-
`无障碍树搜索结果 — 关键词: "${t}" | 总行数: ${
|
|
4925
|
+
})), y = [
|
|
4926
|
+
`无障碍树搜索结果 — 关键词: "${t}" | 总行数: ${m} | 命中: ${L.length} 行 | 返回分组: ${T.length}`,
|
|
4607
4927
|
""
|
|
4608
4928
|
];
|
|
4609
|
-
return
|
|
4610
|
-
const
|
|
4611
|
-
|
|
4612
|
-
const
|
|
4613
|
-
|
|
4614
|
-
}),
|
|
4615
|
-
}),
|
|
4616
|
-
text:
|
|
4929
|
+
return T.length === 0 ? y.push("(未找到匹配项)") : (T.forEach((C, S) => {
|
|
4930
|
+
const A = f[S];
|
|
4931
|
+
y.push(`── 分组 ${S + 1}(第 ${A.start + 1}–${A.end + 1} 行)──`), C.context.forEach(({ lineNumber: D, line: P }) => {
|
|
4932
|
+
const R = A.hits.includes(D - 1), F = String(D).padStart(4);
|
|
4933
|
+
y.push(R ? `>>>${F} | ${P}` : ` ${F} | ${P}`);
|
|
4934
|
+
}), y.push("");
|
|
4935
|
+
}), b && y.push(`⚠️ 命中过多,已截断至前 ${c} 个分组,建议缩小搜索范围`), y.push("提示:如需操作命中元素,使用其 #N 索引;如需查看完整树,请使用 browserState。")), {
|
|
4936
|
+
text: y.join(`
|
|
4617
4937
|
`),
|
|
4618
|
-
matches:
|
|
4619
|
-
totalLines:
|
|
4620
|
-
matchCount:
|
|
4621
|
-
refMap:
|
|
4622
|
-
yaml:
|
|
4938
|
+
matches: T,
|
|
4939
|
+
totalLines: m,
|
|
4940
|
+
matchCount: L.length,
|
|
4941
|
+
refMap: u,
|
|
4942
|
+
yaml: h
|
|
4623
4943
|
};
|
|
4624
4944
|
}
|
|
4625
4945
|
function Diff() {
|
|
@@ -4628,66 +4948,66 @@ Diff.prototype = {
|
|
|
4628
4948
|
diff: function t(e, n) {
|
|
4629
4949
|
var i, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, o = r.callback;
|
|
4630
4950
|
typeof r == "function" && (o = r, r = {});
|
|
4631
|
-
var
|
|
4632
|
-
function
|
|
4633
|
-
return
|
|
4634
|
-
o(
|
|
4635
|
-
}, 0), !0) :
|
|
4951
|
+
var s = this;
|
|
4952
|
+
function a(y) {
|
|
4953
|
+
return y = s.postProcess(y, r), o ? (setTimeout(function() {
|
|
4954
|
+
o(y);
|
|
4955
|
+
}, 0), !0) : y;
|
|
4636
4956
|
}
|
|
4637
4957
|
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,
|
|
4639
|
-
r.maxEditLength != null && (
|
|
4640
|
-
var
|
|
4958
|
+
var c = n.length, d = e.length, u = 1, h = c + d;
|
|
4959
|
+
r.maxEditLength != null && (h = Math.min(h, r.maxEditLength));
|
|
4960
|
+
var p = (i = r.timeout) !== null && i !== void 0 ? i : 1 / 0, m = Date.now() + p, g = [{
|
|
4641
4961
|
oldPos: -1,
|
|
4642
4962
|
lastComponent: void 0
|
|
4643
|
-
}],
|
|
4644
|
-
if (g[0].oldPos + 1 >=
|
|
4645
|
-
return
|
|
4646
|
-
var
|
|
4647
|
-
function
|
|
4648
|
-
for (var
|
|
4649
|
-
var
|
|
4650
|
-
|
|
4651
|
-
var
|
|
4652
|
-
if (
|
|
4653
|
-
var
|
|
4654
|
-
|
|
4963
|
+
}], E = this.extractCommon(g[0], n, e, 0, r);
|
|
4964
|
+
if (g[0].oldPos + 1 >= d && E + 1 >= c)
|
|
4965
|
+
return a(buildValues(s, g[0].lastComponent, n, e, s.useLongestToken));
|
|
4966
|
+
var L = -1 / 0, f = 1 / 0;
|
|
4967
|
+
function b() {
|
|
4968
|
+
for (var y = Math.max(L, -u); y <= Math.min(f, u); y += 2) {
|
|
4969
|
+
var C = void 0, S = g[y - 1], A = g[y + 1];
|
|
4970
|
+
S && (g[y - 1] = void 0);
|
|
4971
|
+
var D = !1;
|
|
4972
|
+
if (A) {
|
|
4973
|
+
var P = A.oldPos - y;
|
|
4974
|
+
D = A && 0 <= P && P < c;
|
|
4655
4975
|
}
|
|
4656
|
-
var
|
|
4657
|
-
if (!
|
|
4658
|
-
g[
|
|
4976
|
+
var R = S && S.oldPos + 1 < d;
|
|
4977
|
+
if (!D && !R) {
|
|
4978
|
+
g[y] = void 0;
|
|
4659
4979
|
continue;
|
|
4660
4980
|
}
|
|
4661
|
-
if (!
|
|
4662
|
-
return
|
|
4663
|
-
g[
|
|
4981
|
+
if (!R || D && S.oldPos < A.oldPos ? C = s.addToPath(A, !0, !1, 0, r) : C = s.addToPath(S, !1, !0, 1, r), E = s.extractCommon(C, n, e, y, r), C.oldPos + 1 >= d && E + 1 >= c)
|
|
4982
|
+
return a(buildValues(s, C.lastComponent, n, e, s.useLongestToken));
|
|
4983
|
+
g[y] = C, C.oldPos + 1 >= d && (f = Math.min(f, y - 1)), E + 1 >= c && (L = Math.max(L, y + 1));
|
|
4664
4984
|
}
|
|
4665
|
-
|
|
4985
|
+
u++;
|
|
4666
4986
|
}
|
|
4667
4987
|
if (o)
|
|
4668
|
-
(function
|
|
4988
|
+
(function y() {
|
|
4669
4989
|
setTimeout(function() {
|
|
4670
|
-
if (
|
|
4990
|
+
if (u > h || Date.now() > m)
|
|
4671
4991
|
return o();
|
|
4672
|
-
|
|
4992
|
+
b() || y();
|
|
4673
4993
|
}, 0);
|
|
4674
4994
|
})();
|
|
4675
4995
|
else
|
|
4676
|
-
for (;
|
|
4677
|
-
var T =
|
|
4996
|
+
for (; u <= h && Date.now() <= m; ) {
|
|
4997
|
+
var T = b();
|
|
4678
4998
|
if (T)
|
|
4679
4999
|
return T;
|
|
4680
5000
|
}
|
|
4681
5001
|
},
|
|
4682
5002
|
addToPath: function t(e, n, i, r, o) {
|
|
4683
|
-
var
|
|
4684
|
-
return
|
|
5003
|
+
var s = e.lastComponent;
|
|
5004
|
+
return s && !o.oneChangePerToken && s.added === n && s.removed === i ? {
|
|
4685
5005
|
oldPos: e.oldPos + r,
|
|
4686
5006
|
lastComponent: {
|
|
4687
|
-
count:
|
|
5007
|
+
count: s.count + 1,
|
|
4688
5008
|
added: n,
|
|
4689
5009
|
removed: i,
|
|
4690
|
-
previousComponent:
|
|
5010
|
+
previousComponent: s.previousComponent
|
|
4691
5011
|
}
|
|
4692
5012
|
} : {
|
|
4693
5013
|
oldPos: e.oldPos + r,
|
|
@@ -4695,24 +5015,24 @@ Diff.prototype = {
|
|
|
4695
5015
|
count: 1,
|
|
4696
5016
|
added: n,
|
|
4697
5017
|
removed: i,
|
|
4698
|
-
previousComponent:
|
|
5018
|
+
previousComponent: s
|
|
4699
5019
|
}
|
|
4700
5020
|
};
|
|
4701
5021
|
},
|
|
4702
5022
|
extractCommon: function t(e, n, i, r, o) {
|
|
4703
|
-
for (var
|
|
4704
|
-
|
|
5023
|
+
for (var s = n.length, a = i.length, c = e.oldPos, d = c - r, u = 0; d + 1 < s && c + 1 < a && this.equals(i[c + 1], n[d + 1], o); )
|
|
5024
|
+
d++, c++, u++, o.oneChangePerToken && (e.lastComponent = {
|
|
4705
5025
|
count: 1,
|
|
4706
5026
|
previousComponent: e.lastComponent,
|
|
4707
5027
|
added: !1,
|
|
4708
5028
|
removed: !1
|
|
4709
5029
|
});
|
|
4710
|
-
return
|
|
4711
|
-
count:
|
|
5030
|
+
return u && !o.oneChangePerToken && (e.lastComponent = {
|
|
5031
|
+
count: u,
|
|
4712
5032
|
previousComponent: e.lastComponent,
|
|
4713
5033
|
added: !1,
|
|
4714
5034
|
removed: !1
|
|
4715
|
-
}), e.oldPos = c,
|
|
5035
|
+
}), e.oldPos = c, d;
|
|
4716
5036
|
},
|
|
4717
5037
|
equals: function t(e, n, i) {
|
|
4718
5038
|
return i.comparator ? i.comparator(e, n) : e === n || i.ignoreCase && e.toLowerCase() === n.toLowerCase();
|
|
@@ -4736,23 +5056,23 @@ Diff.prototype = {
|
|
|
4736
5056
|
}
|
|
4737
5057
|
};
|
|
4738
5058
|
function buildValues(t, e, n, i, r) {
|
|
4739
|
-
for (var o = [],
|
|
4740
|
-
o.push(e),
|
|
5059
|
+
for (var o = [], s; e; )
|
|
5060
|
+
o.push(e), s = e.previousComponent, delete e.previousComponent, e = s;
|
|
4741
5061
|
o.reverse();
|
|
4742
|
-
for (var
|
|
4743
|
-
var
|
|
4744
|
-
if (
|
|
4745
|
-
|
|
5062
|
+
for (var a = 0, c = o.length, d = 0, u = 0; a < c; a++) {
|
|
5063
|
+
var h = o[a];
|
|
5064
|
+
if (h.removed)
|
|
5065
|
+
h.value = t.join(i.slice(u, u + h.count)), u += h.count;
|
|
4746
5066
|
else {
|
|
4747
|
-
if (!
|
|
4748
|
-
var
|
|
4749
|
-
|
|
4750
|
-
var
|
|
4751
|
-
return
|
|
4752
|
-
}),
|
|
5067
|
+
if (!h.added && r) {
|
|
5068
|
+
var p = n.slice(d, d + h.count);
|
|
5069
|
+
p = p.map(function(m, g) {
|
|
5070
|
+
var E = i[u + g];
|
|
5071
|
+
return E.length > m.length ? E : m;
|
|
5072
|
+
}), h.value = t.join(p);
|
|
4753
5073
|
} else
|
|
4754
|
-
|
|
4755
|
-
|
|
5074
|
+
h.value = t.join(n.slice(d, d + h.count));
|
|
5075
|
+
d += h.count, h.added || (u += h.count);
|
|
4756
5076
|
}
|
|
4757
5077
|
}
|
|
4758
5078
|
return o;
|
|
@@ -4801,16 +5121,16 @@ function overlapCount(t, e) {
|
|
|
4801
5121
|
t.length < e.length && (i = t.length);
|
|
4802
5122
|
var r = Array(i), o = 0;
|
|
4803
5123
|
r[0] = 0;
|
|
4804
|
-
for (var
|
|
4805
|
-
for (e[
|
|
5124
|
+
for (var s = 1; s < i; s++) {
|
|
5125
|
+
for (e[s] == e[o] ? r[s] = r[o] : r[s] = o; o > 0 && e[s] != e[o]; )
|
|
4806
5126
|
o = r[o];
|
|
4807
|
-
e[
|
|
5127
|
+
e[s] == e[o] && o++;
|
|
4808
5128
|
}
|
|
4809
5129
|
o = 0;
|
|
4810
|
-
for (var
|
|
4811
|
-
for (; o > 0 && t[
|
|
5130
|
+
for (var a = n; a < t.length; a++) {
|
|
5131
|
+
for (; o > 0 && t[a] != e[o]; )
|
|
4812
5132
|
o = r[o];
|
|
4813
|
-
t[
|
|
5133
|
+
t[a] == e[o] && o++;
|
|
4814
5134
|
}
|
|
4815
5135
|
return o;
|
|
4816
5136
|
}
|
|
@@ -4848,28 +5168,28 @@ wordDiff.postProcess = function(t, e) {
|
|
|
4848
5168
|
};
|
|
4849
5169
|
function dedupeWhitespaceInChangeObjects(t, e, n, i) {
|
|
4850
5170
|
if (e && n) {
|
|
4851
|
-
var r = e.value.match(/^\s*/)[0], o = e.value.match(/\s*$/)[0],
|
|
5171
|
+
var r = e.value.match(/^\s*/)[0], o = e.value.match(/\s*$/)[0], s = n.value.match(/^\s*/)[0], a = n.value.match(/\s*$/)[0];
|
|
4852
5172
|
if (t) {
|
|
4853
|
-
var c = longestCommonPrefix(r,
|
|
4854
|
-
t.value = replaceSuffix(t.value,
|
|
5173
|
+
var c = longestCommonPrefix(r, s);
|
|
5174
|
+
t.value = replaceSuffix(t.value, s, c), e.value = removePrefix(e.value, c), n.value = removePrefix(n.value, c);
|
|
4855
5175
|
}
|
|
4856
5176
|
if (i) {
|
|
4857
|
-
var
|
|
4858
|
-
i.value = replacePrefix(i.value,
|
|
5177
|
+
var d = longestCommonSuffix(o, a);
|
|
5178
|
+
i.value = replacePrefix(i.value, a, d), e.value = removeSuffix(e.value, d), n.value = removeSuffix(n.value, d);
|
|
4859
5179
|
}
|
|
4860
5180
|
} else if (n)
|
|
4861
5181
|
t && (n.value = n.value.replace(/^\s*/, "")), i && (i.value = i.value.replace(/^\s*/, ""));
|
|
4862
5182
|
else if (t && i) {
|
|
4863
|
-
var
|
|
5183
|
+
var u = i.value.match(/^\s*/)[0], h = e.value.match(/^\s*/)[0], p = e.value.match(/\s*$/)[0], m = longestCommonPrefix(u, h);
|
|
4864
5184
|
e.value = removePrefix(e.value, m);
|
|
4865
|
-
var g = longestCommonSuffix(removePrefix(
|
|
4866
|
-
e.value = removeSuffix(e.value, g), i.value = replacePrefix(i.value,
|
|
5185
|
+
var g = longestCommonSuffix(removePrefix(u, m), p);
|
|
5186
|
+
e.value = removeSuffix(e.value, g), i.value = replacePrefix(i.value, u, g), t.value = replaceSuffix(t.value, u, u.slice(0, u.length - g.length));
|
|
4867
5187
|
} else if (i) {
|
|
4868
|
-
var
|
|
4869
|
-
e.value = removeSuffix(e.value,
|
|
5188
|
+
var E = i.value.match(/^\s*/)[0], L = e.value.match(/\s*$/)[0], f = maximumOverlap(L, E);
|
|
5189
|
+
e.value = removeSuffix(e.value, f);
|
|
4870
5190
|
} else if (t) {
|
|
4871
|
-
var
|
|
4872
|
-
e.value = removePrefix(e.value,
|
|
5191
|
+
var b = t.value.match(/\s*$/)[0], T = e.value.match(/^\s*/)[0], y = maximumOverlap(b, T);
|
|
5192
|
+
e.value = removePrefix(e.value, y);
|
|
4873
5193
|
}
|
|
4874
5194
|
}
|
|
4875
5195
|
var wordWithSpaceDiff = new Diff();
|
|
@@ -4919,8 +5239,8 @@ var jsonDiff = new Diff();
|
|
|
4919
5239
|
jsonDiff.useLongestToken = !0;
|
|
4920
5240
|
jsonDiff.tokenize = lineDiff.tokenize;
|
|
4921
5241
|
jsonDiff.castInput = function(t, e) {
|
|
4922
|
-
var n = e.undefinedReplacement, i = e.stringifyReplacer, r = i === void 0 ? function(o,
|
|
4923
|
-
return typeof
|
|
5242
|
+
var n = e.undefinedReplacement, i = e.stringifyReplacer, r = i === void 0 ? function(o, s) {
|
|
5243
|
+
return typeof s > "u" ? n : s;
|
|
4924
5244
|
} : i;
|
|
4925
5245
|
return typeof t == "string" ? t : JSON.stringify(canonicalize(t, null, null, r), r, " ");
|
|
4926
5246
|
};
|
|
@@ -4933,23 +5253,23 @@ function canonicalize(t, e, n, i, r) {
|
|
|
4933
5253
|
for (o = 0; o < e.length; o += 1)
|
|
4934
5254
|
if (e[o] === t)
|
|
4935
5255
|
return n[o];
|
|
4936
|
-
var
|
|
5256
|
+
var s;
|
|
4937
5257
|
if (Object.prototype.toString.call(t) === "[object Array]") {
|
|
4938
|
-
for (e.push(t),
|
|
4939
|
-
|
|
4940
|
-
return e.pop(), n.pop(),
|
|
5258
|
+
for (e.push(t), s = new Array(t.length), n.push(s), o = 0; o < t.length; o += 1)
|
|
5259
|
+
s[o] = canonicalize(t[o], e, n, i, r);
|
|
5260
|
+
return e.pop(), n.pop(), s;
|
|
4941
5261
|
}
|
|
4942
5262
|
if (t && t.toJSON && (t = t.toJSON()), _typeof(t) === "object" && t !== null) {
|
|
4943
|
-
e.push(t),
|
|
4944
|
-
var
|
|
5263
|
+
e.push(t), s = {}, n.push(s);
|
|
5264
|
+
var a = [], c;
|
|
4945
5265
|
for (c in t)
|
|
4946
|
-
Object.prototype.hasOwnProperty.call(t, c) &&
|
|
4947
|
-
for (
|
|
4948
|
-
c =
|
|
5266
|
+
Object.prototype.hasOwnProperty.call(t, c) && a.push(c);
|
|
5267
|
+
for (a.sort(), o = 0; o < a.length; o += 1)
|
|
5268
|
+
c = a[o], s[c] = canonicalize(t[c], e, n, i, c);
|
|
4949
5269
|
e.pop(), n.pop();
|
|
4950
5270
|
} else
|
|
4951
|
-
|
|
4952
|
-
return
|
|
5271
|
+
s = t;
|
|
5272
|
+
return s;
|
|
4953
5273
|
}
|
|
4954
5274
|
var arrayDiff = new Diff();
|
|
4955
5275
|
arrayDiff.tokenize = function(t) {
|
|
@@ -4973,18 +5293,18 @@ class PageStateCache {
|
|
|
4973
5293
|
*/
|
|
4974
5294
|
update(e, n) {
|
|
4975
5295
|
const i = this.isFullRefresh(e), r = this.prev?.url ?? "";
|
|
4976
|
-
let o = 0,
|
|
5296
|
+
let o = 0, s = 0, a = "";
|
|
4977
5297
|
if (!i && this.prev) {
|
|
4978
|
-
const c = diffLines(this.prev.yaml, n),
|
|
4979
|
-
c.forEach((
|
|
4980
|
-
if (!
|
|
4981
|
-
const
|
|
5298
|
+
const c = diffLines(this.prev.yaml, n), d = [];
|
|
5299
|
+
c.forEach((u) => {
|
|
5300
|
+
if (!u.added && !u.removed) return;
|
|
5301
|
+
const h = u.value.split(`
|
|
4982
5302
|
`).filter(Boolean);
|
|
4983
|
-
|
|
4984
|
-
}),
|
|
5303
|
+
u.added ? (o += h.length, h.forEach((p) => d.push(`+ ${p}`))) : (s += h.length, h.forEach((p) => d.push(`- ${p}`)));
|
|
5304
|
+
}), a = d.join(`
|
|
4985
5305
|
`);
|
|
4986
5306
|
}
|
|
4987
|
-
return this.prev = { url: e, yaml: n }, { isFullRefresh: i, prevUrl: r, addedLines: o, removedLines:
|
|
5307
|
+
return this.prev = { url: e, yaml: n }, { isFullRefresh: i, prevUrl: r, addedLines: o, removedLines: s, diffText: a };
|
|
4988
5308
|
}
|
|
4989
5309
|
/** 强制清空缓存(页面刷新 / 手动重置场景) */
|
|
4990
5310
|
invalidate() {
|
|
@@ -4992,114 +5312,114 @@ class PageStateCache {
|
|
|
4992
5312
|
}
|
|
4993
5313
|
}
|
|
4994
5314
|
function computeBorderGeometry(t, e, n, i) {
|
|
4995
|
-
const r = Math.max(1, Math.min(t, e)), o = Math.min(n, 20),
|
|
5315
|
+
const r = Math.max(1, Math.min(t, e)), o = Math.min(n, 20), a = Math.min(o + i, r), c = Math.min(a, Math.floor(t / 2)), d = Math.min(a, Math.floor(e / 2)), u = (w) => w / t * 2 - 1, h = (w) => w / e * 2 - 1, p = 0, m = t, g = 0, E = e, L = c, f = t - c, b = d, T = e - d, y = u(p), C = u(m), S = h(g), A = h(E), D = u(L), P = u(f), R = h(b), F = h(T), 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
5316
|
// Top strip
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5317
|
+
y,
|
|
5318
|
+
S,
|
|
5319
|
+
C,
|
|
5320
|
+
S,
|
|
5321
|
+
y,
|
|
5322
|
+
R,
|
|
5323
|
+
y,
|
|
5324
|
+
R,
|
|
5325
|
+
C,
|
|
5326
|
+
S,
|
|
5327
|
+
C,
|
|
5328
|
+
R,
|
|
5009
5329
|
// Bottom strip
|
|
5010
|
-
L,
|
|
5011
|
-
$,
|
|
5012
|
-
A,
|
|
5013
|
-
$,
|
|
5014
|
-
L,
|
|
5015
5330
|
y,
|
|
5016
|
-
|
|
5331
|
+
F,
|
|
5332
|
+
C,
|
|
5333
|
+
F,
|
|
5017
5334
|
y,
|
|
5018
5335
|
A,
|
|
5019
|
-
$,
|
|
5020
|
-
A,
|
|
5021
5336
|
y,
|
|
5337
|
+
A,
|
|
5338
|
+
C,
|
|
5339
|
+
F,
|
|
5340
|
+
C,
|
|
5341
|
+
A,
|
|
5022
5342
|
// Left strip
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5343
|
+
y,
|
|
5344
|
+
R,
|
|
5345
|
+
D,
|
|
5346
|
+
R,
|
|
5347
|
+
y,
|
|
5348
|
+
F,
|
|
5349
|
+
y,
|
|
5350
|
+
F,
|
|
5351
|
+
D,
|
|
5352
|
+
R,
|
|
5353
|
+
D,
|
|
5354
|
+
F,
|
|
5035
5355
|
// Right strip
|
|
5356
|
+
P,
|
|
5036
5357
|
R,
|
|
5037
|
-
|
|
5038
|
-
A,
|
|
5039
|
-
N,
|
|
5358
|
+
C,
|
|
5040
5359
|
R,
|
|
5041
|
-
|
|
5360
|
+
P,
|
|
5361
|
+
F,
|
|
5362
|
+
P,
|
|
5363
|
+
F,
|
|
5364
|
+
C,
|
|
5042
5365
|
R,
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
A,
|
|
5047
|
-
$
|
|
5048
|
-
]), s = new Float32Array([
|
|
5366
|
+
C,
|
|
5367
|
+
F
|
|
5368
|
+
]), l = new Float32Array([
|
|
5049
5369
|
// Top strip
|
|
5050
5370
|
B,
|
|
5051
|
-
|
|
5052
|
-
W,
|
|
5053
|
-
K,
|
|
5054
|
-
B,
|
|
5371
|
+
J,
|
|
5055
5372
|
G,
|
|
5373
|
+
J,
|
|
5056
5374
|
B,
|
|
5057
|
-
G,
|
|
5058
5375
|
W,
|
|
5059
|
-
|
|
5376
|
+
B,
|
|
5060
5377
|
W,
|
|
5061
5378
|
G,
|
|
5379
|
+
J,
|
|
5380
|
+
G,
|
|
5381
|
+
W,
|
|
5062
5382
|
// Bottom strip
|
|
5063
5383
|
B,
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5384
|
+
Z,
|
|
5385
|
+
G,
|
|
5386
|
+
Z,
|
|
5067
5387
|
B,
|
|
5068
|
-
|
|
5388
|
+
Q,
|
|
5069
5389
|
B,
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5390
|
+
Q,
|
|
5391
|
+
G,
|
|
5392
|
+
Z,
|
|
5393
|
+
G,
|
|
5394
|
+
Q,
|
|
5075
5395
|
// Left strip
|
|
5076
5396
|
B,
|
|
5077
|
-
|
|
5397
|
+
W,
|
|
5078
5398
|
ee,
|
|
5079
|
-
|
|
5399
|
+
W,
|
|
5080
5400
|
B,
|
|
5081
|
-
|
|
5401
|
+
Z,
|
|
5082
5402
|
B,
|
|
5083
|
-
|
|
5403
|
+
Z,
|
|
5084
5404
|
ee,
|
|
5085
|
-
|
|
5405
|
+
W,
|
|
5086
5406
|
ee,
|
|
5087
|
-
|
|
5407
|
+
Z,
|
|
5088
5408
|
// Right strip
|
|
5089
5409
|
te,
|
|
5090
|
-
G,
|
|
5091
5410
|
W,
|
|
5092
5411
|
G,
|
|
5412
|
+
W,
|
|
5093
5413
|
te,
|
|
5094
|
-
|
|
5414
|
+
Z,
|
|
5095
5415
|
te,
|
|
5096
|
-
|
|
5097
|
-
W,
|
|
5416
|
+
Z,
|
|
5098
5417
|
G,
|
|
5099
5418
|
W,
|
|
5100
|
-
|
|
5419
|
+
G,
|
|
5420
|
+
Z
|
|
5101
5421
|
]);
|
|
5102
|
-
return { positions: ce, uvs:
|
|
5422
|
+
return { positions: ce, uvs: l };
|
|
5103
5423
|
}
|
|
5104
5424
|
function compileShader(t, e, n) {
|
|
5105
5425
|
const i = t.createShader(e);
|
|
@@ -5114,8 +5434,8 @@ function createProgram(t, e, n) {
|
|
|
5114
5434
|
const i = compileShader(t, t.VERTEX_SHADER, e), r = compileShader(t, t.FRAGMENT_SHADER, n), o = t.createProgram();
|
|
5115
5435
|
if (!o) throw new Error("Failed to create program");
|
|
5116
5436
|
if (t.attachShader(o, i), t.attachShader(o, r), t.linkProgram(o), !t.getProgramParameter(o, t.LINK_STATUS)) {
|
|
5117
|
-
const
|
|
5118
|
-
throw t.deleteProgram(o), t.deleteShader(i), t.deleteShader(r), new Error(
|
|
5437
|
+
const s = t.getProgramInfoLog(o) || "Unknown link error";
|
|
5438
|
+
throw t.deleteProgram(o), t.deleteShader(i), t.deleteShader(r), new Error(s);
|
|
5119
5439
|
}
|
|
5120
5440
|
return t.deleteShader(i), t.deleteShader(r), o;
|
|
5121
5441
|
}
|
|
@@ -5298,23 +5618,23 @@ class Motion {
|
|
|
5298
5618
|
resize(e, n, i) {
|
|
5299
5619
|
if (this.disposed) throw new Error("Motion instance has been disposed.");
|
|
5300
5620
|
if (this.options.width = e, this.options.height = n, i && (this.options.ratio = i), !this.running) return;
|
|
5301
|
-
const { gl: r, program: o, vao:
|
|
5302
|
-
this.canvas.style.width = `${e}px`, this.canvas.style.height = `${n}px`, (this.canvas.width !==
|
|
5621
|
+
const { gl: r, program: o, vao: s, positionBuffer: a, uvBuffer: c, uResolution: d } = this.glr, u = i ?? this.options.ratio ?? window.devicePixelRatio ?? 1, h = Math.max(1, Math.floor(e * u)), p = Math.max(1, Math.floor(n * u));
|
|
5622
|
+
this.canvas.style.width = `${e}px`, this.canvas.style.height = `${n}px`, (this.canvas.width !== h || this.canvas.height !== p) && (this.canvas.width = h, this.canvas.height = p), r.viewport(0, 0, this.canvas.width, this.canvas.height), this.checkGLError(r, "resize: after viewport setup");
|
|
5303
5623
|
const { positions: m, uvs: g } = computeBorderGeometry(
|
|
5304
5624
|
this.canvas.width,
|
|
5305
5625
|
this.canvas.height,
|
|
5306
|
-
this.options.borderWidth *
|
|
5307
|
-
this.options.glowWidth *
|
|
5626
|
+
this.options.borderWidth * u,
|
|
5627
|
+
this.options.glowWidth * u
|
|
5308
5628
|
);
|
|
5309
|
-
r.bindVertexArray(
|
|
5310
|
-
const
|
|
5311
|
-
r.enableVertexAttribArray(
|
|
5312
|
-
const
|
|
5313
|
-
r.enableVertexAttribArray(
|
|
5314
|
-
const
|
|
5315
|
-
this.lastTime =
|
|
5316
|
-
const
|
|
5317
|
-
this.render(
|
|
5629
|
+
r.bindVertexArray(s), r.bindBuffer(r.ARRAY_BUFFER, a), r.bufferData(r.ARRAY_BUFFER, m, r.STATIC_DRAW);
|
|
5630
|
+
const E = r.getAttribLocation(o, "aPosition");
|
|
5631
|
+
r.enableVertexAttribArray(E), r.vertexAttribPointer(E, 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, g, r.STATIC_DRAW);
|
|
5632
|
+
const L = r.getAttribLocation(o, "aUV");
|
|
5633
|
+
r.enableVertexAttribArray(L), r.vertexAttribPointer(L, 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");
|
|
5634
|
+
const f = performance.now();
|
|
5635
|
+
this.lastTime = f;
|
|
5636
|
+
const b = (f - this.startTime) * 1e-3;
|
|
5637
|
+
this.render(b);
|
|
5318
5638
|
}
|
|
5319
5639
|
/**
|
|
5320
5640
|
* Automatically resizes the canvas to match the dimensions of the given element.
|
|
@@ -5388,36 +5708,36 @@ class Motion {
|
|
|
5388
5708
|
this.checkGLError(e, "setupGL: after createProgram");
|
|
5389
5709
|
const i = e.createVertexArray();
|
|
5390
5710
|
e.bindVertexArray(i), this.checkGLError(e, "setupGL: after VAO creation");
|
|
5391
|
-
const r = this.canvas.width || 2, o = this.canvas.height || 2, { positions:
|
|
5711
|
+
const r = this.canvas.width || 2, o = this.canvas.height || 2, { positions: s, uvs: a } = computeBorderGeometry(
|
|
5392
5712
|
r,
|
|
5393
5713
|
o,
|
|
5394
5714
|
this.options.borderWidth,
|
|
5395
5715
|
this.options.glowWidth
|
|
5396
5716
|
), c = e.createBuffer();
|
|
5397
|
-
e.bindBuffer(e.ARRAY_BUFFER, c), e.bufferData(e.ARRAY_BUFFER,
|
|
5398
|
-
const
|
|
5399
|
-
e.enableVertexAttribArray(
|
|
5400
|
-
const
|
|
5401
|
-
e.bindBuffer(e.ARRAY_BUFFER,
|
|
5402
|
-
const
|
|
5403
|
-
e.enableVertexAttribArray(
|
|
5404
|
-
const
|
|
5405
|
-
e.useProgram(n), e.uniform1f(g, this.options.borderWidth), e.uniform1f(
|
|
5406
|
-
const
|
|
5407
|
-
for (let
|
|
5408
|
-
e.uniform3f(e.getUniformLocation(n, `uColors[${
|
|
5717
|
+
e.bindBuffer(e.ARRAY_BUFFER, c), e.bufferData(e.ARRAY_BUFFER, s, e.STATIC_DRAW);
|
|
5718
|
+
const d = e.getAttribLocation(n, "aPosition");
|
|
5719
|
+
e.enableVertexAttribArray(d), e.vertexAttribPointer(d, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after position buffer setup");
|
|
5720
|
+
const u = e.createBuffer();
|
|
5721
|
+
e.bindBuffer(e.ARRAY_BUFFER, u), e.bufferData(e.ARRAY_BUFFER, a, e.STATIC_DRAW);
|
|
5722
|
+
const h = e.getAttribLocation(n, "aUV");
|
|
5723
|
+
e.enableVertexAttribArray(h), e.vertexAttribPointer(h, 2, e.FLOAT, !1, 0, 0), this.checkGLError(e, "setupGL: after UV buffer setup");
|
|
5724
|
+
const p = e.getUniformLocation(n, "uResolution"), m = e.getUniformLocation(n, "uTime"), g = e.getUniformLocation(n, "uBorderWidth"), E = e.getUniformLocation(n, "uGlowWidth"), L = e.getUniformLocation(n, "uBorderRadius"), f = e.getUniformLocation(n, "uColors"), b = e.getUniformLocation(n, "uGlowExponent"), T = e.getUniformLocation(n, "uGlowFactor");
|
|
5725
|
+
e.useProgram(n), e.uniform1f(g, this.options.borderWidth), e.uniform1f(E, this.options.glowWidth), e.uniform1f(L, this.options.borderRadius), this.options.mode === "dark" ? (e.uniform1f(b, 2), e.uniform1f(T, 1.8)) : (e.uniform1f(b, 1), e.uniform1f(T, 1));
|
|
5726
|
+
const y = (this.options.colors || DEFAULT_COLORS).map(parseColor);
|
|
5727
|
+
for (let C = 0; C < y.length; C++)
|
|
5728
|
+
e.uniform3f(e.getUniformLocation(n, `uColors[${C}]`), ...y[C]);
|
|
5409
5729
|
this.checkGLError(e, "setupGL: after uniform setup"), e.bindVertexArray(null), e.bindBuffer(e.ARRAY_BUFFER, null), this.glr = {
|
|
5410
5730
|
gl: e,
|
|
5411
5731
|
program: n,
|
|
5412
5732
|
vao: i,
|
|
5413
5733
|
positionBuffer: c,
|
|
5414
|
-
uvBuffer:
|
|
5415
|
-
uResolution:
|
|
5734
|
+
uvBuffer: u,
|
|
5735
|
+
uResolution: p,
|
|
5416
5736
|
uTime: m,
|
|
5417
5737
|
uBorderWidth: g,
|
|
5418
|
-
uGlowWidth:
|
|
5419
|
-
uBorderRadius:
|
|
5420
|
-
uColors:
|
|
5738
|
+
uGlowWidth: E,
|
|
5739
|
+
uBorderRadius: L,
|
|
5740
|
+
uColors: f
|
|
5421
5741
|
};
|
|
5422
5742
|
}
|
|
5423
5743
|
render(e) {
|
|
@@ -5474,8 +5794,8 @@ function isMainContentBackgroundDark() {
|
|
|
5474
5794
|
for (const r of i) {
|
|
5475
5795
|
const o = document.querySelector(r);
|
|
5476
5796
|
if (!o) continue;
|
|
5477
|
-
const
|
|
5478
|
-
if (!(
|
|
5797
|
+
const s = o.getBoundingClientRect();
|
|
5798
|
+
if (!(s.width * s.height < n) && isColorDark(window.getComputedStyle(o).backgroundColor))
|
|
5479
5799
|
return !0;
|
|
5480
5800
|
}
|
|
5481
5801
|
return !1;
|
|
@@ -5507,31 +5827,15 @@ const injectStyles = `
|
|
|
5507
5827
|
z-index: 10000;
|
|
5508
5828
|
}
|
|
5509
5829
|
|
|
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
5830
|
.webmcp-page-agent-cursorFilling {
|
|
5526
5831
|
position: absolute;
|
|
5527
5832
|
width: 100%;
|
|
5528
5833
|
height: 100%;
|
|
5529
|
-
background: url("data:image/svg+xml,%
|
|
5530
|
-
|
|
5834
|
+
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");
|
|
5835
|
+
background-size: 100% 100%;
|
|
5531
5836
|
background-repeat: no-repeat;
|
|
5532
5837
|
|
|
5533
5838
|
transform-origin: center;
|
|
5534
|
-
transform: rotate(-90deg) scale(0.8);
|
|
5535
5839
|
margin-left: -10px;
|
|
5536
5840
|
margin-top: -18px;
|
|
5537
5841
|
}
|
|
@@ -5589,23 +5893,26 @@ class SimulatorMask extends EventTarget {
|
|
|
5589
5893
|
constructor() {
|
|
5590
5894
|
super(), this.shown = !1, this.wrapper = document.createElement("div"), this.motion = null, this.#i = !1, this.#e = document.createElement("div"), this.#t = 0, this.#n = 0, this.#r = 0, this.#o = 0, document.head.appendChild(document.createElement("style")).textContent = injectStyles, this.wrapper.id = "page-agent-runtime_simulator-mask", this.wrapper.className = "webmcp-page-agent-wrapper", this.wrapper.setAttribute("data-browser-use-ignore", "true"), this.wrapper.setAttribute("data-page-agent-ignore", "true");
|
|
5591
5895
|
try {
|
|
5592
|
-
const
|
|
5896
|
+
const s = new Motion({
|
|
5593
5897
|
mode: isPageDark() ? "dark" : "light",
|
|
5594
|
-
styles: { position: "absolute", inset: "0" }
|
|
5898
|
+
styles: { position: "absolute", inset: "0" },
|
|
5899
|
+
glowWidth: 80,
|
|
5900
|
+
borderWidth: 8,
|
|
5901
|
+
colors: ["rgb(121, 216, 247)", "rgb(171, 219, 110)", "rgb(252, 188, 114)", "rgb(235, 117, 231)"]
|
|
5595
5902
|
});
|
|
5596
|
-
this.motion =
|
|
5597
|
-
} catch (
|
|
5598
|
-
console.warn("[SimulatorMask] Motion overlay unavailable:",
|
|
5903
|
+
this.motion = s, this.wrapper.appendChild(s.element), s.autoResize(this.wrapper);
|
|
5904
|
+
} catch (s) {
|
|
5905
|
+
console.warn("[SimulatorMask] Motion overlay unavailable:", s);
|
|
5599
5906
|
}
|
|
5600
|
-
const e = (
|
|
5601
|
-
|
|
5907
|
+
const e = (s) => {
|
|
5908
|
+
s.stopPropagation(), s.preventDefault();
|
|
5602
5909
|
};
|
|
5603
5910
|
["click", "mousedown", "mouseup", "mousemove", "wheel", "keydown", "keyup"].forEach(
|
|
5604
|
-
(
|
|
5605
|
-
), this.#
|
|
5606
|
-
const n = (
|
|
5607
|
-
const { x:
|
|
5608
|
-
this.setCursorPosition(
|
|
5911
|
+
(s) => this.wrapper.addEventListener(s, e)
|
|
5912
|
+
), this.#a(), document.body.appendChild(this.wrapper), this.#s();
|
|
5913
|
+
const n = (s) => {
|
|
5914
|
+
const { x: a, y: c } = s.detail;
|
|
5915
|
+
this.setCursorPosition(a, c);
|
|
5609
5916
|
}, i = () => {
|
|
5610
5917
|
this.triggerClickAnimation();
|
|
5611
5918
|
}, r = () => {
|
|
@@ -5623,21 +5930,19 @@ class SimulatorMask extends EventTarget {
|
|
|
5623
5930
|
#n;
|
|
5624
5931
|
#r;
|
|
5625
5932
|
#o;
|
|
5626
|
-
#
|
|
5933
|
+
#a() {
|
|
5627
5934
|
this.#e.className = "webmcp-page-agent-cursor";
|
|
5628
5935
|
const e = document.createElement("div");
|
|
5629
5936
|
e.className = "webmcp-page-agent-cursorRipple", this.#e.appendChild(e);
|
|
5630
5937
|
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);
|
|
5938
|
+
n.className = "webmcp-page-agent-cursorFilling", this.#e.appendChild(n), this.wrapper.appendChild(this.#e);
|
|
5634
5939
|
}
|
|
5635
|
-
#
|
|
5940
|
+
#s() {
|
|
5636
5941
|
if (this.#i) return;
|
|
5637
5942
|
const e = this.#t + (this.#r - this.#t) * 0.2, n = this.#n + (this.#o - this.#n) * 0.2, i = Math.abs(e - this.#r);
|
|
5638
5943
|
i > 0 && (i < 2 ? this.#t = this.#r : this.#t = e, this.#e.style.left = `${this.#t}px`);
|
|
5639
5944
|
const r = Math.abs(n - this.#o);
|
|
5640
|
-
r > 0 && (r < 2 ? this.#n = this.#o : this.#n = n, this.#e.style.top = `${this.#n}px`), requestAnimationFrame(() => this.#
|
|
5945
|
+
r > 0 && (r < 2 ? this.#n = this.#o : this.#n = n, this.#e.style.top = `${this.#n}px`), requestAnimationFrame(() => this.#s());
|
|
5641
5946
|
}
|
|
5642
5947
|
setCursorPosition(e, n) {
|
|
5643
5948
|
this.#i || (this.#r = e, this.#o = n);
|
|
@@ -5656,56 +5961,19 @@ class SimulatorMask extends EventTarget {
|
|
|
5656
5961
|
dispose() {
|
|
5657
5962
|
this.#i = !0, this.motion?.dispose(), this.wrapper.remove(), this.dispatchEvent(new Event("dispose"));
|
|
5658
5963
|
}
|
|
5964
|
+
// 根据目标元素大小,在 wrapper 添加绝对定位边框:2px 宽、与目标间距 2px,对角渐变 (0,0 → 1,1)
|
|
5965
|
+
borderElement(e) {
|
|
5966
|
+
if (!e) return;
|
|
5967
|
+
this.wrapper.querySelector(".webmcp-page-agent-border")?.remove();
|
|
5968
|
+
const n = e.getBoundingClientRect(), i = 2, r = 2, o = i + r, s = document.createElement("div");
|
|
5969
|
+
s.className = "webmcp-page-agent-border", s.style.position = "absolute", s.style.left = `${n.left - o}px`, s.style.top = `${n.top - o}px`, s.style.width = `${n.width + o * 2}px`, s.style.height = `${n.height + o * 2}px`, s.style.boxSizing = "border-box", s.style.pointerEvents = "none", s.style.zIndex = "10000", s.style.border = `${r}px solid transparent`, s.style.borderImageSource = "linear-gradient(to bottom right, #79D8F7, #ABDB6E, #FCBC72, #FA8682, #EB75E7)", s.style.borderImageSlice = "1", s.style.borderImageWidth = `${r}px`, this.wrapper.appendChild(s);
|
|
5970
|
+
}
|
|
5971
|
+
removeBorderElement() {
|
|
5972
|
+
this.wrapper.querySelector(".webmcp-page-agent-border")?.remove();
|
|
5973
|
+
}
|
|
5659
5974
|
}
|
|
5660
|
-
const
|
|
5661
|
-
|
|
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({
|
|
5708
|
-
action: z.enum(["browserState", "click", "fill", "select", "scroll", "executeJavascript", "searchTree"]).describe(`执行的动作名称, 每一次执行 'click', 'fill', 'select'动作之前,**必须**要先调用 'browserState' 去获取页面的最新状态。
|
|
5975
|
+
const inputSchema = z.object({
|
|
5976
|
+
action: z.enum(["browserState", "click", "fill", "select", "scroll", "executeJavascript", "searchTree", "hover"]).describe(`执行的动作名称, 每一次执行 'click', 'fill', 'select', 'hover'动作之前,**必须**要先调用 'browserState' 去获取页面的最新状态。
|
|
5709
5977
|
browserState: '查询整个页面的浏览器状态;返回页面的标题、URL、YAML格式的语义化页面树',
|
|
5710
5978
|
click: '根据元素索引点击;',
|
|
5711
5979
|
fill: '根据元素索引填写文本;';
|
|
@@ -5713,8 +5981,9 @@ const DEFAULT_ERROR_SELECTORS = [
|
|
|
5713
5981
|
scroll: '滚动页面的动作,可以指定水平滚动还是上下滚动; 不带元素索引时:滚动整个文档。带元素索引时:滚动该索引处的容器(或其最近的可滚动祖先元素)'
|
|
5714
5982
|
executeJavascript: '执行javascript代码'
|
|
5715
5983
|
searchTree: '按关键词搜索无障碍树,返回带行号的匹配节点及上下文,无需获取全量树。适合快速定位特定元素(如所有按钮、特定名称的链接等),显著减少上下文消耗。必须提供 query 参数。'
|
|
5984
|
+
hover: '根据元素索引悬浮(hover)目标元素; 触发 mouseover/mouseenter 等事件,用于显示 tooltip、展开悬浮菜单等交互; 操作后自动返回最新页面状态。'
|
|
5716
5985
|
`),
|
|
5717
|
-
index: z.number().min(0).optional().describe("执行动作 of the element index, 动作为 click,fill,select时,必须提供元素索引"),
|
|
5986
|
+
index: z.number().min(0).optional().describe("执行动作 of the element index, 动作为 click,fill,select,hover时,必须提供元素索引"),
|
|
5718
5987
|
text: z.string().optional().describe("执行动作的文本内容, 动作为 fill,select 时,必须提供文本内容"),
|
|
5719
5988
|
down: z.boolean().optional().describe("执行上下滚动时,必须提供down参数"),
|
|
5720
5989
|
right: z.boolean().optional().describe("执行水平滚动方向, 必须提供right参数"),
|
|
@@ -5729,86 +5998,97 @@ const DEFAULT_ERROR_SELECTORS = [
|
|
|
5729
5998
|
responseMode: z.enum(["full", "diff", "both"]).optional().default("diff").describe(
|
|
5730
5999
|
"返回浏览器状态的模式。full: 仅返回当前全量 A11y 树;diff: 仅返回与上一次状态的增量差异;both: 同时返回全量 A11y 树与增量差异。默认值为 diff。"
|
|
5731
6000
|
)
|
|
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}`);
|
|
6001
|
+
}), 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";
|
|
6002
|
+
function isPageAgentToolErrorResult(t) {
|
|
6003
|
+
return typeof t == "object" && t !== null && "isError" in t && t.isError === !0 && "error" in t && typeof t.error == "string";
|
|
6004
|
+
}
|
|
6005
|
+
function dispatchPageAgentToolResult(t) {
|
|
6006
|
+
window.dispatchEvent(new CustomEvent(PAGE_AGENT_TOOL_RESULT_EVENT, { detail: t }));
|
|
6007
|
+
}
|
|
6008
|
+
function setupPageAgentToolEventBridge(t, e) {
|
|
6009
|
+
window.__nextSdkPageAgentToolEventCleanup?.();
|
|
6010
|
+
const n = async (r) => {
|
|
6011
|
+
const o = r.detail, s = o?.requestId;
|
|
6012
|
+
if (!s) {
|
|
6013
|
+
dispatchPageAgentToolResult({
|
|
6014
|
+
requestId: "",
|
|
6015
|
+
data: {
|
|
6016
|
+
success: !1,
|
|
6017
|
+
error: "缺少 requestId"
|
|
5782
6018
|
}
|
|
5783
|
-
}
|
|
5784
|
-
|
|
6019
|
+
});
|
|
6020
|
+
return;
|
|
5785
6021
|
}
|
|
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
6022
|
try {
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
6023
|
+
const a = inputSchema.parse(o.data), c = await t(a);
|
|
6024
|
+
if (isPageAgentToolErrorResult(c)) {
|
|
6025
|
+
dispatchPageAgentToolResult({
|
|
6026
|
+
requestId: s,
|
|
6027
|
+
data: {
|
|
6028
|
+
success: !1,
|
|
6029
|
+
error: c.error,
|
|
6030
|
+
result: c
|
|
6031
|
+
}
|
|
6032
|
+
});
|
|
6033
|
+
return;
|
|
5804
6034
|
}
|
|
6035
|
+
dispatchPageAgentToolResult({
|
|
6036
|
+
requestId: s,
|
|
6037
|
+
data: {
|
|
6038
|
+
success: !0,
|
|
6039
|
+
result: c
|
|
6040
|
+
}
|
|
6041
|
+
});
|
|
6042
|
+
} catch (a) {
|
|
6043
|
+
dispatchPageAgentToolResult({
|
|
6044
|
+
requestId: s,
|
|
6045
|
+
data: {
|
|
6046
|
+
success: !1,
|
|
6047
|
+
error: a instanceof Error ? a.message : String(a)
|
|
6048
|
+
}
|
|
6049
|
+
});
|
|
6050
|
+
}
|
|
6051
|
+
}, i = async () => {
|
|
6052
|
+
try {
|
|
6053
|
+
await e.hideMask();
|
|
5805
6054
|
} catch {
|
|
5806
6055
|
}
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
6056
|
+
};
|
|
6057
|
+
window.addEventListener(PAGE_AGENT_TOOL_CALL_EVENT, n), window.addEventListener(PAGE_AGENT_CHAT_END_EVENT, i), window.__nextSdkPageAgentToolEventCleanup = () => {
|
|
6058
|
+
window.removeEventListener(PAGE_AGENT_TOOL_CALL_EVENT, n), window.removeEventListener(PAGE_AGENT_CHAT_END_EVENT, i), window.__nextSdkPageAgentToolEventCleanup = void 0;
|
|
6059
|
+
};
|
|
6060
|
+
}
|
|
6061
|
+
function withStateFields(t, e) {
|
|
6062
|
+
try {
|
|
6063
|
+
const n = JSON.parse(t);
|
|
6064
|
+
return JSON.stringify({ ...n, ...e });
|
|
6065
|
+
} catch {
|
|
6066
|
+
return JSON.stringify({ ...e, raw: t });
|
|
6067
|
+
}
|
|
6068
|
+
}
|
|
6069
|
+
async function createActionErrorResult(t, e) {
|
|
6070
|
+
try {
|
|
6071
|
+
const n = await e("full");
|
|
6072
|
+
return {
|
|
6073
|
+
isError: !0,
|
|
6074
|
+
error: t,
|
|
6075
|
+
content: [{ type: "text", text: withStateFields(n.content[0].text, { error: t }) }]
|
|
6076
|
+
};
|
|
6077
|
+
} catch (n) {
|
|
6078
|
+
return {
|
|
6079
|
+
isError: !0,
|
|
6080
|
+
error: t,
|
|
6081
|
+
content: [
|
|
6082
|
+
{
|
|
6083
|
+
type: "text",
|
|
6084
|
+
text: JSON.stringify({
|
|
6085
|
+
error: t,
|
|
6086
|
+
stateError: n instanceof Error ? n.message : String(n)
|
|
6087
|
+
})
|
|
6088
|
+
}
|
|
6089
|
+
]
|
|
6090
|
+
};
|
|
6091
|
+
}
|
|
5812
6092
|
}
|
|
5813
6093
|
async function handleBrowserState(t, e) {
|
|
5814
6094
|
if (window.__webmcpcli_beforeGetBrowserState)
|
|
@@ -5821,9 +6101,12 @@ async function handleBrowserState(t, e) {
|
|
|
5821
6101
|
}
|
|
5822
6102
|
async function handleClick(t, e) {
|
|
5823
6103
|
const n = t.responseMode ?? "diff";
|
|
5824
|
-
if (t.index === void 0) return e.
|
|
6104
|
+
if (t.index === void 0) return e.actionError("点击结果: 缺少元素索引");
|
|
5825
6105
|
const i = e.getRefMap().get(t.index);
|
|
5826
|
-
if (!i)
|
|
6106
|
+
if (!i)
|
|
6107
|
+
return e.actionError(
|
|
6108
|
+
`点击失败: ref 索引 ${t.index} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。`
|
|
6109
|
+
);
|
|
5827
6110
|
let r = i;
|
|
5828
6111
|
if (i.shadowRoot && !(i instanceof HTMLButtonElement) && !(i instanceof HTMLAnchorElement)) {
|
|
5829
6112
|
const o = i.shadowRoot.querySelector(
|
|
@@ -5835,9 +6118,13 @@ async function handleClick(t, e) {
|
|
|
5835
6118
|
}
|
|
5836
6119
|
async function handleFill(t, e) {
|
|
5837
6120
|
const n = t.responseMode ?? "diff";
|
|
5838
|
-
if (t.index === void 0 || typeof t.text != "string")
|
|
6121
|
+
if (t.index === void 0 || typeof t.text != "string")
|
|
6122
|
+
return e.actionError("填写结果: 缺少元素索引或文本内容");
|
|
5839
6123
|
const i = e.getRefMap().get(t.index);
|
|
5840
|
-
if (!i)
|
|
6124
|
+
if (!i)
|
|
6125
|
+
return e.actionError(
|
|
6126
|
+
`填写失败: ref 索引 ${t.index} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。`
|
|
6127
|
+
);
|
|
5841
6128
|
let r = i;
|
|
5842
6129
|
if (!(r instanceof HTMLInputElement) && !(r instanceof HTMLTextAreaElement)) {
|
|
5843
6130
|
const o = i.querySelector("input, textarea") ?? i.shadowRoot?.querySelector("input, textarea");
|
|
@@ -5850,23 +6137,27 @@ async function handleFill(t, e) {
|
|
|
5850
6137
|
try {
|
|
5851
6138
|
await inputTextElement(r, t.text), o = !0;
|
|
5852
6139
|
} catch {
|
|
5853
|
-
const
|
|
6140
|
+
const a = Object.getOwnPropertyDescriptor(
|
|
5854
6141
|
(r instanceof HTMLTextAreaElement ? HTMLTextAreaElement : HTMLInputElement).prototype,
|
|
5855
6142
|
"value"
|
|
5856
6143
|
)?.set;
|
|
5857
|
-
|
|
6144
|
+
a && (r instanceof HTMLInputElement || r instanceof HTMLTextAreaElement) && (a.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
6145
|
}
|
|
5859
6146
|
if (!o)
|
|
5860
|
-
return e.
|
|
6147
|
+
return e.actionError(`填写结果: 无法填写元素 ${t.index},元素不是 input、textarea 或 contenteditable`);
|
|
5861
6148
|
isInShadowDom(r) && dispatchComposedEvents(r, "input", "change");
|
|
5862
6149
|
}
|
|
5863
6150
|
return await waitForDomSettled(), e.buildBrowserStateResponse(n);
|
|
5864
6151
|
}
|
|
5865
6152
|
async function handleSelect(t, e) {
|
|
5866
6153
|
const n = t.responseMode ?? "diff";
|
|
5867
|
-
if (t.index === void 0 || typeof t.text != "string")
|
|
6154
|
+
if (t.index === void 0 || typeof t.text != "string")
|
|
6155
|
+
return e.actionError("选择结果: 缺少元素索引或文本内容");
|
|
5868
6156
|
let i = e.getRefMap().get(t.index);
|
|
5869
|
-
if (!i)
|
|
6157
|
+
if (!i)
|
|
6158
|
+
return e.actionError(
|
|
6159
|
+
`选择失败: ref 索引 ${t.index} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。`
|
|
6160
|
+
);
|
|
5870
6161
|
let r = null;
|
|
5871
6162
|
if (i instanceof HTMLSelectElement)
|
|
5872
6163
|
r = i;
|
|
@@ -5874,24 +6165,24 @@ async function handleSelect(t, e) {
|
|
|
5874
6165
|
const o = i.querySelector("select") ?? i.shadowRoot?.querySelector("select");
|
|
5875
6166
|
o && (r = o);
|
|
5876
6167
|
}
|
|
5877
|
-
return r ? (await selectOptionElement(r, t.text), isInShadowDom(r) && dispatchComposedEvents(r, "change"), await waitForDomSettled(), e.buildBrowserStateResponse(n)) : e.
|
|
6168
|
+
return r ? (await selectOptionElement(r, t.text), isInShadowDom(r) && dispatchComposedEvents(r, "change"), await waitForDomSettled(), e.buildBrowserStateResponse(n)) : e.actionError(`选择结果: 无法选择元素 ${t.index},未找到对应的 <select> 元素`);
|
|
5878
6169
|
}
|
|
5879
6170
|
function getScrollInfo(t = window) {
|
|
5880
6171
|
if (t === window) {
|
|
5881
|
-
const e = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight), n = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth), i = window.scrollY, r = window.scrollX, o = Math.max(0, e - (window.innerHeight + i)),
|
|
6172
|
+
const e = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight), n = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth), i = window.scrollY, r = window.scrollX, o = Math.max(0, e - (window.innerHeight + i)), s = Math.max(0, n - (window.innerWidth + r));
|
|
5882
6173
|
return {
|
|
5883
6174
|
scrollY: i,
|
|
5884
6175
|
scrollX: r,
|
|
5885
6176
|
pixelsAbove: i,
|
|
5886
6177
|
pixelsBelow: o,
|
|
5887
6178
|
pixelsLeft: r,
|
|
5888
|
-
pixelsRight:
|
|
6179
|
+
pixelsRight: s,
|
|
5889
6180
|
pagesAbove: window.innerHeight > 0 ? i / window.innerHeight : 0,
|
|
5890
6181
|
pagesBelow: window.innerHeight > 0 ? o / window.innerHeight : 0,
|
|
5891
6182
|
atTop: i <= 1,
|
|
5892
6183
|
atBottom: o <= 1,
|
|
5893
6184
|
atLeft: r <= 1,
|
|
5894
|
-
atRight:
|
|
6185
|
+
atRight: s <= 1
|
|
5895
6186
|
};
|
|
5896
6187
|
} else {
|
|
5897
6188
|
const e = t, n = e.scrollTop, i = e.scrollLeft, r = e.scrollHeight - e.clientHeight - n, o = e.scrollWidth - e.clientWidth - i;
|
|
@@ -5915,9 +6206,9 @@ function waitForScrollEnd(t, e = 2e3) {
|
|
|
5915
6206
|
return new Promise((n) => {
|
|
5916
6207
|
let i = !1;
|
|
5917
6208
|
const r = t === window ? document : t, o = () => {
|
|
5918
|
-
i || (i = !0, r.removeEventListener("scrollend",
|
|
5919
|
-
},
|
|
5920
|
-
r.addEventListener("scrollend",
|
|
6209
|
+
i || (i = !0, r.removeEventListener("scrollend", s), clearTimeout(a), n());
|
|
6210
|
+
}, s = () => o(), a = setTimeout(o, e);
|
|
6211
|
+
r.addEventListener("scrollend", s, { once: !0 });
|
|
5921
6212
|
});
|
|
5922
6213
|
}
|
|
5923
6214
|
async function handleScroll(t, e) {
|
|
@@ -5938,20 +6229,18 @@ async function handleScroll(t, e) {
|
|
|
5938
6229
|
i.scrollBy({ top: t.down ? m : -m, behavior: "smooth" });
|
|
5939
6230
|
}
|
|
5940
6231
|
await waitForScrollEnd(i);
|
|
5941
|
-
const o = getScrollInfo(i),
|
|
5942
|
-
let
|
|
5943
|
-
if (Math.abs(
|
|
5944
|
-
c ?
|
|
6232
|
+
const o = getScrollInfo(i), s = Math.round(o.scrollY - r.scrollY), a = Math.round(o.scrollX - r.scrollX), c = t.right !== void 0;
|
|
6233
|
+
let d;
|
|
6234
|
+
if (Math.abs(s) < 1 && Math.abs(a) < 1)
|
|
6235
|
+
c ? d = t.right ? "⚠️ 已到达右边界,无法继续向右滚动" : "⚠️ 已到达左边界,无法继续向左滚动" : d = t.down ? "⚠️ 已到达底部,无法继续向下滚动" : "⚠️ 已到达顶部,无法继续向上滚动";
|
|
5945
6236
|
else {
|
|
5946
|
-
const m = c ? `水平滚动 ${
|
|
6237
|
+
const m = c ? `水平滚动 ${a}px` : `垂直滚动 ${s}px`;
|
|
5947
6238
|
let g = "";
|
|
5948
|
-
c ? t.right && o.atRight ? g = ",已到达右边界" : !t.right && o.atLeft && (g = ",已到达左边界") : t.down && o.atBottom ? g = ",已到达底部" : !t.down && o.atTop && (g = ",已到达顶部"),
|
|
6239
|
+
c ? t.right && o.atRight ? g = ",已到达右边界" : !t.right && o.atLeft && (g = ",已到达左边界") : t.down && o.atBottom ? g = ",已到达底部" : !t.down && o.atTop && (g = ",已到达顶部"), d = `✅ ${m}${g}`;
|
|
5949
6240
|
}
|
|
5950
|
-
const
|
|
5951
|
-
${
|
|
5952
|
-
return
|
|
5953
|
-
|
|
5954
|
-
${f.content[0].text}`, f;
|
|
6241
|
+
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)} 屏`, h = `[滚动结果] ${d}
|
|
6242
|
+
${u}`, p = await e.buildBrowserStateResponse(n);
|
|
6243
|
+
return p.content[0].text = withStateFields(p.content[0].text, { scrollResult: h }), p;
|
|
5955
6244
|
}
|
|
5956
6245
|
async function handleExecuteJavascript(t, e) {
|
|
5957
6246
|
if (!t.script) return e.errContent("脚本执行异常: 缺少javascript代码");
|
|
@@ -5967,110 +6256,372 @@ async function handleExecuteJavascript(t, e) {
|
|
|
5967
6256
|
}
|
|
5968
6257
|
async function handleSearchTree(t, e) {
|
|
5969
6258
|
if (!t.query) return e.errContent("搜索失败: 缺少 query 参数");
|
|
5970
|
-
const n =
|
|
6259
|
+
const n = searchA11yTree(t.query, document.body, {
|
|
6260
|
+
...getPageAgentToolConfig().a11yConfig,
|
|
5971
6261
|
contextLines: t.contextLines,
|
|
5972
|
-
maxMatches: t.maxMatches
|
|
5973
|
-
exposedAttributes: r,
|
|
5974
|
-
errorSelectors: (window.__webmcpcli_errorSelectors ?? DEFAULT_ERROR_SELECTORS).join(", ")
|
|
6262
|
+
maxMatches: t.maxMatches
|
|
5975
6263
|
});
|
|
5976
|
-
e.setRefMap(
|
|
5977
|
-
const
|
|
6264
|
+
e.setRefMap(n.refMap), e.stateCache.update(window.location.href, n.yaml), await e.pageController.hideMask();
|
|
6265
|
+
const i = detectPageDialog(), r = detectValidationErrors();
|
|
6266
|
+
if (i.length === 0 && r.length === 0)
|
|
6267
|
+
return { content: [{ type: "text", text: n.text }] };
|
|
6268
|
+
const o = {
|
|
6269
|
+
...i.length > 0 ? { dialogs: i } : {},
|
|
6270
|
+
...r.length > 0 ? { validationErrors: r } : {}
|
|
6271
|
+
};
|
|
5978
6272
|
return {
|
|
5979
|
-
content: [{ type: "text", text:
|
|
5980
|
-
${
|
|
6273
|
+
content: [{ type: "text", text: `${JSON.stringify(o)}
|
|
6274
|
+
${n.text}` }]
|
|
5981
6275
|
};
|
|
5982
6276
|
}
|
|
6277
|
+
async function handleHover(t, e) {
|
|
6278
|
+
if (t.index === void 0) return e.errContent("悬浮结果: 缺少元素索引");
|
|
6279
|
+
const n = e.getRefMap().get(t.index);
|
|
6280
|
+
if (!n) return e.refreshOnStaleRef("悬浮", t.index);
|
|
6281
|
+
let i = n;
|
|
6282
|
+
if (n.shadowRoot && !(n instanceof HTMLButtonElement) && !(n instanceof HTMLAnchorElement)) {
|
|
6283
|
+
const d = n.shadowRoot.querySelector(
|
|
6284
|
+
'button, a, [role="button"], [role="link"]'
|
|
6285
|
+
);
|
|
6286
|
+
d && (i = d);
|
|
6287
|
+
}
|
|
6288
|
+
const r = i.getBoundingClientRect(), o = r.left + r.width / 2, s = r.top + r.height / 2, a = [
|
|
6289
|
+
{ type: "pointerenter", bubbles: !1, usePointer: !0 },
|
|
6290
|
+
{ type: "pointerover", bubbles: !0, usePointer: !0 },
|
|
6291
|
+
{ type: "pointermove", bubbles: !0, usePointer: !0 },
|
|
6292
|
+
{ type: "mouseenter", bubbles: !1, usePointer: !1 },
|
|
6293
|
+
{ type: "mouseover", bubbles: !0, usePointer: !1 },
|
|
6294
|
+
{ type: "mousemove", bubbles: !0, usePointer: !1 }
|
|
6295
|
+
];
|
|
6296
|
+
for (const { type: d, bubbles: u, usePointer: h } of a) {
|
|
6297
|
+
const p = h ? PointerEvent : MouseEvent;
|
|
6298
|
+
i.dispatchEvent(new p(d, {
|
|
6299
|
+
bubbles: u,
|
|
6300
|
+
cancelable: !0,
|
|
6301
|
+
view: window,
|
|
6302
|
+
clientX: o,
|
|
6303
|
+
clientY: s
|
|
6304
|
+
}));
|
|
6305
|
+
}
|
|
6306
|
+
await waitForDomSettled();
|
|
6307
|
+
const c = t.responseMode ?? "diff";
|
|
6308
|
+
return e.buildBrowserStateResponse(c);
|
|
6309
|
+
}
|
|
5983
6310
|
function registerPageAgentTool(t = {}) {
|
|
5984
|
-
initializeBuiltinWebMCP(),
|
|
6311
|
+
initializeBuiltinWebMCP(), setPageAgentToolConfig(t, { mode: "replace" }), window.__webmcpcli_beforeGetBrowserState = window.__webmcpcli_beforeGetBrowserState || null;
|
|
5985
6312
|
const e = new PageController({ enableMask: !1 });
|
|
5986
6313
|
e.maskReady = (async () => {
|
|
5987
6314
|
e.mask = new SimulatorMask();
|
|
5988
6315
|
})();
|
|
5989
6316
|
const n = new PageStateCache();
|
|
5990
6317
|
let i = /* @__PURE__ */ new Map();
|
|
5991
|
-
async function r(
|
|
5992
|
-
return
|
|
6318
|
+
async function r(u) {
|
|
6319
|
+
return { content: [{ type: "text", text: u }] };
|
|
5993
6320
|
}
|
|
5994
|
-
async function o(
|
|
5995
|
-
const
|
|
6321
|
+
async function o(u) {
|
|
6322
|
+
const h = await createActionErrorResult(u, a);
|
|
6323
|
+
return t.removeMaskAfterToolCall && await e.hideMask(), h;
|
|
6324
|
+
}
|
|
6325
|
+
async function s(u, h) {
|
|
6326
|
+
const p = await a("full"), m = `⚠️ ${u}失败: ref 索引 ${h} 已失效(页面可能已刷新),已自动重新加载页面状态,请使用新的 ref 索引重试。`;
|
|
5996
6327
|
return {
|
|
5997
|
-
content: [
|
|
5998
|
-
|
|
6328
|
+
content: [
|
|
6329
|
+
{
|
|
6330
|
+
type: "text",
|
|
6331
|
+
text: withStateFields(p.content[0].text, { warning: m })
|
|
6332
|
+
}
|
|
6333
|
+
]
|
|
5999
6334
|
};
|
|
6000
6335
|
}
|
|
6001
|
-
async function a(
|
|
6002
|
-
const
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
});
|
|
6006
|
-
i = S, t?.enableHighlight && (highlight(S), globalRemoveListener());
|
|
6007
|
-
const E = n.update(u, g);
|
|
6008
|
-
await e.hideMask();
|
|
6009
|
-
const h = detectPageDialog(), x = detectValidationErrors();
|
|
6336
|
+
async function a(u = "diff") {
|
|
6337
|
+
const h = window.location.href, p = document.title, { yaml: m, refMap: g } = buildA11yTree(document.body, getPageAgentToolConfig().a11yConfig);
|
|
6338
|
+
i = g, getPageAgentToolConfig().enableHighlight && (highlight(g), globalRemoveListener());
|
|
6339
|
+
const E = n.update(h, m), L = detectPageDialog(), f = detectValidationErrors(), b = detectVisibleTooltips();
|
|
6010
6340
|
let T = "";
|
|
6011
|
-
|
|
6012
|
-
${
|
|
6341
|
+
u === "full" ? T = m : u === "diff" ? T = E.isFullRefresh ? m : E.diffText : u === "both" && (T = `【全量页面树】:
|
|
6342
|
+
${m}
|
|
6013
6343
|
|
|
6014
6344
|
【增量差异】:
|
|
6015
|
-
${E.isFullRefresh ? "(首次/刷新,无增量差异)" : E.diffText}`)
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6345
|
+
${E.isFullRefresh ? "(首次/刷新,无增量差异)" : E.diffText}`);
|
|
6346
|
+
const y = {
|
|
6347
|
+
url: h,
|
|
6348
|
+
title: p,
|
|
6349
|
+
content: T,
|
|
6350
|
+
...L.length > 0 ? { dialogs: L } : {},
|
|
6351
|
+
...f.length > 0 ? { validationErrors: f } : {},
|
|
6352
|
+
...b.length > 0 ? { tooltips: b } : {}
|
|
6353
|
+
};
|
|
6354
|
+
return { content: [{ type: "text", text: JSON.stringify(y) }] };
|
|
6020
6355
|
}
|
|
6021
|
-
const
|
|
6356
|
+
const c = {
|
|
6022
6357
|
pageController: e,
|
|
6023
6358
|
stateCache: n,
|
|
6024
6359
|
getRefMap: () => i,
|
|
6025
|
-
setRefMap: (
|
|
6026
|
-
i =
|
|
6360
|
+
setRefMap: (u) => {
|
|
6361
|
+
i = u;
|
|
6027
6362
|
},
|
|
6028
6363
|
buildBrowserStateResponse: a,
|
|
6029
|
-
refreshOnStaleRef:
|
|
6030
|
-
errContent: r
|
|
6364
|
+
refreshOnStaleRef: s,
|
|
6365
|
+
errContent: r,
|
|
6366
|
+
actionError: o
|
|
6031
6367
|
};
|
|
6368
|
+
async function d(u) {
|
|
6369
|
+
try {
|
|
6370
|
+
let h;
|
|
6371
|
+
switch (u.action) {
|
|
6372
|
+
case "browserState":
|
|
6373
|
+
h = await handleBrowserState(u, c);
|
|
6374
|
+
break;
|
|
6375
|
+
case "click":
|
|
6376
|
+
await e.showMask(), e.mask.borderElement(i.get(u.index)), h = await handleClick(u, c), e.mask.removeBorderElement(), t.removeMaskAfterToolCall && await e.hideMask();
|
|
6377
|
+
break;
|
|
6378
|
+
case "fill":
|
|
6379
|
+
await e.showMask(), e.mask.borderElement(i.get(u.index)), h = await handleFill(u, c), e.mask.removeBorderElement(), t.removeMaskAfterToolCall && await e.hideMask();
|
|
6380
|
+
break;
|
|
6381
|
+
case "select":
|
|
6382
|
+
await e.showMask(), e.mask.borderElement(i.get(u.index)), h = await handleSelect(u, c), e.mask.removeBorderElement(), t.removeMaskAfterToolCall && await e.hideMask();
|
|
6383
|
+
break;
|
|
6384
|
+
case "scroll":
|
|
6385
|
+
await e.showMask(), h = await handleScroll(u, c), t.removeMaskAfterToolCall && await e.hideMask();
|
|
6386
|
+
break;
|
|
6387
|
+
case "executeJavascript":
|
|
6388
|
+
h = await handleExecuteJavascript(u, c);
|
|
6389
|
+
break;
|
|
6390
|
+
case "searchTree":
|
|
6391
|
+
h = await handleSearchTree(u, c);
|
|
6392
|
+
break;
|
|
6393
|
+
case "hover":
|
|
6394
|
+
h = await handleHover(u, c);
|
|
6395
|
+
break;
|
|
6396
|
+
default:
|
|
6397
|
+
h = { content: [{ type: "text", text: `未知操作: ${u.action}` }] };
|
|
6398
|
+
}
|
|
6399
|
+
return h;
|
|
6400
|
+
} catch (h) {
|
|
6401
|
+
const p = {
|
|
6402
|
+
click: "点击",
|
|
6403
|
+
fill: "填写",
|
|
6404
|
+
select: "选择"
|
|
6405
|
+
};
|
|
6406
|
+
if (u.action in p)
|
|
6407
|
+
return o(
|
|
6408
|
+
`${p[u.action]}执行异常: ${h instanceof Error ? h.message : String(h)}`
|
|
6409
|
+
);
|
|
6410
|
+
throw t.removeMaskAfterToolCall && await e.hideMask(), h;
|
|
6411
|
+
}
|
|
6412
|
+
}
|
|
6032
6413
|
document.modelContext.registerTool({
|
|
6033
6414
|
name: "page-agent-tool",
|
|
6034
6415
|
description: pageAgentPrompt,
|
|
6035
6416
|
// @ts-ignore
|
|
6036
6417
|
inputSchema: zodToJsonSchema(inputSchema),
|
|
6037
|
-
async execute(
|
|
6038
|
-
await e.showMask();
|
|
6418
|
+
async execute(u) {
|
|
6039
6419
|
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)}` }] };
|
|
6420
|
+
return d(u);
|
|
6421
|
+
} catch (h) {
|
|
6422
|
+
return { content: [{ type: "text", text: `异常: ${String(h)}` }] };
|
|
6060
6423
|
}
|
|
6061
6424
|
}
|
|
6062
|
-
});
|
|
6425
|
+
}), setupPageAgentToolEventBridge(d, e);
|
|
6426
|
+
}
|
|
6427
|
+
const consoleCloudPageAgentToolOptions = {
|
|
6428
|
+
enableHighlight: !1,
|
|
6429
|
+
a11yConfig: {
|
|
6430
|
+
roles: [
|
|
6431
|
+
// Tiny3 Tabs:真正可聚焦/可点击的是内部 .ti3-tabs-text(tabindex=0)
|
|
6432
|
+
{ role: "tablist", selector: "ul.ti3-tabs" },
|
|
6433
|
+
{ role: "tab", selector: ".ti3-tabs-text" },
|
|
6434
|
+
{ role: "tabpanel", selector: ["ti-tab.ti3-tab-pane", ".ti3-tab-pane"] },
|
|
6435
|
+
// 自定义下拉 / 区域选择触发器
|
|
6436
|
+
{
|
|
6437
|
+
role: "combobox",
|
|
6438
|
+
selector: [
|
|
6439
|
+
".ti3-select-dominator-container",
|
|
6440
|
+
".selected-label",
|
|
6441
|
+
".sort-select",
|
|
6442
|
+
".service-select",
|
|
6443
|
+
".region-select",
|
|
6444
|
+
'[cf-uba="searchableRegion..open"]'
|
|
6445
|
+
]
|
|
6446
|
+
},
|
|
6447
|
+
// 图标型 / 无语义按钮
|
|
6448
|
+
{
|
|
6449
|
+
role: "button",
|
|
6450
|
+
selector: [
|
|
6451
|
+
".modules-service-list-menu-service-icon-container",
|
|
6452
|
+
".ti3-btn-only-icon-noborder",
|
|
6453
|
+
".ti3-select-dominator-dropdown-btn",
|
|
6454
|
+
".modules-right-sidebar-icon-item-wrapper",
|
|
6455
|
+
".modules-right-sidebar-hide-state-plugin",
|
|
6456
|
+
".components-service-list-container-service-list-input-service-close",
|
|
6457
|
+
".modules-searchable-region-region-panel-close",
|
|
6458
|
+
".modules-searchable-region-region-panel-search-btn",
|
|
6459
|
+
'[cf-uba="rightSidebar..hideBtn"]',
|
|
6460
|
+
// Tiny3 图标组件:帮助中心固定/全屏/关闭等(ti-icon / tp-icon 无原生 button 语义)
|
|
6461
|
+
".ti-global-help-panel-header-icon",
|
|
6462
|
+
"ti-icon[name]",
|
|
6463
|
+
"tp-icon[name]",
|
|
6464
|
+
// 无 name 的箭头/操作图标(如 latest news 区 common-icon 展开箭头)
|
|
6465
|
+
"tp-icon.common-icon",
|
|
6466
|
+
"ti-icon.common-icon",
|
|
6467
|
+
"ti-icon.ti3-icon-full-screen",
|
|
6468
|
+
"ti-icon.ti3-icon-close",
|
|
6469
|
+
"tp-icon.ti3-icon-full-screen",
|
|
6470
|
+
"tp-icon.ti3-icon-close"
|
|
6471
|
+
]
|
|
6472
|
+
},
|
|
6473
|
+
// 服务列表侧栏分类 / 顶栏菜单项
|
|
6474
|
+
{
|
|
6475
|
+
role: "menuitem",
|
|
6476
|
+
selector: [
|
|
6477
|
+
".components-service-list-left-box-sidebar-visit-panel > li",
|
|
6478
|
+
".modules-menus-menu-item",
|
|
6479
|
+
".components-menu-wrapper-menu-text"
|
|
6480
|
+
]
|
|
6481
|
+
},
|
|
6482
|
+
// 区域筛选项 / 下拉选项
|
|
6483
|
+
{
|
|
6484
|
+
role: "option",
|
|
6485
|
+
selector: [
|
|
6486
|
+
".region-selector-item",
|
|
6487
|
+
".modules-searchable-region-project-item-region-item",
|
|
6488
|
+
".modules-searchable-region-region-panel-recent-region-item",
|
|
6489
|
+
".ti3-multiselect-box-cell"
|
|
6490
|
+
]
|
|
6491
|
+
},
|
|
6492
|
+
// 模态弹窗:补齐缺失的 role="dialog"(Tiny3 modal/message-box/drawer/侧栏面板)
|
|
6493
|
+
{
|
|
6494
|
+
role: "dialog",
|
|
6495
|
+
selector: [
|
|
6496
|
+
'[class*="ti3-modal"]',
|
|
6497
|
+
'[class*="ti3-message-box"]',
|
|
6498
|
+
'[class*="drawer"]',
|
|
6499
|
+
".modules-layout-module-sidebar-panel"
|
|
6500
|
+
]
|
|
6501
|
+
},
|
|
6502
|
+
// Tiny3 tooltip / 帮助提示:补齐缺失的 role="tooltip"
|
|
6503
|
+
{
|
|
6504
|
+
role: "tooltip",
|
|
6505
|
+
selector: ["tp-helptip", '[class*="ti3-tooltip"]', ".tp-helptip-content", ".ti3-tooltip", ".ti3-tooltip-popper"]
|
|
6506
|
+
}
|
|
6507
|
+
],
|
|
6508
|
+
states: {
|
|
6509
|
+
// 选中态:挂在容器 class 上,用 selector + closest 即可命中内部交互节点
|
|
6510
|
+
selected: [
|
|
6511
|
+
{ selector: "li.ti3-tab-li.ti3-tab-active" },
|
|
6512
|
+
// Tiny3 按钮组(计费模式等):ti3-active 在 .ti3-btn-item-container 上,不在 button 上
|
|
6513
|
+
{ selector: ".ti3-btn-item-container.ti3-active" },
|
|
6514
|
+
{ selector: ".components-service-list-left-box-active" },
|
|
6515
|
+
{
|
|
6516
|
+
selector: [
|
|
6517
|
+
".modules-searchable-region-project-item-region-item-selected",
|
|
6518
|
+
".components-search-content-search-select-search-select-selected"
|
|
6519
|
+
]
|
|
6520
|
+
}
|
|
6521
|
+
],
|
|
6522
|
+
hasPopup: [
|
|
6523
|
+
{
|
|
6524
|
+
selector: [
|
|
6525
|
+
".ti3-select-dominator-container",
|
|
6526
|
+
".selected-label",
|
|
6527
|
+
".sort-select",
|
|
6528
|
+
".service-select",
|
|
6529
|
+
".region-select",
|
|
6530
|
+
'[cf-uba="searchableRegion..open"]',
|
|
6531
|
+
'[cf-uba="serviceList..open"]',
|
|
6532
|
+
'[cf-uba="userinfo"]',
|
|
6533
|
+
"tp-helptip"
|
|
6534
|
+
]
|
|
6535
|
+
}
|
|
6536
|
+
],
|
|
6537
|
+
disabled: [{ selector: ".ti3-disabled" }],
|
|
6538
|
+
// Tiny3 / Lego 校验错误
|
|
6539
|
+
error: [{ selector: [".ti3-unifyvalid-error", ".ti3-error", ".ti-error", ".lego-text-error", ".lego-error"] }],
|
|
6540
|
+
// Tiny3 / Lego 警告
|
|
6541
|
+
warning: [{ selector: [".ti3-warning", ".ti-warning", ".lego-text-warning"] }],
|
|
6542
|
+
// 展开态:需结合计算样式,选择器表达不了「可见」
|
|
6543
|
+
expanded: [
|
|
6544
|
+
{
|
|
6545
|
+
match: (t) => {
|
|
6546
|
+
try {
|
|
6547
|
+
if (!t.matches(
|
|
6548
|
+
".modules-layout-module-sidebar-panel, .modules-searchable-region-region-panel, .ti3-dropdown-container"
|
|
6549
|
+
))
|
|
6550
|
+
return !1;
|
|
6551
|
+
const e = window.getComputedStyle(t);
|
|
6552
|
+
return e.display !== "none" && e.visibility !== "hidden" && e.opacity !== "0";
|
|
6553
|
+
} catch {
|
|
6554
|
+
return !1;
|
|
6555
|
+
}
|
|
6556
|
+
}
|
|
6557
|
+
}
|
|
6558
|
+
]
|
|
6559
|
+
},
|
|
6560
|
+
// exposedAttributes 输出属性 token;带 name 的 ti-icon/tp-icon 可交互性由 roles/whitelist 中 ti-icon[name] 等规则判定。
|
|
6561
|
+
exposedAttributes: ["cf-uba", "data-qa-id", "name"],
|
|
6562
|
+
whitelist: [
|
|
6563
|
+
".modules-service-list-menu-service-icon-container",
|
|
6564
|
+
".ti3-tabs-text",
|
|
6565
|
+
"tp-helptip",
|
|
6566
|
+
'[cf-uba="cloudShell"]',
|
|
6567
|
+
'[cf-uba="messageBox"]',
|
|
6568
|
+
'[cf-uba="helpFeedback"]',
|
|
6569
|
+
'[cf-uba="globalMessage"]',
|
|
6570
|
+
'[cf-uba="rightSidebar..hideBtn"]',
|
|
6571
|
+
// 帮助中心等区域的 ti-icon / tp-icon 图标按钮
|
|
6572
|
+
".ti-global-help-panel-header-icon",
|
|
6573
|
+
"ti-icon[name]",
|
|
6574
|
+
"tp-icon[name]",
|
|
6575
|
+
"tp-icon.common-icon",
|
|
6576
|
+
"ti-icon.common-icon",
|
|
6577
|
+
"ti-icon.ti3-icon-full-screen"
|
|
6578
|
+
],
|
|
6579
|
+
blacklist: [
|
|
6580
|
+
"noscript",
|
|
6581
|
+
"pan-gu",
|
|
6582
|
+
// 忽略 WebMCP 高亮容器
|
|
6583
|
+
"#webmcpcli-highlight-container",
|
|
6584
|
+
"#page-agent-runtime_simulator-mask",
|
|
6585
|
+
// CFUI 忽略几个大区域
|
|
6586
|
+
"#J_header",
|
|
6587
|
+
"#J_rightSidebar",
|
|
6588
|
+
"#cf_service_icon",
|
|
6589
|
+
"tp-helptip"
|
|
6590
|
+
]
|
|
6591
|
+
}
|
|
6592
|
+
};
|
|
6593
|
+
function isConsoleCloudHost(t = typeof location < "u" ? location.hostname : "") {
|
|
6594
|
+
return /(^|\.)console\.huaweicloud\.com$/i.test(t);
|
|
6063
6595
|
}
|
|
6064
6596
|
export {
|
|
6597
|
+
DEFAULT_PAGE_AGENT_TOOL_CONFIG as D,
|
|
6065
6598
|
Motion as M,
|
|
6599
|
+
PAGE_AGENT_TOOL_CALL_EVENT as P,
|
|
6066
6600
|
QrCode as Q,
|
|
6067
6601
|
getSkillMdContent as a,
|
|
6068
6602
|
getMainSkillPaths as b,
|
|
6069
6603
|
getMainSkillPathByName as c,
|
|
6070
6604
|
createSkillTools as d,
|
|
6071
|
-
|
|
6605
|
+
PAGE_AGENT_TOOL_RESULT_EVENT as e,
|
|
6072
6606
|
formatSkillsForSystemPrompt as f,
|
|
6073
6607
|
getSkillOverviews as g,
|
|
6608
|
+
getPageAgentToolConfig as h,
|
|
6609
|
+
consoleCloudPageAgentToolOptions as i,
|
|
6610
|
+
isConsoleCloudHost as j,
|
|
6611
|
+
DEFAULT_A11Y_CONFIG as k,
|
|
6612
|
+
defineA11yConfig as l,
|
|
6613
|
+
resolveA11yInfo as m,
|
|
6614
|
+
resolveA11yRole as n,
|
|
6615
|
+
resolveA11yStates as o,
|
|
6074
6616
|
parseSkillFrontMatter as p,
|
|
6075
|
-
|
|
6617
|
+
mergeA11yConfig as q,
|
|
6618
|
+
registerPageAgentTool as r,
|
|
6619
|
+
setPageAgentToolConfig as s,
|
|
6620
|
+
mergeA11yConfigs as t,
|
|
6621
|
+
ensureResolvedA11yConfig as u,
|
|
6622
|
+
isResolvedA11yConfig as v,
|
|
6623
|
+
extractSelectors as w,
|
|
6624
|
+
buildA11yTree as x,
|
|
6625
|
+
searchA11yTree as y,
|
|
6626
|
+
createRemoter as z
|
|
6076
6627
|
};
|