|
|
@ -42,6 +42,8 @@ var _global_scope = require('../shared/global_scope'); |
|
|
|
|
|
|
|
|
|
|
|
var _global_scope2 = _interopRequireDefault(_global_scope); |
|
|
|
var _global_scope2 = _interopRequireDefault(_global_scope); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _worker_options = require('./worker_options'); |
|
|
|
|
|
|
|
|
|
|
|
var _metadata = require('./metadata'); |
|
|
|
var _metadata = require('./metadata'); |
|
|
|
|
|
|
|
|
|
|
|
var _transport_stream = require('./transport_stream'); |
|
|
|
var _transport_stream = require('./transport_stream'); |
|
|
@ -54,8 +56,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons |
|
|
|
|
|
|
|
|
|
|
|
var DEFAULT_RANGE_CHUNK_SIZE = 65536; |
|
|
|
var DEFAULT_RANGE_CHUNK_SIZE = 65536; |
|
|
|
var isWorkerDisabled = false; |
|
|
|
var isWorkerDisabled = false; |
|
|
|
var workerSrc; |
|
|
|
var workerSrc = void 0; |
|
|
|
var isPostMessageTransfersDisabled = false; |
|
|
|
|
|
|
|
var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null; |
|
|
|
var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null; |
|
|
|
var fakeWorkerFilesLoader = null; |
|
|
|
var fakeWorkerFilesLoader = null; |
|
|
|
var useRequireEnsure = false; |
|
|
|
var useRequireEnsure = false; |
|
|
@ -145,9 +146,19 @@ function getDocument(src) { |
|
|
|
if (params.nativeImageDecoderSupport === undefined || !nativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) { |
|
|
|
if (params.nativeImageDecoderSupport === undefined || !nativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) { |
|
|
|
params.nativeImageDecoderSupport = _util.NativeImageDecoding.DECODE; |
|
|
|
params.nativeImageDecoderSupport = _util.NativeImageDecoding.DECODE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
(0, _util.setVerbosityLevel)(params.verbosity); |
|
|
|
if (!worker) { |
|
|
|
if (!worker) { |
|
|
|
var workerPort = (0, _dom_utils.getDefaultSetting)('workerPort'); |
|
|
|
var workerParams = { |
|
|
|
worker = workerPort ? PDFWorker.fromPort(workerPort) : new PDFWorker(); |
|
|
|
postMessageTransfers: params.postMessageTransfers, |
|
|
|
|
|
|
|
verbosity: params.verbosity |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
var workerPort = _worker_options.GlobalWorkerOptions.workerPort; |
|
|
|
|
|
|
|
if (workerPort) { |
|
|
|
|
|
|
|
workerParams.port = workerPort; |
|
|
|
|
|
|
|
worker = PDFWorker.fromPort(workerParams); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
worker = new PDFWorker(workerParams); |
|
|
|
|
|
|
|
} |
|
|
|
task._worker = worker; |
|
|
|
task._worker = worker; |
|
|
|
} |
|
|
|
} |
|
|
|
var docId = task.docId; |
|
|
|
var docId = task.docId; |
|
|
@ -178,7 +189,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { |
|
|
|
if (worker.destroyed) { |
|
|
|
if (worker.destroyed) { |
|
|
|
return Promise.reject(new Error('Worker was destroyed')); |
|
|
|
return Promise.reject(new Error('Worker was destroyed')); |
|
|
|
} |
|
|
|
} |
|
|
|
var apiVersion = '2.0.378'; |
|
|
|
var apiVersion = '2.0.385'; |
|
|
|
source.disableRange = (0, _dom_utils.getDefaultSetting)('disableRange'); |
|
|
|
source.disableRange = (0, _dom_utils.getDefaultSetting)('disableRange'); |
|
|
|
source.disableAutoFetch = (0, _dom_utils.getDefaultSetting)('disableAutoFetch'); |
|
|
|
source.disableAutoFetch = (0, _dom_utils.getDefaultSetting)('disableAutoFetch'); |
|
|
|
source.disableStream = (0, _dom_utils.getDefaultSetting)('disableStream'); |
|
|
|
source.disableStream = (0, _dom_utils.getDefaultSetting)('disableStream'); |
|
|
@ -200,7 +211,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { |
|
|
|
maxImageSize: (0, _dom_utils.getDefaultSetting)('maxImageSize'), |
|
|
|
maxImageSize: (0, _dom_utils.getDefaultSetting)('maxImageSize'), |
|
|
|
disableFontFace: (0, _dom_utils.getDefaultSetting)('disableFontFace'), |
|
|
|
disableFontFace: (0, _dom_utils.getDefaultSetting)('disableFontFace'), |
|
|
|
disableCreateObjectURL: (0, _dom_utils.getDefaultSetting)('disableCreateObjectURL'), |
|
|
|
disableCreateObjectURL: (0, _dom_utils.getDefaultSetting)('disableCreateObjectURL'), |
|
|
|
postMessageTransfers: (0, _dom_utils.getDefaultSetting)('postMessageTransfers') && !isPostMessageTransfersDisabled, |
|
|
|
postMessageTransfers: worker.postMessageTransfers, |
|
|
|
docBaseUrl: source.docBaseUrl, |
|
|
|
docBaseUrl: source.docBaseUrl, |
|
|
|
nativeImageDecoderSupport: source.nativeImageDecoderSupport, |
|
|
|
nativeImageDecoderSupport: source.nativeImageDecoderSupport, |
|
|
|
ignoreErrors: source.ignoreErrors, |
|
|
|
ignoreErrors: source.ignoreErrors, |
|
|
@ -714,8 +725,8 @@ var LoopbackPort = function () { |
|
|
|
var PDFWorker = function PDFWorkerClosure() { |
|
|
|
var PDFWorker = function PDFWorkerClosure() { |
|
|
|
var nextFakeWorkerId = 0; |
|
|
|
var nextFakeWorkerId = 0; |
|
|
|
function getWorkerSrc() { |
|
|
|
function getWorkerSrc() { |
|
|
|
if ((0, _dom_utils.getDefaultSetting)('workerSrc')) { |
|
|
|
if (_worker_options.GlobalWorkerOptions.workerSrc) { |
|
|
|
return (0, _dom_utils.getDefaultSetting)('workerSrc'); |
|
|
|
return _worker_options.GlobalWorkerOptions.workerSrc; |
|
|
|
} |
|
|
|
} |
|
|
|
if (typeof workerSrc !== 'undefined') { |
|
|
|
if (typeof workerSrc !== 'undefined') { |
|
|
|
return workerSrc; |
|
|
|
return workerSrc; |
|
|
@ -723,7 +734,7 @@ var PDFWorker = function PDFWorkerClosure() { |
|
|
|
if (pdfjsFilePath) { |
|
|
|
if (pdfjsFilePath) { |
|
|
|
return pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, '.worker$1$2'); |
|
|
|
return pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, '.worker$1$2'); |
|
|
|
} |
|
|
|
} |
|
|
|
throw new Error('No PDFJS.workerSrc specified'); |
|
|
|
throw new Error('No "GlobalWorkerOptions.workerSrc" specified.'); |
|
|
|
} |
|
|
|
} |
|
|
|
function getMainThreadWorkerMessageHandler() { |
|
|
|
function getMainThreadWorkerMessageHandler() { |
|
|
|
if (typeof window === 'undefined') { |
|
|
|
if (typeof window === 'undefined') { |
|
|
@ -755,13 +766,24 @@ var PDFWorker = function PDFWorkerClosure() { |
|
|
|
return URL.createObjectURL(new Blob([wrapper])); |
|
|
|
return URL.createObjectURL(new Blob([wrapper])); |
|
|
|
} |
|
|
|
} |
|
|
|
var pdfWorkerPorts = new WeakMap(); |
|
|
|
var pdfWorkerPorts = new WeakMap(); |
|
|
|
function PDFWorker(name, port) { |
|
|
|
function PDFWorker() { |
|
|
|
|
|
|
|
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, |
|
|
|
|
|
|
|
_ref2$name = _ref2.name, |
|
|
|
|
|
|
|
name = _ref2$name === undefined ? null : _ref2$name, |
|
|
|
|
|
|
|
_ref2$port = _ref2.port, |
|
|
|
|
|
|
|
port = _ref2$port === undefined ? null : _ref2$port, |
|
|
|
|
|
|
|
_ref2$postMessageTran = _ref2.postMessageTransfers, |
|
|
|
|
|
|
|
postMessageTransfers = _ref2$postMessageTran === undefined ? true : _ref2$postMessageTran, |
|
|
|
|
|
|
|
_ref2$verbosity = _ref2.verbosity, |
|
|
|
|
|
|
|
verbosity = _ref2$verbosity === undefined ? null : _ref2$verbosity; |
|
|
|
|
|
|
|
|
|
|
|
if (port && pdfWorkerPorts.has(port)) { |
|
|
|
if (port && pdfWorkerPorts.has(port)) { |
|
|
|
throw new Error('Cannot use more than one PDFWorker per port'); |
|
|
|
throw new Error('Cannot use more than one PDFWorker per port'); |
|
|
|
} |
|
|
|
} |
|
|
|
this.name = name; |
|
|
|
this.name = name; |
|
|
|
this.destroyed = false; |
|
|
|
this.destroyed = false; |
|
|
|
this.postMessageTransfers = true; |
|
|
|
this.postMessageTransfers = postMessageTransfers !== false; |
|
|
|
|
|
|
|
this.verbosity = (0, _util.isNum)(verbosity) ? verbosity : (0, _util.getVerbosityLevel)(); |
|
|
|
this._readyCapability = (0, _util.createPromiseCapability)(); |
|
|
|
this._readyCapability = (0, _util.createPromiseCapability)(); |
|
|
|
this._port = null; |
|
|
|
this._port = null; |
|
|
|
this._webWorker = null; |
|
|
|
this._webWorker = null; |
|
|
@ -829,10 +851,9 @@ var PDFWorker = function PDFWorkerClosure() { |
|
|
|
_this6._webWorker = worker; |
|
|
|
_this6._webWorker = worker; |
|
|
|
if (!data.supportTransfers) { |
|
|
|
if (!data.supportTransfers) { |
|
|
|
_this6.postMessageTransfers = false; |
|
|
|
_this6.postMessageTransfers = false; |
|
|
|
isPostMessageTransfersDisabled = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
_this6._readyCapability.resolve(); |
|
|
|
_this6._readyCapability.resolve(); |
|
|
|
messageHandler.send('configure', { verbosity: (0, _util.getVerbosityLevel)() }); |
|
|
|
messageHandler.send('configure', { verbosity: _this6.verbosity }); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
_this6._setupFakeWorker(); |
|
|
|
_this6._setupFakeWorker(); |
|
|
|
messageHandler.destroy(); |
|
|
|
messageHandler.destroy(); |
|
|
@ -852,8 +873,7 @@ var PDFWorker = function PDFWorkerClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
var sendTest = function sendTest() { |
|
|
|
var sendTest = function sendTest() { |
|
|
|
var postMessageTransfers = (0, _dom_utils.getDefaultSetting)('postMessageTransfers') && !isPostMessageTransfersDisabled; |
|
|
|
var testObj = new Uint8Array([_this6.postMessageTransfers ? 255 : 0]); |
|
|
|
var testObj = new Uint8Array([postMessageTransfers ? 255 : 0]); |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
messageHandler.send('test', testObj, [testObj.buffer]); |
|
|
|
messageHandler.send('test', testObj, [testObj.buffer]); |
|
|
|
} catch (ex) { |
|
|
|
} catch (ex) { |
|
|
@ -907,11 +927,11 @@ var PDFWorker = function PDFWorkerClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
PDFWorker.fromPort = function (port) { |
|
|
|
PDFWorker.fromPort = function (params) { |
|
|
|
if (pdfWorkerPorts.has(port)) { |
|
|
|
if (pdfWorkerPorts.has(params.port)) { |
|
|
|
return pdfWorkerPorts.get(port); |
|
|
|
return pdfWorkerPorts.get(params.port); |
|
|
|
} |
|
|
|
} |
|
|
|
return new PDFWorker(null, port); |
|
|
|
return new PDFWorker(params); |
|
|
|
}; |
|
|
|
}; |
|
|
|
PDFWorker.getWorkerSrc = function () { |
|
|
|
PDFWorker.getWorkerSrc = function () { |
|
|
|
return getWorkerSrc(); |
|
|
|
return getWorkerSrc(); |
|
|
@ -989,9 +1009,9 @@ var WorkerTransport = function WorkerTransportClosure() { |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
}; |
|
|
|
sink.onPull = function () { |
|
|
|
sink.onPull = function () { |
|
|
|
_this9._fullReader.read().then(function (_ref2) { |
|
|
|
_this9._fullReader.read().then(function (_ref3) { |
|
|
|
var value = _ref2.value, |
|
|
|
var value = _ref3.value, |
|
|
|
done = _ref2.done; |
|
|
|
done = _ref3.done; |
|
|
|
|
|
|
|
|
|
|
|
if (done) { |
|
|
|
if (done) { |
|
|
|
sink.close(); |
|
|
|
sink.close(); |
|
|
@ -1042,9 +1062,9 @@ var WorkerTransport = function WorkerTransportClosure() { |
|
|
|
(0, _util.assert)(this._networkStream); |
|
|
|
(0, _util.assert)(this._networkStream); |
|
|
|
var _rangeReader = this._networkStream.getRangeReader(data.begin, data.end); |
|
|
|
var _rangeReader = this._networkStream.getRangeReader(data.begin, data.end); |
|
|
|
sink.onPull = function () { |
|
|
|
sink.onPull = function () { |
|
|
|
_rangeReader.read().then(function (_ref3) { |
|
|
|
_rangeReader.read().then(function (_ref4) { |
|
|
|
var value = _ref3.value, |
|
|
|
var value = _ref4.value, |
|
|
|
done = _ref3.done; |
|
|
|
done = _ref4.done; |
|
|
|
|
|
|
|
|
|
|
|
if (done) { |
|
|
|
if (done) { |
|
|
|
sink.close(); |
|
|
|
sink.close(); |
|
|
@ -1060,8 +1080,8 @@ var WorkerTransport = function WorkerTransportClosure() { |
|
|
|
_rangeReader.cancel(reason); |
|
|
|
_rangeReader.cancel(reason); |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, this); |
|
|
|
}, this); |
|
|
|
messageHandler.on('GetDoc', function transportDoc(_ref4) { |
|
|
|
messageHandler.on('GetDoc', function transportDoc(_ref5) { |
|
|
|
var pdfInfo = _ref4.pdfInfo; |
|
|
|
var pdfInfo = _ref5.pdfInfo; |
|
|
|
|
|
|
|
|
|
|
|
this.numPages = pdfInfo.numPages; |
|
|
|
this.numPages = pdfInfo.numPages; |
|
|
|
var loadingTask = this.loadingTask; |
|
|
|
var loadingTask = this.loadingTask; |
|
|
@ -1577,8 +1597,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() { |
|
|
|
}(); |
|
|
|
}(); |
|
|
|
var version, build; |
|
|
|
var version, build; |
|
|
|
{ |
|
|
|
{ |
|
|
|
exports.version = version = '2.0.378'; |
|
|
|
exports.version = version = '2.0.385'; |
|
|
|
exports.build = build = 'a89071bd'; |
|
|
|
exports.build = build = '99060e24'; |
|
|
|
} |
|
|
|
} |
|
|
|
exports.getDocument = getDocument; |
|
|
|
exports.getDocument = getDocument; |
|
|
|
exports.LoopbackPort = LoopbackPort; |
|
|
|
exports.LoopbackPort = LoopbackPort; |
|
|
|