@posthog/rrweb 0.0.30 → 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)) {
@@ -1523,8 +1526,8 @@ function getAugmentedNamespace$1(n2) {
1523
1526
  if (n2.__esModule) return n2;
1524
1527
  var f2 = n2.default;
1525
1528
  if (typeof f2 == "function") {
1526
- var a2 = function a22() {
1527
- if (this instanceof a22) {
1529
+ var a2 = function a3() {
1530
+ if (this instanceof a3) {
1528
1531
  return Reflect.construct(f2, arguments, this.constructor);
1529
1532
  }
1530
1533
  return f2.apply(this, arguments);
@@ -1533,8 +1536,8 @@ function getAugmentedNamespace$1(n2) {
1533
1536
  } else a2 = {};
1534
1537
  Object.defineProperty(a2, "__esModule", { value: true });
1535
1538
  Object.keys(n2).forEach(function(k) {
1536
- var d = Object.getOwnPropertyDescriptor(n2, k);
1537
- Object.defineProperty(a2, k, d.get ? d : {
1539
+ var d2 = Object.getOwnPropertyDescriptor(n2, k);
1540
+ Object.defineProperty(a2, k, d2.get ? d2 : {
1538
1541
  enumerable: true,
1539
1542
  get: function() {
1540
1543
  return n2[k];
@@ -1910,8 +1913,8 @@ function requireStringifier$1() {
1910
1913
  if (root2.raws.indent) return root2.raws.indent;
1911
1914
  let value;
1912
1915
  root2.walk((i2) => {
1913
- let p = i2.parent;
1914
- if (p && p !== root2 && p.parent && p.parent === root2) {
1916
+ let p2 = i2.parent;
1917
+ if (p2 && p2 !== root2 && p2.parent && p2.parent === root2) {
1915
1918
  if (typeof i2.raws.before !== "undefined") {
1916
1919
  let parts = i2.raws.before.split("\n");
1917
1920
  value = parts[parts.length - 1];
@@ -2009,7 +2012,7 @@ function requireNode$1() {
2009
2012
  } else if (i2 === "source") {
2010
2013
  cloned[i2] = value;
2011
2014
  } else if (Array.isArray(value)) {
2012
- cloned[i2] = value.map((j) => cloneNode(j, cloned));
2015
+ cloned[i2] = value.map((j2) => cloneNode(j2, cloned));
2013
2016
  } else {
2014
2017
  if (type === "object" && value !== null) value = cloneNode(value);
2015
2018
  cloned[i2] = value;
@@ -2795,10 +2798,10 @@ function requireAtRule$1() {
2795
2798
  Container.registerAtRule(AtRule);
2796
2799
  return atRule$1;
2797
2800
  }
2798
- var document$1$1;
2801
+ var document$2;
2799
2802
  var hasRequiredDocument$1;
2800
2803
  function requireDocument$1() {
2801
- if (hasRequiredDocument$1) return document$1$1;
2804
+ if (hasRequiredDocument$1) return document$2;
2802
2805
  hasRequiredDocument$1 = 1;
2803
2806
  let Container = requireContainer$1();
2804
2807
  let LazyResult, Processor;
@@ -2820,9 +2823,9 @@ function requireDocument$1() {
2820
2823
  Document2.registerProcessor = (dependant) => {
2821
2824
  Processor = dependant;
2822
2825
  };
2823
- document$1$1 = Document2;
2826
+ document$2 = Document2;
2824
2827
  Document2.default = Document2;
2825
- return document$1$1;
2828
+ return document$2;
2826
2829
  }
2827
2830
  var nonSecure$1;
2828
2831
  var hasRequiredNonSecure$1;
@@ -3524,9 +3527,9 @@ function requireMapGenerator$1() {
3524
3527
  column += str.length;
3525
3528
  }
3526
3529
  if (node2 && type !== "start") {
3527
- let p = node2.parent || { raws: {} };
3530
+ let p2 = node2.parent || { raws: {} };
3528
3531
  let childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
3529
- if (!childless || node2 !== p.last || p.raws.semicolon) {
3532
+ if (!childless || node2 !== p2.last || p2.raws.semicolon) {
3530
3533
  if (node2.source && node2.source.end) {
3531
3534
  mapping.source = this.sourcePath(node2);
3532
3535
  mapping.original.line = node2.source.end.line;
@@ -4019,8 +4022,8 @@ function requireParser$1() {
4019
4022
  if (colon === false) return;
4020
4023
  let founded = 0;
4021
4024
  let token;
4022
- for (let j = colon - 1; j >= 0; j--) {
4023
- token = tokens[j];
4025
+ for (let j2 = colon - 1; j2 >= 0; j2--) {
4026
+ token = tokens[j2];
4024
4027
  if (token[0] !== "space") {
4025
4028
  founded += 1;
4026
4029
  if (founded === 2) break;
@@ -4138,8 +4141,8 @@ function requireParser$1() {
4138
4141
  } else if (token[1].toLowerCase() === "important") {
4139
4142
  let cache = tokens.slice(0);
4140
4143
  let str = "";
4141
- for (let j = i2; j > 0; j--) {
4142
- let type = cache[j][0];
4144
+ for (let j2 = i2; j2 > 0; j2--) {
4145
+ let type = cache[j2][0];
4143
4146
  if (str.trim().startsWith("!") && type !== "space") {
4144
4147
  break;
4145
4148
  }
@@ -4727,8 +4730,8 @@ function requireLazyResult$1() {
4727
4730
  let pluginVer = plugin.postcssVersion;
4728
4731
  let runtimeVer = this.result.processor.version;
4729
4732
  let a2 = pluginVer.split(".");
4730
- let b = runtimeVer.split(".");
4731
- if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
4733
+ let b2 = runtimeVer.split(".");
4734
+ if (a2[0] !== b2[0] || parseInt(a2[1]) > parseInt(b2[1])) {
4732
4735
  console.error(
4733
4736
  "Unknown error from PostCSS plugin. Your current PostCSS version is " + runtimeVer + ", but " + pluginName + " uses " + pluginVer + ". Perhaps this is the source of the error below."
4734
4737
  );
@@ -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") {
@@ -5879,8 +5888,8 @@ function getAugmentedNamespace(n2) {
5879
5888
  if (n2.__esModule) return n2;
5880
5889
  var f2 = n2.default;
5881
5890
  if (typeof f2 == "function") {
5882
- var a2 = function a22() {
5883
- if (this instanceof a22) {
5891
+ var a2 = function a3() {
5892
+ if (this instanceof a3) {
5884
5893
  return Reflect.construct(f2, arguments, this.constructor);
5885
5894
  }
5886
5895
  return f2.apply(this, arguments);
@@ -5889,8 +5898,8 @@ function getAugmentedNamespace(n2) {
5889
5898
  } else a2 = {};
5890
5899
  Object.defineProperty(a2, "__esModule", { value: true });
5891
5900
  Object.keys(n2).forEach(function(k) {
5892
- var d = Object.getOwnPropertyDescriptor(n2, k);
5893
- Object.defineProperty(a2, k, d.get ? d : {
5901
+ var d2 = Object.getOwnPropertyDescriptor(n2, k);
5902
+ Object.defineProperty(a2, k, d2.get ? d2 : {
5894
5903
  enumerable: true,
5895
5904
  get: function() {
5896
5905
  return n2[k];
@@ -6266,8 +6275,8 @@ function requireStringifier() {
6266
6275
  if (root2.raws.indent) return root2.raws.indent;
6267
6276
  let value;
6268
6277
  root2.walk((i2) => {
6269
- let p = i2.parent;
6270
- if (p && p !== root2 && p.parent && p.parent === root2) {
6278
+ let p2 = i2.parent;
6279
+ if (p2 && p2 !== root2 && p2.parent && p2.parent === root2) {
6271
6280
  if (typeof i2.raws.before !== "undefined") {
6272
6281
  let parts = i2.raws.before.split("\n");
6273
6282
  value = parts[parts.length - 1];
@@ -6365,7 +6374,7 @@ function requireNode() {
6365
6374
  } else if (i2 === "source") {
6366
6375
  cloned[i2] = value;
6367
6376
  } else if (Array.isArray(value)) {
6368
- cloned[i2] = value.map((j) => cloneNode(j, cloned));
6377
+ cloned[i2] = value.map((j2) => cloneNode(j2, cloned));
6369
6378
  } else {
6370
6379
  if (type === "object" && value !== null) value = cloneNode(value);
6371
6380
  cloned[i2] = value;
@@ -7880,9 +7889,9 @@ function requireMapGenerator() {
7880
7889
  column += str.length;
7881
7890
  }
7882
7891
  if (node2 && type !== "start") {
7883
- let p = node2.parent || { raws: {} };
7892
+ let p2 = node2.parent || { raws: {} };
7884
7893
  let childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
7885
- if (!childless || node2 !== p.last || p.raws.semicolon) {
7894
+ if (!childless || node2 !== p2.last || p2.raws.semicolon) {
7886
7895
  if (node2.source && node2.source.end) {
7887
7896
  mapping.source = this.sourcePath(node2);
7888
7897
  mapping.original.line = node2.source.end.line;
@@ -8375,8 +8384,8 @@ function requireParser() {
8375
8384
  if (colon === false) return;
8376
8385
  let founded = 0;
8377
8386
  let token;
8378
- for (let j = colon - 1; j >= 0; j--) {
8379
- token = tokens[j];
8387
+ for (let j2 = colon - 1; j2 >= 0; j2--) {
8388
+ token = tokens[j2];
8380
8389
  if (token[0] !== "space") {
8381
8390
  founded += 1;
8382
8391
  if (founded === 2) break;
@@ -8494,8 +8503,8 @@ function requireParser() {
8494
8503
  } else if (token[1].toLowerCase() === "important") {
8495
8504
  let cache = tokens.slice(0);
8496
8505
  let str = "";
8497
- for (let j = i2; j > 0; j--) {
8498
- let type = cache[j][0];
8506
+ for (let j2 = i2; j2 > 0; j2--) {
8507
+ let type = cache[j2][0];
8499
8508
  if (str.trim().startsWith("!") && type !== "space") {
8500
8509
  break;
8501
8510
  }
@@ -9083,8 +9092,8 @@ function requireLazyResult() {
9083
9092
  let pluginVer = plugin.postcssVersion;
9084
9093
  let runtimeVer = this.result.processor.version;
9085
9094
  let a2 = pluginVer.split(".");
9086
- let b = runtimeVer.split(".");
9087
- if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
9095
+ let b2 = runtimeVer.split(".");
9096
+ if (a2[0] !== b2[0] || parseInt(a2[1]) > parseInt(b2[1])) {
9088
9097
  console.error(
9089
9098
  "Unknown error from PostCSS plugin. Your current PostCSS version is " + runtimeVer + ", but " + pluginName + " uses " + pluginVer + ". Perhaps this is the source of the error below."
9090
9099
  );
@@ -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,