html2canvas-pro 2.2.0 → 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.
@@ -64,7 +64,8 @@ const renderElement = async (element, opts, config) => {
64
64
  imageTimeout: opts.imageTimeout ?? 15000,
65
65
  proxy: opts.proxy,
66
66
  useCORS: opts.useCORS ?? false,
67
- customIsSameOrigin: opts.customIsSameOrigin
67
+ customIsSameOrigin: opts.customIsSameOrigin,
68
+ maxCacheSize: opts.maxCacheSize
68
69
  };
69
70
  const contextOptions = {
70
71
  logging: opts.logging ?? true,
@@ -310,10 +310,16 @@ const parse = (context, descriptor, style) => {
310
310
  valueCache = new Map();
311
311
  parseCache.set(descriptor, valueCache);
312
312
  }
313
- if (valueCache.size >= constants_1.PARSE_CACHE_MAX_PER_DESCRIPTOR) {
314
- const oldestKey = valueCache.keys().next().value;
315
- valueCache.delete(oldestKey);
313
+ // Skip caching for image descriptors — their parse() has the critical
314
+ // side effect of calling context.cache.addImage(url) which must run
315
+ // on every render pass (different cache instances per html2canvas call).
316
+ const skipCache = descriptor.type === 3 /* PropertyDescriptorParsingType.TYPE_VALUE */ && descriptor.format === 'image';
317
+ if (!skipCache) {
318
+ if (valueCache.size >= constants_1.PARSE_CACHE_MAX_PER_DESCRIPTOR) {
319
+ const oldestKey = valueCache.keys().next().value;
320
+ valueCache.delete(oldestKey);
321
+ }
322
+ valueCache.set(rawValue, result);
316
323
  }
317
- valueCache.set(rawValue, result);
318
324
  return result;
319
325
  };
@@ -67,7 +67,14 @@ class EffectsRenderer {
67
67
  this.ctx.globalCompositeOperation = effect.compositeOperation;
68
68
  }
69
69
  else if ((0, effects_1.isFilterEffect)(effect)) {
70
- this.ctx.filter = effect.filterString;
70
+ // Canvas 2D `ctx.filter` accepts CSS filter strings including
71
+ // drop-shadow(). However, using drop-shadow() on the canvas context
72
+ // can taint the canvas in some browsers (Chrome, Firefox) even for
73
+ // same-origin content. Our filter parser wraps shadows with
74
+ // drop-shadow(...) — strip that single function so we never set
75
+ // a filter that could taint the canvas.
76
+ const safe = effect.filterString.replace(/drop-shadow\([^)]+\)\s*/g, '').trim();
77
+ this.ctx.filter = safe || 'none';
71
78
  }
72
79
  this.activeEffects.push(effect);
73
80
  }
package/package.json CHANGED
@@ -19,7 +19,7 @@
19
19
  "default": "./dist/html2canvas-pro.esm.js"
20
20
  }
21
21
  },
22
- "version": "2.2.0",
22
+ "version": "2.2.1",
23
23
  "author": {
24
24
  "name": "yorickshan",
25
25
  "email": "yorickshan@gmail.com",