@highlight-run/rrweb 2.0.1 → 2.0.4

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.
Files changed (117) hide show
  1. package/dist/plugins/console-record.js +408 -609
  2. package/dist/plugins/console-record.min.js +12 -15
  3. package/dist/plugins/console-record.min.js.map +1 -1
  4. package/dist/plugins/console-replay.js +142 -271
  5. package/dist/plugins/console-replay.min.js +4 -15
  6. package/dist/plugins/console-replay.min.js.map +1 -1
  7. package/dist/plugins/sequential-id-record.js +23 -26
  8. package/dist/plugins/sequential-id-record.min.js +1 -1
  9. package/dist/plugins/sequential-id-record.min.js.map +1 -1
  10. package/dist/plugins/sequential-id-replay.js +26 -30
  11. package/dist/plugins/sequential-id-replay.min.js +1 -1
  12. package/dist/plugins/sequential-id-replay.min.js.map +1 -1
  13. package/dist/record/rrweb-record-pack.js +63 -146
  14. package/dist/record/rrweb-record-pack.min.js +3 -15
  15. package/dist/record/rrweb-record-pack.min.js.map +1 -1
  16. package/dist/record/rrweb-record.js +3002 -3118
  17. package/dist/record/rrweb-record.min.js +4 -15
  18. package/dist/record/rrweb-record.min.js.map +1 -1
  19. package/dist/replay/rrweb-replay-unpack.js +4354 -4054
  20. package/dist/replay/rrweb-replay-unpack.min.js +5 -17
  21. package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
  22. package/dist/replay/rrweb-replay.js +4286 -3984
  23. package/dist/replay/rrweb-replay.min.js +5 -17
  24. package/dist/replay/rrweb-replay.min.js.map +1 -1
  25. package/dist/rrweb-all.js +7634 -7453
  26. package/dist/rrweb-all.min.js +16 -17
  27. package/dist/rrweb-all.min.js.map +1 -1
  28. package/dist/rrweb.js +7339 -7075
  29. package/dist/rrweb.min.js +6 -17
  30. package/dist/rrweb.min.js.map +1 -1
  31. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
  32. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
  33. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +31 -0
  34. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
  35. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
  36. package/es/rrweb/_virtual/image-bitmap-data-url-worker.js +6 -0
  37. package/es/rrweb/ext/mitt/dist/mitt.es.js +1 -1
  38. package/es/rrweb/ext/tslib/tslib.es6.js +38 -0
  39. package/es/rrweb/packages/rrdom/es/virtual-dom.js +1099 -0
  40. package/es/rrweb/packages/rrweb/src/index.js +6 -4
  41. package/es/rrweb/packages/rrweb/src/packer/base.js +1 -1
  42. package/es/rrweb/packages/rrweb/src/packer/pack.js +4 -5
  43. package/es/rrweb/packages/rrweb/src/packer/unpack.js +24 -24
  44. package/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js +175 -176
  45. package/es/rrweb/packages/rrweb/src/plugins/console/record/index.js +109 -128
  46. package/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js +125 -138
  47. package/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js +88 -105
  48. package/es/rrweb/packages/rrweb/src/plugins/sequential-id/record/index.js +19 -20
  49. package/es/rrweb/packages/rrweb/src/plugins/sequential-id/replay/index.js +25 -25
  50. package/es/rrweb/packages/rrweb/src/record/iframe-manager.js +29 -30
  51. package/es/rrweb/packages/rrweb/src/record/index.js +348 -373
  52. package/es/rrweb/packages/rrweb/src/record/mutation.js +487 -528
  53. package/es/rrweb/packages/rrweb/src/record/observer.js +584 -659
  54. package/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +44 -73
  55. package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +166 -87
  56. package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +21 -26
  57. package/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js +119 -112
  58. package/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +53 -72
  59. package/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js +38 -40
  60. package/es/rrweb/packages/rrweb/src/record/stylesheet-manager.js +31 -0
  61. package/es/rrweb/packages/rrweb/src/replay/canvas/2d.js +27 -23
  62. package/es/rrweb/packages/rrweb/src/replay/canvas/deserialize-args.js +67 -0
  63. package/es/rrweb/packages/rrweb/src/replay/canvas/index.js +37 -29
  64. package/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js +58 -120
  65. package/es/rrweb/packages/rrweb/src/replay/index.js +1545 -1854
  66. package/es/rrweb/packages/rrweb/src/replay/machine.js +275 -315
  67. package/es/rrweb/packages/rrweb/src/replay/smoothscroll.js +216 -218
  68. package/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js +7 -7
  69. package/es/rrweb/packages/rrweb/src/replay/timer.js +87 -91
  70. package/es/rrweb/packages/rrweb/src/types.js +72 -72
  71. package/es/rrweb/packages/rrweb/src/utils.js +312 -506
  72. package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +195 -71
  73. package/lib/plugins/console-record.js +469 -627
  74. package/lib/plugins/console-replay.js +198 -268
  75. package/lib/plugins/sequential-id-record.js +19 -20
  76. package/lib/plugins/sequential-id-replay.js +25 -25
  77. package/lib/record/rrweb-record-pack.js +184 -139
  78. package/lib/record/rrweb-record.js +2473 -2425
  79. package/lib/replay/rrweb-replay-unpack.js +3797 -3343
  80. package/lib/replay/rrweb-replay.js +3742 -3288
  81. package/lib/rrweb-all.js +6725 -6247
  82. package/lib/rrweb.js +6157 -5632
  83. package/package.json +14 -13
  84. package/typings/packer/base.d.ts +1 -1
  85. package/typings/plugins/console/record/index.d.ts +1 -1
  86. package/typings/plugins/console/record/stringify.d.ts +1 -1
  87. package/typings/plugins/sequential-id/record/index.d.ts +1 -1
  88. package/typings/plugins/sequential-id/replay/index.d.ts +1 -1
  89. package/typings/record/iframe-manager.d.ts +3 -3
  90. package/typings/record/index.d.ts +1 -1
  91. package/typings/record/mutation.d.ts +2 -1
  92. package/typings/record/observers/canvas/2d.d.ts +2 -1
  93. package/typings/record/observers/canvas/canvas-manager.d.ts +5 -2
  94. package/typings/record/observers/canvas/canvas.d.ts +1 -1
  95. package/typings/record/observers/canvas/serialize-args.d.ts +5 -5
  96. package/typings/record/observers/canvas/webgl.d.ts +2 -1
  97. package/typings/record/shadow-dom-manager.d.ts +2 -1
  98. package/typings/record/stylesheet-manager.d.ts +12 -0
  99. package/typings/record/workers/image-bitmap-data-url-worker.d.ts +5 -0
  100. package/typings/replay/canvas/2d.d.ts +3 -3
  101. package/typings/replay/canvas/deserialize-args.d.ts +7 -0
  102. package/typings/replay/canvas/index.d.ts +4 -3
  103. package/typings/replay/canvas/webgl.d.ts +3 -5
  104. package/typings/replay/index.d.ts +7 -10
  105. package/typings/types.d.ts +45 -17
  106. package/typings/utils.d.ts +17 -44
  107. package/dist/replay/rrweb-replay-unpack.min.css +0 -2
  108. package/dist/replay/rrweb-replay-unpack.min.css.map +0 -1
  109. package/dist/replay/rrweb-replay.min.css +0 -2
  110. package/dist/replay/rrweb-replay.min.css.map +0 -1
  111. package/dist/rrweb-all.min.css +0 -2
  112. package/dist/rrweb-all.min.css.map +0 -1
  113. package/dist/rrweb.min.css +0 -2
  114. package/dist/rrweb.min.css.map +0 -1
  115. package/es/rrweb/packages/rrweb/ext/tslib/tslib.es6.js +0 -78
  116. package/es/rrweb/packages/rrweb/src/replay/virtual-styles.js +0 -121
  117. 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
