@amplitude/rrweb-player 2.0.0-alpha.35 → 2.0.0-alpha.36

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.
@@ -14595,6 +14595,15 @@ function v(t2) {
14595
14595
  } };
14596
14596
  return c2;
14597
14597
  }
14598
+ function isDuplicateEvent(existing, incoming) {
14599
+ if (existing === incoming) {
14600
+ return true;
14601
+ }
14602
+ if (existing.timestamp === incoming.timestamp && existing.type === incoming.type) {
14603
+ return JSON.stringify(existing) === JSON.stringify(incoming);
14604
+ }
14605
+ return false;
14606
+ }
14598
14607
  function discardPriorSnapshots(events, baselineTime) {
14599
14608
  for (let idx = events.length - 1; idx >= 0; idx--) {
14600
14609
  const event2 = events[idx];
@@ -14749,6 +14758,9 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
14749
14758
  addDelay(event2, baselineTime);
14750
14759
  let end = events.length - 1;
14751
14760
  if (!events[end] || events[end].timestamp <= event2.timestamp) {
14761
+ if (events[end] && isDuplicateEvent(events[end], event2)) {
14762
+ return { ...ctx, events };
14763
+ }
14752
14764
  events.push(event2);
14753
14765
  } else {
14754
14766
  let insertionIndex = -1;
@@ -14764,6 +14776,16 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
14764
14776
  if (insertionIndex === -1) {
14765
14777
  insertionIndex = start;
14766
14778
  }
14779
+ for (let i2 = insertionIndex - 1; i2 >= 0 && events[i2].timestamp === event2.timestamp; i2--) {
14780
+ if (isDuplicateEvent(events[i2], event2)) {
14781
+ return { ...ctx, events };
14782
+ }
14783
+ }
14784
+ for (let i2 = insertionIndex; i2 < events.length && events[i2].timestamp === event2.timestamp; i2++) {
14785
+ if (isDuplicateEvent(events[i2], event2)) {
14786
+ return { ...ctx, events };
14787
+ }
14788
+ }
14767
14789
  events.splice(insertionIndex, 0, event2);
14768
14790
  }
14769
14791
  const isSync = event2.timestamp < baselineTime;