@openreplay/tracker 7.0.2-beta.2 → 7.0.3
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/CHANGELOG.md +8 -0
- package/cjs/app/index.js +18 -23
- package/cjs/app/observer/iframe_offsets.js +4 -2
- package/cjs/app/observer/observer.js +1 -1
- package/cjs/index.js +1 -1
- package/cjs/modules/axiosSpy.d.ts +1 -0
- package/cjs/modules/axiosSpy.js +29 -5
- package/cjs/modules/constructedStyleSheets.js +2 -5
- package/cjs/modules/mouse.js +12 -21
- package/cjs/modules/network.js +13 -11
- package/cjs/utils.js +2 -1
- package/coverage/clover.xml +2461 -0
- package/coverage/coverage-final.json +38 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +176 -0
- package/coverage/lcov-report/main/app/guards.ts.html +229 -0
- package/coverage/lcov-report/main/app/index.html +206 -0
- package/coverage/lcov-report/main/app/index.ts.html +2053 -0
- package/coverage/lcov-report/main/app/logger.ts.html +277 -0
- package/coverage/lcov-report/main/app/messages.gen.ts.html +2752 -0
- package/coverage/lcov-report/main/app/nodes.ts.html +367 -0
- package/coverage/lcov-report/main/app/observer/iframe_observer.ts.html +148 -0
- package/coverage/lcov-report/main/app/observer/iframe_offsets.ts.html +289 -0
- package/coverage/lcov-report/main/app/observer/index.html +161 -0
- package/coverage/lcov-report/main/app/observer/observer.ts.html +1282 -0
- package/coverage/lcov-report/main/app/observer/shadow_root_observer.ts.html +142 -0
- package/coverage/lcov-report/main/app/observer/top_observer.ts.html +535 -0
- package/coverage/lcov-report/main/app/sanitizer.ts.html +394 -0
- package/coverage/lcov-report/main/app/session.ts.html +559 -0
- package/coverage/lcov-report/main/app/ticker.ts.html +250 -0
- package/coverage/lcov-report/main/index.html +131 -0
- package/coverage/lcov-report/main/index.ts.html +1012 -0
- package/coverage/lcov-report/main/modules/axiosSpy.ts.html +700 -0
- package/coverage/lcov-report/main/modules/connection.ts.html +160 -0
- package/coverage/lcov-report/main/modules/console.ts.html +508 -0
- package/coverage/lcov-report/main/modules/constructedStyleSheets.ts.html +559 -0
- package/coverage/lcov-report/main/modules/cssrules.ts.html +418 -0
- package/coverage/lcov-report/main/modules/exception.ts.html +385 -0
- package/coverage/lcov-report/main/modules/focus.ts.html +220 -0
- package/coverage/lcov-report/main/modules/fonts.ts.html +289 -0
- package/coverage/lcov-report/main/modules/img.ts.html +433 -0
- package/coverage/lcov-report/main/modules/index.html +371 -0
- package/coverage/lcov-report/main/modules/input.ts.html +811 -0
- package/coverage/lcov-report/main/modules/mouse.ts.html +826 -0
- package/coverage/lcov-report/main/modules/network.ts.html +1129 -0
- package/coverage/lcov-report/main/modules/performance.ts.html +367 -0
- package/coverage/lcov-report/main/modules/scroll.ts.html +364 -0
- package/coverage/lcov-report/main/modules/selection.ts.html +202 -0
- package/coverage/lcov-report/main/modules/tabs.ts.html +124 -0
- package/coverage/lcov-report/main/modules/timing.ts.html +841 -0
- package/coverage/lcov-report/main/modules/viewport.ts.html +250 -0
- package/coverage/lcov-report/main/utils.ts.html +406 -0
- package/coverage/lcov-report/main/vendors/finder/finder.ts.html +1381 -0
- package/coverage/lcov-report/main/vendors/finder/index.html +116 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/webworker/BatchWriter.ts.html +532 -0
- package/coverage/lcov-report/webworker/MessageEncoder.gen.ts.html +949 -0
- package/coverage/lcov-report/webworker/PrimitiveEncoder.ts.html +436 -0
- package/coverage/lcov-report/webworker/QueueSender.ts.html +475 -0
- package/coverage/lcov-report/webworker/StringDictionary.ts.html +124 -0
- package/coverage/lcov-report/webworker/index.html +191 -0
- package/coverage/lcov-report/webworker/index.ts.html +592 -0
- package/coverage/lcov.info +4882 -0
- package/jest.config.js +2 -0
- package/lib/app/index.js +18 -23
- package/lib/app/observer/iframe_offsets.js +4 -2
- package/lib/app/observer/observer.js +1 -1
- package/lib/common/tsconfig.tsbuildinfo +1 -1
- package/lib/index.js +1 -1
- package/lib/modules/axiosSpy.d.ts +1 -0
- package/lib/modules/axiosSpy.js +29 -5
- package/lib/modules/constructedStyleSheets.js +2 -5
- package/lib/modules/mouse.js +12 -21
- package/lib/modules/network.js +13 -11
- package/lib/utils.js +2 -1
- package/package.json +2 -3
- package/tsconfig-base.json +2 -2
- package/cjs/vendors/finder/finder.d.ts +0 -12
- package/cjs/vendors/finder/finder.js +0 -352
- package/lib/vendors/finder/finder.d.ts +0 -12
- 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 = { ...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 = { ...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
|
-
}
|