@openreplay/tracker 5.0.1-beta.3 → 5.0.2-beta

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.
Files changed (136) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/package.json +1 -1
  3. package/cjs/app/guards.d.ts +0 -20
  4. package/cjs/app/guards.js +0 -33
  5. package/cjs/app/index.d.ts +0 -121
  6. package/cjs/app/index.js +0 -439
  7. package/cjs/app/logger.d.ts +0 -26
  8. package/cjs/app/logger.js +0 -45
  9. package/cjs/app/messages.gen.d.ts +0 -63
  10. package/cjs/app/messages.gen.js +0 -551
  11. package/cjs/app/nodes.d.ts +0 -18
  12. package/cjs/app/nodes.js +0 -82
  13. package/cjs/app/observer/iframe_observer.d.ts +0 -4
  14. package/cjs/app/observer/iframe_observer.js +0 -23
  15. package/cjs/app/observer/iframe_offsets.d.ts +0 -8
  16. package/cjs/app/observer/iframe_offsets.js +0 -59
  17. package/cjs/app/observer/observer.d.ts +0 -23
  18. package/cjs/app/observer/observer.js +0 -337
  19. package/cjs/app/observer/shadow_root_observer.d.ts +0 -4
  20. package/cjs/app/observer/shadow_root_observer.js +0 -21
  21. package/cjs/app/observer/top_observer.d.ts +0 -24
  22. package/cjs/app/observer/top_observer.js +0 -115
  23. package/cjs/app/sanitizer.d.ts +0 -24
  24. package/cjs/app/sanitizer.js +0 -76
  25. package/cjs/app/session.d.ts +0 -38
  26. package/cjs/app/session.js +0 -114
  27. package/cjs/app/ticker.d.ts +0 -12
  28. package/cjs/app/ticker.js +0 -42
  29. package/cjs/common/interaction.d.ts +0 -24
  30. package/cjs/common/interaction.js +0 -2
  31. package/cjs/common/messages.gen.d.ts +0 -427
  32. package/cjs/common/messages.gen.js +0 -4
  33. package/cjs/index.d.ts +0 -47
  34. package/cjs/index.js +0 -254
  35. package/cjs/modules/connection.d.ts +0 -2
  36. package/cjs/modules/connection.js +0 -15
  37. package/cjs/modules/console.d.ts +0 -6
  38. package/cjs/modules/console.js +0 -119
  39. package/cjs/modules/constructedStyleSheets.d.ts +0 -4
  40. package/cjs/modules/constructedStyleSheets.js +0 -131
  41. package/cjs/modules/cssrules.d.ts +0 -2
  42. package/cjs/modules/cssrules.js +0 -99
  43. package/cjs/modules/exception.d.ts +0 -16
  44. package/cjs/modules/exception.js +0 -77
  45. package/cjs/modules/focus.d.ts +0 -2
  46. package/cjs/modules/focus.js +0 -45
  47. package/cjs/modules/fonts.d.ts +0 -2
  48. package/cjs/modules/fonts.js +0 -57
  49. package/cjs/modules/img.d.ts +0 -2
  50. package/cjs/modules/img.js +0 -110
  51. package/cjs/modules/input.d.ts +0 -16
  52. package/cjs/modules/input.js +0 -163
  53. package/cjs/modules/mouse.d.ts +0 -2
  54. package/cjs/modules/mouse.js +0 -148
  55. package/cjs/modules/network.d.ts +0 -28
  56. package/cjs/modules/network.js +0 -237
  57. package/cjs/modules/performance.d.ts +0 -7
  58. package/cjs/modules/performance.js +0 -53
  59. package/cjs/modules/scroll.d.ts +0 -2
  60. package/cjs/modules/scroll.js +0 -79
  61. package/cjs/modules/timing.d.ts +0 -7
  62. package/cjs/modules/timing.js +0 -160
  63. package/cjs/modules/viewport.d.ts +0 -2
  64. package/cjs/modules/viewport.js +0 -43
  65. package/cjs/package.json +0 -1
  66. package/cjs/utils.d.ts +0 -13
  67. package/cjs/utils.js +0 -71
  68. package/cjs/vendors/finder/finder.d.ts +0 -12
  69. package/cjs/vendors/finder/finder.js +0 -352
  70. package/lib/app/guards.d.ts +0 -20
  71. package/lib/app/guards.js +0 -23
  72. package/lib/app/index.d.ts +0 -121
  73. package/lib/app/index.js +0 -435
  74. package/lib/app/logger.d.ts +0 -26
  75. package/lib/app/logger.js +0 -41
  76. package/lib/app/messages.gen.d.ts +0 -63
  77. package/lib/app/messages.gen.js +0 -486
  78. package/lib/app/nodes.d.ts +0 -18
  79. package/lib/app/nodes.js +0 -79
  80. package/lib/app/observer/iframe_observer.d.ts +0 -4
  81. package/lib/app/observer/iframe_observer.js +0 -20
  82. package/lib/app/observer/iframe_offsets.d.ts +0 -8
  83. package/lib/app/observer/iframe_offsets.js +0 -56
  84. package/lib/app/observer/observer.d.ts +0 -23
  85. package/lib/app/observer/observer.js +0 -334
  86. package/lib/app/observer/shadow_root_observer.d.ts +0 -4
  87. package/lib/app/observer/shadow_root_observer.js +0 -18
  88. package/lib/app/observer/top_observer.d.ts +0 -24
  89. package/lib/app/observer/top_observer.js +0 -112
  90. package/lib/app/sanitizer.d.ts +0 -24
  91. package/lib/app/sanitizer.js +0 -72
  92. package/lib/app/session.d.ts +0 -38
  93. package/lib/app/session.js +0 -111
  94. package/lib/app/ticker.d.ts +0 -12
  95. package/lib/app/ticker.js +0 -39
  96. package/lib/common/interaction.d.ts +0 -24
  97. package/lib/common/interaction.js +0 -1
  98. package/lib/common/messages.gen.d.ts +0 -427
  99. package/lib/common/messages.gen.js +0 -3
  100. package/lib/common/tsconfig.tsbuildinfo +0 -1
  101. package/lib/index.d.ts +0 -47
  102. package/lib/index.js +0 -248
  103. package/lib/modules/connection.d.ts +0 -2
  104. package/lib/modules/connection.js +0 -12
  105. package/lib/modules/console.d.ts +0 -6
  106. package/lib/modules/console.js +0 -116
  107. package/lib/modules/constructedStyleSheets.d.ts +0 -4
  108. package/lib/modules/constructedStyleSheets.js +0 -126
  109. package/lib/modules/cssrules.d.ts +0 -2
  110. package/lib/modules/cssrules.js +0 -97
  111. package/lib/modules/exception.d.ts +0 -16
  112. package/lib/modules/exception.js +0 -71
  113. package/lib/modules/focus.d.ts +0 -2
  114. package/lib/modules/focus.js +0 -42
  115. package/lib/modules/fonts.d.ts +0 -2
  116. package/lib/modules/fonts.js +0 -54
  117. package/lib/modules/img.d.ts +0 -2
  118. package/lib/modules/img.js +0 -107
  119. package/lib/modules/input.d.ts +0 -16
  120. package/lib/modules/input.js +0 -158
  121. package/lib/modules/mouse.d.ts +0 -2
  122. package/lib/modules/mouse.js +0 -145
  123. package/lib/modules/network.d.ts +0 -28
  124. package/lib/modules/network.js +0 -234
  125. package/lib/modules/performance.d.ts +0 -7
  126. package/lib/modules/performance.js +0 -49
  127. package/lib/modules/scroll.d.ts +0 -2
  128. package/lib/modules/scroll.js +0 -76
  129. package/lib/modules/timing.d.ts +0 -7
  130. package/lib/modules/timing.js +0 -157
  131. package/lib/modules/viewport.d.ts +0 -2
  132. package/lib/modules/viewport.js +0 -40
  133. package/lib/utils.d.ts +0 -13
  134. package/lib/utils.js +0 -61
  135. package/lib/vendors/finder/finder.d.ts +0 -12
  136. package/lib/vendors/finder/finder.js +0 -348
