@posthog/rrweb 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.
@@ -938,6 +938,7 @@ function hrefFrom(n2) {
938
938
  return n2.href;
939
939
  }
940
940
  function serializeElementNode(n2, options) {
941
+ var _a2, _b;
941
942
  const {
942
943
  doc,
943
944
  blockClass,
@@ -1111,11 +1112,13 @@ function serializeElementNode(n2, options) {
1111
1112
  }
1112
1113
  }
1113
1114
  if (needBlock) {
1114
- const { width, height } = n2.getBoundingClientRect();
1115
+ const { width, height, left, top } = n2.getBoundingClientRect();
1115
1116
  attributes = {
1116
1117
  class: attributes.class,
1117
1118
  rr_width: `${width}px`,
1118
- rr_height: `${height}px`
1119
+ rr_height: `${height}px`,
1120
+ rr_left: `${Math.floor(left + (((_a2 = doc.defaultView) == null ? void 0 : _a2.scrollX) || 0))}px`,
1121
+ rr_top: `${Math.floor(top + (((_b = doc.defaultView) == null ? void 0 : _b.scrollY) || 0))}px`
1119
1122
  };
1120
1123
  }
1121
1124
  if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
@@ -5617,6 +5620,12 @@ function buildNode(n2, options) {
5617
5620
  node2.style.setProperty("width", value.toString());
5618
5621
  } else if (name === "rr_height") {
5619
5622
  node2.style.setProperty("height", value.toString());
5623
+ } else if (name === "rr_left") {
5624
+ node2.style.setProperty("left", value.toString());
5625
+ node2.style.setProperty("position", "absolute");
5626
+ } else if (name === "rr_top") {
5627
+ node2.style.setProperty("top", value.toString());
5628
+ node2.style.setProperty("position", "absolute");
5620
5629
  } else if (name === "rr_mediaCurrentTime" && typeof value === "number") {
5621
5630
  node2.currentTime = value;
5622
5631
  } else if (name === "rr_mediaState") {
@@ -13400,6 +13409,7 @@ class IframeManager {
13400
13409
  __publicField(this, "recordCrossOriginIframes");
13401
13410
  __publicField(this, "messageHandler");
13402
13411
  __publicField(this, "nestedIframeListeners", /* @__PURE__ */ new Map());
13412
+ __publicField(this, "attachedIframes", /* @__PURE__ */ new Map());
13403
13413
  this.mutationCb = options.mutationCb;
13404
13414
  this.wrappedEmit = options.wrappedEmit;
13405
13415
  this.stylesheetManager = options.stylesheetManager;
@@ -13428,6 +13438,7 @@ class IframeManager {
13428
13438
  }
13429
13439
  attachIframe(iframeEl, childSn) {
13430
13440
  var _a2;
13441
+ this.attachedIframes.set(iframeEl, childSn);
13431
13442
  this.mutationCb({
13432
13443
  adds: [
13433
13444
  {
@@ -13483,6 +13494,7 @@ class IframeManager {
13483
13494
  const rootId = e2.data.node.id;
13484
13495
  this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
13485
13496
  this.patchRootIdOnNode(e2.data.node, rootId);
13497
+ this.attachedIframes.set(iframeEl, e2.data.node);
13486
13498
  return {
13487
13499
  timestamp: e2.timestamp,
13488
13500
  type: EventType.IncrementalSnapshot,
@@ -13625,6 +13637,32 @@ class IframeManager {
13625
13637
  });
13626
13638
  }
13627
13639
  }
13640
+ reattachIframes() {
13641
+ this.attachedIframes.forEach((content, iframe) => {
13642
+ if (!iframe.isConnected) {
13643
+ this.attachedIframes.delete(iframe);
13644
+ return;
13645
+ }
13646
+ const parentId = this.mirror.getId(iframe);
13647
+ if (parentId === -1) {
13648
+ this.attachedIframes.delete(iframe);
13649
+ return;
13650
+ }
13651
+ this.mutationCb({
13652
+ adds: [
13653
+ {
13654
+ parentId,
13655
+ nextId: null,
13656
+ node: content
13657
+ }
13658
+ ],
13659
+ removes: [],
13660
+ texts: [],
13661
+ attributes: [],
13662
+ isAttachIframe: true
13663
+ });
13664
+ });
13665
+ }
13628
13666
  destroy() {
13629
13667
  if (this.recordCrossOriginIframes) {
13630
13668
  window.removeEventListener("message", this.messageHandler);
@@ -13635,6 +13673,7 @@ class IframeManager {
13635
13673
  this.nestedIframeListeners.clear();
13636
13674
  this.crossOriginIframeMirror.reset();
13637
13675
  this.crossOriginIframeStyleMirror.reset();
13676
+ this.attachedIframes.clear();
13638
13677
  }
13639
13678
  }
13640
13679
  class ShadowDomManager {
@@ -14730,6 +14769,9 @@ function record(options = {}) {
14730
14769
  isCheckout
14731
14770
  );
14732
14771
  mutationBuffers.forEach((buf) => buf.unlock());
14772
+ if (recordCrossOriginIframes) {
14773
+ iframeManager.reattachIframes();
14774
+ }
14733
14775
  if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0)
14734
14776
  stylesheetManager.adoptStyleSheets(
14735
14777
  document.adoptedStyleSheets,