@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.
@@ -15470,6 +15470,30 @@ class MutationBuffer {
15470
15470
  this.shadowDomManager.reset();
15471
15471
  this.canvasManager.reset();
15472
15472
  }
15473
+ /**
15474
+ * Clear all accumulated mutation data without emitting.
15475
+ * Used after freeze+debounce checkout — FullSnapshot already captured the state.
15476
+ */
15477
+ resetBuffers() {
15478
+ this.addedSet = /* @__PURE__ */ new Set();
15479
+ this.movedSet = /* @__PURE__ */ new Set();
15480
+ this.droppedSet = /* @__PURE__ */ new Set();
15481
+ this.removesSubTreeCache = /* @__PURE__ */ new Set();
15482
+ this.mapRemoves = [];
15483
+ this.movedMap = {};
15484
+ this.attributes = [];
15485
+ this.texts = [];
15486
+ this.attributeMap = /* @__PURE__ */ new WeakMap();
15487
+ this.removes = [];
15488
+ }
15489
+ /**
15490
+ * Clear frozen flag without triggering emit.
15491
+ * Used after freeze+debounce checkout — buffers already cleared by resetBuffers().
15492
+ */
15493
+ unsetFrozen() {
15494
+ this.frozen = false;
15495
+ this.canvasManager.unfreeze();
15496
+ }
15473
15497
  }
