@posthog/rrweb 0.0.49 → 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.
@@ -1160,7 +1160,9 @@ function slimDOMExcluded(sn, slimDOMOptions) {
1160
1160
  return true;
1161
1161
  } else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(
1162
1162
  /^msapplication-tile(image|color)$/
1163
- ) || lowerIfExists(sn.attributes.name) === "application-name" || lowerIfExists(sn.attributes.rel) === "icon" || lowerIfExists(sn.attributes.rel) === "apple-touch-icon" || lowerIfExists(sn.attributes.rel) === "shortcut icon"))) {
1163
+ ) || lowerIfExists(sn.attributes.name) === "application-name" || ["icon", "apple-touch-icon", "shortcut icon"].includes(
1164
+ lowerIfExists(sn.attributes.rel)
1165
+ )))) {
1164
1166
  return true;
1165
1167
  } else if (sn.tagName === "meta") {
1166
1168
  if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
@@ -1168,13 +1170,25 @@ function slimDOMExcluded(sn, slimDOMOptions) {
1168
1170
  } else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || // og = opengraph (facebook)
1169
1171
  lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
1170
1172
  return true;
1171
- } else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
1173
+ } else if (slimDOMOptions.headMetaRobots && ["robots", "googlebot", "bingbot"].includes(
1174
+ lowerIfExists(sn.attributes.name)
1175
+ )) {
1172
1176
  return true;
1173
1177
  } else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
1174
1178
  return true;
1175
- } 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:/))) {
1179
+ } else if (slimDOMOptions.headMetaAuthorship && (["author", "generator", "framework", "publisher", "progid"].includes(
1180
+ lowerIfExists(sn.attributes.name)
1181
+ ) || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
1176
1182
  return true;
1177
- } 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")) {
1183
+ } else if (slimDOMOptions.headMetaVerification && [
1184
+ "google-site-verification",
1185
+ "yandex-verification",
1186
+ "csrf-token",
1187
+ "p:domain_verify",
1188
+ "verify-v1",
1189
+ "verification",
1190
+ "shopify-checkout-api-token"
1191
+ ].includes(lowerIfExists(sn.attributes.name))) {
1178
1192
  return true;
1179
1193
  }
1180
1194
  }
@@ -1427,6 +1441,27 @@ function serializeNodeWithId(n2, options) {
1427
1441
  }
1428
1442
  return serializedNode;
1429
1443
  }
