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