@betterbugs/rrweb-plugin-console-replay 2.0.0-alpha.19
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/README.md +178 -0
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/rrweb-plugin-console-replay.cjs +132 -0
- package/dist/rrweb-plugin-console-replay.cjs.map +1 -0
- package/dist/rrweb-plugin-console-replay.js +132 -0
- package/dist/rrweb-plugin-console-replay.js.map +1 -0
- package/dist/rrweb-plugin-console-replay.umd.cjs +162 -0
- package/dist/rrweb-plugin-console-replay.umd.cjs.map +7 -0
- package/dist/rrweb-plugin-console-replay.umd.min.cjs +33 -0
- package/dist/rrweb-plugin-console-replay.umd.min.cjs.map +7 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# @rrweb/rrweb-plugin-console-replay
|
|
2
|
+
|
|
3
|
+
Please refer to the [console recipe](../../../docs/recipes/console.md) on how to use this plugin.
|
|
4
|
+
See the [guide](../../../guide.md) for more info on rrweb.
|
|
5
|
+
|
|
6
|
+
## Sponsors
|
|
7
|
+
|
|
8
|
+
[Become a sponsor](https://opencollective.com/rrweb#sponsor) and get your logo on our README on Github with a link to your site.
|
|
9
|
+
|
|
10
|
+
### Gold Sponsors 🥇
|
|
11
|
+
|
|
12
|
+
<div dir="auto">
|
|
13
|
+
|
|
14
|
+
<a href="https://opencollective.com/rrweb/tiers/gold-sponsor/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/gold-sponsor/0/avatar.svg?requireActive=false&avatarHeight=225" alt="sponsor"></a>
|
|
15
|
+
<a href="https://opencollective.com/rrweb/tiers/gold-sponsor/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/gold-sponsor/1/avatar.svg?requireActive=false&avatarHeight=225" alt="sponsor"></a>
|
|
16
|
+
<a href="https://opencollective.com/rrweb/tiers/gold-sponsor/2/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/gold-sponsor/2/avatar.svg?requireActive=false&avatarHeight=225" alt="sponsor"></a>
|
|
17
|
+
<a href="https://opencollective.com/rrweb/tiers/gold-sponsor/3/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/gold-sponsor/3/avatar.svg?requireActive=false&avatarHeight=225" alt="sponsor"></a>
|
|
18
|
+
<a href="https://opencollective.com/rrweb/tiers/gold-sponsor/4/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/gold-sponsor/4/avatar.svg?requireActive=false&avatarHeight=225" alt="sponsor"></a>
|
|
19
|
+
<a href="https://opencollective.com/rrweb/tiers/gold-sponsor/5/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/gold-sponsor/5/avatar.svg?requireActive=false&avatarHeight=225" alt="sponsor"></a>
|
|
20
|
+
<a href="https://opencollective.com/rrweb/tiers/gold-sponsor/6/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/gold-sponsor/6/avatar.svg?requireActive=false&avatarHeight=225" alt="sponsor"></a>
|
|
21
|
+
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
### Silver Sponsors 🥈
|
|
25
|
+
|
|
26
|
+
<div dir="auto">
|
|
27
|
+
|
|
28
|
+
<a href="https://opencollective.com/rrweb/tiers/silver-sponsor/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/silver-sponsor/0/avatar.svg?requireActive=false&avatarHeight=158" alt="sponsor"></a>
|
|
29
|
+
<a href="https://opencollective.com/rrweb/tiers/silver-sponsor/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/silver-sponsor/1/avatar.svg?requireActive=false&avatarHeight=158" alt="sponsor"></a>
|
|
30
|
+
<a href="https://opencollective.com/rrweb/tiers/silver-sponsor/2/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/silver-sponsor/2/avatar.svg?requireActive=false&avatarHeight=158" alt="sponsor"></a>
|
|
31
|
+
<a href="https://opencollective.com/rrweb/tiers/silver-sponsor/3/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/silver-sponsor/3/avatar.svg?requireActive=false&avatarHeight=158" alt="sponsor"></a>
|
|
32
|
+
<a href="https://opencollective.com/rrweb/tiers/silver-sponsor/4/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/silver-sponsor/4/avatar.svg?requireActive=false&avatarHeight=158" alt="sponsor"></a>
|
|
33
|
+
<a href="https://opencollective.com/rrweb/tiers/silver-sponsor/5/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/silver-sponsor/5/avatar.svg?requireActive=false&avatarHeight=158" alt="sponsor"></a>
|
|
34
|
+
<a href="https://opencollective.com/rrweb/tiers/silver-sponsor/6/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/silver-sponsor/6/avatar.svg?requireActive=false&avatarHeight=158" alt="sponsor"></a>
|
|
35
|
+
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
### Bronze Sponsors 🥉
|
|
39
|
+
|
|
40
|
+
<div dir="auto">
|
|
41
|
+
|
|
42
|
+
<a href="https://opencollective.com/rrweb/tiers/sponsors/0/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/0/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a>
|
|
43
|
+
<a href="https://opencollective.com/rrweb/tiers/sponsors/1/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/1/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a>
|
|
44
|
+
<a href="https://opencollective.com/rrweb/tiers/sponsors/2/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/2/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a>
|
|
45
|
+
<a href="https://opencollective.com/rrweb/tiers/sponsors/3/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/3/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a>
|
|
46
|
+
<a href="https://opencollective.com/rrweb/tiers/sponsors/4/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/4/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a>
|
|
47
|
+
<a href="https://opencollective.com/rrweb/tiers/sponsors/5/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/5/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a>
|
|
48
|
+
<a href="https://opencollective.com/rrweb/tiers/sponsors/6/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/6/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a>
|
|
49
|
+
<a href="https://opencollective.com/rrweb/tiers/sponsors/7/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/7/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a>
|
|
50
|
+
<a href="https://opencollective.com/rrweb/tiers/sponsors/8/website?requireActive=false" target="_blank"><img src="https://opencollective.com/rrweb/tiers/sponsors/8/avatar.svg?requireActive=false&avatarHeight=70" alt="sponsor"></a>
|
|
51
|
+
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
### Backers
|
|
55
|
+
|
|
56
|
+
<a href="https://opencollective.com/rrweb#sponsor" rel="nofollow"><img src="https://opencollective.com/rrweb/tiers/backers.svg?avatarHeight=36"></a>
|
|
57
|
+
|
|
58
|
+
## Core Team Members
|
|
59
|
+
|
|
60
|
+
<table>
|
|
61
|
+
<tr>
|
|
62
|
+
<td align="center">
|
|
63
|
+
<a href="https://github.com/Yuyz0112">
|
|
64
|
+
<img
|
|
65
|
+
src="https://avatars.githubusercontent.com/u/13651389?s=100"
|
|
66
|
+
width="100px;"
|
|
67
|
+
alt=""
|
|
68
|
+
/>
|
|
69
|
+
<br /><sub><b>Yuyz0112</b></sub>
|
|
70
|
+
<br /><br />
|
|
71
|
+
</a>
|
|
72
|
+
</td>
|
|
73
|
+
<td align="center">
|
|
74
|
+
<a href="https://github.com/YunFeng0817">
|
|
75
|
+
<img
|
|
76
|
+
src="https://avatars.githubusercontent.com/u/27533910?s=100"
|
|
77
|
+
width="100px;"
|
|
78
|
+
alt=""
|
|
79
|
+
/>
|
|
80
|
+
<br /><sub><b>Yun Feng</b></sub>
|
|
81
|
+
<br /><br />
|
|
82
|
+
</a>
|
|
83
|
+
</td>
|
|
84
|
+
<td align="center">
|
|
85
|
+
<a href="https://github.com/eoghanmurray">
|
|
86
|
+
<img
|
|
87
|
+
src="https://avatars.githubusercontent.com/u/156780?s=100"
|
|
88
|
+
width="100px;"
|
|
89
|
+
alt=""
|
|
90
|
+
/>
|
|
91
|
+
<br /><sub><b>eoghanmurray</b></sub>
|
|
92
|
+
<br /><br />
|
|
93
|
+
</a>
|
|
94
|
+
</td>
|
|
95
|
+
<td align="center">
|
|
96
|
+
<a href="https://github.com/Juice10">
|
|
97
|
+
<img
|
|
98
|
+
src="https://avatars.githubusercontent.com/u/4106?s=100"
|
|
99
|
+
width="100px;"
|
|
100
|
+
alt=""
|
|
101
|
+
/>
|
|
102
|
+
<br /><sub><b>Juice10</b></sub>
|
|
103
|
+
<br /><sub>open for rrweb consulting</sub>
|
|
104
|
+
</a>
|
|
105
|
+
</td>
|
|
106
|
+
</tr>
|
|
107
|
+
</table>
|
|
108
|
+
|
|
109
|
+
## Who's using rrweb?
|
|
110
|
+
|
|
111
|
+
<table>
|
|
112
|
+
<tr>
|
|
113
|
+
<td align="center">
|
|
114
|
+
<a href="http://www.smartx.com/" target="_blank">
|
|
115
|
+
<img width="195px" src="https://www.rrweb.io/logos/smartx.png">
|
|
116
|
+
</a>
|
|
117
|
+
</td>
|
|
118
|
+
<td align="center">
|
|
119
|
+
<a href="https://posthog.com?utm_source=rrweb&utm_medium=sponsorship&utm_campaign=open-source-sponsorship" target="_blank">
|
|
120
|
+
<img width="195px" src="https://www.rrweb.io/logos/posthog.png">
|
|
121
|
+
</a>
|
|
122
|
+
</td>
|
|
123
|
+
<td align="center">
|
|
124
|
+
<a href="https://statcounter.com/session-replay/" target="_blank">
|
|
125
|
+
<img width="195px" src="https://statcounter.com/images/logo-statcounter-arc-blue.svg">
|
|
126
|
+
</a>
|
|
127
|
+
</td>
|
|
128
|
+
<td align="center">
|
|
129
|
+
<a href="https://recordonce.com/" target="_blank">
|
|
130
|
+
<img width="195px" alt="Smart screen recording for SaaS" src="https://uploads-ssl.webflow.com/5f3d133183156245630d4446/5f3d1940abe8db8612c23521_Record-Once-logo-554x80px.svg">
|
|
131
|
+
</a>
|
|
132
|
+
</td>
|
|
133
|
+
</tr>
|
|
134
|
+
<tr>
|
|
135
|
+
<td align="center">
|
|
136
|
+
<a href="https://cux.io" target="_blank">
|
|
137
|
+
<img style="padding: 8px" alt="The first ever UX automation tool" width="195px" src="https://cux.io/cux-logo.svg">
|
|
138
|
+
</a>
|
|
139
|
+
</td>
|
|
140
|
+
<td align="center">
|
|
141
|
+
<a href="https://remsupp.com" target="_blank">
|
|
142
|
+
<img style="padding: 8px" alt="Remote Access & Co-Browsing" width="195px" src="https://remsupp.com/images/logo.png">
|
|
143
|
+
</a>
|
|
144
|
+
</td>
|
|
145
|
+
<td align="center">
|
|
146
|
+
<a href="https://highlight.io" target="_blank">
|
|
147
|
+
<img style="padding: 8px" alt="The open source, fullstack Monitoring Platform." width="195px" src="https://github.com/highlight/highlight/raw/main/highlight.io/public/images/logo.png">
|
|
148
|
+
</a>
|
|
149
|
+
</td>
|
|
150
|
+
<td align="center">
|
|
151
|
+
<a href="https://analyzee.io" target="_blank">
|
|
152
|
+
<img style="padding: 8px" alt="Comprehensive data analytics platform that empowers businesses to gain valuable insights and make data-driven decisions." width="195px" src="https://cdn.analyzee.io/assets/analyzee-logo.png">
|
|
153
|
+
</a>
|
|
154
|
+
</td>
|
|
155
|
+
</tr>
|
|
156
|
+
<tr>
|
|
157
|
+
<td align="center">
|
|
158
|
+
<a href="https://requestly.io" target="_blank">
|
|
159
|
+
<img style="padding: 8px" alt="Intercept, Modify, Record & Replay HTTP Requests." width="195px" src="https://github.com/requestly/requestly/assets/16779465/652552db-c867-44cb-9bb5-94a2026e04ca">
|
|
160
|
+
</a>
|
|
161
|
+
</td>
|
|
162
|
+
<td align="center">
|
|
163
|
+
<a href="https://gleap.io" target="_blank">
|
|
164
|
+
<img style="padding: 8px" alt="In-app bug reporting & customer feedback platform." width="195px" src="https://assets-global.website-files.com/6506f3f29c68b1724807619d/6506f56010237164c6306591_GleapLogo.svg">
|
|
165
|
+
</a>
|
|
166
|
+
</td>
|
|
167
|
+
<td align="center">
|
|
168
|
+
<a href="https://uxwizz.com" target="_blank">
|
|
169
|
+
<img style="padding: 8px" alt="Self-hosted website analytics with heatmaps and session recordings." width="195px" src="https://github.com/UXWizz/public-files/raw/main/assets/logo.png">
|
|
170
|
+
</a>
|
|
171
|
+
</td>
|
|
172
|
+
<td align="center">
|
|
173
|
+
<a href="https://www.howdygo.com" target="_blank">
|
|
174
|
+
<img style="padding: 8px" alt="Interactive product demos for small marketing teams" width="195px" src="https://assets-global.website-files.com/650afb446f1dd5bd410f00cc/650b2cec6188ff54dd9b01e1_Logo.svg">
|
|
175
|
+
</a>
|
|
176
|
+
</td>
|
|
177
|
+
</tr>
|
|
178
|
+
</table>
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LogData } from '@betterbugs/rrweb-plugin-console-record';
|
|
2
|
+
import { LogLevel } from '@betterbugs/rrweb-plugin-console-record';
|
|
3
|
+
import { ReplayPlugin } from '@betterbugs/rrweb';
|
|
4
|
+
|
|
5
|
+
export declare const getReplayConsolePlugin: (options?: LogReplayConfig) => ReplayPlugin;
|
|
6
|
+
|
|
7
|
+
declare type LogReplayConfig = {
|
|
8
|
+
level?: LogLevel[];
|
|
9
|
+
replayLogger?: ReplayLogger;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
declare type ReplayLogger = Partial<Record<LogLevel, (data: LogData) => void>>;
|
|
13
|
+
|
|
14
|
+
export { }
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LogData } from '@betterbugs/rrweb-plugin-console-record';
|
|
2
|
+
import { LogLevel } from '@betterbugs/rrweb-plugin-console-record';
|
|
3
|
+
import { ReplayPlugin } from '@betterbugs/rrweb';
|
|
4
|
+
|
|
5
|
+
export declare const getReplayConsolePlugin: (options?: LogReplayConfig) => ReplayPlugin;
|
|
6
|
+
|
|
7
|
+
declare type LogReplayConfig = {
|
|
8
|
+
level?: LogLevel[];
|
|
9
|
+
replayLogger?: ReplayLogger;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
declare type ReplayLogger = Partial<Record<LogLevel, (data: LogData) => void>>;
|
|
13
|
+
|
|
14
|
+
export { }
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
6
|
+
const PLUGIN_NAME = "rrweb/console@1";
|
|
7
|
+
var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
8
|
+
EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
|
|
9
|
+
EventType2[EventType2["Load"] = 1] = "Load";
|
|
10
|
+
EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
|
|
11
|
+
EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
|
|
12
|
+
EventType2[EventType2["Meta"] = 4] = "Meta";
|
|
13
|
+
EventType2[EventType2["Custom"] = 5] = "Custom";
|
|
14
|
+
EventType2[EventType2["Plugin"] = 6] = "Plugin";
|
|
15
|
+
return EventType2;
|
|
16
|
+
})(EventType || {});
|
|
17
|
+
var IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => {
|
|
18
|
+
IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
|
|
19
|
+
IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
|
|
20
|
+
IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
|
|
21
|
+
IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
|
|
22
|
+
IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
|
|
23
|
+
IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
|
|
24
|
+
IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
|
|
25
|
+
IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
|
|
26
|
+
IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
|
|
27
|
+
IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
|
|
28
|
+
IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
|
|
29
|
+
IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
|
|
30
|
+
IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
|
|
31
|
+
IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
|
|
32
|
+
IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
|
|
33
|
+
IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
|
|
34
|
+
IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
|
|
35
|
+
return IncrementalSource2;
|
|
36
|
+
})(IncrementalSource || {});
|
|
37
|
+
const ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
|
|
38
|
+
const defaultLogConfig = {
|
|
39
|
+
level: [
|
|
40
|
+
"assert",
|
|
41
|
+
"clear",
|
|
42
|
+
"count",
|
|
43
|
+
"countReset",
|
|
44
|
+
"debug",
|
|
45
|
+
"dir",
|
|
46
|
+
"dirxml",
|
|
47
|
+
"error",
|
|
48
|
+
"group",
|
|
49
|
+
"groupCollapsed",
|
|
50
|
+
"groupEnd",
|
|
51
|
+
"info",
|
|
52
|
+
"log",
|
|
53
|
+
"table",
|
|
54
|
+
"time",
|
|
55
|
+
"timeEnd",
|
|
56
|
+
"timeLog",
|
|
57
|
+
"trace",
|
|
58
|
+
"warn"
|
|
59
|
+
],
|
|
60
|
+
replayLogger: void 0
|
|
61
|
+
};
|
|
62
|
+
class LogReplayPlugin {
|
|
63
|
+
constructor(config) {
|
|
64
|
+
__publicField(this, "config");
|
|
65
|
+
this.config = Object.assign(defaultLogConfig, config);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* generate a console log replayer which implement the interface ReplayLogger
|
|
69
|
+
*/
|
|
70
|
+
getConsoleLogger() {
|
|
71
|
+
const replayLogger = {};
|
|
72
|
+
for (const level of this.config.level) {
|
|
73
|
+
if (level === "trace") {
|
|
74
|
+
replayLogger[level] = (data) => {
|
|
75
|
+
const logger = console.log[ORIGINAL_ATTRIBUTE_NAME] ? console.log[ORIGINAL_ATTRIBUTE_NAME] : console.log;
|
|
76
|
+
logger(
|
|
77
|
+
...data.payload.map((s) => JSON.parse(s)),
|
|
78
|
+
this.formatMessage(data)
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
} else {
|
|
82
|
+
replayLogger[level] = (data) => {
|
|
83
|
+
const logger = console[level][ORIGINAL_ATTRIBUTE_NAME] ? console[level][ORIGINAL_ATTRIBUTE_NAME] : console[level];
|
|
84
|
+
logger(
|
|
85
|
+
...data.payload.map((s) => JSON.parse(s)),
|
|
86
|
+
this.formatMessage(data)
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return replayLogger;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* format the trace data to a string
|
|
95
|
+
* @param data - the log data
|
|
96
|
+
*/
|
|
97
|
+
formatMessage(data) {
|
|
98
|
+
if (data.trace.length === 0) {
|
|
99
|
+
return "";
|
|
100
|
+
}
|
|
101
|
+
const stackPrefix = "\n at ";
|
|
102
|
+
let result = stackPrefix;
|
|
103
|
+
result += data.trace.join(stackPrefix);
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const getReplayConsolePlugin = (options) => {
|
|
108
|
+
const replayLogger = (options == null ? void 0 : options.replayLogger) || new LogReplayPlugin(options).getConsoleLogger();
|
|
109
|
+
return {
|
|
110
|
+
handler(event, _isSync, context) {
|
|
111
|
+
let logData = null;
|
|
112
|
+
if (event.type === EventType.IncrementalSnapshot && event.data.source === IncrementalSource.Log) {
|
|
113
|
+
logData = event.data;
|
|
114
|
+
} else if (event.type === EventType.Plugin && event.data.plugin === PLUGIN_NAME) {
|
|
115
|
+
logData = event.data.payload;
|
|
116
|
+
}
|
|
117
|
+
if (logData) {
|
|
118
|
+
try {
|
|
119
|
+
if (typeof replayLogger[logData.level] === "function") {
|
|
120
|
+
replayLogger[logData.level](logData);
|
|
121
|
+
}
|
|
122
|
+
} catch (error) {
|
|
123
|
+
if (context.replayer.config.showWarning) {
|
|
124
|
+
console.warn(error);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
exports.getReplayConsolePlugin = getReplayConsolePlugin;
|
|
132
|
+
//# sourceMappingURL=rrweb-plugin-console-replay.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rrweb-plugin-console-replay.cjs","sources":["../../rrweb-plugin-console-record/dist/rrweb-plugin-console-record.js","../../../types/dist/types.js","../src/index.ts"],"sourcesContent":["var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nfunction patch(source, name, replacement) {\n try {\n if (!(name in source)) {\n return () => {\n };\n }\n const original = source[name];\n const wrapped = replacement(original);\n if (typeof wrapped === \"function\") {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original\n }\n });\n }\n source[name] = wrapped;\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {\n };\n }\n}\nclass StackFrame {\n constructor(obj) {\n __publicField(this, \"fileName\");\n __publicField(this, \"functionName\");\n __publicField(this, \"lineNumber\");\n __publicField(this, \"columnNumber\");\n this.fileName = obj.fileName || \"\";\n this.functionName = obj.functionName || \"\";\n this.lineNumber = obj.lineNumber;\n this.columnNumber = obj.columnNumber;\n }\n toString() {\n const lineNumber = this.lineNumber || \"\";\n const columnNumber = this.columnNumber || \"\";\n if (this.functionName)\n return `${this.functionName} (${this.fileName}:${lineNumber}:${columnNumber})`;\n return `${this.fileName}:${lineNumber}:${columnNumber}`;\n }\n}\nconst FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\\S+:\\d+/;\nconst CHROME_IE_STACK_REGEXP = /^\\s*at .*(\\S+:\\d+|\\(native\\))/m;\nconst SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\\[native code])?$/;\nconst ErrorStackParser = {\n /**\n * Given an Error object, extract the most information from it.\n */\n parse: function(error) {\n if (!error) {\n return [];\n }\n if (\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n typeof error.stacktrace !== \"undefined\" || // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n typeof error[\"opera#sourceloc\"] !== \"undefined\"\n ) {\n return this.parseOpera(\n error\n );\n } else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {\n return this.parseV8OrIE(error);\n } else if (error.stack) {\n return this.parseFFOrSafari(error);\n } else {\n console.warn(\n \"[console-record-plugin]: Failed to parse error object:\",\n error\n );\n return [];\n }\n },\n // Separate line and column numbers from a string of the form: (URI:Line:Column)\n extractLocation: function(urlLike) {\n if (urlLike.indexOf(\":\") === -1) {\n return [urlLike];\n }\n const regExp = /(.+?)(?::(\\d+))?(?::(\\d+))?$/;\n const parts = regExp.exec(urlLike.replace(/[()]/g, \"\"));\n if (!parts) throw new Error(`Cannot parse given url: ${urlLike}`);\n return [parts[1], parts[2] || void 0, parts[3] || void 0];\n },\n parseV8OrIE: function(error) {\n const filtered = error.stack.split(\"\\n\").filter(function(line) {\n return !!line.match(CHROME_IE_STACK_REGEXP);\n }, this);\n return filtered.map(function(line) {\n if (line.indexOf(\"(eval \") > -1) {\n line = line.replace(/eval code/g, \"eval\").replace(/(\\(eval at [^()]*)|(\\),.*$)/g, \"\");\n }\n let sanitizedLine = line.replace(/^\\s+/, \"\").replace(/\\(eval code/g, \"(\");\n const location = sanitizedLine.match(/ (\\((.+):(\\d+):(\\d+)\\)$)/);\n sanitizedLine = location ? sanitizedLine.replace(location[0], \"\") : sanitizedLine;\n const tokens = sanitizedLine.split(/\\s+/).slice(1);\n const locationParts = this.extractLocation(\n location ? location[1] : tokens.pop()\n );\n const functionName = tokens.join(\" \") || void 0;\n const fileName = [\"eval\", \"<anonymous>\"].indexOf(locationParts[0]) > -1 ? void 0 : locationParts[0];\n return new StackFrame({\n functionName,\n fileName,\n lineNumber: locationParts[1],\n columnNumber: locationParts[2]\n });\n }, this);\n },\n parseFFOrSafari: function(error) {\n const filtered = error.stack.split(\"\\n\").filter(function(line) {\n return !line.match(SAFARI_NATIVE_CODE_REGEXP);\n }, this);\n return filtered.map(function(line) {\n if (line.indexOf(\" > eval\") > -1) {\n line = line.replace(\n / line (\\d+)(?: > eval line \\d+)* > eval:\\d+:\\d+/g,\n \":$1\"\n );\n }\n if (line.indexOf(\"@\") === -1 && line.indexOf(\":\") === -1) {\n return new StackFrame({\n functionName: line\n });\n } else {\n const functionNameRegex = /((.*\".+\"[^@]*)?[^@]*)(?:@)/;\n const matches = line.match(functionNameRegex);\n const functionName = matches && matches[1] ? matches[1] : void 0;\n const locationParts = this.extractLocation(\n line.replace(functionNameRegex, \"\")\n );\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2]\n });\n }\n }, this);\n },\n parseOpera: function(e) {\n if (!e.stacktrace || e.message.indexOf(\"\\n\") > -1 && e.message.split(\"\\n\").length > e.stacktrace.split(\"\\n\").length) {\n return this.parseOpera9(e);\n } else if (!e.stack) {\n return this.parseOpera10(e);\n } else {\n return this.parseOpera11(e);\n }\n },\n parseOpera9: function(e) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)/i;\n const lines = e.message.split(\"\\n\");\n const result = [];\n for (let i = 2, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n fileName: match[2],\n lineNumber: parseFloat(match[1])\n })\n );\n }\n }\n return result;\n },\n parseOpera10: function(e) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)(?:: In function (\\S+))?$/i;\n const lines = e.stacktrace.split(\"\\n\");\n const result = [];\n for (let i = 0, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n functionName: match[3] || void 0,\n fileName: match[2],\n lineNumber: parseFloat(match[1])\n })\n );\n }\n }\n return result;\n },\n // Opera 10.65+ Error.stack very similar to FF/Safari\n parseOpera11: function(error) {\n const filtered = error.stack.split(\"\\n\").filter(function(line) {\n return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);\n }, this);\n return filtered.map(function(line) {\n const tokens = line.split(\"@\");\n const locationParts = this.extractLocation(tokens.pop());\n const functionCall = tokens.shift() || \"\";\n const functionName = functionCall.replace(/<anonymous function(: (\\w+))?>/, \"$2\").replace(/\\([^)]*\\)/g, \"\") || void 0;\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2]\n });\n }, this);\n }\n};\nfunction pathToSelector(node) {\n if (!node || !node.outerHTML) {\n return \"\";\n }\n let path = \"\";\n while (node.parentElement) {\n let name = node.localName;\n if (!name) {\n break;\n }\n name = name.toLowerCase();\n const parent = node.parentElement;\n const domSiblings = [];\n if (parent.children && parent.children.length > 0) {\n for (let i = 0; i < parent.children.length; i++) {\n const sibling = parent.children[i];\n if (sibling.localName && sibling.localName.toLowerCase) {\n if (sibling.localName.toLowerCase() === name) {\n domSiblings.push(sibling);\n }\n }\n }\n }\n if (domSiblings.length > 1) {\n name += `:eq(${domSiblings.indexOf(node)})`;\n }\n path = name + (path ? \">\" + path : \"\");\n node = parent;\n }\n return path;\n}\nfunction isObject(obj) {\n return Object.prototype.toString.call(obj) === \"[object Object]\";\n}\nfunction isObjTooDeep(obj, limit) {\n if (limit === 0) {\n return true;\n }\n const keys = Object.keys(obj);\n for (const key of keys) {\n if (isObject(obj[key]) && isObjTooDeep(obj[key], limit - 1)) {\n return true;\n }\n }\n return false;\n}\nfunction stringify(obj, stringifyOptions) {\n const options = {\n numOfKeysLimit: 50,\n depthOfLimit: 4\n };\n Object.assign(options, stringifyOptions);\n const stack = [];\n const keys = [];\n return JSON.stringify(\n obj,\n function(key, value) {\n if (stack.length > 0) {\n const thisPos = stack.indexOf(this);\n ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);\n ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);\n if (~stack.indexOf(value)) {\n if (stack[0] === value) {\n value = \"[Circular ~]\";\n } else {\n value = \"[Circular ~.\" + keys.slice(0, stack.indexOf(value)).join(\".\") + \"]\";\n }\n }\n } else {\n stack.push(value);\n }\n if (value === null) return value;\n if (value === void 0) return \"undefined\";\n if (shouldIgnore(value)) {\n return toString(value);\n }\n if (typeof value === \"bigint\") {\n return value.toString() + \"n\";\n }\n if (value instanceof Event) {\n const eventResult = {};\n for (const eventKey in value) {\n const eventValue = value[eventKey];\n if (Array.isArray(eventValue)) {\n eventResult[eventKey] = pathToSelector(\n eventValue.length ? eventValue[0] : null\n );\n } else {\n eventResult[eventKey] = eventValue;\n }\n }\n return eventResult;\n } else if (value instanceof Node) {\n if (value instanceof HTMLElement) {\n return value ? value.outerHTML : \"\";\n }\n return value.nodeName;\n } else if (value instanceof Error) {\n return value.stack ? value.stack + \"\\nEnd of stack for Error object\" : value.name + \": \" + value.message;\n }\n return value;\n }\n );\n function shouldIgnore(_obj) {\n if (isObject(_obj) && Object.keys(_obj).length > options.numOfKeysLimit) {\n return true;\n }\n if (typeof _obj === \"function\") {\n return true;\n }\n if (isObject(_obj) && isObjTooDeep(_obj, options.depthOfLimit)) {\n return true;\n }\n return false;\n }\n function toString(_obj) {\n let str = _obj.toString();\n if (options.stringLengthLimit && str.length > options.stringLengthLimit) {\n str = `${str.slice(0, options.stringLengthLimit)}...`;\n }\n return str;\n }\n}\nconst defaultLogOptions = {\n level: [\n \"assert\",\n \"clear\",\n \"count\",\n \"countReset\",\n \"debug\",\n \"dir\",\n \"dirxml\",\n \"error\",\n \"group\",\n \"groupCollapsed\",\n \"groupEnd\",\n \"info\",\n \"log\",\n \"table\",\n \"time\",\n \"timeEnd\",\n \"timeLog\",\n \"trace\",\n \"warn\"\n ],\n lengthThreshold: 1e3,\n logger: \"console\"\n};\nfunction initLogObserver(cb, win, options) {\n const logOptions = options ? Object.assign({}, defaultLogOptions, options) : defaultLogOptions;\n const loggerType = logOptions.logger;\n if (!loggerType) {\n return () => {\n };\n }\n let logger;\n if (typeof loggerType === \"string\") {\n logger = win[loggerType];\n } else {\n logger = loggerType;\n }\n let logCount = 0;\n let inStack = false;\n const cancelHandlers = [];\n if (logOptions.level.includes(\"error\")) {\n const errorHandler = (event) => {\n const message = event.message, error = event.error;\n const trace = ErrorStackParser.parse(error).map(\n (stackFrame) => stackFrame.toString()\n );\n const payload = [stringify(message, logOptions.stringifyOptions)];\n cb({\n level: \"error\",\n trace,\n payload\n });\n };\n win.addEventListener(\"error\", errorHandler);\n cancelHandlers.push(() => {\n win.removeEventListener(\"error\", errorHandler);\n });\n const unhandledrejectionHandler = (event) => {\n let error;\n let payload;\n if (event.reason instanceof Error) {\n error = event.reason;\n payload = [\n stringify(\n `Uncaught (in promise) ${error.name}: ${error.message}`,\n logOptions.stringifyOptions\n )\n ];\n } else {\n error = new Error();\n payload = [\n stringify(\"Uncaught (in promise)\", logOptions.stringifyOptions),\n stringify(event.reason, logOptions.stringifyOptions)\n ];\n }\n const trace = ErrorStackParser.parse(error).map(\n (stackFrame) => stackFrame.toString()\n );\n cb({\n level: \"error\",\n trace,\n payload\n });\n };\n win.addEventListener(\"unhandledrejection\", unhandledrejectionHandler);\n cancelHandlers.push(() => {\n win.removeEventListener(\"unhandledrejection\", unhandledrejectionHandler);\n });\n }\n for (const levelType of logOptions.level) {\n cancelHandlers.push(replace(logger, levelType));\n }\n return () => {\n cancelHandlers.forEach((h) => h());\n };\n function replace(_logger, level) {\n if (!_logger[level]) {\n return () => {\n };\n }\n return patch(\n _logger,\n level,\n (original) => {\n return (...args) => {\n original.apply(this, args);\n if (level === \"assert\" && !!args[0]) {\n return;\n }\n if (inStack) {\n return;\n }\n inStack = true;\n try {\n const trace = ErrorStackParser.parse(new Error()).map((stackFrame) => stackFrame.toString()).splice(1);\n const argsForPayload = level === \"assert\" ? args.slice(1) : args;\n const payload = argsForPayload.map(\n (s) => stringify(s, logOptions.stringifyOptions)\n );\n logCount++;\n if (logCount < logOptions.lengthThreshold) {\n cb({\n level,\n trace,\n payload\n });\n } else if (logCount === logOptions.lengthThreshold) {\n cb({\n level: \"warn\",\n trace: [],\n payload: [\n stringify(\"The number of log records reached the threshold.\")\n ]\n });\n }\n } catch (error) {\n original(\"rrweb logger error:\", error, ...args);\n } finally {\n inStack = false;\n }\n };\n }\n );\n }\n}\nconst PLUGIN_NAME = \"rrweb/console@1\";\nconst getRecordConsolePlugin = (options) => ({\n name: PLUGIN_NAME,\n observer: initLogObserver,\n options\n});\nexport {\n PLUGIN_NAME,\n getRecordConsolePlugin\n};\n//# sourceMappingURL=rrweb-plugin-console-record.js.map\n","var EventType = /* @__PURE__ */ ((EventType2) => {\n EventType2[EventType2[\"DomContentLoaded\"] = 0] = \"DomContentLoaded\";\n EventType2[EventType2[\"Load\"] = 1] = \"Load\";\n EventType2[EventType2[\"FullSnapshot\"] = 2] = \"FullSnapshot\";\n EventType2[EventType2[\"IncrementalSnapshot\"] = 3] = \"IncrementalSnapshot\";\n EventType2[EventType2[\"Meta\"] = 4] = \"Meta\";\n EventType2[EventType2[\"Custom\"] = 5] = \"Custom\";\n EventType2[EventType2[\"Plugin\"] = 6] = \"Plugin\";\n return EventType2;\n})(EventType || {});\nvar IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => {\n IncrementalSource2[IncrementalSource2[\"Mutation\"] = 0] = \"Mutation\";\n IncrementalSource2[IncrementalSource2[\"MouseMove\"] = 1] = \"MouseMove\";\n IncrementalSource2[IncrementalSource2[\"MouseInteraction\"] = 2] = \"MouseInteraction\";\n IncrementalSource2[IncrementalSource2[\"Scroll\"] = 3] = \"Scroll\";\n IncrementalSource2[IncrementalSource2[\"ViewportResize\"] = 4] = \"ViewportResize\";\n IncrementalSource2[IncrementalSource2[\"Input\"] = 5] = \"Input\";\n IncrementalSource2[IncrementalSource2[\"TouchMove\"] = 6] = \"TouchMove\";\n IncrementalSource2[IncrementalSource2[\"MediaInteraction\"] = 7] = \"MediaInteraction\";\n IncrementalSource2[IncrementalSource2[\"StyleSheetRule\"] = 8] = \"StyleSheetRule\";\n IncrementalSource2[IncrementalSource2[\"CanvasMutation\"] = 9] = \"CanvasMutation\";\n IncrementalSource2[IncrementalSource2[\"Font\"] = 10] = \"Font\";\n IncrementalSource2[IncrementalSource2[\"Log\"] = 11] = \"Log\";\n IncrementalSource2[IncrementalSource2[\"Drag\"] = 12] = \"Drag\";\n IncrementalSource2[IncrementalSource2[\"StyleDeclaration\"] = 13] = \"StyleDeclaration\";\n IncrementalSource2[IncrementalSource2[\"Selection\"] = 14] = \"Selection\";\n IncrementalSource2[IncrementalSource2[\"AdoptedStyleSheet\"] = 15] = \"AdoptedStyleSheet\";\n IncrementalSource2[IncrementalSource2[\"CustomElement\"] = 16] = \"CustomElement\";\n return IncrementalSource2;\n})(IncrementalSource || {});\nvar MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {\n MouseInteractions2[MouseInteractions2[\"MouseUp\"] = 0] = \"MouseUp\";\n MouseInteractions2[MouseInteractions2[\"MouseDown\"] = 1] = \"MouseDown\";\n MouseInteractions2[MouseInteractions2[\"Click\"] = 2] = \"Click\";\n MouseInteractions2[MouseInteractions2[\"ContextMenu\"] = 3] = \"ContextMenu\";\n MouseInteractions2[MouseInteractions2[\"DblClick\"] = 4] = \"DblClick\";\n MouseInteractions2[MouseInteractions2[\"Focus\"] = 5] = \"Focus\";\n MouseInteractions2[MouseInteractions2[\"Blur\"] = 6] = \"Blur\";\n MouseInteractions2[MouseInteractions2[\"TouchStart\"] = 7] = \"TouchStart\";\n MouseInteractions2[MouseInteractions2[\"TouchMove_Departed\"] = 8] = \"TouchMove_Departed\";\n MouseInteractions2[MouseInteractions2[\"TouchEnd\"] = 9] = \"TouchEnd\";\n MouseInteractions2[MouseInteractions2[\"TouchCancel\"] = 10] = \"TouchCancel\";\n return MouseInteractions2;\n})(MouseInteractions || {});\nvar PointerTypes = /* @__PURE__ */ ((PointerTypes2) => {\n PointerTypes2[PointerTypes2[\"Mouse\"] = 0] = \"Mouse\";\n PointerTypes2[PointerTypes2[\"Pen\"] = 1] = \"Pen\";\n PointerTypes2[PointerTypes2[\"Touch\"] = 2] = \"Touch\";\n return PointerTypes2;\n})(PointerTypes || {});\nvar CanvasContext = /* @__PURE__ */ ((CanvasContext2) => {\n CanvasContext2[CanvasContext2[\"2D\"] = 0] = \"2D\";\n CanvasContext2[CanvasContext2[\"WebGL\"] = 1] = \"WebGL\";\n CanvasContext2[CanvasContext2[\"WebGL2\"] = 2] = \"WebGL2\";\n return CanvasContext2;\n})(CanvasContext || {});\nvar MediaInteractions = /* @__PURE__ */ ((MediaInteractions2) => {\n MediaInteractions2[MediaInteractions2[\"Play\"] = 0] = \"Play\";\n MediaInteractions2[MediaInteractions2[\"Pause\"] = 1] = \"Pause\";\n MediaInteractions2[MediaInteractions2[\"Seeked\"] = 2] = \"Seeked\";\n MediaInteractions2[MediaInteractions2[\"VolumeChange\"] = 3] = \"VolumeChange\";\n MediaInteractions2[MediaInteractions2[\"RateChange\"] = 4] = \"RateChange\";\n return MediaInteractions2;\n})(MediaInteractions || {});\nvar ReplayerEvents = /* @__PURE__ */ ((ReplayerEvents2) => {\n ReplayerEvents2[\"Start\"] = \"start\";\n ReplayerEvents2[\"Pause\"] = \"pause\";\n ReplayerEvents2[\"Resume\"] = \"resume\";\n ReplayerEvents2[\"Resize\"] = \"resize\";\n ReplayerEvents2[\"Finish\"] = \"finish\";\n ReplayerEvents2[\"FullsnapshotRebuilded\"] = \"fullsnapshot-rebuilded\";\n ReplayerEvents2[\"LoadStylesheetStart\"] = \"load-stylesheet-start\";\n ReplayerEvents2[\"LoadStylesheetEnd\"] = \"load-stylesheet-end\";\n ReplayerEvents2[\"SkipStart\"] = \"skip-start\";\n ReplayerEvents2[\"SkipEnd\"] = \"skip-end\";\n ReplayerEvents2[\"MouseInteraction\"] = \"mouse-interaction\";\n ReplayerEvents2[\"EventCast\"] = \"event-cast\";\n ReplayerEvents2[\"CustomEvent\"] = \"custom-event\";\n ReplayerEvents2[\"Flush\"] = \"flush\";\n ReplayerEvents2[\"StateChange\"] = \"state-change\";\n ReplayerEvents2[\"PlayBack\"] = \"play-back\";\n ReplayerEvents2[\"Destroy\"] = \"destroy\";\n return ReplayerEvents2;\n})(ReplayerEvents || {});\nvar NodeType = /* @__PURE__ */ ((NodeType2) => {\n NodeType2[NodeType2[\"Document\"] = 0] = \"Document\";\n NodeType2[NodeType2[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType2[NodeType2[\"Element\"] = 2] = \"Element\";\n NodeType2[NodeType2[\"Text\"] = 3] = \"Text\";\n NodeType2[NodeType2[\"CDATA\"] = 4] = \"CDATA\";\n NodeType2[NodeType2[\"Comment\"] = 5] = \"Comment\";\n return NodeType2;\n})(NodeType || {});\nexport {\n CanvasContext,\n EventType,\n IncrementalSource,\n MediaInteractions,\n MouseInteractions,\n NodeType,\n PointerTypes,\n ReplayerEvents\n};\n//# sourceMappingURL=types.js.map\n","import {\n type LogLevel,\n type LogData,\n PLUGIN_NAME,\n} from '@betterbugs/rrweb-plugin-console-record';\nimport type { eventWithTime } from '@betterbugs/types';\nimport { EventType, IncrementalSource } from '@betterbugs/types';\nimport type { ReplayPlugin, Replayer } from '@betterbugs/rrweb';\n\n/**\n * define an interface to replay log records\n * (data: logData) => void> function to display the log data\n */\ntype ReplayLogger = Partial<Record<LogLevel, (data: LogData) => void>>;\n\ntype LogReplayConfig = {\n level?: LogLevel[];\n replayLogger?: ReplayLogger;\n};\n\nconst ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\ntype PatchedConsoleLog = {\n [ORIGINAL_ATTRIBUTE_NAME]: typeof console.log;\n};\n\nconst defaultLogConfig: LogReplayConfig = {\n level: [\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n 'group',\n 'groupCollapsed',\n 'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n ],\n replayLogger: undefined,\n};\n\nclass LogReplayPlugin {\n private config: LogReplayConfig;\n\n constructor(config?: LogReplayConfig) {\n this.config = Object.assign(defaultLogConfig, config);\n }\n\n /**\n * generate a console log replayer which implement the interface ReplayLogger\n */\n public getConsoleLogger(): ReplayLogger {\n const replayLogger: ReplayLogger = {};\n for (const level of this.config.level!) {\n if (level === 'trace') {\n replayLogger[level] = (data: LogData) => {\n const logger = (console.log as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? (console.log as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console.log;\n logger(\n ...data.payload.map((s) => JSON.parse(s) as object),\n this.formatMessage(data),\n );\n };\n } else {\n replayLogger[level] = (data: LogData) => {\n const logger = (console[level] as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? (console[level] as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console[level];\n logger(\n ...data.payload.map((s) => JSON.parse(s) as object),\n this.formatMessage(data),\n );\n };\n }\n }\n return replayLogger;\n }\n\n /**\n * format the trace data to a string\n * @param data - the log data\n */\n private formatMessage(data: LogData): string {\n if (data.trace.length === 0) {\n return '';\n }\n const stackPrefix = '\\n\\tat ';\n let result = stackPrefix;\n result += data.trace.join(stackPrefix);\n return result;\n }\n}\n\nexport const getReplayConsolePlugin: (\n options?: LogReplayConfig,\n) => ReplayPlugin = (options) => {\n const replayLogger =\n options?.replayLogger || new LogReplayPlugin(options).getConsoleLogger();\n\n return {\n handler(\n event: eventWithTime,\n _isSync: boolean,\n context: { replayer: Replayer },\n ) {\n let logData: LogData | null = null;\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === (IncrementalSource.Log as IncrementalSource)\n ) {\n logData = event.data as unknown as LogData;\n } else if (\n event.type === EventType.Plugin &&\n event.data.plugin === PLUGIN_NAME\n ) {\n logData = event.data.payload as LogData;\n }\n if (logData) {\n try {\n if (typeof replayLogger[logData.level] === 'function') {\n replayLogger[logData.level]!(logData);\n }\n } catch (error) {\n if (context.replayer.config.showWarning) {\n console.warn(error);\n }\n }\n }\n },\n };\n};\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
const PLUGIN_NAME = "rrweb/console@1";
|
|
5
|
+
var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
6
|
+
EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
|
|
7
|
+
EventType2[EventType2["Load"] = 1] = "Load";
|
|
8
|
+
EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
|
|
9
|
+
EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
|
|
10
|
+
EventType2[EventType2["Meta"] = 4] = "Meta";
|
|
11
|
+
EventType2[EventType2["Custom"] = 5] = "Custom";
|
|
12
|
+
EventType2[EventType2["Plugin"] = 6] = "Plugin";
|
|
13
|
+
return EventType2;
|
|
14
|
+
})(EventType || {});
|
|
15
|
+
var IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => {
|
|
16
|
+
IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
|
|
17
|
+
IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
|
|
18
|
+
IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
|
|
19
|
+
IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
|
|
20
|
+
IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
|
|
21
|
+
IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
|
|
22
|
+
IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
|
|
23
|
+
IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
|
|
24
|
+
IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
|
|
25
|
+
IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
|
|
26
|
+
IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
|
|
27
|
+
IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
|
|
28
|
+
IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
|
|
29
|
+
IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
|
|
30
|
+
IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
|
|
31
|
+
IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
|
|
32
|
+
IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
|
|
33
|
+
return IncrementalSource2;
|
|
34
|
+
})(IncrementalSource || {});
|
|
35
|
+
const ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
|
|
36
|
+
const defaultLogConfig = {
|
|
37
|
+
level: [
|
|
38
|
+
"assert",
|
|
39
|
+
"clear",
|
|
40
|
+
"count",
|
|
41
|
+
"countReset",
|
|
42
|
+
"debug",
|
|
43
|
+
"dir",
|
|
44
|
+
"dirxml",
|
|
45
|
+
"error",
|
|
46
|
+
"group",
|
|
47
|
+
"groupCollapsed",
|
|
48
|
+
"groupEnd",
|
|
49
|
+
"info",
|
|
50
|
+
"log",
|
|
51
|
+
"table",
|
|
52
|
+
"time",
|
|
53
|
+
"timeEnd",
|
|
54
|
+
"timeLog",
|
|
55
|
+
"trace",
|
|
56
|
+
"warn"
|
|
57
|
+
],
|
|
58
|
+
replayLogger: void 0
|
|
59
|
+
};
|
|
60
|
+
class LogReplayPlugin {
|
|
61
|
+
constructor(config) {
|
|
62
|
+
__publicField(this, "config");
|
|
63
|
+
this.config = Object.assign(defaultLogConfig, config);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* generate a console log replayer which implement the interface ReplayLogger
|
|
67
|
+
*/
|
|
68
|
+
getConsoleLogger() {
|
|
69
|
+
const replayLogger = {};
|
|
70
|
+
for (const level of this.config.level) {
|
|
71
|
+
if (level === "trace") {
|
|
72
|
+
replayLogger[level] = (data) => {
|
|
73
|
+
const logger = console.log[ORIGINAL_ATTRIBUTE_NAME] ? console.log[ORIGINAL_ATTRIBUTE_NAME] : console.log;
|
|
74
|
+
logger(
|
|
75
|
+
...data.payload.map((s) => JSON.parse(s)),
|
|
76
|
+
this.formatMessage(data)
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
} else {
|
|
80
|
+
replayLogger[level] = (data) => {
|
|
81
|
+
const logger = console[level][ORIGINAL_ATTRIBUTE_NAME] ? console[level][ORIGINAL_ATTRIBUTE_NAME] : console[level];
|
|
82
|
+
logger(
|
|
83
|
+
...data.payload.map((s) => JSON.parse(s)),
|
|
84
|
+
this.formatMessage(data)
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return replayLogger;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* format the trace data to a string
|
|
93
|
+
* @param data - the log data
|
|
94
|
+
*/
|
|
95
|
+
formatMessage(data) {
|
|
96
|
+
if (data.trace.length === 0) {
|
|
97
|
+
return "";
|
|
98
|
+
}
|
|
99
|
+
const stackPrefix = "\n at ";
|
|
100
|
+
let result = stackPrefix;
|
|
101
|
+
result += data.trace.join(stackPrefix);
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const getReplayConsolePlugin = (options) => {
|
|
106
|
+
const replayLogger = (options == null ? void 0 : options.replayLogger) || new LogReplayPlugin(options).getConsoleLogger();
|
|
107
|
+
return {
|
|
108
|
+
handler(event, _isSync, context) {
|
|
109
|
+
let logData = null;
|
|
110
|
+
if (event.type === EventType.IncrementalSnapshot && event.data.source === IncrementalSource.Log) {
|
|
111
|
+
logData = event.data;
|
|
112
|
+
} else if (event.type === EventType.Plugin && event.data.plugin === PLUGIN_NAME) {
|
|
113
|
+
logData = event.data.payload;
|
|
114
|
+
}
|
|
115
|
+
if (logData) {
|
|
116
|
+
try {
|
|
117
|
+
if (typeof replayLogger[logData.level] === "function") {
|
|
118
|
+
replayLogger[logData.level](logData);
|
|
119
|
+
}
|
|
120
|
+
} catch (error) {
|
|
121
|
+
if (context.replayer.config.showWarning) {
|
|
122
|
+
console.warn(error);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
export {
|
|
130
|
+
getReplayConsolePlugin
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=rrweb-plugin-console-replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rrweb-plugin-console-replay.js","sources":["../../rrweb-plugin-console-record/dist/rrweb-plugin-console-record.js","../../../types/dist/types.js","../src/index.ts"],"sourcesContent":["var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nfunction patch(source, name, replacement) {\n try {\n if (!(name in source)) {\n return () => {\n };\n }\n const original = source[name];\n const wrapped = replacement(original);\n if (typeof wrapped === \"function\") {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original\n }\n });\n }\n source[name] = wrapped;\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {\n };\n }\n}\nclass StackFrame {\n constructor(obj) {\n __publicField(this, \"fileName\");\n __publicField(this, \"functionName\");\n __publicField(this, \"lineNumber\");\n __publicField(this, \"columnNumber\");\n this.fileName = obj.fileName || \"\";\n this.functionName = obj.functionName || \"\";\n this.lineNumber = obj.lineNumber;\n this.columnNumber = obj.columnNumber;\n }\n toString() {\n const lineNumber = this.lineNumber || \"\";\n const columnNumber = this.columnNumber || \"\";\n if (this.functionName)\n return `${this.functionName} (${this.fileName}:${lineNumber}:${columnNumber})`;\n return `${this.fileName}:${lineNumber}:${columnNumber}`;\n }\n}\nconst FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\\S+:\\d+/;\nconst CHROME_IE_STACK_REGEXP = /^\\s*at .*(\\S+:\\d+|\\(native\\))/m;\nconst SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\\[native code])?$/;\nconst ErrorStackParser = {\n /**\n * Given an Error object, extract the most information from it.\n */\n parse: function(error) {\n if (!error) {\n return [];\n }\n if (\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n typeof error.stacktrace !== \"undefined\" || // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n typeof error[\"opera#sourceloc\"] !== \"undefined\"\n ) {\n return this.parseOpera(\n error\n );\n } else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {\n return this.parseV8OrIE(error);\n } else if (error.stack) {\n return this.parseFFOrSafari(error);\n } else {\n console.warn(\n \"[console-record-plugin]: Failed to parse error object:\",\n error\n );\n return [];\n }\n },\n // Separate line and column numbers from a string of the form: (URI:Line:Column)\n extractLocation: function(urlLike) {\n if (urlLike.indexOf(\":\") === -1) {\n return [urlLike];\n }\n const regExp = /(.+?)(?::(\\d+))?(?::(\\d+))?$/;\n const parts = regExp.exec(urlLike.replace(/[()]/g, \"\"));\n if (!parts) throw new Error(`Cannot parse given url: ${urlLike}`);\n return [parts[1], parts[2] || void 0, parts[3] || void 0];\n },\n parseV8OrIE: function(error) {\n const filtered = error.stack.split(\"\\n\").filter(function(line) {\n return !!line.match(CHROME_IE_STACK_REGEXP);\n }, this);\n return filtered.map(function(line) {\n if (line.indexOf(\"(eval \") > -1) {\n line = line.replace(/eval code/g, \"eval\").replace(/(\\(eval at [^()]*)|(\\),.*$)/g, \"\");\n }\n let sanitizedLine = line.replace(/^\\s+/, \"\").replace(/\\(eval code/g, \"(\");\n const location = sanitizedLine.match(/ (\\((.+):(\\d+):(\\d+)\\)$)/);\n sanitizedLine = location ? sanitizedLine.replace(location[0], \"\") : sanitizedLine;\n const tokens = sanitizedLine.split(/\\s+/).slice(1);\n const locationParts = this.extractLocation(\n location ? location[1] : tokens.pop()\n );\n const functionName = tokens.join(\" \") || void 0;\n const fileName = [\"eval\", \"<anonymous>\"].indexOf(locationParts[0]) > -1 ? void 0 : locationParts[0];\n return new StackFrame({\n functionName,\n fileName,\n lineNumber: locationParts[1],\n columnNumber: locationParts[2]\n });\n }, this);\n },\n parseFFOrSafari: function(error) {\n const filtered = error.stack.split(\"\\n\").filter(function(line) {\n return !line.match(SAFARI_NATIVE_CODE_REGEXP);\n }, this);\n return filtered.map(function(line) {\n if (line.indexOf(\" > eval\") > -1) {\n line = line.replace(\n / line (\\d+)(?: > eval line \\d+)* > eval:\\d+:\\d+/g,\n \":$1\"\n );\n }\n if (line.indexOf(\"@\") === -1 && line.indexOf(\":\") === -1) {\n return new StackFrame({\n functionName: line\n });\n } else {\n const functionNameRegex = /((.*\".+\"[^@]*)?[^@]*)(?:@)/;\n const matches = line.match(functionNameRegex);\n const functionName = matches && matches[1] ? matches[1] : void 0;\n const locationParts = this.extractLocation(\n line.replace(functionNameRegex, \"\")\n );\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2]\n });\n }\n }, this);\n },\n parseOpera: function(e) {\n if (!e.stacktrace || e.message.indexOf(\"\\n\") > -1 && e.message.split(\"\\n\").length > e.stacktrace.split(\"\\n\").length) {\n return this.parseOpera9(e);\n } else if (!e.stack) {\n return this.parseOpera10(e);\n } else {\n return this.parseOpera11(e);\n }\n },\n parseOpera9: function(e) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)/i;\n const lines = e.message.split(\"\\n\");\n const result = [];\n for (let i = 2, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n fileName: match[2],\n lineNumber: parseFloat(match[1])\n })\n );\n }\n }\n return result;\n },\n parseOpera10: function(e) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)(?:: In function (\\S+))?$/i;\n const lines = e.stacktrace.split(\"\\n\");\n const result = [];\n for (let i = 0, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n functionName: match[3] || void 0,\n fileName: match[2],\n lineNumber: parseFloat(match[1])\n })\n );\n }\n }\n return result;\n },\n // Opera 10.65+ Error.stack very similar to FF/Safari\n parseOpera11: function(error) {\n const filtered = error.stack.split(\"\\n\").filter(function(line) {\n return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);\n }, this);\n return filtered.map(function(line) {\n const tokens = line.split(\"@\");\n const locationParts = this.extractLocation(tokens.pop());\n const functionCall = tokens.shift() || \"\";\n const functionName = functionCall.replace(/<anonymous function(: (\\w+))?>/, \"$2\").replace(/\\([^)]*\\)/g, \"\") || void 0;\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2]\n });\n }, this);\n }\n};\nfunction pathToSelector(node) {\n if (!node || !node.outerHTML) {\n return \"\";\n }\n let path = \"\";\n while (node.parentElement) {\n let name = node.localName;\n if (!name) {\n break;\n }\n name = name.toLowerCase();\n const parent = node.parentElement;\n const domSiblings = [];\n if (parent.children && parent.children.length > 0) {\n for (let i = 0; i < parent.children.length; i++) {\n const sibling = parent.children[i];\n if (sibling.localName && sibling.localName.toLowerCase) {\n if (sibling.localName.toLowerCase() === name) {\n domSiblings.push(sibling);\n }\n }\n }\n }\n if (domSiblings.length > 1) {\n name += `:eq(${domSiblings.indexOf(node)})`;\n }\n path = name + (path ? \">\" + path : \"\");\n node = parent;\n }\n return path;\n}\nfunction isObject(obj) {\n return Object.prototype.toString.call(obj) === \"[object Object]\";\n}\nfunction isObjTooDeep(obj, limit) {\n if (limit === 0) {\n return true;\n }\n const keys = Object.keys(obj);\n for (const key of keys) {\n if (isObject(obj[key]) && isObjTooDeep(obj[key], limit - 1)) {\n return true;\n }\n }\n return false;\n}\nfunction stringify(obj, stringifyOptions) {\n const options = {\n numOfKeysLimit: 50,\n depthOfLimit: 4\n };\n Object.assign(options, stringifyOptions);\n const stack = [];\n const keys = [];\n return JSON.stringify(\n obj,\n function(key, value) {\n if (stack.length > 0) {\n const thisPos = stack.indexOf(this);\n ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);\n ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);\n if (~stack.indexOf(value)) {\n if (stack[0] === value) {\n value = \"[Circular ~]\";\n } else {\n value = \"[Circular ~.\" + keys.slice(0, stack.indexOf(value)).join(\".\") + \"]\";\n }\n }\n } else {\n stack.push(value);\n }\n if (value === null) return value;\n if (value === void 0) return \"undefined\";\n if (shouldIgnore(value)) {\n return toString(value);\n }\n if (typeof value === \"bigint\") {\n return value.toString() + \"n\";\n }\n if (value instanceof Event) {\n const eventResult = {};\n for (const eventKey in value) {\n const eventValue = value[eventKey];\n if (Array.isArray(eventValue)) {\n eventResult[eventKey] = pathToSelector(\n eventValue.length ? eventValue[0] : null\n );\n } else {\n eventResult[eventKey] = eventValue;\n }\n }\n return eventResult;\n } else if (value instanceof Node) {\n if (value instanceof HTMLElement) {\n return value ? value.outerHTML : \"\";\n }\n return value.nodeName;\n } else if (value instanceof Error) {\n return value.stack ? value.stack + \"\\nEnd of stack for Error object\" : value.name + \": \" + value.message;\n }\n return value;\n }\n );\n function shouldIgnore(_obj) {\n if (isObject(_obj) && Object.keys(_obj).length > options.numOfKeysLimit) {\n return true;\n }\n if (typeof _obj === \"function\") {\n return true;\n }\n if (isObject(_obj) && isObjTooDeep(_obj, options.depthOfLimit)) {\n return true;\n }\n return false;\n }\n function toString(_obj) {\n let str = _obj.toString();\n if (options.stringLengthLimit && str.length > options.stringLengthLimit) {\n str = `${str.slice(0, options.stringLengthLimit)}...`;\n }\n return str;\n }\n}\nconst defaultLogOptions = {\n level: [\n \"assert\",\n \"clear\",\n \"count\",\n \"countReset\",\n \"debug\",\n \"dir\",\n \"dirxml\",\n \"error\",\n \"group\",\n \"groupCollapsed\",\n \"groupEnd\",\n \"info\",\n \"log\",\n \"table\",\n \"time\",\n \"timeEnd\",\n \"timeLog\",\n \"trace\",\n \"warn\"\n ],\n lengthThreshold: 1e3,\n logger: \"console\"\n};\nfunction initLogObserver(cb, win, options) {\n const logOptions = options ? Object.assign({}, defaultLogOptions, options) : defaultLogOptions;\n const loggerType = logOptions.logger;\n if (!loggerType) {\n return () => {\n };\n }\n let logger;\n if (typeof loggerType === \"string\") {\n logger = win[loggerType];\n } else {\n logger = loggerType;\n }\n let logCount = 0;\n let inStack = false;\n const cancelHandlers = [];\n if (logOptions.level.includes(\"error\")) {\n const errorHandler = (event) => {\n const message = event.message, error = event.error;\n const trace = ErrorStackParser.parse(error).map(\n (stackFrame) => stackFrame.toString()\n );\n const payload = [stringify(message, logOptions.stringifyOptions)];\n cb({\n level: \"error\",\n trace,\n payload\n });\n };\n win.addEventListener(\"error\", errorHandler);\n cancelHandlers.push(() => {\n win.removeEventListener(\"error\", errorHandler);\n });\n const unhandledrejectionHandler = (event) => {\n let error;\n let payload;\n if (event.reason instanceof Error) {\n error = event.reason;\n payload = [\n stringify(\n `Uncaught (in promise) ${error.name}: ${error.message}`,\n logOptions.stringifyOptions\n )\n ];\n } else {\n error = new Error();\n payload = [\n stringify(\"Uncaught (in promise)\", logOptions.stringifyOptions),\n stringify(event.reason, logOptions.stringifyOptions)\n ];\n }\n const trace = ErrorStackParser.parse(error).map(\n (stackFrame) => stackFrame.toString()\n );\n cb({\n level: \"error\",\n trace,\n payload\n });\n };\n win.addEventListener(\"unhandledrejection\", unhandledrejectionHandler);\n cancelHandlers.push(() => {\n win.removeEventListener(\"unhandledrejection\", unhandledrejectionHandler);\n });\n }\n for (const levelType of logOptions.level) {\n cancelHandlers.push(replace(logger, levelType));\n }\n return () => {\n cancelHandlers.forEach((h) => h());\n };\n function replace(_logger, level) {\n if (!_logger[level]) {\n return () => {\n };\n }\n return patch(\n _logger,\n level,\n (original) => {\n return (...args) => {\n original.apply(this, args);\n if (level === \"assert\" && !!args[0]) {\n return;\n }\n if (inStack) {\n return;\n }\n inStack = true;\n try {\n const trace = ErrorStackParser.parse(new Error()).map((stackFrame) => stackFrame.toString()).splice(1);\n const argsForPayload = level === \"assert\" ? args.slice(1) : args;\n const payload = argsForPayload.map(\n (s) => stringify(s, logOptions.stringifyOptions)\n );\n logCount++;\n if (logCount < logOptions.lengthThreshold) {\n cb({\n level,\n trace,\n payload\n });\n } else if (logCount === logOptions.lengthThreshold) {\n cb({\n level: \"warn\",\n trace: [],\n payload: [\n stringify(\"The number of log records reached the threshold.\")\n ]\n });\n }\n } catch (error) {\n original(\"rrweb logger error:\", error, ...args);\n } finally {\n inStack = false;\n }\n };\n }\n );\n }\n}\nconst PLUGIN_NAME = \"rrweb/console@1\";\nconst getRecordConsolePlugin = (options) => ({\n name: PLUGIN_NAME,\n observer: initLogObserver,\n options\n});\nexport {\n PLUGIN_NAME,\n getRecordConsolePlugin\n};\n//# sourceMappingURL=rrweb-plugin-console-record.js.map\n","var EventType = /* @__PURE__ */ ((EventType2) => {\n EventType2[EventType2[\"DomContentLoaded\"] = 0] = \"DomContentLoaded\";\n EventType2[EventType2[\"Load\"] = 1] = \"Load\";\n EventType2[EventType2[\"FullSnapshot\"] = 2] = \"FullSnapshot\";\n EventType2[EventType2[\"IncrementalSnapshot\"] = 3] = \"IncrementalSnapshot\";\n EventType2[EventType2[\"Meta\"] = 4] = \"Meta\";\n EventType2[EventType2[\"Custom\"] = 5] = \"Custom\";\n EventType2[EventType2[\"Plugin\"] = 6] = \"Plugin\";\n return EventType2;\n})(EventType || {});\nvar IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => {\n IncrementalSource2[IncrementalSource2[\"Mutation\"] = 0] = \"Mutation\";\n IncrementalSource2[IncrementalSource2[\"MouseMove\"] = 1] = \"MouseMove\";\n IncrementalSource2[IncrementalSource2[\"MouseInteraction\"] = 2] = \"MouseInteraction\";\n IncrementalSource2[IncrementalSource2[\"Scroll\"] = 3] = \"Scroll\";\n IncrementalSource2[IncrementalSource2[\"ViewportResize\"] = 4] = \"ViewportResize\";\n IncrementalSource2[IncrementalSource2[\"Input\"] = 5] = \"Input\";\n IncrementalSource2[IncrementalSource2[\"TouchMove\"] = 6] = \"TouchMove\";\n IncrementalSource2[IncrementalSource2[\"MediaInteraction\"] = 7] = \"MediaInteraction\";\n IncrementalSource2[IncrementalSource2[\"StyleSheetRule\"] = 8] = \"StyleSheetRule\";\n IncrementalSource2[IncrementalSource2[\"CanvasMutation\"] = 9] = \"CanvasMutation\";\n IncrementalSource2[IncrementalSource2[\"Font\"] = 10] = \"Font\";\n IncrementalSource2[IncrementalSource2[\"Log\"] = 11] = \"Log\";\n IncrementalSource2[IncrementalSource2[\"Drag\"] = 12] = \"Drag\";\n IncrementalSource2[IncrementalSource2[\"StyleDeclaration\"] = 13] = \"StyleDeclaration\";\n IncrementalSource2[IncrementalSource2[\"Selection\"] = 14] = \"Selection\";\n IncrementalSource2[IncrementalSource2[\"AdoptedStyleSheet\"] = 15] = \"AdoptedStyleSheet\";\n IncrementalSource2[IncrementalSource2[\"CustomElement\"] = 16] = \"CustomElement\";\n return IncrementalSource2;\n})(IncrementalSource || {});\nvar MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {\n MouseInteractions2[MouseInteractions2[\"MouseUp\"] = 0] = \"MouseUp\";\n MouseInteractions2[MouseInteractions2[\"MouseDown\"] = 1] = \"MouseDown\";\n MouseInteractions2[MouseInteractions2[\"Click\"] = 2] = \"Click\";\n MouseInteractions2[MouseInteractions2[\"ContextMenu\"] = 3] = \"ContextMenu\";\n MouseInteractions2[MouseInteractions2[\"DblClick\"] = 4] = \"DblClick\";\n MouseInteractions2[MouseInteractions2[\"Focus\"] = 5] = \"Focus\";\n MouseInteractions2[MouseInteractions2[\"Blur\"] = 6] = \"Blur\";\n MouseInteractions2[MouseInteractions2[\"TouchStart\"] = 7] = \"TouchStart\";\n MouseInteractions2[MouseInteractions2[\"TouchMove_Departed\"] = 8] = \"TouchMove_Departed\";\n MouseInteractions2[MouseInteractions2[\"TouchEnd\"] = 9] = \"TouchEnd\";\n MouseInteractions2[MouseInteractions2[\"TouchCancel\"] = 10] = \"TouchCancel\";\n return MouseInteractions2;\n})(MouseInteractions || {});\nvar PointerTypes = /* @__PURE__ */ ((PointerTypes2) => {\n PointerTypes2[PointerTypes2[\"Mouse\"] = 0] = \"Mouse\";\n PointerTypes2[PointerTypes2[\"Pen\"] = 1] = \"Pen\";\n PointerTypes2[PointerTypes2[\"Touch\"] = 2] = \"Touch\";\n return PointerTypes2;\n})(PointerTypes || {});\nvar CanvasContext = /* @__PURE__ */ ((CanvasContext2) => {\n CanvasContext2[CanvasContext2[\"2D\"] = 0] = \"2D\";\n CanvasContext2[CanvasContext2[\"WebGL\"] = 1] = \"WebGL\";\n CanvasContext2[CanvasContext2[\"WebGL2\"] = 2] = \"WebGL2\";\n return CanvasContext2;\n})(CanvasContext || {});\nvar MediaInteractions = /* @__PURE__ */ ((MediaInteractions2) => {\n MediaInteractions2[MediaInteractions2[\"Play\"] = 0] = \"Play\";\n MediaInteractions2[MediaInteractions2[\"Pause\"] = 1] = \"Pause\";\n MediaInteractions2[MediaInteractions2[\"Seeked\"] = 2] = \"Seeked\";\n MediaInteractions2[MediaInteractions2[\"VolumeChange\"] = 3] = \"VolumeChange\";\n MediaInteractions2[MediaInteractions2[\"RateChange\"] = 4] = \"RateChange\";\n return MediaInteractions2;\n})(MediaInteractions || {});\nvar ReplayerEvents = /* @__PURE__ */ ((ReplayerEvents2) => {\n ReplayerEvents2[\"Start\"] = \"start\";\n ReplayerEvents2[\"Pause\"] = \"pause\";\n ReplayerEvents2[\"Resume\"] = \"resume\";\n ReplayerEvents2[\"Resize\"] = \"resize\";\n ReplayerEvents2[\"Finish\"] = \"finish\";\n ReplayerEvents2[\"FullsnapshotRebuilded\"] = \"fullsnapshot-rebuilded\";\n ReplayerEvents2[\"LoadStylesheetStart\"] = \"load-stylesheet-start\";\n ReplayerEvents2[\"LoadStylesheetEnd\"] = \"load-stylesheet-end\";\n ReplayerEvents2[\"SkipStart\"] = \"skip-start\";\n ReplayerEvents2[\"SkipEnd\"] = \"skip-end\";\n ReplayerEvents2[\"MouseInteraction\"] = \"mouse-interaction\";\n ReplayerEvents2[\"EventCast\"] = \"event-cast\";\n ReplayerEvents2[\"CustomEvent\"] = \"custom-event\";\n ReplayerEvents2[\"Flush\"] = \"flush\";\n ReplayerEvents2[\"StateChange\"] = \"state-change\";\n ReplayerEvents2[\"PlayBack\"] = \"play-back\";\n ReplayerEvents2[\"Destroy\"] = \"destroy\";\n return ReplayerEvents2;\n})(ReplayerEvents || {});\nvar NodeType = /* @__PURE__ */ ((NodeType2) => {\n NodeType2[NodeType2[\"Document\"] = 0] = \"Document\";\n NodeType2[NodeType2[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType2[NodeType2[\"Element\"] = 2] = \"Element\";\n NodeType2[NodeType2[\"Text\"] = 3] = \"Text\";\n NodeType2[NodeType2[\"CDATA\"] = 4] = \"CDATA\";\n NodeType2[NodeType2[\"Comment\"] = 5] = \"Comment\";\n return NodeType2;\n})(NodeType || {});\nexport {\n CanvasContext,\n EventType,\n IncrementalSource,\n MediaInteractions,\n MouseInteractions,\n NodeType,\n PointerTypes,\n ReplayerEvents\n};\n//# sourceMappingURL=types.js.map\n","import {\n type LogLevel,\n type LogData,\n PLUGIN_NAME,\n} from '@betterbugs/rrweb-plugin-console-record';\nimport type { eventWithTime } from '@betterbugs/types';\nimport { EventType, IncrementalSource } from '@betterbugs/types';\nimport type { ReplayPlugin, Replayer } from '@betterbugs/rrweb';\n\n/**\n * define an interface to replay log records\n * (data: logData) => void> function to display the log data\n */\ntype ReplayLogger = Partial<Record<LogLevel, (data: LogData) => void>>;\n\ntype LogReplayConfig = {\n level?: LogLevel[];\n replayLogger?: ReplayLogger;\n};\n\nconst ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\ntype PatchedConsoleLog = {\n [ORIGINAL_ATTRIBUTE_NAME]: typeof console.log;\n};\n\nconst defaultLogConfig: LogReplayConfig = {\n level: [\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n 'group',\n 'groupCollapsed',\n 'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n ],\n replayLogger: undefined,\n};\n\nclass LogReplayPlugin {\n private config: LogReplayConfig;\n\n constructor(config?: LogReplayConfig) {\n this.config = Object.assign(defaultLogConfig, config);\n }\n\n /**\n * generate a console log replayer which implement the interface ReplayLogger\n */\n public getConsoleLogger(): ReplayLogger {\n const replayLogger: ReplayLogger = {};\n for (const level of this.config.level!) {\n if (level === 'trace') {\n replayLogger[level] = (data: LogData) => {\n const logger = (console.log as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? (console.log as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console.log;\n logger(\n ...data.payload.map((s) => JSON.parse(s) as object),\n this.formatMessage(data),\n );\n };\n } else {\n replayLogger[level] = (data: LogData) => {\n const logger = (console[level] as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? (console[level] as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console[level];\n logger(\n ...data.payload.map((s) => JSON.parse(s) as object),\n this.formatMessage(data),\n );\n };\n }\n }\n return replayLogger;\n }\n\n /**\n * format the trace data to a string\n * @param data - the log data\n */\n private formatMessage(data: LogData): string {\n if (data.trace.length === 0) {\n return '';\n }\n const stackPrefix = '\\n\\tat ';\n let result = stackPrefix;\n result += data.trace.join(stackPrefix);\n return result;\n }\n}\n\nexport const getReplayConsolePlugin: (\n options?: LogReplayConfig,\n) => ReplayPlugin = (options) => {\n const replayLogger =\n options?.replayLogger || new LogReplayPlugin(options).getConsoleLogger();\n\n return {\n handler(\n event: eventWithTime,\n _isSync: boolean,\n context: { replayer: Replayer },\n ) {\n let logData: LogData | null = null;\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === (IncrementalSource.Log as IncrementalSource)\n ) {\n logData = event.data as unknown as LogData;\n } else if (\n event.type === EventType.Plugin &&\n event.data.plugin === PLUGIN_NAME\n ) {\n logData = event.data.payload as LogData;\n }\n if (logData) {\n try {\n if (typeof replayLogger[logData.level] === 'function') {\n replayLogger[logData.level]!(logData);\n }\n } catch (error) {\n if (context.replayer.config.showWarning) {\n console.warn(error);\n }\n }\n }\n },\n };\n};\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
(function (g, f) {
|
|
2
|
+
if ("object" == typeof exports && "object" == typeof module) {
|
|
3
|
+
module.exports = f();
|
|
4
|
+
} else if ("function" == typeof define && define.amd) {
|
|
5
|
+
define("rrwebPluginConsoleReplay", [], f);
|
|
6
|
+
} else if ("object" == typeof exports) {
|
|
7
|
+
exports["rrwebPluginConsoleReplay"] = f();
|
|
8
|
+
} else {
|
|
9
|
+
g["rrwebPluginConsoleReplay"] = f();
|
|
10
|
+
}
|
|
11
|
+
}(this, () => {
|
|
12
|
+
var exports = {};
|
|
13
|
+
var module = { exports };
|
|
14
|
+
"use strict";
|
|
15
|
+
var __defProp = Object.defineProperty;
|
|
16
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
17
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
18
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
19
|
+
const PLUGIN_NAME = "rrweb/console@1";
|
|
20
|
+
var EventType = /* @__PURE__ */ ((EventType2) => {
|
|
21
|
+
EventType2[EventType2["DomContentLoaded"] = 0] = "DomContentLoaded";
|
|
22
|
+
EventType2[EventType2["Load"] = 1] = "Load";
|
|
23
|
+
EventType2[EventType2["FullSnapshot"] = 2] = "FullSnapshot";
|
|
24
|
+
EventType2[EventType2["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
|
|
25
|
+
EventType2[EventType2["Meta"] = 4] = "Meta";
|
|
26
|
+
EventType2[EventType2["Custom"] = 5] = "Custom";
|
|
27
|
+
EventType2[EventType2["Plugin"] = 6] = "Plugin";
|
|
28
|
+
return EventType2;
|
|
29
|
+
})(EventType || {});
|
|
30
|
+
var IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => {
|
|
31
|
+
IncrementalSource2[IncrementalSource2["Mutation"] = 0] = "Mutation";
|
|
32
|
+
IncrementalSource2[IncrementalSource2["MouseMove"] = 1] = "MouseMove";
|
|
33
|
+
IncrementalSource2[IncrementalSource2["MouseInteraction"] = 2] = "MouseInteraction";
|
|
34
|
+
IncrementalSource2[IncrementalSource2["Scroll"] = 3] = "Scroll";
|
|
35
|
+
IncrementalSource2[IncrementalSource2["ViewportResize"] = 4] = "ViewportResize";
|
|
36
|
+
IncrementalSource2[IncrementalSource2["Input"] = 5] = "Input";
|
|
37
|
+
IncrementalSource2[IncrementalSource2["TouchMove"] = 6] = "TouchMove";
|
|
38
|
+
IncrementalSource2[IncrementalSource2["MediaInteraction"] = 7] = "MediaInteraction";
|
|
39
|
+
IncrementalSource2[IncrementalSource2["StyleSheetRule"] = 8] = "StyleSheetRule";
|
|
40
|
+
IncrementalSource2[IncrementalSource2["CanvasMutation"] = 9] = "CanvasMutation";
|
|
41
|
+
IncrementalSource2[IncrementalSource2["Font"] = 10] = "Font";
|
|
42
|
+
IncrementalSource2[IncrementalSource2["Log"] = 11] = "Log";
|
|
43
|
+
IncrementalSource2[IncrementalSource2["Drag"] = 12] = "Drag";
|
|
44
|
+
IncrementalSource2[IncrementalSource2["StyleDeclaration"] = 13] = "StyleDeclaration";
|
|
45
|
+
IncrementalSource2[IncrementalSource2["Selection"] = 14] = "Selection";
|
|
46
|
+
IncrementalSource2[IncrementalSource2["AdoptedStyleSheet"] = 15] = "AdoptedStyleSheet";
|
|
47
|
+
IncrementalSource2[IncrementalSource2["CustomElement"] = 16] = "CustomElement";
|
|
48
|
+
return IncrementalSource2;
|
|
49
|
+
})(IncrementalSource || {});
|
|
50
|
+
const ORIGINAL_ATTRIBUTE_NAME = "__rrweb_original__";
|
|
51
|
+
const defaultLogConfig = {
|
|
52
|
+
level: [
|
|
53
|
+
"assert",
|
|
54
|
+
"clear",
|
|
55
|
+
"count",
|
|
56
|
+
"countReset",
|
|
57
|
+
"debug",
|
|
58
|
+
"dir",
|
|
59
|
+
"dirxml",
|
|
60
|
+
"error",
|
|
61
|
+
"group",
|
|
62
|
+
"groupCollapsed",
|
|
63
|
+
"groupEnd",
|
|
64
|
+
"info",
|
|
65
|
+
"log",
|
|
66
|
+
"table",
|
|
67
|
+
"time",
|
|
68
|
+
"timeEnd",
|
|
69
|
+
"timeLog",
|
|
70
|
+
"trace",
|
|
71
|
+
"warn"
|
|
72
|
+
],
|
|
73
|
+
replayLogger: void 0
|
|
74
|
+
};
|
|
75
|
+
class LogReplayPlugin {
|
|
76
|
+
constructor(config) {
|
|
77
|
+
__publicField(this, "config");
|
|
78
|
+
this.config = Object.assign(defaultLogConfig, config);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* generate a console log replayer which implement the interface ReplayLogger
|
|
82
|
+
*/
|
|
83
|
+
getConsoleLogger() {
|
|
84
|
+
const replayLogger = {};
|
|
85
|
+
for (const level of this.config.level) {
|
|
86
|
+
if (level === "trace") {
|
|
87
|
+
replayLogger[level] = (data) => {
|
|
88
|
+
const logger = console.log[ORIGINAL_ATTRIBUTE_NAME] ? console.log[ORIGINAL_ATTRIBUTE_NAME] : console.log;
|
|
89
|
+
logger(
|
|
90
|
+
...data.payload.map((s) => JSON.parse(s)),
|
|
91
|
+
this.formatMessage(data)
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
} else {
|
|
95
|
+
replayLogger[level] = (data) => {
|
|
96
|
+
const logger = console[level][ORIGINAL_ATTRIBUTE_NAME] ? console[level][ORIGINAL_ATTRIBUTE_NAME] : console[level];
|
|
97
|
+
logger(
|
|
98
|
+
...data.payload.map((s) => JSON.parse(s)),
|
|
99
|
+
this.formatMessage(data)
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return replayLogger;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* format the trace data to a string
|
|
108
|
+
* @param data - the log data
|
|
109
|
+
*/
|
|
110
|
+
formatMessage(data) {
|
|
111
|
+
if (data.trace.length === 0) {
|
|
112
|
+
return "";
|
|
113
|
+
}
|
|
114
|
+
const stackPrefix = "\n at ";
|
|
115
|
+
let result = stackPrefix;
|
|
116
|
+
result += data.trace.join(stackPrefix);
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const getReplayConsolePlugin = (options) => {
|
|
121
|
+
const replayLogger = (options == null ? void 0 : options.replayLogger) || new LogReplayPlugin(options).getConsoleLogger();
|
|
122
|
+
return {
|
|
123
|
+
handler(event, _isSync, context) {
|
|
124
|
+
let logData = null;
|
|
125
|
+
if (event.type === EventType.IncrementalSnapshot && event.data.source === IncrementalSource.Log) {
|
|
126
|
+
logData = event.data;
|
|
127
|
+
} else if (event.type === EventType.Plugin && event.data.plugin === PLUGIN_NAME) {
|
|
128
|
+
logData = event.data.payload;
|
|
129
|
+
}
|
|
130
|
+
if (logData) {
|
|
131
|
+
try {
|
|
132
|
+
if (typeof replayLogger[logData.level] === "function") {
|
|
133
|
+
replayLogger[logData.level](logData);
|
|
134
|
+
}
|
|
135
|
+
} catch (error) {
|
|
136
|
+
if (context.replayer.config.showWarning) {
|
|
137
|
+
console.warn(error);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
exports.getReplayConsolePlugin = getReplayConsolePlugin;
|
|
145
|
+
if (typeof module.exports == "object" && typeof exports == "object") {
|
|
146
|
+
var __cp = (to, from, except, desc) => {
|
|
147
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
148
|
+
for (let key of Object.getOwnPropertyNames(from)) {
|
|
149
|
+
if (!Object.prototype.hasOwnProperty.call(to, key) && key !== except)
|
|
150
|
+
Object.defineProperty(to, key, {
|
|
151
|
+
get: () => from[key],
|
|
152
|
+
enumerable: !(desc = Object.getOwnPropertyDescriptor(from, key)) || desc.enumerable,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return to;
|
|
157
|
+
};
|
|
158
|
+
module.exports = __cp(module.exports, exports);
|
|
159
|
+
}
|
|
160
|
+
return module.exports;
|
|
161
|
+
}))
|
|
162
|
+
//# sourceMappingURL=rrweb-plugin-console-replay.umd.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../rrweb-plugin-console-record/dist/rrweb-plugin-console-record.js", "../../../types/dist/types.js", "../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nfunction patch(source, name, replacement) {\n try {\n if (!(name in source)) {\n return () => {\n };\n }\n const original = source[name];\n const wrapped = replacement(original);\n if (typeof wrapped === \"function\") {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original\n }\n });\n }\n source[name] = wrapped;\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {\n };\n }\n}\nclass StackFrame {\n constructor(obj) {\n __publicField(this, \"fileName\");\n __publicField(this, \"functionName\");\n __publicField(this, \"lineNumber\");\n __publicField(this, \"columnNumber\");\n this.fileName = obj.fileName || \"\";\n this.functionName = obj.functionName || \"\";\n this.lineNumber = obj.lineNumber;\n this.columnNumber = obj.columnNumber;\n }\n toString() {\n const lineNumber = this.lineNumber || \"\";\n const columnNumber = this.columnNumber || \"\";\n if (this.functionName)\n return `${this.functionName} (${this.fileName}:${lineNumber}:${columnNumber})`;\n return `${this.fileName}:${lineNumber}:${columnNumber}`;\n }\n}\nconst FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\\S+:\\d+/;\nconst CHROME_IE_STACK_REGEXP = /^\\s*at .*(\\S+:\\d+|\\(native\\))/m;\nconst SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\\[native code])?$/;\nconst ErrorStackParser = {\n /**\n * Given an Error object, extract the most information from it.\n */\n parse: function(error) {\n if (!error) {\n return [];\n }\n if (\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n typeof error.stacktrace !== \"undefined\" || // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n typeof error[\"opera#sourceloc\"] !== \"undefined\"\n ) {\n return this.parseOpera(\n error\n );\n } else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {\n return this.parseV8OrIE(error);\n } else if (error.stack) {\n return this.parseFFOrSafari(error);\n } else {\n console.warn(\n \"[console-record-plugin]: Failed to parse error object:\",\n error\n );\n return [];\n }\n },\n // Separate line and column numbers from a string of the form: (URI:Line:Column)\n extractLocation: function(urlLike) {\n if (urlLike.indexOf(\":\") === -1) {\n return [urlLike];\n }\n const regExp = /(.+?)(?::(\\d+))?(?::(\\d+))?$/;\n const parts = regExp.exec(urlLike.replace(/[()]/g, \"\"));\n if (!parts) throw new Error(`Cannot parse given url: ${urlLike}`);\n return [parts[1], parts[2] || void 0, parts[3] || void 0];\n },\n parseV8OrIE: function(error) {\n const filtered = error.stack.split(\"\\n\").filter(function(line) {\n return !!line.match(CHROME_IE_STACK_REGEXP);\n }, this);\n return filtered.map(function(line) {\n if (line.indexOf(\"(eval \") > -1) {\n line = line.replace(/eval code/g, \"eval\").replace(/(\\(eval at [^()]*)|(\\),.*$)/g, \"\");\n }\n let sanitizedLine = line.replace(/^\\s+/, \"\").replace(/\\(eval code/g, \"(\");\n const location = sanitizedLine.match(/ (\\((.+):(\\d+):(\\d+)\\)$)/);\n sanitizedLine = location ? sanitizedLine.replace(location[0], \"\") : sanitizedLine;\n const tokens = sanitizedLine.split(/\\s+/).slice(1);\n const locationParts = this.extractLocation(\n location ? location[1] : tokens.pop()\n );\n const functionName = tokens.join(\" \") || void 0;\n const fileName = [\"eval\", \"<anonymous>\"].indexOf(locationParts[0]) > -1 ? void 0 : locationParts[0];\n return new StackFrame({\n functionName,\n fileName,\n lineNumber: locationParts[1],\n columnNumber: locationParts[2]\n });\n }, this);\n },\n parseFFOrSafari: function(error) {\n const filtered = error.stack.split(\"\\n\").filter(function(line) {\n return !line.match(SAFARI_NATIVE_CODE_REGEXP);\n }, this);\n return filtered.map(function(line) {\n if (line.indexOf(\" > eval\") > -1) {\n line = line.replace(\n / line (\\d+)(?: > eval line \\d+)* > eval:\\d+:\\d+/g,\n \":$1\"\n );\n }\n if (line.indexOf(\"@\") === -1 && line.indexOf(\":\") === -1) {\n return new StackFrame({\n functionName: line\n });\n } else {\n const functionNameRegex = /((.*\".+\"[^@]*)?[^@]*)(?:@)/;\n const matches = line.match(functionNameRegex);\n const functionName = matches && matches[1] ? matches[1] : void 0;\n const locationParts = this.extractLocation(\n line.replace(functionNameRegex, \"\")\n );\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2]\n });\n }\n }, this);\n },\n parseOpera: function(e) {\n if (!e.stacktrace || e.message.indexOf(\"\\n\") > -1 && e.message.split(\"\\n\").length > e.stacktrace.split(\"\\n\").length) {\n return this.parseOpera9(e);\n } else if (!e.stack) {\n return this.parseOpera10(e);\n } else {\n return this.parseOpera11(e);\n }\n },\n parseOpera9: function(e) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)/i;\n const lines = e.message.split(\"\\n\");\n const result = [];\n for (let i = 2, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n fileName: match[2],\n lineNumber: parseFloat(match[1])\n })\n );\n }\n }\n return result;\n },\n parseOpera10: function(e) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)(?:: In function (\\S+))?$/i;\n const lines = e.stacktrace.split(\"\\n\");\n const result = [];\n for (let i = 0, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n functionName: match[3] || void 0,\n fileName: match[2],\n lineNumber: parseFloat(match[1])\n })\n );\n }\n }\n return result;\n },\n // Opera 10.65+ Error.stack very similar to FF/Safari\n parseOpera11: function(error) {\n const filtered = error.stack.split(\"\\n\").filter(function(line) {\n return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);\n }, this);\n return filtered.map(function(line) {\n const tokens = line.split(\"@\");\n const locationParts = this.extractLocation(tokens.pop());\n const functionCall = tokens.shift() || \"\";\n const functionName = functionCall.replace(/<anonymous function(: (\\w+))?>/, \"$2\").replace(/\\([^)]*\\)/g, \"\") || void 0;\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2]\n });\n }, this);\n }\n};\nfunction pathToSelector(node) {\n if (!node || !node.outerHTML) {\n return \"\";\n }\n let path = \"\";\n while (node.parentElement) {\n let name = node.localName;\n if (!name) {\n break;\n }\n name = name.toLowerCase();\n const parent = node.parentElement;\n const domSiblings = [];\n if (parent.children && parent.children.length > 0) {\n for (let i = 0; i < parent.children.length; i++) {\n const sibling = parent.children[i];\n if (sibling.localName && sibling.localName.toLowerCase) {\n if (sibling.localName.toLowerCase() === name) {\n domSiblings.push(sibling);\n }\n }\n }\n }\n if (domSiblings.length > 1) {\n name += `:eq(${domSiblings.indexOf(node)})`;\n }\n path = name + (path ? \">\" + path : \"\");\n node = parent;\n }\n return path;\n}\nfunction isObject(obj) {\n return Object.prototype.toString.call(obj) === \"[object Object]\";\n}\nfunction isObjTooDeep(obj, limit) {\n if (limit === 0) {\n return true;\n }\n const keys = Object.keys(obj);\n for (const key of keys) {\n if (isObject(obj[key]) && isObjTooDeep(obj[key], limit - 1)) {\n return true;\n }\n }\n return false;\n}\nfunction stringify(obj, stringifyOptions) {\n const options = {\n numOfKeysLimit: 50,\n depthOfLimit: 4\n };\n Object.assign(options, stringifyOptions);\n const stack = [];\n const keys = [];\n return JSON.stringify(\n obj,\n function(key, value) {\n if (stack.length > 0) {\n const thisPos = stack.indexOf(this);\n ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);\n ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);\n if (~stack.indexOf(value)) {\n if (stack[0] === value) {\n value = \"[Circular ~]\";\n } else {\n value = \"[Circular ~.\" + keys.slice(0, stack.indexOf(value)).join(\".\") + \"]\";\n }\n }\n } else {\n stack.push(value);\n }\n if (value === null) return value;\n if (value === void 0) return \"undefined\";\n if (shouldIgnore(value)) {\n return toString(value);\n }\n if (typeof value === \"bigint\") {\n return value.toString() + \"n\";\n }\n if (value instanceof Event) {\n const eventResult = {};\n for (const eventKey in value) {\n const eventValue = value[eventKey];\n if (Array.isArray(eventValue)) {\n eventResult[eventKey] = pathToSelector(\n eventValue.length ? eventValue[0] : null\n );\n } else {\n eventResult[eventKey] = eventValue;\n }\n }\n return eventResult;\n } else if (value instanceof Node) {\n if (value instanceof HTMLElement) {\n return value ? value.outerHTML : \"\";\n }\n return value.nodeName;\n } else if (value instanceof Error) {\n return value.stack ? value.stack + \"\\nEnd of stack for Error object\" : value.name + \": \" + value.message;\n }\n return value;\n }\n );\n function shouldIgnore(_obj) {\n if (isObject(_obj) && Object.keys(_obj).length > options.numOfKeysLimit) {\n return true;\n }\n if (typeof _obj === \"function\") {\n return true;\n }\n if (isObject(_obj) && isObjTooDeep(_obj, options.depthOfLimit)) {\n return true;\n }\n return false;\n }\n function toString(_obj) {\n let str = _obj.toString();\n if (options.stringLengthLimit && str.length > options.stringLengthLimit) {\n str = `${str.slice(0, options.stringLengthLimit)}...`;\n }\n return str;\n }\n}\nconst defaultLogOptions = {\n level: [\n \"assert\",\n \"clear\",\n \"count\",\n \"countReset\",\n \"debug\",\n \"dir\",\n \"dirxml\",\n \"error\",\n \"group\",\n \"groupCollapsed\",\n \"groupEnd\",\n \"info\",\n \"log\",\n \"table\",\n \"time\",\n \"timeEnd\",\n \"timeLog\",\n \"trace\",\n \"warn\"\n ],\n lengthThreshold: 1e3,\n logger: \"console\"\n};\nfunction initLogObserver(cb, win, options) {\n const logOptions = options ? Object.assign({}, defaultLogOptions, options) : defaultLogOptions;\n const loggerType = logOptions.logger;\n if (!loggerType) {\n return () => {\n };\n }\n let logger;\n if (typeof loggerType === \"string\") {\n logger = win[loggerType];\n } else {\n logger = loggerType;\n }\n let logCount = 0;\n let inStack = false;\n const cancelHandlers = [];\n if (logOptions.level.includes(\"error\")) {\n const errorHandler = (event) => {\n const message = event.message, error = event.error;\n const trace = ErrorStackParser.parse(error).map(\n (stackFrame) => stackFrame.toString()\n );\n const payload = [stringify(message, logOptions.stringifyOptions)];\n cb({\n level: \"error\",\n trace,\n payload\n });\n };\n win.addEventListener(\"error\", errorHandler);\n cancelHandlers.push(() => {\n win.removeEventListener(\"error\", errorHandler);\n });\n const unhandledrejectionHandler = (event) => {\n let error;\n let payload;\n if (event.reason instanceof Error) {\n error = event.reason;\n payload = [\n stringify(\n `Uncaught (in promise) ${error.name}: ${error.message}`,\n logOptions.stringifyOptions\n )\n ];\n } else {\n error = new Error();\n payload = [\n stringify(\"Uncaught (in promise)\", logOptions.stringifyOptions),\n stringify(event.reason, logOptions.stringifyOptions)\n ];\n }\n const trace = ErrorStackParser.parse(error).map(\n (stackFrame) => stackFrame.toString()\n );\n cb({\n level: \"error\",\n trace,\n payload\n });\n };\n win.addEventListener(\"unhandledrejection\", unhandledrejectionHandler);\n cancelHandlers.push(() => {\n win.removeEventListener(\"unhandledrejection\", unhandledrejectionHandler);\n });\n }\n for (const levelType of logOptions.level) {\n cancelHandlers.push(replace(logger, levelType));\n }\n return () => {\n cancelHandlers.forEach((h) => h());\n };\n function replace(_logger, level) {\n if (!_logger[level]) {\n return () => {\n };\n }\n return patch(\n _logger,\n level,\n (original) => {\n return (...args) => {\n original.apply(this, args);\n if (level === \"assert\" && !!args[0]) {\n return;\n }\n if (inStack) {\n return;\n }\n inStack = true;\n try {\n const trace = ErrorStackParser.parse(new Error()).map((stackFrame) => stackFrame.toString()).splice(1);\n const argsForPayload = level === \"assert\" ? args.slice(1) : args;\n const payload = argsForPayload.map(\n (s) => stringify(s, logOptions.stringifyOptions)\n );\n logCount++;\n if (logCount < logOptions.lengthThreshold) {\n cb({\n level,\n trace,\n payload\n });\n } else if (logCount === logOptions.lengthThreshold) {\n cb({\n level: \"warn\",\n trace: [],\n payload: [\n stringify(\"The number of log records reached the threshold.\")\n ]\n });\n }\n } catch (error) {\n original(\"rrweb logger error:\", error, ...args);\n } finally {\n inStack = false;\n }\n };\n }\n );\n }\n}\nconst PLUGIN_NAME = \"rrweb/console@1\";\nconst getRecordConsolePlugin = (options) => ({\n name: PLUGIN_NAME,\n observer: initLogObserver,\n options\n});\nexport {\n PLUGIN_NAME,\n getRecordConsolePlugin\n};\n//# sourceMappingURL=rrweb-plugin-console-record.js.map\n", "var EventType = /* @__PURE__ */ ((EventType2) => {\n EventType2[EventType2[\"DomContentLoaded\"] = 0] = \"DomContentLoaded\";\n EventType2[EventType2[\"Load\"] = 1] = \"Load\";\n EventType2[EventType2[\"FullSnapshot\"] = 2] = \"FullSnapshot\";\n EventType2[EventType2[\"IncrementalSnapshot\"] = 3] = \"IncrementalSnapshot\";\n EventType2[EventType2[\"Meta\"] = 4] = \"Meta\";\n EventType2[EventType2[\"Custom\"] = 5] = \"Custom\";\n EventType2[EventType2[\"Plugin\"] = 6] = \"Plugin\";\n return EventType2;\n})(EventType || {});\nvar IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => {\n IncrementalSource2[IncrementalSource2[\"Mutation\"] = 0] = \"Mutation\";\n IncrementalSource2[IncrementalSource2[\"MouseMove\"] = 1] = \"MouseMove\";\n IncrementalSource2[IncrementalSource2[\"MouseInteraction\"] = 2] = \"MouseInteraction\";\n IncrementalSource2[IncrementalSource2[\"Scroll\"] = 3] = \"Scroll\";\n IncrementalSource2[IncrementalSource2[\"ViewportResize\"] = 4] = \"ViewportResize\";\n IncrementalSource2[IncrementalSource2[\"Input\"] = 5] = \"Input\";\n IncrementalSource2[IncrementalSource2[\"TouchMove\"] = 6] = \"TouchMove\";\n IncrementalSource2[IncrementalSource2[\"MediaInteraction\"] = 7] = \"MediaInteraction\";\n IncrementalSource2[IncrementalSource2[\"StyleSheetRule\"] = 8] = \"StyleSheetRule\";\n IncrementalSource2[IncrementalSource2[\"CanvasMutation\"] = 9] = \"CanvasMutation\";\n IncrementalSource2[IncrementalSource2[\"Font\"] = 10] = \"Font\";\n IncrementalSource2[IncrementalSource2[\"Log\"] = 11] = \"Log\";\n IncrementalSource2[IncrementalSource2[\"Drag\"] = 12] = \"Drag\";\n IncrementalSource2[IncrementalSource2[\"StyleDeclaration\"] = 13] = \"StyleDeclaration\";\n IncrementalSource2[IncrementalSource2[\"Selection\"] = 14] = \"Selection\";\n IncrementalSource2[IncrementalSource2[\"AdoptedStyleSheet\"] = 15] = \"AdoptedStyleSheet\";\n IncrementalSource2[IncrementalSource2[\"CustomElement\"] = 16] = \"CustomElement\";\n return IncrementalSource2;\n})(IncrementalSource || {});\nvar MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {\n MouseInteractions2[MouseInteractions2[\"MouseUp\"] = 0] = \"MouseUp\";\n MouseInteractions2[MouseInteractions2[\"MouseDown\"] = 1] = \"MouseDown\";\n MouseInteractions2[MouseInteractions2[\"Click\"] = 2] = \"Click\";\n MouseInteractions2[MouseInteractions2[\"ContextMenu\"] = 3] = \"ContextMenu\";\n MouseInteractions2[MouseInteractions2[\"DblClick\"] = 4] = \"DblClick\";\n MouseInteractions2[MouseInteractions2[\"Focus\"] = 5] = \"Focus\";\n MouseInteractions2[MouseInteractions2[\"Blur\"] = 6] = \"Blur\";\n MouseInteractions2[MouseInteractions2[\"TouchStart\"] = 7] = \"TouchStart\";\n MouseInteractions2[MouseInteractions2[\"TouchMove_Departed\"] = 8] = \"TouchMove_Departed\";\n MouseInteractions2[MouseInteractions2[\"TouchEnd\"] = 9] = \"TouchEnd\";\n MouseInteractions2[MouseInteractions2[\"TouchCancel\"] = 10] = \"TouchCancel\";\n return MouseInteractions2;\n})(MouseInteractions || {});\nvar PointerTypes = /* @__PURE__ */ ((PointerTypes2) => {\n PointerTypes2[PointerTypes2[\"Mouse\"] = 0] = \"Mouse\";\n PointerTypes2[PointerTypes2[\"Pen\"] = 1] = \"Pen\";\n PointerTypes2[PointerTypes2[\"Touch\"] = 2] = \"Touch\";\n return PointerTypes2;\n})(PointerTypes || {});\nvar CanvasContext = /* @__PURE__ */ ((CanvasContext2) => {\n CanvasContext2[CanvasContext2[\"2D\"] = 0] = \"2D\";\n CanvasContext2[CanvasContext2[\"WebGL\"] = 1] = \"WebGL\";\n CanvasContext2[CanvasContext2[\"WebGL2\"] = 2] = \"WebGL2\";\n return CanvasContext2;\n})(CanvasContext || {});\nvar MediaInteractions = /* @__PURE__ */ ((MediaInteractions2) => {\n MediaInteractions2[MediaInteractions2[\"Play\"] = 0] = \"Play\";\n MediaInteractions2[MediaInteractions2[\"Pause\"] = 1] = \"Pause\";\n MediaInteractions2[MediaInteractions2[\"Seeked\"] = 2] = \"Seeked\";\n MediaInteractions2[MediaInteractions2[\"VolumeChange\"] = 3] = \"VolumeChange\";\n MediaInteractions2[MediaInteractions2[\"RateChange\"] = 4] = \"RateChange\";\n return MediaInteractions2;\n})(MediaInteractions || {});\nvar ReplayerEvents = /* @__PURE__ */ ((ReplayerEvents2) => {\n ReplayerEvents2[\"Start\"] = \"start\";\n ReplayerEvents2[\"Pause\"] = \"pause\";\n ReplayerEvents2[\"Resume\"] = \"resume\";\n ReplayerEvents2[\"Resize\"] = \"resize\";\n ReplayerEvents2[\"Finish\"] = \"finish\";\n ReplayerEvents2[\"FullsnapshotRebuilded\"] = \"fullsnapshot-rebuilded\";\n ReplayerEvents2[\"LoadStylesheetStart\"] = \"load-stylesheet-start\";\n ReplayerEvents2[\"LoadStylesheetEnd\"] = \"load-stylesheet-end\";\n ReplayerEvents2[\"SkipStart\"] = \"skip-start\";\n ReplayerEvents2[\"SkipEnd\"] = \"skip-end\";\n ReplayerEvents2[\"MouseInteraction\"] = \"mouse-interaction\";\n ReplayerEvents2[\"EventCast\"] = \"event-cast\";\n ReplayerEvents2[\"CustomEvent\"] = \"custom-event\";\n ReplayerEvents2[\"Flush\"] = \"flush\";\n ReplayerEvents2[\"StateChange\"] = \"state-change\";\n ReplayerEvents2[\"PlayBack\"] = \"play-back\";\n ReplayerEvents2[\"Destroy\"] = \"destroy\";\n return ReplayerEvents2;\n})(ReplayerEvents || {});\nvar NodeType = /* @__PURE__ */ ((NodeType2) => {\n NodeType2[NodeType2[\"Document\"] = 0] = \"Document\";\n NodeType2[NodeType2[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType2[NodeType2[\"Element\"] = 2] = \"Element\";\n NodeType2[NodeType2[\"Text\"] = 3] = \"Text\";\n NodeType2[NodeType2[\"CDATA\"] = 4] = \"CDATA\";\n NodeType2[NodeType2[\"Comment\"] = 5] = \"Comment\";\n return NodeType2;\n})(NodeType || {});\nexport {\n CanvasContext,\n EventType,\n IncrementalSource,\n MediaInteractions,\n MouseInteractions,\n NodeType,\n PointerTypes,\n ReplayerEvents\n};\n//# sourceMappingURL=types.js.map\n", "import {\n type LogLevel,\n type LogData,\n PLUGIN_NAME,\n} from '@betterbugs/rrweb-plugin-console-record';\nimport type { eventWithTime } from '@betterbugs/types';\nimport { EventType, IncrementalSource } from '@betterbugs/types';\nimport type { ReplayPlugin, Replayer } from '@betterbugs/rrweb';\n\n/**\n * define an interface to replay log records\n * (data: logData) => void> function to display the log data\n */\ntype ReplayLogger = Partial<Record<LogLevel, (data: LogData) => void>>;\n\ntype LogReplayConfig = {\n level?: LogLevel[];\n replayLogger?: ReplayLogger;\n};\n\nconst ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\ntype PatchedConsoleLog = {\n [ORIGINAL_ATTRIBUTE_NAME]: typeof console.log;\n};\n\nconst defaultLogConfig: LogReplayConfig = {\n level: [\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n 'group',\n 'groupCollapsed',\n 'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n ],\n replayLogger: undefined,\n};\n\nclass LogReplayPlugin {\n private config: LogReplayConfig;\n\n constructor(config?: LogReplayConfig) {\n this.config = Object.assign(defaultLogConfig, config);\n }\n\n /**\n * generate a console log replayer which implement the interface ReplayLogger\n */\n public getConsoleLogger(): ReplayLogger {\n const replayLogger: ReplayLogger = {};\n for (const level of this.config.level!) {\n if (level === 'trace') {\n replayLogger[level] = (data: LogData) => {\n const logger = (console.log as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? (console.log as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console.log;\n logger(\n ...data.payload.map((s) => JSON.parse(s) as object),\n this.formatMessage(data),\n );\n };\n } else {\n replayLogger[level] = (data: LogData) => {\n const logger = (console[level] as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? (console[level] as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console[level];\n logger(\n ...data.payload.map((s) => JSON.parse(s) as object),\n this.formatMessage(data),\n );\n };\n }\n }\n return replayLogger;\n }\n\n /**\n * format the trace data to a string\n * @param data - the log data\n */\n private formatMessage(data: LogData): string {\n if (data.trace.length === 0) {\n return '';\n }\n const stackPrefix = '\\n\\tat ';\n let result = stackPrefix;\n result += data.trace.join(stackPrefix);\n return result;\n }\n}\n\nexport const getReplayConsolePlugin: (\n options?: LogReplayConfig,\n) => ReplayPlugin = (options) => {\n const replayLogger =\n options?.replayLogger || new LogReplayPlugin(options).getConsoleLogger();\n\n return {\n handler(\n event: eventWithTime,\n _isSync: boolean,\n context: { replayer: Replayer },\n ) {\n let logData: LogData | null = null;\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === (IncrementalSource.Log as IncrementalSource)\n ) {\n logData = event.data as unknown as LogData;\n } else if (\n event.type === EventType.Plugin &&\n event.data.plugin === PLUGIN_NAME\n ) {\n logData = event.data.payload as LogData;\n }\n if (logData) {\n try {\n if (typeof replayLogger[logData.level] === 'function') {\n replayLogger[logData.level]!(logData);\n }\n } catch (error) {\n if (context.replayer.config.showWarning) {\n console.warn(error);\n }\n }\n }\n },\n };\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
(function (g, f) {
|
|
2
|
+
if ("object" == typeof exports && "object" == typeof module) {
|
|
3
|
+
module.exports = f();
|
|
4
|
+
} else if ("function" == typeof define && define.amd) {
|
|
5
|
+
define("rrwebPluginConsoleReplay", [], f);
|
|
6
|
+
} else if ("object" == typeof exports) {
|
|
7
|
+
exports["rrwebPluginConsoleReplay"] = f();
|
|
8
|
+
} else {
|
|
9
|
+
g["rrwebPluginConsoleReplay"] = f();
|
|
10
|
+
}
|
|
11
|
+
}(this, () => {
|
|
12
|
+
var exports = {};
|
|
13
|
+
var module = { exports };
|
|
14
|
+
"use strict";var f=Object.defineProperty,p=(o,l,t)=>l in o?f(o,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[l]=t,M=(o,l,t)=>p(o,typeof l!="symbol"?l+"":l,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n="rrweb/console@1";var e=(o=>(o[o.DomContentLoaded=0]="DomContentLoaded",o[o.Load=1]="Load",o[o.FullSnapshot=2]="FullSnapshot",o[o.IncrementalSnapshot=3]="IncrementalSnapshot",o[o.Meta=4]="Meta",o[o.Custom=5]="Custom",o[o.Plugin=6]="Plugin",o))(e||{}),r=(o=>(o[o.Mutation=0]="Mutation",o[o.MouseMove=1]="MouseMove",o[o.MouseInteraction=2]="MouseInteraction",o[o.Scroll=3]="Scroll",o[o.ViewportResize=4]="ViewportResize",o[o.Input=5]="Input",o[o.TouchMove=6]="TouchMove",o[o.MediaInteraction=7]="MediaInteraction",o[o.StyleSheetRule=8]="StyleSheetRule",o[o.CanvasMutation=9]="CanvasMutation",o[o.Font=10]="Font",o[o.Log=11]="Log",o[o.Drag=12]="Drag",o[o.StyleDeclaration=13]="StyleDeclaration",o[o.Selection=14]="Selection",o[o.AdoptedStyleSheet=15]="AdoptedStyleSheet",o[o.CustomElement=16]="CustomElement",o))(r||{});const g="__rrweb_original__",u={level:["assert","clear","count","countReset","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","table","time","timeEnd","timeLog","trace","warn"],replayLogger:void 0};class h{constructor(l){M(this,"config"),this.config=Object.assign(u,l)}getConsoleLogger(){const l={};for(const t of this.config.level)t==="trace"?l[t]=i=>{(console.log[g]?console.log[g]:console.log)(...i.payload.map(s=>JSON.parse(s)),this.formatMessage(i))}:l[t]=i=>{(console[t][g]?console[t][g]:console[t])(...i.payload.map(s=>JSON.parse(s)),this.formatMessage(i))};return l}formatMessage(l){if(l.trace.length===0)return"";const t=`
|
|
15
|
+
at `;let i=t;return i+=l.trace.join(t),i}}const L=o=>{const l=(o==null?void 0:o.replayLogger)||new h(o).getConsoleLogger();return{handler(t,i,a){let s=null;if(t.type===e.IncrementalSnapshot&&t.data.source===r.Log?s=t.data:t.type===e.Plugin&&t.data.plugin===n&&(s=t.data.payload),s)try{typeof l[s.level]=="function"&&l[s.level](s)}catch(d){a.replayer.config.showWarning&&console.warn(d)}}}};exports.getReplayConsolePlugin=L;
|
|
16
|
+
if (typeof module.exports == "object" && typeof exports == "object") {
|
|
17
|
+
var __cp = (to, from, except, desc) => {
|
|
18
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
19
|
+
for (let key of Object.getOwnPropertyNames(from)) {
|
|
20
|
+
if (!Object.prototype.hasOwnProperty.call(to, key) && key !== except)
|
|
21
|
+
Object.defineProperty(to, key, {
|
|
22
|
+
get: () => from[key],
|
|
23
|
+
enumerable: !(desc = Object.getOwnPropertyDescriptor(from, key)) || desc.enumerable,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
module.exports = __cp(module.exports, exports);
|
|
30
|
+
}
|
|
31
|
+
return module.exports;
|
|
32
|
+
}))
|
|
33
|
+
//# sourceMappingURL=rrweb-plugin-console-replay.umd.min.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../rrweb-plugin-console-record/dist/rrweb-plugin-console-record.js", "../../../types/dist/types.js", "../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["var __defProp = Object.defineProperty;\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nfunction patch(source, name, replacement) {\n try {\n if (!(name in source)) {\n return () => {\n };\n }\n const original = source[name];\n const wrapped = replacement(original);\n if (typeof wrapped === \"function\") {\n wrapped.prototype = wrapped.prototype || {};\n Object.defineProperties(wrapped, {\n __rrweb_original__: {\n enumerable: false,\n value: original\n }\n });\n }\n source[name] = wrapped;\n return () => {\n source[name] = original;\n };\n } catch {\n return () => {\n };\n }\n}\nclass StackFrame {\n constructor(obj) {\n __publicField(this, \"fileName\");\n __publicField(this, \"functionName\");\n __publicField(this, \"lineNumber\");\n __publicField(this, \"columnNumber\");\n this.fileName = obj.fileName || \"\";\n this.functionName = obj.functionName || \"\";\n this.lineNumber = obj.lineNumber;\n this.columnNumber = obj.columnNumber;\n }\n toString() {\n const lineNumber = this.lineNumber || \"\";\n const columnNumber = this.columnNumber || \"\";\n if (this.functionName)\n return `${this.functionName} (${this.fileName}:${lineNumber}:${columnNumber})`;\n return `${this.fileName}:${lineNumber}:${columnNumber}`;\n }\n}\nconst FIREFOX_SAFARI_STACK_REGEXP = /(^|@)\\S+:\\d+/;\nconst CHROME_IE_STACK_REGEXP = /^\\s*at .*(\\S+:\\d+|\\(native\\))/m;\nconst SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\\[native code])?$/;\nconst ErrorStackParser = {\n /**\n * Given an Error object, extract the most information from it.\n */\n parse: function(error) {\n if (!error) {\n return [];\n }\n if (\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n typeof error.stacktrace !== \"undefined\" || // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n typeof error[\"opera#sourceloc\"] !== \"undefined\"\n ) {\n return this.parseOpera(\n error\n );\n } else if (error.stack && error.stack.match(CHROME_IE_STACK_REGEXP)) {\n return this.parseV8OrIE(error);\n } else if (error.stack) {\n return this.parseFFOrSafari(error);\n } else {\n console.warn(\n \"[console-record-plugin]: Failed to parse error object:\",\n error\n );\n return [];\n }\n },\n // Separate line and column numbers from a string of the form: (URI:Line:Column)\n extractLocation: function(urlLike) {\n if (urlLike.indexOf(\":\") === -1) {\n return [urlLike];\n }\n const regExp = /(.+?)(?::(\\d+))?(?::(\\d+))?$/;\n const parts = regExp.exec(urlLike.replace(/[()]/g, \"\"));\n if (!parts) throw new Error(`Cannot parse given url: ${urlLike}`);\n return [parts[1], parts[2] || void 0, parts[3] || void 0];\n },\n parseV8OrIE: function(error) {\n const filtered = error.stack.split(\"\\n\").filter(function(line) {\n return !!line.match(CHROME_IE_STACK_REGEXP);\n }, this);\n return filtered.map(function(line) {\n if (line.indexOf(\"(eval \") > -1) {\n line = line.replace(/eval code/g, \"eval\").replace(/(\\(eval at [^()]*)|(\\),.*$)/g, \"\");\n }\n let sanitizedLine = line.replace(/^\\s+/, \"\").replace(/\\(eval code/g, \"(\");\n const location = sanitizedLine.match(/ (\\((.+):(\\d+):(\\d+)\\)$)/);\n sanitizedLine = location ? sanitizedLine.replace(location[0], \"\") : sanitizedLine;\n const tokens = sanitizedLine.split(/\\s+/).slice(1);\n const locationParts = this.extractLocation(\n location ? location[1] : tokens.pop()\n );\n const functionName = tokens.join(\" \") || void 0;\n const fileName = [\"eval\", \"<anonymous>\"].indexOf(locationParts[0]) > -1 ? void 0 : locationParts[0];\n return new StackFrame({\n functionName,\n fileName,\n lineNumber: locationParts[1],\n columnNumber: locationParts[2]\n });\n }, this);\n },\n parseFFOrSafari: function(error) {\n const filtered = error.stack.split(\"\\n\").filter(function(line) {\n return !line.match(SAFARI_NATIVE_CODE_REGEXP);\n }, this);\n return filtered.map(function(line) {\n if (line.indexOf(\" > eval\") > -1) {\n line = line.replace(\n / line (\\d+)(?: > eval line \\d+)* > eval:\\d+:\\d+/g,\n \":$1\"\n );\n }\n if (line.indexOf(\"@\") === -1 && line.indexOf(\":\") === -1) {\n return new StackFrame({\n functionName: line\n });\n } else {\n const functionNameRegex = /((.*\".+\"[^@]*)?[^@]*)(?:@)/;\n const matches = line.match(functionNameRegex);\n const functionName = matches && matches[1] ? matches[1] : void 0;\n const locationParts = this.extractLocation(\n line.replace(functionNameRegex, \"\")\n );\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2]\n });\n }\n }, this);\n },\n parseOpera: function(e) {\n if (!e.stacktrace || e.message.indexOf(\"\\n\") > -1 && e.message.split(\"\\n\").length > e.stacktrace.split(\"\\n\").length) {\n return this.parseOpera9(e);\n } else if (!e.stack) {\n return this.parseOpera10(e);\n } else {\n return this.parseOpera11(e);\n }\n },\n parseOpera9: function(e) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)/i;\n const lines = e.message.split(\"\\n\");\n const result = [];\n for (let i = 2, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n fileName: match[2],\n lineNumber: parseFloat(match[1])\n })\n );\n }\n }\n return result;\n },\n parseOpera10: function(e) {\n const lineRE = /Line (\\d+).*script (?:in )?(\\S+)(?:: In function (\\S+))?$/i;\n const lines = e.stacktrace.split(\"\\n\");\n const result = [];\n for (let i = 0, len = lines.length; i < len; i += 2) {\n const match = lineRE.exec(lines[i]);\n if (match) {\n result.push(\n new StackFrame({\n functionName: match[3] || void 0,\n fileName: match[2],\n lineNumber: parseFloat(match[1])\n })\n );\n }\n }\n return result;\n },\n // Opera 10.65+ Error.stack very similar to FF/Safari\n parseOpera11: function(error) {\n const filtered = error.stack.split(\"\\n\").filter(function(line) {\n return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);\n }, this);\n return filtered.map(function(line) {\n const tokens = line.split(\"@\");\n const locationParts = this.extractLocation(tokens.pop());\n const functionCall = tokens.shift() || \"\";\n const functionName = functionCall.replace(/<anonymous function(: (\\w+))?>/, \"$2\").replace(/\\([^)]*\\)/g, \"\") || void 0;\n return new StackFrame({\n functionName,\n fileName: locationParts[0],\n lineNumber: locationParts[1],\n columnNumber: locationParts[2]\n });\n }, this);\n }\n};\nfunction pathToSelector(node) {\n if (!node || !node.outerHTML) {\n return \"\";\n }\n let path = \"\";\n while (node.parentElement) {\n let name = node.localName;\n if (!name) {\n break;\n }\n name = name.toLowerCase();\n const parent = node.parentElement;\n const domSiblings = [];\n if (parent.children && parent.children.length > 0) {\n for (let i = 0; i < parent.children.length; i++) {\n const sibling = parent.children[i];\n if (sibling.localName && sibling.localName.toLowerCase) {\n if (sibling.localName.toLowerCase() === name) {\n domSiblings.push(sibling);\n }\n }\n }\n }\n if (domSiblings.length > 1) {\n name += `:eq(${domSiblings.indexOf(node)})`;\n }\n path = name + (path ? \">\" + path : \"\");\n node = parent;\n }\n return path;\n}\nfunction isObject(obj) {\n return Object.prototype.toString.call(obj) === \"[object Object]\";\n}\nfunction isObjTooDeep(obj, limit) {\n if (limit === 0) {\n return true;\n }\n const keys = Object.keys(obj);\n for (const key of keys) {\n if (isObject(obj[key]) && isObjTooDeep(obj[key], limit - 1)) {\n return true;\n }\n }\n return false;\n}\nfunction stringify(obj, stringifyOptions) {\n const options = {\n numOfKeysLimit: 50,\n depthOfLimit: 4\n };\n Object.assign(options, stringifyOptions);\n const stack = [];\n const keys = [];\n return JSON.stringify(\n obj,\n function(key, value) {\n if (stack.length > 0) {\n const thisPos = stack.indexOf(this);\n ~thisPos ? stack.splice(thisPos + 1) : stack.push(this);\n ~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);\n if (~stack.indexOf(value)) {\n if (stack[0] === value) {\n value = \"[Circular ~]\";\n } else {\n value = \"[Circular ~.\" + keys.slice(0, stack.indexOf(value)).join(\".\") + \"]\";\n }\n }\n } else {\n stack.push(value);\n }\n if (value === null) return value;\n if (value === void 0) return \"undefined\";\n if (shouldIgnore(value)) {\n return toString(value);\n }\n if (typeof value === \"bigint\") {\n return value.toString() + \"n\";\n }\n if (value instanceof Event) {\n const eventResult = {};\n for (const eventKey in value) {\n const eventValue = value[eventKey];\n if (Array.isArray(eventValue)) {\n eventResult[eventKey] = pathToSelector(\n eventValue.length ? eventValue[0] : null\n );\n } else {\n eventResult[eventKey] = eventValue;\n }\n }\n return eventResult;\n } else if (value instanceof Node) {\n if (value instanceof HTMLElement) {\n return value ? value.outerHTML : \"\";\n }\n return value.nodeName;\n } else if (value instanceof Error) {\n return value.stack ? value.stack + \"\\nEnd of stack for Error object\" : value.name + \": \" + value.message;\n }\n return value;\n }\n );\n function shouldIgnore(_obj) {\n if (isObject(_obj) && Object.keys(_obj).length > options.numOfKeysLimit) {\n return true;\n }\n if (typeof _obj === \"function\") {\n return true;\n }\n if (isObject(_obj) && isObjTooDeep(_obj, options.depthOfLimit)) {\n return true;\n }\n return false;\n }\n function toString(_obj) {\n let str = _obj.toString();\n if (options.stringLengthLimit && str.length > options.stringLengthLimit) {\n str = `${str.slice(0, options.stringLengthLimit)}...`;\n }\n return str;\n }\n}\nconst defaultLogOptions = {\n level: [\n \"assert\",\n \"clear\",\n \"count\",\n \"countReset\",\n \"debug\",\n \"dir\",\n \"dirxml\",\n \"error\",\n \"group\",\n \"groupCollapsed\",\n \"groupEnd\",\n \"info\",\n \"log\",\n \"table\",\n \"time\",\n \"timeEnd\",\n \"timeLog\",\n \"trace\",\n \"warn\"\n ],\n lengthThreshold: 1e3,\n logger: \"console\"\n};\nfunction initLogObserver(cb, win, options) {\n const logOptions = options ? Object.assign({}, defaultLogOptions, options) : defaultLogOptions;\n const loggerType = logOptions.logger;\n if (!loggerType) {\n return () => {\n };\n }\n let logger;\n if (typeof loggerType === \"string\") {\n logger = win[loggerType];\n } else {\n logger = loggerType;\n }\n let logCount = 0;\n let inStack = false;\n const cancelHandlers = [];\n if (logOptions.level.includes(\"error\")) {\n const errorHandler = (event) => {\n const message = event.message, error = event.error;\n const trace = ErrorStackParser.parse(error).map(\n (stackFrame) => stackFrame.toString()\n );\n const payload = [stringify(message, logOptions.stringifyOptions)];\n cb({\n level: \"error\",\n trace,\n payload\n });\n };\n win.addEventListener(\"error\", errorHandler);\n cancelHandlers.push(() => {\n win.removeEventListener(\"error\", errorHandler);\n });\n const unhandledrejectionHandler = (event) => {\n let error;\n let payload;\n if (event.reason instanceof Error) {\n error = event.reason;\n payload = [\n stringify(\n `Uncaught (in promise) ${error.name}: ${error.message}`,\n logOptions.stringifyOptions\n )\n ];\n } else {\n error = new Error();\n payload = [\n stringify(\"Uncaught (in promise)\", logOptions.stringifyOptions),\n stringify(event.reason, logOptions.stringifyOptions)\n ];\n }\n const trace = ErrorStackParser.parse(error).map(\n (stackFrame) => stackFrame.toString()\n );\n cb({\n level: \"error\",\n trace,\n payload\n });\n };\n win.addEventListener(\"unhandledrejection\", unhandledrejectionHandler);\n cancelHandlers.push(() => {\n win.removeEventListener(\"unhandledrejection\", unhandledrejectionHandler);\n });\n }\n for (const levelType of logOptions.level) {\n cancelHandlers.push(replace(logger, levelType));\n }\n return () => {\n cancelHandlers.forEach((h) => h());\n };\n function replace(_logger, level) {\n if (!_logger[level]) {\n return () => {\n };\n }\n return patch(\n _logger,\n level,\n (original) => {\n return (...args) => {\n original.apply(this, args);\n if (level === \"assert\" && !!args[0]) {\n return;\n }\n if (inStack) {\n return;\n }\n inStack = true;\n try {\n const trace = ErrorStackParser.parse(new Error()).map((stackFrame) => stackFrame.toString()).splice(1);\n const argsForPayload = level === \"assert\" ? args.slice(1) : args;\n const payload = argsForPayload.map(\n (s) => stringify(s, logOptions.stringifyOptions)\n );\n logCount++;\n if (logCount < logOptions.lengthThreshold) {\n cb({\n level,\n trace,\n payload\n });\n } else if (logCount === logOptions.lengthThreshold) {\n cb({\n level: \"warn\",\n trace: [],\n payload: [\n stringify(\"The number of log records reached the threshold.\")\n ]\n });\n }\n } catch (error) {\n original(\"rrweb logger error:\", error, ...args);\n } finally {\n inStack = false;\n }\n };\n }\n );\n }\n}\nconst PLUGIN_NAME = \"rrweb/console@1\";\nconst getRecordConsolePlugin = (options) => ({\n name: PLUGIN_NAME,\n observer: initLogObserver,\n options\n});\nexport {\n PLUGIN_NAME,\n getRecordConsolePlugin\n};\n//# sourceMappingURL=rrweb-plugin-console-record.js.map\n", "var EventType = /* @__PURE__ */ ((EventType2) => {\n EventType2[EventType2[\"DomContentLoaded\"] = 0] = \"DomContentLoaded\";\n EventType2[EventType2[\"Load\"] = 1] = \"Load\";\n EventType2[EventType2[\"FullSnapshot\"] = 2] = \"FullSnapshot\";\n EventType2[EventType2[\"IncrementalSnapshot\"] = 3] = \"IncrementalSnapshot\";\n EventType2[EventType2[\"Meta\"] = 4] = \"Meta\";\n EventType2[EventType2[\"Custom\"] = 5] = \"Custom\";\n EventType2[EventType2[\"Plugin\"] = 6] = \"Plugin\";\n return EventType2;\n})(EventType || {});\nvar IncrementalSource = /* @__PURE__ */ ((IncrementalSource2) => {\n IncrementalSource2[IncrementalSource2[\"Mutation\"] = 0] = \"Mutation\";\n IncrementalSource2[IncrementalSource2[\"MouseMove\"] = 1] = \"MouseMove\";\n IncrementalSource2[IncrementalSource2[\"MouseInteraction\"] = 2] = \"MouseInteraction\";\n IncrementalSource2[IncrementalSource2[\"Scroll\"] = 3] = \"Scroll\";\n IncrementalSource2[IncrementalSource2[\"ViewportResize\"] = 4] = \"ViewportResize\";\n IncrementalSource2[IncrementalSource2[\"Input\"] = 5] = \"Input\";\n IncrementalSource2[IncrementalSource2[\"TouchMove\"] = 6] = \"TouchMove\";\n IncrementalSource2[IncrementalSource2[\"MediaInteraction\"] = 7] = \"MediaInteraction\";\n IncrementalSource2[IncrementalSource2[\"StyleSheetRule\"] = 8] = \"StyleSheetRule\";\n IncrementalSource2[IncrementalSource2[\"CanvasMutation\"] = 9] = \"CanvasMutation\";\n IncrementalSource2[IncrementalSource2[\"Font\"] = 10] = \"Font\";\n IncrementalSource2[IncrementalSource2[\"Log\"] = 11] = \"Log\";\n IncrementalSource2[IncrementalSource2[\"Drag\"] = 12] = \"Drag\";\n IncrementalSource2[IncrementalSource2[\"StyleDeclaration\"] = 13] = \"StyleDeclaration\";\n IncrementalSource2[IncrementalSource2[\"Selection\"] = 14] = \"Selection\";\n IncrementalSource2[IncrementalSource2[\"AdoptedStyleSheet\"] = 15] = \"AdoptedStyleSheet\";\n IncrementalSource2[IncrementalSource2[\"CustomElement\"] = 16] = \"CustomElement\";\n return IncrementalSource2;\n})(IncrementalSource || {});\nvar MouseInteractions = /* @__PURE__ */ ((MouseInteractions2) => {\n MouseInteractions2[MouseInteractions2[\"MouseUp\"] = 0] = \"MouseUp\";\n MouseInteractions2[MouseInteractions2[\"MouseDown\"] = 1] = \"MouseDown\";\n MouseInteractions2[MouseInteractions2[\"Click\"] = 2] = \"Click\";\n MouseInteractions2[MouseInteractions2[\"ContextMenu\"] = 3] = \"ContextMenu\";\n MouseInteractions2[MouseInteractions2[\"DblClick\"] = 4] = \"DblClick\";\n MouseInteractions2[MouseInteractions2[\"Focus\"] = 5] = \"Focus\";\n MouseInteractions2[MouseInteractions2[\"Blur\"] = 6] = \"Blur\";\n MouseInteractions2[MouseInteractions2[\"TouchStart\"] = 7] = \"TouchStart\";\n MouseInteractions2[MouseInteractions2[\"TouchMove_Departed\"] = 8] = \"TouchMove_Departed\";\n MouseInteractions2[MouseInteractions2[\"TouchEnd\"] = 9] = \"TouchEnd\";\n MouseInteractions2[MouseInteractions2[\"TouchCancel\"] = 10] = \"TouchCancel\";\n return MouseInteractions2;\n})(MouseInteractions || {});\nvar PointerTypes = /* @__PURE__ */ ((PointerTypes2) => {\n PointerTypes2[PointerTypes2[\"Mouse\"] = 0] = \"Mouse\";\n PointerTypes2[PointerTypes2[\"Pen\"] = 1] = \"Pen\";\n PointerTypes2[PointerTypes2[\"Touch\"] = 2] = \"Touch\";\n return PointerTypes2;\n})(PointerTypes || {});\nvar CanvasContext = /* @__PURE__ */ ((CanvasContext2) => {\n CanvasContext2[CanvasContext2[\"2D\"] = 0] = \"2D\";\n CanvasContext2[CanvasContext2[\"WebGL\"] = 1] = \"WebGL\";\n CanvasContext2[CanvasContext2[\"WebGL2\"] = 2] = \"WebGL2\";\n return CanvasContext2;\n})(CanvasContext || {});\nvar MediaInteractions = /* @__PURE__ */ ((MediaInteractions2) => {\n MediaInteractions2[MediaInteractions2[\"Play\"] = 0] = \"Play\";\n MediaInteractions2[MediaInteractions2[\"Pause\"] = 1] = \"Pause\";\n MediaInteractions2[MediaInteractions2[\"Seeked\"] = 2] = \"Seeked\";\n MediaInteractions2[MediaInteractions2[\"VolumeChange\"] = 3] = \"VolumeChange\";\n MediaInteractions2[MediaInteractions2[\"RateChange\"] = 4] = \"RateChange\";\n return MediaInteractions2;\n})(MediaInteractions || {});\nvar ReplayerEvents = /* @__PURE__ */ ((ReplayerEvents2) => {\n ReplayerEvents2[\"Start\"] = \"start\";\n ReplayerEvents2[\"Pause\"] = \"pause\";\n ReplayerEvents2[\"Resume\"] = \"resume\";\n ReplayerEvents2[\"Resize\"] = \"resize\";\n ReplayerEvents2[\"Finish\"] = \"finish\";\n ReplayerEvents2[\"FullsnapshotRebuilded\"] = \"fullsnapshot-rebuilded\";\n ReplayerEvents2[\"LoadStylesheetStart\"] = \"load-stylesheet-start\";\n ReplayerEvents2[\"LoadStylesheetEnd\"] = \"load-stylesheet-end\";\n ReplayerEvents2[\"SkipStart\"] = \"skip-start\";\n ReplayerEvents2[\"SkipEnd\"] = \"skip-end\";\n ReplayerEvents2[\"MouseInteraction\"] = \"mouse-interaction\";\n ReplayerEvents2[\"EventCast\"] = \"event-cast\";\n ReplayerEvents2[\"CustomEvent\"] = \"custom-event\";\n ReplayerEvents2[\"Flush\"] = \"flush\";\n ReplayerEvents2[\"StateChange\"] = \"state-change\";\n ReplayerEvents2[\"PlayBack\"] = \"play-back\";\n ReplayerEvents2[\"Destroy\"] = \"destroy\";\n return ReplayerEvents2;\n})(ReplayerEvents || {});\nvar NodeType = /* @__PURE__ */ ((NodeType2) => {\n NodeType2[NodeType2[\"Document\"] = 0] = \"Document\";\n NodeType2[NodeType2[\"DocumentType\"] = 1] = \"DocumentType\";\n NodeType2[NodeType2[\"Element\"] = 2] = \"Element\";\n NodeType2[NodeType2[\"Text\"] = 3] = \"Text\";\n NodeType2[NodeType2[\"CDATA\"] = 4] = \"CDATA\";\n NodeType2[NodeType2[\"Comment\"] = 5] = \"Comment\";\n return NodeType2;\n})(NodeType || {});\nexport {\n CanvasContext,\n EventType,\n IncrementalSource,\n MediaInteractions,\n MouseInteractions,\n NodeType,\n PointerTypes,\n ReplayerEvents\n};\n//# sourceMappingURL=types.js.map\n", "import {\n type LogLevel,\n type LogData,\n PLUGIN_NAME,\n} from '@betterbugs/rrweb-plugin-console-record';\nimport type { eventWithTime } from '@betterbugs/types';\nimport { EventType, IncrementalSource } from '@betterbugs/types';\nimport type { ReplayPlugin, Replayer } from '@betterbugs/rrweb';\n\n/**\n * define an interface to replay log records\n * (data: logData) => void> function to display the log data\n */\ntype ReplayLogger = Partial<Record<LogLevel, (data: LogData) => void>>;\n\ntype LogReplayConfig = {\n level?: LogLevel[];\n replayLogger?: ReplayLogger;\n};\n\nconst ORIGINAL_ATTRIBUTE_NAME = '__rrweb_original__';\ntype PatchedConsoleLog = {\n [ORIGINAL_ATTRIBUTE_NAME]: typeof console.log;\n};\n\nconst defaultLogConfig: LogReplayConfig = {\n level: [\n 'assert',\n 'clear',\n 'count',\n 'countReset',\n 'debug',\n 'dir',\n 'dirxml',\n 'error',\n 'group',\n 'groupCollapsed',\n 'groupEnd',\n 'info',\n 'log',\n 'table',\n 'time',\n 'timeEnd',\n 'timeLog',\n 'trace',\n 'warn',\n ],\n replayLogger: undefined,\n};\n\nclass LogReplayPlugin {\n private config: LogReplayConfig;\n\n constructor(config?: LogReplayConfig) {\n this.config = Object.assign(defaultLogConfig, config);\n }\n\n /**\n * generate a console log replayer which implement the interface ReplayLogger\n */\n public getConsoleLogger(): ReplayLogger {\n const replayLogger: ReplayLogger = {};\n for (const level of this.config.level!) {\n if (level === 'trace') {\n replayLogger[level] = (data: LogData) => {\n const logger = (console.log as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? (console.log as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console.log;\n logger(\n ...data.payload.map((s) => JSON.parse(s) as object),\n this.formatMessage(data),\n );\n };\n } else {\n replayLogger[level] = (data: LogData) => {\n const logger = (console[level] as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n ? (console[level] as unknown as PatchedConsoleLog)[\n ORIGINAL_ATTRIBUTE_NAME\n ]\n : console[level];\n logger(\n ...data.payload.map((s) => JSON.parse(s) as object),\n this.formatMessage(data),\n );\n };\n }\n }\n return replayLogger;\n }\n\n /**\n * format the trace data to a string\n * @param data - the log data\n */\n private formatMessage(data: LogData): string {\n if (data.trace.length === 0) {\n return '';\n }\n const stackPrefix = '\\n\\tat ';\n let result = stackPrefix;\n result += data.trace.join(stackPrefix);\n return result;\n }\n}\n\nexport const getReplayConsolePlugin: (\n options?: LogReplayConfig,\n) => ReplayPlugin = (options) => {\n const replayLogger =\n options?.replayLogger || new LogReplayPlugin(options).getConsoleLogger();\n\n return {\n handler(\n event: eventWithTime,\n _isSync: boolean,\n context: { replayer: Replayer },\n ) {\n let logData: LogData | null = null;\n if (\n event.type === EventType.IncrementalSnapshot &&\n event.data.source === (IncrementalSource.Log as IncrementalSource)\n ) {\n logData = event.data as unknown as LogData;\n } else if (\n event.type === EventType.Plugin &&\n event.data.plugin === PLUGIN_NAME\n ) {\n logData = event.data.payload as LogData;\n }\n if (logData) {\n try {\n if (typeof replayLogger[logData.level] === 'function') {\n replayLogger[logData.level]!(logData);\n }\n } catch (error) {\n if (context.replayer.config.showWarning) {\n console.warn(error);\n }\n }\n }\n },\n };\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["PLUGIN_NAME", "EventType", "EventType2", "IncrementalSource", "IncrementalSource2", "ORIGINAL_ATTRIBUTE_NAME", "defaultLogConfig", "LogReplayPlugin", "config", "__publicField", "replayLogger", "level", "data", "stackPrefix", "result", "getReplayConsolePlugin", "options", "event", "_isSync", "context", "logData", "error"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@betterbugs/rrweb-plugin-console-replay",
|
|
3
|
+
"version": "2.0.0-alpha.19",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/rrweb-plugin-console-replay.umd.cjs",
|
|
10
|
+
"module": "./dist/rrweb-plugin-console-replay.js",
|
|
11
|
+
"unpkg": "./dist/rrweb-plugin-console-replay.umd.cjs",
|
|
12
|
+
"typings": "dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/rrweb-plugin-console-replay.js"
|
|
18
|
+
},
|
|
19
|
+
"require": {
|
|
20
|
+
"types": "./dist/index.d.cts",
|
|
21
|
+
"default": "./dist/rrweb-plugin-console-replay.umd.cjs"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"package.json"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"dev": "vite build --watch",
|
|
31
|
+
"build": "yarn turbo run prepublish",
|
|
32
|
+
"check-types": "tsc -noEmit",
|
|
33
|
+
"prepublish": "tsc -noEmit && vite build"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/BetterBugs-Team/rrweb.git"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"rrweb",
|
|
41
|
+
"betterbugs"
|
|
42
|
+
],
|
|
43
|
+
"author": "BetterBugs-Team",
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/BetterBugs-Team/rrweb/issues"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/BetterBugs-Team/rrweb#readme",
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@betterbugs/rrweb-plugin-console-record": "^2.0.0-alpha.19",
|
|
51
|
+
"@betterbugs/rrweb": "^2.0.0-alpha.19",
|
|
52
|
+
"typescript": "^5.4.5",
|
|
53
|
+
"vite": "^5.3.1",
|
|
54
|
+
"vite-plugin-dts": "^3.9.1"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"@betterbugs/rrweb": "^2.0.0-alpha.19"
|
|
58
|
+
}
|
|
59
|
+
}
|