@kalayanasundaram123/rrweb 2.0.2 → 2.0.3
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 +95 -95
- package/dist/rrweb.cjs.map +1 -1
- package/dist/rrweb.js +95 -95
- package/dist/rrweb.js.map +1 -1
- package/dist/rrweb.umd.cjs +95 -95
- package/dist/rrweb.umd.cjs.map +3 -3
- package/dist/rrweb.umd.min.cjs +20 -117
- package/dist/rrweb.umd.min.cjs.map +3 -3
- package/package.json +1 -1
- package/umd/rrweb.js +95 -95
- package/umd/rrweb.min.js +20 -117
- package/dist/assets/image-bitmap-data-url-worker-DIbJg1p8.js.map +0 -1
package/dist/rrweb.cjs
CHANGED
|
@@ -4963,10 +4963,10 @@ function requireNoWorkResult$1() {
|
|
|
4963
4963
|
let str = stringify;
|
|
4964
4964
|
this.result = new Result(this._processor, root2, this._opts);
|
|
4965
4965
|
this.result.css = css;
|
|
4966
|
-
let
|
|
4966
|
+
let self = this;
|
|
4967
4967
|
Object.defineProperty(this.result, "root", {
|
|
4968
4968
|
get() {
|
|
4969
|
-
return
|
|
4969
|
+
return self.root;
|
|
4970
4970
|
}
|
|
4971
4971
|
});
|
|
4972
4972
|
let map = new MapGenerator(str, root2, this._opts, css);
|
|
@@ -9244,10 +9244,10 @@ function requireNoWorkResult() {
|
|
|
9244
9244
|
let str = stringify;
|
|
9245
9245
|
this.result = new Result(this._processor, root2, this._opts);
|
|
9246
9246
|
this.result.css = css;
|
|
9247
|
-
let
|
|
9247
|
+
let self = this;
|
|
9248
9248
|
Object.defineProperty(this.result, "root", {
|
|
9249
9249
|
get() {
|
|
9250
|
-
return
|
|
9250
|
+
return self.root;
|
|
9251
9251
|
}
|
|
9252
9252
|
});
|
|
9253
9253
|
let map = new MapGenerator(str, root2, this._opts, css);
|
|
@@ -13938,37 +13938,17 @@ function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector) {
|
|
|
13938
13938
|
handlers.forEach((h) => h());
|
|
13939
13939
|
};
|
|
13940
13940
|
}
|
|
13941
|
-
|
|
13942
|
-
const
|
|
13943
|
-
|
|
13944
|
-
let
|
|
13945
|
-
|
|
13946
|
-
|
|
13947
|
-
if (!objURL) throw "";
|
|
13948
|
-
const worker = new Worker(objURL, {
|
|
13949
|
-
name: options == null ? void 0 : options.name
|
|
13950
|
-
});
|
|
13951
|
-
worker.addEventListener("error", () => {
|
|
13952
|
-
(self.URL || self.webkitURL).revokeObjectURL(objURL);
|
|
13953
|
-
});
|
|
13954
|
-
return worker;
|
|
13955
|
-
} catch (e2) {
|
|
13956
|
-
return new Worker(
|
|
13957
|
-
"data:text/javascript;charset=utf-8," + encodeURIComponent(jsContent),
|
|
13958
|
-
{
|
|
13959
|
-
name: options == null ? void 0 : options.name
|
|
13960
|
-
}
|
|
13961
|
-
);
|
|
13962
|
-
} finally {
|
|
13963
|
-
objURL && (self.URL || self.webkitURL).revokeObjectURL(objURL);
|
|
13941
|
+
function fnv1aHash(buffer) {
|
|
13942
|
+
const view = new Uint8Array(buffer);
|
|
13943
|
+
let hash = 2166136261;
|
|
13944
|
+
for (let i2 = 0; i2 < view.length; i2++) {
|
|
13945
|
+
hash ^= view[i2];
|
|
13946
|
+
hash = hash * 16777619 | 0;
|
|
13964
13947
|
}
|
|
13948
|
+
return (hash >>> 0).toString(16);
|
|
13965
13949
|
}
|
|
13966
|
-
function
|
|
13967
|
-
|
|
13968
|
-
return typeof Worker !== "undefined" && win.origin != null && win.origin !== "null";
|
|
13969
|
-
} catch {
|
|
13970
|
-
return false;
|
|
13971
|
-
}
|
|
13950
|
+
function canSnapshotCanvas() {
|
|
13951
|
+
return typeof OffscreenCanvas !== "undefined";
|
|
13972
13952
|
}
|
|
13973
13953
|
class CanvasManager {
|
|
13974
13954
|
constructor(options) {
|
|
@@ -13989,7 +13969,9 @@ class CanvasManager {
|
|
|
13989
13969
|
__publicField(this, "frozen", false);
|
|
13990
13970
|
__publicField(this, "locked", false);
|
|
13991
13971
|
__publicField(this, "snapshotInProgressMap", /* @__PURE__ */ new Map());
|
|
13992
|
-
__publicField(this, "
|
|
13972
|
+
__publicField(this, "lastFingerprintMap", /* @__PURE__ */ new Map());
|
|
13973
|
+
__publicField(this, "snapshotCanvas", null);
|
|
13974
|
+
__publicField(this, "snapshotCtx", null);
|
|
13993
13975
|
__publicField(this, "lastSnapshotTime", 0);
|
|
13994
13976
|
__publicField(this, "processMutation", (target, mutation) => {
|
|
13995
13977
|
const newFrame = this.rafStamps.invokeId && this.rafStamps.latestId !== this.rafStamps.invokeId;
|
|
@@ -14005,20 +13987,16 @@ class CanvasManager {
|
|
|
14005
13987
|
this.mutationCb = options.mutationCb;
|
|
14006
13988
|
this.mirror = options.mirror;
|
|
14007
13989
|
this.options = options;
|
|
14008
|
-
if (recordCanvas && typeof sampling === "number" && canCreateBlobWorker(win)) {
|
|
14009
|
-
this.worker = this.initFPSWorker();
|
|
14010
|
-
}
|
|
14011
13990
|
this.addWindow(win);
|
|
14012
13991
|
if (recordCanvas && sampling === "all") {
|
|
14013
13992
|
this.startRAFTimestamping();
|
|
14014
13993
|
this.startPendingCanvasMutationFlusher();
|
|
14015
13994
|
}
|
|
14016
|
-
if (recordCanvas && typeof sampling === "number" &&
|
|
13995
|
+
if (recordCanvas && typeof sampling === "number" && canSnapshotCanvas()) {
|
|
14017
13996
|
this.initCanvasFPSObserver();
|
|
14018
13997
|
}
|
|
14019
13998
|
}
|
|
14020
13999
|
reset() {
|
|
14021
|
-
var _a2;
|
|
14022
14000
|
this.pendingCanvasMutations.clear();
|
|
14023
14001
|
this.restoreHandlers.forEach((handler) => {
|
|
14024
14002
|
try {
|
|
@@ -14030,9 +14008,10 @@ class CanvasManager {
|
|
|
14030
14008
|
this.windowsSet = /* @__PURE__ */ new WeakSet();
|
|
14031
14009
|
this.windows = [];
|
|
14032
14010
|
this.shadowDoms = /* @__PURE__ */ new Set();
|
|
14033
|
-
(_a2 = this.worker) == null ? void 0 : _a2.terminate();
|
|
14034
|
-
this.worker = null;
|
|
14035
14011
|
this.snapshotInProgressMap = /* @__PURE__ */ new Map();
|
|
14012
|
+
this.lastFingerprintMap = /* @__PURE__ */ new Map();
|
|
14013
|
+
this.snapshotCanvas = null;
|
|
14014
|
+
this.snapshotCtx = null;
|
|
14036
14015
|
}
|
|
14037
14016
|
freeze() {
|
|
14038
14017
|
this.frozen = true;
|
|
@@ -14085,45 +14064,74 @@ class CanvasManager {
|
|
|
14085
14064
|
resetShadowRoots() {
|
|
14086
14065
|
this.shadowDoms = /* @__PURE__ */ new Set();
|
|
14087
14066
|
}
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
|
|
14091
|
-
|
|
14092
|
-
|
|
14093
|
-
|
|
14094
|
-
|
|
14095
|
-
|
|
14096
|
-
this.
|
|
14067
|
+
/**
|
|
14068
|
+
* Encode one canvas frame (an ImageBitmap of the canvas) to a data blob on
|
|
14069
|
+
* the main thread, de-duplicating unchanged frames, and emit it as a canvas
|
|
14070
|
+
* mutation. Replaces the old blob-URL Worker, which crashed the renderer when
|
|
14071
|
+
* created inside sandboxed frames.
|
|
14072
|
+
*/
|
|
14073
|
+
async snapshotImageBitmap(id, bitmap, width, height, dataURLOptions) {
|
|
14074
|
+
try {
|
|
14075
|
+
let offscreen = this.snapshotCanvas;
|
|
14076
|
+
if (!offscreen || offscreen.width !== width || offscreen.height !== height) {
|
|
14077
|
+
offscreen = new OffscreenCanvas(width, height);
|
|
14078
|
+
this.snapshotCanvas = offscreen;
|
|
14079
|
+
this.snapshotCtx = offscreen.getContext("2d");
|
|
14080
|
+
}
|
|
14081
|
+
const ctx = this.snapshotCtx;
|
|
14082
|
+
if (!ctx) return;
|
|
14083
|
+
ctx.clearRect(0, 0, width, height);
|
|
14084
|
+
ctx.drawImage(bitmap, 0, 0);
|
|
14085
|
+
const blob = await offscreen.convertToBlob(
|
|
14086
|
+
dataURLOptions
|
|
14087
|
+
);
|
|
14088
|
+
const arrayBuffer = await blob.arrayBuffer();
|
|
14089
|
+
const fingerprint = fnv1aHash(arrayBuffer);
|
|
14090
|
+
if (this.lastFingerprintMap.get(id) === fingerprint) return;
|
|
14091
|
+
this.lastFingerprintMap.set(id, fingerprint);
|
|
14092
|
+
this.emitCanvasSnapshot(
|
|
14097
14093
|
id,
|
|
14098
|
-
|
|
14099
|
-
|
|
14100
|
-
|
|
14101
|
-
|
|
14102
|
-
|
|
14103
|
-
|
|
14104
|
-
|
|
14105
|
-
|
|
14106
|
-
|
|
14107
|
-
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14094
|
+
encode(arrayBuffer),
|
|
14095
|
+
blob.type,
|
|
14096
|
+
width,
|
|
14097
|
+
height
|
|
14098
|
+
);
|
|
14099
|
+
} catch {
|
|
14100
|
+
} finally {
|
|
14101
|
+
bitmap.close();
|
|
14102
|
+
this.snapshotInProgressMap.set(id, false);
|
|
14103
|
+
}
|
|
14104
|
+
}
|
|
14105
|
+
emitCanvasSnapshot(id, base64, type, width, height) {
|
|
14106
|
+
this.mutationCb({
|
|
14107
|
+
id,
|
|
14108
|
+
type: CanvasContext["2D"],
|
|
14109
|
+
commands: [
|
|
14110
|
+
{
|
|
14111
|
+
property: "clearRect",
|
|
14112
|
+
// wipe canvas
|
|
14113
|
+
args: [0, 0, width, height]
|
|
14114
|
+
},
|
|
14115
|
+
{
|
|
14116
|
+
property: "drawImage",
|
|
14117
|
+
// draws (semi-transparent) image
|
|
14118
|
+
args: [
|
|
14119
|
+
{
|
|
14120
|
+
rr_type: "ImageBitmap",
|
|
14121
|
+
args: [
|
|
14122
|
+
{
|
|
14123
|
+
rr_type: "Blob",
|
|
14124
|
+
data: [{ rr_type: "ArrayBuffer", base64 }],
|
|
14125
|
+
type
|
|
14126
|
+
}
|
|
14127
|
+
]
|
|
14128
|
+
},
|
|
14129
|
+
0,
|
|
14130
|
+
0
|
|
14131
|
+
]
|
|
14132
|
+
}
|
|
14133
|
+
]
|
|
14134
|
+
});
|
|
14127
14135
|
}
|
|
14128
14136
|
initCanvasFPSObserver() {
|
|
14129
14137
|
let rafId;
|
|
@@ -14221,20 +14229,12 @@ class CanvasManager {
|
|
|
14221
14229
|
context.clear(context.COLOR_BUFFER_BIT);
|
|
14222
14230
|
}
|
|
14223
14231
|
}
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
width: canvas.width,
|
|
14231
|
-
height: canvas.height,
|
|
14232
|
-
dataURLOptions
|
|
14233
|
-
},
|
|
14234
|
-
[bitmap]
|
|
14235
|
-
);
|
|
14236
|
-
}).catch(() => {
|
|
14237
|
-
this.snapshotInProgressMap.delete(id);
|
|
14232
|
+
const width = canvas.width;
|
|
14233
|
+
const height = canvas.height;
|
|
14234
|
+
createImageBitmap(canvas).then(
|
|
14235
|
+
(bitmap) => this.snapshotImageBitmap(id, bitmap, width, height, dataURLOptions)
|
|
14236
|
+
).catch(() => {
|
|
14237
|
+
this.snapshotInProgressMap.set(id, false);
|
|
14238
14238
|
});
|
|
14239
14239
|
});
|
|
14240
14240
|
}
|
|
@@ -15624,10 +15624,10 @@ function deserializeArg(imageMap, ctx, preload) {
|
|
|
15624
15624
|
const blobContents = await Promise.all(
|
|
15625
15625
|
arg.data.map(deserializeArg(imageMap, ctx, preload))
|
|
15626
15626
|
);
|
|
15627
|
-
const
|
|
15627
|
+
const blob = new Blob(blobContents, {
|
|
15628
15628
|
type: arg.type
|
|
15629
15629
|
});
|
|
15630
|
-
return
|
|
15630
|
+
return blob;
|
|
15631
15631
|
}
|
|
15632
15632
|
} else if (Array.isArray(arg)) {
|
|
15633
15633
|
const result2 = await Promise.all(
|