@appsurify-testmap/rrweb-all 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.
@@ -15972,6 +15972,30 @@ class MutationBuffer {
15972
15972
  this.shadowDomManager.reset();
15973
15973
  this.canvasManager.reset();
15974
15974
  }
15975
+ /**
15976
+ * Clear all accumulated mutation data without emitting.
15977
+ * Used after freeze+debounce checkout — FullSnapshot already captured the state.
15978
+ */
15979
+ resetBuffers() {
15980
+ this.addedSet = /* @__PURE__ */ new Set();
15981
+ this.movedSet = /* @__PURE__ */ new Set();
15982
+ this.droppedSet = /* @__PURE__ */ new Set();
15983
+ this.removesSubTreeCache = /* @__PURE__ */ new Set();
15984
+ this.mapRemoves = [];
15985
+ this.movedMap = {};
15986
+ this.attributes = [];
15987
+ this.texts = [];
15988
+ this.attributeMap = /* @__PURE__ */ new WeakMap();
15989
+ this.removes = [];
15990
+ }
15991
+ /**
15992
+ * Clear frozen flag without triggering emit.
15993
+ * Used after freeze+debounce checkout — buffers already cleared by resetBuffers().
15994
+ */
15995
+ unsetFrozen() {
15996
+ this.frozen = false;
15997
+ this.canvasManager.unfreeze();
15998
+ }
15975
15999
  }
