@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
package/cjs/modules/exception.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getExceptionMessageFromEvent = exports.getExceptionMessage = void 0;
|
|
4
|
-
const messages_gen_js_1 = require("../app/messages.gen.js");
|
|
5
|
-
const error_stack_parser_1 = require("error-stack-parser");
|
|
6
|
-
function getDefaultStack(e) {
|
|
7
|
-
return [
|
|
8
|
-
{
|
|
9
|
-
columnNumber: e.colno,
|
|
10
|
-
lineNumber: e.lineno,
|
|
11
|
-
fileName: e.filename,
|
|
12
|
-
functionName: '',
|
|
13
|
-
source: '',
|
|
14
|
-
},
|
|
15
|
-
];
|
|
16
|
-
}
|
|
17
|
-
function getExceptionMessage(error, fallbackStack, metadata = {}) {
|
|
18
|
-
let stack = fallbackStack;
|
|
19
|
-
try {
|
|
20
|
-
stack = error_stack_parser_1.default.parse(error);
|
|
21
|
-
}
|
|
22
|
-
catch (e) { }
|
|
23
|
-
return (0, messages_gen_js_1.JSException)(error.name, error.message, JSON.stringify(stack), JSON.stringify(metadata));
|
|
24
|
-
}
|
|
25
|
-
exports.getExceptionMessage = getExceptionMessage;
|
|
26
|
-
function getExceptionMessageFromEvent(e, context = window, metadata = {}) {
|
|
27
|
-
if (e instanceof ErrorEvent) {
|
|
28
|
-
if (e.error instanceof Error) {
|
|
29
|
-
return getExceptionMessage(e.error, getDefaultStack(e), metadata);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
let [name, message] = e.message.split(':');
|
|
33
|
-
if (!message) {
|
|
34
|
-
name = 'Error';
|
|
35
|
-
message = e.message;
|
|
36
|
-
}
|
|
37
|
-
return (0, messages_gen_js_1.JSException)(name, message, JSON.stringify(getDefaultStack(e)), JSON.stringify(metadata));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else if ('PromiseRejectionEvent' in context && e instanceof context.PromiseRejectionEvent) {
|
|
41
|
-
if (e.reason instanceof Error) {
|
|
42
|
-
return getExceptionMessage(e.reason, [], metadata);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
let message;
|
|
46
|
-
try {
|
|
47
|
-
message = JSON.stringify(e.reason);
|
|
48
|
-
}
|
|
49
|
-
catch (_) {
|
|
50
|
-
message = String(e.reason);
|
|
51
|
-
}
|
|
52
|
-
return (0, messages_gen_js_1.JSException)('Unhandled Promise Rejection', message, '[]', JSON.stringify(metadata));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
exports.getExceptionMessageFromEvent = getExceptionMessageFromEvent;
|
|
58
|
-
function default_1(app, opts) {
|
|
59
|
-
const options = Object.assign({
|
|
60
|
-
captureExceptions: true,
|
|
61
|
-
}, opts);
|
|
62
|
-
function patchContext(context) {
|
|
63
|
-
function handler(e) {
|
|
64
|
-
const msg = getExceptionMessageFromEvent(e, context);
|
|
65
|
-
if (msg != null) {
|
|
66
|
-
app.send(msg);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
app.attachEventListener(context, 'unhandledrejection', handler);
|
|
70
|
-
app.attachEventListener(context, 'error', handler);
|
|
71
|
-
}
|
|
72
|
-
if (options.captureExceptions) {
|
|
73
|
-
app.observer.attachContextCallback(patchContext); // TODO: attach once-per-iframe (?)
|
|
74
|
-
patchContext(window);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
exports.default = default_1;
|
package/cjs/modules/focus.d.ts
DELETED
package/cjs/modules/focus.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const guards_js_1 = require("../app/guards.js");
|
|
4
|
-
const messages_gen_js_1 = require("../app/messages.gen.js");
|
|
5
|
-
function default_1(app) {
|
|
6
|
-
function sendSetNodeFocus(n) {
|
|
7
|
-
const id = app.nodes.getID(n);
|
|
8
|
-
if (id !== undefined) {
|
|
9
|
-
app.send((0, messages_gen_js_1.SetNodeFocus)(id));
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
let blurred = false;
|
|
13
|
-
app.nodes.attachNodeCallback((node) => {
|
|
14
|
-
if (!(0, guards_js_1.hasTag)(node, 'body')) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
app.nodes.attachNodeListener(node, 'focus', (e) => {
|
|
18
|
-
if (!(0, guards_js_1.isNode)(e.target)) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
sendSetNodeFocus(e.target);
|
|
22
|
-
blurred = false;
|
|
23
|
-
});
|
|
24
|
-
app.nodes.attachNodeListener(node, 'blur', (e) => {
|
|
25
|
-
if (e.relatedTarget === null) {
|
|
26
|
-
blurred = true;
|
|
27
|
-
setTimeout(() => {
|
|
28
|
-
if (blurred) {
|
|
29
|
-
app.send((0, messages_gen_js_1.SetNodeFocus)(-1));
|
|
30
|
-
}
|
|
31
|
-
}, 0);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
app.attachStartCallback(() => {
|
|
36
|
-
let elem = document.activeElement;
|
|
37
|
-
while (elem && (0, guards_js_1.hasTag)(elem, 'iframe') && elem.contentDocument) {
|
|
38
|
-
elem = elem.contentDocument.activeElement;
|
|
39
|
-
}
|
|
40
|
-
if (elem && elem !== elem.ownerDocument.body) {
|
|
41
|
-
sendSetNodeFocus(elem);
|
|
42
|
-
}
|
|
43
|
-
}, true);
|
|
44
|
-
}
|
|
45
|
-
exports.default = default_1;
|
package/cjs/modules/fonts.d.ts
DELETED
package/cjs/modules/fonts.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const guards_js_1 = require("../app/guards.js");
|
|
4
|
-
const messages_gen_js_1 = require("../app/messages.gen.js");
|
|
5
|
-
function default_1(app) {
|
|
6
|
-
if (!window.FontFace) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
const docFonts = new Map();
|
|
10
|
-
const patchWindow = (wnd) => {
|
|
11
|
-
class FontFaceInterceptor extends wnd.FontFace {
|
|
12
|
-
constructor(...args) {
|
|
13
|
-
//maybe do this on load(). In this case check if the document.fonts.load(...) function calls the font's load()
|
|
14
|
-
if (typeof args[1] === 'string') {
|
|
15
|
-
let desc = '';
|
|
16
|
-
if (args[2]) {
|
|
17
|
-
app.safe(() => {
|
|
18
|
-
desc = JSON.stringify(args[2]);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
const ffData = [args[0], args[1], desc];
|
|
22
|
-
const ffDataArr = docFonts.get(wnd.document) || [];
|
|
23
|
-
ffDataArr.push(ffData);
|
|
24
|
-
docFonts.set(wnd.document, ffDataArr);
|
|
25
|
-
const parentID = wnd === window ? 0 : app.nodes.getID(wnd.document);
|
|
26
|
-
if (parentID === undefined) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (app.active()) {
|
|
30
|
-
app.send((0, messages_gen_js_1.LoadFontFace)(parentID, ...ffData));
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
super(...args);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
wnd.FontFace = FontFaceInterceptor;
|
|
37
|
-
};
|
|
38
|
-
app.observer.attachContextCallback(patchWindow);
|
|
39
|
-
patchWindow(window);
|
|
40
|
-
app.nodes.attachNodeCallback(app.safe((node) => {
|
|
41
|
-
if (!(0, guards_js_1.isDocument)(node)) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const ffDataArr = docFonts.get(node);
|
|
45
|
-
if (!ffDataArr) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const parentID = node.defaultView === window ? 0 : app.nodes.getID(node);
|
|
49
|
-
if (parentID === undefined) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
ffDataArr.forEach((ffData) => {
|
|
53
|
-
app.send((0, messages_gen_js_1.LoadFontFace)(parentID, ...ffData));
|
|
54
|
-
});
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
exports.default = default_1;
|
package/cjs/modules/img.d.ts
DELETED
package/cjs/modules/img.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_js_1 = require("../utils.js");
|
|
4
|
-
const messages_gen_js_1 = require("../app/messages.gen.js");
|
|
5
|
-
const guards_js_1 = require("../app/guards.js");
|
|
6
|
-
function resolveURL(url, location = document.location) {
|
|
7
|
-
url = url.trim();
|
|
8
|
-
if (url.startsWith('//') ||
|
|
9
|
-
url.startsWith('http://') ||
|
|
10
|
-
url.startsWith('https://') ||
|
|
11
|
-
url.startsWith('data:') // any other possible value here? https://bugzilla.mozilla.org/show_bug.cgi?id=1758035
|
|
12
|
-
) {
|
|
13
|
-
return url;
|
|
14
|
-
}
|
|
15
|
-
else if (url.startsWith('/')) {
|
|
16
|
-
return location.origin + url;
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return location.origin + location.pathname + url;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
// https://bugzilla.mozilla.org/show_bug.cgi?id=1607081
|
|
23
|
-
function isSVGInFireFox(url) {
|
|
24
|
-
return utils_js_1.IS_FIREFOX && (url.startsWith('data:image/svg+xml') || url.match(/.svg$|/i));
|
|
25
|
-
}
|
|
26
|
-
const PLACEHOLDER_SRC = 'https://static.openreplay.com/tracker/placeholder.jpeg';
|
|
27
|
-
function default_1(app) {
|
|
28
|
-
function sendPlaceholder(id, node) {
|
|
29
|
-
app.send((0, messages_gen_js_1.SetNodeAttribute)(id, 'src', PLACEHOLDER_SRC));
|
|
30
|
-
const { width, height } = node.getBoundingClientRect();
|
|
31
|
-
if (!node.hasAttribute('width')) {
|
|
32
|
-
app.send((0, messages_gen_js_1.SetNodeAttribute)(id, 'width', String(width)));
|
|
33
|
-
}
|
|
34
|
-
if (!node.hasAttribute('height')) {
|
|
35
|
-
app.send((0, messages_gen_js_1.SetNodeAttribute)(id, 'height', String(height)));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const sendSrcset = function (id, img) {
|
|
39
|
-
const { srcset } = img;
|
|
40
|
-
if (!srcset) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const resolvedSrcset = srcset
|
|
44
|
-
.split(',')
|
|
45
|
-
.map((str) => resolveURL(str))
|
|
46
|
-
.join(',');
|
|
47
|
-
app.send((0, messages_gen_js_1.SetNodeAttribute)(id, 'srcset', resolvedSrcset));
|
|
48
|
-
};
|
|
49
|
-
const sendSrc = function (id, img) {
|
|
50
|
-
if (img.src.length > utils_js_1.MAX_STR_LEN) {
|
|
51
|
-
sendPlaceholder(id, img);
|
|
52
|
-
}
|
|
53
|
-
app.send((0, messages_gen_js_1.SetNodeAttributeURLBased)(id, 'src', img.src, app.getBaseHref()));
|
|
54
|
-
};
|
|
55
|
-
const sendImgError = app.safe(function (img) {
|
|
56
|
-
const resolvedSrc = resolveURL(img.src || ''); // Src type is null sometimes. - is it true?
|
|
57
|
-
if ((0, utils_js_1.isURL)(resolvedSrc)) {
|
|
58
|
-
app.send((0, messages_gen_js_1.ResourceTiming)(app.timestamp(), 0, 0, 0, 0, 0, resolvedSrc, 'img'));
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
const sendImgAttrs = app.safe(function (img) {
|
|
62
|
-
const id = app.nodes.getID(img);
|
|
63
|
-
if (id === undefined) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (!img.complete) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (img.naturalHeight === 0 && img.naturalWidth === 0 && !isSVGInFireFox(img.src)) {
|
|
70
|
-
sendImgError(img);
|
|
71
|
-
}
|
|
72
|
-
else if (app.sanitizer.isHidden(id) || app.sanitizer.isObscured(id)) {
|
|
73
|
-
sendPlaceholder(id, img);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
sendSrc(id, img);
|
|
77
|
-
sendSrcset(id, img);
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
const observer = new MutationObserver((mutations) => {
|
|
81
|
-
for (const mutation of mutations) {
|
|
82
|
-
if (mutation.type === 'attributes') {
|
|
83
|
-
const target = mutation.target;
|
|
84
|
-
const id = app.nodes.getID(target);
|
|
85
|
-
if (id === undefined) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (mutation.attributeName === 'src') {
|
|
89
|
-
sendSrc(id, target);
|
|
90
|
-
}
|
|
91
|
-
if (mutation.attributeName === 'srcset') {
|
|
92
|
-
sendSrcset(id, target);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
app.attachStopCallback(() => {
|
|
98
|
-
observer.disconnect();
|
|
99
|
-
});
|
|
100
|
-
app.nodes.attachNodeCallback((node) => {
|
|
101
|
-
if (!(0, guards_js_1.hasTag)(node, 'img')) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
app.nodes.attachNodeListener(node, 'error', () => sendImgError(node));
|
|
105
|
-
app.nodes.attachNodeListener(node, 'load', () => sendImgAttrs(node));
|
|
106
|
-
sendImgAttrs(node);
|
|
107
|
-
observer.observe(node, { attributes: true, attributeFilter: ['src', 'srcset'] });
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
exports.default = default_1;
|
package/cjs/modules/input.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type App from '../app/index.js';
|
|
2
|
-
type TextEditableElement = HTMLInputElement | HTMLTextAreaElement;
|
|
3
|
-
export declare function getInputLabel(node: TextEditableElement): string;
|
|
4
|
-
export declare const enum InputMode {
|
|
5
|
-
Plain = 0,
|
|
6
|
-
Obscured = 1,
|
|
7
|
-
Hidden = 2
|
|
8
|
-
}
|
|
9
|
-
export interface Options {
|
|
10
|
-
obscureInputNumbers: boolean;
|
|
11
|
-
obscureInputEmails: boolean;
|
|
12
|
-
defaultInputMode: InputMode;
|
|
13
|
-
obscureInputDates: boolean;
|
|
14
|
-
}
|
|
15
|
-
export default function (app: App, opts: Partial<Options>): void;
|
|
16
|
-
export {};
|
package/cjs/modules/input.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getInputLabel = void 0;
|
|
4
|
-
const utils_js_1 = require("../utils.js");
|
|
5
|
-
const guards_js_1 = require("../app/guards.js");
|
|
6
|
-
const messages_gen_js_1 = require("../app/messages.gen.js");
|
|
7
|
-
const INPUT_TYPES = ['text', 'password', 'email', 'search', 'number', 'range', 'date', 'tel'];
|
|
8
|
-
function isTextEditable(node) {
|
|
9
|
-
if ((0, guards_js_1.hasTag)(node, 'textarea')) {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
if (!(0, guards_js_1.hasTag)(node, 'input')) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
return INPUT_TYPES.includes(node.type);
|
|
16
|
-
}
|
|
17
|
-
function isCheckable(node) {
|
|
18
|
-
if (!(0, guards_js_1.hasTag)(node, 'input')) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
const type = node.type;
|
|
22
|
-
return type === 'checkbox' || type === 'radio';
|
|
23
|
-
}
|
|
24
|
-
const labelElementFor = utils_js_1.IN_BROWSER && 'labels' in HTMLInputElement.prototype
|
|
25
|
-
? (node) => {
|
|
26
|
-
let p = node;
|
|
27
|
-
while ((p = p.parentNode) !== null) {
|
|
28
|
-
if ((0, guards_js_1.hasTag)(p, 'label')) {
|
|
29
|
-
return p;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const labels = node.labels;
|
|
33
|
-
if (labels !== null && labels.length === 1) {
|
|
34
|
-
return labels[0];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
: (node) => {
|
|
38
|
-
let p = node;
|
|
39
|
-
while ((p = p.parentNode) !== null) {
|
|
40
|
-
if ((0, guards_js_1.hasTag)(p, 'label')) {
|
|
41
|
-
return p;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const id = node.id;
|
|
45
|
-
if (id) {
|
|
46
|
-
const labels = node.ownerDocument.querySelectorAll('label[for="' + id + '"]');
|
|
47
|
-
if (labels !== null && labels.length === 1) {
|
|
48
|
-
return labels[0];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
function getInputLabel(node) {
|
|
53
|
-
let label = (0, utils_js_1.getLabelAttribute)(node);
|
|
54
|
-
if (label === null) {
|
|
55
|
-
const labelElement = labelElementFor(node);
|
|
56
|
-
label =
|
|
57
|
-
(labelElement && labelElement.innerText) ||
|
|
58
|
-
node.placeholder ||
|
|
59
|
-
node.name ||
|
|
60
|
-
node.id ||
|
|
61
|
-
node.className ||
|
|
62
|
-
node.type;
|
|
63
|
-
}
|
|
64
|
-
return (0, utils_js_1.normSpaces)(label).slice(0, 100);
|
|
65
|
-
}
|
|
66
|
-
exports.getInputLabel = getInputLabel;
|
|
67
|
-
function default_1(app, opts) {
|
|
68
|
-
const options = Object.assign({
|
|
69
|
-
obscureInputNumbers: true,
|
|
70
|
-
obscureInputEmails: true,
|
|
71
|
-
defaultInputMode: 1 /* InputMode.Obscured */,
|
|
72
|
-
obscureInputDates: false,
|
|
73
|
-
}, opts);
|
|
74
|
-
function sendInputTarget(id, node) {
|
|
75
|
-
const label = getInputLabel(node);
|
|
76
|
-
if (label !== '') {
|
|
77
|
-
app.send((0, messages_gen_js_1.SetInputTarget)(id, label));
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
function sendInputValue(id, node) {
|
|
81
|
-
let value = node.value;
|
|
82
|
-
let inputMode = options.defaultInputMode;
|
|
83
|
-
if (node.type === 'password' || app.sanitizer.isHidden(id)) {
|
|
84
|
-
inputMode = 2 /* InputMode.Hidden */;
|
|
85
|
-
}
|
|
86
|
-
else if (app.sanitizer.isObscured(id) ||
|
|
87
|
-
(inputMode === 0 /* InputMode.Plain */ &&
|
|
88
|
-
((options.obscureInputNumbers && node.type !== 'date' && /\d\d\d\d/.test(value)) ||
|
|
89
|
-
(options.obscureInputDates && node.type === 'date') ||
|
|
90
|
-
(options.obscureInputEmails && (node.type === 'email' || !!~value.indexOf('@')))))) {
|
|
91
|
-
inputMode = 1 /* InputMode.Obscured */;
|
|
92
|
-
}
|
|
93
|
-
let mask = 0;
|
|
94
|
-
switch (inputMode) {
|
|
95
|
-
case 2 /* InputMode.Hidden */:
|
|
96
|
-
mask = -1;
|
|
97
|
-
value = '';
|
|
98
|
-
break;
|
|
99
|
-
case 1 /* InputMode.Obscured */:
|
|
100
|
-
mask = value.length;
|
|
101
|
-
value = '';
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
app.send((0, messages_gen_js_1.SetInputValue)(id, value, mask));
|
|
105
|
-
}
|
|
106
|
-
const inputValues = new Map();
|
|
107
|
-
const checkableValues = new Map();
|
|
108
|
-
const registeredTargets = new Set();
|
|
109
|
-
app.attachStopCallback(() => {
|
|
110
|
-
inputValues.clear();
|
|
111
|
-
checkableValues.clear();
|
|
112
|
-
registeredTargets.clear();
|
|
113
|
-
});
|
|
114
|
-
app.ticker.attach(() => {
|
|
115
|
-
inputValues.forEach((value, id) => {
|
|
116
|
-
const node = app.nodes.getNode(id);
|
|
117
|
-
if (!node)
|
|
118
|
-
return inputValues.delete(id);
|
|
119
|
-
if (value !== node.value) {
|
|
120
|
-
inputValues.set(id, node.value);
|
|
121
|
-
if (!registeredTargets.has(id)) {
|
|
122
|
-
registeredTargets.add(id);
|
|
123
|
-
sendInputTarget(id, node);
|
|
124
|
-
}
|
|
125
|
-
sendInputValue(id, node);
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
checkableValues.forEach((checked, id) => {
|
|
129
|
-
const node = app.nodes.getNode(id);
|
|
130
|
-
if (!node)
|
|
131
|
-
return checkableValues.delete(id);
|
|
132
|
-
if (checked !== node.checked) {
|
|
133
|
-
checkableValues.set(id, node.checked);
|
|
134
|
-
app.send((0, messages_gen_js_1.SetInputChecked)(id, node.checked));
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
app.ticker.attach(Set.prototype.clear, 100, false, registeredTargets);
|
|
139
|
-
app.nodes.attachNodeCallback(app.safe((node) => {
|
|
140
|
-
const id = app.nodes.getID(node);
|
|
141
|
-
if (id === undefined) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
// TODO: support multiple select (?): use selectedOptions; Need send target?
|
|
145
|
-
if ((0, guards_js_1.hasTag)(node, 'select')) {
|
|
146
|
-
sendInputValue(id, node);
|
|
147
|
-
app.attachEventListener(node, 'change', () => {
|
|
148
|
-
sendInputValue(id, node);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
if (isTextEditable(node)) {
|
|
152
|
-
inputValues.set(id, node.value);
|
|
153
|
-
sendInputValue(id, node);
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
if (isCheckable(node)) {
|
|
157
|
-
checkableValues.set(id, node.checked);
|
|
158
|
-
app.send((0, messages_gen_js_1.SetInputChecked)(id, node.checked));
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
}));
|
|
162
|
-
}
|
|
163
|
-
exports.default = default_1;
|
package/cjs/modules/mouse.d.ts
DELETED
package/cjs/modules/mouse.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const guards_js_1 = require("../app/guards.js");
|
|
4
|
-
const utils_js_1 = require("../utils.js");
|
|
5
|
-
const messages_gen_js_1 = require("../app/messages.gen.js");
|
|
6
|
-
const input_js_1 = require("./input.js");
|
|
7
|
-
const finder_1 = require("@medv/finder");
|
|
8
|
-
function _getSelector(target, document) {
|
|
9
|
-
const selector = (0, finder_1.finder)(target, {
|
|
10
|
-
root: document.body,
|
|
11
|
-
seedMinLength: 3,
|
|
12
|
-
optimizedMinLength: 2,
|
|
13
|
-
threshold: 1000,
|
|
14
|
-
maxNumberOfTries: 10000,
|
|
15
|
-
});
|
|
16
|
-
return selector;
|
|
17
|
-
}
|
|
18
|
-
function isClickable(element) {
|
|
19
|
-
const tag = element.tagName.toUpperCase();
|
|
20
|
-
return (tag === 'BUTTON' ||
|
|
21
|
-
tag === 'A' ||
|
|
22
|
-
tag === 'LI' ||
|
|
23
|
-
tag === 'SELECT' ||
|
|
24
|
-
tag === 'TR' ||
|
|
25
|
-
tag === 'TH' ||
|
|
26
|
-
element.onclick != null ||
|
|
27
|
-
element.getAttribute('role') === 'button');
|
|
28
|
-
//|| element.className.includes("btn")
|
|
29
|
-
// MBTODO: intersept addEventListener
|
|
30
|
-
}
|
|
31
|
-
//TODO: fix (typescript is not sure about target variable after assignation of svg)
|
|
32
|
-
function getTarget(target, document) {
|
|
33
|
-
if (target instanceof Element) {
|
|
34
|
-
return _getTarget(target, document);
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
function _getTarget(target, document) {
|
|
39
|
-
let element = target;
|
|
40
|
-
while (element !== null && element !== document.documentElement) {
|
|
41
|
-
if ((0, utils_js_1.hasOpenreplayAttribute)(element, 'masked')) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
element = element.parentElement;
|
|
45
|
-
}
|
|
46
|
-
if ((0, guards_js_1.isSVGElement)(target)) {
|
|
47
|
-
let owner = target.ownerSVGElement;
|
|
48
|
-
while (owner !== null) {
|
|
49
|
-
target = owner;
|
|
50
|
-
owner = owner.ownerSVGElement;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
element = target;
|
|
54
|
-
while (element !== null && element !== document.documentElement) {
|
|
55
|
-
const tag = element.tagName.toUpperCase();
|
|
56
|
-
if (tag === 'LABEL') {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
if (tag === 'INPUT') {
|
|
60
|
-
return element;
|
|
61
|
-
}
|
|
62
|
-
if (isClickable(element) || (0, utils_js_1.getLabelAttribute)(element) !== null) {
|
|
63
|
-
return element;
|
|
64
|
-
}
|
|
65
|
-
element = element.parentElement;
|
|
66
|
-
}
|
|
67
|
-
return target === document.documentElement ? null : target;
|
|
68
|
-
}
|
|
69
|
-
function default_1(app) {
|
|
70
|
-
function getTargetLabel(target) {
|
|
71
|
-
const dl = (0, utils_js_1.getLabelAttribute)(target);
|
|
72
|
-
if (dl !== null) {
|
|
73
|
-
return dl;
|
|
74
|
-
}
|
|
75
|
-
if ((0, guards_js_1.hasTag)(target, 'input')) {
|
|
76
|
-
return (0, input_js_1.getInputLabel)(target);
|
|
77
|
-
}
|
|
78
|
-
if (isClickable(target)) {
|
|
79
|
-
let label = '';
|
|
80
|
-
if (target instanceof HTMLElement) {
|
|
81
|
-
label = app.sanitizer.getInnerTextSecure(target);
|
|
82
|
-
}
|
|
83
|
-
label = label || target.id || target.className;
|
|
84
|
-
return (0, utils_js_1.normSpaces)(label).slice(0, 100);
|
|
85
|
-
}
|
|
86
|
-
return '';
|
|
87
|
-
}
|
|
88
|
-
let mousePositionX = -1;
|
|
89
|
-
let mousePositionY = -1;
|
|
90
|
-
let mousePositionChanged = false;
|
|
91
|
-
let mouseTarget = null;
|
|
92
|
-
let mouseTargetTime = 0;
|
|
93
|
-
let selectorMap = {};
|
|
94
|
-
app.attachStopCallback(() => {
|
|
95
|
-
mousePositionX = -1;
|
|
96
|
-
mousePositionY = -1;
|
|
97
|
-
mousePositionChanged = false;
|
|
98
|
-
mouseTarget = null;
|
|
99
|
-
selectorMap = {};
|
|
100
|
-
});
|
|
101
|
-
const sendMouseMove = () => {
|
|
102
|
-
if (mousePositionChanged) {
|
|
103
|
-
app.send((0, messages_gen_js_1.MouseMove)(mousePositionX, mousePositionY));
|
|
104
|
-
mousePositionChanged = false;
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
const patchDocument = (document, topframe = false) => {
|
|
108
|
-
function getSelector(id, target) {
|
|
109
|
-
return (selectorMap[id] = selectorMap[id] || _getSelector(target, document));
|
|
110
|
-
}
|
|
111
|
-
const attachListener = topframe
|
|
112
|
-
? app.attachEventListener.bind(app) // attached/removed on start/stop
|
|
113
|
-
: app.nodes.attachNodeListener.bind(app.nodes); // attached/removed on node register/unregister
|
|
114
|
-
attachListener(document.documentElement, 'mouseover', (e) => {
|
|
115
|
-
const target = getTarget(e.target, document);
|
|
116
|
-
if (target !== mouseTarget) {
|
|
117
|
-
mouseTarget = target;
|
|
118
|
-
mouseTargetTime = performance.now();
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
attachListener(document, 'mousemove', (e) => {
|
|
122
|
-
const [left, top] = app.observer.getDocumentOffset(document); // MBTODO?: document-id related message
|
|
123
|
-
mousePositionX = e.clientX + left;
|
|
124
|
-
mousePositionY = e.clientY + top;
|
|
125
|
-
mousePositionChanged = true;
|
|
126
|
-
}, false);
|
|
127
|
-
attachListener(document, 'click', (e) => {
|
|
128
|
-
const target = getTarget(e.target, document);
|
|
129
|
-
if ((!e.clientX && !e.clientY) || target === null) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const id = app.nodes.getID(target);
|
|
133
|
-
if (id !== undefined) {
|
|
134
|
-
sendMouseMove();
|
|
135
|
-
app.send((0, messages_gen_js_1.MouseClick)(id, mouseTarget === target ? Math.round(performance.now() - mouseTargetTime) : 0, getTargetLabel(target), isClickable(target) ? getSelector(id, target) : ''), true);
|
|
136
|
-
}
|
|
137
|
-
mouseTarget = null;
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
app.nodes.attachNodeCallback((node) => {
|
|
141
|
-
if ((0, guards_js_1.isDocument)(node)) {
|
|
142
|
-
patchDocument(node);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
patchDocument(document, true);
|
|
146
|
-
app.ticker.attach(sendMouseMove, 10);
|
|
147
|
-
}
|
|
148
|
-
exports.default = default_1;
|
package/cjs/modules/network.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type App from '../app/index.js';
|
|
2
|
-
type XHRRequestBody = Parameters<XMLHttpRequest['send']>[0];
|
|
3
|
-
type FetchRequestBody = RequestInit['body'];
|
|
4
|
-
interface RequestData {
|
|
5
|
-
body: XHRRequestBody | FetchRequestBody;
|
|
6
|
-
headers: Record<string, string>;
|
|
7
|
-
}
|
|
8
|
-
interface ResponseData {
|
|
9
|
-
body: any;
|
|
10
|
-
headers: Record<string, string>;
|
|
11
|
-
}
|
|
12
|
-
interface RequestResponseData {
|
|
13
|
-
readonly status: number;
|
|
14
|
-
readonly method: string;
|
|
15
|
-
url: string;
|
|
16
|
-
request: RequestData;
|
|
17
|
-
response: ResponseData;
|
|
18
|
-
}
|
|
19
|
-
type Sanitizer = (data: RequestResponseData) => RequestResponseData | null;
|
|
20
|
-
export interface Options {
|
|
21
|
-
sessionTokenHeader: string | boolean;
|
|
22
|
-
failuresOnly: boolean;
|
|
23
|
-
ignoreHeaders: Array<string> | boolean;
|
|
24
|
-
capturePayload: boolean;
|
|
25
|
-
sanitizer?: Sanitizer;
|
|
26
|
-
}
|
|
27
|
-
export default function (app: App, opts?: Partial<Options>): void;
|
|
28
|
-
export {};
|