@posthog/rrweb 0.0.48 → 0.0.50

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.d.cts CHANGED
@@ -70,7 +70,7 @@ export declare const freezePage: () => void;
70
70
 
71
71
  declare function getBaseDimension(node: Node, rootIframe: Node): DocumentDimension;
72
72
 
73
- declare function getNestedRule(rules: CSSRuleList, position: number[]): CSSGroupingRule;
73
+ declare function getNestedRule(rules: CSSRuleList, position: number[]): CSSGroupingRule | null;
74
74
 
75
75
  declare function getPositionsAndIndex(nestedIndex: number[]): {
76
76
  positions: number[];
package/dist/rrweb.d.ts CHANGED
@@ -70,7 +70,7 @@ export declare const freezePage: () => void;
70
70
 
71
71
  declare function getBaseDimension(node: Node, rootIframe: Node): DocumentDimension;
72
72
 
73
- declare function getNestedRule(rules: CSSRuleList, position: number[]): CSSGroupingRule;
73
+ declare function getNestedRule(rules: CSSRuleList, position: number[]): CSSGroupingRule | null;
74
74
 
75
75
  declare function getPositionsAndIndex(nestedIndex: number[]): {
76
76
  positions: number[];
package/dist/rrweb.js CHANGED
@@ -1125,7 +1125,9 @@ function slimDOMExcluded(sn, slimDOMOptions) {
1125
1125
  return true;
1126
1126
  } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(
1127
1127
  /^msapplication-tile(image|color)$/
1128
- ) || lowerIfExists(sn.attributes.name) === "application-name" || lowerIfExists(sn.attributes.rel) === "icon" || lowerIfExists(sn.attributes.rel) === "apple-touch-icon" || lowerIfExists(sn.attributes.rel) === "shortcut icon"))) {
1128
+ ) || lowerIfExists(sn.attributes.name) === "application-name" || ["icon", "apple-touch-icon", "shortcut icon"].includes(
1129
+ lowerIfExists(sn.attributes.rel)
1130
+ )))) {
1129
1131
  return true;
1130
1132
  } else if (sn.tagName === "meta") {
1131
1133
  if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
@@ -1133,13 +1135,25 @@ function slimDOMExcluded(sn, slimDOMOptions) {
1133
1135
  } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
1134
1136
  lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
1135
1137
  return true;
1136
- } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
1138
+ } else if (slimDOMOptions.headMetaRobots && ["robots", "googlebot", "bingbot"].includes(
1139
+ lowerIfExists(sn.attributes.name)
1140
+ )) {
1137
1141
  return true;
1138
1142
  } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
1139
1143
  return true;
1140
- } else if (slimDOMOptions.headMetaAuthorship && (lowerIfExists(sn.attributes.name) === "author" || lowerIfExists(sn.attributes.name) === "generator" || lowerIfExists(sn.attributes.name) === "framework" || lowerIfExists(sn.attributes.name) === "publisher" || lowerIfExists(sn.attributes.name) === "progid" || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
1144
+ } else if (slimDOMOptions.headMetaAuthorship && (["author", "generator", "framework", "publisher", "progid"].includes(
1145
+ lowerIfExists(sn.attributes.name)
1146
+ ) || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
1141
1147
  return true;
1142
- } else if (slimDOMOptions.headMetaVerification && (lowerIfExists(sn.attributes.name) === "google-site-verification" || lowerIfExists(sn.attributes.name) === "yandex-verification" || lowerIfExists(sn.attributes.name) === "csrf-token" || lowerIfExists(sn.attributes.name) === "p:domain_verify" || lowerIfExists(sn.attributes.name) === "verify-v1" || lowerIfExists(sn.attributes.name) === "verification" || lowerIfExists(sn.attributes.name) === "shopify-checkout-api-token")) {
1148
+ } else if (slimDOMOptions.headMetaVerification && [
1149
+ "google-site-verification",
1150
+ "yandex-verification",
1151
+ "csrf-token",
1152
+ "p:domain_verify",
1153
+ "verify-v1",
1154
+ "verification",
1155
+ "shopify-checkout-api-token"
1156
+ ].includes(lowerIfExists(sn.attributes.name))) {
1143
1157
  return true;
1144
1158
  }
1145
1159
  }
@@ -1392,6 +1406,27 @@ function serializeNodeWithId(n2, options) {
1392
1406
  }
1393
1407
  return serializedNode;
1394
1408
  }
