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