@whenessel/seql-js 1.2.0 → 1.4.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/dist/seql-js.d.ts +9 -1
- package/dist/seql-js.js +148 -103
- package/dist/seql-js.js.map +1 -1
- package/dist/seql-js.umd.cjs +1 -1
- package/dist/seql-js.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/seql-js.d.ts
CHANGED
|
@@ -443,6 +443,14 @@ export declare class CssGenerator {
|
|
|
443
443
|
/**
|
|
444
444
|
* Default generator options
|
|
445
445
|
* Note: cache is optional and not included in defaults
|
|
446
|
+
*
|
|
447
|
+
* @remarks
|
|
448
|
+
* confidenceThreshold set to 0.0 to ensure generateEID always returns an EID
|
|
449
|
+
* for valid DOM elements. Low confidence is indicated via meta.confidence field,
|
|
450
|
+
* allowing callers to decide whether to use the EID rather than preventing
|
|
451
|
+
* generation entirely. This ensures elements with minimal semantics (e.g., plain
|
|
452
|
+
* div with utility classes) can still be identified using positional information
|
|
453
|
+
* (nthChild).
|
|
446
454
|
*/
|
|
447
455
|
export declare const DEFAULT_GENERATOR_OPTIONS: Omit<Required<GeneratorOptions>, 'cache'> & Pick<GeneratorOptions, 'cache'>;
|
|
448
456
|
|
|
@@ -726,7 +734,7 @@ export declare interface GeneratorOptions {
|
|
|
726
734
|
maxPathDepth?: number;
|
|
727
735
|
/** Enable SVG fingerprinting (default: true) */
|
|
728
736
|
enableSvgFingerprint?: boolean;
|
|
729
|
-
/** Minimum confidence to return EID (default: 0.
|
|
737
|
+
/** Minimum confidence to return EID (default: 0.0) */
|
|
730
738
|
confidenceThreshold?: number;
|
|
731
739
|
/** Fallback to body if no anchor found (default: true) */
|
|
732
740
|
fallbackToBody?: boolean;
|
package/dist/seql-js.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ne = "1.0", ae = 10, q = {
|
|
2
2
|
ANCHOR: 0.4,
|
|
3
3
|
PATH: 0.3,
|
|
4
4
|
TARGET: 0.2,
|
|
@@ -7,7 +7,7 @@ const se = "1.0", re = 10, _ = {
|
|
|
7
7
|
SEMANTIC_TAG: 0.5,
|
|
8
8
|
ROLE: 0.3,
|
|
9
9
|
ARIA_LABEL: 0.1,
|
|
10
|
-
STABLE_ID: 0.
|
|
10
|
+
STABLE_ID: 0.25,
|
|
11
11
|
TEST_MARKER: 0.05,
|
|
12
12
|
DEPTH_PENALTY_THRESHOLD: 5,
|
|
13
13
|
DEPTH_PENALTY_FACTOR: 0.05,
|
|
@@ -122,7 +122,7 @@ const se = "1.0", re = 10, _ = {
|
|
|
122
122
|
"defs",
|
|
123
123
|
"clipPath",
|
|
124
124
|
"mask"
|
|
125
|
-
],
|
|
125
|
+
], ie = [
|
|
126
126
|
"aria-label",
|
|
127
127
|
"aria-labelledby",
|
|
128
128
|
"aria-describedby",
|
|
@@ -177,7 +177,7 @@ const se = "1.0", re = 10, _ = {
|
|
|
177
177
|
]), dt = {
|
|
178
178
|
maxPathDepth: 10,
|
|
179
179
|
enableSvgFingerprint: !0,
|
|
180
|
-
confidenceThreshold: 0
|
|
180
|
+
confidenceThreshold: 0,
|
|
181
181
|
fallbackToBody: !0,
|
|
182
182
|
includeUtilityClasses: !1,
|
|
183
183
|
source: "dom-dsl"
|
|
@@ -502,20 +502,20 @@ const mt = [
|
|
|
502
502
|
function L(n) {
|
|
503
503
|
return mt.some((t) => t.test(n));
|
|
504
504
|
}
|
|
505
|
-
function
|
|
505
|
+
function _(n) {
|
|
506
506
|
return n.length <= 2 || /^\d/.test(n) ? !0 : pt.some((t) => t.test(n));
|
|
507
507
|
}
|
|
508
508
|
function St(n) {
|
|
509
|
-
return L(n) ||
|
|
509
|
+
return L(n) || _(n) ? !1 : bt.some((t) => t.test(n));
|
|
510
510
|
}
|
|
511
511
|
function yt(n) {
|
|
512
|
-
return !L(n) && !
|
|
512
|
+
return !L(n) && !_(n);
|
|
513
513
|
}
|
|
514
514
|
function M(n) {
|
|
515
515
|
return n.filter((t) => yt(t));
|
|
516
516
|
}
|
|
517
517
|
function At(n) {
|
|
518
|
-
if (L(n) ||
|
|
518
|
+
if (L(n) || _(n))
|
|
519
519
|
return 0;
|
|
520
520
|
let t = 0.5;
|
|
521
521
|
return St(n) && (t = 0.8), n.length < 3 ? t *= 0.3 : n.length < 5 && (t *= 0.6), /\d/.test(n) && (t *= 0.7), Math.min(t, 1);
|
|
@@ -523,13 +523,13 @@ function At(n) {
|
|
|
523
523
|
function xt(n) {
|
|
524
524
|
const t = [], e = [];
|
|
525
525
|
for (const s of n)
|
|
526
|
-
|
|
526
|
+
_(s) || L(s) ? e.push(s) : t.push(s);
|
|
527
527
|
return { semantic: t, utility: e };
|
|
528
528
|
}
|
|
529
529
|
function J(n) {
|
|
530
|
-
return
|
|
530
|
+
return _(n) || L(n);
|
|
531
531
|
}
|
|
532
|
-
function
|
|
532
|
+
function oe(n) {
|
|
533
533
|
return At(n);
|
|
534
534
|
}
|
|
535
535
|
const tt = (n) => n.replace(/([#:.[\]@])/g, "\\$1");
|
|
@@ -782,7 +782,7 @@ function wt(n, t) {
|
|
|
782
782
|
let o = a;
|
|
783
783
|
return e && t.preserveQueryForAbsolute && i && (o += `?${i}`), r && (t.removeDynamicHashes && Et(r) || (o += `#${r}`)), o;
|
|
784
784
|
}
|
|
785
|
-
function
|
|
785
|
+
function k(n, t, e = {}) {
|
|
786
786
|
if (!t) return t;
|
|
787
787
|
const s = { ...Tt, ...e };
|
|
788
788
|
return n === "href" || n === "src" ? wt(t, s) : t;
|
|
@@ -851,6 +851,51 @@ const vt = [
|
|
|
851
851
|
"data-product-id",
|
|
852
852
|
"data-user-id"
|
|
853
853
|
], Mt = [
|
|
854
|
+
// Google Analytics / GTM
|
|
855
|
+
"data-ga",
|
|
856
|
+
"data-gtm",
|
|
857
|
+
"data-google",
|
|
858
|
+
"data-layer",
|
|
859
|
+
"data-event",
|
|
860
|
+
// Yandex Metrica
|
|
861
|
+
"data-yandex",
|
|
862
|
+
"data-ym",
|
|
863
|
+
"data-metrika",
|
|
864
|
+
// A/B Testing
|
|
865
|
+
"data-optimizely",
|
|
866
|
+
"data-vwo",
|
|
867
|
+
"data-optimize",
|
|
868
|
+
// Session Recording
|
|
869
|
+
"data-hj",
|
|
870
|
+
"data-hotjar",
|
|
871
|
+
"data-fs",
|
|
872
|
+
"data-mouseflow",
|
|
873
|
+
"data-mf",
|
|
874
|
+
"data-smartlook",
|
|
875
|
+
"data-sl",
|
|
876
|
+
// Social / Ad Pixels
|
|
877
|
+
"data-fb",
|
|
878
|
+
"data-facebook",
|
|
879
|
+
"data-tt",
|
|
880
|
+
"data-li",
|
|
881
|
+
// Generic Tracking
|
|
882
|
+
"data-track",
|
|
883
|
+
"data-tracking",
|
|
884
|
+
"data-click",
|
|
885
|
+
"data-impression",
|
|
886
|
+
"data-conversion",
|
|
887
|
+
"data-segment",
|
|
888
|
+
"data-analytics"
|
|
889
|
+
], Dt = [
|
|
890
|
+
"data-category",
|
|
891
|
+
// Google Analytics category
|
|
892
|
+
"data-action",
|
|
893
|
+
// Google Analytics action
|
|
894
|
+
"data-label",
|
|
895
|
+
// Google Analytics label
|
|
896
|
+
"data-value"
|
|
897
|
+
// Google Analytics value
|
|
898
|
+
], Ht = [
|
|
854
899
|
"id",
|
|
855
900
|
"name",
|
|
856
901
|
"type",
|
|
@@ -859,7 +904,7 @@ const vt = [
|
|
|
859
904
|
"for",
|
|
860
905
|
"alt",
|
|
861
906
|
"href"
|
|
862
|
-
],
|
|
907
|
+
], Pt = [
|
|
863
908
|
"disabled",
|
|
864
909
|
"checked",
|
|
865
910
|
"selected",
|
|
@@ -867,15 +912,15 @@ const vt = [
|
|
|
867
912
|
"readonly",
|
|
868
913
|
"required",
|
|
869
914
|
"value"
|
|
870
|
-
],
|
|
915
|
+
], kt = [
|
|
871
916
|
/^radix-/,
|
|
872
917
|
/^headlessui-/,
|
|
873
918
|
/^mui-/,
|
|
874
919
|
/:\w+:/
|
|
875
920
|
// matches :ru:, :r1:, etc.
|
|
876
921
|
];
|
|
877
|
-
function
|
|
878
|
-
return vt.includes(n) ? !0 : $t.includes(n) || It.includes(n) || Nt.some((e) => n.startsWith(e)) ? !1 : Rt.includes(n) || n.startsWith("data-") && n.endsWith("-id") ? !0 : n === "id" ? !
|
|
922
|
+
function Lt(n, t) {
|
|
923
|
+
return vt.includes(n) ? !0 : $t.includes(n) || It.includes(n) || Nt.some((e) => n.startsWith(e)) ? !1 : Rt.includes(n) ? !0 : Mt.some((e) => n.startsWith(e)) || Dt.includes(n) ? !1 : n.startsWith("data-") && n.endsWith("-id") ? !0 : n === "id" ? !kt.some((e) => e.test(t)) : Ht.includes(n) ? !0 : Pt.includes(n) ? !1 : !!n.startsWith("data-");
|
|
879
924
|
}
|
|
880
925
|
class et {
|
|
881
926
|
constructor(t, e) {
|
|
@@ -962,8 +1007,8 @@ class et {
|
|
|
962
1007
|
const e = {};
|
|
963
1008
|
for (const s of Array.from(t.attributes)) {
|
|
964
1009
|
const r = s.name;
|
|
965
|
-
if (this.shouldIgnoreAttribute(r) || !
|
|
966
|
-
const i = r === "href" || r === "src" ?
|
|
1010
|
+
if (this.shouldIgnoreAttribute(r) || !Lt(r, s.value) || G.has(r) && V(s.value) || this.getAttributePriority(r) === 0) continue;
|
|
1011
|
+
const i = r === "href" || r === "src" ? k(r, s.value) : s.value;
|
|
967
1012
|
!i || i.trim() === "" || this.isDynamicValue(i) || (e[r] = i);
|
|
968
1013
|
}
|
|
969
1014
|
return e;
|
|
@@ -1022,7 +1067,7 @@ class et {
|
|
|
1022
1067
|
].includes(e);
|
|
1023
1068
|
}
|
|
1024
1069
|
}
|
|
1025
|
-
class
|
|
1070
|
+
class _t {
|
|
1026
1071
|
/**
|
|
1027
1072
|
* Generates fingerprint for SVG element
|
|
1028
1073
|
* @param element - SVG element to fingerprint
|
|
@@ -1133,15 +1178,15 @@ class qt {
|
|
|
1133
1178
|
return Math.abs(e).toString(16).padStart(8, "0");
|
|
1134
1179
|
}
|
|
1135
1180
|
}
|
|
1136
|
-
function
|
|
1137
|
-
const e = n.anchor.score, s = n.path.length > 0 ? n.path.reduce((o, c) => o + c.score, 0) / n.path.length : 0.5, r = n.target.score, a = e *
|
|
1181
|
+
function qt(n, t = 0) {
|
|
1182
|
+
const e = n.anchor.score, s = n.path.length > 0 ? n.path.reduce((o, c) => o + c.score, 0) / n.path.length : 0.5, r = n.target.score, a = e * q.ANCHOR + s * q.PATH + r * q.TARGET + t * q.UNIQUENESS, i = n.anchor.degraded ? 0.2 : 0;
|
|
1138
1183
|
return Math.max(0, Math.min(1, a - i));
|
|
1139
1184
|
}
|
|
1140
|
-
function
|
|
1185
|
+
function ce(n, t, e) {
|
|
1141
1186
|
let s = 0.5;
|
|
1142
1187
|
return t && (s += 0.2), e && (s += 0.15), s += Math.min(n * 0.05, 0.15), Math.min(s, 1);
|
|
1143
1188
|
}
|
|
1144
|
-
class
|
|
1189
|
+
class Ot {
|
|
1145
1190
|
constructor(t) {
|
|
1146
1191
|
this.cache = /* @__PURE__ */ new Map(), this.maxSize = t;
|
|
1147
1192
|
}
|
|
@@ -1172,9 +1217,9 @@ class kt {
|
|
|
1172
1217
|
return this.cache.size;
|
|
1173
1218
|
}
|
|
1174
1219
|
}
|
|
1175
|
-
class
|
|
1220
|
+
class Ut {
|
|
1176
1221
|
constructor(t = {}) {
|
|
1177
|
-
this.eidCache = /* @__PURE__ */ new WeakMap(), this.selectorResultCache = new
|
|
1222
|
+
this.eidCache = /* @__PURE__ */ new WeakMap(), this.selectorResultCache = new Ot(
|
|
1178
1223
|
t.maxSelectorCacheSize ?? 1e3
|
|
1179
1224
|
), this.anchorCache = /* @__PURE__ */ new WeakMap(), this.semanticsCache = /* @__PURE__ */ new WeakMap(), this.stats = {
|
|
1180
1225
|
eidHits: 0,
|
|
@@ -1323,27 +1368,27 @@ class _t {
|
|
|
1323
1368
|
return s > 0 ? t / s : 0;
|
|
1324
1369
|
}
|
|
1325
1370
|
}
|
|
1326
|
-
function
|
|
1327
|
-
return new
|
|
1371
|
+
function zt(n) {
|
|
1372
|
+
return new Ut(n);
|
|
1328
1373
|
}
|
|
1329
1374
|
let O = null;
|
|
1330
|
-
function
|
|
1331
|
-
return O || (O =
|
|
1375
|
+
function Y() {
|
|
1376
|
+
return O || (O = zt()), O;
|
|
1332
1377
|
}
|
|
1333
|
-
function
|
|
1378
|
+
function le() {
|
|
1334
1379
|
O = null;
|
|
1335
1380
|
}
|
|
1336
|
-
function
|
|
1381
|
+
function Z(n, t = {}) {
|
|
1337
1382
|
if (!n || !n.ownerDocument || !n.isConnected)
|
|
1338
1383
|
return null;
|
|
1339
|
-
const e = { ...dt, ...t }, s = e.cache ??
|
|
1384
|
+
const e = { ...dt, ...t }, s = e.cache ?? Y(), r = s.getEID(n);
|
|
1340
1385
|
if (r !== void 0)
|
|
1341
1386
|
return r;
|
|
1342
1387
|
if (n.tagName.toLowerCase() === "html") {
|
|
1343
|
-
const v = new et(e, s), A =
|
|
1388
|
+
const v = new et(e, s), A = Wt(n, e, v);
|
|
1344
1389
|
return s.setEID(n, A), A;
|
|
1345
1390
|
}
|
|
1346
|
-
const i = new gt(e, s), o = new Ct(e, s), c = new et(e, s), u = new
|
|
1391
|
+
const i = new gt(e, s), o = new Ct(e, s), c = new et(e, s), u = new _t(), d = i.findAnchor(n);
|
|
1347
1392
|
if (!d && !e.fallbackToBody)
|
|
1348
1393
|
return null;
|
|
1349
1394
|
const l = d?.element ?? n.ownerDocument?.body ?? null;
|
|
@@ -1361,7 +1406,7 @@ function Y(n, t = {}) {
|
|
|
1361
1406
|
degraded: h,
|
|
1362
1407
|
nthChild: m
|
|
1363
1408
|
}, y = o.buildPath(l, n, c), w = c.extract(n);
|
|
1364
|
-
e.enableSvgFingerprint &&
|
|
1409
|
+
e.enableSvgFingerprint && Ft(n) && (w.svg = u.fingerprint(n));
|
|
1365
1410
|
const x = n.parentElement;
|
|
1366
1411
|
let b;
|
|
1367
1412
|
if (x) {
|
|
@@ -1377,7 +1422,7 @@ function Y(n, t = {}) {
|
|
|
1377
1422
|
onMultiple: "best-score",
|
|
1378
1423
|
onMissing: "anchor-only",
|
|
1379
1424
|
maxDepth: 3
|
|
1380
|
-
}, T = S.degraded || y.degraded, R =
|
|
1425
|
+
}, T = S.degraded || y.degraded, R = jt(S.degraded, y), C = {
|
|
1381
1426
|
version: "1.0",
|
|
1382
1427
|
anchor: S,
|
|
1383
1428
|
path: y.path,
|
|
@@ -1394,12 +1439,12 @@ function Y(n, t = {}) {
|
|
|
1394
1439
|
degradationReason: R
|
|
1395
1440
|
}
|
|
1396
1441
|
};
|
|
1397
|
-
return C.meta.confidence =
|
|
1442
|
+
return C.meta.confidence = qt(C), C.meta.confidence < e.confidenceThreshold ? null : (s.setEID(n, C), C);
|
|
1398
1443
|
}
|
|
1399
|
-
function
|
|
1444
|
+
function Ft(n) {
|
|
1400
1445
|
return n.namespaceURI === "http://www.w3.org/2000/svg" || n.tagName.toLowerCase() === "svg" || n instanceof SVGElement;
|
|
1401
1446
|
}
|
|
1402
|
-
function
|
|
1447
|
+
function jt(n, t) {
|
|
1403
1448
|
if (n && t.degraded)
|
|
1404
1449
|
return "anchor-and-path-degraded";
|
|
1405
1450
|
if (n)
|
|
@@ -1407,7 +1452,7 @@ function zt(n, t) {
|
|
|
1407
1452
|
if (t.degraded)
|
|
1408
1453
|
return t.degradationReason;
|
|
1409
1454
|
}
|
|
1410
|
-
function
|
|
1455
|
+
function Wt(n, t, e, s) {
|
|
1411
1456
|
const a = {
|
|
1412
1457
|
tag: "html",
|
|
1413
1458
|
semantics: e.extract(n),
|
|
@@ -1652,7 +1697,7 @@ class rt {
|
|
|
1652
1697
|
}
|
|
1653
1698
|
return !!(s.classes && s.classes.length > 0 && s.classes.every((o) => a.classList.contains(o)) || s.attributes && Object.entries(s.attributes).every(([o, c]) => {
|
|
1654
1699
|
const u = a.getAttribute(o);
|
|
1655
|
-
return o === "href" || o === "src" ?
|
|
1700
|
+
return o === "href" || o === "src" ? k(o, u || "") === k(o, c) : u === c;
|
|
1656
1701
|
}) || s.text);
|
|
1657
1702
|
});
|
|
1658
1703
|
}
|
|
@@ -1930,7 +1975,7 @@ class rt {
|
|
|
1930
1975
|
if (r.attributes) {
|
|
1931
1976
|
const i = this.getSortedAttributes(r.attributes);
|
|
1932
1977
|
for (const { name: o, value: c } of i) {
|
|
1933
|
-
const u = o === "href" || o === "src" ?
|
|
1978
|
+
const u = o === "href" || o === "src" ? k(o, c) : c;
|
|
1934
1979
|
if (u) {
|
|
1935
1980
|
const d = `${s}[${o}="${this.escapeAttr(u)}"]`;
|
|
1936
1981
|
if (this.isUnique(d, e))
|
|
@@ -2029,7 +2074,7 @@ class rt {
|
|
|
2029
2074
|
if (e.attributes) {
|
|
2030
2075
|
const a = this.getSortedAttributes(e.attributes);
|
|
2031
2076
|
for (const { name: i, value: o } of a) {
|
|
2032
|
-
const c = i === "href" || i === "src" ?
|
|
2077
|
+
const c = i === "href" || i === "src" ? k(i, o) : o;
|
|
2033
2078
|
c && (r += `[${i}="${this.escapeAttr(c)}"]`);
|
|
2034
2079
|
}
|
|
2035
2080
|
}
|
|
@@ -2093,7 +2138,7 @@ class rt {
|
|
|
2093
2138
|
};
|
|
2094
2139
|
}
|
|
2095
2140
|
}
|
|
2096
|
-
class
|
|
2141
|
+
class Bt {
|
|
2097
2142
|
/**
|
|
2098
2143
|
* Filters elements that match the semantics
|
|
2099
2144
|
* @param elements - Candidate elements
|
|
@@ -2189,7 +2234,7 @@ class jt {
|
|
|
2189
2234
|
return Math.abs(e).toString(16).padStart(8, "0");
|
|
2190
2235
|
}
|
|
2191
2236
|
}
|
|
2192
|
-
class
|
|
2237
|
+
class Gt {
|
|
2193
2238
|
/**
|
|
2194
2239
|
* Applies a single constraint to candidates
|
|
2195
2240
|
* @param candidates - Current candidate elements
|
|
@@ -2279,7 +2324,7 @@ class Wt {
|
|
|
2279
2324
|
return s[e.length];
|
|
2280
2325
|
}
|
|
2281
2326
|
}
|
|
2282
|
-
class
|
|
2327
|
+
class Vt {
|
|
2283
2328
|
constructor() {
|
|
2284
2329
|
this.cssGenerator = new rt();
|
|
2285
2330
|
}
|
|
@@ -2424,8 +2469,8 @@ class Bt {
|
|
|
2424
2469
|
return r > 0 ? s / r : 0;
|
|
2425
2470
|
}
|
|
2426
2471
|
}
|
|
2427
|
-
function
|
|
2428
|
-
const s = { ...ft, ...e }, r = new rt(), a = new
|
|
2472
|
+
function Qt(n, t, e = {}) {
|
|
2473
|
+
const s = { ...ft, ...e }, r = new rt(), a = new Bt(), i = new Gt(), o = new Vt(), c = t instanceof Document ? t : t.ownerDocument ?? t, u = r.buildSelector(n, {
|
|
2429
2474
|
ensureUnique: !1,
|
|
2430
2475
|
root: c
|
|
2431
2476
|
});
|
|
@@ -2461,7 +2506,7 @@ function Gt(n, t, e = {}) {
|
|
|
2461
2506
|
meta: { degraded: !0, degradationReason: "not-found" }
|
|
2462
2507
|
};
|
|
2463
2508
|
let h = l;
|
|
2464
|
-
const g =
|
|
2509
|
+
const g = Yt(n.constraints);
|
|
2465
2510
|
for (const f of g) {
|
|
2466
2511
|
if (h = i.applyConstraint(h, f), h.length === 1)
|
|
2467
2512
|
return {
|
|
@@ -2488,10 +2533,10 @@ function Gt(n, t, e = {}) {
|
|
|
2488
2533
|
meta: { degraded: !0, degradationReason: "ambiguous" }
|
|
2489
2534
|
} : o.handleAmbiguous(h, n);
|
|
2490
2535
|
}
|
|
2491
|
-
function
|
|
2536
|
+
function Yt(n) {
|
|
2492
2537
|
return [...n].sort((t, e) => e.priority - t.priority);
|
|
2493
2538
|
}
|
|
2494
|
-
function
|
|
2539
|
+
function he(n) {
|
|
2495
2540
|
const t = [], e = [];
|
|
2496
2541
|
if (n.version ? n.version !== "1.0" && e.push(`Unknown version: ${n.version}`) : t.push("Missing version field"), n.anchor ? (n.anchor.tag || t.push("Anchor missing tag"), typeof n.anchor.score != "number" && t.push("Anchor missing score"), n.anchor.semantics || t.push("Anchor missing semantics")) : t.push("Missing anchor field"), n.target ? (n.target.tag || t.push("Target missing tag"), typeof n.target.score != "number" && t.push("Target missing score"), n.target.semantics || t.push("Target missing semantics")) : t.push("Missing target field"), !Array.isArray(n.path))
|
|
2497
2542
|
t.push("Path must be an array");
|
|
@@ -2506,7 +2551,7 @@ function ce(n) {
|
|
|
2506
2551
|
warnings: e
|
|
2507
2552
|
};
|
|
2508
2553
|
}
|
|
2509
|
-
function
|
|
2554
|
+
function ue(n) {
|
|
2510
2555
|
if (!n || typeof n != "object") return !1;
|
|
2511
2556
|
const t = n;
|
|
2512
2557
|
return typeof t.version == "string" && typeof t.anchor == "object" && Array.isArray(t.path) && typeof t.target == "object";
|
|
@@ -2522,17 +2567,17 @@ const nt = {
|
|
|
2522
2567
|
function st(n) {
|
|
2523
2568
|
return n === "id" ? 101 : E[n] !== void 0 ? E[n] : n.startsWith("data-") ? E["data-*"] : n.startsWith("aria-") ? E["aria-*"] : 0;
|
|
2524
2569
|
}
|
|
2525
|
-
function
|
|
2570
|
+
function Zt(n) {
|
|
2526
2571
|
return ["id", "data-testid", "data-qa", "data-cy", "href", "text", "role"].includes(n);
|
|
2527
2572
|
}
|
|
2528
|
-
function
|
|
2573
|
+
function Xt(n) {
|
|
2529
2574
|
return !!(/@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/.test(n) || /(\+?\d{1,3}[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}/.test(n) || /\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}/.test(n));
|
|
2530
2575
|
}
|
|
2531
|
-
function
|
|
2532
|
-
const e = { ...nt, ...t }, s = `v${n.version}`, r = z(n.anchor, !1, e), a = n.path.length > 0 ? n.path.map((c) => z(c, !1, e)).join(" > ") + " > " : "", i = z(n.target, !0, e), o = e.includeConstraints ?
|
|
2576
|
+
function Kt(n, t) {
|
|
2577
|
+
const e = { ...nt, ...t }, s = `v${n.version}`, r = z(n.anchor, !1, e), a = n.path.length > 0 ? n.path.map((c) => z(c, !1, e)).join(" > ") + " > " : "", i = z(n.target, !0, e), o = e.includeConstraints ? te(n) : "";
|
|
2533
2578
|
return `${s}: ${r} :: ${a}${i}${o}`;
|
|
2534
2579
|
}
|
|
2535
|
-
function
|
|
2580
|
+
function Jt(n) {
|
|
2536
2581
|
n = n.trim();
|
|
2537
2582
|
const t = n.match(/^v(\d+(?:\.\d+)?)\s*:\s*/);
|
|
2538
2583
|
if (!t)
|
|
@@ -2552,7 +2597,7 @@ function Xt(n) {
|
|
|
2552
2597
|
const c = s.split(/\s*>\s*/).map((p) => p.trim()).filter((p) => p);
|
|
2553
2598
|
if (c.length === 0)
|
|
2554
2599
|
throw new Error("Invalid SEQL Selector: missing target node");
|
|
2555
|
-
const u = c[c.length - 1], d = c.slice(0, -1), l = F(a, !0), h = d.map((p) => F(p, !1)), g = F(u, !1), f =
|
|
2600
|
+
const u = c[c.length - 1], d = c.slice(0, -1), l = F(a, !0), h = d.map((p) => F(p, !1)), g = F(u, !1), f = ee(o);
|
|
2556
2601
|
return {
|
|
2557
2602
|
version: "1.0",
|
|
2558
2603
|
anchor: l,
|
|
@@ -2579,7 +2624,7 @@ function z(n, t = !1, e = nt) {
|
|
|
2579
2624
|
const i = [], o = { ...r.attributes };
|
|
2580
2625
|
r.id && (o.id = r.id), r.role && !o.role && (o.role = r.role);
|
|
2581
2626
|
const c = Object.entries(o).map(([l, h]) => {
|
|
2582
|
-
const g = st(l), f = l === "href" || l === "src" ?
|
|
2627
|
+
const g = st(l), f = l === "href" || l === "src" ? k(l, h) : h;
|
|
2583
2628
|
return { name: l, value: f, priority: g };
|
|
2584
2629
|
}).filter((l) => l.name !== "id" && l.name !== "class" && B.has(l.name) || G.has(l.name) && V(l.value) ? !1 : l.priority > 0 || l.name === "role" || l.name === "id");
|
|
2585
2630
|
c.sort((l, h) => h.priority - l.priority);
|
|
@@ -2587,7 +2632,7 @@ function z(n, t = !1, e = nt) {
|
|
|
2587
2632
|
u.sort((l, h) => l.name.localeCompare(h.name));
|
|
2588
2633
|
for (const { name: l, value: h } of u)
|
|
2589
2634
|
i.push(`${l}="${j(h)}"`);
|
|
2590
|
-
if (e.includeText && r.text && !
|
|
2635
|
+
if (e.includeText && r.text && !Xt(r.text.normalized)) {
|
|
2591
2636
|
const l = r.text.normalized;
|
|
2592
2637
|
l.length > 0 && l.length <= e.maxTextLength && i.push(`text="${j(l)}"`);
|
|
2593
2638
|
}
|
|
@@ -2605,12 +2650,12 @@ function z(n, t = !1, e = nt) {
|
|
|
2605
2650
|
}
|
|
2606
2651
|
}
|
|
2607
2652
|
if (d.length > 0 && (a += `[${d.join(",")}]`), "nthChild" in n && n.nthChild) {
|
|
2608
|
-
const l = !!r.id || r.attributes && Object.keys(r.attributes).some(
|
|
2653
|
+
const l = !!r.id || r.attributes && Object.keys(r.attributes).some(Zt);
|
|
2609
2654
|
t && e.simplifyTarget && l || (a += `#${n.nthChild}`);
|
|
2610
2655
|
}
|
|
2611
2656
|
return a;
|
|
2612
2657
|
}
|
|
2613
|
-
function
|
|
2658
|
+
function te(n) {
|
|
2614
2659
|
if (!n.constraints || n.constraints.length === 0)
|
|
2615
2660
|
return "";
|
|
2616
2661
|
const t = [];
|
|
@@ -2645,7 +2690,7 @@ function F(n, t) {
|
|
|
2645
2690
|
i.length > 0 && (s.classes = i);
|
|
2646
2691
|
const c = e.match(/^\[([^\]]+)\]/);
|
|
2647
2692
|
if (c) {
|
|
2648
|
-
const l = c[1], h = {}, g =
|
|
2693
|
+
const l = c[1], h = {}, g = se(l);
|
|
2649
2694
|
for (const f of g) {
|
|
2650
2695
|
const m = f.match(/^([a-z][a-z0-9-]*)(?:=|~=)"((?:[^"\\]|\\.)*)"/);
|
|
2651
2696
|
if (m) {
|
|
@@ -2674,7 +2719,7 @@ function F(n, t) {
|
|
|
2674
2719
|
nthChild: u
|
|
2675
2720
|
};
|
|
2676
2721
|
}
|
|
2677
|
-
function
|
|
2722
|
+
function ee(n) {
|
|
2678
2723
|
if (!n.trim())
|
|
2679
2724
|
return [];
|
|
2680
2725
|
const t = [], e = n.split(",").map((s) => s.trim());
|
|
@@ -2715,7 +2760,7 @@ function Jt(n) {
|
|
|
2715
2760
|
}
|
|
2716
2761
|
return t;
|
|
2717
2762
|
}
|
|
2718
|
-
function
|
|
2763
|
+
function se(n) {
|
|
2719
2764
|
const t = [];
|
|
2720
2765
|
let e = "", s = !1;
|
|
2721
2766
|
for (let r = 0; r < n.length; r++) {
|
|
@@ -2730,25 +2775,25 @@ function j(n) {
|
|
|
2730
2775
|
function at(n) {
|
|
2731
2776
|
return n.replace(/\\\\/g, "\0").replace(/\\"/g, '"').replace(/\\>/g, ">").replace(/\\:/g, ":").replace(/\x00/g, "\\");
|
|
2732
2777
|
}
|
|
2733
|
-
function
|
|
2734
|
-
const s =
|
|
2735
|
-
return s ?
|
|
2778
|
+
function de(n, t, e) {
|
|
2779
|
+
const s = Z(n, t);
|
|
2780
|
+
return s ? Kt(s, e) : null;
|
|
2736
2781
|
}
|
|
2737
|
-
function
|
|
2782
|
+
function fe(n, t, e) {
|
|
2738
2783
|
try {
|
|
2739
|
-
const s =
|
|
2740
|
-
return
|
|
2784
|
+
const s = Jt(n);
|
|
2785
|
+
return Qt(s, t, e).elements || [];
|
|
2741
2786
|
} catch (s) {
|
|
2742
2787
|
return console.error("Failed to resolve SEQL Selector:", s), [];
|
|
2743
2788
|
}
|
|
2744
2789
|
}
|
|
2745
|
-
const
|
|
2790
|
+
const re = /* @__PURE__ */ new Set(["script", "style", "noscript", "meta", "link", "head", "title"]);
|
|
2746
2791
|
function W(n) {
|
|
2747
2792
|
return n.id && !D(n.id) ? 3 : n.hasAttribute("role") || n.hasAttribute("aria-label") || n.hasAttribute("aria-labelledby") || n.hasAttribute("data-testid") || n.hasAttribute("data-qa") || n.hasAttribute("data-test") ? 2 : 1;
|
|
2748
2793
|
}
|
|
2749
2794
|
function it(n, t) {
|
|
2750
2795
|
const e = n.tagName.toLowerCase();
|
|
2751
|
-
return !!(
|
|
2796
|
+
return !!(re.has(e) || t && W(n) === 1 && ![
|
|
2752
2797
|
"form",
|
|
2753
2798
|
"main",
|
|
2754
2799
|
"nav",
|
|
@@ -2770,7 +2815,7 @@ function ot(n) {
|
|
|
2770
2815
|
return W(e) - s;
|
|
2771
2816
|
});
|
|
2772
2817
|
}
|
|
2773
|
-
function
|
|
2818
|
+
function ge(n = {}) {
|
|
2774
2819
|
const t = performance.now(), {
|
|
2775
2820
|
root: e = typeof document < "u" ? document.body : void 0,
|
|
2776
2821
|
filter: s = "*",
|
|
@@ -2784,7 +2829,7 @@ function de(n = {}) {
|
|
|
2784
2829
|
} = n;
|
|
2785
2830
|
if (!e)
|
|
2786
2831
|
throw new Error("Root element or document is required");
|
|
2787
|
-
const l = u ??
|
|
2832
|
+
const l = u ?? Y(), h = { ...c, cache: l };
|
|
2788
2833
|
let g;
|
|
2789
2834
|
try {
|
|
2790
2835
|
e instanceof Document, g = Array.from(e.querySelectorAll(s));
|
|
@@ -2819,7 +2864,7 @@ function de(n = {}) {
|
|
|
2819
2864
|
else {
|
|
2820
2865
|
const U = performance.now();
|
|
2821
2866
|
try {
|
|
2822
|
-
const P =
|
|
2867
|
+
const P = Z(v, h), ct = performance.now() - U;
|
|
2823
2868
|
P ? S.push({
|
|
2824
2869
|
element: v,
|
|
2825
2870
|
eid: P,
|
|
@@ -2850,7 +2895,7 @@ function de(n = {}) {
|
|
|
2850
2895
|
}
|
|
2851
2896
|
};
|
|
2852
2897
|
}
|
|
2853
|
-
function
|
|
2898
|
+
function me(n, t = {}) {
|
|
2854
2899
|
const e = performance.now(), {
|
|
2855
2900
|
limit: s = 1 / 0,
|
|
2856
2901
|
onProgress: r,
|
|
@@ -2859,7 +2904,7 @@ function fe(n, t = {}) {
|
|
|
2859
2904
|
generatorOptions: o = {},
|
|
2860
2905
|
cache: c,
|
|
2861
2906
|
signal: u
|
|
2862
|
-
} = t, d = c ??
|
|
2907
|
+
} = t, d = c ?? Y(), l = { ...o, cache: d }, h = n.filter((T) => !it(T, i)), f = ot(h).slice(0, s), m = [], p = [];
|
|
2863
2908
|
let S = 0;
|
|
2864
2909
|
const y = f.length;
|
|
2865
2910
|
let w = 0;
|
|
@@ -2874,7 +2919,7 @@ function fe(n, t = {}) {
|
|
|
2874
2919
|
else {
|
|
2875
2920
|
const v = performance.now();
|
|
2876
2921
|
try {
|
|
2877
|
-
const A =
|
|
2922
|
+
const A = Z(R, l), U = performance.now() - v;
|
|
2878
2923
|
A ? m.push({
|
|
2879
2924
|
element: R,
|
|
2880
2925
|
eid: A,
|
|
@@ -2907,40 +2952,40 @@ function fe(n, t = {}) {
|
|
|
2907
2952
|
}
|
|
2908
2953
|
export {
|
|
2909
2954
|
gt as AnchorFinder,
|
|
2910
|
-
|
|
2955
|
+
Gt as ConstraintsEvaluator,
|
|
2911
2956
|
rt as CssGenerator,
|
|
2912
2957
|
dt as DEFAULT_GENERATOR_OPTIONS,
|
|
2913
2958
|
ft as DEFAULT_RESOLVER_OPTIONS,
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2959
|
+
Ut as EIDCache,
|
|
2960
|
+
ne as EID_VERSION,
|
|
2961
|
+
Vt as FallbackHandler,
|
|
2962
|
+
ae as MAX_PATH_DEPTH,
|
|
2918
2963
|
Ct as PathBuilder,
|
|
2919
2964
|
K as ROLE_ANCHOR_VALUES,
|
|
2920
2965
|
X as SEMANTIC_ANCHOR_TAGS,
|
|
2921
|
-
|
|
2966
|
+
ie as SEMANTIC_ATTRIBUTES,
|
|
2922
2967
|
ht as SEMANTIC_TAGS,
|
|
2923
2968
|
et as SemanticExtractor,
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2969
|
+
Bt as SemanticsMatcher,
|
|
2970
|
+
_t as SvgFingerprinter,
|
|
2971
|
+
qt as calculateConfidence,
|
|
2972
|
+
ce as calculateElementScore,
|
|
2973
|
+
zt as createEIDCache,
|
|
2929
2974
|
xt as filterClasses,
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2975
|
+
Z as generateEID,
|
|
2976
|
+
ge as generateEIDBatch,
|
|
2977
|
+
me as generateEIDForElements,
|
|
2978
|
+
de as generateSEQL,
|
|
2979
|
+
oe as getClassScore,
|
|
2980
|
+
Y as getGlobalCache,
|
|
2981
|
+
ue as isEID,
|
|
2937
2982
|
J as isUtilityClass,
|
|
2938
2983
|
Q as normalizeText,
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2984
|
+
Jt as parseSEQL,
|
|
2985
|
+
le as resetGlobalCache,
|
|
2986
|
+
Qt as resolve,
|
|
2987
|
+
fe as resolveSEQL,
|
|
2988
|
+
Kt as stringifySEQL,
|
|
2989
|
+
he as validateEID
|
|
2945
2990
|
};
|
|
2946
2991
|
//# sourceMappingURL=seql-js.js.map
|