@screeb/rrweb 1.0.18 → 1.0.20
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 +53 -31
- package/dist/rrweb.cjs.map +1 -1
- package/dist/rrweb.d.cts +2 -0
- package/dist/rrweb.d.ts +2 -0
- package/dist/rrweb.js +53 -31
- package/dist/rrweb.js.map +1 -1
- package/dist/rrweb.umd.cjs +53 -31
- package/dist/rrweb.umd.cjs.map +2 -2
- package/dist/rrweb.umd.min.cjs +4 -4
- package/dist/rrweb.umd.min.cjs.map +3 -3
- package/dist/ts3.8/rrweb.d.ts +2 -0
- package/package.json +1 -1
package/dist/rrweb.cjs
CHANGED
|
@@ -8218,7 +8218,7 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
|
|
|
8218
8218
|
}
|
|
8219
8219
|
events.splice(insertionIndex, 0, event);
|
|
8220
8220
|
}
|
|
8221
|
-
const isSync = event.timestamp < baselineTime;
|
|
8221
|
+
const isSync = event.timestamp < baselineTime || !timer.isActive();
|
|
8222
8222
|
const castFn = getCastFn(event, isSync);
|
|
8223
8223
|
if (isSync) {
|
|
8224
8224
|
castFn();
|
|
@@ -8537,6 +8537,7 @@ class Replayer {
|
|
|
8537
8537
|
this.firstFullSnapshot = null;
|
|
8538
8538
|
this.newDocumentQueue = [];
|
|
8539
8539
|
this.pointers = {};
|
|
8540
|
+
this.mouseTailAnimationFrame = null;
|
|
8540
8541
|
this.lastMouseDownEvent = null;
|
|
8541
8542
|
this.lastSelectionData = null;
|
|
8542
8543
|
this.constructedStyleMutations = [];
|
|
@@ -8674,6 +8675,53 @@ class Replayer {
|
|
|
8674
8675
|
};
|
|
8675
8676
|
return wrappedCastFn;
|
|
8676
8677
|
};
|
|
8678
|
+
this.stepMouseTails = (timestamp) => {
|
|
8679
|
+
const { lineCap, lineWidth, strokeStyle, duration } = this.config.mouseTail === true ? defaultMouseTailConfig : Object.assign({}, defaultMouseTailConfig, this.config.mouseTail);
|
|
8680
|
+
const maxAge = duration / this.speedService.state.context.timer.speed;
|
|
8681
|
+
let hasAnyTail = false;
|
|
8682
|
+
Object.values(this.pointers).forEach((pointer) => {
|
|
8683
|
+
if (!pointer.mouseTail) {
|
|
8684
|
+
return;
|
|
8685
|
+
}
|
|
8686
|
+
const mouseTail = pointer.mouseTail;
|
|
8687
|
+
const ctx = mouseTail.getContext("2d");
|
|
8688
|
+
if (!ctx) {
|
|
8689
|
+
return;
|
|
8690
|
+
}
|
|
8691
|
+
pointer.tailPositions = pointer.tailPositions.filter(
|
|
8692
|
+
(p) => timestamp - p.t <= maxAge
|
|
8693
|
+
);
|
|
8694
|
+
ctx.clearRect(0, 0, mouseTail.width, mouseTail.height);
|
|
8695
|
+
if (pointer.tailPositions.length > 1) {
|
|
8696
|
+
hasAnyTail = true;
|
|
8697
|
+
ctx.lineWidth = lineWidth;
|
|
8698
|
+
ctx.lineCap = lineCap;
|
|
8699
|
+
ctx.strokeStyle = strokeStyle;
|
|
8700
|
+
for (let i2 = 1; i2 < pointer.tailPositions.length; i2++) {
|
|
8701
|
+
const prev = pointer.tailPositions[i2 - 1];
|
|
8702
|
+
const curr = pointer.tailPositions[i2];
|
|
8703
|
+
const age = (timestamp - curr.t) / maxAge;
|
|
8704
|
+
const alpha = Math.max(0, 1 - age);
|
|
8705
|
+
if (alpha <= 0) {
|
|
8706
|
+
continue;
|
|
8707
|
+
}
|
|
8708
|
+
ctx.globalAlpha = alpha;
|
|
8709
|
+
ctx.beginPath();
|
|
8710
|
+
ctx.moveTo(prev.x, prev.y);
|
|
8711
|
+
ctx.lineTo(curr.x, curr.y);
|
|
8712
|
+
ctx.stroke();
|
|
8713
|
+
}
|
|
8714
|
+
ctx.globalAlpha = 1;
|
|
8715
|
+
}
|
|
8716
|
+
});
|
|
8717
|
+
if (hasAnyTail) {
|
|
8718
|
+
this.mouseTailAnimationFrame = requestAnimationFrame(
|
|
8719
|
+
this.stepMouseTails
|
|
8720
|
+
);
|
|
8721
|
+
} else {
|
|
8722
|
+
this.mouseTailAnimationFrame = null;
|
|
8723
|
+
}
|
|
8724
|
+
};
|
|
8677
8725
|
if (!config?.liveMode && events.length < 2) {
|
|
8678
8726
|
throw new Error("Replayer need at least 2 events.");
|
|
8679
8727
|
}
|
|
@@ -10198,38 +10246,12 @@ class Replayer {
|
|
|
10198
10246
|
if (!pointer || !pointer.mouseTail) {
|
|
10199
10247
|
return;
|
|
10200
10248
|
}
|
|
10201
|
-
const { lineCap, lineWidth, strokeStyle, duration } = this.config.mouseTail === true ? defaultMouseTailConfig : Object.assign({}, defaultMouseTailConfig, this.config.mouseTail);
|
|
10202
10249
|
const now = typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
10203
|
-
const maxAge = duration / this.speedService.state.context.timer.speed;
|
|
10204
10250
|
pointer.tailPositions.push({ x: position.x, y: position.y, t: now });
|
|
10205
|
-
|
|
10206
|
-
|
|
10207
|
-
|
|
10208
|
-
|
|
10209
|
-
const ctx = mouseTail.getContext("2d");
|
|
10210
|
-
if (!ctx) {
|
|
10211
|
-
return;
|
|
10212
|
-
}
|
|
10213
|
-
ctx.clearRect(0, 0, mouseTail.width, mouseTail.height);
|
|
10214
|
-
if (pointer.tailPositions.length > 1) {
|
|
10215
|
-
ctx.lineWidth = lineWidth;
|
|
10216
|
-
ctx.lineCap = lineCap;
|
|
10217
|
-
ctx.strokeStyle = strokeStyle;
|
|
10218
|
-
for (let i2 = 1; i2 < pointer.tailPositions.length; i2++) {
|
|
10219
|
-
const prev = pointer.tailPositions[i2 - 1];
|
|
10220
|
-
const curr = pointer.tailPositions[i2];
|
|
10221
|
-
const age = (now - curr.t) / maxAge;
|
|
10222
|
-
const alpha = Math.max(0, 1 - age);
|
|
10223
|
-
if (alpha <= 0) {
|
|
10224
|
-
continue;
|
|
10225
|
-
}
|
|
10226
|
-
ctx.globalAlpha = alpha;
|
|
10227
|
-
ctx.beginPath();
|
|
10228
|
-
ctx.moveTo(prev.x, prev.y);
|
|
10229
|
-
ctx.lineTo(curr.x, curr.y);
|
|
10230
|
-
ctx.stroke();
|
|
10231
|
-
}
|
|
10232
|
-
ctx.globalAlpha = 1;
|
|
10251
|
+
if (this.mouseTailAnimationFrame === null) {
|
|
10252
|
+
this.mouseTailAnimationFrame = requestAnimationFrame(
|
|
10253
|
+
this.stepMouseTails
|
|
10254
|
+
);
|
|
10233
10255
|
}
|
|
10234
10256
|
}
|
|
10235
10257
|
hoverElements(el) {
|