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