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