@zumer/snapdom 2.23.2 → 2.24.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zumer/snapdom",
3
- "version": "2.23.2",
3
+ "version": "2.24.1",
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",
@@ -18,6 +18,46 @@ export type BlobType = "svg" | RasterMime;
18
18
  export type IconFontMatcher = string | RegExp;
19
19
  export type CachePolicy = "disabled" | "full" | "auto" | "soft";
20
20
 
21
+ /** Geometry of the serialized capture, expressed in SVG viewBox CSS pixels. */
22
+ export interface CaptureMeta {
23
+ /** Logical capture-box size (the clip-window size when clip is active). */
24
+ readonly w0: number;
25
+ readonly h0: number;
26
+ /** Serialized SVG viewBox size, including bleed/padding. */
27
+ readonly vbW: number;
28
+ readonly vbH: number;
29
+ /** Requested output basis before scale/dpr rasterization. */
30
+ readonly targetW: number;
31
+ readonly targetH: number;
32
+ /** Exact logical capture-box origin inside the viewBox. */
33
+ readonly contentX: number;
34
+ readonly contentY: number;
35
+ /** Resolved clip window, or null for a full-element capture. */
36
+ readonly clip: Readonly<{ x: number; y: number; width: number; height: number }> | null;
37
+ }
38
+
39
+ /** A window in serialized SVG viewBox coordinates. */
40
+ export interface CanvasCrop {
41
+ x: number;
42
+ y: number;
43
+ width: number;
44
+ height: number;
45
+ }
46
+
47
+ export type CanvasExportOptions = Partial<SnapdomOptions> & { crop?: CanvasCrop };
48
+
49
+ /** Silent core exporters exposed only while a plugin defines custom exports. */
50
+ export interface PluginExportFacade {
51
+ img(options?: Partial<SnapdomOptions>): Promise<HTMLImageElement>;
52
+ svg(options?: Partial<SnapdomOptions>): Promise<HTMLImageElement>;
53
+ canvas(options?: CanvasExportOptions): Promise<HTMLCanvasElement>;
54
+ blob(options?: BlobOptions & Partial<SnapdomOptions>): Promise<Blob>;
55
+ png(options?: Partial<SnapdomOptions>): Promise<HTMLImageElement>;
56
+ jpeg(options?: Partial<SnapdomOptions>): Promise<HTMLImageElement>;
57
+ jpg(options?: Partial<SnapdomOptions>): Promise<HTMLImageElement>;
58
+ webp(options?: Partial<SnapdomOptions>): Promise<HTMLImageElement>;
59
+ }
60
+
21
61
  /* =========================
22
62
  * Font & proxy declarations
23
63
  * ========================= */
@@ -204,12 +244,20 @@ export interface CaptureContext extends SnapdomOptions {
204
244
  svgString?: string;
205
245
  dataURL?: string;
206
246
 
247
+ /** Authoritative geometry produced by the render pass. */
248
+ readonly meta?: Readonly<CaptureMeta>;
249
+
250
+ /** Silent core-export facade, available to `defineExports` only. */
251
+ exports?: PluginExportFacade;
252
+
207
253
  /** Current export info during beforeExport/afterExport. */
208
254
  export?: {
209
255
  /** Export key (e.g., "png", "jpeg", "svg", or any custom key). */
210
- type: string;
211
- /** Options passed to the exporter. */
256
+ type?: string;
257
+ /** Capture defaults merged with the options passed to the exporter. */
212
258
  options?: any;
259
+ /** Exact own options supplied to this export call; omitted keys stay omitted. */
260
+ requestedOptions?: Readonly<Record<string, unknown>>;
213
261
  /** Canonical SVG data URL of this capture. */
214
262
  url: string;
215
263
  };
@@ -303,6 +351,9 @@ export interface CaptureResult {
303
351
  /** Canonical data URL of the SVG snapshot (when available). */
304
352
  url: string;
305
353
 
354
+ /** Authoritative serialized viewBox/content geometry. */
355
+ readonly meta: Readonly<CaptureMeta>;
356
+
306
357
  /** Returns the raw SVG data URL (same as `url`). */
307
358
  toRaw(): string;
308
359
 
@@ -319,7 +370,7 @@ export interface CaptureResult {
319
370
  toSvg(options?: Partial<SnapdomOptions>): Promise<HTMLImageElement>;
320
371
 
321
372
  /** Returns a Canvas with the rasterized snapshot. */
322
- toCanvas(options?: Partial<SnapdomOptions>): Promise<HTMLCanvasElement>;
373
+ toCanvas(options?: CanvasExportOptions): Promise<HTMLCanvasElement>;
323
374
 
324
375
  /** Returns a Blob of the chosen type (svg/png/jpeg/webp). */
325
376
  toBlob(options?: BlobOptions & Partial<SnapdomOptions>): Promise<Blob>;