@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.
@@ -881,6 +881,7 @@ function hrefFrom(n2) {
881
881
  return n2.href;
882
882
  }
883
883
  function serializeElementNode(n2, options) {
884
+ var _a2, _b;
884
885
  const {
885
886
  doc,
886
887
  blockClass,
@@ -1054,11 +1055,13 @@ function serializeElementNode(n2, options) {
1054
1055
  }
1055
1056
  }
1056
1057
  if (needBlock) {
1057
- const { width, height } = n2.getBoundingClientRect();
1058
+ const { width, height, left, top } = n2.getBoundingClientRect();
1058
1059
  attributes = {
1059
1060
  class: attributes.class,
1060
1061
  rr_width: `${width}px`,
1061
- rr_height: `${height}px`
1062
+ rr_height: `${height}px`,
1063
+ rr_left: `${Math.floor(left + (((_a2 = doc.defaultView) == null ? void 0 : _a2.scrollX) || 0))}px`,
1064
+ rr_top: `${Math.floor(top + (((_b = doc.defaultView) == null ? void 0 : _b.scrollY) || 0))}px`
1062
1065
  };
1063
1066
  }
1064
1067
  if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
@@ -11503,6 +11506,7 @@ class IframeManager {
11503
11506
  __publicField(this, "recordCrossOriginIframes");
11504
11507
  __publicField(this, "messageHandler");
11505
11508
  __publicField(this, "nestedIframeListeners", /* @__PURE__ */ new Map());
11509
+ __publicField(this, "attachedIframes", /* @__PURE__ */ new Map());
11506
11510
  this.mutationCb = options.mutationCb;
11507
11511
  this.wrappedEmit = options.wrappedEmit;
11508
11512
  this.stylesheetManager = options.stylesheetManager;
@@ -11531,6 +11535,7 @@ class IframeManager {
11531
11535
  }
11532
11536
  attachIframe(iframeEl, childSn) {
11533
11537
  var _a2;
11538
+ this.attachedIframes.set(iframeEl, childSn);
11534
11539
  this.mutationCb({
11535
11540
  adds: [
11536
11541
  {
@@ -11586,6 +11591,7 @@ class IframeManager {
11586
11591
  const rootId = e2.data.node.id;
11587
11592
  this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
11588
11593
  this.patchRootIdOnNode(e2.data.node, rootId);
11594
+ this.attachedIframes.set(iframeEl, e2.data.node);
11589
11595
  return {
11590
11596
  timestamp: e2.timestamp,
11591
11597
  type: EventType.IncrementalSnapshot,
@@ -11728,6 +11734,32 @@ class IframeManager {
11728
11734
  });
11729
11735
  }
11730
11736
  }
11737
+ reattachIframes() {
11738
+ this.attachedIframes.forEach((content, iframe) => {
11739
+ if (!iframe.isConnected) {
11740
+ this.attachedIframes.delete(iframe);
11741
+ return;
11742
+ }
11743
+ const parentId = this.mirror.getId(iframe);
11744
+ if (parentId === -1) {
11745
+ this.attachedIframes.delete(iframe);
11746
+ return;
11747
+ }
11748
+ this.mutationCb({
11749
+ adds: [
11750
+ {
11751
+ parentId,
11752
+ nextId: null,
11753
+ node: content
11754
+ }
11755
+ ],
11756
+ removes: [],
11757
+ texts: [],
11758
+ attributes: [],
11759
+ isAttachIframe: true
11760
+ });
11761
+ });
11762
+ }
11731
11763
  destroy() {
11732
11764
  if (this.recordCrossOriginIframes) {
11733
11765
  window.removeEventListener("message", this.messageHandler);
@@ -11738,6 +11770,7 @@ class IframeManager {
11738
11770
  this.nestedIframeListeners.clear();
11739
11771
  this.crossOriginIframeMirror.reset();
11740
11772
  this.crossOriginIframeStyleMirror.reset();
11773
+ this.attachedIframes.clear();
11741
11774
  }
11742
11775
  }
11743
11776
  class ShadowDomManager {
@@ -12820,6 +12853,9 @@ function record(options = {}) {
12820
12853
  isCheckout
12821
12854
  );
12822
12855
  mutationBuffers.forEach((buf) => buf.unlock());
12856
+ if (recordCrossOriginIframes) {
12857
+ iframeManager.reattachIframes();
12858
+ }
12823
12859
  if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0)
12824
12860
  stylesheetManager.adoptStyleSheets(
12825
12861
  document.adoptedStyleSheets,