@posthog/rrweb-snapshot 0.0.9 → 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.
- 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
|
@@ -47,7 +47,7 @@ var __defProp2 = Object.defineProperty;
|
|
|
47
47
|
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
48
48
|
var __publicField = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
49
49
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
50
|
-
var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
50
|
+
var NodeType$1 = /* @__PURE__ */ ((NodeType2) => {
|
|
51
51
|
NodeType2[NodeType2["Document"] = 0] = "Document";
|
|
52
52
|
NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
|
|
53
53
|
NodeType2[NodeType2["Element"] = 2] = "Element";
|
|
@@ -55,7 +55,7 @@ var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
|
55
55
|
NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
|
|
56
56
|
NodeType2[NodeType2["Comment"] = 5] = "Comment";
|
|
57
57
|
return NodeType2;
|
|
58
|
-
})(NodeType || {});
|
|
58
|
+
})(NodeType$1 || {});
|
|
59
59
|
const testableAccessors = {
|
|
60
60
|
Node: ["childNodes", "parentNode", "parentElement", "textContent"],
|
|
61
61
|
ShadowRoot: ["host", "styleSheets"],
|
|
@@ -279,13 +279,9 @@ function stringifyStylesheet(s) {
|
|
|
279
279
|
if (!rules) {
|
|
280
280
|
return null;
|
|
281
281
|
}
|
|
282
|
-
let sheetHref = s.href;
|
|
283
|
-
if (!sheetHref && s.ownerNode && s.ownerNode.ownerDocument) {
|
|
284
|
-
sheetHref = s.ownerNode.ownerDocument.location.href;
|
|
285
|
-
}
|
|
286
282
|
const stringifiedRules = Array.from(
|
|
287
283
|
rules,
|
|
288
|
-
(rule2) => stringifyRule(rule2,
|
|
284
|
+
(rule2) => stringifyRule(rule2, s.href)
|
|
289
285
|
).join("");
|
|
290
286
|
return fixBrowserCompatibilityIssuesInCSS(stringifiedRules);
|
|
291
287
|
} catch (error) {
|
|
@@ -434,13 +430,13 @@ function is2DCanvasBlank(canvas) {
|
|
|
434
430
|
}
|
|
435
431
|
function isNodeMetaEqual(a, b) {
|
|
436
432
|
if (!a || !b || a.type !== b.type) return false;
|
|
437
|
-
if (a.type === NodeType.Document)
|
|
433
|
+
if (a.type === NodeType$1.Document)
|
|
438
434
|
return a.compatMode === b.compatMode;
|
|
439
|
-
else if (a.type === NodeType.DocumentType)
|
|
435
|
+
else if (a.type === NodeType$1.DocumentType)
|
|
440
436
|
return a.name === b.name && a.publicId === b.publicId && a.systemId === b.systemId;
|
|
441
|
-
else if (a.type === NodeType.Comment || a.type === NodeType.Text || a.type === NodeType.CDATA)
|
|
437
|
+
else if (a.type === NodeType$1.Comment || a.type === NodeType$1.Text || a.type === NodeType$1.CDATA)
|
|
442
438
|
return a.textContent === b.textContent;
|
|
443
|
-
else if (a.type === NodeType.Element)
|
|
439
|
+
else if (a.type === NodeType$1.Element)
|
|
444
440
|
return a.tagName === b.tagName && JSON.stringify(a.attributes) === JSON.stringify(b.attributes) && a.isSVG === b.isSVG && a.needBlock === b.needBlock;
|
|
445
441
|
return false;
|
|
446
442
|
}
|
|
@@ -511,90 +507,6 @@ function absolutifyURLs(cssText, href) {
|
|
|
511
507
|
}
|
|
512
508
|
);
|
|
513
509
|
}
|
|
514
|
-
const normalizationCache = /* @__PURE__ */ new Map();
|
|
515
|
-
const splitCache = /* @__PURE__ */ new Map();
|
|
516
|
-
function normalizeCssString(cssText) {
|
|
517
|
-
if (!normalizationCache.has(cssText)) {
|
|
518
|
-
const normalized = cssText.replace(/(\/\*[^*]*\*\/)|[\s;]/g, "");
|
|
519
|
-
normalizationCache.set(cssText, normalized);
|
|
520
|
-
}
|
|
521
|
-
return normalizationCache.get(cssText);
|
|
522
|
-
}
|
|
523
|
-
function splitCssText(cssText, style) {
|
|
524
|
-
const og = cssText;
|
|
525
|
-
if (splitCache.has(cssText)) {
|
|
526
|
-
return splitCache.get(cssText);
|
|
527
|
-
}
|
|
528
|
-
const childNodes2 = Array.from(style.childNodes);
|
|
529
|
-
const splits = [];
|
|
530
|
-
let iterLimit = 0;
|
|
531
|
-
if (childNodes2.length > 1 && cssText && typeof cssText === "string") {
|
|
532
|
-
let cssTextNorm = normalizeCssString(cssText);
|
|
533
|
-
const normFactor = cssTextNorm.length / cssText.length;
|
|
534
|
-
for (let i = 1; i < childNodes2.length; i++) {
|
|
535
|
-
if (childNodes2[i].textContent && typeof childNodes2[i].textContent === "string") {
|
|
536
|
-
const textContentNorm = normalizeCssString(childNodes2[i].textContent);
|
|
537
|
-
let j = 3;
|
|
538
|
-
for (; j < textContentNorm.length; j++) {
|
|
539
|
-
if (
|
|
540
|
-
// keep consuming css identifiers (to get a decent chunk more quickly)
|
|
541
|
-
textContentNorm[j].match(/[a-zA-Z0-9]/) || // substring needs to be unique to this section
|
|
542
|
-
textContentNorm.indexOf(textContentNorm.substring(0, j), 1) !== -1
|
|
543
|
-
) {
|
|
544
|
-
continue;
|
|
545
|
-
}
|
|
546
|
-
break;
|
|
547
|
-
}
|
|
548
|
-
for (; j < textContentNorm.length; j++) {
|
|
549
|
-
const bit = textContentNorm.substring(0, j);
|
|
550
|
-
const bits = cssTextNorm.split(bit);
|
|
551
|
-
let splitNorm = -1;
|
|
552
|
-
if (bits.length === 2) {
|
|
553
|
-
splitNorm = cssTextNorm.indexOf(bit);
|
|
554
|
-
} else if (bits.length > 2 && bits[0] === "" && childNodes2[i - 1].textContent !== "") {
|
|
555
|
-
splitNorm = cssTextNorm.indexOf(bit, 1);
|
|
556
|
-
}
|
|
557
|
-
if (splitNorm !== -1) {
|
|
558
|
-
let k = Math.floor(splitNorm / normFactor);
|
|
559
|
-
for (; k > 0 && k < cssText.length; ) {
|
|
560
|
-
iterLimit += 1;
|
|
561
|
-
if (iterLimit > 50 * childNodes2.length) {
|
|
562
|
-
splits.push(cssText);
|
|
563
|
-
return splits;
|
|
564
|
-
}
|
|
565
|
-
const normPart = normalizeCssString(cssText.substring(0, k));
|
|
566
|
-
if (normPart.length === splitNorm) {
|
|
567
|
-
splits.push(cssText.substring(0, k));
|
|
568
|
-
cssText = cssText.substring(k);
|
|
569
|
-
cssTextNorm = cssTextNorm.substring(splitNorm);
|
|
570
|
-
break;
|
|
571
|
-
} else if (normPart.length < splitNorm) {
|
|
572
|
-
k += Math.max(
|
|
573
|
-
1,
|
|
574
|
-
Math.floor((splitNorm - normPart.length) / normFactor)
|
|
575
|
-
);
|
|
576
|
-
} else {
|
|
577
|
-
k -= Math.max(
|
|
578
|
-
1,
|
|
579
|
-
Math.floor((normPart.length - splitNorm) * normFactor)
|
|
580
|
-
);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
break;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
splits.push(cssText);
|
|
590
|
-
if (og) {
|
|
591
|
-
splitCache.set(og, splits);
|
|
592
|
-
}
|
|
593
|
-
return splits;
|
|
594
|
-
}
|
|
595
|
-
function markCssSplits(cssText, style) {
|
|
596
|
-
return splitCssText(cssText, style).join("/* rr_split */");
|
|
597
|
-
}
|
|
598
510
|
let _id = 1;
|
|
599
511
|
const tagNameRegex = new RegExp("[^a-z0-9-_:]");
|
|
600
512
|
const IGNORED_NODE = -2;
|
|
@@ -853,28 +765,27 @@ function serializeNode(n, options) {
|
|
|
853
765
|
inlineImages,
|
|
854
766
|
recordCanvas,
|
|
855
767
|
keepIframeSrcFn,
|
|
856
|
-
newlyAddedElement = false
|
|
857
|
-
cssCaptured = false
|
|
768
|
+
newlyAddedElement = false
|
|
858
769
|
} = options;
|
|
859
770
|
const rootId = getRootId(doc, mirror);
|
|
860
771
|
switch (n.nodeType) {
|
|
861
772
|
case n.DOCUMENT_NODE:
|
|
862
773
|
if (n.compatMode !== "CSS1Compat") {
|
|
863
774
|
return {
|
|
864
|
-
type: NodeType.Document,
|
|
775
|
+
type: NodeType$1.Document,
|
|
865
776
|
childNodes: [],
|
|
866
777
|
compatMode: n.compatMode
|
|
867
778
|
// probably "BackCompat"
|
|
868
779
|
};
|
|
869
780
|
} else {
|
|
870
781
|
return {
|
|
871
|
-
type: NodeType.Document,
|
|
782
|
+
type: NodeType$1.Document,
|
|
872
783
|
childNodes: []
|
|
873
784
|
};
|
|
874
785
|
}
|
|
875
786
|
case n.DOCUMENT_TYPE_NODE:
|
|
876
787
|
return {
|
|
877
|
-
type: NodeType.DocumentType,
|
|
788
|
+
type: NodeType$1.DocumentType,
|
|
878
789
|
name: n.name,
|
|
879
790
|
publicId: n.publicId,
|
|
880
791
|
systemId: n.systemId,
|
|
@@ -900,18 +811,17 @@ function serializeNode(n, options) {
|
|
|
900
811
|
doc,
|
|
901
812
|
needsMask,
|
|
902
813
|
maskTextFn,
|
|
903
|
-
rootId
|
|
904
|
-
cssCaptured
|
|
814
|
+
rootId
|
|
905
815
|
});
|
|
906
816
|
case n.CDATA_SECTION_NODE:
|
|
907
817
|
return {
|
|
908
|
-
type: NodeType.CDATA,
|
|
818
|
+
type: NodeType$1.CDATA,
|
|
909
819
|
textContent: "",
|
|
910
820
|
rootId
|
|
911
821
|
};
|
|
912
822
|
case n.COMMENT_NODE:
|
|
913
823
|
return {
|
|
914
|
-
type: NodeType.Comment,
|
|
824
|
+
type: NodeType$1.Comment,
|
|
915
825
|
textContent: index.textContent(n) || "",
|
|
916
826
|
rootId
|
|
917
827
|
};
|
|
@@ -925,26 +835,37 @@ function getRootId(doc, mirror) {
|
|
|
925
835
|
return docId === 1 ? void 0 : docId;
|
|
926
836
|
}
|
|
927
837
|
function serializeTextNode(n, options) {
|
|
928
|
-
|
|
838
|
+
var _a;
|
|
839
|
+
const { needsMask, maskTextFn, rootId } = options;
|
|
929
840
|
const parent = index.parentNode(n);
|
|
930
841
|
const parentTagName = parent && parent.tagName;
|
|
931
|
-
let
|
|
842
|
+
let text = index.textContent(n);
|
|
932
843
|
const isStyle = parentTagName === "STYLE" ? true : void 0;
|
|
933
844
|
const isScript = parentTagName === "SCRIPT" ? true : void 0;
|
|
934
|
-
if (
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
845
|
+
if (isStyle && text) {
|
|
846
|
+
try {
|
|
847
|
+
if (n.nextSibling || n.previousSibling) {
|
|
848
|
+
} else if ((_a = parent.sheet) == null ? void 0 : _a.cssRules) {
|
|
849
|
+
text = stringifyStylesheet(parent.sheet);
|
|
850
|
+
}
|
|
851
|
+
} catch (err) {
|
|
852
|
+
console.warn(
|
|
853
|
+
`Cannot get CSS styles from text's parentNode. Error: ${err}`,
|
|
854
|
+
n
|
|
855
|
+
);
|
|
940
856
|
}
|
|
857
|
+
text = absolutifyURLs(text, getHref(options.doc));
|
|
858
|
+
}
|
|
859
|
+
if (isScript) {
|
|
860
|
+
text = "SCRIPT_PLACEHOLDER";
|
|
941
861
|
}
|
|
942
|
-
if (!isStyle && !isScript &&
|
|
943
|
-
|
|
862
|
+
if (!isStyle && !isScript && text && needsMask) {
|
|
863
|
+
text = maskTextFn ? maskTextFn(text, index.parentElement(n)) : text.replace(/[\S]/g, "*");
|
|
944
864
|
}
|
|
945
865
|
return {
|
|
946
|
-
type: NodeType.Text,
|
|
947
|
-
textContent:
|
|
866
|
+
type: NodeType$1.Text,
|
|
867
|
+
textContent: text || "",
|
|
868
|
+
isStyle,
|
|
948
869
|
rootId
|
|
949
870
|
};
|
|
950
871
|
}
|
|
@@ -1005,14 +926,12 @@ function serializeElementNode(n, options) {
|
|
|
1005
926
|
}
|
|
1006
927
|
}
|
|
1007
928
|
}
|
|
1008
|
-
if (tagName === "style" && n.sheet
|
|
1009
|
-
|
|
929
|
+
if (tagName === "style" && n.sheet && // TODO: Currently we only try to get dynamic stylesheet when it is an empty style element
|
|
930
|
+
!(n.innerText || index.textContent(n) || "").trim().length) {
|
|
931
|
+
const cssText = stringifyStylesheet(
|
|
1010
932
|
n.sheet
|
|
1011
933
|
);
|
|
1012
934
|
if (cssText) {
|
|
1013
|
-
if (n.childNodes.length > 1) {
|
|
1014
|
-
cssText = markCssSplits(cssText, n);
|
|
1015
|
-
}
|
|
1016
935
|
attributes._cssText = cssText;
|
|
1017
936
|
}
|
|
1018
937
|
}
|
|
@@ -1147,7 +1066,7 @@ function serializeElementNode(n, options) {
|
|
|
1147
1066
|
} catch (e) {
|
|
1148
1067
|
}
|
|
1149
1068
|
return {
|
|
1150
|
-
type: NodeType.Element,
|
|
1069
|
+
type: NodeType$1.Element,
|
|
1151
1070
|
tagName,
|
|
1152
1071
|
attributes,
|
|
1153
1072
|
childNodes: [],
|
|
@@ -1165,9 +1084,9 @@ function lowerIfExists(maybeAttr) {
|
|
|
1165
1084
|
}
|
|
1166
1085
|
}
|
|
1167
1086
|
function slimDOMExcluded(sn, slimDOMOptions) {
|
|
1168
|
-
if (slimDOMOptions.comment && sn.type === NodeType.Comment) {
|
|
1087
|
+
if (slimDOMOptions.comment && sn.type === NodeType$1.Comment) {
|
|
1169
1088
|
return true;
|
|
1170
|
-
} else if (sn.type === NodeType.Element) {
|
|
1089
|
+
} else if (sn.type === NodeType$1.Element) {
|
|
1171
1090
|
if (slimDOMOptions.script && // script tag
|
|
1172
1091
|
(sn.tagName === "script" || // (module)preload link
|
|
1173
1092
|
sn.tagName === "link" && (sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.attributes.rel === "modulepreload") || // prefetch link
|
|
@@ -1219,8 +1138,7 @@ function serializeNodeWithId(n, options) {
|
|
|
1219
1138
|
onStylesheetLoad,
|
|
1220
1139
|
stylesheetLoadTimeout = 5e3,
|
|
1221
1140
|
keepIframeSrcFn = () => false,
|
|
1222
|
-
newlyAddedElement = false
|
|
1223
|
-
cssCaptured = false
|
|
1141
|
+
newlyAddedElement = false
|
|
1224
1142
|
} = options;
|
|
1225
1143
|
let { needsMask } = options;
|
|
1226
1144
|
let { preserveWhiteSpace = true } = options;
|
|
@@ -1247,8 +1165,7 @@ function serializeNodeWithId(n, options) {
|
|
|
1247
1165
|
inlineImages,
|
|
1248
1166
|
recordCanvas,
|
|
1249
1167
|
keepIframeSrcFn,
|
|
1250
|
-
newlyAddedElement
|
|
1251
|
-
cssCaptured
|
|
1168
|
+
newlyAddedElement
|
|
1252
1169
|
});
|
|
1253
1170
|
if (!_serializedNode) {
|
|
1254
1171
|
console.warn(n, "not serialized");
|
|
@@ -1257,7 +1174,7 @@ function serializeNodeWithId(n, options) {
|
|
|
1257
1174
|
let id;
|
|
1258
1175
|
if (mirror.hasNode(n)) {
|
|
1259
1176
|
id = mirror.getId(n);
|
|
1260
|
-
} else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType.Text && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
|
|
1177
|
+
} else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType$1.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
|
|
1261
1178
|
id = IGNORED_NODE;
|
|
1262
1179
|
} else {
|
|
1263
1180
|
id = genId();
|
|
@@ -1271,15 +1188,15 @@ function serializeNodeWithId(n, options) {
|
|
|
1271
1188
|
onSerialize(n);
|
|
1272
1189
|
}
|
|
1273
1190
|
let recordChild = !skipChild;
|
|
1274
|
-
if (serializedNode.type === NodeType.Element) {
|
|
1191
|
+
if (serializedNode.type === NodeType$1.Element) {
|
|
1275
1192
|
recordChild = recordChild && !serializedNode.needBlock;
|
|
1276
1193
|
delete serializedNode.needBlock;
|
|
1277
1194
|
const shadowRootEl = index.shadowRoot(n);
|
|
1278
1195
|
if (shadowRootEl && isNativeShadowDom(shadowRootEl))
|
|
1279
1196
|
serializedNode.isShadowHost = true;
|
|
1280
1197
|
}
|
|
1281
|
-
if ((serializedNode.type === NodeType.Document || serializedNode.type === NodeType.Element) && recordChild) {
|
|
1282
|
-
if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType.Element && serializedNode.tagName === "head") {
|
|
1198
|
+
if ((serializedNode.type === NodeType$1.Document || serializedNode.type === NodeType$1.Element) && recordChild) {
|
|
1199
|
+
if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType$1.Element && serializedNode.tagName === "head") {
|
|
1283
1200
|
preserveWhiteSpace = false;
|
|
1284
1201
|
}
|
|
1285
1202
|
const bypassOptions = {
|
|
@@ -1305,14 +1222,10 @@ function serializeNodeWithId(n, options) {
|
|
|
1305
1222
|
iframeLoadTimeout,
|
|
1306
1223
|
onStylesheetLoad,
|
|
1307
1224
|
stylesheetLoadTimeout,
|
|
1308
|
-
keepIframeSrcFn
|
|
1309
|
-
cssCaptured: false
|
|
1225
|
+
keepIframeSrcFn
|
|
1310
1226
|
};
|
|
1311
|
-
if (serializedNode.type === NodeType.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
|
|
1227
|
+
if (serializedNode.type === NodeType$1.Element && serializedNode.tagName === "textarea" && serializedNode.attributes.value !== void 0) ;
|
|
1312
1228
|
else {
|
|
1313
|
-
if (serializedNode.type === NodeType.Element && serializedNode.attributes._cssText !== void 0 && typeof serializedNode.attributes._cssText === "string") {
|
|
1314
|
-
bypassOptions.cssCaptured = true;
|
|
1315
|
-
}
|
|
1316
1229
|
for (const childN of Array.from(index.childNodes(n))) {
|
|
1317
1230
|
const serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
1318
1231
|
if (serializedChildNode) {
|
|
@@ -1335,7 +1248,7 @@ function serializeNodeWithId(n, options) {
|
|
|
1335
1248
|
if (parent && isShadowRoot(parent) && isNativeShadowDom(parent)) {
|
|
1336
1249
|
serializedNode.isShadow = true;
|
|
1337
1250
|
}
|
|
1338
|
-
if (serializedNode.type === NodeType.Element && serializedNode.tagName === "iframe") {
|
|
1251
|
+
if (serializedNode.type === NodeType$1.Element && serializedNode.tagName === "iframe") {
|
|
1339
1252
|
onceIframeLoaded(
|
|
1340
1253
|
n,
|
|
1341
1254
|
() => {
|
|
@@ -1377,7 +1290,7 @@ function serializeNodeWithId(n, options) {
|
|
|
1377
1290
|
iframeLoadTimeout
|
|
1378
1291
|
);
|
|
1379
1292
|
}
|
|
1380
|
-
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")) {
|
|
1293
|
+
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")) {
|
|
1381
1294
|
onceStylesheetLoaded(
|
|
1382
1295
|
n,
|
|
1383
1296
|
() => {
|
|
@@ -1508,7 +1421,7 @@ function snapshot(n, options) {
|
|
|
1508
1421
|
function visitSnapshot(node2, onVisit) {
|
|
1509
1422
|
function walk(current) {
|
|
1510
1423
|
onVisit(current);
|
|
1511
|
-
if (current.type === NodeType.Document || current.type === NodeType.Element) {
|
|
1424
|
+
if (current.type === NodeType$1.Document || current.type === NodeType$1.Element) {
|
|
1512
1425
|
current.childNodes.forEach(walk);
|
|
1513
1426
|
}
|
|
1514
1427
|
}
|
|
@@ -5437,6 +5350,15 @@ function requireSafeParse() {
|
|
|
5437
5350
|
}
|
|
5438
5351
|
var safeParseExports = requireSafeParse();
|
|
5439
5352
|
const safeParser = /* @__PURE__ */ getDefaultExportFromCjs(safeParseExports);
|
|
5353
|
+
var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
5354
|
+
NodeType2[NodeType2["Document"] = 0] = "Document";
|
|
5355
|
+
NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
|
|
5356
|
+
NodeType2[NodeType2["Element"] = 2] = "Element";
|
|
5357
|
+
NodeType2[NodeType2["Text"] = 3] = "Text";
|
|
5358
|
+
NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
|
|
5359
|
+
NodeType2[NodeType2["Comment"] = 5] = "Comment";
|
|
5360
|
+
return NodeType2;
|
|
5361
|
+
})(NodeType || {});
|
|
5440
5362
|
var postcssExports = requirePostcss();
|
|
5441
5363
|
const postcss = /* @__PURE__ */ getDefaultExportFromCjs(postcssExports);
|
|
5442
5364
|
postcss.stringify;
|
|
@@ -5532,49 +5454,19 @@ function createCache() {
|
|
|
5532
5454
|
stylesWithHoverClass
|
|
5533
5455
|
};
|
|
5534
5456
|
}
|
|
5535
|
-
function applyCssSplits(n, cssText, hackCss, cache) {
|
|
5536
|
-
const childTextNodes = [];
|
|
5537
|
-
for (const scn of n.childNodes) {
|
|
5538
|
-
if (scn.type === NodeType.Text) {
|
|
5539
|
-
childTextNodes.push(scn);
|
|
5540
|
-
}
|
|
5541
|
-
}
|
|
5542
|
-
const cssTextSplits = cssText.split("/* rr_split */");
|
|
5543
|
-
while (cssTextSplits.length > 1 && cssTextSplits.length > childTextNodes.length) {
|
|
5544
|
-
cssTextSplits.splice(-2, 2, cssTextSplits.slice(-2).join(""));
|
|
5545
|
-
}
|
|
5546
|
-
for (let i = 0; i < childTextNodes.length; i++) {
|
|
5547
|
-
const childTextNode = childTextNodes[i];
|
|
5548
|
-
const cssTextSection = cssTextSplits[i];
|
|
5549
|
-
if (childTextNode && cssTextSection) {
|
|
5550
|
-
childTextNode.textContent = hackCss ? adaptCssForReplay(cssTextSection, cache) : cssTextSection;
|
|
5551
|
-
}
|
|
5552
|
-
}
|
|
5553
|
-
}
|
|
5554
|
-
function buildStyleNode(n, styleEl, cssText, options) {
|
|
5555
|
-
const { doc, hackCss, cache } = options;
|
|
5556
|
-
if (n.childNodes.length) {
|
|
5557
|
-
applyCssSplits(n, cssText, hackCss, cache);
|
|
5558
|
-
} else {
|
|
5559
|
-
if (hackCss) {
|
|
5560
|
-
cssText = adaptCssForReplay(cssText, cache);
|
|
5561
|
-
}
|
|
5562
|
-
styleEl.appendChild(doc.createTextNode(cssText));
|
|
5563
|
-
}
|
|
5564
|
-
}
|
|
5565
5457
|
function buildNode(n, options) {
|
|
5566
5458
|
var _a;
|
|
5567
5459
|
const { doc, hackCss, cache } = options;
|
|
5568
5460
|
switch (n.type) {
|
|
5569
|
-
case NodeType.Document:
|
|
5461
|
+
case NodeType$1.Document:
|
|
5570
5462
|
return doc.implementation.createDocument(null, "", null);
|
|
5571
|
-
case NodeType.DocumentType:
|
|
5463
|
+
case NodeType$1.DocumentType:
|
|
5572
5464
|
return doc.implementation.createDocumentType(
|
|
5573
5465
|
n.name || "html",
|
|
5574
5466
|
n.publicId,
|
|
5575
5467
|
n.systemId
|
|
5576
5468
|
);
|
|
5577
|
-
case NodeType.Element: {
|
|
5469
|
+
case NodeType$1.Element: {
|
|
5578
5470
|
const tagName = getTagName(n);
|
|
5579
5471
|
let node2;
|
|
5580
5472
|
if (n.isSVG) {
|
|
@@ -5610,11 +5502,12 @@ function buildNode(n, options) {
|
|
|
5610
5502
|
specialAttributes[name] = value;
|
|
5611
5503
|
continue;
|
|
5612
5504
|
}
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
}
|
|
5505
|
+
const isTextarea = tagName === "textarea" && name === "value";
|
|
5506
|
+
const isRemoteOrDynamicCss = tagName === "style" && name === "_cssText";
|
|
5507
|
+
if (isRemoteOrDynamicCss && hackCss && typeof value === "string") {
|
|
5508
|
+
value = adaptCssForReplay(value, cache);
|
|
5509
|
+
}
|
|
5510
|
+
if ((isTextarea || isRemoteOrDynamicCss) && typeof value === "string") {
|
|
5618
5511
|
node2.appendChild(doc.createTextNode(value));
|
|
5619
5512
|
n.childNodes = [];
|
|
5620
5513
|
continue;
|
|
@@ -5708,14 +5601,13 @@ function buildNode(n, options) {
|
|
|
5708
5601
|
}
|
|
5709
5602
|
return node2;
|
|
5710
5603
|
}
|
|
5711
|
-
case NodeType.Text:
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
case NodeType.CDATA:
|
|
5604
|
+
case NodeType$1.Text:
|
|
5605
|
+
return doc.createTextNode(
|
|
5606
|
+
n.isStyle && hackCss ? adaptCssForReplay(n.textContent, cache) : n.textContent
|
|
5607
|
+
);
|
|
5608
|
+
case NodeType$1.CDATA:
|
|
5717
5609
|
return doc.createCDATASection(n.textContent);
|
|
5718
|
-
case NodeType.Comment:
|
|
5610
|
+
case NodeType$1.Comment:
|
|
5719
5611
|
return doc.createComment(n.textContent);
|
|
5720
5612
|
default:
|
|
5721
5613
|
return null;
|
|
@@ -5742,11 +5634,11 @@ function buildNodeWithSN(n, options) {
|
|
|
5742
5634
|
if (n.rootId && mirror.getNode(n.rootId) !== doc) {
|
|
5743
5635
|
mirror.replace(n.rootId, doc);
|
|
5744
5636
|
}
|
|
5745
|
-
if (n.type === NodeType.Document) {
|
|
5637
|
+
if (n.type === NodeType$1.Document) {
|
|
5746
5638
|
doc.close();
|
|
5747
5639
|
doc.open();
|
|
5748
|
-
if (n.compatMode === "BackCompat" && n.childNodes && n.childNodes[0].type !== NodeType.DocumentType) {
|
|
5749
|
-
if (n.childNodes[0].type === NodeType.Element && "xmlns" in n.childNodes[0].attributes && n.childNodes[0].attributes.xmlns === "http://www.w3.org/1999/xhtml") {
|
|
5640
|
+
if (n.compatMode === "BackCompat" && n.childNodes && n.childNodes[0].type !== NodeType$1.DocumentType) {
|
|
5641
|
+
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") {
|
|
5750
5642
|
doc.write(
|
|
5751
5643
|
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'
|
|
5752
5644
|
);
|
|
@@ -5759,7 +5651,7 @@ function buildNodeWithSN(n, options) {
|
|
|
5759
5651
|
node2 = doc;
|
|
5760
5652
|
}
|
|
5761
5653
|
mirror.add(node2, n);
|
|
5762
|
-
if ((n.type === NodeType.Document || n.type === NodeType.Element) && !skipChild) {
|
|
5654
|
+
if ((n.type === NodeType$1.Document || n.type === NodeType$1.Element) && !skipChild) {
|
|
5763
5655
|
for (const childN of n.childNodes) {
|
|
5764
5656
|
const childNode = buildNodeWithSN(childN, {
|
|
5765
5657
|
doc,
|
|
@@ -5775,7 +5667,7 @@ function buildNodeWithSN(n, options) {
|
|
|
5775
5667
|
}
|
|
5776
5668
|
if (childN.isShadow && isElement(node2) && node2.shadowRoot) {
|
|
5777
5669
|
node2.shadowRoot.appendChild(childNode);
|
|
5778
|
-
} else if (n.type === NodeType.Document && childN.type == NodeType.Element) {
|
|
5670
|
+
} else if (n.type === NodeType$1.Document && childN.type == NodeType$1.Element) {
|
|
5779
5671
|
const htmlElement = childNode;
|
|
5780
5672
|
let body = null;
|
|
5781
5673
|
htmlElement.childNodes.forEach((child) => {
|
|
@@ -5810,7 +5702,7 @@ function visit(mirror, onVisit) {
|
|
|
5810
5702
|
}
|
|
5811
5703
|
function handleScroll(node2, mirror) {
|
|
5812
5704
|
const n = mirror.getMeta(node2);
|
|
5813
|
-
if ((n == null ? void 0 : n.type) !== NodeType.Element) {
|
|
5705
|
+
if ((n == null ? void 0 : n.type) !== NodeType$1.Element) {
|
|
5814
5706
|
return;
|
|
5815
5707
|
}
|
|
5816
5708
|
const el = node2;
|
|
@@ -5854,6 +5746,7 @@ function rebuild(n, options) {
|
|
|
5854
5746
|
}
|
|
5855
5747
|
exports.IGNORED_NODE = IGNORED_NODE;
|
|
5856
5748
|
exports.Mirror = Mirror;
|
|
5749
|
+
exports.NodeType = NodeType;
|
|
5857
5750
|
exports.absolutifyURLs = absolutifyURLs;
|
|
5858
5751
|
exports.adaptCssForReplay = adaptCssForReplay;
|
|
5859
5752
|
exports.buildNodeWithSN = buildNodeWithSN;
|
|
@@ -5874,14 +5767,11 @@ exports.isElement = isElement;
|
|
|
5874
5767
|
exports.isNativeShadowDom = isNativeShadowDom;
|
|
5875
5768
|
exports.isNodeMetaEqual = isNodeMetaEqual;
|
|
5876
5769
|
exports.isShadowRoot = isShadowRoot;
|
|
5877
|
-
exports.markCssSplits = markCssSplits;
|
|
5878
5770
|
exports.maskInputValue = maskInputValue;
|
|
5879
5771
|
exports.needMaskingText = needMaskingText;
|
|
5880
|
-
exports.normalizeCssString = normalizeCssString;
|
|
5881
5772
|
exports.rebuild = rebuild;
|
|
5882
5773
|
exports.serializeNodeWithId = serializeNodeWithId;
|
|
5883
5774
|
exports.snapshot = snapshot;
|
|
5884
|
-
exports.splitCssText = splitCssText;
|
|
5885
5775
|
exports.stringifyRule = stringifyRule;
|
|
5886
5776
|
exports.stringifyStylesheet = stringifyStylesheet;
|
|
5887
5777
|
exports.toLowerCase = toLowerCase;
|