@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.
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)) {
@@ -1478,8 +1481,8 @@ function getAugmentedNamespace$1(n2) {
1478
1481
  if (n2.__esModule) return n2;
1479
1482
  var f2 = n2.default;
1480
1483
  if (typeof f2 == "function") {
1481
- var a2 = function a22() {
1482
- if (this instanceof a22) {
1484
+ var a2 = function a3() {
1485
+ if (this instanceof a3) {
1483
1486
  return Reflect.construct(f2, arguments, this.constructor);
1484
1487
  }
1485
1488
  return f2.apply(this, arguments);
@@ -1488,8 +1491,8 @@ function getAugmentedNamespace$1(n2) {
1488
1491
  } else a2 = {};
1489
1492
  Object.defineProperty(a2, "__esModule", { value: true });
1490
1493
  Object.keys(n2).forEach(function(k) {
1491
- var d = Object.getOwnPropertyDescriptor(n2, k);
1492
- Object.defineProperty(a2, k, d.get ? d : {
1494
+ var d2 = Object.getOwnPropertyDescriptor(n2, k);
1495
+ Object.defineProperty(a2, k, d2.get ? d2 : {
1493
1496
  enumerable: true,
1494
1497
  get: function() {
1495
1498
  return n2[k];
@@ -1865,8 +1868,8 @@ function requireStringifier$1() {
1865
1868
  if (root2.raws.indent) return root2.raws.indent;
1866
1869
  let value;
1867
1870
  root2.walk((i2) => {
1868
- let p = i2.parent;
1869
- if (p && p !== root2 && p.parent && p.parent === root2) {
1871
+ let p2 = i2.parent;
1872
+ if (p2 && p2 !== root2 && p2.parent && p2.parent === root2) {
1870
1873
  if (typeof i2.raws.before !== "undefined") {
1871
1874
  let parts = i2.raws.before.split("\n");
1872
1875
  value = parts[parts.length - 1];
@@ -1964,7 +1967,7 @@ function requireNode$1() {
1964
1967
  } else if (i2 === "source") {
1965
1968
  cloned[i2] = value;
1966
1969
  } else if (Array.isArray(value)) {
1967
- cloned[i2] = value.map((j) => cloneNode(j, cloned));
1970
+ cloned[i2] = value.map((j2) => cloneNode(j2, cloned));
1968
1971
  } else {
1969
1972
  if (type === "object" && value !== null) value = cloneNode(value);
1970
1973
  cloned[i2] = value;
@@ -2750,10 +2753,10 @@ function requireAtRule$1() {
2750
2753
  Container.registerAtRule(AtRule);
2751
2754
  return atRule$1;
2752
2755
  }
2753
- var document$1$1;
2756
+ var document$2;
2754
2757
  var hasRequiredDocument$1;
2755
2758
  function requireDocument$1() {
2756
- if (hasRequiredDocument$1) return document$1$1;
2759
+ if (hasRequiredDocument$1) return document$2;
2757
2760
  hasRequiredDocument$1 = 1;
2758
2761
  let Container = requireContainer$1();
2759
2762
  let LazyResult, Processor;
@@ -2775,9 +2778,9 @@ function requireDocument$1() {
2775
2778
  Document2.registerProcessor = (dependant) => {
2776
2779
  Processor = dependant;
2777
2780
  };
2778
- document$1$1 = Document2;
2781
+ document$2 = Document2;
2779
2782
  Document2.default = Document2;
2780
- return document$1$1;
2783
+ return document$2;
2781
2784
  }
2782
2785
  var nonSecure$1;
2783
2786
  var hasRequiredNonSecure$1;
@@ -3480,9 +3483,9 @@ function requireMapGenerator$1() {
3480
3483
  column += str.length;
3481
3484
  }
3482
3485
  if (node2 && type !== "start") {
3483
- let p = node2.parent || { raws: {} };
3486
+ let p2 = node2.parent || { raws: {} };
3484
3487
  let childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
3485
- if (!childless || node2 !== p.last || p.raws.semicolon) {
3488
+ if (!childless || node2 !== p2.last || p2.raws.semicolon) {
3486
3489
  if (node2.source && node2.source.end) {
3487
3490
  mapping.source = this.sourcePath(node2);
3488
3491
  mapping.original.line = node2.source.end.line;
@@ -3975,8 +3978,8 @@ function requireParser$1() {
3975
3978
  if (colon === false) return;
3976
3979
  let founded = 0;
3977
3980
  let token;
3978
- for (let j = colon - 1; j >= 0; j--) {
3979
- token = tokens[j];
3981
+ for (let j2 = colon - 1; j2 >= 0; j2--) {
3982
+ token = tokens[j2];
3980
3983
  if (token[0] !== "space") {
3981
3984
  founded += 1;
3982
3985
  if (founded === 2) break;
@@ -4094,8 +4097,8 @@ function requireParser$1() {
4094
4097
  } else if (token[1].toLowerCase() === "important") {
4095
4098
  let cache = tokens.slice(0);
4096
4099
  let str = "";
4097
- for (let j = i2; j > 0; j--) {
4098
- let type = cache[j][0];
4100
+ for (let j2 = i2; j2 > 0; j2--) {
4101
+ let type = cache[j2][0];
4099
4102
  if (str.trim().startsWith("!") && type !== "space") {
4100
4103
  break;
4101
4104
  }
@@ -4683,8 +4686,8 @@ function requireLazyResult$1() {
4683
4686
  let pluginVer = plugin.postcssVersion;
4684
4687
  let runtimeVer = this.result.processor.version;
4685
4688
  let a2 = pluginVer.split(".");
4686
- let b = runtimeVer.split(".");
4687
- if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
4689
+ let b2 = runtimeVer.split(".");
4690
+ if (a2[0] !== b2[0] || parseInt(a2[1]) > parseInt(b2[1])) {
4688
4691
  console.error(
4689
4692
  "Unknown error from PostCSS plugin. Your current PostCSS version is " + runtimeVer + ", but " + pluginName + " uses " + pluginVer + ". Perhaps this is the source of the error below."
4690
4693
  );
@@ -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") {
@@ -5835,8 +5844,8 @@ function getAugmentedNamespace(n2) {
5835
5844
  if (n2.__esModule) return n2;
5836
5845
  var f2 = n2.default;
5837
5846
  if (typeof f2 == "function") {
5838
- var a2 = function a22() {
5839
- if (this instanceof a22) {
5847
+ var a2 = function a3() {
5848
+ if (this instanceof a3) {
5840
5849
  return Reflect.construct(f2, arguments, this.constructor);
5841
5850
  }
5842
5851
  return f2.apply(this, arguments);
@@ -5845,8 +5854,8 @@ function getAugmentedNamespace(n2) {
5845
5854
  } else a2 = {};
5846
5855
  Object.defineProperty(a2, "__esModule", { value: true });
5847
5856
  Object.keys(n2).forEach(function(k) {
5848
- var d = Object.getOwnPropertyDescriptor(n2, k);
5849
- Object.defineProperty(a2, k, d.get ? d : {
5857
+ var d2 = Object.getOwnPropertyDescriptor(n2, k);
5858
+ Object.defineProperty(a2, k, d2.get ? d2 : {
5850
5859
  enumerable: true,
5851
5860
  get: function() {
5852
5861
  return n2[k];
@@ -6222,8 +6231,8 @@ function requireStringifier() {
6222
6231
  if (root2.raws.indent) return root2.raws.indent;
6223
6232
  let value;
6224
6233
  root2.walk((i2) => {
6225
- let p = i2.parent;
6226
- if (p && p !== root2 && p.parent && p.parent === root2) {
6234
+ let p2 = i2.parent;
6235
+ if (p2 && p2 !== root2 && p2.parent && p2.parent === root2) {
6227
6236
  if (typeof i2.raws.before !== "undefined") {
6228
6237
  let parts = i2.raws.before.split("\n");
6229
6238
  value = parts[parts.length - 1];
@@ -6321,7 +6330,7 @@ function requireNode() {
6321
6330
  } else if (i2 === "source") {
6322
6331
  cloned[i2] = value;
6323
6332
  } else if (Array.isArray(value)) {
6324
- cloned[i2] = value.map((j) => cloneNode(j, cloned));
6333
+ cloned[i2] = value.map((j2) => cloneNode(j2, cloned));
6325
6334
  } else {
6326
6335
  if (type === "object" && value !== null) value = cloneNode(value);
6327
6336
  cloned[i2] = value;
@@ -7837,9 +7846,9 @@ function requireMapGenerator() {
7837
7846
  column += str.length;
7838
7847
  }
7839
7848
  if (node2 && type !== "start") {
7840
- let p = node2.parent || { raws: {} };
7849
+ let p2 = node2.parent || { raws: {} };
7841
7850
  let childless = node2.type === "decl" || node2.type === "atrule" && !node2.nodes;
7842
- if (!childless || node2 !== p.last || p.raws.semicolon) {
7851
+ if (!childless || node2 !== p2.last || p2.raws.semicolon) {
7843
7852
  if (node2.source && node2.source.end) {
7844
7853
  mapping.source = this.sourcePath(node2);
7845
7854
  mapping.original.line = node2.source.end.line;
@@ -8332,8 +8341,8 @@ function requireParser() {
8332
8341
  if (colon === false) return;
8333
8342
  let founded = 0;
8334
8343
  let token;
8335
- for (let j = colon - 1; j >= 0; j--) {
8336
- token = tokens[j];
8344
+ for (let j2 = colon - 1; j2 >= 0; j2--) {
8345
+ token = tokens[j2];
8337
8346
  if (token[0] !== "space") {
8338
8347
  founded += 1;
8339
8348
  if (founded === 2) break;
@@ -8451,8 +8460,8 @@ function requireParser() {
8451
8460
  } else if (token[1].toLowerCase() === "important") {
8452
8461
  let cache = tokens.slice(0);
8453
8462
  let str = "";
8454
- for (let j = i2; j > 0; j--) {
8455
- let type = cache[j][0];
8463
+ for (let j2 = i2; j2 > 0; j2--) {
8464
+ let type = cache[j2][0];
8456
8465
  if (str.trim().startsWith("!") && type !== "space") {
8457
8466
  break;
8458
8467
  }
@@ -9040,8 +9049,8 @@ function requireLazyResult() {
9040
9049
  let pluginVer = plugin.postcssVersion;
9041
9050
  let runtimeVer = this.result.processor.version;
9042
9051
  let a2 = pluginVer.split(".");
9043
- let b = runtimeVer.split(".");
9044
- if (a2[0] !== b[0] || parseInt(a2[1]) > parseInt(b[1])) {
9052
+ let b2 = runtimeVer.split(".");
9053
+ if (a2[0] !== b2[0] || parseInt(a2[1]) > parseInt(b2[1])) {
9045
9054
  console.error(
9046
9055
  "Unknown error from PostCSS plugin. Your current PostCSS version is " + runtimeVer + ", but " + pluginName + " uses " + pluginVer + ". Perhaps this is the source of the error below."
9047
9056
  );
@@ -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,