html2canvas-pro 2.2.0 → 2.2.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.
package/README.md CHANGED
@@ -5,32 +5,32 @@
5
5
  html2canvas-pro
6
6
  </h1>
7
7
  <p align="center">
8
- Next generation JavaScript screenshots tool.
9
- <p>
8
+ Next generation JavaScript screenshot tool.
9
+ </p>
10
10
  <p align="center">
11
11
  <a href="https://github.com/yorickshan/html2canvas-pro/actions/workflows/ci.yml"><img src="https://github.com/yorickshan/html2canvas-pro/actions/workflows/ci.yml/badge.svg?branch=main" alt="build status"></a>
12
- <a href=https://npm.im/html2canvas-pro><img src="https://badgen.net/npm/v/html2canvas-pro" alt="npm version"></a>
13
- <a href=http://npm.im/html2canvas-pro><img src="https://badgen.net/npm/dm/html2canvas-pro" alt="npm downloads"></a>
12
+ <a href="https://npm.im/html2canvas-pro"><img src="https://badgen.net/npm/v/html2canvas-pro" alt="npm version"></a>
13
+ <a href="http://npm.im/html2canvas-pro"><img src="https://badgen.net/npm/dm/html2canvas-pro" alt="npm downloads"></a>
14
14
  <a href="https://www.jsdelivr.com/package/npm/html2canvas-pro"><img src="https://data.jsdelivr.com/v1/package/npm/html2canvas-pro/badge" /></a>
15
- <p>
15
+ <a href="https://deepwiki.com/yorickshan/html2canvas-pro"><img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki"></a>
16
+ </p>
16
17
  <p align="center">
17
18
  <a href="https://yorickshan.github.io/html2canvas-pro/getting-started.html">Getting Started</a>
18
- | <a href="https://deepwiki.com/yorickshan/html2canvas-pro">DeepWiki</a>
19
19
  </p>
20
20
  <br>
21
21
 
22
22
  ## Why html2canvas-pro?
23
23
 
