@posthog/rrweb 0.0.29 → 0.0.30
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/rrweb.cjs +65 -5
- package/dist/rrweb.cjs.map +1 -1
- package/dist/rrweb.js +65 -5
- package/dist/rrweb.js.map +1 -1
- package/dist/rrweb.umd.cjs +64 -5
- package/dist/rrweb.umd.cjs.map +2 -2
- package/dist/rrweb.umd.min.cjs +19 -19
- package/dist/rrweb.umd.min.cjs.map +3 -3
- package/package.json +1 -1
package/dist/rrweb.umd.cjs
CHANGED
|
@@ -519,6 +519,36 @@ function absolutifyURLs(cssText, href) {
|
|
|
519
519
|
}
|
|
520
520
|
);
|
|
521
521
|
}
|
|
522
|
+
const STRIPED_PLACEHOLDER_SVG = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogIDxkZWZzPgogICAgPHBhdHRlcm4gaWQ9InN0cmlwZXMiIHBhdHRlcm5Vbml0cz0idXNlclNwYWNlT25Vc2UiIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiI+CiAgICAgIDxyZWN0IHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iYmxhY2siLz4KICAgICAgPHBhdGggZD0iTTggMEgxNkwwIDE2VjhMOCAwWiIgZmlsbD0iIzJEMkQyRCIvPgogICAgICA8cGF0aCBkPSJNMTYgOFYxNkg4TDE2IDhaIiBmaWxsPSIjMkQyRDJEIi8+CiAgICA8L3BhdHRlcm4+CiAgPC9kZWZzPgogIDxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjc3RyaXBlcykiLz4KPC9zdmc+Cg==";
|
|
523
|
+
const MAX_IMAGE_DIMENSION_FOR_RECOMPRESSION = 4096;
|
|
524
|
+
function recompressBase64Image(img, dataURL, type, quality) {
|
|
525
|
+
if (!img.complete || img.naturalWidth === 0) {
|
|
526
|
+
return dataURL;
|
|
527
|
+
}
|
|
528
|
+
if (img.naturalWidth > MAX_IMAGE_DIMENSION_FOR_RECOMPRESSION || img.naturalHeight > MAX_IMAGE_DIMENSION_FOR_RECOMPRESSION) {
|
|
529
|
+
return dataURL;
|
|
530
|
+
}
|
|
531
|
+
try {
|
|
532
|
+
const canvas = document.createElement("canvas");
|
|
533
|
+
canvas.width = img.naturalWidth;
|
|
534
|
+
canvas.height = img.naturalHeight;
|
|
535
|
+
const ctx = canvas.getContext("2d");
|
|
536
|
+
if (!ctx) {
|
|
537
|
+
return dataURL;
|
|
538
|
+
}
|
|
539
|
+
ctx.drawImage(img, 0, 0);
|
|
540
|
+
const recompressed = canvas.toDataURL(type || "image/webp", quality != null ? quality : 0.4);
|
|
541
|
+
return recompressed;
|
|
542
|
+
} catch (err) {
|
|
543
|
+
return dataURL;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
function checkDataURLSize(dataURL, maxLength) {
|
|
547
|
+
if (!maxLength || dataURL.length <= maxLength) {
|
|
548
|
+
return dataURL;
|
|
549
|
+
}
|
|
550
|
+
return STRIPED_PLACEHOLDER_SVG;
|
|
551
|
+
}
|
|
522
552
|
let _id = 1;
|
|
523
553
|
const tagNameRegex = new RegExp("[^a-z0-9-_:]");
|
|
524
554
|
const IGNORED_NODE = -2;
|
|
@@ -617,12 +647,32 @@ function getHref(doc, customHref) {
|
|
|
617
647
|
a2.setAttribute("href", customHref);
|
|
618
648
|
return a2.href;
|
|
619
649
|
}
|
|
620
|
-
function transformAttribute(doc, tagName, name, value) {
|
|
650
|
+
function transformAttribute(doc, tagName, name, value, element, dataURLOptions) {
|
|
621
651
|
if (!value) {
|
|
622
652
|
return value;
|
|
623
653
|
}
|
|
624
654
|
if (name === "src" || name === "href" && !(tagName === "use" && value[0] === "#")) {
|
|
625
|
-
|
|
655
|
+
const transformedValue = absoluteToDoc(doc, value);
|
|
656
|
+
if (tagName === "img" && transformedValue.startsWith("data:") && element) {
|
|
657
|
+
const img = element;
|
|
658
|
+
let processedDataURL = transformedValue;
|
|
659
|
+
if ((dataURLOptions == null ? void 0 : dataURLOptions.type) || (dataURLOptions == null ? void 0 : dataURLOptions.quality) !== void 0) {
|
|
660
|
+
processedDataURL = recompressBase64Image(
|
|
661
|
+
img,
|
|
662
|
+
transformedValue,
|
|
663
|
+
dataURLOptions.type,
|
|
664
|
+
dataURLOptions.quality
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
if (dataURLOptions == null ? void 0 : dataURLOptions.maxBase64ImageLength) {
|
|
668
|
+
processedDataURL = checkDataURLSize(
|
|
669
|
+
processedDataURL,
|
|
670
|
+
dataURLOptions.maxBase64ImageLength
|
|
671
|
+
);
|
|
672
|
+
}
|
|
673
|
+
return processedDataURL;
|
|
674
|
+
}
|
|
675
|
+
return transformedValue;
|
|
626
676
|
} else if (name === "xlink:href" && value[0] !== "#") {
|
|
627
677
|
return absoluteToDoc(doc, value);
|
|
628
678
|
} else if (name === "background" && (tagName === "table" || tagName === "td" || tagName === "th")) {
|
|
@@ -913,7 +963,9 @@ function serializeElementNode(n2, options) {
|
|
|
913
963
|
doc,
|
|
914
964
|
tagName,
|
|
915
965
|
toLowerCase(attr.name),
|
|
916
|
-
attr.value
|
|
966
|
+
attr.value,
|
|
967
|
+
n2,
|
|
968
|
+
dataURLOptions
|
|
917
969
|
);
|
|
918
970
|
}
|
|
919
971
|
}
|
|
@@ -12033,7 +12085,9 @@ class MutationBuffer {
|
|
|
12033
12085
|
this.doc,
|
|
12034
12086
|
toLowerCase(target.tagName),
|
|
12035
12087
|
toLowerCase(attributeName),
|
|
12036
|
-
value
|
|
12088
|
+
value,
|
|
12089
|
+
target,
|
|
12090
|
+
this.dataURLOptions
|
|
12037
12091
|
);
|
|
12038
12092
|
if (attributeName === "style") {
|
|
12039
12093
|
if (!this.unattachedDoc) {
|
|
@@ -14406,7 +14460,7 @@ function record(options = {}) {
|
|
|
14406
14460
|
hooks,
|
|
14407
14461
|
packFn,
|
|
14408
14462
|
sampling = {},
|
|
14409
|
-
dataURLOptions = {},
|
|
14463
|
+
dataURLOptions: _dataURLOptions = {},
|
|
14410
14464
|
mousemoveWait,
|
|
14411
14465
|
recordDOM = true,
|
|
14412
14466
|
recordCanvas = false,
|
|
@@ -14421,6 +14475,11 @@ function record(options = {}) {
|
|
|
14421
14475
|
errorHandler: errorHandler2
|
|
14422
14476
|
} = options;
|
|
14423
14477
|
registerErrorHandler(errorHandler2);
|
|
14478
|
+
const dataURLOptions = __spreadValues({
|
|
14479
|
+
type: "image/webp",
|
|
14480
|
+
quality: 0.4,
|
|
14481
|
+
maxBase64ImageLength: 1048576
|
|
14482
|
+
}, _dataURLOptions);
|
|
14424
14483
|
const inEmittingFrame = recordCrossOriginIframes ? window.parent === window : true;
|
|
14425
14484
|
let passEmitsToParent = false;
|
|
14426
14485
|
if (!inEmittingFrame) {
|