@appsurify-testmap/rrweb-snapshot 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.
package/dist/index.d.cts CHANGED
@@ -60,6 +60,8 @@ export declare interface ICanvas extends HTMLCanvasElement {
60
60
 
61
61
  export declare type idNodeMap = Map<number, Node>;
62
62
 
63
+ export declare function ignoreAttribute(tagName: string, name: string, _value: unknown): boolean;
64
+
63
65
  export declare const IGNORED_NODE = -2;
64
66
 
65
67
  export declare const interactiveEvents: string[];
@@ -78,7 +80,9 @@ export declare function isElementInteractive(n: Node): boolean;
78
80
 
79
81
  export declare function isElementVisible(n: Element): boolean;
80
82
 
81
- export declare function isIgnoreAttribute(tagName: string, name: string, _value: unknown): boolean;
83
+ export declare function isExcludeAttribute(name: string, exclude: string | RegExp): boolean;
84
+
85
+ export declare function isIncludeAttribute(name: string, include: string | RegExp): boolean;
82
86
 
83
87
  export declare function isNativeShadowDom(shadowRoot: ShadowRoot): boolean;
84
88
 
@@ -161,7 +165,8 @@ export declare function serializeNodeWithId(n: Node, options: {
161
165
  blockSelector: string | null;
162
166
  maskTextClass: string | RegExp;
163
167
  maskTextSelector: string | null;
164
- ignoreAttribute: string | RegExp;
168
+ excludeAttribute: string | RegExp;
169
+ includeAttribute: string | RegExp;
165
170
  skipChild: boolean;
166
171
  inlineStylesheet: boolean;
167
172
  newlyAddedElement?: boolean;
@@ -203,7 +208,8 @@ export declare function snapshot(n: Document, options?: {
203
208
  blockSelector?: string | null;
204
209
  maskTextClass?: string | RegExp;
205
210
  maskTextSelector?: string | null;
206
- ignoreAttribute?: string | RegExp;
211
+ excludeAttribute?: string | RegExp;
212
+ includeAttribute?: string | RegExp;
207
213
  inlineStylesheet?: boolean;
208
214
  maskAllInputs?: boolean | MaskInputOptions;
209
215
  maskTextFn?: MaskTextFn;
package/dist/index.d.ts CHANGED
@@ -60,6 +60,8 @@ export declare interface ICanvas extends HTMLCanvasElement {
60
60
 
61
61
  export declare type idNodeMap = Map<number, Node>;
62
62
 
63
+ export declare function ignoreAttribute(tagName: string, name: string, _value: unknown): boolean;
64
+
63
65
  export declare const IGNORED_NODE = -2;
64
66
 
65
67
  export declare const interactiveEvents: string[];
@@ -78,7 +80,9 @@ export declare function isElementInteractive(n: Node): boolean;
78
80
 
79
81
  export declare function isElementVisible(n: Element): boolean;
80
82
 
81
- export declare function isIgnoreAttribute(tagName: string, name: string, _value: unknown): boolean;
83
+ export declare function isExcludeAttribute(name: string, exclude: string | RegExp): boolean;
84
+
85
+ export declare function isIncludeAttribute(name: string, include: string | RegExp): boolean;
82
86
 
83
87
  export declare function isNativeShadowDom(shadowRoot: ShadowRoot): boolean;
84
88
 
@@ -161,7 +165,8 @@ export declare function serializeNodeWithId(n: Node, options: {
161
165
  blockSelector: string | null;
162
166
  maskTextClass: string | RegExp;
163
167
  maskTextSelector: string | null;
164
- ignoreAttribute: string | RegExp;
168
+ excludeAttribute: string | RegExp;
169
+ includeAttribute: string | RegExp;
165
170
  skipChild: boolean;
166
171
  inlineStylesheet: boolean;
167
172
  newlyAddedElement?: boolean;
@@ -203,7 +208,8 @@ export declare function snapshot(n: Document, options?: {
203
208
  blockSelector?: string | null;
204
209
  maskTextClass?: string | RegExp;
205
210
  maskTextSelector?: string | null;
206
- ignoreAttribute?: string | RegExp;
211
+ excludeAttribute?: string | RegExp;
212
+ includeAttribute?: string | RegExp;
207
213
  inlineStylesheet?: boolean;
208
214
  maskAllInputs?: boolean | MaskInputOptions;
209
215
  maskTextFn?: MaskTextFn;
@@ -888,28 +888,14 @@ function transformAttribute(doc, tagName, name, value) {
888
888
  }
889
889
  return value;
890
890
  }
891
- function isIgnoreAttribute(tagName, name, _value) {
891
+ function ignoreAttribute(tagName, name, _value) {
892
892
  return (tagName === "video" || tagName === "audio") && name === "autoplay";
893
893
  }
894
- function cleanAttributes(doc, element, ignoreAttribute) {
895
- const tagName = getValidTagName(element);
896
- const attributes = {};
897
- const len = element.attributes.length;
898
- for (let i = 0; i < len; i++) {
899
- const attr = element.attributes[i];
900
- const name = attr.name;
901
- const value = attr.value;
902
- const shouldIgnoreByName = typeof ignoreAttribute === "string" ? name === ignoreAttribute : ignoreAttribute.test(name);
903
- if (!shouldIgnoreByName && !isIgnoreAttribute(tagName, name)) {
904
- attributes[name] = transformAttribute(
905
- doc,
906
- tagName,
907
- toLowerCase(name),
908
- value
909
- );
910
- }
911
- }
912
- return attributes;
894
+ function isIncludeAttribute(name, include) {
895
+ return typeof include === "string" ? name.includes(include) : include.test(name);
896
+ }
897
+ function isExcludeAttribute(name, exclude) {
898
+ return typeof exclude === "string" ? name.includes(exclude) : exclude.test(name);
913
899
  }
914
900
  function _isBlockedElement(element, blockClass, blockSelector) {
915
901
  try {
@@ -1040,7 +1026,8 @@ function serializeNode(n, options) {
1040
1026
  mirror,
1041
1027
  blockClass,
1042
1028
  blockSelector,
1043
- ignoreAttribute,
1029
+ excludeAttribute,
1030
+ includeAttribute,
1044
1031
  needsMask,
1045
1032
  inlineStylesheet,
1046
1033
  maskInputOptions = {},
@@ -1086,7 +1073,8 @@ function serializeNode(n, options) {
1086
1073
  doc,
1087
1074
  blockClass,
1088
1075
  blockSelector,
1089
- ignoreAttribute,
1076
+ excludeAttribute,
1077
+ includeAttribute,
1090
1078
  inlineStylesheet,
1091
1079
  maskInputOptions,
1092
1080
  maskInputFn,
@@ -1164,7 +1152,8 @@ function serializeElementNode(n, options) {
1164
1152
  doc,
1165
1153
  blockClass,
1166
1154
  blockSelector,
1167
- ignoreAttribute,
1155
+ excludeAttribute,
1156
+ includeAttribute,
1168
1157
  inlineStylesheet,
1169
1158
  maskInputOptions = {},
1170
1159
  maskInputFn,
@@ -1178,7 +1167,22 @@ function serializeElementNode(n, options) {
1178
1167
  } = options;
1179
1168
  const needBlock = _isBlockedElement(n, blockClass, blockSelector);
1180
1169
  const tagName = getValidTagName(n);
1181
- let attributes = cleanAttributes(doc, n, ignoreAttribute);
1170
+ let attributes = {};
1171
+ const len = n.attributes.length;
1172
+ for (let i = 0; i < len; i++) {
1173
+ const attr = n.attributes[i];
1174
+ if (isExcludeAttribute(attr.name, excludeAttribute) && !isIncludeAttribute(attr.name, includeAttribute)) {
1175
+ continue;
1176
+ }
1177
+ if (!ignoreAttribute(tagName, attr.name, attr.value)) {
1178
+ attributes[attr.name] = transformAttribute(
1179
+ doc,
1180
+ tagName,
1181
+ toLowerCase(attr.name),
1182
+ attr.value
1183
+ );
1184
+ }
1185
+ }
1182
1186
  if (tagName === "link" && inlineStylesheet) {
1183
1187
  const stylesheet = Array.from(doc.styleSheets).find((s) => {
1184
1188
  return s.href === n.href;
@@ -1392,7 +1396,8 @@ function serializeNodeWithId(n, options) {
1392
1396
  blockSelector,
1393
1397
  maskTextClass,
1394
1398
  maskTextSelector,
1395
- ignoreAttribute,
1399
+ excludeAttribute,
1400
+ includeAttribute,
1396
1401
  skipChild = false,
1397
1402
  inlineStylesheet = true,
1398
1403
  maskInputOptions = {},
@@ -1427,7 +1432,8 @@ function serializeNodeWithId(n, options) {
1427
1432
  mirror,
1428
1433
  blockClass,
1429
1434
  blockSelector,
1430
- ignoreAttribute,
1435
+ excludeAttribute,
1436
+ includeAttribute,
1431
1437
  needsMask,
1432
1438
  inlineStylesheet,
1433
1439
  maskInputOptions,
@@ -1480,7 +1486,8 @@ function serializeNodeWithId(n, options) {
1480
1486
  needsMask,
1481
1487
  maskTextClass,
1482
1488
  maskTextSelector,
1483
- ignoreAttribute,
1489
+ excludeAttribute,
1490
+ includeAttribute,
1484
1491
  skipChild,
1485
1492
  inlineStylesheet,
1486
1493
  maskInputOptions,
@@ -1540,7 +1547,8 @@ function serializeNodeWithId(n, options) {
1540
1547
  needsMask,
1541
1548
  maskTextClass,
1542
1549
  maskTextSelector,
1543
- ignoreAttribute,
1550
+ excludeAttribute,
1551
+ includeAttribute,
1544
1552
  skipChild: false,
1545
1553
  inlineStylesheet,
1546
1554
  maskInputOptions,
@@ -1582,7 +1590,8 @@ function serializeNodeWithId(n, options) {
1582
1590
  needsMask,
1583
1591
  maskTextClass,
1584
1592
  maskTextSelector,
1585
- ignoreAttribute,
1593
+ excludeAttribute,
1594
+ includeAttribute,
1586
1595
  skipChild: false,
1587
1596
  inlineStylesheet,
1588
1597
  maskInputOptions,
@@ -1620,7 +1629,8 @@ function snapshot(n, options) {
1620
1629
  blockSelector = null,
1621
1630
  maskTextClass = "rr-mask",
1622
1631
  maskTextSelector = null,
1623
- ignoreAttribute = "rr-ignore",
1632
+ excludeAttribute = /^$a/,
1633
+ includeAttribute = /.+/i,
1624
1634
  inlineStylesheet = true,
1625
1635
  inlineImages = false,
1626
1636
  recordCanvas = false,
@@ -1680,7 +1690,8 @@ function snapshot(n, options) {
1680
1690
  blockSelector,
1681
1691
  maskTextClass,
1682
1692
  maskTextSelector,
1683
- ignoreAttribute,
1693
+ excludeAttribute,
1694
+ includeAttribute,
1684
1695
  skipChild: false,
1685
1696
  inlineStylesheet,
1686
1697
  maskInputOptions,
@@ -5727,6 +5738,7 @@ exports.fixSafariColons = fixSafariColons;
5727
5738
  exports.genId = genId;
5728
5739
  exports.getInputType = getInputType;
5729
5740
  exports.getXPath = getXPath;
5741
+ exports.ignoreAttribute = ignoreAttribute;
5730
5742
  exports.interactiveEvents = interactiveEvents;
5731
5743
  exports.interactiveTags = interactiveTags;
5732
5744
  exports.is2DCanvasBlank = is2DCanvasBlank;
@@ -5735,7 +5747,8 @@ exports.isCSSStyleRule = isCSSStyleRule;
5735
5747
  exports.isElement = isElement;
5736
5748
  exports.isElementInteractive = isElementInteractive;
5737
5749
  exports.isElementVisible = isElementVisible;
5738
- exports.isIgnoreAttribute = isIgnoreAttribute;
5750
+ exports.isExcludeAttribute = isExcludeAttribute;
5751
+ exports.isIncludeAttribute = isIncludeAttribute;
5739
5752
  exports.isNativeShadowDom = isNativeShadowDom;
5740
5753
  exports.isNodeMetaEqual = isNodeMetaEqual;
5741
5754
  exports.isShadowRoot = isShadowRoot;