@swmansion/argent 0.34.1-next.32 → 0.34.1-next.33
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/cli-cmds.mjs +1 -1
- package/dist/installer.mjs +1 -1
- package/dist/mcp-server.mjs +11 -0
- package/dist/tool-args.generated.d.ts +1 -1
- package/dist/tool-server.cjs +2614 -373
- package/package.json +1 -1
- package/skills/argent-device-interact/SKILL.md +1 -1
- package/skills/argent-screenshot-diff/SKILL.md +1 -1
package/dist/tool-server.cjs
CHANGED
|
@@ -43155,7 +43155,7 @@ var require_view = __commonJS({
|
|
|
43155
43155
|
var dirname27 = path72.dirname;
|
|
43156
43156
|
var basename22 = path72.basename;
|
|
43157
43157
|
var extname7 = path72.extname;
|
|
43158
|
-
var
|
|
43158
|
+
var join76 = path72.join;
|
|
43159
43159
|
var resolve21 = path72.resolve;
|
|
43160
43160
|
module2.exports = View;
|
|
43161
43161
|
function View(name, options) {
|
|
@@ -43217,12 +43217,12 @@ var require_view = __commonJS({
|
|
|
43217
43217
|
};
|
|
43218
43218
|
View.prototype.resolve = function resolve22(dir, file2) {
|
|
43219
43219
|
var ext = this.ext;
|
|
43220
|
-
var path73 =
|
|
43220
|
+
var path73 = join76(dir, file2);
|
|
43221
43221
|
var stat12 = tryStat(path73);
|
|
43222
43222
|
if (stat12 && stat12.isFile()) {
|
|
43223
43223
|
return path73;
|
|
43224
43224
|
}
|
|
43225
|
-
path73 =
|
|
43225
|
+
path73 = join76(dir, basename22(file2, ext), "index" + ext);
|
|
43226
43226
|
stat12 = tryStat(path73);
|
|
43227
43227
|
if (stat12 && stat12.isFile()) {
|
|
43228
43228
|
return path73;
|
|
@@ -75677,7 +75677,7 @@ var require_send = __commonJS({
|
|
|
75677
75677
|
var Stream2 = require("stream");
|
|
75678
75678
|
var util = require("util");
|
|
75679
75679
|
var extname7 = path72.extname;
|
|
75680
|
-
var
|
|
75680
|
+
var join76 = path72.join;
|
|
75681
75681
|
var normalize = path72.normalize;
|
|
75682
75682
|
var resolve21 = path72.resolve;
|
|
75683
75683
|
var sep11 = path72.sep;
|
|
@@ -75849,7 +75849,7 @@ var require_send = __commonJS({
|
|
|
75849
75849
|
return res;
|
|
75850
75850
|
}
|
|
75851
75851
|
parts2 = path73.split(sep11);
|
|
75852
|
-
path73 = normalize(
|
|
75852
|
+
path73 = normalize(join76(root, path73));
|
|
75853
75853
|
} else {
|
|
75854
75854
|
if (UP_PATH_REGEXP.test(path73)) {
|
|
75855
75855
|
debug('malicious path "%s"', path73);
|
|
@@ -75982,7 +75982,7 @@ var require_send = __commonJS({
|
|
|
75982
75982
|
if (err) return self2.onStatError(err);
|
|
75983
75983
|
return self2.error(404);
|
|
75984
75984
|
}
|
|
75985
|
-
var p =
|
|
75985
|
+
var p = join76(path73, self2._index[i]);
|
|
75986
75986
|
debug('stat "%s"', p);
|
|
75987
75987
|
fs86.stat(p, function(err2, stat12) {
|
|
75988
75988
|
if (err2) return next(err2);
|
|
@@ -97884,7 +97884,7 @@ __export(index_exports, {
|
|
|
97884
97884
|
});
|
|
97885
97885
|
module.exports = __toCommonJS(index_exports);
|
|
97886
97886
|
var path71 = __toESM(require("node:path"));
|
|
97887
|
-
var
|
|
97887
|
+
var import_node_os19 = require("node:os");
|
|
97888
97888
|
init_src();
|
|
97889
97889
|
init_src2();
|
|
97890
97890
|
|
|
@@ -101440,7 +101440,7 @@ function isCi(env = process.env) {
|
|
|
101440
101440
|
var SESSION_ID = (0, import_node_crypto3.randomUUID)();
|
|
101441
101441
|
function readCliVersion() {
|
|
101442
101442
|
if (true) {
|
|
101443
|
-
return "0.34.1-next.
|
|
101443
|
+
return "0.34.1-next.33";
|
|
101444
101444
|
}
|
|
101445
101445
|
return "0.0.0";
|
|
101446
101446
|
}
|
|
@@ -105178,6 +105178,10 @@ var describeFrameSchema = external_exports.object({
|
|
|
105178
105178
|
width: external_exports.number().finite().min(0).max(1),
|
|
105179
105179
|
height: external_exports.number().finite().min(0).max(1)
|
|
105180
105180
|
});
|
|
105181
|
+
var describePointSchema = external_exports.object({
|
|
105182
|
+
x: external_exports.number().finite().min(0).max(1),
|
|
105183
|
+
y: external_exports.number().finite().min(0).max(1)
|
|
105184
|
+
});
|
|
105181
105185
|
var describeNodeSchema = external_exports.lazy(
|
|
105182
105186
|
() => external_exports.object({
|
|
105183
105187
|
role: external_exports.string().min(1),
|
|
@@ -105191,6 +105195,9 @@ var describeNodeSchema = external_exports.lazy(
|
|
|
105191
105195
|
clickable: external_exports.boolean().optional(),
|
|
105192
105196
|
longClickable: external_exports.boolean().optional(),
|
|
105193
105197
|
scrollable: external_exports.boolean().optional(),
|
|
105198
|
+
clipFrame: describeFrameSchema.optional(),
|
|
105199
|
+
clipBounds: describeFrameSchema.optional(),
|
|
105200
|
+
clipAnchors: external_exports.object({ x: describePointSchema.optional(), y: describePointSchema.optional() }).optional(),
|
|
105194
105201
|
checkable: external_exports.boolean().optional(),
|
|
105195
105202
|
checked: external_exports.boolean().optional(),
|
|
105196
105203
|
disabled: external_exports.boolean().optional(),
|
|
@@ -124359,6 +124366,8 @@ function postureForSize(size, panels) {
|
|
|
124359
124366
|
return panel.screenId === MAIN_SCREEN_ID ? "the cover panel (closed)" : "the inner panel (half-open or open)";
|
|
124360
124367
|
}
|
|
124361
124368
|
async function foldablePostureHint(udid, expected, actual) {
|
|
124369
|
+
const rotated = { width: actual.height, height: actual.width };
|
|
124370
|
+
if (sameAspect(expected, actual) || sameAspect(expected, rotated)) return void 0;
|
|
124362
124371
|
const foldable = await isFoldableSimulator(udid).catch((err) => {
|
|
124363
124372
|
if (err instanceof XcodeFirstLaunchPendingError) return false;
|
|
124364
124373
|
throw err;
|
|
@@ -129365,8 +129374,17 @@ async function readViewport(cdp) {
|
|
|
129365
129374
|
// ../tool-server/src/chromium-server/index.ts
|
|
129366
129375
|
async function createChromiumServer(opts) {
|
|
129367
129376
|
const { cdp, wsUrl, target } = await connectCdp(opts.port);
|
|
129368
|
-
|
|
129369
|
-
|
|
129377
|
+
let viewport;
|
|
129378
|
+
try {
|
|
129379
|
+
if (opts.answerTimeoutMs !== void 0) {
|
|
129380
|
+
await cdp.send("Runtime.evaluate", { expression: "0" }, opts.answerTimeoutMs);
|
|
129381
|
+
}
|
|
129382
|
+
await primePageSession(cdp);
|
|
129383
|
+
viewport = await readViewport(cdp);
|
|
129384
|
+
} catch (err) {
|
|
129385
|
+
await cdp.disconnect();
|
|
129386
|
+
throw err;
|
|
129387
|
+
}
|
|
129370
129388
|
const events = new TypedEventEmitter();
|
|
129371
129389
|
const fps = new FpsTracker(events);
|
|
129372
129390
|
const screencast = new ScreencastManager(cdp, events, fps);
|
|
@@ -129502,7 +129520,11 @@ var chromiumCdpBlueprint = {
|
|
|
129502
129520
|
}
|
|
129503
129521
|
);
|
|
129504
129522
|
}
|
|
129505
|
-
const server = await createChromiumServer({
|
|
129523
|
+
const server = await createChromiumServer({
|
|
129524
|
+
deviceId: device.id,
|
|
129525
|
+
port,
|
|
129526
|
+
answerTimeoutMs: opts?.answerTimeoutMs
|
|
129527
|
+
});
|
|
129506
129528
|
const rootDomNodeId = await getDocumentNodeId(server.cdp);
|
|
129507
129529
|
const events = new TypedEventEmitter();
|
|
129508
129530
|
server.events.on("terminated", (err) => {
|
|
@@ -136935,6 +136957,24 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
136935
136957
|
const h = window.innerHeight;
|
|
136936
136958
|
if (!w || !h) return JSON.stringify({ tree: null, error: "viewport is zero" });
|
|
136937
136959
|
|
|
136960
|
+
// A page script's global named after a DOM interface (\`function Node\`, \`var Element =
|
|
136961
|
+
// 5\`, a top-level \`class HTMLElement\`) is in scope here, so these shadow it with the
|
|
136962
|
+
// builtins, taken from elements the document makes: no page binding replaces document.
|
|
136963
|
+
let docProto = Object.getPrototypeOf(document);
|
|
136964
|
+
while (!Object.getOwnPropertyDescriptor(docProto, "createElementNS")) {
|
|
136965
|
+
docProto = Object.getPrototypeOf(docProto);
|
|
136966
|
+
}
|
|
136967
|
+
const made = (ns, tag) =>
|
|
136968
|
+
Object.getPrototypeOf(docProto.createElementNS.call(document, ns, tag)).constructor;
|
|
136969
|
+
const HTMLInputElement = made("http://www.w3.org/1999/xhtml", "input");
|
|
136970
|
+
const HTMLTextAreaElement = made("http://www.w3.org/1999/xhtml", "textarea");
|
|
136971
|
+
const HTMLImageElement = made("http://www.w3.org/1999/xhtml", "img");
|
|
136972
|
+
const SVGSVGElement = made("http://www.w3.org/2000/svg", "svg");
|
|
136973
|
+
const HTMLSlotElement = made("http://www.w3.org/1999/xhtml", "slot");
|
|
136974
|
+
const HTMLElement = Object.getPrototypeOf(HTMLInputElement);
|
|
136975
|
+
const Element = Object.getPrototypeOf(HTMLElement);
|
|
136976
|
+
const Node = Object.getPrototypeOf(Element);
|
|
136977
|
+
|
|
136938
136978
|
// Native prototype accessors, captured once. HTMLFormElement (and HTMLObject/Embed)
|
|
136939
136979
|
// is [LegacyOverrideBuiltins]: a control named the same as an inherited member shadows
|
|
136940
136980
|
// it on the <form>, so el.children returns the control element (not iterable) and
|
|
@@ -136956,24 +136996,47 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
136956
136996
|
const getNodeValue = protoGetter(Node.prototype, "nodeValue");
|
|
136957
136997
|
const getTextContent = protoGetter(Node.prototype, "textContent");
|
|
136958
136998
|
const getTagName = protoGetter(Element.prototype, "tagName");
|
|
136999
|
+
const getLocalName = protoGetter(Element.prototype, "localName");
|
|
137000
|
+
const getNamespaceURI = protoGetter(Element.prototype, "namespaceURI");
|
|
136959
137001
|
const getChildrenEls = protoGetter(Element.prototype, "children");
|
|
136960
137002
|
const getShadowRoot = protoGetter(Element.prototype, "shadowRoot");
|
|
137003
|
+
const getAssignedSlot = protoGetter(Element.prototype, "assignedSlot");
|
|
137004
|
+
const getParentNode = protoGetter(Node.prototype, "parentNode");
|
|
137005
|
+
const getPreviousSibling = protoGetter(Node.prototype, "previousSibling");
|
|
136961
137006
|
const getScrollHeight = protoGetter(Element.prototype, "scrollHeight");
|
|
136962
137007
|
const getClientHeight = protoGetter(Element.prototype, "clientHeight");
|
|
136963
137008
|
const getScrollWidth = protoGetter(Element.prototype, "scrollWidth");
|
|
137009
|
+
const getScrollLeft = protoGetter(Element.prototype, "scrollLeft");
|
|
137010
|
+
const getScrollTop = protoGetter(Element.prototype, "scrollTop");
|
|
136964
137011
|
const getClientWidth = protoGetter(Element.prototype, "clientWidth");
|
|
137012
|
+
const getClientLeft = protoGetter(Element.prototype, "clientLeft");
|
|
137013
|
+
const getClientTop = protoGetter(Element.prototype, "clientTop");
|
|
137014
|
+
const getOffsetWidth = protoGetter(HTMLElement.prototype, "offsetWidth");
|
|
137015
|
+
const getOffsetHeight = protoGetter(HTMLElement.prototype, "offsetHeight");
|
|
137016
|
+
const getOffsetLeft = protoGetter(HTMLElement.prototype, "offsetLeft");
|
|
137017
|
+
const getOffsetTop = protoGetter(HTMLElement.prototype, "offsetTop");
|
|
137018
|
+
const getOffsetParent = protoGetter(HTMLElement.prototype, "offsetParent");
|
|
136965
137019
|
const getAttr = Element.prototype.getAttribute;
|
|
136966
137020
|
const hasAttr = Element.prototype.hasAttribute;
|
|
136967
137021
|
const getBCR = Element.prototype.getBoundingClientRect;
|
|
137022
|
+
const matchesSel = Element.prototype.matches;
|
|
136968
137023
|
// Document's named getter is [LegacyOverrideBuiltIns] (like a form's): a
|
|
136969
137024
|
// <form name="activeElement"> shadows document.activeElement, so both focus
|
|
136970
|
-
// reads go through prototype accessors.
|
|
136971
|
-
// harness's mock DOM, which defines no Document constructor \u2014 protoGetter's
|
|
136972
|
-
// direct-read fallback then degrades focus reporting instead of throwing.
|
|
136973
|
-
const docProto = typeof Document === "undefined" ? {} : Document.prototype;
|
|
137025
|
+
// reads go through prototype accessors.
|
|
136974
137026
|
const getOwnerDocument = protoGetter(Node.prototype, "ownerDocument");
|
|
136975
137027
|
const getActiveElement = protoGetter(docProto, "activeElement");
|
|
136976
137028
|
const getDocBody = protoGetter(docProto, "body");
|
|
137029
|
+
const getRootNode = Node.prototype.getRootNode;
|
|
137030
|
+
const nodeContains = Node.prototype.contains;
|
|
137031
|
+
const docElementsFromPoint = docProto.elementsFromPoint;
|
|
137032
|
+
const docGetElementById = docProto.getElementById;
|
|
137033
|
+
const slotAssignedNodes = HTMLSlotElement.prototype.assignedNodes;
|
|
137034
|
+
// A document's named getter can shadow elementsFromPoint; a shadow root has none.
|
|
137035
|
+
function elementsAt(root, x, y) {
|
|
137036
|
+
return getNodeType.call(root) === 9
|
|
137037
|
+
? docElementsFromPoint.call(root, x, y)
|
|
137038
|
+
: root.elementsFromPoint(x, y);
|
|
137039
|
+
}
|
|
136977
137040
|
|
|
136978
137041
|
function nodeRole(el) {
|
|
136979
137042
|
const r = getAttr.call(el, "role");
|
|
@@ -136982,39 +137045,88 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
136982
137045
|
return t;
|
|
136983
137046
|
}
|
|
136984
137047
|
|
|
137048
|
+
// Per document or shadow root, aria-labelledby id -> its target and, once read, its
|
|
137049
|
+
// trimmed text for controls that read it alike; null for a missing id.
|
|
137050
|
+
const labelTargets = nodeMap();
|
|
137051
|
+
const NAME_MAX = 200;
|
|
137052
|
+
|
|
137053
|
+
// A blank aria-labelledby name or aria-label falls through to the next source.
|
|
136985
137054
|
function accessibleName(el) {
|
|
136986
|
-
const aria = getAttr.call(el, "aria-label");
|
|
136987
|
-
if (aria) return aria.trim().slice(0, 200);
|
|
136988
137055
|
const labelledBy = getAttr.call(el, "aria-labelledby");
|
|
136989
137056
|
if (labelledBy) {
|
|
137057
|
+
// Its ids name elements in el's own tree. A document's named getter can shadow
|
|
137058
|
+
// getElementById; a shadow root has none.
|
|
137059
|
+
const root = getRootNode.call(el);
|
|
137060
|
+
let targets = labelTargets.get(root);
|
|
137061
|
+
if (!targets) labelTargets.set(root, (targets = Object.create(null)));
|
|
136990
137062
|
const ids = labelledBy.split(/\\s+/);
|
|
136991
137063
|
const parts = [];
|
|
136992
137064
|
for (const id of ids) {
|
|
136993
|
-
|
|
136994
|
-
|
|
136995
|
-
|
|
136996
|
-
|
|
136997
|
-
|
|
137065
|
+
let target = targets[id];
|
|
137066
|
+
if (target === undefined) {
|
|
137067
|
+
const ref =
|
|
137068
|
+
getNodeType.call(root) === 9
|
|
137069
|
+
? docGetElementById.call(root, id)
|
|
137070
|
+
: root.getElementById(id);
|
|
137071
|
+
target = targets[id] = ref ? { ref, text: null } : null;
|
|
137072
|
+
}
|
|
137073
|
+
if (!target) continue;
|
|
137074
|
+
let text;
|
|
137075
|
+
if (readsAsSelf(el, target.ref)) text = labelText(target.ref, el).trim();
|
|
137076
|
+
else {
|
|
137077
|
+
if (target.text === null) target.text = labelText(target.ref, null).trim();
|
|
137078
|
+
text = target.text;
|
|
137079
|
+
}
|
|
137080
|
+
if (text) parts.push(text);
|
|
136998
137081
|
}
|
|
136999
|
-
|
|
137082
|
+
const name = parts.join(" ");
|
|
137083
|
+
if (name) return name.slice(0, NAME_MAX);
|
|
137000
137084
|
}
|
|
137085
|
+
const aria = (getAttr.call(el, "aria-label") || "").trim();
|
|
137086
|
+
if (aria) return aria.slice(0, NAME_MAX);
|
|
137001
137087
|
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
|
|
137002
|
-
if (el.placeholder) return el.placeholder.slice(0,
|
|
137088
|
+
if (el.placeholder) return el.placeholder.slice(0, NAME_MAX);
|
|
137089
|
+
// Chrome never names a text field by its value; describe does, so a filled one reads.
|
|
137003
137090
|
// Never fall through to a password input's value: with no aria label or
|
|
137004
137091
|
// placeholder (a floating/uncontrolled-label pattern) the typed secret
|
|
137005
137092
|
// would become the node's label and reach every describe consumer.
|
|
137006
|
-
if (el.value && !isPassword(el)) return el.value.slice(0,
|
|
137093
|
+
if (el.value && !isPassword(el)) return el.value.slice(0, NAME_MAX);
|
|
137007
137094
|
}
|
|
137008
|
-
if (el instanceof HTMLImageElement && el.alt) return el.alt.slice(0,
|
|
137095
|
+
if (el instanceof HTMLImageElement && el.alt) return el.alt.slice(0, NAME_MAX);
|
|
137009
137096
|
// getAttribute, not el.title: a <form> with a control named "title" clobbers the
|
|
137010
137097
|
// .title property to return that element (not a string), and .slice() then throws,
|
|
137011
137098
|
// aborting the whole describe. getAttribute always yields string | null.
|
|
137012
137099
|
const t = getAttr.call(el, "title");
|
|
137013
|
-
if (t) return t.slice(0,
|
|
137100
|
+
if (t) return t.slice(0, NAME_MAX);
|
|
137014
137101
|
return null;
|
|
137015
137102
|
}
|
|
137016
137103
|
|
|
137017
|
-
|
|
137104
|
+
// A <br> separates the words around it unless it is display:none (what a
|
|
137105
|
+
// display:contents <br> computes to), which leaves them joined on screen.
|
|
137106
|
+
// The nodeType check comes first: the Element getters throw on a Comment. An SVG
|
|
137107
|
+
// br or a createElementNS "BR" fails the name/namespace check and renders inline.
|
|
137108
|
+
function isRenderedBr(node) {
|
|
137109
|
+
return (
|
|
137110
|
+
getNodeType.call(node) === 1 &&
|
|
137111
|
+
getLocalName.call(node) === "br" &&
|
|
137112
|
+
getNamespaceURI.call(node) === "http://www.w3.org/1999/xhtml" &&
|
|
137113
|
+
window.getComputedStyle(node).display !== "none"
|
|
137114
|
+
);
|
|
137115
|
+
}
|
|
137116
|
+
|
|
137117
|
+
// Whether an element is a non-atomic inline box, whose words Chromium runs on into its
|
|
137118
|
+
// neighbours' and whose overflow and transforms it ignores.
|
|
137119
|
+
function isInlineBox(style) {
|
|
137120
|
+
return /^(inline|ruby|ruby-text|inline list-item)$/.test(style.display);
|
|
137121
|
+
}
|
|
137122
|
+
|
|
137123
|
+
// JS \\s, minus U+FEFF: a zero-width no-break space must not collapse to a visible one.
|
|
137124
|
+
const WHITESPACE = /[^\\S\\uFEFF]+/g;
|
|
137125
|
+
|
|
137126
|
+
// An element's text children in the case its style's text-transform lays them out in,
|
|
137127
|
+
// and a rendered <br> as a space. Not in a ::first-letter's case: finding the block whose
|
|
137128
|
+
// first letter a text holds would cost every text a climb through its ancestors' styles.
|
|
137129
|
+
function ownText(el, style) {
|
|
137018
137130
|
let s = "";
|
|
137019
137131
|
for (const child of getChildNodes.call(el)) {
|
|
137020
137132
|
// nodeType/nodeValue via the prototype getters, keeping the "every inherited
|
|
@@ -137022,9 +137134,854 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
137022
137134
|
// clobbering <form> whose named control shadows these to a control element.
|
|
137023
137135
|
// (=== 3 already made a clobbered nodeType safe; this removes the lone
|
|
137024
137136
|
// directly-read member so no read's safety rests on the comparison semantics.)
|
|
137025
|
-
if (getNodeType.call(child) === 3)
|
|
137137
|
+
if (getNodeType.call(child) === 3) {
|
|
137138
|
+
s += caseText(getNodeValue.call(child), style, () => laidBefore(child));
|
|
137139
|
+
} else if (isRenderedBr(child)) s += " ";
|
|
137140
|
+
}
|
|
137141
|
+
return s.replace(WHITESPACE, " ").trim();
|
|
137142
|
+
}
|
|
137143
|
+
|
|
137144
|
+
// Chrome hides for any aria-hidden value but "false" and "undefined", in any ASCII case.
|
|
137145
|
+
function isAriaHidden(el) {
|
|
137146
|
+
const v = getAttr.call(el, "aria-hidden");
|
|
137147
|
+
return !!v && !/^(false|undefined)$/i.test(v);
|
|
137148
|
+
}
|
|
137149
|
+
|
|
137150
|
+
// A node's children in the flat tree: an open shadow root's in place of the host's,
|
|
137151
|
+
// and a <slot>'s assigned nodes, else its fallback content.
|
|
137152
|
+
function flatChildNodes(node) {
|
|
137153
|
+
if (getNodeType.call(node) === 1) {
|
|
137154
|
+
const shadow = getShadowRoot.call(node);
|
|
137155
|
+
if (shadow) return getChildNodes.call(shadow);
|
|
137156
|
+
if (isSlot(node)) {
|
|
137157
|
+
const assigned = slotAssignedNodes.call(node);
|
|
137158
|
+
if (assigned.length) return assigned;
|
|
137159
|
+
}
|
|
137160
|
+
}
|
|
137161
|
+
return getChildNodes.call(node);
|
|
137162
|
+
}
|
|
137163
|
+
|
|
137164
|
+
// An element's element children in the flat tree, but a closed root's host gives its
|
|
137165
|
+
// light children.
|
|
137166
|
+
function flatChildElements(el) {
|
|
137167
|
+
const shadow = getShadowRoot.call(el);
|
|
137168
|
+
if (shadow) return shadow.children;
|
|
137169
|
+
const assigned = isSlot(el) ? slotAssignedNodes.call(el) : [];
|
|
137170
|
+
return assigned.length
|
|
137171
|
+
? assigned.filter((n) => getNodeType.call(n) === 1)
|
|
137172
|
+
: getChildrenEls.call(el);
|
|
137173
|
+
}
|
|
137174
|
+
|
|
137175
|
+
function isSlot(el) {
|
|
137176
|
+
return (
|
|
137177
|
+
getLocalName.call(el) === "slot" && getNamespaceURI.call(el) === "http://www.w3.org/1999/xhtml"
|
|
137178
|
+
);
|
|
137179
|
+
}
|
|
137180
|
+
|
|
137181
|
+
// An aria-labelledby target's text (text and CDATA) in the flat tree, read by a subset
|
|
137182
|
+
// of Chrome's accessible-name rules. A text field reads as its value, uncased (a
|
|
137183
|
+
// password's as bullets), else its aria-label, title or placeholder. Another element
|
|
137184
|
+
// reads as what a <select> shows, a range widget's value (a range input's too) or a
|
|
137185
|
+
// listbox's aria-selected options; else as its aria-label, an <img>'s or image input's
|
|
137186
|
+
// alt, an SVG element's <title> or a button input's value; else as its ::before, content
|
|
137187
|
+
// and ::after, or as its title if those are blank (not an <img> with an alt). A
|
|
137188
|
+
// non-inline element, an <img> (but a presentational alt=""), an <svg> with content, an
|
|
137189
|
+
// SVG <style> or a <br> parts the words around it, and an SVG <style>'s text never
|
|
137190
|
+
// counts. Nor does the text of a <noscript>, or of a <script> or <style> with no box,
|
|
137191
|
+
// which parts words only under display:none. A shown target leaves out its display:none,
|
|
137192
|
+
// visibility:hidden or collapse, aria-hidden and inert subtrees, and SVG elements SVG
|
|
137193
|
+
// never renders (one it does not know, <metadata>, <script>); a hidden one reads them
|
|
137194
|
+
// all, and there any <svg> parts words, as does every element under display:none, which
|
|
137195
|
+
// has no layout to run inline in. Neither reads what layout skips: a closed <details>
|
|
137196
|
+
// past its first <summary>, a rendered <progress> or <meter>'s content, a
|
|
137197
|
+
// content-visibility:hidden box's content, a hidden chosen option, or a hidden ::before
|
|
137198
|
+
// or ::after (or any in an aria-hidden target). Laid-out text and ::before/::after
|
|
137199
|
+
// strings take their text-transform case, and a block container's first letter its
|
|
137200
|
+
// ::first-letter's. In its own target, the control being named (self) is no embedded
|
|
137201
|
+
// control and reads as selfText says.
|
|
137202
|
+
// Iterative: the target's depth has no MAX_DEPTH bound. The walk stops once more than
|
|
137203
|
+
// NAME_MAX non-whitespace characters are in, which settles the name accessibleName cuts.
|
|
137204
|
+
function labelText(root, self) {
|
|
137205
|
+
const rootStyle = window.getComputedStyle(root);
|
|
137206
|
+
let shown = rootStyle.visibility === "visible";
|
|
137207
|
+
let ariaHidden = false;
|
|
137208
|
+
let inert = false;
|
|
137209
|
+
// How many display:none elements enclose the walk's position.
|
|
137210
|
+
let unrendered = 0;
|
|
137211
|
+
for (let n = root; !unrendered && n && getNodeType.call(n) === 1; n = getParentNode.call(n)) {
|
|
137212
|
+
if (isInert(n)) inert = true;
|
|
137213
|
+
if (window.getComputedStyle(n).display === "none") {
|
|
137214
|
+
unrendered = 1;
|
|
137215
|
+
shown = false;
|
|
137216
|
+
} else if (isAriaHidden(n)) {
|
|
137217
|
+
shown = false;
|
|
137218
|
+
ariaHidden = true;
|
|
137219
|
+
}
|
|
137220
|
+
}
|
|
137221
|
+
const rootOptions = chosenOptions(root);
|
|
137222
|
+
const own = root === self ? selfText(root, true) : shownText(root, !unrendered, rootOptions);
|
|
137223
|
+
if (own !== null) return own;
|
|
137224
|
+
if (shown && inert) return "";
|
|
137225
|
+
let s = "";
|
|
137226
|
+
// Characters read into s that trim() keeps; a lower bound, as s only gains them.
|
|
137227
|
+
let seen = 0;
|
|
137228
|
+
const read = (text) => {
|
|
137229
|
+
s += text;
|
|
137230
|
+
seen += text.replace(/\\s/g, "").length;
|
|
137231
|
+
};
|
|
137232
|
+
// The laid-out style whose text-transform cases the text nodes being read, or null.
|
|
137233
|
+
let textCase = null;
|
|
137234
|
+
// Whether the element whose children are read is an inline box.
|
|
137235
|
+
let inInline = false;
|
|
137236
|
+
// The last laid-out character, which capitalize's first word depends on. As in Blink,
|
|
137237
|
+
// layout reads back through inline flow, and anything else is a space: the start of a
|
|
137238
|
+
// box that is not inline flow, a replaced element, and the end of a block-level box
|
|
137239
|
+
// in a block container (an anonymous block follows it). null until something is laid
|
|
137240
|
+
// out in an inline-flow root, whose first character runs on from what precedes it.
|
|
137241
|
+
let laid = isFlow(root, rootStyle) ? null : " ";
|
|
137242
|
+
const prevLaid = () => (laid === null ? (laid = laidBefore(root)) : laid);
|
|
137243
|
+
const lay = (text) => {
|
|
137244
|
+
if (text) laid = lastChar(text);
|
|
137245
|
+
};
|
|
137246
|
+
// The block containers, outermost first, whose ::first-letter is the next letter laid
|
|
137247
|
+
// out, or null. OUTSIDE stands for those of the root's ancestors, found when needed.
|
|
137248
|
+
const rootBox = unrendered ? 0 : letterBox(root, rootStyle);
|
|
137249
|
+
let letters = unrendered
|
|
137250
|
+
? null
|
|
137251
|
+
: isFlow(root, rootStyle)
|
|
137252
|
+
? [OUTSIDE]
|
|
137253
|
+
: rootBox === 1
|
|
137254
|
+
? [OUTSIDE, root]
|
|
137255
|
+
: rootBox
|
|
137256
|
+
? [root]
|
|
137257
|
+
: null;
|
|
137258
|
+
// Laid-out text in a style's case, its first letter in its ::first-letter's if it holds
|
|
137259
|
+
// the pending one.
|
|
137260
|
+
const caseLaid = (text, style) => {
|
|
137261
|
+
if (!letters || !/\\S/.test(text)) return caseText(text, style, prevLaid);
|
|
137262
|
+
const blocks = letters;
|
|
137263
|
+
letters = null;
|
|
137264
|
+
let letter = null;
|
|
137265
|
+
for (let i = blocks.length - 1; !letter && i >= 0; i--) {
|
|
137266
|
+
if (blocks[i] !== OUTSIDE) letter = firstLetterStyle(blocks[i]);
|
|
137267
|
+
else for (const block of openLetters(root)) if (!letter) letter = firstLetterStyle(block);
|
|
137268
|
+
}
|
|
137269
|
+
const m = letter && FIRST_LETTER.exec(text);
|
|
137270
|
+
if (!m) return caseText(text, style, prevLaid);
|
|
137271
|
+
// Only whitespace is laid out before a first letter.
|
|
137272
|
+
const head = caseText(m[0], letter, () => " ");
|
|
137273
|
+
return head + caseText(text.slice(m[0].length), style, () => lastChar(head));
|
|
137274
|
+
};
|
|
137275
|
+
// Takes what an element lays out: its last character, and an end to a pending first
|
|
137276
|
+
// letter.
|
|
137277
|
+
const layOut = (el) => {
|
|
137278
|
+
const end = lastLaid(el, inInline);
|
|
137279
|
+
if (end !== null) {
|
|
137280
|
+
laid = end;
|
|
137281
|
+
letters = null;
|
|
137282
|
+
}
|
|
137283
|
+
};
|
|
137284
|
+
// A ::before or ::after: its name read, and its strings laid out in its case.
|
|
137285
|
+
const readPseudo = (pseudo, parentStyle) => {
|
|
137286
|
+
if (!pseudo.inline) {
|
|
137287
|
+
laid = " ";
|
|
137288
|
+
letters = null;
|
|
137289
|
+
}
|
|
137290
|
+
const strings = caseLaid(pseudo.strings, pseudo.style);
|
|
137291
|
+
read(pseudo.alt === null ? strings : pseudo.alt);
|
|
137292
|
+
lay(strings);
|
|
137293
|
+
if (pseudo.block && !isInlineBox(parentStyle)) laid = " ";
|
|
137294
|
+
};
|
|
137295
|
+
// Nodes, SPACE where a non-inline element's content ends (BLOCK where a block-level
|
|
137296
|
+
// one's ends in a block container), RENDERED where a display:none element's does, and
|
|
137297
|
+
// functions that finish an element's text.
|
|
137298
|
+
const SPACE = {};
|
|
137299
|
+
const BLOCK = {};
|
|
137300
|
+
const RENDERED = {};
|
|
137301
|
+
const stack = [];
|
|
137302
|
+
// A listbox's chosen options, each read only when it is laid out and shown.
|
|
137303
|
+
const pushOptions = (options, rendered) => {
|
|
137304
|
+
for (let i = options.length - 1; i >= 0; i--) {
|
|
137305
|
+
const style = window.getComputedStyle(options[i]);
|
|
137306
|
+
if (rendered && style.display !== "none" && style.visibility === "visible") {
|
|
137307
|
+
if (!isAriaHidden(options[i])) stack.push(SPACE, options[i]);
|
|
137308
|
+
}
|
|
137309
|
+
}
|
|
137310
|
+
};
|
|
137311
|
+
// An element's ::before, shown children and ::after, or its title if those are blank;
|
|
137312
|
+
// only the title when empty.
|
|
137313
|
+
const pushContent = (el, style, rendered, empty) => {
|
|
137314
|
+
const html = getNamespaceURI.call(el) === "http://www.w3.org/1999/xhtml";
|
|
137315
|
+
const tag = getLocalName.call(el);
|
|
137316
|
+
const title = getAttr.call(el, "title");
|
|
137317
|
+
const start = s.length;
|
|
137318
|
+
if (title && !(html && tag === "img" && hasAttr.call(el, "alt"))) {
|
|
137319
|
+
stack.push(() => {
|
|
137320
|
+
if (!s.slice(start).replace(WHITESPACE, "")) {
|
|
137321
|
+
s = s.slice(0, start) + " " + title + " ";
|
|
137322
|
+
}
|
|
137323
|
+
});
|
|
137324
|
+
}
|
|
137325
|
+
if (
|
|
137326
|
+
empty ||
|
|
137327
|
+
(rendered && html && /^(progress|meter)$/.test(tag)) ||
|
|
137328
|
+
(rendered &&
|
|
137329
|
+
style.contentVisibility === "hidden" &&
|
|
137330
|
+
!isInlineBox(style) &&
|
|
137331
|
+
style.display !== "contents")
|
|
137332
|
+
) {
|
|
137333
|
+
return;
|
|
137334
|
+
}
|
|
137335
|
+
if (rendered && !ariaHidden && html && !REPLACED.test(tag)) {
|
|
137336
|
+
const before = pseudoText(el, "::before");
|
|
137337
|
+
if (before) readPseudo(before, style);
|
|
137338
|
+
const from = s.length;
|
|
137339
|
+
// A spaced pseudo-element is parted only from the element's other text, and a
|
|
137340
|
+
// block-level one also from what follows the element.
|
|
137341
|
+
stack.push(() => {
|
|
137342
|
+
const after = pseudoText(el, "::after");
|
|
137343
|
+
const filled = !!s.slice(from).replace(WHITESPACE, "");
|
|
137344
|
+
if (before && before.spaced && (filled || after)) {
|
|
137345
|
+
s = s.slice(0, from) + " " + s.slice(from);
|
|
137346
|
+
}
|
|
137347
|
+
if (after) {
|
|
137348
|
+
if (after.spaced && (filled || before)) s += " ";
|
|
137349
|
+
readPseudo(after, style);
|
|
137350
|
+
}
|
|
137351
|
+
if ((before && before.block) || (after && after.block)) s += " ";
|
|
137352
|
+
});
|
|
137353
|
+
}
|
|
137354
|
+
if (rendered && html && tag === "details" && closedDetails(el)) {
|
|
137355
|
+
for (const child of getChildNodes.call(el)) {
|
|
137356
|
+
if (
|
|
137357
|
+
getNodeType.call(child) === 1 &&
|
|
137358
|
+
getLocalName.call(child) === "summary" &&
|
|
137359
|
+
getNamespaceURI.call(child) === "http://www.w3.org/1999/xhtml"
|
|
137360
|
+
) {
|
|
137361
|
+
stack.push(child);
|
|
137362
|
+
break;
|
|
137363
|
+
}
|
|
137364
|
+
}
|
|
137365
|
+
} else {
|
|
137366
|
+
const kids = flatChildNodes(el);
|
|
137367
|
+
// Layout cases text; display:none content reads as authored.
|
|
137368
|
+
const kidsCase = rendered && CASED.test(style.textTransform) ? style : null;
|
|
137369
|
+
const kidsInline = style.display === "contents" ? inInline : isInlineBox(style);
|
|
137370
|
+
if (kidsCase !== textCase || kidsInline !== inInline) {
|
|
137371
|
+
const outerCase = textCase;
|
|
137372
|
+
const outerInline = inInline;
|
|
137373
|
+
stack.push(() => {
|
|
137374
|
+
textCase = outerCase;
|
|
137375
|
+
inInline = outerInline;
|
|
137376
|
+
});
|
|
137377
|
+
textCase = kidsCase;
|
|
137378
|
+
inInline = kidsInline;
|
|
137379
|
+
}
|
|
137380
|
+
for (let i = kids.length - 1; i >= 0; i--) stack.push(kids[i]);
|
|
137381
|
+
}
|
|
137382
|
+
};
|
|
137383
|
+
if (rootOptions) pushOptions(rootOptions, !unrendered);
|
|
137384
|
+
else pushContent(root, rootStyle, !unrendered, false);
|
|
137385
|
+
while (stack.length) {
|
|
137386
|
+
const node = stack.pop();
|
|
137387
|
+
if (typeof node === "function") {
|
|
137388
|
+
node();
|
|
137389
|
+
continue;
|
|
137390
|
+
}
|
|
137391
|
+
// Past the cap only the open elements' functions, which can insert a space, still
|
|
137392
|
+
// change the cut name.
|
|
137393
|
+
if (seen > NAME_MAX) continue;
|
|
137394
|
+
if (node === SPACE || node === BLOCK) {
|
|
137395
|
+
s += " ";
|
|
137396
|
+
if (node === BLOCK) laid = " ";
|
|
137397
|
+
continue;
|
|
137398
|
+
}
|
|
137399
|
+
if (node === RENDERED) {
|
|
137400
|
+
unrendered--;
|
|
137401
|
+
continue;
|
|
137402
|
+
}
|
|
137403
|
+
const type = getNodeType.call(node);
|
|
137404
|
+
if (type === 3 || type === 4) {
|
|
137405
|
+
const value = getNodeValue.call(node);
|
|
137406
|
+
const text = unrendered ? value : caseLaid(value, textCase);
|
|
137407
|
+
read(text);
|
|
137408
|
+
lay(text);
|
|
137409
|
+
continue;
|
|
137410
|
+
}
|
|
137411
|
+
if (type !== 1) continue;
|
|
137412
|
+
const style = window.getComputedStyle(node);
|
|
137413
|
+
const ns = getNamespaceURI.call(node);
|
|
137414
|
+
const tag = getLocalName.call(node);
|
|
137415
|
+
const svg = ns === "http://www.w3.org/2000/svg";
|
|
137416
|
+
if (
|
|
137417
|
+
shown &&
|
|
137418
|
+
(style.display === "none" ||
|
|
137419
|
+
(svg &&
|
|
137420
|
+
(tag === "metadata" ||
|
|
137421
|
+
tag === "script" ||
|
|
137422
|
+
Object.prototype.toString.call(node) === "[object SVGElement]")))
|
|
137423
|
+
) {
|
|
137424
|
+
continue;
|
|
137425
|
+
}
|
|
137426
|
+
if (shown && (style.visibility !== "visible" || isAriaHidden(node) || isInert(node))) {
|
|
137427
|
+
// Laid out but not read: an in-flow block-level box still parts the words around it.
|
|
137428
|
+
if (
|
|
137429
|
+
isBlockLevel(style) &&
|
|
137430
|
+
style.cssFloat === "none" &&
|
|
137431
|
+
!/^(absolute|fixed)$/.test(style.position)
|
|
137432
|
+
) {
|
|
137433
|
+
s += " ";
|
|
137434
|
+
}
|
|
137435
|
+
layOut(node);
|
|
137436
|
+
continue;
|
|
137437
|
+
}
|
|
137438
|
+
if (isRenderedBr(node)) {
|
|
137439
|
+
s += " ";
|
|
137440
|
+
laid = " ";
|
|
137441
|
+
if (!unrendered) letters = null;
|
|
137442
|
+
continue;
|
|
137443
|
+
}
|
|
137444
|
+
const rendered = !unrendered && style.display !== "none";
|
|
137445
|
+
const flow = isFlow(node, style);
|
|
137446
|
+
const blockEnd = isBlockLevel(style) && !inInline;
|
|
137447
|
+
if (!flow) laid = " ";
|
|
137448
|
+
if (!flow && rendered) {
|
|
137449
|
+
const box = letterBox(node, style);
|
|
137450
|
+
if (box === 1 && letters) letters.push(node);
|
|
137451
|
+
else letters = box ? [node] : null;
|
|
137452
|
+
}
|
|
137453
|
+
const options = chosenOptions(node);
|
|
137454
|
+
const content = node === self ? selfText(node, false) : shownText(node, rendered, options);
|
|
137455
|
+
if (content !== null) {
|
|
137456
|
+
read(" " + content + " ");
|
|
137457
|
+
if (rendered) layOut(node);
|
|
137458
|
+
continue;
|
|
137459
|
+
}
|
|
137460
|
+
if (options) {
|
|
137461
|
+
s += " ";
|
|
137462
|
+
stack.push(SPACE);
|
|
137463
|
+
pushOptions(options, rendered);
|
|
137464
|
+
continue;
|
|
137465
|
+
}
|
|
137466
|
+
// A shown <svg> holding at most whitespace reads as nothing: SVG drops that text.
|
|
137467
|
+
const emptySvg = svg && tag === "svg" && shown && !hasContent(node);
|
|
137468
|
+
// A <noscript> has no box while scripts run, nor a <script> or <style> undisplayed.
|
|
137469
|
+
const noBox =
|
|
137470
|
+
ns === "http://www.w3.org/1999/xhtml" &&
|
|
137471
|
+
(tag === "noscript" ||
|
|
137472
|
+
(/^(script|style)$/.test(tag) && (style.display === "none" || unrendered)));
|
|
137473
|
+
const svgStyle = svg && tag === "style";
|
|
137474
|
+
const img =
|
|
137475
|
+
ns === "http://www.w3.org/1999/xhtml" &&
|
|
137476
|
+
tag === "img" &&
|
|
137477
|
+
(getAttr.call(node, "alt") !== "" || !!getAttr.call(node, "title"));
|
|
137478
|
+
if (
|
|
137479
|
+
(!isInlineBox(style) && !noBox) ||
|
|
137480
|
+
img ||
|
|
137481
|
+
(svg && tag === "svg" && !emptySvg) ||
|
|
137482
|
+
svgStyle ||
|
|
137483
|
+
unrendered
|
|
137484
|
+
) {
|
|
137485
|
+
s += " ";
|
|
137486
|
+
stack.push(rendered && blockEnd ? BLOCK : SPACE);
|
|
137487
|
+
}
|
|
137488
|
+
if (style.display === "none") {
|
|
137489
|
+
unrendered++;
|
|
137490
|
+
stack.push(RENDERED);
|
|
137491
|
+
}
|
|
137492
|
+
if (!noBox && !svgStyle) pushContent(node, style, rendered, emptySvg);
|
|
137493
|
+
}
|
|
137494
|
+
return s.replace(WHITESPACE, " ");
|
|
137495
|
+
}
|
|
137496
|
+
|
|
137497
|
+
// Whether a node has an element child, or a text or CDATA child that is not all whitespace.
|
|
137498
|
+
function hasContent(node) {
|
|
137499
|
+
for (const child of getChildNodes.call(node)) {
|
|
137500
|
+
const type = getNodeType.call(child);
|
|
137501
|
+
if (type === 1) return true;
|
|
137502
|
+
if ((type === 3 || type === 4) && getNodeValue.call(child).replace(WHITESPACE, "")) {
|
|
137503
|
+
return true;
|
|
137504
|
+
}
|
|
137505
|
+
}
|
|
137506
|
+
return false;
|
|
137507
|
+
}
|
|
137508
|
+
|
|
137509
|
+
// What an element reads as in place of its content, or null: a text field's value (a
|
|
137510
|
+
// password's as bullets), else its aria-label, title or placeholder; what a <select>
|
|
137511
|
+
// shows; a range widget's value; else, unless it is a listbox with chosen options, its
|
|
137512
|
+
// alt text or a button input's value.
|
|
137513
|
+
function shownText(el, rendered, options) {
|
|
137514
|
+
if (isTextField(el)) {
|
|
137515
|
+
return fieldText(el) || altText(el) || getAttr.call(el, "title") || el.placeholder;
|
|
137516
|
+
}
|
|
137517
|
+
const control = controlText(el);
|
|
137518
|
+
if (control !== null) return control;
|
|
137519
|
+
const range = rangeText(el, rendered);
|
|
137520
|
+
if (range !== null) return range;
|
|
137521
|
+
if (options) return null;
|
|
137522
|
+
const alt = altText(el);
|
|
137523
|
+
return alt !== null ? alt : buttonText(el);
|
|
137524
|
+
}
|
|
137525
|
+
|
|
137526
|
+
// What the control being named reads as in place of its content, in its own
|
|
137527
|
+
// aria-labelledby target, or null: its alt text or a button input's value; for a text
|
|
137528
|
+
// field its title or placeholder, else, as the target itself, its value; for a <select>
|
|
137529
|
+
// its title, never its options.
|
|
137530
|
+
function selfText(el, isTarget) {
|
|
137531
|
+
const alt = altText(el);
|
|
137532
|
+
if (alt !== null) return alt;
|
|
137533
|
+
if (isTextField(el)) {
|
|
137534
|
+
return getAttr.call(el, "title") || el.placeholder || (isTarget ? fieldText(el) : "");
|
|
137535
|
+
}
|
|
137536
|
+
if (isHtml(el, "select")) return getAttr.call(el, "title") || "";
|
|
137537
|
+
return buttonText(el);
|
|
137538
|
+
}
|
|
137539
|
+
|
|
137540
|
+
// Whether target can read differently for el than for other controls: only when it
|
|
137541
|
+
// holds el and el reads otherwise as itself.
|
|
137542
|
+
function readsAsSelf(el, target) {
|
|
137543
|
+
if (!nodeContains.call(target, el)) return false;
|
|
137544
|
+
return selfText(el, target === el) !== shownText(el, true, chosenOptions(el));
|
|
137545
|
+
}
|
|
137546
|
+
|
|
137547
|
+
function fieldText(el) {
|
|
137548
|
+
return isPassword(el) ? "\\u2022".repeat(el.value.length) : el.value;
|
|
137549
|
+
}
|
|
137550
|
+
|
|
137551
|
+
function buttonText(el) {
|
|
137552
|
+
const button = isHtml(el, "input") && /^(button|submit|reset|image)$/.test(el.type);
|
|
137553
|
+
return button && el.value ? el.value : null;
|
|
137554
|
+
}
|
|
137555
|
+
|
|
137556
|
+
function isTextField(el) {
|
|
137557
|
+
if (getNamespaceURI.call(el) !== "http://www.w3.org/1999/xhtml") return false;
|
|
137558
|
+
const tag = getLocalName.call(el);
|
|
137559
|
+
return (
|
|
137560
|
+
tag === "textarea" ||
|
|
137561
|
+
(tag === "input" && /^(text|search|email|url|tel|number|password)$/.test(el.type))
|
|
137562
|
+
);
|
|
137563
|
+
}
|
|
137564
|
+
|
|
137565
|
+
// What a <select> or <textarea> shows, which its child text is not; null for others.
|
|
137566
|
+
function controlText(el) {
|
|
137567
|
+
if (getNamespaceURI.call(el) !== "http://www.w3.org/1999/xhtml") return null;
|
|
137568
|
+
const tag = getLocalName.call(el);
|
|
137569
|
+
if (tag === "textarea") return el.value || el.placeholder;
|
|
137570
|
+
if (tag !== "select") return null;
|
|
137571
|
+
let chosen = "";
|
|
137572
|
+
for (const option of el.selectedOptions) chosen += option.label + " ";
|
|
137573
|
+
return chosen;
|
|
137574
|
+
}
|
|
137575
|
+
|
|
137576
|
+
// An element's aria-label, or an <img>'s or image input's alt, when it has one that is not
|
|
137577
|
+
// blank; else an SVG element's first <title> child's text, which Chrome takes even when
|
|
137578
|
+
// blank.
|
|
137579
|
+
function altText(el) {
|
|
137580
|
+
const ns = getNamespaceURI.call(el);
|
|
137581
|
+
const tag = getLocalName.call(el);
|
|
137582
|
+
const img =
|
|
137583
|
+
ns === "http://www.w3.org/1999/xhtml" &&
|
|
137584
|
+
(tag === "img" || (tag === "input" && el.type === "image"));
|
|
137585
|
+
const t = getAttr.call(el, "aria-label") || (img && getAttr.call(el, "alt"));
|
|
137586
|
+
if (t && t.trim()) return t;
|
|
137587
|
+
if (ns !== "http://www.w3.org/2000/svg") return null;
|
|
137588
|
+
for (const child of getChildNodes.call(el)) {
|
|
137589
|
+
if (
|
|
137590
|
+
getNodeType.call(child) === 1 &&
|
|
137591
|
+
getLocalName.call(child) === "title" &&
|
|
137592
|
+
getNamespaceURI.call(child) === "http://www.w3.org/2000/svg"
|
|
137593
|
+
) {
|
|
137594
|
+
return getTextContent.call(child) || null;
|
|
137595
|
+
}
|
|
137596
|
+
}
|
|
137597
|
+
return null;
|
|
137598
|
+
}
|
|
137599
|
+
|
|
137600
|
+
function isInert(el) {
|
|
137601
|
+
return (
|
|
137602
|
+
getNamespaceURI.call(el) === "http://www.w3.org/1999/xhtml" && hasAttr.call(el, "inert")
|
|
137603
|
+
);
|
|
137604
|
+
}
|
|
137605
|
+
|
|
137606
|
+
// The roles Chrome knows; it passes over any other token. It also passes over an option,
|
|
137607
|
+
// listitem or treeitem outside its context, and an unnamed form or region; this takes them.
|
|
137608
|
+
const ROLES = Object.create(null);
|
|
137609
|
+
for (const role of (
|
|
137610
|
+
"alert alertdialog application article banner blockquote button caption cell checkbox " +
|
|
137611
|
+
"code columnheader combobox comment complementary contentinfo definition deletion dialog " +
|
|
137612
|
+
"directory document emphasis feed figure form generic grid gridcell group heading image " +
|
|
137613
|
+
"img insertion link list listbox listitem log main mark marquee math menu menubar " +
|
|
137614
|
+
"menuitem menuitemcheckbox menuitemradio meter navigation none note option paragraph " +
|
|
137615
|
+
"presentation progressbar radio radiogroup region row rowgroup rowheader scrollbar " +
|
|
137616
|
+
"search searchbox sectionfooter sectionheader separator slider spinbutton status strong " +
|
|
137617
|
+
"subscript suggestion superscript switch tab table tablist tabpanel term textbox time " +
|
|
137618
|
+
"timer toolbar tooltip tree treegrid treeitem graphics-document graphics-object " +
|
|
137619
|
+
"graphics-symbol " +
|
|
137620
|
+
"doc-abstract doc-acknowledgments doc-afterword doc-appendix doc-backlink " +
|
|
137621
|
+
"doc-biblioentry doc-bibliography doc-biblioref doc-chapter doc-colophon doc-conclusion " +
|
|
137622
|
+
"doc-cover doc-credit doc-credits doc-dedication doc-endnote doc-endnotes doc-epigraph " +
|
|
137623
|
+
"doc-epilogue doc-errata doc-example doc-footnote doc-foreword doc-glossary doc-glossref " +
|
|
137624
|
+
"doc-index doc-introduction doc-noteref doc-notice doc-pagebreak doc-pagefooter " +
|
|
137625
|
+
"doc-pageheader doc-pagelist doc-part doc-preface doc-prologue doc-pullquote doc-qna " +
|
|
137626
|
+
"doc-subtitle doc-tip doc-toc"
|
|
137627
|
+
).split(" ")) {
|
|
137628
|
+
ROLES[role] = true;
|
|
137629
|
+
}
|
|
137630
|
+
|
|
137631
|
+
// The first token of an element's role that Chrome knows, lowercased, else "".
|
|
137632
|
+
function ariaRole(el) {
|
|
137633
|
+
const role = getAttr.call(el, "role");
|
|
137634
|
+
for (const token of role ? role.trim().split(/\\s+/) : []) {
|
|
137635
|
+
const r = token.toLowerCase();
|
|
137636
|
+
if (ROLES[r] === true) return r;
|
|
137637
|
+
}
|
|
137638
|
+
return "";
|
|
137639
|
+
}
|
|
137640
|
+
|
|
137641
|
+
// A range widget's value as Chrome reads it: its aria-valuetext, else its aria-valuenow
|
|
137642
|
+
// held to aria-valuemin and aria-valuemax, to 6 significant digits. A value that does
|
|
137643
|
+
// not parse reads as 0, and a missing aria-valuenow as Chrome's default for the role.
|
|
137644
|
+
// A rendered <progress> or <meter>, and a range input, is one unless its role is another:
|
|
137645
|
+
// a <progress> reads its aria-valuenow unheld, else its value if it has one, and a
|
|
137646
|
+
// <meter>'s or range input's min, max and value stand in for the missing attributes (a
|
|
137647
|
+
// range input's min and max are 0 and 100 unless they parse). null for other roles, and
|
|
137648
|
+
// for a progressbar without a value.
|
|
137649
|
+
function rangeText(el, rendered) {
|
|
137650
|
+
const tag = getLocalName.call(el);
|
|
137651
|
+
const html = getNamespaceURI.call(el) === "http://www.w3.org/1999/xhtml";
|
|
137652
|
+
let native = "";
|
|
137653
|
+
if (html && rendered && /^(progress|meter)$/.test(tag)) native = tag;
|
|
137654
|
+
else if (html && tag === "input" && el.type === "range") native = "range";
|
|
137655
|
+
const implicit = native === "progress" ? "progressbar" : native === "range" ? "slider" : native;
|
|
137656
|
+
const role = ariaRole(el) || implicit;
|
|
137657
|
+
if (!/^(slider|scrollbar|spinbutton|meter|progressbar)$/.test(role)) return null;
|
|
137658
|
+
const text = getAttr.call(el, "aria-valuetext");
|
|
137659
|
+
if (text !== null) return text;
|
|
137660
|
+
const num = (name, missing, invalid = 0) => {
|
|
137661
|
+
const v = getAttr.call(el, name);
|
|
137662
|
+
if (v === null) return missing;
|
|
137663
|
+
return /^[+-]?(\\d+\\.?\\d*|\\.\\d+)(e[+-]?\\d+)?$/i.test(v) ? Number(v) : invalid;
|
|
137664
|
+
};
|
|
137665
|
+
let v = num("aria-valuenow", null);
|
|
137666
|
+
if (native === "progress") {
|
|
137667
|
+
if (v === null) {
|
|
137668
|
+
if (!hasAttr.call(el, "value")) return null;
|
|
137669
|
+
v = el.value;
|
|
137670
|
+
}
|
|
137671
|
+
} else {
|
|
137672
|
+
const lo = native === "range" ? num("min", 0, 0) : 0;
|
|
137673
|
+
const own =
|
|
137674
|
+
native === "range"
|
|
137675
|
+
? { min: lo, max: Math.max(lo, num("max", 100, 100)), value: el.valueAsNumber }
|
|
137676
|
+
: el;
|
|
137677
|
+
const spin = role === "spinbutton";
|
|
137678
|
+
const min = num("aria-valuemin", native ? own.min : spin ? -Infinity : 0);
|
|
137679
|
+
const max = num("aria-valuemax", native ? own.max : spin ? Infinity : 100);
|
|
137680
|
+
if (v !== null) v = Math.max(min, Math.min(max, v));
|
|
137681
|
+
else if (native) v = own.value;
|
|
137682
|
+
else if (role === "progressbar") return null;
|
|
137683
|
+
else v = role === "meter" ? min : spin ? 0 : (min + max) / 2;
|
|
137684
|
+
}
|
|
137685
|
+
const p = v.toPrecision(6);
|
|
137686
|
+
return /^[^e]*\\.[^e]*$/.test(p) ? p.replace(/\\.?0+$/, "") : p;
|
|
137687
|
+
}
|
|
137688
|
+
|
|
137689
|
+
// A listbox's option children with aria-selected="true", or null when it is not a
|
|
137690
|
+
// listbox or has none.
|
|
137691
|
+
function chosenOptions(el) {
|
|
137692
|
+
if (ariaRole(el) !== "listbox") return null;
|
|
137693
|
+
const chosen = [];
|
|
137694
|
+
for (const child of flatChildNodes(el)) {
|
|
137695
|
+
if (
|
|
137696
|
+
getNodeType.call(child) === 1 &&
|
|
137697
|
+
ariaRole(child) === "option" &&
|
|
137698
|
+
/^true$/i.test(getAttr.call(child, "aria-selected") || "")
|
|
137699
|
+
) {
|
|
137700
|
+
chosen.push(child);
|
|
137701
|
+
}
|
|
137702
|
+
}
|
|
137703
|
+
return chosen.length ? chosen : null;
|
|
137704
|
+
}
|
|
137705
|
+
|
|
137706
|
+
// Whether a <details> hides its content: closed, unless the page shows its
|
|
137707
|
+
// ::details-content or makes it display:contents.
|
|
137708
|
+
function closedDetails(el) {
|
|
137709
|
+
if (hasAttr.call(el, "open")) return false;
|
|
137710
|
+
const content = window.getComputedStyle(el, "::details-content");
|
|
137711
|
+
return content.contentVisibility !== "visible" && content.display !== "contents";
|
|
137712
|
+
}
|
|
137713
|
+
|
|
137714
|
+
// What a ::before or ::after shows, or null: the strings of its content outside
|
|
137715
|
+
// functions (counters, url()), and its alt text after a "/" (else null), which names it
|
|
137716
|
+
// in their place. Alt text and a non-inline box's text are spaced (a display:contents
|
|
137717
|
+
// or math box is inline); block marks a block-level box; style is the box's own.
|
|
137718
|
+
function pseudoText(el, which) {
|
|
137719
|
+
const style = window.getComputedStyle(el, which);
|
|
137720
|
+
if (style.display === "none" || style.visibility !== "visible") return null;
|
|
137721
|
+
const v = style.content;
|
|
137722
|
+
let text = "";
|
|
137723
|
+
let alt = null;
|
|
137724
|
+
let depth = 0;
|
|
137725
|
+
for (let i = 0; i < v.length; i++) {
|
|
137726
|
+
const c = v[i];
|
|
137727
|
+
if (c === "(") depth++;
|
|
137728
|
+
else if (c === ")") depth--;
|
|
137729
|
+
else if (c === "/" && !depth) alt = "";
|
|
137730
|
+
else if (c === '"') {
|
|
137731
|
+
let str = "";
|
|
137732
|
+
// Computed strings escape only '"', the backslash (code 92) and, in hex, controls.
|
|
137733
|
+
for (i++; i < v.length && v[i] !== '"'; i++) {
|
|
137734
|
+
if (v.charCodeAt(i) !== 92) {
|
|
137735
|
+
str += v[i];
|
|
137736
|
+
continue;
|
|
137737
|
+
}
|
|
137738
|
+
let hex = "";
|
|
137739
|
+
while (hex.length < 6 && /[0-9a-f]/i.test(v[i + 1] || "")) hex += v[++i];
|
|
137740
|
+
if (!hex) str += v[++i];
|
|
137741
|
+
else {
|
|
137742
|
+
str += String.fromCodePoint(parseInt(hex, 16));
|
|
137743
|
+
if (v[i + 1] === " ") i++;
|
|
137744
|
+
}
|
|
137745
|
+
}
|
|
137746
|
+
if (depth) continue;
|
|
137747
|
+
if (alt === null) text += str;
|
|
137748
|
+
else alt += str;
|
|
137749
|
+
}
|
|
137026
137750
|
}
|
|
137027
|
-
|
|
137751
|
+
if (!(alt === null ? text : alt)) return null;
|
|
137752
|
+
const d = style.display;
|
|
137753
|
+
const inline = isInlineBox(style) || /^(contents|math)$/.test(d);
|
|
137754
|
+
return {
|
|
137755
|
+
strings: text,
|
|
137756
|
+
alt,
|
|
137757
|
+
inline,
|
|
137758
|
+
spaced: alt !== null || !inline,
|
|
137759
|
+
block: /^(block|flex|grid|table|flow-root|list-item|-webkit-box)( |$)/.test(d),
|
|
137760
|
+
style,
|
|
137761
|
+
};
|
|
137762
|
+
}
|
|
137763
|
+
|
|
137764
|
+
const REPLACED = /^(img|input|video|audio|canvas|iframe|object|embed|progress|meter)$/;
|
|
137765
|
+
|
|
137766
|
+
// The last character a node lays out, or null if it lays out nothing. A <br>, a replaced
|
|
137767
|
+
// element or <svg> (but a broken <img> with an alt), the start of a box and the end of a
|
|
137768
|
+
// block-level box in a block container (inline false: the node's parent does not run
|
|
137769
|
+
// inline) are a space.
|
|
137770
|
+
function lastLaid(start, inline) {
|
|
137771
|
+
// Triples: a kind (a node, its ::before or ::after, or the start of a box), the node,
|
|
137772
|
+
// and whether the node's or the pseudo-element's parent runs inline.
|
|
137773
|
+
const stack = [0, start, inline];
|
|
137774
|
+
while (stack.length) {
|
|
137775
|
+
const inl = stack.pop();
|
|
137776
|
+
const node = stack.pop();
|
|
137777
|
+
const kind = stack.pop();
|
|
137778
|
+
if (kind === 3) return " ";
|
|
137779
|
+
if (kind) {
|
|
137780
|
+
const p = pseudoText(node, kind === 1 ? "::before" : "::after");
|
|
137781
|
+
const end = p && pseudoEnd(p, inl);
|
|
137782
|
+
if (end) return end;
|
|
137783
|
+
continue;
|
|
137784
|
+
}
|
|
137785
|
+
const type = getNodeType.call(node);
|
|
137786
|
+
if (type === 3 || type === 4) {
|
|
137787
|
+
const text = getNodeValue.call(node);
|
|
137788
|
+
if (text) return lastChar(text);
|
|
137789
|
+
continue;
|
|
137790
|
+
}
|
|
137791
|
+
if (type !== 1) continue;
|
|
137792
|
+
const style = window.getComputedStyle(node);
|
|
137793
|
+
if (style.display === "none") continue;
|
|
137794
|
+
const html = getNamespaceURI.call(node) === "http://www.w3.org/1999/xhtml";
|
|
137795
|
+
const tag = getLocalName.call(node);
|
|
137796
|
+
if (html && tag === "img") {
|
|
137797
|
+
const alt = !node.naturalWidth && getAttr.call(node, "alt");
|
|
137798
|
+
return alt ? lastChar(alt) : " ";
|
|
137799
|
+
}
|
|
137800
|
+
if ((html && (tag === "br" || REPLACED.test(tag))) || tag === "svg") return " ";
|
|
137801
|
+
const control = controlText(node);
|
|
137802
|
+
if (control !== null) return lastChar(control.trimEnd()) || " ";
|
|
137803
|
+
const inlineBox = isInlineBox(style);
|
|
137804
|
+
if (!inlineBox && style.display !== "contents") {
|
|
137805
|
+
if (isBlockLevel(style) && !inl) return " ";
|
|
137806
|
+
stack.push(3, null, false);
|
|
137807
|
+
}
|
|
137808
|
+
const kidsInline = style.display === "contents" ? inl : inlineBox;
|
|
137809
|
+
if (html) stack.push(1, node, inlineBox);
|
|
137810
|
+
for (const child of flatChildNodes(node)) stack.push(0, child, kidsInline);
|
|
137811
|
+
if (html) stack.push(2, node, inlineBox);
|
|
137812
|
+
}
|
|
137813
|
+
return null;
|
|
137814
|
+
}
|
|
137815
|
+
|
|
137816
|
+
// 1 for a block-level block container, whose ::first-letter can be in a block-level
|
|
137817
|
+
// child's, 2 for another block container, else 0.
|
|
137818
|
+
function letterBox(el, style) {
|
|
137819
|
+
const tag = getLocalName.call(el);
|
|
137820
|
+
if (getNamespaceURI.call(el) !== "http://www.w3.org/1999/xhtml" || REPLACED.test(tag)) {
|
|
137821
|
+
return 0;
|
|
137822
|
+
}
|
|
137823
|
+
if (/^(block|list-item|flow-root)$/.test(style.display)) return 1;
|
|
137824
|
+
return /^(inline-block|table-cell|table-caption)$/.test(style.display) ? 2 : 0;
|
|
137825
|
+
}
|
|
137826
|
+
|
|
137827
|
+
// Stands for the root's ancestors in a labelText walk's pending first letters.
|
|
137828
|
+
const OUTSIDE = {};
|
|
137829
|
+
|
|
137830
|
+
// An element's ancestors, innermost first, whose first letter is still to come at its
|
|
137831
|
+
// start: block containers it starts, up through block-level ones, past nothing laid out
|
|
137832
|
+
// but whitespace text.
|
|
137833
|
+
function openLetters(el) {
|
|
137834
|
+
const blocks = [];
|
|
137835
|
+
for (let node = el; ; ) {
|
|
137836
|
+
const parent = flatParent(node);
|
|
137837
|
+
if (!parent || getNodeType.call(parent) !== 1) return blocks;
|
|
137838
|
+
const style = window.getComputedStyle(parent);
|
|
137839
|
+
const inline = isInlineBox(style);
|
|
137840
|
+
const laidOut = someBefore(parent, node, (kid) => {
|
|
137841
|
+
const type = getNodeType.call(kid);
|
|
137842
|
+
const blank = (type === 3 || type === 4) && !/\\S/.test(getNodeValue.call(kid));
|
|
137843
|
+
return !blank && lastLaid(kid, inline) !== null;
|
|
137844
|
+
});
|
|
137845
|
+
if (laidOut) return blocks;
|
|
137846
|
+
const before =
|
|
137847
|
+
getNamespaceURI.call(parent) === "http://www.w3.org/1999/xhtml" &&
|
|
137848
|
+
pseudoText(parent, "::before");
|
|
137849
|
+
if (before && (/\\S/.test(before.strings) || !before.inline)) return blocks;
|
|
137850
|
+
if (!isFlow(parent, style)) {
|
|
137851
|
+
const box = letterBox(parent, style);
|
|
137852
|
+
if (box) blocks.push(parent);
|
|
137853
|
+
if (box !== 1) return blocks;
|
|
137854
|
+
}
|
|
137855
|
+
node = parent;
|
|
137856
|
+
}
|
|
137857
|
+
}
|
|
137858
|
+
|
|
137859
|
+
// A block's ::first-letter style when its text-transform differs from the block's, which
|
|
137860
|
+
// takes a ::first-letter rule; else null.
|
|
137861
|
+
function firstLetterStyle(el) {
|
|
137862
|
+
const style = window.getComputedStyle(el, "::first-letter");
|
|
137863
|
+
return style.textTransform !== window.getComputedStyle(el).textTransform ? style : null;
|
|
137864
|
+
}
|
|
137865
|
+
|
|
137866
|
+
// A text's first letter, with the whitespace and punctuation before it.
|
|
137867
|
+
const FIRST_LETTER = /^[\\s\\p{P}]*[^\\s\\p{P}]\\p{M}*/u;
|
|
137868
|
+
|
|
137869
|
+
// The last character a ::before or ::after lays out, as lastLaid finds it, or null.
|
|
137870
|
+
function pseudoEnd(pseudo, parentInline) {
|
|
137871
|
+
if (pseudo.block && !parentInline) return " ";
|
|
137872
|
+
return pseudo.strings ? lastChar(pseudo.strings) : pseudo.inline ? null : " ";
|
|
137873
|
+
}
|
|
137874
|
+
|
|
137875
|
+
// The last character laid out before an inline-flow element: in what precedes it in the
|
|
137876
|
+
// flat tree, up through the inline flow it runs in.
|
|
137877
|
+
function laidBefore(el) {
|
|
137878
|
+
for (let node = el; ; ) {
|
|
137879
|
+
const parent = flatParent(node);
|
|
137880
|
+
if (!parent || getNodeType.call(parent) !== 1) return " ";
|
|
137881
|
+
const style = window.getComputedStyle(parent);
|
|
137882
|
+
const inline = isInlineBox(style);
|
|
137883
|
+
let last = null;
|
|
137884
|
+
if (someBefore(parent, node, (kid) => (last = lastLaid(kid, inline)) !== null)) return last;
|
|
137885
|
+
const before =
|
|
137886
|
+
getNamespaceURI.call(parent) === "http://www.w3.org/1999/xhtml" &&
|
|
137887
|
+
pseudoText(parent, "::before");
|
|
137888
|
+
const end = before && pseudoEnd(before, inline);
|
|
137889
|
+
if (end) return end;
|
|
137890
|
+
if (!isFlow(parent, style)) return " ";
|
|
137891
|
+
node = parent;
|
|
137892
|
+
}
|
|
137893
|
+
}
|
|
137894
|
+
|
|
137895
|
+
// Whether test holds for a node before another among a parent's flat children, nearest
|
|
137896
|
+
// first. A childNodes list is stepped by previousSibling: indexing a long one once per
|
|
137897
|
+
// target is quadratic.
|
|
137898
|
+
function someBefore(parent, node, test) {
|
|
137899
|
+
const kids = flatChildNodes(parent);
|
|
137900
|
+
const light = getParentNode.call(node);
|
|
137901
|
+
if (light && getChildNodes.call(light) === kids) {
|
|
137902
|
+
for (let kid = getPreviousSibling.call(node); kid; kid = getPreviousSibling.call(kid)) {
|
|
137903
|
+
if (test(kid)) return true;
|
|
137904
|
+
}
|
|
137905
|
+
return false;
|
|
137906
|
+
}
|
|
137907
|
+
for (let i = Array.prototype.indexOf.call(kids, node) - 1; i >= 0; i--) {
|
|
137908
|
+
if (test(kids[i])) return true;
|
|
137909
|
+
}
|
|
137910
|
+
return false;
|
|
137911
|
+
}
|
|
137912
|
+
|
|
137913
|
+
// Whether an element runs in inline flow, which layout reads the previous character back
|
|
137914
|
+
// through: display:contents, or an inline box that is not replaced.
|
|
137915
|
+
function isFlow(el, style) {
|
|
137916
|
+
if (style.display === "contents") return true;
|
|
137917
|
+
const tag = getLocalName.call(el);
|
|
137918
|
+
const ns = getNamespaceURI.call(el);
|
|
137919
|
+
return (
|
|
137920
|
+
isInlineBox(style) &&
|
|
137921
|
+
!(ns === "http://www.w3.org/1999/xhtml" && REPLACED.test(tag)) &&
|
|
137922
|
+
!(ns === "http://www.w3.org/2000/svg" && tag === "svg")
|
|
137923
|
+
);
|
|
137924
|
+
}
|
|
137925
|
+
|
|
137926
|
+
// A string's last code point.
|
|
137927
|
+
function lastChar(text) {
|
|
137928
|
+
const pair = text.slice(-2);
|
|
137929
|
+
return pair.codePointAt(0) > 0xffff ? pair : text.slice(-1);
|
|
137930
|
+
}
|
|
137931
|
+
|
|
137932
|
+
// Whether a box is block-level, not inline-level.
|
|
137933
|
+
function isBlockLevel(style) {
|
|
137934
|
+
return !/^(inline|ruby|contents|math)/.test(style.display);
|
|
137935
|
+
}
|
|
137936
|
+
|
|
137937
|
+
const CASED = /^(uppercase|lowercase|capitalize)/;
|
|
137938
|
+
// Text as a style's text-transform cases it under its lang; prev gives the character
|
|
137939
|
+
// before it, which decides whether capitalize starts a word there. As in Blink, a lang
|
|
137940
|
+
// cases by its first 2 letters when a "-", "_", "@" or the end follows them: tr_TR as
|
|
137941
|
+
// Turkish, but tr.UTF-8 and tur as no lang.
|
|
137942
|
+
function caseText(text, style, prev) {
|
|
137943
|
+
const mode = style && CASED.exec(style.textTransform);
|
|
137944
|
+
if (!mode) return text;
|
|
137945
|
+
if (mode[1] === "capitalize") return capitalize(text, prev());
|
|
137946
|
+
const lang = /^"([a-z]{2})([-_@].*)?"$/i.exec(style.webkitLocale || "");
|
|
137947
|
+
if (mode[1] === "uppercase") return lang ? text.toLocaleUpperCase(lang[1]) : text.toUpperCase();
|
|
137948
|
+
return lang ? text.toLocaleLowerCase(lang[1]) : text.toLowerCase();
|
|
137949
|
+
}
|
|
137950
|
+
|
|
137951
|
+
// Blink's capitalize: each ICU word of prev + text starts in its first code unit's
|
|
137952
|
+
// single-character title case. Text is kept as is where Intl.Segmenter is missing or is
|
|
137953
|
+
// a page's own that misbehaves.
|
|
137954
|
+
let wordSegmenter = null;
|
|
137955
|
+
function capitalize(text, prev) {
|
|
137956
|
+
try {
|
|
137957
|
+
if (!wordSegmenter) wordSegmenter = new Intl.Segmenter(undefined, { granularity: "word" });
|
|
137958
|
+
let out = "";
|
|
137959
|
+
let at = 0;
|
|
137960
|
+
for (const { index } of wordSegmenter.segment(prev + text)) {
|
|
137961
|
+
if (index < prev.length) continue;
|
|
137962
|
+
const i = index - prev.length;
|
|
137963
|
+
out += text.slice(at, i) + titleCase(text[i]);
|
|
137964
|
+
at = i + 1;
|
|
137965
|
+
}
|
|
137966
|
+
return out + text.slice(at);
|
|
137967
|
+
} catch {
|
|
137968
|
+
return text;
|
|
137969
|
+
}
|
|
137970
|
+
}
|
|
137971
|
+
|
|
137972
|
+
// A code unit's simple title case, which JS lacks: a D\u017D, LJ, NJ or DZ digraph's is its
|
|
137973
|
+
// mixed-case form, Georgian Mkhedruli's is itself (not Mtavruli), a Greek letter with
|
|
137974
|
+
// ypogegrammeni's is its prosgegrammeni form, and otherwise it is the uppercase when
|
|
137975
|
+
// that is one character.
|
|
137976
|
+
function titleCase(c) {
|
|
137977
|
+
const code = c.charCodeAt(0);
|
|
137978
|
+
if (code >= 0x1c4 && code <= 0x1cc) return String.fromCharCode(code + 1 - ((code - 0x1c4) % 3));
|
|
137979
|
+
if (code >= 0x1f1 && code <= 0x1f3) return String.fromCharCode(0x1f2);
|
|
137980
|
+
if (code >= 0x10d0 && code <= 0x10ff) return c;
|
|
137981
|
+
if (code >= 0x1f80 && code <= 0x1faf && code % 16 < 8) return String.fromCharCode(code + 8);
|
|
137982
|
+
if (code === 0x1fb3 || code === 0x1fc3 || code === 0x1ff3) return String.fromCharCode(code + 9);
|
|
137983
|
+
const upper = c.toUpperCase();
|
|
137984
|
+
return upper.length === 1 ? upper : c;
|
|
137028
137985
|
}
|
|
137029
137986
|
|
|
137030
137987
|
function isInteractive(el) {
|
|
@@ -137081,8 +138038,766 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
137081
138038
|
return { x, y, width: Math.max(0, right - x), height: Math.max(0, bottom - y) };
|
|
137082
138039
|
}
|
|
137083
138040
|
|
|
137084
|
-
|
|
137085
|
-
|
|
138041
|
+
// Clip windows carry viewport-px bounds and, for oblique strips, a visible polygon.
|
|
138042
|
+
// A null window means only the viewport, which normRect already clamps to.
|
|
138043
|
+
function intersect(a, b) {
|
|
138044
|
+
if (!a) return b;
|
|
138045
|
+
if (!b) return a;
|
|
138046
|
+
return {
|
|
138047
|
+
left: Math.max(a.left, b.left),
|
|
138048
|
+
top: Math.max(a.top, b.top),
|
|
138049
|
+
right: Math.min(a.right, b.right),
|
|
138050
|
+
bottom: Math.min(a.bottom, b.bottom),
|
|
138051
|
+
};
|
|
138052
|
+
}
|
|
138053
|
+
|
|
138054
|
+
// Overflow clips a descendant only when the clipper is on its containing-block chain,
|
|
138055
|
+
// so an absolute or fixed box takes the clip in force at its containing block. Each
|
|
138056
|
+
// entry is the clip a child with that position gets.
|
|
138057
|
+
const NO_CLIP = { flow: null, abs: null, fixed: null };
|
|
138058
|
+
const NO_AREA = { left: 0, top: 0, right: 0, bottom: 0 };
|
|
138059
|
+
// Content a box skips paints nowhere, whatever its position.
|
|
138060
|
+
const SKIPPED = { flow: NO_AREA, abs: NO_AREA, fixed: NO_AREA };
|
|
138061
|
+
|
|
138062
|
+
// An element-keyed map. A page's top-level \`class Map\` shadows only the bare name,
|
|
138063
|
+
// but \`var Map = ...\` replaces globalThis.Map (with Immutable.Map, say, whose set
|
|
138064
|
+
// returns a copy); unless it keeps object keys in place, a linear list stands in.
|
|
138065
|
+
function nodeMap() {
|
|
138066
|
+
try {
|
|
138067
|
+
const m = new globalThis.Map();
|
|
138068
|
+
const k = {};
|
|
138069
|
+
m.set(k, 1);
|
|
138070
|
+
if (m.has(k) && m.get(k) === 1 && !m.has({})) return m;
|
|
138071
|
+
} catch (e) {
|
|
138072
|
+
/* not a usable Map */
|
|
138073
|
+
}
|
|
138074
|
+
const keys = [];
|
|
138075
|
+
const vals = [];
|
|
138076
|
+
return {
|
|
138077
|
+
has: (k) => keys.indexOf(k) >= 0,
|
|
138078
|
+
get: (k) => vals[keys.lastIndexOf(k)],
|
|
138079
|
+
set: (k, v) => void (keys.push(k), vals.push(v)),
|
|
138080
|
+
};
|
|
138081
|
+
}
|
|
138082
|
+
|
|
138083
|
+
// A slotted element paints where its <slot> sits in the shadow tree, so it takes the
|
|
138084
|
+
// clips in force there; each host's shadow tree is walked before its light children.
|
|
138085
|
+
const slotClips = nodeMap();
|
|
138086
|
+
// A rendered legend takes its fieldset's own clips, wherever in the DOM it sits.
|
|
138087
|
+
const legendClips = nodeMap();
|
|
138088
|
+
// Elements hidden() pruned, each with the clips it was walked under.
|
|
138089
|
+
const pruned = nodeMap();
|
|
138090
|
+
// The clips a slot in a pruned element gives its nodes, found down its path from there
|
|
138091
|
+
// as walk() finds them: null where it paints nothing, undefined outside pruned elements.
|
|
138092
|
+
// Memoized: a slot's nodes share it.
|
|
138093
|
+
const prunedSlots = nodeMap();
|
|
138094
|
+
function prunedSlotClips(slot) {
|
|
138095
|
+
if (prunedSlots.has(slot)) return prunedSlots.get(slot);
|
|
138096
|
+
const path = [];
|
|
138097
|
+
let n = slot;
|
|
138098
|
+
for (; n && !pruned.has(n); n = getParentNode.call(n)) path.push(n);
|
|
138099
|
+
let clips;
|
|
138100
|
+
if (n) {
|
|
138101
|
+
path.push(n);
|
|
138102
|
+
clips = pruned.get(n);
|
|
138103
|
+
}
|
|
138104
|
+
for (let i = path.length - 1; clips && i >= 0; i--) {
|
|
138105
|
+
const style = window.getComputedStyle(path[i]);
|
|
138106
|
+
if (style.display === "none" || (style.display !== "contents" && style.opacity === "0")) {
|
|
138107
|
+
clips = null;
|
|
138108
|
+
} else {
|
|
138109
|
+
if (inTopLayer(path[i], style)) clips = NO_CLIP;
|
|
138110
|
+
clips = childClips(path[i], style, clips, ownClip(clips, style));
|
|
138111
|
+
}
|
|
138112
|
+
}
|
|
138113
|
+
prunedSlots.set(slot, clips);
|
|
138114
|
+
return clips;
|
|
138115
|
+
}
|
|
138116
|
+
|
|
138117
|
+
// Each walked element's scrollers, its own last when it scrolls; the elements a
|
|
138118
|
+
// scroller cuts are anchored once the whole tree has been walked.
|
|
138119
|
+
const chains = nodeMap();
|
|
138120
|
+
const cuts = [];
|
|
138121
|
+
// Each emitted node's unclipped extent and the scrollers measured against it.
|
|
138122
|
+
const extents = nodeMap();
|
|
138123
|
+
|
|
138124
|
+
// An element's parent in the flat tree: its slot, else its parent, a shadow root's host.
|
|
138125
|
+
function flatParent(n) {
|
|
138126
|
+
const p = (getNodeType.call(n) === 1 && getAssignedSlot.call(n)) || getParentNode.call(n);
|
|
138127
|
+
return p && getNodeType.call(p) === 11 ? p.host : p;
|
|
138128
|
+
}
|
|
138129
|
+
|
|
138130
|
+
// The innermost scroller along an axis on a walked element's chain.
|
|
138131
|
+
function chainScroller(el, axis) {
|
|
138132
|
+
const chain = chains.get(el) || [];
|
|
138133
|
+
for (let i = chain.length - 1; i >= 0; i--) if (chain[i][axis]) return chain[i].el;
|
|
138134
|
+
return null;
|
|
138135
|
+
}
|
|
138136
|
+
|
|
138137
|
+
// The scroller a wheel at (x, y) scrolls along an axis: the innermost on the
|
|
138138
|
+
// painted element's chain, the one Chrome latches to. Null where that is unknown:
|
|
138139
|
+
// over a frame, whose own document may take the wheel, or where a scroll container
|
|
138140
|
+
// short of that scroller, scrollable or not, keeps the wheel with its
|
|
138141
|
+
// overscroll-behavior on the axis. \`stop\` is the element that settled it: that frame
|
|
138142
|
+
// or container (\`kept\`), else the walked element whose chain was read.
|
|
138143
|
+
function wheelScroller(x, y, axis) {
|
|
138144
|
+
let hit = elementsAt(document, x, y)[0];
|
|
138145
|
+
for (let sr = hit && getShadowRoot.call(hit); sr; sr = getShadowRoot.call(hit)) {
|
|
138146
|
+
const deeper = sr.elementsFromPoint(x, y)[0];
|
|
138147
|
+
if (!deeper || deeper === hit) break;
|
|
138148
|
+
hit = deeper;
|
|
138149
|
+
}
|
|
138150
|
+
if (hit && /^(IFRAME|FRAME|EMBED|OBJECT)$/.test(htmlTag(hit))) {
|
|
138151
|
+
return { scroller: null, stop: hit, kept: true };
|
|
138152
|
+
}
|
|
138153
|
+
const overscroll = axis === "sx" ? "overscrollBehaviorX" : "overscrollBehaviorY";
|
|
138154
|
+
let scroller;
|
|
138155
|
+
let stop = null;
|
|
138156
|
+
for (let n = hit; n; n = flatParent(n)) {
|
|
138157
|
+
if (scroller === undefined && chains.has(n)) {
|
|
138158
|
+
stop = n;
|
|
138159
|
+
scroller = chainScroller(n, axis);
|
|
138160
|
+
if (!scroller) break;
|
|
138161
|
+
}
|
|
138162
|
+
if (n === scroller) return { scroller, stop };
|
|
138163
|
+
const st = getNodeType.call(n) === 1 && window.getComputedStyle(n);
|
|
138164
|
+
const contains = st && (st[overscroll] === "contain" || st[overscroll] === "none");
|
|
138165
|
+
const clips = (o) => o !== "visible" && o !== "clip";
|
|
138166
|
+
if (contains && (clips(st.overflowX) || clips(st.overflowY))) {
|
|
138167
|
+
return { scroller: null, stop: n, kept: true };
|
|
138168
|
+
}
|
|
138169
|
+
}
|
|
138170
|
+
return { scroller: null, stop };
|
|
138171
|
+
}
|
|
138172
|
+
|
|
138173
|
+
// Every cut under one cutter probes the same points.
|
|
138174
|
+
const probed = Object.create(null);
|
|
138175
|
+
function wheelProbe(x, y, axis) {
|
|
138176
|
+
const key = axis + x + "," + y;
|
|
138177
|
+
return probed[key] || (probed[key] = wheelScroller(x, y, axis));
|
|
138178
|
+
}
|
|
138179
|
+
|
|
138180
|
+
// What a wheel at (x, y) that missed the movers landed on: the frame or container
|
|
138181
|
+
// keeping it, else the largest box around the point whose content wheels the same
|
|
138182
|
+
// scroller, short of a mover or one holding a mover (\`holders\`).
|
|
138183
|
+
function wheelBlocker(probe, holders, axis, x, y) {
|
|
138184
|
+
const over = (el) => {
|
|
138185
|
+
const b = getBCR.call(el);
|
|
138186
|
+
return b.left <= x && x <= b.right && b.top <= y && y <= b.bottom ? b : null;
|
|
138187
|
+
};
|
|
138188
|
+
let n = probe.stop;
|
|
138189
|
+
if (!n) return null;
|
|
138190
|
+
let box = over(n);
|
|
138191
|
+
if (probe.kept) return box;
|
|
138192
|
+
const target = chainScroller(n, axis);
|
|
138193
|
+
for (let p = flatParent(n); p && getNodeType.call(p) === 1; p = flatParent(p)) {
|
|
138194
|
+
if (holders.includes(p)) break;
|
|
138195
|
+
if (!chains.has(p) || chainScroller(p, axis) !== target) break;
|
|
138196
|
+
box = over(p) || box;
|
|
138197
|
+
}
|
|
138198
|
+
return box;
|
|
138199
|
+
}
|
|
138200
|
+
|
|
138201
|
+
// Region q less rect b: the bands of q above, below, left and right of b.
|
|
138202
|
+
function outside(q, b) {
|
|
138203
|
+
const top = Math.max(q.top, b.top);
|
|
138204
|
+
const bottom = Math.min(q.bottom, b.bottom);
|
|
138205
|
+
return [
|
|
138206
|
+
{ left: q.left, top: q.top, right: q.right, bottom: Math.min(q.bottom, b.top) },
|
|
138207
|
+
{ left: q.left, top: Math.max(q.top, b.bottom), right: q.right, bottom: q.bottom },
|
|
138208
|
+
{ left: q.left, top, right: Math.min(q.right, b.left), bottom },
|
|
138209
|
+
{ left: Math.max(q.left, b.right), top, right: q.right, bottom },
|
|
138210
|
+
].filter((v) => v.right - v.left >= 1 && v.bottom - v.top >= 1);
|
|
138211
|
+
}
|
|
138212
|
+
|
|
138213
|
+
// A point where a wheel scrolls the element (visible part r) against a scroller
|
|
138214
|
+
// cutting it along the axis: one on its chain from the outermost cutter in, of
|
|
138215
|
+
// scrollers \`scs\`. Elsewhere the wheel may move an overlay's scroller, the element's
|
|
138216
|
+
// own, or one holding the cutter. The shown part of the innermost cutter's window is
|
|
138217
|
+
// tried first, its points farthest along the axis first: content scrolling under the
|
|
138218
|
+
// point mid-wheel takes the rest of it. A 3x3 grid of each window is tried, then,
|
|
138219
|
+
// for a few rounds, the parts of it left beside the boxes its missed points landed
|
|
138220
|
+
// on, so a strip too thin for the grid is still found. With no such point on screen,
|
|
138221
|
+
// the centre of the cut window \`win\` across the element.
|
|
138222
|
+
function wheelAnchor(r, scs, cutters, win, axis) {
|
|
138223
|
+
const movers = scs.slice(scs.indexOf(cutters[0])).filter((s) => s[axis]);
|
|
138224
|
+
const away = ([x, y]) =>
|
|
138225
|
+
axis === "sx" ? Math.max(r.left - x, x - r.right) : Math.max(r.top - y, y - r.bottom);
|
|
138226
|
+
const holders = [];
|
|
138227
|
+
for (const m of movers) for (let n = m.el; n; n = flatParent(n)) holders.push(n);
|
|
138228
|
+
// elementsFromPoint hits what meets the 1px box right of and below a point, a wheel
|
|
138229
|
+
// the box that holds it once edges snap to pixels: a point keeps that 1px box in q
|
|
138230
|
+
// where it can, and half a pixel past q's start.
|
|
138231
|
+
const span = (lo, hi, f) => Math.max(Math.min(lo + (hi - lo) * f, hi - 1), lo + 0.5);
|
|
138232
|
+
const at = (q, f, g) => [span(q.left, q.right, f), span(q.top, q.bottom, g)];
|
|
138233
|
+
// Probes past the grids, each an elementsFromPoint and a walk up its path.
|
|
138234
|
+
let spare = 24;
|
|
138235
|
+
for (let i = cutters.length - 1; i >= 0; i--) {
|
|
138236
|
+
let regions = [intersect(cutters[i].shown, { left: 0, top: 0, right: w, bottom: h })];
|
|
138237
|
+
for (let round = 0; round < 4 && regions.length; round++) {
|
|
138238
|
+
const points = [];
|
|
138239
|
+
for (const q of regions) {
|
|
138240
|
+
for (const f of [0.1, 0.5, 0.9]) {
|
|
138241
|
+
if (round) points.push([axis === "sx" ? at(q, f, 0.5) : at(q, 0.5, f), q]);
|
|
138242
|
+
else for (const g of [0.1, 0.5, 0.9]) points.push([at(q, f, g), q]);
|
|
138243
|
+
}
|
|
138244
|
+
}
|
|
138245
|
+
points.sort((a, b) => away(b[0]) - away(a[0]));
|
|
138246
|
+
const boxes = [];
|
|
138247
|
+
const blocked = [];
|
|
138248
|
+
for (const [[x, y], q] of points) {
|
|
138249
|
+
if (round && spare-- <= 0) break;
|
|
138250
|
+
const probe = wheelProbe(x, y, axis);
|
|
138251
|
+
if (movers.some((m) => m.el === probe.scroller)) return { x: x / w, y: y / h };
|
|
138252
|
+
const box = wheelBlocker(probe, holders, axis, x, y);
|
|
138253
|
+
if (box) {
|
|
138254
|
+
boxes.push(box);
|
|
138255
|
+
blocked.push(q);
|
|
138256
|
+
}
|
|
138257
|
+
}
|
|
138258
|
+
// Bounded: each box can split every part in four.
|
|
138259
|
+
regions = regions
|
|
138260
|
+
.filter((q) => blocked.includes(q))
|
|
138261
|
+
.flatMap((q) =>
|
|
138262
|
+
boxes.reduce((parts, b) => parts.flatMap((v) => outside(v, b)).slice(0, 8), [q])
|
|
138263
|
+
)
|
|
138264
|
+
.slice(0, 8);
|
|
138265
|
+
}
|
|
138266
|
+
}
|
|
138267
|
+
const [x, y] = [(r.left + r.right) / 2, (r.top + r.bottom) / 2];
|
|
138268
|
+
if (movers.some((m) => m.el === wheelProbe(x, y, axis).scroller)) {
|
|
138269
|
+
return { x: x / w, y: y / h };
|
|
138270
|
+
}
|
|
138271
|
+
return axis === "sx"
|
|
138272
|
+
? { x: (win.left + win.right) / 2 / w, y: (r.top + r.bottom) / 2 / h }
|
|
138273
|
+
: { x: (r.left + r.right) / 2 / w, y: (win.top + win.bottom) / 2 / h };
|
|
138274
|
+
}
|
|
138275
|
+
|
|
138276
|
+
// An XHTML document keeps tagName lowercase.
|
|
138277
|
+
function htmlTag(el) {
|
|
138278
|
+
return getTagName.call(el).toUpperCase();
|
|
138279
|
+
}
|
|
138280
|
+
|
|
138281
|
+
// False for a pseudo-class this Chromium lacks.
|
|
138282
|
+
function matches(el, sel) {
|
|
138283
|
+
try {
|
|
138284
|
+
return matchesSel.call(el, sel);
|
|
138285
|
+
} catch (e) {
|
|
138286
|
+
return false;
|
|
138287
|
+
}
|
|
138288
|
+
}
|
|
138289
|
+
|
|
138290
|
+
// A top-layer box (modal dialog, open popover, fullscreen element) escapes every clip.
|
|
138291
|
+
function inTopLayer(el, style) {
|
|
138292
|
+
if (style.position !== "fixed" && style.position !== "absolute") return false;
|
|
138293
|
+
return [":modal", ":popover-open", ":fullscreen"].some((sel) => matches(el, sel));
|
|
138294
|
+
}
|
|
138295
|
+
|
|
138296
|
+
// An open customizable select draws every child but a leading <button> in its
|
|
138297
|
+
// top-layer ::picker(select).
|
|
138298
|
+
function inPicker(el, child, i) {
|
|
138299
|
+
if (htmlTag(el) !== "SELECT" || !matches(el, ":open")) return false;
|
|
138300
|
+
return i > 0 || htmlTag(child) !== "BUTTON";
|
|
138301
|
+
}
|
|
138302
|
+
|
|
138303
|
+
// A display: contents element has no box to position: its own text is in flow.
|
|
138304
|
+
function ownClip(clips, style) {
|
|
138305
|
+
if (style.display === "contents") return clips.flow;
|
|
138306
|
+
if (style.position === "absolute") return clips.abs;
|
|
138307
|
+
if (style.position === "fixed") return clips.fixed;
|
|
138308
|
+
return clips.flow;
|
|
138309
|
+
}
|
|
138310
|
+
|
|
138311
|
+
function isSet(v) {
|
|
138312
|
+
return Boolean(v) && v !== "none";
|
|
138313
|
+
}
|
|
138314
|
+
|
|
138315
|
+
// content-visibility: auto or hidden applies paint containment that computed contain omits.
|
|
138316
|
+
function paintContained(style) {
|
|
138317
|
+
return (
|
|
138318
|
+
/paint|strict|content/.test(style.contain || "") ||
|
|
138319
|
+
/auto|hidden/.test(style.contentVisibility || "")
|
|
138320
|
+
);
|
|
138321
|
+
}
|
|
138322
|
+
|
|
138323
|
+
// Whether an element is the containing block of fixed descendants. Chromium ignores
|
|
138324
|
+
// transforms on inline boxes, and containment wherever it ignores overflow.
|
|
138325
|
+
function containsFixed(el, style) {
|
|
138326
|
+
// Computed will-change keeps the author's case and -webkit- aliases.
|
|
138327
|
+
const hints = (style.willChange || "")
|
|
138328
|
+
.split(",")
|
|
138329
|
+
.map((t) => t.trim().toLowerCase().replace(/^-webkit-/, ""));
|
|
138330
|
+
const hinted = (...props) => props.some((p) => hints.includes(p));
|
|
138331
|
+
if (isSet(style.filter) || isSet(style.backdropFilter) || hinted("filter", "backdrop-filter")) {
|
|
138332
|
+
return true;
|
|
138333
|
+
}
|
|
138334
|
+
if (isInlineBox(style)) return false;
|
|
138335
|
+
if (
|
|
138336
|
+
isSet(style.transform) ||
|
|
138337
|
+
isSet(style.translate) ||
|
|
138338
|
+
isSet(style.rotate) ||
|
|
138339
|
+
isSet(style.scale) ||
|
|
138340
|
+
isSet(style.perspective) ||
|
|
138341
|
+
style.transformStyle === "preserve-3d" ||
|
|
138342
|
+
hinted("transform", "translate", "rotate", "scale", "perspective", "transform-style")
|
|
138343
|
+
) {
|
|
138344
|
+
return true;
|
|
138345
|
+
}
|
|
138346
|
+
return (
|
|
138347
|
+
overflowApplies(el, style) &&
|
|
138348
|
+
(/layout/.test(style.contain || "") || paintContained(style) || hinted("contain"))
|
|
138349
|
+
);
|
|
138350
|
+
}
|
|
138351
|
+
|
|
138352
|
+
// A computed transform's 2D part as [a, b, c, d, e, f], or null for none.
|
|
138353
|
+
function matrix2d(v) {
|
|
138354
|
+
const m = /^matrix(3d)?\\(([^)]*)\\)$/.exec(v || "");
|
|
138355
|
+
if (!m) return null;
|
|
138356
|
+
const n = m[2].split(",").map(parseFloat);
|
|
138357
|
+
return m[1] ? [n[0], n[1], n[4], n[5], n[12], n[13]] : n;
|
|
138358
|
+
}
|
|
138359
|
+
|
|
138360
|
+
function multiply(p, q) {
|
|
138361
|
+
return [
|
|
138362
|
+
p[0] * q[0] + p[2] * q[1],
|
|
138363
|
+
p[1] * q[0] + p[3] * q[1],
|
|
138364
|
+
p[0] * q[2] + p[2] * q[3],
|
|
138365
|
+
p[1] * q[2] + p[3] * q[3],
|
|
138366
|
+
p[0] * q[4] + p[2] * q[5] + p[4],
|
|
138367
|
+
p[1] * q[4] + p[3] * q[5] + p[5],
|
|
138368
|
+
];
|
|
138369
|
+
}
|
|
138370
|
+
|
|
138371
|
+
// The 2D matrix of translate, rotate, scale and transform, applied in that order.
|
|
138372
|
+
function transformMatrix(style) {
|
|
138373
|
+
let t = [1, 0, 0, 1, 0, 0];
|
|
138374
|
+
if (isSet(style.translate)) {
|
|
138375
|
+
const [tx = 0, ty = 0] = style.translate.split(" ").map((v) => parseFloat(v) || 0);
|
|
138376
|
+
t = multiply(t, [1, 0, 0, 1, tx, ty]);
|
|
138377
|
+
}
|
|
138378
|
+
// Only a rotation about z is 2D: "45deg" or "z 45deg".
|
|
138379
|
+
const rot = /^(?:z )?(-?[\\d.]+)deg$/.exec(style.rotate || "");
|
|
138380
|
+
if (rot) {
|
|
138381
|
+
const a = (parseFloat(rot[1]) * Math.PI) / 180;
|
|
138382
|
+
t = multiply(t, [Math.cos(a), Math.sin(a), -Math.sin(a), Math.cos(a), 0, 0]);
|
|
138383
|
+
}
|
|
138384
|
+
if (isSet(style.scale)) {
|
|
138385
|
+
const [sx = 1, sy = sx] = style.scale.split(" ").map(parseFloat);
|
|
138386
|
+
t = multiply(t, [sx, 0, 0, sy, 0, 0]);
|
|
138387
|
+
}
|
|
138388
|
+
const m = matrix2d(style.transform);
|
|
138389
|
+
return m ? multiply(t, m) : t;
|
|
138390
|
+
}
|
|
138391
|
+
|
|
138392
|
+
// A nested <svg>'s rect bounds its content, not its viewport: its x/y/width/height in
|
|
138393
|
+
// the parent's user space, moved by its own transforms about its transform-origin.
|
|
138394
|
+
function nestedSvgViewport(el, style) {
|
|
138395
|
+
if (!(el instanceof SVGSVGElement) || !el.ownerSVGElement) return null;
|
|
138396
|
+
const parent = el.parentNode;
|
|
138397
|
+
const m = parent.getScreenCTM && parent.getScreenCTM();
|
|
138398
|
+
if (!m) return null;
|
|
138399
|
+
const x = el.x.animVal.value;
|
|
138400
|
+
const y = el.y.animVal.value;
|
|
138401
|
+
const w = el.width.animVal.value;
|
|
138402
|
+
const h = el.height.animVal.value;
|
|
138403
|
+
const t = transformMatrix(style);
|
|
138404
|
+
const [ox = 0, oy = 0] = (style.transformOrigin || "").split(" ").map((v) => parseFloat(v) || 0);
|
|
138405
|
+
const xs = [];
|
|
138406
|
+
const ys = [];
|
|
138407
|
+
for (const [px, py] of [[x, y], [x + w, y], [x, y + h], [x + w, y + h]]) {
|
|
138408
|
+
const qx = t[0] * (px - ox) + t[2] * (py - oy) + t[4] + ox;
|
|
138409
|
+
const qy = t[1] * (px - ox) + t[3] * (py - oy) + t[5] + oy;
|
|
138410
|
+
xs.push(m.a * qx + m.c * qy + m.e);
|
|
138411
|
+
ys.push(m.b * qx + m.d * qy + m.f);
|
|
138412
|
+
}
|
|
138413
|
+
return {
|
|
138414
|
+
left: Math.min(...xs),
|
|
138415
|
+
top: Math.min(...ys),
|
|
138416
|
+
right: Math.max(...xs),
|
|
138417
|
+
bottom: Math.max(...ys),
|
|
138418
|
+
};
|
|
138419
|
+
}
|
|
138420
|
+
|
|
138421
|
+
const IDENTITY = [1, 0, 0, 1, 0, 0];
|
|
138422
|
+
|
|
138423
|
+
// The 2D linear part of the transforms an element renders under, its own included: style
|
|
138424
|
+
// is its own, and base its flat parent's when the caller has it. An HTML inline box
|
|
138425
|
+
// ignores its own, a top-layer box its ancestors'. Memoized, and climbed without
|
|
138426
|
+
// recursion: display: contents chains can nest thousands deep.
|
|
138427
|
+
const linears = nodeMap();
|
|
138428
|
+
function linearTransform(el, style, base) {
|
|
138429
|
+
if (linears.has(el)) return linears.get(el);
|
|
138430
|
+
const chain = [el];
|
|
138431
|
+
let t = base;
|
|
138432
|
+
let n = base ? null : flatParent(el);
|
|
138433
|
+
while (!t) {
|
|
138434
|
+
if (!n || getNodeType.call(n) !== 1) t = IDENTITY;
|
|
138435
|
+
else if (linears.has(n)) t = linears.get(n);
|
|
138436
|
+
else {
|
|
138437
|
+
chain.push(n);
|
|
138438
|
+
n = flatParent(n);
|
|
138439
|
+
}
|
|
138440
|
+
}
|
|
138441
|
+
for (let i = chain.length - 1; i >= 0; i--) {
|
|
138442
|
+
const n = chain[i];
|
|
138443
|
+
const st = n === el ? style : window.getComputedStyle(n);
|
|
138444
|
+
if (t !== IDENTITY && inTopLayer(n, st)) t = IDENTITY;
|
|
138445
|
+
if (
|
|
138446
|
+
(isSet(st.transform) || isSet(st.rotate) || isSet(st.scale)) &&
|
|
138447
|
+
st.display !== "contents" &&
|
|
138448
|
+
!(n instanceof HTMLElement && isInlineBox(st))
|
|
138449
|
+
) {
|
|
138450
|
+
t = multiply(t, transformMatrix(st));
|
|
138451
|
+
}
|
|
138452
|
+
linears.set(n, t);
|
|
138453
|
+
}
|
|
138454
|
+
return t;
|
|
138455
|
+
}
|
|
138456
|
+
|
|
138457
|
+
// The map from layout px, measured from el's w x h border box's top-left, to viewport
|
|
138458
|
+
// px: el's linear transform, sized and placed to fill its rendered rect r.
|
|
138459
|
+
function boxMap(el, style, r, w, h) {
|
|
138460
|
+
// A quarter turn's computed cosine (about 6e-17) would carry an infinite edge across.
|
|
138461
|
+
const [a, b, c, d] = linearTransform(el, style).map((v) => (Math.abs(v) < 1e-9 ? 0 : v));
|
|
138462
|
+
const spanX = Math.abs(a) * w + Math.abs(c) * h;
|
|
138463
|
+
const spanY = Math.abs(b) * w + Math.abs(d) * h;
|
|
138464
|
+
const kx = spanX > 0 ? r.width / spanX : 1;
|
|
138465
|
+
const ky = spanY > 0 ? r.height / spanY : 1;
|
|
138466
|
+
const m = [a * kx, b * ky, c * kx, d * ky];
|
|
138467
|
+
return m.concat([
|
|
138468
|
+
r.left - Math.min(0, m[0] * w) - Math.min(0, m[2] * h),
|
|
138469
|
+
r.top - Math.min(0, m[1] * w) - Math.min(0, m[3] * h),
|
|
138470
|
+
]);
|
|
138471
|
+
}
|
|
138472
|
+
|
|
138473
|
+
// The viewport bounds of a layout rect under boxMap's m. An infinite edge stays
|
|
138474
|
+
// infinite on whichever axis it maps to.
|
|
138475
|
+
function mapRect(m, rect) {
|
|
138476
|
+
const term = (k, v) => (k ? k * v : 0);
|
|
138477
|
+
const xs = [];
|
|
138478
|
+
const ys = [];
|
|
138479
|
+
for (const x of [rect.left, rect.right]) {
|
|
138480
|
+
for (const y of [rect.top, rect.bottom]) {
|
|
138481
|
+
xs.push(term(m[0], x) + term(m[2], y) + m[4]);
|
|
138482
|
+
ys.push(term(m[1], x) + term(m[3], y) + m[5]);
|
|
138483
|
+
}
|
|
138484
|
+
}
|
|
138485
|
+
return {
|
|
138486
|
+
left: Math.min(...xs),
|
|
138487
|
+
top: Math.min(...ys),
|
|
138488
|
+
right: Math.max(...xs),
|
|
138489
|
+
bottom: Math.max(...ys),
|
|
138490
|
+
};
|
|
138491
|
+
}
|
|
138492
|
+
|
|
138493
|
+
// Clip a convex polygon against one edge. The signed distance is positive inside.
|
|
138494
|
+
function clipEdge(points, distance) {
|
|
138495
|
+
const kept = [];
|
|
138496
|
+
let prev = points[points.length - 1];
|
|
138497
|
+
if (!prev) return kept;
|
|
138498
|
+
let from = distance(prev);
|
|
138499
|
+
for (const next of points) {
|
|
138500
|
+
const to = distance(next);
|
|
138501
|
+
if ((from < 0) !== (to < 0)) {
|
|
138502
|
+
const t = from / (from - to);
|
|
138503
|
+
kept.push([prev[0] + t * (next[0] - prev[0]), prev[1] + t * (next[1] - prev[1])]);
|
|
138504
|
+
}
|
|
138505
|
+
if (to >= 0) kept.push(next);
|
|
138506
|
+
prev = next;
|
|
138507
|
+
from = to;
|
|
138508
|
+
}
|
|
138509
|
+
return kept;
|
|
138510
|
+
}
|
|
138511
|
+
|
|
138512
|
+
// An oblique strip has an infinite bounding rect on both viewport axes. Keep the
|
|
138513
|
+
// visible polygon through nested clips and take its bounds only for the reported frame.
|
|
138514
|
+
function clipBox(clip, m, box) {
|
|
138515
|
+
const [a, b, c, d, tx, ty] = m;
|
|
138516
|
+
const obliqueStrip = (box.top === -Infinity && c && d) || (box.left === -Infinity && a && b);
|
|
138517
|
+
const polygon = clip && clip.polygon;
|
|
138518
|
+
if (!obliqueStrip && !polygon) return intersect(clip, mapRect(m, box));
|
|
138519
|
+
|
|
138520
|
+
const det = a * d - b * c;
|
|
138521
|
+
if (!det) return { ...NO_AREA };
|
|
138522
|
+
const view = intersect(clip, { left: 0, top: 0, right: w, bottom: h });
|
|
138523
|
+
if (view.right <= view.left || view.bottom <= view.top) return { ...NO_AREA };
|
|
138524
|
+
let points = polygon || [
|
|
138525
|
+
[view.left, view.top],
|
|
138526
|
+
[view.right, view.top],
|
|
138527
|
+
[view.right, view.bottom],
|
|
138528
|
+
[view.left, view.bottom],
|
|
138529
|
+
];
|
|
138530
|
+
// Invert the box map to compare viewport points with each finite layout edge.
|
|
138531
|
+
const localX = ([x, y]) => (d * (x - tx) - c * (y - ty)) / det;
|
|
138532
|
+
const localY = ([x, y]) => (a * (y - ty) - b * (x - tx)) / det;
|
|
138533
|
+
if (Number.isFinite(box.left)) points = clipEdge(points, (p) => localX(p) - box.left);
|
|
138534
|
+
if (Number.isFinite(box.right)) points = clipEdge(points, (p) => box.right - localX(p));
|
|
138535
|
+
if (Number.isFinite(box.top)) points = clipEdge(points, (p) => localY(p) - box.top);
|
|
138536
|
+
if (Number.isFinite(box.bottom)) points = clipEdge(points, (p) => box.bottom - localY(p));
|
|
138537
|
+
if (points.length < 3) return { ...NO_AREA };
|
|
138538
|
+
// A box touching only a slanted edge spans both viewport axes but paints no area.
|
|
138539
|
+
const [x0, y0] = points[0];
|
|
138540
|
+
let twiceArea = 0;
|
|
138541
|
+
for (let i = 2; i < points.length; i++) {
|
|
138542
|
+
const [x1, y1] = points[i - 1];
|
|
138543
|
+
const [x2, y2] = points[i];
|
|
138544
|
+
twiceArea += (x1 - x0) * (y2 - y0) - (x2 - x0) * (y1 - y0);
|
|
138545
|
+
}
|
|
138546
|
+
if (Math.abs(twiceArea) < 1e-9) return { ...NO_AREA };
|
|
138547
|
+
const xs = points.map(([x]) => x);
|
|
138548
|
+
const ys = points.map(([, y]) => y);
|
|
138549
|
+
return {
|
|
138550
|
+
left: Math.min(...xs),
|
|
138551
|
+
top: Math.min(...ys),
|
|
138552
|
+
right: Math.max(...xs),
|
|
138553
|
+
bottom: Math.max(...ys),
|
|
138554
|
+
polygon: points,
|
|
138555
|
+
};
|
|
138556
|
+
}
|
|
138557
|
+
|
|
138558
|
+
function visibleBox(el, style, r, clip) {
|
|
138559
|
+
if (!clip || !clip.polygon) return intersect(r, clip);
|
|
138560
|
+
if (el instanceof HTMLElement) {
|
|
138561
|
+
const width = getOffsetWidth.call(el);
|
|
138562
|
+
const height = getOffsetHeight.call(el);
|
|
138563
|
+
if (width && height) {
|
|
138564
|
+
return clipBox(clip, boxMap(el, style, r, width, height), {
|
|
138565
|
+
left: 0, top: 0, right: width, bottom: height,
|
|
138566
|
+
});
|
|
138567
|
+
}
|
|
138568
|
+
}
|
|
138569
|
+
return clipBox(clip, IDENTITY, r);
|
|
138570
|
+
}
|
|
138571
|
+
|
|
138572
|
+
// Padding box, scrollbars excluded, in layout px from the border box's top-left, and
|
|
138573
|
+
// boxMap's m from those to viewport px. A non-HTML clipper has no offset* to measure by:
|
|
138574
|
+
// an outer <svg> clips at its content box, a <foreignObject> at its rect. That rect, a
|
|
138575
|
+
// nested <svg>'s viewport and a quirks-mode body's box come in viewport px, with the
|
|
138576
|
+
// identity.
|
|
138577
|
+
function paddingBox(el, style) {
|
|
138578
|
+
const vp = nestedSvgViewport(el, style);
|
|
138579
|
+
if (vp) return { ...vp, m: IDENTITY };
|
|
138580
|
+
const r = getBCR.call(el);
|
|
138581
|
+
// A quirks-mode body reports the viewport's client size, so its own borders measure it.
|
|
138582
|
+
if (htmlTag(el) === "BODY" && getOwnerDocument.call(el).compatMode === "BackCompat") {
|
|
138583
|
+
const border = (side) => parseFloat(style["border" + side + "Width"]) || 0;
|
|
138584
|
+
return {
|
|
138585
|
+
left: r.left + border("Left"),
|
|
138586
|
+
top: r.top + border("Top"),
|
|
138587
|
+
right: r.right - border("Right"),
|
|
138588
|
+
bottom: r.bottom - border("Bottom"),
|
|
138589
|
+
m: IDENTITY,
|
|
138590
|
+
};
|
|
138591
|
+
}
|
|
138592
|
+
if (!(el instanceof HTMLElement)) {
|
|
138593
|
+
if (!(el instanceof SVGSVGElement)) {
|
|
138594
|
+
return { left: r.left, top: r.top, right: r.right, bottom: r.bottom, m: IDENTITY };
|
|
138595
|
+
}
|
|
138596
|
+
const px = (prop) => parseFloat(style[prop]) || 0;
|
|
138597
|
+
const inset = (side) => px("border" + side + "Width") + px("padding" + side);
|
|
138598
|
+
const borderBox = style.boxSizing === "border-box";
|
|
138599
|
+
const lw = px("width") + (borderBox ? 0 : inset("Left") + inset("Right"));
|
|
138600
|
+
const lh = px("height") + (borderBox ? 0 : inset("Top") + inset("Bottom"));
|
|
138601
|
+
return {
|
|
138602
|
+
left: inset("Left"),
|
|
138603
|
+
top: inset("Top"),
|
|
138604
|
+
right: lw - inset("Right"),
|
|
138605
|
+
bottom: lh - inset("Bottom"),
|
|
138606
|
+
m: boxMap(el, style, r, lw, lh),
|
|
138607
|
+
};
|
|
138608
|
+
}
|
|
138609
|
+
const left = getClientLeft.call(el);
|
|
138610
|
+
const top = getClientTop.call(el);
|
|
138611
|
+
return {
|
|
138612
|
+
left,
|
|
138613
|
+
top,
|
|
138614
|
+
right: left + getClientWidth.call(el),
|
|
138615
|
+
bottom: top + getClientHeight.call(el),
|
|
138616
|
+
m: boxMap(el, style, r, getOffsetWidth.call(el), getOffsetHeight.call(el)),
|
|
138617
|
+
};
|
|
138618
|
+
}
|
|
138619
|
+
|
|
138620
|
+
// How far, in layout px, overflow-clip-margin moves a clip edge out of the clip box (the
|
|
138621
|
+
// padding box, or an outer <svg>'s content box). It applies only where the axis clips by
|
|
138622
|
+
// overflow: clip or by paint containment, and to overflow: clip only when both axes do.
|
|
138623
|
+
function clipMargin(el, style, overflow, side) {
|
|
138624
|
+
if (overflow !== "clip" && overflow !== "visible") return 0;
|
|
138625
|
+
if (!paintContained(style) && (style.overflowX !== "clip" || style.overflowY !== "clip")) {
|
|
138626
|
+
return 0;
|
|
138627
|
+
}
|
|
138628
|
+
const v = style.overflowClipMargin || "";
|
|
138629
|
+
const len = parseFloat(v.replace(/^[a-z-]+/, "")) || 0;
|
|
138630
|
+
const padding = parseFloat(style["padding" + side]) || 0;
|
|
138631
|
+
let box = el instanceof SVGSVGElement ? padding : 0;
|
|
138632
|
+
if (v.startsWith("content-box")) box -= padding;
|
|
138633
|
+
if (v.startsWith("border-box")) box += parseFloat(style["border" + side + "Width"]) || 0;
|
|
138634
|
+
return box + len;
|
|
138635
|
+
}
|
|
138636
|
+
|
|
138637
|
+
// The root's overflow clips the viewport, not its box, and so does the body's unless
|
|
138638
|
+
// the root's is set or either has containment; the viewport is left to the clamp.
|
|
138639
|
+
// Chromium ignores overflow on inline HTML boxes and on table rows, row groups and
|
|
138640
|
+
// columns.
|
|
138641
|
+
function overflowApplies(el, style) {
|
|
138642
|
+
const tag = htmlTag(el);
|
|
138643
|
+
if (tag === "HTML") return false;
|
|
138644
|
+
if (tag === "BODY") {
|
|
138645
|
+
const doc = getOwnerDocument.call(el);
|
|
138646
|
+
const rootStyle = doc && doc.documentElement && window.getComputedStyle(doc.documentElement);
|
|
138647
|
+
if (!rootStyle) return false;
|
|
138648
|
+
const contained = (st) => isSet(st.contain) || paintContained(st);
|
|
138649
|
+
const rootClips = rootStyle.overflowX !== "visible" || rootStyle.overflowY !== "visible";
|
|
138650
|
+
if (!rootClips && !contained(rootStyle) && !contained(style)) return false;
|
|
138651
|
+
}
|
|
138652
|
+
if (el.namespaceURI === "http://www.w3.org/2000/svg") return true;
|
|
138653
|
+
return !isInlineBox(style) && !/^table-(row|column|header|footer)/.test(style.display);
|
|
138654
|
+
}
|
|
138655
|
+
|
|
138656
|
+
// Whether content-visibility: hidden skips an element's content.
|
|
138657
|
+
function skipsContent(el, style) {
|
|
138658
|
+
return (
|
|
138659
|
+
style.display !== "contents" &&
|
|
138660
|
+
style.contentVisibility === "hidden" &&
|
|
138661
|
+
overflowApplies(el, style)
|
|
138662
|
+
);
|
|
138663
|
+
}
|
|
138664
|
+
|
|
138665
|
+
function childClips(el, style, clips, clip, legend) {
|
|
138666
|
+
if (style.display === "contents") return clips;
|
|
138667
|
+
if (skipsContent(el, style)) return clipsWithin(el, style, clips, NO_AREA);
|
|
138668
|
+
let inner = clip;
|
|
138669
|
+
if (overflowApplies(el, style)) {
|
|
138670
|
+
const paint = paintContained(style);
|
|
138671
|
+
const cx = paint || style.overflowX !== "visible";
|
|
138672
|
+
const cy = paint || style.overflowY !== "visible";
|
|
138673
|
+
if (cx || cy) {
|
|
138674
|
+
const p = paddingBox(el, style);
|
|
138675
|
+
if (legend) belowLegend(el, p, style, legend);
|
|
138676
|
+
const ox = style.overflowX;
|
|
138677
|
+
const oy = style.overflowY;
|
|
138678
|
+
const box = {
|
|
138679
|
+
left: cx ? p.left - clipMargin(el, style, ox, "Left") : -Infinity,
|
|
138680
|
+
top: cy ? p.top - clipMargin(el, style, oy, "Top") : -Infinity,
|
|
138681
|
+
right: cx ? p.right + clipMargin(el, style, ox, "Right") : Infinity,
|
|
138682
|
+
bottom: cy ? p.bottom + clipMargin(el, style, oy, "Bottom") : Infinity,
|
|
138683
|
+
};
|
|
138684
|
+
inner = clipBox(clip, p.m, box);
|
|
138685
|
+
// inner.scrollers lists, outermost first, the clippers on the chain that a user
|
|
138686
|
+
// can scroll content past, with the axes they scroll along and the part of their
|
|
138687
|
+
// window the clips above leave showing.
|
|
138688
|
+
const sx =
|
|
138689
|
+
(ox === "auto" || ox === "scroll") && getScrollWidth.call(el) > getClientWidth.call(el);
|
|
138690
|
+
const sy =
|
|
138691
|
+
(oy === "auto" || oy === "scroll") &&
|
|
138692
|
+
getScrollHeight.call(el) > getClientHeight.call(el);
|
|
138693
|
+
const scrollers = clip && clip.scrollers;
|
|
138694
|
+
inner.scrollers =
|
|
138695
|
+
sx || sy
|
|
138696
|
+
? (scrollers || []).concat([{ el, sx, sy, win: mapRect(p.m, box), shown: inner }])
|
|
138697
|
+
: scrollers;
|
|
138698
|
+
}
|
|
138699
|
+
}
|
|
138700
|
+
return clipsWithin(el, style, clips, inner);
|
|
138701
|
+
}
|
|
138702
|
+
|
|
138703
|
+
// The clips children get when \`el\` clips its content to \`inner\`.
|
|
138704
|
+
function clipsWithin(el, style, clips, inner) {
|
|
138705
|
+
const fixedBlock = containsFixed(el, style) || getTagName.call(el) === "foreignObject";
|
|
138706
|
+
return {
|
|
138707
|
+
flow: inner,
|
|
138708
|
+
abs: fixedBlock || style.position !== "static" ? inner : clips.abs,
|
|
138709
|
+
fixed: fixedBlock ? inner : clips.fixed,
|
|
138710
|
+
};
|
|
138711
|
+
}
|
|
138712
|
+
|
|
138713
|
+
// A fieldset's rendered legend, which its overflow never clips: the first <legend>
|
|
138714
|
+
// among its flat-tree children, seen through display:contents boxes (slots included),
|
|
138715
|
+
// that generates a box and is neither floated nor out of flow. A display:contents
|
|
138716
|
+
// fieldset has none; the fieldset around it takes the legend. Under a box that may host
|
|
138717
|
+
// a closed root, which can slot it anywhere in its shadow tree, a legend counts only
|
|
138718
|
+
// where layout put it. A stack, not recursion: those boxes can nest thousands deep.
|
|
138719
|
+
function renderedLegend(el, style) {
|
|
138720
|
+
if (!isHtml(el, "fieldset") || style.display === "contents") return null;
|
|
138721
|
+
const stack = [];
|
|
138722
|
+
const push = (kids, unsure) => {
|
|
138723
|
+
for (let i = kids.length - 1; i >= 0; i--) stack.push([kids[i], unsure]);
|
|
138724
|
+
};
|
|
138725
|
+
push(flatChildElements(el), false);
|
|
138726
|
+
while (stack.length) {
|
|
138727
|
+
const [kid, unsure] = stack.pop();
|
|
138728
|
+
const ks = window.getComputedStyle(kid);
|
|
138729
|
+
if (ks.display === "contents") {
|
|
138730
|
+
push(flatChildElements(kid), unsure || (!getShadowRoot.call(kid) && canHostShadow(kid)));
|
|
138731
|
+
} else if (
|
|
138732
|
+
isHtml(kid, "legend") &&
|
|
138733
|
+
ks.display !== "none" &&
|
|
138734
|
+
ks.cssFloat === "none" &&
|
|
138735
|
+
ks.position !== "absolute" &&
|
|
138736
|
+
ks.position !== "fixed" &&
|
|
138737
|
+
(!unsure || laidOutAsLegend(el, style, kid, ks))
|
|
138738
|
+
) {
|
|
138739
|
+
return kid;
|
|
138740
|
+
}
|
|
138741
|
+
}
|
|
138742
|
+
return null;
|
|
138743
|
+
}
|
|
138744
|
+
|
|
138745
|
+
// Whether layout put legend where a fieldset's rendered legend goes: over its
|
|
138746
|
+
// block-start border, short of the padding its flow content starts past. Offsets,
|
|
138747
|
+
// unlike rects, ignore transforms and scrolling.
|
|
138748
|
+
function laidOutAsLegend(el, style, legend, ls) {
|
|
138749
|
+
const px = (st, prop) => parseFloat(st[prop]) || 0;
|
|
138750
|
+
const op = getOffsetParent.call(legend);
|
|
138751
|
+
// The fieldset's padding edges in the legend's offset coordinates.
|
|
138752
|
+
let left = 0;
|
|
138753
|
+
let top = 0;
|
|
138754
|
+
if (op !== el) {
|
|
138755
|
+
if (!op || op !== getOffsetParent.call(el)) return false;
|
|
138756
|
+
left = getOffsetLeft.call(el) + px(style, "borderLeftWidth");
|
|
138757
|
+
top = getOffsetTop.call(el) + px(style, "borderTopWidth");
|
|
138758
|
+
}
|
|
138759
|
+
const right =
|
|
138760
|
+
left + getOffsetWidth.call(el) - px(style, "borderLeftWidth") - px(style, "borderRightWidth");
|
|
138761
|
+
const rel = ls.position === "relative";
|
|
138762
|
+
const x = getOffsetLeft.call(legend) - (rel ? px(ls, "left") : 0);
|
|
138763
|
+
const y = getOffsetTop.call(legend) - (rel ? px(ls, "top") : 0);
|
|
138764
|
+
const wm = style.writingMode;
|
|
138765
|
+
// How far past the block-start padding edge the legend's border box starts.
|
|
138766
|
+
const [into, pad] =
|
|
138767
|
+
wm === "horizontal-tb"
|
|
138768
|
+
? [y - top, px(style, "paddingTop")]
|
|
138769
|
+
: wm.endsWith("rl")
|
|
138770
|
+
? [right - x - getOffsetWidth.call(legend), px(style, "paddingRight")]
|
|
138771
|
+
: [x - left, px(style, "paddingLeft")];
|
|
138772
|
+
return into < pad;
|
|
138773
|
+
}
|
|
138774
|
+
|
|
138775
|
+
// A fieldset's overflow (but not its paint containment) clips its content no nearer
|
|
138776
|
+
// its block-start side than where its rendered legend's margin box ends, as laid out: the
|
|
138777
|
+
// legend's border box at the fieldset's block-start edge, centred on a thicker border. A
|
|
138778
|
+
// relative or sticky offset or a transform moves only where the legend paints.
|
|
138779
|
+
function belowLegend(el, p, style, legend) {
|
|
138780
|
+
const ls = window.getComputedStyle(legend);
|
|
138781
|
+
const px = (st, prop) => parseFloat(st[prop]) || 0;
|
|
138782
|
+
// How far past the border-box edge the legend's margin box ends, unscaled.
|
|
138783
|
+
const end = (border, size, margin) =>
|
|
138784
|
+
Math.max(0, (px(style, border) - size) / 2) + size + px(ls, margin);
|
|
138785
|
+
const wm = style.writingMode;
|
|
138786
|
+
if (wm === "horizontal-tb") {
|
|
138787
|
+
if (style.overflowY === "visible") return;
|
|
138788
|
+
const h = getOffsetHeight.call(legend);
|
|
138789
|
+
p.top = Math.max(p.top, end("borderTopWidth", h, "marginBottom"));
|
|
138790
|
+
} else if (style.overflowX !== "visible") {
|
|
138791
|
+
const w = getOffsetWidth.call(legend);
|
|
138792
|
+
if (wm.endsWith("rl")) {
|
|
138793
|
+
p.right = Math.min(
|
|
138794
|
+
p.right,
|
|
138795
|
+
getOffsetWidth.call(el) - end("borderRightWidth", w, "marginLeft")
|
|
138796
|
+
);
|
|
138797
|
+
} else {
|
|
138798
|
+
p.left = Math.max(p.left, end("borderLeftWidth", w, "marginRight"));
|
|
138799
|
+
}
|
|
138800
|
+
}
|
|
137086
138801
|
}
|
|
137087
138802
|
|
|
137088
138803
|
// Painted extent of an element's own inline TEXT. A box-less element (display:contents,
|
|
@@ -137091,9 +138806,9 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
137091
138806
|
// text-node children \u2014 NOT selectNodeContents(el) over the whole subtree, which also
|
|
137092
138807
|
// spans the still-laid-out boxes of visibility:hidden / opacity:0 element descendants
|
|
137093
138808
|
// (they keep a layout box but paint nothing), oversizing the frame and mis-placing the
|
|
137094
|
-
// tap point.
|
|
138809
|
+
// tap point. Null when an ancestor transform (e.g. scale(0)) or display:none
|
|
137095
138810
|
// collapses the paint. walk() consults this only when the element has its own text.
|
|
137096
|
-
function
|
|
138811
|
+
function contentBox(el) {
|
|
137097
138812
|
try {
|
|
137098
138813
|
let box = null;
|
|
137099
138814
|
for (const child of getChildNodes.call(el)) {
|
|
@@ -137113,7 +138828,7 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
137113
138828
|
}
|
|
137114
138829
|
}
|
|
137115
138830
|
if (!box || box.right <= box.left || box.bottom <= box.top) return null;
|
|
137116
|
-
return
|
|
138831
|
+
return box;
|
|
137117
138832
|
} catch (e) {
|
|
137118
138833
|
return null;
|
|
137119
138834
|
}
|
|
@@ -137140,17 +138855,199 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
137140
138855
|
// rect; walk() descends and promotes the visible content.
|
|
137141
138856
|
if (style.display === "contents") return false;
|
|
137142
138857
|
if (style.opacity === "0") return true;
|
|
137143
|
-
// visibility:hidden is deliberately NOT hard-pruned here: visibility
|
|
137144
|
-
// descendant can override it back to visible, so cutting the subtree
|
|
137145
|
-
// painted content. walk() descends and suppresses only this element's own
|
|
137146
|
-
// (see \`invisibleSelf\`), pruning it only if no visible descendant survives.
|
|
138858
|
+
// visibility:hidden or collapse is deliberately NOT hard-pruned here: visibility
|
|
138859
|
+
// inherits but a descendant can override it back to visible, so cutting the subtree
|
|
138860
|
+
// would drop painted content. walk() descends and suppresses only this element's own
|
|
138861
|
+
// paint (see \`invisibleSelf\`), pruning it only if no visible descendant survives.
|
|
137147
138862
|
const r = getBCR.call(el);
|
|
137148
138863
|
if (r.width > 0 && r.height > 0) return false;
|
|
137149
138864
|
// Zero-area box: prune it only when it clips its overflow (a collapsed
|
|
137150
|
-
// overflow:hidden container
|
|
137151
|
-
// overflow:visible, abs-positioned / overflowing /
|
|
137152
|
-
// paint, so walk() must descend and promote them
|
|
137153
|
-
|
|
138865
|
+
// overflow:hidden container hides its in-flow content). With the default
|
|
138866
|
+
// overflow:visible, or overflow Chromium ignores, abs-positioned / overflowing /
|
|
138867
|
+
// floated descendants still paint, so walk() must descend and promote them
|
|
138868
|
+
// instead of cutting the subtree.
|
|
138869
|
+
return overflowApplies(el, style) && overflowClips(style);
|
|
138870
|
+
}
|
|
138871
|
+
|
|
138872
|
+
// Whether the page hit-tests el or its content outside \`clip\`, where the clip would
|
|
138873
|
+
// cut it: content slotted into a closed shadow root paints where its unseen slot sits,
|
|
138874
|
+
// which may escape its host's clips. Chrome hit-tests clipped content across its
|
|
138875
|
+
// clippers' borders too, so a point must lie outside their border boxes; and integer
|
|
138876
|
+
// client sizes put a clip edge up to a pixel inside the true one, so more than a pixel
|
|
138877
|
+
// outside.
|
|
138878
|
+
function paintsOutside(el, clip) {
|
|
138879
|
+
const r = getBCR.call(el);
|
|
138880
|
+
const v = intersect(r, { left: 0, top: 0, right: w, bottom: h });
|
|
138881
|
+
// Nothing in view outside the clip to probe.
|
|
138882
|
+
if (v.left >= v.right || v.top >= v.bottom) return false;
|
|
138883
|
+
if (
|
|
138884
|
+
v.left >= clip.left &&
|
|
138885
|
+
v.right <= clip.right &&
|
|
138886
|
+
v.top >= clip.top &&
|
|
138887
|
+
v.bottom <= clip.bottom
|
|
138888
|
+
) {
|
|
138889
|
+
return false;
|
|
138890
|
+
}
|
|
138891
|
+
if (laidOutByParent(el, r)) return false;
|
|
138892
|
+
const b = clipperBorders(getParentNode.call(el)) || clip;
|
|
138893
|
+
const e = {
|
|
138894
|
+
left: Math.min(clip.left, b.left) - 1,
|
|
138895
|
+
top: Math.min(clip.top, b.top) - 1,
|
|
138896
|
+
right: Math.max(clip.right, b.right) + 1,
|
|
138897
|
+
bottom: Math.max(clip.bottom, b.bottom) + 1,
|
|
138898
|
+
};
|
|
138899
|
+
const cx = (v.left + v.right) / 2;
|
|
138900
|
+
const cy = (v.top + v.bottom) / 2;
|
|
138901
|
+
return [
|
|
138902
|
+
[(v.left + Math.min(v.right, e.left)) / 2, cy],
|
|
138903
|
+
[(Math.max(v.left, e.right) + v.right) / 2, cy],
|
|
138904
|
+
[cx, (v.top + Math.min(v.bottom, e.top)) / 2],
|
|
138905
|
+
[cx, (Math.max(v.top, e.bottom) + v.bottom) / 2],
|
|
138906
|
+
].some(
|
|
138907
|
+
([x, y]) =>
|
|
138908
|
+
x >= v.left &&
|
|
138909
|
+
x < v.right &&
|
|
138910
|
+
y >= v.top &&
|
|
138911
|
+
y < v.bottom &&
|
|
138912
|
+
(x < e.left || x >= e.right || y < e.top || y >= e.bottom) &&
|
|
138913
|
+
carriesHit(el, x, y)
|
|
138914
|
+
);
|
|
138915
|
+
}
|
|
138916
|
+
|
|
138917
|
+
// Whether layout shows el where its parent's box puts it, so no closed root slotted it
|
|
138918
|
+
// past the clips; this spares a hit test, a pass over every paint layer. offsetParent
|
|
138919
|
+
// skips a closed tree's boxes, and past a fixed one gives that box's offsetParent, so
|
|
138920
|
+
// a box containing absolute descendants is el's offsetParent unless a closed root put
|
|
138921
|
+
// el in a fixed or top-layer box, the only way out of that box's clips. Under any other
|
|
138922
|
+
// box, el must lie in its border box or scrollable overflow and name no slot. Missed:
|
|
138923
|
+
// default-slotted content a closed root's absolute box (or a fixed box a transform
|
|
138924
|
+
// contains) shows within that overflow.
|
|
138925
|
+
function laidOutByParent(el, r) {
|
|
138926
|
+
if (!(el instanceof HTMLElement)) return false;
|
|
138927
|
+
const op = getOffsetParent.call(el);
|
|
138928
|
+
if (!op) return false;
|
|
138929
|
+
const parent = parentBox(getParentNode.call(el));
|
|
138930
|
+
const o = parent.overflow;
|
|
138931
|
+
if (!o) return op === parent.box;
|
|
138932
|
+
if (hasAttr.call(el, "slot")) return false;
|
|
138933
|
+
return r.left >= o.left && r.top >= o.top && r.right <= o.right && r.bottom <= o.bottom;
|
|
138934
|
+
}
|
|
138935
|
+
|
|
138936
|
+
// The box n's children lie in and, unless it contains absolute descendants, its border
|
|
138937
|
+
// box and scrollable overflow in viewport px. Memoized: siblings share it.
|
|
138938
|
+
const parentBoxes = nodeMap();
|
|
138939
|
+
function parentBox(n) {
|
|
138940
|
+
if (parentBoxes.has(n)) return parentBoxes.get(n);
|
|
138941
|
+
let box = n;
|
|
138942
|
+
let style = window.getComputedStyle(box);
|
|
138943
|
+
while (style.display === "contents") {
|
|
138944
|
+
box = flatParent(box);
|
|
138945
|
+
style = window.getComputedStyle(box);
|
|
138946
|
+
}
|
|
138947
|
+
const found = { box, overflow: null };
|
|
138948
|
+
if (style.position === "static" && !containsFixed(box, style)) {
|
|
138949
|
+
const p = paddingBox(box, style);
|
|
138950
|
+
const b = getBCR.call(box);
|
|
138951
|
+
const left = p.left - getScrollLeft.call(box);
|
|
138952
|
+
const top = p.top - getScrollTop.call(box);
|
|
138953
|
+
const s = mapRect(p.m, {
|
|
138954
|
+
left,
|
|
138955
|
+
top,
|
|
138956
|
+
right: left + getScrollWidth.call(box),
|
|
138957
|
+
bottom: top + getScrollHeight.call(box),
|
|
138958
|
+
});
|
|
138959
|
+
// Integer scroll sizes, like client sizes, put an edge up to a pixel short.
|
|
138960
|
+
found.overflow = {
|
|
138961
|
+
left: Math.min(b.left, s.left) - 1,
|
|
138962
|
+
top: Math.min(b.top, s.top) - 1,
|
|
138963
|
+
right: Math.max(b.right, s.right) + 1,
|
|
138964
|
+
bottom: Math.max(b.bottom, s.bottom) + 1,
|
|
138965
|
+
};
|
|
138966
|
+
}
|
|
138967
|
+
parentBoxes.set(n, found);
|
|
138968
|
+
return found;
|
|
138969
|
+
}
|
|
138970
|
+
|
|
138971
|
+
// Whether attachShadow accepts el: a custom element or one of the DOM spec's listed
|
|
138972
|
+
// HTML elements.
|
|
138973
|
+
function canHostShadow(el) {
|
|
138974
|
+
if (getNamespaceURI.call(el) !== "http://www.w3.org/1999/xhtml") return false;
|
|
138975
|
+
const name = getLocalName.call(el);
|
|
138976
|
+
return (
|
|
138977
|
+
name.includes("-") ||
|
|
138978
|
+
/^(article|aside|blockquote|body|div|footer|h[1-6]|header|main|nav|p|section|span)$/.test(
|
|
138979
|
+
name
|
|
138980
|
+
)
|
|
138981
|
+
);
|
|
138982
|
+
}
|
|
138983
|
+
|
|
138984
|
+
function isHtml(el, name) {
|
|
138985
|
+
return (
|
|
138986
|
+
getLocalName.call(el) === name && getNamespaceURI.call(el) === "http://www.w3.org/1999/xhtml"
|
|
138987
|
+
);
|
|
138988
|
+
}
|
|
138989
|
+
|
|
138990
|
+
// The border boxes of n and its flat-tree ancestors that clip their content,
|
|
138991
|
+
// intersected; null when none does. Memoized: siblings share every ancestor.
|
|
138992
|
+
const clipperBoxes = nodeMap();
|
|
138993
|
+
function clipperBorders(n) {
|
|
138994
|
+
if (!n || getNodeType.call(n) !== 1) return null;
|
|
138995
|
+
if (clipperBoxes.has(n)) return clipperBoxes.get(n);
|
|
138996
|
+
const st = window.getComputedStyle(n);
|
|
138997
|
+
const own =
|
|
138998
|
+
overflowApplies(n, st) && (overflowClips(st) || paintContained(st)) ? getBCR.call(n) : null;
|
|
138999
|
+
const borders = intersect(clipperBorders(flatParent(n)), own);
|
|
139000
|
+
clipperBoxes.set(n, borders);
|
|
139001
|
+
return borders;
|
|
139002
|
+
}
|
|
139003
|
+
|
|
139004
|
+
// The elements hit at (x, y) in root's tree and the open shadow trees under it. A tree
|
|
139005
|
+
// lists a host for anything its shadow tree paints, a fixed popup included, so each
|
|
139006
|
+
// host gives way to its shadow root's hits, which list it only where its own box is
|
|
139007
|
+
// hit; the rest of root's tree there is root's own list's.
|
|
139008
|
+
function hitsAt(root, x, y) {
|
|
139009
|
+
const hits = [];
|
|
139010
|
+
for (const hit of elementsAt(root, x, y)) {
|
|
139011
|
+
const sr = getRootNode.call(hit) === root && getShadowRoot.call(hit);
|
|
139012
|
+
if (!sr) {
|
|
139013
|
+
hits.push(hit);
|
|
139014
|
+
continue;
|
|
139015
|
+
}
|
|
139016
|
+
for (const n of hitsAt(sr, x, y)) {
|
|
139017
|
+
if (n === hit || getRootNode.call(n) !== root) hits.push(n);
|
|
139018
|
+
}
|
|
139019
|
+
}
|
|
139020
|
+
return hits;
|
|
139021
|
+
}
|
|
139022
|
+
|
|
139023
|
+
// Whether an element hit at (x, y) is in el's flat tree and el's own painting puts it
|
|
139024
|
+
// there: no box between them is fixed or absolute, which would paint by its own
|
|
139025
|
+
// containing block, escaping el's clips. Each point's carriers are found once: stacked
|
|
139026
|
+
// content probes the same points.
|
|
139027
|
+
const carriersAt = Object.create(null);
|
|
139028
|
+
function carriesHit(el, x, y) {
|
|
139029
|
+
const key = x + "," + y;
|
|
139030
|
+
let carriers = carriersAt[key];
|
|
139031
|
+
if (!carriers) {
|
|
139032
|
+
carriers = carriersAt[key] = nodeMap();
|
|
139033
|
+
// A loop, not recursion: a hit can sit under thousands of display:contents boxes.
|
|
139034
|
+
for (const hit of hitsAt(document, x, y)) {
|
|
139035
|
+
for (let n = hit; n && !carriers.has(n); n = carrierParent(n)) carriers.set(n, true);
|
|
139036
|
+
}
|
|
139037
|
+
}
|
|
139038
|
+
return carriers.has(el);
|
|
139039
|
+
}
|
|
139040
|
+
|
|
139041
|
+
// The element that carries whatever n carries: its flat parent, unless n is fixed or
|
|
139042
|
+
// absolute. Memoized: every probe point can hit a page's whole ancestor stack.
|
|
139043
|
+
const carrierParents = nodeMap();
|
|
139044
|
+
function carrierParent(n) {
|
|
139045
|
+
if (carrierParents.has(n)) return carrierParents.get(n);
|
|
139046
|
+
const position = window.getComputedStyle(n).position;
|
|
139047
|
+
const p = position === "fixed" || position === "absolute" ? null : flatParent(n);
|
|
139048
|
+
const carrier = p && getNodeType.call(p) === 1 ? p : null;
|
|
139049
|
+
carrierParents.set(n, carrier);
|
|
139050
|
+
return carrier;
|
|
137154
139051
|
}
|
|
137155
139052
|
|
|
137156
139053
|
// Smallest normalized box covering every surviving child frame \u2014 the frame we give
|
|
@@ -137161,6 +139058,8 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
137161
139058
|
let maxRight = 0;
|
|
137162
139059
|
let maxBottom = 0;
|
|
137163
139060
|
for (const c of children) {
|
|
139061
|
+
// A child clipped or scrolled out of view has no extent to cover.
|
|
139062
|
+
if (c.frame.width <= 0 || c.frame.height <= 0) continue;
|
|
137164
139063
|
minX = Math.min(minX, c.frame.x);
|
|
137165
139064
|
minY = Math.min(minY, c.frame.y);
|
|
137166
139065
|
maxRight = Math.max(maxRight, c.frame.x + c.frame.width);
|
|
@@ -137172,20 +139071,24 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
137172
139071
|
return { x: minX, y: minY, width: maxRight - minX, height: maxBottom - minY };
|
|
137173
139072
|
}
|
|
137174
139073
|
|
|
137175
|
-
function walk(el, depth) {
|
|
139074
|
+
function walk(el, depth, clips = NO_CLIP, unseenSlot = false, base = IDENTITY) {
|
|
137176
139075
|
if (truncated) return null;
|
|
137177
139076
|
if (depth > MAX_DEPTH) return null;
|
|
137178
139077
|
if (!(el instanceof Element)) return null;
|
|
137179
139078
|
const style = window.getComputedStyle(el);
|
|
137180
|
-
|
|
139079
|
+
const t = linearTransform(el, style, base);
|
|
139080
|
+
if (hidden(el, style)) {
|
|
139081
|
+
pruned.set(el, clips);
|
|
139082
|
+
return null;
|
|
139083
|
+
}
|
|
137181
139084
|
// Charge the node budget only for elements that can actually EMIT. A
|
|
137182
|
-
// visibility:hidden element paints nothing itself and is descended
|
|
137183
|
-
// purely to catch a descendant that overrides visibility back to visible
|
|
139085
|
+
// visibility:hidden or collapse element paints nothing itself and is descended
|
|
139086
|
+
// into purely to catch a descendant that overrides visibility back to visible
|
|
137184
139087
|
// (see hidden()); it is otherwise promoted/dropped. Counting it would let a
|
|
137185
139088
|
// large fully-hidden subtree (a closed drawer/modal) exhaust the budget and
|
|
137186
139089
|
// truncate genuinely visible content elsewhere in the tree. Its visible
|
|
137187
139090
|
// descendants, if any, still consume the budget themselves.
|
|
137188
|
-
if (style.visibility
|
|
139091
|
+
if (style.visibility === "visible") {
|
|
137189
139092
|
if (nodeBudget <= 0) {
|
|
137190
139093
|
truncated = true;
|
|
137191
139094
|
return null;
|
|
@@ -137193,11 +139096,18 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
137193
139096
|
nodeBudget--;
|
|
137194
139097
|
}
|
|
137195
139098
|
|
|
137196
|
-
|
|
137197
|
-
|
|
137198
|
-
|
|
137199
|
-
|
|
139099
|
+
if (inTopLayer(el, style)) clips = NO_CLIP;
|
|
139100
|
+
let clip = ownClip(clips, style);
|
|
139101
|
+
if (unseenSlot && clip && paintsOutside(el, clip)) {
|
|
139102
|
+
clips = NO_CLIP;
|
|
139103
|
+
clip = null;
|
|
137200
139104
|
}
|
|
139105
|
+
const kids = getChildrenEls.call(el);
|
|
139106
|
+
const legend = renderedLegend(el, style);
|
|
139107
|
+
if (legend) legendClips.set(legend, clipsWithin(el, style, clips, clip));
|
|
139108
|
+
const inner = childClips(el, style, clips, clip, legend);
|
|
139109
|
+
if (htmlTag(el) === "SLOT") slotClips.set(el, inner);
|
|
139110
|
+
chains.set(el, inner.flow && inner.flow.scrollers);
|
|
137201
139111
|
|
|
137202
139112
|
// Pierce open shadow roots \u2014 closed roots are unreachable by design.
|
|
137203
139113
|
// Web-components-heavy apps (VS Code, every Lit/Polymer SPA) put their
|
|
@@ -137207,36 +139117,57 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
137207
139117
|
// would otherwise return that control, and we'd re-walk its light-DOM children as
|
|
137208
139118
|
// shadow content and duplicate the subtree. A real ShadowRoot is a DocumentFragment
|
|
137209
139119
|
// (never a form), so its own .children read is safe.
|
|
139120
|
+
const shadowResults = [];
|
|
137210
139121
|
const shadow = getShadowRoot.call(el);
|
|
137211
139122
|
if (shadow) {
|
|
137212
139123
|
for (const child of shadow.children) {
|
|
137213
|
-
const
|
|
137214
|
-
|
|
139124
|
+
const kidClips = legendClips.has(child) ? legendClips.get(child) : inner;
|
|
139125
|
+
const c = walk(child, depth + 1, kidClips, false, t);
|
|
139126
|
+
if (c) shadowResults.push(c);
|
|
137215
139127
|
}
|
|
137216
139128
|
}
|
|
137217
139129
|
|
|
137218
|
-
|
|
137219
|
-
//
|
|
137220
|
-
//
|
|
137221
|
-
|
|
137222
|
-
|
|
137223
|
-
|
|
137224
|
-
|
|
137225
|
-
|
|
137226
|
-
|
|
137227
|
-
|
|
137228
|
-
|
|
137229
|
-
|
|
139130
|
+
const childResults = [];
|
|
139131
|
+
// An element with no open shadow root may have a closed one, whose slots the walker
|
|
139132
|
+
// cannot see.
|
|
139133
|
+
const closedHost = !shadow && canHostShadow(el);
|
|
139134
|
+
// A closed <details> lays out only its first <summary> child.
|
|
139135
|
+
const closed = isHtml(el, "details") && closedDetails(el);
|
|
139136
|
+
const summary = closed ? Array.prototype.find.call(kids, (k) => isHtml(k, "summary")) : null;
|
|
139137
|
+
for (let i = 0; i < kids.length; i++) {
|
|
139138
|
+
const slot = getAssignedSlot.call(kids[i]);
|
|
139139
|
+
const unwalked = slot && !slotClips.has(slot) ? prunedSlotClips(slot) : undefined;
|
|
139140
|
+
// Of what a slot in a pruned element holds, only content escaping its clips paints.
|
|
139141
|
+
const shown = unwalked && ownClip(unwalked, window.getComputedStyle(kids[i]));
|
|
139142
|
+
if (
|
|
139143
|
+
unwalked === null ||
|
|
139144
|
+
(shown && (shown.right <= shown.left || shown.bottom <= shown.top))
|
|
139145
|
+
) {
|
|
139146
|
+
continue;
|
|
137230
139147
|
}
|
|
139148
|
+
const kidClips =
|
|
139149
|
+
closed && kids[i] !== summary
|
|
139150
|
+
? SKIPPED
|
|
139151
|
+
: inPicker(el, kids[i], i)
|
|
139152
|
+
? NO_CLIP
|
|
139153
|
+
: legendClips.has(kids[i])
|
|
139154
|
+
? legendClips.get(kids[i])
|
|
139155
|
+
: slot && slotClips.has(slot)
|
|
139156
|
+
? slotClips.get(slot)
|
|
139157
|
+
: unwalked || inner;
|
|
139158
|
+
const kidBase = slot ? linears.get(slot) : t;
|
|
139159
|
+
const c = walk(kids[i], depth + 1, kidClips, closedHost && !slot, kidBase);
|
|
139160
|
+
if (c) childResults.push(c);
|
|
137231
139161
|
}
|
|
139162
|
+
childResults.push(...shadowResults);
|
|
137232
139163
|
|
|
137233
|
-
// A visibility:hidden element paints nothing itself, but a descendant can
|
|
137234
|
-
// visibility back to visible, so walk() descended instead of pruning (see
|
|
137235
|
-
// Suppress this element's own paint \u2014 its text / name / interactivity are
|
|
137236
|
-
// and treat it as box-less so it contributes no box of its own: it
|
|
137237
|
-
// through, and is framed by, whatever visible descendants it has.
|
|
137238
|
-
const invisibleSelf = style.visibility
|
|
137239
|
-
const text = invisibleSelf ? "" : ownText(el);
|
|
139164
|
+
// A visibility:hidden or collapse element paints nothing itself, but a descendant can
|
|
139165
|
+
// override visibility back to visible, so walk() descended instead of pruning (see
|
|
139166
|
+
// hidden()). Suppress this element's own paint \u2014 its text / name / interactivity are
|
|
139167
|
+
// invisible \u2014 and treat it as box-less so it contributes no box of its own: it
|
|
139168
|
+
// survives only through, and is framed by, whatever visible descendants it has.
|
|
139169
|
+
const invisibleSelf = style.visibility !== "visible";
|
|
139170
|
+
const text = invisibleSelf || closed || skipsContent(el, style) ? "" : ownText(el, style);
|
|
137240
139171
|
const name = invisibleSelf ? null : accessibleName(el);
|
|
137241
139172
|
const clickable = invisibleSelf ? false : isInteractive(el);
|
|
137242
139173
|
const role = nodeRole(el);
|
|
@@ -137264,11 +139195,31 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
137264
139195
|
// child. (Clickable / named / identified box-less nodes fall through and are emitted
|
|
137265
139196
|
// with this child- or content-spanning frame.)
|
|
137266
139197
|
let selfFrame;
|
|
139198
|
+
let clipBounds;
|
|
139199
|
+
let cut;
|
|
139200
|
+
const scs = clip && clip.scrollers;
|
|
139201
|
+
// Unclipped extent: a box-less element's spans its children under the same scrollers.
|
|
139202
|
+
let r = null;
|
|
137267
139203
|
if (bl) {
|
|
137268
139204
|
selfFrame = unionFrame(childResults);
|
|
139205
|
+
for (const c of scs ? childResults : []) {
|
|
139206
|
+
const e = extents.get(c);
|
|
139207
|
+
if (!e || e.scs !== scs) continue;
|
|
139208
|
+
r = !r
|
|
139209
|
+
? e.r
|
|
139210
|
+
: {
|
|
139211
|
+
left: Math.min(r.left, e.r.left),
|
|
139212
|
+
top: Math.min(r.top, e.r.top),
|
|
139213
|
+
right: Math.max(r.right, e.r.right),
|
|
139214
|
+
bottom: Math.max(r.bottom, e.r.bottom),
|
|
139215
|
+
};
|
|
139216
|
+
}
|
|
137269
139217
|
if (text && selfFrame.width <= 0 && selfFrame.height <= 0) {
|
|
137270
|
-
const
|
|
137271
|
-
if (
|
|
139218
|
+
const box = contentBox(el);
|
|
139219
|
+
if (box) {
|
|
139220
|
+
selfFrame = normRect(visibleBox(null, style, box, clip));
|
|
139221
|
+
r = box;
|
|
139222
|
+
}
|
|
137272
139223
|
}
|
|
137273
139224
|
if (childResults.length === 0 && selfFrame.width <= 0 && selfFrame.height <= 0) {
|
|
137274
139225
|
return null;
|
|
@@ -137290,7 +139241,31 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
137290
139241
|
return childResults[0];
|
|
137291
139242
|
}
|
|
137292
139243
|
} else {
|
|
137293
|
-
|
|
139244
|
+
r = getBCR.call(el);
|
|
139245
|
+
selfFrame = normRect(visibleBox(el, style, r, clip));
|
|
139246
|
+
}
|
|
139247
|
+
if (scs && r && selfFrame.width > 0 && selfFrame.height > 0) {
|
|
139248
|
+
// Integer client sizes put a clip edge up to a pixel inside the true one.
|
|
139249
|
+
const cutsX = scs.filter(
|
|
139250
|
+
(s) => s.sx && (s.win.left > r.left + 1 || s.win.right < r.right - 1)
|
|
139251
|
+
);
|
|
139252
|
+
const cutsY = scs.filter(
|
|
139253
|
+
(s) => s.sy && (s.win.top > r.top + 1 || s.win.bottom < r.bottom - 1)
|
|
139254
|
+
);
|
|
139255
|
+
if (cutsX.length || cutsY.length) {
|
|
139256
|
+
// The part of each cutter's window that the clips above it leave showing.
|
|
139257
|
+
const win = {
|
|
139258
|
+
left: Math.max(0, ...cutsX.map((s) => s.shown.left)),
|
|
139259
|
+
top: Math.max(0, ...cutsY.map((s) => s.shown.top)),
|
|
139260
|
+
right: Math.min(w, ...cutsX.map((s) => s.shown.right)),
|
|
139261
|
+
bottom: Math.min(h, ...cutsY.map((s) => s.shown.bottom)),
|
|
139262
|
+
};
|
|
139263
|
+
clipBounds = normRect(win);
|
|
139264
|
+
const vis = intersect(visibleBox(bl ? null : el, style, r, clip), {
|
|
139265
|
+
left: 0, top: 0, right: w, bottom: h,
|
|
139266
|
+
});
|
|
139267
|
+
cut = { r: vis, scs, win, cutsX, cutsY };
|
|
139268
|
+
}
|
|
137294
139269
|
}
|
|
137295
139270
|
|
|
137296
139271
|
const scrollable = isScrollable(el, style);
|
|
@@ -137316,6 +139291,11 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
137316
139291
|
frame: selfFrame,
|
|
137317
139292
|
children: childResults,
|
|
137318
139293
|
};
|
|
139294
|
+
if (scs && r) extents.set(node, { r, scs });
|
|
139295
|
+
if (clipBounds) {
|
|
139296
|
+
node.clipBounds = clipBounds;
|
|
139297
|
+
if (cut) cuts.push({ ...cut, node });
|
|
139298
|
+
}
|
|
137319
139299
|
if (name) node.label = name;
|
|
137320
139300
|
if (text && text !== name) node.value = text.slice(0, 200);
|
|
137321
139301
|
if (id) node.identifier = id;
|
|
@@ -137323,16 +139303,18 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
137323
139303
|
if (isDisabled(el)) node.disabled = true;
|
|
137324
139304
|
if (isChecked(el)) node.checked = true;
|
|
137325
139305
|
if (isPassword(el)) node.password = true;
|
|
137326
|
-
if (scrollable)
|
|
139306
|
+
if (scrollable) {
|
|
139307
|
+
node.scrollable = true;
|
|
139308
|
+
if (inner.flow) node.clipFrame = normRect(inner.flow);
|
|
139309
|
+
}
|
|
137327
139310
|
// Input focus: el is its document's activeElement. Deliberately emitted to
|
|
137328
139311
|
// EVERY describe consumer (the agent-facing tool as much as the flow type
|
|
137329
139312
|
// directive's focus wait) \u2014 where the caret is is useful targeting info.
|
|
137330
139313
|
// The body is excluded \u2014 it's the default holder when nothing is focused,
|
|
137331
139314
|
// and its screen-spanning frame would satisfy any overlap check. A host
|
|
137332
139315
|
// <iframe>/<frame> is excluded too: it is the outer document's
|
|
137333
|
-
// activeElement whenever focus merely sits inside its
|
|
137334
|
-
//
|
|
137335
|
-
// is the one that carries the flag \u2014 flagging both would double-report.
|
|
139316
|
+
// activeElement whenever focus merely sits anywhere inside its
|
|
139317
|
+
// subdocument, so it does not mark where the caret is.
|
|
137336
139318
|
if (!invisibleSelf) {
|
|
137337
139319
|
const tag = getTagName.call(el);
|
|
137338
139320
|
if (tag !== "IFRAME" && tag !== "FRAME") {
|
|
@@ -137350,6 +139332,11 @@ var buildDescribeDomScript = ({ maxDepth, maxNodes }) => `(() => {
|
|
|
137350
139332
|
frame: { x: 0, y: 0, width: 1, height: 1 },
|
|
137351
139333
|
children: [],
|
|
137352
139334
|
};
|
|
139335
|
+
for (const { node, r, scs, win, cutsX, cutsY } of cuts) {
|
|
139336
|
+
node.clipAnchors = {};
|
|
139337
|
+
if (cutsX.length) node.clipAnchors.x = wheelAnchor(r, scs, cutsX, win, "sx");
|
|
139338
|
+
if (cutsY.length) node.clipAnchors.y = wheelAnchor(r, scs, cutsY, win, "sy");
|
|
139339
|
+
}
|
|
137353
139340
|
return JSON.stringify({ tree: root, truncated });
|
|
137354
139341
|
})()`;
|
|
137355
139342
|
var DESCRIBE_DOM_SCRIPT = buildDescribeDomScript(DEFAULT_WALK_LIMITS);
|
|
@@ -137405,6 +139392,9 @@ async function describeChromium(api, limits = DEFAULT_WALK_LIMITS) {
|
|
|
137405
139392
|
return data;
|
|
137406
139393
|
}
|
|
137407
139394
|
|
|
139395
|
+
// ../tool-server/src/tools/describe/platforms/vega.ts
|
|
139396
|
+
init_src2();
|
|
139397
|
+
|
|
137408
139398
|
// ../tool-server/src/utils/vega-inspect.ts
|
|
137409
139399
|
var import_node_http3 = require("node:http");
|
|
137410
139400
|
init_adb();
|
|
@@ -141912,12 +143902,18 @@ var EMPTY_TREE = {
|
|
|
141912
143902
|
};
|
|
141913
143903
|
var UNAVAILABLE_HINT = "No UI tree from the Vega automation toolkit. The toolkit attaches at app launch \u2014 relaunch the foreground app (e.g. via restart-app) and call describe again.";
|
|
141914
143904
|
var PAGE_SOURCE_EMPTY_LENGTH = 50;
|
|
143905
|
+
var DISCOVERY_FAILURES = /* @__PURE__ */ new Set([
|
|
143906
|
+
FAILURE_CODES.VEGA_DEVICE_NOT_FOUND,
|
|
143907
|
+
FAILURE_CODES.VEGA_DEVICE_NOT_REGISTERED,
|
|
143908
|
+
FAILURE_CODES.VEGA_MULTIPLE_DEVICES
|
|
143909
|
+
]);
|
|
141915
143910
|
async function describeVega(_serial) {
|
|
141916
143911
|
let xml;
|
|
141917
143912
|
try {
|
|
141918
143913
|
xml = (await fetchVegaPageSource()).trim();
|
|
141919
143914
|
} catch (err) {
|
|
141920
|
-
|
|
143915
|
+
const code = getFailureSignal(err)?.error_code;
|
|
143916
|
+
if (code && DISCOVERY_FAILURES.has(code)) throw err;
|
|
141921
143917
|
return { tree: EMPTY_TREE, source: "vega-automation", hint: UNAVAILABLE_HINT };
|
|
141922
143918
|
}
|
|
141923
143919
|
if (xml.length < PAGE_SOURCE_EMPTY_LENGTH) {
|
|
@@ -143505,37 +145501,6 @@ init_capability();
|
|
|
143505
145501
|
var import_pngjs = __toESM(require_png());
|
|
143506
145502
|
|
|
143507
145503
|
// ../tool-server/src/tools/screenshot-diff/resize.ts
|
|
143508
|
-
var ASPECT_RATIO_TOLERANCE = 0.01;
|
|
143509
|
-
function normalizeToCommonSize(baseline, current) {
|
|
143510
|
-
if (baseline.width === current.width && baseline.height === current.height) {
|
|
143511
|
-
return { baseline, current };
|
|
143512
|
-
}
|
|
143513
|
-
if (!aspectRatiosMatch(baseline, current)) {
|
|
143514
|
-
return null;
|
|
143515
|
-
}
|
|
143516
|
-
const baselineArea = baseline.width * baseline.height;
|
|
143517
|
-
const currentArea = current.width * current.height;
|
|
143518
|
-
if (baselineArea <= currentArea) {
|
|
143519
|
-
return {
|
|
143520
|
-
baseline,
|
|
143521
|
-
current: resizeDecodedPng(current, baseline.width, baseline.height)
|
|
143522
|
-
};
|
|
143523
|
-
}
|
|
143524
|
-
return {
|
|
143525
|
-
baseline: resizeDecodedPng(baseline, current.width, current.height),
|
|
143526
|
-
current
|
|
143527
|
-
};
|
|
143528
|
-
}
|
|
143529
|
-
function aspectRatiosMatch(a, b) {
|
|
143530
|
-
if (a.width <= 0 || a.height <= 0 || b.width <= 0 || b.height <= 0) {
|
|
143531
|
-
return false;
|
|
143532
|
-
}
|
|
143533
|
-
const aspectA = a.width / a.height;
|
|
143534
|
-
const aspectB = b.width / b.height;
|
|
143535
|
-
const largest = Math.max(aspectA, aspectB);
|
|
143536
|
-
if (largest === 0) return false;
|
|
143537
|
-
return Math.abs(aspectA - aspectB) / largest <= ASPECT_RATIO_TOLERANCE;
|
|
143538
|
-
}
|
|
143539
145504
|
function resizeDecodedPng(src, width, height) {
|
|
143540
145505
|
const targetWidth = Math.max(1, Math.round(width));
|
|
143541
145506
|
const targetHeight = Math.max(1, Math.round(height));
|
|
@@ -144759,7 +146724,7 @@ function exactFieldCount(node2, selector, fullTextRegex) {
|
|
|
144759
146724
|
if (selector.role !== void 0 && equalsCI(node2.role, selector.role)) count2++;
|
|
144760
146725
|
return count2;
|
|
144761
146726
|
}
|
|
144762
|
-
function
|
|
146727
|
+
function selectorToNode(root, selector) {
|
|
144763
146728
|
const visible = frontmost(findAll(root, selector).filter(isVisible));
|
|
144764
146729
|
if (visible.length === 0) return void 0;
|
|
144765
146730
|
if (!hasOwnConstraint(selector)) {
|
|
@@ -144767,7 +146732,7 @@ function selectorToFrame(root, selector) {
|
|
|
144767
146732
|
for (const n of visible) {
|
|
144768
146733
|
if (first === void 0 || compareBelowPick(n.frame, first.frame) < 0) first = n;
|
|
144769
146734
|
}
|
|
144770
|
-
return first
|
|
146735
|
+
return first;
|
|
144771
146736
|
}
|
|
144772
146737
|
const fullTextRegex = fullConsumptionRegex(selector);
|
|
144773
146738
|
let best;
|
|
@@ -144788,7 +146753,10 @@ function selectorToFrame(root, selector) {
|
|
|
144788
146753
|
best = n;
|
|
144789
146754
|
}
|
|
144790
146755
|
}
|
|
144791
|
-
return best
|
|
146756
|
+
return best;
|
|
146757
|
+
}
|
|
146758
|
+
function selectorToFrame(root, selector) {
|
|
146759
|
+
return selectorToNode(root, selector)?.frame;
|
|
144792
146760
|
}
|
|
144793
146761
|
var GENERIC_ROLES = /* @__PURE__ */ new Set([
|
|
144794
146762
|
"axgroup",
|
|
@@ -145161,12 +147129,15 @@ var STALE_LOG_MS = 24 * 60 * 60 * 1e3;
|
|
|
145161
147129
|
var CLUSTER_KEY_LENGTH = 80;
|
|
145162
147130
|
var SOURCE_EXT = /\.(tsx?|jsx?|mjs|cjs)$/;
|
|
145163
147131
|
var LINE_RE = /^\[L:(\d+)\] (\S+) (\S+)\s+(\S+) \| (.*)$/;
|
|
147132
|
+
var CAMEL_LEVELS = ["startGroup", "startGroupCollapsed", "endGroup", "profileEnd", "timeEnd"];
|
|
145164
147133
|
var liveLogFiles = /* @__PURE__ */ new Set();
|
|
145165
147134
|
var LogFileWriter = class {
|
|
145166
147135
|
filePath;
|
|
145167
147136
|
fd = null;
|
|
145168
147137
|
bytesWritten = 0;
|
|
145169
147138
|
entryCount = 0;
|
|
147139
|
+
fileEntryCount = 0;
|
|
147140
|
+
midLine = false;
|
|
145170
147141
|
levelCounts = {};
|
|
145171
147142
|
clusters = /* @__PURE__ */ new Map();
|
|
145172
147143
|
ready = false;
|
|
@@ -145174,7 +147145,10 @@ var LogFileWriter = class {
|
|
|
145174
147145
|
constructor(port) {
|
|
145175
147146
|
const timestamp = Date.now();
|
|
145176
147147
|
const dir = path34.join(os16.homedir(), ".argent", "tmp");
|
|
145177
|
-
|
|
147148
|
+
try {
|
|
147149
|
+
fs40.mkdirSync(dir, { recursive: true });
|
|
147150
|
+
} catch {
|
|
147151
|
+
}
|
|
145178
147152
|
pruneStaleLogs(dir);
|
|
145179
147153
|
this.filePath = path34.join(dir, `argent-logs-${port}-${timestamp}-p${process.pid}.log`);
|
|
145180
147154
|
liveLogFiles.add(this.filePath);
|
|
@@ -145205,10 +147179,20 @@ var LogFileWriter = class {
|
|
|
145205
147179
|
const line = `[L:${entry.id}] ${entry.timestamp} ${levelDisplay} ${source} | ${flatMessage}
|
|
145206
147180
|
`;
|
|
145207
147181
|
if (this.ready && this.fd !== null) {
|
|
145208
|
-
|
|
145209
|
-
|
|
147182
|
+
try {
|
|
147183
|
+
const bytes = Buffer.from(this.midLine ? `
|
|
147184
|
+
${line}` : line);
|
|
147185
|
+
const written = fs40.writeSync(this.fd, bytes, 0, bytes.length, this.bytesWritten);
|
|
147186
|
+
if (written === bytes.length) {
|
|
147187
|
+
this.bytesWritten += written;
|
|
147188
|
+
this.midLine = false;
|
|
147189
|
+
this.fileEntryCount++;
|
|
147190
|
+
} else {
|
|
147191
|
+
this.dropTornLine(this.fd, bytes, written);
|
|
147192
|
+
}
|
|
147193
|
+
} catch {
|
|
147194
|
+
}
|
|
145210
147195
|
}
|
|
145211
|
-
this.bytesWritten += Buffer.byteLength(line);
|
|
145212
147196
|
this.entryCount++;
|
|
145213
147197
|
this.levelCounts[entry.level] = (this.levelCounts[entry.level] || 0) + 1;
|
|
145214
147198
|
const key2 = entry.message.slice(0, CLUSTER_KEY_LENGTH);
|
|
@@ -145229,9 +147213,25 @@ var LogFileWriter = class {
|
|
|
145229
147213
|
}
|
|
145230
147214
|
return rich;
|
|
145231
147215
|
}
|
|
147216
|
+
/** A torn line past " | " would parse as a whole entry with its message cut. */
|
|
147217
|
+
dropTornLine(fd, bytes, written) {
|
|
147218
|
+
try {
|
|
147219
|
+
fs40.ftruncateSync(fd, this.bytesWritten);
|
|
147220
|
+
} catch {
|
|
147221
|
+
this.bytesWritten += written;
|
|
147222
|
+
if (written > 0) this.midLine = bytes[written - 1] !== 10;
|
|
147223
|
+
}
|
|
147224
|
+
}
|
|
145232
147225
|
getFilePath() {
|
|
145233
147226
|
return this.filePath;
|
|
145234
147227
|
}
|
|
147228
|
+
/** Entries whose whole line reached the file; `totalEntries` also counts the rest. */
|
|
147229
|
+
getFileEntryCount() {
|
|
147230
|
+
return this.fileEntryCount;
|
|
147231
|
+
}
|
|
147232
|
+
hasFile() {
|
|
147233
|
+
return fs40.existsSync(this.filePath);
|
|
147234
|
+
}
|
|
145235
147235
|
getStats() {
|
|
145236
147236
|
return {
|
|
145237
147237
|
file: this.filePath,
|
|
@@ -145337,7 +147337,7 @@ function parseFlatLine(line) {
|
|
|
145337
147337
|
const match = LINE_RE.exec(line);
|
|
145338
147338
|
if (!match) return null;
|
|
145339
147339
|
const [, idStr, timestamp, levelRaw, , message] = match;
|
|
145340
|
-
const level =
|
|
147340
|
+
const level = CAMEL_LEVELS.find((l) => l.toUpperCase() === levelRaw) ?? levelRaw.toLowerCase();
|
|
145341
147341
|
return {
|
|
145342
147342
|
marker: `[L:${idStr}]`,
|
|
145343
147343
|
id: parseInt(idStr, 10),
|
|
@@ -145554,14 +147554,17 @@ var chromiumJsRuntimeDebuggerBlueprint = {
|
|
|
145554
147554
|
cdp.events.off("disconnected", onDisconnected);
|
|
145555
147555
|
await consoleServer.close();
|
|
145556
147556
|
const captured = logWriter.getStats().totalEntries;
|
|
145557
|
-
const
|
|
147557
|
+
const connectionLost = !cdp.isConnected();
|
|
147558
|
+
const inFile = logWriter.getFileEntryCount();
|
|
147559
|
+
const stored = logWriter.hasFile() && inFile > 0;
|
|
147560
|
+
const keepFile = captured > 0 && connectionLost && stored;
|
|
145558
147561
|
if (captured > 0) {
|
|
145559
147562
|
const entries = `${captured} captured console ${captured === 1 ? "entry" : "entries"}`;
|
|
145560
147563
|
recordReapedSession(
|
|
145561
147564
|
"js-runtime-debugger",
|
|
145562
147565
|
device.id,
|
|
145563
|
-
keepFile ? `The log file with its ${entries} is kept at ${logWriter.getFilePath()}.` : `The ${entries} went with it \u2014 the log file is deleted on teardown, so this registry starts empty rather than the app having logged nothing.`,
|
|
145564
|
-
|
|
147566
|
+
keepFile ? `The log file with ${inFile < captured ? `${inFile} of its` : "its"} ${entries} is kept at ${logWriter.getFilePath()}.` : stored ? `The ${entries} went with it \u2014 the log file is deleted on teardown, so this registry starts empty rather than the app having logged nothing.` : `The ${entries} went with it \u2014 no log file held them, so this registry starts empty rather than the app having logged nothing.`,
|
|
147567
|
+
connectionLost
|
|
145565
147568
|
);
|
|
145566
147569
|
}
|
|
145567
147570
|
logWriter.close({ keepFile });
|
|
@@ -149851,15 +151854,18 @@ var jsRuntimeDebuggerBlueprint = {
|
|
|
149851
151854
|
api,
|
|
149852
151855
|
dispose: async () => {
|
|
149853
151856
|
const captured = logWriter.getStats().totalEntries;
|
|
149854
|
-
const
|
|
151857
|
+
const connectionLost = !cdp.isConnected();
|
|
151858
|
+
const inFile = logWriter.getFileEntryCount();
|
|
151859
|
+
const stored = logWriter.hasFile() && inFile > 0;
|
|
151860
|
+
const keepFile = captured > 0 && connectionLost && stored;
|
|
149855
151861
|
if (captured > 0) {
|
|
149856
151862
|
const entries = `${captured} captured console ${captured === 1 ? "entry" : "entries"}`;
|
|
149857
|
-
const salvage = keepFile ? `The log file with its ${entries} is kept at ${logWriter.getFilePath()}.` : `The ${entries} went with it \u2014 the log file is deleted on teardown, so this registry starts empty rather than the app having logged nothing.`;
|
|
151863
|
+
const salvage = keepFile ? `The log file with ${inFile < captured ? `${inFile} of its` : "its"} ${entries} is kept at ${logWriter.getFilePath()}.` : stored ? `The ${entries} went with it \u2014 the log file is deleted on teardown, so this registry starts empty rather than the app having logged nothing.` : `The ${entries} went with it \u2014 no log file held them, so this registry starts empty rather than the app having logged nothing.`;
|
|
149858
151864
|
recordReapedSession(
|
|
149859
151865
|
"js-runtime-debugger",
|
|
149860
151866
|
[deviceId, api.logicalDeviceId],
|
|
149861
151867
|
salvage,
|
|
149862
|
-
|
|
151868
|
+
connectionLost
|
|
149863
151869
|
);
|
|
149864
151870
|
}
|
|
149865
151871
|
forgetDeviceAlias(api.logicalDeviceId);
|
|
@@ -156130,37 +158136,68 @@ function androidDevtoolsRotationPeek(registry2, device) {
|
|
|
156130
158136
|
|
|
156131
158137
|
// ../tool-server/src/utils/vega-screen.ts
|
|
156132
158138
|
var import_promises17 = require("node:fs/promises");
|
|
156133
|
-
var
|
|
156134
|
-
var
|
|
158139
|
+
var import_node_os16 = require("node:os");
|
|
158140
|
+
var import_node_path28 = require("node:path");
|
|
156135
158141
|
var import_pngjs3 = __toESM(require_png());
|
|
156136
158142
|
init_src2();
|
|
156137
158143
|
init_adb();
|
|
158144
|
+
|
|
158145
|
+
// ../tool-server/src/utils/emulator-console.ts
|
|
158146
|
+
var import_node_os15 = require("node:os");
|
|
158147
|
+
var import_node_path27 = require("node:path");
|
|
158148
|
+
init_adb();
|
|
158149
|
+
async function runEmuConsole(serial, args) {
|
|
158150
|
+
const { stdout } = await runAdb(["-s", serial, "emu", ...args], { timeoutMs: 1e4 });
|
|
158151
|
+
const verdict = replyLines(stdout).at(-1);
|
|
158152
|
+
if (verdict?.startsWith("KO:")) {
|
|
158153
|
+
throw new Error(
|
|
158154
|
+
`emulator console rejected \`${args.join(" ")}\` \u2014 ${describeConsoleReply(stdout)}`
|
|
158155
|
+
);
|
|
158156
|
+
}
|
|
158157
|
+
return stdout;
|
|
158158
|
+
}
|
|
158159
|
+
function describeConsoleReply(stdout) {
|
|
158160
|
+
const lines = replyLines(stdout);
|
|
158161
|
+
const reply = lines.join("; ") || "empty reply";
|
|
158162
|
+
if (!lines.at(-1)?.startsWith("KO: unknown command")) return reply;
|
|
158163
|
+
const tokenFile = (0, import_node_path27.join)((0, import_node_os15.homedir)(), ".emulator_console_auth_token");
|
|
158164
|
+
const fileKind = process.platform === "win32" ? "a file" : "a regular file, not a symlink,";
|
|
158165
|
+
return `${reply} (adb authenticates to the console with ${tokenFile}, which must be ${fileKind} holding the emulator's token)`;
|
|
158166
|
+
}
|
|
158167
|
+
function replyLines(stdout) {
|
|
158168
|
+
return stdout.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
158169
|
+
}
|
|
158170
|
+
|
|
158171
|
+
// ../tool-server/src/utils/vega-screen.ts
|
|
156138
158172
|
async function captureVegaScreenshotPng(opts = {}) {
|
|
156139
158173
|
return captureViaEmulatorConsole(opts);
|
|
156140
158174
|
}
|
|
156141
158175
|
async function captureViaEmulatorConsole(opts) {
|
|
156142
158176
|
const port = await discoverVegaConsolePort();
|
|
156143
158177
|
const serial = `emulator-${port}`;
|
|
156144
|
-
const outDir = await (0, import_promises17.mkdtemp)((0,
|
|
158178
|
+
const outDir = await (0, import_promises17.mkdtemp)((0, import_node_path28.join)((0, import_node_os16.tmpdir)(), "vega-shot-"));
|
|
156145
158179
|
try {
|
|
156146
|
-
await runAdb(["-s", serial, "emu", "screenrecord", "screenshot", outDir], {
|
|
158180
|
+
const { stdout } = await runAdb(["-s", serial, "emu", "screenrecord", "screenshot", outDir], {
|
|
156147
158181
|
timeoutMs: 2e4
|
|
156148
158182
|
});
|
|
156149
158183
|
const pngName = (await (0, import_promises17.readdir)(outDir)).find((f) => f.toLowerCase().endsWith(".png"));
|
|
156150
158184
|
if (!pngName) {
|
|
156151
|
-
throw new FailureError(
|
|
156152
|
-
|
|
156153
|
-
|
|
156154
|
-
|
|
156155
|
-
|
|
156156
|
-
|
|
158185
|
+
throw new FailureError(
|
|
158186
|
+
`emulator console wrote no PNG for ${serial}: ${describeConsoleReply(stdout)}`,
|
|
158187
|
+
{
|
|
158188
|
+
error_code: FAILURE_CODES.VEGA_SCREENSHOT_FAILED,
|
|
158189
|
+
failure_stage: "vega_screenshot_no_png",
|
|
158190
|
+
failure_area: "tool_server",
|
|
158191
|
+
error_kind: "unknown"
|
|
158192
|
+
}
|
|
158193
|
+
);
|
|
156157
158194
|
}
|
|
156158
|
-
const decoded2 = import_pngjs3.PNG.sync.read(await (0, import_promises17.readFile)((0,
|
|
158195
|
+
const decoded2 = import_pngjs3.PNG.sync.read(await (0, import_promises17.readFile)((0, import_node_path28.join)(outDir, pngName)));
|
|
156159
158196
|
const scaled = scaleDecodedPng(
|
|
156160
158197
|
decoded2,
|
|
156161
158198
|
opts.scale ?? getScreenshotScaleOverride() ?? tvDefaultScale(decoded2.width, decoded2.height)
|
|
156162
158199
|
);
|
|
156163
|
-
const outPath = (0,
|
|
158200
|
+
const outPath = (0, import_node_path28.join)((0, import_node_os16.tmpdir)(), `vega-screenshot-${process.hrtime.bigint()}.png`);
|
|
156164
158201
|
await (0, import_promises17.writeFile)(outPath, import_pngjs3.PNG.sync.write(scaled));
|
|
156165
158202
|
return outPath;
|
|
156166
158203
|
} finally {
|
|
@@ -156171,8 +158208,8 @@ async function captureViaEmulatorConsole(opts) {
|
|
|
156171
158208
|
|
|
156172
158209
|
// ../tool-server/src/utils/harmony-screen.ts
|
|
156173
158210
|
var import_promises18 = require("node:fs/promises");
|
|
156174
|
-
var
|
|
156175
|
-
var
|
|
158211
|
+
var import_node_os17 = require("node:os");
|
|
158212
|
+
var import_node_path29 = require("node:path");
|
|
156176
158213
|
var import_pngjs4 = __toESM(require_png());
|
|
156177
158214
|
init_src2();
|
|
156178
158215
|
function decodeCapture(raw, connectKey) {
|
|
@@ -156193,12 +158230,12 @@ function decodeCapture(raw, connectKey) {
|
|
|
156193
158230
|
}
|
|
156194
158231
|
}
|
|
156195
158232
|
async function captureHarmonyScreenshotPng(opts) {
|
|
156196
|
-
const rawPath = (0,
|
|
158233
|
+
const rawPath = (0, import_node_path29.join)((0, import_node_os17.tmpdir)(), `argent-harmony-raw-${process.hrtime.bigint()}.png`);
|
|
156197
158234
|
try {
|
|
156198
158235
|
await harmonyScreenCap(opts.connectKey, rawPath);
|
|
156199
158236
|
const decoded2 = decodeCapture(await (0, import_promises18.readFile)(rawPath), opts.connectKey);
|
|
156200
158237
|
const scaled = scaleDecodedPng(decoded2, opts.scale);
|
|
156201
|
-
const outPath = (0,
|
|
158238
|
+
const outPath = (0, import_node_path29.join)((0, import_node_os17.tmpdir)(), `harmony-screenshot-${process.hrtime.bigint()}.png`);
|
|
156202
158239
|
if (scaled === decoded2) {
|
|
156203
158240
|
await (0, import_promises18.rename)(rawPath, outPath);
|
|
156204
158241
|
} else {
|
|
@@ -159102,20 +161139,6 @@ var iosRemoteImpl6 = {
|
|
|
159102
161139
|
// ../tool-server/src/tools/shake/platforms/android.ts
|
|
159103
161140
|
init_src2();
|
|
159104
161141
|
init_adb();
|
|
159105
|
-
|
|
159106
|
-
// ../tool-server/src/utils/emulator-console.ts
|
|
159107
|
-
init_adb();
|
|
159108
|
-
async function runEmuConsole(serial, args) {
|
|
159109
|
-
const { stdout } = await runAdb(["-s", serial, "emu", ...args], { timeoutMs: 1e4 });
|
|
159110
|
-
const lines = stdout.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
159111
|
-
const verdict = lines[lines.length - 1];
|
|
159112
|
-
if (verdict?.startsWith("KO:")) {
|
|
159113
|
-
throw new Error(`emulator console rejected \`${args.join(" ")}\` \u2014 ${verdict}`);
|
|
159114
|
-
}
|
|
159115
|
-
return stdout;
|
|
159116
|
-
}
|
|
159117
|
-
|
|
159118
|
-
// ../tool-server/src/tools/shake/platforms/android.ts
|
|
159119
161142
|
init_capability();
|
|
159120
161143
|
var SHAKE_AMPLITUDE = 30;
|
|
159121
161144
|
var SWINGS_PER_SHAKE = 8;
|
|
@@ -160051,7 +162074,7 @@ var debuggerConnectTool = {
|
|
|
160051
162074
|
id: "debugger-connect",
|
|
160052
162075
|
description: `Connect to a JS runtime CDP debugger.
|
|
160053
162076
|
iOS / Android / Vega: connects to Metro's CDP endpoint on the given port. Chromium: re-uses the page CDP session opened by boot-device.
|
|
160054
|
-
Returns connection info including port, projectRoot (empty on Chromium and on legacy Metro, e.g. Vega), deviceName, appName, logicalDeviceId, and isNewDebugger, plus a note
|
|
162077
|
+
Returns connection info including port, projectRoot (empty on Chromium and on legacy Metro, e.g. Vega), deviceName, appName, logicalDeviceId, and isNewDebugger, plus a note when the previous session ended because the app crashed, naming its kept log file if it had one. If already connected, returns the existing connection.
|
|
160055
162078
|
Use when starting a debug session or before calling other debugger-* tools. Fails if the runtime is unreachable (Metro down, or Chromium CDP terminated).`,
|
|
160056
162079
|
zodSchema: zodSchema31,
|
|
160057
162080
|
interaction: {
|
|
@@ -161711,7 +163734,7 @@ function createDebuggerLogRegistryTool(registry2) {
|
|
|
161711
163734
|
id: "debugger-log-registry",
|
|
161712
163735
|
description: `Get a summary of all console logs captured from the app's JS runtime.
|
|
161713
163736
|
Returns the log file path, entry counts by level, and message clusters (grouped by similarity). Works against Hermes (iOS / Android / Vega) and V8 (Chromium).
|
|
161714
|
-
Use when investigating warnings, errors, or unexpected output. Call this first for an overview, then Grep the returned file for details; never Read it whole, it can hold 50,000 lines. Returns empty stats if no log data has been captured yet, but check { note }, which is present only when the stats are empty BECAUSE the previous debugger session ended: torn down (its log file deleted) or cut off by an app crash (
|
|
163737
|
+
Use when investigating warnings, errors, or unexpected output. Call this first for an overview, then Grep the returned file for details; never Read it whole, it can hold 50,000 lines. Returns empty stats if no log data has been captured yet, but check { note }, which is present only when { file } does not exist or holds fewer entries than totalEntries counts (failed writes, e.g. a full disk), or when the stats are empty BECAUSE the previous debugger session ended: torn down (its log file deleted) or cut off by an app crash (the note names its kept log file, if it had one). Without that note, empty means the app has logged nothing.
|
|
161715
163738
|
When the debugger cannot be reached, it returns { status: "not_connected", reason, detail, guidance } with NO log file. Follow the guidance (do not retry in a loop). Grep a log file in this state only when a { note } names one kept from before the app crashed. A "connected" result's stats may come from a session whose socket has since died. Use debugger-status, not this tool, to judge debugger health.`,
|
|
161716
163739
|
zodSchema: zodSchema37,
|
|
161717
163740
|
readOnly: true,
|
|
@@ -161746,6 +163769,9 @@ When the debugger cannot be reached, it returns { status: "not_connected", reaso
|
|
|
161746
163769
|
]);
|
|
161747
163770
|
if (reaped2) response.note = describeReapedSession(reaped2, "JS-runtime debugger session");
|
|
161748
163771
|
}
|
|
163772
|
+
const inFile = api.logWriter.getFileEntryCount();
|
|
163773
|
+
const fileNote = !api.logWriter.hasFile() ? `No log file exists at ${stats.file}, so there is nothing to grep: the counts and clusters are all that was captured. Usually the disk was full or ~/.argent/tmp was not writable when this session started (if root owns ~/.argent: sudo chown -R "$USER" ~/.argent). Only a new debugger session gets a file: once that is fixed, call stop-all-simulator-servers with devices: ["${canonicalDeviceId(params.device_id)}"], then debugger-connect again.` : inFile === 0 && stats.totalEntries > 0 ? `The log file at ${stats.file} holds none of the ${stats.totalEntries} captured entries: every write to it failed (e.g. a full disk), so there is nothing to grep and the counts and clusters are all that was captured. Entries logged once the disk has room are written to it.` : inFile < stats.totalEntries ? `The log file at ${stats.file} holds only ${inFile} of the ${stats.totalEntries} captured entries: the other writes to it failed (e.g. a full disk or a file-size limit), so byLevel and clusters count entries that grepping it will not find. Entries logged once the disk has room are written to it.` : void 0;
|
|
163774
|
+
if (fileNote) response.note = response.note ? `${response.note} ${fileNote}` : fileNote;
|
|
161749
163775
|
return response;
|
|
161750
163776
|
} catch (err) {
|
|
161751
163777
|
const reason2 = classifyNotConnected(err);
|
|
@@ -162625,7 +164651,7 @@ function createDescribeTool(registry2) {
|
|
|
162625
164651
|
description: `Get the accessibility / DOM element tree for the current screen.
|
|
162626
164652
|
Use when you need element frames or labels and have no fresh tree: most interaction tools (not tv-remote or shake) already return one after each action, or name an identical earlier one by its tree id.
|
|
162627
164653
|
On iOS it reads the AXRuntime accessibility service, so it sees whatever is visible, including system dialogs and permission prompts. While a system dialog is visible it returns the dialog's elements (buttons, text); otherwise the foreground app's. On a physical iOS device it covers only the app started with launch-app; to read system dialogs there, launch-app \`com.apple.springboard\` first.
|
|
162628
|
-
On Android it reads the tree through Argent's UiAutomation helper, falling back to \`uiautomator dump\`. On Chromium it walks the DOM over the Chrome DevTools Protocol: every visible element with its ARIA role, accessible name and bounding rect.
|
|
164654
|
+
On Android it reads the tree through Argent's UiAutomation helper, falling back to \`uiautomator dump\`. On Chromium it walks the DOM over the Chrome DevTools Protocol: every visible element with its ARIA role, accessible name and the visible part of its bounding rect; content scrolled or clipped out of view, or skipped by a closed \`<details>\` or \`content-visibility: hidden\`, has a zero-area frame.
|
|
162629
164655
|
On Vega (Fire TV) it reads the on-device automation toolkit; \`[focused]\`/\`[selected]\` mark the D-pad cursor, which you move with \`tv-remote\` (Vega has no touch).<flag:harmonyos>
|
|
162630
164656
|
On HarmonyOS it runs the device's \`uitest dumpLayout\` (\`source: "harmony-uitest"\`); each top-level child is a window whose \`identifier\` (not its label) is the owning bundle, so an app plus the status bar reads as two windows. A suspended display still dumps its last frame, so the result then carries a \`hint\`, as it does for an empty dump.</flag:harmonyos><flag:macos-apps>
|
|
162631
164657
|
On a Mac app it reads the app's accessibility tree with web view content and React Native testIDs merged in; frames are fractions of the app window, grown to include sheets and menus past it.</flag:macos-apps>
|
|
@@ -163260,6 +165286,28 @@ function notAnsweredError(stage) {
|
|
|
163260
165286
|
}
|
|
163261
165287
|
);
|
|
163262
165288
|
}
|
|
165289
|
+
function pageNotAnsweringError(stage, waitedMs) {
|
|
165290
|
+
return new FailureError(
|
|
165291
|
+
`The page did not answer for ${waitedMs / 1e3} s, so fill changed nothing. A JavaScript dialog (alert, confirm or prompt) may be open, or the page is busy or has crashed. Argent cannot close a dialog: ask the user to close it, then retry. A retry fills a busy page once its task ends. If no dialog is open and it still does not answer, restart the app.`,
|
|
165292
|
+
{
|
|
165293
|
+
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
165294
|
+
failure_stage: stage,
|
|
165295
|
+
failure_area: "tool_server",
|
|
165296
|
+
error_kind: "timeout"
|
|
165297
|
+
}
|
|
165298
|
+
);
|
|
165299
|
+
}
|
|
165300
|
+
function pageNotFinishedError(stage) {
|
|
165301
|
+
return new FailureError(
|
|
165302
|
+
"The page did not finish the fill in time; it may have opened a JavaScript dialog or crashed. The field may have changed, and may still change when the page resumes: read it before retrying. If the page does not answer and no dialog is open, restart the app.",
|
|
165303
|
+
{
|
|
165304
|
+
error_code: FAILURE_CODES.FILL_NOT_VERIFIED,
|
|
165305
|
+
failure_stage: stage,
|
|
165306
|
+
failure_area: "tool_server",
|
|
165307
|
+
error_kind: "timeout"
|
|
165308
|
+
}
|
|
165309
|
+
);
|
|
165310
|
+
}
|
|
163263
165311
|
function unsupportedFieldError(detail, stage) {
|
|
163264
165312
|
return new InvalidToolInputError(
|
|
163265
165313
|
`fill cannot set this field's text: ${detail}. Nothing was changed.`,
|
|
@@ -163409,16 +165457,20 @@ function buildChromiumFillScript(text) {
|
|
|
163409
165457
|
return el;
|
|
163410
165458
|
};
|
|
163411
165459
|
let el = deepActive(document);
|
|
163412
|
-
while (el && String(el.tagName).toLowerCase()
|
|
165460
|
+
while (el && /^(i?frame|object)$/.test(String(el.tagName).toLowerCase())) {
|
|
165461
|
+
// An <object> showing an image or a plugin has no document to descend into.
|
|
165462
|
+
if (!el.contentWindow) break;
|
|
163413
165463
|
let inner = null;
|
|
163414
165464
|
try { inner = el.contentDocument; } catch (e) { inner = null; }
|
|
163415
|
-
|
|
165465
|
+
// A cross-origin or sandboxed frame hides its document.
|
|
165466
|
+
if (!inner) return { status: "unsupported", detail: "focus is in a cross-origin frame, which fill cannot reach" };
|
|
163416
165467
|
el = deepActive(inner);
|
|
163417
165468
|
}
|
|
163418
165469
|
if (!el || el.tagName === undefined) return { status: "no_focus" };
|
|
163419
165470
|
const doc = el.ownerDocument || document;
|
|
163420
165471
|
const win = doc.defaultView || window;
|
|
163421
165472
|
const tag = String(el.tagName).toLowerCase();
|
|
165473
|
+
if (tag === "embed") return { status: "unsupported", detail: "focus is in an <embed>, which fill cannot reach" };
|
|
163422
165474
|
const type = tag === "input" ? String(el.type || "text").toLowerCase() : null;
|
|
163423
165475
|
if (type !== null && /^(date|time|month|week|datetime-local)$/.test(type)) {
|
|
163424
165476
|
return { status: "unsupported", detail: "a " + type + " input holds a structured value" };
|
|
@@ -163426,13 +165478,77 @@ function buildChromiumFillScript(text) {
|
|
|
163426
165478
|
const control =
|
|
163427
165479
|
tag === "textarea" ||
|
|
163428
165480
|
(tag === "input" && !/^(button|checkbox|radio|file|submit|reset|image|range|color|hidden)$/.test(type));
|
|
163429
|
-
if (!control
|
|
165481
|
+
if (!control) {
|
|
165482
|
+
// Focus in a closed shadow root stops at its host. An element that can
|
|
165483
|
+
// host one is focusable itself only as a tab stop, an editing host or a
|
|
165484
|
+
// box the user can scroll; one with focus that is none of these, or whose
|
|
165485
|
+
// selection is in its shadow tree, holds it in a closed shadow root. The
|
|
165486
|
+
// browser shows such a selection collapsed before the host, or in place
|
|
165487
|
+
// when the page set it there, even in an editing host's own text. In a
|
|
165488
|
+
// focused page, which :focus needs, an editing host focused itself
|
|
165489
|
+
// matches :focus-visible; one whose focus is in its shadow tree does not.
|
|
165490
|
+
const scrolls = (style) =>
|
|
165491
|
+
(/^(auto|scroll)$/.test(style.overflowY) && el.scrollHeight > el.clientHeight) ||
|
|
165492
|
+
(/^(auto|scroll)$/.test(style.overflowX) && el.scrollWidth > el.clientWidth);
|
|
165493
|
+
const inShadow = (node, offset) => {
|
|
165494
|
+
if (node == null) return false;
|
|
165495
|
+
if (node === el.parentNode && node.childNodes[offset] === el) return true;
|
|
165496
|
+
for (let root = node.getRootNode(); root.host; root = root.host.getRootNode()) if (root.host === el) return true;
|
|
165497
|
+
return false;
|
|
165498
|
+
};
|
|
165499
|
+
const selectionInShadow = () => {
|
|
165500
|
+
if (el.shadowRoot) return false;
|
|
165501
|
+
const sel = el.getRootNode().getSelection();
|
|
165502
|
+
return inShadow(sel.anchorNode, sel.anchorOffset) && inShadow(sel.focusNode, sel.focusOffset);
|
|
165503
|
+
};
|
|
165504
|
+
const focusInShadow = () => {
|
|
165505
|
+
if (el.isContentEditable !== true) return false;
|
|
165506
|
+
try {
|
|
165507
|
+
return el.matches(":focus") && !el.matches(":focus-visible");
|
|
165508
|
+
} catch (e) {
|
|
165509
|
+
// Chromium before 86 has no :focus-visible.
|
|
165510
|
+
return false;
|
|
165511
|
+
}
|
|
165512
|
+
};
|
|
165513
|
+
const closedHost =
|
|
165514
|
+
/-|^(article|aside|blockquote|div|footer|h[1-6]|header|main|nav|p|section|span)$/.test(tag) &&
|
|
165515
|
+
((!el.hasAttribute("tabindex") &&
|
|
165516
|
+
(el.isContentEditable !== true || (el.parentElement !== null && el.parentElement.isContentEditable === true)) &&
|
|
165517
|
+
!scrolls(win.getComputedStyle(el))) ||
|
|
165518
|
+
selectionInShadow() ||
|
|
165519
|
+
focusInShadow());
|
|
165520
|
+
if (closedHost) return { status: "unsupported", detail: "focus is in a closed shadow root, which fill cannot reach" };
|
|
165521
|
+
if (el.isContentEditable !== true) return { status: "no_focus" };
|
|
165522
|
+
}
|
|
163430
165523
|
if (control && el.disabled === true) return { status: "unsupported", detail: "it is disabled" };
|
|
163431
165524
|
if (control && el.readOnly === true) return { status: "unsupported", detail: "it is read-only" };
|
|
163432
165525
|
// An <input> holds one line and drops a newline.
|
|
163433
165526
|
if (tag === "input" && /[\\r\\n]/.test(text)) {
|
|
163434
165527
|
return { status: "unsupported", detail: "a single-line input cannot hold a newline" };
|
|
163435
165528
|
}
|
|
165529
|
+
// A textarea or an editable element stores a CR or CRLF as one LF.
|
|
165530
|
+
const want = text.replace(/\\r\\n?/g, "\\n");
|
|
165531
|
+
// Typed text stops at maxlength, which the value setter ignores.
|
|
165532
|
+
const limited = tag === "textarea" || /^(text|search|url|tel|email|password)$/.test(type);
|
|
165533
|
+
if (limited && el.maxLength >= 0 && want.length > el.maxLength) {
|
|
165534
|
+
return { status: "unsupported", detail: "the text is longer than its maxlength of " + el.maxLength };
|
|
165535
|
+
}
|
|
165536
|
+
// A number input holds only a valid number and an email input drops the
|
|
165537
|
+
// whitespace around an address, typed or set. A detached input of the
|
|
165538
|
+
// same type applies the browser's own sanitization; outside an HTML
|
|
165539
|
+
// document only the XHTML namespace makes it an input.
|
|
165540
|
+
if (type === "number" || type === "email") {
|
|
165541
|
+
const probe = doc.createElementNS("http://www.w3.org/1999/xhtml", "input");
|
|
165542
|
+
probe.type = type;
|
|
165543
|
+
probe.multiple = el.multiple === true;
|
|
165544
|
+
probe.value = text;
|
|
165545
|
+
if (probe.value !== text) {
|
|
165546
|
+
return {
|
|
165547
|
+
status: "unsupported",
|
|
165548
|
+
detail: type === "number" ? "a number input holds only a valid number" : "an email input drops the whitespace around an address",
|
|
165549
|
+
};
|
|
165550
|
+
}
|
|
165551
|
+
}
|
|
163436
165552
|
if (!control) {
|
|
163437
165553
|
// designMode or <body contenteditable>: the whole document is the field.
|
|
163438
165554
|
let host = el;
|
|
@@ -163444,7 +165560,32 @@ function buildChromiumFillScript(text) {
|
|
|
163444
165560
|
const trimEnd = (s) => s.replace(/[\\u200b\\ufeff]/g, "").replace(/\\n+$/, "");
|
|
163445
165561
|
const read = () =>
|
|
163446
165562
|
control ? String(el.value == null ? "" : el.value) : trimEnd(String(el.innerText == null ? el.textContent || "" : el.innerText));
|
|
163447
|
-
|
|
165563
|
+
// A number input showing text it cannot parse reads as "".
|
|
165564
|
+
const badInput = () => el.validity != null && el.validity.badInput === true;
|
|
165565
|
+
// Chrome stores an edited email address's non-ASCII domain in ASCII, by
|
|
165566
|
+
// UTS #46 transitional processing: the URL parser's, once its deviations
|
|
165567
|
+
// (\xDF, \u03C2, ZWNJ, ZWJ) are mapped.
|
|
165568
|
+
const asciiEmail = (a) => {
|
|
165569
|
+
const at = a.indexOf("@");
|
|
165570
|
+
if (at < 0 || !/[^\\x00-\\x7f]/.test(a)) return a;
|
|
165571
|
+
const host = a.slice(at + 1).replace(/[\\u00df\\u1e9e]/g, "ss").replace(/\\u03c2/g, "\\u03c3").replace(/[\\u200c\\u200d]/g, "");
|
|
165572
|
+
// A link parses its href with the URL parser even where a page's own URL
|
|
165573
|
+
// global shadows the builtin. The ".a" label keeps a numeric last label
|
|
165574
|
+
// from parsing as IPv4.
|
|
165575
|
+
const link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a");
|
|
165576
|
+
link.href = "http://" + host + ".a";
|
|
165577
|
+
// Unparsable, or not a bare host: it has a user, a port or a path.
|
|
165578
|
+
if (link.href !== "http://" + link.hostname + "/") return a;
|
|
165579
|
+
return a.slice(0, at + 1) + link.hostname.slice(0, -2);
|
|
165580
|
+
};
|
|
165581
|
+
const sameText = (got) => {
|
|
165582
|
+
if (type !== "email") return got === want;
|
|
165583
|
+
const split = (s) => (el.multiple === true ? s.split(",") : [s]);
|
|
165584
|
+
const wants = split(want);
|
|
165585
|
+
const gots = split(got);
|
|
165586
|
+
return gots.length === wants.length && gots.every((g, i) => g === wants[i] || g === asciiEmail(wants[i]));
|
|
165587
|
+
};
|
|
165588
|
+
const matches = () => (control ? sameText(read()) && !badInput() : read() === trimEnd(want));
|
|
163448
165589
|
const settle = async () => {
|
|
163449
165590
|
for (let i = 0; i < 10; i++) {
|
|
163450
165591
|
await sleep(i === 0 ? 0 : 50);
|
|
@@ -163453,22 +165594,41 @@ function buildChromiumFillScript(text) {
|
|
|
163453
165594
|
return false;
|
|
163454
165595
|
};
|
|
163455
165596
|
|
|
163456
|
-
|
|
163457
|
-
|
|
163458
|
-
|
|
163459
|
-
|
|
163460
|
-
|
|
163461
|
-
|
|
163462
|
-
|
|
163463
|
-
|
|
163464
|
-
|
|
163465
|
-
|
|
163466
|
-
|
|
163467
|
-
|
|
163468
|
-
|
|
165597
|
+
const before = read();
|
|
165598
|
+
// The browser fires input synchronously for an edit it performed. The
|
|
165599
|
+
// window's capture phase sees it unless a page listener added there
|
|
165600
|
+
// earlier stops it.
|
|
165601
|
+
let edited = false;
|
|
165602
|
+
const onInput = () => { edited = true; };
|
|
165603
|
+
win.addEventListener("input", onInput, true);
|
|
165604
|
+
try {
|
|
165605
|
+
if (control) {
|
|
165606
|
+
try { el.select(); } catch (e) { /* no selection API */ }
|
|
165607
|
+
} else {
|
|
165608
|
+
const sel = doc.getSelection();
|
|
165609
|
+
const range = doc.createRange();
|
|
165610
|
+
range.selectNodeContents(el);
|
|
165611
|
+
sel.removeAllRanges();
|
|
165612
|
+
sel.addRange(range);
|
|
165613
|
+
}
|
|
165614
|
+
try {
|
|
165615
|
+
if (text === "") {
|
|
165616
|
+
if (read() !== "" || badInput()) doc.execCommand("delete");
|
|
165617
|
+
} else {
|
|
165618
|
+
doc.execCommand("insertText", false, text);
|
|
165619
|
+
}
|
|
165620
|
+
} catch (e) {
|
|
165621
|
+
// An SVG document has no editing commands; a control still has its setter.
|
|
165622
|
+
if (!control) throw e;
|
|
165623
|
+
}
|
|
165624
|
+
} finally {
|
|
165625
|
+
win.removeEventListener("input", onInput, true);
|
|
163469
165626
|
}
|
|
163470
165627
|
let verified = await settle();
|
|
163471
|
-
|
|
165628
|
+
// An edit that did not happen fires no input and leaves the old text.
|
|
165629
|
+
// Anything else is the browser's or the page's own rewrite, which the
|
|
165630
|
+
// setter must not override, even when the rewrite equals the old text.
|
|
165631
|
+
if (!verified && control && !edited && read() === before) {
|
|
163472
165632
|
const proto = tag === "textarea" ? win.HTMLTextAreaElement.prototype : win.HTMLInputElement.prototype;
|
|
163473
165633
|
const setter = Object.getOwnPropertyDescriptor(proto, "value").set;
|
|
163474
165634
|
setter.call(el, text);
|
|
@@ -163482,13 +165642,38 @@ function buildChromiumFillScript(text) {
|
|
|
163482
165642
|
}
|
|
163483
165643
|
})()`;
|
|
163484
165644
|
}
|
|
165645
|
+
var PAGE_ANSWER_TIMEOUT_MS = 1e4;
|
|
165646
|
+
var FILL_TIMEOUT_MS2 = 1e4;
|
|
165647
|
+
async function withTimeoutError(send, timeoutError) {
|
|
165648
|
+
try {
|
|
165649
|
+
return await send();
|
|
165650
|
+
} catch (err) {
|
|
165651
|
+
if (getFailureSignal(err)?.error_code === FAILURE_CODES.DEBUGGER_CDP_REQUEST_TIMEOUT) {
|
|
165652
|
+
throw timeoutError();
|
|
165653
|
+
}
|
|
165654
|
+
throw err;
|
|
165655
|
+
}
|
|
165656
|
+
}
|
|
163485
165657
|
async function fillChromium(registry2, device, text) {
|
|
163486
165658
|
const ref = chromiumCdpRef(device);
|
|
163487
|
-
const api = await
|
|
163488
|
-
|
|
163489
|
-
|
|
163490
|
-
|
|
163491
|
-
|
|
165659
|
+
const api = await withTimeoutError(
|
|
165660
|
+
() => registry2.resolveService(ref.urn, {
|
|
165661
|
+
...ref.options,
|
|
165662
|
+
answerTimeoutMs: PAGE_ANSWER_TIMEOUT_MS
|
|
165663
|
+
}),
|
|
165664
|
+
() => pageNotAnsweringError("fill_chromium_connect", PAGE_ANSWER_TIMEOUT_MS)
|
|
165665
|
+
);
|
|
165666
|
+
await withTimeoutError(
|
|
165667
|
+
() => api.cdp.send("Runtime.evaluate", { expression: "0" }, PAGE_ANSWER_TIMEOUT_MS),
|
|
165668
|
+
() => pageNotAnsweringError("fill_chromium_page_blocked", PAGE_ANSWER_TIMEOUT_MS)
|
|
165669
|
+
);
|
|
165670
|
+
const out = await withTimeoutError(
|
|
165671
|
+
() => api.cdp.send(
|
|
165672
|
+
"Runtime.evaluate",
|
|
165673
|
+
{ expression: buildChromiumFillScript(text), awaitPromise: true, returnByValue: true },
|
|
165674
|
+
FILL_TIMEOUT_MS2
|
|
165675
|
+
),
|
|
165676
|
+
() => pageNotFinishedError("fill_chromium_timeout")
|
|
163492
165677
|
);
|
|
163493
165678
|
const answer = out.result?.value;
|
|
163494
165679
|
switch (answer?.status) {
|
|
@@ -163571,7 +165756,7 @@ function createFillTool(registry2) {
|
|
|
163571
165756
|
id: "fill",
|
|
163572
165757
|
description: `Set the text of the focused text field to exactly \`text\`, replacing what it holds; "" clears it. Tap the field first.
|
|
163573
165758
|
Returns { verified }, never the text: true when the field was read back holding the text, false on a physical iPhone, where nothing can read it back.
|
|
163574
|
-
Fails with FILL_NO_FOCUSED_FIELD when nothing editable has focus, FILL_NOT_VERIFIED when the field does not read back the text, FILL_UNSUPPORTED_FIELD for a field that cannot take the text (a date or time input, a newline in a single-line field; nothing is changed). Fails if the device's ax-service or devtools helper predates fill; update argent. Not supported on TV targets or Vega.`,
|
|
165759
|
+
Fails with FILL_NO_FOCUSED_FIELD when nothing editable has focus, FILL_NOT_VERIFIED when the field does not read back the text or the device does not answer in time, FILL_UNSUPPORTED_FIELD for a field that cannot take the text (a date or time input, a newline in a single-line field; on Chromium also text over the field's maxlength, text a number input does not hold as a number, whitespace around an email address, or focus in a cross-origin frame, a closed shadow root or an <embed>; nothing is changed). Fails if the device's ax-service or devtools helper predates fill; update argent. Not supported on TV targets or Vega.`,
|
|
163575
165760
|
zodSchema: zodSchema43,
|
|
163576
165761
|
hideFromMcp: true,
|
|
163577
165762
|
interaction: {
|
|
@@ -163654,7 +165839,7 @@ var zodSchema44 = external_exports.object({
|
|
|
163654
165839
|
),
|
|
163655
165840
|
pollIntervalMs: external_exports.number().int().min(50).max(5e3).optional().describe(`How often to re-read the tree (default ${DEFAULT_POLL_INTERVAL_MS2}).`),
|
|
163656
165841
|
minStableMs: external_exports.number().int().min(0).max(1e4).optional().describe(
|
|
163657
|
-
`The screen must hold the same content for at least this long to count as settled (default ${DEFAULT_MIN_STABLE_MS}).`
|
|
165842
|
+
`The screen must hold the same content for at least this long to count as settled (default ${DEFAULT_MIN_STABLE_MS}); 0 settles on the first non-empty read.`
|
|
163658
165843
|
)
|
|
163659
165844
|
}).strict();
|
|
163660
165845
|
function createAwaitScreenIdleTool(registry2) {
|
|
@@ -163679,9 +165864,9 @@ function createAwaitScreenIdleTool(registry2) {
|
|
|
163679
165864
|
}
|
|
163680
165865
|
return {
|
|
163681
165866
|
id: AWAIT_SCREEN_IDLE_TOOL_ID,
|
|
163682
|
-
description: `Block until the screen has rendered content and
|
|
165867
|
+
description: `Block until the screen has rendered content and held it for minStableMs, or the timeout elapses. It polls the same element tree as \`describe\`.
|
|
163683
165868
|
Use when a launch or navigation must finish rendering before a screenshot or tap.
|
|
163684
|
-
Returns { settled, waitedMs, polls, note? }. If
|
|
165869
|
+
Returns { settled, waitedMs, polls, note? }. If that is not seen before timeoutMs, it returns settled=false instead of failing.<flag:harmonyos> A note on settled=true means the screen it settled on is not live: a suspended HarmonyOS panel settles instantly on its last frame, and taps land nowhere until it is woken.</flag:harmonyos>`,
|
|
163685
165870
|
zodSchema: zodSchema44,
|
|
163686
165871
|
searchHint: "wait until screen settles idle stable stops changing animation transition rendered ready before screenshot",
|
|
163687
165872
|
readOnly: true,
|
|
@@ -164457,7 +166642,7 @@ var IDLE_FRAME_NAMES = /* @__PURE__ */ new Set(["(idle)", "(program)", "(root)",
|
|
|
164457
166642
|
function isIdleFrame(name) {
|
|
164458
166643
|
return !name || IDLE_FRAME_NAMES.has(name);
|
|
164459
166644
|
}
|
|
164460
|
-
function queryCpuWindow(index, startMs, endMs, topN2 = 5) {
|
|
166645
|
+
function queryCpuWindow(index, startMs, endMs, topN2 = 5, { withCallers = false, unrounded = false } = {}) {
|
|
164461
166646
|
const { timestampsMs, intervalStartsMs, sampleNodeIds, nodeMap } = index;
|
|
164462
166647
|
const n = timestampsMs.length;
|
|
164463
166648
|
const sampleRangeMs = {
|
|
@@ -164521,16 +166706,19 @@ function queryCpuWindow(index, startMs, endMs, topN2 = 5) {
|
|
|
164521
166706
|
current = parent;
|
|
164522
166707
|
}
|
|
164523
166708
|
}
|
|
166709
|
+
const round3 = (ms3) => unrounded ? ms3 : Math.round(ms3 * 100) / 100;
|
|
164524
166710
|
const entries = [];
|
|
164525
|
-
for (const
|
|
166711
|
+
for (const nodeId of (withCallers ? totalMsByNode : selfMsByNode).keys()) {
|
|
164526
166712
|
const node2 = nodeMap.get(nodeId);
|
|
164527
166713
|
if (!node2) continue;
|
|
164528
166714
|
const name = node2.callFrame.functionName;
|
|
164529
166715
|
if (isArgentProfilerFunction(name)) continue;
|
|
166716
|
+
const ms3 = selfMsByNode.get(nodeId) ?? 0;
|
|
164530
166717
|
entries.push({
|
|
164531
166718
|
name,
|
|
164532
|
-
|
|
164533
|
-
|
|
166719
|
+
nodeId,
|
|
166720
|
+
selfMs: round3(ms3),
|
|
166721
|
+
totalMs: round3(totalMsByNode.get(nodeId)),
|
|
164534
166722
|
url: node2.callFrame.url || void 0,
|
|
164535
166723
|
lineNumber: node2.callFrame.lineNumber >= 0 ? node2.callFrame.lineNumber : void 0
|
|
164536
166724
|
});
|
|
@@ -165840,13 +168028,13 @@ function buildHotCommitSummaries(commits, hotCommitIndices, unattributedByCommit
|
|
|
165840
168028
|
const existing = componentMap.get(e.componentName);
|
|
165841
168029
|
if (existing) {
|
|
165842
168030
|
existing.totalSelf += e.selfDuration ?? 0;
|
|
165843
|
-
existing.
|
|
168031
|
+
existing.maxActual = Math.max(existing.maxActual, e.actualDuration ?? 0);
|
|
165844
168032
|
existing.count++;
|
|
165845
168033
|
if (!isFirstMount) existing.isFirstMount = false;
|
|
165846
168034
|
} else {
|
|
165847
168035
|
componentMap.set(e.componentName, {
|
|
165848
168036
|
totalSelf: e.selfDuration ?? 0,
|
|
165849
|
-
|
|
168037
|
+
maxActual: e.actualDuration ?? 0,
|
|
165850
168038
|
count: 1,
|
|
165851
168039
|
firstEntry: e,
|
|
165852
168040
|
isFirstMount
|
|
@@ -165854,7 +168042,7 @@ function buildHotCommitSummaries(commits, hotCommitIndices, unattributedByCommit
|
|
|
165854
168042
|
}
|
|
165855
168043
|
}
|
|
165856
168044
|
const totalComponentCount = componentMap.size;
|
|
165857
|
-
const componentEntries = Array.from(componentMap.entries()).sort((a, b) => b[1].totalSelf - a[1].totalSelf).slice(0, MAX_COMPONENT_ENTRIES).map(([name, { totalSelf,
|
|
168045
|
+
const componentEntries = Array.from(componentMap.entries()).sort((a, b) => b[1].totalSelf - a[1].totalSelf).slice(0, MAX_COMPONENT_ENTRIES).map(([name, { totalSelf, maxActual, count: count2, firstEntry, isFirstMount }]) => {
|
|
165858
168046
|
const cd = firstEntry.changeDescription;
|
|
165859
168047
|
const rerendered = rerenderNames.has(name);
|
|
165860
168048
|
const reason2 = rerendered && cd ? deriveReason(cd, firstEntry.hookTypes) : void 0;
|
|
@@ -165874,7 +168062,7 @@ function buildHotCommitSummaries(commits, hotCommitIndices, unattributedByCommit
|
|
|
165874
168062
|
const entry = {
|
|
165875
168063
|
name,
|
|
165876
168064
|
selfDurationMs: Math.round(totalSelf * 100) / 100,
|
|
165877
|
-
actualDurationMs: Math.round(
|
|
168065
|
+
actualDurationMs: Math.round(maxActual * 100) / 100,
|
|
165878
168066
|
count: count2,
|
|
165879
168067
|
...isFirstMount && { isFirstMount: true },
|
|
165880
168068
|
...reason2 !== void 0 && { reason: reason2 },
|
|
@@ -166776,9 +168964,10 @@ function buildFullMarkdown(input2, annotations, totalHotCommits) {
|
|
|
166776
168964
|
...input2.renderSummary ? [renderTimeLine(input2, input2.renderSummary)] : [],
|
|
166777
168965
|
``,
|
|
166778
168966
|
`> **Duration columns:** \`self\` = this component's own render work only (exclusive).`,
|
|
166779
|
-
`> \`w/children\` = self + the entire subtree it owns (inclusive)
|
|
166780
|
-
`>
|
|
166781
|
-
`>
|
|
168967
|
+
`> \`w/children\` = self + the entire subtree it owns (inclusive). On a grouped \`\xD7N\` row it is`,
|
|
168968
|
+
`> the largest single instance, while \`self\` is the total of all N.`,
|
|
168969
|
+
`> Do not sum \`w/children\` across rows or instances \u2014 inclusive times nest inside each other.`,
|
|
168970
|
+
`> Use \`self\` for summing; use \`w/children\` to understand container cost.`,
|
|
166782
168971
|
``,
|
|
166783
168972
|
`---`,
|
|
166784
168973
|
`## Slow React Batches`,
|
|
@@ -167573,9 +169762,10 @@ var COLLECT_RENDERS_SCRIPT = `
|
|
|
167573
169762
|
else if (fiber.type.name) name = fiber.type.name;
|
|
167574
169763
|
}
|
|
167575
169764
|
if (name && fiber.actualDuration !== undefined) {
|
|
167576
|
-
if (!results[name]) results[name] = {
|
|
167577
|
-
results[name].
|
|
167578
|
-
|
|
169765
|
+
if (!results[name]) results[name] = { instanceCount: 0, maxActualDuration: 0, selfBaseDuration: 0 };
|
|
169766
|
+
results[name].instanceCount += 1;
|
|
169767
|
+
var inclusive = fiber.actualDuration || 0;
|
|
169768
|
+
if (inclusive > results[name].maxActualDuration) results[name].maxActualDuration = inclusive;
|
|
167579
169769
|
results[name].selfBaseDuration += fiber.selfBaseDuration || 0;
|
|
167580
169770
|
}
|
|
167581
169771
|
if (fiber.child) walkFiber(fiber.child, depth + 1);
|
|
@@ -167607,10 +169797,10 @@ function messageForHookError(code) {
|
|
|
167607
169797
|
function renderMarkdownTable2(entries) {
|
|
167608
169798
|
if (entries.length === 0)
|
|
167609
169799
|
return "_No render data found. Ensure React DevTools global hook is present._";
|
|
167610
|
-
const header = "| Component | Instances |
|
|
169800
|
+
const header = "| Component | Instances | Largest subtree (ms) | Self Base (ms) |";
|
|
167611
169801
|
const sep11 = "|---|---|---|---|";
|
|
167612
169802
|
const rows = entries.map(
|
|
167613
|
-
(e) => `| \`${e.component}\` | ${e.
|
|
169803
|
+
(e) => `| \`${e.component}\` | ${e.instanceCount} | ${e.maxActualDuration_ms.toFixed(2)} | ${e.selfBaseDuration_ms.toFixed(2)} |`
|
|
167614
169804
|
);
|
|
167615
169805
|
return [header, sep11, ...rows].join("\n");
|
|
167616
169806
|
}
|
|
@@ -167624,14 +169814,14 @@ var zodSchema51 = external_exports.object({
|
|
|
167624
169814
|
var reactProfilerRendersTool = {
|
|
167625
169815
|
id: "react-profiler-renders",
|
|
167626
169816
|
description: `Scan the live React fiber tree and count the mounted instances of each component, with their last render durations.
|
|
167627
|
-
Returns a markdown table of the components with the longest total render time. It reads the top 30 levels of the tree and does not count re-renders: record a profiling session for that.
|
|
169817
|
+
Returns a markdown table of the components with the longest total self render time. It reads the top 30 levels of the tree and does not count re-renders: record a profiling session for that.
|
|
167628
169818
|
Use when you want a quick look at what is mounted in a live connected app, without a profiling session.
|
|
167629
169819
|
Fails if the React DevTools hook is not present in the runtime or the app is not connected.`,
|
|
167630
169820
|
zodSchema: zodSchema51,
|
|
167631
169821
|
readOnly: true,
|
|
167632
169822
|
// It walks only the top 30 fiber levels, above the screens of a real app
|
|
167633
|
-
// (Bluesky's first feed item sits at depth 446), and
|
|
167634
|
-
//
|
|
169823
|
+
// (Bluesky's first feed item sits at depth 446), and counts mounts, not
|
|
169824
|
+
// re-renders. Agents read render counts from a profiling session
|
|
167635
169825
|
// (profiler-commit-query mode=render_counts); HTTP and SDK callers keep it.
|
|
167636
169826
|
hideFromMcp: true,
|
|
167637
169827
|
interaction: {
|
|
@@ -167703,10 +169893,10 @@ Fails if the React DevTools hook is not present in the runtime or the app is not
|
|
|
167703
169893
|
}
|
|
167704
169894
|
const entries = Object.entries(parsed2).map(([component, data]) => ({
|
|
167705
169895
|
component,
|
|
167706
|
-
|
|
167707
|
-
|
|
169896
|
+
instanceCount: data.instanceCount,
|
|
169897
|
+
maxActualDuration_ms: data.maxActualDuration,
|
|
167708
169898
|
selfBaseDuration_ms: data.selfBaseDuration
|
|
167709
|
-
})).sort((a, b) => b.
|
|
169899
|
+
})).sort((a, b) => b.selfBaseDuration_ms - a.selfBaseDuration_ms).slice(0, params.top_n);
|
|
167710
169900
|
return `## Mounted React Components
|
|
167711
169901
|
|
|
167712
169902
|
${renderMarkdownTable2(entries)}`;
|
|
@@ -175991,7 +178181,7 @@ function makePointerControl(simulator) {
|
|
|
175991
178181
|
}
|
|
175992
178182
|
|
|
175993
178183
|
// ../tool-server/src/tools/screen-recording/screen-recording-stop.ts
|
|
175994
|
-
var
|
|
178184
|
+
var import_node_path30 = require("node:path");
|
|
175995
178185
|
init_zod();
|
|
175996
178186
|
init_device_info();
|
|
175997
178187
|
init_capability();
|
|
@@ -176039,7 +178229,7 @@ Fails if no recording (running or finished-but-unretrieved) exists for the given
|
|
|
176039
178229
|
kind: "screen-recording",
|
|
176040
178230
|
mimeType: "video/mp4",
|
|
176041
178231
|
// Drop the internal `argent-` temp-file prefix from the saved name.
|
|
176042
|
-
filename: (0,
|
|
178232
|
+
filename: (0, import_node_path30.basename)(stopped.outputFile).replace(/^argent-/, ""),
|
|
176043
178233
|
saveDir: RECORDINGS_DIR
|
|
176044
178234
|
});
|
|
176045
178235
|
const result = { video, durationMs: stopped.durationMs };
|
|
@@ -176201,24 +178391,26 @@ function renderByComponent(commits, componentName, topN2, summary = null) {
|
|
|
176201
178391
|
const sortedCommits = [...byCommit.entries()].map(([idx, entries]) => ({
|
|
176202
178392
|
commitIndex: idx,
|
|
176203
178393
|
instances: entries.length,
|
|
176204
|
-
|
|
178394
|
+
// Same-named instances nest, so inclusive durations can't be summed.
|
|
178395
|
+
maxSubtree: entries.reduce((m, e) => Math.max(m, e.actualDuration), 0),
|
|
178396
|
+
totalSelf: entries.reduce((s, e) => s + e.selfDuration, 0),
|
|
176205
178397
|
commitDuration: entries[0].commitDuration,
|
|
176206
178398
|
timestamp: entries[0].timestamp,
|
|
176207
178399
|
reason: formatReason2(entries[0]),
|
|
176208
178400
|
parentName: entries[0].parentName ?? "\u2014"
|
|
176209
|
-
})).sort((a, b) => b.
|
|
178401
|
+
})).sort((a, b) => b.totalSelf - a.totalSelf).slice(0, topN2);
|
|
176210
178402
|
const lines = [
|
|
176211
178403
|
`## Commits for \`${resolvedName}\``,
|
|
176212
178404
|
"",
|
|
176213
178405
|
...resolutionNote ? [resolutionNote, ""] : [],
|
|
176214
178406
|
`**Total occurrences:** ${matching.length} across ${byCommit.size} commits${storedOnlyNote(resolvedName, matching.filter((c) => c.didRender).length, summary)}`,
|
|
176215
178407
|
"",
|
|
176216
|
-
"| Commit | Instances |
|
|
176217
|
-
"
|
|
178408
|
+
"| Commit | Instances | Self (ms) | Largest subtree (ms) | Commit Total (ms) | Time (ms) | Reason | Parent |",
|
|
178409
|
+
"|---|---|---|---|---|---|---|---|"
|
|
176218
178410
|
];
|
|
176219
178411
|
for (const c of sortedCommits) {
|
|
176220
178412
|
lines.push(
|
|
176221
|
-
`| #${c.commitIndex} | ${c.instances} | ${c.
|
|
178413
|
+
`| #${c.commitIndex} | ${c.instances} | ${c.totalSelf.toFixed(1)} | ${c.maxSubtree.toFixed(1)} | ${c.commitDuration.toFixed(1)} | ${c.timestamp.toFixed(0)} | ${c.reason} | \`${c.parentName}\` |`
|
|
176222
178414
|
);
|
|
176223
178415
|
}
|
|
176224
178416
|
return lines.join("\n");
|
|
@@ -176278,7 +178470,7 @@ function renderByTimeRange(data, start2, end, topN2) {
|
|
|
176278
178470
|
lines.push("");
|
|
176279
178471
|
for (const comp of s.topComponents) {
|
|
176280
178472
|
lines.push(
|
|
176281
|
-
`- \`${comp.name}\` \xD7${comp.count} ${comp.
|
|
178473
|
+
`- \`${comp.name}\` \xD7${comp.count} self ${comp.totalSelf.toFixed(1)}ms, largest subtree ${comp.maxSubtree.toFixed(1)}ms \u2014 ${comp.reason}`
|
|
176282
178474
|
);
|
|
176283
178475
|
}
|
|
176284
178476
|
lines.push("");
|
|
@@ -176292,7 +178484,7 @@ function renderByIndex(commits, commitIndex, topN2) {
|
|
|
176292
178484
|
}
|
|
176293
178485
|
const commitDuration = matching[0].commitDuration;
|
|
176294
178486
|
const timestamp = matching[0].timestamp;
|
|
176295
|
-
const sorted = [...matching].sort((a, b) => b.
|
|
178487
|
+
const sorted = [...matching].sort((a, b) => b.selfDuration - a.selfDuration);
|
|
176296
178488
|
const shown = topN2 !== void 0 ? sorted.slice(0, topN2) : sorted;
|
|
176297
178489
|
const hidden = sorted.length - shown.length;
|
|
176298
178490
|
const lines = [
|
|
@@ -176300,7 +178492,7 @@ function renderByIndex(commits, commitIndex, topN2) {
|
|
|
176300
178492
|
"",
|
|
176301
178493
|
`**Time:** ${timestamp.toFixed(0)}ms **Duration:** ${commitDuration.toFixed(1)}ms **Fibers:** ${matching.length}${hidden > 0 ? ` (showing ${shown.length})` : ""}`,
|
|
176302
178494
|
"",
|
|
176303
|
-
"| Component |
|
|
178495
|
+
"| Component | Self (ms) | Subtree (ms) | Reason | Parent | Compiler |",
|
|
176304
178496
|
"|---|---|---|---|---|---|"
|
|
176305
178497
|
];
|
|
176306
178498
|
for (const c of shown) {
|
|
@@ -176308,13 +178500,13 @@ function renderByIndex(commits, commitIndex, topN2) {
|
|
|
176308
178500
|
const parent = c.parentName ?? "\u2014";
|
|
176309
178501
|
const compiler = c.isCompilerOptimized ? "\u2713" : "";
|
|
176310
178502
|
lines.push(
|
|
176311
|
-
`| \`${c.componentName}\` | ${c.
|
|
178503
|
+
`| \`${c.componentName}\` | ${c.selfDuration.toFixed(1)} | ${c.actualDuration.toFixed(1)} | ${reason2} | \`${parent}\` | ${compiler} |`
|
|
176312
178504
|
);
|
|
176313
178505
|
}
|
|
176314
178506
|
if (hidden > 0) {
|
|
176315
178507
|
lines.push("");
|
|
176316
178508
|
lines.push(
|
|
176317
|
-
`_Showing the ${shown.length}
|
|
178509
|
+
`_Showing the ${shown.length} of ${sorted.length} fibers with the most self time \u2014 ${hidden} cheaper fibers hidden. Note these are fibers, not components: the full set covers ${new Set(sorted.map((c) => c.componentName)).size} distinct components and this view covers ${new Set(shown.map((c) => c.componentName)).size}. Omit top_n for everything._`
|
|
176318
178510
|
);
|
|
176319
178511
|
}
|
|
176320
178512
|
const withRootCause = matching.find((c) => c.rootCauseParent);
|
|
@@ -176379,15 +178571,22 @@ function getTopComponents(entries, topN2) {
|
|
|
176379
178571
|
const existing = byName.get(e.componentName);
|
|
176380
178572
|
if (existing) {
|
|
176381
178573
|
existing.count++;
|
|
176382
|
-
existing.
|
|
178574
|
+
existing.totalSelf += e.selfDuration;
|
|
178575
|
+
existing.maxSubtree = Math.max(existing.maxSubtree, e.actualDuration);
|
|
176383
178576
|
} else {
|
|
176384
|
-
byName.set(e.componentName, {
|
|
178577
|
+
byName.set(e.componentName, {
|
|
178578
|
+
count: 1,
|
|
178579
|
+
totalSelf: e.selfDuration,
|
|
178580
|
+
maxSubtree: e.actualDuration,
|
|
178581
|
+
first: e
|
|
178582
|
+
});
|
|
176385
178583
|
}
|
|
176386
178584
|
}
|
|
176387
|
-
return [...byName.entries()].sort((a, b) => b[1].
|
|
178585
|
+
return [...byName.entries()].sort((a, b) => b[1].totalSelf - a[1].totalSelf).slice(0, topN2).map(([name, { count: count2, totalSelf, maxSubtree, first }]) => ({
|
|
176388
178586
|
name,
|
|
176389
178587
|
count: count2,
|
|
176390
|
-
|
|
178588
|
+
totalSelf,
|
|
178589
|
+
maxSubtree,
|
|
176391
178590
|
reason: formatReason2(first)
|
|
176392
178591
|
}));
|
|
176393
178592
|
}
|
|
@@ -176743,24 +178942,52 @@ Use mode=\`top_functions\` for JS CPU.`;
|
|
|
176743
178942
|
}
|
|
176744
178943
|
}
|
|
176745
178944
|
const aggregated = /* @__PURE__ */ new Map();
|
|
178945
|
+
const selfMsByLocation = /* @__PURE__ */ new Map();
|
|
178946
|
+
const locationOfNode = /* @__PURE__ */ new Map();
|
|
178947
|
+
const nestedInSameName = nodesNestedInSameName(
|
|
178948
|
+
index.nodeMap,
|
|
178949
|
+
index.childToParent ?? buildChildToParent(index.nodeMap)
|
|
178950
|
+
);
|
|
176746
178951
|
for (const window2 of commitWindows.values()) {
|
|
176747
|
-
const { hotspots } = queryCpuWindow(index, window2.start, window2.end,
|
|
178952
|
+
const { hotspots } = queryCpuWindow(index, window2.start, window2.end, Infinity, {
|
|
178953
|
+
withCallers: true,
|
|
178954
|
+
unrounded: true
|
|
178955
|
+
});
|
|
178956
|
+
const perWindow = /* @__PURE__ */ new Map();
|
|
176748
178957
|
for (const hs of hotspots) {
|
|
176749
|
-
|
|
178958
|
+
let location = locationOfNode.get(hs.nodeId);
|
|
178959
|
+
if (!location) {
|
|
178960
|
+
const locations2 = selfMsByLocation.get(hs.name) ?? /* @__PURE__ */ new Map();
|
|
178961
|
+
selfMsByLocation.set(hs.name, locations2);
|
|
178962
|
+
const locationKey = `${hs.url ?? ""}:${hs.lineNumber ?? ""}`;
|
|
178963
|
+
location = locations2.get(locationKey);
|
|
178964
|
+
if (!location) {
|
|
178965
|
+
location = { url: hs.url, lineNumber: hs.lineNumber, selfMs: 0 };
|
|
178966
|
+
locations2.set(locationKey, location);
|
|
178967
|
+
}
|
|
178968
|
+
locationOfNode.set(hs.nodeId, location);
|
|
178969
|
+
}
|
|
178970
|
+
location.selfMs += hs.selfMs;
|
|
178971
|
+
const totalMs = nestedInSameName.has(hs.nodeId) ? 0 : hs.totalMs;
|
|
178972
|
+
const seen = perWindow.get(hs.name);
|
|
178973
|
+
if (seen) {
|
|
178974
|
+
seen.selfMs += hs.selfMs;
|
|
178975
|
+
seen.totalMs += totalMs;
|
|
178976
|
+
} else {
|
|
178977
|
+
perWindow.set(hs.name, { selfMs: hs.selfMs, totalMs });
|
|
178978
|
+
}
|
|
178979
|
+
}
|
|
178980
|
+
for (const [name, win] of perWindow) {
|
|
178981
|
+
const existing = aggregated.get(name);
|
|
176750
178982
|
if (existing) {
|
|
176751
|
-
existing.selfMs +=
|
|
176752
|
-
existing.totalMs +=
|
|
178983
|
+
existing.selfMs += win.selfMs;
|
|
178984
|
+
existing.totalMs += win.totalMs;
|
|
176753
178985
|
} else {
|
|
176754
|
-
aggregated.set(
|
|
176755
|
-
selfMs: hs.selfMs,
|
|
176756
|
-
totalMs: hs.totalMs,
|
|
176757
|
-
url: hs.url,
|
|
176758
|
-
lineNumber: hs.lineNumber
|
|
176759
|
-
});
|
|
178986
|
+
aggregated.set(name, { ...win });
|
|
176760
178987
|
}
|
|
176761
178988
|
}
|
|
176762
178989
|
}
|
|
176763
|
-
const sorted = [...aggregated.entries()].sort((a, b) => b[1].selfMs - a[1].selfMs).slice(0, topN2);
|
|
178990
|
+
const sorted = [...aggregated.entries()].filter(([, row]) => roundMs(row.selfMs) > 0).sort((a, b) => b[1].selfMs - a[1].selfMs).slice(0, topN2);
|
|
176764
178991
|
if (sorted.length === 0) {
|
|
176765
178992
|
return `_No CPU samples found during \`${resolvedName}\` commits._`;
|
|
176766
178993
|
}
|
|
@@ -176779,18 +179006,52 @@ Use mode=\`top_functions\` for JS CPU.`;
|
|
|
176779
179006
|
"| Function | Self (ms) | Total (ms) | Location |",
|
|
176780
179007
|
"|---|---|---|---|"
|
|
176781
179008
|
];
|
|
176782
|
-
for (const [name, { selfMs, totalMs
|
|
179009
|
+
for (const [name, { selfMs, totalMs }] of sorted) {
|
|
179010
|
+
let top;
|
|
179011
|
+
for (const location of selfMsByLocation.get(name).values()) {
|
|
179012
|
+
if (!top || location.selfMs > top.selfMs) top = location;
|
|
179013
|
+
}
|
|
179014
|
+
const { url: url2, lineNumber } = top;
|
|
176783
179015
|
const loc = url2 ? `${shortenUrl(url2)}${lineNumber != null ? `:${lineNumber}` : ""}` : "\u2014";
|
|
176784
|
-
|
|
176785
|
-
|
|
176786
|
-
);
|
|
179016
|
+
const total = roundMs(Math.max(totalMs, selfMs));
|
|
179017
|
+
lines.push(`| \`${name}\` | ${roundMs(selfMs)} | ${total} | ${loc} |`);
|
|
176787
179018
|
}
|
|
176788
179019
|
return lines.join("\n");
|
|
176789
179020
|
}
|
|
179021
|
+
function roundMs(ms3) {
|
|
179022
|
+
return Math.round(ms3 * 100) / 100;
|
|
179023
|
+
}
|
|
176790
179024
|
function shortenUrl(url2) {
|
|
176791
179025
|
const parts2 = url2.replace(/\\/g, "/").split("/");
|
|
176792
179026
|
return parts2.slice(-2).join("/");
|
|
176793
179027
|
}
|
|
179028
|
+
function nodesNestedInSameName(nodeMap, childToParent) {
|
|
179029
|
+
const nested = /* @__PURE__ */ new Set();
|
|
179030
|
+
const onPath = /* @__PURE__ */ new Map();
|
|
179031
|
+
const stack = [];
|
|
179032
|
+
for (const id of nodeMap.keys()) {
|
|
179033
|
+
if (!childToParent.has(id)) stack.push({ id, leaving: false });
|
|
179034
|
+
}
|
|
179035
|
+
while (stack.length > 0) {
|
|
179036
|
+
const { id, leaving } = stack.pop();
|
|
179037
|
+
const node2 = nodeMap.get(id);
|
|
179038
|
+
const name = node2.callFrame.functionName;
|
|
179039
|
+
const count2 = onPath.get(name) ?? 0;
|
|
179040
|
+
if (leaving) {
|
|
179041
|
+
onPath.set(name, count2 - 1);
|
|
179042
|
+
continue;
|
|
179043
|
+
}
|
|
179044
|
+
if (count2 > 0) nested.add(id);
|
|
179045
|
+
onPath.set(name, count2 + 1);
|
|
179046
|
+
stack.push({ id, leaving: true });
|
|
179047
|
+
for (const child of node2.children ?? []) {
|
|
179048
|
+
if (childToParent.get(child) === id && nodeMap.has(child)) {
|
|
179049
|
+
stack.push({ id: child, leaving: false });
|
|
179050
|
+
}
|
|
179051
|
+
}
|
|
179052
|
+
}
|
|
179053
|
+
return nested;
|
|
179054
|
+
}
|
|
176794
179055
|
var timeWindowSchema = external_exports.object({
|
|
176795
179056
|
start: external_exports.coerce.number().describe("Start of window in ms"),
|
|
176796
179057
|
end: external_exports.coerce.number().describe("End of window in ms")
|
|
@@ -182173,13 +184434,16 @@ function flowFindAll(tree, sel) {
|
|
|
182173
184434
|
}
|
|
182174
184435
|
return fallback;
|
|
182175
184436
|
}
|
|
182176
|
-
function
|
|
184437
|
+
function flowSelectorToNode(tree, sel) {
|
|
182177
184438
|
for (const s of selectorAlternatives(sel)) {
|
|
182178
|
-
const
|
|
182179
|
-
if (
|
|
184439
|
+
const node2 = selectorToNode(tree, s);
|
|
184440
|
+
if (node2) return node2;
|
|
182180
184441
|
}
|
|
182181
184442
|
return void 0;
|
|
182182
184443
|
}
|
|
184444
|
+
function flowSelectorToFrame(tree, sel) {
|
|
184445
|
+
return flowSelectorToNode(tree, sel)?.frame;
|
|
184446
|
+
}
|
|
182183
184447
|
function provenTreeOutage(env) {
|
|
182184
184448
|
const proven = env.treeOutage?.proven;
|
|
182185
184449
|
return proven && proven.deviceId === env.device.id ? proven.error : void 0;
|
|
@@ -182291,11 +184555,23 @@ async function waitForFocus(env, into, tappedFrame) {
|
|
|
182291
184555
|
}
|
|
182292
184556
|
}
|
|
182293
184557
|
var NO_SCROLLABLE_VIEW = /No scrollable view at the point/;
|
|
182294
|
-
|
|
182295
|
-
|
|
182296
|
-
|
|
184558
|
+
function leadingRoom(frame2, clip3, direction) {
|
|
184559
|
+
switch (direction) {
|
|
184560
|
+
case "down":
|
|
184561
|
+
return frame2.y - clip3.y;
|
|
184562
|
+
case "up":
|
|
184563
|
+
return clip3.y + clip3.height - (frame2.y + frame2.height);
|
|
184564
|
+
case "right":
|
|
184565
|
+
return frame2.x - clip3.x;
|
|
184566
|
+
case "left":
|
|
184567
|
+
return clip3.x + clip3.width - (frame2.x + frame2.width);
|
|
184568
|
+
}
|
|
184569
|
+
}
|
|
184570
|
+
async function scrollIncrement(env, direction, region, limit = Infinity, anchor2 = void 0) {
|
|
184571
|
+
const cx = clamp014(anchor2 ? anchor2.x : region.x + region.width / 2);
|
|
184572
|
+
const cy = clamp014(anchor2 ? anchor2.y : region.y + region.height / 2);
|
|
182297
184573
|
const extent = direction === "up" || direction === "down" ? region.height : region.width;
|
|
182298
|
-
const dist = Math.min(SCROLL_INCREMENT, Math.max(MIN_SCROLL_INCREMENT, extent / 2));
|
|
184574
|
+
const dist = Math.min(limit, SCROLL_INCREMENT, Math.max(MIN_SCROLL_INCREMENT, extent / 2));
|
|
182299
184575
|
if (isPointerDesktop(env.device)) {
|
|
182300
184576
|
const delta = direction === "down" ? { deltaY: dist } : direction === "up" ? { deltaY: -dist } : direction === "right" ? { deltaX: dist } : { deltaX: -dist };
|
|
182301
184577
|
return toolWarning(await invokeOnDevice(env, "gesture-scroll", { x: cx, y: cy, ...delta }));
|
|
@@ -182333,23 +184609,40 @@ async function scrollIncrement(env, direction, region) {
|
|
|
182333
184609
|
}
|
|
182334
184610
|
async function scrollToVisible(env, target, direction, within) {
|
|
182335
184611
|
let prevFp;
|
|
184612
|
+
let prevShown;
|
|
184613
|
+
let anchorSpent = false;
|
|
182336
184614
|
let warning;
|
|
182337
184615
|
for (let i = 0; i < MAX_SCROLL_ITERATIONS; i++) {
|
|
182338
184616
|
if (env.signal?.aborted) return { aborted: true };
|
|
182339
184617
|
const tree = await settleTree(env);
|
|
182340
184618
|
if (!tree) return { aborted: true };
|
|
182341
|
-
const
|
|
182342
|
-
if (!
|
|
184619
|
+
const container = within ? flowSelectorToNode(tree, within) : void 0;
|
|
184620
|
+
if (within && !container) {
|
|
182343
184621
|
return { reason: `scroll container ${describeSelector(within)} is not visible` };
|
|
182344
184622
|
}
|
|
182345
|
-
const
|
|
182346
|
-
|
|
184623
|
+
const targetNode = flowSelectorToNode(tree, target);
|
|
184624
|
+
const frame2 = targetNode?.frame;
|
|
184625
|
+
const cut = frame2 && targetNode.clipBounds;
|
|
184626
|
+
const vertical = direction === "up" || direction === "down";
|
|
184627
|
+
const withinCut = cut && container && axisFullyInside(frame2, direction, cut) && !axisFullyInside(frame2, direction, container.clipFrame ?? container.frame);
|
|
184628
|
+
const anchor2 = cut && !withinCut ? targetNode.clipAnchors?.[vertical ? "y" : "x"] : void 0;
|
|
184629
|
+
const axisCut = anchor2 ? cut : void 0;
|
|
184630
|
+
const region = frame2 && axisCut ? vertical ? { x: frame2.x, y: axisCut.y, width: frame2.width, height: axisCut.height } : { x: axisCut.x, y: frame2.y, width: axisCut.width, height: frame2.height } : container?.frame ?? FULL_SCREEN2;
|
|
184631
|
+
if (frame2 && axisFullyInside(frame2, direction, axisCut ?? container?.clipFrame ?? region)) {
|
|
182347
184632
|
return { frame: frame2, ...warnedBy(warning) };
|
|
182348
184633
|
}
|
|
184634
|
+
const room = frame2 && axisCut ? leadingRoom(frame2, axisCut, direction) : void 0;
|
|
184635
|
+
const shown = room === void 0 ? void 0 : (vertical ? region.height : region.width) - room;
|
|
184636
|
+
let spentNow = false;
|
|
184637
|
+
if (shown !== void 0 && prevShown !== void 0 && Math.abs(shown - prevShown) < 1e-4) {
|
|
184638
|
+
if (anchorSpent) return { frame: frame2, ...warnedBy(warning) };
|
|
184639
|
+
anchorSpent = spentNow = true;
|
|
184640
|
+
}
|
|
184641
|
+
prevShown = shown;
|
|
182349
184642
|
const scope = within ? [region] : anchorScrollFrames(tree, getDescribeTapPoint(region));
|
|
182350
184643
|
if (scope.length === 0) scope.push(FULL_SCREEN2);
|
|
182351
184644
|
const fp = treeFingerprint(tree, (node2) => scope.some((r) => framesOverlap(node2.frame, r)));
|
|
182352
|
-
if (prevFp !== void 0 && fp === prevFp) {
|
|
184645
|
+
if (!spentNow && prevFp !== void 0 && fp === prevFp) {
|
|
182353
184646
|
if (frame2) return { frame: frame2, ...warnedBy(warning) };
|
|
182354
184647
|
return {
|
|
182355
184648
|
reason: `reached the end of the scroll without finding ${describeSelector(target)}`,
|
|
@@ -182357,8 +184650,14 @@ async function scrollToVisible(env, target, direction, within) {
|
|
|
182357
184650
|
};
|
|
182358
184651
|
}
|
|
182359
184652
|
prevFp = fp;
|
|
184653
|
+
const retry = container?.frame ?? region;
|
|
184654
|
+
const retryAt = getDescribeTapPoint(retry);
|
|
184655
|
+
if (spentNow && frame2 && axisCut && frameContains(frame2, retryAt.x, retryAt.y)) {
|
|
184656
|
+
return { frame: frame2, ...warnedBy(warning) };
|
|
184657
|
+
}
|
|
182360
184658
|
try {
|
|
182361
|
-
|
|
184659
|
+
const sent = anchorSpent ? await scrollIncrement(env, direction, retry, room) : await scrollIncrement(env, direction, region, room, anchor2);
|
|
184660
|
+
warning ??= sent;
|
|
182362
184661
|
} catch (err) {
|
|
182363
184662
|
if (!(err instanceof Error && NO_SCROLLABLE_VIEW.test(err.message))) throw err;
|
|
182364
184663
|
if (frame2) return { frame: frame2, ...warnedBy(warning) };
|
|
@@ -182581,7 +184880,8 @@ async function runPinch(env, step) {
|
|
|
182581
184880
|
let sentWarning;
|
|
182582
184881
|
for (let i = 0; i < n; i++) {
|
|
182583
184882
|
if (env.signal?.aborted) return ABORTED_OUTCOME;
|
|
182584
|
-
|
|
184883
|
+
const sent = toolWarning(await invokeOnDevice(env, "gesture-pinch", args));
|
|
184884
|
+
sentWarning ??= sent;
|
|
182585
184885
|
if (i < n - 1 && !await sleepOrAbort(PINCH_SETTLE_MS, env.signal)) return ABORTED_OUTCOME;
|
|
182586
184886
|
}
|
|
182587
184887
|
return { ok: true, ...warnedBy(settle3.warning, sentWarning) };
|
|
@@ -183823,9 +186123,9 @@ function runnerSideReadClause(udid, condition) {
|
|
|
183823
186123
|
if (condition === "hidden") {
|
|
183824
186124
|
return settle3 + "This verdict says that tree still HAS the element, so the usual chromium tips are the wrong direction here: a `scroll-to` before the check, or a switch to an `id`/`role` selector, only makes the directive match more surely. Absence from `describe` is not the element having left, either \u2014 on a dense page the recorder's walk stops at 5000 nodes where the runner's goes to 12000. Narrow the selector until it matches only what you expect to leave, or gate on something that does leave; or keep the step raw";
|
|
183825
186125
|
}
|
|
183826
|
-
return settle3 + // Name both axes:
|
|
186126
|
+
return settle3 + // Name both axes: the walker clips each edge on its own, so a
|
|
183827
186127
|
// horizontally scrolled node comes back zero-WIDTH at a normal height.
|
|
183828
|
-
"A zero-area frame in `describe` means off-viewport \u2014 zero height for a node above or below
|
|
186128
|
+
"A zero-area frame in `describe` means off-viewport, clipped by an `overflow` ancestor or inside a closed `<details>` (its `<summary>` opens it) \u2014 zero height for a node cut off above or below, zero width for one cut off left or right, since the walker clips each edge on its own \u2014 and the fix for a scrolled-out node is a `scroll-to` before the check rather than a different selector; a password field reaches the runner under the name `[password]`, so only an `id`/`role` selector can match it";
|
|
183829
186129
|
}
|
|
183830
186130
|
if (platform === "macos") {
|
|
183831
186131
|
const settle3 = `No read-only tool reports the runner's flat list on macOS: \`describe\` prints the nested tree, with the windows, scroll bars and unlabelled containers the runner drops, and it stops at ${MACOS_DESCRIBE_LIMITS.maxNodes} elements where the runner reads ${MACOS_JUDGING_LIMITS.maxNodes}. Settle it by running the conversion: put the directive in an e2e test and \`e2e-execute\` it. `;
|
|
@@ -183849,7 +186149,7 @@ function treeDivergenceFor(udid, condition) {
|
|
|
183849
186149
|
if (condition === "hidden") {
|
|
183850
186150
|
return "Both read the same DOM but project it differently, and here it is the RECORDER that never saw the element: the live wait passed on absence, and this verdict says the runner's tree holds it \u2014 so nothing the runner tree DROPS can be the cause. What is left is the recorder's own limit: its walk stops at 5000 nodes where the runner tree's goes to 12000, so on a dense page the element is past the end of what it read." + SCREEN_MAY_HAVE_MOVED;
|
|
183851
186151
|
}
|
|
183852
|
-
return "Both read the same DOM but project it differently, and here it is the RUNNER's side to check: the live wait passed, so the recorder's tree did hold a matching element and its 5000-node walk limit is not what went wrong. The runner tree keeps only addressable nodes (id, label, value, clickable or focused) whose frame the walker did not
|
|
186152
|
+
return "Both read the same DOM but project it differently, and here it is the RUNNER's side to check: the live wait passed, so the recorder's tree did hold a matching element and its 5000-node walk limit is not what went wrong. The runner tree keeps only addressable nodes (id, label, value, clickable or focused) whose frame the walker did not clip to zero area (off-viewport, or cut off by an `overflow` ancestor), and it redacts a password field's name to `[password]`." + SCREEN_MAY_HAVE_MOVED;
|
|
183853
186153
|
}
|
|
183854
186154
|
if (platform === "macos") {
|
|
183855
186155
|
if (condition === "hidden") {
|
|
@@ -187230,30 +189530,14 @@ async function analyzeScreenshotTextChanges(options) {
|
|
|
187230
189530
|
};
|
|
187231
189531
|
}
|
|
187232
189532
|
return analyzeTextRegions({
|
|
187233
|
-
baselineRegions:
|
|
187234
|
-
currentRegions:
|
|
189533
|
+
baselineRegions: baselineOcr.blocks,
|
|
189534
|
+
currentRegions: currentOcr.blocks,
|
|
187235
189535
|
baselineImage: options.baselineImage,
|
|
187236
189536
|
currentImage: options.currentImage,
|
|
187237
189537
|
ignoreTopPixels: options.ignoreTopPixels,
|
|
187238
189538
|
textChangeMinConfidence: options.textChangeMinConfidence
|
|
187239
189539
|
});
|
|
187240
189540
|
}
|
|
187241
|
-
function rescaleTextRegions(regions, scale) {
|
|
187242
|
-
if (!scale || scale.x === 1 && scale.y === 1) return regions;
|
|
187243
|
-
return regions.map((region) => ({
|
|
187244
|
-
...region,
|
|
187245
|
-
bounds: scaleBounds(region.bounds, scale),
|
|
187246
|
-
words: region.words?.map((word) => ({ ...word, bounds: scaleBounds(word.bounds, scale) }))
|
|
187247
|
-
}));
|
|
187248
|
-
}
|
|
187249
|
-
function scaleBounds(bounds, scale) {
|
|
187250
|
-
return {
|
|
187251
|
-
x: bounds.x * scale.x,
|
|
187252
|
-
y: bounds.y * scale.y,
|
|
187253
|
-
width: bounds.width * scale.x,
|
|
187254
|
-
height: bounds.height * scale.y
|
|
187255
|
-
};
|
|
187256
|
-
}
|
|
187257
189541
|
function analyzeTextRegions(params) {
|
|
187258
189542
|
const textChangeMinConfidence = params.textChangeMinConfidence ?? DEFAULT_TEXT_CHANGE_MIN_CONFIDENCE;
|
|
187259
189543
|
validateTextChangeMinConfidence(textChangeMinConfidence);
|
|
@@ -187618,22 +189902,16 @@ function formatScreenshotDiffSummary(result) {
|
|
|
187618
189902
|
const coordinateSpace2 = coordinateSpaceForSummary(result.imageSize);
|
|
187619
189903
|
const lines = ["Screenshot diff summary", "", "Overall:"];
|
|
187620
189904
|
lines.push(statusLine(status));
|
|
187621
|
-
if (result.sizeNormalization) {
|
|
187622
|
-
const { baseline, current, comparedAt } = result.sizeNormalization;
|
|
187623
|
-
lines.push(
|
|
187624
|
-
`- size_normalized: baseline=${formatSize(baseline)} current=${formatSize(current)} compared_at=${formatSize(comparedAt)}`,
|
|
187625
|
-
" - the inputs share an aspect ratio but not a resolution, so the larger was downscaled before comparing; any pixel or text differences below may include resampling artifacts, and the diff images are at compared_at rather than full size",
|
|
187626
|
-
" - re-capture the baseline at the same scale as the current image (screenshot with scale: 1.0) to compare without resampling"
|
|
187627
|
-
);
|
|
187628
|
-
}
|
|
187629
189905
|
if (result.dimensionMismatch) {
|
|
187630
189906
|
lines.push(
|
|
187631
|
-
`- dimension_mismatch: expected=${formatSize(result.dimensionMismatch.expected)} actual=${formatSize(result.dimensionMismatch.actual)}
|
|
189907
|
+
`- dimension_mismatch: expected=${formatSize(result.dimensionMismatch.expected)} actual=${formatSize(result.dimensionMismatch.actual)}`,
|
|
189908
|
+
" - only images of identical dimensions are compared; capture both with the same device model, orientation, foldable posture and screenshot scale (live captures use scale: 1.0) and, on a Mac app, the same window size, counting a sheet, popover, alert or menu reaching past it"
|
|
187632
189909
|
);
|
|
187633
189910
|
} else {
|
|
187634
189911
|
lines.push(
|
|
187635
189912
|
`- pixel_mismatch: ${formatPercentage(result.mismatchPercentage)} - ${describeMismatch(result)}`
|
|
187636
189913
|
);
|
|
189914
|
+
if (result.imageSize) lines.push(`- compared_at: ${formatSize(result.imageSize)}`);
|
|
187637
189915
|
}
|
|
187638
189916
|
lines.push(
|
|
187639
189917
|
`- changed_areas: shown=${formatInteger(shownRegions.length)} total=${formatInteger(result.regions.length)} omitted=${formatInteger(Math.max(0, result.regions.length - shownRegions.length))}`
|
|
@@ -187693,7 +189971,6 @@ function screenshotDiffStatus(result) {
|
|
|
187693
189971
|
if (result.textAnalysis?.status === "ok" && result.textAnalysis.changes.length > 0) {
|
|
187694
189972
|
return "changed";
|
|
187695
189973
|
}
|
|
187696
|
-
if (result.sizeNormalization) return "resized_no_change";
|
|
187697
189974
|
return "unchanged";
|
|
187698
189975
|
}
|
|
187699
189976
|
function formatSize(size) {
|
|
@@ -187911,26 +190188,13 @@ var HORIZONTAL_TEXT_MERGE_MAX_GAP = 120;
|
|
|
187911
190188
|
var UNIFORM_BRIGHTNESS_DELTA_TOLERANCE = 4;
|
|
187912
190189
|
async function diffPngFiles(options) {
|
|
187913
190190
|
const settings = resolveDiffSettings(options.topMask ?? "status-bar");
|
|
187914
|
-
const [
|
|
190191
|
+
const [baseline, current] = await Promise.all([
|
|
187915
190192
|
decodePngFile(options.baselinePath),
|
|
187916
190193
|
decodePngFile(options.currentPath)
|
|
187917
190194
|
]);
|
|
187918
|
-
|
|
187919
|
-
|
|
187920
|
-
return summarizeResult(
|
|
187921
|
-
buildDimensionMismatchResult({
|
|
187922
|
-
baseline: decodedBaseline,
|
|
187923
|
-
current: decodedCurrent
|
|
187924
|
-
})
|
|
187925
|
-
);
|
|
190195
|
+
if (baseline.width !== current.width || baseline.height !== current.height) {
|
|
190196
|
+
return summarizeResult(buildDimensionMismatchResult({ baseline, current }));
|
|
187926
190197
|
}
|
|
187927
|
-
const baseline = normalized.baseline;
|
|
187928
|
-
const current = normalized.current;
|
|
187929
|
-
const sizeNormalization = decodedBaseline.width === decodedCurrent.width && decodedBaseline.height === decodedCurrent.height ? void 0 : {
|
|
187930
|
-
baseline: { width: decodedBaseline.width, height: decodedBaseline.height },
|
|
187931
|
-
current: { width: decodedCurrent.width, height: decodedCurrent.height },
|
|
187932
|
-
comparedAt: { width: baseline.width, height: baseline.height }
|
|
187933
|
-
};
|
|
187934
190198
|
const totalPixels = baseline.width * baseline.height;
|
|
187935
190199
|
const pixelDiff = markChangedPixels({
|
|
187936
190200
|
baseline,
|
|
@@ -187960,8 +190224,6 @@ async function diffPngFiles(options) {
|
|
|
187960
190224
|
hasPixelDiff: pixelDiff.differentPixels > 0,
|
|
187961
190225
|
baselineImage: baseline,
|
|
187962
190226
|
currentImage: current,
|
|
187963
|
-
baselineRegionScale: regionScaleBetween(decodedBaseline, baseline),
|
|
187964
|
-
currentRegionScale: regionScaleBetween(decodedCurrent, current),
|
|
187965
190227
|
ignoreTopPixels: ignoredTopRowsFor(baseline.height, settings.ignoreTopNormalizedY),
|
|
187966
190228
|
textChangeMinConfidence: DEFAULT_TEXT_CHANGE_MIN_CONFIDENCE
|
|
187967
190229
|
});
|
|
@@ -187973,8 +190235,7 @@ async function diffPngFiles(options) {
|
|
|
187973
190235
|
diffPath: artifactPaths.diffPath,
|
|
187974
190236
|
contextDiffPath: artifactPaths.contextDiffPath,
|
|
187975
190237
|
regions,
|
|
187976
|
-
textAnalysis
|
|
187977
|
-
...sizeNormalization && { sizeNormalization }
|
|
190238
|
+
textAnalysis
|
|
187978
190239
|
});
|
|
187979
190240
|
}
|
|
187980
190241
|
function resolveDiffSettings(topMask) {
|
|
@@ -187988,9 +190249,6 @@ function resolveDiffSettings(topMask) {
|
|
|
187988
190249
|
function summarizeResult(result) {
|
|
187989
190250
|
return { ...result, summary: formatScreenshotDiffSummary(result) };
|
|
187990
190251
|
}
|
|
187991
|
-
function sameDimensionsOrNull(baseline, current) {
|
|
187992
|
-
return baseline.width === current.width && baseline.height === current.height ? { baseline, current } : null;
|
|
187993
|
-
}
|
|
187994
190252
|
function buildDimensionMismatchResult(params) {
|
|
187995
190253
|
return {
|
|
187996
190254
|
totalPixels: params.baseline.width * params.baseline.height,
|
|
@@ -188034,12 +190292,6 @@ function markChangedPixels(params) {
|
|
|
188034
190292
|
function ignoredTopRowsFor(height, ignoreTopNormalizedY) {
|
|
188035
190293
|
return Math.min(height, Math.ceil(height * ignoreTopNormalizedY));
|
|
188036
190294
|
}
|
|
188037
|
-
function regionScaleBetween(from2, to) {
|
|
188038
|
-
return {
|
|
188039
|
-
x: from2.width === 0 ? 1 : to.width / from2.width,
|
|
188040
|
-
y: from2.height === 0 ? 1 : to.height / from2.height
|
|
188041
|
-
};
|
|
188042
|
-
}
|
|
188043
190295
|
function getChangedRegions(params) {
|
|
188044
190296
|
const rawRegions = traceChangeRegions({
|
|
188045
190297
|
mask: params.mask,
|
|
@@ -188640,10 +190892,7 @@ async function runSnapshot(env, opts) {
|
|
|
188640
190892
|
// band (a vacuous pass); a crop overlapping the band leans on the run's
|
|
188641
190893
|
// best-effort pinStatusBar instead. A Mac window has no status bar: its
|
|
188642
190894
|
// top band is the title bar and toolbar, compared like the rest.
|
|
188643
|
-
topMask: cropFrame === void 0 && env.device.platform !== "macos" ? "status-bar" : "none"
|
|
188644
|
-
// Crop dimensions track the element — size drift must hard-fail below
|
|
188645
|
-
// instead of being resampled away like a full-screen scale difference.
|
|
188646
|
-
...cropFrame !== void 0 && { normalizeSizes: false }
|
|
190895
|
+
topMask: cropFrame === void 0 && env.device.platform !== "macos" ? "status-bar" : "none"
|
|
188647
190896
|
}).catch((err) => {
|
|
188648
190897
|
throw opts.clientFlowPath === void 0 ? err : namingClientBaseline(err, localBaseline, baselinePath);
|
|
188649
190898
|
});
|
|
@@ -188892,15 +191141,18 @@ function flowLaunchGateReason(bundleId, state3) {
|
|
|
188892
191141
|
}
|
|
188893
191142
|
async function waitForVegaAutomation(device, signal) {
|
|
188894
191143
|
const deadline = Date.now() + NATIVE_READY_TIMEOUT_MS;
|
|
191144
|
+
let reason2;
|
|
188895
191145
|
for (; ; ) {
|
|
188896
|
-
if (signal?.aborted) return false;
|
|
191146
|
+
if (signal?.aborted) return { ready: false };
|
|
188897
191147
|
try {
|
|
188898
191148
|
const data = await describeVega(device.id);
|
|
188899
|
-
if (!data.hint) return true;
|
|
188900
|
-
|
|
191149
|
+
if (!data.hint) return { ready: true };
|
|
191150
|
+
reason2 = void 0;
|
|
191151
|
+
} catch (err) {
|
|
191152
|
+
reason2 = err instanceof Error ? err.message : String(err);
|
|
188901
191153
|
}
|
|
188902
|
-
if (Date.now() >= deadline) return false;
|
|
188903
|
-
if (!await sleepOrAbort(NATIVE_READY_POLL_MS, signal)) return false;
|
|
191154
|
+
if (Date.now() >= deadline) return { ready: false, reason: reason2 };
|
|
191155
|
+
if (!await sleepOrAbort(NATIVE_READY_POLL_MS, signal)) return { ready: false };
|
|
188904
191156
|
}
|
|
188905
191157
|
}
|
|
188906
191158
|
async function androidDevtoolsReady(registry2, device) {
|
|
@@ -188935,8 +191187,9 @@ async function treeSourceGate(registry2, device, bundleId, signal) {
|
|
|
188935
191187
|
}
|
|
188936
191188
|
}
|
|
188937
191189
|
if (device.platform === "vega" && !signal?.aborted) {
|
|
188938
|
-
const ready2 = await waitForVegaAutomation(device, signal);
|
|
191190
|
+
const { ready: ready2, reason: reason2 } = await waitForVegaAutomation(device, signal);
|
|
188939
191191
|
if (!ready2 && !signal?.aborted) {
|
|
191192
|
+
if (reason2) return `Vega device discovery failed: ${reason2}`;
|
|
188940
191193
|
return `the Vega automation toolkit never served a page source for ${bundleId} (the runner tree source). The toolkit attaches at app launch \u2014 re-run to relaunch; if it keeps failing, confirm the app was built with automation support and the VVD is reachable over adb.`;
|
|
188941
191194
|
}
|
|
188942
191195
|
}
|
|
@@ -190524,7 +192777,7 @@ init_zod();
|
|
|
190524
192777
|
|
|
190525
192778
|
// ../tool-server/src/utils/workspace-reader.ts
|
|
190526
192779
|
var import_promises22 = require("node:fs/promises");
|
|
190527
|
-
var
|
|
192780
|
+
var import_node_path31 = require("node:path");
|
|
190528
192781
|
var import_node_child_process54 = require("node:child_process");
|
|
190529
192782
|
var import_dotenv2 = __toESM(require_dist());
|
|
190530
192783
|
async function exists2(path72) {
|
|
@@ -190612,7 +192865,7 @@ async function detectLockfile(workspacePath) {
|
|
|
190612
192865
|
const checks = await Promise.all(
|
|
190613
192866
|
LOCKFILES.map(async (name) => ({
|
|
190614
192867
|
name,
|
|
190615
|
-
exists: await exists2((0,
|
|
192868
|
+
exists: await exists2((0, import_node_path31.join)(workspacePath, name))
|
|
190616
192869
|
}))
|
|
190617
192870
|
);
|
|
190618
192871
|
return checks.find((c) => c.exists)?.name ?? null;
|
|
@@ -190631,7 +192884,7 @@ var CI_CONFIGS = [
|
|
|
190631
192884
|
];
|
|
190632
192885
|
async function detectCiConfig(workspacePath) {
|
|
190633
192886
|
for (const ci of CI_CONFIGS) {
|
|
190634
|
-
if (await exists2((0,
|
|
192887
|
+
if (await exists2((0, import_node_path31.join)(workspacePath, ci.path))) return ci.label;
|
|
190635
192888
|
}
|
|
190636
192889
|
return null;
|
|
190637
192890
|
}
|
|
@@ -190652,7 +192905,7 @@ async function detectLintStagedConfig(workspacePath, packageJson) {
|
|
|
190652
192905
|
return packageJson["lint-staged"];
|
|
190653
192906
|
}
|
|
190654
192907
|
for (const file2 of LINT_STAGED_FILES) {
|
|
190655
|
-
const full = (0,
|
|
192908
|
+
const full = (0, import_node_path31.join)(workspacePath, file2);
|
|
190656
192909
|
if (await exists2(full)) {
|
|
190657
192910
|
if (file2.endsWith(".json") || file2 === ".lintstagedrc") {
|
|
190658
192911
|
return readJsonFile(full);
|
|
@@ -190694,7 +192947,7 @@ var CONFIG_FILES = [
|
|
|
190694
192947
|
async function detectConfigFiles(workspacePath) {
|
|
190695
192948
|
const results = await Promise.allSettled(
|
|
190696
192949
|
CONFIG_FILES.map(async (file2) => {
|
|
190697
|
-
if (await exists2((0,
|
|
192950
|
+
if (await exists2((0, import_node_path31.join)(workspacePath, file2))) return file2;
|
|
190698
192951
|
return null;
|
|
190699
192952
|
})
|
|
190700
192953
|
);
|
|
@@ -190733,7 +192986,7 @@ async function detectEnvFiles(workspacePath) {
|
|
|
190733
192986
|
const envFileNames = entries.filter((e) => e === ".env" || e.startsWith(".env."));
|
|
190734
192987
|
const results = await Promise.all(
|
|
190735
192988
|
envFileNames.map(async (name) => {
|
|
190736
|
-
const content = await readTextFile((0,
|
|
192989
|
+
const content = await readTextFile((0, import_node_path31.join)(workspacePath, name));
|
|
190737
192990
|
return {
|
|
190738
192991
|
name,
|
|
190739
192992
|
keys: content ? extractEnvKeys(content) : []
|
|
@@ -190760,34 +193013,34 @@ async function readWorkspaceSnapshot(workspacePath) {
|
|
|
190760
193013
|
ciConfig,
|
|
190761
193014
|
configFilesFound
|
|
190762
193015
|
] = await Promise.all([
|
|
190763
|
-
readJsonFile((0,
|
|
190764
|
-
readJsonFile((0,
|
|
190765
|
-
readJsonFile((0,
|
|
190766
|
-
readJsonFile((0,
|
|
190767
|
-
readTextFile((0,
|
|
190768
|
-
(r) => r ?? readTextFile((0,
|
|
193016
|
+
readJsonFile((0, import_node_path31.join)(workspacePath, "package.json")),
|
|
193017
|
+
readJsonFile((0, import_node_path31.join)(workspacePath, "app.json")),
|
|
193018
|
+
readJsonFile((0, import_node_path31.join)(workspacePath, "eas.json")),
|
|
193019
|
+
readJsonFile((0, import_node_path31.join)(workspacePath, "tsconfig.json")),
|
|
193020
|
+
readTextFile((0, import_node_path31.join)(workspacePath, "metro.config.js")).then(
|
|
193021
|
+
(r) => r ?? readTextFile((0, import_node_path31.join)(workspacePath, "metro.config.ts"))
|
|
190769
193022
|
),
|
|
190770
|
-
readTextFile((0,
|
|
190771
|
-
(r) => r ?? readTextFile((0,
|
|
193023
|
+
readTextFile((0, import_node_path31.join)(workspacePath, "babel.config.js")).then(
|
|
193024
|
+
(r) => r ?? readTextFile((0, import_node_path31.join)(workspacePath, "babel.config.cjs"))
|
|
190772
193025
|
),
|
|
190773
|
-
isDirectory2((0,
|
|
190774
|
-
isDirectory2((0,
|
|
193026
|
+
isDirectory2((0, import_node_path31.join)(workspacePath, "ios")),
|
|
193027
|
+
isDirectory2((0, import_node_path31.join)(workspacePath, "android")),
|
|
190775
193028
|
detectLockfile(workspacePath),
|
|
190776
193029
|
detectEnvFiles(workspacePath),
|
|
190777
193030
|
detectToolVersions(workspacePath),
|
|
190778
|
-
listDir((0,
|
|
190779
|
-
listDir((0,
|
|
193031
|
+
listDir((0, import_node_path31.join)(workspacePath, "scripts")),
|
|
193032
|
+
listDir((0, import_node_path31.join)(workspacePath, ".husky")),
|
|
190780
193033
|
detectCiConfig(workspacePath),
|
|
190781
193034
|
detectConfigFiles(workspacePath)
|
|
190782
193035
|
]);
|
|
190783
|
-
const iosDir = (0,
|
|
190784
|
-
const androidDir = (0,
|
|
193036
|
+
const iosDir = (0, import_node_path31.join)(workspacePath, "ios");
|
|
193037
|
+
const androidDir = (0, import_node_path31.join)(workspacePath, "android");
|
|
190785
193038
|
const [iosWorkspace, iosHasPodfile, makefileText, lintStagedConfig, androidHasGradle] = await Promise.all([
|
|
190786
193039
|
hasIosDir ? findIosWorkspace(iosDir) : Promise.resolve(null),
|
|
190787
|
-
exists2((0,
|
|
190788
|
-
readTextFile((0,
|
|
193040
|
+
exists2((0, import_node_path31.join)(workspacePath, "ios", "Podfile")),
|
|
193041
|
+
readTextFile((0, import_node_path31.join)(workspacePath, "Makefile")),
|
|
190789
193042
|
detectLintStagedConfig(workspacePath, packageJson),
|
|
190790
|
-
hasAndroidDir ? exists2((0,
|
|
193043
|
+
hasAndroidDir ? exists2((0, import_node_path31.join)(androidDir, "gradlew")) : Promise.resolve(false)
|
|
190791
193044
|
]);
|
|
190792
193045
|
const metroPort2 = metroConfigRaw ? extractMetroPort(metroConfigRaw) : null;
|
|
190793
193046
|
const makefileTargets = makefileText ? extractMakefileTargets(makefileText) : null;
|
|
@@ -191061,7 +193314,7 @@ var dismissUpdateTool = {
|
|
|
191061
193314
|
// ../tool-server/src/tools/screenshot-diff/index.ts
|
|
191062
193315
|
var import_node_crypto20 = __toESM(require("node:crypto"));
|
|
191063
193316
|
var import_promises23 = __toESM(require("fs/promises"));
|
|
191064
|
-
var
|
|
193317
|
+
var import_node_os18 = __toESM(require("node:os"));
|
|
191065
193318
|
var import_path9 = __toESM(require("path"));
|
|
191066
193319
|
init_zod();
|
|
191067
193320
|
init_src2();
|
|
@@ -191105,9 +193358,10 @@ var screenshotDiffTool = {
|
|
|
191105
193358
|
id: "screenshot-diff",
|
|
191106
193359
|
description: `Compare two PNG screenshots and return a compact visual-diff summary.
|
|
191107
193360
|
Each side is a saved PNG or a live capture from the device<flag:harmonyos> (iOS, Android or HarmonyOS)</flag:harmonyos>. baselinePath + captureCurrent is the common visual-regression flow.
|
|
193361
|
+
Both images must have identical dimensions: save baselines with screenshot scale: 1.0, one per device model. A size difference fails as a dimension mismatch.
|
|
191108
193362
|
Use when stable before/after screenshots exist and the expected result is pixel-visible: layout, spacing, color, typography, image/icon rendering, clipping, overflow, or text rendering.
|
|
191109
|
-
Physical iPhones: live captures are device-wide and need no registered app.
|
|
191110
|
-
<flag:macos-apps>Mac apps:
|
|
193363
|
+
Physical iPhones: live captures are device-wide and need no registered app.
|
|
193364
|
+
<flag:macos-apps>Mac apps: a resized window fails as a dimension mismatch.
|
|
191111
193365
|
</flag:macos-apps>Returns { summary, diffPath, contextDiffPath }. The summary uses normalized [0,1] screen locations matching describe coordinates; diffPath is the full-size diff image and contextDiffPath is a downscaled image for MCP/agent display.
|
|
191112
193366
|
Ignores the fixed top status-bar band for both pixel and OCR text comparisons.
|
|
191113
193367
|
Fails if the input sources are invalid, PNG files cannot be read, outputDir cannot be written, or the simulator-server / emulator backend<flag:harmonyos>, or \`hdc\` on HarmonyOS,</flag:harmonyos> is not reachable.`,
|
|
@@ -191212,7 +193466,7 @@ async function resolveOutputDir(params, options) {
|
|
|
191212
193466
|
}
|
|
191213
193467
|
}
|
|
191214
193468
|
const dir = import_path9.default.join(
|
|
191215
|
-
|
|
193469
|
+
import_node_os18.default.tmpdir(),
|
|
191216
193470
|
"argent-screenshot-diff",
|
|
191217
193471
|
import_node_crypto20.default.randomBytes(6).toString("hex")
|
|
191218
193472
|
);
|
|
@@ -191351,28 +193605,15 @@ async function captureHarmonyLiveInput(params) {
|
|
|
191351
193605
|
async function captureLiveInput(params) {
|
|
191352
193606
|
const panel = await resolveCapturePanel(params.api);
|
|
191353
193607
|
const captureScreenshot2 = panel ? (a, r, s, sc) => params.captureScreenshot(a, r, s, sc, panel.screen) : params.captureScreenshot;
|
|
191354
|
-
|
|
191355
|
-
|
|
191356
|
-
|
|
191357
|
-
|
|
191358
|
-
|
|
191359
|
-
|
|
191360
|
-
|
|
191361
|
-
|
|
191362
|
-
|
|
191363
|
-
params.peekFor?.(params.device)
|
|
191364
|
-
);
|
|
191365
|
-
} catch {
|
|
191366
|
-
capture = await captureScreenshotUpright(
|
|
191367
|
-
params.api,
|
|
191368
|
-
params.device,
|
|
191369
|
-
params.rotation,
|
|
191370
|
-
params.signal,
|
|
191371
|
-
void 0,
|
|
191372
|
-
captureScreenshot2,
|
|
191373
|
-
params.peekFor?.(params.device)
|
|
191374
|
-
);
|
|
191375
|
-
}
|
|
193608
|
+
const capture = await captureScreenshotUpright(
|
|
193609
|
+
params.api,
|
|
193610
|
+
params.device,
|
|
193611
|
+
params.rotation,
|
|
193612
|
+
params.signal,
|
|
193613
|
+
1,
|
|
193614
|
+
captureScreenshot2,
|
|
193615
|
+
params.peekFor?.(params.device)
|
|
193616
|
+
);
|
|
191376
193617
|
const suffix = import_node_crypto20.default.randomBytes(4).toString("hex");
|
|
191377
193618
|
const destination = import_path9.default.join(params.outputDir, `${params.name}-${suffix}.live.png`);
|
|
191378
193619
|
await import_promises23.default.mkdir(params.outputDir, { recursive: true });
|
|
@@ -192685,7 +194926,7 @@ function start() {
|
|
|
192685
194926
|
attachRegistryLogger(registry2);
|
|
192686
194927
|
let eventLog = null;
|
|
192687
194928
|
if (isFlagEnabled("tool-server-event-log")) {
|
|
192688
|
-
const eventLogPath = process.env.ARGENT_EVENT_LOG || path71.join((0,
|
|
194929
|
+
const eventLogPath = process.env.ARGENT_EVENT_LOG || path71.join((0, import_node_os19.homedir)(), ".argent", "tool-server-events.jsonl");
|
|
192689
194930
|
try {
|
|
192690
194931
|
eventLog = createToolServerEventLog({ filePath: eventLogPath });
|
|
192691
194932
|
} catch (err) {
|