ax-grep 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +154 -1
- package/dist/browser.d.ts +11 -0
- package/dist/browser.js +12 -0
- package/dist/browser.js.map +1 -0
- package/dist/chunk-U3GDKPLQ.js +578 -0
- package/dist/chunk-U3GDKPLQ.js.map +1 -0
- package/dist/chunk-Z7V6PIPH.js +735 -0
- package/dist/chunk-Z7V6PIPH.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +402 -0
- package/dist/index.js.map +1 -0
- package/dist/static.d.ts +6 -0
- package/dist/static.js +8 -0
- package/dist/static.js.map +1 -0
- package/dist/types-dgf3brcf.d.ts +74 -0
- package/package.json +61 -5
- package/index.js +0 -1
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
// src/browser.ts
|
|
2
|
+
var defaultOptions = {
|
|
3
|
+
mode: "compact",
|
|
4
|
+
includeBounds: true,
|
|
5
|
+
includeAttributes: true,
|
|
6
|
+
includeTextNodes: true,
|
|
7
|
+
includeHidden: false,
|
|
8
|
+
includeSelectOptions: true,
|
|
9
|
+
excludeLikelyAds: false,
|
|
10
|
+
excludeLikelyBoilerplate: false,
|
|
11
|
+
pruneCustomElementWrappers: true,
|
|
12
|
+
pruneCollapsedSubtrees: true,
|
|
13
|
+
pruneLikelyClosedOverlays: false,
|
|
14
|
+
summarizeLargeSubtrees: false,
|
|
15
|
+
summarizeLikelyLinkFarms: false,
|
|
16
|
+
summarizeRepeatedSubtrees: false,
|
|
17
|
+
maxChildrenPerNode: 80,
|
|
18
|
+
maxLinkFarmChildren: 24,
|
|
19
|
+
maxRepeatedSubtreeInstances: 3,
|
|
20
|
+
maxTextLength: 240
|
|
21
|
+
};
|
|
22
|
+
var defaultObserverOptions = {
|
|
23
|
+
debounceMs: 50
|
|
24
|
+
};
|
|
25
|
+
var interactiveRoles = /* @__PURE__ */ new Set([
|
|
26
|
+
"button",
|
|
27
|
+
"checkbox",
|
|
28
|
+
"combobox",
|
|
29
|
+
"link",
|
|
30
|
+
"listbox",
|
|
31
|
+
"menuitem",
|
|
32
|
+
"menuitemcheckbox",
|
|
33
|
+
"menuitemradio",
|
|
34
|
+
"option",
|
|
35
|
+
"radio",
|
|
36
|
+
"searchbox",
|
|
37
|
+
"slider",
|
|
38
|
+
"spinbutton",
|
|
39
|
+
"switch",
|
|
40
|
+
"tab",
|
|
41
|
+
"textbox",
|
|
42
|
+
"treeitem"
|
|
43
|
+
]);
|
|
44
|
+
var landmarkTags = {
|
|
45
|
+
article: "article",
|
|
46
|
+
aside: "complementary",
|
|
47
|
+
footer: "contentinfo",
|
|
48
|
+
form: "form",
|
|
49
|
+
header: "banner",
|
|
50
|
+
main: "main",
|
|
51
|
+
nav: "navigation",
|
|
52
|
+
section: "region"
|
|
53
|
+
};
|
|
54
|
+
var rolesNamedFromContents = /* @__PURE__ */ new Set([
|
|
55
|
+
"button",
|
|
56
|
+
"cell",
|
|
57
|
+
"checkbox",
|
|
58
|
+
"columnheader",
|
|
59
|
+
"heading",
|
|
60
|
+
"link",
|
|
61
|
+
"menuitem",
|
|
62
|
+
"menuitemcheckbox",
|
|
63
|
+
"menuitemradio",
|
|
64
|
+
"option",
|
|
65
|
+
"radio",
|
|
66
|
+
"rowheader",
|
|
67
|
+
"switch",
|
|
68
|
+
"tab",
|
|
69
|
+
"treeitem"
|
|
70
|
+
]);
|
|
71
|
+
function extractSemanticTree(options = {}) {
|
|
72
|
+
const rootDocument = document;
|
|
73
|
+
const context = {
|
|
74
|
+
options: { ...defaultOptions, ...options },
|
|
75
|
+
nextId: 1,
|
|
76
|
+
rootDocument
|
|
77
|
+
};
|
|
78
|
+
return walkElement(rootDocument.body ?? rootDocument.documentElement, context) ?? unavailableNode(context, "document", "Document has no inspectable body");
|
|
79
|
+
}
|
|
80
|
+
function formatSemanticTreeText(node) {
|
|
81
|
+
const lines = [];
|
|
82
|
+
function visit(current, depth) {
|
|
83
|
+
const prefix = " ".repeat(depth);
|
|
84
|
+
const role = current.role ?? current.tag;
|
|
85
|
+
const marker = current.interactive ? "[i] " : "";
|
|
86
|
+
const name = current.name ? ` '${current.name}'` : "";
|
|
87
|
+
const state = formatState(current.state);
|
|
88
|
+
const unavailable = current.unavailableReason ? ` (${current.unavailableReason})` : "";
|
|
89
|
+
lines.push(`${prefix}${marker}${role}${name}${state}${unavailable}`);
|
|
90
|
+
for (const child of current.children) visit(child, depth + 1);
|
|
91
|
+
}
|
|
92
|
+
visit(node, 0);
|
|
93
|
+
return lines.join("\n");
|
|
94
|
+
}
|
|
95
|
+
function observeSemanticTree(onChange, options = {}) {
|
|
96
|
+
const root = document.documentElement;
|
|
97
|
+
const observerOptions = { ...defaultObserverOptions, ...options };
|
|
98
|
+
let mutationCount = 0;
|
|
99
|
+
let timeoutId;
|
|
100
|
+
function snapshot() {
|
|
101
|
+
return extractSemanticTree(options);
|
|
102
|
+
}
|
|
103
|
+
function emit() {
|
|
104
|
+
timeoutId = void 0;
|
|
105
|
+
onChange({
|
|
106
|
+
tree: snapshot(),
|
|
107
|
+
changedAt: Date.now(),
|
|
108
|
+
mutationCount
|
|
109
|
+
});
|
|
110
|
+
mutationCount = 0;
|
|
111
|
+
}
|
|
112
|
+
const observer = new MutationObserver((mutations) => {
|
|
113
|
+
mutationCount += mutations.length;
|
|
114
|
+
if (timeoutId !== void 0) window.clearTimeout(timeoutId);
|
|
115
|
+
timeoutId = window.setTimeout(emit, observerOptions.debounceMs);
|
|
116
|
+
});
|
|
117
|
+
observer.observe(root, {
|
|
118
|
+
attributes: true,
|
|
119
|
+
characterData: true,
|
|
120
|
+
childList: true,
|
|
121
|
+
subtree: true
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
disconnect() {
|
|
125
|
+
if (timeoutId !== void 0) window.clearTimeout(timeoutId);
|
|
126
|
+
observer.disconnect();
|
|
127
|
+
},
|
|
128
|
+
snapshot
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function walkElement(element, context) {
|
|
132
|
+
if (!context.options.includeHidden && isHidden(element)) return null;
|
|
133
|
+
if (context.options.excludeLikelyAds && isLikelyAd(element)) return null;
|
|
134
|
+
const role = getRole(element);
|
|
135
|
+
const state = getState(element);
|
|
136
|
+
const focusable = isFocusable(element);
|
|
137
|
+
const interactive = isInteractive(element, role, focusable);
|
|
138
|
+
const name = role ? computeName(element, role, context) : "";
|
|
139
|
+
const description = computeDescription(element, context);
|
|
140
|
+
const tag = element.tagName.toLowerCase();
|
|
141
|
+
const children = collectChildren(element, context);
|
|
142
|
+
if (context.options.mode === "interactive" && !interactive) {
|
|
143
|
+
return children.length > 0 ? containerNode(context, tag, children) : null;
|
|
144
|
+
}
|
|
145
|
+
if (shouldPrune(element, role, name, interactive, children, context)) {
|
|
146
|
+
return children.length === 1 ? children[0] ?? null : containerNode(context, tag, children);
|
|
147
|
+
}
|
|
148
|
+
const node = {
|
|
149
|
+
id: nextId(context),
|
|
150
|
+
tag,
|
|
151
|
+
role,
|
|
152
|
+
name,
|
|
153
|
+
interactive,
|
|
154
|
+
focusable,
|
|
155
|
+
children
|
|
156
|
+
};
|
|
157
|
+
if (description) node.description = description;
|
|
158
|
+
const text = getDirectText(element, context.options.maxTextLength);
|
|
159
|
+
if (text) node.text = text;
|
|
160
|
+
const value = getValue(element);
|
|
161
|
+
if (value) node.value = value;
|
|
162
|
+
if (Object.keys(state).length > 0) node.state = state;
|
|
163
|
+
node.selector = getCssPath(element);
|
|
164
|
+
node.xpath = getXPath(element);
|
|
165
|
+
if (context.options.includeBounds) node.bounds = getBounds(element);
|
|
166
|
+
if (context.options.includeAttributes) node.attributes = getAttributes(element);
|
|
167
|
+
appendSpecialChildren(element, node, context);
|
|
168
|
+
appendShadowChildren(element, node, context);
|
|
169
|
+
appendFrameChildren(element, node, context);
|
|
170
|
+
return node;
|
|
171
|
+
}
|
|
172
|
+
function collectChildren(element, context) {
|
|
173
|
+
const children = [];
|
|
174
|
+
for (const child of Array.from(element.childNodes)) {
|
|
175
|
+
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
176
|
+
if (!context.options.includeSelectOptions && element instanceof HTMLSelectElement) continue;
|
|
177
|
+
const semanticChild = walkElement(child, context);
|
|
178
|
+
if (semanticChild) children.push(semanticChild);
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (context.options.includeTextNodes && child.nodeType === Node.TEXT_NODE) {
|
|
182
|
+
const text = normalizeText(child.textContent ?? "", context.options.maxTextLength);
|
|
183
|
+
if (text) {
|
|
184
|
+
children.push({
|
|
185
|
+
id: nextId(context),
|
|
186
|
+
tag: "#text",
|
|
187
|
+
role: "text",
|
|
188
|
+
name: text,
|
|
189
|
+
text,
|
|
190
|
+
interactive: false,
|
|
191
|
+
focusable: false,
|
|
192
|
+
children: []
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return children;
|
|
198
|
+
}
|
|
199
|
+
function shouldPrune(element, role, name, interactive, children, context) {
|
|
200
|
+
if (context.options.mode === "full") return false;
|
|
201
|
+
if (role === "none" || role === "presentation") return true;
|
|
202
|
+
if (interactive) return false;
|
|
203
|
+
if (context.options.pruneCustomElementWrappers && isCustomElement(element)) return children.length > 0;
|
|
204
|
+
if (role && role !== "generic") return false;
|
|
205
|
+
if (name) return false;
|
|
206
|
+
if (element.id || element.getAttribute("aria-label") || element.getAttribute("aria-labelledby")) return false;
|
|
207
|
+
return children.length > 0;
|
|
208
|
+
}
|
|
209
|
+
function getRole(element) {
|
|
210
|
+
const explicit = firstToken(element.getAttribute("role"));
|
|
211
|
+
if (explicit) return explicit;
|
|
212
|
+
const tag = element.tagName.toLowerCase();
|
|
213
|
+
if (tag === "section" && !hasExplicitNameSource(element)) return null;
|
|
214
|
+
if (tag === "form" && !hasExplicitNameSource(element)) return null;
|
|
215
|
+
if (tag in landmarkTags) return landmarkTags[tag] ?? null;
|
|
216
|
+
if (/^h[1-6]$/.test(tag)) return "heading";
|
|
217
|
+
if (tag === "a" || tag === "area") return element.hasAttribute("href") ? "link" : null;
|
|
218
|
+
if (tag === "button") return "button";
|
|
219
|
+
if (tag === "details") return "group";
|
|
220
|
+
if (tag === "dialog") return "dialog";
|
|
221
|
+
if (tag === "fieldset") return "group";
|
|
222
|
+
if (tag === "figure") return "figure";
|
|
223
|
+
if (tag === "iframe") return "iframe";
|
|
224
|
+
if (tag === "img") return hasEmptyAlt(element) ? "presentation" : "img";
|
|
225
|
+
if (tag === "li") return "listitem";
|
|
226
|
+
if (tag === "ol" || tag === "ul") return "list";
|
|
227
|
+
if (tag === "optgroup") return "group";
|
|
228
|
+
if (tag === "option") return "option";
|
|
229
|
+
if (tag === "output") return "status";
|
|
230
|
+
if (tag === "progress") return "progressbar";
|
|
231
|
+
if (tag === "select") return element.hasAttribute("multiple") ? "listbox" : "combobox";
|
|
232
|
+
if (tag === "summary") return "button";
|
|
233
|
+
if (tag === "table") return "table";
|
|
234
|
+
if (tag === "caption") return "caption";
|
|
235
|
+
if (tag === "tbody" || tag === "tfoot" || tag === "thead") return "rowgroup";
|
|
236
|
+
if (tag === "td") return "cell";
|
|
237
|
+
if (tag === "textarea") return "textbox";
|
|
238
|
+
if (tag === "th") return element.getAttribute("scope") === "row" ? "rowheader" : "columnheader";
|
|
239
|
+
if (tag === "tr") return "row";
|
|
240
|
+
if (tag === "input") return inputRole(element);
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
function inputRole(input) {
|
|
244
|
+
const type = (input.getAttribute("type") || "text").toLowerCase();
|
|
245
|
+
if (type === "button" || type === "image" || type === "reset" || type === "submit") return "button";
|
|
246
|
+
if (type === "checkbox") return "checkbox";
|
|
247
|
+
if (type === "email" || type === "tel" || type === "text" || type === "url") return "textbox";
|
|
248
|
+
if (type === "number") return "spinbutton";
|
|
249
|
+
if (type === "radio") return "radio";
|
|
250
|
+
if (type === "range") return "slider";
|
|
251
|
+
if (type === "search") return "searchbox";
|
|
252
|
+
if (type === "hidden") return null;
|
|
253
|
+
return "textbox";
|
|
254
|
+
}
|
|
255
|
+
function computeName(element, role, context) {
|
|
256
|
+
if (element.getAttribute("aria-labelledby")) {
|
|
257
|
+
const labelled = textFromIds(element.getAttribute("aria-labelledby") ?? "", context.rootDocument);
|
|
258
|
+
if (labelled) return labelled;
|
|
259
|
+
}
|
|
260
|
+
const ariaLabel = element.getAttribute("aria-label");
|
|
261
|
+
if (ariaLabel) return normalizeText(ariaLabel, context.options.maxTextLength);
|
|
262
|
+
if (element instanceof HTMLInputElement && isButtonLikeInput(element)) {
|
|
263
|
+
return normalizeText(element.value || element.getAttribute("value") || inputFallbackName(element), context.options.maxTextLength);
|
|
264
|
+
}
|
|
265
|
+
if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement) {
|
|
266
|
+
const label = labelText(element, context);
|
|
267
|
+
if (label) return label;
|
|
268
|
+
const placeholder = element.getAttribute("placeholder");
|
|
269
|
+
if (placeholder) return normalizeText(placeholder, context.options.maxTextLength);
|
|
270
|
+
}
|
|
271
|
+
if (element instanceof HTMLImageElement) {
|
|
272
|
+
return normalizeText(element.alt || element.getAttribute("title") || "", context.options.maxTextLength);
|
|
273
|
+
}
|
|
274
|
+
if (element instanceof HTMLFieldSetElement) {
|
|
275
|
+
const legend = element.querySelector(":scope > legend");
|
|
276
|
+
if (legend) return getVisibleText(legend, context.options.maxTextLength);
|
|
277
|
+
}
|
|
278
|
+
if (rolesNamedFromContents.has(role)) {
|
|
279
|
+
const ownText = getVisibleText(element, context.options.maxTextLength);
|
|
280
|
+
if (ownText) return ownText;
|
|
281
|
+
}
|
|
282
|
+
return normalizeText(element.getAttribute("title") ?? "", context.options.maxTextLength);
|
|
283
|
+
}
|
|
284
|
+
function computeDescription(element, context) {
|
|
285
|
+
const describedBy = element.getAttribute("aria-describedby");
|
|
286
|
+
if (describedBy) return textFromIds(describedBy, context.rootDocument);
|
|
287
|
+
return normalizeText(element.getAttribute("title") ?? "", context.options.maxTextLength);
|
|
288
|
+
}
|
|
289
|
+
function labelText(element, context) {
|
|
290
|
+
if (element.labels && element.labels.length > 0) {
|
|
291
|
+
return normalizeText(Array.from(element.labels).map((label) => getVisibleText(label, context.options.maxTextLength)).join(" "), context.options.maxTextLength);
|
|
292
|
+
}
|
|
293
|
+
return "";
|
|
294
|
+
}
|
|
295
|
+
function getState(element) {
|
|
296
|
+
const state = {};
|
|
297
|
+
if (isHidden(element)) state.hidden = true;
|
|
298
|
+
if (isDisabled(element)) state.disabled = true;
|
|
299
|
+
if (element === document.activeElement) state.focused = true;
|
|
300
|
+
const checked = ariaBooleanOrMixed(element.getAttribute("aria-checked"));
|
|
301
|
+
if (checked !== void 0) state.checked = checked;
|
|
302
|
+
else if (element instanceof HTMLInputElement && (element.type === "checkbox" || element.type === "radio")) {
|
|
303
|
+
state.checked = element.checked;
|
|
304
|
+
}
|
|
305
|
+
const selected = ariaBoolean(element.getAttribute("aria-selected"));
|
|
306
|
+
if (selected !== void 0) state.selected = selected;
|
|
307
|
+
else if (element instanceof HTMLOptionElement) state.selected = element.selected;
|
|
308
|
+
const expanded = ariaBoolean(element.getAttribute("aria-expanded"));
|
|
309
|
+
if (expanded !== void 0) state.expanded = expanded;
|
|
310
|
+
const pressed = ariaBooleanOrMixed(element.getAttribute("aria-pressed"));
|
|
311
|
+
if (pressed !== void 0) state.pressed = pressed;
|
|
312
|
+
const required = ariaBoolean(element.getAttribute("aria-required"));
|
|
313
|
+
if (required !== void 0) state.required = required;
|
|
314
|
+
else if ("required" in element && Boolean(element.required)) state.required = true;
|
|
315
|
+
const invalid = element.getAttribute("aria-invalid");
|
|
316
|
+
if (invalid && invalid !== "false") state.invalid = invalid === "true" ? true : invalid;
|
|
317
|
+
if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {
|
|
318
|
+
if (element.readOnly) state.readonly = true;
|
|
319
|
+
}
|
|
320
|
+
return state;
|
|
321
|
+
}
|
|
322
|
+
function isHidden(element) {
|
|
323
|
+
if (element.hasAttribute("hidden")) return true;
|
|
324
|
+
if (element.getAttribute("aria-hidden") === "true") return true;
|
|
325
|
+
const style = getComputedStyle(element);
|
|
326
|
+
if (style.display === "none" || style.visibility === "hidden" || style.contentVisibility === "hidden") return true;
|
|
327
|
+
if (Number(style.opacity) === 0) return true;
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
function isLikelyAd(element) {
|
|
331
|
+
const haystack = [
|
|
332
|
+
element.id,
|
|
333
|
+
element.getAttribute("class"),
|
|
334
|
+
element.getAttribute("aria-label"),
|
|
335
|
+
element.getAttribute("data-testid"),
|
|
336
|
+
element.getAttribute("data-test-id"),
|
|
337
|
+
element.getAttribute("data-name")
|
|
338
|
+
].filter(Boolean).join(" ").toLowerCase();
|
|
339
|
+
if (/\b(ad|ads|advert|advertisement|sponsor|sponsored|placement)\b/.test(haystack)) return true;
|
|
340
|
+
if (element instanceof HTMLAnchorElement && normalizeText(element.textContent ?? "", 80).toLowerCase() === "ad") return true;
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
function isDisabled(element) {
|
|
344
|
+
if (element.getAttribute("aria-disabled") === "true") return true;
|
|
345
|
+
return "disabled" in element && Boolean(element.disabled);
|
|
346
|
+
}
|
|
347
|
+
function isFocusable(element) {
|
|
348
|
+
if (isDisabled(element) || isHidden(element)) return false;
|
|
349
|
+
const tabindex = element.getAttribute("tabindex");
|
|
350
|
+
if (tabindex !== null) return Number(tabindex) >= 0;
|
|
351
|
+
return element.matches("a[href],area[href],button,input,select,textarea,summary,iframe,[contenteditable=''],[contenteditable='true']");
|
|
352
|
+
}
|
|
353
|
+
function isInteractive(element, role, focusable) {
|
|
354
|
+
if (role && interactiveRoles.has(role)) return true;
|
|
355
|
+
if (element.matches("a[href],button,input,select,textarea,summary,option")) return true;
|
|
356
|
+
if (element.hasAttribute("onclick")) return true;
|
|
357
|
+
return focusable && Boolean(role);
|
|
358
|
+
}
|
|
359
|
+
function appendSpecialChildren(element, node, context) {
|
|
360
|
+
if (!context.options.includeSelectOptions) return;
|
|
361
|
+
if (element instanceof HTMLSelectElement) {
|
|
362
|
+
for (const option of Array.from(element.options)) {
|
|
363
|
+
node.children.push({
|
|
364
|
+
id: nextId(context),
|
|
365
|
+
tag: "option",
|
|
366
|
+
role: "option",
|
|
367
|
+
name: normalizeText(option.textContent ?? "", context.options.maxTextLength),
|
|
368
|
+
value: option.value,
|
|
369
|
+
state: { selected: option.selected, disabled: option.disabled },
|
|
370
|
+
interactive: false,
|
|
371
|
+
focusable: false,
|
|
372
|
+
selector: getCssPath(option),
|
|
373
|
+
xpath: getXPath(option),
|
|
374
|
+
children: []
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
function isCustomElement(element) {
|
|
380
|
+
return element.tagName.includes("-");
|
|
381
|
+
}
|
|
382
|
+
function appendShadowChildren(element, node, context) {
|
|
383
|
+
const shadowRoot = element.shadowRoot;
|
|
384
|
+
if (!shadowRoot) return;
|
|
385
|
+
for (const child of Array.from(shadowRoot.children)) {
|
|
386
|
+
const semanticChild = walkElement(child, context);
|
|
387
|
+
if (semanticChild) node.children.push(semanticChild);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function appendFrameChildren(element, node, context) {
|
|
391
|
+
if (!(element instanceof HTMLIFrameElement)) return;
|
|
392
|
+
try {
|
|
393
|
+
const frameDocument = element.contentDocument;
|
|
394
|
+
if (!frameDocument?.body) {
|
|
395
|
+
node.children.push(unavailableNode(context, "iframe", "iframe document unavailable"));
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
const previousDocument = context.rootDocument;
|
|
399
|
+
context.rootDocument = frameDocument;
|
|
400
|
+
const child = walkElement(frameDocument.body, context);
|
|
401
|
+
context.rootDocument = previousDocument;
|
|
402
|
+
if (child) node.children.push(child);
|
|
403
|
+
} catch {
|
|
404
|
+
node.children.push(unavailableNode(context, "iframe", "cross-origin iframe"));
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function unavailableNode(context, tag, reason) {
|
|
408
|
+
return {
|
|
409
|
+
id: nextId(context),
|
|
410
|
+
tag,
|
|
411
|
+
role: null,
|
|
412
|
+
name: "",
|
|
413
|
+
interactive: false,
|
|
414
|
+
focusable: false,
|
|
415
|
+
unavailableReason: reason,
|
|
416
|
+
children: []
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function containerNode(context, tag, children) {
|
|
420
|
+
return {
|
|
421
|
+
id: nextId(context),
|
|
422
|
+
tag,
|
|
423
|
+
role: null,
|
|
424
|
+
name: "",
|
|
425
|
+
interactive: false,
|
|
426
|
+
focusable: false,
|
|
427
|
+
children
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
function getValue(element) {
|
|
431
|
+
if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement) {
|
|
432
|
+
return element.value;
|
|
433
|
+
}
|
|
434
|
+
return normalizeText(element.getAttribute("aria-valuetext") ?? element.getAttribute("aria-valuenow") ?? "", 80);
|
|
435
|
+
}
|
|
436
|
+
function getDirectText(element, maxLength) {
|
|
437
|
+
return normalizeText(
|
|
438
|
+
Array.from(element.childNodes).filter((node) => node.nodeType === Node.TEXT_NODE).map((node) => node.textContent ?? "").join(" "),
|
|
439
|
+
maxLength
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
function getVisibleText(element, maxLength) {
|
|
443
|
+
const parts = [];
|
|
444
|
+
function visit(node) {
|
|
445
|
+
if (node.nodeType === Node.TEXT_NODE) {
|
|
446
|
+
parts.push(node.textContent ?? "");
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
if (node.nodeType !== Node.ELEMENT_NODE) return;
|
|
450
|
+
const childElement = node;
|
|
451
|
+
if (isHidden(childElement)) return;
|
|
452
|
+
for (const child of Array.from(childElement.childNodes)) visit(child);
|
|
453
|
+
}
|
|
454
|
+
visit(element);
|
|
455
|
+
return normalizeText(parts.join(" "), maxLength);
|
|
456
|
+
}
|
|
457
|
+
function getAttributes(element) {
|
|
458
|
+
const attributes = {};
|
|
459
|
+
for (const attribute of Array.from(element.attributes)) {
|
|
460
|
+
if (attribute.name === "id" || attribute.name === "href" || attribute.name === "type" || attribute.name === "role" || attribute.name === "alt" || attribute.name === "title" || attribute.name.startsWith("aria-") || attribute.name.startsWith("data-")) {
|
|
461
|
+
attributes[attribute.name] = attribute.value;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return attributes;
|
|
465
|
+
}
|
|
466
|
+
function getBounds(element) {
|
|
467
|
+
const rect = element.getBoundingClientRect();
|
|
468
|
+
return {
|
|
469
|
+
x: round(rect.x),
|
|
470
|
+
y: round(rect.y),
|
|
471
|
+
width: round(rect.width),
|
|
472
|
+
height: round(rect.height)
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
function getCssPath(element) {
|
|
476
|
+
if (element.id) return `#${cssEscape(element.id)}`;
|
|
477
|
+
const segments = [];
|
|
478
|
+
let current = element;
|
|
479
|
+
while (current && current.nodeType === Node.ELEMENT_NODE && current !== document.documentElement) {
|
|
480
|
+
const elementAtLevel = current;
|
|
481
|
+
const tag = elementAtLevel.tagName.toLowerCase();
|
|
482
|
+
const parent = elementAtLevel.parentElement;
|
|
483
|
+
if (!parent) {
|
|
484
|
+
segments.unshift(tag);
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
const siblings = Array.from(parent.children).filter((child) => child.tagName === elementAtLevel.tagName);
|
|
488
|
+
const index = siblings.indexOf(elementAtLevel) + 1;
|
|
489
|
+
segments.unshift(siblings.length > 1 ? `${tag}:nth-of-type(${index})` : tag);
|
|
490
|
+
current = parent;
|
|
491
|
+
}
|
|
492
|
+
return segments.join(" > ");
|
|
493
|
+
}
|
|
494
|
+
function getXPath(element) {
|
|
495
|
+
const segments = [];
|
|
496
|
+
let current = element;
|
|
497
|
+
while (current && current.nodeType === Node.ELEMENT_NODE) {
|
|
498
|
+
const elementAtLevel = current;
|
|
499
|
+
const tag = elementAtLevel.tagName.toLowerCase();
|
|
500
|
+
const parent = elementAtLevel.parentElement;
|
|
501
|
+
if (!parent) {
|
|
502
|
+
segments.unshift(`/${tag}[1]`);
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
const sameTag = Array.from(parent.children).filter((child) => child.tagName === elementAtLevel.tagName);
|
|
506
|
+
segments.unshift(`/${tag}[${sameTag.indexOf(elementAtLevel) + 1}]`);
|
|
507
|
+
current = parent;
|
|
508
|
+
}
|
|
509
|
+
return segments.join("");
|
|
510
|
+
}
|
|
511
|
+
function textFromIds(ids, rootDocument) {
|
|
512
|
+
return normalizeText(
|
|
513
|
+
ids.split(/\s+/).map((id) => {
|
|
514
|
+
const element = rootDocument.getElementById(id);
|
|
515
|
+
return element ? getVisibleText(element, 240) : "";
|
|
516
|
+
}).filter(Boolean).join(" "),
|
|
517
|
+
240
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
function normalizeText(value, maxLength) {
|
|
521
|
+
const normalized = value.replace(/\s+/g, " ").trim();
|
|
522
|
+
return normalized.length > maxLength ? `${normalized.slice(0, maxLength - 1)}\u2026` : normalized;
|
|
523
|
+
}
|
|
524
|
+
function firstToken(value) {
|
|
525
|
+
return value?.trim().split(/\s+/)[0] || null;
|
|
526
|
+
}
|
|
527
|
+
function hasExplicitNameSource(element) {
|
|
528
|
+
return Boolean(
|
|
529
|
+
element.getAttribute("aria-label") || element.getAttribute("aria-labelledby") || element.getAttribute("title")
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
function hasEmptyAlt(element) {
|
|
533
|
+
return element.hasAttribute("alt") && element.getAttribute("alt") === "";
|
|
534
|
+
}
|
|
535
|
+
function isButtonLikeInput(input) {
|
|
536
|
+
return ["button", "image", "reset", "submit"].includes((input.getAttribute("type") || "").toLowerCase());
|
|
537
|
+
}
|
|
538
|
+
function inputFallbackName(input) {
|
|
539
|
+
const type = (input.getAttribute("type") || "").toLowerCase();
|
|
540
|
+
if (type === "submit") return "Submit";
|
|
541
|
+
if (type === "reset") return "Reset";
|
|
542
|
+
return "";
|
|
543
|
+
}
|
|
544
|
+
function ariaBoolean(value) {
|
|
545
|
+
if (value === "true") return true;
|
|
546
|
+
if (value === "false") return false;
|
|
547
|
+
return void 0;
|
|
548
|
+
}
|
|
549
|
+
function ariaBooleanOrMixed(value) {
|
|
550
|
+
if (value === "mixed") return "mixed";
|
|
551
|
+
return ariaBoolean(value);
|
|
552
|
+
}
|
|
553
|
+
function formatState(state) {
|
|
554
|
+
if (!state) return "";
|
|
555
|
+
const entries = Object.entries(state).filter(([, value]) => value !== void 0);
|
|
556
|
+
return entries.length > 0 ? ` [${entries.map(([key, value]) => `${key}=${String(value)}`).join(" ")}]` : "";
|
|
557
|
+
}
|
|
558
|
+
function nextId(context) {
|
|
559
|
+
const id = `n${context.nextId}`;
|
|
560
|
+
context.nextId += 1;
|
|
561
|
+
return id;
|
|
562
|
+
}
|
|
563
|
+
function round(value) {
|
|
564
|
+
return Math.round(value * 100) / 100;
|
|
565
|
+
}
|
|
566
|
+
function cssEscape(value) {
|
|
567
|
+
if (typeof CSS !== "undefined" && typeof CSS.escape === "function") {
|
|
568
|
+
return CSS.escape(value);
|
|
569
|
+
}
|
|
570
|
+
return value.replace(/[^a-zA-Z0-9_-]/g, (char) => `\\${char}`);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
export {
|
|
574
|
+
extractSemanticTree,
|
|
575
|
+
formatSemanticTreeText,
|
|
576
|
+
observeSemanticTree
|
|
577
|
+
};
|
|
578
|
+
//# sourceMappingURL=chunk-U3GDKPLQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/browser.ts"],"sourcesContent":["import type {\n SemanticNode,\n SemanticNodeState,\n SemanticTreeChange,\n SemanticTreeObserverOptions,\n SemanticTreeOptions,\n} from \"./types\";\n\ntype WalkContext = {\n options: Required<SemanticTreeOptions>;\n nextId: number;\n rootDocument: Document;\n};\n\nconst defaultOptions: Required<SemanticTreeOptions> = {\n mode: \"compact\",\n includeBounds: true,\n includeAttributes: true,\n includeTextNodes: true,\n includeHidden: false,\n includeSelectOptions: true,\n excludeLikelyAds: false,\n excludeLikelyBoilerplate: false,\n pruneCustomElementWrappers: true,\n pruneCollapsedSubtrees: true,\n pruneLikelyClosedOverlays: false,\n summarizeLargeSubtrees: false,\n summarizeLikelyLinkFarms: false,\n summarizeRepeatedSubtrees: false,\n maxChildrenPerNode: 80,\n maxLinkFarmChildren: 24,\n maxRepeatedSubtreeInstances: 3,\n maxTextLength: 240,\n};\n\nconst defaultObserverOptions: Required<Pick<SemanticTreeObserverOptions, \"debounceMs\">> = {\n debounceMs: 50,\n};\n\nconst interactiveRoles = new Set([\n \"button\",\n \"checkbox\",\n \"combobox\",\n \"link\",\n \"listbox\",\n \"menuitem\",\n \"menuitemcheckbox\",\n \"menuitemradio\",\n \"option\",\n \"radio\",\n \"searchbox\",\n \"slider\",\n \"spinbutton\",\n \"switch\",\n \"tab\",\n \"textbox\",\n \"treeitem\",\n]);\n\nconst landmarkTags: Record<string, string> = {\n article: \"article\",\n aside: \"complementary\",\n footer: \"contentinfo\",\n form: \"form\",\n header: \"banner\",\n main: \"main\",\n nav: \"navigation\",\n section: \"region\",\n};\n\nconst rolesNamedFromContents = new Set([\n \"button\",\n \"cell\",\n \"checkbox\",\n \"columnheader\",\n \"heading\",\n \"link\",\n \"menuitem\",\n \"menuitemcheckbox\",\n \"menuitemradio\",\n \"option\",\n \"radio\",\n \"rowheader\",\n \"switch\",\n \"tab\",\n \"treeitem\",\n]);\n\nexport function extractSemanticTree(options: SemanticTreeOptions = {}): SemanticNode {\n const rootDocument = document;\n const context: WalkContext = {\n options: { ...defaultOptions, ...options },\n nextId: 1,\n rootDocument,\n };\n\n return (\n walkElement(rootDocument.body ?? rootDocument.documentElement, context) ??\n unavailableNode(context, \"document\", \"Document has no inspectable body\")\n );\n}\n\nexport { extractSemanticTree as extract };\n\nexport function formatSemanticTreeText(node: SemanticNode): string {\n const lines: string[] = [];\n\n function visit(current: SemanticNode, depth: number): void {\n const prefix = \" \".repeat(depth);\n const role = current.role ?? current.tag;\n const marker = current.interactive ? \"[i] \" : \"\";\n const name = current.name ? ` '${current.name}'` : \"\";\n const state = formatState(current.state);\n const unavailable = current.unavailableReason ? ` (${current.unavailableReason})` : \"\";\n lines.push(`${prefix}${marker}${role}${name}${state}${unavailable}`);\n for (const child of current.children) visit(child, depth + 1);\n }\n\n visit(node, 0);\n return lines.join(\"\\n\");\n}\n\nexport function observeSemanticTree(\n onChange: (change: SemanticTreeChange) => void,\n options: SemanticTreeObserverOptions = {},\n): { disconnect: () => void; snapshot: () => SemanticNode } {\n const root = document.documentElement;\n const observerOptions = { ...defaultObserverOptions, ...options };\n let mutationCount = 0;\n let timeoutId: number | undefined;\n\n function snapshot(): SemanticNode {\n return extractSemanticTree(options);\n }\n\n function emit(): void {\n timeoutId = undefined;\n onChange({\n tree: snapshot(),\n changedAt: Date.now(),\n mutationCount,\n });\n mutationCount = 0;\n }\n\n const observer = new MutationObserver((mutations) => {\n mutationCount += mutations.length;\n if (timeoutId !== undefined) window.clearTimeout(timeoutId);\n timeoutId = window.setTimeout(emit, observerOptions.debounceMs);\n });\n\n observer.observe(root, {\n attributes: true,\n characterData: true,\n childList: true,\n subtree: true,\n });\n\n return {\n disconnect() {\n if (timeoutId !== undefined) window.clearTimeout(timeoutId);\n observer.disconnect();\n },\n snapshot,\n };\n}\n\nfunction walkElement(element: Element, context: WalkContext): SemanticNode | null {\n if (!context.options.includeHidden && isHidden(element)) return null;\n if (context.options.excludeLikelyAds && isLikelyAd(element)) return null;\n\n const role = getRole(element);\n const state = getState(element);\n const focusable = isFocusable(element);\n const interactive = isInteractive(element, role, focusable);\n const name = role ? computeName(element, role, context) : \"\";\n const description = computeDescription(element, context);\n const tag = element.tagName.toLowerCase();\n const children = collectChildren(element, context);\n\n if (context.options.mode === \"interactive\" && !interactive) {\n return children.length > 0\n ? containerNode(context, tag, children)\n : null;\n }\n\n if (shouldPrune(element, role, name, interactive, children, context)) {\n return children.length === 1 ? children[0] ?? null : containerNode(context, tag, children);\n }\n\n const node: SemanticNode = {\n id: nextId(context),\n tag,\n role,\n name,\n interactive,\n focusable,\n children,\n };\n\n if (description) node.description = description;\n const text = getDirectText(element, context.options.maxTextLength);\n if (text) node.text = text;\n const value = getValue(element);\n if (value) node.value = value;\n if (Object.keys(state).length > 0) node.state = state;\n node.selector = getCssPath(element);\n node.xpath = getXPath(element);\n if (context.options.includeBounds) node.bounds = getBounds(element);\n if (context.options.includeAttributes) node.attributes = getAttributes(element);\n\n appendSpecialChildren(element, node, context);\n appendShadowChildren(element, node, context);\n appendFrameChildren(element, node, context);\n\n return node;\n}\n\nfunction collectChildren(element: Element, context: WalkContext): SemanticNode[] {\n const children: SemanticNode[] = [];\n for (const child of Array.from(element.childNodes)) {\n if (child.nodeType === Node.ELEMENT_NODE) {\n if (!context.options.includeSelectOptions && element instanceof HTMLSelectElement) continue;\n const semanticChild = walkElement(child as Element, context);\n if (semanticChild) children.push(semanticChild);\n continue;\n }\n\n if (context.options.includeTextNodes && child.nodeType === Node.TEXT_NODE) {\n const text = normalizeText(child.textContent ?? \"\", context.options.maxTextLength);\n if (text) {\n children.push({\n id: nextId(context),\n tag: \"#text\",\n role: \"text\",\n name: text,\n text,\n interactive: false,\n focusable: false,\n children: [],\n });\n }\n }\n }\n return children;\n}\n\nfunction shouldPrune(\n element: Element,\n role: string | null,\n name: string,\n interactive: boolean,\n children: SemanticNode[],\n context: WalkContext,\n): boolean {\n if (context.options.mode === \"full\") return false;\n if (role === \"none\" || role === \"presentation\") return true;\n if (interactive) return false;\n if (context.options.pruneCustomElementWrappers && isCustomElement(element)) return children.length > 0;\n if (role && role !== \"generic\") return false;\n if (name) return false;\n if (element.id || element.getAttribute(\"aria-label\") || element.getAttribute(\"aria-labelledby\")) return false;\n return children.length > 0;\n}\n\nfunction getRole(element: Element): string | null {\n const explicit = firstToken(element.getAttribute(\"role\"));\n if (explicit) return explicit;\n\n const tag = element.tagName.toLowerCase();\n if (tag === \"section\" && !hasExplicitNameSource(element)) return null;\n if (tag === \"form\" && !hasExplicitNameSource(element)) return null;\n if (tag in landmarkTags) return landmarkTags[tag] ?? null;\n if (/^h[1-6]$/.test(tag)) return \"heading\";\n\n if (tag === \"a\" || tag === \"area\") return element.hasAttribute(\"href\") ? \"link\" : null;\n if (tag === \"button\") return \"button\";\n if (tag === \"details\") return \"group\";\n if (tag === \"dialog\") return \"dialog\";\n if (tag === \"fieldset\") return \"group\";\n if (tag === \"figure\") return \"figure\";\n if (tag === \"iframe\") return \"iframe\";\n if (tag === \"img\") return hasEmptyAlt(element) ? \"presentation\" : \"img\";\n if (tag === \"li\") return \"listitem\";\n if (tag === \"ol\" || tag === \"ul\") return \"list\";\n if (tag === \"optgroup\") return \"group\";\n if (tag === \"option\") return \"option\";\n if (tag === \"output\") return \"status\";\n if (tag === \"progress\") return \"progressbar\";\n if (tag === \"select\") return element.hasAttribute(\"multiple\") ? \"listbox\" : \"combobox\";\n if (tag === \"summary\") return \"button\";\n if (tag === \"table\") return \"table\";\n if (tag === \"caption\") return \"caption\";\n if (tag === \"tbody\" || tag === \"tfoot\" || tag === \"thead\") return \"rowgroup\";\n if (tag === \"td\") return \"cell\";\n if (tag === \"textarea\") return \"textbox\";\n if (tag === \"th\") return element.getAttribute(\"scope\") === \"row\" ? \"rowheader\" : \"columnheader\";\n if (tag === \"tr\") return \"row\";\n\n if (tag === \"input\") return inputRole(element as HTMLInputElement);\n return null;\n}\n\nfunction inputRole(input: HTMLInputElement): string | null {\n const type = (input.getAttribute(\"type\") || \"text\").toLowerCase();\n if (type === \"button\" || type === \"image\" || type === \"reset\" || type === \"submit\") return \"button\";\n if (type === \"checkbox\") return \"checkbox\";\n if (type === \"email\" || type === \"tel\" || type === \"text\" || type === \"url\") return \"textbox\";\n if (type === \"number\") return \"spinbutton\";\n if (type === \"radio\") return \"radio\";\n if (type === \"range\") return \"slider\";\n if (type === \"search\") return \"searchbox\";\n if (type === \"hidden\") return null;\n return \"textbox\";\n}\n\nfunction computeName(element: Element, role: string, context: WalkContext): string {\n if (element.getAttribute(\"aria-labelledby\")) {\n const labelled = textFromIds(element.getAttribute(\"aria-labelledby\") ?? \"\", context.rootDocument);\n if (labelled) return labelled;\n }\n\n const ariaLabel = element.getAttribute(\"aria-label\");\n if (ariaLabel) return normalizeText(ariaLabel, context.options.maxTextLength);\n\n if (element instanceof HTMLInputElement && isButtonLikeInput(element)) {\n return normalizeText(element.value || element.getAttribute(\"value\") || inputFallbackName(element), context.options.maxTextLength);\n }\n\n if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement) {\n const label = labelText(element, context);\n if (label) return label;\n const placeholder = element.getAttribute(\"placeholder\");\n if (placeholder) return normalizeText(placeholder, context.options.maxTextLength);\n }\n\n if (element instanceof HTMLImageElement) {\n return normalizeText(element.alt || element.getAttribute(\"title\") || \"\", context.options.maxTextLength);\n }\n\n if (element instanceof HTMLFieldSetElement) {\n const legend = element.querySelector(\":scope > legend\");\n if (legend) return getVisibleText(legend, context.options.maxTextLength);\n }\n\n if (rolesNamedFromContents.has(role)) {\n const ownText = getVisibleText(element, context.options.maxTextLength);\n if (ownText) return ownText;\n }\n\n return normalizeText(element.getAttribute(\"title\") ?? \"\", context.options.maxTextLength);\n}\n\nfunction computeDescription(element: Element, context: WalkContext): string {\n const describedBy = element.getAttribute(\"aria-describedby\");\n if (describedBy) return textFromIds(describedBy, context.rootDocument);\n return normalizeText(element.getAttribute(\"title\") ?? \"\", context.options.maxTextLength);\n}\n\nfunction labelText(\n element: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement,\n context: WalkContext,\n): string {\n if (element.labels && element.labels.length > 0) {\n return normalizeText(Array.from(element.labels).map((label) => getVisibleText(label, context.options.maxTextLength)).join(\" \"), context.options.maxTextLength);\n }\n return \"\";\n}\n\nfunction getState(element: Element): SemanticNodeState {\n const state: SemanticNodeState = {};\n if (isHidden(element)) state.hidden = true;\n if (isDisabled(element)) state.disabled = true;\n if (element === document.activeElement) state.focused = true;\n\n const checked = ariaBooleanOrMixed(element.getAttribute(\"aria-checked\"));\n if (checked !== undefined) state.checked = checked;\n else if (element instanceof HTMLInputElement && (element.type === \"checkbox\" || element.type === \"radio\")) {\n state.checked = element.checked;\n }\n\n const selected = ariaBoolean(element.getAttribute(\"aria-selected\"));\n if (selected !== undefined) state.selected = selected;\n else if (element instanceof HTMLOptionElement) state.selected = element.selected;\n\n const expanded = ariaBoolean(element.getAttribute(\"aria-expanded\"));\n if (expanded !== undefined) state.expanded = expanded;\n\n const pressed = ariaBooleanOrMixed(element.getAttribute(\"aria-pressed\"));\n if (pressed !== undefined) state.pressed = pressed;\n\n const required = ariaBoolean(element.getAttribute(\"aria-required\"));\n if (required !== undefined) state.required = required;\n else if (\"required\" in element && Boolean((element as HTMLInputElement).required)) state.required = true;\n\n const invalid = element.getAttribute(\"aria-invalid\");\n if (invalid && invalid !== \"false\") state.invalid = invalid === \"true\" ? true : invalid;\n\n if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {\n if (element.readOnly) state.readonly = true;\n }\n\n return state;\n}\n\nfunction isHidden(element: Element): boolean {\n if (element.hasAttribute(\"hidden\")) return true;\n if (element.getAttribute(\"aria-hidden\") === \"true\") return true;\n\n const style = getComputedStyle(element);\n if (\n style.display === \"none\" ||\n style.visibility === \"hidden\" ||\n style.contentVisibility === \"hidden\"\n ) return true;\n if (Number(style.opacity) === 0) return true;\n return false;\n}\n\nfunction isLikelyAd(element: Element): boolean {\n const haystack = [\n element.id,\n element.getAttribute(\"class\"),\n element.getAttribute(\"aria-label\"),\n element.getAttribute(\"data-testid\"),\n element.getAttribute(\"data-test-id\"),\n element.getAttribute(\"data-name\"),\n ].filter(Boolean).join(\" \").toLowerCase();\n if (/\\b(ad|ads|advert|advertisement|sponsor|sponsored|placement)\\b/.test(haystack)) return true;\n if (element instanceof HTMLAnchorElement && normalizeText(element.textContent ?? \"\", 80).toLowerCase() === \"ad\") return true;\n return false;\n}\n\nfunction isDisabled(element: Element): boolean {\n if (element.getAttribute(\"aria-disabled\") === \"true\") return true;\n return \"disabled\" in element && Boolean((element as HTMLButtonElement).disabled);\n}\n\nfunction isFocusable(element: Element): boolean {\n if (isDisabled(element) || isHidden(element)) return false;\n const tabindex = element.getAttribute(\"tabindex\");\n if (tabindex !== null) return Number(tabindex) >= 0;\n return element.matches(\"a[href],area[href],button,input,select,textarea,summary,iframe,[contenteditable=''],[contenteditable='true']\");\n}\n\nfunction isInteractive(element: Element, role: string | null, focusable: boolean): boolean {\n if (role && interactiveRoles.has(role)) return true;\n if (element.matches(\"a[href],button,input,select,textarea,summary,option\")) return true;\n if (element.hasAttribute(\"onclick\")) return true;\n return focusable && Boolean(role);\n}\n\nfunction appendSpecialChildren(element: Element, node: SemanticNode, context: WalkContext): void {\n if (!context.options.includeSelectOptions) return;\n if (element instanceof HTMLSelectElement) {\n for (const option of Array.from(element.options)) {\n node.children.push({\n id: nextId(context),\n tag: \"option\",\n role: \"option\",\n name: normalizeText(option.textContent ?? \"\", context.options.maxTextLength),\n value: option.value,\n state: { selected: option.selected, disabled: option.disabled },\n interactive: false,\n focusable: false,\n selector: getCssPath(option),\n xpath: getXPath(option),\n children: [],\n });\n }\n }\n}\n\nfunction isCustomElement(element: Element): boolean {\n return element.tagName.includes(\"-\");\n}\n\nfunction appendShadowChildren(element: Element, node: SemanticNode, context: WalkContext): void {\n const shadowRoot = element.shadowRoot;\n if (!shadowRoot) return;\n for (const child of Array.from(shadowRoot.children)) {\n const semanticChild = walkElement(child, context);\n if (semanticChild) node.children.push(semanticChild);\n }\n}\n\nfunction appendFrameChildren(element: Element, node: SemanticNode, context: WalkContext): void {\n if (!(element instanceof HTMLIFrameElement)) return;\n try {\n const frameDocument = element.contentDocument;\n if (!frameDocument?.body) {\n node.children.push(unavailableNode(context, \"iframe\", \"iframe document unavailable\"));\n return;\n }\n const previousDocument = context.rootDocument;\n context.rootDocument = frameDocument;\n const child = walkElement(frameDocument.body, context);\n context.rootDocument = previousDocument;\n if (child) node.children.push(child);\n } catch {\n node.children.push(unavailableNode(context, \"iframe\", \"cross-origin iframe\"));\n }\n}\n\nfunction unavailableNode(context: WalkContext, tag: string, reason: string): SemanticNode {\n return {\n id: nextId(context),\n tag,\n role: null,\n name: \"\",\n interactive: false,\n focusable: false,\n unavailableReason: reason,\n children: [],\n };\n}\n\nfunction containerNode(context: WalkContext, tag: string, children: SemanticNode[]): SemanticNode {\n return {\n id: nextId(context),\n tag,\n role: null,\n name: \"\",\n interactive: false,\n focusable: false,\n children,\n };\n}\n\nfunction getValue(element: Element): string {\n if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement) {\n return element.value;\n }\n return normalizeText(element.getAttribute(\"aria-valuetext\") ?? element.getAttribute(\"aria-valuenow\") ?? \"\", 80);\n}\n\nfunction getDirectText(element: Element, maxLength: number): string {\n return normalizeText(\n Array.from(element.childNodes)\n .filter((node) => node.nodeType === Node.TEXT_NODE)\n .map((node) => node.textContent ?? \"\")\n .join(\" \"),\n maxLength,\n );\n}\n\nfunction getVisibleText(element: Element, maxLength: number): string {\n const parts: string[] = [];\n\n function visit(node: Node): void {\n if (node.nodeType === Node.TEXT_NODE) {\n parts.push(node.textContent ?? \"\");\n return;\n }\n\n if (node.nodeType !== Node.ELEMENT_NODE) return;\n const childElement = node as Element;\n if (isHidden(childElement)) return;\n for (const child of Array.from(childElement.childNodes)) visit(child);\n }\n\n visit(element);\n return normalizeText(parts.join(\" \"), maxLength);\n}\n\nfunction getAttributes(element: Element): Record<string, string> {\n const attributes: Record<string, string> = {};\n for (const attribute of Array.from(element.attributes)) {\n if (\n attribute.name === \"id\" ||\n attribute.name === \"href\" ||\n attribute.name === \"type\" ||\n attribute.name === \"role\" ||\n attribute.name === \"alt\" ||\n attribute.name === \"title\" ||\n attribute.name.startsWith(\"aria-\") ||\n attribute.name.startsWith(\"data-\")\n ) {\n attributes[attribute.name] = attribute.value;\n }\n }\n return attributes;\n}\n\nfunction getBounds(element: Element) {\n const rect = element.getBoundingClientRect();\n return {\n x: round(rect.x),\n y: round(rect.y),\n width: round(rect.width),\n height: round(rect.height),\n };\n}\n\nfunction getCssPath(element: Element): string {\n if (element.id) return `#${cssEscape(element.id)}`;\n const segments: string[] = [];\n let current: Element | null = element;\n while (current && current.nodeType === Node.ELEMENT_NODE && current !== document.documentElement) {\n const elementAtLevel: Element = current;\n const tag = elementAtLevel.tagName.toLowerCase();\n const parent: Element | null = elementAtLevel.parentElement;\n if (!parent) {\n segments.unshift(tag);\n break;\n }\n const siblings = Array.from(parent.children).filter((child) => child.tagName === elementAtLevel.tagName);\n const index = siblings.indexOf(elementAtLevel) + 1;\n segments.unshift(siblings.length > 1 ? `${tag}:nth-of-type(${index})` : tag);\n current = parent;\n }\n return segments.join(\" > \");\n}\n\nfunction getXPath(element: Element): string {\n const segments: string[] = [];\n let current: Element | null = element;\n while (current && current.nodeType === Node.ELEMENT_NODE) {\n const elementAtLevel: Element = current;\n const tag = elementAtLevel.tagName.toLowerCase();\n const parent: Element | null = elementAtLevel.parentElement;\n if (!parent) {\n segments.unshift(`/${tag}[1]`);\n break;\n }\n const sameTag = Array.from(parent.children).filter((child) => child.tagName === elementAtLevel.tagName);\n segments.unshift(`/${tag}[${sameTag.indexOf(elementAtLevel) + 1}]`);\n current = parent;\n }\n return segments.join(\"\");\n}\n\nfunction textFromIds(ids: string, rootDocument: Document): string {\n return normalizeText(\n ids\n .split(/\\s+/)\n .map((id) => {\n const element = rootDocument.getElementById(id);\n return element ? getVisibleText(element, 240) : \"\";\n })\n .filter(Boolean)\n .join(\" \"),\n 240,\n );\n}\n\nfunction normalizeText(value: string, maxLength: number): string {\n const normalized = value.replace(/\\s+/g, \" \").trim();\n return normalized.length > maxLength ? `${normalized.slice(0, maxLength - 1)}…` : normalized;\n}\n\nfunction firstToken(value: string | null): string | null {\n return value?.trim().split(/\\s+/)[0] || null;\n}\n\nfunction hasExplicitNameSource(element: Element): boolean {\n return Boolean(\n element.getAttribute(\"aria-label\") ||\n element.getAttribute(\"aria-labelledby\") ||\n element.getAttribute(\"title\"),\n );\n}\n\nfunction hasEmptyAlt(element: Element): boolean {\n return element.hasAttribute(\"alt\") && element.getAttribute(\"alt\") === \"\";\n}\n\nfunction isButtonLikeInput(input: HTMLInputElement): boolean {\n return [\"button\", \"image\", \"reset\", \"submit\"].includes((input.getAttribute(\"type\") || \"\").toLowerCase());\n}\n\nfunction inputFallbackName(input: HTMLInputElement): string {\n const type = (input.getAttribute(\"type\") || \"\").toLowerCase();\n if (type === \"submit\") return \"Submit\";\n if (type === \"reset\") return \"Reset\";\n return \"\";\n}\n\nfunction ariaBoolean(value: string | null): boolean | undefined {\n if (value === \"true\") return true;\n if (value === \"false\") return false;\n return undefined;\n}\n\nfunction ariaBooleanOrMixed(value: string | null): boolean | \"mixed\" | undefined {\n if (value === \"mixed\") return \"mixed\";\n return ariaBoolean(value);\n}\n\nfunction formatState(state: SemanticNodeState | undefined): string {\n if (!state) return \"\";\n const entries = Object.entries(state).filter(([, value]) => value !== undefined);\n return entries.length > 0\n ? ` [${entries.map(([key, value]) => `${key}=${String(value)}`).join(\" \")}]`\n : \"\";\n}\n\nfunction nextId(context: WalkContext): string {\n const id = `n${context.nextId}`;\n context.nextId += 1;\n return id;\n}\n\nfunction round(value: number): number {\n return Math.round(value * 100) / 100;\n}\n\nfunction cssEscape(value: string): string {\n if (typeof CSS !== \"undefined\" && typeof CSS.escape === \"function\") {\n return CSS.escape(value);\n }\n return value.replace(/[^a-zA-Z0-9_-]/g, (char) => `\\\\${char}`);\n}\n"],"mappings":";AAcA,IAAM,iBAAgD;AAAA,EACpD,MAAM;AAAA,EACN,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,kBAAkB;AAAA,EAClB,0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