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.
- package/README.md +19 -19
- package/dist/html2canvas-pro.esm.js +13 -7
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +13 -7
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +3 -3
- package/dist/lib/core/render-element.js +2 -1
- package/dist/lib/css/index.js +10 -4
- package/dist/lib/render/canvas/effects-renderer.js +8 -1
- package/package.json +1 -1
|
@@ -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,
|
package/dist/lib/css/index.js
CHANGED
|
@@ -310,10 +310,16 @@ const parse = (context, descriptor, style) => {
|
|
|
310
310
|
valueCache = new Map();
|
|
311
311
|
parseCache.set(descriptor, valueCache);
|
|
312
312
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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
|
-
|
|
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
|
}
|