@appsurify-testmap/rrweb-snapshot 2.0.0-alpha.21 → 2.0.0-alpha.23

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
@@ -52,7 +52,7 @@ export declare function genId(): number;
52
52
 
53
53
  export declare function getInputType(element: HTMLElement): Lowercase<string> | null;
54
54
 
55
- export declare function getXPath(n: Element): string;
55
+ export declare function getXPath(node: Node): string;
56
56
 
57
57
  export declare interface ICanvas extends HTMLCanvasElement {
58
58
  __context: string;
package/dist/index.d.ts CHANGED
@@ -52,7 +52,7 @@ export declare function genId(): number;
52
52
 
53
53
  export declare function getInputType(element: HTMLElement): Lowercase<string> | null;
54
54
 
55
- export declare function getXPath(n: Element): string;
55
+ export declare function getXPath(node: Node): string;
56
56
 
57
57
  export declare interface ICanvas extends HTMLCanvasElement {
58
58
  __context: string;
@@ -154,23 +154,71 @@ const index = {
154
154
  querySelectorAll,
155
155
  mutationObserver: mutationObserverCtor
156
156
  };
157
- function getXPath(n) {
158
- if (n.id) {
159
- return `//*[@id="${n.id}"]`;
157
+ function getXPath(node2) {
158
+ if (node2.nodeType === Node.DOCUMENT_NODE) {
159
+ return "/";
160
160
  }
161
- if (n === document.body) {
162
- return "/html/body";
161
+ if (node2.nodeType === Node.DOCUMENT_TYPE_NODE) {
162
+ return "/html/doctype";
163
163
  }
164
- const parentNode2 = index.parentNode(n);
165
- if (!parentNode2 || !(parentNode2 instanceof Element)) {
166
- return "";
164
+ if (node2.nodeType === Node.ELEMENT_NODE) {
165
+ const element = node2;
166
+ if (element.id) {
167
+ return `//*[@id="${element.id}"]`;
168
+ }
169
+ if (element.tagName && element.tagName.toLowerCase() === "html") {
170
+ return "/html";
171
+ }
172
+ if (element === document.head) {
173
+ return "/html/head";
174
+ }
175
+ if (element === document.body) {
176
+ return "/html/body";
177
+ }
178
+ const parentNode2 = element.parentNode;
179
+ if (!parentNode2 || !(parentNode2 instanceof Element)) {
180
+ return "";
181
+ }
182
+ const siblings = Array.from(parentNode2.children).filter(
183
+ (sibling) => sibling.tagName === element.tagName
184
+ );
185
+ const index2 = siblings.length > 1 ? `[${siblings.indexOf(element) + 1}]` : "";
186
+ return `${getXPath(parentNode2)}/${element.tagName.toLowerCase()}${index2}`;
167
187
  }
168
- const siblings = Array.from(parentNode2.children).filter(
169
- (node2) => node2.tagName === n.tagName
170
- );
171
- const index$1 = siblings.length > 1 ? `[${siblings.indexOf(n) + 1}]` : "";
172
- const path = getXPath(parentNode2) + "/" + n.tagName.toLowerCase() + index$1;
173
- return path;
188
+ if (node2.nodeType === Node.TEXT_NODE) {
189
+ const parent = node2.parentNode;
190
+ if (!parent) {
191
+ return "";
192
+ }
193
+ const textSiblings = Array.from(parent.childNodes).filter(
194
+ (sibling) => sibling.nodeType === Node.TEXT_NODE
195
+ );
196
+ const index2 = textSiblings.length > 1 ? `[${textSiblings.indexOf(node2) + 1}]` : "";
197
+ return `${getXPath(parent)}/text()${index2}`;
198
+ }
199
+ if (node2.nodeType === Node.CDATA_SECTION_NODE) {
200
+ const parent = node2.parentNode;
201
+ if (!parent) {
202
+ return "";
203
+ }
204
+ const cdataSiblings = Array.from(parent.childNodes).filter(
205
+ (sibling) => sibling.nodeType === Node.CDATA_SECTION_NODE
206
+ );
207
+ const index2 = cdataSiblings.length > 1 ? `[${cdataSiblings.indexOf(node2) + 1}]` : "";
208
+ return `${getXPath(parent)}/text()${index2}`;
209
+ }
210
+ if (node2.nodeType === Node.COMMENT_NODE) {
211
+ const parent = node2.parentNode;
212
+ if (!parent) {
213
+ return "";
214
+ }
215
+ const commentSiblings = Array.from(parent.childNodes).filter(
216
+ (sibling) => sibling.nodeType === Node.COMMENT_NODE
217
+ );
218
+ const index2 = commentSiblings.length > 1 ? `[${commentSiblings.indexOf(node2) + 1}]` : "";
219
+ return `${getXPath(parent)}/comment()${index2}`;
220
+ }
221
+ return "";
174
222
  }
175
223
  function isElement(n) {
176
224
  return n.nodeType === n.ELEMENT_NODE;
@@ -1951,7 +1999,7 @@ function cloneNode(obj, parent) {
1951
1999
  }
1952
2000
  return cloned;
1953
2001
  }
1954
- let Node$4 = class Node {
2002
+ let Node$5 = class Node2 {
1955
2003
  constructor(defaults = {}) {
1956
2004
  this.raws = {};
1957
2005
  this[isClean$2] = false;
@@ -2243,10 +2291,10 @@ let Node$4 = class Node {
2243
2291
  return this;
2244
2292
  }
2245
2293
  };
2246
- var node = Node$4;
2247
- Node$4.default = Node$4;
2248
- let Node$3 = node;
2249
- let Declaration$4 = class Declaration extends Node$3 {
2294
+ var node = Node$5;
2295
+ Node$5.default = Node$5;
2296
+ let Node$4 = node;
2297
+ let Declaration$4 = class Declaration extends Node$4 {
2250
2298
  constructor(defaults) {
2251
2299
  if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
2252
2300
  defaults = { ...defaults, value: String(defaults.value) };
@@ -2902,8 +2950,8 @@ let MapGenerator$2 = class MapGenerator {
2902
2950
  }
2903
2951
  };
2904
2952
  var mapGenerator = MapGenerator$2;
2905
- let Node$2 = node;
2906
- let Comment$4 = class Comment extends Node$2 {
2953
+ let Node$3 = node;
2954
+ let Comment$4 = class Comment extends Node$3 {
2907
2955
  constructor(defaults) {
2908
2956
  super(defaults);
2909
2957
  this.type = "comment";
@@ -2914,7 +2962,7 @@ Comment$4.default = Comment$4;
2914
2962
  let { isClean: isClean$1, my: my$1 } = symbols;
2915
2963
  let Declaration$3 = declaration;
2916
2964
  let Comment$3 = comment;
2917
- let Node$1 = node;
2965
+ let Node$2 = node;
2918
2966
  let parse$4, Rule$4, AtRule$4, Root$6;
2919
2967
  function cleanSource(nodes) {
2920
2968
  return nodes.map((i) => {
@@ -2931,7 +2979,7 @@ function markDirtyUp(node2) {
2931
2979
  }
2932
2980
  }
2933
2981
  }
2934
- let Container$7 = class Container extends Node$1 {
2982
+ let Container$7 = class Container extends Node$2 {
2935
2983
  append(...children) {
2936
2984
  for (let child of children) {
2937
2985
  let nodes = this.normalize(child, this.last);
@@ -4958,7 +5006,7 @@ let parse = parse_1;
4958
5006
  let list = list_1;
4959
5007
  let Rule2 = rule;
4960
5008
  let Root2 = root;
4961
- let Node2 = node;
5009
+ let Node$1 = node;
4962
5010
  function postcss(...plugins) {
4963
5011
  if (plugins.length === 1 && Array.isArray(plugins[0])) {
4964
5012
  plugins = plugins[0];
@@ -5018,7 +5066,7 @@ postcss.Result = Result2;
5018
5066
  postcss.Input = Input2;
5019
5067
  postcss.Rule = Rule2;
5020
5068
  postcss.Root = Root2;
5021
- postcss.Node = Node2;
5069
+ postcss.Node = Node$1;
5022
5070
  LazyResult2.registerPostcss(postcss);
5023
5071
  var postcss_1 = postcss;
5024
5072
  postcss.default = postcss;