1444
+ function slimDOMDefaults(slimDOM) {
1445
+ if (slimDOM === true || slimDOM === "all") {
1446
+ return {
1447
+ script: true,
1448
+ comment: true,
1449
+ headFavicon: true,
1450
+ headWhitespace: true,
1451
+ headMetaSocial: true,
1452
+ headMetaRobots: true,
1453
+ headMetaHttpEquiv: true,
1454
+ headMetaVerification: true,
1455
+ headMetaAuthorship: slimDOM === "all",
1456
+ headMetaDescKeywords: slimDOM === "all",
1457
+ headTitleMutations: slimDOM === "all"
1458
+ };
1459
+ }
1460
+ if (slimDOM === false) {
1461
+ return {};
1462
+ }
1463
+ return slimDOM;
1464
+ }
1430
1465
  function snapshot(n2, options) {
1431
1466
  const {
1432
1467
  mirror: mirror2 = new Mirror(),
@@ -1471,22 +1506,7 @@ function snapshot(n2, options) {
1471
1506
  } : maskAllInputs === false ? {
1472
1507
  password: true
1473
1508
  } : maskAllInputs;
1474
- const slimDOMOptions = slimDOM === true || slimDOM === "all" ? (
1475
- // if true: set of sensible options that should not throw away any information
1476
- {
1477
- script: true,
1478
- comment: true,
1479
- headFavicon: true,
1480
- headWhitespace: true,
1481
- headMetaDescKeywords: slimDOM === "all",
1482
- // destructive
1483
- headMetaSocial: true,
1484
- headMetaRobots: true,
1485
- headMetaHttpEquiv: true,
1486
- headMetaAuthorship: true,
1487
- headMetaVerification: true
1488
- }
1489
- ) : slimDOM === false ? {} : slimDOM;
1509
+ const slimDOMOptions = slimDOMDefaults(slimDOM);
1490
1510
  return serializeNodeWithId(n2, {
1491
1511
  doc: n2,
1492
1512
  mirror: mirror2,
@@ -11768,14 +11788,14 @@ function hasShadowRoot(n2) {
11768
11788
  return Boolean(index.shadowRoot(n2));
11769
11789
  }
11770
11790
  function getNestedRule(rules2, position) {
11771
- const rule2 = rules2[position[0]];
11791
+ const rule2 = rules2 == null ? void 0 : rules2[position[0]];
11792
+ if (!rule2) {
11793
+ return null;
11794
+ }
11772
11795
  if (position.length === 1) {
11773
11796
  return rule2;
11774
11797
  } else {
11775
- return getNestedRule(
11776
- rule2.cssRules[position[1]].cssRules,
11777
- position.slice(2)
11778
- );
11798
+ return getNestedRule(rule2.cssRules, position.slice(1));
11779
11799
  }
11780
11800
  }
11781
11801
  function getPositionsAndIndex(nestedIndex) {
@@ -12303,10 +12323,18 @@ class MutationBuffer {
12303
12323
  this.attributes.push(item);
12304
12324
  this.attributeMap.set(textarea, item);
12305
12325
  }
12306
- item.attributes.value = Array.from(
12326
+ const value = Array.from(
12307
12327
  index.childNodes(textarea),
12308
12328
  (cn) => index.textContent(cn) || ""
12309
12329
  ).join("");
12330
+ item.attributes.value = maskInputValue({
12331
+ element: textarea,
12332
+ maskInputOptions: this.maskInputOptions,
12333
+ tagName: textarea.tagName,
12334
+ type: getInputType(textarea),
12335
+ value,
12336
+ maskInputFn: this.maskInputFn
12337
+ });
12310
12338
  });
12311
12339
  __publicField(this, "processMutation", (m) => {
12312
12340
  if (isIgnored(m.target, this.mirror, this.slimDOMOptions)) {
@@ -12974,6 +13002,7 @@ function getNestedCSSRulePositions(rule2) {
12974
13002
  );
12975
13003
  const index2 = rules2.indexOf(childRule);
12976
13004
  pos.unshift(index2);
13005
+ return recurse(childRule.parentRule, pos);
12977
13006
  } else if (childRule.parentStyleSheet) {
12978
13007
  const rules2 = Array.from(childRule.parentStyleSheet.cssRules);
12979
13008
  const index2 = rules2.indexOf(childRule);
@@ -14409,17 +14438,19 @@ function patchGLPrototype(prototype, type, cb, blockClass, blockSelector, win, d
14409
14438
  }
14410
14439
  function initCanvasWebGLMutationObserver(cb, win, blockClass, blockSelector, dataURLOptions) {
14411
14440
  const handlers = [];
14412
- handlers.push(
14413
- ...patchGLPrototype(
14414
- win.WebGLRenderingContext.prototype,
14415
- CanvasContext.WebGL,
14416
- cb,
14417
- blockClass,
14418
- blockSelector,
14419
- win,
14420
- dataURLOptions
14421
- )
14422
- );
14441
+ if (typeof win.WebGLRenderingContext !== "undefined") {
14442
+ handlers.push(
14443
+ ...patchGLPrototype(
14444
+ win.WebGLRenderingContext.prototype,
14445
+ CanvasContext.WebGL,
14446
+ cb,
14447
+ blockClass,
14448
+ blockSelector,
14449
+ win,
14450
+ dataURLOptions
14451
+ )
14452
+ );
14453
+ }
14423
14454
  if (typeof win.WebGL2RenderingContext !== "undefined") {
14424
14455
  handlers.push(
14425
14456
  ...patchGLPrototype(
@@ -14885,21 +14916,9 @@ function record(options = {}) {
14885
14916
  select: true,
14886
14917
  password: true
14887
14918
  } : _maskInputOptions !== void 0 ? _maskInputOptions : { password: true };
14888
- const slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
14889
- script: true,
14890
- comment: true,
14891
- headFavicon: true,
14892
- headWhitespace: true,
14893
- headMetaSocial: true,
14894
- headMetaRobots: true,
14895
- headMetaHttpEquiv: true,
14896
- headMetaVerification: true,
14897
- // the following are off for slimDOMOptions === true,
14898
- // as they destroy some (hidden) info:
14899
- headMetaAuthorship: _slimDOMOptions === "all",
14900
- headMetaDescKeywords: _slimDOMOptions === "all",
14901
- headTitleMutations: _slimDOMOptions === "all"
14902
- } : _slimDOMOptions ? _slimDOMOptions : {};
14919
+ const slimDOMOptions = slimDOMDefaults(
14920
+ _slimDOMOptions !== void 0 ? _slimDOMOptions : false
14921
+ );
14903
14922
  polyfill$1();
14904
14923
  let lastFullSnapshotEvent;
14905
14924
  let incrementalSnapshotCount = 0;
@@ -15272,7 +15291,7 @@ function record(options = {}) {
15272
15291
  handlers.push(observe(document));
15273
15292
  recording = true;
15274
15293
  };
15275
- if (document.readyState === "interactive" || document.readyState === "complete") {
15294
+ if (["interactive", "complete"].includes(document.readyState)) {
15276
15295
  init();
15277
15296
  } else {
15278
15297
  handlers.push(
@@ -17865,18 +17884,23 @@ class Replayer {
17865
17884
  const newSn = mirror2.getMeta(
17866
17885
  target
17867
17886
  );
17887
+ const newNode = buildNodeWithSN(
17888
+ __spreadProps(__spreadValues({}, newSn), {
17889
+ attributes: __spreadValues(__spreadValues({}, newSn.attributes), mutation.attributes)
17890
+ }),
17891
+ {
17892
+ doc: target.ownerDocument,
17893
+ // can be Document or RRDocument
17894
+ mirror: mirror2,
17895
+ skipChild: true,
17896
+ hackCss: true,
17897
+ cache: this.cache
17898
+ }
17899
+ );
17868
17900
  Object.assign(
17869
17901
  newSn.attributes,
17870
17902
  mutation.attributes
17871
17903
  );
17872
- const newNode = buildNodeWithSN(newSn, {
17873
- doc: target.ownerDocument,
17874
- // can be Document or RRDocument
17875
- mirror: mirror2,
17876
- skipChild: true,
17877
- hackCss: true,
17878
- cache: this.cache
17879
- });
17880
17904
  const siblingNode = target.nextSibling;
17881
17905
  const parentNode2 = target.parentNode;
17882
17906
  if (newNode && parentNode2) {
@@ -18026,7 +18050,7 @@ class Replayer {
18026
18050
  if (Array.isArray(nestedIndex)) {
18027
18051
  const { positions, index: index2 } = getPositionsAndIndex(nestedIndex);
18028
18052
  const nestedRule = getNestedRule(styleSheet.cssRules, positions);
18029
- nestedRule.insertRule(rule2, index2);
18053
+ nestedRule == null ? void 0 : nestedRule.insertRule(rule2, index2);
18030
18054
  } else {
18031
18055
  const index2 = nestedIndex === void 0 ? void 0 : Math.min(nestedIndex, styleSheet.cssRules.length);
18032
18056
  styleSheet == null ? void 0 : styleSheet.insertRule(rule2, index2);
@@ -18039,19 +18063,19 @@ class Replayer {
18039
18063
  if (Array.isArray(nestedIndex)) {
18040
18064
  const { positions, index: index2 } = getPositionsAndIndex(nestedIndex);
18041
18065
  const nestedRule = getNestedRule(styleSheet.cssRules, positions);
18042
- nestedRule.deleteRule(index2 || 0);
18066
+ nestedRule == null ? void 0 : nestedRule.deleteRule(index2 || 0);
18043
18067
  } else {
18044
18068
  styleSheet == null ? void 0 : styleSheet.deleteRule(nestedIndex);
18045
18069
  }
18046
18070
  } catch (e2) {
18047
18071
  }
18048
18072
  });
18049
- if (data.replace)
18073
+ if (typeof data.replace === "string")
18050
18074
  try {
18051
18075
  void ((_c = styleSheet.replace) == null ? void 0 : _c.call(styleSheet, data.replace));
18052
18076
  } catch (e2) {
18053
18077
  }
18054
- if (data.replaceSync)
18078
+ if (typeof data.replaceSync === "string")
18055
18079
  try {
18056
18080
  (_d = styleSheet.replaceSync) == null ? void 0 : _d.call(styleSheet, data.replaceSync);
18057
18081
  } catch (e2) {