diff --git a/src/display/api.js b/src/display/api.js index e47ecb064..545060958 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -27,7 +27,7 @@ import { unreachable, warn } from '../shared/util'; import { - DOMCanvasFactory, DOMCMapReaderFactory, loadScript, PageViewport, + deprecated, DOMCanvasFactory, DOMCMapReaderFactory, loadScript, PageViewport, releaseImageResources, RenderingCancelledException, StatTimer } from './display_utils'; import { FontFaceObject, FontLoader } from './font_loader'; @@ -43,7 +43,6 @@ import { WebGLContext } from './webgl'; const DEFAULT_RANGE_CHUNK_SIZE = 65536; // 2^16 = 65536 const RENDERING_CANCELLED_TIMEOUT = 100; // ms - /** * @typedef {function} IPDFStreamFactory * @param {DocumentInitParameters} params The document initialization @@ -1477,15 +1476,15 @@ const PDFWorker = (function PDFWorkerClosure() { // Workers aren't supported in Node.js, force-disabling them there. isWorkerDisabled = true; + if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('LIB')) { + fallbackWorkerSrc = '../pdf.worker.js'; + } else { + fallbackWorkerSrc = './pdf.worker.js'; + } fakeWorkerFilesLoader = function() { return new Promise(function(resolve, reject) { try { - let worker; - if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('LIB')) { - worker = __non_webpack_require__('../pdf.worker.js'); - } else { - worker = __non_webpack_require__('./pdf.worker.js'); - } + const worker = __non_webpack_require__(getWorkerSrc()); resolve(worker.WorkerMessageHandler); } catch (ex) { reject(ex); @@ -1507,6 +1506,9 @@ const PDFWorker = (function PDFWorkerClosure() { return GlobalWorkerOptions.workerSrc; } if (typeof fallbackWorkerSrc !== 'undefined') { + if (!isNodeJS) { + deprecated('No "GlobalWorkerOptions.workerSrc" specified.'); + } return fallbackWorkerSrc; } throw new Error('No "GlobalWorkerOptions.workerSrc" specified.');