@zumer/snapdom 1.9.3 → 1.9.6-dev.0
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 +36 -34
- package/dist/snapdom.js +165 -143
- package/dist/snapdom.min.js +7 -7
- package/dist/snapdom.min.mjs +10 -10
- package/dist/snapdom.mjs +163 -141
- package/package.json +1 -1
- package/types/snapdom.d.ts +1 -0
package/README.md
CHANGED
|
@@ -151,6 +151,9 @@ All capture methods accept an `options` object:
|
|
|
151
151
|
| `backgroundColor` | string | `"#fff"` | Fallback color for JPG/WebP |
|
|
152
152
|
| `quality` | number | `1` | Quality for JPG/WebP (0 to 1) |
|
|
153
153
|
| `useProxy` | string | '' | Specify a proxy for handling CORS images as fallback|
|
|
154
|
+
| `type` | string | `svg` | Select `png`, `jpg`, `webp` Blob type|
|
|
155
|
+
| `exclude` | string[] | - | CSS selectors for elements to exclude |
|
|
156
|
+
| `filter` | function | - | Custom filter function ie `(el) => !el.classList.contains('hidden')` |
|
|
154
157
|
|
|
155
158
|
### Setting custom dimensions with width and height options
|
|
156
159
|
|
|
@@ -256,55 +259,51 @@ import { snapdom, preCache } from './snapdom.mjs';
|
|
|
256
259
|
|
|
257
260
|
## ⚡ Performance Benchmarks
|
|
258
261
|
|
|
259
|
-
Snapdom has received **
|
|
262
|
+
Snapdom has received **significant performance improvements** since version `v1.8.0`. The following benchmarks compare:
|
|
260
263
|
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
264
|
+
* **Snapdom (current)**
|
|
265
|
+
* **Snapdom v1.8.0**
|
|
266
|
+
* `html2canvas`
|
|
267
|
+
* `html-to-image`
|
|
265
268
|
|
|
266
|
-
Each benchmark shows the **fastest observed time** (lower is better), measured in **milliseconds (ms)**.
|
|
267
|
-
|
|
268
|
-
---
|
|
269
269
|
|
|
270
270
|
### Simple elements
|
|
271
271
|
|
|
272
|
-
| Scenario | Snapdom (current) | Snapdom v1.8.0 | html2canvas |
|
|
273
|
-
| ------------------------ | ----------------- | -------------- | ----------- |
|
|
274
|
-
| Small (200×100) | **0.4 ms** | 1.2 ms | 70.3 ms |
|
|
275
|
-
| Modal (400×300) | **0.4 ms** | 1.1 ms | 68.8 ms |
|
|
276
|
-
| Page View (1200×800) | **0.4 ms** | 1.0 ms | 100.5 ms |
|
|
277
|
-
| Large Scroll (2000×1500) | **0.4 ms** | 1.0 ms | 153.1 ms |
|
|
278
|
-
| Very Large (4000×2000) | **0.4 ms** | 1.0 ms | 278.9 ms |
|
|
272
|
+
| Scenario | Snapdom (current) | Snapdom v1.8.0 | html2canvas | html-to-image |
|
|
273
|
+
| ------------------------ | ----------------- | -------------- | ----------- | ------------- |
|
|
274
|
+
| Small (200×100) | **0.4 ms** | 1.2 ms | 70.3 ms | 3.6 ms |
|
|
275
|
+
| Modal (400×300) | **0.4 ms** | 1.1 ms | 68.8 ms | 3.6 ms |
|
|
276
|
+
| Page View (1200×800) | **0.4 ms** | 1.0 ms | 100.5 ms | 3.4 ms |
|
|
277
|
+
| Large Scroll (2000×1500) | **0.4 ms** | 1.0 ms | 153.1 ms | 3.4 ms |
|
|
278
|
+
| Very Large (4000×2000) | **0.4 ms** | 1.0 ms | 278.9 ms | 4.3 ms |
|
|
279
|
+
|
|
279
280
|
|
|
280
|
-
---
|
|
281
281
|
|
|
282
282
|
### Complex elements
|
|
283
283
|
|
|
284
|
-
| Scenario | Snapdom (current) | Snapdom v1.8.0 | html2canvas |
|
|
285
|
-
| ------------------------ | ----------------- | -------------- | ----------- |
|
|
286
|
-
| Small (200×100) | **1.1 ms** | 3.2 ms |
|
|
287
|
-
| Modal (400×300) | **4.5 ms** | 14.0 ms |
|
|
288
|
-
| Page View (1200×800) | **32.9 ms** | 113.6 ms |
|
|
289
|
-
| Large Scroll (2000×1500) | **133.9 ms** | 387.4 ms |
|
|
290
|
-
| Very Large (4000×2000) | **364.0 ms** | 1,200.4 ms | 1,
|
|
284
|
+
| Scenario | Snapdom (current) | Snapdom v1.8.0 | html2canvas | html-to-image |
|
|
285
|
+
| ------------------------ | ----------------- | -------------- | ----------- | ------------- |
|
|
286
|
+
| Small (200×100) | **1.1 ms** | 3.2 ms | 76.0 ms | 15.3 ms |
|
|
287
|
+
| Modal (400×300) | **4.5 ms** | 14.0 ms | 133.2 ms | 55.4 ms |
|
|
288
|
+
| Page View (1200×800) | **32.9 ms** | 113.6 ms | 303.4 ms | 369.1 ms |
|
|
289
|
+
| Large Scroll (2000×1500) | **133.9 ms** | 387.4 ms | 594.4 ms | 1,163.0 ms |
|
|
290
|
+
| Very Large (4000×2000) | **364.0 ms** | 1,200.4 ms | 1,380.8 ms | 3,023.9 ms |
|
|
291
|
+
|
|
291
292
|
|
|
292
|
-
---
|
|
293
293
|
|
|
294
294
|
### Summary
|
|
295
295
|
|
|
296
|
-
* Snapdom (current) is
|
|
297
|
-
* Up to **
|
|
298
|
-
*
|
|
296
|
+
* Snapdom (current) is **2×–6× faster** than `v1.8.0`
|
|
297
|
+
* Up to **150× faster** than `html2canvas`
|
|
298
|
+
* Up to **8× faster** than `html-to-image` in large scenarios
|
|
299
299
|
|
|
300
|
-
<sub>
|
|
301
|
-
|
|
302
|
-
⚠️ Performance
|
|
300
|
+
<sub>Benchmarks run in Chromium using Vitest.<br>
|
|
301
|
+
Hardware: MacBook Air 2018.<br>
|
|
302
|
+
⚠️ Performance may vary depending on device.</sub>
|
|
303
303
|
|
|
304
304
|
|
|
305
|
-
### Run the benchmarks
|
|
306
305
|
|
|
307
|
-
|
|
306
|
+
### Run the benchmarks
|
|
308
307
|
|
|
309
308
|
```sh
|
|
310
309
|
git clone https://github.com/zumerlab/snapdom.git
|
|
@@ -313,8 +312,6 @@ npm install
|
|
|
313
312
|
npm run test:benchmark
|
|
314
313
|
```
|
|
315
314
|
|
|
316
|
-
They execute in **headless Chromium** using real DOM nodes.
|
|
317
|
-
|
|
318
315
|
## Development
|
|
319
316
|
|
|
320
317
|
To contribute or build snapDOM locally:
|
|
@@ -324,6 +321,9 @@ To contribute or build snapDOM locally:
|
|
|
324
321
|
git clone https://github.com/zumerlab/snapdom.git
|
|
325
322
|
cd snapdom
|
|
326
323
|
|
|
324
|
+
# Switch to dev branch
|
|
325
|
+
git checkout dev
|
|
326
|
+
|
|
327
327
|
# Install dependencies
|
|
328
328
|
npm install
|
|
329
329
|
|
|
@@ -347,12 +347,14 @@ For detailed contribution guidelines, please see [CONTRIBUTING](https://github.c
|
|
|
347
347
|
<!-- CONTRIBUTORS:START -->
|
|
348
348
|
<p>
|
|
349
349
|
<a href="https://github.com/tinchox5" title="tinchox5"><img src="https://avatars.githubusercontent.com/u/11557901?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="tinchox5"/></a>
|
|
350
|
+
<a href="https://github.com/tarwin" title="tarwin"><img src="https://avatars.githubusercontent.com/u/646149?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="tarwin"/></a>
|
|
350
351
|
<a href="https://github.com/17biubiu" title="17biubiu"><img src="https://avatars.githubusercontent.com/u/13295895?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="17biubiu"/></a>
|
|
351
352
|
<a href="https://github.com/pedrocateexte" title="pedrocateexte"><img src="https://avatars.githubusercontent.com/u/207524750?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="pedrocateexte"/></a>
|
|
352
353
|
<a href="https://github.com/domialex" title="domialex"><img src="https://avatars.githubusercontent.com/u/4694217?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="domialex"/></a>
|
|
353
354
|
<a href="https://github.com/elliots" title="elliots"><img src="https://avatars.githubusercontent.com/u/622455?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="elliots"/></a>
|
|
354
355
|
<a href="https://github.com/jswhisperer" title="jswhisperer"><img src="https://avatars.githubusercontent.com/u/1177690?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="jswhisperer"/></a>
|
|
355
356
|
<a href="https://github.com/simon1uo" title="simon1uo"><img src="https://avatars.githubusercontent.com/u/60037549?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="simon1uo"/></a>
|
|
357
|
+
<a href="https://github.com/titoBouzout" title="titoBouzout"><img src="https://avatars.githubusercontent.com/u/64156?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="titoBouzout"/></a>
|
|
356
358
|
<a href="https://github.com/jhbae200" title="jhbae200"><img src="https://avatars.githubusercontent.com/u/20170610?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="jhbae200"/></a>
|
|
357
359
|
</p>
|
|
358
360
|
<!-- CONTRIBUTORS:END -->
|