@@ -1,348 +0,0 @@
1
- var Limit;
2
- (function (Limit) {
3
- Limit[Limit["All"] = 0] = "All";
4
- Limit[Limit["Two"] = 1] = "Two";
5
- Limit[Limit["One"] = 2] = "One";
6
- })(Limit || (Limit = {}));
7
- let config;
8
- let rootDocument;
9
- export function finder(input, options) {
10
- if (input.nodeType !== Node.ELEMENT_NODE) {
11
- throw new Error("Can't generate CSS selector for non-element node type.");
12
- }
13
- if ('html' === input.tagName.toLowerCase()) {
14
- return 'html';
15
- }
16
- const defaults = {
17
- root: document.body,
18
- idName: (name) => true,
19
- className: (name) => true,
20
- tagName: (name) => true,
21
- attr: (name, value) => false,
22
- seedMinLength: 1,
23
- optimizedMinLength: 2,
24
- threshold: 1000,
25
- maxNumberOfTries: 10000,
26
- };
27
- config = Object.assign(Object.assign({}, defaults), options);
28
- rootDocument = findRootDocument(config.root, defaults);
29
- let path = bottomUpSearch(input, Limit.All, () => bottomUpSearch(input, Limit.Two, () => bottomUpSearch(input, Limit.One)));
30
- if (path) {
31
- const optimized = sort(optimize(path, input));
32
- if (optimized.length > 0) {
33
- path = optimized[0];
34
- }
35
- return selector(path);
36
- }
37
- else {
38
- throw new Error('Selector was not found.');
39
- }
40
- }
41
- function findRootDocument(rootNode, defaults) {
42
- if (rootNode.nodeType === Node.DOCUMENT_NODE) {
43
- return rootNode;
44
- }
45
- if (rootNode === defaults.root) {
46
- return rootNode.ownerDocument;
47
- }
48
- return rootNode;
49
- }
50
- function bottomUpSearch(input, limit, fallback) {
51
- let path = null;
52
- const stack = [];
53
- let current = input;
54
- let i = 0;
55
- while (current && current !== config.root.parentElement) {
56
- let level = maybe(id(current)) ||
57
- maybe(...attr(current)) ||
58
- maybe(...classNames(current)) ||
59
- maybe(tagName(current)) || [any()];
60
- const nth = index(current);
61
- if (limit === Limit.All) {
62
- if (nth) {
63
- level = level.concat(level.filter(dispensableNth).map((node) => nthChild(node, nth)));
64
- }
65
- }
66
- else if (limit === Limit.Two) {
67
- level = level.slice(0, 1);
68
- if (nth) {
69
- level = level.concat(level.filter(dispensableNth).map((node) => nthChild(node, nth)));
70
- }
71
- }
72
- else if (limit === Limit.One) {
73
- const [node] = (level = level.slice(0, 1));
74
- if (nth && dispensableNth(node)) {
75
- level = [nthChild(node, nth)];
76
- }
77
- }
78
- for (const node of level) {
79
- node.level = i;
80
- }
81
- stack.push(level);
82
- if (stack.length >= config.seedMinLength) {
83
- path = findUniquePath(stack, fallback);
84
- if (path) {
85
- break;
86
- }
87
- }
88
- current = current.parentElement;
89
- i++;
90
- }
91
- if (!path) {
92
- path = findUniquePath(stack, fallback);
93
- }
94
- return path;
95
- }
96
- function findUniquePath(stack, fallback) {
97
- const paths = sort(combinations(stack));
98
- if (paths.length > config.threshold) {
99
- return fallback ? fallback() : null;
100
- }
101
- for (const candidate of paths) {
102
- if (unique(candidate)) {
103
- return candidate;
104
- }
105
- }
106
- return null;
107
- }
108
- function selector(path) {
109
- let node = path[0];
110
- let query = node.name;
111
- for (let i = 1; i < path.length; i++) {
112
- const level = path[i].level || 0;
113
- if (node.level === level - 1) {
114
- query = `${path[i].name} > ${query}`;
115
- }
116
- else {
117
- query = `${path[i].name} ${query}`;
118
- }
119
- node = path[i];
120
- }
121
- return query;
122
- }
123
- function penalty(path) {
124
- return path.map((node) => node.penalty).reduce((acc, i) => acc + i, 0);
125
- }
126
- function unique(path) {
127
- switch (rootDocument.querySelectorAll(selector(path)).length) {
128
- case 0:
129
- throw new Error(`Can't select any node with this selector: ${selector(path)}`);
130
- case 1:
131
- return true;
132
- default:
133
- return false;
134
- }
135
- }
136
- function id(input) {
137
- const elementId = input.getAttribute('id');
138
- if (elementId && config.idName(elementId)) {
139
- return {
140
- name: '#' + cssesc(elementId, { isIdentifier: true }),
141
- penalty: 0,
142
- };
143
- }
144
- return null;
145
- }
146
- function attr(input) {
147
- const attrs = Array.from(input.attributes).filter((attr) => config.attr(attr.name, attr.value));
148
- return attrs.map((attr) => ({
149
- name: '[' + cssesc(attr.name, { isIdentifier: true }) + '="' + cssesc(attr.value) + '"]',
150
- penalty: 0.5,
151
- }));
152
- }
153
- function classNames(input) {
154
- const names = Array.from(input.classList).filter(config.className);
155
- return names.map((name) => ({
156
- name: '.' + cssesc(name, { isIdentifier: true }),
157
- penalty: 1,
158
- }));
159
- }
160
- function tagName(input) {
161
- const name = input.tagName.toLowerCase();
162
- if (config.tagName(name)) {
163
- return {
164
- name,
165
- penalty: 2,
166
- };
167
- }
168
- return null;
169
- }
170
- function any() {
171
- return {
172
- name: '*',
173
- penalty: 3,
174
- };
175
- }
176
- function index(input) {
177
- const parent = input.parentNode;
178
- if (!parent) {
179
- return null;
180
- }
181
- let child = parent.firstChild;
182
- if (!child) {
183
- return null;
184
- }
185
- let i = 0;
186
- while (child) {
187
- if (child.nodeType === Node.ELEMENT_NODE) {
188
- i++;
189
- }
190
- if (child === input) {
191
- break;
192
- }
193
- child = child.nextSibling;
194
- }
195
- return i;
196
- }
197
- function nthChild(node, i) {
198
- return {
199
- name: node.name + `:nth-child(${i})`,
200
- penalty: node.penalty + 1,
201
- };
202
- }
203
- function dispensableNth(node) {
204
- return node.name !== 'html' && !node.name.startsWith('#');
205
- }
206
- function maybe(...level) {
207
- const list = level.filter(notEmpty);
208
- if (list.length > 0) {
209
- return list;
210
- }
211
- return null;
212
- }
213
- function notEmpty(value) {
214
- return value !== null && value !== undefined;
215
- }
216
- function combinations(stack, path = []) {
217
- const paths = [];
218
- if (stack.length > 0) {
219
- for (const node of stack[0]) {
220
- paths.push(...combinations(stack.slice(1, stack.length), path.concat(node)));
221
- }
222
- }
223
- else {
224
- paths.push(path);
225
- }
226
- return paths;
227
- }
228
- function sort(paths) {
229
- return Array.from(paths).sort((a, b) => penalty(a) - penalty(b));
230
- }
231
- function optimize(path, input, scope = {
232
- counter: 0,
233
- visited: new Map(),
234
- }) {
235
- const paths = [];
236
- if (path.length > 2 && path.length > config.optimizedMinLength) {
237
- for (let i = 1; i < path.length - 1; i++) {
238
- if (scope.counter > config.maxNumberOfTries) {
239
- return paths; // Okay At least I tried!
240
- }
241
- scope.counter += 1;
242
- const newPath = [...path];
243
- newPath.splice(i, 1);
244
- const newPathKey = selector(newPath);
245
- if (scope.visited.has(newPathKey)) {
246
- return paths;
247
- }
248
- if (unique(newPath) && same(newPath, input)) {
249
- paths.push(newPath);
250
- scope.visited.set(newPathKey, true);
251
- paths.push(...optimize(newPath, input, scope));
252
- }
253
- }
254
- }
255
- return paths;
256
- }
257
- function same(path, input) {
258
- return rootDocument.querySelector(selector(path)) === input;
259
- }
260
- const regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
261
- const regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
262
- const regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
263
- const defaultOptions = {
264
- escapeEverything: false,
265
- isIdentifier: false,
266
- quotes: 'single',
267
- wrap: false,
268
- };
269
- function cssesc(string, opt = {}) {
270
- const options = Object.assign(Object.assign({}, defaultOptions), opt);
271
- if (options.quotes != 'single' && options.quotes != 'double') {
272
- options.quotes = 'single';
273
- }
274
- const quote = options.quotes == 'double' ? '"' : "'";
275
- const isIdentifier = options.isIdentifier;
276
- const firstChar = string.charAt(0);
277
- let output = '';
278
- let counter = 0;
279
- const length = string.length;
280
- while (counter < length) {
281
- const character = string.charAt(counter++);
282
- let codePoint = character.charCodeAt(0);
283
- let value = void 0;
284
- // If it’s not a printable ASCII character…
285
- if (codePoint < 0x20 || codePoint > 0x7e) {
286
- if (codePoint >= 0xd800 && codePoint <= 0xdbff && counter < length) {
287
- // It’s a high surrogate, and there is a next character.
288
- const extra = string.charCodeAt(counter++);
289
- if ((extra & 0xfc00) == 0xdc00) {
290
- // next character is low surrogate
291
- codePoint = ((codePoint & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
292
- }
293
- else {
294
- // It’s an unmatched surrogate; only append this code unit, in case
295
- // the next code unit is the high surrogate of a surrogate pair.
296
- counter--;
297
- }
298
- }
299
- value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
300
- }
301
- else {
302
- if (options.escapeEverything) {
303
- if (regexAnySingleEscape.test(character)) {
304
- value = '\\' + character;
305
- }
306
- else {
307
- value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
308
- }
309
- }
310
- else if (/[\t\n\f\r\x0B]/.test(character)) {
311
- value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
312
- }
313
- else if (character == '\\' ||
314
- (!isIdentifier &&
315
- ((character == '"' && quote == character) || (character == "'" && quote == character))) ||
316
- (isIdentifier && regexSingleEscape.test(character))) {
317
- value = '\\' + character;
318
- }
319
- else {
320
- value = character;
321
- }
322
- }
323
- output += value;
324
- }
325
- if (isIdentifier) {
326
- if (/^-[-\d]/.test(output)) {
327
- output = '\\-' + output.slice(1);
328
- }
329
- else if (/\d/.test(firstChar)) {
330
- output = '\\3' + firstChar + ' ' + output.slice(1);
331
- }
332
- }
333
- // Remove spaces after `\HEX` escapes that are not followed by a hex digit,
334
- // since they’re redundant. Note that this is only possible if the escape
335
- // sequence isn’t preceded by an odd number of backslashes.
336
- output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
337
- if ($1 && $1.length % 2) {
338
- // It’s not safe to remove the space, so don’t.
339
- return $0;
340
- }
341
- // Strip the space.
342
- return ($1 || '') + $2;
343
- });
344
- if (!isIdentifier && options.wrap) {
345
- return quote + output + quote;
346
- }
347
- return output;
348
- }