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