html2canvas-pro 2.4.5 → 2.5.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 +117 -13
- package/dist/html2canvas-pro.cjs +3425 -1677
- package/dist/html2canvas-pro.cjs.map +1 -1
- package/dist/html2canvas-pro.esm.js +3425 -1677
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +3479 -1731
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +5 -5
- package/dist/types/core/cache-storage.d.ts +22 -1
- package/dist/types/core/context.d.ts +10 -1
- package/dist/types/core/logger.d.ts +0 -3
- package/dist/types/core/render-element.d.ts +11 -0
- package/dist/types/core/util.d.ts +6 -0
- package/dist/types/css/index.d.ts +77 -46
- package/dist/types/css/parse.d.ts +15 -0
- package/dist/types/css/property-descriptors/accent-color.d.ts +5 -0
- package/dist/types/css/property-descriptors/backdrop-filter.d.ts +9 -0
- package/dist/types/css/property-descriptors/background-blend-mode.d.ts +16 -16
- package/dist/types/css/property-descriptors/border-image-width.d.ts +36 -0
- package/dist/types/css/property-descriptors/clip-path.d.ts +16 -2
- package/dist/types/css/property-descriptors/isolation.d.ts +6 -0
- package/dist/types/css/property-descriptors/mask.d.ts +25 -0
- package/dist/types/css/property-descriptors/mix-blend-mode.d.ts +16 -16
- package/dist/types/css/property-descriptors/outline.d.ts +15 -0
- package/dist/types/css/property-descriptors/text-emphasis.d.ts +22 -0
- package/dist/types/css/property-descriptors/text-shadow.d.ts +1 -1
- package/dist/types/css/property-descriptors/webkit-box-reflect.d.ts +19 -0
- package/dist/types/css/property-descriptors/webkit-text-fill-color.d.ts +9 -0
- package/dist/types/css/syntax/token-constants.d.ts +1 -1
- package/dist/types/css/types/color-math.d.ts +7 -1
- package/dist/types/css/types/color-spaces/a98.d.ts +2 -1
- package/dist/types/css/types/color-spaces/p3.d.ts +5 -4
- package/dist/types/css/types/color-spaces/pro-photo.d.ts +5 -4
- package/dist/types/css/types/color-spaces/rec2020.d.ts +5 -4
- package/dist/types/css/types/color-spaces/srgb.d.ts +5 -4
- package/dist/types/css/types/color-utilities.d.ts +11 -11
- package/dist/types/css/types/color.d.ts +1 -0
- package/dist/types/css/types/functions/conic-gradient.d.ts +17 -0
- package/dist/types/css/types/functions/image-set.d.ts +11 -0
- package/dist/types/css/types/functions/repeating-radial-gradient.d.ts +8 -0
- package/dist/types/css/types/image.d.ts +17 -2
- package/dist/types/css/types/safe-eval.d.ts +0 -6
- package/dist/types/dom/copy-css-styles.d.ts +8 -0
- package/dist/types/dom/document-cloner.d.ts +3 -13
- package/dist/types/dom/iframe-mount.d.ts +37 -0
- package/dist/types/dom/pseudo-content.d.ts +33 -0
- package/dist/types/dom/replaced-elements/iframe-element-container.d.ts +2 -2
- package/dist/types/dom/replaced-elements/input-element-container.d.ts +1 -1
- package/dist/types/options.d.ts +8 -2
- package/dist/types/render/canvas/background-renderer.d.ts +28 -0
- package/dist/types/render/canvas/border-image-renderer.d.ts +50 -1
- package/dist/types/render/canvas/canvas-renderer.d.ts +29 -15
- package/dist/types/render/canvas/effects-renderer.d.ts +8 -0
- package/dist/types/render/canvas/mask-renderer.d.ts +36 -0
- package/dist/types/render/canvas/text-clip-renderer.d.ts +56 -0
- package/dist/types/render/canvas/text-renderer.d.ts +22 -0
- package/dist/types/render/stacking-context.d.ts +4 -1
- package/package.json +41 -42
- package/dist/lib/config.js +0 -49
- package/dist/lib/core/abort-helper.js +0 -20
- package/dist/lib/core/background-parser.js +0 -41
- package/dist/lib/core/bitwise.js +0 -5
- package/dist/lib/core/cache-storage.js +0 -283
- package/dist/lib/core/config-assembler.js +0 -88
- package/dist/lib/core/constants.js +0 -25
- package/dist/lib/core/context.js +0 -19
- package/dist/lib/core/debugger.js +0 -27
- package/dist/lib/core/features.js +0 -190
- package/dist/lib/core/logger.js +0 -56
- package/dist/lib/core/lru-map.js +0 -66
- package/dist/lib/core/origin-checker.js +0 -53
- package/dist/lib/core/performance-monitor.js +0 -185
- package/dist/lib/core/render-element.js +0 -131
- package/dist/lib/core/util.js +0 -4
- package/dist/lib/core/validator.js +0 -500
- package/dist/lib/css/grouped/background-styles.js +0 -36
- package/dist/lib/css/grouped/border-styles.js +0 -75
- package/dist/lib/css/grouped/font-styles.js +0 -93
- package/dist/lib/css/grouped/layout-styles.js +0 -127
- package/dist/lib/css/index.js +0 -339
- package/dist/lib/css/layout/bounds.js +0 -52
- package/dist/lib/css/layout/text.js +0 -133
- package/dist/lib/css/property-descriptor.js +0 -2
- package/dist/lib/css/property-descriptors/background-blend-mode.js +0 -41
- package/dist/lib/css/property-descriptors/background-clip.js +0 -25
- package/dist/lib/css/property-descriptors/background-color.js +0 -10
- package/dist/lib/css/property-descriptors/background-image.js +0 -24
- package/dist/lib/css/property-descriptors/background-origin.js +0 -23
- package/dist/lib/css/property-descriptors/background-position.js +0 -19
- package/dist/lib/css/property-descriptors/background-repeat.js +0 -33
- package/dist/lib/css/property-descriptors/background-size.js +0 -23
- package/dist/lib/css/property-descriptors/border-color.js +0 -14
- package/dist/lib/css/property-descriptors/border-image-repeat.js +0 -42
- package/dist/lib/css/property-descriptors/border-image-slice.js +0 -45
- package/dist/lib/css/property-descriptors/border-image-source.js +0 -22
- package/dist/lib/css/property-descriptors/border-radius.js +0 -15
- package/dist/lib/css/property-descriptors/border-style.js +0 -26
- package/dist/lib/css/property-descriptors/border-width.js +0 -20
- package/dist/lib/css/property-descriptors/box-decoration-break.js +0 -18
- package/dist/lib/css/property-descriptors/box-shadow.js +0 -54
- package/dist/lib/css/property-descriptors/clip-path.js +0 -189
- package/dist/lib/css/property-descriptors/color.js +0 -10
- package/dist/lib/css/property-descriptors/content.js +0 -19
- package/dist/lib/css/property-descriptors/counter-increment.js +0 -35
- package/dist/lib/css/property-descriptors/counter-reset.js +0 -18
- package/dist/lib/css/property-descriptors/direction.js +0 -18
- package/dist/lib/css/property-descriptors/display.js +0 -81
- package/dist/lib/css/property-descriptors/duration.js +0 -14
- package/dist/lib/css/property-descriptors/filter.js +0 -86
- package/dist/lib/css/property-descriptors/float.js +0 -22
- package/dist/lib/css/property-descriptors/font-family.js +0 -47
- package/dist/lib/css/property-descriptors/font-size.js +0 -10
- package/dist/lib/css/property-descriptors/font-style.js +0 -20
- package/dist/lib/css/property-descriptors/font-variant-ligatures.js +0 -34
- package/dist/lib/css/property-descriptors/font-variant.js +0 -13
- package/dist/lib/css/property-descriptors/font-weight.js +0 -25
- package/dist/lib/css/property-descriptors/image-rendering.js +0 -33
- package/dist/lib/css/property-descriptors/letter-spacing.js +0 -21
- package/dist/lib/css/property-descriptors/line-break.js +0 -23
- package/dist/lib/css/property-descriptors/line-height.js +0 -24
- package/dist/lib/css/property-descriptors/list-style-image.js +0 -17
- package/dist/lib/css/property-descriptors/list-style-position.js +0 -18
- package/dist/lib/css/property-descriptors/list-style-type.js +0 -122
- package/dist/lib/css/property-descriptors/margin.js +0 -13
- package/dist/lib/css/property-descriptors/mix-blend-mode.js +0 -31
- package/dist/lib/css/property-descriptors/object-fit.js +0 -28
- package/dist/lib/css/property-descriptors/object-position.js +0 -42
- package/dist/lib/css/property-descriptors/opacity.js +0 -16
- package/dist/lib/css/property-descriptors/overflow-wrap.js +0 -18
- package/dist/lib/css/property-descriptors/overflow.js +0 -27
- package/dist/lib/css/property-descriptors/padding.js +0 -14
- package/dist/lib/css/property-descriptors/paint-order.js +0 -33
- package/dist/lib/css/property-descriptors/position.js +0 -22
- package/dist/lib/css/property-descriptors/quotes.js +0 -41
- package/dist/lib/css/property-descriptors/rotate.js +0 -27
- package/dist/lib/css/property-descriptors/text-align.js +0 -21
- package/dist/lib/css/property-descriptors/text-decoration-color.js +0 -10
- package/dist/lib/css/property-descriptors/text-decoration-line.js +0 -28
- package/dist/lib/css/property-descriptors/text-decoration-style.js +0 -24
- package/dist/lib/css/property-descriptors/text-decoration-thickness.js +0 -26
- package/dist/lib/css/property-descriptors/text-overflow.js +0 -18
- package/dist/lib/css/property-descriptors/text-shadow.js +0 -46
- package/dist/lib/css/property-descriptors/text-transform.js +0 -20
- package/dist/lib/css/property-descriptors/text-underline-offset.js +0 -23
- package/dist/lib/css/property-descriptors/transform-origin.js +0 -24
- package/dist/lib/css/property-descriptors/transform.js +0 -57
- package/dist/lib/css/property-descriptors/visibility.js +0 -20
- package/dist/lib/css/property-descriptors/webkit-line-clamp.js +0 -26
- package/dist/lib/css/property-descriptors/webkit-text-stroke-color.js +0 -10
- package/dist/lib/css/property-descriptors/webkit-text-stroke-width.js +0 -16
- package/dist/lib/css/property-descriptors/white-space.js +0 -32
- package/dist/lib/css/property-descriptors/word-break.js +0 -26
- package/dist/lib/css/property-descriptors/writing-mode.js +0 -28
- package/dist/lib/css/property-descriptors/z-index.js +0 -19
- package/dist/lib/css/property-descriptors/zoom.js +0 -18
- package/dist/lib/css/syntax/parser.js +0 -141
- package/dist/lib/css/syntax/token-constants.js +0 -214
- package/dist/lib/css/syntax/token-singletons.js +0 -36
- package/dist/lib/css/syntax/token-types.js +0 -10
- package/dist/lib/css/syntax/tokenizer.js +0 -502
- package/dist/lib/css/type-descriptor.js +0 -2
- package/dist/lib/css/types/angle.js +0 -80
- package/dist/lib/css/types/color-math.js +0 -25
- package/dist/lib/css/types/color-spaces/a98.js +0 -78
- package/dist/lib/css/types/color-spaces/p3.js +0 -86
- package/dist/lib/css/types/color-spaces/pro-photo.js +0 -83
- package/dist/lib/css/types/color-spaces/rec2020.js +0 -85
- package/dist/lib/css/types/color-spaces/srgb.js +0 -79
- package/dist/lib/css/types/color-utilities.js +0 -342
- package/dist/lib/css/types/color.js +0 -400
- package/dist/lib/css/types/functions/-prefix-linear-gradient.js +0 -32
- package/dist/lib/css/types/functions/-prefix-radial-gradient.js +0 -83
- package/dist/lib/css/types/functions/-webkit-gradient.js +0 -59
- package/dist/lib/css/types/functions/counter.js +0 -367
- package/dist/lib/css/types/functions/gradient.js +0 -163
- package/dist/lib/css/types/functions/linear-gradient.js +0 -27
- package/dist/lib/css/types/functions/radial-gradient.js +0 -90
- package/dist/lib/css/types/functions/repeating-linear-gradient.js +0 -9
- package/dist/lib/css/types/image.js +0 -62
- package/dist/lib/css/types/index.js +0 -2
- package/dist/lib/css/types/length-percentage.js +0 -197
- package/dist/lib/css/types/length.js +0 -5
- package/dist/lib/css/types/safe-eval.js +0 -80
- package/dist/lib/css/types/time.js +0 -17
- package/dist/lib/dom/document-cloner.js +0 -618
- package/dist/lib/dom/dom-normalizer.js +0 -115
- package/dist/lib/dom/element-container.js +0 -71
- package/dist/lib/dom/elements/li-element-container.js +0 -11
- package/dist/lib/dom/elements/ol-element-container.js +0 -12
- package/dist/lib/dom/elements/select-element-container.js +0 -12
- package/dist/lib/dom/elements/textarea-element-container.js +0 -11
- package/dist/lib/dom/node-parser.js +0 -125
- package/dist/lib/dom/node-type-guards.js +0 -81
- package/dist/lib/dom/replaced-elements/canvas-element-container.js +0 -13
- package/dist/lib/dom/replaced-elements/iframe-element-container.js +0 -38
- package/dist/lib/dom/replaced-elements/image-element-container.js +0 -14
- package/dist/lib/dom/replaced-elements/index.js +0 -2
- package/dist/lib/dom/replaced-elements/input-element-container.js +0 -89
- package/dist/lib/dom/replaced-elements/svg-element-container.js +0 -57
- package/dist/lib/dom/slot-cloner.js +0 -176
- package/dist/lib/dom/text-container.js +0 -35
- package/dist/lib/index.js +0 -49
- package/dist/lib/options.js +0 -2
- package/dist/lib/render/background.js +0 -188
- package/dist/lib/render/bezier-curve.js +0 -34
- package/dist/lib/render/border.js +0 -104
- package/dist/lib/render/bound-curves.js +0 -188
- package/dist/lib/render/box-sizing.js +0 -20
- package/dist/lib/render/canvas/background-renderer.js +0 -338
- package/dist/lib/render/canvas/border-image-renderer.js +0 -153
- package/dist/lib/render/canvas/border-renderer.js +0 -184
- package/dist/lib/render/canvas/box-shadow-geometry.js +0 -52
- package/dist/lib/render/canvas/box-shadow-painter.js +0 -194
- package/dist/lib/render/canvas/box-shadow-transform.js +0 -42
- package/dist/lib/render/canvas/canvas-path.js +0 -25
- package/dist/lib/render/canvas/canvas-renderer.js +0 -610
- package/dist/lib/render/canvas/content-renderer.js +0 -270
- package/dist/lib/render/canvas/effects-renderer.js +0 -171
- package/dist/lib/render/canvas/filter-surface.js +0 -270
- package/dist/lib/render/canvas/font-utils.js +0 -46
- package/dist/lib/render/canvas/foreignobject-renderer.js +0 -38
- package/dist/lib/render/canvas/surface-bounds.js +0 -64
- package/dist/lib/render/canvas/text/text-decoration-renderer.js +0 -99
- package/dist/lib/render/canvas/text-renderer.js +0 -486
- package/dist/lib/render/effects.js +0 -231
- package/dist/lib/render/font-metrics.js +0 -53
- package/dist/lib/render/object-fit.js +0 -91
- package/dist/lib/render/path.js +0 -26
- package/dist/lib/render/renderer-interface.js +0 -2
- package/dist/lib/render/stacking-context.js +0 -341
- package/dist/lib/render/vector.js +0 -16
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mask Renderer
|
|
3
|
+
*
|
|
4
|
+
* Paints CSS mask-image layers into a mask surface (alpha mask) which the
|
|
5
|
+
* caller composites onto the element surface via `destination-in`.
|
|
6
|
+
*
|
|
7
|
+
* Value grammars are shared with background-image (position/size/repeat), so
|
|
8
|
+
* the layer maths mirrors the background renderer but works in the local
|
|
9
|
+
* coordinate space of the mask positioning area (default: border box) and
|
|
10
|
+
* always fills the whole area — a mask surface is about alpha coverage, not
|
|
11
|
+
* about what is visible underneath.
|
|
12
|
+
*
|
|
13
|
+
* Limitations (v1): repeating gradients render their base cycle; mask-mode is
|
|
14
|
+
* alpha-only; layers composite with source-over (≈ the default `add`).
|
|
15
|
+
*/
|
|
16
|
+
import { ICSSImage } from '../../css/types/image';
|
|
17
|
+
import { LengthPercentage } from '../../css/types/length-percentage';
|
|
18
|
+
import { BACKGROUND_REPEAT } from '../../css/property-descriptors/background-repeat';
|
|
19
|
+
import { BackgroundSizeInfo } from '../../css/property-descriptors/background-size';
|
|
20
|
+
export interface MaskLayerStyles {
|
|
21
|
+
maskPosition: LengthPercentage[][];
|
|
22
|
+
maskRepeat: BACKGROUND_REPEAT[];
|
|
23
|
+
maskSize: BackgroundSizeInfo[][];
|
|
24
|
+
}
|
|
25
|
+
export interface MaskArea {
|
|
26
|
+
left: number;
|
|
27
|
+
top: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
}
|
|
31
|
+
export type MaskImageSource = HTMLImageElement | HTMLCanvasElement;
|
|
32
|
+
/**
|
|
33
|
+
* Paint every mask layer into `ctx` (expected to already be scaled to device
|
|
34
|
+
* pixels and translated so the page origin maps correctly).
|
|
35
|
+
*/
|
|
36
|
+
export declare const paintMaskLayers: (ctx: CanvasRenderingContext2D, layers: ICSSImage[], styles: MaskLayerStyles, area: MaskArea, matchImage: (url: string) => Promise<MaskImageSource | undefined>) => Promise<void>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text Clip Renderer
|
|
3
|
+
*
|
|
4
|
+
* Implements `background-clip: text` — paints the element's background
|
|
5
|
+
* (color + images) to an offscreen canvas and clips it to the text glyph
|
|
6
|
+
* shapes with destination-in compositing, then composites the result back
|
|
7
|
+
* onto the main canvas.
|
|
8
|
+
*
|
|
9
|
+
* Extracted from CanvasRenderer to keep paint orchestration separate from
|
|
10
|
+
* this self-contained compositing algorithm.
|
|
11
|
+
*
|
|
12
|
+
* The offscreen and mask canvases are backed at device-pixel resolution
|
|
13
|
+
* (bounds × scale) with their contexts scaled to CSS pixels, so the
|
|
14
|
+
* composite back onto the main canvas maps 1:1 onto the backing store and
|
|
15
|
+
* stays sharp at devicePixelRatio > 1.
|
|
16
|
+
*
|
|
17
|
+
* Matching browser paint order for clipped text:
|
|
18
|
+
* - text shadows render *beneath* the clipped background (silhouettes in
|
|
19
|
+
* the shadow colour), they are not part of the clip region;
|
|
20
|
+
* - -webkit-text-stroke is part of the clip region (fill ∪ stroke band).
|
|
21
|
+
*/
|
|
22
|
+
import { ElementPaint } from '../stacking-context';
|
|
23
|
+
import { CSSParsedDeclaration } from '../../css';
|
|
24
|
+
import { Context } from '../../core/context';
|
|
25
|
+
export interface TextClipRendererDependencies {
|
|
26
|
+
/** Main canvas context the clipped background is composited onto. */
|
|
27
|
+
ctx: CanvasRenderingContext2D;
|
|
28
|
+
context: Context;
|
|
29
|
+
/** Device-pixel ratio shared with the main renderer. */
|
|
30
|
+
scale: number;
|
|
31
|
+
/** Font builder shared with the text renderer so both use identical fonts. */
|
|
32
|
+
createFontStyle: (styles: CSSParsedDeclaration) => string[];
|
|
33
|
+
}
|
|
34
|
+
export declare class TextClipRenderer {
|
|
35
|
+
private readonly ctx;
|
|
36
|
+
private readonly context;
|
|
37
|
+
private readonly scale;
|
|
38
|
+
private readonly createFontStyle;
|
|
39
|
+
constructor(deps: TextClipRendererDependencies);
|
|
40
|
+
render(paint: ElementPaint): Promise<void>;
|
|
41
|
+
private createLayer;
|
|
42
|
+
private createGlyphLayer;
|
|
43
|
+
/**
|
|
44
|
+
* Draw one text bound onto a glyph layer, splitting into per-glyph draws
|
|
45
|
+
* when letter-spacing is in effect so the layout matches the main text
|
|
46
|
+
* renderer. Vertical writing modes fall back to a single draw call.
|
|
47
|
+
*/
|
|
48
|
+
private drawGlyphs;
|
|
49
|
+
/**
|
|
50
|
+
* Paint the text-shadow silhouettes for every glyph, one canvas per
|
|
51
|
+
* shadow, returned front-to-back (the last shadow sits deepest). Returns
|
|
52
|
+
* null when the element has no text shadows.
|
|
53
|
+
*/
|
|
54
|
+
private renderShadowSilhouettes;
|
|
55
|
+
private getTextStrokeLineJoin;
|
|
56
|
+
}
|
|
@@ -35,6 +35,13 @@ export declare class TextRenderer {
|
|
|
35
35
|
private readonly ctx;
|
|
36
36
|
private readonly options;
|
|
37
37
|
private readonly decorationRenderer;
|
|
38
|
+
/**
|
|
39
|
+
* Baseline ascent per font string. Consecutive text nodes overwhelmingly
|
|
40
|
+
* share a font, and each measureBaseline call issues a canvas measureText,
|
|
41
|
+
* so repeated fonts are memoised (bounded; cleared if the working set
|
|
42
|
+
* exceeds the cap).
|
|
43
|
+
*/
|
|
44
|
+
private readonly baselineCache;
|
|
38
45
|
/**
|
|
39
46
|
* Per-render glyph width cache. Keyed by glyph + font string,
|
|
40
47
|
* avoids redundant `measureText` calls when letter-spacing is non-zero.
|
|
@@ -90,6 +97,13 @@ export declare class TextRenderer {
|
|
|
90
97
|
* Public method used by list rendering
|
|
91
98
|
*/
|
|
92
99
|
createFontStyle(styles: CSSParsedDeclaration): string[];
|
|
100
|
+
/**
|
|
101
|
+
* -webkit-text-fill-color overrides the fill colour while leaving
|
|
102
|
+
* decorations and strokes on `color` (e.g. the classic transparent-fill
|
|
103
|
+
* gradient text). Falls back to `color` when the computed value could not
|
|
104
|
+
* be resolved (currentcolor).
|
|
105
|
+
*/
|
|
106
|
+
private resolveFillColor;
|
|
93
107
|
/**
|
|
94
108
|
* Render text with -webkit-line-clamp truncation.
|
|
95
109
|
* Groups text bounds by their Y position into visual lines, then renders
|
|
@@ -101,5 +115,13 @@ export declare class TextRenderer {
|
|
|
101
115
|
* Returns true if ellipsis was applied (caller should skip normal rendering).
|
|
102
116
|
*/
|
|
103
117
|
private renderEllipsisText;
|
|
118
|
+
private measureBaselineCached;
|
|
104
119
|
renderTextNode(text: TextContainer, styles: CSSParsedDeclaration, containerBounds?: Bounds): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Draw text-emphasis marks over (or under) each grapheme cluster.
|
|
122
|
+
*
|
|
123
|
+
* Vertical writing modes are skipped in the current scope: marks would
|
|
124
|
+
* need to sit beside vertical glyph runs rather than above them.
|
|
125
|
+
*/
|
|
126
|
+
private renderTextEmphasis;
|
|
105
127
|
}
|
|
@@ -20,11 +20,14 @@ export declare class ElementPaint {
|
|
|
20
20
|
readonly effects: IElementEffect[];
|
|
21
21
|
readonly curves: BoundCurves;
|
|
22
22
|
listValue?: string;
|
|
23
|
+
/** Memoised getEffects results for the plain (surfaceRoot-less) render path. */
|
|
24
|
+
private plainEffectsCache;
|
|
23
25
|
constructor(container: ElementContainer, parent: ElementPaint | null);
|
|
24
26
|
getEffects(target: EffectTarget, surfaceRoot?: ElementPaint): IElementEffect[];
|
|
27
|
+
private computeEffects;
|
|
25
28
|
}
|
|
26
29
|
/** @internal – exported for testing only. */
|
|
27
|
-
export declare const hasOverflowClip: (styles: ElementContainer[
|
|
30
|
+
export declare const hasOverflowClip: (styles: ElementContainer['styles']) => boolean;
|
|
28
31
|
/**
|
|
29
32
|
* Resolve a `closest-side` or `farthest-side` shape-radius keyword to pixels
|
|
30
33
|
* for a single axis. Used by both `circle()` (per-axis) and `ellipse()`.
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"default": "./dist/html2canvas-pro.esm.js"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
-
"version": "2.
|
|
22
|
+
"version": "2.5.1",
|
|
23
23
|
"author": {
|
|
24
24
|
"name": "yorickshan",
|
|
25
25
|
"email": "yorickshan@gmail.com",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"screenshot"
|
|
32
32
|
],
|
|
33
33
|
"engines": {
|
|
34
|
-
"node": ">=
|
|
34
|
+
"node": ">=24.0.0"
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://yorickshan.github.io/html2canvas-pro/",
|
|
37
37
|
"repository": {
|
|
@@ -39,66 +39,65 @@
|
|
|
39
39
|
"url": "https://github.com/yorickshan/html2canvas-pro"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@commitlint/cli": "^
|
|
43
|
-
"@commitlint/config-conventional": "^
|
|
42
|
+
"@commitlint/cli": "^21.2.3",
|
|
43
|
+
"@commitlint/config-conventional": "^21.2.3",
|
|
44
44
|
"@types/chai": "^5.2.3",
|
|
45
45
|
"@types/express": "^5.0.6",
|
|
46
|
-
"@types/karma": "^6.3.
|
|
47
|
-
"@types/mocha": "^10.0.
|
|
48
|
-
"@types/node": "^
|
|
49
|
-
"@types/platform": "^1.3.
|
|
46
|
+
"@types/karma": "^6.3.9",
|
|
47
|
+
"@types/mocha": "^10.0.10",
|
|
48
|
+
"@types/node": "^26.6.3",
|
|
49
|
+
"@types/platform": "^1.3.6",
|
|
50
50
|
"@types/pngjs": "^6.0.5",
|
|
51
51
|
"@types/serve-index": "^1.9.4",
|
|
52
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
53
|
-
"@typescript-eslint/parser": "^8.
|
|
54
|
-
"@
|
|
55
|
-
"
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^8.70.1",
|
|
53
|
+
"@typescript-eslint/parser": "^8.70.1",
|
|
54
|
+
"@typescript/native": "npm:typescript@^7.0.2",
|
|
55
|
+
"@vitest/coverage-v8": "^5.0.2",
|
|
56
|
+
"appium-ios-simulator": "^8.2.8",
|
|
56
57
|
"base64-arraybuffer": "1.0.2",
|
|
57
|
-
"body-parser": "^2.
|
|
58
|
+
"body-parser": "^2.3.0",
|
|
58
59
|
"chai": "6.2.2",
|
|
59
60
|
"change-case": "^5.4.4",
|
|
60
|
-
"conventional-changelog": "^
|
|
61
|
-
"conventional-changelog-conventionalcommits": "^
|
|
62
|
-
"cors": "^2.8.
|
|
61
|
+
"conventional-changelog": "^8.1.3",
|
|
62
|
+
"conventional-changelog-conventionalcommits": "^10.4.0",
|
|
63
|
+
"cors": "^2.8.6",
|
|
63
64
|
"cz-conventional-changelog": "^3.3.0",
|
|
64
|
-
"eslint": "^
|
|
65
|
+
"eslint": "^10.11.0",
|
|
65
66
|
"eslint-config-prettier": "^10.1.8",
|
|
66
|
-
"eslint-plugin-prettier": "^5.5.
|
|
67
|
+
"eslint-plugin-prettier": "^5.5.6",
|
|
67
68
|
"express": "^5.2.1",
|
|
68
69
|
"filenamify-url": "4.0.0",
|
|
69
|
-
"glob": "^13.0.
|
|
70
|
-
"html2canvas-pro-baseline": "npm:html2canvas-pro@2.4.3",
|
|
70
|
+
"glob": "^13.0.6",
|
|
71
71
|
"husky": "^9.1.7",
|
|
72
|
-
"jsdom": "^
|
|
73
|
-
"karma": "^6.
|
|
74
|
-
"karma-chrome-launcher": "^3.
|
|
72
|
+
"jsdom": "^30.1.1",
|
|
73
|
+
"karma": "^6.4.4",
|
|
74
|
+
"karma-chrome-launcher": "^3.2.0",
|
|
75
75
|
"karma-edge-launcher": "^0.4.2",
|
|
76
|
-
"karma-firefox-launcher": "^2.1.
|
|
76
|
+
"karma-firefox-launcher": "^2.1.3",
|
|
77
77
|
"karma-ie-launcher": "^1.0.0",
|
|
78
78
|
"karma-junit-reporter": "^2.0.1",
|
|
79
79
|
"karma-mocha": "^2.0.1",
|
|
80
80
|
"karma-safarinative-launcher": "^1.1.0",
|
|
81
|
-
"lint-staged": "^
|
|
82
|
-
"mocha": "^
|
|
83
|
-
"node-simctl": "^8.
|
|
81
|
+
"lint-staged": "^17.6.0",
|
|
82
|
+
"mocha": "^12.0.2",
|
|
83
|
+
"node-simctl": "^8.2.9",
|
|
84
84
|
"pixelmatch": "^7.2.0",
|
|
85
85
|
"platform": "^1.3.6",
|
|
86
|
-
"playwright": "1.
|
|
86
|
+
"playwright": "1.63.0",
|
|
87
87
|
"pngjs": "^7.0.0",
|
|
88
|
-
"prettier": "^3.
|
|
89
|
-
"puppeteer": "^
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"serve-index": "^1.9.1",
|
|
88
|
+
"prettier": "^3.9.9",
|
|
89
|
+
"puppeteer": "^25.12.0",
|
|
90
|
+
"rimraf": "^6.1.3",
|
|
91
|
+
"rolldown": "^1.2.11",
|
|
92
|
+
"serve-index": "^1.9.2",
|
|
94
93
|
"slash": "5.1.0",
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
94
|
+
"tsx": "^4.23.15",
|
|
95
|
+
"typedoc": "^0.28.20",
|
|
96
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
97
|
+
"vite": "^8.3.1",
|
|
99
98
|
"vitepress": "^1.6.4",
|
|
100
|
-
"vitest": "^
|
|
101
|
-
"yargs": "^18.
|
|
99
|
+
"vitest": "^5.0.2",
|
|
100
|
+
"yargs": "^18.2.0"
|
|
102
101
|
},
|
|
103
102
|
"dependencies": {
|
|
104
103
|
"css-line-break": "^2.1.0",
|
|
@@ -112,13 +111,13 @@
|
|
|
112
111
|
},
|
|
113
112
|
"scripts": {
|
|
114
113
|
"prebuild": "rimraf dist/ && rimraf build/ && mkdir -p dist && mkdir -p build",
|
|
115
|
-
"build": "tsc
|
|
114
|
+
"build": "tsc -p tsconfig.build.json && rolldown -c rolldown.config.ts && pnpm build:create-reftest-list && rolldown -c tests/rolldown.testrunner.config.ts && node scripts/bundle-filter-surface.mjs",
|
|
116
115
|
"build:testrunner": "rolldown -c tests/rolldown.testrunner.config.ts",
|
|
117
116
|
"build:reftest-result-list": "tsx scripts/create-reftest-result-list.ts",
|
|
118
117
|
"build:create-reftest-list": "tsx scripts/create-reftest-list.ts tests/reftests/ignore.txt build/reftests.js",
|
|
119
118
|
"release": "sh scripts/version-upgrade.sh",
|
|
120
119
|
"format": "prettier --write \"{src,tests,scripts}/**/*.ts\"",
|
|
121
|
-
"lint": "eslint src/**/*.ts --max-warnings 0",
|
|
120
|
+
"lint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\" \"scripts/**/*.ts\" \"scripts/**/*.mjs\" --max-warnings 0",
|
|
122
121
|
"test": "pnpm lint && pnpm unittest && pnpm karma",
|
|
123
122
|
"unittest": "vitest run",
|
|
124
123
|
"unittest:coverage": "vitest run --coverage",
|
package/dist/lib/config.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Html2CanvasConfig = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Html2Canvas Configuration
|
|
6
|
-
*
|
|
7
|
-
* Manages configuration state for html2canvas rendering.
|
|
8
|
-
* Eliminates the need for global static variables.
|
|
9
|
-
*/
|
|
10
|
-
class Html2CanvasConfig {
|
|
11
|
-
constructor(options = {}) {
|
|
12
|
-
const resolvedWindow = options.window || (typeof window !== 'undefined' ? window : undefined);
|
|
13
|
-
if (!resolvedWindow) {
|
|
14
|
-
throw new Error('Window object is required but not available');
|
|
15
|
-
}
|
|
16
|
-
this.window = resolvedWindow;
|
|
17
|
-
this.cspNonce = options.cspNonce;
|
|
18
|
-
this.cache = options.cache;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Create configuration from an element
|
|
22
|
-
* Extracts window from element's owner document
|
|
23
|
-
*/
|
|
24
|
-
static fromElement(element, options = {}) {
|
|
25
|
-
const ownerDocument = element.ownerDocument;
|
|
26
|
-
if (!ownerDocument) {
|
|
27
|
-
throw new Error('Element is not attached to a document');
|
|
28
|
-
}
|
|
29
|
-
const defaultView = ownerDocument.defaultView;
|
|
30
|
-
if (!defaultView) {
|
|
31
|
-
throw new Error('Document is not attached to a window');
|
|
32
|
-
}
|
|
33
|
-
return new Html2CanvasConfig({
|
|
34
|
-
window: defaultView,
|
|
35
|
-
...options
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Clone configuration with override options
|
|
40
|
-
*/
|
|
41
|
-
clone(options = {}) {
|
|
42
|
-
return new Html2CanvasConfig({
|
|
43
|
-
window: options.window || this.window,
|
|
44
|
-
cspNonce: options.cspNonce ?? this.cspNonce,
|
|
45
|
-
cache: options.cache ?? this.cache
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.Html2CanvasConfig = Html2CanvasConfig;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* AbortSignal helper utilities.
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.throwIfAborted = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Throw a DOMException if the given AbortSignal is already aborted.
|
|
9
|
-
* Used at checkpoints throughout the rendering pipeline to support
|
|
10
|
-
* cancellable renders.
|
|
11
|
-
*
|
|
12
|
-
* @param signal - The AbortSignal to check. If undefined or not aborted, this is a no-op.
|
|
13
|
-
* @throws {DOMException} With name 'AbortError' if the signal has been aborted.
|
|
14
|
-
*/
|
|
15
|
-
const throwIfAborted = (signal) => {
|
|
16
|
-
if (signal?.aborted) {
|
|
17
|
-
throw new DOMException('The operation was aborted.', 'AbortError');
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
exports.throwIfAborted = throwIfAborted;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseBackgroundColor = void 0;
|
|
4
|
-
const color_1 = require("../css/types/color");
|
|
5
|
-
const color_utilities_1 = require("../css/types/color-utilities");
|
|
6
|
-
/**
|
|
7
|
-
* Resolve the background colour for the rendered canvas, following CSS
|
|
8
|
-
* background propagation rules:
|
|
9
|
-
*
|
|
10
|
-
* 1. If the target element is `<html>`, inherit the first opaque ancestor
|
|
11
|
-
* (doc → body → fallback).
|
|
12
|
-
* 2. Otherwise use the user-supplied backgroundColor, or opaque white.
|
|
13
|
-
*
|
|
14
|
-
* @param context - Current rendering context.
|
|
15
|
-
* @param element - The root element being rendered.
|
|
16
|
-
* @param backgroundColorOverride - User-supplied override (string | null).
|
|
17
|
-
* @returns A resolved colour value suitable for filling the canvas.
|
|
18
|
-
*/
|
|
19
|
-
const parseBackgroundColor = (context, element, backgroundColorOverride) => {
|
|
20
|
-
const ownerDocument = element.ownerDocument;
|
|
21
|
-
// http://www.w3.org/TR/css3-background/#special-backgrounds
|
|
22
|
-
const documentBackgroundColor = ownerDocument.documentElement
|
|
23
|
-
? (0, color_1.parseColor)(context, getComputedStyle(ownerDocument.documentElement).backgroundColor)
|
|
24
|
-
: color_1.COLORS.TRANSPARENT;
|
|
25
|
-
const bodyBackgroundColor = ownerDocument.body
|
|
26
|
-
? (0, color_1.parseColor)(context, getComputedStyle(ownerDocument.body).backgroundColor)
|
|
27
|
-
: color_1.COLORS.TRANSPARENT;
|
|
28
|
-
const defaultBackgroundColor = typeof backgroundColorOverride === 'string'
|
|
29
|
-
? (0, color_1.parseColor)(context, backgroundColorOverride)
|
|
30
|
-
: backgroundColorOverride === null
|
|
31
|
-
? color_1.COLORS.TRANSPARENT
|
|
32
|
-
: 0xffffffff;
|
|
33
|
-
return element === ownerDocument.documentElement
|
|
34
|
-
? (0, color_utilities_1.isTransparent)(documentBackgroundColor)
|
|
35
|
-
? (0, color_utilities_1.isTransparent)(bodyBackgroundColor)
|
|
36
|
-
? defaultBackgroundColor
|
|
37
|
-
: bodyBackgroundColor
|
|
38
|
-
: documentBackgroundColor
|
|
39
|
-
: defaultBackgroundColor;
|
|
40
|
-
};
|
|
41
|
-
exports.parseBackgroundColor = parseBackgroundColor;
|