@appsurify-testmap/rrweb 3.1.1-alpha.3 → 3.2.0-alpha.1

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 CHANGED
@@ -15490,6 +15490,30 @@ class MutationBuffer {
15490
15490
  this.shadowDomManager.reset();
15491
15491
  this.canvasManager.reset();
15492
15492
  }
15493
+ /**
15494
+ * Clear all accumulated mutation data without emitting.
15495
+ * Used after freeze+debounce checkout — FullSnapshot already captured the state.
15496
+ */
15497
+ resetBuffers() {
15498
+ this.addedSet = /* @__PURE__ */ new Set();
15499
+ this.movedSet = /* @__PURE__ */ new Set();
15500
+ this.droppedSet = /* @__PURE__ */ new Set();
15501
+ this.removesSubTreeCache = /* @__PURE__ */ new Set();
15502
+ this.mapRemoves = [];
15503
+ this.movedMap = {};
15504
+ this.attributes = [];
15505
+ this.texts = [];
15506
+ this.attributeMap = /* @__PURE__ */ new WeakMap();
15507
+ this.removes = [];
15508
+ }
15509
+ /**
15510
+ * Clear frozen flag without triggering emit.
15511
+ * Used after freeze+debounce checkout — buffers already cleared by resetBuffers().
15512
+ */
15513
+ unsetFrozen() {
15514
+ this.frozen = false;
15515
+ this.canvasManager.unfreeze();
15516
+ }
15493
15517
  }
