@posthog/rrweb-snapshot 0.0.10 → 0.0.11

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.
@@ -3,7 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
- var NodeType = /* @__PURE__ */ ((NodeType2) => {
6
+ var NodeType$1 = /* @__PURE__ */ ((NodeType2) => {
7
7
  NodeType2[NodeType2["Document"] = 0] = "Document";
8
8
  NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
9
9
  NodeType2[NodeType2["Element"] = 2] = "Element";
@@ -11,7 +11,7 @@ var NodeType = /* @__PURE__ */ ((NodeType2) => {
11
11
  NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
12
12
  NodeType2[NodeType2["Comment"] = 5] = "Comment";
13
13
  return NodeType2;
14
- })(NodeType || {});
14
+ })(NodeType$1 || {});
15
15
  const testableAccessors = {
16
16
  Node: ["childNodes", "parentNode", "parentElement", "textContent"],
17
17
  ShadowRoot: ["host", "styleSheets"],
@@ -235,13 +235,9 @@ function stringifyStylesheet(s) {
235
235
  if (!rules) {
236
236
  return null;
237
237
  }
238
- let sheetHref = s.href;
239
- if (!sheetHref && s.ownerNode && s.ownerNode.ownerDocument) {
240
- sheetHref = s.ownerNode.ownerDocument.location.href;
241
- }
242
238
  const stringifiedRules = Array.from(
243
239
  rules,
244
- (rule2) => stringifyRule(rule2, sheetHref)
240
+ (rule2) => stringifyRule(rule2, s.href)
245
241
  ).join("");
246
242
  return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
247
243
  } catch (error) {
@@ -390,13 +386,13 @@ function is2DCanvasBlank(canvas) {
390
386
  }
391
387
  function isNodeMetaEqual(a, b) {
392
388
  if (!a || !b || a.type !== b.type) return false;
393
- if (a.type === NodeType.Document)
389
+ if (a.type === NodeType$1.Document)
394
390
  return a.compatMode === b.compatMode;
395
- else if (a.type === NodeType.DocumentType)
391
+ else if (a.type === NodeType$1.DocumentType)
396
392
  return a.name === b.name && a.publicId === b.publicId && a.systemId === b.systemId;
397
- else if (a.type === NodeType.Comment || a.type === NodeType.Text || a.type === NodeType.CDATA)
393
+ else if (a.type === NodeType$1.Comment || a.type === NodeType$1.Text || a.type === NodeType$1.CDATA)
398
394
  return a.textContent === b.textContent;
399
- else if (a.type === NodeType.Element)
395
+ else if (a.type === NodeType$1.Element)
400
396
  return a.tagName === b.tagName && JSON.stringify(a.attributes) === JSON.stringify(b.attributes) && a.isSVG === b.isSVG && a.needBlock === b.needBlock;
401
397
  return false;
402
398
  }
@@ -466,90 +462,6 @@ function absolutifyURLs(cssText, href) {
466
462
  }
467
463
  );
468
464
  }
469
- const normalizationCache = /* @__PURE__ */ new Map();
470
- const splitCache = /* @__PURE__ */ new Map();
471
- function normalizeCssString(cssText) {
472
- if (!normalizationCache.has(cssText)) {
473
- const normalized = cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
474
- normalizationCache.set(cssText, normalized);
475
- }
476
- return normalizationCache.get(cssText);
477
- }
478
- function splitCssText(cssText, style) {
479
- const og = cssText;
480
- if (splitCache.has(cssText)) {
481
- return splitCache.get(cssText);
482
- }
483
- const childNodes2 = Array.from(style.childNodes);
484
- const splits = [];
485
- let iterLimit = 0;
486
- if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
487
- let cssTextNorm = normalizeCssString(cssText);
488
- const normFactor = cssTextNorm.length / cssText.length;
489
- for (let i = 1; i < childNodes2.length; i++) {
490
- if (childNodes2[i].textContent && typeof childNodes2[i].textContent === "string") {
491
- const textContentNorm = normalizeCssString(childNodes2[i].textContent);
492
- let j = 3;
493
- for (; j < textContentNorm.length; j++) {
494
- if (
495
- // keep consuming css identifiers (to get a decent chunk more quickly)
496
- textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
497
- textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1
498
- ) {
499
- continue;
500
- }
501
- break;
502
- }
503
- for (; j < textContentNorm.length; j++) {
504
- const bit = textContentNorm.substring(0, j);
505
- const bits = cssTextNorm.split(bit);
506
- let splitNorm = -1;
507
- if (bits.length === 2) {
508
- splitNorm = cssTextNorm.indexOf(bit);
509
- } else if (bits.length > 2 && bits[0] === "" && childNodes2[i - 1].textContent !== "") {
510
- splitNorm = cssTextNorm.indexOf(bit, 1);
511
- }
512
- if (splitNorm !== -1) {
513
- let k = Math.floor(splitNorm / normFactor);
514
- for (; k > 0 && k < cssText.length; ) {
515
- iterLimit += 1;
516
- if (iterLimit > 50 * childNodes2.length) {
517
- splits.push(cssText);
518
- return splits;
519
- }
520
- const normPart = normalizeCssString(cssText.substring(0, k));
521
- if (normPart.length === splitNorm) {
522
- splits.push(cssText.substring(0, k));
523
- cssText = cssText.substring(k);
524
- cssTextNorm = cssTextNorm.substring(splitNorm);
525
- break;
526
- } else if (normPart.length < splitNorm) {
527
- k += Math.max(
528
- 1,
529
- Math.floor((splitNorm - normPart.length) / normFactor)
530
- );
531
- } else {
532
- k -= Math.max(
533
- 1,
534
- Math.floor((normPart.length - splitNorm) * normFactor)
535
- );
536
- }
537
- }
538
- break;
539
- }
540
- }
541
- }
542
- }
543
- }
544
- splits.push(cssText);
545
- if (og) {
546
- splitCache.set(og, splits);
547
- }
548
- return splits;
549
- }
550
- function markCssSplits(cssText, style) {
551
- return splitCssText(cssText, style).join("/* rr_split */");
552
- }
553
465
  let _id = 1;
554
466
  const tagNameRegex = new RegExp("[^a-z0-9-_:]");
555
467
  const IGNORED_NODE = -2;
@@ -808,28 +720,27 @@ function serializeNode(n, options) {
808
720
  inlineImages,
809
721
  recordCanvas,
810
722
  keepIframeSrcFn,
811
- newlyAddedElement = false,
812
- cssCaptured = false
723
+ newlyAddedElement = false
813
724
  } = options;
814
725
  const rootId = getRootId(doc, mirror);
815
726
  switch (n.nodeType) {
816
727
  case n.DOCUMENT_NODE:
817
728
  if (n.compatMode !== "CSS1Compat") {
818
729
  return {
819
- type: NodeType.Document,
730
+ type: NodeType$1.Document,
820
731
  childNodes: [],
821
732
  compatMode: n.compatMode
822
733
  // probably "BackCompat"
823
734
  };
824
735
  } else {
825
736
  return {
826
- type: NodeType.Document,
737
+ type: NodeType$1.Document,
827
738
  childNodes: []
828
739
  };
829
740
  }
830
741
  case n.DOCUMENT_TYPE_NODE:
831
742
  return {
832
- type: NodeType.DocumentType,
743
+ type: NodeType$1.DocumentType,
833
744
  name: n.name,
834
745
  publicId: n.publicId,
835
746
  systemId: n.systemId,
@@ -855,18 +766,17 @@ function serializeNode(n, options) {
855
766
  doc,
856
767
  needsMask,
857
768
  maskTextFn,
858
- rootId,
859
- cssCaptured
769
+ rootId
860
770
  });
861
771
  case n.CDATA_SECTION_NODE:
862
772
  return {
863
- type: NodeType.CDATA,
773
+ type: NodeType$1.CDATA,
864
774
  textContent: "",
865
775
  rootId
866
776
  };
867
777
  case n.COMMENT_NODE:
868
778
  return {
869
- type: NodeType.Comment,
779
+ type: NodeType$1.Comment,
870
780
  textContent: index.textContent(n) || "",
871
781
  rootId
872
782
  };
@@ -880,26 +790,37 @@ function getRootId(doc, mirror) {
880
790
  return docId === 1 ? void 0 : docId;
881
791
  }
882
792
  function serializeTextNode(n, options) {
883
- const { needsMask, maskTextFn, rootId, cssCaptured } = options;
793
+ var _a;
794
+ const { needsMask, maskTextFn, rootId } = options;
884
795
  const parent = index.parentNode(n);
885
796
  const parentTagName = parent && parent.tagName;
886
- let textContent2 = "";
797
+ let text = index.textContent(n);
887
798
  const isStyle = parentTagName === "STYLE" ? true : void 0;
888
799
  const isScript = parentTagName === "SCRIPT" ? true : void 0;
889
- if (isScript) {
890
- textContent2 = "SCRIPT_PLACEHOLDER";
891
- } else if (!cssCaptured) {
892
- textContent2 = index.textContent(n);
893
- if (isStyle && textContent2) {
894
- textContent2 = absolutifyURLs(textContent2, getHref(options.doc));
800
+ if (isStyle && text) {
801
+ try {
802
+ if (n.nextSibling || n.previousSibling) {
803
+ } else if ((_a = parent.sheet) == null ? void 0 : _a.cssRules) {
804
+ text = stringifyStylesheet(parent.sheet);
805
+ }
806
+ } catch (err) {
807
+ console.warn(
808
+ `Cannot get CSS styles from text's parentNode. Error: ${err}`,
809
+ n
810
+ );
895
811
  }
812
+ text = absolutifyURLs(text, getHref(options.doc));
813
+ }
814
+ if (isScript) {
815
+ text = "SCRIPT_PLACEHOLDER";
896
816
  }
897
- if (!isStyle && !isScript && textContent2 && needsMask) {
898
- textContent2 = maskTextFn ? maskTextFn(textContent2, index.parentElement(n)) : textContent2.replace(/[\S]/g, "*");
817
+ if (!isStyle && !isScript && text && needsMask) {
818
+ text = maskTextFn ? maskTextFn(text, index.parentElement(n)) : text.replace(/[\S]/g, "*");
899
819
  }
900
820
  return {
901
- type: NodeType.Text,
902
- textContent: textContent2 || "",
821
+ type: NodeType$1.Text,
822
+ textContent: text || "",
823
+ isStyle,
903
824
  rootId
904
825
  };
905
826
  }
@@ -960,14 +881,12 @@ function serializeElementNode(n, options) {
960
881
  }
961
882
  }
962
883
  }
963
- if (tagName === "style" && n.sheet) {
964
- let cssText = stringifyStylesheet(
884
+ if (tagName === "style" && n.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
885
+ !(n.innerText || index.textContent(n) || "").trim().length) {
886
+ const cssText = stringifyStylesheet(
965
887
  n.sheet
966
888
  );
967
889
  if (cssText) {
968
- if (n.childNodes.length > 1) {
969
- cssText = markCssSplits(cssText, n);
970
- }
971
890
  attributes._cssText = cssText;
972
891
  }
973
892
  }
@@ -1102,7 +1021,7 @@ function serializeElementNode(n, options) {
1102
1021
  } catch (e) {
1103
1022
  }
1104
1023
  return {
1105
- type: NodeType.Element,
1024
+ type: NodeType$1.Element,
1106
1025
  tagName,
1107
1026
  attributes,
1108
1027
  childNodes: [],
@@ -1120,9 +1039,9 @@ function lowerIfExists(maybeAttr) {
1120
1039
  }
1121
1040
  }
1122
1041
  function slimDOMExcluded(sn, slimDOMOptions) {
1123
- if (slimDOMOptions.comment && sn.type === NodeType.Comment) {
1042
+ if (slimDOMOptions.comment && sn.type === NodeType$1.Comment) {
1124
1043
  return true;
1125
- } else if (sn.type === NodeType.Element) {
1044
+ } else if (sn.type === NodeType$1.Element) {
1126
1045
  if (slimDOMOptions.script && // script tag
1127
1046
  (sn.tagName === "script" || // (module)preload link
1128
1047
  sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
@@ -1174,8 +1093,7 @@ function serializeNodeWithId(n, options) {
1174
1093
  onStylesheetLoad,
1175
1094
  stylesheetLoadTimeout = 5e3,
1176
1095
  keepIframeSrcFn = () => false,
1177
- newlyAddedElement = false,
1178
- cssCaptured = false
1096
+ newlyAddedElement = false
1179
1097
  } = options;
1180
1098
  let { needsMask } = options;
1181
1099
  let { preserveWhiteSpace = true } = options;
@@ -1202,8 +1120,7 @@ function serializeNodeWithId(n, options) {
1202
1120
  inlineImages,
1203
1121
  recordCanvas,
1204
1122
  keepIframeSrcFn,
1205
- newlyAddedElement,
1206
- cssCaptured
1123
+ newlyAddedElement
1207
1124
  });
1208
1125
  if (!_serializedNode) {
1209
1126
  console.warn(n, "not serialized");
@@ -1212,7 +1129,7 @@ function serializeNodeWithId(n, options) {
1212
1129
  let id;
1213
1130
  if (mirror.hasNode(n)) {
1214
1131
  id = mirror.getId(n);
1215
- } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
1132
+ } else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$1.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
1216
1133
  id = IGNORED_NODE;
1217
1134
  } else {
1218
1135
  id = genId();
@@ -1226,15 +1143,15 @@ function serializeNodeWithId(n, options) {
1226
1143
  onSerialize(n);
1227
1144
  }
1228
1145
  let recordChild = !skipChild;
1229
- if (serializedNode.type === NodeType.Element) {
1146
+ if (serializedNode.type === NodeType$1.Element) {
1230
1147
  recordChild = recordChild && !serializedNode.needBlock;
1231
1148
  delete serializedNode.needBlock;
1232
1149
  const shadowRootEl = index.shadowRoot(n);
1233
1150
  if (shadowRootEl && isNativeShadowDom(shadowRootEl))
1234
1151
  serializedNode.isShadowHost = true;
1235
1152
  }
1236
- if ((serializedNode.type === NodeType.Document || serializedNode.type === NodeType.Element) && recordChild) {
1237
- if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType.Element && serializedNode.tagName === "head") {
1153
+ if ((serializedNode.type === NodeType$1.Document || serializedNode.type === NodeType$1.Element) && recordChild) {
1154
+ if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$1.Element && serializedNode.tagName === "head") {
1238
1155
  preserveWhiteSpace = false;
1239
1156
  }
1240
1157
  const bypassOptions = {
@@ -1260,14 +1177,10 @@ function serializeNodeWithId(n, options) {
1260
1177
  iframeLoadTimeout,
1261
1178
  onStylesheetLoad,
1262
1179
  stylesheetLoadTimeout,
1263
- keepIframeSrcFn,
1264
- cssCaptured: false
1180
+ keepIframeSrcFn
1265
1181
  };
1266
- if (serializedNode.type === NodeType.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1182
+ if (serializedNode.type === NodeType$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
1267
1183
  else {
1268
- if (serializedNode.type === NodeType.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
1269
- bypassOptions.cssCaptured = true;
1270
- }
1271
1184
  for (const childN of Array.from(index.childNodes(n))) {
1272
1185
  const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
1273
1186
  if (serializedChildNode) {
@@ -1290,7 +1203,7 @@ function serializeNodeWithId(n, options) {
1290
1203
  if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
1291
1204
  serializedNode.isShadow = true;
1292
1205
  }
1293
- if (serializedNode.type === NodeType.Element && serializedNode.tagName === "iframe") {
1206
+ if (serializedNode.type === NodeType$1.Element && serializedNode.tagName === "iframe") {
1294
1207
  onceIframeLoaded(
1295
1208
  n,
1296
1209
  () => {
@@ -1332,7 +1245,7 @@ function serializeNodeWithId(n, options) {
1332
1245
  iframeLoadTimeout
1333
1246
  );
1334
1247
  }
1335
- if (serializedNode.type === NodeType.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && extractFileExtension(serializedNode.attributes.href) === "css")) {
1248
+ if (serializedNode.type === NodeType$1.Element && serializedNode.tagName === "link" && typeof serializedNode.attributes.rel === "string" && (serializedNode.attributes.rel === "stylesheet" || serializedNode.attributes.rel === "preload" && typeof serializedNode.attributes.href === "string" && extractFileExtension(serializedNode.attributes.href) === "css")) {
1336
1249
  onceStylesheetLoaded(
1337
1250
  n,
1338
1251
  () => {
@@ -1463,7 +1376,7 @@ function snapshot(n, options) {
1463
1376
  function visitSnapshot(node2, onVisit) {
1464
1377
  function walk(current) {
1465
1378
  onVisit(current);
1466
- if (current.type === NodeType.Document || current.type === NodeType.Element) {
1379
+ if (current.type === NodeType$1.Document || current.type === NodeType$1.Element) {
1467
1380
  current.childNodes.forEach(walk);
1468
1381
  }
1469
1382
  }
@@ -5393,6 +5306,15 @@ function requireSafeParse() {
5393
5306
  }
5394
5307
  var safeParseExports = requireSafeParse();
5395
5308
  const safeParser = /* @__PURE__ */ getDefaultExportFromCjs(safeParseExports);
5309
+ var NodeType = /* @__PURE__ */ ((NodeType2) => {
5310
+ NodeType2[NodeType2["Document"] = 0] = "Document";
5311
+ NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
5312
+ NodeType2[NodeType2["Element"] = 2] = "Element";
5313
+ NodeType2[NodeType2["Text"] = 3] = "Text";
5314
+ NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
5315
+ NodeType2[NodeType2["Comment"] = 5] = "Comment";
5316
+ return NodeType2;
5317
+ })(NodeType || {});
5396
5318
  var postcssExports = requirePostcss();
5397
5319
  const postcss = /* @__PURE__ */ getDefaultExportFromCjs(postcssExports);
5398
5320
  postcss.stringify;
@@ -5488,49 +5410,19 @@ function createCache() {
5488
5410
  stylesWithHoverClass
5489
5411
  };
5490
5412
  }
5491
- function applyCssSplits(n, cssText, hackCss, cache) {
5492
- const childTextNodes = [];
5493
- for (const scn of n.childNodes) {
5494
- if (scn.type === NodeType.Text) {
5495
- childTextNodes.push(scn);
5496
- }
5497
- }
5498
- const cssTextSplits = cssText.split("/* rr_split */");
5499
- while (cssTextSplits.length > 1 && cssTextSplits.length > childTextNodes.length) {
5500
- cssTextSplits.splice(-2, 2, cssTextSplits.slice(-2).join(""));
5501
- }
5502
- for (let i = 0; i < childTextNodes.length; i++) {
5503
- const childTextNode = childTextNodes[i];
5504
- const cssTextSection = cssTextSplits[i];
5505
- if (childTextNode && cssTextSection) {
5506
- childTextNode.textContent = hackCss ? adaptCssForReplay(cssTextSection, cache) : cssTextSection;
5507
- }
5508
- }
5509
- }
5510
- function buildStyleNode(n, styleEl, cssText, options) {
5511
- const { doc, hackCss, cache } = options;
5512
- if (n.childNodes.length) {
5513
- applyCssSplits(n, cssText, hackCss, cache);
5514
- } else {
5515
- if (hackCss) {
5516
- cssText = adaptCssForReplay(cssText, cache);
5517
- }
5518
- styleEl.appendChild(doc.createTextNode(cssText));
5519
- }
5520
- }
5521
5413
  function buildNode(n, options) {
5522
5414
  var _a;
5523
5415
  const { doc, hackCss, cache } = options;
5524
5416
  switch (n.type) {
5525
- case NodeType.Document:
5417
+ case NodeType$1.Document:
5526
5418
  return doc.implementation.createDocument(null, "", null);
5527
- case NodeType.DocumentType:
5419
+ case NodeType$1.DocumentType:
5528
5420
  return doc.implementation.createDocumentType(
5529
5421
  n.name || "html",
5530
5422
  n.publicId,
5531
5423
  n.systemId
5532
5424
  );
5533
- case NodeType.Element: {
5425
+ case NodeType$1.Element: {
5534
5426
  const tagName = getTagName(n);
5535
5427
  let node2;
5536
5428
  if (n.isSVG) {
@@ -5566,11 +5458,12 @@ function buildNode(n, options) {
5566
5458
  specialAttributes[name] = value;
5567
5459
  continue;
5568
5460
  }
5569
- if (typeof value !== "string") ;
5570
- else if (tagName === "style" && name === "_cssText") {
5571
- buildStyleNode(n, node2, value, options);
5572
- continue;
5573
- } else if (tagName === "textarea" && name === "value") {
5461
+ const isTextarea = tagName === "textarea" && name === "value";
5462
+ const isRemoteOrDynamicCss = tagName === "style" && name === "_cssText";
5463
+ if (isRemoteOrDynamicCss && hackCss && typeof value === "string") {
5464
+ value = adaptCssForReplay(value, cache);
5465
+ }
5466
+ if ((isTextarea || isRemoteOrDynamicCss) && typeof value === "string") {
5574
5467
  node2.appendChild(doc.createTextNode(value));
5575
5468
  n.childNodes = [];
5576
5469
  continue;
@@ -5664,14 +5557,13 @@ function buildNode(n, options) {
5664
5557
  }
5665
5558
  return node2;
5666
5559
  }
5667
- case NodeType.Text:
5668
- if (n.isStyle && hackCss) {
5669
- return doc.createTextNode(adaptCssForReplay(n.textContent, cache));
5670
- }
5671
- return doc.createTextNode(n.textContent);
5672
- case NodeType.CDATA:
5560
+ case NodeType$1.Text:
5561
+ return doc.createTextNode(
5562
+ n.isStyle && hackCss ? adaptCssForReplay(n.textContent, cache) : n.textContent
5563
+ );
5564
+ case NodeType$1.CDATA:
5673
5565
  return doc.createCDATASection(n.textContent);
5674
- case NodeType.Comment:
5566
+ case NodeType$1.Comment:
5675
5567
  return doc.createComment(n.textContent);
5676
5568
  default:
5677
5569
  return null;
@@ -5698,11 +5590,11 @@ function buildNodeWithSN(n, options) {
5698
5590
  if (n.rootId && mirror.getNode(n.rootId) !== doc) {
5699
5591
  mirror.replace(n.rootId, doc);
5700
5592
  }
5701
- if (n.type === NodeType.Document) {
5593
+ if (n.type === NodeType$1.Document) {
5702
5594
  doc.close();
5703
5595
  doc.open();
5704
- if (n.compatMode === "BackCompat" && n.childNodes && n.childNodes[0].type !== NodeType.DocumentType) {
5705
- if (n.childNodes[0].type === NodeType.Element && "xmlns" in n.childNodes[0].attributes && n.childNodes[0].attributes.xmlns === "http://www.w3.org/1999/xhtml") {
5596
+ if (n.compatMode === "BackCompat" && n.childNodes && n.childNodes[0].type !== NodeType$1.DocumentType) {
5597
+ if (n.childNodes[0].type === NodeType$1.Element && "xmlns" in n.childNodes[0].attributes && n.childNodes[0].attributes.xmlns === "http://www.w3.org/1999/xhtml") {
5706
5598
  doc.write(
5707
5599
  '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'
5708
5600
  );
@@ -5715,7 +5607,7 @@ function buildNodeWithSN(n, options) {
5715
5607
  node2 = doc;
5716
5608
  }
5717
5609
  mirror.add(node2, n);
5718
- if ((n.type === NodeType.Document || n.type === NodeType.Element) && !skipChild) {
5610
+ if ((n.type === NodeType$1.Document || n.type === NodeType$1.Element) && !skipChild) {
5719
5611
  for (const childN of n.childNodes) {
5720
5612
  const childNode = buildNodeWithSN(childN, {
5721
5613
  doc,
@@ -5731,7 +5623,7 @@ function buildNodeWithSN(n, options) {
5731
5623
  }
5732
5624
  if (childN.isShadow && isElement(node2) && node2.shadowRoot) {
5733
5625
  node2.shadowRoot.appendChild(childNode);
5734
- } else if (n.type === NodeType.Document && childN.type == NodeType.Element) {
5626
+ } else if (n.type === NodeType$1.Document && childN.type == NodeType$1.Element) {
5735
5627
  const htmlElement = childNode;
5736
5628
  let body = null;
5737
5629
  htmlElement.childNodes.forEach((child) => {
@@ -5766,7 +5658,7 @@ function visit(mirror, onVisit) {
5766
5658
  }
5767
5659
  function handleScroll(node2, mirror) {
5768
5660
  const n = mirror.getMeta(node2);
5769
- if ((n == null ? void 0 : n.type) !== NodeType.Element) {
5661
+ if ((n == null ? void 0 : n.type) !== NodeType$1.Element) {
5770
5662
  return;
5771
5663
  }
5772
5664
  const el = node2;
@@ -5810,6 +5702,7 @@ function rebuild(n, options) {
5810
5702
  }
5811
5703
  exports.IGNORED_NODE = IGNORED_NODE;
5812
5704
  exports.Mirror = Mirror;
5705
+ exports.NodeType = NodeType;
5813
5706
  exports.absolutifyURLs = absolutifyURLs;
5814
5707
  exports.adaptCssForReplay = adaptCssForReplay;
5815
5708
  exports.buildNodeWithSN = buildNodeWithSN;
@@ -5830,14 +5723,11 @@ exports.isElement = isElement;
5830
5723
  exports.isNativeShadowDom = isNativeShadowDom;
5831
5724
  exports.isNodeMetaEqual = isNodeMetaEqual;
5832
5725
  exports.isShadowRoot = isShadowRoot;
5833
- exports.markCssSplits = markCssSplits;
5834
5726
  exports.maskInputValue = maskInputValue;
5835
5727
  exports.needMaskingText = needMaskingText;
5836
- exports.normalizeCssString = normalizeCssString;
5837
5728
  exports.rebuild = rebuild;
5838
5729
  exports.serializeNodeWithId = serializeNodeWithId;
5839
5730
  exports.snapshot = snapshot;
5840
- exports.splitCssText = splitCssText;
5841
5731
  exports.stringifyRule = stringifyRule;
5842
5732
  exports.stringifyStylesheet = stringifyStylesheet;
5843
5733
  exports.toLowerCase = toLowerCase;