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