@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,116 +1,123 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { encode } from '../../../../../../ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js';
|
|
1
|
+
import { encode } from './../../../../../../ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
function variableListFor(ctx, ctor) {
|
|
6
|
-
|
|
7
|
-
if (!contextMap) {
|
|
8
|
-
contextMap = new Map();
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
if (!contextMap.has(ctor)) {
|
|
12
|
-
contextMap.set(ctor, []);
|
|
13
|
-
}
|
|
14
|
-
return contextMap.get(ctor);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (!value ||
|
|
18
|
-
!(isInstanceOfWebGLObject(value, win) || typeof value === 'object'))
|
|
19
|
-
return;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (index === -1) {
|
|
24
|
-
index = list.length;
|
|
25
|
-
list.push(value);
|
|
26
|
-
}
|
|
27
|
-
return index;
|
|
28
|
-
};
|
|
29
|
-
function serializeArg(value, win, ctx) {
|
|
30
|
-
if (value instanceof Array) {
|
|
31
|
-
return value.map(
|
|
32
|
-
}
|
|
33
|
-
else if (value === null) {
|
|
34
|
-
return value;
|
|
35
|
-
}
|
|
36
|
-
else if (value instanceof Float32Array ||
|
|
37
|
-
value instanceof Float64Array ||
|
|
38
|
-
value instanceof Int32Array ||
|
|
39
|
-
value instanceof Uint32Array ||
|
|
40
|
-
value instanceof Uint8Array ||
|
|
41
|
-
value instanceof Uint16Array ||
|
|
42
|
-
value instanceof Int16Array ||
|
|
43
|
-
value instanceof Int8Array ||
|
|
44
|
-
value instanceof Uint8ClampedArray) {
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
rr_type:
|
|
48
|
-
args: [Object.values(value)],
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
else if (value instanceof ArrayBuffer) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
rr_type:
|
|
56
|
-
base64
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
else if (value instanceof DataView) {
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
rr_type:
|
|
63
|
-
args: [
|
|
64
|
-
serializeArg(value.buffer, win, ctx),
|
|
65
|
-
value.byteOffset,
|
|
66
|
-
value.byteLength,
|
|
67
|
-
],
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
else if (value instanceof HTMLImageElement) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
rr_type:
|
|
75
|
-
src
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
else if (value instanceof
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
rr_type:
|
|
90
|
-
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
'
|
|
109
|
-
'
|
|
110
|
-
'
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
3
|
+
const canvasVarMap = new Map();
|
|
4
|
+
function variableListFor(ctx, ctor) {
|
|
5
|
+
let contextMap = canvasVarMap.get(ctx);
|
|
6
|
+
if (!contextMap) {
|
|
7
|
+
contextMap = new Map();
|
|
8
|
+
canvasVarMap.set(ctx, contextMap);
|
|
9
|
+
}
|
|
10
|
+
if (!contextMap.has(ctor)) {
|
|
11
|
+
contextMap.set(ctor, []);
|
|
12
|
+
}
|
|
13
|
+
return contextMap.get(ctor);
|
|
14
|
+
}
|
|
15
|
+
const saveWebGLVar = (value, win, ctx) => {
|
|
16
|
+
if (!value ||
|
|
17
|
+
!(isInstanceOfWebGLObject(value, win) || typeof value === 'object'))
|
|
18
|
+
return;
|
|
19
|
+
const name = value.constructor.name;
|
|
20
|
+
const list = variableListFor(ctx, name);
|
|
21
|
+
let index = list.indexOf(value);
|
|
22
|
+
if (index === -1) {
|
|
23
|
+
index = list.length;
|
|
24
|
+
list.push(value);
|
|
25
|
+
}
|
|
26
|
+
return index;
|
|
27
|
+
};
|
|
28
|
+
function serializeArg(value, win, ctx) {
|
|
29
|
+
if (value instanceof Array) {
|
|
30
|
+
return value.map((arg) => serializeArg(arg, win, ctx));
|
|
31
|
+
}
|
|
32
|
+
else if (value === null) {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
else if (value instanceof Float32Array ||
|
|
36
|
+
value instanceof Float64Array ||
|
|
37
|
+
value instanceof Int32Array ||
|
|
38
|
+
value instanceof Uint32Array ||
|
|
39
|
+
value instanceof Uint8Array ||
|
|
40
|
+
value instanceof Uint16Array ||
|
|
41
|
+
value instanceof Int16Array ||
|
|
42
|
+
value instanceof Int8Array ||
|
|
43
|
+
value instanceof Uint8ClampedArray) {
|
|
44
|
+
const name = value.constructor.name;
|
|
45
|
+
return {
|
|
46
|
+
rr_type: name,
|
|
47
|
+
args: [Object.values(value)],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
else if (value instanceof ArrayBuffer) {
|
|
51
|
+
const name = value.constructor.name;
|
|
52
|
+
const base64 = encode(value);
|
|
53
|
+
return {
|
|
54
|
+
rr_type: name,
|
|
55
|
+
base64,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
else if (value instanceof DataView) {
|
|
59
|
+
const name = value.constructor.name;
|
|
60
|
+
return {
|
|
61
|
+
rr_type: name,
|
|
62
|
+
args: [
|
|
63
|
+
serializeArg(value.buffer, win, ctx),
|
|
64
|
+
value.byteOffset,
|
|
65
|
+
value.byteLength,
|
|
66
|
+
],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
else if (value instanceof HTMLImageElement) {
|
|
70
|
+
const name = value.constructor.name;
|
|
71
|
+
const { src } = value;
|
|
72
|
+
return {
|
|
73
|
+
rr_type: name,
|
|
74
|
+
src,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
else if (value instanceof HTMLCanvasElement) {
|
|
78
|
+
const name = 'HTMLImageElement';
|
|
79
|
+
const src = value.toDataURL();
|
|
80
|
+
return {
|
|
81
|
+
rr_type: name,
|
|
82
|
+
src,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
else if (value instanceof ImageData) {
|
|
86
|
+
const name = value.constructor.name;
|
|
87
|
+
return {
|
|
88
|
+
rr_type: name,
|
|
89
|
+
args: [serializeArg(value.data, win, ctx), value.width, value.height],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
else if (isInstanceOfWebGLObject(value, win) || typeof value === 'object') {
|
|
93
|
+
const name = value.constructor.name;
|
|
94
|
+
const index = saveWebGLVar(value, win, ctx);
|
|
95
|
+
return {
|
|
96
|
+
rr_type: name,
|
|
97
|
+
index: index,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return value;
|
|
101
|
+
}
|
|
102
|
+
const serializeArgs = (args, win, ctx) => {
|
|
103
|
+
return [...args].map((arg) => serializeArg(arg, win, ctx));
|
|
104
|
+
};
|
|
105
|
+
const isInstanceOfWebGLObject = (value, win) => {
|
|
106
|
+
const webGLConstructorNames = [
|
|
107
|
+
'WebGLActiveInfo',
|
|
108
|
+
'WebGLBuffer',
|
|
109
|
+
'WebGLFramebuffer',
|
|
110
|
+
'WebGLProgram',
|
|
111
|
+
'WebGLRenderbuffer',
|
|
112
|
+
'WebGLShader',
|
|
113
|
+
'WebGLShaderPrecisionFormat',
|
|
114
|
+
'WebGLTexture',
|
|
115
|
+
'WebGLUniformLocation',
|
|
116
|
+
'WebGLVertexArrayObject',
|
|
117
|
+
'WebGLVertexArrayObjectOES',
|
|
118
|
+
];
|
|
119
|
+
const supportedWebGLConstructorNames = webGLConstructorNames.filter((name) => typeof win[name] === 'function');
|
|
120
|
+
return Boolean(supportedWebGLConstructorNames.find((name) => value instanceof win[name]));
|
|
114
121
|
};
|
|
115
122
|
|
|
116
123
|
export { isInstanceOfWebGLObject, saveWebGLVar, serializeArg, serializeArgs, variableListFor };
|
|
@@ -1,78 +1,59 @@
|
|
|
1
|
-
import { __spreadArray, __read, __values } from '../../../../ext/tslib/tslib.es6.js';
|
|
2
1
|
import { CanvasContext } from '../../../types.js';
|
|
3
2
|
import { patch, isBlocked, hookSetter } from '../../../utils.js';
|
|
4
3
|
import { saveWebGLVar, serializeArgs } from './serialize-args.js';
|
|
5
4
|
|
|
6
|
-
function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
59
|
-
finally {
|
|
60
|
-
try {
|
|
61
|
-
if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1);
|
|
62
|
-
}
|
|
63
|
-
finally { if (e_1) throw e_1.error; }
|
|
64
|
-
}
|
|
65
|
-
return handlers;
|
|
66
|
-
}
|
|
67
|
-
function initCanvasWebGLMutationObserver(cb, win, blockClass, mirror) {
|
|
68
|
-
var handlers = [];
|
|
69
|
-
handlers.push.apply(handlers, __spreadArray([], __read(patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, mirror, win)), false));
|
|
70
|
-
if (typeof win.WebGL2RenderingContext !== 'undefined') {
|
|
71
|
-
handlers.push.apply(handlers, __spreadArray([], __read(patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, mirror, win)), false));
|
|
72
|
-
}
|
|
73
|
-
return function () {
|
|
74
|
-
handlers.forEach(function (h) { return h(); });
|
|
75
|
-
};
|
|
5
|
+
function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
|
|
6
|
+
const handlers = [];
|
|
7
|
+
const props = Object.getOwnPropertyNames(prototype);
|
|
8
|
+
for (const prop of props) {
|
|
9
|
+
try {
|
|
10
|
+
if (typeof prototype[prop] !== 'function') {
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const restoreHandler = patch(prototype, prop, function (original) {
|
|
14
|
+
return function (...args) {
|
|
15
|
+
const result = original.apply(this, args);
|
|
16
|
+
saveWebGLVar(result, win, prototype);
|
|
17
|
+
if (!isBlocked(this.canvas, blockClass)) {
|
|
18
|
+
const id = mirror.getId(this.canvas);
|
|
19
|
+
const recordArgs = serializeArgs([...args], win, prototype);
|
|
20
|
+
const mutation = {
|
|
21
|
+
type,
|
|
22
|
+
property: prop,
|
|
23
|
+
args: recordArgs,
|
|
24
|
+
};
|
|
25
|
+
cb(this.canvas, mutation);
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
handlers.push(restoreHandler);
|
|
31
|
+
}
|
|
32
|
+
catch (_a) {
|
|
33
|
+
const hookHandler = hookSetter(prototype, prop, {
|
|
34
|
+
set(v) {
|
|
35
|
+
cb(this.canvas, {
|
|
36
|
+
type,
|
|
37
|
+
property: prop,
|
|
38
|
+
args: [v],
|
|
39
|
+
setter: true,
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
handlers.push(hookHandler);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return handlers;
|
|
47
|
+
}
|
|
48
|
+
function initCanvasWebGLMutationObserver(cb, win, blockClass, mirror) {
|
|
49
|
+
const handlers = [];
|
|
50
|
+
handlers.push(...patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass, mirror, win));
|
|
51
|
+
if (typeof win.WebGL2RenderingContext !== 'undefined') {
|
|
52
|
+
handlers.push(...patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass, mirror, win));
|
|
53
|
+
}
|
|
54
|
+
return () => {
|
|
55
|
+
handlers.forEach((h) => h());
|
|
56
|
+
};
|
|
76
57
|
}
|
|
77
58
|
|
|
78
|
-
export default
|
|
59
|
+
export { initCanvasWebGLMutationObserver as default };
|
|
@@ -1,45 +1,43 @@
|
|
|
1
|
-
import { __assign } from '../../ext/tslib/tslib.es6.js';
|
|
2
1
|
import { initMutationObserver, initScrollObserver } from './observer.js';
|
|
3
2
|
import { patch } from '../utils.js';
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.restorePatches = [];
|
|
8
|
-
this.mutationCb = options.mutationCb;
|
|
9
|
-
this.scrollCb = options.scrollCb;
|
|
10
|
-
this.bypassOptions = options.bypassOptions;
|
|
11
|
-
this.mirror = options.mirror;
|
|
12
|
-
|
|
13
|
-
this.restorePatches.push(patch(HTMLElement.prototype, 'attachShadow', function (original) {
|
|
14
|
-
return function () {
|
|
15
|
-
|
|
16
|
-
if (this.shadowRoot)
|
|
17
|
-
manager.addShadowRoot(this.shadowRoot, this.ownerDocument);
|
|
18
|
-
return shadowRoot;
|
|
19
|
-
};
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
initMutationObserver(
|
|
24
|
-
initScrollObserver(
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (iframeElement.contentWindow) {
|
|
28
|
-
|
|
29
|
-
this.restorePatches.push(patch(iframeElement.contentWindow.HTMLElement.prototype, 'attachShadow', function (original) {
|
|
30
|
-
return function () {
|
|
31
|
-
|
|
32
|
-
if (this.shadowRoot)
|
|
33
|
-
|
|
34
|
-
return shadowRoot;
|
|
35
|
-
};
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
this.restorePatches.forEach(
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
}());
|
|
4
|
+
class ShadowDomManager {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.restorePatches = [];
|
|
7
|
+
this.mutationCb = options.mutationCb;
|
|
8
|
+
this.scrollCb = options.scrollCb;
|
|
9
|
+
this.bypassOptions = options.bypassOptions;
|
|
10
|
+
this.mirror = options.mirror;
|
|
11
|
+
const manager = this;
|
|
12
|
+
this.restorePatches.push(patch(HTMLElement.prototype, 'attachShadow', function (original) {
|
|
13
|
+
return function () {
|
|
14
|
+
const shadowRoot = original.apply(this, arguments);
|
|
15
|
+
if (this.shadowRoot)
|
|
16
|
+
manager.addShadowRoot(this.shadowRoot, this.ownerDocument);
|
|
17
|
+
return shadowRoot;
|
|
18
|
+
};
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
addShadowRoot(shadowRoot, doc) {
|
|
22
|
+
initMutationObserver(Object.assign(Object.assign({}, this.bypassOptions), { doc, mutationCb: this.mutationCb, mirror: this.mirror, shadowDomManager: this }), shadowRoot);
|
|
23
|
+
initScrollObserver(Object.assign(Object.assign({}, this.bypassOptions), { scrollCb: this.scrollCb, doc: shadowRoot, mirror: this.mirror }));
|
|
24
|
+
}
|
|
25
|
+
observeAttachShadow(iframeElement) {
|
|
26
|
+
if (iframeElement.contentWindow) {
|
|
27
|
+
const manager = this;
|
|
28
|
+
this.restorePatches.push(patch(iframeElement.contentWindow.HTMLElement.prototype, 'attachShadow', function (original) {
|
|
29
|
+
return function () {
|
|
30
|
+
const shadowRoot = original.apply(this, arguments);
|
|
31
|
+
if (this.shadowRoot)
|
|
32
|
+
manager.addShadowRoot(this.shadowRoot, iframeElement.contentDocument);
|
|
33
|
+
return shadowRoot;
|
|
34
|
+
};
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
reset() {
|
|
39
|
+
this.restorePatches.forEach((restorePatch) => restorePatch());
|
|
40
|
+
}
|
|
41
|
+
}
|
|
44
42
|
|
|
45
43
|
export { ShadowDomManager };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class StylesheetManager {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
this.trackedStylesheets = new WeakSet();
|
|
4
|
+
this.mutationCb = options.mutationCb;
|
|
5
|
+
}
|
|
6
|
+
addStylesheet(linkEl) {
|
|
7
|
+
if (this.trackedStylesheets.has(linkEl))
|
|
8
|
+
return;
|
|
9
|
+
this.trackedStylesheets.add(linkEl);
|
|
10
|
+
this.trackStylesheet(linkEl);
|
|
11
|
+
}
|
|
12
|
+
trackStylesheet(linkEl) {
|
|
13
|
+
}
|
|
14
|
+
attachStylesheet(linkEl, childSn, mirror) {
|
|
15
|
+
this.mutationCb({
|
|
16
|
+
adds: [
|
|
17
|
+
{
|
|
18
|
+
parentId: mirror.getId(linkEl),
|
|
19
|
+
nextId: null,
|
|
20
|
+
node: childSn,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
removes: [],
|
|
24
|
+
texts: [],
|
|
25
|
+
attributes: [],
|
|
26
|
+
});
|
|
27
|
+
this.addStylesheet(linkEl);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { StylesheetManager };
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
mutation.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { __awaiter } from './../../../../../ext/tslib/tslib.es6.js';
|
|
2
|
+
import { deserializeArg } from './deserialize-args.js';
|
|
3
|
+
|
|
4
|
+
function canvasMutation({ event, mutation, target, imageMap, errorHandler, }) {
|
|
5
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6
|
+
try {
|
|
7
|
+
const ctx = target.getContext('2d');
|
|
8
|
+
if (mutation.setter) {
|
|
9
|
+
ctx[mutation.property] = mutation.args[0];
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const original = ctx[mutation.property];
|
|
13
|
+
if (mutation.property === 'drawImage' &&
|
|
14
|
+
typeof mutation.args[0] === 'string') {
|
|
15
|
+
const image = imageMap.get(event);
|
|
16
|
+
original.apply(ctx, mutation.args);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
const args = yield Promise.all(mutation.args.map(deserializeArg(imageMap, ctx)));
|
|
20
|
+
original.apply(ctx, args);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
errorHandler(mutation, error);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
export default
|
|
29
|
+
export { canvasMutation as default };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { __awaiter } from './../../../../../ext/tslib/tslib.es6.js';
|
|
2
|
+
import { decode } from './../../../../../ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js';
|
|
3
|
+
|
|
4
|
+
const webGLVarMap = new Map();
|
|
5
|
+
function variableListFor(ctx, ctor) {
|
|
6
|
+
let contextMap = webGLVarMap.get(ctx);
|
|
7
|
+
if (!contextMap) {
|
|
8
|
+
contextMap = new Map();
|
|
9
|
+
webGLVarMap.set(ctx, contextMap);
|
|
10
|
+
}
|
|
11
|
+
if (!contextMap.has(ctor)) {
|
|
12
|
+
contextMap.set(ctor, []);
|
|
13
|
+
}
|
|
14
|
+
return contextMap.get(ctor);
|
|
15
|
+
}
|
|
16
|
+
function deserializeArg(imageMap, ctx, preload) {
|
|
17
|
+
return (arg) => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
if (arg && typeof arg === 'object' && 'rr_type' in arg) {
|
|
19
|
+
if (preload)
|
|
20
|
+
preload.isUnchanged = false;
|
|
21
|
+
if (arg.rr_type === 'ImageBitmap' && 'args' in arg) {
|
|
22
|
+
const args = yield deserializeArg(imageMap, ctx, preload)(arg.args);
|
|
23
|
+
return yield createImageBitmap.apply(null, args);
|
|
24
|
+
}
|
|
25
|
+
else if ('index' in arg) {
|
|
26
|
+
if (preload || ctx === null)
|
|
27
|
+
return arg;
|
|
28
|
+
const { rr_type: name, index } = arg;
|
|
29
|
+
return variableListFor(ctx, name)[index];
|
|
30
|
+
}
|
|
31
|
+
else if ('args' in arg) {
|
|
32
|
+
const { rr_type: name, args } = arg;
|
|
33
|
+
const ctor = window[name];
|
|
34
|
+
return new ctor(...(yield Promise.all(args.map(deserializeArg(imageMap, ctx, preload)))));
|
|
35
|
+
}
|
|
36
|
+
else if ('base64' in arg) {
|
|
37
|
+
return decode(arg.base64);
|
|
38
|
+
}
|
|
39
|
+
else if ('src' in arg) {
|
|
40
|
+
const image = imageMap.get(arg.src);
|
|
41
|
+
if (image) {
|
|
42
|
+
return image;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const image = new Image();
|
|
46
|
+
image.src = arg.src;
|
|
47
|
+
imageMap.set(arg.src, image);
|
|
48
|
+
return image;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else if ('data' in arg && arg.rr_type === 'Blob') {
|
|
52
|
+
const blobContents = yield Promise.all(arg.data.map(deserializeArg(imageMap, ctx, preload)));
|
|
53
|
+
const blob = new Blob(blobContents, {
|
|
54
|
+
type: arg.type,
|
|
55
|
+
});
|
|
56
|
+
return blob;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (Array.isArray(arg)) {
|
|
60
|
+
const result = yield Promise.all(arg.map(deserializeArg(imageMap, ctx, preload)));
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
return arg;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { deserializeArg, variableListFor };
|