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