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
package/dist/html2canvas-pro.js
CHANGED
|
@@ -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
|
*/
|
|
@@ -3977,24 +3977,44 @@
|
|
|
3977
3977
|
if (typeof transformFunction === 'undefined') {
|
|
3978
3978
|
throw new Error("Attempting to parse an unsupported transform function \"".concat(token.name, "\""));
|
|
3979
3979
|
}
|
|
3980
|
-
return transformFunction(token.values);
|
|
3980
|
+
return transformFunction(_context, token.values);
|
|
3981
3981
|
}
|
|
3982
3982
|
return null;
|
|
3983
3983
|
}
|
|
3984
3984
|
};
|
|
3985
|
-
var matrix = function (args) {
|
|
3985
|
+
var matrix = function (_context, args) {
|
|
3986
3986
|
var values = args.filter(function (arg) { return arg.type === 17 /* TokenType.NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
|
|
3987
3987
|
return values.length === 6 ? values : null;
|
|
3988
3988
|
};
|
|
3989
3989
|
// doesn't support 3D transforms at the moment
|
|
3990
|
-
var matrix3d = function (args) {
|
|
3990
|
+
var matrix3d = function (_context, args) {
|
|
3991
3991
|
var values = args.filter(function (arg) { return arg.type === 17 /* TokenType.NUMBER_TOKEN */; }).map(function (arg) { return arg.number; });
|
|
3992
3992
|
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];
|
|
3993
3993
|
return values.length === 16 ? [a1, b1, a2, b2, a4, b4] : null;
|
|
3994
3994
|
};
|
|
3995
|
+
var rotate$1 = function (context, args) {
|
|
3996
|
+
if (args.length !== 1) {
|
|
3997
|
+
return null;
|
|
3998
|
+
}
|
|
3999
|
+
var arg = args[0];
|
|
4000
|
+
var radians = 0;
|
|
4001
|
+
if (arg.type === 17 /* TokenType.NUMBER_TOKEN */ && arg.number === 0) {
|
|
4002
|
+
radians = 0;
|
|
4003
|
+
}
|
|
4004
|
+
else if (arg.type === 15 /* TokenType.DIMENSION_TOKEN */) {
|
|
4005
|
+
radians = angle.parse(context, arg);
|
|
4006
|
+
}
|
|
4007
|
+
else {
|
|
4008
|
+
return null;
|
|
4009
|
+
}
|
|
4010
|
+
var cos = Math.cos(radians);
|
|
4011
|
+
var sin = Math.sin(radians);
|
|
4012
|
+
return [cos, sin, -sin, cos, 0, 0];
|
|
4013
|
+
};
|
|
3995
4014
|
var SUPPORTED_TRANSFORM_FUNCTIONS = {
|
|
3996
4015
|
matrix: matrix,
|
|
3997
|
-
matrix3d: matrix3d
|
|
4016
|
+
matrix3d: matrix3d,
|
|
4017
|
+
rotate: rotate$1
|
|
3998
4018
|
};
|
|
3999
4019
|
|
|
4000
4020
|
var DEFAULT_VALUE = {
|
|
@@ -4017,6 +4037,30 @@
|
|
|
4017
4037
|
}
|
|
4018
4038
|
};
|
|
4019
4039
|
|
|
4040
|
+
var rotate = {
|
|
4041
|
+
name: 'rotate',
|
|
4042
|
+
initialValue: 'none',
|
|
4043
|
+
prefix: false,
|
|
4044
|
+
type: 0 /* PropertyDescriptorParsingType.VALUE */,
|
|
4045
|
+
parse: function (_context, token) {
|
|
4046
|
+
if (token.type === 20 /* TokenType.IDENT_TOKEN */ && token.value === 'none') {
|
|
4047
|
+
return null;
|
|
4048
|
+
}
|
|
4049
|
+
if (token.type === 17 /* TokenType.NUMBER_TOKEN */) {
|
|
4050
|
+
if (token.number === 0) {
|
|
4051
|
+
return 0;
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
if (token.type === 15 /* TokenType.DIMENSION_TOKEN */) {
|
|
4055
|
+
// Parse angle and convert to degrees for storage
|
|
4056
|
+
var radians = angle.parse(_context, token);
|
|
4057
|
+
// Store as degrees for consistency
|
|
4058
|
+
return (radians * 180) / Math.PI;
|
|
4059
|
+
}
|
|
4060
|
+
return null;
|
|
4061
|
+
}
|
|
4062
|
+
};
|
|
4063
|
+
|
|
4020
4064
|
var visibility = {
|
|
4021
4065
|
name: 'visible',
|
|
4022
4066
|
initialValue: 'none',
|
|
@@ -4529,6 +4573,7 @@
|
|
|
4529
4573
|
this.textTransform = parse(context, textTransform, declaration.textTransform);
|
|
4530
4574
|
this.transform = parse(context, transform$1, declaration.transform);
|
|
4531
4575
|
this.transformOrigin = parse(context, transformOrigin, declaration.transformOrigin);
|
|
4576
|
+
this.rotate = parse(context, rotate, declaration.rotate);
|
|
4532
4577
|
this.visibility = parse(context, visibility, declaration.visibility);
|
|
4533
4578
|
this.webkitTextStrokeColor = parse(context, webkitTextStrokeColor, declaration.webkitTextStrokeColor);
|
|
4534
4579
|
this.webkitTextStrokeWidth = parse(context, webkitTextStrokeWidth, declaration.webkitTextStrokeWidth);
|
|
@@ -4543,7 +4588,7 @@
|
|
|
4543
4588
|
return isTransparent(this.backgroundColor);
|
|
4544
4589
|
};
|
|
4545
4590
|
CSSParsedDeclaration.prototype.isTransformed = function () {
|
|
4546
|
-
return this.transform !== null;
|
|
4591
|
+
return this.transform !== null || this.rotate !== null;
|
|
4547
4592
|
};
|
|
4548
4593
|
CSSParsedDeclaration.prototype.isPositioned = function () {
|
|
4549
4594
|
return this.position !== 0 /* POSITION.STATIC */;
|
|
@@ -4654,6 +4699,10 @@
|
|
|
4654
4699
|
// getBoundingClientRect takes transforms into account
|
|
4655
4700
|
element.style.transform = 'none';
|
|
4656
4701
|
}
|
|
4702
|
+
if (this.styles.rotate !== null) {
|
|
4703
|
+
// Handle rotate property similarly to transform
|
|
4704
|
+
element.style.rotate = 'none';
|
|
4705
|
+
}
|
|
4657
4706
|
}
|
|
4658
4707
|
this.bounds = parseBounds(this.context, element);
|
|
4659
4708
|
if (isDebugging(element, 4 /* DebuggerType.RENDER */)) {
|
|
@@ -6118,16 +6167,27 @@
|
|
|
6118
6167
|
}
|
|
6119
6168
|
});
|
|
6120
6169
|
}); });
|
|
6121
|
-
var adoptedNode = documentClone.adoptNode(this.documentElement);
|
|
6122
6170
|
/**
|
|
6123
6171
|
* The baseURI of the document will be lost after documentClone.open().
|
|
6124
|
-
* We
|
|
6172
|
+
* We save it before open() to preserve the original base URI for resource resolution.
|
|
6125
6173
|
* */
|
|
6126
|
-
|
|
6174
|
+
var baseUri = documentClone.baseURI;
|
|
6127
6175
|
documentClone.open();
|
|
6128
6176
|
documentClone.write("".concat(serializeDoctype(document.doctype), "<html></html>"));
|
|
6129
6177
|
// Chrome scrolls the parent document for some reason after the write to the cloned window???
|
|
6130
6178
|
restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY);
|
|
6179
|
+
/**
|
|
6180
|
+
* Note: adoptNode() should be called AFTER documentClone.open() and close()
|
|
6181
|
+
*
|
|
6182
|
+
* In Chrome, calling adoptNode() before or during open/write may cause
|
|
6183
|
+
* styles with uppercase characters in class names (e.g. ".MyClass") to not apply correctly.
|
|
6184
|
+
*
|
|
6185
|
+
* Fix:
|
|
6186
|
+
* - Make sure adoptNode() is called after documentClone.open() and close()
|
|
6187
|
+
* - This allows Chrome to properly match and apply all CSS rules including mixed-case class selectors.
|
|
6188
|
+
* */
|
|
6189
|
+
var adoptedNode = documentClone.adoptNode(this.documentElement);
|
|
6190
|
+
addBase(adoptedNode, baseUri);
|
|
6131
6191
|
documentClone.replaceChild(adoptedNode, documentClone.documentElement);
|
|
6132
6192
|
documentClone.close();
|
|
6133
6193
|
return iframeLoad;
|
|
@@ -6536,10 +6596,10 @@
|
|
|
6536
6596
|
body.appendChild(style);
|
|
6537
6597
|
}
|
|
6538
6598
|
};
|
|
6539
|
-
var addBase = function (targetELement,
|
|
6599
|
+
var addBase = function (targetELement, baseUri) {
|
|
6540
6600
|
var _a;
|
|
6541
|
-
var baseNode =
|
|
6542
|
-
baseNode.href =
|
|
6601
|
+
var baseNode = targetELement.ownerDocument.createElement('base');
|
|
6602
|
+
baseNode.href = baseUri;
|
|
6543
6603
|
var headEle = targetELement.getElementsByTagName('head').item(0);
|
|
6544
6604
|
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);
|
|
6545
6605
|
};
|
|
@@ -6592,12 +6652,21 @@
|
|
|
6592
6652
|
};
|
|
6593
6653
|
Cache.prototype.loadImage = function (key) {
|
|
6594
6654
|
return __awaiter(this, void 0, void 0, function () {
|
|
6595
|
-
var isSameOrigin, useCORS, useProxy, src;
|
|
6655
|
+
var isSameOrigin, _a, useCORS, useProxy, src;
|
|
6596
6656
|
var _this = this;
|
|
6597
|
-
return __generator(this, function (
|
|
6598
|
-
switch (
|
|
6657
|
+
return __generator(this, function (_b) {
|
|
6658
|
+
switch (_b.label) {
|
|
6599
6659
|
case 0:
|
|
6600
|
-
|
|
6660
|
+
if (!(typeof this._options.customIsSameOrigin === 'function')) return [3 /*break*/, 2];
|
|
6661
|
+
return [4 /*yield*/, this._options.customIsSameOrigin(key, CacheStorage.isSameOrigin)];
|
|
6662
|
+
case 1:
|
|
6663
|
+
_a = _b.sent();
|
|
6664
|
+
return [3 /*break*/, 3];
|
|
6665
|
+
case 2:
|
|
6666
|
+
_a = CacheStorage.isSameOrigin(key);
|
|
6667
|
+
_b.label = 3;
|
|
6668
|
+
case 3:
|
|
6669
|
+
isSameOrigin = _a;
|
|
6601
6670
|
useCORS = !isInlineImage(key) && this._options.useCORS === true && FEATURES.SUPPORT_CORS_IMAGES && !isSameOrigin;
|
|
6602
6671
|
useProxy = !isInlineImage(key) &&
|
|
6603
6672
|
!isSameOrigin &&
|
|
@@ -6614,12 +6683,12 @@
|
|
|
6614
6683
|
return [2 /*return*/];
|
|
6615
6684
|
}
|
|
6616
6685
|
src = key;
|
|
6617
|
-
if (!useProxy) return [3 /*break*/,
|
|
6686
|
+
if (!useProxy) return [3 /*break*/, 5];
|
|
6618
6687
|
return [4 /*yield*/, this.proxy(src)];
|
|
6619
|
-
case
|
|
6620
|
-
src =
|
|
6621
|
-
|
|
6622
|
-
case
|
|
6688
|
+
case 4:
|
|
6689
|
+
src = _b.sent();
|
|
6690
|
+
_b.label = 5;
|
|
6691
|
+
case 5:
|
|
6623
6692
|
this.context.logger.debug("Added image ".concat(key.substring(0, 256)));
|
|
6624
6693
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
6625
6694
|
var img = new Image();
|
|
@@ -6638,7 +6707,7 @@
|
|
|
6638
6707
|
setTimeout(function () { return reject("Timed out (".concat(_this._options.imageTimeout, "ms) loading image")); }, _this._options.imageTimeout);
|
|
6639
6708
|
}
|
|
6640
6709
|
})];
|
|
6641
|
-
case
|
|
6710
|
+
case 6: return [2 /*return*/, _b.sent()];
|
|
6642
6711
|
}
|
|
6643
6712
|
});
|
|
6644
6713
|
});
|
|
@@ -6998,6 +7067,17 @@
|
|
|
6998
7067
|
if (this.container.styles.opacity < 1) {
|
|
6999
7068
|
this.effects.push(new OpacityEffect(this.container.styles.opacity));
|
|
7000
7069
|
}
|
|
7070
|
+
if (this.container.styles.rotate !== null) {
|
|
7071
|
+
var offsetX = this.container.bounds.left + this.container.styles.transformOrigin[0].number;
|
|
7072
|
+
var offsetY = this.container.bounds.top + this.container.styles.transformOrigin[1].number;
|
|
7073
|
+
// Apply rotate property if present
|
|
7074
|
+
var angle = this.container.styles.rotate;
|
|
7075
|
+
var rad = (angle * Math.PI) / 180;
|
|
7076
|
+
var cos = Math.cos(rad);
|
|
7077
|
+
var sin = Math.sin(rad);
|
|
7078
|
+
var rotateMatrix = [cos, sin, -sin, cos, 0, 0];
|
|
7079
|
+
this.effects.push(new TransformEffect(offsetX, offsetY, rotateMatrix));
|
|
7080
|
+
}
|
|
7001
7081
|
if (this.container.styles.transform !== null) {
|
|
7002
7082
|
var offsetX = this.container.bounds.left + this.container.styles.transformOrigin[0].number;
|
|
7003
7083
|
var offsetY = this.container.bounds.top + this.container.styles.transformOrigin[1].number;
|
|
@@ -8681,7 +8761,8 @@
|
|
|
8681
8761
|
allowTaint: (_b = opts.allowTaint) !== null && _b !== void 0 ? _b : false,
|
|
8682
8762
|
imageTimeout: (_c = opts.imageTimeout) !== null && _c !== void 0 ? _c : 15000,
|
|
8683
8763
|
proxy: opts.proxy,
|
|
8684
|
-
useCORS: (_d = opts.useCORS) !== null && _d !== void 0 ? _d : false
|
|
8764
|
+
useCORS: (_d = opts.useCORS) !== null && _d !== void 0 ? _d : false,
|
|
8765
|
+
customIsSameOrigin: opts.customIsSameOrigin
|
|
8685
8766
|
};
|
|
8686
8767
|
contextOptions = __assign({ logging: (_e = opts.logging) !== null && _e !== void 0 ? _e : true, cache: opts.cache }, resourceOptions);
|
|
8687
8768
|
windowOptions = {
|