@appsurify-testmap/rrweb-playwright-plugin 2.1.3-alpha.4 → 3.1.1-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.js +1390 -147
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1389 -146
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var O=Object.create;var f=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var U=(t,e)=>{for(var n in e)f(t,n,{get:e[n],enumerable:!0})},$=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of L(e))!F.call(t,r)&&r!==n&&f(t,r,{get:()=>e[r],enumerable:!(s=P(e,r))||s.enumerable});return t};var b=(t,e,n)=>(n=t!=null?O(D(t)):{},$(e||!t||!t.__esModule?f(n,"default",{value:t,enumerable:!0}):n,t)),
|
|
1
|
+
"use strict";var O=Object.create;var f=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var U=(t,e)=>{for(var n in e)f(t,n,{get:e[n],enumerable:!0})},$=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of L(e))!F.call(t,r)&&r!==n&&f(t,r,{get:()=>e[r],enumerable:!(s=P(e,r))||s.enumerable});return t};var b=(t,e,n)=>(n=t!=null?O(D(t)):{},$(e||!t||!t.__esModule?f(n,"default",{value:t,enumerable:!0}):n,t)),z=t=>$(f({},"__esModule",{value:!0}),t);var Y={};U(Y,{expect:()=>y.expect,test:()=>k});module.exports=z(Y);var y=require("@playwright/test");var w=b(require("os")),p=b(require("path")),u=b(require("fs")),j="test-results/playwright/ui";function V(t,e){let n=p.default.dirname(t),s=p.default.join(n,`.${p.default.basename(t)}.tmp-${process.pid}-${Date.now()}`);u.default.mkdirSync(n,{recursive:!0}),u.default.writeFileSync(s,e,"utf-8"),u.default.renameSync(s,t)}function W(t){try{if(!u.default.existsSync(t))return[];let e=u.default.readFileSync(t,"utf-8").trim();if(!e)return[];let n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}function C(t,e){let n=e!==void 0?e:j,s=v(t.spec.name),r=v(t.test.suite?.title),i=v(t.test.title),o=t.browser.name,c=`${r?r+"-":""}${i}.json`,d=p.default.join(n,s,o,c),h={events:t.recorderEvents,metadata:{runner:t.runner,spec:t.spec,suite:t.test.suite,test:t.test,browser:t.browser}};u.default.mkdirSync(n,{recursive:!0}),u.default.mkdirSync(p.default.dirname(d),{recursive:!0}),u.default.writeFileSync(d,JSON.stringify(h,null,2),"utf-8"),console.log(`[ui-coverage] Saved report to ${d}`);try{let a=p.default.join(n,"ui-coverage-aggregated.json"),l=W(a);l.push(h),V(a,JSON.stringify(l,null,2)),console.log(`[ui-coverage] Updated aggregate: ${a}`)}catch(a){console.warn("[ui-coverage] Failed to update aggregate report:",a)}}function v(t){return(t??"").trim().replace(/[\s:/\\<>|"'?*]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function _(t,e){let n=t.browserType(),s=t.version(),r=n.name(),i=e.file,o=i.replace(process.cwd(),"").replace(/^[/\\]/,""),c=o.split(/[\\/]/).pop()??"",[d,h]=c.split(/\.(?=[^\\.]+$)/),a=e.titlePath.slice(1,-1),l=a.join(" > ")||"Root Suite";return{runner:{source:"playwright",type:"unknown",version:e.config.version,platform:w.default.platform(),arch:w.default.arch(),recorder:{scriptVersion:"unknown",libVersion:"unknown"}},spec:{name:c,relative:o,absolute:i,baseName:c,fileName:d,fileExtension:h,id:o},test:{suite:{id:a.join("::")||"root",invocationDetails:{absoluteFile:i,column:e.column??0,line:e.line??0,fileUrl:void 0,function:void 0,originalFile:void 0,relativeFile:o},pending:!1,root:a.length===0,title:l,type:"unknown"},id:e.testId,title:e.title,titlePath:e.titlePath.slice(1),fullTitle:e.titlePath.slice(1).join(" "),file:e.file,invocationDetails:{absoluteFile:i,column:e.column,line:e.line,fileUrl:"",relativeFile:o},state:e.status,duration:e.duration,pending:!1,sync:!1,timedOut:void 0,type:""},browser:{name:r,family:r,version:s,majorVersion:parseInt(s.split(".")[0],10),displayName:e.project.use?.channel?.toUpperCase?.()??r.charAt(0).toUpperCase()+r.slice(1),channel:e.project.use?.channel??"",path:n.executablePath()},recorderEvents:[]}}function S(t,e){let n={...t};for(let s in e){let r=e[s],i=t[s];r&&typeof r=="object"&&!Array.isArray(r)&&i&&typeof i=="object"&&!Array.isArray(i)?n[s]=S(i,r):r!==void 0&&(n[s]=r)}return n}async function I(t,e=500){let n=Date.now(),s=t.getEvents().length;return new Promise(r=>{let i=setInterval(()=>{let o=t.getEvents().length;(o===s||Date.now()-n>e)&&(clearInterval(i),r()),s=o},50)})}async function E(t){await t.evaluate(()=>new Promise(e=>requestAnimationFrame(()=>e())))}var B={i8:Int8Array,ui8:Uint8Array,ui8c:Uint8ClampedArray,i16:Int16Array,ui16:Uint16Array,i32:Int32Array,ui32:Uint32Array,f32:Float32Array,f64:Float64Array,bi64:BigInt64Array,bui64:BigUint64Array},Z=new Map(Object.entries(B).map(([t,e])=>[e,t]));var R=`(function (g, f) {
|
|
2
2
|
if ("object" == typeof exports && "object" == typeof module) {
|
|
3
3
|
module.exports = f();
|
|
4
4
|
} else if ("function" == typeof define && define.amd) {
|
|
@@ -352,6 +352,8 @@ function stringifyRule(rule2, sheetHref) {
|
|
|
352
352
|
return importStringified;
|
|
353
353
|
} else {
|
|
354
354
|
let ruleStringified = rule2.cssText;
|
|
355
|
+
if (rule2.type === CSSRule.KEYFRAMES_RULE || rule2.type === CSSRule.KEYFRAME_RULE)
|
|
356
|
+
;
|
|
355
357
|
if (isCSSStyleRule(rule2) && rule2.selectorText.includes(":")) {
|
|
356
358
|
ruleStringified = fixSafariColons(ruleStringified);
|
|
357
359
|
}
|
|
@@ -567,19 +569,19 @@ function splitCssText(cssText, style, _testNoPxNorm = false) {
|
|
|
567
569
|
_testNoPxNorm
|
|
568
570
|
);
|
|
569
571
|
const jLimit = 100;
|
|
570
|
-
let
|
|
571
|
-
for (;
|
|
572
|
+
let j2 = 3;
|
|
573
|
+
for (; j2 < textContentNorm.length; j2++) {
|
|
572
574
|
if (
|
|
573
575
|
// keep consuming css identifiers (to get a decent chunk more quickly)
|
|
574
|
-
textContentNorm[
|
|
575
|
-
textContentNorm.indexOf(textContentNorm.substring(0,
|
|
576
|
+
textContentNorm[j2].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
|
|
577
|
+
textContentNorm.indexOf(textContentNorm.substring(0, j2), 1) !== -1
|
|
576
578
|
) {
|
|
577
579
|
continue;
|
|
578
580
|
}
|
|
579
581
|
break;
|
|
580
582
|
}
|
|
581
|
-
for (;
|
|
582
|
-
let startSubstring = textContentNorm.substring(0,
|
|
583
|
+
for (; j2 < textContentNorm.length; j2++) {
|
|
584
|
+
let startSubstring = textContentNorm.substring(0, j2);
|
|
583
585
|
let cssNormSplits = cssTextNorm.split(startSubstring);
|
|
584
586
|
let splitNorm = -1;
|
|
585
587
|
if (cssNormSplits.length === 2) {
|
|
@@ -596,11 +598,11 @@ function splitCssText(cssText, style, _testNoPxNorm = false) {
|
|
|
596
598
|
splits.push(cssText);
|
|
597
599
|
return splits;
|
|
598
600
|
}
|
|
599
|
-
|
|
600
|
-
} else if (
|
|
601
|
+
j2 = jLimit + 1;
|
|
602
|
+
} else if (j2 === textContentNorm.length - 1) {
|
|
601
603
|
splitNorm = cssTextNorm.indexOf(startSubstring);
|
|
602
604
|
}
|
|
603
|
-
if (cssNormSplits.length >= 2 &&
|
|
605
|
+
if (cssNormSplits.length >= 2 && j2 > jLimit) {
|
|
604
606
|
const prevTextContent = childNodes2[i2 - 1].textContent;
|
|
605
607
|
if (prevTextContent && typeof prevTextContent === "string") {
|
|
606
608
|
const prevMinLength = normalizeCssString(prevTextContent).length;
|
|
@@ -611,29 +613,29 @@ function splitCssText(cssText, style, _testNoPxNorm = false) {
|
|
|
611
613
|
}
|
|
612
614
|
}
|
|
613
615
|
if (splitNorm !== -1) {
|
|
614
|
-
let
|
|
615
|
-
for (;
|
|
616
|
+
let k2 = Math.floor(splitNorm / normFactor);
|
|
617
|
+
for (; k2 > 0 && k2 < cssText.length; ) {
|
|
616
618
|
iterCount += 1;
|
|
617
619
|
if (iterCount > 50 * childNodes2.length) {
|
|
618
620
|
splits.push(cssText);
|
|
619
621
|
return splits;
|
|
620
622
|
}
|
|
621
623
|
const normPart = normalizeCssString(
|
|
622
|
-
cssText.substring(0,
|
|
624
|
+
cssText.substring(0, k2),
|
|
623
625
|
_testNoPxNorm
|
|
624
626
|
);
|
|
625
627
|
if (normPart.length === splitNorm) {
|
|
626
|
-
splits.push(cssText.substring(0,
|
|
627
|
-
cssText = cssText.substring(
|
|
628
|
+
splits.push(cssText.substring(0, k2));
|
|
629
|
+
cssText = cssText.substring(k2);
|
|
628
630
|
cssTextNorm = cssTextNorm.substring(splitNorm);
|
|
629
631
|
break;
|
|
630
632
|
} else if (normPart.length < splitNorm) {
|
|
631
|
-
|
|
633
|
+
k2 += Math.max(
|
|
632
634
|
1,
|
|
633
635
|
Math.floor((splitNorm - normPart.length) / normFactor)
|
|
634
636
|
);
|
|
635
637
|
} else {
|
|
636
|
-
|
|
638
|
+
k2 -= Math.max(
|
|
637
639
|
1,
|
|
638
640
|
Math.floor((normPart.length - splitNorm) * normFactor)
|
|
639
641
|
);
|
|
@@ -651,102 +653,6 @@ function splitCssText(cssText, style, _testNoPxNorm = false) {
|
|
|
651
653
|
function markCssSplits(cssText, style) {
|
|
652
654
|
return splitCssText(cssText, style).join("/* rr_split */");
|
|
653
655
|
}
|
|
654
|
-
function isSelectorUnique(selector, target) {
|
|
655
|
-
try {
|
|
656
|
-
const matches = document.querySelectorAll(selector);
|
|
657
|
-
return matches.length === 1 && matches[0] === target;
|
|
658
|
-
} catch (e) {
|
|
659
|
-
return false;
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
function buildSelector(node2) {
|
|
663
|
-
if (!(node2 instanceof Element))
|
|
664
|
-
return null;
|
|
665
|
-
if (node2.id) {
|
|
666
|
-
return \`#\${CSS.escape(node2.id)}\`;
|
|
667
|
-
}
|
|
668
|
-
const parts = [];
|
|
669
|
-
const tag = node2.tagName.toLowerCase();
|
|
670
|
-
if (node2.classList.length) {
|
|
671
|
-
parts.push(...Array.from(node2.classList).map((cls) => \`.\${CSS.escape(cls)}\`));
|
|
672
|
-
}
|
|
673
|
-
Array.from(node2.attributes).forEach((attr) => {
|
|
674
|
-
if (attr.name.startsWith("data-")) {
|
|
675
|
-
parts.push(\`[\${attr.name}="\${CSS.escape(attr.value)}"]\`);
|
|
676
|
-
}
|
|
677
|
-
});
|
|
678
|
-
const shortSelector = \`\${tag}\${parts.join("")}\`;
|
|
679
|
-
if (isSelectorUnique(shortSelector, node2)) {
|
|
680
|
-
return shortSelector;
|
|
681
|
-
}
|
|
682
|
-
const pathParts = [];
|
|
683
|
-
let current = node2;
|
|
684
|
-
while (current && current.nodeType === Node.ELEMENT_NODE) {
|
|
685
|
-
const parent = current.parentElement;
|
|
686
|
-
const tagName = current.tagName.toLowerCase();
|
|
687
|
-
let nth = "";
|
|
688
|
-
if (parent) {
|
|
689
|
-
const siblings = Array.from(parent.children).filter(
|
|
690
|
-
(el) => el.tagName.toLowerCase() === tagName
|
|
691
|
-
);
|
|
692
|
-
if (siblings.length > 1) {
|
|
693
|
-
nth = \`:nth-of-type(\${siblings.indexOf(current) + 1})\`;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
pathParts.unshift(\`\${tagName}\${nth}\`);
|
|
697
|
-
current = parent;
|
|
698
|
-
}
|
|
699
|
-
return pathParts.join(" > ") || null;
|
|
700
|
-
}
|
|
701
|
-
function buildXPath(node2) {
|
|
702
|
-
switch (node2.nodeType) {
|
|
703
|
-
case Node.DOCUMENT_NODE:
|
|
704
|
-
return "/";
|
|
705
|
-
case Node.DOCUMENT_TYPE_NODE:
|
|
706
|
-
return "/html/doctype";
|
|
707
|
-
case Node.ELEMENT_NODE: {
|
|
708
|
-
const element = node2;
|
|
709
|
-
if (element.id) {
|
|
710
|
-
return \`//*[@id="\${CSS.escape(element.id)}"]\`;
|
|
711
|
-
}
|
|
712
|
-
if (element.tagName.toLowerCase() === "html")
|
|
713
|
-
return "/html";
|
|
714
|
-
if (element === document.head)
|
|
715
|
-
return "/html/head";
|
|
716
|
-
if (element === document.body)
|
|
717
|
-
return "/html/body";
|
|
718
|
-
const parent = element.parentNode;
|
|
719
|
-
if (!parent)
|
|
720
|
-
return "";
|
|
721
|
-
const tag = element.tagName.toLowerCase();
|
|
722
|
-
const siblings = Array.from(parent.children).filter(
|
|
723
|
-
(el) => el.tagName.toLowerCase() === tag
|
|
724
|
-
);
|
|
725
|
-
const index2 = siblings.length > 1 ? \`[\${siblings.indexOf(element) + 1}]\` : "";
|
|
726
|
-
return \`\${buildXPath(parent)}/\${tag}\${index2}\`;
|
|
727
|
-
}
|
|
728
|
-
case Node.TEXT_NODE:
|
|
729
|
-
case Node.CDATA_SECTION_NODE:
|
|
730
|
-
case Node.COMMENT_NODE: {
|
|
731
|
-
const parent = node2.parentNode;
|
|
732
|
-
if (!parent)
|
|
733
|
-
return "";
|
|
734
|
-
const typeMap = {
|
|
735
|
-
[Node.TEXT_NODE]: "text()",
|
|
736
|
-
[Node.CDATA_SECTION_NODE]: "text()",
|
|
737
|
-
// CDATA \u2261 text() \u0432 XPath
|
|
738
|
-
[Node.COMMENT_NODE]: "comment()"
|
|
739
|
-
};
|
|
740
|
-
const sameTypeSiblings = Array.from(parent.childNodes).filter(
|
|
741
|
-
(sibling) => sibling.nodeType === node2.nodeType
|
|
742
|
-
);
|
|
743
|
-
const index2 = sameTypeSiblings.length > 1 ? \`[\${sameTypeSiblings.indexOf(node2)}]\` : "";
|
|
744
|
-
return \`\${buildXPath(parent)}/\${typeMap[node2.nodeType]}\${index2}\`;
|
|
745
|
-
}
|
|
746
|
-
default:
|
|
747
|
-
return "";
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
656
|
function isTextVisible(n2) {
|
|
751
657
|
var _a2;
|
|
752
658
|
const parent = index$1.parentNode(n2);
|
|
@@ -879,6 +785,1309 @@ try {
|
|
|
879
785
|
}
|
|
880
786
|
} catch (error) {
|
|
881
787
|
}
|
|
788
|
+
const L = {
|
|
789
|
+
ANCHOR: 0.4,
|
|
790
|
+
PATH: 0.3,
|
|
791
|
+
TARGET: 0.2,
|
|
792
|
+
UNIQUENESS: 0.1
|
|
793
|
+
};
|
|
794
|
+
const I = {
|
|
795
|
+
SEMANTIC_TAG: 0.5,
|
|
796
|
+
ROLE: 0.3,
|
|
797
|
+
ARIA_LABEL: 0.1,
|
|
798
|
+
STABLE_ID: 0.1,
|
|
799
|
+
TEST_MARKER: 0.05,
|
|
800
|
+
DEPTH_PENALTY_THRESHOLD: 5,
|
|
801
|
+
DEPTH_PENALTY_FACTOR: 0.05,
|
|
802
|
+
DEGRADED_SCORE: 0.3
|
|
803
|
+
};
|
|
804
|
+
const ct = {
|
|
805
|
+
MIN_CONFIDENCE_FOR_SKIP: 0.7
|
|
806
|
+
};
|
|
807
|
+
const X = [
|
|
808
|
+
"form",
|
|
809
|
+
"main",
|
|
810
|
+
"nav",
|
|
811
|
+
"section",
|
|
812
|
+
"article",
|
|
813
|
+
"footer",
|
|
814
|
+
"header"
|
|
815
|
+
];
|
|
816
|
+
const K = [
|
|
817
|
+
"form",
|
|
818
|
+
"navigation",
|
|
819
|
+
"main",
|
|
820
|
+
"region",
|
|
821
|
+
"contentinfo",
|
|
822
|
+
"complementary",
|
|
823
|
+
"banner",
|
|
824
|
+
"search"
|
|
825
|
+
];
|
|
826
|
+
const lt = [
|
|
827
|
+
// HTML5 Semantic
|
|
828
|
+
"article",
|
|
829
|
+
"aside",
|
|
830
|
+
"details",
|
|
831
|
+
"figcaption",
|
|
832
|
+
"figure",
|
|
833
|
+
"footer",
|
|
834
|
+
"header",
|
|
835
|
+
"main",
|
|
836
|
+
"mark",
|
|
837
|
+
"nav",
|
|
838
|
+
"section",
|
|
839
|
+
"summary",
|
|
840
|
+
"time",
|
|
841
|
+
// Form elements
|
|
842
|
+
"button",
|
|
843
|
+
"datalist",
|
|
844
|
+
"fieldset",
|
|
845
|
+
"form",
|
|
846
|
+
"input",
|
|
847
|
+
"label",
|
|
848
|
+
"legend",
|
|
849
|
+
"meter",
|
|
850
|
+
"optgroup",
|
|
851
|
+
"option",
|
|
852
|
+
"output",
|
|
853
|
+
"progress",
|
|
854
|
+
"select",
|
|
855
|
+
"textarea",
|
|
856
|
+
// Interactive
|
|
857
|
+
"a",
|
|
858
|
+
"audio",
|
|
859
|
+
"video",
|
|
860
|
+
"canvas",
|
|
861
|
+
"dialog",
|
|
862
|
+
"menu",
|
|
863
|
+
// Text content
|
|
864
|
+
"blockquote",
|
|
865
|
+
"dd",
|
|
866
|
+
"dl",
|
|
867
|
+
"dt",
|
|
868
|
+
"hr",
|
|
869
|
+
"li",
|
|
870
|
+
"ol",
|
|
871
|
+
"ul",
|
|
872
|
+
"p",
|
|
873
|
+
"pre",
|
|
874
|
+
"h1",
|
|
875
|
+
"h2",
|
|
876
|
+
"h3",
|
|
877
|
+
"h4",
|
|
878
|
+
"h5",
|
|
879
|
+
"h6",
|
|
880
|
+
// Table
|
|
881
|
+
"caption",
|
|
882
|
+
"col",
|
|
883
|
+
"colgroup",
|
|
884
|
+
"table",
|
|
885
|
+
"tbody",
|
|
886
|
+
"td",
|
|
887
|
+
"tfoot",
|
|
888
|
+
"th",
|
|
889
|
+
"thead",
|
|
890
|
+
"tr",
|
|
891
|
+
// SVG
|
|
892
|
+
"svg",
|
|
893
|
+
"path",
|
|
894
|
+
"circle",
|
|
895
|
+
"rect",
|
|
896
|
+
"line",
|
|
897
|
+
"polyline",
|
|
898
|
+
"polygon",
|
|
899
|
+
"ellipse",
|
|
900
|
+
"g",
|
|
901
|
+
"text",
|
|
902
|
+
"use"
|
|
903
|
+
];
|
|
904
|
+
const w = {
|
|
905
|
+
// Test attributes (highest priority)
|
|
906
|
+
"data-testid": 100,
|
|
907
|
+
"data-qa": 99,
|
|
908
|
+
"data-cy": 98,
|
|
909
|
+
"data-test": 97,
|
|
910
|
+
"data-test-id": 96,
|
|
911
|
+
// ARIA (accessibility semantics)
|
|
912
|
+
"aria-label": 90,
|
|
913
|
+
"aria-labelledby": 85,
|
|
914
|
+
"aria-describedby": 80,
|
|
915
|
+
// Semantic HTML attributes
|
|
916
|
+
name: 75,
|
|
917
|
+
href: 70,
|
|
918
|
+
// for <a>
|
|
919
|
+
src: 70,
|
|
920
|
+
// for <img>, <script>, etc.
|
|
921
|
+
type: 65,
|
|
922
|
+
role: 60,
|
|
923
|
+
alt: 55,
|
|
924
|
+
title: 50,
|
|
925
|
+
for: 45,
|
|
926
|
+
placeholder: 40,
|
|
927
|
+
// Any data-* attribute (if not above)
|
|
928
|
+
"data-*": 30,
|
|
929
|
+
// Any aria-* attribute (if not above)
|
|
930
|
+
"aria-*": 25
|
|
931
|
+
};
|
|
932
|
+
const B = /* @__PURE__ */ new Set([
|
|
933
|
+
"id",
|
|
934
|
+
// handled separately
|
|
935
|
+
"class",
|
|
936
|
+
// handled separately
|
|
937
|
+
"style",
|
|
938
|
+
// unstable
|
|
939
|
+
"xmlns",
|
|
940
|
+
// service attribute for SVG
|
|
941
|
+
"tabindex",
|
|
942
|
+
// can change
|
|
943
|
+
"contenteditable"
|
|
944
|
+
]);
|
|
945
|
+
const ut = {
|
|
946
|
+
maxPathDepth: 10,
|
|
947
|
+
enableSvgFingerprint: true,
|
|
948
|
+
confidenceThreshold: 0.1,
|
|
949
|
+
fallbackToBody: true,
|
|
950
|
+
includeUtilityClasses: false,
|
|
951
|
+
source: "dom-dsl"
|
|
952
|
+
};
|
|
953
|
+
function D(n2) {
|
|
954
|
+
return !!(/^[a-z]+-\\d+$/i.test(n2) || /^[a-z]+(-[a-z]+)+-\\d+$/i.test(n2) || /^[a-z]+(_[a-z]+)*_\\d+$/i.test(n2) || /^\\d+$/.test(n2) || /^:[a-z0-9]+:$/i.test(n2) || /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(n2) || /^[a-z]{1,3}[A-Za-z0-9]{8,}$/.test(n2) && (/\\d/.test(n2) || /[A-Z]/.test(n2)) || /^radix-/.test(n2) || /^mui-\\d+$/.test(n2));
|
|
955
|
+
}
|
|
956
|
+
const G = /* @__PURE__ */ new Set([
|
|
957
|
+
"aria-labelledby",
|
|
958
|
+
"aria-describedby",
|
|
959
|
+
"aria-controls",
|
|
960
|
+
"aria-owns",
|
|
961
|
+
"aria-activedescendant",
|
|
962
|
+
"for",
|
|
963
|
+
"form",
|
|
964
|
+
"list",
|
|
965
|
+
"headers",
|
|
966
|
+
"aria-details",
|
|
967
|
+
"aria-errormessage",
|
|
968
|
+
"aria-flowto"
|
|
969
|
+
]);
|
|
970
|
+
function V(n2) {
|
|
971
|
+
return n2.trim().split(/\\s+/).some((e2) => D(e2));
|
|
972
|
+
}
|
|
973
|
+
class ft {
|
|
974
|
+
constructor(t2, e2) {
|
|
975
|
+
var _a2;
|
|
976
|
+
this.maxDepth = (_a2 = t2.maxPathDepth) != null ? _a2 : 10, this.cache = e2;
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* Finds the best anchor element for the target
|
|
980
|
+
* @param target - Target element to find anchor for
|
|
981
|
+
* @returns Anchor result or null if not found
|
|
982
|
+
*/
|
|
983
|
+
findAnchor(t2) {
|
|
984
|
+
if (this.cache) {
|
|
985
|
+
const i2 = this.cache.getAnchor(t2);
|
|
986
|
+
if (i2 !== void 0)
|
|
987
|
+
return i2;
|
|
988
|
+
}
|
|
989
|
+
let e2 = t2.parentElement, s2 = 0, r2 = null;
|
|
990
|
+
for (; e2 && s2 < this.maxDepth; ) {
|
|
991
|
+
if (e2.tagName.toLowerCase() === "body")
|
|
992
|
+
return r2 || {
|
|
993
|
+
element: e2,
|
|
994
|
+
score: I.DEGRADED_SCORE,
|
|
995
|
+
tier: "C",
|
|
996
|
+
depth: s2
|
|
997
|
+
};
|
|
998
|
+
const i2 = this.scoreAnchor(e2);
|
|
999
|
+
if (i2 > 0) {
|
|
1000
|
+
const o2 = this.applyDepthPenalty(i2, s2), l2 = this.getTier(e2), u2 = { element: e2, score: o2, tier: l2, depth: s2 };
|
|
1001
|
+
if (l2 === "A")
|
|
1002
|
+
return u2;
|
|
1003
|
+
(!r2 || o2 > r2.score) && (r2 = u2);
|
|
1004
|
+
}
|
|
1005
|
+
e2 = e2.parentElement, s2++;
|
|
1006
|
+
}
|
|
1007
|
+
const a2 = r2;
|
|
1008
|
+
return this.cache && this.cache.setAnchor(t2, a2), a2;
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Scores an element as anchor candidate (without depth penalty)
|
|
1012
|
+
* @param element - Element to score
|
|
1013
|
+
* @returns Raw score from 0 to 1
|
|
1014
|
+
*/
|
|
1015
|
+
scoreAnchor(t2) {
|
|
1016
|
+
let e2 = 0;
|
|
1017
|
+
const s2 = t2.tagName.toLowerCase();
|
|
1018
|
+
X.includes(s2) && (e2 += I.SEMANTIC_TAG);
|
|
1019
|
+
const r2 = t2.getAttribute("role");
|
|
1020
|
+
r2 && K.includes(r2) && (e2 += I.ROLE), (t2.hasAttribute("aria-label") || t2.hasAttribute("aria-labelledby")) && (e2 += I.ARIA_LABEL);
|
|
1021
|
+
const a2 = t2.id;
|
|
1022
|
+
return a2 && !D(a2) && (e2 += I.STABLE_ID), (t2.hasAttribute("data-testid") || t2.hasAttribute("data-qa") || t2.hasAttribute("data-test")) && (e2 += I.TEST_MARKER), Math.min(e2, 1);
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Applies depth penalty to score
|
|
1026
|
+
* Following SPECIFICATION.md \xA77: depthPenalty = (depth - threshold) * factor
|
|
1027
|
+
*/
|
|
1028
|
+
applyDepthPenalty(t2, e2) {
|
|
1029
|
+
if (e2 <= I.DEPTH_PENALTY_THRESHOLD)
|
|
1030
|
+
return t2;
|
|
1031
|
+
const s2 = (e2 - I.DEPTH_PENALTY_THRESHOLD) * I.DEPTH_PENALTY_FACTOR;
|
|
1032
|
+
return Math.max(0, t2 - s2);
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* Determines the tier of an anchor element
|
|
1036
|
+
*/
|
|
1037
|
+
getTier(t2) {
|
|
1038
|
+
const e2 = t2.tagName.toLowerCase();
|
|
1039
|
+
if (X.includes(e2))
|
|
1040
|
+
return "A";
|
|
1041
|
+
const s2 = t2.getAttribute("role");
|
|
1042
|
+
return s2 && K.includes(s2) ? "B" : "C";
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
const gt = [
|
|
1046
|
+
// CSS-in-JS
|
|
1047
|
+
/^css-[a-z0-9]+$/i,
|
|
1048
|
+
/^sc-[a-z0-9]+-\\d+$/i,
|
|
1049
|
+
/^[a-z]{5,8}$/i,
|
|
1050
|
+
// Short generated classes (abcdef)
|
|
1051
|
+
// Material-UI / MUI
|
|
1052
|
+
/^Mui[A-Z]\\w+-\\w+-\\w+/,
|
|
1053
|
+
/^makeStyles-\\w+-\\d+$/,
|
|
1054
|
+
// JSS
|
|
1055
|
+
/^jss\\d+$/,
|
|
1056
|
+
// Emotion / Linaria
|
|
1057
|
+
/^(emotion|linaria)-[a-z0-9]+/i,
|
|
1058
|
+
// Component libraries with hashes
|
|
1059
|
+
/^(chakra|tw-|ant-)[a-z0-9]+-\\w+/i,
|
|
1060
|
+
// Hash-based (hashes in classes)
|
|
1061
|
+
/-[a-f0-9]{6,}$/i,
|
|
1062
|
+
/^_[a-z0-9]{5,}$/i,
|
|
1063
|
+
/\\d{5,}/
|
|
1064
|
+
// 5+ digits in a row
|
|
1065
|
+
];
|
|
1066
|
+
const pt = [
|
|
1067
|
+
// === FIX 4: Tailwind arbitrary values and variants (highest priority) ===
|
|
1068
|
+
/^\\[/,
|
|
1069
|
+
// Any arbitrary value or variant starting with [ (e.g., [&_svg]:..., [mask-type:luminance])
|
|
1070
|
+
// === FIX 4: Pseudo-class variants (must be before specific patterns) ===
|
|
1071
|
+
/^(first|last|odd|even|only|first-of-type|last-of-type|only-of-type):/,
|
|
1072
|
+
// first:, last:, etc.
|
|
1073
|
+
/^(hover|focus|active|disabled|enabled|checked|indeterminate|default|required|valid|invalid|in-range|out-of-range|placeholder-shown|autofill|read-only):/,
|
|
1074
|
+
// State pseudo-classes
|
|
1075
|
+
/^(focus-within|focus-visible|visited|target|open):/,
|
|
1076
|
+
// Advanced pseudo-classes
|
|
1077
|
+
// === FIX 4: Responsive variants (must be before specific patterns) ===
|
|
1078
|
+
/^(sm|md|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl):/,
|
|
1079
|
+
// === FIX 4: Dark mode and directional variants ===
|
|
1080
|
+
/^dark:/,
|
|
1081
|
+
/^(rtl|ltr):/,
|
|
1082
|
+
// === FIX 4: Group and peer variants ===
|
|
1083
|
+
/^(group|peer)(-hover|-focus|-active)?:/,
|
|
1084
|
+
// === FIX 4: Tailwind utilities with fraction values ===
|
|
1085
|
+
/\\/([\\d.]+|full|auto|screen)$/,
|
|
1086
|
+
// /50, /100, /full, /auto, /screen
|
|
1087
|
+
// === FIX 4: Positioning utilities ===
|
|
1088
|
+
/^(inset|top|right|bottom|left)(-|$)/,
|
|
1089
|
+
// inset-0, top-0, left-0
|
|
1090
|
+
// === Layout & Display ===
|
|
1091
|
+
/^(flex|inline-flex|grid|block|inline|inline-block|hidden|visible)$/,
|
|
1092
|
+
/^(absolute|relative|fixed|sticky|static)$/,
|
|
1093
|
+
// === Flexbox & Grid ===
|
|
1094
|
+
/^(items|justify|content|self|place)-/,
|
|
1095
|
+
/^flex-(row|col|wrap|nowrap|1|auto|initial|none)/,
|
|
1096
|
+
/^grid-(cols|rows|flow)/,
|
|
1097
|
+
// === Spacing (Tailwind) ===
|
|
1098
|
+
/^(gap|space)-/,
|
|
1099
|
+
/^[mp][trblxy]?-(\\d+|auto|px)$/,
|
|
1100
|
+
// === Negative Tailwind utilities (margins, positioning, transforms) ===
|
|
1101
|
+
/^-[mp][trblxy]?-\\d+$/,
|
|
1102
|
+
// -m-4, -mt-2, -mx-4, -px-4, -py-2
|
|
1103
|
+
/^-(top|right|bottom|left|inset)-\\d+$/,
|
|
1104
|
+
// -top-4, -bottom-6, -left-6, -inset-0
|
|
1105
|
+
/^-z-\\d+$/,
|
|
1106
|
+
// -z-10, -z-20
|
|
1107
|
+
/^-space-[xy]-\\d+$/,
|
|
1108
|
+
// -space-x-2, -space-y-4
|
|
1109
|
+
/^-translate-[xy]-\\d+$/,
|
|
1110
|
+
// -translate-x-4, -translate-y-2
|
|
1111
|
+
/^-rotate-\\d+$/,
|
|
1112
|
+
// -rotate-45, -rotate-90
|
|
1113
|
+
/^-scale-\\d+$/,
|
|
1114
|
+
// -scale-50, -scale-75
|
|
1115
|
+
/^-skew-[xy]-\\d+$/,
|
|
1116
|
+
// -skew-x-12, -skew-y-6
|
|
1117
|
+
// === Sizing ===
|
|
1118
|
+
/^(w|h|min-w|min-h|max-w|max-h|size)-/,
|
|
1119
|
+
// === Colors & Styling ===
|
|
1120
|
+
// Note: text-* can be semantic (text-muted, text-primary) or utility (text-center, text-lg)
|
|
1121
|
+
// More specific patterns for utility text-* classes
|
|
1122
|
+
/^text-(center|left|right|justify|start|end|xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/,
|
|
1123
|
+
/^text-(uppercase|lowercase|capitalize|normal-case|underline|line-through|no-underline)$/,
|
|
1124
|
+
/^text-(truncate|ellipsis|clip)$/,
|
|
1125
|
+
/^(bg|border|ring|shadow|outline)-/,
|
|
1126
|
+
/^rounded(-|$)/,
|
|
1127
|
+
// === Typography ===
|
|
1128
|
+
/^(font|leading|tracking|whitespace|break|truncate)-/,
|
|
1129
|
+
/^(uppercase|lowercase|capitalize|normal-case)$/,
|
|
1130
|
+
// === Transform & Animation (IMPORTANT!) ===
|
|
1131
|
+
/^(transform|transition|duration|delay|ease|animate)-/,
|
|
1132
|
+
/^(scale|rotate|translate|skew)-/,
|
|
1133
|
+
/^transform$/,
|
|
1134
|
+
/^backdrop-blur-/,
|
|
1135
|
+
/^motion-/,
|
|
1136
|
+
// Framer Motion
|
|
1137
|
+
/^(fade|slide|zoom|bounce|pulse|spin|ping)-/,
|
|
1138
|
+
// animations
|
|
1139
|
+
// === Overflow & Scrolling ===
|
|
1140
|
+
/^(overflow|overscroll|scroll)-/,
|
|
1141
|
+
/^object-(contain|cover|fill|none|scale-down)$/,
|
|
1142
|
+
// === Interactivity ===
|
|
1143
|
+
/^(cursor|pointer-events|select|resize)-/,
|
|
1144
|
+
// === Visibility & Opacity ===
|
|
1145
|
+
/^(opacity|z)-/,
|
|
1146
|
+
/^(visible|invisible|collapse)$/,
|
|
1147
|
+
// === Bootstrap utilities ===
|
|
1148
|
+
/^d-(none|inline|inline-block|block|grid|table|flex)$/,
|
|
1149
|
+
/^(float|clearfix|text)-(left|right|center|justify|start|end)$/,
|
|
1150
|
+
/^(m|p)[trblxy]?-[0-5]$/,
|
|
1151
|
+
/^(w|h)-(25|50|75|100|auto)$/,
|
|
1152
|
+
// Note: btn-* classes are semantic (component classes), not utility
|
|
1153
|
+
// /^btn-(primary|secondary|success|danger|warning|info|light|dark|link)$/,
|
|
1154
|
+
/^btn-(sm|lg|block)$/,
|
|
1155
|
+
// Only size modifiers are utility
|
|
1156
|
+
/^text-(muted|primary|success|danger|warning|info|light|dark|white)$/,
|
|
1157
|
+
/^bg-(primary|secondary|success|danger|warning|info|light|dark|white|transparent)$/,
|
|
1158
|
+
/^border(-top|-bottom|-left|-right)?(-0)?$/,
|
|
1159
|
+
/^rounded(-top|-bottom|-left|-right|-circle|-pill|-0)?$/,
|
|
1160
|
+
/^shadow(-sm|-lg|-none)?$/,
|
|
1161
|
+
/^(align|justify|order|flex)-(start|end|center|between|around|fill|grow|shrink)$/,
|
|
1162
|
+
/^col(-sm|-md|-lg|-xl)?(-\\d+|-auto)?$/,
|
|
1163
|
+
/^row(-cols)?(-\\d+)?$/,
|
|
1164
|
+
/^g[xy]?-[0-5]$/,
|
|
1165
|
+
/^(show|hide|invisible|visible)$/,
|
|
1166
|
+
/^(position|top|bottom|start|end)-(static|relative|absolute|fixed|sticky|-\\d+)$/,
|
|
1167
|
+
// === Common utility patterns ===
|
|
1168
|
+
/^(row|col)$/,
|
|
1169
|
+
/^clearfix$/,
|
|
1170
|
+
/^pull-(left|right)$/,
|
|
1171
|
+
/^float-(left|right|none)$/
|
|
1172
|
+
];
|
|
1173
|
+
function _(n2) {
|
|
1174
|
+
return gt.some((t2) => t2.test(n2));
|
|
1175
|
+
}
|
|
1176
|
+
function q(n2) {
|
|
1177
|
+
return n2.length <= 2 || /^\\d/.test(n2) ? true : pt.some((t2) => t2.test(n2));
|
|
1178
|
+
}
|
|
1179
|
+
function St(n2) {
|
|
1180
|
+
return !_(n2) && !q(n2);
|
|
1181
|
+
}
|
|
1182
|
+
function N(n2) {
|
|
1183
|
+
return n2.filter((t2) => St(t2));
|
|
1184
|
+
}
|
|
1185
|
+
function At(n2) {
|
|
1186
|
+
const t2 = [], e2 = [];
|
|
1187
|
+
for (const s2 of n2)
|
|
1188
|
+
q(s2) || _(s2) ? e2.push(s2) : t2.push(s2);
|
|
1189
|
+
return { semantic: t2, utility: e2 };
|
|
1190
|
+
}
|
|
1191
|
+
function J(n2) {
|
|
1192
|
+
return q(n2) || _(n2);
|
|
1193
|
+
}
|
|
1194
|
+
const tt = (n2) => n2.replace(/([#:.[\\]@])/g, "\\\\$1");
|
|
1195
|
+
class xt {
|
|
1196
|
+
constructor(t2, e2) {
|
|
1197
|
+
var _a2;
|
|
1198
|
+
this.maxDepth = (_a2 = t2.maxPathDepth) != null ? _a2 : 10, this.cache = e2;
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Builds path from anchor to target (excluding both)
|
|
1202
|
+
* @param anchor - Anchor element (start)
|
|
1203
|
+
* @param target - Target element (end)
|
|
1204
|
+
* @param extractor - Semantic extractor instance
|
|
1205
|
+
* @returns Path build result with nodes and degradation info
|
|
1206
|
+
*/
|
|
1207
|
+
buildPath(t2, e2, s2) {
|
|
1208
|
+
const r2 = [];
|
|
1209
|
+
let a2 = e2.parentElement;
|
|
1210
|
+
for (; a2 && a2 !== t2 && r2.length < this.maxDepth; )
|
|
1211
|
+
r2.unshift(a2), a2 = a2.parentElement;
|
|
1212
|
+
const i2 = r2.length >= this.maxDepth && a2 !== t2;
|
|
1213
|
+
let o2 = this.filterNoise(r2);
|
|
1214
|
+
return o2 = this.ensureUniqueness(r2, o2, t2, e2, s2), {
|
|
1215
|
+
path: o2.map((u2) => {
|
|
1216
|
+
const d = u2.parentElement;
|
|
1217
|
+
let c2;
|
|
1218
|
+
if (d) {
|
|
1219
|
+
const g = Array.from(d.children).indexOf(u2);
|
|
1220
|
+
g !== -1 && (c2 = g + 1);
|
|
1221
|
+
}
|
|
1222
|
+
return {
|
|
1223
|
+
tag: u2.tagName.toLowerCase(),
|
|
1224
|
+
semantics: s2.extract(u2),
|
|
1225
|
+
score: s2.scoreElement(u2),
|
|
1226
|
+
nthChild: c2
|
|
1227
|
+
};
|
|
1228
|
+
}),
|
|
1229
|
+
degraded: i2,
|
|
1230
|
+
degradationReason: i2 ? "path-depth-overflow" : void 0
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Legacy method for backward compatibility
|
|
1235
|
+
*/
|
|
1236
|
+
buildPathNodes(t2, e2, s2) {
|
|
1237
|
+
return this.buildPath(t2, e2, s2).path;
|
|
1238
|
+
}
|
|
1239
|
+
/**
|
|
1240
|
+
* Ensures path uniqueness by adding nodes if needed
|
|
1241
|
+
* Following SPECIFICATION.md \xA78 Disambiguation Algorithm
|
|
1242
|
+
*/
|
|
1243
|
+
ensureUniqueness(t2, e2, s2, r2, a2) {
|
|
1244
|
+
const i2 = this.buildTestSelector(s2, e2, r2);
|
|
1245
|
+
try {
|
|
1246
|
+
const o2 = r2.ownerDocument;
|
|
1247
|
+
if (!o2)
|
|
1248
|
+
return e2;
|
|
1249
|
+
let l2;
|
|
1250
|
+
if (this.cache) {
|
|
1251
|
+
const d = this.cache.getSelectorResults(i2);
|
|
1252
|
+
d !== void 0 ? l2 = d : (l2 = Array.from(o2.querySelectorAll(i2)), this.cache.setSelectorResults(i2, l2));
|
|
1253
|
+
} else
|
|
1254
|
+
l2 = o2.querySelectorAll(i2);
|
|
1255
|
+
if (l2.length <= 1)
|
|
1256
|
+
return e2;
|
|
1257
|
+
const u2 = t2.filter((d) => !e2.includes(d));
|
|
1258
|
+
for (const d of u2) {
|
|
1259
|
+
if (a2.scoreElement(d) < ct.MIN_CONFIDENCE_FOR_SKIP)
|
|
1260
|
+
continue;
|
|
1261
|
+
const h = this.insertNodeInOrder(e2, d, t2), g = this.buildTestSelector(s2, h, r2);
|
|
1262
|
+
try {
|
|
1263
|
+
let f2;
|
|
1264
|
+
if (this.cache) {
|
|
1265
|
+
const p = this.cache.getSelectorResults(g);
|
|
1266
|
+
p !== void 0 ? f2 = p : (f2 = Array.from(o2.querySelectorAll(g)), this.cache.setSelectorResults(g, f2));
|
|
1267
|
+
} else
|
|
1268
|
+
f2 = o2.querySelectorAll(g);
|
|
1269
|
+
if (f2.length === 1)
|
|
1270
|
+
return h;
|
|
1271
|
+
f2.length < l2.length && (e2 = h);
|
|
1272
|
+
} catch (e) {
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
return e2;
|
|
1276
|
+
} catch (e) {
|
|
1277
|
+
return e2;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Inserts node into path maintaining original order
|
|
1282
|
+
*/
|
|
1283
|
+
insertNodeInOrder(t2, e2, s2) {
|
|
1284
|
+
const r2 = s2.indexOf(e2), a2 = [...t2];
|
|
1285
|
+
let i2 = 0;
|
|
1286
|
+
for (let o2 = 0; o2 < a2.length && !(s2.indexOf(a2[o2]) > r2); o2++)
|
|
1287
|
+
i2 = o2 + 1;
|
|
1288
|
+
return a2.splice(i2, 0, e2), a2;
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Builds a test CSS selector from path
|
|
1292
|
+
*/
|
|
1293
|
+
buildTestSelector(t2, e2, s2) {
|
|
1294
|
+
const r2 = [];
|
|
1295
|
+
r2.push(this.elementToSelector(t2));
|
|
1296
|
+
for (const a2 of e2)
|
|
1297
|
+
r2.push(this.elementToSelector(a2));
|
|
1298
|
+
return r2.push(this.elementToSelector(s2)), r2.join(" ");
|
|
1299
|
+
}
|
|
1300
|
+
/**
|
|
1301
|
+
* Converts element to basic CSS selector
|
|
1302
|
+
*/
|
|
1303
|
+
elementToSelector(t2) {
|
|
1304
|
+
let e2 = t2.tagName.toLowerCase();
|
|
1305
|
+
t2.id && !D(t2.id) && (e2 += \`#\${tt(t2.id)}\`);
|
|
1306
|
+
for (const s2 of Array.from(t2.classList))
|
|
1307
|
+
J(s2) || (e2 += \`.\${tt(s2)}\`);
|
|
1308
|
+
return e2;
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Filters out noise/layout elements
|
|
1312
|
+
*/
|
|
1313
|
+
filterNoise(t2) {
|
|
1314
|
+
return t2.filter((e2) => this.shouldInclude(e2));
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Determines if element should be included in path
|
|
1318
|
+
*/
|
|
1319
|
+
shouldInclude(t2) {
|
|
1320
|
+
const e2 = t2.tagName.toLowerCase();
|
|
1321
|
+
return lt.includes(e2) ? true : e2 === "div" || e2 === "span" ? this.hasSemanticFeatures(t2) : false;
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Checks if element has meaningful semantic features
|
|
1325
|
+
*/
|
|
1326
|
+
hasSemanticFeatures(t2) {
|
|
1327
|
+
if (t2.hasAttribute("role"))
|
|
1328
|
+
return true;
|
|
1329
|
+
for (const s2 of Array.from(t2.attributes))
|
|
1330
|
+
if (s2.name.startsWith("aria-"))
|
|
1331
|
+
return true;
|
|
1332
|
+
if (t2.classList.length > 0) {
|
|
1333
|
+
for (const s2 of Array.from(t2.classList))
|
|
1334
|
+
if (!J(s2))
|
|
1335
|
+
return true;
|
|
1336
|
+
}
|
|
1337
|
+
if (t2.hasAttribute("data-testid") || t2.hasAttribute("data-qa") || t2.hasAttribute("data-test"))
|
|
1338
|
+
return true;
|
|
1339
|
+
const e2 = t2.id;
|
|
1340
|
+
return !!(e2 && !D(e2));
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
function Q(n2) {
|
|
1344
|
+
return n2 ? n2.trim().replace(/[\\n\\t\\r]/g, " ").replace(/\\s+/g, " ") : "";
|
|
1345
|
+
}
|
|
1346
|
+
const Ct = {
|
|
1347
|
+
preserveQueryForAbsolute: true,
|
|
1348
|
+
removeDynamicHashes: true
|
|
1349
|
+
};
|
|
1350
|
+
function Tt(n2) {
|
|
1351
|
+
return n2 ? [
|
|
1352
|
+
/\\d{5,}/,
|
|
1353
|
+
// 5+ digits
|
|
1354
|
+
/[a-f0-9]{8,}/i,
|
|
1355
|
+
// hex hash 8+ characters
|
|
1356
|
+
/(session|token|temp|random|timestamp|nonce|cache)/i,
|
|
1357
|
+
// dynamic words
|
|
1358
|
+
/^\\d+$/,
|
|
1359
|
+
// only digits
|
|
1360
|
+
/^[a-f0-9-]{32,}$/i
|
|
1361
|
+
// UUID-like
|
|
1362
|
+
].some((e2) => e2.test(n2)) : false;
|
|
1363
|
+
}
|
|
1364
|
+
function Et(n2, t2) {
|
|
1365
|
+
if (!n2)
|
|
1366
|
+
return n2;
|
|
1367
|
+
const e2 = n2.startsWith("http://") || n2.startsWith("https://"), [s2, r2] = n2.split("#"), [a2, i2] = s2.split("?");
|
|
1368
|
+
let o2 = a2;
|
|
1369
|
+
return e2 && t2.preserveQueryForAbsolute && i2 && (o2 += \`?\${i2}\`), r2 && (t2.removeDynamicHashes && Tt(r2) || (o2 += \`#\${r2}\`)), o2;
|
|
1370
|
+
}
|
|
1371
|
+
function k(n2, t2, e2 = {}) {
|
|
1372
|
+
if (!t2)
|
|
1373
|
+
return t2;
|
|
1374
|
+
const s2 = __spreadValues(__spreadValues({}, Ct), e2);
|
|
1375
|
+
return n2 === "href" || n2 === "src" ? Et(t2, s2) : t2;
|
|
1376
|
+
}
|
|
1377
|
+
const wt = [
|
|
1378
|
+
"role",
|
|
1379
|
+
"aria-label",
|
|
1380
|
+
"aria-labelledby",
|
|
1381
|
+
"aria-describedby",
|
|
1382
|
+
"aria-controls",
|
|
1383
|
+
"aria-owns",
|
|
1384
|
+
"aria-level",
|
|
1385
|
+
"aria-posinset",
|
|
1386
|
+
"aria-setsize",
|
|
1387
|
+
"aria-haspopup"
|
|
1388
|
+
];
|
|
1389
|
+
const vt = [
|
|
1390
|
+
"aria-selected",
|
|
1391
|
+
"aria-checked",
|
|
1392
|
+
"aria-pressed",
|
|
1393
|
+
"aria-expanded",
|
|
1394
|
+
"aria-hidden",
|
|
1395
|
+
"aria-disabled",
|
|
1396
|
+
"aria-current",
|
|
1397
|
+
"aria-busy",
|
|
1398
|
+
"aria-invalid",
|
|
1399
|
+
"aria-grabbed",
|
|
1400
|
+
"aria-live",
|
|
1401
|
+
"aria-atomic"
|
|
1402
|
+
];
|
|
1403
|
+
const $t = [
|
|
1404
|
+
"data-state",
|
|
1405
|
+
"data-active",
|
|
1406
|
+
"data-inactive",
|
|
1407
|
+
"data-selected",
|
|
1408
|
+
"data-open",
|
|
1409
|
+
"data-closed",
|
|
1410
|
+
"data-visible",
|
|
1411
|
+
"data-hidden",
|
|
1412
|
+
"data-disabled",
|
|
1413
|
+
"data-enabled",
|
|
1414
|
+
"data-loading",
|
|
1415
|
+
"data-error",
|
|
1416
|
+
"data-success",
|
|
1417
|
+
"data-highlighted",
|
|
1418
|
+
"data-focused",
|
|
1419
|
+
"data-hover",
|
|
1420
|
+
"data-orientation",
|
|
1421
|
+
"data-theme"
|
|
1422
|
+
];
|
|
1423
|
+
const Mt = [
|
|
1424
|
+
"data-radix-",
|
|
1425
|
+
"data-headlessui-",
|
|
1426
|
+
"data-reach-",
|
|
1427
|
+
"data-mui-",
|
|
1428
|
+
"data-chakra-",
|
|
1429
|
+
"data-mantine-",
|
|
1430
|
+
"data-tw-"
|
|
1431
|
+
];
|
|
1432
|
+
const It = [
|
|
1433
|
+
"data-testid",
|
|
1434
|
+
"data-test-id",
|
|
1435
|
+
"data-test",
|
|
1436
|
+
"data-cy",
|
|
1437
|
+
"data-qa",
|
|
1438
|
+
"data-automation-id",
|
|
1439
|
+
"data-id",
|
|
1440
|
+
"data-component",
|
|
1441
|
+
"data-entity-id",
|
|
1442
|
+
"data-product-id",
|
|
1443
|
+
"data-user-id"
|
|
1444
|
+
];
|
|
1445
|
+
const Rt = [
|
|
1446
|
+
"id",
|
|
1447
|
+
"name",
|
|
1448
|
+
"type",
|
|
1449
|
+
"placeholder",
|
|
1450
|
+
"title",
|
|
1451
|
+
"for",
|
|
1452
|
+
"alt",
|
|
1453
|
+
"href"
|
|
1454
|
+
];
|
|
1455
|
+
const Nt = [
|
|
1456
|
+
"disabled",
|
|
1457
|
+
"checked",
|
|
1458
|
+
"selected",
|
|
1459
|
+
"hidden",
|
|
1460
|
+
"readonly",
|
|
1461
|
+
"required",
|
|
1462
|
+
"value"
|
|
1463
|
+
];
|
|
1464
|
+
const Dt = [
|
|
1465
|
+
/^radix-/,
|
|
1466
|
+
/^headlessui-/,
|
|
1467
|
+
/^mui-/,
|
|
1468
|
+
/:\\w+:/
|
|
1469
|
+
// matches :ru:, :r1:, etc.
|
|
1470
|
+
];
|
|
1471
|
+
function Ht(n2, t2) {
|
|
1472
|
+
return wt.includes(n2) ? true : vt.includes(n2) || $t.includes(n2) || Mt.some((e2) => n2.startsWith(e2)) ? false : It.includes(n2) || n2.startsWith("data-") && n2.endsWith("-id") ? true : n2 === "id" ? !Dt.some((e2) => e2.test(t2)) : Rt.includes(n2) ? true : Nt.includes(n2) ? false : !!n2.startsWith("data-");
|
|
1473
|
+
}
|
|
1474
|
+
class Pt {
|
|
1475
|
+
constructor(t2, e2) {
|
|
1476
|
+
var _a2;
|
|
1477
|
+
this.includeUtilityClasses = (_a2 = t2.includeUtilityClasses) != null ? _a2 : false, this.cache = e2;
|
|
1478
|
+
}
|
|
1479
|
+
/**
|
|
1480
|
+
* Extracts semantic features from element
|
|
1481
|
+
* @param element - DOM element to extract from
|
|
1482
|
+
* @returns Semantic features object
|
|
1483
|
+
*/
|
|
1484
|
+
extract(t2) {
|
|
1485
|
+
if (this.cache) {
|
|
1486
|
+
const i2 = this.cache.getSemantics(t2);
|
|
1487
|
+
if (i2 !== void 0)
|
|
1488
|
+
return i2;
|
|
1489
|
+
}
|
|
1490
|
+
const e2 = {}, s2 = t2.id;
|
|
1491
|
+
if (s2 && !D(s2) && (e2.id = s2), t2.classList.length > 0) {
|
|
1492
|
+
const i2 = Array.from(t2.classList);
|
|
1493
|
+
if (this.includeUtilityClasses)
|
|
1494
|
+
e2.classes = i2;
|
|
1495
|
+
else {
|
|
1496
|
+
const { semantic: o2 } = At(i2);
|
|
1497
|
+
o2.length > 0 && (e2.classes = o2);
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
const r2 = this.extractAttributes(t2);
|
|
1501
|
+
Object.keys(r2).length > 0 && (e2.attributes = r2);
|
|
1502
|
+
const a2 = t2.getAttribute("role");
|
|
1503
|
+
if (a2 && (e2.role = a2), this.shouldExtractText(t2)) {
|
|
1504
|
+
const i2 = this.extractText(t2);
|
|
1505
|
+
i2 && (e2.text = i2);
|
|
1506
|
+
}
|
|
1507
|
+
return this.cache && this.cache.setSemantics(t2, e2), e2;
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Scores element based on semantic richness
|
|
1511
|
+
* @param element - Element to score
|
|
1512
|
+
* @returns Score from 0 to 1
|
|
1513
|
+
*/
|
|
1514
|
+
scoreElement(t2) {
|
|
1515
|
+
let e2 = 0.5;
|
|
1516
|
+
const s2 = this.extract(t2);
|
|
1517
|
+
return s2.id && (e2 += 0.15), s2.classes && s2.classes.length > 0 && (e2 += 0.1), s2.attributes && Object.keys(s2.attributes).length > 0 && (e2 += 0.1), s2.role && (e2 += 0.1), s2.text && (e2 += 0.05), Math.min(e2, 1);
|
|
1518
|
+
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Checks if attribute should be ignored
|
|
1521
|
+
* @param attrName - Attribute name
|
|
1522
|
+
* @returns True if should be ignored
|
|
1523
|
+
*/
|
|
1524
|
+
shouldIgnoreAttribute(t2) {
|
|
1525
|
+
return !!(B.has(t2) || t2.startsWith("on") || t2.startsWith("ng-") || t2.startsWith("_ng") || t2.startsWith("data-reactid") || t2.startsWith("data-react") || t2.startsWith("data-v-"));
|
|
1526
|
+
}
|
|
1527
|
+
/**
|
|
1528
|
+
* Gets attribute priority
|
|
1529
|
+
* @param attrName - Attribute name
|
|
1530
|
+
* @returns Priority number (higher = more priority)
|
|
1531
|
+
*/
|
|
1532
|
+
getAttributePriority(t2) {
|
|
1533
|
+
return w[t2] !== void 0 ? w[t2] : t2.startsWith("data-") ? w["data-*"] : t2.startsWith("aria-") ? w["aria-*"] : 0;
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Checks if attribute value is dynamic (should be ignored)
|
|
1537
|
+
* @param value - Attribute value
|
|
1538
|
+
* @returns True if value is dynamic
|
|
1539
|
+
*/
|
|
1540
|
+
isDynamicValue(t2) {
|
|
1541
|
+
return [
|
|
1542
|
+
/^[a-f0-9]{32,}$/i,
|
|
1543
|
+
// Long hashes
|
|
1544
|
+
/^\\d{10,}$/,
|
|
1545
|
+
// Timestamp
|
|
1546
|
+
/^(undefined|null|\\[object)/,
|
|
1547
|
+
// JS artifacts
|
|
1548
|
+
/^{{.*}}$/
|
|
1549
|
+
// Template literals
|
|
1550
|
+
].some((s2) => s2.test(t2));
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Extracts relevant semantic attributes from element
|
|
1554
|
+
* Iterates through all attributes and filters by priority
|
|
1555
|
+
*/
|
|
1556
|
+
extractAttributes(t2) {
|
|
1557
|
+
const e2 = {};
|
|
1558
|
+
for (const s2 of Array.from(t2.attributes)) {
|
|
1559
|
+
const r2 = s2.name;
|
|
1560
|
+
if (this.shouldIgnoreAttribute(r2) || !Ht(r2, s2.value) || G.has(r2) && V(s2.value) || this.getAttributePriority(r2) === 0)
|
|
1561
|
+
continue;
|
|
1562
|
+
const i2 = r2 === "href" || r2 === "src" ? k(r2, s2.value) : s2.value;
|
|
1563
|
+
!i2 || i2.trim() === "" || this.isDynamicValue(i2) || (e2[r2] = i2);
|
|
1564
|
+
}
|
|
1565
|
+
return e2;
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1568
|
+
* Extracts and normalizes text content
|
|
1569
|
+
*/
|
|
1570
|
+
extractText(t2) {
|
|
1571
|
+
const e2 = this.getDirectTextContent(t2);
|
|
1572
|
+
if (!e2)
|
|
1573
|
+
return null;
|
|
1574
|
+
const s2 = Q(e2);
|
|
1575
|
+
if (!s2)
|
|
1576
|
+
return null;
|
|
1577
|
+
const r2 = 100, a2 = e2.length > r2 ? e2.slice(0, r2) + "..." : e2, i2 = s2.length > r2 ? s2.slice(0, r2) + "..." : s2;
|
|
1578
|
+
return {
|
|
1579
|
+
raw: a2,
|
|
1580
|
+
normalized: i2
|
|
1581
|
+
};
|
|
1582
|
+
}
|
|
1583
|
+
/**
|
|
1584
|
+
* Gets direct text content excluding child elements
|
|
1585
|
+
*/
|
|
1586
|
+
getDirectTextContent(t2) {
|
|
1587
|
+
var _a2;
|
|
1588
|
+
const e2 = [];
|
|
1589
|
+
for (const s2 of Array.from(t2.childNodes))
|
|
1590
|
+
if (s2.nodeType === Node.TEXT_NODE && s2.textContent) {
|
|
1591
|
+
const r2 = s2.textContent.trim();
|
|
1592
|
+
r2 && e2.push(r2);
|
|
1593
|
+
}
|
|
1594
|
+
return e2.length > 0 ? e2.join(" ") : (_a2 = t2.textContent) != null ? _a2 : null;
|
|
1595
|
+
}
|
|
1596
|
+
/**
|
|
1597
|
+
* Determines if text should be extracted for this element
|
|
1598
|
+
*/
|
|
1599
|
+
shouldExtractText(t2) {
|
|
1600
|
+
const e2 = t2.tagName.toLowerCase();
|
|
1601
|
+
return [
|
|
1602
|
+
"button",
|
|
1603
|
+
"a",
|
|
1604
|
+
"label",
|
|
1605
|
+
"h1",
|
|
1606
|
+
"h2",
|
|
1607
|
+
"h3",
|
|
1608
|
+
"h4",
|
|
1609
|
+
"h5",
|
|
1610
|
+
"h6",
|
|
1611
|
+
"p",
|
|
1612
|
+
"span",
|
|
1613
|
+
"li",
|
|
1614
|
+
"th",
|
|
1615
|
+
"td",
|
|
1616
|
+
"dt",
|
|
1617
|
+
"dd",
|
|
1618
|
+
"legend",
|
|
1619
|
+
"figcaption",
|
|
1620
|
+
"summary"
|
|
1621
|
+
].includes(e2);
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
class kt {
|
|
1625
|
+
/**
|
|
1626
|
+
* Generates fingerprint for SVG element
|
|
1627
|
+
* @param element - SVG element to fingerprint
|
|
1628
|
+
* @returns SVG fingerprint object
|
|
1629
|
+
*/
|
|
1630
|
+
fingerprint(t2) {
|
|
1631
|
+
const e2 = t2.tagName.toLowerCase(), s2 = this.getShape(e2), r2 = {
|
|
1632
|
+
shape: s2,
|
|
1633
|
+
hasAnimation: this.hasAnimation(t2)
|
|
1634
|
+
};
|
|
1635
|
+
if (s2 === "path") {
|
|
1636
|
+
const o2 = t2.getAttribute("d");
|
|
1637
|
+
o2 && (r2.dHash = this.computePathHash(o2));
|
|
1638
|
+
} else
|
|
1639
|
+
["circle", "rect", "ellipse", "line"].includes(s2) && (r2.geomHash = this.computeGeomHash(t2, s2));
|
|
1640
|
+
const a2 = t2.getAttribute("role");
|
|
1641
|
+
a2 && (r2.role = a2);
|
|
1642
|
+
const i2 = t2.querySelector("title");
|
|
1643
|
+
return (i2 == null ? void 0 : i2.textContent) && (r2.titleText = i2.textContent.trim()), r2;
|
|
1644
|
+
}
|
|
1645
|
+
/**
|
|
1646
|
+
* Computes hash from path data (first N commands)
|
|
1647
|
+
* @param d - SVG path d attribute value
|
|
1648
|
+
* @returns Hash string
|
|
1649
|
+
*/
|
|
1650
|
+
computePathHash(t2) {
|
|
1651
|
+
const e2 = this.normalizePathData(t2);
|
|
1652
|
+
return this.simpleHash(e2);
|
|
1653
|
+
}
|
|
1654
|
+
/**
|
|
1655
|
+
* Gets the shape type from tag name
|
|
1656
|
+
*/
|
|
1657
|
+
getShape(t2) {
|
|
1658
|
+
var _a2;
|
|
1659
|
+
return (_a2 = [
|
|
1660
|
+
"path",
|
|
1661
|
+
"circle",
|
|
1662
|
+
"rect",
|
|
1663
|
+
"line",
|
|
1664
|
+
"polyline",
|
|
1665
|
+
"polygon",
|
|
1666
|
+
"ellipse",
|
|
1667
|
+
"g",
|
|
1668
|
+
"text",
|
|
1669
|
+
"use",
|
|
1670
|
+
"svg"
|
|
1671
|
+
].find((s2) => s2 === t2)) != null ? _a2 : "path";
|
|
1672
|
+
}
|
|
1673
|
+
/**
|
|
1674
|
+
* Normalizes path data for consistent hashing
|
|
1675
|
+
*/
|
|
1676
|
+
normalizePathData(t2) {
|
|
1677
|
+
var _a2;
|
|
1678
|
+
return ((_a2 = t2.match(/[MLHVCSQTAZ][^MLHVCSQTAZ]*/gi)) != null ? _a2 : []).slice(0, 5).map((r2) => r2.trim().replace(/(-?\\d+\\.?\\d*)/g, (a2) => parseFloat(a2).toFixed(1))).join(" ");
|
|
1679
|
+
}
|
|
1680
|
+
/**
|
|
1681
|
+
* Computes geometry hash for non-path shapes
|
|
1682
|
+
*/
|
|
1683
|
+
computeGeomHash(t2, e2) {
|
|
1684
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1685
|
+
const s2 = [];
|
|
1686
|
+
switch (e2) {
|
|
1687
|
+
case "circle":
|
|
1688
|
+
s2.push(\`r=\${(_a2 = t2.getAttribute("r")) != null ? _a2 : "0"}\`);
|
|
1689
|
+
break;
|
|
1690
|
+
case "rect":
|
|
1691
|
+
{
|
|
1692
|
+
const r2 = parseFloat((_b = t2.getAttribute("width")) != null ? _b : "0"), a2 = parseFloat((_c = t2.getAttribute("height")) != null ? _c : "0");
|
|
1693
|
+
r2 > 0 && a2 > 0 && s2.push(\`ratio=\${(r2 / a2).toFixed(2)}\`);
|
|
1694
|
+
}
|
|
1695
|
+
break;
|
|
1696
|
+
case "ellipse":
|
|
1697
|
+
{
|
|
1698
|
+
const r2 = parseFloat((_d = t2.getAttribute("rx")) != null ? _d : "0"), a2 = parseFloat((_e = t2.getAttribute("ry")) != null ? _e : "0");
|
|
1699
|
+
r2 > 0 && a2 > 0 && s2.push(\`ratio=\${(r2 / a2).toFixed(2)}\`);
|
|
1700
|
+
}
|
|
1701
|
+
break;
|
|
1702
|
+
case "line":
|
|
1703
|
+
{
|
|
1704
|
+
const r2 = parseFloat((_f = t2.getAttribute("x1")) != null ? _f : "0"), a2 = parseFloat((_g = t2.getAttribute("y1")) != null ? _g : "0"), i2 = parseFloat((_h = t2.getAttribute("x2")) != null ? _h : "0"), o2 = parseFloat((_i = t2.getAttribute("y2")) != null ? _i : "0"), l2 = Math.atan2(o2 - a2, i2 - r2);
|
|
1705
|
+
s2.push(\`angle=\${l2.toFixed(2)}\`);
|
|
1706
|
+
}
|
|
1707
|
+
break;
|
|
1708
|
+
}
|
|
1709
|
+
return this.simpleHash(s2.join(";"));
|
|
1710
|
+
}
|
|
1711
|
+
/**
|
|
1712
|
+
* Detects animations on SVG element
|
|
1713
|
+
*/
|
|
1714
|
+
hasAnimation(t2) {
|
|
1715
|
+
if (t2.querySelector("animate, animateTransform, animateMotion"))
|
|
1716
|
+
return true;
|
|
1717
|
+
const e2 = t2.ownerDocument;
|
|
1718
|
+
if (e2 == null ? void 0 : e2.defaultView)
|
|
1719
|
+
try {
|
|
1720
|
+
const s2 = e2.defaultView.getComputedStyle(t2);
|
|
1721
|
+
if (s2.animationName !== "none" || s2.transitionProperty !== "all" && s2.transitionProperty !== "none")
|
|
1722
|
+
return true;
|
|
1723
|
+
} catch (e) {
|
|
1724
|
+
}
|
|
1725
|
+
return false;
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Simple hash function for fingerprinting (not cryptographic)
|
|
1729
|
+
*/
|
|
1730
|
+
simpleHash(t2) {
|
|
1731
|
+
let e2 = 0;
|
|
1732
|
+
for (let s2 = 0; s2 < t2.length; s2++) {
|
|
1733
|
+
const r2 = t2.charCodeAt(s2);
|
|
1734
|
+
e2 = (e2 << 5) - e2 + r2, e2 = e2 & e2;
|
|
1735
|
+
}
|
|
1736
|
+
return Math.abs(e2).toString(16).padStart(8, "0");
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
function _t(n2, t2 = 0) {
|
|
1740
|
+
const e2 = n2.anchor.score, s2 = n2.path.length > 0 ? n2.path.reduce((o2, l2) => o2 + l2.score, 0) / n2.path.length : 0.5, r2 = n2.target.score, a2 = e2 * L.ANCHOR + s2 * L.PATH + r2 * L.TARGET + t2 * L.UNIQUENESS, i2 = n2.anchor.degraded ? 0.2 : 0;
|
|
1741
|
+
return Math.max(0, Math.min(1, a2 - i2));
|
|
1742
|
+
}
|
|
1743
|
+
class qt {
|
|
1744
|
+
constructor(t2) {
|
|
1745
|
+
this.cache = /* @__PURE__ */ new Map(), this.maxSize = t2;
|
|
1746
|
+
}
|
|
1747
|
+
get(t2) {
|
|
1748
|
+
const e2 = this.cache.get(t2);
|
|
1749
|
+
if (e2 !== void 0)
|
|
1750
|
+
return this.cache.delete(t2), this.cache.set(t2, e2), e2;
|
|
1751
|
+
}
|
|
1752
|
+
set(t2, e2) {
|
|
1753
|
+
if (this.cache.has(t2))
|
|
1754
|
+
this.cache.delete(t2);
|
|
1755
|
+
else if (this.cache.size >= this.maxSize) {
|
|
1756
|
+
const s2 = this.cache.keys().next().value;
|
|
1757
|
+
s2 !== void 0 && this.cache.delete(s2);
|
|
1758
|
+
}
|
|
1759
|
+
this.cache.set(t2, e2);
|
|
1760
|
+
}
|
|
1761
|
+
has(t2) {
|
|
1762
|
+
return this.cache.has(t2);
|
|
1763
|
+
}
|
|
1764
|
+
delete(t2) {
|
|
1765
|
+
this.cache.delete(t2);
|
|
1766
|
+
}
|
|
1767
|
+
clear() {
|
|
1768
|
+
this.cache.clear();
|
|
1769
|
+
}
|
|
1770
|
+
get size() {
|
|
1771
|
+
return this.cache.size;
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
class Lt {
|
|
1775
|
+
constructor(t2 = {}) {
|
|
1776
|
+
var _a2, _b;
|
|
1777
|
+
this.eidCache = /* @__PURE__ */ new WeakMap(), this.selectorResultCache = new qt(
|
|
1778
|
+
(_a2 = t2.maxSelectorCacheSize) != null ? _a2 : 1e3
|
|
1779
|
+
), this.anchorCache = /* @__PURE__ */ new WeakMap(), this.semanticsCache = /* @__PURE__ */ new WeakMap(), this.stats = {
|
|
1780
|
+
eidHits: 0,
|
|
1781
|
+
eidMisses: 0,
|
|
1782
|
+
selectorHits: 0,
|
|
1783
|
+
selectorMisses: 0,
|
|
1784
|
+
anchorHits: 0,
|
|
1785
|
+
anchorMisses: 0,
|
|
1786
|
+
semanticsHits: 0,
|
|
1787
|
+
semanticsMisses: 0,
|
|
1788
|
+
selectorCacheSize: 0,
|
|
1789
|
+
maxSelectorCacheSize: (_b = t2.maxSelectorCacheSize) != null ? _b : 1e3
|
|
1790
|
+
};
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Get cached EID for element
|
|
1794
|
+
*/
|
|
1795
|
+
getEID(t2) {
|
|
1796
|
+
const e2 = this.eidCache.get(t2);
|
|
1797
|
+
if (e2 !== void 0)
|
|
1798
|
+
return this.stats.eidHits++, e2;
|
|
1799
|
+
this.stats.eidMisses++;
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Cache EID for element
|
|
1803
|
+
*/
|
|
1804
|
+
setEID(t2, e2) {
|
|
1805
|
+
this.eidCache.set(t2, e2);
|
|
1806
|
+
}
|
|
1807
|
+
/**
|
|
1808
|
+
* Get cached selector results
|
|
1809
|
+
*/
|
|
1810
|
+
getSelectorResults(t2) {
|
|
1811
|
+
const e2 = this.selectorResultCache.get(t2);
|
|
1812
|
+
if (e2 !== void 0)
|
|
1813
|
+
return this.stats.selectorHits++, this.stats.selectorCacheSize = this.selectorResultCache.size, e2;
|
|
1814
|
+
this.stats.selectorMisses++, this.stats.selectorCacheSize = this.selectorResultCache.size;
|
|
1815
|
+
}
|
|
1816
|
+
/**
|
|
1817
|
+
* Cache selector results
|
|
1818
|
+
*/
|
|
1819
|
+
setSelectorResults(t2, e2) {
|
|
1820
|
+
this.selectorResultCache.set(t2, e2), this.stats.selectorCacheSize = this.selectorResultCache.size;
|
|
1821
|
+
}
|
|
1822
|
+
/**
|
|
1823
|
+
* Get cached anchor result
|
|
1824
|
+
*/
|
|
1825
|
+
getAnchor(t2) {
|
|
1826
|
+
if (this.anchorCache.has(t2))
|
|
1827
|
+
return this.stats.anchorHits++, this.anchorCache.get(t2);
|
|
1828
|
+
this.stats.anchorMisses++;
|
|
1829
|
+
}
|
|
1830
|
+
/**
|
|
1831
|
+
* Cache anchor result
|
|
1832
|
+
*/
|
|
1833
|
+
setAnchor(t2, e2) {
|
|
1834
|
+
this.anchorCache.set(t2, e2);
|
|
1835
|
+
}
|
|
1836
|
+
/**
|
|
1837
|
+
* Get cached semantics
|
|
1838
|
+
*/
|
|
1839
|
+
getSemantics(t2) {
|
|
1840
|
+
const e2 = this.semanticsCache.get(t2);
|
|
1841
|
+
if (e2 !== void 0)
|
|
1842
|
+
return this.stats.semanticsHits++, e2;
|
|
1843
|
+
this.stats.semanticsMisses++;
|
|
1844
|
+
}
|
|
1845
|
+
/**
|
|
1846
|
+
* Cache semantics
|
|
1847
|
+
*/
|
|
1848
|
+
setSemantics(t2, e2) {
|
|
1849
|
+
this.semanticsCache.set(t2, e2);
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* Clear all caches
|
|
1853
|
+
*/
|
|
1854
|
+
clear() {
|
|
1855
|
+
this.selectorResultCache.clear(), this.stats.selectorCacheSize = 0, this.stats = {
|
|
1856
|
+
eidHits: 0,
|
|
1857
|
+
eidMisses: 0,
|
|
1858
|
+
selectorHits: 0,
|
|
1859
|
+
selectorMisses: 0,
|
|
1860
|
+
anchorHits: 0,
|
|
1861
|
+
anchorMisses: 0,
|
|
1862
|
+
semanticsHits: 0,
|
|
1863
|
+
semanticsMisses: 0,
|
|
1864
|
+
selectorCacheSize: 0,
|
|
1865
|
+
maxSelectorCacheSize: this.stats.maxSelectorCacheSize
|
|
1866
|
+
};
|
|
1867
|
+
}
|
|
1868
|
+
/**
|
|
1869
|
+
* Invalidate cache for a specific element
|
|
1870
|
+
* Note: WeakMaps don't support deletion, but we can clear selector cache
|
|
1871
|
+
* if needed. This method is mainly for future extensibility.
|
|
1872
|
+
*/
|
|
1873
|
+
invalidateElement(t2) {
|
|
1874
|
+
}
|
|
1875
|
+
/**
|
|
1876
|
+
* Invalidate a specific selector from cache
|
|
1877
|
+
*/
|
|
1878
|
+
invalidateSelector(t2) {
|
|
1879
|
+
this.selectorResultCache.delete(t2), this.stats.selectorCacheSize = this.selectorResultCache.size;
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* Get cache statistics
|
|
1883
|
+
*/
|
|
1884
|
+
getStats() {
|
|
1885
|
+
return __spreadProps(__spreadValues({}, this.stats), {
|
|
1886
|
+
selectorCacheSize: this.selectorResultCache.size
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
/**
|
|
1890
|
+
* Get cache hit rate for EID cache
|
|
1891
|
+
*/
|
|
1892
|
+
getEIDHitRate() {
|
|
1893
|
+
const t2 = this.stats.eidHits + this.stats.eidMisses;
|
|
1894
|
+
return t2 > 0 ? this.stats.eidHits / t2 : 0;
|
|
1895
|
+
}
|
|
1896
|
+
/**
|
|
1897
|
+
* Get cache hit rate for selector cache
|
|
1898
|
+
*/
|
|
1899
|
+
getSelectorHitRate() {
|
|
1900
|
+
const t2 = this.stats.selectorHits + this.stats.selectorMisses;
|
|
1901
|
+
return t2 > 0 ? this.stats.selectorHits / t2 : 0;
|
|
1902
|
+
}
|
|
1903
|
+
/**
|
|
1904
|
+
* Get cache hit rate for anchor cache
|
|
1905
|
+
*/
|
|
1906
|
+
getAnchorHitRate() {
|
|
1907
|
+
const t2 = this.stats.anchorHits + this.stats.anchorMisses;
|
|
1908
|
+
return t2 > 0 ? this.stats.anchorHits / t2 : 0;
|
|
1909
|
+
}
|
|
1910
|
+
/**
|
|
1911
|
+
* Get cache hit rate for semantics cache
|
|
1912
|
+
*/
|
|
1913
|
+
getSemanticsHitRate() {
|
|
1914
|
+
const t2 = this.stats.semanticsHits + this.stats.semanticsMisses;
|
|
1915
|
+
return t2 > 0 ? this.stats.semanticsHits / t2 : 0;
|
|
1916
|
+
}
|
|
1917
|
+
/**
|
|
1918
|
+
* Get overall cache hit rate
|
|
1919
|
+
*/
|
|
1920
|
+
getOverallHitRate() {
|
|
1921
|
+
const t2 = this.stats.eidHits + this.stats.selectorHits + this.stats.anchorHits + this.stats.semanticsHits, e2 = this.stats.eidMisses + this.stats.selectorMisses + this.stats.anchorMisses + this.stats.semanticsMisses, s2 = t2 + e2;
|
|
1922
|
+
return s2 > 0 ? t2 / s2 : 0;
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
function Ot(n2) {
|
|
1926
|
+
return new Lt(n2);
|
|
1927
|
+
}
|
|
1928
|
+
let O = null;
|
|
1929
|
+
function Z() {
|
|
1930
|
+
return O || (O = Ot()), O;
|
|
1931
|
+
}
|
|
1932
|
+
function Y(n2, t2 = {}) {
|
|
1933
|
+
var _a3, _b, _c, _d;
|
|
1934
|
+
var _a2;
|
|
1935
|
+
if (!n2 || !n2.ownerDocument || !n2.isConnected)
|
|
1936
|
+
return null;
|
|
1937
|
+
const e2 = __spreadValues(__spreadValues({}, ut), t2), s2 = (_a3 = e2.cache) != null ? _a3 : Z(), r2 = s2.getEID(n2);
|
|
1938
|
+
if (r2 !== void 0)
|
|
1939
|
+
return r2;
|
|
1940
|
+
const a2 = new ft(e2, s2), i2 = new xt(e2, s2), o2 = new Pt(e2, s2), l2 = new kt(), u2 = a2.findAnchor(n2);
|
|
1941
|
+
if (!u2 && !e2.fallbackToBody)
|
|
1942
|
+
return null;
|
|
1943
|
+
const d = (_c = (_b = u2 == null ? void 0 : u2.element) != null ? _b : (_a2 = n2.ownerDocument) == null ? void 0 : _a2.body) != null ? _c : null;
|
|
1944
|
+
if (!d)
|
|
1945
|
+
return null;
|
|
1946
|
+
const c2 = !u2 || u2.tier === "C", h = d.tagName.toLowerCase(), g = d.parentElement;
|
|
1947
|
+
let f2;
|
|
1948
|
+
if (g && h !== "body" && h !== "html") {
|
|
1949
|
+
const T = Array.from(g.children).indexOf(d);
|
|
1950
|
+
T !== -1 && (f2 = T + 1);
|
|
1951
|
+
}
|
|
1952
|
+
const p = o2.extract(d), m = {
|
|
1953
|
+
tag: d.tagName.toLowerCase(),
|
|
1954
|
+
semantics: p,
|
|
1955
|
+
score: (_d = u2 == null ? void 0 : u2.score) != null ? _d : I.DEGRADED_SCORE,
|
|
1956
|
+
degraded: c2,
|
|
1957
|
+
nthChild: f2
|
|
1958
|
+
}, b = i2.buildPath(d, n2, o2), y = o2.extract(n2);
|
|
1959
|
+
e2.enableSvgFingerprint && zt(n2) && (y.svg = l2.fingerprint(n2));
|
|
1960
|
+
const v2 = n2.parentElement;
|
|
1961
|
+
let A;
|
|
1962
|
+
if (v2) {
|
|
1963
|
+
const T = Array.from(v2.children).indexOf(n2);
|
|
1964
|
+
T !== -1 && (A = T + 1);
|
|
1965
|
+
}
|
|
1966
|
+
const S = {
|
|
1967
|
+
tag: n2.tagName.toLowerCase(),
|
|
1968
|
+
semantics: y,
|
|
1969
|
+
score: o2.scoreElement(n2),
|
|
1970
|
+
nthChild: A
|
|
1971
|
+
}, $ = [], M = {
|
|
1972
|
+
onMultiple: "best-score",
|
|
1973
|
+
onMissing: "anchor-only",
|
|
1974
|
+
maxDepth: 3
|
|
1975
|
+
}, H = m.degraded || b.degraded, E = Ut(m.degraded, b), x2 = {
|
|
1976
|
+
version: "1.0",
|
|
1977
|
+
anchor: m,
|
|
1978
|
+
path: b.path,
|
|
1979
|
+
target: S,
|
|
1980
|
+
constraints: $,
|
|
1981
|
+
fallback: M,
|
|
1982
|
+
meta: {
|
|
1983
|
+
confidence: 0,
|
|
1984
|
+
// Calculated below
|
|
1985
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1986
|
+
generator: "dom-eid@1.0",
|
|
1987
|
+
source: e2.source,
|
|
1988
|
+
degraded: H,
|
|
1989
|
+
degradationReason: E
|
|
1990
|
+
}
|
|
1991
|
+
};
|
|
1992
|
+
return x2.meta.confidence = _t(x2), x2.meta.confidence < e2.confidenceThreshold ? null : (s2.setEID(n2, x2), x2);
|
|
1993
|
+
}
|
|
1994
|
+
function zt(n2) {
|
|
1995
|
+
return n2.namespaceURI === "http://www.w3.org/2000/svg" || n2.tagName.toLowerCase() === "svg" || n2 instanceof SVGElement;
|
|
1996
|
+
}
|
|
1997
|
+
function Ut(n2, t2) {
|
|
1998
|
+
if (n2 && t2.degraded)
|
|
1999
|
+
return "anchor-and-path-degraded";
|
|
2000
|
+
if (n2)
|
|
2001
|
+
return "no-semantic-anchor";
|
|
2002
|
+
if (t2.degraded)
|
|
2003
|
+
return t2.degradationReason;
|
|
2004
|
+
}
|
|
2005
|
+
const rt = {
|
|
2006
|
+
maxClasses: 2,
|
|
2007
|
+
maxAttributes: 5,
|
|
2008
|
+
includeText: true,
|
|
2009
|
+
maxTextLength: 50,
|
|
2010
|
+
simplifyTarget: true,
|
|
2011
|
+
includeConstraints: true
|
|
2012
|
+
};
|
|
2013
|
+
function et(n2) {
|
|
2014
|
+
return n2 === "id" ? 101 : w[n2] !== void 0 ? w[n2] : n2.startsWith("data-") ? w["data-*"] : n2.startsWith("aria-") ? w["aria-*"] : 0;
|
|
2015
|
+
}
|
|
2016
|
+
function Vt(n2) {
|
|
2017
|
+
return ["id", "data-testid", "data-qa", "data-cy", "href", "text", "role"].includes(n2);
|
|
2018
|
+
}
|
|
2019
|
+
function Qt(n2) {
|
|
2020
|
+
return !!(/@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}/.test(n2) || /(\\+?\\d{1,3}[-.\\s]?)?\\(?\\d{3}\\)?[-.\\s]?\\d{3}[-.\\s]?\\d{4}/.test(n2) || /\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}[-\\s]?\\d{4}/.test(n2));
|
|
2021
|
+
}
|
|
2022
|
+
function Zt(n2, t2) {
|
|
2023
|
+
const e2 = __spreadValues(__spreadValues({}, rt), t2), s2 = \`v\${n2.version}\`, r2 = U(n2.anchor, false, e2), a2 = n2.path.length > 0 ? n2.path.map((l2) => U(l2, false, e2)).join(" > ") + " > " : "", i2 = U(n2.target, true, e2), o2 = e2.includeConstraints ? Xt(n2) : "";
|
|
2024
|
+
return \`\${s2}: \${r2} :: \${a2}\${i2}\${o2}\`;
|
|
2025
|
+
}
|
|
2026
|
+
function U(n2, t2 = false, e2 = rt) {
|
|
2027
|
+
const { tag: s2, semantics: r2 } = n2;
|
|
2028
|
+
let a2 = s2;
|
|
2029
|
+
const i2 = [], o2 = __spreadValues({}, r2.attributes);
|
|
2030
|
+
r2.id && (o2.id = r2.id), r2.role && !o2.role && (o2.role = r2.role);
|
|
2031
|
+
const l2 = Object.entries(o2).map(([c2, h]) => {
|
|
2032
|
+
const g = et(c2), f2 = c2 === "href" || c2 === "src" ? k(c2, h) : h;
|
|
2033
|
+
return { name: c2, value: f2, priority: g };
|
|
2034
|
+
}).filter((c2) => c2.name !== "id" && c2.name !== "class" && B.has(c2.name) || G.has(c2.name) && V(c2.value) ? false : c2.priority > 0 || c2.name === "role" || c2.name === "id");
|
|
2035
|
+
l2.sort((c2, h) => h.priority - c2.priority);
|
|
2036
|
+
const u2 = l2.slice(0, e2.maxAttributes);
|
|
2037
|
+
u2.sort((c2, h) => c2.name.localeCompare(h.name));
|
|
2038
|
+
for (const { name: c2, value: h } of u2)
|
|
2039
|
+
i2.push(\`\${c2}="\${j(h)}"\`);
|
|
2040
|
+
if (e2.includeText && r2.text && !Qt(r2.text.normalized)) {
|
|
2041
|
+
const c2 = r2.text.normalized;
|
|
2042
|
+
c2.length > 0 && c2.length <= e2.maxTextLength && i2.push(\`text="\${j(c2)}"\`);
|
|
2043
|
+
}
|
|
2044
|
+
let d = i2;
|
|
2045
|
+
if (i2.length > 0 && (t2 && e2.simplifyTarget && r2.id && (d = i2.filter((c2) => {
|
|
2046
|
+
const h = c2.split("=")[0];
|
|
2047
|
+
return et(h) >= 60 || h === "text" || h === "id" || h === "role";
|
|
2048
|
+
})), d.length > 0 && d.sort((c2, h) => c2.localeCompare(h))), r2.classes && r2.classes.length > 0) {
|
|
2049
|
+
const c2 = N(r2.classes), h = !!r2.id || i2.some(
|
|
2050
|
+
(f2) => f2.startsWith("href=") || f2.startsWith("data-testid=") || f2.startsWith("text=") || f2.startsWith("role=")
|
|
2051
|
+
);
|
|
2052
|
+
if (!(t2 && e2.simplifyTarget && h) && c2.length > 0) {
|
|
2053
|
+
const f2 = c2.sort().slice(0, e2.maxClasses);
|
|
2054
|
+
a2 += f2.map((p) => \`.\${p}\`).join("");
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
if (d.length > 0 && (a2 += \`[\${d.join(",")}]\`), "nthChild" in n2 && n2.nthChild) {
|
|
2058
|
+
const c2 = !!r2.id || r2.attributes && Object.keys(r2.attributes).some(Vt);
|
|
2059
|
+
t2 && e2.simplifyTarget && c2 || (a2 += \`#\${n2.nthChild}\`);
|
|
2060
|
+
}
|
|
2061
|
+
return a2;
|
|
2062
|
+
}
|
|
2063
|
+
function Xt(n2) {
|
|
2064
|
+
if (!n2.constraints || n2.constraints.length === 0)
|
|
2065
|
+
return "";
|
|
2066
|
+
const t2 = [];
|
|
2067
|
+
for (const e2 of n2.constraints)
|
|
2068
|
+
switch (e2.type) {
|
|
2069
|
+
case "uniqueness":
|
|
2070
|
+
t2.push("unique=true");
|
|
2071
|
+
break;
|
|
2072
|
+
case "position":
|
|
2073
|
+
e2.params && e2.params.strategy && t2.push(\`pos=\${e2.params.strategy}\`);
|
|
2074
|
+
break;
|
|
2075
|
+
case "text-proximity":
|
|
2076
|
+
if (e2.params && e2.params.reference) {
|
|
2077
|
+
const s2 = j(String(e2.params.reference));
|
|
2078
|
+
t2.push(\`text="\${s2}"\`);
|
|
2079
|
+
}
|
|
2080
|
+
break;
|
|
2081
|
+
}
|
|
2082
|
+
return t2.length === 0 ? "" : \` {\${t2.join(",")}}\`;
|
|
2083
|
+
}
|
|
2084
|
+
function j(n2) {
|
|
2085
|
+
return n2.replace(/\\\\/g, "\\\\\\\\").replace(/"/g, '\\\\"').replace(/>/g, "\\\\>").replace(/:/g, "\\\\:");
|
|
2086
|
+
}
|
|
2087
|
+
function le(n2, t2, e2) {
|
|
2088
|
+
const s2 = Y(n2, t2);
|
|
2089
|
+
return s2 ? Zt(s2, e2) : null;
|
|
2090
|
+
}
|
|
882
2091
|
let _id = 1;
|
|
883
2092
|
const tagNameRegex = new RegExp("[^a-z0-9-_:]");
|
|
884
2093
|
const IGNORED_NODE = -2;
|
|
@@ -1000,6 +2209,8 @@ function ignoreAttribute(tagName, name, _value) {
|
|
|
1000
2209
|
return (tagName === "video" || tagName === "audio") && name === "autoplay";
|
|
1001
2210
|
}
|
|
1002
2211
|
function isExcludeAttribute(name, exclude) {
|
|
2212
|
+
if (!exclude)
|
|
2213
|
+
return false;
|
|
1003
2214
|
return typeof exclude === "string" ? name.includes(exclude) : exclude.test(name);
|
|
1004
2215
|
}
|
|
1005
2216
|
function _isBlockedElement(element, blockClass, blockSelector) {
|
|
@@ -1510,7 +2721,8 @@ function serializeNodeWithId(n2, options) {
|
|
|
1510
2721
|
stylesheetLoadTimeout = 5e3,
|
|
1511
2722
|
keepIframeSrcFn = () => false,
|
|
1512
2723
|
newlyAddedElement = false,
|
|
1513
|
-
cssCaptured = false
|
|
2724
|
+
cssCaptured = false,
|
|
2725
|
+
selectorOptions
|
|
1514
2726
|
} = options;
|
|
1515
2727
|
let { needsMask } = options;
|
|
1516
2728
|
let { preserveWhiteSpace = true } = options;
|
|
@@ -1555,11 +2767,20 @@ function serializeNodeWithId(n2, options) {
|
|
|
1555
2767
|
}
|
|
1556
2768
|
const serializedNode = Object.assign(_serializedNode, { id });
|
|
1557
2769
|
if (isElement(n2) || n2.nodeType === Node.TEXT_NODE) {
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
2770
|
+
if (isElement(n2) && selectorOptions !== null && selectorOptions !== void 0) {
|
|
2771
|
+
try {
|
|
2772
|
+
const seqlGeneratorOptions = {
|
|
2773
|
+
maxPathDepth: selectorOptions.maxPathDepth,
|
|
2774
|
+
enableSvgFingerprint: selectorOptions.enableSvgFingerprint,
|
|
2775
|
+
confidenceThreshold: selectorOptions.confidenceThreshold,
|
|
2776
|
+
fallbackToBody: selectorOptions.fallbackToBody
|
|
2777
|
+
};
|
|
2778
|
+
const selector = le(n2, seqlGeneratorOptions);
|
|
2779
|
+
if (selector) {
|
|
2780
|
+
serializedNode.selector = selector;
|
|
2781
|
+
}
|
|
2782
|
+
} catch (error) {
|
|
2783
|
+
console.warn("Failed to generate SEQL selector:", error);
|
|
1563
2784
|
}
|
|
1564
2785
|
}
|
|
1565
2786
|
if (n2.nodeType === Node.TEXT_NODE) {
|
|
@@ -1614,7 +2835,8 @@ function serializeNodeWithId(n2, options) {
|
|
|
1614
2835
|
onStylesheetLoad,
|
|
1615
2836
|
stylesheetLoadTimeout,
|
|
1616
2837
|
keepIframeSrcFn,
|
|
1617
|
-
cssCaptured: false
|
|
2838
|
+
cssCaptured: false,
|
|
2839
|
+
selectorOptions
|
|
1618
2840
|
};
|
|
1619
2841
|
if (serializedNode.type === NodeType$3.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0)
|
|
1620
2842
|
;
|
|
@@ -1674,7 +2896,8 @@ function serializeNodeWithId(n2, options) {
|
|
|
1674
2896
|
iframeLoadTimeout,
|
|
1675
2897
|
onStylesheetLoad,
|
|
1676
2898
|
stylesheetLoadTimeout,
|
|
1677
|
-
keepIframeSrcFn
|
|
2899
|
+
keepIframeSrcFn,
|
|
2900
|
+
selectorOptions
|
|
1678
2901
|
});
|
|
1679
2902
|
if (serializedIframeNode) {
|
|
1680
2903
|
onIframeLoad(
|
|
@@ -1716,7 +2939,8 @@ function serializeNodeWithId(n2, options) {
|
|
|
1716
2939
|
iframeLoadTimeout,
|
|
1717
2940
|
onStylesheetLoad,
|
|
1718
2941
|
stylesheetLoadTimeout,
|
|
1719
|
-
keepIframeSrcFn
|
|
2942
|
+
keepIframeSrcFn,
|
|
2943
|
+
selectorOptions
|
|
1720
2944
|
});
|
|
1721
2945
|
if (serializedLinkNode) {
|
|
1722
2946
|
onStylesheetLoad(
|
|
@@ -1732,6 +2956,7 @@ function serializeNodeWithId(n2, options) {
|
|
|
1732
2956
|
return serializedNode;
|
|
1733
2957
|
}
|
|
1734
2958
|
function snapshot(n2, options) {
|
|
2959
|
+
var _a2, _b, _c, _d;
|
|
1735
2960
|
const {
|
|
1736
2961
|
mirror: mirror2 = new Mirror(),
|
|
1737
2962
|
blockClass = "rr-block",
|
|
@@ -1753,7 +2978,8 @@ function snapshot(n2, options) {
|
|
|
1753
2978
|
iframeLoadTimeout,
|
|
1754
2979
|
onStylesheetLoad,
|
|
1755
2980
|
stylesheetLoadTimeout,
|
|
1756
|
-
keepIframeSrcFn = () => false
|
|
2981
|
+
keepIframeSrcFn = () => false,
|
|
2982
|
+
selector
|
|
1757
2983
|
} = options || {};
|
|
1758
2984
|
const maskInputOptions = maskAllInputs === true ? {
|
|
1759
2985
|
color: true,
|
|
@@ -1791,6 +3017,22 @@ function snapshot(n2, options) {
|
|
|
1791
3017
|
headMetaVerification: true
|
|
1792
3018
|
}
|
|
1793
3019
|
) : slimDOM === false ? {} : slimDOM;
|
|
3020
|
+
const selectorOptions = selector === false ? null : selector === true ? {
|
|
3021
|
+
maxPathDepth: 10,
|
|
3022
|
+
enableSvgFingerprint: true,
|
|
3023
|
+
confidenceThreshold: 0.3,
|
|
3024
|
+
fallbackToBody: true
|
|
3025
|
+
} : selector === void 0 ? {
|
|
3026
|
+
maxPathDepth: 10,
|
|
3027
|
+
enableSvgFingerprint: true,
|
|
3028
|
+
confidenceThreshold: 0.3,
|
|
3029
|
+
fallbackToBody: true
|
|
3030
|
+
} : {
|
|
3031
|
+
maxPathDepth: (_a2 = selector.maxPathDepth) != null ? _a2 : 10,
|
|
3032
|
+
enableSvgFingerprint: (_b = selector.enableSvgFingerprint) != null ? _b : true,
|
|
3033
|
+
confidenceThreshold: (_c = selector.confidenceThreshold) != null ? _c : 0.3,
|
|
3034
|
+
fallbackToBody: (_d = selector.fallbackToBody) != null ? _d : true
|
|
3035
|
+
};
|
|
1794
3036
|
return serializeNodeWithId(n2, {
|
|
1795
3037
|
doc: n2,
|
|
1796
3038
|
mirror: mirror2,
|
|
@@ -1815,7 +3057,8 @@ function snapshot(n2, options) {
|
|
|
1815
3057
|
onStylesheetLoad,
|
|
1816
3058
|
stylesheetLoadTimeout,
|
|
1817
3059
|
keepIframeSrcFn,
|
|
1818
|
-
newlyAddedElement: false
|
|
3060
|
+
newlyAddedElement: false,
|
|
3061
|
+
selectorOptions
|
|
1819
3062
|
});
|
|
1820
3063
|
}
|
|
1821
3064
|
function getDefaultExportFromCjs$1(x2) {
|
|
@@ -1836,12 +3079,12 @@ function getAugmentedNamespace$1(n2) {
|
|
|
1836
3079
|
} else
|
|
1837
3080
|
a2 = {};
|
|
1838
3081
|
Object.defineProperty(a2, "__esModule", { value: true });
|
|
1839
|
-
Object.keys(n2).forEach(function(
|
|
1840
|
-
var d = Object.getOwnPropertyDescriptor(n2,
|
|
1841
|
-
Object.defineProperty(a2,
|
|
3082
|
+
Object.keys(n2).forEach(function(k2) {
|
|
3083
|
+
var d = Object.getOwnPropertyDescriptor(n2, k2);
|
|
3084
|
+
Object.defineProperty(a2, k2, d.get ? d : {
|
|
1842
3085
|
enumerable: true,
|
|
1843
3086
|
get: function() {
|
|
1844
|
-
return n2[
|
|
3087
|
+
return n2[k2];
|
|
1845
3088
|
}
|
|
1846
3089
|
});
|
|
1847
3090
|
});
|
|
@@ -2288,7 +3531,7 @@ function cloneNode$1(obj, parent) {
|
|
|
2288
3531
|
} else if (i2 === "source") {
|
|
2289
3532
|
cloned[i2] = value;
|
|
2290
3533
|
} else if (Array.isArray(value)) {
|
|
2291
|
-
cloned[i2] = value.map((
|
|
3534
|
+
cloned[i2] = value.map((j2) => cloneNode$1(j2, cloned));
|
|
2292
3535
|
} else {
|
|
2293
3536
|
if (type === "object" && value !== null)
|
|
2294
3537
|
value = cloneNode$1(value);
|
|
@@ -2529,7 +3772,7 @@ let Node$5$1 = class Node2 {
|
|
|
2529
3772
|
}
|
|
2530
3773
|
return result2;
|
|
2531
3774
|
}
|
|
2532
|
-
toJSON(
|
|
3775
|
+
toJSON(_2, inputs) {
|
|
2533
3776
|
let fixed = {};
|
|
2534
3777
|
let emitInputs = inputs == null;
|
|
2535
3778
|
inputs = inputs || /* @__PURE__ */ new Map();
|
|
@@ -4245,8 +5488,8 @@ let Parser$1$1 = class Parser {
|
|
|
4245
5488
|
return;
|
|
4246
5489
|
let founded = 0;
|
|
4247
5490
|
let token;
|
|
4248
|
-
for (let
|
|
4249
|
-
token = tokens[
|
|
5491
|
+
for (let j2 = colon - 1; j2 >= 0; j2--) {
|
|
5492
|
+
token = tokens[j2];
|
|
4250
5493
|
if (token[0] !== "space") {
|
|
4251
5494
|
founded += 1;
|
|
4252
5495
|
if (founded === 2)
|
|
@@ -4368,8 +5611,8 @@ let Parser$1$1 = class Parser {
|
|
|
4368
5611
|
} else if (token[1].toLowerCase() === "important") {
|
|
4369
5612
|
let cache = tokens.slice(0);
|
|
4370
5613
|
let str = "";
|
|
4371
|
-
for (let
|
|
4372
|
-
let type = cache[
|
|
5614
|
+
for (let j2 = i2; j2 > 0; j2--) {
|
|
5615
|
+
let type = cache[j2][0];
|
|
4373
5616
|
if (str.trim().indexOf("!") === 0 && type !== "space") {
|
|
4374
5617
|
break;
|
|
4375
5618
|
}
|
|
@@ -5610,12 +6853,12 @@ function getAugmentedNamespace(n2) {
|
|
|
5610
6853
|
} else
|
|
5611
6854
|
a2 = {};
|
|
5612
6855
|
Object.defineProperty(a2, "__esModule", { value: true });
|
|
5613
|
-
Object.keys(n2).forEach(function(
|
|
5614
|
-
var d = Object.getOwnPropertyDescriptor(n2,
|
|
5615
|
-
Object.defineProperty(a2,
|
|
6856
|
+
Object.keys(n2).forEach(function(k2) {
|
|
6857
|
+
var d = Object.getOwnPropertyDescriptor(n2, k2);
|
|
6858
|
+
Object.defineProperty(a2, k2, d.get ? d : {
|
|
5616
6859
|
enumerable: true,
|
|
5617
6860
|
get: function() {
|
|
5618
|
-
return n2[
|
|
6861
|
+
return n2[k2];
|
|
5619
6862
|
}
|
|
5620
6863
|
});
|
|
5621
6864
|
});
|
|
@@ -6062,7 +7305,7 @@ function cloneNode(obj, parent) {
|
|
|
6062
7305
|
} else if (i2 === "source") {
|
|
6063
7306
|
cloned[i2] = value;
|
|
6064
7307
|
} else if (Array.isArray(value)) {
|
|
6065
|
-
cloned[i2] = value.map((
|
|
7308
|
+
cloned[i2] = value.map((j2) => cloneNode(j2, cloned));
|
|
6066
7309
|
} else {
|
|
6067
7310
|
if (type === "object" && value !== null)
|
|
6068
7311
|
value = cloneNode(value);
|
|
@@ -6303,7 +7546,7 @@ let Node$5 = class Node22 {
|
|
|
6303
7546
|
}
|
|
6304
7547
|
return result2;
|
|
6305
7548
|
}
|
|
6306
|
-
toJSON(
|
|
7549
|
+
toJSON(_2, inputs) {
|
|
6307
7550
|
let fixed = {};
|
|
6308
7551
|
let emitInputs = inputs == null;
|
|
6309
7552
|
inputs = inputs || /* @__PURE__ */ new Map();
|
|
@@ -8019,8 +9262,8 @@ let Parser$1 = class Parser2 {
|
|
|
8019
9262
|
return;
|
|
8020
9263
|
let founded = 0;
|
|
8021
9264
|
let token;
|
|
8022
|
-
for (let
|
|
8023
|
-
token = tokens[
|
|
9265
|
+
for (let j2 = colon - 1; j2 >= 0; j2--) {
|
|
9266
|
+
token = tokens[j2];
|
|
8024
9267
|
if (token[0] !== "space") {
|
|
8025
9268
|
founded += 1;
|
|
8026
9269
|
if (founded === 2)
|
|
@@ -8142,8 +9385,8 @@ let Parser$1 = class Parser2 {
|
|
|
8142
9385
|
} else if (token[1].toLowerCase() === "important") {
|
|
8143
9386
|
let cache = tokens.slice(0);
|
|
8144
9387
|
let str = "";
|
|
8145
|
-
for (let
|
|
8146
|
-
let type = cache[
|
|
9388
|
+
for (let j2 = i2; j2 > 0; j2--) {
|
|
9389
|
+
let type = cache[j2][0];
|
|
8147
9390
|
if (str.trim().indexOf("!") === 0 && type !== "space") {
|
|
8148
9391
|
break;
|
|
8149
9392
|
}
|
|
@@ -13031,7 +14274,7 @@ class VisibilityManager {
|
|
|
13031
14274
|
}
|
|
13032
14275
|
}
|
|
13033
14276
|
}
|
|
13034
|
-
const version$1 = "
|
|
14277
|
+
const version$1 = "3.1.1-alpha.1";
|
|
13035
14278
|
let wrappedEmit;
|
|
13036
14279
|
let takeFullSnapshot$1;
|
|
13037
14280
|
let canvasManager;
|
|
@@ -13675,7 +14918,7 @@ if (typeof module.exports == "object" && typeof exports == "object") {
|
|
|
13675
14918
|
return module.exports;
|
|
13676
14919
|
}))
|
|
13677
14920
|
//# sourceMappingURL=rrweb-record.umd.cjs.map
|
|
13678
|
-
`;var
|
|
14921
|
+
`;var A=`(function (g, f) {
|
|
13679
14922
|
if ("object" == typeof exports && "object" == typeof module) {
|
|
13680
14923
|
module.exports = f();
|
|
13681
14924
|
} else if ("function" == typeof define && define.amd) {
|
|
@@ -13731,5 +14974,5 @@ if (typeof module.exports == "object" && typeof exports == "object") {
|
|
|
13731
14974
|
return module.exports;
|
|
13732
14975
|
}))
|
|
13733
14976
|
//# sourceMappingURL=rrweb-plugin-sequential-id-record.umd.cjs.map
|
|
13734
|
-
`;var K={slimDOMOptions:"all",inlineStylesheet:!0,recordDOM:!0,recordCanvas:!0,collectFonts:!0,inlineImages:!0,maskInputOptions:{password:!0},sampling:{mousemove:!1,mouseInteraction:{MouseUp:!1,MouseDown:!1,Click:!0,ContextMenu:!0,DblClick:!0,Focus:!0,Blur:!0,TouchStart:!1,TouchEnd:!1},scroll:100,media:100,input:"last",canvas:"all",visibility:{mode:"none",debounce:0,threshold:.5,sensitivity:.05,rafThrottle:10}},flushCustomEvent:"after",recordAfter:"DOMContentLoaded",userTriggeredOnInput:!0},m=class{recordFn=null;page=null;context;eventCounter=0;events=[];recordOptions;pendingEvents=[];recorderScriptVersion="unknown";recorderLibVersion="unknown";isRecording=!1;constructor(e){this.recordOptions=S(K,e??{}),this.context={pushEvent:n=>this.events.push(n)}}handleEmit(e){if(e.type===0||e.type===1)return;let n={...e};this.context.pushEvent(n)}async inject(e){this.page=e,await this.page?.addInitScript({content:R}),await this.page?.addInitScript({content:
|
|
14977
|
+
`;var K={slimDOMOptions:"all",inlineStylesheet:!0,recordDOM:!0,recordCanvas:!0,collectFonts:!0,inlineImages:!0,maskInputOptions:{password:!0},sampling:{mousemove:!1,mouseInteraction:{MouseUp:!1,MouseDown:!1,Click:!0,ContextMenu:!0,DblClick:!0,Focus:!0,Blur:!0,TouchStart:!1,TouchEnd:!1},scroll:100,media:100,input:"last",canvas:"all",visibility:{mode:"none",debounce:0,threshold:.5,sensitivity:.05,rafThrottle:10}},flushCustomEvent:"after",recordAfter:"DOMContentLoaded",userTriggeredOnInput:!0},m=class{recordFn=null;page=null;context;eventCounter=0;events=[];recordOptions;pendingEvents=[];recorderScriptVersion="unknown";recorderLibVersion="unknown";isRecording=!1;constructor(e){this.recordOptions=S(K,e??{}),this.context={pushEvent:n=>this.events.push(n)}}handleEmit(e){if(e.type===0||e.type===1)return;let n={...e};this.context.pushEvent(n)}async inject(e){this.page=e,await this.page?.addInitScript({content:R}),await this.page?.addInitScript({content:A}),await this.page?.exposeFunction("handleEmit",n=>{this.handleEmit(n)})}async start(){this.recordFn=await this.page?.evaluateHandle(()=>window.rrweb?.record),await this.recordFn?.evaluate((e,n)=>{let s=JSON.parse(n),r=[];window.rrwebPluginSequentialIdRecord&&r.push(window.rrwebPluginSequentialIdRecord.getRecordSequentialIdPlugin({key:"id"})),window.stopFn=e({emit:i=>{window.handleEmit?.(i)},plugins:r,...s})},JSON.stringify(this.recordOptions)),this.isRecording=await this.recordFn?.evaluate(e=>e.isRecording()),this.recorderScriptVersion=await this.recordFn?.evaluate(e=>e.getVersion()),await this.flush()}async stop(){this.isRecording=!1,this.recordFn&&this.page&&!this.page.isClosed()&&(await this.flush(),await this.page.evaluate(()=>{window.stopFn=null}))}async reset(){this.eventCounter=0,this.events=[],await this.stop(),this.context={pushEvent:e=>this.events.push(e)}}async flush(){if(!this.recordFn)return;let e=[];for(let n of this.pendingEvents)try{await this.recordFn.evaluate((s,r)=>{s.addCustomEvent(r.tag,r.payload)},n)}catch{console.debug(`[${Date.now()}] [recorder] flush failed for custom event: ${n.tag}`),e.push(n)}this.pendingEvents=e}async addCustomEvent(e,n){let s={tag:e,payload:n};if(!this.recordFn||!this.isRecording){console.debug(`[${Date.now()}] [recorder] queued custom event (recorder not ready): ${e}`),this.pendingEvents.push(s);return}try{await this.recordFn.evaluate((r,i)=>{r.addCustomEvent(i.tag,i.payload)},s)}catch{this.pendingEvents.push(s)}}isRecordingReady(){return!!this.recordFn&&this.isRecording}getScriptVersion(){return`@appsurify-testmap/rrweb-record:${this.recorderScriptVersion}`}getLibVersion(){return`@appsurify-testmap/rrweb:${this.recorderLibVersion!=="unknown"?this.recorderLibVersion:this.recorderScriptVersion}`}getEvents(){return this.events}getMirror(){return this.recordFn?.mirror}bind(e){this.context=e}setEventCounter(e){this.eventCounter=e}};var g=m;var T=new Map;function M(t,e){T.set(t,e)}function x(t){return T.get(t)}var k=y.test.extend({browser:async({browser:t},e)=>{await e(t)},context:async({browser:t},e,n)=>{let s=await t.newContext(),r=_(t,n);M(n.testId,r),await e(s),await s.close()},page:async({page:t},e,n)=>{let r=n.project.use.testmap??{},i=typeof r=="object"&&"recordingOpts"in r?r.recordingOpts:g,o=new g(i),c=x(n.testId);c&&(c.recorderInstance=o),o.bind({pushEvent:async a=>{c?.recorderEvents.push(a),await Promise.resolve()}}),await o.inject(t),t.on("console",async a=>{a.type()!=="debug"&&console.debug(`[${Date.now()}] [page] console`,a.text())}),t.on("load",async()=>{}),t.on("domcontentloaded",async()=>{await o.start(),c?.runner&&(c.runner.recorder={scriptVersion:o.getScriptVersion(),libVersion:o.getLibVersion()})}),t.on("framenavigated",async()=>{}),t.on("close",async()=>{await o.flush()});let d=n._onStepEnd.bind(void 0);n._onStepEnd=async a=>{let l=n._stepMap.get(a.stepId);if(l.apiName&&l?.location.file===n.file&&await o.addCustomEvent(l.apiName,{stepId:l.stepId,category:l.category,location:l.location,title:l.title,apiName:l.apiName,endWallTime:l.endWallTime}),!t.isClosed())try{await E(t)}catch{}await d(a)};let h=n._onDidFinishTestFunction.bind(void 0);n._onDidFinishTestFunction=async()=>{o&&o.isRecordingReady()&&(await I(o,500),await o.stop()),await h()},await e(t)}});k.beforeEach(async({},t)=>{console.log(`[${Date.now()}] [\u{1F7E2} TEST START] ${t.title}`)});k.afterEach(async({},t)=>{console.log(`[${Date.now()}] [\u{1F534} TEST END] ${t.title}`);let e=x(t.testId);if(!e)return;e.test.duration=t.duration;let n={runner:e?.runner,spec:e?.spec,browser:e?.browser,test:e?.test,suite:e?.test.suite,recorderEvents:Array.isArray(e?.recorderEvents)?e?.recorderEvents:[]},r=t.project.use.testmap??{};C(n,r.outputReportDir)});0&&(module.exports={expect,test});
|
|
13735
14978
|
//# sourceMappingURL=index.js.map
|