@glimt/record 0.0.25 → 0.0.26
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/record.cjs +8 -9
- package/dist/record.cjs.map +1 -1
- package/dist/record.js +8 -9
- package/dist/record.js.map +1 -1
- package/dist/record.umd.cjs +8 -9
- package/dist/record.umd.cjs.map +2 -2
- package/dist/record.umd.min.cjs +6 -6
- package/dist/record.umd.min.cjs.map +3 -3
- package/package.json +1 -1
package/dist/record.cjs
CHANGED
|
@@ -364,9 +364,9 @@ function toLowerCase(str) {
|
|
|
364
364
|
}
|
|
365
365
|
const ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
|
|
366
366
|
const COPY_CANVAS_ON_VOLUME_GREATER_THAN = 25e4;
|
|
367
|
-
function getReadableCanvasContext(canvas) {
|
|
367
|
+
function getReadableCanvasContext(canvas, cachedContext) {
|
|
368
368
|
if (canvas.width * canvas.height < COPY_CANVAS_ON_VOLUME_GREATER_THAN)
|
|
369
|
-
return canvas.getContext("2d");
|
|
369
|
+
return cachedContext ?? canvas.getContext("2d");
|
|
370
370
|
console.log("cloning canvas for is2DCanvasBlank");
|
|
371
371
|
const start = performance.now();
|
|
372
372
|
const offscreen = document.createElement("canvas");
|
|
@@ -383,9 +383,9 @@ function getReadableCanvasContext(canvas) {
|
|
|
383
383
|
);
|
|
384
384
|
return offscreen.getContext("2d", { willReadFrequently: true });
|
|
385
385
|
}
|
|
386
|
-
function is2DCanvasBlank(canvas) {
|
|
386
|
+
function is2DCanvasBlank(canvas, cachedContext) {
|
|
387
387
|
if (canvas.width === 0 || canvas.height === 0) return true;
|
|
388
|
-
const ctx = getReadableCanvasContext(canvas);
|
|
388
|
+
const ctx = getReadableCanvasContext(canvas, cachedContext);
|
|
389
389
|
if (!ctx) return true;
|
|
390
390
|
const chunkSize = canvas.width > 512 || canvas.height > 512 ? 100 : 50;
|
|
391
391
|
const getImageData = ctx.getImageData;
|
|
@@ -1012,16 +1012,15 @@ function serializeElementNode(n2, options) {
|
|
|
1012
1012
|
attributes.rr_open_mode = n2.matches("dialog:modal") ? "modal" : "non-modal";
|
|
1013
1013
|
}
|
|
1014
1014
|
if (tagName === "canvas" && recordCanvas) {
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
if (!is2DCanvasBlank(n2)) {
|
|
1015
|
+
let context = "getContext" in n2 ? n2.getContext("2d") : null;
|
|
1016
|
+
if (context != null) {
|
|
1017
|
+
if (!is2DCanvasBlank(n2, context)) {
|
|
1018
1018
|
attributes.rr_dataURL = n2.toDataURL(
|
|
1019
1019
|
dataURLOptions.type,
|
|
1020
1020
|
dataURLOptions.quality
|
|
1021
1021
|
);
|
|
1022
1022
|
}
|
|
1023
|
-
|
|
1024
|
-
} else if (!("__context" in n2)) {
|
|
1023
|
+
} else if (n2.width !== 0 && n2.height !== 0) {
|
|
1025
1024
|
const canvasDataURL = n2.toDataURL(
|
|
1026
1025
|
dataURLOptions.type,
|
|
1027
1026
|
dataURLOptions.quality
|