Browse Source

PDF.js version 1.9.493 - See mozilla/pdf.js@bad3203fdad1ee0bee3e30d31912021c6a0b0676

master v1.9.493
pdfjsbot 7 years ago
parent
commit
81b3df2b25
  1. 2
      bower.json
  2. 814
      build/pdf.combined.js
  3. 2
      build/pdf.combined.js.map
  4. 692
      build/pdf.js
  5. 2
      build/pdf.js.map
  6. 2
      build/pdf.min.js
  7. 15
      build/pdf.worker.js
  8. 2
      build/pdf.worker.js.map
  9. 2
      build/pdf.worker.min.js
  10. 4
      lib/display/api.js
  11. 275
      lib/display/fetch_stream.js
  12. 4
      lib/display/global.js
  13. 11
      lib/display/network.js
  14. 18
      lib/display/network_utils.js
  15. 7
      lib/pdf.js
  16. 4
      lib/pdf.worker.js
  17. 11
      lib/shared/util.js
  18. 9
      lib/test/unit/jasmine-boot.js
  19. 2
      package.json

2
bower.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "pdfjs-dist",
"version": "1.9.491",
"version": "1.9.493",
"main": [
"build/pdf.js",
"build/pdf.worker.js"

814
build/pdf.combined.js

File diff suppressed because it is too large Load Diff

2
build/pdf.combined.js.map

File diff suppressed because one or more lines are too long

692
build/pdf.js

File diff suppressed because it is too large Load Diff

2
build/pdf.js.map

File diff suppressed because one or more lines are too long

2
build/pdf.min.js vendored

File diff suppressed because one or more lines are too long

15
build/pdf.worker.js vendored

@ -1029,6 +1029,12 @@ function wrapReason(reason) { @@ -1029,6 +1029,12 @@ function wrapReason(reason) {
return new UnknownErrorException(reason.message, reason.details);
}
}
function makeReasonSerializable(reason) {
if (!(reason instanceof Error) || reason instanceof AbortException || reason instanceof MissingPDFException || reason instanceof UnexpectedResponseException || reason instanceof UnknownErrorException) {
return reason;
}
return new UnknownErrorException(reason.message, reason.toString());
}
function resolveOrReject(capability, success, reason) {
if (success) {
capability.resolve();
@ -1088,15 +1094,12 @@ function MessageHandler(sourceName, targetName, comObj) { @@ -1088,15 +1094,12 @@ function MessageHandler(sourceName, targetName, comObj) {
data: result
});
}, function (reason) {
if (reason instanceof Error) {
reason = reason + '';
}
comObj.postMessage({
sourceName: _sourceName,
targetName: _targetName,
isReply: true,
callbackId: data.callbackId,
error: reason
error: makeReasonSerializable(reason)
});
});
} else if (data.streamId) {
@ -42149,8 +42152,8 @@ exports.Type1Parser = Type1Parser; @@ -42149,8 +42152,8 @@ exports.Type1Parser = Type1Parser;
"use strict";
var pdfjsVersion = '1.9.491';
var pdfjsBuild = 'd734b3d1';
var pdfjsVersion = '1.9.493';
var pdfjsBuild = 'bad3203f';
var pdfjsCoreWorker = __w_pdfjs_require__(61);
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;

2
build/pdf.worker.js.map vendored

File diff suppressed because one or more lines are too long

2
build/pdf.worker.min.js vendored

File diff suppressed because one or more lines are too long

4
lib/display/api.js

@ -1581,8 +1581,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -1581,8 +1581,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}();
var version, build;
{
exports.version = version = '1.9.491';
exports.build = build = 'd734b3d1';
exports.version = version = '1.9.493';
exports.build = build = 'bad3203f';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;

275
lib/display/fetch_stream.js

@ -0,0 +1,275 @@ @@ -0,0 +1,275 @@
/* Copyright 2017 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PDFFetchStream = undefined;
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _util = require('../shared/util');
var _network_utils = require('./network_utils');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function createFetchOptions(headers, withCredentials) {
return {
method: 'GET',
headers: headers,
mode: 'cors',
credentials: withCredentials ? 'omit' : 'include',
redirect: 'follow'
};
}
var PDFFetchStream = function () {
function PDFFetchStream(options) {
_classCallCheck(this, PDFFetchStream);
this.options = options;
this.source = options.source;
this.isHttp = /^https?:/i.test(this.source.url);
this.httpHeaders = this.isHttp && this.source.httpHeaders || {};
this._fullRequestReader = null;
this._rangeRequestReaders = [];
}
_createClass(PDFFetchStream, [{
key: 'getFullReader',
value: function getFullReader() {
(0, _util.assert)(!this._fullRequestReader);
this._fullRequestReader = new PDFFetchStreamReader(this);
return this._fullRequestReader;
}
}, {
key: 'getRangeReader',
value: function getRangeReader(begin, end) {
var reader = new PDFFetchStreamRangeReader(this, begin, end);
this._rangeRequestReaders.push(reader);
return reader;
}
}, {
key: 'cancelAllRequests',
value: function cancelAllRequests(reason) {
if (this._fullRequestReader) {
this._fullRequestReader.cancel(reason);
}
var readers = this._rangeRequestReaders.slice(0);
readers.forEach(function (reader) {
reader.cancel(reason);
});
}
}]);
return PDFFetchStream;
}();
var PDFFetchStreamReader = function () {
function PDFFetchStreamReader(stream) {
var _this = this;
_classCallCheck(this, PDFFetchStreamReader);
this._stream = stream;
this._reader = null;
this._loaded = 0;
this._withCredentials = stream.source.withCredentials;
this._contentLength = this._stream.source.length;
this._headersCapability = (0, _util.createPromiseCapability)();
this._disableRange = this._stream.options.disableRange;
this._rangeChunkSize = this._stream.source.rangeChunkSize;
if (!this._rangeChunkSize && !this._disableRange) {
this._disableRange = true;
}
this._isRangeSupported = !this._stream.options.disableRange;
this._isStreamingSupported = !this._stream.source.disableStream;
this._headers = new Headers();
for (var property in this._stream.httpHeaders) {
var value = this._stream.httpHeaders[property];
if (typeof value === 'undefined') {
continue;
}
this._headers.append(property, value);
}
var url = this._stream.source.url;
fetch(url, createFetchOptions(this._headers, this._withCredentials)).then(function (response) {
if (!(0, _network_utils.validateResponseStatus)(response.status, _this._stream.isHttp)) {
throw (0, _network_utils.createResponseStatusError)(response.status, url);
}
_this._headersCapability.resolve();
_this._reader = response.body.getReader();
var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({
getResponseHeader: function getResponseHeader(name) {
return response.headers.get(name);
},
isHttp: _this._stream.isHttp,
rangeChunkSize: _this._rangeChunkSize,
disableRange: _this._disableRange
}),
allowRangeRequests = _validateRangeRequest.allowRangeRequests,
suggestedLength = _validateRangeRequest.suggestedLength;
_this._contentLength = suggestedLength;
_this._isRangeSupported = allowRangeRequests;
}).catch(this._headersCapability.reject);
this.onProgress = null;
}
_createClass(PDFFetchStreamReader, [{
key: 'read',
value: function read() {
var _this2 = this;
return this._headersCapability.promise.then(function () {
return _this2._reader.read().then(function (_ref) {
var value = _ref.value,
done = _ref.done;
if (done) {
return Promise.resolve({
value: value,
done: done
});
}
_this2._loaded += value.byteLength;
if (_this2.onProgress) {
_this2.onProgress({
loaded: _this2._loaded,
total: _this2._contentLength
});
}
var buffer = new Uint8Array(value).buffer;
return Promise.resolve({
value: buffer,
done: false
});
});
});
}
}, {
key: 'cancel',
value: function cancel(reason) {
if (this._reader) {
this._reader.cancel(reason);
}
}
}, {
key: 'headersReady',
get: function get() {
return this._headersCapability.promise;
}
}, {
key: 'contentLength',
get: function get() {
return this._contentLength;
}
}, {
key: 'isRangeSupported',
get: function get() {
return this._isRangeSupported;
}
}, {
key: 'isStreamingSupported',
get: function get() {
return this._isStreamingSupported;
}
}]);
return PDFFetchStreamReader;
}();
var PDFFetchStreamRangeReader = function () {
function PDFFetchStreamRangeReader(stream, begin, end) {
var _this3 = this;
_classCallCheck(this, PDFFetchStreamRangeReader);
this._stream = stream;
this._reader = null;
this._loaded = 0;
this._withCredentials = stream.source.withCredentials;
this._readCapability = (0, _util.createPromiseCapability)();
this._isStreamingSupported = !stream.source.disableStream;
this._headers = new Headers();
for (var property in this._stream.httpHeaders) {
var value = this._stream.httpHeaders[property];
if (typeof value === 'undefined') {
continue;
}
this._headers.append(property, value);
}
var rangeStr = begin + '-' + (end - 1);
this._headers.append('Range', 'bytes=' + rangeStr);
var url = this._stream.source.url;
fetch(url, createFetchOptions(this._headers, this._withCredentials)).then(function (response) {
if (!(0, _network_utils.validateResponseStatus)(response.status, _this3._stream.isHttp)) {
throw (0, _network_utils.createResponseStatusError)(response.status, url);
}
_this3._readCapability.resolve();
_this3._reader = response.body.getReader();
});
this.onProgress = null;
}
_createClass(PDFFetchStreamRangeReader, [{
key: 'read',
value: function read() {
var _this4 = this;
return this._readCapability.promise.then(function () {
return _this4._reader.read().then(function (_ref2) {
var value = _ref2.value,
done = _ref2.done;
if (done) {
return Promise.resolve({
value: value,
done: done
});
}
_this4._loaded += value.byteLength;
if (_this4.onProgress) {
_this4.onProgress({ loaded: _this4._loaded });
}
var buffer = new Uint8Array(value).buffer;
return Promise.resolve({
value: buffer,
done: false
});
});
});
}
}, {
key: 'cancel',
value: function cancel(reason) {
if (this._reader) {
this._reader.cancel(reason);
}
}
}, {
key: 'isStreamingSupported',
get: function get() {
return this._isStreamingSupported;
}
}]);
return PDFFetchStreamRangeReader;
}();
exports.PDFFetchStream = PDFFetchStream;

4
lib/display/global.js

@ -45,8 +45,8 @@ if (!_global_scope2.default.PDFJS) { @@ -45,8 +45,8 @@ if (!_global_scope2.default.PDFJS) {
}
var PDFJS = _global_scope2.default.PDFJS;
{
PDFJS.version = '1.9.491';
PDFJS.build = 'd734b3d1';
PDFJS.version = '1.9.493';
PDFJS.build = 'bad3203f';
}
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {

11
lib/display/network.js

@ -21,12 +21,12 @@ exports.NetworkManager = exports.PDFNetworkStream = undefined; @@ -21,12 +21,12 @@ exports.NetworkManager = exports.PDFNetworkStream = undefined;
var _util = require('../shared/util');
var _network_utils = require('./network_utils');
var _global_scope = require('../shared/global_scope');
var _global_scope2 = _interopRequireDefault(_global_scope);
var _network_utils = require('./network_utils');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
;
@ -341,12 +341,7 @@ PDFNetworkStreamFullRequestReader.prototype = { @@ -341,12 +341,7 @@ PDFNetworkStreamFullRequestReader.prototype = {
},
_onError: function PDFNetworkStreamFullRequestReader_onError(status) {
var url = this._url;
var exception;
if (status === 404 || status === 0 && /^file:/.test(url)) {
exception = new _util.MissingPDFException('Missing PDF "' + url + '".');
} else {
exception = new _util.UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
}
var exception = (0, _network_utils.createResponseStatusError)(status, url);
this._storedError = exception;
this._headersReceivedCapability.reject(exception);
this._requests.forEach(function (requestCapability) {

18
lib/display/network_utils.js

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.validateRangeRequestCapabilities = undefined;
exports.validateResponseStatus = exports.validateRangeRequestCapabilities = exports.createResponseStatusError = undefined;
var _util = require('../shared/util');
@ -54,4 +54,18 @@ function validateRangeRequestCapabilities(_ref) { @@ -54,4 +54,18 @@ function validateRangeRequestCapabilities(_ref) {
returnValues.allowRangeRequests = true;
return returnValues;
}
exports.validateRangeRequestCapabilities = validateRangeRequestCapabilities;
function createResponseStatusError(status, url) {
if (status === 404 || status === 0 && /^file:/.test(url)) {
return new _util.MissingPDFException('Missing PDF "' + url + '".');
}
return new _util.UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
}
function validateResponseStatus(status, isHttp) {
if (!isHttp) {
return status === 0;
}
return status === 200 || status === 206;
}
exports.createResponseStatusError = createResponseStatusError;
exports.validateRangeRequestCapabilities = validateRangeRequestCapabilities;
exports.validateResponseStatus = validateResponseStatus;

7
lib/pdf.js

@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
*/
'use strict';
var pdfjsVersion = '1.9.491';
var pdfjsBuild = 'd734b3d1';
var pdfjsVersion = '1.9.493';
var pdfjsBuild = 'bad3203f';
var pdfjsSharedUtil = require('./shared/util.js');
var pdfjsDisplayGlobal = require('./display/global.js');
var pdfjsDisplayAPI = require('./display/api.js');
@ -27,6 +27,9 @@ var pdfjsDisplaySVG = require('./display/svg.js'); @@ -27,6 +27,9 @@ var pdfjsDisplaySVG = require('./display/svg.js');
if (pdfjsSharedUtil.isNodeJS()) {
var PDFNodeStream = require('./display/node_stream.js').PDFNodeStream;
pdfjsDisplayAPI.setPDFNetworkStreamClass(PDFNodeStream);
} else if (typeof Response !== 'undefined' && 'body' in Response.prototype) {
var PDFFetchStream = require('./display/fetch_stream.js').PDFFetchStream;
pdfjsDisplayAPI.setPDFNetworkStreamClass(PDFFetchStream);
} else {
var PDFNetworkStream = require('./display/network.js').PDFNetworkStream;
pdfjsDisplayAPI.setPDFNetworkStreamClass(PDFNetworkStream);

4
lib/pdf.worker.js vendored

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
*/
'use strict';
var pdfjsVersion = '1.9.491';
var pdfjsBuild = 'd734b3d1';
var pdfjsVersion = '1.9.493';
var pdfjsBuild = 'bad3203f';
var pdfjsCoreWorker = require('./core/worker.js');
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;

11
lib/shared/util.js

@ -945,6 +945,12 @@ function wrapReason(reason) { @@ -945,6 +945,12 @@ function wrapReason(reason) {
return new UnknownErrorException(reason.message, reason.details);
}
}
function makeReasonSerializable(reason) {
if (!(reason instanceof Error) || reason instanceof AbortException || reason instanceof MissingPDFException || reason instanceof UnexpectedResponseException || reason instanceof UnknownErrorException) {
return reason;
}
return new UnknownErrorException(reason.message, reason.toString());
}
function resolveOrReject(capability, success, reason) {
if (success) {
capability.resolve();
@ -1004,15 +1010,12 @@ function MessageHandler(sourceName, targetName, comObj) { @@ -1004,15 +1010,12 @@ function MessageHandler(sourceName, targetName, comObj) {
data: result
});
}, function (reason) {
if (reason instanceof Error) {
reason = reason + '';
}
comObj.postMessage({
sourceName: _sourceName,
targetName: _targetName,
isReply: true,
callbackId: data.callbackId,
error: reason
error: makeReasonSerializable(reason)
});
});
} else if (data.streamId) {

9
lib/test/unit/jasmine-boot.js

@ -15,13 +15,18 @@ @@ -15,13 +15,18 @@
'use strict';
function initializePDFJS(callback) {
Promise.all(['pdfjs/display/global', 'pdfjs/display/api', 'pdfjs/display/network', 'pdfjs-test/unit/annotation_spec', 'pdfjs-test/unit/api_spec', 'pdfjs-test/unit/bidi_spec', 'pdfjs-test/unit/cff_parser_spec', 'pdfjs-test/unit/cmap_spec', 'pdfjs-test/unit/colorspace_spec', 'pdfjs-test/unit/crypto_spec', 'pdfjs-test/unit/custom_spec', 'pdfjs-test/unit/display_svg_spec', 'pdfjs-test/unit/document_spec', 'pdfjs-test/unit/dom_utils_spec', 'pdfjs-test/unit/evaluator_spec', 'pdfjs-test/unit/fonts_spec', 'pdfjs-test/unit/function_spec', 'pdfjs-test/unit/metadata_spec', 'pdfjs-test/unit/murmurhash3_spec', 'pdfjs-test/unit/network_spec', 'pdfjs-test/unit/parser_spec', 'pdfjs-test/unit/primitives_spec', 'pdfjs-test/unit/stream_spec', 'pdfjs-test/unit/type1_parser_spec', 'pdfjs-test/unit/ui_utils_spec', 'pdfjs-test/unit/unicode_spec', 'pdfjs-test/unit/util_spec', 'pdfjs-test/unit/util_stream_spec'].map(function (moduleName) {
Promise.all(['pdfjs/display/global', 'pdfjs/display/api', 'pdfjs/display/network', 'pdfjs/display/fetch_stream', 'pdfjs-test/unit/annotation_spec', 'pdfjs-test/unit/api_spec', 'pdfjs-test/unit/bidi_spec', 'pdfjs-test/unit/cff_parser_spec', 'pdfjs-test/unit/cmap_spec', 'pdfjs-test/unit/colorspace_spec', 'pdfjs-test/unit/crypto_spec', 'pdfjs-test/unit/custom_spec', 'pdfjs-test/unit/display_svg_spec', 'pdfjs-test/unit/document_spec', 'pdfjs-test/unit/dom_utils_spec', 'pdfjs-test/unit/evaluator_spec', 'pdfjs-test/unit/fonts_spec', 'pdfjs-test/unit/function_spec', 'pdfjs-test/unit/metadata_spec', 'pdfjs-test/unit/murmurhash3_spec', 'pdfjs-test/unit/network_spec', 'pdfjs-test/unit/parser_spec', 'pdfjs-test/unit/primitives_spec', 'pdfjs-test/unit/stream_spec', 'pdfjs-test/unit/type1_parser_spec', 'pdfjs-test/unit/ui_utils_spec', 'pdfjs-test/unit/unicode_spec', 'pdfjs-test/unit/util_spec', 'pdfjs-test/unit/util_stream_spec'].map(function (moduleName) {
return SystemJS.import(moduleName);
})).then(function (modules) {
var displayGlobal = modules[0];
var displayApi = modules[1];
var PDFNetworkStream = modules[2].PDFNetworkStream;
displayApi.setPDFNetworkStreamClass(PDFNetworkStream);
var PDFFetchStream = modules[3].PDFFetchStream;
if (typeof Response !== 'undefined' && 'body' in Response.prototype) {
displayApi.setPDFNetworkStreamClass(PDFFetchStream);
} else {
displayApi.setPDFNetworkStreamClass(PDFNetworkStream);
}
displayGlobal.PDFJS.workerSrc = '../../build/generic/build/pdf.worker.js';
displayGlobal.PDFJS.pdfjsNext = true;
callback();

2
package.json

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
{
"name": "pdfjs-dist",
"version": "1.9.491",
"version": "1.9.493",
"main": "build/pdf.js",
"description": "Generic build of Mozilla's PDF.js library.",
"keywords": [

Loading…
Cancel
Save