@highlight-run/rrweb 2.0.4 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugins/console-record.js +12 -454
- package/dist/plugins/console-record.min.js.map +1 -1
- package/dist/plugins/console-replay.js +4 -164
- package/dist/plugins/console-replay.min.js.map +1 -1
- package/dist/plugins/sequential-id-record.js +1 -30
- package/dist/plugins/sequential-id-replay.js +1 -33
- package/dist/record/rrweb-record-pack.js +3 -664
- package/dist/record/rrweb-record-pack.min.js.map +1 -1
- package/dist/record/rrweb-record.js +4 -3202
- package/dist/record/rrweb-record.min.js +3 -3
- package/dist/record/rrweb-record.min.js.map +1 -1
- package/dist/replay/rrweb-replay-unpack.css +1 -0
- package/dist/replay/rrweb-replay-unpack.js +5 -4914
- 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 +1 -1
- package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
- package/dist/replay/rrweb-replay.css +1 -0
- package/dist/replay/rrweb-replay.js +5 -4506
- 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 +1 -1
- package/dist/replay/rrweb-replay.min.js.map +1 -1
- package/dist/rrweb-all.css +1 -0
- package/dist/rrweb-all.js +16 -8877
- package/dist/rrweb-all.min.css +2 -0
- package/dist/rrweb-all.min.css.map +1 -0
- package/dist/rrweb-all.min.js +1 -1
- package/dist/rrweb-all.min.js.map +1 -1
- package/dist/rrweb.css +1 -0
- package/dist/rrweb.js +6 -7546
- package/dist/rrweb.min.css +2 -0
- package/dist/rrweb.min.css.map +1 -0
- package/dist/rrweb.min.js +1 -1
- package/dist/rrweb.min.js.map +1 -1
- package/es/rrweb/all.css +1 -0
- package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +1 -1
- package/lib/replay/rrweb-replay-unpack.css +1 -0
- package/lib/replay/rrweb-replay-unpack.js +1 -1
- package/lib/replay/rrweb-replay.css +1 -0
- package/lib/replay/rrweb-replay.js +1 -1
- package/lib/rrweb-all.css +1 -0
- package/lib/rrweb-all.js +1 -1
- package/lib/rrweb.css +1 -0
- package/lib/rrweb.js +1 -1
- package/package.json +4 -4
|
@@ -1,3202 +1,4 @@
|
|
|
1
|
-
var rrwebRecord = (function () {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var NodeType;
|
|
5
|
-
(function(NodeType2) {
|
|
6
|
-
NodeType2[NodeType2["Document"] = 0] = "Document";
|
|
7
|
-
NodeType2[NodeType2["DocumentType"] = 1] = "DocumentType";
|
|
8
|
-
NodeType2[NodeType2["Element"] = 2] = "Element";
|
|
9
|
-
NodeType2[NodeType2["Text"] = 3] = "Text";
|
|
10
|
-
NodeType2[NodeType2["CDATA"] = 4] = "CDATA";
|
|
11
|
-
NodeType2[NodeType2["Comment"] = 5] = "Comment";
|
|
12
|
-
})(NodeType || (NodeType = {}));
|
|
13
|
-
function isElement(n) {
|
|
14
|
-
return n.nodeType === n.ELEMENT_NODE;
|
|
15
|
-
}
|
|
16
|
-
function isShadowRoot(n) {
|
|
17
|
-
var _a;
|
|
18
|
-
var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;
|
|
19
|
-
return Boolean(host && host.shadowRoot && host.shadowRoot === n);
|
|
20
|
-
}
|
|
21
|
-
var Mirror = function() {
|
|
22
|
-
function Mirror2() {
|
|
23
|
-
this.idNodeMap = /* @__PURE__ */ new Map();
|
|
24
|
-
this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
|
|
25
|
-
}
|
|
26
|
-
Mirror2.prototype.getId = function(n) {
|
|
27
|
-
var _a;
|
|
28
|
-
if (!n)
|
|
29
|
-
return -1;
|
|
30
|
-
var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
|
|
31
|
-
return id !== null && id !== void 0 ? id : -1;
|
|
32
|
-
};
|
|
33
|
-
Mirror2.prototype.getNode = function(id) {
|
|
34
|
-
return this.idNodeMap.get(id) || null;
|
|
35
|
-
};
|
|
36
|
-
Mirror2.prototype.getIds = function() {
|
|
37
|
-
return Array.from(this.idNodeMap.keys());
|
|
38
|
-
};
|
|
39
|
-
Mirror2.prototype.getMeta = function(n) {
|
|
40
|
-
return this.nodeMetaMap.get(n) || null;
|
|
41
|
-
};
|
|
42
|
-
Mirror2.prototype.removeNodeFromMap = function(n) {
|
|
43
|
-
var _this = this;
|
|
44
|
-
var id = this.getId(n);
|
|
45
|
-
this.idNodeMap["delete"](id);
|
|
46
|
-
if (n.childNodes) {
|
|
47
|
-
n.childNodes.forEach(function(childNode) {
|
|
48
|
-
return _this.removeNodeFromMap(childNode);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
Mirror2.prototype.has = function(id) {
|
|
53
|
-
return this.idNodeMap.has(id);
|
|
54
|
-
};
|
|
55
|
-
Mirror2.prototype.hasNode = function(node) {
|
|
56
|
-
return this.nodeMetaMap.has(node);
|
|
57
|
-
};
|
|
58
|
-
Mirror2.prototype.add = function(n, meta) {
|
|
59
|
-
var id = meta.id;
|
|
60
|
-
this.idNodeMap.set(id, n);
|
|
61
|
-
this.nodeMetaMap.set(n, meta);
|
|
62
|
-
};
|
|
63
|
-
Mirror2.prototype.replace = function(id, n) {
|
|
64
|
-
this.idNodeMap.set(id, n);
|
|
65
|
-
};
|
|
66
|
-
Mirror2.prototype.reset = function() {
|
|
67
|
-
this.idNodeMap = /* @__PURE__ */ new Map();
|
|
68
|
-
this.nodeMetaMap = /* @__PURE__ */ new WeakMap();
|
|
69
|
-
};
|
|
70
|
-
return Mirror2;
|
|
71
|
-
}();
|
|
72
|
-
function createMirror() {
|
|
73
|
-
return new Mirror();
|
|
74
|
-
}
|
|
75
|
-
function maskInputValue(_a) {
|
|
76
|
-
var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;
|
|
77
|
-
var text = value || "";
|
|
78
|
-
if (maskInputOptions[tagName.toLowerCase()] || maskInputOptions[type]) {
|
|
79
|
-
if (maskInputFn) {
|
|
80
|
-
text = maskInputFn(text);
|
|
81
|
-
} else {
|
|
82
|
-
text = "*".repeat(text.length);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return text;
|
|
86
|
-
}
|
|
87
|
-
var ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
|
|
88
|
-
function is2DCanvasBlank(canvas) {
|
|
89
|
-
var ctx = canvas.getContext("2d");
|
|
90
|
-
if (!ctx)
|
|
91
|
-
return true;
|
|
92
|
-
var chunkSize = 50;
|
|
93
|
-
for (var x = 0; x < canvas.width; x += chunkSize) {
|
|
94
|
-
for (var y = 0; y < canvas.height; y += chunkSize) {
|
|
95
|
-
var getImageData = ctx.getImageData;
|
|
96
|
-
var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData ? getImageData[ORIGINAL_ATTRIBUTE_NAME] : getImageData;
|
|
97
|
-
var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);
|
|
98
|
-
if (pixelBuffer.some(function(pixel) {
|
|
99
|
-
return pixel !== 0;
|
|
100
|
-
}))
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
function obfuscateText(text) {
|
|
107
|
-
text = text.replace(/[^ -~]+/g, "");
|
|
108
|
-
text = (text === null || text === void 0 ? void 0 : text.split(" ").map(function(word) {
|
|
109
|
-
return Math.random().toString(20).substr(2, word.length);
|
|
110
|
-
}).join(" ")) || "";
|
|
111
|
-
return text;
|
|
112
|
-
}
|
|
113
|
-
var _id = 1;
|
|
114
|
-
var tagNameRegex = new RegExp("[^a-z0-9-_:]");
|
|
115
|
-
var IGNORED_NODE = -2;
|
|
116
|
-
function genId() {
|
|
117
|
-
return _id++;
|
|
118
|
-
}
|
|
119
|
-
function getValidTagName(element) {
|
|
120
|
-
if (element instanceof HTMLFormElement) {
|
|
121
|
-
return "form";
|
|
122
|
-
}
|
|
123
|
-
var processedTagName = element.tagName.toLowerCase().trim();
|
|
124
|
-
if (tagNameRegex.test(processedTagName)) {
|
|
125
|
-
return "div";
|
|
126
|
-
}
|
|
127
|
-
return processedTagName;
|
|
128
|
-
}
|
|
129
|
-
function getCssRulesString(s) {
|
|
130
|
-
try {
|
|
131
|
-
var rules = s.rules || s.cssRules;
|
|
132
|
-
return rules ? Array.from(rules).map(getCssRuleString).join("") : null;
|
|
133
|
-
} catch (error) {
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
function getCssRuleString(rule) {
|
|
138
|
-
var cssStringified = rule.cssText;
|
|
139
|
-
if (isCSSImportRule(rule)) {
|
|
140
|
-
try {
|
|
141
|
-
cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;
|
|
142
|
-
} catch (_a) {
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return cssStringified;
|
|
146
|
-
}
|
|
147
|
-
function isCSSImportRule(rule) {
|
|
148
|
-
return "styleSheet" in rule;
|
|
149
|
-
}
|
|
150
|
-
function stringifyStyleSheet(sheet) {
|
|
151
|
-
return sheet.cssRules ? Array.from(sheet.cssRules).map(function(rule) {
|
|
152
|
-
return rule.cssText || "";
|
|
153
|
-
}).join("") : "";
|
|
154
|
-
}
|
|
155
|
-
function extractOrigin(url) {
|
|
156
|
-
var origin = "";
|
|
157
|
-
if (url.indexOf("//") > -1) {
|
|
158
|
-
origin = url.split("/").slice(0, 3).join("/");
|
|
159
|
-
} else {
|
|
160
|
-
origin = url.split("/")[0];
|
|
161
|
-
}
|
|
162
|
-
origin = origin.split("?")[0];
|
|
163
|
-
return origin;
|
|
164
|
-
}
|
|
165
|
-
var canvasService;
|
|
166
|
-
var canvasCtx;
|
|
167
|
-
var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
|
|
168
|
-
var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/;
|
|
169
|
-
var DATA_URI = /^(data:)([^,]*),(.*)/i;
|
|
170
|
-
function absoluteToStylesheet(cssText, href) {
|
|
171
|
-
return (cssText || "").replace(URL_IN_CSS_REF, function(origin, quote1, path1, quote2, path2, path3) {
|
|
172
|
-
var filePath = path1 || path2 || path3;
|
|
173
|
-
var maybeQuote = quote1 || quote2 || "";
|
|
174
|
-
if (!filePath) {
|
|
175
|
-
return origin;
|
|
176
|
-
}
|
|
177
|
-
if (!RELATIVE_PATH.test(filePath)) {
|
|
178
|
-
return "url(" + maybeQuote + filePath + maybeQuote + ")";
|
|
179
|
-
}
|
|
180
|
-
if (DATA_URI.test(filePath)) {
|
|
181
|
-
return "url(" + maybeQuote + filePath + maybeQuote + ")";
|
|
182
|
-
}
|
|
183
|
-
if (filePath[0] === "/") {
|
|
184
|
-
return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
|
|
185
|
-
}
|
|
186
|
-
var stack = href.split("/");
|
|
187
|
-
var parts = filePath.split("/");
|
|
188
|
-
stack.pop();
|
|
189
|
-
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
|
|
190
|
-
var part = parts_1[_i];
|
|
191
|
-
if (part === ".") {
|
|
192
|
-
continue;
|
|
193
|
-
} else if (part === "..") {
|
|
194
|
-
stack.pop();
|
|
195
|
-
} else {
|
|
196
|
-
stack.push(part);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return "url(" + maybeQuote + stack.join("/") + maybeQuote + ")";
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
|
|
203
|
-
var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
|
|
204
|
-
function getAbsoluteSrcsetString(doc, attributeValue) {
|
|
205
|
-
if (attributeValue.trim() === "") {
|
|
206
|
-
return attributeValue;
|
|
207
|
-
}
|
|
208
|
-
var pos = 0;
|
|
209
|
-
function collectCharacters(regEx) {
|
|
210
|
-
var chars;
|
|
211
|
-
var match = regEx.exec(attributeValue.substring(pos));
|
|
212
|
-
if (match) {
|
|
213
|
-
chars = match[0];
|
|
214
|
-
pos += chars.length;
|
|
215
|
-
return chars;
|
|
216
|
-
}
|
|
217
|
-
return "";
|
|
218
|
-
}
|
|
219
|
-
var output = [];
|
|
220
|
-
while (true) {
|
|
221
|
-
collectCharacters(SRCSET_COMMAS_OR_SPACES);
|
|
222
|
-
if (pos >= attributeValue.length) {
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
var url = collectCharacters(SRCSET_NOT_SPACES);
|
|
226
|
-
if (url.slice(-1) === ",") {
|
|
227
|
-
url = absoluteToDoc(doc, url.substring(0, url.length - 1));
|
|
228
|
-
output.push(url);
|
|
229
|
-
} else {
|
|
230
|
-
var descriptorsStr = "";
|
|
231
|
-
url = absoluteToDoc(doc, url);
|
|
232
|
-
var inParens = false;
|
|
233
|
-
while (true) {
|
|
234
|
-
var c = attributeValue.charAt(pos);
|
|
235
|
-
if (c === "") {
|
|
236
|
-
output.push((url + descriptorsStr).trim());
|
|
237
|
-
break;
|
|
238
|
-
} else if (!inParens) {
|
|
239
|
-
if (c === ",") {
|
|
240
|
-
pos += 1;
|
|
241
|
-
output.push((url + descriptorsStr).trim());
|
|
242
|
-
break;
|
|
243
|
-
} else if (c === "(") {
|
|
244
|
-
inParens = true;
|
|
245
|
-
}
|
|
246
|
-
} else {
|
|
247
|
-
if (c === ")") {
|
|
248
|
-
inParens = false;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
descriptorsStr += c;
|
|
252
|
-
pos += 1;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
return output.join(", ");
|
|
257
|
-
}
|
|
258
|
-
function absoluteToDoc(doc, attributeValue) {
|
|
259
|
-
if (!attributeValue || attributeValue.trim() === "") {
|
|
260
|
-
return attributeValue;
|
|
261
|
-
}
|
|
262
|
-
var a = doc.createElement("a");
|
|
263
|
-
a.href = attributeValue;
|
|
264
|
-
return a.href;
|
|
265
|
-
}
|
|
266
|
-
function isSVGElement(el) {
|
|
267
|
-
return Boolean(el.tagName === "svg" || el.ownerSVGElement);
|
|
268
|
-
}
|
|
269
|
-
function getHref() {
|
|
270
|
-
var a = document.createElement("a");
|
|
271
|
-
a.href = "";
|
|
272
|
-
return a.href;
|
|
273
|
-
}
|
|
274
|
-
function transformAttribute(doc, tagName, name, value) {
|
|
275
|
-
if (name === "src" || name === "href" && value) {
|
|
276
|
-
return absoluteToDoc(doc, value);
|
|
277
|
-
} else if (name === "xlink:href" && value && value[0] !== "#") {
|
|
278
|
-
return absoluteToDoc(doc, value);
|
|
279
|
-
} else if (name === "background" && value && (tagName === "table" || tagName === "td" || tagName === "th")) {
|
|
280
|
-
return absoluteToDoc(doc, value);
|
|
281
|
-
} else if (name === "srcset" && value) {
|
|
282
|
-
return getAbsoluteSrcsetString(doc, value);
|
|
283
|
-
} else if (name === "style" && value) {
|
|
284
|
-
return absoluteToStylesheet(value, getHref());
|
|
285
|
-
} else if (tagName === "object" && name === "data" && value) {
|
|
286
|
-
return absoluteToDoc(doc, value);
|
|
287
|
-
} else {
|
|
288
|
-
return value;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
function _isBlockedElement(element, blockClass, blockSelector) {
|
|
292
|
-
if (typeof blockClass === "string") {
|
|
293
|
-
if (element.classList.contains(blockClass)) {
|
|
294
|
-
return true;
|
|
295
|
-
}
|
|
296
|
-
} else {
|
|
297
|
-
for (var eIndex = 0; eIndex < element.classList.length; eIndex++) {
|
|
298
|
-
var className = element.classList[eIndex];
|
|
299
|
-
if (blockClass.test(className)) {
|
|
300
|
-
return true;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
if (blockSelector) {
|
|
305
|
-
return element.matches(blockSelector);
|
|
306
|
-
}
|
|
307
|
-
return false;
|
|
308
|
-
}
|
|
309
|
-
function needMaskingText(node, maskTextClass, maskTextSelector) {
|
|
310
|
-
if (!node) {
|
|
311
|
-
return false;
|
|
312
|
-
}
|
|
313
|
-
if (node.nodeType === node.ELEMENT_NODE) {
|
|
314
|
-
if (typeof maskTextClass === "string") {
|
|
315
|
-
if (node.classList.contains(maskTextClass)) {
|
|
316
|
-
return true;
|
|
317
|
-
}
|
|
318
|
-
} else {
|
|
319
|
-
for (var eIndex = 0; eIndex < node.classList.length; eIndex++) {
|
|
320
|
-
var className = node.classList[eIndex];
|
|
321
|
-
if (maskTextClass.test(className)) {
|
|
322
|
-
return true;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
if (maskTextSelector) {
|
|
327
|
-
if (node.matches(maskTextSelector)) {
|
|
328
|
-
return true;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);
|
|
332
|
-
}
|
|
333
|
-
if (node.nodeType === node.TEXT_NODE) {
|
|
334
|
-
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);
|
|
335
|
-
}
|
|
336
|
-
return needMaskingText(node.parentNode, maskTextClass, maskTextSelector);
|
|
337
|
-
}
|
|
338
|
-
function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
|
|
339
|
-
var win = iframeEl.contentWindow;
|
|
340
|
-
if (!win) {
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
var fired = false;
|
|
344
|
-
var readyState;
|
|
345
|
-
try {
|
|
346
|
-
readyState = win.document.readyState;
|
|
347
|
-
} catch (error) {
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
if (readyState !== "complete") {
|
|
351
|
-
var timer_1 = setTimeout(function() {
|
|
352
|
-
if (!fired) {
|
|
353
|
-
listener();
|
|
354
|
-
fired = true;
|
|
355
|
-
}
|
|
356
|
-
}, iframeLoadTimeout);
|
|
357
|
-
iframeEl.addEventListener("load", function() {
|
|
358
|
-
clearTimeout(timer_1);
|
|
359
|
-
fired = true;
|
|
360
|
-
listener();
|
|
361
|
-
});
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
var blankUrl = "about:blank";
|
|
365
|
-
if (win.location.href !== blankUrl || iframeEl.src === blankUrl || iframeEl.src === "") {
|
|
366
|
-
setTimeout(listener, 0);
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
|
-
iframeEl.addEventListener("load", listener);
|
|
370
|
-
}
|
|
371
|
-
function isStylesheetLoaded(link) {
|
|
372
|
-
if (!link.getAttribute("href"))
|
|
373
|
-
return true;
|
|
374
|
-
return link.sheet !== null;
|
|
375
|
-
}
|
|
376
|
-
function onceStylesheetLoaded(link, listener, iframeLoadTimeout) {
|
|
377
|
-
var fired = false;
|
|
378
|
-
var styleSheetLoaded;
|
|
379
|
-
try {
|
|
380
|
-
styleSheetLoaded = link.sheet;
|
|
381
|
-
} catch (error) {
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
if (styleSheetLoaded)
|
|
385
|
-
return;
|
|
386
|
-
var timer = setTimeout(function() {
|
|
387
|
-
if (!fired) {
|
|
388
|
-
listener();
|
|
389
|
-
fired = true;
|
|
390
|
-
}
|
|
391
|
-
}, iframeLoadTimeout);
|
|
392
|
-
link.addEventListener("load", function() {
|
|
393
|
-
clearTimeout(timer);
|
|
394
|
-
fired = true;
|
|
395
|
-
listener();
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
function serializeNode(n, options) {
|
|
399
|
-
var _a;
|
|
400
|
-
var doc = options.doc, mirror = options.mirror, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _b = options.maskInputOptions, maskInputOptions = _b === void 0 ? {} : _b, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _c = options.dataURLOptions, dataURLOptions = _c === void 0 ? {} : _c, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn, enableStrictPrivacy = options.enableStrictPrivacy;
|
|
401
|
-
var rootId;
|
|
402
|
-
if (mirror.getMeta(doc)) {
|
|
403
|
-
var docId = mirror.getId(doc);
|
|
404
|
-
rootId = docId === 1 ? void 0 : docId;
|
|
405
|
-
}
|
|
406
|
-
switch (n.nodeType) {
|
|
407
|
-
case n.DOCUMENT_NODE:
|
|
408
|
-
if (n.compatMode !== "CSS1Compat") {
|
|
409
|
-
return {
|
|
410
|
-
type: NodeType.Document,
|
|
411
|
-
childNodes: [],
|
|
412
|
-
compatMode: n.compatMode,
|
|
413
|
-
rootId
|
|
414
|
-
};
|
|
415
|
-
} else {
|
|
416
|
-
return {
|
|
417
|
-
type: NodeType.Document,
|
|
418
|
-
childNodes: [],
|
|
419
|
-
rootId
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
case n.DOCUMENT_TYPE_NODE:
|
|
423
|
-
return {
|
|
424
|
-
type: NodeType.DocumentType,
|
|
425
|
-
name: n.name,
|
|
426
|
-
publicId: n.publicId,
|
|
427
|
-
systemId: n.systemId,
|
|
428
|
-
rootId
|
|
429
|
-
};
|
|
430
|
-
case n.ELEMENT_NODE:
|
|
431
|
-
var needBlock = _isBlockedElement(n, blockClass, blockSelector);
|
|
432
|
-
var tagName = getValidTagName(n);
|
|
433
|
-
var attributes_1 = {};
|
|
434
|
-
var len = n.attributes.length;
|
|
435
|
-
for (var i = 0; i < len; i++) {
|
|
436
|
-
var attr = n.attributes[i];
|
|
437
|
-
attributes_1[attr.name] = transformAttribute(doc, tagName, attr.name, attr.value);
|
|
438
|
-
}
|
|
439
|
-
if (tagName === "link" && inlineStylesheet) {
|
|
440
|
-
var stylesheet = Array.from(doc.styleSheets).find(function(s) {
|
|
441
|
-
return s.href === n.href;
|
|
442
|
-
});
|
|
443
|
-
var cssText = null;
|
|
444
|
-
if (stylesheet) {
|
|
445
|
-
cssText = getCssRulesString(stylesheet);
|
|
446
|
-
}
|
|
447
|
-
if (cssText) {
|
|
448
|
-
delete attributes_1.rel;
|
|
449
|
-
delete attributes_1.href;
|
|
450
|
-
attributes_1._cssText = absoluteToStylesheet(cssText, stylesheet.href);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
if (tagName === "style" && n.sheet && !(n.innerText || n.textContent || "").trim().length) {
|
|
454
|
-
var cssText = getCssRulesString(n.sheet);
|
|
455
|
-
if (cssText) {
|
|
456
|
-
attributes_1._cssText = absoluteToStylesheet(cssText, getHref());
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
if (tagName === "input" || tagName === "textarea" || tagName === "select") {
|
|
460
|
-
var value = n.value;
|
|
461
|
-
if (attributes_1.type !== "radio" && attributes_1.type !== "checkbox" && attributes_1.type !== "submit" && attributes_1.type !== "button" && value) {
|
|
462
|
-
attributes_1.value = maskInputValue({
|
|
463
|
-
type: attributes_1.type,
|
|
464
|
-
tagName,
|
|
465
|
-
value,
|
|
466
|
-
maskInputOptions,
|
|
467
|
-
maskInputFn
|
|
468
|
-
});
|
|
469
|
-
} else if (n.checked) {
|
|
470
|
-
attributes_1.checked = n.checked;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
if (tagName === "option") {
|
|
474
|
-
if (n.selected && !maskInputOptions["select"]) {
|
|
475
|
-
attributes_1.selected = true;
|
|
476
|
-
} else {
|
|
477
|
-
delete attributes_1.selected;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
if (tagName === "canvas" && recordCanvas) {
|
|
481
|
-
if (n.__context === "2d") {
|
|
482
|
-
if (!is2DCanvasBlank(n)) {
|
|
483
|
-
attributes_1.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
484
|
-
}
|
|
485
|
-
} else if (!("__context" in n)) {
|
|
486
|
-
var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
487
|
-
var blankCanvas = document.createElement("canvas");
|
|
488
|
-
blankCanvas.width = n.width;
|
|
489
|
-
blankCanvas.height = n.height;
|
|
490
|
-
var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
491
|
-
if (canvasDataURL !== blankCanvasDataURL) {
|
|
492
|
-
attributes_1.rr_dataURL = canvasDataURL;
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
if (tagName === "img" && inlineImages) {
|
|
497
|
-
if (!canvasService) {
|
|
498
|
-
canvasService = doc.createElement("canvas");
|
|
499
|
-
canvasCtx = canvasService.getContext("2d");
|
|
500
|
-
}
|
|
501
|
-
var image_1 = n;
|
|
502
|
-
var oldValue_1 = image_1.crossOrigin;
|
|
503
|
-
image_1.crossOrigin = "anonymous";
|
|
504
|
-
var recordInlineImage = function() {
|
|
505
|
-
try {
|
|
506
|
-
canvasService.width = image_1.naturalWidth;
|
|
507
|
-
canvasService.height = image_1.naturalHeight;
|
|
508
|
-
canvasCtx.drawImage(image_1, 0, 0);
|
|
509
|
-
attributes_1.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
510
|
-
} catch (err) {
|
|
511
|
-
console.warn("Cannot inline img src=" + image_1.currentSrc + "! Error: " + err);
|
|
512
|
-
}
|
|
513
|
-
oldValue_1 ? attributes_1.crossOrigin = oldValue_1 : image_1.removeAttribute("crossorigin");
|
|
514
|
-
};
|
|
515
|
-
if (image_1.complete && image_1.naturalWidth !== 0)
|
|
516
|
-
recordInlineImage();
|
|
517
|
-
else
|
|
518
|
-
image_1.onload = recordInlineImage;
|
|
519
|
-
}
|
|
520
|
-
if (tagName === "audio" || tagName === "video") {
|
|
521
|
-
attributes_1.rr_mediaState = n.paused ? "paused" : "played";
|
|
522
|
-
attributes_1.rr_mediaCurrentTime = n.currentTime;
|
|
523
|
-
}
|
|
524
|
-
if (n.scrollLeft) {
|
|
525
|
-
attributes_1.rr_scrollLeft = n.scrollLeft;
|
|
526
|
-
}
|
|
527
|
-
if (n.scrollTop) {
|
|
528
|
-
attributes_1.rr_scrollTop = n.scrollTop;
|
|
529
|
-
}
|
|
530
|
-
if (needBlock || tagName === "img" && enableStrictPrivacy) {
|
|
531
|
-
var _d = n.getBoundingClientRect(), width = _d.width, height = _d.height;
|
|
532
|
-
attributes_1 = {
|
|
533
|
-
"class": attributes_1["class"],
|
|
534
|
-
rr_width: width + "px",
|
|
535
|
-
rr_height: height + "px"
|
|
536
|
-
};
|
|
537
|
-
needBlock = true;
|
|
538
|
-
}
|
|
539
|
-
if (tagName === "iframe" && !keepIframeSrcFn(attributes_1.src)) {
|
|
540
|
-
if (!n.contentDocument) {
|
|
541
|
-
attributes_1.rr_src = attributes_1.src;
|
|
542
|
-
}
|
|
543
|
-
delete attributes_1.src;
|
|
544
|
-
}
|
|
545
|
-
return {
|
|
546
|
-
type: NodeType.Element,
|
|
547
|
-
tagName,
|
|
548
|
-
attributes: attributes_1,
|
|
549
|
-
childNodes: [],
|
|
550
|
-
isSVG: isSVGElement(n) || void 0,
|
|
551
|
-
needBlock,
|
|
552
|
-
rootId
|
|
553
|
-
};
|
|
554
|
-
case n.TEXT_NODE:
|
|
555
|
-
var parentTagName = n.parentNode && n.parentNode.tagName;
|
|
556
|
-
var textContent = n.textContent;
|
|
557
|
-
var isStyle = parentTagName === "STYLE" ? true : void 0;
|
|
558
|
-
var isScript = parentTagName === "SCRIPT" ? true : void 0;
|
|
559
|
-
var textContentHandled = false;
|
|
560
|
-
if (isStyle && textContent) {
|
|
561
|
-
try {
|
|
562
|
-
if (n.nextSibling || n.previousSibling) {
|
|
563
|
-
} else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
|
|
564
|
-
textContent = stringifyStyleSheet(n.parentNode.sheet);
|
|
565
|
-
}
|
|
566
|
-
} catch (err) {
|
|
567
|
-
console.warn("Cannot get CSS styles from text's parentNode. Error: " + err, n);
|
|
568
|
-
}
|
|
569
|
-
textContent = absoluteToStylesheet(textContent, getHref());
|
|
570
|
-
textContentHandled = true;
|
|
571
|
-
}
|
|
572
|
-
if (isScript) {
|
|
573
|
-
textContent = "SCRIPT_PLACEHOLDER";
|
|
574
|
-
textContentHandled = true;
|
|
575
|
-
} else if (parentTagName === "NOSCRIPT") {
|
|
576
|
-
textContent = "";
|
|
577
|
-
textContentHandled = true;
|
|
578
|
-
}
|
|
579
|
-
if (!isStyle && !isScript && needMaskingText(n, maskTextClass, maskTextSelector) && textContent) {
|
|
580
|
-
textContent = maskTextFn ? maskTextFn(textContent) : textContent.replace(/[\S]/g, "*");
|
|
581
|
-
}
|
|
582
|
-
if (enableStrictPrivacy && !textContentHandled && parentTagName) {
|
|
583
|
-
var IGNORE_TAG_NAMES = /* @__PURE__ */ new Set([
|
|
584
|
-
"HEAD",
|
|
585
|
-
"TITLE",
|
|
586
|
-
"STYLE",
|
|
587
|
-
"SCRIPT",
|
|
588
|
-
"HTML",
|
|
589
|
-
"BODY",
|
|
590
|
-
"NOSCRIPT"
|
|
591
|
-
]);
|
|
592
|
-
if (!IGNORE_TAG_NAMES.has(parentTagName) && textContent) {
|
|
593
|
-
textContent = obfuscateText(textContent);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
return {
|
|
597
|
-
type: NodeType.Text,
|
|
598
|
-
textContent: textContent || "",
|
|
599
|
-
isStyle,
|
|
600
|
-
rootId
|
|
601
|
-
};
|
|
602
|
-
case n.CDATA_SECTION_NODE:
|
|
603
|
-
return {
|
|
604
|
-
type: NodeType.CDATA,
|
|
605
|
-
textContent: "",
|
|
606
|
-
rootId
|
|
607
|
-
};
|
|
608
|
-
case n.COMMENT_NODE:
|
|
609
|
-
return {
|
|
610
|
-
type: NodeType.Comment,
|
|
611
|
-
textContent: n.textContent || "",
|
|
612
|
-
rootId
|
|
613
|
-
};
|
|
614
|
-
default:
|
|
615
|
-
return false;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
function lowerIfExists(maybeAttr) {
|
|
619
|
-
if (maybeAttr === void 0) {
|
|
620
|
-
return "";
|
|
621
|
-
} else {
|
|
622
|
-
return maybeAttr.toLowerCase();
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
function slimDOMExcluded(sn, slimDOMOptions) {
|
|
626
|
-
if (slimDOMOptions.comment && sn.type === NodeType.Comment) {
|
|
627
|
-
return true;
|
|
628
|
-
} else if (sn.type === NodeType.Element) {
|
|
629
|
-
if (slimDOMOptions.script && (sn.tagName === "script" || sn.tagName === "link" && sn.attributes.rel === "preload" && sn.attributes.as === "script" || sn.tagName === "link" && sn.attributes.rel === "prefetch" && typeof sn.attributes.href === "string" && sn.attributes.href.endsWith(".js"))) {
|
|
630
|
-
return true;
|
|
631
|
-
} else if (slimDOMOptions.headFavicon && (sn.tagName === "link" && sn.attributes.rel === "shortcut icon" || sn.tagName === "meta" && (lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) || lowerIfExists(sn.attributes.name) === "application-name" || lowerIfExists(sn.attributes.rel) === "icon" || lowerIfExists(sn.attributes.rel) === "apple-touch-icon" || lowerIfExists(sn.attributes.rel) === "shortcut icon"))) {
|
|
632
|
-
return true;
|
|
633
|
-
} else if (sn.tagName === "meta") {
|
|
634
|
-
if (slimDOMOptions.headMetaDescKeywords && lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
|
|
635
|
-
return true;
|
|
636
|
-
} else if (slimDOMOptions.headMetaSocial && (lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) || lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) || lowerIfExists(sn.attributes.name) === "pinterest")) {
|
|
637
|
-
return true;
|
|
638
|
-
} else if (slimDOMOptions.headMetaRobots && (lowerIfExists(sn.attributes.name) === "robots" || lowerIfExists(sn.attributes.name) === "googlebot" || lowerIfExists(sn.attributes.name) === "bingbot")) {
|
|
639
|
-
return true;
|
|
640
|
-
} else if (slimDOMOptions.headMetaHttpEquiv && sn.attributes["http-equiv"] !== void 0) {
|
|
641
|
-
return true;
|
|
642
|
-
} else if (slimDOMOptions.headMetaAuthorship && (lowerIfExists(sn.attributes.name) === "author" || lowerIfExists(sn.attributes.name) === "generator" || lowerIfExists(sn.attributes.name) === "framework" || lowerIfExists(sn.attributes.name) === "publisher" || lowerIfExists(sn.attributes.name) === "progid" || lowerIfExists(sn.attributes.property).match(/^article:/) || lowerIfExists(sn.attributes.property).match(/^product:/))) {
|
|
643
|
-
return true;
|
|
644
|
-
} else if (slimDOMOptions.headMetaVerification && (lowerIfExists(sn.attributes.name) === "google-site-verification" || lowerIfExists(sn.attributes.name) === "yandex-verification" || lowerIfExists(sn.attributes.name) === "csrf-token" || lowerIfExists(sn.attributes.name) === "p:domain_verify" || lowerIfExists(sn.attributes.name) === "verify-v1" || lowerIfExists(sn.attributes.name) === "verification" || lowerIfExists(sn.attributes.name) === "shopify-checkout-api-token")) {
|
|
645
|
-
return true;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
return false;
|
|
650
|
-
}
|
|
651
|
-
function serializeNodeWithId(n, options) {
|
|
652
|
-
var doc = options.doc, mirror = options.mirror, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.inlineStylesheet, inlineStylesheet = _b === void 0 ? true : _b, _c = options.maskInputOptions, maskInputOptions = _c === void 0 ? {} : _c, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, slimDOMOptions = options.slimDOMOptions, _d = options.dataURLOptions, dataURLOptions = _d === void 0 ? {} : _d, _e = options.inlineImages, inlineImages = _e === void 0 ? false : _e, _f = options.recordCanvas, recordCanvas = _f === void 0 ? false : _f, onSerialize = options.onSerialize, onIframeLoad = options.onIframeLoad, _g = options.iframeLoadTimeout, iframeLoadTimeout = _g === void 0 ? 5e3 : _g, onStylesheetLoad = options.onStylesheetLoad, _h = options.stylesheetLoadTimeout, stylesheetLoadTimeout = _h === void 0 ? 5e3 : _h, _j = options.keepIframeSrcFn, keepIframeSrcFn = _j === void 0 ? function() {
|
|
653
|
-
return false;
|
|
654
|
-
} : _j, enableStrictPrivacy = options.enableStrictPrivacy;
|
|
655
|
-
var _k = options.preserveWhiteSpace, preserveWhiteSpace = _k === void 0 ? true : _k;
|
|
656
|
-
var _serializedNode = serializeNode(n, {
|
|
657
|
-
doc,
|
|
658
|
-
mirror,
|
|
659
|
-
blockClass,
|
|
660
|
-
blockSelector,
|
|
661
|
-
maskTextClass,
|
|
662
|
-
maskTextSelector,
|
|
663
|
-
inlineStylesheet,
|
|
664
|
-
maskInputOptions,
|
|
665
|
-
maskTextFn,
|
|
666
|
-
maskInputFn,
|
|
667
|
-
dataURLOptions,
|
|
668
|
-
inlineImages,
|
|
669
|
-
recordCanvas,
|
|
670
|
-
keepIframeSrcFn,
|
|
671
|
-
enableStrictPrivacy
|
|
672
|
-
});
|
|
673
|
-
if (!_serializedNode) {
|
|
674
|
-
console.warn(n, "not serialized");
|
|
675
|
-
return null;
|
|
676
|
-
}
|
|
677
|
-
var id;
|
|
678
|
-
if (mirror.hasNode(n)) {
|
|
679
|
-
id = mirror.getId(n);
|
|
680
|
-
} else if (slimDOMExcluded(_serializedNode, slimDOMOptions) || !preserveWhiteSpace && _serializedNode.type === NodeType.Text && !_serializedNode.isStyle && !_serializedNode.textContent.replace(/^\s+|\s+$/gm, "").length) {
|
|
681
|
-
id = IGNORED_NODE;
|
|
682
|
-
} else {
|
|
683
|
-
id = genId();
|
|
684
|
-
}
|
|
685
|
-
if (id === IGNORED_NODE) {
|
|
686
|
-
return null;
|
|
687
|
-
}
|
|
688
|
-
var serializedNode = Object.assign(_serializedNode, { id });
|
|
689
|
-
mirror.add(n, serializedNode);
|
|
690
|
-
if (onSerialize) {
|
|
691
|
-
onSerialize(n);
|
|
692
|
-
}
|
|
693
|
-
var recordChild = !skipChild;
|
|
694
|
-
if (serializedNode.type === NodeType.Element) {
|
|
695
|
-
recordChild = recordChild && !serializedNode.needBlock;
|
|
696
|
-
if (serializedNode.needBlock && serializedNode.tagName === "img") {
|
|
697
|
-
var clone = n.cloneNode();
|
|
698
|
-
clone.src = "";
|
|
699
|
-
mirror.add(clone, serializedNode);
|
|
700
|
-
}
|
|
701
|
-
if (serializedNode.tagName === "link") {
|
|
702
|
-
var clone = n.cloneNode();
|
|
703
|
-
clone.href = "";
|
|
704
|
-
clone.innerText = serializedNode.attributes._cssText;
|
|
705
|
-
mirror.add(clone, serializedNode);
|
|
706
|
-
}
|
|
707
|
-
delete serializedNode.needBlock;
|
|
708
|
-
if (n.shadowRoot)
|
|
709
|
-
serializedNode.isShadowHost = true;
|
|
710
|
-
}
|
|
711
|
-
if ((serializedNode.type === NodeType.Document || serializedNode.type === NodeType.Element) && recordChild) {
|
|
712
|
-
if (slimDOMOptions.headWhitespace && serializedNode.type === NodeType.Element && serializedNode.tagName === "head") {
|
|
713
|
-
preserveWhiteSpace = false;
|
|
714
|
-
}
|
|
715
|
-
var bypassOptions = {
|
|
716
|
-
doc,
|
|
717
|
-
mirror,
|
|
718
|
-
blockClass,
|
|
719
|
-
blockSelector,
|
|
720
|
-
maskTextClass,
|
|
721
|
-
maskTextSelector,
|
|
722
|
-
skipChild,
|
|
723
|
-
inlineStylesheet,
|
|
724
|
-
maskInputOptions,
|
|
725
|
-
maskTextFn,
|
|
726
|
-
maskInputFn,
|
|
727
|
-
slimDOMOptions,
|
|
728
|
-
dataURLOptions,
|
|
729
|
-
inlineImages,
|
|
730
|
-
recordCanvas,
|
|
731
|
-
preserveWhiteSpace,
|
|
732
|
-
onSerialize,
|
|
733
|
-
onIframeLoad,
|
|
734
|
-
iframeLoadTimeout,
|
|
735
|
-
onStylesheetLoad,
|
|
736
|
-
stylesheetLoadTimeout,
|
|
737
|
-
keepIframeSrcFn,
|
|
738
|
-
enableStrictPrivacy
|
|
739
|
-
};
|
|
740
|
-
for (var _i = 0, _l = Array.from(n.childNodes); _i < _l.length; _i++) {
|
|
741
|
-
var childN = _l[_i];
|
|
742
|
-
var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
743
|
-
if (serializedChildNode) {
|
|
744
|
-
serializedNode.childNodes.push(serializedChildNode);
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
if (isElement(n) && n.shadowRoot) {
|
|
748
|
-
for (var _m = 0, _o = Array.from(n.shadowRoot.childNodes); _m < _o.length; _m++) {
|
|
749
|
-
var childN = _o[_m];
|
|
750
|
-
var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
751
|
-
if (serializedChildNode) {
|
|
752
|
-
serializedChildNode.isShadow = true;
|
|
753
|
-
serializedNode.childNodes.push(serializedChildNode);
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
if (n.parentNode && isShadowRoot(n.parentNode)) {
|
|
759
|
-
serializedNode.isShadow = true;
|
|
760
|
-
}
|
|
761
|
-
if (serializedNode.type === NodeType.Element && serializedNode.tagName === "iframe") {
|
|
762
|
-
onceIframeLoaded(n, function() {
|
|
763
|
-
var iframeDoc = n.contentDocument;
|
|
764
|
-
if (iframeDoc && onIframeLoad) {
|
|
765
|
-
var serializedIframeNode = serializeNodeWithId(iframeDoc, {
|
|
766
|
-
doc: iframeDoc,
|
|
767
|
-
mirror,
|
|
768
|
-
blockClass,
|
|
769
|
-
blockSelector,
|
|
770
|
-
maskTextClass,
|
|
771
|
-
maskTextSelector,
|
|
772
|
-
skipChild: false,
|
|
773
|
-
inlineStylesheet,
|
|
774
|
-
maskInputOptions,
|
|
775
|
-
maskTextFn,
|
|
776
|
-
maskInputFn,
|
|
777
|
-
slimDOMOptions,
|
|
778
|
-
dataURLOptions,
|
|
779
|
-
inlineImages,
|
|
780
|
-
recordCanvas,
|
|
781
|
-
preserveWhiteSpace,
|
|
782
|
-
onSerialize,
|
|
783
|
-
onIframeLoad,
|
|
784
|
-
iframeLoadTimeout,
|
|
785
|
-
keepIframeSrcFn,
|
|
786
|
-
enableStrictPrivacy
|
|
787
|
-
});
|
|
788
|
-
if (serializedIframeNode) {
|
|
789
|
-
onIframeLoad(n, serializedIframeNode);
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
}, iframeLoadTimeout);
|
|
793
|
-
}
|
|
794
|
-
if (serializedNode.type === NodeType.Element && serializedNode.tagName === "link" && serializedNode.attributes.rel === "stylesheet") {
|
|
795
|
-
onceStylesheetLoaded(n, function() {
|
|
796
|
-
if (onStylesheetLoad) {
|
|
797
|
-
var serializedLinkNode = serializeNodeWithId(n, {
|
|
798
|
-
doc,
|
|
799
|
-
mirror,
|
|
800
|
-
blockClass,
|
|
801
|
-
blockSelector,
|
|
802
|
-
maskTextClass,
|
|
803
|
-
maskTextSelector,
|
|
804
|
-
skipChild: false,
|
|
805
|
-
inlineStylesheet,
|
|
806
|
-
maskInputOptions,
|
|
807
|
-
maskTextFn,
|
|
808
|
-
maskInputFn,
|
|
809
|
-
slimDOMOptions,
|
|
810
|
-
dataURLOptions,
|
|
811
|
-
inlineImages,
|
|
812
|
-
recordCanvas,
|
|
813
|
-
preserveWhiteSpace,
|
|
814
|
-
onSerialize,
|
|
815
|
-
onIframeLoad,
|
|
816
|
-
onStylesheetLoad,
|
|
817
|
-
iframeLoadTimeout,
|
|
818
|
-
keepIframeSrcFn,
|
|
819
|
-
enableStrictPrivacy
|
|
820
|
-
});
|
|
821
|
-
if (serializedLinkNode) {
|
|
822
|
-
onStylesheetLoad(n, serializedLinkNode);
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
}, stylesheetLoadTimeout);
|
|
826
|
-
if (isStylesheetLoaded(n) === false)
|
|
827
|
-
return null;
|
|
828
|
-
}
|
|
829
|
-
return serializedNode;
|
|
830
|
-
}
|
|
831
|
-
function snapshot(n, options) {
|
|
832
|
-
var _a = options || {}, _b = _a.mirror, mirror = _b === void 0 ? new Mirror() : _b, _c = _a.blockClass, blockClass = _c === void 0 ? "highlight-block" : _c, _d = _a.blockSelector, blockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? "highlight-mask" : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.inlineStylesheet, inlineStylesheet = _g === void 0 ? true : _g, _h = _a.inlineImages, inlineImages = _h === void 0 ? false : _h, _j = _a.recordCanvas, recordCanvas = _j === void 0 ? false : _j, _k = _a.maskAllInputs, maskAllInputs = _k === void 0 ? false : _k, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _l = _a.slimDOM, slimDOM = _l === void 0 ? false : _l, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, onStylesheetLoad = _a.onStylesheetLoad, stylesheetLoadTimeout = _a.stylesheetLoadTimeout, _m = _a.keepIframeSrcFn, keepIframeSrcFn = _m === void 0 ? function() {
|
|
833
|
-
return false;
|
|
834
|
-
} : _m, _o = _a.enableStrictPrivacy, enableStrictPrivacy = _o === void 0 ? false : _o;
|
|
835
|
-
var maskInputOptions = maskAllInputs === true ? {
|
|
836
|
-
color: true,
|
|
837
|
-
date: true,
|
|
838
|
-
"datetime-local": true,
|
|
839
|
-
email: true,
|
|
840
|
-
month: true,
|
|
841
|
-
number: true,
|
|
842
|
-
range: true,
|
|
843
|
-
search: true,
|
|
844
|
-
tel: true,
|
|
845
|
-
text: true,
|
|
846
|
-
time: true,
|
|
847
|
-
url: true,
|
|
848
|
-
week: true,
|
|
849
|
-
textarea: true,
|
|
850
|
-
select: true,
|
|
851
|
-
password: true
|
|
852
|
-
} : maskAllInputs === false ? {
|
|
853
|
-
password: true
|
|
854
|
-
} : maskAllInputs;
|
|
855
|
-
var slimDOMOptions = slimDOM === true || slimDOM === "all" ? {
|
|
856
|
-
script: true,
|
|
857
|
-
comment: true,
|
|
858
|
-
headFavicon: true,
|
|
859
|
-
headWhitespace: true,
|
|
860
|
-
headMetaDescKeywords: slimDOM === "all",
|
|
861
|
-
headMetaSocial: true,
|
|
862
|
-
headMetaRobots: true,
|
|
863
|
-
headMetaHttpEquiv: true,
|
|
864
|
-
headMetaAuthorship: true,
|
|
865
|
-
headMetaVerification: true
|
|
866
|
-
} : slimDOM === false ? {} : slimDOM;
|
|
867
|
-
return serializeNodeWithId(n, {
|
|
868
|
-
doc: n,
|
|
869
|
-
mirror,
|
|
870
|
-
blockClass,
|
|
871
|
-
blockSelector,
|
|
872
|
-
maskTextClass,
|
|
873
|
-
maskTextSelector,
|
|
874
|
-
skipChild: false,
|
|
875
|
-
inlineStylesheet,
|
|
876
|
-
maskInputOptions,
|
|
877
|
-
maskTextFn,
|
|
878
|
-
maskInputFn,
|
|
879
|
-
slimDOMOptions,
|
|
880
|
-
dataURLOptions,
|
|
881
|
-
inlineImages,
|
|
882
|
-
recordCanvas,
|
|
883
|
-
preserveWhiteSpace,
|
|
884
|
-
onSerialize,
|
|
885
|
-
onIframeLoad,
|
|
886
|
-
iframeLoadTimeout,
|
|
887
|
-
onStylesheetLoad,
|
|
888
|
-
stylesheetLoadTimeout,
|
|
889
|
-
keepIframeSrcFn,
|
|
890
|
-
enableStrictPrivacy
|
|
891
|
-
});
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
function on(type, fn, target = document) {
|
|
895
|
-
const options = { capture: true, passive: true };
|
|
896
|
-
target.addEventListener(type, fn, options);
|
|
897
|
-
return () => target.removeEventListener(type, fn, options);
|
|
898
|
-
}
|
|
899
|
-
const DEPARTED_MIRROR_ACCESS_WARNING = "Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";
|
|
900
|
-
let _mirror = {
|
|
901
|
-
map: {},
|
|
902
|
-
getId() {
|
|
903
|
-
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
904
|
-
return -1;
|
|
905
|
-
},
|
|
906
|
-
getNode() {
|
|
907
|
-
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
908
|
-
return null;
|
|
909
|
-
},
|
|
910
|
-
removeNodeFromMap() {
|
|
911
|
-
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
912
|
-
},
|
|
913
|
-
has() {
|
|
914
|
-
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
915
|
-
return false;
|
|
916
|
-
},
|
|
917
|
-
reset() {
|
|
918
|
-
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
919
|
-
}
|
|
920
|
-
};
|
|
921
|
-
if (typeof window !== "undefined" && window.Proxy && window.Reflect) {
|
|
922
|
-
_mirror = new Proxy(_mirror, {
|
|
923
|
-
get(target, prop, receiver) {
|
|
924
|
-
if (prop === "map") {
|
|
925
|
-
console.error(DEPARTED_MIRROR_ACCESS_WARNING);
|
|
926
|
-
}
|
|
927
|
-
return Reflect.get(target, prop, receiver);
|
|
928
|
-
}
|
|
929
|
-
});
|
|
930
|
-
}
|
|
931
|
-
function throttle(func, wait, options = {}) {
|
|
932
|
-
let timeout = null;
|
|
933
|
-
let previous = 0;
|
|
934
|
-
return function(arg) {
|
|
935
|
-
const now = Date.now();
|
|
936
|
-
if (!previous && options.leading === false) {
|
|
937
|
-
previous = now;
|
|
938
|
-
}
|
|
939
|
-
const remaining = wait - (now - previous);
|
|
940
|
-
const context = this;
|
|
941
|
-
const args = arguments;
|
|
942
|
-
if (remaining <= 0 || remaining > wait) {
|
|
943
|
-
if (timeout) {
|
|
944
|
-
clearTimeout(timeout);
|
|
945
|
-
timeout = null;
|
|
946
|
-
}
|
|
947
|
-
previous = now;
|
|
948
|
-
func.apply(context, args);
|
|
949
|
-
} else if (!timeout && options.trailing !== false) {
|
|
950
|
-
timeout = setTimeout(() => {
|
|
951
|
-
previous = options.leading === false ? 0 : Date.now();
|
|
952
|
-
timeout = null;
|
|
953
|
-
func.apply(context, args);
|
|
954
|
-
}, remaining);
|
|
955
|
-
}
|
|
956
|
-
};
|
|
957
|
-
}
|
|
958
|
-
function hookSetter(target, key, d, isRevoked, win = window) {
|
|
959
|
-
const original = win.Object.getOwnPropertyDescriptor(target, key);
|
|
960
|
-
win.Object.defineProperty(target, key, isRevoked ? d : {
|
|
961
|
-
set(value) {
|
|
962
|
-
setTimeout(() => {
|
|
963
|
-
d.set.call(this, value);
|
|
964
|
-
}, 0);
|
|
965
|
-
if (original && original.set) {
|
|
966
|
-
original.set.call(this, value);
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
});
|
|
970
|
-
return () => hookSetter(target, key, original || {}, true);
|
|
971
|
-
}
|
|
972
|
-
function patch(source, name, replacement) {
|
|
973
|
-
try {
|
|
974
|
-
if (!(name in source)) {
|
|
975
|
-
return () => {
|
|
976
|
-
};
|
|
977
|
-
}
|
|
978
|
-
const original = source[name];
|
|
979
|
-
const wrapped = replacement(original);
|
|
980
|
-
if (typeof wrapped === "function") {
|
|
981
|
-
wrapped.prototype = wrapped.prototype || {};
|
|
982
|
-
Object.defineProperties(wrapped, {
|
|
983
|
-
__rrweb_original__: {
|
|
984
|
-
enumerable: false,
|
|
985
|
-
value: original
|
|
986
|
-
}
|
|
987
|
-
});
|
|
988
|
-
}
|
|
989
|
-
source[name] = wrapped;
|
|
990
|
-
return () => {
|
|
991
|
-
source[name] = original;
|
|
992
|
-
};
|
|
993
|
-
} catch (e) {
|
|
994
|
-
return () => {
|
|
995
|
-
};
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
function getWindowHeight() {
|
|
999
|
-
return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body && document.body.clientHeight;
|
|
1000
|
-
}
|
|
1001
|
-
function getWindowWidth() {
|
|
1002
|
-
return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body && document.body.clientWidth;
|
|
1003
|
-
}
|
|
1004
|
-
const isCanvasNode = (node) => {
|
|
1005
|
-
try {
|
|
1006
|
-
if (node instanceof HTMLElement) {
|
|
1007
|
-
return node.tagName === "CANVAS";
|
|
1008
|
-
}
|
|
1009
|
-
} catch (e) {
|
|
1010
|
-
return false;
|
|
1011
|
-
}
|
|
1012
|
-
return false;
|
|
1013
|
-
};
|
|
1014
|
-
function isBlocked(node, blockClass) {
|
|
1015
|
-
if (!node) {
|
|
1016
|
-
return false;
|
|
1017
|
-
}
|
|
1018
|
-
if (node.nodeType === node.ELEMENT_NODE) {
|
|
1019
|
-
let needBlock = false;
|
|
1020
|
-
if (typeof blockClass === "string") {
|
|
1021
|
-
if (node.closest !== void 0) {
|
|
1022
|
-
return node.closest("." + blockClass) !== null;
|
|
1023
|
-
} else {
|
|
1024
|
-
needBlock = node.classList.contains(blockClass);
|
|
1025
|
-
}
|
|
1026
|
-
} else {
|
|
1027
|
-
node.classList.forEach((className) => {
|
|
1028
|
-
if (blockClass.test(className)) {
|
|
1029
|
-
needBlock = true;
|
|
1030
|
-
}
|
|
1031
|
-
});
|
|
1032
|
-
}
|
|
1033
|
-
return needBlock || isBlocked(node.parentNode, blockClass);
|
|
1034
|
-
}
|
|
1035
|
-
if (node.nodeType === node.TEXT_NODE) {
|
|
1036
|
-
return isBlocked(node.parentNode, blockClass);
|
|
1037
|
-
}
|
|
1038
|
-
return isBlocked(node.parentNode, blockClass);
|
|
1039
|
-
}
|
|
1040
|
-
function isSerialized(n, mirror) {
|
|
1041
|
-
return mirror.getId(n) !== -1;
|
|
1042
|
-
}
|
|
1043
|
-
function isIgnored(n, mirror) {
|
|
1044
|
-
return mirror.getId(n) === IGNORED_NODE;
|
|
1045
|
-
}
|
|
1046
|
-
function isAncestorRemoved(target, mirror) {
|
|
1047
|
-
if (isShadowRoot(target)) {
|
|
1048
|
-
return false;
|
|
1049
|
-
}
|
|
1050
|
-
const id = mirror.getId(target);
|
|
1051
|
-
if (!mirror.has(id)) {
|
|
1052
|
-
return true;
|
|
1053
|
-
}
|
|
1054
|
-
if (target.parentNode && target.parentNode.nodeType === target.DOCUMENT_NODE) {
|
|
1055
|
-
return false;
|
|
1056
|
-
}
|
|
1057
|
-
if (!target.parentNode) {
|
|
1058
|
-
return true;
|
|
1059
|
-
}
|
|
1060
|
-
return isAncestorRemoved(target.parentNode, mirror);
|
|
1061
|
-
}
|
|
1062
|
-
function isTouchEvent(event) {
|
|
1063
|
-
return Boolean(event.changedTouches);
|
|
1064
|
-
}
|
|
1065
|
-
function polyfill(win = window) {
|
|
1066
|
-
if ("NodeList" in win && !win.NodeList.prototype.forEach) {
|
|
1067
|
-
win.NodeList.prototype.forEach = Array.prototype.forEach;
|
|
1068
|
-
}
|
|
1069
|
-
if ("DOMTokenList" in win && !win.DOMTokenList.prototype.forEach) {
|
|
1070
|
-
win.DOMTokenList.prototype.forEach = Array.prototype.forEach;
|
|
1071
|
-
}
|
|
1072
|
-
if (!Node.prototype.contains) {
|
|
1073
|
-
Node.prototype.contains = function contains(node) {
|
|
1074
|
-
if (!(0 in arguments)) {
|
|
1075
|
-
throw new TypeError("1 argument is required");
|
|
1076
|
-
}
|
|
1077
|
-
do {
|
|
1078
|
-
if (this === node) {
|
|
1079
|
-
return true;
|
|
1080
|
-
}
|
|
1081
|
-
} while (node = node && node.parentNode);
|
|
1082
|
-
return false;
|
|
1083
|
-
};
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
function isSerializedIframe(n, mirror) {
|
|
1087
|
-
return Boolean(n.nodeName === "IFRAME" && mirror.getMeta(n));
|
|
1088
|
-
}
|
|
1089
|
-
function isSerializedStylesheet(n, mirror) {
|
|
1090
|
-
return Boolean(n.nodeName === "LINK" && n.nodeType === n.ELEMENT_NODE && n.getAttribute && n.getAttribute("rel") === "stylesheet" && mirror.getMeta(n));
|
|
1091
|
-
}
|
|
1092
|
-
function hasShadowRoot(n) {
|
|
1093
|
-
return Boolean(n == null ? void 0 : n.shadowRoot);
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
1097
|
-
EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
|
|
1098
|
-
EventType2[EventType2["Load"] = 1] = "Load";
|
|
1099
|
-
EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
|
|
1100
|
-
EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
|
|
1101
|
-
EventType2[EventType2["Meta"] = 4] = "Meta";
|
|
1102
|
-
EventType2[EventType2["Custom"] = 5] = "Custom";
|
|
1103
|
-
EventType2[EventType2["Plugin"] = 6] = "Plugin";
|
|
1104
|
-
return EventType2;
|
|
1105
|
-
})(EventType || {});
|
|
1106
|
-
var IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => {
|
|
1107
|
-
IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
|
|
1108
|
-
IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
|
|
1109
|
-
IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
|
|
1110
|
-
IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
|
|
1111
|
-
IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
|
|
1112
|
-
IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
|
|
1113
|
-
IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
|
|
1114
|
-
IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
|
|
1115
|
-
IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
|
|
1116
|
-
IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
|
|
1117
|
-
IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
|
|
1118
|
-
IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
|
|
1119
|
-
IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
|
|
1120
|
-
IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
|
|
1121
|
-
return IncrementalSource2;
|
|
1122
|
-
})(IncrementalSource || {});
|
|
1123
|
-
var MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {
|
|
1124
|
-
MouseInteractions2[MouseInteractions2["MouseUp"] = 0] = "MouseUp";
|
|
1125
|
-
MouseInteractions2[MouseInteractions2["MouseDown"] = 1] = "MouseDown";
|
|
1126
|
-
MouseInteractions2[MouseInteractions2["Click"] = 2] = "Click";
|
|
1127
|
-
MouseInteractions2[MouseInteractions2["ContextMenu"] = 3] = "ContextMenu";
|
|
1128
|
-
MouseInteractions2[MouseInteractions2["DblClick"] = 4] = "DblClick";
|
|
1129
|
-
MouseInteractions2[MouseInteractions2["Focus"] = 5] = "Focus";
|
|
1130
|
-
MouseInteractions2[MouseInteractions2["Blur"] = 6] = "Blur";
|
|
1131
|
-
MouseInteractions2[MouseInteractions2["TouchStart"] = 7] = "TouchStart";
|
|
1132
|
-
MouseInteractions2[MouseInteractions2["TouchMove_Departed"] = 8] = "TouchMove_Departed";
|
|
1133
|
-
MouseInteractions2[MouseInteractions2["TouchEnd"] = 9] = "TouchEnd";
|
|
1134
|
-
MouseInteractions2[MouseInteractions2["TouchCancel"] = 10] = "TouchCancel";
|
|
1135
|
-
return MouseInteractions2;
|
|
1136
|
-
})(MouseInteractions || {});
|
|
1137
|
-
var CanvasContext = /* @__PURE__ */ ((CanvasContext2) => {
|
|
1138
|
-
CanvasContext2[CanvasContext2["2D"] = 0] = "2D";
|
|
1139
|
-
CanvasContext2[CanvasContext2["WebGL"] = 1] = "WebGL";
|
|
1140
|
-
CanvasContext2[CanvasContext2["WebGL2"] = 2] = "WebGL2";
|
|
1141
|
-
return CanvasContext2;
|
|
1142
|
-
})(CanvasContext || {});
|
|
1143
|
-
var MediaInteractions = /* @__PURE__ */ ((MediaInteractions2) => {
|
|
1144
|
-
MediaInteractions2[MediaInteractions2["Play"] = 0] = "Play";
|
|
1145
|
-
MediaInteractions2[MediaInteractions2["Pause"] = 1] = "Pause";
|
|
1146
|
-
MediaInteractions2[MediaInteractions2["Seeked"] = 2] = "Seeked";
|
|
1147
|
-
MediaInteractions2[MediaInteractions2["VolumeChange"] = 3] = "VolumeChange";
|
|
1148
|
-
return MediaInteractions2;
|
|
1149
|
-
})(MediaInteractions || {});
|
|
1150
|
-
|
|
1151
|
-
function isNodeInLinkedList(n) {
|
|
1152
|
-
return "__ln" in n;
|
|
1153
|
-
}
|
|
1154
|
-
class DoubleLinkedList {
|
|
1155
|
-
constructor() {
|
|
1156
|
-
this.length = 0;
|
|
1157
|
-
this.head = null;
|
|
1158
|
-
}
|
|
1159
|
-
get(position) {
|
|
1160
|
-
if (position >= this.length) {
|
|
1161
|
-
throw new Error("Position outside of list range");
|
|
1162
|
-
}
|
|
1163
|
-
let current = this.head;
|
|
1164
|
-
for (let index = 0; index < position; index++) {
|
|
1165
|
-
current = (current == null ? void 0 : current.next) || null;
|
|
1166
|
-
}
|
|
1167
|
-
return current;
|
|
1168
|
-
}
|
|
1169
|
-
addNode(n) {
|
|
1170
|
-
const node = {
|
|
1171
|
-
value: n,
|
|
1172
|
-
previous: null,
|
|
1173
|
-
next: null
|
|
1174
|
-
};
|
|
1175
|
-
n.__ln = node;
|
|
1176
|
-
if (n.previousSibling && isNodeInLinkedList(n.previousSibling)) {
|
|
1177
|
-
const current = n.previousSibling.__ln.next;
|
|
1178
|
-
node.next = current;
|
|
1179
|
-
node.previous = n.previousSibling.__ln;
|
|
1180
|
-
n.previousSibling.__ln.next = node;
|
|
1181
|
-
if (current) {
|
|
1182
|
-
current.previous = node;
|
|
1183
|
-
}
|
|
1184
|
-
} else if (n.nextSibling && isNodeInLinkedList(n.nextSibling) && n.nextSibling.__ln.previous) {
|
|
1185
|
-
const current = n.nextSibling.__ln.previous;
|
|
1186
|
-
node.previous = current;
|
|
1187
|
-
node.next = n.nextSibling.__ln;
|
|
1188
|
-
n.nextSibling.__ln.previous = node;
|
|
1189
|
-
if (current) {
|
|
1190
|
-
current.next = node;
|
|
1191
|
-
}
|
|
1192
|
-
} else {
|
|
1193
|
-
if (this.head) {
|
|
1194
|
-
this.head.previous = node;
|
|
1195
|
-
}
|
|
1196
|
-
node.next = this.head;
|
|
1197
|
-
this.head = node;
|
|
1198
|
-
}
|
|
1199
|
-
this.length++;
|
|
1200
|
-
}
|
|
1201
|
-
removeNode(n) {
|
|
1202
|
-
const current = n.__ln;
|
|
1203
|
-
if (!this.head) {
|
|
1204
|
-
return;
|
|
1205
|
-
}
|
|
1206
|
-
if (!current.previous) {
|
|
1207
|
-
this.head = current.next;
|
|
1208
|
-
if (this.head) {
|
|
1209
|
-
this.head.previous = null;
|
|
1210
|
-
}
|
|
1211
|
-
} else {
|
|
1212
|
-
current.previous.next = current.next;
|
|
1213
|
-
if (current.next) {
|
|
1214
|
-
current.next.previous = current.previous;
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
if (n.__ln) {
|
|
1218
|
-
delete n.__ln;
|
|
1219
|
-
}
|
|
1220
|
-
this.length--;
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
const moveKey = (id, parentId) => `${id}@${parentId}`;
|
|
1224
|
-
class MutationBuffer {
|
|
1225
|
-
constructor() {
|
|
1226
|
-
this.frozen = false;
|
|
1227
|
-
this.locked = false;
|
|
1228
|
-
this.texts = [];
|
|
1229
|
-
this.attributes = [];
|
|
1230
|
-
this.removes = [];
|
|
1231
|
-
this.mapRemoves = [];
|
|
1232
|
-
this.movedMap = {};
|
|
1233
|
-
this.addedSet = /* @__PURE__ */ new Set();
|
|
1234
|
-
this.movedSet = /* @__PURE__ */ new Set();
|
|
1235
|
-
this.droppedSet = /* @__PURE__ */ new Set();
|
|
1236
|
-
this.processMutations = (mutations) => {
|
|
1237
|
-
mutations.forEach(this.processMutation);
|
|
1238
|
-
this.emit();
|
|
1239
|
-
};
|
|
1240
|
-
this.emit = () => {
|
|
1241
|
-
if (this.frozen || this.locked) {
|
|
1242
|
-
return;
|
|
1243
|
-
}
|
|
1244
|
-
const adds = [];
|
|
1245
|
-
const addList = new DoubleLinkedList();
|
|
1246
|
-
const getNextId = (n) => {
|
|
1247
|
-
let ns = n;
|
|
1248
|
-
let nextId = IGNORED_NODE;
|
|
1249
|
-
while (nextId === IGNORED_NODE) {
|
|
1250
|
-
ns = ns && ns.nextSibling;
|
|
1251
|
-
nextId = ns && this.mirror.getId(ns);
|
|
1252
|
-
}
|
|
1253
|
-
return nextId;
|
|
1254
|
-
};
|
|
1255
|
-
const pushAdd = (n) => {
|
|
1256
|
-
var _a, _b, _c, _d, _e;
|
|
1257
|
-
const shadowHost = n.getRootNode ? (_a = n.getRootNode()) == null ? void 0 : _a.host : null;
|
|
1258
|
-
let rootShadowHost = shadowHost;
|
|
1259
|
-
while ((_c = (_b = rootShadowHost == null ? void 0 : rootShadowHost.getRootNode) == null ? void 0 : _b.call(rootShadowHost)) == null ? void 0 : _c.host)
|
|
1260
|
-
rootShadowHost = ((_e = (_d = rootShadowHost == null ? void 0 : rootShadowHost.getRootNode) == null ? void 0 : _d.call(rootShadowHost)) == null ? void 0 : _e.host) || null;
|
|
1261
|
-
const notInDoc = !this.doc.contains(n) && (!rootShadowHost || !this.doc.contains(rootShadowHost));
|
|
1262
|
-
if (!n.parentNode || notInDoc) {
|
|
1263
|
-
return;
|
|
1264
|
-
}
|
|
1265
|
-
const parentId = isShadowRoot(n.parentNode) ? this.mirror.getId(shadowHost) : this.mirror.getId(n.parentNode);
|
|
1266
|
-
const nextId = getNextId(n);
|
|
1267
|
-
if (parentId === -1 || nextId === -1) {
|
|
1268
|
-
return addList.addNode(n);
|
|
1269
|
-
}
|
|
1270
|
-
const sn = serializeNodeWithId(n, {
|
|
1271
|
-
doc: this.doc,
|
|
1272
|
-
mirror: this.mirror,
|
|
1273
|
-
blockClass: this.blockClass,
|
|
1274
|
-
blockSelector: this.blockSelector,
|
|
1275
|
-
maskTextClass: this.maskTextClass,
|
|
1276
|
-
maskTextSelector: this.maskTextSelector,
|
|
1277
|
-
skipChild: true,
|
|
1278
|
-
inlineStylesheet: this.inlineStylesheet,
|
|
1279
|
-
maskInputOptions: this.maskInputOptions,
|
|
1280
|
-
maskTextFn: this.maskTextFn,
|
|
1281
|
-
maskInputFn: this.maskInputFn,
|
|
1282
|
-
slimDOMOptions: this.slimDOMOptions,
|
|
1283
|
-
recordCanvas: this.recordCanvas,
|
|
1284
|
-
inlineImages: this.inlineImages,
|
|
1285
|
-
enableStrictPrivacy: this.enableStrictPrivacy,
|
|
1286
|
-
onSerialize: (currentN) => {
|
|
1287
|
-
if (isSerializedIframe(currentN, this.mirror)) {
|
|
1288
|
-
this.iframeManager.addIframe(currentN);
|
|
1289
|
-
}
|
|
1290
|
-
if (isSerializedStylesheet(currentN, this.mirror)) {
|
|
1291
|
-
this.stylesheetManager.addStylesheet(currentN);
|
|
1292
|
-
}
|
|
1293
|
-
if (hasShadowRoot(n)) {
|
|
1294
|
-
this.shadowDomManager.addShadowRoot(n.shadowRoot, document);
|
|
1295
|
-
}
|
|
1296
|
-
},
|
|
1297
|
-
onIframeLoad: (iframe, childSn) => {
|
|
1298
|
-
this.iframeManager.attachIframe(iframe, childSn, this.mirror);
|
|
1299
|
-
this.shadowDomManager.observeAttachShadow(iframe);
|
|
1300
|
-
},
|
|
1301
|
-
onStylesheetLoad: (link, childSn) => {
|
|
1302
|
-
this.stylesheetManager.attachStylesheet(link, childSn, this.mirror);
|
|
1303
|
-
}
|
|
1304
|
-
});
|
|
1305
|
-
if (sn) {
|
|
1306
|
-
adds.push({
|
|
1307
|
-
parentId,
|
|
1308
|
-
nextId,
|
|
1309
|
-
node: sn
|
|
1310
|
-
});
|
|
1311
|
-
}
|
|
1312
|
-
};
|
|
1313
|
-
while (this.mapRemoves.length) {
|
|
1314
|
-
this.mirror.removeNodeFromMap(this.mapRemoves.shift());
|
|
1315
|
-
}
|
|
1316
|
-
for (const n of Array.from(this.movedSet.values())) {
|
|
1317
|
-
if (isParentRemoved(this.removes, n, this.mirror) && !this.movedSet.has(n.parentNode)) {
|
|
1318
|
-
continue;
|
|
1319
|
-
}
|
|
1320
|
-
pushAdd(n);
|
|
1321
|
-
}
|
|
1322
|
-
for (const n of Array.from(this.addedSet.values())) {
|
|
1323
|
-
if (!isAncestorInSet(this.droppedSet, n) && !isParentRemoved(this.removes, n, this.mirror)) {
|
|
1324
|
-
pushAdd(n);
|
|
1325
|
-
} else if (isAncestorInSet(this.movedSet, n)) {
|
|
1326
|
-
pushAdd(n);
|
|
1327
|
-
} else {
|
|
1328
|
-
this.droppedSet.add(n);
|
|
1329
|
-
}
|
|
1330
|
-
}
|
|
1331
|
-
let candidate = null;
|
|
1332
|
-
while (addList.length) {
|
|
1333
|
-
let node = null;
|
|
1334
|
-
if (candidate) {
|
|
1335
|
-
const parentId = this.mirror.getId(candidate.value.parentNode);
|
|
1336
|
-
const nextId = getNextId(candidate.value);
|
|
1337
|
-
if (parentId !== -1 && nextId !== -1) {
|
|
1338
|
-
node = candidate;
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
if (!node) {
|
|
1342
|
-
for (let index = addList.length - 1; index >= 0; index--) {
|
|
1343
|
-
const _node = addList.get(index);
|
|
1344
|
-
if (_node) {
|
|
1345
|
-
const parentId = this.mirror.getId(_node.value.parentNode);
|
|
1346
|
-
const nextId = getNextId(_node.value);
|
|
1347
|
-
if (parentId !== -1 && nextId !== -1) {
|
|
1348
|
-
node = _node;
|
|
1349
|
-
break;
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
if (!node) {
|
|
1355
|
-
while (addList.head) {
|
|
1356
|
-
addList.removeNode(addList.head.value);
|
|
1357
|
-
}
|
|
1358
|
-
break;
|
|
1359
|
-
}
|
|
1360
|
-
candidate = node.previous;
|
|
1361
|
-
addList.removeNode(node.value);
|
|
1362
|
-
pushAdd(node.value);
|
|
1363
|
-
}
|
|
1364
|
-
const payload = {
|
|
1365
|
-
texts: this.texts.map((text) => {
|
|
1366
|
-
let value = text.value;
|
|
1367
|
-
if (this.enableStrictPrivacy && value) {
|
|
1368
|
-
value = obfuscateText(value);
|
|
1369
|
-
}
|
|
1370
|
-
return {
|
|
1371
|
-
id: this.mirror.getId(text.node),
|
|
1372
|
-
value
|
|
1373
|
-
};
|
|
1374
|
-
}).filter((text) => this.mirror.has(text.id)),
|
|
1375
|
-
attributes: this.attributes.map((attribute) => ({
|
|
1376
|
-
id: this.mirror.getId(attribute.node),
|
|
1377
|
-
attributes: attribute.attributes
|
|
1378
|
-
})).filter((attribute) => this.mirror.has(attribute.id)),
|
|
1379
|
-
removes: this.removes,
|
|
1380
|
-
adds
|
|
1381
|
-
};
|
|
1382
|
-
if (!payload.texts.length && !payload.attributes.length && !payload.removes.length && !payload.adds.length) {
|
|
1383
|
-
return;
|
|
1384
|
-
}
|
|
1385
|
-
this.texts = [];
|
|
1386
|
-
this.attributes = [];
|
|
1387
|
-
this.removes = [];
|
|
1388
|
-
this.addedSet = /* @__PURE__ */ new Set();
|
|
1389
|
-
this.movedSet = /* @__PURE__ */ new Set();
|
|
1390
|
-
this.droppedSet = /* @__PURE__ */ new Set();
|
|
1391
|
-
this.movedMap = {};
|
|
1392
|
-
this.mutationCb(payload);
|
|
1393
|
-
};
|
|
1394
|
-
this.processMutation = (m) => {
|
|
1395
|
-
if (isIgnored(m.target, this.mirror)) {
|
|
1396
|
-
return;
|
|
1397
|
-
}
|
|
1398
|
-
switch (m.type) {
|
|
1399
|
-
case "characterData": {
|
|
1400
|
-
const value = m.target.textContent;
|
|
1401
|
-
if (!isBlocked(m.target, this.blockClass) && value !== m.oldValue) {
|
|
1402
|
-
this.texts.push({
|
|
1403
|
-
value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector) && value ? this.maskTextFn ? this.maskTextFn(value) : value.replace(/[\S]/g, "*") : value,
|
|
1404
|
-
node: m.target
|
|
1405
|
-
});
|
|
1406
|
-
}
|
|
1407
|
-
break;
|
|
1408
|
-
}
|
|
1409
|
-
case "attributes": {
|
|
1410
|
-
const target = m.target;
|
|
1411
|
-
let value = m.target.getAttribute(m.attributeName);
|
|
1412
|
-
if (m.attributeName === "value") {
|
|
1413
|
-
value = maskInputValue({
|
|
1414
|
-
maskInputOptions: this.maskInputOptions,
|
|
1415
|
-
tagName: m.target.tagName,
|
|
1416
|
-
type: m.target.getAttribute("type"),
|
|
1417
|
-
value,
|
|
1418
|
-
maskInputFn: this.maskInputFn
|
|
1419
|
-
});
|
|
1420
|
-
}
|
|
1421
|
-
if (isBlocked(m.target, this.blockClass) || value === m.oldValue) {
|
|
1422
|
-
return;
|
|
1423
|
-
}
|
|
1424
|
-
let item = this.attributes.find((a) => a.node === m.target);
|
|
1425
|
-
if (!item) {
|
|
1426
|
-
item = {
|
|
1427
|
-
node: m.target,
|
|
1428
|
-
attributes: {}
|
|
1429
|
-
};
|
|
1430
|
-
this.attributes.push(item);
|
|
1431
|
-
}
|
|
1432
|
-
if (m.attributeName === "style") {
|
|
1433
|
-
const old = this.doc.createElement("span");
|
|
1434
|
-
if (m.oldValue) {
|
|
1435
|
-
old.setAttribute("style", m.oldValue);
|
|
1436
|
-
}
|
|
1437
|
-
if (item.attributes.style === void 0 || item.attributes.style === null) {
|
|
1438
|
-
item.attributes.style = {};
|
|
1439
|
-
}
|
|
1440
|
-
const styleObj = item.attributes.style;
|
|
1441
|
-
for (const pname of Array.from(target.style)) {
|
|
1442
|
-
const newValue = target.style.getPropertyValue(pname);
|
|
1443
|
-
const newPriority = target.style.getPropertyPriority(pname);
|
|
1444
|
-
if (newValue !== old.style.getPropertyValue(pname) || newPriority !== old.style.getPropertyPriority(pname)) {
|
|
1445
|
-
if (newPriority === "") {
|
|
1446
|
-
styleObj[pname] = newValue;
|
|
1447
|
-
} else {
|
|
1448
|
-
styleObj[pname] = [newValue, newPriority];
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
for (const pname of Array.from(old.style)) {
|
|
1453
|
-
if (target.style.getPropertyValue(pname) === "") {
|
|
1454
|
-
styleObj[pname] = false;
|
|
1455
|
-
}
|
|
1456
|
-
}
|
|
1457
|
-
} else {
|
|
1458
|
-
const tagName = m.target.tagName;
|
|
1459
|
-
if (tagName === "INPUT") {
|
|
1460
|
-
const node = m.target;
|
|
1461
|
-
if (node.type === "password") {
|
|
1462
|
-
item.attributes["value"] = "*".repeat(node.value.length);
|
|
1463
|
-
break;
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
item.attributes[m.attributeName] = transformAttribute(this.doc, m.target.tagName, m.attributeName, value);
|
|
1467
|
-
}
|
|
1468
|
-
break;
|
|
1469
|
-
}
|
|
1470
|
-
case "childList": {
|
|
1471
|
-
m.addedNodes.forEach((n) => this.genAdds(n, m.target));
|
|
1472
|
-
m.removedNodes.forEach((n) => {
|
|
1473
|
-
const nodeId = this.mirror.getId(n);
|
|
1474
|
-
const parentId = isShadowRoot(m.target) ? this.mirror.getId(m.target.host) : this.mirror.getId(m.target);
|
|
1475
|
-
if (isBlocked(m.target, this.blockClass) || isIgnored(n, this.mirror) || !isSerialized(n, this.mirror)) {
|
|
1476
|
-
return;
|
|
1477
|
-
}
|
|
1478
|
-
if (this.addedSet.has(n)) {
|
|
1479
|
-
deepDelete(this.addedSet, n);
|
|
1480
|
-
this.droppedSet.add(n);
|
|
1481
|
-
} else if (this.addedSet.has(m.target) && nodeId === -1) ; else if (isAncestorRemoved(m.target, this.mirror)) ; else if (this.movedSet.has(n) && this.movedMap[moveKey(nodeId, parentId)]) {
|
|
1482
|
-
deepDelete(this.movedSet, n);
|
|
1483
|
-
} else {
|
|
1484
|
-
this.removes.push({
|
|
1485
|
-
parentId,
|
|
1486
|
-
id: nodeId,
|
|
1487
|
-
isShadow: isShadowRoot(m.target) ? true : void 0
|
|
1488
|
-
});
|
|
1489
|
-
}
|
|
1490
|
-
this.mapRemoves.push(n);
|
|
1491
|
-
});
|
|
1492
|
-
break;
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
};
|
|
1496
|
-
this.genAdds = (n, target) => {
|
|
1497
|
-
if (target && isBlocked(target, this.blockClass)) {
|
|
1498
|
-
return;
|
|
1499
|
-
}
|
|
1500
|
-
if (this.mirror.getMeta(n)) {
|
|
1501
|
-
if (isIgnored(n, this.mirror)) {
|
|
1502
|
-
return;
|
|
1503
|
-
}
|
|
1504
|
-
this.movedSet.add(n);
|
|
1505
|
-
let targetId = null;
|
|
1506
|
-
if (target && this.mirror.getMeta(target)) {
|
|
1507
|
-
targetId = this.mirror.getId(target);
|
|
1508
|
-
}
|
|
1509
|
-
if (targetId && targetId !== -1) {
|
|
1510
|
-
this.movedMap[moveKey(this.mirror.getId(n), targetId)] = true;
|
|
1511
|
-
}
|
|
1512
|
-
} else {
|
|
1513
|
-
this.addedSet.add(n);
|
|
1514
|
-
this.droppedSet.delete(n);
|
|
1515
|
-
}
|
|
1516
|
-
if (!isBlocked(n, this.blockClass))
|
|
1517
|
-
n.childNodes.forEach((childN) => this.genAdds(childN));
|
|
1518
|
-
};
|
|
1519
|
-
}
|
|
1520
|
-
init(options) {
|
|
1521
|
-
[
|
|
1522
|
-
"mutationCb",
|
|
1523
|
-
"blockClass",
|
|
1524
|
-
"blockSelector",
|
|
1525
|
-
"maskTextClass",
|
|
1526
|
-
"maskTextSelector",
|
|
1527
|
-
"inlineStylesheet",
|
|
1528
|
-
"maskInputOptions",
|
|
1529
|
-
"maskTextFn",
|
|
1530
|
-
"maskInputFn",
|
|
1531
|
-
"recordCanvas",
|
|
1532
|
-
"inlineImages",
|
|
1533
|
-
"slimDOMOptions",
|
|
1534
|
-
"doc",
|
|
1535
|
-
"mirror",
|
|
1536
|
-
"iframeManager",
|
|
1537
|
-
"stylesheetManager",
|
|
1538
|
-
"shadowDomManager",
|
|
1539
|
-
"canvasManager",
|
|
1540
|
-
"enableStrictPrivacy"
|
|
1541
|
-
].forEach((key) => {
|
|
1542
|
-
this[key] = options[key];
|
|
1543
|
-
});
|
|
1544
|
-
}
|
|
1545
|
-
freeze() {
|
|
1546
|
-
this.frozen = true;
|
|
1547
|
-
this.canvasManager.freeze();
|
|
1548
|
-
}
|
|
1549
|
-
unfreeze() {
|
|
1550
|
-
this.frozen = false;
|
|
1551
|
-
this.canvasManager.unfreeze();
|
|
1552
|
-
this.emit();
|
|
1553
|
-
}
|
|
1554
|
-
isFrozen() {
|
|
1555
|
-
return this.frozen;
|
|
1556
|
-
}
|
|
1557
|
-
lock() {
|
|
1558
|
-
this.locked = true;
|
|
1559
|
-
this.canvasManager.lock();
|
|
1560
|
-
}
|
|
1561
|
-
unlock() {
|
|
1562
|
-
this.locked = false;
|
|
1563
|
-
this.canvasManager.unlock();
|
|
1564
|
-
this.emit();
|
|
1565
|
-
}
|
|
1566
|
-
reset() {
|
|
1567
|
-
this.shadowDomManager.reset();
|
|
1568
|
-
this.canvasManager.reset();
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
function deepDelete(addsSet, n) {
|
|
1572
|
-
addsSet.delete(n);
|
|
1573
|
-
n.childNodes.forEach((childN) => deepDelete(addsSet, childN));
|
|
1574
|
-
}
|
|
1575
|
-
function isParentRemoved(removes, n, mirror) {
|
|
1576
|
-
const { parentNode } = n;
|
|
1577
|
-
if (!parentNode) {
|
|
1578
|
-
return false;
|
|
1579
|
-
}
|
|
1580
|
-
const parentId = mirror.getId(parentNode);
|
|
1581
|
-
if (removes.some((r) => r.id === parentId)) {
|
|
1582
|
-
return true;
|
|
1583
|
-
}
|
|
1584
|
-
return isParentRemoved(removes, parentNode, mirror);
|
|
1585
|
-
}
|
|
1586
|
-
function isAncestorInSet(set, n) {
|
|
1587
|
-
const { parentNode } = n;
|
|
1588
|
-
if (!parentNode) {
|
|
1589
|
-
return false;
|
|
1590
|
-
}
|
|
1591
|
-
if (set.has(parentNode)) {
|
|
1592
|
-
return true;
|
|
1593
|
-
}
|
|
1594
|
-
return isAncestorInSet(set, parentNode);
|
|
1595
|
-
}
|
|
1596
|
-
|
|
1597
|
-
var __defProp$2 = Object.defineProperty;
|
|
1598
|
-
var __defProps$2 = Object.defineProperties;
|
|
1599
|
-
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
1600
|
-
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
1601
|
-
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
1602
|
-
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
1603
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1604
|
-
var __spreadValues$2 = (a, b) => {
|
|
1605
|
-
for (var prop in b || (b = {}))
|
|
1606
|
-
if (__hasOwnProp$3.call(b, prop))
|
|
1607
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
1608
|
-
if (__getOwnPropSymbols$3)
|
|
1609
|
-
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
1610
|
-
if (__propIsEnum$3.call(b, prop))
|
|
1611
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
1612
|
-
}
|
|
1613
|
-
return a;
|
|
1614
|
-
};
|
|
1615
|
-
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
1616
|
-
const mutationBuffers = [];
|
|
1617
|
-
const isCSSGroupingRuleSupported = typeof CSSGroupingRule !== "undefined";
|
|
1618
|
-
const isCSSMediaRuleSupported = typeof CSSMediaRule !== "undefined";
|
|
1619
|
-
const isCSSSupportsRuleSupported = typeof CSSSupportsRule !== "undefined";
|
|
1620
|
-
const isCSSConditionRuleSupported = typeof CSSConditionRule !== "undefined";
|
|
1621
|
-
function getEventTarget(event) {
|
|
1622
|
-
try {
|
|
1623
|
-
if ("composedPath" in event) {
|
|
1624
|
-
const path = event.composedPath();
|
|
1625
|
-
if (path.length) {
|
|
1626
|
-
return path[0];
|
|
1627
|
-
}
|
|
1628
|
-
} else if ("path" in event && event.path.length) {
|
|
1629
|
-
return event.path[0];
|
|
1630
|
-
}
|
|
1631
|
-
return event.target;
|
|
1632
|
-
} catch (e) {
|
|
1633
|
-
return event.target;
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
function initMutationObserver(options, rootEl) {
|
|
1637
|
-
var _a, _b;
|
|
1638
|
-
const mutationBuffer = new MutationBuffer();
|
|
1639
|
-
mutationBuffers.push(mutationBuffer);
|
|
1640
|
-
mutationBuffer.init(options);
|
|
1641
|
-
let mutationObserverCtor = window.MutationObserver || window.__rrMutationObserver;
|
|
1642
|
-
const angularZoneSymbol = (_b = (_a = window == null ? void 0 : window.Zone) == null ? void 0 : _a.__symbol__) == null ? void 0 : _b.call(_a, "MutationObserver");
|
|
1643
|
-
if (angularZoneSymbol && window[angularZoneSymbol]) {
|
|
1644
|
-
mutationObserverCtor = window[angularZoneSymbol];
|
|
1645
|
-
}
|
|
1646
|
-
const observer = new mutationObserverCtor(mutationBuffer.processMutations.bind(mutationBuffer));
|
|
1647
|
-
observer.observe(rootEl, {
|
|
1648
|
-
attributes: true,
|
|
1649
|
-
attributeOldValue: true,
|
|
1650
|
-
characterData: true,
|
|
1651
|
-
characterDataOldValue: true,
|
|
1652
|
-
childList: true,
|
|
1653
|
-
subtree: true
|
|
1654
|
-
});
|
|
1655
|
-
return observer;
|
|
1656
|
-
}
|
|
1657
|
-
function initMoveObserver({
|
|
1658
|
-
mousemoveCb,
|
|
1659
|
-
sampling,
|
|
1660
|
-
doc,
|
|
1661
|
-
mirror
|
|
1662
|
-
}) {
|
|
1663
|
-
if (sampling.mousemove === false) {
|
|
1664
|
-
return () => {
|
|
1665
|
-
};
|
|
1666
|
-
}
|
|
1667
|
-
const threshold = typeof sampling.mousemove === "number" ? sampling.mousemove : 50;
|
|
1668
|
-
const callbackThreshold = typeof sampling.mousemoveCallback === "number" ? sampling.mousemoveCallback : 500;
|
|
1669
|
-
let positions = [];
|
|
1670
|
-
let timeBaseline;
|
|
1671
|
-
const wrappedCb = throttle((source) => {
|
|
1672
|
-
const totalOffset = Date.now() - timeBaseline;
|
|
1673
|
-
mousemoveCb(positions.map((p) => {
|
|
1674
|
-
p.timeOffset -= totalOffset;
|
|
1675
|
-
return p;
|
|
1676
|
-
}), source);
|
|
1677
|
-
positions = [];
|
|
1678
|
-
timeBaseline = null;
|
|
1679
|
-
}, callbackThreshold);
|
|
1680
|
-
const updatePosition = throttle((evt) => {
|
|
1681
|
-
const target = getEventTarget(evt);
|
|
1682
|
-
const { clientX, clientY } = isTouchEvent(evt) ? evt.changedTouches[0] : evt;
|
|
1683
|
-
if (!timeBaseline) {
|
|
1684
|
-
timeBaseline = Date.now();
|
|
1685
|
-
}
|
|
1686
|
-
positions.push({
|
|
1687
|
-
x: clientX,
|
|
1688
|
-
y: clientY,
|
|
1689
|
-
id: mirror.getId(target),
|
|
1690
|
-
timeOffset: Date.now() - timeBaseline
|
|
1691
|
-
});
|
|
1692
|
-
wrappedCb(typeof DragEvent !== "undefined" && evt instanceof DragEvent ? IncrementalSource.Drag : evt instanceof MouseEvent ? IncrementalSource.MouseMove : IncrementalSource.TouchMove);
|
|
1693
|
-
}, threshold, {
|
|
1694
|
-
trailing: false
|
|
1695
|
-
});
|
|
1696
|
-
const handlers = [
|
|
1697
|
-
on("mousemove", updatePosition, doc),
|
|
1698
|
-
on("touchmove", updatePosition, doc),
|
|
1699
|
-
on("drag", updatePosition, doc)
|
|
1700
|
-
];
|
|
1701
|
-
return () => {
|
|
1702
|
-
handlers.forEach((h) => h());
|
|
1703
|
-
};
|
|
1704
|
-
}
|
|
1705
|
-
function initMouseInteractionObserver({
|
|
1706
|
-
mouseInteractionCb,
|
|
1707
|
-
doc,
|
|
1708
|
-
mirror,
|
|
1709
|
-
blockClass,
|
|
1710
|
-
sampling
|
|
1711
|
-
}) {
|
|
1712
|
-
if (sampling.mouseInteraction === false) {
|
|
1713
|
-
return () => {
|
|
1714
|
-
};
|
|
1715
|
-
}
|
|
1716
|
-
const disableMap = sampling.mouseInteraction === true || sampling.mouseInteraction === void 0 ? {} : sampling.mouseInteraction;
|
|
1717
|
-
const handlers = [];
|
|
1718
|
-
const getHandler = (eventKey) => {
|
|
1719
|
-
return (event) => {
|
|
1720
|
-
const target = getEventTarget(event);
|
|
1721
|
-
if (isBlocked(target, blockClass) || isCanvasNode(target)) {
|
|
1722
|
-
return;
|
|
1723
|
-
}
|
|
1724
|
-
const e = isTouchEvent(event) ? event.changedTouches[0] : event;
|
|
1725
|
-
if (!e) {
|
|
1726
|
-
return;
|
|
1727
|
-
}
|
|
1728
|
-
const id = mirror.getId(target);
|
|
1729
|
-
const { clientX, clientY } = e;
|
|
1730
|
-
mouseInteractionCb({
|
|
1731
|
-
type: MouseInteractions[eventKey],
|
|
1732
|
-
id,
|
|
1733
|
-
x: clientX,
|
|
1734
|
-
y: clientY
|
|
1735
|
-
});
|
|
1736
|
-
};
|
|
1737
|
-
};
|
|
1738
|
-
Object.keys(MouseInteractions).filter((key) => Number.isNaN(Number(key)) && !key.endsWith("_Departed") && disableMap[key] !== false).forEach((eventKey) => {
|
|
1739
|
-
const eventName = eventKey.toLowerCase();
|
|
1740
|
-
const handler = getHandler(eventKey);
|
|
1741
|
-
handlers.push(on(eventName, handler, doc));
|
|
1742
|
-
});
|
|
1743
|
-
return () => {
|
|
1744
|
-
handlers.forEach((h) => h());
|
|
1745
|
-
};
|
|
1746
|
-
}
|
|
1747
|
-
function initScrollObserver({
|
|
1748
|
-
scrollCb,
|
|
1749
|
-
doc,
|
|
1750
|
-
mirror,
|
|
1751
|
-
blockClass,
|
|
1752
|
-
sampling
|
|
1753
|
-
}) {
|
|
1754
|
-
const updatePosition = throttle((evt) => {
|
|
1755
|
-
const target = getEventTarget(evt);
|
|
1756
|
-
if (!target || isBlocked(target, blockClass)) {
|
|
1757
|
-
return;
|
|
1758
|
-
}
|
|
1759
|
-
const id = mirror.getId(target);
|
|
1760
|
-
if (target === doc) {
|
|
1761
|
-
const scrollEl = doc.scrollingElement || doc.documentElement;
|
|
1762
|
-
scrollCb({
|
|
1763
|
-
id,
|
|
1764
|
-
x: scrollEl.scrollLeft,
|
|
1765
|
-
y: scrollEl.scrollTop
|
|
1766
|
-
});
|
|
1767
|
-
} else {
|
|
1768
|
-
scrollCb({
|
|
1769
|
-
id,
|
|
1770
|
-
x: target.scrollLeft,
|
|
1771
|
-
y: target.scrollTop
|
|
1772
|
-
});
|
|
1773
|
-
}
|
|
1774
|
-
}, sampling.scroll || 100);
|
|
1775
|
-
return on("scroll", updatePosition, doc);
|
|
1776
|
-
}
|
|
1777
|
-
function initViewportResizeObserver({
|
|
1778
|
-
viewportResizeCb
|
|
1779
|
-
}) {
|
|
1780
|
-
let lastH = -1;
|
|
1781
|
-
let lastW = -1;
|
|
1782
|
-
const updateDimension = throttle(() => {
|
|
1783
|
-
const height = getWindowHeight();
|
|
1784
|
-
const width = getWindowWidth();
|
|
1785
|
-
if (lastH !== height || lastW !== width) {
|
|
1786
|
-
viewportResizeCb({
|
|
1787
|
-
width: Number(width),
|
|
1788
|
-
height: Number(height)
|
|
1789
|
-
});
|
|
1790
|
-
lastH = height;
|
|
1791
|
-
lastW = width;
|
|
1792
|
-
}
|
|
1793
|
-
}, 200);
|
|
1794
|
-
return on("resize", updateDimension, window);
|
|
1795
|
-
}
|
|
1796
|
-
function wrapEventWithUserTriggeredFlag(v, enable) {
|
|
1797
|
-
const value = __spreadValues$2({}, v);
|
|
1798
|
-
if (!enable)
|
|
1799
|
-
delete value.userTriggered;
|
|
1800
|
-
return value;
|
|
1801
|
-
}
|
|
1802
|
-
const INPUT_TAGS = ["INPUT", "TEXTAREA", "SELECT"];
|
|
1803
|
-
const lastInputValueMap = /* @__PURE__ */ new WeakMap();
|
|
1804
|
-
function initInputObserver({
|
|
1805
|
-
inputCb,
|
|
1806
|
-
doc,
|
|
1807
|
-
mirror,
|
|
1808
|
-
blockClass,
|
|
1809
|
-
ignoreClass,
|
|
1810
|
-
maskInputOptions,
|
|
1811
|
-
maskInputFn,
|
|
1812
|
-
sampling,
|
|
1813
|
-
userTriggeredOnInput
|
|
1814
|
-
}) {
|
|
1815
|
-
function eventHandler(event) {
|
|
1816
|
-
let target = getEventTarget(event);
|
|
1817
|
-
const userTriggered = event.isTrusted;
|
|
1818
|
-
if (target && target.tagName === "OPTION")
|
|
1819
|
-
target = target.parentElement;
|
|
1820
|
-
if (!target || !target.tagName || INPUT_TAGS.indexOf(target.tagName) < 0 || isBlocked(target, blockClass)) {
|
|
1821
|
-
return;
|
|
1822
|
-
}
|
|
1823
|
-
const type = target.type;
|
|
1824
|
-
if (target.classList.contains(ignoreClass)) {
|
|
1825
|
-
return;
|
|
1826
|
-
}
|
|
1827
|
-
let text = target.value;
|
|
1828
|
-
let isChecked = false;
|
|
1829
|
-
if (type === "radio" || type === "checkbox") {
|
|
1830
|
-
isChecked = target.checked;
|
|
1831
|
-
} else if (maskInputOptions[target.tagName.toLowerCase()] || maskInputOptions[type]) {
|
|
1832
|
-
text = maskInputValue({
|
|
1833
|
-
maskInputOptions,
|
|
1834
|
-
tagName: target.tagName,
|
|
1835
|
-
type,
|
|
1836
|
-
value: text,
|
|
1837
|
-
maskInputFn
|
|
1838
|
-
});
|
|
1839
|
-
}
|
|
1840
|
-
cbWithDedup(target, wrapEventWithUserTriggeredFlag({ text, isChecked, userTriggered }, userTriggeredOnInput));
|
|
1841
|
-
const name = target.name;
|
|
1842
|
-
if (type === "radio" && name && isChecked) {
|
|
1843
|
-
doc.querySelectorAll(`input[type="radio"][name="${name}"]`).forEach((el) => {
|
|
1844
|
-
if (el !== target) {
|
|
1845
|
-
cbWithDedup(el, wrapEventWithUserTriggeredFlag({
|
|
1846
|
-
text: el.value,
|
|
1847
|
-
isChecked: !isChecked,
|
|
1848
|
-
userTriggered: false
|
|
1849
|
-
}, userTriggeredOnInput));
|
|
1850
|
-
}
|
|
1851
|
-
});
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
function cbWithDedup(target, v) {
|
|
1855
|
-
const lastInputValue = lastInputValueMap.get(target);
|
|
1856
|
-
if (!lastInputValue || lastInputValue.text !== v.text || lastInputValue.isChecked !== v.isChecked) {
|
|
1857
|
-
lastInputValueMap.set(target, v);
|
|
1858
|
-
const id = mirror.getId(target);
|
|
1859
|
-
inputCb(__spreadProps$2(__spreadValues$2({}, v), {
|
|
1860
|
-
id
|
|
1861
|
-
}));
|
|
1862
|
-
}
|
|
1863
|
-
}
|
|
1864
|
-
const events = sampling.input === "last" ? ["change"] : ["input", "change"];
|
|
1865
|
-
const handlers = events.map((eventName) => on(eventName, eventHandler, doc));
|
|
1866
|
-
const propertyDescriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value");
|
|
1867
|
-
const hookProperties = [
|
|
1868
|
-
[HTMLInputElement.prototype, "value"],
|
|
1869
|
-
[HTMLInputElement.prototype, "checked"],
|
|
1870
|
-
[HTMLSelectElement.prototype, "value"],
|
|
1871
|
-
[HTMLTextAreaElement.prototype, "value"],
|
|
1872
|
-
[HTMLSelectElement.prototype, "selectedIndex"],
|
|
1873
|
-
[HTMLOptionElement.prototype, "selected"]
|
|
1874
|
-
];
|
|
1875
|
-
if (propertyDescriptor && propertyDescriptor.set) {
|
|
1876
|
-
handlers.push(...hookProperties.map((p) => hookSetter(p[0], p[1], {
|
|
1877
|
-
set() {
|
|
1878
|
-
eventHandler({ target: this });
|
|
1879
|
-
}
|
|
1880
|
-
})));
|
|
1881
|
-
}
|
|
1882
|
-
return () => {
|
|
1883
|
-
handlers.forEach((h) => h());
|
|
1884
|
-
};
|
|
1885
|
-
}
|
|
1886
|
-
function getNestedCSSRulePositions(rule) {
|
|
1887
|
-
const positions = [];
|
|
1888
|
-
function recurse(childRule, pos) {
|
|
1889
|
-
if (isCSSGroupingRuleSupported && childRule.parentRule instanceof CSSGroupingRule || isCSSMediaRuleSupported && childRule.parentRule instanceof CSSMediaRule || isCSSSupportsRuleSupported && childRule.parentRule instanceof CSSSupportsRule || isCSSConditionRuleSupported && childRule.parentRule instanceof CSSConditionRule) {
|
|
1890
|
-
const rules = Array.from(childRule.parentRule.cssRules);
|
|
1891
|
-
const index = rules.indexOf(childRule);
|
|
1892
|
-
pos.unshift(index);
|
|
1893
|
-
} else {
|
|
1894
|
-
const rules = Array.from(childRule.parentStyleSheet.cssRules);
|
|
1895
|
-
const index = rules.indexOf(childRule);
|
|
1896
|
-
pos.unshift(index);
|
|
1897
|
-
}
|
|
1898
|
-
return pos;
|
|
1899
|
-
}
|
|
1900
|
-
return recurse(rule, positions);
|
|
1901
|
-
}
|
|
1902
|
-
function initStyleSheetObserver({ styleSheetRuleCb, mirror }, { win }) {
|
|
1903
|
-
const insertRule = win.CSSStyleSheet.prototype.insertRule;
|
|
1904
|
-
win.CSSStyleSheet.prototype.insertRule = function(rule, index) {
|
|
1905
|
-
const id = mirror.getId(this.ownerNode);
|
|
1906
|
-
if (id !== -1) {
|
|
1907
|
-
styleSheetRuleCb({
|
|
1908
|
-
id,
|
|
1909
|
-
adds: [{ rule, index }]
|
|
1910
|
-
});
|
|
1911
|
-
}
|
|
1912
|
-
return insertRule.apply(this, arguments);
|
|
1913
|
-
};
|
|
1914
|
-
const deleteRule = win.CSSStyleSheet.prototype.deleteRule;
|
|
1915
|
-
win.CSSStyleSheet.prototype.deleteRule = function(index) {
|
|
1916
|
-
const id = mirror.getId(this.ownerNode);
|
|
1917
|
-
if (id !== -1) {
|
|
1918
|
-
styleSheetRuleCb({
|
|
1919
|
-
id,
|
|
1920
|
-
removes: [{ index }]
|
|
1921
|
-
});
|
|
1922
|
-
}
|
|
1923
|
-
return deleteRule.apply(this, arguments);
|
|
1924
|
-
};
|
|
1925
|
-
const supportedNestedCSSRuleTypes = {};
|
|
1926
|
-
if (isCSSGroupingRuleSupported) {
|
|
1927
|
-
supportedNestedCSSRuleTypes.CSSGroupingRule = win.CSSGroupingRule;
|
|
1928
|
-
} else {
|
|
1929
|
-
if (isCSSMediaRuleSupported) {
|
|
1930
|
-
supportedNestedCSSRuleTypes.CSSMediaRule = win.CSSMediaRule;
|
|
1931
|
-
}
|
|
1932
|
-
if (isCSSConditionRuleSupported) {
|
|
1933
|
-
supportedNestedCSSRuleTypes.CSSConditionRule = win.CSSConditionRule;
|
|
1934
|
-
}
|
|
1935
|
-
if (isCSSSupportsRuleSupported) {
|
|
1936
|
-
supportedNestedCSSRuleTypes.CSSSupportsRule = win.CSSSupportsRule;
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
const unmodifiedFunctions = {};
|
|
1940
|
-
Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {
|
|
1941
|
-
unmodifiedFunctions[typeKey] = {
|
|
1942
|
-
insertRule: type.prototype.insertRule,
|
|
1943
|
-
deleteRule: type.prototype.deleteRule
|
|
1944
|
-
};
|
|
1945
|
-
type.prototype.insertRule = function(rule, index) {
|
|
1946
|
-
const id = mirror.getId(this.parentStyleSheet.ownerNode);
|
|
1947
|
-
if (id !== -1) {
|
|
1948
|
-
styleSheetRuleCb({
|
|
1949
|
-
id,
|
|
1950
|
-
adds: [
|
|
1951
|
-
{
|
|
1952
|
-
rule,
|
|
1953
|
-
index: [
|
|
1954
|
-
...getNestedCSSRulePositions(this),
|
|
1955
|
-
index || 0
|
|
1956
|
-
]
|
|
1957
|
-
}
|
|
1958
|
-
]
|
|
1959
|
-
});
|
|
1960
|
-
}
|
|
1961
|
-
return unmodifiedFunctions[typeKey].insertRule.apply(this, arguments);
|
|
1962
|
-
};
|
|
1963
|
-
type.prototype.deleteRule = function(index) {
|
|
1964
|
-
const id = mirror.getId(this.parentStyleSheet.ownerNode);
|
|
1965
|
-
if (id !== -1) {
|
|
1966
|
-
styleSheetRuleCb({
|
|
1967
|
-
id,
|
|
1968
|
-
removes: [{ index: [...getNestedCSSRulePositions(this), index] }]
|
|
1969
|
-
});
|
|
1970
|
-
}
|
|
1971
|
-
return unmodifiedFunctions[typeKey].deleteRule.apply(this, arguments);
|
|
1972
|
-
};
|
|
1973
|
-
});
|
|
1974
|
-
return () => {
|
|
1975
|
-
win.CSSStyleSheet.prototype.insertRule = insertRule;
|
|
1976
|
-
win.CSSStyleSheet.prototype.deleteRule = deleteRule;
|
|
1977
|
-
Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {
|
|
1978
|
-
type.prototype.insertRule = unmodifiedFunctions[typeKey].insertRule;
|
|
1979
|
-
type.prototype.deleteRule = unmodifiedFunctions[typeKey].deleteRule;
|
|
1980
|
-
});
|
|
1981
|
-
};
|
|
1982
|
-
}
|
|
1983
|
-
function initStyleDeclarationObserver({ styleDeclarationCb, mirror }, { win }) {
|
|
1984
|
-
const setProperty = win.CSSStyleDeclaration.prototype.setProperty;
|
|
1985
|
-
win.CSSStyleDeclaration.prototype.setProperty = function(property, value, priority) {
|
|
1986
|
-
var _a, _b;
|
|
1987
|
-
const id = mirror.getId((_b = (_a = this.parentRule) == null ? void 0 : _a.parentStyleSheet) == null ? void 0 : _b.ownerNode);
|
|
1988
|
-
if (id !== -1) {
|
|
1989
|
-
styleDeclarationCb({
|
|
1990
|
-
id,
|
|
1991
|
-
set: {
|
|
1992
|
-
property,
|
|
1993
|
-
value,
|
|
1994
|
-
priority
|
|
1995
|
-
},
|
|
1996
|
-
index: getNestedCSSRulePositions(this.parentRule)
|
|
1997
|
-
});
|
|
1998
|
-
}
|
|
1999
|
-
return setProperty.apply(this, arguments);
|
|
2000
|
-
};
|
|
2001
|
-
const removeProperty = win.CSSStyleDeclaration.prototype.removeProperty;
|
|
2002
|
-
win.CSSStyleDeclaration.prototype.removeProperty = function(property) {
|
|
2003
|
-
var _a, _b;
|
|
2004
|
-
const id = mirror.getId((_b = (_a = this.parentRule) == null ? void 0 : _a.parentStyleSheet) == null ? void 0 : _b.ownerNode);
|
|
2005
|
-
if (id !== -1) {
|
|
2006
|
-
styleDeclarationCb({
|
|
2007
|
-
id,
|
|
2008
|
-
remove: {
|
|
2009
|
-
property
|
|
2010
|
-
},
|
|
2011
|
-
index: getNestedCSSRulePositions(this.parentRule)
|
|
2012
|
-
});
|
|
2013
|
-
}
|
|
2014
|
-
return removeProperty.apply(this, arguments);
|
|
2015
|
-
};
|
|
2016
|
-
return () => {
|
|
2017
|
-
win.CSSStyleDeclaration.prototype.setProperty = setProperty;
|
|
2018
|
-
win.CSSStyleDeclaration.prototype.removeProperty = removeProperty;
|
|
2019
|
-
};
|
|
2020
|
-
}
|
|
2021
|
-
function initMediaInteractionObserver({
|
|
2022
|
-
mediaInteractionCb,
|
|
2023
|
-
blockClass,
|
|
2024
|
-
mirror,
|
|
2025
|
-
sampling
|
|
2026
|
-
}) {
|
|
2027
|
-
const handler = (type) => throttle((event) => {
|
|
2028
|
-
const target = getEventTarget(event);
|
|
2029
|
-
if (!target || isBlocked(target, blockClass)) {
|
|
2030
|
-
return;
|
|
2031
|
-
}
|
|
2032
|
-
const { currentTime, volume, muted } = target;
|
|
2033
|
-
mediaInteractionCb({
|
|
2034
|
-
type,
|
|
2035
|
-
id: mirror.getId(target),
|
|
2036
|
-
currentTime,
|
|
2037
|
-
volume,
|
|
2038
|
-
muted
|
|
2039
|
-
});
|
|
2040
|
-
}, sampling.media || 500);
|
|
2041
|
-
const handlers = [
|
|
2042
|
-
on("play", handler(MediaInteractions.Play)),
|
|
2043
|
-
on("pause", handler(MediaInteractions.Pause)),
|
|
2044
|
-
on("seeked", handler(MediaInteractions.Seeked)),
|
|
2045
|
-
on("volumechange", handler(MediaInteractions.VolumeChange))
|
|
2046
|
-
];
|
|
2047
|
-
return () => {
|
|
2048
|
-
handlers.forEach((h) => h());
|
|
2049
|
-
};
|
|
2050
|
-
}
|
|
2051
|
-
function initFontObserver({ fontCb, doc }) {
|
|
2052
|
-
const win = doc.defaultView;
|
|
2053
|
-
if (!win) {
|
|
2054
|
-
return () => {
|
|
2055
|
-
};
|
|
2056
|
-
}
|
|
2057
|
-
const handlers = [];
|
|
2058
|
-
const fontMap = /* @__PURE__ */ new WeakMap();
|
|
2059
|
-
const originalFontFace = win.FontFace;
|
|
2060
|
-
win.FontFace = function FontFace(family, source, descriptors) {
|
|
2061
|
-
const fontFace = new originalFontFace(family, source, descriptors);
|
|
2062
|
-
fontMap.set(fontFace, {
|
|
2063
|
-
family,
|
|
2064
|
-
buffer: typeof source !== "string",
|
|
2065
|
-
descriptors,
|
|
2066
|
-
fontSource: typeof source === "string" ? source : JSON.stringify(Array.from(new Uint8Array(source)))
|
|
2067
|
-
});
|
|
2068
|
-
return fontFace;
|
|
2069
|
-
};
|
|
2070
|
-
const restoreHandler = patch(doc.fonts, "add", function(original) {
|
|
2071
|
-
return function(fontFace) {
|
|
2072
|
-
setTimeout(() => {
|
|
2073
|
-
const p = fontMap.get(fontFace);
|
|
2074
|
-
if (p) {
|
|
2075
|
-
fontCb(p);
|
|
2076
|
-
fontMap.delete(fontFace);
|
|
2077
|
-
}
|
|
2078
|
-
}, 0);
|
|
2079
|
-
return original.apply(this, [fontFace]);
|
|
2080
|
-
};
|
|
2081
|
-
});
|
|
2082
|
-
handlers.push(() => {
|
|
2083
|
-
win.FontFace = originalFontFace;
|
|
2084
|
-
});
|
|
2085
|
-
handlers.push(restoreHandler);
|
|
2086
|
-
return () => {
|
|
2087
|
-
handlers.forEach((h) => h());
|
|
2088
|
-
};
|
|
2089
|
-
}
|
|
2090
|
-
function mergeHooks(o, hooks) {
|
|
2091
|
-
const {
|
|
2092
|
-
mutationCb,
|
|
2093
|
-
mousemoveCb,
|
|
2094
|
-
mouseInteractionCb,
|
|
2095
|
-
scrollCb,
|
|
2096
|
-
viewportResizeCb,
|
|
2097
|
-
inputCb,
|
|
2098
|
-
mediaInteractionCb,
|
|
2099
|
-
styleSheetRuleCb,
|
|
2100
|
-
styleDeclarationCb,
|
|
2101
|
-
canvasMutationCb,
|
|
2102
|
-
fontCb
|
|
2103
|
-
} = o;
|
|
2104
|
-
o.mutationCb = (...p) => {
|
|
2105
|
-
if (hooks.mutation) {
|
|
2106
|
-
hooks.mutation(...p);
|
|
2107
|
-
}
|
|
2108
|
-
mutationCb(...p);
|
|
2109
|
-
};
|
|
2110
|
-
o.mousemoveCb = (...p) => {
|
|
2111
|
-
if (hooks.mousemove) {
|
|
2112
|
-
hooks.mousemove(...p);
|
|
2113
|
-
}
|
|
2114
|
-
mousemoveCb(...p);
|
|
2115
|
-
};
|
|
2116
|
-
o.mouseInteractionCb = (...p) => {
|
|
2117
|
-
if (hooks.mouseInteraction) {
|
|
2118
|
-
hooks.mouseInteraction(...p);
|
|
2119
|
-
}
|
|
2120
|
-
mouseInteractionCb(...p);
|
|
2121
|
-
};
|
|
2122
|
-
o.scrollCb = (...p) => {
|
|
2123
|
-
if (hooks.scroll) {
|
|
2124
|
-
hooks.scroll(...p);
|
|
2125
|
-
}
|
|
2126
|
-
scrollCb(...p);
|
|
2127
|
-
};
|
|
2128
|
-
o.viewportResizeCb = (...p) => {
|
|
2129
|
-
if (hooks.viewportResize) {
|
|
2130
|
-
hooks.viewportResize(...p);
|
|
2131
|
-
}
|
|
2132
|
-
viewportResizeCb(...p);
|
|
2133
|
-
};
|
|
2134
|
-
o.inputCb = (...p) => {
|
|
2135
|
-
if (hooks.input) {
|
|
2136
|
-
hooks.input(...p);
|
|
2137
|
-
}
|
|
2138
|
-
inputCb(...p);
|
|
2139
|
-
};
|
|
2140
|
-
o.mediaInteractionCb = (...p) => {
|
|
2141
|
-
if (hooks.mediaInteaction) {
|
|
2142
|
-
hooks.mediaInteaction(...p);
|
|
2143
|
-
}
|
|
2144
|
-
mediaInteractionCb(...p);
|
|
2145
|
-
};
|
|
2146
|
-
o.styleSheetRuleCb = (...p) => {
|
|
2147
|
-
if (hooks.styleSheetRule) {
|
|
2148
|
-
hooks.styleSheetRule(...p);
|
|
2149
|
-
}
|
|
2150
|
-
styleSheetRuleCb(...p);
|
|
2151
|
-
};
|
|
2152
|
-
o.styleDeclarationCb = (...p) => {
|
|
2153
|
-
if (hooks.styleDeclaration) {
|
|
2154
|
-
hooks.styleDeclaration(...p);
|
|
2155
|
-
}
|
|
2156
|
-
styleDeclarationCb(...p);
|
|
2157
|
-
};
|
|
2158
|
-
o.canvasMutationCb = (...p) => {
|
|
2159
|
-
if (hooks.canvasMutation) {
|
|
2160
|
-
hooks.canvasMutation(...p);
|
|
2161
|
-
}
|
|
2162
|
-
canvasMutationCb(...p);
|
|
2163
|
-
};
|
|
2164
|
-
o.fontCb = (...p) => {
|
|
2165
|
-
if (hooks.font) {
|
|
2166
|
-
hooks.font(...p);
|
|
2167
|
-
}
|
|
2168
|
-
fontCb(...p);
|
|
2169
|
-
};
|
|
2170
|
-
}
|
|
2171
|
-
function initObservers(o, hooks = {}) {
|
|
2172
|
-
const currentWindow = o.doc.defaultView;
|
|
2173
|
-
if (!currentWindow) {
|
|
2174
|
-
return () => {
|
|
2175
|
-
};
|
|
2176
|
-
}
|
|
2177
|
-
mergeHooks(o, hooks);
|
|
2178
|
-
const mutationObserver = initMutationObserver(o, o.doc);
|
|
2179
|
-
const mousemoveHandler = initMoveObserver(o);
|
|
2180
|
-
const mouseInteractionHandler = initMouseInteractionObserver(o);
|
|
2181
|
-
const scrollHandler = initScrollObserver(o);
|
|
2182
|
-
const viewportResizeHandler = initViewportResizeObserver(o);
|
|
2183
|
-
const inputHandler = initInputObserver(o);
|
|
2184
|
-
const mediaInteractionHandler = initMediaInteractionObserver(o);
|
|
2185
|
-
const styleSheetObserver = initStyleSheetObserver(o, { win: currentWindow });
|
|
2186
|
-
const styleDeclarationObserver = initStyleDeclarationObserver(o, {
|
|
2187
|
-
win: currentWindow
|
|
2188
|
-
});
|
|
2189
|
-
const fontObserver = o.collectFonts ? initFontObserver(o) : () => {
|
|
2190
|
-
};
|
|
2191
|
-
const pluginHandlers = [];
|
|
2192
|
-
for (const plugin of o.plugins) {
|
|
2193
|
-
pluginHandlers.push(plugin.observer(plugin.callback, currentWindow, plugin.options));
|
|
2194
|
-
}
|
|
2195
|
-
return () => {
|
|
2196
|
-
mutationBuffers.forEach((b) => b.reset());
|
|
2197
|
-
mutationObserver.disconnect();
|
|
2198
|
-
mousemoveHandler();
|
|
2199
|
-
mouseInteractionHandler();
|
|
2200
|
-
scrollHandler();
|
|
2201
|
-
viewportResizeHandler();
|
|
2202
|
-
inputHandler();
|
|
2203
|
-
mediaInteractionHandler();
|
|
2204
|
-
styleSheetObserver();
|
|
2205
|
-
styleDeclarationObserver();
|
|
2206
|
-
fontObserver();
|
|
2207
|
-
pluginHandlers.forEach((h) => h());
|
|
2208
|
-
};
|
|
2209
|
-
}
|
|
2210
|
-
|
|
2211
|
-
class IframeManager {
|
|
2212
|
-
constructor(options) {
|
|
2213
|
-
this.iframes = /* @__PURE__ */ new WeakMap();
|
|
2214
|
-
this.mutationCb = options.mutationCb;
|
|
2215
|
-
}
|
|
2216
|
-
addIframe(iframeEl) {
|
|
2217
|
-
this.iframes.set(iframeEl, true);
|
|
2218
|
-
}
|
|
2219
|
-
addLoadListener(cb) {
|
|
2220
|
-
this.loadListener = cb;
|
|
2221
|
-
}
|
|
2222
|
-
attachIframe(iframeEl, childSn, mirror) {
|
|
2223
|
-
var _a;
|
|
2224
|
-
this.mutationCb({
|
|
2225
|
-
adds: [
|
|
2226
|
-
{
|
|
2227
|
-
parentId: mirror.getId(iframeEl),
|
|
2228
|
-
nextId: null,
|
|
2229
|
-
node: childSn
|
|
2230
|
-
}
|
|
2231
|
-
],
|
|
2232
|
-
removes: [],
|
|
2233
|
-
texts: [],
|
|
2234
|
-
attributes: [],
|
|
2235
|
-
isAttachIframe: true
|
|
2236
|
-
});
|
|
2237
|
-
(_a = this.loadListener) == null ? void 0 : _a.call(this, iframeEl);
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
|
-
|
|
2241
|
-
var __defProp$1 = Object.defineProperty;
|
|
2242
|
-
var __defProps$1 = Object.defineProperties;
|
|
2243
|
-
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
2244
|
-
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
2245
|
-
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
2246
|
-
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
2247
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2248
|
-
var __spreadValues$1 = (a, b) => {
|
|
2249
|
-
for (var prop in b || (b = {}))
|
|
2250
|
-
if (__hasOwnProp$2.call(b, prop))
|
|
2251
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
2252
|
-
if (__getOwnPropSymbols$2)
|
|
2253
|
-
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
2254
|
-
if (__propIsEnum$2.call(b, prop))
|
|
2255
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
2256
|
-
}
|
|
2257
|
-
return a;
|
|
2258
|
-
};
|
|
2259
|
-
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
2260
|
-
class ShadowDomManager {
|
|
2261
|
-
constructor(options) {
|
|
2262
|
-
this.restorePatches = [];
|
|
2263
|
-
this.mutationCb = options.mutationCb;
|
|
2264
|
-
this.scrollCb = options.scrollCb;
|
|
2265
|
-
this.bypassOptions = options.bypassOptions;
|
|
2266
|
-
this.mirror = options.mirror;
|
|
2267
|
-
const manager = this;
|
|
2268
|
-
this.restorePatches.push(patch(HTMLElement.prototype, "attachShadow", function(original) {
|
|
2269
|
-
return function() {
|
|
2270
|
-
const shadowRoot = original.apply(this, arguments);
|
|
2271
|
-
if (this.shadowRoot)
|
|
2272
|
-
manager.addShadowRoot(this.shadowRoot, this.ownerDocument);
|
|
2273
|
-
return shadowRoot;
|
|
2274
|
-
};
|
|
2275
|
-
}));
|
|
2276
|
-
}
|
|
2277
|
-
addShadowRoot(shadowRoot, doc) {
|
|
2278
|
-
initMutationObserver(__spreadProps$1(__spreadValues$1({}, this.bypassOptions), {
|
|
2279
|
-
doc,
|
|
2280
|
-
mutationCb: this.mutationCb,
|
|
2281
|
-
mirror: this.mirror,
|
|
2282
|
-
shadowDomManager: this
|
|
2283
|
-
}), shadowRoot);
|
|
2284
|
-
initScrollObserver(__spreadProps$1(__spreadValues$1({}, this.bypassOptions), {
|
|
2285
|
-
scrollCb: this.scrollCb,
|
|
2286
|
-
doc: shadowRoot,
|
|
2287
|
-
mirror: this.mirror
|
|
2288
|
-
}));
|
|
2289
|
-
}
|
|
2290
|
-
observeAttachShadow(iframeElement) {
|
|
2291
|
-
if (iframeElement.contentWindow) {
|
|
2292
|
-
const manager = this;
|
|
2293
|
-
this.restorePatches.push(patch(iframeElement.contentWindow.HTMLElement.prototype, "attachShadow", function(original) {
|
|
2294
|
-
return function() {
|
|
2295
|
-
const shadowRoot = original.apply(this, arguments);
|
|
2296
|
-
if (this.shadowRoot)
|
|
2297
|
-
manager.addShadowRoot(this.shadowRoot, iframeElement.contentDocument);
|
|
2298
|
-
return shadowRoot;
|
|
2299
|
-
};
|
|
2300
|
-
}));
|
|
2301
|
-
}
|
|
2302
|
-
}
|
|
2303
|
-
reset() {
|
|
2304
|
-
this.restorePatches.forEach((restorePatch) => restorePatch());
|
|
2305
|
-
}
|
|
2306
|
-
}
|
|
2307
|
-
|
|
2308
|
-
/*
|
|
2309
|
-
* base64-arraybuffer 1.0.1 <https://github.com/niklasvh/base64-arraybuffer>
|
|
2310
|
-
* Copyright (c) 2021 Niklas von Hertzen <https://hertzen.com>
|
|
2311
|
-
* Released under MIT License
|
|
2312
|
-
*/
|
|
2313
|
-
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
2314
|
-
// Use a lookup table to find the index.
|
|
2315
|
-
var lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
|
|
2316
|
-
for (var i = 0; i < chars.length; i++) {
|
|
2317
|
-
lookup[chars.charCodeAt(i)] = i;
|
|
2318
|
-
}
|
|
2319
|
-
var encode = function (arraybuffer) {
|
|
2320
|
-
var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';
|
|
2321
|
-
for (i = 0; i < len; i += 3) {
|
|
2322
|
-
base64 += chars[bytes[i] >> 2];
|
|
2323
|
-
base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
|
|
2324
|
-
base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
|
|
2325
|
-
base64 += chars[bytes[i + 2] & 63];
|
|
2326
|
-
}
|
|
2327
|
-
if (len % 3 === 2) {
|
|
2328
|
-
base64 = base64.substring(0, base64.length - 1) + '=';
|
|
2329
|
-
}
|
|
2330
|
-
else if (len % 3 === 1) {
|
|
2331
|
-
base64 = base64.substring(0, base64.length - 2) + '==';
|
|
2332
|
-
}
|
|
2333
|
-
return base64;
|
|
2334
|
-
};
|
|
2335
|
-
|
|
2336
|
-
const canvasVarMap = /* @__PURE__ */ new Map();
|
|
2337
|
-
function variableListFor(ctx, ctor) {
|
|
2338
|
-
let contextMap = canvasVarMap.get(ctx);
|
|
2339
|
-
if (!contextMap) {
|
|
2340
|
-
contextMap = /* @__PURE__ */ new Map();
|
|
2341
|
-
canvasVarMap.set(ctx, contextMap);
|
|
2342
|
-
}
|
|
2343
|
-
if (!contextMap.has(ctor)) {
|
|
2344
|
-
contextMap.set(ctor, []);
|
|
2345
|
-
}
|
|
2346
|
-
return contextMap.get(ctor);
|
|
2347
|
-
}
|
|
2348
|
-
const saveWebGLVar = (value, win, ctx) => {
|
|
2349
|
-
if (!value || !(isInstanceOfWebGLObject(value, win) || typeof value === "object"))
|
|
2350
|
-
return;
|
|
2351
|
-
const name = value.constructor.name;
|
|
2352
|
-
const list = variableListFor(ctx, name);
|
|
2353
|
-
let index = list.indexOf(value);
|
|
2354
|
-
if (index === -1) {
|
|
2355
|
-
index = list.length;
|
|
2356
|
-
list.push(value);
|
|
2357
|
-
}
|
|
2358
|
-
return index;
|
|
2359
|
-
};
|
|
2360
|
-
function serializeArg(value, win, ctx) {
|
|
2361
|
-
if (value instanceof Array) {
|
|
2362
|
-
return value.map((arg) => serializeArg(arg, win, ctx));
|
|
2363
|
-
} else if (value === null) {
|
|
2364
|
-
return value;
|
|
2365
|
-
} else if (value instanceof Float32Array || value instanceof Float64Array || value instanceof Int32Array || value instanceof Uint32Array || value instanceof Uint8Array || value instanceof Uint16Array || value instanceof Int16Array || value instanceof Int8Array || value instanceof Uint8ClampedArray) {
|
|
2366
|
-
const name = value.constructor.name;
|
|
2367
|
-
return {
|
|
2368
|
-
rr_type: name,
|
|
2369
|
-
args: [Object.values(value)]
|
|
2370
|
-
};
|
|
2371
|
-
} else if (value instanceof ArrayBuffer) {
|
|
2372
|
-
const name = value.constructor.name;
|
|
2373
|
-
const base64 = encode(value);
|
|
2374
|
-
return {
|
|
2375
|
-
rr_type: name,
|
|
2376
|
-
base64
|
|
2377
|
-
};
|
|
2378
|
-
} else if (value instanceof DataView) {
|
|
2379
|
-
const name = value.constructor.name;
|
|
2380
|
-
return {
|
|
2381
|
-
rr_type: name,
|
|
2382
|
-
args: [
|
|
2383
|
-
serializeArg(value.buffer, win, ctx),
|
|
2384
|
-
value.byteOffset,
|
|
2385
|
-
value.byteLength
|
|
2386
|
-
]
|
|
2387
|
-
};
|
|
2388
|
-
} else if (value instanceof HTMLImageElement) {
|
|
2389
|
-
const name = value.constructor.name;
|
|
2390
|
-
const { src } = value;
|
|
2391
|
-
return {
|
|
2392
|
-
rr_type: name,
|
|
2393
|
-
src
|
|
2394
|
-
};
|
|
2395
|
-
} else if (value instanceof HTMLCanvasElement) {
|
|
2396
|
-
const name = "HTMLImageElement";
|
|
2397
|
-
const src = value.toDataURL();
|
|
2398
|
-
return {
|
|
2399
|
-
rr_type: name,
|
|
2400
|
-
src
|
|
2401
|
-
};
|
|
2402
|
-
} else if (value instanceof ImageData) {
|
|
2403
|
-
const name = value.constructor.name;
|
|
2404
|
-
return {
|
|
2405
|
-
rr_type: name,
|
|
2406
|
-
args: [serializeArg(value.data, win, ctx), value.width, value.height]
|
|
2407
|
-
};
|
|
2408
|
-
} else if (isInstanceOfWebGLObject(value, win) || typeof value === "object") {
|
|
2409
|
-
const name = value.constructor.name;
|
|
2410
|
-
const index = saveWebGLVar(value, win, ctx);
|
|
2411
|
-
return {
|
|
2412
|
-
rr_type: name,
|
|
2413
|
-
index
|
|
2414
|
-
};
|
|
2415
|
-
}
|
|
2416
|
-
return value;
|
|
2417
|
-
}
|
|
2418
|
-
const serializeArgs = (args, win, ctx) => {
|
|
2419
|
-
return [...args].map((arg) => serializeArg(arg, win, ctx));
|
|
2420
|
-
};
|
|
2421
|
-
const isInstanceOfWebGLObject = (value, win) => {
|
|
2422
|
-
const webGLConstructorNames = [
|
|
2423
|
-
"WebGLActiveInfo",
|
|
2424
|
-
"WebGLBuffer",
|
|
2425
|
-
"WebGLFramebuffer",
|
|
2426
|
-
"WebGLProgram",
|
|
2427
|
-
"WebGLRenderbuffer",
|
|
2428
|
-
"WebGLShader",
|
|
2429
|
-
"WebGLShaderPrecisionFormat",
|
|
2430
|
-
"WebGLTexture",
|
|
2431
|
-
"WebGLUniformLocation",
|
|
2432
|
-
"WebGLVertexArrayObject",
|
|
2433
|
-
"WebGLVertexArrayObjectOES"
|
|
2434
|
-
];
|
|
2435
|
-
const supportedWebGLConstructorNames = webGLConstructorNames.filter((name) => typeof win[name] === "function");
|
|
2436
|
-
return Boolean(supportedWebGLConstructorNames.find((name) => value instanceof win[name]));
|
|
2437
|
-
};
|
|
2438
|
-
|
|
2439
|
-
function initCanvas2DMutationObserver(cb, win, blockClass2, mirror) {
|
|
2440
|
-
const handlers = [];
|
|
2441
|
-
const props2D = Object.getOwnPropertyNames(win.CanvasRenderingContext2D.prototype);
|
|
2442
|
-
for (const prop of props2D) {
|
|
2443
|
-
try {
|
|
2444
|
-
if (typeof win.CanvasRenderingContext2D.prototype[prop] !== "function") {
|
|
2445
|
-
continue;
|
|
2446
|
-
}
|
|
2447
|
-
const restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function(original) {
|
|
2448
|
-
return function(...args) {
|
|
2449
|
-
if (!isBlocked(this.canvas, blockClass2)) {
|
|
2450
|
-
setTimeout(() => {
|
|
2451
|
-
const recordArgs = serializeArgs([...args], win, this);
|
|
2452
|
-
cb(this.canvas, {
|
|
2453
|
-
type: CanvasContext["2D"],
|
|
2454
|
-
property: prop,
|
|
2455
|
-
args: recordArgs
|
|
2456
|
-
});
|
|
2457
|
-
}, 0);
|
|
2458
|
-
}
|
|
2459
|
-
return original.apply(this, args);
|
|
2460
|
-
};
|
|
2461
|
-
});
|
|
2462
|
-
handlers.push(restoreHandler);
|
|
2463
|
-
} catch (e) {
|
|
2464
|
-
const hookHandler = hookSetter(win.CanvasRenderingContext2D.prototype, prop, {
|
|
2465
|
-
set(v) {
|
|
2466
|
-
cb(this.canvas, {
|
|
2467
|
-
type: CanvasContext["2D"],
|
|
2468
|
-
property: prop,
|
|
2469
|
-
args: [v],
|
|
2470
|
-
setter: true
|
|
2471
|
-
});
|
|
2472
|
-
}
|
|
2473
|
-
});
|
|
2474
|
-
handlers.push(hookHandler);
|
|
2475
|
-
}
|
|
2476
|
-
}
|
|
2477
|
-
return () => {
|
|
2478
|
-
handlers.forEach((h) => h());
|
|
2479
|
-
};
|
|
2480
|
-
}
|
|
2481
|
-
|
|
2482
|
-
function initCanvasContextObserver(win, blockClass) {
|
|
2483
|
-
const handlers = [];
|
|
2484
|
-
try {
|
|
2485
|
-
const restoreHandler = patch(win.HTMLCanvasElement.prototype, "getContext", function(original) {
|
|
2486
|
-
return function(contextType, ...args) {
|
|
2487
|
-
if (!isBlocked(this, blockClass)) {
|
|
2488
|
-
if (!("__context" in this))
|
|
2489
|
-
this.__context = contextType;
|
|
2490
|
-
}
|
|
2491
|
-
return original.apply(this, [contextType, ...args]);
|
|
2492
|
-
};
|
|
2493
|
-
});
|
|
2494
|
-
handlers.push(restoreHandler);
|
|
2495
|
-
} catch (e) {
|
|
2496
|
-
console.error("failed to patch HTMLCanvasElement.prototype.getContext");
|
|
2497
|
-
}
|
|
2498
|
-
return () => {
|
|
2499
|
-
handlers.forEach((h) => h());
|
|
2500
|
-
};
|
|
2501
|
-
}
|
|
2502
|
-
|
|
2503
|
-
function patchGLPrototype(prototype, type, cb, blockClass2, mirror, win) {
|
|
2504
|
-
const handlers = [];
|
|
2505
|
-
const props = Object.getOwnPropertyNames(prototype);
|
|
2506
|
-
for (const prop of props) {
|
|
2507
|
-
try {
|
|
2508
|
-
if (typeof prototype[prop] !== "function") {
|
|
2509
|
-
continue;
|
|
2510
|
-
}
|
|
2511
|
-
const restoreHandler = patch(prototype, prop, function(original) {
|
|
2512
|
-
return function(...args) {
|
|
2513
|
-
const result = original.apply(this, args);
|
|
2514
|
-
saveWebGLVar(result, win, prototype);
|
|
2515
|
-
if (!isBlocked(this.canvas, blockClass2)) {
|
|
2516
|
-
const id = mirror.getId(this.canvas);
|
|
2517
|
-
const recordArgs = serializeArgs([...args], win, prototype);
|
|
2518
|
-
const mutation = {
|
|
2519
|
-
type,
|
|
2520
|
-
property: prop,
|
|
2521
|
-
args: recordArgs
|
|
2522
|
-
};
|
|
2523
|
-
cb(this.canvas, mutation);
|
|
2524
|
-
}
|
|
2525
|
-
return result;
|
|
2526
|
-
};
|
|
2527
|
-
});
|
|
2528
|
-
handlers.push(restoreHandler);
|
|
2529
|
-
} catch (e) {
|
|
2530
|
-
const hookHandler = hookSetter(prototype, prop, {
|
|
2531
|
-
set(v) {
|
|
2532
|
-
cb(this.canvas, {
|
|
2533
|
-
type,
|
|
2534
|
-
property: prop,
|
|
2535
|
-
args: [v],
|
|
2536
|
-
setter: true
|
|
2537
|
-
});
|
|
2538
|
-
}
|
|
2539
|
-
});
|
|
2540
|
-
handlers.push(hookHandler);
|
|
2541
|
-
}
|
|
2542
|
-
}
|
|
2543
|
-
return handlers;
|
|
2544
|
-
}
|
|
2545
|
-
function initCanvasWebGLMutationObserver(cb, win, blockClass2, mirror) {
|
|
2546
|
-
const handlers = [];
|
|
2547
|
-
handlers.push(...patchGLPrototype(win.WebGLRenderingContext.prototype, CanvasContext.WebGL, cb, blockClass2, mirror, win));
|
|
2548
|
-
if (typeof win.WebGL2RenderingContext !== "undefined") {
|
|
2549
|
-
handlers.push(...patchGLPrototype(win.WebGL2RenderingContext.prototype, CanvasContext.WebGL2, cb, blockClass2, mirror, win));
|
|
2550
|
-
}
|
|
2551
|
-
return () => {
|
|
2552
|
-
handlers.forEach((h) => h());
|
|
2553
|
-
};
|
|
2554
|
-
}
|
|
2555
|
-
|
|
2556
|
-
function decodeBase64(base64, enableUnicode) {
|
|
2557
|
-
var binaryString = atob(base64);
|
|
2558
|
-
if (enableUnicode) {
|
|
2559
|
-
var binaryView = new Uint8Array(binaryString.length);
|
|
2560
|
-
for (var i = 0, n = binaryString.length; i < n; ++i) {
|
|
2561
|
-
binaryView[i] = binaryString.charCodeAt(i);
|
|
2562
|
-
}
|
|
2563
|
-
return String.fromCharCode.apply(null, new Uint16Array(binaryView.buffer));
|
|
2564
|
-
}
|
|
2565
|
-
return binaryString;
|
|
2566
|
-
}
|
|
2567
|
-
|
|
2568
|
-
function createURL(base64, sourcemapArg, enableUnicodeArg) {
|
|
2569
|
-
var sourcemap = sourcemapArg === undefined ? null : sourcemapArg;
|
|
2570
|
-
var enableUnicode = enableUnicodeArg === undefined ? false : enableUnicodeArg;
|
|
2571
|
-
var source = decodeBase64(base64, enableUnicode);
|
|
2572
|
-
var start = source.indexOf('\n', 10) + 1;
|
|
2573
|
-
var body = source.substring(start) + (sourcemap ? '\/\/# sourceMappingURL=' + sourcemap : '');
|
|
2574
|
-
var blob = new Blob([body], { type: 'application/javascript' });
|
|
2575
|
-
return URL.createObjectURL(blob);
|
|
2576
|
-
}
|
|
2577
|
-
|
|
2578
|
-
function createBase64WorkerFactory(base64, sourcemapArg, enableUnicodeArg) {
|
|
2579
|
-
var url;
|
|
2580
|
-
return function WorkerFactory(options) {
|
|
2581
|
-
url = url || createURL(base64, sourcemapArg, enableUnicodeArg);
|
|
2582
|
-
return new Worker(url, options);
|
|
2583
|
-
};
|
|
2584
|
-
}
|
|
2585
|
-
|
|
2586
|
-
var WorkerFactory = createBase64WorkerFactory('Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qCiAgICAgKiBiYXNlNjQtYXJyYXlidWZmZXIgMS4wLjEgPGh0dHBzOi8vZ2l0aHViLmNvbS9uaWtsYXN2aC9iYXNlNjQtYXJyYXlidWZmZXI+CiAgICAgKiBDb3B5cmlnaHQgKGMpIDIwMjEgTmlrbGFzIHZvbiBIZXJ0emVuIDxodHRwczovL2hlcnR6ZW4uY29tPgogICAgICogUmVsZWFzZWQgdW5kZXIgTUlUIExpY2Vuc2UKICAgICAqLwogICAgdmFyIGNoYXJzID0gJ0FCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXowMTIzNDU2Nzg5Ky8nOwogICAgLy8gVXNlIGEgbG9va3VwIHRhYmxlIHRvIGZpbmQgdGhlIGluZGV4LgogICAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAndW5kZWZpbmVkJyA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICAgIGZvciAodmFyIGkgPSAwOyBpIDwgY2hhcnMubGVuZ3RoOyBpKyspIHsKICAgICAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogICAgfQogICAgdmFyIGVuY29kZSA9IGZ1bmN0aW9uIChhcnJheWJ1ZmZlcikgewogICAgICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaSwgbGVuID0gYnl0ZXMubGVuZ3RoLCBiYXNlNjQgPSAnJzsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgbGVuOyBpICs9IDMpIHsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2ldID4+IDJdOwogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbKChieXRlc1tpXSAmIDMpIDw8IDQpIHwgKGJ5dGVzW2kgKyAxXSA+PiA0KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2kgKyAxXSAmIDE1KSA8PCAyKSB8IChieXRlc1tpICsgMl0gPj4gNildOwogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaSArIDJdICYgNjNdOwogICAgICAgIH0KICAgICAgICBpZiAobGVuICUgMyA9PT0gMikgewogICAgICAgICAgICBiYXNlNjQgPSBiYXNlNjQuc3Vic3RyaW5nKDAsIGJhc2U2NC5sZW5ndGggLSAxKSArICc9JzsKICAgICAgICB9CiAgICAgICAgZWxzZSBpZiAobGVuICUgMyA9PT0gMSkgewogICAgICAgICAgICBiYXNlNjQgPSBiYXNlNjQuc3Vic3RyaW5nKDAsIGJhc2U2NC5sZW5ndGggLSAyKSArICc9PSc7CiAgICAgICAgfQogICAgICAgIHJldHVybiBiYXNlNjQ7CiAgICB9OwoKICAgIGNvbnN0IGxhc3RCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICAgIGNvbnN0IHRyYW5zcGFyZW50QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCkgewogICAgICBjb25zdCBpZCA9IGAke3dpZHRofS0ke2hlaWdodH1gOwogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpCiAgICAgICAgcmV0dXJuIHRyYW5zcGFyZW50QmxvYk1hcC5nZXQoaWQpOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKCk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsKICAgIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICAgIGlmICghKCJPZmZzY3JlZW5DYW52YXMiIGluIGdsb2JhbFRoaXMpKQogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZDogZS5kYXRhLmlkIH0pOwogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQgfSA9IGUuZGF0YTsKICAgICAgY29uc3QgdHJhbnNwYXJlbnRCYXNlNjQgPSBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCk7CiAgICAgIGNvbnN0IG9mZnNjcmVlbiA9IG5ldyBPZmZzY3JlZW5DYW52YXMod2lkdGgsIGhlaWdodCk7CiAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCIyZCIpOwogICAgICBjdHguZHJhd0ltYWdlKGJpdG1hcCwgMCwgMCk7CiAgICAgIGJpdG1hcC5jbG9zZSgpOwogICAgICBjb25zdCBibG9iID0gYXdhaXQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsKICAgICAgICBpZCwKICAgICAgICB0eXBlLAogICAgICAgIGJhc2U2NCwKICAgICAgICB3aWR0aCwKICAgICAgICBoZWlnaHQKICAgICAgfSk7CiAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsKICAgIH07Cgp9KSgpOwoK', null, false);
|
|
2587
|
-
/* eslint-enable */
|
|
2588
|
-
|
|
2589
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
2590
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
2591
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
2592
|
-
var __objRest = (source, exclude) => {
|
|
2593
|
-
var target = {};
|
|
2594
|
-
for (var prop in source)
|
|
2595
|
-
if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2596
|
-
target[prop] = source[prop];
|
|
2597
|
-
if (source != null && __getOwnPropSymbols$1)
|
|
2598
|
-
for (var prop of __getOwnPropSymbols$1(source)) {
|
|
2599
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
|
|
2600
|
-
target[prop] = source[prop];
|
|
2601
|
-
}
|
|
2602
|
-
return target;
|
|
2603
|
-
};
|
|
2604
|
-
var __async = (__this, __arguments, generator) => {
|
|
2605
|
-
return new Promise((resolve, reject) => {
|
|
2606
|
-
var fulfilled = (value) => {
|
|
2607
|
-
try {
|
|
2608
|
-
step(generator.next(value));
|
|
2609
|
-
} catch (e) {
|
|
2610
|
-
reject(e);
|
|
2611
|
-
}
|
|
2612
|
-
};
|
|
2613
|
-
var rejected = (value) => {
|
|
2614
|
-
try {
|
|
2615
|
-
step(generator.throw(value));
|
|
2616
|
-
} catch (e) {
|
|
2617
|
-
reject(e);
|
|
2618
|
-
}
|
|
2619
|
-
};
|
|
2620
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2621
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
2622
|
-
});
|
|
2623
|
-
};
|
|
2624
|
-
class CanvasManager {
|
|
2625
|
-
constructor(options) {
|
|
2626
|
-
this.pendingCanvasMutations = /* @__PURE__ */ new Map();
|
|
2627
|
-
this.rafStamps = { latestId: 0, invokeId: null };
|
|
2628
|
-
this.frozen = false;
|
|
2629
|
-
this.locked = false;
|
|
2630
|
-
this.processMutation = function(target, mutation) {
|
|
2631
|
-
const newFrame = this.rafStamps.invokeId && this.rafStamps.latestId !== this.rafStamps.invokeId;
|
|
2632
|
-
if (newFrame || !this.rafStamps.invokeId)
|
|
2633
|
-
this.rafStamps.invokeId = this.rafStamps.latestId;
|
|
2634
|
-
if (!this.pendingCanvasMutations.has(target)) {
|
|
2635
|
-
this.pendingCanvasMutations.set(target, []);
|
|
2636
|
-
}
|
|
2637
|
-
this.pendingCanvasMutations.get(target).push(mutation);
|
|
2638
|
-
};
|
|
2639
|
-
const { sampling = "all", win, blockClass, recordCanvas } = options;
|
|
2640
|
-
this.mutationCb = options.mutationCb;
|
|
2641
|
-
this.mirror = options.mirror;
|
|
2642
|
-
if (recordCanvas && sampling === "all")
|
|
2643
|
-
this.initCanvasMutationObserver(win, blockClass);
|
|
2644
|
-
if (recordCanvas && typeof sampling === "number")
|
|
2645
|
-
this.initCanvasFPSObserver(sampling, win, blockClass);
|
|
2646
|
-
}
|
|
2647
|
-
reset() {
|
|
2648
|
-
this.pendingCanvasMutations.clear();
|
|
2649
|
-
this.resetObservers && this.resetObservers();
|
|
2650
|
-
}
|
|
2651
|
-
freeze() {
|
|
2652
|
-
this.frozen = true;
|
|
2653
|
-
}
|
|
2654
|
-
unfreeze() {
|
|
2655
|
-
this.frozen = false;
|
|
2656
|
-
}
|
|
2657
|
-
lock() {
|
|
2658
|
-
this.locked = true;
|
|
2659
|
-
}
|
|
2660
|
-
unlock() {
|
|
2661
|
-
this.locked = false;
|
|
2662
|
-
}
|
|
2663
|
-
initCanvasFPSObserver(fps, win, blockClass) {
|
|
2664
|
-
const canvasContextReset = initCanvasContextObserver(win, blockClass);
|
|
2665
|
-
const snapshotInProgressMap = /* @__PURE__ */ new Map();
|
|
2666
|
-
const worker = new WorkerFactory();
|
|
2667
|
-
worker.onmessage = (e) => {
|
|
2668
|
-
const { id } = e.data;
|
|
2669
|
-
snapshotInProgressMap.set(id, false);
|
|
2670
|
-
if (!("base64" in e.data))
|
|
2671
|
-
return;
|
|
2672
|
-
const { base64, type, width, height } = e.data;
|
|
2673
|
-
this.mutationCb({
|
|
2674
|
-
id,
|
|
2675
|
-
type: CanvasContext["2D"],
|
|
2676
|
-
commands: [
|
|
2677
|
-
{
|
|
2678
|
-
property: "clearRect",
|
|
2679
|
-
args: [0, 0, width, height]
|
|
2680
|
-
},
|
|
2681
|
-
{
|
|
2682
|
-
property: "drawImage",
|
|
2683
|
-
args: [
|
|
2684
|
-
{
|
|
2685
|
-
rr_type: "ImageBitmap",
|
|
2686
|
-
args: [
|
|
2687
|
-
{
|
|
2688
|
-
rr_type: "Blob",
|
|
2689
|
-
data: [{ rr_type: "ArrayBuffer", base64 }],
|
|
2690
|
-
type
|
|
2691
|
-
}
|
|
2692
|
-
]
|
|
2693
|
-
},
|
|
2694
|
-
0,
|
|
2695
|
-
0
|
|
2696
|
-
]
|
|
2697
|
-
}
|
|
2698
|
-
]
|
|
2699
|
-
});
|
|
2700
|
-
};
|
|
2701
|
-
const timeBetweenSnapshots = 1e3 / fps;
|
|
2702
|
-
let lastSnapshotTime = 0;
|
|
2703
|
-
let rafId;
|
|
2704
|
-
const takeCanvasSnapshots = (timestamp) => {
|
|
2705
|
-
if (lastSnapshotTime && timestamp - lastSnapshotTime < timeBetweenSnapshots) {
|
|
2706
|
-
rafId = requestAnimationFrame(takeCanvasSnapshots);
|
|
2707
|
-
return;
|
|
2708
|
-
}
|
|
2709
|
-
lastSnapshotTime = timestamp;
|
|
2710
|
-
win.document.querySelectorAll(`canvas:not(.${blockClass} *)`).forEach((canvas) => __async(this, null, function* () {
|
|
2711
|
-
var _a;
|
|
2712
|
-
const id = this.mirror.getId(canvas);
|
|
2713
|
-
if (snapshotInProgressMap.get(id))
|
|
2714
|
-
return;
|
|
2715
|
-
snapshotInProgressMap.set(id, true);
|
|
2716
|
-
if (["webgl", "webgl2"].includes(canvas.__context)) {
|
|
2717
|
-
const context = canvas.getContext(canvas.__context);
|
|
2718
|
-
if (((_a = context == null ? void 0 : context.getContextAttributes()) == null ? void 0 : _a.preserveDrawingBuffer) === false) {
|
|
2719
|
-
context == null ? void 0 : context.clear(context.COLOR_BUFFER_BIT);
|
|
2720
|
-
}
|
|
2721
|
-
}
|
|
2722
|
-
const bitmap = yield createImageBitmap(canvas);
|
|
2723
|
-
worker.postMessage({
|
|
2724
|
-
id,
|
|
2725
|
-
bitmap,
|
|
2726
|
-
width: canvas.width,
|
|
2727
|
-
height: canvas.height
|
|
2728
|
-
}, [bitmap]);
|
|
2729
|
-
}));
|
|
2730
|
-
rafId = requestAnimationFrame(takeCanvasSnapshots);
|
|
2731
|
-
};
|
|
2732
|
-
rafId = requestAnimationFrame(takeCanvasSnapshots);
|
|
2733
|
-
this.resetObservers = () => {
|
|
2734
|
-
canvasContextReset();
|
|
2735
|
-
cancelAnimationFrame(rafId);
|
|
2736
|
-
};
|
|
2737
|
-
}
|
|
2738
|
-
initCanvasMutationObserver(win, blockClass) {
|
|
2739
|
-
this.startRAFTimestamping();
|
|
2740
|
-
this.startPendingCanvasMutationFlusher();
|
|
2741
|
-
const canvasContextReset = initCanvasContextObserver(win, blockClass);
|
|
2742
|
-
const canvas2DReset = initCanvas2DMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
|
|
2743
|
-
const canvasWebGL1and2Reset = initCanvasWebGLMutationObserver(this.processMutation.bind(this), win, blockClass, this.mirror);
|
|
2744
|
-
this.resetObservers = () => {
|
|
2745
|
-
canvasContextReset();
|
|
2746
|
-
canvas2DReset();
|
|
2747
|
-
canvasWebGL1and2Reset();
|
|
2748
|
-
};
|
|
2749
|
-
}
|
|
2750
|
-
startPendingCanvasMutationFlusher() {
|
|
2751
|
-
requestAnimationFrame(() => this.flushPendingCanvasMutations());
|
|
2752
|
-
}
|
|
2753
|
-
startRAFTimestamping() {
|
|
2754
|
-
const setLatestRAFTimestamp = (timestamp) => {
|
|
2755
|
-
this.rafStamps.latestId = timestamp;
|
|
2756
|
-
requestAnimationFrame(setLatestRAFTimestamp);
|
|
2757
|
-
};
|
|
2758
|
-
requestAnimationFrame(setLatestRAFTimestamp);
|
|
2759
|
-
}
|
|
2760
|
-
flushPendingCanvasMutations() {
|
|
2761
|
-
this.pendingCanvasMutations.forEach((values, canvas) => {
|
|
2762
|
-
const id = this.mirror.getId(canvas);
|
|
2763
|
-
this.flushPendingCanvasMutationFor(canvas, id);
|
|
2764
|
-
});
|
|
2765
|
-
requestAnimationFrame(() => this.flushPendingCanvasMutations());
|
|
2766
|
-
}
|
|
2767
|
-
flushPendingCanvasMutationFor(canvas, id) {
|
|
2768
|
-
if (this.frozen || this.locked) {
|
|
2769
|
-
return;
|
|
2770
|
-
}
|
|
2771
|
-
const valuesWithType = this.pendingCanvasMutations.get(canvas);
|
|
2772
|
-
if (!valuesWithType || id === -1)
|
|
2773
|
-
return;
|
|
2774
|
-
const values = valuesWithType.map((value) => {
|
|
2775
|
-
const _a = value, rest = __objRest(_a, ["type"]);
|
|
2776
|
-
return rest;
|
|
2777
|
-
});
|
|
2778
|
-
const { type } = valuesWithType[0];
|
|
2779
|
-
this.mutationCb({ id, type, commands: values });
|
|
2780
|
-
this.pendingCanvasMutations.delete(canvas);
|
|
2781
|
-
}
|
|
2782
|
-
}
|
|
2783
|
-
|
|
2784
|
-
class StylesheetManager {
|
|
2785
|
-
constructor(options) {
|
|
2786
|
-
this.trackedStylesheets = /* @__PURE__ */ new WeakSet();
|
|
2787
|
-
this.mutationCb = options.mutationCb;
|
|
2788
|
-
}
|
|
2789
|
-
addStylesheet(linkEl) {
|
|
2790
|
-
if (this.trackedStylesheets.has(linkEl))
|
|
2791
|
-
return;
|
|
2792
|
-
this.trackedStylesheets.add(linkEl);
|
|
2793
|
-
this.trackStylesheet(linkEl);
|
|
2794
|
-
}
|
|
2795
|
-
trackStylesheet(linkEl) {
|
|
2796
|
-
}
|
|
2797
|
-
attachStylesheet(linkEl, childSn, mirror) {
|
|
2798
|
-
this.mutationCb({
|
|
2799
|
-
adds: [
|
|
2800
|
-
{
|
|
2801
|
-
parentId: mirror.getId(linkEl),
|
|
2802
|
-
nextId: null,
|
|
2803
|
-
node: childSn
|
|
2804
|
-
}
|
|
2805
|
-
],
|
|
2806
|
-
removes: [],
|
|
2807
|
-
texts: [],
|
|
2808
|
-
attributes: []
|
|
2809
|
-
});
|
|
2810
|
-
this.addStylesheet(linkEl);
|
|
2811
|
-
}
|
|
2812
|
-
}
|
|
2813
|
-
|
|
2814
|
-
var __defProp = Object.defineProperty;
|
|
2815
|
-
var __defProps = Object.defineProperties;
|
|
2816
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
2817
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
2818
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2819
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
2820
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2821
|
-
var __spreadValues = (a, b) => {
|
|
2822
|
-
for (var prop in b || (b = {}))
|
|
2823
|
-
if (__hasOwnProp.call(b, prop))
|
|
2824
|
-
__defNormalProp(a, prop, b[prop]);
|
|
2825
|
-
if (__getOwnPropSymbols)
|
|
2826
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
2827
|
-
if (__propIsEnum.call(b, prop))
|
|
2828
|
-
__defNormalProp(a, prop, b[prop]);
|
|
2829
|
-
}
|
|
2830
|
-
return a;
|
|
2831
|
-
};
|
|
2832
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
2833
|
-
function wrapEvent(e) {
|
|
2834
|
-
return __spreadProps(__spreadValues({}, e), {
|
|
2835
|
-
timestamp: Date.now()
|
|
2836
|
-
});
|
|
2837
|
-
}
|
|
2838
|
-
let wrappedEmit;
|
|
2839
|
-
let takeFullSnapshot;
|
|
2840
|
-
const mirror = createMirror();
|
|
2841
|
-
function record(options = {}) {
|
|
2842
|
-
const {
|
|
2843
|
-
emit,
|
|
2844
|
-
checkoutEveryNms,
|
|
2845
|
-
checkoutEveryNth,
|
|
2846
|
-
blockClass = "highlight-block",
|
|
2847
|
-
blockSelector = null,
|
|
2848
|
-
ignoreClass = "highlight-ignore",
|
|
2849
|
-
maskTextClass = "highlight-mask",
|
|
2850
|
-
maskTextSelector = null,
|
|
2851
|
-
inlineStylesheet = true,
|
|
2852
|
-
maskAllInputs,
|
|
2853
|
-
maskInputOptions: _maskInputOptions,
|
|
2854
|
-
slimDOMOptions: _slimDOMOptions,
|
|
2855
|
-
maskInputFn,
|
|
2856
|
-
maskTextFn,
|
|
2857
|
-
hooks,
|
|
2858
|
-
packFn,
|
|
2859
|
-
sampling = {},
|
|
2860
|
-
mousemoveWait,
|
|
2861
|
-
recordCanvas = false,
|
|
2862
|
-
userTriggeredOnInput = false,
|
|
2863
|
-
collectFonts = false,
|
|
2864
|
-
inlineImages = false,
|
|
2865
|
-
plugins,
|
|
2866
|
-
keepIframeSrcFn = () => false,
|
|
2867
|
-
enableStrictPrivacy = false
|
|
2868
|
-
} = options;
|
|
2869
|
-
if (!emit) {
|
|
2870
|
-
throw new Error("emit function is required");
|
|
2871
|
-
}
|
|
2872
|
-
if (mousemoveWait !== void 0 && sampling.mousemove === void 0) {
|
|
2873
|
-
sampling.mousemove = mousemoveWait;
|
|
2874
|
-
}
|
|
2875
|
-
mirror.reset();
|
|
2876
|
-
const maskInputOptions = maskAllInputs === true ? {
|
|
2877
|
-
color: true,
|
|
2878
|
-
date: true,
|
|
2879
|
-
"datetime-local": true,
|
|
2880
|
-
email: true,
|
|
2881
|
-
month: true,
|
|
2882
|
-
number: true,
|
|
2883
|
-
range: true,
|
|
2884
|
-
search: true,
|
|
2885
|
-
tel: true,
|
|
2886
|
-
text: true,
|
|
2887
|
-
time: true,
|
|
2888
|
-
url: true,
|
|
2889
|
-
week: true,
|
|
2890
|
-
textarea: true,
|
|
2891
|
-
select: true,
|
|
2892
|
-
password: true
|
|
2893
|
-
} : _maskInputOptions !== void 0 ? _maskInputOptions : { password: true };
|
|
2894
|
-
const slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === "all" ? {
|
|
2895
|
-
script: true,
|
|
2896
|
-
comment: true,
|
|
2897
|
-
headFavicon: true,
|
|
2898
|
-
headWhitespace: true,
|
|
2899
|
-
headMetaSocial: true,
|
|
2900
|
-
headMetaRobots: true,
|
|
2901
|
-
headMetaHttpEquiv: true,
|
|
2902
|
-
headMetaVerification: true,
|
|
2903
|
-
headMetaAuthorship: _slimDOMOptions === "all",
|
|
2904
|
-
headMetaDescKeywords: _slimDOMOptions === "all"
|
|
2905
|
-
} : _slimDOMOptions ? _slimDOMOptions : {};
|
|
2906
|
-
polyfill();
|
|
2907
|
-
let lastFullSnapshotEvent;
|
|
2908
|
-
let incrementalSnapshotCount = 0;
|
|
2909
|
-
const eventProcessor = (e) => {
|
|
2910
|
-
for (const plugin of plugins || []) {
|
|
2911
|
-
if (plugin.eventProcessor) {
|
|
2912
|
-
e = plugin.eventProcessor(e);
|
|
2913
|
-
}
|
|
2914
|
-
}
|
|
2915
|
-
if (packFn) {
|
|
2916
|
-
e = packFn(e);
|
|
2917
|
-
}
|
|
2918
|
-
return e;
|
|
2919
|
-
};
|
|
2920
|
-
wrappedEmit = (e, isCheckout) => {
|
|
2921
|
-
var _a;
|
|
2922
|
-
if (((_a = mutationBuffers[0]) == null ? void 0 : _a.isFrozen()) && e.type !== EventType.FullSnapshot && !(e.type === EventType.IncrementalSnapshot && e.data.source === IncrementalSource.Mutation)) {
|
|
2923
|
-
mutationBuffers.forEach((buf) => buf.unfreeze());
|
|
2924
|
-
}
|
|
2925
|
-
emit(eventProcessor(e), isCheckout);
|
|
2926
|
-
if (e.type === EventType.FullSnapshot) {
|
|
2927
|
-
lastFullSnapshotEvent = e;
|
|
2928
|
-
incrementalSnapshotCount = 0;
|
|
2929
|
-
} else if (e.type === EventType.IncrementalSnapshot) {
|
|
2930
|
-
if (e.data.source === IncrementalSource.Mutation && e.data.isAttachIframe) {
|
|
2931
|
-
return;
|
|
2932
|
-
}
|
|
2933
|
-
incrementalSnapshotCount++;
|
|
2934
|
-
const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
|
|
2935
|
-
const exceedTime = checkoutEveryNms && e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
|
|
2936
|
-
if (exceedCount || exceedTime) {
|
|
2937
|
-
takeFullSnapshot(true);
|
|
2938
|
-
}
|
|
2939
|
-
}
|
|
2940
|
-
};
|
|
2941
|
-
const wrappedMutationEmit = (m) => {
|
|
2942
|
-
wrappedEmit(wrapEvent({
|
|
2943
|
-
type: EventType.IncrementalSnapshot,
|
|
2944
|
-
data: __spreadValues({
|
|
2945
|
-
source: IncrementalSource.Mutation
|
|
2946
|
-
}, m)
|
|
2947
|
-
}));
|
|
2948
|
-
};
|
|
2949
|
-
const wrappedScrollEmit = (p) => wrappedEmit(wrapEvent({
|
|
2950
|
-
type: EventType.IncrementalSnapshot,
|
|
2951
|
-
data: __spreadValues({
|
|
2952
|
-
source: IncrementalSource.Scroll
|
|
2953
|
-
}, p)
|
|
2954
|
-
}));
|
|
2955
|
-
const wrappedCanvasMutationEmit = (p) => wrappedEmit(wrapEvent({
|
|
2956
|
-
type: EventType.IncrementalSnapshot,
|
|
2957
|
-
data: __spreadValues({
|
|
2958
|
-
source: IncrementalSource.CanvasMutation
|
|
2959
|
-
}, p)
|
|
2960
|
-
}));
|
|
2961
|
-
const iframeManager = new IframeManager({
|
|
2962
|
-
mutationCb: wrappedMutationEmit
|
|
2963
|
-
});
|
|
2964
|
-
const stylesheetManager = new StylesheetManager({
|
|
2965
|
-
mutationCb: wrappedMutationEmit
|
|
2966
|
-
});
|
|
2967
|
-
const canvasManager = new CanvasManager({
|
|
2968
|
-
recordCanvas,
|
|
2969
|
-
mutationCb: wrappedCanvasMutationEmit,
|
|
2970
|
-
win: window,
|
|
2971
|
-
blockClass,
|
|
2972
|
-
mirror,
|
|
2973
|
-
sampling: sampling.canvas
|
|
2974
|
-
});
|
|
2975
|
-
const shadowDomManager = new ShadowDomManager({
|
|
2976
|
-
mutationCb: wrappedMutationEmit,
|
|
2977
|
-
scrollCb: wrappedScrollEmit,
|
|
2978
|
-
bypassOptions: {
|
|
2979
|
-
blockClass,
|
|
2980
|
-
blockSelector,
|
|
2981
|
-
maskTextClass,
|
|
2982
|
-
maskTextSelector,
|
|
2983
|
-
inlineStylesheet,
|
|
2984
|
-
maskInputOptions,
|
|
2985
|
-
maskTextFn,
|
|
2986
|
-
maskInputFn,
|
|
2987
|
-
recordCanvas,
|
|
2988
|
-
inlineImages,
|
|
2989
|
-
sampling,
|
|
2990
|
-
slimDOMOptions,
|
|
2991
|
-
iframeManager,
|
|
2992
|
-
stylesheetManager,
|
|
2993
|
-
canvasManager,
|
|
2994
|
-
enableStrictPrivacy
|
|
2995
|
-
},
|
|
2996
|
-
mirror
|
|
2997
|
-
});
|
|
2998
|
-
takeFullSnapshot = (isCheckout = false) => {
|
|
2999
|
-
var _a, _b, _c, _d;
|
|
3000
|
-
wrappedEmit(wrapEvent({
|
|
3001
|
-
type: EventType.Meta,
|
|
3002
|
-
data: {
|
|
3003
|
-
href: window.location.href,
|
|
3004
|
-
width: getWindowWidth(),
|
|
3005
|
-
height: getWindowHeight()
|
|
3006
|
-
}
|
|
3007
|
-
}), isCheckout);
|
|
3008
|
-
mutationBuffers.forEach((buf) => buf.lock());
|
|
3009
|
-
const node = snapshot(document, {
|
|
3010
|
-
mirror,
|
|
3011
|
-
blockClass,
|
|
3012
|
-
blockSelector,
|
|
3013
|
-
maskTextClass,
|
|
3014
|
-
maskTextSelector,
|
|
3015
|
-
inlineStylesheet,
|
|
3016
|
-
maskAllInputs: maskInputOptions,
|
|
3017
|
-
maskTextFn,
|
|
3018
|
-
slimDOM: slimDOMOptions,
|
|
3019
|
-
recordCanvas,
|
|
3020
|
-
inlineImages,
|
|
3021
|
-
enableStrictPrivacy,
|
|
3022
|
-
onSerialize: (n) => {
|
|
3023
|
-
if (isSerializedIframe(n, mirror)) {
|
|
3024
|
-
iframeManager.addIframe(n);
|
|
3025
|
-
}
|
|
3026
|
-
if (hasShadowRoot(n)) {
|
|
3027
|
-
shadowDomManager.addShadowRoot(n.shadowRoot, document);
|
|
3028
|
-
}
|
|
3029
|
-
},
|
|
3030
|
-
onIframeLoad: (iframe, childSn) => {
|
|
3031
|
-
iframeManager.attachIframe(iframe, childSn, mirror);
|
|
3032
|
-
shadowDomManager.observeAttachShadow(iframe);
|
|
3033
|
-
},
|
|
3034
|
-
onStylesheetLoad: (linkEl, childSn) => {
|
|
3035
|
-
this.stylesheetManager.attachStylesheet(linkEl, childSn, this.mirror);
|
|
3036
|
-
},
|
|
3037
|
-
keepIframeSrcFn
|
|
3038
|
-
});
|
|
3039
|
-
if (!node) {
|
|
3040
|
-
return console.warn("Failed to snapshot the document");
|
|
3041
|
-
}
|
|
3042
|
-
wrappedEmit(wrapEvent({
|
|
3043
|
-
type: EventType.FullSnapshot,
|
|
3044
|
-
data: {
|
|
3045
|
-
node,
|
|
3046
|
-
initialOffset: {
|
|
3047
|
-
left: window.pageXOffset !== void 0 ? window.pageXOffset : (document == null ? void 0 : document.documentElement.scrollLeft) || ((_b = (_a = document == null ? void 0 : document.body) == null ? void 0 : _a.parentElement) == null ? void 0 : _b.scrollLeft) || (document == null ? void 0 : document.body.scrollLeft) || 0,
|
|
3048
|
-
top: window.pageYOffset !== void 0 ? window.pageYOffset : (document == null ? void 0 : document.documentElement.scrollTop) || ((_d = (_c = document == null ? void 0 : document.body) == null ? void 0 : _c.parentElement) == null ? void 0 : _d.scrollTop) || (document == null ? void 0 : document.body.scrollTop) || 0
|
|
3049
|
-
}
|
|
3050
|
-
}
|
|
3051
|
-
}));
|
|
3052
|
-
mutationBuffers.forEach((buf) => buf.unlock());
|
|
3053
|
-
};
|
|
3054
|
-
try {
|
|
3055
|
-
const handlers = [];
|
|
3056
|
-
handlers.push(on("DOMContentLoaded", () => {
|
|
3057
|
-
wrappedEmit(wrapEvent({
|
|
3058
|
-
type: EventType.DomContentLoaded,
|
|
3059
|
-
data: {}
|
|
3060
|
-
}));
|
|
3061
|
-
}));
|
|
3062
|
-
const observe = (doc) => {
|
|
3063
|
-
var _a;
|
|
3064
|
-
return initObservers({
|
|
3065
|
-
mutationCb: wrappedMutationEmit,
|
|
3066
|
-
mousemoveCb: (positions, source) => wrappedEmit(wrapEvent({
|
|
3067
|
-
type: EventType.IncrementalSnapshot,
|
|
3068
|
-
data: {
|
|
3069
|
-
source,
|
|
3070
|
-
positions
|
|
3071
|
-
}
|
|
3072
|
-
})),
|
|
3073
|
-
mouseInteractionCb: (d) => wrappedEmit(wrapEvent({
|
|
3074
|
-
type: EventType.IncrementalSnapshot,
|
|
3075
|
-
data: __spreadValues({
|
|
3076
|
-
source: IncrementalSource.MouseInteraction
|
|
3077
|
-
}, d)
|
|
3078
|
-
})),
|
|
3079
|
-
scrollCb: wrappedScrollEmit,
|
|
3080
|
-
viewportResizeCb: (d) => wrappedEmit(wrapEvent({
|
|
3081
|
-
type: EventType.IncrementalSnapshot,
|
|
3082
|
-
data: __spreadValues({
|
|
3083
|
-
source: IncrementalSource.ViewportResize
|
|
3084
|
-
}, d)
|
|
3085
|
-
})),
|
|
3086
|
-
inputCb: (v) => wrappedEmit(wrapEvent({
|
|
3087
|
-
type: EventType.IncrementalSnapshot,
|
|
3088
|
-
data: __spreadValues({
|
|
3089
|
-
source: IncrementalSource.Input
|
|
3090
|
-
}, v)
|
|
3091
|
-
})),
|
|
3092
|
-
mediaInteractionCb: (p) => wrappedEmit(wrapEvent({
|
|
3093
|
-
type: EventType.IncrementalSnapshot,
|
|
3094
|
-
data: __spreadValues({
|
|
3095
|
-
source: IncrementalSource.MediaInteraction
|
|
3096
|
-
}, p)
|
|
3097
|
-
})),
|
|
3098
|
-
styleSheetRuleCb: (r) => wrappedEmit(wrapEvent({
|
|
3099
|
-
type: EventType.IncrementalSnapshot,
|
|
3100
|
-
data: __spreadValues({
|
|
3101
|
-
source: IncrementalSource.StyleSheetRule
|
|
3102
|
-
}, r)
|
|
3103
|
-
})),
|
|
3104
|
-
styleDeclarationCb: (r) => wrappedEmit(wrapEvent({
|
|
3105
|
-
type: EventType.IncrementalSnapshot,
|
|
3106
|
-
data: __spreadValues({
|
|
3107
|
-
source: IncrementalSource.StyleDeclaration
|
|
3108
|
-
}, r)
|
|
3109
|
-
})),
|
|
3110
|
-
canvasMutationCb: wrappedCanvasMutationEmit,
|
|
3111
|
-
fontCb: (p) => wrappedEmit(wrapEvent({
|
|
3112
|
-
type: EventType.IncrementalSnapshot,
|
|
3113
|
-
data: __spreadValues({
|
|
3114
|
-
source: IncrementalSource.Font
|
|
3115
|
-
}, p)
|
|
3116
|
-
})),
|
|
3117
|
-
blockClass,
|
|
3118
|
-
ignoreClass,
|
|
3119
|
-
maskTextClass,
|
|
3120
|
-
maskTextSelector,
|
|
3121
|
-
maskInputOptions,
|
|
3122
|
-
inlineStylesheet,
|
|
3123
|
-
sampling,
|
|
3124
|
-
recordCanvas,
|
|
3125
|
-
inlineImages,
|
|
3126
|
-
userTriggeredOnInput,
|
|
3127
|
-
collectFonts,
|
|
3128
|
-
doc,
|
|
3129
|
-
maskInputFn,
|
|
3130
|
-
maskTextFn,
|
|
3131
|
-
blockSelector,
|
|
3132
|
-
slimDOMOptions,
|
|
3133
|
-
mirror,
|
|
3134
|
-
iframeManager,
|
|
3135
|
-
stylesheetManager,
|
|
3136
|
-
shadowDomManager,
|
|
3137
|
-
canvasManager,
|
|
3138
|
-
enableStrictPrivacy,
|
|
3139
|
-
plugins: ((_a = plugins == null ? void 0 : plugins.filter((p) => p.observer)) == null ? void 0 : _a.map((p) => ({
|
|
3140
|
-
observer: p.observer,
|
|
3141
|
-
options: p.options,
|
|
3142
|
-
callback: (payload) => wrappedEmit(wrapEvent({
|
|
3143
|
-
type: EventType.Plugin,
|
|
3144
|
-
data: {
|
|
3145
|
-
plugin: p.name,
|
|
3146
|
-
payload
|
|
3147
|
-
}
|
|
3148
|
-
}))
|
|
3149
|
-
}))) || []
|
|
3150
|
-
}, hooks);
|
|
3151
|
-
};
|
|
3152
|
-
iframeManager.addLoadListener((iframeEl) => {
|
|
3153
|
-
handlers.push(observe(iframeEl.contentDocument));
|
|
3154
|
-
});
|
|
3155
|
-
const init = () => {
|
|
3156
|
-
takeFullSnapshot();
|
|
3157
|
-
handlers.push(observe(document));
|
|
3158
|
-
};
|
|
3159
|
-
if (document.readyState === "interactive" || document.readyState === "complete") {
|
|
3160
|
-
init();
|
|
3161
|
-
} else {
|
|
3162
|
-
handlers.push(on("load", () => {
|
|
3163
|
-
wrappedEmit(wrapEvent({
|
|
3164
|
-
type: EventType.Load,
|
|
3165
|
-
data: {}
|
|
3166
|
-
}));
|
|
3167
|
-
init();
|
|
3168
|
-
}, window));
|
|
3169
|
-
}
|
|
3170
|
-
return () => {
|
|
3171
|
-
handlers.forEach((h) => h());
|
|
3172
|
-
};
|
|
3173
|
-
} catch (error) {
|
|
3174
|
-
console.warn(error);
|
|
3175
|
-
}
|
|
3176
|
-
}
|
|
3177
|
-
record.addCustomEvent = (tag, payload) => {
|
|
3178
|
-
if (!wrappedEmit) {
|
|
3179
|
-
return;
|
|
3180
|
-
}
|
|
3181
|
-
wrappedEmit(wrapEvent({
|
|
3182
|
-
type: EventType.Custom,
|
|
3183
|
-
data: {
|
|
3184
|
-
tag,
|
|
3185
|
-
payload
|
|
3186
|
-
}
|
|
3187
|
-
}));
|
|
3188
|
-
};
|
|
3189
|
-
record.freezePage = () => {
|
|
3190
|
-
mutationBuffers.forEach((buf) => buf.freeze());
|
|
3191
|
-
};
|
|
3192
|
-
record.takeFullSnapshot = (isCheckout) => {
|
|
3193
|
-
if (!takeFullSnapshot) {
|
|
3194
|
-
throw new Error("please take full snapshot after start recording");
|
|
3195
|
-
}
|
|
3196
|
-
takeFullSnapshot(isCheckout);
|
|
3197
|
-
};
|
|
3198
|
-
record.mirror = mirror;
|
|
3199
|
-
|
|
3200
|
-
return record;
|
|
3201
|
-
|
|
3202
|
-
})();
|
|
1
|
+
var rrwebRecord=function(){"use strict";var R;(function(t){t[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment"})(R||(R={}));function ge(t){return t.nodeType===t.ELEMENT_NODE}function dt(t){var e,n=(e=t)===null||e===void 0?void 0:e.host;return Boolean(n&&n.shadowRoot&&n.shadowRoot===t)}var Dt=function(){function t(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return t.prototype.getId=function(e){var n;if(!e)return-1;var r=(n=this.getMeta(e))===null||n===void 0?void 0:n.id;return r??-1},t.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},t.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},t.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},t.prototype.removeNodeFromMap=function(e){var n=this,r=this.getId(e);this.idNodeMap.delete(r),e.childNodes&&e.childNodes.forEach(function(o){return n.removeNodeFromMap(o)})},t.prototype.has=function(e){return this.idNodeMap.has(e)},t.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},t.prototype.add=function(e,n){var r=n.id;this.idNodeMap.set(r,e),this.nodeMetaMap.set(e,n)},t.prototype.replace=function(e,n){this.idNodeMap.set(e,n)},t.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},t}();function be(){return new Dt}function Mt(t){var e=t.maskInputOptions,n=t.tagName,r=t.type,o=t.value,s=t.maskInputFn,l=o||"";return(e[n.toLowerCase()]||e[r])&&(s?l=s(l):l="*".repeat(l.length)),l}var Ft="__rrweb_original__";function Se(t){var e=t.getContext("2d");if(!e)return!0;for(var n=50,r=0;r<t.width;r+=n)for(var o=0;o<t.height;o+=n){var s=e.getImageData,l=Ft in s?s[Ft]:s,a=new Uint32Array(l.call(e,r,o,Math.min(n,t.width-r),Math.min(n,t.height-o)).data.buffer);if(a.some(function(i){return i!==0}))return!1}return!0}function Pt(t){return t=t.replace(/[^ -~]+/g,""),t=t?.split(" ").map(function(e){return Math.random().toString(20).substr(2,e.length)}).join(" ")||"",t}var Ce=1,ke=new RegExp("[^a-z0-9-_:]"),pt=-2;function Ie(){return Ce++}function we(t){if(t instanceof HTMLFormElement)return"form";var e=t.tagName.toLowerCase().trim();return ke.test(e)?"div":e}function Tt(t){try{var e=t.rules||t.cssRules;return e?Array.from(e).map(Me).join(""):null}catch{return null}}function Me(t){var e=t.cssText;if(Te(t))try{e=Tt(t.styleSheet)||e}catch{}return e}function Te(t){return"styleSheet"in t}function Ne(t){return t.cssRules?Array.from(t.cssRules).map(function(e){return e.cssText||""}).join(""):""}function Oe(t){var e="";return t.indexOf("//")>-1?e=t.split("/").slice(0,3).join("/"):e=t.split("/")[0],e=e.split("?")[0],e}var ot,At,xe=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,Ee=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,Le=/^(data:)([^,]*),(.*)/i;function gt(t,e){return(t||"").replace(xe,function(n,r,o,s,l,a){var i=o||l||a,c=r||s||"";if(!i)return n;if(!Ee.test(i)||Le.test(i))return"url("+c+i+c+")";if(i[0]==="/")return"url("+c+(Oe(e)+i)+c+")";var d=e.split("/"),p=i.split("/");d.pop();for(var f=0,u=p;f<u.length;f++){var h=u[f];h!=="."&&(h===".."?d.pop():d.push(h))}return"url("+c+d.join("/")+c+")"})}var Re=/^[^ \t\n\r\u000c]+/,De=/^[, \t\n\r\u000c]+/;function Fe(t,e){if(e.trim()==="")return e;var n=0;function r(c){var d,p=c.exec(e.substring(n));return p?(d=p[0],n+=d.length,d):""}for(var o=[];r(De),!(n>=e.length);){var s=r(Re);if(s.slice(-1)===",")s=bt(t,s.substring(0,s.length-1)),o.push(s);else{var l="";s=bt(t,s);for(var a=!1;;){var i=e.charAt(n);if(i===""){o.push((s+l).trim());break}else if(a)i===")"&&(a=!1);else if(i===","){n+=1,o.push((s+l).trim());break}else i==="("&&(a=!0);l+=i,n+=1}}}return o.join(", ")}function bt(t,e){if(!e||e.trim()==="")return e;var n=t.createElement("a");return n.href=e,n.href}function Pe(t){return Boolean(t.tagName==="svg"||t.ownerSVGElement)}function Nt(){var t=document.createElement("a");return t.href="",t.href}function _t(t,e,n,r){return n==="src"||n==="href"&&r||n==="xlink:href"&&r&&r[0]!=="#"||n==="background"&&r&&(e==="table"||e==="td"||e==="th")?bt(t,r):n==="srcset"&&r?Fe(t,r):n==="style"&&r?gt(r,Nt()):e==="object"&&n==="data"&&r?bt(t,r):r}function Ae(t,e,n){if(typeof e=="string"){if(t.classList.contains(e))return!0}else for(var r=0;r<t.classList.length;r++){var o=t.classList[r];if(e.test(o))return!0}return n?t.matches(n):!1}function St(t,e,n){if(!t)return!1;if(t.nodeType===t.ELEMENT_NODE){if(typeof e=="string"){if(t.classList.contains(e))return!0}else for(var r=0;r<t.classList.length;r++){var o=t.classList[r];if(e.test(o))return!0}return n&&t.matches(n)?!0:St(t.parentNode,e,n)}return t.nodeType,t.TEXT_NODE,St(t.parentNode,e,n)}function _e(t,e,n){var r=t.contentWindow;if(r){var o=!1,s;try{s=r.document.readyState}catch{return}if(s!=="complete"){var l=setTimeout(function(){o||(e(),o=!0)},n);t.addEventListener("load",function(){clearTimeout(l),o=!0,e()});return}var a="about:blank";if(r.location.href!==a||t.src===a||t.src===""){setTimeout(e,0);return}t.addEventListener("load",e)}}function We(t){return t.getAttribute("href")?t.sheet!==null:!0}function Ge(t,e,n){var r=!1,o;try{o=t.sheet}catch{return}if(!o){var s=setTimeout(function(){r||(e(),r=!0)},n);t.addEventListener("load",function(){clearTimeout(s),r=!0,e()})}}function Ve(t,e){var n,r=e.doc,o=e.mirror,s=e.blockClass,l=e.blockSelector,a=e.maskTextClass,i=e.maskTextSelector,c=e.inlineStylesheet,d=e.maskInputOptions,p=d===void 0?{}:d,f=e.maskTextFn,u=e.maskInputFn,h=e.dataURLOptions,m=h===void 0?{}:h,C=e.inlineImages,O=e.recordCanvas,D=e.keepIframeSrcFn,I=e.enableStrictPrivacy,T;if(o.getMeta(r)){var B=o.getId(r);T=B===1?void 0:B}switch(t.nodeType){case t.DOCUMENT_NODE:return t.compatMode!=="CSS1Compat"?{type:R.Document,childNodes:[],compatMode:t.compatMode,rootId:T}:{type:R.Document,childNodes:[],rootId:T};case t.DOCUMENT_TYPE_NODE:return{type:R.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:T};case t.ELEMENT_NODE:for(var G=Ae(t,s,l),w=we(t),y={},J=t.attributes.length,V=0;V<J;V++){var j=t.attributes[V];y[j.name]=_t(r,w,j.name,j.value)}if(w==="link"&&c){var $=Array.from(r.styleSheets).find(function(nt){return nt.href===t.href}),_=null;$&&(_=Tt($)),_&&(delete y.rel,delete y.href,y._cssText=gt(_,$.href))}if(w==="style"&&t.sheet&&!(t.innerText||t.textContent||"").trim().length){var _=Tt(t.sheet);_&&(y._cssText=gt(_,Nt()))}if(w==="input"||w==="textarea"||w==="select"){var Q=t.value;y.type!=="radio"&&y.type!=="checkbox"&&y.type!=="submit"&&y.type!=="button"&&Q?y.value=Mt({type:y.type,tagName:w,value:Q,maskInputOptions:p,maskInputFn:u}):t.checked&&(y.checked=t.checked)}if(w==="option"&&(t.selected&&!p.select?y.selected=!0:delete y.selected),w==="canvas"&&O){if(t.__context==="2d")Se(t)||(y.rr_dataURL=t.toDataURL(m.type,m.quality));else if(!("__context"in t)){var z=t.toDataURL(m.type,m.quality),Z=document.createElement("canvas");Z.width=t.width,Z.height=t.height;var q=Z.toDataURL(m.type,m.quality);z!==q&&(y.rr_dataURL=z)}}if(w==="img"&&C){ot||(ot=r.createElement("canvas"),At=ot.getContext("2d"));var N=t,U=N.crossOrigin;N.crossOrigin="anonymous";var X=function(){try{ot.width=N.naturalWidth,ot.height=N.naturalHeight,At.drawImage(N,0,0),y.rr_dataURL=ot.toDataURL(m.type,m.quality)}catch(nt){console.warn("Cannot inline img src="+N.currentSrc+"! Error: "+nt)}U?y.crossOrigin=U:N.removeAttribute("crossorigin")};N.complete&&N.naturalWidth!==0?X():N.onload=X}if((w==="audio"||w==="video")&&(y.rr_mediaState=t.paused?"paused":"played",y.rr_mediaCurrentTime=t.currentTime),t.scrollLeft&&(y.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(y.rr_scrollTop=t.scrollTop),G||w==="img"&&I){var g=t.getBoundingClientRect(),v=g.width,L=g.height;y={class:y.class,rr_width:v+"px",rr_height:L+"px"},G=!0}return w==="iframe"&&!D(y.src)&&(t.contentDocument||(y.rr_src=y.src),delete y.src),{type:R.Element,tagName:w,attributes:y,childNodes:[],isSVG:Pe(t)||void 0,needBlock:G,rootId:T};case t.TEXT_NODE:var P=t.parentNode&&t.parentNode.tagName,b=t.textContent,H=P==="STYLE"?!0:void 0,S=P==="SCRIPT"?!0:void 0,k=!1;if(H&&b){try{t.nextSibling||t.previousSibling||!((n=t.parentNode.sheet)===null||n===void 0)&&n.cssRules&&(b=Ne(t.parentNode.sheet))}catch(nt){console.warn("Cannot get CSS styles from text's parentNode. Error: "+nt,t)}b=gt(b,Nt()),k=!0}if(S?(b="SCRIPT_PLACEHOLDER",k=!0):P==="NOSCRIPT"&&(b="",k=!0),!H&&!S&&St(t,a,i)&&b&&(b=f?f(b):b.replace(/[\S]/g,"*")),I&&!k&&P){var tt=new Set(["HEAD","TITLE","STYLE","SCRIPT","HTML","BODY","NOSCRIPT"]);!tt.has(P)&&b&&(b=Pt(b))}return{type:R.Text,textContent:b||"",isStyle:H,rootId:T};case t.CDATA_SECTION_NODE:return{type:R.CDATA,textContent:"",rootId:T};case t.COMMENT_NODE:return{type:R.Comment,textContent:t.textContent||"",rootId:T};default:return!1}}function M(t){return t===void 0?"":t.toLowerCase()}function je(t,e){return!!(e.comment&&t.type===R.Comment||t.type===R.Element&&(e.script&&(t.tagName==="script"||t.tagName==="link"&&t.attributes.rel==="preload"&&t.attributes.as==="script"||t.tagName==="link"&&t.attributes.rel==="prefetch"&&typeof t.attributes.href=="string"&&t.attributes.href.endsWith(".js"))||e.headFavicon&&(t.tagName==="link"&&t.attributes.rel==="shortcut icon"||t.tagName==="meta"&&(M(t.attributes.name).match(/^msapplication-tile(image|color)$/)||M(t.attributes.name)==="application-name"||M(t.attributes.rel)==="icon"||M(t.attributes.rel)==="apple-touch-icon"||M(t.attributes.rel)==="shortcut icon"))||t.tagName==="meta"&&(e.headMetaDescKeywords&&M(t.attributes.name).match(/^description|keywords$/)||e.headMetaSocial&&(M(t.attributes.property).match(/^(og|twitter|fb):/)||M(t.attributes.name).match(/^(og|twitter):/)||M(t.attributes.name)==="pinterest")||e.headMetaRobots&&(M(t.attributes.name)==="robots"||M(t.attributes.name)==="googlebot"||M(t.attributes.name)==="bingbot")||e.headMetaHttpEquiv&&t.attributes["http-equiv"]!==void 0||e.headMetaAuthorship&&(M(t.attributes.name)==="author"||M(t.attributes.name)==="generator"||M(t.attributes.name)==="framework"||M(t.attributes.name)==="publisher"||M(t.attributes.name)==="progid"||M(t.attributes.property).match(/^article:/)||M(t.attributes.property).match(/^product:/))||e.headMetaVerification&&(M(t.attributes.name)==="google-site-verification"||M(t.attributes.name)==="yandex-verification"||M(t.attributes.name)==="csrf-token"||M(t.attributes.name)==="p:domain_verify"||M(t.attributes.name)==="verify-v1"||M(t.attributes.name)==="verification"||M(t.attributes.name)==="shopify-checkout-api-token"))))}function at(t,e){var n=e.doc,r=e.mirror,o=e.blockClass,s=e.blockSelector,l=e.maskTextClass,a=e.maskTextSelector,i=e.skipChild,c=i===void 0?!1:i,d=e.inlineStylesheet,p=d===void 0?!0:d,f=e.maskInputOptions,u=f===void 0?{}:f,h=e.maskTextFn,m=e.maskInputFn,C=e.slimDOMOptions,O=e.dataURLOptions,D=O===void 0?{}:O,I=e.inlineImages,T=I===void 0?!1:I,B=e.recordCanvas,G=B===void 0?!1:B,w=e.onSerialize,y=e.onIframeLoad,J=e.iframeLoadTimeout,V=J===void 0?5e3:J,j=e.onStylesheetLoad,$=e.stylesheetLoadTimeout,_=$===void 0?5e3:$,Q=e.keepIframeSrcFn,z=Q===void 0?function(){return!1}:Q,Z=e.enableStrictPrivacy,q=e.preserveWhiteSpace,N=q===void 0?!0:q,U=Ve(t,{doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:l,maskTextSelector:a,inlineStylesheet:p,maskInputOptions:u,maskTextFn:h,maskInputFn:m,dataURLOptions:D,inlineImages:T,recordCanvas:G,keepIframeSrcFn:z,enableStrictPrivacy:Z});if(!U)return console.warn(t,"not serialized"),null;var X;if(r.hasNode(t)?X=r.getId(t):je(U,C)||!N&&U.type===R.Text&&!U.isStyle&&!U.textContent.replace(/^\s+|\s+$/gm,"").length?X=pt:X=Ie(),X===pt)return null;var g=Object.assign(U,{id:X});r.add(t,g),w&&w(t);var v=!c;if(g.type===R.Element){if(v=v&&!g.needBlock,g.needBlock&&g.tagName==="img"){var L=t.cloneNode();L.src="",r.add(L,g)}if(g.tagName==="link"){var L=t.cloneNode();L.href="",L.innerText=g.attributes._cssText,r.add(L,g)}delete g.needBlock,t.shadowRoot&&(g.isShadowHost=!0)}if((g.type===R.Document||g.type===R.Element)&&v){C.headWhitespace&&g.type===R.Element&&g.tagName==="head"&&(N=!1);for(var P={doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:l,maskTextSelector:a,skipChild:c,inlineStylesheet:p,maskInputOptions:u,maskTextFn:h,maskInputFn:m,slimDOMOptions:C,dataURLOptions:D,inlineImages:T,recordCanvas:G,preserveWhiteSpace:N,onSerialize:w,onIframeLoad:y,iframeLoadTimeout:V,onStylesheetLoad:j,stylesheetLoadTimeout:_,keepIframeSrcFn:z,enableStrictPrivacy:Z},b=0,H=Array.from(t.childNodes);b<H.length;b++){var S=H[b],k=at(S,P);k&&g.childNodes.push(k)}if(ge(t)&&t.shadowRoot)for(var tt=0,nt=Array.from(t.shadowRoot.childNodes);tt<nt.length;tt++){var S=nt[tt],k=at(S,P);k&&(k.isShadow=!0,g.childNodes.push(k))}}return t.parentNode&&dt(t.parentNode)&&(g.isShadow=!0),g.type===R.Element&&g.tagName==="iframe"&&_e(t,function(){var ut=t.contentDocument;if(ut&&y){var ve=at(ut,{doc:ut,mirror:r,blockClass:o,blockSelector:s,maskTextClass:l,maskTextSelector:a,skipChild:!1,inlineStylesheet:p,maskInputOptions:u,maskTextFn:h,maskInputFn:m,slimDOMOptions:C,dataURLOptions:D,inlineImages:T,recordCanvas:G,preserveWhiteSpace:N,onSerialize:w,onIframeLoad:y,iframeLoadTimeout:V,keepIframeSrcFn:z,enableStrictPrivacy:Z});ve&&y(t,ve)}},V),g.type===R.Element&&g.tagName==="link"&&g.attributes.rel==="stylesheet"&&(Ge(t,function(){if(j){var ut=at(t,{doc:n,mirror:r,blockClass:o,blockSelector:s,maskTextClass:l,maskTextSelector:a,skipChild:!1,inlineStylesheet:p,maskInputOptions:u,maskTextFn:h,maskInputFn:m,slimDOMOptions:C,dataURLOptions:D,inlineImages:T,recordCanvas:G,preserveWhiteSpace:N,onSerialize:w,onIframeLoad:y,onStylesheetLoad:j,iframeLoadTimeout:V,keepIframeSrcFn:z,enableStrictPrivacy:Z});ut&&j(t,ut)}},_),We(t)===!1)?null:g}function ze(t,e){var n=e||{},r=n.mirror,o=r===void 0?new Dt:r,s=n.blockClass,l=s===void 0?"highlight-block":s,a=n.blockSelector,i=a===void 0?null:a,c=n.maskTextClass,d=c===void 0?"highlight-mask":c,p=n.maskTextSelector,f=p===void 0?null:p,u=n.inlineStylesheet,h=u===void 0?!0:u,m=n.inlineImages,C=m===void 0?!1:m,O=n.recordCanvas,D=O===void 0?!1:O,I=n.maskAllInputs,T=I===void 0?!1:I,B=n.maskTextFn,G=n.maskInputFn,w=n.slimDOM,y=w===void 0?!1:w,J=n.dataURLOptions,V=n.preserveWhiteSpace,j=n.onSerialize,$=n.onIframeLoad,_=n.iframeLoadTimeout,Q=n.onStylesheetLoad,z=n.stylesheetLoadTimeout,Z=n.keepIframeSrcFn,q=Z===void 0?function(){return!1}:Z,N=n.enableStrictPrivacy,U=N===void 0?!1:N,X=T===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:T===!1?{password:!0}:T,g=y===!0||y==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:y==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:y===!1?{}:y;return at(t,{doc:t,mirror:o,blockClass:l,blockSelector:i,maskTextClass:d,maskTextSelector:f,skipChild:!1,inlineStylesheet:h,maskInputOptions:X,maskTextFn:B,maskInputFn:G,slimDOMOptions:g,dataURLOptions:J,inlineImages:C,recordCanvas:D,preserveWhiteSpace:V,onSerialize:j,onIframeLoad:$,iframeLoadTimeout:_,onStylesheetLoad:Q,stylesheetLoadTimeout:z,keepIframeSrcFn:q,enableStrictPrivacy:U})}function Y(t,e,n=document){const r={capture:!0,passive:!0};return n.addEventListener(t,e,r),()=>n.removeEventListener(t,e,r)}const st=`Please stop import mirror directly. Instead of that,\r
|
|
2
|
+
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
|
|
3
|
+
or you can use record.mirror to access the mirror instance during recording.`;let Wt={map:{},getId(){return console.error(st),-1},getNode(){return console.error(st),null},removeNodeFromMap(){console.error(st)},has(){return console.error(st),!1},reset(){console.error(st)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(Wt=new Proxy(Wt,{get(t,e,n){return e==="map"&&console.error(st),Reflect.get(t,e,n)}}));function ht(t,e,n={}){let r=null,o=0;return function(s){const l=Date.now();!o&&n.leading===!1&&(o=l);const a=e-(l-o),i=this,c=arguments;a<=0||a>e?(r&&(clearTimeout(r),r=null),o=l,t.apply(i,c)):!r&&n.trailing!==!1&&(r=setTimeout(()=>{o=n.leading===!1?0:Date.now(),r=null,t.apply(i,c)},a))}}function Ct(t,e,n,r,o=window){const s=o.Object.getOwnPropertyDescriptor(t,e);return o.Object.defineProperty(t,e,r?n:{set(l){setTimeout(()=>{n.set.call(this,l)},0),s&&s.set&&s.set.call(this,l)}}),()=>Ct(t,e,s||{},!0)}function it(t,e,n){try{if(!(e in t))return()=>{};const r=t[e],o=n(r);return typeof o=="function"&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),t[e]=o,()=>{t[e]=r}}catch{return()=>{}}}function Gt(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Vt(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}const Ze=t=>{try{if(t instanceof HTMLElement)return t.tagName==="CANVAS"}catch{return!1}return!1};function W(t,e){if(!t)return!1;if(t.nodeType===t.ELEMENT_NODE){let n=!1;if(typeof e=="string"){if(t.closest!==void 0)return t.closest("."+e)!==null;n=t.classList.contains(e)}else t.classList.forEach(r=>{e.test(r)&&(n=!0)});return n||W(t.parentNode,e)}return t.nodeType,t.TEXT_NODE,W(t.parentNode,e)}function Ue(t,e){return e.getId(t)!==-1}function Ot(t,e){return e.getId(t)===pt}function jt(t,e){if(dt(t))return!1;const n=e.getId(t);return e.has(n)?t.parentNode&&t.parentNode.nodeType===t.DOCUMENT_NODE?!1:t.parentNode?jt(t.parentNode,e):!0:!0}function zt(t){return Boolean(t.changedTouches)}function He(t=window){"NodeList"in t&&!t.NodeList.prototype.forEach&&(t.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in t&&!t.DOMTokenList.prototype.forEach&&(t.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=function(e){if(!(0 in arguments))throw new TypeError("1 argument is required");do if(this===e)return!0;while(e=e&&e.parentNode);return!1})}function Zt(t,e){return Boolean(t.nodeName==="IFRAME"&&e.getMeta(t))}function Ye(t,e){return Boolean(t.nodeName==="LINK"&&t.nodeType===t.ELEMENT_NODE&&t.getAttribute&&t.getAttribute("rel")==="stylesheet"&&e.getMeta(t))}function Ut(t){return Boolean(t?.shadowRoot)}var x=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(x||{}),A=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t))(A||{}),xt=(t=>(t[t.MouseUp=0]="MouseUp",t[t.MouseDown=1]="MouseDown",t[t.Click=2]="Click",t[t.ContextMenu=3]="ContextMenu",t[t.DblClick=4]="DblClick",t[t.Focus=5]="Focus",t[t.Blur=6]="Blur",t[t.TouchStart=7]="TouchStart",t[t.TouchMove_Departed=8]="TouchMove_Departed",t[t.TouchEnd=9]="TouchEnd",t[t.TouchCancel=10]="TouchCancel",t))(xt||{}),lt=(t=>(t[t["2D"]=0]="2D",t[t.WebGL=1]="WebGL",t[t.WebGL2=2]="WebGL2",t))(lt||{}),mt=(t=>(t[t.Play=0]="Play",t[t.Pause=1]="Pause",t[t.Seeked=2]="Seeked",t[t.VolumeChange=3]="VolumeChange",t))(mt||{}),Be=(t=>(t.Start="start",t.Pause="pause",t.Resume="resume",t.Resize="resize",t.Finish="finish",t.FullsnapshotRebuilded="fullsnapshot-rebuilded",t.LoadStylesheetStart="load-stylesheet-start",t.LoadStylesheetEnd="load-stylesheet-end",t.SkipStart="skip-start",t.SkipEnd="skip-end",t.MouseInteraction="mouse-interaction",t.EventCast="event-cast",t.CustomEvent="custom-event",t.Flush="flush",t.StateChange="state-change",t.PlayBack="play-back",t))(Be||{});function Ht(t){return"__ln"in t}class Xe{constructor(){this.length=0,this.head=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let n=this.head;for(let r=0;r<e;r++)n=n?.next||null;return n}addNode(e){const n={value:e,previous:null,next:null};if(e.__ln=n,e.previousSibling&&Ht(e.previousSibling)){const r=e.previousSibling.__ln.next;n.next=r,n.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=n,r&&(r.previous=n)}else if(e.nextSibling&&Ht(e.nextSibling)&&e.nextSibling.__ln.previous){const r=e.nextSibling.__ln.previous;n.previous=r,n.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=n,r&&(r.next=n)}else this.head&&(this.head.previous=n),n.next=this.head,this.head=n;this.length++}removeNode(e){const n=e.__ln;!this.head||(n.previous?(n.previous.next=n.next,n.next&&(n.next.previous=n.previous)):(this.head=n.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}}const Yt=(t,e)=>`${t}@${e}`;class Ke{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],n=new Xe,r=a=>{let i=a,c=pt;for(;c===pt;)i=i&&i.nextSibling,c=i&&this.mirror.getId(i);return c},o=a=>{var i,c,d,p,f;const u=a.getRootNode?(i=a.getRootNode())==null?void 0:i.host:null;let h=u;for(;(d=(c=h?.getRootNode)==null?void 0:c.call(h))!=null&&d.host;)h=((f=(p=h?.getRootNode)==null?void 0:p.call(h))==null?void 0:f.host)||null;const m=!this.doc.contains(a)&&(!h||!this.doc.contains(h));if(!a.parentNode||m)return;const C=dt(a.parentNode)?this.mirror.getId(u):this.mirror.getId(a.parentNode),O=r(a);if(C===-1||O===-1)return n.addNode(a);const D=at(a,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,enableStrictPrivacy:this.enableStrictPrivacy,onSerialize:I=>{Zt(I,this.mirror)&&this.iframeManager.addIframe(I),Ye(I,this.mirror)&&this.stylesheetManager.addStylesheet(I),Ut(a)&&this.shadowDomManager.addShadowRoot(a.shadowRoot,document)},onIframeLoad:(I,T)=>{this.iframeManager.attachIframe(I,T,this.mirror),this.shadowDomManager.observeAttachShadow(I)},onStylesheetLoad:(I,T)=>{this.stylesheetManager.attachStylesheet(I,T,this.mirror)}});D&&e.push({parentId:C,nextId:O,node:D})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of Array.from(this.movedSet.values()))Lt(this.removes,a,this.mirror)&&!this.movedSet.has(a.parentNode)||o(a);for(const a of Array.from(this.addedSet.values()))!Rt(this.droppedSet,a)&&!Lt(this.removes,a,this.mirror)||Rt(this.movedSet,a)?o(a):this.droppedSet.add(a);let s=null;for(;n.length;){let a=null;if(s){const i=this.mirror.getId(s.value.parentNode),c=r(s.value);i!==-1&&c!==-1&&(a=s)}if(!a)for(let i=n.length-1;i>=0;i--){const c=n.get(i);if(c){const d=this.mirror.getId(c.value.parentNode),p=r(c.value);if(d!==-1&&p!==-1){a=c;break}}}if(!a){for(;n.head;)n.removeNode(n.head.value);break}s=a.previous,n.removeNode(a.value),o(a.value)}const l={texts:this.texts.map(a=>{let i=a.value;return this.enableStrictPrivacy&&i&&(i=Pt(i)),{id:this.mirror.getId(a.node),value:i}}).filter(a=>this.mirror.has(a.id)),attributes:this.attributes.map(a=>({id:this.mirror.getId(a.node),attributes:a.attributes})).filter(a=>this.mirror.has(a.id)),removes:this.removes,adds:e};!l.texts.length&&!l.attributes.length&&!l.removes.length&&!l.adds.length||(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(l))},this.processMutation=e=>{if(!Ot(e.target,this.mirror))switch(e.type){case"characterData":{const n=e.target.textContent;!W(e.target,this.blockClass)&&n!==e.oldValue&&this.texts.push({value:St(e.target,this.maskTextClass,this.maskTextSelector)&&n?this.maskTextFn?this.maskTextFn(n):n.replace(/[\S]/g,"*"):n,node:e.target});break}case"attributes":{const n=e.target;let r=e.target.getAttribute(e.attributeName);if(e.attributeName==="value"&&(r=Mt({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:r,maskInputFn:this.maskInputFn})),W(e.target,this.blockClass)||r===e.oldValue)return;let o=this.attributes.find(s=>s.node===e.target);if(o||(o={node:e.target,attributes:{}},this.attributes.push(o)),e.attributeName==="style"){const s=this.doc.createElement("span");e.oldValue&&s.setAttribute("style",e.oldValue),(o.attributes.style===void 0||o.attributes.style===null)&&(o.attributes.style={});const l=o.attributes.style;for(const a of Array.from(n.style)){const i=n.style.getPropertyValue(a),c=n.style.getPropertyPriority(a);(i!==s.style.getPropertyValue(a)||c!==s.style.getPropertyPriority(a))&&(c===""?l[a]=i:l[a]=[i,c])}for(const a of Array.from(s.style))n.style.getPropertyValue(a)===""&&(l[a]=!1)}else{if(e.target.tagName==="INPUT"){const s=e.target;if(s.type==="password"){o.attributes.value="*".repeat(s.value.length);break}}o.attributes[e.attributeName]=_t(this.doc,e.target.tagName,e.attributeName,r)}break}case"childList":{e.addedNodes.forEach(n=>this.genAdds(n,e.target)),e.removedNodes.forEach(n=>{const r=this.mirror.getId(n),o=dt(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);W(e.target,this.blockClass)||Ot(n,this.mirror)||!Ue(n,this.mirror)||(this.addedSet.has(n)?(Et(this.addedSet,n),this.droppedSet.add(n)):this.addedSet.has(e.target)&&r===-1||jt(e.target,this.mirror)||(this.movedSet.has(n)&&this.movedMap[Yt(r,o)]?Et(this.movedSet,n):this.removes.push({parentId:o,id:r,isShadow:dt(e.target)?!0:void 0})),this.mapRemoves.push(n))});break}}},this.genAdds=(e,n)=>{if(!(n&&W(n,this.blockClass))){if(this.mirror.getMeta(e)){if(Ot(e,this.mirror))return;this.movedSet.add(e);let r=null;n&&this.mirror.getMeta(n)&&(r=this.mirror.getId(n)),r&&r!==-1&&(this.movedMap[Yt(this.mirror.getId(e),r)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);W(e,this.blockClass)||e.childNodes.forEach(r=>this.genAdds(r))}}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","recordCanvas","inlineImages","slimDOMOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","enableStrictPrivacy"].forEach(n=>{this[n]=e[n]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function Et(t,e){t.delete(e),e.childNodes.forEach(n=>Et(t,n))}function Lt(t,e,n){const{parentNode:r}=e;if(!r)return!1;const o=n.getId(r);return t.some(s=>s.id===o)?!0:Lt(t,r,n)}function Rt(t,e){const{parentNode:n}=e;return n?t.has(n)?!0:Rt(t,n):!1}var $e=Object.defineProperty,Je=Object.defineProperties,Qe=Object.getOwnPropertyDescriptors,Bt=Object.getOwnPropertySymbols,qe=Object.prototype.hasOwnProperty,tn=Object.prototype.propertyIsEnumerable,Xt=(t,e,n)=>e in t?$e(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Kt=(t,e)=>{for(var n in e||(e={}))qe.call(e,n)&&Xt(t,n,e[n]);if(Bt)for(var n of Bt(e))tn.call(e,n)&&Xt(t,n,e[n]);return t},en=(t,e)=>Je(t,Qe(e));const rt=[],$t=typeof CSSGroupingRule<"u",Jt=typeof CSSMediaRule<"u",Qt=typeof CSSSupportsRule<"u",qt=typeof CSSConditionRule<"u";function ft(t){try{if("composedPath"in t){const e=t.composedPath();if(e.length)return e[0]}else if("path"in t&&t.path.length)return t.path[0];return t.target}catch{return t.target}}function te(t,e){var n,r;const o=new Ke;rt.push(o),o.init(t);let s=window.MutationObserver||window.__rrMutationObserver;const l=(r=(n=window?.Zone)==null?void 0:n.__symbol__)==null?void 0:r.call(n,"MutationObserver");l&&window[l]&&(s=window[l]);const a=new s(o.processMutations.bind(o));return a.observe(e,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function nn({mousemoveCb:t,sampling:e,doc:n,mirror:r}){if(e.mousemove===!1)return()=>{};const o=typeof e.mousemove=="number"?e.mousemove:50,s=typeof e.mousemoveCallback=="number"?e.mousemoveCallback:500;let l=[],a;const i=ht(p=>{const f=Date.now()-a;t(l.map(u=>(u.timeOffset-=f,u)),p),l=[],a=null},s),c=ht(p=>{const f=ft(p),{clientX:u,clientY:h}=zt(p)?p.changedTouches[0]:p;a||(a=Date.now()),l.push({x:u,y:h,id:r.getId(f),timeOffset:Date.now()-a}),i(typeof DragEvent<"u"&&p instanceof DragEvent?A.Drag:p instanceof MouseEvent?A.MouseMove:A.TouchMove)},o,{trailing:!1}),d=[Y("mousemove",c,n),Y("touchmove",c,n),Y("drag",c,n)];return()=>{d.forEach(p=>p())}}function rn({mouseInteractionCb:t,doc:e,mirror:n,blockClass:r,sampling:o}){if(o.mouseInteraction===!1)return()=>{};const s=o.mouseInteraction===!0||o.mouseInteraction===void 0?{}:o.mouseInteraction,l=[],a=i=>c=>{const d=ft(c);if(W(d,r)||Ze(d))return;const p=zt(c)?c.changedTouches[0]:c;if(!p)return;const f=n.getId(d),{clientX:u,clientY:h}=p;t({type:xt[i],id:f,x:u,y:h})};return Object.keys(xt).filter(i=>Number.isNaN(Number(i))&&!i.endsWith("_Departed")&&s[i]!==!1).forEach(i=>{const c=i.toLowerCase(),d=a(i);l.push(Y(c,d,e))}),()=>{l.forEach(i=>i())}}function ee({scrollCb:t,doc:e,mirror:n,blockClass:r,sampling:o}){const s=ht(l=>{const a=ft(l);if(!a||W(a,r))return;const i=n.getId(a);if(a===e){const c=e.scrollingElement||e.documentElement;t({id:i,x:c.scrollLeft,y:c.scrollTop})}else t({id:i,x:a.scrollLeft,y:a.scrollTop})},o.scroll||100);return Y("scroll",s,e)}function on({viewportResizeCb:t}){let e=-1,n=-1;const r=ht(()=>{const o=Gt(),s=Vt();(e!==o||n!==s)&&(t({width:Number(s),height:Number(o)}),e=o,n=s)},200);return Y("resize",r,window)}function ne(t,e){const n=Kt({},t);return e||delete n.userTriggered,n}const an=["INPUT","TEXTAREA","SELECT"],re=new WeakMap;function sn({inputCb:t,doc:e,mirror:n,blockClass:r,ignoreClass:o,maskInputOptions:s,maskInputFn:l,sampling:a,userTriggeredOnInput:i}){function c(h){let m=ft(h);const C=h.isTrusted;if(m&&m.tagName==="OPTION"&&(m=m.parentElement),!m||!m.tagName||an.indexOf(m.tagName)<0||W(m,r))return;const O=m.type;if(m.classList.contains(o))return;let D=m.value,I=!1;O==="radio"||O==="checkbox"?I=m.checked:(s[m.tagName.toLowerCase()]||s[O])&&(D=Mt({maskInputOptions:s,tagName:m.tagName,type:O,value:D,maskInputFn:l})),d(m,ne({text:D,isChecked:I,userTriggered:C},i));const T=m.name;O==="radio"&&T&&I&&e.querySelectorAll(`input[type="radio"][name="${T}"]`).forEach(B=>{B!==m&&d(B,ne({text:B.value,isChecked:!I,userTriggered:!1},i))})}function d(h,m){const C=re.get(h);if(!C||C.text!==m.text||C.isChecked!==m.isChecked){re.set(h,m);const O=n.getId(h);t(en(Kt({},m),{id:O}))}}const p=(a.input==="last"?["change"]:["input","change"]).map(h=>Y(h,c,e)),f=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value"),u=[[HTMLInputElement.prototype,"value"],[HTMLInputElement.prototype,"checked"],[HTMLSelectElement.prototype,"value"],[HTMLTextAreaElement.prototype,"value"],[HTMLSelectElement.prototype,"selectedIndex"],[HTMLOptionElement.prototype,"selected"]];return f&&f.set&&p.push(...u.map(h=>Ct(h[0],h[1],{set(){c({target:this})}}))),()=>{p.forEach(h=>h())}}function kt(t){const e=[];function n(r,o){if($t&&r.parentRule instanceof CSSGroupingRule||Jt&&r.parentRule instanceof CSSMediaRule||Qt&&r.parentRule instanceof CSSSupportsRule||qt&&r.parentRule instanceof CSSConditionRule){const s=Array.from(r.parentRule.cssRules).indexOf(r);o.unshift(s)}else{const s=Array.from(r.parentStyleSheet.cssRules).indexOf(r);o.unshift(s)}return o}return n(t,e)}function ln({styleSheetRuleCb:t,mirror:e},{win:n}){const r=n.CSSStyleSheet.prototype.insertRule;n.CSSStyleSheet.prototype.insertRule=function(a,i){const c=e.getId(this.ownerNode);return c!==-1&&t({id:c,adds:[{rule:a,index:i}]}),r.apply(this,arguments)};const o=n.CSSStyleSheet.prototype.deleteRule;n.CSSStyleSheet.prototype.deleteRule=function(a){const i=e.getId(this.ownerNode);return i!==-1&&t({id:i,removes:[{index:a}]}),o.apply(this,arguments)};const s={};$t?s.CSSGroupingRule=n.CSSGroupingRule:(Jt&&(s.CSSMediaRule=n.CSSMediaRule),qt&&(s.CSSConditionRule=n.CSSConditionRule),Qt&&(s.CSSSupportsRule=n.CSSSupportsRule));const l={};return Object.entries(s).forEach(([a,i])=>{l[a]={insertRule:i.prototype.insertRule,deleteRule:i.prototype.deleteRule},i.prototype.insertRule=function(c,d){const p=e.getId(this.parentStyleSheet.ownerNode);return p!==-1&&t({id:p,adds:[{rule:c,index:[...kt(this),d||0]}]}),l[a].insertRule.apply(this,arguments)},i.prototype.deleteRule=function(c){const d=e.getId(this.parentStyleSheet.ownerNode);return d!==-1&&t({id:d,removes:[{index:[...kt(this),c]}]}),l[a].deleteRule.apply(this,arguments)}}),()=>{n.CSSStyleSheet.prototype.insertRule=r,n.CSSStyleSheet.prototype.deleteRule=o,Object.entries(s).forEach(([a,i])=>{i.prototype.insertRule=l[a].insertRule,i.prototype.deleteRule=l[a].deleteRule})}}function cn({styleDeclarationCb:t,mirror:e},{win:n}){const r=n.CSSStyleDeclaration.prototype.setProperty;n.CSSStyleDeclaration.prototype.setProperty=function(s,l,a){var i,c;const d=e.getId((c=(i=this.parentRule)==null?void 0:i.parentStyleSheet)==null?void 0:c.ownerNode);return d!==-1&&t({id:d,set:{property:s,value:l,priority:a},index:kt(this.parentRule)}),r.apply(this,arguments)};const o=n.CSSStyleDeclaration.prototype.removeProperty;return n.CSSStyleDeclaration.prototype.removeProperty=function(s){var l,a;const i=e.getId((a=(l=this.parentRule)==null?void 0:l.parentStyleSheet)==null?void 0:a.ownerNode);return i!==-1&&t({id:i,remove:{property:s},index:kt(this.parentRule)}),o.apply(this,arguments)},()=>{n.CSSStyleDeclaration.prototype.setProperty=r,n.CSSStyleDeclaration.prototype.removeProperty=o}}function un({mediaInteractionCb:t,blockClass:e,mirror:n,sampling:r}){const o=l=>ht(a=>{const i=ft(a);if(!i||W(i,e))return;const{currentTime:c,volume:d,muted:p}=i;t({type:l,id:n.getId(i),currentTime:c,volume:d,muted:p})},r.media||500),s=[Y("play",o(mt.Play)),Y("pause",o(mt.Pause)),Y("seeked",o(mt.Seeked)),Y("volumechange",o(mt.VolumeChange))];return()=>{s.forEach(l=>l())}}function dn({fontCb:t,doc:e}){const n=e.defaultView;if(!n)return()=>{};const r=[],o=new WeakMap,s=n.FontFace;n.FontFace=function(a,i,c){const d=new s(a,i,c);return o.set(d,{family:a,buffer:typeof i!="string",descriptors:c,fontSource:typeof i=="string"?i:JSON.stringify(Array.from(new Uint8Array(i)))}),d};const l=it(e.fonts,"add",function(a){return function(i){return setTimeout(()=>{const c=o.get(i);c&&(t(c),o.delete(i))},0),a.apply(this,[i])}});return r.push(()=>{n.FontFace=s}),r.push(l),()=>{r.forEach(a=>a())}}function pn(t,e){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:s,viewportResizeCb:l,inputCb:a,mediaInteractionCb:i,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:p,fontCb:f}=t;t.mutationCb=(...u)=>{e.mutation&&e.mutation(...u),n(...u)},t.mousemoveCb=(...u)=>{e.mousemove&&e.mousemove(...u),r(...u)},t.mouseInteractionCb=(...u)=>{e.mouseInteraction&&e.mouseInteraction(...u),o(...u)},t.scrollCb=(...u)=>{e.scroll&&e.scroll(...u),s(...u)},t.viewportResizeCb=(...u)=>{e.viewportResize&&e.viewportResize(...u),l(...u)},t.inputCb=(...u)=>{e.input&&e.input(...u),a(...u)},t.mediaInteractionCb=(...u)=>{e.mediaInteaction&&e.mediaInteaction(...u),i(...u)},t.styleSheetRuleCb=(...u)=>{e.styleSheetRule&&e.styleSheetRule(...u),c(...u)},t.styleDeclarationCb=(...u)=>{e.styleDeclaration&&e.styleDeclaration(...u),d(...u)},t.canvasMutationCb=(...u)=>{e.canvasMutation&&e.canvasMutation(...u),p(...u)},t.fontCb=(...u)=>{e.font&&e.font(...u),f(...u)}}function hn(t,e={}){const n=t.doc.defaultView;if(!n)return()=>{};pn(t,e);const r=te(t,t.doc),o=nn(t),s=rn(t),l=ee(t),a=on(t),i=sn(t),c=un(t),d=ln(t,{win:n}),p=cn(t,{win:n}),f=t.collectFonts?dn(t):()=>{},u=[];for(const h of t.plugins)u.push(h.observer(h.callback,n,h.options));return()=>{rt.forEach(h=>h.reset()),r.disconnect(),o(),s(),l(),a(),i(),c(),d(),p(),f(),u.forEach(h=>h())}}class mn{constructor(e){this.iframes=new WeakMap,this.mutationCb=e.mutationCb}addIframe(e){this.iframes.set(e,!0)}addLoadListener(e){this.loadListener=e}attachIframe(e,n,r){var o;this.mutationCb({adds:[{parentId:r.getId(e),nextId:null,node:n}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),(o=this.loadListener)==null||o.call(this,e)}}var fn=Object.defineProperty,yn=Object.defineProperties,vn=Object.getOwnPropertyDescriptors,oe=Object.getOwnPropertySymbols,gn=Object.prototype.hasOwnProperty,bn=Object.prototype.propertyIsEnumerable,ae=(t,e,n)=>e in t?fn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,se=(t,e)=>{for(var n in e||(e={}))gn.call(e,n)&&ae(t,n,e[n]);if(oe)for(var n of oe(e))bn.call(e,n)&&ae(t,n,e[n]);return t},ie=(t,e)=>yn(t,vn(e));class Sn{constructor(e){this.restorePatches=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror;const n=this;this.restorePatches.push(it(HTMLElement.prototype,"attachShadow",function(r){return function(){const o=r.apply(this,arguments);return this.shadowRoot&&n.addShadowRoot(this.shadowRoot,this.ownerDocument),o}}))}addShadowRoot(e,n){te(ie(se({},this.bypassOptions),{doc:n,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e),ee(ie(se({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror}))}observeAttachShadow(e){if(e.contentWindow){const n=this;this.restorePatches.push(it(e.contentWindow.HTMLElement.prototype,"attachShadow",function(r){return function(){const o=r.apply(this,arguments);return this.shadowRoot&&n.addShadowRoot(this.shadowRoot,e.contentDocument),o}}))}}reset(){this.restorePatches.forEach(e=>e())}}for(var ct="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Cn=typeof Uint8Array>"u"?[]:new Uint8Array(256),It=0;It<ct.length;It++)Cn[ct.charCodeAt(It)]=It;var kn=function(t){var e=new Uint8Array(t),n,r=e.length,o="";for(n=0;n<r;n+=3)o+=ct[e[n]>>2],o+=ct[(e[n]&3)<<4|e[n+1]>>4],o+=ct[(e[n+1]&15)<<2|e[n+2]>>6],o+=ct[e[n+2]&63];return r%3===2?o=o.substring(0,o.length-1)+"=":r%3===1&&(o=o.substring(0,o.length-2)+"=="),o};const le=new Map;function In(t,e){let n=le.get(t);return n||(n=new Map,le.set(t,n)),n.has(e)||n.set(e,[]),n.get(e)}const ce=(t,e,n)=>{if(!t||!(de(t,e)||typeof t=="object"))return;const r=t.constructor.name,o=In(n,r);let s=o.indexOf(t);return s===-1&&(s=o.length,o.push(t)),s};function wt(t,e,n){if(t instanceof Array)return t.map(r=>wt(r,e,n));if(t===null)return t;if(t instanceof Float32Array||t instanceof Float64Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Int8Array||t instanceof Uint8ClampedArray)return{rr_type:t.constructor.name,args:[Object.values(t)]};if(t instanceof ArrayBuffer){const r=t.constructor.name,o=kn(t);return{rr_type:r,base64:o}}else{if(t instanceof DataView)return{rr_type:t.constructor.name,args:[wt(t.buffer,e,n),t.byteOffset,t.byteLength]};if(t instanceof HTMLImageElement){const r=t.constructor.name,{src:o}=t;return{rr_type:r,src:o}}else if(t instanceof HTMLCanvasElement){const r="HTMLImageElement",o=t.toDataURL();return{rr_type:r,src:o}}else{if(t instanceof ImageData)return{rr_type:t.constructor.name,args:[wt(t.data,e,n),t.width,t.height]};if(de(t,e)||typeof t=="object"){const r=t.constructor.name,o=ce(t,e,n);return{rr_type:r,index:o}}}}return t}const ue=(t,e,n)=>[...t].map(r=>wt(r,e,n)),de=(t,e)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(r=>typeof e[r]=="function");return Boolean(n.find(r=>t instanceof e[r]))};function wn(t,e,n,r){const o=[],s=Object.getOwnPropertyNames(e.CanvasRenderingContext2D.prototype);for(const l of s)try{if(typeof e.CanvasRenderingContext2D.prototype[l]!="function")continue;const a=it(e.CanvasRenderingContext2D.prototype,l,function(i){return function(...c){return W(this.canvas,n)||setTimeout(()=>{const d=ue([...c],e,this);t(this.canvas,{type:lt["2D"],property:l,args:d})},0),i.apply(this,c)}});o.push(a)}catch{const i=Ct(e.CanvasRenderingContext2D.prototype,l,{set(c){t(this.canvas,{type:lt["2D"],property:l,args:[c],setter:!0})}});o.push(i)}return()=>{o.forEach(l=>l())}}function pe(t,e){const n=[];try{const r=it(t.HTMLCanvasElement.prototype,"getContext",function(o){return function(s,...l){return W(this,e)||"__context"in this||(this.__context=s),o.apply(this,[s,...l])}});n.push(r)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{n.forEach(r=>r())}}function he(t,e,n,r,o,s){const l=[],a=Object.getOwnPropertyNames(t);for(const i of a)try{if(typeof t[i]!="function")continue;const c=it(t,i,function(d){return function(...p){const f=d.apply(this,p);if(ce(f,s,t),!W(this.canvas,r)){const u=o.getId(this.canvas),h=ue([...p],s,t),m={type:e,property:i,args:h};n(this.canvas,m)}return f}});l.push(c)}catch{const d=Ct(t,i,{set(p){n(this.canvas,{type:e,property:i,args:[p],setter:!0})}});l.push(d)}return l}function Mn(t,e,n,r){const o=[];return o.push(...he(e.WebGLRenderingContext.prototype,lt.WebGL,t,n,r,e)),typeof e.WebGL2RenderingContext<"u"&&o.push(...he(e.WebGL2RenderingContext.prototype,lt.WebGL2,t,n,r,e)),()=>{o.forEach(s=>s())}}function Tn(t,e){var n=atob(t);if(e){for(var r=new Uint8Array(n.length),o=0,s=n.length;o<s;++o)r[o]=n.charCodeAt(o);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}function Nn(t,e,n){var r=e===void 0?null:e,o=n===void 0?!1:n,s=Tn(t,o),l=s.indexOf(`
|
|
4
|
+
`,10)+1,a=s.substring(l)+(r?"//# sourceMappingURL="+r:""),i=new Blob([a],{type:"application/javascript"});return URL.createObjectURL(i)}function On(t,e,n){var r;return function(s){return r=r||Nn(t,e,n),new Worker(r,s)}}var xn=On("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24oKXsidXNlIHN0cmljdCI7Zm9yKHZhciByPSJBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OSsvIixsPXR5cGVvZiBVaW50OEFycmF5PiJ1Ij9bXTpuZXcgVWludDhBcnJheSgyNTYpLGY9MDtmPHIubGVuZ3RoO2YrKylsW3IuY2hhckNvZGVBdChmKV09Zjt2YXIgZD1mdW5jdGlvbihzKXt2YXIgZT1uZXcgVWludDhBcnJheShzKSxuLGE9ZS5sZW5ndGgsdD0iIjtmb3Iobj0wO248YTtuKz0zKXQrPXJbZVtuXT4+Ml0sdCs9clsoZVtuXSYzKTw8NHxlW24rMV0+PjRdLHQrPXJbKGVbbisxXSYxNSk8PDJ8ZVtuKzJdPj42XSx0Kz1yW2VbbisyXSY2M107cmV0dXJuIGElMz09PTI/dD10LnN1YnN0cmluZygwLHQubGVuZ3RoLTEpKyI9IjphJTM9PT0xJiYodD10LnN1YnN0cmluZygwLHQubGVuZ3RoLTIpKyI9PSIpLHR9O2NvbnN0IGM9bmV3IE1hcCx1PW5ldyBNYXA7YXN5bmMgZnVuY3Rpb24gcChzLGUpe2NvbnN0IG49YCR7c30tJHtlfWA7aWYodS5oYXMobikpcmV0dXJuIHUuZ2V0KG4pO2NvbnN0IGE9bmV3IE9mZnNjcmVlbkNhbnZhcyhzLGUpO2EuZ2V0Q29udGV4dCgiMmQiKTtjb25zdCB0PWF3YWl0KGF3YWl0IGEuY29udmVydFRvQmxvYigpKS5hcnJheUJ1ZmZlcigpLGc9ZCh0KTtyZXR1cm4gdS5zZXQobixnKSxnfWNvbnN0IGk9c2VsZjtpLm9ubWVzc2FnZT1hc3luYyBmdW5jdGlvbihzKXtpZighKCJPZmZzY3JlZW5DYW52YXMiaW4gZ2xvYmFsVGhpcykpcmV0dXJuIGkucG9zdE1lc3NhZ2Uoe2lkOnMuZGF0YS5pZH0pO2NvbnN0e2lkOmUsYml0bWFwOm4sd2lkdGg6YSxoZWlnaHQ6dH09cy5kYXRhLGc9cChhLHQpLGg9bmV3IE9mZnNjcmVlbkNhbnZhcyhhLHQpO2guZ2V0Q29udGV4dCgiMmQiKS5kcmF3SW1hZ2UobiwwLDApLG4uY2xvc2UoKTtjb25zdCB3PWF3YWl0IGguY29udmVydFRvQmxvYigpLHk9dy50eXBlLGI9YXdhaXQgdy5hcnJheUJ1ZmZlcigpLG89ZChiKTtpZighYy5oYXMoZSkmJmF3YWl0IGc9PT1vKXJldHVybiBjLnNldChlLG8pLGkucG9zdE1lc3NhZ2Uoe2lkOmV9KTtpZihjLmdldChlKT09PW8pcmV0dXJuIGkucG9zdE1lc3NhZ2Uoe2lkOmV9KTtpLnBvc3RNZXNzYWdlKHtpZDplLHR5cGU6eSxiYXNlNjQ6byx3aWR0aDphLGhlaWdodDp0fSksYy5zZXQoZSxvKX19KSgpOwoK",null,!1),me=Object.getOwnPropertySymbols,En=Object.prototype.hasOwnProperty,Ln=Object.prototype.propertyIsEnumerable,Rn=(t,e)=>{var n={};for(var r in t)En.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&me)for(var r of me(t))e.indexOf(r)<0&&Ln.call(t,r)&&(n[r]=t[r]);return n},Dn=(t,e,n)=>new Promise((r,o)=>{var s=i=>{try{a(n.next(i))}catch(c){o(c)}},l=i=>{try{a(n.throw(i))}catch(c){o(c)}},a=i=>i.done?r(i.value):Promise.resolve(i.value).then(s,l);a((n=n.apply(t,e)).next())});class Fn{constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=function(l,a){(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(l)||this.pendingCanvasMutations.set(l,[]),this.pendingCanvasMutations.get(l).push(a)};const{sampling:n="all",win:r,blockClass:o,recordCanvas:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&n==="all"&&this.initCanvasMutationObserver(r,o),s&&typeof n=="number"&&this.initCanvasFPSObserver(n,r,o)}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,n,r){const o=pe(n,r),s=new Map,l=new xn;l.onmessage=p=>{const{id:f}=p.data;if(s.set(f,!1),!("base64"in p.data))return;const{base64:u,type:h,width:m,height:C}=p.data;this.mutationCb({id:f,type:lt["2D"],commands:[{property:"clearRect",args:[0,0,m,C]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:u}],type:h}]},0,0]}]})};const a=1e3/e;let i=0,c;const d=p=>{if(i&&p-i<a){c=requestAnimationFrame(d);return}i=p,n.document.querySelectorAll(`canvas:not(.${r} *)`).forEach(f=>Dn(this,null,function*(){var u;const h=this.mirror.getId(f);if(s.get(h))return;if(s.set(h,!0),["webgl","webgl2"].includes(f.__context)){const C=f.getContext(f.__context);((u=C?.getContextAttributes())==null?void 0:u.preserveDrawingBuffer)===!1&&C?.clear(C.COLOR_BUFFER_BIT)}const m=yield createImageBitmap(f);l.postMessage({id:h,bitmap:m,width:f.width,height:f.height},[m])})),c=requestAnimationFrame(d)};c=requestAnimationFrame(d),this.resetObservers=()=>{o(),cancelAnimationFrame(c)}}initCanvasMutationObserver(e,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=pe(e,n),o=wn(this.processMutation.bind(this),e,n,this.mirror),s=Mn(this.processMutation.bind(this),e,n,this.mirror);this.resetObservers=()=>{r(),o(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=n=>{this.rafStamps.latestId=n,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,n)=>{const r=this.mirror.getId(n);this.flushPendingCanvasMutationFor(n,r)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,n){if(this.frozen||this.locked)return;const r=this.pendingCanvasMutations.get(e);if(!r||n===-1)return;const o=r.map(l=>Rn(l,["type"])),{type:s}=r[0];this.mutationCb({id:n,type:s,commands:o}),this.pendingCanvasMutations.delete(e)}}class Pn{constructor(e){this.trackedStylesheets=new WeakSet,this.mutationCb=e.mutationCb}addStylesheet(e){this.trackedStylesheets.has(e)||(this.trackedStylesheets.add(e),this.trackStylesheet(e))}trackStylesheet(e){}attachStylesheet(e,n,r){this.mutationCb({adds:[{parentId:r.getId(e),nextId:null,node:n}],removes:[],texts:[],attributes:[]}),this.addStylesheet(e)}}var An=Object.defineProperty,_n=Object.defineProperties,Wn=Object.getOwnPropertyDescriptors,fe=Object.getOwnPropertySymbols,Gn=Object.prototype.hasOwnProperty,Vn=Object.prototype.propertyIsEnumerable,ye=(t,e,n)=>e in t?An(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,K=(t,e)=>{for(var n in e||(e={}))Gn.call(e,n)&&ye(t,n,e[n]);if(fe)for(var n of fe(e))Vn.call(e,n)&&ye(t,n,e[n]);return t},jn=(t,e)=>_n(t,Wn(e));function F(t){return jn(K({},t),{timestamp:Date.now()})}let E,yt;const et=be();function vt(t={}){const{emit:e,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="highlight-block",blockSelector:s=null,ignoreClass:l="highlight-ignore",maskTextClass:a="highlight-mask",maskTextSelector:i=null,inlineStylesheet:c=!0,maskAllInputs:d,maskInputOptions:p,slimDOMOptions:f,maskInputFn:u,maskTextFn:h,hooks:m,packFn:C,sampling:O={},mousemoveWait:D,recordCanvas:I=!1,userTriggeredOnInput:T=!1,collectFonts:B=!1,inlineImages:G=!1,plugins:w,keepIframeSrcFn:y=()=>!1,enableStrictPrivacy:J=!1}=t;if(!e)throw new Error("emit function is required");D!==void 0&&O.mousemove===void 0&&(O.mousemove=D),et.reset();const V=d===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:p!==void 0?p:{password:!0},j=f===!0||f==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:f==="all",headMetaDescKeywords:f==="all"}:f||{};He();let $,_=0;const Q=v=>{for(const L of w||[])L.eventProcessor&&(v=L.eventProcessor(v));return C&&(v=C(v)),v};E=(v,L)=>{var P;if(((P=rt[0])==null?void 0:P.isFrozen())&&v.type!==x.FullSnapshot&&!(v.type===x.IncrementalSnapshot&&v.data.source===A.Mutation)&&rt.forEach(b=>b.unfreeze()),e(Q(v),L),v.type===x.FullSnapshot)$=v,_=0;else if(v.type===x.IncrementalSnapshot){if(v.data.source===A.Mutation&&v.data.isAttachIframe)return;_++;const b=r&&_>=r,H=n&&v.timestamp-$.timestamp>n;(b||H)&&yt(!0)}};const z=v=>{E(F({type:x.IncrementalSnapshot,data:K({source:A.Mutation},v)}))},Z=v=>E(F({type:x.IncrementalSnapshot,data:K({source:A.Scroll},v)})),q=v=>E(F({type:x.IncrementalSnapshot,data:K({source:A.CanvasMutation},v)})),N=new mn({mutationCb:z}),U=new Pn({mutationCb:z}),X=new Fn({recordCanvas:I,mutationCb:q,win:window,blockClass:o,mirror:et,sampling:O.canvas}),g=new Sn({mutationCb:z,scrollCb:Z,bypassOptions:{blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:i,inlineStylesheet:c,maskInputOptions:V,maskTextFn:h,maskInputFn:u,recordCanvas:I,inlineImages:G,sampling:O,slimDOMOptions:j,iframeManager:N,stylesheetManager:U,canvasManager:X,enableStrictPrivacy:J},mirror:et});yt=(v=!1)=>{var L,P,b,H;E(F({type:x.Meta,data:{href:window.location.href,width:Vt(),height:Gt()}}),v),rt.forEach(k=>k.lock());const S=ze(document,{mirror:et,blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:i,inlineStylesheet:c,maskAllInputs:V,maskTextFn:h,slimDOM:j,recordCanvas:I,inlineImages:G,enableStrictPrivacy:J,onSerialize:k=>{Zt(k,et)&&N.addIframe(k),Ut(k)&&g.addShadowRoot(k.shadowRoot,document)},onIframeLoad:(k,tt)=>{N.attachIframe(k,tt,et),g.observeAttachShadow(k)},onStylesheetLoad:(k,tt)=>{this.stylesheetManager.attachStylesheet(k,tt,this.mirror)},keepIframeSrcFn:y});if(!S)return console.warn("Failed to snapshot the document");E(F({type:x.FullSnapshot,data:{node:S,initialOffset:{left:window.pageXOffset!==void 0?window.pageXOffset:document?.documentElement.scrollLeft||((P=(L=document?.body)==null?void 0:L.parentElement)==null?void 0:P.scrollLeft)||document?.body.scrollLeft||0,top:window.pageYOffset!==void 0?window.pageYOffset:document?.documentElement.scrollTop||((H=(b=document?.body)==null?void 0:b.parentElement)==null?void 0:H.scrollTop)||document?.body.scrollTop||0}}})),rt.forEach(k=>k.unlock())};try{const v=[];v.push(Y("DOMContentLoaded",()=>{E(F({type:x.DomContentLoaded,data:{}}))}));const L=b=>{var H;return hn({mutationCb:z,mousemoveCb:(S,k)=>E(F({type:x.IncrementalSnapshot,data:{source:k,positions:S}})),mouseInteractionCb:S=>E(F({type:x.IncrementalSnapshot,data:K({source:A.MouseInteraction},S)})),scrollCb:Z,viewportResizeCb:S=>E(F({type:x.IncrementalSnapshot,data:K({source:A.ViewportResize},S)})),inputCb:S=>E(F({type:x.IncrementalSnapshot,data:K({source:A.Input},S)})),mediaInteractionCb:S=>E(F({type:x.IncrementalSnapshot,data:K({source:A.MediaInteraction},S)})),styleSheetRuleCb:S=>E(F({type:x.IncrementalSnapshot,data:K({source:A.StyleSheetRule},S)})),styleDeclarationCb:S=>E(F({type:x.IncrementalSnapshot,data:K({source:A.StyleDeclaration},S)})),canvasMutationCb:q,fontCb:S=>E(F({type:x.IncrementalSnapshot,data:K({source:A.Font},S)})),blockClass:o,ignoreClass:l,maskTextClass:a,maskTextSelector:i,maskInputOptions:V,inlineStylesheet:c,sampling:O,recordCanvas:I,inlineImages:G,userTriggeredOnInput:T,collectFonts:B,doc:b,maskInputFn:u,maskTextFn:h,blockSelector:s,slimDOMOptions:j,mirror:et,iframeManager:N,stylesheetManager:U,shadowDomManager:g,canvasManager:X,enableStrictPrivacy:J,plugins:((H=w?.filter(S=>S.observer))==null?void 0:H.map(S=>({observer:S.observer,options:S.options,callback:k=>E(F({type:x.Plugin,data:{plugin:S.name,payload:k}}))})))||[]},m)};N.addLoadListener(b=>{v.push(L(b.contentDocument))});const P=()=>{yt(),v.push(L(document))};return document.readyState==="interactive"||document.readyState==="complete"?P():v.push(Y("load",()=>{E(F({type:x.Load,data:{}})),P()},window)),()=>{v.forEach(b=>b())}}catch(v){console.warn(v)}}return vt.addCustomEvent=(t,e)=>{!E||E(F({type:x.Custom,data:{tag:t,payload:e}}))},vt.freezePage=()=>{rt.forEach(t=>t.freeze())},vt.takeFullSnapshot=t=>{if(!yt)throw new Error("please take full snapshot after start recording");yt(t)},vt.mirror=et,vt}();
|