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