@betterbugs/rrweb 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 +237 -0
- package/dist/assets/image-bitmap-data-url-worker-IJpC7g_b.js.map +1 -0
- package/dist/rrweb.cjs +17087 -0
- package/dist/rrweb.cjs.map +1 -0
- package/dist/rrweb.d.cts +477 -0
- package/dist/rrweb.d.ts +477 -0
- package/dist/rrweb.js +17088 -0
- package/dist/rrweb.js.map +1 -0
- package/dist/rrweb.umd.cjs +17106 -0
- package/dist/rrweb.umd.cjs.map +7 -0
- package/dist/rrweb.umd.min.cjs +98 -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 +96 -0
package/README.md
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img width="100px" height="100px" src="https://www.rrweb.io/favicon.png">
|
|
3
|
+
</p>
|
|
4
|
+
<p align="center">
|
|
5
|
+
<a href="https://www.rrweb.io/" style="font-weight: bold">Try rrweb</a>
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
# rrweb
|
|
9
|
+
|
|
10
|
+
**This is a simpler version of the [original rrweb README](../../README.md) within this rrweb subpackage**
|
|
11
|
+
|
|
12
|
+
[δΈζζζ‘£](../../README.zh_CN.md)
|
|
13
|
+
|
|
14
|
+
rrweb refers to 'record and replay the web', which is a tool for recording and replaying users' interactions on the web.
|
|
15
|
+
|
|
16
|
+
## Guide
|
|
17
|
+
|
|
18
|
+
[**π Read the rrweb guide here. π**](../../guide.md)
|
|
19
|
+
|
|
20
|
+
[**π³ Recipes π³**](../../docs/recipes/index.md)
|
|
21
|
+
|
|
22
|
+
## Project Structure
|
|
23
|
+
|
|
24
|
+
**[rrweb](https://github.com/rrweb-io/rrweb)** mainly includes two funtions:
|
|
25
|
+
|
|
26
|
+
- **Record**: The record function is used to record all the mutations in the DOM
|
|
27
|
+
- **Replay**: The replay function is to replay the recorded mutations one by one according to the corresponding timestamp.
|
|
28
|
+
|
|
29
|
+
## Roadmap
|
|
30
|
+
|
|
31
|
+
- storage engine: do deduplication on a large number of rrweb sessions
|
|
32
|
+
- compact mutation data in common patterns
|
|
33
|
+
- provide plugins via the new plugin API, including:
|
|
34
|
+
- XHR plugin
|
|
35
|
+
- fetch plugin
|
|
36
|
+
- GraphQL plugin
|
|
37
|
+
- ...
|
|
38
|
+
|
|
39
|
+
## Internal Design
|
|
40
|
+
|
|
41
|
+
- [serialization](../../docs/serialization.md)
|
|
42
|
+
- [incremental snapshot](../../docs/observer.md)
|
|
43
|
+
- [replay](../../docs/replay.md)
|
|
44
|
+
- [sandbox](../../docs/sandbox.md)
|
|
45
|
+
|
|
46
|
+
## Contribute Guide
|
|
47
|
+
|
|
48
|
+
Since we want the record and replay sides to share a strongly typed data structure, rrweb is developed with typescript which provides stronger type support.
|
|
49
|
+
|
|
50
|
+
[Typescript handbook](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html)
|
|
51
|
+
|
|
52
|
+
1. Fork this repository.
|
|
53
|
+
2. Run `yarn install` in the root to install required dependencies for all sub-packages (note: `npm install` is _not_ recommended).
|
|
54
|
+
3. Run `yarn dev` in the root to get auto-building for all the sub-packages whenever you modify anything.
|
|
55
|
+
4. Navigate to one of the sub-packages (in the `packages` folder) where you'd like to make a change.
|
|
56
|
+
5. Patch the code and run `yarn test` to run the tests, make sure they pass before you commit anything.
|
|
57
|
+
6. Push the code and create a pull request.
|
|
58
|
+
|
|
59
|
+
Protip: You can run `yarn test` in the root folder to run all the tests.
|
|
60
|
+
|
|
61
|
+
In addition to adding integration tests and unit tests, rrweb also provides a REPL testing tool.
|
|
62
|
+
|
|
63
|
+
[Using the REPL tool](../../guide.md#REPL-tool)
|
|
64
|
+
|
|
65
|
+
## Sponsors
|
|
66
|
+
|
|
67
|
+
[Become a sponsor](https://opencollective.com/rrweb#sponsor) and get your logo on our README on Github with a link to your site.
|
|
68
|
+
|
|
69
|
+
### Gold Sponsors π₯
|
|
70
|
+
|
|
71
|
+
<div dir="auto">
|
|
72
|
+
|
|
73
|
+
<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>
|
|
74
|
+
<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>
|
|
75
|
+
<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>
|
|
76
|
+
<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>
|
|
77
|
+
<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>
|
|
78
|
+
<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>
|
|
79
|
+
<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>
|
|
80
|
+
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
### Silver Sponsors π₯
|
|
84
|
+
|
|
85
|
+
<div dir="auto">
|
|
86
|
+
|
|
87
|
+
<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>
|
|
88
|
+
<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>
|
|
89
|
+
<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>
|
|
90
|
+
<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>
|
|
91
|
+
<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>
|
|
92
|
+
<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>
|
|
93
|
+
<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>
|
|
94
|
+
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
### Bronze Sponsors π₯
|
|
98
|
+
|
|
99
|
+
<div dir="auto">
|
|
100
|
+
|
|
101
|
+
<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>
|
|
102
|
+
<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>
|
|
103
|
+
<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>
|
|
104
|
+
<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>
|
|
105
|
+
<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>
|
|
106
|
+
<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>
|
|
107
|
+
<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>
|
|
108
|
+
<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>
|
|
109
|
+
<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>
|
|
110
|
+
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
### Backers
|
|
114
|
+
|
|
115
|
+
<a href="https://opencollective.com/rrweb#sponsor" rel="nofollow"><img src="https://opencollective.com/rrweb/tiers/backers.svg?avatarHeight=36"></a>
|
|
116
|
+
|
|
117
|
+
## Core Team Members
|
|
118
|
+
|
|
119
|
+
<table>
|
|
120
|
+
<tr>
|
|
121
|
+
<td align="center">
|
|
122
|
+
<a href="https://github.com/Yuyz0112">
|
|
123
|
+
<img
|
|
124
|
+
src="https://avatars.githubusercontent.com/u/13651389?s=100"
|
|
125
|
+
width="100px;"
|
|
126
|
+
alt=""
|
|
127
|
+
/>
|
|
128
|
+
<br /><sub><b>Yuyz0112</b></sub>
|
|
129
|
+
<br /><br />
|
|
130
|
+
</a>
|
|
131
|
+
</td>
|
|
132
|
+
<td align="center">
|
|
133
|
+
<a href="https://github.com/YunFeng0817">
|
|
134
|
+
<img
|
|
135
|
+
src="https://avatars.githubusercontent.com/u/27533910?s=100"
|
|
136
|
+
width="100px;"
|
|
137
|
+
alt=""
|
|
138
|
+
/>
|
|
139
|
+
<br /><sub><b>Yun Feng</b></sub>
|
|
140
|
+
<br /><br />
|
|
141
|
+
</a>
|
|
142
|
+
</td>
|
|
143
|
+
<td align="center">
|
|
144
|
+
<a href="https://github.com/eoghanmurray">
|
|
145
|
+
<img
|
|
146
|
+
src="https://avatars.githubusercontent.com/u/156780?s=100"
|
|
147
|
+
width="100px;"
|
|
148
|
+
alt=""
|
|
149
|
+
/>
|
|
150
|
+
<br /><sub><b>eoghanmurray</b></sub>
|
|
151
|
+
<br /><br />
|
|
152
|
+
</a>
|
|
153
|
+
</td>
|
|
154
|
+
<td align="center">
|
|
155
|
+
<a href="https://github.com/Juice10">
|
|
156
|
+
<img
|
|
157
|
+
src="https://avatars.githubusercontent.com/u/4106?s=100"
|
|
158
|
+
width="100px;"
|
|
159
|
+
alt=""
|
|
160
|
+
/>
|
|
161
|
+
<br /><sub><b>Juice10</b></sub>
|
|
162
|
+
<br /><sub>open for rrweb consulting</sub>
|
|
163
|
+
</a>
|
|
164
|
+
</td>
|
|
165
|
+
</tr>
|
|
166
|
+
</table>
|
|
167
|
+
|
|
168
|
+
## Who's using rrweb?
|
|
169
|
+
|
|
170
|
+
<table>
|
|
171
|
+
<tr>
|
|
172
|
+
<td align="center">
|
|
173
|
+
<a href="http://www.smartx.com/" target="_blank">
|
|
174
|
+
<img width="195px" src="https://www.rrweb.io/logos/smartx.png">
|
|
175
|
+
</a>
|
|
176
|
+
</td>
|
|
177
|
+
<td align="center">
|
|
178
|
+
<a href="https://posthog.com?utm_source=rrweb&utm_medium=sponsorship&utm_campaign=open-source-sponsorship" target="_blank">
|
|
179
|
+
<img width="195px" src="https://www.rrweb.io/logos/posthog.png">
|
|
180
|
+
</a>
|
|
181
|
+
</td>
|
|
182
|
+
<td align="center">
|
|
183
|
+
<a href="https://statcounter.com/session-replay/" target="_blank">
|
|
184
|
+
<img width="195px" src="https://statcounter.com/images/logo-statcounter-arc-blue.svg">
|
|
185
|
+
</a>
|
|
186
|
+
</td>
|
|
187
|
+
<td align="center">
|
|
188
|
+
<a href="https://recordonce.com/" target="_blank">
|
|
189
|
+
<img width="195px" alt="Smart screen recording for SaaS" src="https://uploads-ssl.webflow.com/5f3d133183156245630d4446/5f3d1940abe8db8612c23521_Record-Once-logo-554x80px.svg">
|
|
190
|
+
</a>
|
|
191
|
+
</td>
|
|
192
|
+
</tr>
|
|
193
|
+
<tr>
|
|
194
|
+
<td align="center">
|
|
195
|
+
<a href="https://cux.io" target="_blank">
|
|
196
|
+
<img style="padding: 8px" alt="The first ever UX automation tool" width="195px" src="https://cux.io/cux-logo.svg">
|
|
197
|
+
</a>
|
|
198
|
+
</td>
|
|
199
|
+
<td align="center">
|
|
200
|
+
<a href="https://remsupp.com" target="_blank">
|
|
201
|
+
<img style="padding: 8px" alt="Remote Access & Co-Browsing" width="195px" src="https://remsupp.com/images/logo.png">
|
|
202
|
+
</a>
|
|
203
|
+
</td>
|
|
204
|
+
<td align="center">
|
|
205
|
+
<a href="https://highlight.io" target="_blank">
|
|
206
|
+
<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">
|
|
207
|
+
</a>
|
|
208
|
+
</td>
|
|
209
|
+
<td align="center">
|
|
210
|
+
<a href="https://analyzee.io" target="_blank">
|
|
211
|
+
<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">
|
|
212
|
+
</a>
|
|
213
|
+
</td>
|
|
214
|
+
</tr>
|
|
215
|
+
<tr>
|
|
216
|
+
<td align="center">
|
|
217
|
+
<a href="https://requestly.io" target="_blank">
|
|
218
|
+
<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">
|
|
219
|
+
</a>
|
|
220
|
+
</td>
|
|
221
|
+
<td align="center">
|
|
222
|
+
<a href="https://gleap.io" target="_blank">
|
|
223
|
+
<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">
|
|
224
|
+
</a>
|
|
225
|
+
</td>
|
|
226
|
+
<td align="center">
|
|
227
|
+
<a href="https://uxwizz.com" target="_blank">
|
|
228
|
+
<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">
|
|
229
|
+
</a>
|
|
230
|
+
</td>
|
|
231
|
+
<td align="center">
|
|
232
|
+
<a href="https://www.howdygo.com" target="_blank">
|
|
233
|
+
<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">
|
|
234
|
+
</a>
|
|
235
|
+
</td>
|
|
236
|
+
</tr>
|
|
237
|
+
</table>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-bitmap-data-url-worker-IJpC7g_b.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 '@betterbugs/types';\n\nconst lastBlobMap: Map<number, string> = new Map();\nconst transparentBlobMap: Map<string, string> = new Map();\n\nexport interface ImageBitmapDataURLRequestWorker {\n postMessage: (\n message: ImageBitmapDataURLWorkerParams,\n transfer?: [ImageBitmap],\n ) => void;\n onmessage: (message: MessageEvent<ImageBitmapDataURLWorkerResponse>) => 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// 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 const transparentBase64 = getTransparentBlobFor(\n width,\n height,\n dataURLOptions,\n );\n\n const offscreen = new OffscreenCanvas(width, height);\n const ctx = offscreen.getContext('2d')!;\n\n ctx.drawImage(bitmap, 0, 0);\n bitmap.close();\n const blob = await offscreen.convertToBlob(dataURLOptions); // takes a while\n const type = blob.type;\n const arrayBuffer = await blob.arrayBuffer();\n const base64 = encode(arrayBuffer); // cpu intensive\n\n // on first try we should check if canvas is transparent,\n // no need to save it's contents in that case\n if (!lastBlobMap.has(id) && (await transparentBase64) === base64) {\n lastBlobMap.set(id, base64);\n return worker.postMessage({ id });\n }\n\n if (lastBlobMap.get(id) === base64) return worker.postMessage({ id }); // unchanged\n worker.postMessage({\n id,\n type,\n base64,\n width,\n height,\n });\n lastBlobMap.set(id, base64);\n } else {\n return worker.postMessage({ id: e.data.id });\n }\n};\n"],"names":["i"],"mappings":";;AAKA,MAAI,QAAQ;AAEZ,MAAI,SAAS,OAAO,eAAe,cAAc,CAAE,IAAG,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,IACpC;AACD,QAAI,MAAM,MAAM,GAAG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