@openreplay/tracker 14.0.10-beta.1 → 14.0.10
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/{cjs → dist/cjs}/index.js +27 -49
- package/dist/cjs/index.js.map +1 -0
- package/{cjs → dist/cjs/main}/app/index.d.ts +38 -6
- package/{lib → dist/cjs/main}/app/messages.gen.d.ts +2 -2
- package/{lib/app/nodes.d.ts → dist/cjs/main/app/nodes/index.d.ts} +15 -7
- package/dist/cjs/main/app/nodes/maintainer.d.ts +28 -0
- package/{cjs → dist/cjs/main}/app/observer/iframe_observer.d.ts +1 -1
- package/{lib → dist/cjs/main}/app/observer/iframe_offsets.d.ts +1 -1
- package/{lib → dist/cjs/main}/app/observer/observer.d.ts +6 -0
- package/{lib → dist/cjs/main}/app/observer/top_observer.d.ts +6 -2
- package/{cjs → dist/cjs/main}/app/sanitizer.d.ts +5 -2
- package/{cjs → dist/cjs/main}/app/session.d.ts +6 -3
- package/{lib → dist/cjs/main}/index.d.ts +2 -2
- package/{lib → dist/cjs/main}/modules/attributeSender.d.ts +5 -2
- package/{cjs → dist/cjs/main}/modules/conditionsManager.d.ts +1 -1
- package/{cjs → dist/cjs/main}/modules/tagWatcher.d.ts +8 -4
- package/{lib → dist/cjs/main}/modules/userTesting/SignalManager.d.ts +2 -2
- package/{lib → dist/cjs/main}/utils.d.ts +4 -3
- package/dist/lib/index.js +9323 -0
- package/dist/lib/index.js.map +1 -0
- package/{lib → dist/lib/main}/app/index.d.ts +38 -6
- package/{cjs → dist/lib/main}/app/messages.gen.d.ts +2 -2
- package/{cjs/app/nodes.d.ts → dist/lib/main/app/nodes/index.d.ts} +15 -7
- package/dist/lib/main/app/nodes/maintainer.d.ts +28 -0
- package/{lib → dist/lib/main}/app/observer/iframe_observer.d.ts +1 -1
- package/{cjs → dist/lib/main}/app/observer/iframe_offsets.d.ts +1 -1
- package/{cjs → dist/lib/main}/app/observer/observer.d.ts +6 -0
- package/{cjs → dist/lib/main}/app/observer/top_observer.d.ts +6 -2
- package/{lib → dist/lib/main}/app/sanitizer.d.ts +5 -2
- package/{lib → dist/lib/main}/app/session.d.ts +6 -3
- package/{cjs → dist/lib/main}/index.d.ts +2 -2
- package/{cjs → dist/lib/main}/modules/attributeSender.d.ts +5 -2
- package/{lib → dist/lib/main}/modules/conditionsManager.d.ts +1 -1
- package/{lib → dist/lib/main}/modules/tagWatcher.d.ts +8 -4
- package/{cjs → dist/lib/main}/modules/userTesting/SignalManager.d.ts +2 -2
- package/{cjs → dist/lib/main}/utils.d.ts +4 -3
- package/package.json +29 -10
- package/.eslintignore +0 -11
- package/.nvmrc +0 -1
- package/.prettierignore +0 -1
- package/CHANGELOG.md +0 -297
- package/bun.lockb +0 -0
- package/cjs/app/canvas.js +0 -204
- package/cjs/app/guards.js +0 -37
- package/cjs/app/index.js +0 -1366
- package/cjs/app/logger.js +0 -37
- package/cjs/app/messages.gen.js +0 -702
- package/cjs/app/nodes.js +0 -110
- package/cjs/app/observer/iframe_observer.js +0 -35
- package/cjs/app/observer/iframe_offsets.js +0 -56
- package/cjs/app/observer/observer.js +0 -352
- package/cjs/app/observer/shadow_root_observer.js +0 -24
- package/cjs/app/observer/top_observer.js +0 -134
- package/cjs/app/sanitizer.js +0 -82
- package/cjs/app/session.js +0 -140
- package/cjs/app/ticker.js +0 -48
- package/cjs/common/interaction.js +0 -2
- package/cjs/common/messages.gen.js +0 -4
- package/cjs/modules/attributeSender.js +0 -51
- package/cjs/modules/axiosSpy.js +0 -122
- package/cjs/modules/conditionsManager.js +0 -343
- package/cjs/modules/connection.js +0 -15
- package/cjs/modules/console.js +0 -127
- package/cjs/modules/constructedStyleSheets.js +0 -138
- package/cjs/modules/cssrules.js +0 -99
- package/cjs/modules/exception.js +0 -85
- package/cjs/modules/featureFlags.js +0 -89
- package/cjs/modules/focus.js +0 -45
- package/cjs/modules/fonts.js +0 -57
- package/cjs/modules/img.js +0 -110
- package/cjs/modules/input.js +0 -203
- package/cjs/modules/mouse.js +0 -195
- package/cjs/modules/network.js +0 -244
- package/cjs/modules/performance.js +0 -53
- package/cjs/modules/scroll.js +0 -84
- package/cjs/modules/selection.js +0 -37
- package/cjs/modules/tabs.js +0 -13
- package/cjs/modules/tagWatcher.js +0 -76
- package/cjs/modules/timing.js +0 -173
- package/cjs/modules/userTesting/SignalManager.js +0 -83
- package/cjs/modules/userTesting/dnd.js +0 -40
- package/cjs/modules/userTesting/index.js +0 -464
- package/cjs/modules/userTesting/recorder.js +0 -101
- package/cjs/modules/userTesting/styles.js +0 -266
- package/cjs/modules/userTesting/utils.js +0 -87
- package/cjs/modules/viewport.js +0 -43
- package/cjs/package.json +0 -1
- package/cjs/utils.js +0 -230
- package/coverage/clover.xml +0 -4304
- package/coverage/coverage-final.json +0 -55
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -206
- package/coverage/lcov-report/main/app/canvas.ts.html +0 -712
- package/coverage/lcov-report/main/app/guards.ts.html +0 -232
- package/coverage/lcov-report/main/app/index.html +0 -236
- package/coverage/lcov-report/main/app/index.ts.html +0 -3955
- package/coverage/lcov-report/main/app/logger.ts.html +0 -211
- package/coverage/lcov-report/main/app/messages.gen.ts.html +0 -3034
- package/coverage/lcov-report/main/app/nodes.ts.html +0 -406
- package/coverage/lcov-report/main/app/observer/iframe_observer.ts.html +0 -148
- package/coverage/lcov-report/main/app/observer/iframe_offsets.ts.html +0 -289
- package/coverage/lcov-report/main/app/observer/index.html +0 -161
- package/coverage/lcov-report/main/app/observer/shadow_root_observer.ts.html +0 -142
- package/coverage/lcov-report/main/app/observer/top_observer.ts.html +0 -541
- package/coverage/lcov-report/main/app/sanitizer.ts.html +0 -403
- package/coverage/lcov-report/main/app/session.ts.html +0 -622
- package/coverage/lcov-report/main/app/ticker.ts.html +0 -250
- package/coverage/lcov-report/main/index.html +0 -131
- package/coverage/lcov-report/main/index.ts.html +0 -1597
- package/coverage/lcov-report/main/modules/Network/beaconProxy.ts.html +0 -400
- package/coverage/lcov-report/main/modules/Network/fetchProxy.ts.html +0 -1075
- package/coverage/lcov-report/main/modules/Network/index.html +0 -191
- package/coverage/lcov-report/main/modules/Network/index.ts.html +0 -244
- package/coverage/lcov-report/main/modules/Network/networkMessage.ts.html +0 -400
- package/coverage/lcov-report/main/modules/Network/utils.ts.html +0 -709
- package/coverage/lcov-report/main/modules/Network/xhrProxy.ts.html +0 -877
- package/coverage/lcov-report/main/modules/attributeSender.ts.html +0 -241
- package/coverage/lcov-report/main/modules/axiosSpy.ts.html +0 -709
- package/coverage/lcov-report/main/modules/conditionsManager.ts.html +0 -1381
- package/coverage/lcov-report/main/modules/connection.ts.html +0 -160
- package/coverage/lcov-report/main/modules/console.ts.html +0 -541
- package/coverage/lcov-report/main/modules/constructedStyleSheets.ts.html +0 -571
- package/coverage/lcov-report/main/modules/cssrules.ts.html +0 -418
- package/coverage/lcov-report/main/modules/exception.ts.html +0 -385
- package/coverage/lcov-report/main/modules/featureFlags.ts.html +0 -415
- package/coverage/lcov-report/main/modules/focus.ts.html +0 -220
- package/coverage/lcov-report/main/modules/fonts.ts.html +0 -289
- package/coverage/lcov-report/main/modules/img.ts.html +0 -436
- package/coverage/lcov-report/main/modules/index.html +0 -431
- package/coverage/lcov-report/main/modules/input.ts.html +0 -826
- package/coverage/lcov-report/main/modules/mouse.ts.html +0 -826
- package/coverage/lcov-report/main/modules/network.ts.html +0 -1123
- package/coverage/lcov-report/main/modules/performance.ts.html +0 -367
- package/coverage/lcov-report/main/modules/scroll.ts.html +0 -364
- package/coverage/lcov-report/main/modules/selection.ts.html +0 -202
- package/coverage/lcov-report/main/modules/tabs.ts.html +0 -124
- package/coverage/lcov-report/main/modules/tagWatcher.ts.html +0 -337
- package/coverage/lcov-report/main/modules/timing.ts.html +0 -877
- package/coverage/lcov-report/main/modules/userTesting/SignalManager.ts.html +0 -370
- package/coverage/lcov-report/main/modules/userTesting/dnd.ts.html +0 -220
- package/coverage/lcov-report/main/modules/userTesting/index.html +0 -191
- package/coverage/lcov-report/main/modules/userTesting/index.ts.html +0 -1909
- package/coverage/lcov-report/main/modules/userTesting/recorder.ts.html +0 -430
- package/coverage/lcov-report/main/modules/userTesting/styles.ts.html +0 -937
- package/coverage/lcov-report/main/modules/userTesting/utils.ts.html +0 -364
- package/coverage/lcov-report/main/modules/viewport.ts.html +0 -250
- package/coverage/lcov-report/main/utils.ts.html +0 -814
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/webworker/BatchWriter.ts.html +0 -499
- package/coverage/lcov-report/webworker/MessageEncoder.gen.ts.html +0 -1021
- package/coverage/lcov-report/webworker/PrimitiveEncoder.ts.html +0 -436
- package/coverage/lcov-report/webworker/QueueSender.ts.html +0 -547
- package/coverage/lcov-report/webworker/index.html +0 -176
- package/coverage/lcov-report/webworker/index.ts.html +0 -667
- package/coverage/lcov.info +0 -8425
- package/jest.config.js +0 -13
- package/lib/app/canvas.js +0 -202
- package/lib/app/guards.js +0 -26
- package/lib/app/index.js +0 -1336
- package/lib/app/logger.js +0 -33
- package/lib/app/messages.gen.js +0 -622
- package/lib/app/nodes.js +0 -107
- package/lib/app/observer/iframe_observer.js +0 -29
- package/lib/app/observer/iframe_offsets.js +0 -53
- package/lib/app/observer/observer.js +0 -349
- package/lib/app/observer/shadow_root_observer.js +0 -18
- package/lib/app/observer/top_observer.js +0 -128
- package/lib/app/sanitizer.js +0 -77
- package/lib/app/session.js +0 -137
- package/lib/app/ticker.js +0 -45
- package/lib/common/interaction.js +0 -1
- package/lib/common/messages.gen.js +0 -3
- package/lib/common/tsconfig.tsbuildinfo +0 -1
- package/lib/index.js +0 -423
- package/lib/modules/attributeSender.js +0 -46
- package/lib/modules/axiosSpy.js +0 -119
- package/lib/modules/conditionsManager.js +0 -340
- package/lib/modules/connection.js +0 -12
- package/lib/modules/console.js +0 -124
- package/lib/modules/constructedStyleSheets.js +0 -133
- package/lib/modules/cssrules.js +0 -97
- package/lib/modules/exception.js +0 -76
- package/lib/modules/featureFlags.js +0 -86
- package/lib/modules/focus.js +0 -42
- package/lib/modules/fonts.js +0 -54
- package/lib/modules/img.js +0 -107
- package/lib/modules/input.js +0 -198
- package/lib/modules/mouse.js +0 -192
- package/lib/modules/network.js +0 -238
- package/lib/modules/performance.js +0 -49
- package/lib/modules/scroll.js +0 -81
- package/lib/modules/selection.js +0 -35
- package/lib/modules/tabs.js +0 -10
- package/lib/modules/tagWatcher.js +0 -73
- package/lib/modules/timing.js +0 -170
- package/lib/modules/userTesting/SignalManager.js +0 -80
- package/lib/modules/userTesting/dnd.js +0 -37
- package/lib/modules/userTesting/index.js +0 -435
- package/lib/modules/userTesting/recorder.js +0 -97
- package/lib/modules/userTesting/styles.js +0 -263
- package/lib/modules/userTesting/utils.js +0 -79
- package/lib/modules/viewport.js +0 -40
- package/lib/utils.js +0 -211
- package/rollup.config.js +0 -12
- package/scripts/checkver.cjs +0 -7
- package/tsconfig-base.json +0 -16
- /package/{cjs → dist/cjs}/common/interaction.d.ts +0 -0
- /package/{cjs → dist/cjs}/common/messages.gen.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/app/canvas.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/app/guards.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/app/logger.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/app/observer/shadow_root_observer.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/app/ticker.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/axiosSpy.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/connection.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/console.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/constructedStyleSheets.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/cssrules.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/exception.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/featureFlags.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/focus.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/fonts.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/img.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/input.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/mouse.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/network.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/performance.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/scroll.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/selection.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/tabs.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/timing.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/userTesting/dnd.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/userTesting/index.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/userTesting/recorder.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/userTesting/styles.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/userTesting/utils.d.ts +0 -0
- /package/{cjs → dist/cjs/main}/modules/viewport.d.ts +0 -0
- /package/{lib → dist/lib}/common/interaction.d.ts +0 -0
- /package/{lib → dist/lib}/common/messages.gen.d.ts +0 -0
- /package/{lib → dist/lib/main}/app/canvas.d.ts +0 -0
- /package/{lib → dist/lib/main}/app/guards.d.ts +0 -0
- /package/{lib → dist/lib/main}/app/logger.d.ts +0 -0
- /package/{lib → dist/lib/main}/app/observer/shadow_root_observer.d.ts +0 -0
- /package/{lib → dist/lib/main}/app/ticker.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/axiosSpy.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/connection.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/console.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/constructedStyleSheets.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/cssrules.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/exception.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/featureFlags.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/focus.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/fonts.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/img.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/input.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/mouse.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/network.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/performance.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/scroll.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/selection.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/tabs.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/timing.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/userTesting/dnd.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/userTesting/index.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/userTesting/recorder.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/userTesting/styles.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/userTesting/utils.d.ts +0 -0
- /package/{lib → dist/lib/main}/modules/viewport.d.ts +0 -0
package/lib/modules/mouse.js
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { hasTag, isSVGElement, isDocument } from '../app/guards.js';
|
|
2
|
-
import { normSpaces, hasOpenreplayAttribute, getLabelAttribute, now } from '../utils.js';
|
|
3
|
-
import { MouseMove, MouseClick, MouseThrashing } from '../app/messages.gen.js';
|
|
4
|
-
import { getInputLabel } from './input.js';
|
|
5
|
-
import { finder } from '@medv/finder';
|
|
6
|
-
function _getSelector(target, document, options) {
|
|
7
|
-
const selector = finder(target, {
|
|
8
|
-
root: document.body,
|
|
9
|
-
seedMinLength: 3,
|
|
10
|
-
optimizedMinLength: options?.minSelectorDepth || 2,
|
|
11
|
-
threshold: options?.nthThreshold || 1000,
|
|
12
|
-
maxNumberOfTries: options?.maxOptimiseTries || 10000,
|
|
13
|
-
});
|
|
14
|
-
return selector;
|
|
15
|
-
}
|
|
16
|
-
function isClickable(element) {
|
|
17
|
-
const tag = element.tagName.toUpperCase();
|
|
18
|
-
return (tag === 'BUTTON' ||
|
|
19
|
-
tag === 'A' ||
|
|
20
|
-
tag === 'LI' ||
|
|
21
|
-
tag === 'SELECT' ||
|
|
22
|
-
tag === 'TR' ||
|
|
23
|
-
tag === 'TH' ||
|
|
24
|
-
element.onclick != null ||
|
|
25
|
-
element.getAttribute('role') === 'button');
|
|
26
|
-
//|| element.className.includes("btn")
|
|
27
|
-
// MBTODO: intercept addEventListener
|
|
28
|
-
}
|
|
29
|
-
//TODO: fix (typescript is not sure about target variable after assignation of svg)
|
|
30
|
-
function getTarget(target, document) {
|
|
31
|
-
if (target instanceof Element) {
|
|
32
|
-
return _getTarget(target, document);
|
|
33
|
-
}
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
function _getTarget(target, document) {
|
|
37
|
-
let element = target;
|
|
38
|
-
while (element !== null && element !== document.documentElement) {
|
|
39
|
-
if (hasOpenreplayAttribute(element, 'masked')) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
element = element.parentElement;
|
|
43
|
-
}
|
|
44
|
-
if (isSVGElement(target)) {
|
|
45
|
-
let owner = target.ownerSVGElement;
|
|
46
|
-
while (owner !== null) {
|
|
47
|
-
target = owner;
|
|
48
|
-
owner = owner.ownerSVGElement;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
element = target;
|
|
52
|
-
while (element !== null && element !== document.documentElement) {
|
|
53
|
-
const tag = element.tagName.toUpperCase();
|
|
54
|
-
if (tag === 'LABEL') {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
if (tag === 'INPUT') {
|
|
58
|
-
return element;
|
|
59
|
-
}
|
|
60
|
-
if (isClickable(element) || getLabelAttribute(element) !== null) {
|
|
61
|
-
return element;
|
|
62
|
-
}
|
|
63
|
-
element = element.parentElement;
|
|
64
|
-
}
|
|
65
|
-
return target === document.documentElement ? null : target;
|
|
66
|
-
}
|
|
67
|
-
export default function (app, options) {
|
|
68
|
-
const { disableClickmaps = false } = options || {};
|
|
69
|
-
function getTargetLabel(target) {
|
|
70
|
-
const dl = getLabelAttribute(target);
|
|
71
|
-
if (dl !== null) {
|
|
72
|
-
return dl;
|
|
73
|
-
}
|
|
74
|
-
if (hasTag(target, 'input')) {
|
|
75
|
-
return getInputLabel(target);
|
|
76
|
-
}
|
|
77
|
-
if (isClickable(target)) {
|
|
78
|
-
let label = '';
|
|
79
|
-
if (target instanceof HTMLElement) {
|
|
80
|
-
label = app.sanitizer.getInnerTextSecure(target);
|
|
81
|
-
}
|
|
82
|
-
label = label || target.id || target.className;
|
|
83
|
-
return normSpaces(label).slice(0, 100);
|
|
84
|
-
}
|
|
85
|
-
return '';
|
|
86
|
-
}
|
|
87
|
-
let mousePositionX = -1;
|
|
88
|
-
let mousePositionY = -1;
|
|
89
|
-
let mousePositionChanged = false;
|
|
90
|
-
let mouseTarget = null;
|
|
91
|
-
let mouseTargetTime = 0;
|
|
92
|
-
let selectorMap = {};
|
|
93
|
-
let velocity = 0;
|
|
94
|
-
let direction = 0;
|
|
95
|
-
let directionChangeCount = 0;
|
|
96
|
-
let distance = 0;
|
|
97
|
-
let checkIntervalId;
|
|
98
|
-
const shakeThreshold = 0.008;
|
|
99
|
-
const shakeCheckInterval = 225;
|
|
100
|
-
function checkMouseShaking() {
|
|
101
|
-
const nextVelocity = distance / shakeCheckInterval;
|
|
102
|
-
if (!velocity) {
|
|
103
|
-
velocity = nextVelocity;
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
const acceleration = (nextVelocity - velocity) / shakeCheckInterval;
|
|
107
|
-
if (directionChangeCount > 4 && acceleration > shakeThreshold) {
|
|
108
|
-
app.send(MouseThrashing(now()));
|
|
109
|
-
}
|
|
110
|
-
distance = 0;
|
|
111
|
-
directionChangeCount = 0;
|
|
112
|
-
velocity = nextVelocity;
|
|
113
|
-
}
|
|
114
|
-
app.attachStartCallback(() => {
|
|
115
|
-
checkIntervalId = setInterval(() => checkMouseShaking(), shakeCheckInterval);
|
|
116
|
-
});
|
|
117
|
-
app.attachStopCallback(() => {
|
|
118
|
-
mousePositionX = -1;
|
|
119
|
-
mousePositionY = -1;
|
|
120
|
-
mousePositionChanged = false;
|
|
121
|
-
mouseTarget = null;
|
|
122
|
-
selectorMap = {};
|
|
123
|
-
if (checkIntervalId) {
|
|
124
|
-
clearInterval(checkIntervalId);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
const sendMouseMove = () => {
|
|
128
|
-
if (mousePositionChanged) {
|
|
129
|
-
app.send(MouseMove(mousePositionX, mousePositionY));
|
|
130
|
-
mousePositionChanged = false;
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
const patchDocument = (document, topframe = false) => {
|
|
134
|
-
function getSelector(id, target, options) {
|
|
135
|
-
return (selectorMap[id] = selectorMap[id] || _getSelector(target, document, options));
|
|
136
|
-
}
|
|
137
|
-
const attachListener = topframe
|
|
138
|
-
? app.attachEventListener.bind(app) // attached/removed on start/stop
|
|
139
|
-
: app.nodes.attachNodeListener.bind(app.nodes); // attached/removed on node register/unregister
|
|
140
|
-
attachListener(document.documentElement, 'mouseover', (e) => {
|
|
141
|
-
const target = getTarget(e.target, document);
|
|
142
|
-
if (target !== mouseTarget) {
|
|
143
|
-
mouseTarget = target;
|
|
144
|
-
mouseTargetTime = performance.now();
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
attachListener(document, 'mousemove', (e) => {
|
|
148
|
-
const [left, top] = app.observer.getDocumentOffset(document); // MBTODO?: document-id related message
|
|
149
|
-
mousePositionX = e.clientX + left;
|
|
150
|
-
mousePositionY = e.clientY + top;
|
|
151
|
-
mousePositionChanged = true;
|
|
152
|
-
const nextDirection = Math.sign(e.movementX);
|
|
153
|
-
distance += Math.abs(e.movementX) + Math.abs(e.movementY);
|
|
154
|
-
if (nextDirection !== direction) {
|
|
155
|
-
direction = nextDirection;
|
|
156
|
-
directionChangeCount++;
|
|
157
|
-
}
|
|
158
|
-
}, false);
|
|
159
|
-
attachListener(document, 'click', (e) => {
|
|
160
|
-
const target = getTarget(e.target, document);
|
|
161
|
-
if ((!e.clientX && !e.clientY) || target === null) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const id = app.nodes.getID(target);
|
|
165
|
-
if (id !== undefined) {
|
|
166
|
-
const clickX = e.pageX;
|
|
167
|
-
const clickY = e.pageY;
|
|
168
|
-
const contentWidth = document.documentElement.scrollWidth;
|
|
169
|
-
const contentHeight = document.documentElement.scrollHeight;
|
|
170
|
-
const normalizedX = roundNumber(clickX / contentWidth);
|
|
171
|
-
const normalizedY = roundNumber(clickY / contentHeight);
|
|
172
|
-
sendMouseMove();
|
|
173
|
-
app.send(MouseClick(id, mouseTarget === target ? Math.round(performance.now() - mouseTargetTime) : 0, getTargetLabel(target), isClickable(target) && !disableClickmaps ? getSelector(id, target, options) : '', normalizedX, normalizedY), true);
|
|
174
|
-
}
|
|
175
|
-
mouseTarget = null;
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
app.nodes.attachNodeCallback((node) => {
|
|
179
|
-
if (isDocument(node)) {
|
|
180
|
-
patchDocument(node);
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
patchDocument(document, true);
|
|
184
|
-
app.ticker.attach(sendMouseMove, options?.trackingOffset || 7);
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* we get 0 to 1 decimal number, convert and round it, then turn to %
|
|
188
|
-
* 0.39643 => 396.43 => 396 => 39.6%
|
|
189
|
-
* */
|
|
190
|
-
function roundNumber(num) {
|
|
191
|
-
return Math.round(num * 1e4);
|
|
192
|
-
}
|
package/lib/modules/network.js
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { NetworkRequest } from '../app/messages.gen.js';
|
|
2
|
-
import { getTimeOrigin } from '../utils.js';
|
|
3
|
-
import axiosSpy from './axiosSpy.js';
|
|
4
|
-
import createNetworkProxy from '@openreplay/network-proxy';
|
|
5
|
-
function getXHRRequestDataObject(xhr) {
|
|
6
|
-
// @ts-ignore this is 3x faster than using Map<XHR, XHRRequestData>
|
|
7
|
-
if (!xhr.__or_req_data__) {
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
xhr.__or_req_data__ = { body: undefined, headers: {} };
|
|
10
|
-
}
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
return xhr.__or_req_data__;
|
|
13
|
-
}
|
|
14
|
-
function strMethod(method) {
|
|
15
|
-
return typeof method === 'string' ? method.toUpperCase() : 'GET';
|
|
16
|
-
}
|
|
17
|
-
export default function (app, opts = {}) {
|
|
18
|
-
const options = Object.assign({
|
|
19
|
-
failuresOnly: false,
|
|
20
|
-
ignoreHeaders: ['cookie', 'set-cookie', 'authorization'],
|
|
21
|
-
capturePayload: false,
|
|
22
|
-
sessionTokenHeader: false,
|
|
23
|
-
captureInIframes: true,
|
|
24
|
-
axiosInstances: undefined,
|
|
25
|
-
useProxy: true,
|
|
26
|
-
}, opts);
|
|
27
|
-
if (options.useProxy === false) {
|
|
28
|
-
app.debug.warn('Network module is migrating to proxy api, to gradually migrate and test it set useProxy to true');
|
|
29
|
-
}
|
|
30
|
-
const ignoreHeaders = options.ignoreHeaders;
|
|
31
|
-
const isHIgnored = Array.isArray(ignoreHeaders)
|
|
32
|
-
? (name) => ignoreHeaders.includes(name)
|
|
33
|
-
: () => ignoreHeaders;
|
|
34
|
-
const stHeader = options.sessionTokenHeader === true ? 'X-OpenReplay-SessionToken' : options.sessionTokenHeader;
|
|
35
|
-
function setSessionTokenHeader(setRequestHeader) {
|
|
36
|
-
if (stHeader) {
|
|
37
|
-
const sessionToken = app.getSessionToken();
|
|
38
|
-
if (sessionToken) {
|
|
39
|
-
app.safe(setRequestHeader)(stHeader, sessionToken);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function sanitize(reqResInfo) {
|
|
44
|
-
if (!options.capturePayload) {
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
delete reqResInfo.request.body;
|
|
47
|
-
delete reqResInfo.response.body;
|
|
48
|
-
}
|
|
49
|
-
if (options.sanitizer) {
|
|
50
|
-
const resBody = reqResInfo.response.body;
|
|
51
|
-
if (typeof resBody === 'string') {
|
|
52
|
-
// Parse response in order to have handy view in sanitization function
|
|
53
|
-
try {
|
|
54
|
-
reqResInfo.response.body = JSON.parse(resBody);
|
|
55
|
-
}
|
|
56
|
-
catch { }
|
|
57
|
-
}
|
|
58
|
-
return options.sanitizer(reqResInfo);
|
|
59
|
-
}
|
|
60
|
-
return reqResInfo;
|
|
61
|
-
}
|
|
62
|
-
function stringify(r) {
|
|
63
|
-
if (r && typeof r.body !== 'string') {
|
|
64
|
-
try {
|
|
65
|
-
r.body = JSON.stringify(r.body);
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
r.body = '<unable to stringify>';
|
|
69
|
-
app.notify.warn("Openreplay fetch couldn't stringify body:", r.body);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return JSON.stringify(r);
|
|
73
|
-
}
|
|
74
|
-
const patchWindow = (context) => {
|
|
75
|
-
/* ====== modern way ====== */
|
|
76
|
-
if (options.useProxy) {
|
|
77
|
-
return createNetworkProxy(context, options.ignoreHeaders, setSessionTokenHeader, sanitize, (message) => {
|
|
78
|
-
app.send(NetworkRequest(message.requestType, message.method, message.url, message.request, message.response, message.status, message.startTime + getTimeOrigin(), message.duration, message.responseSize));
|
|
79
|
-
}, (url) => app.isServiceURL(url), { xhr: true, fetch: true, beacon: true }, options.tokenUrlMatcher);
|
|
80
|
-
}
|
|
81
|
-
/* ====== Fetch ====== */
|
|
82
|
-
const origFetch = context.fetch.bind(context);
|
|
83
|
-
const trackFetch = (input, init = {}) => {
|
|
84
|
-
if (!(typeof input === 'string' || input instanceof URL) || app.isServiceURL(String(input))) {
|
|
85
|
-
return origFetch(input, init);
|
|
86
|
-
}
|
|
87
|
-
setSessionTokenHeader(function (name, value) {
|
|
88
|
-
if (init.headers === undefined) {
|
|
89
|
-
init.headers = {};
|
|
90
|
-
}
|
|
91
|
-
if (init.headers instanceof Headers) {
|
|
92
|
-
init.headers.append(name, value);
|
|
93
|
-
}
|
|
94
|
-
else if (Array.isArray(init.headers)) {
|
|
95
|
-
init.headers.push([name, value]);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
init.headers[name] = value;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
const startTime = performance.now();
|
|
102
|
-
return origFetch(input, init).then((response) => {
|
|
103
|
-
const duration = performance.now() - startTime;
|
|
104
|
-
if (options.failuresOnly && response.status < 400) {
|
|
105
|
-
return response;
|
|
106
|
-
}
|
|
107
|
-
const r = response.clone();
|
|
108
|
-
r.text()
|
|
109
|
-
.then((text) => {
|
|
110
|
-
const reqHs = {};
|
|
111
|
-
const resHs = {};
|
|
112
|
-
if (ignoreHeaders !== true) {
|
|
113
|
-
// request headers
|
|
114
|
-
const writeReqHeader = ([n, v]) => {
|
|
115
|
-
if (!isHIgnored(n)) {
|
|
116
|
-
reqHs[n] = v;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
if (init.headers instanceof Headers) {
|
|
120
|
-
init.headers.forEach((v, n) => writeReqHeader([n, v]));
|
|
121
|
-
}
|
|
122
|
-
else if (Array.isArray(init.headers)) {
|
|
123
|
-
init.headers.forEach(writeReqHeader);
|
|
124
|
-
}
|
|
125
|
-
else if (typeof init.headers === 'object') {
|
|
126
|
-
Object.entries(init.headers).forEach(writeReqHeader);
|
|
127
|
-
}
|
|
128
|
-
// response headers
|
|
129
|
-
r.headers.forEach((v, n) => {
|
|
130
|
-
if (!isHIgnored(n))
|
|
131
|
-
resHs[n] = v;
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
const method = strMethod(init.method);
|
|
135
|
-
const reqResInfo = sanitize({
|
|
136
|
-
url: String(input),
|
|
137
|
-
method,
|
|
138
|
-
status: r.status,
|
|
139
|
-
request: {
|
|
140
|
-
headers: reqHs,
|
|
141
|
-
// @ts-ignore
|
|
142
|
-
body: init.body || null,
|
|
143
|
-
},
|
|
144
|
-
response: {
|
|
145
|
-
headers: resHs,
|
|
146
|
-
body: text,
|
|
147
|
-
},
|
|
148
|
-
});
|
|
149
|
-
if (!reqResInfo) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
app.send(NetworkRequest('fetch', method, String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), r.status, startTime + getTimeOrigin(), duration, 0));
|
|
153
|
-
})
|
|
154
|
-
.catch((e) => app.debug.error('Could not process Fetch response:', e));
|
|
155
|
-
return response;
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
|
-
// @ts-ignore
|
|
159
|
-
context.fetch = trackFetch;
|
|
160
|
-
/* ====== <> ====== */
|
|
161
|
-
/* ====== XHR ====== */
|
|
162
|
-
const nativeOpen = context.XMLHttpRequest.prototype.open;
|
|
163
|
-
const nativeSetRequestHeader = context.XMLHttpRequest.prototype.setRequestHeader;
|
|
164
|
-
const nativeSend = context.XMLHttpRequest.prototype.send;
|
|
165
|
-
function trackXMLHttpReqOpen(initMethod, url) {
|
|
166
|
-
const xhr = this;
|
|
167
|
-
setSessionTokenHeader((name, value) => xhr.setRequestHeader(name, value));
|
|
168
|
-
let startTime = 0;
|
|
169
|
-
xhr.addEventListener('loadstart', (e) => {
|
|
170
|
-
startTime = e.timeStamp;
|
|
171
|
-
});
|
|
172
|
-
xhr.addEventListener('load', app.safe((e) => {
|
|
173
|
-
const { headers: reqHs, body: reqBody } = getXHRRequestDataObject(xhr);
|
|
174
|
-
const duration = startTime > 0 ? e.timeStamp - startTime : 0;
|
|
175
|
-
const hString = xhr.getAllResponseHeaders() || ''; // might be null (only if no response received though)
|
|
176
|
-
const headersArr = hString.trim().split(/[\r\n]+/);
|
|
177
|
-
const headerMap = {};
|
|
178
|
-
headersArr.forEach(function (line) {
|
|
179
|
-
const parts = line.split(': ');
|
|
180
|
-
const header = parts.shift();
|
|
181
|
-
if (!isHIgnored(header)) {
|
|
182
|
-
headerMap[header] = parts.join(': ');
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
const method = strMethod(initMethod);
|
|
186
|
-
const reqResInfo = sanitize({
|
|
187
|
-
url: String(url),
|
|
188
|
-
method,
|
|
189
|
-
status: xhr.status,
|
|
190
|
-
request: {
|
|
191
|
-
headers: reqHs,
|
|
192
|
-
// @ts-ignore
|
|
193
|
-
body: reqBody || null,
|
|
194
|
-
},
|
|
195
|
-
response: {
|
|
196
|
-
headers: headerMap,
|
|
197
|
-
body: xhr.response,
|
|
198
|
-
},
|
|
199
|
-
});
|
|
200
|
-
if (!reqResInfo) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
app.send(NetworkRequest('xhr', method, String(reqResInfo.url), stringify(reqResInfo.request), stringify(reqResInfo.response), xhr.status, startTime + getTimeOrigin(), duration, 0));
|
|
204
|
-
}));
|
|
205
|
-
//TODO: handle error (though it has no Error API nor any useful information)
|
|
206
|
-
//xhr.addEventListener('error', (e) => {})
|
|
207
|
-
return nativeOpen.apply(this, arguments);
|
|
208
|
-
}
|
|
209
|
-
function trackXHRSend(body) {
|
|
210
|
-
const rdo = getXHRRequestDataObject(this);
|
|
211
|
-
rdo.body = body;
|
|
212
|
-
// @ts-ignore ??? this -> XMLHttpRequest
|
|
213
|
-
return nativeSend.apply(this, arguments);
|
|
214
|
-
}
|
|
215
|
-
function trackSetReqHeader(name, value) {
|
|
216
|
-
if (!isHIgnored(name)) {
|
|
217
|
-
const rdo = getXHRRequestDataObject(this);
|
|
218
|
-
rdo.headers[name] = value;
|
|
219
|
-
}
|
|
220
|
-
return nativeSetRequestHeader.apply(this, arguments);
|
|
221
|
-
}
|
|
222
|
-
if (!options.axiosInstances) {
|
|
223
|
-
context.XMLHttpRequest.prototype.open = trackXMLHttpReqOpen;
|
|
224
|
-
context.XMLHttpRequest.prototype.send = trackXHRSend;
|
|
225
|
-
context.XMLHttpRequest.prototype.setRequestHeader = trackSetReqHeader;
|
|
226
|
-
}
|
|
227
|
-
/* ====== <> ====== */
|
|
228
|
-
};
|
|
229
|
-
patchWindow(window);
|
|
230
|
-
if (options.axiosInstances) {
|
|
231
|
-
options.axiosInstances.forEach((axiosInstance) => {
|
|
232
|
-
axiosSpy(app, axiosInstance, options, sanitize, stringify);
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
if (options.captureInIframes) {
|
|
236
|
-
app.observer.attachContextCallback(app.safe(patchWindow));
|
|
237
|
-
}
|
|
238
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { IN_BROWSER } from '../utils.js';
|
|
2
|
-
import { PerformanceTrack } from '../app/messages.gen.js';
|
|
3
|
-
const perf = IN_BROWSER && 'performance' in window && 'memory' in performance // works in Chrome only
|
|
4
|
-
? performance
|
|
5
|
-
: { memory: {} };
|
|
6
|
-
export const deviceMemory = IN_BROWSER ? (navigator.deviceMemory || 0) * 1024 : 0;
|
|
7
|
-
export const jsHeapSizeLimit = perf.memory.jsHeapSizeLimit || 0;
|
|
8
|
-
export default function (app, opts) {
|
|
9
|
-
const options = Object.assign({
|
|
10
|
-
capturePerformance: true,
|
|
11
|
-
}, opts);
|
|
12
|
-
if (!options.capturePerformance) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
let frames;
|
|
16
|
-
let ticks;
|
|
17
|
-
const nextFrame = () => {
|
|
18
|
-
if (frames === undefined || frames === -1) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
frames++;
|
|
22
|
-
requestAnimationFrame(nextFrame);
|
|
23
|
-
};
|
|
24
|
-
app.ticker.attach(() => {
|
|
25
|
-
if (ticks === undefined || ticks === -1) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
ticks++;
|
|
29
|
-
}, 0, false);
|
|
30
|
-
const sendPerformanceTrack = () => {
|
|
31
|
-
if (frames === undefined || ticks === undefined) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
app.send(PerformanceTrack(frames, ticks, perf.memory.totalJSHeapSize || 0, perf.memory.usedJSHeapSize || 0));
|
|
35
|
-
ticks = frames = document.hidden ? -1 : 0;
|
|
36
|
-
};
|
|
37
|
-
app.attachStartCallback(() => {
|
|
38
|
-
ticks = frames = -1;
|
|
39
|
-
sendPerformanceTrack();
|
|
40
|
-
nextFrame();
|
|
41
|
-
});
|
|
42
|
-
app.attachStopCallback(() => {
|
|
43
|
-
ticks = frames = undefined;
|
|
44
|
-
});
|
|
45
|
-
app.ticker.attach(sendPerformanceTrack, 40, false);
|
|
46
|
-
if (document.hidden !== undefined) {
|
|
47
|
-
app.attachEventListener(document, 'visibilitychange', sendPerformanceTrack, false, false);
|
|
48
|
-
}
|
|
49
|
-
}
|
package/lib/modules/scroll.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { SetViewportScroll, SetNodeScroll } from '../app/messages.gen.js';
|
|
2
|
-
import { isNode, isElementNode, isRootNode, isDocument } from '../app/guards.js';
|
|
3
|
-
function getDocumentScroll(doc) {
|
|
4
|
-
const win = doc.defaultView;
|
|
5
|
-
return [
|
|
6
|
-
(win && win.scrollX) ||
|
|
7
|
-
(doc.documentElement && doc.documentElement.scrollLeft) ||
|
|
8
|
-
(doc.body && doc.body.scrollLeft) ||
|
|
9
|
-
0,
|
|
10
|
-
(win && win.scrollY) ||
|
|
11
|
-
(doc.documentElement && doc.documentElement.scrollTop) ||
|
|
12
|
-
(doc.body && doc.body.scrollTop) ||
|
|
13
|
-
0,
|
|
14
|
-
];
|
|
15
|
-
}
|
|
16
|
-
export default function (app, insideIframe) {
|
|
17
|
-
let documentScroll = false;
|
|
18
|
-
const nodeScroll = new Map();
|
|
19
|
-
function setNodeScroll(target) {
|
|
20
|
-
if (!isNode(target)) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
if (isElementNode(target)) {
|
|
24
|
-
nodeScroll.set(target, [target.scrollLeft, target.scrollTop]);
|
|
25
|
-
}
|
|
26
|
-
if (isDocument(target)) {
|
|
27
|
-
nodeScroll.set(target, getDocumentScroll(target));
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
const sendSetViewportScroll = app.safe(() => {
|
|
31
|
-
if (insideIframe) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
app.send(SetViewportScroll(...getDocumentScroll(document)));
|
|
35
|
-
});
|
|
36
|
-
const sendSetNodeScroll = app.safe((s, node) => {
|
|
37
|
-
const id = app.nodes.getID(node);
|
|
38
|
-
if (id !== undefined) {
|
|
39
|
-
app.send(SetNodeScroll(id, s[0], s[1]));
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
app.attachStartCallback(sendSetViewportScroll);
|
|
43
|
-
app.attachStopCallback(() => {
|
|
44
|
-
documentScroll = false;
|
|
45
|
-
nodeScroll.clear();
|
|
46
|
-
});
|
|
47
|
-
app.nodes.attachNodeCallback((node, isStart) => {
|
|
48
|
-
// MBTODO: iterate over all the nodes on start instead of using isStart hack
|
|
49
|
-
if (isStart) {
|
|
50
|
-
if (isElementNode(node) && node.scrollLeft + node.scrollTop > 0) {
|
|
51
|
-
nodeScroll.set(node, [node.scrollLeft, node.scrollTop]);
|
|
52
|
-
}
|
|
53
|
-
else if (isDocument(node)) {
|
|
54
|
-
// DRY somehow?
|
|
55
|
-
nodeScroll.set(node, getDocumentScroll(node));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (isRootNode(node)) {
|
|
59
|
-
// scroll is not-composed event (https://javascript.info/shadow-dom-events)
|
|
60
|
-
app.nodes.attachNodeListener(node, 'scroll', (e) => {
|
|
61
|
-
setNodeScroll(e.target);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
app.attachEventListener(document, 'scroll', (e) => {
|
|
66
|
-
const target = e.target;
|
|
67
|
-
if (target === document) {
|
|
68
|
-
documentScroll = true;
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
setNodeScroll(target);
|
|
72
|
-
});
|
|
73
|
-
app.ticker.attach(() => {
|
|
74
|
-
if (documentScroll) {
|
|
75
|
-
sendSetViewportScroll();
|
|
76
|
-
documentScroll = false;
|
|
77
|
-
}
|
|
78
|
-
nodeScroll.forEach(sendSetNodeScroll);
|
|
79
|
-
nodeScroll.clear();
|
|
80
|
-
}, 5, false);
|
|
81
|
-
}
|
package/lib/modules/selection.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { SelectionChange } from '../app/messages.gen.js';
|
|
2
|
-
function selection(app) {
|
|
3
|
-
app.attachEventListener(document, 'selectionchange', () => {
|
|
4
|
-
const selection = document.getSelection();
|
|
5
|
-
if (selection !== null && !selection.isCollapsed) {
|
|
6
|
-
const selectionStart = app.nodes.getID(selection.anchorNode);
|
|
7
|
-
const selectionEnd = app.nodes.getID(selection.focusNode);
|
|
8
|
-
const selectedText = selection.toString().replace(/\s+/g, ' ');
|
|
9
|
-
if (selectionStart && selectionEnd) {
|
|
10
|
-
app.send(SelectionChange(selectionStart, selectionEnd, selectedText));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
app.send(SelectionChange(-1, -1, ''));
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
export default selection;
|
|
19
|
-
/** TODO: research how to get all in-between nodes inside selection range
|
|
20
|
-
* including nodes between anchor and focus nodes and their children
|
|
21
|
-
* without recursively searching the dom tree
|
|
22
|
-
*/
|
|
23
|
-
// if (selection.rangeCount) {
|
|
24
|
-
// const nodes = [];
|
|
25
|
-
// for (let i = 0; i < selection.rangeCount; i++) {
|
|
26
|
-
// const range = selection.getRangeAt(i);
|
|
27
|
-
// let node: Node | null = range.startContainer;
|
|
28
|
-
// while (node) {
|
|
29
|
-
// nodes.push(node);
|
|
30
|
-
// if (node === range.endContainer) break;
|
|
31
|
-
// node = node.nextSibling;
|
|
32
|
-
// }
|
|
33
|
-
// }
|
|
34
|
-
// // send selected nodes
|
|
35
|
-
// }
|
package/lib/modules/tabs.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { TabChange } from '../app/messages.gen.js';
|
|
2
|
-
export default function (app) {
|
|
3
|
-
function changeTab() {
|
|
4
|
-
if (!document.hidden) {
|
|
5
|
-
app.debug.log('Openreplay: tab change to' + app.session.getTabId());
|
|
6
|
-
app.send(TabChange(app.session.getTabId()));
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
app.attachEventListener(window, 'focus', changeTab, false, false);
|
|
10
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
export const WATCHED_TAGS_KEY = '__or__watched_tags__';
|
|
2
|
-
class TagWatcher {
|
|
3
|
-
constructor(sessionStorage, errLog, onTag) {
|
|
4
|
-
this.sessionStorage = sessionStorage;
|
|
5
|
-
this.errLog = errLog;
|
|
6
|
-
this.onTag = onTag;
|
|
7
|
-
this.intervals = {};
|
|
8
|
-
this.tags = [];
|
|
9
|
-
const tags = JSON.parse(sessionStorage.getItem(WATCHED_TAGS_KEY) ?? '[]');
|
|
10
|
-
this.setTags(tags);
|
|
11
|
-
this.observer = new IntersectionObserver((entries) => {
|
|
12
|
-
entries.forEach((entry) => {
|
|
13
|
-
if (entry.isIntersecting) {
|
|
14
|
-
if (entry.target) {
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
const tag = entry.target.__or_watcher_tagname;
|
|
17
|
-
if (tag) {
|
|
18
|
-
this.onTagRendered(tag);
|
|
19
|
-
}
|
|
20
|
-
this.observer.unobserve(entry.target);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
async fetchTags(ingest, token) {
|
|
27
|
-
return fetch(`${ingest}/v1/web/tags`, {
|
|
28
|
-
method: 'GET',
|
|
29
|
-
headers: {
|
|
30
|
-
Authorization: `Bearer ${token}`,
|
|
31
|
-
},
|
|
32
|
-
})
|
|
33
|
-
.then((r) => r.json())
|
|
34
|
-
.then(({ tags }) => {
|
|
35
|
-
if (tags && tags.length) {
|
|
36
|
-
this.setTags(tags);
|
|
37
|
-
const tagString = JSON.stringify(tags);
|
|
38
|
-
this.sessionStorage.setItem(WATCHED_TAGS_KEY, tagString || '');
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
.catch((e) => this.errLog(e));
|
|
42
|
-
}
|
|
43
|
-
setTags(tags) {
|
|
44
|
-
this.tags = tags;
|
|
45
|
-
this.intervals = {};
|
|
46
|
-
tags.forEach((tag) => {
|
|
47
|
-
this.intervals[tag.id] = setInterval(() => {
|
|
48
|
-
const possibleEls = document.querySelectorAll(tag.selector);
|
|
49
|
-
if (possibleEls.length > 0) {
|
|
50
|
-
const el = possibleEls[0];
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
el.__or_watcher_tagname = tag.id;
|
|
53
|
-
this.observer.observe(el);
|
|
54
|
-
}
|
|
55
|
-
}, 500);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
onTagRendered(tagId) {
|
|
59
|
-
if (this.intervals[tagId]) {
|
|
60
|
-
clearInterval(this.intervals[tagId]);
|
|
61
|
-
}
|
|
62
|
-
this.onTag(tagId);
|
|
63
|
-
}
|
|
64
|
-
clear() {
|
|
65
|
-
this.tags.forEach((tag) => {
|
|
66
|
-
clearInterval(this.intervals[tag.id]);
|
|
67
|
-
});
|
|
68
|
-
this.tags = [];
|
|
69
|
-
this.intervals = {};
|
|
70
|
-
this.observer.disconnect();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
export default TagWatcher;
|