@appsurify-testmap/rrweb-all 2.1.0-alpha.3 → 2.1.0-alpha.5

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.
@@ -892,32 +892,14 @@ function transformAttribute(doc, tagName, name, value) {
892
892
  }
893
893
  return value;
894
894
  }
895
- function isIgnoreAttribute(tagName, name, _value) {
895
+ function ignoreAttribute(tagName, name, _value) {
896
896
  return (tagName === "video" || tagName === "audio") && name === "autoplay";
897
897
  }
898
- function cleanAttributes(doc, element, ignoreAttribute) {
899
- const tagName = getValidTagName$1(element);
900
- const attributes = {};
901
- const len = element.attributes.length;
902
- for (let i2 = 0; i2 < len; i2++) {
903
- const attr = element.attributes[i2];
904
- const name = attr.name;
905
- const value = attr.value;
906
- const shouldIgnoreByName = typeof ignoreAttribute === "string" ? name === ignoreAttribute : ignoreAttribute.test(name);
907
- if (!shouldIgnoreByName && !isIgnoreAttribute(tagName, name)) {
908
- attributes[name] = transformAttribute(
909
- doc,
910
- tagName,
911
- toLowerCase(name),
912
- value
913
- );
914
- }
915
- }
916
- return attributes;
898
+ function isIncludeAttribute(name, include) {
899
+ return typeof include === "string" ? name.includes(include) : include.test(name);
917
900
  }
918
- function shouldIgnoreAttribute(ignore, name) {
919
- if (!ignore) return false;
920
- return typeof ignore === "string" ? name === ignore : ignore.test(name);
901
+ function isExcludeAttribute(name, exclude) {
902
+ return typeof exclude === "string" ? name.includes(exclude) : exclude.test(name);
921
903
  }
922
904
  function _isBlockedElement(element, blockClass, blockSelector) {
923
905
  try {
@@ -1048,7 +1030,8 @@ function serializeNode(n2, options) {
1048
1030
  mirror: mirror2,
1049
1031
  blockClass,
1050
1032
  blockSelector,
1051
- ignoreAttribute,
1033
+ excludeAttribute,
1034
+ includeAttribute,
1052
1035
  needsMask,
1053
1036
  inlineStylesheet,
1054
1037
  maskInputOptions = {},
@@ -1094,7 +1077,8 @@ function serializeNode(n2, options) {
1094
1077
  doc,
1095
1078
  blockClass,
1096
1079
  blockSelector,
1097
- ignoreAttribute,
1080
+ excludeAttribute,
1081
+ includeAttribute,
1098
1082
  inlineStylesheet,
1099
1083
  maskInputOptions,
1100
1084
  maskInputFn,
@@ -1172,7 +1156,8 @@ function serializeElementNode(n2, options) {
1172
1156
  doc,
1173
1157
  blockClass,
1174
1158
  blockSelector,
1175
- ignoreAttribute,
1159
+ excludeAttribute,
1160
+ includeAttribute,
1176
1161
  inlineStylesheet,
1177
1162
  maskInputOptions = {},
1178
1163
  maskInputFn,
@@ -1186,7 +1171,22 @@ function serializeElementNode(n2, options) {
1186
1171
  } = options;
1187
1172
  const needBlock = _isBlockedElement(n2, blockClass, blockSelector);
1188
1173
  const tagName = getValidTagName$1(n2);
1189
- let attributes = cleanAttributes(doc, n2, ignoreAttribute);
1174
+ let attributes = {};
1175
+ const len = n2.attributes.length;
1176
+ for (let i2 = 0; i2 < len; i2++) {
1177
+ const attr = n2.attributes[i2];
1178
+ if (isExcludeAttribute(attr.name, excludeAttribute) && !isIncludeAttribute(attr.name, includeAttribute)) {
1179
+ continue;
1180
+ }
1181
+ if (!ignoreAttribute(tagName, attr.name, attr.value)) {
1182
+ attributes[attr.name] = transformAttribute(
1183
+ doc,
1184
+ tagName,
1185
+ toLowerCase(attr.name),
1186
+ attr.value
1187
+ );
1188
+ }
1189
+ }
1190
1190
  if (tagName === "link" && inlineStylesheet) {
1191
1191
  const stylesheet = Array.from(doc.styleSheets).find((s2) => {
1192
1192
  return s2.href === n2.href;
@@ -1400,7 +1400,8 @@ function serializeNodeWithId(n2, options) {
1400
1400
  blockSelector,
1401
1401
  maskTextClass,
1402
1402
  maskTextSelector,
1403
- ignoreAttribute,
1403
+ excludeAttribute,
1404
+ includeAttribute,
1404
1405
  skipChild = false,
1405
1406
  inlineStylesheet = true,
1406
1407
  maskInputOptions = {},
@@ -1435,7 +1436,8 @@ function serializeNodeWithId(n2, options) {
1435
1436
  mirror: mirror2,
1436
1437
  blockClass,
1437
1438
  blockSelector,
1438
- ignoreAttribute,
1439
+ excludeAttribute,
1440
+ includeAttribute,
1439
1441
  needsMask,
1440
1442
  inlineStylesheet,
1441
1443
  maskInputOptions,
@@ -1488,7 +1490,8 @@ function serializeNodeWithId(n2, options) {
1488
1490
  needsMask,
1489
1491
  maskTextClass,
1490
1492
  maskTextSelector,
1491
- ignoreAttribute,
1493
+ excludeAttribute,
1494
+ includeAttribute,
1492
1495
  skipChild,
1493
1496
  inlineStylesheet,
1494
1497
  maskInputOptions,
@@ -1548,7 +1551,8 @@ function serializeNodeWithId(n2, options) {
1548
1551
  needsMask,
1549
1552
  maskTextClass,
1550
1553
  maskTextSelector,
1551
- ignoreAttribute,
1554
+ excludeAttribute,
1555
+ includeAttribute,
1552
1556
  skipChild: false,
1553
1557
  inlineStylesheet,
1554
1558
  maskInputOptions,
@@ -1590,7 +1594,8 @@ function serializeNodeWithId(n2, options) {
1590
1594
  needsMask,
1591
1595
  maskTextClass,
1592
1596
  maskTextSelector,
1593
- ignoreAttribute,
1597
+ excludeAttribute,
1598
+ includeAttribute,
1594
1599
  skipChild: false,
1595
1600
  inlineStylesheet,
1596
1601
  maskInputOptions,
@@ -1628,7 +1633,8 @@ function snapshot(n2, options) {
1628
1633
  blockSelector = null,
1629
1634
  maskTextClass = "rr-mask",
1630
1635
  maskTextSelector = null,
1631
- ignoreAttribute = "rr-ignore",
1636
+ excludeAttribute = /^$a/,
1637
+ includeAttribute = /.+/i,
1632
1638
  inlineStylesheet = true,
1633
1639
  inlineImages = false,
1634
1640
  recordCanvas = false,
@@ -1688,7 +1694,8 @@ function snapshot(n2, options) {
1688
1694
  blockSelector,
1689
1695
  maskTextClass,
1690
1696
  maskTextSelector,
1691
- ignoreAttribute,
1697
+ excludeAttribute,
1698
+ includeAttribute,
1692
1699
  skipChild: false,
1693
1700
  inlineStylesheet,
1694
1701
  maskInputOptions,
@@ -10924,7 +10931,7 @@ function hookSetter(target, key, d, isRevoked, win = window) {
10924
10931
  return () => hookSetter(target, key, original || {}, true);
10925
10932
  }
10926
10933
  function nowTimestamp() {
10927
- return performance.timeOrigin + performance.now();
10934
+ return Math.round(performance.timeOrigin + performance.now());
10928
10935
  }
10929
10936
  function getWindowScroll(win = window) {
10930
10937
  var _a2, _b2, _c, _d;
@@ -11241,7 +11248,6 @@ var IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => {
11241
11248
  IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
11242
11249
  IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
11243
11250
  IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
11244
- IncrementalSource2[IncrementalSource2["VisibilityChange"] = 17] = "VisibilityChange";
11245
11251
  return IncrementalSource2;
11246
11252
  })(IncrementalSource || {});
11247
11253
  var MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {
@@ -11407,7 +11413,8 @@ class MutationBuffer {
11407
11413
  __publicField(this, "blockSelector");
11408
11414
  __publicField(this, "maskTextClass");
11409
11415
  __publicField(this, "maskTextSelector");
11410
- __publicField(this, "ignoreAttribute");
11416
+ __publicField(this, "excludeAttribute");
11417
+ __publicField(this, "includeAttribute");
11411
11418
  __publicField(this, "inlineStylesheet");
11412
11419
  __publicField(this, "maskInputOptions");
11413
11420
  __publicField(this, "maskTextFn");
@@ -11471,7 +11478,8 @@ class MutationBuffer {
11471
11478
  blockSelector: this.blockSelector,
11472
11479
  maskTextClass: this.maskTextClass,
11473
11480
  maskTextSelector: this.maskTextSelector,
11474
- ignoreAttribute: this.ignoreAttribute || "",
11481
+ excludeAttribute: this.excludeAttribute,
11482
+ includeAttribute: this.includeAttribute,
11475
11483
  skipChild: true,
11476
11484
  newlyAddedElement: true,
11477
11485
  inlineStylesheet: this.inlineStylesheet,
@@ -11591,21 +11599,6 @@ class MutationBuffer {
11591
11599
  };
11592
11600
  }).filter((text) => !addedIds.has(text.id)).filter((text) => this.mirror.has(text.id)),
11593
11601
  attributes: this.attributes.map((attribute) => {
11594
- const element = attribute.node;
11595
- const filtered = {};
11596
- for (const [name, value] of Object.entries(attribute.attributes)) {
11597
- const isIgnored2 = shouldIgnoreAttribute(this.ignoreAttribute, name);
11598
- const existedBefore = element.hasAttribute(name);
11599
- const keep = value !== null && !isIgnored2 || value === null && (!isIgnored2 || attribute.attributes[name] !== null || existedBefore);
11600
- if (keep) {
11601
- filtered[name] = value;
11602
- }
11603
- }
11604
- return {
11605
- ...attribute,
11606
- attributes: filtered
11607
- };
11608
- }).filter((attribute) => Object.keys(attribute.attributes).length > 0).map((attribute) => {
11609
11602
  const { attributes } = attribute;
11610
11603
  if (typeof attributes.style === "string") {
11611
11604
  const diffAsStr = JSON.stringify(attribute.styleDiff);
@@ -11687,8 +11680,13 @@ class MutationBuffer {
11687
11680
  case "attributes": {
11688
11681
  const target = m.target;
11689
11682
  let attributeName = m.attributeName;
11690
- let value = target.getAttribute(attributeName);
11691
- if (value === null && m.oldValue === null) {
11683
+ let value = m.target.getAttribute(attributeName);
11684
+ const propValue = target[attributeName];
11685
+ const isPhantomAttributeMutation = value === null && !target.hasAttribute(attributeName) && m.oldValue !== null && (propValue === "" || propValue === null || typeof propValue === "undefined");
11686
+ if (isPhantomAttributeMutation && !isIncludeAttribute(attributeName, this.includeAttribute)) {
11687
+ return;
11688
+ }
11689
+ if (isExcludeAttribute(attributeName, this.excludeAttribute)) {
11692
11690
  return;
11693
11691
  }
11694
11692
  if (attributeName === "value") {
@@ -11726,14 +11724,21 @@ class MutationBuffer {
11726
11724
  if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
11727
11725
  target.setAttribute("data-rr-is-password", "true");
11728
11726
  }
11729
- if (!isIgnoreAttribute(target.tagName, attributeName) && // eslint-disable-next-line @typescript-eslint/no-unsafe-call
11730
- !shouldIgnoreAttribute(this.ignoreAttribute, attributeName)) {
11727
+ if (!ignoreAttribute(target.tagName, attributeName)) {
11731
11728
  item.attributes[attributeName] = transformAttribute(
11732
11729
  this.doc,
11733
11730
  toLowerCase(target.tagName),
11734
11731
  toLowerCase(attributeName),
11735
11732
  value
11736
11733
  );
11734
+ if (value === item.attributes[attributeName] && !isIncludeAttribute(attributeName, this.includeAttribute)) {
11735
+ delete item.attributes[attributeName];
11736
+ if (Object.keys(item.attributes).length === 0) {
11737
+ this.attributes = this.attributes.filter((a2) => a2 !== item);
11738
+ this.attributeMap.delete(m.target);
11739
+ }
11740
+ return;
11741
+ }
11737
11742
  if (attributeName === "style") {
11738
11743
  if (!this.unattachedDoc) {
11739
11744
  try {
@@ -11846,7 +11851,8 @@ class MutationBuffer {
11846
11851
  "blockSelector",
11847
11852
  "maskTextClass",
11848
11853
  "maskTextSelector",
11849
- "ignoreAttribute",
11854
+ "excludeAttribute",
11855
+ "includeAttribute",
11850
11856
  "inlineStylesheet",
11851
11857
  "maskInputOptions",
11852
11858
  "maskTextFn",
@@ -11985,60 +11991,6 @@ function initMutationObserver(options, rootEl) {
11985
11991
  });
11986
11992
  return observer;
11987
11993
  }
11988
- function initVisibilityObserver({
11989
- visibilityChangeCb,
11990
- doc,
11991
- mirror: mirror2,
11992
- sampling
11993
- }) {
11994
- if (!visibilityChangeCb) {
11995
- return () => {
11996
- };
11997
- }
11998
- const observedElements = /* @__PURE__ */ new WeakMap();
11999
- const debounceThreshold = typeof sampling.visibility === "number" ? sampling.visibility : 50;
12000
- const throttledCb = throttle(
12001
- callbackWrapper((entry) => {
12002
- const target = entry.target;
12003
- const id = mirror2.getId(target);
12004
- const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
12005
- if (id !== -1) {
12006
- visibilityChangeCb({
12007
- id,
12008
- isVisible,
12009
- visibilityRatio: entry.intersectionRatio
12010
- });
12011
- }
12012
- }),
12013
- debounceThreshold,
12014
- { leading: sampling.visibility !== false, trailing: true }
12015
- );
12016
- const observer = new IntersectionObserver((entries) => {
12017
- entries.forEach((entry) => {
12018
- const target = entry.target;
12019
- if (observedElements.has(target)) {
12020
- throttledCb(entry);
12021
- } else {
12022
- observedElements.set(target, true);
12023
- }
12024
- });
12025
- }, { root: null, threshold: [0.1, 0.9] });
12026
- doc.querySelectorAll("*").forEach((el) => observer.observe(el));
12027
- const mutationObserver = new MutationObserver((mutations) => {
12028
- mutations.forEach((mutation) => {
12029
- mutation.addedNodes.forEach((node2) => {
12030
- if (node2 instanceof Element) {
12031
- observer.observe(node2);
12032
- }
12033
- });
12034
- });
12035
- });
12036
- mutationObserver.observe(doc, { childList: true, subtree: true });
12037
- return () => {
12038
- observer.disconnect();
12039
- mutationObserver.disconnect();
12040
- };
12041
- }
12042
11994
  function initMoveObserver({
12043
11995
  mousemoveCb,
12044
11996
  sampling,
@@ -12318,6 +12270,20 @@ function initInputObserver({
12318
12270
  }
12319
12271
  function cbWithDedup(target, v2) {
12320
12272
  const lastInputValue = lastInputValueMap.get(target);
12273
+ const el = target;
12274
+ const hasPlaceholder = el.hasAttribute("placeholder");
12275
+ const isEmpty = el.value === "";
12276
+ const isDefaultEmpty = typeof el.defaultValue === "string" ? el.defaultValue === "" : true;
12277
+ const isNonUser = !v2.userTriggered;
12278
+ const isRepeatEmpty = !lastInputValue || lastInputValue.text === "";
12279
+ const isLikelyPhantom = hasPlaceholder && isEmpty && isDefaultEmpty && isRepeatEmpty && isNonUser && !v2.isChecked && el.type !== "hidden" && INPUT_TAGS.includes(el.tagName);
12280
+ const isRenderDrivenTextInput = el.tagName === "INPUT" && el.type === "text" && !v2.userTriggered && v2.text === el.defaultValue && !lastInputValue && el.hasAttribute("placeholder");
12281
+ const isValueFromDefault = !v2.userTriggered && el.value === el.defaultValue && !lastInputValue && el.hasAttribute("placeholder") && !v2.isChecked && el.type !== "hidden" && INPUT_TAGS.includes(el.tagName);
12282
+ const isPhantomCheckbox = el.type === "checkbox" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
12283
+ const isPhantomRadio = el.type === "radio" && !v2.userTriggered && !v2.isChecked && !lastInputValue;
12284
+ if (isLikelyPhantom || isRenderDrivenTextInput || isValueFromDefault || isPhantomCheckbox || isPhantomRadio) {
12285
+ return;
12286
+ }
12321
12287
  if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
12322
12288
  lastInputValueMap.set(target, v2);
12323
12289
  const id = mirror2.getId(target);
@@ -12855,7 +12821,6 @@ function initCustomElementObserver({
12855
12821
  function mergeHooks(o2, hooks) {
12856
12822
  const {
12857
12823
  mutationCb,
12858
- visibilityChangeCb,
12859
12824
  mousemoveCb,
12860
12825
  mouseInteractionCb,
12861
12826
  scrollCb,
@@ -12875,12 +12840,6 @@ function mergeHooks(o2, hooks) {
12875
12840
  }
12876
12841
  mutationCb(...p);
12877
12842
  };
12878
- o2.visibilityChangeCb = (...p) => {
12879
- if (hooks.visibilityChange) {
12880
- hooks.visibilityChange(...p);
12881
- }
12882
- visibilityChangeCb(...p);
12883
- };
12884
12843
  o2.mousemoveCb = (...p) => {
12885
12844
  if (hooks.mousemove) {
12886
12845
  hooks.mousemove(...p);
@@ -12973,7 +12932,6 @@ function initObservers(o2, hooks = {}) {
12973
12932
  });
12974
12933
  const inputHandler = initInputObserver(o2);
12975
12934
  const mediaInteractionHandler = initMediaInteractionObserver(o2);
12976
- const visibleHandler = initVisibilityObserver(o2);
12977
12935
  let styleSheetObserver = () => {
12978
12936
  };
12979
12937
  let adoptedStyleSheetObserver = () => {
@@ -13003,7 +12961,6 @@ function initObservers(o2, hooks = {}) {
13003
12961
  return callbackWrapper(() => {
13004
12962
  mutationBuffers.forEach((b) => b.reset());
13005
12963
  mutationObserver == null ? void 0 : mutationObserver.disconnect();
13006
- visibleHandler();
13007
12964
  mousemoveHandler();
13008
12965
  mouseInteractionHandler();
13009
12966
  scrollHandler();
@@ -14090,12 +14047,12 @@ function record(options = {}) {
14090
14047
  emit,
14091
14048
  checkoutEveryNms,
14092
14049
  checkoutEveryNth,
14093
- checkoutEveryEvc,
14094
14050
  blockClass = "rr-block",
14095
14051
  blockSelector = null,
14096
14052
  ignoreClass = "rr-ignore",
14097
14053
  ignoreSelector = null,
14098
- ignoreAttribute = "rr-ignore",
14054
+ excludeAttribute: _excludeAttribute,
14055
+ includeAttribute: _includeAttribute,
14099
14056
  maskTextClass = "rr-mask",
14100
14057
  maskTextSelector = null,
14101
14058
  inlineStylesheet = true,
@@ -14144,6 +14101,8 @@ function record(options = {}) {
14144
14101
  sampling.mousemove = mousemoveWait;
14145
14102
  }
14146
14103
  mirror.reset();
14104
+ const excludeAttribute = _excludeAttribute === void 0 ? /^$a/ : _excludeAttribute;
14105
+ const includeAttribute = _includeAttribute === void 0 ? /.+/i : _includeAttribute;
14147
14106
  const maskInputOptions = maskAllInputs === true ? {
14148
14107
  color: true,
14149
14108
  date: true,
@@ -14220,8 +14179,7 @@ function record(options = {}) {
14220
14179
  incrementalSnapshotCount++;
14221
14180
  const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
14222
14181
  const exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
14223
- const isVisibilityChanged = checkoutEveryEvc && e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.VisibilityChange;
14224
- if (exceedCount || exceedTime || isVisibilityChanged) {
14182
+ if (exceedCount || exceedTime) {
14225
14183
  takeFullSnapshot$1(true);
14226
14184
  }
14227
14185
  }
@@ -14294,7 +14252,8 @@ function record(options = {}) {
14294
14252
  blockSelector,
14295
14253
  maskTextClass,
14296
14254
  maskTextSelector,
14297
- ignoreAttribute,
14255
+ excludeAttribute,
14256
+ includeAttribute,
14298
14257
  inlineStylesheet,
14299
14258
  maskInputOptions,
14300
14259
  dataURLOptions,
@@ -14336,7 +14295,8 @@ function record(options = {}) {
14336
14295
  blockSelector,
14337
14296
  maskTextClass,
14338
14297
  maskTextSelector,
14339
- ignoreAttribute,
14298
+ excludeAttribute,
14299
+ includeAttribute,
14340
14300
  inlineStylesheet,
14341
14301
  maskAllInputs: maskInputOptions,
14342
14302
  maskTextFn,
@@ -14392,15 +14352,6 @@ function record(options = {}) {
14392
14352
  return callbackWrapper(initObservers)(
14393
14353
  {
14394
14354
  mutationCb: wrappedMutationEmit,
14395
- visibilityChangeCb: (v2) => {
14396
- wrappedEmit({
14397
- type: EventType.IncrementalSnapshot,
14398
- data: {
14399
- source: IncrementalSource.VisibilityChange,
14400
- ...v2
14401
- }
14402
- });
14403
- },
14404
14355
  mousemoveCb: (positions, source) => wrappedEmit({
14405
14356
  type: EventType.IncrementalSnapshot,
14406
14357
  data: {
@@ -14482,7 +14433,8 @@ function record(options = {}) {
14482
14433
  ignoreSelector,
14483
14434
  maskTextClass,
14484
14435
  maskTextSelector,
14485
- ignoreAttribute,
14436
+ excludeAttribute,
14437
+ includeAttribute,
14486
14438
  maskInputOptions,
14487
14439
  inlineStylesheet,
14488
14440
  sampling,