1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Replacing custom bundling with webpack2.

This commit is contained in:
Yury Delendik 2017-02-08 16:32:15 -06:00
parent d7cb46dafc
commit eb4c88cd44
12 changed files with 330 additions and 321 deletions

View file

@ -12,8 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals pdfjsFilePath, pdfjsVersion, pdfjsBuild, requirejs, pdfjsLibs,
__webpack_require__ */
/* globals requirejs, pdfjsLibs, __webpack_require__, __pdfjsdev_webpack__ */
'use strict';
@ -70,10 +69,18 @@ var isWorkerDisabled = false;
var workerSrc;
var isPostMessageTransfersDisabled = false;
var pdfjsFilePath =
typeof PDFJSDev !== 'undefined' &&
PDFJSDev.test('PRODUCTION && !(MOZCENTRAL || FIREFOX)') &&
typeof document !== 'undefined' && document.currentScript ?
document.currentScript.src : null;
var fakeWorkerFilesLoader = null;
var useRequireEnsure = false;
// The if below protected by __pdfjsdev_webpack__ check from webpack parsing.
if (typeof PDFJSDev !== 'undefined' &&
PDFJSDev.test('GENERIC && !SINGLE_FILE')) {
PDFJSDev.test('GENERIC && !SINGLE_FILE') &&
typeof __pdfjsdev_webpack__ === 'undefined') {
// For GENERIC build we need add support of different fake file loaders
// for different frameworks.
if (typeof window === 'undefined') {
@ -83,8 +90,8 @@ if (typeof PDFJSDev !== 'undefined' &&
require.ensure = require('node-ensure');
}
useRequireEnsure = true;
}
if (typeof __webpack_require__ !== 'undefined') {
} else if (typeof require !== 'undefined' &&
typeof require.ensure === 'function') {
useRequireEnsure = true;
}
if (typeof requirejs !== 'undefined' && requirejs.toUrl) {
@ -2184,11 +2191,9 @@ var _UnsupportedManager = (function UnsupportedManagerClosure() {
};
})();
if (typeof pdfjsVersion !== 'undefined') {
exports.version = pdfjsVersion;
}
if (typeof pdfjsBuild !== 'undefined') {
exports.build = pdfjsBuild;
if (typeof PDFJSDev !== 'undefined') {
exports.version = PDFJSDev.eval('BUNDLE_VERSION');
exports.build = PDFJSDev.eval('BUNDLE_BUILD');
}
exports.getDocument = getDocument;

View file

@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals pdfjsVersion, pdfjsBuild */
'use strict';
@ -54,11 +53,9 @@
}
var PDFJS = globalScope.PDFJS;
if (typeof pdfjsVersion !== 'undefined') {
PDFJS.version = pdfjsVersion;
}
if (typeof pdfjsBuild !== 'undefined') {
PDFJS.build = pdfjsBuild;
if (typeof PDFJSDev !== 'undefined') {
PDFJS.version = PDFJSDev.eval('BUNDLE_VERSION');
PDFJS.build = PDFJSDev.eval('BUNDLE_BUILD');
}
PDFJS.pdfBug = false;

View file

@ -12,75 +12,50 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint strict: ["error", "function"] */
/* eslint-disable no-unused-vars */
/* umdutils ignore */
(function (root, factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(PDFJSDev.eval('BUNDLE_AMD_NAME'), ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root[PDFJSDev.eval('BUNDLE_JS_NAME')] = {}));
}
}(this, function (exports) {
// Use strict in our context only - users might not want it
'use strict';
'use strict';
var pdfjsVersion = PDFJSDev.eval('BUNDLE_VERSION');
var pdfjsBuild = PDFJSDev.eval('BUNDLE_BUILD');
var pdfjsVersion = PDFJSDev.eval('BUNDLE_VERSION');
var pdfjsBuild = PDFJSDev.eval('BUNDLE_BUILD');
var pdfjsFilePath =
typeof document !== 'undefined' && document.currentScript ?
document.currentScript.src : null;
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');
var pdfjsDisplayDOMUtils = require('./display/dom_utils.js');
var pdfjsDisplaySVG = require('./display/svg.js');
var pdfjsLibs = {};
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('SINGLE_FILE')) {
require('./core/worker.js');
require('./core/network.js');
}
(function pdfjsWrapper() {
//#expand __BUNDLE__
}).call(pdfjsLibs);
if (PDFJSDev.test('MAIN_FILE')) {
exports.PDFJS = pdfjsLibs.pdfjsDisplayGlobal.PDFJS;
exports.build = pdfjsLibs.pdfjsDisplayAPI.build;
exports.version = pdfjsLibs.pdfjsDisplayAPI.version;
exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument;
exports.PDFDataRangeTransport =
pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport;
exports.PDFWorker = pdfjsLibs.pdfjsDisplayAPI.PDFWorker;
exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer;
exports.AnnotationLayer =
pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer;
exports.CustomStyle = pdfjsLibs.pdfjsDisplayDOMUtils.CustomStyle;
exports.createPromiseCapability =
pdfjsLibs.pdfjsSharedUtil.createPromiseCapability;
exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses;
exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException;
exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException;
exports.SVGGraphics = pdfjsLibs.pdfjsDisplaySVG.SVGGraphics;
exports.UnexpectedResponseException =
pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException;
exports.OPS = pdfjsLibs.pdfjsSharedUtil.OPS;
exports.UNSUPPORTED_FEATURES =
pdfjsLibs.pdfjsSharedUtil.UNSUPPORTED_FEATURES;
exports.isValidUrl = pdfjsLibs.pdfjsDisplayDOMUtils.isValidUrl;
exports.createValidAbsoluteUrl =
pdfjsLibs.pdfjsSharedUtil.createValidAbsoluteUrl;
exports.createObjectURL = pdfjsLibs.pdfjsSharedUtil.createObjectURL;
exports.removeNullCharacters =
pdfjsLibs.pdfjsSharedUtil.removeNullCharacters;
exports.shadow = pdfjsLibs.pdfjsSharedUtil.shadow;
exports.createBlob = pdfjsLibs.pdfjsSharedUtil.createBlob;
exports.getFilenameFromUrl =
pdfjsLibs.pdfjsDisplayDOMUtils.getFilenameFromUrl;
exports.addLinkAttributes =
pdfjsLibs.pdfjsDisplayDOMUtils.addLinkAttributes;
} else {
exports.WorkerMessageHandler =
pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
}
}));
exports.PDFJS = pdfjsDisplayGlobal.PDFJS;
exports.build = pdfjsDisplayAPI.build;
exports.version = pdfjsDisplayAPI.version;
exports.getDocument = pdfjsDisplayAPI.getDocument;
exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport;
exports.PDFWorker = pdfjsDisplayAPI.PDFWorker;
exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer;
exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer;
exports.CustomStyle = pdfjsDisplayDOMUtils.CustomStyle;
exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability;
exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses;
exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException;
exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException;
exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics;
exports.UnexpectedResponseException =
pdfjsSharedUtil.UnexpectedResponseException;
exports.OPS = pdfjsSharedUtil.OPS;
exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES;
exports.isValidUrl = pdfjsDisplayDOMUtils.isValidUrl;
exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl;
exports.createObjectURL = pdfjsSharedUtil.createObjectURL;
exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
exports.shadow = pdfjsSharedUtil.shadow;
exports.createBlob = pdfjsSharedUtil.createBlob;
exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl;
exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes;

30
src/pdf.worker.js vendored Normal file
View file

@ -0,0 +1,30 @@
/* Copyright 2012 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.
*/
/* eslint-disable no-unused-vars */
/* umdutils ignore */
'use strict';
var pdfjsVersion = PDFJSDev.eval('BUNDLE_VERSION');
var pdfjsBuild = PDFJSDev.eval('BUNDLE_BUILD');
var pdfjsCoreWorker = require('./core/worker.js');
if (typeof PDFJSDev === 'undefined' ||
!PDFJSDev.test('FIREFOX || MOZCENTRAL')) {
require('./core/network.js');
}
exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;