Merge pull request #9077 from yurydelendik/v2

Version 2.0 merge
This commit is contained in:
Brendan Dahl 2017-10-31 14:24:20 -07:00 committed by GitHub
commit b46443f0c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 69 additions and 255 deletions

View File

@ -81,7 +81,7 @@ var DEFINES = {
SINGLE_FILE: false, SINGLE_FILE: false,
COMPONENTS: false, COMPONENTS: false,
LIB: false, LIB: false,
PDFJS_NEXT: false, SKIP_BABEL: false,
}; };
function safeSpawnSync(command, parameters, options) { function safeSpawnSync(command, parameters, options) {
@ -130,8 +130,8 @@ function createWebpackConfig(defines, output) {
var licenseHeader = fs.readFileSync('./src/license_header.js').toString(); var licenseHeader = fs.readFileSync('./src/license_header.js').toString();
var enableSourceMaps = !bundleDefines.FIREFOX && !bundleDefines.MOZCENTRAL && var enableSourceMaps = !bundleDefines.FIREFOX && !bundleDefines.MOZCENTRAL &&
!bundleDefines.CHROME; !bundleDefines.CHROME;
var pdfjsNext = bundleDefines.PDFJS_NEXT || var skipBabel = bundleDefines.SKIP_BABEL ||
process.env['PDFJS_NEXT'] === 'true'; process.env['SKIP_BABEL'] === 'true';
return { return {
output: output, output: output,
@ -152,7 +152,7 @@ function createWebpackConfig(defines, output) {
loader: 'babel-loader', loader: 'babel-loader',
exclude: /src\/core\/(glyphlist|unicode)/, // babel is too slow exclude: /src\/core\/(glyphlist|unicode)/, // babel is too slow
options: { options: {
presets: pdfjsNext ? undefined : ['env'], presets: skipBabel ? undefined : ['env'],
plugins: ['transform-es2015-modules-commonjs'], plugins: ['transform-es2015-modules-commonjs'],
}, },
}, },
@ -732,7 +732,7 @@ gulp.task('minified', ['minified-post']);
gulp.task('firefox-pre', ['buildnumber', 'locale'], function () { gulp.task('firefox-pre', ['buildnumber', 'locale'], function () {
console.log(); console.log();
console.log('### Building Firefox extension'); console.log('### Building Firefox extension');
var defines = builder.merge(DEFINES, { FIREFOX: true, PDFJS_NEXT: true, }); var defines = builder.merge(DEFINES, { FIREFOX: true, SKIP_BABEL: true, });
var FIREFOX_BUILD_CONTENT_DIR = FIREFOX_BUILD_DIR + '/content/', var FIREFOX_BUILD_CONTENT_DIR = FIREFOX_BUILD_DIR + '/content/',
FIREFOX_EXTENSION_DIR = 'extensions/firefox/', FIREFOX_EXTENSION_DIR = 'extensions/firefox/',
@ -840,7 +840,7 @@ gulp.task('firefox', ['firefox-pre'], function (done) {
gulp.task('mozcentral-pre', ['buildnumber', 'locale'], function () { gulp.task('mozcentral-pre', ['buildnumber', 'locale'], function () {
console.log(); console.log();
console.log('### Building mozilla-central extension'); console.log('### Building mozilla-central extension');
var defines = builder.merge(DEFINES, { MOZCENTRAL: true, PDFJS_NEXT: true, }); var defines = builder.merge(DEFINES, { MOZCENTRAL: true, SKIP_BABEL: true, });
var MOZCENTRAL_DIR = BUILD_DIR + 'mozcentral/', var MOZCENTRAL_DIR = BUILD_DIR + 'mozcentral/',
MOZCENTRAL_EXTENSION_DIR = MOZCENTRAL_DIR + 'browser/extensions/pdfjs/', MOZCENTRAL_EXTENSION_DIR = MOZCENTRAL_DIR + 'browser/extensions/pdfjs/',
@ -913,7 +913,7 @@ gulp.task('mozcentral', ['mozcentral-pre']);
gulp.task('chromium-pre', ['buildnumber', 'locale'], function () { gulp.task('chromium-pre', ['buildnumber', 'locale'], function () {
console.log(); console.log();
console.log('### Building Chromium extension'); console.log('### Building Chromium extension');
var defines = builder.merge(DEFINES, { CHROME: true, PDFJS_NEXT: true, }); var defines = builder.merge(DEFINES, { CHROME: true, SKIP_BABEL: true, });
var CHROME_BUILD_DIR = BUILD_DIR + '/chromium/', var CHROME_BUILD_DIR = BUILD_DIR + '/chromium/',
CHROME_BUILD_CONTENT_DIR = CHROME_BUILD_DIR + '/content/'; CHROME_BUILD_CONTENT_DIR = CHROME_BUILD_DIR + '/content/';

View File

@ -1,6 +1,6 @@
{ {
"name": "pdf.js", "name": "pdf.js",
"version": "1.0.0", "version": "2.0.0",
"devDependencies": { "devDependencies": {
"acorn": "^5.1.2", "acorn": "^5.1.2",
"babel-core": "^6.26.0", "babel-core": "^6.26.0",

View File

@ -1,6 +1,6 @@
{ {
"betaVersion": "1.10.88", "betaVersion": "1.10.88",
"stableVersion": "1.9.426", "stableVersion": "1.9.426",
"baseVersion": "d7b37ae7453220e75714e502268c89a826e989a7", "baseVersion": "9b353ef407b694c10c755501a9693b8173a4e8e0",
"versionPrefix": "1.10." "versionPrefix": "2.0."
} }

View File

@ -371,7 +371,7 @@ var Catalog = (function CatalogClosure() {
var xref = this.xref; var xref = this.xref;
var obj = this.catDict.get('Names'); var obj = this.catDict.get('Names');
var javaScript = []; let javaScript = null;
function appendIfJavaScriptDict(jsDict) { function appendIfJavaScriptDict(jsDict) {
var type = jsDict.get('S'); var type = jsDict.get('S');
if (!isName(type, 'JavaScript')) { if (!isName(type, 'JavaScript')) {
@ -383,6 +383,9 @@ var Catalog = (function CatalogClosure() {
} else if (!isString(js)) { } else if (!isString(js)) {
return; return;
} }
if (!javaScript) {
javaScript = [];
}
javaScript.push(stringToPDFString(js)); javaScript.push(stringToPDFString(js));
} }
if (obj && obj.has('JavaScript')) { if (obj && obj.has('JavaScript')) {
@ -407,6 +410,9 @@ var Catalog = (function CatalogClosure() {
// but is supported by many PDF readers/writers (including Adobe's). // but is supported by many PDF readers/writers (including Adobe's).
var action = openactionDict.get('N'); var action = openactionDict.get('N');
if (isName(action, 'Print')) { if (isName(action, 'Print')) {
if (!javaScript) {
javaScript = [];
}
javaScript.push('print({});'); javaScript.push('print({});');
} }
} else { } else {

View File

@ -15,7 +15,7 @@
/* globals requirejs, __non_webpack_require__ */ /* globals requirejs, __non_webpack_require__ */
import { import {
assert, createPromiseCapability, deprecated, getVerbosityLevel, info, assert, createPromiseCapability, getVerbosityLevel, info,
InvalidPDFException, isArrayBuffer, isSameOrigin, loadJpegStream, InvalidPDFException, isArrayBuffer, isSameOrigin, loadJpegStream,
MessageHandler, MissingPDFException, NativeImageDecoding, PageViewport, MessageHandler, MissingPDFException, NativeImageDecoding, PageViewport,
PasswordException, StatTimer, stringToBytes, UnexpectedResponseException, PasswordException, StatTimer, stringToBytes, UnexpectedResponseException,
@ -120,10 +120,6 @@ function setPDFNetworkStreamClass(cls) {
* @property {string} docBaseUrl - (optional) The base URL of the document, * @property {string} docBaseUrl - (optional) The base URL of the document,
* used when attempting to recover valid absolute URLs for annotations, and * used when attempting to recover valid absolute URLs for annotations, and
* outline items, that (incorrectly) only specify relative URLs. * outline items, that (incorrectly) only specify relative URLs.
* @property {boolean} disableNativeImageDecoder - (deprecated) Disable decoding
* of certain (simple) JPEG images in the browser. This is useful for
* environments without DOM image support, such as e.g. Node.js.
* The default value is `false`.
* @property {string} nativeImageDecoderSupport - (optional) Strategy for * @property {string} nativeImageDecoderSupport - (optional) Strategy for
* decoding certain (simple) JPEG images in the browser. This is useful for * decoding certain (simple) JPEG images in the browser. This is useful for
* environments without DOM image and canvas support, such as e.g. Node.js. * environments without DOM image and canvas support, such as e.g. Node.js.
@ -160,46 +156,11 @@ function setPDFNetworkStreamClass(cls) {
* Can be a url to where a PDF is located, a typed array (Uint8Array) * Can be a url to where a PDF is located, a typed array (Uint8Array)
* already populated with data or parameter object. * already populated with data or parameter object.
* *
* @param {PDFDataRangeTransport} pdfDataRangeTransport (deprecated) It is used
* if you want to manually serve range requests for data in the PDF.
*
* @param {function} passwordCallback (deprecated) It is used to request a
* password if wrong or no password was provided. The callback receives two
* parameters: function that needs to be called with new password and reason
* (see {PasswordResponses}).
*
* @param {function} progressCallback (deprecated) It is used to be able to
* monitor the loading progress of the PDF file (necessary to implement e.g.
* a loading bar). The callback receives an {Object} with the properties:
* {number} loaded and {number} total.
*
* @return {PDFDocumentLoadingTask} * @return {PDFDocumentLoadingTask}
*/ */
function getDocument(src, pdfDataRangeTransport, function getDocument(src) {
passwordCallback, progressCallback) {
var task = new PDFDocumentLoadingTask(); var task = new PDFDocumentLoadingTask();
// Support of the obsolete arguments (for compatibility with API v1.0)
if (arguments.length > 1) {
deprecated('getDocument is called with pdfDataRangeTransport, ' +
'passwordCallback or progressCallback argument');
}
if (pdfDataRangeTransport) {
if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
// Not a PDFDataRangeTransport instance, trying to add missing properties.
pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
pdfDataRangeTransport.length = src.length;
pdfDataRangeTransport.initialData = src.initialData;
if (!pdfDataRangeTransport.abort) {
pdfDataRangeTransport.abort = function () {};
}
}
src = Object.create(src);
src.range = pdfDataRangeTransport;
}
task.onPassword = passwordCallback || null;
task.onProgress = progressCallback || null;
var source; var source;
if (typeof src === 'string') { if (typeof src === 'string') {
source = { url: src, }; source = { url: src, };
@ -262,18 +223,9 @@ function getDocument(src, pdfDataRangeTransport,
params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE; params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
params.ignoreErrors = params.stopAtErrors !== true; params.ignoreErrors = params.stopAtErrors !== true;
if (params.disableNativeImageDecoder !== undefined) { const nativeImageDecoderValues = Object.values(NativeImageDecoding);
deprecated('parameter disableNativeImageDecoder, ' + if (params.nativeImageDecoderSupport === undefined ||
'use nativeImageDecoderSupport instead'); !nativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) {
}
params.nativeImageDecoderSupport = params.nativeImageDecoderSupport ||
(params.disableNativeImageDecoder === true ? NativeImageDecoding.NONE :
NativeImageDecoding.DECODE);
if (params.nativeImageDecoderSupport !== NativeImageDecoding.DECODE &&
params.nativeImageDecoderSupport !== NativeImageDecoding.NONE &&
params.nativeImageDecoderSupport !== NativeImageDecoding.DISPLAY) {
warn('Invalid parameter nativeImageDecoderSupport: ' +
'need a state of enum {NativeImageDecoding}');
params.nativeImageDecoderSupport = NativeImageDecoding.DECODE; params.nativeImageDecoderSupport = NativeImageDecoding.DECODE;
} }
@ -618,10 +570,10 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
return this.transport.getAttachments(); return this.transport.getAttachments();
}, },
/** /**
* @return {Promise} A promise that is resolved with an array of all the * @return {Promise} A promise that is resolved with an {Array} of all the
* JavaScript strings in the name tree. * JavaScript strings in the name tree, or `null` if no JavaScript exists.
*/ */
getJavaScript: function PDFDocumentProxy_getJavaScript() { getJavaScript() {
return this.transport.getJavaScript(); return this.transport.getJavaScript();
}, },
/** /**
@ -756,10 +708,6 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
* just before viewport transform. * just before viewport transform.
* @property {Object} imageLayer - (optional) An object that has beginLayout, * @property {Object} imageLayer - (optional) An object that has beginLayout,
* endLayout and appendImage functions. * endLayout and appendImage functions.
* @property {function} continueCallback - (deprecated) A function that will be
* called each time the rendering is paused. To continue
* rendering call the function that is the first argument
* to the callback.
* @property {Object} canvasFactory - (optional) The factory that will be used * @property {Object} canvasFactory - (optional) The factory that will be used
* when creating canvases. The default value is * when creating canvases. The default value is
* {DOMCanvasFactory}. * {DOMCanvasFactory}.
@ -933,12 +881,6 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
intentState.renderTasks.push(internalRenderTask); intentState.renderTasks.push(internalRenderTask);
var renderTask = internalRenderTask.task; var renderTask = internalRenderTask.task;
// Obsolete parameter support
if (params.continueCallback) {
deprecated('render is used with continueCallback parameter');
renderTask.onContinue = params.continueCallback;
}
intentState.displayReadyCapability.promise.then((transparency) => { intentState.displayReadyCapability.promise.then((transparency) => {
if (this.pendingCleanup) { if (this.pendingCleanup) {
complete(); complete();
@ -1073,14 +1015,6 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
return Promise.all(waitOn); return Promise.all(waitOn);
}, },
/**
* Cleans up resources allocated by the page. (deprecated)
*/
destroy() {
deprecated('page destroy method, use cleanup() instead');
this.cleanup();
},
/** /**
* Cleans up resources allocated by the page. * Cleans up resources allocated by the page.
*/ */
@ -1908,17 +1842,14 @@ var WorkerTransport = (function WorkerTransportClosure() {
} }
}, this); }, this);
messageHandler.on('UnsupportedFeature', messageHandler.on('UnsupportedFeature', function(data) {
function transportUnsupportedFeature(data) {
if (this.destroyed) { if (this.destroyed) {
return; // Ignore any pending requests if the worker was terminated. return; // Ignore any pending requests if the worker was terminated.
} }
var featureId = data.featureId; let loadingTask = this.loadingTask;
var loadingTask = this.loadingTask;
if (loadingTask.onUnsupportedFeature) { if (loadingTask.onUnsupportedFeature) {
loadingTask.onUnsupportedFeature(featureId); loadingTask.onUnsupportedFeature(data.featureId);
} }
_UnsupportedManager.notify(featureId);
}, this); }, this);
messageHandler.on('JpegDecode', function(data) { messageHandler.on('JpegDecode', function(data) {
@ -2325,14 +2256,8 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
if (this._canvas) { if (this._canvas) {
canvasInRendering.delete(this._canvas); canvasInRendering.delete(this._canvas);
} }
this.callback(new RenderingCancelledException(
if ((typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PDFJS_NEXT')) || 'Rendering cancelled, page ' + this.pageNumber, 'canvas'));
getDefaultSetting('pdfjsNext')) {
this.callback(new RenderingCancelledException(
'Rendering cancelled, page ' + this.pageNumber, 'canvas'));
} else {
this.callback('cancelled');
}
}, },
operatorListChanged: function InternalRenderTask_operatorListChanged() { operatorListChanged: function InternalRenderTask_operatorListChanged() {
@ -2398,26 +2323,6 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
return InternalRenderTask; return InternalRenderTask;
})(); })();
/**
* (Deprecated) Global observer of unsupported feature usages. Use
* onUnsupportedFeature callback of the {PDFDocumentLoadingTask} instance.
*/
var _UnsupportedManager = (function UnsupportedManagerClosure() {
var listeners = [];
return {
listen(cb) {
deprecated('Global UnsupportedManager.listen is used: ' +
' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
listeners.push(cb);
},
notify(featureId) {
for (var i = 0, ii = listeners.length; i < ii; i++) {
listeners[i](featureId);
}
},
};
})();
var version, build; var version, build;
if (typeof PDFJSDev !== 'undefined') { if (typeof PDFJSDev !== 'undefined') {
version = PDFJSDev.eval('BUNDLE_VERSION'); version = PDFJSDev.eval('BUNDLE_VERSION');
@ -2432,7 +2337,6 @@ export {
PDFDocumentProxy, PDFDocumentProxy,
PDFPageProxy, PDFPageProxy,
setPDFNetworkStreamClass, setPDFNetworkStreamClass,
_UnsupportedManager,
version, version,
build, build,
}; };

View File

@ -14,8 +14,7 @@
*/ */
import { import {
assert, CMapCompressionType, createValidAbsoluteUrl, deprecated, assert, CMapCompressionType, removeNullCharacters, stringToBytes, warn
removeNullCharacters, stringToBytes, warn
} from '../shared/util'; } from '../shared/util';
import globalScope from '../shared/global_scope'; import globalScope from '../shared/global_scope';
@ -444,8 +443,6 @@ function getDefaultSetting(id) {
return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL; return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
case 'enableStats': case 'enableStats':
return !!(globalSettings && globalSettings.enableStats); return !!(globalSettings && globalSettings.enableStats);
case 'pdfjsNext':
return !!(globalSettings && globalSettings.pdfjsNext);
default: default:
throw new Error('Unknown default setting: ' + id); throw new Error('Unknown default setting: ' + id);
} }
@ -464,18 +461,11 @@ function isExternalLinkTargetSet() {
} }
} }
function isValidUrl(url, allowRelative) {
deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
var baseUrl = allowRelative ? 'http://example.com' : null;
return createValidAbsoluteUrl(url, baseUrl) !== null;
}
export { export {
CustomStyle, CustomStyle,
RenderingCancelledException, RenderingCancelledException,
addLinkAttributes, addLinkAttributes,
isExternalLinkTargetSet, isExternalLinkTargetSet,
isValidUrl,
getFilenameFromUrl, getFilenameFromUrl,
LinkTarget, LinkTarget,
getDefaultSetting, getDefaultSetting,

View File

@ -13,21 +13,20 @@
* limitations under the License. * limitations under the License.
*/ */
import {
_UnsupportedManager, getDocument, LoopbackPort, PDFDataRangeTransport,
PDFWorker
} from './api';
import { import {
addLinkAttributes, CustomStyle, DEFAULT_LINK_REL, getFilenameFromUrl, addLinkAttributes, CustomStyle, DEFAULT_LINK_REL, getFilenameFromUrl,
isExternalLinkTargetSet, isValidUrl, LinkTarget isExternalLinkTargetSet, isValidUrl, LinkTarget
} from './dom_utils'; } from './dom_utils';
import { import {
createBlob, createObjectURL, createPromiseCapability, deprecated, createBlob, createObjectURL, createPromiseCapability, getVerbosityLevel,
getVerbosityLevel, InvalidPDFException, isLittleEndian, InvalidPDFException, isLittleEndian, MissingPDFException, OPS, PageViewport,
MissingPDFException, OPS, PageViewport, PasswordException, PasswordResponses, PasswordException, PasswordResponses, removeNullCharacters, setVerbosityLevel,
removeNullCharacters, setVerbosityLevel, shadow, UnexpectedResponseException, shadow, UnexpectedResponseException, UnknownErrorException,
UnknownErrorException, UNSUPPORTED_FEATURES, Util, VERBOSITY_LEVELS, warn UNSUPPORTED_FEATURES, Util, VERBOSITY_LEVELS
} from '../shared/util'; } from '../shared/util';
import {
getDocument, LoopbackPort, PDFDataRangeTransport, PDFWorker
} from './api';
import { AnnotationLayer } from './annotation_layer'; import { AnnotationLayer } from './annotation_layer';
import globalScope from '../shared/global_scope'; import globalScope from '../shared/global_scope';
import { Metadata } from './metadata'; import { Metadata } from './metadata';
@ -239,47 +238,6 @@ PDFJS.externalLinkRel = (PDFJS.externalLinkRel === undefined ?
PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ? PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ?
true : PDFJS.isEvalSupported); true : PDFJS.isEvalSupported);
/**
* Opt-in to backwards incompatible API changes. NOTE:
* If the `PDFJS_NEXT` build flag is set, it will override this setting.
* @var {boolean}
*/
PDFJS.pdfjsNext = (PDFJS.pdfjsNext === undefined) ? false : PDFJS.pdfjsNext;
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('MOZCENTRAL')) {
var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
delete PDFJS.openExternalLinksInNewWindow;
Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
get() {
return PDFJS.externalLinkTarget === LinkTarget.BLANK;
},
set(value) {
if (value) {
deprecated('PDFJS.openExternalLinksInNewWindow, please use ' +
'"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
}
if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
warn('PDFJS.externalLinkTarget is already initialized');
return;
}
PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
},
enumerable: true,
configurable: true,
});
if (savedOpenExternalLinksInNewWindow) {
/**
* (Deprecated) Opens external links in a new window if enabled.
* The default behavior opens external links in the PDF.js window.
*
* NOTE: This property has been deprecated, please use
* `PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK` instead.
* @var {boolean}
*/
PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
}
}
PDFJS.getDocument = getDocument; PDFJS.getDocument = getDocument;
PDFJS.LoopbackPort = LoopbackPort; PDFJS.LoopbackPort = LoopbackPort;
PDFJS.PDFDataRangeTransport = PDFDataRangeTransport; PDFJS.PDFDataRangeTransport = PDFDataRangeTransport;
@ -300,8 +258,6 @@ PDFJS.Metadata = Metadata;
PDFJS.SVGGraphics = SVGGraphics; PDFJS.SVGGraphics = SVGGraphics;
PDFJS.UnsupportedManager = _UnsupportedManager;
export { export {
globalScope, globalScope,
PDFJS, PDFJS,

View File

@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { assert, deprecated } from '../shared/util'; import { assert } from '../shared/util';
import { SimpleXMLParser } from './dom_utils'; import { SimpleXMLParser } from './dom_utils';
class Metadata { class Metadata {
@ -98,11 +98,6 @@ class Metadata {
has(name) { has(name) {
return typeof this._metadata[name] !== 'undefined'; return typeof this._metadata[name] !== 'undefined';
} }
get metadata() {
deprecated('`metadata` getter; use `getAll()` instead.');
return this.getAll();
}
} }
export { export {

View File

@ -64,7 +64,6 @@ exports.UnexpectedResponseException =
pdfjsSharedUtil.UnexpectedResponseException; pdfjsSharedUtil.UnexpectedResponseException;
exports.OPS = pdfjsSharedUtil.OPS; exports.OPS = pdfjsSharedUtil.OPS;
exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES; exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl; exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
exports.createObjectURL = pdfjsSharedUtil.createObjectURL; exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters; exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;

View File

@ -839,6 +839,25 @@ PDFJS.compatibilityChecked = true;
}; };
})(); })();
// Provides support for Object.values in legacy browsers.
// Support: IE.
(function checkObjectValues() {
if (Object.values) {
return;
}
Object.values = require('core-js/fn/object/values');
})();
// Provides support for Array.prototype.includes in legacy browsers.
// Support: IE.
(function checkArrayIncludes() {
if (Array.prototype.includes) {
return;
}
Array.prototype.includes = require('core-js/fn/array/includes');
})();
// Provides support for Number.isNaN in legacy browsers. // Provides support for Number.isNaN in legacy browsers.
// Support: IE. // Support: IE.
(function checkNumberIsNaN() { (function checkNumberIsNaN() {

View File

@ -255,8 +255,6 @@ var Driver = (function DriverClosure() { // eslint-disable-line no-unused-vars
PDFJS.cMapUrl = '../external/bcmaps/'; PDFJS.cMapUrl = '../external/bcmaps/';
PDFJS.enableStats = true; PDFJS.enableStats = true;
PDFJS.imageResourcesPath = '/web/images/'; PDFJS.imageResourcesPath = '/web/images/';
// Opt-in to using the latest API.
PDFJS.pdfjsNext = true;
// Set the passed options // Set the passed options
this.inflight = options.inflight; this.inflight = options.inflight;

View File

@ -38,7 +38,6 @@ describe('api', function() {
beforeAll(function(done) { beforeAll(function(done) {
if (isNodeJS()) { if (isNodeJS()) {
PDFJS.pdfjsNext = true;
// NOTE: To support running the canvas-related tests in Node.js, // NOTE: To support running the canvas-related tests in Node.js,
// a `NodeCanvasFactory` would need to be added (in test_utils.js). // a `NodeCanvasFactory` would need to be added (in test_utils.js).
} else { } else {
@ -684,7 +683,7 @@ describe('api', function() {
it('gets javascript', function(done) { it('gets javascript', function(done) {
var promise = doc.getJavaScript(); var promise = doc.getJavaScript();
promise.then(function (data) { promise.then(function (data) {
expect(data).toEqual([]); expect(data).toEqual(null);
done(); done();
}).catch(function (reason) { }).catch(function (reason) {
done.fail(reason); done.fail(reason);

View File

@ -17,7 +17,6 @@ import { buildGetDocumentParams } from './test_utils';
import { DOMCanvasFactory } from '../../src/display/dom_utils'; import { DOMCanvasFactory } from '../../src/display/dom_utils';
import { getDocument } from '../../src/display/api'; import { getDocument } from '../../src/display/api';
import { isNodeJS } from '../../src/shared/util'; import { isNodeJS } from '../../src/shared/util';
import { PDFJS } from '../../src/display/global';
function getTopLeftPixel(canvasContext) { function getTopLeftPixel(canvasContext) {
let imgData = canvasContext.getImageData(0, 0, 1, 1); let imgData = canvasContext.getImageData(0, 0, 1, 1);
@ -38,7 +37,6 @@ describe('custom canvas rendering', function() {
beforeAll(function(done) { beforeAll(function(done) {
if (isNodeJS()) { if (isNodeJS()) {
PDFJS.pdfjsNext = true;
// NOTE: To support running the canvas-related tests in Node.js, // NOTE: To support running the canvas-related tests in Node.js,
// a `NodeCanvasFactory` would need to be added (in test_utils.js). // a `NodeCanvasFactory` would need to be added (in test_utils.js).
} else { } else {

View File

@ -90,8 +90,6 @@ function initializePDFJS(callback) {
// Configure the worker. // Configure the worker.
displayGlobal.PDFJS.workerSrc = '../../build/generic/build/pdf.worker.js'; displayGlobal.PDFJS.workerSrc = '../../build/generic/build/pdf.worker.js';
// Opt-in to using the latest API.
displayGlobal.PDFJS.pdfjsNext = true;
callback(); callback();
}); });

View File

@ -55,13 +55,11 @@ function configure(PDFJS) {
} }
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) { if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {
PDFJS.cMapUrl = '../external/bcmaps/'; PDFJS.cMapUrl = '../external/bcmaps/';
PDFJS.cMapPacked = true;
PDFJS.workerSrc = '../src/worker_loader.js'; PDFJS.workerSrc = '../src/worker_loader.js';
PDFJS.pdfjsNext = true;
} else { } else {
PDFJS.cMapUrl = '../web/cmaps/'; PDFJS.cMapUrl = '../web/cmaps/';
PDFJS.cMapPacked = true;
} }
PDFJS.cMapPacked = true;
} }
const DefaultExternalServices = { const DefaultExternalServices = {
@ -633,11 +631,6 @@ let PDFViewerApplication = {
* is opened. * is opened.
*/ */
open(file, args) { open(file, args) {
if ((typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) &&
(arguments.length > 2 || typeof args === 'number')) {
return Promise.reject(
new Error('Call of open() with obsolete signature.'));
}
if (this.pdfLoadingTask) { if (this.pdfLoadingTask) {
// We need to destroy already opened document. // We need to destroy already opened document.
return this.close().then(() => { return this.close().then(() => {
@ -667,12 +660,7 @@ let PDFViewerApplication = {
if (args) { if (args) {
for (let prop in args) { for (let prop in args) {
if ((typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PDFJS_NEXT')) && if (prop === 'length') {
!PDFJS.pdfjsNext && prop === 'scale') {
console.error('Call of open() with obsolete "scale" argument, ' +
'please use the "defaultZoomValue" preference instead.');
continue;
} else if (prop === 'length') {
this.pdfDocumentProperties.setFileSize(args[prop]); this.pdfDocumentProperties.setFileSize(args[prop]);
} }
parameters[prop] = args[prop]; parameters[prop] = args[prop];
@ -1047,7 +1035,7 @@ let PDFViewerApplication = {
return; return;
} }
pdfDocument.getJavaScript().then((javaScript) => { pdfDocument.getJavaScript().then((javaScript) => {
if (javaScript.length === 0) { if (!javaScript) {
return; return;
} }
javaScript.some((js) => { javaScript.some((js) => {

View File

@ -601,11 +601,6 @@ class BaseViewer {
* @param {ScrollPageIntoViewParameters} params * @param {ScrollPageIntoViewParameters} params
*/ */
scrollPageIntoView(params) { scrollPageIntoView(params) {
if ((typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) &&
(arguments.length > 1 || typeof params === 'number')) {
console.error('Call of scrollPageIntoView() with obsolete signature.');
return;
}
if (!this.pdfDocument) { if (!this.pdfDocument) {
return; return;
} }

View File

@ -46,22 +46,8 @@ class PDFCursorTools {
this._addEventListeners(); this._addEventListeners();
Promise.all([ preferences.get('cursorToolOnLoad').then((value) => {
preferences.get('cursorToolOnLoad'), this.switchTool(value);
preferences.get('enableHandToolOnLoad')
]).then(([cursorToolPref, handToolPref]) => {
// If the 'cursorToolOnLoad' preference has not been set to a non-default
// value, attempt to convert the old 'enableHandToolOnLoad' preference.
// TODO: Remove this conversion after a suitable number of releases.
if (handToolPref === true) {
preferences.set('enableHandToolOnLoad', false);
if (cursorToolPref === CursorTool.SELECT) {
cursorToolPref = CursorTool.HAND;
preferences.set('cursorToolOnLoad', cursorToolPref).catch(() => { });
}
}
this.switchTool(cursorToolPref);
}).catch(() => { }); }).catch(() => { });
} }

View File

@ -260,14 +260,6 @@ class PDFLinkService {
}); });
} }
} else { // Named (or explicit) destination. } else { // Named (or explicit) destination.
if ((typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) &&
/^\d+$/.test(hash) && hash <= this.pagesCount) {
console.warn('PDFLinkService_setHash: specifying a page number ' +
'directly after the hash symbol (#) is deprecated, ' +
`please use the "#page=${hash}" form instead.`);
this.page = hash | 0;
}
dest = unescape(hash); dest = unescape(hash);
try { try {
dest = JSON.parse(dest); dest = JSON.parse(dest);

View File

@ -412,9 +412,7 @@ class PDFPageView {
this.paintTask = null; this.paintTask = null;
} }
if (((typeof PDFJSDev === 'undefined' || if (error instanceof RenderingCancelledException) {
!PDFJSDev.test('PDFJS_NEXT')) && error === 'cancelled') ||
error instanceof RenderingCancelledException) {
this.error = null; this.error = null;
return Promise.resolve(undefined); return Promise.resolve(undefined);
} }
@ -594,13 +592,8 @@ class PDFPageView {
let cancelled = false; let cancelled = false;
let ensureNotCancelled = () => { let ensureNotCancelled = () => {
if (cancelled) { if (cancelled) {
if ((typeof PDFJSDev !== 'undefined' && throw new RenderingCancelledException(
PDFJSDev.test('PDFJS_NEXT')) || PDFJS.pdfjsNext) { 'Rendering cancelled, page ' + this.id, 'svg');
throw new RenderingCancelledException(
'Rendering cancelled, page ' + this.id, 'svg');
} else {
throw 'cancelled'; // eslint-disable-line no-throw-literal
}
} }
}; };

View File

@ -303,9 +303,7 @@ class PDFThumbnailView {
this.renderTask = null; this.renderTask = null;
} }
if (((typeof PDFJSDev === 'undefined' || if (error instanceof RenderingCancelledException) {
!PDFJSDev.test('PDFJS_NEXT')) && error === 'cancelled') ||
error instanceof RenderingCancelledException) {
renderCapability.resolve(undefined); renderCapability.resolve(undefined);
return; return;
} }