html2canvas-pro 2.5.1 → 2.5.2

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.
Files changed (51) hide show
  1. package/README.md +11 -1
  2. package/dist/html2canvas-pro.cjs +1835 -1470
  3. package/dist/html2canvas-pro.cjs.map +1 -1
  4. package/dist/html2canvas-pro.esm.js +1835 -1470
  5. package/dist/html2canvas-pro.esm.js.map +1 -1
  6. package/dist/html2canvas-pro.js +1839 -1471
  7. package/dist/html2canvas-pro.js.map +1 -1
  8. package/dist/html2canvas-pro.min.js +6 -5
  9. package/dist/types/core/cache-storage.d.ts +6 -2
  10. package/dist/types/core/constants.d.ts +11 -0
  11. package/dist/types/core/context.d.ts +9 -1
  12. package/dist/types/core/features.d.ts +9 -5
  13. package/dist/types/core/origin-checker.d.ts +7 -4
  14. package/dist/types/core/validator.d.ts +0 -2
  15. package/dist/types/css/grouped/background-styles.d.ts +4 -0
  16. package/dist/types/css/grouped/border-styles.d.ts +4 -0
  17. package/dist/types/css/grouped/font-styles.d.ts +4 -0
  18. package/dist/types/css/grouped/layout-styles.d.ts +4 -0
  19. package/dist/types/css/index.d.ts +4 -0
  20. package/dist/types/css/property-descriptor.d.ts +11 -3
  21. package/dist/types/css/property-descriptors/scale.d.ts +9 -0
  22. package/dist/types/css/property-descriptors/translate.d.ts +10 -0
  23. package/dist/types/css/syntax/tokenizer.d.ts +8 -0
  24. package/dist/types/css/types/color-utilities.d.ts +21 -0
  25. package/dist/types/css/types/functions/color-mix.d.ts +17 -0
  26. package/dist/types/dom/adopted-styles.d.ts +23 -0
  27. package/dist/types/dom/document-cloner.d.ts +12 -0
  28. package/dist/types/dom/dom-normalizer.d.ts +2 -0
  29. package/dist/types/dom/elements/li-element-container.d.ts +2 -2
  30. package/dist/types/dom/elements/ol-element-container.d.ts +2 -2
  31. package/dist/types/dom/elements/select-element-container.d.ts +2 -2
  32. package/dist/types/dom/elements/textarea-element-container.d.ts +2 -2
  33. package/dist/types/dom/iframe-mount.d.ts +17 -0
  34. package/dist/types/dom/node-parser.d.ts +2 -2
  35. package/dist/types/dom/replaced-elements/canvas-element-container.d.ts +2 -2
  36. package/dist/types/dom/replaced-elements/iframe-element-container.d.ts +2 -2
  37. package/dist/types/dom/replaced-elements/image-element-container.d.ts +2 -2
  38. package/dist/types/dom/replaced-elements/input-element-container.d.ts +2 -2
  39. package/dist/types/dom/replaced-elements/svg-element-container.d.ts +2 -2
  40. package/dist/types/dom/slot-cloner.d.ts +10 -0
  41. package/dist/types/options.d.ts +24 -0
  42. package/dist/types/render/canvas/border-image-renderer.d.ts +7 -0
  43. package/dist/types/render/canvas/canvas-renderer.d.ts +2 -3
  44. package/dist/types/render/canvas/filter-surface.d.ts +37 -11
  45. package/dist/types/render/canvas/gradient-rasterizer.d.ts +53 -0
  46. package/dist/types/render/canvas/mask-renderer.d.ts +5 -2
  47. package/dist/types/render/canvas/text-clip-renderer.d.ts +0 -1
  48. package/dist/types/render/canvas/text-renderer.d.ts +1 -0
  49. package/package.json +9 -31
  50. package/dist/types/render/font-metrics.d.ts +0 -11
  51. package/dist/types/render/renderer-interface.d.ts +0 -28
