@appsurify-testmap/rrweb-all 2.1.0-alpha.2 → 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,28 +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);
900
+ }
901
+ function isExcludeAttribute(name, exclude) {
902
+ return typeof exclude === "string" ? name.includes(exclude) : exclude.test(name);
917
903
  }
918
904
  function _isBlockedElement(element, blockClass, blockSelector) {
919
905
  try {
@@ -1044,7 +1030,8 @@ function serializeNode(n2, options) {
1044
1030
  mirror: mirror2,
1045
1031
  blockClass,
1046
1032
  blockSelector,
1047
- ignoreAttribute,
1033
+ excludeAttribute,
1034
+ includeAttribute,
1048
1035
  needsMask,
1049
1036
  inlineStylesheet,
1050
1037
  maskInputOptions = {},
@@ -1090,7 +1077,8 @@ function serializeNode(n2, options) {
1090
1077
  doc,
1091
1078
  blockClass,
1092
1079
  blockSelector,
1093
- ignoreAttribute,
1080
+ excludeAttribute,
1081
+ includeAttribute,
1094
1082
  inlineStylesheet,
1095
1083
  maskInputOptions,
1096
1084
  maskInputFn,
@@ -1168,7 +1156,8 @@ function serializeElementNode(n2, options) {
1168
1156
  doc,
1169
1157
  blockClass,
1170
1158
  blockSelector,
1171
- ignoreAttribute,
1159
+ excludeAttribute,
1160
+ includeAttribute,
1172
1161
  inlineStylesheet,
1173
1162
  maskInputOptions = {},
1174
1163
  maskInputFn,
@@ -1182,7 +1171,22 @@ function serializeElementNode(n2, options) {
1182
1171
  } = options;
1183
1172
  const needBlock = _isBlockedElement(n2, blockClass, blockSelector);
1184
1173
  const tagName = getValidTagName$1(n2);
1185
- 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
+ }
1186
1190
  if (tagName === "link" && inlineStylesheet) {
1187
1191
  const stylesheet = Array.from(doc.styleSheets).find((s2) => {
1188
1192
  return s2.href === n2.href;
@@ -1396,7 +1400,8 @@ function serializeNodeWithId(n2, options) {
1396
1400
  blockSelector,
1397
1401
  maskTextClass,
1398
1402
  maskTextSelector,
1399
- ignoreAttribute,
1403
+ excludeAttribute,
1404
+ includeAttribute,
1400
1405
  skipChild = false,
1401
1406
  inlineStylesheet = true,
1402
1407
  maskInputOptions = {},
@@ -1431,7 +1436,8 @@ function serializeNodeWithId(n2, options) {
1431
1436
  mirror: mirror2,
1432
1437
  blockClass,
1433
1438
  blockSelector,
1434
- ignoreAttribute,
1439
+ excludeAttribute,
1440
+ includeAttribute,
1435
1441
  needsMask,
1436
1442
  inlineStylesheet,
1437
1443
  maskInputOptions,
@@ -1484,7 +1490,8 @@ function serializeNodeWithId(n2, options) {
1484
1490
  needsMask,
1485
1491
  maskTextClass,
1486
1492
  maskTextSelector,
1487
- ignoreAttribute,
1493
+ excludeAttribute,
1494
+ includeAttribute,
1488
1495
  skipChild,
1489
1496
  inlineStylesheet,
1490
1497
  maskInputOptions,
@@ -1544,7 +1551,8 @@ function serializeNodeWithId(n2, options) {
1544
1551
  needsMask,
1545
1552
  maskTextClass,
1546
1553
  maskTextSelector,
1547
- ignoreAttribute,
1554
+ excludeAttribute,
1555
+ includeAttribute,
1548
1556
  skipChild: false,
1549
1557
  inlineStylesheet,
1550
1558
  maskInputOptions,
@@ -1586,7 +1594,8 @@ function serializeNodeWithId(n2, options) {
1586
1594
  needsMask,
1587
1595
  maskTextClass,
1588
1596
  maskTextSelector,
1589
- ignoreAttribute,
1597
+ excludeAttribute,
1598
+ includeAttribute,
1590
1599
  skipChild: false,
1591
1600
  inlineStylesheet,
1592
1601
  maskInputOptions,
@@ -1624,7 +1633,8 @@ function snapshot(n2, options) {
1624
1633
  blockSelector = null,
1625
1634
  maskTextClass = "rr-mask",
1626
1635
  maskTextSelector = null,
1627
- ignoreAttribute = "rr-ignore",
1636
+ excludeAttribute = /^$a/,
1637
+ includeAttribute = /.+/i,
1628
1638
  inlineStylesheet = true,
1629
1639
  inlineImages = false,
1630
1640
  recordCanvas = false,
@@ -1684,7 +1694,8 @@ function snapshot(n2, options) {
1684
1694
  blockSelector,
1685
1695
  maskTextClass,
1686
1696
  maskTextSelector,
1687
- ignoreAttribute,
1697
+ excludeAttribute,
1698
+ includeAttribute,
1688
1699
  skipChild: false,
1689
1700
  inlineStylesheet,
1690
1701
  maskInputOptions,
@@ -10919,9 +10930,8 @@ function hookSetter(target, key, d, isRevoked, win = window) {
10919
10930
  );
10920
10931
  return () => hookSetter(target, key, original || {}, true);
10921
10932
  }
10922
- let nowTimestamp = Date.now;
10923
- if (!/* @__PURE__ */ /[1-9][0-9]{12}/.test(Date.now().toString())) {
10924
- nowTimestamp = () => (/* @__PURE__ */ new Date()).getTime();
10933
+ function nowTimestamp() {
10934
+ return Math.round(performance.timeOrigin + performance.now());
10925
10935
  }
10926
10936
  function getWindowScroll(win = window) {
10927
10937
  var _a2, _b2, _c, _d;
@@ -11202,9 +11212,7 @@ const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
11202
11212
  isSerializedStylesheet,
11203
11213
  iterateResolveTree,
11204
11214
  legacy_isTouchEvent,
11205
- get nowTimestamp() {
11206
- return nowTimestamp;
11207
- },
11215
+ nowTimestamp,
11208
11216
  on,
11209
11217
  polyfill: polyfill$1,
11210
11218
  queueToResolveTrees,
@@ -11240,7 +11248,6 @@ var IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => {
11240
11248
  IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
11241
11249
  IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
11242
11250
  IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
11243
- IncrementalSource2[IncrementalSource2["VisibilityChange"] = 17] = "VisibilityChange";
11244
11251
  return IncrementalSource2;
11245
11252
  })(IncrementalSource || {});
11246
11253
  var MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {
@@ -11406,7 +11413,8 @@ class MutationBuffer {
11406
11413
  __publicField(this, "blockSelector");
11407
11414
  __publicField(this, "maskTextClass");
11408
11415
  __publicField(this, "maskTextSelector");
11409
- __publicField(this, "ignoreAttribute");
11416
+ __publicField(this, "excludeAttribute");
11417
+ __publicField(this, "includeAttribute");
11410
11418
  __publicField(this, "inlineStylesheet");
11411
11419
  __publicField(this, "maskInputOptions");
11412
11420
  __publicField(this, "maskTextFn");
@@ -11470,7 +11478,8 @@ class MutationBuffer {
11470
11478
  blockSelector: this.blockSelector,
11471
11479
  maskTextClass: this.maskTextClass,
11472
11480
  maskTextSelector: this.maskTextSelector,
11473
- ignoreAttribute: this.ignoreAttribute || "",
11481
+ excludeAttribute: this.excludeAttribute,
11482
+ includeAttribute: this.includeAttribute,
11474
11483
  skipChild: true,
11475
11484
  newlyAddedElement: true,
11476
11485
  inlineStylesheet: this.inlineStylesheet,
@@ -11672,6 +11681,14 @@ class MutationBuffer {
11672
11681
  const target = m.target;
11673
11682
  let attributeName = m.attributeName;
11674
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)) {
11690
+ return;
11691
+ }
11675
11692
  if (attributeName === "value") {
11676
11693
  const type = getInputType(target);
11677
11694
  value = maskInputValue({
@@ -11707,13 +11724,21 @@ class MutationBuffer {
11707
11724
  if (attributeName === "type" && target.tagName === "INPUT" && (m.oldValue || "").toLowerCase() === "password") {
11708
11725
  target.setAttribute("data-rr-is-password", "true");
11709
11726
  }
11710
- if (!isIgnoreAttribute(target.tagName, attributeName)) {
11727
+ if (!ignoreAttribute(target.tagName, attributeName)) {
11711
11728
  item.attributes[attributeName] = transformAttribute(
11712
11729
  this.doc,
11713
11730
  toLowerCase(target.tagName),
11714
11731
  toLowerCase(attributeName),
11715
11732
  value
11716
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
+ }
11717
11742
  if (attributeName === "style") {
11718
11743
  if (!this.unattachedDoc) {
11719
11744
  try {
@@ -11826,7 +11851,8 @@ class MutationBuffer {
11826
11851
  "blockSelector",
11827
11852
  "maskTextClass",
11828
11853
  "maskTextSelector",
11829
- "ignoreAttribute",
11854
+ "excludeAttribute",
11855
+ "includeAttribute",
11830
11856
  "inlineStylesheet",
11831
11857
  "maskInputOptions",
11832
11858
  "maskTextFn",
@@ -11965,60 +11991,6 @@ function initMutationObserver(options, rootEl) {
11965
11991
  });
11966
11992
  return observer;
11967
11993
  }
11968
- function initVisibilityObserver({
11969
- visibilityChangeCb,
11970
- doc,
11971
- mirror: mirror2,
11972
- sampling
11973
- }) {
11974
- if (!visibilityChangeCb) {
11975
- return () => {
11976
- };
11977
- }
11978
- const observedElements = /* @__PURE__ */ new WeakMap();
11979
- const debounceThreshold = typeof sampling.visibility === "number" ? sampling.visibility : 50;
11980
- const throttledCb = throttle(
11981
- callbackWrapper((entry) => {
11982
- const target = entry.target;
11983
- const id = mirror2.getId(target);
11984
- const isVisible = entry.isIntersecting || entry.intersectionRatio > 0;
11985
- if (id !== -1) {
11986
- visibilityChangeCb({
11987
- id,
11988
- isVisible,
11989
- visibilityRatio: entry.intersectionRatio
11990
- });
11991
- }
11992
- }),
11993
- debounceThreshold,
11994
- { leading: sampling.visibility !== false, trailing: true }
11995
- );
11996
- const observer = new IntersectionObserver((entries) => {
11997
- entries.forEach((entry) => {
11998
- const target = entry.target;
11999
- if (observedElements.has(target)) {
12000
- throttledCb(entry);
12001
- } else {
12002
- observedElements.set(target, true);
12003
- }
12004
- });
12005
- }, { root: null, threshold: [0.1, 0.9] });
12006
- doc.querySelectorAll("*").forEach((el) => observer.observe(el));
12007
- const mutationObserver = new MutationObserver((mutations) => {
12008
- mutations.forEach((mutation) => {
12009
- mutation.addedNodes.forEach((node2) => {
12010
- if (node2 instanceof Element) {
12011
- observer.observe(node2);
12012
- }
12013
- });
12014
- });
12015
- });
12016
- mutationObserver.observe(doc, { childList: true, subtree: true });
12017
- return () => {
12018
- observer.disconnect();
12019
- mutationObserver.disconnect();
12020
- };
12021
- }
12022
11994
  function initMoveObserver({
12023
11995
  mousemoveCb,
12024
11996
  sampling,
@@ -12298,6 +12270,20 @@ function initInputObserver({
12298
12270
  }
12299
12271
  function cbWithDedup(target, v2) {
12300
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
+ }
12301
12287
  if (!lastInputValue || lastInputValue.text !== v2.text || lastInputValue.isChecked !== v2.isChecked) {
12302
12288
  lastInputValueMap.set(target, v2);
12303
12289
  const id = mirror2.getId(target);
@@ -12835,7 +12821,6 @@ function initCustomElementObserver({
12835
12821
  function mergeHooks(o2, hooks) {
12836
12822
  const {
12837
12823
  mutationCb,
12838
- visibilityChangeCb,
12839
12824
  mousemoveCb,
12840
12825
  mouseInteractionCb,
12841
12826
  scrollCb,
@@ -12855,12 +12840,6 @@ function mergeHooks(o2, hooks) {
12855
12840
  }
12856
12841
  mutationCb(...p);
12857
12842
  };
12858
- o2.visibilityChangeCb = (...p) => {
12859
- if (hooks.visibilityChange) {
12860
- hooks.visibilityChange(...p);
12861
- }
12862
- visibilityChangeCb(...p);
12863
- };
12864
12843
  o2.mousemoveCb = (...p) => {
12865
12844
  if (hooks.mousemove) {
12866
12845
  hooks.mousemove(...p);
@@ -12953,7 +12932,6 @@ function initObservers(o2, hooks = {}) {
12953
12932
  });
12954
12933
  const inputHandler = initInputObserver(o2);
12955
12934
  const mediaInteractionHandler = initMediaInteractionObserver(o2);
12956
- const visibleHandler = initVisibilityObserver(o2);
12957
12935
  let styleSheetObserver = () => {
12958
12936
  };
12959
12937
  let adoptedStyleSheetObserver = () => {
@@ -12983,7 +12961,6 @@ function initObservers(o2, hooks = {}) {
12983
12961
  return callbackWrapper(() => {
12984
12962
  mutationBuffers.forEach((b) => b.reset());
12985
12963
  mutationObserver == null ? void 0 : mutationObserver.disconnect();
12986
- visibleHandler();
12987
12964
  mousemoveHandler();
12988
12965
  mouseInteractionHandler();
12989
12966
  scrollHandler();
@@ -14070,12 +14047,12 @@ function record(options = {}) {
14070
14047
  emit,
14071
14048
  checkoutEveryNms,
14072
14049
  checkoutEveryNth,
14073
- checkoutEveryEvc,
14074
14050
  blockClass = "rr-block",
14075
14051
  blockSelector = null,
14076
14052
  ignoreClass = "rr-ignore",
14077
14053
  ignoreSelector = null,
14078
- ignoreAttribute = "rr-ignore",
14054
+ excludeAttribute: _excludeAttribute,
14055
+ includeAttribute: _includeAttribute,
14079
14056
  maskTextClass = "rr-mask",
14080
14057
  maskTextSelector = null,
14081
14058
  inlineStylesheet = true,
@@ -14124,6 +14101,8 @@ function record(options = {}) {
14124
14101
  sampling.mousemove = mousemoveWait;
14125
14102
  }
14126
14103
  mirror.reset();
14104
+ const excludeAttribute = _excludeAttribute === void 0 ? /^$a/ : _excludeAttribute;
14105
+ const includeAttribute = _includeAttribute === void 0 ? /.+/i : _includeAttribute;
14127
14106
  const maskInputOptions = maskAllInputs === true ? {
14128
14107
  color: true,
14129
14108
  date: true,
@@ -14200,8 +14179,7 @@ function record(options = {}) {
14200
14179
  incrementalSnapshotCount++;
14201
14180
  const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
14202
14181
  const exceedTime = checkoutEveryNms && e2.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
14203
- const isVisibilityChanged = checkoutEveryEvc && e2.type === EventType.IncrementalSnapshot && e2.data.source === IncrementalSource.VisibilityChange;
14204
- if (exceedCount || exceedTime || isVisibilityChanged) {
14182
+ if (exceedCount || exceedTime) {
14205
14183
  takeFullSnapshot$1(true);
14206
14184
  }
14207
14185
  }
@@ -14274,7 +14252,8 @@ function record(options = {}) {
14274
14252
  blockSelector,
14275
14253
  maskTextClass,
14276
14254
  maskTextSelector,
14277
- ignoreAttribute,
14255
+ excludeAttribute,
14256
+ includeAttribute,
14278
14257
  inlineStylesheet,
14279
14258
  maskInputOptions,
14280
14259
  dataURLOptions,
@@ -14316,7 +14295,8 @@ function record(options = {}) {
14316
14295
  blockSelector,
14317
14296
  maskTextClass,
14318
14297
  maskTextSelector,
14319
- ignoreAttribute,
14298
+ excludeAttribute,
14299
+ includeAttribute,
14320
14300
  inlineStylesheet,
14321
14301
  maskAllInputs: maskInputOptions,
14322
14302
  maskTextFn,
@@ -14372,15 +14352,6 @@ function record(options = {}) {
14372
14352
  return callbackWrapper(initObservers)(
14373
14353
  {
14374
14354
  mutationCb: wrappedMutationEmit,
14375
- visibilityChangeCb: (v2) => {
14376
- wrappedEmit({
14377
- type: EventType.IncrementalSnapshot,
14378
- data: {
14379
- source: IncrementalSource.VisibilityChange,
14380
- ...v2
14381
- }
14382
- });
14383
- },
14384
14355
  mousemoveCb: (positions, source) => wrappedEmit({
14385
14356
  type: EventType.IncrementalSnapshot,
14386
14357
  data: {
@@ -14462,7 +14433,8 @@ function record(options = {}) {
14462
14433
  ignoreSelector,
14463
14434
  maskTextClass,
14464
14435
  maskTextSelector,
14465
- ignoreAttribute,
14436
+ excludeAttribute,
14437
+ includeAttribute,
14466
14438
  maskInputOptions,
14467
14439
  inlineStylesheet,
14468
14440
  sampling,