mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
[api-major] Completely remove the global PDFJS
object
This commit is contained in:
parent
4b4fcecf70
commit
b8606abbc1
18 changed files with 323 additions and 426 deletions
|
@ -1,82 +0,0 @@
|
|||
/* Copyright 2015 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.
|
||||
*/
|
||||
|
||||
import {
|
||||
createBlob, createPromiseCapability, InvalidPDFException, isLittleEndian,
|
||||
MissingPDFException, OPS, PageViewport, PasswordException, PasswordResponses,
|
||||
removeNullCharacters, shadow, UnexpectedResponseException,
|
||||
UnknownErrorException, UNSUPPORTED_FEATURES, Util
|
||||
} from '../shared/util';
|
||||
import {
|
||||
getDocument, LoopbackPort, PDFDataRangeTransport, PDFWorker
|
||||
} from './api';
|
||||
import { AnnotationLayer } from './annotation_layer';
|
||||
import { getFilenameFromUrl } from './dom_utils';
|
||||
import globalScope from '../shared/global_scope';
|
||||
import { GlobalWorkerOptions } from './worker_options';
|
||||
import { Metadata } from './metadata';
|
||||
import { renderTextLayer } from './text_layer';
|
||||
import { SVGGraphics } from './svg';
|
||||
|
||||
// The global PDFJS object is now deprecated and will not be supported in
|
||||
// the future. The members below are maintained for backward compatibility
|
||||
// and shall not be extended or modified. If the global.js is included as
|
||||
// a module, we will create a global PDFJS object instance or use existing.
|
||||
if (!globalScope.PDFJS) {
|
||||
globalScope.PDFJS = {};
|
||||
}
|
||||
var PDFJS = globalScope.PDFJS;
|
||||
|
||||
PDFJS.OPS = OPS;
|
||||
PDFJS.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
|
||||
PDFJS.shadow = shadow;
|
||||
PDFJS.createBlob = createBlob;
|
||||
Object.defineProperty(PDFJS, 'isLittleEndian', {
|
||||
configurable: true,
|
||||
get: function PDFJS_isLittleEndian() {
|
||||
return shadow(PDFJS, 'isLittleEndian', isLittleEndian());
|
||||
},
|
||||
});
|
||||
PDFJS.removeNullCharacters = removeNullCharacters;
|
||||
PDFJS.PasswordResponses = PasswordResponses;
|
||||
PDFJS.PasswordException = PasswordException;
|
||||
PDFJS.UnknownErrorException = UnknownErrorException;
|
||||
PDFJS.InvalidPDFException = InvalidPDFException;
|
||||
PDFJS.MissingPDFException = MissingPDFException;
|
||||
PDFJS.UnexpectedResponseException = UnexpectedResponseException;
|
||||
PDFJS.Util = Util;
|
||||
PDFJS.PageViewport = PageViewport;
|
||||
PDFJS.createPromiseCapability = createPromiseCapability;
|
||||
|
||||
PDFJS.getDocument = getDocument;
|
||||
PDFJS.LoopbackPort = LoopbackPort;
|
||||
PDFJS.PDFDataRangeTransport = PDFDataRangeTransport;
|
||||
PDFJS.PDFWorker = PDFWorker;
|
||||
PDFJS.GlobalWorkerOptions = GlobalWorkerOptions;
|
||||
|
||||
PDFJS.getFilenameFromUrl = getFilenameFromUrl;
|
||||
|
||||
PDFJS.AnnotationLayer = AnnotationLayer;
|
||||
|
||||
PDFJS.renderTextLayer = renderTextLayer;
|
||||
|
||||
PDFJS.Metadata = Metadata;
|
||||
|
||||
PDFJS.SVGGraphics = SVGGraphics;
|
||||
|
||||
export {
|
||||
globalScope,
|
||||
PDFJS,
|
||||
};
|
|
@ -18,15 +18,6 @@
|
|||
It is not for use in the executable code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* PDFJS scope object that contains all functions, objects and variables related
|
||||
* to the PDF.js.
|
||||
* @constructor
|
||||
*/
|
||||
function PDFJS() { // eslint-disable-line no-unused-vars
|
||||
// Mock class constructor. See src/display/api.js.
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the eventual result of an asynchronous operation.
|
||||
* @external Promise
|
||||
|
|
|
@ -22,7 +22,6 @@ var pdfjsBuild =
|
|||
typeof PDFJSDev !== 'undefined' ? PDFJSDev.eval('BUNDLE_BUILD') : void 0;
|
||||
|
||||
var pdfjsSharedUtil = require('./shared/util.js');
|
||||
var pdfjsDisplayGlobal = require('./display/global.js');
|
||||
var pdfjsDisplayAPI = require('./display/api.js');
|
||||
var pdfjsDisplayTextLayer = require('./display/text_layer.js');
|
||||
var pdfjsDisplayAnnotationLayer = require('./display/annotation_layer.js');
|
||||
|
@ -66,7 +65,6 @@ if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
|
|||
});
|
||||
}
|
||||
|
||||
exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
|
||||
exports.build = pdfjsDisplayAPI.build;
|
||||
exports.version = pdfjsDisplayAPI.version;
|
||||
exports.getDocument = pdfjsDisplayAPI.getDocument;
|
||||
|
@ -91,6 +89,7 @@ exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
|
|||
exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
|
||||
exports.shadow = pdfjsSharedUtil.shadow;
|
||||
exports.createBlob = pdfjsSharedUtil.createBlob;
|
||||
exports.Util = pdfjsSharedUtil.Util;
|
||||
exports.RenderingCancelledException =
|
||||
pdfjsDisplayDOMUtils.RenderingCancelledException;
|
||||
exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
|
||||
|
|
|
@ -13,32 +13,26 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
/* eslint-disable mozilla/use-includes-instead-of-indexOf */
|
||||
/* globals PDFJS */
|
||||
|
||||
const globalScope = require('./global_scope');
|
||||
|
||||
// Skip compatibility checks for the extensions and if we already ran
|
||||
// this module.
|
||||
if ((typeof PDFJSDev === 'undefined' ||
|
||||
!PDFJSDev.test('FIREFOX || MOZCENTRAL')) &&
|
||||
(typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked)) {
|
||||
!globalScope._pdfjsCompatibilityChecked) {
|
||||
|
||||
globalScope._pdfjsCompatibilityChecked = true;
|
||||
|
||||
// In the Chrome extension, most of the polyfills are unnecessary.
|
||||
// We support down to Chrome 49, because it's still commonly used by Windows XP
|
||||
// users - https://github.com/mozilla/pdf.js/issues/9397
|
||||
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('CHROME')) {
|
||||
|
||||
const globalScope = require('./global_scope');
|
||||
const isNodeJS = require('./is_node');
|
||||
|
||||
const hasDOM = typeof window === 'object' && typeof document === 'object';
|
||||
|
||||
// Initializing PDFJS global object here, it case if we need to change/disable
|
||||
// some PDF.js features, e.g. range requests
|
||||
if (typeof PDFJS === 'undefined') {
|
||||
globalScope.PDFJS = {};
|
||||
}
|
||||
|
||||
PDFJS.compatibilityChecked = true;
|
||||
|
||||
// Support: Node.js
|
||||
(function checkNodeBtoa() {
|
||||
if (globalScope.btoa || !isNodeJS()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue