html2canvas-pro 2.1.1 → 2.2.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/README.md +19 -19
- package/dist/html2canvas-pro.esm.js +10232 -10540
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +10875 -11185
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +8 -8
- package/dist/lib/config.js +0 -22
- package/dist/lib/core/cache-storage.js +1 -38
- package/dist/lib/core/constants.js +25 -0
- package/dist/lib/core/context.js +1 -0
- package/dist/lib/core/features.js +1 -0
- package/dist/lib/core/render-element.js +2 -1
- package/dist/lib/core/validator.js +3 -3
- package/dist/lib/css/grouped/background-styles.js +36 -0
- package/dist/lib/css/grouped/border-styles.js +75 -0
- package/dist/lib/css/grouped/font-styles.js +93 -0
- package/dist/lib/css/grouped/layout-styles.js +127 -0
- package/dist/lib/css/index.js +81 -47
- package/dist/lib/css/layout/text.js +7 -6
- package/dist/lib/css/property-descriptors/background-blend-mode.js +41 -0
- package/dist/lib/css/property-descriptors/border-image-repeat.js +42 -0
- package/dist/lib/css/property-descriptors/border-image-slice.js +45 -0
- package/dist/lib/css/property-descriptors/border-image-source.js +21 -0
- package/dist/lib/css/property-descriptors/border-radius.js +1 -1
- package/dist/lib/css/property-descriptors/box-decoration-break.js +18 -0
- package/dist/lib/css/property-descriptors/counter-increment.js +17 -12
- package/dist/lib/css/property-descriptors/counter-reset.js +4 -12
- package/dist/lib/css/property-descriptors/filter.js +76 -0
- package/dist/lib/css/property-descriptors/font-variant-ligatures.js +34 -0
- package/dist/lib/css/property-descriptors/object-fit.js +1 -1
- package/dist/lib/css/property-descriptors/object-position.js +42 -0
- package/dist/lib/css/property-descriptors/visibility.js +1 -1
- package/dist/lib/css/property-descriptors/zoom.js +18 -0
- package/dist/lib/css/syntax/parser.js +0 -1
- package/dist/lib/css/types/color.js +5 -1
- package/dist/lib/css/types/functions/repeating-linear-gradient.js +9 -0
- package/dist/lib/css/types/image.js +12 -2
- package/dist/lib/css/types/length-percentage.js +6 -2
- package/dist/lib/css/types/safe-eval.js +80 -0
- package/dist/lib/dom/document-cloner.js +23 -163
- package/dist/lib/dom/slot-cloner.js +176 -0
- package/dist/lib/index.js +1 -17
- package/dist/lib/render/canvas/background-renderer.js +165 -32
- package/dist/lib/render/canvas/border-image-renderer.js +153 -0
- package/dist/lib/render/canvas/canvas-renderer.js +34 -189
- package/dist/lib/render/canvas/content-renderer.js +202 -0
- package/dist/lib/render/canvas/effects-renderer.js +10 -0
- package/dist/lib/render/canvas/text/text-decoration-renderer.js +99 -0
- package/dist/lib/render/canvas/text-renderer.js +100 -224
- package/dist/lib/render/effects.js +38 -3
- package/dist/lib/render/object-fit.js +19 -15
- package/dist/lib/render/stacking-context.js +11 -0
- package/dist/types/config.d.ts +0 -10
- package/dist/types/core/cache-storage.d.ts +0 -24
- package/dist/types/core/constants.d.ts +22 -0
- package/dist/types/core/context.d.ts +3 -0
- package/dist/types/core/performance-monitor.d.ts +4 -4
- package/dist/types/core/validator.d.ts +6 -8
- package/dist/types/css/grouped/background-styles.d.ts +16 -0
- package/dist/types/css/grouped/border-styles.d.ts +31 -0
- package/dist/types/css/grouped/font-styles.d.ts +35 -0
- package/dist/types/css/grouped/layout-styles.d.ts +46 -0
- package/dist/types/css/index.d.ts +30 -0
- package/dist/types/css/property-descriptors/background-blend-mode.d.ts +23 -0
- package/dist/types/css/property-descriptors/border-image-repeat.d.ts +12 -0
- package/dist/types/css/property-descriptors/border-image-slice.d.ts +10 -0
- package/dist/types/css/property-descriptors/border-image-source.d.ts +4 -0
- package/dist/types/css/property-descriptors/box-decoration-break.d.ts +6 -0
- package/dist/types/css/property-descriptors/counter-increment.d.ts +3 -0
- package/dist/types/css/property-descriptors/filter.d.ts +3 -0
- package/dist/types/css/property-descriptors/font-variant-ligatures.d.ts +14 -0
- package/dist/types/css/property-descriptors/object-position.d.ts +4 -0
- package/dist/types/css/property-descriptors/zoom.d.ts +3 -0
- package/dist/types/css/types/functions/repeating-linear-gradient.d.ts +4 -0
- package/dist/types/css/types/image.d.ts +4 -2
- package/dist/types/css/types/safe-eval.d.ts +8 -0
- package/dist/types/dom/document-cloner.d.ts +3 -44
- package/dist/types/dom/slot-cloner.d.ts +66 -0
- package/dist/types/index.d.ts +3 -7
- package/dist/types/options.d.ts +11 -0
- package/dist/types/render/canvas/background-renderer.d.ts +23 -0
- package/dist/types/render/canvas/border-image-renderer.d.ts +18 -0
- package/dist/types/render/canvas/canvas-renderer.d.ts +1 -0
- package/dist/types/render/canvas/content-renderer.d.ts +44 -0
- package/dist/types/render/canvas/text/text-decoration-renderer.d.ts +18 -0
- package/dist/types/render/canvas/text-renderer.d.ts +12 -1
- package/dist/types/render/effects.d.ts +12 -2
- package/dist/types/render/object-fit.d.ts +2 -1
- package/dist/types/render/renderer-interface.d.ts +11 -9
- package/package.json +5 -10
- package/dist/lib/dom/replaced-elements/pseudo-elements.js +0 -0
- package/dist/types/dom/replaced-elements/pseudo-elements.d.ts +0 -0
|
@@ -10,11 +10,8 @@
|
|
|
10
10
|
export interface ValidationResult {
|
|
11
11
|
valid: boolean;
|
|
12
12
|
error?: string;
|
|
13
|
-
sanitized?:
|
|
14
|
-
/**
|
|
15
|
-
* Indicates if runtime validation is recommended
|
|
16
|
-
* (e.g., for proxy URLs to prevent DNS rebinding attacks)
|
|
17
|
-
*/
|
|
13
|
+
sanitized?: unknown;
|
|
14
|
+
/** Indicates if runtime validation is recommended (e.g. for proxy URLs against DNS rebinding) */
|
|
18
15
|
requiresRuntimeCheck?: boolean;
|
|
19
16
|
}
|
|
20
17
|
/**
|
|
@@ -42,7 +39,8 @@ export interface ValidatorConfig {
|
|
|
42
39
|
/**
|
|
43
40
|
* Custom validation function
|
|
44
41
|
*/
|
|
45
|
-
|
|
42
|
+
/** Custom validation function. Receives the raw value and its semantic type. */
|
|
43
|
+
customValidator?: (value: unknown, type: string) => ValidationResult;
|
|
46
44
|
}
|
|
47
45
|
/**
|
|
48
46
|
* Input Validator
|
|
@@ -113,14 +111,14 @@ export declare class Validator {
|
|
|
113
111
|
* @param element - Element to validate
|
|
114
112
|
* @returns Validation result
|
|
115
113
|
*/
|
|
116
|
-
validateElement(element:
|
|
114
|
+
validateElement(element: unknown): ValidationResult;
|
|
117
115
|
/**
|
|
118
116
|
* Validate entire options object
|
|
119
117
|
*
|
|
120
118
|
* @param options - Options to validate
|
|
121
119
|
* @returns Validation result with all errors
|
|
122
120
|
*/
|
|
123
|
-
validateOptions(options:
|
|
121
|
+
validateOptions(options: Record<string, unknown>): ValidationResult;
|
|
124
122
|
}
|
|
125
123
|
/**
|
|
126
124
|
* Create a default validator instance
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CSSParsedDeclaration } from '../index';
|
|
2
|
+
/**
|
|
3
|
+
* Read-only grouped accessor for background-related CSS properties.
|
|
4
|
+
*/
|
|
5
|
+
export declare class BackgroundStyles {
|
|
6
|
+
private readonly styles;
|
|
7
|
+
constructor(styles: CSSParsedDeclaration);
|
|
8
|
+
get color(): number;
|
|
9
|
+
get image(): import("../types/image").ICSSImage[];
|
|
10
|
+
get clip(): import("../property-descriptors/background-clip").BackgroundClip;
|
|
11
|
+
get origin(): import("../property-descriptors/background-origin").BackgroundOrigin;
|
|
12
|
+
get position(): import("../property-descriptors/background-position").BackgroundPosition;
|
|
13
|
+
get repeat(): import("../property-descriptors/background-repeat").BackgroundRepeat;
|
|
14
|
+
get size(): import("../property-descriptors/background-size").BackgroundSize;
|
|
15
|
+
get blendMode(): import("../property-descriptors/background-blend-mode").BackgroundBlendMode;
|
|
16
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CSSParsedDeclaration } from '../index';
|
|
2
|
+
/**
|
|
3
|
+
* Read-only grouped accessor for border-related CSS properties.
|
|
4
|
+
*
|
|
5
|
+
* Provides structured access: `styles.border.topColor` as an alternative
|
|
6
|
+
* to the flat `styles.borderTopColor`. Both forms remain valid.
|
|
7
|
+
*/
|
|
8
|
+
export declare class BorderStyles {
|
|
9
|
+
private readonly styles;
|
|
10
|
+
constructor(styles: CSSParsedDeclaration);
|
|
11
|
+
get topColor(): number;
|
|
12
|
+
get rightColor(): number;
|
|
13
|
+
get bottomColor(): number;
|
|
14
|
+
get leftColor(): number;
|
|
15
|
+
get topStyle(): import("../property-descriptors/border-style").BORDER_STYLE;
|
|
16
|
+
get rightStyle(): import("../property-descriptors/border-style").BORDER_STYLE;
|
|
17
|
+
get bottomStyle(): import("../property-descriptors/border-style").BORDER_STYLE;
|
|
18
|
+
get leftStyle(): import("../property-descriptors/border-style").BORDER_STYLE;
|
|
19
|
+
get topWidth(): number;
|
|
20
|
+
get rightWidth(): number;
|
|
21
|
+
get bottomWidth(): number;
|
|
22
|
+
get leftWidth(): number;
|
|
23
|
+
get topLeftRadius(): import("../types/length-percentage").LengthPercentageTuple;
|
|
24
|
+
get topRightRadius(): import("../types/length-percentage").LengthPercentageTuple;
|
|
25
|
+
get bottomRightRadius(): import("../types/length-percentage").LengthPercentageTuple;
|
|
26
|
+
get bottomLeftRadius(): import("../types/length-percentage").LengthPercentageTuple;
|
|
27
|
+
get imageSource(): import("../property-descriptors/border-image-source").BorderImageSource;
|
|
28
|
+
get imageSlice(): import("../property-descriptors/border-image-slice").BorderImageSlice;
|
|
29
|
+
get imageRepeat(): import("../property-descriptors/border-image-repeat").BorderImageRepeat;
|
|
30
|
+
get boxShadow(): import("../property-descriptors/box-shadow").BoxShadow;
|
|
31
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CSSParsedDeclaration } from '../index';
|
|
2
|
+
/**
|
|
3
|
+
* Read-only grouped accessor for font/text-related CSS properties.
|
|
4
|
+
*/
|
|
5
|
+
export declare class FontStyles {
|
|
6
|
+
private readonly styles;
|
|
7
|
+
constructor(styles: CSSParsedDeclaration);
|
|
8
|
+
get family(): import("../property-descriptors/font-family").FontFamily;
|
|
9
|
+
get size(): import("../types/length-percentage").LengthPercentage;
|
|
10
|
+
get style(): import("../property-descriptors/font-style").FONT_STYLE;
|
|
11
|
+
get variant(): string[];
|
|
12
|
+
get weight(): number;
|
|
13
|
+
get ligatures(): import("../property-descriptors/font-variant-ligatures").FONT_VARIANT_LIGATURES;
|
|
14
|
+
get color(): number;
|
|
15
|
+
get letterSpacing(): number;
|
|
16
|
+
get lineHeight(): import("../syntax/parser").CSSValue;
|
|
17
|
+
get textAlign(): import("../property-descriptors/text-align").TEXT_ALIGN;
|
|
18
|
+
get textTransform(): import("../property-descriptors/text-transform").TEXT_TRANSFORM;
|
|
19
|
+
get textOverflow(): import("../property-descriptors/text-overflow").TEXT_OVERFLOW;
|
|
20
|
+
get textShadow(): import("../property-descriptors/text-shadow").TextShadow;
|
|
21
|
+
get textDecorationColor(): number;
|
|
22
|
+
get textDecorationLine(): import("../property-descriptors/text-decoration-line").TextDecorationLine;
|
|
23
|
+
get textDecorationStyle(): import("../property-descriptors/text-decoration-style").TEXT_DECORATION_STYLE;
|
|
24
|
+
get textDecorationThickness(): import("../property-descriptors/text-decoration-thickness").TextDecorationThickness;
|
|
25
|
+
get textUnderlineOffset(): import("../property-descriptors/text-underline-offset").TextUnderlineOffset;
|
|
26
|
+
get wordBreak(): import("../property-descriptors/word-break").WORD_BREAK;
|
|
27
|
+
get lineBreak(): import("../property-descriptors/line-break").LINE_BREAK;
|
|
28
|
+
get overflowWrap(): import("../property-descriptors/overflow-wrap").OVERFLOW_WRAP;
|
|
29
|
+
get writingMode(): import("../property-descriptors/writing-mode").WRITING_MODE;
|
|
30
|
+
get direction(): import("../property-descriptors/direction").DIRECTION;
|
|
31
|
+
get webkitTextStrokeColor(): number;
|
|
32
|
+
get webkitTextStrokeWidth(): number;
|
|
33
|
+
get webkitLineClamp(): number;
|
|
34
|
+
get paintOrder(): import("../property-descriptors/paint-order").PaintOrder;
|
|
35
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { CSSParsedDeclaration } from '../index';
|
|
2
|
+
/**
|
|
3
|
+
* Read-only grouped accessor for layout/display/positioning CSS properties.
|
|
4
|
+
*/
|
|
5
|
+
export declare class LayoutStyles {
|
|
6
|
+
private readonly styles;
|
|
7
|
+
constructor(styles: CSSParsedDeclaration);
|
|
8
|
+
get display(): number;
|
|
9
|
+
get position(): import("../property-descriptors/position").POSITION;
|
|
10
|
+
get float(): import("../property-descriptors/float").FLOAT;
|
|
11
|
+
get zIndex(): CSSParsedDeclaration['zIndex'];
|
|
12
|
+
get marginTop(): import("../syntax/parser").CSSValue;
|
|
13
|
+
get marginRight(): import("../syntax/parser").CSSValue;
|
|
14
|
+
get marginBottom(): import("../syntax/parser").CSSValue;
|
|
15
|
+
get marginLeft(): import("../syntax/parser").CSSValue;
|
|
16
|
+
get paddingTop(): import("../types/length-percentage").LengthPercentage;
|
|
17
|
+
get paddingRight(): import("../types/length-percentage").LengthPercentage;
|
|
18
|
+
get paddingBottom(): import("../types/length-percentage").LengthPercentage;
|
|
19
|
+
get paddingLeft(): import("../types/length-percentage").LengthPercentage;
|
|
20
|
+
get overflowX(): import("../property-descriptors/overflow").OVERFLOW;
|
|
21
|
+
get overflowY(): import("../property-descriptors/overflow").OVERFLOW;
|
|
22
|
+
get opacity(): number;
|
|
23
|
+
get visibility(): import("../property-descriptors/visibility").VISIBILITY;
|
|
24
|
+
get transform(): import("../property-descriptors/transform").Transform;
|
|
25
|
+
get transformOrigin(): import("../property-descriptors/transform-origin").TransformOrigin;
|
|
26
|
+
get rotate(): import("../property-descriptors/rotate").Rotate;
|
|
27
|
+
get zoom(): number;
|
|
28
|
+
get clipPath(): import("../property-descriptors/clip-path").ClipPathValue;
|
|
29
|
+
get mixBlendMode(): import("../property-descriptors/mix-blend-mode").MixBlendMode;
|
|
30
|
+
get filter(): import("../property-descriptors/filter").FilterValue;
|
|
31
|
+
get imageRendering(): import("../property-descriptors/image-rendering").IMAGE_RENDERING;
|
|
32
|
+
get objectFit(): number;
|
|
33
|
+
get objectPosition(): import("../property-descriptors/object-position").ObjectPosition;
|
|
34
|
+
get boxDecorationBreak(): import("../property-descriptors/box-decoration-break").BOX_DECORATION_BREAK;
|
|
35
|
+
get listStyleImage(): import("../types/image").ICSSImage | null;
|
|
36
|
+
get listStylePosition(): import("../property-descriptors/list-style-position").LIST_STYLE_POSITION;
|
|
37
|
+
get listStyleType(): import("../property-descriptors/list-style-type").LIST_STYLE_TYPE;
|
|
38
|
+
get animationDuration(): number[];
|
|
39
|
+
isVisible(): boolean;
|
|
40
|
+
isTransparent(): boolean;
|
|
41
|
+
isTransformed(): boolean;
|
|
42
|
+
isPositioned(): boolean;
|
|
43
|
+
isPositionedWithZIndex(): boolean;
|
|
44
|
+
isFloating(): boolean;
|
|
45
|
+
isInlineLevel(): boolean;
|
|
46
|
+
}
|
|
@@ -55,6 +55,19 @@ import { objectFit } from './property-descriptors/object-fit';
|
|
|
55
55
|
import { textOverflow } from './property-descriptors/text-overflow';
|
|
56
56
|
import { imageRendering } from './property-descriptors/image-rendering';
|
|
57
57
|
import { MixBlendMode } from './property-descriptors/mix-blend-mode';
|
|
58
|
+
import { filter } from './property-descriptors/filter';
|
|
59
|
+
import { fontVariantLigatures } from './property-descriptors/font-variant-ligatures';
|
|
60
|
+
import { zoom } from './property-descriptors/zoom';
|
|
61
|
+
import { objectPosition } from './property-descriptors/object-position';
|
|
62
|
+
import { backgroundBlendMode } from './property-descriptors/background-blend-mode';
|
|
63
|
+
import { borderImageSource } from './property-descriptors/border-image-source';
|
|
64
|
+
import { borderImageSlice } from './property-descriptors/border-image-slice';
|
|
65
|
+
import { borderImageRepeat } from './property-descriptors/border-image-repeat';
|
|
66
|
+
import { boxDecorationBreak } from './property-descriptors/box-decoration-break';
|
|
67
|
+
import { BorderStyles } from './grouped/border-styles';
|
|
68
|
+
import { BackgroundStyles } from './grouped/background-styles';
|
|
69
|
+
import { FontStyles } from './grouped/font-styles';
|
|
70
|
+
import { LayoutStyles } from './grouped/layout-styles';
|
|
58
71
|
export declare class CSSParsedDeclaration {
|
|
59
72
|
animationDuration: ReturnType<typeof duration.parse>;
|
|
60
73
|
backgroundClip: ReturnType<typeof backgroundClip.parse>;
|
|
@@ -133,6 +146,23 @@ export declare class CSSParsedDeclaration {
|
|
|
133
146
|
objectFit: ReturnType<typeof objectFit.parse>;
|
|
134
147
|
imageRendering: ReturnType<typeof imageRendering.parse>;
|
|
135
148
|
mixBlendMode: MixBlendMode;
|
|
149
|
+
filter: ReturnType<typeof filter.parse>;
|
|
150
|
+
fontVariantLigatures: ReturnType<typeof fontVariantLigatures.parse>;
|
|
151
|
+
zoom: ReturnType<typeof zoom.parse>;
|
|
152
|
+
objectPosition: ReturnType<typeof objectPosition.parse>;
|
|
153
|
+
backgroundBlendMode: ReturnType<typeof backgroundBlendMode.parse>;
|
|
154
|
+
borderImageSource: ReturnType<typeof borderImageSource.parse>;
|
|
155
|
+
borderImageSlice: ReturnType<typeof borderImageSlice.parse>;
|
|
156
|
+
borderImageRepeat: ReturnType<typeof borderImageRepeat.parse>;
|
|
157
|
+
boxDecorationBreak: ReturnType<typeof boxDecorationBreak.parse>;
|
|
158
|
+
private _border?;
|
|
159
|
+
private _background?;
|
|
160
|
+
private _font?;
|
|
161
|
+
private _layout?;
|
|
162
|
+
get border(): BorderStyles;
|
|
163
|
+
get background(): BackgroundStyles;
|
|
164
|
+
get font(): FontStyles;
|
|
165
|
+
get layout(): LayoutStyles;
|
|
136
166
|
private static readonly standardProps;
|
|
137
167
|
constructor(context: Context, declaration: CSSStyleDeclaration);
|
|
138
168
|
isVisible(): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IPropertyListDescriptor } from '../property-descriptor';
|
|
2
|
+
export declare const MIX_BLEND_MODE: {
|
|
3
|
+
readonly NORMAL: "normal";
|
|
4
|
+
readonly MULTIPLY: "multiply";
|
|
5
|
+
readonly SCREEN: "screen";
|
|
6
|
+
readonly OVERLAY: "overlay";
|
|
7
|
+
readonly DARKEN: "darken";
|
|
8
|
+
readonly LIGHTEN: "lighten";
|
|
9
|
+
readonly COLOR_DODGE: "color-dodge";
|
|
10
|
+
readonly COLOR_BURN: "color-burn";
|
|
11
|
+
readonly HARD_LIGHT: "hard-light";
|
|
12
|
+
readonly SOFT_LIGHT: "soft-light";
|
|
13
|
+
readonly DIFFERENCE: "difference";
|
|
14
|
+
readonly EXCLUSION: "exclusion";
|
|
15
|
+
readonly HUE: "hue";
|
|
16
|
+
readonly SATURATION: "saturation";
|
|
17
|
+
readonly COLOR: "color";
|
|
18
|
+
readonly LUMINOSITY: "luminosity";
|
|
19
|
+
};
|
|
20
|
+
export type BackgroundBlendMode = BlendModeValue[];
|
|
21
|
+
type BlendModeValue = (typeof MIX_BLEND_MODE)[keyof typeof MIX_BLEND_MODE];
|
|
22
|
+
export declare const backgroundBlendMode: IPropertyListDescriptor<BackgroundBlendMode>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IPropertyListDescriptor } from '../property-descriptor';
|
|
2
|
+
export declare enum BORDER_IMAGE_REPEAT {
|
|
3
|
+
STRETCH = 0,
|
|
4
|
+
REPEAT = 1,
|
|
5
|
+
ROUND = 2,
|
|
6
|
+
SPACE = 3
|
|
7
|
+
}
|
|
8
|
+
export interface BorderImageRepeat {
|
|
9
|
+
horizontal: BORDER_IMAGE_REPEAT;
|
|
10
|
+
vertical: BORDER_IMAGE_REPEAT;
|
|
11
|
+
}
|
|
12
|
+
export declare const borderImageRepeat: IPropertyListDescriptor<BorderImageRepeat>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IPropertyListDescriptor } from '../property-descriptor';
|
|
2
|
+
export interface BorderImageSlice {
|
|
3
|
+
top: number;
|
|
4
|
+
right: number;
|
|
5
|
+
bottom: number;
|
|
6
|
+
left: number;
|
|
7
|
+
fill: boolean;
|
|
8
|
+
unit: 'number' | 'percent';
|
|
9
|
+
}
|
|
10
|
+
export declare const borderImageSlice: IPropertyListDescriptor<BorderImageSlice>;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { IPropertyListDescriptor } from '../property-descriptor';
|
|
2
|
+
import { CSSValue } from '../syntax/parser';
|
|
2
3
|
export interface COUNTER_INCREMENT {
|
|
3
4
|
counter: string;
|
|
4
5
|
increment: number;
|
|
5
6
|
}
|
|
6
7
|
export type CounterIncrement = COUNTER_INCREMENT[] | null;
|
|
8
|
+
/** Shared counter-ID parsing: returns next number or a fallback default. */
|
|
9
|
+
export declare const parseCounterValue: (tokens: CSSValue[], defaultNumber: number) => [string, number][];
|
|
7
10
|
export declare const counterIncrement: IPropertyListDescriptor<CounterIncrement>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IPropertyIdentValueDescriptor } from '../property-descriptor';
|
|
2
|
+
export declare const enum FONT_VARIANT_LIGATURES {
|
|
3
|
+
NORMAL = 0,
|
|
4
|
+
NONE = 1,
|
|
5
|
+
COMMON_LIGATURES = 2,
|
|
6
|
+
NO_COMMON_LIGATURES = 3,
|
|
7
|
+
DISCRETIONARY_LIGATURES = 4,
|
|
8
|
+
NO_DISCRETIONARY_LIGATURES = 5,
|
|
9
|
+
HISTORICAL_LIGATURES = 6,
|
|
10
|
+
NO_HISTORICAL_LIGATURES = 7,
|
|
11
|
+
CONTEXTUAL = 8,
|
|
12
|
+
NO_CONTEXTUAL = 9
|
|
13
|
+
}
|
|
14
|
+
export declare const fontVariantLigatures: IPropertyIdentValueDescriptor<FONT_VARIANT_LIGATURES>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IPropertyListDescriptor } from '../property-descriptor';
|
|
2
|
+
import { LengthPercentage } from '../types/length-percentage';
|
|
3
|
+
export type ObjectPosition = [LengthPercentage, LengthPercentage];
|
|
4
|
+
export declare const objectPosition: IPropertyListDescriptor<ObjectPosition>;
|
|
@@ -5,10 +5,12 @@ import { LengthPercentage } from './length-percentage';
|
|
|
5
5
|
export declare const enum CSSImageType {
|
|
6
6
|
URL = 0,
|
|
7
7
|
LINEAR_GRADIENT = 1,
|
|
8
|
-
RADIAL_GRADIENT = 2
|
|
8
|
+
RADIAL_GRADIENT = 2,
|
|
9
|
+
REPEATING_LINEAR_GRADIENT = 3
|
|
9
10
|
}
|
|
10
11
|
export declare const isLinearGradient: (background: ICSSImage) => background is CSSLinearGradientImage;
|
|
11
12
|
export declare const isRadialGradient: (background: ICSSImage) => background is CSSRadialGradientImage;
|
|
13
|
+
export declare const isRepeatingLinearGradient: (background: ICSSImage) => background is CSSLinearGradientImage;
|
|
12
14
|
export interface UnprocessedGradientColorStop {
|
|
13
15
|
color: Color;
|
|
14
16
|
stop: LengthPercentage | null;
|
|
@@ -30,7 +32,7 @@ interface ICSSGradientImage extends ICSSImage {
|
|
|
30
32
|
}
|
|
31
33
|
export interface CSSLinearGradientImage extends ICSSGradientImage {
|
|
32
34
|
angle: number | GradientCorner;
|
|
33
|
-
type: CSSImageType.LINEAR_GRADIENT;
|
|
35
|
+
type: CSSImageType.LINEAR_GRADIENT | CSSImageType.REPEATING_LINEAR_GRADIENT;
|
|
34
36
|
}
|
|
35
37
|
export declare const enum CSSRadialShape {
|
|
36
38
|
CIRCLE = 0,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe arithmetic expression evaluator — replaces `new Function()`.
|
|
3
|
+
*
|
|
4
|
+
* Supports only: numbers, +, -, *, /, parentheses.
|
|
5
|
+
* Does NOT execute arbitrary code. Returns NaN on any illegal token.
|
|
6
|
+
*/
|
|
7
|
+
declare const safeEvalArithmetic: (expr: string) => number;
|
|
8
|
+
export default safeEvalArithmetic;
|
|
@@ -25,6 +25,7 @@ export declare class DocumentCloner {
|
|
|
25
25
|
clonedReferenceElement?: HTMLElement;
|
|
26
26
|
private readonly documentElement;
|
|
27
27
|
private readonly counters;
|
|
28
|
+
private readonly slotCloner;
|
|
28
29
|
private quoteDepth;
|
|
29
30
|
constructor(context: Context, element: HTMLElement, options: CloneConfigurations);
|
|
30
31
|
toIFrame(ownerDocument: Document, windowSize: Bounds): Promise<HTMLIFrameElement>;
|
|
@@ -35,50 +36,8 @@ export declare class DocumentCloner {
|
|
|
35
36
|
createVideoClone(video: HTMLVideoElement): HTMLCanvasElement;
|
|
36
37
|
appendChildNode(clone: HTMLElement | SVGElement, child: Node, copyStyles: boolean): void;
|
|
37
38
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
private shouldCloneChild;
|
|
42
|
-
/**
|
|
43
|
-
* Check if a style element should be cloned based on copyStyles option
|
|
44
|
-
*/
|
|
45
|
-
private shouldCloneStyleElement;
|
|
46
|
-
/**
|
|
47
|
-
* Safely append a cloned child to a target, applying all filtering rules
|
|
48
|
-
*/
|
|
49
|
-
private safeAppendClonedChild;
|
|
50
|
-
/**
|
|
51
|
-
* Clone assigned nodes from a slot element to the target
|
|
52
|
-
*/
|
|
53
|
-
private cloneAssignedNodes;
|
|
54
|
-
/**
|
|
55
|
-
* Clone fallback content from a slot element when no nodes are assigned
|
|
56
|
-
*/
|
|
57
|
-
private cloneSlotFallbackContent;
|
|
58
|
-
/**
|
|
59
|
-
* Handle cloning of a slot element, including assigned nodes or fallback content
|
|
60
|
-
*/
|
|
61
|
-
private cloneSlotElement;
|
|
62
|
-
/**
|
|
63
|
-
* Clone shadow DOM children to the target shadow root
|
|
64
|
-
*/
|
|
65
|
-
private cloneShadowDOMChildren;
|
|
66
|
-
/**
|
|
67
|
-
* Clone light DOM children to the target element
|
|
68
|
-
*/
|
|
69
|
-
private cloneLightDOMChildren;
|
|
70
|
-
/**
|
|
71
|
-
* Clone slot element as light DOM when shadow root creation failed
|
|
72
|
-
*/
|
|
73
|
-
private cloneSlotElementAsLightDOM;
|
|
74
|
-
/**
|
|
75
|
-
* Clone shadow DOM content as light DOM when shadow root creation failed
|
|
76
|
-
* This is a fallback mechanism to ensure content is not lost
|
|
77
|
-
*/
|
|
78
|
-
private cloneShadowDOMAsLightDOM;
|
|
79
|
-
/**
|
|
80
|
-
* Clone child nodes from source element to clone element
|
|
81
|
-
* Handles shadow DOM, slots, and light DOM appropriately
|
|
39
|
+
* Clone child nodes from source element to clone element.
|
|
40
|
+
* Delegates to SlotCloner which handles shadow DOM, slots, and light DOM.
|
|
82
41
|
*/
|
|
83
42
|
cloneChildNodes(node: Element, clone: HTMLElement | SVGElement, copyStyles: boolean): void;
|
|
84
43
|
cloneNode(node: Node, copyStyles: boolean): Node;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Context } from '../core/context';
|
|
2
|
+
/** Options subset needed by SlotCloner */
|
|
3
|
+
export interface SlotClonerOptions {
|
|
4
|
+
ignoreElements?: (element: Element) => boolean;
|
|
5
|
+
copyStyles: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** Exported for reuse in document-cloner.ts */
|
|
8
|
+
export declare const IGNORE_ATTRIBUTE = "data-html2canvas-ignore";
|
|
9
|
+
/**
|
|
10
|
+
* Handles shadow DOM child cloning, slot assignment, and light DOM traversal.
|
|
11
|
+
* Extracted from DocumentCloner to reduce file size and improve separation of concerns.
|
|
12
|
+
*/
|
|
13
|
+
export declare class SlotCloner {
|
|
14
|
+
private readonly cloneNodeFn;
|
|
15
|
+
private readonly options;
|
|
16
|
+
private readonly context;
|
|
17
|
+
constructor(cloneNodeFn: (node: Node, copyStyles: boolean) => Node, options: SlotClonerOptions, context: Context);
|
|
18
|
+
appendChildNode(clone: HTMLElement | SVGElement, child: Node, copyStyles: boolean): void;
|
|
19
|
+
/**
|
|
20
|
+
* Clone child nodes from source element to clone element.
|
|
21
|
+
* Handles shadow DOM, slots, and light DOM appropriately.
|
|
22
|
+
*/
|
|
23
|
+
cloneChildNodes(node: Element, clone: HTMLElement | SVGElement, copyStyles: boolean): void;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a child node should be cloned based on filtering rules.
|
|
26
|
+
* Filters out: scripts, ignored elements, and optionally styles.
|
|
27
|
+
*/
|
|
28
|
+
private shouldCloneChild;
|
|
29
|
+
/**
|
|
30
|
+
* Check if a style element should be cloned based on copyStyles option.
|
|
31
|
+
*/
|
|
32
|
+
private shouldCloneStyleElement;
|
|
33
|
+
/**
|
|
34
|
+
* Safely append a cloned child to a target, applying all filtering rules.
|
|
35
|
+
*/
|
|
36
|
+
private safeAppendClonedChild;
|
|
37
|
+
/**
|
|
38
|
+
* Clone assigned nodes from a slot element to the target.
|
|
39
|
+
*/
|
|
40
|
+
private cloneAssignedNodes;
|
|
41
|
+
/**
|
|
42
|
+
* Clone fallback content from a slot element when no nodes are assigned.
|
|
43
|
+
*/
|
|
44
|
+
private cloneSlotFallbackContent;
|
|
45
|
+
/**
|
|
46
|
+
* Handle cloning of a slot element, including assigned nodes or fallback content.
|
|
47
|
+
*/
|
|
48
|
+
private cloneSlotElement;
|
|
49
|
+
/**
|
|
50
|
+
* Clone shadow DOM children to the target shadow root.
|
|
51
|
+
*/
|
|
52
|
+
private cloneShadowDOMChildren;
|
|
53
|
+
/**
|
|
54
|
+
* Clone light DOM children to the target element.
|
|
55
|
+
*/
|
|
56
|
+
private cloneLightDOMChildren;
|
|
57
|
+
/**
|
|
58
|
+
* Clone slot element as light DOM when shadow root creation failed.
|
|
59
|
+
*/
|
|
60
|
+
private cloneSlotElementAsLightDOM;
|
|
61
|
+
/**
|
|
62
|
+
* Clone shadow DOM content as light DOM when shadow root creation failed.
|
|
63
|
+
* This is a fallback mechanism to ensure content is not lost.
|
|
64
|
+
*/
|
|
65
|
+
private cloneShadowDOMAsLightDOM;
|
|
66
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Html2CanvasConfig, ConfigOptions } from './config';
|
|
2
|
-
import { createDefaultValidator, Validator, ValidationResult } from './core/validator';
|
|
1
|
+
import { Html2CanvasConfig, type ConfigOptions } from './config';
|
|
2
|
+
import { createDefaultValidator, Validator, type ValidationResult } from './core/validator';
|
|
3
3
|
import { PerformanceMonitor } from './core/performance-monitor';
|
|
4
4
|
import type { Options } from './options';
|
|
5
5
|
export type { Options };
|
|
@@ -31,10 +31,6 @@ export type { Options };
|
|
|
31
31
|
* @throws {Error} If the element is not attached to a document.
|
|
32
32
|
* @throws {DOMException} If an {@link Options.signal|AbortSignal} was provided and the operation was aborted.
|
|
33
33
|
*/
|
|
34
|
-
declare const html2canvas:
|
|
35
|
-
(element: HTMLElement, options?: Partial<Options>, config?: Html2CanvasConfig): Promise<HTMLCanvasElement>;
|
|
36
|
-
setCspNonce: (nonce: string) => void;
|
|
37
|
-
};
|
|
34
|
+
declare const html2canvas: (element: HTMLElement, options?: Partial<Options>, config?: Html2CanvasConfig) => Promise<HTMLCanvasElement>;
|
|
38
35
|
export default html2canvas;
|
|
39
36
|
export { html2canvas, Html2CanvasConfig, ConfigOptions, Validator, ValidationResult, createDefaultValidator, PerformanceMonitor };
|
|
40
|
-
export { IMAGE_RENDERING } from './css/property-descriptors/image-rendering';
|
package/dist/types/options.d.ts
CHANGED
|
@@ -48,4 +48,15 @@ export type Options = CloneOptions & WindowOptions & RenderOptions & ContextOpti
|
|
|
48
48
|
* @default browser default (usually 'low' or 'medium')
|
|
49
49
|
*/
|
|
50
50
|
imageSmoothingQuality?: 'low' | 'medium' | 'high';
|
|
51
|
+
/**
|
|
52
|
+
* Called when a resource fails to load (image, font, iframe, etc.).
|
|
53
|
+
* The render continues — this is a notification hook, not an abort.
|
|
54
|
+
*/
|
|
55
|
+
onError?: (error: Error) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Called at key milestones during the render pipeline.
|
|
58
|
+
* `phase` is one of: 'clone', 'parse', 'layout', 'render'.
|
|
59
|
+
* `progress` is 0..100 percentage estimate.
|
|
60
|
+
*/
|
|
61
|
+
onProgress?: (phase: string, progress: number) => void;
|
|
51
62
|
};
|
|
@@ -33,6 +33,17 @@ export declare class BackgroundRenderer {
|
|
|
33
33
|
private readonly ctx;
|
|
34
34
|
private readonly context;
|
|
35
35
|
private readonly canvas;
|
|
36
|
+
/**
|
|
37
|
+
* Instance-level LRU cache for background-image patterns.
|
|
38
|
+
* CanvasPatterns are tied to the rendering context and must not be
|
|
39
|
+
* shared across different render passes. This cache lives for the
|
|
40
|
+
* duration of one html2canvas() call.
|
|
41
|
+
*
|
|
42
|
+
* Also reused for linear-gradient and repeating-linear-gradient
|
|
43
|
+
* pattern canvases to avoid redundant offscreen canvas allocation.
|
|
44
|
+
*/
|
|
45
|
+
private readonly patternCache;
|
|
46
|
+
private static readonly PATTERN_CACHE_MAX;
|
|
36
47
|
constructor(deps: BackgroundRendererDependencies);
|
|
37
48
|
/**
|
|
38
49
|
* Render background images for a container
|
|
@@ -45,6 +56,12 @@ export declare class BackgroundRenderer {
|
|
|
45
56
|
* Render a URL-based background image
|
|
46
57
|
*/
|
|
47
58
|
private renderBackgroundURLImage;
|
|
59
|
+
/**
|
|
60
|
+
* Render a repeating linear gradient background.
|
|
61
|
+
* Renders one cycle of the gradient to a pattern canvas, then fills
|
|
62
|
+
* the background area using createPattern('repeat').
|
|
63
|
+
*/
|
|
64
|
+
private renderRepeatingLinearGradient;
|
|
48
65
|
/**
|
|
49
66
|
* Render a linear gradient background
|
|
50
67
|
*/
|
|
@@ -78,4 +95,10 @@ export declare class BackgroundRenderer {
|
|
|
78
95
|
* @param paths - Array of path points
|
|
79
96
|
*/
|
|
80
97
|
private path;
|
|
98
|
+
/**
|
|
99
|
+
* LRU-aware get: returns value and promotes the entry to end of Map.
|
|
100
|
+
*/
|
|
101
|
+
private lruGet;
|
|
102
|
+
/** LRU-aware set for CanvasPattern caches. Evicts oldest entry on overflow. */
|
|
103
|
+
private lruSet;
|
|
81
104
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Border Image Renderer
|
|
3
|
+
*
|
|
4
|
+
* Renders CSS border-image using 9-slice scaling.
|
|
5
|
+
* The source image is divided into 9 regions (4 corners, 4 edges, 1 center)
|
|
6
|
+
* based on border-image-slice values, then each region is drawn to the
|
|
7
|
+
* corresponding area of the element's border box.
|
|
8
|
+
*/
|
|
9
|
+
import { BorderImageSlice } from '../../css/property-descriptors/border-image-slice';
|
|
10
|
+
import { BorderImageRepeat } from '../../css/property-descriptors/border-image-repeat';
|
|
11
|
+
import { Bounds } from '../../css/layout/bounds';
|
|
12
|
+
export declare class BorderImageRenderer {
|
|
13
|
+
private readonly ctx;
|
|
14
|
+
constructor(ctx: CanvasRenderingContext2D);
|
|
15
|
+
renderBorderImage(bounds: Bounds, image: HTMLImageElement, slice: BorderImageSlice, repeat: BorderImageRepeat, borderTopWidth: number, borderRightWidth: number, borderBottomWidth: number, borderLeftWidth: number): void;
|
|
16
|
+
private drawRegion;
|
|
17
|
+
private drawRepeatedEdge;
|
|
18
|
+
}
|
|
@@ -40,6 +40,7 @@ export declare class CanvasRenderer {
|
|
|
40
40
|
private readonly fontMetrics;
|
|
41
41
|
private readonly backgroundRenderer;
|
|
42
42
|
private readonly borderRenderer;
|
|
43
|
+
private readonly borderImageRenderer;
|
|
43
44
|
private readonly effectsRenderer;
|
|
44
45
|
private readonly textRenderer;
|
|
45
46
|
constructor(context: Context, options: RenderConfigurations);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ElementPaint } from '../stacking-context';
|
|
2
|
+
import { ReplacedElementContainer } from '../../dom/replaced-elements';
|
|
3
|
+
import { ElementContainer } from '../../dom/element-container';
|
|
4
|
+
import { BoundCurves } from '../bound-curves';
|
|
5
|
+
import { Vector } from '../vector';
|
|
6
|
+
import { Context } from '../../core/context';
|
|
7
|
+
import { TextRenderer } from './text-renderer';
|
|
8
|
+
import { FontMetrics } from '../font-metrics';
|
|
9
|
+
import { Color } from '../../css/types/color';
|
|
10
|
+
import { CSSParsedDeclaration } from '../../css/index';
|
|
11
|
+
/**
|
|
12
|
+
* Factory type for creating an iframe canvas renderer — avoids circular import
|
|
13
|
+
* from canvas-renderer.ts which in turn imports content-renderer.ts.
|
|
14
|
+
*/
|
|
15
|
+
type IframeRendererFactory = (context: Context, options: {
|
|
16
|
+
scale: number;
|
|
17
|
+
backgroundColor: Color | null;
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
}) => {
|
|
23
|
+
render: (element: ElementContainer) => Promise<HTMLCanvasElement>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Render replaced elements: Image, Canvas, SVG, IFrame.
|
|
27
|
+
*/
|
|
28
|
+
export declare function renderReplacedElements(ctx: CanvasRenderingContext2D, context: Context, options: {
|
|
29
|
+
scale: number;
|
|
30
|
+
backgroundColor: Color | null;
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
}, iframeRendererFactory: IframeRendererFactory, container: ElementContainer, curves: BoundCurves, styles: CSSParsedDeclaration, renderReplacedElementFn: (container: ReplacedElementContainer, curves: BoundCurves, image: HTMLImageElement | HTMLCanvasElement) => void): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Render form element content: checkbox, radio, text input.
|
|
38
|
+
*/
|
|
39
|
+
export declare function renderFormElements(ctx: CanvasRenderingContext2D, fontMetrics: FontMetrics, textRenderer: TextRenderer, pathFn: (paths: Vector[]) => void, container: ElementContainer, styles: CSSParsedDeclaration): void;
|
|
40
|
+
/**
|
|
41
|
+
* Render list-item marker (image or text).
|
|
42
|
+
*/
|
|
43
|
+
export declare function renderListMarker(ctx: CanvasRenderingContext2D, context: Context, textRenderer: TextRenderer, paint: ElementPaint, container: ElementContainer, styles: CSSParsedDeclaration): Promise<void>;
|
|
44
|
+
export {};
|