@highlight-run/rrweb 2.0.11 → 2.0.15
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 +5 -5
- package/dist/plugins/console-record.min.js +5 -5
- package/dist/plugins/console-record.min.js.map +1 -1
- package/dist/plugins/console-replay.js +3 -3
- package/dist/plugins/console-replay.min.js +3 -3
- package/dist/plugins/console-replay.min.js.map +1 -1
- package/dist/record/rrweb-record-pack.js +2 -2
- package/dist/record/rrweb-record-pack.min.js +2 -2
- package/dist/record/rrweb-record-pack.min.js.map +1 -1
- package/dist/record/rrweb-record.js +3 -3
- 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.js +4 -3
- package/dist/replay/rrweb-replay-unpack.min.js +4 -3
- package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
- package/dist/replay/rrweb-replay.js +4 -3
- package/dist/replay/rrweb-replay.min.js +4 -3
- package/dist/replay/rrweb-replay.min.js.map +1 -1
- package/dist/rrweb-all.js +25 -24
- package/dist/rrweb-all.min.js +25 -24
- package/dist/rrweb-all.min.js.map +1 -1
- package/dist/rrweb.js +15 -14
- package/dist/rrweb.min.js +15 -14
- package/dist/rrweb.min.js.map +1 -1
- package/es/rrweb/packages/rrdom/es/{virtual-dom.js → rrdom.js} +86 -49
- package/es/rrweb/packages/rrweb/src/index.js +2 -2
- package/es/rrweb/packages/rrweb/src/record/index.js +3 -1
- package/es/rrweb/packages/rrweb/src/record/mutation.js +13 -2
- package/es/rrweb/packages/rrweb/src/record/observer.js +1 -1
- package/es/rrweb/packages/rrweb/src/replay/index.js +4 -4
- package/es/rrweb/packages/rrweb/src/utils.js +1 -1
- package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +1870 -0
- package/lib/plugins/console-record.js +9 -1
- package/lib/plugins/console-replay.js +9 -1
- package/lib/record/rrweb-record-pack.js +9 -3
- package/lib/record/rrweb-record.js +1075 -17
- package/lib/replay/rrweb-replay-unpack.js +1023 -96
- package/lib/replay/rrweb-replay.js +1023 -96
- package/lib/rrweb-all.js +2056 -137
- package/lib/rrweb.js +2056 -137
- package/package.json +5 -5
- package/typings/record/mutation.d.ts +1 -0
- package/typings/replay/index.d.ts +1 -1
- package/typings/types.d.ts +3 -2
- package/typings/utils.d.ts +1 -1
package/lib/rrweb-all.js
CHANGED
|
@@ -2,7 +2,1874 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var NodeType$2;
|
|
6
|
+
(function (NodeType) {
|
|
7
|
+
NodeType[NodeType["Document"] = 0] = "Document";
|
|
8
|
+
NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
|
|
9
|
+
NodeType[NodeType["Element"] = 2] = "Element";
|
|
10
|
+
NodeType[NodeType["Text"] = 3] = "Text";
|
|
11
|
+
NodeType[NodeType["CDATA"] = 4] = "CDATA";
|
|
12
|
+
NodeType[NodeType["Comment"] = 5] = "Comment";
|
|
13
|
+
})(NodeType$2 || (NodeType$2 = {}));
|
|
14
|
+
|
|
15
|
+
function isElement(n) {
|
|
16
|
+
return n.nodeType === n.ELEMENT_NODE;
|
|
17
|
+
}
|
|
18
|
+
function isShadowRoot(n) {
|
|
19
|
+
var host = n === null || n === void 0 ? void 0 : n.host;
|
|
20
|
+
return Boolean((host === null || host === void 0 ? void 0 : host.shadowRoot) === n);
|
|
21
|
+
}
|
|
22
|
+
var Mirror$2 = (function () {
|
|
23
|
+
function Mirror() {
|
|
24
|
+
this.idNodeMap = new Map();
|
|
25
|
+
this.nodeMetaMap = new WeakMap();
|
|
26
|
+
}
|
|
27
|
+
Mirror.prototype.getId = function (n) {
|
|
28
|
+
var _a;
|
|
29
|
+
if (!n)
|
|
30
|
+
return -1;
|
|
31
|
+
var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
|
|
32
|
+
return id !== null && id !== void 0 ? id : -1;
|
|
33
|
+
};
|
|
34
|
+
Mirror.prototype.getNode = function (id) {
|
|
35
|
+
return this.idNodeMap.get(id) || null;
|
|
36
|
+
};
|
|
37
|
+
Mirror.prototype.getIds = function () {
|
|
38
|
+
return Array.from(this.idNodeMap.keys());
|
|
39
|
+
};
|
|
40
|
+
Mirror.prototype.getMeta = function (n) {
|
|
41
|
+
return this.nodeMetaMap.get(n) || null;
|
|
42
|
+
};
|
|
43
|
+
Mirror.prototype.removeNodeFromMap = function (n) {
|
|
44
|
+
var _this = this;
|
|
45
|
+
var id = this.getId(n);
|
|
46
|
+
this.idNodeMap["delete"](id);
|
|
47
|
+
if (n.childNodes) {
|
|
48
|
+
n.childNodes.forEach(function (childNode) {
|
|
49
|
+
return _this.removeNodeFromMap(childNode);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Mirror.prototype.has = function (id) {
|
|
54
|
+
return this.idNodeMap.has(id);
|
|
55
|
+
};
|
|
56
|
+
Mirror.prototype.hasNode = function (node) {
|
|
57
|
+
return this.nodeMetaMap.has(node);
|
|
58
|
+
};
|
|
59
|
+
Mirror.prototype.add = function (n, meta) {
|
|
60
|
+
var id = meta.id;
|
|
61
|
+
this.idNodeMap.set(id, n);
|
|
62
|
+
this.nodeMetaMap.set(n, meta);
|
|
63
|
+
};
|
|
64
|
+
Mirror.prototype.replace = function (id, n) {
|
|
65
|
+
this.idNodeMap.set(id, n);
|
|
66
|
+
};
|
|
67
|
+
Mirror.prototype.reset = function () {
|
|
68
|
+
this.idNodeMap = new Map();
|
|
69
|
+
this.nodeMetaMap = new WeakMap();
|
|
70
|
+
};
|
|
71
|
+
return Mirror;
|
|
72
|
+
}());
|
|
73
|
+
function createMirror$2() {
|
|
74
|
+
return new Mirror$2();
|
|
75
|
+
}
|
|
76
|
+
function maskInputValue(_a) {
|
|
77
|
+
var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;
|
|
78
|
+
var text = value || '';
|
|
79
|
+
if (maskInputOptions[tagName.toLowerCase()] ||
|
|
80
|
+
maskInputOptions[type]) {
|
|
81
|
+
if (maskInputFn) {
|
|
82
|
+
text = maskInputFn(text);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
text = '*'.repeat(text.length);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return text;
|
|
89
|
+
}
|
|
90
|
+
var ORIGINAL_ATTRIBUTE_NAME$1 = '__rrweb_original__';
|
|
91
|
+
function is2DCanvasBlank(canvas) {
|
|
92
|
+
var ctx = canvas.getContext('2d');
|
|
93
|
+
if (!ctx)
|
|
94
|
+
return true;
|
|
95
|
+
var chunkSize = 50;
|
|
96
|
+
for (var x = 0; x < canvas.width; x += chunkSize) {
|
|
97
|
+
for (var y = 0; y < canvas.height; y += chunkSize) {
|
|
98
|
+
var getImageData = ctx.getImageData;
|
|
99
|
+
var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME$1 in getImageData
|
|
100
|
+
? getImageData[ORIGINAL_ATTRIBUTE_NAME$1]
|
|
101
|
+
: getImageData;
|
|
102
|
+
var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);
|
|
103
|
+
if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
function obfuscateText(text) {
|
|
110
|
+
text = text.replace(/[^ -~]+/g, '');
|
|
111
|
+
text =
|
|
112
|
+
(text === null || text === void 0 ? void 0 : text.split(' ').map(function (word) { return Math.random().toString(20).substr(2, word.length); }).join(' ')) || '';
|
|
113
|
+
return text;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
var _id = 1;
|
|
117
|
+
var tagNameRegex = new RegExp('[^a-z0-9-_:]');
|
|
118
|
+
var IGNORED_NODE = -2;
|
|
119
|
+
function genId() {
|
|
120
|
+
return _id++;
|
|
121
|
+
}
|
|
122
|
+
function getValidTagName$1(element) {
|
|
123
|
+
if (element instanceof HTMLFormElement) {
|
|
124
|
+
return 'form';
|
|
125
|
+
}
|
|
126
|
+
var processedTagName = element.tagName.toLowerCase().trim();
|
|
127
|
+
if (tagNameRegex.test(processedTagName)) {
|
|
128
|
+
return 'div';
|
|
129
|
+
}
|
|
130
|
+
return processedTagName;
|
|
131
|
+
}
|
|
132
|
+
function getCssRulesString(s) {
|
|
133
|
+
try {
|
|
134
|
+
var rules = s.rules || s.cssRules;
|
|
135
|
+
return rules ? Array.from(rules).map(getCssRuleString).join('') : null;
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function getCssRuleString(rule) {
|
|
142
|
+
var cssStringified = rule.cssText;
|
|
143
|
+
if (isCSSImportRule(rule)) {
|
|
144
|
+
try {
|
|
145
|
+
cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;
|
|
146
|
+
}
|
|
147
|
+
catch (_a) {
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return cssStringified;
|
|
151
|
+
}
|
|
152
|
+
function isCSSImportRule(rule) {
|
|
153
|
+
return 'styleSheet' in rule;
|
|
154
|
+
}
|
|
155
|
+
function stringifyStyleSheet(sheet) {
|
|
156
|
+
return sheet.cssRules
|
|
157
|
+
? Array.from(sheet.cssRules)
|
|
158
|
+
.map(function (rule) { return rule.cssText || ''; })
|
|
159
|
+
.join('')
|
|
160
|
+
: '';
|
|
161
|
+
}
|
|
162
|
+
function extractOrigin(url) {
|
|
163
|
+
var origin = '';
|
|
164
|
+
if (url.indexOf('//') > -1) {
|
|
165
|
+
origin = url.split('/').slice(0, 3).join('/');
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
origin = url.split('/')[0];
|
|
169
|
+
}
|
|
170
|
+
origin = origin.split('?')[0];
|
|
171
|
+
return origin;
|
|
172
|
+
}
|
|
173
|
+
var canvasService;
|
|
174
|
+
var canvasCtx;
|
|
175
|
+
var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
|
|
176
|
+
var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/;
|
|
177
|
+
var DATA_URI = /^(data:)([^,]*),(.*)/i;
|
|
178
|
+
function absoluteToStylesheet(cssText, href) {
|
|
179
|
+
return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {
|
|
180
|
+
var filePath = path1 || path2 || path3;
|
|
181
|
+
var maybeQuote = quote1 || quote2 || '';
|
|
182
|
+
if (!filePath) {
|
|
183
|
+
return origin;
|
|
184
|
+
}
|
|
185
|
+
if (!RELATIVE_PATH.test(filePath)) {
|
|
186
|
+
return "url(".concat(maybeQuote).concat(filePath).concat(maybeQuote, ")");
|
|
187
|
+
}
|
|
188
|
+
if (DATA_URI.test(filePath)) {
|
|
189
|
+
return "url(".concat(maybeQuote).concat(filePath).concat(maybeQuote, ")");
|
|
190
|
+
}
|
|
191
|
+
if (filePath[0] === '/') {
|
|
192
|
+
return "url(".concat(maybeQuote).concat(extractOrigin(href) + filePath).concat(maybeQuote, ")");
|
|
193
|
+
}
|
|
194
|
+
var stack = href.split('/');
|
|
195
|
+
var parts = filePath.split('/');
|
|
196
|
+
stack.pop();
|
|
197
|
+
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
|
|
198
|
+
var part = parts_1[_i];
|
|
199
|
+
if (part === '.') {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
else if (part === '..') {
|
|
203
|
+
stack.pop();
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
stack.push(part);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return "url(".concat(maybeQuote).concat(stack.join('/')).concat(maybeQuote, ")");
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
|
|
213
|
+
var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
|
|
214
|
+
function getAbsoluteSrcsetString(doc, attributeValue) {
|
|
215
|
+
if (attributeValue.trim() === '') {
|
|
216
|
+
return attributeValue;
|
|
217
|
+
}
|
|
218
|
+
var pos = 0;
|
|
219
|
+
function collectCharacters(regEx) {
|
|
220
|
+
var chars;
|
|
221
|
+
var match = regEx.exec(attributeValue.substring(pos));
|
|
222
|
+
if (match) {
|
|
223
|
+
chars = match[0];
|
|
224
|
+
pos += chars.length;
|
|
225
|
+
return chars;
|
|
226
|
+
}
|
|
227
|
+
return '';
|
|
228
|
+
}
|
|
229
|
+
var output = [];
|
|
230
|
+
while (true) {
|
|
231
|
+
collectCharacters(SRCSET_COMMAS_OR_SPACES);
|
|
232
|
+
if (pos >= attributeValue.length) {
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
var url = collectCharacters(SRCSET_NOT_SPACES);
|
|
236
|
+
if (url.slice(-1) === ',') {
|
|
237
|
+
url = absoluteToDoc(doc, url.substring(0, url.length - 1));
|
|
238
|
+
output.push(url);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
var descriptorsStr = '';
|
|
242
|
+
url = absoluteToDoc(doc, url);
|
|
243
|
+
var inParens = false;
|
|
244
|
+
while (true) {
|
|
245
|
+
var c = attributeValue.charAt(pos);
|
|
246
|
+
if (c === '') {
|
|
247
|
+
output.push((url + descriptorsStr).trim());
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
else if (!inParens) {
|
|
251
|
+
if (c === ',') {
|
|
252
|
+
pos += 1;
|
|
253
|
+
output.push((url + descriptorsStr).trim());
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
else if (c === '(') {
|
|
257
|
+
inParens = true;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
if (c === ')') {
|
|
262
|
+
inParens = false;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
descriptorsStr += c;
|
|
266
|
+
pos += 1;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return output.join(', ');
|
|
271
|
+
}
|
|
272
|
+
function absoluteToDoc(doc, attributeValue) {
|
|
273
|
+
if (!attributeValue || attributeValue.trim() === '') {
|
|
274
|
+
return attributeValue;
|
|
275
|
+
}
|
|
276
|
+
var a = doc.createElement('a');
|
|
277
|
+
a.href = attributeValue;
|
|
278
|
+
return a.href;
|
|
279
|
+
}
|
|
280
|
+
function isSVGElement(el) {
|
|
281
|
+
return Boolean(el.tagName === 'svg' || el.ownerSVGElement);
|
|
282
|
+
}
|
|
283
|
+
function getHref() {
|
|
284
|
+
var a = document.createElement('a');
|
|
285
|
+
a.href = '';
|
|
286
|
+
return a.href;
|
|
287
|
+
}
|
|
288
|
+
function transformAttribute(doc, tagName, name, value) {
|
|
289
|
+
if (name === 'src' || (name === 'href' && value)) {
|
|
290
|
+
return absoluteToDoc(doc, value);
|
|
291
|
+
}
|
|
292
|
+
else if (name === 'xlink:href' && value && value[0] !== '#') {
|
|
293
|
+
return absoluteToDoc(doc, value);
|
|
294
|
+
}
|
|
295
|
+
else if (name === 'background' &&
|
|
296
|
+
value &&
|
|
297
|
+
(tagName === 'table' || tagName === 'td' || tagName === 'th')) {
|
|
298
|
+
return absoluteToDoc(doc, value);
|
|
299
|
+
}
|
|
300
|
+
else if (name === 'srcset' && value) {
|
|
301
|
+
return getAbsoluteSrcsetString(doc, value);
|
|
302
|
+
}
|
|
303
|
+
else if (name === 'style' && value) {
|
|
304
|
+
return absoluteToStylesheet(value, getHref());
|
|
305
|
+
}
|
|
306
|
+
else if (tagName === 'object' && name === 'data' && value) {
|
|
307
|
+
return absoluteToDoc(doc, value);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
return value;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function _isBlockedElement(element, blockClass, blockSelector) {
|
|
314
|
+
if (typeof blockClass === 'string') {
|
|
315
|
+
if (element.classList.contains(blockClass)) {
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
for (var eIndex = element.classList.length; eIndex--;) {
|
|
321
|
+
var className = element.classList[eIndex];
|
|
322
|
+
if (blockClass.test(className)) {
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (blockSelector) {
|
|
328
|
+
return element.matches(blockSelector);
|
|
329
|
+
}
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
function classMatchesRegex(node, regex, checkAncestors) {
|
|
333
|
+
if (!node)
|
|
334
|
+
return false;
|
|
335
|
+
if (node.nodeType !== node.ELEMENT_NODE) {
|
|
336
|
+
if (!checkAncestors)
|
|
337
|
+
return false;
|
|
338
|
+
return classMatchesRegex(node.parentNode, regex, checkAncestors);
|
|
339
|
+
}
|
|
340
|
+
for (var eIndex = node.classList.length; eIndex--;) {
|
|
341
|
+
var className = node.classList[eIndex];
|
|
342
|
+
if (regex.test(className)) {
|
|
343
|
+
return true;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (!checkAncestors)
|
|
347
|
+
return false;
|
|
348
|
+
return classMatchesRegex(node.parentNode, regex, checkAncestors);
|
|
349
|
+
}
|
|
350
|
+
function needMaskingText(node, maskTextClass, maskTextSelector) {
|
|
351
|
+
var el = node.nodeType === node.ELEMENT_NODE
|
|
352
|
+
? node
|
|
353
|
+
: node.parentElement;
|
|
354
|
+
if (el === null)
|
|
355
|
+
return false;
|
|
356
|
+
if (typeof maskTextClass === 'string') {
|
|
357
|
+
if (el.classList.contains(maskTextClass))
|
|
358
|
+
return true;
|
|
359
|
+
if (el.closest(".".concat(maskTextClass)))
|
|
360
|
+
return true;
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
if (classMatchesRegex(el, maskTextClass, true))
|
|
364
|
+
return true;
|
|
365
|
+
}
|
|
366
|
+
if (maskTextSelector) {
|
|
367
|
+
if (el.matches(maskTextSelector))
|
|
368
|
+
return true;
|
|
369
|
+
if (el.closest(maskTextSelector))
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
|
|
375
|
+
var win = iframeEl.contentWindow;
|
|
376
|
+
if (!win) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
var fired = false;
|
|
380
|
+
var readyState;
|
|
381
|
+
try {
|
|
382
|
+
readyState = win.document.readyState;
|
|
383
|
+
}
|
|
384
|
+
catch (error) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
if (readyState !== 'complete') {
|
|
388
|
+
var timer_1 = setTimeout(function () {
|
|
389
|
+
if (!fired) {
|
|
390
|
+
listener();
|
|
391
|
+
fired = true;
|
|
392
|
+
}
|
|
393
|
+
}, iframeLoadTimeout);
|
|
394
|
+
iframeEl.addEventListener('load', function () {
|
|
395
|
+
clearTimeout(timer_1);
|
|
396
|
+
fired = true;
|
|
397
|
+
listener();
|
|
398
|
+
});
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
var blankUrl = 'about:blank';
|
|
402
|
+
if (win.location.href !== blankUrl ||
|
|
403
|
+
iframeEl.src === blankUrl ||
|
|
404
|
+
iframeEl.src === '') {
|
|
405
|
+
setTimeout(listener, 0);
|
|
406
|
+
return iframeEl.addEventListener('load', listener);
|
|
407
|
+
}
|
|
408
|
+
iframeEl.addEventListener('load', listener);
|
|
409
|
+
}
|
|
410
|
+
function isStylesheetLoaded(link) {
|
|
411
|
+
if (!link.getAttribute('href'))
|
|
412
|
+
return true;
|
|
413
|
+
return link.sheet !== null;
|
|
414
|
+
}
|
|
415
|
+
function onceStylesheetLoaded(link, listener, styleSheetLoadTimeout) {
|
|
416
|
+
var fired = false;
|
|
417
|
+
var styleSheetLoaded;
|
|
418
|
+
try {
|
|
419
|
+
styleSheetLoaded = link.sheet;
|
|
420
|
+
}
|
|
421
|
+
catch (error) {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
if (styleSheetLoaded)
|
|
425
|
+
return;
|
|
426
|
+
var timer = setTimeout(function () {
|
|
427
|
+
if (!fired) {
|
|
428
|
+
listener();
|
|
429
|
+
fired = true;
|
|
430
|
+
}
|
|
431
|
+
}, styleSheetLoadTimeout);
|
|
432
|
+
link.addEventListener('load', function () {
|
|
433
|
+
clearTimeout(timer);
|
|
434
|
+
fired = true;
|
|
435
|
+
listener();
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
function serializeNode(n, options) {
|
|
439
|
+
var doc = options.doc, mirror = options.mirror, blockClass = options.blockClass, blockSelector = options.blockSelector, maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, inlineStylesheet = options.inlineStylesheet, _a = options.maskInputOptions, maskInputOptions = _a === void 0 ? {} : _a, maskTextFn = options.maskTextFn, maskInputFn = options.maskInputFn, _b = options.dataURLOptions, dataURLOptions = _b === void 0 ? {} : _b, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn, _c = options.newlyAddedElement, newlyAddedElement = _c === void 0 ? false : _c, enableStrictPrivacy = options.enableStrictPrivacy;
|
|
440
|
+
var rootId = getRootId(doc, mirror);
|
|
441
|
+
switch (n.nodeType) {
|
|
442
|
+
case n.DOCUMENT_NODE:
|
|
443
|
+
if (n.compatMode !== 'CSS1Compat') {
|
|
444
|
+
return {
|
|
445
|
+
type: NodeType$2.Document,
|
|
446
|
+
childNodes: [],
|
|
447
|
+
compatMode: n.compatMode,
|
|
448
|
+
rootId: rootId
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
return {
|
|
453
|
+
type: NodeType$2.Document,
|
|
454
|
+
childNodes: [],
|
|
455
|
+
rootId: rootId
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
case n.DOCUMENT_TYPE_NODE:
|
|
459
|
+
return {
|
|
460
|
+
type: NodeType$2.DocumentType,
|
|
461
|
+
name: n.name,
|
|
462
|
+
publicId: n.publicId,
|
|
463
|
+
systemId: n.systemId,
|
|
464
|
+
rootId: rootId
|
|
465
|
+
};
|
|
466
|
+
case n.ELEMENT_NODE:
|
|
467
|
+
return serializeElementNode(n, {
|
|
468
|
+
doc: doc,
|
|
469
|
+
blockClass: blockClass,
|
|
470
|
+
blockSelector: blockSelector,
|
|
471
|
+
inlineStylesheet: inlineStylesheet,
|
|
472
|
+
maskInputOptions: maskInputOptions,
|
|
473
|
+
maskInputFn: maskInputFn,
|
|
474
|
+
dataURLOptions: dataURLOptions,
|
|
475
|
+
inlineImages: inlineImages,
|
|
476
|
+
recordCanvas: recordCanvas,
|
|
477
|
+
keepIframeSrcFn: keepIframeSrcFn,
|
|
478
|
+
newlyAddedElement: newlyAddedElement,
|
|
479
|
+
enableStrictPrivacy: enableStrictPrivacy,
|
|
480
|
+
rootId: rootId
|
|
481
|
+
});
|
|
482
|
+
case n.TEXT_NODE:
|
|
483
|
+
return serializeTextNode(n, {
|
|
484
|
+
maskTextClass: maskTextClass,
|
|
485
|
+
maskTextSelector: maskTextSelector,
|
|
486
|
+
maskTextFn: maskTextFn,
|
|
487
|
+
enableStrictPrivacy: enableStrictPrivacy,
|
|
488
|
+
rootId: rootId
|
|
489
|
+
});
|
|
490
|
+
case n.CDATA_SECTION_NODE:
|
|
491
|
+
return {
|
|
492
|
+
type: NodeType$2.CDATA,
|
|
493
|
+
textContent: '',
|
|
494
|
+
rootId: rootId
|
|
495
|
+
};
|
|
496
|
+
case n.COMMENT_NODE:
|
|
497
|
+
return {
|
|
498
|
+
type: NodeType$2.Comment,
|
|
499
|
+
textContent: n.textContent || '',
|
|
500
|
+
rootId: rootId
|
|
501
|
+
};
|
|
502
|
+
default:
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function getRootId(doc, mirror) {
|
|
507
|
+
if (!mirror.hasNode(doc))
|
|
508
|
+
return undefined;
|
|
509
|
+
var docId = mirror.getId(doc);
|
|
510
|
+
return docId === 1 ? undefined : docId;
|
|
511
|
+
}
|
|
512
|
+
function serializeTextNode(n, options) {
|
|
513
|
+
var _a;
|
|
514
|
+
var maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, maskTextFn = options.maskTextFn, enableStrictPrivacy = options.enableStrictPrivacy, rootId = options.rootId;
|
|
515
|
+
var parentTagName = n.parentNode && n.parentNode.tagName;
|
|
516
|
+
var textContent = n.textContent;
|
|
517
|
+
var isStyle = parentTagName === 'STYLE' ? true : undefined;
|
|
518
|
+
var isScript = parentTagName === 'SCRIPT' ? true : undefined;
|
|
519
|
+
var textContentHandled = false;
|
|
520
|
+
if (isStyle && textContent) {
|
|
521
|
+
try {
|
|
522
|
+
if (n.nextSibling || n.previousSibling) {
|
|
523
|
+
}
|
|
524
|
+
else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
|
|
525
|
+
textContent = stringifyStyleSheet(n.parentNode.sheet);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
catch (err) {
|
|
529
|
+
console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(err), n);
|
|
530
|
+
}
|
|
531
|
+
textContent = absoluteToStylesheet(textContent, getHref());
|
|
532
|
+
textContentHandled = true;
|
|
533
|
+
}
|
|
534
|
+
if (isScript) {
|
|
535
|
+
textContent = 'SCRIPT_PLACEHOLDER';
|
|
536
|
+
textContentHandled = true;
|
|
537
|
+
}
|
|
538
|
+
else if (parentTagName === 'NOSCRIPT') {
|
|
539
|
+
textContent = '';
|
|
540
|
+
textContentHandled = true;
|
|
541
|
+
}
|
|
542
|
+
if (!isStyle &&
|
|
543
|
+
!isScript &&
|
|
544
|
+
textContent &&
|
|
545
|
+
needMaskingText(n, maskTextClass, maskTextSelector)) {
|
|
546
|
+
textContent = maskTextFn
|
|
547
|
+
? maskTextFn(textContent)
|
|
548
|
+
: textContent.replace(/[\S]/g, '*');
|
|
549
|
+
}
|
|
550
|
+
if (enableStrictPrivacy && !textContentHandled && parentTagName) {
|
|
551
|
+
var IGNORE_TAG_NAMES = new Set([
|
|
552
|
+
'HEAD',
|
|
553
|
+
'TITLE',
|
|
554
|
+
'STYLE',
|
|
555
|
+
'SCRIPT',
|
|
556
|
+
'HTML',
|
|
557
|
+
'BODY',
|
|
558
|
+
'NOSCRIPT',
|
|
559
|
+
]);
|
|
560
|
+
if (!IGNORE_TAG_NAMES.has(parentTagName) && textContent) {
|
|
561
|
+
textContent = obfuscateText(textContent);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return {
|
|
565
|
+
type: NodeType$2.Text,
|
|
566
|
+
textContent: textContent || '',
|
|
567
|
+
isStyle: isStyle,
|
|
568
|
+
rootId: rootId
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
function serializeElementNode(n, options) {
|
|
572
|
+
var doc = options.doc, blockClass = options.blockClass, blockSelector = options.blockSelector, inlineStylesheet = options.inlineStylesheet, _a = options.maskInputOptions, maskInputOptions = _a === void 0 ? {} : _a, maskInputFn = options.maskInputFn, _b = options.dataURLOptions, dataURLOptions = _b === void 0 ? {} : _b, inlineImages = options.inlineImages, recordCanvas = options.recordCanvas, keepIframeSrcFn = options.keepIframeSrcFn, _c = options.newlyAddedElement, newlyAddedElement = _c === void 0 ? false : _c, enableStrictPrivacy = options.enableStrictPrivacy, rootId = options.rootId;
|
|
573
|
+
var needBlock = _isBlockedElement(n, blockClass, blockSelector);
|
|
574
|
+
var tagName = getValidTagName$1(n);
|
|
575
|
+
var attributes = {};
|
|
576
|
+
var len = n.attributes.length;
|
|
577
|
+
for (var i = 0; i < len; i++) {
|
|
578
|
+
var attr = n.attributes[i];
|
|
579
|
+
attributes[attr.name] = transformAttribute(doc, tagName, attr.name, attr.value);
|
|
580
|
+
}
|
|
581
|
+
if (tagName === 'link' && inlineStylesheet) {
|
|
582
|
+
var stylesheet = Array.from(doc.styleSheets).find(function (s) {
|
|
583
|
+
return s.href === n.href;
|
|
584
|
+
});
|
|
585
|
+
var cssText = null;
|
|
586
|
+
if (stylesheet) {
|
|
587
|
+
cssText = getCssRulesString(stylesheet);
|
|
588
|
+
}
|
|
589
|
+
if (cssText) {
|
|
590
|
+
delete attributes.rel;
|
|
591
|
+
delete attributes.href;
|
|
592
|
+
attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
if (tagName === 'style' &&
|
|
596
|
+
n.sheet &&
|
|
597
|
+
!(n.innerText || n.textContent || '').trim().length) {
|
|
598
|
+
var cssText = getCssRulesString(n.sheet);
|
|
599
|
+
if (cssText) {
|
|
600
|
+
attributes._cssText = absoluteToStylesheet(cssText, getHref());
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
if (tagName === 'input' || tagName === 'textarea' || tagName === 'select') {
|
|
604
|
+
var value = n.value;
|
|
605
|
+
if (attributes.type !== 'radio' &&
|
|
606
|
+
attributes.type !== 'checkbox' &&
|
|
607
|
+
attributes.type !== 'submit' &&
|
|
608
|
+
attributes.type !== 'button' &&
|
|
609
|
+
value) {
|
|
610
|
+
attributes.value = maskInputValue({
|
|
611
|
+
type: attributes.type,
|
|
612
|
+
tagName: tagName,
|
|
613
|
+
value: value,
|
|
614
|
+
maskInputOptions: maskInputOptions,
|
|
615
|
+
maskInputFn: maskInputFn
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
else if (n.checked) {
|
|
619
|
+
attributes.checked = n.checked;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
if (tagName === 'option') {
|
|
623
|
+
if (n.selected && !maskInputOptions['select']) {
|
|
624
|
+
attributes.selected = true;
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
delete attributes.selected;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
if (tagName === 'canvas' && recordCanvas) {
|
|
631
|
+
if (n.__context === '2d') {
|
|
632
|
+
if (!is2DCanvasBlank(n)) {
|
|
633
|
+
attributes.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
else if (!('__context' in n)) {
|
|
637
|
+
var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
638
|
+
var blankCanvas = document.createElement('canvas');
|
|
639
|
+
blankCanvas.width = n.width;
|
|
640
|
+
blankCanvas.height = n.height;
|
|
641
|
+
var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
642
|
+
if (canvasDataURL !== blankCanvasDataURL) {
|
|
643
|
+
attributes.rr_dataURL = canvasDataURL;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
if (tagName === 'img' && inlineImages) {
|
|
648
|
+
if (!canvasService) {
|
|
649
|
+
canvasService = doc.createElement('canvas');
|
|
650
|
+
canvasCtx = canvasService.getContext('2d');
|
|
651
|
+
}
|
|
652
|
+
var image_1 = n;
|
|
653
|
+
var oldValue_1 = image_1.crossOrigin;
|
|
654
|
+
image_1.crossOrigin = 'anonymous';
|
|
655
|
+
var recordInlineImage = function () {
|
|
656
|
+
try {
|
|
657
|
+
canvasService.width = image_1.naturalWidth;
|
|
658
|
+
canvasService.height = image_1.naturalHeight;
|
|
659
|
+
canvasCtx.drawImage(image_1, 0, 0);
|
|
660
|
+
attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
661
|
+
}
|
|
662
|
+
catch (err) {
|
|
663
|
+
console.warn("Cannot inline img src=".concat(image_1.currentSrc, "! Error: ").concat(err));
|
|
664
|
+
}
|
|
665
|
+
oldValue_1
|
|
666
|
+
? (attributes.crossOrigin = oldValue_1)
|
|
667
|
+
: image_1.removeAttribute('crossorigin');
|
|
668
|
+
};
|
|
669
|
+
if (image_1.complete && image_1.naturalWidth !== 0)
|
|
670
|
+
recordInlineImage();
|
|
671
|
+
else
|
|
672
|
+
image_1.onload = recordInlineImage;
|
|
673
|
+
}
|
|
674
|
+
if (tagName === 'audio' || tagName === 'video') {
|
|
675
|
+
attributes.rr_mediaState = n.paused
|
|
676
|
+
? 'paused'
|
|
677
|
+
: 'played';
|
|
678
|
+
attributes.rr_mediaCurrentTime = n.currentTime;
|
|
679
|
+
}
|
|
680
|
+
if (!newlyAddedElement) {
|
|
681
|
+
if (n.scrollLeft) {
|
|
682
|
+
attributes.rr_scrollLeft = n.scrollLeft;
|
|
683
|
+
}
|
|
684
|
+
if (n.scrollTop) {
|
|
685
|
+
attributes.rr_scrollTop = n.scrollTop;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
if (needBlock || (tagName === 'img' && enableStrictPrivacy)) {
|
|
689
|
+
var _d = n.getBoundingClientRect(), width = _d.width, height = _d.height;
|
|
690
|
+
attributes = {
|
|
691
|
+
"class": attributes["class"],
|
|
692
|
+
rr_width: "".concat(width, "px"),
|
|
693
|
+
rr_height: "".concat(height, "px")
|
|
694
|
+
};
|
|
695
|
+
needBlock = true;
|
|
696
|
+
}
|
|
697
|
+
if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src)) {
|
|
698
|
+
if (!n.contentDocument) {
|
|
699
|
+
attributes.rr_src = attributes.src;
|
|
700
|
+
}
|
|
701
|
+
delete attributes.src;
|
|
702
|
+
}
|
|
703
|
+
return {
|
|
704
|
+
type: NodeType$2.Element,
|
|
705
|
+
tagName: tagName,
|
|
706
|
+
attributes: attributes,
|
|
707
|
+
childNodes: [],
|
|
708
|
+
isSVG: isSVGElement(n) || undefined,
|
|
709
|
+
needBlock: needBlock,
|
|
710
|
+
rootId: rootId
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
function lowerIfExists(maybeAttr) {
|
|
714
|
+
if (maybeAttr === undefined) {
|
|
715
|
+
return '';
|
|
716
|
+
}
|
|
717
|
+
else {
|
|
718
|
+
return maybeAttr.toLowerCase();
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
function slimDOMExcluded(sn, slimDOMOptions) {
|
|
722
|
+
if (slimDOMOptions.comment && sn.type === NodeType$2.Comment) {
|
|
723
|
+
return true;
|
|
724
|
+
}
|
|
725
|
+
else if (sn.type === NodeType$2.Element) {
|
|
726
|
+
if (slimDOMOptions.script &&
|
|
727
|
+
(sn.tagName === 'script' ||
|
|
728
|
+
(sn.tagName === 'link' &&
|
|
729
|
+
sn.attributes.rel === 'preload' &&
|
|
730
|
+
sn.attributes.as === 'script') ||
|
|
731
|
+
(sn.tagName === 'link' &&
|
|
732
|
+
sn.attributes.rel === 'prefetch' &&
|
|
733
|
+
typeof sn.attributes.href === 'string' &&
|
|
734
|
+
sn.attributes.href.endsWith('.js')))) {
|
|
735
|
+
return true;
|
|
736
|
+
}
|
|
737
|
+
else if (slimDOMOptions.headFavicon &&
|
|
738
|
+
((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||
|
|
739
|
+
(sn.tagName === 'meta' &&
|
|
740
|
+
(lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||
|
|
741
|
+
lowerIfExists(sn.attributes.name) === 'application-name' ||
|
|
742
|
+
lowerIfExists(sn.attributes.rel) === 'icon' ||
|
|
743
|
+
lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||
|
|
744
|
+
lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {
|
|
745
|
+
return true;
|
|
746
|
+
}
|
|
747
|
+
else if (sn.tagName === 'meta') {
|
|
748
|
+
if (slimDOMOptions.headMetaDescKeywords &&
|
|
749
|
+
lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
|
|
750
|
+
return true;
|
|
751
|
+
}
|
|
752
|
+
else if (slimDOMOptions.headMetaSocial &&
|
|
753
|
+
(lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||
|
|
754
|
+
lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||
|
|
755
|
+
lowerIfExists(sn.attributes.name) === 'pinterest')) {
|
|
756
|
+
return true;
|
|
757
|
+
}
|
|
758
|
+
else if (slimDOMOptions.headMetaRobots &&
|
|
759
|
+
(lowerIfExists(sn.attributes.name) === 'robots' ||
|
|
760
|
+
lowerIfExists(sn.attributes.name) === 'googlebot' ||
|
|
761
|
+
lowerIfExists(sn.attributes.name) === 'bingbot')) {
|
|
762
|
+
return true;
|
|
763
|
+
}
|
|
764
|
+
else if (slimDOMOptions.headMetaHttpEquiv &&
|
|
765
|
+
sn.attributes['http-equiv'] !== undefined) {
|
|
766
|
+
return true;
|
|
767
|
+
}
|
|
768
|
+
else if (slimDOMOptions.headMetaAuthorship &&
|
|
769
|
+
(lowerIfExists(sn.attributes.name) === 'author' ||
|
|
770
|
+
lowerIfExists(sn.attributes.name) === 'generator' ||
|
|
771
|
+
lowerIfExists(sn.attributes.name) === 'framework' ||
|
|
772
|
+
lowerIfExists(sn.attributes.name) === 'publisher' ||
|
|
773
|
+
lowerIfExists(sn.attributes.name) === 'progid' ||
|
|
774
|
+
lowerIfExists(sn.attributes.property).match(/^article:/) ||
|
|
775
|
+
lowerIfExists(sn.attributes.property).match(/^product:/))) {
|
|
776
|
+
return true;
|
|
777
|
+
}
|
|
778
|
+
else if (slimDOMOptions.headMetaVerification &&
|
|
779
|
+
(lowerIfExists(sn.attributes.name) === 'google-site-verification' ||
|
|
780
|
+
lowerIfExists(sn.attributes.name) === 'yandex-verification' ||
|
|
781
|
+
lowerIfExists(sn.attributes.name) === 'csrf-token' ||
|
|
782
|
+
lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||
|
|
783
|
+
lowerIfExists(sn.attributes.name) === 'verify-v1' ||
|
|
784
|
+
lowerIfExists(sn.attributes.name) === 'verification' ||
|
|
785
|
+
lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {
|
|
786
|
+
return true;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return false;
|
|
791
|
+
}
|
|
792
|
+
function serializeNodeWithId(n, options) {
|
|
793
|
+
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 ? 5000 : _g, onStylesheetLoad = options.onStylesheetLoad, _h = options.stylesheetLoadTimeout, stylesheetLoadTimeout = _h === void 0 ? 5000 : _h, _j = options.keepIframeSrcFn, keepIframeSrcFn = _j === void 0 ? function () { return false; } : _j, _k = options.newlyAddedElement, newlyAddedElement = _k === void 0 ? false : _k, enableStrictPrivacy = options.enableStrictPrivacy;
|
|
794
|
+
var _l = options.preserveWhiteSpace, preserveWhiteSpace = _l === void 0 ? true : _l;
|
|
795
|
+
var _serializedNode = serializeNode(n, {
|
|
796
|
+
doc: doc,
|
|
797
|
+
mirror: mirror,
|
|
798
|
+
blockClass: blockClass,
|
|
799
|
+
blockSelector: blockSelector,
|
|
800
|
+
maskTextClass: maskTextClass,
|
|
801
|
+
maskTextSelector: maskTextSelector,
|
|
802
|
+
inlineStylesheet: inlineStylesheet,
|
|
803
|
+
maskInputOptions: maskInputOptions,
|
|
804
|
+
maskTextFn: maskTextFn,
|
|
805
|
+
maskInputFn: maskInputFn,
|
|
806
|
+
dataURLOptions: dataURLOptions,
|
|
807
|
+
inlineImages: inlineImages,
|
|
808
|
+
recordCanvas: recordCanvas,
|
|
809
|
+
keepIframeSrcFn: keepIframeSrcFn,
|
|
810
|
+
newlyAddedElement: newlyAddedElement,
|
|
811
|
+
enableStrictPrivacy: enableStrictPrivacy
|
|
812
|
+
});
|
|
813
|
+
if (!_serializedNode) {
|
|
814
|
+
console.warn(n, 'not serialized');
|
|
815
|
+
return null;
|
|
816
|
+
}
|
|
817
|
+
var id;
|
|
818
|
+
if (mirror.hasNode(n)) {
|
|
819
|
+
id = mirror.getId(n);
|
|
820
|
+
}
|
|
821
|
+
else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||
|
|
822
|
+
(!preserveWhiteSpace &&
|
|
823
|
+
_serializedNode.type === NodeType$2.Text &&
|
|
824
|
+
!_serializedNode.isStyle &&
|
|
825
|
+
!_serializedNode.textContent.replace(/^\s+|\s+$/gm, '').length)) {
|
|
826
|
+
id = IGNORED_NODE;
|
|
827
|
+
}
|
|
828
|
+
else {
|
|
829
|
+
id = genId();
|
|
830
|
+
}
|
|
831
|
+
if (id === IGNORED_NODE) {
|
|
832
|
+
return null;
|
|
833
|
+
}
|
|
834
|
+
var serializedNode = Object.assign(_serializedNode, { id: id });
|
|
835
|
+
mirror.add(n, serializedNode);
|
|
836
|
+
if (onSerialize) {
|
|
837
|
+
onSerialize(n);
|
|
838
|
+
}
|
|
839
|
+
var recordChild = !skipChild;
|
|
840
|
+
if (serializedNode.type === NodeType$2.Element) {
|
|
841
|
+
recordChild = recordChild && !serializedNode.needBlock;
|
|
842
|
+
if (serializedNode.needBlock && serializedNode.tagName === 'img') {
|
|
843
|
+
var clone = n.cloneNode();
|
|
844
|
+
clone.src = '';
|
|
845
|
+
mirror.add(clone, serializedNode);
|
|
846
|
+
}
|
|
847
|
+
delete serializedNode.needBlock;
|
|
848
|
+
if (n.shadowRoot)
|
|
849
|
+
serializedNode.isShadowHost = true;
|
|
850
|
+
}
|
|
851
|
+
if ((serializedNode.type === NodeType$2.Document ||
|
|
852
|
+
serializedNode.type === NodeType$2.Element) &&
|
|
853
|
+
recordChild) {
|
|
854
|
+
if (slimDOMOptions.headWhitespace &&
|
|
855
|
+
serializedNode.type === NodeType$2.Element &&
|
|
856
|
+
serializedNode.tagName === 'head') {
|
|
857
|
+
preserveWhiteSpace = false;
|
|
858
|
+
}
|
|
859
|
+
var bypassOptions = {
|
|
860
|
+
doc: doc,
|
|
861
|
+
mirror: mirror,
|
|
862
|
+
blockClass: blockClass,
|
|
863
|
+
blockSelector: blockSelector,
|
|
864
|
+
maskTextClass: maskTextClass,
|
|
865
|
+
maskTextSelector: maskTextSelector,
|
|
866
|
+
skipChild: skipChild,
|
|
867
|
+
inlineStylesheet: inlineStylesheet,
|
|
868
|
+
maskInputOptions: maskInputOptions,
|
|
869
|
+
maskTextFn: maskTextFn,
|
|
870
|
+
maskInputFn: maskInputFn,
|
|
871
|
+
slimDOMOptions: slimDOMOptions,
|
|
872
|
+
dataURLOptions: dataURLOptions,
|
|
873
|
+
inlineImages: inlineImages,
|
|
874
|
+
recordCanvas: recordCanvas,
|
|
875
|
+
preserveWhiteSpace: preserveWhiteSpace,
|
|
876
|
+
onSerialize: onSerialize,
|
|
877
|
+
onIframeLoad: onIframeLoad,
|
|
878
|
+
iframeLoadTimeout: iframeLoadTimeout,
|
|
879
|
+
onStylesheetLoad: onStylesheetLoad,
|
|
880
|
+
stylesheetLoadTimeout: stylesheetLoadTimeout,
|
|
881
|
+
keepIframeSrcFn: keepIframeSrcFn,
|
|
882
|
+
enableStrictPrivacy: enableStrictPrivacy
|
|
883
|
+
};
|
|
884
|
+
for (var _i = 0, _m = Array.from(n.childNodes); _i < _m.length; _i++) {
|
|
885
|
+
var childN = _m[_i];
|
|
886
|
+
var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
887
|
+
if (serializedChildNode) {
|
|
888
|
+
serializedNode.childNodes.push(serializedChildNode);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
if (isElement(n) && n.shadowRoot) {
|
|
892
|
+
for (var _o = 0, _p = Array.from(n.shadowRoot.childNodes); _o < _p.length; _o++) {
|
|
893
|
+
var childN = _p[_o];
|
|
894
|
+
var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
895
|
+
if (serializedChildNode) {
|
|
896
|
+
serializedChildNode.isShadow = true;
|
|
897
|
+
serializedNode.childNodes.push(serializedChildNode);
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
if (n.parentNode && isShadowRoot(n.parentNode)) {
|
|
903
|
+
serializedNode.isShadow = true;
|
|
904
|
+
}
|
|
905
|
+
if (serializedNode.type === NodeType$2.Element &&
|
|
906
|
+
serializedNode.tagName === 'iframe') {
|
|
907
|
+
onceIframeLoaded(n, function () {
|
|
908
|
+
var iframeDoc = n.contentDocument;
|
|
909
|
+
if (iframeDoc && onIframeLoad) {
|
|
910
|
+
var serializedIframeNode = serializeNodeWithId(iframeDoc, {
|
|
911
|
+
doc: iframeDoc,
|
|
912
|
+
mirror: mirror,
|
|
913
|
+
blockClass: blockClass,
|
|
914
|
+
blockSelector: blockSelector,
|
|
915
|
+
maskTextClass: maskTextClass,
|
|
916
|
+
maskTextSelector: maskTextSelector,
|
|
917
|
+
skipChild: false,
|
|
918
|
+
inlineStylesheet: inlineStylesheet,
|
|
919
|
+
maskInputOptions: maskInputOptions,
|
|
920
|
+
maskTextFn: maskTextFn,
|
|
921
|
+
maskInputFn: maskInputFn,
|
|
922
|
+
slimDOMOptions: slimDOMOptions,
|
|
923
|
+
dataURLOptions: dataURLOptions,
|
|
924
|
+
inlineImages: inlineImages,
|
|
925
|
+
recordCanvas: recordCanvas,
|
|
926
|
+
preserveWhiteSpace: preserveWhiteSpace,
|
|
927
|
+
onSerialize: onSerialize,
|
|
928
|
+
onIframeLoad: onIframeLoad,
|
|
929
|
+
iframeLoadTimeout: iframeLoadTimeout,
|
|
930
|
+
onStylesheetLoad: onStylesheetLoad,
|
|
931
|
+
stylesheetLoadTimeout: stylesheetLoadTimeout,
|
|
932
|
+
keepIframeSrcFn: keepIframeSrcFn,
|
|
933
|
+
enableStrictPrivacy: enableStrictPrivacy
|
|
934
|
+
});
|
|
935
|
+
if (serializedIframeNode) {
|
|
936
|
+
onIframeLoad(n, serializedIframeNode);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}, iframeLoadTimeout);
|
|
940
|
+
}
|
|
941
|
+
if (serializedNode.type === NodeType$2.Element &&
|
|
942
|
+
serializedNode.tagName === 'link' &&
|
|
943
|
+
serializedNode.attributes.rel === 'stylesheet') {
|
|
944
|
+
onceStylesheetLoaded(n, function () {
|
|
945
|
+
if (onStylesheetLoad) {
|
|
946
|
+
var serializedLinkNode = serializeNodeWithId(n, {
|
|
947
|
+
doc: doc,
|
|
948
|
+
mirror: mirror,
|
|
949
|
+
blockClass: blockClass,
|
|
950
|
+
blockSelector: blockSelector,
|
|
951
|
+
maskTextClass: maskTextClass,
|
|
952
|
+
maskTextSelector: maskTextSelector,
|
|
953
|
+
skipChild: false,
|
|
954
|
+
inlineStylesheet: inlineStylesheet,
|
|
955
|
+
maskInputOptions: maskInputOptions,
|
|
956
|
+
maskTextFn: maskTextFn,
|
|
957
|
+
maskInputFn: maskInputFn,
|
|
958
|
+
slimDOMOptions: slimDOMOptions,
|
|
959
|
+
dataURLOptions: dataURLOptions,
|
|
960
|
+
inlineImages: inlineImages,
|
|
961
|
+
recordCanvas: recordCanvas,
|
|
962
|
+
preserveWhiteSpace: preserveWhiteSpace,
|
|
963
|
+
onSerialize: onSerialize,
|
|
964
|
+
onIframeLoad: onIframeLoad,
|
|
965
|
+
iframeLoadTimeout: iframeLoadTimeout,
|
|
966
|
+
onStylesheetLoad: onStylesheetLoad,
|
|
967
|
+
stylesheetLoadTimeout: stylesheetLoadTimeout,
|
|
968
|
+
keepIframeSrcFn: keepIframeSrcFn,
|
|
969
|
+
enableStrictPrivacy: enableStrictPrivacy
|
|
970
|
+
});
|
|
971
|
+
if (serializedLinkNode) {
|
|
972
|
+
onStylesheetLoad(n, serializedLinkNode);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}, stylesheetLoadTimeout);
|
|
976
|
+
if (isStylesheetLoaded(n) === false)
|
|
977
|
+
return null;
|
|
978
|
+
}
|
|
979
|
+
return serializedNode;
|
|
980
|
+
}
|
|
981
|
+
function snapshot(n, options) {
|
|
982
|
+
var _a = options || {}, _b = _a.mirror, mirror = _b === void 0 ? new Mirror$2() : _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 () { return false; } : _m, _o = _a.enableStrictPrivacy, enableStrictPrivacy = _o === void 0 ? false : _o;
|
|
983
|
+
var maskInputOptions = maskAllInputs === true
|
|
984
|
+
? {
|
|
985
|
+
color: true,
|
|
986
|
+
date: true,
|
|
987
|
+
'datetime-local': true,
|
|
988
|
+
email: true,
|
|
989
|
+
month: true,
|
|
990
|
+
number: true,
|
|
991
|
+
range: true,
|
|
992
|
+
search: true,
|
|
993
|
+
tel: true,
|
|
994
|
+
text: true,
|
|
995
|
+
time: true,
|
|
996
|
+
url: true,
|
|
997
|
+
week: true,
|
|
998
|
+
textarea: true,
|
|
999
|
+
select: true,
|
|
1000
|
+
password: true
|
|
1001
|
+
}
|
|
1002
|
+
: maskAllInputs === false
|
|
1003
|
+
? {
|
|
1004
|
+
password: true
|
|
1005
|
+
}
|
|
1006
|
+
: maskAllInputs;
|
|
1007
|
+
var slimDOMOptions = slimDOM === true || slimDOM === 'all'
|
|
1008
|
+
?
|
|
1009
|
+
{
|
|
1010
|
+
script: true,
|
|
1011
|
+
comment: true,
|
|
1012
|
+
headFavicon: true,
|
|
1013
|
+
headWhitespace: true,
|
|
1014
|
+
headMetaDescKeywords: slimDOM === 'all',
|
|
1015
|
+
headMetaSocial: true,
|
|
1016
|
+
headMetaRobots: true,
|
|
1017
|
+
headMetaHttpEquiv: true,
|
|
1018
|
+
headMetaAuthorship: true,
|
|
1019
|
+
headMetaVerification: true
|
|
1020
|
+
}
|
|
1021
|
+
: slimDOM === false
|
|
1022
|
+
? {}
|
|
1023
|
+
: slimDOM;
|
|
1024
|
+
return serializeNodeWithId(n, {
|
|
1025
|
+
doc: n,
|
|
1026
|
+
mirror: mirror,
|
|
1027
|
+
blockClass: blockClass,
|
|
1028
|
+
blockSelector: blockSelector,
|
|
1029
|
+
maskTextClass: maskTextClass,
|
|
1030
|
+
maskTextSelector: maskTextSelector,
|
|
1031
|
+
skipChild: false,
|
|
1032
|
+
inlineStylesheet: inlineStylesheet,
|
|
1033
|
+
maskInputOptions: maskInputOptions,
|
|
1034
|
+
maskTextFn: maskTextFn,
|
|
1035
|
+
maskInputFn: maskInputFn,
|
|
1036
|
+
slimDOMOptions: slimDOMOptions,
|
|
1037
|
+
dataURLOptions: dataURLOptions,
|
|
1038
|
+
inlineImages: inlineImages,
|
|
1039
|
+
recordCanvas: recordCanvas,
|
|
1040
|
+
preserveWhiteSpace: preserveWhiteSpace,
|
|
1041
|
+
onSerialize: onSerialize,
|
|
1042
|
+
onIframeLoad: onIframeLoad,
|
|
1043
|
+
iframeLoadTimeout: iframeLoadTimeout,
|
|
1044
|
+
onStylesheetLoad: onStylesheetLoad,
|
|
1045
|
+
stylesheetLoadTimeout: stylesheetLoadTimeout,
|
|
1046
|
+
keepIframeSrcFn: keepIframeSrcFn,
|
|
1047
|
+
newlyAddedElement: false,
|
|
1048
|
+
enableStrictPrivacy: enableStrictPrivacy
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
1053
|
+
function parse(css, options) {
|
|
1054
|
+
if (options === void 0) { options = {}; }
|
|
1055
|
+
var lineno = 1;
|
|
1056
|
+
var column = 1;
|
|
1057
|
+
function updatePosition(str) {
|
|
1058
|
+
var lines = str.match(/\n/g);
|
|
1059
|
+
if (lines) {
|
|
1060
|
+
lineno += lines.length;
|
|
1061
|
+
}
|
|
1062
|
+
var i = str.lastIndexOf('\n');
|
|
1063
|
+
column = i === -1 ? column + str.length : str.length - i;
|
|
1064
|
+
}
|
|
1065
|
+
function position() {
|
|
1066
|
+
var start = { line: lineno, column: column };
|
|
1067
|
+
return function (node) {
|
|
1068
|
+
node.position = new Position(start);
|
|
1069
|
+
whitespace();
|
|
1070
|
+
return node;
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
var Position = (function () {
|
|
1074
|
+
function Position(start) {
|
|
1075
|
+
this.start = start;
|
|
1076
|
+
this.end = { line: lineno, column: column };
|
|
1077
|
+
this.source = options.source;
|
|
1078
|
+
}
|
|
1079
|
+
return Position;
|
|
1080
|
+
}());
|
|
1081
|
+
Position.prototype.content = css;
|
|
1082
|
+
var errorsList = [];
|
|
1083
|
+
function error(msg) {
|
|
1084
|
+
var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
|
|
1085
|
+
err.reason = msg;
|
|
1086
|
+
err.filename = options.source;
|
|
1087
|
+
err.line = lineno;
|
|
1088
|
+
err.column = column;
|
|
1089
|
+
err.source = css;
|
|
1090
|
+
if (options.silent) {
|
|
1091
|
+
errorsList.push(err);
|
|
1092
|
+
}
|
|
1093
|
+
else {
|
|
1094
|
+
throw err;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
function stylesheet() {
|
|
1098
|
+
var rulesList = rules();
|
|
1099
|
+
return {
|
|
1100
|
+
type: 'stylesheet',
|
|
1101
|
+
stylesheet: {
|
|
1102
|
+
source: options.source,
|
|
1103
|
+
rules: rulesList,
|
|
1104
|
+
parsingErrors: errorsList
|
|
1105
|
+
}
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
function open() {
|
|
1109
|
+
return match(/^{\s*/);
|
|
1110
|
+
}
|
|
1111
|
+
function close() {
|
|
1112
|
+
return match(/^}/);
|
|
1113
|
+
}
|
|
1114
|
+
function rules() {
|
|
1115
|
+
var node;
|
|
1116
|
+
var rules = [];
|
|
1117
|
+
whitespace();
|
|
1118
|
+
comments(rules);
|
|
1119
|
+
while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {
|
|
1120
|
+
if (node !== false) {
|
|
1121
|
+
rules.push(node);
|
|
1122
|
+
comments(rules);
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
return rules;
|
|
1126
|
+
}
|
|
1127
|
+
function match(re) {
|
|
1128
|
+
var m = re.exec(css);
|
|
1129
|
+
if (!m) {
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
var str = m[0];
|
|
1133
|
+
updatePosition(str);
|
|
1134
|
+
css = css.slice(str.length);
|
|
1135
|
+
return m;
|
|
1136
|
+
}
|
|
1137
|
+
function whitespace() {
|
|
1138
|
+
match(/^\s*/);
|
|
1139
|
+
}
|
|
1140
|
+
function comments(rules) {
|
|
1141
|
+
if (rules === void 0) { rules = []; }
|
|
1142
|
+
var c;
|
|
1143
|
+
while ((c = comment())) {
|
|
1144
|
+
if (c !== false) {
|
|
1145
|
+
rules.push(c);
|
|
1146
|
+
}
|
|
1147
|
+
c = comment();
|
|
1148
|
+
}
|
|
1149
|
+
return rules;
|
|
1150
|
+
}
|
|
1151
|
+
function comment() {
|
|
1152
|
+
var pos = position();
|
|
1153
|
+
if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {
|
|
1154
|
+
return;
|
|
1155
|
+
}
|
|
1156
|
+
var i = 2;
|
|
1157
|
+
while ('' !== css.charAt(i) &&
|
|
1158
|
+
('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {
|
|
1159
|
+
++i;
|
|
1160
|
+
}
|
|
1161
|
+
i += 2;
|
|
1162
|
+
if ('' === css.charAt(i - 1)) {
|
|
1163
|
+
return error('End of comment missing');
|
|
1164
|
+
}
|
|
1165
|
+
var str = css.slice(2, i - 2);
|
|
1166
|
+
column += 2;
|
|
1167
|
+
updatePosition(str);
|
|
1168
|
+
css = css.slice(i);
|
|
1169
|
+
column += 2;
|
|
1170
|
+
return pos({
|
|
1171
|
+
type: 'comment',
|
|
1172
|
+
comment: str
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
function selector() {
|
|
1176
|
+
var m = match(/^([^{]+)/);
|
|
1177
|
+
if (!m) {
|
|
1178
|
+
return;
|
|
1179
|
+
}
|
|
1180
|
+
return trim(m[0])
|
|
1181
|
+
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
|
|
1182
|
+
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (m) {
|
|
1183
|
+
return m.replace(/,/g, '\u200C');
|
|
1184
|
+
})
|
|
1185
|
+
.split(/\s*(?![^(]*\)),\s*/)
|
|
1186
|
+
.map(function (s) {
|
|
1187
|
+
return s.replace(/\u200C/g, ',');
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
function declaration() {
|
|
1191
|
+
var pos = position();
|
|
1192
|
+
var propMatch = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
|
|
1193
|
+
if (!propMatch) {
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
var prop = trim(propMatch[0]);
|
|
1197
|
+
if (!match(/^:\s*/)) {
|
|
1198
|
+
return error("property missing ':'");
|
|
1199
|
+
}
|
|
1200
|
+
var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
|
|
1201
|
+
var ret = pos({
|
|
1202
|
+
type: 'declaration',
|
|
1203
|
+
property: prop.replace(commentre, ''),
|
|
1204
|
+
value: val ? trim(val[0]).replace(commentre, '') : ''
|
|
1205
|
+
});
|
|
1206
|
+
match(/^[;\s]*/);
|
|
1207
|
+
return ret;
|
|
1208
|
+
}
|
|
1209
|
+
function declarations() {
|
|
1210
|
+
var decls = [];
|
|
1211
|
+
if (!open()) {
|
|
1212
|
+
return error("missing '{'");
|
|
1213
|
+
}
|
|
1214
|
+
comments(decls);
|
|
1215
|
+
var decl;
|
|
1216
|
+
while ((decl = declaration())) {
|
|
1217
|
+
if (decl !== false) {
|
|
1218
|
+
decls.push(decl);
|
|
1219
|
+
comments(decls);
|
|
1220
|
+
}
|
|
1221
|
+
decl = declaration();
|
|
1222
|
+
}
|
|
1223
|
+
if (!close()) {
|
|
1224
|
+
return error("missing '}'");
|
|
1225
|
+
}
|
|
1226
|
+
return decls;
|
|
1227
|
+
}
|
|
1228
|
+
function keyframe() {
|
|
1229
|
+
var m;
|
|
1230
|
+
var vals = [];
|
|
1231
|
+
var pos = position();
|
|
1232
|
+
while ((m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/))) {
|
|
1233
|
+
vals.push(m[1]);
|
|
1234
|
+
match(/^,\s*/);
|
|
1235
|
+
}
|
|
1236
|
+
if (!vals.length) {
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
return pos({
|
|
1240
|
+
type: 'keyframe',
|
|
1241
|
+
values: vals,
|
|
1242
|
+
declarations: declarations()
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
function atkeyframes() {
|
|
1246
|
+
var pos = position();
|
|
1247
|
+
var m = match(/^@([-\w]+)?keyframes\s*/);
|
|
1248
|
+
if (!m) {
|
|
1249
|
+
return;
|
|
1250
|
+
}
|
|
1251
|
+
var vendor = m[1];
|
|
1252
|
+
m = match(/^([-\w]+)\s*/);
|
|
1253
|
+
if (!m) {
|
|
1254
|
+
return error('@keyframes missing name');
|
|
1255
|
+
}
|
|
1256
|
+
var name = m[1];
|
|
1257
|
+
if (!open()) {
|
|
1258
|
+
return error("@keyframes missing '{'");
|
|
1259
|
+
}
|
|
1260
|
+
var frame;
|
|
1261
|
+
var frames = comments();
|
|
1262
|
+
while ((frame = keyframe())) {
|
|
1263
|
+
frames.push(frame);
|
|
1264
|
+
frames = frames.concat(comments());
|
|
1265
|
+
}
|
|
1266
|
+
if (!close()) {
|
|
1267
|
+
return error("@keyframes missing '}'");
|
|
1268
|
+
}
|
|
1269
|
+
return pos({
|
|
1270
|
+
type: 'keyframes',
|
|
1271
|
+
name: name,
|
|
1272
|
+
vendor: vendor,
|
|
1273
|
+
keyframes: frames
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
function atsupports() {
|
|
1277
|
+
var pos = position();
|
|
1278
|
+
var m = match(/^@supports *([^{]+)/);
|
|
1279
|
+
if (!m) {
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
var supports = trim(m[1]);
|
|
1283
|
+
if (!open()) {
|
|
1284
|
+
return error("@supports missing '{'");
|
|
1285
|
+
}
|
|
1286
|
+
var style = comments().concat(rules());
|
|
1287
|
+
if (!close()) {
|
|
1288
|
+
return error("@supports missing '}'");
|
|
1289
|
+
}
|
|
1290
|
+
return pos({
|
|
1291
|
+
type: 'supports',
|
|
1292
|
+
supports: supports,
|
|
1293
|
+
rules: style
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
function athost() {
|
|
1297
|
+
var pos = position();
|
|
1298
|
+
var m = match(/^@host\s*/);
|
|
1299
|
+
if (!m) {
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
if (!open()) {
|
|
1303
|
+
return error("@host missing '{'");
|
|
1304
|
+
}
|
|
1305
|
+
var style = comments().concat(rules());
|
|
1306
|
+
if (!close()) {
|
|
1307
|
+
return error("@host missing '}'");
|
|
1308
|
+
}
|
|
1309
|
+
return pos({
|
|
1310
|
+
type: 'host',
|
|
1311
|
+
rules: style
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
function atmedia() {
|
|
1315
|
+
var pos = position();
|
|
1316
|
+
var m = match(/^@media *([^{]+)/);
|
|
1317
|
+
if (!m) {
|
|
1318
|
+
return;
|
|
1319
|
+
}
|
|
1320
|
+
var media = trim(m[1]);
|
|
1321
|
+
if (!open()) {
|
|
1322
|
+
return error("@media missing '{'");
|
|
1323
|
+
}
|
|
1324
|
+
var style = comments().concat(rules());
|
|
1325
|
+
if (!close()) {
|
|
1326
|
+
return error("@media missing '}'");
|
|
1327
|
+
}
|
|
1328
|
+
return pos({
|
|
1329
|
+
type: 'media',
|
|
1330
|
+
media: media,
|
|
1331
|
+
rules: style
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
function atcustommedia() {
|
|
1335
|
+
var pos = position();
|
|
1336
|
+
var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
|
|
1337
|
+
if (!m) {
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
return pos({
|
|
1341
|
+
type: 'custom-media',
|
|
1342
|
+
name: trim(m[1]),
|
|
1343
|
+
media: trim(m[2])
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
function atpage() {
|
|
1347
|
+
var pos = position();
|
|
1348
|
+
var m = match(/^@page */);
|
|
1349
|
+
if (!m) {
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
var sel = selector() || [];
|
|
1353
|
+
if (!open()) {
|
|
1354
|
+
return error("@page missing '{'");
|
|
1355
|
+
}
|
|
1356
|
+
var decls = comments();
|
|
1357
|
+
var decl;
|
|
1358
|
+
while ((decl = declaration())) {
|
|
1359
|
+
decls.push(decl);
|
|
1360
|
+
decls = decls.concat(comments());
|
|
1361
|
+
}
|
|
1362
|
+
if (!close()) {
|
|
1363
|
+
return error("@page missing '}'");
|
|
1364
|
+
}
|
|
1365
|
+
return pos({
|
|
1366
|
+
type: 'page',
|
|
1367
|
+
selectors: sel,
|
|
1368
|
+
declarations: decls
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
function atdocument() {
|
|
1372
|
+
var pos = position();
|
|
1373
|
+
var m = match(/^@([-\w]+)?document *([^{]+)/);
|
|
1374
|
+
if (!m) {
|
|
1375
|
+
return;
|
|
1376
|
+
}
|
|
1377
|
+
var vendor = trim(m[1]);
|
|
1378
|
+
var doc = trim(m[2]);
|
|
1379
|
+
if (!open()) {
|
|
1380
|
+
return error("@document missing '{'");
|
|
1381
|
+
}
|
|
1382
|
+
var style = comments().concat(rules());
|
|
1383
|
+
if (!close()) {
|
|
1384
|
+
return error("@document missing '}'");
|
|
1385
|
+
}
|
|
1386
|
+
return pos({
|
|
1387
|
+
type: 'document',
|
|
1388
|
+
document: doc,
|
|
1389
|
+
vendor: vendor,
|
|
1390
|
+
rules: style
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
function atfontface() {
|
|
1394
|
+
var pos = position();
|
|
1395
|
+
var m = match(/^@font-face\s*/);
|
|
1396
|
+
if (!m) {
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
if (!open()) {
|
|
1400
|
+
return error("@font-face missing '{'");
|
|
1401
|
+
}
|
|
1402
|
+
var decls = comments();
|
|
1403
|
+
var decl;
|
|
1404
|
+
while ((decl = declaration())) {
|
|
1405
|
+
decls.push(decl);
|
|
1406
|
+
decls = decls.concat(comments());
|
|
1407
|
+
}
|
|
1408
|
+
if (!close()) {
|
|
1409
|
+
return error("@font-face missing '}'");
|
|
1410
|
+
}
|
|
1411
|
+
return pos({
|
|
1412
|
+
type: 'font-face',
|
|
1413
|
+
declarations: decls
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
var atimport = _compileAtrule('import');
|
|
1417
|
+
var atcharset = _compileAtrule('charset');
|
|
1418
|
+
var atnamespace = _compileAtrule('namespace');
|
|
1419
|
+
function _compileAtrule(name) {
|
|
1420
|
+
var re = new RegExp('^@' + name + '\\s*([^;]+);');
|
|
1421
|
+
return function () {
|
|
1422
|
+
var pos = position();
|
|
1423
|
+
var m = match(re);
|
|
1424
|
+
if (!m) {
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
var ret = { type: name };
|
|
1428
|
+
ret[name] = m[1].trim();
|
|
1429
|
+
return pos(ret);
|
|
1430
|
+
};
|
|
1431
|
+
}
|
|
1432
|
+
function atrule() {
|
|
1433
|
+
if (css[0] !== '@') {
|
|
1434
|
+
return;
|
|
1435
|
+
}
|
|
1436
|
+
return (atkeyframes() ||
|
|
1437
|
+
atmedia() ||
|
|
1438
|
+
atcustommedia() ||
|
|
1439
|
+
atsupports() ||
|
|
1440
|
+
atimport() ||
|
|
1441
|
+
atcharset() ||
|
|
1442
|
+
atnamespace() ||
|
|
1443
|
+
atdocument() ||
|
|
1444
|
+
atpage() ||
|
|
1445
|
+
athost() ||
|
|
1446
|
+
atfontface());
|
|
1447
|
+
}
|
|
1448
|
+
function rule() {
|
|
1449
|
+
var pos = position();
|
|
1450
|
+
var sel = selector();
|
|
1451
|
+
if (!sel) {
|
|
1452
|
+
return error('selector missing');
|
|
1453
|
+
}
|
|
1454
|
+
comments();
|
|
1455
|
+
return pos({
|
|
1456
|
+
type: 'rule',
|
|
1457
|
+
selectors: sel,
|
|
1458
|
+
declarations: declarations()
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1461
|
+
return addParent(stylesheet());
|
|
1462
|
+
}
|
|
1463
|
+
function trim(str) {
|
|
1464
|
+
return str ? str.replace(/^\s+|\s+$/g, '') : '';
|
|
1465
|
+
}
|
|
1466
|
+
function addParent(obj, parent) {
|
|
1467
|
+
var isNode = obj && typeof obj.type === 'string';
|
|
1468
|
+
var childParent = isNode ? obj : parent;
|
|
1469
|
+
for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {
|
|
1470
|
+
var k = _a[_i];
|
|
1471
|
+
var value = obj[k];
|
|
1472
|
+
if (Array.isArray(value)) {
|
|
1473
|
+
value.forEach(function (v) {
|
|
1474
|
+
addParent(v, childParent);
|
|
1475
|
+
});
|
|
1476
|
+
}
|
|
1477
|
+
else if (value && typeof value === 'object') {
|
|
1478
|
+
addParent(value, childParent);
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
if (isNode) {
|
|
1482
|
+
Object.defineProperty(obj, 'parent', {
|
|
1483
|
+
configurable: true,
|
|
1484
|
+
writable: true,
|
|
1485
|
+
enumerable: false,
|
|
1486
|
+
value: parent || null
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
return obj;
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
var tagMap = {
|
|
1493
|
+
script: 'noscript',
|
|
1494
|
+
altglyph: 'altGlyph',
|
|
1495
|
+
altglyphdef: 'altGlyphDef',
|
|
1496
|
+
altglyphitem: 'altGlyphItem',
|
|
1497
|
+
animatecolor: 'animateColor',
|
|
1498
|
+
animatemotion: 'animateMotion',
|
|
1499
|
+
animatetransform: 'animateTransform',
|
|
1500
|
+
clippath: 'clipPath',
|
|
1501
|
+
feblend: 'feBlend',
|
|
1502
|
+
fecolormatrix: 'feColorMatrix',
|
|
1503
|
+
fecomponenttransfer: 'feComponentTransfer',
|
|
1504
|
+
fecomposite: 'feComposite',
|
|
1505
|
+
feconvolvematrix: 'feConvolveMatrix',
|
|
1506
|
+
fediffuselighting: 'feDiffuseLighting',
|
|
1507
|
+
fedisplacementmap: 'feDisplacementMap',
|
|
1508
|
+
fedistantlight: 'feDistantLight',
|
|
1509
|
+
fedropshadow: 'feDropShadow',
|
|
1510
|
+
feflood: 'feFlood',
|
|
1511
|
+
fefunca: 'feFuncA',
|
|
1512
|
+
fefuncb: 'feFuncB',
|
|
1513
|
+
fefuncg: 'feFuncG',
|
|
1514
|
+
fefuncr: 'feFuncR',
|
|
1515
|
+
fegaussianblur: 'feGaussianBlur',
|
|
1516
|
+
feimage: 'feImage',
|
|
1517
|
+
femerge: 'feMerge',
|
|
1518
|
+
femergenode: 'feMergeNode',
|
|
1519
|
+
femorphology: 'feMorphology',
|
|
1520
|
+
feoffset: 'feOffset',
|
|
1521
|
+
fepointlight: 'fePointLight',
|
|
1522
|
+
fespecularlighting: 'feSpecularLighting',
|
|
1523
|
+
fespotlight: 'feSpotLight',
|
|
1524
|
+
fetile: 'feTile',
|
|
1525
|
+
feturbulence: 'feTurbulence',
|
|
1526
|
+
foreignobject: 'foreignObject',
|
|
1527
|
+
glyphref: 'glyphRef',
|
|
1528
|
+
lineargradient: 'linearGradient',
|
|
1529
|
+
radialgradient: 'radialGradient'
|
|
1530
|
+
};
|
|
1531
|
+
function getTagName(n) {
|
|
1532
|
+
var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;
|
|
1533
|
+
if (tagName === 'link' && n.attributes._cssText) {
|
|
1534
|
+
tagName = 'style';
|
|
1535
|
+
}
|
|
1536
|
+
return tagName;
|
|
1537
|
+
}
|
|
1538
|
+
function escapeRegExp(str) {
|
|
1539
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1540
|
+
}
|
|
1541
|
+
var HOVER_SELECTOR = /([^\\]):hover/;
|
|
1542
|
+
var HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');
|
|
1543
|
+
function addHoverClass(cssText, cache) {
|
|
1544
|
+
var _a;
|
|
1545
|
+
if (!((_a = window === null || window === void 0 ? void 0 : window.HIG_CONFIGURATION) === null || _a === void 0 ? void 0 : _a.enableOnHoverClass)) {
|
|
1546
|
+
return cssText;
|
|
1547
|
+
}
|
|
1548
|
+
var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);
|
|
1549
|
+
if (cachedStyle)
|
|
1550
|
+
return cachedStyle;
|
|
1551
|
+
var ast = parse(cssText, {
|
|
1552
|
+
silent: true
|
|
1553
|
+
});
|
|
1554
|
+
if (!ast.stylesheet) {
|
|
1555
|
+
return cssText;
|
|
1556
|
+
}
|
|
1557
|
+
var selectors = [];
|
|
1558
|
+
ast.stylesheet.rules.forEach(function (rule) {
|
|
1559
|
+
if ('selectors' in rule) {
|
|
1560
|
+
(rule.selectors || []).forEach(function (selector) {
|
|
1561
|
+
if (HOVER_SELECTOR.test(selector)) {
|
|
1562
|
+
selectors.push(selector);
|
|
1563
|
+
}
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
});
|
|
1567
|
+
if (selectors.length === 0) {
|
|
1568
|
+
return cssText;
|
|
1569
|
+
}
|
|
1570
|
+
var selectorMatcher = new RegExp(selectors
|
|
1571
|
+
.filter(function (selector, index) { return selectors.indexOf(selector) === index; })
|
|
1572
|
+
.sort(function (a, b) { return b.length - a.length; })
|
|
1573
|
+
.map(function (selector) {
|
|
1574
|
+
return escapeRegExp(selector);
|
|
1575
|
+
})
|
|
1576
|
+
.join('|'), 'g');
|
|
1577
|
+
var result = cssText.replace(selectorMatcher, function (selector) {
|
|
1578
|
+
var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\:hover');
|
|
1579
|
+
return "".concat(selector, ", ").concat(newSelector);
|
|
1580
|
+
});
|
|
1581
|
+
cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);
|
|
1582
|
+
return result;
|
|
1583
|
+
}
|
|
1584
|
+
function createCache() {
|
|
1585
|
+
var stylesWithHoverClass = new Map();
|
|
1586
|
+
return {
|
|
1587
|
+
stylesWithHoverClass: stylesWithHoverClass
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
function buildNode(n, options) {
|
|
1591
|
+
var doc = options.doc, hackCss = options.hackCss, cache = options.cache;
|
|
1592
|
+
switch (n.type) {
|
|
1593
|
+
case NodeType$2.Document:
|
|
1594
|
+
return doc.implementation.createDocument(null, '', null);
|
|
1595
|
+
case NodeType$2.DocumentType:
|
|
1596
|
+
return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);
|
|
1597
|
+
case NodeType$2.Element:
|
|
1598
|
+
var tagName = getTagName(n);
|
|
1599
|
+
var node_1;
|
|
1600
|
+
if (n.isSVG) {
|
|
1601
|
+
node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);
|
|
1602
|
+
}
|
|
1603
|
+
else {
|
|
1604
|
+
node_1 = doc.createElement(tagName);
|
|
1605
|
+
}
|
|
1606
|
+
var _loop_1 = function (name_1) {
|
|
1607
|
+
if (!n.attributes.hasOwnProperty(name_1)) {
|
|
1608
|
+
return "continue";
|
|
1609
|
+
}
|
|
1610
|
+
var value = n.attributes[name_1];
|
|
1611
|
+
if (tagName === 'option' && name_1 === 'selected' && value === false) {
|
|
1612
|
+
return "continue";
|
|
1613
|
+
}
|
|
1614
|
+
value =
|
|
1615
|
+
typeof value === 'boolean' || typeof value === 'number' ? '' : value;
|
|
1616
|
+
if (!name_1.startsWith('rr_')) {
|
|
1617
|
+
var isTextarea = tagName === 'textarea' && name_1 === 'value';
|
|
1618
|
+
var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';
|
|
1619
|
+
if (isRemoteOrDynamicCss && hackCss) {
|
|
1620
|
+
value = addHoverClass(value, cache);
|
|
1621
|
+
if (typeof value === 'string') {
|
|
1622
|
+
var regex = /url\(\"https:\/\/\S*(.eot|.woff2|.ttf|.woff)\S*\"\)/gm;
|
|
1623
|
+
var m = void 0;
|
|
1624
|
+
var fontUrls_1 = [];
|
|
1625
|
+
var PROXY_URL_1 = 'https://replay-cors-proxy.highlightrun.workers.dev';
|
|
1626
|
+
while ((m = regex.exec(value)) !== null) {
|
|
1627
|
+
if (m.index === regex.lastIndex) {
|
|
1628
|
+
regex.lastIndex++;
|
|
1629
|
+
}
|
|
1630
|
+
m.forEach(function (match, groupIndex) {
|
|
1631
|
+
if (groupIndex === 0) {
|
|
1632
|
+
var url = match.slice(5, match.length - 2);
|
|
1633
|
+
fontUrls_1.push({
|
|
1634
|
+
originalUrl: url,
|
|
1635
|
+
proxyUrl: url.replace(url, "".concat(PROXY_URL_1, "?url=").concat(url))
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
});
|
|
1639
|
+
}
|
|
1640
|
+
fontUrls_1.forEach(function (urlPair) {
|
|
1641
|
+
value = value.replace(urlPair.originalUrl, urlPair.proxyUrl);
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
if (isTextarea || isRemoteOrDynamicCss) {
|
|
1646
|
+
var child = doc.createTextNode(value);
|
|
1647
|
+
for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {
|
|
1648
|
+
var c = _a[_i];
|
|
1649
|
+
if (c.nodeType === node_1.TEXT_NODE) {
|
|
1650
|
+
node_1.removeChild(c);
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
node_1.appendChild(child);
|
|
1654
|
+
return "continue";
|
|
1655
|
+
}
|
|
1656
|
+
try {
|
|
1657
|
+
if (n.isSVG && name_1 === 'xlink:href') {
|
|
1658
|
+
node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);
|
|
1659
|
+
}
|
|
1660
|
+
else if (name_1 === 'onload' ||
|
|
1661
|
+
name_1 === 'onclick' ||
|
|
1662
|
+
name_1.substring(0, 7) === 'onmouse') {
|
|
1663
|
+
node_1.setAttribute('_' + name_1, value);
|
|
1664
|
+
}
|
|
1665
|
+
else if (tagName === 'meta' &&
|
|
1666
|
+
n.attributes['http-equiv'] === 'Content-Security-Policy' &&
|
|
1667
|
+
name_1 === 'content') {
|
|
1668
|
+
node_1.setAttribute('csp-content', value);
|
|
1669
|
+
return "continue";
|
|
1670
|
+
}
|
|
1671
|
+
else if (tagName === 'link' &&
|
|
1672
|
+
n.attributes.rel === 'preload' &&
|
|
1673
|
+
n.attributes.as === 'script') {
|
|
1674
|
+
}
|
|
1675
|
+
else if (tagName === 'link' &&
|
|
1676
|
+
n.attributes.rel === 'prefetch' &&
|
|
1677
|
+
typeof n.attributes.href === 'string' &&
|
|
1678
|
+
n.attributes.href.endsWith('.js')) {
|
|
1679
|
+
}
|
|
1680
|
+
else if (tagName === 'img' &&
|
|
1681
|
+
n.attributes.srcset &&
|
|
1682
|
+
n.attributes.rr_dataURL) {
|
|
1683
|
+
node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);
|
|
1684
|
+
}
|
|
1685
|
+
else {
|
|
1686
|
+
node_1.setAttribute(name_1, value);
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
catch (error) {
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
else {
|
|
1693
|
+
if (tagName === 'canvas' && name_1 === 'rr_dataURL') {
|
|
1694
|
+
var image_1 = document.createElement('img');
|
|
1695
|
+
image_1.src = value;
|
|
1696
|
+
image_1.onload = function () {
|
|
1697
|
+
var ctx = node_1.getContext('2d');
|
|
1698
|
+
if (ctx) {
|
|
1699
|
+
ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);
|
|
1700
|
+
}
|
|
1701
|
+
};
|
|
1702
|
+
}
|
|
1703
|
+
else if (tagName === 'img' && name_1 === 'rr_dataURL') {
|
|
1704
|
+
var image = node_1;
|
|
1705
|
+
if (!image.currentSrc.startsWith('data:')) {
|
|
1706
|
+
image.setAttribute('rrweb-original-src', n.attributes.src);
|
|
1707
|
+
image.src = value;
|
|
1708
|
+
image.setAttribute('rrweb-inline-src', value);
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
if (name_1 === 'rr_width') {
|
|
1712
|
+
node_1.style.width = value;
|
|
1713
|
+
}
|
|
1714
|
+
else if (name_1 === 'rr_height') {
|
|
1715
|
+
node_1.style.height = value;
|
|
1716
|
+
}
|
|
1717
|
+
else if (name_1 === 'rr_mediaCurrentTime') {
|
|
1718
|
+
node_1.currentTime = n.attributes
|
|
1719
|
+
.rr_mediaCurrentTime;
|
|
1720
|
+
}
|
|
1721
|
+
else if (name_1 === 'rr_mediaState') {
|
|
1722
|
+
switch (value) {
|
|
1723
|
+
case 'played':
|
|
1724
|
+
node_1
|
|
1725
|
+
.play()["catch"](function (e) { return console.warn('media playback error', e); });
|
|
1726
|
+
break;
|
|
1727
|
+
case 'paused':
|
|
1728
|
+
node_1.pause();
|
|
1729
|
+
break;
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
};
|
|
1734
|
+
for (var name_1 in n.attributes) {
|
|
1735
|
+
_loop_1(name_1);
|
|
1736
|
+
}
|
|
1737
|
+
if (tagName === 'img') {
|
|
1738
|
+
var image = node_1;
|
|
1739
|
+
if (!image.currentSrc.startsWith('data:')) {
|
|
1740
|
+
var inlineSrc = image.getAttribute('rrweb-inline-src');
|
|
1741
|
+
if (inlineSrc === null || inlineSrc === void 0 ? void 0 : inlineSrc.startsWith('data:')) {
|
|
1742
|
+
image.src = inlineSrc;
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
if (n.isShadowHost) {
|
|
1747
|
+
if (!node_1.shadowRoot) {
|
|
1748
|
+
node_1.attachShadow({ mode: 'open' });
|
|
1749
|
+
}
|
|
1750
|
+
else {
|
|
1751
|
+
while (node_1.shadowRoot.firstChild) {
|
|
1752
|
+
node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
return node_1;
|
|
1757
|
+
case NodeType$2.Text:
|
|
1758
|
+
return doc.createTextNode(n.isStyle && hackCss
|
|
1759
|
+
? addHoverClass(n.textContent, cache)
|
|
1760
|
+
: n.textContent);
|
|
1761
|
+
case NodeType$2.CDATA:
|
|
1762
|
+
return doc.createCDATASection(n.textContent);
|
|
1763
|
+
case NodeType$2.Comment:
|
|
1764
|
+
return doc.createComment(n.textContent);
|
|
1765
|
+
default:
|
|
1766
|
+
return null;
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
function buildNodeWithSN(n, options) {
|
|
1770
|
+
var doc = options.doc, mirror = options.mirror, _a = options.skipChild, skipChild = _a === void 0 ? false : _a, _b = options.hackCss, hackCss = _b === void 0 ? true : _b, afterAppend = options.afterAppend, cache = options.cache;
|
|
1771
|
+
var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });
|
|
1772
|
+
if (!node) {
|
|
1773
|
+
return null;
|
|
1774
|
+
}
|
|
1775
|
+
if (n.rootId) {
|
|
1776
|
+
console.assert(mirror.getNode(n.rootId) === doc, 'Target document should have the same root id.');
|
|
1777
|
+
}
|
|
1778
|
+
if (n.type === NodeType$2.Document) {
|
|
1779
|
+
doc.close();
|
|
1780
|
+
doc.open();
|
|
1781
|
+
if (n.compatMode === 'BackCompat' &&
|
|
1782
|
+
n.childNodes &&
|
|
1783
|
+
n.childNodes[0].type !== NodeType$2.DocumentType) {
|
|
1784
|
+
if (n.childNodes[0].type === NodeType$2.Element &&
|
|
1785
|
+
'xmlns' in n.childNodes[0].attributes &&
|
|
1786
|
+
n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {
|
|
1787
|
+
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">');
|
|
1788
|
+
}
|
|
1789
|
+
else {
|
|
1790
|
+
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">');
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
node = doc;
|
|
1794
|
+
}
|
|
1795
|
+
mirror.add(node, n);
|
|
1796
|
+
if ((n.type === NodeType$2.Document || n.type === NodeType$2.Element) &&
|
|
1797
|
+
!skipChild) {
|
|
1798
|
+
for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {
|
|
1799
|
+
var childN = _c[_i];
|
|
1800
|
+
var childNode = buildNodeWithSN(childN, {
|
|
1801
|
+
doc: doc,
|
|
1802
|
+
mirror: mirror,
|
|
1803
|
+
skipChild: false,
|
|
1804
|
+
hackCss: hackCss,
|
|
1805
|
+
afterAppend: afterAppend,
|
|
1806
|
+
cache: cache
|
|
1807
|
+
});
|
|
1808
|
+
if (!childNode) {
|
|
1809
|
+
console.warn('Failed to rebuild', childN);
|
|
1810
|
+
continue;
|
|
1811
|
+
}
|
|
1812
|
+
if (childN.isShadow && isElement(node) && node.shadowRoot) {
|
|
1813
|
+
node.shadowRoot.appendChild(childNode);
|
|
1814
|
+
}
|
|
1815
|
+
else {
|
|
1816
|
+
node.appendChild(childNode);
|
|
1817
|
+
}
|
|
1818
|
+
if (afterAppend) {
|
|
1819
|
+
afterAppend(childNode);
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
return node;
|
|
1824
|
+
}
|
|
1825
|
+
function visit(mirror, onVisit) {
|
|
1826
|
+
function walk(node) {
|
|
1827
|
+
onVisit(node);
|
|
1828
|
+
}
|
|
1829
|
+
for (var _i = 0, _a = mirror.getIds(); _i < _a.length; _i++) {
|
|
1830
|
+
var id = _a[_i];
|
|
1831
|
+
if (mirror.has(id)) {
|
|
1832
|
+
walk(mirror.getNode(id));
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
function handleScroll(node, mirror) {
|
|
1837
|
+
var n = mirror.getMeta(node);
|
|
1838
|
+
if ((n === null || n === void 0 ? void 0 : n.type) !== NodeType$2.Element) {
|
|
1839
|
+
return;
|
|
1840
|
+
}
|
|
1841
|
+
var el = node;
|
|
1842
|
+
for (var name_2 in n.attributes) {
|
|
1843
|
+
if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {
|
|
1844
|
+
continue;
|
|
1845
|
+
}
|
|
1846
|
+
var value = n.attributes[name_2];
|
|
1847
|
+
if (name_2 === 'rr_scrollLeft') {
|
|
1848
|
+
el.scrollLeft = value;
|
|
1849
|
+
}
|
|
1850
|
+
if (name_2 === 'rr_scrollTop') {
|
|
1851
|
+
el.scrollTop = value;
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
function rebuild(n, options) {
|
|
1856
|
+
var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache, _b = options.mirror, mirror = _b === void 0 ? new Mirror$2() : _b;
|
|
1857
|
+
var node = buildNodeWithSN(n, {
|
|
1858
|
+
doc: doc,
|
|
1859
|
+
mirror: mirror,
|
|
1860
|
+
skipChild: false,
|
|
1861
|
+
hackCss: hackCss,
|
|
1862
|
+
afterAppend: afterAppend,
|
|
1863
|
+
cache: cache
|
|
1864
|
+
});
|
|
1865
|
+
visit(mirror, function (visitedNode) {
|
|
1866
|
+
if (onVisit) {
|
|
1867
|
+
onVisit(visitedNode);
|
|
1868
|
+
}
|
|
1869
|
+
handleScroll(visitedNode, mirror);
|
|
1870
|
+
});
|
|
1871
|
+
return node;
|
|
1872
|
+
}
|
|
6
1873
|
|
|
7
1874
|
function on(type, fn, target = document) {
|
|
8
1875
|
const options = { capture: true, passive: true };
|
|
@@ -151,7 +2018,7 @@ function isBlocked(node, blockClass, checkAncestors) {
|
|
|
151
2018
|
return true;
|
|
152
2019
|
}
|
|
153
2020
|
else {
|
|
154
|
-
if (
|
|
2021
|
+
if (classMatchesRegex(el, blockClass, checkAncestors))
|
|
155
2022
|
return true;
|
|
156
2023
|
}
|
|
157
2024
|
return false;
|
|
@@ -160,10 +2027,10 @@ function isSerialized(n, mirror) {
|
|
|
160
2027
|
return mirror.getId(n) !== -1;
|
|
161
2028
|
}
|
|
162
2029
|
function isIgnored(n, mirror) {
|
|
163
|
-
return mirror.getId(n) ===
|
|
2030
|
+
return mirror.getId(n) === IGNORED_NODE;
|
|
164
2031
|
}
|
|
165
2032
|
function isAncestorRemoved(target, mirror) {
|
|
166
|
-
if (
|
|
2033
|
+
if (isShadowRoot(target)) {
|
|
167
2034
|
return false;
|
|
168
2035
|
}
|
|
169
2036
|
const id = mirror.getId(target);
|
|
@@ -310,30 +2177,30 @@ function uniqueTextMutations(mutations) {
|
|
|
310
2177
|
}
|
|
311
2178
|
|
|
312
2179
|
var utils = /*#__PURE__*/Object.freeze({
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
2180
|
+
__proto__: null,
|
|
2181
|
+
on: on,
|
|
2182
|
+
get _mirror () { return exports.mirror; },
|
|
2183
|
+
throttle: throttle,
|
|
2184
|
+
hookSetter: hookSetter,
|
|
2185
|
+
patch: patch,
|
|
2186
|
+
getWindowHeight: getWindowHeight,
|
|
2187
|
+
getWindowWidth: getWindowWidth,
|
|
2188
|
+
isCanvasNode: isCanvasNode,
|
|
2189
|
+
isBlocked: isBlocked,
|
|
2190
|
+
isSerialized: isSerialized,
|
|
2191
|
+
isIgnored: isIgnored,
|
|
2192
|
+
isAncestorRemoved: isAncestorRemoved,
|
|
2193
|
+
isTouchEvent: isTouchEvent,
|
|
2194
|
+
polyfill: polyfill$1,
|
|
2195
|
+
queueToResolveTrees: queueToResolveTrees,
|
|
2196
|
+
iterateResolveTree: iterateResolveTree,
|
|
2197
|
+
isSerializedIframe: isSerializedIframe,
|
|
2198
|
+
isSerializedStylesheet: isSerializedStylesheet,
|
|
2199
|
+
getBaseDimension: getBaseDimension,
|
|
2200
|
+
hasShadowRoot: hasShadowRoot,
|
|
2201
|
+
getNestedRule: getNestedRule$1,
|
|
2202
|
+
getPositionsAndIndex: getPositionsAndIndex$1,
|
|
2203
|
+
uniqueTextMutations: uniqueTextMutations
|
|
337
2204
|
});
|
|
338
2205
|
|
|
339
2206
|
exports.EventType = void 0;
|
|
@@ -512,8 +2379,8 @@ class MutationBuffer {
|
|
|
512
2379
|
const addList = new DoubleLinkedList();
|
|
513
2380
|
const getNextId = (n) => {
|
|
514
2381
|
let ns = n;
|
|
515
|
-
let nextId =
|
|
516
|
-
while (nextId ===
|
|
2382
|
+
let nextId = IGNORED_NODE;
|
|
2383
|
+
while (nextId === IGNORED_NODE) {
|
|
517
2384
|
ns = ns && ns.nextSibling;
|
|
518
2385
|
nextId = ns && this.mirror.getId(ns);
|
|
519
2386
|
}
|
|
@@ -534,14 +2401,14 @@ class MutationBuffer {
|
|
|
534
2401
|
if (!n.parentNode || notInDoc) {
|
|
535
2402
|
return;
|
|
536
2403
|
}
|
|
537
|
-
const parentId =
|
|
2404
|
+
const parentId = isShadowRoot(n.parentNode)
|
|
538
2405
|
? this.mirror.getId(shadowHost)
|
|
539
2406
|
: this.mirror.getId(n.parentNode);
|
|
540
2407
|
const nextId = getNextId(n);
|
|
541
2408
|
if (parentId === -1 || nextId === -1) {
|
|
542
2409
|
return addList.addNode(n);
|
|
543
2410
|
}
|
|
544
|
-
const sn =
|
|
2411
|
+
const sn = serializeNodeWithId(n, {
|
|
545
2412
|
doc: this.doc,
|
|
546
2413
|
mirror: this.mirror,
|
|
547
2414
|
blockClass: this.blockClass,
|
|
@@ -645,7 +2512,7 @@ class MutationBuffer {
|
|
|
645
2512
|
.map((text) => {
|
|
646
2513
|
let value = text.value;
|
|
647
2514
|
if (this.enableStrictPrivacy && value) {
|
|
648
|
-
value =
|
|
2515
|
+
value = obfuscateText(value);
|
|
649
2516
|
}
|
|
650
2517
|
return {
|
|
651
2518
|
id: this.mirror.getId(text.node),
|
|
@@ -687,7 +2554,7 @@ class MutationBuffer {
|
|
|
687
2554
|
if (!isBlocked(m.target, this.blockClass, false) &&
|
|
688
2555
|
value !== m.oldValue) {
|
|
689
2556
|
this.texts.push({
|
|
690
|
-
value:
|
|
2557
|
+
value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector) && value
|
|
691
2558
|
? this.maskTextFn
|
|
692
2559
|
? this.maskTextFn(value)
|
|
693
2560
|
: value.replace(/[\S]/g, '*')
|
|
@@ -701,7 +2568,7 @@ class MutationBuffer {
|
|
|
701
2568
|
const target = m.target;
|
|
702
2569
|
let value = m.target.getAttribute(m.attributeName);
|
|
703
2570
|
if (m.attributeName === 'value') {
|
|
704
|
-
value =
|
|
2571
|
+
value = maskInputValue({
|
|
705
2572
|
maskInputOptions: this.maskInputOptions,
|
|
706
2573
|
tagName: m.target.tagName,
|
|
707
2574
|
type: m.target.getAttribute('type'),
|
|
@@ -714,6 +2581,16 @@ class MutationBuffer {
|
|
|
714
2581
|
return;
|
|
715
2582
|
}
|
|
716
2583
|
let item = this.attributes.find((a) => a.node === m.target);
|
|
2584
|
+
if (target.tagName === 'IFRAME' &&
|
|
2585
|
+
m.attributeName === 'src' &&
|
|
2586
|
+
!this.keepIframeSrcFn(value)) {
|
|
2587
|
+
if (!target.contentDocument) {
|
|
2588
|
+
m.attributeName = 'rr_src';
|
|
2589
|
+
}
|
|
2590
|
+
else {
|
|
2591
|
+
return;
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
717
2594
|
if (!item) {
|
|
718
2595
|
item = {
|
|
719
2596
|
node: m.target,
|
|
@@ -759,7 +2636,7 @@ class MutationBuffer {
|
|
|
759
2636
|
break;
|
|
760
2637
|
}
|
|
761
2638
|
}
|
|
762
|
-
item.attributes[m.attributeName] =
|
|
2639
|
+
item.attributes[m.attributeName] = transformAttribute(this.doc, target.tagName, m.attributeName, value);
|
|
763
2640
|
}
|
|
764
2641
|
break;
|
|
765
2642
|
}
|
|
@@ -769,7 +2646,7 @@ class MutationBuffer {
|
|
|
769
2646
|
m.addedNodes.forEach((n) => this.genAdds(n, m.target));
|
|
770
2647
|
m.removedNodes.forEach((n) => {
|
|
771
2648
|
const nodeId = this.mirror.getId(n);
|
|
772
|
-
const parentId =
|
|
2649
|
+
const parentId = isShadowRoot(m.target)
|
|
773
2650
|
? this.mirror.getId(m.target.host)
|
|
774
2651
|
: this.mirror.getId(m.target);
|
|
775
2652
|
if (isBlocked(m.target, this.blockClass, false) ||
|
|
@@ -791,7 +2668,7 @@ class MutationBuffer {
|
|
|
791
2668
|
this.removes.push({
|
|
792
2669
|
parentId,
|
|
793
2670
|
id: nodeId,
|
|
794
|
-
isShadow:
|
|
2671
|
+
isShadow: isShadowRoot(m.target) ? true : undefined,
|
|
795
2672
|
});
|
|
796
2673
|
}
|
|
797
2674
|
this.mapRemoves.push(n);
|
|
@@ -833,6 +2710,7 @@ class MutationBuffer {
|
|
|
833
2710
|
'maskInputOptions',
|
|
834
2711
|
'maskTextFn',
|
|
835
2712
|
'maskInputFn',
|
|
2713
|
+
'keepIframeSrcFn',
|
|
836
2714
|
'recordCanvas',
|
|
837
2715
|
'inlineImages',
|
|
838
2716
|
'slimDOMOptions',
|
|
@@ -1120,7 +2998,7 @@ function initInputObserver({ inputCb, doc, mirror, blockClass, ignoreClass, mask
|
|
|
1120
2998
|
}
|
|
1121
2999
|
else if (maskInputOptions[target.tagName.toLowerCase()] ||
|
|
1122
3000
|
maskInputOptions[type]) {
|
|
1123
|
-
text =
|
|
3001
|
+
text = maskInputValue({
|
|
1124
3002
|
maskInputOptions,
|
|
1125
3003
|
tagName: target.tagName,
|
|
1126
3004
|
type,
|
|
@@ -2156,7 +4034,7 @@ function wrapEvent(e) {
|
|
|
2156
4034
|
}
|
|
2157
4035
|
let wrappedEmit;
|
|
2158
4036
|
let takeFullSnapshot;
|
|
2159
|
-
const mirror =
|
|
4037
|
+
const mirror = createMirror$2();
|
|
2160
4038
|
function record(options = {}) {
|
|
2161
4039
|
const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = 'highlight-block', blockSelector = null, ignoreClass = 'highlight-ignore', maskTextClass = 'highlight-mask', maskTextSelector = null, inlineStylesheet = true, maskAllInputs, maskInputOptions: _maskInputOptions, slimDOMOptions: _slimDOMOptions, maskInputFn, maskTextFn, hooks, packFn, sampling = {}, mousemoveWait, recordCanvas = false, userTriggeredOnInput = false, collectFonts = false, inlineImages = false, plugins, keepIframeSrcFn = () => false, enableStrictPrivacy = false, } = options;
|
|
2162
4040
|
if (!emit) {
|
|
@@ -2292,6 +4170,7 @@ function record(options = {}) {
|
|
|
2292
4170
|
iframeManager,
|
|
2293
4171
|
stylesheetManager,
|
|
2294
4172
|
canvasManager,
|
|
4173
|
+
keepIframeSrcFn,
|
|
2295
4174
|
enableStrictPrivacy
|
|
2296
4175
|
},
|
|
2297
4176
|
mirror,
|
|
@@ -2307,7 +4186,7 @@ function record(options = {}) {
|
|
|
2307
4186
|
},
|
|
2308
4187
|
}), isCheckout);
|
|
2309
4188
|
mutationBuffers.forEach((buf) => buf.lock());
|
|
2310
|
-
const node =
|
|
4189
|
+
const node = snapshot(document, {
|
|
2311
4190
|
mirror,
|
|
2312
4191
|
blockClass,
|
|
2313
4192
|
blockSelector,
|
|
@@ -2428,6 +4307,7 @@ function record(options = {}) {
|
|
|
2428
4307
|
doc,
|
|
2429
4308
|
maskInputFn,
|
|
2430
4309
|
maskTextFn,
|
|
4310
|
+
keepIframeSrcFn,
|
|
2431
4311
|
blockSelector,
|
|
2432
4312
|
slimDOMOptions,
|
|
2433
4313
|
mirror,
|
|
@@ -2500,6 +4380,70 @@ record.takeFullSnapshot = (isCheckout) => {
|
|
|
2500
4380
|
};
|
|
2501
4381
|
record.mirror = mirror;
|
|
2502
4382
|
|
|
4383
|
+
var NodeType$1;
|
|
4384
|
+
(function (NodeType) {
|
|
4385
|
+
NodeType[NodeType["Document"] = 0] = "Document";
|
|
4386
|
+
NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
|
|
4387
|
+
NodeType[NodeType["Element"] = 2] = "Element";
|
|
4388
|
+
NodeType[NodeType["Text"] = 3] = "Text";
|
|
4389
|
+
NodeType[NodeType["CDATA"] = 4] = "CDATA";
|
|
4390
|
+
NodeType[NodeType["Comment"] = 5] = "Comment";
|
|
4391
|
+
})(NodeType$1 || (NodeType$1 = {}));
|
|
4392
|
+
var Mirror$1 = (function () {
|
|
4393
|
+
function Mirror() {
|
|
4394
|
+
this.idNodeMap = new Map();
|
|
4395
|
+
this.nodeMetaMap = new WeakMap();
|
|
4396
|
+
}
|
|
4397
|
+
Mirror.prototype.getId = function (n) {
|
|
4398
|
+
var _a;
|
|
4399
|
+
if (!n)
|
|
4400
|
+
return -1;
|
|
4401
|
+
var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
|
|
4402
|
+
return id !== null && id !== void 0 ? id : -1;
|
|
4403
|
+
};
|
|
4404
|
+
Mirror.prototype.getNode = function (id) {
|
|
4405
|
+
return this.idNodeMap.get(id) || null;
|
|
4406
|
+
};
|
|
4407
|
+
Mirror.prototype.getIds = function () {
|
|
4408
|
+
return Array.from(this.idNodeMap.keys());
|
|
4409
|
+
};
|
|
4410
|
+
Mirror.prototype.getMeta = function (n) {
|
|
4411
|
+
return this.nodeMetaMap.get(n) || null;
|
|
4412
|
+
};
|
|
4413
|
+
Mirror.prototype.removeNodeFromMap = function (n) {
|
|
4414
|
+
var _this = this;
|
|
4415
|
+
var id = this.getId(n);
|
|
4416
|
+
this.idNodeMap["delete"](id);
|
|
4417
|
+
if (n.childNodes) {
|
|
4418
|
+
n.childNodes.forEach(function (childNode) {
|
|
4419
|
+
return _this.removeNodeFromMap(childNode);
|
|
4420
|
+
});
|
|
4421
|
+
}
|
|
4422
|
+
};
|
|
4423
|
+
Mirror.prototype.has = function (id) {
|
|
4424
|
+
return this.idNodeMap.has(id);
|
|
4425
|
+
};
|
|
4426
|
+
Mirror.prototype.hasNode = function (node) {
|
|
4427
|
+
return this.nodeMetaMap.has(node);
|
|
4428
|
+
};
|
|
4429
|
+
Mirror.prototype.add = function (n, meta) {
|
|
4430
|
+
var id = meta.id;
|
|
4431
|
+
this.idNodeMap.set(id, n);
|
|
4432
|
+
this.nodeMetaMap.set(n, meta);
|
|
4433
|
+
};
|
|
4434
|
+
Mirror.prototype.replace = function (id, n) {
|
|
4435
|
+
this.idNodeMap.set(id, n);
|
|
4436
|
+
};
|
|
4437
|
+
Mirror.prototype.reset = function () {
|
|
4438
|
+
this.idNodeMap = new Map();
|
|
4439
|
+
this.nodeMetaMap = new WeakMap();
|
|
4440
|
+
};
|
|
4441
|
+
return Mirror;
|
|
4442
|
+
}());
|
|
4443
|
+
function createMirror$1() {
|
|
4444
|
+
return new Mirror$1();
|
|
4445
|
+
}
|
|
4446
|
+
|
|
2503
4447
|
function parseCSSText(cssText) {
|
|
2504
4448
|
const res = {};
|
|
2505
4449
|
const listDelimiter = /;(?![^(]*\))/g;
|
|
@@ -2590,21 +4534,21 @@ function BaseRRDocumentImpl(RRNodeClass) {
|
|
|
2590
4534
|
this.nodeType = NodeType.DOCUMENT_NODE;
|
|
2591
4535
|
this.nodeName = '#document';
|
|
2592
4536
|
this.compatMode = 'CSS1Compat';
|
|
2593
|
-
this.RRNodeType =
|
|
4537
|
+
this.RRNodeType = NodeType$1.Document;
|
|
2594
4538
|
this.textContent = null;
|
|
2595
4539
|
}
|
|
2596
4540
|
get documentElement() {
|
|
2597
|
-
return (this.childNodes.find((node) => node.RRNodeType ===
|
|
4541
|
+
return (this.childNodes.find((node) => node.RRNodeType === NodeType$1.Element &&
|
|
2598
4542
|
node.tagName === 'HTML') || null);
|
|
2599
4543
|
}
|
|
2600
4544
|
get body() {
|
|
2601
4545
|
var _a;
|
|
2602
|
-
return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType ===
|
|
4546
|
+
return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element &&
|
|
2603
4547
|
node.tagName === 'BODY')) || null);
|
|
2604
4548
|
}
|
|
2605
4549
|
get head() {
|
|
2606
4550
|
var _a;
|
|
2607
|
-
return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType ===
|
|
4551
|
+
return (((_a = this.documentElement) === null || _a === void 0 ? void 0 : _a.childNodes.find((node) => node.RRNodeType === NodeType$1.Element &&
|
|
2608
4552
|
node.tagName === 'HEAD')) || null);
|
|
2609
4553
|
}
|
|
2610
4554
|
get implementation() {
|
|
@@ -2615,10 +4559,10 @@ function BaseRRDocumentImpl(RRNodeClass) {
|
|
|
2615
4559
|
}
|
|
2616
4560
|
appendChild(childNode) {
|
|
2617
4561
|
const nodeType = childNode.RRNodeType;
|
|
2618
|
-
if (nodeType ===
|
|
2619
|
-
nodeType ===
|
|
4562
|
+
if (nodeType === NodeType$1.Element ||
|
|
4563
|
+
nodeType === NodeType$1.DocumentType) {
|
|
2620
4564
|
if (this.childNodes.some((s) => s.RRNodeType === nodeType)) {
|
|
2621
|
-
throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType ===
|
|
4565
|
+
throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`);
|
|
2622
4566
|
}
|
|
2623
4567
|
}
|
|
2624
4568
|
childNode.parentElement = null;
|
|
@@ -2628,10 +4572,10 @@ function BaseRRDocumentImpl(RRNodeClass) {
|
|
|
2628
4572
|
}
|
|
2629
4573
|
insertBefore(newChild, refChild) {
|
|
2630
4574
|
const nodeType = newChild.RRNodeType;
|
|
2631
|
-
if (nodeType ===
|
|
2632
|
-
nodeType ===
|
|
4575
|
+
if (nodeType === NodeType$1.Element ||
|
|
4576
|
+
nodeType === NodeType$1.DocumentType) {
|
|
2633
4577
|
if (this.childNodes.some((s) => s.RRNodeType === nodeType)) {
|
|
2634
|
-
throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType ===
|
|
4578
|
+
throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${nodeType === NodeType$1.Element ? 'RRElement' : 'RRDoctype'} on RRDocument allowed.`);
|
|
2635
4579
|
}
|
|
2636
4580
|
}
|
|
2637
4581
|
if (refChild === null)
|
|
@@ -2713,7 +4657,7 @@ function BaseRRDocumentTypeImpl(RRNodeClass) {
|
|
|
2713
4657
|
constructor(qualifiedName, publicId, systemId) {
|
|
2714
4658
|
super();
|
|
2715
4659
|
this.nodeType = NodeType.DOCUMENT_TYPE_NODE;
|
|
2716
|
-
this.RRNodeType =
|
|
4660
|
+
this.RRNodeType = NodeType$1.DocumentType;
|
|
2717
4661
|
this.textContent = null;
|
|
2718
4662
|
this.name = qualifiedName;
|
|
2719
4663
|
this.publicId = publicId;
|
|
@@ -2730,7 +4674,7 @@ function BaseRRElementImpl(RRNodeClass) {
|
|
|
2730
4674
|
constructor(tagName) {
|
|
2731
4675
|
super();
|
|
2732
4676
|
this.nodeType = NodeType.ELEMENT_NODE;
|
|
2733
|
-
this.RRNodeType =
|
|
4677
|
+
this.RRNodeType = NodeType$1.Element;
|
|
2734
4678
|
this.attributes = {};
|
|
2735
4679
|
this.shadowRoot = null;
|
|
2736
4680
|
this.tagName = tagName.toUpperCase();
|
|
@@ -2857,7 +4801,7 @@ function BaseRRTextImpl(RRNodeClass) {
|
|
|
2857
4801
|
super();
|
|
2858
4802
|
this.nodeType = NodeType.TEXT_NODE;
|
|
2859
4803
|
this.nodeName = '#text';
|
|
2860
|
-
this.RRNodeType =
|
|
4804
|
+
this.RRNodeType = NodeType$1.Text;
|
|
2861
4805
|
this.data = data;
|
|
2862
4806
|
}
|
|
2863
4807
|
get textContent() {
|
|
@@ -2877,7 +4821,7 @@ function BaseRRCommentImpl(RRNodeClass) {
|
|
|
2877
4821
|
super();
|
|
2878
4822
|
this.nodeType = NodeType.COMMENT_NODE;
|
|
2879
4823
|
this.nodeName = '#comment';
|
|
2880
|
-
this.RRNodeType =
|
|
4824
|
+
this.RRNodeType = NodeType$1.Comment;
|
|
2881
4825
|
this.data = data;
|
|
2882
4826
|
}
|
|
2883
4827
|
get textContent() {
|
|
@@ -2897,7 +4841,7 @@ function BaseRRCDATASectionImpl(RRNodeClass) {
|
|
|
2897
4841
|
super();
|
|
2898
4842
|
this.nodeName = '#cdata-section';
|
|
2899
4843
|
this.nodeType = NodeType.CDATA_SECTION_NODE;
|
|
2900
|
-
this.RRNodeType =
|
|
4844
|
+
this.RRNodeType = NodeType$1.CDATA;
|
|
2901
4845
|
this.data = data;
|
|
2902
4846
|
}
|
|
2903
4847
|
get textContent() {
|
|
@@ -2967,12 +4911,12 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
|
|
|
2967
4911
|
}
|
|
2968
4912
|
let inputDataToApply = null, scrollDataToApply = null;
|
|
2969
4913
|
switch (newTree.RRNodeType) {
|
|
2970
|
-
case
|
|
4914
|
+
case NodeType$1.Document: {
|
|
2971
4915
|
const newRRDocument = newTree;
|
|
2972
4916
|
scrollDataToApply = newRRDocument.scrollData;
|
|
2973
4917
|
break;
|
|
2974
4918
|
}
|
|
2975
|
-
case
|
|
4919
|
+
case NodeType$1.Element: {
|
|
2976
4920
|
const oldElement = oldTree;
|
|
2977
4921
|
const newRRElement = newTree;
|
|
2978
4922
|
diffProps(oldElement, newRRElement, rrnodeMirror);
|
|
@@ -3012,9 +4956,9 @@ function diff(oldTree, newTree, replayer, rrnodeMirror) {
|
|
|
3012
4956
|
}
|
|
3013
4957
|
break;
|
|
3014
4958
|
}
|
|
3015
|
-
case
|
|
3016
|
-
case
|
|
3017
|
-
case
|
|
4959
|
+
case NodeType$1.Text:
|
|
4960
|
+
case NodeType$1.Comment:
|
|
4961
|
+
case NodeType$1.CDATA:
|
|
3018
4962
|
if (oldTree.textContent !==
|
|
3019
4963
|
newTree.data)
|
|
3020
4964
|
oldTree.textContent = newTree.data;
|
|
@@ -3084,26 +5028,16 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
|
|
|
3084
5028
|
newEndNode = newChildren[--newEndIndex];
|
|
3085
5029
|
}
|
|
3086
5030
|
else if (replayer.mirror.getId(oldStartNode) === rrnodeMirror.getId(newEndNode)) {
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
newEndNode = newChildren[--newEndIndex];
|
|
3092
|
-
}
|
|
3093
|
-
catch (e) {
|
|
3094
|
-
console.error(e, parentNode, oldStartNode, oldEndNode);
|
|
3095
|
-
}
|
|
5031
|
+
parentNode.insertBefore(oldStartNode, oldEndNode.nextSibling);
|
|
5032
|
+
diff(oldStartNode, newEndNode, replayer, rrnodeMirror);
|
|
5033
|
+
oldStartNode = oldChildren[++oldStartIndex];
|
|
5034
|
+
newEndNode = newChildren[--newEndIndex];
|
|
3096
5035
|
}
|
|
3097
5036
|
else if (replayer.mirror.getId(oldEndNode) === rrnodeMirror.getId(newStartNode)) {
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
newStartNode = newChildren[++newStartIndex];
|
|
3103
|
-
}
|
|
3104
|
-
catch (e) {
|
|
3105
|
-
console.error(e, parentNode, oldEndNode, oldStartNode);
|
|
3106
|
-
}
|
|
5037
|
+
parentNode.insertBefore(oldEndNode, oldStartNode);
|
|
5038
|
+
diff(oldEndNode, newStartNode, replayer, rrnodeMirror);
|
|
5039
|
+
oldEndNode = oldChildren[--oldEndIndex];
|
|
5040
|
+
newStartNode = newChildren[++newStartIndex];
|
|
3107
5041
|
}
|
|
3108
5042
|
else {
|
|
3109
5043
|
if (!oldIdToIndex) {
|
|
@@ -3117,31 +5051,21 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
|
|
|
3117
5051
|
indexInOld = oldIdToIndex[rrnodeMirror.getId(newStartNode)];
|
|
3118
5052
|
if (indexInOld) {
|
|
3119
5053
|
const nodeToMove = oldChildren[indexInOld];
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
oldChildren[indexInOld] = undefined;
|
|
3124
|
-
}
|
|
3125
|
-
catch (e) {
|
|
3126
|
-
console.error(e, parentNode, nodeToMove, oldStartNode);
|
|
3127
|
-
}
|
|
5054
|
+
parentNode.insertBefore(nodeToMove, oldStartNode);
|
|
5055
|
+
diff(nodeToMove, newStartNode, replayer, rrnodeMirror);
|
|
5056
|
+
oldChildren[indexInOld] = undefined;
|
|
3128
5057
|
}
|
|
3129
5058
|
else {
|
|
3130
5059
|
const newNode = createOrGetNode(newStartNode, replayer.mirror, rrnodeMirror);
|
|
3131
5060
|
if (parentNode.nodeName === '#document' &&
|
|
3132
|
-
((_a = replayer.mirror.getMeta(newNode)) === null || _a === void 0 ? void 0 : _a.type) ===
|
|
5061
|
+
((_a = replayer.mirror.getMeta(newNode)) === null || _a === void 0 ? void 0 : _a.type) === NodeType$1.Element &&
|
|
3133
5062
|
parentNode.documentElement) {
|
|
3134
5063
|
parentNode.removeChild(parentNode.documentElement);
|
|
3135
5064
|
oldChildren[oldStartIndex] = undefined;
|
|
3136
5065
|
oldStartNode = undefined;
|
|
3137
5066
|
}
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
diff(newNode, newStartNode, replayer, rrnodeMirror);
|
|
3141
|
-
}
|
|
3142
|
-
catch (e) {
|
|
3143
|
-
console.error(e, parentNode, newNode, oldStartNode || null);
|
|
3144
|
-
}
|
|
5067
|
+
parentNode.insertBefore(newNode, oldStartNode || null);
|
|
5068
|
+
diff(newNode, newStartNode, replayer, rrnodeMirror);
|
|
3145
5069
|
}
|
|
3146
5070
|
newStartNode = newChildren[++newStartIndex];
|
|
3147
5071
|
}
|
|
@@ -3156,13 +5080,8 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
|
|
|
3156
5080
|
});
|
|
3157
5081
|
for (; newStartIndex <= newEndIndex; ++newStartIndex) {
|
|
3158
5082
|
const newNode = createOrGetNode(newChildren[newStartIndex], replayer.mirror, rrnodeMirror);
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
diff(newNode, newChildren[newStartIndex], replayer, rrnodeMirror);
|
|
3162
|
-
}
|
|
3163
|
-
catch (e) {
|
|
3164
|
-
console.error(e, parentNode, newNode, referenceNode);
|
|
3165
|
-
}
|
|
5083
|
+
parentNode.insertBefore(newNode, referenceNode);
|
|
5084
|
+
diff(newNode, newChildren[newStartIndex], replayer, rrnodeMirror);
|
|
3166
5085
|
}
|
|
3167
5086
|
}
|
|
3168
5087
|
else if (newStartIndex > newEndIndex) {
|
|
@@ -3181,13 +5100,13 @@ function createOrGetNode(rrNode, domMirror, rrnodeMirror) {
|
|
|
3181
5100
|
if (node !== null)
|
|
3182
5101
|
return node;
|
|
3183
5102
|
switch (rrNode.RRNodeType) {
|
|
3184
|
-
case
|
|
5103
|
+
case NodeType$1.Document:
|
|
3185
5104
|
node = new Document();
|
|
3186
5105
|
break;
|
|
3187
|
-
case
|
|
5106
|
+
case NodeType$1.DocumentType:
|
|
3188
5107
|
node = document.implementation.createDocumentType(rrNode.name, rrNode.publicId, rrNode.systemId);
|
|
3189
5108
|
break;
|
|
3190
|
-
case
|
|
5109
|
+
case NodeType$1.Element: {
|
|
3191
5110
|
rrNode.tagName.toLowerCase();
|
|
3192
5111
|
if (sn && 'isSVG' in sn && (sn === null || sn === void 0 ? void 0 : sn.isSVG)) {
|
|
3193
5112
|
node = document.createElementNS(NAMESPACES['svg'], rrNode.tagName.toLowerCase());
|
|
@@ -3196,13 +5115,13 @@ function createOrGetNode(rrNode, domMirror, rrnodeMirror) {
|
|
|
3196
5115
|
node = document.createElement(rrNode.tagName);
|
|
3197
5116
|
break;
|
|
3198
5117
|
}
|
|
3199
|
-
case
|
|
5118
|
+
case NodeType$1.Text:
|
|
3200
5119
|
node = document.createTextNode(rrNode.data);
|
|
3201
5120
|
break;
|
|
3202
|
-
case
|
|
5121
|
+
case NodeType$1.Comment:
|
|
3203
5122
|
node = document.createComment(rrNode.data);
|
|
3204
5123
|
break;
|
|
3205
|
-
case
|
|
5124
|
+
case NodeType$1.CDATA:
|
|
3206
5125
|
node = document.createCDATASection(rrNode.data);
|
|
3207
5126
|
break;
|
|
3208
5127
|
}
|
|
@@ -3396,11 +5315,11 @@ function buildFromNode(node, rrdom, domMirror, parentRRNode) {
|
|
|
3396
5315
|
}
|
|
3397
5316
|
break;
|
|
3398
5317
|
case NodeType.DOCUMENT_TYPE_NODE:
|
|
3399
|
-
const documentType =
|
|
5318
|
+
const documentType = node;
|
|
3400
5319
|
rrNode = rrdom.createDocumentType(documentType.name, documentType.publicId, documentType.systemId);
|
|
3401
5320
|
break;
|
|
3402
5321
|
case NodeType.ELEMENT_NODE:
|
|
3403
|
-
const elementNode =
|
|
5322
|
+
const elementNode = node;
|
|
3404
5323
|
const tagName = getValidTagName(elementNode);
|
|
3405
5324
|
rrNode = rrdom.createElement(tagName);
|
|
3406
5325
|
const rrElement = rrNode;
|
|
@@ -3411,13 +5330,13 @@ function buildFromNode(node, rrdom, domMirror, parentRRNode) {
|
|
|
3411
5330
|
elementNode.scrollTop && (rrElement.scrollTop = elementNode.scrollTop);
|
|
3412
5331
|
break;
|
|
3413
5332
|
case NodeType.TEXT_NODE:
|
|
3414
|
-
rrNode = rrdom.createTextNode(
|
|
5333
|
+
rrNode = rrdom.createTextNode(node.textContent || '');
|
|
3415
5334
|
break;
|
|
3416
5335
|
case NodeType.CDATA_SECTION_NODE:
|
|
3417
|
-
rrNode = rrdom.createCDATASection(
|
|
5336
|
+
rrNode = rrdom.createCDATASection(node.data);
|
|
3418
5337
|
break;
|
|
3419
5338
|
case NodeType.COMMENT_NODE:
|
|
3420
|
-
rrNode = rrdom.createComment(
|
|
5339
|
+
rrNode = rrdom.createComment(node.textContent || '');
|
|
3421
5340
|
break;
|
|
3422
5341
|
case NodeType.DOCUMENT_FRAGMENT_NODE:
|
|
3423
5342
|
rrNode = parentRRNode.attachShadow({ mode: 'open' });
|
|
@@ -3435,7 +5354,7 @@ function buildFromNode(node, rrdom, domMirror, parentRRNode) {
|
|
|
3435
5354
|
}
|
|
3436
5355
|
return rrNode;
|
|
3437
5356
|
}
|
|
3438
|
-
function buildFromDom(dom, domMirror =
|
|
5357
|
+
function buildFromDom(dom, domMirror = createMirror$1(), rrdom = new RRDocument()) {
|
|
3439
5358
|
function walk(node, parentRRNode) {
|
|
3440
5359
|
const rrNode = buildFromNode(node, rrdom, domMirror, parentRRNode);
|
|
3441
5360
|
if (rrNode === null)
|
|
@@ -3453,8 +5372,8 @@ function buildFromDom(dom, domMirror = rrwebSnapshot.createMirror(), rrdom = new
|
|
|
3453
5372
|
node.nodeType === NodeType.ELEMENT_NODE ||
|
|
3454
5373
|
node.nodeType === NodeType.DOCUMENT_FRAGMENT_NODE) {
|
|
3455
5374
|
if (node.nodeType === NodeType.ELEMENT_NODE &&
|
|
3456
|
-
|
|
3457
|
-
walk(
|
|
5375
|
+
node.shadowRoot)
|
|
5376
|
+
walk(node.shadowRoot, rrNode);
|
|
3458
5377
|
node.childNodes.forEach((childNode) => walk(childNode, rrNode));
|
|
3459
5378
|
}
|
|
3460
5379
|
}
|
|
@@ -3513,13 +5432,13 @@ class Mirror {
|
|
|
3513
5432
|
}
|
|
3514
5433
|
function getDefaultSN(node, id) {
|
|
3515
5434
|
switch (node.RRNodeType) {
|
|
3516
|
-
case
|
|
5435
|
+
case NodeType$1.Document:
|
|
3517
5436
|
return {
|
|
3518
5437
|
id,
|
|
3519
5438
|
type: node.RRNodeType,
|
|
3520
5439
|
childNodes: [],
|
|
3521
5440
|
};
|
|
3522
|
-
case
|
|
5441
|
+
case NodeType$1.DocumentType:
|
|
3523
5442
|
const doctype = node;
|
|
3524
5443
|
return {
|
|
3525
5444
|
id,
|
|
@@ -3528,7 +5447,7 @@ function getDefaultSN(node, id) {
|
|
|
3528
5447
|
publicId: doctype.publicId,
|
|
3529
5448
|
systemId: doctype.systemId,
|
|
3530
5449
|
};
|
|
3531
|
-
case
|
|
5450
|
+
case NodeType$1.Element:
|
|
3532
5451
|
return {
|
|
3533
5452
|
id,
|
|
3534
5453
|
type: node.RRNodeType,
|
|
@@ -3536,19 +5455,19 @@ function getDefaultSN(node, id) {
|
|
|
3536
5455
|
attributes: {},
|
|
3537
5456
|
childNodes: [],
|
|
3538
5457
|
};
|
|
3539
|
-
case
|
|
5458
|
+
case NodeType$1.Text:
|
|
3540
5459
|
return {
|
|
3541
5460
|
id,
|
|
3542
5461
|
type: node.RRNodeType,
|
|
3543
5462
|
textContent: node.textContent || '',
|
|
3544
5463
|
};
|
|
3545
|
-
case
|
|
5464
|
+
case NodeType$1.Comment:
|
|
3546
5465
|
return {
|
|
3547
5466
|
id,
|
|
3548
5467
|
type: node.RRNodeType,
|
|
3549
5468
|
textContent: node.textContent || '',
|
|
3550
5469
|
};
|
|
3551
|
-
case
|
|
5470
|
+
case NodeType$1.CDATA:
|
|
3552
5471
|
return {
|
|
3553
5472
|
id,
|
|
3554
5473
|
type: node.RRNodeType,
|
|
@@ -3620,8 +5539,8 @@ function mitt$1(all ) {
|
|
|
3620
5539
|
}
|
|
3621
5540
|
|
|
3622
5541
|
var mittProxy = /*#__PURE__*/Object.freeze({
|
|
3623
|
-
|
|
3624
|
-
|
|
5542
|
+
__proto__: null,
|
|
5543
|
+
'default': mitt$1
|
|
3625
5544
|
});
|
|
3626
5545
|
|
|
3627
5546
|
function polyfill(w = window, d = document) {
|
|
@@ -4439,10 +6358,10 @@ class Replayer {
|
|
|
4439
6358
|
this.emitter = mitt();
|
|
4440
6359
|
this.activityIntervals = [];
|
|
4441
6360
|
this.legacy_missingNodeRetryMap = {};
|
|
4442
|
-
this.cache =
|
|
6361
|
+
this.cache = createCache();
|
|
4443
6362
|
this.imageMap = new Map();
|
|
4444
6363
|
this.canvasEventMap = new Map();
|
|
4445
|
-
this.mirror =
|
|
6364
|
+
this.mirror = createMirror$2();
|
|
4446
6365
|
this.firstFullSnapshot = null;
|
|
4447
6366
|
this.newDocumentQueue = [];
|
|
4448
6367
|
this.mousePos = null;
|
|
@@ -4784,7 +6703,7 @@ class Replayer {
|
|
|
4784
6703
|
this.iframe.style.pointerEvents = 'none';
|
|
4785
6704
|
}
|
|
4786
6705
|
resetCache() {
|
|
4787
|
-
this.cache =
|
|
6706
|
+
this.cache = createCache();
|
|
4788
6707
|
}
|
|
4789
6708
|
setupDom() {
|
|
4790
6709
|
this.wrapper = document.createElement('div');
|
|
@@ -4986,7 +6905,7 @@ class Replayer {
|
|
|
4986
6905
|
}
|
|
4987
6906
|
this.legacy_missingNodeRetryMap = {};
|
|
4988
6907
|
const collected = [];
|
|
4989
|
-
|
|
6908
|
+
rebuild(event.data.node, {
|
|
4990
6909
|
doc: this.iframe.contentDocument,
|
|
4991
6910
|
afterAppend: (builtNode) => {
|
|
4992
6911
|
this.collectIframeAndAttachDocument(collected, builtNode);
|
|
@@ -5034,7 +6953,7 @@ class Replayer {
|
|
|
5034
6953
|
const styleEl = document.createElement('style');
|
|
5035
6954
|
documentElement.insertBefore(styleEl, head);
|
|
5036
6955
|
for (let idx = 0; idx < injectStylesRules.length; idx++) {
|
|
5037
|
-
|
|
6956
|
+
styleEl.sheet.insertRule(injectStylesRules[idx], idx);
|
|
5038
6957
|
}
|
|
5039
6958
|
}
|
|
5040
6959
|
}
|
|
@@ -5043,7 +6962,7 @@ class Replayer {
|
|
|
5043
6962
|
? this.virtualDom.mirror
|
|
5044
6963
|
: this.mirror;
|
|
5045
6964
|
const collected = [];
|
|
5046
|
-
|
|
6965
|
+
buildNodeWithSN(mutation.node, {
|
|
5047
6966
|
doc: iframeEl.contentDocument,
|
|
5048
6967
|
mirror: mirror,
|
|
5049
6968
|
hackCss: true,
|
|
@@ -5051,7 +6970,7 @@ class Replayer {
|
|
|
5051
6970
|
afterAppend: (builtNode) => {
|
|
5052
6971
|
this.collectIframeAndAttachDocument(collected, builtNode);
|
|
5053
6972
|
const sn = mirror.getMeta(builtNode);
|
|
5054
|
-
if ((sn === null || sn === void 0 ? void 0 : sn.type) ===
|
|
6973
|
+
if ((sn === null || sn === void 0 ? void 0 : sn.type) === NodeType$2.Element &&
|
|
5055
6974
|
(sn === null || sn === void 0 ? void 0 : sn.tagName.toUpperCase()) === 'HTML') {
|
|
5056
6975
|
const { documentElement, head } = iframeEl.contentDocument;
|
|
5057
6976
|
this.insertStyleRules(documentElement, head);
|
|
@@ -5419,7 +7338,7 @@ class Replayer {
|
|
|
5419
7338
|
if (!target) {
|
|
5420
7339
|
return this.debugNodeNotFound(d, d.id);
|
|
5421
7340
|
}
|
|
5422
|
-
const styleSheet =
|
|
7341
|
+
const styleSheet = target.sheet;
|
|
5423
7342
|
(_d = d.adds) === null || _d === void 0 ? void 0 : _d.forEach(({ rule, index: nestedIndex }) => {
|
|
5424
7343
|
try {
|
|
5425
7344
|
if (Array.isArray(nestedIndex)) {
|
|
@@ -5605,7 +7524,7 @@ class Replayer {
|
|
|
5605
7524
|
}
|
|
5606
7525
|
let parent = mirror.getNode(mutation.parentId);
|
|
5607
7526
|
if (!parent) {
|
|
5608
|
-
if (mutation.node.type ===
|
|
7527
|
+
if (mutation.node.type === NodeType$2.Document) {
|
|
5609
7528
|
return this.newDocumentQueue.push(mutation);
|
|
5610
7529
|
}
|
|
5611
7530
|
return queue.push(mutation);
|
|
@@ -5641,7 +7560,7 @@ class Replayer {
|
|
|
5641
7560
|
this.attachDocumentToIframe(mutation, parent);
|
|
5642
7561
|
return;
|
|
5643
7562
|
}
|
|
5644
|
-
const target =
|
|
7563
|
+
const target = buildNodeWithSN(mutation.node, {
|
|
5645
7564
|
doc: targetDoc,
|
|
5646
7565
|
mirror: mirror,
|
|
5647
7566
|
skipChild: true,
|
|
@@ -5657,9 +7576,9 @@ class Replayer {
|
|
|
5657
7576
|
}
|
|
5658
7577
|
const parentSn = mirror.getMeta(parent);
|
|
5659
7578
|
if (parentSn &&
|
|
5660
|
-
parentSn.type ===
|
|
7579
|
+
parentSn.type === NodeType$2.Element &&
|
|
5661
7580
|
parentSn.tagName === 'textarea' &&
|
|
5662
|
-
mutation.node.type ===
|
|
7581
|
+
mutation.node.type === NodeType$2.Text) {
|
|
5663
7582
|
const childNodeArray = Array.isArray(parent.childNodes)
|
|
5664
7583
|
? parent.childNodes
|
|
5665
7584
|
: Array.from(parent.childNodes);
|
|
@@ -5802,7 +7721,7 @@ class Replayer {
|
|
|
5802
7721
|
behavior: isSync ? 'auto' : 'smooth',
|
|
5803
7722
|
});
|
|
5804
7723
|
}
|
|
5805
|
-
else if ((sn === null || sn === void 0 ? void 0 : sn.type) ===
|
|
7724
|
+
else if ((sn === null || sn === void 0 ? void 0 : sn.type) === NodeType$2.Document) {
|
|
5806
7725
|
target.defaultView.scrollTo({
|
|
5807
7726
|
top: d.y,
|
|
5808
7727
|
left: d.x,
|