@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,381 +1,356 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { snapshot } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
|
|
1
|
+
import { createMirror, snapshot } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
|
|
3
2
|
import { initObservers, mutationBuffers } from './observer.js';
|
|
4
|
-
import { polyfill, on,
|
|
3
|
+
import { polyfill, on, getWindowWidth, getWindowHeight, isSerializedIframe, hasShadowRoot } from '../utils.js';
|
|
5
4
|
import { EventType, IncrementalSource } from '../types.js';
|
|
6
5
|
import { IframeManager } from './iframe-manager.js';
|
|
7
6
|
import { ShadowDomManager } from './shadow-dom-manager.js';
|
|
8
7
|
import { CanvasManager } from './observers/canvas/canvas-manager.js';
|
|
8
|
+
import { StylesheetManager } from './stylesheet-manager.js';
|
|
9
9
|
|
|
10
|
-
function wrapEvent(e) {
|
|
11
|
-
return
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function record(options) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
? {
|
|
27
|
-
color: true,
|
|
28
|
-
date: true,
|
|
29
|
-
'datetime-local': true,
|
|
30
|
-
email: true,
|
|
31
|
-
month: true,
|
|
32
|
-
number: true,
|
|
33
|
-
range: true,
|
|
34
|
-
search: true,
|
|
35
|
-
tel: true,
|
|
36
|
-
text: true,
|
|
37
|
-
time: true,
|
|
38
|
-
url: true,
|
|
39
|
-
week: true,
|
|
40
|
-
textarea: true,
|
|
41
|
-
select: true,
|
|
42
|
-
password: true,
|
|
43
|
-
}
|
|
44
|
-
: _maskInputOptions !== undefined
|
|
45
|
-
? _maskInputOptions
|
|
46
|
-
: { password: true };
|
|
47
|
-
|
|
48
|
-
? {
|
|
49
|
-
script: true,
|
|
50
|
-
comment: true,
|
|
51
|
-
headFavicon: true,
|
|
52
|
-
headWhitespace: true,
|
|
53
|
-
headMetaSocial: true,
|
|
54
|
-
headMetaRobots: true,
|
|
55
|
-
headMetaHttpEquiv: true,
|
|
56
|
-
headMetaVerification: true,
|
|
57
|
-
headMetaAuthorship: _slimDOMOptions === 'all',
|
|
58
|
-
headMetaDescKeywords: _slimDOMOptions === 'all',
|
|
59
|
-
}
|
|
60
|
-
: _slimDOMOptions
|
|
61
|
-
? _slimDOMOptions
|
|
62
|
-
: {};
|
|
63
|
-
polyfill();
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
e.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
catch (error) {
|
|
355
|
-
console.warn(error);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
record.addCustomEvent = function (tag, payload) {
|
|
359
|
-
if (!wrappedEmit) {
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
wrappedEmit(wrapEvent({
|
|
363
|
-
type: EventType.Custom,
|
|
364
|
-
data: {
|
|
365
|
-
tag: tag,
|
|
366
|
-
payload: payload,
|
|
367
|
-
},
|
|
368
|
-
}));
|
|
369
|
-
};
|
|
370
|
-
record.freezePage = function () {
|
|
371
|
-
mutationBuffers.forEach(function (buf) { return buf.freeze(); });
|
|
372
|
-
};
|
|
373
|
-
record.takeFullSnapshot = function (isCheckout) {
|
|
374
|
-
if (!takeFullSnapshot) {
|
|
375
|
-
throw new Error('please take full snapshot after start recording');
|
|
376
|
-
}
|
|
377
|
-
takeFullSnapshot(isCheckout);
|
|
378
|
-
};
|
|
10
|
+
function wrapEvent(e) {
|
|
11
|
+
return Object.assign(Object.assign({}, e), { timestamp: Date.now() });
|
|
12
|
+
}
|
|
13
|
+
let wrappedEmit;
|
|
14
|
+
let takeFullSnapshot;
|
|
15
|
+
const mirror = createMirror();
|
|
16
|
+
function record(options = {}) {
|
|
17
|
+
const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = 'highlight-block', blockSelector = null, ignoreClass = 'highlight-ignore', maskTextClass = 'highlight-mask', maskTextSelector = null, inlineStylesheet = true, maskAllInputs, maskInputOptions: _maskInputOptions, slimDOMOptions: _slimDOMOptions, maskInputFn, maskTextFn, hooks, packFn, sampling = {}, mousemoveWait, recordCanvas = false, userTriggeredOnInput = false, collectFonts = false, inlineImages = false, plugins, keepIframeSrcFn = () => false, enableStrictPrivacy = false, } = options;
|
|
18
|
+
if (!emit) {
|
|
19
|
+
throw new Error('emit function is required');
|
|
20
|
+
}
|
|
21
|
+
if (mousemoveWait !== undefined && sampling.mousemove === undefined) {
|
|
22
|
+
sampling.mousemove = mousemoveWait;
|
|
23
|
+
}
|
|
24
|
+
mirror.reset();
|
|
25
|
+
const maskInputOptions = maskAllInputs === true
|
|
26
|
+
? {
|
|
27
|
+
color: true,
|
|
28
|
+
date: true,
|
|
29
|
+
'datetime-local': true,
|
|
30
|
+
email: true,
|
|
31
|
+
month: true,
|
|
32
|
+
number: true,
|
|
33
|
+
range: true,
|
|
34
|
+
search: true,
|
|
35
|
+
tel: true,
|
|
36
|
+
text: true,
|
|
37
|
+
time: true,
|
|
38
|
+
url: true,
|
|
39
|
+
week: true,
|
|
40
|
+
textarea: true,
|
|
41
|
+
select: true,
|
|
42
|
+
password: true,
|
|
43
|
+
}
|
|
44
|
+
: _maskInputOptions !== undefined
|
|
45
|
+
? _maskInputOptions
|
|
46
|
+
: { password: true };
|
|
47
|
+
const slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === 'all'
|
|
48
|
+
? {
|
|
49
|
+
script: true,
|
|
50
|
+
comment: true,
|
|
51
|
+
headFavicon: true,
|
|
52
|
+
headWhitespace: true,
|
|
53
|
+
headMetaSocial: true,
|
|
54
|
+
headMetaRobots: true,
|
|
55
|
+
headMetaHttpEquiv: true,
|
|
56
|
+
headMetaVerification: true,
|
|
57
|
+
headMetaAuthorship: _slimDOMOptions === 'all',
|
|
58
|
+
headMetaDescKeywords: _slimDOMOptions === 'all',
|
|
59
|
+
}
|
|
60
|
+
: _slimDOMOptions
|
|
61
|
+
? _slimDOMOptions
|
|
62
|
+
: {};
|
|
63
|
+
polyfill();
|
|
64
|
+
let lastFullSnapshotEvent;
|
|
65
|
+
let incrementalSnapshotCount = 0;
|
|
66
|
+
const eventProcessor = (e) => {
|
|
67
|
+
for (const plugin of plugins || []) {
|
|
68
|
+
if (plugin.eventProcessor) {
|
|
69
|
+
e = plugin.eventProcessor(e);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (packFn) {
|
|
73
|
+
e = packFn(e);
|
|
74
|
+
}
|
|
75
|
+
return e;
|
|
76
|
+
};
|
|
77
|
+
wrappedEmit = (e, isCheckout) => {
|
|
78
|
+
var _a;
|
|
79
|
+
if (((_a = mutationBuffers[0]) === null || _a === void 0 ? void 0 : _a.isFrozen()) &&
|
|
80
|
+
e.type !== EventType.FullSnapshot &&
|
|
81
|
+
!(e.type === EventType.IncrementalSnapshot &&
|
|
82
|
+
e.data.source === IncrementalSource.Mutation)) {
|
|
83
|
+
mutationBuffers.forEach((buf) => buf.unfreeze());
|
|
84
|
+
}
|
|
85
|
+
emit(eventProcessor(e), isCheckout);
|
|
86
|
+
if (e.type === EventType.FullSnapshot) {
|
|
87
|
+
lastFullSnapshotEvent = e;
|
|
88
|
+
incrementalSnapshotCount = 0;
|
|
89
|
+
}
|
|
90
|
+
else if (e.type === EventType.IncrementalSnapshot) {
|
|
91
|
+
if (e.data.source === IncrementalSource.Mutation &&
|
|
92
|
+
e.data.isAttachIframe) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
incrementalSnapshotCount++;
|
|
96
|
+
const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
|
|
97
|
+
const exceedTime = checkoutEveryNms &&
|
|
98
|
+
e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
|
|
99
|
+
if (exceedCount || exceedTime) {
|
|
100
|
+
takeFullSnapshot(true);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const wrappedMutationEmit = (m) => {
|
|
105
|
+
wrappedEmit(wrapEvent({
|
|
106
|
+
type: EventType.IncrementalSnapshot,
|
|
107
|
+
data: Object.assign({ source: IncrementalSource.Mutation }, m),
|
|
108
|
+
}));
|
|
109
|
+
};
|
|
110
|
+
const wrappedScrollEmit = (p) => wrappedEmit(wrapEvent({
|
|
111
|
+
type: EventType.IncrementalSnapshot,
|
|
112
|
+
data: Object.assign({ source: IncrementalSource.Scroll }, p),
|
|
113
|
+
}));
|
|
114
|
+
const wrappedCanvasMutationEmit = (p) => wrappedEmit(wrapEvent({
|
|
115
|
+
type: EventType.IncrementalSnapshot,
|
|
116
|
+
data: Object.assign({ source: IncrementalSource.CanvasMutation }, p),
|
|
117
|
+
}));
|
|
118
|
+
const iframeManager = new IframeManager({
|
|
119
|
+
mutationCb: wrappedMutationEmit,
|
|
120
|
+
});
|
|
121
|
+
const stylesheetManager = new StylesheetManager({
|
|
122
|
+
mutationCb: wrappedMutationEmit,
|
|
123
|
+
});
|
|
124
|
+
const canvasManager = new CanvasManager({
|
|
125
|
+
recordCanvas,
|
|
126
|
+
mutationCb: wrappedCanvasMutationEmit,
|
|
127
|
+
win: window,
|
|
128
|
+
blockClass,
|
|
129
|
+
mirror,
|
|
130
|
+
sampling: sampling.canvas,
|
|
131
|
+
});
|
|
132
|
+
const shadowDomManager = new ShadowDomManager({
|
|
133
|
+
mutationCb: wrappedMutationEmit,
|
|
134
|
+
scrollCb: wrappedScrollEmit,
|
|
135
|
+
bypassOptions: {
|
|
136
|
+
blockClass,
|
|
137
|
+
blockSelector,
|
|
138
|
+
maskTextClass,
|
|
139
|
+
maskTextSelector,
|
|
140
|
+
inlineStylesheet,
|
|
141
|
+
maskInputOptions,
|
|
142
|
+
maskTextFn,
|
|
143
|
+
maskInputFn,
|
|
144
|
+
recordCanvas,
|
|
145
|
+
inlineImages,
|
|
146
|
+
sampling,
|
|
147
|
+
slimDOMOptions,
|
|
148
|
+
iframeManager,
|
|
149
|
+
stylesheetManager,
|
|
150
|
+
canvasManager,
|
|
151
|
+
enableStrictPrivacy
|
|
152
|
+
},
|
|
153
|
+
mirror,
|
|
154
|
+
});
|
|
155
|
+
takeFullSnapshot = (isCheckout = false) => {
|
|
156
|
+
var _a, _b, _c, _d;
|
|
157
|
+
wrappedEmit(wrapEvent({
|
|
158
|
+
type: EventType.Meta,
|
|
159
|
+
data: {
|
|
160
|
+
href: window.location.href,
|
|
161
|
+
width: getWindowWidth(),
|
|
162
|
+
height: getWindowHeight(),
|
|
163
|
+
},
|
|
164
|
+
}), isCheckout);
|
|
165
|
+
mutationBuffers.forEach((buf) => buf.lock());
|
|
166
|
+
const node = snapshot(document, {
|
|
167
|
+
mirror,
|
|
168
|
+
blockClass,
|
|
169
|
+
blockSelector,
|
|
170
|
+
maskTextClass,
|
|
171
|
+
maskTextSelector,
|
|
172
|
+
inlineStylesheet,
|
|
173
|
+
maskAllInputs: maskInputOptions,
|
|
174
|
+
maskTextFn,
|
|
175
|
+
slimDOM: slimDOMOptions,
|
|
176
|
+
recordCanvas,
|
|
177
|
+
inlineImages,
|
|
178
|
+
enableStrictPrivacy,
|
|
179
|
+
onSerialize: (n) => {
|
|
180
|
+
if (isSerializedIframe(n, mirror)) {
|
|
181
|
+
iframeManager.addIframe(n);
|
|
182
|
+
}
|
|
183
|
+
if (hasShadowRoot(n)) {
|
|
184
|
+
shadowDomManager.addShadowRoot(n.shadowRoot, document);
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
onIframeLoad: (iframe, childSn) => {
|
|
188
|
+
iframeManager.attachIframe(iframe, childSn, mirror);
|
|
189
|
+
shadowDomManager.observeAttachShadow(iframe);
|
|
190
|
+
},
|
|
191
|
+
onStylesheetLoad: (linkEl, childSn) => {
|
|
192
|
+
this.stylesheetManager.attachStylesheet(linkEl, childSn, this.mirror);
|
|
193
|
+
},
|
|
194
|
+
keepIframeSrcFn,
|
|
195
|
+
});
|
|
196
|
+
if (!node) {
|
|
197
|
+
return console.warn('Failed to snapshot the document');
|
|
198
|
+
}
|
|
199
|
+
wrappedEmit(wrapEvent({
|
|
200
|
+
type: EventType.FullSnapshot,
|
|
201
|
+
data: {
|
|
202
|
+
node,
|
|
203
|
+
initialOffset: {
|
|
204
|
+
left: window.pageXOffset !== undefined
|
|
205
|
+
? window.pageXOffset
|
|
206
|
+
: (document === null || document === void 0 ? void 0 : document.documentElement.scrollLeft) ||
|
|
207
|
+
((_b = (_a = document === null || document === void 0 ? void 0 : document.body) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.scrollLeft) ||
|
|
208
|
+
(document === null || document === void 0 ? void 0 : document.body.scrollLeft) ||
|
|
209
|
+
0,
|
|
210
|
+
top: window.pageYOffset !== undefined
|
|
211
|
+
? window.pageYOffset
|
|
212
|
+
: (document === null || document === void 0 ? void 0 : document.documentElement.scrollTop) ||
|
|
213
|
+
((_d = (_c = document === null || document === void 0 ? void 0 : document.body) === null || _c === void 0 ? void 0 : _c.parentElement) === null || _d === void 0 ? void 0 : _d.scrollTop) ||
|
|
214
|
+
(document === null || document === void 0 ? void 0 : document.body.scrollTop) ||
|
|
215
|
+
0,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
}));
|
|
219
|
+
mutationBuffers.forEach((buf) => buf.unlock());
|
|
220
|
+
};
|
|
221
|
+
try {
|
|
222
|
+
const handlers = [];
|
|
223
|
+
handlers.push(on('DOMContentLoaded', () => {
|
|
224
|
+
wrappedEmit(wrapEvent({
|
|
225
|
+
type: EventType.DomContentLoaded,
|
|
226
|
+
data: {},
|
|
227
|
+
}));
|
|
228
|
+
}));
|
|
229
|
+
const observe = (doc) => {
|
|
230
|
+
var _a;
|
|
231
|
+
return initObservers({
|
|
232
|
+
mutationCb: wrappedMutationEmit,
|
|
233
|
+
mousemoveCb: (positions, source) => wrappedEmit(wrapEvent({
|
|
234
|
+
type: EventType.IncrementalSnapshot,
|
|
235
|
+
data: {
|
|
236
|
+
source,
|
|
237
|
+
positions,
|
|
238
|
+
},
|
|
239
|
+
})),
|
|
240
|
+
mouseInteractionCb: (d) => wrappedEmit(wrapEvent({
|
|
241
|
+
type: EventType.IncrementalSnapshot,
|
|
242
|
+
data: Object.assign({ source: IncrementalSource.MouseInteraction }, d),
|
|
243
|
+
})),
|
|
244
|
+
scrollCb: wrappedScrollEmit,
|
|
245
|
+
viewportResizeCb: (d) => wrappedEmit(wrapEvent({
|
|
246
|
+
type: EventType.IncrementalSnapshot,
|
|
247
|
+
data: Object.assign({ source: IncrementalSource.ViewportResize }, d),
|
|
248
|
+
})),
|
|
249
|
+
inputCb: (v) => wrappedEmit(wrapEvent({
|
|
250
|
+
type: EventType.IncrementalSnapshot,
|
|
251
|
+
data: Object.assign({ source: IncrementalSource.Input }, v),
|
|
252
|
+
})),
|
|
253
|
+
mediaInteractionCb: (p) => wrappedEmit(wrapEvent({
|
|
254
|
+
type: EventType.IncrementalSnapshot,
|
|
255
|
+
data: Object.assign({ source: IncrementalSource.MediaInteraction }, p),
|
|
256
|
+
})),
|
|
257
|
+
styleSheetRuleCb: (r) => wrappedEmit(wrapEvent({
|
|
258
|
+
type: EventType.IncrementalSnapshot,
|
|
259
|
+
data: Object.assign({ source: IncrementalSource.StyleSheetRule }, r),
|
|
260
|
+
})),
|
|
261
|
+
styleDeclarationCb: (r) => wrappedEmit(wrapEvent({
|
|
262
|
+
type: EventType.IncrementalSnapshot,
|
|
263
|
+
data: Object.assign({ source: IncrementalSource.StyleDeclaration }, r),
|
|
264
|
+
})),
|
|
265
|
+
canvasMutationCb: wrappedCanvasMutationEmit,
|
|
266
|
+
fontCb: (p) => wrappedEmit(wrapEvent({
|
|
267
|
+
type: EventType.IncrementalSnapshot,
|
|
268
|
+
data: Object.assign({ source: IncrementalSource.Font }, p),
|
|
269
|
+
})),
|
|
270
|
+
blockClass,
|
|
271
|
+
ignoreClass,
|
|
272
|
+
maskTextClass,
|
|
273
|
+
maskTextSelector,
|
|
274
|
+
maskInputOptions,
|
|
275
|
+
inlineStylesheet,
|
|
276
|
+
sampling,
|
|
277
|
+
recordCanvas,
|
|
278
|
+
inlineImages,
|
|
279
|
+
userTriggeredOnInput,
|
|
280
|
+
collectFonts,
|
|
281
|
+
doc,
|
|
282
|
+
maskInputFn,
|
|
283
|
+
maskTextFn,
|
|
284
|
+
blockSelector,
|
|
285
|
+
slimDOMOptions,
|
|
286
|
+
mirror,
|
|
287
|
+
iframeManager,
|
|
288
|
+
stylesheetManager,
|
|
289
|
+
shadowDomManager,
|
|
290
|
+
canvasManager,
|
|
291
|
+
enableStrictPrivacy,
|
|
292
|
+
plugins: ((_a = plugins === null || plugins === void 0 ? void 0 : plugins.filter((p) => p.observer)) === null || _a === void 0 ? void 0 : _a.map((p) => ({
|
|
293
|
+
observer: p.observer,
|
|
294
|
+
options: p.options,
|
|
295
|
+
callback: (payload) => wrappedEmit(wrapEvent({
|
|
296
|
+
type: EventType.Plugin,
|
|
297
|
+
data: {
|
|
298
|
+
plugin: p.name,
|
|
299
|
+
payload,
|
|
300
|
+
},
|
|
301
|
+
})),
|
|
302
|
+
}))) || [],
|
|
303
|
+
}, hooks);
|
|
304
|
+
};
|
|
305
|
+
iframeManager.addLoadListener((iframeEl) => {
|
|
306
|
+
handlers.push(observe(iframeEl.contentDocument));
|
|
307
|
+
});
|
|
308
|
+
const init = () => {
|
|
309
|
+
takeFullSnapshot();
|
|
310
|
+
handlers.push(observe(document));
|
|
311
|
+
};
|
|
312
|
+
if (document.readyState === 'interactive' ||
|
|
313
|
+
document.readyState === 'complete') {
|
|
314
|
+
init();
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
handlers.push(on('load', () => {
|
|
318
|
+
wrappedEmit(wrapEvent({
|
|
319
|
+
type: EventType.Load,
|
|
320
|
+
data: {},
|
|
321
|
+
}));
|
|
322
|
+
init();
|
|
323
|
+
}, window));
|
|
324
|
+
}
|
|
325
|
+
return () => {
|
|
326
|
+
handlers.forEach((h) => h());
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
console.warn(error);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
record.addCustomEvent = (tag, payload) => {
|
|
334
|
+
if (!wrappedEmit) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
wrappedEmit(wrapEvent({
|
|
338
|
+
type: EventType.Custom,
|
|
339
|
+
data: {
|
|
340
|
+
tag,
|
|
341
|
+
payload,
|
|
342
|
+
},
|
|
343
|
+
}));
|
|
344
|
+
};
|
|
345
|
+
record.freezePage = () => {
|
|
346
|
+
mutationBuffers.forEach((buf) => buf.freeze());
|
|
347
|
+
};
|
|
348
|
+
record.takeFullSnapshot = (isCheckout) => {
|
|
349
|
+
if (!takeFullSnapshot) {
|
|
350
|
+
throw new Error('please take full snapshot after start recording');
|
|
351
|
+
}
|
|
352
|
+
takeFullSnapshot(isCheckout);
|
|
353
|
+
};
|
|
379
354
|
record.mirror = mirror;
|
|
380
355
|
|
|
381
|
-
export default
|
|
356
|
+
export { record as default };
|