15976
16000
  function deepDelete(addsSet, n2) {
15977
16001
  addsSet.delete(n2);
@@ -18412,11 +18436,15 @@ class VisibilityManager {
18412
18436
  }
18413
18437
  flushBuffer() {
18414
18438
  var _a2;
18439
+ if (this.frozen || this.locked)
18440
+ return;
18415
18441
  if (this.buffer.size === 0)
18416
18442
  return;
18417
- (_a2 = this.notifyActivity) == null ? void 0 : _a2.call(this, this.buffer.size);
18418
- this.mutationCb({ mutations: Array.from(this.buffer.values()) });
18443
+ const mutations = Array.from(this.buffer.values());
18444
+ const count = mutations.length;
18419
18445
  this.buffer.clear();
18446
+ this.mutationCb({ mutations });
18447
+ (_a2 = this.notifyActivity) == null ? void 0 : _a2.call(this, count);
18420
18448
  }
18421
18449
  observe(el) {
18422
18450
  if (this.disabled)
@@ -18432,6 +18460,10 @@ class VisibilityManager {
18432
18460
  }
18433
18461
  freeze() {
18434
18462
  this.frozen = true;
18463
+ if (this.debounceTimer) {
18464
+ clearTimeout(this.debounceTimer);
18465
+ this.debounceTimer = null;
18466
+ }
18435
18467
  }
18436
18468
  unfreeze() {
18437
18469
  this.frozen = false;
@@ -18439,9 +18471,33 @@ class VisibilityManager {
18439
18471
  }
18440
18472
  lock() {
18441
18473
  this.locked = true;
18474
+ if (this.debounceTimer) {
18475
+ clearTimeout(this.debounceTimer);
18476
+ this.debounceTimer = null;
18477
+ }
18442
18478
  }
18443
18479
  unlock() {
18444
18480
  this.locked = false;
18481
+ this.buffer.clear();
18482
+ if (this.debounceTimer) {
18483
+ clearTimeout(this.debounceTimer);
18484
+ this.debounceTimer = null;
18485
+ }
18486
+ if (!this.disabled && this.elements.size > 0) {
18487
+ this.previousState = computeVisibility(this.elements, /* @__PURE__ */ new Map(), {
18488
+ root: this.root,
18489
+ threshold: this.threshold,
18490
+ sensitivity: this.sensitivity,
18491
+ rootMargin: this.rootMargin
18492
+ });
18493
+ }
18494
+ }
18495
+ /**
18496
+ * Clear frozen flag without triggering flush.
18497
+ * Used after freeze+debounce checkout — buffer already cleared by unlock().
18498
+ */
18499
+ unsetFrozen() {
18500
+ this.frozen = false;
18445
18501
  }
18446
18502
  reset() {
18447
18503
  this.elements.clear();
@@ -18598,6 +18654,7 @@ function record(options = {}) {
18598
18654
  checkoutEveryNms,
18599
18655
  checkoutEveryNth,
18600
18656
  checkoutEveryNvm,
18657
+ checkoutDebounce,
18601
18658
  blockClass = "rr-block",
18602
18659
  blockSelector = null,
18603
18660
  ignoreClass = "rr-ignore",
@@ -18692,6 +18749,10 @@ function record(options = {}) {
18692
18749
  let lastFullSnapshotEvent;
18693
18750
  let incrementalSnapshotCount = 0;
18694
18751
  let visibilityMutationCount = 0;
18752
+ let checkoutId = 0;
18753
+ let checkoutPending = false;
18754
+ let checkoutDebounceTimer = null;
18755
+ let checkoutFreezeTimestamp = null;
18695
18756
  const eventProcessor = (e2) => {
18696
18757
  for (const plugin3 of plugins || []) {
18697
18758
  if (plugin3.eventProcessor) {
@@ -18704,11 +18765,25 @@ function record(options = {}) {
18704
18765
  }
18705
18766
  return e2;
18706
18767
  };
18768
+ const executeCheckout = () => {
18769
+ checkoutDebounceTimer = null;
18770
+ checkoutPending = false;
18771
+ checkoutFreezeTimestamp = null;
18772
+ takeFullSnapshot$1(true);
18773
+ mutationBuffers.forEach((buf) => {
18774
+ buf.resetBuffers();
18775
+ buf.unsetFrozen();
18776
+ });
18777
+ if (visibilityManager) {
18778
+ visibilityManager.unsetFrozen();
18779
+ }
18780
+ };
18707
18781
  wrappedEmit = (r2, isCheckout) => {
18708
18782
  var _a2;
18709
18783
  const e2 = r2;
18710
18784
  e2.timestamp = nowTimestamp();
18711
- if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
18785
+ e2.checkoutId = checkoutId;
18786
+ if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && !checkoutPending && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
18712
18787
  mutationBuffers.forEach((buf) => buf.unfreeze());
18713
18788
  visibilityManager == null ? void 0 : visibilityManager.unfreeze();
18714
18789
  }
@@ -18735,7 +18810,29 @@ function record(options = {}) {
18735
18810
  const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
18736
18811
  const exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
18737
18812
  if (exceedCount || exceedTime) {
18738
- takeFullSnapshot$1(true);
18813
+ if (checkoutDebounce) {
18814
+ if (!checkoutPending) {
18815
+ checkoutPending = true;
18816
+ checkoutFreezeTimestamp = nowTimestamp();
18817
+ mutationBuffers.forEach((buf) => buf.freeze());
18818
+ visibilityManager == null ? void 0 : visibilityManager.freeze();
18819
+ }
18820
+ if (checkoutDebounceTimer) {
18821
+ clearTimeout(checkoutDebounceTimer);
18822
+ }
18823
+ const frozenDuration = nowTimestamp() - checkoutFreezeTimestamp;
18824
+ const maxFreeze = checkoutDebounce * 3;
18825
+ if (frozenDuration >= maxFreeze) {
18826
+ executeCheckout();
18827
+ } else {
18828
+ checkoutDebounceTimer = setTimeout(
18829
+ () => executeCheckout(),
18830
+ checkoutDebounce
18831
+ );
18832
+ }
18833
+ } else {
18834
+ takeFullSnapshot$1(true);
18835
+ }
18739
18836
  }
18740
18837
  }
18741
18838
  }
@@ -18845,8 +18942,30 @@ function record(options = {}) {
18845
18942
  notifyActivity: checkoutEveryNvm != null ? (count) => {
18846
18943
  visibilityMutationCount += count;
18847
18944
  if (visibilityMutationCount >= checkoutEveryNvm) {
18848
- takeFullSnapshot$1(true);
18849
18945
  visibilityMutationCount = 0;
18946
+ if (checkoutDebounce) {
18947
+ if (!checkoutPending) {
18948
+ checkoutPending = true;
18949
+ checkoutFreezeTimestamp = nowTimestamp();
18950
+ mutationBuffers.forEach((buf) => buf.freeze());
18951
+ visibilityManager == null ? void 0 : visibilityManager.freeze();
18952
+ }
18953
+ if (checkoutDebounceTimer) {
18954
+ clearTimeout(checkoutDebounceTimer);
18955
+ }
18956
+ const frozenDuration = nowTimestamp() - checkoutFreezeTimestamp;
18957
+ const maxFreeze = checkoutDebounce * 3;
18958
+ if (frozenDuration >= maxFreeze) {
18959
+ executeCheckout();
18960
+ } else {
18961
+ checkoutDebounceTimer = setTimeout(
18962
+ () => executeCheckout(),
18963
+ checkoutDebounce
18964
+ );
18965
+ }
18966
+ } else {
18967
+ takeFullSnapshot$1(true);
18968
+ }
18850
18969
  }
18851
18970
  } : void 0
18852
18971
  });
@@ -18855,6 +18974,7 @@ function record(options = {}) {
18855
18974
  if (!recordDOM) {
18856
18975
  return;
18857
18976
  }
18977
+ checkoutId++;
18858
18978
  wrappedEmit(
18859
18979
  {
18860
18980
  type: EventType.Meta,
@@ -19126,6 +19246,10 @@ function record(options = {}) {
19126
19246
  );
19127
19247
  }
19128
19248
  return () => {
19249
+ if (checkoutDebounceTimer) {
19250
+ clearTimeout(checkoutDebounceTimer);
19251
+ checkoutDebounceTimer = null;
19252
+ }
19129
19253
  flushCustomEventQueue$1();
19130
19254
  handlers.forEach((h) => h());
19131
19255
  processedNodeManager.destroy();