@zumer/snapdom 1.9.7 → 1.9.9

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 CHANGED
@@ -1,8 +1,6 @@
1
- # snapDOM
2
-
3
1
  <p align="center">
4
2
  <a href="http://zumerlab.github.io/snapdom">
5
- <img src="https://raw.githubusercontent.com/zumerlab/snapdom/main/docs/assets/hero.png" width="80%">
3
+ <img src="https://raw.githubusercontent.com/zumerlab/snapdom/main/docs/assets/newhero.png" width="70%">
6
4
  </a>
7
5
  </p>
8
6
 
@@ -28,13 +26,15 @@
28
26
  </a>
29
27
  </p>
30
28
 
29
+ # snapDOM
30
+
31
31
  **snapDOM** is a fast and accurate DOM-to-image capture tool built for **Zumly**, a zoom-based view transition framework.
32
32
 
33
33
  It captures any HTML element as a scalable SVG image, preserving styles, fonts, background images, pseudo-elements, and even shadow DOM. It also supports export to raster image formats and canvas.
34
34
 
35
35
  * 📸 Full DOM capture
36
36
  * 🎨 Embedded styles, pseudo-elements, and fonts
37
- * 🖼️ Export to SVG, PNG, JPG, WebP, or `canvas`
37
+ * 🖼️ Export to SVG, PNG, JPG, WebP, `canvas`, or Blob
38
38
  * ⚡ Ultra fast, no dependencies
39
39
  * 📦 100% based on standard Web APIs
40
40
 
@@ -54,6 +54,12 @@ npm i @zumer/snapdom
54
54
  yarn add @zumer/snapdom
55
55
  ```
56
56
 
57
+ Then import it in your code:
58
+
59
+ ```js
60
+ import { snapdom } from '@zumer/snapdom';
61
+ ```
62
+
57
63
  ### CDN
58
64
 
59
65
  ```html
@@ -145,12 +151,15 @@ All capture methods accept an `options` object:
145
151
  | `compress` | boolean | `true` | Removes redundant styles |
146
152
  | `fast` | boolean | `true` | Skips idle delay for faster results |
147
153
  | `embedFonts` | boolean | `false` | Inlines fonts (icon fonts always embedded) |
154
+ | `localFonts` | array | `[]` | Array of local font descriptors `{ family, src, weight?, style? }` |
155
+ | `iconFonts` | string \| RegExp \| (string \| RegExp)[] | `[]` | Additional icon font families or patterns |
148
156
  | `scale` | number | `1` | Output scale multiplier |
157
+ | `dpr` | number | `devicePixelRatio` | Device pixel ratio |
149
158
  | `width` | number | - | Output specific width size |
150
159
  | `height` | number | - | Output specific height size |
151
160
  | `backgroundColor` | string | `"#fff"` | Fallback color for JPG/WebP |
152
161
  | `quality` | number | `1` | Quality for JPG/WebP (0 to 1) |
153
- | `useProxy` | string | '' | Specify a proxy for handling CORS images as fallback|
162
+ | `useProxy` | string | '' | Specify a proxy for handling CORS images/fonts as fallback|
154
163
  | `type` | string | `svg` | Select `png`, `jpg`, `webp` Blob type|
155
164
  | `exclude` | string[] | - | CSS selectors for elements to exclude |
156
165
  | `filter` | function | - | Custom filter function ie `(el) => !el.classList.contains('hidden')` |
