@openreplay/tracker 5.0.1 → 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.
- package/package.json +1 -1
- package/cjs/app/guards.d.ts +0 -21
- package/cjs/app/guards.js +0 -37
- package/cjs/app/index.d.ts +0 -118
- package/cjs/app/index.js +0 -438
- package/cjs/app/logger.d.ts +0 -26
- package/cjs/app/logger.js +0 -45
- package/cjs/app/messages.gen.d.ts +0 -63
- package/cjs/app/messages.gen.js +0 -551
- package/cjs/app/nodes.d.ts +0 -18
- package/cjs/app/nodes.js +0 -82
- package/cjs/app/observer/iframe_observer.d.ts +0 -4
- package/cjs/app/observer/iframe_observer.js +0 -23
- package/cjs/app/observer/iframe_offsets.d.ts +0 -8
- package/cjs/app/observer/iframe_offsets.js +0 -59
- package/cjs/app/observer/observer.d.ts +0 -23
- package/cjs/app/observer/observer.js +0 -340
- package/cjs/app/observer/shadow_root_observer.d.ts +0 -4
- package/cjs/app/observer/shadow_root_observer.js +0 -21
- package/cjs/app/observer/top_observer.d.ts +0 -24
- package/cjs/app/observer/top_observer.js +0 -113
- package/cjs/app/sanitizer.d.ts +0 -24
- package/cjs/app/sanitizer.js +0 -76
- package/cjs/app/session.d.ts +0 -38
- package/cjs/app/session.js +0 -114
- package/cjs/app/ticker.d.ts +0 -12
- package/cjs/app/ticker.js +0 -42
- package/cjs/common/interaction.d.ts +0 -24
- package/cjs/common/interaction.js +0 -2
- package/cjs/common/messages.gen.d.ts +0 -427
- package/cjs/common/messages.gen.js +0 -4
- package/cjs/index.d.ts +0 -47
- package/cjs/index.js +0 -254
- package/cjs/modules/connection.d.ts +0 -2
- package/cjs/modules/connection.js +0 -15
- package/cjs/modules/console.d.ts +0 -6
- package/cjs/modules/console.js +0 -119
- package/cjs/modules/constructedStyleSheets.d.ts +0 -4
- package/cjs/modules/constructedStyleSheets.js +0 -131
- package/cjs/modules/cssrules.d.ts +0 -2
- package/cjs/modules/cssrules.js +0 -99
- package/cjs/modules/exception.d.ts +0 -16
- package/cjs/modules/exception.js +0 -77
- package/cjs/modules/focus.d.ts +0 -2
- package/cjs/modules/focus.js +0 -45
- package/cjs/modules/fonts.d.ts +0 -2
- package/cjs/modules/fonts.js +0 -57
- package/cjs/modules/img.d.ts +0 -2
- package/cjs/modules/img.js +0 -110
- package/cjs/modules/input.d.ts +0 -16
- package/cjs/modules/input.js +0 -163
- package/cjs/modules/mouse.d.ts +0 -2
- package/cjs/modules/mouse.js +0 -148
- package/cjs/modules/network.d.ts +0 -28
- package/cjs/modules/network.js +0 -203
- package/cjs/modules/performance.d.ts +0 -7
- package/cjs/modules/performance.js +0 -53
- package/cjs/modules/scroll.d.ts +0 -2
- package/cjs/modules/scroll.js +0 -79
- package/cjs/modules/timing.d.ts +0 -7
- package/cjs/modules/timing.js +0 -160
- package/cjs/modules/viewport.d.ts +0 -2
- package/cjs/modules/viewport.js +0 -43
- package/cjs/package.json +0 -1
- package/cjs/utils.d.ts +0 -13
- package/cjs/utils.js +0 -71
- package/cjs/vendors/finder/finder.d.ts +0 -12
- package/cjs/vendors/finder/finder.js +0 -352
- package/lib/app/guards.d.ts +0 -21
- package/lib/app/guards.js +0 -26
- package/lib/app/index.d.ts +0 -118
- package/lib/app/index.js +0 -434
- package/lib/app/logger.d.ts +0 -26
- package/lib/app/logger.js +0 -41
- package/lib/app/messages.gen.d.ts +0 -63
- package/lib/app/messages.gen.js +0 -486
- package/lib/app/nodes.d.ts +0 -18
- package/lib/app/nodes.js +0 -79
- package/lib/app/observer/iframe_observer.d.ts +0 -4
- package/lib/app/observer/iframe_observer.js +0 -20
- package/lib/app/observer/iframe_offsets.d.ts +0 -8
- package/lib/app/observer/iframe_offsets.js +0 -56
- package/lib/app/observer/observer.d.ts +0 -23
- package/lib/app/observer/observer.js +0 -337
- package/lib/app/observer/shadow_root_observer.d.ts +0 -4
- package/lib/app/observer/shadow_root_observer.js +0 -18
- package/lib/app/observer/top_observer.d.ts +0 -24
- package/lib/app/observer/top_observer.js +0 -110
- package/lib/app/sanitizer.d.ts +0 -24
- package/lib/app/sanitizer.js +0 -72
- package/lib/app/session.d.ts +0 -38
- package/lib/app/session.js +0 -111
- package/lib/app/ticker.d.ts +0 -12
- package/lib/app/ticker.js +0 -39
- package/lib/common/interaction.d.ts +0 -24
- package/lib/common/interaction.js +0 -1
- package/lib/common/messages.gen.d.ts +0 -427
- package/lib/common/messages.gen.js +0 -3
- package/lib/common/tsconfig.tsbuildinfo +0 -1
- package/lib/index.d.ts +0 -47
- package/lib/index.js +0 -248
- package/lib/modules/connection.d.ts +0 -2
- package/lib/modules/connection.js +0 -12
- package/lib/modules/console.d.ts +0 -6
- package/lib/modules/console.js +0 -116
- package/lib/modules/constructedStyleSheets.d.ts +0 -4
- package/lib/modules/constructedStyleSheets.js +0 -126
- package/lib/modules/cssrules.d.ts +0 -2
- package/lib/modules/cssrules.js +0 -97
- package/lib/modules/exception.d.ts +0 -16
- package/lib/modules/exception.js +0 -71
- package/lib/modules/focus.d.ts +0 -2
- package/lib/modules/focus.js +0 -42
- package/lib/modules/fonts.d.ts +0 -2
- package/lib/modules/fonts.js +0 -54
- package/lib/modules/img.d.ts +0 -2
- package/lib/modules/img.js +0 -107
- package/lib/modules/input.d.ts +0 -16
- package/lib/modules/input.js +0 -158
- package/lib/modules/mouse.d.ts +0 -2
- package/lib/modules/mouse.js +0 -145
- package/lib/modules/network.d.ts +0 -28
- package/lib/modules/network.js +0 -200
- package/lib/modules/performance.d.ts +0 -7
- package/lib/modules/performance.js +0 -49
- package/lib/modules/scroll.d.ts +0 -2
- package/lib/modules/scroll.js +0 -76
- package/lib/modules/timing.d.ts +0 -7
- package/lib/modules/timing.js +0 -157
- package/lib/modules/viewport.d.ts +0 -2
- package/lib/modules/viewport.js +0 -40
- package/lib/utils.d.ts +0 -13
- package/lib/utils.js +0 -61
- package/lib/vendors/finder/finder.d.ts +0 -12
- package/lib/vendors/finder/finder.js +0 -348
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.finder = void 0;
|
|
4
|
-
var Limit;
|
|
5
|
-
(function (Limit) {
|
|
6
|
-
Limit[Limit["All"] = 0] = "All";
|
|
7
|
-
Limit[Limit["Two"] = 1] = "Two";
|
|
8
|
-
Limit[Limit["One"] = 2] = "One";
|
|
9
|
-
})(Limit || (Limit = {}));
|
|
10
|
-
let config;
|
|
11
|
-
let rootDocument;
|
|
12
|
-
function finder(input, options) {
|
|
13
|
-
if (input.nodeType !== Node.ELEMENT_NODE) {
|
|
14
|
-
throw new Error("Can't generate CSS selector for non-element node type.");
|
|
15
|
-
}
|
|
16
|
-
if ('html' === input.tagName.toLowerCase()) {
|
|
17
|
-
return 'html';
|
|
18
|
-
}
|
|
19
|
-
const defaults = {
|
|
20
|
-
root: document.body,
|
|
21
|
-
idName: (name) => true,
|
|
22
|
-
className: (name) => true,
|
|
23
|
-
tagName: (name) => true,
|
|
24
|
-
attr: (name, value) => false,
|
|
25
|
-
seedMinLength: 1,
|
|
26
|
-
optimizedMinLength: 2,
|
|
27
|
-
threshold: 1000,
|
|
28
|
-
maxNumberOfTries: 10000,
|
|
29
|
-
};
|
|
30
|
-
config = Object.assign(Object.assign({}, defaults), options);
|
|
31
|
-
rootDocument = findRootDocument(config.root, defaults);
|
|
32
|
-
let path = bottomUpSearch(input, Limit.All, () => bottomUpSearch(input, Limit.Two, () => bottomUpSearch(input, Limit.One)));
|
|
33
|
-
if (path) {
|
|
34
|
-
const optimized = sort(optimize(path, input));
|
|
35
|
-
if (optimized.length > 0) {
|
|
36
|
-
path = optimized[0];
|
|
37
|
-
}
|
|
38
|
-
return selector(path);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
throw new Error('Selector was not found.');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.finder = finder;
|
|
45
|
-
function findRootDocument(rootNode, defaults) {
|
|
46
|
-
if (rootNode.nodeType === Node.DOCUMENT_NODE) {
|
|
47
|
-
return rootNode;
|
|
48
|
-
}
|
|
49
|
-
if (rootNode === defaults.root) {
|
|
50
|
-
return rootNode.ownerDocument;
|
|
51
|
-
}
|
|
52
|
-
return rootNode;
|
|
53
|
-
}
|
|
54
|
-
function bottomUpSearch(input, limit, fallback) {
|
|
55
|
-
let path = null;
|
|
56
|
-
const stack = [];
|
|
57
|
-
let current = input;
|
|
58
|
-
let i = 0;
|
|
59
|
-
while (current && current !== config.root.parentElement) {
|
|
60
|
-
let level = maybe(id(current)) ||
|
|
61
|
-
maybe(...attr(current)) ||
|
|
62
|
-
maybe(...classNames(current)) ||
|
|
63
|
-
maybe(tagName(current)) || [any()];
|
|
64
|
-
const nth = index(current);
|
|
65
|
-
if (limit === Limit.All) {
|
|
66
|
-
if (nth) {
|
|
67
|
-
level = level.concat(level.filter(dispensableNth).map((node) => nthChild(node, nth)));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else if (limit === Limit.Two) {
|
|
71
|
-
level = level.slice(0, 1);
|
|
72
|
-
if (nth) {
|
|
73
|
-
level = level.concat(level.filter(dispensableNth).map((node) => nthChild(node, nth)));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
else if (limit === Limit.One) {
|
|
77
|
-
const [node] = (level = level.slice(0, 1));
|
|
78
|
-
if (nth && dispensableNth(node)) {
|
|
79
|
-
level = [nthChild(node, nth)];
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
for (const node of level) {
|
|
83
|
-
node.level = i;
|
|
84
|
-
}
|
|
85
|
-
stack.push(level);
|
|
86
|
-
if (stack.length >= config.seedMinLength) {
|
|
87
|
-
path = findUniquePath(stack, fallback);
|
|
88
|
-
if (path) {
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
current = current.parentElement;
|
|
93
|
-
i++;
|
|
94
|
-
}
|
|
95
|
-
if (!path) {
|
|
96
|
-
path = findUniquePath(stack, fallback);
|
|
97
|
-
}
|
|
98
|
-
return path;
|
|
99
|
-
}
|
|
100
|
-
function findUniquePath(stack, fallback) {
|
|
101
|
-
const paths = sort(combinations(stack));
|
|
102
|
-
if (paths.length > config.threshold) {
|
|
103
|
-
return fallback ? fallback() : null;
|
|
104
|
-
}
|
|
105
|
-
for (const candidate of paths) {
|
|
106
|
-
if (unique(candidate)) {
|
|
107
|
-
return candidate;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
function selector(path) {
|
|
113
|
-
let node = path[0];
|
|
114
|
-
let query = node.name;
|
|
115
|
-
for (let i = 1; i < path.length; i++) {
|
|
116
|
-
const level = path[i].level || 0;
|
|
117
|
-
if (node.level === level - 1) {
|
|
118
|
-
query = `${path[i].name} > ${query}`;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
query = `${path[i].name} ${query}`;
|
|
122
|
-
}
|
|
123
|
-
node = path[i];
|
|
124
|
-
}
|
|
125
|
-
return query;
|
|
126
|
-
}
|
|
127
|
-
function penalty(path) {
|
|
128
|
-
return path.map((node) => node.penalty).reduce((acc, i) => acc + i, 0);
|
|
129
|
-
}
|
|
130
|
-
function unique(path) {
|
|
131
|
-
switch (rootDocument.querySelectorAll(selector(path)).length) {
|
|
132
|
-
case 0:
|
|
133
|
-
throw new Error(`Can't select any node with this selector: ${selector(path)}`);
|
|
134
|
-
case 1:
|
|
135
|
-
return true;
|
|
136
|
-
default:
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
function id(input) {
|
|
141
|
-
const elementId = input.getAttribute('id');
|
|
142
|
-
if (elementId && config.idName(elementId)) {
|
|
143
|
-
return {
|
|
144
|
-
name: '#' + cssesc(elementId, { isIdentifier: true }),
|
|
145
|
-
penalty: 0,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
function attr(input) {
|
|
151
|
-
const attrs = Array.from(input.attributes).filter((attr) => config.attr(attr.name, attr.value));
|
|
152
|
-
return attrs.map((attr) => ({
|
|
153
|
-
name: '[' + cssesc(attr.name, { isIdentifier: true }) + '="' + cssesc(attr.value) + '"]',
|
|
154
|
-
penalty: 0.5,
|
|
155
|
-
}));
|
|
156
|
-
}
|
|
157
|
-
function classNames(input) {
|
|
158
|
-
const names = Array.from(input.classList).filter(config.className);
|
|
159
|
-
return names.map((name) => ({
|
|
160
|
-
name: '.' + cssesc(name, { isIdentifier: true }),
|
|
161
|
-
penalty: 1,
|
|
162
|
-
}));
|
|
163
|
-
}
|
|
164
|
-
function tagName(input) {
|
|
165
|
-
const name = input.tagName.toLowerCase();
|
|
166
|
-
if (config.tagName(name)) {
|
|
167
|
-
return {
|
|
168
|
-
name,
|
|
169
|
-
penalty: 2,
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
function any() {
|
|
175
|
-
return {
|
|
176
|
-
name: '*',
|
|
177
|
-
penalty: 3,
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
function index(input) {
|
|
181
|
-
const parent = input.parentNode;
|
|
182
|
-
if (!parent) {
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
let child = parent.firstChild;
|
|
186
|
-
if (!child) {
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
let i = 0;
|
|
190
|
-
while (child) {
|
|
191
|
-
if (child.nodeType === Node.ELEMENT_NODE) {
|
|
192
|
-
i++;
|
|
193
|
-
}
|
|
194
|
-
if (child === input) {
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
|
-
child = child.nextSibling;
|
|
198
|
-
}
|
|
199
|
-
return i;
|
|
200
|
-
}
|
|
201
|
-
function nthChild(node, i) {
|
|
202
|
-
return {
|
|
203
|
-
name: node.name + `:nth-child(${i})`,
|
|
204
|
-
penalty: node.penalty + 1,
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
function dispensableNth(node) {
|
|
208
|
-
return node.name !== 'html' && !node.name.startsWith('#');
|
|
209
|
-
}
|
|
210
|
-
function maybe(...level) {
|
|
211
|
-
const list = level.filter(notEmpty);
|
|
212
|
-
if (list.length > 0) {
|
|
213
|
-
return list;
|
|
214
|
-
}
|
|
215
|
-
return null;
|
|
216
|
-
}
|
|
217
|
-
function notEmpty(value) {
|
|
218
|
-
return value !== null && value !== undefined;
|
|
219
|
-
}
|
|
220
|
-
function combinations(stack, path = []) {
|
|
221
|
-
const paths = [];
|
|
222
|
-
if (stack.length > 0) {
|
|
223
|
-
for (const node of stack[0]) {
|
|
224
|
-
paths.push(...combinations(stack.slice(1, stack.length), path.concat(node)));
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
paths.push(path);
|
|
229
|
-
}
|
|
230
|
-
return paths;
|
|
231
|
-
}
|
|
232
|
-
function sort(paths) {
|
|
233
|
-
return Array.from(paths).sort((a, b) => penalty(a) - penalty(b));
|
|
234
|
-
}
|
|
235
|
-
function optimize(path, input, scope = {
|
|
236
|
-
counter: 0,
|
|
237
|
-
visited: new Map(),
|
|
238
|
-
}) {
|
|
239
|
-
const paths = [];
|
|
240
|
-
if (path.length > 2 && path.length > config.optimizedMinLength) {
|
|
241
|
-
for (let i = 1; i < path.length - 1; i++) {
|
|
242
|
-
if (scope.counter > config.maxNumberOfTries) {
|
|
243
|
-
return paths; // Okay At least I tried!
|
|
244
|
-
}
|
|
245
|
-
scope.counter += 1;
|
|
246
|
-
const newPath = [...path];
|
|
247
|
-
newPath.splice(i, 1);
|
|
248
|
-
const newPathKey = selector(newPath);
|
|
249
|
-
if (scope.visited.has(newPathKey)) {
|
|
250
|
-
return paths;
|
|
251
|
-
}
|
|
252
|
-
if (unique(newPath) && same(newPath, input)) {
|
|
253
|
-
paths.push(newPath);
|
|
254
|
-
scope.visited.set(newPathKey, true);
|
|
255
|
-
paths.push(...optimize(newPath, input, scope));
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return paths;
|
|
260
|
-
}
|
|
261
|
-
function same(path, input) {
|
|
262
|
-
return rootDocument.querySelector(selector(path)) === input;
|
|
263
|
-
}
|
|
264
|
-
const regexAnySingleEscape = /[ -,\.\/:-@\[-\^`\{-~]/;
|
|
265
|
-
const regexSingleEscape = /[ -,\.\/:-@\[\]\^`\{-~]/;
|
|
266
|
-
const regexExcessiveSpaces = /(^|\\+)?(\\[A-F0-9]{1,6})\x20(?![a-fA-F0-9\x20])/g;
|
|
267
|
-
const defaultOptions = {
|
|
268
|
-
escapeEverything: false,
|
|
269
|
-
isIdentifier: false,
|
|
270
|
-
quotes: 'single',
|
|
271
|
-
wrap: false,
|
|
272
|
-
};
|
|
273
|
-
function cssesc(string, opt = {}) {
|
|
274
|
-
const options = Object.assign(Object.assign({}, defaultOptions), opt);
|
|
275
|
-
if (options.quotes != 'single' && options.quotes != 'double') {
|
|
276
|
-
options.quotes = 'single';
|
|
277
|
-
}
|
|
278
|
-
const quote = options.quotes == 'double' ? '"' : "'";
|
|
279
|
-
const isIdentifier = options.isIdentifier;
|
|
280
|
-
const firstChar = string.charAt(0);
|
|
281
|
-
let output = '';
|
|
282
|
-
let counter = 0;
|
|
283
|
-
const length = string.length;
|
|
284
|
-
while (counter < length) {
|
|
285
|
-
const character = string.charAt(counter++);
|
|
286
|
-
let codePoint = character.charCodeAt(0);
|
|
287
|
-
let value = void 0;
|
|
288
|
-
// If it’s not a printable ASCII character…
|
|
289
|
-
if (codePoint < 0x20 || codePoint > 0x7e) {
|
|
290
|
-
if (codePoint >= 0xd800 && codePoint <= 0xdbff && counter < length) {
|
|
291
|
-
// It’s a high surrogate, and there is a next character.
|
|
292
|
-
const extra = string.charCodeAt(counter++);
|
|
293
|
-
if ((extra & 0xfc00) == 0xdc00) {
|
|
294
|
-
// next character is low surrogate
|
|
295
|
-
codePoint = ((codePoint & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
// It’s an unmatched surrogate; only append this code unit, in case
|
|
299
|
-
// the next code unit is the high surrogate of a surrogate pair.
|
|
300
|
-
counter--;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
|
|
304
|
-
}
|
|
305
|
-
else {
|
|
306
|
-
if (options.escapeEverything) {
|
|
307
|
-
if (regexAnySingleEscape.test(character)) {
|
|
308
|
-
value = '\\' + character;
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
else if (/[\t\n\f\r\x0B]/.test(character)) {
|
|
315
|
-
value = '\\' + codePoint.toString(16).toUpperCase() + ' ';
|
|
316
|
-
}
|
|
317
|
-
else if (character == '\\' ||
|
|
318
|
-
(!isIdentifier &&
|
|
319
|
-
((character == '"' && quote == character) || (character == "'" && quote == character))) ||
|
|
320
|
-
(isIdentifier && regexSingleEscape.test(character))) {
|
|
321
|
-
value = '\\' + character;
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
value = character;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
output += value;
|
|
328
|
-
}
|
|
329
|
-
if (isIdentifier) {
|
|
330
|
-
if (/^-[-\d]/.test(output)) {
|
|
331
|
-
output = '\\-' + output.slice(1);
|
|
332
|
-
}
|
|
333
|
-
else if (/\d/.test(firstChar)) {
|
|
334
|
-
output = '\\3' + firstChar + ' ' + output.slice(1);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
// Remove spaces after `\HEX` escapes that are not followed by a hex digit,
|
|
338
|
-
// since they’re redundant. Note that this is only possible if the escape
|
|
339
|
-
// sequence isn’t preceded by an odd number of backslashes.
|
|
340
|
-
output = output.replace(regexExcessiveSpaces, function ($0, $1, $2) {
|
|
341
|
-
if ($1 && $1.length % 2) {
|
|
342
|
-
// It’s not safe to remove the space, so don’t.
|
|
343
|
-
return $0;
|
|
344
|
-
}
|
|
345
|
-
// Strip the space.
|
|
346
|
-
return ($1 || '') + $2;
|
|
347
|
-
});
|
|
348
|
-
if (!isIdentifier && options.wrap) {
|
|
349
|
-
return quote + output + quote;
|
|
350
|
-
}
|
|
351
|
-
return output;
|
|
352
|
-
}
|
package/lib/app/guards.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare function isNode(sth: any): sth is Node;
|
|
2
|
-
export declare function isSVGElement(node: Element): node is SVGElement;
|
|
3
|
-
export declare function isElementNode(node: Node): node is Element;
|
|
4
|
-
export declare function isCommentNode(node: Node): node is Comment;
|
|
5
|
-
export declare function isTextNode(node: Node): node is Text;
|
|
6
|
-
export declare function isDocument(node: Node): node is Document;
|
|
7
|
-
export declare function isRootNode(node: Node): node is Document | DocumentFragment;
|
|
8
|
-
type TagTypeMap = {
|
|
9
|
-
html: HTMLHtmlElement;
|
|
10
|
-
body: HTMLBodyElement;
|
|
11
|
-
img: HTMLImageElement;
|
|
12
|
-
input: HTMLInputElement;
|
|
13
|
-
textarea: HTMLTextAreaElement;
|
|
14
|
-
select: HTMLSelectElement;
|
|
15
|
-
label: HTMLLabelElement;
|
|
16
|
-
iframe: HTMLIFrameElement;
|
|
17
|
-
style: HTMLStyleElement | SVGStyleElement;
|
|
18
|
-
link: HTMLLinkElement;
|
|
19
|
-
};
|
|
20
|
-
export declare function hasTag<T extends keyof TagTypeMap>(el: Node, tagName: T): el is TagTypeMap[typeof tagName];
|
|
21
|
-
export {};
|
package/lib/app/guards.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
//@ts-ignore
|
|
2
|
-
export function isNode(sth) {
|
|
3
|
-
return !!sth && sth.nodeType != null;
|
|
4
|
-
}
|
|
5
|
-
export function isSVGElement(node) {
|
|
6
|
-
return node.namespaceURI === 'http://www.w3.org/2000/svg';
|
|
7
|
-
}
|
|
8
|
-
export function isElementNode(node) {
|
|
9
|
-
return node.nodeType === Node.ELEMENT_NODE;
|
|
10
|
-
}
|
|
11
|
-
export function isCommentNode(node) {
|
|
12
|
-
return node.nodeType === Node.COMMENT_NODE;
|
|
13
|
-
}
|
|
14
|
-
export function isTextNode(node) {
|
|
15
|
-
return node.nodeType === Node.TEXT_NODE;
|
|
16
|
-
}
|
|
17
|
-
export function isDocument(node) {
|
|
18
|
-
return node.nodeType === Node.DOCUMENT_NODE;
|
|
19
|
-
}
|
|
20
|
-
export function isRootNode(node) {
|
|
21
|
-
return node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE;
|
|
22
|
-
}
|
|
23
|
-
export function hasTag(el, tagName) {
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
return el.localName === tagName;
|
|
26
|
-
}
|
package/lib/app/index.d.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import type Message from './messages.gen.js';
|
|
2
|
-
import Nodes from './nodes.js';
|
|
3
|
-
import Observer from './observer/top_observer.js';
|
|
4
|
-
import Sanitizer from './sanitizer.js';
|
|
5
|
-
import Ticker from './ticker.js';
|
|
6
|
-
import Logger from './logger.js';
|
|
7
|
-
import Session from './session.js';
|
|
8
|
-
import type { Options as ObserverOptions } from './observer/top_observer.js';
|
|
9
|
-
import type { Options as SanitizerOptions } from './sanitizer.js';
|
|
10
|
-
import type { Options as LoggerOptions } from './logger.js';
|
|
11
|
-
import type { Options as SessOptions } from './session.js';
|
|
12
|
-
import type { Options as WebworkerOptions } from '../common/interaction.js';
|
|
13
|
-
export interface StartOptions {
|
|
14
|
-
userID?: string;
|
|
15
|
-
metadata?: Record<string, string>;
|
|
16
|
-
forceNew?: boolean;
|
|
17
|
-
sessionHash?: string;
|
|
18
|
-
}
|
|
19
|
-
interface OnStartInfo {
|
|
20
|
-
sessionID: string;
|
|
21
|
-
sessionToken: string;
|
|
22
|
-
userUUID: string;
|
|
23
|
-
}
|
|
24
|
-
declare const CANCELED: "canceled";
|
|
25
|
-
type SuccessfulStart = OnStartInfo & {
|
|
26
|
-
success: true;
|
|
27
|
-
};
|
|
28
|
-
type UnsuccessfulStart = {
|
|
29
|
-
reason: typeof CANCELED | string;
|
|
30
|
-
success: false;
|
|
31
|
-
};
|
|
32
|
-
declare const UnsuccessfulStart: (reason: string) => UnsuccessfulStart;
|
|
33
|
-
declare const SuccessfulStart: (body: OnStartInfo) => SuccessfulStart;
|
|
34
|
-
export type StartPromiseReturn = SuccessfulStart | UnsuccessfulStart;
|
|
35
|
-
type StartCallback = (i: OnStartInfo) => void;
|
|
36
|
-
type CommitCallback = (messages: Array<Message>) => void;
|
|
37
|
-
type AppOptions = {
|
|
38
|
-
revID: string;
|
|
39
|
-
node_id: string;
|
|
40
|
-
session_reset_key: string;
|
|
41
|
-
session_token_key: string;
|
|
42
|
-
session_pageno_key: string;
|
|
43
|
-
local_uuid_key: string;
|
|
44
|
-
ingestPoint: string;
|
|
45
|
-
resourceBaseHref: string | null;
|
|
46
|
-
verbose: boolean;
|
|
47
|
-
__is_snippet: boolean;
|
|
48
|
-
__debug_report_edp: string | null;
|
|
49
|
-
__debug__?: LoggerOptions;
|
|
50
|
-
localStorage: Storage | null;
|
|
51
|
-
sessionStorage: Storage | null;
|
|
52
|
-
onStart?: StartCallback;
|
|
53
|
-
} & WebworkerOptions & SessOptions;
|
|
54
|
-
export type Options = AppOptions & ObserverOptions & SanitizerOptions;
|
|
55
|
-
export declare const DEFAULT_INGEST_POINT = "https://api.openreplay.com/ingest";
|
|
56
|
-
export default class App {
|
|
57
|
-
readonly nodes: Nodes;
|
|
58
|
-
readonly ticker: Ticker;
|
|
59
|
-
readonly projectKey: string;
|
|
60
|
-
readonly sanitizer: Sanitizer;
|
|
61
|
-
readonly debug: Logger;
|
|
62
|
-
readonly notify: Logger;
|
|
63
|
-
readonly session: Session;
|
|
64
|
-
readonly localStorage: Storage;
|
|
65
|
-
readonly sessionStorage: Storage;
|
|
66
|
-
private readonly messages;
|
|
67
|
-
readonly observer: Observer;
|
|
68
|
-
private readonly startCallbacks;
|
|
69
|
-
private readonly stopCallbacks;
|
|
70
|
-
private readonly commitCallbacks;
|
|
71
|
-
private readonly options;
|
|
72
|
-
private readonly revID;
|
|
73
|
-
private activityState;
|
|
74
|
-
private readonly version;
|
|
75
|
-
private readonly worker?;
|
|
76
|
-
constructor(projectKey: string, sessionToken: string | undefined, options: Partial<Options>);
|
|
77
|
-
private _debug;
|
|
78
|
-
private _usingOldFetchPlugin;
|
|
79
|
-
send(message: Message, urgent?: boolean): void;
|
|
80
|
-
private commit;
|
|
81
|
-
private delay;
|
|
82
|
-
timestamp(): number;
|
|
83
|
-
safe<T extends (this: any, ...args: any[]) => void>(fn: T): T;
|
|
84
|
-
attachCommitCallback(cb: CommitCallback): void;
|
|
85
|
-
attachStartCallback(cb: StartCallback, useSafe?: boolean): void;
|
|
86
|
-
attachStopCallback(cb: () => any, useSafe?: boolean): void;
|
|
87
|
-
attachEventListener(target: EventTarget, type: string, listener: EventListener, useSafe?: boolean, useCapture?: boolean): void;
|
|
88
|
-
checkRequiredVersion(version: string): boolean;
|
|
89
|
-
private getTrackerInfo;
|
|
90
|
-
getSessionInfo(): {
|
|
91
|
-
userUUID: string | null;
|
|
92
|
-
projectKey: string;
|
|
93
|
-
revID: string;
|
|
94
|
-
trackerVersion: string;
|
|
95
|
-
isSnippet: boolean;
|
|
96
|
-
sessionID: string | undefined;
|
|
97
|
-
metadata: Record<string, string>;
|
|
98
|
-
userID: string | null;
|
|
99
|
-
timestamp: number;
|
|
100
|
-
projectID?: string | undefined;
|
|
101
|
-
};
|
|
102
|
-
getSessionToken(): string | undefined;
|
|
103
|
-
getSessionID(): string | undefined;
|
|
104
|
-
getSessionURL(options?: {
|
|
105
|
-
withCurrentTime?: boolean;
|
|
106
|
-
}): string | undefined;
|
|
107
|
-
getHost(): string;
|
|
108
|
-
getProjectKey(): string;
|
|
109
|
-
getBaseHref(): string;
|
|
110
|
-
resolveResourceURL(resourceURL: string): string;
|
|
111
|
-
isServiceURL(url: string): boolean;
|
|
112
|
-
active(): boolean;
|
|
113
|
-
resetNextPageSession(flag: boolean): void;
|
|
114
|
-
private _start;
|
|
115
|
-
start(...args: Parameters<App['_start']>): Promise<StartPromiseReturn>;
|
|
116
|
-
stop(stopWorker?: boolean): void;
|
|
117
|
-
}
|
|
118
|
-
export {};
|