@appsurify-testmap/rrweb-all 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.
@@ -11727,35 +11727,41 @@ function initMutationObserver(options, rootEl) {
11727
11727
  function initVisibilityObserver({
11728
11728
  visibilityChangeCb,
11729
11729
  doc,
11730
- mirror: mirror2
11730
+ mirror: mirror2,
11731
+ sampling
11731
11732
  }) {
11732
11733
  if (!visibilityChangeCb) {
11733
11734
  return () => {
11734
11735
  };
11735
11736
  }
11736
11737
  const observedElements = /* @__PURE__ */ new WeakMap();
11737
- const observer = new IntersectionObserver(
11738
- (entries) => {
11739
- entries.forEach((entry) => {
11740
- const target = entry.target;
11741
- const id = mirror2.getId(target);
11742
- const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
11743
- if (id !== -1) {
11744
- if (observedElements.has(target)) {
11745
- visibilityChangeCb({
11746
- id,
11747
- isVisible,
11748
- visibilityRatio: entry.intersectionRatio,
11749
- boundingRect: entry.boundingClientRect
11750
- });
11751
- } else {
11752
- observedElements.set(target, true);
11753
- }
11754
- }
11755
- });
11756
- },
11757
- { root: null, threshold: [0.1, 0.9] }
11738
+ const debounceThreshold = typeof sampling.visibility === "number" ? sampling.visibility : 50;
11739
+ const throttledCb = throttle(
11740
+ callbackWrapper((entry) => {
11741
+ const target = entry.target;
11742
+ const id = mirror2.getId(target);
11743
+ const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
11744
+ if (id !== -1) {
11745
+ visibilityChangeCb({
11746
+ id,
11747
+ isVisible,
11748
+ visibilityRatio: entry.intersectionRatio
11749
+ });
11750
+ }
11751
+ }),
11752
+ debounceThreshold,
11753
+ { leading: sampling.visibility !== false, trailing: true }
11758
11754
  );
11755
+ const observer = new IntersectionObserver((entries) => {
11756
+ entries.forEach((entry) => {
11757
+ const target = entry.target;
11758
+ if (observedElements.has(target)) {
11759
+ throttledCb(entry);
11760
+ } else {
11761
+ observedElements.set(target, true);
11762
+ }
11763
+ });
11764
+ }, { root: null, threshold: [0.1, 0.9] });
11759
11765
  doc.querySelectorAll("*").forEach((el) => observer.observe(el));
11760
11766
  const mutationObserver = new MutationObserver((mutations) => {
11761
11767
  mutations.forEach((mutation) => {
@@ -12687,7 +12693,6 @@ function mergeHooks(o2, hooks) {
12687
12693
  };
12688
12694
  }
12689
12695
  function initObservers(o2, hooks = {}) {
12690
- console.info("initObservers", o2);
12691
12696
  const currentWindow = o2.doc.defaultView;
12692
12697
  if (!currentWindow) {
12693
12698
  return () => {
@@ -13952,7 +13957,8 @@ function record(options = {}) {
13952
13957
  incrementalSnapshotCount++;
13953
13958
  const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
13954
13959
  const exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
13955
- if (exceedCount || exceedTime) {
13960
+ const isVisibilityChanged = checkoutEveryEvc && e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.VisibilityChange;
13961
+ if (exceedCount || exceedTime || isVisibilityChanged) {
13956
13962
  takeFullSnapshot$1(true);
13957
13963
  }
13958
13964
  }
@@ -14114,11 +14120,6 @@ function record(options = {}) {
14114
14120
  mirror.getId(document)
14115
14121
  );
14116
14122
  };
14117
- const debouncedFullSnapshot = throttle(() => {
14118
- if (checkoutEveryEvc) {
14119
- takeFullSnapshot$1(true);
14120
- }
14121
- }, 100, { leading: false, trailing: true });
14122
14123
  try {
14123
14124
  const handlers = [];
14124
14125
  const observe = (doc) => {
@@ -14127,16 +14128,13 @@ function record(options = {}) {
14127
14128
  {
14128
14129
  mutationCb: wrappedMutationEmit,
14129
14130
  visibilityChangeCb: (v2) => {
14130
- debouncedFullSnapshot();
14131
- if (sampling.visibility) {
14132
- return wrappedEmit({
14133
- type: EventType.IncrementalSnapshot,
14134
- data: {
14135
- source: IncrementalSource.VisibilityChange,
14136
- ...v2
14137
- }
14138
- });
14139
- }
14131
+ wrappedEmit({
14132
+ type: EventType.IncrementalSnapshot,
14133
+ data: {
14134
+ source: IncrementalSource.VisibilityChange,
14135
+ ...v2
14136
+ }
14137
+ });
14140
14138
  },
14141
14139
  mousemoveCb: (positions, source) => wrappedEmit({
14142
14140
  type: EventType.IncrementalSnapshot,