Skip to content

Commit

Permalink
Replace Deflater with pako (#2944)
Browse files Browse the repository at this point in the history
Co-authored-by: Marko.Taht <markotaht@guardtime.com>
Co-authored-by: Lukas Hollaender <lukas.hollaender@yworks.com>
  • Loading branch information
3 people committed Dec 7, 2020
1 parent 3538bf7 commit 1f23740
Show file tree
Hide file tree
Showing 41 changed files with 7,494 additions and 3,962 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
@@ -1 +1,4 @@
**/*{.,-}min.js
examples/PDF.js/**/*
examples/css/**/*
examples/html2pdf/examples.css
4 changes: 3 additions & 1 deletion .eslintrc.js
Expand Up @@ -17,5 +17,7 @@ module.exports = {
ecmaVersion: 2018,
sourceType: "module"
},
rules: {}
rules: {
"@typescript-eslint/no-var-requires": "off"
}
};
4 changes: 4 additions & 0 deletions .prettierignore
@@ -0,0 +1,4 @@
**/*{.,-}min.js
examples/PDF.js/**/*
examples/css/**/*
examples/html2pdf/examples.css
20 changes: 10 additions & 10 deletions CODE_OF_CONDUCT.md
Expand Up @@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo

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

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

Examples of unacceptable behavior by participants include:

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

## Our Responsibilities

Expand Down
2 changes: 1 addition & 1 deletion ISSUE_TEMPLATE.md
Expand Up @@ -6,5 +6,5 @@ Note that bug reports should follow these guidelines:

