Skip to content

Commit 1f23740

Browse files
markotahtMarko.TahtHackbrettXXX
authored
Replace Deflater with pako (#2944)
Co-authored-by: Marko.Taht <[email protected]> Co-authored-by: Lukas Hollaender <[email protected]>
1 parent 3538bf7 commit 1f23740

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+7494
-3962
lines changed

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
**/*{.,-}min.js
2+
examples/PDF.js/**/*
3+
examples/css/**/*
4+
examples/html2pdf/examples.css

.eslintrc.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ module.exports = {
1717
ecmaVersion: 2018,
1818
sourceType: "module"
1919
},
20-
rules: {}
20+
rules: {
21+
"@typescript-eslint/no-var-requires": "off"
22+
}
2123
};

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
**/*{.,-}min.js
2+
examples/PDF.js/**/*
3+
examples/css/**/*
4+
examples/html2pdf/examples.css

CODE_OF_CONDUCT.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo
88

99
Examples of behavior that contributes to creating a positive environment include:
1010

11-
* Using welcoming and inclusive language
12-
* Being respectful of differing viewpoints and experiences
13-
* Gracefully accepting constructive criticism
14-
* Focusing on what is best for the community
15-
* Showing empathy towards other community members
11+
- Using welcoming and inclusive language
12+
- Being respectful of differing viewpoints and experiences
13+
- Gracefully accepting constructive criticism
14+
- Focusing on what is best for the community
15+
- Showing empathy towards other community members
1616

1717
Examples of unacceptable behavior by participants include:
1818

19-
* The use of sexualized language or imagery and unwelcome sexual attention or advances
20-
* Trolling, insulting/derogatory comments, and personal or political attacks
21-
* Public or private harassment
22-
* Publishing others' private information, such as a physical or electronic address, without explicit permission
23-
* Other conduct which could reasonably be considered inappropriate in a professional setting
19+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
- Trolling, insulting/derogatory comments, and personal or political attacks
21+
- Public or private harassment
22+
- Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
- Other conduct which could reasonably be considered inappropriate in a professional setting
2424

2525
## Our Responsibilities
2626

ISSUE_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ Note that bug reports should follow these guidelines:
66

