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