@posthog/rrweb-record 0.0.32 → 0.0.34

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.
@@ -926,6 +926,7 @@ function hrefFrom(n2) {
926
926
  return n2.href;
927
927
  }
928
928
  function serializeElementNode(n2, options) {
929
+ var _a2, _b;
929
930
  const {
930
931
  doc,
931
932
  blockClass,
@@ -1099,11 +1100,13 @@ function serializeElementNode(n2, options) {
1099
1100
  }
1100
1101
  }
1101
1102
  if (needBlock) {
1102
- const { width, height } = n2.getBoundingClientRect();
1103
+ const { width, height, left, top } = n2.getBoundingClientRect();
1103
1104
  attributes = {
1104
1105
  class: attributes.class,
1105
1106
  rr_width: `${width}px`,
1106
- rr_height: `${height}px`
1107
+ rr_height: `${height}px`,
1108
+ rr_left: `${Math.floor(left + (((_a2 = doc.defaultView) == null ? void 0 : _a2.scrollX) || 0))}px`,
1109
+ rr_top: `${Math.floor(top + (((_b = doc.defaultView) == null ? void 0 : _b.scrollY) || 0))}px`
1107
1110
  };
1108
1111
  }
1109
1112
  if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
@@ -11545,6 +11548,7 @@ class IframeManager {
11545
11548
  __publicField(this, "recordCrossOriginIframes");
11546
11549
  __publicField(this, "messageHandler");
11547
11550
  __publicField(this, "nestedIframeListeners", /* @__PURE__ */ new Map());
11551
+ __publicField(this, "attachedIframes", /* @__PURE__ */ new Map());
11548
11552
  this.mutationCb = options.mutationCb;
11549
11553
  this.wrappedEmit = options.wrappedEmit;
11550
11554
  this.stylesheetManager = options.stylesheetManager;
@@ -11573,6 +11577,7 @@ class IframeManager {
11573
11577
  }
11574
11578
  attachIframe(iframeEl, childSn) {
11575
11579
  var _a2;
11580
+ this.attachedIframes.set(iframeEl, childSn);
11576
11581
  this.mutationCb({
11577
11582
  adds: [
11578
11583
  {
@@ -11628,6 +11633,7 @@ class IframeManager {
11628
11633
  const rootId = e2.data.node.id;
11629
11634
  this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
11630
11635
  this.patchRootIdOnNode(e2.data.node, rootId);
11636
+ this.attachedIframes.set(iframeEl, e2.data.node);
11631
11637
  return {
11632
11638
  timestamp: e2.timestamp,
11633
11639
  type: EventType.IncrementalSnapshot,
@@ -11770,6 +11776,32 @@ class IframeManager {
11770
11776
  });
11771
11777
  }
11772
11778
  }
11779
+ reattachIframes() {
11780
+ this.attachedIframes.forEach((content, iframe) => {
11781
+ if (!iframe.isConnected) {
11782
+ this.attachedIframes.delete(iframe);
11783
+ return;
11784
+ }
11785
+ const parentId = this.mirror.getId(iframe);
11786
+ if (parentId === -1) {
11787
+ this.attachedIframes.delete(iframe);
11788
+ return;
11789
+ }
11790
+ this.mutationCb({
11791
+ adds: [
11792
+ {
11793
+ parentId,
11794
+ nextId: null,
11795
+ node: content
11796
+ }
11797
+ ],
11798
+ removes: [],
11799
+ texts: [],
11800
+ attributes: [],
11801
+ isAttachIframe: true
11802
+ });
11803
+ });
11804
+ }
11773
11805
  destroy() {
11774
11806
  if (this.recordCrossOriginIframes) {
11775
11807
  window.removeEventListener("message", this.messageHandler);
@@ -11780,6 +11812,7 @@ class IframeManager {
11780
11812
  this.nestedIframeListeners.clear();
11781
11813
  this.crossOriginIframeMirror.reset();
11782
11814
  this.crossOriginIframeStyleMirror.reset();
11815
+ this.attachedIframes.clear();
11783
11816
  }
11784
11817
  }
11785
11818
  class ShadowDomManager {
@@ -12855,6 +12888,9 @@ function record(options = {}) {
12855
12888
  isCheckout
12856
12889
  );
12857
12890
  mutationBuffers.forEach((buf) => buf.unlock());
12891
+ if (recordCrossOriginIframes) {
12892
+ iframeManager.reattachIframes();
12893
+ }
12858
12894
  if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0)
12859
12895
  stylesheetManager.adoptStyleSheets(
12860
12896
  document.adoptedStyleSheets,