@highlight-run/rrweb 1.2.0 → 2.0.1
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 +655 -0
- package/dist/plugins/console-record.min.js +1 -1
- package/dist/plugins/console-record.min.js.map +1 -1
- package/dist/plugins/console-replay.js +293 -0
- package/dist/plugins/console-replay.min.js +16 -0
- package/dist/plugins/console-replay.min.js.map +1 -0
- package/dist/plugins/sequential-id-record.js +33 -0
- package/dist/plugins/sequential-id-record.min.js +2 -0
- package/dist/plugins/sequential-id-record.min.js.map +1 -0
- package/dist/plugins/sequential-id-replay.js +37 -0
- package/dist/plugins/sequential-id-replay.min.js +2 -0
- package/dist/plugins/sequential-id-replay.min.js.map +1 -0
- package/dist/record/rrweb-record-pack.js +747 -0
- package/dist/record/rrweb-record-pack.min.js +16 -0
- package/dist/record/rrweb-record-pack.min.js.map +1 -0
- package/dist/record/rrweb-record.js +3318 -0
- package/dist/record/rrweb-record.min.js +16 -0
- package/dist/record/rrweb-record.min.js.map +1 -0
- package/dist/replay/rrweb-replay-unpack.js +4626 -0
- package/dist/replay/rrweb-replay-unpack.min.css +2 -0
- package/dist/replay/rrweb-replay-unpack.min.css.map +1 -0
- package/dist/replay/rrweb-replay-unpack.min.js +30 -0
- package/dist/replay/rrweb-replay-unpack.min.js.map +1 -0
- package/dist/replay/rrweb-replay.js +4216 -0
- package/dist/replay/rrweb-replay.min.css +2 -0
- package/dist/replay/rrweb-replay.min.css.map +1 -0
- package/dist/replay/rrweb-replay.min.js +30 -0
- package/dist/replay/rrweb-replay.min.js.map +1 -0
- package/dist/rrweb-all.js +8708 -0
- package/dist/rrweb-all.min.css +2 -0
- package/dist/rrweb-all.min.css.map +1 -0
- package/dist/rrweb-all.min.js +30 -0
- package/dist/rrweb-all.min.js.map +1 -0
- package/dist/rrweb.js +7294 -0
- package/dist/rrweb.min.css +2 -0
- package/dist/rrweb.min.css.map +1 -0
- package/dist/rrweb.min.js +2 -2
- package/dist/rrweb.min.js.map +1 -1
- package/es/rrweb/ext/@xstate/fsm/es/index.js +17 -0
- package/es/rrweb/ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js +49 -0
- package/es/rrweb/ext/fflate/esm/browser.js +777 -0
- package/es/rrweb/ext/mitt/dist/mitt.es.js +63 -0
- package/es/rrweb/packages/rrweb/ext/tslib/tslib.es6.js +78 -0
- package/es/rrweb/packages/rrweb/src/entries/all.js +13 -0
- package/es/rrweb/packages/rrweb/src/index.js +12 -0
- package/es/rrweb/packages/rrweb/src/packer/base.js +3 -0
- package/es/rrweb/packages/rrweb/src/packer/pack.js +10 -0
- package/es/rrweb/packages/rrweb/src/packer/unpack.js +29 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js +179 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/record/index.js +134 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js +141 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js +111 -0
- package/es/rrweb/packages/rrweb/src/plugins/sequential-id/record/index.js +23 -0
- package/es/rrweb/packages/rrweb/src/plugins/sequential-id/replay/index.js +28 -0
- package/es/rrweb/packages/rrweb/src/record/iframe-manager.js +32 -0
- package/es/rrweb/packages/rrweb/src/record/index.js +381 -0
- package/es/rrweb/packages/rrweb/src/record/mutation.js +532 -0
- package/es/rrweb/packages/rrweb/src/record/observer.js +665 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +78 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +93 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +30 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js +116 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +78 -0
- package/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js +45 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/2d.js +25 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/index.js +35 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js +124 -0
- package/es/rrweb/packages/rrweb/src/replay/index.js +1864 -0
- package/es/rrweb/packages/rrweb/src/replay/machine.js +321 -0
- package/es/rrweb/packages/rrweb/src/replay/smoothscroll.js +221 -0
- package/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js +8 -0
- package/es/rrweb/packages/rrweb/src/replay/timer.js +96 -0
- package/es/rrweb/packages/rrweb/src/replay/virtual-styles.js +121 -0
- package/es/rrweb/packages/rrweb/src/types.js +75 -0
- package/es/rrweb/packages/rrweb/src/utils.js +509 -0
- package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +1697 -0
- package/lib/plugins/console-record.js +650 -0
- package/lib/plugins/console-replay.js +288 -0
- package/lib/plugins/sequential-id-record.js +28 -0
- package/lib/plugins/sequential-id-replay.js +32 -0
- package/lib/record/rrweb-record-pack.js +742 -0
- package/lib/record/rrweb-record.js +3315 -0
- package/lib/replay/rrweb-replay-unpack.js +4621 -0
- package/lib/replay/rrweb-replay.js +4211 -0
- package/lib/rrweb-all.js +8703 -0
- package/lib/rrweb.js +7289 -0
- package/package.json +41 -43
- package/typings/entries/all.d.ts +6 -0
- package/{dist → typings}/entries/record-pack.d.ts +0 -0
- package/{dist → typings}/entries/replay-unpack.d.ts +0 -0
- package/{dist → typings}/index.d.ts +1 -2
- package/{dist → typings}/packer/base.d.ts +0 -0
- package/{dist → typings}/packer/index.d.ts +0 -0
- package/{dist → typings}/packer/pack.d.ts +0 -0
- package/{dist → typings}/packer/unpack.d.ts +0 -0
- package/{dist → typings}/plugins/console/record/error-stack-parser.d.ts +0 -0
- package/{dist → typings}/plugins/console/record/index.d.ts +3 -2
- package/{dist → typings}/plugins/console/record/stringify.d.ts +0 -0
- package/{dist → typings}/plugins/console/replay/index.d.ts +2 -2
- package/{dist → typings}/plugins/sequential-id/record/index.d.ts +0 -0
- package/{dist → typings}/plugins/sequential-id/replay/index.d.ts +0 -0
- package/{dist → typings}/record/iframe-manager.d.ts +1 -1
- package/{dist → typings}/record/index.d.ts +0 -0
- package/{dist → typings}/record/mutation.d.ts +5 -8
- package/typings/record/observer.d.ts +7 -0
- package/{dist → typings}/record/observers/canvas/2d.d.ts +0 -0
- package/{dist → typings}/record/observers/canvas/canvas-manager.d.ts +0 -0
- package/{dist → typings}/record/observers/canvas/canvas.d.ts +0 -0
- package/{dist → typings}/record/observers/canvas/serialize-args.d.ts +1 -1
- package/{dist → typings}/record/observers/canvas/webgl.d.ts +0 -0
- package/typings/record/observers/canvas/webgl2.d.ts +2 -0
- package/typings/record/shadow-dom-manager.d.ts +21 -0
- package/{dist → typings}/replay/canvas/2d.d.ts +0 -0
- package/{dist → typings}/replay/canvas/index.d.ts +0 -0
- package/{dist → typings}/replay/canvas/webgl.d.ts +0 -0
- package/{dist → typings}/replay/index.d.ts +1 -0
- package/{dist → typings}/replay/machine.d.ts +0 -0
- package/{dist → typings}/replay/smoothscroll.d.ts +0 -0
- package/{dist → typings}/replay/styles/inject-style.d.ts +0 -0
- package/{dist → typings}/replay/timer.d.ts +0 -0
- package/{dist → typings}/replay/virtual-styles.d.ts +1 -1
- package/{dist → typings}/rrdom/index.d.ts +0 -0
- package/{dist → typings}/rrdom/tree-node.d.ts +0 -0
- package/{dist → typings}/types.d.ts +7 -8
- package/{dist → typings}/utils.d.ts +3 -4
- package/CHANGELOG.md +0 -26
- package/README.md +0 -124
- package/README.zh_CN.md +0 -122
- package/dist/entries/all.d.ts +0 -4
- package/dist/index.css +0 -82
- package/dist/index.css.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.LICENSE.txt +0 -14
- package/dist/index.js.map +0 -1
- package/dist/plugins/entries/all.d.ts +0 -4
- package/dist/plugins/entries/record-pack.d.ts +0 -2
- package/dist/plugins/entries/replay-unpack.d.ts +0 -2
- package/dist/plugins/index.d.ts +0 -9
- package/dist/plugins/packer/base.d.ts +0 -7
- package/dist/plugins/packer/index.d.ts +0 -2
- package/dist/plugins/packer/pack.d.ts +0 -2
- package/dist/plugins/packer/unpack.d.ts +0 -2
- package/dist/plugins/plugins/console/record/error-stack-parser.d.ts +0 -37
- package/dist/plugins/plugins/console/record/index.d.ts +0 -41
- package/dist/plugins/plugins/console/record/stringify.d.ts +0 -2
- package/dist/plugins/plugins/console/replay/index.d.ts +0 -9
- package/dist/plugins/plugins/sequential-id/record/index.d.ts +0 -6
- package/dist/plugins/plugins/sequential-id/replay/index.d.ts +0 -7
- package/dist/plugins/record/iframe-manager.d.ts +0 -13
- package/dist/plugins/record/index.d.ts +0 -9
- package/dist/plugins/record/mutation.d.ts +0 -45
- package/dist/plugins/record/observer.d.ts +0 -11
- package/dist/plugins/record/observers/canvas/2d.d.ts +0 -2
- package/dist/plugins/record/observers/canvas/canvas-manager.d.ts +0 -32
- package/dist/plugins/record/observers/canvas/canvas.d.ts +0 -2
- package/dist/plugins/record/observers/canvas/serialize-args.d.ts +0 -6
- package/dist/plugins/record/observers/canvas/webgl.d.ts +0 -2
- package/dist/plugins/record/shadow-dom-manager.d.ts +0 -34
- package/dist/plugins/replay/canvas/2d.d.ts +0 -9
- package/dist/plugins/replay/canvas/index.d.ts +0 -9
- package/dist/plugins/replay/canvas/webgl.d.ts +0 -11
- package/dist/plugins/replay/index.d.ts +0 -82
- package/dist/plugins/replay/machine.d.ts +0 -85
- package/dist/plugins/replay/smoothscroll.d.ts +0 -1
- package/dist/plugins/replay/styles/inject-style.d.ts +0 -2
- package/dist/plugins/replay/timer.d.ts +0 -19
- package/dist/plugins/replay/virtual-styles.d.ts +0 -43
- package/dist/plugins/rrdom/index.d.ts +0 -1
- package/dist/plugins/rrdom/tree-node.d.ts +0 -20
- package/dist/plugins/snapshot/css.d.ts +0 -92
- package/dist/plugins/snapshot/index.d.ts +0 -5
- package/dist/plugins/snapshot/rebuild.d.ts +0 -19
- package/dist/plugins/snapshot/snapshot.d.ts +0 -49
- package/dist/plugins/snapshot/types.d.ts +0 -99
- package/dist/plugins/snapshot/utils.d.ts +0 -11
- package/dist/plugins/types.d.ts +0 -509
- package/dist/plugins/utils.d.ts +0 -71
- package/dist/record/observer.d.ts +0 -11
- package/dist/record/shadow-dom-manager.d.ts +0 -34
- package/dist/snapshot/css.d.ts +0 -92
- package/dist/snapshot/index.d.ts +0 -5
- package/dist/snapshot/rebuild.d.ts +0 -19
- package/dist/snapshot/snapshot.d.ts +0 -49
- package/dist/snapshot/types.d.ts +0 -99
- package/dist/snapshot/utils.d.ts +0 -11
|
@@ -0,0 +1,4211 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/*! *****************************************************************************
|
|
6
|
+
Copyright (c) Microsoft Corporation.
|
|
7
|
+
|
|
8
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
9
|
+
purpose with or without fee is hereby granted.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
12
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
13
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
14
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
15
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
+
***************************************************************************** */
|
|
19
|
+
|
|
20
|
+
var __assign = function() {
|
|
21
|
+
__assign = Object.assign || function __assign(t) {
|
|
22
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
23
|
+
s = arguments[i];
|
|
24
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
25
|
+
}
|
|
26
|
+
return t;
|
|
27
|
+
};
|
|
28
|
+
return __assign.apply(this, arguments);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function __values(o) {
|
|
32
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
33
|
+
if (m) return m.call(o);
|
|
34
|
+
if (o && typeof o.length === "number") return {
|
|
35
|
+
next: function () {
|
|
36
|
+
if (o && i >= o.length) o = void 0;
|
|
37
|
+
return { value: o && o[i++], done: !o };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function __read(o, n) {
|
|
44
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
45
|
+
if (!m) return o;
|
|
46
|
+
var i = m.call(o), r, ar = [], e;
|
|
47
|
+
try {
|
|
48
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
49
|
+
}
|
|
50
|
+
catch (error) { e = { error: error }; }
|
|
51
|
+
finally {
|
|
52
|
+
try {
|
|
53
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
54
|
+
}
|
|
55
|
+
finally { if (e) throw e.error; }
|
|
56
|
+
}
|
|
57
|
+
return ar;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function __spreadArray(to, from, pack) {
|
|
61
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
62
|
+
if (ar || !(i in from)) {
|
|
63
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
64
|
+
ar[i] = from[i];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
var NodeType;
|
|
71
|
+
(function (NodeType) {
|
|
72
|
+
NodeType[NodeType["Document"] = 0] = "Document";
|
|
73
|
+
NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
|
|
74
|
+
NodeType[NodeType["Element"] = 2] = "Element";
|
|
75
|
+
NodeType[NodeType["Text"] = 3] = "Text";
|
|
76
|
+
NodeType[NodeType["CDATA"] = 4] = "CDATA";
|
|
77
|
+
NodeType[NodeType["Comment"] = 5] = "Comment";
|
|
78
|
+
})(NodeType || (NodeType = {}));
|
|
79
|
+
|
|
80
|
+
function isElement(n) {
|
|
81
|
+
return n.nodeType === n.ELEMENT_NODE;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
85
|
+
function parse(css, options) {
|
|
86
|
+
if (options === void 0) { options = {}; }
|
|
87
|
+
var lineno = 1;
|
|
88
|
+
var column = 1;
|
|
89
|
+
function updatePosition(str) {
|
|
90
|
+
var lines = str.match(/\n/g);
|
|
91
|
+
if (lines) {
|
|
92
|
+
lineno += lines.length;
|
|
93
|
+
}
|
|
94
|
+
var i = str.lastIndexOf('\n');
|
|
95
|
+
column = i === -1 ? column + str.length : str.length - i;
|
|
96
|
+
}
|
|
97
|
+
function position() {
|
|
98
|
+
var start = { line: lineno, column: column };
|
|
99
|
+
return function (node) {
|
|
100
|
+
node.position = new Position(start);
|
|
101
|
+
whitespace();
|
|
102
|
+
return node;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
var Position = (function () {
|
|
106
|
+
function Position(start) {
|
|
107
|
+
this.start = start;
|
|
108
|
+
this.end = { line: lineno, column: column };
|
|
109
|
+
this.source = options.source;
|
|
110
|
+
}
|
|
111
|
+
return Position;
|
|
112
|
+
}());
|
|
113
|
+
Position.prototype.content = css;
|
|
114
|
+
var errorsList = [];
|
|
115
|
+
function error(msg) {
|
|
116
|
+
var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
|
|
117
|
+
err.reason = msg;
|
|
118
|
+
err.filename = options.source;
|
|
119
|
+
err.line = lineno;
|
|
120
|
+
err.column = column;
|
|
121
|
+
err.source = css;
|
|
122
|
+
if (options.silent) {
|
|
123
|
+
errorsList.push(err);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
throw err;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function stylesheet() {
|
|
130
|
+
var rulesList = rules();
|
|
131
|
+
return {
|
|
132
|
+
type: 'stylesheet',
|
|
133
|
+
stylesheet: {
|
|
134
|
+
source: options.source,
|
|
135
|
+
rules: rulesList,
|
|
136
|
+
parsingErrors: errorsList
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function open() {
|
|
141
|
+
return match(/^{\s*/);
|
|
142
|
+
}
|
|
143
|
+
function close() {
|
|
144
|
+
return match(/^}/);
|
|
145
|
+
}
|
|
146
|
+
function rules() {
|
|
147
|
+
var node;
|
|
148
|
+
var rules = [];
|
|
149
|
+
whitespace();
|
|
150
|
+
comments(rules);
|
|
151
|
+
while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {
|
|
152
|
+
if (node !== false) {
|
|
153
|
+
rules.push(node);
|
|
154
|
+
comments(rules);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return rules;
|
|
158
|
+
}
|
|
159
|
+
function match(re) {
|
|
160
|
+
var m = re.exec(css);
|
|
161
|
+
if (!m) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
var str = m[0];
|
|
165
|
+
updatePosition(str);
|
|
166
|
+
css = css.slice(str.length);
|
|
167
|
+
return m;
|
|
168
|
+
}
|
|
169
|
+
function whitespace() {
|
|
170
|
+
match(/^\s*/);
|
|
171
|
+
}
|
|
172
|
+
function comments(rules) {
|
|
173
|
+
if (rules === void 0) { rules = []; }
|
|
174
|
+
var c;
|
|
175
|
+
while ((c = comment())) {
|
|
176
|
+
if (c !== false) {
|
|
177
|
+
rules.push(c);
|
|
178
|
+
}
|
|
179
|
+
c = comment();
|
|
180
|
+
}
|
|
181
|
+
return rules;
|
|
182
|
+
}
|
|
183
|
+
function comment() {
|
|
184
|
+
var pos = position();
|
|
185
|
+
if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
var i = 2;
|
|
189
|
+
while ('' !== css.charAt(i) &&
|
|
190
|
+
('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {
|
|
191
|
+
++i;
|
|
192
|
+
}
|
|
193
|
+
i += 2;
|
|
194
|
+
if ('' === css.charAt(i - 1)) {
|
|
195
|
+
return error('End of comment missing');
|
|
196
|
+
}
|
|
197
|
+
var str = css.slice(2, i - 2);
|
|
198
|
+
column += 2;
|
|
199
|
+
updatePosition(str);
|
|
200
|
+
css = css.slice(i);
|
|
201
|
+
column += 2;
|
|
202
|
+
return pos({
|
|
203
|
+
type: 'comment',
|
|
204
|
+
comment: str
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function selector() {
|
|
208
|
+
var m = match(/^([^{]+)/);
|
|
209
|
+
if (!m) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
return trim(m[0])
|
|
213
|
+
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
|
|
214
|
+
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (m) {
|
|
215
|
+
return m.replace(/,/g, '\u200C');
|
|
216
|
+
})
|
|
217
|
+
.split(/\s*(?![^(]*\)),\s*/)
|
|
218
|
+
.map(function (s) {
|
|
219
|
+
return s.replace(/\u200C/g, ',');
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function declaration() {
|
|
223
|
+
var pos = position();
|
|
224
|
+
var propMatch = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
|
|
225
|
+
if (!propMatch) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
var prop = trim(propMatch[0]);
|
|
229
|
+
if (!match(/^:\s*/)) {
|
|
230
|
+
return error("property missing ':'");
|
|
231
|
+
}
|
|
232
|
+
var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
|
|
233
|
+
var ret = pos({
|
|
234
|
+
type: 'declaration',
|
|
235
|
+
property: prop.replace(commentre, ''),
|
|
236
|
+
value: val ? trim(val[0]).replace(commentre, '') : ''
|
|
237
|
+
});
|
|
238
|
+
match(/^[;\s]*/);
|
|
239
|
+
return ret;
|
|
240
|
+
}
|
|
241
|
+
function declarations() {
|
|
242
|
+
var decls = [];
|
|
243
|
+
if (!open()) {
|
|
244
|
+
return error("missing '{'");
|
|
245
|
+
}
|
|
246
|
+
comments(decls);
|
|
247
|
+
var decl;
|
|
248
|
+
while ((decl = declaration())) {
|
|
249
|
+
if (decl !== false) {
|
|
250
|
+
decls.push(decl);
|
|
251
|
+
comments(decls);
|
|
252
|
+
}
|
|
253
|
+
decl = declaration();
|
|
254
|
+
}
|
|
255
|
+
if (!close()) {
|
|
256
|
+
return error("missing '}'");
|
|
257
|
+
}
|
|
258
|
+
return decls;
|
|
259
|
+
}
|
|
260
|
+
function keyframe() {
|
|
261
|
+
var m;
|
|
262
|
+
var vals = [];
|
|
263
|
+
var pos = position();
|
|
264
|
+
while ((m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/))) {
|
|
265
|
+
vals.push(m[1]);
|
|
266
|
+
match(/^,\s*/);
|
|
267
|
+
}
|
|
268
|
+
if (!vals.length) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
return pos({
|
|
272
|
+
type: 'keyframe',
|
|
273
|
+
values: vals,
|
|
274
|
+
declarations: declarations()
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
function atkeyframes() {
|
|
278
|
+
var pos = position();
|
|
279
|
+
var m = match(/^@([-\w]+)?keyframes\s*/);
|
|
280
|
+
if (!m) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
var vendor = m[1];
|
|
284
|
+
m = match(/^([-\w]+)\s*/);
|
|
285
|
+
if (!m) {
|
|
286
|
+
return error('@keyframes missing name');
|
|
287
|
+
}
|
|
288
|
+
var name = m[1];
|
|
289
|
+
if (!open()) {
|
|
290
|
+
return error("@keyframes missing '{'");
|
|
291
|
+
}
|
|
292
|
+
var frame;
|
|
293
|
+
var frames = comments();
|
|
294
|
+
while ((frame = keyframe())) {
|
|
295
|
+
frames.push(frame);
|
|
296
|
+
frames = frames.concat(comments());
|
|
297
|
+
}
|
|
298
|
+
if (!close()) {
|
|
299
|
+
return error("@keyframes missing '}'");
|
|
300
|
+
}
|
|
301
|
+
return pos({
|
|
302
|
+
type: 'keyframes',
|
|
303
|
+
name: name,
|
|
304
|
+
vendor: vendor,
|
|
305
|
+
keyframes: frames
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
function atsupports() {
|
|
309
|
+
var pos = position();
|
|
310
|
+
var m = match(/^@supports *([^{]+)/);
|
|
311
|
+
if (!m) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
var supports = trim(m[1]);
|
|
315
|
+
if (!open()) {
|
|
316
|
+
return error("@supports missing '{'");
|
|
317
|
+
}
|
|
318
|
+
var style = comments().concat(rules());
|
|
319
|
+
if (!close()) {
|
|
320
|
+
return error("@supports missing '}'");
|
|
321
|
+
}
|
|
322
|
+
return pos({
|
|
323
|
+
type: 'supports',
|
|
324
|
+
supports: supports,
|
|
325
|
+
rules: style
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
function athost() {
|
|
329
|
+
var pos = position();
|
|
330
|
+
var m = match(/^@host\s*/);
|
|
331
|
+
if (!m) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (!open()) {
|
|
335
|
+
return error("@host missing '{'");
|
|
336
|
+
}
|
|
337
|
+
var style = comments().concat(rules());
|
|
338
|
+
if (!close()) {
|
|
339
|
+
return error("@host missing '}'");
|
|
340
|
+
}
|
|
341
|
+
return pos({
|
|
342
|
+
type: 'host',
|
|
343
|
+
rules: style
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
function atmedia() {
|
|
347
|
+
var pos = position();
|
|
348
|
+
var m = match(/^@media *([^{]+)/);
|
|
349
|
+
if (!m) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
var media = trim(m[1]);
|
|
353
|
+
if (!open()) {
|
|
354
|
+
return error("@media missing '{'");
|
|
355
|
+
}
|
|
356
|
+
var style = comments().concat(rules());
|
|
357
|
+
if (!close()) {
|
|
358
|
+
return error("@media missing '}'");
|
|
359
|
+
}
|
|
360
|
+
return pos({
|
|
361
|
+
type: 'media',
|
|
362
|
+
media: media,
|
|
363
|
+
rules: style
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
function atcustommedia() {
|
|
367
|
+
var pos = position();
|
|
368
|
+
var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
|
|
369
|
+
if (!m) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
return pos({
|
|
373
|
+
type: 'custom-media',
|
|
374
|
+
name: trim(m[1]),
|
|
375
|
+
media: trim(m[2])
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
function atpage() {
|
|
379
|
+
var pos = position();
|
|
380
|
+
var m = match(/^@page */);
|
|
381
|
+
if (!m) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
var sel = selector() || [];
|
|
385
|
+
if (!open()) {
|
|
386
|
+
return error("@page missing '{'");
|
|
387
|
+
}
|
|
388
|
+
var decls = comments();
|
|
389
|
+
var decl;
|
|
390
|
+
while ((decl = declaration())) {
|
|
391
|
+
decls.push(decl);
|
|
392
|
+
decls = decls.concat(comments());
|
|
393
|
+
}
|
|
394
|
+
if (!close()) {
|
|
395
|
+
return error("@page missing '}'");
|
|
396
|
+
}
|
|
397
|
+
return pos({
|
|
398
|
+
type: 'page',
|
|
399
|
+
selectors: sel,
|
|
400
|
+
declarations: decls
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
function atdocument() {
|
|
404
|
+
var pos = position();
|
|
405
|
+
var m = match(/^@([-\w]+)?document *([^{]+)/);
|
|
406
|
+
if (!m) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
var vendor = trim(m[1]);
|
|
410
|
+
var doc = trim(m[2]);
|
|
411
|
+
if (!open()) {
|
|
412
|
+
return error("@document missing '{'");
|
|
413
|
+
}
|
|
414
|
+
var style = comments().concat(rules());
|
|
415
|
+
if (!close()) {
|
|
416
|
+
return error("@document missing '}'");
|
|
417
|
+
}
|
|
418
|
+
return pos({
|
|
419
|
+
type: 'document',
|
|
420
|
+
document: doc,
|
|
421
|
+
vendor: vendor,
|
|
422
|
+
rules: style
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
function atfontface() {
|
|
426
|
+
var pos = position();
|
|
427
|
+
var m = match(/^@font-face\s*/);
|
|
428
|
+
if (!m) {
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
if (!open()) {
|
|
432
|
+
return error("@font-face missing '{'");
|
|
433
|
+
}
|
|
434
|
+
var decls = comments();
|
|
435
|
+
var decl;
|
|
436
|
+
while ((decl = declaration())) {
|
|
437
|
+
decls.push(decl);
|
|
438
|
+
decls = decls.concat(comments());
|
|
439
|
+
}
|
|
440
|
+
if (!close()) {
|
|
441
|
+
return error("@font-face missing '}'");
|
|
442
|
+
}
|
|
443
|
+
return pos({
|
|
444
|
+
type: 'font-face',
|
|
445
|
+
declarations: decls
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
var atimport = _compileAtrule('import');
|
|
449
|
+
var atcharset = _compileAtrule('charset');
|
|
450
|
+
var atnamespace = _compileAtrule('namespace');
|
|
451
|
+
function _compileAtrule(name) {
|
|
452
|
+
var re = new RegExp('^@' + name + '\\s*([^;]+);');
|
|
453
|
+
return function () {
|
|
454
|
+
var pos = position();
|
|
455
|
+
var m = match(re);
|
|
456
|
+
if (!m) {
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
var ret = { type: name };
|
|
460
|
+
ret[name] = m[1].trim();
|
|
461
|
+
return pos(ret);
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
function atrule() {
|
|
465
|
+
if (css[0] !== '@') {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
return (atkeyframes() ||
|
|
469
|
+
atmedia() ||
|
|
470
|
+
atcustommedia() ||
|
|
471
|
+
atsupports() ||
|
|
472
|
+
atimport() ||
|
|
473
|
+
atcharset() ||
|
|
474
|
+
atnamespace() ||
|
|
475
|
+
atdocument() ||
|
|
476
|
+
atpage() ||
|
|
477
|
+
athost() ||
|
|
478
|
+
atfontface());
|
|
479
|
+
}
|
|
480
|
+
function rule() {
|
|
481
|
+
var pos = position();
|
|
482
|
+
var sel = selector();
|
|
483
|
+
if (!sel) {
|
|
484
|
+
return error('selector missing');
|
|
485
|
+
}
|
|
486
|
+
comments();
|
|
487
|
+
return pos({
|
|
488
|
+
type: 'rule',
|
|
489
|
+
selectors: sel,
|
|
490
|
+
declarations: declarations()
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
return addParent(stylesheet());
|
|
494
|
+
}
|
|
495
|
+
function trim(str) {
|
|
496
|
+
return str ? str.replace(/^\s+|\s+$/g, '') : '';
|
|
497
|
+
}
|
|
498
|
+
function addParent(obj, parent) {
|
|
499
|
+
var isNode = obj && typeof obj.type === 'string';
|
|
500
|
+
var childParent = isNode ? obj : parent;
|
|
501
|
+
for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {
|
|
502
|
+
var k = _a[_i];
|
|
503
|
+
var value = obj[k];
|
|
504
|
+
if (Array.isArray(value)) {
|
|
505
|
+
value.forEach(function (v) {
|
|
506
|
+
addParent(v, childParent);
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
else if (value && typeof value === 'object') {
|
|
510
|
+
addParent(value, childParent);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
if (isNode) {
|
|
514
|
+
Object.defineProperty(obj, 'parent', {
|
|
515
|
+
configurable: true,
|
|
516
|
+
writable: true,
|
|
517
|
+
enumerable: false,
|
|
518
|
+
value: parent || null
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
return obj;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
var tagMap = {
|
|
525
|
+
script: 'noscript',
|
|
526
|
+
altglyph: 'altGlyph',
|
|
527
|
+
altglyphdef: 'altGlyphDef',
|
|
528
|
+
altglyphitem: 'altGlyphItem',
|
|
529
|
+
animatecolor: 'animateColor',
|
|
530
|
+
animatemotion: 'animateMotion',
|
|
531
|
+
animatetransform: 'animateTransform',
|
|
532
|
+
clippath: 'clipPath',
|
|
533
|
+
feblend: 'feBlend',
|
|
534
|
+
fecolormatrix: 'feColorMatrix',
|
|
535
|
+
fecomponenttransfer: 'feComponentTransfer',
|
|
536
|
+
fecomposite: 'feComposite',
|
|
537
|
+
feconvolvematrix: 'feConvolveMatrix',
|
|
538
|
+
fediffuselighting: 'feDiffuseLighting',
|
|
539
|
+
fedisplacementmap: 'feDisplacementMap',
|
|
540
|
+
fedistantlight: 'feDistantLight',
|
|
541
|
+
fedropshadow: 'feDropShadow',
|
|
542
|
+
feflood: 'feFlood',
|
|
543
|
+
fefunca: 'feFuncA',
|
|
544
|
+
fefuncb: 'feFuncB',
|
|
545
|
+
fefuncg: 'feFuncG',
|
|
546
|
+
fefuncr: 'feFuncR',
|
|
547
|
+
fegaussianblur: 'feGaussianBlur',
|
|
548
|
+
feimage: 'feImage',
|
|
549
|
+
femerge: 'feMerge',
|
|
550
|
+
femergenode: 'feMergeNode',
|
|
551
|
+
femorphology: 'feMorphology',
|
|
552
|
+
feoffset: 'feOffset',
|
|
553
|
+
fepointlight: 'fePointLight',
|
|
554
|
+
fespecularlighting: 'feSpecularLighting',
|
|
555
|
+
fespotlight: 'feSpotLight',
|
|
556
|
+
fetile: 'feTile',
|
|
557
|
+
feturbulence: 'feTurbulence',
|
|
558
|
+
foreignobject: 'foreignObject',
|
|
559
|
+
glyphref: 'glyphRef',
|
|
560
|
+
lineargradient: 'linearGradient',
|
|
561
|
+
radialgradient: 'radialGradient'
|
|
562
|
+
};
|
|
563
|
+
function getTagName(n) {
|
|
564
|
+
var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;
|
|
565
|
+
if (tagName === 'link' && n.attributes._cssText) {
|
|
566
|
+
tagName = 'style';
|
|
567
|
+
}
|
|
568
|
+
return tagName;
|
|
569
|
+
}
|
|
570
|
+
function escapeRegExp(str) {
|
|
571
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
572
|
+
}
|
|
573
|
+
var HOVER_SELECTOR = /([^\\]):hover/;
|
|
574
|
+
var HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');
|
|
575
|
+
function addHoverClass(cssText, cache) {
|
|
576
|
+
var _a;
|
|
577
|
+
if (!((_a = window.HIG_CONFIGURATION) === null || _a === void 0 ? void 0 : _a.enableOnHoverClass)) {
|
|
578
|
+
return cssText;
|
|
579
|
+
}
|
|
580
|
+
var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);
|
|
581
|
+
if (cachedStyle)
|
|
582
|
+
return cachedStyle;
|
|
583
|
+
var ast = parse(cssText, {
|
|
584
|
+
silent: true
|
|
585
|
+
});
|
|
586
|
+
if (!ast.stylesheet) {
|
|
587
|
+
return cssText;
|
|
588
|
+
}
|
|
589
|
+
var selectors = [];
|
|
590
|
+
ast.stylesheet.rules.forEach(function (rule) {
|
|
591
|
+
if ('selectors' in rule) {
|
|
592
|
+
(rule.selectors || []).forEach(function (selector) {
|
|
593
|
+
if (HOVER_SELECTOR.test(selector)) {
|
|
594
|
+
selectors.push(selector);
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
if (selectors.length === 0) {
|
|
600
|
+
return cssText;
|
|
601
|
+
}
|
|
602
|
+
var selectorMatcher = new RegExp(selectors
|
|
603
|
+
.filter(function (selector, index) { return selectors.indexOf(selector) === index; })
|
|
604
|
+
.sort(function (a, b) { return b.length - a.length; })
|
|
605
|
+
.map(function (selector) {
|
|
606
|
+
return escapeRegExp(selector);
|
|
607
|
+
})
|
|
608
|
+
.join('|'), 'g');
|
|
609
|
+
var result = cssText.replace(selectorMatcher, function (selector) {
|
|
610
|
+
var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\:hover');
|
|
611
|
+
return selector + ", " + newSelector;
|
|
612
|
+
});
|
|
613
|
+
cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);
|
|
614
|
+
return result;
|
|
615
|
+
}
|
|
616
|
+
function createCache() {
|
|
617
|
+
var stylesWithHoverClass = new Map();
|
|
618
|
+
return {
|
|
619
|
+
stylesWithHoverClass: stylesWithHoverClass
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
function buildNode(n, options) {
|
|
623
|
+
var doc = options.doc, hackCss = options.hackCss, cache = options.cache;
|
|
624
|
+
switch (n.type) {
|
|
625
|
+
case NodeType.Document:
|
|
626
|
+
return doc.implementation.createDocument(null, '', null);
|
|
627
|
+
case NodeType.DocumentType:
|
|
628
|
+
return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);
|
|
629
|
+
case NodeType.Element:
|
|
630
|
+
var tagName = getTagName(n);
|
|
631
|
+
var node_1;
|
|
632
|
+
if (n.isSVG) {
|
|
633
|
+
node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);
|
|
634
|
+
}
|
|
635
|
+
else {
|
|
636
|
+
node_1 = doc.createElement(tagName);
|
|
637
|
+
}
|
|
638
|
+
var _loop_1 = function (name_1) {
|
|
639
|
+
if (!n.attributes.hasOwnProperty(name_1)) {
|
|
640
|
+
return "continue";
|
|
641
|
+
}
|
|
642
|
+
var value = n.attributes[name_1];
|
|
643
|
+
if (tagName === 'option' && name_1 === 'selected' && value === false) {
|
|
644
|
+
return "continue";
|
|
645
|
+
}
|
|
646
|
+
value =
|
|
647
|
+
typeof value === 'boolean' || typeof value === 'number' ? '' : value;
|
|
648
|
+
if (!name_1.startsWith('rr_')) {
|
|
649
|
+
var isTextarea = tagName === 'textarea' && name_1 === 'value';
|
|
650
|
+
var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';
|
|
651
|
+
if (isRemoteOrDynamicCss && hackCss) {
|
|
652
|
+
value = addHoverClass(value, cache);
|
|
653
|
+
if (typeof value === 'string') {
|
|
654
|
+
var regex = /url\(\"https:\/\/\S*(.eot|.woff2|.ttf|.woff)\S*\"\)/gm;
|
|
655
|
+
var m = void 0;
|
|
656
|
+
var fontUrls_1 = [];
|
|
657
|
+
var PROXY_URL_1 = 'https://replay-cors-proxy.highlightrun.workers.dev';
|
|
658
|
+
while ((m = regex.exec(value)) !== null) {
|
|
659
|
+
if (m.index === regex.lastIndex) {
|
|
660
|
+
regex.lastIndex++;
|
|
661
|
+
}
|
|
662
|
+
m.forEach(function (match, groupIndex) {
|
|
663
|
+
if (groupIndex === 0) {
|
|
664
|
+
var url = match.slice(5, match.length - 2);
|
|
665
|
+
fontUrls_1.push({
|
|
666
|
+
originalUrl: url,
|
|
667
|
+
proxyUrl: url.replace(url, PROXY_URL_1 + "?url=" + url)
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
fontUrls_1.forEach(function (urlPair) {
|
|
673
|
+
value = value.replace(urlPair.originalUrl, urlPair.proxyUrl);
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
if (isTextarea || isRemoteOrDynamicCss) {
|
|
678
|
+
var child = doc.createTextNode(value);
|
|
679
|
+
for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {
|
|
680
|
+
var c = _a[_i];
|
|
681
|
+
if (c.nodeType === node_1.TEXT_NODE) {
|
|
682
|
+
node_1.removeChild(c);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
node_1.appendChild(child);
|
|
686
|
+
return "continue";
|
|
687
|
+
}
|
|
688
|
+
try {
|
|
689
|
+
if (n.isSVG && name_1 === 'xlink:href') {
|
|
690
|
+
node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);
|
|
691
|
+
}
|
|
692
|
+
else if (name_1 === 'onload' ||
|
|
693
|
+
name_1 === 'onclick' ||
|
|
694
|
+
name_1.substring(0, 7) === 'onmouse') {
|
|
695
|
+
node_1.setAttribute('_' + name_1, value);
|
|
696
|
+
}
|
|
697
|
+
else if (tagName === 'meta' &&
|
|
698
|
+
n.attributes['http-equiv'] === 'Content-Security-Policy' &&
|
|
699
|
+
name_1 === 'content') {
|
|
700
|
+
node_1.setAttribute('csp-content', value);
|
|
701
|
+
return "continue";
|
|
702
|
+
}
|
|
703
|
+
else if (tagName === 'link' &&
|
|
704
|
+
n.attributes.rel === 'preload' &&
|
|
705
|
+
n.attributes.as === 'script') {
|
|
706
|
+
}
|
|
707
|
+
else if (tagName === 'link' &&
|
|
708
|
+
n.attributes.rel === 'prefetch' &&
|
|
709
|
+
typeof n.attributes.href === 'string' &&
|
|
710
|
+
n.attributes.href.endsWith('.js')) {
|
|
711
|
+
}
|
|
712
|
+
else if (tagName === 'img' &&
|
|
713
|
+
n.attributes.srcset &&
|
|
714
|
+
n.attributes.rr_dataURL) {
|
|
715
|
+
node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);
|
|
716
|
+
}
|
|
717
|
+
else {
|
|
718
|
+
node_1.setAttribute(name_1, value);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
catch (error) {
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
else {
|
|
725
|
+
if (tagName === 'canvas' && name_1 === 'rr_dataURL') {
|
|
726
|
+
var image_1 = document.createElement('img');
|
|
727
|
+
image_1.src = value;
|
|
728
|
+
image_1.onload = function () {
|
|
729
|
+
var ctx = node_1.getContext('2d');
|
|
730
|
+
if (ctx) {
|
|
731
|
+
ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
else if (tagName === 'img' && name_1 === 'rr_dataURL') {
|
|
736
|
+
var image = node_1;
|
|
737
|
+
if (!image.currentSrc.startsWith('data:')) {
|
|
738
|
+
image.setAttribute('rrweb-original-src', n.attributes.src);
|
|
739
|
+
image.src = value;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
if (name_1 === 'rr_width') {
|
|
743
|
+
node_1.style.width = value;
|
|
744
|
+
}
|
|
745
|
+
else if (name_1 === 'rr_height') {
|
|
746
|
+
node_1.style.height = value;
|
|
747
|
+
}
|
|
748
|
+
else if (name_1 === 'rr_mediaCurrentTime') {
|
|
749
|
+
node_1.currentTime = n.attributes
|
|
750
|
+
.rr_mediaCurrentTime;
|
|
751
|
+
}
|
|
752
|
+
else if (name_1 === 'rr_mediaState') {
|
|
753
|
+
switch (value) {
|
|
754
|
+
case 'played':
|
|
755
|
+
node_1
|
|
756
|
+
.play()["catch"](function (e) { return console.warn('media playback error', e); });
|
|
757
|
+
break;
|
|
758
|
+
case 'paused':
|
|
759
|
+
node_1.pause();
|
|
760
|
+
break;
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
for (var name_1 in n.attributes) {
|
|
766
|
+
_loop_1(name_1);
|
|
767
|
+
}
|
|
768
|
+
if (n.isShadowHost) {
|
|
769
|
+
if (!node_1.shadowRoot) {
|
|
770
|
+
node_1.attachShadow({ mode: 'open' });
|
|
771
|
+
}
|
|
772
|
+
else {
|
|
773
|
+
while (node_1.shadowRoot.firstChild) {
|
|
774
|
+
node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
return node_1;
|
|
779
|
+
case NodeType.Text:
|
|
780
|
+
return doc.createTextNode(n.isStyle && hackCss
|
|
781
|
+
? addHoverClass(n.textContent, cache)
|
|
782
|
+
: n.textContent);
|
|
783
|
+
case NodeType.CDATA:
|
|
784
|
+
return doc.createCDATASection(n.textContent);
|
|
785
|
+
case NodeType.Comment:
|
|
786
|
+
return doc.createComment(n.textContent);
|
|
787
|
+
default:
|
|
788
|
+
return null;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
function buildNodeWithSN(n, options) {
|
|
792
|
+
var doc = options.doc, map = options.map, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;
|
|
793
|
+
var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });
|
|
794
|
+
if (!node) {
|
|
795
|
+
return null;
|
|
796
|
+
}
|
|
797
|
+
if (n.rootId) {
|
|
798
|
+
console.assert(map[n.rootId] === doc, 'Target document should has the same root id.');
|
|
799
|
+
}
|
|
800
|
+
if (n.type === NodeType.Document) {
|
|
801
|
+
doc.close();
|
|
802
|
+
doc.open();
|
|
803
|
+
if (n.compatMode === 'BackCompat' &&
|
|
804
|
+
n.childNodes &&
|
|
805
|
+
n.childNodes[0].type !== NodeType.DocumentType) {
|
|
806
|
+
if (n.childNodes[0].type === NodeType.Element &&
|
|
807
|
+
'xmlns' in n.childNodes[0].attributes &&
|
|
808
|
+
n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {
|
|
809
|
+
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">');
|
|
810
|
+
}
|
|
811
|
+
else {
|
|
812
|
+
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">');
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
node = doc;
|
|
816
|
+
}
|
|
817
|
+
node.__sn = n;
|
|
818
|
+
map[n.id] = node;
|
|
819
|
+
if ((n.type === NodeType.Document || n.type === NodeType.Element) &&
|
|
820
|
+
!skipChild) {
|
|
821
|
+
for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {
|
|
822
|
+
var childN = _c[_i];
|
|
823
|
+
var childNode = buildNodeWithSN(childN, {
|
|
824
|
+
doc: doc,
|
|
825
|
+
map: map,
|
|
826
|
+
skipChild: false,
|
|
827
|
+
hackCss: hackCss,
|
|
828
|
+
afterAppend: afterAppend,
|
|
829
|
+
cache: cache
|
|
830
|
+
});
|
|
831
|
+
if (!childNode) {
|
|
832
|
+
console.warn('Failed to rebuild', childN);
|
|
833
|
+
continue;
|
|
834
|
+
}
|
|
835
|
+
if (childN.isShadow && isElement(node) && node.shadowRoot) {
|
|
836
|
+
node.shadowRoot.appendChild(childNode);
|
|
837
|
+
}
|
|
838
|
+
else {
|
|
839
|
+
node.appendChild(childNode);
|
|
840
|
+
}
|
|
841
|
+
if (afterAppend) {
|
|
842
|
+
afterAppend(childNode);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
return node;
|
|
847
|
+
}
|
|
848
|
+
function visit(idNodeMap, onVisit) {
|
|
849
|
+
function walk(node) {
|
|
850
|
+
onVisit(node);
|
|
851
|
+
}
|
|
852
|
+
for (var key in idNodeMap) {
|
|
853
|
+
if (idNodeMap[key]) {
|
|
854
|
+
walk(idNodeMap[key]);
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
function handleScroll(node) {
|
|
859
|
+
var n = node.__sn;
|
|
860
|
+
if (n.type !== NodeType.Element) {
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
var el = node;
|
|
864
|
+
for (var name_2 in n.attributes) {
|
|
865
|
+
if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {
|
|
866
|
+
continue;
|
|
867
|
+
}
|
|
868
|
+
var value = n.attributes[name_2];
|
|
869
|
+
if (name_2 === 'rr_scrollLeft') {
|
|
870
|
+
el.scrollLeft = value;
|
|
871
|
+
}
|
|
872
|
+
if (name_2 === 'rr_scrollTop') {
|
|
873
|
+
el.scrollTop = value;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
function rebuild(n, options) {
|
|
878
|
+
var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache;
|
|
879
|
+
var idNodeMap = {};
|
|
880
|
+
var node = buildNodeWithSN(n, {
|
|
881
|
+
doc: doc,
|
|
882
|
+
map: idNodeMap,
|
|
883
|
+
skipChild: false,
|
|
884
|
+
hackCss: hackCss,
|
|
885
|
+
afterAppend: afterAppend,
|
|
886
|
+
cache: cache
|
|
887
|
+
});
|
|
888
|
+
visit(idNodeMap, function (visitedNode) {
|
|
889
|
+
if (onVisit) {
|
|
890
|
+
onVisit(visitedNode);
|
|
891
|
+
}
|
|
892
|
+
handleScroll(visitedNode);
|
|
893
|
+
});
|
|
894
|
+
return [node, idNodeMap];
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
//
|
|
898
|
+
// An event handler can take an optional event argument
|
|
899
|
+
// and should not return a value
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
// An array of all currently registered event handlers for a type
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
// A map of event types and their corresponding event handlers.
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
/** Mitt: Tiny (~200b) functional event emitter / pubsub.
|
|
913
|
+
* @name mitt
|
|
914
|
+
* @returns {Mitt}
|
|
915
|
+
*/
|
|
916
|
+
function mitt$1(all ) {
|
|
917
|
+
all = all || Object.create(null);
|
|
918
|
+
|
|
919
|
+
return {
|
|
920
|
+
/**
|
|
921
|
+
* Register an event handler for the given type.
|
|
922
|
+
*
|
|
923
|
+
* @param {String} type Type of event to listen for, or `"*"` for all events
|
|
924
|
+
* @param {Function} handler Function to call in response to given event
|
|
925
|
+
* @memberOf mitt
|
|
926
|
+
*/
|
|
927
|
+
on: function on(type , handler ) {
|
|
928
|
+
(all[type] || (all[type] = [])).push(handler);
|
|
929
|
+
},
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Remove an event handler for the given type.
|
|
933
|
+
*
|
|
934
|
+
* @param {String} type Type of event to unregister `handler` from, or `"*"`
|
|
935
|
+
* @param {Function} handler Handler function to remove
|
|
936
|
+
* @memberOf mitt
|
|
937
|
+
*/
|
|
938
|
+
off: function off(type , handler ) {
|
|
939
|
+
if (all[type]) {
|
|
940
|
+
all[type].splice(all[type].indexOf(handler) >>> 0, 1);
|
|
941
|
+
}
|
|
942
|
+
},
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* Invoke all handlers for the given type.
|
|
946
|
+
* If present, `"*"` handlers are invoked after type-matched handlers.
|
|
947
|
+
*
|
|
948
|
+
* @param {String} type The event type to invoke
|
|
949
|
+
* @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
|
|
950
|
+
* @memberOf mitt
|
|
951
|
+
*/
|
|
952
|
+
emit: function emit(type , evt ) {
|
|
953
|
+
(all[type] || []).slice().map(function (handler) { handler(evt); });
|
|
954
|
+
(all['*'] || []).slice().map(function (handler) { handler(type, evt); });
|
|
955
|
+
}
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
var mittProxy = /*#__PURE__*/Object.freeze({
|
|
960
|
+
__proto__: null,
|
|
961
|
+
'default': mitt$1
|
|
962
|
+
});
|
|
963
|
+
|
|
964
|
+
function polyfill$1(w, d) {
|
|
965
|
+
if (w === void 0) { w = window; }
|
|
966
|
+
if (d === void 0) { d = document; }
|
|
967
|
+
if ('scrollBehavior' in d.documentElement.style &&
|
|
968
|
+
w.__forceSmoothScrollPolyfill__ !== true) {
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
var Element = w.HTMLElement || w.Element;
|
|
972
|
+
var SCROLL_TIME = 468;
|
|
973
|
+
var original = {
|
|
974
|
+
scroll: w.scroll || w.scrollTo,
|
|
975
|
+
scrollBy: w.scrollBy,
|
|
976
|
+
elementScroll: Element.prototype.scroll || scrollElement,
|
|
977
|
+
scrollIntoView: Element.prototype.scrollIntoView,
|
|
978
|
+
};
|
|
979
|
+
var now = w.performance && w.performance.now
|
|
980
|
+
? w.performance.now.bind(w.performance)
|
|
981
|
+
: Date.now;
|
|
982
|
+
function isMicrosoftBrowser(userAgent) {
|
|
983
|
+
var userAgentPatterns = ['MSIE ', 'Trident/', 'Edge/'];
|
|
984
|
+
return new RegExp(userAgentPatterns.join('|')).test(userAgent);
|
|
985
|
+
}
|
|
986
|
+
var ROUNDING_TOLERANCE = isMicrosoftBrowser(w.navigator.userAgent) ? 1 : 0;
|
|
987
|
+
function scrollElement(x, y) {
|
|
988
|
+
this.scrollLeft = x;
|
|
989
|
+
this.scrollTop = y;
|
|
990
|
+
}
|
|
991
|
+
function ease(k) {
|
|
992
|
+
return 0.5 * (1 - Math.cos(Math.PI * k));
|
|
993
|
+
}
|
|
994
|
+
function shouldBailOut(firstArg) {
|
|
995
|
+
if (firstArg === null ||
|
|
996
|
+
typeof firstArg !== 'object' ||
|
|
997
|
+
firstArg.behavior === undefined ||
|
|
998
|
+
firstArg.behavior === 'auto' ||
|
|
999
|
+
firstArg.behavior === 'instant') {
|
|
1000
|
+
return true;
|
|
1001
|
+
}
|
|
1002
|
+
if (typeof firstArg === 'object' && firstArg.behavior === 'smooth') {
|
|
1003
|
+
return false;
|
|
1004
|
+
}
|
|
1005
|
+
throw new TypeError('behavior member of ScrollOptions ' +
|
|
1006
|
+
firstArg.behavior +
|
|
1007
|
+
' is not a valid value for enumeration ScrollBehavior.');
|
|
1008
|
+
}
|
|
1009
|
+
function hasScrollableSpace(el, axis) {
|
|
1010
|
+
if (axis === 'Y') {
|
|
1011
|
+
return el.clientHeight + ROUNDING_TOLERANCE < el.scrollHeight;
|
|
1012
|
+
}
|
|
1013
|
+
if (axis === 'X') {
|
|
1014
|
+
return el.clientWidth + ROUNDING_TOLERANCE < el.scrollWidth;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
function canOverflow(el, axis) {
|
|
1018
|
+
var overflowValue = w.getComputedStyle(el, null)['overflow' + axis];
|
|
1019
|
+
return overflowValue === 'auto' || overflowValue === 'scroll';
|
|
1020
|
+
}
|
|
1021
|
+
function isScrollable(el) {
|
|
1022
|
+
var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y');
|
|
1023
|
+
var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X');
|
|
1024
|
+
return isScrollableY || isScrollableX;
|
|
1025
|
+
}
|
|
1026
|
+
function findScrollableParent(el) {
|
|
1027
|
+
while (el !== d.body && isScrollable(el) === false) {
|
|
1028
|
+
el = el.parentNode || el.host;
|
|
1029
|
+
}
|
|
1030
|
+
return el;
|
|
1031
|
+
}
|
|
1032
|
+
function step(context) {
|
|
1033
|
+
var time = now();
|
|
1034
|
+
var value;
|
|
1035
|
+
var currentX;
|
|
1036
|
+
var currentY;
|
|
1037
|
+
var elapsed = (time - context.startTime) / SCROLL_TIME;
|
|
1038
|
+
elapsed = elapsed > 1 ? 1 : elapsed;
|
|
1039
|
+
value = ease(elapsed);
|
|
1040
|
+
currentX = context.startX + (context.x - context.startX) * value;
|
|
1041
|
+
currentY = context.startY + (context.y - context.startY) * value;
|
|
1042
|
+
context.method.call(context.scrollable, currentX, currentY);
|
|
1043
|
+
if (currentX !== context.x || currentY !== context.y) {
|
|
1044
|
+
w.requestAnimationFrame(step.bind(w, context));
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
function smoothScroll(el, x, y) {
|
|
1048
|
+
var scrollable;
|
|
1049
|
+
var startX;
|
|
1050
|
+
var startY;
|
|
1051
|
+
var method;
|
|
1052
|
+
var startTime = now();
|
|
1053
|
+
if (el === d.body) {
|
|
1054
|
+
scrollable = w;
|
|
1055
|
+
startX = w.scrollX || w.pageXOffset;
|
|
1056
|
+
startY = w.scrollY || w.pageYOffset;
|
|
1057
|
+
method = original.scroll;
|
|
1058
|
+
}
|
|
1059
|
+
else {
|
|
1060
|
+
scrollable = el;
|
|
1061
|
+
startX = el.scrollLeft;
|
|
1062
|
+
startY = el.scrollTop;
|
|
1063
|
+
method = scrollElement;
|
|
1064
|
+
}
|
|
1065
|
+
step({
|
|
1066
|
+
scrollable: scrollable,
|
|
1067
|
+
method: method,
|
|
1068
|
+
startTime: startTime,
|
|
1069
|
+
startX: startX,
|
|
1070
|
+
startY: startY,
|
|
1071
|
+
x: x,
|
|
1072
|
+
y: y,
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
w.scroll = w.scrollTo = function () {
|
|
1076
|
+
if (arguments[0] === undefined) {
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
if (shouldBailOut(arguments[0]) === true) {
|
|
1080
|
+
original.scroll.call(w, arguments[0].left !== undefined
|
|
1081
|
+
? arguments[0].left
|
|
1082
|
+
: typeof arguments[0] !== 'object'
|
|
1083
|
+
? arguments[0]
|
|
1084
|
+
: w.scrollX || w.pageXOffset, arguments[0].top !== undefined
|
|
1085
|
+
? arguments[0].top
|
|
1086
|
+
: arguments[1] !== undefined
|
|
1087
|
+
? arguments[1]
|
|
1088
|
+
: w.scrollY || w.pageYOffset);
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
smoothScroll.call(w, d.body, arguments[0].left !== undefined
|
|
1092
|
+
? ~~arguments[0].left
|
|
1093
|
+
: w.scrollX || w.pageXOffset, arguments[0].top !== undefined
|
|
1094
|
+
? ~~arguments[0].top
|
|
1095
|
+
: w.scrollY || w.pageYOffset);
|
|
1096
|
+
};
|
|
1097
|
+
w.scrollBy = function () {
|
|
1098
|
+
if (arguments[0] === undefined) {
|
|
1099
|
+
return;
|
|
1100
|
+
}
|
|
1101
|
+
if (shouldBailOut(arguments[0])) {
|
|
1102
|
+
original.scrollBy.call(w, arguments[0].left !== undefined
|
|
1103
|
+
? arguments[0].left
|
|
1104
|
+
: typeof arguments[0] !== 'object'
|
|
1105
|
+
? arguments[0]
|
|
1106
|
+
: 0, arguments[0].top !== undefined
|
|
1107
|
+
? arguments[0].top
|
|
1108
|
+
: arguments[1] !== undefined
|
|
1109
|
+
? arguments[1]
|
|
1110
|
+
: 0);
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
smoothScroll.call(w, d.body, ~~arguments[0].left + (w.scrollX || w.pageXOffset), ~~arguments[0].top + (w.scrollY || w.pageYOffset));
|
|
1114
|
+
};
|
|
1115
|
+
Element.prototype.scroll = Element.prototype.scrollTo = function () {
|
|
1116
|
+
if (arguments[0] === undefined) {
|
|
1117
|
+
return;
|
|
1118
|
+
}
|
|
1119
|
+
if (shouldBailOut(arguments[0]) === true) {
|
|
1120
|
+
if (typeof arguments[0] === 'number' && arguments[1] === undefined) {
|
|
1121
|
+
throw new SyntaxError('Value could not be converted');
|
|
1122
|
+
}
|
|
1123
|
+
original.elementScroll.call(this, arguments[0].left !== undefined
|
|
1124
|
+
? ~~arguments[0].left
|
|
1125
|
+
: typeof arguments[0] !== 'object'
|
|
1126
|
+
? ~~arguments[0]
|
|
1127
|
+
: this.scrollLeft, arguments[0].top !== undefined
|
|
1128
|
+
? ~~arguments[0].top
|
|
1129
|
+
: arguments[1] !== undefined
|
|
1130
|
+
? ~~arguments[1]
|
|
1131
|
+
: this.scrollTop);
|
|
1132
|
+
return;
|
|
1133
|
+
}
|
|
1134
|
+
var left = arguments[0].left;
|
|
1135
|
+
var top = arguments[0].top;
|
|
1136
|
+
smoothScroll.call(this, this, typeof left === 'undefined' ? this.scrollLeft : ~~left, typeof top === 'undefined' ? this.scrollTop : ~~top);
|
|
1137
|
+
};
|
|
1138
|
+
Element.prototype.scrollBy = function () {
|
|
1139
|
+
if (arguments[0] === undefined) {
|
|
1140
|
+
return;
|
|
1141
|
+
}
|
|
1142
|
+
if (shouldBailOut(arguments[0]) === true) {
|
|
1143
|
+
original.elementScroll.call(this, arguments[0].left !== undefined
|
|
1144
|
+
? ~~arguments[0].left + this.scrollLeft
|
|
1145
|
+
: ~~arguments[0] + this.scrollLeft, arguments[0].top !== undefined
|
|
1146
|
+
? ~~arguments[0].top + this.scrollTop
|
|
1147
|
+
: ~~arguments[1] + this.scrollTop);
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
this.scroll({
|
|
1151
|
+
left: ~~arguments[0].left + this.scrollLeft,
|
|
1152
|
+
top: ~~arguments[0].top + this.scrollTop,
|
|
1153
|
+
behavior: arguments[0].behavior,
|
|
1154
|
+
});
|
|
1155
|
+
};
|
|
1156
|
+
Element.prototype.scrollIntoView = function () {
|
|
1157
|
+
if (shouldBailOut(arguments[0]) === true) {
|
|
1158
|
+
original.scrollIntoView.call(this, arguments[0] === undefined ? true : arguments[0]);
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
var scrollableParent = findScrollableParent(this);
|
|
1162
|
+
var parentRects = scrollableParent.getBoundingClientRect();
|
|
1163
|
+
var clientRects = this.getBoundingClientRect();
|
|
1164
|
+
if (scrollableParent !== d.body) {
|
|
1165
|
+
smoothScroll.call(this, scrollableParent, scrollableParent.scrollLeft + clientRects.left - parentRects.left, scrollableParent.scrollTop + clientRects.top - parentRects.top);
|
|
1166
|
+
if (w.getComputedStyle(scrollableParent).position !== 'fixed') {
|
|
1167
|
+
w.scrollBy({
|
|
1168
|
+
left: parentRects.left,
|
|
1169
|
+
top: parentRects.top,
|
|
1170
|
+
behavior: 'smooth',
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
else {
|
|
1175
|
+
w.scrollBy({
|
|
1176
|
+
left: clientRects.left,
|
|
1177
|
+
top: clientRects.top,
|
|
1178
|
+
behavior: 'smooth',
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
var EventType;
|
|
1185
|
+
(function (EventType) {
|
|
1186
|
+
EventType[EventType["DomContentLoaded"] = 0] = "DomContentLoaded";
|
|
1187
|
+
EventType[EventType["Load"] = 1] = "Load";
|
|
1188
|
+
EventType[EventType["FullSnapshot"] = 2] = "FullSnapshot";
|
|
1189
|
+
EventType[EventType["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
|
|
1190
|
+
EventType[EventType["Meta"] = 4] = "Meta";
|
|
1191
|
+
EventType[EventType["Custom"] = 5] = "Custom";
|
|
1192
|
+
EventType[EventType["Plugin"] = 6] = "Plugin";
|
|
1193
|
+
})(EventType || (EventType = {}));
|
|
1194
|
+
var IncrementalSource;
|
|
1195
|
+
(function (IncrementalSource) {
|
|
1196
|
+
IncrementalSource[IncrementalSource["Mutation"] = 0] = "Mutation";
|
|
1197
|
+
IncrementalSource[IncrementalSource["MouseMove"] = 1] = "MouseMove";
|
|
1198
|
+
IncrementalSource[IncrementalSource["MouseInteraction"] = 2] = "MouseInteraction";
|
|
1199
|
+
IncrementalSource[IncrementalSource["Scroll"] = 3] = "Scroll";
|
|
1200
|
+
IncrementalSource[IncrementalSource["ViewportResize"] = 4] = "ViewportResize";
|
|
1201
|
+
IncrementalSource[IncrementalSource["Input"] = 5] = "Input";
|
|
1202
|
+
IncrementalSource[IncrementalSource["TouchMove"] = 6] = "TouchMove";
|
|
1203
|
+
IncrementalSource[IncrementalSource["MediaInteraction"] = 7] = "MediaInteraction";
|
|
1204
|
+
IncrementalSource[IncrementalSource["StyleSheetRule"] = 8] = "StyleSheetRule";
|
|
1205
|
+
IncrementalSource[IncrementalSource["CanvasMutation"] = 9] = "CanvasMutation";
|
|
1206
|
+
IncrementalSource[IncrementalSource["Font"] = 10] = "Font";
|
|
1207
|
+
IncrementalSource[IncrementalSource["Log"] = 11] = "Log";
|
|
1208
|
+
IncrementalSource[IncrementalSource["Drag"] = 12] = "Drag";
|
|
1209
|
+
IncrementalSource[IncrementalSource["StyleDeclaration"] = 13] = "StyleDeclaration";
|
|
1210
|
+
})(IncrementalSource || (IncrementalSource = {}));
|
|
1211
|
+
var MouseInteractions;
|
|
1212
|
+
(function (MouseInteractions) {
|
|
1213
|
+
MouseInteractions[MouseInteractions["MouseUp"] = 0] = "MouseUp";
|
|
1214
|
+
MouseInteractions[MouseInteractions["MouseDown"] = 1] = "MouseDown";
|
|
1215
|
+
MouseInteractions[MouseInteractions["Click"] = 2] = "Click";
|
|
1216
|
+
MouseInteractions[MouseInteractions["ContextMenu"] = 3] = "ContextMenu";
|
|
1217
|
+
MouseInteractions[MouseInteractions["DblClick"] = 4] = "DblClick";
|
|
1218
|
+
MouseInteractions[MouseInteractions["Focus"] = 5] = "Focus";
|
|
1219
|
+
MouseInteractions[MouseInteractions["Blur"] = 6] = "Blur";
|
|
1220
|
+
MouseInteractions[MouseInteractions["TouchStart"] = 7] = "TouchStart";
|
|
1221
|
+
MouseInteractions[MouseInteractions["TouchMove_Departed"] = 8] = "TouchMove_Departed";
|
|
1222
|
+
MouseInteractions[MouseInteractions["TouchEnd"] = 9] = "TouchEnd";
|
|
1223
|
+
MouseInteractions[MouseInteractions["TouchCancel"] = 10] = "TouchCancel";
|
|
1224
|
+
})(MouseInteractions || (MouseInteractions = {}));
|
|
1225
|
+
var CanvasContext;
|
|
1226
|
+
(function (CanvasContext) {
|
|
1227
|
+
CanvasContext[CanvasContext["2D"] = 0] = "2D";
|
|
1228
|
+
CanvasContext[CanvasContext["WebGL"] = 1] = "WebGL";
|
|
1229
|
+
CanvasContext[CanvasContext["WebGL2"] = 2] = "WebGL2";
|
|
1230
|
+
})(CanvasContext || (CanvasContext = {}));
|
|
1231
|
+
var MediaInteractions;
|
|
1232
|
+
(function (MediaInteractions) {
|
|
1233
|
+
MediaInteractions[MediaInteractions["Play"] = 0] = "Play";
|
|
1234
|
+
MediaInteractions[MediaInteractions["Pause"] = 1] = "Pause";
|
|
1235
|
+
MediaInteractions[MediaInteractions["Seeked"] = 2] = "Seeked";
|
|
1236
|
+
MediaInteractions[MediaInteractions["VolumeChange"] = 3] = "VolumeChange";
|
|
1237
|
+
})(MediaInteractions || (MediaInteractions = {}));
|
|
1238
|
+
var ReplayerEvents;
|
|
1239
|
+
(function (ReplayerEvents) {
|
|
1240
|
+
ReplayerEvents["Start"] = "start";
|
|
1241
|
+
ReplayerEvents["Pause"] = "pause";
|
|
1242
|
+
ReplayerEvents["Resume"] = "resume";
|
|
1243
|
+
ReplayerEvents["Resize"] = "resize";
|
|
1244
|
+
ReplayerEvents["Finish"] = "finish";
|
|
1245
|
+
ReplayerEvents["FullsnapshotRebuilded"] = "fullsnapshot-rebuilded";
|
|
1246
|
+
ReplayerEvents["LoadStylesheetStart"] = "load-stylesheet-start";
|
|
1247
|
+
ReplayerEvents["LoadStylesheetEnd"] = "load-stylesheet-end";
|
|
1248
|
+
ReplayerEvents["SkipStart"] = "skip-start";
|
|
1249
|
+
ReplayerEvents["SkipEnd"] = "skip-end";
|
|
1250
|
+
ReplayerEvents["MouseInteraction"] = "mouse-interaction";
|
|
1251
|
+
ReplayerEvents["EventCast"] = "event-cast";
|
|
1252
|
+
ReplayerEvents["CustomEvent"] = "custom-event";
|
|
1253
|
+
ReplayerEvents["Flush"] = "flush";
|
|
1254
|
+
ReplayerEvents["StateChange"] = "state-change";
|
|
1255
|
+
ReplayerEvents["PlayBack"] = "play-back";
|
|
1256
|
+
})(ReplayerEvents || (ReplayerEvents = {}));
|
|
1257
|
+
|
|
1258
|
+
var Timer = (function () {
|
|
1259
|
+
function Timer(actions, speed) {
|
|
1260
|
+
if (actions === void 0) { actions = []; }
|
|
1261
|
+
this.timeOffset = 0;
|
|
1262
|
+
this.raf = null;
|
|
1263
|
+
this.actions = actions;
|
|
1264
|
+
this.speed = speed;
|
|
1265
|
+
}
|
|
1266
|
+
Timer.prototype.addAction = function (action) {
|
|
1267
|
+
var index = this.findActionIndex(action);
|
|
1268
|
+
this.actions.splice(index, 0, action);
|
|
1269
|
+
};
|
|
1270
|
+
Timer.prototype.addActions = function (actions) {
|
|
1271
|
+
this.actions = this.actions.concat(actions);
|
|
1272
|
+
};
|
|
1273
|
+
Timer.prototype.replaceActions = function (actions) {
|
|
1274
|
+
var _a;
|
|
1275
|
+
this.actions.length = 0;
|
|
1276
|
+
(_a = this.actions).splice.apply(_a, __spreadArray([0, 0], __read(actions), false));
|
|
1277
|
+
};
|
|
1278
|
+
Timer.prototype.start = function () {
|
|
1279
|
+
this.timeOffset = 0;
|
|
1280
|
+
var lastTimestamp = performance.now();
|
|
1281
|
+
var actions = this.actions;
|
|
1282
|
+
var self = this;
|
|
1283
|
+
function check() {
|
|
1284
|
+
var time = performance.now();
|
|
1285
|
+
self.timeOffset += (time - lastTimestamp) * self.speed;
|
|
1286
|
+
lastTimestamp = time;
|
|
1287
|
+
while (actions.length) {
|
|
1288
|
+
var action = actions[0];
|
|
1289
|
+
if (self.timeOffset >= action.delay) {
|
|
1290
|
+
actions.shift();
|
|
1291
|
+
action.doAction();
|
|
1292
|
+
}
|
|
1293
|
+
else {
|
|
1294
|
+
break;
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
if (actions.length > 0 || self.liveMode) {
|
|
1298
|
+
self.raf = requestAnimationFrame(check);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
this.raf = requestAnimationFrame(check);
|
|
1302
|
+
};
|
|
1303
|
+
Timer.prototype.clear = function () {
|
|
1304
|
+
if (this.raf) {
|
|
1305
|
+
cancelAnimationFrame(this.raf);
|
|
1306
|
+
this.raf = null;
|
|
1307
|
+
}
|
|
1308
|
+
this.actions.length = 0;
|
|
1309
|
+
};
|
|
1310
|
+
Timer.prototype.setSpeed = function (speed) {
|
|
1311
|
+
this.speed = speed;
|
|
1312
|
+
};
|
|
1313
|
+
Timer.prototype.toggleLiveMode = function (mode) {
|
|
1314
|
+
this.liveMode = mode;
|
|
1315
|
+
};
|
|
1316
|
+
Timer.prototype.isActive = function () {
|
|
1317
|
+
return this.raf !== null;
|
|
1318
|
+
};
|
|
1319
|
+
Timer.prototype.findActionIndex = function (action) {
|
|
1320
|
+
var start = 0;
|
|
1321
|
+
var end = this.actions.length - 1;
|
|
1322
|
+
while (start <= end) {
|
|
1323
|
+
var mid = Math.floor((start + end) / 2);
|
|
1324
|
+
if (this.actions[mid].delay < action.delay) {
|
|
1325
|
+
start = mid + 1;
|
|
1326
|
+
}
|
|
1327
|
+
else if (this.actions[mid].delay > action.delay) {
|
|
1328
|
+
end = mid - 1;
|
|
1329
|
+
}
|
|
1330
|
+
else {
|
|
1331
|
+
return mid + 1;
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
return start;
|
|
1335
|
+
};
|
|
1336
|
+
return Timer;
|
|
1337
|
+
}());
|
|
1338
|
+
function addDelay(event, baselineTime) {
|
|
1339
|
+
if (event.type === EventType.IncrementalSnapshot &&
|
|
1340
|
+
event.data.source === IncrementalSource.MouseMove) {
|
|
1341
|
+
var firstOffset = event.data.positions[0].timeOffset;
|
|
1342
|
+
var firstTimestamp = event.timestamp + firstOffset;
|
|
1343
|
+
event.delay = firstTimestamp - baselineTime;
|
|
1344
|
+
return firstTimestamp - baselineTime;
|
|
1345
|
+
}
|
|
1346
|
+
event.delay = event.timestamp - baselineTime;
|
|
1347
|
+
return event.delay;
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
/*! *****************************************************************************
|
|
1351
|
+
Copyright (c) Microsoft Corporation.
|
|
1352
|
+
|
|
1353
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
1354
|
+
purpose with or without fee is hereby granted.
|
|
1355
|
+
|
|
1356
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1357
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1358
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1359
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1360
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1361
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1362
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
1363
|
+
***************************************************************************** */
|
|
1364
|
+
function t(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),a=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)a.push(r.value);}catch(t){o={error:t};}finally{try{r&&!r.done&&(e=i.return)&&e.call(i);}finally{if(o)throw o.error}}return a}var n;!function(t){t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped";}(n||(n={}));var e={type:"xstate.init"};function r(t){return void 0===t?[]:[].concat(t)}function o(t){return {type:"xstate.assign",assignment:t}}function i$1(t,n){return "string"==typeof(t="string"==typeof t&&n&&n[t]?n[t]:t)?{type:t}:"function"==typeof t?{type:t.name,exec:t}:t}function a(t){return function(n){return t===n}}function u(t){return "string"==typeof t?{type:t}:t}function c(t,n){return {value:t,context:n,actions:[],changed:!1,matches:a(t)}}function f(t,n,e){var r=n,o=!1;return [t.filter((function(t){if("xstate.assign"===t.type){o=!0;var n=Object.assign({},r);return "function"==typeof t.assignment?n=t.assignment(r,e):Object.keys(t.assignment).forEach((function(o){n[o]="function"==typeof t.assignment[o]?t.assignment[o](r,e):t.assignment[o];})),r=n,!1}return !0})),r,o]}function s(n,o){void 0===o&&(o={});var s=t(f(r(n.states[n.initial].entry).map((function(t){return i$1(t,o.actions)})),n.context,e),2),l=s[0],v=s[1],y={config:n,_options:o,initialState:{value:n.initial,actions:l,context:v,matches:a(n.initial)},transition:function(e,o){var s,l,v="string"==typeof e?{value:e,context:n.context}:e,p=v.value,g=v.context,d=u(o),x=n.states[p];if(x.on){var m=r(x.on[d.type]);try{for(var h=function(t){var n="function"==typeof Symbol&&Symbol.iterator,e=n&&t[n],r=0;if(e)return e.call(t);if(t&&"number"==typeof t.length)return {next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}(m),b=h.next();!b.done;b=h.next()){var S=b.value;if(void 0===S)return c(p,g);var w="string"==typeof S?{target:S}:S,j=w.target,E=w.actions,R=void 0===E?[]:E,N=w.cond,O=void 0===N?function(){return !0}:N,_=void 0===j,k=null!=j?j:p,T=n.states[k];if(O(g,d)){var q=t(f((_?r(R):[].concat(x.exit,R,T.entry).filter((function(t){return t}))).map((function(t){return i$1(t,y._options.actions)})),g,d),3),z=q[0],A=q[1],B=q[2],C=null!=j?j:p;return {value:C,context:A,actions:z,changed:j!==p||z.length>0||B,matches:a(C)}}}}catch(t){s={error:t};}finally{try{b&&!b.done&&(l=h.return)&&l.call(h);}finally{if(s)throw s.error}}}return c(p,g)}};return y}var l=function(t,n){return t.actions.forEach((function(e){var r=e.exec;return r&&r(t.context,n)}))};function v(t){var r=t.initialState,o=n.NotStarted,i=new Set,c={_machine:t,send:function(e){o===n.Running&&(r=t.transition(r,e),l(r,u(e)),i.forEach((function(t){return t(r)})));},subscribe:function(t){return i.add(t),t(r),{unsubscribe:function(){return i.delete(t)}}},start:function(i){if(i){var u="object"==typeof i?i:{context:t.config.context,value:i};r={value:u.value,actions:[],context:u.context,matches:a(u.value)};}return o=n.Running,l(r,e),c},stop:function(){return o=n.Stopped,i.clear(),c},get state(){return r},get status(){return o}};return c}
|
|
1365
|
+
|
|
1366
|
+
function discardPriorSnapshots(events, baselineTime) {
|
|
1367
|
+
for (var idx = events.length - 1; idx >= 0; idx--) {
|
|
1368
|
+
var event_1 = events[idx];
|
|
1369
|
+
if (event_1.type === EventType.Meta) {
|
|
1370
|
+
if (event_1.timestamp <= baselineTime) {
|
|
1371
|
+
return events.slice(idx);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
return events;
|
|
1376
|
+
}
|
|
1377
|
+
function createPlayerService(context, _a) {
|
|
1378
|
+
var getCastFn = _a.getCastFn, applyEventsSynchronously = _a.applyEventsSynchronously, emitter = _a.emitter;
|
|
1379
|
+
var playerMachine = s({
|
|
1380
|
+
id: 'player',
|
|
1381
|
+
context: context,
|
|
1382
|
+
initial: 'paused',
|
|
1383
|
+
states: {
|
|
1384
|
+
playing: {
|
|
1385
|
+
on: {
|
|
1386
|
+
PAUSE: {
|
|
1387
|
+
target: 'paused',
|
|
1388
|
+
actions: ['pause'],
|
|
1389
|
+
},
|
|
1390
|
+
CAST_EVENT: {
|
|
1391
|
+
target: 'playing',
|
|
1392
|
+
actions: 'castEvent',
|
|
1393
|
+
},
|
|
1394
|
+
END: {
|
|
1395
|
+
target: 'paused',
|
|
1396
|
+
actions: ['resetLastPlayedEvent', 'pause'],
|
|
1397
|
+
},
|
|
1398
|
+
ADD_EVENT: {
|
|
1399
|
+
target: 'playing',
|
|
1400
|
+
actions: ['addEvent'],
|
|
1401
|
+
},
|
|
1402
|
+
REPLACE_EVENTS: {
|
|
1403
|
+
target: 'playing',
|
|
1404
|
+
actions: ['replaceEvents'],
|
|
1405
|
+
},
|
|
1406
|
+
},
|
|
1407
|
+
},
|
|
1408
|
+
paused: {
|
|
1409
|
+
on: {
|
|
1410
|
+
PLAY: {
|
|
1411
|
+
target: 'playing',
|
|
1412
|
+
actions: ['recordTimeOffset', 'play'],
|
|
1413
|
+
},
|
|
1414
|
+
CAST_EVENT: {
|
|
1415
|
+
target: 'paused',
|
|
1416
|
+
actions: 'castEvent',
|
|
1417
|
+
},
|
|
1418
|
+
TO_LIVE: {
|
|
1419
|
+
target: 'live',
|
|
1420
|
+
actions: ['startLive'],
|
|
1421
|
+
},
|
|
1422
|
+
ADD_EVENT: {
|
|
1423
|
+
target: 'paused',
|
|
1424
|
+
actions: ['addEvent'],
|
|
1425
|
+
},
|
|
1426
|
+
REPLACE_EVENTS: {
|
|
1427
|
+
target: 'paused',
|
|
1428
|
+
actions: ['replaceEvents'],
|
|
1429
|
+
},
|
|
1430
|
+
},
|
|
1431
|
+
},
|
|
1432
|
+
live: {
|
|
1433
|
+
on: {
|
|
1434
|
+
ADD_EVENT: {
|
|
1435
|
+
target: 'live',
|
|
1436
|
+
actions: ['addEvent'],
|
|
1437
|
+
},
|
|
1438
|
+
CAST_EVENT: {
|
|
1439
|
+
target: 'live',
|
|
1440
|
+
actions: ['castEvent'],
|
|
1441
|
+
},
|
|
1442
|
+
},
|
|
1443
|
+
},
|
|
1444
|
+
},
|
|
1445
|
+
}, {
|
|
1446
|
+
actions: {
|
|
1447
|
+
castEvent: o({
|
|
1448
|
+
lastPlayedEvent: function (ctx, event) {
|
|
1449
|
+
if (event.type === 'CAST_EVENT') {
|
|
1450
|
+
return event.payload.event;
|
|
1451
|
+
}
|
|
1452
|
+
return ctx.lastPlayedEvent;
|
|
1453
|
+
},
|
|
1454
|
+
}),
|
|
1455
|
+
recordTimeOffset: o(function (ctx, event) {
|
|
1456
|
+
var timeOffset = ctx.timeOffset;
|
|
1457
|
+
if ('payload' in event && 'timeOffset' in event.payload) {
|
|
1458
|
+
timeOffset = event.payload.timeOffset;
|
|
1459
|
+
}
|
|
1460
|
+
return __assign(__assign({}, ctx), { timeOffset: timeOffset, baselineTime: ctx.events[0].timestamp + timeOffset });
|
|
1461
|
+
}),
|
|
1462
|
+
play: function (ctx) {
|
|
1463
|
+
var e_1, _a, e_2, _b;
|
|
1464
|
+
var _c;
|
|
1465
|
+
var timer = ctx.timer, events = ctx.events, baselineTime = ctx.baselineTime, lastPlayedEvent = ctx.lastPlayedEvent;
|
|
1466
|
+
timer.clear();
|
|
1467
|
+
try {
|
|
1468
|
+
for (var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) {
|
|
1469
|
+
var event_2 = events_1_1.value;
|
|
1470
|
+
addDelay(event_2, baselineTime);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1474
|
+
finally {
|
|
1475
|
+
try {
|
|
1476
|
+
if (events_1_1 && !events_1_1.done && (_a = events_1.return)) _a.call(events_1);
|
|
1477
|
+
}
|
|
1478
|
+
finally { if (e_1) throw e_1.error; }
|
|
1479
|
+
}
|
|
1480
|
+
var neededEvents = discardPriorSnapshots(events, baselineTime);
|
|
1481
|
+
var lastPlayedTimestamp = lastPlayedEvent === null || lastPlayedEvent === void 0 ? void 0 : lastPlayedEvent.timestamp;
|
|
1482
|
+
if ((lastPlayedEvent === null || lastPlayedEvent === void 0 ? void 0 : lastPlayedEvent.type) === EventType.IncrementalSnapshot &&
|
|
1483
|
+
lastPlayedEvent.data.source === IncrementalSource.MouseMove) {
|
|
1484
|
+
lastPlayedTimestamp =
|
|
1485
|
+
lastPlayedEvent.timestamp +
|
|
1486
|
+
((_c = lastPlayedEvent.data.positions[0]) === null || _c === void 0 ? void 0 : _c.timeOffset);
|
|
1487
|
+
}
|
|
1488
|
+
if (baselineTime < (lastPlayedTimestamp || 0)) {
|
|
1489
|
+
emitter.emit(ReplayerEvents.PlayBack);
|
|
1490
|
+
}
|
|
1491
|
+
var syncEvents = new Array();
|
|
1492
|
+
var actions = new Array();
|
|
1493
|
+
var _loop_1 = function (event_3) {
|
|
1494
|
+
if (lastPlayedTimestamp &&
|
|
1495
|
+
lastPlayedTimestamp < baselineTime &&
|
|
1496
|
+
(event_3.timestamp <= lastPlayedTimestamp ||
|
|
1497
|
+
event_3 === lastPlayedEvent)) {
|
|
1498
|
+
return "continue";
|
|
1499
|
+
}
|
|
1500
|
+
if (event_3.timestamp < baselineTime) {
|
|
1501
|
+
syncEvents.push(event_3);
|
|
1502
|
+
}
|
|
1503
|
+
else {
|
|
1504
|
+
var castFn_1 = getCastFn(event_3, false);
|
|
1505
|
+
actions.push({
|
|
1506
|
+
doAction: function () {
|
|
1507
|
+
castFn_1();
|
|
1508
|
+
},
|
|
1509
|
+
delay: event_3.delay,
|
|
1510
|
+
});
|
|
1511
|
+
}
|
|
1512
|
+
};
|
|
1513
|
+
try {
|
|
1514
|
+
for (var neededEvents_1 = __values(neededEvents), neededEvents_1_1 = neededEvents_1.next(); !neededEvents_1_1.done; neededEvents_1_1 = neededEvents_1.next()) {
|
|
1515
|
+
var event_3 = neededEvents_1_1.value;
|
|
1516
|
+
_loop_1(event_3);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1520
|
+
finally {
|
|
1521
|
+
try {
|
|
1522
|
+
if (neededEvents_1_1 && !neededEvents_1_1.done && (_b = neededEvents_1.return)) _b.call(neededEvents_1);
|
|
1523
|
+
}
|
|
1524
|
+
finally { if (e_2) throw e_2.error; }
|
|
1525
|
+
}
|
|
1526
|
+
applyEventsSynchronously(syncEvents);
|
|
1527
|
+
emitter.emit(ReplayerEvents.Flush);
|
|
1528
|
+
timer.addActions(actions);
|
|
1529
|
+
timer.start();
|
|
1530
|
+
},
|
|
1531
|
+
pause: function (ctx) {
|
|
1532
|
+
ctx.timer.clear();
|
|
1533
|
+
},
|
|
1534
|
+
resetLastPlayedEvent: o(function (ctx) {
|
|
1535
|
+
return __assign(__assign({}, ctx), { lastPlayedEvent: null });
|
|
1536
|
+
}),
|
|
1537
|
+
startLive: o({
|
|
1538
|
+
baselineTime: function (ctx, event) {
|
|
1539
|
+
ctx.timer.toggleLiveMode(true);
|
|
1540
|
+
ctx.timer.start();
|
|
1541
|
+
if (event.type === 'TO_LIVE' && event.payload.baselineTime) {
|
|
1542
|
+
return event.payload.baselineTime;
|
|
1543
|
+
}
|
|
1544
|
+
return Date.now();
|
|
1545
|
+
},
|
|
1546
|
+
}),
|
|
1547
|
+
replaceEvents: o(function (ctx, machineEvent) {
|
|
1548
|
+
var e_3, _a;
|
|
1549
|
+
var curEvents = ctx.events, timer = ctx.timer, baselineTime = ctx.baselineTime;
|
|
1550
|
+
if (machineEvent.type === 'REPLACE_EVENTS') {
|
|
1551
|
+
var newEvents = machineEvent.payload.events;
|
|
1552
|
+
curEvents.length = 0;
|
|
1553
|
+
var actions = [];
|
|
1554
|
+
var _loop_2 = function (event_4) {
|
|
1555
|
+
addDelay(event_4, baselineTime);
|
|
1556
|
+
curEvents.push(event_4);
|
|
1557
|
+
if (event_4.timestamp >= timer.timeOffset + baselineTime) {
|
|
1558
|
+
var castFn_2 = getCastFn(event_4, false);
|
|
1559
|
+
actions.push({
|
|
1560
|
+
doAction: function () {
|
|
1561
|
+
castFn_2();
|
|
1562
|
+
},
|
|
1563
|
+
delay: event_4.delay,
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
};
|
|
1567
|
+
try {
|
|
1568
|
+
for (var newEvents_1 = __values(newEvents), newEvents_1_1 = newEvents_1.next(); !newEvents_1_1.done; newEvents_1_1 = newEvents_1.next()) {
|
|
1569
|
+
var event_4 = newEvents_1_1.value;
|
|
1570
|
+
_loop_2(event_4);
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1574
|
+
finally {
|
|
1575
|
+
try {
|
|
1576
|
+
if (newEvents_1_1 && !newEvents_1_1.done && (_a = newEvents_1.return)) _a.call(newEvents_1);
|
|
1577
|
+
}
|
|
1578
|
+
finally { if (e_3) throw e_3.error; }
|
|
1579
|
+
}
|
|
1580
|
+
if (timer.isActive()) {
|
|
1581
|
+
timer.replaceActions(actions);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
return __assign(__assign({}, ctx), { events: curEvents });
|
|
1585
|
+
}),
|
|
1586
|
+
addEvent: o(function (ctx, machineEvent) {
|
|
1587
|
+
var baselineTime = ctx.baselineTime, timer = ctx.timer, events = ctx.events;
|
|
1588
|
+
if (machineEvent.type === 'ADD_EVENT') {
|
|
1589
|
+
var event_5 = machineEvent.payload.event;
|
|
1590
|
+
addDelay(event_5, baselineTime);
|
|
1591
|
+
var end = events.length - 1;
|
|
1592
|
+
if (!events[end] || events[end].timestamp <= event_5.timestamp) {
|
|
1593
|
+
events.push(event_5);
|
|
1594
|
+
}
|
|
1595
|
+
else {
|
|
1596
|
+
var insertionIndex = -1;
|
|
1597
|
+
var start = 0;
|
|
1598
|
+
while (start <= end) {
|
|
1599
|
+
var mid = Math.floor((start + end) / 2);
|
|
1600
|
+
if (events[mid].timestamp <= event_5.timestamp) {
|
|
1601
|
+
start = mid + 1;
|
|
1602
|
+
}
|
|
1603
|
+
else {
|
|
1604
|
+
end = mid - 1;
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
if (insertionIndex === -1) {
|
|
1608
|
+
insertionIndex = start;
|
|
1609
|
+
}
|
|
1610
|
+
events.splice(insertionIndex, 0, event_5);
|
|
1611
|
+
}
|
|
1612
|
+
var isSync = event_5.timestamp < baselineTime;
|
|
1613
|
+
var castFn_3 = getCastFn(event_5, isSync);
|
|
1614
|
+
if (isSync) {
|
|
1615
|
+
castFn_3();
|
|
1616
|
+
}
|
|
1617
|
+
else if (timer.isActive()) {
|
|
1618
|
+
timer.addAction({
|
|
1619
|
+
doAction: function () {
|
|
1620
|
+
castFn_3();
|
|
1621
|
+
},
|
|
1622
|
+
delay: event_5.delay,
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
return __assign(__assign({}, ctx), { events: events });
|
|
1627
|
+
}),
|
|
1628
|
+
},
|
|
1629
|
+
});
|
|
1630
|
+
return v(playerMachine);
|
|
1631
|
+
}
|
|
1632
|
+
function createSpeedService(context) {
|
|
1633
|
+
var speedMachine = s({
|
|
1634
|
+
id: 'speed',
|
|
1635
|
+
context: context,
|
|
1636
|
+
initial: 'normal',
|
|
1637
|
+
states: {
|
|
1638
|
+
normal: {
|
|
1639
|
+
on: {
|
|
1640
|
+
FAST_FORWARD: {
|
|
1641
|
+
target: 'skipping',
|
|
1642
|
+
actions: ['recordSpeed', 'setSpeed'],
|
|
1643
|
+
},
|
|
1644
|
+
SET_SPEED: {
|
|
1645
|
+
target: 'normal',
|
|
1646
|
+
actions: ['setSpeed'],
|
|
1647
|
+
},
|
|
1648
|
+
},
|
|
1649
|
+
},
|
|
1650
|
+
skipping: {
|
|
1651
|
+
on: {
|
|
1652
|
+
BACK_TO_NORMAL: {
|
|
1653
|
+
target: 'normal',
|
|
1654
|
+
actions: ['restoreSpeed'],
|
|
1655
|
+
},
|
|
1656
|
+
SET_SPEED: {
|
|
1657
|
+
target: 'normal',
|
|
1658
|
+
actions: ['setSpeed'],
|
|
1659
|
+
},
|
|
1660
|
+
},
|
|
1661
|
+
},
|
|
1662
|
+
},
|
|
1663
|
+
}, {
|
|
1664
|
+
actions: {
|
|
1665
|
+
setSpeed: function (ctx, event) {
|
|
1666
|
+
if ('payload' in event) {
|
|
1667
|
+
ctx.timer.setSpeed(event.payload.speed);
|
|
1668
|
+
}
|
|
1669
|
+
},
|
|
1670
|
+
recordSpeed: o({
|
|
1671
|
+
normalSpeed: function (ctx) { return ctx.timer.speed; },
|
|
1672
|
+
}),
|
|
1673
|
+
restoreSpeed: function (ctx) {
|
|
1674
|
+
ctx.timer.setSpeed(ctx.normalSpeed);
|
|
1675
|
+
},
|
|
1676
|
+
},
|
|
1677
|
+
});
|
|
1678
|
+
return v(speedMachine);
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
function createMirror() {
|
|
1682
|
+
return {
|
|
1683
|
+
map: {},
|
|
1684
|
+
getId: function (n) {
|
|
1685
|
+
if (!n || !n.__sn) {
|
|
1686
|
+
return -1;
|
|
1687
|
+
}
|
|
1688
|
+
return n.__sn.id;
|
|
1689
|
+
},
|
|
1690
|
+
getNode: function (id) {
|
|
1691
|
+
return this.map[id] || null;
|
|
1692
|
+
},
|
|
1693
|
+
removeNodeFromMap: function (n) {
|
|
1694
|
+
var _this = this;
|
|
1695
|
+
var id = n.__sn && n.__sn.id;
|
|
1696
|
+
delete this.map[id];
|
|
1697
|
+
if (n.childNodes) {
|
|
1698
|
+
n.childNodes.forEach(function (child) {
|
|
1699
|
+
return _this.removeNodeFromMap(child);
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
},
|
|
1703
|
+
has: function (id) {
|
|
1704
|
+
return this.map.hasOwnProperty(id);
|
|
1705
|
+
},
|
|
1706
|
+
reset: function () {
|
|
1707
|
+
this.map = {};
|
|
1708
|
+
},
|
|
1709
|
+
};
|
|
1710
|
+
}
|
|
1711
|
+
var DEPARTED_MIRROR_ACCESS_WARNING = 'Please stop import mirror directly. Instead of that,' +
|
|
1712
|
+
'\r\n' +
|
|
1713
|
+
'now you can use replayer.getMirror() to access the mirror instance of a replayer,' +
|
|
1714
|
+
'\r\n' +
|
|
1715
|
+
'or you can use record.mirror to access the mirror instance during recording.';
|
|
1716
|
+
var _mirror = {
|
|
1717
|
+
map: {},
|
|
1718
|
+
getId: function () {
|
|
1719
|
+
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
1720
|
+
return -1;
|
|
1721
|
+
},
|
|
1722
|
+
getNode: function () {
|
|
1723
|
+
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
1724
|
+
return null;
|
|
1725
|
+
},
|
|
1726
|
+
removeNodeFromMap: function () {
|
|
1727
|
+
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
1728
|
+
},
|
|
1729
|
+
has: function () {
|
|
1730
|
+
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
1731
|
+
return false;
|
|
1732
|
+
},
|
|
1733
|
+
reset: function () {
|
|
1734
|
+
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
1735
|
+
},
|
|
1736
|
+
};
|
|
1737
|
+
if (typeof window !== 'undefined' && window.Proxy && window.Reflect) {
|
|
1738
|
+
_mirror = new Proxy(_mirror, {
|
|
1739
|
+
get: function (target, prop, receiver) {
|
|
1740
|
+
if (prop === 'map') {
|
|
1741
|
+
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
1742
|
+
}
|
|
1743
|
+
return Reflect.get(target, prop, receiver);
|
|
1744
|
+
},
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
function polyfill(win) {
|
|
1748
|
+
if (win === void 0) { win = window; }
|
|
1749
|
+
if ('NodeList' in win && !win.NodeList.prototype.forEach) {
|
|
1750
|
+
win.NodeList.prototype.forEach = Array.prototype
|
|
1751
|
+
.forEach;
|
|
1752
|
+
}
|
|
1753
|
+
if ('DOMTokenList' in win && !win.DOMTokenList.prototype.forEach) {
|
|
1754
|
+
win.DOMTokenList.prototype.forEach = Array.prototype
|
|
1755
|
+
.forEach;
|
|
1756
|
+
}
|
|
1757
|
+
if (!Node.prototype.contains) {
|
|
1758
|
+
Node.prototype.contains = function contains(node) {
|
|
1759
|
+
if (!(0 in arguments)) {
|
|
1760
|
+
throw new TypeError('1 argument is required');
|
|
1761
|
+
}
|
|
1762
|
+
do {
|
|
1763
|
+
if (this === node) {
|
|
1764
|
+
return true;
|
|
1765
|
+
}
|
|
1766
|
+
} while ((node = node && node.parentNode));
|
|
1767
|
+
return false;
|
|
1768
|
+
};
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
var TreeIndex = (function () {
|
|
1772
|
+
function TreeIndex() {
|
|
1773
|
+
this.reset();
|
|
1774
|
+
}
|
|
1775
|
+
TreeIndex.prototype.add = function (mutation) {
|
|
1776
|
+
var parentTreeNode = this.indexes.get(mutation.parentId);
|
|
1777
|
+
var treeNode = {
|
|
1778
|
+
id: mutation.node.id,
|
|
1779
|
+
mutation: mutation,
|
|
1780
|
+
children: [],
|
|
1781
|
+
texts: [],
|
|
1782
|
+
attributes: [],
|
|
1783
|
+
};
|
|
1784
|
+
if (!parentTreeNode) {
|
|
1785
|
+
this.tree[treeNode.id] = treeNode;
|
|
1786
|
+
}
|
|
1787
|
+
else {
|
|
1788
|
+
treeNode.parent = parentTreeNode;
|
|
1789
|
+
parentTreeNode.children[treeNode.id] = treeNode;
|
|
1790
|
+
}
|
|
1791
|
+
this.indexes.set(treeNode.id, treeNode);
|
|
1792
|
+
};
|
|
1793
|
+
TreeIndex.prototype.remove = function (mutation, mirror) {
|
|
1794
|
+
var _this = this;
|
|
1795
|
+
var parentTreeNode = this.indexes.get(mutation.parentId);
|
|
1796
|
+
var treeNode = this.indexes.get(mutation.id);
|
|
1797
|
+
var deepRemoveFromMirror = function (id) {
|
|
1798
|
+
_this.removeIdSet.add(id);
|
|
1799
|
+
var node = mirror.getNode(id);
|
|
1800
|
+
node === null || node === void 0 ? void 0 : node.childNodes.forEach(function (childNode) {
|
|
1801
|
+
if ('__sn' in childNode) {
|
|
1802
|
+
deepRemoveFromMirror(childNode.__sn.id);
|
|
1803
|
+
}
|
|
1804
|
+
});
|
|
1805
|
+
};
|
|
1806
|
+
var deepRemoveFromTreeIndex = function (node) {
|
|
1807
|
+
_this.removeIdSet.add(node.id);
|
|
1808
|
+
Object.values(node.children).forEach(function (n) { return deepRemoveFromTreeIndex(n); });
|
|
1809
|
+
var _treeNode = _this.indexes.get(node.id);
|
|
1810
|
+
if (_treeNode) {
|
|
1811
|
+
var _parentTreeNode = _treeNode.parent;
|
|
1812
|
+
if (_parentTreeNode) {
|
|
1813
|
+
delete _treeNode.parent;
|
|
1814
|
+
delete _parentTreeNode.children[_treeNode.id];
|
|
1815
|
+
_this.indexes.delete(mutation.id);
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
};
|
|
1819
|
+
if (!treeNode) {
|
|
1820
|
+
this.removeNodeMutations.push(mutation);
|
|
1821
|
+
deepRemoveFromMirror(mutation.id);
|
|
1822
|
+
}
|
|
1823
|
+
else if (!parentTreeNode) {
|
|
1824
|
+
delete this.tree[treeNode.id];
|
|
1825
|
+
this.indexes.delete(treeNode.id);
|
|
1826
|
+
deepRemoveFromTreeIndex(treeNode);
|
|
1827
|
+
}
|
|
1828
|
+
else {
|
|
1829
|
+
delete treeNode.parent;
|
|
1830
|
+
delete parentTreeNode.children[treeNode.id];
|
|
1831
|
+
this.indexes.delete(mutation.id);
|
|
1832
|
+
deepRemoveFromTreeIndex(treeNode);
|
|
1833
|
+
}
|
|
1834
|
+
};
|
|
1835
|
+
TreeIndex.prototype.text = function (mutation) {
|
|
1836
|
+
var treeNode = this.indexes.get(mutation.id);
|
|
1837
|
+
if (treeNode) {
|
|
1838
|
+
treeNode.texts.push(mutation);
|
|
1839
|
+
}
|
|
1840
|
+
else {
|
|
1841
|
+
this.textMutations.push(mutation);
|
|
1842
|
+
}
|
|
1843
|
+
};
|
|
1844
|
+
TreeIndex.prototype.attribute = function (mutation) {
|
|
1845
|
+
var treeNode = this.indexes.get(mutation.id);
|
|
1846
|
+
if (treeNode) {
|
|
1847
|
+
treeNode.attributes.push(mutation);
|
|
1848
|
+
}
|
|
1849
|
+
else {
|
|
1850
|
+
this.attributeMutations.push(mutation);
|
|
1851
|
+
}
|
|
1852
|
+
};
|
|
1853
|
+
TreeIndex.prototype.scroll = function (d) {
|
|
1854
|
+
this.scrollMap.set(d.id, d);
|
|
1855
|
+
};
|
|
1856
|
+
TreeIndex.prototype.input = function (d) {
|
|
1857
|
+
this.inputMap.set(d.id, d);
|
|
1858
|
+
};
|
|
1859
|
+
TreeIndex.prototype.flush = function () {
|
|
1860
|
+
var e_1, _a, e_2, _b;
|
|
1861
|
+
var _this = this;
|
|
1862
|
+
var _c = this, tree = _c.tree, removeNodeMutations = _c.removeNodeMutations, textMutations = _c.textMutations, attributeMutations = _c.attributeMutations;
|
|
1863
|
+
var batchMutationData = {
|
|
1864
|
+
source: IncrementalSource.Mutation,
|
|
1865
|
+
removes: removeNodeMutations,
|
|
1866
|
+
texts: textMutations,
|
|
1867
|
+
attributes: attributeMutations,
|
|
1868
|
+
adds: [],
|
|
1869
|
+
};
|
|
1870
|
+
var walk = function (treeNode, removed) {
|
|
1871
|
+
if (removed) {
|
|
1872
|
+
_this.removeIdSet.add(treeNode.id);
|
|
1873
|
+
}
|
|
1874
|
+
batchMutationData.texts = batchMutationData.texts
|
|
1875
|
+
.concat(removed ? [] : treeNode.texts)
|
|
1876
|
+
.filter(function (m) { return !_this.removeIdSet.has(m.id); });
|
|
1877
|
+
batchMutationData.attributes = batchMutationData.attributes
|
|
1878
|
+
.concat(removed ? [] : treeNode.attributes)
|
|
1879
|
+
.filter(function (m) { return !_this.removeIdSet.has(m.id); });
|
|
1880
|
+
if (!_this.removeIdSet.has(treeNode.id) &&
|
|
1881
|
+
!_this.removeIdSet.has(treeNode.mutation.parentId) &&
|
|
1882
|
+
!removed) {
|
|
1883
|
+
batchMutationData.adds.push(treeNode.mutation);
|
|
1884
|
+
if (treeNode.children) {
|
|
1885
|
+
Object.values(treeNode.children).forEach(function (n) { return walk(n, false); });
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
else {
|
|
1889
|
+
Object.values(treeNode.children).forEach(function (n) { return walk(n, true); });
|
|
1890
|
+
}
|
|
1891
|
+
};
|
|
1892
|
+
Object.values(tree).forEach(function (n) { return walk(n, false); });
|
|
1893
|
+
try {
|
|
1894
|
+
for (var _d = __values(this.scrollMap.keys()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1895
|
+
var id = _e.value;
|
|
1896
|
+
if (this.removeIdSet.has(id)) {
|
|
1897
|
+
this.scrollMap.delete(id);
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1902
|
+
finally {
|
|
1903
|
+
try {
|
|
1904
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
1905
|
+
}
|
|
1906
|
+
finally { if (e_1) throw e_1.error; }
|
|
1907
|
+
}
|
|
1908
|
+
try {
|
|
1909
|
+
for (var _f = __values(this.inputMap.keys()), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1910
|
+
var id = _g.value;
|
|
1911
|
+
if (this.removeIdSet.has(id)) {
|
|
1912
|
+
this.inputMap.delete(id);
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1917
|
+
finally {
|
|
1918
|
+
try {
|
|
1919
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
1920
|
+
}
|
|
1921
|
+
finally { if (e_2) throw e_2.error; }
|
|
1922
|
+
}
|
|
1923
|
+
var scrollMap = new Map(this.scrollMap);
|
|
1924
|
+
var inputMap = new Map(this.inputMap);
|
|
1925
|
+
this.reset();
|
|
1926
|
+
return {
|
|
1927
|
+
mutationData: batchMutationData,
|
|
1928
|
+
scrollMap: scrollMap,
|
|
1929
|
+
inputMap: inputMap,
|
|
1930
|
+
};
|
|
1931
|
+
};
|
|
1932
|
+
TreeIndex.prototype.reset = function () {
|
|
1933
|
+
this.tree = [];
|
|
1934
|
+
this.indexes = new Map();
|
|
1935
|
+
this.removeNodeMutations = [];
|
|
1936
|
+
this.textMutations = [];
|
|
1937
|
+
this.attributeMutations = [];
|
|
1938
|
+
this.removeIdSet = new Set();
|
|
1939
|
+
this.scrollMap = new Map();
|
|
1940
|
+
this.inputMap = new Map();
|
|
1941
|
+
};
|
|
1942
|
+
TreeIndex.prototype.idRemoved = function (id) {
|
|
1943
|
+
return this.removeIdSet.has(id);
|
|
1944
|
+
};
|
|
1945
|
+
return TreeIndex;
|
|
1946
|
+
}());
|
|
1947
|
+
function queueToResolveTrees(queue) {
|
|
1948
|
+
var e_3, _a;
|
|
1949
|
+
var queueNodeMap = {};
|
|
1950
|
+
var putIntoMap = function (m, parent) {
|
|
1951
|
+
var nodeInTree = {
|
|
1952
|
+
value: m,
|
|
1953
|
+
parent: parent,
|
|
1954
|
+
children: [],
|
|
1955
|
+
};
|
|
1956
|
+
queueNodeMap[m.node.id] = nodeInTree;
|
|
1957
|
+
return nodeInTree;
|
|
1958
|
+
};
|
|
1959
|
+
var queueNodeTrees = [];
|
|
1960
|
+
try {
|
|
1961
|
+
for (var queue_1 = __values(queue), queue_1_1 = queue_1.next(); !queue_1_1.done; queue_1_1 = queue_1.next()) {
|
|
1962
|
+
var mutation = queue_1_1.value;
|
|
1963
|
+
var nextId = mutation.nextId, parentId = mutation.parentId;
|
|
1964
|
+
if (nextId && nextId in queueNodeMap) {
|
|
1965
|
+
var nextInTree = queueNodeMap[nextId];
|
|
1966
|
+
if (nextInTree.parent) {
|
|
1967
|
+
var idx = nextInTree.parent.children.indexOf(nextInTree);
|
|
1968
|
+
nextInTree.parent.children.splice(idx, 0, putIntoMap(mutation, nextInTree.parent));
|
|
1969
|
+
}
|
|
1970
|
+
else {
|
|
1971
|
+
var idx = queueNodeTrees.indexOf(nextInTree);
|
|
1972
|
+
queueNodeTrees.splice(idx, 0, putIntoMap(mutation, null));
|
|
1973
|
+
}
|
|
1974
|
+
continue;
|
|
1975
|
+
}
|
|
1976
|
+
if (parentId in queueNodeMap) {
|
|
1977
|
+
var parentInTree = queueNodeMap[parentId];
|
|
1978
|
+
parentInTree.children.push(putIntoMap(mutation, parentInTree));
|
|
1979
|
+
continue;
|
|
1980
|
+
}
|
|
1981
|
+
queueNodeTrees.push(putIntoMap(mutation, null));
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1985
|
+
finally {
|
|
1986
|
+
try {
|
|
1987
|
+
if (queue_1_1 && !queue_1_1.done && (_a = queue_1.return)) _a.call(queue_1);
|
|
1988
|
+
}
|
|
1989
|
+
finally { if (e_3) throw e_3.error; }
|
|
1990
|
+
}
|
|
1991
|
+
return queueNodeTrees;
|
|
1992
|
+
}
|
|
1993
|
+
function iterateResolveTree(tree, cb) {
|
|
1994
|
+
cb(tree.value);
|
|
1995
|
+
for (var i = tree.children.length - 1; i >= 0; i--) {
|
|
1996
|
+
iterateResolveTree(tree.children[i], cb);
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
function isIframeINode(node) {
|
|
2000
|
+
if ('__sn' in node) {
|
|
2001
|
+
return (node.__sn.type === NodeType.Element && node.__sn.tagName === 'iframe');
|
|
2002
|
+
}
|
|
2003
|
+
return false;
|
|
2004
|
+
}
|
|
2005
|
+
function getBaseDimension(node, rootIframe) {
|
|
2006
|
+
var _a, _b;
|
|
2007
|
+
var frameElement = (_b = (_a = node.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.frameElement;
|
|
2008
|
+
if (!frameElement || frameElement === rootIframe) {
|
|
2009
|
+
return {
|
|
2010
|
+
x: 0,
|
|
2011
|
+
y: 0,
|
|
2012
|
+
relativeScale: 1,
|
|
2013
|
+
absoluteScale: 1,
|
|
2014
|
+
};
|
|
2015
|
+
}
|
|
2016
|
+
var frameDimension = frameElement.getBoundingClientRect();
|
|
2017
|
+
var frameBaseDimension = getBaseDimension(frameElement, rootIframe);
|
|
2018
|
+
var relativeScale = frameDimension.height / frameElement.clientHeight;
|
|
2019
|
+
return {
|
|
2020
|
+
x: frameDimension.x * frameBaseDimension.relativeScale +
|
|
2021
|
+
frameBaseDimension.x,
|
|
2022
|
+
y: frameDimension.y * frameBaseDimension.relativeScale +
|
|
2023
|
+
frameBaseDimension.y,
|
|
2024
|
+
relativeScale: relativeScale,
|
|
2025
|
+
absoluteScale: frameBaseDimension.absoluteScale * relativeScale,
|
|
2026
|
+
};
|
|
2027
|
+
}
|
|
2028
|
+
function hasShadowRoot(n) {
|
|
2029
|
+
return Boolean(n === null || n === void 0 ? void 0 : n.shadowRoot);
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
var rules = function (blockClass) { return [
|
|
2033
|
+
".".concat(blockClass, " { background: currentColor }"),
|
|
2034
|
+
'noscript { display: none !important; }',
|
|
2035
|
+
".".concat(blockClass, " { background: currentColor; border-radius: 5px; }"),
|
|
2036
|
+
".".concat(blockClass, ":hover::after {content: 'Redacted'; color: white; background: black; text-align: center; width: 100%; display: block;}"),
|
|
2037
|
+
]; };
|
|
2038
|
+
|
|
2039
|
+
var StyleRuleType;
|
|
2040
|
+
(function (StyleRuleType) {
|
|
2041
|
+
StyleRuleType[StyleRuleType["Insert"] = 0] = "Insert";
|
|
2042
|
+
StyleRuleType[StyleRuleType["Remove"] = 1] = "Remove";
|
|
2043
|
+
StyleRuleType[StyleRuleType["Snapshot"] = 2] = "Snapshot";
|
|
2044
|
+
StyleRuleType[StyleRuleType["SetProperty"] = 3] = "SetProperty";
|
|
2045
|
+
StyleRuleType[StyleRuleType["RemoveProperty"] = 4] = "RemoveProperty";
|
|
2046
|
+
})(StyleRuleType || (StyleRuleType = {}));
|
|
2047
|
+
function getNestedRule(rules, position) {
|
|
2048
|
+
var rule = rules[position[0]];
|
|
2049
|
+
if (position.length === 1) {
|
|
2050
|
+
return rule;
|
|
2051
|
+
}
|
|
2052
|
+
else {
|
|
2053
|
+
return getNestedRule(rule.cssRules[position[1]]
|
|
2054
|
+
.cssRules, position.slice(2));
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
function getPositionsAndIndex(nestedIndex) {
|
|
2058
|
+
var positions = __spreadArray([], __read(nestedIndex), false);
|
|
2059
|
+
var index = positions.pop();
|
|
2060
|
+
return { positions: positions, index: index };
|
|
2061
|
+
}
|
|
2062
|
+
function applyVirtualStyleRulesToNode(storedRules, styleNode) {
|
|
2063
|
+
var sheet = styleNode.sheet;
|
|
2064
|
+
if (!sheet) {
|
|
2065
|
+
return;
|
|
2066
|
+
}
|
|
2067
|
+
storedRules.forEach(function (rule) {
|
|
2068
|
+
if (rule.type === StyleRuleType.Insert) {
|
|
2069
|
+
try {
|
|
2070
|
+
if (Array.isArray(rule.index)) {
|
|
2071
|
+
var _a = getPositionsAndIndex(rule.index), positions = _a.positions, index = _a.index;
|
|
2072
|
+
var nestedRule = getNestedRule(sheet.cssRules, positions);
|
|
2073
|
+
nestedRule.insertRule(rule.cssText, index);
|
|
2074
|
+
}
|
|
2075
|
+
else {
|
|
2076
|
+
sheet.insertRule(rule.cssText, rule.index);
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
catch (e) {
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
else if (rule.type === StyleRuleType.Remove) {
|
|
2083
|
+
try {
|
|
2084
|
+
if (Array.isArray(rule.index)) {
|
|
2085
|
+
var _b = getPositionsAndIndex(rule.index), positions = _b.positions, index = _b.index;
|
|
2086
|
+
var nestedRule = getNestedRule(sheet.cssRules, positions);
|
|
2087
|
+
nestedRule.deleteRule(index || 0);
|
|
2088
|
+
}
|
|
2089
|
+
else {
|
|
2090
|
+
sheet.deleteRule(rule.index);
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
catch (e) {
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
else if (rule.type === StyleRuleType.Snapshot) {
|
|
2097
|
+
restoreSnapshotOfStyleRulesToNode(rule.cssTexts, styleNode);
|
|
2098
|
+
}
|
|
2099
|
+
else if (rule.type === StyleRuleType.SetProperty) {
|
|
2100
|
+
var nativeRule = getNestedRule(sheet.cssRules, rule.index);
|
|
2101
|
+
nativeRule.style.setProperty(rule.property, rule.value, rule.priority);
|
|
2102
|
+
}
|
|
2103
|
+
else if (rule.type === StyleRuleType.RemoveProperty) {
|
|
2104
|
+
var nativeRule = getNestedRule(sheet.cssRules, rule.index);
|
|
2105
|
+
nativeRule.style.removeProperty(rule.property);
|
|
2106
|
+
}
|
|
2107
|
+
});
|
|
2108
|
+
}
|
|
2109
|
+
function restoreSnapshotOfStyleRulesToNode(cssTexts, styleNode) {
|
|
2110
|
+
var _a;
|
|
2111
|
+
try {
|
|
2112
|
+
var existingRules = Array.from(((_a = styleNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) || []).map(function (rule) { return rule.cssText; });
|
|
2113
|
+
var existingRulesReversed = Object.entries(existingRules).reverse();
|
|
2114
|
+
var lastMatch_1 = existingRules.length;
|
|
2115
|
+
existingRulesReversed.forEach(function (_a) {
|
|
2116
|
+
var _b;
|
|
2117
|
+
var _c = __read(_a, 2), index = _c[0], rule = _c[1];
|
|
2118
|
+
var indexOf = cssTexts.indexOf(rule);
|
|
2119
|
+
if (indexOf === -1 || indexOf > lastMatch_1) {
|
|
2120
|
+
try {
|
|
2121
|
+
(_b = styleNode.sheet) === null || _b === void 0 ? void 0 : _b.deleteRule(Number(index));
|
|
2122
|
+
}
|
|
2123
|
+
catch (e) {
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
lastMatch_1 = indexOf;
|
|
2127
|
+
});
|
|
2128
|
+
cssTexts.forEach(function (cssText, index) {
|
|
2129
|
+
var _a, _b, _c;
|
|
2130
|
+
try {
|
|
2131
|
+
if (((_b = (_a = styleNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules[index]) === null || _b === void 0 ? void 0 : _b.cssText) !== cssText) {
|
|
2132
|
+
(_c = styleNode.sheet) === null || _c === void 0 ? void 0 : _c.insertRule(cssText, index);
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
catch (e) {
|
|
2136
|
+
}
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
catch (e) {
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
function storeCSSRules(parentElement, virtualStyleRulesMap) {
|
|
2143
|
+
var _a;
|
|
2144
|
+
try {
|
|
2145
|
+
var cssTexts = Array.from(((_a = parentElement.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) || []).map(function (rule) { return rule.cssText; });
|
|
2146
|
+
virtualStyleRulesMap.set(parentElement, [
|
|
2147
|
+
{
|
|
2148
|
+
type: StyleRuleType.Snapshot,
|
|
2149
|
+
cssTexts: cssTexts,
|
|
2150
|
+
},
|
|
2151
|
+
]);
|
|
2152
|
+
}
|
|
2153
|
+
catch (e) {
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
/*
|
|
2158
|
+
* base64-arraybuffer 1.0.1 <https://github.com/niklasvh/base64-arraybuffer>
|
|
2159
|
+
* Copyright (c) 2021 Niklas von Hertzen <https://hertzen.com>
|
|
2160
|
+
* Released under MIT License
|
|
2161
|
+
*/
|
|
2162
|
+
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
2163
|
+
// Use a lookup table to find the index.
|
|
2164
|
+
var lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
|
|
2165
|
+
for (var i = 0; i < chars.length; i++) {
|
|
2166
|
+
lookup[chars.charCodeAt(i)] = i;
|
|
2167
|
+
}
|
|
2168
|
+
var decode = function (base64) {
|
|
2169
|
+
var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;
|
|
2170
|
+
if (base64[base64.length - 1] === '=') {
|
|
2171
|
+
bufferLength--;
|
|
2172
|
+
if (base64[base64.length - 2] === '=') {
|
|
2173
|
+
bufferLength--;
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);
|
|
2177
|
+
for (i = 0; i < len; i += 4) {
|
|
2178
|
+
encoded1 = lookup[base64.charCodeAt(i)];
|
|
2179
|
+
encoded2 = lookup[base64.charCodeAt(i + 1)];
|
|
2180
|
+
encoded3 = lookup[base64.charCodeAt(i + 2)];
|
|
2181
|
+
encoded4 = lookup[base64.charCodeAt(i + 3)];
|
|
2182
|
+
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
|
|
2183
|
+
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
|
|
2184
|
+
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
|
|
2185
|
+
}
|
|
2186
|
+
return arraybuffer;
|
|
2187
|
+
};
|
|
2188
|
+
|
|
2189
|
+
var webGLVarMap = new Map();
|
|
2190
|
+
function variableListFor(ctx, ctor) {
|
|
2191
|
+
var contextMap = webGLVarMap.get(ctx);
|
|
2192
|
+
if (!contextMap) {
|
|
2193
|
+
contextMap = new Map();
|
|
2194
|
+
webGLVarMap.set(ctx, contextMap);
|
|
2195
|
+
}
|
|
2196
|
+
if (!contextMap.has(ctor)) {
|
|
2197
|
+
contextMap.set(ctor, []);
|
|
2198
|
+
}
|
|
2199
|
+
return contextMap.get(ctor);
|
|
2200
|
+
}
|
|
2201
|
+
function getContext(target, type) {
|
|
2202
|
+
try {
|
|
2203
|
+
if (type === CanvasContext.WebGL) {
|
|
2204
|
+
return (target.getContext('webgl') || target.getContext('experimental-webgl'));
|
|
2205
|
+
}
|
|
2206
|
+
return target.getContext('webgl2');
|
|
2207
|
+
}
|
|
2208
|
+
catch (e) {
|
|
2209
|
+
return null;
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
var WebGLVariableConstructorsNames = [
|
|
2213
|
+
'WebGLActiveInfo',
|
|
2214
|
+
'WebGLBuffer',
|
|
2215
|
+
'WebGLFramebuffer',
|
|
2216
|
+
'WebGLProgram',
|
|
2217
|
+
'WebGLRenderbuffer',
|
|
2218
|
+
'WebGLShader',
|
|
2219
|
+
'WebGLShaderPrecisionFormat',
|
|
2220
|
+
'WebGLTexture',
|
|
2221
|
+
'WebGLUniformLocation',
|
|
2222
|
+
'WebGLVertexArrayObject',
|
|
2223
|
+
];
|
|
2224
|
+
function saveToWebGLVarMap(ctx, result) {
|
|
2225
|
+
if (!(result === null || result === void 0 ? void 0 : result.constructor))
|
|
2226
|
+
return;
|
|
2227
|
+
var name = result.constructor.name;
|
|
2228
|
+
if (!WebGLVariableConstructorsNames.includes(name))
|
|
2229
|
+
return;
|
|
2230
|
+
var variables = variableListFor(ctx, name);
|
|
2231
|
+
if (!variables.includes(result))
|
|
2232
|
+
variables.push(result);
|
|
2233
|
+
}
|
|
2234
|
+
function deserializeArg(imageMap, ctx) {
|
|
2235
|
+
return function (arg) {
|
|
2236
|
+
if (arg && typeof arg === 'object' && 'rr_type' in arg) {
|
|
2237
|
+
if ('index' in arg) {
|
|
2238
|
+
var name_1 = arg.rr_type, index = arg.index;
|
|
2239
|
+
return variableListFor(ctx, name_1)[index];
|
|
2240
|
+
}
|
|
2241
|
+
else if ('args' in arg) {
|
|
2242
|
+
var name_2 = arg.rr_type, args = arg.args;
|
|
2243
|
+
var ctor = window[name_2];
|
|
2244
|
+
return new (ctor.bind.apply(ctor, __spreadArray([void 0], __read(args.map(deserializeArg(imageMap, ctx))), false)))();
|
|
2245
|
+
}
|
|
2246
|
+
else if ('base64' in arg) {
|
|
2247
|
+
return decode(arg.base64);
|
|
2248
|
+
}
|
|
2249
|
+
else if ('src' in arg) {
|
|
2250
|
+
var image = imageMap.get(arg.src);
|
|
2251
|
+
if (image) {
|
|
2252
|
+
return image;
|
|
2253
|
+
}
|
|
2254
|
+
else {
|
|
2255
|
+
var image_1 = new Image();
|
|
2256
|
+
image_1.src = arg.src;
|
|
2257
|
+
imageMap.set(arg.src, image_1);
|
|
2258
|
+
return image_1;
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
else if (Array.isArray(arg)) {
|
|
2263
|
+
return arg.map(deserializeArg(imageMap, ctx));
|
|
2264
|
+
}
|
|
2265
|
+
return arg;
|
|
2266
|
+
};
|
|
2267
|
+
}
|
|
2268
|
+
function webglMutation(_a) {
|
|
2269
|
+
var mutation = _a.mutation, target = _a.target, type = _a.type, imageMap = _a.imageMap, errorHandler = _a.errorHandler;
|
|
2270
|
+
try {
|
|
2271
|
+
var ctx = getContext(target, type);
|
|
2272
|
+
if (!ctx)
|
|
2273
|
+
return;
|
|
2274
|
+
if (mutation.setter) {
|
|
2275
|
+
ctx[mutation.property] = mutation.args[0];
|
|
2276
|
+
return;
|
|
2277
|
+
}
|
|
2278
|
+
var original = ctx[mutation.property];
|
|
2279
|
+
var args = mutation.args.map(deserializeArg(imageMap, ctx));
|
|
2280
|
+
var result = original.apply(ctx, args);
|
|
2281
|
+
saveToWebGLVarMap(ctx, result);
|
|
2282
|
+
var debugMode = false;
|
|
2283
|
+
if (debugMode) {
|
|
2284
|
+
if (mutation.property === 'compileShader') {
|
|
2285
|
+
if (!ctx.getShaderParameter(args[0], ctx.COMPILE_STATUS))
|
|
2286
|
+
console.warn('something went wrong in replay', ctx.getShaderInfoLog(args[0]));
|
|
2287
|
+
}
|
|
2288
|
+
else if (mutation.property === 'linkProgram') {
|
|
2289
|
+
ctx.validateProgram(args[0]);
|
|
2290
|
+
if (!ctx.getProgramParameter(args[0], ctx.LINK_STATUS))
|
|
2291
|
+
console.warn('something went wrong in replay', ctx.getProgramInfoLog(args[0]));
|
|
2292
|
+
}
|
|
2293
|
+
var webglError = ctx.getError();
|
|
2294
|
+
if (webglError !== ctx.NO_ERROR) {
|
|
2295
|
+
console.warn.apply(console, __spreadArray(['WEBGL ERROR',
|
|
2296
|
+
webglError,
|
|
2297
|
+
'on command:',
|
|
2298
|
+
mutation.property], __read(args), false));
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
catch (error) {
|
|
2303
|
+
errorHandler(mutation, error);
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
function canvasMutation$1(_a) {
|
|
2308
|
+
var event = _a.event, mutation = _a.mutation, target = _a.target, imageMap = _a.imageMap, errorHandler = _a.errorHandler;
|
|
2309
|
+
try {
|
|
2310
|
+
var ctx = target.getContext('2d');
|
|
2311
|
+
if (mutation.setter) {
|
|
2312
|
+
ctx[mutation.property] = mutation.args[0];
|
|
2313
|
+
return;
|
|
2314
|
+
}
|
|
2315
|
+
var original = ctx[mutation.property];
|
|
2316
|
+
if (mutation.property === 'drawImage' &&
|
|
2317
|
+
typeof mutation.args[0] === 'string') {
|
|
2318
|
+
var image = imageMap.get(event);
|
|
2319
|
+
mutation.args[0] = image;
|
|
2320
|
+
original.apply(ctx, mutation.args);
|
|
2321
|
+
}
|
|
2322
|
+
else {
|
|
2323
|
+
original.apply(ctx, mutation.args);
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
catch (error) {
|
|
2327
|
+
errorHandler(mutation, error);
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
|
|
2331
|
+
function canvasMutation(_a) {
|
|
2332
|
+
var event = _a.event, mutation = _a.mutation, target = _a.target, imageMap = _a.imageMap, errorHandler = _a.errorHandler;
|
|
2333
|
+
try {
|
|
2334
|
+
var mutations = 'commands' in mutation ? mutation.commands : [mutation];
|
|
2335
|
+
if ([CanvasContext.WebGL, CanvasContext.WebGL2].includes(mutation.type)) {
|
|
2336
|
+
return mutations.forEach(function (command) {
|
|
2337
|
+
webglMutation({
|
|
2338
|
+
mutation: command,
|
|
2339
|
+
type: mutation.type,
|
|
2340
|
+
target: target,
|
|
2341
|
+
imageMap: imageMap,
|
|
2342
|
+
errorHandler: errorHandler,
|
|
2343
|
+
});
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
return mutations.forEach(function (command) {
|
|
2347
|
+
canvasMutation$1({
|
|
2348
|
+
event: event,
|
|
2349
|
+
mutation: command,
|
|
2350
|
+
target: target,
|
|
2351
|
+
imageMap: imageMap,
|
|
2352
|
+
errorHandler: errorHandler,
|
|
2353
|
+
});
|
|
2354
|
+
});
|
|
2355
|
+
}
|
|
2356
|
+
catch (error) {
|
|
2357
|
+
errorHandler(mutation, error);
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2361
|
+
var SKIP_TIME_THRESHOLD = 10 * 1000;
|
|
2362
|
+
var SKIP_TIME_INTERVAL = 2 * 1000;
|
|
2363
|
+
var SKIP_TIME_MIN = 1 * 1000;
|
|
2364
|
+
var SKIP_DURATION_LIMIT = 60 * 60 * 1000;
|
|
2365
|
+
var mitt = mitt$1 || mittProxy;
|
|
2366
|
+
var REPLAY_CONSOLE_PREFIX = '[replayer]';
|
|
2367
|
+
var defaultMouseTailConfig = {
|
|
2368
|
+
duration: 500,
|
|
2369
|
+
lineCap: 'round',
|
|
2370
|
+
lineWidth: 3,
|
|
2371
|
+
strokeStyle: 'red',
|
|
2372
|
+
};
|
|
2373
|
+
function indicatesTouchDevice(e) {
|
|
2374
|
+
return (e.type == EventType.IncrementalSnapshot &&
|
|
2375
|
+
(e.data.source == IncrementalSource.TouchMove ||
|
|
2376
|
+
(e.data.source == IncrementalSource.MouseInteraction &&
|
|
2377
|
+
e.data.type == MouseInteractions.TouchStart)));
|
|
2378
|
+
}
|
|
2379
|
+
var Replayer = (function () {
|
|
2380
|
+
function Replayer(events, config) {
|
|
2381
|
+
var _this = this;
|
|
2382
|
+
this.mouseTail = null;
|
|
2383
|
+
this.tailPositions = [];
|
|
2384
|
+
this.emitter = mitt();
|
|
2385
|
+
this.activityIntervals = [];
|
|
2386
|
+
this.legacy_missingNodeRetryMap = {};
|
|
2387
|
+
this.cache = createCache();
|
|
2388
|
+
this.imageMap = new Map();
|
|
2389
|
+
this.mirror = createMirror();
|
|
2390
|
+
this.firstFullSnapshot = null;
|
|
2391
|
+
this.newDocumentQueue = [];
|
|
2392
|
+
this.mousePos = null;
|
|
2393
|
+
this.touchActive = null;
|
|
2394
|
+
if (!(config === null || config === void 0 ? void 0 : config.liveMode) && events.length < 2) {
|
|
2395
|
+
throw new Error('Replayer need at least 2 events.');
|
|
2396
|
+
}
|
|
2397
|
+
var defaultConfig = {
|
|
2398
|
+
speed: 1,
|
|
2399
|
+
maxSpeed: 360,
|
|
2400
|
+
root: document.body,
|
|
2401
|
+
loadTimeout: 0,
|
|
2402
|
+
skipInactive: false,
|
|
2403
|
+
showWarning: true,
|
|
2404
|
+
showDebug: false,
|
|
2405
|
+
blockClass: 'highlight-block',
|
|
2406
|
+
liveMode: false,
|
|
2407
|
+
insertStyleRules: [],
|
|
2408
|
+
triggerFocus: true,
|
|
2409
|
+
UNSAFE_replayCanvas: false,
|
|
2410
|
+
pauseAnimation: true,
|
|
2411
|
+
mouseTail: defaultMouseTailConfig,
|
|
2412
|
+
inactiveThreshold: 0.02,
|
|
2413
|
+
inactiveSkipTime: SKIP_TIME_INTERVAL,
|
|
2414
|
+
};
|
|
2415
|
+
this.config = Object.assign({}, defaultConfig, config);
|
|
2416
|
+
this.handleResize = this.handleResize.bind(this);
|
|
2417
|
+
this.getCastFn = this.getCastFn.bind(this);
|
|
2418
|
+
this.applyEventsSynchronously = this.applyEventsSynchronously.bind(this);
|
|
2419
|
+
this.emitter.on(ReplayerEvents.Resize, this.handleResize);
|
|
2420
|
+
this.setupDom();
|
|
2421
|
+
this.treeIndex = new TreeIndex();
|
|
2422
|
+
this.fragmentParentMap = new Map();
|
|
2423
|
+
this.elementStateMap = new Map();
|
|
2424
|
+
this.virtualStyleRulesMap = new Map();
|
|
2425
|
+
this.emitter.on(ReplayerEvents.Flush, function () {
|
|
2426
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
2427
|
+
var _e = _this.treeIndex.flush(), scrollMap = _e.scrollMap, inputMap = _e.inputMap, mutationData = _e.mutationData;
|
|
2428
|
+
_this.fragmentParentMap.forEach(function (parent, frag) {
|
|
2429
|
+
return _this.restoreRealParent(frag, parent);
|
|
2430
|
+
});
|
|
2431
|
+
try {
|
|
2432
|
+
for (var _f = __values(mutationData.texts), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
2433
|
+
var d = _g.value;
|
|
2434
|
+
_this.applyText(d, mutationData);
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2438
|
+
finally {
|
|
2439
|
+
try {
|
|
2440
|
+
if (_g && !_g.done && (_a = _f.return)) _a.call(_f);
|
|
2441
|
+
}
|
|
2442
|
+
finally { if (e_1) throw e_1.error; }
|
|
2443
|
+
}
|
|
2444
|
+
try {
|
|
2445
|
+
for (var _h = __values(_this.virtualStyleRulesMap.keys()), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
2446
|
+
var node = _j.value;
|
|
2447
|
+
_this.restoreNodeSheet(node);
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2451
|
+
finally {
|
|
2452
|
+
try {
|
|
2453
|
+
if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
|
|
2454
|
+
}
|
|
2455
|
+
finally { if (e_2) throw e_2.error; }
|
|
2456
|
+
}
|
|
2457
|
+
_this.fragmentParentMap.clear();
|
|
2458
|
+
_this.elementStateMap.clear();
|
|
2459
|
+
_this.virtualStyleRulesMap.clear();
|
|
2460
|
+
try {
|
|
2461
|
+
for (var _k = __values(scrollMap.values()), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
2462
|
+
var d = _l.value;
|
|
2463
|
+
_this.applyScroll(d, true);
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
2467
|
+
finally {
|
|
2468
|
+
try {
|
|
2469
|
+
if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
|
|
2470
|
+
}
|
|
2471
|
+
finally { if (e_3) throw e_3.error; }
|
|
2472
|
+
}
|
|
2473
|
+
try {
|
|
2474
|
+
for (var _m = __values(inputMap.values()), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
2475
|
+
var d = _o.value;
|
|
2476
|
+
_this.applyInput(d);
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
2480
|
+
finally {
|
|
2481
|
+
try {
|
|
2482
|
+
if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
|
|
2483
|
+
}
|
|
2484
|
+
finally { if (e_4) throw e_4.error; }
|
|
2485
|
+
}
|
|
2486
|
+
});
|
|
2487
|
+
this.emitter.on(ReplayerEvents.PlayBack, function () {
|
|
2488
|
+
_this.firstFullSnapshot = null;
|
|
2489
|
+
_this.mirror.reset();
|
|
2490
|
+
});
|
|
2491
|
+
var timer = new Timer([], (config === null || config === void 0 ? void 0 : config.speed) || defaultConfig.speed);
|
|
2492
|
+
this.service = createPlayerService({
|
|
2493
|
+
events: events
|
|
2494
|
+
.map(function (e) {
|
|
2495
|
+
if (config && config.unpackFn) {
|
|
2496
|
+
return config.unpackFn(e);
|
|
2497
|
+
}
|
|
2498
|
+
return e;
|
|
2499
|
+
})
|
|
2500
|
+
.sort(function (a1, a2) { return a1.timestamp - a2.timestamp; }),
|
|
2501
|
+
timer: timer,
|
|
2502
|
+
timeOffset: 0,
|
|
2503
|
+
baselineTime: 0,
|
|
2504
|
+
lastPlayedEvent: null,
|
|
2505
|
+
}, {
|
|
2506
|
+
getCastFn: this.getCastFn,
|
|
2507
|
+
applyEventsSynchronously: this.applyEventsSynchronously,
|
|
2508
|
+
emitter: this.emitter,
|
|
2509
|
+
});
|
|
2510
|
+
this.service.start();
|
|
2511
|
+
this.service.subscribe(function (state) {
|
|
2512
|
+
_this.emitter.emit(ReplayerEvents.StateChange, {
|
|
2513
|
+
player: state,
|
|
2514
|
+
});
|
|
2515
|
+
});
|
|
2516
|
+
this.speedService = createSpeedService({
|
|
2517
|
+
normalSpeed: -1,
|
|
2518
|
+
timer: timer,
|
|
2519
|
+
});
|
|
2520
|
+
this.speedService.start();
|
|
2521
|
+
this.speedService.subscribe(function (state) {
|
|
2522
|
+
_this.emitter.emit(ReplayerEvents.StateChange, {
|
|
2523
|
+
speed: state,
|
|
2524
|
+
});
|
|
2525
|
+
});
|
|
2526
|
+
var firstMeta = this.service.state.context.events.find(function (e) { return e.type === EventType.Meta; });
|
|
2527
|
+
var firstFullsnapshot = this.service.state.context.events.find(function (e) { return e.type === EventType.FullSnapshot; });
|
|
2528
|
+
if (firstMeta) {
|
|
2529
|
+
var _a = firstMeta.data, width_1 = _a.width, height_1 = _a.height;
|
|
2530
|
+
setTimeout(function () {
|
|
2531
|
+
_this.emitter.emit(ReplayerEvents.Resize, {
|
|
2532
|
+
width: width_1,
|
|
2533
|
+
height: height_1,
|
|
2534
|
+
});
|
|
2535
|
+
}, 0);
|
|
2536
|
+
}
|
|
2537
|
+
if (firstFullsnapshot) {
|
|
2538
|
+
setTimeout(function () {
|
|
2539
|
+
if (_this.firstFullSnapshot) {
|
|
2540
|
+
return;
|
|
2541
|
+
}
|
|
2542
|
+
_this.firstFullSnapshot = firstFullsnapshot;
|
|
2543
|
+
_this.rebuildFullSnapshot(firstFullsnapshot);
|
|
2544
|
+
_this.iframe.contentWindow.scrollTo(firstFullsnapshot.data.initialOffset);
|
|
2545
|
+
}, 1);
|
|
2546
|
+
}
|
|
2547
|
+
if (this.service.state.context.events.find(indicatesTouchDevice)) {
|
|
2548
|
+
this.mouse.classList.add('touch-device');
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
Object.defineProperty(Replayer.prototype, "timer", {
|
|
2552
|
+
get: function () {
|
|
2553
|
+
return this.service.state.context.timer;
|
|
2554
|
+
},
|
|
2555
|
+
enumerable: false,
|
|
2556
|
+
configurable: true
|
|
2557
|
+
});
|
|
2558
|
+
Replayer.prototype.on = function (event, handler) {
|
|
2559
|
+
this.emitter.on(event, handler);
|
|
2560
|
+
return this;
|
|
2561
|
+
};
|
|
2562
|
+
Replayer.prototype.off = function (event, handler) {
|
|
2563
|
+
this.emitter.off(event, handler);
|
|
2564
|
+
return this;
|
|
2565
|
+
};
|
|
2566
|
+
Replayer.prototype.setConfig = function (config) {
|
|
2567
|
+
var _this = this;
|
|
2568
|
+
Object.keys(config).forEach(function (key) {
|
|
2569
|
+
_this.config[key] = config[key];
|
|
2570
|
+
});
|
|
2571
|
+
if (!this.config.skipInactive) {
|
|
2572
|
+
this.backToNormal();
|
|
2573
|
+
}
|
|
2574
|
+
if (typeof config.speed !== 'undefined') {
|
|
2575
|
+
this.speedService.send({
|
|
2576
|
+
type: 'SET_SPEED',
|
|
2577
|
+
payload: {
|
|
2578
|
+
speed: config.speed,
|
|
2579
|
+
},
|
|
2580
|
+
});
|
|
2581
|
+
}
|
|
2582
|
+
if (typeof config.mouseTail !== 'undefined') {
|
|
2583
|
+
if (config.mouseTail === false) {
|
|
2584
|
+
if (this.mouseTail) {
|
|
2585
|
+
this.mouseTail.style.display = 'none';
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
else {
|
|
2589
|
+
if (!this.mouseTail) {
|
|
2590
|
+
this.mouseTail = document.createElement('canvas');
|
|
2591
|
+
this.mouseTail.width = Number.parseFloat(this.iframe.width);
|
|
2592
|
+
this.mouseTail.height = Number.parseFloat(this.iframe.height);
|
|
2593
|
+
this.mouseTail.classList.add('replayer-mouse-tail');
|
|
2594
|
+
this.wrapper.insertBefore(this.mouseTail, this.iframe);
|
|
2595
|
+
}
|
|
2596
|
+
this.mouseTail.style.display = 'inherit';
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
};
|
|
2600
|
+
Replayer.prototype.getActivityIntervals = function () {
|
|
2601
|
+
var _this = this;
|
|
2602
|
+
if (this.activityIntervals.length == 0) {
|
|
2603
|
+
var allIntervals = [];
|
|
2604
|
+
var metadata = this.getMetaData();
|
|
2605
|
+
var userInteractionEvents = __spreadArray(__spreadArray([
|
|
2606
|
+
{ timestamp: metadata.startTime }
|
|
2607
|
+
], __read(this.service.state.context.events.filter(function (ev) {
|
|
2608
|
+
return _this.isUserInteraction(ev);
|
|
2609
|
+
})), false), [
|
|
2610
|
+
{ timestamp: metadata.endTime },
|
|
2611
|
+
], false);
|
|
2612
|
+
for (var i = 1; i < userInteractionEvents.length; i++) {
|
|
2613
|
+
var currentInterval_1 = userInteractionEvents[i - 1];
|
|
2614
|
+
var _event = userInteractionEvents[i];
|
|
2615
|
+
if (_event.timestamp - currentInterval_1.timestamp >
|
|
2616
|
+
SKIP_TIME_THRESHOLD) {
|
|
2617
|
+
allIntervals.push({
|
|
2618
|
+
startTime: currentInterval_1.timestamp,
|
|
2619
|
+
endTime: _event.timestamp,
|
|
2620
|
+
duration: _event.timestamp - currentInterval_1.timestamp,
|
|
2621
|
+
active: false,
|
|
2622
|
+
});
|
|
2623
|
+
}
|
|
2624
|
+
else {
|
|
2625
|
+
allIntervals.push({
|
|
2626
|
+
startTime: currentInterval_1.timestamp,
|
|
2627
|
+
endTime: _event.timestamp,
|
|
2628
|
+
duration: _event.timestamp - currentInterval_1.timestamp,
|
|
2629
|
+
active: true,
|
|
2630
|
+
});
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
var mergedIntervals = [];
|
|
2634
|
+
var currentInterval = allIntervals[0];
|
|
2635
|
+
for (var i = 1; i < allIntervals.length; i++) {
|
|
2636
|
+
if (allIntervals[i].active != allIntervals[i - 1].active) {
|
|
2637
|
+
mergedIntervals.push({
|
|
2638
|
+
startTime: currentInterval.startTime,
|
|
2639
|
+
endTime: allIntervals[i - 1].endTime,
|
|
2640
|
+
duration: allIntervals[i - 1].endTime - currentInterval.startTime,
|
|
2641
|
+
active: allIntervals[i - 1].active,
|
|
2642
|
+
});
|
|
2643
|
+
currentInterval = allIntervals[i];
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
if (currentInterval && allIntervals.length > 0) {
|
|
2647
|
+
mergedIntervals.push({
|
|
2648
|
+
startTime: currentInterval.startTime,
|
|
2649
|
+
endTime: allIntervals[allIntervals.length - 1].endTime,
|
|
2650
|
+
duration: allIntervals[allIntervals.length - 1].endTime -
|
|
2651
|
+
currentInterval.startTime,
|
|
2652
|
+
active: allIntervals[allIntervals.length - 1].active,
|
|
2653
|
+
});
|
|
2654
|
+
}
|
|
2655
|
+
currentInterval = mergedIntervals[0];
|
|
2656
|
+
for (var i = 1; i < mergedIntervals.length; i++) {
|
|
2657
|
+
if ((!mergedIntervals[i].active &&
|
|
2658
|
+
mergedIntervals[i].duration >
|
|
2659
|
+
this.config.inactiveThreshold * metadata.totalTime) ||
|
|
2660
|
+
(!mergedIntervals[i - 1].active &&
|
|
2661
|
+
mergedIntervals[i - 1].duration >
|
|
2662
|
+
this.config.inactiveThreshold * metadata.totalTime)) {
|
|
2663
|
+
this.activityIntervals.push({
|
|
2664
|
+
startTime: currentInterval.startTime,
|
|
2665
|
+
endTime: mergedIntervals[i - 1].endTime,
|
|
2666
|
+
duration: mergedIntervals[i - 1].endTime - currentInterval.startTime,
|
|
2667
|
+
active: mergedIntervals[i - 1].active,
|
|
2668
|
+
});
|
|
2669
|
+
currentInterval = mergedIntervals[i];
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
if (currentInterval && mergedIntervals.length > 0) {
|
|
2673
|
+
this.activityIntervals.push({
|
|
2674
|
+
startTime: currentInterval.startTime,
|
|
2675
|
+
endTime: mergedIntervals[mergedIntervals.length - 1].endTime,
|
|
2676
|
+
duration: mergedIntervals[mergedIntervals.length - 1].endTime -
|
|
2677
|
+
currentInterval.startTime,
|
|
2678
|
+
active: mergedIntervals[mergedIntervals.length - 1].active,
|
|
2679
|
+
});
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
return this.activityIntervals;
|
|
2683
|
+
};
|
|
2684
|
+
Replayer.prototype.getMetaData = function () {
|
|
2685
|
+
var firstEvent = this.service.state.context.events[0];
|
|
2686
|
+
var lastEvent = this.service.state.context.events[this.service.state.context.events.length - 1];
|
|
2687
|
+
return {
|
|
2688
|
+
startTime: firstEvent.timestamp,
|
|
2689
|
+
endTime: lastEvent.timestamp,
|
|
2690
|
+
totalTime: lastEvent.timestamp - firstEvent.timestamp,
|
|
2691
|
+
};
|
|
2692
|
+
};
|
|
2693
|
+
Replayer.prototype.getCurrentTime = function () {
|
|
2694
|
+
return this.timer.timeOffset + this.getTimeOffset();
|
|
2695
|
+
};
|
|
2696
|
+
Replayer.prototype.getTimeOffset = function () {
|
|
2697
|
+
var _a = this.service.state.context, baselineTime = _a.baselineTime, events = _a.events;
|
|
2698
|
+
return baselineTime - events[0].timestamp;
|
|
2699
|
+
};
|
|
2700
|
+
Replayer.prototype.getMirror = function () {
|
|
2701
|
+
return this.mirror;
|
|
2702
|
+
};
|
|
2703
|
+
Replayer.prototype.play = function (timeOffset) {
|
|
2704
|
+
var _a;
|
|
2705
|
+
if (timeOffset === void 0) { timeOffset = 0; }
|
|
2706
|
+
if (this.service.state.matches('paused')) {
|
|
2707
|
+
this.service.send({ type: 'PLAY', payload: { timeOffset: timeOffset } });
|
|
2708
|
+
}
|
|
2709
|
+
else {
|
|
2710
|
+
this.service.send({ type: 'PAUSE' });
|
|
2711
|
+
this.service.send({ type: 'PLAY', payload: { timeOffset: timeOffset } });
|
|
2712
|
+
}
|
|
2713
|
+
(_a = this.iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.getElementsByTagName('html')[0].classList.remove('rrweb-paused');
|
|
2714
|
+
this.emitter.emit(ReplayerEvents.Start);
|
|
2715
|
+
this.handleInactivity(this.getMetaData().startTime + timeOffset, true);
|
|
2716
|
+
};
|
|
2717
|
+
Replayer.prototype.pause = function (timeOffset) {
|
|
2718
|
+
var _a;
|
|
2719
|
+
if (timeOffset === undefined && this.service.state.matches('playing')) {
|
|
2720
|
+
this.service.send({ type: 'PAUSE' });
|
|
2721
|
+
}
|
|
2722
|
+
if (typeof timeOffset === 'number') {
|
|
2723
|
+
this.play(timeOffset);
|
|
2724
|
+
this.service.send({ type: 'PAUSE' });
|
|
2725
|
+
}
|
|
2726
|
+
(_a = this.iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.getElementsByTagName('html')[0].classList.add('rrweb-paused');
|
|
2727
|
+
this.emitter.emit(ReplayerEvents.Pause);
|
|
2728
|
+
};
|
|
2729
|
+
Replayer.prototype.resume = function (timeOffset) {
|
|
2730
|
+
if (timeOffset === void 0) { timeOffset = 0; }
|
|
2731
|
+
console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface.");
|
|
2732
|
+
this.play(timeOffset);
|
|
2733
|
+
this.emitter.emit(ReplayerEvents.Resume);
|
|
2734
|
+
};
|
|
2735
|
+
Replayer.prototype.startLive = function (baselineTime) {
|
|
2736
|
+
this.service.send({ type: 'TO_LIVE', payload: { baselineTime: baselineTime } });
|
|
2737
|
+
};
|
|
2738
|
+
Replayer.prototype.addEvent = function (rawEvent) {
|
|
2739
|
+
var _this = this;
|
|
2740
|
+
var event = this.config.unpackFn
|
|
2741
|
+
? this.config.unpackFn(rawEvent)
|
|
2742
|
+
: rawEvent;
|
|
2743
|
+
if (indicatesTouchDevice(event)) {
|
|
2744
|
+
this.mouse.classList.add('touch-device');
|
|
2745
|
+
}
|
|
2746
|
+
Promise.resolve().then(function () {
|
|
2747
|
+
return _this.service.send({ type: 'ADD_EVENT', payload: { event: event } });
|
|
2748
|
+
});
|
|
2749
|
+
};
|
|
2750
|
+
Replayer.prototype.replaceEvents = function (events) {
|
|
2751
|
+
var e_5, _a;
|
|
2752
|
+
try {
|
|
2753
|
+
for (var events_1 = __values(events), events_1_1 = events_1.next(); !events_1_1.done; events_1_1 = events_1.next()) {
|
|
2754
|
+
var event_1 = events_1_1.value;
|
|
2755
|
+
if (indicatesTouchDevice(event_1)) {
|
|
2756
|
+
this.mouse.classList.add('touch-device');
|
|
2757
|
+
break;
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
2762
|
+
finally {
|
|
2763
|
+
try {
|
|
2764
|
+
if (events_1_1 && !events_1_1.done && (_a = events_1.return)) _a.call(events_1);
|
|
2765
|
+
}
|
|
2766
|
+
finally { if (e_5) throw e_5.error; }
|
|
2767
|
+
}
|
|
2768
|
+
this.service.send({ type: 'REPLACE_EVENTS', payload: { events: events } });
|
|
2769
|
+
};
|
|
2770
|
+
Replayer.prototype.enableInteract = function () {
|
|
2771
|
+
this.iframe.setAttribute('scrolling', 'auto');
|
|
2772
|
+
this.iframe.style.pointerEvents = 'auto';
|
|
2773
|
+
};
|
|
2774
|
+
Replayer.prototype.disableInteract = function () {
|
|
2775
|
+
this.iframe.setAttribute('scrolling', 'no');
|
|
2776
|
+
this.iframe.style.pointerEvents = 'none';
|
|
2777
|
+
};
|
|
2778
|
+
Replayer.prototype.resetCache = function () {
|
|
2779
|
+
this.cache = createCache();
|
|
2780
|
+
};
|
|
2781
|
+
Replayer.prototype.setupDom = function () {
|
|
2782
|
+
this.wrapper = document.createElement('div');
|
|
2783
|
+
this.wrapper.classList.add('replayer-wrapper');
|
|
2784
|
+
this.config.root.appendChild(this.wrapper);
|
|
2785
|
+
this.mouse = document.createElement('div');
|
|
2786
|
+
this.mouse.classList.add('replayer-mouse');
|
|
2787
|
+
this.wrapper.appendChild(this.mouse);
|
|
2788
|
+
if (this.config.mouseTail !== false) {
|
|
2789
|
+
this.mouseTail = document.createElement('canvas');
|
|
2790
|
+
this.mouseTail.classList.add('replayer-mouse-tail');
|
|
2791
|
+
this.mouseTail.style.display = 'inherit';
|
|
2792
|
+
this.wrapper.appendChild(this.mouseTail);
|
|
2793
|
+
}
|
|
2794
|
+
this.iframe = document.createElement('iframe');
|
|
2795
|
+
var attributes = ['allow-same-origin'];
|
|
2796
|
+
if (this.config.UNSAFE_replayCanvas) {
|
|
2797
|
+
attributes.push('allow-scripts');
|
|
2798
|
+
}
|
|
2799
|
+
this.iframe.style.display = 'none';
|
|
2800
|
+
this.iframe.setAttribute('sandbox', attributes.join(' '));
|
|
2801
|
+
this.disableInteract();
|
|
2802
|
+
this.wrapper.appendChild(this.iframe);
|
|
2803
|
+
if (this.iframe.contentWindow && this.iframe.contentDocument) {
|
|
2804
|
+
polyfill$1(this.iframe.contentWindow, this.iframe.contentDocument);
|
|
2805
|
+
polyfill(this.iframe.contentWindow);
|
|
2806
|
+
}
|
|
2807
|
+
};
|
|
2808
|
+
Replayer.prototype.handleResize = function (dimension) {
|
|
2809
|
+
var e_6, _a;
|
|
2810
|
+
this.iframe.style.display = 'inherit';
|
|
2811
|
+
try {
|
|
2812
|
+
for (var _b = __values([this.mouseTail, this.iframe]), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2813
|
+
var el = _c.value;
|
|
2814
|
+
if (!el) {
|
|
2815
|
+
continue;
|
|
2816
|
+
}
|
|
2817
|
+
el.setAttribute('width', String(dimension.width));
|
|
2818
|
+
el.setAttribute('height', String(dimension.height));
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
2822
|
+
finally {
|
|
2823
|
+
try {
|
|
2824
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2825
|
+
}
|
|
2826
|
+
finally { if (e_6) throw e_6.error; }
|
|
2827
|
+
}
|
|
2828
|
+
};
|
|
2829
|
+
Replayer.prototype.applyEventsSynchronously = function (events) {
|
|
2830
|
+
var e_7, _a;
|
|
2831
|
+
try {
|
|
2832
|
+
for (var events_2 = __values(events), events_2_1 = events_2.next(); !events_2_1.done; events_2_1 = events_2.next()) {
|
|
2833
|
+
var event_2 = events_2_1.value;
|
|
2834
|
+
switch (event_2.type) {
|
|
2835
|
+
case EventType.DomContentLoaded:
|
|
2836
|
+
case EventType.Load:
|
|
2837
|
+
case EventType.Custom:
|
|
2838
|
+
continue;
|
|
2839
|
+
case EventType.FullSnapshot:
|
|
2840
|
+
case EventType.Meta:
|
|
2841
|
+
case EventType.Plugin:
|
|
2842
|
+
break;
|
|
2843
|
+
case EventType.IncrementalSnapshot:
|
|
2844
|
+
switch (event_2.data.source) {
|
|
2845
|
+
case IncrementalSource.MediaInteraction:
|
|
2846
|
+
continue;
|
|
2847
|
+
default:
|
|
2848
|
+
break;
|
|
2849
|
+
}
|
|
2850
|
+
break;
|
|
2851
|
+
default:
|
|
2852
|
+
break;
|
|
2853
|
+
}
|
|
2854
|
+
var castFn = this.getCastFn(event_2, true);
|
|
2855
|
+
castFn();
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
2859
|
+
finally {
|
|
2860
|
+
try {
|
|
2861
|
+
if (events_2_1 && !events_2_1.done && (_a = events_2.return)) _a.call(events_2);
|
|
2862
|
+
}
|
|
2863
|
+
finally { if (e_7) throw e_7.error; }
|
|
2864
|
+
}
|
|
2865
|
+
if (this.mousePos) {
|
|
2866
|
+
this.moveAndHover(this.mousePos.x, this.mousePos.y, this.mousePos.id, true, this.mousePos.debugData);
|
|
2867
|
+
}
|
|
2868
|
+
this.mousePos = null;
|
|
2869
|
+
if (this.touchActive === true) {
|
|
2870
|
+
this.mouse.classList.add('touch-active');
|
|
2871
|
+
}
|
|
2872
|
+
else if (this.touchActive === false) {
|
|
2873
|
+
this.mouse.classList.remove('touch-active');
|
|
2874
|
+
}
|
|
2875
|
+
this.touchActive = null;
|
|
2876
|
+
};
|
|
2877
|
+
Replayer.prototype.getCastFn = function (event, isSync) {
|
|
2878
|
+
var _this = this;
|
|
2879
|
+
if (isSync === void 0) { isSync = false; }
|
|
2880
|
+
var castFn;
|
|
2881
|
+
switch (event.type) {
|
|
2882
|
+
case EventType.DomContentLoaded:
|
|
2883
|
+
case EventType.Load:
|
|
2884
|
+
break;
|
|
2885
|
+
case EventType.Custom:
|
|
2886
|
+
castFn = function () {
|
|
2887
|
+
_this.emitter.emit(ReplayerEvents.CustomEvent, event);
|
|
2888
|
+
};
|
|
2889
|
+
break;
|
|
2890
|
+
case EventType.Meta:
|
|
2891
|
+
castFn = function () {
|
|
2892
|
+
return _this.emitter.emit(ReplayerEvents.Resize, {
|
|
2893
|
+
width: event.data.width,
|
|
2894
|
+
height: event.data.height,
|
|
2895
|
+
});
|
|
2896
|
+
};
|
|
2897
|
+
break;
|
|
2898
|
+
case EventType.FullSnapshot:
|
|
2899
|
+
castFn = function () {
|
|
2900
|
+
if (_this.firstFullSnapshot) {
|
|
2901
|
+
if (_this.firstFullSnapshot === event) {
|
|
2902
|
+
_this.firstFullSnapshot = true;
|
|
2903
|
+
return;
|
|
2904
|
+
}
|
|
2905
|
+
}
|
|
2906
|
+
else {
|
|
2907
|
+
_this.firstFullSnapshot = true;
|
|
2908
|
+
}
|
|
2909
|
+
_this.rebuildFullSnapshot(event, isSync);
|
|
2910
|
+
_this.iframe.contentWindow.scrollTo(event.data.initialOffset);
|
|
2911
|
+
};
|
|
2912
|
+
break;
|
|
2913
|
+
case EventType.IncrementalSnapshot:
|
|
2914
|
+
castFn = function () {
|
|
2915
|
+
var e_8, _a;
|
|
2916
|
+
_this.applyIncremental(event, isSync);
|
|
2917
|
+
if (isSync) {
|
|
2918
|
+
return;
|
|
2919
|
+
}
|
|
2920
|
+
_this.handleInactivity(event.timestamp);
|
|
2921
|
+
if (event === _this.nextUserInteractionEvent) {
|
|
2922
|
+
_this.nextUserInteractionEvent = null;
|
|
2923
|
+
_this.backToNormal();
|
|
2924
|
+
}
|
|
2925
|
+
if (_this.config.skipInactive && !_this.nextUserInteractionEvent) {
|
|
2926
|
+
try {
|
|
2927
|
+
for (var _b = __values(_this.service.state.context.events), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2928
|
+
var _event = _c.value;
|
|
2929
|
+
if (_event.timestamp <= event.timestamp) {
|
|
2930
|
+
continue;
|
|
2931
|
+
}
|
|
2932
|
+
if (_this.isUserInteraction(_event)) {
|
|
2933
|
+
if (_event.delay - event.delay >
|
|
2934
|
+
SKIP_TIME_THRESHOLD *
|
|
2935
|
+
_this.speedService.state.context.timer.speed) {
|
|
2936
|
+
_this.nextUserInteractionEvent = _event;
|
|
2937
|
+
}
|
|
2938
|
+
break;
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
2943
|
+
finally {
|
|
2944
|
+
try {
|
|
2945
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2946
|
+
}
|
|
2947
|
+
finally { if (e_8) throw e_8.error; }
|
|
2948
|
+
}
|
|
2949
|
+
if (_this.nextUserInteractionEvent) {
|
|
2950
|
+
var skipTime = _this.nextUserInteractionEvent.delay - event.delay;
|
|
2951
|
+
var payload = {
|
|
2952
|
+
speed: Math.min(Math.round(skipTime / SKIP_TIME_INTERVAL), _this.config.maxSpeed),
|
|
2953
|
+
};
|
|
2954
|
+
_this.speedService.send({ type: 'FAST_FORWARD', payload: payload });
|
|
2955
|
+
_this.emitter.emit(ReplayerEvents.SkipStart, payload);
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
};
|
|
2959
|
+
break;
|
|
2960
|
+
}
|
|
2961
|
+
var wrappedCastFn = function () {
|
|
2962
|
+
var e_9, _a;
|
|
2963
|
+
if (castFn) {
|
|
2964
|
+
castFn();
|
|
2965
|
+
}
|
|
2966
|
+
try {
|
|
2967
|
+
for (var _b = __values(_this.config.plugins || []), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2968
|
+
var plugin = _c.value;
|
|
2969
|
+
plugin.handler(event, isSync, { replayer: _this });
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
2973
|
+
finally {
|
|
2974
|
+
try {
|
|
2975
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2976
|
+
}
|
|
2977
|
+
finally { if (e_9) throw e_9.error; }
|
|
2978
|
+
}
|
|
2979
|
+
_this.service.send({ type: 'CAST_EVENT', payload: { event: event } });
|
|
2980
|
+
var last_index = _this.service.state.context.events.length - 1;
|
|
2981
|
+
if (event === _this.service.state.context.events[last_index]) {
|
|
2982
|
+
var finish_1 = function () {
|
|
2983
|
+
if (last_index < _this.service.state.context.events.length - 1) {
|
|
2984
|
+
return;
|
|
2985
|
+
}
|
|
2986
|
+
_this.backToNormal();
|
|
2987
|
+
_this.service.send('END');
|
|
2988
|
+
_this.emitter.emit(ReplayerEvents.Finish);
|
|
2989
|
+
};
|
|
2990
|
+
if (event.type === EventType.IncrementalSnapshot &&
|
|
2991
|
+
event.data.source === IncrementalSource.MouseMove &&
|
|
2992
|
+
event.data.positions.length) {
|
|
2993
|
+
setTimeout(function () {
|
|
2994
|
+
finish_1();
|
|
2995
|
+
}, Math.max(0, -event.data.positions[0].timeOffset + 50));
|
|
2996
|
+
}
|
|
2997
|
+
else {
|
|
2998
|
+
finish_1();
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
3001
|
+
_this.emitter.emit(ReplayerEvents.EventCast, event);
|
|
3002
|
+
};
|
|
3003
|
+
return wrappedCastFn;
|
|
3004
|
+
};
|
|
3005
|
+
Replayer.prototype.handleInactivity = function (timestamp, resetNext) {
|
|
3006
|
+
var e_10, _a;
|
|
3007
|
+
if (timestamp === this.inactiveEndTimestamp || resetNext) {
|
|
3008
|
+
this.inactiveEndTimestamp = null;
|
|
3009
|
+
this.backToNormal();
|
|
3010
|
+
}
|
|
3011
|
+
if (this.config.skipInactive && !this.inactiveEndTimestamp) {
|
|
3012
|
+
try {
|
|
3013
|
+
for (var _b = __values(this.getActivityIntervals()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3014
|
+
var interval = _c.value;
|
|
3015
|
+
if (timestamp >= interval.startTime &&
|
|
3016
|
+
timestamp < interval.endTime &&
|
|
3017
|
+
!interval.active) {
|
|
3018
|
+
this.inactiveEndTimestamp = interval.endTime;
|
|
3019
|
+
break;
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
}
|
|
3023
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
3024
|
+
finally {
|
|
3025
|
+
try {
|
|
3026
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3027
|
+
}
|
|
3028
|
+
finally { if (e_10) throw e_10.error; }
|
|
3029
|
+
}
|
|
3030
|
+
if (this.inactiveEndTimestamp) {
|
|
3031
|
+
var skipTime = this.inactiveEndTimestamp - timestamp;
|
|
3032
|
+
var payload = {
|
|
3033
|
+
speed: (skipTime / SKIP_DURATION_LIMIT) * this.config.inactiveSkipTime <
|
|
3034
|
+
SKIP_TIME_MIN
|
|
3035
|
+
? skipTime / SKIP_TIME_MIN
|
|
3036
|
+
: Math.round(Math.max(skipTime, SKIP_DURATION_LIMIT) /
|
|
3037
|
+
this.config.inactiveSkipTime),
|
|
3038
|
+
};
|
|
3039
|
+
this.speedService.send({ type: 'FAST_FORWARD', payload: payload });
|
|
3040
|
+
this.emitter.emit(ReplayerEvents.SkipStart, payload);
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
3043
|
+
};
|
|
3044
|
+
Replayer.prototype.rebuildFullSnapshot = function (event, isSync) {
|
|
3045
|
+
var e_11, _a;
|
|
3046
|
+
var _this = this;
|
|
3047
|
+
if (isSync === void 0) { isSync = false; }
|
|
3048
|
+
if (!this.iframe.contentDocument) {
|
|
3049
|
+
return console.warn('Looks like your replayer has been destroyed.');
|
|
3050
|
+
}
|
|
3051
|
+
if (Object.keys(this.legacy_missingNodeRetryMap).length) {
|
|
3052
|
+
console.warn('Found unresolved missing node map', this.legacy_missingNodeRetryMap);
|
|
3053
|
+
}
|
|
3054
|
+
this.legacy_missingNodeRetryMap = {};
|
|
3055
|
+
var collected = [];
|
|
3056
|
+
this.mirror.map = rebuild(event.data.node, {
|
|
3057
|
+
doc: this.iframe.contentDocument,
|
|
3058
|
+
afterAppend: function (builtNode) {
|
|
3059
|
+
_this.collectIframeAndAttachDocument(collected, builtNode);
|
|
3060
|
+
},
|
|
3061
|
+
cache: this.cache,
|
|
3062
|
+
})[1];
|
|
3063
|
+
var _loop_1 = function (mutationInQueue, builtNode) {
|
|
3064
|
+
this_1.attachDocumentToIframe(mutationInQueue, builtNode);
|
|
3065
|
+
this_1.newDocumentQueue = this_1.newDocumentQueue.filter(function (m) { return m !== mutationInQueue; });
|
|
3066
|
+
};
|
|
3067
|
+
var this_1 = this;
|
|
3068
|
+
try {
|
|
3069
|
+
for (var collected_1 = __values(collected), collected_1_1 = collected_1.next(); !collected_1_1.done; collected_1_1 = collected_1.next()) {
|
|
3070
|
+
var _b = collected_1_1.value, mutationInQueue = _b.mutationInQueue, builtNode = _b.builtNode;
|
|
3071
|
+
_loop_1(mutationInQueue, builtNode);
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3074
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
3075
|
+
finally {
|
|
3076
|
+
try {
|
|
3077
|
+
if (collected_1_1 && !collected_1_1.done && (_a = collected_1.return)) _a.call(collected_1);
|
|
3078
|
+
}
|
|
3079
|
+
finally { if (e_11) throw e_11.error; }
|
|
3080
|
+
}
|
|
3081
|
+
var _c = this.iframe.contentDocument, documentElement = _c.documentElement, head = _c.head;
|
|
3082
|
+
this.insertStyleRules(documentElement, head);
|
|
3083
|
+
if (!this.service.state.matches('playing')) {
|
|
3084
|
+
this.iframe.contentDocument
|
|
3085
|
+
.getElementsByTagName('html')[0]
|
|
3086
|
+
.classList.add('rrweb-paused');
|
|
3087
|
+
}
|
|
3088
|
+
this.emitter.emit(ReplayerEvents.FullsnapshotRebuilded, event);
|
|
3089
|
+
if (!isSync) {
|
|
3090
|
+
this.waitForStylesheetLoad();
|
|
3091
|
+
}
|
|
3092
|
+
if (this.config.UNSAFE_replayCanvas) {
|
|
3093
|
+
this.preloadAllImages();
|
|
3094
|
+
}
|
|
3095
|
+
};
|
|
3096
|
+
Replayer.prototype.insertStyleRules = function (documentElement, head) {
|
|
3097
|
+
var styleEl = document.createElement('style');
|
|
3098
|
+
documentElement.insertBefore(styleEl, head);
|
|
3099
|
+
var injectStylesRules = rules(this.config.blockClass).concat(this.config.insertStyleRules);
|
|
3100
|
+
if (this.config.pauseAnimation) {
|
|
3101
|
+
injectStylesRules.push('html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }');
|
|
3102
|
+
}
|
|
3103
|
+
for (var idx = 0; idx < injectStylesRules.length; idx++) {
|
|
3104
|
+
styleEl.sheet.insertRule(injectStylesRules[idx], idx);
|
|
3105
|
+
}
|
|
3106
|
+
};
|
|
3107
|
+
Replayer.prototype.attachDocumentToIframe = function (mutation, iframeEl) {
|
|
3108
|
+
var e_12, _a;
|
|
3109
|
+
var _this = this;
|
|
3110
|
+
var collected = [];
|
|
3111
|
+
if (!iframeEl.contentDocument) {
|
|
3112
|
+
var parent_1 = iframeEl.parentNode;
|
|
3113
|
+
while (parent_1) {
|
|
3114
|
+
if (this.fragmentParentMap.has(parent_1)) {
|
|
3115
|
+
var frag = parent_1;
|
|
3116
|
+
var realParent = this.fragmentParentMap.get(frag);
|
|
3117
|
+
this.restoreRealParent(frag, realParent);
|
|
3118
|
+
break;
|
|
3119
|
+
}
|
|
3120
|
+
parent_1 = parent_1.parentNode;
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
buildNodeWithSN(mutation.node, {
|
|
3124
|
+
doc: iframeEl.contentDocument,
|
|
3125
|
+
map: this.mirror.map,
|
|
3126
|
+
hackCss: true,
|
|
3127
|
+
skipChild: false,
|
|
3128
|
+
afterAppend: function (builtNode) {
|
|
3129
|
+
_this.collectIframeAndAttachDocument(collected, builtNode);
|
|
3130
|
+
if (builtNode.__sn.type === NodeType.Element &&
|
|
3131
|
+
builtNode.__sn.tagName.toUpperCase() === 'HTML') {
|
|
3132
|
+
var _a = iframeEl.contentDocument, documentElement = _a.documentElement, head = _a.head;
|
|
3133
|
+
_this.insertStyleRules(documentElement, head);
|
|
3134
|
+
}
|
|
3135
|
+
},
|
|
3136
|
+
cache: this.cache,
|
|
3137
|
+
});
|
|
3138
|
+
var _loop_2 = function (mutationInQueue, builtNode) {
|
|
3139
|
+
this_2.attachDocumentToIframe(mutationInQueue, builtNode);
|
|
3140
|
+
this_2.newDocumentQueue = this_2.newDocumentQueue.filter(function (m) { return m !== mutationInQueue; });
|
|
3141
|
+
};
|
|
3142
|
+
var this_2 = this;
|
|
3143
|
+
try {
|
|
3144
|
+
for (var collected_2 = __values(collected), collected_2_1 = collected_2.next(); !collected_2_1.done; collected_2_1 = collected_2.next()) {
|
|
3145
|
+
var _b = collected_2_1.value, mutationInQueue = _b.mutationInQueue, builtNode = _b.builtNode;
|
|
3146
|
+
_loop_2(mutationInQueue, builtNode);
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
3150
|
+
finally {
|
|
3151
|
+
try {
|
|
3152
|
+
if (collected_2_1 && !collected_2_1.done && (_a = collected_2.return)) _a.call(collected_2);
|
|
3153
|
+
}
|
|
3154
|
+
finally { if (e_12) throw e_12.error; }
|
|
3155
|
+
}
|
|
3156
|
+
};
|
|
3157
|
+
Replayer.prototype.collectIframeAndAttachDocument = function (collected, builtNode) {
|
|
3158
|
+
if (isIframeINode(builtNode)) {
|
|
3159
|
+
var mutationInQueue = this.newDocumentQueue.find(function (m) { return m.parentId === builtNode.__sn.id; });
|
|
3160
|
+
if (mutationInQueue) {
|
|
3161
|
+
collected.push({ mutationInQueue: mutationInQueue, builtNode: builtNode });
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
3164
|
+
};
|
|
3165
|
+
Replayer.prototype.waitForStylesheetLoad = function () {
|
|
3166
|
+
var _this = this;
|
|
3167
|
+
var _a;
|
|
3168
|
+
var head = (_a = this.iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.head;
|
|
3169
|
+
if (head) {
|
|
3170
|
+
var unloadSheets_1 = new Set();
|
|
3171
|
+
var timer_1;
|
|
3172
|
+
var beforeLoadState_1 = this.service.state;
|
|
3173
|
+
var stateHandler_1 = function () {
|
|
3174
|
+
beforeLoadState_1 = _this.service.state;
|
|
3175
|
+
};
|
|
3176
|
+
this.emitter.on(ReplayerEvents.Start, stateHandler_1);
|
|
3177
|
+
this.emitter.on(ReplayerEvents.Pause, stateHandler_1);
|
|
3178
|
+
var unsubscribe_1 = function () {
|
|
3179
|
+
_this.emitter.off(ReplayerEvents.Start, stateHandler_1);
|
|
3180
|
+
_this.emitter.off(ReplayerEvents.Pause, stateHandler_1);
|
|
3181
|
+
};
|
|
3182
|
+
head
|
|
3183
|
+
.querySelectorAll('link[rel="stylesheet"]')
|
|
3184
|
+
.forEach(function (css) {
|
|
3185
|
+
if (!css.sheet) {
|
|
3186
|
+
unloadSheets_1.add(css);
|
|
3187
|
+
css.addEventListener('load', function () {
|
|
3188
|
+
unloadSheets_1.delete(css);
|
|
3189
|
+
if (unloadSheets_1.size === 0 && timer_1 !== -1) {
|
|
3190
|
+
if (beforeLoadState_1.matches('playing')) {
|
|
3191
|
+
_this.play(_this.getCurrentTime());
|
|
3192
|
+
}
|
|
3193
|
+
_this.emitter.emit(ReplayerEvents.LoadStylesheetEnd);
|
|
3194
|
+
if (timer_1) {
|
|
3195
|
+
clearTimeout(timer_1);
|
|
3196
|
+
}
|
|
3197
|
+
unsubscribe_1();
|
|
3198
|
+
}
|
|
3199
|
+
});
|
|
3200
|
+
}
|
|
3201
|
+
});
|
|
3202
|
+
if (unloadSheets_1.size > 0) {
|
|
3203
|
+
this.service.send({ type: 'PAUSE' });
|
|
3204
|
+
this.emitter.emit(ReplayerEvents.LoadStylesheetStart);
|
|
3205
|
+
timer_1 = setTimeout(function () {
|
|
3206
|
+
if (beforeLoadState_1.matches('playing')) {
|
|
3207
|
+
_this.play(_this.getCurrentTime());
|
|
3208
|
+
}
|
|
3209
|
+
timer_1 = -1;
|
|
3210
|
+
unsubscribe_1();
|
|
3211
|
+
}, this.config.loadTimeout);
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
};
|
|
3215
|
+
Replayer.prototype.hasImageArg = function (args) {
|
|
3216
|
+
var e_13, _a;
|
|
3217
|
+
try {
|
|
3218
|
+
for (var args_1 = __values(args), args_1_1 = args_1.next(); !args_1_1.done; args_1_1 = args_1.next()) {
|
|
3219
|
+
var arg = args_1_1.value;
|
|
3220
|
+
if (!arg || typeof arg !== 'object') {
|
|
3221
|
+
}
|
|
3222
|
+
else if ('rr_type' in arg && 'args' in arg) {
|
|
3223
|
+
if (this.hasImageArg(arg.args))
|
|
3224
|
+
return true;
|
|
3225
|
+
}
|
|
3226
|
+
else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {
|
|
3227
|
+
return true;
|
|
3228
|
+
}
|
|
3229
|
+
else if (arg instanceof Array) {
|
|
3230
|
+
if (this.hasImageArg(arg))
|
|
3231
|
+
return true;
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
3236
|
+
finally {
|
|
3237
|
+
try {
|
|
3238
|
+
if (args_1_1 && !args_1_1.done && (_a = args_1.return)) _a.call(args_1);
|
|
3239
|
+
}
|
|
3240
|
+
finally { if (e_13) throw e_13.error; }
|
|
3241
|
+
}
|
|
3242
|
+
return false;
|
|
3243
|
+
};
|
|
3244
|
+
Replayer.prototype.getImageArgs = function (args) {
|
|
3245
|
+
var e_14, _a;
|
|
3246
|
+
var images = [];
|
|
3247
|
+
try {
|
|
3248
|
+
for (var args_2 = __values(args), args_2_1 = args_2.next(); !args_2_1.done; args_2_1 = args_2.next()) {
|
|
3249
|
+
var arg = args_2_1.value;
|
|
3250
|
+
if (!arg || typeof arg !== 'object') {
|
|
3251
|
+
}
|
|
3252
|
+
else if ('rr_type' in arg && 'args' in arg) {
|
|
3253
|
+
images.push.apply(images, __spreadArray([], __read(this.getImageArgs(arg.args)), false));
|
|
3254
|
+
}
|
|
3255
|
+
else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {
|
|
3256
|
+
images.push(arg.src);
|
|
3257
|
+
}
|
|
3258
|
+
else if (arg instanceof Array) {
|
|
3259
|
+
images.push.apply(images, __spreadArray([], __read(this.getImageArgs(arg)), false));
|
|
3260
|
+
}
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
3264
|
+
finally {
|
|
3265
|
+
try {
|
|
3266
|
+
if (args_2_1 && !args_2_1.done && (_a = args_2.return)) _a.call(args_2);
|
|
3267
|
+
}
|
|
3268
|
+
finally { if (e_14) throw e_14.error; }
|
|
3269
|
+
}
|
|
3270
|
+
return images;
|
|
3271
|
+
};
|
|
3272
|
+
Replayer.prototype.preloadAllImages = function () {
|
|
3273
|
+
var e_15, _a;
|
|
3274
|
+
var _this = this;
|
|
3275
|
+
this.service.state;
|
|
3276
|
+
var stateHandler = function () {
|
|
3277
|
+
_this.service.state;
|
|
3278
|
+
};
|
|
3279
|
+
this.emitter.on(ReplayerEvents.Start, stateHandler);
|
|
3280
|
+
this.emitter.on(ReplayerEvents.Pause, stateHandler);
|
|
3281
|
+
var _loop_3 = function (event_3) {
|
|
3282
|
+
if (event_3.type === EventType.IncrementalSnapshot &&
|
|
3283
|
+
event_3.data.source === IncrementalSource.CanvasMutation)
|
|
3284
|
+
if ('commands' in event_3.data) {
|
|
3285
|
+
event_3.data.commands.forEach(function (c) { return _this.preloadImages(c, event_3); });
|
|
3286
|
+
}
|
|
3287
|
+
else {
|
|
3288
|
+
this_3.preloadImages(event_3.data, event_3);
|
|
3289
|
+
}
|
|
3290
|
+
};
|
|
3291
|
+
var this_3 = this;
|
|
3292
|
+
try {
|
|
3293
|
+
for (var _b = __values(this.service.state.context.events), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
3294
|
+
var event_3 = _c.value;
|
|
3295
|
+
_loop_3(event_3);
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
3299
|
+
finally {
|
|
3300
|
+
try {
|
|
3301
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
3302
|
+
}
|
|
3303
|
+
finally { if (e_15) throw e_15.error; }
|
|
3304
|
+
}
|
|
3305
|
+
};
|
|
3306
|
+
Replayer.prototype.preloadImages = function (data, event) {
|
|
3307
|
+
var _this = this;
|
|
3308
|
+
if (data.property === 'drawImage' &&
|
|
3309
|
+
typeof data.args[0] === 'string' &&
|
|
3310
|
+
!this.imageMap.has(event)) {
|
|
3311
|
+
var canvas = document.createElement('canvas');
|
|
3312
|
+
var ctx = canvas.getContext('2d');
|
|
3313
|
+
var imgd = ctx === null || ctx === void 0 ? void 0 : ctx.createImageData(canvas.width, canvas.height);
|
|
3314
|
+
imgd === null || imgd === void 0 ? void 0 : imgd.data;
|
|
3315
|
+
JSON.parse(data.args[0]);
|
|
3316
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.putImageData(imgd, 0, 0);
|
|
3317
|
+
}
|
|
3318
|
+
else if (this.hasImageArg(data.args)) {
|
|
3319
|
+
this.getImageArgs(data.args).forEach(function (url) {
|
|
3320
|
+
var image = new Image();
|
|
3321
|
+
image.src = url;
|
|
3322
|
+
_this.imageMap.set(url, image);
|
|
3323
|
+
});
|
|
3324
|
+
}
|
|
3325
|
+
};
|
|
3326
|
+
Replayer.prototype.applyIncremental = function (e, isSync) {
|
|
3327
|
+
var _this = this;
|
|
3328
|
+
var _a, _b;
|
|
3329
|
+
var d = e.data;
|
|
3330
|
+
switch (d.source) {
|
|
3331
|
+
case IncrementalSource.Mutation: {
|
|
3332
|
+
if (isSync) {
|
|
3333
|
+
d.adds.forEach(function (m) { return _this.treeIndex.add(m); });
|
|
3334
|
+
d.texts.forEach(function (m) {
|
|
3335
|
+
var target = _this.mirror.getNode(m.id);
|
|
3336
|
+
var parent = target === null || target === void 0 ? void 0 : target.parentNode;
|
|
3337
|
+
if (parent && _this.virtualStyleRulesMap.has(parent))
|
|
3338
|
+
_this.virtualStyleRulesMap.delete(parent);
|
|
3339
|
+
_this.treeIndex.text(m);
|
|
3340
|
+
});
|
|
3341
|
+
d.attributes.forEach(function (m) { return _this.treeIndex.attribute(m); });
|
|
3342
|
+
d.removes.forEach(function (m) { return _this.treeIndex.remove(m, _this.mirror); });
|
|
3343
|
+
}
|
|
3344
|
+
try {
|
|
3345
|
+
this.applyMutation(d, isSync);
|
|
3346
|
+
}
|
|
3347
|
+
catch (error) {
|
|
3348
|
+
this.warn("Exception in mutation ".concat(error.message || error), d);
|
|
3349
|
+
}
|
|
3350
|
+
break;
|
|
3351
|
+
}
|
|
3352
|
+
case IncrementalSource.Drag:
|
|
3353
|
+
case IncrementalSource.TouchMove:
|
|
3354
|
+
case IncrementalSource.MouseMove:
|
|
3355
|
+
if (isSync) {
|
|
3356
|
+
var lastPosition = d.positions[d.positions.length - 1];
|
|
3357
|
+
this.mousePos = {
|
|
3358
|
+
x: lastPosition.x,
|
|
3359
|
+
y: lastPosition.y,
|
|
3360
|
+
id: lastPosition.id,
|
|
3361
|
+
debugData: d,
|
|
3362
|
+
};
|
|
3363
|
+
}
|
|
3364
|
+
else {
|
|
3365
|
+
d.positions.forEach(function (p) {
|
|
3366
|
+
var action = {
|
|
3367
|
+
doAction: function () {
|
|
3368
|
+
_this.moveAndHover(p.x, p.y, p.id, isSync, d);
|
|
3369
|
+
},
|
|
3370
|
+
delay: p.timeOffset +
|
|
3371
|
+
e.timestamp -
|
|
3372
|
+
_this.service.state.context.baselineTime,
|
|
3373
|
+
};
|
|
3374
|
+
_this.timer.addAction(action);
|
|
3375
|
+
});
|
|
3376
|
+
this.timer.addAction({
|
|
3377
|
+
doAction: function () { },
|
|
3378
|
+
delay: e.delay - ((_a = d.positions[0]) === null || _a === void 0 ? void 0 : _a.timeOffset),
|
|
3379
|
+
});
|
|
3380
|
+
}
|
|
3381
|
+
break;
|
|
3382
|
+
case IncrementalSource.MouseInteraction: {
|
|
3383
|
+
if (d.id === -1) {
|
|
3384
|
+
break;
|
|
3385
|
+
}
|
|
3386
|
+
var event_4 = new Event(MouseInteractions[d.type].toLowerCase());
|
|
3387
|
+
var target = this.mirror.getNode(d.id);
|
|
3388
|
+
if (!target) {
|
|
3389
|
+
return this.debugNodeNotFound(d, d.id);
|
|
3390
|
+
}
|
|
3391
|
+
this.emitter.emit(ReplayerEvents.MouseInteraction, {
|
|
3392
|
+
type: d.type,
|
|
3393
|
+
target: target,
|
|
3394
|
+
});
|
|
3395
|
+
var triggerFocus = this.config.triggerFocus;
|
|
3396
|
+
switch (d.type) {
|
|
3397
|
+
case MouseInteractions.Blur:
|
|
3398
|
+
if ('blur' in target) {
|
|
3399
|
+
target.blur();
|
|
3400
|
+
}
|
|
3401
|
+
break;
|
|
3402
|
+
case MouseInteractions.Focus:
|
|
3403
|
+
if (triggerFocus && target.focus) {
|
|
3404
|
+
target.focus({
|
|
3405
|
+
preventScroll: true,
|
|
3406
|
+
});
|
|
3407
|
+
}
|
|
3408
|
+
break;
|
|
3409
|
+
case MouseInteractions.Click:
|
|
3410
|
+
case MouseInteractions.TouchStart:
|
|
3411
|
+
case MouseInteractions.TouchEnd:
|
|
3412
|
+
if (isSync) {
|
|
3413
|
+
if (d.type === MouseInteractions.TouchStart) {
|
|
3414
|
+
this.touchActive = true;
|
|
3415
|
+
}
|
|
3416
|
+
else if (d.type === MouseInteractions.TouchEnd) {
|
|
3417
|
+
this.touchActive = false;
|
|
3418
|
+
}
|
|
3419
|
+
this.mousePos = {
|
|
3420
|
+
x: d.x,
|
|
3421
|
+
y: d.y,
|
|
3422
|
+
id: d.id,
|
|
3423
|
+
debugData: d,
|
|
3424
|
+
};
|
|
3425
|
+
}
|
|
3426
|
+
else {
|
|
3427
|
+
if (d.type === MouseInteractions.TouchStart) {
|
|
3428
|
+
this.tailPositions.length = 0;
|
|
3429
|
+
}
|
|
3430
|
+
this.moveAndHover(d.x, d.y, d.id, isSync, d);
|
|
3431
|
+
if (d.type === MouseInteractions.Click) {
|
|
3432
|
+
this.mouse.classList.remove('active');
|
|
3433
|
+
void this.mouse.offsetWidth;
|
|
3434
|
+
this.mouse.classList.add('active');
|
|
3435
|
+
}
|
|
3436
|
+
else if (d.type === MouseInteractions.TouchStart) {
|
|
3437
|
+
void this.mouse.offsetWidth;
|
|
3438
|
+
this.mouse.classList.add('touch-active');
|
|
3439
|
+
}
|
|
3440
|
+
else if (d.type === MouseInteractions.TouchEnd) {
|
|
3441
|
+
this.mouse.classList.remove('touch-active');
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
break;
|
|
3445
|
+
case MouseInteractions.TouchCancel:
|
|
3446
|
+
if (isSync) {
|
|
3447
|
+
this.touchActive = false;
|
|
3448
|
+
}
|
|
3449
|
+
else {
|
|
3450
|
+
this.mouse.classList.remove('touch-active');
|
|
3451
|
+
}
|
|
3452
|
+
break;
|
|
3453
|
+
default:
|
|
3454
|
+
target.dispatchEvent(event_4);
|
|
3455
|
+
}
|
|
3456
|
+
break;
|
|
3457
|
+
}
|
|
3458
|
+
case IncrementalSource.Scroll: {
|
|
3459
|
+
if (d.id === -1) {
|
|
3460
|
+
break;
|
|
3461
|
+
}
|
|
3462
|
+
if (isSync) {
|
|
3463
|
+
this.treeIndex.scroll(d);
|
|
3464
|
+
break;
|
|
3465
|
+
}
|
|
3466
|
+
this.applyScroll(d, false);
|
|
3467
|
+
break;
|
|
3468
|
+
}
|
|
3469
|
+
case IncrementalSource.ViewportResize:
|
|
3470
|
+
this.emitter.emit(ReplayerEvents.Resize, {
|
|
3471
|
+
width: d.width,
|
|
3472
|
+
height: d.height,
|
|
3473
|
+
});
|
|
3474
|
+
break;
|
|
3475
|
+
case IncrementalSource.Input: {
|
|
3476
|
+
if (d.id === -1) {
|
|
3477
|
+
break;
|
|
3478
|
+
}
|
|
3479
|
+
if (isSync) {
|
|
3480
|
+
this.treeIndex.input(d);
|
|
3481
|
+
break;
|
|
3482
|
+
}
|
|
3483
|
+
this.applyInput(d);
|
|
3484
|
+
break;
|
|
3485
|
+
}
|
|
3486
|
+
case IncrementalSource.MediaInteraction: {
|
|
3487
|
+
var target = this.mirror.getNode(d.id);
|
|
3488
|
+
if (!target) {
|
|
3489
|
+
return this.debugNodeNotFound(d, d.id);
|
|
3490
|
+
}
|
|
3491
|
+
var mediaEl = target;
|
|
3492
|
+
try {
|
|
3493
|
+
if (d.currentTime) {
|
|
3494
|
+
mediaEl.currentTime = d.currentTime;
|
|
3495
|
+
}
|
|
3496
|
+
if (d.volume) {
|
|
3497
|
+
mediaEl.volume = d.volume;
|
|
3498
|
+
}
|
|
3499
|
+
if (d.muted) {
|
|
3500
|
+
mediaEl.muted = d.muted;
|
|
3501
|
+
}
|
|
3502
|
+
if (d.type === 1) {
|
|
3503
|
+
mediaEl.pause();
|
|
3504
|
+
}
|
|
3505
|
+
if (d.type === 0) {
|
|
3506
|
+
mediaEl.play();
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
catch (error) {
|
|
3510
|
+
if (this.config.showWarning) {
|
|
3511
|
+
console.warn("Failed to replay media interactions: ".concat(error.message || error));
|
|
3512
|
+
}
|
|
3513
|
+
}
|
|
3514
|
+
break;
|
|
3515
|
+
}
|
|
3516
|
+
case IncrementalSource.StyleSheetRule: {
|
|
3517
|
+
var target = this.mirror.getNode(d.id);
|
|
3518
|
+
if (!target) {
|
|
3519
|
+
return this.debugNodeNotFound(d, d.id);
|
|
3520
|
+
}
|
|
3521
|
+
var styleEl = target;
|
|
3522
|
+
var parent_2 = target.parentNode;
|
|
3523
|
+
var usingVirtualParent_1 = this.fragmentParentMap.has(parent_2);
|
|
3524
|
+
var styleSheet_1 = usingVirtualParent_1 ? null : styleEl.sheet;
|
|
3525
|
+
var rules_1;
|
|
3526
|
+
if (!styleSheet_1) {
|
|
3527
|
+
if (this.virtualStyleRulesMap.has(target)) {
|
|
3528
|
+
rules_1 = this.virtualStyleRulesMap.get(target);
|
|
3529
|
+
}
|
|
3530
|
+
else {
|
|
3531
|
+
rules_1 = [];
|
|
3532
|
+
this.virtualStyleRulesMap.set(target, rules_1);
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3535
|
+
if (d.adds) {
|
|
3536
|
+
d.adds.forEach(function (_a) {
|
|
3537
|
+
var rule = _a.rule, nestedIndex = _a.index;
|
|
3538
|
+
if (styleSheet_1) {
|
|
3539
|
+
try {
|
|
3540
|
+
if (Array.isArray(nestedIndex)) {
|
|
3541
|
+
var _b = getPositionsAndIndex(nestedIndex), positions = _b.positions, index = _b.index;
|
|
3542
|
+
var nestedRule = getNestedRule(styleSheet_1.cssRules, positions);
|
|
3543
|
+
nestedRule.insertRule(rule, index);
|
|
3544
|
+
}
|
|
3545
|
+
else {
|
|
3546
|
+
var index = nestedIndex === undefined
|
|
3547
|
+
? undefined
|
|
3548
|
+
: Math.min(nestedIndex, styleSheet_1.cssRules.length);
|
|
3549
|
+
styleSheet_1.insertRule(rule, index);
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
catch (e) {
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
else {
|
|
3556
|
+
rules_1 === null || rules_1 === void 0 ? void 0 : rules_1.push({
|
|
3557
|
+
cssText: rule,
|
|
3558
|
+
index: nestedIndex,
|
|
3559
|
+
type: StyleRuleType.Insert,
|
|
3560
|
+
});
|
|
3561
|
+
}
|
|
3562
|
+
});
|
|
3563
|
+
}
|
|
3564
|
+
if (d.removes) {
|
|
3565
|
+
d.removes.forEach(function (_a) {
|
|
3566
|
+
var nestedIndex = _a.index;
|
|
3567
|
+
if (usingVirtualParent_1) {
|
|
3568
|
+
rules_1 === null || rules_1 === void 0 ? void 0 : rules_1.push({ index: nestedIndex, type: StyleRuleType.Remove });
|
|
3569
|
+
}
|
|
3570
|
+
else {
|
|
3571
|
+
try {
|
|
3572
|
+
if (Array.isArray(nestedIndex)) {
|
|
3573
|
+
var _b = getPositionsAndIndex(nestedIndex), positions = _b.positions, index = _b.index;
|
|
3574
|
+
var nestedRule = getNestedRule(styleSheet_1.cssRules, positions);
|
|
3575
|
+
nestedRule.deleteRule(index || 0);
|
|
3576
|
+
}
|
|
3577
|
+
else {
|
|
3578
|
+
styleSheet_1 === null || styleSheet_1 === void 0 ? void 0 : styleSheet_1.deleteRule(nestedIndex);
|
|
3579
|
+
}
|
|
3580
|
+
}
|
|
3581
|
+
catch (e) {
|
|
3582
|
+
}
|
|
3583
|
+
}
|
|
3584
|
+
});
|
|
3585
|
+
}
|
|
3586
|
+
break;
|
|
3587
|
+
}
|
|
3588
|
+
case IncrementalSource.StyleDeclaration: {
|
|
3589
|
+
var target = this.mirror.getNode(d.id);
|
|
3590
|
+
if (!target) {
|
|
3591
|
+
return this.debugNodeNotFound(d, d.id);
|
|
3592
|
+
}
|
|
3593
|
+
var styleEl = target;
|
|
3594
|
+
var parent_3 = target.parentNode;
|
|
3595
|
+
var usingVirtualParent = this.fragmentParentMap.has(parent_3);
|
|
3596
|
+
var styleSheet = usingVirtualParent ? null : styleEl.sheet;
|
|
3597
|
+
var rules = [];
|
|
3598
|
+
if (!styleSheet) {
|
|
3599
|
+
if (this.virtualStyleRulesMap.has(target)) {
|
|
3600
|
+
rules = this.virtualStyleRulesMap.get(target);
|
|
3601
|
+
}
|
|
3602
|
+
else {
|
|
3603
|
+
rules = [];
|
|
3604
|
+
this.virtualStyleRulesMap.set(target, rules);
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
if (d.set) {
|
|
3608
|
+
if (styleSheet) {
|
|
3609
|
+
var rule = getNestedRule(styleSheet.rules, d.index);
|
|
3610
|
+
rule.style.setProperty(d.set.property, d.set.value, d.set.priority);
|
|
3611
|
+
}
|
|
3612
|
+
else {
|
|
3613
|
+
rules.push(__assign({ type: StyleRuleType.SetProperty, index: d.index }, d.set));
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
if (d.remove) {
|
|
3617
|
+
if (styleSheet) {
|
|
3618
|
+
var rule = getNestedRule(styleSheet.rules, d.index);
|
|
3619
|
+
rule.style.removeProperty(d.remove.property);
|
|
3620
|
+
}
|
|
3621
|
+
else {
|
|
3622
|
+
rules.push(__assign({ type: StyleRuleType.RemoveProperty, index: d.index }, d.remove));
|
|
3623
|
+
}
|
|
3624
|
+
}
|
|
3625
|
+
break;
|
|
3626
|
+
}
|
|
3627
|
+
case IncrementalSource.CanvasMutation: {
|
|
3628
|
+
if (!this.config.UNSAFE_replayCanvas) {
|
|
3629
|
+
return;
|
|
3630
|
+
}
|
|
3631
|
+
var target = this.mirror.getNode(d.id);
|
|
3632
|
+
if (!target) {
|
|
3633
|
+
return this.debugNodeNotFound(d, d.id);
|
|
3634
|
+
}
|
|
3635
|
+
canvasMutation({
|
|
3636
|
+
event: e,
|
|
3637
|
+
mutation: d,
|
|
3638
|
+
target: target,
|
|
3639
|
+
imageMap: this.imageMap,
|
|
3640
|
+
errorHandler: this.warnCanvasMutationFailed.bind(this),
|
|
3641
|
+
});
|
|
3642
|
+
break;
|
|
3643
|
+
}
|
|
3644
|
+
case IncrementalSource.Font: {
|
|
3645
|
+
try {
|
|
3646
|
+
var fontFace = new FontFace(d.family, d.buffer ? new Uint8Array(JSON.parse(d.fontSource)) : d.fontSource, d.descriptors);
|
|
3647
|
+
(_b = this.iframe.contentDocument) === null || _b === void 0 ? void 0 : _b.fonts.add(fontFace);
|
|
3648
|
+
}
|
|
3649
|
+
catch (error) {
|
|
3650
|
+
if (this.config.showWarning) {
|
|
3651
|
+
console.warn(error);
|
|
3652
|
+
}
|
|
3653
|
+
}
|
|
3654
|
+
break;
|
|
3655
|
+
}
|
|
3656
|
+
}
|
|
3657
|
+
};
|
|
3658
|
+
Replayer.prototype.applyMutation = function (d, useVirtualParent) {
|
|
3659
|
+
var e_16, _a;
|
|
3660
|
+
var _this = this;
|
|
3661
|
+
d.removes.forEach(function (mutation) {
|
|
3662
|
+
var target = _this.mirror.getNode(mutation.id);
|
|
3663
|
+
if (!target) {
|
|
3664
|
+
if (d.removes.find(function (r) { return r.id === mutation.parentId; })) {
|
|
3665
|
+
return;
|
|
3666
|
+
}
|
|
3667
|
+
return _this.warnNodeNotFound(d, mutation.id);
|
|
3668
|
+
}
|
|
3669
|
+
if (_this.virtualStyleRulesMap.has(target)) {
|
|
3670
|
+
_this.virtualStyleRulesMap.delete(target);
|
|
3671
|
+
}
|
|
3672
|
+
var parent = _this.mirror.getNode(mutation.parentId);
|
|
3673
|
+
if (!parent) {
|
|
3674
|
+
return _this.warnNodeNotFound(d, mutation.parentId);
|
|
3675
|
+
}
|
|
3676
|
+
if (mutation.isShadow && hasShadowRoot(parent)) {
|
|
3677
|
+
parent = parent.shadowRoot;
|
|
3678
|
+
}
|
|
3679
|
+
_this.mirror.removeNodeFromMap(target);
|
|
3680
|
+
if (parent) {
|
|
3681
|
+
var realTarget = null;
|
|
3682
|
+
var realParent = '__sn' in parent ? _this.fragmentParentMap.get(parent) : undefined;
|
|
3683
|
+
if (realParent && realParent.contains(target)) {
|
|
3684
|
+
parent = realParent;
|
|
3685
|
+
}
|
|
3686
|
+
else if (_this.fragmentParentMap.has(target)) {
|
|
3687
|
+
realTarget = _this.fragmentParentMap.get(target);
|
|
3688
|
+
_this.fragmentParentMap.delete(target);
|
|
3689
|
+
target = realTarget;
|
|
3690
|
+
}
|
|
3691
|
+
try {
|
|
3692
|
+
parent.removeChild(target);
|
|
3693
|
+
}
|
|
3694
|
+
catch (error) {
|
|
3695
|
+
if (error instanceof DOMException) {
|
|
3696
|
+
_this.warn('parent could not remove child in mutation', parent, realParent, target, realTarget, d);
|
|
3697
|
+
}
|
|
3698
|
+
else {
|
|
3699
|
+
throw error;
|
|
3700
|
+
}
|
|
3701
|
+
}
|
|
3702
|
+
}
|
|
3703
|
+
});
|
|
3704
|
+
var legacy_missingNodeMap = __assign({}, this.legacy_missingNodeRetryMap);
|
|
3705
|
+
var queue = [];
|
|
3706
|
+
var nextNotInDOM = function (mutation) {
|
|
3707
|
+
var next = null;
|
|
3708
|
+
if (mutation.nextId) {
|
|
3709
|
+
next = _this.mirror.getNode(mutation.nextId);
|
|
3710
|
+
}
|
|
3711
|
+
if (mutation.nextId !== null &&
|
|
3712
|
+
mutation.nextId !== undefined &&
|
|
3713
|
+
mutation.nextId !== -1 &&
|
|
3714
|
+
!next) {
|
|
3715
|
+
return true;
|
|
3716
|
+
}
|
|
3717
|
+
return false;
|
|
3718
|
+
};
|
|
3719
|
+
var appendNode = function (mutation) {
|
|
3720
|
+
var e_17, _a;
|
|
3721
|
+
var _b, _c;
|
|
3722
|
+
if (!_this.iframe.contentDocument) {
|
|
3723
|
+
return console.warn('Looks like your replayer has been destroyed.');
|
|
3724
|
+
}
|
|
3725
|
+
var parent = _this.mirror.getNode(mutation.parentId);
|
|
3726
|
+
if (!parent) {
|
|
3727
|
+
if (mutation.node.type === NodeType.Document) {
|
|
3728
|
+
return _this.newDocumentQueue.push(mutation);
|
|
3729
|
+
}
|
|
3730
|
+
return queue.push(mutation);
|
|
3731
|
+
}
|
|
3732
|
+
var parentInDocument = null;
|
|
3733
|
+
if (_this.iframe.contentDocument.contains) {
|
|
3734
|
+
parentInDocument = _this.iframe.contentDocument.contains(parent);
|
|
3735
|
+
}
|
|
3736
|
+
else if (_this.iframe.contentDocument.body.contains) {
|
|
3737
|
+
parentInDocument = _this.iframe.contentDocument.body.contains(parent);
|
|
3738
|
+
}
|
|
3739
|
+
var hasIframeChild = ((_c = (_b = parent).getElementsByTagName) === null || _c === void 0 ? void 0 : _c.call(_b, 'iframe').length) > 0;
|
|
3740
|
+
if (useVirtualParent &&
|
|
3741
|
+
parentInDocument &&
|
|
3742
|
+
!isIframeINode(parent) &&
|
|
3743
|
+
!hasIframeChild) {
|
|
3744
|
+
var virtualParent = document.createDocumentFragment();
|
|
3745
|
+
_this.mirror.map[mutation.parentId] = virtualParent;
|
|
3746
|
+
_this.fragmentParentMap.set(virtualParent, parent);
|
|
3747
|
+
_this.storeState(parent);
|
|
3748
|
+
while (parent.firstChild) {
|
|
3749
|
+
virtualParent.appendChild(parent.firstChild);
|
|
3750
|
+
}
|
|
3751
|
+
parent = virtualParent;
|
|
3752
|
+
}
|
|
3753
|
+
if (mutation.node.isShadow) {
|
|
3754
|
+
if (!hasShadowRoot(parent)) {
|
|
3755
|
+
parent.attachShadow({ mode: 'open' });
|
|
3756
|
+
parent = parent.shadowRoot;
|
|
3757
|
+
}
|
|
3758
|
+
else
|
|
3759
|
+
parent = parent.shadowRoot;
|
|
3760
|
+
}
|
|
3761
|
+
var previous = null;
|
|
3762
|
+
var next = null;
|
|
3763
|
+
if (mutation.previousId) {
|
|
3764
|
+
previous = _this.mirror.getNode(mutation.previousId);
|
|
3765
|
+
}
|
|
3766
|
+
if (mutation.nextId) {
|
|
3767
|
+
next = _this.mirror.getNode(mutation.nextId);
|
|
3768
|
+
}
|
|
3769
|
+
if (nextNotInDOM(mutation)) {
|
|
3770
|
+
return queue.push(mutation);
|
|
3771
|
+
}
|
|
3772
|
+
if (mutation.node.rootId && !_this.mirror.getNode(mutation.node.rootId)) {
|
|
3773
|
+
return;
|
|
3774
|
+
}
|
|
3775
|
+
var targetDoc = mutation.node.rootId
|
|
3776
|
+
? _this.mirror.getNode(mutation.node.rootId)
|
|
3777
|
+
: _this.iframe.contentDocument;
|
|
3778
|
+
if (isIframeINode(parent)) {
|
|
3779
|
+
_this.attachDocumentToIframe(mutation, parent);
|
|
3780
|
+
return;
|
|
3781
|
+
}
|
|
3782
|
+
var target = buildNodeWithSN(mutation.node, {
|
|
3783
|
+
doc: targetDoc,
|
|
3784
|
+
map: _this.mirror.map,
|
|
3785
|
+
skipChild: true,
|
|
3786
|
+
hackCss: true,
|
|
3787
|
+
cache: _this.cache,
|
|
3788
|
+
});
|
|
3789
|
+
if (mutation.previousId === -1 || mutation.nextId === -1) {
|
|
3790
|
+
legacy_missingNodeMap[mutation.node.id] = {
|
|
3791
|
+
node: target,
|
|
3792
|
+
mutation: mutation,
|
|
3793
|
+
};
|
|
3794
|
+
return;
|
|
3795
|
+
}
|
|
3796
|
+
if ('__sn' in parent &&
|
|
3797
|
+
parent.__sn.type === NodeType.Element &&
|
|
3798
|
+
parent.__sn.tagName === 'textarea' &&
|
|
3799
|
+
mutation.node.type === NodeType.Text) {
|
|
3800
|
+
try {
|
|
3801
|
+
for (var _d = __values(Array.from(parent.childNodes)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
3802
|
+
var c = _e.value;
|
|
3803
|
+
if (c.nodeType === parent.TEXT_NODE) {
|
|
3804
|
+
parent.removeChild(c);
|
|
3805
|
+
}
|
|
3806
|
+
}
|
|
3807
|
+
}
|
|
3808
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
3809
|
+
finally {
|
|
3810
|
+
try {
|
|
3811
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
3812
|
+
}
|
|
3813
|
+
finally { if (e_17) throw e_17.error; }
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3816
|
+
if (previous && previous.nextSibling && previous.nextSibling.parentNode) {
|
|
3817
|
+
parent.insertBefore(target, previous.nextSibling);
|
|
3818
|
+
}
|
|
3819
|
+
else if (next && next.parentNode) {
|
|
3820
|
+
parent.contains(next)
|
|
3821
|
+
? parent.insertBefore(target, next)
|
|
3822
|
+
: parent.insertBefore(target, null);
|
|
3823
|
+
}
|
|
3824
|
+
else {
|
|
3825
|
+
if (parent === targetDoc) {
|
|
3826
|
+
while (targetDoc.firstChild) {
|
|
3827
|
+
targetDoc.removeChild(targetDoc.firstChild);
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
parent.appendChild(target);
|
|
3831
|
+
}
|
|
3832
|
+
if (isIframeINode(target)) {
|
|
3833
|
+
var mutationInQueue_1 = _this.newDocumentQueue.find(function (m) { return m.parentId === target.__sn.id; });
|
|
3834
|
+
if (mutationInQueue_1) {
|
|
3835
|
+
_this.attachDocumentToIframe(mutationInQueue_1, target);
|
|
3836
|
+
_this.newDocumentQueue = _this.newDocumentQueue.filter(function (m) { return m !== mutationInQueue_1; });
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
if (mutation.previousId || mutation.nextId) {
|
|
3840
|
+
_this.legacy_resolveMissingNode(legacy_missingNodeMap, parent, target, mutation);
|
|
3841
|
+
}
|
|
3842
|
+
};
|
|
3843
|
+
d.adds.forEach(function (mutation) {
|
|
3844
|
+
appendNode(mutation);
|
|
3845
|
+
});
|
|
3846
|
+
var startTime = Date.now();
|
|
3847
|
+
while (queue.length) {
|
|
3848
|
+
var resolveTrees = queueToResolveTrees(queue);
|
|
3849
|
+
queue.length = 0;
|
|
3850
|
+
if (Date.now() - startTime > 500) {
|
|
3851
|
+
this.warn('Timeout in the loop, please check the resolve tree data:', resolveTrees);
|
|
3852
|
+
break;
|
|
3853
|
+
}
|
|
3854
|
+
try {
|
|
3855
|
+
for (var resolveTrees_1 = (e_16 = void 0, __values(resolveTrees)), resolveTrees_1_1 = resolveTrees_1.next(); !resolveTrees_1_1.done; resolveTrees_1_1 = resolveTrees_1.next()) {
|
|
3856
|
+
var tree = resolveTrees_1_1.value;
|
|
3857
|
+
var parent_4 = this.mirror.getNode(tree.value.parentId);
|
|
3858
|
+
if (!parent_4) {
|
|
3859
|
+
this.debug('Drop resolve tree since there is no parent for the root node.', tree);
|
|
3860
|
+
}
|
|
3861
|
+
else {
|
|
3862
|
+
iterateResolveTree(tree, function (mutation) {
|
|
3863
|
+
appendNode(mutation);
|
|
3864
|
+
});
|
|
3865
|
+
}
|
|
3866
|
+
}
|
|
3867
|
+
}
|
|
3868
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
3869
|
+
finally {
|
|
3870
|
+
try {
|
|
3871
|
+
if (resolveTrees_1_1 && !resolveTrees_1_1.done && (_a = resolveTrees_1.return)) _a.call(resolveTrees_1);
|
|
3872
|
+
}
|
|
3873
|
+
finally { if (e_16) throw e_16.error; }
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
if (Object.keys(legacy_missingNodeMap).length) {
|
|
3877
|
+
Object.assign(this.legacy_missingNodeRetryMap, legacy_missingNodeMap);
|
|
3878
|
+
}
|
|
3879
|
+
d.texts.forEach(function (mutation) {
|
|
3880
|
+
var target = _this.mirror.getNode(mutation.id);
|
|
3881
|
+
if (!target) {
|
|
3882
|
+
if (d.removes.find(function (r) { return r.id === mutation.id; })) {
|
|
3883
|
+
return;
|
|
3884
|
+
}
|
|
3885
|
+
return _this.warnNodeNotFound(d, mutation.id);
|
|
3886
|
+
}
|
|
3887
|
+
if (_this.fragmentParentMap.has(target)) {
|
|
3888
|
+
target = _this.fragmentParentMap.get(target);
|
|
3889
|
+
}
|
|
3890
|
+
target.textContent = mutation.value;
|
|
3891
|
+
});
|
|
3892
|
+
d.attributes.forEach(function (mutation) {
|
|
3893
|
+
var target = _this.mirror.getNode(mutation.id);
|
|
3894
|
+
if (!target) {
|
|
3895
|
+
if (d.removes.find(function (r) { return r.id === mutation.id; })) {
|
|
3896
|
+
return;
|
|
3897
|
+
}
|
|
3898
|
+
return _this.warnNodeNotFound(d, mutation.id);
|
|
3899
|
+
}
|
|
3900
|
+
if (_this.fragmentParentMap.has(target)) {
|
|
3901
|
+
target = _this.fragmentParentMap.get(target);
|
|
3902
|
+
}
|
|
3903
|
+
for (var attributeName in mutation.attributes) {
|
|
3904
|
+
if (typeof attributeName === 'string') {
|
|
3905
|
+
var value = mutation.attributes[attributeName];
|
|
3906
|
+
if (value === null) {
|
|
3907
|
+
target.removeAttribute(attributeName);
|
|
3908
|
+
}
|
|
3909
|
+
else if (typeof value === 'string') {
|
|
3910
|
+
try {
|
|
3911
|
+
target.setAttribute(attributeName, value);
|
|
3912
|
+
}
|
|
3913
|
+
catch (error) {
|
|
3914
|
+
if (_this.config.showWarning) {
|
|
3915
|
+
console.warn('An error occurred may due to the checkout feature.', error);
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
}
|
|
3919
|
+
else if (attributeName === 'style') {
|
|
3920
|
+
var styleValues = value;
|
|
3921
|
+
var targetEl = target;
|
|
3922
|
+
for (var s in styleValues) {
|
|
3923
|
+
if (styleValues[s] === false) {
|
|
3924
|
+
targetEl.style.removeProperty(s);
|
|
3925
|
+
}
|
|
3926
|
+
else if (styleValues[s] instanceof Array) {
|
|
3927
|
+
var svp = styleValues[s];
|
|
3928
|
+
targetEl.style.setProperty(s, svp[0], svp[1]);
|
|
3929
|
+
}
|
|
3930
|
+
else {
|
|
3931
|
+
var svs = styleValues[s];
|
|
3932
|
+
targetEl.style.setProperty(s, svs);
|
|
3933
|
+
}
|
|
3934
|
+
}
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
});
|
|
3939
|
+
};
|
|
3940
|
+
Replayer.prototype.applyScroll = function (d, isSync) {
|
|
3941
|
+
var target = this.mirror.getNode(d.id);
|
|
3942
|
+
if (!target) {
|
|
3943
|
+
return this.debugNodeNotFound(d, d.id);
|
|
3944
|
+
}
|
|
3945
|
+
if (target === this.iframe.contentDocument) {
|
|
3946
|
+
this.iframe.contentWindow.scrollTo({
|
|
3947
|
+
top: d.y,
|
|
3948
|
+
left: d.x,
|
|
3949
|
+
behavior: isSync ? 'auto' : 'smooth',
|
|
3950
|
+
});
|
|
3951
|
+
}
|
|
3952
|
+
else if (target.__sn.type === NodeType.Document) {
|
|
3953
|
+
target.defaultView.scrollTo({
|
|
3954
|
+
top: d.y,
|
|
3955
|
+
left: d.x,
|
|
3956
|
+
behavior: isSync ? 'auto' : 'smooth',
|
|
3957
|
+
});
|
|
3958
|
+
}
|
|
3959
|
+
else {
|
|
3960
|
+
try {
|
|
3961
|
+
target.scrollTop = d.y;
|
|
3962
|
+
target.scrollLeft = d.x;
|
|
3963
|
+
}
|
|
3964
|
+
catch (error) {
|
|
3965
|
+
}
|
|
3966
|
+
}
|
|
3967
|
+
};
|
|
3968
|
+
Replayer.prototype.applyInput = function (d) {
|
|
3969
|
+
var target = this.mirror.getNode(d.id);
|
|
3970
|
+
if (!target) {
|
|
3971
|
+
return this.debugNodeNotFound(d, d.id);
|
|
3972
|
+
}
|
|
3973
|
+
try {
|
|
3974
|
+
target.checked = d.isChecked;
|
|
3975
|
+
target.value = d.text;
|
|
3976
|
+
}
|
|
3977
|
+
catch (error) {
|
|
3978
|
+
}
|
|
3979
|
+
};
|
|
3980
|
+
Replayer.prototype.applyText = function (d, mutation) {
|
|
3981
|
+
var target = this.mirror.getNode(d.id);
|
|
3982
|
+
if (!target) {
|
|
3983
|
+
return this.debugNodeNotFound(mutation, d.id);
|
|
3984
|
+
}
|
|
3985
|
+
try {
|
|
3986
|
+
target.textContent = d.value;
|
|
3987
|
+
}
|
|
3988
|
+
catch (error) {
|
|
3989
|
+
}
|
|
3990
|
+
};
|
|
3991
|
+
Replayer.prototype.legacy_resolveMissingNode = function (map, parent, target, targetMutation) {
|
|
3992
|
+
var previousId = targetMutation.previousId, nextId = targetMutation.nextId;
|
|
3993
|
+
var previousInMap = previousId && map[previousId];
|
|
3994
|
+
var nextInMap = nextId && map[nextId];
|
|
3995
|
+
if (previousInMap) {
|
|
3996
|
+
var _a = previousInMap, node = _a.node, mutation = _a.mutation;
|
|
3997
|
+
parent.insertBefore(node, target);
|
|
3998
|
+
delete map[mutation.node.id];
|
|
3999
|
+
delete this.legacy_missingNodeRetryMap[mutation.node.id];
|
|
4000
|
+
if (mutation.previousId || mutation.nextId) {
|
|
4001
|
+
this.legacy_resolveMissingNode(map, parent, node, mutation);
|
|
4002
|
+
}
|
|
4003
|
+
}
|
|
4004
|
+
if (nextInMap) {
|
|
4005
|
+
var _b = nextInMap, node = _b.node, mutation = _b.mutation;
|
|
4006
|
+
parent.insertBefore(node, target.nextSibling);
|
|
4007
|
+
delete map[mutation.node.id];
|
|
4008
|
+
delete this.legacy_missingNodeRetryMap[mutation.node.id];
|
|
4009
|
+
if (mutation.previousId || mutation.nextId) {
|
|
4010
|
+
this.legacy_resolveMissingNode(map, parent, node, mutation);
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
};
|
|
4014
|
+
Replayer.prototype.moveAndHover = function (x, y, id, isSync, debugData) {
|
|
4015
|
+
var target = this.mirror.getNode(id);
|
|
4016
|
+
if (!target) {
|
|
4017
|
+
return this.debugNodeNotFound(debugData, id);
|
|
4018
|
+
}
|
|
4019
|
+
var base = getBaseDimension(target, this.iframe);
|
|
4020
|
+
var _x = x * base.absoluteScale + base.x;
|
|
4021
|
+
var _y = y * base.absoluteScale + base.y;
|
|
4022
|
+
this.mouse.style.left = "".concat(_x, "px");
|
|
4023
|
+
this.mouse.style.top = "".concat(_y, "px");
|
|
4024
|
+
if (!isSync) {
|
|
4025
|
+
this.drawMouseTail({ x: _x, y: _y });
|
|
4026
|
+
}
|
|
4027
|
+
this.hoverElements(target);
|
|
4028
|
+
};
|
|
4029
|
+
Replayer.prototype.drawMouseTail = function (position) {
|
|
4030
|
+
var _this = this;
|
|
4031
|
+
if (!this.mouseTail) {
|
|
4032
|
+
return;
|
|
4033
|
+
}
|
|
4034
|
+
var _a = this.config.mouseTail === true
|
|
4035
|
+
? defaultMouseTailConfig
|
|
4036
|
+
: Object.assign({}, defaultMouseTailConfig, this.config.mouseTail), lineCap = _a.lineCap, lineWidth = _a.lineWidth, strokeStyle = _a.strokeStyle, duration = _a.duration;
|
|
4037
|
+
var draw = function () {
|
|
4038
|
+
if (!_this.mouseTail) {
|
|
4039
|
+
return;
|
|
4040
|
+
}
|
|
4041
|
+
var ctx = _this.mouseTail.getContext('2d');
|
|
4042
|
+
if (!ctx || !_this.tailPositions.length) {
|
|
4043
|
+
return;
|
|
4044
|
+
}
|
|
4045
|
+
ctx.clearRect(0, 0, _this.mouseTail.width, _this.mouseTail.height);
|
|
4046
|
+
ctx.beginPath();
|
|
4047
|
+
ctx.lineWidth = lineWidth;
|
|
4048
|
+
ctx.lineCap = lineCap;
|
|
4049
|
+
ctx.strokeStyle = strokeStyle;
|
|
4050
|
+
ctx.moveTo(_this.tailPositions[0].x, _this.tailPositions[0].y);
|
|
4051
|
+
_this.tailPositions.forEach(function (p) { return ctx.lineTo(p.x, p.y); });
|
|
4052
|
+
ctx.stroke();
|
|
4053
|
+
};
|
|
4054
|
+
this.tailPositions.push(position);
|
|
4055
|
+
draw();
|
|
4056
|
+
setTimeout(function () {
|
|
4057
|
+
_this.tailPositions = _this.tailPositions.filter(function (p) { return p !== position; });
|
|
4058
|
+
draw();
|
|
4059
|
+
}, duration / this.speedService.state.context.timer.speed);
|
|
4060
|
+
};
|
|
4061
|
+
Replayer.prototype.hoverElements = function (el) {
|
|
4062
|
+
var _a;
|
|
4063
|
+
(_a = this.iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.\\:hover').forEach(function (hoveredEl) {
|
|
4064
|
+
hoveredEl.classList.remove(':hover');
|
|
4065
|
+
});
|
|
4066
|
+
var currentEl = el;
|
|
4067
|
+
while (currentEl) {
|
|
4068
|
+
if (currentEl.classList) {
|
|
4069
|
+
currentEl.classList.add(':hover');
|
|
4070
|
+
}
|
|
4071
|
+
currentEl = currentEl.parentElement;
|
|
4072
|
+
}
|
|
4073
|
+
};
|
|
4074
|
+
Replayer.prototype.isUserInteraction = function (event) {
|
|
4075
|
+
if (event.type !== EventType.IncrementalSnapshot) {
|
|
4076
|
+
return false;
|
|
4077
|
+
}
|
|
4078
|
+
return (event.data.source > IncrementalSource.Mutation &&
|
|
4079
|
+
event.data.source <= IncrementalSource.Input);
|
|
4080
|
+
};
|
|
4081
|
+
Replayer.prototype.backToNormal = function () {
|
|
4082
|
+
this.nextUserInteractionEvent = null;
|
|
4083
|
+
if (this.speedService.state.matches('normal')) {
|
|
4084
|
+
return;
|
|
4085
|
+
}
|
|
4086
|
+
this.speedService.send({ type: 'BACK_TO_NORMAL' });
|
|
4087
|
+
this.emitter.emit(ReplayerEvents.SkipEnd, {
|
|
4088
|
+
speed: this.speedService.state.context.normalSpeed,
|
|
4089
|
+
});
|
|
4090
|
+
};
|
|
4091
|
+
Replayer.prototype.restoreRealParent = function (frag, parent) {
|
|
4092
|
+
this.mirror.map[parent.__sn.id] = parent;
|
|
4093
|
+
if (parent.__sn.type === NodeType.Element &&
|
|
4094
|
+
parent.__sn.tagName === 'textarea' &&
|
|
4095
|
+
frag.textContent) {
|
|
4096
|
+
parent.value = frag.textContent;
|
|
4097
|
+
}
|
|
4098
|
+
parent.appendChild(frag);
|
|
4099
|
+
this.restoreState(parent);
|
|
4100
|
+
};
|
|
4101
|
+
Replayer.prototype.storeState = function (parent) {
|
|
4102
|
+
var e_18, _a;
|
|
4103
|
+
if (parent) {
|
|
4104
|
+
if (parent.nodeType === parent.ELEMENT_NODE) {
|
|
4105
|
+
var parentElement = parent;
|
|
4106
|
+
if (parentElement.scrollLeft || parentElement.scrollTop) {
|
|
4107
|
+
this.elementStateMap.set(parent, {
|
|
4108
|
+
scroll: [parentElement.scrollLeft, parentElement.scrollTop],
|
|
4109
|
+
});
|
|
4110
|
+
}
|
|
4111
|
+
if (parentElement.tagName === 'STYLE')
|
|
4112
|
+
storeCSSRules(parentElement, this.virtualStyleRulesMap);
|
|
4113
|
+
var children = parentElement.children;
|
|
4114
|
+
try {
|
|
4115
|
+
for (var _b = __values(Array.from(children)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
4116
|
+
var child = _c.value;
|
|
4117
|
+
this.storeState(child);
|
|
4118
|
+
}
|
|
4119
|
+
}
|
|
4120
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
4121
|
+
finally {
|
|
4122
|
+
try {
|
|
4123
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
4124
|
+
}
|
|
4125
|
+
finally { if (e_18) throw e_18.error; }
|
|
4126
|
+
}
|
|
4127
|
+
}
|
|
4128
|
+
}
|
|
4129
|
+
};
|
|
4130
|
+
Replayer.prototype.restoreState = function (parent) {
|
|
4131
|
+
var e_19, _a;
|
|
4132
|
+
if (parent.nodeType === parent.ELEMENT_NODE) {
|
|
4133
|
+
var parentElement = parent;
|
|
4134
|
+
if (this.elementStateMap.has(parent)) {
|
|
4135
|
+
var storedState = this.elementStateMap.get(parent);
|
|
4136
|
+
if (storedState.scroll) {
|
|
4137
|
+
parentElement.scrollLeft = storedState.scroll[0];
|
|
4138
|
+
parentElement.scrollTop = storedState.scroll[1];
|
|
4139
|
+
}
|
|
4140
|
+
this.elementStateMap.delete(parent);
|
|
4141
|
+
}
|
|
4142
|
+
var children = parentElement.children;
|
|
4143
|
+
try {
|
|
4144
|
+
for (var _b = __values(Array.from(children)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
4145
|
+
var child = _c.value;
|
|
4146
|
+
this.restoreState(child);
|
|
4147
|
+
}
|
|
4148
|
+
}
|
|
4149
|
+
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
4150
|
+
finally {
|
|
4151
|
+
try {
|
|
4152
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
4153
|
+
}
|
|
4154
|
+
finally { if (e_19) throw e_19.error; }
|
|
4155
|
+
}
|
|
4156
|
+
}
|
|
4157
|
+
};
|
|
4158
|
+
Replayer.prototype.restoreNodeSheet = function (node) {
|
|
4159
|
+
var storedRules = this.virtualStyleRulesMap.get(node);
|
|
4160
|
+
if (node.nodeName !== 'STYLE') {
|
|
4161
|
+
return;
|
|
4162
|
+
}
|
|
4163
|
+
if (!storedRules) {
|
|
4164
|
+
return;
|
|
4165
|
+
}
|
|
4166
|
+
var styleNode = node;
|
|
4167
|
+
applyVirtualStyleRulesToNode(storedRules, styleNode);
|
|
4168
|
+
};
|
|
4169
|
+
Replayer.prototype.warnNodeNotFound = function (d, id) {
|
|
4170
|
+
if (this.treeIndex.idRemoved(id)) {
|
|
4171
|
+
this.warn("Node with id '".concat(id, "' was previously removed. "), d);
|
|
4172
|
+
}
|
|
4173
|
+
else {
|
|
4174
|
+
this.warn("Node with id '".concat(id, "' not found. "), d);
|
|
4175
|
+
}
|
|
4176
|
+
};
|
|
4177
|
+
Replayer.prototype.warnCanvasMutationFailed = function (d, error) {
|
|
4178
|
+
this.warn("Has error on canvas update", error, 'canvas mutation:', d);
|
|
4179
|
+
};
|
|
4180
|
+
Replayer.prototype.debugNodeNotFound = function (d, id) {
|
|
4181
|
+
if (this.treeIndex.idRemoved(id)) {
|
|
4182
|
+
this.debug(REPLAY_CONSOLE_PREFIX, "Node with id '".concat(id, "' was previously removed. "), d);
|
|
4183
|
+
}
|
|
4184
|
+
else {
|
|
4185
|
+
this.debug(REPLAY_CONSOLE_PREFIX, "Node with id '".concat(id, "' not found. "), d);
|
|
4186
|
+
}
|
|
4187
|
+
};
|
|
4188
|
+
Replayer.prototype.warn = function () {
|
|
4189
|
+
var args = [];
|
|
4190
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
4191
|
+
args[_i] = arguments[_i];
|
|
4192
|
+
}
|
|
4193
|
+
if (!this.config.showWarning) {
|
|
4194
|
+
return;
|
|
4195
|
+
}
|
|
4196
|
+
console.warn.apply(console, __spreadArray([REPLAY_CONSOLE_PREFIX], __read(args), false));
|
|
4197
|
+
};
|
|
4198
|
+
Replayer.prototype.debug = function () {
|
|
4199
|
+
var args = [];
|
|
4200
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
4201
|
+
args[_i] = arguments[_i];
|
|
4202
|
+
}
|
|
4203
|
+
if (!this.config.showDebug) {
|
|
4204
|
+
return;
|
|
4205
|
+
}
|
|
4206
|
+
console.log.apply(console, __spreadArray([REPLAY_CONSOLE_PREFIX], __read(args), false));
|
|
4207
|
+
};
|
|
4208
|
+
return Replayer;
|
|
4209
|
+
}());
|
|
4210
|
+
|
|
4211
|
+
exports.Replayer = Replayer;
|