@highlight-run/rrweb 2.0.0-lambda.1 → 2.0.0-lambda.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.js CHANGED
@@ -15007,8 +15007,12 @@ class Timer {
15007
15007
  this.actions = this.actions.concat(actions);
15008
15008
  }
15009
15009
  replaceActions(actions) {
15010
+ const rafWasActive = this.raf === true;
15010
15011
  this.actions.length = 0;
15011
- this.actions.splice(0, 0, ...actions);
15012
+ this.actions = [...actions];
15013
+ if (rafWasActive) {
15014
+ this.raf = requestAnimationFrame(this.rafCheck.bind(this));
15015
+ }
15012
15016
  }
15013
15017
  /* End Highlight Code */
15014
15018
  start() {
@@ -15377,28 +15381,26 @@ function createPlayerService(context, { getCastFn, applyEventsSynchronously, emi
15377
15381
  }),
15378
15382
  /* Highlight Code Start */
15379
15383
  replaceEvents: o((ctx, machineEvent) => {
15384
+ if (machineEvent.type !== "REPLACE_EVENTS") return ctx;
15380
15385
  const { events: curEvents, timer, baselineTime } = ctx;
15381
- if (machineEvent.type === "REPLACE_EVENTS") {
15382
- const { events: newEvents } = machineEvent.payload;
15383
- curEvents.length = 0;
15384
- const actions = [];
15385
- for (const event of newEvents) {
15386
- addDelay(event, baselineTime);
15387
- curEvents.push(event);
15388
- if (event.timestamp >= timer.timeOffset + baselineTime) {
15389
- const castFn = getCastFn(event, false);
15390
- actions.push({
15391
- doAction: () => {
15392
- castFn();
15393
- },
15394
- delay: event.delay
15395
- });
15396
- }
15397
- }
15398
- if (timer.isActive()) {
15399
- timer.replaceActions(actions);
15386
+ const { events: newEvents } = machineEvent.payload;
15387
+ if (newEvents.length === 0) return ctx;
15388
+ curEvents.length = 0;
15389
+ const actions = [];
15390
+ const timeThreshold = timer.timeOffset + baselineTime;
15391
+ for (const event of newEvents) {
15392
+ addDelay(event, baselineTime);
15393
+ curEvents.push(event);
15394
+ if (event.timestamp >= timeThreshold) {
15395
+ actions.push({
15396
+ doAction: getCastFn(event, false),
15397
+ delay: event.delay
15398
+ });
15400
15399
  }
15401
15400
  }
15401
+ if (timer.isActive()) {
15402
+ timer.replaceActions(actions);
15403
+ }
15402
15404
  return { ...ctx, events: curEvents };
15403
15405
  }),
15404
15406
  /* Highlight Code End */