@whenessel/seql-js 1.0.1 → 1.0.2
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 +0 -4
- package/dist/seql-js.js +203 -201
- 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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Gt = "1.0", Vt = 10, L = {
|
|
2
2
|
ANCHOR: 0.4,
|
|
3
3
|
PATH: 0.3,
|
|
4
4
|
TARGET: 0.2,
|
|
@@ -12,9 +12,9 @@ const Wt = "1.0", Bt = 10, L = {
|
|
|
12
12
|
DEPTH_PENALTY_THRESHOLD: 5,
|
|
13
13
|
DEPTH_PENALTY_FACTOR: 0.05,
|
|
14
14
|
DEGRADED_SCORE: 0.3
|
|
15
|
-
},
|
|
15
|
+
}, ct = {
|
|
16
16
|
MIN_CONFIDENCE_FOR_SKIP: 0.7
|
|
17
|
-
},
|
|
17
|
+
}, Y = [
|
|
18
18
|
"form",
|
|
19
19
|
"main",
|
|
20
20
|
"nav",
|
|
@@ -22,7 +22,7 @@ const Wt = "1.0", Bt = 10, L = {
|
|
|
22
22
|
"article",
|
|
23
23
|
"footer",
|
|
24
24
|
"header"
|
|
25
|
-
],
|
|
25
|
+
], K = [
|
|
26
26
|
"form",
|
|
27
27
|
"navigation",
|
|
28
28
|
"main",
|
|
@@ -31,7 +31,7 @@ const Wt = "1.0", Bt = 10, L = {
|
|
|
31
31
|
"complementary",
|
|
32
32
|
"banner",
|
|
33
33
|
"search"
|
|
34
|
-
],
|
|
34
|
+
], lt = [
|
|
35
35
|
// HTML5 Semantic
|
|
36
36
|
"article",
|
|
37
37
|
"aside",
|
|
@@ -108,7 +108,7 @@ const Wt = "1.0", Bt = 10, L = {
|
|
|
108
108
|
"g",
|
|
109
109
|
"text",
|
|
110
110
|
"use"
|
|
111
|
-
],
|
|
111
|
+
], ht = [
|
|
112
112
|
"rect",
|
|
113
113
|
"path",
|
|
114
114
|
"circle",
|
|
@@ -122,7 +122,7 @@ const Wt = "1.0", Bt = 10, L = {
|
|
|
122
122
|
"defs",
|
|
123
123
|
"clipPath",
|
|
124
124
|
"mask"
|
|
125
|
-
],
|
|
125
|
+
], Qt = [
|
|
126
126
|
"aria-label",
|
|
127
127
|
"aria-labelledby",
|
|
128
128
|
"aria-describedby",
|
|
@@ -162,7 +162,7 @@ const Wt = "1.0", Bt = 10, L = {
|
|
|
162
162
|
"data-*": 30,
|
|
163
163
|
// Any aria-* attribute (if not above)
|
|
164
164
|
"aria-*": 25
|
|
165
|
-
},
|
|
165
|
+
}, et = /* @__PURE__ */ new Set([
|
|
166
166
|
"id",
|
|
167
167
|
// handled separately
|
|
168
168
|
"class",
|
|
@@ -174,22 +174,39 @@ const Wt = "1.0", Bt = 10, L = {
|
|
|
174
174
|
"tabindex",
|
|
175
175
|
// can change
|
|
176
176
|
"contenteditable"
|
|
177
|
-
]),
|
|
177
|
+
]), ut = {
|
|
178
178
|
maxPathDepth: 10,
|
|
179
179
|
enableSvgFingerprint: !0,
|
|
180
180
|
confidenceThreshold: 0.1,
|
|
181
181
|
fallbackToBody: !0,
|
|
182
182
|
includeUtilityClasses: !1,
|
|
183
183
|
source: "dom-dsl"
|
|
184
|
-
},
|
|
184
|
+
}, ft = {
|
|
185
185
|
strictMode: !1,
|
|
186
186
|
enableFallback: !0,
|
|
187
187
|
maxCandidates: 20
|
|
188
188
|
};
|
|
189
|
-
function
|
|
190
|
-
return !!(/^[a-z]+-\d+$/i.test(n) || /^\d+$/.test(n) || /^:[a-z0-9]+:$/i.test(n) || /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(n) || /^[a-z]{1,3}[A-Za-z0-9]{8,}$/.test(n) && (/\d/.test(n) || /[A-Z]/.test(n)) || /^radix-/.test(n) || /^mui-\d+$/.test(n));
|
|
189
|
+
function D(n) {
|
|
190
|
+
return !!(/^[a-z]+-\d+$/i.test(n) || /^[a-z]+(-[a-z]+)+-\d+$/i.test(n) || /^[a-z]+(_[a-z]+)*_\d+$/i.test(n) || /^\d+$/.test(n) || /^:[a-z0-9]+:$/i.test(n) || /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(n) || /^[a-z]{1,3}[A-Za-z0-9]{8,}$/.test(n) && (/\d/.test(n) || /[A-Z]/.test(n)) || /^radix-/.test(n) || /^mui-\d+$/.test(n));
|
|
191
191
|
}
|
|
192
|
-
|
|
192
|
+
const B = /* @__PURE__ */ new Set([
|
|
193
|
+
"aria-labelledby",
|
|
194
|
+
"aria-describedby",
|
|
195
|
+
"aria-controls",
|
|
196
|
+
"aria-owns",
|
|
197
|
+
"aria-activedescendant",
|
|
198
|
+
"for",
|
|
199
|
+
"form",
|
|
200
|
+
"list",
|
|
201
|
+
"headers",
|
|
202
|
+
"aria-details",
|
|
203
|
+
"aria-errormessage",
|
|
204
|
+
"aria-flowto"
|
|
205
|
+
]);
|
|
206
|
+
function G(n) {
|
|
207
|
+
return n.trim().split(/\s+/).some((e) => D(e));
|
|
208
|
+
}
|
|
209
|
+
class dt {
|
|
193
210
|
constructor(t, e) {
|
|
194
211
|
this.maxDepth = t.maxPathDepth ?? 10, this.cache = e;
|
|
195
212
|
}
|
|
@@ -233,11 +250,11 @@ class ut {
|
|
|
233
250
|
scoreAnchor(t) {
|
|
234
251
|
let e = 0;
|
|
235
252
|
const s = t.tagName.toLowerCase();
|
|
236
|
-
|
|
253
|
+
Y.includes(s) && (e += $.SEMANTIC_TAG);
|
|
237
254
|
const r = t.getAttribute("role");
|
|
238
|
-
r &&
|
|
255
|
+
r && K.includes(r) && (e += $.ROLE), (t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby")) && (e += $.ARIA_LABEL);
|
|
239
256
|
const i = t.id;
|
|
240
|
-
return i && !
|
|
257
|
+
return i && !D(i) && (e += $.STABLE_ID), (t.hasAttribute("data-testid") || t.hasAttribute("data-qa") || t.hasAttribute("data-test")) && (e += $.TEST_MARKER), Math.min(e, 1);
|
|
241
258
|
}
|
|
242
259
|
/**
|
|
243
260
|
* Applies depth penalty to score
|
|
@@ -254,13 +271,13 @@ class ut {
|
|
|
254
271
|
*/
|
|
255
272
|
getTier(t) {
|
|
256
273
|
const e = t.tagName.toLowerCase();
|
|
257
|
-
if (
|
|
274
|
+
if (Y.includes(e))
|
|
258
275
|
return "A";
|
|
259
276
|
const s = t.getAttribute("role");
|
|
260
|
-
return s &&
|
|
277
|
+
return s && K.includes(s) ? "B" : "C";
|
|
261
278
|
}
|
|
262
279
|
}
|
|
263
|
-
const
|
|
280
|
+
const gt = [
|
|
264
281
|
// CSS-in-JS
|
|
265
282
|
/^css-[a-z0-9]+$/i,
|
|
266
283
|
/^sc-[a-z0-9]+-\d+$/i,
|
|
@@ -280,7 +297,7 @@ const ft = [
|
|
|
280
297
|
/^_[a-z0-9]{5,}$/i,
|
|
281
298
|
/\d{5,}/
|
|
282
299
|
// 5+ digits in a row
|
|
283
|
-
],
|
|
300
|
+
], mt = [
|
|
284
301
|
// === FIX 4: Tailwind arbitrary values and variants (highest priority) ===
|
|
285
302
|
/^\[/,
|
|
286
303
|
// Any arbitrary value or variant starting with [ (e.g., [&_svg]:..., [mask-type:luminance])
|
|
@@ -368,7 +385,7 @@ const ft = [
|
|
|
368
385
|
/^clearfix$/,
|
|
369
386
|
/^pull-(left|right)$/,
|
|
370
387
|
/^float-(left|right|none)$/
|
|
371
|
-
],
|
|
388
|
+
], pt = [
|
|
372
389
|
// === Navigation ===
|
|
373
390
|
/^(nav|menu|header|footer|sidebar|topbar|navbar|breadcrumb)/,
|
|
374
391
|
/(navigation|dropdown|megamenu)$/,
|
|
@@ -396,40 +413,40 @@ const ft = [
|
|
|
396
413
|
/^(loading|pending|complete|failed|draft|published)/
|
|
397
414
|
];
|
|
398
415
|
function q(n) {
|
|
399
|
-
return
|
|
416
|
+
return gt.some((t) => t.test(n));
|
|
400
417
|
}
|
|
401
418
|
function O(n) {
|
|
402
|
-
return n.length <= 2 || /^\d/.test(n) ? !0 :
|
|
419
|
+
return n.length <= 2 || /^\d/.test(n) ? !0 : mt.some((t) => t.test(n));
|
|
403
420
|
}
|
|
404
|
-
function
|
|
405
|
-
return q(n) || O(n) ? !1 :
|
|
421
|
+
function bt(n) {
|
|
422
|
+
return q(n) || O(n) ? !1 : pt.some((t) => t.test(n));
|
|
406
423
|
}
|
|
407
|
-
function
|
|
424
|
+
function St(n) {
|
|
408
425
|
return !q(n) && !O(n);
|
|
409
426
|
}
|
|
410
427
|
function I(n) {
|
|
411
|
-
return n.filter((t) =>
|
|
428
|
+
return n.filter((t) => St(t));
|
|
412
429
|
}
|
|
413
|
-
function
|
|
430
|
+
function yt(n) {
|
|
414
431
|
if (q(n) || O(n))
|
|
415
432
|
return 0;
|
|
416
433
|
let t = 0.5;
|
|
417
|
-
return
|
|
434
|
+
return bt(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);
|
|
418
435
|
}
|
|
419
|
-
function
|
|
436
|
+
function At(n) {
|
|
420
437
|
const t = [], e = [];
|
|
421
438
|
for (const s of n)
|
|
422
439
|
O(s) || q(s) ? e.push(s) : t.push(s);
|
|
423
440
|
return { semantic: t, utility: e };
|
|
424
441
|
}
|
|
425
|
-
function
|
|
442
|
+
function X(n) {
|
|
426
443
|
return O(n) || q(n);
|
|
427
444
|
}
|
|
428
|
-
function
|
|
429
|
-
return
|
|
445
|
+
function Zt(n) {
|
|
446
|
+
return yt(n);
|
|
430
447
|
}
|
|
431
|
-
const
|
|
432
|
-
class
|
|
448
|
+
const J = (n) => n.replace(/([#:.[\]@])/g, "\\$1");
|
|
449
|
+
class xt {
|
|
433
450
|
constructor(t, e) {
|
|
434
451
|
this.maxDepth = t.maxPathDepth ?? 10, this.cache = e;
|
|
435
452
|
}
|
|
@@ -497,7 +514,7 @@ class yt {
|
|
|
497
514
|
return e;
|
|
498
515
|
const h = t.filter((c) => !e.includes(c));
|
|
499
516
|
for (const c of h) {
|
|
500
|
-
if (i.scoreElement(c) <
|
|
517
|
+
if (i.scoreElement(c) < ct.MIN_CONFIDENCE_FOR_SKIP)
|
|
501
518
|
continue;
|
|
502
519
|
const f = this.insertNodeInOrder(e, c, t), g = this.buildTestSelector(s, f, r);
|
|
503
520
|
try {
|
|
@@ -543,9 +560,9 @@ class yt {
|
|
|
543
560
|
*/
|
|
544
561
|
elementToSelector(t) {
|
|
545
562
|
let e = t.tagName.toLowerCase();
|
|
546
|
-
t.id && !
|
|
563
|
+
t.id && !D(t.id) && (e += `#${J(t.id)}`);
|
|
547
564
|
for (const s of Array.from(t.classList))
|
|
548
|
-
|
|
565
|
+
X(s) || (e += `.${J(s)}`);
|
|
549
566
|
return e;
|
|
550
567
|
}
|
|
551
568
|
/**
|
|
@@ -559,7 +576,7 @@ class yt {
|
|
|
559
576
|
*/
|
|
560
577
|
shouldInclude(t) {
|
|
561
578
|
const e = t.tagName.toLowerCase();
|
|
562
|
-
return
|
|
579
|
+
return lt.includes(e) ? !0 : e === "div" || e === "span" ? this.hasSemanticFeatures(t) : !1;
|
|
563
580
|
}
|
|
564
581
|
/**
|
|
565
582
|
* Checks if element has meaningful semantic features
|
|
@@ -570,22 +587,22 @@ class yt {
|
|
|
570
587
|
if (s.name.startsWith("aria-")) return !0;
|
|
571
588
|
if (t.classList.length > 0) {
|
|
572
589
|
for (const s of Array.from(t.classList))
|
|
573
|
-
if (!
|
|
590
|
+
if (!X(s)) return !0;
|
|
574
591
|
}
|
|
575
592
|
if (t.hasAttribute("data-testid") || t.hasAttribute("data-qa") || t.hasAttribute("data-test"))
|
|
576
593
|
return !0;
|
|
577
594
|
const e = t.id;
|
|
578
|
-
return !!(e && !
|
|
595
|
+
return !!(e && !D(e));
|
|
579
596
|
}
|
|
580
597
|
}
|
|
581
|
-
function
|
|
598
|
+
function V(n) {
|
|
582
599
|
return n ? n.trim().replace(/[\n\t\r]/g, " ").replace(/\s+/g, " ") : "";
|
|
583
600
|
}
|
|
584
|
-
const
|
|
601
|
+
const Ct = {
|
|
585
602
|
preserveQueryForAbsolute: !0,
|
|
586
603
|
removeDynamicHashes: !0
|
|
587
604
|
};
|
|
588
|
-
function
|
|
605
|
+
function Et(n) {
|
|
589
606
|
return n ? [
|
|
590
607
|
/\d{5,}/,
|
|
591
608
|
// 5+ digits
|
|
@@ -599,20 +616,20 @@ function xt(n) {
|
|
|
599
616
|
// UUID-like
|
|
600
617
|
].some((e) => e.test(n)) : !1;
|
|
601
618
|
}
|
|
602
|
-
function
|
|
619
|
+
function Tt(n, t) {
|
|
603
620
|
if (!n) return n;
|
|
604
621
|
const e = n.startsWith("http://") || n.startsWith("https://");
|
|
605
622
|
let [s, r] = n.split("#");
|
|
606
623
|
const [i, a] = s.split("?");
|
|
607
624
|
let o = i;
|
|
608
|
-
return e && t.preserveQueryForAbsolute && a && (o += `?${a}`), r && (t.removeDynamicHashes &&
|
|
625
|
+
return e && t.preserveQueryForAbsolute && a && (o += `?${a}`), r && (t.removeDynamicHashes && Et(r) || (o += `#${r}`)), o;
|
|
609
626
|
}
|
|
610
|
-
function
|
|
627
|
+
function P(n, t, e = {}) {
|
|
611
628
|
if (!t) return t;
|
|
612
|
-
const s = { ...
|
|
613
|
-
return n === "href" || n === "src" ?
|
|
629
|
+
const s = { ...Ct, ...e };
|
|
630
|
+
return n === "href" || n === "src" ? Tt(t, s) : t;
|
|
614
631
|
}
|
|
615
|
-
class
|
|
632
|
+
class wt {
|
|
616
633
|
constructor(t, e) {
|
|
617
634
|
this.includeUtilityClasses = t.includeUtilityClasses ?? !1, this.cache = e;
|
|
618
635
|
}
|
|
@@ -628,12 +645,12 @@ class Et {
|
|
|
628
645
|
return a;
|
|
629
646
|
}
|
|
630
647
|
const e = {}, s = t.id;
|
|
631
|
-
if (s && !
|
|
648
|
+
if (s && !D(s) && (e.id = s), t.classList.length > 0) {
|
|
632
649
|
const a = Array.from(t.classList);
|
|
633
650
|
if (this.includeUtilityClasses)
|
|
634
651
|
e.classes = a;
|
|
635
652
|
else {
|
|
636
|
-
const { semantic: o } =
|
|
653
|
+
const { semantic: o } = At(a);
|
|
637
654
|
o.length > 0 && (e.classes = o);
|
|
638
655
|
}
|
|
639
656
|
}
|
|
@@ -662,7 +679,7 @@ class Et {
|
|
|
662
679
|
* @returns True if should be ignored
|
|
663
680
|
*/
|
|
664
681
|
shouldIgnoreAttribute(t) {
|
|
665
|
-
return !!(
|
|
682
|
+
return !!(et.has(t) || t.startsWith("on") || t.startsWith("ng-") || t.startsWith("_ng") || t.startsWith("data-reactid") || t.startsWith("data-react") || t.startsWith("data-v-"));
|
|
666
683
|
}
|
|
667
684
|
/**
|
|
668
685
|
* Gets attribute priority
|
|
@@ -697,8 +714,8 @@ class Et {
|
|
|
697
714
|
const e = {};
|
|
698
715
|
for (const s of Array.from(t.attributes)) {
|
|
699
716
|
const r = s.name;
|
|
700
|
-
if (this.shouldIgnoreAttribute(r) || this.getAttributePriority(r) === 0) continue;
|
|
701
|
-
const a = r === "href" || r === "src" ?
|
|
717
|
+
if (this.shouldIgnoreAttribute(r) || B.has(r) && G(s.value) || this.getAttributePriority(r) === 0) continue;
|
|
718
|
+
const a = r === "href" || r === "src" ? P(r, s.value) : s.value;
|
|
702
719
|
!a || a.trim() === "" || this.isDynamicValue(a) || (e[r] = a);
|
|
703
720
|
}
|
|
704
721
|
return e;
|
|
@@ -709,7 +726,7 @@ class Et {
|
|
|
709
726
|
extractText(t) {
|
|
710
727
|
const e = this.getDirectTextContent(t);
|
|
711
728
|
if (!e) return null;
|
|
712
|
-
const s =
|
|
729
|
+
const s = V(e);
|
|
713
730
|
if (!s) return null;
|
|
714
731
|
const r = 100, i = e.length > r ? e.slice(0, r) + "..." : e, a = s.length > r ? s.slice(0, r) + "..." : s;
|
|
715
732
|
return {
|
|
@@ -757,7 +774,7 @@ class Et {
|
|
|
757
774
|
].includes(e);
|
|
758
775
|
}
|
|
759
776
|
}
|
|
760
|
-
class
|
|
777
|
+
class vt {
|
|
761
778
|
/**
|
|
762
779
|
* Generates fingerprint for SVG element
|
|
763
780
|
* @param element - SVG element to fingerprint
|
|
@@ -868,15 +885,15 @@ class Tt {
|
|
|
868
885
|
return Math.abs(e).toString(16).padStart(8, "0");
|
|
869
886
|
}
|
|
870
887
|
}
|
|
871
|
-
function
|
|
888
|
+
function $t(n, t = 0) {
|
|
872
889
|
const e = n.anchor.score, s = n.path.length > 0 ? n.path.reduce((o, l) => o + l.score, 0) / n.path.length : 0.5, r = n.target.score, i = e * L.ANCHOR + s * L.PATH + r * L.TARGET + t * L.UNIQUENESS, a = n.anchor.degraded ? 0.2 : 0;
|
|
873
890
|
return Math.max(0, Math.min(1, i - a));
|
|
874
891
|
}
|
|
875
|
-
function
|
|
892
|
+
function Yt(n, t, e) {
|
|
876
893
|
let s = 0.5;
|
|
877
894
|
return t && (s += 0.2), e && (s += 0.15), s += Math.min(n * 0.05, 0.15), Math.min(s, 1);
|
|
878
895
|
}
|
|
879
|
-
class
|
|
896
|
+
class Mt {
|
|
880
897
|
constructor(t) {
|
|
881
898
|
this.cache = /* @__PURE__ */ new Map(), this.maxSize = t;
|
|
882
899
|
}
|
|
@@ -907,9 +924,9 @@ class vt {
|
|
|
907
924
|
return this.cache.size;
|
|
908
925
|
}
|
|
909
926
|
}
|
|
910
|
-
class
|
|
927
|
+
class It {
|
|
911
928
|
constructor(t = {}) {
|
|
912
|
-
this.eidCache = /* @__PURE__ */ new WeakMap(), this.selectorResultCache = new
|
|
929
|
+
this.eidCache = /* @__PURE__ */ new WeakMap(), this.selectorResultCache = new Mt(
|
|
913
930
|
t.maxSelectorCacheSize ?? 1e3
|
|
914
931
|
), this.anchorCache = /* @__PURE__ */ new WeakMap(), this.semanticsCache = /* @__PURE__ */ new WeakMap(), this.stats = {
|
|
915
932
|
eidHits: 0,
|
|
@@ -1058,23 +1075,23 @@ class $t {
|
|
|
1058
1075
|
return s > 0 ? t / s : 0;
|
|
1059
1076
|
}
|
|
1060
1077
|
}
|
|
1061
|
-
function
|
|
1062
|
-
return new
|
|
1078
|
+
function Nt(n) {
|
|
1079
|
+
return new It(n);
|
|
1063
1080
|
}
|
|
1064
1081
|
let _ = null;
|
|
1065
|
-
function
|
|
1066
|
-
return _ || (_ =
|
|
1082
|
+
function Q() {
|
|
1083
|
+
return _ || (_ = Nt()), _;
|
|
1067
1084
|
}
|
|
1068
|
-
function
|
|
1085
|
+
function Kt() {
|
|
1069
1086
|
_ = null;
|
|
1070
1087
|
}
|
|
1071
|
-
function
|
|
1088
|
+
function Z(n, t = {}) {
|
|
1072
1089
|
if (!n || !n.ownerDocument || !n.isConnected)
|
|
1073
1090
|
return null;
|
|
1074
|
-
const e = { ...
|
|
1091
|
+
const e = { ...ut, ...t }, s = e.cache ?? Q(), r = s.getEID(n);
|
|
1075
1092
|
if (r !== void 0)
|
|
1076
1093
|
return r;
|
|
1077
|
-
const i = new
|
|
1094
|
+
const i = new dt(e, s), a = new xt(e, s), o = new wt(e, s), l = new vt(), h = i.findAnchor(n);
|
|
1078
1095
|
if (!h && !e.fallbackToBody)
|
|
1079
1096
|
return null;
|
|
1080
1097
|
const c = h?.element ?? n.ownerDocument?.body ?? null;
|
|
@@ -1089,7 +1106,7 @@ function V(n, t = {}) {
|
|
|
1089
1106
|
n,
|
|
1090
1107
|
o
|
|
1091
1108
|
), m = o.extract(n);
|
|
1092
|
-
e.enableSvgFingerprint &&
|
|
1109
|
+
e.enableSvgFingerprint && Rt(n) && (m.svg = l.fingerprint(n));
|
|
1093
1110
|
const p = n.parentElement;
|
|
1094
1111
|
let S;
|
|
1095
1112
|
if (p) {
|
|
@@ -1105,7 +1122,7 @@ function V(n, t = {}) {
|
|
|
1105
1122
|
onMultiple: "best-score",
|
|
1106
1123
|
onMissing: "anchor-only",
|
|
1107
1124
|
maxDepth: 3
|
|
1108
|
-
}, b = g.degraded || d.degraded, v =
|
|
1125
|
+
}, b = g.degraded || d.degraded, v = Dt(g.degraded, d), x = {
|
|
1109
1126
|
version: "1.0",
|
|
1110
1127
|
anchor: g,
|
|
1111
1128
|
path: d.path,
|
|
@@ -1122,12 +1139,12 @@ function V(n, t = {}) {
|
|
|
1122
1139
|
degradationReason: v
|
|
1123
1140
|
}
|
|
1124
1141
|
};
|
|
1125
|
-
return x.meta.confidence =
|
|
1142
|
+
return x.meta.confidence = $t(x), x.meta.confidence < e.confidenceThreshold ? null : (s.setEID(n, x), x);
|
|
1126
1143
|
}
|
|
1127
|
-
function
|
|
1144
|
+
function Rt(n) {
|
|
1128
1145
|
return n.namespaceURI === "http://www.w3.org/2000/svg" || n.tagName.toLowerCase() === "svg" || n instanceof SVGElement;
|
|
1129
1146
|
}
|
|
1130
|
-
function
|
|
1147
|
+
function Dt(n, t) {
|
|
1131
1148
|
if (n && t.degraded)
|
|
1132
1149
|
return "anchor-and-path-degraded";
|
|
1133
1150
|
if (n)
|
|
@@ -1135,7 +1152,7 @@ function Nt(n, t) {
|
|
|
1135
1152
|
if (t.degraded)
|
|
1136
1153
|
return t.degradationReason;
|
|
1137
1154
|
}
|
|
1138
|
-
class
|
|
1155
|
+
class st {
|
|
1139
1156
|
buildSelector(t, e) {
|
|
1140
1157
|
if (t.path.length === 0 && t.anchor.tag === t.target.tag && JSON.stringify(t.anchor.semantics) === JSON.stringify(t.target.semantics)) {
|
|
1141
1158
|
const u = this.buildNodeSelector(
|
|
@@ -1347,7 +1364,7 @@ class tt {
|
|
|
1347
1364
|
) || s.attributes && Object.entries(s.attributes).every(
|
|
1348
1365
|
([o, l]) => {
|
|
1349
1366
|
const h = i.getAttribute(o);
|
|
1350
|
-
return o === "href" || o === "src" ?
|
|
1367
|
+
return o === "href" || o === "src" ? P(o, h || "") === P(o, l) : h === l;
|
|
1351
1368
|
}
|
|
1352
1369
|
) || s.text);
|
|
1353
1370
|
});
|
|
@@ -1550,28 +1567,13 @@ class tt {
|
|
|
1550
1567
|
buildElementSelector(t) {
|
|
1551
1568
|
const e = t.tagName.toLowerCase();
|
|
1552
1569
|
let s = e;
|
|
1553
|
-
if (t.id && !
|
|
1570
|
+
if (t.id && !D(t.id))
|
|
1554
1571
|
return `${e}#${this.escapeCSS(t.id)}`;
|
|
1555
1572
|
const r = Array.from(t.classList), i = I(r);
|
|
1556
1573
|
i.length > 0 && (s += i.slice(0, 2).map((o) => `.${this.escapeCSS(o)}`).join(""));
|
|
1557
1574
|
const a = t.getAttribute("role");
|
|
1558
1575
|
return a && (s += `[role="${this.escapeAttr(a)}"]`), s;
|
|
1559
1576
|
}
|
|
1560
|
-
/**
|
|
1561
|
-
* Checks if ID is dynamic (generated)
|
|
1562
|
-
*/
|
|
1563
|
-
isDynamicId(t) {
|
|
1564
|
-
return [
|
|
1565
|
-
/^[a-f0-9]{8,}$/i,
|
|
1566
|
-
// hex hash
|
|
1567
|
-
/^\d{5,}$/,
|
|
1568
|
-
// numeric
|
|
1569
|
-
/^(r|react|ember|vue)[\d_]/i,
|
|
1570
|
-
// framework prefixes
|
|
1571
|
-
/:r\d+:$/
|
|
1572
|
-
// React 18 ID pattern
|
|
1573
|
-
].some((s) => s.test(t));
|
|
1574
|
-
}
|
|
1575
1577
|
/**
|
|
1576
1578
|
* Safe querySelectorAll that doesn't throw
|
|
1577
1579
|
*/
|
|
@@ -1642,7 +1644,7 @@ class tt {
|
|
|
1642
1644
|
if (r.attributes) {
|
|
1643
1645
|
const a = this.getSortedAttributes(r.attributes);
|
|
1644
1646
|
for (const { name: o, value: l } of a) {
|
|
1645
|
-
const h = o === "href" || o === "src" ?
|
|
1647
|
+
const h = o === "href" || o === "src" ? P(o, l) : l;
|
|
1646
1648
|
if (h) {
|
|
1647
1649
|
const c = `${s}[${o}="${this.escapeAttr(h)}"]`;
|
|
1648
1650
|
if (this.isUnique(c, e))
|
|
@@ -1711,7 +1713,7 @@ class tt {
|
|
|
1711
1713
|
* @returns True if should be ignored
|
|
1712
1714
|
*/
|
|
1713
1715
|
shouldIgnoreAttribute(t) {
|
|
1714
|
-
return !!(
|
|
1716
|
+
return !!(et.has(t) || t.startsWith("on") || t.startsWith("ng-") || t.startsWith("_ng") || t.startsWith("data-reactid") || t.startsWith("data-react") || t.startsWith("data-v-"));
|
|
1715
1717
|
}
|
|
1716
1718
|
/**
|
|
1717
1719
|
* Gets attributes sorted by priority
|
|
@@ -1719,7 +1721,7 @@ class tt {
|
|
|
1719
1721
|
* @returns Sorted array of attributes with priority
|
|
1720
1722
|
*/
|
|
1721
1723
|
getSortedAttributes(t) {
|
|
1722
|
-
return Object.entries(t).filter(([e]) => !this.shouldIgnoreAttribute(e)).map(([e, s]) => ({
|
|
1724
|
+
return Object.entries(t).filter(([e]) => !this.shouldIgnoreAttribute(e)).filter(([e, s]) => !B.has(e) || !G(s)).map(([e, s]) => ({
|
|
1723
1725
|
name: e,
|
|
1724
1726
|
value: s,
|
|
1725
1727
|
priority: this.getAttributePriority(e)
|
|
@@ -1736,7 +1738,7 @@ class tt {
|
|
|
1736
1738
|
if (e.attributes) {
|
|
1737
1739
|
const i = this.getSortedAttributes(e.attributes);
|
|
1738
1740
|
for (const { name: a, value: o } of i) {
|
|
1739
|
-
const l = a === "href" || a === "src" ?
|
|
1741
|
+
const l = a === "href" || a === "src" ? P(a, o) : o;
|
|
1740
1742
|
l && (r += `[${a}="${this.escapeAttr(l)}"]`);
|
|
1741
1743
|
}
|
|
1742
1744
|
}
|
|
@@ -1764,10 +1766,10 @@ class tt {
|
|
|
1764
1766
|
* @returns True if element is an SVG child
|
|
1765
1767
|
*/
|
|
1766
1768
|
isSvgChildElement(t) {
|
|
1767
|
-
return
|
|
1769
|
+
return ht.includes(t);
|
|
1768
1770
|
}
|
|
1769
1771
|
}
|
|
1770
|
-
class
|
|
1772
|
+
class Ht {
|
|
1771
1773
|
/**
|
|
1772
1774
|
* Filters elements that match the semantics
|
|
1773
1775
|
* @param elements - Candidate elements
|
|
@@ -1790,7 +1792,7 @@ class Dt {
|
|
|
1790
1792
|
matchText(t, e) {
|
|
1791
1793
|
const i = Array.from(t.childNodes).filter((o) => o.nodeType === Node.TEXT_NODE).map((o) => o.textContent?.trim() ?? "").join(" ") || (t.textContent?.trim() ?? "");
|
|
1792
1794
|
if (!i) return !1;
|
|
1793
|
-
const a =
|
|
1795
|
+
const a = V(i);
|
|
1794
1796
|
return e.matchMode === "partial" ? a.includes(e.normalized) : a === e.normalized;
|
|
1795
1797
|
}
|
|
1796
1798
|
/**
|
|
@@ -1861,7 +1863,7 @@ class Dt {
|
|
|
1861
1863
|
return Math.abs(e).toString(16).padStart(8, "0");
|
|
1862
1864
|
}
|
|
1863
1865
|
}
|
|
1864
|
-
class
|
|
1866
|
+
class Pt {
|
|
1865
1867
|
/**
|
|
1866
1868
|
* Applies a single constraint to candidates
|
|
1867
1869
|
* @param candidates - Current candidate elements
|
|
@@ -1954,9 +1956,9 @@ class Rt {
|
|
|
1954
1956
|
return s[e.length];
|
|
1955
1957
|
}
|
|
1956
1958
|
}
|
|
1957
|
-
class
|
|
1959
|
+
class kt {
|
|
1958
1960
|
constructor() {
|
|
1959
|
-
this.cssGenerator = new
|
|
1961
|
+
this.cssGenerator = new st();
|
|
1960
1962
|
}
|
|
1961
1963
|
/**
|
|
1962
1964
|
* Handles fallback when resolution fails
|
|
@@ -2095,14 +2097,14 @@ class Ht {
|
|
|
2095
2097
|
}
|
|
2096
2098
|
if (e.role && (r += 0.15, t.getAttribute("role") === e.role && (s += 0.15)), e.text) {
|
|
2097
2099
|
r += 0.1;
|
|
2098
|
-
const i =
|
|
2100
|
+
const i = V(t.textContent);
|
|
2099
2101
|
i === e.text.normalized ? s += 0.1 : i.includes(e.text.normalized) && (s += 0.05);
|
|
2100
2102
|
}
|
|
2101
2103
|
return r > 0 ? s / r : 0;
|
|
2102
2104
|
}
|
|
2103
2105
|
}
|
|
2104
|
-
function
|
|
2105
|
-
const s = { ...
|
|
2106
|
+
function qt(n, t, e = {}) {
|
|
2107
|
+
const s = { ...ft, ...e }, r = new st(), i = new Ht(), a = new Pt(), o = new kt(), l = t instanceof Document ? t : t.ownerDocument ?? t, h = r.buildSelector(n, {
|
|
2106
2108
|
ensureUnique: !1,
|
|
2107
2109
|
root: l
|
|
2108
2110
|
});
|
|
@@ -2141,7 +2143,7 @@ function Pt(n, t, e = {}) {
|
|
|
2141
2143
|
meta: { degraded: !0, degradationReason: "not-found" }
|
|
2142
2144
|
};
|
|
2143
2145
|
let f = u;
|
|
2144
|
-
const g =
|
|
2146
|
+
const g = Ot(n.constraints);
|
|
2145
2147
|
for (const d of g) {
|
|
2146
2148
|
if (f = a.applyConstraint(f, d), f.length === 1)
|
|
2147
2149
|
return {
|
|
@@ -2168,10 +2170,10 @@ function Pt(n, t, e = {}) {
|
|
|
2168
2170
|
meta: { degraded: !0, degradationReason: "ambiguous" }
|
|
2169
2171
|
} : o.handleAmbiguous(f, n);
|
|
2170
2172
|
}
|
|
2171
|
-
function
|
|
2173
|
+
function Ot(n) {
|
|
2172
2174
|
return [...n].sort((t, e) => e.priority - t.priority);
|
|
2173
2175
|
}
|
|
2174
|
-
function
|
|
2176
|
+
function Xt(n) {
|
|
2175
2177
|
const t = [], e = [];
|
|
2176
2178
|
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))
|
|
2177
2179
|
t.push("Path must be an array");
|
|
@@ -2186,12 +2188,12 @@ function Yt(n) {
|
|
|
2186
2188
|
warnings: e
|
|
2187
2189
|
};
|
|
2188
2190
|
}
|
|
2189
|
-
function
|
|
2191
|
+
function Jt(n) {
|
|
2190
2192
|
if (!n || typeof n != "object") return !1;
|
|
2191
2193
|
const t = n;
|
|
2192
2194
|
return typeof t.version == "string" && typeof t.anchor == "object" && Array.isArray(t.path) && typeof t.target == "object";
|
|
2193
2195
|
}
|
|
2194
|
-
const
|
|
2196
|
+
const rt = {
|
|
2195
2197
|
maxClasses: 2,
|
|
2196
2198
|
maxAttributes: 5,
|
|
2197
2199
|
includeText: !0,
|
|
@@ -2199,20 +2201,20 @@ const et = {
|
|
|
2199
2201
|
simplifyTarget: !0,
|
|
2200
2202
|
includeConstraints: !0
|
|
2201
2203
|
};
|
|
2202
|
-
function
|
|
2204
|
+
function tt(n) {
|
|
2203
2205
|
return n === "id" ? 101 : T[n] !== void 0 ? T[n] : n.startsWith("data-") ? T["data-*"] : n.startsWith("aria-") ? T["aria-*"] : 0;
|
|
2204
2206
|
}
|
|
2205
|
-
function
|
|
2207
|
+
function Lt(n) {
|
|
2206
2208
|
return ["id", "data-testid", "data-qa", "data-cy", "href", "text", "role"].includes(n);
|
|
2207
2209
|
}
|
|
2208
|
-
function
|
|
2210
|
+
function _t(n) {
|
|
2209
2211
|
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));
|
|
2210
2212
|
}
|
|
2211
|
-
function
|
|
2212
|
-
const e = { ...
|
|
2213
|
+
function zt(n, t) {
|
|
2214
|
+
const e = { ...rt, ...t }, s = `v${n.version}`, r = F(n.anchor, !1, e), i = n.path.length > 0 ? n.path.map((l) => F(l, !1, e)).join(" > ") + " > " : "", a = F(n.target, !0, e), o = e.includeConstraints ? Ut(n) : "";
|
|
2213
2215
|
return `${s}: ${r} :: ${i}${a}${o}`;
|
|
2214
2216
|
}
|
|
2215
|
-
function
|
|
2217
|
+
function Ft(n) {
|
|
2216
2218
|
n = n.trim();
|
|
2217
2219
|
const t = n.match(/^v(\d+(?:\.\d+)?)\s*:\s*/);
|
|
2218
2220
|
if (!t)
|
|
@@ -2232,7 +2234,7 @@ function _t(n) {
|
|
|
2232
2234
|
const l = s.split(/\s*>\s*/).map((p) => p.trim()).filter((p) => p);
|
|
2233
2235
|
if (l.length === 0)
|
|
2234
2236
|
throw new Error("Invalid SEQL Selector: missing target node");
|
|
2235
|
-
const h = l[l.length - 1], c = l.slice(0, -1), u = U(i, !0), f = c.map((p) => U(p, !1)), g = U(h, !1), d =
|
|
2237
|
+
const h = l[l.length - 1], c = l.slice(0, -1), u = U(i, !0), f = c.map((p) => U(p, !1)), g = U(h, !1), d = jt(o);
|
|
2236
2238
|
return {
|
|
2237
2239
|
version: "1.0",
|
|
2238
2240
|
anchor: u,
|
|
@@ -2253,21 +2255,21 @@ function _t(n) {
|
|
|
2253
2255
|
}
|
|
2254
2256
|
};
|
|
2255
2257
|
}
|
|
2256
|
-
function F(n, t = !1, e =
|
|
2258
|
+
function F(n, t = !1, e = rt) {
|
|
2257
2259
|
const { tag: s, semantics: r } = n;
|
|
2258
2260
|
let i = s;
|
|
2259
2261
|
const a = [], o = { ...r.attributes };
|
|
2260
2262
|
r.id && (o.id = r.id), r.role && !o.role && (o.role = r.role);
|
|
2261
2263
|
const l = Object.entries(o).map(([c, u]) => {
|
|
2262
|
-
const f =
|
|
2264
|
+
const f = tt(c), g = c === "href" || c === "src" ? P(c, u) : u;
|
|
2263
2265
|
return { name: c, value: g, priority: f };
|
|
2264
|
-
}).filter((c) => ["style", "xmlns", "tabindex", "contenteditable"].includes(c.name) ? !1 : c.priority > 0 || c.name === "role" || c.name === "id");
|
|
2266
|
+
}).filter((c) => ["style", "xmlns", "tabindex", "contenteditable"].includes(c.name) || B.has(c.name) && G(c.value) ? !1 : c.priority > 0 || c.name === "role" || c.name === "id");
|
|
2265
2267
|
l.sort((c, u) => u.priority - c.priority);
|
|
2266
2268
|
const h = l.slice(0, e.maxAttributes);
|
|
2267
2269
|
h.sort((c, u) => c.name.localeCompare(u.name));
|
|
2268
2270
|
for (const { name: c, value: u } of h)
|
|
2269
2271
|
a.push(`${c}="${j(u)}"`);
|
|
2270
|
-
if (e.includeText && r.text && !
|
|
2272
|
+
if (e.includeText && r.text && !_t(r.text.normalized)) {
|
|
2271
2273
|
const c = r.text.normalized;
|
|
2272
2274
|
c.length > 0 && c.length <= e.maxTextLength && a.push(`text="${j(c)}"`);
|
|
2273
2275
|
}
|
|
@@ -2275,7 +2277,7 @@ function F(n, t = !1, e = et) {
|
|
|
2275
2277
|
let c = a;
|
|
2276
2278
|
t && e.simplifyTarget && r.id && (c = a.filter((u) => {
|
|
2277
2279
|
const f = u.split("=")[0];
|
|
2278
|
-
return
|
|
2280
|
+
return tt(f) >= 60 || f === "text" || f === "id" || f === "role";
|
|
2279
2281
|
})), c.length > 0 && (c.sort((u, f) => u.localeCompare(f)), i += `[${c.join(",")}]`);
|
|
2280
2282
|
}
|
|
2281
2283
|
if (r.classes && r.classes.length > 0) {
|
|
@@ -2286,12 +2288,12 @@ function F(n, t = !1, e = et) {
|
|
|
2286
2288
|
}
|
|
2287
2289
|
}
|
|
2288
2290
|
if ("nthChild" in n && n.nthChild) {
|
|
2289
|
-
const c = !!r.id || r.attributes && Object.keys(r.attributes).some(
|
|
2291
|
+
const c = !!r.id || r.attributes && Object.keys(r.attributes).some(Lt);
|
|
2290
2292
|
t && e.simplifyTarget && c || (i += `#${n.nthChild}`);
|
|
2291
2293
|
}
|
|
2292
2294
|
return i;
|
|
2293
2295
|
}
|
|
2294
|
-
function
|
|
2296
|
+
function Ut(n) {
|
|
2295
2297
|
if (!n.constraints || n.constraints.length === 0)
|
|
2296
2298
|
return "";
|
|
2297
2299
|
const t = [];
|
|
@@ -2326,12 +2328,12 @@ function U(n, t) {
|
|
|
2326
2328
|
a.length > 0 && (s.classes = a);
|
|
2327
2329
|
const l = e.match(/^\[([^\]]+)\]/);
|
|
2328
2330
|
if (l) {
|
|
2329
|
-
const u = l[1], f = {}, g =
|
|
2331
|
+
const u = l[1], f = {}, g = Wt(u);
|
|
2330
2332
|
for (const d of g) {
|
|
2331
2333
|
const m = d.match(/^([a-z][a-z0-9-]*)(?:=|~=)"((?:[^"\\]|\\.)*)"/);
|
|
2332
2334
|
if (m) {
|
|
2333
2335
|
const [, p, S] = m;
|
|
2334
|
-
f[p] =
|
|
2336
|
+
f[p] = nt(S);
|
|
2335
2337
|
}
|
|
2336
2338
|
}
|
|
2337
2339
|
Object.keys(f).length > 0 && (f.text && (s.text = {
|
|
@@ -2355,7 +2357,7 @@ function U(n, t) {
|
|
|
2355
2357
|
nthChild: h
|
|
2356
2358
|
};
|
|
2357
2359
|
}
|
|
2358
|
-
function
|
|
2360
|
+
function jt(n) {
|
|
2359
2361
|
if (!n.trim())
|
|
2360
2362
|
return [];
|
|
2361
2363
|
const t = [], e = n.split(",").map((s) => s.trim());
|
|
@@ -2385,7 +2387,7 @@ function Ft(n) {
|
|
|
2385
2387
|
t.push({
|
|
2386
2388
|
type: "text-proximity",
|
|
2387
2389
|
params: {
|
|
2388
|
-
reference:
|
|
2390
|
+
reference: nt(a),
|
|
2389
2391
|
maxDistance: 5
|
|
2390
2392
|
},
|
|
2391
2393
|
priority: 60
|
|
@@ -2395,7 +2397,7 @@ function Ft(n) {
|
|
|
2395
2397
|
}
|
|
2396
2398
|
return t;
|
|
2397
2399
|
}
|
|
2398
|
-
function
|
|
2400
|
+
function Wt(n) {
|
|
2399
2401
|
const t = [];
|
|
2400
2402
|
let e = "", s = !1;
|
|
2401
2403
|
for (let r = 0; r < n.length; r++) {
|
|
@@ -2407,22 +2409,22 @@ function Ut(n) {
|
|
|
2407
2409
|
function j(n) {
|
|
2408
2410
|
return n.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/>/g, "\\>").replace(/:/g, "\\:");
|
|
2409
2411
|
}
|
|
2410
|
-
function
|
|
2412
|
+
function nt(n) {
|
|
2411
2413
|
return n.replace(/\\\\/g, "\0").replace(/\\"/g, '"').replace(/\\>/g, ">").replace(/\\:/g, ":").replace(/\x00/g, "\\");
|
|
2412
2414
|
}
|
|
2413
|
-
function
|
|
2414
|
-
const s =
|
|
2415
|
-
return s ?
|
|
2415
|
+
function te(n, t, e) {
|
|
2416
|
+
const s = Z(n, t);
|
|
2417
|
+
return s ? zt(s, e) : null;
|
|
2416
2418
|
}
|
|
2417
|
-
function
|
|
2419
|
+
function ee(n, t, e) {
|
|
2418
2420
|
try {
|
|
2419
|
-
const s =
|
|
2420
|
-
return
|
|
2421
|
+
const s = Ft(n);
|
|
2422
|
+
return qt(s, t, e).elements || [];
|
|
2421
2423
|
} catch (s) {
|
|
2422
2424
|
return console.error("Failed to resolve SEQL Selector:", s), [];
|
|
2423
2425
|
}
|
|
2424
2426
|
}
|
|
2425
|
-
const
|
|
2427
|
+
const Bt = /* @__PURE__ */ new Set([
|
|
2426
2428
|
"script",
|
|
2427
2429
|
"style",
|
|
2428
2430
|
"noscript",
|
|
@@ -2432,11 +2434,11 @@ const jt = /* @__PURE__ */ new Set([
|
|
|
2432
2434
|
"title"
|
|
2433
2435
|
]);
|
|
2434
2436
|
function W(n) {
|
|
2435
|
-
return n.id && !
|
|
2437
|
+
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;
|
|
2436
2438
|
}
|
|
2437
|
-
function
|
|
2439
|
+
function it(n, t) {
|
|
2438
2440
|
const e = n.tagName.toLowerCase();
|
|
2439
|
-
return !!(
|
|
2441
|
+
return !!(Bt.has(e) || t && W(n) === 1 && ![
|
|
2440
2442
|
"form",
|
|
2441
2443
|
"main",
|
|
2442
2444
|
"nav",
|
|
@@ -2452,13 +2454,13 @@ function rt(n, t) {
|
|
|
2452
2454
|
"textarea"
|
|
2453
2455
|
].includes(e));
|
|
2454
2456
|
}
|
|
2455
|
-
function
|
|
2457
|
+
function at(n) {
|
|
2456
2458
|
return [...n].sort((t, e) => {
|
|
2457
2459
|
const s = W(t);
|
|
2458
2460
|
return W(e) - s;
|
|
2459
2461
|
});
|
|
2460
2462
|
}
|
|
2461
|
-
function
|
|
2463
|
+
function se(n = {}) {
|
|
2462
2464
|
const t = performance.now(), {
|
|
2463
2465
|
root: e = typeof document < "u" ? document.body : void 0,
|
|
2464
2466
|
filter: s = "*",
|
|
@@ -2472,7 +2474,7 @@ function te(n = {}) {
|
|
|
2472
2474
|
} = n;
|
|
2473
2475
|
if (!e)
|
|
2474
2476
|
throw new Error("Root element or document is required");
|
|
2475
|
-
const u = h ??
|
|
2477
|
+
const u = h ?? Q(), f = { ...l, cache: u };
|
|
2476
2478
|
let g;
|
|
2477
2479
|
try {
|
|
2478
2480
|
e instanceof Document, g = Array.from(e.querySelectorAll(s));
|
|
@@ -2492,16 +2494,16 @@ function te(n = {}) {
|
|
|
2492
2494
|
};
|
|
2493
2495
|
}
|
|
2494
2496
|
const d = g.filter(
|
|
2495
|
-
(E) => !
|
|
2496
|
-
), p =
|
|
2497
|
+
(E) => !it(E, o)
|
|
2498
|
+
), p = at(d).slice(0, r), S = [], y = [];
|
|
2497
2499
|
let w = 0;
|
|
2498
2500
|
const A = p.length;
|
|
2499
2501
|
let b = 0;
|
|
2500
2502
|
for (let E = 0; E < p.length && !c?.aborted; E++) {
|
|
2501
|
-
const
|
|
2503
|
+
const R = p[E], M = u.getEID(R);
|
|
2502
2504
|
if (M)
|
|
2503
2505
|
S.push({
|
|
2504
|
-
element:
|
|
2506
|
+
element: R,
|
|
2505
2507
|
eid: M,
|
|
2506
2508
|
generationTimeMs: 0
|
|
2507
2509
|
// Cached, no generation time
|
|
@@ -2509,23 +2511,23 @@ function te(n = {}) {
|
|
|
2509
2511
|
else {
|
|
2510
2512
|
const z = performance.now();
|
|
2511
2513
|
try {
|
|
2512
|
-
const
|
|
2513
|
-
|
|
2514
|
-
element:
|
|
2515
|
-
eid:
|
|
2516
|
-
generationTimeMs:
|
|
2514
|
+
const H = Z(R, f), ot = performance.now() - z;
|
|
2515
|
+
H ? S.push({
|
|
2516
|
+
element: R,
|
|
2517
|
+
eid: H,
|
|
2518
|
+
generationTimeMs: ot
|
|
2517
2519
|
}) : w++;
|
|
2518
|
-
} catch (
|
|
2520
|
+
} catch (H) {
|
|
2519
2521
|
y.push({
|
|
2520
|
-
element:
|
|
2521
|
-
error:
|
|
2522
|
+
element: R,
|
|
2523
|
+
error: H instanceof Error ? H.message : String(H)
|
|
2522
2524
|
});
|
|
2523
2525
|
}
|
|
2524
2526
|
}
|
|
2525
2527
|
i && E - b >= a && (i(E + 1, A), b = E);
|
|
2526
2528
|
}
|
|
2527
2529
|
i && i(A, A);
|
|
2528
|
-
const v = performance.now() - t, x = u.getStats(),
|
|
2530
|
+
const v = performance.now() - t, x = u.getStats(), k = x.eidHits + x.eidMisses + x.selectorHits + x.selectorMisses, C = x.eidHits + x.selectorHits, N = k > 0 ? C / k : 0;
|
|
2529
2531
|
return {
|
|
2530
2532
|
results: S,
|
|
2531
2533
|
failed: y,
|
|
@@ -2540,7 +2542,7 @@ function te(n = {}) {
|
|
|
2540
2542
|
}
|
|
2541
2543
|
};
|
|
2542
2544
|
}
|
|
2543
|
-
function
|
|
2545
|
+
function re(n, t = {}) {
|
|
2544
2546
|
const e = performance.now(), {
|
|
2545
2547
|
limit: s = 1 / 0,
|
|
2546
2548
|
onProgress: r,
|
|
@@ -2549,9 +2551,9 @@ function ee(n, t = {}) {
|
|
|
2549
2551
|
generatorOptions: o = {},
|
|
2550
2552
|
cache: l,
|
|
2551
2553
|
signal: h
|
|
2552
|
-
} = t, c = l ??
|
|
2553
|
-
(C) => !
|
|
2554
|
-
), d =
|
|
2554
|
+
} = t, c = l ?? Q(), u = { ...o, cache: c }, f = n.filter(
|
|
2555
|
+
(C) => !it(C, a)
|
|
2556
|
+
), d = at(f).slice(0, s), m = [], p = [];
|
|
2555
2557
|
let S = 0;
|
|
2556
2558
|
const y = d.length;
|
|
2557
2559
|
let w = 0;
|
|
@@ -2564,9 +2566,9 @@ function ee(n, t = {}) {
|
|
|
2564
2566
|
generationTimeMs: 0
|
|
2565
2567
|
});
|
|
2566
2568
|
else {
|
|
2567
|
-
const
|
|
2569
|
+
const R = performance.now();
|
|
2568
2570
|
try {
|
|
2569
|
-
const M =
|
|
2571
|
+
const M = Z(N, u), z = performance.now() - R;
|
|
2570
2572
|
M ? m.push({
|
|
2571
2573
|
element: N,
|
|
2572
2574
|
eid: M,
|
|
@@ -2582,7 +2584,7 @@ function ee(n, t = {}) {
|
|
|
2582
2584
|
r && C - w >= i && (r(C + 1, y), w = C);
|
|
2583
2585
|
}
|
|
2584
2586
|
r && r(y, y);
|
|
2585
|
-
const A = performance.now() - e, b = c.getStats(), v = b.eidHits + b.eidMisses + b.selectorHits + b.selectorMisses, x = b.eidHits + b.selectorHits,
|
|
2587
|
+
const A = performance.now() - e, b = c.getStats(), v = b.eidHits + b.eidMisses + b.selectorHits + b.selectorMisses, x = b.eidHits + b.selectorHits, k = v > 0 ? x / v : 0;
|
|
2586
2588
|
return {
|
|
2587
2589
|
results: m,
|
|
2588
2590
|
failed: p,
|
|
@@ -2593,46 +2595,46 @@ function ee(n, t = {}) {
|
|
|
2593
2595
|
skipped: S,
|
|
2594
2596
|
totalTimeMs: A,
|
|
2595
2597
|
avgTimePerElementMs: m.length > 0 ? A / m.length : 0,
|
|
2596
|
-
cacheHitRate:
|
|
2598
|
+
cacheHitRate: k
|
|
2597
2599
|
}
|
|
2598
2600
|
};
|
|
2599
2601
|
}
|
|
2600
2602
|
export {
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2603
|
+
dt as AnchorFinder,
|
|
2604
|
+
Pt as ConstraintsEvaluator,
|
|
2605
|
+
st as CssGenerator,
|
|
2606
|
+
ut as DEFAULT_GENERATOR_OPTIONS,
|
|
2607
|
+
ft as DEFAULT_RESOLVER_OPTIONS,
|
|
2608
|
+
It as EIDCache,
|
|
2609
|
+
Gt as EID_VERSION,
|
|
2610
|
+
kt as FallbackHandler,
|
|
2611
|
+
Vt as MAX_PATH_DEPTH,
|
|
2612
|
+
xt as PathBuilder,
|
|
2613
|
+
K as ROLE_ANCHOR_VALUES,
|
|
2614
|
+
Y as SEMANTIC_ANCHOR_TAGS,
|
|
2615
|
+
Qt as SEMANTIC_ATTRIBUTES,
|
|
2616
|
+
lt as SEMANTIC_TAGS,
|
|
2617
|
+
wt as SemanticExtractor,
|
|
2618
|
+
Ht as SemanticsMatcher,
|
|
2619
|
+
vt as SvgFingerprinter,
|
|
2620
|
+
$t as calculateConfidence,
|
|
2621
|
+
Yt as calculateElementScore,
|
|
2622
|
+
Nt as createEIDCache,
|
|
2623
|
+
At as filterClasses,
|
|
2624
|
+
Z as generateEID,
|
|
2625
|
+
se as generateEIDBatch,
|
|
2626
|
+
re as generateEIDForElements,
|
|
2627
|
+
te as generateSEQL,
|
|
2628
|
+
Zt as getClassScore,
|
|
2629
|
+
Q as getGlobalCache,
|
|
2630
|
+
Jt as isEID,
|
|
2631
|
+
X as isUtilityClass,
|
|
2632
|
+
V as normalizeText,
|
|
2633
|
+
Ft as parseSEQL,
|
|
2634
|
+
Kt as resetGlobalCache,
|
|
2635
|
+
qt as resolve,
|
|
2636
|
+
ee as resolveSEQL,
|
|
2637
|
+
zt as stringifySEQL,
|
|
2638
|
+
Xt as validateEID
|
|
2637
2639
|
};
|
|
2638
2640
|
//# sourceMappingURL=seql-js.js.map
|