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