mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Move the workerSrc
option from the global PDFJS
object and into GlobalWorkerOptions
instead
This commit is contained in:
parent
45adf33187
commit
c3c1fc511d
20 changed files with 69 additions and 60 deletions
|
@ -34,11 +34,11 @@ import { WebGLContext } from './webgl';
|
|||
|
||||
var DEFAULT_RANGE_CHUNK_SIZE = 65536; // 2^16 = 65536
|
||||
|
||||
var isWorkerDisabled = false;
|
||||
var workerSrc;
|
||||
let isWorkerDisabled = false;
|
||||
let workerSrc;
|
||||
var isPostMessageTransfersDisabled = false;
|
||||
|
||||
var pdfjsFilePath =
|
||||
const pdfjsFilePath =
|
||||
typeof PDFJSDev !== 'undefined' &&
|
||||
PDFJSDev.test('PRODUCTION && !(MOZCENTRAL || FIREFOX)') &&
|
||||
typeof document !== 'undefined' && document.currentScript ?
|
||||
|
@ -47,8 +47,8 @@ var pdfjsFilePath =
|
|||
var fakeWorkerFilesLoader = null;
|
||||
var useRequireEnsure = false;
|
||||
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) {
|
||||
// For GENERIC build we need add support of different fake file loaders
|
||||
// for different frameworks.
|
||||
// For GENERIC build we need to add support for different fake file loaders
|
||||
// for different frameworks.
|
||||
if (typeof window === 'undefined') {
|
||||
// node.js - disable worker and set require.ensure.
|
||||
isWorkerDisabled = true;
|
||||
|
@ -1202,8 +1202,8 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||
let nextFakeWorkerId = 0;
|
||||
|
||||
function getWorkerSrc() {
|
||||
if (getDefaultSetting('workerSrc')) {
|
||||
return getDefaultSetting('workerSrc');
|
||||
if (GlobalWorkerOptions.workerSrc) {
|
||||
return GlobalWorkerOptions.workerSrc;
|
||||
}
|
||||
if (typeof workerSrc !== 'undefined') {
|
||||
return workerSrc;
|
||||
|
@ -1213,7 +1213,7 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||
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() {
|
||||
|
|
|
@ -351,8 +351,6 @@ function getDefaultSetting(id) {
|
|||
return globalSettings ? globalSettings.cMapPacked : false;
|
||||
case 'postMessageTransfers':
|
||||
return globalSettings ? globalSettings.postMessageTransfers : true;
|
||||
case 'workerSrc':
|
||||
return globalSettings ? globalSettings.workerSrc : null;
|
||||
case 'maxImageSize':
|
||||
return globalSettings ? globalSettings.maxImageSize : -1;
|
||||
case 'isEvalSupported':
|
||||
|
|
|
@ -112,16 +112,6 @@ PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
|
|||
PDFJS.disableFontFace = (PDFJS.disableFontFace === undefined ?
|
||||
false : PDFJS.disableFontFace);
|
||||
|
||||
/**
|
||||
* Path and filename of the worker file. Required when the worker is enabled
|
||||
* in development mode. If unspecified in the production build, the worker
|
||||
* will be loaded based on the location of the pdf.js file. It is recommended
|
||||
* that the workerSrc is set in a custom application to prevent issues caused
|
||||
* by third-party frameworks and libraries.
|
||||
* @var {string}
|
||||
*/
|
||||
PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc);
|
||||
|
||||
/**
|
||||
* Disable range request loading of PDF files. When enabled and if the server
|
||||
* supports partial content requests then the PDF will be fetched in chunks.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue