@highlight-run/rrweb 1.2.0 → 2.0.1
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 +655 -0
- package/dist/plugins/console-record.min.js +1 -1
- package/dist/plugins/console-record.min.js.map +1 -1
- package/dist/plugins/console-replay.js +293 -0
- package/dist/plugins/console-replay.min.js +16 -0
- package/dist/plugins/console-replay.min.js.map +1 -0
- package/dist/plugins/sequential-id-record.js +33 -0
- package/dist/plugins/sequential-id-record.min.js +2 -0
- package/dist/plugins/sequential-id-record.min.js.map +1 -0
- package/dist/plugins/sequential-id-replay.js +37 -0
- package/dist/plugins/sequential-id-replay.min.js +2 -0
- package/dist/plugins/sequential-id-replay.min.js.map +1 -0
- package/dist/record/rrweb-record-pack.js +747 -0
- package/dist/record/rrweb-record-pack.min.js +16 -0
- package/dist/record/rrweb-record-pack.min.js.map +1 -0
- package/dist/record/rrweb-record.js +3318 -0
- package/dist/record/rrweb-record.min.js +16 -0
- package/dist/record/rrweb-record.min.js.map +1 -0
- package/dist/replay/rrweb-replay-unpack.js +4626 -0
- package/dist/replay/rrweb-replay-unpack.min.css +2 -0
- package/dist/replay/rrweb-replay-unpack.min.css.map +1 -0
- package/dist/replay/rrweb-replay-unpack.min.js +30 -0
- package/dist/replay/rrweb-replay-unpack.min.js.map +1 -0
- package/dist/replay/rrweb-replay.js +4216 -0
- package/dist/replay/rrweb-replay.min.css +2 -0
- package/dist/replay/rrweb-replay.min.css.map +1 -0
- package/dist/replay/rrweb-replay.min.js +30 -0
- package/dist/replay/rrweb-replay.min.js.map +1 -0
- package/dist/rrweb-all.js +8708 -0
- package/dist/rrweb-all.min.css +2 -0
- package/dist/rrweb-all.min.css.map +1 -0
- package/dist/rrweb-all.min.js +30 -0
- package/dist/rrweb-all.min.js.map +1 -0
- package/dist/rrweb.js +7294 -0
- package/dist/rrweb.min.css +2 -0
- package/dist/rrweb.min.css.map +1 -0
- package/dist/rrweb.min.js +2 -2
- package/dist/rrweb.min.js.map +1 -1
- package/es/rrweb/ext/@xstate/fsm/es/index.js +17 -0
- package/es/rrweb/ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js +49 -0
- package/es/rrweb/ext/fflate/esm/browser.js +777 -0
- package/es/rrweb/ext/mitt/dist/mitt.es.js +63 -0
- package/es/rrweb/packages/rrweb/ext/tslib/tslib.es6.js +78 -0
- package/es/rrweb/packages/rrweb/src/entries/all.js +13 -0
- package/es/rrweb/packages/rrweb/src/index.js +12 -0
- package/es/rrweb/packages/rrweb/src/packer/base.js +3 -0
- package/es/rrweb/packages/rrweb/src/packer/pack.js +10 -0
- package/es/rrweb/packages/rrweb/src/packer/unpack.js +29 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js +179 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/record/index.js +134 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js +141 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js +111 -0
- package/es/rrweb/packages/rrweb/src/plugins/sequential-id/record/index.js +23 -0
- package/es/rrweb/packages/rrweb/src/plugins/sequential-id/replay/index.js +28 -0
- package/es/rrweb/packages/rrweb/src/record/iframe-manager.js +32 -0
- package/es/rrweb/packages/rrweb/src/record/index.js +381 -0
- package/es/rrweb/packages/rrweb/src/record/mutation.js +532 -0
- package/es/rrweb/packages/rrweb/src/record/observer.js +665 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +78 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +93 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +30 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js +116 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +78 -0
- package/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js +45 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/2d.js +25 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/index.js +35 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js +124 -0
- package/es/rrweb/packages/rrweb/src/replay/index.js +1864 -0
- package/es/rrweb/packages/rrweb/src/replay/machine.js +321 -0
- package/es/rrweb/packages/rrweb/src/replay/smoothscroll.js +221 -0
- package/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js +8 -0
- package/es/rrweb/packages/rrweb/src/replay/timer.js +96 -0
- package/es/rrweb/packages/rrweb/src/replay/virtual-styles.js +121 -0
- package/es/rrweb/packages/rrweb/src/types.js +75 -0
- package/es/rrweb/packages/rrweb/src/utils.js +509 -0
- package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +1697 -0
- package/lib/plugins/console-record.js +650 -0
- package/lib/plugins/console-replay.js +288 -0
- package/lib/plugins/sequential-id-record.js +28 -0
- package/lib/plugins/sequential-id-replay.js +32 -0
- package/lib/record/rrweb-record-pack.js +742 -0
- package/lib/record/rrweb-record.js +3315 -0
- package/lib/replay/rrweb-replay-unpack.js +4621 -0
- package/lib/replay/rrweb-replay.js +4211 -0
- package/lib/rrweb-all.js +8703 -0
- package/lib/rrweb.js +7289 -0
- package/package.json +41 -43
- package/typings/entries/all.d.ts +6 -0
- package/{dist → typings}/entries/record-pack.d.ts +0 -0
- package/{dist → typings}/entries/replay-unpack.d.ts +0 -0
- package/{dist → typings}/index.d.ts +1 -2
- package/{dist → typings}/packer/base.d.ts +0 -0
- package/{dist → typings}/packer/index.d.ts +0 -0
- package/{dist → typings}/packer/pack.d.ts +0 -0
- package/{dist → typings}/packer/unpack.d.ts +0 -0
- package/{dist → typings}/plugins/console/record/error-stack-parser.d.ts +0 -0
- package/{dist → typings}/plugins/console/record/index.d.ts +3 -2
- package/{dist → typings}/plugins/console/record/stringify.d.ts +0 -0
- package/{dist → typings}/plugins/console/replay/index.d.ts +2 -2
- package/{dist → typings}/plugins/sequential-id/record/index.d.ts +0 -0
- package/{dist → typings}/plugins/sequential-id/replay/index.d.ts +0 -0
- package/{dist → typings}/record/iframe-manager.d.ts +1 -1
- package/{dist → typings}/record/index.d.ts +0 -0
- package/{dist → typings}/record/mutation.d.ts +5 -8
- package/typings/record/observer.d.ts +7 -0
- package/{dist → typings}/record/observers/canvas/2d.d.ts +0 -0
- package/{dist → typings}/record/observers/canvas/canvas-manager.d.ts +0 -0
- package/{dist → typings}/record/observers/canvas/canvas.d.ts +0 -0
- package/{dist → typings}/record/observers/canvas/serialize-args.d.ts +1 -1
- package/{dist → typings}/record/observers/canvas/webgl.d.ts +0 -0
- package/typings/record/observers/canvas/webgl2.d.ts +2 -0
- package/typings/record/shadow-dom-manager.d.ts +21 -0
- package/{dist → typings}/replay/canvas/2d.d.ts +0 -0
- package/{dist → typings}/replay/canvas/index.d.ts +0 -0
- package/{dist → typings}/replay/canvas/webgl.d.ts +0 -0
- package/{dist → typings}/replay/index.d.ts +1 -0
- package/{dist → typings}/replay/machine.d.ts +0 -0
- package/{dist → typings}/replay/smoothscroll.d.ts +0 -0
- package/{dist → typings}/replay/styles/inject-style.d.ts +0 -0
- package/{dist → typings}/replay/timer.d.ts +0 -0
- package/{dist → typings}/replay/virtual-styles.d.ts +1 -1
- package/{dist → typings}/rrdom/index.d.ts +0 -0
- package/{dist → typings}/rrdom/tree-node.d.ts +0 -0
- package/{dist → typings}/types.d.ts +7 -8
- package/{dist → typings}/utils.d.ts +3 -4
- package/CHANGELOG.md +0 -26
- package/README.md +0 -124
- package/README.zh_CN.md +0 -122
- package/dist/entries/all.d.ts +0 -4
- package/dist/index.css +0 -82
- package/dist/index.css.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.LICENSE.txt +0 -14
- package/dist/index.js.map +0 -1
- package/dist/plugins/entries/all.d.ts +0 -4
- package/dist/plugins/entries/record-pack.d.ts +0 -2
- package/dist/plugins/entries/replay-unpack.d.ts +0 -2
- package/dist/plugins/index.d.ts +0 -9
- package/dist/plugins/packer/base.d.ts +0 -7
- package/dist/plugins/packer/index.d.ts +0 -2
- package/dist/plugins/packer/pack.d.ts +0 -2
- package/dist/plugins/packer/unpack.d.ts +0 -2
- package/dist/plugins/plugins/console/record/error-stack-parser.d.ts +0 -37
- package/dist/plugins/plugins/console/record/index.d.ts +0 -41
- package/dist/plugins/plugins/console/record/stringify.d.ts +0 -2
- package/dist/plugins/plugins/console/replay/index.d.ts +0 -9
- package/dist/plugins/plugins/sequential-id/record/index.d.ts +0 -6
- package/dist/plugins/plugins/sequential-id/replay/index.d.ts +0 -7
- package/dist/plugins/record/iframe-manager.d.ts +0 -13
- package/dist/plugins/record/index.d.ts +0 -9
- package/dist/plugins/record/mutation.d.ts +0 -45
- package/dist/plugins/record/observer.d.ts +0 -11
- package/dist/plugins/record/observers/canvas/2d.d.ts +0 -2
- package/dist/plugins/record/observers/canvas/canvas-manager.d.ts +0 -32
- package/dist/plugins/record/observers/canvas/canvas.d.ts +0 -2
- package/dist/plugins/record/observers/canvas/serialize-args.d.ts +0 -6
- package/dist/plugins/record/observers/canvas/webgl.d.ts +0 -2
- package/dist/plugins/record/shadow-dom-manager.d.ts +0 -34
- package/dist/plugins/replay/canvas/2d.d.ts +0 -9
- package/dist/plugins/replay/canvas/index.d.ts +0 -9
- package/dist/plugins/replay/canvas/webgl.d.ts +0 -11
- package/dist/plugins/replay/index.d.ts +0 -82
- package/dist/plugins/replay/machine.d.ts +0 -85
- package/dist/plugins/replay/smoothscroll.d.ts +0 -1
- package/dist/plugins/replay/styles/inject-style.d.ts +0 -2
- package/dist/plugins/replay/timer.d.ts +0 -19
- package/dist/plugins/replay/virtual-styles.d.ts +0 -43
- package/dist/plugins/rrdom/index.d.ts +0 -1
- package/dist/plugins/rrdom/tree-node.d.ts +0 -20
- package/dist/plugins/snapshot/css.d.ts +0 -92
- package/dist/plugins/snapshot/index.d.ts +0 -5
- package/dist/plugins/snapshot/rebuild.d.ts +0 -19
- package/dist/plugins/snapshot/snapshot.d.ts +0 -49
- package/dist/plugins/snapshot/types.d.ts +0 -99
- package/dist/plugins/snapshot/utils.d.ts +0 -11
- package/dist/plugins/types.d.ts +0 -509
- package/dist/plugins/utils.d.ts +0 -71
- package/dist/record/observer.d.ts +0 -11
- package/dist/record/shadow-dom-manager.d.ts +0 -34
- package/dist/snapshot/css.d.ts +0 -92
- package/dist/snapshot/index.d.ts +0 -5
- package/dist/snapshot/rebuild.d.ts +0 -19
- package/dist/snapshot/snapshot.d.ts +0 -49
- package/dist/snapshot/types.d.ts +0 -99
- package/dist/snapshot/utils.d.ts +0 -11
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { __values, __spreadArray, __read } from '../../../../ext/tslib/tslib.es6.js';
|
|
2
|
+
import { PLUGIN_NAME } from '../record/index.js';
|
|
3
|
+
import { EventType, IncrementalSource } from '../../../types.js';
|
|
4
|
+
|
|
5
|
+
var ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';
|
|
6
|
+
var defaultLogConfig = {
|
|
7
|
+
level: [
|
|
8
|
+
'assert',
|
|
9
|
+
'clear',
|
|
10
|
+
'count',
|
|
11
|
+
'countReset',
|
|
12
|
+
'debug',
|
|
13
|
+
'dir',
|
|
14
|
+
'dirxml',
|
|
15
|
+
'error',
|
|
16
|
+
'group',
|
|
17
|
+
'groupCollapsed',
|
|
18
|
+
'groupEnd',
|
|
19
|
+
'info',
|
|
20
|
+
'log',
|
|
21
|
+
'table',
|
|
22
|
+
'time',
|
|
23
|
+
'timeEnd',
|
|
24
|
+
'timeLog',
|
|
25
|
+
'trace',
|
|
26
|
+
'warn',
|
|
27
|
+
],
|
|
28
|
+
replayLogger: undefined,
|
|
29
|
+
};
|
|
30
|
+
var LogReplayPlugin = (function () {
|
|
31
|
+
function LogReplayPlugin(config) {
|
|
32
|
+
this.config = Object.assign(defaultLogConfig, config);
|
|
33
|
+
}
|
|
34
|
+
LogReplayPlugin.prototype.getConsoleLogger = function () {
|
|
35
|
+
var e_1, _a;
|
|
36
|
+
var _this = this;
|
|
37
|
+
var replayLogger = {};
|
|
38
|
+
var _loop_1 = function (level) {
|
|
39
|
+
if (level === 'trace') {
|
|
40
|
+
replayLogger[level] = function (data) {
|
|
41
|
+
var logger = console.log[ORIGINAL_ATTRIBUTE_NAME]
|
|
42
|
+
? console.log[ORIGINAL_ATTRIBUTE_NAME]
|
|
43
|
+
: console.log;
|
|
44
|
+
logger.apply(void 0, __spreadArray(__spreadArray([], __read(data.payload.map(function (s) { return JSON.parse(s); })), false), [_this.formatMessage(data)], false));
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
replayLogger[level] = function (data) {
|
|
49
|
+
var logger = console[level][ORIGINAL_ATTRIBUTE_NAME]
|
|
50
|
+
? console[level][ORIGINAL_ATTRIBUTE_NAME]
|
|
51
|
+
: console[level];
|
|
52
|
+
logger.apply(void 0, __spreadArray(__spreadArray([], __read(data.payload.map(function (s) { return JSON.parse(s); })), false), [_this.formatMessage(data)], false));
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
try {
|
|
57
|
+
for (var _b = __values(this.config.level), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
58
|
+
var level = _c.value;
|
|
59
|
+
_loop_1(level);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
63
|
+
finally {
|
|
64
|
+
try {
|
|
65
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
66
|
+
}
|
|
67
|
+
finally { if (e_1) throw e_1.error; }
|
|
68
|
+
}
|
|
69
|
+
return replayLogger;
|
|
70
|
+
};
|
|
71
|
+
LogReplayPlugin.prototype.formatMessage = function (data) {
|
|
72
|
+
if (data.trace.length === 0) {
|
|
73
|
+
return '';
|
|
74
|
+
}
|
|
75
|
+
var stackPrefix = '\n\tat ';
|
|
76
|
+
var result = stackPrefix;
|
|
77
|
+
result += data.trace.join(stackPrefix);
|
|
78
|
+
return result;
|
|
79
|
+
};
|
|
80
|
+
return LogReplayPlugin;
|
|
81
|
+
}());
|
|
82
|
+
var getReplayConsolePlugin = function (options) {
|
|
83
|
+
var replayLogger = (options === null || options === void 0 ? void 0 : options.replayLogger) || new LogReplayPlugin(options).getConsoleLogger();
|
|
84
|
+
return {
|
|
85
|
+
handler: function (event, _isSync, context) {
|
|
86
|
+
var logData = null;
|
|
87
|
+
if (event.type === EventType.IncrementalSnapshot &&
|
|
88
|
+
event.data.source === IncrementalSource.Log) {
|
|
89
|
+
logData = event.data;
|
|
90
|
+
}
|
|
91
|
+
else if (event.type === EventType.Plugin &&
|
|
92
|
+
event.data.plugin === PLUGIN_NAME) {
|
|
93
|
+
logData = event.data.payload;
|
|
94
|
+
}
|
|
95
|
+
if (logData) {
|
|
96
|
+
try {
|
|
97
|
+
if (typeof replayLogger[logData.level] === 'function') {
|
|
98
|
+
replayLogger[logData.level](logData);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
if (context.replayer.config.showWarning) {
|
|
103
|
+
console.warn(error);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export { getReplayConsolePlugin };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var defaultOptions = {
|
|
2
|
+
key: '_sid',
|
|
3
|
+
};
|
|
4
|
+
var PLUGIN_NAME = 'rrweb/sequential-id@1';
|
|
5
|
+
var getRecordSequentialIdPlugin = function (options) {
|
|
6
|
+
var _options = options
|
|
7
|
+
? Object.assign({}, defaultOptions, options)
|
|
8
|
+
: defaultOptions;
|
|
9
|
+
var id = 0;
|
|
10
|
+
return {
|
|
11
|
+
name: PLUGIN_NAME,
|
|
12
|
+
eventProcessor: function (event) {
|
|
13
|
+
var _a;
|
|
14
|
+
Object.assign(event, (_a = {},
|
|
15
|
+
_a[_options.key] = ++id,
|
|
16
|
+
_a));
|
|
17
|
+
return event;
|
|
18
|
+
},
|
|
19
|
+
options: _options,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { PLUGIN_NAME, getRecordSequentialIdPlugin };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var defaultOptions = {
|
|
2
|
+
key: '_sid',
|
|
3
|
+
warnOnMissingId: true,
|
|
4
|
+
};
|
|
5
|
+
var getReplaySequentialIdPlugin = function (options) {
|
|
6
|
+
var _a = options
|
|
7
|
+
? Object.assign({}, defaultOptions, options)
|
|
8
|
+
: defaultOptions, key = _a.key, warnOnMissingId = _a.warnOnMissingId;
|
|
9
|
+
var currentId = 1;
|
|
10
|
+
return {
|
|
11
|
+
handler: function (event) {
|
|
12
|
+
if (key in event) {
|
|
13
|
+
var id = event[key];
|
|
14
|
+
if (id !== currentId) {
|
|
15
|
+
console.error("[sequential-id-plugin]: expect to get an id with value \"".concat(currentId, "\", but got \"").concat(id, "\""));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
currentId++;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else if (warnOnMissingId) {
|
|
22
|
+
console.warn("[sequential-id-plugin]: failed to get id in key: \"".concat(key, "\""));
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { getReplaySequentialIdPlugin };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var IframeManager = (function () {
|
|
2
|
+
function IframeManager(options) {
|
|
3
|
+
this.iframes = new WeakMap();
|
|
4
|
+
this.mutationCb = options.mutationCb;
|
|
5
|
+
}
|
|
6
|
+
IframeManager.prototype.addIframe = function (iframeEl) {
|
|
7
|
+
this.iframes.set(iframeEl, true);
|
|
8
|
+
};
|
|
9
|
+
IframeManager.prototype.addLoadListener = function (cb) {
|
|
10
|
+
this.loadListener = cb;
|
|
11
|
+
};
|
|
12
|
+
IframeManager.prototype.attachIframe = function (iframeEl, childSn) {
|
|
13
|
+
var _a;
|
|
14
|
+
this.mutationCb({
|
|
15
|
+
adds: [
|
|
16
|
+
{
|
|
17
|
+
parentId: iframeEl.__sn.id,
|
|
18
|
+
nextId: null,
|
|
19
|
+
node: childSn,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
removes: [],
|
|
23
|
+
texts: [],
|
|
24
|
+
attributes: [],
|
|
25
|
+
isAttachIframe: true,
|
|
26
|
+
});
|
|
27
|
+
(_a = this.loadListener) === null || _a === void 0 ? void 0 : _a.call(this, iframeEl);
|
|
28
|
+
};
|
|
29
|
+
return IframeManager;
|
|
30
|
+
}());
|
|
31
|
+
|
|
32
|
+
export { IframeManager };
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { __assign, __read, __values } from '../../ext/tslib/tslib.es6.js';
|
|
2
|
+
import { snapshot } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
|
|
3
|
+
import { initObservers, mutationBuffers } from './observer.js';
|
|
4
|
+
import { polyfill, on, createMirror, getWindowWidth, getWindowHeight, isIframeINode, hasShadowRoot } from '../utils.js';
|
|
5
|
+
import { EventType, IncrementalSource } from '../types.js';
|
|
6
|
+
import { IframeManager } from './iframe-manager.js';
|
|
7
|
+
import { ShadowDomManager } from './shadow-dom-manager.js';
|
|
8
|
+
import { CanvasManager } from './observers/canvas/canvas-manager.js';
|
|
9
|
+
|
|
10
|
+
function wrapEvent(e) {
|
|
11
|
+
return __assign(__assign({}, e), { timestamp: Date.now() });
|
|
12
|
+
}
|
|
13
|
+
var wrappedEmit;
|
|
14
|
+
var takeFullSnapshot;
|
|
15
|
+
var mirror = createMirror();
|
|
16
|
+
function record(options) {
|
|
17
|
+
if (options === void 0) { options = {}; }
|
|
18
|
+
var emit = options.emit, checkoutEveryNms = options.checkoutEveryNms, checkoutEveryNth = options.checkoutEveryNth, _a = options.blockClass, blockClass = _a === void 0 ? 'highlight-block' : _a, _b = options.blockSelector, blockSelector = _b === void 0 ? null : _b, _c = options.ignoreClass, ignoreClass = _c === void 0 ? 'highlight-ignore' : _c, _d = options.maskTextClass, maskTextClass = _d === void 0 ? 'highlight-mask' : _d, _e = options.maskTextSelector, maskTextSelector = _e === void 0 ? null : _e, _f = options.inlineStylesheet, inlineStylesheet = _f === void 0 ? true : _f, maskAllInputs = options.maskAllInputs, _maskInputOptions = options.maskInputOptions, _slimDOMOptions = options.slimDOMOptions, maskInputFn = options.maskInputFn, maskTextFn = options.maskTextFn, hooks = options.hooks, packFn = options.packFn, _g = options.sampling, sampling = _g === void 0 ? {} : _g, mousemoveWait = options.mousemoveWait, _h = options.recordCanvas, recordCanvas = _h === void 0 ? false : _h, _j = options.userTriggeredOnInput, userTriggeredOnInput = _j === void 0 ? false : _j, _k = options.collectFonts, collectFonts = _k === void 0 ? false : _k, _l = options.inlineImages, inlineImages = _l === void 0 ? false : _l, plugins = options.plugins, _m = options.keepIframeSrcFn, keepIframeSrcFn = _m === void 0 ? function () { return false; } : _m, _o = options.enableStrictPrivacy, enableStrictPrivacy = _o === void 0 ? false : _o;
|
|
19
|
+
if (!emit) {
|
|
20
|
+
throw new Error('emit function is required');
|
|
21
|
+
}
|
|
22
|
+
if (mousemoveWait !== undefined && sampling.mousemove === undefined) {
|
|
23
|
+
sampling.mousemove = mousemoveWait;
|
|
24
|
+
}
|
|
25
|
+
var 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
|
+
var 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
|
+
var lastFullSnapshotEvent;
|
|
65
|
+
var incrementalSnapshotCount = 0;
|
|
66
|
+
var eventProcessor = function (e) {
|
|
67
|
+
var e_1, _a;
|
|
68
|
+
try {
|
|
69
|
+
for (var _b = __values(plugins || []), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
70
|
+
var plugin = _c.value;
|
|
71
|
+
if (plugin.eventProcessor) {
|
|
72
|
+
e = plugin.eventProcessor(e);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
77
|
+
finally {
|
|
78
|
+
try {
|
|
79
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
80
|
+
}
|
|
81
|
+
finally { if (e_1) throw e_1.error; }
|
|
82
|
+
}
|
|
83
|
+
if (packFn) {
|
|
84
|
+
e = packFn(e);
|
|
85
|
+
}
|
|
86
|
+
return e;
|
|
87
|
+
};
|
|
88
|
+
wrappedEmit = function (e, isCheckout) {
|
|
89
|
+
var _a;
|
|
90
|
+
if (((_a = mutationBuffers[0]) === null || _a === void 0 ? void 0 : _a.isFrozen()) &&
|
|
91
|
+
e.type !== EventType.FullSnapshot &&
|
|
92
|
+
!(e.type === EventType.IncrementalSnapshot &&
|
|
93
|
+
e.data.source === IncrementalSource.Mutation)) {
|
|
94
|
+
mutationBuffers.forEach(function (buf) { return buf.unfreeze(); });
|
|
95
|
+
}
|
|
96
|
+
emit(eventProcessor(e), isCheckout);
|
|
97
|
+
if (e.type === EventType.FullSnapshot) {
|
|
98
|
+
lastFullSnapshotEvent = e;
|
|
99
|
+
incrementalSnapshotCount = 0;
|
|
100
|
+
}
|
|
101
|
+
else if (e.type === EventType.IncrementalSnapshot) {
|
|
102
|
+
if (e.data.source === IncrementalSource.Mutation &&
|
|
103
|
+
e.data.isAttachIframe) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
incrementalSnapshotCount++;
|
|
107
|
+
var exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
|
|
108
|
+
var exceedTime = checkoutEveryNms &&
|
|
109
|
+
e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
|
|
110
|
+
if (exceedCount || exceedTime) {
|
|
111
|
+
takeFullSnapshot(true);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
var wrappedMutationEmit = function (m) {
|
|
116
|
+
wrappedEmit(wrapEvent({
|
|
117
|
+
type: EventType.IncrementalSnapshot,
|
|
118
|
+
data: __assign({ source: IncrementalSource.Mutation }, m),
|
|
119
|
+
}));
|
|
120
|
+
};
|
|
121
|
+
var wrappedScrollEmit = function (p) {
|
|
122
|
+
return wrappedEmit(wrapEvent({
|
|
123
|
+
type: EventType.IncrementalSnapshot,
|
|
124
|
+
data: __assign({ source: IncrementalSource.Scroll }, p),
|
|
125
|
+
}));
|
|
126
|
+
};
|
|
127
|
+
var wrappedCanvasMutationEmit = function (p) {
|
|
128
|
+
return wrappedEmit(wrapEvent({
|
|
129
|
+
type: EventType.IncrementalSnapshot,
|
|
130
|
+
data: __assign({ source: IncrementalSource.CanvasMutation }, p),
|
|
131
|
+
}));
|
|
132
|
+
};
|
|
133
|
+
var iframeManager = new IframeManager({
|
|
134
|
+
mutationCb: wrappedMutationEmit,
|
|
135
|
+
});
|
|
136
|
+
var canvasManager = new CanvasManager({
|
|
137
|
+
recordCanvas: recordCanvas,
|
|
138
|
+
mutationCb: wrappedCanvasMutationEmit,
|
|
139
|
+
win: window,
|
|
140
|
+
blockClass: blockClass,
|
|
141
|
+
mirror: mirror,
|
|
142
|
+
});
|
|
143
|
+
var shadowDomManager = new ShadowDomManager({
|
|
144
|
+
mutationCb: wrappedMutationEmit,
|
|
145
|
+
scrollCb: wrappedScrollEmit,
|
|
146
|
+
bypassOptions: {
|
|
147
|
+
blockClass: blockClass,
|
|
148
|
+
blockSelector: blockSelector,
|
|
149
|
+
maskTextClass: maskTextClass,
|
|
150
|
+
maskTextSelector: maskTextSelector,
|
|
151
|
+
inlineStylesheet: inlineStylesheet,
|
|
152
|
+
maskInputOptions: maskInputOptions,
|
|
153
|
+
maskTextFn: maskTextFn,
|
|
154
|
+
maskInputFn: maskInputFn,
|
|
155
|
+
recordCanvas: recordCanvas,
|
|
156
|
+
inlineImages: inlineImages,
|
|
157
|
+
sampling: sampling,
|
|
158
|
+
slimDOMOptions: slimDOMOptions,
|
|
159
|
+
iframeManager: iframeManager,
|
|
160
|
+
canvasManager: canvasManager,
|
|
161
|
+
enableStrictPrivacy: enableStrictPrivacy
|
|
162
|
+
},
|
|
163
|
+
mirror: mirror,
|
|
164
|
+
});
|
|
165
|
+
takeFullSnapshot = function (isCheckout) {
|
|
166
|
+
var _a, _b, _c, _d;
|
|
167
|
+
if (isCheckout === void 0) { isCheckout = false; }
|
|
168
|
+
wrappedEmit(wrapEvent({
|
|
169
|
+
type: EventType.Meta,
|
|
170
|
+
data: {
|
|
171
|
+
href: window.location.href,
|
|
172
|
+
width: getWindowWidth(),
|
|
173
|
+
height: getWindowHeight(),
|
|
174
|
+
},
|
|
175
|
+
}), isCheckout);
|
|
176
|
+
mutationBuffers.forEach(function (buf) { return buf.lock(); });
|
|
177
|
+
var _e = __read(snapshot(document, {
|
|
178
|
+
blockClass: blockClass,
|
|
179
|
+
blockSelector: blockSelector,
|
|
180
|
+
maskTextClass: maskTextClass,
|
|
181
|
+
maskTextSelector: maskTextSelector,
|
|
182
|
+
inlineStylesheet: inlineStylesheet,
|
|
183
|
+
maskAllInputs: maskInputOptions,
|
|
184
|
+
maskTextFn: maskTextFn,
|
|
185
|
+
slimDOM: slimDOMOptions,
|
|
186
|
+
recordCanvas: recordCanvas,
|
|
187
|
+
inlineImages: inlineImages,
|
|
188
|
+
enableStrictPrivacy: enableStrictPrivacy,
|
|
189
|
+
onSerialize: function (n) {
|
|
190
|
+
if (isIframeINode(n)) {
|
|
191
|
+
iframeManager.addIframe(n);
|
|
192
|
+
}
|
|
193
|
+
if (hasShadowRoot(n)) {
|
|
194
|
+
shadowDomManager.addShadowRoot(n.shadowRoot, document);
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
onIframeLoad: function (iframe, childSn) {
|
|
198
|
+
iframeManager.attachIframe(iframe, childSn);
|
|
199
|
+
shadowDomManager.observeAttachShadow(iframe);
|
|
200
|
+
},
|
|
201
|
+
keepIframeSrcFn: keepIframeSrcFn,
|
|
202
|
+
}), 2), node = _e[0], idNodeMap = _e[1];
|
|
203
|
+
if (!node) {
|
|
204
|
+
return console.warn('Failed to snapshot the document');
|
|
205
|
+
}
|
|
206
|
+
mirror.map = idNodeMap;
|
|
207
|
+
wrappedEmit(wrapEvent({
|
|
208
|
+
type: EventType.FullSnapshot,
|
|
209
|
+
data: {
|
|
210
|
+
node: node,
|
|
211
|
+
initialOffset: {
|
|
212
|
+
left: window.pageXOffset !== undefined
|
|
213
|
+
? window.pageXOffset
|
|
214
|
+
: (document === null || document === void 0 ? void 0 : document.documentElement.scrollLeft) ||
|
|
215
|
+
((_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) ||
|
|
216
|
+
(document === null || document === void 0 ? void 0 : document.body.scrollLeft) ||
|
|
217
|
+
0,
|
|
218
|
+
top: window.pageYOffset !== undefined
|
|
219
|
+
? window.pageYOffset
|
|
220
|
+
: (document === null || document === void 0 ? void 0 : document.documentElement.scrollTop) ||
|
|
221
|
+
((_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) ||
|
|
222
|
+
(document === null || document === void 0 ? void 0 : document.body.scrollTop) ||
|
|
223
|
+
0,
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
}));
|
|
227
|
+
mutationBuffers.forEach(function (buf) { return buf.unlock(); });
|
|
228
|
+
};
|
|
229
|
+
try {
|
|
230
|
+
var handlers_1 = [];
|
|
231
|
+
handlers_1.push(on('DOMContentLoaded', function () {
|
|
232
|
+
wrappedEmit(wrapEvent({
|
|
233
|
+
type: EventType.DomContentLoaded,
|
|
234
|
+
data: {},
|
|
235
|
+
}));
|
|
236
|
+
}));
|
|
237
|
+
var observe_1 = function (doc) {
|
|
238
|
+
var _a;
|
|
239
|
+
return initObservers({
|
|
240
|
+
mutationCb: wrappedMutationEmit,
|
|
241
|
+
mousemoveCb: function (positions, source) {
|
|
242
|
+
return wrappedEmit(wrapEvent({
|
|
243
|
+
type: EventType.IncrementalSnapshot,
|
|
244
|
+
data: {
|
|
245
|
+
source: source,
|
|
246
|
+
positions: positions,
|
|
247
|
+
},
|
|
248
|
+
}));
|
|
249
|
+
},
|
|
250
|
+
mouseInteractionCb: function (d) {
|
|
251
|
+
return wrappedEmit(wrapEvent({
|
|
252
|
+
type: EventType.IncrementalSnapshot,
|
|
253
|
+
data: __assign({ source: IncrementalSource.MouseInteraction }, d),
|
|
254
|
+
}));
|
|
255
|
+
},
|
|
256
|
+
scrollCb: wrappedScrollEmit,
|
|
257
|
+
viewportResizeCb: function (d) {
|
|
258
|
+
return wrappedEmit(wrapEvent({
|
|
259
|
+
type: EventType.IncrementalSnapshot,
|
|
260
|
+
data: __assign({ source: IncrementalSource.ViewportResize }, d),
|
|
261
|
+
}));
|
|
262
|
+
},
|
|
263
|
+
inputCb: function (v) {
|
|
264
|
+
return wrappedEmit(wrapEvent({
|
|
265
|
+
type: EventType.IncrementalSnapshot,
|
|
266
|
+
data: __assign({ source: IncrementalSource.Input }, v),
|
|
267
|
+
}));
|
|
268
|
+
},
|
|
269
|
+
mediaInteractionCb: function (p) {
|
|
270
|
+
return wrappedEmit(wrapEvent({
|
|
271
|
+
type: EventType.IncrementalSnapshot,
|
|
272
|
+
data: __assign({ source: IncrementalSource.MediaInteraction }, p),
|
|
273
|
+
}));
|
|
274
|
+
},
|
|
275
|
+
styleSheetRuleCb: function (r) {
|
|
276
|
+
return wrappedEmit(wrapEvent({
|
|
277
|
+
type: EventType.IncrementalSnapshot,
|
|
278
|
+
data: __assign({ source: IncrementalSource.StyleSheetRule }, r),
|
|
279
|
+
}));
|
|
280
|
+
},
|
|
281
|
+
styleDeclarationCb: function (r) {
|
|
282
|
+
return wrappedEmit(wrapEvent({
|
|
283
|
+
type: EventType.IncrementalSnapshot,
|
|
284
|
+
data: __assign({ source: IncrementalSource.StyleDeclaration }, r),
|
|
285
|
+
}));
|
|
286
|
+
},
|
|
287
|
+
canvasMutationCb: wrappedCanvasMutationEmit,
|
|
288
|
+
fontCb: function (p) {
|
|
289
|
+
return wrappedEmit(wrapEvent({
|
|
290
|
+
type: EventType.IncrementalSnapshot,
|
|
291
|
+
data: __assign({ source: IncrementalSource.Font }, p),
|
|
292
|
+
}));
|
|
293
|
+
},
|
|
294
|
+
blockClass: blockClass,
|
|
295
|
+
ignoreClass: ignoreClass,
|
|
296
|
+
maskTextClass: maskTextClass,
|
|
297
|
+
maskTextSelector: maskTextSelector,
|
|
298
|
+
maskInputOptions: maskInputOptions,
|
|
299
|
+
inlineStylesheet: inlineStylesheet,
|
|
300
|
+
sampling: sampling,
|
|
301
|
+
recordCanvas: recordCanvas,
|
|
302
|
+
inlineImages: inlineImages,
|
|
303
|
+
userTriggeredOnInput: userTriggeredOnInput,
|
|
304
|
+
collectFonts: collectFonts,
|
|
305
|
+
doc: doc,
|
|
306
|
+
maskInputFn: maskInputFn,
|
|
307
|
+
maskTextFn: maskTextFn,
|
|
308
|
+
blockSelector: blockSelector,
|
|
309
|
+
slimDOMOptions: slimDOMOptions,
|
|
310
|
+
mirror: mirror,
|
|
311
|
+
iframeManager: iframeManager,
|
|
312
|
+
shadowDomManager: shadowDomManager,
|
|
313
|
+
canvasManager: canvasManager,
|
|
314
|
+
enableStrictPrivacy: enableStrictPrivacy,
|
|
315
|
+
plugins: ((_a = plugins === null || plugins === void 0 ? void 0 : plugins.filter(function (p) { return p.observer; })) === null || _a === void 0 ? void 0 : _a.map(function (p) { return ({
|
|
316
|
+
observer: p.observer,
|
|
317
|
+
options: p.options,
|
|
318
|
+
callback: function (payload) {
|
|
319
|
+
return wrappedEmit(wrapEvent({
|
|
320
|
+
type: EventType.Plugin,
|
|
321
|
+
data: {
|
|
322
|
+
plugin: p.name,
|
|
323
|
+
payload: payload,
|
|
324
|
+
},
|
|
325
|
+
}));
|
|
326
|
+
},
|
|
327
|
+
}); })) || [],
|
|
328
|
+
}, hooks);
|
|
329
|
+
};
|
|
330
|
+
iframeManager.addLoadListener(function (iframeEl) {
|
|
331
|
+
handlers_1.push(observe_1(iframeEl.contentDocument));
|
|
332
|
+
});
|
|
333
|
+
var init_1 = function () {
|
|
334
|
+
takeFullSnapshot();
|
|
335
|
+
handlers_1.push(observe_1(document));
|
|
336
|
+
};
|
|
337
|
+
if (document.readyState === 'interactive' ||
|
|
338
|
+
document.readyState === 'complete') {
|
|
339
|
+
init_1();
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
handlers_1.push(on('load', function () {
|
|
343
|
+
wrappedEmit(wrapEvent({
|
|
344
|
+
type: EventType.Load,
|
|
345
|
+
data: {},
|
|
346
|
+
}));
|
|
347
|
+
init_1();
|
|
348
|
+
}, window));
|
|
349
|
+
}
|
|
350
|
+
return function () {
|
|
351
|
+
handlers_1.forEach(function (h) { return h(); });
|
|
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
|
+
};
|
|
379
|
+
record.mirror = mirror;
|
|
380
|
+
|
|
381
|
+
export default record;
|