77
1. A bug should be reported as an [mcve](https://stackoverflow.com/help/mcve)
88
2. Make sure code is properly indented and [formatted](https://help.github.com/articles/basic-writing-and-formatting-syntax/#quoting-code) (Use ``` around code blocks)
9-
3. Provide a runnable example.
9+
3. Provide a runnable example.
1010
4. Try to make sure and show in your issue that the issue is actually related to jspdf and not your framework of choice your setup.

bower.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
],
1414
"moduleType": ["amd", "globals", "node", "es6"],
1515
"keywords": ["pdf"],
16-
"dependencies": {},
16+
"dependencies": {
17+
"pako": "^1.0.11"
18+
},
1719
"optionalDependencies": {
1820
"canvg": "^3.0.6",
1921
"core-js": "^3.6.0",

cli.js

+96-76
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,116 @@
11
const inquirer = require("inquirer");
2-
const configuration = require('./modules.conf.js');
2+
const configuration = require("./modules.conf.js");
33

44
console.log(configuration);
55

66
function uniq(a) {
7-
var prims = { "boolean": {}, "number": {}, "string": {} }, objs = [];
7+
var prims = { boolean: {}, number: {}, string: {} },
8+
objs = [];
89

9-
return a.filter(function (item) {
10-
var type = typeof item;
11-
if (type in prims)
12-
return prims[type].hasOwnProperty(item) ? false : (prims[type][item] = true);
13-
else
14-
return objs.indexOf(item) >= 0 ? false : objs.push(item);
15-
});
10+
return a.filter(function(item) {
11+
var type = typeof item;
12+
if (type in prims)
13+
if (Object.prototype.hasOwnProperty.call(prims[type], item)) {
14+
return false;
15+
} else {
16+
prims[type][item] = true;
17+
return true;
18+
}
19+
else return objs.indexOf(item) >= 0 ? false : objs.push(item);
20+
});
1621
}
1722

1823
function generateFileList(list) {
19-
var fileList = [];
20-
var file;
21-
for (var i = 0; i < list.length; i++) {
22-
fileList.push(list[i].name + '.js');
23-
console.log(list[i])
24-
console.log(configuration[list[i].name])
25-
for (var j = 0; j < configuration[list[i]].deps.length; j++) {
26-
file = configuration[list[i]].deps[j];
27-
configuration[file].type
28-
fileList.push(configuration[file].type + '/' + '.js');
29-
}
24+
var fileList = [];
25+
var file;
26+
for (var i = 0; i < list.length; i++) {
27+
fileList.push(list[i].name + ".js");
28+
console.log(list[i]);
29+
console.log(configuration[list[i].name]);
30+
for (var j = 0; j < configuration[list[i]].deps.length; j++) {
31+
file = configuration[list[i]].deps[j];
32+
configuration[file].type;
33+
fileList.push(configuration[file].type + "/" + ".js");
3034
}
31-
fileList = uniq(fileList);
32-
return fileList;
35+
}
36+
fileList = uniq(fileList);
37+
return fileList;
3338
}
3439

3540
/**
3641
* Ask use a few questions on command prompt
3742
* @returns {Promise} The promise with the result of the prompt
3843
*/
3944
function promptUser() {
40-
return inquirer.prompt([
41-
{
42-
type: "list",
43-
name: "env",
44-
message: "Where does your code run?",
45-
default: ["browser"],
46-
choices: [
47-
{ name: "Browser", value: "browser" },
48-
{ name: "Node", value: "node" }
49-
]
50-
},
51-
{
52-
type: "checkbox",
53-
name: "images",
54-
message: "Which ImageTypes should be supported?",
55-
default: ["jpeg_support", 'bmp_support', 'gif_support', 'webp_support'],
56-
choices: [
57-
{ name: "Jpeg", value: "jpeg_support" },
58-
{ name: "Bmp", value: "bmp_support" },
59-
{ name: "Gif", value: "gif_support" },
60-
{ name: "WebP", value: "webp_support" }
61-
]
62-
},
63-
{
64-
type: "checkbox",
65-
name: "modules",
66-
message: "Additional Modules",
67-
default: ['acroform', 'annotations', 'arabic', 'autoprint', 'context2d',
68-
'fileloading', 'filters', 'html', 'javascript', 'outline',
69-
'setlanguage', 'svg', 'total_pages', 'utf8', 'viewerpreferences',
70-
'xmp_metadata'
71-
],
72-
choices: [
73-
{ name: "Acroform", value: "acroform" },
74-
{ name: "Annotations", value: "annotations" },
75-
{ name: "Arabic Parser", value: "arabic" },
76-
{ name: "Autoprint", value: "autoprint" },
77-
{ name: "Context2d", value: "context2d" },
78-
{ name: "File Loading", value: "fileloading" },
79-
{ name: "Filters", value: "filters" },
80-
{ name: "HTML", value: "html" },
81-
{ name: "Javascript", value: "javascript" },
82-
{ name: "Outline", value: "outline" },
83-
{ name: "Language-Tagging", value: "setlanguage" },
84-
{ name: "SVG", value: "svg" },
85-
{ name: "TotalPages", value: "total_pages" },
86-
{ name: "Unicode", value: "utf8" },
87-
{ name: "ViewerPreferences", value: "viewerpreferences" },
88-
{ name: "XMP Metadata", value: "xmp_metadata" }
89-
]
90-
}
91-
]).then(result => {
92-
console.log(generateFileList([...result.images, ...result.modules]));
45+
return inquirer
46+
.prompt([
47+
{
48+
type: "list",
49+
name: "env",
50+
message: "Where does your code run?",
51+
default: ["browser"],
52+
choices: [
53+
{ name: "Browser", value: "browser" },
54+
{ name: "Node", value: "node" }
55+
]
56+
},
57+
{
58+
type: "checkbox",
59+
name: "images",
60+
message: "Which ImageTypes should be supported?",
61+
default: ["jpeg_support", "bmp_support", "gif_support", "webp_support"],
62+
choices: [
63+
{ name: "Jpeg", value: "jpeg_support" },
64+
{ name: "Bmp", value: "bmp_support" },
65+
{ name: "Gif", value: "gif_support" },
66+
{ name: "WebP", value: "webp_support" }
67+
]
68+
},
69+
{
70+
type: "checkbox",
71+
name: "modules",
72+
message: "Additional Modules",
73+
default: [
74+
"acroform",
75+
"annotations",
76+
"arabic",
77+
"autoprint",
78+
"context2d",
79+
"fileloading",
80+
"filters",
81+
"html",
82+
"javascript",
83+
"outline",
84+
"setlanguage",
85+
"svg",
86+
"total_pages",
87+
"utf8",
88+
"viewerpreferences",
89+
"xmp_metadata"
90+
],
91+
choices: [
92+
{ name: "Acroform", value: "acroform" },
93+
{ name: "Annotations", value: "annotations" },
94+
{ name: "Arabic Parser", value: "arabic" },
95+
{ name: "Autoprint", value: "autoprint" },
96+
{ name: "Context2d", value: "context2d" },
97+
{ name: "File Loading", value: "fileloading" },
98+
{ name: "Filters", value: "filters" },
99+
{ name: "HTML", value: "html" },
100+
{ name: "Javascript", value: "javascript" },
101+
{ name: "Outline", value: "outline" },
102+
{ name: "Language-Tagging", value: "setlanguage" },
103+
{ name: "SVG", value: "svg" },
104+
{ name: "TotalPages", value: "total_pages" },
105+
{ name: "Unicode", value: "utf8" },
106+
{ name: "ViewerPreferences", value: "viewerpreferences" },
107+
{ name: "XMP Metadata", value: "xmp_metadata" }
108+
]
109+
}
110+
])
111+
.then(result => {
112+
console.log(generateFileList([...result.images, ...result.modules]));
93113
});
94114
}
95115

96-
promptUser();
116+
promptUser();

deletedocs.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
const deleteFolder = require('folder-delete');
1+
const deleteFolder = require("folder-delete");
22

33
try {
4-
deleteFolder('docs', {debugLog: false});
5-
} catch (e) {
6-
}
4+
deleteFolder("docs", { debugLog: false });
5+
} catch (e) {}

examples/PDF.js/build/pdf.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -18934,7 +18934,11 @@
1893418934
groupCtx.mozCurrentTransformInverse;
1893518935
copyCtxState(currentCtx, groupCtx);
1893618936
this.ctx = groupCtx;
18937-
this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
18937+
this.setGState([
18938+
["BM", "source-over"],
18939+
["ca", 1],
18940+
["CA", 1]
18941+
]);
1893818942
this.groupStack.push(currentCtx);
1893918943
this.groupLevel++;
1894018944
},
@@ -19912,7 +19916,11 @@
1991219916

1991319917
copyCtxState(currentCtx, groupCtx);
1991419918
this.ctx = groupCtx;
19915-
this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
19919+
this.setGState([
19920+
["BM", "source-over"],
19921+
["ca", 1],
19922+
["CA", 1]
19923+
]);
1991619924
this.groupStack.push(currentCtx);
1991719925
this.groupLevel++;
1991819926
this.current.activeSMask = null;

examples/PDF.js/build/pdf.worker.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -46761,7 +46761,10 @@
4676146761
if (Array.isArray(arr)) return arr;
4676246762
}
4676346763

46764-
var PRIVATE_USE_AREAS = [[0xe000, 0xf8ff], [0x100000, 0x10fffd]];
46764+
var PRIVATE_USE_AREAS = [
46765+
[0xe000, 0xf8ff],
46766+
[0x100000, 0x10fffd]
46767+
];
4676546768
var PDF_GLYPH_SPACE_UNITS = 1000;
4676646769
var SEAC_ANALYSIS_ENABLED = true;
4676746770
exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED;

examples/PDF.js/web/viewer.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -4886,11 +4886,11 @@
48864886
}
48874887

48884888
function getPDFFileNameFromURL(url) {
4889-
let downloadName = (window.location.search).split('=')[2];
4889+
let downloadName = window.location.search.split("=")[2];
48904890
var defaultFilename = downloadName || "document.pdf";
4891-
// arguments.length > 1 && arguments[1] !== undefined
4892-
// ? arguments[1]
4893-
// : "document.pdf";
4891+
// arguments.length > 1 && arguments[1] !== undefined
4892+
// ? arguments[1]
4893+
// : "document.pdf";
48944894

48954895
if (typeof url !== "string") {
48964896
return defaultFilename;

examples/css/bootstrap.min.css

+7,128-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)