24
- html2canvas-pro is a fork of [niklasvh/html2canvas](https://github.com/niklasvh/html2canvas) that includes various fixes and new features. It offers several advantages over the original html2canvas, such as:
25
- - support color function ```color()``` (including relative colors)
26
- - support color function ```lab()``` / ```lch()``` / ```oklab()``` / ```oklch()```
27
- - Support object-fit of ```<img/>```
28
- - Support CSS ```clip-path``` (inset, circle, ellipse, polygon, path)
29
- - Support CSS ```writing-mode``` (horizontal-tb, vertical-rl, vertical-lr)
30
- - **Image smoothing control** - Support CSS `image-rendering` property and `imageSmoothing`/`imageSmoothingQuality` options
31
- - **Security validation** - Built-in input validation (XSS/SSRF protection)
32
- - **Performance monitoring** - Built-in performance measurement API
33
- - Fixed some [issues](./CHANGELOG.md)
24
+ html2canvas-pro is a fork of [niklasvh/html2canvas](https://github.com/niklasvh/html2canvas) that includes various fixes and new features. It offers several advantages over the original html2canvas:
25
+ - Color function `color()` (including relative colors)
26
+ - Color functions `lab()` / `lch()` / `oklab()` / `oklch()`
27
+ - `object-fit` support for `<img/>`
28
+ - CSS `clip-path` support (inset, circle, ellipse, polygon, path)
29
+ - CSS `writing-mode` support (horizontal-tb, vertical-rl, vertical-lr)
30
+ - **Image smoothing control** CSS `image-rendering` property and `imageSmoothing`/`imageSmoothingQuality` options
31
+ - **Security validation** Built-in input validation (XSS/SSRF protection)
32
+ - **Performance monitoring** Built-in performance measurement API
33
+ - Various bug fixes from the [changelog](./CHANGELOG.md)
34
34
 
35
35
  If you found this helpful, don't forget to
36
36
  leave a star 🌟.
@@ -78,10 +78,10 @@ See the [Configuration Guide](/docs/configuration.md#canvas-dimensions) for more
78
78
 
79
79
  ## Contribution
80
80
 
81
- If you want to add some features, feel free to submit PR.
81
+ If you'd like to add a feature, feel free to submit a PR.
82
82
 
83
- If you want to become a maintainer on it, please contact me.
83
+ Interested in becoming a maintainer? Open an [issue](https://github.com/yorickshan/html2canvas-pro/issues) or reach out to [@yorickshan](https://github.com/yorickshan).
84
84
 
85
85
  ## License
86
86
 
87
- [MIT](LICENSE).
87
+ [MIT](LICENSE)
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * html2canvas-pro 2.2.0 <https://yorickshan.github.io/html2canvas-pro/>
2
+ * html2canvas-pro 2.2.2 <https://yorickshan.github.io/html2canvas-pro/>
3
3
  * Copyright (c) 2024-present yorickshan and html2canvas-pro contributors
4
4
  * Released under MIT License
5
5
  */
@@ -6294,11 +6294,13 @@ const parse = (context, descriptor, style) => {
6294
6294
  valueCache = /* @__PURE__ */ new Map();
6295
6295
  parseCache.set(descriptor, valueCache);
6296
6296
  }
6297
- if (valueCache.size >= 200) {
6298
- const oldestKey = valueCache.keys().next().value;
6299
- valueCache.delete(oldestKey);
6297
+ if (!(descriptor.type === 3 && descriptor.format === "image")) {
6298
+ if (valueCache.size >= 200) {
6299
+ const oldestKey = valueCache.keys().next().value;
6300
+ valueCache.delete(oldestKey);
6301
+ }
6302
+ valueCache.set(rawValue, result);
6300
6303
  }
6301
- valueCache.set(rawValue, result);
6302
6304
  return result;
6303
6305
  };
6304
6306
  //#endregion
@@ -8440,9 +8442,18 @@ var BlendEffect = class {
8440
8442
  };
8441
8443
  var FilterEffect = class {
8442
8444
  constructor(filterString) {
8443
- this.filterString = filterString;
8444
8445
  this.type = 5;
8445
8446
  this.target = 6;
8447
+ const dropShadowMatch = filterString.match(/drop-shadow\(\s*([\d.-]+)(px)?\s+([\d.-]+)(px)?\s+([\d.-]+)(px)?\s+(.+?)\s*\)/);
8448
+ if (dropShadowMatch) {
8449
+ this.shadow = {
8450
+ offsetX: parseFloat(dropShadowMatch[1]),
8451
+ offsetY: parseFloat(dropShadowMatch[3]),
8452
+ blur: parseFloat(dropShadowMatch[5]),
8453
+ color: dropShadowMatch[7].trim()
8454
+ };
8455
+ this.safeFilterString = filterString.replace(/drop-shadow\([^)]+\)\s*/g, "").trim();
8456
+ } else this.safeFilterString = filterString;
8446
8457
  }
8447
8458
  };
8448
8459
  const isTransformEffect = (effect) => effect.type === 0;
@@ -9897,7 +9908,15 @@ var EffectsRenderer = class {
9897
9908
  this.ctx.clip();
9898
9909
  } else if (isClipPathEffect(effect)) effect.applyClip(this.ctx);
9899
9910
  else if (isBlendEffect(effect)) this.ctx.globalCompositeOperation = effect.compositeOperation;
9900
- else if (isFilterEffect(effect)) this.ctx.filter = effect.filterString;
9911
+ else if (isFilterEffect(effect)) {
9912
+ this.ctx.filter = effect.safeFilterString || "none";
9913
+ if (effect.shadow) {
9914
+ this.ctx.shadowOffsetX = effect.shadow.offsetX;
9915
+ this.ctx.shadowOffsetY = effect.shadow.offsetY;
9916
+ this.ctx.shadowBlur = effect.shadow.blur;
9917
+ this.ctx.shadowColor = effect.shadow.color;
9918
+ }
9919
+ }
9901
9920
  this.activeEffects.push(effect);
9902
9921
  }
9903
9922
  /**
@@ -10714,7 +10733,8 @@ const renderElement = async (element, opts, config) => {
10714
10733
  imageTimeout: opts.imageTimeout ?? 15e3,
10715
10734
  proxy: opts.proxy,
10716
10735
  useCORS: opts.useCORS ?? false,
10717
- customIsSameOrigin: opts.customIsSameOrigin
10736
+ customIsSameOrigin: opts.customIsSameOrigin,
10737
+ maxCacheSize: opts.maxCacheSize
10718
10738
  };
10719
10739
  const contextOptions = {
10720
10740
  logging: opts.logging ?? true,