@usecrow/client 0.1.27 → 0.1.28
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/PageController-72owMK9b.cjs +9 -0
- package/dist/{PageController-KoeqDxMP.js → PageController-BT9YJiz0.js} +276 -274
- package/dist/SimulatorMask-74sRLkJv.js +79 -0
- package/dist/SimulatorMask-jCkPs2Tt.cjs +2 -0
- package/dist/browser.cjs +1 -1
- package/dist/browser.d.ts +25 -4
- package/dist/browser.js +22 -16
- package/dist/browserUse-CMYea2D_.cjs +1 -0
- package/dist/{browserUse-BbPG4pH1.js → browserUse-CMq8wG4u.js} +101 -47
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/PageController-GcMFZYwU.cjs +0 -9
- package/dist/SimulatorMask-CgaoHOve.js +0 -120
- package/dist/SimulatorMask-DoBLczoQ.cjs +0 -2
- package/dist/browserUse-BOc9kyBK.cjs +0 -1
|
@@ -42,9 +42,9 @@ async function inputTextElement(e, n) {
|
|
|
42
42
|
async function selectOptionElement(e, n) {
|
|
43
43
|
if (!(e instanceof HTMLSelectElement))
|
|
44
44
|
throw new Error("Element is not a select element");
|
|
45
|
-
const i = Array.from(e.options).find((
|
|
45
|
+
const i = Array.from(e.options).find((w) => {
|
|
46
46
|
var d;
|
|
47
|
-
return ((d =
|
|
47
|
+
return ((d = w.textContent) == null ? void 0 : d.trim()) === n.trim();
|
|
48
48
|
});
|
|
49
49
|
if (!i)
|
|
50
50
|
throw new Error(`Option with text "${n}" not found in select element`);
|
|
@@ -61,37 +61,37 @@ async function scrollVertically(e, n, s) {
|
|
|
61
61
|
"[SCROLL DEBUG] Starting direct container scroll for element:",
|
|
62
62
|
l.tagName
|
|
63
63
|
);
|
|
64
|
-
let h = l,
|
|
65
|
-
const
|
|
64
|
+
let h = l, T = !1, b = null, u = 0, f = 0;
|
|
65
|
+
const N = n;
|
|
66
66
|
for (; h && f < 10; ) {
|
|
67
|
-
const
|
|
67
|
+
const D = window.getComputedStyle(h), z = /(auto|scroll|overlay)/.test(D.overflowY), O = h.scrollHeight > h.clientHeight;
|
|
68
68
|
if (console.log(
|
|
69
69
|
"[SCROLL DEBUG] Checking element:",
|
|
70
70
|
h.tagName,
|
|
71
71
|
"hasScrollableY:",
|
|
72
|
-
|
|
72
|
+
z,
|
|
73
73
|
"canScrollVertically:",
|
|
74
74
|
O,
|
|
75
75
|
"scrollHeight:",
|
|
76
76
|
h.scrollHeight,
|
|
77
77
|
"clientHeight:",
|
|
78
78
|
h.clientHeight
|
|
79
|
-
),
|
|
80
|
-
const R = h.scrollTop,
|
|
81
|
-
let H =
|
|
82
|
-
H > 0 ? H = Math.min(H,
|
|
83
|
-
const
|
|
79
|
+
), z && O) {
|
|
80
|
+
const R = h.scrollTop, U = h.scrollHeight - h.clientHeight;
|
|
81
|
+
let H = N / 3;
|
|
82
|
+
H > 0 ? H = Math.min(H, U - R) : H = Math.max(H, -R), h.scrollTop = R + H;
|
|
83
|
+
const B = h.scrollTop, _ = B - R;
|
|
84
84
|
if (console.log(
|
|
85
85
|
"[SCROLL DEBUG] Scroll attempt:",
|
|
86
86
|
h.tagName,
|
|
87
87
|
"before:",
|
|
88
88
|
R,
|
|
89
89
|
"after:",
|
|
90
|
-
|
|
90
|
+
B,
|
|
91
91
|
"delta:",
|
|
92
92
|
_
|
|
93
93
|
), Math.abs(_) > 0.5) {
|
|
94
|
-
|
|
94
|
+
T = !0, b = h, u = _, console.log(
|
|
95
95
|
"[SCROLL DEBUG] Successfully scrolled container:",
|
|
96
96
|
h.tagName,
|
|
97
97
|
"delta:",
|
|
@@ -104,27 +104,27 @@ async function scrollVertically(e, n, s) {
|
|
|
104
104
|
break;
|
|
105
105
|
h = h.parentElement, f++;
|
|
106
106
|
}
|
|
107
|
-
return
|
|
107
|
+
return T ? `Scrolled container (${b == null ? void 0 : b.tagName}) by ${u}px` : `No scrollable container found for element (${l.tagName})`;
|
|
108
108
|
}
|
|
109
|
-
const i = n,
|
|
109
|
+
const i = n, w = (l) => l.clientHeight >= window.innerHeight * 0.5, d = (l) => l && /(auto|scroll|overlay)/.test(getComputedStyle(l).overflowY) && l.scrollHeight > l.clientHeight && w(l);
|
|
110
110
|
let r = document.activeElement;
|
|
111
111
|
for (; r && !d(r) && r !== document.body; ) r = r.parentElement;
|
|
112
112
|
if (r = d(r) ? r : Array.from(document.querySelectorAll("*")).find(d) || document.scrollingElement || document.documentElement, r === document.scrollingElement || r === document.documentElement || r === document.body) {
|
|
113
113
|
const l = window.scrollY, h = document.documentElement.scrollHeight - window.innerHeight;
|
|
114
114
|
window.scrollBy(0, i);
|
|
115
|
-
const
|
|
116
|
-
if (Math.abs(
|
|
115
|
+
const T = window.scrollY, b = T - l;
|
|
116
|
+
if (Math.abs(b) < 1)
|
|
117
117
|
return i > 0 ? "⚠️ Already at the bottom of the page, cannot scroll down further." : "⚠️ Already at the top of the page, cannot scroll up further.";
|
|
118
|
-
const u = i > 0 &&
|
|
119
|
-
return u ? `✅ Scrolled page by ${
|
|
118
|
+
const u = i > 0 && T >= h - 1, f = i < 0 && T <= 1;
|
|
119
|
+
return u ? `✅ Scrolled page by ${b}px. Reached the bottom of the page.` : f ? `✅ Scrolled page by ${b}px. Reached the top of the page.` : `✅ Scrolled page by ${b}px.`;
|
|
120
120
|
} else {
|
|
121
121
|
const l = r.scrollTop, h = r.scrollHeight - r.clientHeight;
|
|
122
122
|
r.scrollBy({ top: i, behavior: "smooth" }), await waitFor(0.1);
|
|
123
|
-
const
|
|
124
|
-
if (Math.abs(
|
|
123
|
+
const T = r.scrollTop, b = T - l;
|
|
124
|
+
if (Math.abs(b) < 1)
|
|
125
125
|
return i > 0 ? `⚠️ Already at the bottom of container (${r.tagName}), cannot scroll down further.` : `⚠️ Already at the top of container (${r.tagName}), cannot scroll up further.`;
|
|
126
|
-
const u = i > 0 &&
|
|
127
|
-
return u ? `✅ Scrolled container (${r.tagName}) by ${
|
|
126
|
+
const u = i > 0 && T >= h - 1, f = i < 0 && T <= 1;
|
|
127
|
+
return u ? `✅ Scrolled container (${r.tagName}) by ${b}px. Reached the bottom.` : f ? `✅ Scrolled container (${r.tagName}) by ${b}px. Reached the top.` : `✅ Scrolled container (${r.tagName}) by ${b}px.`;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
async function scrollHorizontally(e, n, s) {
|
|
@@ -134,37 +134,37 @@ async function scrollHorizontally(e, n, s) {
|
|
|
134
134
|
"[SCROLL DEBUG] Starting direct container scroll for element:",
|
|
135
135
|
l.tagName
|
|
136
136
|
);
|
|
137
|
-
let h = l,
|
|
138
|
-
const
|
|
137
|
+
let h = l, T = !1, b = null, u = 0, f = 0;
|
|
138
|
+
const N = e ? n : -n;
|
|
139
139
|
for (; h && f < 10; ) {
|
|
140
|
-
const
|
|
140
|
+
const D = window.getComputedStyle(h), z = /(auto|scroll|overlay)/.test(D.overflowX), O = h.scrollWidth > h.clientWidth;
|
|
141
141
|
if (console.log(
|
|
142
142
|
"[SCROLL DEBUG] Checking element:",
|
|
143
143
|
h.tagName,
|
|
144
144
|
"hasScrollableX:",
|
|
145
|
-
|
|
145
|
+
z,
|
|
146
146
|
"canScrollHorizontally:",
|
|
147
147
|
O,
|
|
148
148
|
"scrollWidth:",
|
|
149
149
|
h.scrollWidth,
|
|
150
150
|
"clientWidth:",
|
|
151
151
|
h.clientWidth
|
|
152
|
-
),
|
|
153
|
-
const R = h.scrollLeft,
|
|
154
|
-
let H =
|
|
155
|
-
H > 0 ? H = Math.min(H,
|
|
156
|
-
const
|
|
152
|
+
), z && O) {
|
|
153
|
+
const R = h.scrollLeft, U = h.scrollWidth - h.clientWidth;
|
|
154
|
+
let H = N / 3;
|
|
155
|
+
H > 0 ? H = Math.min(H, U - R) : H = Math.max(H, -R), h.scrollLeft = R + H;
|
|
156
|
+
const B = h.scrollLeft, _ = B - R;
|
|
157
157
|
if (console.log(
|
|
158
158
|
"[SCROLL DEBUG] Scroll attempt:",
|
|
159
159
|
h.tagName,
|
|
160
160
|
"before:",
|
|
161
161
|
R,
|
|
162
162
|
"after:",
|
|
163
|
-
|
|
163
|
+
B,
|
|
164
164
|
"delta:",
|
|
165
165
|
_
|
|
166
166
|
), Math.abs(_) > 0.5) {
|
|
167
|
-
|
|
167
|
+
T = !0, b = h, u = _, console.log(
|
|
168
168
|
"[SCROLL DEBUG] Successfully scrolled container:",
|
|
169
169
|
h.tagName,
|
|
170
170
|
"delta:",
|
|
@@ -177,27 +177,27 @@ async function scrollHorizontally(e, n, s) {
|
|
|
177
177
|
break;
|
|
178
178
|
h = h.parentElement, f++;
|
|
179
179
|
}
|
|
180
|
-
return
|
|
180
|
+
return T ? `Scrolled container (${b == null ? void 0 : b.tagName}) horizontally by ${u}px` : `No horizontally scrollable container found for element (${l.tagName})`;
|
|
181
181
|
}
|
|
182
|
-
const i = e ? n : -n,
|
|
182
|
+
const i = e ? n : -n, w = (l) => l.clientWidth >= window.innerWidth * 0.5, d = (l) => l && /(auto|scroll|overlay)/.test(getComputedStyle(l).overflowX) && l.scrollWidth > l.clientWidth && w(l);
|
|
183
183
|
let r = document.activeElement;
|
|
184
184
|
for (; r && !d(r) && r !== document.body; ) r = r.parentElement;
|
|
185
185
|
if (r = d(r) ? r : Array.from(document.querySelectorAll("*")).find(d) || document.scrollingElement || document.documentElement, r === document.scrollingElement || r === document.documentElement || r === document.body) {
|
|
186
186
|
const l = window.scrollX, h = document.documentElement.scrollWidth - window.innerWidth;
|
|
187
187
|
window.scrollBy(i, 0);
|
|
188
|
-
const
|
|
189
|
-
if (Math.abs(
|
|
188
|
+
const T = window.scrollX, b = T - l;
|
|
189
|
+
if (Math.abs(b) < 1)
|
|
190
190
|
return i > 0 ? "⚠️ Already at the right edge of the page, cannot scroll right further." : "⚠️ Already at the left edge of the page, cannot scroll left further.";
|
|
191
|
-
const u = i > 0 &&
|
|
192
|
-
return u ? `✅ Scrolled page by ${
|
|
191
|
+
const u = i > 0 && T >= h - 1, f = i < 0 && T <= 1;
|
|
192
|
+
return u ? `✅ Scrolled page by ${b}px. Reached the right edge of the page.` : f ? `✅ Scrolled page by ${b}px. Reached the left edge of the page.` : `✅ Scrolled page horizontally by ${b}px.`;
|
|
193
193
|
} else {
|
|
194
194
|
const l = r.scrollLeft, h = r.scrollWidth - r.clientWidth;
|
|
195
195
|
r.scrollBy({ left: i, behavior: "smooth" }), await waitFor(0.1);
|
|
196
|
-
const
|
|
197
|
-
if (Math.abs(
|
|
196
|
+
const T = r.scrollLeft, b = T - l;
|
|
197
|
+
if (Math.abs(b) < 1)
|
|
198
198
|
return i > 0 ? `⚠️ Already at the right edge of container (${r.tagName}), cannot scroll right further.` : `⚠️ Already at the left edge of container (${r.tagName}), cannot scroll left further.`;
|
|
199
|
-
const u = i > 0 &&
|
|
200
|
-
return u ? `✅ Scrolled container (${r.tagName}) by ${
|
|
199
|
+
const u = i > 0 && T >= h - 1, f = i < 0 && T <= 1;
|
|
200
|
+
return u ? `✅ Scrolled container (${r.tagName}) by ${b}px. Reached the right edge.` : f ? `✅ Scrolled container (${r.tagName}) by ${b}px. Reached the left edge.` : `✅ Scrolled container (${r.tagName}) horizontally by ${b}px.`;
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
@@ -215,11 +215,11 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
215
215
|
highlightOpacity: 0.1,
|
|
216
216
|
highlightLabelOpacity: 0.5
|
|
217
217
|
}) => {
|
|
218
|
-
const { interactiveBlacklist: n, interactiveWhitelist: s, highlightOpacity: i, highlightLabelOpacity:
|
|
219
|
-
let
|
|
220
|
-
const
|
|
218
|
+
const { interactiveBlacklist: n, interactiveWhitelist: s, highlightOpacity: i, highlightLabelOpacity: w } = e, { doHighlightElements: d, focusHighlightIndex: r, viewportExpansion: l, debugMode: h } = e;
|
|
219
|
+
let T = 0;
|
|
220
|
+
const b = /* @__PURE__ */ new WeakMap();
|
|
221
221
|
function u(t, o) {
|
|
222
|
-
!t || t.nodeType !== Node.ELEMENT_NODE ||
|
|
222
|
+
!t || t.nodeType !== Node.ELEMENT_NODE || b.set(t, { ...b.get(t), ...o });
|
|
223
223
|
}
|
|
224
224
|
const f = {
|
|
225
225
|
boundingRects: /* @__PURE__ */ new WeakMap(),
|
|
@@ -229,37 +229,37 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
229
229
|
f.boundingRects = /* @__PURE__ */ new WeakMap(), f.clientRects = /* @__PURE__ */ new WeakMap(), f.computedStyles = /* @__PURE__ */ new WeakMap();
|
|
230
230
|
}
|
|
231
231
|
};
|
|
232
|
-
function
|
|
232
|
+
function N(t) {
|
|
233
233
|
if (!t) return null;
|
|
234
234
|
if (f.boundingRects.has(t))
|
|
235
235
|
return f.boundingRects.get(t);
|
|
236
236
|
const o = t.getBoundingClientRect();
|
|
237
237
|
return o && f.boundingRects.set(t, o), o;
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function D(t) {
|
|
240
240
|
if (!t) return null;
|
|
241
241
|
if (f.computedStyles.has(t))
|
|
242
242
|
return f.computedStyles.get(t);
|
|
243
243
|
const o = window.getComputedStyle(t);
|
|
244
244
|
return o && f.computedStyles.set(t, o), o;
|
|
245
245
|
}
|
|
246
|
-
function
|
|
246
|
+
function z(t) {
|
|
247
247
|
if (!t) return null;
|
|
248
248
|
if (f.clientRects.has(t))
|
|
249
249
|
return f.clientRects.get(t);
|
|
250
250
|
const o = t.getClientRects();
|
|
251
251
|
return o && f.clientRects.set(t, o), o;
|
|
252
252
|
}
|
|
253
|
-
const O = {}, R = { current: 0 },
|
|
253
|
+
const O = {}, R = { current: 0 }, U = "playwright-highlight-container";
|
|
254
254
|
function H(t, o, p = null) {
|
|
255
255
|
if (!t) return o;
|
|
256
256
|
const a = [];
|
|
257
|
-
let c = null, x = 20, E = 16,
|
|
257
|
+
let c = null, x = 20, E = 16, I = null;
|
|
258
258
|
try {
|
|
259
|
-
let m = document.getElementById(
|
|
260
|
-
m || (m = document.createElement("div"), m.id =
|
|
261
|
-
const
|
|
262
|
-
if (
|
|
259
|
+
let m = document.getElementById(U);
|
|
260
|
+
m || (m = document.createElement("div"), m.id = U, m.style.position = "fixed", m.style.pointerEvents = "none", m.style.top = "0", m.style.left = "0", m.style.width = "100%", m.style.height = "100%", m.style.zIndex = "2147483640", m.style.backgroundColor = "transparent", document.body.appendChild(m));
|
|
261
|
+
const $ = t.getClientRects();
|
|
262
|
+
if (!$ || $.length === 0) return o;
|
|
263
263
|
const A = [
|
|
264
264
|
"#FF0000",
|
|
265
265
|
"#00FF00",
|
|
@@ -275,68 +275,70 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
275
275
|
"#4682B4"
|
|
276
276
|
], g = o % A.length;
|
|
277
277
|
let y = A[g];
|
|
278
|
-
const
|
|
279
|
-
y = y + Math.floor(
|
|
280
|
-
let
|
|
278
|
+
const C = y + Math.floor(i * 255).toString(16).padStart(2, "0");
|
|
279
|
+
y = y + Math.floor(w * 255).toString(16).padStart(2, "0");
|
|
280
|
+
let M = { x: 0, y: 0 };
|
|
281
281
|
if (p) {
|
|
282
|
-
const
|
|
283
|
-
|
|
282
|
+
const k = p.getBoundingClientRect();
|
|
283
|
+
M.x = k.left, M.y = k.top;
|
|
284
|
+
}
|
|
285
|
+
const V = document.createDocumentFragment();
|
|
286
|
+
for (const k of $) {
|
|
287
|
+
if (k.width === 0 || k.height === 0) continue;
|
|
288
|
+
const S = document.createElement("div");
|
|
289
|
+
S.style.position = "fixed", S.style.border = `2px solid ${y}`, S.style.backgroundColor = C, S.style.pointerEvents = "none", S.style.boxSizing = "border-box";
|
|
290
|
+
const v = k.top + M.y, W = k.left + M.x;
|
|
291
|
+
S.style.top = `${v}px`, S.style.left = `${W}px`, S.style.width = `${k.width}px`, S.style.height = `${k.height}px`, V.appendChild(S), a.push({ element: S, initialRect: k });
|
|
284
292
|
}
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
$.style.top = `${N}px`, $.style.left = `${q}px`, $.style.width = `${I.width}px`, $.style.height = `${I.height}px`, B.appendChild($), a.push({ element: $, initialRect: I });
|
|
293
|
+
const G = $[0];
|
|
294
|
+
if (w > 0) {
|
|
295
|
+
c = document.createElement("div"), c.className = "playwright-highlight-label", c.style.position = "fixed", c.style.background = y, c.style.color = "white", c.style.padding = "1px 4px", c.style.borderRadius = "4px", c.style.fontSize = `${Math.min(12, Math.max(8, G.height / 2))}px`, c.textContent = o.toString(), x = c.offsetWidth > 0 ? c.offsetWidth : x, E = c.offsetHeight > 0 ? c.offsetHeight : E;
|
|
296
|
+
const k = G.top + M.y, S = G.left + M.x;
|
|
297
|
+
let v = k + 2, W = S + G.width - x - 2;
|
|
298
|
+
(G.width < x + 4 || G.height < E + 4) && (v = k - E - 2, W = S + G.width - x, W < M.x && (W = S)), v = Math.max(0, Math.min(v, window.innerHeight - E)), W = Math.max(0, Math.min(W, window.innerWidth - x)), c.style.top = `${v}px`, c.style.left = `${W}px`, V.appendChild(c);
|
|
292
299
|
}
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
let N = 0;
|
|
300
|
-
return (...q) => {
|
|
301
|
-
const V = performance.now();
|
|
302
|
-
if (!(V - N < $))
|
|
303
|
-
return N = V, I(...q);
|
|
300
|
+
const j = ((k, S) => {
|
|
301
|
+
let v = 0;
|
|
302
|
+
return (...W) => {
|
|
303
|
+
const P = performance.now();
|
|
304
|
+
if (!(P - v < S))
|
|
305
|
+
return v = P, k(...W);
|
|
304
306
|
};
|
|
305
307
|
})(() => {
|
|
306
|
-
const
|
|
307
|
-
let
|
|
308
|
+
const k = t.getClientRects();
|
|
309
|
+
let S = { x: 0, y: 0 };
|
|
308
310
|
if (p) {
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
+
const v = p.getBoundingClientRect();
|
|
312
|
+
S.x = v.left, S.y = v.top;
|
|
311
313
|
}
|
|
312
|
-
if (a.forEach((
|
|
313
|
-
if (
|
|
314
|
-
const
|
|
315
|
-
|
|
314
|
+
if (a.forEach((v, W) => {
|
|
315
|
+
if (W < k.length) {
|
|
316
|
+
const P = k[W], Z = P.top + S.y, J = P.left + S.x;
|
|
317
|
+
v.element.style.top = `${Z}px`, v.element.style.left = `${J}px`, v.element.style.width = `${P.width}px`, v.element.style.height = `${P.height}px`, v.element.style.display = P.width === 0 || P.height === 0 ? "none" : "block";
|
|
316
318
|
} else
|
|
317
|
-
|
|
318
|
-
}),
|
|
319
|
-
for (let
|
|
320
|
-
a[
|
|
321
|
-
if (c &&
|
|
322
|
-
const
|
|
323
|
-
let
|
|
324
|
-
(
|
|
319
|
+
v.element.style.display = "none";
|
|
320
|
+
}), k.length < a.length)
|
|
321
|
+
for (let v = k.length; v < a.length; v++)
|
|
322
|
+
a[v].element.style.display = "none";
|
|
323
|
+
if (c && k.length > 0) {
|
|
324
|
+
const v = k[0], W = v.top + S.y, P = v.left + S.x;
|
|
325
|
+
let Z = W + 2, J = P + v.width - x - 2;
|
|
326
|
+
(v.width < x + 4 || v.height < E + 4) && (Z = W - E - 2, J = P + v.width - x, J < S.x && (J = P)), Z = Math.max(0, Math.min(Z, window.innerHeight - E)), J = Math.max(0, Math.min(J, window.innerWidth - x)), c.style.top = `${Z}px`, c.style.left = `${J}px`, c.style.display = "block";
|
|
325
327
|
} else c && (c.style.display = "none");
|
|
326
328
|
}, 16);
|
|
327
|
-
return window.addEventListener("scroll",
|
|
328
|
-
window.removeEventListener("scroll",
|
|
329
|
-
}, m.appendChild(
|
|
329
|
+
return window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), I = () => {
|
|
330
|
+
window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j), a.forEach((k) => k.element.remove()), c && c.remove();
|
|
331
|
+
}, m.appendChild(V), o + 1;
|
|
330
332
|
} finally {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
+
I && (window._highlightCleanupFunctions = window._highlightCleanupFunctions || []).push(
|
|
334
|
+
I
|
|
333
335
|
);
|
|
334
336
|
}
|
|
335
337
|
}
|
|
336
|
-
function
|
|
338
|
+
function B(t) {
|
|
337
339
|
if (!t || t.nodeType !== Node.ELEMENT_NODE)
|
|
338
340
|
return null;
|
|
339
|
-
const o =
|
|
341
|
+
const o = D(t);
|
|
340
342
|
if (!o) return null;
|
|
341
343
|
const p = o.display;
|
|
342
344
|
if (p === "inline" || p === "inline-block")
|
|
@@ -344,19 +346,19 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
344
346
|
const a = o.overflowX, c = o.overflowY, x = a === "auto" || a === "scroll", E = c === "auto" || c === "scroll";
|
|
345
347
|
if (!x && !E)
|
|
346
348
|
return null;
|
|
347
|
-
const
|
|
348
|
-
if (
|
|
349
|
+
const I = t.scrollWidth - t.clientWidth, m = t.scrollHeight - t.clientHeight, $ = 4;
|
|
350
|
+
if (I < $ && m < $ || !E && I < $ || !x && m < $)
|
|
349
351
|
return null;
|
|
350
|
-
const A = t.scrollTop, g = t.scrollLeft, y = t.scrollWidth - t.clientWidth - t.scrollLeft,
|
|
352
|
+
const A = t.scrollTop, g = t.scrollLeft, y = t.scrollWidth - t.clientWidth - t.scrollLeft, C = t.scrollHeight - t.clientHeight - t.scrollTop, M = {
|
|
351
353
|
top: A,
|
|
352
354
|
right: y,
|
|
353
|
-
bottom:
|
|
355
|
+
bottom: C,
|
|
354
356
|
left: g
|
|
355
357
|
};
|
|
356
358
|
return u(t, {
|
|
357
359
|
scrollable: !0,
|
|
358
|
-
scrollData:
|
|
359
|
-
}),
|
|
360
|
+
scrollData: M
|
|
361
|
+
}), M;
|
|
360
362
|
}
|
|
361
363
|
function _(t) {
|
|
362
364
|
try {
|
|
@@ -394,14 +396,14 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
394
396
|
checkVisibilityCSS: !0
|
|
395
397
|
});
|
|
396
398
|
} catch {
|
|
397
|
-
const
|
|
398
|
-
return
|
|
399
|
+
const I = window.getComputedStyle(x);
|
|
400
|
+
return I.display !== "none" && I.visibility !== "hidden" && I.opacity !== "0";
|
|
399
401
|
}
|
|
400
402
|
} catch (o) {
|
|
401
403
|
return console.warn("Error checking text node visibility:", o), !1;
|
|
402
404
|
}
|
|
403
405
|
}
|
|
404
|
-
function
|
|
406
|
+
function ot(t) {
|
|
405
407
|
if (!t || !t.tagName) return !1;
|
|
406
408
|
const o = /* @__PURE__ */ new Set([
|
|
407
409
|
"body",
|
|
@@ -423,17 +425,17 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
423
425
|
"template"
|
|
424
426
|
])).has(p);
|
|
425
427
|
}
|
|
426
|
-
function
|
|
427
|
-
const o =
|
|
428
|
+
function X(t) {
|
|
429
|
+
const o = D(t);
|
|
428
430
|
return t.offsetWidth > 0 && t.offsetHeight > 0 && (o == null ? void 0 : o.visibility) !== "hidden" && (o == null ? void 0 : o.display) !== "none";
|
|
429
431
|
}
|
|
430
|
-
function
|
|
431
|
-
var
|
|
432
|
+
function L(t) {
|
|
433
|
+
var C, M;
|
|
432
434
|
if (!t || t.nodeType !== Node.ELEMENT_NODE || n.includes(t))
|
|
433
435
|
return !1;
|
|
434
436
|
if (s.includes(t))
|
|
435
437
|
return !0;
|
|
436
|
-
const o = t.tagName.toLowerCase(), p =
|
|
438
|
+
const o = t.tagName.toLowerCase(), p = D(t), a = /* @__PURE__ */ new Set([
|
|
437
439
|
"pointer",
|
|
438
440
|
// Link/clickable elements
|
|
439
441
|
"move",
|
|
@@ -510,12 +512,12 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
510
512
|
// 'default', // Default cursor
|
|
511
513
|
// 'auto', // Browser default
|
|
512
514
|
]);
|
|
513
|
-
function x(
|
|
514
|
-
return
|
|
515
|
+
function x(V) {
|
|
516
|
+
return V.tagName.toLowerCase() === "html" ? !1 : !!(p != null && p.cursor && a.has(p.cursor));
|
|
515
517
|
}
|
|
516
518
|
if (x(t))
|
|
517
519
|
return !0;
|
|
518
|
-
const
|
|
520
|
+
const I = /* @__PURE__ */ new Set([
|
|
519
521
|
"a",
|
|
520
522
|
// Links
|
|
521
523
|
"button",
|
|
@@ -554,15 +556,15 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
554
556
|
// 'tabindex="-1"', // Removed from tab order
|
|
555
557
|
// 'aria-hidden="true"' // Hidden from screen readers
|
|
556
558
|
]);
|
|
557
|
-
if (
|
|
559
|
+
if (I.has(o)) {
|
|
558
560
|
if (p != null && p.cursor && c.has(p.cursor))
|
|
559
561
|
return !1;
|
|
560
|
-
for (const
|
|
561
|
-
if (t.hasAttribute(
|
|
562
|
+
for (const V of m)
|
|
563
|
+
if (t.hasAttribute(V) || t.getAttribute(V) === "true" || t.getAttribute(V) === "")
|
|
562
564
|
return !1;
|
|
563
565
|
return !(t.disabled || t.readOnly || t.inert);
|
|
564
566
|
}
|
|
565
|
-
const
|
|
567
|
+
const $ = t.getAttribute("role"), A = t.getAttribute("aria-role");
|
|
566
568
|
if (t.getAttribute("contenteditable") === "true" || t.isContentEditable || t.classList && (t.classList.contains("button") || t.classList.contains("dropdown-toggle") || t.getAttribute("data-index") || t.getAttribute("data-toggle") === "dropdown" || t.getAttribute("aria-haspopup") === "true"))
|
|
567
569
|
return !0;
|
|
568
570
|
const g = /* @__PURE__ */ new Set([
|
|
@@ -604,17 +606,17 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
604
606
|
"scrollbar"
|
|
605
607
|
// Scrollable control
|
|
606
608
|
]);
|
|
607
|
-
if (
|
|
609
|
+
if (I.has(o) || $ && g.has($) || A && g.has(A)) return !0;
|
|
608
610
|
try {
|
|
609
611
|
if (typeof getEventListeners == "function") {
|
|
610
|
-
const
|
|
611
|
-
for (const j of
|
|
612
|
-
if (
|
|
612
|
+
const q = getEventListeners(t), nt = ["click", "mousedown", "mouseup", "dblclick"];
|
|
613
|
+
for (const j of nt)
|
|
614
|
+
if (q[j] && q[j].length > 0)
|
|
613
615
|
return !0;
|
|
614
616
|
}
|
|
615
|
-
const
|
|
616
|
-
if (typeof
|
|
617
|
-
const
|
|
617
|
+
const V = ((M = (C = t == null ? void 0 : t.ownerDocument) == null ? void 0 : C.defaultView) == null ? void 0 : M.getEventListenersForNode) || window.getEventListenersForNode;
|
|
618
|
+
if (typeof V == "function") {
|
|
619
|
+
const q = V(t), nt = [
|
|
618
620
|
"click",
|
|
619
621
|
"mousedown",
|
|
620
622
|
"mouseup",
|
|
@@ -626,23 +628,23 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
626
628
|
"focus",
|
|
627
629
|
"blur"
|
|
628
630
|
];
|
|
629
|
-
for (const j of
|
|
630
|
-
for (const
|
|
631
|
-
if (
|
|
631
|
+
for (const j of nt)
|
|
632
|
+
for (const k of q)
|
|
633
|
+
if (k.type === j)
|
|
632
634
|
return !0;
|
|
633
635
|
}
|
|
634
636
|
const G = ["onclick", "onmousedown", "onmouseup", "ondblclick"];
|
|
635
|
-
for (const
|
|
636
|
-
if (t.hasAttribute(
|
|
637
|
+
for (const q of G)
|
|
638
|
+
if (t.hasAttribute(q) || typeof t[q] == "function")
|
|
637
639
|
return !0;
|
|
638
640
|
} catch {
|
|
639
641
|
}
|
|
640
|
-
return !!
|
|
642
|
+
return !!B(t);
|
|
641
643
|
}
|
|
642
|
-
function
|
|
644
|
+
function et(t) {
|
|
643
645
|
if (l === -1)
|
|
644
646
|
return !0;
|
|
645
|
-
const o =
|
|
647
|
+
const o = z(t);
|
|
646
648
|
if (!o || o.length === 0)
|
|
647
649
|
return !1;
|
|
648
650
|
let p = !1;
|
|
@@ -661,9 +663,9 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
661
663
|
return !1;
|
|
662
664
|
const x = t.getRootNode();
|
|
663
665
|
if (x instanceof ShadowRoot) {
|
|
664
|
-
const m = c.left + c.width / 2,
|
|
666
|
+
const m = c.left + c.width / 2, $ = c.top + c.height / 2;
|
|
665
667
|
try {
|
|
666
|
-
const A = x.elementFromPoint(m,
|
|
668
|
+
const A = x.elementFromPoint(m, $);
|
|
667
669
|
if (!A) return !1;
|
|
668
670
|
let g = A;
|
|
669
671
|
for (; g && g !== x; ) {
|
|
@@ -685,9 +687,9 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
685
687
|
// { x: rect.left + margin, y: rect.bottom - margin }, // bottom left
|
|
686
688
|
{ x: c.right - E, y: c.bottom - E }
|
|
687
689
|
// bottom right
|
|
688
|
-
].some(({ x: m, y:
|
|
690
|
+
].some(({ x: m, y: $ }) => {
|
|
689
691
|
try {
|
|
690
|
-
const A = document.elementFromPoint(m,
|
|
692
|
+
const A = document.elementFromPoint(m, $);
|
|
691
693
|
if (!A) return !1;
|
|
692
694
|
let g = A;
|
|
693
695
|
for (; g && g !== document.documentElement; ) {
|
|
@@ -700,12 +702,12 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
700
702
|
}
|
|
701
703
|
});
|
|
702
704
|
}
|
|
703
|
-
function
|
|
705
|
+
function it(t, o) {
|
|
704
706
|
if (o === -1)
|
|
705
707
|
return !0;
|
|
706
708
|
const p = t.getClientRects();
|
|
707
709
|
if (!p || p.length === 0) {
|
|
708
|
-
const a =
|
|
710
|
+
const a = N(t);
|
|
709
711
|
return !a || a.width === 0 || a.height === 0 ? !1 : !(a.bottom < -o || a.top > window.innerHeight + o || a.right < -o || a.left > window.innerWidth + o);
|
|
710
712
|
}
|
|
711
713
|
for (const a of p)
|
|
@@ -713,7 +715,7 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
713
715
|
return !0;
|
|
714
716
|
return !1;
|
|
715
717
|
}
|
|
716
|
-
function
|
|
718
|
+
function F(t) {
|
|
717
719
|
if (!t || t.nodeType !== Node.ELEMENT_NODE) return !1;
|
|
718
720
|
const o = t.tagName.toLowerCase();
|
|
719
721
|
return (/* @__PURE__ */ new Set([
|
|
@@ -727,7 +729,7 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
727
729
|
"label"
|
|
728
730
|
])).has(o) ? !0 : t.hasAttribute("onclick") || t.hasAttribute("role") || t.hasAttribute("tabindex") || t.hasAttribute("aria-") || t.hasAttribute("data-action") || t.getAttribute("contenteditable") === "true";
|
|
729
731
|
}
|
|
730
|
-
const
|
|
732
|
+
const Y = /* @__PURE__ */ new Set([
|
|
731
733
|
"a",
|
|
732
734
|
"button",
|
|
733
735
|
"input",
|
|
@@ -737,7 +739,7 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
737
739
|
"details",
|
|
738
740
|
"label",
|
|
739
741
|
"option"
|
|
740
|
-
]),
|
|
742
|
+
]), K = /* @__PURE__ */ new Set([
|
|
741
743
|
"button",
|
|
742
744
|
"link",
|
|
743
745
|
"menuitem",
|
|
@@ -756,24 +758,24 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
756
758
|
"option",
|
|
757
759
|
"scrollbar"
|
|
758
760
|
]);
|
|
759
|
-
function
|
|
760
|
-
if (!t || t.nodeType !== Node.ELEMENT_NODE || !
|
|
761
|
+
function tt(t) {
|
|
762
|
+
if (!t || t.nodeType !== Node.ELEMENT_NODE || !X(t)) return !1;
|
|
761
763
|
const o = t.hasAttribute("role") || t.hasAttribute("tabindex") || t.hasAttribute("onclick") || typeof t.onclick == "function", p = /\b(btn|clickable|menu|item|entry|link)\b/i.test(
|
|
762
764
|
t.className || ""
|
|
763
|
-
), a = !!t.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'), c = [...t.children].some(
|
|
764
|
-
return (
|
|
765
|
+
), a = !!t.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'), c = [...t.children].some(X), x = t.parentElement && t.parentElement.isSameNode(document.body);
|
|
766
|
+
return (L(t) || o || p) && c && a && !x;
|
|
765
767
|
}
|
|
766
|
-
function
|
|
768
|
+
function rt(t) {
|
|
767
769
|
var a, c;
|
|
768
770
|
if (!t || t.nodeType !== Node.ELEMENT_NODE)
|
|
769
771
|
return !1;
|
|
770
772
|
const o = t.tagName.toLowerCase(), p = t.getAttribute("role");
|
|
771
|
-
if (o === "iframe" ||
|
|
773
|
+
if (o === "iframe" || Y.has(o) || p && K.has(p) || t.isContentEditable || t.getAttribute("contenteditable") === "true" || t.hasAttribute("data-testid") || t.hasAttribute("data-cy") || t.hasAttribute("data-test") || t.hasAttribute("onclick") || typeof t.onclick == "function")
|
|
772
774
|
return !0;
|
|
773
775
|
try {
|
|
774
776
|
const x = ((c = (a = t == null ? void 0 : t.ownerDocument) == null ? void 0 : a.defaultView) == null ? void 0 : c.getEventListenersForNode) || window.getEventListenersForNode;
|
|
775
777
|
if (typeof x == "function") {
|
|
776
|
-
const
|
|
778
|
+
const I = x(t), m = [
|
|
777
779
|
"click",
|
|
778
780
|
"mousedown",
|
|
779
781
|
"mouseup",
|
|
@@ -785,9 +787,9 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
785
787
|
"focus",
|
|
786
788
|
"blur"
|
|
787
789
|
];
|
|
788
|
-
for (const
|
|
789
|
-
for (const A of
|
|
790
|
-
if (A.type ===
|
|
790
|
+
for (const $ of m)
|
|
791
|
+
for (const A of I)
|
|
792
|
+
if (A.type === $)
|
|
791
793
|
return !0;
|
|
792
794
|
}
|
|
793
795
|
if ([
|
|
@@ -800,20 +802,20 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
800
802
|
"oninput",
|
|
801
803
|
"onfocus",
|
|
802
804
|
"onblur"
|
|
803
|
-
].some((
|
|
805
|
+
].some((I) => t.hasAttribute(I)))
|
|
804
806
|
return !0;
|
|
805
807
|
} catch {
|
|
806
808
|
}
|
|
807
|
-
return !!
|
|
809
|
+
return !!tt(t);
|
|
808
810
|
}
|
|
809
|
-
function
|
|
811
|
+
function st(t, o, p, a) {
|
|
810
812
|
if (!t.isInteractive) return !1;
|
|
811
813
|
let c = !1;
|
|
812
|
-
return a ?
|
|
814
|
+
return a ? rt(o) ? c = !0 : c = !1 : c = !0, c && (t.isInViewport = it(o, l), (t.isInViewport || l === -1) && (t.highlightIndex = T++, d)) ? (r >= 0 ? r === t.highlightIndex && H(o, t.highlightIndex, p) : H(o, t.highlightIndex, p), !0) : !1;
|
|
813
815
|
}
|
|
814
|
-
function
|
|
815
|
-
var E,
|
|
816
|
-
if (!t || t.id ===
|
|
816
|
+
function Q(t, o = null, p = !1) {
|
|
817
|
+
var E, I, m, $, A;
|
|
818
|
+
if (!t || t.id === U || t.nodeType !== Node.ELEMENT_NODE && t.nodeType !== Node.TEXT_NODE || !t || t.id === U || ((E = t.dataset) == null ? void 0 : E.browserUseIgnore) === "true" || t.getAttribute && t.getAttribute("aria-hidden") === "true")
|
|
817
819
|
return null;
|
|
818
820
|
if (t === document.body) {
|
|
819
821
|
const g = {
|
|
@@ -822,9 +824,9 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
822
824
|
xpath: "/body",
|
|
823
825
|
children: []
|
|
824
826
|
};
|
|
825
|
-
for (const
|
|
826
|
-
const
|
|
827
|
-
|
|
827
|
+
for (const C of t.childNodes) {
|
|
828
|
+
const M = Q(C, o, !1);
|
|
829
|
+
M && g.children.push(M);
|
|
828
830
|
}
|
|
829
831
|
const y = `${R.current++}`;
|
|
830
832
|
return O[y] = g, y;
|
|
@@ -832,24 +834,24 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
832
834
|
if (t.nodeType !== Node.ELEMENT_NODE && t.nodeType !== Node.TEXT_NODE)
|
|
833
835
|
return null;
|
|
834
836
|
if (t.nodeType === Node.TEXT_NODE) {
|
|
835
|
-
const g = (
|
|
837
|
+
const g = (I = t.textContent) == null ? void 0 : I.trim();
|
|
836
838
|
if (!g)
|
|
837
839
|
return null;
|
|
838
840
|
const y = t.parentElement;
|
|
839
841
|
if (!y || y.tagName.toLowerCase() === "script")
|
|
840
842
|
return null;
|
|
841
|
-
const
|
|
842
|
-
return O[
|
|
843
|
+
const C = `${R.current++}`;
|
|
844
|
+
return O[C] = {
|
|
843
845
|
type: "TEXT_NODE",
|
|
844
846
|
text: g,
|
|
845
847
|
isVisible: _(t)
|
|
846
|
-
},
|
|
848
|
+
}, C;
|
|
847
849
|
}
|
|
848
|
-
if (t.nodeType === Node.ELEMENT_NODE && !
|
|
850
|
+
if (t.nodeType === Node.ELEMENT_NODE && !ot(t))
|
|
849
851
|
return null;
|
|
850
852
|
if (l !== -1 && !t.shadowRoot) {
|
|
851
|
-
const g =
|
|
852
|
-
if (!g || !
|
|
853
|
+
const g = N(t), y = D(t), C = y && (y.position === "fixed" || y.position === "sticky"), M = t.offsetWidth > 0 || t.offsetHeight > 0;
|
|
854
|
+
if (!g || !C && !M && (g.bottom < -l || g.top > window.innerHeight + l || g.right < -l || g.left > window.innerWidth + l))
|
|
853
855
|
return null;
|
|
854
856
|
}
|
|
855
857
|
const a = {
|
|
@@ -861,63 +863,63 @@ const VIEWPORT_EXPANSION = -1, domTree = (e = {
|
|
|
861
863
|
// xpath: getXPathTree(node, true),
|
|
862
864
|
children: []
|
|
863
865
|
};
|
|
864
|
-
if (
|
|
866
|
+
if (F(t) || t.tagName.toLowerCase() === "iframe" || t.tagName.toLowerCase() === "body") {
|
|
865
867
|
const g = ((m = t.getAttributeNames) == null ? void 0 : m.call(t)) || [];
|
|
866
868
|
for (const y of g) {
|
|
867
|
-
const
|
|
868
|
-
a.attributes[y] =
|
|
869
|
+
const C = t.getAttribute(y);
|
|
870
|
+
a.attributes[y] = C;
|
|
869
871
|
}
|
|
870
872
|
t.tagName.toLowerCase() === "input" && (t.type === "checkbox" || t.type === "radio") && (a.attributes.checked = t.checked ? "true" : "false");
|
|
871
873
|
}
|
|
872
874
|
let c = !1;
|
|
873
|
-
if (t.nodeType === Node.ELEMENT_NODE && (a.isVisible =
|
|
874
|
-
a.isTopElement =
|
|
875
|
+
if (t.nodeType === Node.ELEMENT_NODE && (a.isVisible = X(t), a.isVisible)) {
|
|
876
|
+
a.isTopElement = et(t);
|
|
875
877
|
const g = t.getAttribute("role"), y = g === "menu" || g === "menubar" || g === "listbox";
|
|
876
|
-
(a.isTopElement || y) && (a.isInteractive =
|
|
878
|
+
(a.isTopElement || y) && (a.isInteractive = L(t), c = st(a, t, o, p), a.ref = t);
|
|
877
879
|
}
|
|
878
880
|
if (t.tagName) {
|
|
879
881
|
const g = t.tagName.toLowerCase();
|
|
880
882
|
if (g === "iframe")
|
|
881
883
|
try {
|
|
882
|
-
const y = t.contentDocument || ((
|
|
884
|
+
const y = t.contentDocument || (($ = t.contentWindow) == null ? void 0 : $.document);
|
|
883
885
|
if (y)
|
|
884
|
-
for (const
|
|
885
|
-
const
|
|
886
|
-
|
|
886
|
+
for (const C of y.childNodes) {
|
|
887
|
+
const M = Q(C, t, !1);
|
|
888
|
+
M && a.children.push(M);
|
|
887
889
|
}
|
|
888
890
|
} catch (y) {
|
|
889
891
|
console.warn("Unable to access iframe:", y);
|
|
890
892
|
}
|
|
891
893
|
else if (t.isContentEditable || t.getAttribute("contenteditable") === "true" || t.id === "tinymce" || t.classList.contains("mce-content-body") || g === "body" && ((A = t.getAttribute("data-id")) != null && A.startsWith("mce_")))
|
|
892
894
|
for (const y of t.childNodes) {
|
|
893
|
-
const
|
|
894
|
-
|
|
895
|
+
const C = Q(y, o, c);
|
|
896
|
+
C && a.children.push(C);
|
|
895
897
|
}
|
|
896
898
|
else {
|
|
897
899
|
if (t.shadowRoot) {
|
|
898
900
|
a.shadowRoot = !0;
|
|
899
901
|
for (const y of t.shadowRoot.childNodes) {
|
|
900
|
-
const
|
|
901
|
-
|
|
902
|
+
const C = Q(y, o, c);
|
|
903
|
+
C && a.children.push(C);
|
|
902
904
|
}
|
|
903
905
|
}
|
|
904
906
|
for (const y of t.childNodes) {
|
|
905
|
-
const
|
|
906
|
-
|
|
907
|
+
const M = Q(y, o, c || p);
|
|
908
|
+
M && a.children.push(M);
|
|
907
909
|
}
|
|
908
910
|
}
|
|
909
911
|
}
|
|
910
912
|
if (a.tagName === "a" && a.children.length === 0 && !a.attributes.href) {
|
|
911
|
-
const g =
|
|
913
|
+
const g = N(t);
|
|
912
914
|
if (!(g && g.width > 0 && g.height > 0 || t.offsetWidth > 0 || t.offsetHeight > 0))
|
|
913
915
|
return null;
|
|
914
916
|
}
|
|
915
|
-
a.extra =
|
|
917
|
+
a.extra = b.get(t) || null;
|
|
916
918
|
const x = `${R.current++}`;
|
|
917
919
|
return O[x] = a, x;
|
|
918
920
|
}
|
|
919
|
-
const
|
|
920
|
-
return f.clearCache(), { rootId:
|
|
921
|
+
const lt = Q(document.body);
|
|
922
|
+
return f.clearCache(), { rootId: lt, map: O };
|
|
921
923
|
}, newElementsCache = /* @__PURE__ */ new WeakMap();
|
|
922
924
|
function getFlatTree(e) {
|
|
923
925
|
const n = [];
|
|
@@ -935,12 +937,12 @@ function getFlatTree(e) {
|
|
|
935
937
|
interactiveWhitelist: s,
|
|
936
938
|
highlightOpacity: e.highlightOpacity ?? 0,
|
|
937
939
|
highlightLabelOpacity: e.highlightLabelOpacity ?? 0.1
|
|
938
|
-
}),
|
|
940
|
+
}), w = window.location.href;
|
|
939
941
|
for (const d in i.map) {
|
|
940
942
|
const r = i.map[d];
|
|
941
943
|
if (r.isInteractive && r.ref) {
|
|
942
944
|
const l = r.ref;
|
|
943
|
-
newElementsCache.has(l) || (newElementsCache.set(l,
|
|
945
|
+
newElementsCache.has(l) || (newElementsCache.set(l, w), r.isNew = !0);
|
|
944
946
|
}
|
|
945
947
|
}
|
|
946
948
|
return i;
|
|
@@ -969,43 +971,43 @@ function flatTreeToString(e, n) {
|
|
|
969
971
|
"aria-haspopup",
|
|
970
972
|
"aria-controls",
|
|
971
973
|
"aria-owns"
|
|
972
|
-
], i = [...n || [], ...s],
|
|
974
|
+
], i = [...n || [], ...s], w = (u, f) => u.length > f ? u.substring(0, f) + "..." : u, d = (u) => {
|
|
973
975
|
const f = e.map[u];
|
|
974
976
|
if (!f) return null;
|
|
975
977
|
if (f.type === "TEXT_NODE") {
|
|
976
|
-
const
|
|
978
|
+
const N = f;
|
|
977
979
|
return {
|
|
978
980
|
type: "text",
|
|
979
|
-
text:
|
|
980
|
-
isVisible:
|
|
981
|
+
text: N.text,
|
|
982
|
+
isVisible: N.isVisible,
|
|
981
983
|
parent: null,
|
|
982
984
|
children: []
|
|
983
985
|
};
|
|
984
986
|
} else {
|
|
985
|
-
const
|
|
986
|
-
if (
|
|
987
|
-
for (const
|
|
988
|
-
const O = d(
|
|
989
|
-
O && (O.parent = null,
|
|
987
|
+
const N = f, D = [];
|
|
988
|
+
if (N.children)
|
|
989
|
+
for (const z of N.children) {
|
|
990
|
+
const O = d(z);
|
|
991
|
+
O && (O.parent = null, D.push(O));
|
|
990
992
|
}
|
|
991
993
|
return {
|
|
992
994
|
type: "element",
|
|
993
|
-
tagName:
|
|
994
|
-
attributes:
|
|
995
|
-
isVisible:
|
|
996
|
-
isInteractive:
|
|
997
|
-
isTopElement:
|
|
998
|
-
isNew:
|
|
999
|
-
highlightIndex:
|
|
995
|
+
tagName: N.tagName,
|
|
996
|
+
attributes: N.attributes ?? {},
|
|
997
|
+
isVisible: N.isVisible ?? !1,
|
|
998
|
+
isInteractive: N.isInteractive ?? !1,
|
|
999
|
+
isTopElement: N.isTopElement ?? !1,
|
|
1000
|
+
isNew: N.isNew ?? !1,
|
|
1001
|
+
highlightIndex: N.highlightIndex,
|
|
1000
1002
|
parent: null,
|
|
1001
|
-
children:
|
|
1002
|
-
extra:
|
|
1003
|
+
children: D,
|
|
1004
|
+
extra: N.extra ?? {}
|
|
1003
1005
|
};
|
|
1004
1006
|
}
|
|
1005
1007
|
}, r = (u, f = null) => {
|
|
1006
1008
|
u.parent = f;
|
|
1007
|
-
for (const
|
|
1008
|
-
r(
|
|
1009
|
+
for (const N of u.children)
|
|
1010
|
+
r(N, u);
|
|
1009
1011
|
}, l = d(e.rootId);
|
|
1010
1012
|
if (!l) return "";
|
|
1011
1013
|
r(l);
|
|
@@ -1017,67 +1019,67 @@ function flatTreeToString(e, n) {
|
|
|
1017
1019
|
f = f.parent;
|
|
1018
1020
|
}
|
|
1019
1021
|
return !1;
|
|
1020
|
-
},
|
|
1021
|
-
var O, R,
|
|
1022
|
-
let
|
|
1023
|
-
const
|
|
1022
|
+
}, T = (u, f, N) => {
|
|
1023
|
+
var O, R, U, H;
|
|
1024
|
+
let D = f;
|
|
1025
|
+
const z = " ".repeat(f);
|
|
1024
1026
|
if (u.type === "element") {
|
|
1025
1027
|
if (u.highlightIndex !== void 0) {
|
|
1026
|
-
|
|
1027
|
-
const
|
|
1028
|
+
D += 1;
|
|
1029
|
+
const B = getAllTextTillNextClickableElement(u);
|
|
1028
1030
|
let _ = "";
|
|
1029
1031
|
if (i.length > 0 && u.attributes) {
|
|
1030
|
-
const
|
|
1031
|
-
for (const
|
|
1032
|
-
const
|
|
1033
|
-
|
|
1032
|
+
const L = {};
|
|
1033
|
+
for (const F of i) {
|
|
1034
|
+
const Y = u.attributes[F];
|
|
1035
|
+
Y && Y.trim() !== "" && (L[F] = Y.trim());
|
|
1034
1036
|
}
|
|
1035
|
-
const
|
|
1036
|
-
if (
|
|
1037
|
-
const
|
|
1038
|
-
for (const
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1037
|
+
const et = i.filter((F) => F in L);
|
|
1038
|
+
if (et.length > 1) {
|
|
1039
|
+
const F = /* @__PURE__ */ new Set(), Y = {};
|
|
1040
|
+
for (const K of et) {
|
|
1041
|
+
const tt = L[K];
|
|
1042
|
+
tt.length > 5 && (tt in Y ? F.add(K) : Y[tt] = K);
|
|
1041
1043
|
}
|
|
1042
|
-
for (const
|
|
1043
|
-
delete
|
|
1044
|
+
for (const K of F)
|
|
1045
|
+
delete L[K];
|
|
1044
1046
|
}
|
|
1045
|
-
|
|
1046
|
-
const
|
|
1047
|
-
for (const
|
|
1048
|
-
|
|
1049
|
-
Object.keys(
|
|
1047
|
+
L.role === u.tagName && delete L.role;
|
|
1048
|
+
const it = ["aria-label", "placeholder", "title"];
|
|
1049
|
+
for (const F of it)
|
|
1050
|
+
L[F] && L[F].toLowerCase().trim() === B.toLowerCase().trim() && delete L[F];
|
|
1051
|
+
Object.keys(L).length > 0 && (_ = Object.entries(L).map(([F, Y]) => `${F}=${w(Y, 20)}`).join(" "));
|
|
1050
1052
|
}
|
|
1051
|
-
const
|
|
1052
|
-
let
|
|
1053
|
-
if (_ && (
|
|
1054
|
-
let
|
|
1055
|
-
(O = u.extra.scrollData) != null && O.left && (
|
|
1053
|
+
const ot = u.isNew ? `*[${u.highlightIndex}]` : `[${u.highlightIndex}]`;
|
|
1054
|
+
let X = `${z}${ot}<${u.tagName ?? ""}`;
|
|
1055
|
+
if (_ && (X += ` ${_}`), u.extra && u.extra.scrollable) {
|
|
1056
|
+
let L = "";
|
|
1057
|
+
(O = u.extra.scrollData) != null && O.left && (L += `left=${u.extra.scrollData.left}, `), (R = u.extra.scrollData) != null && R.top && (L += `top=${u.extra.scrollData.top}, `), (U = u.extra.scrollData) != null && U.right && (L += `right=${u.extra.scrollData.right}, `), (H = u.extra.scrollData) != null && H.bottom && (L += `bottom=${u.extra.scrollData.bottom}`), X += ` data-scrollable="${L}"`;
|
|
1056
1058
|
}
|
|
1057
|
-
if (
|
|
1058
|
-
const
|
|
1059
|
-
_ || (
|
|
1060
|
-
} else _ || (
|
|
1061
|
-
|
|
1059
|
+
if (B) {
|
|
1060
|
+
const L = B.trim();
|
|
1061
|
+
_ || (X += " "), X += `>${L}`;
|
|
1062
|
+
} else _ || (X += " ");
|
|
1063
|
+
X += " />", N.push(X);
|
|
1062
1064
|
}
|
|
1063
|
-
for (const
|
|
1064
|
-
|
|
1065
|
+
for (const B of u.children)
|
|
1066
|
+
T(B, D, N);
|
|
1065
1067
|
} else if (u.type === "text") {
|
|
1066
1068
|
if (h(u))
|
|
1067
1069
|
return;
|
|
1068
|
-
u.parent && u.parent.type === "element" && u.parent.isVisible && u.parent.isTopElement &&
|
|
1070
|
+
u.parent && u.parent.type === "element" && u.parent.isVisible && u.parent.isTopElement && N.push(`${z}${u.text ?? ""}`);
|
|
1069
1071
|
}
|
|
1070
|
-
},
|
|
1071
|
-
return
|
|
1072
|
+
}, b = [];
|
|
1073
|
+
return T(l, 0, b), b.join(`
|
|
1072
1074
|
`);
|
|
1073
1075
|
}
|
|
1074
1076
|
const getAllTextTillNextClickableElement = (e, n = -1) => {
|
|
1075
|
-
const s = [], i = (
|
|
1076
|
-
if (!(n !== -1 && d > n) && !(
|
|
1077
|
-
if (
|
|
1078
|
-
s.push(
|
|
1079
|
-
else if (
|
|
1080
|
-
for (const r of
|
|
1077
|
+
const s = [], i = (w, d) => {
|
|
1078
|
+
if (!(n !== -1 && d > n) && !(w.type === "element" && w !== e && w.highlightIndex !== void 0)) {
|
|
1079
|
+
if (w.type === "text" && w.text)
|
|
1080
|
+
s.push(w.text);
|
|
1081
|
+
else if (w.type === "element")
|
|
1082
|
+
for (const r of w.children)
|
|
1081
1083
|
i(r, d + 1);
|
|
1082
1084
|
}
|
|
1083
1085
|
};
|
|
@@ -1087,8 +1089,8 @@ const getAllTextTillNextClickableElement = (e, n = -1) => {
|
|
|
1087
1089
|
function getSelectorMap(e) {
|
|
1088
1090
|
const n = /* @__PURE__ */ new Map(), s = Object.keys(e.map);
|
|
1089
1091
|
for (const i of s) {
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1092
|
+
const w = e.map[i];
|
|
1093
|
+
w.isInteractive && typeof w.highlightIndex == "number" && n.set(w.highlightIndex, w);
|
|
1092
1094
|
}
|
|
1093
1095
|
return n;
|
|
1094
1096
|
}
|
|
@@ -1134,7 +1136,7 @@ function getPageInfo() {
|
|
|
1134
1136
|
const e = window.innerWidth, n = window.innerHeight, s = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth || 0), i = Math.max(
|
|
1135
1137
|
document.documentElement.scrollHeight,
|
|
1136
1138
|
document.body.scrollHeight || 0
|
|
1137
|
-
),
|
|
1139
|
+
), w = window.scrollX || window.pageXOffset || document.documentElement.scrollLeft || 0, d = window.scrollY || window.pageYOffset || document.documentElement.scrollTop || 0, r = Math.max(0, i - (window.innerHeight + d)), l = Math.max(0, s - (window.innerWidth + w));
|
|
1138
1140
|
return {
|
|
1139
1141
|
// Current viewport dimensions
|
|
1140
1142
|
viewport_width: e,
|
|
@@ -1143,7 +1145,7 @@ function getPageInfo() {
|
|
|
1143
1145
|
page_width: s,
|
|
1144
1146
|
page_height: i,
|
|
1145
1147
|
// Current scroll position
|
|
1146
|
-
scroll_x:
|
|
1148
|
+
scroll_x: w,
|
|
1147
1149
|
scroll_y: d,
|
|
1148
1150
|
pixels_above: d,
|
|
1149
1151
|
pixels_below: r,
|
|
@@ -1151,7 +1153,7 @@ function getPageInfo() {
|
|
|
1151
1153
|
pages_below: n > 0 ? r / n : 0,
|
|
1152
1154
|
total_pages: n > 0 ? i / n : 0,
|
|
1153
1155
|
current_page_position: d / Math.max(1, i - n),
|
|
1154
|
-
pixels_left:
|
|
1156
|
+
pixels_left: w,
|
|
1155
1157
|
pixels_right: l
|
|
1156
1158
|
};
|
|
1157
1159
|
}
|
|
@@ -1171,7 +1173,7 @@ class PageController extends EventTarget {
|
|
|
1171
1173
|
*/
|
|
1172
1174
|
initMask() {
|
|
1173
1175
|
this.maskReady === null && (this.maskReady = (async () => {
|
|
1174
|
-
const { SimulatorMask: e } = await import("./SimulatorMask-
|
|
1176
|
+
const { SimulatorMask: e } = await import("./SimulatorMask-74sRLkJv.js");
|
|
1175
1177
|
this.mask = new e();
|
|
1176
1178
|
})());
|
|
1177
1179
|
}
|
|
@@ -1195,13 +1197,13 @@ class PageController extends EventTarget {
|
|
|
1195
1197
|
async getBrowserState() {
|
|
1196
1198
|
const e = window.location.href, n = document.title, s = getPageInfo(), i = this.config.viewportExpansion ?? VIEWPORT_EXPANSION;
|
|
1197
1199
|
await this.updateTree();
|
|
1198
|
-
const
|
|
1200
|
+
const w = this.simplifiedHTML, d = `Current Page: [${n}](${e})`, r = `Page info: ${s.viewport_width}x${s.viewport_height}px viewport, ${s.page_width}x${s.page_height}px total page size, ${s.pages_above.toFixed(1)} pages above, ${s.pages_below.toFixed(1)} pages below, ${s.total_pages.toFixed(1)} total pages, at ${(s.current_page_position * 100).toFixed(0)}% of page`, l = i === -1 ? "Interactive elements from top layer of the current page (full page):" : "Interactive elements from top layer of the current page inside the viewport:", T = s.pixels_above > 4 && i !== -1 ? `... ${s.pixels_above} pixels above (${s.pages_above.toFixed(1)} pages) - scroll to see more ...` : "[Start of page]", b = `${d}
|
|
1199
1201
|
${r}
|
|
1200
1202
|
|
|
1201
1203
|
${l}
|
|
1202
1204
|
|
|
1203
|
-
${
|
|
1204
|
-
return { url: e, title: n, header:
|
|
1205
|
+
${T}`, f = s.pixels_below > 4 && i !== -1 ? `... ${s.pixels_below} pixels below (${s.pages_below.toFixed(1)} pages) - scroll to see more ...` : "[End of page]";
|
|
1206
|
+
return { url: e, title: n, header: b, content: w, footer: f };
|
|
1205
1207
|
}
|
|
1206
1208
|
// ======= DOM Tree Operations =======
|
|
1207
1209
|
/**
|
|
@@ -1297,9 +1299,9 @@ ${v}`, f = s.pixels_below > 4 && i !== -1 ? `... ${s.pixels_below} pixels below
|
|
|
1297
1299
|
*/
|
|
1298
1300
|
async scroll(e) {
|
|
1299
1301
|
try {
|
|
1300
|
-
const { down: n, numPages: s, pixels: i, index:
|
|
1302
|
+
const { down: n, numPages: s, pixels: i, index: w } = e;
|
|
1301
1303
|
this.assertIndexed();
|
|
1302
|
-
const d = i ?? s * (n ? 1 : -1) * window.innerHeight, r =
|
|
1304
|
+
const d = i ?? s * (n ? 1 : -1) * window.innerHeight, r = w !== void 0 ? getElementByIndex(this.selectorMap, w) : null;
|
|
1303
1305
|
return {
|
|
1304
1306
|
success: !0,
|
|
1305
1307
|
message: await scrollVertically(n, d, r)
|
|
@@ -1318,10 +1320,10 @@ ${v}`, f = s.pixels_below > 4 && i !== -1 ? `... ${s.pixels_below} pixels below
|
|
|
1318
1320
|
try {
|
|
1319
1321
|
const { right: n, pixels: s, index: i } = e;
|
|
1320
1322
|
this.assertIndexed();
|
|
1321
|
-
const
|
|
1323
|
+
const w = s * (n ? 1 : -1), d = i !== void 0 ? getElementByIndex(this.selectorMap, i) : null;
|
|
1322
1324
|
return {
|
|
1323
1325
|
success: !0,
|
|
1324
|
-
message: await scrollHorizontally(n,
|
|
1326
|
+
message: await scrollHorizontally(n, w, d)
|
|
1325
1327
|
};
|
|
1326
1328
|
} catch (n) {
|
|
1327
1329
|
return {
|