@kalayanasundaram123/rrweb 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +296 -0
- package/dist/assets/image-bitmap-data-url-worker-DIbJg1p8.js.map +1 -0
- package/dist/rrweb.cjs +17778 -0
- package/dist/rrweb.cjs.map +1 -0
- package/dist/rrweb.d.cts +478 -0
- package/dist/rrweb.d.ts +478 -0
- package/dist/rrweb.js +17779 -0
- package/dist/rrweb.js.map +1 -0
- package/dist/rrweb.umd.cjs +17784 -0
- package/dist/rrweb.umd.cjs.map +7 -0
- package/dist/rrweb.umd.min.cjs +195 -0
- package/dist/rrweb.umd.min.cjs.map +7 -0
- package/dist/style.css +79 -0
- package/dist/style.min.css +2 -0
- package/dist/style.min.css.map +7 -0
- package/package.json +100 -0
- package/umd/rrweb.js +17784 -0
- package/umd/rrweb.min.js +195 -0
package/README.md
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
# rrweb
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
> **Deprecated.** `rrweb` is kept for backward compatibility only. New projects should depend on [@rrweb/record](packages/record/) and [@rrweb/replay](packages/replay/) directly, or use [@rrweb/all](packages/all/) for a single convenience import. Moving to these entrypoints lets us slim down and eventually remove this package.
|
|
6
|
+
|
|
7
|
+
rrweb refers to 'record and replay the web', a tool for recording and replaying users' interactions on the web.
|
|
8
|
+
|
|
9
|
+
In most production setups, the recorder and replayer are deployed to different pages/apps. Use [@rrweb/record](packages/record/) on recorded pages and [@rrweb/replay](packages/replay/) (or [rrweb-player](packages/rrweb-player/) to include UI) on replay pages.
|
|
10
|
+
|
|
11
|
+
| Use case | Package choice |
|
|
12
|
+
| ----------------------------------------------- | --------------------------------- |
|
|
13
|
+
| Most apps (explicit record/replay dependencies) | `@rrweb/record` + `@rrweb/replay` |
|
|
14
|
+
| Single import for record, replay + packer | `@rrweb/all` |
|
|
15
|
+
|
|
16
|
+
### Dev Note
|
|
17
|
+
|
|
18
|
+
As this was the original rrweb package, typescript code for both @rrweb/record and @rrweb/replay still lives in src/record and src/replay in this package. These will be refactored into their respective packages in due course, but for now this package is the principal one for both record and replay related PRs. See [Contributing to rrweb](../../CONTRIBUTING.md) for more info.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
### 1) Bundler / npm (Recommended)
|
|
23
|
+
|
|
24
|
+
For new projects:
|
|
25
|
+
|
|
26
|
+
```shell
|
|
27
|
+
npm install @rrweb/record @rrweb/replay
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
import { record } from '@rrweb/record';
|
|
32
|
+
import { Replayer } from '@rrweb/replay';
|
|
33
|
+
import '@rrweb/replay/dist/style.css';
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Convenience single-package option:
|
|
37
|
+
|
|
38
|
+
```shell
|
|
39
|
+
npm install @rrweb/all
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
import { record, Replayer, pack, unpack } from '@rrweb/all';
|
|
44
|
+
import '@rrweb/all/dist/style.css';
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Legacy compatibility package:
|
|
48
|
+
|
|
49
|
+
```shell
|
|
50
|
+
npm install rrweb
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import { record, Replayer } from 'rrweb';
|
|
55
|
+
import 'rrweb/dist/style.css';
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 2) Browser Without Bundler (ESM)
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<link
|
|
62
|
+
rel="stylesheet"
|
|
63
|
+
href="https://cdn.rrweb.com/replay/current/dist/style.css"
|
|
64
|
+
/>
|
|
65
|
+
<script type="module">
|
|
66
|
+
import { record } from 'https://cdn.rrweb.com/record/current/dist/record.js';
|
|
67
|
+
import { Replayer } from 'https://cdn.rrweb.com/replay/current/dist/replay.js';
|
|
68
|
+
</script>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Use `current` for the latest stable release, or pin exact versions such as
|
|
72
|
+
`https://cdn.rrweb.com/record/2.0.0/dist/record.js` and
|
|
73
|
+
`https://cdn.rrweb.com/replay/2.0.0/dist/replay.js` for immutable
|
|
74
|
+
production URLs.
|
|
75
|
+
|
|
76
|
+
### 3) Legacy Direct `<script>` Include (UMD fallback)
|
|
77
|
+
|
|
78
|
+
Use this only for compatibility with non-module environments; modern browsers
|
|
79
|
+
support the ESM method above.
|
|
80
|
+
|
|
81
|
+
```html
|
|
82
|
+
<link
|
|
83
|
+
rel="stylesheet"
|
|
84
|
+
href="https://cdn.rrweb.com/replay/current/dist/style.css"
|
|
85
|
+
/>
|
|
86
|
+
<script src="https://cdn.rrweb.com/record/current/dist/record.umd.cjs"></script>
|
|
87
|
+
<script src="https://cdn.rrweb.com/replay/current/dist/replay.umd.cjs"></script>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Sponsors
|
|
91
|
+
|
|
92
|
+
[Become a sponsor](https://opencollective.com/rrweb#sponsor) and get your logo on our README on Github with a link to your site.
|
|
93
|
+
|
|
94
|
+
### Gold Sponsors 🥇
|
|
95
|
+
|
|
96
|
+
<div dir="auto">
|
|
97
|
+
|
|
98
|
+
<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>
|
|
99
|
+
<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>
|
|
100
|
+
<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>
|
|
101
|
+
<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>
|
|
102
|
+
<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>
|
|
103
|
+
<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>
|
|
104
|
+
<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>
|
|
105
|
+
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
### Silver Sponsors 🥈
|
|
109
|
+
|
|
110
|
+
<div dir="auto">
|
|
111
|
+
|
|
112
|
+
<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>
|
|
113
|
+
<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>
|
|
114
|
+
<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>
|
|
115
|
+
<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>
|
|
116
|
+
<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>
|
|
117
|
+
<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>
|
|
118
|
+
<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>
|
|
119
|
+
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
### Bronze Sponsors 🥉
|
|
123
|
+
|
|
124
|
+
<div dir="auto">
|
|
125
|
+
|
|
126
|
+
<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>
|
|
127
|
+
<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>
|
|
128
|
+
<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>
|
|
129
|
+
<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>
|
|
130
|
+
<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>
|
|
131
|
+
<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>
|
|
132
|
+
<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>
|
|
133
|
+
<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>
|
|
134
|
+
<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>
|
|
135
|
+
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
### Backers
|
|
139
|
+
|
|
140
|
+
<a href="https://opencollective.com/rrweb#sponsor" rel="nofollow"><img src="https://opencollective.com/rrweb/tiers/backers.svg?avatarHeight=36"></a>
|
|
141
|
+
|
|
142
|
+
## Core Team Members
|
|
143
|
+
|
|
144
|
+
<table>
|
|
145
|
+
<tr>
|
|
146
|
+
<td align="center">
|
|
147
|
+
<a href="https://github.com/Yuyz0112">
|
|
148
|
+
<img
|
|
149
|
+
src="https://avatars.githubusercontent.com/u/13651389?s=100"
|
|
150
|
+
width="100px;"
|
|
151
|
+
alt=""
|
|
152
|
+
/>
|
|
153
|
+
<br /><sub><b>Yuyz0112</b></sub>
|
|
154
|
+
<br /><br />
|
|
155
|
+
</a>
|
|
156
|
+
</td>
|
|
157
|
+
<td align="center">
|
|
158
|
+
<a href="https://github.com/YunFeng0817">
|
|
159
|
+
<img
|
|
160
|
+
src="https://avatars.githubusercontent.com/u/27533910?s=100"
|
|
161
|
+
width="100px;"
|
|
162
|
+
alt=""
|
|
163
|
+
/>
|
|
164
|
+
<br /><sub><b>Yun Feng</b></sub>
|
|
165
|
+
<br /><br />
|
|
166
|
+
</a>
|
|
167
|
+
</td>
|
|
168
|
+
<td align="center">
|
|
169
|
+
<a href="https://github.com/eoghanmurray">
|
|
170
|
+
<img
|
|
171
|
+
src="https://avatars.githubusercontent.com/u/156780?s=100"
|
|
172
|
+
width="100px;"
|
|
173
|
+
alt=""
|
|
174
|
+
/>
|
|
175
|
+
<br /><sub><b>eoghanmurray</b></sub>
|
|
176
|
+
<br /><br />
|
|
177
|
+
</a>
|
|
178
|
+
</td>
|
|
179
|
+
<td align="center">
|
|
180
|
+
<a href="https://github.com/Juice10">
|
|
181
|
+
<img
|
|
182
|
+
src="https://avatars.githubusercontent.com/u/4106?s=100"
|
|
183
|
+
width="100px;"
|
|
184
|
+
alt=""
|
|
185
|
+
/>
|
|
186
|
+
<br /><sub><b>Juice10</b></sub>
|
|
187
|
+
<br /><sub>open for rrweb consulting</sub>
|
|
188
|
+
</a>
|
|
189
|
+
</td>
|
|
190
|
+
</tr>
|
|
191
|
+
</table>
|
|
192
|
+
|
|
193
|
+
## Who's using rrweb?
|
|
194
|
+
|
|
195
|
+
<table>
|
|
196
|
+
<tr>
|
|
197
|
+
<td align="center">
|
|
198
|
+
<a href="http://www.smartx.com/" target="_blank">
|
|
199
|
+
<img width="195px" src="https://raw.githubusercontent.com/rrweb-io/web/master/static/logos/smartx.png" alt="SmartX">
|
|
200
|
+
</a>
|
|
201
|
+
</td>
|
|
202
|
+
<td align="center">
|
|
203
|
+
<a href="https://posthog.com?utm_source=rrweb&utm_medium=sponsorship&utm_campaign=open-source-sponsorship" target="_blank">
|
|
204
|
+
<img width="195px" src="https://rrweb.com/posthog.png" alt="PostHog">
|
|
205
|
+
</a>
|
|
206
|
+
</td>
|
|
207
|
+
<td align="center">
|
|
208
|
+
<a href="https://statcounter.com/session-replay/" target="_blank">
|
|
209
|
+
<img width="195px" src="https://statcounter.com/images/logo-statcounter-arc-blue.svg">
|
|
210
|
+
</a>
|
|
211
|
+
</td>
|
|
212
|
+
<td align="center">
|
|
213
|
+
<a href="https://recordonce.com/" target="_blank">
|
|
214
|
+
<img width="195px" alt="Smart screen recording for SaaS" src="https://uploads-ssl.webflow.com/5f3d133183156245630d4446/5f3d1940abe8db8612c23521_Record-Once-logo-554x80px.svg">
|
|
215
|
+
</a>
|
|
216
|
+
</td>
|
|
217
|
+
</tr>
|
|
218
|
+
<tr>
|
|
219
|
+
<td align="center">
|
|
220
|
+
<a href="https://sentry.io" target="_blank">
|
|
221
|
+
<img width="195px" src="https://rrweb.com/sentry.png" alt="Sentry">
|
|
222
|
+
</a>
|
|
223
|
+
</td>
|
|
224
|
+
<td align="center">
|
|
225
|
+
<a href="https://www.pendo.io" target="_blank">
|
|
226
|
+
<img width="195px" src="https://rrweb.com/pendo.png" alt="Pendo">
|
|
227
|
+
</a>
|
|
228
|
+
</td>
|
|
229
|
+
<td align="center">
|
|
230
|
+
<a href="https://mixpanel.com" target="_blank">
|
|
231
|
+
<img width="195px" src="https://rrweb.com/mixpanel.png" alt="Mixpanel">
|
|
232
|
+
</a>
|
|
233
|
+
</td>
|
|
234
|
+
<td align="center">
|
|
235
|
+
<a href="https://www.datadoghq.com" target="_blank">
|
|
236
|
+
<img width="195px" src="https://rrweb.com/datadog.png" alt="Datadog">
|
|
237
|
+
</a>
|
|
238
|
+
</td>
|
|
239
|
+
</tr>
|
|
240
|
+
<tr>
|
|
241
|
+
<td align="center">
|
|
242
|
+
<a href="https://amplitude.com" target="_blank">
|
|
243
|
+
<img width="195px" src="https://rrweb.com/amplitude.png" alt="Amplitude">
|
|
244
|
+
</a>
|
|
245
|
+
</td>
|
|
246
|
+
<td align="center">
|
|
247
|
+
<a href="https://newrelic.com" target="_blank">
|
|
248
|
+
<img width="195px" src="https://rrweb.com/new%20relic.png" alt="New Relic">
|
|
249
|
+
</a>
|
|
250
|
+
</td>
|
|
251
|
+
<td align="center">
|
|
252
|
+
<a href="https://cux.io" target="_blank">
|
|
253
|
+
<img style="padding: 8px" alt="The first ever UX automation tool" width="195px" src="https://cux.io/cux-logo.svg">
|
|
254
|
+
</a>
|
|
255
|
+
</td>
|
|
256
|
+
<td align="center">
|
|
257
|
+
<a href="https://remsupp.com" target="_blank">
|
|
258
|
+
<img style="padding: 8px" alt="Remote Access & Co-Browsing" width="195px" src="https://remsupp.com/images/logo.png">
|
|
259
|
+
</a>
|
|
260
|
+
</td>
|
|
261
|
+
</tr>
|
|
262
|
+
<tr>
|
|
263
|
+
<td align="center">
|
|
264
|
+
<a href="https://highlight.io" target="_blank">
|
|
265
|
+
<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">
|
|
266
|
+
</a>
|
|
267
|
+
</td>
|
|
268
|
+
<td align="center">
|
|
269
|
+
<a href="https://analyzee.io" target="_blank">
|
|
270
|
+
<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://analyzee.io/img/analyzee-main-logo.webp">
|
|
271
|
+
</a>
|
|
272
|
+
</td>
|
|
273
|
+
<td align="center">
|
|
274
|
+
<a href="https://requestly.io" target="_blank">
|
|
275
|
+
<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">
|
|
276
|
+
</a>
|
|
277
|
+
</td>
|
|
278
|
+
<td align="center">
|
|
279
|
+
<a href="https://gleap.io" target="_blank">
|
|
280
|
+
<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">
|
|
281
|
+
</a>
|
|
282
|
+
</td>
|
|
283
|
+
</tr>
|
|
284
|
+
<tr>
|
|
285
|
+
<td align="center">
|
|
286
|
+
<a href="https://uxwizz.com" target="_blank">
|
|
287
|
+
<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">
|
|
288
|
+
</a>
|
|
289
|
+
</td>
|
|
290
|
+
<td align="center">
|
|
291
|
+
<a href="https://www.howdygo.com" target="_blank">
|
|
292
|
+
<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">
|
|
293
|
+
</a>
|
|
294
|
+
</td>
|
|
295
|
+
</tr>
|
|
296
|
+
</table>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-bitmap-data-url-worker-DIbJg1p8.js","sources":["../../../node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js","../src/record/workers/image-bitmap-data-url-worker.ts"],"sourcesContent":["/*\n * base64-arraybuffer 1.0.2 <https://github.com/niklasvh/base64-arraybuffer>\n * Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>\n * Released under MIT License\n */\nvar chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\n// Use a lookup table to find the index.\nvar lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);\nfor (var i = 0; i < chars.length; i++) {\n lookup[chars.charCodeAt(i)] = i;\n}\nvar encode = function (arraybuffer) {\n var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';\n for (i = 0; i < len; i += 3) {\n base64 += chars[bytes[i] >> 2];\n base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];\n base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];\n base64 += chars[bytes[i + 2] & 63];\n }\n if (len % 3 === 2) {\n base64 = base64.substring(0, base64.length - 1) + '=';\n }\n else if (len % 3 === 1) {\n base64 = base64.substring(0, base64.length - 2) + '==';\n }\n return base64;\n};\nvar decode = function (base64) {\n var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;\n if (base64[base64.length - 1] === '=') {\n bufferLength--;\n if (base64[base64.length - 2] === '=') {\n bufferLength--;\n }\n }\n var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);\n for (i = 0; i < len; i += 4) {\n encoded1 = lookup[base64.charCodeAt(i)];\n encoded2 = lookup[base64.charCodeAt(i + 1)];\n encoded3 = lookup[base64.charCodeAt(i + 2)];\n encoded4 = lookup[base64.charCodeAt(i + 3)];\n bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);\n bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);\n bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);\n }\n return arraybuffer;\n};\n\nexport { decode, encode };\n//# sourceMappingURL=base64-arraybuffer.es5.js.map\n","import { encode } from 'base64-arraybuffer';\nimport type {\n DataURLOptions,\n ImageBitmapDataURLWorkerParams,\n ImageBitmapDataURLWorkerResponse,\n} from '@rrweb/types';\n\n// Per-canvas fingerprint of the last emitted frame. Storing a small hash (not\n// the full base64) keeps memory flat and lets us skip base64-encoding frames\n// that haven't changed — the dominant cost for a busy canvas.\nconst lastFingerprintMap: Map<number, string> = new Map();\nconst transparentBlobMap: Map<string, string> = new Map();\n\n// FNV-1a: fast, allocation-free hash over the encoded image bytes.\nfunction fnv1aHash(buffer: ArrayBuffer): string {\n const view = new Uint8Array(buffer);\n let hash = 0x811c9dc5;\n for (let i = 0; i < view.length; i++) {\n hash ^= view[i];\n hash = (hash * 0x01000193) | 0;\n }\n return (hash >>> 0).toString(16);\n}\n\nexport interface ImageBitmapDataURLRequestWorker {\n postMessage: (\n message: ImageBitmapDataURLWorkerParams,\n transfer?: [ImageBitmap],\n ) => void;\n onmessage: (message: MessageEvent<ImageBitmapDataURLWorkerResponse>) => void;\n terminate: () => void;\n}\n\ninterface ImageBitmapDataURLResponseWorker {\n onmessage:\n | null\n | ((message: MessageEvent<ImageBitmapDataURLWorkerParams>) => void);\n postMessage(e: ImageBitmapDataURLWorkerResponse): void;\n}\n\nasync function getTransparentBlobFor(\n width: number,\n height: number,\n dataURLOptions: DataURLOptions,\n): Promise<string> {\n const id = `${width}-${height}`;\n if ('OffscreenCanvas' in globalThis) {\n if (transparentBlobMap.has(id)) return transparentBlobMap.get(id)!;\n const offscreen = new OffscreenCanvas(width, height);\n offscreen.getContext('2d'); // creates rendering context for `converToBlob`\n const blob = await offscreen.convertToBlob(dataURLOptions); // takes a while\n const arrayBuffer = await blob.arrayBuffer();\n const base64 = encode(arrayBuffer); // cpu intensive\n transparentBlobMap.set(id, base64);\n return base64;\n } else {\n return '';\n }\n}\n\n// `as any` because: https://github.com/Microsoft/TypeScript/issues/20595\nconst worker: ImageBitmapDataURLResponseWorker = self;\n\n// Reused across frames to avoid allocating a fresh OffscreenCanvas every tick.\nlet reusableCanvas: OffscreenCanvas | null = null;\nlet reusableCtx: OffscreenCanvasRenderingContext2D | null = null;\n\n// eslint-disable-next-line @typescript-eslint/no-misused-promises\nworker.onmessage = async function (e) {\n if ('OffscreenCanvas' in globalThis) {\n const { id, bitmap, width, height, dataURLOptions } = e.data;\n\n try {\n const transparentBase64 = getTransparentBlobFor(\n width,\n height,\n dataURLOptions,\n );\n\n if (\n !reusableCanvas ||\n reusableCanvas.width !== width ||\n reusableCanvas.height !== height\n ) {\n reusableCanvas = new OffscreenCanvas(width, height);\n reusableCtx = reusableCanvas.getContext('2d')!;\n }\n\n reusableCtx!.clearRect(0, 0, width, height);\n reusableCtx!.drawImage(bitmap, 0, 0);\n bitmap.close();\n const blob = await reusableCanvas.convertToBlob(dataURLOptions); // takes a while\n const type = blob.type;\n const arrayBuffer = await blob.arrayBuffer();\n const fingerprint = fnv1aHash(arrayBuffer);\n\n // on first try we should check if canvas is transparent,\n // no need to save its contents in that case\n if (!lastFingerprintMap.has(id)) {\n const base64 = encode(arrayBuffer); // cpu intensive\n if ((await transparentBase64) === base64) {\n lastFingerprintMap.set(id, fingerprint);\n return worker.postMessage({ id });\n }\n lastFingerprintMap.set(id, fingerprint);\n worker.postMessage({ id, type, base64, width, height });\n return;\n }\n\n if (lastFingerprintMap.get(id) === fingerprint) {\n return worker.postMessage({ id }); // unchanged, no need to re-encode\n }\n\n const base64 = encode(arrayBuffer); // cpu intensive\n worker.postMessage({ id, type, base64, width, height });\n lastFingerprintMap.set(id, fingerprint);\n } catch {\n // Always respond so the main thread clears its in-progress marker.\n worker.postMessage({ id });\n }\n } else {\n e.data.bitmap.close();\n return worker.postMessage({ id: e.data.id });\n }\n};\n"],"names":["i","base64"],"mappings":";;AAKA,MAAI,QAAQ;AAEZ,MAAI,SAAS,OAAO,eAAe,cAAc,CAAA,IAAK,IAAI,WAAW,GAAG;AACxE,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACnC,WAAO,MAAM,WAAW,CAAC,CAAC,IAAI;AAAA,EAClC;AACA,MAAI,SAAS,SAAU,aAAa;AAChC,QAAI,QAAQ,IAAI,WAAW,WAAW,GAAGA,IAAG,MAAM,MAAM,QAAQ,SAAS;AACzE,SAAKA,KAAI,GAAGA,KAAI,KAAKA,MAAK,GAAG;AACzB,gBAAU,MAAM,MAAMA,EAAC,KAAK,CAAC;AAC7B,gBAAU,OAAQ,MAAMA,EAAC,IAAI,MAAM,IAAM,MAAMA,KAAI,CAAC,KAAK,CAAE;AAC3D,gBAAU,OAAQ,MAAMA,KAAI,CAAC,IAAI,OAAO,IAAM,MAAMA,KAAI,CAAC,KAAK,CAAE;AAChE,gBAAU,MAAM,MAAMA,KAAI,CAAC,IAAI,EAAE;AAAA,IACzC;AACI,QAAI,MAAM,MAAM,GAAG;AACf,eAAS,OAAO,UAAU,GAAG,OAAO,SAA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