html2canvas-pro 1.5.10 → 1.5.12
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/dist/html2canvas-pro.esm.js +104 -23
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +104 -23
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +2 -2
- package/dist/lib/core/cache-storage.js +19 -10
- package/dist/lib/core/cache-storage.js.map +1 -1
- package/dist/lib/css/index.js +3 -1
- package/dist/lib/css/index.js.map +1 -1
- package/dist/lib/css/property-descriptors/rotate.js +28 -0
- package/dist/lib/css/property-descriptors/rotate.js.map +1 -0
- package/dist/lib/css/property-descriptors/transform.js +25 -4
- package/dist/lib/css/property-descriptors/transform.js.map +1 -1
- package/dist/lib/dom/document-cloner.js +17 -6
- package/dist/lib/dom/document-cloner.js.map +1 -1
- package/dist/lib/dom/element-container.js +4 -0
- package/dist/lib/dom/element-container.js.map +1 -1
- package/dist/lib/index.js +2 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/render/stacking-context.js +11 -0
- package/dist/lib/render/stacking-context.js.map +1 -1
- package/dist/types/core/cache-storage.d.ts +1 -0
- package/dist/types/css/index.d.ts +2 -0
- package/dist/types/css/property-descriptors/rotate.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* html2canvas-pro 1.5.
|
|
2
|
+
* html2canvas-pro 1.5.12 <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
|
*/
|
|
@@ -3971,24 +3971,44 @@ var transform$1 = {
|
|
|
3971
3971
|
if (typeof transformFunction === 'undefined') {
|
|
3972
3972
|
throw new Error("Attempting to parse an unsupported transform function \"".concat(token.name, "\""));
|
|
3973
3973
|
}
|
|
3974
|
-
return transformFunction(token.values);
|
|
3974
|
+
return transformFunction(_context, token.values);
|
|
3975
3975
|
}
|
|
3976
3976
|
return null;
|
|
3977
3977
|
}
|
|
3978
3978
|
};
|
|
3979
|
-
var matrix = function (args) {
|
|
3979
|
+
var matrix = function (_context, args) {
|
|
3980
3980
|
var values = args.filter(function (arg) { return arg.type === 17 /* TokenType.NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
|
|
3981
3981
|
return values.length === 6 ? values : null;
|
|
3982
3982
|
};
|
|
3983
3983
|
// doesn't support 3D transforms at the moment
|
|
3984
|
-
var matrix3d = function (args) {
|
|
3984
|
+
var matrix3d = function (_context, args) {
|
|
3985
3985
|
var values = args.filter(function (arg) { return arg.type === 17 /* TokenType.NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
|
|
3986
3986
|
var a1 = values[0], b1 = values[1]; values[2]; values[3]; var a2 = values[4], b2 = values[5]; values[6]; values[7]; values[8]; values[9]; values[10]; values[11]; var a4 = values[12], b4 = values[13]; values[14]; values[15];
|
|
3987
3987
|
return values.length === 16 ? [a1, b1, a2, b2, a4, b4] : null;
|
|
3988
3988
|
};
|
|
3989
|
+
var rotate$1 = function (context, args) {
|
|
3990
|
+
if (args.length !== 1) {
|
|
3991
|
+
return null;
|
|
3992
|
+
}
|
|
3993
|
+
var arg = args[0];
|
|
3994
|
+
var radians = 0;
|
|
3995
|
+
if (arg.type === 17 /* TokenType.NUMBER_TOKEN */ && arg.number === 0) {
|
|
3996
|
+
radians = 0;
|
|
3997
|
+
}
|
|
3998
|
+
else if (arg.type === 15 /* TokenType.DIMENSION_TOKEN */) {
|
|
3999
|
+
radians = angle.parse(context, arg);
|
|
4000
|
+
}
|
|
4001
|
+
else {
|
|
4002
|
+
return null;
|
|
4003
|
+
}
|
|
4004
|
+
var cos = Math.cos(radians);
|
|
4005
|
+
var sin = Math.sin(radians);
|
|
4006
|
+
return [cos, sin, -sin, cos, 0, 0];
|
|
4007
|
+
};
|
|
3989
4008
|
var SUPPORTED_TRANSFORM_FUNCTIONS = {
|
|
3990
4009
|
matrix: matrix,
|
|
3991
|
-
matrix3d: matrix3d
|
|
4010
|
+
matrix3d: matrix3d,
|
|
4011
|
+
rotate: rotate$1
|
|
3992
4012
|
};
|
|
3993
4013
|
|
|
3994
4014
|
var DEFAULT_VALUE = {
|
|
@@ -4011,6 +4031,30 @@ var transformOrigin = {
|
|
|
4011
4031
|
}
|
|
4012
4032
|
};
|
|
4013
4033
|
|
|
4034
|
+
var rotate = {
|
|
4035
|
+
name: 'rotate',
|
|
4036
|
+
initialValue: 'none',
|
|
4037
|
+
prefix: false,
|
|
4038
|
+
type: 0 /* PropertyDescriptorParsingType.VALUE */,
|
|
4039
|
+
parse: function (_context, token) {
|
|
4040
|
+
if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'none') {
|
|
4041
|
+
return null;
|
|
4042
|
+
}
|
|
4043
|
+
if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
|
|
4044
|
+
if (token.number === 0) {
|
|
4045
|
+
return 0;
|
|
4046
|
+
}
|
|
4047
|
+
}
|
|
4048
|
+
if (token.type === 15 /* TokenType.DIMENSION_TOKEN */) {
|
|
4049
|
+
// Parse angle and convert to degrees for storage
|
|
4050
|
+
var radians = angle.parse(_context, token);
|
|
4051
|
+
// Store as degrees for consistency
|
|
4052
|
+
return (radians * 180) / Math.PI;
|
|
4053
|
+
}
|
|
4054
|
+
return null;
|
|
4055
|
+
}
|
|
4056
|
+
};
|
|
4057
|
+
|
|
4014
4058
|
var visibility = {
|
|
4015
4059
|
name: 'visible',
|
|
4016
4060
|
initialValue: 'none',
|
|
@@ -4523,6 +4567,7 @@ var CSSParsedDeclaration = /** @class */ (function () {
|
|
|
4523
4567
|
this.textTransform = parse(context, textTransform, declaration.textTransform);
|
|
4524
4568
|
this.transform = parse(context, transform$1, declaration.transform);
|
|
4525
4569
|
this.transformOrigin = parse(context, transformOrigin, declaration.transformOrigin);
|
|
4570
|
+
this.rotate = parse(context, rotate, declaration.rotate);
|
|
4526
4571
|
this.visibility = parse(context, visibility, declaration.visibility);
|
|
4527
4572
|
this.webkitTextStrokeColor = parse(context, webkitTextStrokeColor, declaration.webkitTextStrokeColor);
|
|
4528
4573
|
this.webkitTextStrokeWidth = parse(context, webkitTextStrokeWidth, declaration.webkitTextStrokeWidth);
|
|
@@ -4537,7 +4582,7 @@ var CSSParsedDeclaration = /** @class */ (function () {
|
|
|
4537
4582
|
return isTransparent(this.backgroundColor);
|
|
4538
4583
|
};
|
|
4539
4584
|
CSSParsedDeclaration.prototype.isTransformed = function () {
|
|
4540
|
-
return this.transform !== null;
|
|
4585
|
+
return this.transform !== null || this.rotate !== null;
|
|
4541
4586
|
};
|
|
4542
4587
|
CSSParsedDeclaration.prototype.isPositioned = function () {
|
|
4543
4588
|
return this.position !== 0 /* POSITION.STATIC */;
|
|
@@ -4648,6 +4693,10 @@ var ElementContainer = /** @class */ (function () {
|
|
|
4648
4693
|
// getBoundingClientRect takes transforms into account
|
|
4649
4694
|
element.style.transform = 'none';
|
|
4650
4695
|
}
|
|
4696
|
+
if (this.styles.rotate !== null) {
|
|
4697
|
+
// Handle rotate property similarly to transform
|
|
4698
|
+
element.style.rotate = 'none';
|
|
4699
|
+
}
|
|
4651
4700
|
}
|
|
4652
4701
|
this.bounds = parseBounds(this.context, element);
|
|
4653
4702
|
if (isDebugging(element, 4 /* DebuggerType.RENDER */)) {
|
|
@@ -6112,16 +6161,27 @@ var DocumentCloner = /** @class */ (function () {
|
|
|
6112
6161
|
}
|
|
6113
6162
|
});
|
|
6114
6163
|
}); });
|
|
6115
|
-
var adoptedNode = documentClone.adoptNode(this.documentElement);
|
|
6116
6164
|
/**
|
|
6117
6165
|
* The baseURI of the document will be lost after documentClone.open().
|
|
6118
|
-
* We
|
|
6166
|
+
* We save it before open() to preserve the original base URI for resource resolution.
|
|
6119
6167
|
* */
|
|
6120
|
-
|
|
6168
|
+
var baseUri = documentClone.baseURI;
|
|
6121
6169
|
documentClone.open();
|
|
6122
6170
|
documentClone.write("".concat(serializeDoctype(document.doctype), "<html></html>"));
|
|
6123
6171
|
// Chrome scrolls the parent document for some reason after the write to the cloned window???
|
|
6124
6172
|
restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY);
|
|
6173
|
+
/**
|
|
6174
|
+
* Note: adoptNode() should be called AFTER documentClone.open() and close()
|
|
6175
|
+
*
|
|
6176
|
+
* In Chrome, calling adoptNode() before or during open/write may cause
|
|
6177
|
+
* styles with uppercase characters in class names (e.g. ".MyClass") to not apply correctly.
|
|
6178
|
+
*
|
|
6179
|
+
* Fix:
|
|
6180
|
+
* - Make sure adoptNode() is called after documentClone.open() and close()
|
|
6181
|
+
* - This allows Chrome to properly match and apply all CSS rules including mixed-case class selectors.
|
|
6182
|
+
* */
|
|
6183
|
+
var adoptedNode = documentClone.adoptNode(this.documentElement);
|
|
6184
|
+
addBase(adoptedNode, baseUri);
|
|
6125
6185
|
documentClone.replaceChild(adoptedNode, documentClone.documentElement);
|
|
6126
6186
|
documentClone.close();
|
|
6127
6187
|
return iframeLoad;
|
|
@@ -6530,10 +6590,10 @@ var createStyles = function (body, styles) {
|
|
|
6530
6590
|
body.appendChild(style);
|
|
6531
6591
|
}
|
|
6532
6592
|
};
|
|
6533
|
-
var addBase = function (targetELement,
|
|
6593
|
+
var addBase = function (targetELement, baseUri) {
|
|
6534
6594
|
var _a;
|
|
6535
|
-
var baseNode =
|
|
6536
|
-
baseNode.href =
|
|
6595
|
+
var baseNode = targetELement.ownerDocument.createElement('base');
|
|
6596
|
+
baseNode.href = baseUri;
|
|
6537
6597
|
var headEle = targetELement.getElementsByTagName('head').item(0);
|
|
6538
6598
|
headEle === null || headEle === void 0 ? void 0 : headEle.insertBefore(baseNode, (_a = headEle === null || headEle === void 0 ? void 0 : headEle.firstChild) !== null && _a !== void 0 ? _a : null);
|
|
6539
6599
|
};
|
|
@@ -6586,12 +6646,21 @@ var Cache = /** @class */ (function () {
|
|
|
6586
6646
|
};
|
|
6587
6647
|
Cache.prototype.loadImage = function (key) {
|
|
6588
6648
|
return __awaiter(this, void 0, void 0, function () {
|
|
6589
|
-
var isSameOrigin, useCORS, useProxy, src;
|
|
6649
|
+
var isSameOrigin, _a, useCORS, useProxy, src;
|
|
6590
6650
|
var _this = this;
|
|
6591
|
-
return __generator(this, function (
|
|
6592
|
-
switch (
|
|
6651
|
+
return __generator(this, function (_b) {
|
|
6652
|
+
switch (_b.label) {
|
|
6593
6653
|
case 0:
|
|
6594
|
-
|
|
6654
|
+
if (!(typeof this._options.customIsSameOrigin === 'function')) return [3 /*break*/, 2];
|
|
6655
|
+
return [4 /*yield*/, this._options.customIsSameOrigin(key, CacheStorage.isSameOrigin)];
|
|
6656
|
+
case 1:
|
|
6657
|
+
_a = _b.sent();
|
|
6658
|
+
return [3 /*break*/, 3];
|
|
6659
|
+
case 2:
|
|
6660
|
+
_a = CacheStorage.isSameOrigin(key);
|
|
6661
|
+
_b.label = 3;
|
|
6662
|
+
case 3:
|
|
6663
|
+
isSameOrigin = _a;
|
|
6595
6664
|
useCORS = !isInlineImage(key) && this._options.useCORS === true && FEATURES.SUPPORT_CORS_IMAGES && !isSameOrigin;
|
|
6596
6665
|
useProxy = !isInlineImage(key) &&
|
|
6597
6666
|
!isSameOrigin &&
|
|
@@ -6608,12 +6677,12 @@ var Cache = /** @class */ (function () {
|
|
|
6608
6677
|
return [2 /*return*/];
|
|
6609
6678
|
}
|
|
6610
6679
|
src = key;
|
|
6611
|
-
if (!useProxy) return [3 /*break*/,
|
|
6680
|
+
if (!useProxy) return [3 /*break*/, 5];
|
|
6612
6681
|
return [4 /*yield*/, this.proxy(src)];
|
|
6613
|
-
case
|
|
6614
|
-
src =
|
|
6615
|
-
|
|
6616
|
-
case
|
|
6682
|
+
case 4:
|
|
6683
|
+
src = _b.sent();
|
|
6684
|
+
_b.label = 5;
|
|
6685
|
+
case 5:
|
|
6617
6686
|
this.context.logger.debug("Added image ".concat(key.substring(0, 256)));
|
|
6618
6687
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
6619
6688
|
var img = new Image();
|
|
@@ -6632,7 +6701,7 @@ var Cache = /** @class */ (function () {
|
|
|
6632
6701
|
setTimeout(function () { return reject("Timed out (".concat(_this._options.imageTimeout, "ms) loading image")); }, _this._options.imageTimeout);
|
|
6633
6702
|
}
|
|
6634
6703
|
})];
|
|
6635
|
-
case
|
|
6704
|
+
case 6: return [2 /*return*/, _b.sent()];
|
|
6636
6705
|
}
|
|
6637
6706
|
});
|
|
6638
6707
|
});
|
|
@@ -6992,6 +7061,17 @@ var ElementPaint = /** @class */ (function () {
|
|
|
6992
7061
|
if (this.container.styles.opacity < 1) {
|
|
6993
7062
|
this.effects.push(new OpacityEffect(this.container.styles.opacity));
|
|
6994
7063
|
}
|
|
7064
|
+
if (this.container.styles.rotate !== null) {
|
|
7065
|
+
var offsetX = this.container.bounds.left + this.container.styles.transformOrigin[0].number;
|
|
7066
|
+
var offsetY = this.container.bounds.top + this.container.styles.transformOrigin[1].number;
|
|
7067
|
+
// Apply rotate property if present
|
|
7068
|
+
var angle = this.container.styles.rotate;
|
|
7069
|
+
var rad = (angle * Math.PI) / 180;
|
|
7070
|
+
var cos = Math.cos(rad);
|
|
7071
|
+
var sin = Math.sin(rad);
|
|
7072
|
+
var rotateMatrix = [cos, sin, -sin, cos, 0, 0];
|
|
7073
|
+
this.effects.push(new TransformEffect(offsetX, offsetY, rotateMatrix));
|
|
7074
|
+
}
|
|
6995
7075
|
if (this.container.styles.transform !== null) {
|
|
6996
7076
|
var offsetX = this.container.bounds.left + this.container.styles.transformOrigin[0].number;
|
|
6997
7077
|
var offsetY = this.container.bounds.top + this.container.styles.transformOrigin[1].number;
|
|
@@ -8675,7 +8755,8 @@ var renderElement = function (element, opts) { return __awaiter(void 0, void 0,
|
|
|
8675
8755
|
allowTaint: (_b = opts.allowTaint) !== null && _b !== void 0 ? _b : false,
|
|
8676
8756
|
imageTimeout: (_c = opts.imageTimeout) !== null && _c !== void 0 ? _c : 15000,
|
|
8677
8757
|
proxy: opts.proxy,
|
|
8678
|
-
useCORS: (_d = opts.useCORS) !== null && _d !== void 0 ? _d : false
|
|
8758
|
+
useCORS: (_d = opts.useCORS) !== null && _d !== void 0 ? _d : false,
|
|
8759
|
+
customIsSameOrigin: opts.customIsSameOrigin
|
|
8679
8760
|
};
|
|
8680
8761
|
contextOptions = __assign({ logging: (_e = opts.logging) !== null && _e !== void 0 ? _e : true, cache: opts.cache }, resourceOptions);
|
|
8681
8762
|
windowOptions = {
|