@posthog/rrweb-snapshot 0.0.54 → 0.0.55

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.
Files changed (41) hide show
  1. package/dist/record-BhFABPFv.js +1016 -0
  2. package/dist/record-BhFABPFv.js.map +1 -0
  3. package/dist/record-Rc5ocxPN.cjs +1015 -0
  4. package/dist/record-Rc5ocxPN.cjs.map +1 -0
  5. package/dist/record-Rc5ocxPN.umd.cjs +1593 -0
  6. package/dist/record-Rc5ocxPN.umd.cjs.map +7 -0
  7. package/dist/record-Rc5ocxPN.umd.min.cjs +20 -0
  8. package/dist/record-Rc5ocxPN.umd.min.cjs.map +7 -0
  9. package/dist/record.cjs +13 -1012
  10. package/dist/record.cjs.map +1 -1
  11. package/dist/record.d.cts +273 -5
  12. package/dist/record.d.ts +273 -5
  13. package/dist/record.js +29 -1029
  14. package/dist/record.js.map +1 -1
  15. package/dist/record.umd.cjs +976 -955
  16. package/dist/record.umd.cjs.map +3 -3
  17. package/dist/record.umd.min.cjs +1 -1
  18. package/dist/record.umd.min.cjs.map +4 -4
  19. package/dist/replay.d.cts +219 -5
  20. package/dist/replay.d.ts +219 -5
  21. package/dist/rrweb-snapshot.cjs +1 -1
  22. package/dist/rrweb-snapshot.d.cts +299 -1
  23. package/dist/rrweb-snapshot.d.ts +299 -1
  24. package/dist/rrweb-snapshot.js +26 -26
  25. package/dist/rrweb-snapshot.umd.cjs +4 -26
  26. package/dist/rrweb-snapshot.umd.cjs.map +2 -2
  27. package/dist/rrweb-snapshot.umd.min.cjs +10 -10
  28. package/dist/rrweb-snapshot.umd.min.cjs.map +2 -2
  29. package/package.json +3 -3
  30. package/dist/css.d.cts +0 -5
  31. package/dist/css.d.ts +0 -5
  32. package/dist/index.d.cts +0 -6
  33. package/dist/index.d.ts +0 -6
  34. package/dist/rebuild.d.cts +0 -23
  35. package/dist/rebuild.d.ts +0 -23
  36. package/dist/snapshot.d.cts +0 -71
  37. package/dist/snapshot.d.ts +0 -71
  38. package/dist/types.d.cts +0 -103
  39. package/dist/types.d.ts +0 -103
  40. package/dist/utils.d.cts +0 -51
  41. package/dist/utils.d.ts +0 -51
@@ -559,1007 +559,1042 @@ var require_types_BjupQhwp = __commonJS({
559
559
  }
560
560
  });
561
561
 