1. A bug should be reported as an [mcve](https://stackoverflow.com/help/mcve)
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)
3. Provide a runnable example.
3. Provide a runnable example.
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.
4 changes: 3 additions & 1 deletion bower.json
Expand Up @@ -13,7 +13,9 @@
],
"moduleType": ["amd", "globals", "node", "es6"],
"keywords": ["pdf"],
"dependencies": {},
"dependencies": {
"pako": "^1.0.11"
},
"optionalDependencies": {
"canvg": "^3.0.6",
"core-js": "^3.6.0",
Expand Down
172 changes: 96 additions & 76 deletions cli.js
@@ -1,96 +1,116 @@
const inquirer = require("inquirer");
const configuration = require('./modules.conf.js');
const configuration = require("./modules.conf.js");

console.log(configuration);

function uniq(a) {
var prims = { "boolean": {}, "number": {}, "string": {} }, objs = [];
var prims = { boolean: {}, number: {}, string: {} },
objs = [];

return a.filter(function (item) {
var type = typeof item;
if (type in prims)
return prims[type].hasOwnProperty(item) ? false : (prims[type][item] = true);
else
return objs.indexOf(item) >= 0 ? false : objs.push(item);
});
return a.filter(function(item) {
var type = typeof item;
if (type in prims)
if (Object.prototype.hasOwnProperty.call(prims[type], item)) {
return false;
} else {
prims[type][item] = true;
return true;
}
else return objs.indexOf(item) >= 0 ? false : objs.push(item);
});
}

function generateFileList(list) {
var fileList = [];
var file;
for (var i = 0; i < list.length; i++) {
fileList.push(list[i].name + '.js');
console.log(list[i])
console.log(configuration[list[i].name])
for (var j = 0; j < configuration[list[i]].deps.length; j++) {
file = configuration[list[i]].deps[j];
configuration[file].type
fileList.push(configuration[file].type + '/' + '.js');
}
var fileList = [];
var file;
for (var i = 0; i < list.length; i++) {
fileList.push(list[i].name + ".js");
console.log(list[i]);
console.log(configuration[list[i].name]);
for (var j = 0; j < configuration[list[i]].deps.length; j++) {
file = configuration[list[i]].deps[j];
configuration[file].type;
fileList.push(configuration[file].type + "/" + ".js");
}
fileList = uniq(fileList);
return fileList;
}
fileList = uniq(fileList);
return fileList;
}

/**
* Ask use a few questions on command prompt
* @returns {Promise} The promise with the result of the prompt
*/
function promptUser() {
return inquirer.prompt([
{
type: "list",
name: "env",
message: "Where does your code run?",
default: ["browser"],
choices: [
{ name: "Browser", value: "browser" },
{ name: "Node", value: "node" }
]
},
{
type: "checkbox",
name: "images",
message: "Which ImageTypes should be supported?",
default: ["jpeg_support", 'bmp_support', 'gif_support', 'webp_support'],
choices: [
{ name: "Jpeg", value: "jpeg_support" },
{ name: "Bmp", value: "bmp_support" },
{ name: "Gif", value: "gif_support" },
{ name: "WebP", value: "webp_support" }
]
},
{
type: "checkbox",
name: "modules",
message: "Additional Modules",
default: ['acroform', 'annotations', 'arabic', 'autoprint', 'context2d',
'fileloading', 'filters', 'html', 'javascript', 'outline',
'setlanguage', 'svg', 'total_pages', 'utf8', 'viewerpreferences',
'xmp_metadata'
],
choices: [
{ name: "Acroform", value: "acroform" },
{ name: "Annotations", value: "annotations" },
{ name: "Arabic Parser", value: "arabic" },
{ name: "Autoprint", value: "autoprint" },
{ name: "Context2d", value: "context2d" },
{ name: "File Loading", value: "fileloading" },
{ name: "Filters", value: "filters" },
{ name: "HTML", value: "html" },
{ name: "Javascript", value: "javascript" },
{ name: "Outline", value: "outline" },
{ name: "Language-Tagging", value: "setlanguage" },
{ name: "SVG", value: "svg" },
{ name: "TotalPages", value: "total_pages" },
{ name: "Unicode", value: "utf8" },
{ name: "ViewerPreferences", value: "viewerpreferences" },
{ name: "XMP Metadata", value: "xmp_metadata" }
]
}
]).then(result => {
console.log(generateFileList([...result.images, ...result.modules]));
return inquirer
.prompt([
{
type: "list",
name: "env",
message: "Where does your code run?",
default: ["browser"],
choices: [
{ name: "Browser", value: "browser" },
{ name: "Node", value: "node" }
]
},
{
type: "checkbox",
name: "images",
message: "Which ImageTypes should be supported?",
default: ["jpeg_support", "bmp_support", "gif_support", "webp_support"],
choices: [
{ name: "Jpeg", value: "jpeg_support" },
{ name: "Bmp", value: "bmp_support" },
{ name: "Gif", value: "gif_support" },
{ name: "WebP", value: "webp_support" }
]
},
{
type: "checkbox",
name: "modules",
message: "Additional Modules",
default: [
"acroform",
"annotations",
"arabic",
"autoprint",
"context2d",
"fileloading",
"filters",
"html",
"javascript",
"outline",
"setlanguage",
"svg",
"total_pages",
"utf8",
"viewerpreferences",
"xmp_metadata"
],
choices: [
{ name: "Acroform", value: "acroform" },
{ name: "Annotations", value: "annotations" },
{ name: "Arabic Parser", value: "arabic" },
{ name: "Autoprint", value: "autoprint" },
{ name: "Context2d", value: "context2d" },
{ name: "File Loading", value: "fileloading" },
{ name: "Filters", value: "filters" },
{ name: "HTML", value: "html" },
{ name: "Javascript", value: "javascript" },
{ name: "Outline", value: "outline" },
{ name: "Language-Tagging", value: "setlanguage" },
{ name: "SVG", value: "svg" },
{ name: "TotalPages", value: "total_pages" },
{ name: "Unicode", value: "utf8" },
{ name: "ViewerPreferences", value: "viewerpreferences" },
{ name: "XMP Metadata", value: "xmp_metadata" }
]
}
])
.then(result => {
console.log(generateFileList([...result.images, ...result.modules]));
});
}

promptUser();
promptUser();
7 changes: 3 additions & 4 deletions deletedocs.js
@@ -1,6 +1,5 @@
const deleteFolder = require('folder-delete');
const deleteFolder = require("folder-delete");

try {
deleteFolder('docs', {debugLog: false});
} catch (e) {
}
deleteFolder("docs", { debugLog: false });
} catch (e) {}
12 changes: 10 additions & 2 deletions examples/PDF.js/build/pdf.js
Expand Up @@ -18934,7 +18934,11 @@
groupCtx.mozCurrentTransformInverse;
copyCtxState(currentCtx, groupCtx);
this.ctx = groupCtx;
this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
this.setGState([
["BM", "source-over"],
["ca", 1],
["CA", 1]
]);
this.groupStack.push(currentCtx);
this.groupLevel++;
},
Expand Down Expand Up @@ -19912,7 +19916,11 @@

copyCtxState(currentCtx, groupCtx);
this.ctx = groupCtx;
this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
this.setGState([
["BM", "source-over"],
["ca", 1],
["CA", 1]
]);
this.groupStack.push(currentCtx);
this.groupLevel++;
this.current.activeSMask = null;
Expand Down
5 changes: 4 additions & 1 deletion examples/PDF.js/build/pdf.worker.js
Expand Up @@ -46761,7 +46761,10 @@
if (Array.isArray(arr)) return arr;
}

var PRIVATE_USE_AREAS = [[0xe000, 0xf8ff], [0x100000, 0x10fffd]];
var PRIVATE_USE_AREAS = [
[0xe000, 0xf8ff],
[0x100000, 0x10fffd]
];
var PDF_GLYPH_SPACE_UNITS = 1000;
var SEAC_ANALYSIS_ENABLED = true;
exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED;
Expand Down
8 changes: 4 additions & 4 deletions examples/PDF.js/web/viewer.js
Expand Up @@ -4886,11 +4886,11 @@
}

function getPDFFileNameFromURL(url) {
let downloadName = (window.location.search).split('=')[2];
let downloadName = window.location.search.split("=")[2];
var defaultFilename = downloadName || "document.pdf";
// arguments.length > 1 && arguments[1] !== undefined
// ? arguments[1]
// : "document.pdf";
// arguments.length > 1 && arguments[1] !== undefined
// ? arguments[1]
// : "document.pdf";

if (typeof url !== "string") {
return defaultFilename;
Expand Down
7,130 changes: 7,128 additions & 2 deletions examples/css/bootstrap.min.css

Large diffs are not rendered by default.

0 comments on commit 1f23740

Please sign in to comment.