Skip to content

Commit 8b78db7

Browse files
committed
Fix more variable scoping bugs exposed by TypeScript
- Fix rotationTransformationMatrix undefined in addimage module - Fix fontSize and related variables undefined in context2d module - Both caused by variables declared inside if blocks but used outside - Test failures reduced from 25 to 7 (98% pass rate: 437/444 tests passing)
1 parent 20a37b4 commit 8b78db7

16 files changed

+63
-50
lines changed

dist/jspdf.es.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/** @license
22
*
33
* jsPDF - PDF Document creation from JavaScript
4-
* Version 3.0.3 Built on 2025-11-09T21:04:31.161Z
5-
* CommitID 1002184b4d
4+
* Version 3.0.3 Built on 2025-11-09T21:09:43.430Z
5+
* CommitID 20a37b42ba
66
*
77
* Copyright (c) 2010-2025 James Hall <[email protected]>, https://github.com/MrRio/jsPDF
88
* 2015-2025 yWorks GmbH, http://www.yworks.com
@@ -8765,6 +8765,7 @@ var AcroForm = jsPDF.AcroForm;
87658765
width = dims[0];
87668766
height = dims[1];
87678767
images[image.index] = image;
8768+
var rotationTransformationMatrix;
87688769
if (rotation) {
87698770
rotation *= Math.PI / 180;
87708771
var c = Math.cos(rotation);
@@ -8773,7 +8774,7 @@ var AcroForm = jsPDF.AcroForm;
87738774
var f4 = function f4(number) {
87748775
return number.toFixed(4);
87758776
};
8776-
[f4(c), f4(s), f4(s * -1), f4(c), 0, 0, "cm"];
8777+
rotationTransformationMatrix = [f4(c), f4(s), f4(s * -1), f4(c), 0, 0, "cm"];
87778778
}
87788779
this.internal.write("q"); //Save graphics state
87798780
if (rotation) {
@@ -11204,13 +11205,14 @@ function parseFontFamily(input) {
1120411205
// eslint-disable-next-line no-useless-escape
1120511206
rx = /^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-_,\"\'\sa-z]+?)\s*$/i;
1120611207
matches = rx.exec(value);
11208+
var fontStyle, fontWeight, fontSize, fontFamily;
1120711209
if (matches !== null) {
11208-
matches[1];
11210+
fontStyle = matches[1];
1120911211
matches[2];
11210-
matches[3];
11211-
matches[4];
11212+
fontWeight = matches[3];
11213+
fontSize = matches[4];
1121211214
matches[5];
11213-
matches[6];
11215+
fontFamily = matches[6];
1121411216
} else {
1121511217
return;
1121611218
}

dist/jspdf.es.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jspdf.es.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jspdf.es.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jspdf.node.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/** @license
22
*
33
* jsPDF - PDF Document creation from JavaScript
4-
* Version 3.0.3 Built on 2025-11-09T21:04:31.195Z
5-
* CommitID 1002184b4d
4+
* Version 3.0.3 Built on 2025-11-09T21:09:43.462Z
5+
* CommitID 20a37b42ba
66
*
77
* Copyright (c) 2010-2025 James Hall <[email protected]>, https://github.com/MrRio/jsPDF
88
* 2015-2025 yWorks GmbH, http://www.yworks.com
@@ -9487,6 +9487,7 @@ let AcroForm = jsPDF.AcroForm;
94879487
width = dims[0];
94889488
height = dims[1];
94899489
images[image.index] = image;
9490+
let rotationTransformationMatrix;
94909491
if (rotation) {
94919492
rotation *= Math.PI / 180;
94929493
let c = Math.cos(rotation);
@@ -9495,7 +9496,7 @@ let AcroForm = jsPDF.AcroForm;
94959496
let f4 = function (number) {
94969497
return number.toFixed(4);
94979498
};
9498-
[
9499+
rotationTransformationMatrix = [
94999500
f4(c),
95009501
f4(s),
95019502
f4(s * -1),
@@ -12001,13 +12002,14 @@ function parseFontFamily(input) {
1200112002
// eslint-disable-next-line no-useless-escape
1200212003
rx = /^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-_,\"\'\sa-z]+?)\s*$/i;
1200312004
matches = rx.exec(value);
12005+
let fontStyle, fontWeight, fontSize, fontFamily;
1200412006
if (matches !== null) {
12005-
matches[1];
12007+
fontStyle = matches[1];
1200612008
matches[2];
12007-
matches[3];
12008-
matches[4];
12009+
fontWeight = matches[3];
12010+
fontSize = matches[4];
1200912011
matches[5];
12010-
matches[6];
12012+
fontFamily = matches[6];
1201112013
}
1201212014
else {
1201312015
return;

dist/jspdf.node.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jspdf.node.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jspdf.node.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jspdf.umd.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/** @license
22
*
33
* jsPDF - PDF Document creation from JavaScript
4-
* Version 3.0.3 Built on 2025-11-09T21:04:31.121Z
5-
* CommitID 1002184b4d
4+
* Version 3.0.3 Built on 2025-11-09T21:09:43.398Z
5+
* CommitID 20a37b42ba
66
*
77
* Copyright (c) 2010-2025 James Hall <[email protected]>, https://github.com/MrRio/jsPDF
88
* 2015-2025 yWorks GmbH, http://www.yworks.com
@@ -8850,6 +8850,7 @@
88508850
width = dims[0];
88518851
height = dims[1];
88528852
images[image.index] = image;
8853+
var rotationTransformationMatrix;
88538854
if (rotation) {
88548855
rotation *= Math.PI / 180;
88558856
var c = Math.cos(rotation);
@@ -8858,7 +8859,7 @@
88588859
var f4 = function f4(number) {
88598860
return number.toFixed(4);
88608861
};
8861-
[f4(c), f4(s), f4(s * -1), f4(c), 0, 0, "cm"];
8862+
rotationTransformationMatrix = [f4(c), f4(s), f4(s * -1), f4(c), 0, 0, "cm"];
88628863
}
88638864
this.internal.write("q"); //Save graphics state
88648865
if (rotation) {
@@ -11289,13 +11290,14 @@
1128911290
// eslint-disable-next-line no-useless-escape
1129011291
rx = /^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-_,\"\'\sa-z]+?)\s*$/i;
1129111292
matches = rx.exec(value);
11293+
var fontStyle, fontWeight, fontSize, fontFamily;
1129211294
if (matches !== null) {
11293-
matches[1];
11295+
fontStyle = matches[1];
1129411296
matches[2];
11295-
matches[3];
11296-
matches[4];
11297+
fontWeight = matches[3];
11298+
fontSize = matches[4];
1129711299
matches[5];
11298-
matches[6];
11300+
fontFamily = matches[6];
1129911301
} else {
1130011302
return;
1130111303
}

dist/jspdf.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)