562
- // dist/record.cjs
563
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
564
- var types = require_types_BjupQhwp();
565
- var _id = 1;
566
- var tagNameRegex = new RegExp("[^a-z0-9-_:]");
567
- var IGNORED_NODE = -2;
568
- function genId() {
569
- return _id++;
570
- }
571
- function getValidTagName(element) {
572
- if (element instanceof HTMLFormElement) {
573
- return "form";
574
- }
575
- const processedTagName = types.toLowerCase(element.tagName);
576
- if (tagNameRegex.test(processedTagName)) {
577
- return "div";
578
- }
579
- return processedTagName;
580
- }
581
- var canvasService;
582
- var canvasCtx;
583
- var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
584
- var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
585
- function getAbsoluteSrcsetString(doc, attributeValue) {
586
- if (attributeValue.trim() === "") {
587
- return attributeValue;
588
- }
589
- let pos = 0;
590
- function collectCharacters(regEx) {
591
- let chars;
592
- const match = regEx.exec(attributeValue.substring(pos));
593
- if (match) {
594
- chars = match[0];
595
- pos += chars.length;
596
- return chars;
597
- }
598
- return "";
599
- }
600
- const output = [];
601
- while (true) {
602
- collectCharacters(SRCSET_COMMAS_OR_SPACES);
603
- if (pos >= attributeValue.length) {
604
- break;
605
- }
606
- let url = collectCharacters(SRCSET_NOT_SPACES);
607
- if (url.slice(-1) === ",") {
608
- url = absoluteToDoc(doc, url.substring(0, url.length - 1));
609
- output.push(url);
610
- } else {
611
- let descriptorsStr = "";
612
- url = absoluteToDoc(doc, url);
613
- let inParens = false;
562
+ // dist/record-Rc5ocxPN.cjs
563
+ var require_record_Rc5ocxPN = __commonJS({
564
+ "dist/record-Rc5ocxPN.cjs"(exports2) {
565
+ "use strict";
566
+ var types2 = require_types_BjupQhwp();
567
+ var _id = 1;
568
+ var tagNameRegex = new RegExp("[^a-z0-9-_:]");
569
+ var IGNORED_NODE = -2;
570
+ function genId() {
571
+ return _id++;
572
+ }
573
+ function getValidTagName(element) {
574
+ if (element instanceof HTMLFormElement) {
575
+ return "form";
576
+ }
577
+ const processedTagName = types2.toLowerCase(element.tagName);
578
+ if (tagNameRegex.test(processedTagName)) {
579
+ return "div";
580
+ }
581
+ return processedTagName;
582
+ }
583
+ var canvasService;
584
+ var canvasCtx;
585
+ var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
586
+ var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
587
+ function getAbsoluteSrcsetString(doc, attributeValue) {
588
+ if (attributeValue.trim() === "") {
589
+ return attributeValue;
590
+ }
591
+ let pos = 0;
592
+ function collectCharacters(regEx) {
593
+ let chars;
594
+ const match = regEx.exec(attributeValue.substring(pos));
595
+ if (match) {
596
+ chars = match[0];
597
+ pos += chars.length;
598
+ return chars;
599
+ }
600
+ return "";
601
+ }
602
+ const output = [];
614
603
  while (true) {
615
- const c = attributeValue.charAt(pos);
616
- if (c === "") {
617
- output.push((url + descriptorsStr).trim());
604
+ collectCharacters(SRCSET_COMMAS_OR_SPACES);
605
+ if (pos >= attributeValue.length) {
618
606
  break;
619
- } else if (!inParens) {
620
- if (c === ",") {
621
- pos += 1;
622
- output.push((url + descriptorsStr).trim());
623
- break;
624
- } else if (c === "(") {
625
- inParens = true;
626
- }
607
+ }
608
+ let url = collectCharacters(SRCSET_NOT_SPACES);
609
+ if (url.slice(-1) === ",") {
610
+ url = absoluteToDoc(doc, url.substring(0, url.length - 1));
611
+ output.push(url);
627
612
  } else {
628
- if (c === ")") {
629
- inParens = false;
613
+ let descriptorsStr = "";
614
+ url = absoluteToDoc(doc, url);
615
+ let inParens = false;
616
+ while (true) {
617
+ const c = attributeValue.charAt(pos);
618
+ if (c === "") {
619
+ output.push((url + descriptorsStr).trim());
620
+ break;
621
+ } else if (!inParens) {
622
+ if (c === ",") {
623
+ pos += 1;
624
+ output.push((url + descriptorsStr).trim());
625
+ break;
626
+ } else if (c === "(") {
627
+ inParens = true;
628
+ }
629
+ } else {
630
+ if (c === ")") {
631
+ inParens = false;
632
+ }
633
+ }
634
+ descriptorsStr += c;
635
+ pos += 1;
630
636
  }
631
637
  }
632
- descriptorsStr += c;
633
- pos += 1;
634
638
  }
639
+ return output.join(", ");
635
640
  }
636
- }
637
- return output.join(", ");
638
- }
639
- var cachedDocument = /* @__PURE__ */ new WeakMap();
640
- function absoluteToDoc(doc, attributeValue) {
641
- if (!attributeValue || attributeValue.trim() === "") {
642
- return attributeValue;
643
- }
644
- return getHref(doc, attributeValue);
645
- }
646
- function isSVGElement(el) {
647
- return Boolean(el.tagName === "svg" || el.ownerSVGElement);
648
- }
649
- function getHref(doc, customHref) {
650
- let a = cachedDocument.get(doc);
651
- if (!a) {
652
- a = doc.createElement("a");
653
- cachedDocument.set(doc, a);
654
- }
655
- if (!customHref) {
656
- customHref = "";
657
- } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
658
- return customHref;
659
- }
660
- a.setAttribute("href", customHref);
661
- return a.href;
662
- }
663
- function transformAttribute(doc, tagName, name, value, element, dataURLOptions) {
664
- if (!value) {
665
- return value;
666
- }
667
- if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
668
- const transformedValue = absoluteToDoc(doc, value);
669
- if (tagName === "img" && transformedValue.startsWith("data:") && element) {
670
- const img = element;
671
- let processedDataURL = transformedValue;
672
- if ((dataURLOptions == null ? void 0 : dataURLOptions.type) || (dataURLOptions == null ? void 0 : dataURLOptions.quality) !== void 0) {
673
- processedDataURL = types.recompressBase64Image(
674
- img,
675
- transformedValue,
676
- dataURLOptions.type,
677
- dataURLOptions.quality
678
- );
641
+ var cachedDocument = /* @__PURE__ */ new WeakMap();
642
+ function absoluteToDoc(doc, attributeValue) {
643
+ if (!attributeValue || attributeValue.trim() === "") {
644
+ return attributeValue;
679
645
  }
680
- if (dataURLOptions == null ? void 0 : dataURLOptions.maxBase64ImageLength) {
681
- processedDataURL = types.checkDataURLSize(
682
- processedDataURL,
683
- dataURLOptions.maxBase64ImageLength
684
- );
646
+ return getHref(doc, attributeValue);
647
+ }
648
+ function isSVGElement(el) {
649
+ return Boolean(el.tagName === "svg" || el.ownerSVGElement);
650
+ }
651
+ function getHref(doc, customHref) {
652
+ let a = cachedDocument.get(doc);
653
+ if (!a) {
654
+ a = doc.createElement("a");
655
+ cachedDocument.set(doc, a);
685
656
  }
686
- return processedDataURL;
687
- }
688
- return transformedValue;
689
- } else if (name === "xlink:href" && value[0] !== "#") {
690
- return absoluteToDoc(doc, value);
691
- } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
692
- return absoluteToDoc(doc, value);
693
- } else if (name === "srcset") {
694
- return getAbsoluteSrcsetString(doc, value);
695
- } else if (name === "style") {
696
- return types.absolutifyURLs(value, getHref(doc));
697
- } else if (tagName === "object" && name === "data") {
698
- return absoluteToDoc(doc, value);
699
- }
700
- return value;
701
- }
702
- function ignoreAttribute(tagName, name, _value) {
703
- return (tagName === "video" || tagName === "audio") && name === "autoplay";
704
- }
705
- function _isBlockedElement(element, blockClass, blockSelector) {
706
- try {
707
- if (typeof blockClass === "string") {
708
- if (element.classList.contains(blockClass)) {
709
- return true;
657
+ if (!customHref) {
658
+ customHref = "";
659
+ } else if (customHref.startsWith("blob:") || customHref.startsWith("data:")) {
660
+ return customHref;
710
661
  }
711
- } else {
712
- for (let eIndex = element.classList.length; eIndex--; ) {
713
- const className = element.classList[eIndex];
714
- if (blockClass.test(className)) {
715
- return true;
662
+ a.setAttribute("href", customHref);
663
+ return a.href;
664
+ }
665
+ function transformAttribute(doc, tagName, name, value, element, dataURLOptions) {
666
+ if (!value) {
667
+ return value;
668
+ }
669
+ if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
670
+ const transformedValue = absoluteToDoc(doc, value);
671
+ if (tagName === "img" && transformedValue.startsWith("data:") && element) {
672
+ const img = element;
673
+ let processedDataURL = transformedValue;
674
+ if ((dataURLOptions == null ? void 0 : dataURLOptions.type) || (dataURLOptions == null ? void 0 : dataURLOptions.quality) !== void 0) {
675
+ processedDataURL = types2.recompressBase64Image(
676
+ img,
677
+ transformedValue,
678
+ dataURLOptions.type,
679
+ dataURLOptions.quality
680
+ );
681
+ }
682
+ if (dataURLOptions == null ? void 0 : dataURLOptions.maxBase64ImageLength) {
683
+ processedDataURL = types2.checkDataURLSize(
684
+ processedDataURL,
685
+ dataURLOptions.maxBase64ImageLength
686
+ );
687
+ }
688
+ return processedDataURL;
716
689
  }
690
+ return transformedValue;
691
+ } else if (name === "xlink:href" && value[0] !== "#") {
692
+ return absoluteToDoc(doc, value);
693
+ } else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
694
+ return absoluteToDoc(doc, value);
695
+ } else if (name === "srcset") {
696
+ return getAbsoluteSrcsetString(doc, value);
697
+ } else if (name === "style") {
698
+ return types2.absolutifyURLs(value, getHref(doc));
699
+ } else if (tagName === "object" && name === "data") {
700
+ return absoluteToDoc(doc, value);
717
701
  }
702
+ return value;
718
703
  }
719
- if (blockSelector) {
720
- return element.matches(blockSelector);
721
- }
722
- } catch (e) {
723
- }
724
- return false;
725
- }
726
- function classMatchesRegex(node, regex, checkAncestors) {
727
- if (!node) return false;
728
- if (node.nodeType !== node.ELEMENT_NODE) {
729
- if (!checkAncestors) return false;
730
- return classMatchesRegex(types.index.parentNode(node), regex, checkAncestors);
731
- }
732
- for (let eIndex = node.classList.length; eIndex--; ) {
733
- const className = node.classList[eIndex];
734
- if (regex.test(className)) {
735
- return true;
704
+ function ignoreAttribute(tagName, name, _value) {
705
+ return (tagName === "video" || tagName === "audio") && name === "autoplay";
736
706
  }
737
- }
738
- if (!checkAncestors) return false;
739
- return classMatchesRegex(types.index.parentNode(node), regex, checkAncestors);
740
- }
741
- function needMaskingText(node, maskTextClass, maskTextSelector, checkAncestors) {
742
- let el;
743
- if (types.isElement(node)) {
744
- el = node;
745
- if (!types.index.childNodes(el).length) {
707
+ function _isBlockedElement(element, blockClass, blockSelector) {
708
+ try {
709
+ if (typeof blockClass === "string") {
710
+ if (element.classList.contains(blockClass)) {
711
+ return true;
712
+ }
713
+ } else {
714
+ for (let eIndex = element.classList.length; eIndex--; ) {
715
+ const className = element.classList[eIndex];
716
+ if (blockClass.test(className)) {
717
+ return true;
718
+ }
719
+ }
720
+ }
721
+ if (blockSelector) {
722
+ return element.matches(blockSelector);
723
+ }
724
+ } catch (e) {
725
+ }
746
726
  return false;
747
727
  }
748
- } else if (types.index.parentElement(node) === null) {
749
- return false;
750
- } else {
751
- el = types.index.parentElement(node);
752
- }
753
- try {
754
- if (typeof maskTextClass === "string") {
755
- if (checkAncestors) {
756
- if (el.closest(`.${maskTextClass}`)) return true;
728
+ function classMatchesRegex(node, regex, checkAncestors) {
729
+ if (!node) return false;
730
+ if (node.nodeType !== node.ELEMENT_NODE) {
731
+ if (!checkAncestors) return false;
732
+ return classMatchesRegex(types2.index.parentNode(node), regex, checkAncestors);
733
+ }
734
+ for (let eIndex = node.classList.length; eIndex--; ) {
735
+ const className = node.classList[eIndex];
736
+ if (regex.test(className)) {
737
+ return true;
738
+ }
739
+ }
740
+ if (!checkAncestors) return false;
741
+ return classMatchesRegex(types2.index.parentNode(node), regex, checkAncestors);
742
+ }
743
+ function needMaskingText(node, maskTextClass, maskTextSelector, checkAncestors) {
744
+ let el;
745
+ if (types2.isElement(node)) {
746
+ el = node;
747
+ if (!types2.index.childNodes(el).length) {
748
+ return false;
749
+ }
750
+ } else if (types2.index.parentElement(node) === null) {
751
+ return false;
757
752
  } else {
758
- if (el.classList.contains(maskTextClass)) return true;
753
+ el = types2.index.parentElement(node);
754
+ }
755
+ try {
756
+ if (typeof maskTextClass === "string") {
757
+ if (checkAncestors) {
758
+ if (el.closest(`.${maskTextClass}`)) return true;
759
+ } else {
760
+ if (el.classList.contains(maskTextClass)) return true;
761
+ }
762
+ } else {
763
+ if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
764
+ }
765
+ if (maskTextSelector) {
766
+ if (checkAncestors) {
767
+ if (el.closest(maskTextSelector)) return true;
768
+ } else {
769
+ if (el.matches(maskTextSelector)) return true;
770
+ }
771
+ }
772
+ } catch (e) {
759
773
  }
760
- } else {
761
- if (classMatchesRegex(el, maskTextClass, checkAncestors)) return true;
774
+ return false;
762
775
  }
763
- if (maskTextSelector) {
764
- if (checkAncestors) {
765
- if (el.closest(maskTextSelector)) return true;
766
- } else {
767
- if (el.matches(maskTextSelector)) return true;
776
+ function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
777
+ const win = iframeEl.contentWindow;
778
+ if (!win) {
779
+ return;
768
780
  }
781
+ let fired = false;
782
+ let readyState;
783
+ try {
784
+ readyState = win.document.readyState;
785
+ } catch (error) {
786
+ return;
787
+ }
788
+ if (readyState !== "complete") {
789
+ const timer = setTimeout(() => {
790
+ if (!fired) {
791
+ listener();
792
+ fired = true;
793
+ }
794
+ }, iframeLoadTimeout);
795
+ iframeEl.addEventListener("load", () => {
796
+ clearTimeout(timer);
797
+ fired = true;
798
+ listener();
799
+ });
800
+ return;
801
+ }
802
+ const blankUrl = "about:blank";
803
+ if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
804
+ setTimeout(listener, 0);
805
+ return iframeEl.addEventListener("load", listener);
806
+ }
807
+ iframeEl.addEventListener("load", listener);
769
808
  }
770
- } catch (e) {
771
- }
772
- return false;
773
- }
774
- function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
775
- const win = iframeEl.contentWindow;
776
- if (!win) {
777
- return;
778
- }
779
- let fired = false;
780
- let readyState;
781
- try {
782
- readyState = win.document.readyState;
783
- } catch (error) {
784
- return;
785
- }
786
- if (readyState !== "complete") {
787
- const timer = setTimeout(() => {
788
- if (!fired) {
789
- listener();
809
+ function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
810
+ let fired = false;
811
+ let styleSheetLoaded;
812
+ try {
813
+ styleSheetLoaded = link.sheet;
814
+ } catch (error) {
815
+ return;
816
+ }
817
+ if (styleSheetLoaded) return;
818
+ const timer = setTimeout(() => {
819
+ if (!fired) {
820
+ listener();
821
+ fired = true;
822
+ }
823
+ }, styleSheetLoadTimeout);
824
+ link.addEventListener("load", () => {
825
+ clearTimeout(timer);
790
826
  fired = true;
827
+ listener();
828
+ });
829
+ }
830
+ function serializeNode(n, options) {
831
+ const {
832
+ doc,
833
+ mirror,
834
+ blockClass,
835
+ blockSelector,
836
+ needsMask,
837
+ inlineStylesheet,
838
+ maskInputOptions = {},
839
+ maskTextFn,
840
+ maskInputFn,
841
+ dataURLOptions = {},
842
+ inlineImages,
843
+ recordCanvas,
844
+ keepIframeSrcFn,
845
+ newlyAddedElement = false
846
+ } = options;
847
+ const rootId = getRootId(doc, mirror);
848
+ switch (n.nodeType) {
849
+ case n.DOCUMENT_NODE:
850
+ if (n.compatMode !== "CSS1Compat") {
851
+ return {
852
+ type: types2.NodeType$1.Document,
853
+ childNodes: [],
854
+ compatMode: n.compatMode
855
+ // probably "BackCompat"
856
+ };
857
+ } else {
858
+ return {
859
+ type: types2.NodeType$1.Document,
860
+ childNodes: []
861
+ };
862
+ }
863
+ case n.DOCUMENT_TYPE_NODE:
864
+ return {
865
+ type: types2.NodeType$1.DocumentType,
866
+ name: n.name,
867
+ publicId: n.publicId,
868
+ systemId: n.systemId,
869
+ rootId
870
+ };
871
+ case n.ELEMENT_NODE:
872
+ return serializeElementNode(n, {
873
+ doc,
874
+ blockClass,
875
+ blockSelector,
876
+ inlineStylesheet,
877
+ maskInputOptions,
878
+ maskInputFn,
879
+ dataURLOptions,
880
+ inlineImages,
881
+ recordCanvas,
882
+ keepIframeSrcFn,
883
+ newlyAddedElement,
884
+ rootId
885
+ });
886
+ case n.TEXT_NODE:
887
+ return serializeTextNode(n, {
888
+ doc,
889
+ needsMask,
890
+ maskTextFn,
891
+ rootId
892
+ });
893
+ case n.CDATA_SECTION_NODE:
894
+ return {
895
+ type: types2.NodeType$1.CDATA,
896
+ textContent: "",
897
+ rootId
898
+ };
899
+ case n.COMMENT_NODE:
900
+ return {
901
+ type: types2.NodeType$1.Comment,
902
+ textContent: types2.index.textContent(n) || "",
903
+ rootId
904
+ };
905
+ default:
906
+ return false;
791
907
  }
792
- }, iframeLoadTimeout);
793
- iframeEl.addEventListener("load", () => {
794
- clearTimeout(timer);
795
- fired = true;
796
- listener();
797
- });
798
- return;
799
- }
800
- const blankUrl = "about:blank";
801
- if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
802
- setTimeout(listener, 0);
803
- return iframeEl.addEventListener("load", listener);
804
- }
805
- iframeEl.addEventListener("load", listener);
806
- }
807
- function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
808
- let fired = false;
809
- let styleSheetLoaded;
810
- try {
811
- styleSheetLoaded = link.sheet;
812
- } catch (error) {
813
- return;
814
- }
815
- if (styleSheetLoaded) return;
816
- const timer = setTimeout(() => {
817
- if (!fired) {
818
- listener();
819
- fired = true;
820
- }
821
- }, styleSheetLoadTimeout);
822
- link.addEventListener("load", () => {
823
- clearTimeout(timer);
824
- fired = true;
825
- listener();
826
- });
827
- }
828
- function serializeNode(n, options) {
829
- const {
830
- doc,
831
- mirror,
832
- blockClass,
833
- blockSelector,
834
- needsMask,
835
- inlineStylesheet,
836
- maskInputOptions = {},
837
- maskTextFn,
838
- maskInputFn,
839
- dataURLOptions = {},
840
- inlineImages,
841
- recordCanvas,
842
- keepIframeSrcFn,
843
- newlyAddedElement = false
844
- } = options;
845
- const rootId = getRootId(doc, mirror);
846
- switch (n.nodeType) {
847
- case n.DOCUMENT_NODE:
848
- if (n.compatMode !== "CSS1Compat") {
849
- return {
850
- type: types.NodeType$1.Document,
851
- childNodes: [],
852
- compatMode: n.compatMode
853
- // probably "BackCompat"
854
- };
855
- } else {
856
- return {
857
- type: types.NodeType$1.Document,
858
- childNodes: []
859
- };
908
+ }
909
+ function getRootId(doc, mirror) {
910
+ if (!mirror.hasNode(doc)) return void 0;
911
+ const docId = mirror.getId(doc);
912
+ return docId === 1 ? void 0 : docId;
913
+ }
914
+ function serializeTextNode(n, options) {
915
+ var _a;
916
+ const { needsMask, maskTextFn, rootId } = options;
917
+ const parent = types2.index.parentNode(n);
918
+ const parentTagName = parent && parent.tagName;
919
+ let text = types2.index.textContent(n);
920
+ const isStyle = parentTagName === "STYLE" ? true : void 0;
921
+ const isScript = parentTagName === "SCRIPT" ? true : void 0;
922
+ if (isStyle && text) {
923
+ try {
924
+ if (n.nextSibling || n.previousSibling) {
925
+ } else if ((_a = parent.sheet) == null ? void 0 : _a.cssRules) {
926
+ text = types2.stringifyStylesheet(parent.sheet);
927
+ }
928
+ } catch (err) {
929
+ console.warn(
930
+ `Cannot get CSS styles from text's parentNode. Error: ${err}`,
931
+ n
932
+ );
933
+ }
934
+ text = types2.absolutifyURLs(text, getHref(options.doc));
935
+ }
936
+ if (isScript) {
937
+ text = "SCRIPT_PLACEHOLDER";
938
+ }
939
+ if (!isStyle && !isScript && text && needsMask) {
940
+ text = maskTextFn ? maskTextFn(text, types2.index.parentElement(n)) : text.replace(/[\S]/g, "*");
860
941
  }
861
- case n.DOCUMENT_TYPE_NODE:
862
942
  return {
863
- type: types.NodeType$1.DocumentType,
864
- name: n.name,
865
- publicId: n.publicId,
866
- systemId: n.systemId,
943
+ type: types2.NodeType$1.Text,
944
+ textContent: text || "",
945
+ isStyle,
867
946
  rootId
868
947
  };
869
- case n.ELEMENT_NODE:
870
- return serializeElementNode(n, {
948
+ }
949
+ function findStylesheet(doc, href) {
950
+ return Array.from(doc.styleSheets).find((s) => s.href === href);
951
+ }
952
+ function hrefFrom(n) {
953
+ return n.href;
954
+ }
955
+ function serializeElementNode(n, options) {
956
+ var _a, _b;
957
+ const {
871
958
  doc,
872
959
  blockClass,
873
960
  blockSelector,
874
961
  inlineStylesheet,
875
- maskInputOptions,
962
+ maskInputOptions = {},
876
963
  maskInputFn,
877
- dataURLOptions,
964
+ dataURLOptions = {},
878
965
  inlineImages,
879
966
  recordCanvas,
880
967
  keepIframeSrcFn,
881
- newlyAddedElement,
968
+ newlyAddedElement = false,
882
969
  rootId
883
- });
884
- case n.TEXT_NODE:
885
- return serializeTextNode(n, {
886
- doc,
887
- needsMask,
888
- maskTextFn,
889
- rootId
890
- });
891
- case n.CDATA_SECTION_NODE:
892
- return {
893
- type: types.NodeType$1.CDATA,
894
- textContent: "",
895
- rootId
896
- };
897
- case n.COMMENT_NODE:
898
- return {
899
- type: types.NodeType$1.Comment,
900
- textContent: types.index.textContent(n) || "",
901
- rootId
902
- };
903
- default:
904
- return false;
905
- }
906
- }
907
- function getRootId(doc, mirror) {
908
- if (!mirror.hasNode(doc)) return void 0;
909
- const docId = mirror.getId(doc);
910
- return docId === 1 ? void 0 : docId;
911
- }
912
- function serializeTextNode(n, options) {
913
- var _a;
914
- const { needsMask, maskTextFn, rootId } = options;
915
- const parent = types.index.parentNode(n);
916
- const parentTagName = parent && parent.tagName;
917
- let text = types.index.textContent(n);
918
- const isStyle = parentTagName === "STYLE" ? true : void 0;
919
- const isScript = parentTagName === "SCRIPT" ? true : void 0;
920
- if (isStyle && text) {
921
- try {
922
- if (n.nextSibling || n.previousSibling) {
923
- } else if ((_a = parent.sheet) == null ? void 0 : _a.cssRules) {
924
- text = types.stringifyStylesheet(parent.sheet);
925
- }
926
- } catch (err) {
927
- console.warn(
928
- `Cannot get CSS styles from text's parentNode. Error: ${err}`,
929
- n
930
- );
931
- }
932
- text = types.absolutifyURLs(text, getHref(options.doc));
933
- }
934
- if (isScript) {
935
- text = "SCRIPT_PLACEHOLDER";
936
- }
937
- if (!isStyle && !isScript && text && needsMask) {
938
- text = maskTextFn ? maskTextFn(text, types.index.parentElement(n)) : text.replace(/[\S]/g, "*");
939
- }
940
- return {
941
- type: types.NodeType$1.Text,
942
- textContent: text || "",
943
- isStyle,
944
- rootId
945
- };
946
- }
947
- function findStylesheet(doc, href) {
948
- return Array.from(doc.styleSheets).find((s) => s.href === href);
949
- }
950
- function hrefFrom(n) {
951
- return n.href;
952
- }
953
- function serializeElementNode(n, options) {
954
- var _a, _b;
955
- const {
956
- doc,
957
- blockClass,
958
- blockSelector,
959
- inlineStylesheet,
960
- maskInputOptions = {},
961
- maskInputFn,
962
- dataURLOptions = {},
963
- inlineImages,
964
- recordCanvas,
965
- keepIframeSrcFn,
966
- newlyAddedElement = false,
967
- rootId
968
- } = options;
969
- const needBlock = _isBlockedElement(n, blockClass, blockSelector);
970
- const tagName = getValidTagName(n);
971
- let attributes = {};
972
- const len = n.attributes.length;
973
- for (let i = 0; i < len; i++) {
974
- const attr = n.attributes[i];
975
- if (!ignoreAttribute(tagName, attr.name, attr.value)) {
976
- attributes[attr.name] = transformAttribute(
977
- doc,
978
- tagName,
979
- types.toLowerCase(attr.name),
980
- attr.value,
981
- n,
982
- dataURLOptions
983
- );
984
- }
985
- }
986
- if (tagName === "link" && inlineStylesheet) {
987
- const href = hrefFrom(n);
988
- if (href) {
989
- let stylesheet = findStylesheet(doc, href);
990
- if (!stylesheet && href.includes(".css")) {
991
- const rootDomain = window.location.origin;
992
- const stylesheetPath = href.replace(window.location.href, "");
993
- const potentialStylesheetHref = rootDomain + "/" + stylesheetPath;
994
- stylesheet = findStylesheet(doc, potentialStylesheetHref);
995
- }
996
- let cssText = null;
997
- if (stylesheet) {
998
- cssText = types.stringifyStylesheet(stylesheet);
999
- }
1000
- if (cssText) {
1001
- delete attributes.rel;
1002
- delete attributes.href;
1003
- attributes._cssText = cssText;
970
+ } = options;
971
+ const needBlock = _isBlockedElement(n, blockClass, blockSelector);
972
+ const tagName = getValidTagName(n);
973
+ let attributes = {};
974
+ const len = n.attributes.length;
975
+ for (let i = 0; i < len; i++) {
976
+ const attr = n.attributes[i];
977
+ if (!ignoreAttribute(tagName, attr.name, attr.value)) {
978
+ attributes[attr.name] = transformAttribute(
979
+ doc,
980
+ tagName,
981
+ types2.toLowerCase(attr.name),
982
+ attr.value,
983
+ n,
984
+ dataURLOptions
985
+ );
986
+ }
1004
987
  }
1005
- }
1006
- }
1007
- if (tagName === "style" && n.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
1008
- !(n.innerText || types.index.textContent(n) || "").trim().length) {
1009
- const cssText = types.stringifyStylesheet(
1010
- n.sheet
1011
- );
1012
- if (cssText) {
1013
- attributes._cssText = cssText;
1014
- }
1015
- }
1016
- if (tagName === "input" || tagName === "textarea" || tagName === "select") {
1017
- const value = n.value;
1018
- const checked = n.checked;
1019
- if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
1020
- attributes.value = types.maskInputValue({
1021
- element: n,
1022
- type: types.getInputType(n),
1023
- tagName,
1024
- value,
1025
- maskInputOptions,
1026
- maskInputFn
1027
- });
1028
- } else if (checked) {
1029
- attributes.checked = checked;
1030
- }
1031
- }
1032
- if (tagName === "option") {
1033
- if (n.selected && !maskInputOptions["select"]) {
1034
- attributes.selected = true;
1035
- } else {
1036
- delete attributes.selected;
1037
- }
1038
- }
1039
- if (tagName === "dialog" && n.open) {
1040
- try {
1041
- attributes.rr_open_mode = n.matches("dialog:modal") ? "modal" : "non-modal";
1042
- } catch (e) {
1043
- attributes.rr_open_mode = "modal";
1044
- attributes.ph_rr_could_not_detect_modal = true;
1045
- }
1046
- }
1047
- if (tagName === "canvas" && recordCanvas) {
1048
- if (n.__context === "2d") {
1049
- if (!types.is2DCanvasBlank(n)) {
1050
- attributes.rr_dataURL = n.toDataURL(
1051
- dataURLOptions.type,
1052
- dataURLOptions.quality
988
+ if (tagName === "link" && inlineStylesheet) {
989
+ const href = hrefFrom(n);
990
+ if (href) {
991
+ let stylesheet = findStylesheet(doc, href);
992
+ if (!stylesheet && href.includes(".css")) {
993
+ const rootDomain = window.location.origin;
994
+ const stylesheetPath = href.replace(window.location.href, "");
995
+ const potentialStylesheetHref = rootDomain + "/" + stylesheetPath;
996
+ stylesheet = findStylesheet(doc, potentialStylesheetHref);
997
+ }
998
+ let cssText = null;
999
+ if (stylesheet) {
1000
+ cssText = types2.stringifyStylesheet(stylesheet);
1001
+ }
1002
+ if (cssText) {
1003
+ delete attributes.rel;
1004
+ delete attributes.href;
1005
+ attributes._cssText = cssText;
1006
+ }
1007
+ }
1008
+ }
1009
+ if (tagName === "style" && n.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
1010
+ !(n.innerText || types2.index.textContent(n) || "").trim().length) {
1011
+ const cssText = types2.stringifyStylesheet(
1012
+ n.sheet
1053
1013
  );
1014
+ if (cssText) {
1015
+ attributes._cssText = cssText;
1016
+ }
1054
1017
  }
1055
- } else if (!("__context" in n)) {
1056
- const canvasDataURL = n.toDataURL(
1057
- dataURLOptions.type,
1058
- dataURLOptions.quality
1059
- );
1060
- const blankCanvas = doc.createElement("canvas");
1061
- blankCanvas.width = n.width;
1062
- blankCanvas.height = n.height;
1063
- const blankCanvasDataURL = blankCanvas.toDataURL(
1064
- dataURLOptions.type,
1065
- dataURLOptions.quality
1066
- );
1067
- if (canvasDataURL !== blankCanvasDataURL) {
1068
- attributes.rr_dataURL = canvasDataURL;
1018
+ if (tagName === "input" || tagName === "textarea" || tagName === "select") {
1019
+ const value = n.value;
1020
+ const checked = n.checked;
1021
+ if (attributes.type !== "radio" && attributes.type !== "checkbox" && attributes.type !== "submit" && attributes.type !== "button" && value) {
1022
+ attributes.value = types2.maskInputValue({
1023
+ element: n,
1024
+ type: types2.getInputType(n),
1025
+ tagName,
1026
+ value,
1027
+ maskInputOptions,
1028
+ maskInputFn
1029
+ });
1030
+ } else if (checked) {
1031
+ attributes.checked = checked;
1032
+ }
1069
1033
  }
1070
- }
1071
- }
1072
- if (tagName === "img" && inlineImages) {
1073
- if (!canvasService) {
1074
- canvasService = doc.createElement("canvas");
1075
- canvasCtx = canvasService.getContext("2d");
1076
- }
1077
- const image = n;
1078
- const imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
1079
- const priorCrossOrigin = image.crossOrigin;
1080
- const recordInlineImage = () => {
1081
- image.removeEventListener("load", recordInlineImage);
1082
- try {
1083
- canvasService.width = image.naturalWidth;
1084
- canvasService.height = image.naturalHeight;
1085
- canvasCtx.drawImage(image, 0, 0);
1086
- attributes.rr_dataURL = canvasService.toDataURL(
1087
- dataURLOptions.type,
1088
- dataURLOptions.quality
1089
- );
1090
- } catch (err) {
1091
- if (image.crossOrigin !== "anonymous") {
1092
- image.crossOrigin = "anonymous";
1093
- if (image.complete && image.naturalWidth !== 0)
1094
- recordInlineImage();
1095
- else image.addEventListener("load", recordInlineImage);
1096
- return;
1034
+ if (tagName === "option") {
1035
+ if (n.selected && !maskInputOptions["select"]) {
1036
+ attributes.selected = true;
1097
1037
  } else {
1098
- console.warn(
1099
- `Cannot inline img src=${imageSrc}! Error: ${err}`
1038
+ delete attributes.selected;
1039
+ }
1040
+ }
1041
+ if (tagName === "dialog" && n.open) {
1042
+ try {
1043
+ attributes.rr_open_mode = n.matches("dialog:modal") ? "modal" : "non-modal";
1044
+ } catch (e) {
1045
+ attributes.rr_open_mode = "modal";
1046
+ attributes.ph_rr_could_not_detect_modal = true;
1047
+ }
1048
+ }
1049
+ if (tagName === "canvas" && recordCanvas) {
1050
+ if (n.__context === "2d") {
1051
+ if (!types2.is2DCanvasBlank(n)) {
1052
+ attributes.rr_dataURL = n.toDataURL(
1053
+ dataURLOptions.type,
1054
+ dataURLOptions.quality
1055
+ );
1056
+ }
1057
+ } else if (!("__context" in n)) {
1058
+ const canvasDataURL = n.toDataURL(
1059
+ dataURLOptions.type,
1060
+ dataURLOptions.quality
1061
+ );
1062
+ const blankCanvas = doc.createElement("canvas");
1063
+ blankCanvas.width = n.width;
1064
+ blankCanvas.height = n.height;
1065
+ const blankCanvasDataURL = blankCanvas.toDataURL(
1066
+ dataURLOptions.type,
1067
+ dataURLOptions.quality
1100
1068
  );
1069
+ if (canvasDataURL !== blankCanvasDataURL) {
1070
+ attributes.rr_dataURL = canvasDataURL;
1071
+ }
1101
1072
  }
1102
1073
  }
1103
- if (image.crossOrigin === "anonymous") {
1104
- priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
1074
+ if (tagName === "img" && inlineImages) {
1075
+ if (!canvasService) {
1076
+ canvasService = doc.createElement("canvas");
1077
+ canvasCtx = canvasService.getContext("2d");
1078
+ }
1079
+ const image = n;
1080
+ const imageSrc = image.currentSrc || image.getAttribute("src") || "<unknown-src>";
1081
+ const priorCrossOrigin = image.crossOrigin;
1082
+ const recordInlineImage = () => {
1083
+ image.removeEventListener("load", recordInlineImage);
1084
+ try {
1085
+ canvasService.width = image.naturalWidth;
1086
+ canvasService.height = image.naturalHeight;
1087
+ canvasCtx.drawImage(image, 0, 0);
1088
+ attributes.rr_dataURL = canvasService.toDataURL(
1089
+ dataURLOptions.type,
1090
+ dataURLOptions.quality
1091
+ );
1092
+ } catch (err) {
1093
+ if (image.crossOrigin !== "anonymous") {
1094
+ image.crossOrigin = "anonymous";
1095
+ if (image.complete && image.naturalWidth !== 0)
1096
+ recordInlineImage();
1097
+ else image.addEventListener("load", recordInlineImage);
1098
+ return;
1099
+ } else {
1100
+ console.warn(
1101
+ `Cannot inline img src=${imageSrc}! Error: ${err}`
1102
+ );
1103
+ }
1104
+ }
1105
+ if (image.crossOrigin === "anonymous") {
1106
+ priorCrossOrigin ? attributes.crossOrigin = priorCrossOrigin : image.removeAttribute("crossorigin");
1107
+ }
1108
+ };
1109
+ if (image.complete && image.naturalWidth !== 0) recordInlineImage();
1110
+ else image.addEventListener("load", recordInlineImage);
1105
1111
  }
1106
- };
1107
- if (image.complete && image.naturalWidth !== 0) recordInlineImage();
1108
- else image.addEventListener("load", recordInlineImage);
1109
- }
1110
- if (tagName === "audio" || tagName === "video") {
1111
- const mediaAttributes = attributes;
1112
- mediaAttributes.rr_mediaState = n.paused ? "paused" : "played";
1113
- mediaAttributes.rr_mediaCurrentTime = n.currentTime;
1114
- mediaAttributes.rr_mediaPlaybackRate = n.playbackRate;
1115
- mediaAttributes.rr_mediaMuted = n.muted;
1116
- mediaAttributes.rr_mediaLoop = n.loop;
1117
- mediaAttributes.rr_mediaVolume = n.volume;
1118
- }
1119
- if (!newlyAddedElement) {
1120
- if (n.scrollLeft) {
1121
- attributes.rr_scrollLeft = n.scrollLeft;
1122
- }
1123
- if (n.scrollTop) {
1124
- attributes.rr_scrollTop = n.scrollTop;
1112
+ if (tagName === "audio" || tagName === "video") {
1113
+ const mediaAttributes = attributes;
1114
+ mediaAttributes.rr_mediaState = n.paused ? "paused" : "played";
1115
+ mediaAttributes.rr_mediaCurrentTime = n.currentTime;
1116
+ mediaAttributes.rr_mediaPlaybackRate = n.playbackRate;
1117
+ mediaAttributes.rr_mediaMuted = n.muted;
1118
+ mediaAttributes.rr_mediaLoop = n.loop;
1119
+ mediaAttributes.rr_mediaVolume = n.volume;
1120
+ }
1121
+ if (!newlyAddedElement) {
1122
+ if (n.scrollLeft) {
1123
+ attributes.rr_scrollLeft = n.scrollLeft;
1124
+ }
1125
+ if (n.scrollTop) {
1126
+ attributes.rr_scrollTop = n.scrollTop;
1127
+ }
1128
+ }
1129
+ if (needBlock) {
1130
+ const { width, height, left, top } = n.getBoundingClientRect();
1131
+ attributes = {
1132
+ class: attributes.class,
1133
+ rr_width: `${width}px`,
1134
+ rr_height: `${height}px`,
1135
+ rr_left: `${Math.floor(left + (((_a = doc.defaultView) == null ? void 0 : _a.scrollX) || 0))}px`,
1136
+ rr_top: `${Math.floor(top + (((_b = doc.defaultView) == null ? void 0 : _b.scrollY) || 0))}px`
1137
+ };
1138
+ }
1139
+ if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
1140
+ if (!n.contentDocument) {
1141
+ attributes.rr_src = attributes.src;
1142
+ }
1143
+ delete attributes.src;
1144
+ }
1145
+ let isCustomElement;
1146
+ try {
1147
+ if (customElements.get(tagName)) isCustomElement = true;
1148
+ } catch (e) {
1149
+ }
1150
+ return {
1151
+ type: types2.NodeType$1.Element,
1152
+ tagName,
1153
+ attributes,
1154
+ childNodes: [],
1155
+ isSVG: isSVGElement(n) || void 0,
1156
+ needBlock,
1157
+ rootId,
1158
+ isCustom: isCustomElement
1159
+ };
1125
1160
  }
1126
- }
1127
- if (needBlock) {
1128
- const { width, height, left, top } = n.getBoundingClientRect();
1129
- attributes = {
1130
- class: attributes.class,
1131
- rr_width: `${width}px`,
1132
- rr_height: `${height}px`,
1133
- rr_left: `${Math.floor(left + (((_a = doc.defaultView) == null ? void 0 : _a.scrollX) || 0))}px`,
1134
- rr_top: `${Math.floor(top + (((_b = doc.defaultView) == null ? void 0 : _b.scrollY) || 0))}px`
1135
- };
1136
- }
1137
- if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
1138
- if (!n.contentDocument) {
1139
- attributes.rr_src = attributes.src;
1161
+ function lowerIfExists(maybeAttr) {
1162
+ if (maybeAttr === void 0 || maybeAttr === null) {
1163
+ return "";
1164
+ } else {
1165
+ return maybeAttr.toLowerCase();
1166
+ }
1140
1167
  }
1141
- delete attributes.src;
1142
- }
1143
- let isCustomElement;
1144
- try {
1145
- if (customElements.get(tagName)) isCustomElement = true;
1146
- } catch (e) {
1147
- }
1148
- return {
1149
- type: types.NodeType$1.Element,
1150
- tagName,
1151
- attributes,
1152
- childNodes: [],
1153
- isSVG: isSVGElement(n) || void 0,
1154
- needBlock,
1155
- rootId,
1156
- isCustom: isCustomElement
1157
- };
1158
- }
1159
- function lowerIfExists(maybeAttr) {
1160
- if (maybeAttr === void 0 || maybeAttr === null) {
1161
- return "";
1162
- } else {
1163
- return maybeAttr.toLowerCase();
1164
- }
1165
- }
1166
- function slimDOMExcluded(sn, slimDOMOptions) {
1167
- if (slimDOMOptions.comment && sn.type === types.NodeType$1.Comment) {
1168
- return true;
1169
- } else if (sn.type === types.NodeType$1.Element) {
1170
- if (slimDOMOptions.script && // script tag
1171
- (sn.tagName === "script" || // (module)preload link
1172
- sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
1173
- sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && types.extractFileExtension(sn.attributes.href) === "js")) {
1174
- return true;
1175
- } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(
1176
- /^msapplication-tile(image|color)$/
1177
- ) || lowerIfExists(sn.attributes.name) === "application-name" || ["icon", "apple-touch-icon", "shortcut icon"].includes(
1178
- lowerIfExists(sn.attributes.rel)
1179
- )))) {
1180
- return true;
1181
- } else if (sn.tagName === "meta") {
1182
- if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
1183
- return true;
1184
- } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
1185
- lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
1186
- return true;
1187
- } else if (slimDOMOptions.headMetaRobots && ["robots", "googlebot", "bingbot"].includes(
1188
- lowerIfExists(sn.attributes.name)
1189
- )) {
1190
- return true;
1191
- } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
1192
- return true;
1193
- } else if (slimDOMOptions.headMetaAuthorship && (["author", "generator", "framework", "publisher", "progid"].includes(
1194
- lowerIfExists(sn.attributes.name)
1195
- ) || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
1196
- return true;
1197
- } else if (slimDOMOptions.headMetaVerification && [
1198
- "google-site-verification",
1199
- "yandex-verification",
1200
- "csrf-token",
1201
- "p:domain_verify",
1202
- "verify-v1",
1203
- "verification",
1204
- "shopify-checkout-api-token"
1205
- ].includes(lowerIfExists(sn.attributes.name))) {
1168
+ function slimDOMExcluded(sn, slimDOMOptions) {
1169
+ if (slimDOMOptions.comment && sn.type === types2.NodeType$1.Comment) {
1206
1170
  return true;
1171
+ } else if (sn.type === types2.NodeType$1.Element) {
1172
+ if (slimDOMOptions.script && // script tag
1173
+ (sn.tagName === "script" || // (module)preload link
1174
+ sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
1175
+ sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && types2.extractFileExtension(sn.attributes.href) === "js")) {
1176
+ return true;
1177
+ } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(
1178
+ /^msapplication-tile(image|color)$/
1179
+ ) || lowerIfExists(sn.attributes.name) === "application-name" || ["icon", "apple-touch-icon", "shortcut icon"].includes(
1180
+ lowerIfExists(sn.attributes.rel)
1181
+ )))) {
1182
+ return true;
1183
+ } else if (sn.tagName === "meta") {
1184
+ if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
1185
+ return true;
1186
+ } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
1187
+ lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
1188
+ return true;
1189
+ } else if (slimDOMOptions.headMetaRobots && ["robots", "googlebot", "bingbot"].includes(
1190
+ lowerIfExists(sn.attributes.name)
1191
+ )) {
1192
+ return true;
1193
+ } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
1194
+ return true;
1195
+ } else if (slimDOMOptions.headMetaAuthorship && (["author", "generator", "framework", "publisher", "progid"].includes(
1196
+ lowerIfExists(sn.attributes.name)
1197
+ ) || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
1198
+ return true;
1199
+ } else if (slimDOMOptions.headMetaVerification && [
1200
+ "google-site-verification",
1201
+ "yandex-verification",
1202
+ "csrf-token",
1203
+ "p:domain_verify",
1204
+ "verify-v1",
1205
+ "verification",
1206
+ "shopify-checkout-api-token"
1207
+ ].includes(lowerIfExists(sn.attributes.name))) {
1208
+ return true;
1209
+ }
1210
+ }
1207
1211
  }
1212
+ return false;
1208
1213
  }
1209
- }
1210
- return false;
1211
- }
1212
- var DEFAULT_MAX_DEPTH = 50;
1213
- var _maxDepthWarned = false;
1214
- var _maxDepthReached = false;
1215
- function wasMaxDepthReached() {
1216
- return _maxDepthReached;
1217
- }
1218
- function resetMaxDepthState() {
1219
- _maxDepthReached = false;
1220
- _maxDepthWarned = false;
1221
- }
1222
- function serializeNodeWithId(n, options) {
1223
- const {
1224
- doc,
1225
- mirror,
1226
- blockClass,
1227
- blockSelector,
1228
- maskTextClass,
1229
- maskTextSelector,
1230
- skipChild = false,
1231
- inlineStylesheet = true,
1232
- maskInputOptions = {},
1233
- maskTextFn,
1234
- maskInputFn,
1235
- slimDOMOptions,
1236
- dataURLOptions = {},
1237
- inlineImages = false,
1238
- recordCanvas = false,
1239
- onSerialize,
1240
- onIframeLoad,
1241
- iframeLoadTimeout = 5e3,
1242
- onStylesheetLoad,
1243
- stylesheetLoadTimeout = 5e3,
1244
- keepIframeSrcFn = () => false,
1245
- newlyAddedElement = false,
1246
- depth = 0,
1247
- maxDepth = DEFAULT_MAX_DEPTH
1248
- } = options;
1249
- let { needsMask } = options;
1250
- let { preserveWhiteSpace = true } = options;
1251
- if (depth >= maxDepth) {
1252
- _maxDepthReached = true;
1253
- if (!_maxDepthWarned) {
1254
- _maxDepthWarned = true;
1255
- console.warn(
1256
- `[rrweb-snapshot] DOM tree depth exceeded max depth of ${maxDepth}. Children beyond this depth will not be recorded. This may indicate deeply nested DOM structures.`
1257
- );
1214
+ var DEFAULT_MAX_DEPTH = 50;
1215
+ var _maxDepthWarned = false;
1216
+ var _maxDepthReached = false;
1217
+ function wasMaxDepthReached() {
1218
+ return _maxDepthReached;
1258
1219
  }
1259
- return null;
1260
- }
1261
- if (!needsMask) {
1262
- const checkAncestors = needsMask === void 0;
1263
- needsMask = needMaskingText(
1264
- n,
1265
- maskTextClass,
1266
- maskTextSelector,
1267
- checkAncestors
1268
- );
1269
- }
1270
- const _serializedNode = serializeNode(n, {
1271
- doc,
1272
- mirror,
1273
- blockClass,
1274
- blockSelector,
1275
- needsMask,
1276
- inlineStylesheet,
1277
- maskInputOptions,
1278
- maskTextFn,
1279
- maskInputFn,
1280
- dataURLOptions,
1281
- inlineImages,
1282
- recordCanvas,
1283
- keepIframeSrcFn,
1284
- newlyAddedElement
1285
- });
1286
- if (!_serializedNode) {
1287
- console.warn(n, "not serialized");
1288
- return null;
1289
- }
1290
- let id;
1291
- if (mirror.hasNode(n)) {
1292
- id = mirror.getId(n);
1293
- } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === types.NodeType$1.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
1294
- id = IGNORED_NODE;
1295
- } else {
1296
- id = genId();
1297
- }
1298
- const serializedNode = Object.assign(_serializedNode, { id });
1299
- mirror.add(n, serializedNode);
1300
- if (id === IGNORED_NODE) {
1301
- return null;
1302
- }
1303
- if (onSerialize) {
1304
- onSerialize(n);
1305
- }
1306
- let recordChild = !skipChild;
1307
- if (serializedNode.type === types.NodeType$1.Element) {
1308
- recordChild = recordChild && !serializedNode.needBlock;
1309
- delete serializedNode.needBlock;
1310
- const shadowRootEl = types.index.shadowRoot(n);
1311
- if (shadowRootEl && types.isNativeShadowDom(shadowRootEl))
1312
- serializedNode.isShadowHost = true;
1313
- }
1314
- if ((serializedNode.type === types.NodeType$1.Document || serializedNode.type === types.NodeType$1.Element) && recordChild) {
1315
- if (slimDOMOptions.headWhitespace && serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "head") {
1316
- preserveWhiteSpace = false;
1317
- }
1318
- const bypassOptions = {
1319
- doc,
1320
- mirror,
1321
- blockClass,
1322
- blockSelector,
1323
- needsMask,
1324
- maskTextClass,
1325
- maskTextSelector,
1326
- skipChild,
1327
- inlineStylesheet,
1328
- maskInputOptions,
1329
- maskTextFn,
1330
- maskInputFn,
1331
- slimDOMOptions,
1332
- dataURLOptions,
1333
- inlineImages,
1334
- recordCanvas,
1335
- preserveWhiteSpace,
1336
- onSerialize,
1337
- onIframeLoad,
1338
- iframeLoadTimeout,
1339
- onStylesheetLoad,
1340
- stylesheetLoadTimeout,
1341
- keepIframeSrcFn,
1342
- depth: depth + 1,
1343
- maxDepth
1344
- };
1345
- if (serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1346
- else {
1347
- for (const childN of Array.from(types.index.childNodes(n))) {
1348
- const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1349
- if (serializedChildNode) {
1350
- serializedNode.childNodes.push(serializedChildNode);
1351
- }
1352
- }
1220
+ function resetMaxDepthState() {
1221
+ _maxDepthReached = false;
1222
+ _maxDepthWarned = false;
1353
1223
  }
1354
- let shadowRootEl = null;
1355
- if (types.isElement(n) && (shadowRootEl = types.index.shadowRoot(n))) {
1356
- for (const childN of Array.from(types.index.childNodes(shadowRootEl))) {
1357
- const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1358
- if (serializedChildNode) {
1359
- types.isNativeShadowDom(shadowRootEl) && (serializedChildNode.isShadow = true);
1360
- serializedNode.childNodes.push(serializedChildNode);
1224
+ function serializeNodeWithId(n, options) {
1225
+ const {
1226
+ doc,
1227
+ mirror,
1228
+ blockClass,
1229
+ blockSelector,
1230
+ maskTextClass,
1231
+ maskTextSelector,
1232
+ skipChild = false,
1233
+ inlineStylesheet = true,
1234
+ maskInputOptions = {},
1235
+ maskTextFn,
1236
+ maskInputFn,
1237
+ slimDOMOptions,
1238
+ dataURLOptions = {},
1239
+ inlineImages = false,
1240
+ recordCanvas = false,
1241
+ onSerialize,
1242
+ onIframeLoad,
1243
+ iframeLoadTimeout = 5e3,
1244
+ onStylesheetLoad,
1245
+ stylesheetLoadTimeout = 5e3,
1246
+ keepIframeSrcFn = () => false,
1247
+ newlyAddedElement = false,
1248
+ depth = 0,
1249
+ maxDepth = DEFAULT_MAX_DEPTH
1250
+ } = options;
1251
+ let { needsMask } = options;
1252
+ let { preserveWhiteSpace = true } = options;
1253
+ if (depth >= maxDepth) {
1254
+ _maxDepthReached = true;
1255
+ if (!_maxDepthWarned) {
1256
+ _maxDepthWarned = true;
1257
+ console.warn(
1258
+ `[rrweb-snapshot] DOM tree depth exceeded max depth of ${maxDepth}. Children beyond this depth will not be recorded. This may indicate deeply nested DOM structures.`
1259
+ );
1361
1260
  }
1261
+ return null;
1362
1262
  }
1363
- }
1364
- }
1365
- const parent = types.index.parentNode(n);
1366
- if (parent && types.isShadowRoot(parent) && types.isNativeShadowDom(parent)) {
1367
- serializedNode.isShadow = true;
1368
- }
1369
- if (serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "iframe") {
1370
- onceIframeLoaded(
1371
- n,
1372
- () => {
1373
- const iframeDoc = n.contentDocument;
1374
- if (iframeDoc && onIframeLoad) {
1375
- const serializedIframeNode = serializeNodeWithId(iframeDoc, {
1376
- doc: iframeDoc,
1377
- mirror,
1378
- blockClass,
1379
- blockSelector,
1380
- needsMask,
1381
- maskTextClass,
1382
- maskTextSelector,
1383
- skipChild: false,
1384
- inlineStylesheet,
1385
- maskInputOptions,
1386
- maskTextFn,
1387
- maskInputFn,
1388
- slimDOMOptions,
1389
- dataURLOptions,
1390
- inlineImages,
1391
- recordCanvas,
1392
- preserveWhiteSpace,
1393
- onSerialize,
1394
- onIframeLoad,
1395
- iframeLoadTimeout,
1396
- onStylesheetLoad,
1397
- stylesheetLoadTimeout,
1398
- keepIframeSrcFn,
1399
- depth: depth + 1,
1400
- maxDepth
1401
- });
1402
- if (serializedIframeNode) {
1403
- onIframeLoad(
1404
- n,
1405
- serializedIframeNode
1406
- );
1263
+ if (!needsMask) {
1264
+ const checkAncestors = needsMask === void 0;
1265
+ needsMask = needMaskingText(
1266
+ n,
1267
+ maskTextClass,
1268
+ maskTextSelector,
1269
+ checkAncestors
1270
+ );
1271
+ }
1272
+ const _serializedNode = serializeNode(n, {
1273
+ doc,
1274
+ mirror,
1275
+ blockClass,
1276
+ blockSelector,
1277
+ needsMask,
1278
+ inlineStylesheet,
1279
+ maskInputOptions,
1280
+ maskTextFn,
1281
+ maskInputFn,
1282
+ dataURLOptions,
1283
+ inlineImages,
1284
+ recordCanvas,
1285
+ keepIframeSrcFn,
1286
+ newlyAddedElement
1287
+ });
1288
+ if (!_serializedNode) {
1289
+ console.warn(n, "not serialized");
1290
+ return null;
1291
+ }
1292
+ let id;
1293
+ if (mirror.hasNode(n)) {
1294
+ id = mirror.getId(n);
1295
+ } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === types2.NodeType$1.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
1296
+ id = IGNORED_NODE;
1297
+ } else {
1298
+ id = genId();
1299
+ }
1300
+ const serializedNode = Object.assign(_serializedNode, { id });
1301
+ mirror.add(n, serializedNode);
1302
+ if (id === IGNORED_NODE) {
1303
+ return null;
1304
+ }
1305
+ if (onSerialize) {
1306
+ onSerialize(n);
1307
+ }
1308
+ let recordChild = !skipChild;
1309
+ if (serializedNode.type === types2.NodeType$1.Element) {
1310
+ recordChild = recordChild && !serializedNode.needBlock;
1311
+ delete serializedNode.needBlock;
1312
+ const shadowRootEl = types2.index.shadowRoot(n);
1313
+ if (shadowRootEl && types2.isNativeShadowDom(shadowRootEl))
1314
+ serializedNode.isShadowHost = true;
1315
+ }
1316
+ if ((serializedNode.type === types2.NodeType$1.Document || serializedNode.type === types2.NodeType$1.Element) && recordChild) {
1317
+ if (slimDOMOptions.headWhitespace && serializedNode.type === types2.NodeType$1.Element && serializedNode.tagName === "head") {
1318
+ preserveWhiteSpace = false;
1319
+ }
1320
+ const bypassOptions = {
1321
+ doc,
1322
+ mirror,
1323
+ blockClass,
1324
+ blockSelector,
1325
+ needsMask,
1326
+ maskTextClass,
1327
+ maskTextSelector,
1328
+ skipChild,
1329
+ inlineStylesheet,
1330
+ maskInputOptions,
1331
+ maskTextFn,
1332
+ maskInputFn,
1333
+ slimDOMOptions,
1334
+ dataURLOptions,
1335
+ inlineImages,
1336
+ recordCanvas,
1337
+ preserveWhiteSpace,
1338
+ onSerialize,
1339
+ onIframeLoad,
1340
+ iframeLoadTimeout,
1341
+ onStylesheetLoad,
1342
+ stylesheetLoadTimeout,
1343
+ keepIframeSrcFn,
1344
+ depth: depth + 1,
1345
+ maxDepth
1346
+ };
1347
+ if (serializedNode.type === types2.NodeType$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1348
+ else {
1349
+ for (const childN of Array.from(types2.index.childNodes(n))) {
1350
+ const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1351
+ if (serializedChildNode) {
1352
+ serializedNode.childNodes.push(serializedChildNode);
1353
+ }
1407
1354
  }
1408
1355
  }
1409
- },
1410
- iframeLoadTimeout
1411
- );
1412
- }
1413
- if (serializedNode.type === types.NodeType$1.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && types.extractFileExtension(serializedNode.attributes.href) === "css")) {
1414
- onceStylesheetLoaded(
1415
- n,
1416
- () => {
1417
- if (onStylesheetLoad) {
1418
- const serializedLinkNode = serializeNodeWithId(n, {
1419
- doc,
1420
- mirror,
1421
- blockClass,
1422
- blockSelector,
1423
- needsMask,
1424
- maskTextClass,
1425
- maskTextSelector,
1426
- skipChild: false,
1427
- inlineStylesheet,
1428
- maskInputOptions,
1429
- maskTextFn,
1430
- maskInputFn,
1431
- slimDOMOptions,
1432
- dataURLOptions,
1433
- inlineImages,
1434
- recordCanvas,
1435
- preserveWhiteSpace,
1436
- onSerialize,
1437
- onIframeLoad,
1438
- iframeLoadTimeout,
1439
- onStylesheetLoad,
1440
- stylesheetLoadTimeout,
1441
- keepIframeSrcFn,
1442
- depth,
1443
- maxDepth
1444
- });
1445
- if (serializedLinkNode) {
1446
- onStylesheetLoad(
1447
- n,
1448
- serializedLinkNode
1449
- );
1356
+ let shadowRootEl = null;
1357
+ if (types2.isElement(n) && (shadowRootEl = types2.index.shadowRoot(n))) {
1358
+ for (const childN of Array.from(types2.index.childNodes(shadowRootEl))) {
1359
+ const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1360
+ if (serializedChildNode) {
1361
+ types2.isNativeShadowDom(shadowRootEl) && (serializedChildNode.isShadow = true);
1362
+ serializedNode.childNodes.push(serializedChildNode);
1363
+ }
1450
1364
  }
1451
1365
  }
1452
- },
1453
- stylesheetLoadTimeout
1454
- );
1455
- }
1456
- return serializedNode;
1457
- }
1458
- function slimDOMDefaults(slimDOM) {
1459
- if (slimDOM === true || slimDOM === "all") {
1460
- return {
1461
- script: true,
1462
- comment: true,
1463
- headFavicon: true,
1464
- headWhitespace: true,
1465
- headMetaSocial: true,
1466
- headMetaRobots: true,
1467
- headMetaHttpEquiv: true,
1468
- headMetaVerification: true,
1469
- headMetaAuthorship: slimDOM === "all",
1470
- headMetaDescKeywords: slimDOM === "all",
1471
- headTitleMutations: slimDOM === "all"
1472
- };
1473
- }
1474
- if (slimDOM === false) {
1475
- return {};
1476
- }
1477
- return slimDOM;
1478
- }
1479
- function snapshot(n, options) {
1480
- const {
1481
- mirror = new types.Mirror(),
1482
- blockClass = "rr-block",
1483
- blockSelector = null,
1484
- maskTextClass = "rr-mask",
1485
- maskTextSelector = null,
1486
- inlineStylesheet = true,
1487
- inlineImages = false,
1488
- recordCanvas = false,
1489
- maskAllInputs = false,
1490
- maskTextFn,
1491
- maskInputFn,
1492
- slimDOM = false,
1493
- dataURLOptions,
1494
- preserveWhiteSpace,
1495
- onSerialize,
1496
- onIframeLoad,
1497
- iframeLoadTimeout,
1498
- onStylesheetLoad,
1499
- stylesheetLoadTimeout,
1500
- keepIframeSrcFn = () => false,
1501
- maxDepth
1502
- } = options || {};
1503
- const maskInputOptions = maskAllInputs === true ? {
1504
- color: true,
1505
- date: true,
1506
- "datetime-local": true,
1507
- email: true,
1508
- month: true,
1509
- number: true,
1510
- range: true,
1511
- search: true,
1512
- tel: true,
1513
- text: true,
1514
- time: true,
1515
- url: true,
1516
- week: true,
1517
- textarea: true,
1518
- select: true,
1519
- password: true
1520
- } : maskAllInputs === false ? {
1521
- password: true
1522
- } : maskAllInputs;
1523
- const slimDOMOptions = slimDOMDefaults(slimDOM);
1524
- return serializeNodeWithId(n, {
1525
- doc: n,
1526
- mirror,
1527
- blockClass,
1528
- blockSelector,
1529
- maskTextClass,
1530
- maskTextSelector,
1531
- skipChild: false,
1532
- inlineStylesheet,
1533
- maskInputOptions,
1534
- maskTextFn,
1535
- maskInputFn,
1536
- slimDOMOptions,
1537
- dataURLOptions,
1538
- inlineImages,
1539
- recordCanvas,
1540
- preserveWhiteSpace,
1541
- onSerialize,
1542
- onIframeLoad,
1543
- iframeLoadTimeout,
1544
- onStylesheetLoad,
1545
- stylesheetLoadTimeout,
1546
- keepIframeSrcFn,
1547
- newlyAddedElement: false,
1548
- maxDepth
1549
- });
1550
- }
1551
- function visitSnapshot(node, onVisit) {
1552
- function walk(current) {
1553
- onVisit(current);
1554
- if (current.type === types.NodeType$1.Document || current.type === types.NodeType$1.Element) {
1555
- current.childNodes.forEach(walk);
1366
+ }
1367
+ const parent = types2.index.parentNode(n);
1368
+ if (parent && types2.isShadowRoot(parent) && types2.isNativeShadowDom(parent)) {
1369
+ serializedNode.isShadow = true;
1370
+ }
1371
+ if (serializedNode.type === types2.NodeType$1.Element && serializedNode.tagName === "iframe") {
1372
+ onceIframeLoaded(
1373
+ n,
1374
+ () => {
1375
+ const iframeDoc = n.contentDocument;
1376
+ if (iframeDoc && onIframeLoad) {
1377
+ const serializedIframeNode = serializeNodeWithId(iframeDoc, {
1378
+ doc: iframeDoc,
1379
+ mirror,
1380
+ blockClass,
1381
+ blockSelector,
1382
+ needsMask,
1383
+ maskTextClass,
1384
+ maskTextSelector,
1385
+ skipChild: false,
1386
+ inlineStylesheet,
1387
+ maskInputOptions,
1388
+ maskTextFn,
1389
+ maskInputFn,
1390
+ slimDOMOptions,
1391
+ dataURLOptions,
1392
+ inlineImages,
1393
+ recordCanvas,
1394
+ preserveWhiteSpace,
1395
+ onSerialize,
1396
+ onIframeLoad,
1397
+ iframeLoadTimeout,
1398
+ onStylesheetLoad,
1399
+ stylesheetLoadTimeout,
1400
+ keepIframeSrcFn,
1401
+ depth: depth + 1,
1402
+ maxDepth
1403
+ });
1404
+ if (serializedIframeNode) {
1405
+ onIframeLoad(
1406
+ n,
1407
+ serializedIframeNode
1408
+ );
1409
+ }
1410
+ }
1411
+ },
1412
+ iframeLoadTimeout
1413
+ );
1414
+ }
1415
+ if (serializedNode.type === types2.NodeType$1.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && types2.extractFileExtension(serializedNode.attributes.href) === "css")) {
1416
+ onceStylesheetLoaded(
1417
+ n,
1418
+ () => {
1419
+ if (onStylesheetLoad) {
1420
+ const serializedLinkNode = serializeNodeWithId(n, {
1421
+ doc,
1422
+ mirror,
1423
+ blockClass,
1424
+ blockSelector,
1425
+ needsMask,
1426
+ maskTextClass,
1427
+ maskTextSelector,
1428
+ skipChild: false,
1429
+ inlineStylesheet,
1430
+ maskInputOptions,
1431
+ maskTextFn,
1432
+ maskInputFn,
1433
+ slimDOMOptions,
1434
+ dataURLOptions,
1435
+ inlineImages,
1436
+ recordCanvas,
1437
+ preserveWhiteSpace,
1438
+ onSerialize,
1439
+ onIframeLoad,
1440
+ iframeLoadTimeout,
1441
+ onStylesheetLoad,
1442
+ stylesheetLoadTimeout,
1443
+ keepIframeSrcFn,
1444
+ depth,
1445
+ maxDepth
1446
+ });
1447
+ if (serializedLinkNode) {
1448
+ onStylesheetLoad(
1449
+ n,
1450
+ serializedLinkNode
1451
+ );
1452
+ }
1453
+ }
1454
+ },
1455
+ stylesheetLoadTimeout
1456
+ );
1457
+ }
1458
+ return serializedNode;
1556
1459
  }
1460
+ function slimDOMDefaults(slimDOM) {
1461
+ if (slimDOM === true || slimDOM === "all") {
1462
+ return {
1463
+ script: true,
1464
+ comment: true,
1465
+ headFavicon: true,
1466
+ headWhitespace: true,
1467
+ headMetaSocial: true,
1468
+ headMetaRobots: true,
1469
+ headMetaHttpEquiv: true,
1470
+ headMetaVerification: true,
1471
+ headMetaAuthorship: slimDOM === "all",
1472
+ headMetaDescKeywords: slimDOM === "all",
1473
+ headTitleMutations: slimDOM === "all"
1474
+ };
1475
+ }
1476
+ if (slimDOM === false) {
1477
+ return {};
1478
+ }
1479
+ return slimDOM;
1480
+ }
1481
+ function snapshot(n, options) {
1482
+ const {
1483
+ mirror = new types2.Mirror(),
1484
+ blockClass = "rr-block",
1485
+ blockSelector = null,
1486
+ maskTextClass = "rr-mask",
1487
+ maskTextSelector = null,
1488
+ inlineStylesheet = true,
1489
+ inlineImages = false,
1490
+ recordCanvas = false,
1491
+ maskAllInputs = false,
1492
+ maskTextFn,
1493
+ maskInputFn,
1494
+ slimDOM = false,
1495
+ dataURLOptions,
1496
+ preserveWhiteSpace,
1497
+ onSerialize,
1498
+ onIframeLoad,
1499
+ iframeLoadTimeout,
1500
+ onStylesheetLoad,
1501
+ stylesheetLoadTimeout,
1502
+ keepIframeSrcFn = () => false,
1503
+ maxDepth
1504
+ } = options || {};
1505
+ const maskInputOptions = maskAllInputs === true ? {
1506
+ color: true,
1507
+ date: true,
1508
+ "datetime-local": true,
1509
+ email: true,
1510
+ month: true,
1511
+ number: true,
1512
+ range: true,
1513
+ search: true,
1514
+ tel: true,
1515
+ text: true,
1516
+ time: true,
1517
+ url: true,
1518
+ week: true,
1519
+ textarea: true,
1520
+ select: true,
1521
+ password: true
1522
+ } : maskAllInputs === false ? {
1523
+ password: true
1524
+ } : maskAllInputs;
1525
+ const slimDOMOptions = slimDOMDefaults(slimDOM);
1526
+ return serializeNodeWithId(n, {
1527
+ doc: n,
1528
+ mirror,
1529
+ blockClass,
1530
+ blockSelector,
1531
+ maskTextClass,
1532
+ maskTextSelector,
1533
+ skipChild: false,
1534
+ inlineStylesheet,
1535
+ maskInputOptions,
1536
+ maskTextFn,
1537
+ maskInputFn,
1538
+ slimDOMOptions,
1539
+ dataURLOptions,
1540
+ inlineImages,
1541
+ recordCanvas,
1542
+ preserveWhiteSpace,
1543
+ onSerialize,
1544
+ onIframeLoad,
1545
+ iframeLoadTimeout,
1546
+ onStylesheetLoad,
1547
+ stylesheetLoadTimeout,
1548
+ keepIframeSrcFn,
1549
+ newlyAddedElement: false,
1550
+ maxDepth
1551
+ });
1552
+ }
1553
+ function visitSnapshot(node, onVisit) {
1554
+ function walk(current) {
1555
+ onVisit(current);
1556
+ if (current.type === types2.NodeType$1.Document || current.type === types2.NodeType$1.Element) {
1557
+ current.childNodes.forEach(walk);
1558
+ }
1559
+ }
1560
+ walk(node);
1561
+ }
1562
+ function cleanupSnapshot() {
1563
+ _id = 1;
1564
+ }
1565
+ exports2.DEFAULT_MAX_DEPTH = DEFAULT_MAX_DEPTH;
1566
+ exports2.IGNORED_NODE = IGNORED_NODE;
1567
+ exports2.classMatchesRegex = classMatchesRegex;
1568
+ exports2.cleanupSnapshot = cleanupSnapshot;
1569
+ exports2.genId = genId;
1570
+ exports2.ignoreAttribute = ignoreAttribute;
1571
+ exports2.needMaskingText = needMaskingText;
1572
+ exports2.resetMaxDepthState = resetMaxDepthState;
1573
+ exports2.serializeNodeWithId = serializeNodeWithId;
1574
+ exports2.slimDOMDefaults = slimDOMDefaults;
1575
+ exports2.snapshot = snapshot;
1576
+ exports2.transformAttribute = transformAttribute;
1577
+ exports2.visitSnapshot = visitSnapshot;
1578
+ exports2.wasMaxDepthReached = wasMaxDepthReached;
1557
1579
  }
1558
- walk(node);
1559
- }
1560
- function cleanupSnapshot() {
1561
- _id = 1;
1562
- }
1580
+ });
1581
+
1582
+ // dist/record.cjs
1583
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
1584
+ var record = require_record_Rc5ocxPN();
1585
+ var types = require_types_BjupQhwp();
1586
+ exports.DEFAULT_MAX_DEPTH = record.DEFAULT_MAX_DEPTH;
1587
+ exports.IGNORED_NODE = record.IGNORED_NODE;
1588
+ exports.classMatchesRegex = record.classMatchesRegex;
1589
+ exports.cleanupSnapshot = record.cleanupSnapshot;
1590
+ exports.genId = record.genId;
1591
+ exports.ignoreAttribute = record.ignoreAttribute;
1592
+ exports.needMaskingText = record.needMaskingText;
1593
+ exports.serializeNodeWithId = record.serializeNodeWithId;
1594
+ exports.snapshot = record.snapshot;
1595
+ exports.transformAttribute = record.transformAttribute;
1596
+ exports.visitSnapshot = record.visitSnapshot;
1597
+ exports.wasMaxDepthReached = record.wasMaxDepthReached;
1563
1598
  exports.Mirror = types.Mirror;
1564
1599
  exports.NodeType = types.NodeType;
1565
1600
  exports.absolutifyURLs = types.absolutifyURLs;
@@ -1581,20 +1616,6 @@ exports.recompressBase64Image = types.recompressBase64Image;
1581
1616
  exports.stringifyRule = types.stringifyRule;
1582
1617
  exports.stringifyStylesheet = types.stringifyStylesheet;
1583
1618
  exports.toLowerCase = types.toLowerCase;
1584
- exports.DEFAULT_MAX_DEPTH = DEFAULT_MAX_DEPTH;
1585
- exports.IGNORED_NODE = IGNORED_NODE;
1586
- exports.classMatchesRegex = classMatchesRegex;
1587
- exports.cleanupSnapshot = cleanupSnapshot;
1588
- exports.genId = genId;
1589
- exports.ignoreAttribute = ignoreAttribute;
1590
- exports.needMaskingText = needMaskingText;
1591
- exports.resetMaxDepthState = resetMaxDepthState;
1592
- exports.serializeNodeWithId = serializeNodeWithId;
1593
- exports.slimDOMDefaults = slimDOMDefaults;
1594
- exports.snapshot = snapshot;
1595
- exports.transformAttribute = transformAttribute;
1596
- exports.visitSnapshot = visitSnapshot;
1597
- exports.wasMaxDepthReached = wasMaxDepthReached;
1598
1619
  ;if (typeof module.exports == "object" && typeof exports == "object") {
1599
1620
  var __cp = (to, from, except, desc) => {
1600
1621
  if ((from && typeof from === "object") || typeof from === "function") {