1409
+ function slimDOMDefaults(slimDOM) {
1410
+ if (slimDOM === true || slimDOM === "all") {
1411
+ return {
1412
+ script: true,
1413
+ comment: true,
1414
+ headFavicon: true,
1415
+ headWhitespace: true,
1416
+ headMetaSocial: true,
1417
+ headMetaRobots: true,
1418
+ headMetaHttpEquiv: true,
1419
+ headMetaVerification: true,
1420
+ headMetaAuthorship: slimDOM === "all",
1421
+ headMetaDescKeywords: slimDOM === "all",
1422
+ headTitleMutations: slimDOM === "all"
1423
+ };
1424
+ }
1425
+ if (slimDOM === false) {
1426
+ return {};
1427
+ }
1428
+ return slimDOM;
1429
+ }
1395
1430
  function snapshot(n2, options) {
1396
1431
  const {
1397
1432
  mirror: mirror2 = new Mirror(),
@@ -1436,22 +1471,7 @@ function snapshot(n2, options) {
1436
1471
  } : maskAllInputs === false ? {
1437
1472
  password: true
1438
1473
  } : maskAllInputs;
1439
- const slimDOMOptions = slimDOM === true || slimDOM === "all" ? (
1440
- // if true: set of sensible options that should not throw away any information
1441
- {
1442
- script: true,
1443
- comment: true,
1444
- headFavicon: true,
1445
- headWhitespace: true,
1446
- headMetaDescKeywords: slimDOM === "all",
1447
- // destructive
1448
- headMetaSocial: true,
1449
- headMetaRobots: true,
1450
- headMetaHttpEquiv: true,
1451
- headMetaAuthorship: true,
1452
- headMetaVerification: true
1453
- }
1454
- ) : slimDOM === false ? {} : slimDOM;
1474
+ const slimDOMOptions = slimDOMDefaults(slimDOM);
1455
1475
  return serializeNodeWithId(n2, {
1456
1476
  doc: n2,
1457
1477
  mirror: mirror2,
@@ -11737,14 +11757,14 @@ function hasShadowRoot(n2) {
11737
11757
  return Boolean(index.shadowRoot(n2));
11738
11758
  }
11739
11759
  function getNestedRule(rules2, position) {
11740
- const rule2 = rules2[position[0]];
11760
+ const rule2 = rules2 == null ? void 0 : rules2[position[0]];
11761
+ if (!rule2) {
11762
+ return null;
11763
+ }
11741
11764
  if (position.length === 1) {
11742
11765
  return rule2;
11743
11766
  } else {
11744
- return getNestedRule(
11745
- rule2.cssRules[position[1]].cssRules,
11746
- position.slice(2)
11747
- );
11767
+ return getNestedRule(rule2.cssRules, position.slice(1));
11748
11768
  }
11749
11769
  }
11750
11770
  function getPositionsAndIndex(nestedIndex) {
@@ -12288,10 +12308,18 @@ class MutationBuffer {
12288
12308
  this.attributes.push(item);
12289
12309
  this.attributeMap.set(textarea, item);
12290
12310
  }
12291
- item.attributes.value = Array.from(
12311
+ const value = Array.from(
12292
12312
  index.childNodes(textarea),
12293
12313
  (cn) => index.textContent(cn) || ""
12294
12314
  ).join("");
12315
+ item.attributes.value = maskInputValue({
12316
+ element: textarea,
12317
+ maskInputOptions: this.maskInputOptions,
12318
+ tagName: textarea.tagName,
12319
+ type: getInputType(textarea),
12320
+ value,
12321
+ maskInputFn: this.maskInputFn
12322
+ });
12295
12323
  });
12296
12324
  __publicField(this, "processMutation", (m) => {
12297
12325
  if (isIgnored(m.target, this.mirror, this.slimDOMOptions)) {
@@ -12964,6 +12992,7 @@ function getNestedCSSRulePositions(rule2) {
12964
12992
  );
12965
12993
  const index2 = rules2.indexOf(childRule);
12966
12994
  pos.unshift(index2);
12995
+ return recurse(childRule.parentRule, pos);
12967
12996
  } else if (childRule.parentStyleSheet) {
12968
12997
  const rules2 = Array.from(childRule.parentStyleSheet.cssRules);
12969
12998
  const index2 = rules2.indexOf(childRule);
@@ -14402,17 +14431,19 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win, d
14402
14431
  }
14403
14432
  function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector, dataURLOptions) {
14404
14433
  const handlers = [];
14405
- handlers.push(
14406
- ...patchGLPrototype(
14407
- win.WebGLRenderingContext.prototype,
14408
- CanvasContext.WebGL,
14409
- cb,
14410
- blockClass,
14411
- blockSelector,
14412
- win,
14413
- dataURLOptions
14414
- )
14415
- );
14434
+ if (typeof win.WebGLRenderingContext !== "undefined") {
14435
+ handlers.push(
14436
+ ...patchGLPrototype(
14437
+ win.WebGLRenderingContext.prototype,
14438
+ CanvasContext.WebGL,
14439
+ cb,
14440
+ blockClass,
14441
+ blockSelector,
14442
+ win,
14443
+ dataURLOptions
14444
+ )
14445
+ );
14446
+ }
14416
14447
  if (typeof win.WebGL2RenderingContext !== "undefined") {
14417
14448
  handlers.push(
14418
14449
  ...patchGLPrototype(
@@ -14879,21 +14910,9 @@ function record(options = {}) {
14879
14910
  select: true,
14880
14911
  password: true
14881
14912
  } : _maskInputOptions !== void 0 ? _maskInputOptions : { password: true };
14882
- const slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
14883
- script: true,
14884
- comment: true,
14885
- headFavicon: true,
14886
- headWhitespace: true,
14887
- headMetaSocial: true,
14888
- headMetaRobots: true,
14889
- headMetaHttpEquiv: true,
14890
- headMetaVerification: true,
14891
- // the following are off for slimDOMOptions === true,
14892
- // as they destroy some (hidden) info:
14893
- headMetaAuthorship: _slimDOMOptions === "all",
14894
- headMetaDescKeywords: _slimDOMOptions === "all",
14895
- headTitleMutations: _slimDOMOptions === "all"
14896
- } : _slimDOMOptions ? _slimDOMOptions : {};
14913
+ const slimDOMOptions = slimDOMDefaults(
14914
+ _slimDOMOptions !== void 0 ? _slimDOMOptions : false
14915
+ );
14897
14916
  polyfill$1();
14898
14917
  let lastFullSnapshotEvent;
14899
14918
  let incrementalSnapshotCount = 0;
@@ -15279,7 +15298,7 @@ function record(options = {}) {
15279
15298
  handlers.push(observe(document));
15280
15299
  recording = true;
15281
15300
  };
15282
- if (document.readyState === "interactive" || document.readyState === "complete") {
15301
+ if (["interactive", "complete"].includes(document.readyState)) {
15283
15302
  init();
15284
15303
  } else {
15285
15304
  handlers.push(
@@ -15306,7 +15325,17 @@ function record(options = {}) {
15306
15325
  );
15307
15326
  }
15308
15327
  return () => {
15309
- handlers.forEach((h) => h());
15328
+ handlers.forEach((h) => {
15329
+ try {
15330
+ h();
15331
+ } catch (error) {
15332
+ const msg = String(error);
15333
+ const isCrossOriginFrameError = msg.includes("from accessing a cross-origin frame") && msg.includes("Blocked a frame with origin");
15334
+ if (!isCrossOriginFrameError) {
15335
+ throw error;
15336
+ }
15337
+ }
15338
+ });
15310
15339
  processedNodeManager.destroy();
15311
15340
  iframeManager.removeLoadListener();
15312
15341
  iframeManager.destroy();
@@ -17874,18 +17903,27 @@ class Replayer {
17874
17903
  const newSn = mirror2.getMeta(
17875
17904
  target
17876
17905
  );
17906
+ const newNode = buildNodeWithSN(
17907
+ {
17908
+ ...newSn,
17909
+ attributes: {
17910
+ ...newSn.attributes,
17911
+ ...mutation.attributes
17912
+ }
17913
+ },
17914
+ {
17915
+ doc: target.ownerDocument,
17916
+ // can be Document or RRDocument
17917
+ mirror: mirror2,
17918
+ skipChild: true,
17919
+ hackCss: true,
17920
+ cache: this.cache
17921
+ }
17922
+ );
17877
17923
  Object.assign(
17878
17924
  newSn.attributes,
17879
17925
  mutation.attributes
17880
17926
  );
17881
- const newNode = buildNodeWithSN(newSn, {
17882
- doc: target.ownerDocument,
17883
- // can be Document or RRDocument
17884
- mirror: mirror2,
17885
- skipChild: true,
17886
- hackCss: true,
17887
- cache: this.cache
17888
- });
17889
17927
  const siblingNode = target.nextSibling;
17890
17928
  const parentNode2 = target.parentNode;
17891
17929
  if (newNode && parentNode2) {
@@ -18035,7 +18073,7 @@ class Replayer {
18035
18073
  if (Array.isArray(nestedIndex)) {
18036
18074
  const { positions, index: index2 } = getPositionsAndIndex(nestedIndex);
18037
18075
  const nestedRule = getNestedRule(styleSheet.cssRules, positions);
18038
- nestedRule.insertRule(rule2, index2);
18076
+ nestedRule == null ? void 0 : nestedRule.insertRule(rule2, index2);
18039
18077
  } else {
18040
18078
  const index2 = nestedIndex === void 0 ? void 0 : Math.min(nestedIndex, styleSheet.cssRules.length);
18041
18079
  styleSheet == null ? void 0 : styleSheet.insertRule(rule2, index2);
@@ -18048,19 +18086,19 @@ class Replayer {
18048
18086
  if (Array.isArray(nestedIndex)) {
18049
18087
  const { positions, index: index2 } = getPositionsAndIndex(nestedIndex);
18050
18088
  const nestedRule = getNestedRule(styleSheet.cssRules, positions);
18051
- nestedRule.deleteRule(index2 || 0);
18089
+ nestedRule == null ? void 0 : nestedRule.deleteRule(index2 || 0);
18052
18090
  } else {
18053
18091
  styleSheet == null ? void 0 : styleSheet.deleteRule(nestedIndex);
18054
18092
  }
18055
18093
  } catch (e2) {
18056
18094
  }
18057
18095
  });
18058
- if (data.replace)
18096
+ if (typeof data.replace === "string")
18059
18097
  try {
18060
18098
  void ((_c = styleSheet.replace) == null ? void 0 : _c.call(styleSheet, data.replace));
18061
18099
  } catch (e2) {
18062
18100
  }
18063
- if (data.replaceSync)
18101
+ if (typeof data.replaceSync === "string")
18064
18102
  try {
18065
18103
  (_d = styleSheet.replaceSync) == null ? void 0 : _d.call(styleSheet, data.replaceSync);
18066
18104
  } catch (e2) {