@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,63 @@
|
|
|
1
|
+
//
|
|
2
|
+
// An event handler can take an optional event argument
|
|
3
|
+
// and should not return a value
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
// An array of all currently registered event handlers for a type
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
// A map of event types and their corresponding event handlers.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/** Mitt: Tiny (~200b) functional event emitter / pubsub.
|
|
17
|
+
* @name mitt
|
|
18
|
+
* @returns {Mitt}
|
|
19
|
+
*/
|
|
20
|
+
function mitt(all ) {
|
|
21
|
+
all = all || Object.create(null);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
/**
|
|
25
|
+
* Register an event handler for the given type.
|
|
26
|
+
*
|
|
27
|
+
* @param {String} type Type of event to listen for, or `"*"` for all events
|
|
28
|
+
* @param {Function} handler Function to call in response to given event
|
|
29
|
+
* @memberOf mitt
|
|
30
|
+
*/
|
|
31
|
+
on: function on(type , handler ) {
|
|
32
|
+
(all[type] || (all[type] = [])).push(handler);
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Remove an event handler for the given type.
|
|
37
|
+
*
|
|
38
|
+
* @param {String} type Type of event to unregister `handler` from, or `"*"`
|
|
39
|
+
* @param {Function} handler Handler function to remove
|
|
40
|
+
* @memberOf mitt
|
|
41
|
+
*/
|
|
42
|
+
off: function off(type , handler ) {
|
|
43
|
+
if (all[type]) {
|
|
44
|
+
all[type].splice(all[type].indexOf(handler) >>> 0, 1);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Invoke all handlers for the given type.
|
|
50
|
+
* If present, `"*"` handlers are invoked after type-matched handlers.
|
|
51
|
+
*
|
|
52
|
+
* @param {String} type The event type to invoke
|
|
53
|
+
* @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler
|
|
54
|
+
* @memberOf mitt
|
|
55
|
+
*/
|
|
56
|
+
emit: function emit(type , evt ) {
|
|
57
|
+
(all[type] || []).slice().map(function (handler) { handler(evt); });
|
|
58
|
+
(all['*'] || []).slice().map(function (handler) { handler(type, evt); });
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default mitt;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/*! *****************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
|
|
16
|
+
var __assign = function() {
|
|
17
|
+
__assign = Object.assign || function __assign(t) {
|
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
+
s = arguments[i];
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function __rest(s, e) {
|
|
28
|
+
var t = {};
|
|
29
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
30
|
+
t[p] = s[p];
|
|
31
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
32
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
33
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
34
|
+
t[p[i]] = s[p[i]];
|
|
35
|
+
}
|
|
36
|
+
return t;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function __values(o) {
|
|
40
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
41
|
+
if (m) return m.call(o);
|
|
42
|
+
if (o && typeof o.length === "number") return {
|
|
43
|
+
next: function () {
|
|
44
|
+
if (o && i >= o.length) o = void 0;
|
|
45
|
+
return { value: o && o[i++], done: !o };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function __read(o, n) {
|
|
52
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
53
|
+
if (!m) return o;
|
|
54
|
+
var i = m.call(o), r, ar = [], e;
|
|
55
|
+
try {
|
|
56
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
57
|
+
}
|
|
58
|
+
catch (error) { e = { error: error }; }
|
|
59
|
+
finally {
|
|
60
|
+
try {
|
|
61
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
62
|
+
}
|
|
63
|
+
finally { if (e) throw e.error; }
|
|
64
|
+
}
|
|
65
|
+
return ar;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function __spreadArray(to, from, pack) {
|
|
69
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
70
|
+
if (ar || !(i in from)) {
|
|
71
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
72
|
+
ar[i] = from[i];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { __assign, __read, __rest, __spreadArray, __values };
|
|
@@ -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,12 @@
|
|
|
1
|
+
import record from './record/index.js';
|
|
2
|
+
export { default as record } from './record/index.js';
|
|
3
|
+
export { Replayer } from './replay/index.js';
|
|
4
|
+
import * as utils from './utils.js';
|
|
5
|
+
export { utils };
|
|
6
|
+
export { _mirror as mirror } from './utils.js';
|
|
7
|
+
export { EventType, IncrementalSource, MouseInteractions, ReplayerEvents } from './types.js';
|
|
8
|
+
|
|
9
|
+
var addCustomEvent = record.addCustomEvent;
|
|
10
|
+
var freezePage = record.freezePage;
|
|
11
|
+
|
|
12
|
+
export { addCustomEvent, freezePage };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { __assign } from '../../ext/tslib/tslib.es6.js';
|
|
2
|
+
import { strFromU8, zlibSync, strToU8 } from '../../../../ext/fflate/esm/browser.js';
|
|
3
|
+
import { MARK } from './base.js';
|
|
4
|
+
|
|
5
|
+
var pack = function (event) {
|
|
6
|
+
var _e = __assign(__assign({}, event), { v: MARK });
|
|
7
|
+
return strFromU8(zlibSync(strToU8(JSON.stringify(_e))), true);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
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
|
+
var unpack = function (raw) {
|
|
5
|
+
if (typeof raw !== 'string') {
|
|
6
|
+
return raw;
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
var e = JSON.parse(raw);
|
|
10
|
+
if (e.timestamp) {
|
|
11
|
+
return e;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
var 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 ".concat(e.v, " which is incompatible with current packer ").concat(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,179 @@
|
|
|
1
|
+
var StackFrame = (function () {
|
|
2
|
+
function StackFrame(obj) {
|
|
3
|
+
this.fileName = obj.fileName || '';
|
|
4
|
+
this.functionName = obj.functionName || '';
|
|
5
|
+
this.lineNumber = obj.lineNumber;
|
|
6
|
+
this.columnNumber = obj.columnNumber;
|
|
7
|
+
}
|
|
8
|
+
StackFrame.prototype.toString = function () {
|
|
9
|
+
var lineNumber = this.lineNumber || '';
|
|
10
|
+
var 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
|
+
return StackFrame;
|
|
24
|
+
}());
|
|
25
|
+
var FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\S+:\d+/;
|
|
26
|
+
var CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m;
|
|
27
|
+
var SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code])?$/;
|
|
28
|
+
var ErrorStackParser = {
|
|
29
|
+
parse: function (error) {
|
|
30
|
+
if (!error) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
if (typeof error.stacktrace !== 'undefined' ||
|
|
34
|
+
typeof error['opera#sourceloc'] !== 'undefined') {
|
|
35
|
+
return this.parseOpera(error);
|
|
36
|
+
}
|
|
37
|
+
else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {
|
|
38
|
+
return this.parseV8OrIE(error);
|
|
39
|
+
}
|
|
40
|
+
else if (error.stack) {
|
|
41
|
+
return this.parseFFOrSafari(error);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
throw new Error('Cannot parse given Error object');
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
extractLocation: function (urlLike) {
|
|
48
|
+
if (urlLike.indexOf(':') === -1) {
|
|
49
|
+
return [urlLike];
|
|
50
|
+
}
|
|
51
|
+
var regExp = /(.+?)(?::(\d+))?(?::(\d+))?$/;
|
|
52
|
+
var parts = regExp.exec(urlLike.replace(/[()]/g, ''));
|
|
53
|
+
if (!parts)
|
|
54
|
+
throw new Error("Cannot parse given url: ".concat(urlLike));
|
|
55
|
+
return [parts[1], parts[2] || undefined, parts[3] || undefined];
|
|
56
|
+
},
|
|
57
|
+
parseV8OrIE: function (error) {
|
|
58
|
+
var filtered = error.stack.split('\n').filter(function (line) {
|
|
59
|
+
return !!line.match(CHROME_IE_STACK_REGEXP);
|
|
60
|
+
}, this);
|
|
61
|
+
return filtered.map(function (line) {
|
|
62
|
+
if (line.indexOf('(eval ') > -1) {
|
|
63
|
+
line = line
|
|
64
|
+
.replace(/eval code/g, 'eval')
|
|
65
|
+
.replace(/(\(eval at [^()]*)|(\),.*$)/g, '');
|
|
66
|
+
}
|
|
67
|
+
var sanitizedLine = line.replace(/^\s+/, '').replace(/\(eval code/g, '(');
|
|
68
|
+
var location = sanitizedLine.match(/ (\((.+):(\d+):(\d+)\)$)/);
|
|
69
|
+
sanitizedLine = location
|
|
70
|
+
? sanitizedLine.replace(location[0], '')
|
|
71
|
+
: sanitizedLine;
|
|
72
|
+
var tokens = sanitizedLine.split(/\s+/).slice(1);
|
|
73
|
+
var locationParts = this.extractLocation(location ? location[1] : tokens.pop());
|
|
74
|
+
var functionName = tokens.join(' ') || undefined;
|
|
75
|
+
var fileName = ['eval', '<anonymous>'].indexOf(locationParts[0]) > -1
|
|
76
|
+
? undefined
|
|
77
|
+
: locationParts[0];
|
|
78
|
+
return new StackFrame({
|
|
79
|
+
functionName: functionName,
|
|
80
|
+
fileName: fileName,
|
|
81
|
+
lineNumber: locationParts[1],
|
|
82
|
+
columnNumber: locationParts[2],
|
|
83
|
+
});
|
|
84
|
+
}, this);
|
|
85
|
+
},
|
|
86
|
+
parseFFOrSafari: function (error) {
|
|
87
|
+
var filtered = error.stack.split('\n').filter(function (line) {
|
|
88
|
+
return !line.match(SAFARI_NATIVE_CODE_REGEXP);
|
|
89
|
+
}, this);
|
|
90
|
+
return filtered.map(function (line) {
|
|
91
|
+
if (line.indexOf(' > eval') > -1) {
|
|
92
|
+
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g, ':$1');
|
|
93
|
+
}
|
|
94
|
+
if (line.indexOf('@') === -1 && line.indexOf(':') === -1) {
|
|
95
|
+
return new StackFrame({
|
|
96
|
+
functionName: line,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
var functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/;
|
|
101
|
+
var matches = line.match(functionNameRegex);
|
|
102
|
+
var functionName = matches && matches[1] ? matches[1] : undefined;
|
|
103
|
+
var locationParts = this.extractLocation(line.replace(functionNameRegex, ''));
|
|
104
|
+
return new StackFrame({
|
|
105
|
+
functionName: functionName,
|
|
106
|
+
fileName: locationParts[0],
|
|
107
|
+
lineNumber: locationParts[1],
|
|
108
|
+
columnNumber: locationParts[2],
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}, this);
|
|
112
|
+
},
|
|
113
|
+
parseOpera: function (e) {
|
|
114
|
+
if (!e.stacktrace ||
|
|
115
|
+
(e.message.indexOf('\n') > -1 &&
|
|
116
|
+
e.message.split('\n').length > e.stacktrace.split('\n').length)) {
|
|
117
|
+
return this.parseOpera9(e);
|
|
118
|
+
}
|
|
119
|
+
else if (!e.stack) {
|
|
120
|
+
return this.parseOpera10(e);
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
return this.parseOpera11(e);
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
parseOpera9: function (e) {
|
|
127
|
+
var lineRE = /Line (\d+).*script (?:in )?(\S+)/i;
|
|
128
|
+
var lines = e.message.split('\n');
|
|
129
|
+
var result = [];
|
|
130
|
+
for (var i = 2, len = lines.length; i < len; i += 2) {
|
|
131
|
+
var match = lineRE.exec(lines[i]);
|
|
132
|
+
if (match) {
|
|
133
|
+
result.push(new StackFrame({
|
|
134
|
+
fileName: match[2],
|
|
135
|
+
lineNumber: parseFloat(match[1]),
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
},
|
|
141
|
+
parseOpera10: function (e) {
|
|
142
|
+
var lineRE = /Line (\d+).*script (?:in )?(\S+)(?:: In function (\S+))?$/i;
|
|
143
|
+
var lines = e.stacktrace.split('\n');
|
|
144
|
+
var result = [];
|
|
145
|
+
for (var i = 0, len = lines.length; i < len; i += 2) {
|
|
146
|
+
var match = lineRE.exec(lines[i]);
|
|
147
|
+
if (match) {
|
|
148
|
+
result.push(new StackFrame({
|
|
149
|
+
functionName: match[3] || undefined,
|
|
150
|
+
fileName: match[2],
|
|
151
|
+
lineNumber: parseFloat(match[1]),
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return result;
|
|
156
|
+
},
|
|
157
|
+
parseOpera11: function (error) {
|
|
158
|
+
var filtered = error.stack.split('\n').filter(function (line) {
|
|
159
|
+
return (!!line.match(FIREFOX_SAFARI_STACK_REGEXP) &&
|
|
160
|
+
!line.match(/^Error created at/));
|
|
161
|
+
}, this);
|
|
162
|
+
return filtered.map(function (line) {
|
|
163
|
+
var tokens = line.split('@');
|
|
164
|
+
var locationParts = this.extractLocation(tokens.pop());
|
|
165
|
+
var functionCall = tokens.shift() || '';
|
|
166
|
+
var functionName = functionCall
|
|
167
|
+
.replace(/<anonymous function(: (\w+))?>/, '$2')
|
|
168
|
+
.replace(/\([^)]*\)/g, '') || undefined;
|
|
169
|
+
return new StackFrame({
|
|
170
|
+
functionName: functionName,
|
|
171
|
+
fileName: locationParts[0],
|
|
172
|
+
lineNumber: locationParts[1],
|
|
173
|
+
columnNumber: locationParts[2],
|
|
174
|
+
});
|
|
175
|
+
}, this);
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export { ErrorStackParser, StackFrame };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { __values, __spreadArray, __read } from '../../../../ext/tslib/tslib.es6.js';
|
|
2
|
+
import { patch } from '../../../utils.js';
|
|
3
|
+
import { ErrorStackParser } from './error-stack-parser.js';
|
|
4
|
+
import { stringify } from './stringify.js';
|
|
5
|
+
|
|
6
|
+
var defaultLogOptions = {
|
|
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
|
+
lengthThreshold: 1000,
|
|
29
|
+
logger: 'console',
|
|
30
|
+
};
|
|
31
|
+
function initLogObserver(cb, win, logOptions) {
|
|
32
|
+
var e_1, _a;
|
|
33
|
+
var loggerType = logOptions.logger;
|
|
34
|
+
if (!loggerType) {
|
|
35
|
+
return function () { };
|
|
36
|
+
}
|
|
37
|
+
var logger;
|
|
38
|
+
if (typeof loggerType === 'string') {
|
|
39
|
+
logger = win[loggerType];
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
logger = loggerType;
|
|
43
|
+
}
|
|
44
|
+
var logCount = 0;
|
|
45
|
+
var cancelHandlers = [];
|
|
46
|
+
if (logOptions.level.includes('error')) {
|
|
47
|
+
if (window) {
|
|
48
|
+
var errorHandler_1 = function (event) {
|
|
49
|
+
var message = event.message, error = event.error;
|
|
50
|
+
var trace = ErrorStackParser.parse(error).map(function (stackFrame) { return stackFrame.toString(); });
|
|
51
|
+
var payload = [stringify(message, logOptions.stringifyOptions)];
|
|
52
|
+
cb({
|
|
53
|
+
level: 'error',
|
|
54
|
+
trace: trace,
|
|
55
|
+
payload: payload,
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
window.addEventListener('error', errorHandler_1);
|
|
59
|
+
cancelHandlers.push(function () {
|
|
60
|
+
if (window)
|
|
61
|
+
window.removeEventListener('error', errorHandler_1);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
for (var _b = __values(logOptions.level), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
67
|
+
var levelType = _c.value;
|
|
68
|
+
cancelHandlers.push(replace(logger, levelType));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
72
|
+
finally {
|
|
73
|
+
try {
|
|
74
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
75
|
+
}
|
|
76
|
+
finally { if (e_1) throw e_1.error; }
|
|
77
|
+
}
|
|
78
|
+
return function () {
|
|
79
|
+
cancelHandlers.forEach(function (h) { return h(); });
|
|
80
|
+
};
|
|
81
|
+
function replace(_logger, level) {
|
|
82
|
+
var _this = this;
|
|
83
|
+
if (!_logger[level]) {
|
|
84
|
+
return function () { };
|
|
85
|
+
}
|
|
86
|
+
return patch(_logger, level, function (original) {
|
|
87
|
+
return function () {
|
|
88
|
+
var args = [];
|
|
89
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
90
|
+
args[_i] = arguments[_i];
|
|
91
|
+
}
|
|
92
|
+
original.apply(_this, args);
|
|
93
|
+
try {
|
|
94
|
+
var trace = ErrorStackParser.parse(new Error())
|
|
95
|
+
.map(function (stackFrame) { return stackFrame.toString(); })
|
|
96
|
+
.splice(1);
|
|
97
|
+
var payload = args.map(function (s) {
|
|
98
|
+
return stringify(s, logOptions.stringifyOptions);
|
|
99
|
+
});
|
|
100
|
+
logCount++;
|
|
101
|
+
if (logCount < logOptions.lengthThreshold) {
|
|
102
|
+
cb({
|
|
103
|
+
level: level,
|
|
104
|
+
trace: trace,
|
|
105
|
+
payload: payload,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else if (logCount === logOptions.lengthThreshold) {
|
|
109
|
+
cb({
|
|
110
|
+
level: 'warn',
|
|
111
|
+
trace: [],
|
|
112
|
+
payload: [
|
|
113
|
+
stringify('The number of log records reached the threshold.'),
|
|
114
|
+
],
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
original.apply(void 0, __spreadArray(['rrweb logger error:', error], __read(args), false));
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
var PLUGIN_NAME = 'rrweb/console@1';
|
|
126
|
+
var getRecordConsolePlugin = function (options) { return ({
|
|
127
|
+
name: PLUGIN_NAME,
|
|
128
|
+
observer: initLogObserver,
|
|
129
|
+
options: options
|
|
130
|
+
? Object.assign({}, defaultLogOptions, options)
|
|
131
|
+
: defaultLogOptions,
|
|
132
|
+
}); };
|
|
133
|
+
|
|
134
|
+
export { PLUGIN_NAME, getRecordConsolePlugin };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { __values } from '../../../../ext/tslib/tslib.es6.js';
|
|
2
|
+
|
|
3
|
+
function pathToSelector(node) {
|
|
4
|
+
if (!node || !node.outerHTML) {
|
|
5
|
+
return '';
|
|
6
|
+
}
|
|
7
|
+
var path = '';
|
|
8
|
+
while (node.parentElement) {
|
|
9
|
+
var name_1 = node.localName;
|
|
10
|
+
if (!name_1) {
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
13
|
+
name_1 = name_1.toLowerCase();
|
|
14
|
+
var parent_1 = node.parentElement;
|
|
15
|
+
var domSiblings = [];
|
|
16
|
+
if (parent_1.children && parent_1.children.length > 0) {
|
|
17
|
+
for (var i = 0; i < parent_1.children.length; i++) {
|
|
18
|
+
var sibling = parent_1.children[i];
|
|
19
|
+
if (sibling.localName && sibling.localName.toLowerCase) {
|
|
20
|
+
if (sibling.localName.toLowerCase() === name_1) {
|
|
21
|
+
domSiblings.push(sibling);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (domSiblings.length > 1) {
|
|
27
|
+
name_1 += ':eq(' + domSiblings.indexOf(node) + ')';
|
|
28
|
+
}
|
|
29
|
+
path = name_1 + (path ? '>' + path : '');
|
|
30
|
+
node = parent_1;
|
|
31
|
+
}
|
|
32
|
+
return path;
|
|
33
|
+
}
|
|
34
|
+
function isObject(obj) {
|
|
35
|
+
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
36
|
+
}
|
|
37
|
+
function isObjTooDeep(obj, limit) {
|
|
38
|
+
var e_1, _a;
|
|
39
|
+
if (limit === 0) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
var keys = Object.keys(obj);
|
|
43
|
+
try {
|
|
44
|
+
for (var keys_1 = __values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
|
|
45
|
+
var key = keys_1_1.value;
|
|
46
|
+
if (isObject(obj[key]) && isObjTooDeep(obj[key], limit - 1)) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
52
|
+
finally {
|
|
53
|
+
try {
|
|
54
|
+
if (keys_1_1 && !keys_1_1.done && (_a = keys_1.return)) _a.call(keys_1);
|
|
55
|
+
}
|
|
56
|
+
finally { if (e_1) throw e_1.error; }
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
function stringify(obj, stringifyOptions) {
|
|
61
|
+
var options = {
|
|
62
|
+
numOfKeysLimit: 50,
|
|
63
|
+
depthOfLimit: 4,
|
|
64
|
+
};
|
|
65
|
+
Object.assign(options, stringifyOptions);
|
|
66
|
+
var stack = [];
|
|
67
|
+
var keys = [];
|
|
68
|
+
return JSON.stringify(obj, function (key, value) {
|
|
69
|
+
if (stack.length > 0) {
|
|
70
|
+
var thisPos = stack.indexOf(this);
|
|
71
|
+
~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
|
|
72
|
+
~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
|
|
73
|
+
if (~stack.indexOf(value)) {
|
|
74
|
+
if (stack[0] === value) {
|
|
75
|
+
value = '[Circular ~]';
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
value =
|
|
79
|
+
'[Circular ~.' +
|
|
80
|
+
keys.slice(0, stack.indexOf(value)).join('.') +
|
|
81
|
+
']';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
stack.push(value);
|
|
87
|
+
}
|
|
88
|
+
if (value === null || value === undefined) {
|
|
89
|
+
return value;
|
|
90
|
+
}
|
|
91
|
+
if (shouldIgnore(value)) {
|
|
92
|
+
return toString(value);
|
|
93
|
+
}
|
|
94
|
+
if (value instanceof Event) {
|
|
95
|
+
var eventResult = {};
|
|
96
|
+
for (var eventKey in value) {
|
|
97
|
+
var eventValue = value[eventKey];
|
|
98
|
+
if (Array.isArray(eventValue)) {
|
|
99
|
+
eventResult[eventKey] = pathToSelector(eventValue.length ? eventValue[0] : null);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
eventResult[eventKey] = eventValue;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return eventResult;
|
|
106
|
+
}
|
|
107
|
+
else if (value instanceof Node) {
|
|
108
|
+
if (value instanceof HTMLElement) {
|
|
109
|
+
return value ? value.outerHTML : '';
|
|
110
|
+
}
|
|
111
|
+
return value.nodeName;
|
|
112
|
+
}
|
|
113
|
+
else if (value instanceof Error) {
|
|
114
|
+
return value.stack
|
|
115
|
+
? value.stack + '\nEnd of stack for Error object'
|
|
116
|
+
: value.name + ': ' + value.message;
|
|
117
|
+
}
|
|
118
|
+
return value;
|
|
119
|
+
});
|
|
120
|
+
function shouldIgnore(_obj) {
|
|
121
|
+
if (isObject(_obj) && Object.keys(_obj).length > options.numOfKeysLimit) {
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
if (typeof _obj === 'function') {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
if (isObject(_obj) && isObjTooDeep(_obj, options.depthOfLimit)) {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
function toString(_obj) {
|
|
133
|
+
var str = _obj.toString();
|
|
134
|
+
if (options.stringLengthLimit && str.length > options.stringLengthLimit) {
|
|
135
|
+
str = "".concat(str.slice(0, options.stringLengthLimit), "...");
|
|
136
|
+
}
|
|
137
|
+
return str;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export { stringify };
|