@appsurify-testmap/rrweb 2.0.0-alpha.24 → 2.0.0-alpha.25

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
@@ -11745,35 +11745,41 @@ function initMutationObserver(options, rootEl) {
11745
11745
  function initVisibilityObserver({
11746
11746
  visibilityChangeCb,
11747
11747
  doc,
11748
- mirror: mirror2
11748
+ mirror: mirror2,
11749
+ sampling
11749
11750
  }) {
11750
11751
  if (!visibilityChangeCb) {
11751
11752
  return () => {
11752
11753
  };
11753
11754
  }
11754
11755
  const observedElements = /* @__PURE__ */ new WeakMap();
11755
- const observer = new IntersectionObserver(
11756
- (entries) => {
11757
- entries.forEach((entry) => {
11758
- const target = entry.target;
11759
- const id = mirror2.getId(target);
11760
- const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
11761
- if (id !== -1) {
11762
- if (observedElements.has(target)) {
11763
- visibilityChangeCb({
11764
- id,
11765
- isVisible,
11766
- visibilityRatio: entry.intersectionRatio,
11767
- boundingRect: entry.boundingClientRect
11768
- });
11769
- } else {
11770
- observedElements.set(target, true);
11771
- }
11772
- }
11773
- });
11774
- },
11775
- { root: null, threshold: [0.1, 0.9] }
11756
+ const debounceThreshold = typeof sampling.visibility === "number" ? sampling.visibility : 50;
11757
+ const throttledCb = throttle(
11758
+ callbackWrapper((entry) => {
11759
+ const target = entry.target;
11760
+ const id = mirror2.getId(target);
11761
+ const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
11762
+ if (id !== -1) {
11763
+ visibilityChangeCb({
11764
+ id,
11765
+ isVisible,
11766
+ visibilityRatio: entry.intersectionRatio
11767
+ });
11768
+ }
11769
+ }),
11770
+ debounceThreshold,
11771
+ { leading: sampling.visibility !== false, trailing: true }
11776
11772
  );
11773
+ const observer = new IntersectionObserver((entries) => {
11774
+ entries.forEach((entry) => {
11775
+ const target = entry.target;
11776
+ if (observedElements.has(target)) {
11777
+ throttledCb(entry);
11778
+ } else {
11779
+ observedElements.set(target, true);
11780
+ }
11781
+ });
11782
+ }, { root: null, threshold: [0.1, 0.9] });
11777
11783
  doc.querySelectorAll("*").forEach((el) => observer.observe(el));
11778
11784
  const mutationObserver = new MutationObserver((mutations) => {
11779
11785
  mutations.forEach((mutation) => {
@@ -12705,7 +12711,6 @@ function mergeHooks(o2, hooks) {
12705
12711
  };
12706
12712
  }
12707
12713
  function initObservers(o2, hooks = {}) {
12708
- console.info("initObservers", o2);
12709
12714
  const currentWindow = o2.doc.defaultView;
12710
12715
  if (!currentWindow) {
12711
12716
  return () => {
@@ -13970,7 +13975,8 @@ function record(options = {}) {
13970
13975
  incrementalSnapshotCount++;
13971
13976
  const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
13972
13977
  const exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
13973
- if (exceedCount || exceedTime) {
13978
+ const isVisibilityChanged = checkoutEveryEvc && e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.VisibilityChange;
13979
+ if (exceedCount || exceedTime || isVisibilityChanged) {
13974
13980
  takeFullSnapshot$1(true);
13975
13981
  }
13976
13982
  }
@@ -14132,11 +14138,6 @@ function record(options = {}) {
14132
14138
  mirror.getId(document)
14133
14139
  );
14134
14140
  };
14135
- const debouncedFullSnapshot = throttle(() => {
14136
- if (checkoutEveryEvc) {
14137
- takeFullSnapshot$1(true);
14138
- }
14139
- }, 100, { leading: false, trailing: true });
14140
14141
  try {
14141
14142
  const handlers = [];
14142
14143
  const observe = (doc) => {
@@ -14145,16 +14146,13 @@ function record(options = {}) {
14145
14146
  {
14146
14147
  mutationCb: wrappedMutationEmit,
14147
14148
  visibilityChangeCb: (v2) => {
14148
- debouncedFullSnapshot();
14149
- if (sampling.visibility) {
14150
- return wrappedEmit({
14151
- type: EventType.IncrementalSnapshot,
14152
- data: {
14153
- source: IncrementalSource.VisibilityChange,
14154
- ...v2
14155
- }
14156
- });
14157
- }
14149
+ wrappedEmit({
14150
+ type: EventType.IncrementalSnapshot,
14151
+ data: {
14152
+ source: IncrementalSource.VisibilityChange,
14153
+ ...v2
14154
+ }
14155
+ });
14158
14156
  },
14159
14157
  mousemoveCb: (positions, source) => wrappedEmit({
14160
14158
  type: EventType.IncrementalSnapshot,