Skip to content

Commit 7f5008b

Browse files
hackerrdaveMrRio
authored andcommitted
use npm packages instead of github for file-saver and adler32cs (#1432)
1 parent daacf2c commit 7f5008b

File tree

4 files changed

+62
-142
lines changed

4 files changed

+62
-142
lines changed

dist/jspdf.debug.js

Lines changed: 57 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ var asyncGenerator = function () {
129129

130130
/** @preserve
131131
* jsPDF - PDF Document creation from JavaScript
132-
* Version 1.3.4 Built on 2017-09-11T11:23:37.340Z
133-
* CommitID a9c6ecb794
132+
* Version 1.3.4 Built on 2017-09-11T18:13:05.073Z
133+
* CommitID daacf2c6e2
134134
*
135135
* Copyright (c) 2010-2016 James Hall <[email protected]>, https://github.com/MrRio/jsPDF
136136
* 2010 Aaron Spike, https://github.com/acspike
@@ -3009,7 +3009,8 @@ AcroForm.Appearance.internal = {
30093009
var cross = {
30103010
x1: { // upperLeft
30113011
x: (width - a) / 2,
3012-
y: (height - a) / 2 + a },
3012+
y: (height - a) / 2 + a //height - borderPadding
3013+
},
30133014
x2: { // lowerRight
30143015
x: (width - a) / 2 + a,
30153016
y: (height - a) / 2 //borderPadding
@@ -3020,7 +3021,8 @@ AcroForm.Appearance.internal = {
30203021
},
30213022
x4: { // upperRight
30223023
x: (width - a) / 2 + a,
3023-
y: (height - a) / 2 + a }
3024+
y: (height - a) / 2 + a //height - borderPadding
3025+
}
30243026
};
30253027

30263028
return cross;
@@ -9343,24 +9345,24 @@ MIT license.
93439345
'Times-Italic': encodingBlock
93449346
// , 'Symbol'
93459347
// , 'ZapfDingbats'
9346-
} }
9347-
/**
9348-
Resources:
9349-
Font metrics data is reprocessed derivative of contents of
9350-
"Font Metrics for PDF Core 14 Fonts" package, which exhibits the following copyright and license:
9351-
9352-
Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.
9353-
9354-
This file and the 14 PostScript(R) AFM files it accompanies may be used,
9355-
copied, and distributed for any purpose and without charge, with or without
9356-
modification, provided that all copyright notices are retained; that the AFM
9357-
files are not distributed without this file; that all modifications to this
9358-
file or any of the AFM files are prominently noted in the modified file(s);
9359-
and that this paragraph is not modified. Adobe Systems has no responsibility
9360-
or obligation to support the use of the AFM files.
9361-
9362-
*/
9363-
,
9348+
}
9349+
/**
9350+
Resources:
9351+
Font metrics data is reprocessed derivative of contents of
9352+
"Font Metrics for PDF Core 14 Fonts" package, which exhibits the following copyright and license:
9353+
9354+
Copyright (c) 1989, 1990, 1991, 1992, 1993, 1997 Adobe Systems Incorporated. All Rights Reserved.
9355+
9356+
This file and the 14 PostScript(R) AFM files it accompanies may be used,
9357+
copied, and distributed for any purpose and without charge, with or without
9358+
modification, provided that all copyright notices are retained; that the AFM
9359+
files are not distributed without this file; that all modifications to this
9360+
file or any of the AFM files are prominently noted in the modified file(s);
9361+
and that this paragraph is not modified. Adobe Systems has no responsibility
9362+
or obligation to support the use of the AFM files.
9363+
9364+
*/
9365+
},
93649366
fontMetrics = { 'Unicode': {
93659367
// all sizing numbers are n/fontMetricsFractionOf = one font size unit
93669368
// this means that if fontMetricsFractionOf = 1000, and letter A's width is 476, it's
@@ -9882,7 +9884,8 @@ Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
98829884

98839885
/* FileSaver.js
98849886
* A saveAs() FileSaver implementation.
9885-
* 1.1.20151003
9887+
* 1.3.2
9888+
* 2016-06-16 18:25:19
98869889
*
98879890
* By Eli Grey, http://eligrey.com
98889891
* License: MIT
@@ -9897,7 +9900,7 @@ Copyright (c) 2012 Willow Systems Corporation, willow-systems.com
98979900
var saveAs = saveAs || (function(view) {
98989901
"use strict";
98999902
// IE <10 is explicitly unsupported
9900-
if (typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
9903+
if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
99019904
return;
99029905
}
99039906
var
@@ -9912,20 +9915,16 @@ var saveAs = saveAs || (function(view) {
99129915
var event = new MouseEvent("click");
99139916
node.dispatchEvent(event);
99149917
}
9915-
, is_safari = /Version\/[\d\.]+.*Safari/.test(navigator.userAgent)
9916-
, webkit_req_fs = view.webkitRequestFileSystem
9917-
, req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem
9918+
, is_safari = /constructor/i.test(view.HTMLElement) || view.safari
9919+
, is_chrome_ios =/CriOS\/[\d]+/.test(navigator.userAgent)
99189920
, throw_outside = function(ex) {
99199921
(view.setImmediate || view.setTimeout)(function() {
99209922
throw ex;
99219923
}, 0);
99229924
}
99239925
, force_saveable_type = "application/octet-stream"
9924-
, fs_min_size = 0
9925-
// See https://code.google.com/p/chromium/issues/detail?id=375297#c7 and
9926-
// https://github.com/eligrey/FileSaver.js/commit/485930a#commitcomment-8768047
9927-
// for the reasoning behind the timeout and revocation flow
9928-
, arbitrary_revoke_timeout = 500 // in ms
9926+
// the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to
9927+
, arbitrary_revoke_timeout = 1000 * 40 // in ms
99299928
, revoke = function(file) {
99309929
var revoker = function() {
99319930
if (typeof file === "string") { // file is an object URL
@@ -9934,11 +9933,7 @@ var saveAs = saveAs || (function(view) {
99349933
file.remove();
99359934
}
99369935
};
9937-
if (view.chrome) {
9938-
revoker();
9939-
} else {
9940-
setTimeout(revoker, arbitrary_revoke_timeout);
9941-
}
9936+
setTimeout(revoker, arbitrary_revoke_timeout);
99429937
}
99439938
, dispatch = function(filesaver, event_types, event) {
99449939
event_types = [].concat(event_types);
@@ -9956,8 +9951,9 @@ var saveAs = saveAs || (function(view) {
99569951
}
99579952
, auto_bom = function(blob) {
99589953
// prepend BOM for UTF-8 XML and text/* types (including HTML)
9954+
// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
99599955
if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
9960-
return new Blob(["\ufeff", blob], {type: blob.type});
9956+
return new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type});
99619957
}
99629958
return blob;
99639959
}
@@ -9969,20 +9965,21 @@ var saveAs = saveAs || (function(view) {
99699965
var
99709966
filesaver = this
99719967
, type = blob.type
9972-
, blob_changed = false
9968+
, force = type === force_saveable_type
99739969
, object_url
9974-
, target_view
99759970
, dispatch_all = function() {
99769971
dispatch(filesaver, "writestart progress write writeend".split(" "));
99779972
}
99789973
// on any filesys errors revert to saving with object URLs
99799974
, fs_error = function() {
9980-
if (target_view && is_safari && typeof FileReader !== "undefined") {
9975+
if ((is_chrome_ios || (force && is_safari)) && view.FileReader) {
99819976
// Safari doesn't allow downloading of blob urls
99829977
var reader = new FileReader();
99839978
reader.onloadend = function() {
9984-
var base64Data = reader.result;
9985-
target_view.location.href = "data:attachment/file" + base64Data.slice(base64Data.search(/[,;]/));
9979+
var url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;');
9980+
var popup = view.open(url, '_blank');
9981+
if(!popup) view.location.href = url;
9982+
url=undefined; // release reference before dispatching
99869983
filesaver.readyState = filesaver.DONE;
99879984
dispatch_all();
99889985
};
@@ -9991,35 +9988,24 @@ var saveAs = saveAs || (function(view) {
99919988
return;
99929989
}
99939990
// don't create more object URLs than needed
9994-
if (blob_changed || !object_url) {
9991+
if (!object_url) {
99959992
object_url = get_URL().createObjectURL(blob);
99969993
}
9997-
if (target_view) {
9998-
target_view.location.href = object_url;
9994+
if (force) {
9995+
view.location.href = object_url;
99999996
} else {
10000-
var new_tab = view.open(object_url, "_blank");
10001-
if (new_tab == undefined && is_safari) {
10002-
//Apple do not allow window.open, see http://bit.ly/1kZffRI
9997+
var opened = view.open(object_url, "_blank");
9998+
if (!opened) {
9999+
// Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html
1000310000
view.location.href = object_url;
1000410001
}
1000510002
}
1000610003
filesaver.readyState = filesaver.DONE;
1000710004
dispatch_all();
1000810005
revoke(object_url);
10009-
}
10010-
, abortable = function(func) {
10011-
return function() {
10012-
if (filesaver.readyState !== filesaver.DONE) {
10013-
return func.apply(this, arguments);
10014-
}
10015-
};
10016-
}
10017-
, create_if_not_found = {create: true, exclusive: false}
10018-
, slice;
10006+
};
1001910007
filesaver.readyState = filesaver.INIT;
10020-
if (!name) {
10021-
name = "download";
10022-
}
10008+
1002310009
if (can_use_save_link) {
1002410010
object_url = get_URL().createObjectURL(blob);
1002510011
setTimeout(function() {
@@ -10032,92 +10018,26 @@ var saveAs = saveAs || (function(view) {
1003210018
});
1003310019
return;
1003410020
}
10035-
// Object and web filesystem URLs have a problem saving in Google Chrome when
10036-
// viewed in a tab, so I force save with application/octet-stream
10037-
// http://code.google.com/p/chromium/issues/detail?id=91158
10038-
// Update: Google errantly closed 91158, I submitted it again:
10039-
// https://code.google.com/p/chromium/issues/detail?id=389642
10040-
if (view.chrome && type && type !== force_saveable_type) {
10041-
slice = blob.slice || blob.webkitSlice;
10042-
blob = slice.call(blob, 0, blob.size, force_saveable_type);
10043-
blob_changed = true;
10044-
}
10045-
// Since I can't be sure that the guessed media type will trigger a download
10046-
// in WebKit, I append .download to the filename.
10047-
// https://bugs.webkit.org/show_bug.cgi?id=65440
10048-
if (webkit_req_fs && name !== "download") {
10049-
name += ".download";
10050-
}
10051-
if (type === force_saveable_type || webkit_req_fs) {
10052-
target_view = view;
10053-
}
10054-
if (!req_fs) {
10055-
fs_error();
10056-
return;
10057-
}
10058-
fs_min_size += blob.size;
10059-
req_fs(view.TEMPORARY, fs_min_size, abortable(function(fs) {
10060-
fs.root.getDirectory("saved", create_if_not_found, abortable(function(dir) {
10061-
var save = function() {
10062-
dir.getFile(name, create_if_not_found, abortable(function(file) {
10063-
file.createWriter(abortable(function(writer) {
10064-
writer.onwriteend = function(event) {
10065-
target_view.location.href = file.toURL();
10066-
filesaver.readyState = filesaver.DONE;
10067-
dispatch(filesaver, "writeend", event);
10068-
revoke(file);
10069-
};
10070-
writer.onerror = function() {
10071-
var error = writer.error;
10072-
if (error.code !== error.ABORT_ERR) {
10073-
fs_error();
10074-
}
10075-
};
10076-
"writestart progress write abort".split(" ").forEach(function(event) {
10077-
writer["on" + event] = filesaver["on" + event];
10078-
});
10079-
writer.write(blob);
10080-
filesaver.abort = function() {
10081-
writer.abort();
10082-
filesaver.readyState = filesaver.DONE;
10083-
};
10084-
filesaver.readyState = filesaver.WRITING;
10085-
}), fs_error);
10086-
}), fs_error);
10087-
};
10088-
dir.getFile(name, {create: false}, abortable(function(file) {
10089-
// delete file if it already exists
10090-
file.remove();
10091-
save();
10092-
}), abortable(function(ex) {
10093-
if (ex.code === ex.NOT_FOUND_ERR) {
10094-
save();
10095-
} else {
10096-
fs_error();
10097-
}
10098-
}));
10099-
}), fs_error);
10100-
}), fs_error);
10021+
10022+
fs_error();
1010110023
}
1010210024
, FS_proto = FileSaver.prototype
1010310025
, saveAs = function(blob, name, no_auto_bom) {
10104-
return new FileSaver(blob, name, no_auto_bom);
10026+
return new FileSaver(blob, name || blob.name || "download", no_auto_bom);
1010510027
};
1010610028
// IE 10+ (native saveAs)
1010710029
if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) {
1010810030
return function(blob, name, no_auto_bom) {
10031+
name = name || blob.name || "download";
10032+
1010910033
if (!no_auto_bom) {
1011010034
blob = auto_bom(blob);
1011110035
}
10112-
return navigator.msSaveOrOpenBlob(blob, name || "download");
10036+
return navigator.msSaveOrOpenBlob(blob, name);
1011310037
};
1011410038
}
1011510039

10116-
FS_proto.abort = function() {
10117-
var filesaver = this;
10118-
filesaver.readyState = filesaver.DONE;
10119-
dispatch(filesaver, "abort");
10120-
};
10040+
FS_proto.abort = function(){};
1012110041
FS_proto.readyState = FS_proto.INIT = 0;
1012210042
FS_proto.WRITING = 1;
1012310043
FS_proto.DONE = 2;
@@ -10143,8 +10063,8 @@ var saveAs = saveAs || (function(view) {
1014310063

1014410064
if (typeof module !== "undefined" && module.exports) {
1014510065
module.exports.saveAs = saveAs;
10146-
} else if ((typeof define !== "undefined" && define !== null) && (define.amd != null)) {
10147-
define([], function() {
10066+
} else if ((typeof define !== "undefined" && define !== null) && (define.amd !== null)) {
10067+
define("FileSaver.js", function() {
1014810068
return saveAs;
1014910069
});
1015010070
}

0 commit comments

Comments
 (0)