@appsurify-testmap/rrweb-record 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.
@@ -9870,35 +9870,41 @@ function initMutationObserver(options, rootEl) {
9870
9870
  function initVisibilityObserver({
9871
9871
  visibilityChangeCb,
9872
9872
  doc,
9873
- mirror: mirror2
9873
+ mirror: mirror2,
9874
+ sampling
9874
9875
  }) {
9875
9876
  if (!visibilityChangeCb) {
9876
9877
  return () => {
9877
9878
  };
9878
9879
  }
9879
9880
  const observedElements = /* @__PURE__ */ new WeakMap();
9880
- const observer = new IntersectionObserver(
9881
- (entries) => {
9882
- entries.forEach((entry) => {
9883
- const target = entry.target;
9884
- const id = mirror2.getId(target);
9885
- const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
9886
- if (id !== -1) {
9887
- if (observedElements.has(target)) {
9888
- visibilityChangeCb({
9889
- id,
9890
- isVisible,
9891
- visibilityRatio: entry.intersectionRatio,
9892
- boundingRect: entry.boundingClientRect
9893
- });
9894
- } else {
9895
- observedElements.set(target, true);
9896
- }
9897
- }
9898
- });
9899
- },
9900
- { root: null, threshold: [0.1, 0.9] }
9881
+ const debounceThreshold = typeof sampling.visibility === "number" ? sampling.visibility : 50;
9882
+ const throttledCb = throttle(
9883
+ callbackWrapper((entry) => {
9884
+ const target = entry.target;
9885
+ const id = mirror2.getId(target);
9886
+ const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
9887
+ if (id !== -1) {
9888
+ visibilityChangeCb({
9889
+ id,
9890
+ isVisible,
9891
+ visibilityRatio: entry.intersectionRatio
9892
+ });
9893
+ }
9894
+ }),
9895
+ debounceThreshold,
9896
+ { leading: sampling.visibility !== false, trailing: true }
9901
9897
  );
9898
+ const observer = new IntersectionObserver((entries) => {
9899
+ entries.forEach((entry) => {
9900
+ const target = entry.target;
9901
+ if (observedElements.has(target)) {
9902
+ throttledCb(entry);
9903
+ } else {
9904
+ observedElements.set(target, true);
9905
+ }
9906
+ });
9907
+ }, { root: null, threshold: [0.1, 0.9] });
9902
9908
  doc.querySelectorAll("*").forEach((el) => observer.observe(el));
9903
9909
  const mutationObserver = new MutationObserver((mutations) => {
9904
9910
  mutations.forEach((mutation) => {
@@ -10830,7 +10836,6 @@ function mergeHooks(o2, hooks) {
10830
10836
  };
10831
10837
  }
10832
10838
  function initObservers(o2, hooks = {}) {
10833
- console.info("initObservers", o2);
10834
10839
  const currentWindow = o2.doc.defaultView;
10835
10840
  if (!currentWindow) {
10836
10841
  return () => {
@@ -12075,7 +12080,8 @@ function record(options = {}) {
12075
12080
  incrementalSnapshotCount++;
12076
12081
  const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
12077
12082
  const exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
12078
- if (exceedCount || exceedTime) {
12083
+ const isVisibilityChanged = checkoutEveryEvc && e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.VisibilityChange;
12084
+ if (exceedCount || exceedTime || isVisibilityChanged) {
12079
12085
  takeFullSnapshot$1(true);
12080
12086
  }
12081
12087
  }
@@ -12237,11 +12243,6 @@ function record(options = {}) {
12237
12243
  mirror.getId(document)
12238
12244
  );
12239
12245
  };
12240
- const debouncedFullSnapshot = throttle(() => {
12241
- if (checkoutEveryEvc) {
12242
- takeFullSnapshot$1(true);
12243
- }
12244
- }, 100, { leading: false, trailing: true });
12245
12246
  try {
12246
12247
  const handlers = [];
12247
12248
  const observe = (doc) => {
@@ -12250,16 +12251,13 @@ function record(options = {}) {
12250
12251
  {
12251
12252
  mutationCb: wrappedMutationEmit,
12252
12253
  visibilityChangeCb: (v2) => {
12253
- debouncedFullSnapshot();
12254
- if (sampling.visibility) {
12255
- return wrappedEmit({
12256
- type: EventType.IncrementalSnapshot,
12257
- data: {
12258
- source: IncrementalSource.VisibilityChange,
12259
- ...v2
12260
- }
12261
- });
12262
- }
12254
+ wrappedEmit({
12255
+ type: EventType.IncrementalSnapshot,
12256
+ data: {
12257
+ source: IncrementalSource.VisibilityChange,
12258
+ ...v2
12259
+ }
12260
+ });
12263
12261
  },
12264
12262
  mousemoveCb: (positions, source) => wrappedEmit({
12265
12263
  type: EventType.IncrementalSnapshot,