@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.
@@ -14589,6 +14589,15 @@ function v(t2) {
14589
14589
  } };
14590
14590
  return c2;
14591
14591
  }
14592
+ function isDuplicateEvent(existing, incoming) {
14593
+ if (existing === incoming) {
14594
+ return true;
14595
+ }
14596
+ if (existing.timestamp === incoming.timestamp && existing.type === incoming.type) {
14597
+ return JSON.stringify(existing) === JSON.stringify(incoming);
14598
+ }
14599
+ return false;
14600
+ }
14592
14601
  function discardPriorSnapshots(events, baselineTime) {
14593
14602
  for (let idx = events.length - 1; idx >= 0; idx--) {
14594
14603
  const event2 = events[idx];
@@ -14741,6 +14750,9 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
14741
14750
  addDelay(event2, baselineTime);
14742
14751
  let end = events.length - 1;
14743
14752
  if (!events[end] || events[end].timestamp <= event2.timestamp) {
14753
+ if (events[end] && isDuplicateEvent(events[end], event2)) {
14754
+ return __spreadProps(__spreadValues({}, ctx), { events });
14755
+ }
14744
14756
  events.push(event2);
14745
14757
  } else {
14746
14758
  let insertionIndex = -1;
@@ -14756,6 +14768,16 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
14756
14768
  if (insertionIndex === -1) {
14757
14769
  insertionIndex = start;
14758
14770
  }
14771
+ for (let i2 = insertionIndex - 1; i2 >= 0 && events[i2].timestamp === event2.timestamp; i2--) {
14772
+ if (isDuplicateEvent(events[i2], event2)) {
14773
+ return __spreadProps(__spreadValues({}, ctx), { events });
14774
+ }
14775
+ }
14776
+ for (let i2 = insertionIndex; i2 < events.length && events[i2].timestamp === event2.timestamp; i2++) {
14777
+ if (isDuplicateEvent(events[i2], event2)) {
14778
+ return __spreadProps(__spreadValues({}, ctx), { events });
14779
+ }
14780
+ }
14759
14781
  events.splice(insertionIndex, 0, event2);
14760
14782
  }
14761
14783
  const isSync = event2.timestamp < baselineTime;