@highlight-run/rrweb 2.0.1 → 2.0.6
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/dist/plugins/console-record.js +12 -655
- package/dist/plugins/console-record.min.js +12 -15
- package/dist/plugins/console-record.min.js.map +1 -1
- package/dist/plugins/console-replay.js +4 -293
- package/dist/plugins/console-replay.min.js +4 -15
- package/dist/plugins/console-replay.min.js.map +1 -1
- package/dist/plugins/sequential-id-record.js +1 -33
- package/dist/plugins/sequential-id-record.min.js +1 -1
- package/dist/plugins/sequential-id-record.min.js.map +1 -1
- package/dist/plugins/sequential-id-replay.js +1 -37
- package/dist/plugins/sequential-id-replay.min.js +1 -1
- package/dist/plugins/sequential-id-replay.min.js.map +1 -1
- package/dist/record/rrweb-record-pack.js +3 -747
- package/dist/record/rrweb-record-pack.min.js +3 -15
- package/dist/record/rrweb-record-pack.min.js.map +1 -1
- package/dist/record/rrweb-record.js +4 -3318
- package/dist/record/rrweb-record.min.js +4 -15
- package/dist/record/rrweb-record.min.js.map +1 -1
- package/dist/replay/rrweb-replay-unpack.css +1 -0
- package/dist/replay/rrweb-replay-unpack.js +5 -4614
- package/dist/replay/rrweb-replay-unpack.min.js +5 -17
- package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
- package/dist/replay/rrweb-replay.css +1 -0
- package/dist/replay/rrweb-replay.js +5 -4204
- package/dist/replay/rrweb-replay.min.js +5 -17
- package/dist/replay/rrweb-replay.min.js.map +1 -1
- package/dist/rrweb-all.css +1 -0
- package/dist/rrweb-all.js +16 -8696
- package/dist/rrweb-all.min.js +16 -17
- package/dist/rrweb-all.min.js.map +1 -1
- package/dist/rrweb.css +1 -0
- package/dist/rrweb.js +6 -7282
- package/dist/rrweb.min.js +6 -17
- package/dist/rrweb.min.js.map +1 -1
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +31 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
- package/es/rrweb/_virtual/image-bitmap-data-url-worker.js +6 -0
- package/es/rrweb/all.css +1 -0
- package/es/rrweb/ext/mitt/dist/mitt.es.js +1 -1
- package/es/rrweb/ext/tslib/tslib.es6.js +38 -0
- package/es/rrweb/packages/rrdom/es/virtual-dom.js +1099 -0
- package/es/rrweb/packages/rrweb/src/index.js +6 -4
- package/es/rrweb/packages/rrweb/src/packer/base.js +1 -1
- package/es/rrweb/packages/rrweb/src/packer/pack.js +4 -5
- package/es/rrweb/packages/rrweb/src/packer/unpack.js +24 -24
- package/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js +175 -176
- package/es/rrweb/packages/rrweb/src/plugins/console/record/index.js +109 -128
- package/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js +125 -138
- package/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js +88 -105
- package/es/rrweb/packages/rrweb/src/plugins/sequential-id/record/index.js +19 -20
- package/es/rrweb/packages/rrweb/src/plugins/sequential-id/replay/index.js +25 -25
- package/es/rrweb/packages/rrweb/src/record/iframe-manager.js +29 -30
- package/es/rrweb/packages/rrweb/src/record/index.js +348 -373
- package/es/rrweb/packages/rrweb/src/record/mutation.js +487 -528
- package/es/rrweb/packages/rrweb/src/record/observer.js +584 -659
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +44 -73
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +166 -87
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +21 -26
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js +119 -112
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +53 -72
- package/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js +38 -40
- package/es/rrweb/packages/rrweb/src/record/stylesheet-manager.js +31 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/2d.js +27 -23
- package/es/rrweb/packages/rrweb/src/replay/canvas/deserialize-args.js +67 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/index.js +37 -29
- package/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js +58 -120
- package/es/rrweb/packages/rrweb/src/replay/index.js +1545 -1854
- package/es/rrweb/packages/rrweb/src/replay/machine.js +275 -315
- package/es/rrweb/packages/rrweb/src/replay/smoothscroll.js +216 -218
- package/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js +7 -7
- package/es/rrweb/packages/rrweb/src/replay/timer.js +87 -91
- package/es/rrweb/packages/rrweb/src/types.js +72 -72
- package/es/rrweb/packages/rrweb/src/utils.js +312 -506
- package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +190 -72
- package/lib/plugins/console-record.js +469 -627
- package/lib/plugins/console-replay.js +198 -268
- package/lib/plugins/sequential-id-record.js +19 -20
- package/lib/plugins/sequential-id-replay.js +25 -25
- package/lib/record/rrweb-record-pack.js +184 -139
- package/lib/record/rrweb-record.js +2467 -2425
- package/lib/replay/rrweb-replay-unpack.css +1 -0
- package/lib/replay/rrweb-replay-unpack.js +3798 -3344
- package/lib/replay/rrweb-replay.css +1 -0
- package/lib/replay/rrweb-replay.js +3743 -3289
- package/lib/rrweb-all.css +1 -0
- package/lib/rrweb-all.js +6721 -6249
- package/lib/rrweb.css +1 -0
- package/lib/rrweb.js +6151 -5632
- package/package.json +14 -13
- package/typings/packer/base.d.ts +1 -1
- package/typings/plugins/console/record/index.d.ts +1 -1
- package/typings/plugins/console/record/stringify.d.ts +1 -1
- package/typings/plugins/sequential-id/record/index.d.ts +1 -1
- package/typings/plugins/sequential-id/replay/index.d.ts +1 -1
- package/typings/record/iframe-manager.d.ts +3 -3
- package/typings/record/index.d.ts +1 -1
- package/typings/record/mutation.d.ts +2 -1
- package/typings/record/observers/canvas/2d.d.ts +2 -1
- package/typings/record/observers/canvas/canvas-manager.d.ts +5 -2
- package/typings/record/observers/canvas/canvas.d.ts +1 -1
- package/typings/record/observers/canvas/serialize-args.d.ts +5 -5
- package/typings/record/observers/canvas/webgl.d.ts +2 -1
- package/typings/record/shadow-dom-manager.d.ts +2 -1
- package/typings/record/stylesheet-manager.d.ts +12 -0
- package/typings/record/workers/image-bitmap-data-url-worker.d.ts +5 -0
- package/typings/replay/canvas/2d.d.ts +3 -3
- package/typings/replay/canvas/deserialize-args.d.ts +7 -0
- package/typings/replay/canvas/index.d.ts +4 -3
- package/typings/replay/canvas/webgl.d.ts +3 -5
- package/typings/replay/index.d.ts +7 -10
- package/typings/types.d.ts +45 -17
- package/typings/utils.d.ts +17 -44
- package/es/rrweb/packages/rrweb/ext/tslib/tslib.es6.js +0 -78
- package/es/rrweb/packages/rrweb/src/replay/virtual-styles.js +0 -121
- package/typings/replay/virtual-styles.d.ts +0 -43
|
@@ -1,78 +1,49 @@
|
|
|
1
|
-
import { __values, __spreadArray, __read } from '../../../../ext/tslib/tslib.es6.js';
|
|
2
1
|
import { CanvasContext } from '../../../types.js';
|
|
3
2
|
import { patch, isBlocked, hookSetter } from '../../../utils.js';
|
|
3
|
+
import { serializeArgs } from './serialize-args.js';
|
|
4
4
|
|
|
5
|
-
function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
|
|
48
|
-
set: function (v) {
|
|
49
|
-
cb(this.canvas, {
|
|
50
|
-
type: CanvasContext['2D'],
|
|
51
|
-
property: prop,
|
|
52
|
-
args: [v],
|
|
53
|
-
setter: true,
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
handlers.push(hookHandler);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
try {
|
|
61
|
-
for (var props2D_1 = __values(props2D), props2D_1_1 = props2D_1.next(); !props2D_1_1.done; props2D_1_1 = props2D_1.next()) {
|
|
62
|
-
var prop = props2D_1_1.value;
|
|
63
|
-
_loop_1(prop);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
67
|
-
finally {
|
|
68
|
-
try {
|
|
69
|
-
if (props2D_1_1 && !props2D_1_1.done && (_a = props2D_1.return)) _a.call(props2D_1);
|
|
70
|
-
}
|
|
71
|
-
finally { if (e_1) throw e_1.error; }
|
|
72
|
-
}
|
|
73
|
-
return function () {
|
|
74
|
-
handlers.forEach(function (h) { return h(); });
|
|
75
|
-
};
|
|
5
|
+
function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
|
|
6
|
+
const handlers = [];
|
|
7
|
+
const props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
|
|
8
|
+
for (const prop of props2D) {
|
|
9
|
+
try {
|
|
10
|
+
if (typeof win.CanvasRenderingContext2D.prototype[prop] !== 'function') {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function (original) {
|
|
14
|
+
return function (...args) {
|
|
15
|
+
if (!isBlocked(this.canvas, blockClass)) {
|
|
16
|
+
setTimeout(() => {
|
|
17
|
+
const recordArgs = serializeArgs([...args], win, this);
|
|
18
|
+
cb(this.canvas, {
|
|
19
|
+
type: CanvasContext['2D'],
|
|
20
|
+
property: prop,
|
|
21
|
+
args: recordArgs,
|
|
22
|
+
});
|
|
23
|
+
}, 0);
|
|
24
|
+
}
|
|
25
|
+
return original.apply(this, args);
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
handlers.push(restoreHandler);
|
|
29
|
+
}
|
|
30
|
+
catch (_a) {
|
|
31
|
+
const hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
|
|
32
|
+
set(v) {
|
|
33
|
+
cb(this.canvas, {
|
|
34
|
+
type: CanvasContext['2D'],
|
|
35
|
+
property: prop,
|
|
36
|
+
args: [v],
|
|
37
|
+
setter: true,
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
handlers.push(hookHandler);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return () => {
|
|
45
|
+
handlers.forEach((h) => h());
|
|
46
|
+
};
|
|
76
47
|
}
|
|
77
48
|
|
|
78
|
-
export default
|
|
49
|
+
export { initCanvas2DMutationObserver as default };
|
|
@@ -1,93 +1,172 @@
|
|
|
1
|
-
import { __rest } from '
|
|
1
|
+
import { __rest, __awaiter } from './../../../../../../ext/tslib/tslib.es6.js';
|
|
2
|
+
import { CanvasContext } from '../../../types.js';
|
|
2
3
|
import initCanvas2DMutationObserver from './2d.js';
|
|
3
4
|
import initCanvasContextObserver from './canvas.js';
|
|
4
5
|
import initCanvasWebGLMutationObserver from './webgl.js';
|
|
6
|
+
import WorkerFactory from '../../../../../../_virtual/image-bitmap-data-url-worker.js';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
this.pendingCanvasMutations = new Map();
|
|
9
|
-
this.rafStamps = { latestId: 0, invokeId: null };
|
|
10
|
-
this.frozen = false;
|
|
11
|
-
this.locked = false;
|
|
12
|
-
this.processMutation = function (target, mutation) {
|
|
13
|
-
|
|
14
|
-
this.rafStamps.latestId !== this.rafStamps.invokeId;
|
|
15
|
-
if (newFrame || !this.rafStamps.invokeId)
|
|
16
|
-
this.rafStamps.invokeId = this.rafStamps.latestId;
|
|
17
|
-
if (!this.pendingCanvasMutations.has(target)) {
|
|
18
|
-
this.pendingCanvasMutations.set(target, []);
|
|
19
|
-
}
|
|
20
|
-
this.pendingCanvasMutations.get(target).push(mutation);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
this.frozen =
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
this.
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
this.locked =
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
this.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
8
|
+
class CanvasManager {
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.pendingCanvasMutations = new Map();
|
|
11
|
+
this.rafStamps = { latestId: 0, invokeId: null };
|
|
12
|
+
this.frozen = false;
|
|
13
|
+
this.locked = false;
|
|
14
|
+
this.processMutation = function (target, mutation) {
|
|
15
|
+
const newFrame = this.rafStamps.invokeId &&
|
|
16
|
+
this.rafStamps.latestId !== this.rafStamps.invokeId;
|
|
17
|
+
if (newFrame || !this.rafStamps.invokeId)
|
|
18
|
+
this.rafStamps.invokeId = this.rafStamps.latestId;
|
|
19
|
+
if (!this.pendingCanvasMutations.has(target)) {
|
|
20
|
+
this.pendingCanvasMutations.set(target, []);
|
|
21
|
+
}
|
|
22
|
+
this.pendingCanvasMutations.get(target).push(mutation);
|
|
23
|
+
};
|
|
24
|
+
const { sampling = 'all', win, blockClass, recordCanvas } = options;
|
|
25
|
+
this.mutationCb = options.mutationCb;
|
|
26
|
+
this.mirror = options.mirror;
|
|
27
|
+
if (recordCanvas && sampling === 'all')
|
|
28
|
+
this.initCanvasMutationObserver(win, blockClass);
|
|
29
|
+
if (recordCanvas && typeof sampling === 'number')
|
|
30
|
+
this.initCanvasFPSObserver(sampling, win, blockClass);
|
|
31
|
+
}
|
|
32
|
+
reset() {
|
|
33
|
+
this.pendingCanvasMutations.clear();
|
|
34
|
+
this.resetObservers && this.resetObservers();
|
|
35
|
+
}
|
|
36
|
+
freeze() {
|
|
37
|
+
this.frozen = true;
|
|
38
|
+
}
|
|
39
|
+
unfreeze() {
|
|
40
|
+
this.frozen = false;
|
|
41
|
+
}
|
|
42
|
+
lock() {
|
|
43
|
+
this.locked = true;
|
|
44
|
+
}
|
|
45
|
+
unlock() {
|
|
46
|
+
this.locked = false;
|
|
47
|
+
}
|
|
48
|
+
initCanvasFPSObserver(fps, win, blockClass) {
|
|
49
|
+
const canvasContextReset = initCanvasContextObserver(win, blockClass);
|
|
50
|
+
const snapshotInProgressMap = new Map();
|
|
51
|
+
const worker = new WorkerFactory();
|
|
52
|
+
worker.onmessage = (e) => {
|
|
53
|
+
const { id } = e.data;
|
|
54
|
+
snapshotInProgressMap.set(id, false);
|
|
55
|
+
if (!('base64' in e.data))
|
|
56
|
+
return;
|
|
57
|
+
const { base64, type, width, height } = e.data;
|
|
58
|
+
this.mutationCb({
|
|
59
|
+
id,
|
|
60
|
+
type: CanvasContext['2D'],
|
|
61
|
+
commands: [
|
|
62
|
+
{
|
|
63
|
+
property: 'clearRect',
|
|
64
|
+
args: [0, 0, width, height],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
property: 'drawImage',
|
|
68
|
+
args: [
|
|
69
|
+
{
|
|
70
|
+
rr_type: 'ImageBitmap',
|
|
71
|
+
args: [
|
|
72
|
+
{
|
|
73
|
+
rr_type: 'Blob',
|
|
74
|
+
data: [{ rr_type: 'ArrayBuffer', base64 }],
|
|
75
|
+
type,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
0,
|
|
80
|
+
0,
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const timeBetweenSnapshots = 1000 / fps;
|
|
87
|
+
let lastSnapshotTime = 0;
|
|
88
|
+
let rafId;
|
|
89
|
+
const takeCanvasSnapshots = (timestamp) => {
|
|
90
|
+
if (lastSnapshotTime &&
|
|
91
|
+
timestamp - lastSnapshotTime < timeBetweenSnapshots) {
|
|
92
|
+
rafId = requestAnimationFrame(takeCanvasSnapshots);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
lastSnapshotTime = timestamp;
|
|
96
|
+
win.document
|
|
97
|
+
.querySelectorAll(`canvas:not(.${blockClass} *)`)
|
|
98
|
+
.forEach((canvas) => __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
var _a;
|
|
100
|
+
const id = this.mirror.getId(canvas);
|
|
101
|
+
if (snapshotInProgressMap.get(id))
|
|
102
|
+
return;
|
|
103
|
+
snapshotInProgressMap.set(id, true);
|
|
104
|
+
if (['webgl', 'webgl2'].includes(canvas.__context)) {
|
|
105
|
+
const context = canvas.getContext(canvas.__context);
|
|
106
|
+
if (((_a = context === null || context === void 0 ? void 0 : context.getContextAttributes()) === null || _a === void 0 ? void 0 : _a.preserveDrawingBuffer) === false) {
|
|
107
|
+
context === null || context === void 0 ? void 0 : context.clear(context.COLOR_BUFFER_BIT);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const bitmap = yield createImageBitmap(canvas);
|
|
111
|
+
worker.postMessage({
|
|
112
|
+
id,
|
|
113
|
+
bitmap,
|
|
114
|
+
width: canvas.width,
|
|
115
|
+
height: canvas.height,
|
|
116
|
+
}, [bitmap]);
|
|
117
|
+
}));
|
|
118
|
+
rafId = requestAnimationFrame(takeCanvasSnapshots);
|
|
119
|
+
};
|
|
120
|
+
rafId = requestAnimationFrame(takeCanvasSnapshots);
|
|
121
|
+
this.resetObservers = () => {
|
|
122
|
+
canvasContextReset();
|
|
123
|
+
cancelAnimationFrame(rafId);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
initCanvasMutationObserver(win, blockClass) {
|
|
127
|
+
this.startRAFTimestamping();
|
|
128
|
+
this.startPendingCanvasMutationFlusher();
|
|
129
|
+
const canvasContextReset = initCanvasContextObserver(win, blockClass);
|
|
130
|
+
const canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
|
|
131
|
+
const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
|
|
132
|
+
this.resetObservers = () => {
|
|
133
|
+
canvasContextReset();
|
|
134
|
+
canvas2DReset();
|
|
135
|
+
canvasWebGL1and2Reset();
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
startPendingCanvasMutationFlusher() {
|
|
139
|
+
requestAnimationFrame(() => this.flushPendingCanvasMutations());
|
|
140
|
+
}
|
|
141
|
+
startRAFTimestamping() {
|
|
142
|
+
const setLatestRAFTimestamp = (timestamp) => {
|
|
143
|
+
this.rafStamps.latestId = timestamp;
|
|
144
|
+
requestAnimationFrame(setLatestRAFTimestamp);
|
|
145
|
+
};
|
|
146
|
+
requestAnimationFrame(setLatestRAFTimestamp);
|
|
147
|
+
}
|
|
148
|
+
flushPendingCanvasMutations() {
|
|
149
|
+
this.pendingCanvasMutations.forEach((values, canvas) => {
|
|
150
|
+
const id = this.mirror.getId(canvas);
|
|
151
|
+
this.flushPendingCanvasMutationFor(canvas, id);
|
|
152
|
+
});
|
|
153
|
+
requestAnimationFrame(() => this.flushPendingCanvasMutations());
|
|
154
|
+
}
|
|
155
|
+
flushPendingCanvasMutationFor(canvas, id) {
|
|
156
|
+
if (this.frozen || this.locked) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const valuesWithType = this.pendingCanvasMutations.get(canvas);
|
|
160
|
+
if (!valuesWithType || id === -1)
|
|
161
|
+
return;
|
|
162
|
+
const values = valuesWithType.map((value) => {
|
|
163
|
+
const rest = __rest(value, ["type"]);
|
|
164
|
+
return rest;
|
|
165
|
+
});
|
|
166
|
+
const { type } = valuesWithType[0];
|
|
167
|
+
this.mutationCb({ id, type, commands: values });
|
|
168
|
+
this.pendingCanvasMutations.delete(canvas);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
92
171
|
|
|
93
172
|
export { CanvasManager };
|
|
@@ -1,30 +1,25 @@
|
|
|
1
|
-
import { __spreadArray, __read } from '../../../../ext/tslib/tslib.es6.js';
|
|
2
1
|
import { patch, isBlocked } from '../../../utils.js';
|
|
3
2
|
|
|
4
|
-
function initCanvasContextObserver(win, blockClass) {
|
|
5
|
-
|
|
6
|
-
try {
|
|
7
|
-
|
|
8
|
-
return function (contextType) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return function () {
|
|
26
|
-
handlers.forEach(function (h) { return h(); });
|
|
27
|
-
};
|
|
3
|
+
function initCanvasContextObserver(win, blockClass) {
|
|
4
|
+
const handlers = [];
|
|
5
|
+
try {
|
|
6
|
+
const restoreHandler = patch(win.HTMLCanvasElement.prototype, 'getContext', function (original) {
|
|
7
|
+
return function (contextType, ...args) {
|
|
8
|
+
if (!isBlocked(this, blockClass)) {
|
|
9
|
+
if (!('__context' in this))
|
|
10
|
+
(this).__context = contextType;
|
|
11
|
+
}
|
|
12
|
+
return original.apply(this, [contextType, ...args]);
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
handlers.push(restoreHandler);
|
|
16
|
+
}
|
|
17
|
+
catch (_a) {
|
|
18
|
+
console.error('failed to patch HTMLCanvasElement.prototype.getContext');
|
|
19
|
+
}
|
|
20
|
+
return () => {
|
|
21
|
+
handlers.forEach((h) => h());
|
|
22
|
+
};
|
|
28
23
|
}
|
|
29
24
|
|
|
30
|
-
export default
|
|
25
|
+
export { initCanvasContextObserver as default };
|