@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/jest.config.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
|
2
|
-
const config = {
|
|
3
|
-
preset: 'ts-jest',
|
|
4
|
-
testEnvironment: 'jsdom',
|
|
5
|
-
collectCoverage: true,
|
|
6
|
-
collectCoverageFrom: ['src/**/*.ts', '!src/**/*.d.ts'],
|
|
7
|
-
// .js file extension fix
|
|
8
|
-
moduleNameMapper: {
|
|
9
|
-
'(.+)\\.js': '$1',
|
|
10
|
-
},
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default config
|
package/lib/app/canvas.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { hasTag } from './guards.js';
|
|
2
|
-
import { CanvasNode } from './messages.gen.js';
|
|
3
|
-
class CanvasRecorder {
|
|
4
|
-
constructor(app, options) {
|
|
5
|
-
this.app = app;
|
|
6
|
-
this.options = options;
|
|
7
|
-
this.snapshots = {};
|
|
8
|
-
this.intervals = [];
|
|
9
|
-
this.restartTracking = () => {
|
|
10
|
-
this.clear();
|
|
11
|
-
this.app.nodes.scanTree(this.captureCanvas);
|
|
12
|
-
};
|
|
13
|
-
this.captureCanvas = (node) => {
|
|
14
|
-
const id = this.app.nodes.getID(node);
|
|
15
|
-
if (!id || !hasTag(node, 'canvas')) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const isIgnored = this.app.sanitizer.isObscured(id) || this.app.sanitizer.isHidden(id);
|
|
19
|
-
if (isIgnored || !hasTag(node, 'canvas') || this.snapshots[id]) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const observer = new IntersectionObserver((entries) => {
|
|
23
|
-
entries.forEach((entry) => {
|
|
24
|
-
if (entry.isIntersecting) {
|
|
25
|
-
if (entry.target) {
|
|
26
|
-
if (this.snapshots[id] && this.snapshots[id].createdAt) {
|
|
27
|
-
this.snapshots[id].paused = false;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
this.recordCanvas(entry.target, id);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* We can switch this to start observing when element is in the view
|
|
34
|
-
* but otherwise right now we're just pausing when it's not
|
|
35
|
-
* just to save some bandwidth and space on backend
|
|
36
|
-
* */
|
|
37
|
-
// observer.unobserve(entry.target)
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
if (this.snapshots[id]) {
|
|
41
|
-
this.snapshots[id].paused = true;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
observer.observe(node);
|
|
48
|
-
};
|
|
49
|
-
this.recordCanvas = (node, id) => {
|
|
50
|
-
const ts = this.app.timestamp();
|
|
51
|
-
this.snapshots[id] = {
|
|
52
|
-
images: [],
|
|
53
|
-
createdAt: ts,
|
|
54
|
-
paused: false,
|
|
55
|
-
dummy: document.createElement('canvas'),
|
|
56
|
-
};
|
|
57
|
-
const canvasMsg = CanvasNode(id.toString(), ts);
|
|
58
|
-
this.app.send(canvasMsg);
|
|
59
|
-
const captureFn = (canvas) => {
|
|
60
|
-
captureSnapshot(canvas, this.options.quality, this.snapshots[id].dummy, this.options.fixedScaling, this.fileExt, (blob) => {
|
|
61
|
-
if (!blob)
|
|
62
|
-
return;
|
|
63
|
-
if (!this.snapshots[id]) {
|
|
64
|
-
return this.app.debug.warn('Canvas not present in snapshots after capture:', this.snapshots, id);
|
|
65
|
-
}
|
|
66
|
-
this.snapshots[id].images.push({ id: this.app.timestamp(), data: blob });
|
|
67
|
-
if (this.snapshots[id].images.length > 9) {
|
|
68
|
-
this.sendSnaps(this.snapshots[id].images, id, this.snapshots[id].createdAt);
|
|
69
|
-
this.snapshots[id].images = [];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
const int = setInterval(() => {
|
|
74
|
-
const cid = this.app.nodes.getID(node);
|
|
75
|
-
const canvas = cid ? this.app.nodes.getNode(cid) : undefined;
|
|
76
|
-
if (!this.snapshots[id]) {
|
|
77
|
-
this.app.debug.log('Canvas is not present in {snapshots}');
|
|
78
|
-
clearInterval(int);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
if (!canvas || !hasTag(canvas, 'canvas') || canvas !== node) {
|
|
82
|
-
this.app.debug.log('Canvas element not in sync', canvas, node);
|
|
83
|
-
clearInterval(int);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
if (!this.snapshots[id].paused) {
|
|
88
|
-
if (this.options.useAnimationFrame) {
|
|
89
|
-
requestAnimationFrame(() => {
|
|
90
|
-
captureFn(canvas);
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
captureFn(canvas);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}, this.interval);
|
|
99
|
-
this.intervals.push(int);
|
|
100
|
-
};
|
|
101
|
-
this.fileExt = options.fileExt ?? 'webp';
|
|
102
|
-
this.interval = 1000 / options.fps;
|
|
103
|
-
}
|
|
104
|
-
startTracking() {
|
|
105
|
-
setTimeout(() => {
|
|
106
|
-
this.app.nodes.scanTree(this.captureCanvas);
|
|
107
|
-
this.app.nodes.attachNodeCallback(this.captureCanvas);
|
|
108
|
-
}, 250);
|
|
109
|
-
}
|
|
110
|
-
sendSnaps(images, canvasId, createdAt) {
|
|
111
|
-
if (Object.keys(this.snapshots).length === 0) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
const formData = new FormData();
|
|
115
|
-
images.forEach((snapshot) => {
|
|
116
|
-
const blob = snapshot.data;
|
|
117
|
-
if (!blob)
|
|
118
|
-
return;
|
|
119
|
-
formData.append('snapshot', blob, `${createdAt}_${canvasId}_${snapshot.id}.${this.fileExt}`);
|
|
120
|
-
if (this.options.isDebug) {
|
|
121
|
-
saveImageData(blob, `${createdAt}_${canvasId}_${snapshot.id}.${this.fileExt}`);
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
const initRestart = () => {
|
|
125
|
-
this.app.debug.log('Restarting tracker; token expired');
|
|
126
|
-
this.app.stop(false);
|
|
127
|
-
setTimeout(() => {
|
|
128
|
-
void this.app.start({}, true);
|
|
129
|
-
}, 250);
|
|
130
|
-
};
|
|
131
|
-
fetch(this.app.options.ingestPoint + '/v1/web/images', {
|
|
132
|
-
method: 'POST',
|
|
133
|
-
headers: {
|
|
134
|
-
Authorization: `Bearer ${this.app.session.getSessionToken() ?? ''}`,
|
|
135
|
-
},
|
|
136
|
-
body: formData,
|
|
137
|
-
})
|
|
138
|
-
.then((r) => {
|
|
139
|
-
if (r.status === 401) {
|
|
140
|
-
return initRestart();
|
|
141
|
-
}
|
|
142
|
-
return true;
|
|
143
|
-
})
|
|
144
|
-
.catch((e) => {
|
|
145
|
-
this.app.debug.error('error saving canvas', e);
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
clear() {
|
|
149
|
-
this.intervals.forEach((int) => clearInterval(int));
|
|
150
|
-
this.snapshots = {};
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
const qualityInt = {
|
|
154
|
-
low: 0.35,
|
|
155
|
-
medium: 0.55,
|
|
156
|
-
high: 0.8,
|
|
157
|
-
};
|
|
158
|
-
function captureSnapshot(canvas, quality = 'medium', dummy, fixedScaling = false, fileExt, onBlob) {
|
|
159
|
-
const imageFormat = `image/${fileExt}`;
|
|
160
|
-
if (fixedScaling) {
|
|
161
|
-
const canvasScaleRatio = window.devicePixelRatio || 1;
|
|
162
|
-
dummy.width = canvas.width / canvasScaleRatio;
|
|
163
|
-
dummy.height = canvas.height / canvasScaleRatio;
|
|
164
|
-
const ctx = dummy.getContext('2d');
|
|
165
|
-
if (!ctx) {
|
|
166
|
-
return '';
|
|
167
|
-
}
|
|
168
|
-
ctx.clearRect(0, 0, dummy.width, dummy.height);
|
|
169
|
-
ctx.drawImage(canvas, 0, 0, dummy.width, dummy.height);
|
|
170
|
-
dummy.toBlob(onBlob, imageFormat, qualityInt[quality]);
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
canvas.toBlob(onBlob, imageFormat, qualityInt[quality]);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
function saveImageData(imageDataBlob, name) {
|
|
177
|
-
const imageDataUrl = URL.createObjectURL(imageDataBlob);
|
|
178
|
-
const link = document.createElement('a');
|
|
179
|
-
link.href = imageDataUrl;
|
|
180
|
-
link.download = name;
|
|
181
|
-
link.style.display = 'none';
|
|
182
|
-
document.body.appendChild(link);
|
|
183
|
-
link.click();
|
|
184
|
-
document.body.removeChild(link);
|
|
185
|
-
}
|
|
186
|
-
function dataUrlToBlob(dataUrl) {
|
|
187
|
-
const [header, base64] = dataUrl.split(',');
|
|
188
|
-
if (!header || !base64)
|
|
189
|
-
return null;
|
|
190
|
-
const encParts = header.match(/:(.*?);/);
|
|
191
|
-
if (!encParts)
|
|
192
|
-
return null;
|
|
193
|
-
const mime = encParts[1];
|
|
194
|
-
const blobStr = atob(base64);
|
|
195
|
-
let n = blobStr.length;
|
|
196
|
-
const u8arr = new Uint8Array(n);
|
|
197
|
-
while (n--) {
|
|
198
|
-
u8arr[n] = blobStr.charCodeAt(n);
|
|
199
|
-
}
|
|
200
|
-
return [new Blob([u8arr], { type: mime }), u8arr];
|
|
201
|
-
}
|
|
202
|
-
export default CanvasRecorder;
|
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
|
-
}
|