@@ -217,7 +226,7 @@ const result = await snapdom(element, {
217
226
 
218
227
  ### `preCache()` – Optional helper
219
228
 
220
- The `preCache()` function can be used to load external resources (like images and fonts) in advance. It is specially useful when the element to capure is big and complex.
229
+ The `preCache()` function can be used to load external resources (like images and fonts) in advance. It is specially useful when the element to capture is big and complex.
221
230
 
222
231
  ```js
223
232
  import { preCache } from '@zumer/snapdom';
@@ -236,7 +245,9 @@ import { snapdom, preCache } from './snapdom.mjs';
236
245
  **Options for `preCache()`:**
237
246
 
238
247
  * `embedFonts` *(boolean, default: true)* — Inlines non-icon fonts during preload.
239
- * `useProxy` *(string)* — Proxy for handling CORS images as fallback.
248
+ * `localFonts` *(array)* — Array of `{ family, src, weight?, style? }` for local font sources.
249
+ * `useProxy` *(string)* — Proxy for handling CORS images/fonts as fallback.
250
+
240
251
 
241
252
 
242
253
  ## Features
@@ -250,7 +261,7 @@ import { snapdom, preCache } from './snapdom.mjs';
250
261
 
251
262
  ## Limitations
252
263
 
253
- * External images shloud be CORS-accessible (use `useProxy` option for handling CORS denied)
264
+ * External images should be CORS-accessible (use `useProxy` option for handling CORS denied)
254
265
  * Iframes are not supported
255
266
  * When WebP format is used on Safari, it will fallback to PNG rendering.
256
267
  * `@font-face` CSS rule is well supported, but if need to use JS `FontFace()`, see this workaround [`#43`](https://github.com/zumerlab/snapdom/issues/43)
@@ -311,6 +322,36 @@ npm install
311
322
  npm run test:benchmark
312
323
  ```
313
324
 
325
+
326
+ ## Roadmap
327
+
328
+ Planned improvements for future versions of SnapDOM:
329
+
330
+ * [ ] **Implement plugin system**
331
+ SnapDOM will support external plugins to extend or override internal behavior (e.g. custom node transformers, exporters, or filters).
332
+
333
+ * [ ] **Refactor to modular architecture**
334
+ Internal logic will be split into smaller, focused modules to improve maintainability and code reuse.
335
+
336
+ * [X] **Decouple internal logic from global options**
337
+ Functions will be redesigned to avoid relying directly on `options`. A centralized capture context will improve clarity, autonomy, and testability. See [`next` branch](https://github.com/zumerlab/snapdom/tree/main)
338
+
339
+ * [ ] **Expose cache control**
340
+ Users will be able to manually clear image and font caches or configure their own caching strategies.
341
+
342
+ * [ ] **Auto font preloading**
343
+ Required fonts will be automatically detected and preloaded before capture, reducing the need for manual `preCache()` calls.
344
+
345
+ * [ ] **Document plugin development**
346
+ A full guide will be provided for creating and registering custom SnapDOM plugins.
347
+
348
+ * [ ] **Make export utilities tree-shakeable**
349
+ Export functions like `toPng`, `toJpg`, `toBlob`, etc. will be restructured into independent modules to support tree shaking and minimal builds.
350
+
351
+ Have ideas or feature requests?
352
+ Feel free to share suggestions or feedback in [GitHub Discussions](https://github.com/zumerlab/snapdom/discussions).
353
+
354
+
314
355
  ## Development
315
356
 
316
357
  To contribute or build snapDOM locally:
@@ -351,16 +392,21 @@ For detailed contribution guidelines, please see [CONTRIBUTING](https://github.c
351
392
  <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>
352
393
  <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>
353
394
  <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>
395
+ <a href="https://github.com/av01d" title="av01d"><img src="https://avatars.githubusercontent.com/u/6247646?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="av01d"/></a>
396
+ <a href="https://github.com/CHOYSEN" title="CHOYSEN"><img src="https://avatars.githubusercontent.com/u/25995358?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="CHOYSEN"/></a>
354
397
  <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>
355
398
  <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>
356
399
  <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>
357
400
  <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>
401
+ <a href="https://github.com/sharuzzaman" title="sharuzzaman"><img src="https://avatars.githubusercontent.com/u/7421941?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="sharuzzaman"/></a>
358
402
  <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>
359
403
  <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>
360
404
  <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>
361
405
  <a href="https://github.com/miusuncle" title="miusuncle"><img src="https://avatars.githubusercontent.com/u/7549857?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="miusuncle"/></a>
362
406
  <a href="https://github.com/rbbydotdev" title="rbbydotdev"><img src="https://avatars.githubusercontent.com/u/101137670?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="rbbydotdev"/></a>
407
+ <a href="https://github.com/zhanghaotian2018" title="zhanghaotian2018"><img src="https://avatars.githubusercontent.com/u/169218899?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="zhanghaotian2018"/></a>
363
408
  <a href="https://github.com/kohaiy" title="kohaiy"><img src="https://avatars.githubusercontent.com/u/15622127?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="kohaiy"/></a>
409
+ <a href="https://github.com/fu050409" title="fu050409"><img src="https://avatars.githubusercontent.com/u/46275354?v=4&s=100" style="border-radius:10px; width:60px; height:60px; object-fit:cover; margin:5px;" alt="fu050409"/></a>
364
410
  </p>
365
411
  <!-- CONTRIBUTORS:END -->
366
412
 
@@ -370,6 +416,10 @@ Special thanks to [@megaphonecolin](https://github.com/megaphonecolin) for suppo
370
416
 
371
417
  If you'd like to support this project too, you can [become a sponsor](https://github.com/sponsors/tinchox5).
372
418
 
419
+ ## Star History
420
+
421
+ [![Star History Chart](https://api.star-history.com/svg?repos=zumerlab/snapdom&type=Date)](https://www.star-history.com/#zumerlab/snapdom&Date)
422
+
373
423
  ## License
374
424
 
375
425
  MIT © Zumerlab