@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.
package/dist/rrweb.cjs CHANGED
@@ -893,6 +893,7 @@ function hrefFrom(n2) {
893
893
  return n2.href;
894
894
  }
895
895
  function serializeElementNode(n2, options) {
896
+ var _a2, _b;
896
897
  const {
897
898
  doc,
898
899
  blockClass,
@@ -1066,11 +1067,13 @@ function serializeElementNode(n2, options) {
1066
1067
  }
1067
1068
  }
1068
1069
  if (needBlock) {
1069
- const { width, height } = n2.getBoundingClientRect();
1070
+ const { width, height, left, top } = n2.getBoundingClientRect();
1070
1071
  attributes = {
1071
1072
  class: attributes.class,
1072
1073
  rr_width: `${width}px`,
1073
- rr_height: `${height}px`
1074
+ rr_height: `${height}px`,
1075
+ rr_left: `${Math.floor(left + (((_a2 = doc.defaultView) == null ? void 0 : _a2.scrollX) || 0))}px`,
1076
+ rr_top: `${Math.floor(top + (((_b = doc.defaultView) == null ? void 0 : _b.scrollY) || 0))}px`
1074
1077
  };
1075
1078
  }
1076
1079
  if (tagName === "iframe" && !keepIframeSrcFn(attributes.src)) {
@@ -5573,6 +5576,12 @@ function buildNode(n2, options) {
5573
5576
  node2.style.setProperty("width", value.toString());
5574
5577
  } else if (name === "rr_height") {
5575
5578
  node2.style.setProperty("height", value.toString());
5579
+ } else if (name === "rr_left") {
5580
+ node2.style.setProperty("left", value.toString());
5581
+ node2.style.setProperty("position", "absolute");
5582
+ } else if (name === "rr_top") {
5583
+ node2.style.setProperty("top", value.toString());
5584
+ node2.style.setProperty("position", "absolute");
5576
5585
  } else if (name === "rr_mediaCurrentTime" && typeof value === "number") {
5577
5586
  node2.currentTime = value;
5578
5587
  } else if (name === "rr_mediaState") {
@@ -13379,6 +13388,7 @@ class IframeManager {
13379
13388
  __publicField(this, "messageHandler");
13380
13389
  // Map window to handler for cleanup - windows are browser-owned and won't prevent GC
13381
13390
  __publicField(this, "nestedIframeListeners", /* @__PURE__ */ new Map());
13391
+ __publicField(this, "attachedIframes", /* @__PURE__ */ new Map());
13382
13392
  this.mutationCb = options.mutationCb;
13383
13393
  this.wrappedEmit = options.wrappedEmit;
13384
13394
  this.stylesheetManager = options.stylesheetManager;
@@ -13407,6 +13417,7 @@ class IframeManager {
13407
13417
  }
13408
13418
  attachIframe(iframeEl, childSn) {
13409
13419
  var _a2;
13420
+ this.attachedIframes.set(iframeEl, childSn);
13410
13421
  this.mutationCb({
13411
13422
  adds: [
13412
13423
  {
@@ -13462,6 +13473,7 @@ class IframeManager {
13462
13473
  const rootId = e2.data.node.id;
13463
13474
  this.crossOriginIframeRootIdMap.set(iframeEl, rootId);
13464
13475
  this.patchRootIdOnNode(e2.data.node, rootId);
13476
+ this.attachedIframes.set(iframeEl, e2.data.node);
13465
13477
  return {
13466
13478
  timestamp: e2.timestamp,
13467
13479
  type: EventType.IncrementalSnapshot,
@@ -13604,6 +13616,32 @@ class IframeManager {
13604
13616
  });
13605
13617
  }
13606
13618
  }
13619
+ reattachIframes() {
13620
+ this.attachedIframes.forEach((content, iframe) => {
13621
+ if (!iframe.isConnected) {
13622
+ this.attachedIframes.delete(iframe);
13623
+ return;
13624
+ }
13625
+ const parentId = this.mirror.getId(iframe);
13626
+ if (parentId === -1) {
13627
+ this.attachedIframes.delete(iframe);
13628
+ return;
13629
+ }
13630
+ this.mutationCb({
13631
+ adds: [
13632
+ {
13633
+ parentId,
13634
+ nextId: null,
13635
+ node: content
13636
+ }
13637
+ ],
13638
+ removes: [],
13639
+ texts: [],
13640
+ attributes: [],
13641
+ isAttachIframe: true
13642
+ });
13643
+ });
13644
+ }
13607
13645
  destroy() {
13608
13646
  if (this.recordCrossOriginIframes) {
13609
13647
  window.removeEventListener("message", this.messageHandler);
@@ -13614,6 +13652,7 @@ class IframeManager {
13614
13652
  this.nestedIframeListeners.clear();
13615
13653
  this.crossOriginIframeMirror.reset();
13616
13654
  this.crossOriginIframeStyleMirror.reset();
13655
+ this.attachedIframes.clear();
13617
13656
  }
13618
13657
  }
13619
13658
  class ShadowDomManager {
@@ -14716,6 +14755,9 @@ function record(options = {}) {
14716
14755
  isCheckout
14717
14756
  );
14718
14757
  mutationBuffers.forEach((buf) => buf.unlock());
14758
+ if (recordCrossOriginIframes) {
14759
+ iframeManager.reattachIframes();
14760
+ }
14719
14761
  if (document.adoptedStyleSheets && document.adoptedStyleSheets.length > 0)
14720
14762
  stylesheetManager.adoptStyleSheets(
14721
14763
  document.adoptedStyleSheets,