@posthog/rrweb-snapshot 0.0.40 → 0.0.42

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