@highlight-run/rrweb 1.2.1 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugins/console-record.js +454 -0
- package/dist/plugins/console-record.min.js +12 -15
- package/dist/plugins/console-record.min.js.map +1 -1
- package/dist/plugins/console-replay.js +164 -0
- package/dist/plugins/console-replay.min.js +5 -0
- package/dist/plugins/console-replay.min.js.map +1 -0
- package/dist/plugins/sequential-id-record.js +30 -0
- package/dist/plugins/sequential-id-record.min.js +2 -0
- package/dist/plugins/sequential-id-record.min.js.map +1 -0
- package/dist/plugins/sequential-id-replay.js +33 -0
- package/dist/plugins/sequential-id-replay.min.js +2 -0
- package/dist/plugins/sequential-id-replay.min.js.map +1 -0
- package/dist/record/rrweb-record-pack.js +664 -0
- package/dist/record/rrweb-record-pack.min.js +4 -0
- package/dist/record/rrweb-record-pack.min.js.map +1 -0
- package/dist/record/rrweb-record.js +3202 -0
- package/dist/record/rrweb-record.min.js +5 -0
- package/dist/record/rrweb-record.min.js.map +1 -0
- package/dist/replay/rrweb-replay-unpack.js +4926 -0
- package/dist/replay/rrweb-replay-unpack.min.js +18 -0
- package/dist/replay/rrweb-replay-unpack.min.js.map +1 -0
- package/dist/replay/rrweb-replay.js +4518 -0
- package/dist/replay/rrweb-replay.min.js +18 -0
- package/dist/replay/rrweb-replay.min.js.map +1 -0
- package/dist/rrweb-all.js +8889 -0
- package/dist/rrweb-all.min.js +29 -0
- package/dist/rrweb-all.min.js.map +1 -0
- package/dist/rrweb.js +7558 -0
- package/dist/rrweb.min.js +6 -17
- package/dist/rrweb.min.js.map +1 -1
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +31 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
- package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
- package/es/rrweb/_virtual/image-bitmap-data-url-worker.js +6 -0
- package/es/rrweb/ext/@xstate/fsm/es/index.js +17 -0
- package/es/rrweb/ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js +49 -0
- package/es/rrweb/ext/fflate/esm/browser.js +777 -0
- package/es/rrweb/ext/mitt/dist/mitt.es.js +63 -0
- package/es/rrweb/ext/tslib/tslib.es6.js +38 -0
- package/es/rrweb/packages/rrdom/es/virtual-dom.js +1099 -0
- package/es/rrweb/packages/rrweb/src/entries/all.js +13 -0
- package/es/rrweb/packages/rrweb/src/index.js +14 -0
- package/es/rrweb/packages/rrweb/src/packer/base.js +3 -0
- package/es/rrweb/packages/rrweb/src/packer/pack.js +9 -0
- package/es/rrweb/packages/rrweb/src/packer/unpack.js +29 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js +178 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/record/index.js +115 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js +128 -0
- package/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js +94 -0
- package/es/rrweb/packages/rrweb/src/plugins/sequential-id/record/index.js +22 -0
- package/es/rrweb/packages/rrweb/src/plugins/sequential-id/replay/index.js +28 -0
- package/es/rrweb/packages/rrweb/src/record/iframe-manager.js +31 -0
- package/es/rrweb/packages/rrweb/src/record/index.js +356 -0
- package/es/rrweb/packages/rrweb/src/record/mutation.js +491 -0
- package/es/rrweb/packages/rrweb/src/record/observer.js +590 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +49 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +172 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +25 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js +123 -0
- package/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +59 -0
- package/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js +43 -0
- package/es/rrweb/packages/rrweb/src/record/stylesheet-manager.js +31 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/2d.js +29 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/deserialize-args.js +67 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/index.js +43 -0
- package/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js +62 -0
- package/es/rrweb/packages/rrweb/src/replay/index.js +1555 -0
- package/es/rrweb/packages/rrweb/src/replay/machine.js +281 -0
- package/es/rrweb/packages/rrweb/src/replay/smoothscroll.js +219 -0
- package/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js +8 -0
- package/es/rrweb/packages/rrweb/src/replay/timer.js +92 -0
- package/es/rrweb/packages/rrweb/src/types.js +75 -0
- package/es/rrweb/packages/rrweb/src/utils.js +315 -0
- package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +1821 -0
- package/lib/plugins/console-record.js +492 -0
- package/lib/plugins/console-replay.js +218 -0
- package/lib/plugins/sequential-id-record.js +27 -0
- package/lib/plugins/sequential-id-replay.js +32 -0
- package/lib/record/rrweb-record-pack.js +787 -0
- package/lib/record/rrweb-record.js +3363 -0
- package/lib/replay/rrweb-replay-unpack.js +5075 -0
- package/lib/replay/rrweb-replay.js +4665 -0
- package/lib/rrweb-all.js +9181 -0
- package/lib/rrweb.js +7814 -0
- package/package.json +41 -42
- package/typings/entries/all.d.ts +6 -0
- package/{dist → typings}/entries/record-pack.d.ts +0 -0
- package/{dist → typings}/entries/replay-unpack.d.ts +0 -0
- package/{dist → typings}/index.d.ts +1 -2
- package/{dist → typings}/packer/base.d.ts +1 -1
- package/{dist → typings}/packer/index.d.ts +0 -0
- package/{dist → typings}/packer/pack.d.ts +0 -0
- package/{dist → typings}/packer/unpack.d.ts +0 -0
- package/{dist → typings}/plugins/console/record/error-stack-parser.d.ts +0 -0
- package/{dist → typings}/plugins/console/record/index.d.ts +4 -3
- package/{dist → typings}/plugins/console/record/stringify.d.ts +1 -1
- package/{dist → typings}/plugins/console/replay/index.d.ts +2 -2
- package/{dist → typings}/plugins/sequential-id/record/index.d.ts +1 -1
- package/{dist → typings}/plugins/sequential-id/replay/index.d.ts +1 -1
- package/{dist → typings}/record/iframe-manager.d.ts +3 -3
- package/{dist/plugins → typings}/record/index.d.ts +9 -9
- package/{dist → typings}/record/mutation.d.ts +6 -8
- package/typings/record/observer.d.ts +7 -0
- package/{dist/plugins → typings}/record/observers/canvas/2d.d.ts +3 -2
- package/{dist → typings}/record/observers/canvas/canvas-manager.d.ts +5 -2
- package/{dist/plugins → typings}/record/observers/canvas/canvas.d.ts +2 -2
- package/typings/record/observers/canvas/serialize-args.d.ts +6 -0
- package/{dist/plugins → typings}/record/observers/canvas/webgl.d.ts +3 -2
- package/typings/record/observers/canvas/webgl2.d.ts +2 -0
- package/typings/record/shadow-dom-manager.d.ts +22 -0
- package/typings/record/stylesheet-manager.d.ts +12 -0
- package/typings/record/workers/image-bitmap-data-url-worker.d.ts +5 -0
- package/{dist → typings}/replay/canvas/2d.d.ts +3 -3
- package/typings/replay/canvas/deserialize-args.d.ts +7 -0
- package/{dist/plugins → typings}/replay/canvas/index.d.ts +10 -9
- package/typings/replay/canvas/webgl.d.ts +9 -0
- package/{dist → typings}/replay/index.d.ts +7 -9
- package/{dist → typings}/replay/machine.d.ts +0 -0
- package/{dist → typings}/replay/smoothscroll.d.ts +0 -0
- package/{dist → typings}/replay/styles/inject-style.d.ts +0 -0
- package/{dist → typings}/replay/timer.d.ts +0 -0
- package/{dist → typings}/rrdom/index.d.ts +0 -0
- package/{dist → typings}/rrdom/tree-node.d.ts +0 -0
- package/{dist/plugins → typings}/types.d.ts +536 -509
- package/typings/utils.d.ts +43 -0
- package/CHANGELOG.md +0 -26
- package/README.md +0 -124
- package/README.zh_CN.md +0 -122
- package/dist/entries/all.d.ts +0 -4
- package/dist/index.css +0 -82
- package/dist/index.css.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.LICENSE.txt +0 -14
- package/dist/index.js.map +0 -1
- package/dist/plugins/entries/all.d.ts +0 -4
- package/dist/plugins/entries/record-pack.d.ts +0 -2
- package/dist/plugins/entries/replay-unpack.d.ts +0 -2
- package/dist/plugins/index.d.ts +0 -9
- package/dist/plugins/packer/base.d.ts +0 -7
- package/dist/plugins/packer/index.d.ts +0 -2
- package/dist/plugins/packer/pack.d.ts +0 -2
- package/dist/plugins/packer/unpack.d.ts +0 -2
- package/dist/plugins/plugins/console/record/error-stack-parser.d.ts +0 -37
- package/dist/plugins/plugins/console/record/index.d.ts +0 -41
- package/dist/plugins/plugins/console/record/stringify.d.ts +0 -2
- package/dist/plugins/plugins/console/replay/index.d.ts +0 -9
- package/dist/plugins/plugins/sequential-id/record/index.d.ts +0 -6
- package/dist/plugins/plugins/sequential-id/replay/index.d.ts +0 -7
- package/dist/plugins/record/iframe-manager.d.ts +0 -13
- package/dist/plugins/record/mutation.d.ts +0 -45
- package/dist/plugins/record/observer.d.ts +0 -11
- package/dist/plugins/record/observers/canvas/canvas-manager.d.ts +0 -32
- package/dist/plugins/record/observers/canvas/serialize-args.d.ts +0 -6
- package/dist/plugins/record/shadow-dom-manager.d.ts +0 -34
- package/dist/plugins/replay/canvas/2d.d.ts +0 -9
- package/dist/plugins/replay/canvas/webgl.d.ts +0 -11
- package/dist/plugins/replay/index.d.ts +0 -82
- package/dist/plugins/replay/machine.d.ts +0 -85
- package/dist/plugins/replay/smoothscroll.d.ts +0 -1
- package/dist/plugins/replay/styles/inject-style.d.ts +0 -2
- package/dist/plugins/replay/timer.d.ts +0 -19
- package/dist/plugins/replay/virtual-styles.d.ts +0 -43
- package/dist/plugins/rrdom/index.d.ts +0 -1
- package/dist/plugins/rrdom/tree-node.d.ts +0 -20
- package/dist/plugins/snapshot/css.d.ts +0 -92
- package/dist/plugins/snapshot/index.d.ts +0 -5
- package/dist/plugins/snapshot/rebuild.d.ts +0 -19
- package/dist/plugins/snapshot/snapshot.d.ts +0 -49
- package/dist/plugins/snapshot/types.d.ts +0 -99
- package/dist/plugins/snapshot/utils.d.ts +0 -11
- package/dist/plugins/utils.d.ts +0 -71
- package/dist/record/index.d.ts +0 -9
- package/dist/record/observer.d.ts +0 -11
- package/dist/record/observers/canvas/2d.d.ts +0 -2
- package/dist/record/observers/canvas/canvas.d.ts +0 -2
- package/dist/record/observers/canvas/serialize-args.d.ts +0 -6
- package/dist/record/observers/canvas/webgl.d.ts +0 -2
- package/dist/record/shadow-dom-manager.d.ts +0 -34
- package/dist/replay/canvas/index.d.ts +0 -9
- package/dist/replay/canvas/webgl.d.ts +0 -11
- package/dist/replay/virtual-styles.d.ts +0 -43
- package/dist/snapshot/css.d.ts +0 -92
- package/dist/snapshot/index.d.ts +0 -5
- package/dist/snapshot/rebuild.d.ts +0 -19
- package/dist/snapshot/snapshot.d.ts +0 -49
- package/dist/snapshot/types.d.ts +0 -99
- package/dist/snapshot/utils.d.ts +0 -11
- package/dist/types.d.ts +0 -509
- package/dist/utils.d.ts +0 -71
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { addCustomEvent, freezePage } from '../index.js';
|
|
2
|
+
export { pack } from '../packer/pack.js';
|
|
3
|
+
export { unpack } from '../packer/unpack.js';
|
|
4
|
+
export { PLUGIN_NAME, getRecordConsolePlugin } from '../plugins/console/record/index.js';
|
|
5
|
+
export { getReplayConsolePlugin } from '../plugins/console/replay/index.js';
|
|
6
|
+
export { getRecordSequentialIdPlugin } from '../plugins/sequential-id/record/index.js';
|
|
7
|
+
export { getReplaySequentialIdPlugin } from '../plugins/sequential-id/replay/index.js';
|
|
8
|
+
export { default as record } from '../record/index.js';
|
|
9
|
+
export { EventType, IncrementalSource, MouseInteractions, ReplayerEvents } from '../types.js';
|
|
10
|
+
export { Replayer } from '../replay/index.js';
|
|
11
|
+
import * as utils from '../utils.js';
|
|
12
|
+
export { utils };
|
|
13
|
+
export { _mirror as mirror } from '../utils.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import record from './record/index.js';
|
|
2
|
+
export { default as record } from './record/index.js';
|
|
3
|
+
import '../../rrweb-snapshot/es/rrweb-snapshot.js';
|
|
4
|
+
import '../../rrdom/es/virtual-dom.js';
|
|
5
|
+
export { EventType, IncrementalSource, MouseInteractions, ReplayerEvents } from './types.js';
|
|
6
|
+
import * as utils from './utils.js';
|
|
7
|
+
export { utils };
|
|
8
|
+
export { _mirror as mirror } from './utils.js';
|
|
9
|
+
import './../../../ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js';
|
|
10
|
+
|
|
11
|
+
const { addCustomEvent } = record;
|
|
12
|
+
const { freezePage } = record;
|
|
13
|
+
|
|
14
|
+
export { addCustomEvent, freezePage };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { strFromU8, zlibSync, strToU8 } from './../../../../ext/fflate/esm/browser.js';
|
|
2
|
+
import { MARK } from './base.js';
|
|
3
|
+
|
|
4
|
+
const pack = (event) => {
|
|
5
|
+
const _e = Object.assign(Object.assign({}, event), { v: MARK });
|
|
6
|
+
return strFromU8(zlibSync(strToU8(JSON.stringify(_e))), true);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { pack };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { strFromU8, unzlibSync, strToU8 } from './../../../../ext/fflate/esm/browser.js';
|
|
2
|
+
import { MARK } from './base.js';
|
|
3
|
+
|
|
4
|
+
const unpack = (raw) => {
|
|
5
|
+
if (typeof raw !== 'string') {
|
|
6
|
+
return raw;
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
const e = JSON.parse(raw);
|
|
10
|
+
if (e.timestamp) {
|
|
11
|
+
return e;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const e = JSON.parse(strFromU8(unzlibSync(strToU8(raw, true))));
|
|
18
|
+
if (e.v === MARK) {
|
|
19
|
+
return e;
|
|
20
|
+
}
|
|
21
|
+
throw new Error(`These events were packed with packer ${e.v} which is incompatible with current packer ${MARK}.`);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
console.error(error);
|
|
25
|
+
throw new Error('Unknown data format.');
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { unpack };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
class StackFrame {
|
|
2
|
+
constructor(obj) {
|
|
3
|
+
this.fileName = obj.fileName || '';
|
|
4
|
+
this.functionName = obj.functionName || '';
|
|
5
|
+
this.lineNumber = obj.lineNumber;
|
|
6
|
+
this.columnNumber = obj.columnNumber;
|
|
7
|
+
}
|
|
8
|
+
toString() {
|
|
9
|
+
const lineNumber = this.lineNumber || '';
|
|
10
|
+
const columnNumber = this.columnNumber || '';
|
|
11
|
+
if (this.functionName) {
|
|
12
|
+
return (this.functionName +
|
|
13
|
+
' (' +
|
|
14
|
+
this.fileName +
|
|
15
|
+
':' +
|
|
16
|
+
lineNumber +
|
|
17
|
+
':' +
|
|
18
|
+
columnNumber +
|
|
19
|
+
')');
|
|
20
|
+
}
|
|
21
|
+
return this.fileName + ':' + lineNumber + ':' + columnNumber;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
|
|
25
|
+
const CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
|
|
26
|
+
const SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code])?$/;
|
|
27
|
+
const ErrorStackParser = {
|
|
28
|
+
parse: function (error) {
|
|
29
|
+
if (!error) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
if (typeof error.stacktrace !== 'undefined' ||
|
|
33
|
+
typeof error['opera#sourceloc'] !== 'undefined') {
|
|
34
|
+
return this.parseOpera(error);
|
|
35
|
+
}
|
|
36
|
+
else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
|
|
37
|
+
return this.parseV8OrIE(error);
|
|
38
|
+
}
|
|
39
|
+
else if (error.stack) {
|
|
40
|
+
return this.parseFFOrSafari(error);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
throw new Error('Cannot parse given Error object');
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
extractLocation: function (urlLike) {
|
|
47
|
+
if (urlLike.indexOf(':') === -1) {
|
|
48
|
+
return [urlLike];
|
|
49
|
+
}
|
|
50
|
+
const regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
|
|
51
|
+
const parts = regExp.exec(urlLike.replace(/[()]/g, ''));
|
|
52
|
+
if (!parts)
|
|
53
|
+
throw new Error(`Cannot parse given url: ${urlLike}`);
|
|
54
|
+
return [parts[1], parts[2] || undefined, parts[3] || undefined];
|
|
55
|
+
},
|
|
56
|
+
parseV8OrIE: function (error) {
|
|
57
|
+
const filtered = error.stack.split('\n').filter(function (line) {
|
|
58
|
+
return !!line.match(CHROME_IE_STACK_REGEXP);
|
|
59
|
+
}, this);
|
|
60
|
+
return filtered.map(function (line) {
|
|
61
|
+
if (line.indexOf('(eval ') > -1) {
|
|
62
|
+
line = line
|
|
63
|
+
.replace(/eval code/g, 'eval')
|
|
64
|
+
.replace(/(\(eval at [^()]*)|(\),.*$)/g, '');
|
|
65
|
+
}
|
|
66
|
+
let sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(');
|
|
67
|
+
const location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/);
|
|
68
|
+
sanitizedLine = location
|
|
69
|
+
? sanitizedLine.replace(location[0], '')
|
|
70
|
+
: sanitizedLine;
|
|
71
|
+
const tokens = sanitizedLine.split(/\s+/).slice(1);
|
|
72
|
+
const locationParts = this.extractLocation(location ? location[1] : tokens.pop());
|
|
73
|
+
const functionName = tokens.join(' ') || undefined;
|
|
74
|
+
const fileName = ['eval', '<anonymous>'].indexOf(locationParts[0]) > -1
|
|
75
|
+
? undefined
|
|
76
|
+
: locationParts[0];
|
|
77
|
+
return new StackFrame({
|
|
78
|
+
functionName,
|
|
79
|
+
fileName,
|
|
80
|
+
lineNumber: locationParts[1],
|
|
81
|
+
columnNumber: locationParts[2],
|
|
82
|
+
});
|
|
83
|
+
}, this);
|
|
84
|
+
},
|
|
85
|
+
parseFFOrSafari: function (error) {
|
|
86
|
+
const filtered = error.stack.split('\n').filter(function (line) {
|
|
87
|
+
return !line.match(SAFARI_NATIVE_CODE_REGEXP);
|
|
88
|
+
}, this);
|
|
89
|
+
return filtered.map(function (line) {
|
|
90
|
+
if (line.indexOf(' > eval') > -1) {
|
|
91
|
+
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ':$1');
|
|
92
|
+
}
|
|
93
|
+
if (line.indexOf('@') === -1 && line.indexOf(':') === -1) {
|
|
94
|
+
return new StackFrame({
|
|
95
|
+
functionName: line,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/;
|
|
100
|
+
const matches = line.match(functionNameRegex);
|
|
101
|
+
const functionName = matches && matches[1] ? matches[1] : undefined;
|
|
102
|
+
const locationParts = this.extractLocation(line.replace(functionNameRegex, ''));
|
|
103
|
+
return new StackFrame({
|
|
104
|
+
functionName,
|
|
105
|
+
fileName: locationParts[0],
|
|
106
|
+
lineNumber: locationParts[1],
|
|
107
|
+
columnNumber: locationParts[2],
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}, this);
|
|
111
|
+
},
|
|
112
|
+
parseOpera: function (e) {
|
|
113
|
+
if (!e.stacktrace ||
|
|
114
|
+
(e.message.indexOf('\n') > -1 &&
|
|
115
|
+
e.message.split('\n').length > e.stacktrace.split('\n').length)) {
|
|
116
|
+
return this.parseOpera9(e);
|
|
117
|
+
}
|
|
118
|
+
else if (!e.stack) {
|
|
119
|
+
return this.parseOpera10(e);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
return this.parseOpera11(e);
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
parseOpera9: function (e) {
|
|
126
|
+
const lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
|
|
127
|
+
const lines = e.message.split('\n');
|
|
128
|
+
const result = [];
|
|
129
|
+
for (let i = 2, len = lines.length; i < len; i += 2) {
|
|
130
|
+
const match = lineRE.exec(lines[i]);
|
|
131
|
+
if (match) {
|
|
132
|
+
result.push(new StackFrame({
|
|
133
|
+
fileName: match[2],
|
|
134
|
+
lineNumber: parseFloat(match[1]),
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
139
|
+
},
|
|
140
|
+
parseOpera10: function (e) {
|
|
141
|
+
const lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
|
|
142
|
+
const lines = e.stacktrace.split('\n');
|
|
143
|
+
const result = [];
|
|
144
|
+
for (let i = 0, len = lines.length; i < len; i += 2) {
|
|
145
|
+
const match = lineRE.exec(lines[i]);
|
|
146
|
+
if (match) {
|
|
147
|
+
result.push(new StackFrame({
|
|
148
|
+
functionName: match[3] || undefined,
|
|
149
|
+
fileName: match[2],
|
|
150
|
+
lineNumber: parseFloat(match[1]),
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
155
|
+
},
|
|
156
|
+
parseOpera11: function (error) {
|
|
157
|
+
const filtered = error.stack.split('\n').filter(function (line) {
|
|
158
|
+
return (!!line.match(FIREFOX_SAFARI_STACK_REGEXP) &&
|
|
159
|
+
!line.match(/^Error created at/));
|
|
160
|
+
}, this);
|
|
161
|
+
return filtered.map(function (line) {
|
|
162
|
+
const tokens = line.split('@');
|
|
163
|
+
const locationParts = this.extractLocation(tokens.pop());
|
|
164
|
+
const functionCall = tokens.shift() || '';
|
|
165
|
+
const functionName = functionCall
|
|
166
|
+
.replace(/<anonymous function(: (\w+))?>/, '$2')
|
|
167
|
+
.replace(/\([^)]*\)/g, '') || undefined;
|
|
168
|
+
return new StackFrame({
|
|
169
|
+
functionName,
|
|
170
|
+
fileName: locationParts[0],
|
|
171
|
+
lineNumber: locationParts[1],
|
|
172
|
+
columnNumber: locationParts[2],
|
|
173
|
+
});
|
|
174
|
+
}, this);
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export { ErrorStackParser, StackFrame };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { patch } from '../../../utils.js';
|
|
2
|
+
import { ErrorStackParser } from './error-stack-parser.js';
|
|
3
|
+
import { stringify } from './stringify.js';
|
|
4
|
+
|
|
5
|
+
const defaultLogOptions = {
|
|
6
|
+
level: [
|
|
7
|
+
'assert',
|
|
8
|
+
'clear',
|
|
9
|
+
'count',
|
|
10
|
+
'countReset',
|
|
11
|
+
'debug',
|
|
12
|
+
'dir',
|
|
13
|
+
'dirxml',
|
|
14
|
+
'error',
|
|
15
|
+
'group',
|
|
16
|
+
'groupCollapsed',
|
|
17
|
+
'groupEnd',
|
|
18
|
+
'info',
|
|
19
|
+
'log',
|
|
20
|
+
'table',
|
|
21
|
+
'time',
|
|
22
|
+
'timeEnd',
|
|
23
|
+
'timeLog',
|
|
24
|
+
'trace',
|
|
25
|
+
'warn',
|
|
26
|
+
],
|
|
27
|
+
lengthThreshold: 1000,
|
|
28
|
+
logger: 'console',
|
|
29
|
+
};
|
|
30
|
+
function initLogObserver(cb, win, logOptions) {
|
|
31
|
+
const loggerType = logOptions.logger;
|
|
32
|
+
if (!loggerType) {
|
|
33
|
+
return () => { };
|
|
34
|
+
}
|
|
35
|
+
let logger;
|
|
36
|
+
if (typeof loggerType === 'string') {
|
|
37
|
+
logger = win[loggerType];
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
logger = loggerType;
|
|
41
|
+
}
|
|
42
|
+
let logCount = 0;
|
|
43
|
+
const cancelHandlers = [];
|
|
44
|
+
if (logOptions.level.includes('error')) {
|
|
45
|
+
if (window) {
|
|
46
|
+
const errorHandler = (event) => {
|
|
47
|
+
const { message, error } = event;
|
|
48
|
+
const trace = ErrorStackParser.parse(error).map((stackFrame) => stackFrame.toString());
|
|
49
|
+
const payload = [stringify(message, logOptions.stringifyOptions)];
|
|
50
|
+
cb({
|
|
51
|
+
level: 'error',
|
|
52
|
+
trace,
|
|
53
|
+
payload,
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
window.addEventListener('error', errorHandler);
|
|
57
|
+
cancelHandlers.push(() => {
|
|
58
|
+
if (window)
|
|
59
|
+
window.removeEventListener('error', errorHandler);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
for (const levelType of logOptions.level) {
|
|
64
|
+
cancelHandlers.push(replace(logger, levelType));
|
|
65
|
+
}
|
|
66
|
+
return () => {
|
|
67
|
+
cancelHandlers.forEach((h) => h());
|
|
68
|
+
};
|
|
69
|
+
function replace(_logger, level) {
|
|
70
|
+
if (!_logger[level]) {
|
|
71
|
+
return () => { };
|
|
72
|
+
}
|
|
73
|
+
return patch(_logger, level, (original) => {
|
|
74
|
+
return (...args) => {
|
|
75
|
+
original.apply(this, args);
|
|
76
|
+
try {
|
|
77
|
+
const trace = ErrorStackParser.parse(new Error())
|
|
78
|
+
.map((stackFrame) => stackFrame.toString())
|
|
79
|
+
.splice(1);
|
|
80
|
+
const payload = args.map((s) => stringify(s, logOptions.stringifyOptions));
|
|
81
|
+
logCount++;
|
|
82
|
+
if (logCount < logOptions.lengthThreshold) {
|
|
83
|
+
cb({
|
|
84
|
+
level,
|
|
85
|
+
trace,
|
|
86
|
+
payload,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
else if (logCount === logOptions.lengthThreshold) {
|
|
90
|
+
cb({
|
|
91
|
+
level: 'warn',
|
|
92
|
+
trace: [],
|
|
93
|
+
payload: [
|
|
94
|
+
stringify('The number of log records reached the threshold.'),
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
original('rrweb logger error:', error, ...args);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const PLUGIN_NAME = 'rrweb/console@1';
|
|
107
|
+
const getRecordConsolePlugin = (options) => ({
|
|
108
|
+
name: PLUGIN_NAME,
|
|
109
|
+
observer: initLogObserver,
|
|
110
|
+
options: options
|
|
111
|
+
? Object.assign({}, defaultLogOptions, options)
|
|
112
|
+
: defaultLogOptions,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export { PLUGIN_NAME, getRecordConsolePlugin };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
function pathToSelector(node) {
|
|
2
|
+
if (!node || !node.outerHTML) {
|
|
3
|
+
return '';
|
|
4
|
+
}
|
|
5
|
+
let path = '';
|
|
6
|
+
while (node.parentElement) {
|
|
7
|
+
let name = node.localName;
|
|
8
|
+
if (!name) {
|
|
9
|
+
break;
|
|
10
|
+
}
|
|
11
|
+
name = name.toLowerCase();
|
|
12
|
+
const parent = node.parentElement;
|
|
13
|
+
const domSiblings = [];
|
|
14
|
+
if (parent.children && parent.children.length > 0) {
|
|
15
|
+
for (let i = 0; i < parent.children.length; i++) {
|
|
16
|
+
const sibling = parent.children[i];
|
|
17
|
+
if (sibling.localName && sibling.localName.toLowerCase) {
|
|
18
|
+
if (sibling.localName.toLowerCase() === name) {
|
|
19
|
+
domSiblings.push(sibling);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (domSiblings.length > 1) {
|
|
25
|
+
name += ':eq(' + domSiblings.indexOf(node) + ')';
|
|
26
|
+
}
|
|
27
|
+
path = name + (path ? '>' + path : '');
|
|
28
|
+
node = parent;
|
|
29
|
+
}
|
|
30
|
+
return path;
|
|
31
|
+
}
|
|
32
|
+
function isObject(obj) {
|
|
33
|
+
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
34
|
+
}
|
|
35
|
+
function isObjTooDeep(obj, limit) {
|
|
36
|
+
if (limit === 0) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
const keys = Object.keys(obj);
|
|
40
|
+
for (const key of keys) {
|
|
41
|
+
if (isObject(obj[key]) && isObjTooDeep(obj[key], limit - 1)) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
function stringify(obj, stringifyOptions) {
|
|
48
|
+
const options = {
|
|
49
|
+
numOfKeysLimit: 50,
|
|
50
|
+
depthOfLimit: 4,
|
|
51
|
+
};
|
|
52
|
+
Object.assign(options, stringifyOptions);
|
|
53
|
+
const stack = [];
|
|
54
|
+
const keys = [];
|
|
55
|
+
return JSON.stringify(obj, function (key, value) {
|
|
56
|
+
if (stack.length > 0) {
|
|
57
|
+
const thisPos = stack.indexOf(this);
|
|
58
|
+
~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
|
|
59
|
+
~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
|
|
60
|
+
if (~stack.indexOf(value)) {
|
|
61
|
+
if (stack[0] === value) {
|
|
62
|
+
value = '[Circular ~]';
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
value =
|
|
66
|
+
'[Circular ~.' +
|
|
67
|
+
keys.slice(0, stack.indexOf(value)).join('.') +
|
|
68
|
+
']';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
stack.push(value);
|
|
74
|
+
}
|
|
75
|
+
if (value === null || value === undefined) {
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
if (shouldIgnore(value)) {
|
|
79
|
+
return toString(value);
|
|
80
|
+
}
|
|
81
|
+
if (value instanceof Event) {
|
|
82
|
+
const eventResult = {};
|
|
83
|
+
for (const eventKey in value) {
|
|
84
|
+
const eventValue = value[eventKey];
|
|
85
|
+
if (Array.isArray(eventValue)) {
|
|
86
|
+
eventResult[eventKey] = pathToSelector(eventValue.length ? eventValue[0] : null);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
eventResult[eventKey] = eventValue;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return eventResult;
|
|
93
|
+
}
|
|
94
|
+
else if (value instanceof Node) {
|
|
95
|
+
if (value instanceof HTMLElement) {
|
|
96
|
+
return value ? value.outerHTML : '';
|
|
97
|
+
}
|
|
98
|
+
return value.nodeName;
|
|
99
|
+
}
|
|
100
|
+
else if (value instanceof Error) {
|
|
101
|
+
return value.stack
|
|
102
|
+
? value.stack + '\nEnd of stack for Error object'
|
|
103
|
+
: value.name + ': ' + value.message;
|
|
104
|
+
}
|
|
105
|
+
return value;
|
|
106
|
+
});
|
|
107
|
+
function shouldIgnore(_obj) {
|
|
108
|
+
if (isObject(_obj) && Object.keys(_obj).length > options.numOfKeysLimit) {
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
if (typeof _obj === 'function') {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
if (isObject(_obj) && isObjTooDeep(_obj, options.depthOfLimit)) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
function toString(_obj) {
|
|
120
|
+
let str = _obj.toString();
|
|
121
|
+
if (options.stringLengthLimit && str.length > options.stringLengthLimit) {
|
|
122
|
+
str = `${str.slice(0, options.stringLengthLimit)}...`;
|
|
123
|
+
}
|
|
124
|
+
return str;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export { stringify };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { PLUGIN_NAME } from '../record/index.js';
|
|
2
|
+
import { EventType, IncrementalSource } from '../../../types.js';
|
|
3
|
+
|
|
4
|
+
const ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';
|
|
5
|
+
const defaultLogConfig = {
|
|
6
|
+
level: [
|
|
7
|
+
'assert',
|
|
8
|
+
'clear',
|
|
9
|
+
'count',
|
|
10
|
+
'countReset',
|
|
11
|
+
'debug',
|
|
12
|
+
'dir',
|
|
13
|
+
'dirxml',
|
|
14
|
+
'error',
|
|
15
|
+
'group',
|
|
16
|
+
'groupCollapsed',
|
|
17
|
+
'groupEnd',
|
|
18
|
+
'info',
|
|
19
|
+
'log',
|
|
20
|
+
'table',
|
|
21
|
+
'time',
|
|
22
|
+
'timeEnd',
|
|
23
|
+
'timeLog',
|
|
24
|
+
'trace',
|
|
25
|
+
'warn',
|
|
26
|
+
],
|
|
27
|
+
replayLogger: undefined,
|
|
28
|
+
};
|
|
29
|
+
class LogReplayPlugin {
|
|
30
|
+
constructor(config) {
|
|
31
|
+
this.config = Object.assign(defaultLogConfig, config);
|
|
32
|
+
}
|
|
33
|
+
getConsoleLogger() {
|
|
34
|
+
const replayLogger = {};
|
|
35
|
+
for (const level of this.config.level) {
|
|
36
|
+
if (level === 'trace') {
|
|
37
|
+
replayLogger[level] = (data) => {
|
|
38
|
+
const logger = console.log[ORIGINAL_ATTRIBUTE_NAME]
|
|
39
|
+
? console.log[ORIGINAL_ATTRIBUTE_NAME]
|
|
40
|
+
: console.log;
|
|
41
|
+
logger(...data.payload.map((s) => JSON.parse(s)), this.formatMessage(data));
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
replayLogger[level] = (data) => {
|
|
46
|
+
const logger = console[level][ORIGINAL_ATTRIBUTE_NAME]
|
|
47
|
+
? console[level][ORIGINAL_ATTRIBUTE_NAME]
|
|
48
|
+
: console[level];
|
|
49
|
+
logger(...data.payload.map((s) => JSON.parse(s)), this.formatMessage(data));
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return replayLogger;
|
|
54
|
+
}
|
|
55
|
+
formatMessage(data) {
|
|
56
|
+
if (data.trace.length === 0) {
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
59
|
+
const stackPrefix = '\n\tat ';
|
|
60
|
+
let result = stackPrefix;
|
|
61
|
+
result += data.trace.join(stackPrefix);
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const getReplayConsolePlugin = (options) => {
|
|
66
|
+
const replayLogger = (options === null || options === void 0 ? void 0 : options.replayLogger) || new LogReplayPlugin(options).getConsoleLogger();
|
|
67
|
+
return {
|
|
68
|
+
handler(event, _isSync, context) {
|
|
69
|
+
let logData = null;
|
|
70
|
+
if (event.type === EventType.IncrementalSnapshot &&
|
|
71
|
+
event.data.source === IncrementalSource.Log) {
|
|
72
|
+
logData = event.data;
|
|
73
|
+
}
|
|
74
|
+
else if (event.type === EventType.Plugin &&
|
|
75
|
+
event.data.plugin === PLUGIN_NAME) {
|
|
76
|
+
logData = event.data.payload;
|
|
77
|
+
}
|
|
78
|
+
if (logData) {
|
|
79
|
+
try {
|
|
80
|
+
if (typeof replayLogger[logData.level] === 'function') {
|
|
81
|
+
replayLogger[logData.level](logData);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (context.replayer.config.showWarning) {
|
|
86
|
+
console.warn(error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export { getReplayConsolePlugin };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const defaultOptions = {
|
|
2
|
+
key: '_sid',
|
|
3
|
+
};
|
|
4
|
+
const PLUGIN_NAME = 'rrweb/sequential-id@1';
|
|
5
|
+
const getRecordSequentialIdPlugin = (options) => {
|
|
6
|
+
const _options = options
|
|
7
|
+
? Object.assign({}, defaultOptions, options)
|
|
8
|
+
: defaultOptions;
|
|
9
|
+
let id = 0;
|
|
10
|
+
return {
|
|
11
|
+
name: PLUGIN_NAME,
|
|
12
|
+
eventProcessor(event) {
|
|
13
|
+
Object.assign(event, {
|
|
14
|
+
[_options.key]: ++id,
|
|
15
|
+
});
|
|
16
|
+
return event;
|
|
17
|
+
},
|
|
18
|
+
options: _options,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { PLUGIN_NAME, getRecordSequentialIdPlugin };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const defaultOptions = {
|
|
2
|
+
key: '_sid',
|
|
3
|
+
warnOnMissingId: true,
|
|
4
|
+
};
|
|
5
|
+
const getReplaySequentialIdPlugin = (options) => {
|
|
6
|
+
const { key, warnOnMissingId } = options
|
|
7
|
+
? Object.assign({}, defaultOptions, options)
|
|
8
|
+
: defaultOptions;
|
|
9
|
+
let currentId = 1;
|
|
10
|
+
return {
|
|
11
|
+
handler(event) {
|
|
12
|
+
if (key in event) {
|
|
13
|
+
const id = event[key];
|
|
14
|
+
if (id !== currentId) {
|
|
15
|
+
console.error(`[sequential-id-plugin]: expect to get an id with value "${currentId}", but got "${id}"`);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
currentId++;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
else if (warnOnMissingId) {
|
|
22
|
+
console.warn(`[sequential-id-plugin]: failed to get id in key: "${key}"`);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { getReplaySequentialIdPlugin };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class IframeManager {
|
|
2
|
+
constructor(options) {
|
|
3
|
+
this.iframes = new WeakMap();
|
|
4
|
+
this.mutationCb = options.mutationCb;
|
|
5
|
+
}
|
|
6
|
+
addIframe(iframeEl) {
|
|
7
|
+
this.iframes.set(iframeEl, true);
|
|
8
|
+
}
|
|
9
|
+
addLoadListener(cb) {
|
|
10
|
+
this.loadListener = cb;
|
|
11
|
+
}
|
|
12
|
+
attachIframe(iframeEl, childSn, mirror) {
|
|
13
|
+
var _a;
|
|
14
|
+
this.mutationCb({
|
|
15
|
+
adds: [
|
|
16
|
+
{
|
|
17
|
+
parentId: mirror.getId(iframeEl),
|
|
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
|
+
}
|
|
30
|
+
|
|
31
|
+
export { IframeManager };
|