@imggion/html2realpdf 0.1.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 +292 -0
- package/dist/LICENSE.md +465 -0
- package/dist/compat.d.ts +113 -0
- package/dist/compat.js +215 -0
- package/dist/compat.js.map +1 -0
- package/dist/errors.d.ts +55 -0
- package/dist/errors.js +73 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/libhtml2realpdf.wasm +0 -0
- package/dist/page.d.ts +23 -0
- package/dist/page.js +54 -0
- package/dist/page.js.map +1 -0
- package/dist/pdf-document.d.ts +51 -0
- package/dist/pdf-document.js +107 -0
- package/dist/pdf-document.js.map +1 -0
- package/dist/preview.d.ts +74 -0
- package/dist/preview.js +369 -0
- package/dist/preview.js.map +1 -0
- package/dist/renderer.d.ts +64 -0
- package/dist/renderer.js +276 -0
- package/dist/renderer.js.map +1 -0
- package/dist/snapshot.d.ts +79 -0
- package/dist/snapshot.js +2972 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/types.d.ts +273 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/vendor/pdf.min.mjs +28 -0
- package/dist/vendor/pdf.worker.min.mjs +28 -0
- package/dist/wasm.d.ts +39 -0
- package/dist/wasm.js +176 -0
- package/dist/wasm.js.map +1 -0
- package/dist/worker.d.ts +1 -0
- package/dist/worker.js +30 -0
- package/dist/worker.js.map +1 -0
- package/package.json +57 -0
- package/skills/html2realpdf/SKILL.md +260 -0
- package/skills/html2realpdf/agents/openai.yaml +4 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public configuration and callback contracts for the browser wrapper.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/** A structural ref accepted without making React a runtime dependency. */
|
|
7
|
+
export type RefLike<T> = {
|
|
8
|
+
readonly current: T | null;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Input accepted by the snapshot boundary.
|
|
12
|
+
*
|
|
13
|
+
* @remarks
|
|
14
|
+
* Mounted elements and refs preserve computed styles and live browser state;
|
|
15
|
+
* strings are evaluated in an inert document.
|
|
16
|
+
*/
|
|
17
|
+
export type HtmlSource = string | Element | RefLike<Element>;
|
|
18
|
+
/** Units used for custom page dimensions and margins. */
|
|
19
|
+
export type LengthUnit = "pt" | "px" | "mm" | "cm" | "in";
|
|
20
|
+
/** Named physical page sizes or a custom `[width, height]` in the selected unit. */
|
|
21
|
+
export type PageFormat = "a4" | "letter" | readonly [width: number, height: number];
|
|
22
|
+
/** Orientation applied after resolving the page format. */
|
|
23
|
+
export type PageOrientation = "portrait" | "landscape";
|
|
24
|
+
/**
|
|
25
|
+
* Layout and CSS support profile.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* `document` favors stable paged reports. `web` enables the broader browser
|
|
29
|
+
* layout profile. `strict` uses that broader profile and rejects unsupported
|
|
30
|
+
* CSS by default.
|
|
31
|
+
*/
|
|
32
|
+
export type CssProfile = "document" | "web" | "strict";
|
|
33
|
+
/** Media environment used while resolving styles and media queries. */
|
|
34
|
+
export type MediaType = "screen" | "print";
|
|
35
|
+
/** Containing block used for the snapshotted root element. */
|
|
36
|
+
export type LayoutContext = "source" | "page";
|
|
37
|
+
/** Action taken when an authored CSS property is outside the selected profile. */
|
|
38
|
+
export type UnsupportedCssPolicy = "warn" | "error" | "ignore";
|
|
39
|
+
/** Policy for SVG subtrees that cannot remain native PDF vectors. */
|
|
40
|
+
export type FallbackPolicy = "error" | "rasterize-subtree";
|
|
41
|
+
/** Policy used when a canvas-to-SVG adapter intentionally returns `null`. */
|
|
42
|
+
export type CanvasFallbackPolicy = "error" | "rasterize";
|
|
43
|
+
/** Complete SVG returned by a canvas adapter. */
|
|
44
|
+
export type CanvasSvgSource = string | Blob | SVGSVGElement;
|
|
45
|
+
/** Context passed to a canvas-to-SVG adapter. */
|
|
46
|
+
export interface CanvasToSvgRequest {
|
|
47
|
+
/** Original live canvas, suitable for chart-library export APIs. */
|
|
48
|
+
canvas: HTMLCanvasElement;
|
|
49
|
+
/** Stable snapshot path used to identify failures and fallbacks. */
|
|
50
|
+
nodePath: string;
|
|
51
|
+
/** Rendered canvas width in CSS pixels. */
|
|
52
|
+
cssWidth: number;
|
|
53
|
+
/** Rendered canvas height in CSS pixels. */
|
|
54
|
+
cssHeight: number;
|
|
55
|
+
/** Backing bitmap width. */
|
|
56
|
+
bitmapWidth: number;
|
|
57
|
+
/** Backing bitmap height. */
|
|
58
|
+
bitmapHeight: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Replaces a live canvas with vector SVG when the source library can export it.
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* Returning `null` delegates to `canvasFallback`. Throwing or returning
|
|
65
|
+
* malformed SVG produces `CanvasToSvgError`.
|
|
66
|
+
*/
|
|
67
|
+
export type CanvasToSvg = (request: CanvasToSvgRequest) => CanvasSvgSource | null | Promise<CanvasSvgSource | null>;
|
|
68
|
+
/** Deterministic viewport used for responsive layout and media queries. */
|
|
69
|
+
export interface ViewportOptions {
|
|
70
|
+
/** Viewport width in CSS pixels. Values below one are clamped. */
|
|
71
|
+
width: number;
|
|
72
|
+
/** Viewport height in CSS pixels. Values below one are clamped. */
|
|
73
|
+
height: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Page margins in the selected page unit.
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* Four values use html2pdf.js order `[top, left, bottom, right]`, not CSS
|
|
80
|
+
* shorthand order. Two values mean `[vertical, horizontal]`.
|
|
81
|
+
*/
|
|
82
|
+
export type Margin = number | readonly [vertical: number, horizontal: number] | readonly [top: number, left: number, bottom: number, right: number];
|
|
83
|
+
/** Explicit page geometry. Supplying this overrides captured `@page` geometry. */
|
|
84
|
+
export interface PageOptions {
|
|
85
|
+
/** Page size. Defaults to `a4`. */
|
|
86
|
+
format?: PageFormat;
|
|
87
|
+
/** Page orientation. Defaults to `portrait`. */
|
|
88
|
+
orientation?: PageOrientation;
|
|
89
|
+
/** Unit for custom dimensions and margins. Defaults to `pt`. */
|
|
90
|
+
unit?: LengthUnit;
|
|
91
|
+
/** Page margins. Defaults to zero on every edge. */
|
|
92
|
+
margin?: Margin;
|
|
93
|
+
}
|
|
94
|
+
/** Coarse rendering phases reported at stable cancellation boundaries. */
|
|
95
|
+
export type RenderPhase = "snapshot" | "wasm" | "complete";
|
|
96
|
+
/** Progress notification for a rendering phase. */
|
|
97
|
+
export interface RenderProgress {
|
|
98
|
+
/** Phase producing this notification. */
|
|
99
|
+
phase: RenderPhase;
|
|
100
|
+
/** Completed work units within the phase. */
|
|
101
|
+
completed: number;
|
|
102
|
+
/** Total work units within the phase. */
|
|
103
|
+
total: number;
|
|
104
|
+
}
|
|
105
|
+
/** Structured warning or error produced without losing successful PDF output. */
|
|
106
|
+
export interface Diagnostic {
|
|
107
|
+
/** Stable machine-readable identifier. */
|
|
108
|
+
code: string;
|
|
109
|
+
/** Diagnostic severity assigned by the snapshot or native renderer. */
|
|
110
|
+
severity: "warning" | "error";
|
|
111
|
+
/** Human-readable explanation. */
|
|
112
|
+
message: string;
|
|
113
|
+
/** CSS property associated with the diagnostic, when applicable. */
|
|
114
|
+
property?: string;
|
|
115
|
+
/** Stable snapshot path to the affected node, when available. */
|
|
116
|
+
nodePath?: string;
|
|
117
|
+
/** Pipeline phase that produced the diagnostic. */
|
|
118
|
+
phase?: "snapshot" | "parse" | "cascade" | "computed" | "layout" | "fragmentation" | "paint" | "pdf";
|
|
119
|
+
/** Fallback that preserved output despite the unsupported input. */
|
|
120
|
+
fallback?: string;
|
|
121
|
+
}
|
|
122
|
+
/** Resource requested while materializing a self-contained snapshot. */
|
|
123
|
+
export interface ResourceRequest {
|
|
124
|
+
/** Resource class. Fonts are registered on `createRenderer` instead. */
|
|
125
|
+
kind: "image" | "stylesheet";
|
|
126
|
+
/** Absolute URL resolved against `baseUrl` or the source document. */
|
|
127
|
+
url: URL;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Resolves resources that cannot be fetched directly by the browser snapshot.
|
|
131
|
+
*
|
|
132
|
+
* @remarks
|
|
133
|
+
* For stylesheets, a string is CSS source. For images, a string is a data URL
|
|
134
|
+
* or replacement URL. `null` leaves the request unresolved and applies
|
|
135
|
+
* `resourcePolicy`.
|
|
136
|
+
*/
|
|
137
|
+
export type ResourceResolver = (request: ResourceRequest) => Blob | string | null | Promise<Blob | string | null>;
|
|
138
|
+
/** Selector-driven pagination overrides compatible with html2pdf.js workflows. */
|
|
139
|
+
export interface PageBreakRules {
|
|
140
|
+
/** Selectors forced to begin on a new page. */
|
|
141
|
+
before?: string | readonly string[];
|
|
142
|
+
/** Selectors forced to end the current page. */
|
|
143
|
+
after?: string | readonly string[];
|
|
144
|
+
/** Selectors whose contents should avoid internal fragmentation. */
|
|
145
|
+
avoid?: string | readonly string[];
|
|
146
|
+
/** Applies `break-inside: avoid` to every element. */
|
|
147
|
+
avoidAll?: boolean;
|
|
148
|
+
/** Honors the legacy `.html2pdf__page-break` marker. */
|
|
149
|
+
legacy?: boolean;
|
|
150
|
+
}
|
|
151
|
+
/** PDF information dictionary fields written by the native renderer. */
|
|
152
|
+
export interface PdfMetadata {
|
|
153
|
+
/** Document title. */
|
|
154
|
+
title?: string;
|
|
155
|
+
/** Document author. */
|
|
156
|
+
author?: string;
|
|
157
|
+
/** Document subject. */
|
|
158
|
+
subject?: string;
|
|
159
|
+
/** Search keywords, joined when supplied as an array. */
|
|
160
|
+
keywords?: string | readonly string[];
|
|
161
|
+
/** Application or service that created the document. */
|
|
162
|
+
creator?: string;
|
|
163
|
+
}
|
|
164
|
+
/** Options applied to one HTML snapshot and PDF render. */
|
|
165
|
+
export interface RenderOptions {
|
|
166
|
+
/** Explicit page geometry; captured `@page` rules are used when omitted. */
|
|
167
|
+
page?: PageOptions;
|
|
168
|
+
/**
|
|
169
|
+
* Promotes unsupported snapshot CSS to errors without selecting the `web`
|
|
170
|
+
* layout profile. An explicit `unsupportedCss` policy takes precedence.
|
|
171
|
+
*/
|
|
172
|
+
strict?: boolean;
|
|
173
|
+
/** Layout profile. Defaults to `document`. */
|
|
174
|
+
cssProfile?: CssProfile;
|
|
175
|
+
/** Media environment used for style resolution. Defaults to `screen`. */
|
|
176
|
+
mediaType?: MediaType;
|
|
177
|
+
/**
|
|
178
|
+
* Root layout context. `source` preserves the mounted browser width;
|
|
179
|
+
* `page` resolves an implicit root width and auto inline margins against the
|
|
180
|
+
* PDF content box. Defaults to `source`.
|
|
181
|
+
*/
|
|
182
|
+
layoutContext?: LayoutContext;
|
|
183
|
+
/** Isolated viewport used for media queries and responsive layout. */
|
|
184
|
+
viewport?: ViewportOptions;
|
|
185
|
+
/** Unsupported-CSS policy; defaults to `error` for strict mode and `warn` otherwise. */
|
|
186
|
+
unsupportedCss?: UnsupportedCssPolicy;
|
|
187
|
+
/** Unsupported SVG policy. Defaults to `error`. */
|
|
188
|
+
fallback?: FallbackPolicy;
|
|
189
|
+
/** Optional bridge from live canvas content to validated SVG. */
|
|
190
|
+
canvasToSvg?: CanvasToSvg;
|
|
191
|
+
/** Fallback when `canvasToSvg` returns `null`. Defaults to `error`. */
|
|
192
|
+
canvasFallback?: CanvasFallbackPolicy;
|
|
193
|
+
/** Flattens open Shadow DOM into the snapshot. Defaults to `false`. */
|
|
194
|
+
includeShadowDom?: boolean;
|
|
195
|
+
/** Base URL for relative resources. Defaults to the source document URL. */
|
|
196
|
+
baseUrl?: string | URL;
|
|
197
|
+
/** Failed-resource policy. Defaults to `error`. */
|
|
198
|
+
resourcePolicy?: "error" | "omit";
|
|
199
|
+
/** Resolver for protected, virtual, or otherwise unavailable resources. */
|
|
200
|
+
resourceResolver?: ResourceResolver;
|
|
201
|
+
/** Selector-driven page-break overrides. */
|
|
202
|
+
pageBreak?: PageBreakRules;
|
|
203
|
+
/** PDF information dictionary fields. */
|
|
204
|
+
metadata?: PdfMetadata;
|
|
205
|
+
/** Preserves PDF link annotations unless explicitly set to `false`. */
|
|
206
|
+
enableLinks?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Rejects the caller at snapshot and render boundaries when aborted.
|
|
209
|
+
* An already-running synchronous WASM render cannot be preempted.
|
|
210
|
+
*/
|
|
211
|
+
signal?: AbortSignal;
|
|
212
|
+
/** Receives coarse phase-boundary progress, not per-page render progress. */
|
|
213
|
+
onProgress?: (progress: RenderProgress) => void;
|
|
214
|
+
}
|
|
215
|
+
/** Configuration whose lifetime matches an explicit renderer instance. */
|
|
216
|
+
export interface RendererInit {
|
|
217
|
+
/** Execution backend. Defaults to `worker`. */
|
|
218
|
+
execution?: "worker" | "main";
|
|
219
|
+
/** WASM asset override for deployments that cannot serve package-relative assets. */
|
|
220
|
+
wasmUrl?: string | URL;
|
|
221
|
+
/** Embeddable TrueType fonts registered once for every render. */
|
|
222
|
+
fonts?: readonly FontRegistration[];
|
|
223
|
+
}
|
|
224
|
+
/** Embeddable TrueType font registered in a renderer-owned WASM context. */
|
|
225
|
+
export interface FontRegistration {
|
|
226
|
+
/** CSS family name used during font resolution. */
|
|
227
|
+
family: string;
|
|
228
|
+
/** Complete TrueType font bytes, copied into the native context. */
|
|
229
|
+
data: ArrayBuffer | Uint8Array;
|
|
230
|
+
/** CSS font weight. Defaults to `400`. */
|
|
231
|
+
weight?: number | "normal" | "bold";
|
|
232
|
+
/** CSS font style. Defaults to `normal`. */
|
|
233
|
+
style?: "normal" | "italic";
|
|
234
|
+
}
|
|
235
|
+
/** Page settings accepted through the html2pdf.js-compatible `jsPDF` option. */
|
|
236
|
+
export interface CompatJsPdfOptions {
|
|
237
|
+
/** Unit shared by custom page geometry and margins. */
|
|
238
|
+
unit?: LengthUnit;
|
|
239
|
+
/** Named or custom page format forwarded to the modern page contract. */
|
|
240
|
+
format?: PageFormat;
|
|
241
|
+
/** Page orientation forwarded to the modern page contract. */
|
|
242
|
+
orientation?: PageOrientation;
|
|
243
|
+
}
|
|
244
|
+
/** Page-break settings accepted by the html2pdf.js compatibility layer. */
|
|
245
|
+
export interface CompatPageBreakOptions {
|
|
246
|
+
/** Compatibility modes. Defaults to `css` and `legacy`. */
|
|
247
|
+
mode?: "css" | "legacy" | "avoid-all" | readonly ("css" | "legacy" | "avoid-all")[];
|
|
248
|
+
/** Selectors forced to begin on a new page. */
|
|
249
|
+
before?: string | readonly string[];
|
|
250
|
+
/** Selectors forced to end the current page. */
|
|
251
|
+
after?: string | readonly string[];
|
|
252
|
+
/** Selectors whose contents should avoid internal fragmentation. */
|
|
253
|
+
avoid?: string | readonly string[];
|
|
254
|
+
}
|
|
255
|
+
/** Options supported by the PDF-oriented html2pdf.js compatibility layer. */
|
|
256
|
+
export interface Html2PdfOptions {
|
|
257
|
+
/** Page margins in html2pdf.js order. */
|
|
258
|
+
margin?: Margin;
|
|
259
|
+
/** Filename used by `save` when no method argument is supplied. */
|
|
260
|
+
filename?: string;
|
|
261
|
+
/** Preserves links unless explicitly disabled. */
|
|
262
|
+
enableLinks?: boolean;
|
|
263
|
+
/** Compatibility pagination rules. */
|
|
264
|
+
pagebreak?: CompatPageBreakOptions;
|
|
265
|
+
/** Compatibility page geometry. */
|
|
266
|
+
jsPDF?: CompatJsPdfOptions;
|
|
267
|
+
/** Unsupported because this renderer does not use an html2canvas pipeline. */
|
|
268
|
+
html2canvas?: never;
|
|
269
|
+
/** Unsupported because PDF pages are not encoded as raster images. */
|
|
270
|
+
image?: never;
|
|
271
|
+
}
|
|
272
|
+
/** Output encodings supported by compatibility `output` methods. */
|
|
273
|
+
export type PdfOutputType = "arraybuffer" | "blob" | "bloburl" | "bloburi" | "datauristring" | "dataurlstring";
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/**\n * Public configuration and callback contracts for the browser wrapper.\n *\n * @packageDocumentation\n */\n\n/** A structural ref accepted without making React a runtime dependency. */\nexport type RefLike<T> = { readonly current: T | null };\n\n/**\n * Input accepted by the snapshot boundary.\n *\n * @remarks\n * Mounted elements and refs preserve computed styles and live browser state;\n * strings are evaluated in an inert document.\n */\nexport type HtmlSource = string | Element | RefLike<Element>;\n\n/** Units used for custom page dimensions and margins. */\nexport type LengthUnit = \"pt\" | \"px\" | \"mm\" | \"cm\" | \"in\";\n\n/** Named physical page sizes or a custom `[width, height]` in the selected unit. */\nexport type PageFormat = \"a4\" | \"letter\" | readonly [width: number, height: number];\n\n/** Orientation applied after resolving the page format. */\nexport type PageOrientation = \"portrait\" | \"landscape\";\n\n/**\n * Layout and CSS support profile.\n *\n * @remarks\n * `document` favors stable paged reports. `web` enables the broader browser\n * layout profile. `strict` uses that broader profile and rejects unsupported\n * CSS by default.\n */\nexport type CssProfile = \"document\" | \"web\" | \"strict\";\n\n/** Media environment used while resolving styles and media queries. */\nexport type MediaType = \"screen\" | \"print\";\n\n/** Containing block used for the snapshotted root element. */\nexport type LayoutContext = \"source\" | \"page\";\n\n/** Action taken when an authored CSS property is outside the selected profile. */\nexport type UnsupportedCssPolicy = \"warn\" | \"error\" | \"ignore\";\n\n/** Policy for SVG subtrees that cannot remain native PDF vectors. */\nexport type FallbackPolicy = \"error\" | \"rasterize-subtree\";\n\n/** Policy used when a canvas-to-SVG adapter intentionally returns `null`. */\nexport type CanvasFallbackPolicy = \"error\" | \"rasterize\";\n\n/** Complete SVG returned by a canvas adapter. */\nexport type CanvasSvgSource = string | Blob | SVGSVGElement;\n\n/** Context passed to a canvas-to-SVG adapter. */\nexport interface CanvasToSvgRequest {\n /** Original live canvas, suitable for chart-library export APIs. */\n canvas: HTMLCanvasElement;\n /** Stable snapshot path used to identify failures and fallbacks. */\n nodePath: string;\n /** Rendered canvas width in CSS pixels. */\n cssWidth: number;\n /** Rendered canvas height in CSS pixels. */\n cssHeight: number;\n /** Backing bitmap width. */\n bitmapWidth: number;\n /** Backing bitmap height. */\n bitmapHeight: number;\n}\n\n/**\n * Replaces a live canvas with vector SVG when the source library can export it.\n *\n * @remarks\n * Returning `null` delegates to `canvasFallback`. Throwing or returning\n * malformed SVG produces `CanvasToSvgError`.\n */\nexport type CanvasToSvg = (\n request: CanvasToSvgRequest,\n) => CanvasSvgSource | null | Promise<CanvasSvgSource | null>;\n\n/** Deterministic viewport used for responsive layout and media queries. */\nexport interface ViewportOptions {\n /** Viewport width in CSS pixels. Values below one are clamped. */\n width: number;\n /** Viewport height in CSS pixels. Values below one are clamped. */\n height: number;\n}\n\n/**\n * Page margins in the selected page unit.\n *\n * @remarks\n * Four values use html2pdf.js order `[top, left, bottom, right]`, not CSS\n * shorthand order. Two values mean `[vertical, horizontal]`.\n */\nexport type Margin =\n | number\n | readonly [vertical: number, horizontal: number]\n | readonly [top: number, left: number, bottom: number, right: number];\n\n/** Explicit page geometry. Supplying this overrides captured `@page` geometry. */\nexport interface PageOptions {\n /** Page size. Defaults to `a4`. */\n format?: PageFormat;\n /** Page orientation. Defaults to `portrait`. */\n orientation?: PageOrientation;\n /** Unit for custom dimensions and margins. Defaults to `pt`. */\n unit?: LengthUnit;\n /** Page margins. Defaults to zero on every edge. */\n margin?: Margin;\n}\n\n/** Coarse rendering phases reported at stable cancellation boundaries. */\nexport type RenderPhase = \"snapshot\" | \"wasm\" | \"complete\";\n\n/** Progress notification for a rendering phase. */\nexport interface RenderProgress {\n /** Phase producing this notification. */\n phase: RenderPhase;\n /** Completed work units within the phase. */\n completed: number;\n /** Total work units within the phase. */\n total: number;\n}\n\n/** Structured warning or error produced without losing successful PDF output. */\nexport interface Diagnostic {\n /** Stable machine-readable identifier. */\n code: string;\n /** Diagnostic severity assigned by the snapshot or native renderer. */\n severity: \"warning\" | \"error\";\n /** Human-readable explanation. */\n message: string;\n /** CSS property associated with the diagnostic, when applicable. */\n property?: string;\n /** Stable snapshot path to the affected node, when available. */\n nodePath?: string;\n /** Pipeline phase that produced the diagnostic. */\n phase?: \"snapshot\" | \"parse\" | \"cascade\" | \"computed\" | \"layout\" | \"fragmentation\" | \"paint\" | \"pdf\";\n /** Fallback that preserved output despite the unsupported input. */\n fallback?: string;\n}\n\n/** Resource requested while materializing a self-contained snapshot. */\nexport interface ResourceRequest {\n /** Resource class. Fonts are registered on `createRenderer` instead. */\n kind: \"image\" | \"stylesheet\";\n /** Absolute URL resolved against `baseUrl` or the source document. */\n url: URL;\n}\n\n/**\n * Resolves resources that cannot be fetched directly by the browser snapshot.\n *\n * @remarks\n * For stylesheets, a string is CSS source. For images, a string is a data URL\n * or replacement URL. `null` leaves the request unresolved and applies\n * `resourcePolicy`.\n */\nexport type ResourceResolver = (request: ResourceRequest) => Blob | string | null | Promise<Blob | string | null>;\n\n/** Selector-driven pagination overrides compatible with html2pdf.js workflows. */\nexport interface PageBreakRules {\n /** Selectors forced to begin on a new page. */\n before?: string | readonly string[];\n /** Selectors forced to end the current page. */\n after?: string | readonly string[];\n /** Selectors whose contents should avoid internal fragmentation. */\n avoid?: string | readonly string[];\n /** Applies `break-inside: avoid` to every element. */\n avoidAll?: boolean;\n /** Honors the legacy `.html2pdf__page-break` marker. */\n legacy?: boolean;\n}\n\n/** PDF information dictionary fields written by the native renderer. */\nexport interface PdfMetadata {\n /** Document title. */\n title?: string;\n /** Document author. */\n author?: string;\n /** Document subject. */\n subject?: string;\n /** Search keywords, joined when supplied as an array. */\n keywords?: string | readonly string[];\n /** Application or service that created the document. */\n creator?: string;\n}\n\n/** Options applied to one HTML snapshot and PDF render. */\nexport interface RenderOptions {\n /** Explicit page geometry; captured `@page` rules are used when omitted. */\n page?: PageOptions;\n /**\n * Promotes unsupported snapshot CSS to errors without selecting the `web`\n * layout profile. An explicit `unsupportedCss` policy takes precedence.\n */\n strict?: boolean;\n /** Layout profile. Defaults to `document`. */\n cssProfile?: CssProfile;\n /** Media environment used for style resolution. Defaults to `screen`. */\n mediaType?: MediaType;\n /**\n * Root layout context. `source` preserves the mounted browser width;\n * `page` resolves an implicit root width and auto inline margins against the\n * PDF content box. Defaults to `source`.\n */\n layoutContext?: LayoutContext;\n /** Isolated viewport used for media queries and responsive layout. */\n viewport?: ViewportOptions;\n /** Unsupported-CSS policy; defaults to `error` for strict mode and `warn` otherwise. */\n unsupportedCss?: UnsupportedCssPolicy;\n /** Unsupported SVG policy. Defaults to `error`. */\n fallback?: FallbackPolicy;\n /** Optional bridge from live canvas content to validated SVG. */\n canvasToSvg?: CanvasToSvg;\n /** Fallback when `canvasToSvg` returns `null`. Defaults to `error`. */\n canvasFallback?: CanvasFallbackPolicy;\n /** Flattens open Shadow DOM into the snapshot. Defaults to `false`. */\n includeShadowDom?: boolean;\n /** Base URL for relative resources. Defaults to the source document URL. */\n baseUrl?: string | URL;\n /** Failed-resource policy. Defaults to `error`. */\n resourcePolicy?: \"error\" | \"omit\";\n /** Resolver for protected, virtual, or otherwise unavailable resources. */\n resourceResolver?: ResourceResolver;\n /** Selector-driven page-break overrides. */\n pageBreak?: PageBreakRules;\n /** PDF information dictionary fields. */\n metadata?: PdfMetadata;\n /** Preserves PDF link annotations unless explicitly set to `false`. */\n enableLinks?: boolean;\n /**\n * Rejects the caller at snapshot and render boundaries when aborted.\n * An already-running synchronous WASM render cannot be preempted.\n */\n signal?: AbortSignal;\n /** Receives coarse phase-boundary progress, not per-page render progress. */\n onProgress?: (progress: RenderProgress) => void;\n}\n\n/** Configuration whose lifetime matches an explicit renderer instance. */\nexport interface RendererInit {\n /** Execution backend. Defaults to `worker`. */\n execution?: \"worker\" | \"main\";\n /** WASM asset override for deployments that cannot serve package-relative assets. */\n wasmUrl?: string | URL;\n /** Embeddable TrueType fonts registered once for every render. */\n fonts?: readonly FontRegistration[];\n}\n\n/** Embeddable TrueType font registered in a renderer-owned WASM context. */\nexport interface FontRegistration {\n /** CSS family name used during font resolution. */\n family: string;\n /** Complete TrueType font bytes, copied into the native context. */\n data: ArrayBuffer | Uint8Array;\n /** CSS font weight. Defaults to `400`. */\n weight?: number | \"normal\" | \"bold\";\n /** CSS font style. Defaults to `normal`. */\n style?: \"normal\" | \"italic\";\n}\n\n/** Page settings accepted through the html2pdf.js-compatible `jsPDF` option. */\nexport interface CompatJsPdfOptions {\n /** Unit shared by custom page geometry and margins. */\n unit?: LengthUnit;\n /** Named or custom page format forwarded to the modern page contract. */\n format?: PageFormat;\n /** Page orientation forwarded to the modern page contract. */\n orientation?: PageOrientation;\n}\n\n/** Page-break settings accepted by the html2pdf.js compatibility layer. */\nexport interface CompatPageBreakOptions {\n /** Compatibility modes. Defaults to `css` and `legacy`. */\n mode?: \"css\" | \"legacy\" | \"avoid-all\" | readonly (\"css\" | \"legacy\" | \"avoid-all\")[];\n /** Selectors forced to begin on a new page. */\n before?: string | readonly string[];\n /** Selectors forced to end the current page. */\n after?: string | readonly string[];\n /** Selectors whose contents should avoid internal fragmentation. */\n avoid?: string | readonly string[];\n}\n\n/** Options supported by the PDF-oriented html2pdf.js compatibility layer. */\nexport interface Html2PdfOptions {\n /** Page margins in html2pdf.js order. */\n margin?: Margin;\n /** Filename used by `save` when no method argument is supplied. */\n filename?: string;\n /** Preserves links unless explicitly disabled. */\n enableLinks?: boolean;\n /** Compatibility pagination rules. */\n pagebreak?: CompatPageBreakOptions;\n /** Compatibility page geometry. */\n jsPDF?: CompatJsPdfOptions;\n /** Unsupported because this renderer does not use an html2canvas pipeline. */\n html2canvas?: never;\n /** Unsupported because PDF pages are not encoded as raster images. */\n image?: never;\n}\n\n/** Output encodings supported by compatibility `output` methods. */\nexport type PdfOutputType =\n | \"arraybuffer\"\n | \"blob\"\n | \"bloburl\"\n | \"bloburi\"\n | \"datauristring\"\n | \"dataurlstring\";\n"]}
|