15474
15498
  function deepDelete(addsSet, n2) {
15475
15499
  addsSet.delete(n2);
@@ -17880,10 +17904,13 @@ class VisibilityManager {
17880
17904
  }
17881
17905
  flushBuffer() {
17882
17906
  var _a2;
17907
+ if (this.frozen || this.locked) return;
17883
17908
  if (this.buffer.size === 0) return;
17884
- (_a2 = this.notifyActivity) == null ? void 0 : _a2.call(this, this.buffer.size);
17885
- this.mutationCb({ mutations: Array.from(this.buffer.values()) });
17909
+ const mutations = Array.from(this.buffer.values());
17910
+ const count = mutations.length;
17886
17911
  this.buffer.clear();
17912
+ this.mutationCb({ mutations });
17913
+ (_a2 = this.notifyActivity) == null ? void 0 : _a2.call(this, count);
17887
17914
  }
17888
17915
  observe(el) {
17889
17916
  if (this.disabled) return;
@@ -17897,6 +17924,10 @@ class VisibilityManager {
17897
17924
  }
17898
17925
  freeze() {
17899
17926
  this.frozen = true;
17927
+ if (this.debounceTimer) {
17928
+ clearTimeout(this.debounceTimer);
17929
+ this.debounceTimer = null;
17930
+ }
17900
17931
  }
17901
17932
  unfreeze() {
17902
17933
  this.frozen = false;
@@ -17904,9 +17935,33 @@ class VisibilityManager {
17904
17935
  }
17905
17936
  lock() {
17906
17937
  this.locked = true;
17938
+ if (this.debounceTimer) {
17939
+ clearTimeout(this.debounceTimer);
17940
+ this.debounceTimer = null;
17941
+ }
17907
17942
  }
17908
17943
  unlock() {
17909
17944
  this.locked = false;
17945
+ this.buffer.clear();
17946
+ if (this.debounceTimer) {
17947
+ clearTimeout(this.debounceTimer);
17948
+ this.debounceTimer = null;
17949
+ }
17950
+ if (!this.disabled && this.elements.size > 0) {
17951
+ this.previousState = computeVisibility(this.elements, /* @__PURE__ */ new Map(), {
17952
+ root: this.root,
17953
+ threshold: this.threshold,
17954
+ sensitivity: this.sensitivity,
17955
+ rootMargin: this.rootMargin
17956
+ });
17957
+ }
17958
+ }
17959
+ /**
17960
+ * Clear frozen flag without triggering flush.
17961
+ * Used after freeze+debounce checkout — buffer already cleared by unlock().
17962
+ */
17963
+ unsetFrozen() {
17964
+ this.frozen = false;
17910
17965
  }
17911
17966
  reset() {
17912
17967
  this.elements.clear();
@@ -18059,6 +18114,7 @@ function record(options = {}) {
18059
18114
  checkoutEveryNms,
18060
18115
  checkoutEveryNth,
18061
18116
  checkoutEveryNvm,
18117
+ checkoutDebounce,
18062
18118
  blockClass = "rr-block",
18063
18119
  blockSelector = null,
18064
18120
  ignoreClass = "rr-ignore",
@@ -18153,6 +18209,10 @@ function record(options = {}) {
18153
18209
  let lastFullSnapshotEvent;
18154
18210
  let incrementalSnapshotCount = 0;
18155
18211
  let visibilityMutationCount = 0;
18212
+ let checkoutId = 0;
18213
+ let checkoutPending = false;
18214
+ let checkoutDebounceTimer = null;
18215
+ let checkoutFreezeTimestamp = null;
18156
18216
  const eventProcessor = (e2) => {
18157
18217
  for (const plugin3 of plugins || []) {
18158
18218
  if (plugin3.eventProcessor) {
@@ -18165,11 +18225,25 @@ function record(options = {}) {
18165
18225
  }
18166
18226
  return e2;
18167
18227
  };
18228
+ const executeCheckout = () => {
18229
+ checkoutDebounceTimer = null;
18230
+ checkoutPending = false;
18231
+ checkoutFreezeTimestamp = null;
18232
+ takeFullSnapshot$1(true);
18233
+ mutationBuffers.forEach((buf) => {
18234
+ buf.resetBuffers();
18235
+ buf.unsetFrozen();
18236
+ });
18237
+ if (visibilityManager) {
18238
+ visibilityManager.unsetFrozen();
18239
+ }
18240
+ };
18168
18241
  wrappedEmit = (r2, isCheckout) => {
18169
18242
  var _a2;
18170
18243
  const e2 = r2;
18171
18244
  e2.timestamp = nowTimestamp();
18172
- if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
18245
+ e2.checkoutId = checkoutId;
18246
+ if (((_a2 = mutationBuffers[0]) == null ? void 0 : _a2.isFrozen()) && !checkoutPending && e2.type !== EventType.FullSnapshot && !(e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.Mutation)) {
18173
18247
  mutationBuffers.forEach((buf) => buf.unfreeze());
18174
18248
  visibilityManager == null ? void 0 : visibilityManager.unfreeze();
18175
18249
  }
@@ -18196,7 +18270,29 @@ function record(options = {}) {
18196
18270
  const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
18197
18271
  const exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
18198
18272
  if (exceedCount || exceedTime) {
18199
- takeFullSnapshot$1(true);
18273
+ if (checkoutDebounce) {
18274
+ if (!checkoutPending) {
18275
+ checkoutPending = true;
18276
+ checkoutFreezeTimestamp = nowTimestamp();
18277
+ mutationBuffers.forEach((buf) => buf.freeze());
18278
+ visibilityManager == null ? void 0 : visibilityManager.freeze();
18279
+ }
18280
+ if (checkoutDebounceTimer) {
18281
+ clearTimeout(checkoutDebounceTimer);
18282
+ }
18283
+ const frozenDuration = nowTimestamp() - checkoutFreezeTimestamp;
18284
+ const maxFreeze = checkoutDebounce * 3;
18285
+ if (frozenDuration >= maxFreeze) {
18286
+ executeCheckout();
18287
+ } else {
18288
+ checkoutDebounceTimer = setTimeout(
18289
+ () => executeCheckout(),
18290
+ checkoutDebounce
18291
+ );
18292
+ }
18293
+ } else {
18294
+ takeFullSnapshot$1(true);
18295
+ }
18200
18296
  }
18201
18297
  }
18202
18298
  }
@@ -18311,8 +18407,30 @@ function record(options = {}) {
18311
18407
  notifyActivity: checkoutEveryNvm != null ? (count) => {
18312
18408
  visibilityMutationCount += count;
18313
18409
  if (visibilityMutationCount >= checkoutEveryNvm) {
18314
- takeFullSnapshot$1(true);
18315
18410
  visibilityMutationCount = 0;
18411
+ if (checkoutDebounce) {
18412
+ if (!checkoutPending) {
18413
+ checkoutPending = true;
18414
+ checkoutFreezeTimestamp = nowTimestamp();
18415
+ mutationBuffers.forEach((buf) => buf.freeze());
18416
+ visibilityManager == null ? void 0 : visibilityManager.freeze();
18417
+ }
18418
+ if (checkoutDebounceTimer) {
18419
+ clearTimeout(checkoutDebounceTimer);
18420
+ }
18421
+ const frozenDuration = nowTimestamp() - checkoutFreezeTimestamp;
18422
+ const maxFreeze = checkoutDebounce * 3;
18423
+ if (frozenDuration >= maxFreeze) {
18424
+ executeCheckout();
18425
+ } else {
18426
+ checkoutDebounceTimer = setTimeout(
18427
+ () => executeCheckout(),
18428
+ checkoutDebounce
18429
+ );
18430
+ }
18431
+ } else {
18432
+ takeFullSnapshot$1(true);
18433
+ }
18316
18434
  }
18317
18435
  } : void 0
18318
18436
  });
@@ -18321,6 +18439,7 @@ function record(options = {}) {
18321
18439
  if (!recordDOM) {
18322
18440
  return;
18323
18441
  }
18442
+ checkoutId++;
18324
18443
  wrappedEmit(
18325
18444
  {
18326
18445
  type: EventType.Meta,
@@ -18599,6 +18718,10 @@ function record(options = {}) {
18599
18718
  );
18600
18719
  }
18601
18720
  return () => {
18721
+ if (checkoutDebounceTimer) {
18722
+ clearTimeout(checkoutDebounceTimer);
18723
+ checkoutDebounceTimer = null;
18724
+ }
18602
18725
  flushCustomEventQueue$1();
18603
18726
  handlers.forEach((h) => h());
18604
18727
  processedNodeManager.destroy();