@@ -46,14 +46,18 @@ export declare class Cache {
46
46
  * an optional concurrency cap to avoid overwhelming the browser's network
47
47
  * stack (default: 10 concurrent loads).
48
48
  * After this call returns, all images are either loaded (cache hit) or
49
- * failed (logged). Subsequent cache.match() calls return immediately.
49
+ * failed (logged and reported via onError). Subsequent cache.match()
50
+ * calls return immediately.
50
51
  *
51
52
  * @param concurrency - Max concurrent image loads (1–100, default 10).
52
53
  * @param onProgress - Invoked once before loading and after each settled
53
54
  * batch with (settledCount, totalCount), enabling coarse progress UI.
54
55
  * Not invoked when there is nothing to load.
56
+ * @param signal - Checked before each batch; aborting rejects the whole
57
+ * preload with an AbortError instead of waiting for the remaining
58
+ * batches to finish.
55
59
  */
56
- preloadAll(concurrency?: number, onProgress?: (loaded: number, total: number) => void): Promise<void>;
60
+ preloadAll(concurrency?: number, onProgress?: (loaded: number, total: number) => void, signal?: AbortSignal): Promise<void>;
57
61
  addImage(src: string): Promise<void>;
58
62
  /**
59
63
  * Shared helper: enqueues loading for a single URL with pending-operation
@@ -16,6 +16,17 @@ export declare const DEFAULT_IMAGE_TIMEOUT_MS = 15000;
16
16
  export declare const SHADOW_MASK_OFFSET = 10000;
17
17
  /** Polling interval (ms) when waiting for the cloned iframe to become ready. */
18
18
  export declare const IFRAME_READY_POLL_MS = 50;
19
+ /**
20
+ * Total time (ms) to wait for the cloned iframe document to become ready
21
+ * after its load event. A missed deadline resolves with a warning (the
22
+ * capture continues with a possibly incomplete document).
23
+ */
24
+ export declare const CLONE_READY_TIMEOUT_MS = 30000;
25
+ /**
26
+ * Hard ceiling (ms) for the cloned iframe's load event itself. If the event
27
+ * never fires, the mount is rejected instead of hanging forever.
28
+ */
29
+ export declare const IFRAME_LOAD_WATCHDOG_MS = 60000;
19
30
  /** Deferred resolution delay (ms) for inline XML images that may fail to parse. */
20
31
  export declare const INLINE_IMAGE_RESOLVE_DELAY_MS = 500;
21
32
  /** Maximum characters logged for image/resource keys. */
@@ -10,17 +10,25 @@ export type ContextOptions = {
10
10
  onError?: (error: Error) => void;
11
11
  } & ResourceOptions;
12
12
  export declare class Context {
13
+ private static instanceCount;
13
14
  private readonly instanceName;
14
15
  readonly logger: Logger;
15
16
  readonly cache: Cache;
16
17
  readonly originChecker: OriginChecker;
17
18
  readonly config: Html2CanvasConfig;
18
19
  readonly onError?: (error: Error) => void;
19
- private static instanceCount;
20
20
  private _windowBounds;
21
21
  constructor(options: ContextOptions, windowBounds: Bounds, config: Html2CanvasConfig);
22
22
  /** Viewport bounds in page coordinates; added to client rects during bounds parsing. */
23
23
  get windowBounds(): Bounds;
24
+ /**
25
+ * Document used to allocate offscreen resources (offscreen canvases,
26
+ * images, measurement elements). Prefers the configured window's document
27
+ * so resources live in the captured realm; falls back to the global
28
+ * document, which keeps mock environments without a window document
29
+ * working.
30
+ */
31
+ get resourceDocument(): Document;
24
32
  /**
25
33
  * Compensate window bounds for a page scroll that the browser performed
26
34
  * underneath us. Used by the document cloner: WebKit's scroll anchoring can
@@ -1,12 +1,16 @@
1
+ /**
2
+ * Runtime feature detection.
3
+ *
4
+ * Only checks that still gate real behaviour are kept: range-bounds
5
+ * measurement (iOS 13 quirk), SVG drawing and CORS image support.
6
+ * Dead probes (IE-era CORS XHR / XHR response-type checks) were removed —
7
+ * every supported browser exposes `crossOrigin`, `responseType` and
8
+ * `withCredentials`; Intl.Segmenter is used unconditionally.
9
+ */
1
10
  export declare const createForeignObjectSVG: (width: number, height: number, x: number, y: number, node: Node) => SVGForeignObjectElement;
2
11
  export declare const loadSerializedSVG: (svg: Node) => Promise<HTMLImageElement>;
3
12
  export declare const FEATURES: {
4
13
  readonly SUPPORT_RANGE_BOUNDS: boolean;
5
- readonly SUPPORT_WORD_BREAKING: boolean;
6
14
  readonly SUPPORT_SVG_DRAWING: boolean;
7
- readonly SUPPORT_FOREIGNOBJECT_DRAWING: Promise<boolean>;
8
15
  readonly SUPPORT_CORS_IMAGES: boolean;
9
- readonly SUPPORT_RESPONSE_TYPE: boolean;
10
- readonly SUPPORT_CORS_XHR: boolean;
11
- readonly SUPPORT_NATIVE_TEXT_SEGMENTATION: boolean;
12
16
  };
@@ -2,19 +2,22 @@
2
2
  * Origin Checker
3
3
  *
4
4
  * Provides origin checking functionality without global static state.
5
- * Each instance maintains its own anchor element and origin reference.
5
+ * Each instance maintains its own base URI and origin reference.
6
6
  *
7
7
  * Replaces the static methods in CacheStorage with instance-based approach.
8
8
  */
9
9
  export declare class OriginChecker {
10
- private readonly link;
10
+ private readonly baseUri;
11
11
  private readonly origin;
12
12
  constructor(window: Window);
13
13
  /**
14
14
  * Get the origin (protocol + hostname + port) of a URL
15
15
  *
16
- * @param url - URL to parse
17
- * @returns Origin string (e.g., "https://example.com:8080")
16
+ * @param url - URL to parse; relative URLs resolve against the context
17
+ * window's location, as the anchor element used to
18
+ * @returns Origin string (e.g. "https://example.com:8080"), or an empty
19
+ * string for unparseable URLs — which never matches and is
20
+ * therefore treated as cross-origin
18
21
  */
19
22
  getOrigin(url: string): string;
20
23
  /**
@@ -11,8 +11,6 @@ export interface ValidationResult {
11
11
  valid: boolean;
12
12
  error?: string;
13
13
  sanitized?: unknown;
14
- /** Indicates if runtime validation is recommended (e.g. for proxy URLs against DNS rebinding) */
15
- requiresRuntimeCheck?: boolean;
16
14
  }
17
15
  /**
18
16
  * Validator configuration
@@ -1,6 +1,10 @@
1
1
  import type { CSSParsedDeclaration } from '../index';
2
2
  /**
3
3
  * Read-only grouped accessor for background-related CSS properties.
4
+ *
5
+ * Convenience accessors only — the render pipeline reads the top-level
6
+ * parsed fields directly. Some underlying properties are parsed but not
7
+ * rendered; see docs/features.md "Known unsupported CSS features".
4
8
  */
5
9
  export declare class BackgroundStyles {
6
10
  private readonly styles;
@@ -2,6 +2,10 @@ import type { CSSParsedDeclaration } from '../index';
2
2
  /**
3
3
  * Read-only grouped accessor for border-related CSS properties.
4
4
  *
5
+ * Convenience accessors only — the render pipeline reads the top-level
6
+ * parsed fields directly. Some underlying properties are parsed but not
7
+ * rendered; see docs/features.md "Known unsupported CSS features".
8
+ *
5
9
  * Provides structured access: `styles.border.topColor` as an alternative
6
10
  * to the flat `styles.borderTopColor`. Both forms remain valid.
7
11
  */
@@ -1,6 +1,10 @@
1
1
  import type { CSSParsedDeclaration } from '../index';
2
2
  /**
3
3
  * Read-only grouped accessor for font/text-related CSS properties.
4
+ *
5
+ * Convenience accessors only — the render pipeline reads the top-level
6
+ * parsed fields directly. Some underlying properties are parsed but not
7
+ * rendered; see docs/features.md "Known unsupported CSS features".
4
8
  */
5
9
  export declare class FontStyles {
6
10
  private readonly styles;
@@ -1,6 +1,10 @@
1
1
  import type { CSSParsedDeclaration } from '../index';
2
2
  /**
3
3
  * Read-only grouped accessor for layout/display/positioning CSS properties.
4
+ *
5
+ * Convenience accessors only — the render pipeline reads the top-level
6
+ * parsed fields directly. Some underlying properties are parsed but not
7
+ * rendered; see docs/features.md "Known unsupported CSS features".
4
8
  */
5
9
  export declare class LayoutStyles {
6
10
  private readonly styles;
@@ -57,6 +57,8 @@ import { textAlign } from './property-descriptors/text-align';
57
57
  import { transform } from './property-descriptors/transform';
58
58
  import { transformOrigin } from './property-descriptors/transform-origin';
59
59
  import { rotate } from './property-descriptors/rotate';
60
+ import { translate } from './property-descriptors/translate';
61
+ import { scale } from './property-descriptors/scale';
60
62
  import { LengthPercentage } from './types/length-percentage';
61
63
  import { webkitTextStrokeWidth } from './property-descriptors/webkit-text-stroke-width';
62
64
  import { objectFit } from './property-descriptors/object-fit';
@@ -146,6 +148,8 @@ export declare class CSSParsedDeclaration {
146
148
  transform: ReturnType<typeof transform.parse>;
147
149
  transformOrigin: ReturnType<typeof transformOrigin.parse>;
148
150
  rotate: ReturnType<typeof rotate.parse>;
151
+ translate: ReturnType<typeof translate.parse>;
152
+ scale: ReturnType<typeof scale.parse>;
149
153
  visibility: ReturnType<typeof visibility.parse>;
150
154
  webkitTextStrokeColor: Color;
151
155
  webkitTextStrokeWidth: ReturnType<typeof webkitTextStrokeWidth.parse>;
@@ -13,9 +13,17 @@ export interface IPropertyDescriptor {
13
13
  type: PropertyDescriptorParsingType;
14
14
  initialValue: string;
15
15
  prefix: boolean;
16
- /** When true, the parse result is never stored in parseCache.
17
- * Set this for descriptors whose parse() has side effects (e.g.,
18
- * calling context.cache.addImage) that must run on every render pass. */
16
+ /**
17
+ * When true, the parse result is never stored in parseCache.
18
+ * Set this for descriptors whose parse() has side effects (e.g.,
19
+ * calling context.cache.addImage) that must run on every render pass.
20
+ *
21
+ * parse() purity contract: for every descriptor without skipCache, parse()
22
+ * MUST be a pure function of (raw computed string) — its result is
23
+ * memoised in a process-wide cache shared across renders and contexts.
24
+ * Any new side effect (resource loading, context capture) requires
25
+ * skipCache: true, or the effect silently stops running.
26
+ */
19
27
  skipCache?: boolean;
20
28
  }
21
29
  export interface IPropertyIdentValueDescriptor<T> extends IPropertyDescriptor {
@@ -0,0 +1,9 @@
1
+ import { IPropertyListDescriptor } from '../property-descriptor';
2
+ /**
3
+ * CSS Transforms Level 2 independent `scale` property.
4
+ * Computed values: `none`, `<number>` (both axes), `<number> <number>` (x y).
5
+ * Unlike a missing value in `transform: scale()`, a single value scales both
6
+ * axes; y defaults to x per the individual-property grammar.
7
+ */
8
+ export type ScaleValue = [number, number] | null;
9
+ export declare const scale: IPropertyListDescriptor<ScaleValue>;
@@ -0,0 +1,10 @@
1
+ import { IPropertyListDescriptor } from '../property-descriptor';
2
+ import { LengthPercentage } from '../types/length-percentage';
3
+ /**
4
+ * CSS Transforms Level 2 independent `translate` property.
5
+ * Computed values: `none`, `<length-percentage>`, `<length-percentage> <length-percentage>`
6
+ * (a third z length may appear in computed values and is ignored — 2D renderer).
7
+ * Percentages are resolved against the element bounds at paint time.
8
+ */
9
+ export type TranslateValue = [LengthPercentage, LengthPercentage] | null;
10
+ export declare const translate: IPropertyListDescriptor<TranslateValue>;
@@ -10,6 +10,14 @@ export declare class Tokenizer {
10
10
  static get(): Tokenizer;
11
11
  static release(tokenizer: Tokenizer): void;
12
12
  private _value;
13
+ /**
14
+ * Read cursor into `_value`. Consumption advances the cursor instead of
15
+ * shifting the array — `Array.shift()` per code point makes tokenising a
16
+ * long value O(n²) (a 200 KB inline data-URI background alone would cost
17
+ * billions of operations, and background-image values are never parse-
18
+ * cached). `write()` compacts already-consumed prefix bytes.
19
+ */
20
+ private _cursor;
13
21
  constructor();
14
22
  private _reset;
15
23
  write(chunk: string): void;
@@ -33,6 +33,27 @@ export declare const d65toD50: (xyz: [number, number, number]) => [number, numbe
33
33
  */
34
34
  export declare const d50toD65: (xyz: [number, number, number]) => [number, number, number];
35
35
  export declare const hue2rgb: (t1: number, t2: number, hue: number) => number;
36
+ export declare const hsl2rgb: ([h, s, l]: [number, number, number]) => [number, number, number];
37
+ /**
38
+ * Convert lch to OKLab
39
+ *
40
+ * @param l
41
+ * @param c
42
+ * @param h
43
+ */
44
+ export declare const lch2lab: ([l, c, h]: [number, number, number]) => [number, number, number];
45
+ /**
46
+ * Convert OKLab to XYZ relative to D65
47
+ *
48
+ * @param lab
49
+ */
50
+ export declare const oklab2xyz: (lab: [number, number, number]) => [number, number, number];
51
+ /**
52
+ * Convert Lab to D50-adapted XYZ
53
+ *
54
+ * @param lab
55
+ */
56
+ export declare const lab2xyz: (lab: [number, number, number]) => [number, number, number];
36
57
  /**
37
58
  * Convert RGB to XYZ
38
59
  *
@@ -0,0 +1,17 @@
1
+ import { Color } from '../color';
2
+ import { Context } from '../../../core/context';
3
+ import { CSSValue } from '../../syntax/parser';
4
+ import { RGB3 } from '../color-math';
5
+ type HueMethod = 'shorter' | 'longer' | 'increasing' | 'decreasing';
6
+ /** Inverse of color-utilities' lab2xyz: D65 XYZ → CIE Lab (0..100 scale). */
7
+ export declare const xyzD65ToLab: (xyz: RGB3) => RGB3;
8
+ /** D65 XYZ → OKLab via the inverted forward matrices. */
9
+ export declare const xyzD65ToOklab: (xyz: RGB3) => RGB3;
10
+ /**
11
+ * Interpolate a hue angle in degrees per css-color-4 §12.4. `weight1` and
12
+ * `weight2` are the (normalized) mix weights; the hue travels from h1 towards
13
+ * h2 by the shared fraction. Exported for unit tests.
14
+ */
15
+ export declare const interpolateHue: (h1: number, h2: number, weight1: number, weight2: number, method?: HueMethod) => number;
16
+ export declare const colorMix: (context: Context, args: CSSValue[]) => Color;
17
+ export {};
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Constructable stylesheet cloning (adoptedStyleSheets).
3
+ *
4
+ * `adoptedStyleSheets` on a Document or ShadowRoot is the standard way Lit,
5
+ * React and other frameworks inject component styles, but the sheets are not
6
+ * part of the node tree — cloneNode never carries them. A shadow root that
7
+ * relies on adopted sheets (and whose computed styles are not inlined per
8
+ * element, i.e. copyStyles is false) would otherwise lose those rules in the
9
+ * clone. The rules are re-materialised as a regular <style> element, which
10
+ * also cascades last like the spec treats adopted sheets.
11
+ */
12
+ /**
13
+ * Serialize the CSS rules of the given sheets into one stylesheet string.
14
+ * Sheets that cannot be read (e.g. detached) are skipped rather than failing
15
+ * the render.
16
+ */
17
+ export declare const serializeStyleSheetRules: (sheets: readonly CSSStyleSheet[]) => string;
18
+ /**
19
+ * Build a <style> element carrying the rules of the given adopted sheets, or
20
+ * null when there is nothing to clone. `styleDocument` must be the document
21
+ * the clone lives in.
22
+ */
23
+ export declare const createAdoptedStylesElement: (styleDocument: Document, sheets: readonly CSSStyleSheet[], nonce?: string) => HTMLStyleElement | null;
@@ -18,6 +18,8 @@ export type CloneConfigurations = CloneOptions & {
18
18
  inlineImages: boolean;
19
19
  copyStyles: boolean;
20
20
  cspNonce?: string;
21
+ /** Aborting rejects the iframe mount instead of waiting out readiness windows. */
22
+ signal?: AbortSignal;
21
23
  };
22
24
  export declare class DocumentCloner {
23
25
  private readonly context;
@@ -30,6 +32,16 @@ export declare class DocumentCloner {
30
32
  private readonly pseudoContents;
31
33
  private readonly slotCloner;
32
34
  constructor(context: Context, element: HTMLElement, options: CloneConfigurations);
35
+ /**
36
+ * Re-materialise the source document's constructable stylesheets
37
+ * (document.adoptedStyleSheets) as a <style> at the end of the clone's
38
+ * <head>: cloneNode never carries them, and they cascade after all author
39
+ * sheets, which appending last approximates.
40
+ *
41
+ * Skipped when computed styles are inlined per element (copyStyles), like
42
+ * the other stylesheet-cloning paths.
43
+ */
44
+ private appendDocumentAdoptedStyles;
33
45
  toIFrame(ownerDocument: Document, windowSize: Bounds): Promise<HTMLIFrameElement>;
34
46
  createElementClone<T extends HTMLElement | SVGElement>(node: T): HTMLElement | SVGElement;
35
47
  createCustomElementClone(originalNode: HTMLElement, clonedNode: HTMLElement): HTMLElement;
@@ -11,6 +11,8 @@ export interface OriginalStyles {
11
11
  animationDuration?: string;
12
12
  transform?: string;
13
13
  rotate?: string;
14
+ translate?: string;
15
+ scale?: string;
14
16
  }
15
17
  /**
16
18
  * Normalize element styles for accurate rendering
@@ -1,6 +1,6 @@
1
- import { ElementContainer } from '../element-container';
1
+ import { ElementContainer, ElementContainerOptions } from '../element-container';
2
2
  import { Context } from '../../core/context';
3
3
  export declare class LIElementContainer extends ElementContainer {
4
4
  readonly value: number;
5
- constructor(context: Context, element: HTMLLIElement);
5
+ constructor(context: Context, element: HTMLLIElement, options?: ElementContainerOptions);
6
6
  }
@@ -1,7 +1,7 @@
1
- import { ElementContainer } from '../element-container';
1
+ import { ElementContainer, ElementContainerOptions } from '../element-container';
2
2
  import { Context } from '../../core/context';
3
3
  export declare class OLElementContainer extends ElementContainer {
4
4
  readonly start: number;
5
5
  readonly reversed: boolean;
6
- constructor(context: Context, element: HTMLOListElement);
6
+ constructor(context: Context, element: HTMLOListElement, options?: ElementContainerOptions);
7
7
  }
@@ -1,6 +1,6 @@
1
- import { ElementContainer } from '../element-container';
1
+ import { ElementContainer, ElementContainerOptions } from '../element-container';
2
2
  import { Context } from '../../core/context';
3
3
  export declare class SelectElementContainer extends ElementContainer {
4
4
  readonly value: string;
5
- constructor(context: Context, element: HTMLSelectElement);
5
+ constructor(context: Context, element: HTMLSelectElement, options?: ElementContainerOptions);
6
6
  }
@@ -1,6 +1,6 @@
1
- import { ElementContainer } from '../element-container';
1
+ import { ElementContainer, ElementContainerOptions } from '../element-container';
2
2
  import { Context } from '../../core/context';
3
3
  export declare class TextareaElementContainer extends ElementContainer {
4
4
  readonly value: string;
5
- constructor(context: Context, element: HTMLTextAreaElement);
5
+ constructor(context: Context, element: HTMLTextAreaElement, options?: ElementContainerOptions);
6
6
  }
@@ -22,7 +22,23 @@ export interface CloneMountOptions {
22
22
  onclone?: (document: Document, element: HTMLElement) => void;
23
23
  /** Mount the iframe inside a shadow root instead of <body>. */
24
24
  container?: HTMLElement | ShadowRoot;
25
+ /**
26
+ * Aborting rejects the mount (iframe poll, font/image waits) with an
27
+ * AbortError instead of waiting out the readiness windows.
28
+ */
29
+ signal?: AbortSignal;
25
30
  }
31
+ type TrustedTypePolicyLike = {
32
+ createHTML: (s: string) => string;
33
+ };
34
+ /**
35
+ * Resolve the Trusted Types policy used for writing the clone document.
36
+ * Returns null when Trusted Types are unavailable or the policy could not be
37
+ * created — document.write is not a Trusted Types sink, so the plain string
38
+ * stays functional in both cases.
39
+ * @internal – exported for testing only.
40
+ */
41
+ export declare const resolveTrustedTypesPolicy: (ownerWindow: Window | null) => TrustedTypePolicyLike | null;
26
42
  export declare const createIFrameContainer: (ownerDocument: Document, bounds: Bounds, customContainer?: HTMLElement | ShadowRoot) => HTMLIFrameElement;
27
43
  /**
28
44
  * Serialise a document type declaration to an HTML string.
@@ -35,3 +51,4 @@ export declare const serializeDoctype: (doctype?: DocumentType | null) => string
35
51
  */
36
52
  export declare const addBase: (targetELement: HTMLElement, baseUri: string) => void;
37
53
  export declare const mountCloneInIFrame: (context: Context, ownerDocument: Document, windowSize: Bounds, mount: CloneMountOptions) => Promise<HTMLIFrameElement>;
54
+ export {};
@@ -1,3 +1,3 @@
1
- import { ElementContainer } from './element-container';
1
+ import { ElementContainer, ElementContainerOptions } from './element-container';
2
2
  import { Context } from '../core/context';
3
- export declare const parseTree: (context: Context, element: HTMLElement) => ElementContainer;
3
+ export declare const parseTree: (context: Context, element: HTMLElement, options?: ElementContainerOptions) => ElementContainer;
@@ -1,8 +1,8 @@
1
- import { ElementContainer } from '../element-container';
1
+ import { ElementContainer, ElementContainerOptions } from '../element-container';
2
2
  import { Context } from '../../core/context';
3
3
  export declare class CanvasElementContainer extends ElementContainer {
4
4
  canvas: HTMLCanvasElement;
5
5
  intrinsicWidth: number;
6
6
  intrinsicHeight: number;
7
- constructor(context: Context, canvas: HTMLCanvasElement);
7
+ constructor(context: Context, canvas: HTMLCanvasElement, options?: ElementContainerOptions);
8
8
  }
@@ -1,4 +1,4 @@
1
- import { ElementContainer } from '../element-container';
1
+ import { ElementContainer, ElementContainerOptions } from '../element-container';
2
2
  import { type Color } from '../../css/types/color';
3
3
  import { Context } from '../../core/context';
4
4
  type ParseTreeFunction = (context: Context, node: HTMLElement) => ElementContainer;
@@ -9,6 +9,6 @@ export declare class IFrameElementContainer extends ElementContainer {
9
9
  tree?: ElementContainer;
10
10
  backgroundColor: Color;
11
11
  private parseTreeFn?;
12
- constructor(context: Context, iframe: HTMLIFrameElement, parseTreeFn?: ParseTreeFunction);
12
+ constructor(context: Context, iframe: HTMLIFrameElement, parseTreeFn?: ParseTreeFunction, options?: ElementContainerOptions);
13
13
  }
14
14
  export {};
@@ -1,8 +1,8 @@
1
- import { ElementContainer } from '../element-container';
1
+ import { ElementContainer, ElementContainerOptions } from '../element-container';
2
2
  import { Context } from '../../core/context';
3
3
  export declare class ImageElementContainer extends ElementContainer {
4
4
  src: string;
5
5
  intrinsicWidth: number;
6
6
  intrinsicHeight: number;
7
- constructor(context: Context, img: HTMLImageElement);
7
+ constructor(context: Context, img: HTMLImageElement, options?: ElementContainerOptions);
8
8
  }
@@ -1,4 +1,4 @@
1
- import { ElementContainer } from '../element-container';
1
+ import { ElementContainer, ElementContainerOptions } from '../element-container';
2
2
  import { Context } from '../../core/context';
3
3
  export declare const CHECKBOX = "checkbox";
4
4
  export declare const RADIO = "radio";
@@ -10,5 +10,5 @@ export declare class InputElementContainer extends ElementContainer {
10
10
  readonly checked: boolean;
11
11
  readonly value: string;
12
12
  readonly isPlaceholder: boolean;
13
- constructor(context: Context, input: HTMLInputElement);
13
+ constructor(context: Context, input: HTMLInputElement, options?: ElementContainerOptions);
14
14
  }
@@ -1,9 +1,9 @@
1
- import { ElementContainer } from '../element-container';
1
+ import { ElementContainer, ElementContainerOptions } from '../element-container';
2
2
  import { Context } from '../../core/context';
3
3
  export declare const serializeWithoutBoxOffsets: (serializer: XMLSerializer, img: SVGSVGElement) => string;
4
4
  export declare class SVGElementContainer extends ElementContainer {
5
5
  svg: string;
6
6
  intrinsicWidth: number;
7
7
  intrinsicHeight: number;
8
- constructor(context: Context, img: SVGSVGElement);
8
+ constructor(context: Context, img: SVGSVGElement, options?: ElementContainerOptions);
9
9
  }
@@ -3,6 +3,8 @@ import { Context } from '../core/context';
3
3
  export interface SlotClonerOptions {
4
4
  ignoreElements?: (element: Element) => boolean;
5
5
  copyStyles: boolean;
6
+ /** CSP nonce applied to synthesized <style> elements (adopted sheets). */
7
+ cspNonce?: string;
6
8
  }
7
9
  /** Exported for reuse in document-cloner.ts */
8
10
  export declare const IGNORE_ATTRIBUTE = "data-html2canvas-ignore";
@@ -63,4 +65,12 @@ export declare class SlotCloner {
63
65
  * This is a fallback mechanism to ensure content is not lost.
64
66
  */
65
67
  private cloneShadowDOMAsLightDOM;
68
+ /**
69
+ * Re-materialise the shadow root's constructable stylesheets (adoptedStyleSheets)
70
+ * as a <style> element in the clone — cloneNode never carries them.
71
+ *
72
+ * Skipped when computed styles are inlined per element (copyStyles), mirroring
73
+ * how <style> elements inside shadow roots are dropped in that mode.
74
+ */
75
+ private appendAdoptedStyleSheets;
66
76
  }
@@ -7,6 +7,19 @@ import { Validator } from './core/validator';
7
7
  *
8
8
  * Combines clone, window, render, and context configuration into a single
9
9
  * options object. All properties are optional.
10
+ *
11
+ * The full surface is composed from these interfaces (each documented where
12
+ * it is declared):
13
+ * - {@link CloneOptions} — `ignoreElements`, `onclone`, `allowTaint`,
14
+ * `iframeContainer` (src/dom/document-cloner.ts)
15
+ * - {@link WindowOptions} — `scrollX`, `scrollY`, `windowWidth`,
16
+ * `windowHeight` (src/dom/document-cloner.ts)
17
+ * - {@link RenderOptions} — `scale`, `canvas`, `x`, `y`, `width`, `height`
18
+ * (src/render/canvas/canvas-renderer.ts)
19
+ * - {@link ContextOptions} — `logging`, `cache`, `onError`, plus the
20
+ * `ResourceOptions` it extends: `imageTimeout`, `useCORS`, `proxy`,
21
+ * `customIsSameOrigin`, `maxCacheSize` (src/core/context.ts and
22
+ * src/core/cache-storage.ts)
10
23
  */
11
24
  export type Options = CloneOptions & WindowOptions & RenderOptions & ContextOptions & {
12
25
  /** Background color for the resulting canvas. Use `null` for transparent. */
@@ -15,6 +28,14 @@ export type Options = CloneOptions & WindowOptions & RenderOptions & ContextOpti
15
28
  foreignObjectRendering: boolean;
16
29
  /** Whether to remove the cloned iframe after rendering. @default true */
17
30
  removeContainer?: boolean;
31
+ /**
32
+ * Normalize the cloned DOM before parsing: disable CSS animations and
33
+ * replace active transforms with identity values so element bounds are
34
+ * measured in layout space. Set to `false` to keep animation/transform
35
+ * state intact during capture.
36
+ * @default true
37
+ */
38
+ normalizeDom?: boolean;
18
39
  /** CSP nonce for inline style elements. */
19
40
  cspNonce?: string;
20
41
  /** Custom input validator. */
@@ -51,6 +72,9 @@ export type Options = CloneOptions & WindowOptions & RenderOptions & ContextOpti
51
72
  /**
52
73
  * Called when a resource fails to load (image, font, iframe, etc.).
53
74
  * The render continues — this is a notification hook, not an abort.
75
+ * Image/proxy load failures are reported exactly once, by the
76
+ * resource cache at load time; iframe content failures are reported
77
+ * by the iframe container.
54
78
  */
55
79
  onError?: (error: Error) => void;
56
80
  /**
@@ -64,4 +64,11 @@ export declare class BorderImageRenderer {
64
64
  renderBorderImage(bounds: Bounds, image: HTMLImageElement, slice: BorderImageSlice, repeat: BorderImageRepeat, borderTopWidth: number, borderRightWidth: number, borderBottomWidth: number, borderLeftWidth: number, outset?: BorderImageSides): void;
65
65
  private drawRegion;
66
66
  private drawRepeatedEdge;
67
+ /**
68
+ * Draw the center region of the border image, tiling each axis per its
69
+ * border-image-repeat keyword (stretch spans the whole axis, repeat
70
+ * tiles at source size with the overflow cropped, round scales the tile
71
+ * to divide the axis evenly).
72
+ */
73
+ private drawCenterRegion;
67
74
  }
@@ -71,7 +71,6 @@ export declare class CanvasRenderer {
71
71
  renderReplacedElement(container: ReplacedElementContainer, curves: BoundCurves, image: HTMLImageElement | HTMLCanvasElement): void;
72
72
  renderNodeContent(paint: ElementPaint): Promise<void>;
73
73
  renderStackContent(stack: StackingContext): Promise<void>;
74
- mask(paths: Path[]): void;
75
74
  path(paths: Path[]): void;
76
75
  formatPath(paths: Path[]): void;
77
76
  private renderSurfaceBoxShadow;
@@ -91,8 +90,8 @@ export declare class CanvasRenderer {
91
90
  private rasterizeGradientSource;
92
91
  /**
93
92
  * Filter the already-painted content beneath the element's border box and
94
- * paint the result back, approximating CSS backdrop-filter for the
95
- * blur/drop-shadow subset supported by parseSimpleFilter.
93
+ * paint the result back, approximating CSS backdrop-filter for the chain
94
+ * subset the filter surface backends support.
96
95
  */
97
96
  private renderBackdropFilter;
98
97
  render(element: ElementContainer): Promise<HTMLCanvasElement>;