- var e_1, _a;
7
- var handlers = [];
8
- var props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
9
- var _loop_1 = function (prop) {
10
- try {
11
- if (typeof win.CanvasRenderingContext2D.prototype[prop] !== 'function') {
12
- return "continue";
13
- }
14
- var restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function (original) {
15
- return function () {
16
- var _this = this;
17
- var args = [];
18
- for (var _i = 0; _i < arguments.length; _i++) {
19
- args[_i] = arguments[_i];
20
- }
21
- if (!isBlocked(this.canvas, blockClass)) {
22
- setTimeout(function () {
23
- var recordArgs = __spreadArray([], __read(args), false);
24
- if (prop === 'drawImage') {
25
- if (recordArgs[0] &&
26
- recordArgs[0] instanceof HTMLCanvasElement) {
27
- var canvas = recordArgs[0];
28
- var ctx = canvas.getContext('2d');
29
- var imgd = ctx === null || ctx === void 0 ? void 0 : ctx.getImageData(0, 0, canvas.width, canvas.height);
30
- var pix = imgd === null || imgd === void 0 ? void 0 : imgd.data;
31
- recordArgs[0] = JSON.stringify(pix);
32
- }
33
- }
34
- cb(_this.canvas, {
35
- type: CanvasContext['2D'],
36
- property: prop,
37
- args: recordArgs,
38
- });
39
- }, 0);
40
- }
41
- return original.apply(this, args);
42
- };
43
- });
44
- handlers.push(restoreHandler);
45
- }
46
- catch (_b) {
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 initCanvas2DMutationObserver;
49
+ export { initCanvas2DMutationObserver as default };
@@ -1,93 +1,172 @@
1
- import { __rest } from '../../../../ext/tslib/tslib.es6.js';
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
- var CanvasManager = (function () {
7
- function CanvasManager(options) {
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
- var newFrame = this.rafStamps.invokeId &&
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
- this.mutationCb = options.mutationCb;
23
- this.mirror = options.mirror;
24
- if (options.recordCanvas === true)
25
- this.initCanvasMutationObserver(options.win, options.blockClass);
26
- }
27
- CanvasManager.prototype.reset = function () {
28
- this.pendingCanvasMutations.clear();
29
- this.resetObservers && this.resetObservers();
30
- };
31
- CanvasManager.prototype.freeze = function () {
32
- this.frozen = true;
33
- };
34
- CanvasManager.prototype.unfreeze = function () {
35
- this.frozen = false;
36
- };
37
- CanvasManager.prototype.lock = function () {
38
- this.locked = true;
39
- };
40
- CanvasManager.prototype.unlock = function () {
41
- this.locked = false;
42
- };
43
- CanvasManager.prototype.initCanvasMutationObserver = function (win, blockClass) {
44
- this.startRAFTimestamping();
45
- this.startPendingCanvasMutationFlusher();
46
- var canvasContextReset = initCanvasContextObserver(win, blockClass);
47
- var canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
48
- var canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
49
- this.resetObservers = function () {
50
- canvasContextReset();
51
- canvas2DReset();
52
- canvasWebGL1and2Reset();
53
- };
54
- };
55
- CanvasManager.prototype.startPendingCanvasMutationFlusher = function () {
56
- var _this = this;
57
- requestAnimationFrame(function () { return _this.flushPendingCanvasMutations(); });
58
- };
59
- CanvasManager.prototype.startRAFTimestamping = function () {
60
- var _this = this;
61
- var setLatestRAFTimestamp = function (timestamp) {
62
- _this.rafStamps.latestId = timestamp;
63
- requestAnimationFrame(setLatestRAFTimestamp);
64
- };
65
- requestAnimationFrame(setLatestRAFTimestamp);
66
- };
67
- CanvasManager.prototype.flushPendingCanvasMutations = function () {
68
- var _this = this;
69
- this.pendingCanvasMutations.forEach(function (values, canvas) {
70
- var id = _this.mirror.getId(canvas);
71
- _this.flushPendingCanvasMutationFor(canvas, id);
72
- });
73
- requestAnimationFrame(function () { return _this.flushPendingCanvasMutations(); });
74
- };
75
- CanvasManager.prototype.flushPendingCanvasMutationFor = function (canvas, id) {
76
- if (this.frozen || this.locked) {
77
- return;
78
- }
79
- var valuesWithType = this.pendingCanvasMutations.get(canvas);
80
- if (!valuesWithType || id === -1)
81
- return;
82
- var values = valuesWithType.map(function (value) {
83
- value.type; var rest = __rest(value, ["type"]);
84
- return rest;
85
- });
86
- var type = valuesWithType[0].type;
87
- this.mutationCb({ id: id, type: type, commands: values });
88
- this.pendingCanvasMutations.delete(canvas);
89
- };
90
- return CanvasManager;
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
- var handlers = [];
6
- try {
7
- var restoreHandler = patch(win.HTMLCanvasElement.prototype, 'getContext', function (original) {
8
- return function (contextType) {
9
- var args = [];
10
- for (var _i = 1; _i < arguments.length; _i++) {
11
- args[_i - 1] = arguments[_i];
12
- }
13
- if (!isBlocked(this, blockClass)) {
14
- if (!('__context' in this))
15
- this.__context = contextType;
16
- }
17
- return original.apply(this, __spreadArray([contextType], __read(args), false));
18
- };
19
- });
20
- handlers.push(restoreHandler);
21
- }
22
- catch (_a) {
23
- console.error('failed to patch HTMLCanvasElement.prototype.getContext');
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 initCanvasContextObserver;
25
+ export { initCanvasContextObserver as default };