15494
15518
  function deepDelete(addsSet, n2) {
15495
15519
  addsSet.delete(n2);
@@ -17900,10 +17924,13 @@ class VisibilityManager {
17900
17924
  }
17901
17925
  flushBuffer() {
17902
17926
  var _a2;
17927
+ if (this.frozen || this.locked) return;
17903
17928
  if (this.buffer.size === 0) return;
17904
- (_a2 = this.notifyActivity) == null ? void 0 : _a2.call(this, this.buffer.size);
17905
- this.mutationCb({ mutations: Array.from(this.buffer.values()) });
17929
+ const mutations = Array.from(this.buffer.values());
17930
+ const count = mutations.length;
17906
17931
  this.buffer.clear();
17932
+ this.mutationCb({ mutations });
17933
+ (_a2 = this.notifyActivity) == null ? void 0 : _a2.call(this, count);
17907
17934
  }
17908
17935
  observe(el) {
17909
17936
  if (this.disabled) return;
@@ -17917,6 +17944,10 @@ class VisibilityManager {
17917
17944
  }
17918
17945
  freeze() {
17919
17946
  this.frozen = true;
17947
+ if (this.debounceTimer) {
17948
+ clearTimeout(this.debounceTimer);
17949
+ this.debounceTimer = null;
17950
+ }
17920
17951
  }
17921
17952
  unfreeze() {
17922
17953
  this.frozen = false;
@@ -17924,9 +17955,33 @@ class VisibilityManager {
17924
17955
  }
17925
17956
  lock() {
17926
17957
  this.locked = true;
17958
+ if (this.debounceTimer) {
17959
+ clearTimeout(this.debounceTimer);
17960
+ this.debounceTimer = null;
17961
+ }
17927
17962
  }
17928
17963
  unlock() {
17929
17964
  this.locked = false;
17965
+ this.buffer.clear();
17966
+ if (this.debounceTimer) {
17967
+ clearTimeout(this.debounceTimer);
17968
+ this.debounceTimer = null;
17969
+ }
17970
+ if (!this.disabled && this.elements.size > 0) {
17971
+ this.previousState = computeVisibility(this.elements, /* @__PURE__ */ new Map(), {
17972
+ root: this.root,
17973
+ threshold: this.threshold,
17974
+ sensitivity: this.sensitivity,
17975
+ rootMargin: this.rootMargin
17976
+ });
17977
+ }
17978
+ }
17979
+ /**
17980
+ * Clear frozen flag without triggering flush.
17981
+ * Used after freeze+debounce checkout — buffer already cleared by unlock().
17982
+ */
17983
+ unsetFrozen() {
17984
+ this.frozen = false;
17930
17985
  }
17931
17986
  reset() {
17932
17987
  this.elements.clear();
@@ -18025,7 +18080,7 @@ class ProcessedNodeManager {
18025
18080
  destroy() {
18026
18081
  }
18027
18082
  }
18028
- const version$1 = "3.1.1-alpha.3";
18083
+ const version$1 = "3.2.0-alpha.1";
18029
18084
  let wrappedEmit;
18030
18085
  let takeFullSnapshot$1;
18031
18086
  let canvasManager;
@@ -18079,6 +18134,7 @@ function record(options = {}) {
18079
18134
  checkoutEveryNms,
18080
18135
  checkoutEveryNth,
18081
18136
  checkoutEveryNvm,
18137
+ checkoutDebounce,
18082
18138
  blockClass = "rr-block",
18083
18139
  blockSelector = null,
18084
18140
  ignoreClass = "rr-ignore",
@@ -18173,6 +18229,10 @@ function record(options = {}) {
18173
18229
  let lastFullSnapshotEvent;
18174
18230
  let incrementalSnapshotCount = 0;
18175
18231
  let visibilityMutationCount = 0;
18232
+ let checkoutId = 0;
18233
+ let checkoutPending = false;
18234
+ let checkoutDebounceTimer = null;
18235
+ let checkoutFreezeTimestamp = null;
18176
18236
  const eventProcessor = (e2) => {
18177
18237
  for (const plugin3 of plugins || []) {
18178
18238
  if (plugin3.eventProcessor) {
@@ -18185,11 +18245,25 @@ function record(options = {}) {
18185
18245
  }
18186
18246
  return e2;
18187
18247
  };
18248
+ const executeCheckout = () => {
18249
+ checkoutDebounceTimer = null;
18250
+ checkoutPending = false;
18251
+ checkoutFreezeTimestamp = null;
18252
+ takeFullSnapshot$1(true);
18253
+ mutationBuffers.forEach((buf) => {
18254
+ buf.resetBuffers();
18255
+ buf.unsetFrozen();
18256
+ });
18257
+ if (visibilityManager) {
18258
+ visibilityManager.unsetFrozen();
18259
+ }
18260
+ };
18188
18261
  wrappedEmit = (r2, isCheckout) => {
18189
18262
  var _a2;
18190
18263
  const e2 = r2;
18191
18264
  e2.timestamp = nowTimestamp();
18192
- if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
18265
+ e2.checkoutId = checkoutId;
18266
+ if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && !checkoutPending && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
18193
18267
  mutationBuffers.forEach((buf) => buf.unfreeze());
18194
18268
  visibilityManager == null ? void 0 : visibilityManager.unfreeze();
18195
18269
  }
@@ -18216,7 +18290,29 @@ function record(options = {}) {
18216
18290
  const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
18217
18291
  const exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
18218
18292
  if (exceedCount || exceedTime) {
18219
- takeFullSnapshot$1(true);
18293
+ if (checkoutDebounce) {
18294
+ if (!checkoutPending) {
18295
+ checkoutPending = true;
18296
+ checkoutFreezeTimestamp = nowTimestamp();
18297
+ mutationBuffers.forEach((buf) => buf.freeze());
18298
+ visibilityManager == null ? void 0 : visibilityManager.freeze();
18299
+ }
18300
+ if (checkoutDebounceTimer) {
18301
+ clearTimeout(checkoutDebounceTimer);
18302
+ }
18303
+ const frozenDuration = nowTimestamp() - checkoutFreezeTimestamp;
18304
+ const maxFreeze = checkoutDebounce * 3;
18305
+ if (frozenDuration >= maxFreeze) {
18306
+ executeCheckout();
18307
+ } else {
18308
+ checkoutDebounceTimer = setTimeout(
18309
+ () => executeCheckout(),
18310
+ checkoutDebounce
18311
+ );
18312
+ }
18313
+ } else {
18314
+ takeFullSnapshot$1(true);
18315
+ }
18220
18316
  }
18221
18317
  }
18222
18318
  }
@@ -18331,8 +18427,30 @@ function record(options = {}) {
18331
18427
  notifyActivity: checkoutEveryNvm != null ? (count) => {
18332
18428
  visibilityMutationCount += count;
18333
18429
  if (visibilityMutationCount >= checkoutEveryNvm) {
18334
- takeFullSnapshot$1(true);
18335
18430
  visibilityMutationCount = 0;
18431
+ if (checkoutDebounce) {
18432
+ if (!checkoutPending) {
18433
+ checkoutPending = true;
18434
+ checkoutFreezeTimestamp = nowTimestamp();
18435
+ mutationBuffers.forEach((buf) => buf.freeze());
18436
+ visibilityManager == null ? void 0 : visibilityManager.freeze();
18437
+ }
18438
+ if (checkoutDebounceTimer) {
18439
+ clearTimeout(checkoutDebounceTimer);
18440
+ }
18441
+ const frozenDuration = nowTimestamp() - checkoutFreezeTimestamp;
18442
+ const maxFreeze = checkoutDebounce * 3;
18443
+ if (frozenDuration >= maxFreeze) {
18444
+ executeCheckout();
18445
+ } else {
18446
+ checkoutDebounceTimer = setTimeout(
18447
+ () => executeCheckout(),
18448
+ checkoutDebounce
18449
+ );
18450
+ }
18451
+ } else {
18452
+ takeFullSnapshot$1(true);
18453
+ }
18336
18454
  }
18337
18455
  } : void 0
18338
18456
  });
@@ -18341,6 +18459,7 @@ function record(options = {}) {
18341
18459
  if (!recordDOM) {
18342
18460
  return;
18343
18461
  }
18462
+ checkoutId++;
18344
18463
  wrappedEmit(
18345
18464
  {
18346
18465
  type: EventType.Meta,
@@ -18619,6 +18738,10 @@ function record(options = {}) {
18619
18738
  );
18620
18739
  }
18621
18740
  return () => {
18741
+ if (checkoutDebounceTimer) {
18742
+ clearTimeout(checkoutDebounceTimer);
18743
+ checkoutDebounceTimer = null;
18744
+ }
18622
18745
  flushCustomEventQueue$1();
18623
18746
  handlers.forEach((h) => h());
18624
18747
  processedNodeManager.destroy();
@@ -21553,7 +21676,7 @@ class Replayer {
21553
21676
  this.config.logger.log(REPLAY_CONSOLE_PREFIX, ...args);
21554
21677
  }
21555
21678
  }
21556
- const version = "3.1.1-alpha.3";
21679
+ const version = "3.2.0-alpha.1";
21557
21680
  const { getVersion } = record;
21558
21681
  const { isRecording } = record;
21559
21682
  const { flushCustomEventQueue } = record;