@highlight-run/rrweb 2.0.10 → 2.0.14
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.min.js.map +1 -1
- package/dist/plugins/console-replay.min.js.map +1 -1
- package/dist/record/rrweb-record-pack.min.js.map +1 -1
- package/dist/record/rrweb-record.js +3 -3
- package/dist/record/rrweb-record.min.js +3 -3
- package/dist/record/rrweb-record.min.js.map +1 -1
- package/dist/replay/rrweb-replay-unpack.js +4 -4
- package/dist/replay/rrweb-replay-unpack.min.js +4 -4
- package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
- package/dist/replay/rrweb-replay.js +4 -4
- package/dist/replay/rrweb-replay.min.js +4 -4
- package/dist/replay/rrweb-replay.min.js.map +1 -1
- package/dist/rrweb-all.js +8 -8
- package/dist/rrweb-all.min.js +8 -8
- package/dist/rrweb-all.min.js.map +1 -1
- package/dist/rrweb.js +5 -5
- package/dist/rrweb.min.js +5 -5
- package/dist/rrweb.min.js.map +1 -1
- package/es/rrweb/packages/rrdom/es/{virtual-dom.js → rrdom.js} +87 -112
- package/es/rrweb/packages/rrweb/src/index.js +1 -1
- package/es/rrweb/packages/rrweb/src/record/index.js +2 -0
- package/es/rrweb/packages/rrweb/src/record/mutation.js +12 -1
- package/es/rrweb/packages/rrweb/src/replay/index.js +3 -3
- package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +1860 -1861
- package/lib/plugins/console-record.js +8 -8
- package/lib/plugins/console-replay.js +8 -8
- package/lib/record/rrweb-record-pack.js +8 -8
- package/lib/record/rrweb-record.js +1055 -1043
- package/lib/replay/rrweb-replay-unpack.js +971 -996
- package/lib/replay/rrweb-replay.js +971 -996
- package/lib/rrweb-all.js +1963 -1976
- package/lib/rrweb.js +1963 -1976
- package/package.json +4 -4
- package/typings/record/mutation.d.ts +1 -0
- package/typings/replay/index.d.ts +1 -1
- package/typings/types.d.ts +3 -2
- package/typings/utils.d.ts +1 -1
|
@@ -27,958 +27,958 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var NodeType$2;
|
|
31
|
-
(function (NodeType) {
|
|
32
|
-
NodeType[NodeType["Document"] = 0] = "Document";
|
|
33
|
-
NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
|
|
34
|
-
NodeType[NodeType["Element"] = 2] = "Element";
|
|
35
|
-
NodeType[NodeType["Text"] = 3] = "Text";
|
|
36
|
-
NodeType[NodeType["CDATA"] = 4] = "CDATA";
|
|
37
|
-
NodeType[NodeType["Comment"] = 5] = "Comment";
|
|
30
|
+
var NodeType$2;
|
|
31
|
+
(function (NodeType) {
|
|
32
|
+
NodeType[NodeType["Document"] = 0] = "Document";
|
|
33
|
+
NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
|
|
34
|
+
NodeType[NodeType["Element"] = 2] = "Element";
|
|
35
|
+
NodeType[NodeType["Text"] = 3] = "Text";
|
|
36
|
+
NodeType[NodeType["CDATA"] = 4] = "CDATA";
|
|
37
|
+
NodeType[NodeType["Comment"] = 5] = "Comment";
|
|
38
38
|
})(NodeType$2 || (NodeType$2 = {}));
|
|
39
39
|
|
|
40
|
-
function isElement(n) {
|
|
41
|
-
return n.nodeType === n.ELEMENT_NODE;
|
|
42
|
-
}
|
|
43
|
-
var Mirror$2 = (function () {
|
|
44
|
-
function Mirror() {
|
|
45
|
-
this.idNodeMap = new Map();
|
|
46
|
-
this.nodeMetaMap = new WeakMap();
|
|
47
|
-
}
|
|
48
|
-
Mirror.prototype.getId = function (n) {
|
|
49
|
-
var _a;
|
|
50
|
-
if (!n)
|
|
51
|
-
return -1;
|
|
52
|
-
var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
|
|
53
|
-
return id !== null && id !== void 0 ? id : -1;
|
|
54
|
-
};
|
|
55
|
-
Mirror.prototype.getNode = function (id) {
|
|
56
|
-
return this.idNodeMap.get(id) || null;
|
|
57
|
-
};
|
|
58
|
-
Mirror.prototype.getIds = function () {
|
|
59
|
-
return Array.from(this.idNodeMap.keys());
|
|
60
|
-
};
|
|
61
|
-
Mirror.prototype.getMeta = function (n) {
|
|
62
|
-
return this.nodeMetaMap.get(n) || null;
|
|
63
|
-
};
|
|
64
|
-
Mirror.prototype.removeNodeFromMap = function (n) {
|
|
65
|
-
var _this = this;
|
|
66
|
-
var id = this.getId(n);
|
|
67
|
-
this.idNodeMap["delete"](id);
|
|
68
|
-
if (n.childNodes) {
|
|
69
|
-
n.childNodes.forEach(function (childNode) {
|
|
70
|
-
return _this.removeNodeFromMap(childNode);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
Mirror.prototype.has = function (id) {
|
|
75
|
-
return this.idNodeMap.has(id);
|
|
76
|
-
};
|
|
77
|
-
Mirror.prototype.hasNode = function (node) {
|
|
78
|
-
return this.nodeMetaMap.has(node);
|
|
79
|
-
};
|
|
80
|
-
Mirror.prototype.add = function (n, meta) {
|
|
81
|
-
var id = meta.id;
|
|
82
|
-
this.idNodeMap.set(id, n);
|
|
83
|
-
this.nodeMetaMap.set(n, meta);
|
|
84
|
-
};
|
|
85
|
-
Mirror.prototype.replace = function (id, n) {
|
|
86
|
-
this.idNodeMap.set(id, n);
|
|
87
|
-
};
|
|
88
|
-
Mirror.prototype.reset = function () {
|
|
89
|
-
this.idNodeMap = new Map();
|
|
90
|
-
this.nodeMetaMap = new WeakMap();
|
|
91
|
-
};
|
|
92
|
-
return Mirror;
|
|
93
|
-
}());
|
|
94
|
-
function createMirror$2() {
|
|
95
|
-
return new Mirror$2();
|
|
96
|
-
}
|
|
40
|
+
function isElement(n) {
|
|
41
|
+
return n.nodeType === n.ELEMENT_NODE;
|
|
42
|
+
}
|
|
43
|
+
var Mirror$2 = (function () {
|
|
44
|
+
function Mirror() {
|
|
45
|
+
this.idNodeMap = new Map();
|
|
46
|
+
this.nodeMetaMap = new WeakMap();
|
|
47
|
+
}
|
|
48
|
+
Mirror.prototype.getId = function (n) {
|
|
49
|
+
var _a;
|
|
50
|
+
if (!n)
|
|
51
|
+
return -1;
|
|
52
|
+
var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
|
|
53
|
+
return id !== null && id !== void 0 ? id : -1;
|
|
54
|
+
};
|
|
55
|
+
Mirror.prototype.getNode = function (id) {
|
|
56
|
+
return this.idNodeMap.get(id) || null;
|
|
57
|
+
};
|
|
58
|
+
Mirror.prototype.getIds = function () {
|
|
59
|
+
return Array.from(this.idNodeMap.keys());
|
|
60
|
+
};
|
|
61
|
+
Mirror.prototype.getMeta = function (n) {
|
|
62
|
+
return this.nodeMetaMap.get(n) || null;
|
|
63
|
+
};
|
|
64
|
+
Mirror.prototype.removeNodeFromMap = function (n) {
|
|
65
|
+
var _this = this;
|
|
66
|
+
var id = this.getId(n);
|
|
67
|
+
this.idNodeMap["delete"](id);
|
|
68
|
+
if (n.childNodes) {
|
|
69
|
+
n.childNodes.forEach(function (childNode) {
|
|
70
|
+
return _this.removeNodeFromMap(childNode);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
Mirror.prototype.has = function (id) {
|
|
75
|
+
return this.idNodeMap.has(id);
|
|
76
|
+
};
|
|
77
|
+
Mirror.prototype.hasNode = function (node) {
|
|
78
|
+
return this.nodeMetaMap.has(node);
|
|
79
|
+
};
|
|
80
|
+
Mirror.prototype.add = function (n, meta) {
|
|
81
|
+
var id = meta.id;
|
|
82
|
+
this.idNodeMap.set(id, n);
|
|
83
|
+
this.nodeMetaMap.set(n, meta);
|
|
84
|
+
};
|
|
85
|
+
Mirror.prototype.replace = function (id, n) {
|
|
86
|
+
this.idNodeMap.set(id, n);
|
|
87
|
+
};
|
|
88
|
+
Mirror.prototype.reset = function () {
|
|
89
|
+
this.idNodeMap = new Map();
|
|
90
|
+
this.nodeMetaMap = new WeakMap();
|
|
91
|
+
};
|
|
92
|
+
return Mirror;
|
|
93
|
+
}());
|
|
94
|
+
function createMirror$2() {
|
|
95
|
+
return new Mirror$2();
|
|
96
|
+
}
|
|
97
97
|
|
|
98
|
-
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
99
|
-
function parse(css, options) {
|
|
100
|
-
if (options === void 0) { options = {}; }
|
|
101
|
-
var lineno = 1;
|
|
102
|
-
var column = 1;
|
|
103
|
-
function updatePosition(str) {
|
|
104
|
-
var lines = str.match(/\n/g);
|
|
105
|
-
if (lines) {
|
|
106
|
-
lineno += lines.length;
|
|
107
|
-
}
|
|
108
|
-
var i = str.lastIndexOf('\n');
|
|
109
|
-
column = i === -1 ? column + str.length : str.length - i;
|
|
110
|
-
}
|
|
111
|
-
function position() {
|
|
112
|
-
var start = { line: lineno, column: column };
|
|
113
|
-
return function (node) {
|
|
114
|
-
node.position = new Position(start);
|
|
115
|
-
whitespace();
|
|
116
|
-
return node;
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
var Position = (function () {
|
|
120
|
-
function Position(start) {
|
|
121
|
-
this.start = start;
|
|
122
|
-
this.end = { line: lineno, column: column };
|
|
123
|
-
this.source = options.source;
|
|
124
|
-
}
|
|
125
|
-
return Position;
|
|
126
|
-
}());
|
|
127
|
-
Position.prototype.content = css;
|
|
128
|
-
var errorsList = [];
|
|
129
|
-
function error(msg) {
|
|
130
|
-
var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
|
|
131
|
-
err.reason = msg;
|
|
132
|
-
err.filename = options.source;
|
|
133
|
-
err.line = lineno;
|
|
134
|
-
err.column = column;
|
|
135
|
-
err.source = css;
|
|
136
|
-
if (options.silent) {
|
|
137
|
-
errorsList.push(err);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
throw err;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
function stylesheet() {
|
|
144
|
-
var rulesList = rules();
|
|
145
|
-
return {
|
|
146
|
-
type: 'stylesheet',
|
|
147
|
-
stylesheet: {
|
|
148
|
-
source: options.source,
|
|
149
|
-
rules: rulesList,
|
|
150
|
-
parsingErrors: errorsList
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
function open() {
|
|
155
|
-
return match(/^{\s*/);
|
|
156
|
-
}
|
|
157
|
-
function close() {
|
|
158
|
-
return match(/^}/);
|
|
159
|
-
}
|
|
160
|
-
function rules() {
|
|
161
|
-
var node;
|
|
162
|
-
var rules = [];
|
|
163
|
-
whitespace();
|
|
164
|
-
comments(rules);
|
|
165
|
-
while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {
|
|
166
|
-
if (node !== false) {
|
|
167
|
-
rules.push(node);
|
|
168
|
-
comments(rules);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return rules;
|
|
172
|
-
}
|
|
173
|
-
function match(re) {
|
|
174
|
-
var m = re.exec(css);
|
|
175
|
-
if (!m) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
var str = m[0];
|
|
179
|
-
updatePosition(str);
|
|
180
|
-
css = css.slice(str.length);
|
|
181
|
-
return m;
|
|
182
|
-
}
|
|
183
|
-
function whitespace() {
|
|
184
|
-
match(/^\s*/);
|
|
185
|
-
}
|
|
186
|
-
function comments(rules) {
|
|
187
|
-
if (rules === void 0) { rules = []; }
|
|
188
|
-
var c;
|
|
189
|
-
while ((c = comment())) {
|
|
190
|
-
if (c !== false) {
|
|
191
|
-
rules.push(c);
|
|
192
|
-
}
|
|
193
|
-
c = comment();
|
|
194
|
-
}
|
|
195
|
-
return rules;
|
|
196
|
-
}
|
|
197
|
-
function comment() {
|
|
198
|
-
var pos = position();
|
|
199
|
-
if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
var i = 2;
|
|
203
|
-
while ('' !== css.charAt(i) &&
|
|
204
|
-
('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {
|
|
205
|
-
++i;
|
|
206
|
-
}
|
|
207
|
-
i += 2;
|
|
208
|
-
if ('' === css.charAt(i - 1)) {
|
|
209
|
-
return error('End of comment missing');
|
|
210
|
-
}
|
|
211
|
-
var str = css.slice(2, i - 2);
|
|
212
|
-
column += 2;
|
|
213
|
-
updatePosition(str);
|
|
214
|
-
css = css.slice(i);
|
|
215
|
-
column += 2;
|
|
216
|
-
return pos({
|
|
217
|
-
type: 'comment',
|
|
218
|
-
comment: str
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
function selector() {
|
|
222
|
-
var m = match(/^([^{]+)/);
|
|
223
|
-
if (!m) {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
return trim(m[0])
|
|
227
|
-
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
|
|
228
|
-
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (m) {
|
|
229
|
-
return m.replace(/,/g, '\u200C');
|
|
230
|
-
})
|
|
231
|
-
.split(/\s*(?![^(]*\)),\s*/)
|
|
232
|
-
.map(function (s) {
|
|
233
|
-
return s.replace(/\u200C/g, ',');
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
function declaration() {
|
|
237
|
-
var pos = position();
|
|
238
|
-
var propMatch = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
|
|
239
|
-
if (!propMatch) {
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
var prop = trim(propMatch[0]);
|
|
243
|
-
if (!match(/^:\s*/)) {
|
|
244
|
-
return error("property missing ':'");
|
|
245
|
-
}
|
|
246
|
-
var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
|
|
247
|
-
var ret = pos({
|
|
248
|
-
type: 'declaration',
|
|
249
|
-
property: prop.replace(commentre, ''),
|
|
250
|
-
value: val ? trim(val[0]).replace(commentre, '') : ''
|
|
251
|
-
});
|
|
252
|
-
match(/^[;\s]*/);
|
|
253
|
-
return ret;
|
|
254
|
-
}
|
|
255
|
-
function declarations() {
|
|
256
|
-
var decls = [];
|
|
257
|
-
if (!open()) {
|
|
258
|
-
return error("missing '{'");
|
|
259
|
-
}
|
|
260
|
-
comments(decls);
|
|
261
|
-
var decl;
|
|
262
|
-
while ((decl = declaration())) {
|
|
263
|
-
if (decl !== false) {
|
|
264
|
-
decls.push(decl);
|
|
265
|
-
comments(decls);
|
|
266
|
-
}
|
|
267
|
-
decl = declaration();
|
|
268
|
-
}
|
|
269
|
-
if (!close()) {
|
|
270
|
-
return error("missing '}'");
|
|
271
|
-
}
|
|
272
|
-
return decls;
|
|
273
|
-
}
|
|
274
|
-
function keyframe() {
|
|
275
|
-
var m;
|
|
276
|
-
var vals = [];
|
|
277
|
-
var pos = position();
|
|
278
|
-
while ((m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/))) {
|
|
279
|
-
vals.push(m[1]);
|
|
280
|
-
match(/^,\s*/);
|
|
281
|
-
}
|
|
282
|
-
if (!vals.length) {
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
return pos({
|
|
286
|
-
type: 'keyframe',
|
|
287
|
-
values: vals,
|
|
288
|
-
declarations: declarations()
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
function atkeyframes() {
|
|
292
|
-
var pos = position();
|
|
293
|
-
var m = match(/^@([-\w]+)?keyframes\s*/);
|
|
294
|
-
if (!m) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
var vendor = m[1];
|
|
298
|
-
m = match(/^([-\w]+)\s*/);
|
|
299
|
-
if (!m) {
|
|
300
|
-
return error('@keyframes missing name');
|
|
301
|
-
}
|
|
302
|
-
var name = m[1];
|
|
303
|
-
if (!open()) {
|
|
304
|
-
return error("@keyframes missing '{'");
|
|
305
|
-
}
|
|
306
|
-
var frame;
|
|
307
|
-
var frames = comments();
|
|
308
|
-
while ((frame = keyframe())) {
|
|
309
|
-
frames.push(frame);
|
|
310
|
-
frames = frames.concat(comments());
|
|
311
|
-
}
|
|
312
|
-
if (!close()) {
|
|
313
|
-
return error("@keyframes missing '}'");
|
|
314
|
-
}
|
|
315
|
-
return pos({
|
|
316
|
-
type: 'keyframes',
|
|
317
|
-
name: name,
|
|
318
|
-
vendor: vendor,
|
|
319
|
-
keyframes: frames
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
function atsupports() {
|
|
323
|
-
var pos = position();
|
|
324
|
-
var m = match(/^@supports *([^{]+)/);
|
|
325
|
-
if (!m) {
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
var supports = trim(m[1]);
|
|
329
|
-
if (!open()) {
|
|
330
|
-
return error("@supports missing '{'");
|
|
331
|
-
}
|
|
332
|
-
var style = comments().concat(rules());
|
|
333
|
-
if (!close()) {
|
|
334
|
-
return error("@supports missing '}'");
|
|
335
|
-
}
|
|
336
|
-
return pos({
|
|
337
|
-
type: 'supports',
|
|
338
|
-
supports: supports,
|
|
339
|
-
rules: style
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
function athost() {
|
|
343
|
-
var pos = position();
|
|
344
|
-
var m = match(/^@host\s*/);
|
|
345
|
-
if (!m) {
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
if (!open()) {
|
|
349
|
-
return error("@host missing '{'");
|
|
350
|
-
}
|
|
351
|
-
var style = comments().concat(rules());
|
|
352
|
-
if (!close()) {
|
|
353
|
-
return error("@host missing '}'");
|
|
354
|
-
}
|
|
355
|
-
return pos({
|
|
356
|
-
type: 'host',
|
|
357
|
-
rules: style
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
function atmedia() {
|
|
361
|
-
var pos = position();
|
|
362
|
-
var m = match(/^@media *([^{]+)/);
|
|
363
|
-
if (!m) {
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
|
-
var media = trim(m[1]);
|
|
367
|
-
if (!open()) {
|
|
368
|
-
return error("@media missing '{'");
|
|
369
|
-
}
|
|
370
|
-
var style = comments().concat(rules());
|
|
371
|
-
if (!close()) {
|
|
372
|
-
return error("@media missing '}'");
|
|
373
|
-
}
|
|
374
|
-
return pos({
|
|
375
|
-
type: 'media',
|
|
376
|
-
media: media,
|
|
377
|
-
rules: style
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
function atcustommedia() {
|
|
381
|
-
var pos = position();
|
|
382
|
-
var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
|
|
383
|
-
if (!m) {
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
return pos({
|
|
387
|
-
type: 'custom-media',
|
|
388
|
-
name: trim(m[1]),
|
|
389
|
-
media: trim(m[2])
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
function atpage() {
|
|
393
|
-
var pos = position();
|
|
394
|
-
var m = match(/^@page */);
|
|
395
|
-
if (!m) {
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
var sel = selector() || [];
|
|
399
|
-
if (!open()) {
|
|
400
|
-
return error("@page missing '{'");
|
|
401
|
-
}
|
|
402
|
-
var decls = comments();
|
|
403
|
-
var decl;
|
|
404
|
-
while ((decl = declaration())) {
|
|
405
|
-
decls.push(decl);
|
|
406
|
-
decls = decls.concat(comments());
|
|
407
|
-
}
|
|
408
|
-
if (!close()) {
|
|
409
|
-
return error("@page missing '}'");
|
|
410
|
-
}
|
|
411
|
-
return pos({
|
|
412
|
-
type: 'page',
|
|
413
|
-
selectors: sel,
|
|
414
|
-
declarations: decls
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
function atdocument() {
|
|
418
|
-
var pos = position();
|
|
419
|
-
var m = match(/^@([-\w]+)?document *([^{]+)/);
|
|
420
|
-
if (!m) {
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
var vendor = trim(m[1]);
|
|
424
|
-
var doc = trim(m[2]);
|
|
425
|
-
if (!open()) {
|
|
426
|
-
return error("@document missing '{'");
|
|
427
|
-
}
|
|
428
|
-
var style = comments().concat(rules());
|
|
429
|
-
if (!close()) {
|
|
430
|
-
return error("@document missing '}'");
|
|
431
|
-
}
|
|
432
|
-
return pos({
|
|
433
|
-
type: 'document',
|
|
434
|
-
document: doc,
|
|
435
|
-
vendor: vendor,
|
|
436
|
-
rules: style
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
function atfontface() {
|
|
440
|
-
var pos = position();
|
|
441
|
-
var m = match(/^@font-face\s*/);
|
|
442
|
-
if (!m) {
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
if (!open()) {
|
|
446
|
-
return error("@font-face missing '{'");
|
|
447
|
-
}
|
|
448
|
-
var decls = comments();
|
|
449
|
-
var decl;
|
|
450
|
-
while ((decl = declaration())) {
|
|
451
|
-
decls.push(decl);
|
|
452
|
-
decls = decls.concat(comments());
|
|
453
|
-
}
|
|
454
|
-
if (!close()) {
|
|
455
|
-
return error("@font-face missing '}'");
|
|
456
|
-
}
|
|
457
|
-
return pos({
|
|
458
|
-
type: 'font-face',
|
|
459
|
-
declarations: decls
|
|
460
|
-
});
|
|
461
|
-
}
|
|
462
|
-
var atimport = _compileAtrule('import');
|
|
463
|
-
var atcharset = _compileAtrule('charset');
|
|
464
|
-
var atnamespace = _compileAtrule('namespace');
|
|
465
|
-
function _compileAtrule(name) {
|
|
466
|
-
var re = new RegExp('^@' + name + '\\s*([^;]+);');
|
|
467
|
-
return function () {
|
|
468
|
-
var pos = position();
|
|
469
|
-
var m = match(re);
|
|
470
|
-
if (!m) {
|
|
471
|
-
return;
|
|
472
|
-
}
|
|
473
|
-
var ret = { type: name };
|
|
474
|
-
ret[name] = m[1].trim();
|
|
475
|
-
return pos(ret);
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
function atrule() {
|
|
479
|
-
if (css[0] !== '@') {
|
|
480
|
-
return;
|
|
481
|
-
}
|
|
482
|
-
return (atkeyframes() ||
|
|
483
|
-
atmedia() ||
|
|
484
|
-
atcustommedia() ||
|
|
485
|
-
atsupports() ||
|
|
486
|
-
atimport() ||
|
|
487
|
-
atcharset() ||
|
|
488
|
-
atnamespace() ||
|
|
489
|
-
atdocument() ||
|
|
490
|
-
atpage() ||
|
|
491
|
-
athost() ||
|
|
492
|
-
atfontface());
|
|
493
|
-
}
|
|
494
|
-
function rule() {
|
|
495
|
-
var pos = position();
|
|
496
|
-
var sel = selector();
|
|
497
|
-
if (!sel) {
|
|
498
|
-
return error('selector missing');
|
|
499
|
-
}
|
|
500
|
-
comments();
|
|
501
|
-
return pos({
|
|
502
|
-
type: 'rule',
|
|
503
|
-
selectors: sel,
|
|
504
|
-
declarations: declarations()
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
return addParent(stylesheet());
|
|
508
|
-
}
|
|
509
|
-
function trim(str) {
|
|
510
|
-
return str ? str.replace(/^\s+|\s+$/g, '') : '';
|
|
511
|
-
}
|
|
512
|
-
function addParent(obj, parent) {
|
|
513
|
-
var isNode = obj && typeof obj.type === 'string';
|
|
514
|
-
var childParent = isNode ? obj : parent;
|
|
515
|
-
for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {
|
|
516
|
-
var k = _a[_i];
|
|
517
|
-
var value = obj[k];
|
|
518
|
-
if (Array.isArray(value)) {
|
|
519
|
-
value.forEach(function (v) {
|
|
520
|
-
addParent(v, childParent);
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
else if (value && typeof value === 'object') {
|
|
524
|
-
addParent(value, childParent);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
if (isNode) {
|
|
528
|
-
Object.defineProperty(obj, 'parent', {
|
|
529
|
-
configurable: true,
|
|
530
|
-
writable: true,
|
|
531
|
-
enumerable: false,
|
|
532
|
-
value: parent || null
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
return obj;
|
|
98
|
+
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
|
|
99
|
+
function parse(css, options) {
|
|
100
|
+
if (options === void 0) { options = {}; }
|
|
101
|
+
var lineno = 1;
|
|
102
|
+
var column = 1;
|
|
103
|
+
function updatePosition(str) {
|
|
104
|
+
var lines = str.match(/\n/g);
|
|
105
|
+
if (lines) {
|
|
106
|
+
lineno += lines.length;
|
|
107
|
+
}
|
|
108
|
+
var i = str.lastIndexOf('\n');
|
|
109
|
+
column = i === -1 ? column + str.length : str.length - i;
|
|
110
|
+
}
|
|
111
|
+
function position() {
|
|
112
|
+
var start = { line: lineno, column: column };
|
|
113
|
+
return function (node) {
|
|
114
|
+
node.position = new Position(start);
|
|
115
|
+
whitespace();
|
|
116
|
+
return node;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
var Position = (function () {
|
|
120
|
+
function Position(start) {
|
|
121
|
+
this.start = start;
|
|
122
|
+
this.end = { line: lineno, column: column };
|
|
123
|
+
this.source = options.source;
|
|
124
|
+
}
|
|
125
|
+
return Position;
|
|
126
|
+
}());
|
|
127
|
+
Position.prototype.content = css;
|
|
128
|
+
var errorsList = [];
|
|
129
|
+
function error(msg) {
|
|
130
|
+
var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
|
|
131
|
+
err.reason = msg;
|
|
132
|
+
err.filename = options.source;
|
|
133
|
+
err.line = lineno;
|
|
134
|
+
err.column = column;
|
|
135
|
+
err.source = css;
|
|
136
|
+
if (options.silent) {
|
|
137
|
+
errorsList.push(err);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
throw err;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function stylesheet() {
|
|
144
|
+
var rulesList = rules();
|
|
145
|
+
return {
|
|
146
|
+
type: 'stylesheet',
|
|
147
|
+
stylesheet: {
|
|
148
|
+
source: options.source,
|
|
149
|
+
rules: rulesList,
|
|
150
|
+
parsingErrors: errorsList
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function open() {
|
|
155
|
+
return match(/^{\s*/);
|
|
156
|
+
}
|
|
157
|
+
function close() {
|
|
158
|
+
return match(/^}/);
|
|
159
|
+
}
|
|
160
|
+
function rules() {
|
|
161
|
+
var node;
|
|
162
|
+
var rules = [];
|
|
163
|
+
whitespace();
|
|
164
|
+
comments(rules);
|
|
165
|
+
while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {
|
|
166
|
+
if (node !== false) {
|
|
167
|
+
rules.push(node);
|
|
168
|
+
comments(rules);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return rules;
|
|
172
|
+
}
|
|
173
|
+
function match(re) {
|
|
174
|
+
var m = re.exec(css);
|
|
175
|
+
if (!m) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
var str = m[0];
|
|
179
|
+
updatePosition(str);
|
|
180
|
+
css = css.slice(str.length);
|
|
181
|
+
return m;
|
|
182
|
+
}
|
|
183
|
+
function whitespace() {
|
|
184
|
+
match(/^\s*/);
|
|
185
|
+
}
|
|
186
|
+
function comments(rules) {
|
|
187
|
+
if (rules === void 0) { rules = []; }
|
|
188
|
+
var c;
|
|
189
|
+
while ((c = comment())) {
|
|
190
|
+
if (c !== false) {
|
|
191
|
+
rules.push(c);
|
|
192
|
+
}
|
|
193
|
+
c = comment();
|
|
194
|
+
}
|
|
195
|
+
return rules;
|
|
196
|
+
}
|
|
197
|
+
function comment() {
|
|
198
|
+
var pos = position();
|
|
199
|
+
if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
var i = 2;
|
|
203
|
+
while ('' !== css.charAt(i) &&
|
|
204
|
+
('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {
|
|
205
|
+
++i;
|
|
206
|
+
}
|
|
207
|
+
i += 2;
|
|
208
|
+
if ('' === css.charAt(i - 1)) {
|
|
209
|
+
return error('End of comment missing');
|
|
210
|
+
}
|
|
211
|
+
var str = css.slice(2, i - 2);
|
|
212
|
+
column += 2;
|
|
213
|
+
updatePosition(str);
|
|
214
|
+
css = css.slice(i);
|
|
215
|
+
column += 2;
|
|
216
|
+
return pos({
|
|
217
|
+
type: 'comment',
|
|
218
|
+
comment: str
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
function selector() {
|
|
222
|
+
var m = match(/^([^{]+)/);
|
|
223
|
+
if (!m) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
return trim(m[0])
|
|
227
|
+
.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '')
|
|
228
|
+
.replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (m) {
|
|
229
|
+
return m.replace(/,/g, '\u200C');
|
|
230
|
+
})
|
|
231
|
+
.split(/\s*(?![^(]*\)),\s*/)
|
|
232
|
+
.map(function (s) {
|
|
233
|
+
return s.replace(/\u200C/g, ',');
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
function declaration() {
|
|
237
|
+
var pos = position();
|
|
238
|
+
var propMatch = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
|
|
239
|
+
if (!propMatch) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
var prop = trim(propMatch[0]);
|
|
243
|
+
if (!match(/^:\s*/)) {
|
|
244
|
+
return error("property missing ':'");
|
|
245
|
+
}
|
|
246
|
+
var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
|
|
247
|
+
var ret = pos({
|
|
248
|
+
type: 'declaration',
|
|
249
|
+
property: prop.replace(commentre, ''),
|
|
250
|
+
value: val ? trim(val[0]).replace(commentre, '') : ''
|
|
251
|
+
});
|
|
252
|
+
match(/^[;\s]*/);
|
|
253
|
+
return ret;
|
|
254
|
+
}
|
|
255
|
+
function declarations() {
|
|
256
|
+
var decls = [];
|
|
257
|
+
if (!open()) {
|
|
258
|
+
return error("missing '{'");
|
|
259
|
+
}
|
|
260
|
+
comments(decls);
|
|
261
|
+
var decl;
|
|
262
|
+
while ((decl = declaration())) {
|
|
263
|
+
if (decl !== false) {
|
|
264
|
+
decls.push(decl);
|
|
265
|
+
comments(decls);
|
|
266
|
+
}
|
|
267
|
+
decl = declaration();
|
|
268
|
+
}
|
|
269
|
+
if (!close()) {
|
|
270
|
+
return error("missing '}'");
|
|
271
|
+
}
|
|
272
|
+
return decls;
|
|
273
|
+
}
|
|
274
|
+
function keyframe() {
|
|
275
|
+
var m;
|
|
276
|
+
var vals = [];
|
|
277
|
+
var pos = position();
|
|
278
|
+
while ((m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/))) {
|
|
279
|
+
vals.push(m[1]);
|
|
280
|
+
match(/^,\s*/);
|
|
281
|
+
}
|
|
282
|
+
if (!vals.length) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
return pos({
|
|
286
|
+
type: 'keyframe',
|
|
287
|
+
values: vals,
|
|
288
|
+
declarations: declarations()
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function atkeyframes() {
|
|
292
|
+
var pos = position();
|
|
293
|
+
var m = match(/^@([-\w]+)?keyframes\s*/);
|
|
294
|
+
if (!m) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
var vendor = m[1];
|
|
298
|
+
m = match(/^([-\w]+)\s*/);
|
|
299
|
+
if (!m) {
|
|
300
|
+
return error('@keyframes missing name');
|
|
301
|
+
}
|
|
302
|
+
var name = m[1];
|
|
303
|
+
if (!open()) {
|
|
304
|
+
return error("@keyframes missing '{'");
|
|
305
|
+
}
|
|
306
|
+
var frame;
|
|
307
|
+
var frames = comments();
|
|
308
|
+
while ((frame = keyframe())) {
|
|
309
|
+
frames.push(frame);
|
|
310
|
+
frames = frames.concat(comments());
|
|
311
|
+
}
|
|
312
|
+
if (!close()) {
|
|
313
|
+
return error("@keyframes missing '}'");
|
|
314
|
+
}
|
|
315
|
+
return pos({
|
|
316
|
+
type: 'keyframes',
|
|
317
|
+
name: name,
|
|
318
|
+
vendor: vendor,
|
|
319
|
+
keyframes: frames
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
function atsupports() {
|
|
323
|
+
var pos = position();
|
|
324
|
+
var m = match(/^@supports *([^{]+)/);
|
|
325
|
+
if (!m) {
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
var supports = trim(m[1]);
|
|
329
|
+
if (!open()) {
|
|
330
|
+
return error("@supports missing '{'");
|
|
331
|
+
}
|
|
332
|
+
var style = comments().concat(rules());
|
|
333
|
+
if (!close()) {
|
|
334
|
+
return error("@supports missing '}'");
|
|
335
|
+
}
|
|
336
|
+
return pos({
|
|
337
|
+
type: 'supports',
|
|
338
|
+
supports: supports,
|
|
339
|
+
rules: style
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
function athost() {
|
|
343
|
+
var pos = position();
|
|
344
|
+
var m = match(/^@host\s*/);
|
|
345
|
+
if (!m) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (!open()) {
|
|
349
|
+
return error("@host missing '{'");
|
|
350
|
+
}
|
|
351
|
+
var style = comments().concat(rules());
|
|
352
|
+
if (!close()) {
|
|
353
|
+
return error("@host missing '}'");
|
|
354
|
+
}
|
|
355
|
+
return pos({
|
|
356
|
+
type: 'host',
|
|
357
|
+
rules: style
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
function atmedia() {
|
|
361
|
+
var pos = position();
|
|
362
|
+
var m = match(/^@media *([^{]+)/);
|
|
363
|
+
if (!m) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
var media = trim(m[1]);
|
|
367
|
+
if (!open()) {
|
|
368
|
+
return error("@media missing '{'");
|
|
369
|
+
}
|
|
370
|
+
var style = comments().concat(rules());
|
|
371
|
+
if (!close()) {
|
|
372
|
+
return error("@media missing '}'");
|
|
373
|
+
}
|
|
374
|
+
return pos({
|
|
375
|
+
type: 'media',
|
|
376
|
+
media: media,
|
|
377
|
+
rules: style
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
function atcustommedia() {
|
|
381
|
+
var pos = position();
|
|
382
|
+
var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
|
|
383
|
+
if (!m) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
return pos({
|
|
387
|
+
type: 'custom-media',
|
|
388
|
+
name: trim(m[1]),
|
|
389
|
+
media: trim(m[2])
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
function atpage() {
|
|
393
|
+
var pos = position();
|
|
394
|
+
var m = match(/^@page */);
|
|
395
|
+
if (!m) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
var sel = selector() || [];
|
|
399
|
+
if (!open()) {
|
|
400
|
+
return error("@page missing '{'");
|
|
401
|
+
}
|
|
402
|
+
var decls = comments();
|
|
403
|
+
var decl;
|
|
404
|
+
while ((decl = declaration())) {
|
|
405
|
+
decls.push(decl);
|
|
406
|
+
decls = decls.concat(comments());
|
|
407
|
+
}
|
|
408
|
+
if (!close()) {
|
|
409
|
+
return error("@page missing '}'");
|
|
410
|
+
}
|
|
411
|
+
return pos({
|
|
412
|
+
type: 'page',
|
|
413
|
+
selectors: sel,
|
|
414
|
+
declarations: decls
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
function atdocument() {
|
|
418
|
+
var pos = position();
|
|
419
|
+
var m = match(/^@([-\w]+)?document *([^{]+)/);
|
|
420
|
+
if (!m) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
var vendor = trim(m[1]);
|
|
424
|
+
var doc = trim(m[2]);
|
|
425
|
+
if (!open()) {
|
|
426
|
+
return error("@document missing '{'");
|
|
427
|
+
}
|
|
428
|
+
var style = comments().concat(rules());
|
|
429
|
+
if (!close()) {
|
|
430
|
+
return error("@document missing '}'");
|
|
431
|
+
}
|
|
432
|
+
return pos({
|
|
433
|
+
type: 'document',
|
|
434
|
+
document: doc,
|
|
435
|
+
vendor: vendor,
|
|
436
|
+
rules: style
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
function atfontface() {
|
|
440
|
+
var pos = position();
|
|
441
|
+
var m = match(/^@font-face\s*/);
|
|
442
|
+
if (!m) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
if (!open()) {
|
|
446
|
+
return error("@font-face missing '{'");
|
|
447
|
+
}
|
|
448
|
+
var decls = comments();
|
|
449
|
+
var decl;
|
|
450
|
+
while ((decl = declaration())) {
|
|
451
|
+
decls.push(decl);
|
|
452
|
+
decls = decls.concat(comments());
|
|
453
|
+
}
|
|
454
|
+
if (!close()) {
|
|
455
|
+
return error("@font-face missing '}'");
|
|
456
|
+
}
|
|
457
|
+
return pos({
|
|
458
|
+
type: 'font-face',
|
|
459
|
+
declarations: decls
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
var atimport = _compileAtrule('import');
|
|
463
|
+
var atcharset = _compileAtrule('charset');
|
|
464
|
+
var atnamespace = _compileAtrule('namespace');
|
|
465
|
+
function _compileAtrule(name) {
|
|
466
|
+
var re = new RegExp('^@' + name + '\\s*([^;]+);');
|
|
467
|
+
return function () {
|
|
468
|
+
var pos = position();
|
|
469
|
+
var m = match(re);
|
|
470
|
+
if (!m) {
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
var ret = { type: name };
|
|
474
|
+
ret[name] = m[1].trim();
|
|
475
|
+
return pos(ret);
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
function atrule() {
|
|
479
|
+
if (css[0] !== '@') {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
return (atkeyframes() ||
|
|
483
|
+
atmedia() ||
|
|
484
|
+
atcustommedia() ||
|
|
485
|
+
atsupports() ||
|
|
486
|
+
atimport() ||
|
|
487
|
+
atcharset() ||
|
|
488
|
+
atnamespace() ||
|
|
489
|
+
atdocument() ||
|
|
490
|
+
atpage() ||
|
|
491
|
+
athost() ||
|
|
492
|
+
atfontface());
|
|
493
|
+
}
|
|
494
|
+
function rule() {
|
|
495
|
+
var pos = position();
|
|
496
|
+
var sel = selector();
|
|
497
|
+
if (!sel) {
|
|
498
|
+
return error('selector missing');
|
|
499
|
+
}
|
|
500
|
+
comments();
|
|
501
|
+
return pos({
|
|
502
|
+
type: 'rule',
|
|
503
|
+
selectors: sel,
|
|
504
|
+
declarations: declarations()
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
return addParent(stylesheet());
|
|
508
|
+
}
|
|
509
|
+
function trim(str) {
|
|
510
|
+
return str ? str.replace(/^\s+|\s+$/g, '') : '';
|
|
511
|
+
}
|
|
512
|
+
function addParent(obj, parent) {
|
|
513
|
+
var isNode = obj && typeof obj.type === 'string';
|
|
514
|
+
var childParent = isNode ? obj : parent;
|
|
515
|
+
for (var _i = 0, _a = Object.keys(obj); _i < _a.length; _i++) {
|
|
516
|
+
var k = _a[_i];
|
|
517
|
+
var value = obj[k];
|
|
518
|
+
if (Array.isArray(value)) {
|
|
519
|
+
value.forEach(function (v) {
|
|
520
|
+
addParent(v, childParent);
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
else if (value && typeof value === 'object') {
|
|
524
|
+
addParent(value, childParent);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
if (isNode) {
|
|
528
|
+
Object.defineProperty(obj, 'parent', {
|
|
529
|
+
configurable: true,
|
|
530
|
+
writable: true,
|
|
531
|
+
enumerable: false,
|
|
532
|
+
value: parent || null
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
return obj;
|
|
536
536
|
}
|
|
537
537
|
|
|
538
|
-
var tagMap = {
|
|
539
|
-
script: 'noscript',
|
|
540
|
-
altglyph: 'altGlyph',
|
|
541
|
-
altglyphdef: 'altGlyphDef',
|
|
542
|
-
altglyphitem: 'altGlyphItem',
|
|
543
|
-
animatecolor: 'animateColor',
|
|
544
|
-
animatemotion: 'animateMotion',
|
|
545
|
-
animatetransform: 'animateTransform',
|
|
546
|
-
clippath: 'clipPath',
|
|
547
|
-
feblend: 'feBlend',
|
|
548
|
-
fecolormatrix: 'feColorMatrix',
|
|
549
|
-
fecomponenttransfer: 'feComponentTransfer',
|
|
550
|
-
fecomposite: 'feComposite',
|
|
551
|
-
feconvolvematrix: 'feConvolveMatrix',
|
|
552
|
-
fediffuselighting: 'feDiffuseLighting',
|
|
553
|
-
fedisplacementmap: 'feDisplacementMap',
|
|
554
|
-
fedistantlight: 'feDistantLight',
|
|
555
|
-
fedropshadow: 'feDropShadow',
|
|
556
|
-
feflood: 'feFlood',
|
|
557
|
-
fefunca: 'feFuncA',
|
|
558
|
-
fefuncb: 'feFuncB',
|
|
559
|
-
fefuncg: 'feFuncG',
|
|
560
|
-
fefuncr: 'feFuncR',
|
|
561
|
-
fegaussianblur: 'feGaussianBlur',
|
|
562
|
-
feimage: 'feImage',
|
|
563
|
-
femerge: 'feMerge',
|
|
564
|
-
femergenode: 'feMergeNode',
|
|
565
|
-
femorphology: 'feMorphology',
|
|
566
|
-
feoffset: 'feOffset',
|
|
567
|
-
fepointlight: 'fePointLight',
|
|
568
|
-
fespecularlighting: 'feSpecularLighting',
|
|
569
|
-
fespotlight: 'feSpotLight',
|
|
570
|
-
fetile: 'feTile',
|
|
571
|
-
feturbulence: 'feTurbulence',
|
|
572
|
-
foreignobject: 'foreignObject',
|
|
573
|
-
glyphref: 'glyphRef',
|
|
574
|
-
lineargradient: 'linearGradient',
|
|
575
|
-
radialgradient: 'radialGradient'
|
|
576
|
-
};
|
|
577
|
-
function getTagName(n) {
|
|
578
|
-
var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;
|
|
579
|
-
if (tagName === 'link' && n.attributes._cssText) {
|
|
580
|
-
tagName = 'style';
|
|
581
|
-
}
|
|
582
|
-
return tagName;
|
|
583
|
-
}
|
|
584
|
-
function escapeRegExp(str) {
|
|
585
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
586
|
-
}
|
|
587
|
-
var HOVER_SELECTOR = /([^\\]):hover/;
|
|
588
|
-
var HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');
|
|
589
|
-
function addHoverClass(cssText, cache) {
|
|
590
|
-
var _a;
|
|
591
|
-
if (!((_a = window === null || window === void 0 ? void 0 : window.HIG_CONFIGURATION) === null || _a === void 0 ? void 0 : _a.enableOnHoverClass)) {
|
|
592
|
-
return cssText;
|
|
593
|
-
}
|
|
594
|
-
var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);
|
|
595
|
-
if (cachedStyle)
|
|
596
|
-
return cachedStyle;
|
|
597
|
-
var ast = parse(cssText, {
|
|
598
|
-
silent: true
|
|
599
|
-
});
|
|
600
|
-
if (!ast.stylesheet) {
|
|
601
|
-
return cssText;
|
|
602
|
-
}
|
|
603
|
-
var selectors = [];
|
|
604
|
-
ast.stylesheet.rules.forEach(function (rule) {
|
|
605
|
-
if ('selectors' in rule) {
|
|
606
|
-
(rule.selectors || []).forEach(function (selector) {
|
|
607
|
-
if (HOVER_SELECTOR.test(selector)) {
|
|
608
|
-
selectors.push(selector);
|
|
609
|
-
}
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
if (selectors.length === 0) {
|
|
614
|
-
return cssText;
|
|
615
|
-
}
|
|
616
|
-
var selectorMatcher = new RegExp(selectors
|
|
617
|
-
.filter(function (selector, index) { return selectors.indexOf(selector) === index; })
|
|
618
|
-
.sort(function (a, b) { return b.length - a.length; })
|
|
619
|
-
.map(function (selector) {
|
|
620
|
-
return escapeRegExp(selector);
|
|
621
|
-
})
|
|
622
|
-
.join('|'), 'g');
|
|
623
|
-
var result = cssText.replace(selectorMatcher, function (selector) {
|
|
624
|
-
var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\:hover');
|
|
625
|
-
return selector
|
|
626
|
-
});
|
|
627
|
-
cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);
|
|
628
|
-
return result;
|
|
629
|
-
}
|
|
630
|
-
function createCache() {
|
|
631
|
-
var stylesWithHoverClass = new Map();
|
|
632
|
-
return {
|
|
633
|
-
stylesWithHoverClass: stylesWithHoverClass
|
|
634
|
-
};
|
|
635
|
-
}
|
|
636
|
-
function buildNode(n, options) {
|
|
637
|
-
var doc = options.doc, hackCss = options.hackCss, cache = options.cache;
|
|
638
|
-
switch (n.type) {
|
|
639
|
-
case NodeType$2.Document:
|
|
640
|
-
return doc.implementation.createDocument(null, '', null);
|
|
641
|
-
case NodeType$2.DocumentType:
|
|
642
|
-
return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);
|
|
643
|
-
case NodeType$2.Element:
|
|
644
|
-
var tagName = getTagName(n);
|
|
645
|
-
var node_1;
|
|
646
|
-
if (n.isSVG) {
|
|
647
|
-
node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);
|
|
648
|
-
}
|
|
649
|
-
else {
|
|
650
|
-
node_1 = doc.createElement(tagName);
|
|
651
|
-
}
|
|
652
|
-
var _loop_1 = function (name_1) {
|
|
653
|
-
if (!n.attributes.hasOwnProperty(name_1)) {
|
|
654
|
-
return "continue";
|
|
655
|
-
}
|
|
656
|
-
var value = n.attributes[name_1];
|
|
657
|
-
if (tagName === 'option' && name_1 === 'selected' && value === false) {
|
|
658
|
-
return "continue";
|
|
659
|
-
}
|
|
660
|
-
value =
|
|
661
|
-
typeof value === 'boolean' || typeof value === 'number' ? '' : value;
|
|
662
|
-
if (!name_1.startsWith('rr_')) {
|
|
663
|
-
var isTextarea = tagName === 'textarea' && name_1 === 'value';
|
|
664
|
-
var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';
|
|
665
|
-
if (isRemoteOrDynamicCss && hackCss) {
|
|
666
|
-
value = addHoverClass(value, cache);
|
|
667
|
-
if (typeof value === 'string') {
|
|
668
|
-
var regex = /url\(\"https:\/\/\S*(.eot|.woff2|.ttf|.woff)\S*\"\)/gm;
|
|
669
|
-
var m = void 0;
|
|
670
|
-
var fontUrls_1 = [];
|
|
671
|
-
var PROXY_URL_1 = 'https://replay-cors-proxy.highlightrun.workers.dev';
|
|
672
|
-
while ((m = regex.exec(value)) !== null) {
|
|
673
|
-
if (m.index === regex.lastIndex) {
|
|
674
|
-
regex.lastIndex++;
|
|
675
|
-
}
|
|
676
|
-
m.forEach(function (match, groupIndex) {
|
|
677
|
-
if (groupIndex === 0) {
|
|
678
|
-
var url = match.slice(5, match.length - 2);
|
|
679
|
-
fontUrls_1.push({
|
|
680
|
-
originalUrl: url,
|
|
681
|
-
proxyUrl: url.replace(url, PROXY_URL_1
|
|
682
|
-
});
|
|
683
|
-
}
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
fontUrls_1.forEach(function (urlPair) {
|
|
687
|
-
value = value.replace(urlPair.originalUrl, urlPair.proxyUrl);
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
if (isTextarea || isRemoteOrDynamicCss) {
|
|
692
|
-
var child = doc.createTextNode(value);
|
|
693
|
-
for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {
|
|
694
|
-
var c = _a[_i];
|
|
695
|
-
if (c.nodeType === node_1.TEXT_NODE) {
|
|
696
|
-
node_1.removeChild(c);
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
node_1.appendChild(child);
|
|
700
|
-
return "continue";
|
|
701
|
-
}
|
|
702
|
-
try {
|
|
703
|
-
if (n.isSVG && name_1 === 'xlink:href') {
|
|
704
|
-
node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);
|
|
705
|
-
}
|
|
706
|
-
else if (name_1 === 'onload' ||
|
|
707
|
-
name_1 === 'onclick' ||
|
|
708
|
-
name_1.substring(0, 7) === 'onmouse') {
|
|
709
|
-
node_1.setAttribute('_' + name_1, value);
|
|
710
|
-
}
|
|
711
|
-
else if (tagName === 'meta' &&
|
|
712
|
-
n.attributes['http-equiv'] === 'Content-Security-Policy' &&
|
|
713
|
-
name_1 === 'content') {
|
|
714
|
-
node_1.setAttribute('csp-content', value);
|
|
715
|
-
return "continue";
|
|
716
|
-
}
|
|
717
|
-
else if (tagName === 'link' &&
|
|
718
|
-
n.attributes.rel === 'preload' &&
|
|
719
|
-
n.attributes.as === 'script') {
|
|
720
|
-
}
|
|
721
|
-
else if (tagName === 'link' &&
|
|
722
|
-
n.attributes.rel === 'prefetch' &&
|
|
723
|
-
typeof n.attributes.href === 'string' &&
|
|
724
|
-
n.attributes.href.endsWith('.js')) {
|
|
725
|
-
}
|
|
726
|
-
else if (tagName === 'img' &&
|
|
727
|
-
n.attributes.srcset &&
|
|
728
|
-
n.attributes.rr_dataURL) {
|
|
729
|
-
node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);
|
|
730
|
-
}
|
|
731
|
-
else {
|
|
732
|
-
node_1.setAttribute(name_1, value);
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
catch (error) {
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
else {
|
|
739
|
-
if (tagName === 'canvas' && name_1 === 'rr_dataURL') {
|
|
740
|
-
var image_1 = document.createElement('img');
|
|
741
|
-
image_1.src = value;
|
|
742
|
-
image_1.onload = function () {
|
|
743
|
-
var ctx = node_1.getContext('2d');
|
|
744
|
-
if (ctx) {
|
|
745
|
-
ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);
|
|
746
|
-
}
|
|
747
|
-
};
|
|
748
|
-
}
|
|
749
|
-
else if (tagName === 'img' && name_1 === 'rr_dataURL') {
|
|
750
|
-
var image = node_1;
|
|
751
|
-
if (!image.currentSrc.startsWith('data:')) {
|
|
752
|
-
image.setAttribute('rrweb-original-src', n.attributes.src);
|
|
753
|
-
image.src = value;
|
|
754
|
-
image.setAttribute('rrweb-inline-src', value);
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
if (name_1 === 'rr_width') {
|
|
758
|
-
node_1.style.width = value;
|
|
759
|
-
}
|
|
760
|
-
else if (name_1 === 'rr_height') {
|
|
761
|
-
node_1.style.height = value;
|
|
762
|
-
}
|
|
763
|
-
else if (name_1 === 'rr_mediaCurrentTime') {
|
|
764
|
-
node_1.currentTime = n.attributes
|
|
765
|
-
.rr_mediaCurrentTime;
|
|
766
|
-
}
|
|
767
|
-
else if (name_1 === 'rr_mediaState') {
|
|
768
|
-
switch (value) {
|
|
769
|
-
case 'played':
|
|
770
|
-
node_1
|
|
771
|
-
.play()["catch"](function (e) { return console.warn('media playback error', e); });
|
|
772
|
-
break;
|
|
773
|
-
case 'paused':
|
|
774
|
-
node_1.pause();
|
|
775
|
-
break;
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
};
|
|
780
|
-
for (var name_1 in n.attributes) {
|
|
781
|
-
_loop_1(name_1);
|
|
782
|
-
}
|
|
783
|
-
if (tagName === 'img') {
|
|
784
|
-
var image = node_1;
|
|
785
|
-
if (!image.currentSrc.startsWith('data:')) {
|
|
786
|
-
var inlineSrc = image.getAttribute('rrweb-inline-src');
|
|
787
|
-
if (inlineSrc === null || inlineSrc === void 0 ? void 0 : inlineSrc.startsWith('data:')) {
|
|
788
|
-
image.src = inlineSrc;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
if (n.isShadowHost) {
|
|
793
|
-
if (!node_1.shadowRoot) {
|
|
794
|
-
node_1.attachShadow({ mode: 'open' });
|
|
795
|
-
}
|
|
796
|
-
else {
|
|
797
|
-
while (node_1.shadowRoot.firstChild) {
|
|
798
|
-
node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
return node_1;
|
|
803
|
-
case NodeType$2.Text:
|
|
804
|
-
return doc.createTextNode(n.isStyle && hackCss
|
|
805
|
-
? addHoverClass(n.textContent, cache)
|
|
806
|
-
: n.textContent);
|
|
807
|
-
case NodeType$2.CDATA:
|
|
808
|
-
return doc.createCDATASection(n.textContent);
|
|
809
|
-
case NodeType$2.Comment:
|
|
810
|
-
return doc.createComment(n.textContent);
|
|
811
|
-
default:
|
|
812
|
-
return null;
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
function buildNodeWithSN(n, options) {
|
|
816
|
-
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;
|
|
817
|
-
var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });
|
|
818
|
-
if (!node) {
|
|
819
|
-
return null;
|
|
820
|
-
}
|
|
821
|
-
if (n.rootId) {
|
|
822
|
-
console.assert(mirror.getNode(n.rootId) === doc, 'Target document should have the same root id.');
|
|
823
|
-
}
|
|
824
|
-
if (n.type === NodeType$2.Document) {
|
|
825
|
-
doc.close();
|
|
826
|
-
doc.open();
|
|
827
|
-
if (n.compatMode === 'BackCompat' &&
|
|
828
|
-
n.childNodes &&
|
|
829
|
-
n.childNodes[0].type !== NodeType$2.DocumentType) {
|
|
830
|
-
if (n.childNodes[0].type === NodeType$2.Element &&
|
|
831
|
-
'xmlns' in n.childNodes[0].attributes &&
|
|
832
|
-
n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {
|
|
833
|
-
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">');
|
|
834
|
-
}
|
|
835
|
-
else {
|
|
836
|
-
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">');
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
node = doc;
|
|
840
|
-
}
|
|
841
|
-
mirror.add(node, n);
|
|
842
|
-
if ((n.type === NodeType$2.Document || n.type === NodeType$2.Element) &&
|
|
843
|
-
!skipChild) {
|
|
844
|
-
for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {
|
|
845
|
-
var childN = _c[_i];
|
|
846
|
-
var childNode = buildNodeWithSN(childN, {
|
|
847
|
-
doc: doc,
|
|
848
|
-
mirror: mirror,
|
|
849
|
-
skipChild: false,
|
|
850
|
-
hackCss: hackCss,
|
|
851
|
-
afterAppend: afterAppend,
|
|
852
|
-
cache: cache
|
|
853
|
-
});
|
|
854
|
-
if (!childNode) {
|
|
855
|
-
console.warn('Failed to rebuild', childN);
|
|
856
|
-
continue;
|
|
857
|
-
}
|
|
858
|
-
if (childN.isShadow && isElement(node) && node.shadowRoot) {
|
|
859
|
-
node.shadowRoot.appendChild(childNode);
|
|
860
|
-
}
|
|
861
|
-
else {
|
|
862
|
-
node.appendChild(childNode);
|
|
863
|
-
}
|
|
864
|
-
if (afterAppend) {
|
|
865
|
-
afterAppend(childNode);
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
return node;
|
|
870
|
-
}
|
|
871
|
-
function visit(mirror, onVisit) {
|
|
872
|
-
function walk(node) {
|
|
873
|
-
onVisit(node);
|
|
874
|
-
}
|
|
875
|
-
for (var _i = 0, _a = mirror.getIds(); _i < _a.length; _i++) {
|
|
876
|
-
var id = _a[_i];
|
|
877
|
-
if (mirror.has(id)) {
|
|
878
|
-
walk(mirror.getNode(id));
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
function handleScroll(node, mirror) {
|
|
883
|
-
var n = mirror.getMeta(node);
|
|
884
|
-
if ((n === null || n === void 0 ? void 0 : n.type) !== NodeType$2.Element) {
|
|
885
|
-
return;
|
|
886
|
-
}
|
|
887
|
-
var el = node;
|
|
888
|
-
for (var name_2 in n.attributes) {
|
|
889
|
-
if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {
|
|
890
|
-
continue;
|
|
891
|
-
}
|
|
892
|
-
var value = n.attributes[name_2];
|
|
893
|
-
if (name_2 === 'rr_scrollLeft') {
|
|
894
|
-
el.scrollLeft = value;
|
|
895
|
-
}
|
|
896
|
-
if (name_2 === 'rr_scrollTop') {
|
|
897
|
-
el.scrollTop = value;
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
function rebuild(n, options) {
|
|
902
|
-
var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache, _b = options.mirror, mirror = _b === void 0 ? new Mirror$2() : _b;
|
|
903
|
-
var node = buildNodeWithSN(n, {
|
|
904
|
-
doc: doc,
|
|
905
|
-
mirror: mirror,
|
|
906
|
-
skipChild: false,
|
|
907
|
-
hackCss: hackCss,
|
|
908
|
-
afterAppend: afterAppend,
|
|
909
|
-
cache: cache
|
|
910
|
-
});
|
|
911
|
-
visit(mirror, function (visitedNode) {
|
|
912
|
-
if (onVisit) {
|
|
913
|
-
onVisit(visitedNode);
|
|
914
|
-
}
|
|
915
|
-
handleScroll(visitedNode, mirror);
|
|
916
|
-
});
|
|
917
|
-
return node;
|
|
538
|
+
var tagMap = {
|
|
539
|
+
script: 'noscript',
|
|
540
|
+
altglyph: 'altGlyph',
|
|
541
|
+
altglyphdef: 'altGlyphDef',
|
|
542
|
+
altglyphitem: 'altGlyphItem',
|
|
543
|
+
animatecolor: 'animateColor',
|
|
544
|
+
animatemotion: 'animateMotion',
|
|
545
|
+
animatetransform: 'animateTransform',
|
|
546
|
+
clippath: 'clipPath',
|
|
547
|
+
feblend: 'feBlend',
|
|
548
|
+
fecolormatrix: 'feColorMatrix',
|
|
549
|
+
fecomponenttransfer: 'feComponentTransfer',
|
|
550
|
+
fecomposite: 'feComposite',
|
|
551
|
+
feconvolvematrix: 'feConvolveMatrix',
|
|
552
|
+
fediffuselighting: 'feDiffuseLighting',
|
|
553
|
+
fedisplacementmap: 'feDisplacementMap',
|
|
554
|
+
fedistantlight: 'feDistantLight',
|
|
555
|
+
fedropshadow: 'feDropShadow',
|
|
556
|
+
feflood: 'feFlood',
|
|
557
|
+
fefunca: 'feFuncA',
|
|
558
|
+
fefuncb: 'feFuncB',
|
|
559
|
+
fefuncg: 'feFuncG',
|
|
560
|
+
fefuncr: 'feFuncR',
|
|
561
|
+
fegaussianblur: 'feGaussianBlur',
|
|
562
|
+
feimage: 'feImage',
|
|
563
|
+
femerge: 'feMerge',
|
|
564
|
+
femergenode: 'feMergeNode',
|
|
565
|
+
femorphology: 'feMorphology',
|
|
566
|
+
feoffset: 'feOffset',
|
|
567
|
+
fepointlight: 'fePointLight',
|
|
568
|
+
fespecularlighting: 'feSpecularLighting',
|
|
569
|
+
fespotlight: 'feSpotLight',
|
|
570
|
+
fetile: 'feTile',
|
|
571
|
+
feturbulence: 'feTurbulence',
|
|
572
|
+
foreignobject: 'foreignObject',
|
|
573
|
+
glyphref: 'glyphRef',
|
|
574
|
+
lineargradient: 'linearGradient',
|
|
575
|
+
radialgradient: 'radialGradient'
|
|
576
|
+
};
|
|
577
|
+
function getTagName(n) {
|
|
578
|
+
var tagName = tagMap[n.tagName] ? tagMap[n.tagName] : n.tagName;
|
|
579
|
+
if (tagName === 'link' && n.attributes._cssText) {
|
|
580
|
+
tagName = 'style';
|
|
581
|
+
}
|
|
582
|
+
return tagName;
|
|
583
|
+
}
|
|
584
|
+
function escapeRegExp(str) {
|
|
585
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
586
|
+
}
|
|
587
|
+
var HOVER_SELECTOR = /([^\\]):hover/;
|
|
588
|
+
var HOVER_SELECTOR_GLOBAL = new RegExp(HOVER_SELECTOR.source, 'g');
|
|
589
|
+
function addHoverClass(cssText, cache) {
|
|
590
|
+
var _a;
|
|
591
|
+
if (!((_a = window === null || window === void 0 ? void 0 : window.HIG_CONFIGURATION) === null || _a === void 0 ? void 0 : _a.enableOnHoverClass)) {
|
|
592
|
+
return cssText;
|
|
593
|
+
}
|
|
594
|
+
var cachedStyle = cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.get(cssText);
|
|
595
|
+
if (cachedStyle)
|
|
596
|
+
return cachedStyle;
|
|
597
|
+
var ast = parse(cssText, {
|
|
598
|
+
silent: true
|
|
599
|
+
});
|
|
600
|
+
if (!ast.stylesheet) {
|
|
601
|
+
return cssText;
|
|
602
|
+
}
|
|
603
|
+
var selectors = [];
|
|
604
|
+
ast.stylesheet.rules.forEach(function (rule) {
|
|
605
|
+
if ('selectors' in rule) {
|
|
606
|
+
(rule.selectors || []).forEach(function (selector) {
|
|
607
|
+
if (HOVER_SELECTOR.test(selector)) {
|
|
608
|
+
selectors.push(selector);
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
if (selectors.length === 0) {
|
|
614
|
+
return cssText;
|
|
615
|
+
}
|
|
616
|
+
var selectorMatcher = new RegExp(selectors
|
|
617
|
+
.filter(function (selector, index) { return selectors.indexOf(selector) === index; })
|
|
618
|
+
.sort(function (a, b) { return b.length - a.length; })
|
|
619
|
+
.map(function (selector) {
|
|
620
|
+
return escapeRegExp(selector);
|
|
621
|
+
})
|
|
622
|
+
.join('|'), 'g');
|
|
623
|
+
var result = cssText.replace(selectorMatcher, function (selector) {
|
|
624
|
+
var newSelector = selector.replace(HOVER_SELECTOR_GLOBAL, '$1.\\:hover');
|
|
625
|
+
return "".concat(selector, ", ").concat(newSelector);
|
|
626
|
+
});
|
|
627
|
+
cache === null || cache === void 0 ? void 0 : cache.stylesWithHoverClass.set(cssText, result);
|
|
628
|
+
return result;
|
|
629
|
+
}
|
|
630
|
+
function createCache() {
|
|
631
|
+
var stylesWithHoverClass = new Map();
|
|
632
|
+
return {
|
|
633
|
+
stylesWithHoverClass: stylesWithHoverClass
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
function buildNode(n, options) {
|
|
637
|
+
var doc = options.doc, hackCss = options.hackCss, cache = options.cache;
|
|
638
|
+
switch (n.type) {
|
|
639
|
+
case NodeType$2.Document:
|
|
640
|
+
return doc.implementation.createDocument(null, '', null);
|
|
641
|
+
case NodeType$2.DocumentType:
|
|
642
|
+
return doc.implementation.createDocumentType(n.name || 'html', n.publicId, n.systemId);
|
|
643
|
+
case NodeType$2.Element:
|
|
644
|
+
var tagName = getTagName(n);
|
|
645
|
+
var node_1;
|
|
646
|
+
if (n.isSVG) {
|
|
647
|
+
node_1 = doc.createElementNS('http://www.w3.org/2000/svg', tagName);
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
node_1 = doc.createElement(tagName);
|
|
651
|
+
}
|
|
652
|
+
var _loop_1 = function (name_1) {
|
|
653
|
+
if (!n.attributes.hasOwnProperty(name_1)) {
|
|
654
|
+
return "continue";
|
|
655
|
+
}
|
|
656
|
+
var value = n.attributes[name_1];
|
|
657
|
+
if (tagName === 'option' && name_1 === 'selected' && value === false) {
|
|
658
|
+
return "continue";
|
|
659
|
+
}
|
|
660
|
+
value =
|
|
661
|
+
typeof value === 'boolean' || typeof value === 'number' ? '' : value;
|
|
662
|
+
if (!name_1.startsWith('rr_')) {
|
|
663
|
+
var isTextarea = tagName === 'textarea' && name_1 === 'value';
|
|
664
|
+
var isRemoteOrDynamicCss = tagName === 'style' && name_1 === '_cssText';
|
|
665
|
+
if (isRemoteOrDynamicCss && hackCss) {
|
|
666
|
+
value = addHoverClass(value, cache);
|
|
667
|
+
if (typeof value === 'string') {
|
|
668
|
+
var regex = /url\(\"https:\/\/\S*(.eot|.woff2|.ttf|.woff)\S*\"\)/gm;
|
|
669
|
+
var m = void 0;
|
|
670
|
+
var fontUrls_1 = [];
|
|
671
|
+
var PROXY_URL_1 = 'https://replay-cors-proxy.highlightrun.workers.dev';
|
|
672
|
+
while ((m = regex.exec(value)) !== null) {
|
|
673
|
+
if (m.index === regex.lastIndex) {
|
|
674
|
+
regex.lastIndex++;
|
|
675
|
+
}
|
|
676
|
+
m.forEach(function (match, groupIndex) {
|
|
677
|
+
if (groupIndex === 0) {
|
|
678
|
+
var url = match.slice(5, match.length - 2);
|
|
679
|
+
fontUrls_1.push({
|
|
680
|
+
originalUrl: url,
|
|
681
|
+
proxyUrl: url.replace(url, "".concat(PROXY_URL_1, "?url=").concat(url))
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
fontUrls_1.forEach(function (urlPair) {
|
|
687
|
+
value = value.replace(urlPair.originalUrl, urlPair.proxyUrl);
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
if (isTextarea || isRemoteOrDynamicCss) {
|
|
692
|
+
var child = doc.createTextNode(value);
|
|
693
|
+
for (var _i = 0, _a = Array.from(node_1.childNodes); _i < _a.length; _i++) {
|
|
694
|
+
var c = _a[_i];
|
|
695
|
+
if (c.nodeType === node_1.TEXT_NODE) {
|
|
696
|
+
node_1.removeChild(c);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
node_1.appendChild(child);
|
|
700
|
+
return "continue";
|
|
701
|
+
}
|
|
702
|
+
try {
|
|
703
|
+
if (n.isSVG && name_1 === 'xlink:href') {
|
|
704
|
+
node_1.setAttributeNS('http://www.w3.org/1999/xlink', name_1, value);
|
|
705
|
+
}
|
|
706
|
+
else if (name_1 === 'onload' ||
|
|
707
|
+
name_1 === 'onclick' ||
|
|
708
|
+
name_1.substring(0, 7) === 'onmouse') {
|
|
709
|
+
node_1.setAttribute('_' + name_1, value);
|
|
710
|
+
}
|
|
711
|
+
else if (tagName === 'meta' &&
|
|
712
|
+
n.attributes['http-equiv'] === 'Content-Security-Policy' &&
|
|
713
|
+
name_1 === 'content') {
|
|
714
|
+
node_1.setAttribute('csp-content', value);
|
|
715
|
+
return "continue";
|
|
716
|
+
}
|
|
717
|
+
else if (tagName === 'link' &&
|
|
718
|
+
n.attributes.rel === 'preload' &&
|
|
719
|
+
n.attributes.as === 'script') {
|
|
720
|
+
}
|
|
721
|
+
else if (tagName === 'link' &&
|
|
722
|
+
n.attributes.rel === 'prefetch' &&
|
|
723
|
+
typeof n.attributes.href === 'string' &&
|
|
724
|
+
n.attributes.href.endsWith('.js')) {
|
|
725
|
+
}
|
|
726
|
+
else if (tagName === 'img' &&
|
|
727
|
+
n.attributes.srcset &&
|
|
728
|
+
n.attributes.rr_dataURL) {
|
|
729
|
+
node_1.setAttribute('rrweb-original-srcset', n.attributes.srcset);
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
node_1.setAttribute(name_1, value);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
catch (error) {
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
else {
|
|
739
|
+
if (tagName === 'canvas' && name_1 === 'rr_dataURL') {
|
|
740
|
+
var image_1 = document.createElement('img');
|
|
741
|
+
image_1.src = value;
|
|
742
|
+
image_1.onload = function () {
|
|
743
|
+
var ctx = node_1.getContext('2d');
|
|
744
|
+
if (ctx) {
|
|
745
|
+
ctx.drawImage(image_1, 0, 0, image_1.width, image_1.height);
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
else if (tagName === 'img' && name_1 === 'rr_dataURL') {
|
|
750
|
+
var image = node_1;
|
|
751
|
+
if (!image.currentSrc.startsWith('data:')) {
|
|
752
|
+
image.setAttribute('rrweb-original-src', n.attributes.src);
|
|
753
|
+
image.src = value;
|
|
754
|
+
image.setAttribute('rrweb-inline-src', value);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
if (name_1 === 'rr_width') {
|
|
758
|
+
node_1.style.width = value;
|
|
759
|
+
}
|
|
760
|
+
else if (name_1 === 'rr_height') {
|
|
761
|
+
node_1.style.height = value;
|
|
762
|
+
}
|
|
763
|
+
else if (name_1 === 'rr_mediaCurrentTime') {
|
|
764
|
+
node_1.currentTime = n.attributes
|
|
765
|
+
.rr_mediaCurrentTime;
|
|
766
|
+
}
|
|
767
|
+
else if (name_1 === 'rr_mediaState') {
|
|
768
|
+
switch (value) {
|
|
769
|
+
case 'played':
|
|
770
|
+
node_1
|
|
771
|
+
.play()["catch"](function (e) { return console.warn('media playback error', e); });
|
|
772
|
+
break;
|
|
773
|
+
case 'paused':
|
|
774
|
+
node_1.pause();
|
|
775
|
+
break;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
for (var name_1 in n.attributes) {
|
|
781
|
+
_loop_1(name_1);
|
|
782
|
+
}
|
|
783
|
+
if (tagName === 'img') {
|
|
784
|
+
var image = node_1;
|
|
785
|
+
if (!image.currentSrc.startsWith('data:')) {
|
|
786
|
+
var inlineSrc = image.getAttribute('rrweb-inline-src');
|
|
787
|
+
if (inlineSrc === null || inlineSrc === void 0 ? void 0 : inlineSrc.startsWith('data:')) {
|
|
788
|
+
image.src = inlineSrc;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
if (n.isShadowHost) {
|
|
793
|
+
if (!node_1.shadowRoot) {
|
|
794
|
+
node_1.attachShadow({ mode: 'open' });
|
|
795
|
+
}
|
|
796
|
+
else {
|
|
797
|
+
while (node_1.shadowRoot.firstChild) {
|
|
798
|
+
node_1.shadowRoot.removeChild(node_1.shadowRoot.firstChild);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
return node_1;
|
|
803
|
+
case NodeType$2.Text:
|
|
804
|
+
return doc.createTextNode(n.isStyle && hackCss
|
|
805
|
+
? addHoverClass(n.textContent, cache)
|
|
806
|
+
: n.textContent);
|
|
807
|
+
case NodeType$2.CDATA:
|
|
808
|
+
return doc.createCDATASection(n.textContent);
|
|
809
|
+
case NodeType$2.Comment:
|
|
810
|
+
return doc.createComment(n.textContent);
|
|
811
|
+
default:
|
|
812
|
+
return null;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
function buildNodeWithSN(n, options) {
|
|
816
|
+
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;
|
|
817
|
+
var node = buildNode(n, { doc: doc, hackCss: hackCss, cache: cache });
|
|
818
|
+
if (!node) {
|
|
819
|
+
return null;
|
|
820
|
+
}
|
|
821
|
+
if (n.rootId) {
|
|
822
|
+
console.assert(mirror.getNode(n.rootId) === doc, 'Target document should have the same root id.');
|
|
823
|
+
}
|
|
824
|
+
if (n.type === NodeType$2.Document) {
|
|
825
|
+
doc.close();
|
|
826
|
+
doc.open();
|
|
827
|
+
if (n.compatMode === 'BackCompat' &&
|
|
828
|
+
n.childNodes &&
|
|
829
|
+
n.childNodes[0].type !== NodeType$2.DocumentType) {
|
|
830
|
+
if (n.childNodes[0].type === NodeType$2.Element &&
|
|
831
|
+
'xmlns' in n.childNodes[0].attributes &&
|
|
832
|
+
n.childNodes[0].attributes.xmlns === 'http://www.w3.org/1999/xhtml') {
|
|
833
|
+
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">');
|
|
834
|
+
}
|
|
835
|
+
else {
|
|
836
|
+
doc.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">');
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
node = doc;
|
|
840
|
+
}
|
|
841
|
+
mirror.add(node, n);
|
|
842
|
+
if ((n.type === NodeType$2.Document || n.type === NodeType$2.Element) &&
|
|
843
|
+
!skipChild) {
|
|
844
|
+
for (var _i = 0, _c = n.childNodes; _i < _c.length; _i++) {
|
|
845
|
+
var childN = _c[_i];
|
|
846
|
+
var childNode = buildNodeWithSN(childN, {
|
|
847
|
+
doc: doc,
|
|
848
|
+
mirror: mirror,
|
|
849
|
+
skipChild: false,
|
|
850
|
+
hackCss: hackCss,
|
|
851
|
+
afterAppend: afterAppend,
|
|
852
|
+
cache: cache
|
|
853
|
+
});
|
|
854
|
+
if (!childNode) {
|
|
855
|
+
console.warn('Failed to rebuild', childN);
|
|
856
|
+
continue;
|
|
857
|
+
}
|
|
858
|
+
if (childN.isShadow && isElement(node) && node.shadowRoot) {
|
|
859
|
+
node.shadowRoot.appendChild(childNode);
|
|
860
|
+
}
|
|
861
|
+
else {
|
|
862
|
+
node.appendChild(childNode);
|
|
863
|
+
}
|
|
864
|
+
if (afterAppend) {
|
|
865
|
+
afterAppend(childNode);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
return node;
|
|
870
|
+
}
|
|
871
|
+
function visit(mirror, onVisit) {
|
|
872
|
+
function walk(node) {
|
|
873
|
+
onVisit(node);
|
|
874
|
+
}
|
|
875
|
+
for (var _i = 0, _a = mirror.getIds(); _i < _a.length; _i++) {
|
|
876
|
+
var id = _a[_i];
|
|
877
|
+
if (mirror.has(id)) {
|
|
878
|
+
walk(mirror.getNode(id));
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
function handleScroll(node, mirror) {
|
|
883
|
+
var n = mirror.getMeta(node);
|
|
884
|
+
if ((n === null || n === void 0 ? void 0 : n.type) !== NodeType$2.Element) {
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
var el = node;
|
|
888
|
+
for (var name_2 in n.attributes) {
|
|
889
|
+
if (!(n.attributes.hasOwnProperty(name_2) && name_2.startsWith('rr_'))) {
|
|
890
|
+
continue;
|
|
891
|
+
}
|
|
892
|
+
var value = n.attributes[name_2];
|
|
893
|
+
if (name_2 === 'rr_scrollLeft') {
|
|
894
|
+
el.scrollLeft = value;
|
|
895
|
+
}
|
|
896
|
+
if (name_2 === 'rr_scrollTop') {
|
|
897
|
+
el.scrollTop = value;
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
function rebuild(n, options) {
|
|
902
|
+
var doc = options.doc, onVisit = options.onVisit, _a = options.hackCss, hackCss = _a === void 0 ? true : _a, afterAppend = options.afterAppend, cache = options.cache, _b = options.mirror, mirror = _b === void 0 ? new Mirror$2() : _b;
|
|
903
|
+
var node = buildNodeWithSN(n, {
|
|
904
|
+
doc: doc,
|
|
905
|
+
mirror: mirror,
|
|
906
|
+
skipChild: false,
|
|
907
|
+
hackCss: hackCss,
|
|
908
|
+
afterAppend: afterAppend,
|
|
909
|
+
cache: cache
|
|
910
|
+
});
|
|
911
|
+
visit(mirror, function (visitedNode) {
|
|
912
|
+
if (onVisit) {
|
|
913
|
+
onVisit(visitedNode);
|
|
914
|
+
}
|
|
915
|
+
handleScroll(visitedNode, mirror);
|
|
916
|
+
});
|
|
917
|
+
return node;
|
|
918
918
|
}
|
|
919
919
|
|
|
920
|
-
var NodeType$1;
|
|
921
|
-
(function (NodeType) {
|
|
922
|
-
NodeType[NodeType["Document"] = 0] = "Document";
|
|
923
|
-
NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
|
|
924
|
-
NodeType[NodeType["Element"] = 2] = "Element";
|
|
925
|
-
NodeType[NodeType["Text"] = 3] = "Text";
|
|
926
|
-
NodeType[NodeType["CDATA"] = 4] = "CDATA";
|
|
927
|
-
NodeType[NodeType["Comment"] = 5] = "Comment";
|
|
920
|
+
var NodeType$1;
|
|
921
|
+
(function (NodeType) {
|
|
922
|
+
NodeType[NodeType["Document"] = 0] = "Document";
|
|
923
|
+
NodeType[NodeType["DocumentType"] = 1] = "DocumentType";
|
|
924
|
+
NodeType[NodeType["Element"] = 2] = "Element";
|
|
925
|
+
NodeType[NodeType["Text"] = 3] = "Text";
|
|
926
|
+
NodeType[NodeType["CDATA"] = 4] = "CDATA";
|
|
927
|
+
NodeType[NodeType["Comment"] = 5] = "Comment";
|
|
928
928
|
})(NodeType$1 || (NodeType$1 = {}));
|
|
929
|
-
var Mirror$1 = (function () {
|
|
930
|
-
function Mirror() {
|
|
931
|
-
this.idNodeMap = new Map();
|
|
932
|
-
this.nodeMetaMap = new WeakMap();
|
|
933
|
-
}
|
|
934
|
-
Mirror.prototype.getId = function (n) {
|
|
935
|
-
var _a;
|
|
936
|
-
if (!n)
|
|
937
|
-
return -1;
|
|
938
|
-
var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
|
|
939
|
-
return id !== null && id !== void 0 ? id : -1;
|
|
940
|
-
};
|
|
941
|
-
Mirror.prototype.getNode = function (id) {
|
|
942
|
-
return this.idNodeMap.get(id) || null;
|
|
943
|
-
};
|
|
944
|
-
Mirror.prototype.getIds = function () {
|
|
945
|
-
return Array.from(this.idNodeMap.keys());
|
|
946
|
-
};
|
|
947
|
-
Mirror.prototype.getMeta = function (n) {
|
|
948
|
-
return this.nodeMetaMap.get(n) || null;
|
|
949
|
-
};
|
|
950
|
-
Mirror.prototype.removeNodeFromMap = function (n) {
|
|
951
|
-
var _this = this;
|
|
952
|
-
var id = this.getId(n);
|
|
953
|
-
this.idNodeMap["delete"](id);
|
|
954
|
-
if (n.childNodes) {
|
|
955
|
-
n.childNodes.forEach(function (childNode) {
|
|
956
|
-
return _this.removeNodeFromMap(childNode);
|
|
957
|
-
});
|
|
958
|
-
}
|
|
959
|
-
};
|
|
960
|
-
Mirror.prototype.has = function (id) {
|
|
961
|
-
return this.idNodeMap.has(id);
|
|
962
|
-
};
|
|
963
|
-
Mirror.prototype.hasNode = function (node) {
|
|
964
|
-
return this.nodeMetaMap.has(node);
|
|
965
|
-
};
|
|
966
|
-
Mirror.prototype.add = function (n, meta) {
|
|
967
|
-
var id = meta.id;
|
|
968
|
-
this.idNodeMap.set(id, n);
|
|
969
|
-
this.nodeMetaMap.set(n, meta);
|
|
970
|
-
};
|
|
971
|
-
Mirror.prototype.replace = function (id, n) {
|
|
972
|
-
this.idNodeMap.set(id, n);
|
|
973
|
-
};
|
|
974
|
-
Mirror.prototype.reset = function () {
|
|
975
|
-
this.idNodeMap = new Map();
|
|
976
|
-
this.nodeMetaMap = new WeakMap();
|
|
977
|
-
};
|
|
978
|
-
return Mirror;
|
|
979
|
-
}());
|
|
980
|
-
function createMirror$1() {
|
|
981
|
-
return new Mirror$1();
|
|
929
|
+
var Mirror$1 = (function () {
|
|
930
|
+
function Mirror() {
|
|
931
|
+
this.idNodeMap = new Map();
|
|
932
|
+
this.nodeMetaMap = new WeakMap();
|
|
933
|
+
}
|
|
934
|
+
Mirror.prototype.getId = function (n) {
|
|
935
|
+
var _a;
|
|
936
|
+
if (!n)
|
|
937
|
+
return -1;
|
|
938
|
+
var id = (_a = this.getMeta(n)) === null || _a === void 0 ? void 0 : _a.id;
|
|
939
|
+
return id !== null && id !== void 0 ? id : -1;
|
|
940
|
+
};
|
|
941
|
+
Mirror.prototype.getNode = function (id) {
|
|
942
|
+
return this.idNodeMap.get(id) || null;
|
|
943
|
+
};
|
|
944
|
+
Mirror.prototype.getIds = function () {
|
|
945
|
+
return Array.from(this.idNodeMap.keys());
|
|
946
|
+
};
|
|
947
|
+
Mirror.prototype.getMeta = function (n) {
|
|
948
|
+
return this.nodeMetaMap.get(n) || null;
|
|
949
|
+
};
|
|
950
|
+
Mirror.prototype.removeNodeFromMap = function (n) {
|
|
951
|
+
var _this = this;
|
|
952
|
+
var id = this.getId(n);
|
|
953
|
+
this.idNodeMap["delete"](id);
|
|
954
|
+
if (n.childNodes) {
|
|
955
|
+
n.childNodes.forEach(function (childNode) {
|
|
956
|
+
return _this.removeNodeFromMap(childNode);
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
};
|
|
960
|
+
Mirror.prototype.has = function (id) {
|
|
961
|
+
return this.idNodeMap.has(id);
|
|
962
|
+
};
|
|
963
|
+
Mirror.prototype.hasNode = function (node) {
|
|
964
|
+
return this.nodeMetaMap.has(node);
|
|
965
|
+
};
|
|
966
|
+
Mirror.prototype.add = function (n, meta) {
|
|
967
|
+
var id = meta.id;
|
|
968
|
+
this.idNodeMap.set(id, n);
|
|
969
|
+
this.nodeMetaMap.set(n, meta);
|
|
970
|
+
};
|
|
971
|
+
Mirror.prototype.replace = function (id, n) {
|
|
972
|
+
this.idNodeMap.set(id, n);
|
|
973
|
+
};
|
|
974
|
+
Mirror.prototype.reset = function () {
|
|
975
|
+
this.idNodeMap = new Map();
|
|
976
|
+
this.nodeMetaMap = new WeakMap();
|
|
977
|
+
};
|
|
978
|
+
return Mirror;
|
|
979
|
+
}());
|
|
980
|
+
function createMirror$1() {
|
|
981
|
+
return new Mirror$1();
|
|
982
982
|
}
|
|
983
983
|
|
|
984
984
|
function parseCSSText(cssText) {
|
|
@@ -1543,7 +1543,7 @@ function diffProps(oldTree, newTree, rrnodeMirror) {
|
|
|
1543
1543
|
newTree.scrollTop && (oldTree.scrollTop = newTree.scrollTop);
|
|
1544
1544
|
}
|
|
1545
1545
|
function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirror) {
|
|
1546
|
-
var _a
|
|
1546
|
+
var _a;
|
|
1547
1547
|
let oldStartIndex = 0, oldEndIndex = oldChildren.length - 1, newStartIndex = 0, newEndIndex = newChildren.length - 1;
|
|
1548
1548
|
let oldStartNode = oldChildren[oldStartIndex], oldEndNode = oldChildren[oldEndIndex], newStartNode = newChildren[newStartIndex], newEndNode = newChildren[newEndIndex];
|
|
1549
1549
|
let oldIdToIndex = undefined, indexInOld;
|
|
@@ -1565,26 +1565,16 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
|
|
|
1565
1565
|
newEndNode = newChildren[--newEndIndex];
|
|
1566
1566
|
}
|
|
1567
1567
|
else if (replayer.mirror.getId(oldStartNode) === rrnodeMirror.getId(newEndNode)) {
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
console.error(e, parentNode, oldStartNode, oldEndNode);
|
|
1573
|
-
diff(oldStartNode, newEndNode, replayer, rrnodeMirror);
|
|
1574
|
-
oldStartNode = oldChildren[++oldStartIndex];
|
|
1575
|
-
newEndNode = newChildren[--newEndIndex];
|
|
1576
|
-
}
|
|
1568
|
+
parentNode.insertBefore(oldStartNode, oldEndNode.nextSibling);
|
|
1569
|
+
diff(oldStartNode, newEndNode, replayer, rrnodeMirror);
|
|
1570
|
+
oldStartNode = oldChildren[++oldStartIndex];
|
|
1571
|
+
newEndNode = newChildren[--newEndIndex];
|
|
1577
1572
|
}
|
|
1578
1573
|
else if (replayer.mirror.getId(oldEndNode) === rrnodeMirror.getId(newStartNode)) {
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
console.error(e, parentNode, oldEndNode, oldStartNode);
|
|
1584
|
-
diff(oldEndNode, newStartNode, replayer, rrnodeMirror);
|
|
1585
|
-
oldEndNode = oldChildren[--oldEndIndex];
|
|
1586
|
-
newStartNode = newChildren[++newStartIndex];
|
|
1587
|
-
}
|
|
1574
|
+
parentNode.insertBefore(oldEndNode, oldStartNode);
|
|
1575
|
+
diff(oldEndNode, newStartNode, replayer, rrnodeMirror);
|
|
1576
|
+
oldEndNode = oldChildren[--oldEndIndex];
|
|
1577
|
+
newStartNode = newChildren[++newStartIndex];
|
|
1588
1578
|
}
|
|
1589
1579
|
else {
|
|
1590
1580
|
if (!oldIdToIndex) {
|
|
@@ -1598,31 +1588,21 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
|
|
|
1598
1588
|
indexInOld = oldIdToIndex[rrnodeMirror.getId(newStartNode)];
|
|
1599
1589
|
if (indexInOld) {
|
|
1600
1590
|
const nodeToMove = oldChildren[indexInOld];
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
catch (e) {
|
|
1605
|
-
console.error(e, parentNode, nodeToMove, oldStartNode);
|
|
1606
|
-
diff(nodeToMove, newStartNode, replayer, rrnodeMirror);
|
|
1607
|
-
oldChildren[indexInOld] = undefined;
|
|
1608
|
-
}
|
|
1591
|
+
parentNode.insertBefore(nodeToMove, oldStartNode);
|
|
1592
|
+
diff(nodeToMove, newStartNode, replayer, rrnodeMirror);
|
|
1593
|
+
oldChildren[indexInOld] = undefined;
|
|
1609
1594
|
}
|
|
1610
1595
|
else {
|
|
1611
1596
|
const newNode = createOrGetNode(newStartNode, replayer.mirror, rrnodeMirror);
|
|
1612
|
-
if (
|
|
1613
|
-
((
|
|
1597
|
+
if (parentNode.nodeName === '#document' &&
|
|
1598
|
+
((_a = replayer.mirror.getMeta(newNode)) === null || _a === void 0 ? void 0 : _a.type) === NodeType$1.Element &&
|
|
1614
1599
|
parentNode.documentElement) {
|
|
1615
1600
|
parentNode.removeChild(parentNode.documentElement);
|
|
1616
1601
|
oldChildren[oldStartIndex] = undefined;
|
|
1617
1602
|
oldStartNode = undefined;
|
|
1618
1603
|
}
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
}
|
|
1622
|
-
catch (e) {
|
|
1623
|
-
console.error(e, parentNode, newNode, oldStartNode || null);
|
|
1624
|
-
diff(newNode, newStartNode, replayer, rrnodeMirror);
|
|
1625
|
-
}
|
|
1604
|
+
parentNode.insertBefore(newNode, oldStartNode || null);
|
|
1605
|
+
diff(newNode, newStartNode, replayer, rrnodeMirror);
|
|
1626
1606
|
}
|
|
1627
1607
|
newStartNode = newChildren[++newStartIndex];
|
|
1628
1608
|
}
|
|
@@ -1637,13 +1617,8 @@ function diffChildren(oldChildren, newChildren, parentNode, replayer, rrnodeMirr
|
|
|
1637
1617
|
});
|
|
1638
1618
|
for (; newStartIndex <= newEndIndex; ++newStartIndex) {
|
|
1639
1619
|
const newNode = createOrGetNode(newChildren[newStartIndex], replayer.mirror, rrnodeMirror);
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
}
|
|
1643
|
-
catch (e) {
|
|
1644
|
-
console.error(e, parentNode, newNode, referenceNode);
|
|
1645
|
-
diff(newNode, newChildren[newStartIndex], replayer, rrnodeMirror);
|
|
1646
|
-
}
|
|
1620
|
+
parentNode.insertBefore(newNode, referenceNode);
|
|
1621
|
+
diff(newNode, newChildren[newStartIndex], replayer, rrnodeMirror);
|
|
1647
1622
|
}
|
|
1648
1623
|
}
|
|
1649
1624
|
else if (newStartIndex > newEndIndex) {
|
|
@@ -1877,11 +1852,11 @@ function buildFromNode(node, rrdom, domMirror, parentRRNode) {
|
|
|
1877
1852
|
}
|
|
1878
1853
|
break;
|
|
1879
1854
|
case NodeType.DOCUMENT_TYPE_NODE:
|
|
1880
|
-
const documentType =
|
|
1855
|
+
const documentType = node;
|
|
1881
1856
|
rrNode = rrdom.createDocumentType(documentType.name, documentType.publicId, documentType.systemId);
|
|
1882
1857
|
break;
|
|
1883
1858
|
case NodeType.ELEMENT_NODE:
|
|
1884
|
-
const elementNode =
|
|
1859
|
+
const elementNode = node;
|
|
1885
1860
|
const tagName = getValidTagName(elementNode);
|
|
1886
1861
|
rrNode = rrdom.createElement(tagName);
|
|
1887
1862
|
const rrElement = rrNode;
|
|
@@ -1892,13 +1867,13 @@ function buildFromNode(node, rrdom, domMirror, parentRRNode) {
|
|
|
1892
1867
|
elementNode.scrollTop && (rrElement.scrollTop = elementNode.scrollTop);
|
|
1893
1868
|
break;
|
|
1894
1869
|
case NodeType.TEXT_NODE:
|
|
1895
|
-
rrNode = rrdom.createTextNode(
|
|
1870
|
+
rrNode = rrdom.createTextNode(node.textContent || '');
|
|
1896
1871
|
break;
|
|
1897
1872
|
case NodeType.CDATA_SECTION_NODE:
|
|
1898
|
-
rrNode = rrdom.createCDATASection(
|
|
1873
|
+
rrNode = rrdom.createCDATASection(node.data);
|
|
1899
1874
|
break;
|
|
1900
1875
|
case NodeType.COMMENT_NODE:
|
|
1901
|
-
rrNode = rrdom.createComment(
|
|
1876
|
+
rrNode = rrdom.createComment(node.textContent || '');
|
|
1902
1877
|
break;
|
|
1903
1878
|
case NodeType.DOCUMENT_FRAGMENT_NODE:
|
|
1904
1879
|
rrNode = parentRRNode.attachShadow({ mode: 'open' });
|
|
@@ -1934,8 +1909,8 @@ function buildFromDom(dom, domMirror = createMirror$1(), rrdom = new RRDocument(
|
|
|
1934
1909
|
node.nodeType === NodeType.ELEMENT_NODE ||
|
|
1935
1910
|
node.nodeType === NodeType.DOCUMENT_FRAGMENT_NODE) {
|
|
1936
1911
|
if (node.nodeType === NodeType.ELEMENT_NODE &&
|
|
1937
|
-
|
|
1938
|
-
walk(
|
|
1912
|
+
node.shadowRoot)
|
|
1913
|
+
walk(node.shadowRoot, rrNode);
|
|
1939
1914
|
node.childNodes.forEach((childNode) => walk(childNode, rrNode));
|
|
1940
1915
|
}
|
|
1941
1916
|
}
|
|
@@ -3777,7 +3752,7 @@ class Replayer {
|
|
|
3777
3752
|
const styleEl = document.createElement('style');
|
|
3778
3753
|
documentElement.insertBefore(styleEl, head);
|
|
3779
3754
|
for (let idx = 0; idx < injectStylesRules.length; idx++) {
|
|
3780
|
-
|
|
3755
|
+
styleEl.sheet.insertRule(injectStylesRules[idx], idx);
|
|
3781
3756
|
}
|
|
3782
3757
|
}
|
|
3783
3758
|
}
|
|
@@ -4162,7 +4137,7 @@ class Replayer {
|
|
|
4162
4137
|
if (!target) {
|
|
4163
4138
|
return this.debugNodeNotFound(d, d.id);
|
|
4164
4139
|
}
|
|
4165
|
-
const styleSheet =
|
|
4140
|
+
const styleSheet = target.sheet;
|
|
4166
4141
|
(_d = d.adds) === null || _d === void 0 ? void 0 : _d.forEach(({ rule, index: nestedIndex }) => {
|
|
4167
4142
|
try {
|
|
4168
4143
|
if (Array.isArray(nestedIndex)) {
|