@highlight-run/rrweb 1.2.1 → 2.0.4
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 +454 -0
- package/dist/plugins/console-record.min.js +12 -15
- package/dist/plugins/console-record.min.js.map +1 -1
- package/dist/plugins/console-replay.js +164 -0
- package/dist/plugins/console-replay.min.js +5 -0
- package/dist/plugins/console-replay.min.js.map +1 -0
- package/dist/plugins/sequential-id-record.js +30 -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 +33 -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 +664 -0
- package/dist/record/rrweb-record-pack.min.js +4 -0
- package/dist/record/rrweb-record-pack.min.js.map +1 -0
- package/dist/record/rrweb-record.js +3202 -0
- package/dist/record/rrweb-record.min.js +5 -0
- package/dist/record/rrweb-record.min.js.map +1 -0
- package/dist/replay/rrweb-replay-unpack.js +4926 -0
- package/dist/replay/rrweb-replay-unpack.min.js +18 -0
- package/dist/replay/rrweb-replay-unpack.min.js.map +1 -0
- package/dist/replay/rrweb-replay.js +4518 -0
- package/dist/replay/rrweb-replay.min.js +18 -0
- package/dist/replay/rrweb-replay.min.js.map +1 -0
- package/dist/rrweb-all.js +8889 -0
- package/dist/rrweb-all.min.js +29 -0
- package/dist/rrweb-all.min.js.map +1 -0
- package/dist/rrweb.js +7558 -0
- package/dist/rrweb.min.js +6 -17
- package/dist/rrweb.min.js.map +1 -1
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +31 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
- package/es/rrweb/_virtual/image-bitmap-data-url-worker.js +6 -0
- 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/ext/tslib/tslib.es6.js +38 -0
- package/es/rrweb/packages/rrdom/es/virtual-dom.js +1099 -0
- package/es/rrweb/packages/rrweb/src/entries/all.js +13 -0
- package/es/rrweb/packages/rrweb/src/index.js +14 -0
- package/es/rrweb/packages/rrweb/src/packer/base.js +3 -0
- package/es/rrweb/packages/rrweb/src/packer/pack.js +9 -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 +178 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/record/index.js +115 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js +128 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js +94 -0
- package/es/rrweb/packages/rrweb/src/plugins/sequential-id/record/index.js +22 -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 +31 -0
- package/es/rrweb/packages/rrweb/src/record/index.js +356 -0
- package/es/rrweb/packages/rrweb/src/record/mutation.js +491 -0
- package/es/rrweb/packages/rrweb/src/record/observer.js +590 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +49 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +172 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +25 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js +123 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +59 -0
- package/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js +43 -0
- package/es/rrweb/packages/rrweb/src/record/stylesheet-manager.js +31 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/2d.js +29 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/deserialize-args.js +67 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/index.js +43 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js +62 -0
- package/es/rrweb/packages/rrweb/src/replay/index.js +1555 -0
- package/es/rrweb/packages/rrweb/src/replay/machine.js +281 -0
- package/es/rrweb/packages/rrweb/src/replay/smoothscroll.js +219 -0
- package/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js +8 -0
- package/es/rrweb/packages/rrweb/src/replay/timer.js +92 -0
- package/es/rrweb/packages/rrweb/src/types.js +75 -0
- package/es/rrweb/packages/rrweb/src/utils.js +315 -0
- package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +1821 -0
- package/lib/plugins/console-record.js +492 -0
- package/lib/plugins/console-replay.js +218 -0
- package/lib/plugins/sequential-id-record.js +27 -0
- package/lib/plugins/sequential-id-replay.js +32 -0
- package/lib/record/rrweb-record-pack.js +787 -0
- package/lib/record/rrweb-record.js +3363 -0
- package/lib/replay/rrweb-replay-unpack.js +5075 -0
- package/lib/replay/rrweb-replay.js +4665 -0
- package/lib/rrweb-all.js +9181 -0
- package/lib/rrweb.js +7814 -0
- package/package.json +41 -42
- 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 +1 -1
- 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 +4 -3
- package/{dist → typings}/plugins/console/record/stringify.d.ts +1 -1
- package/{dist → typings}/plugins/console/replay/index.d.ts +2 -2
- package/{dist → typings}/plugins/sequential-id/record/index.d.ts +1 -1
- package/{dist → typings}/plugins/sequential-id/replay/index.d.ts +1 -1
- package/{dist → typings}/record/iframe-manager.d.ts +3 -3
- package/{dist/plugins → typings}/record/index.d.ts +9 -9
- package/{dist → typings}/record/mutation.d.ts +6 -8
- package/typings/record/observer.d.ts +7 -0
- package/{dist/plugins → typings}/record/observers/canvas/2d.d.ts +3 -2
- package/{dist → typings}/record/observers/canvas/canvas-manager.d.ts +5 -2
- package/{dist/plugins → typings}/record/observers/canvas/canvas.d.ts +2 -2
- package/typings/record/observers/canvas/serialize-args.d.ts +6 -0
- package/{dist/plugins → typings}/record/observers/canvas/webgl.d.ts +3 -2
- package/typings/record/observers/canvas/webgl2.d.ts +2 -0
- package/typings/record/shadow-dom-manager.d.ts +22 -0
- package/typings/record/stylesheet-manager.d.ts +12 -0
- package/typings/record/workers/image-bitmap-data-url-worker.d.ts +5 -0
- package/{dist → typings}/replay/canvas/2d.d.ts +3 -3
- package/typings/replay/canvas/deserialize-args.d.ts +7 -0
- package/{dist/plugins → typings}/replay/canvas/index.d.ts +10 -9
- package/typings/replay/canvas/webgl.d.ts +9 -0
- package/{dist → typings}/replay/index.d.ts +7 -9
- 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}/rrdom/index.d.ts +0 -0
- package/{dist → typings}/rrdom/tree-node.d.ts +0 -0
- package/{dist/plugins → typings}/types.d.ts +536 -509
- package/typings/utils.d.ts +43 -0
- 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/mutation.d.ts +0 -45
- package/dist/plugins/record/observer.d.ts +0 -11
- package/dist/plugins/record/observers/canvas/canvas-manager.d.ts +0 -32
- package/dist/plugins/record/observers/canvas/serialize-args.d.ts +0 -6
- 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/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/utils.d.ts +0 -71
- package/dist/record/index.d.ts +0 -9
- package/dist/record/observer.d.ts +0 -11
- package/dist/record/observers/canvas/2d.d.ts +0 -2
- package/dist/record/observers/canvas/canvas.d.ts +0 -2
- package/dist/record/observers/canvas/serialize-args.d.ts +0 -6
- package/dist/record/observers/canvas/webgl.d.ts +0 -2
- package/dist/record/shadow-dom-manager.d.ts +0 -34
- package/dist/replay/canvas/index.d.ts +0 -9
- package/dist/replay/canvas/webgl.d.ts +0 -11
- package/dist/replay/virtual-styles.d.ts +0 -43
- 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
- package/dist/types.d.ts +0 -509
- package/dist/utils.d.ts +0 -71
|
@@ -0,0 +1,1555 @@
|
|
|
1
|
+
import { __awaiter } from './../../../../ext/tslib/tslib.es6.js';
|
|
2
|
+
import { createCache, createMirror, rebuild, buildNodeWithSN, NodeType } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
|
|
3
|
+
import { RRDocument, diff, createOrGetNode, getDefaultSN, StyleRuleType, buildFromDom, buildFromNode } from '../../../rrdom/es/virtual-dom.js';
|
|
4
|
+
import * as mitt_es from './../../../../ext/mitt/dist/mitt.es.js';
|
|
5
|
+
import mitt$1 from './../../../../ext/mitt/dist/mitt.es.js';
|
|
6
|
+
import { polyfill } from './smoothscroll.js';
|
|
7
|
+
import { Timer } from './timer.js';
|
|
8
|
+
import { createPlayerService, createSpeedService } from './machine.js';
|
|
9
|
+
import { ReplayerEvents, EventType, IncrementalSource, MouseInteractions } from '../types.js';
|
|
10
|
+
import { polyfill as polyfill$1, isSerializedIframe, getNestedRule, getPositionsAndIndex, hasShadowRoot, queueToResolveTrees, iterateResolveTree, uniqueTextMutations, getBaseDimension } from '../utils.js';
|
|
11
|
+
import rules from './styles/inject-style.js';
|
|
12
|
+
import canvasMutation from './canvas/index.js';
|
|
13
|
+
import { deserializeArg } from './canvas/deserialize-args.js';
|
|
14
|
+
|
|
15
|
+
const SKIP_TIME_THRESHOLD = 10 * 1000;
|
|
16
|
+
const SKIP_TIME_INTERVAL = 2 * 1000;
|
|
17
|
+
const SKIP_TIME_MIN = 1 * 1000;
|
|
18
|
+
const SKIP_DURATION_LIMIT = 60 * 60 * 1000;
|
|
19
|
+
const mitt = mitt$1 || mitt_es;
|
|
20
|
+
const REPLAY_CONSOLE_PREFIX = '[replayer]';
|
|
21
|
+
const defaultMouseTailConfig = {
|
|
22
|
+
duration: 500,
|
|
23
|
+
lineCap: 'round',
|
|
24
|
+
lineWidth: 3,
|
|
25
|
+
strokeStyle: 'red',
|
|
26
|
+
};
|
|
27
|
+
function indicatesTouchDevice(e) {
|
|
28
|
+
return (e.type == EventType.IncrementalSnapshot &&
|
|
29
|
+
(e.data.source == IncrementalSource.TouchMove ||
|
|
30
|
+
(e.data.source == IncrementalSource.MouseInteraction &&
|
|
31
|
+
e.data.type == MouseInteractions.TouchStart)));
|
|
32
|
+
}
|
|
33
|
+
class Replayer {
|
|
34
|
+
constructor(events, config) {
|
|
35
|
+
this.usingVirtualDom = false;
|
|
36
|
+
this.virtualDom = new RRDocument();
|
|
37
|
+
this.mouseTail = null;
|
|
38
|
+
this.tailPositions = [];
|
|
39
|
+
this.emitter = mitt();
|
|
40
|
+
this.activityIntervals = [];
|
|
41
|
+
this.legacy_missingNodeRetryMap = {};
|
|
42
|
+
this.cache = createCache();
|
|
43
|
+
this.imageMap = new Map();
|
|
44
|
+
this.canvasEventMap = new Map();
|
|
45
|
+
this.mirror = createMirror();
|
|
46
|
+
this.firstFullSnapshot = null;
|
|
47
|
+
this.newDocumentQueue = [];
|
|
48
|
+
this.mousePos = null;
|
|
49
|
+
this.touchActive = null;
|
|
50
|
+
if (!(config === null || config === void 0 ? void 0 : config.liveMode) && events.length < 2) {
|
|
51
|
+
throw new Error('Replayer need at least 2 events.');
|
|
52
|
+
}
|
|
53
|
+
const defaultConfig = {
|
|
54
|
+
speed: 1,
|
|
55
|
+
maxSpeed: 360,
|
|
56
|
+
root: document.body,
|
|
57
|
+
loadTimeout: 0,
|
|
58
|
+
skipInactive: false,
|
|
59
|
+
showWarning: true,
|
|
60
|
+
showDebug: false,
|
|
61
|
+
blockClass: 'highlight-block',
|
|
62
|
+
liveMode: false,
|
|
63
|
+
insertStyleRules: [],
|
|
64
|
+
triggerFocus: true,
|
|
65
|
+
UNSAFE_replayCanvas: false,
|
|
66
|
+
pauseAnimation: true,
|
|
67
|
+
mouseTail: defaultMouseTailConfig,
|
|
68
|
+
useVirtualDom: true,
|
|
69
|
+
inactiveThreshold: 0.02,
|
|
70
|
+
inactiveSkipTime: SKIP_TIME_INTERVAL,
|
|
71
|
+
};
|
|
72
|
+
this.config = Object.assign({}, defaultConfig, config);
|
|
73
|
+
this.handleResize = this.handleResize.bind(this);
|
|
74
|
+
this.getCastFn = this.getCastFn.bind(this);
|
|
75
|
+
this.applyEventsSynchronously = this.applyEventsSynchronously.bind(this);
|
|
76
|
+
this.emitter.on(ReplayerEvents.Resize, this.handleResize);
|
|
77
|
+
this.setupDom();
|
|
78
|
+
this.emitter.on(ReplayerEvents.Flush, () => {
|
|
79
|
+
if (this.usingVirtualDom) {
|
|
80
|
+
const replayerHandler = {
|
|
81
|
+
mirror: this.mirror,
|
|
82
|
+
applyCanvas: (canvasEvent, canvasMutationData, target) => {
|
|
83
|
+
canvasMutation({
|
|
84
|
+
event: canvasEvent,
|
|
85
|
+
mutation: canvasMutationData,
|
|
86
|
+
target,
|
|
87
|
+
imageMap: this.imageMap,
|
|
88
|
+
canvasEventMap: this.canvasEventMap,
|
|
89
|
+
errorHandler: this.warnCanvasMutationFailed.bind(this),
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
applyInput: this.applyInput.bind(this),
|
|
93
|
+
applyScroll: this.applyScroll.bind(this),
|
|
94
|
+
};
|
|
95
|
+
diff(this.iframe.contentDocument, this.virtualDom, replayerHandler, this.virtualDom.mirror);
|
|
96
|
+
this.virtualDom.destroyTree();
|
|
97
|
+
this.usingVirtualDom = false;
|
|
98
|
+
if (Object.keys(this.legacy_missingNodeRetryMap).length) {
|
|
99
|
+
for (const key in this.legacy_missingNodeRetryMap) {
|
|
100
|
+
try {
|
|
101
|
+
const value = this.legacy_missingNodeRetryMap[key];
|
|
102
|
+
const realNode = createOrGetNode(value.node, this.mirror, this.virtualDom.mirror);
|
|
103
|
+
diff(realNode, value.node, replayerHandler, this.virtualDom.mirror);
|
|
104
|
+
value.node = realNode;
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (this.config.showWarning) {
|
|
108
|
+
console.warn(error);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (this.mousePos) {
|
|
115
|
+
this.moveAndHover(this.mousePos.x, this.mousePos.y, this.mousePos.id, true, this.mousePos.debugData);
|
|
116
|
+
}
|
|
117
|
+
this.mousePos = null;
|
|
118
|
+
});
|
|
119
|
+
this.emitter.on(ReplayerEvents.PlayBack, () => {
|
|
120
|
+
this.firstFullSnapshot = null;
|
|
121
|
+
this.mirror.reset();
|
|
122
|
+
});
|
|
123
|
+
const timer = new Timer([], (config === null || config === void 0 ? void 0 : config.speed) || defaultConfig.speed);
|
|
124
|
+
this.service = createPlayerService({
|
|
125
|
+
events: events
|
|
126
|
+
.map((e) => {
|
|
127
|
+
if (config && config.unpackFn) {
|
|
128
|
+
return config.unpackFn(e);
|
|
129
|
+
}
|
|
130
|
+
return e;
|
|
131
|
+
})
|
|
132
|
+
.sort((a1, a2) => a1.timestamp - a2.timestamp),
|
|
133
|
+
timer,
|
|
134
|
+
timeOffset: 0,
|
|
135
|
+
baselineTime: 0,
|
|
136
|
+
lastPlayedEvent: null,
|
|
137
|
+
}, {
|
|
138
|
+
getCastFn: this.getCastFn,
|
|
139
|
+
applyEventsSynchronously: this.applyEventsSynchronously,
|
|
140
|
+
emitter: this.emitter,
|
|
141
|
+
});
|
|
142
|
+
this.service.start();
|
|
143
|
+
this.service.subscribe((state) => {
|
|
144
|
+
this.emitter.emit(ReplayerEvents.StateChange, {
|
|
145
|
+
player: state,
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
this.speedService = createSpeedService({
|
|
149
|
+
normalSpeed: -1,
|
|
150
|
+
timer,
|
|
151
|
+
});
|
|
152
|
+
this.speedService.start();
|
|
153
|
+
this.speedService.subscribe((state) => {
|
|
154
|
+
this.emitter.emit(ReplayerEvents.StateChange, {
|
|
155
|
+
speed: state,
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
const firstMeta = this.service.state.context.events.find((e) => e.type === EventType.Meta);
|
|
159
|
+
const firstFullsnapshot = this.service.state.context.events.find((e) => e.type === EventType.FullSnapshot);
|
|
160
|
+
if (firstMeta) {
|
|
161
|
+
const { width, height } = firstMeta.data;
|
|
162
|
+
setTimeout(() => {
|
|
163
|
+
this.emitter.emit(ReplayerEvents.Resize, {
|
|
164
|
+
width,
|
|
165
|
+
height,
|
|
166
|
+
});
|
|
167
|
+
}, 0);
|
|
168
|
+
}
|
|
169
|
+
if (firstFullsnapshot) {
|
|
170
|
+
setTimeout(() => {
|
|
171
|
+
if (this.firstFullSnapshot) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
this.firstFullSnapshot = firstFullsnapshot;
|
|
175
|
+
this.rebuildFullSnapshot(firstFullsnapshot);
|
|
176
|
+
this.iframe.contentWindow.scrollTo(firstFullsnapshot.data.initialOffset);
|
|
177
|
+
}, 1);
|
|
178
|
+
}
|
|
179
|
+
if (this.service.state.context.events.find(indicatesTouchDevice)) {
|
|
180
|
+
this.mouse.classList.add('touch-device');
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
get timer() {
|
|
184
|
+
return this.service.state.context.timer;
|
|
185
|
+
}
|
|
186
|
+
on(event, handler) {
|
|
187
|
+
this.emitter.on(event, handler);
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
off(event, handler) {
|
|
191
|
+
this.emitter.off(event, handler);
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
setConfig(config) {
|
|
195
|
+
Object.keys(config).forEach((key) => {
|
|
196
|
+
this.config[key] = config[key];
|
|
197
|
+
});
|
|
198
|
+
if (!this.config.skipInactive) {
|
|
199
|
+
this.backToNormal();
|
|
200
|
+
}
|
|
201
|
+
if (typeof config.speed !== 'undefined') {
|
|
202
|
+
this.speedService.send({
|
|
203
|
+
type: 'SET_SPEED',
|
|
204
|
+
payload: {
|
|
205
|
+
speed: config.speed,
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
if (typeof config.mouseTail !== 'undefined') {
|
|
210
|
+
if (config.mouseTail === false) {
|
|
211
|
+
if (this.mouseTail) {
|
|
212
|
+
this.mouseTail.style.display = 'none';
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
if (!this.mouseTail) {
|
|
217
|
+
this.mouseTail = document.createElement('canvas');
|
|
218
|
+
this.mouseTail.width = Number.parseFloat(this.iframe.width);
|
|
219
|
+
this.mouseTail.height = Number.parseFloat(this.iframe.height);
|
|
220
|
+
this.mouseTail.classList.add('replayer-mouse-tail');
|
|
221
|
+
this.wrapper.insertBefore(this.mouseTail, this.iframe);
|
|
222
|
+
}
|
|
223
|
+
this.mouseTail.style.display = 'inherit';
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
getActivityIntervals() {
|
|
228
|
+
if (this.activityIntervals.length == 0) {
|
|
229
|
+
const allIntervals = [];
|
|
230
|
+
const metadata = this.getMetaData();
|
|
231
|
+
const userInteractionEvents = [
|
|
232
|
+
{ timestamp: metadata.startTime },
|
|
233
|
+
...this.service.state.context.events.filter((ev) => this.isUserInteraction(ev)),
|
|
234
|
+
{ timestamp: metadata.endTime },
|
|
235
|
+
];
|
|
236
|
+
for (let i = 1; i < userInteractionEvents.length; i++) {
|
|
237
|
+
const currentInterval = userInteractionEvents[i - 1];
|
|
238
|
+
const _event = userInteractionEvents[i];
|
|
239
|
+
if (_event.timestamp - currentInterval.timestamp >
|
|
240
|
+
SKIP_TIME_THRESHOLD) {
|
|
241
|
+
allIntervals.push({
|
|
242
|
+
startTime: currentInterval.timestamp,
|
|
243
|
+
endTime: _event.timestamp,
|
|
244
|
+
duration: _event.timestamp - currentInterval.timestamp,
|
|
245
|
+
active: false,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
allIntervals.push({
|
|
250
|
+
startTime: currentInterval.timestamp,
|
|
251
|
+
endTime: _event.timestamp,
|
|
252
|
+
duration: _event.timestamp - currentInterval.timestamp,
|
|
253
|
+
active: true,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const mergedIntervals = [];
|
|
258
|
+
let currentInterval = allIntervals[0];
|
|
259
|
+
for (let i = 1; i < allIntervals.length; i++) {
|
|
260
|
+
if (allIntervals[i].active != allIntervals[i - 1].active) {
|
|
261
|
+
mergedIntervals.push({
|
|
262
|
+
startTime: currentInterval.startTime,
|
|
263
|
+
endTime: allIntervals[i - 1].endTime,
|
|
264
|
+
duration: allIntervals[i - 1].endTime - currentInterval.startTime,
|
|
265
|
+
active: allIntervals[i - 1].active,
|
|
266
|
+
});
|
|
267
|
+
currentInterval = allIntervals[i];
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (currentInterval && allIntervals.length > 0) {
|
|
271
|
+
mergedIntervals.push({
|
|
272
|
+
startTime: currentInterval.startTime,
|
|
273
|
+
endTime: allIntervals[allIntervals.length - 1].endTime,
|
|
274
|
+
duration: allIntervals[allIntervals.length - 1].endTime -
|
|
275
|
+
currentInterval.startTime,
|
|
276
|
+
active: allIntervals[allIntervals.length - 1].active,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
currentInterval = mergedIntervals[0];
|
|
280
|
+
for (let i = 1; i < mergedIntervals.length; i++) {
|
|
281
|
+
if ((!mergedIntervals[i].active &&
|
|
282
|
+
mergedIntervals[i].duration >
|
|
283
|
+
this.config.inactiveThreshold * metadata.totalTime) ||
|
|
284
|
+
(!mergedIntervals[i - 1].active &&
|
|
285
|
+
mergedIntervals[i - 1].duration >
|
|
286
|
+
this.config.inactiveThreshold * metadata.totalTime)) {
|
|
287
|
+
this.activityIntervals.push({
|
|
288
|
+
startTime: currentInterval.startTime,
|
|
289
|
+
endTime: mergedIntervals[i - 1].endTime,
|
|
290
|
+
duration: mergedIntervals[i - 1].endTime - currentInterval.startTime,
|
|
291
|
+
active: mergedIntervals[i - 1].active,
|
|
292
|
+
});
|
|
293
|
+
currentInterval = mergedIntervals[i];
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (currentInterval && mergedIntervals.length > 0) {
|
|
297
|
+
this.activityIntervals.push({
|
|
298
|
+
startTime: currentInterval.startTime,
|
|
299
|
+
endTime: mergedIntervals[mergedIntervals.length - 1].endTime,
|
|
300
|
+
duration: mergedIntervals[mergedIntervals.length - 1].endTime -
|
|
301
|
+
currentInterval.startTime,
|
|
302
|
+
active: mergedIntervals[mergedIntervals.length - 1].active,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return this.activityIntervals;
|
|
307
|
+
}
|
|
308
|
+
getMetaData() {
|
|
309
|
+
const firstEvent = this.service.state.context.events[0];
|
|
310
|
+
const lastEvent = this.service.state.context.events[this.service.state.context.events.length - 1];
|
|
311
|
+
return {
|
|
312
|
+
startTime: firstEvent.timestamp,
|
|
313
|
+
endTime: lastEvent.timestamp,
|
|
314
|
+
totalTime: lastEvent.timestamp - firstEvent.timestamp,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
getCurrentTime() {
|
|
318
|
+
return this.timer.timeOffset + this.getTimeOffset();
|
|
319
|
+
}
|
|
320
|
+
getTimeOffset() {
|
|
321
|
+
const { baselineTime, events } = this.service.state.context;
|
|
322
|
+
return baselineTime - events[0].timestamp;
|
|
323
|
+
}
|
|
324
|
+
getMirror() {
|
|
325
|
+
return this.mirror;
|
|
326
|
+
}
|
|
327
|
+
play(timeOffset = 0) {
|
|
328
|
+
var _a, _b;
|
|
329
|
+
if (this.service.state.matches('paused')) {
|
|
330
|
+
this.service.send({ type: 'PLAY', payload: { timeOffset } });
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
this.service.send({ type: 'PAUSE' });
|
|
334
|
+
this.service.send({ type: 'PLAY', payload: { timeOffset } });
|
|
335
|
+
}
|
|
336
|
+
(_b = (_a = this.iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.getElementsByTagName('html')[0]) === null || _b === void 0 ? void 0 : _b.classList.remove('rrweb-paused');
|
|
337
|
+
this.emitter.emit(ReplayerEvents.Start);
|
|
338
|
+
this.handleInactivity(this.getMetaData().startTime + timeOffset, true);
|
|
339
|
+
}
|
|
340
|
+
pause(timeOffset) {
|
|
341
|
+
var _a, _b;
|
|
342
|
+
if (timeOffset === undefined && this.service.state.matches('playing')) {
|
|
343
|
+
this.service.send({ type: 'PAUSE' });
|
|
344
|
+
}
|
|
345
|
+
if (typeof timeOffset === 'number') {
|
|
346
|
+
this.play(timeOffset);
|
|
347
|
+
this.service.send({ type: 'PAUSE' });
|
|
348
|
+
}
|
|
349
|
+
(_b = (_a = this.iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.getElementsByTagName('html')[0]) === null || _b === void 0 ? void 0 : _b.classList.add('rrweb-paused');
|
|
350
|
+
this.emitter.emit(ReplayerEvents.Pause);
|
|
351
|
+
}
|
|
352
|
+
resume(timeOffset = 0) {
|
|
353
|
+
console.warn(`The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface.`);
|
|
354
|
+
this.play(timeOffset);
|
|
355
|
+
this.emitter.emit(ReplayerEvents.Resume);
|
|
356
|
+
}
|
|
357
|
+
startLive(baselineTime) {
|
|
358
|
+
this.service.send({ type: 'TO_LIVE', payload: { baselineTime } });
|
|
359
|
+
}
|
|
360
|
+
addEvent(rawEvent) {
|
|
361
|
+
const event = this.config.unpackFn
|
|
362
|
+
? this.config.unpackFn(rawEvent)
|
|
363
|
+
: rawEvent;
|
|
364
|
+
if (indicatesTouchDevice(event)) {
|
|
365
|
+
this.mouse.classList.add('touch-device');
|
|
366
|
+
}
|
|
367
|
+
Promise.resolve().then(() => this.service.send({ type: 'ADD_EVENT', payload: { event } }));
|
|
368
|
+
}
|
|
369
|
+
replaceEvents(events) {
|
|
370
|
+
for (const event of events) {
|
|
371
|
+
if (indicatesTouchDevice(event)) {
|
|
372
|
+
this.mouse.classList.add('touch-device');
|
|
373
|
+
break;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
this.service.send({ type: 'REPLACE_EVENTS', payload: { events } });
|
|
377
|
+
}
|
|
378
|
+
enableInteract() {
|
|
379
|
+
this.iframe.setAttribute('scrolling', 'auto');
|
|
380
|
+
this.iframe.style.pointerEvents = 'auto';
|
|
381
|
+
}
|
|
382
|
+
disableInteract() {
|
|
383
|
+
this.iframe.setAttribute('scrolling', 'no');
|
|
384
|
+
this.iframe.style.pointerEvents = 'none';
|
|
385
|
+
}
|
|
386
|
+
resetCache() {
|
|
387
|
+
this.cache = createCache();
|
|
388
|
+
}
|
|
389
|
+
setupDom() {
|
|
390
|
+
this.wrapper = document.createElement('div');
|
|
391
|
+
this.wrapper.classList.add('replayer-wrapper');
|
|
392
|
+
this.config.root.appendChild(this.wrapper);
|
|
393
|
+
this.mouse = document.createElement('div');
|
|
394
|
+
this.mouse.classList.add('replayer-mouse');
|
|
395
|
+
this.wrapper.appendChild(this.mouse);
|
|
396
|
+
if (this.config.mouseTail !== false) {
|
|
397
|
+
this.mouseTail = document.createElement('canvas');
|
|
398
|
+
this.mouseTail.classList.add('replayer-mouse-tail');
|
|
399
|
+
this.mouseTail.style.display = 'inherit';
|
|
400
|
+
this.wrapper.appendChild(this.mouseTail);
|
|
401
|
+
}
|
|
402
|
+
this.iframe = document.createElement('iframe');
|
|
403
|
+
const attributes = ['allow-same-origin'];
|
|
404
|
+
if (this.config.UNSAFE_replayCanvas) {
|
|
405
|
+
attributes.push('allow-scripts');
|
|
406
|
+
}
|
|
407
|
+
this.iframe.style.display = 'none';
|
|
408
|
+
this.iframe.setAttribute('sandbox', attributes.join(' '));
|
|
409
|
+
this.disableInteract();
|
|
410
|
+
this.wrapper.appendChild(this.iframe);
|
|
411
|
+
if (this.iframe.contentWindow && this.iframe.contentDocument) {
|
|
412
|
+
polyfill(this.iframe.contentWindow, this.iframe.contentDocument);
|
|
413
|
+
polyfill$1(this.iframe.contentWindow);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
handleResize(dimension) {
|
|
417
|
+
this.iframe.style.display = 'inherit';
|
|
418
|
+
for (const el of [this.mouseTail, this.iframe]) {
|
|
419
|
+
if (!el) {
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
el.setAttribute('width', String(dimension.width));
|
|
423
|
+
el.setAttribute('height', String(dimension.height));
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
applyEventsSynchronously(events) {
|
|
427
|
+
for (const event of events) {
|
|
428
|
+
switch (event.type) {
|
|
429
|
+
case EventType.DomContentLoaded:
|
|
430
|
+
case EventType.Load:
|
|
431
|
+
case EventType.Custom:
|
|
432
|
+
continue;
|
|
433
|
+
case EventType.FullSnapshot:
|
|
434
|
+
case EventType.Meta:
|
|
435
|
+
case EventType.Plugin:
|
|
436
|
+
case EventType.IncrementalSnapshot:
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
const castFn = this.getCastFn(event, true);
|
|
440
|
+
castFn();
|
|
441
|
+
}
|
|
442
|
+
if (this.touchActive === true) {
|
|
443
|
+
this.mouse.classList.add('touch-active');
|
|
444
|
+
}
|
|
445
|
+
else if (this.touchActive === false) {
|
|
446
|
+
this.mouse.classList.remove('touch-active');
|
|
447
|
+
}
|
|
448
|
+
this.touchActive = null;
|
|
449
|
+
}
|
|
450
|
+
getCastFn(event, isSync = false) {
|
|
451
|
+
let castFn;
|
|
452
|
+
switch (event.type) {
|
|
453
|
+
case EventType.DomContentLoaded:
|
|
454
|
+
case EventType.Load:
|
|
455
|
+
break;
|
|
456
|
+
case EventType.Custom:
|
|
457
|
+
castFn = () => {
|
|
458
|
+
this.emitter.emit(ReplayerEvents.CustomEvent, event);
|
|
459
|
+
};
|
|
460
|
+
break;
|
|
461
|
+
case EventType.Meta:
|
|
462
|
+
castFn = () => this.emitter.emit(ReplayerEvents.Resize, {
|
|
463
|
+
width: event.data.width,
|
|
464
|
+
height: event.data.height,
|
|
465
|
+
});
|
|
466
|
+
break;
|
|
467
|
+
case EventType.FullSnapshot:
|
|
468
|
+
castFn = () => {
|
|
469
|
+
if (this.firstFullSnapshot) {
|
|
470
|
+
if (this.firstFullSnapshot === event) {
|
|
471
|
+
this.firstFullSnapshot = true;
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
else {
|
|
476
|
+
this.firstFullSnapshot = true;
|
|
477
|
+
}
|
|
478
|
+
this.rebuildFullSnapshot(event, isSync);
|
|
479
|
+
this.iframe.contentWindow.scrollTo(event.data.initialOffset);
|
|
480
|
+
};
|
|
481
|
+
break;
|
|
482
|
+
case EventType.IncrementalSnapshot:
|
|
483
|
+
castFn = () => {
|
|
484
|
+
this.applyIncremental(event, isSync);
|
|
485
|
+
if (isSync) {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
this.handleInactivity(event.timestamp);
|
|
489
|
+
if (event === this.nextUserInteractionEvent) {
|
|
490
|
+
this.nextUserInteractionEvent = null;
|
|
491
|
+
this.backToNormal();
|
|
492
|
+
}
|
|
493
|
+
if (this.config.skipInactive && !this.nextUserInteractionEvent) {
|
|
494
|
+
for (const _event of this.service.state.context.events) {
|
|
495
|
+
if (_event.timestamp <= event.timestamp) {
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
if (this.isUserInteraction(_event)) {
|
|
499
|
+
if (_event.delay - event.delay >
|
|
500
|
+
SKIP_TIME_THRESHOLD *
|
|
501
|
+
this.speedService.state.context.timer.speed) {
|
|
502
|
+
this.nextUserInteractionEvent = _event;
|
|
503
|
+
}
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
if (this.nextUserInteractionEvent) {
|
|
508
|
+
const skipTime = this.nextUserInteractionEvent.delay - event.delay;
|
|
509
|
+
const payload = {
|
|
510
|
+
speed: Math.min(Math.round(skipTime / SKIP_TIME_INTERVAL), this.config.maxSpeed),
|
|
511
|
+
};
|
|
512
|
+
this.speedService.send({ type: 'FAST_FORWARD', payload });
|
|
513
|
+
this.emitter.emit(ReplayerEvents.SkipStart, payload);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
break;
|
|
518
|
+
}
|
|
519
|
+
const wrappedCastFn = () => {
|
|
520
|
+
if (castFn) {
|
|
521
|
+
castFn();
|
|
522
|
+
}
|
|
523
|
+
for (const plugin of this.config.plugins || []) {
|
|
524
|
+
plugin.handler(event, isSync, { replayer: this });
|
|
525
|
+
}
|
|
526
|
+
this.service.send({ type: 'CAST_EVENT', payload: { event } });
|
|
527
|
+
const last_index = this.service.state.context.events.length - 1;
|
|
528
|
+
if (event === this.service.state.context.events[last_index]) {
|
|
529
|
+
const finish = () => {
|
|
530
|
+
if (last_index < this.service.state.context.events.length - 1) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
this.backToNormal();
|
|
534
|
+
this.service.send('END');
|
|
535
|
+
this.emitter.emit(ReplayerEvents.Finish);
|
|
536
|
+
};
|
|
537
|
+
if (event.type === EventType.IncrementalSnapshot &&
|
|
538
|
+
event.data.source === IncrementalSource.MouseMove &&
|
|
539
|
+
event.data.positions.length) {
|
|
540
|
+
setTimeout(() => {
|
|
541
|
+
finish();
|
|
542
|
+
}, Math.max(0, -event.data.positions[0].timeOffset + 50));
|
|
543
|
+
}
|
|
544
|
+
else {
|
|
545
|
+
finish();
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
this.emitter.emit(ReplayerEvents.EventCast, event);
|
|
549
|
+
};
|
|
550
|
+
return wrappedCastFn;
|
|
551
|
+
}
|
|
552
|
+
handleInactivity(timestamp, resetNext) {
|
|
553
|
+
if (timestamp === this.inactiveEndTimestamp || resetNext) {
|
|
554
|
+
this.inactiveEndTimestamp = null;
|
|
555
|
+
this.backToNormal();
|
|
556
|
+
}
|
|
557
|
+
if (this.config.skipInactive && !this.inactiveEndTimestamp) {
|
|
558
|
+
for (const interval of this.getActivityIntervals()) {
|
|
559
|
+
if (timestamp >= interval.startTime &&
|
|
560
|
+
timestamp < interval.endTime &&
|
|
561
|
+
!interval.active) {
|
|
562
|
+
this.inactiveEndTimestamp = interval.endTime;
|
|
563
|
+
break;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
if (this.inactiveEndTimestamp) {
|
|
567
|
+
const skipTime = this.inactiveEndTimestamp - timestamp;
|
|
568
|
+
const payload = {
|
|
569
|
+
speed: (skipTime / SKIP_DURATION_LIMIT) * this.config.inactiveSkipTime <
|
|
570
|
+
SKIP_TIME_MIN
|
|
571
|
+
? skipTime / SKIP_TIME_MIN
|
|
572
|
+
: Math.round(Math.max(skipTime, SKIP_DURATION_LIMIT) /
|
|
573
|
+
this.config.inactiveSkipTime),
|
|
574
|
+
};
|
|
575
|
+
this.speedService.send({ type: 'FAST_FORWARD', payload });
|
|
576
|
+
this.emitter.emit(ReplayerEvents.SkipStart, payload);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
rebuildFullSnapshot(event, isSync = false) {
|
|
581
|
+
if (!this.iframe.contentDocument) {
|
|
582
|
+
return console.warn('Looks like your replayer has been destroyed.');
|
|
583
|
+
}
|
|
584
|
+
if (Object.keys(this.legacy_missingNodeRetryMap).length) {
|
|
585
|
+
console.warn('Found unresolved missing node map', this.legacy_missingNodeRetryMap);
|
|
586
|
+
}
|
|
587
|
+
this.legacy_missingNodeRetryMap = {};
|
|
588
|
+
const collected = [];
|
|
589
|
+
rebuild(event.data.node, {
|
|
590
|
+
doc: this.iframe.contentDocument,
|
|
591
|
+
afterAppend: (builtNode) => {
|
|
592
|
+
this.collectIframeAndAttachDocument(collected, builtNode);
|
|
593
|
+
},
|
|
594
|
+
cache: this.cache,
|
|
595
|
+
mirror: this.mirror,
|
|
596
|
+
});
|
|
597
|
+
for (const { mutationInQueue, builtNode } of collected) {
|
|
598
|
+
this.attachDocumentToIframe(mutationInQueue, builtNode);
|
|
599
|
+
this.newDocumentQueue = this.newDocumentQueue.filter((m) => m !== mutationInQueue);
|
|
600
|
+
}
|
|
601
|
+
const { documentElement, head } = this.iframe.contentDocument;
|
|
602
|
+
this.insertStyleRules(documentElement, head);
|
|
603
|
+
if (!this.service.state.matches('playing')) {
|
|
604
|
+
this.iframe.contentDocument
|
|
605
|
+
.getElementsByTagName('html')[0]
|
|
606
|
+
.classList.add('rrweb-paused');
|
|
607
|
+
}
|
|
608
|
+
this.emitter.emit(ReplayerEvents.FullsnapshotRebuilded, event);
|
|
609
|
+
if (!isSync) {
|
|
610
|
+
this.waitForStylesheetLoad();
|
|
611
|
+
}
|
|
612
|
+
if (this.config.UNSAFE_replayCanvas) {
|
|
613
|
+
this.preloadAllImages();
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
insertStyleRules(documentElement, head) {
|
|
617
|
+
const injectStylesRules = rules(this.config.blockClass).concat(this.config.insertStyleRules);
|
|
618
|
+
if (this.config.pauseAnimation) {
|
|
619
|
+
injectStylesRules.push('html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }');
|
|
620
|
+
}
|
|
621
|
+
if (this.usingVirtualDom) {
|
|
622
|
+
const styleEl = this.virtualDom.createElement('style');
|
|
623
|
+
this.virtualDom.mirror.add(styleEl, getDefaultSN(styleEl, this.virtualDom.unserializedId));
|
|
624
|
+
documentElement.insertBefore(styleEl, head);
|
|
625
|
+
for (let idx = 0; idx < injectStylesRules.length; idx++) {
|
|
626
|
+
styleEl.rules.push({
|
|
627
|
+
cssText: injectStylesRules[idx],
|
|
628
|
+
type: StyleRuleType.Insert,
|
|
629
|
+
index: idx,
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
else {
|
|
634
|
+
const styleEl = document.createElement('style');
|
|
635
|
+
documentElement.insertBefore(styleEl, head);
|
|
636
|
+
for (let idx = 0; idx < injectStylesRules.length; idx++) {
|
|
637
|
+
(styleEl.sheet).insertRule(injectStylesRules[idx], idx);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
attachDocumentToIframe(mutation, iframeEl) {
|
|
642
|
+
const mirror = this.usingVirtualDom
|
|
643
|
+
? this.virtualDom.mirror
|
|
644
|
+
: this.mirror;
|
|
645
|
+
const collected = [];
|
|
646
|
+
buildNodeWithSN(mutation.node, {
|
|
647
|
+
doc: iframeEl.contentDocument,
|
|
648
|
+
mirror: mirror,
|
|
649
|
+
hackCss: true,
|
|
650
|
+
skipChild: false,
|
|
651
|
+
afterAppend: (builtNode) => {
|
|
652
|
+
this.collectIframeAndAttachDocument(collected, builtNode);
|
|
653
|
+
const sn = mirror.getMeta(builtNode);
|
|
654
|
+
if ((sn === null || sn === void 0 ? void 0 : sn.type) === NodeType.Element &&
|
|
655
|
+
(sn === null || sn === void 0 ? void 0 : sn.tagName.toUpperCase()) === 'HTML') {
|
|
656
|
+
const { documentElement, head } = iframeEl.contentDocument;
|
|
657
|
+
this.insertStyleRules(documentElement, head);
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
cache: this.cache,
|
|
661
|
+
});
|
|
662
|
+
for (const { mutationInQueue, builtNode } of collected) {
|
|
663
|
+
this.attachDocumentToIframe(mutationInQueue, builtNode);
|
|
664
|
+
this.newDocumentQueue = this.newDocumentQueue.filter((m) => m !== mutationInQueue);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
collectIframeAndAttachDocument(collected, builtNode) {
|
|
668
|
+
if (isSerializedIframe(builtNode, this.mirror)) {
|
|
669
|
+
const mutationInQueue = this.newDocumentQueue.find((m) => m.parentId === this.mirror.getId(builtNode));
|
|
670
|
+
if (mutationInQueue) {
|
|
671
|
+
collected.push({
|
|
672
|
+
mutationInQueue,
|
|
673
|
+
builtNode: builtNode,
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
waitForStylesheetLoad() {
|
|
679
|
+
var _a;
|
|
680
|
+
const head = (_a = this.iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.head;
|
|
681
|
+
if (head) {
|
|
682
|
+
const unloadSheets = new Set();
|
|
683
|
+
let timer;
|
|
684
|
+
let beforeLoadState = this.service.state;
|
|
685
|
+
const stateHandler = () => {
|
|
686
|
+
beforeLoadState = this.service.state;
|
|
687
|
+
};
|
|
688
|
+
this.emitter.on(ReplayerEvents.Start, stateHandler);
|
|
689
|
+
this.emitter.on(ReplayerEvents.Pause, stateHandler);
|
|
690
|
+
const unsubscribe = () => {
|
|
691
|
+
this.emitter.off(ReplayerEvents.Start, stateHandler);
|
|
692
|
+
this.emitter.off(ReplayerEvents.Pause, stateHandler);
|
|
693
|
+
};
|
|
694
|
+
head
|
|
695
|
+
.querySelectorAll('link[rel="stylesheet"]')
|
|
696
|
+
.forEach((css) => {
|
|
697
|
+
if (!css.sheet) {
|
|
698
|
+
unloadSheets.add(css);
|
|
699
|
+
css.addEventListener('load', () => {
|
|
700
|
+
unloadSheets.delete(css);
|
|
701
|
+
if (unloadSheets.size === 0 && timer !== -1) {
|
|
702
|
+
if (beforeLoadState.matches('playing')) {
|
|
703
|
+
this.play(this.getCurrentTime());
|
|
704
|
+
}
|
|
705
|
+
this.emitter.emit(ReplayerEvents.LoadStylesheetEnd);
|
|
706
|
+
if (timer) {
|
|
707
|
+
clearTimeout(timer);
|
|
708
|
+
}
|
|
709
|
+
unsubscribe();
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
if (unloadSheets.size > 0) {
|
|
715
|
+
this.service.send({ type: 'PAUSE' });
|
|
716
|
+
this.emitter.emit(ReplayerEvents.LoadStylesheetStart);
|
|
717
|
+
timer = setTimeout(() => {
|
|
718
|
+
if (beforeLoadState.matches('playing')) {
|
|
719
|
+
this.play(this.getCurrentTime());
|
|
720
|
+
}
|
|
721
|
+
timer = -1;
|
|
722
|
+
unsubscribe();
|
|
723
|
+
}, this.config.loadTimeout);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
hasImageArg(args) {
|
|
728
|
+
for (const arg of args) {
|
|
729
|
+
if (!arg || typeof arg !== 'object') ;
|
|
730
|
+
else if ('rr_type' in arg && 'args' in arg) {
|
|
731
|
+
if (this.hasImageArg(arg.args))
|
|
732
|
+
return true;
|
|
733
|
+
}
|
|
734
|
+
else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {
|
|
735
|
+
return true;
|
|
736
|
+
}
|
|
737
|
+
else if (arg instanceof Array) {
|
|
738
|
+
if (this.hasImageArg(arg))
|
|
739
|
+
return true;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
return false;
|
|
743
|
+
}
|
|
744
|
+
getImageArgs(args) {
|
|
745
|
+
const images = [];
|
|
746
|
+
for (const arg of args) {
|
|
747
|
+
if (!arg || typeof arg !== 'object') ;
|
|
748
|
+
else if ('rr_type' in arg && 'args' in arg) {
|
|
749
|
+
images.push(...this.getImageArgs(arg.args));
|
|
750
|
+
}
|
|
751
|
+
else if ('rr_type' in arg && arg.rr_type === 'HTMLImageElement') {
|
|
752
|
+
images.push(arg.src);
|
|
753
|
+
}
|
|
754
|
+
else if (arg instanceof Array) {
|
|
755
|
+
images.push(...this.getImageArgs(arg));
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
return images;
|
|
759
|
+
}
|
|
760
|
+
preloadAllImages() {
|
|
761
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
762
|
+
this.service.state;
|
|
763
|
+
const stateHandler = () => {
|
|
764
|
+
this.service.state;
|
|
765
|
+
};
|
|
766
|
+
this.emitter.on(ReplayerEvents.Start, stateHandler);
|
|
767
|
+
this.emitter.on(ReplayerEvents.Pause, stateHandler);
|
|
768
|
+
const promises = [];
|
|
769
|
+
for (const event of this.service.state.context.events) {
|
|
770
|
+
if (event.type === EventType.IncrementalSnapshot &&
|
|
771
|
+
event.data.source === IncrementalSource.CanvasMutation) {
|
|
772
|
+
promises.push(this.deserializeAndPreloadCanvasEvents(event.data, event));
|
|
773
|
+
const commands = 'commands' in event.data ? event.data.commands : [event.data];
|
|
774
|
+
commands.forEach((c) => {
|
|
775
|
+
this.preloadImages(c, event);
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
return Promise.all(promises);
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
preloadImages(data, event) {
|
|
783
|
+
if (data.property === 'drawImage' &&
|
|
784
|
+
typeof data.args[0] === 'string' &&
|
|
785
|
+
!this.imageMap.has(event)) {
|
|
786
|
+
const canvas = document.createElement('canvas');
|
|
787
|
+
const ctx = canvas.getContext('2d');
|
|
788
|
+
const imgd = ctx === null || ctx === void 0 ? void 0 : ctx.createImageData(canvas.width, canvas.height);
|
|
789
|
+
imgd === null || imgd === void 0 ? void 0 : imgd.data;
|
|
790
|
+
JSON.parse(data.args[0]);
|
|
791
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.putImageData(imgd, 0, 0);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
deserializeAndPreloadCanvasEvents(data, event) {
|
|
795
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
796
|
+
if (!this.canvasEventMap.has(event)) {
|
|
797
|
+
const status = {
|
|
798
|
+
isUnchanged: true,
|
|
799
|
+
};
|
|
800
|
+
if ('commands' in data) {
|
|
801
|
+
const commands = yield Promise.all(data.commands.map((c) => __awaiter(this, void 0, void 0, function* () {
|
|
802
|
+
const args = yield Promise.all(c.args.map(deserializeArg(this.imageMap, null, status)));
|
|
803
|
+
return Object.assign(Object.assign({}, c), { args });
|
|
804
|
+
})));
|
|
805
|
+
if (status.isUnchanged === false)
|
|
806
|
+
this.canvasEventMap.set(event, Object.assign(Object.assign({}, data), { commands }));
|
|
807
|
+
}
|
|
808
|
+
else {
|
|
809
|
+
const args = yield Promise.all(data.args.map(deserializeArg(this.imageMap, null, status)));
|
|
810
|
+
if (status.isUnchanged === false)
|
|
811
|
+
this.canvasEventMap.set(event, Object.assign(Object.assign({}, data), { args }));
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
applyIncremental(e, isSync) {
|
|
817
|
+
var _a, _b, _c, _d, _e, _f;
|
|
818
|
+
const { data: d } = e;
|
|
819
|
+
switch (d.source) {
|
|
820
|
+
case IncrementalSource.Mutation: {
|
|
821
|
+
try {
|
|
822
|
+
this.applyMutation(d, isSync);
|
|
823
|
+
}
|
|
824
|
+
catch (error) {
|
|
825
|
+
this.warn(`Exception in mutation ${error.message || error}`, d);
|
|
826
|
+
}
|
|
827
|
+
break;
|
|
828
|
+
}
|
|
829
|
+
case IncrementalSource.Drag:
|
|
830
|
+
case IncrementalSource.TouchMove:
|
|
831
|
+
case IncrementalSource.MouseMove:
|
|
832
|
+
if (isSync) {
|
|
833
|
+
const lastPosition = d.positions[d.positions.length - 1];
|
|
834
|
+
this.mousePos = {
|
|
835
|
+
x: lastPosition.x,
|
|
836
|
+
y: lastPosition.y,
|
|
837
|
+
id: lastPosition.id,
|
|
838
|
+
debugData: d,
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
else {
|
|
842
|
+
d.positions.forEach((p) => {
|
|
843
|
+
const action = {
|
|
844
|
+
doAction: () => {
|
|
845
|
+
this.moveAndHover(p.x, p.y, p.id, isSync, d);
|
|
846
|
+
},
|
|
847
|
+
delay: p.timeOffset +
|
|
848
|
+
e.timestamp -
|
|
849
|
+
this.service.state.context.baselineTime,
|
|
850
|
+
};
|
|
851
|
+
this.timer.addAction(action);
|
|
852
|
+
});
|
|
853
|
+
this.timer.addAction({
|
|
854
|
+
doAction() { },
|
|
855
|
+
delay: e.delay - ((_a = d.positions[0]) === null || _a === void 0 ? void 0 : _a.timeOffset),
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
break;
|
|
859
|
+
case IncrementalSource.MouseInteraction: {
|
|
860
|
+
if (d.id === -1 || isSync) {
|
|
861
|
+
break;
|
|
862
|
+
}
|
|
863
|
+
const event = new Event(MouseInteractions[d.type].toLowerCase());
|
|
864
|
+
const target = this.mirror.getNode(d.id);
|
|
865
|
+
if (!target) {
|
|
866
|
+
return this.debugNodeNotFound(d, d.id);
|
|
867
|
+
}
|
|
868
|
+
this.emitter.emit(ReplayerEvents.MouseInteraction, {
|
|
869
|
+
type: d.type,
|
|
870
|
+
target,
|
|
871
|
+
});
|
|
872
|
+
const { triggerFocus } = this.config;
|
|
873
|
+
switch (d.type) {
|
|
874
|
+
case MouseInteractions.Blur:
|
|
875
|
+
if ('blur' in target) {
|
|
876
|
+
target.blur();
|
|
877
|
+
}
|
|
878
|
+
break;
|
|
879
|
+
case MouseInteractions.Focus:
|
|
880
|
+
if (triggerFocus && target.focus) {
|
|
881
|
+
target.focus({
|
|
882
|
+
preventScroll: true,
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
break;
|
|
886
|
+
case MouseInteractions.Click:
|
|
887
|
+
case MouseInteractions.TouchStart:
|
|
888
|
+
case MouseInteractions.TouchEnd:
|
|
889
|
+
if (isSync) {
|
|
890
|
+
if (d.type === MouseInteractions.TouchStart) {
|
|
891
|
+
this.touchActive = true;
|
|
892
|
+
}
|
|
893
|
+
else if (d.type === MouseInteractions.TouchEnd) {
|
|
894
|
+
this.touchActive = false;
|
|
895
|
+
}
|
|
896
|
+
this.mousePos = {
|
|
897
|
+
x: d.x,
|
|
898
|
+
y: d.y,
|
|
899
|
+
id: d.id,
|
|
900
|
+
debugData: d,
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
else {
|
|
904
|
+
if (d.type === MouseInteractions.TouchStart) {
|
|
905
|
+
this.tailPositions.length = 0;
|
|
906
|
+
}
|
|
907
|
+
this.moveAndHover(d.x, d.y, d.id, isSync, d);
|
|
908
|
+
if (d.type === MouseInteractions.Click) {
|
|
909
|
+
this.mouse.classList.remove('active');
|
|
910
|
+
void this.mouse.offsetWidth;
|
|
911
|
+
this.mouse.classList.add('active');
|
|
912
|
+
}
|
|
913
|
+
else if (d.type === MouseInteractions.TouchStart) {
|
|
914
|
+
void this.mouse.offsetWidth;
|
|
915
|
+
this.mouse.classList.add('touch-active');
|
|
916
|
+
}
|
|
917
|
+
else if (d.type === MouseInteractions.TouchEnd) {
|
|
918
|
+
this.mouse.classList.remove('touch-active');
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
break;
|
|
922
|
+
case MouseInteractions.TouchCancel:
|
|
923
|
+
if (isSync) {
|
|
924
|
+
this.touchActive = false;
|
|
925
|
+
}
|
|
926
|
+
else {
|
|
927
|
+
this.mouse.classList.remove('touch-active');
|
|
928
|
+
}
|
|
929
|
+
break;
|
|
930
|
+
default:
|
|
931
|
+
target.dispatchEvent(event);
|
|
932
|
+
}
|
|
933
|
+
break;
|
|
934
|
+
}
|
|
935
|
+
case IncrementalSource.Scroll: {
|
|
936
|
+
if (d.id === -1) {
|
|
937
|
+
break;
|
|
938
|
+
}
|
|
939
|
+
if (this.usingVirtualDom) {
|
|
940
|
+
const target = this.virtualDom.mirror.getNode(d.id);
|
|
941
|
+
if (!target) {
|
|
942
|
+
return this.debugNodeNotFound(d, d.id);
|
|
943
|
+
}
|
|
944
|
+
target.scrollData = d;
|
|
945
|
+
break;
|
|
946
|
+
}
|
|
947
|
+
this.applyScroll(d, isSync);
|
|
948
|
+
break;
|
|
949
|
+
}
|
|
950
|
+
case IncrementalSource.ViewportResize:
|
|
951
|
+
this.emitter.emit(ReplayerEvents.Resize, {
|
|
952
|
+
width: d.width,
|
|
953
|
+
height: d.height,
|
|
954
|
+
});
|
|
955
|
+
break;
|
|
956
|
+
case IncrementalSource.Input: {
|
|
957
|
+
if (d.id === -1) {
|
|
958
|
+
break;
|
|
959
|
+
}
|
|
960
|
+
if (this.usingVirtualDom) {
|
|
961
|
+
const target = this.virtualDom.mirror.getNode(d.id);
|
|
962
|
+
if (!target) {
|
|
963
|
+
return this.debugNodeNotFound(d, d.id);
|
|
964
|
+
}
|
|
965
|
+
target.inputData = d;
|
|
966
|
+
break;
|
|
967
|
+
}
|
|
968
|
+
this.applyInput(d);
|
|
969
|
+
break;
|
|
970
|
+
}
|
|
971
|
+
case IncrementalSource.MediaInteraction: {
|
|
972
|
+
const target = this.usingVirtualDom
|
|
973
|
+
? this.virtualDom.mirror.getNode(d.id)
|
|
974
|
+
: this.mirror.getNode(d.id);
|
|
975
|
+
if (!target) {
|
|
976
|
+
return this.debugNodeNotFound(d, d.id);
|
|
977
|
+
}
|
|
978
|
+
const mediaEl = target;
|
|
979
|
+
try {
|
|
980
|
+
if (d.currentTime) {
|
|
981
|
+
mediaEl.currentTime = d.currentTime;
|
|
982
|
+
}
|
|
983
|
+
if (d.volume) {
|
|
984
|
+
mediaEl.volume = d.volume;
|
|
985
|
+
}
|
|
986
|
+
if (d.muted) {
|
|
987
|
+
mediaEl.muted = d.muted;
|
|
988
|
+
}
|
|
989
|
+
if (d.type === 1) {
|
|
990
|
+
mediaEl.pause();
|
|
991
|
+
}
|
|
992
|
+
if (d.type === 0) {
|
|
993
|
+
mediaEl.play();
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
catch (error) {
|
|
997
|
+
if (this.config.showWarning) {
|
|
998
|
+
console.warn(`Failed to replay media interactions: ${error.message || error}`);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
break;
|
|
1002
|
+
}
|
|
1003
|
+
case IncrementalSource.StyleSheetRule: {
|
|
1004
|
+
if (this.usingVirtualDom) {
|
|
1005
|
+
const target = this.virtualDom.mirror.getNode(d.id);
|
|
1006
|
+
if (!target) {
|
|
1007
|
+
return this.debugNodeNotFound(d, d.id);
|
|
1008
|
+
}
|
|
1009
|
+
const rules = target.rules;
|
|
1010
|
+
(_b = d.adds) === null || _b === void 0 ? void 0 : _b.forEach(({ rule, index: nestedIndex }) => rules === null || rules === void 0 ? void 0 : rules.push({
|
|
1011
|
+
cssText: rule,
|
|
1012
|
+
index: nestedIndex,
|
|
1013
|
+
type: StyleRuleType.Insert,
|
|
1014
|
+
}));
|
|
1015
|
+
(_c = d.removes) === null || _c === void 0 ? void 0 : _c.forEach(({ index: nestedIndex }) => rules === null || rules === void 0 ? void 0 : rules.push({ index: nestedIndex, type: StyleRuleType.Remove }));
|
|
1016
|
+
}
|
|
1017
|
+
else {
|
|
1018
|
+
const target = this.mirror.getNode(d.id);
|
|
1019
|
+
if (!target) {
|
|
1020
|
+
return this.debugNodeNotFound(d, d.id);
|
|
1021
|
+
}
|
|
1022
|
+
const styleSheet = (target).sheet;
|
|
1023
|
+
(_d = d.adds) === null || _d === void 0 ? void 0 : _d.forEach(({ rule, index: nestedIndex }) => {
|
|
1024
|
+
try {
|
|
1025
|
+
if (Array.isArray(nestedIndex)) {
|
|
1026
|
+
const { positions, index } = getPositionsAndIndex(nestedIndex);
|
|
1027
|
+
const nestedRule = getNestedRule(styleSheet.cssRules, positions);
|
|
1028
|
+
nestedRule.insertRule(rule, index);
|
|
1029
|
+
}
|
|
1030
|
+
else {
|
|
1031
|
+
const index = nestedIndex === undefined
|
|
1032
|
+
? undefined
|
|
1033
|
+
: Math.min(nestedIndex, styleSheet.cssRules.length);
|
|
1034
|
+
styleSheet.insertRule(rule, index);
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
catch (e) {
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
(_e = d.removes) === null || _e === void 0 ? void 0 : _e.forEach(({ index: nestedIndex }) => {
|
|
1041
|
+
try {
|
|
1042
|
+
if (Array.isArray(nestedIndex)) {
|
|
1043
|
+
const { positions, index } = getPositionsAndIndex(nestedIndex);
|
|
1044
|
+
const nestedRule = getNestedRule(styleSheet.cssRules, positions);
|
|
1045
|
+
nestedRule.deleteRule(index || 0);
|
|
1046
|
+
}
|
|
1047
|
+
else {
|
|
1048
|
+
styleSheet === null || styleSheet === void 0 ? void 0 : styleSheet.deleteRule(nestedIndex);
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
catch (e) {
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
break;
|
|
1056
|
+
}
|
|
1057
|
+
case IncrementalSource.StyleDeclaration: {
|
|
1058
|
+
if (this.usingVirtualDom) {
|
|
1059
|
+
const target = this.virtualDom.mirror.getNode(d.id);
|
|
1060
|
+
if (!target) {
|
|
1061
|
+
return this.debugNodeNotFound(d, d.id);
|
|
1062
|
+
}
|
|
1063
|
+
const rules = target.rules;
|
|
1064
|
+
d.set &&
|
|
1065
|
+
rules.push(Object.assign({ type: StyleRuleType.SetProperty, index: d.index }, d.set));
|
|
1066
|
+
d.remove &&
|
|
1067
|
+
rules.push(Object.assign({ type: StyleRuleType.RemoveProperty, index: d.index }, d.remove));
|
|
1068
|
+
}
|
|
1069
|
+
else {
|
|
1070
|
+
const target = this.mirror.getNode(d.id);
|
|
1071
|
+
if (!target) {
|
|
1072
|
+
return this.debugNodeNotFound(d, d.id);
|
|
1073
|
+
}
|
|
1074
|
+
const styleSheet = target.sheet;
|
|
1075
|
+
if (d.set) {
|
|
1076
|
+
const rule = getNestedRule(styleSheet.rules, d.index);
|
|
1077
|
+
rule.style.setProperty(d.set.property, d.set.value, d.set.priority);
|
|
1078
|
+
}
|
|
1079
|
+
if (d.remove) {
|
|
1080
|
+
const rule = getNestedRule(styleSheet.rules, d.index);
|
|
1081
|
+
rule.style.removeProperty(d.remove.property);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
break;
|
|
1085
|
+
}
|
|
1086
|
+
case IncrementalSource.CanvasMutation: {
|
|
1087
|
+
if (!this.config.UNSAFE_replayCanvas) {
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
if (this.usingVirtualDom) {
|
|
1091
|
+
const target = this.virtualDom.mirror.getNode(d.id);
|
|
1092
|
+
if (!target) {
|
|
1093
|
+
return this.debugNodeNotFound(d, d.id);
|
|
1094
|
+
}
|
|
1095
|
+
target.canvasMutations.push({
|
|
1096
|
+
event: e,
|
|
1097
|
+
mutation: d,
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
else {
|
|
1101
|
+
const target = this.mirror.getNode(d.id);
|
|
1102
|
+
if (!target) {
|
|
1103
|
+
return this.debugNodeNotFound(d, d.id);
|
|
1104
|
+
}
|
|
1105
|
+
canvasMutation({
|
|
1106
|
+
event: e,
|
|
1107
|
+
mutation: d,
|
|
1108
|
+
target: target,
|
|
1109
|
+
imageMap: this.imageMap,
|
|
1110
|
+
canvasEventMap: this.canvasEventMap,
|
|
1111
|
+
errorHandler: this.warnCanvasMutationFailed.bind(this),
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
break;
|
|
1115
|
+
}
|
|
1116
|
+
case IncrementalSource.Font: {
|
|
1117
|
+
try {
|
|
1118
|
+
const fontFace = new FontFace(d.family, d.buffer ? new Uint8Array(JSON.parse(d.fontSource)) : d.fontSource, d.descriptors);
|
|
1119
|
+
(_f = this.iframe.contentDocument) === null || _f === void 0 ? void 0 : _f.fonts.add(fontFace);
|
|
1120
|
+
}
|
|
1121
|
+
catch (error) {
|
|
1122
|
+
if (this.config.showWarning) {
|
|
1123
|
+
console.warn(error);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
applyMutation(d, isSync) {
|
|
1131
|
+
if (this.config.useVirtualDom && !this.usingVirtualDom && isSync) {
|
|
1132
|
+
this.usingVirtualDom = true;
|
|
1133
|
+
buildFromDom(this.iframe.contentDocument, this.mirror, this.virtualDom);
|
|
1134
|
+
if (Object.keys(this.legacy_missingNodeRetryMap).length) {
|
|
1135
|
+
for (const key in this.legacy_missingNodeRetryMap) {
|
|
1136
|
+
try {
|
|
1137
|
+
const value = this.legacy_missingNodeRetryMap[key];
|
|
1138
|
+
const virtualNode = buildFromNode(value.node, this.virtualDom, this.mirror);
|
|
1139
|
+
if (virtualNode)
|
|
1140
|
+
value.node = virtualNode;
|
|
1141
|
+
}
|
|
1142
|
+
catch (error) {
|
|
1143
|
+
if (this.config.showWarning) {
|
|
1144
|
+
console.warn(error);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
const mirror = this.usingVirtualDom ? this.virtualDom.mirror : this.mirror;
|
|
1151
|
+
d.removes.forEach((mutation) => {
|
|
1152
|
+
var _a;
|
|
1153
|
+
const target = mirror.getNode(mutation.id);
|
|
1154
|
+
if (!target) {
|
|
1155
|
+
if (d.removes.find((r) => r.id === mutation.parentId)) {
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
return this.warnNodeNotFound(d, mutation.id);
|
|
1159
|
+
}
|
|
1160
|
+
let parent = mirror.getNode(mutation.parentId);
|
|
1161
|
+
if (!parent) {
|
|
1162
|
+
return this.warnNodeNotFound(d, mutation.parentId);
|
|
1163
|
+
}
|
|
1164
|
+
if (mutation.isShadow && hasShadowRoot(parent)) {
|
|
1165
|
+
parent = parent.shadowRoot;
|
|
1166
|
+
}
|
|
1167
|
+
mirror.removeNodeFromMap(target);
|
|
1168
|
+
if (parent)
|
|
1169
|
+
try {
|
|
1170
|
+
parent.removeChild(target);
|
|
1171
|
+
if (this.usingVirtualDom &&
|
|
1172
|
+
target.nodeName === '#text' &&
|
|
1173
|
+
parent.nodeName === 'STYLE' &&
|
|
1174
|
+
((_a = parent.rules) === null || _a === void 0 ? void 0 : _a.length) > 0)
|
|
1175
|
+
parent.rules = [];
|
|
1176
|
+
}
|
|
1177
|
+
catch (error) {
|
|
1178
|
+
if (error instanceof DOMException) {
|
|
1179
|
+
this.warn('parent could not remove child in mutation', parent, target, d);
|
|
1180
|
+
}
|
|
1181
|
+
else {
|
|
1182
|
+
throw error;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
});
|
|
1186
|
+
const legacy_missingNodeMap = Object.assign({}, this.legacy_missingNodeRetryMap);
|
|
1187
|
+
const queue = [];
|
|
1188
|
+
const nextNotInDOM = (mutation) => {
|
|
1189
|
+
let next = null;
|
|
1190
|
+
if (mutation.nextId) {
|
|
1191
|
+
next = mirror.getNode(mutation.nextId);
|
|
1192
|
+
}
|
|
1193
|
+
if (mutation.nextId !== null &&
|
|
1194
|
+
mutation.nextId !== undefined &&
|
|
1195
|
+
mutation.nextId !== -1 &&
|
|
1196
|
+
!next) {
|
|
1197
|
+
return true;
|
|
1198
|
+
}
|
|
1199
|
+
return false;
|
|
1200
|
+
};
|
|
1201
|
+
const appendNode = (mutation) => {
|
|
1202
|
+
var _a;
|
|
1203
|
+
if (!this.iframe.contentDocument) {
|
|
1204
|
+
return console.warn('Looks like your replayer has been destroyed.');
|
|
1205
|
+
}
|
|
1206
|
+
let parent = mirror.getNode(mutation.parentId);
|
|
1207
|
+
if (!parent) {
|
|
1208
|
+
if (mutation.node.type === NodeType.Document) {
|
|
1209
|
+
return this.newDocumentQueue.push(mutation);
|
|
1210
|
+
}
|
|
1211
|
+
return queue.push(mutation);
|
|
1212
|
+
}
|
|
1213
|
+
if (mutation.node.isShadow) {
|
|
1214
|
+
if (!hasShadowRoot(parent)) {
|
|
1215
|
+
parent.attachShadow({ mode: 'open' });
|
|
1216
|
+
parent = parent.shadowRoot;
|
|
1217
|
+
}
|
|
1218
|
+
else
|
|
1219
|
+
parent = parent.shadowRoot;
|
|
1220
|
+
}
|
|
1221
|
+
let previous = null;
|
|
1222
|
+
let next = null;
|
|
1223
|
+
if (mutation.previousId) {
|
|
1224
|
+
previous = mirror.getNode(mutation.previousId);
|
|
1225
|
+
}
|
|
1226
|
+
if (mutation.nextId) {
|
|
1227
|
+
next = mirror.getNode(mutation.nextId);
|
|
1228
|
+
}
|
|
1229
|
+
if (nextNotInDOM(mutation)) {
|
|
1230
|
+
return queue.push(mutation);
|
|
1231
|
+
}
|
|
1232
|
+
if (mutation.node.rootId && !mirror.getNode(mutation.node.rootId)) {
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
const targetDoc = mutation.node.rootId
|
|
1236
|
+
? mirror.getNode(mutation.node.rootId)
|
|
1237
|
+
: this.usingVirtualDom
|
|
1238
|
+
? this.virtualDom
|
|
1239
|
+
: this.iframe.contentDocument;
|
|
1240
|
+
if (isSerializedIframe(parent, mirror)) {
|
|
1241
|
+
this.attachDocumentToIframe(mutation, parent);
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
const target = buildNodeWithSN(mutation.node, {
|
|
1245
|
+
doc: targetDoc,
|
|
1246
|
+
mirror: mirror,
|
|
1247
|
+
skipChild: true,
|
|
1248
|
+
hackCss: true,
|
|
1249
|
+
cache: this.cache,
|
|
1250
|
+
});
|
|
1251
|
+
if (mutation.previousId === -1 || mutation.nextId === -1) {
|
|
1252
|
+
legacy_missingNodeMap[mutation.node.id] = {
|
|
1253
|
+
node: target,
|
|
1254
|
+
mutation,
|
|
1255
|
+
};
|
|
1256
|
+
return;
|
|
1257
|
+
}
|
|
1258
|
+
const parentSn = mirror.getMeta(parent);
|
|
1259
|
+
if (parentSn &&
|
|
1260
|
+
parentSn.type === NodeType.Element &&
|
|
1261
|
+
parentSn.tagName === 'textarea' &&
|
|
1262
|
+
mutation.node.type === NodeType.Text) {
|
|
1263
|
+
const childNodeArray = Array.isArray(parent.childNodes)
|
|
1264
|
+
? parent.childNodes
|
|
1265
|
+
: Array.from(parent.childNodes);
|
|
1266
|
+
for (const c of childNodeArray) {
|
|
1267
|
+
if (c.nodeType === parent.TEXT_NODE) {
|
|
1268
|
+
parent.removeChild(c);
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
if (previous && previous.nextSibling && previous.nextSibling.parentNode) {
|
|
1273
|
+
parent.insertBefore(target, previous.nextSibling);
|
|
1274
|
+
}
|
|
1275
|
+
else if (next && next.parentNode) {
|
|
1276
|
+
parent.contains(next)
|
|
1277
|
+
? parent.insertBefore(target, next)
|
|
1278
|
+
: parent.insertBefore(target, null);
|
|
1279
|
+
}
|
|
1280
|
+
else {
|
|
1281
|
+
if (parent === targetDoc) {
|
|
1282
|
+
while (targetDoc.firstChild) {
|
|
1283
|
+
targetDoc.removeChild(targetDoc.firstChild);
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
parent.appendChild(target);
|
|
1287
|
+
}
|
|
1288
|
+
if (this.usingVirtualDom &&
|
|
1289
|
+
target.nodeName === '#text' &&
|
|
1290
|
+
parent.nodeName === 'STYLE' &&
|
|
1291
|
+
((_a = parent.rules) === null || _a === void 0 ? void 0 : _a.length) > 0)
|
|
1292
|
+
parent.rules = [];
|
|
1293
|
+
if (isSerializedIframe(target, this.mirror)) {
|
|
1294
|
+
const targetId = this.mirror.getId(target);
|
|
1295
|
+
const mutationInQueue = this.newDocumentQueue.find((m) => m.parentId === targetId);
|
|
1296
|
+
if (mutationInQueue) {
|
|
1297
|
+
this.attachDocumentToIframe(mutationInQueue, target);
|
|
1298
|
+
this.newDocumentQueue = this.newDocumentQueue.filter((m) => m !== mutationInQueue);
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
if (mutation.previousId || mutation.nextId) {
|
|
1302
|
+
this.legacy_resolveMissingNode(legacy_missingNodeMap, parent, target, mutation);
|
|
1303
|
+
}
|
|
1304
|
+
};
|
|
1305
|
+
d.adds.forEach((mutation) => {
|
|
1306
|
+
appendNode(mutation);
|
|
1307
|
+
});
|
|
1308
|
+
const startTime = Date.now();
|
|
1309
|
+
while (queue.length) {
|
|
1310
|
+
const resolveTrees = queueToResolveTrees(queue);
|
|
1311
|
+
queue.length = 0;
|
|
1312
|
+
if (Date.now() - startTime > 500) {
|
|
1313
|
+
this.warn('Timeout in the loop, please check the resolve tree data:', resolveTrees);
|
|
1314
|
+
break;
|
|
1315
|
+
}
|
|
1316
|
+
for (const tree of resolveTrees) {
|
|
1317
|
+
const parent = mirror.getNode(tree.value.parentId);
|
|
1318
|
+
if (!parent) {
|
|
1319
|
+
this.debug('Drop resolve tree since there is no parent for the root node.', tree);
|
|
1320
|
+
}
|
|
1321
|
+
else {
|
|
1322
|
+
iterateResolveTree(tree, (mutation) => {
|
|
1323
|
+
appendNode(mutation);
|
|
1324
|
+
});
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
if (Object.keys(legacy_missingNodeMap).length) {
|
|
1329
|
+
Object.assign(this.legacy_missingNodeRetryMap, legacy_missingNodeMap);
|
|
1330
|
+
}
|
|
1331
|
+
uniqueTextMutations(d.texts).forEach((mutation) => {
|
|
1332
|
+
var _a;
|
|
1333
|
+
const target = mirror.getNode(mutation.id);
|
|
1334
|
+
if (!target) {
|
|
1335
|
+
if (d.removes.find((r) => r.id === mutation.id)) {
|
|
1336
|
+
return;
|
|
1337
|
+
}
|
|
1338
|
+
return this.warnNodeNotFound(d, mutation.id);
|
|
1339
|
+
}
|
|
1340
|
+
target.textContent = mutation.value;
|
|
1341
|
+
if (this.usingVirtualDom) {
|
|
1342
|
+
const parent = target.parentNode;
|
|
1343
|
+
if (((_a = parent === null || parent === void 0 ? void 0 : parent.rules) === null || _a === void 0 ? void 0 : _a.length) > 0)
|
|
1344
|
+
parent.rules = [];
|
|
1345
|
+
}
|
|
1346
|
+
});
|
|
1347
|
+
d.attributes.forEach((mutation) => {
|
|
1348
|
+
const target = mirror.getNode(mutation.id);
|
|
1349
|
+
if (!target) {
|
|
1350
|
+
if (d.removes.find((r) => r.id === mutation.id)) {
|
|
1351
|
+
return;
|
|
1352
|
+
}
|
|
1353
|
+
return this.warnNodeNotFound(d, mutation.id);
|
|
1354
|
+
}
|
|
1355
|
+
for (const attributeName in mutation.attributes) {
|
|
1356
|
+
if (typeof attributeName === 'string') {
|
|
1357
|
+
const value = mutation.attributes[attributeName];
|
|
1358
|
+
if (value === null) {
|
|
1359
|
+
target.removeAttribute(attributeName);
|
|
1360
|
+
}
|
|
1361
|
+
else if (typeof value === 'string') {
|
|
1362
|
+
try {
|
|
1363
|
+
target.setAttribute(attributeName, value);
|
|
1364
|
+
}
|
|
1365
|
+
catch (error) {
|
|
1366
|
+
if (this.config.showWarning) {
|
|
1367
|
+
console.warn('An error occurred may due to the checkout feature.', error);
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
else if (attributeName === 'style') {
|
|
1372
|
+
const styleValues = value;
|
|
1373
|
+
const targetEl = target;
|
|
1374
|
+
for (const s in styleValues) {
|
|
1375
|
+
if (styleValues[s] === false) {
|
|
1376
|
+
targetEl.style.removeProperty(s);
|
|
1377
|
+
}
|
|
1378
|
+
else if (styleValues[s] instanceof Array) {
|
|
1379
|
+
const svp = styleValues[s];
|
|
1380
|
+
targetEl.style.setProperty(s, svp[0], svp[1]);
|
|
1381
|
+
}
|
|
1382
|
+
else {
|
|
1383
|
+
const svs = styleValues[s];
|
|
1384
|
+
targetEl.style.setProperty(s, svs);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
applyScroll(d, isSync) {
|
|
1393
|
+
const target = this.mirror.getNode(d.id);
|
|
1394
|
+
if (!target) {
|
|
1395
|
+
return this.debugNodeNotFound(d, d.id);
|
|
1396
|
+
}
|
|
1397
|
+
const sn = this.mirror.getMeta(target);
|
|
1398
|
+
if (target === this.iframe.contentDocument) {
|
|
1399
|
+
this.iframe.contentWindow.scrollTo({
|
|
1400
|
+
top: d.y,
|
|
1401
|
+
left: d.x,
|
|
1402
|
+
behavior: isSync ? 'auto' : 'smooth',
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
else if ((sn === null || sn === void 0 ? void 0 : sn.type) === NodeType.Document) {
|
|
1406
|
+
target.defaultView.scrollTo({
|
|
1407
|
+
top: d.y,
|
|
1408
|
+
left: d.x,
|
|
1409
|
+
behavior: isSync ? 'auto' : 'smooth',
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
else {
|
|
1413
|
+
try {
|
|
1414
|
+
target.scrollTop = d.y;
|
|
1415
|
+
target.scrollLeft = d.x;
|
|
1416
|
+
}
|
|
1417
|
+
catch (error) {
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
applyInput(d) {
|
|
1422
|
+
const target = this.mirror.getNode(d.id);
|
|
1423
|
+
if (!target) {
|
|
1424
|
+
return this.debugNodeNotFound(d, d.id);
|
|
1425
|
+
}
|
|
1426
|
+
try {
|
|
1427
|
+
target.checked = d.isChecked;
|
|
1428
|
+
target.value = d.text;
|
|
1429
|
+
}
|
|
1430
|
+
catch (error) {
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
legacy_resolveMissingNode(map, parent, target, targetMutation) {
|
|
1434
|
+
const { previousId, nextId } = targetMutation;
|
|
1435
|
+
const previousInMap = previousId && map[previousId];
|
|
1436
|
+
const nextInMap = nextId && map[nextId];
|
|
1437
|
+
if (previousInMap) {
|
|
1438
|
+
const { node, mutation } = previousInMap;
|
|
1439
|
+
parent.insertBefore(node, target);
|
|
1440
|
+
delete map[mutation.node.id];
|
|
1441
|
+
delete this.legacy_missingNodeRetryMap[mutation.node.id];
|
|
1442
|
+
if (mutation.previousId || mutation.nextId) {
|
|
1443
|
+
this.legacy_resolveMissingNode(map, parent, node, mutation);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
if (nextInMap) {
|
|
1447
|
+
const { node, mutation } = nextInMap;
|
|
1448
|
+
parent.insertBefore(node, target.nextSibling);
|
|
1449
|
+
delete map[mutation.node.id];
|
|
1450
|
+
delete this.legacy_missingNodeRetryMap[mutation.node.id];
|
|
1451
|
+
if (mutation.previousId || mutation.nextId) {
|
|
1452
|
+
this.legacy_resolveMissingNode(map, parent, node, mutation);
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
moveAndHover(x, y, id, isSync, debugData) {
|
|
1457
|
+
const target = this.mirror.getNode(id);
|
|
1458
|
+
if (!target) {
|
|
1459
|
+
return this.debugNodeNotFound(debugData, id);
|
|
1460
|
+
}
|
|
1461
|
+
const base = getBaseDimension(target, this.iframe);
|
|
1462
|
+
const _x = x * base.absoluteScale + base.x;
|
|
1463
|
+
const _y = y * base.absoluteScale + base.y;
|
|
1464
|
+
this.mouse.style.left = `${_x}px`;
|
|
1465
|
+
this.mouse.style.top = `${_y}px`;
|
|
1466
|
+
if (!isSync) {
|
|
1467
|
+
this.drawMouseTail({ x: _x, y: _y });
|
|
1468
|
+
}
|
|
1469
|
+
this.hoverElements(target);
|
|
1470
|
+
}
|
|
1471
|
+
drawMouseTail(position) {
|
|
1472
|
+
if (!this.mouseTail) {
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
const { lineCap, lineWidth, strokeStyle, duration } = this.config.mouseTail === true
|
|
1476
|
+
? defaultMouseTailConfig
|
|
1477
|
+
: Object.assign({}, defaultMouseTailConfig, this.config.mouseTail);
|
|
1478
|
+
const draw = () => {
|
|
1479
|
+
if (!this.mouseTail) {
|
|
1480
|
+
return;
|
|
1481
|
+
}
|
|
1482
|
+
const ctx = this.mouseTail.getContext('2d');
|
|
1483
|
+
if (!ctx || !this.tailPositions.length) {
|
|
1484
|
+
return;
|
|
1485
|
+
}
|
|
1486
|
+
ctx.clearRect(0, 0, this.mouseTail.width, this.mouseTail.height);
|
|
1487
|
+
ctx.beginPath();
|
|
1488
|
+
ctx.lineWidth = lineWidth;
|
|
1489
|
+
ctx.lineCap = lineCap;
|
|
1490
|
+
ctx.strokeStyle = strokeStyle;
|
|
1491
|
+
ctx.moveTo(this.tailPositions[0].x, this.tailPositions[0].y);
|
|
1492
|
+
this.tailPositions.forEach((p) => ctx.lineTo(p.x, p.y));
|
|
1493
|
+
ctx.stroke();
|
|
1494
|
+
};
|
|
1495
|
+
this.tailPositions.push(position);
|
|
1496
|
+
draw();
|
|
1497
|
+
setTimeout(() => {
|
|
1498
|
+
this.tailPositions = this.tailPositions.filter((p) => p !== position);
|
|
1499
|
+
draw();
|
|
1500
|
+
}, duration / this.speedService.state.context.timer.speed);
|
|
1501
|
+
}
|
|
1502
|
+
hoverElements(el) {
|
|
1503
|
+
var _a;
|
|
1504
|
+
(_a = this.iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.\\:hover').forEach((hoveredEl) => {
|
|
1505
|
+
hoveredEl.classList.remove(':hover');
|
|
1506
|
+
});
|
|
1507
|
+
let currentEl = el;
|
|
1508
|
+
while (currentEl) {
|
|
1509
|
+
if (currentEl.classList) {
|
|
1510
|
+
currentEl.classList.add(':hover');
|
|
1511
|
+
}
|
|
1512
|
+
currentEl = currentEl.parentElement;
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
isUserInteraction(event) {
|
|
1516
|
+
if (event.type !== EventType.IncrementalSnapshot) {
|
|
1517
|
+
return false;
|
|
1518
|
+
}
|
|
1519
|
+
return (event.data.source > IncrementalSource.Mutation &&
|
|
1520
|
+
event.data.source <= IncrementalSource.Input);
|
|
1521
|
+
}
|
|
1522
|
+
backToNormal() {
|
|
1523
|
+
this.nextUserInteractionEvent = null;
|
|
1524
|
+
if (this.speedService.state.matches('normal')) {
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
this.speedService.send({ type: 'BACK_TO_NORMAL' });
|
|
1528
|
+
this.emitter.emit(ReplayerEvents.SkipEnd, {
|
|
1529
|
+
speed: this.speedService.state.context.normalSpeed,
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
warnNodeNotFound(d, id) {
|
|
1533
|
+
this.warn(`Node with id '${id}' not found. `, d);
|
|
1534
|
+
}
|
|
1535
|
+
warnCanvasMutationFailed(d, error) {
|
|
1536
|
+
this.warn(`Has error on canvas update`, error, 'canvas mutation:', d);
|
|
1537
|
+
}
|
|
1538
|
+
debugNodeNotFound(d, id) {
|
|
1539
|
+
this.debug(REPLAY_CONSOLE_PREFIX, `Node with id '${id}' not found. `, d);
|
|
1540
|
+
}
|
|
1541
|
+
warn(...args) {
|
|
1542
|
+
if (!this.config.showWarning) {
|
|
1543
|
+
return;
|
|
1544
|
+
}
|
|
1545
|
+
console.warn(REPLAY_CONSOLE_PREFIX, ...args);
|
|
1546
|
+
}
|
|
1547
|
+
debug(...args) {
|
|
1548
|
+
if (!this.config.showDebug) {
|
|
1549
|
+
return;
|
|
1550
|
+
}
|
|
1551
|
+
console.log(REPLAY_CONSOLE_PREFIX, ...args);
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
export { Replayer };
|