@appsurify-testmap/rrweb-record 2.0.0-alpha.24 → 2.0.0-alpha.30

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.
@@ -9924,35 +9924,41 @@ function initMutationObserver(options, rootEl) {
9924
9924
  function initVisibilityObserver({
9925
9925
  visibilityChangeCb,
9926
9926
  doc,
9927
- mirror: mirror2
9927
+ mirror: mirror2,
9928
+ sampling
9928
9929
  }) {
9929
9930
  if (!visibilityChangeCb) {
9930
9931
  return () => {
9931
9932
  };
9932
9933
  }
9933
9934
  const observedElements = /* @__PURE__ */ new WeakMap();
9934
- const observer = new IntersectionObserver(
9935
- (entries) => {
9936
- entries.forEach((entry) => {
9937
- const target = entry.target;
9938
- const id = mirror2.getId(target);
9939
- const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
9940
- if (id !== -1) {
9941
- if (observedElements.has(target)) {
9942
- visibilityChangeCb({
9943
- id,
9944
- isVisible,
9945
- visibilityRatio: entry.intersectionRatio,
9946
- boundingRect: entry.boundingClientRect
9947
- });
9948
- } else {
9949
- observedElements.set(target, true);
9950
- }
9951
- }
9952
- });
9953
- },
9954
- { root: null, threshold: [0.1, 0.9] }
9935
+ const debounceThreshold = typeof sampling.visibility === "number" ? sampling.visibility : 50;
9936
+ const throttledCb = throttle(
9937
+ callbackWrapper((entry) => {
9938
+ const target = entry.target;
9939
+ const id = mirror2.getId(target);
9940
+ const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
9941
+ if (id !== -1) {
9942
+ visibilityChangeCb({
9943
+ id,
9944
+ isVisible,
9945
+ visibilityRatio: entry.intersectionRatio
9946
+ });
9947
+ }
9948
+ }),
9949
+ debounceThreshold,
9950
+ { leading: sampling.visibility !== false, trailing: true }
9955
9951
  );
9952
+ const observer = new IntersectionObserver((entries) => {
9953
+ entries.forEach((entry) => {
9954
+ const target = entry.target;
9955
+ if (observedElements.has(target)) {
9956
+ throttledCb(entry);
9957
+ } else {
9958
+ observedElements.set(target, true);
9959
+ }
9960
+ });
9961
+ }, { root: null, threshold: [0.1, 0.9] });
9956
9962
  doc.querySelectorAll("*").forEach((el) => observer.observe(el));
9957
9963
  const mutationObserver = new MutationObserver((mutations) => {
9958
9964
  mutations.forEach((mutation) => {
@@ -10882,7 +10888,6 @@ function mergeHooks(o2, hooks) {
10882
10888
  };
10883
10889
  }
10884
10890
  function initObservers(o2, hooks = {}) {
10885
- console.info("initObservers", o2);
10886
10891
  const currentWindow = o2.doc.defaultView;
10887
10892
  if (!currentWindow) {
10888
10893
  return () => {
@@ -12125,7 +12130,8 @@ function record(options = {}) {
12125
12130
  incrementalSnapshotCount++;
12126
12131
  const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
12127
12132
  const exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
12128
- if (exceedCount || exceedTime) {
12133
+ const isVisibilityChanged = checkoutEveryEvc && e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.VisibilityChange;
12134
+ if (exceedCount || exceedTime || isVisibilityChanged) {
12129
12135
  takeFullSnapshot$1(true);
12130
12136
  }
12131
12137
  }
@@ -12283,11 +12289,6 @@ function record(options = {}) {
12283
12289
  mirror.getId(document)
12284
12290
  );
12285
12291
  };
12286
- const debouncedFullSnapshot = throttle(() => {
12287
- if (checkoutEveryEvc) {
12288
- takeFullSnapshot$1(true);
12289
- }
12290
- }, 100, { leading: false, trailing: true });
12291
12292
  try {
12292
12293
  const handlers = [];
12293
12294
  const observe = (doc) => {
@@ -12296,15 +12297,12 @@ function record(options = {}) {
12296
12297
  {
12297
12298
  mutationCb: wrappedMutationEmit,
12298
12299
  visibilityChangeCb: (v2) => {
12299
- debouncedFullSnapshot();
12300
- if (sampling.visibility) {
12301
- return wrappedEmit({
12302
- type: EventType.IncrementalSnapshot,
12303
- data: __spreadValues({
12304
- source: IncrementalSource.VisibilityChange
12305
- }, v2)
12306
- });
12307
- }
12300
+ wrappedEmit({
12301
+ type: EventType.IncrementalSnapshot,
12302
+ data: __spreadValues({
12303
+ source: IncrementalSource.VisibilityChange
12304
+ }, v2)
12305
+ });
12308
12306
  },
12309
12307
  mousemoveCb: (positions, source) => wrappedEmit({
12310
12308
  type: EventType.IncrementalSnapshot,