@highlight-run/rrweb 2.0.8 → 2.0.11
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 +3 -4
- package/dist/replay/rrweb-replay-unpack.min.js +3 -4
- package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
- package/dist/replay/rrweb-replay.js +3 -4
- package/dist/replay/rrweb-replay.min.js +3 -4
- package/dist/replay/rrweb-replay.min.js.map +1 -1
- package/dist/rrweb-all.js +24 -25
- package/dist/rrweb-all.min.js +24 -25
- package/dist/rrweb-all.min.js.map +1 -1
- package/dist/rrweb.js +14 -15
- package/dist/rrweb.min.js +14 -15
- package/dist/rrweb.min.js.map +1 -1
- package/es/rrweb/packages/rrdom/es/virtual-dom.js +51 -90
- package/es/rrweb/packages/rrweb/src/index.js +1 -1
- package/es/rrweb/packages/rrweb/src/record/index.js +6 -3
- package/es/rrweb/packages/rrweb/src/record/mutation.js +1 -1
- package/es/rrweb/packages/rrweb/src/record/observer.js +1 -1
- package/es/rrweb/packages/rrweb/src/replay/index.js +1 -1
- package/es/rrweb/packages/rrweb/src/utils.js +1 -1
- package/lib/plugins/console-record.js +1 -9
- package/lib/plugins/console-replay.js +1 -9
- package/lib/record/rrweb-record-pack.js +3 -9
- package/lib/record/rrweb-record.js +21 -1061
- package/lib/replay/rrweb-replay-unpack.js +96 -1015
- package/lib/replay/rrweb-replay.js +96 -1015
- package/lib/rrweb-all.js +141 -2034
- package/lib/rrweb.js +141 -2034
- package/package.json +4 -4
- package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +0 -1858
|
@@ -1,1858 +0,0 @@
|
|
|
1
|
-
var NodeType;
|
|
2
|
-
(function (NodeType) {
|
|
3
|
-
NodeType[NodeType["Document"] = 0] = "Document";
|
|
4
|
-
NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
|
|
5
|
-
NodeType[NodeType["Element"] = 2] = "Element";
|
|
6
|
-
NodeType[NodeType["Text"] = 3] = "Text";
|
|
7
|
-
NodeType[NodeType["CDATA"] = 4] = "CDATA";
|
|
8
|
-
NodeType[NodeType["Comment"] = 5] = "Comment";
|
|
9
|
-
})(NodeType || (NodeType = {}));
|
|
10
|
-
|
|
11
|
-
function isElement(n) {
|
|
12
|
-
return n.nodeType === n.ELEMENT_NODE;
|
|
13
|
-
}
|
|
14
|
-
function isShadowRoot(n) {
|
|
15
|
-
var _a;
|
|
16
|
-
var host = (_a = n) === null || _a === void 0 ? void 0 : _a.host;
|
|
17
|
-
return Boolean((host === null || host === void 0 ? void 0 : host.shadowRoot) === n);
|
|
18
|
-
}
|
|
19
|
-
var Mirror = (function () {
|
|
20
|
-
function Mirror() {
|
|
21
|
-
this.idNodeMap = new Map();
|
|
22
|
-
this.nodeMetaMap = new WeakMap();
|
|
23
|
-
}
|
|
24
|
-
Mirror.prototype.getId = function (n) {
|
|
25
|
-
var _a;
|
|
26
|
-
if (!n)
|
|
27
|
-
return -1;
|
|
28
|
-
var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
|
|
29
|
-
return id !== null && id !== void 0 ? id : -1;
|
|
30
|
-
};
|
|
31
|
-
Mirror.prototype.getNode = function (id) {
|
|
32
|
-
return this.idNodeMap.get(id) || null;
|
|
33
|
-
};
|
|
34
|
-
Mirror.prototype.getIds = function () {
|
|
35
|
-
return Array.from(this.idNodeMap.keys());
|
|
36
|
-
};
|
|
37
|
-
Mirror.prototype.getMeta = function (n) {
|
|
38
|
-
return this.nodeMetaMap.get(n) || null;
|
|
39
|
-
};
|
|
40
|
-
Mirror.prototype.removeNodeFromMap = function (n) {
|
|
41
|
-
var _this = this;
|
|
42
|
-
var id = this.getId(n);
|
|
43
|
-
this.idNodeMap["delete"](id);
|
|
44
|
-
if (n.childNodes) {
|
|
45
|
-
n.childNodes.forEach(function (childNode) {
|
|
46
|
-
return _this.removeNodeFromMap(childNode);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
Mirror.prototype.has = function (id) {
|
|
51
|
-
return this.idNodeMap.has(id);
|
|
52
|
-
};
|
|
53
|
-
Mirror.prototype.hasNode = function (node) {
|
|
54
|
-
return this.nodeMetaMap.has(node);
|
|
55
|
-
};
|
|
56
|
-
Mirror.prototype.add = function (n, meta) {
|
|
57
|
-
var id = meta.id;
|
|
58
|
-
this.idNodeMap.set(id, n);
|
|
59
|
-
this.nodeMetaMap.set(n, meta);
|
|
60
|
-
};
|
|
61
|
-
Mirror.prototype.replace = function (id, n) {
|
|
62
|
-
this.idNodeMap.set(id, n);
|
|
63
|
-
};
|
|
64
|
-
Mirror.prototype.reset = function () {
|
|
65
|
-
this.idNodeMap = new Map();
|
|
66
|
-
this.nodeMetaMap = new WeakMap();
|
|
67
|
-
};
|
|
68
|
-
return Mirror;
|
|
69
|
-
}());
|
|
70
|
-
function createMirror() {
|
|
71
|
-
return new Mirror();
|
|
72
|
-
}
|
|
73
|
-
function maskInputValue(_a) {
|
|
74
|
-
var maskInputOptions = _a.maskInputOptions, tagName = _a.tagName, type = _a.type, value = _a.value, maskInputFn = _a.maskInputFn;
|
|
75
|
-
var text = value || '';
|
|
76
|
-
if (maskInputOptions[tagName.toLowerCase()] ||
|
|
77
|
-
maskInputOptions[type]) {
|
|
78
|
-
if (maskInputFn) {
|
|
79
|
-
text = maskInputFn(text);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
text = '*'.repeat(text.length);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return text;
|
|
86
|
-
}
|
|
87
|
-
var ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';
|
|
88
|
-
function is2DCanvasBlank(canvas) {
|
|
89
|
-
var ctx = canvas.getContext('2d');
|
|
90
|
-
if (!ctx)
|
|
91
|
-
return true;
|
|
92
|
-
var chunkSize = 50;
|
|
93
|
-
for (var x = 0; x < canvas.width; x += chunkSize) {
|
|
94
|
-
for (var y = 0; y < canvas.height; y += chunkSize) {
|
|
95
|
-
var getImageData = ctx.getImageData;
|
|
96
|
-
var originalGetImageData = ORIGINAL_ATTRIBUTE_NAME in getImageData
|
|
97
|
-
? getImageData[ORIGINAL_ATTRIBUTE_NAME]
|
|
98
|
-
: getImageData;
|
|
99
|
-
var pixelBuffer = new Uint32Array(originalGetImageData.call(ctx, x, y, Math.min(chunkSize, canvas.width - x), Math.min(chunkSize, canvas.height - y)).data.buffer);
|
|
100
|
-
if (pixelBuffer.some(function (pixel) { return pixel !== 0; }))
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
function obfuscateText(text) {
|
|
107
|
-
text = text.replace(/[^ -~]+/g, '');
|
|
108
|
-
text =
|
|
109
|
-
(text === null || text === void 0 ? void 0 : text.split(' ').map(function (word) { return Math.random().toString(20).substr(2, word.length); }).join(' ')) || '';
|
|
110
|
-
return text;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
var _id = 1;
|
|
114
|
-
var tagNameRegex = new RegExp('[^a-z0-9-_:]');
|
|
115
|
-
var IGNORED_NODE = -2;
|
|
116
|
-
function genId() {
|
|
117
|
-
return _id++;
|
|
118
|
-
}
|
|
119
|
-
function getValidTagName(element) {
|
|
120
|
-
if (element instanceof HTMLFormElement) {
|
|
121
|
-
return 'form';
|
|
122
|
-
}
|
|
123
|
-
var processedTagName = element.tagName.toLowerCase().trim();
|
|
124
|
-
if (tagNameRegex.test(processedTagName)) {
|
|
125
|
-
return 'div';
|
|
126
|
-
}
|
|
127
|
-
return processedTagName;
|
|
128
|
-
}
|
|
129
|
-
function getCssRulesString(s) {
|
|
130
|
-
try {
|
|
131
|
-
var rules = s.rules || s.cssRules;
|
|
132
|
-
return rules ? Array.from(rules).map(getCssRuleString).join('') : null;
|
|
133
|
-
}
|
|
134
|
-
catch (error) {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function getCssRuleString(rule) {
|
|
139
|
-
var cssStringified = rule.cssText;
|
|
140
|
-
if (isCSSImportRule(rule)) {
|
|
141
|
-
try {
|
|
142
|
-
cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;
|
|
143
|
-
}
|
|
144
|
-
catch (_a) {
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return cssStringified;
|
|
148
|
-
}
|
|
149
|
-
function isCSSImportRule(rule) {
|
|
150
|
-
return 'styleSheet' in rule;
|
|
151
|
-
}
|
|
152
|
-
function stringifyStyleSheet(sheet) {
|
|
153
|
-
return sheet.cssRules
|
|
154
|
-
? Array.from(sheet.cssRules)
|
|
155
|
-
.map(function (rule) { return rule.cssText || ''; })
|
|
156
|
-
.join('')
|
|
157
|
-
: '';
|
|
158
|
-
}
|
|
159
|
-
function extractOrigin(url) {
|
|
160
|
-
var origin = '';
|
|
161
|
-
if (url.indexOf('//') > -1) {
|
|
162
|
-
origin = url.split('/').slice(0, 3).join('/');
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
origin = url.split('/')[0];
|
|
166
|
-
}
|
|
167
|
-
origin = origin.split('?')[0];
|
|
168
|
-
return origin;
|
|
169
|
-
}
|
|
170
|
-
var canvasService;
|
|
171
|
-
var canvasCtx;
|
|
172
|
-
var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm;
|
|
173
|
-
var RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/;
|
|
174
|
-
var DATA_URI = /^(data:)([^,]*),(.*)/i;
|
|
175
|
-
function absoluteToStylesheet(cssText, href) {
|
|
176
|
-
return (cssText || '').replace(URL_IN_CSS_REF, function (origin, quote1, path1, quote2, path2, path3) {
|
|
177
|
-
var filePath = path1 || path2 || path3;
|
|
178
|
-
var maybeQuote = quote1 || quote2 || '';
|
|
179
|
-
if (!filePath) {
|
|
180
|
-
return origin;
|
|
181
|
-
}
|
|
182
|
-
if (!RELATIVE_PATH.test(filePath)) {
|
|
183
|
-
return "url(" + maybeQuote + filePath + maybeQuote + ")";
|
|
184
|
-
}
|
|
185
|
-
if (DATA_URI.test(filePath)) {
|
|
186
|
-
return "url(" + maybeQuote + filePath + maybeQuote + ")";
|
|
187
|
-
}
|
|
188
|
-
if (filePath[0] === '/') {
|
|
189
|
-
return "url(" + maybeQuote + (extractOrigin(href) + filePath) + maybeQuote + ")";
|
|
190
|
-
}
|
|
191
|
-
var stack = href.split('/');
|
|
192
|
-
var parts = filePath.split('/');
|
|
193
|
-
stack.pop();
|
|
194
|
-
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
|
|
195
|
-
var part = parts_1[_i];
|
|
196
|
-
if (part === '.') {
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
else if (part === '..') {
|
|
200
|
-
stack.pop();
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
stack.push(part);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return "url(" + maybeQuote + stack.join('/') + maybeQuote + ")";
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/;
|
|
210
|
-
var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/;
|
|
211
|
-
function getAbsoluteSrcsetString(doc, attributeValue) {
|
|
212
|
-
if (attributeValue.trim() === '') {
|
|
213
|
-
return attributeValue;
|
|
214
|
-
}
|
|
215
|
-
var pos = 0;
|
|
216
|
-
function collectCharacters(regEx) {
|
|
217
|
-
var chars;
|
|
218
|
-
var match = regEx.exec(attributeValue.substring(pos));
|
|
219
|
-
if (match) {
|
|
220
|
-
chars = match[0];
|
|
221
|
-
pos += chars.length;
|
|
222
|
-
return chars;
|
|
223
|
-
}
|
|
224
|
-
return '';
|
|
225
|
-
}
|
|
226
|
-
var output = [];
|
|
227
|
-
while (true) {
|
|
228
|
-
collectCharacters(SRCSET_COMMAS_OR_SPACES);
|
|
229
|
-
if (pos >= attributeValue.length) {
|
|
230
|
-
break;
|
|
231
|
-
}
|
|
232
|
-
var url = collectCharacters(SRCSET_NOT_SPACES);
|
|
233
|
-
if (url.slice(-1) === ',') {
|
|
234
|
-
url = absoluteToDoc(doc, url.substring(0, url.length - 1));
|
|
235
|
-
output.push(url);
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
var descriptorsStr = '';
|
|
239
|
-
url = absoluteToDoc(doc, url);
|
|
240
|
-
var inParens = false;
|
|
241
|
-
while (true) {
|
|
242
|
-
var c = attributeValue.charAt(pos);
|
|
243
|
-
if (c === '') {
|
|
244
|
-
output.push((url + descriptorsStr).trim());
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
else if (!inParens) {
|
|
248
|
-
if (c === ',') {
|
|
249
|
-
pos += 1;
|
|
250
|
-
output.push((url + descriptorsStr).trim());
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
else if (c === '(') {
|
|
254
|
-
inParens = true;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
if (c === ')') {
|
|
259
|
-
inParens = false;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
descriptorsStr += c;
|
|
263
|
-
pos += 1;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return output.join(', ');
|
|
268
|
-
}
|
|
269
|
-
function absoluteToDoc(doc, attributeValue) {
|
|
270
|
-
if (!attributeValue || attributeValue.trim() === '') {
|
|
271
|
-
return attributeValue;
|
|
272
|
-
}
|
|
273
|
-
var a = doc.createElement('a');
|
|
274
|
-
a.href = attributeValue;
|
|
275
|
-
return a.href;
|
|
276
|
-
}
|
|
277
|
-
function isSVGElement(el) {
|
|
278
|
-
return Boolean(el.tagName === 'svg' || el.ownerSVGElement);
|
|
279
|
-
}
|
|
280
|
-
function getHref() {
|
|
281
|
-
var a = document.createElement('a');
|
|
282
|
-
a.href = '';
|
|
283
|
-
return a.href;
|
|
284
|
-
}
|
|
285
|
-
function transformAttribute(doc, tagName, name, value) {
|
|
286
|
-
if (name === 'src' || (name === 'href' && value)) {
|
|
287
|
-
return absoluteToDoc(doc, value);
|
|
288
|
-
}
|
|
289
|
-
else if (name === 'xlink:href' && value && value[0] !== '#') {
|
|
290
|
-
return absoluteToDoc(doc, value);
|
|
291
|
-
}
|
|
292
|
-
else if (name === 'background' &&
|
|
293
|
-
value &&
|
|
294
|
-
(tagName === 'table' || tagName === 'td' || tagName === 'th')) {
|
|
295
|
-
return absoluteToDoc(doc, value);
|
|
296
|
-
}
|
|
297
|
-
else if (name === 'srcset' && value) {
|
|
298
|
-
return getAbsoluteSrcsetString(doc, value);
|
|
299
|
-
}
|
|
300
|
-
else if (name === 'style' && value) {
|
|
301
|
-
return absoluteToStylesheet(value, getHref());
|
|
302
|
-
}
|
|
303
|
-
else if (tagName === 'object' && name === 'data' && value) {
|
|
304
|
-
return absoluteToDoc(doc, value);
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
return value;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
function _isBlockedElement(element, blockClass, blockSelector) {
|
|
311
|
-
if (typeof blockClass === 'string') {
|
|
312
|
-
if (element.classList.contains(blockClass)) {
|
|
313
|
-
return true;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
for (var eIndex = element.classList.length; eIndex--;) {
|
|
318
|
-
var className = element.classList[eIndex];
|
|
319
|
-
if (blockClass.test(className)) {
|
|
320
|
-
return true;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
if (blockSelector) {
|
|
325
|
-
return element.matches(blockSelector);
|
|
326
|
-
}
|
|
327
|
-
return false;
|
|
328
|
-
}
|
|
329
|
-
function classMatchesRegex(node, regex, checkAncestors) {
|
|
330
|
-
if (!node)
|
|
331
|
-
return false;
|
|
332
|
-
if (node.nodeType !== node.ELEMENT_NODE) {
|
|
333
|
-
if (!checkAncestors)
|
|
334
|
-
return false;
|
|
335
|
-
return classMatchesRegex(node.parentNode, regex, checkAncestors);
|
|
336
|
-
}
|
|
337
|
-
for (var eIndex = node.classList.length; eIndex--;) {
|
|
338
|
-
var className = node.classList[eIndex];
|
|
339
|
-
if (regex.test(className)) {
|
|
340
|
-
return true;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
if (!checkAncestors)
|
|
344
|
-
return false;
|
|
345
|
-
return classMatchesRegex(node.parentNode, regex, checkAncestors);
|
|
346
|
-
}
|
|
347
|
-
function needMaskingText(node, maskTextClass, maskTextSelector) {
|
|
348
|
-
var el = node.nodeType === node.ELEMENT_NODE
|
|
349
|
-
? node
|
|
350
|
-
: node.parentElement;
|
|
351
|
-
if (el === null)
|
|
352
|
-
return false;
|
|
353
|
-
if (typeof maskTextClass === 'string') {
|
|
354
|
-
if (el.classList.contains(maskTextClass))
|
|
355
|
-
return true;
|
|
356
|
-
if (el.closest("." + maskTextClass))
|
|
357
|
-
return true;
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
if (classMatchesRegex(el, maskTextClass, true))
|
|
361
|
-
return true;
|
|
362
|
-
}
|
|
363
|
-
if (maskTextSelector) {
|
|
364
|
-
if (el.matches(maskTextSelector))
|
|
365
|
-
return true;
|
|
366
|
-
if (el.closest(maskTextSelector))
|
|
367
|
-
return true;
|
|
368
|
-
}
|
|
369
|
-
return false;
|
|
370
|
-
}
|
|
371
|
-
function onceIframeLoaded(iframeEl, listener, iframeLoadTimeout) {
|
|
372
|
-
var win = iframeEl.contentWindow;
|
|
373
|
-
if (!win) {
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
var fired = false;
|
|
377
|
-
var readyState;
|
|
378
|
-
try {
|
|
379
|
-
readyState = win.document.readyState;
|
|
380
|
-
}
|
|
381
|
-
catch (error) {
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
if (readyState !== 'complete') {
|
|
385
|
-
var timer_1 = setTimeout(function () {
|
|
386
|
-
if (!fired) {
|
|
387
|
-
listener();
|
|
388
|
-
fired = true;
|
|
389
|
-
}
|
|
390
|
-
}, iframeLoadTimeout);
|
|
391
|
-
iframeEl.addEventListener('load', function () {
|
|
392
|
-
clearTimeout(timer_1);
|
|
393
|
-
fired = true;
|
|
394
|
-
listener();
|
|
395
|
-
});
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
var blankUrl = 'about:blank';
|
|
399
|
-
if (win.location.href !== blankUrl ||
|
|
400
|
-
iframeEl.src === blankUrl ||
|
|
401
|
-
iframeEl.src === '') {
|
|
402
|
-
setTimeout(listener, 0);
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
iframeEl.addEventListener('load', listener);
|
|
406
|
-
}
|
|
407
|
-
function isStylesheetLoaded(link) {
|
|
408
|
-
if (!link.getAttribute('href'))
|
|
409
|
-
return true;
|
|
410
|
-
return link.sheet !== null;
|
|
411
|
-
}
|
|
412
|
-
function onceStylesheetLoaded(link, listener, iframeLoadTimeout) {
|
|
413
|
-
var fired = false;
|
|
414
|
-
var styleSheetLoaded;
|
|
415
|
-
try {
|
|
416
|
-
styleSheetLoaded = link.sheet;
|
|
417
|
-
}
|
|
418
|
-
catch (error) {
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
if (styleSheetLoaded)
|
|
422
|
-
return;
|
|
423
|
-
var timer = setTimeout(function () {
|
|
424
|
-
if (!fired) {
|
|
425
|
-
listener();
|
|
426
|
-
fired = true;
|
|
427
|
-
}
|
|
428
|
-
}, iframeLoadTimeout);
|
|
429
|
-
link.addEventListener('load', function () {
|
|
430
|
-
clearTimeout(timer);
|
|
431
|
-
fired = true;
|
|
432
|
-
listener();
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
function serializeNode(n, options) {
|
|
436
|
-
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;
|
|
437
|
-
var rootId = getRootId(doc, mirror);
|
|
438
|
-
switch (n.nodeType) {
|
|
439
|
-
case n.DOCUMENT_NODE:
|
|
440
|
-
if (n.compatMode !== 'CSS1Compat') {
|
|
441
|
-
return {
|
|
442
|
-
type: NodeType.Document,
|
|
443
|
-
childNodes: [],
|
|
444
|
-
compatMode: n.compatMode,
|
|
445
|
-
rootId: rootId
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
else {
|
|
449
|
-
return {
|
|
450
|
-
type: NodeType.Document,
|
|
451
|
-
childNodes: [],
|
|
452
|
-
rootId: rootId
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
case n.DOCUMENT_TYPE_NODE:
|
|
456
|
-
return {
|
|
457
|
-
type: NodeType.DocumentType,
|
|
458
|
-
name: n.name,
|
|
459
|
-
publicId: n.publicId,
|
|
460
|
-
systemId: n.systemId,
|
|
461
|
-
rootId: rootId
|
|
462
|
-
};
|
|
463
|
-
case n.ELEMENT_NODE:
|
|
464
|
-
return serializeElementNode(n, {
|
|
465
|
-
doc: doc,
|
|
466
|
-
blockClass: blockClass,
|
|
467
|
-
blockSelector: blockSelector,
|
|
468
|
-
inlineStylesheet: inlineStylesheet,
|
|
469
|
-
maskInputOptions: maskInputOptions,
|
|
470
|
-
maskInputFn: maskInputFn,
|
|
471
|
-
dataURLOptions: dataURLOptions,
|
|
472
|
-
inlineImages: inlineImages,
|
|
473
|
-
recordCanvas: recordCanvas,
|
|
474
|
-
keepIframeSrcFn: keepIframeSrcFn,
|
|
475
|
-
newlyAddedElement: newlyAddedElement,
|
|
476
|
-
enableStrictPrivacy: enableStrictPrivacy,
|
|
477
|
-
rootId: rootId
|
|
478
|
-
});
|
|
479
|
-
case n.TEXT_NODE:
|
|
480
|
-
return serializeTextNode(n, {
|
|
481
|
-
maskTextClass: maskTextClass,
|
|
482
|
-
maskTextSelector: maskTextSelector,
|
|
483
|
-
maskTextFn: maskTextFn,
|
|
484
|
-
enableStrictPrivacy: enableStrictPrivacy,
|
|
485
|
-
rootId: rootId
|
|
486
|
-
});
|
|
487
|
-
case n.CDATA_SECTION_NODE:
|
|
488
|
-
return {
|
|
489
|
-
type: NodeType.CDATA,
|
|
490
|
-
textContent: '',
|
|
491
|
-
rootId: rootId
|
|
492
|
-
};
|
|
493
|
-
case n.COMMENT_NODE:
|
|
494
|
-
return {
|
|
495
|
-
type: NodeType.Comment,
|
|
496
|
-
textContent: n.textContent || '',
|
|
497
|
-
rootId: rootId
|
|
498
|
-
};
|
|
499
|
-
default:
|
|
500
|
-
return false;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
function getRootId(doc, mirror) {
|
|
504
|
-
if (!mirror.hasNode(doc))
|
|
505
|
-
return undefined;
|
|
506
|
-
var docId = mirror.getId(doc);
|
|
507
|
-
return docId === 1 ? undefined : docId;
|
|
508
|
-
}
|
|
509
|
-
function serializeTextNode(n, options) {
|
|
510
|
-
var _a;
|
|
511
|
-
var maskTextClass = options.maskTextClass, maskTextSelector = options.maskTextSelector, maskTextFn = options.maskTextFn, enableStrictPrivacy = options.enableStrictPrivacy, rootId = options.rootId;
|
|
512
|
-
var parentTagName = n.parentNode && n.parentNode.tagName;
|
|
513
|
-
var textContent = n.textContent;
|
|
514
|
-
var isStyle = parentTagName === 'STYLE' ? true : undefined;
|
|
515
|
-
var isScript = parentTagName === 'SCRIPT' ? true : undefined;
|
|
516
|
-
var textContentHandled = false;
|
|
517
|
-
if (isStyle && textContent) {
|
|
518
|
-
try {
|
|
519
|
-
if (n.nextSibling || n.previousSibling) {
|
|
520
|
-
}
|
|
521
|
-
else if ((_a = n.parentNode.sheet) === null || _a === void 0 ? void 0 : _a.cssRules) {
|
|
522
|
-
textContent = stringifyStyleSheet(n.parentNode.sheet);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
catch (err) {
|
|
526
|
-
console.warn("Cannot get CSS styles from text's parentNode. Error: " + err, n);
|
|
527
|
-
}
|
|
528
|
-
textContent = absoluteToStylesheet(textContent, getHref());
|
|
529
|
-
textContentHandled = true;
|
|
530
|
-
}
|
|
531
|
-
if (isScript) {
|
|
532
|
-
textContent = 'SCRIPT_PLACEHOLDER';
|
|
533
|
-
textContentHandled = true;
|
|
534
|
-
}
|
|
535
|
-
else if (parentTagName === 'NOSCRIPT') {
|
|
536
|
-
textContent = '';
|
|
537
|
-
textContentHandled = true;
|
|
538
|
-
}
|
|
539
|
-
if (!isStyle &&
|
|
540
|
-
!isScript &&
|
|
541
|
-
textContent &&
|
|
542
|
-
needMaskingText(n, maskTextClass, maskTextSelector)) {
|
|
543
|
-
textContent = maskTextFn
|
|
544
|
-
? maskTextFn(textContent)
|
|
545
|
-
: textContent.replace(/[\S]/g, '*');
|
|
546
|
-
}
|
|
547
|
-
if (enableStrictPrivacy && !textContentHandled && parentTagName) {
|
|
548
|
-
var IGNORE_TAG_NAMES = new Set([
|
|
549
|
-
'HEAD',
|
|
550
|
-
'TITLE',
|
|
551
|
-
'STYLE',
|
|
552
|
-
'SCRIPT',
|
|
553
|
-
'HTML',
|
|
554
|
-
'BODY',
|
|
555
|
-
'NOSCRIPT',
|
|
556
|
-
]);
|
|
557
|
-
if (!IGNORE_TAG_NAMES.has(parentTagName) && textContent) {
|
|
558
|
-
textContent = obfuscateText(textContent);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
return {
|
|
562
|
-
type: NodeType.Text,
|
|
563
|
-
textContent: textContent || '',
|
|
564
|
-
isStyle: isStyle,
|
|
565
|
-
rootId: rootId
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
function serializeElementNode(n, options) {
|
|
569
|
-
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;
|
|
570
|
-
var needBlock = _isBlockedElement(n, blockClass, blockSelector);
|
|
571
|
-
var tagName = getValidTagName(n);
|
|
572
|
-
var attributes = {};
|
|
573
|
-
var len = n.attributes.length;
|
|
574
|
-
for (var i = 0; i < len; i++) {
|
|
575
|
-
var attr = n.attributes[i];
|
|
576
|
-
attributes[attr.name] = transformAttribute(doc, tagName, attr.name, attr.value);
|
|
577
|
-
}
|
|
578
|
-
if (tagName === 'link' && inlineStylesheet) {
|
|
579
|
-
var stylesheet = Array.from(doc.styleSheets).find(function (s) {
|
|
580
|
-
return s.href === n.href;
|
|
581
|
-
});
|
|
582
|
-
var cssText = null;
|
|
583
|
-
if (stylesheet) {
|
|
584
|
-
cssText = getCssRulesString(stylesheet);
|
|
585
|
-
}
|
|
586
|
-
if (cssText) {
|
|
587
|
-
delete attributes.rel;
|
|
588
|
-
delete attributes.href;
|
|
589
|
-
attributes._cssText = absoluteToStylesheet(cssText, stylesheet.href);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
if (tagName === 'style' &&
|
|
593
|
-
n.sheet &&
|
|
594
|
-
!(n.innerText || n.textContent || '').trim().length) {
|
|
595
|
-
var cssText = getCssRulesString(n.sheet);
|
|
596
|
-
if (cssText) {
|
|
597
|
-
attributes._cssText = absoluteToStylesheet(cssText, getHref());
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
if (tagName === 'input' || tagName === 'textarea' || tagName === 'select') {
|
|
601
|
-
var value = n.value;
|
|
602
|
-
if (attributes.type !== 'radio' &&
|
|
603
|
-
attributes.type !== 'checkbox' &&
|
|
604
|
-
attributes.type !== 'submit' &&
|
|
605
|
-
attributes.type !== 'button' &&
|
|
606
|
-
value) {
|
|
607
|
-
attributes.value = maskInputValue({
|
|
608
|
-
type: attributes.type,
|
|
609
|
-
tagName: tagName,
|
|
610
|
-
value: value,
|
|
611
|
-
maskInputOptions: maskInputOptions,
|
|
612
|
-
maskInputFn: maskInputFn
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
else if (n.checked) {
|
|
616
|
-
attributes.checked = n.checked;
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
if (tagName === 'option') {
|
|
620
|
-
if (n.selected && !maskInputOptions['select']) {
|
|
621
|
-
attributes.selected = true;
|
|
622
|
-
}
|
|
623
|
-
else {
|
|
624
|
-
delete attributes.selected;
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
if (tagName === 'canvas' && recordCanvas) {
|
|
628
|
-
if (n.__context === '2d') {
|
|
629
|
-
if (!is2DCanvasBlank(n)) {
|
|
630
|
-
attributes.rr_dataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
else if (!('__context' in n)) {
|
|
634
|
-
var canvasDataURL = n.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
635
|
-
var blankCanvas = document.createElement('canvas');
|
|
636
|
-
blankCanvas.width = n.width;
|
|
637
|
-
blankCanvas.height = n.height;
|
|
638
|
-
var blankCanvasDataURL = blankCanvas.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
639
|
-
if (canvasDataURL !== blankCanvasDataURL) {
|
|
640
|
-
attributes.rr_dataURL = canvasDataURL;
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
if (tagName === 'img' && inlineImages) {
|
|
645
|
-
if (!canvasService) {
|
|
646
|
-
canvasService = doc.createElement('canvas');
|
|
647
|
-
canvasCtx = canvasService.getContext('2d');
|
|
648
|
-
}
|
|
649
|
-
var image_1 = n;
|
|
650
|
-
var oldValue_1 = image_1.crossOrigin;
|
|
651
|
-
image_1.crossOrigin = 'anonymous';
|
|
652
|
-
var recordInlineImage = function () {
|
|
653
|
-
try {
|
|
654
|
-
canvasService.width = image_1.naturalWidth;
|
|
655
|
-
canvasService.height = image_1.naturalHeight;
|
|
656
|
-
canvasCtx.drawImage(image_1, 0, 0);
|
|
657
|
-
attributes.rr_dataURL = canvasService.toDataURL(dataURLOptions.type, dataURLOptions.quality);
|
|
658
|
-
}
|
|
659
|
-
catch (err) {
|
|
660
|
-
console.warn("Cannot inline img src=" + image_1.currentSrc + "! Error: " + err);
|
|
661
|
-
}
|
|
662
|
-
oldValue_1
|
|
663
|
-
? (attributes.crossOrigin = oldValue_1)
|
|
664
|
-
: image_1.removeAttribute('crossorigin');
|
|
665
|
-
};
|
|
666
|
-
if (image_1.complete && image_1.naturalWidth !== 0)
|
|
667
|
-
recordInlineImage();
|
|
668
|
-
else
|
|
669
|
-
image_1.onload = recordInlineImage;
|
|
670
|
-
}
|
|
671
|
-
if (tagName === 'audio' || tagName === 'video') {
|
|
672
|
-
attributes.rr_mediaState = n.paused
|
|
673
|
-
? 'paused'
|
|
674
|
-
: 'played';
|
|
675
|
-
attributes.rr_mediaCurrentTime = n.currentTime;
|
|
676
|
-
}
|
|
677
|
-
if (!newlyAddedElement) {
|
|
678
|
-
if (n.scrollLeft) {
|
|
679
|
-
attributes.rr_scrollLeft = n.scrollLeft;
|
|
680
|
-
}
|
|
681
|
-
if (n.scrollTop) {
|
|
682
|
-
attributes.rr_scrollTop = n.scrollTop;
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
if (needBlock || (tagName === 'img' && enableStrictPrivacy)) {
|
|
686
|
-
var _d = n.getBoundingClientRect(), width = _d.width, height = _d.height;
|
|
687
|
-
attributes = {
|
|
688
|
-
"class": attributes["class"],
|
|
689
|
-
rr_width: width + "px",
|
|
690
|
-
rr_height: height + "px"
|
|
691
|
-
};
|
|
692
|
-
needBlock = true;
|
|
693
|
-
}
|
|
694
|
-
if (tagName === 'iframe' && !keepIframeSrcFn(attributes.src)) {
|
|
695
|
-
if (!n.contentDocument) {
|
|
696
|
-
attributes.rr_src = attributes.src;
|
|
697
|
-
}
|
|
698
|
-
delete attributes.src;
|
|
699
|
-
}
|
|
700
|
-
return {
|
|
701
|
-
type: NodeType.Element,
|
|
702
|
-
tagName: tagName,
|
|
703
|
-
attributes: attributes,
|
|
704
|
-
childNodes: [],
|
|
705
|
-
isSVG: isSVGElement(n) || undefined,
|
|
706
|
-
needBlock: needBlock,
|
|
707
|
-
rootId: rootId
|
|
708
|
-
};
|
|
709
|
-
}
|
|
710
|
-
function lowerIfExists(maybeAttr) {
|
|
711
|
-
if (maybeAttr === undefined) {
|
|
712
|
-
return '';
|
|
713
|
-
}
|
|
714
|
-
else {
|
|
715
|
-
return maybeAttr.toLowerCase();
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
function slimDOMExcluded(sn, slimDOMOptions) {
|
|
719
|
-
if (slimDOMOptions.comment && sn.type === NodeType.Comment) {
|
|
720
|
-
return true;
|
|
721
|
-
}
|
|
722
|
-
else if (sn.type === NodeType.Element) {
|
|
723
|
-
if (slimDOMOptions.script &&
|
|
724
|
-
(sn.tagName === 'script' ||
|
|
725
|
-
(sn.tagName === 'link' &&
|
|
726
|
-
sn.attributes.rel === 'preload' &&
|
|
727
|
-
sn.attributes.as === 'script') ||
|
|
728
|
-
(sn.tagName === 'link' &&
|
|
729
|
-
sn.attributes.rel === 'prefetch' &&
|
|
730
|
-
typeof sn.attributes.href === 'string' &&
|
|
731
|
-
sn.attributes.href.endsWith('.js')))) {
|
|
732
|
-
return true;
|
|
733
|
-
}
|
|
734
|
-
else if (slimDOMOptions.headFavicon &&
|
|
735
|
-
((sn.tagName === 'link' && sn.attributes.rel === 'shortcut icon') ||
|
|
736
|
-
(sn.tagName === 'meta' &&
|
|
737
|
-
(lowerIfExists(sn.attributes.name).match(/^msapplication-tile(image|color)$/) ||
|
|
738
|
-
lowerIfExists(sn.attributes.name) === 'application-name' ||
|
|
739
|
-
lowerIfExists(sn.attributes.rel) === 'icon' ||
|
|
740
|
-
lowerIfExists(sn.attributes.rel) === 'apple-touch-icon' ||
|
|
741
|
-
lowerIfExists(sn.attributes.rel) === 'shortcut icon')))) {
|
|
742
|
-
return true;
|
|
743
|
-
}
|
|
744
|
-
else if (sn.tagName === 'meta') {
|
|
745
|
-
if (slimDOMOptions.headMetaDescKeywords &&
|
|
746
|
-
lowerIfExists(sn.attributes.name).match(/^description|keywords$/)) {
|
|
747
|
-
return true;
|
|
748
|
-
}
|
|
749
|
-
else if (slimDOMOptions.headMetaSocial &&
|
|
750
|
-
(lowerIfExists(sn.attributes.property).match(/^(og|twitter|fb):/) ||
|
|
751
|
-
lowerIfExists(sn.attributes.name).match(/^(og|twitter):/) ||
|
|
752
|
-
lowerIfExists(sn.attributes.name) === 'pinterest')) {
|
|
753
|
-
return true;
|
|
754
|
-
}
|
|
755
|
-
else if (slimDOMOptions.headMetaRobots &&
|
|
756
|
-
(lowerIfExists(sn.attributes.name) === 'robots' ||
|
|
757
|
-
lowerIfExists(sn.attributes.name) === 'googlebot' ||
|
|
758
|
-
lowerIfExists(sn.attributes.name) === 'bingbot')) {
|
|
759
|
-
return true;
|
|
760
|
-
}
|
|
761
|
-
else if (slimDOMOptions.headMetaHttpEquiv &&
|
|
762
|
-
sn.attributes['http-equiv'] !== undefined) {
|
|
763
|
-
return true;
|
|
764
|
-
}
|
|
765
|
-
else if (slimDOMOptions.headMetaAuthorship &&
|
|
766
|
-
(lowerIfExists(sn.attributes.name) === 'author' ||
|
|
767
|
-
lowerIfExists(sn.attributes.name) === 'generator' ||
|
|
768
|
-
lowerIfExists(sn.attributes.name) === 'framework' ||
|
|
769
|
-
lowerIfExists(sn.attributes.name) === 'publisher' ||
|
|
770
|
-
lowerIfExists(sn.attributes.name) === 'progid' ||
|
|
771
|
-
lowerIfExists(sn.attributes.property).match(/^article:/) ||
|
|
772
|
-
lowerIfExists(sn.attributes.property).match(/^product:/))) {
|
|
773
|
-
return true;
|
|
774
|
-
}
|
|
775
|
-
else if (slimDOMOptions.headMetaVerification &&
|
|
776
|
-
(lowerIfExists(sn.attributes.name) === 'google-site-verification' ||
|
|
777
|
-
lowerIfExists(sn.attributes.name) === 'yandex-verification' ||
|
|
778
|
-
lowerIfExists(sn.attributes.name) === 'csrf-token' ||
|
|
779
|
-
lowerIfExists(sn.attributes.name) === 'p:domain_verify' ||
|
|
780
|
-
lowerIfExists(sn.attributes.name) === 'verify-v1' ||
|
|
781
|
-
lowerIfExists(sn.attributes.name) === 'verification' ||
|
|
782
|
-
lowerIfExists(sn.attributes.name) === 'shopify-checkout-api-token')) {
|
|
783
|
-
return true;
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
return false;
|
|
788
|
-
}
|
|
789
|
-
function serializeNodeWithId(n, options) {
|
|
790
|
-
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;
|
|
791
|
-
var _l = options.preserveWhiteSpace, preserveWhiteSpace = _l === void 0 ? true : _l;
|
|
792
|
-
var _serializedNode = serializeNode(n, {
|
|
793
|
-
doc: doc,
|
|
794
|
-
mirror: mirror,
|
|
795
|
-
blockClass: blockClass,
|
|
796
|
-
blockSelector: blockSelector,
|
|
797
|
-
maskTextClass: maskTextClass,
|
|
798
|
-
maskTextSelector: maskTextSelector,
|
|
799
|
-
inlineStylesheet: inlineStylesheet,
|
|
800
|
-
maskInputOptions: maskInputOptions,
|
|
801
|
-
maskTextFn: maskTextFn,
|
|
802
|
-
maskInputFn: maskInputFn,
|
|
803
|
-
dataURLOptions: dataURLOptions,
|
|
804
|
-
inlineImages: inlineImages,
|
|
805
|
-
recordCanvas: recordCanvas,
|
|
806
|
-
keepIframeSrcFn: keepIframeSrcFn,
|
|
807
|
-
newlyAddedElement: newlyAddedElement,
|
|
808
|
-
enableStrictPrivacy: enableStrictPrivacy
|
|
809
|
-
});
|
|
810
|
-
if (!_serializedNode) {
|
|
811
|
-
console.warn(n, 'not serialized');
|
|
812
|
-
return null;
|
|
813
|
-
}
|
|
814
|
-
var id;
|
|
815
|
-
if (mirror.hasNode(n)) {
|
|
816
|
-
id = mirror.getId(n);
|
|
817
|
-
}
|
|
818
|
-
else if (slimDOMExcluded(_serializedNode, slimDOMOptions) ||
|
|
819
|
-
(!preserveWhiteSpace &&
|
|
820
|
-
_serializedNode.type === NodeType.Text &&
|
|
821
|
-
!_serializedNode.isStyle &&
|
|
822
|
-
!_serializedNode.textContent.replace(/^\s+|\s+$/gm, '').length)) {
|
|
823
|
-
id = IGNORED_NODE;
|
|
824
|
-
}
|
|
825
|
-
else {
|
|
826
|
-
id = genId();
|
|
827
|
-
}
|
|
828
|
-
if (id === IGNORED_NODE) {
|
|
829
|
-
return null;
|
|
830
|
-
}
|
|
831
|
-
var serializedNode = Object.assign(_serializedNode, { id: id });
|
|
832
|
-
mirror.add(n, serializedNode);
|
|
833
|
-
if (onSerialize) {
|
|
834
|
-
onSerialize(n);
|
|
835
|
-
}
|
|
836
|
-
var recordChild = !skipChild;
|
|
837
|
-
if (serializedNode.type === NodeType.Element) {
|
|
838
|
-
recordChild = recordChild && !serializedNode.needBlock;
|
|
839
|
-
if (serializedNode.needBlock && serializedNode.tagName === 'img') {
|
|
840
|
-
var clone = n.cloneNode();
|
|
841
|
-
clone.src = '';
|
|
842
|
-
mirror.add(clone, serializedNode);
|
|
843
|
-
}
|
|
844
|
-
delete serializedNode.needBlock;
|
|
845
|
-
if (n.shadowRoot)
|
|
846
|
-
serializedNode.isShadowHost = true;
|
|
847
|
-
}
|
|
848
|
-
if ((serializedNode.type === NodeType.Document ||
|
|
849
|
-
serializedNode.type === NodeType.Element) &&
|
|
850
|
-
recordChild) {
|
|
851
|
-
if (slimDOMOptions.headWhitespace &&
|
|
852
|
-
serializedNode.type === NodeType.Element &&
|
|
853
|
-
serializedNode.tagName === 'head') {
|
|
854
|
-
preserveWhiteSpace = false;
|
|
855
|
-
}
|
|
856
|
-
var bypassOptions = {
|
|
857
|
-
doc: doc,
|
|
858
|
-
mirror: mirror,
|
|
859
|
-
blockClass: blockClass,
|
|
860
|
-
blockSelector: blockSelector,
|
|
861
|
-
maskTextClass: maskTextClass,
|
|
862
|
-
maskTextSelector: maskTextSelector,
|
|
863
|
-
skipChild: skipChild,
|
|
864
|
-
inlineStylesheet: inlineStylesheet,
|
|
865
|
-
maskInputOptions: maskInputOptions,
|
|
866
|
-
maskTextFn: maskTextFn,
|
|
867
|
-
maskInputFn: maskInputFn,
|
|
868
|
-
slimDOMOptions: slimDOMOptions,
|
|
869
|
-
dataURLOptions: dataURLOptions,
|
|
870
|
-
inlineImages: inlineImages,
|
|
871
|
-
recordCanvas: recordCanvas,
|
|
872
|
-
preserveWhiteSpace: preserveWhiteSpace,
|
|
873
|
-
onSerialize: onSerialize,
|
|
874
|
-
onIframeLoad: onIframeLoad,
|
|
875
|
-
iframeLoadTimeout: iframeLoadTimeout,
|
|
876
|
-
onStylesheetLoad: onStylesheetLoad,
|
|
877
|
-
stylesheetLoadTimeout: stylesheetLoadTimeout,
|
|
878
|
-
keepIframeSrcFn: keepIframeSrcFn,
|
|
879
|
-
enableStrictPrivacy: enableStrictPrivacy
|
|
880
|
-
};
|
|
881
|
-
for (var _i = 0, _m = Array.from(n.childNodes); _i < _m.length; _i++) {
|
|
882
|
-
var childN = _m[_i];
|
|
883
|
-
var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
884
|
-
if (serializedChildNode) {
|
|
885
|
-
serializedNode.childNodes.push(serializedChildNode);
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
if (isElement(n) && n.shadowRoot) {
|
|
889
|
-
for (var _o = 0, _p = Array.from(n.shadowRoot.childNodes); _o < _p.length; _o++) {
|
|
890
|
-
var childN = _p[_o];
|
|
891
|
-
var serializedChildNode = serializeNodeWithId(childN, bypassOptions);
|
|
892
|
-
if (serializedChildNode) {
|
|
893
|
-
serializedChildNode.isShadow = true;
|
|
894
|
-
serializedNode.childNodes.push(serializedChildNode);
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
if (n.parentNode && isShadowRoot(n.parentNode)) {
|
|
900
|
-
serializedNode.isShadow = true;
|
|
901
|
-
}
|
|
902
|
-
if (serializedNode.type === NodeType.Element &&
|
|
903
|
-
serializedNode.tagName === 'iframe') {
|
|
904
|
-
onceIframeLoaded(n, function () {
|
|
905
|
-
var iframeDoc = n.contentDocument;
|
|
906
|
-
if (iframeDoc && onIframeLoad) {
|
|
907
|
-
var serializedIframeNode = serializeNodeWithId(iframeDoc, {
|
|
908
|
-
doc: iframeDoc,
|
|
909
|
-
mirror: mirror,
|
|
910
|
-
blockClass: blockClass,
|
|
911
|
-
blockSelector: blockSelector,
|
|
912
|
-
maskTextClass: maskTextClass,
|
|
913
|
-
maskTextSelector: maskTextSelector,
|
|
914
|
-
skipChild: false,
|
|
915
|
-
inlineStylesheet: inlineStylesheet,
|
|
916
|
-
maskInputOptions: maskInputOptions,
|
|
917
|
-
maskTextFn: maskTextFn,
|
|
918
|
-
maskInputFn: maskInputFn,
|
|
919
|
-
slimDOMOptions: slimDOMOptions,
|
|
920
|
-
dataURLOptions: dataURLOptions,
|
|
921
|
-
inlineImages: inlineImages,
|
|
922
|
-
recordCanvas: recordCanvas,
|
|
923
|
-
preserveWhiteSpace: preserveWhiteSpace,
|
|
924
|
-
onSerialize: onSerialize,
|
|
925
|
-
onIframeLoad: onIframeLoad,
|
|
926
|
-
iframeLoadTimeout: iframeLoadTimeout,
|
|
927
|
-
keepIframeSrcFn: keepIframeSrcFn,
|
|
928
|
-
enableStrictPrivacy: enableStrictPrivacy
|
|
929
|
-
});
|
|
930
|
-
if (serializedIframeNode) {
|
|
931
|
-
onIframeLoad(n, serializedIframeNode);
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
}, iframeLoadTimeout);
|
|
935
|
-
}
|
|
936
|
-
if (serializedNode.type === NodeType.Element &&
|
|
937
|
-
serializedNode.tagName === 'link' &&
|
|
938
|
-
serializedNode.attributes.rel === 'stylesheet') {
|
|
939
|
-
onceStylesheetLoaded(n, function () {
|
|
940
|
-
if (onStylesheetLoad) {
|
|
941
|
-
var serializedLinkNode = serializeNodeWithId(n, {
|
|
942
|
-
doc: doc,
|
|
943
|
-
mirror: mirror,
|
|
944
|
-
blockClass: blockClass,
|
|
945
|
-
blockSelector: blockSelector,
|
|
946
|
-
maskTextClass: maskTextClass,
|
|
947
|
-
maskTextSelector: maskTextSelector,
|
|
948
|
-
skipChild: false,
|
|
949
|
-
inlineStylesheet: inlineStylesheet,
|
|
950
|
-
maskInputOptions: maskInputOptions,
|
|
951
|
-
maskTextFn: maskTextFn,
|
|
952
|
-
maskInputFn: maskInputFn,
|
|
953
|
-
slimDOMOptions: slimDOMOptions,
|
|
954
|
-
dataURLOptions: dataURLOptions,
|
|
955
|
-
inlineImages: inlineImages,
|
|
956
|
-
recordCanvas: recordCanvas,
|
|
957
|
-
preserveWhiteSpace: preserveWhiteSpace,
|
|
958
|
-
onSerialize: onSerialize,
|
|
959
|
-
onIframeLoad: onIframeLoad,
|
|
960
|
-
onStylesheetLoad: onStylesheetLoad,
|
|
961
|
-
iframeLoadTimeout: iframeLoadTimeout,
|
|
962
|
-
keepIframeSrcFn: keepIframeSrcFn,
|
|
963
|
-
enableStrictPrivacy: enableStrictPrivacy
|
|
964
|
-
});
|
|
965
|
-
if (serializedLinkNode) {
|
|
966
|
-
onStylesheetLoad(n, serializedLinkNode);
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
}, stylesheetLoadTimeout);
|
|
970
|
-
if (isStylesheetLoaded(n) === false)
|
|
971
|
-
return null;
|
|
972
|
-
}
|
|
973
|
-
return serializedNode;
|
|
974
|
-
}
|
|
975
|
-
function snapshot(n, options) {
|
|
976
|
-
var _a = options || {}, _b = _a.mirror, mirror = _b === void 0 ? new Mirror() : _b, _c = _a.blockClass, blockClass = _c === void 0 ? 'highlight-block' : _c, _d = _a.blockSelector, blockSelector = _d === void 0 ? null : _d, _e = _a.maskTextClass, maskTextClass = _e === void 0 ? 'highlight-mask' : _e, _f = _a.maskTextSelector, maskTextSelector = _f === void 0 ? null : _f, _g = _a.inlineStylesheet, inlineStylesheet = _g === void 0 ? true : _g, _h = _a.inlineImages, inlineImages = _h === void 0 ? false : _h, _j = _a.recordCanvas, recordCanvas = _j === void 0 ? false : _j, _k = _a.maskAllInputs, maskAllInputs = _k === void 0 ? false : _k, maskTextFn = _a.maskTextFn, maskInputFn = _a.maskInputFn, _l = _a.slimDOM, slimDOM = _l === void 0 ? false : _l, dataURLOptions = _a.dataURLOptions, preserveWhiteSpace = _a.preserveWhiteSpace, onSerialize = _a.onSerialize, onIframeLoad = _a.onIframeLoad, iframeLoadTimeout = _a.iframeLoadTimeout, onStylesheetLoad = _a.onStylesheetLoad, stylesheetLoadTimeout = _a.stylesheetLoadTimeout, _m = _a.keepIframeSrcFn, keepIframeSrcFn = _m === void 0 ? function () { return false; } : _m, _o = _a.enableStrictPrivacy, enableStrictPrivacy = _o === void 0 ? false : _o;
|
|
977
|
-
var maskInputOptions = maskAllInputs === true
|
|
978
|
-
? {
|
|
979
|
-
color: true,
|
|
980
|
-
date: true,
|
|
981
|
-
'datetime-local': true,
|
|
982
|
-
email: true,
|
|
983
|
-
month: true,
|
|
984
|
-
number: true,
|
|
985
|
-
range: true,
|
|
986
|
-
search: true,
|
|
987
|
-
tel: true,
|
|
988
|
-
text: true,
|
|
989
|
-
time: true,
|
|
990
|
-
url: true,
|
|
991
|
-
week: true,
|
|
992
|
-
textarea: true,
|
|
993
|
-
select: true,
|
|
994
|
-
password: true
|
|
995
|
-
}
|
|
996
|
-
: maskAllInputs === false
|
|
997
|
-
? {
|
|
998
|
-
password: true
|
|
999
|
-
}
|
|
1000
|
-
: maskAllInputs;
|
|
1001
|
-
var slimDOMOptions = slimDOM === true || slimDOM === 'all'
|
|
1002
|
-
?
|
|
1003
|
-
{
|
|
1004
|
-
script: true,
|
|
1005
|
-
comment: true,
|
|
1006
|
-
headFavicon: true,
|
|
1007
|
-
headWhitespace: true,
|
|
1008
|
-
headMetaDescKeywords: slimDOM === 'all',
|
|
1009
|
-
headMetaSocial: true,
|
|
1010
|
-
headMetaRobots: true,
|
|
1011
|
-
headMetaHttpEquiv: true,
|
|
1012
|
-
headMetaAuthorship: true,
|
|
1013
|
-
headMetaVerification: true
|
|
1014
|
-
}
|
|
1015
|
-
: slimDOM === false
|
|
1016
|
-
? {}
|
|
1017
|
-
: slimDOM;
|
|
1018
|
-
return serializeNodeWithId(n, {
|
|
1019
|
-
doc: n,
|
|
1020
|
-
mirror: mirror,
|
|
1021
|
-
blockClass: blockClass,
|
|
1022
|
-
blockSelector: blockSelector,
|
|
1023
|
-
maskTextClass: maskTextClass,
|
|
1024
|
-
maskTextSelector: maskTextSelector,
|
|
1025
|
-
skipChild: false,
|
|
1026
|
-
inlineStylesheet: inlineStylesheet,
|
|
1027
|
-
maskInputOptions: maskInputOptions,
|
|
1028
|
-
maskTextFn: maskTextFn,
|
|
1029
|
-
maskInputFn: maskInputFn,
|
|
1030
|
-
slimDOMOptions: slimDOMOptions,
|
|
1031
|
-
dataURLOptions: dataURLOptions,
|
|
1032
|
-
inlineImages: inlineImages,
|
|
1033
|
-
recordCanvas: recordCanvas,
|
|
1034
|
-
preserveWhiteSpace: preserveWhiteSpace,
|
|
1035
|
-
onSerialize: onSerialize,
|
|
1036
|
-
onIframeLoad: onIframeLoad,
|
|
1037
|
-
iframeLoadTimeout: iframeLoadTimeout,
|
|
1038
|
-
onStylesheetLoad: onStylesheetLoad,
|
|
1039
|
-
stylesheetLoadTimeout: stylesheetLoadTimeout,
|
|
1040
|
-
keepIframeSrcFn: keepIframeSrcFn,
|
|
1041
|
-
newlyAddedElement: false,
|
|
1042
|
-
enableStrictPrivacy: enableStrictPrivacy
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
|
-
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
1047
|
-
function parse(css, options) {
|
|
1048
|
-
if (options === void 0) { options = {}; }
|
|
1049
|
-
var lineno = 1;
|
|
1050
|
-
var column = 1;
|
|
1051
|
-
function updatePosition(str) {
|
|
1052
|
-
var lines = str.match(/\n/g);
|
|
1053
|
-
if (lines) {
|
|
1054
|
-
lineno += lines.length;
|
|
1055
|
-
}
|
|
1056
|
-
var i = str.lastIndexOf('\n');
|
|
1057
|
-
column = i === -1 ? column + str.length : str.length - i;
|
|
1058
|
-
}
|
|
1059
|
-
function position() {
|
|
1060
|
-
var start = { line: lineno, column: column };
|
|
1061
|
-
return function (node) {
|
|
1062
|
-
node.position = new Position(start);
|
|
1063
|
-
whitespace();
|
|
1064
|
-
return node;
|
|
1065
|
-
};
|
|
1066
|
-
}
|
|
1067
|
-
var Position = (function () {
|
|
1068
|
-
function Position(start) {
|
|
1069
|
-
this.start = start;
|
|
1070
|
-
this.end = { line: lineno, column: column };
|
|
1071
|
-
this.source = options.source;
|
|
1072
|
-
}
|
|
1073
|
-
return Position;
|
|
1074
|
-
}());
|
|
1075
|
-
Position.prototype.content = css;
|
|
1076
|
-
var errorsList = [];
|
|
1077
|
-
function error(msg) {
|
|
1078
|
-
var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
|
|
1079
|
-
err.reason = msg;
|
|
1080
|
-
err.filename = options.source;
|
|
1081
|
-
err.line = lineno;
|
|
1082
|
-
err.column = column;
|
|
1083
|
-
err.source = css;
|
|
1084
|
-
if (options.silent) {
|
|
1085
|
-
errorsList.push(err);
|
|
1086
|
-
}
|
|
1087
|
-
else {
|
|
1088
|
-
throw err;
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
function stylesheet() {
|
|
1092
|
-
var rulesList = rules();
|
|
1093
|
-
return {
|
|
1094
|
-
type: 'stylesheet',
|
|
1095
|
-
stylesheet: {
|
|
1096
|
-
source: options.source,
|
|
1097
|
-
rules: rulesList,
|
|
1098
|
-
parsingErrors: errorsList
|
|
1099
|
-
}
|
|
1100
|
-
};
|
|
1101
|
-
}
|
|
1102
|
-
function open() {
|
|
1103
|
-
return match(/^{\s*/);
|
|
1104
|
-
}
|
|
1105
|
-
function close() {
|
|
1106
|
-
return match(/^}/);
|
|
1107
|
-
}
|
|
1108
|
-
function rules() {
|
|
1109
|
-
var node;
|
|
1110
|
-
var rules = [];
|
|
1111
|
-
whitespace();
|
|
1112
|
-
comments(rules);
|
|
1113
|
-
while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {
|
|
1114
|
-
if (node !== false) {
|
|
1115
|
-
rules.push(node);
|
|
1116
|
-
comments(rules);
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
return rules;
|
|
1120
|
-
}
|
|
1121
|
-
function match(re) {
|
|
1122
|
-
var m = re.exec(css);
|
|
1123
|
-
if (!m) {
|
|
1124
|
-
return;
|
|
1125
|
-
}
|
|
1126
|
-
var str = m[0];
|
|
1127
|
-
updatePosition(str);
|
|
1128
|
-
css = css.slice(str.length);
|
|
1129
|
-
return m;
|
|
1130
|
-
}
|
|
1131
|
-
function whitespace() {
|
|
1132
|
-
match(/^\s*/);
|
|
1133
|
-
}
|
|
1134
|
-
function comments(rules) {
|
|
1135
|
-
if (rules === void 0) { rules = []; }
|
|
1136
|
-
var c;
|
|
1137
|
-
while ((c = comment())) {
|
|
1138
|
-
if (c !== false) {
|
|
1139
|
-
rules.push(c);
|
|
1140
|
-
}
|
|
1141
|
-
c = comment();
|
|
1142
|
-
}
|
|
1143
|
-
return rules;
|
|
1144
|
-
}
|
|
1145
|
-
function comment() {
|
|
1146
|
-
var pos = position();
|
|
1147
|
-
if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {
|
|
1148
|
-
return;
|
|
1149
|
-
}
|
|
1150
|
-
var i = 2;
|
|
1151
|
-
while ('' !== css.charAt(i) &&
|
|
1152
|
-
('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {
|
|
1153
|
-
++i;
|
|
1154
|
-
}
|
|
1155
|
-
i += 2;
|
|
1156
|
-
if ('' === css.charAt(i - 1)) {
|
|
1157
|
-
return error('End of comment missing');
|
|
1158
|
-
}
|
|
1159
|
-
var str = css.slice(2, i - 2);
|
|
1160
|
-
column += 2;
|
|
1161
|
-
updatePosition(str);
|
|
1162
|
-
css = css.slice(i);
|
|
1163
|
-
column += 2;
|
|
1164
|
-
return pos({
|
|
1165
|
-
type: 'comment',
|
|
1166
|
-
comment: str
|
|
1167
|
-
});
|
|
1168
|
-
}
|
|
1169
|
-
function selector() {
|
|
1170
|
-
var m = match(/^([^{]+)/);
|
|
1171
|
-
if (!m) {
|
|
1172
|
-
return;
|
|
1173
|
-
}
|
|
1174
|
-
return trim(m[0])
|
|
1175
|
-
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
|
|
1176
|
-
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (m) {
|
|
1177
|
-
return m.replace(/,/g, '\u200C');
|
|
1178
|
-
})
|
|
1179
|
-
.split(/\s*(?![^(]*\)),\s*/)
|
|
1180
|
-
.map(function (s) {
|
|
1181
|
-
return s.replace(/\u200C/g, ',');
|
|
1182
|
-
});
|
|
1183
|
-
}
|
|
1184
|
-
function declaration() {
|
|
1185
|
-
var pos = position();
|
|
1186
|
-
var propMatch = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
|
|
1187
|
-
if (!propMatch) {
|
|
1188
|
-
return;
|
|
1189
|
-
}
|
|
1190
|
-
var prop = trim(propMatch[0]);
|
|
1191
|
-
if (!match(/^:\s*/)) {
|
|
1192
|
-
return error("property missing ':'");
|
|
1193
|
-
}
|
|
1194
|
-
var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
|
|
1195
|
-
var ret = pos({
|
|
1196
|
-
type: 'declaration',
|
|
1197
|
-
property: prop.replace(commentre, ''),
|
|
1198
|
-
value: val ? trim(val[0]).replace(commentre, '') : ''
|
|
1199
|
-
});
|
|
1200
|
-
match(/^[;\s]*/);
|
|
1201
|
-
return ret;
|
|
1202
|
-
}
|
|
1203
|
-
function declarations() {
|
|
1204
|
-
var decls = [];
|
|
1205
|
-
if (!open()) {
|
|
1206
|
-
return error("missing '{'");
|
|
1207
|
-
}
|
|
1208
|
-
comments(decls);
|
|
1209
|
-
var decl;
|
|
1210
|
-
while ((decl = declaration())) {
|
|
1211
|
-
if (decl !== false) {
|
|
1212
|
-
decls.push(decl);
|
|
1213
|
-
comments(decls);
|
|
1214
|
-
}
|
|
1215
|
-
decl = declaration();
|
|
1216
|
-
}
|
|
1217
|
-
if (!close()) {
|
|
1218
|
-
return error("missing '}'");
|
|
1219
|
-
}
|
|
1220
|
-
return decls;
|
|
1221
|
-
}
|
|
1222
|
-
function keyframe() {
|
|
1223
|
-
var m;
|
|
1224
|
-
var vals = [];
|
|
1225
|
-
var pos = position();
|
|
1226
|
-
while ((m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/))) {
|
|
1227
|
-
vals.push(m[1]);
|
|
1228
|
-
match(/^,\s*/);
|
|
1229
|
-
}
|
|
1230
|
-
if (!vals.length) {
|
|
1231
|
-
return;
|
|
1232
|
-
}
|
|
1233
|
-
return pos({
|
|
1234
|
-
type: 'keyframe',
|
|
1235
|
-
values: vals,
|
|
1236
|
-
declarations: declarations()
|
|
1237
|
-
});
|
|
1238
|
-
}
|
|
1239
|
-
function atkeyframes() {
|
|
1240
|
-
var pos = position();
|
|
1241
|
-
var m = match(/^@([-\w]+)?keyframes\s*/);
|
|
1242
|
-
if (!m) {
|
|
1243
|
-
return;
|
|
1244
|
-
}
|
|
1245
|
-
var vendor = m[1];
|
|
1246
|
-
m = match(/^([-\w]+)\s*/);
|
|
1247
|
-
if (!m) {
|
|
1248
|
-
return error('@keyframes missing name');
|
|
1249
|
-
}
|
|
1250
|
-
var name = m[1];
|
|
1251
|
-
if (!open()) {
|
|
1252
|
-
return error("@keyframes missing '{'");
|
|
1253
|
-
}
|
|
1254
|
-
var frame;
|
|
1255
|
-
var frames = comments();
|
|
1256
|
-
while ((frame = keyframe())) {
|
|
1257
|
-
frames.push(frame);
|
|
1258
|
-
frames = frames.concat(comments());
|
|
1259
|
-
}
|
|
1260
|
-
if (!close()) {
|
|
1261
|
-
return error("@keyframes missing '}'");
|
|
1262
|
-
}
|
|
1263
|
-
return pos({
|
|
1264
|
-
type: 'keyframes',
|
|
1265
|
-
name: name,
|
|
1266
|
-
vendor: vendor,
|
|
1267
|
-
keyframes: frames
|
|
1268
|
-
});
|
|
1269
|
-
}
|
|
1270
|
-
function atsupports() {
|
|
1271
|
-
var pos = position();
|
|
1272
|
-
var m = match(/^@supports *([^{]+)/);
|
|
1273
|
-
if (!m) {
|
|
1274
|
-
return;
|
|
1275
|
-
}
|
|
1276
|
-
var supports = trim(m[1]);
|
|
1277
|
-
if (!open()) {
|
|
1278
|
-
return error("@supports missing '{'");
|
|
1279
|
-
}
|
|
1280
|
-
var style = comments().concat(rules());
|
|
1281
|
-
if (!close()) {
|
|
1282
|
-
return error("@supports missing '}'");
|
|
1283
|
-
}
|
|
1284
|
-
return pos({
|
|
1285
|
-
type: 'supports',
|
|
1286
|
-
supports: supports,
|
|
1287
|
-
rules: style
|
|
1288
|
-
});
|
|
1289
|
-
}
|
|
1290
|
-
function athost() {
|
|
1291
|
-
var pos = position();
|
|
1292
|
-
var m = match(/^@host\s*/);
|
|
1293
|
-
if (!m) {
|
|
1294
|
-
return;
|
|
1295
|
-
}
|
|
1296
|
-
if (!open()) {
|
|
1297
|
-
return error("@host missing '{'");
|
|
1298
|
-
}
|
|
1299
|
-
var style = comments().concat(rules());
|
|
1300
|
-
if (!close()) {
|
|
1301
|
-
return error("@host missing '}'");
|
|
1302
|
-
}
|
|
1303
|
-
return pos({
|
|
1304
|
-
type: 'host',
|
|
1305
|
-
rules: style
|
|
1306
|
-
});
|
|
1307
|
-
}
|
|
1308
|
-
function atmedia() {
|
|
1309
|
-
var pos = position();
|
|
1310
|
-
var m = match(/^@media *([^{]+)/);
|
|
1311
|
-
if (!m) {
|
|
1312
|
-
return;
|
|
1313
|
-
}
|
|
1314
|
-
var media = trim(m[1]);
|
|
1315
|
-
if (!open()) {
|
|
1316
|
-
return error("@media missing '{'");
|
|
1317
|
-
}
|
|
1318
|
-
var style = comments().concat(rules());
|
|
1319
|
-
if (!close()) {
|
|
1320
|
-
return error("@media missing '}'");
|
|
1321
|
-
}
|
|
1322
|
-
return pos({
|
|
1323
|
-
type: 'media',
|
|
1324
|
-
media: media,
|
|
1325
|
-
rules: style
|
|
1326
|
-
});
|
|
1327
|
-
}
|
|
1328
|
-
function atcustommedia() {
|
|
1329
|
-
var pos = position();
|
|
1330
|
-
var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
|
|
1331
|
-
if (!m) {
|
|
1332
|
-
return;
|
|
1333
|
-
}
|
|
1334
|
-
return pos({
|
|
1335
|
-
type: 'custom-media',
|
|
1336
|
-
name: trim(m[1]),
|
|
1337
|
-
media: trim(m[2])
|
|
1338
|
-
});
|
|
1339
|
-
}
|
|
1340
|
-
function atpage() {
|
|
1341
|
-
var pos = position();
|
|
1342
|
-
var m = match(/^@page */);
|
|
1343
|
-
if (!m) {
|
|
1344
|
-
return;
|
|
1345
|
-
}
|
|
1346
|
-
var sel = selector() || [];
|
|
1347
|
-
if (!open()) {
|
|
1348
|
-
return error("@page missing '{'");
|
|
1349
|
-
}
|
|
1350
|
-
var decls = comments();
|
|
1351
|
-
var decl;
|
|
1352
|
-
while ((decl = declaration())) {
|
|
1353
|
-
decls.push(decl);
|
|
1354
|
-
decls = decls.concat(comments());
|
|
1355
|
-
}
|
|
1356
|
-
if (!close()) {
|
|
1357
|
-
return error("@page missing '}'");
|
|
1358
|
-
}
|
|
1359
|
-
return pos({
|
|
1360
|
-
type: 'page',
|
|
1361
|
-
selectors: sel,
|
|
1362
|
-
declarations: decls
|
|
1363
|
-
});
|
|
1364
|
-
}
|
|
1365
|
-
function atdocument() {
|
|
1366
|
-
var pos = position();
|
|
1367
|
-
var m = match(/^@([-\w]+)?document *([^{]+)/);
|
|
1368
|
-
if (!m) {
|
|
1369
|
-
return;
|
|
1370
|
-
}
|
|
1371
|
-
var vendor = trim(m[1]);
|
|
1372
|
-
var doc = trim(m[2]);
|
|
1373
|
-
if (!open()) {
|
|
1374
|
-
return error("@document missing '{'");
|
|
1375
|
-
}
|
|
1376
|
-
var style = comments().concat(rules());
|
|
1377
|
-
if (!close()) {
|
|
1378
|
-
return error("@document missing '}'");
|
|
1379
|
-
}
|
|
1380
|
-
return pos({
|
|
1381
|
-
type: 'document',
|
|
1382
|
-
document: doc,
|
|
1383
|
-
vendor: vendor,
|
|
1384
|
-
rules: style
|
|
1385
|
-
});
|
|
1386
|
-
}
|
|
1387
|
-
function atfontface() {
|
|
1388
|
-
var pos = position();
|
|
1389
|
-
var m = match(/^@font-face\s*/);
|
|
1390
|
-
if (!m) {
|
|
1391
|
-
return;
|
|
1392
|
-
}
|
|
1393
|
-
if (!open()) {
|
|
1394
|
-
return error("@font-face missing '{'");
|
|
1395
|
-
}
|
|
1396
|
-
var decls = comments();
|
|
1397
|
-
var decl;
|
|
1398
|
-
while ((decl = declaration())) {
|
|
1399
|
-
decls.push(decl);
|
|
1400
|
-
decls = decls.concat(comments());
|
|
1401
|
-
}
|
|
1402
|
-
if (!close()) {
|
|
1403
|
-
return error("@font-face missing '}'");
|
|
1404
|
-
}
|
|
1405
|
-
return pos({
|
|
1406
|
-
type: 'font-face',
|
|
1407
|
-
declarations: decls
|
|
1408
|
-
});
|
|
1409
|
-
}
|
|
1410
|
-
var atimport = _compileAtrule('import');
|
|
1411
|
-
var atcharset = _compileAtrule('charset');
|
|
1412
|
-
var atnamespace = _compileAtrule('namespace');
|
|
1413
|
-
function _compileAtrule(name) {
|
|
1414
|
-
var re = new RegExp('^@' + name + '\\s*([^;]+);');
|
|
1415
|
-
return function () {
|
|
1416
|
-
var pos = position();
|
|
1417
|
-
var m = match(re);
|
|
1418
|
-
if (!m) {
|
|
1419
|
-
return;
|
|
1420
|
-
}
|
|
1421
|
-
var ret = { type: name };
|
|
1422
|
-
ret[name] = m[1].trim();
|
|
1423
|
-
return pos(ret);
|
|
1424
|
-
};
|
|
1425
|
-
}
|
|
1426
|
-
function atrule() {
|
|
1427
|
-
if (css[0] !== '@') {
|
|
1428
|
-
return;
|
|
1429
|
-
}
|
|
1430
|
-
return (atkeyframes() ||
|
|
1431
|
-
atmedia() ||
|
|
1432
|
-
atcustommedia() ||
|
|
1433
|
-
atsupports() ||
|
|
1434
|
-
atimport() ||
|
|
1435
|
-
atcharset() ||
|
|
1436
|
-
atnamespace() ||
|
|
1437
|
-
atdocument() ||
|
|
1438
|
-
atpage() ||
|
|
1439
|
-
athost() ||
|
|
1440
|
-
atfontface());
|
|
1441
|
-
}
|
|
1442
|
-
function rule() {
|
|
1443
|
-
var pos = position();
|
|
1444
|
-
var sel = selector();
|
|
1445
|
-
if (!sel) {
|
|
1446
|
-
return error('selector missing');
|
|
1447
|
-
}
|
|
1448
|
-
comments();
|
|
1449
|
-
return pos({
|
|
1450
|
-
type: 'rule',
|
|
1451
|
-
selectors: sel,
|
|
1452
|
-
declarations: declarations()
|
|
1453
|
-
});
|
|
1454
|
-
}
|
|
1455
|
-
return addParent(stylesheet());
|
|
1456
|
-
}
|
|
1457
|
-
function trim(str) {
|
|
1458
|
-
return str ? str.replace(/^\s+|\s+$/g, '') : '';
|
|
1459
|
-
}
|
|
1460
|
-
function addParent(obj, parent) {
|
|
1461
|
-
var isNode = obj && typeof obj.type === 'string';
|
|
1462
|
-
var childParent = isNode ? obj : parent;
|
|
1463
|
-
for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {
|
|
1464
|
-
var k = _a[_i];
|
|
1465
|
-
var value = obj[k];
|
|
1466
|
-
if (Array.isArray(value)) {
|
|
1467
|
-
value.forEach(function (v) {
|
|
1468
|
-
addParent(v, childParent);
|
|
1469
|
-
});
|
|
1470
|
-
}
|
|
1471
|
-
else if (value && typeof value === 'object') {
|
|
1472
|
-
addParent(value, childParent);
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
if (isNode) {
|
|
1476
|
-
Object.defineProperty(obj, 'parent', {
|
|
1477
|
-
configurable: true,
|
|
1478
|
-
writable: true,
|
|
1479
|
-
enumerable: false,
|
|
1480
|
-
value: parent || null
|
|
1481
|
-
});
|
|
1482
|
-
}
|
|
1483
|
-
return obj;
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
var tagMap = {
|
|
1487
|
-
script: 'noscript',
|
|
1488
|
-
altglyph: 'altGlyph',
|
|
1489
|
-
altglyphdef: 'altGlyphDef',
|
|
1490
|
-
altglyphitem: 'altGlyphItem',
|
|
1491
|
-
animatecolor: 'animateColor',
|
|
1492
|
-
animatemotion: 'animateMotion',
|
|
1493
|
-
animatetransform: 'animateTransform',
|
|
1494
|
-
clippath: 'clipPath',
|
|
1495
|
-
feblend: 'feBlend',
|
|
1496
|
-
fecolormatrix: 'feColorMatrix',
|
|
1497
|
-
fecomponenttransfer: 'feComponentTransfer',
|
|
1498
|
-
fecomposite: 'feComposite',
|
|
1499
|
-
feconvolvematrix: 'feConvolveMatrix',
|
|
1500
|
-
fediffuselighting: 'feDiffuseLighting',
|
|
1501
|
-
fedisplacementmap: 'feDisplacementMap',
|
|
1502
|
-
fedistantlight: 'feDistantLight',
|
|
1503
|
-
fedropshadow: 'feDropShadow',
|
|
1504
|
-
feflood: 'feFlood',
|
|
1505
|
-
fefunca: 'feFuncA',
|
|
1506
|
-
fefuncb: 'feFuncB',
|
|
1507
|
-
fefuncg: 'feFuncG',
|
|
1508
|
-
fefuncr: 'feFuncR',
|
|
1509
|
-
fegaussianblur: 'feGaussianBlur',
|
|
1510
|
-
feimage: 'feImage',
|
|
1511
|
-
femerge: 'feMerge',
|
|
1512
|
-
femergenode: 'feMergeNode',
|
|
1513
|
-
femorphology: 'feMorphology',
|
|
1514
|
-
feoffset: 'feOffset',
|
|
1515
|
-
fepointlight: 'fePointLight',
|
|
1516
|
-
fespecularlighting: 'feSpecularLighting',
|
|
1517
|
-
fespotlight: 'feSpotLight',
|
|
1518
|
-
fetile: 'feTile',
|
|
1519
|
-
feturbulence: 'feTurbulence',
|
|
1520
|
-
foreignobject: 'foreignObject',
|
|
1521
|
-
glyphref: 'glyphRef',
|
|
1522
|
-
lineargradient: 'linearGradient',
|
|
1523
|
-
radialgradient: 'radialGradient'
|
|
1524
|
-
};
|
|
1525
|
-
function getTagName(n) {
|
|
1526
|
-
var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;
|
|
1527
|
-
if (tagName === 'link' && n.attributes._cssText) {
|
|
1528
|
-
tagName = 'style';
|
|
1529
|
-
}
|
|
1530
|
-
return tagName;
|
|
1531
|
-
}
|
|
1532
|
-
function escapeRegExp(str) {
|
|
1533
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1534
|
-
}
|
|
1535
|
-
var HOVER_SELECTOR = /([^\\]):hover/;
|
|
1536
|
-
var HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');
|
|
1537
|
-
function addHoverClass(cssText, cache) {
|
|
1538
|
-
var _a;
|
|
1539
|
-
if (!((_a = window === null || window === void 0 ? void 0 : window.HIG_CONFIGURATION) === null || _a === void 0 ? void 0 : _a.enableOnHoverClass)) {
|
|
1540
|
-
return cssText;
|
|
1541
|
-
}
|
|
1542
|
-
var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);
|
|
1543
|
-
if (cachedStyle)
|
|
1544
|
-
return cachedStyle;
|
|
1545
|
-
var ast = parse(cssText, {
|
|
1546
|
-
silent: true
|
|
1547
|
-
});
|
|
1548
|
-
if (!ast.stylesheet) {
|
|
1549
|
-
return cssText;
|
|
1550
|
-
}
|
|
1551
|
-
var selectors = [];
|
|
1552
|
-
ast.stylesheet.rules.forEach(function (rule) {
|
|
1553
|
-
if ('selectors' in rule) {
|
|
1554
|
-
(rule.selectors || []).forEach(function (selector) {
|
|
1555
|
-
if (HOVER_SELECTOR.test(selector)) {
|
|
1556
|
-
selectors.push(selector);
|
|
1557
|
-
}
|
|
1558
|
-
});
|
|
1559
|
-
}
|
|
1560
|
-
});
|
|
1561
|
-
if (selectors.length === 0) {
|
|
1562
|
-
return cssText;
|
|
1563
|
-
}
|
|
1564
|
-
var selectorMatcher = new RegExp(selectors
|
|
1565
|
-
.filter(function (selector, index) { return selectors.indexOf(selector) === index; })
|
|
1566
|
-
.sort(function (a, b) { return b.length - a.length; })
|
|
1567
|
-
.map(function (selector) {
|
|
1568
|
-
return escapeRegExp(selector);
|
|
1569
|
-
})
|
|
1570
|
-
.join('|'), 'g');
|
|
1571
|
-
var result = cssText.replace(selectorMatcher, function (selector) {
|
|
1572
|
-
var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\:hover');
|
|
1573
|
-
return selector + ", " + newSelector;
|
|
1574
|
-
});
|
|
1575
|
-
cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);
|
|
1576
|
-
return result;
|
|
1577
|
-
}
|
|
1578
|
-
function createCache() {
|
|
1579
|
-
var stylesWithHoverClass = new Map();
|
|
1580
|
-
return {
|
|
1581
|
-
stylesWithHoverClass: stylesWithHoverClass
|
|
1582
|
-
};
|
|
1583
|
-
}
|
|
1584
|
-
function buildNode(n, options) {
|
|
1585
|
-
var doc = options.doc, hackCss = options.hackCss, cache = options.cache;
|
|
1586
|
-
switch (n.type) {
|
|
1587
|
-
case NodeType.Document:
|
|
1588
|
-
return doc.implementation.createDocument(null, '', null);
|
|
1589
|
-
case NodeType.DocumentType:
|
|
1590
|
-
return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);
|
|
1591
|
-
case NodeType.Element:
|
|
1592
|
-
var tagName = getTagName(n);
|
|
1593
|
-
var node_1;
|
|
1594
|
-
if (n.isSVG) {
|
|
1595
|
-
node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);
|
|
1596
|
-
}
|
|
1597
|
-
else {
|
|
1598
|
-
node_1 = doc.createElement(tagName);
|
|
1599
|
-
}
|
|
1600
|
-
var _loop_1 = function (name_1) {
|
|
1601
|
-
if (!n.attributes.hasOwnProperty(name_1)) {
|
|
1602
|
-
return "continue";
|
|
1603
|
-
}
|
|
1604
|
-
var value = n.attributes[name_1];
|
|
1605
|
-
if (tagName === 'option' && name_1 === 'selected' && value === false) {
|
|
1606
|
-
return "continue";
|
|
1607
|
-
}
|
|
1608
|
-
value =
|
|
1609
|
-
typeof value === 'boolean' || typeof value === 'number' ? '' : value;
|
|
1610
|
-
if (!name_1.startsWith('rr_')) {
|
|
1611
|
-
var isTextarea = tagName === 'textarea' && name_1 === 'value';
|
|
1612
|
-
var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';
|
|
1613
|
-
if (isRemoteOrDynamicCss && hackCss) {
|
|
1614
|
-
value = addHoverClass(value, cache);
|
|
1615
|
-
if (typeof value === 'string') {
|
|
1616
|
-
var regex = /url\(\"https:\/\/\S*(.eot|.woff2|.ttf|.woff)\S*\"\)/gm;
|
|
1617
|
-
var m = void 0;
|
|
1618
|
-
var fontUrls_1 = [];
|
|
1619
|
-
var PROXY_URL_1 = 'https://replay-cors-proxy.highlightrun.workers.dev';
|
|
1620
|
-
while ((m = regex.exec(value)) !== null) {
|
|
1621
|
-
if (m.index === regex.lastIndex) {
|
|
1622
|
-
regex.lastIndex++;
|
|
1623
|
-
}
|
|
1624
|
-
m.forEach(function (match, groupIndex) {
|
|
1625
|
-
if (groupIndex === 0) {
|
|
1626
|
-
var url = match.slice(5, match.length - 2);
|
|
1627
|
-
fontUrls_1.push({
|
|
1628
|
-
originalUrl: url,
|
|
1629
|
-
proxyUrl: url.replace(url, PROXY_URL_1 + "?url=" + url)
|
|
1630
|
-
});
|
|
1631
|
-
}
|
|
1632
|
-
});
|
|
1633
|
-
}
|
|
1634
|
-
fontUrls_1.forEach(function (urlPair) {
|
|
1635
|
-
value = value.replace(urlPair.originalUrl, urlPair.proxyUrl);
|
|
1636
|
-
});
|
|
1637
|
-
}
|
|
1638
|
-
}
|
|
1639
|
-
if (isTextarea || isRemoteOrDynamicCss) {
|
|
1640
|
-
var child = doc.createTextNode(value);
|
|
1641
|
-
for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {
|
|
1642
|
-
var c = _a[_i];
|
|
1643
|
-
if (c.nodeType === node_1.TEXT_NODE) {
|
|
1644
|
-
node_1.removeChild(c);
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
node_1.appendChild(child);
|
|
1648
|
-
return "continue";
|
|
1649
|
-
}
|
|
1650
|
-
try {
|
|
1651
|
-
if (n.isSVG && name_1 === 'xlink:href') {
|
|
1652
|
-
node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);
|
|
1653
|
-
}
|
|
1654
|
-
else if (name_1 === 'onload' ||
|
|
1655
|
-
name_1 === 'onclick' ||
|
|
1656
|
-
name_1.substring(0, 7) === 'onmouse') {
|
|
1657
|
-
node_1.setAttribute('_' + name_1, value);
|
|
1658
|
-
}
|
|
1659
|
-
else if (tagName === 'meta' &&
|
|
1660
|
-
n.attributes['http-equiv'] === 'Content-Security-Policy' &&
|
|
1661
|
-
name_1 === 'content') {
|
|
1662
|
-
node_1.setAttribute('csp-content', value);
|
|
1663
|
-
return "continue";
|
|
1664
|
-
}
|
|
1665
|
-
else if (tagName === 'link' &&
|
|
1666
|
-
n.attributes.rel === 'preload' &&
|
|
1667
|
-
n.attributes.as === 'script') {
|
|
1668
|
-
}
|
|
1669
|
-
else if (tagName === 'link' &&
|
|
1670
|
-
n.attributes.rel === 'prefetch' &&
|
|
1671
|
-
typeof n.attributes.href === 'string' &&
|
|
1672
|
-
n.attributes.href.endsWith('.js')) {
|
|
1673
|
-
}
|
|
1674
|
-
else if (tagName === 'img' &&
|
|
1675
|
-
n.attributes.srcset &&
|
|
1676
|
-
n.attributes.rr_dataURL) {
|
|
1677
|
-
node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);
|
|
1678
|
-
}
|
|
1679
|
-
else {
|
|
1680
|
-
node_1.setAttribute(name_1, value);
|
|
1681
|
-
}
|
|
1682
|
-
}
|
|
1683
|
-
catch (error) {
|
|
1684
|
-
}
|
|
1685
|
-
}
|
|
1686
|
-
else {
|
|
1687
|
-
if (tagName === 'canvas' && name_1 === 'rr_dataURL') {
|
|
1688
|
-
var image_1 = document.createElement('img');
|
|
1689
|
-
image_1.src = value;
|
|
1690
|
-
image_1.onload = function () {
|
|
1691
|
-
var ctx = node_1.getContext('2d');
|
|
1692
|
-
if (ctx) {
|
|
1693
|
-
ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);
|
|
1694
|
-
}
|
|
1695
|
-
};
|
|
1696
|
-
}
|
|
1697
|
-
else if (tagName === 'img' && name_1 === 'rr_dataURL') {
|
|
1698
|
-
var image = node_1;
|
|
1699
|
-
if (!image.currentSrc.startsWith('data:')) {
|
|
1700
|
-
image.setAttribute('rrweb-original-src', n.attributes.src);
|
|
1701
|
-
image.src = value;
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1704
|
-
if (name_1 === 'rr_width') {
|
|
1705
|
-
node_1.style.width = value;
|
|
1706
|
-
}
|
|
1707
|
-
else if (name_1 === 'rr_height') {
|
|
1708
|
-
node_1.style.height = value;
|
|
1709
|
-
}
|
|
1710
|
-
else if (name_1 === 'rr_mediaCurrentTime') {
|
|
1711
|
-
node_1.currentTime = n.attributes
|
|
1712
|
-
.rr_mediaCurrentTime;
|
|
1713
|
-
}
|
|
1714
|
-
else if (name_1 === 'rr_mediaState') {
|
|
1715
|
-
switch (value) {
|
|
1716
|
-
case 'played':
|
|
1717
|
-
node_1
|
|
1718
|
-
.play()["catch"](function (e) { return console.warn('media playback error', e); });
|
|
1719
|
-
break;
|
|
1720
|
-
case 'paused':
|
|
1721
|
-
node_1.pause();
|
|
1722
|
-
break;
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
}
|
|
1726
|
-
};
|
|
1727
|
-
for (var name_1 in n.attributes) {
|
|
1728
|
-
_loop_1(name_1);
|
|
1729
|
-
}
|
|
1730
|
-
if (n.isShadowHost) {
|
|
1731
|
-
if (!node_1.shadowRoot) {
|
|
1732
|
-
node_1.attachShadow({ mode: 'open' });
|
|
1733
|
-
}
|
|
1734
|
-
else {
|
|
1735
|
-
while (node_1.shadowRoot.firstChild) {
|
|
1736
|
-
node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);
|
|
1737
|
-
}
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
return node_1;
|
|
1741
|
-
case NodeType.Text:
|
|
1742
|
-
return doc.createTextNode(n.isStyle && hackCss
|
|
1743
|
-
? addHoverClass(n.textContent, cache)
|
|
1744
|
-
: n.textContent);
|
|
1745
|
-
case NodeType.CDATA:
|
|
1746
|
-
return doc.createCDATASection(n.textContent);
|
|
1747
|
-
case NodeType.Comment:
|
|
1748
|
-
return doc.createComment(n.textContent);
|
|
1749
|
-
default:
|
|
1750
|
-
return null;
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
function buildNodeWithSN(n, options) {
|
|
1754
|
-
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;
|
|
1755
|
-
var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });
|
|
1756
|
-
if (!node) {
|
|
1757
|
-
return null;
|
|
1758
|
-
}
|
|
1759
|
-
if (n.rootId) {
|
|
1760
|
-
console.assert(mirror.getNode(n.rootId) === doc, 'Target document should have the same root id.');
|
|
1761
|
-
}
|
|
1762
|
-
if (n.type === NodeType.Document) {
|
|
1763
|
-
doc.close();
|
|
1764
|
-
doc.open();
|
|
1765
|
-
if (n.compatMode === 'BackCompat' &&
|
|
1766
|
-
n.childNodes &&
|
|
1767
|
-
n.childNodes[0].type !== NodeType.DocumentType) {
|
|
1768
|
-
if (n.childNodes[0].type === NodeType.Element &&
|
|
1769
|
-
'xmlns' in n.childNodes[0].attributes &&
|
|
1770
|
-
n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {
|
|
1771
|
-
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">');
|
|
1772
|
-
}
|
|
1773
|
-
else {
|
|
1774
|
-
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">');
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
|
-
node = doc;
|
|
1778
|
-
}
|
|
1779
|
-
mirror.add(node, n);
|
|
1780
|
-
if ((n.type === NodeType.Document || n.type === NodeType.Element) &&
|
|
1781
|
-
!skipChild) {
|
|
1782
|
-
for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {
|
|
1783
|
-
var childN = _c[_i];
|
|
1784
|
-
var childNode = buildNodeWithSN(childN, {
|
|
1785
|
-
doc: doc,
|
|
1786
|
-
mirror: mirror,
|
|
1787
|
-
skipChild: false,
|
|
1788
|
-
hackCss: hackCss,
|
|
1789
|
-
afterAppend: afterAppend,
|
|
1790
|
-
cache: cache
|
|
1791
|
-
});
|
|
1792
|
-
if (!childNode) {
|
|
1793
|
-
console.warn('Failed to rebuild', childN);
|
|
1794
|
-
continue;
|
|
1795
|
-
}
|
|
1796
|
-
if (childN.isShadow && isElement(node) && node.shadowRoot) {
|
|
1797
|
-
node.shadowRoot.appendChild(childNode);
|
|
1798
|
-
}
|
|
1799
|
-
else {
|
|
1800
|
-
node.appendChild(childNode);
|
|
1801
|
-
}
|
|
1802
|
-
if (afterAppend) {
|
|
1803
|
-
afterAppend(childNode);
|
|
1804
|
-
}
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
return node;
|
|
1808
|
-
}
|
|
1809
|
-
function visit(mirror, onVisit) {
|
|
1810
|
-
function walk(node) {
|
|
1811
|
-
onVisit(node);
|
|
1812
|
-
}
|
|
1813
|
-
for (var _i = 0, _a = mirror.getIds(); _i < _a.length; _i++) {
|
|
1814
|
-
var id = _a[_i];
|
|
1815
|
-
if (mirror.has(id)) {
|
|
1816
|
-
walk(mirror.getNode(id));
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1819
|
-
}
|
|
1820
|
-
function handleScroll(node, mirror) {
|
|
1821
|
-
var n = mirror.getMeta(node);
|
|
1822
|
-
if ((n === null || n === void 0 ? void 0 : n.type) !== NodeType.Element) {
|
|
1823
|
-
return;
|
|
1824
|
-
}
|
|
1825
|
-
var el = node;
|
|
1826
|
-
for (var name_2 in n.attributes) {
|
|
1827
|
-
if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {
|
|
1828
|
-
continue;
|
|
1829
|
-
}
|
|
1830
|
-
var value = n.attributes[name_2];
|
|
1831
|
-
if (name_2 === 'rr_scrollLeft') {
|
|
1832
|
-
el.scrollLeft = value;
|
|
1833
|
-
}
|
|
1834
|
-
if (name_2 === 'rr_scrollTop') {
|
|
1835
|
-
el.scrollTop = value;
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1839
|
-
function rebuild(n, options) {
|
|
1840
|
-
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() : _b;
|
|
1841
|
-
var node = buildNodeWithSN(n, {
|
|
1842
|
-
doc: doc,
|
|
1843
|
-
mirror: mirror,
|
|
1844
|
-
skipChild: false,
|
|
1845
|
-
hackCss: hackCss,
|
|
1846
|
-
afterAppend: afterAppend,
|
|
1847
|
-
cache: cache
|
|
1848
|
-
});
|
|
1849
|
-
visit(mirror, function (visitedNode) {
|
|
1850
|
-
if (onVisit) {
|
|
1851
|
-
onVisit(visitedNode);
|
|
1852
|
-
}
|
|
1853
|
-
handleScroll(visitedNode, mirror);
|
|
1854
|
-
});
|
|
1855
|
-
return node;
|
|
1856
|
-
}
|
|
1857
|
-
|
|
1858
|
-
export { IGNORED_NODE, Mirror, NodeType, addHoverClass, buildNodeWithSN, classMatchesRegex, createCache, createMirror, is2DCanvasBlank, isElement, isShadowRoot, maskInputValue, needMaskingText, obfuscateText, rebuild, serializeNodeWithId, snapshot, transformAttribute };
|