@screeb/rrweb 1.0.17 → 1.0.18

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.d.cts CHANGED
@@ -375,7 +375,6 @@ export declare class Replayer {
375
375
  private firstFullSnapshot;
376
376
  private newDocumentQueue;
377
377
  private pointers;
378
- private mouseTailAnimationFrame;
379
378
  private lastMouseDownEvent;
380
379
  private lastHoveredRootNode;
381
380
  private lastSelectionData;
@@ -424,7 +423,6 @@ export declare class Replayer {
424
423
  private legacy_resolveMissingNode;
425
424
  private moveAndHover;
426
425
  private drawMouseTail;
427
- private stepMouseTails;
428
426
  private hoverElements;
429
427
  private isUserInteraction;
430
428
  private backToNormal;
package/dist/rrweb.d.ts CHANGED
@@ -375,7 +375,6 @@ export declare class Replayer {
375
375
  private firstFullSnapshot;
376
376
  private newDocumentQueue;
377
377
  private pointers;
378
- private mouseTailAnimationFrame;
379
378
  private lastMouseDownEvent;
380
379
  private lastHoveredRootNode;
381
380
  private lastSelectionData;
@@ -424,7 +423,6 @@ export declare class Replayer {
424
423
  private legacy_resolveMissingNode;
425
424
  private moveAndHover;
426
425
  private drawMouseTail;
427
- private stepMouseTails;
428
426
  private hoverElements;
429
427
  private isUserInteraction;
430
428
  private backToNormal;
package/dist/rrweb.js CHANGED
@@ -8511,9 +8511,6 @@ function indicatesTouchDevice(e2) {
8511
8511
  return false;
8512
8512
  }
8513
8513
  const data = e2.data;
8514
- if (data.source === IncrementalSource.TouchMove) {
8515
- return true;
8516
- }
8517
8514
  if (data.source === IncrementalSource.MouseInteraction && data.type === MouseInteractions.TouchStart) {
8518
8515
  const mouseData = data;
8519
8516
  return mouseData.pointerType === PointerTypes.Touch;
@@ -8538,7 +8535,6 @@ class Replayer {
8538
8535
  this.firstFullSnapshot = null;
8539
8536
  this.newDocumentQueue = [];
8540
8537
  this.pointers = {};
8541
- this.mouseTailAnimationFrame = null;
8542
8538
  this.lastMouseDownEvent = null;
8543
8539
  this.lastSelectionData = null;
8544
8540
  this.constructedStyleMutations = [];
@@ -8676,53 +8672,6 @@ class Replayer {
8676
8672
  };
8677
8673
  return wrappedCastFn;
8678
8674
  };
8679
- this.stepMouseTails = (timestamp) => {
8680
- const { lineCap, lineWidth, strokeStyle, duration } = this.config.mouseTail === true ? defaultMouseTailConfig : Object.assign({}, defaultMouseTailConfig, this.config.mouseTail);
8681
- const maxAge = duration / this.speedService.state.context.timer.speed;
8682
- let hasAnyTail = false;
8683
- Object.values(this.pointers).forEach((pointer) => {
8684
- if (!pointer.mouseTail) {
8685
- return;
8686
- }
8687
- const mouseTail = pointer.mouseTail;
8688
- const ctx = mouseTail.getContext("2d");
8689
- if (!ctx) {
8690
- return;
8691
- }
8692
- pointer.tailPositions = pointer.tailPositions.filter(
8693
- (p) => timestamp - p.t <= maxAge
8694
- );
8695
- ctx.clearRect(0, 0, mouseTail.width, mouseTail.height);
8696
- if (pointer.tailPositions.length > 1) {
8697
- hasAnyTail = true;
8698
- ctx.lineWidth = lineWidth;
8699
- ctx.lineCap = lineCap;
8700
- ctx.strokeStyle = strokeStyle;
8701
- for (let i2 = 1; i2 < pointer.tailPositions.length; i2++) {
8702
- const prev = pointer.tailPositions[i2 - 1];
8703
- const curr = pointer.tailPositions[i2];
8704
- const age = (timestamp - curr.t) / maxAge;
8705
- const alpha = Math.max(0, 1 - age);
8706
- if (alpha <= 0) {
8707
- continue;
8708
- }
8709
- ctx.globalAlpha = alpha;
8710
- ctx.beginPath();
8711
- ctx.moveTo(prev.x, prev.y);
8712
- ctx.lineTo(curr.x, curr.y);
8713
- ctx.stroke();
8714
- }
8715
- ctx.globalAlpha = 1;
8716
- }
8717
- });
8718
- if (hasAnyTail) {
8719
- this.mouseTailAnimationFrame = requestAnimationFrame(
8720
- this.stepMouseTails
8721
- );
8722
- } else {
8723
- this.mouseTailAnimationFrame = null;
8724
- }
8725
- };
8726
8675
  if (!config?.liveMode && events.length < 2) {
8727
8676
  throw new Error("Replayer need at least 2 events.");
8728
8677
  }
@@ -10247,12 +10196,38 @@ class Replayer {
10247
10196
  if (!pointer || !pointer.mouseTail) {
10248
10197
  return;
10249
10198
  }
10199
+ const { lineCap, lineWidth, strokeStyle, duration } = this.config.mouseTail === true ? defaultMouseTailConfig : Object.assign({}, defaultMouseTailConfig, this.config.mouseTail);
10250
10200
  const now = typeof performance !== "undefined" ? performance.now() : Date.now();
10201
+ const maxAge = duration / this.speedService.state.context.timer.speed;
10251
10202
  pointer.tailPositions.push({ x: position.x, y: position.y, t: now });
10252
- if (this.mouseTailAnimationFrame === null) {
10253
- this.mouseTailAnimationFrame = requestAnimationFrame(
10254
- this.stepMouseTails
10255
- );
10203
+ pointer.tailPositions = pointer.tailPositions.filter(
10204
+ (p) => now - p.t <= maxAge
10205
+ );
10206
+ const mouseTail = pointer.mouseTail;
10207
+ const ctx = mouseTail.getContext("2d");
10208
+ if (!ctx) {
10209
+ return;
10210
+ }
10211
+ ctx.clearRect(0, 0, mouseTail.width, mouseTail.height);
10212
+ if (pointer.tailPositions.length > 1) {
10213
+ ctx.lineWidth = lineWidth;
10214
+ ctx.lineCap = lineCap;
10215
+ ctx.strokeStyle = strokeStyle;
10216
+ for (let i2 = 1; i2 < pointer.tailPositions.length; i2++) {
10217
+ const prev = pointer.tailPositions[i2 - 1];
10218
+ const curr = pointer.tailPositions[i2];
10219
+ const age = (now - curr.t) / maxAge;
10220
+ const alpha = Math.max(0, 1 - age);
10221
+ if (alpha <= 0) {
10222
+ continue;
10223
+ }
10224
+ ctx.globalAlpha = alpha;
10225
+ ctx.beginPath();
10226
+ ctx.moveTo(prev.x, prev.y);
10227
+ ctx.lineTo(curr.x, curr.y);
10228
+ ctx.stroke();
10229
+ }
10230
+ ctx.globalAlpha = 1;
10256
10231
  }
10257
10232
  }
10258
10233
  hoverElements(el) {