@zumer/snapdom 2.16.0 → 2.18.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zumer/snapdom",
3
- "version": "2.16.0",
3
+ "version": "2.18.0",
4
4
  "description": "Fast, modern alternative to html2canvas — captures HTML elements to images (PNG, JPG, SVG, WebP) with exceptional speed and accuracy.",
5
5
  "type": "module",
6
6
  "main": "./dist/snapdom.js",
@@ -34,6 +34,10 @@
34
34
  "lint": "eslint src __tests__ --ext .js",
35
35
  "lint:fix": "eslint src __tests__ --ext .js --fix",
36
36
  "test": "npm run lint:fix && npx vitest run --browser.headless --reporter=verbose",
37
+ "test:firefox": "BROWSER=firefox npx vitest run --browser.headless --reporter=verbose",
38
+ "test:webkit": "BROWSER=webkit npx vitest run --browser.headless --reporter=verbose",
39
+ "test:full": "npm run lint:fix && BROWSER=all npx vitest run --browser.headless --reporter=verbose",
40
+ "report:cross": "node scripts/cross-report.mjs",
37
41
  "test:coverage": "npx vitest run --browser.headless --coverage",
38
42
  "test:benchmark": "npx vitest bench --browser.headless --watch=false",
39
43
  "bump:dry": "npx @zumerbox/bump -d",
@@ -82,10 +86,13 @@
82
86
  "@eslint/js": "^9.36.0",
83
87
  "@vitest/browser": "^3.1.2",
84
88
  "@vitest/coverage-v8": "^3.1.2",
85
- "@zumer/snapdiff": "^0.1.1",
89
+ "@zumer/snapdiff": "^0.2.2",
86
90
  "esbuild": "^0.28.1",
87
91
  "eslint": "^9.36.0",
88
92
  "globals": "^16.4.0",
89
93
  "playwright": "^1.52.0"
94
+ },
95
+ "overrides": {
96
+ "vite": "^6"
90
97
  }
91
98
  }
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * snapDOM – ultra-fast DOM-to-image capture
3
- * TypeScript definitions (v1.9.14)
3
+ * TypeScript definitions (v2.16)
4
4
  *
5
5
  * Notes:
6
6
  * - Style compression is internal (no public option).
7
7
  * - Icon fonts are always embedded; `embedFonts` controls non-icon fonts only.
8
- * - This file preserves backward compatibility with earlier 1.9.x defs.
8
+ * - This file preserves backward compatibility with earlier defs.
9
9
  */
10
10
 
11
11
  /* =========================
@@ -27,6 +27,8 @@ export interface LocalFont {
27
27
  src: string; // URL or data: URL
28
28
  weight?: string | number;
29
29
  style?: string;
30
+ /** font-stretch as a percentage (e.g. 100). Default 100. */
31
+ stretchPct?: number;
30
32
  }
31
33
 
32
34
  export interface ExcludeFonts {
@@ -54,9 +56,9 @@ export interface SnapdomOptions {
54
56
  /** Target height of the export (keeps aspect if only one dimension is provided). */
55
57
  height?: number;
56
58
 
57
- /** Background fallback color (used esp. for JPEG). Default "#fff". */
59
+ /** Background fallback color. Default: `"#ffffff"` for JPEG/WebP, `null` (transparent) otherwise. */
58
60
  backgroundColor?: string;
59
- /** Quality for JPEG/WebP (0..1). Default 1. */
61
+ /** Quality for JPEG/WebP (0..1). Default 0.92. */
60
62
  quality?: number;
61
63
  /** Output format for capture/export helpers. Default "png". */
62
64
  format?: BlobType;
@@ -90,8 +92,8 @@ export interface SnapdomOptions {
90
92
 
91
93
  /**
92
94
  * Downsample inlined raster images to their visible resolution (display box × scale × dpr),
93
- * preserving the source codec (lossless PNG stays lossless). Opt-in; off by default — output is
94
- * byte-identical to omitting it.
95
+ * preserving the source codec (lossless PNG stays lossless). On by default; pass `false`
96
+ * to embed images verbatim.
95
97
  */
96
98
  compress?: boolean;
97
99
 
@@ -103,6 +105,23 @@ export interface SnapdomOptions {
103
105
  iconFonts?: IconFontMatcher | IconFontMatcher[];
104
106
  /** Skip specific non-icon fonts (by family/domain/subset). */
105
107
  excludeFonts?: ExcludeFonts;
108
+ /** Extra domains allowed for cross-origin font stylesheet fetches (e.g. self-hosted CDNs). */
109
+ fontStylesheetDomains?: string[];
110
+
111
+ /**
112
+ * Skip style properties when snapshotting computed styles (e.g. `/^--/` to exclude
113
+ * CSS variables on pages with thousands of custom props).
114
+ */
115
+ excludeStyleProps?: RegExp | ((prop: string) => boolean);
116
+
117
+ /** Safari warmup iterations for WebKit #219770 (1..3). Default 3. */
118
+ safariWarmupAttempts?: number;
119
+
120
+ /** Verbose diagnostics via console.warn. Default false. */
121
+ debug?: boolean;
122
+
123
+ /** Default filename (without extension) for download(). Default "snapDOM". */
124
+ filename?: string;
106
125
 
107
126
  /**
108
127
  * Fallback image when <img> fails to load.
@@ -245,6 +264,12 @@ export interface CaptureResult {
245
264
  /** Canonical data URL of the SVG snapshot (when available). */
246
265
  url: string;
247
266
 
267
+ /** Returns the raw SVG data URL (same as `url`). */
268
+ toRaw(): string;
269
+
270
+ /** Run any registered export by name (core or plugin), e.g. `to("png")`. */
271
+ to(type: string, options?: any): Promise<any>;
272
+
248
273
  /**
249
274
  * @deprecated Use `toSvg()` for an <img> that renders the SVG snapshot.
250
275
  * Historical alias kept for compatibility.
@@ -301,6 +326,12 @@ export declare namespace snapdom {
301
326
 
302
327
  /** Shortcut helpers that run a one-off capture+export. */
303
328
 
329
+ /** Returns the raw SVG data URL of a one-off capture. */
330
+ function toRaw(
331
+ element: Element,
332
+ options?: SnapdomOptions
333
+ ): Promise<string>;
334
+
304
335
  /** @deprecated Returns an SVG <img>; prefer `toSvg`. */
305
336
  function toImg(
306
337
  element: Element,