@highlight-run/rrweb 2.0.5 → 2.0.8
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 +1 -1
- package/dist/plugins/console-record.min.js +1 -1
- 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 +3 -3
- package/dist/replay/rrweb-replay.min.js +3 -3
- package/dist/replay/rrweb-replay.min.js.map +1 -1
- package/dist/rrweb-all.js +12 -12
- package/dist/rrweb-all.min.js +12 -12
- 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/rrweb/src/record/mutation.js +23 -11
- package/es/rrweb/packages/rrweb/src/record/observer.js +6 -6
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +1 -1
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +2 -2
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +1 -2
- package/es/rrweb/packages/rrweb/src/utils.js +16 -23
- package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +278 -241
- package/lib/record/rrweb-record.js +325 -284
- package/lib/rrweb-all.js +325 -284
- package/lib/rrweb.js +325 -284
- package/package.json +4 -4
- package/typings/utils.d.ts +1 -1
|
@@ -166,6 +166,7 @@ class MutationBuffer {
|
|
|
166
166
|
onStylesheetLoad: (link, childSn) => {
|
|
167
167
|
this.stylesheetManager.attachStylesheet(link, childSn, this.mirror);
|
|
168
168
|
},
|
|
169
|
+
newlyAddedElement: true,
|
|
169
170
|
});
|
|
170
171
|
if (sn) {
|
|
171
172
|
adds.push({
|
|
@@ -274,7 +275,8 @@ class MutationBuffer {
|
|
|
274
275
|
switch (m.type) {
|
|
275
276
|
case 'characterData': {
|
|
276
277
|
const value = m.target.textContent;
|
|
277
|
-
if (!isBlocked(m.target, this.blockClass) &&
|
|
278
|
+
if (!isBlocked(m.target, this.blockClass, false) &&
|
|
279
|
+
value !== m.oldValue) {
|
|
278
280
|
this.texts.push({
|
|
279
281
|
value: needMaskingText(m.target, this.maskTextClass, this.maskTextSelector) && value
|
|
280
282
|
? this.maskTextFn
|
|
@@ -298,7 +300,8 @@ class MutationBuffer {
|
|
|
298
300
|
maskInputFn: this.maskInputFn,
|
|
299
301
|
});
|
|
300
302
|
}
|
|
301
|
-
if (isBlocked(m.target, this.blockClass) ||
|
|
303
|
+
if (isBlocked(m.target, this.blockClass, false) ||
|
|
304
|
+
value === m.oldValue) {
|
|
302
305
|
return;
|
|
303
306
|
}
|
|
304
307
|
let item = this.attributes.find((a) => a.node === m.target);
|
|
@@ -352,13 +355,15 @@ class MutationBuffer {
|
|
|
352
355
|
break;
|
|
353
356
|
}
|
|
354
357
|
case 'childList': {
|
|
358
|
+
if (isBlocked(m.target, this.blockClass, true))
|
|
359
|
+
return;
|
|
355
360
|
m.addedNodes.forEach((n) => this.genAdds(n, m.target));
|
|
356
361
|
m.removedNodes.forEach((n) => {
|
|
357
362
|
const nodeId = this.mirror.getId(n);
|
|
358
363
|
const parentId = isShadowRoot(m.target)
|
|
359
364
|
? this.mirror.getId(m.target.host)
|
|
360
365
|
: this.mirror.getId(m.target);
|
|
361
|
-
if (isBlocked(m.target, this.blockClass) ||
|
|
366
|
+
if (isBlocked(m.target, this.blockClass, false) ||
|
|
362
367
|
isIgnored(n, this.mirror) ||
|
|
363
368
|
!isSerialized(n, this.mirror)) {
|
|
364
369
|
return;
|
|
@@ -387,16 +392,13 @@ class MutationBuffer {
|
|
|
387
392
|
}
|
|
388
393
|
};
|
|
389
394
|
this.genAdds = (n, target) => {
|
|
390
|
-
if (
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
if (this.mirror.getMeta(n)) {
|
|
395
|
+
if (this.mirror.hasNode(n)) {
|
|
394
396
|
if (isIgnored(n, this.mirror)) {
|
|
395
397
|
return;
|
|
396
398
|
}
|
|
397
399
|
this.movedSet.add(n);
|
|
398
400
|
let targetId = null;
|
|
399
|
-
if (target && this.mirror.
|
|
401
|
+
if (target && this.mirror.hasNode(target)) {
|
|
400
402
|
targetId = this.mirror.getId(target);
|
|
401
403
|
}
|
|
402
404
|
if (targetId && targetId !== -1) {
|
|
@@ -407,7 +409,7 @@ class MutationBuffer {
|
|
|
407
409
|
this.addedSet.add(n);
|
|
408
410
|
this.droppedSet.delete(n);
|
|
409
411
|
}
|
|
410
|
-
if (!isBlocked(n, this.blockClass))
|
|
412
|
+
if (!isBlocked(n, this.blockClass, false))
|
|
411
413
|
n.childNodes.forEach((childN) => this.genAdds(childN));
|
|
412
414
|
};
|
|
413
415
|
}
|
|
@@ -467,6 +469,11 @@ function deepDelete(addsSet, n) {
|
|
|
467
469
|
n.childNodes.forEach((childN) => deepDelete(addsSet, childN));
|
|
468
470
|
}
|
|
469
471
|
function isParentRemoved(removes, n, mirror) {
|
|
472
|
+
if (removes.length === 0)
|
|
473
|
+
return false;
|
|
474
|
+
return _isParentRemoved(removes, n, mirror);
|
|
475
|
+
}
|
|
476
|
+
function _isParentRemoved(removes, n, mirror) {
|
|
470
477
|
const { parentNode } = n;
|
|
471
478
|
if (!parentNode) {
|
|
472
479
|
return false;
|
|
@@ -475,9 +482,14 @@ function isParentRemoved(removes, n, mirror) {
|
|
|
475
482
|
if (removes.some((r) => r.id === parentId)) {
|
|
476
483
|
return true;
|
|
477
484
|
}
|
|
478
|
-
return
|
|
485
|
+
return _isParentRemoved(removes, parentNode, mirror);
|
|
479
486
|
}
|
|
480
487
|
function isAncestorInSet(set, n) {
|
|
488
|
+
if (set.size === 0)
|
|
489
|
+
return false;
|
|
490
|
+
return _isAncestorInSet(set, n);
|
|
491
|
+
}
|
|
492
|
+
function _isAncestorInSet(set, n) {
|
|
481
493
|
const { parentNode } = n;
|
|
482
494
|
if (!parentNode) {
|
|
483
495
|
return false;
|
|
@@ -485,7 +497,7 @@ function isAncestorInSet(set, n) {
|
|
|
485
497
|
if (set.has(parentNode)) {
|
|
486
498
|
return true;
|
|
487
499
|
}
|
|
488
|
-
return
|
|
500
|
+
return _isAncestorInSet(set, parentNode);
|
|
489
501
|
}
|
|
490
502
|
|
|
491
503
|
export { MutationBuffer as default };
|
|
@@ -110,7 +110,7 @@ function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockCl
|
|
|
110
110
|
const getHandler = (eventKey) => {
|
|
111
111
|
return (event) => {
|
|
112
112
|
const target = getEventTarget(event);
|
|
113
|
-
if (isBlocked(target, blockClass) ||
|
|
113
|
+
if (isBlocked(target, blockClass, true) ||
|
|
114
114
|
isCanvasNode(target)) {
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
@@ -144,7 +144,7 @@ function initMouseInteractionObserver({ mouseInteractionCb, doc, mirror, blockCl
|
|
|
144
144
|
function initScrollObserver({ scrollCb, doc, mirror, blockClass, sampling, }) {
|
|
145
145
|
const updatePosition = throttle((evt) => {
|
|
146
146
|
const target = getEventTarget(evt);
|
|
147
|
-
if (!target || isBlocked(target, blockClass)) {
|
|
147
|
+
if (!target || isBlocked(target, blockClass, true)) {
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
150
|
const id = mirror.getId(target);
|
|
@@ -200,7 +200,7 @@ function initInputObserver({ inputCb, doc, mirror, blockClass, ignoreClass, mask
|
|
|
200
200
|
if (!target ||
|
|
201
201
|
!target.tagName ||
|
|
202
202
|
INPUT_TAGS.indexOf(target.tagName) < 0 ||
|
|
203
|
-
isBlocked(target, blockClass)) {
|
|
203
|
+
isBlocked(target, blockClass, true)) {
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
206
|
const type = target.type;
|
|
@@ -335,8 +335,8 @@ function initStyleSheetObserver({ styleSheetRuleCb, mirror }, { win }) {
|
|
|
335
335
|
const unmodifiedFunctions = {};
|
|
336
336
|
Object.entries(supportedNestedCSSRuleTypes).forEach(([typeKey, type]) => {
|
|
337
337
|
unmodifiedFunctions[typeKey] = {
|
|
338
|
-
insertRule:
|
|
339
|
-
deleteRule:
|
|
338
|
+
insertRule: type.prototype.insertRule,
|
|
339
|
+
deleteRule: type.prototype.deleteRule,
|
|
340
340
|
};
|
|
341
341
|
type.prototype.insertRule = function (rule, index) {
|
|
342
342
|
const id = mirror.getId(this.parentStyleSheet.ownerNode);
|
|
@@ -417,7 +417,7 @@ function initStyleDeclarationObserver({ styleDeclarationCb, mirror }, { win }) {
|
|
|
417
417
|
function initMediaInteractionObserver({ mediaInteractionCb, blockClass, mirror, sampling, }) {
|
|
418
418
|
const handler = (type) => throttle((event) => {
|
|
419
419
|
const target = getEventTarget(event);
|
|
420
|
-
if (!target || isBlocked(target, blockClass)) {
|
|
420
|
+
if (!target || isBlocked(target, blockClass, true)) {
|
|
421
421
|
return;
|
|
422
422
|
}
|
|
423
423
|
const { currentTime, volume, muted } = target;
|
|
@@ -12,7 +12,7 @@ function initCanvas2DMutationObserver(cb, win, blockClass, mirror) {
|
|
|
12
12
|
}
|
|
13
13
|
const restoreHandler = patch(win.CanvasRenderingContext2D.prototype, prop, function (original) {
|
|
14
14
|
return function (...args) {
|
|
15
|
-
if (!isBlocked(this.canvas, blockClass)) {
|
|
15
|
+
if (!isBlocked(this.canvas, blockClass, true)) {
|
|
16
16
|
setTimeout(() => {
|
|
17
17
|
const recordArgs = serializeArgs([...args], win, this);
|
|
18
18
|
cb(this.canvas, {
|
|
@@ -5,9 +5,9 @@ function initCanvasContextObserver(win, blockClass) {
|
|
|
5
5
|
try {
|
|
6
6
|
const restoreHandler = patch(win.HTMLCanvasElement.prototype, 'getContext', function (original) {
|
|
7
7
|
return function (contextType, ...args) {
|
|
8
|
-
if (!isBlocked(this, blockClass)) {
|
|
8
|
+
if (!isBlocked(this, blockClass, true)) {
|
|
9
9
|
if (!('__context' in this))
|
|
10
|
-
|
|
10
|
+
this.__context = contextType;
|
|
11
11
|
}
|
|
12
12
|
return original.apply(this, [contextType, ...args]);
|
|
13
13
|
};
|
|
@@ -14,8 +14,7 @@ function patchGLPrototype(prototype, type, cb, blockClass, mirror, win) {
|
|
|
14
14
|
return function (...args) {
|
|
15
15
|
const result = original.apply(this, args);
|
|
16
16
|
saveWebGLVar(result, win, prototype);
|
|
17
|
-
if (!isBlocked(this.canvas, blockClass)) {
|
|
18
|
-
const id = mirror.getId(this.canvas);
|
|
17
|
+
if (!isBlocked(this.canvas, blockClass, true)) {
|
|
19
18
|
const recordArgs = serializeArgs([...args], win, prototype);
|
|
20
19
|
const mutation = {
|
|
21
20
|
type,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IGNORED_NODE, isShadowRoot } from '../../rrweb-snapshot/es/rrweb-snapshot.js';
|
|
1
|
+
import { classMatchesRegex, IGNORED_NODE, isShadowRoot } from '../../rrweb-snapshot/es/rrweb-snapshot.js';
|
|
2
2
|
|
|
3
3
|
function on(type, fn, target = document) {
|
|
4
4
|
const options = { capture: true, passive: true };
|
|
@@ -131,33 +131,26 @@ const isCanvasNode = (node) => {
|
|
|
131
131
|
}
|
|
132
132
|
return false;
|
|
133
133
|
};
|
|
134
|
-
function isBlocked(node, blockClass) {
|
|
134
|
+
function isBlocked(node, blockClass, checkAncestors) {
|
|
135
135
|
if (!node) {
|
|
136
136
|
return false;
|
|
137
137
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
else {
|
|
149
|
-
node.classList.forEach((className) => {
|
|
150
|
-
if (blockClass.test(className)) {
|
|
151
|
-
needBlock = true;
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
return needBlock || isBlocked(node.parentNode, blockClass);
|
|
138
|
+
const el = node.nodeType === node.ELEMENT_NODE
|
|
139
|
+
? node
|
|
140
|
+
: node.parentElement;
|
|
141
|
+
if (!el)
|
|
142
|
+
return false;
|
|
143
|
+
if (typeof blockClass === 'string') {
|
|
144
|
+
if (el.classList.contains(blockClass))
|
|
145
|
+
return true;
|
|
146
|
+
if (checkAncestors && el.closest('.' + blockClass) !== null)
|
|
147
|
+
return true;
|
|
156
148
|
}
|
|
157
|
-
|
|
158
|
-
|
|
149
|
+
else {
|
|
150
|
+
if (classMatchesRegex(el, blockClass, checkAncestors))
|
|
151
|
+
return true;
|
|
159
152
|
}
|
|
160
|
-
return
|
|
153
|
+
return false;
|
|
161
154
|
}
|
|
162
155
|
function isSerialized(n, mirror) {
|
|
163
156
|
return mirror.getId(n) !== -1;
|