@appsurify-testmap/rrweb-snapshot 3.10.0-alpha.1 → 3.12.0-alpha.1
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/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/rrweb-snapshot.cjs +320 -213
- package/dist/rrweb-snapshot.cjs.map +1 -1
- package/dist/rrweb-snapshot.js +320 -213
- package/dist/rrweb-snapshot.js.map +1 -1
- package/dist/rrweb-snapshot.umd.cjs +335 -213
- package/dist/rrweb-snapshot.umd.cjs.map +3 -3
- package/dist/rrweb-snapshot.umd.min.cjs +18 -18
- package/dist/rrweb-snapshot.umd.min.cjs.map +3 -3
- package/package.json +4 -4
package/dist/rrweb-snapshot.js
CHANGED
|
@@ -170,16 +170,30 @@ function describeNode(el) {
|
|
|
170
170
|
const classes = el.classList.length ? "." + Array.from(el.classList).join(".") : "";
|
|
171
171
|
return `${tag}${id}${classes}`;
|
|
172
172
|
}
|
|
173
|
+
function isAncestorOpacityVisible(el, win) {
|
|
174
|
+
var _a;
|
|
175
|
+
let node2 = el.parentElement;
|
|
176
|
+
while (node2) {
|
|
177
|
+
const s = (_a = win.getComputedStyle) == null ? void 0 : _a.call(win, node2);
|
|
178
|
+
if (s && (parseFloat(s.opacity) || 0) <= 0) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
node2 = node2.parentElement;
|
|
182
|
+
}
|
|
183
|
+
return true;
|
|
184
|
+
}
|
|
173
185
|
function getElementVisibility(el) {
|
|
174
186
|
var _a, _b;
|
|
175
187
|
const win = ((_a = el.ownerDocument) == null ? void 0 : _a.defaultView) ?? window;
|
|
176
188
|
const rect = el.getBoundingClientRect();
|
|
177
189
|
const viewportWidth = win.innerWidth || win.document.documentElement.clientWidth || 0;
|
|
178
190
|
const viewportHeight = win.innerHeight || win.document.documentElement.clientHeight || 0;
|
|
179
|
-
const
|
|
191
|
+
const elHasSize = rect.width > 0 && rect.height > 0;
|
|
192
|
+
const isViewportVisible = elHasSize && rect.bottom > 0 && rect.right > 0 && rect.top < viewportHeight && rect.left < viewportWidth;
|
|
180
193
|
const style = (_b = win.getComputedStyle) == null ? void 0 : _b.call(win, el);
|
|
181
|
-
const
|
|
182
|
-
const
|
|
194
|
+
const isOwnStyleVisible = !!style && style.display !== "none" && style.visibility !== "hidden" && (parseFloat(style.opacity) || 0) > 0;
|
|
195
|
+
const isCSSVisible = isOwnStyleVisible && isAncestorOpacityVisible(el, win);
|
|
196
|
+
const isVisible = isCSSVisible && isViewportVisible;
|
|
183
197
|
let ratio = 0;
|
|
184
198
|
if (isVisible) {
|
|
185
199
|
const xOverlap = Math.max(
|
|
@@ -196,6 +210,9 @@ function getElementVisibility(el) {
|
|
|
196
210
|
}
|
|
197
211
|
return {
|
|
198
212
|
isVisible,
|
|
213
|
+
isCSSVisible,
|
|
214
|
+
isViewportVisible,
|
|
215
|
+
hasSize: elHasSize,
|
|
199
216
|
ratio
|
|
200
217
|
};
|
|
201
218
|
}
|
|
@@ -647,19 +664,18 @@ function isTextVisible(n) {
|
|
|
647
664
|
var _a;
|
|
648
665
|
const parent = index.parentNode(n);
|
|
649
666
|
const parentElement2 = parent && parent;
|
|
650
|
-
if (!parentElement2) {
|
|
667
|
+
if (!parentElement2 || parentElement2.nodeType !== Node.ELEMENT_NODE) {
|
|
651
668
|
return false;
|
|
652
669
|
}
|
|
653
|
-
const
|
|
654
|
-
if (!
|
|
670
|
+
const parentVis = isElementVisible(parentElement2);
|
|
671
|
+
if (!parentVis.isVisible) {
|
|
655
672
|
return false;
|
|
656
673
|
}
|
|
657
674
|
const textContent2 = (_a = n.textContent) == null ? void 0 : _a.trim();
|
|
658
675
|
return textContent2 !== "";
|
|
659
676
|
}
|
|
660
677
|
function isElementVisible(el) {
|
|
661
|
-
|
|
662
|
-
return visibility.isVisible;
|
|
678
|
+
return index.getElementVisibility(el);
|
|
663
679
|
}
|
|
664
680
|
const interactiveEvents = [
|
|
665
681
|
"change",
|
|
@@ -775,7 +791,7 @@ try {
|
|
|
775
791
|
}
|
|
776
792
|
} catch (error) {
|
|
777
793
|
}
|
|
778
|
-
const
|
|
794
|
+
const z = {
|
|
779
795
|
ANCHOR: 0.4,
|
|
780
796
|
PATH: 0.3,
|
|
781
797
|
TARGET: 0.2,
|
|
@@ -789,9 +805,9 @@ const U = {
|
|
|
789
805
|
DEPTH_PENALTY_THRESHOLD: 5,
|
|
790
806
|
DEPTH_PENALTY_FACTOR: 0.05,
|
|
791
807
|
DEGRADED_SCORE: 0.3
|
|
792
|
-
},
|
|
808
|
+
}, bt = {
|
|
793
809
|
MIN_CONFIDENCE_FOR_SKIP: 0.7
|
|
794
|
-
},
|
|
810
|
+
}, tt = [
|
|
795
811
|
"form",
|
|
796
812
|
"main",
|
|
797
813
|
"nav",
|
|
@@ -799,7 +815,7 @@ const U = {
|
|
|
799
815
|
"article",
|
|
800
816
|
"footer",
|
|
801
817
|
"header"
|
|
802
|
-
],
|
|
818
|
+
], et = [
|
|
803
819
|
"form",
|
|
804
820
|
"navigation",
|
|
805
821
|
"main",
|
|
@@ -808,7 +824,7 @@ const U = {
|
|
|
808
824
|
"complementary",
|
|
809
825
|
"banner",
|
|
810
826
|
"search"
|
|
811
|
-
],
|
|
827
|
+
], St = [
|
|
812
828
|
// HTML5 Semantic
|
|
813
829
|
"article",
|
|
814
830
|
"aside",
|
|
@@ -912,7 +928,7 @@ const U = {
|
|
|
912
928
|
"data-*": 30,
|
|
913
929
|
// Any aria-* attribute (if not above)
|
|
914
930
|
"aria-*": 25
|
|
915
|
-
},
|
|
931
|
+
}, Y = /* @__PURE__ */ new Set([
|
|
916
932
|
"id",
|
|
917
933
|
// handled separately
|
|
918
934
|
"class",
|
|
@@ -924,7 +940,7 @@ const U = {
|
|
|
924
940
|
"tabindex",
|
|
925
941
|
// can change
|
|
926
942
|
"contenteditable"
|
|
927
|
-
]),
|
|
943
|
+
]), At = {
|
|
928
944
|
maxPathDepth: 10,
|
|
929
945
|
enableSvgFingerprint: true,
|
|
930
946
|
confidenceThreshold: 0,
|
|
@@ -932,7 +948,7 @@ const U = {
|
|
|
932
948
|
includeUtilityClasses: false,
|
|
933
949
|
source: "dom-dsl"
|
|
934
950
|
};
|
|
935
|
-
function
|
|
951
|
+
function L(r) {
|
|
936
952
|
if (/^[a-z]+-\d+$/i.test(r) || /^[a-z]+(-[a-z]+)+-\d+$/i.test(r) || /^[a-z]+(_[a-z]+)*_\d+$/i.test(r) || /^\d+$/.test(r) || /^:[a-z0-9]+:$/i.test(r) || /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(r))
|
|
937
953
|
return true;
|
|
938
954
|
if (/^[a-z]{1,3}[A-Za-z0-9]{8,}$/.test(r)) {
|
|
@@ -942,7 +958,7 @@ function P(r) {
|
|
|
942
958
|
}
|
|
943
959
|
return !!(/^radix-/.test(r) || /^mui-\d+$/.test(r));
|
|
944
960
|
}
|
|
945
|
-
const
|
|
961
|
+
const Z = /* @__PURE__ */ new Set([
|
|
946
962
|
"aria-labelledby",
|
|
947
963
|
"aria-describedby",
|
|
948
964
|
"aria-controls",
|
|
@@ -956,10 +972,10 @@ const Q = /* @__PURE__ */ new Set([
|
|
|
956
972
|
"aria-errormessage",
|
|
957
973
|
"aria-flowto"
|
|
958
974
|
]);
|
|
959
|
-
function
|
|
960
|
-
return r.trim().split(/\s+/).some((e) =>
|
|
975
|
+
function K(r) {
|
|
976
|
+
return r.trim().split(/\s+/).some((e) => L(e));
|
|
961
977
|
}
|
|
962
|
-
class
|
|
978
|
+
class Ct {
|
|
963
979
|
constructor(t, e) {
|
|
964
980
|
this.maxDepth = t.maxPathDepth ?? 10, this.cache = e;
|
|
965
981
|
}
|
|
@@ -992,25 +1008,25 @@ class St {
|
|
|
992
1008
|
if (e === "head" || this.isInsideHead(t)) {
|
|
993
1009
|
const c = s == null ? void 0 : s.documentElement;
|
|
994
1010
|
if (c) {
|
|
995
|
-
const
|
|
1011
|
+
const l = {
|
|
996
1012
|
element: c,
|
|
997
1013
|
score: 1,
|
|
998
1014
|
tier: "A",
|
|
999
1015
|
depth: 0
|
|
1000
1016
|
};
|
|
1001
|
-
return this.cacheResult(t,
|
|
1017
|
+
return this.cacheResult(t, l), l;
|
|
1002
1018
|
}
|
|
1003
1019
|
}
|
|
1004
1020
|
if (e === "body") {
|
|
1005
1021
|
const c = s == null ? void 0 : s.documentElement;
|
|
1006
1022
|
if (c) {
|
|
1007
|
-
const
|
|
1023
|
+
const l = {
|
|
1008
1024
|
element: c,
|
|
1009
1025
|
score: 1,
|
|
1010
1026
|
tier: "A",
|
|
1011
1027
|
depth: 0
|
|
1012
1028
|
};
|
|
1013
|
-
return this.cacheResult(t,
|
|
1029
|
+
return this.cacheResult(t, l), l;
|
|
1014
1030
|
}
|
|
1015
1031
|
}
|
|
1016
1032
|
let n = t.parentElement, a = 0, i = null;
|
|
@@ -1024,10 +1040,10 @@ class St {
|
|
|
1024
1040
|
};
|
|
1025
1041
|
const c = this.scoreAnchor(n);
|
|
1026
1042
|
if (c > 0) {
|
|
1027
|
-
const
|
|
1028
|
-
if (
|
|
1029
|
-
return
|
|
1030
|
-
(!i ||
|
|
1043
|
+
const l = this.applyDepthPenalty(c, a), f = this.getTier(n), h = { element: n, score: l, tier: f, depth: a };
|
|
1044
|
+
if (f === "A")
|
|
1045
|
+
return h;
|
|
1046
|
+
(!i || l > i.score) && (i = h);
|
|
1031
1047
|
}
|
|
1032
1048
|
n = n.parentElement, a++;
|
|
1033
1049
|
}
|
|
@@ -1042,11 +1058,11 @@ class St {
|
|
|
1042
1058
|
scoreAnchor(t) {
|
|
1043
1059
|
let e = 0;
|
|
1044
1060
|
const s = t.tagName.toLowerCase();
|
|
1045
|
-
|
|
1061
|
+
tt.includes(s) && (e += I.SEMANTIC_TAG);
|
|
1046
1062
|
const n = t.getAttribute("role");
|
|
1047
|
-
n &&
|
|
1063
|
+
n && et.includes(n) && (e += I.ROLE), (t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby")) && (e += I.ARIA_LABEL);
|
|
1048
1064
|
const a = t.id;
|
|
1049
|
-
return a && !
|
|
1065
|
+
return a && !L(a) && (e += I.STABLE_ID), (t.hasAttribute("data-testid") || t.hasAttribute("data-qa") || t.hasAttribute("data-test")) && (e += I.TEST_MARKER), Math.min(e, 1);
|
|
1050
1066
|
}
|
|
1051
1067
|
/**
|
|
1052
1068
|
* Applies depth penalty to score
|
|
@@ -1063,10 +1079,10 @@ class St {
|
|
|
1063
1079
|
*/
|
|
1064
1080
|
getTier(t) {
|
|
1065
1081
|
const e = t.tagName.toLowerCase();
|
|
1066
|
-
if (
|
|
1082
|
+
if (tt.includes(e))
|
|
1067
1083
|
return "A";
|
|
1068
1084
|
const s = t.getAttribute("role");
|
|
1069
|
-
return s &&
|
|
1085
|
+
return s && et.includes(s) ? "B" : "C";
|
|
1070
1086
|
}
|
|
1071
1087
|
/**
|
|
1072
1088
|
* Checks if element is inside <head> section.
|
|
@@ -1099,7 +1115,7 @@ class St {
|
|
|
1099
1115
|
this.cache && this.cache.setAnchor(t, e);
|
|
1100
1116
|
}
|
|
1101
1117
|
}
|
|
1102
|
-
const
|
|
1118
|
+
const Tt = [
|
|
1103
1119
|
// CSS-in-JS
|
|
1104
1120
|
/^css-[a-z0-9]+$/i,
|
|
1105
1121
|
/^sc-[a-z0-9]+-\d+$/i,
|
|
@@ -1119,7 +1135,7 @@ const At = [
|
|
|
1119
1135
|
/^_[a-z0-9]{5,}$/i,
|
|
1120
1136
|
/\d{5,}/
|
|
1121
1137
|
// 5+ digits in a row
|
|
1122
|
-
],
|
|
1138
|
+
], Et = [
|
|
1123
1139
|
// === FIX 4: Tailwind arbitrary values and variants (highest priority) ===
|
|
1124
1140
|
/^\[/,
|
|
1125
1141
|
// Any arbitrary value or variant starting with [ (e.g., [&_svg]:..., [mask-type:luminance])
|
|
@@ -1231,29 +1247,81 @@ const At = [
|
|
|
1231
1247
|
/^pull-(left|right)$/,
|
|
1232
1248
|
/^float-(left|right|none)$/
|
|
1233
1249
|
];
|
|
1234
|
-
function
|
|
1235
|
-
return
|
|
1250
|
+
function q(r) {
|
|
1251
|
+
return Tt.some((t) => t.test(r));
|
|
1236
1252
|
}
|
|
1237
|
-
function
|
|
1238
|
-
return r.length <= 2 || /^\d/.test(r) ? true :
|
|
1253
|
+
function U(r) {
|
|
1254
|
+
return r.length <= 2 || /^\d/.test(r) ? true : Et.some((t) => t.test(r));
|
|
1239
1255
|
}
|
|
1240
|
-
function
|
|
1241
|
-
return !
|
|
1256
|
+
function $t(r) {
|
|
1257
|
+
return !q(r) && !U(r);
|
|
1242
1258
|
}
|
|
1243
1259
|
function M(r) {
|
|
1244
|
-
return r.filter((t) =>
|
|
1260
|
+
return r.filter((t) => $t(t));
|
|
1245
1261
|
}
|
|
1246
|
-
function
|
|
1262
|
+
function It(r) {
|
|
1247
1263
|
const t = [], e = [];
|
|
1248
1264
|
for (const s of r)
|
|
1249
|
-
|
|
1265
|
+
U(s) || q(s) ? e.push(s) : t.push(s);
|
|
1250
1266
|
return { semantic: t, utility: e };
|
|
1251
1267
|
}
|
|
1252
|
-
function
|
|
1253
|
-
return
|
|
1268
|
+
function st(r) {
|
|
1269
|
+
return U(r) || q(r);
|
|
1270
|
+
}
|
|
1271
|
+
const Rt = /* @__PURE__ */ new Set([
|
|
1272
|
+
"tr",
|
|
1273
|
+
"td",
|
|
1274
|
+
"th",
|
|
1275
|
+
"thead",
|
|
1276
|
+
"tbody",
|
|
1277
|
+
"tfoot"
|
|
1278
|
+
]), Dt = /* @__PURE__ */ new Set([
|
|
1279
|
+
"data-testid",
|
|
1280
|
+
"data-qa",
|
|
1281
|
+
"data-cy",
|
|
1282
|
+
"data-test",
|
|
1283
|
+
"aria-label",
|
|
1284
|
+
"name",
|
|
1285
|
+
"href"
|
|
1286
|
+
]);
|
|
1287
|
+
function Mt(r) {
|
|
1288
|
+
if (r.id) return true;
|
|
1289
|
+
if (r.attributes) {
|
|
1290
|
+
for (const t of Object.keys(r.attributes))
|
|
1291
|
+
if (Dt.has(t)) return true;
|
|
1292
|
+
}
|
|
1293
|
+
return false;
|
|
1294
|
+
}
|
|
1295
|
+
function Lt(r, t, e) {
|
|
1296
|
+
var _a;
|
|
1297
|
+
const s = r.parentElement;
|
|
1298
|
+
if (!s) return true;
|
|
1299
|
+
for (const n of Array.from(s.children)) {
|
|
1300
|
+
if (n === r || n.tagName.toLowerCase() !== t) continue;
|
|
1301
|
+
if ((((_a = n.textContent) == null ? void 0 : _a.trim()) ?? "") === e) return false;
|
|
1302
|
+
}
|
|
1303
|
+
return true;
|
|
1304
|
+
}
|
|
1305
|
+
function _(r, t, e) {
|
|
1306
|
+
var _a;
|
|
1307
|
+
if (Rt.has(r)) return true;
|
|
1308
|
+
if (Mt(t)) return false;
|
|
1309
|
+
if (e) {
|
|
1310
|
+
const s = e.parentElement;
|
|
1311
|
+
if (s) {
|
|
1312
|
+
const n = (_a = t.text) == null ? void 0 : _a.normalized;
|
|
1313
|
+
if (n && Lt(e, r, n))
|
|
1314
|
+
return false;
|
|
1315
|
+
if (Array.from(s.children).some(
|
|
1316
|
+
(i) => i !== e && i.tagName.toLowerCase() === r
|
|
1317
|
+
)) return true;
|
|
1318
|
+
}
|
|
1319
|
+
return false;
|
|
1320
|
+
}
|
|
1321
|
+
return true;
|
|
1254
1322
|
}
|
|
1255
|
-
const
|
|
1256
|
-
class
|
|
1323
|
+
const rt = (r) => r.replace(/([#:.[\]@])/g, "\\$1");
|
|
1324
|
+
class Pt {
|
|
1257
1325
|
constructor(t, e) {
|
|
1258
1326
|
this.maxDepth = t.maxPathDepth ?? 10, this.cache = e;
|
|
1259
1327
|
}
|
|
@@ -1288,19 +1356,22 @@ class $t {
|
|
|
1288
1356
|
degraded: true,
|
|
1289
1357
|
degradationReason: "target-not-descendant-of-anchor"
|
|
1290
1358
|
};
|
|
1291
|
-
let
|
|
1292
|
-
return
|
|
1293
|
-
path:
|
|
1294
|
-
const h =
|
|
1359
|
+
let l = this.filterNoise(i);
|
|
1360
|
+
return l = this.ensureUniqueness(i, l, t, e, s), {
|
|
1361
|
+
path: l.map((h) => {
|
|
1362
|
+
const d = h.tagName.toLowerCase(), u = s.extract(h);
|
|
1295
1363
|
let g;
|
|
1296
|
-
if (h) {
|
|
1297
|
-
const m =
|
|
1298
|
-
|
|
1364
|
+
if (_(d, u, h)) {
|
|
1365
|
+
const m = h.parentElement;
|
|
1366
|
+
if (m) {
|
|
1367
|
+
const b = Array.from(m.children).indexOf(h);
|
|
1368
|
+
b !== -1 && (g = b + 1);
|
|
1369
|
+
}
|
|
1299
1370
|
}
|
|
1300
1371
|
return {
|
|
1301
|
-
tag:
|
|
1302
|
-
semantics:
|
|
1303
|
-
score: s.scoreElement(
|
|
1372
|
+
tag: d,
|
|
1373
|
+
semantics: u,
|
|
1374
|
+
score: s.scoreElement(h),
|
|
1304
1375
|
nthChild: g
|
|
1305
1376
|
};
|
|
1306
1377
|
}),
|
|
@@ -1325,27 +1396,27 @@ class $t {
|
|
|
1325
1396
|
if (!o) return e;
|
|
1326
1397
|
let c;
|
|
1327
1398
|
if (this.cache) {
|
|
1328
|
-
const
|
|
1329
|
-
|
|
1399
|
+
const f = this.cache.getSelectorResults(i);
|
|
1400
|
+
f !== void 0 ? c = f : (c = Array.from(o.querySelectorAll(i)), this.cache.setSelectorResults(i, c));
|
|
1330
1401
|
} else
|
|
1331
1402
|
c = o.querySelectorAll(i);
|
|
1332
1403
|
if (c.length <= 1)
|
|
1333
1404
|
return e;
|
|
1334
|
-
const
|
|
1335
|
-
for (const
|
|
1336
|
-
if (a.scoreElement(
|
|
1405
|
+
const l = t.filter((f) => !e.includes(f));
|
|
1406
|
+
for (const f of l) {
|
|
1407
|
+
if (a.scoreElement(f) < bt.MIN_CONFIDENCE_FOR_SKIP)
|
|
1337
1408
|
continue;
|
|
1338
|
-
const
|
|
1409
|
+
const d = this.insertNodeInOrder(e, f, t), u = this.buildTestSelector(s, d, n);
|
|
1339
1410
|
try {
|
|
1340
|
-
let
|
|
1411
|
+
let g;
|
|
1341
1412
|
if (this.cache) {
|
|
1342
|
-
const m = this.cache.getSelectorResults(
|
|
1343
|
-
m !== void 0 ?
|
|
1413
|
+
const m = this.cache.getSelectorResults(u);
|
|
1414
|
+
m !== void 0 ? g = m : (g = Array.from(o.querySelectorAll(u)), this.cache.setSelectorResults(u, g));
|
|
1344
1415
|
} else
|
|
1345
|
-
|
|
1346
|
-
if (
|
|
1347
|
-
return
|
|
1348
|
-
|
|
1416
|
+
g = o.querySelectorAll(u);
|
|
1417
|
+
if (g.length === 1)
|
|
1418
|
+
return d;
|
|
1419
|
+
g.length < c.length && (e = d);
|
|
1349
1420
|
} catch {
|
|
1350
1421
|
}
|
|
1351
1422
|
}
|
|
@@ -1379,9 +1450,9 @@ class $t {
|
|
|
1379
1450
|
*/
|
|
1380
1451
|
elementToSelector(t) {
|
|
1381
1452
|
let e = t.tagName.toLowerCase();
|
|
1382
|
-
t.id && !
|
|
1453
|
+
t.id && !L(t.id) && (e += `#${rt(t.id)}`);
|
|
1383
1454
|
for (const s of Array.from(t.classList))
|
|
1384
|
-
|
|
1455
|
+
st(s) || (e += `.${rt(s)}`);
|
|
1385
1456
|
return e;
|
|
1386
1457
|
}
|
|
1387
1458
|
/**
|
|
@@ -1395,7 +1466,7 @@ class $t {
|
|
|
1395
1466
|
*/
|
|
1396
1467
|
shouldInclude(t) {
|
|
1397
1468
|
const e = t.tagName.toLowerCase();
|
|
1398
|
-
return
|
|
1469
|
+
return St.includes(e) ? true : e === "div" || e === "span" ? this.hasSemanticFeatures(t) : false;
|
|
1399
1470
|
}
|
|
1400
1471
|
/**
|
|
1401
1472
|
* Checks if element has meaningful semantic features
|
|
@@ -1406,12 +1477,12 @@ class $t {
|
|
|
1406
1477
|
if (s.name.startsWith("aria-")) return true;
|
|
1407
1478
|
if (t.classList.length > 0) {
|
|
1408
1479
|
for (const s of Array.from(t.classList))
|
|
1409
|
-
if (!
|
|
1480
|
+
if (!st(s)) return true;
|
|
1410
1481
|
}
|
|
1411
1482
|
if (t.hasAttribute("data-testid") || t.hasAttribute("data-qa") || t.hasAttribute("data-test"))
|
|
1412
1483
|
return true;
|
|
1413
1484
|
const e = t.id;
|
|
1414
|
-
return !!(e && !
|
|
1485
|
+
return !!(e && !L(e));
|
|
1415
1486
|
}
|
|
1416
1487
|
/**
|
|
1417
1488
|
* Checks if element is inside <head> section.
|
|
@@ -1458,31 +1529,34 @@ class $t {
|
|
|
1458
1529
|
degradationReason: "head-not-found-in-path"
|
|
1459
1530
|
} : {
|
|
1460
1531
|
path: n.map((c) => {
|
|
1461
|
-
const
|
|
1462
|
-
let
|
|
1463
|
-
if (
|
|
1464
|
-
const
|
|
1465
|
-
|
|
1532
|
+
const l = c.tagName.toLowerCase(), f = s.extract(c);
|
|
1533
|
+
let h;
|
|
1534
|
+
if (_(l, f, c)) {
|
|
1535
|
+
const d = c.parentElement;
|
|
1536
|
+
if (d) {
|
|
1537
|
+
const g = Array.from(d.children).indexOf(c);
|
|
1538
|
+
g !== -1 && (h = g + 1);
|
|
1539
|
+
}
|
|
1466
1540
|
}
|
|
1467
1541
|
return {
|
|
1468
|
-
tag:
|
|
1469
|
-
semantics:
|
|
1542
|
+
tag: l,
|
|
1543
|
+
semantics: f,
|
|
1470
1544
|
score: s.scoreElement(c),
|
|
1471
|
-
nthChild:
|
|
1545
|
+
nthChild: h
|
|
1472
1546
|
};
|
|
1473
1547
|
}),
|
|
1474
1548
|
degraded: false
|
|
1475
1549
|
};
|
|
1476
1550
|
}
|
|
1477
1551
|
}
|
|
1478
|
-
function
|
|
1552
|
+
function j(r) {
|
|
1479
1553
|
return r ? r.trim().replace(/[\n\t\r]/g, " ").replace(/\s+/g, " ") : "";
|
|
1480
1554
|
}
|
|
1481
|
-
const
|
|
1555
|
+
const Ht = {
|
|
1482
1556
|
preserveQueryForAbsolute: true,
|
|
1483
1557
|
removeDynamicHashes: true
|
|
1484
1558
|
};
|
|
1485
|
-
function
|
|
1559
|
+
function kt(r) {
|
|
1486
1560
|
return r ? [
|
|
1487
1561
|
/\d{5,}/,
|
|
1488
1562
|
// 5+ digits
|
|
@@ -1496,18 +1570,18 @@ function It(r) {
|
|
|
1496
1570
|
// UUID-like
|
|
1497
1571
|
].some((e) => e.test(r)) : false;
|
|
1498
1572
|
}
|
|
1499
|
-
function
|
|
1573
|
+
function _t(r, t) {
|
|
1500
1574
|
if (!r) return r;
|
|
1501
1575
|
const e = r.startsWith("http://") || r.startsWith("https://"), [s, n] = r.split("#"), [a, i] = s.split("?");
|
|
1502
1576
|
let o = a;
|
|
1503
|
-
return e && t.preserveQueryForAbsolute && i && (o += `?${i}`), n && (t.removeDynamicHashes &&
|
|
1577
|
+
return e && t.preserveQueryForAbsolute && i && (o += `?${i}`), n && (t.removeDynamicHashes && kt(n) || (o += `#${n}`)), o;
|
|
1504
1578
|
}
|
|
1505
1579
|
function D(r, t, e = {}) {
|
|
1506
1580
|
if (!t) return t;
|
|
1507
|
-
const s = { ...
|
|
1508
|
-
return r === "href" || r === "src" ?
|
|
1581
|
+
const s = { ...Ht, ...e };
|
|
1582
|
+
return r === "href" || r === "src" ? _t(t, s) : t;
|
|
1509
1583
|
}
|
|
1510
|
-
const
|
|
1584
|
+
const Ot = [
|
|
1511
1585
|
"role",
|
|
1512
1586
|
"aria-label",
|
|
1513
1587
|
"aria-labelledby",
|
|
@@ -1518,7 +1592,7 @@ const Dt = [
|
|
|
1518
1592
|
"aria-posinset",
|
|
1519
1593
|
"aria-setsize",
|
|
1520
1594
|
"aria-haspopup"
|
|
1521
|
-
],
|
|
1595
|
+
], qt = [
|
|
1522
1596
|
"aria-selected",
|
|
1523
1597
|
"aria-checked",
|
|
1524
1598
|
"aria-pressed",
|
|
@@ -1531,7 +1605,7 @@ const Dt = [
|
|
|
1531
1605
|
"aria-grabbed",
|
|
1532
1606
|
"aria-live",
|
|
1533
1607
|
"aria-atomic"
|
|
1534
|
-
],
|
|
1608
|
+
], Ut = [
|
|
1535
1609
|
"data-state",
|
|
1536
1610
|
"data-active",
|
|
1537
1611
|
"data-inactive",
|
|
@@ -1550,7 +1624,7 @@ const Dt = [
|
|
|
1550
1624
|
"data-hover",
|
|
1551
1625
|
"data-orientation",
|
|
1552
1626
|
"data-theme"
|
|
1553
|
-
],
|
|
1627
|
+
], zt = [
|
|
1554
1628
|
"data-radix-",
|
|
1555
1629
|
"data-headlessui-",
|
|
1556
1630
|
"data-reach-",
|
|
@@ -1558,7 +1632,7 @@ const Dt = [
|
|
|
1558
1632
|
"data-chakra-",
|
|
1559
1633
|
"data-mantine-",
|
|
1560
1634
|
"data-tw-"
|
|
1561
|
-
],
|
|
1635
|
+
], Ft = [
|
|
1562
1636
|
"data-testid",
|
|
1563
1637
|
"data-test-id",
|
|
1564
1638
|
"data-test",
|
|
@@ -1570,7 +1644,7 @@ const Dt = [
|
|
|
1570
1644
|
"data-entity-id",
|
|
1571
1645
|
"data-product-id",
|
|
1572
1646
|
"data-user-id"
|
|
1573
|
-
],
|
|
1647
|
+
], jt = [
|
|
1574
1648
|
// Google Analytics / GTM
|
|
1575
1649
|
"data-ga",
|
|
1576
1650
|
"data-gtm",
|
|
@@ -1606,7 +1680,7 @@ const Dt = [
|
|
|
1606
1680
|
"data-conversion",
|
|
1607
1681
|
"data-segment",
|
|
1608
1682
|
"data-analytics"
|
|
1609
|
-
],
|
|
1683
|
+
], Wt = [
|
|
1610
1684
|
"data-category",
|
|
1611
1685
|
// Google Analytics category
|
|
1612
1686
|
"data-action",
|
|
@@ -1615,7 +1689,7 @@ const Dt = [
|
|
|
1615
1689
|
// Google Analytics label
|
|
1616
1690
|
"data-value"
|
|
1617
1691
|
// Google Analytics value
|
|
1618
|
-
],
|
|
1692
|
+
], Bt = [
|
|
1619
1693
|
"id",
|
|
1620
1694
|
"name",
|
|
1621
1695
|
"type",
|
|
@@ -1624,7 +1698,7 @@ const Dt = [
|
|
|
1624
1698
|
"for",
|
|
1625
1699
|
"alt",
|
|
1626
1700
|
"href"
|
|
1627
|
-
],
|
|
1701
|
+
], Gt = [
|
|
1628
1702
|
"disabled",
|
|
1629
1703
|
"checked",
|
|
1630
1704
|
"selected",
|
|
@@ -1632,17 +1706,17 @@ const Dt = [
|
|
|
1632
1706
|
"readonly",
|
|
1633
1707
|
"required",
|
|
1634
1708
|
"value"
|
|
1635
|
-
],
|
|
1709
|
+
], Vt = [
|
|
1636
1710
|
/^radix-/,
|
|
1637
1711
|
/^headlessui-/,
|
|
1638
1712
|
/^mui-/,
|
|
1639
1713
|
/:\w+:/
|
|
1640
1714
|
// matches :ru:, :r1:, etc.
|
|
1641
1715
|
];
|
|
1642
|
-
function
|
|
1643
|
-
return
|
|
1716
|
+
function Qt(r, t) {
|
|
1717
|
+
return Ot.includes(r) ? true : qt.includes(r) || Ut.includes(r) || zt.some((e) => r.startsWith(e)) ? false : Ft.includes(r) ? true : jt.some((e) => r.startsWith(e)) || Wt.includes(r) ? false : r.startsWith("data-") && r.endsWith("-id") ? true : r === "id" ? !Vt.some((e) => e.test(t)) : Bt.includes(r) ? true : Gt.includes(r) ? false : !!r.startsWith("data-");
|
|
1644
1718
|
}
|
|
1645
|
-
class
|
|
1719
|
+
class nt {
|
|
1646
1720
|
constructor(t, e) {
|
|
1647
1721
|
this.includeUtilityClasses = t.includeUtilityClasses ?? false, this.cache = e;
|
|
1648
1722
|
}
|
|
@@ -1658,12 +1732,12 @@ class st {
|
|
|
1658
1732
|
return i;
|
|
1659
1733
|
}
|
|
1660
1734
|
const e = {}, s = t.id;
|
|
1661
|
-
if (s && !
|
|
1735
|
+
if (s && !L(s) && (e.id = s), t.classList.length > 0) {
|
|
1662
1736
|
const i = Array.from(t.classList);
|
|
1663
1737
|
if (this.includeUtilityClasses)
|
|
1664
1738
|
e.classes = i;
|
|
1665
1739
|
else {
|
|
1666
|
-
const { semantic: o } =
|
|
1740
|
+
const { semantic: o } = It(i);
|
|
1667
1741
|
o.length > 0 && (e.classes = o);
|
|
1668
1742
|
}
|
|
1669
1743
|
}
|
|
@@ -1692,7 +1766,7 @@ class st {
|
|
|
1692
1766
|
* @returns True if should be ignored
|
|
1693
1767
|
*/
|
|
1694
1768
|
shouldIgnoreAttribute(t) {
|
|
1695
|
-
return !!(
|
|
1769
|
+
return !!(Y.has(t) || t.startsWith("on") || t.startsWith("ng-") || t.startsWith("_ng") || t.startsWith("data-reactid") || t.startsWith("data-react") || t.startsWith("data-v-"));
|
|
1696
1770
|
}
|
|
1697
1771
|
/**
|
|
1698
1772
|
* Gets attribute priority
|
|
@@ -1727,7 +1801,7 @@ class st {
|
|
|
1727
1801
|
const e = {};
|
|
1728
1802
|
for (const s of Array.from(t.attributes)) {
|
|
1729
1803
|
const n = s.name;
|
|
1730
|
-
if (this.shouldIgnoreAttribute(n) || !
|
|
1804
|
+
if (this.shouldIgnoreAttribute(n) || !Qt(n, s.value) || Z.has(n) && K(s.value) || this.getAttributePriority(n) === 0) continue;
|
|
1731
1805
|
const i = n === "href" || n === "src" ? D(n, s.value) : s.value;
|
|
1732
1806
|
!i || i.trim() === "" || this.isDynamicValue(i) || (e[n] = i);
|
|
1733
1807
|
}
|
|
@@ -1739,7 +1813,7 @@ class st {
|
|
|
1739
1813
|
extractText(t) {
|
|
1740
1814
|
const e = this.getDirectTextContent(t);
|
|
1741
1815
|
if (!e) return null;
|
|
1742
|
-
const s =
|
|
1816
|
+
const s = j(e);
|
|
1743
1817
|
if (!s) return null;
|
|
1744
1818
|
const n = 100, a = e.length > n ? e.slice(0, n) + "..." : e, i = s.length > n ? s.slice(0, n) + "..." : s;
|
|
1745
1819
|
return {
|
|
@@ -1787,7 +1861,7 @@ class st {
|
|
|
1787
1861
|
].includes(e);
|
|
1788
1862
|
}
|
|
1789
1863
|
}
|
|
1790
|
-
class
|
|
1864
|
+
class Yt {
|
|
1791
1865
|
/**
|
|
1792
1866
|
* Generates fingerprint for SVG element
|
|
1793
1867
|
* @param element - SVG element to fingerprint
|
|
@@ -1898,11 +1972,11 @@ class Ft {
|
|
|
1898
1972
|
return Math.abs(e).toString(16).padStart(8, "0");
|
|
1899
1973
|
}
|
|
1900
1974
|
}
|
|
1901
|
-
function
|
|
1902
|
-
const e = r.anchor.score, s = r.path.length > 0 ? r.path.reduce((o, c) => o + c.score, 0) / r.path.length : 0.5, n = r.target.score, a = e *
|
|
1975
|
+
function Zt(r, t = 0) {
|
|
1976
|
+
const e = r.anchor.score, s = r.path.length > 0 ? r.path.reduce((o, c) => o + c.score, 0) / r.path.length : 0.5, n = r.target.score, a = e * z.ANCHOR + s * z.PATH + n * z.TARGET + t * z.UNIQUENESS, i = r.anchor.degraded ? 0.2 : 0;
|
|
1903
1977
|
return Math.max(0, Math.min(1, a - i));
|
|
1904
1978
|
}
|
|
1905
|
-
class
|
|
1979
|
+
class Kt {
|
|
1906
1980
|
constructor(t) {
|
|
1907
1981
|
this.cache = /* @__PURE__ */ new Map(), this.maxSize = t;
|
|
1908
1982
|
}
|
|
@@ -1933,9 +2007,9 @@ class Wt {
|
|
|
1933
2007
|
return this.cache.size;
|
|
1934
2008
|
}
|
|
1935
2009
|
}
|
|
1936
|
-
class
|
|
2010
|
+
class Xt {
|
|
1937
2011
|
constructor(t = {}) {
|
|
1938
|
-
this.eidCache = /* @__PURE__ */ new WeakMap(), this.selectorResultCache = new
|
|
2012
|
+
this.eidCache = /* @__PURE__ */ new WeakMap(), this.selectorResultCache = new Kt(
|
|
1939
2013
|
t.maxSelectorCacheSize ?? 1e3
|
|
1940
2014
|
), this.anchorCache = /* @__PURE__ */ new WeakMap(), this.semanticsCache = /* @__PURE__ */ new WeakMap(), this.stats = {
|
|
1941
2015
|
eidHits: 0,
|
|
@@ -2084,12 +2158,12 @@ class Bt {
|
|
|
2084
2158
|
return s > 0 ? t / s : 0;
|
|
2085
2159
|
}
|
|
2086
2160
|
}
|
|
2087
|
-
function
|
|
2088
|
-
return new
|
|
2161
|
+
function Jt(r) {
|
|
2162
|
+
return new Xt(r);
|
|
2089
2163
|
}
|
|
2090
|
-
let
|
|
2091
|
-
function
|
|
2092
|
-
return
|
|
2164
|
+
let F = null;
|
|
2165
|
+
function X() {
|
|
2166
|
+
return F || (F = Jt()), F;
|
|
2093
2167
|
}
|
|
2094
2168
|
function k(r) {
|
|
2095
2169
|
if (r.ownerDocument)
|
|
@@ -2107,7 +2181,7 @@ function k(r) {
|
|
|
2107
2181
|
3. You are working with a document node instead of an element`
|
|
2108
2182
|
);
|
|
2109
2183
|
}
|
|
2110
|
-
function
|
|
2184
|
+
function te(r, t) {
|
|
2111
2185
|
if (!t)
|
|
2112
2186
|
return;
|
|
2113
2187
|
const e = k(r), s = t instanceof Document ? t : k(t);
|
|
@@ -2122,64 +2196,65 @@ Common causes:
|
|
|
2122
2196
|
Solution: Ensure element and root parameter are from the same document context.`
|
|
2123
2197
|
);
|
|
2124
2198
|
}
|
|
2125
|
-
function
|
|
2199
|
+
function J(r, t = {}) {
|
|
2126
2200
|
var _a;
|
|
2127
2201
|
if (!r || !r.ownerDocument || !r.isConnected)
|
|
2128
2202
|
return null;
|
|
2129
|
-
const e = { ...
|
|
2203
|
+
const e = { ...At, ...t };
|
|
2130
2204
|
if (e.root)
|
|
2131
2205
|
try {
|
|
2132
|
-
|
|
2206
|
+
te(r, e.root);
|
|
2133
2207
|
} catch (x2) {
|
|
2134
2208
|
return console.error("Cross-document generation detected:", x2), null;
|
|
2135
2209
|
}
|
|
2136
|
-
const s = e.cache ??
|
|
2210
|
+
const s = e.cache ?? X(), n = s.getEID(r);
|
|
2137
2211
|
if (n !== void 0)
|
|
2138
2212
|
return n;
|
|
2139
|
-
|
|
2140
|
-
|
|
2213
|
+
const a = r.tagName.toLowerCase();
|
|
2214
|
+
if (a === "html") {
|
|
2215
|
+
const x2 = new nt(e, s), y = re(r, e, x2);
|
|
2141
2216
|
return s.setEID(r, y), y;
|
|
2142
2217
|
}
|
|
2143
|
-
const i = new
|
|
2144
|
-
if (!
|
|
2218
|
+
const i = new Ct(e, s), o = new Pt(e, s), c = new nt(e, s), l = new Yt(), f = i.findAnchor(r);
|
|
2219
|
+
if (!f && !e.fallbackToBody)
|
|
2145
2220
|
return null;
|
|
2146
|
-
const
|
|
2147
|
-
if (!
|
|
2148
|
-
const
|
|
2149
|
-
let
|
|
2150
|
-
if (
|
|
2151
|
-
const y = Array.from(
|
|
2152
|
-
y !== -1 && (
|
|
2153
|
-
}
|
|
2154
|
-
const
|
|
2155
|
-
tag:
|
|
2156
|
-
semantics:
|
|
2157
|
-
score: (
|
|
2158
|
-
degraded:
|
|
2159
|
-
nthChild:
|
|
2160
|
-
}, S = o.buildPath(
|
|
2161
|
-
e.enableSvgFingerprint &&
|
|
2221
|
+
const h = (f == null ? void 0 : f.element) ?? ((_a = r.ownerDocument) == null ? void 0 : _a.body) ?? null;
|
|
2222
|
+
if (!h) return null;
|
|
2223
|
+
const d = !f || f.tier === "C", u = h.tagName.toLowerCase(), g = c.extract(h), m = h.parentElement;
|
|
2224
|
+
let p;
|
|
2225
|
+
if (m && u !== "body" && u !== "html" && _(u, g, h)) {
|
|
2226
|
+
const y = Array.from(m.children).indexOf(h);
|
|
2227
|
+
y !== -1 && (p = y + 1);
|
|
2228
|
+
}
|
|
2229
|
+
const b = {
|
|
2230
|
+
tag: h.tagName.toLowerCase(),
|
|
2231
|
+
semantics: g,
|
|
2232
|
+
score: (f == null ? void 0 : f.score) ?? I.DEGRADED_SCORE,
|
|
2233
|
+
degraded: d,
|
|
2234
|
+
nthChild: p
|
|
2235
|
+
}, S = o.buildPath(h, r, c), T = c.extract(r);
|
|
2236
|
+
e.enableSvgFingerprint && ee(r) && (T.svg = l.fingerprint(r));
|
|
2162
2237
|
const C = r.parentElement;
|
|
2163
2238
|
let A;
|
|
2164
|
-
if (C) {
|
|
2239
|
+
if (C && _(a, T, r)) {
|
|
2165
2240
|
const y = Array.from(C.children).indexOf(r);
|
|
2166
2241
|
y !== -1 && (A = y + 1);
|
|
2167
2242
|
}
|
|
2168
2243
|
const v = {
|
|
2169
2244
|
tag: r.tagName.toLowerCase(),
|
|
2170
|
-
semantics:
|
|
2245
|
+
semantics: T,
|
|
2171
2246
|
score: c.scoreElement(r),
|
|
2172
2247
|
nthChild: A
|
|
2173
|
-
},
|
|
2248
|
+
}, P = [], $ = {
|
|
2174
2249
|
onMultiple: "best-score",
|
|
2175
2250
|
onMissing: "anchor-only",
|
|
2176
2251
|
maxDepth: 3
|
|
2177
|
-
},
|
|
2252
|
+
}, E = b.degraded || S.degraded, R = se(b.degraded, S), N = {
|
|
2178
2253
|
version: "1.0",
|
|
2179
2254
|
anchor: b,
|
|
2180
2255
|
path: S.path,
|
|
2181
2256
|
target: v,
|
|
2182
|
-
constraints:
|
|
2257
|
+
constraints: P,
|
|
2183
2258
|
fallback: $,
|
|
2184
2259
|
meta: {
|
|
2185
2260
|
confidence: 0,
|
|
@@ -2187,16 +2262,16 @@ function X(r, t = {}) {
|
|
|
2187
2262
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2188
2263
|
generator: "dom-eid@1.0",
|
|
2189
2264
|
source: e.source,
|
|
2190
|
-
degraded:
|
|
2265
|
+
degraded: E,
|
|
2191
2266
|
degradationReason: R
|
|
2192
2267
|
}
|
|
2193
2268
|
};
|
|
2194
|
-
return N.meta.confidence =
|
|
2269
|
+
return N.meta.confidence = Zt(N), N.meta.confidence < e.confidenceThreshold ? null : (s.setEID(r, N), N);
|
|
2195
2270
|
}
|
|
2196
|
-
function
|
|
2271
|
+
function ee(r) {
|
|
2197
2272
|
return r.namespaceURI === "http://www.w3.org/2000/svg" || r.tagName.toLowerCase() === "svg" || r instanceof SVGElement;
|
|
2198
2273
|
}
|
|
2199
|
-
function
|
|
2274
|
+
function se(r, t) {
|
|
2200
2275
|
if (r && t.degraded)
|
|
2201
2276
|
return "anchor-and-path-degraded";
|
|
2202
2277
|
if (r)
|
|
@@ -2204,7 +2279,7 @@ function Yt(r, t) {
|
|
|
2204
2279
|
if (t.degraded)
|
|
2205
2280
|
return t.degradationReason;
|
|
2206
2281
|
}
|
|
2207
|
-
function
|
|
2282
|
+
function re(r, t, e, s) {
|
|
2208
2283
|
const a = {
|
|
2209
2284
|
tag: "html",
|
|
2210
2285
|
semantics: e.extract(r),
|
|
@@ -2233,91 +2308,119 @@ function Zt(r, t, e, s) {
|
|
|
2233
2308
|
}
|
|
2234
2309
|
};
|
|
2235
2310
|
}
|
|
2236
|
-
const
|
|
2311
|
+
const ht = {
|
|
2312
|
+
id: "i",
|
|
2313
|
+
"data-testid": "tid",
|
|
2314
|
+
"data-qa": "qa",
|
|
2315
|
+
"data-cy": "cy",
|
|
2316
|
+
"data-test": "dt",
|
|
2317
|
+
"aria-label": "al",
|
|
2318
|
+
"aria-labelledby": "alb",
|
|
2319
|
+
"aria-describedby": "adb",
|
|
2320
|
+
name: "n",
|
|
2321
|
+
href: "h",
|
|
2322
|
+
src: "s",
|
|
2323
|
+
type: "t",
|
|
2324
|
+
role: "r",
|
|
2325
|
+
alt: "at",
|
|
2326
|
+
title: "tt",
|
|
2327
|
+
for: "f",
|
|
2328
|
+
placeholder: "ph",
|
|
2329
|
+
text: "x"
|
|
2330
|
+
}, G = Object.fromEntries(
|
|
2331
|
+
Object.entries(ht).map(([r, t]) => [t, r])
|
|
2332
|
+
), ut = {
|
|
2237
2333
|
maxClasses: 2,
|
|
2238
2334
|
maxAttributes: 5,
|
|
2239
2335
|
includeText: true,
|
|
2240
2336
|
maxTextLength: 50,
|
|
2241
2337
|
simplifyTarget: true,
|
|
2242
|
-
includeConstraints: true
|
|
2338
|
+
includeConstraints: true,
|
|
2339
|
+
format: "compact"
|
|
2243
2340
|
};
|
|
2244
|
-
function
|
|
2341
|
+
function ct(r) {
|
|
2245
2342
|
return r === "id" ? 101 : w[r] !== void 0 ? w[r] : r.startsWith("data-") ? w["data-*"] : r.startsWith("aria-") ? w["aria-*"] : 0;
|
|
2246
2343
|
}
|
|
2247
|
-
function
|
|
2344
|
+
function de(r) {
|
|
2248
2345
|
return ["id", "data-testid", "data-qa", "data-cy", "href", "text", "role"].includes(r);
|
|
2249
2346
|
}
|
|
2250
|
-
function
|
|
2347
|
+
function fe(r) {
|
|
2251
2348
|
return !!(/@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/.test(r) || /(\+?\d{1,3}[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}/.test(r) || /\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}/.test(r));
|
|
2252
2349
|
}
|
|
2253
|
-
function
|
|
2254
|
-
const e = { ...
|
|
2255
|
-
return `${
|
|
2256
|
-
}
|
|
2257
|
-
function
|
|
2258
|
-
const { tag:
|
|
2259
|
-
let
|
|
2260
|
-
const
|
|
2261
|
-
|
|
2262
|
-
const
|
|
2263
|
-
const
|
|
2264
|
-
return { name:
|
|
2265
|
-
}).filter((
|
|
2266
|
-
|
|
2267
|
-
const
|
|
2268
|
-
|
|
2269
|
-
for (const { name:
|
|
2270
|
-
i
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
}
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
);
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2350
|
+
function ge(r, t) {
|
|
2351
|
+
const e = { ...ut, ...t }, s = e.format === "compact", n = s ? "v1" : `v${r.version}`, a = s ? ":" : ": ", i = s ? "::" : " :: ", o = s ? ">" : " > ", c = e.includeText && r.target.semantics.text ? r.target.semantics.text.normalized : void 0, l = W(r.anchor, false, e), f = r.path.length > 0 ? r.path.map((u) => W(u, false, e, c)).join(o) + o : "", h = W(r.target, true, e), d = e.includeConstraints ? pe(r, e) : "";
|
|
2352
|
+
return `${n}${a}${l}${i}${f}${h}${d}`;
|
|
2353
|
+
}
|
|
2354
|
+
function W(r, t = false, e = ut, s) {
|
|
2355
|
+
const { tag: n, semantics: a } = r, i = e.format === "compact";
|
|
2356
|
+
let o = n;
|
|
2357
|
+
const c = [], l = { ...a.attributes };
|
|
2358
|
+
a.id && (l.id = a.id), a.role && !l.role && (l.role = a.role);
|
|
2359
|
+
const f = Object.entries(l).map(([u, g]) => {
|
|
2360
|
+
const m = ct(u), p = u === "href" || u === "src" ? D(u, g) : g;
|
|
2361
|
+
return { name: u, value: p, priority: m };
|
|
2362
|
+
}).filter((u) => u.name !== "id" && u.name !== "class" && Y.has(u.name) || Z.has(u.name) && K(u.value) ? false : u.priority > 0 || u.name === "role" || u.name === "id");
|
|
2363
|
+
f.sort((u, g) => g.priority - u.priority);
|
|
2364
|
+
const h = f.slice(0, e.maxAttributes);
|
|
2365
|
+
h.sort((u, g) => u.name.localeCompare(g.name));
|
|
2366
|
+
for (const { name: u, value: g } of h) {
|
|
2367
|
+
const m = i ? ht[u] ?? u : u;
|
|
2368
|
+
c.push(`${m}="${V(g)}"`);
|
|
2369
|
+
}
|
|
2370
|
+
if (e.includeText && a.text && !fe(a.text.normalized)) {
|
|
2371
|
+
const u = a.text.normalized;
|
|
2372
|
+
if (u.length > 0 && u.length <= e.maxTextLength && !(!t && s !== void 0 && u === s)) {
|
|
2373
|
+
const m = i ? "x" : "text";
|
|
2374
|
+
c.push(`${m}="${V(u)}"`);
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
let d = c;
|
|
2378
|
+
if (c.length > 0 && t && e.simplifyTarget && a.id && (d = c.filter((u) => {
|
|
2379
|
+
const g = u.split("=")[0], m = G[g] ?? g;
|
|
2380
|
+
return ct(m) >= 60 || m === "text" || m === "id" || m === "role";
|
|
2381
|
+
})), a.classes && a.classes.length > 0) {
|
|
2382
|
+
const u = M(a.classes), g = !!a.id || c.some((p) => {
|
|
2383
|
+
const b = p.split("=")[0], S = G[b] ?? b;
|
|
2384
|
+
return S === "href" || S === "data-testid" || S === "text" || S === "role";
|
|
2385
|
+
});
|
|
2386
|
+
if (!(t && e.simplifyTarget && g) && u.length > 0) {
|
|
2387
|
+
const p = u.sort().slice(0, e.maxClasses);
|
|
2388
|
+
o += p.map((b) => `.${b}`).join("");
|
|
2286
2389
|
}
|
|
2287
2390
|
}
|
|
2288
|
-
if (d.length > 0 && (
|
|
2289
|
-
const
|
|
2290
|
-
t && e.simplifyTarget &&
|
|
2391
|
+
if (d.length > 0 && (o += `[${d.join(",")}]`), "nthChild" in r && r.nthChild) {
|
|
2392
|
+
const u = !!a.id || a.attributes && Object.keys(a.attributes).some(de);
|
|
2393
|
+
t && e.simplifyTarget && u || (o += `#${r.nthChild}`);
|
|
2291
2394
|
}
|
|
2292
|
-
return
|
|
2395
|
+
return o;
|
|
2293
2396
|
}
|
|
2294
|
-
function
|
|
2397
|
+
function pe(r, t) {
|
|
2295
2398
|
if (!r.constraints || r.constraints.length === 0)
|
|
2296
2399
|
return "";
|
|
2297
|
-
const
|
|
2298
|
-
for (const
|
|
2299
|
-
switch (
|
|
2400
|
+
const e = [];
|
|
2401
|
+
for (const n of r.constraints)
|
|
2402
|
+
switch (n.type) {
|
|
2300
2403
|
case "uniqueness":
|
|
2301
|
-
|
|
2404
|
+
e.push("unique=true");
|
|
2302
2405
|
break;
|
|
2303
2406
|
case "position":
|
|
2304
|
-
|
|
2407
|
+
n.params && n.params.strategy && e.push(`pos=${n.params.strategy}`);
|
|
2305
2408
|
break;
|
|
2306
2409
|
case "text-proximity":
|
|
2307
|
-
if (
|
|
2308
|
-
const
|
|
2309
|
-
|
|
2410
|
+
if (n.params && n.params.reference) {
|
|
2411
|
+
const a = V(String(n.params.reference));
|
|
2412
|
+
e.push(`text="${a}"`);
|
|
2310
2413
|
}
|
|
2311
2414
|
break;
|
|
2312
2415
|
}
|
|
2313
|
-
return
|
|
2416
|
+
return e.length === 0 ? "" : `${t.format === "verbose" ? " " : ""}{${e.join(",")}}`;
|
|
2314
2417
|
}
|
|
2315
|
-
function
|
|
2418
|
+
function V(r) {
|
|
2316
2419
|
return r.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/>/g, "\\>").replace(/:/g, "\\:");
|
|
2317
2420
|
}
|
|
2318
|
-
function
|
|
2319
|
-
const s =
|
|
2320
|
-
return s ?
|
|
2421
|
+
function Ne(r, t, e) {
|
|
2422
|
+
const s = J(r, t);
|
|
2423
|
+
return s ? ge(s, e) : null;
|
|
2321
2424
|
}
|
|
2322
2425
|
let _id = 1;
|
|
2323
2426
|
const tagNameRegex = new RegExp("[^a-z0-9-_:]");
|
|
@@ -2990,7 +3093,7 @@ function serializeNodeWithId(n, options) {
|
|
|
2990
3093
|
enableSvgFingerprint: selectorOptions.enableSvgFingerprint,
|
|
2991
3094
|
fallbackToBody: selectorOptions.fallbackToBody
|
|
2992
3095
|
};
|
|
2993
|
-
const selector =
|
|
3096
|
+
const selector = Ne(n, seqlGeneratorOptions);
|
|
2994
3097
|
if (selector) {
|
|
2995
3098
|
serializedNode.selector = selector;
|
|
2996
3099
|
}
|
|
@@ -3002,7 +3105,11 @@ function serializeNodeWithId(n, options) {
|
|
|
3002
3105
|
serializedNode.isVisible = isTextVisible(n);
|
|
3003
3106
|
}
|
|
3004
3107
|
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
3005
|
-
|
|
3108
|
+
const vis = isElementVisible(n);
|
|
3109
|
+
serializedNode.isVisible = vis.isVisible;
|
|
3110
|
+
serializedNode.isCSSVisible = vis.isCSSVisible;
|
|
3111
|
+
serializedNode.isViewportVisible = vis.isViewportVisible;
|
|
3112
|
+
serializedNode.hasSize = vis.hasSize;
|
|
3006
3113
|
serializedNode.isInteractive = isElementInteractive(n);
|
|
3007
3114
|
}
|
|
3008
3115
|
}
|