mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 23:58:07 +02:00
Merge pull request #8046 from yurydelendik/webpack
Replacing custom bundling with webpack 2
This commit is contained in:
commit
32856f0adb
16 changed files with 453 additions and 317 deletions
|
@ -12,7 +12,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals DEFAULT_URL, PDFBug, Stats */
|
||||
/* globals PDFBug, Stats */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -1396,20 +1396,20 @@ function loadAndEnablePDFBug(enabledTabs) {
|
|||
}
|
||||
|
||||
function webViewerInitialized() {
|
||||
var appConfig = PDFViewerApplication.appConfig;
|
||||
var file;
|
||||
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
|
||||
var queryString = document.location.search.substring(1);
|
||||
var params = parseQueryString(queryString);
|
||||
file = 'file' in params ? params.file : DEFAULT_URL;
|
||||
file = 'file' in params ? params.file : appConfig.defaultUrl;
|
||||
validateFileURL(file);
|
||||
} else if (PDFJSDev.test('FIREFOX || MOZCENTRAL')) {
|
||||
file = window.location.href.split('#')[0];
|
||||
} else if (PDFJSDev.test('CHROME')) {
|
||||
file = DEFAULT_URL;
|
||||
file = appConfig.defaultUrl;
|
||||
}
|
||||
|
||||
var waitForBeforeOpening = [];
|
||||
var appConfig = PDFViewerApplication.appConfig;
|
||||
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
|
||||
var fileInput = document.createElement('input');
|
||||
fileInput.id = appConfig.openFileInputName;
|
||||
|
|
|
@ -12,50 +12,38 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* eslint strict: ["error", "function"] */
|
||||
/* umdutils ignore */
|
||||
|
||||
(function (root, factory) {
|
||||
'use strict';
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs-dist/web/pdf_viewer', ['exports', 'pdfjs-dist/build/pdf'],
|
||||
factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../build/pdf.js'));
|
||||
} else {
|
||||
factory((root.pdfjsDistWebPDFViewer = {}), root.pdfjsDistBuildPdf);
|
||||
}
|
||||
}(this, function (exports, pdfjsLib) {
|
||||
'use strict';
|
||||
'use strict';
|
||||
|
||||
var pdfViewerLibs = {
|
||||
pdfjsWebPDFJS: pdfjsLib
|
||||
};
|
||||
var pdfjsLib = require('./pdfjs.js');
|
||||
var pdfjsWebPDFViewer = require('./pdf_viewer.js');
|
||||
var pdfjsWebPDFPageView = require('./pdf_page_view.js');
|
||||
var pdfjsWebPDFLinkService = require('./pdf_link_service.js');
|
||||
var pdfjsWebTextLayerBuilder = require('./text_layer_builder.js');
|
||||
var pdfjsWebAnnotationLayerBuilder = require('./annotation_layer_builder.js');
|
||||
var pdfjsWebPDFHistory = require('./pdf_history.js');
|
||||
var pdfjsWebPDFFindController = require('./pdf_find_controller.js');
|
||||
var pdfjsWebUIUtils = require('./ui_utils.js');
|
||||
var pdfjsWebDownloadManager = require('./download_manager.js');
|
||||
|
||||
(function () {
|
||||
//#expand __BUNDLE__
|
||||
}).call(pdfViewerLibs);
|
||||
var PDFJS = pdfjsLib.PDFJS;
|
||||
|
||||
var PDFJS = pdfjsLib.PDFJS;
|
||||
PDFJS.PDFViewer = pdfjsWebPDFViewer.PDFViewer;
|
||||
PDFJS.PDFPageView = pdfjsWebPDFPageView.PDFPageView;
|
||||
PDFJS.PDFLinkService = pdfjsWebPDFLinkService.PDFLinkService;
|
||||
PDFJS.TextLayerBuilder = pdfjsWebTextLayerBuilder.TextLayerBuilder;
|
||||
PDFJS.DefaultTextLayerFactory =
|
||||
pdfjsWebTextLayerBuilder.DefaultTextLayerFactory;
|
||||
PDFJS.AnnotationLayerBuilder =
|
||||
pdfjsWebAnnotationLayerBuilder.AnnotationLayerBuilder;
|
||||
PDFJS.DefaultAnnotationLayerFactory =
|
||||
pdfjsWebAnnotationLayerBuilder.DefaultAnnotationLayerFactory;
|
||||
PDFJS.PDFHistory = pdfjsWebPDFHistory.PDFHistory;
|
||||
PDFJS.PDFFindController = pdfjsWebPDFFindController.PDFFindController;
|
||||
PDFJS.EventBus = pdfjsWebUIUtils.EventBus;
|
||||
|
||||
PDFJS.PDFViewer = pdfViewerLibs.pdfjsWebPDFViewer.PDFViewer;
|
||||
PDFJS.PDFPageView = pdfViewerLibs.pdfjsWebPDFPageView.PDFPageView;
|
||||
PDFJS.PDFLinkService = pdfViewerLibs.pdfjsWebPDFLinkService.PDFLinkService;
|
||||
PDFJS.TextLayerBuilder =
|
||||
pdfViewerLibs.pdfjsWebTextLayerBuilder.TextLayerBuilder;
|
||||
PDFJS.DefaultTextLayerFactory =
|
||||
pdfViewerLibs.pdfjsWebTextLayerBuilder.DefaultTextLayerFactory;
|
||||
PDFJS.AnnotationLayerBuilder =
|
||||
pdfViewerLibs.pdfjsWebAnnotationLayerBuilder.AnnotationLayerBuilder;
|
||||
PDFJS.DefaultAnnotationLayerFactory =
|
||||
pdfViewerLibs.pdfjsWebAnnotationLayerBuilder.DefaultAnnotationLayerFactory;
|
||||
PDFJS.PDFHistory = pdfViewerLibs.pdfjsWebPDFHistory.PDFHistory;
|
||||
PDFJS.PDFFindController =
|
||||
pdfViewerLibs.pdfjsWebPDFFindController.PDFFindController;
|
||||
PDFJS.EventBus = pdfViewerLibs.pdfjsWebUIUtils.EventBus;
|
||||
PDFJS.DownloadManager = pdfjsWebDownloadManager.DownloadManager;
|
||||
PDFJS.ProgressBar = pdfjsWebUIUtils.ProgressBar;
|
||||
|
||||
PDFJS.DownloadManager = pdfViewerLibs.pdfjsWebDownloadManager.DownloadManager;
|
||||
PDFJS.ProgressBar = pdfViewerLibs.pdfjsWebUIUtils.ProgressBar;
|
||||
|
||||
exports.PDFJS = PDFJS;
|
||||
}));
|
||||
exports.PDFJS = PDFJS;
|
||||
|
|
35
web/pdfjs.js
35
web/pdfjs.js
|
@ -12,23 +12,28 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals module */
|
||||
/* umdutils ignore */
|
||||
|
||||
'use strict';
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs-web/pdfjs', ['exports', 'pdfjs/main_loader'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../src/main_loader.js'));
|
||||
} else {
|
||||
factory((root.pdfjsWebPDFJS = {}), root.pdfjsMainLoader);
|
||||
}
|
||||
}(this, function (exports, mainLoader) {
|
||||
// Re-export all mainLoader members.
|
||||
for (var i in mainLoader) {
|
||||
if (Object.prototype.hasOwnProperty.call(mainLoader, i)) {
|
||||
exports[i] = mainLoader[i];
|
||||
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION')) {
|
||||
module.exports = window['pdfjs-dist/build/pdf']; // loaded via html script tag
|
||||
} else {
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs-web/pdfjs', ['exports', 'pdfjs/main_loader'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../src/main_loader.js'));
|
||||
} else {
|
||||
factory((root.pdfjsWebPDFJS = {}), root.pdfjsMainLoader);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}(this, function (exports, mainLoader) {
|
||||
// Re-export all mainLoader members.
|
||||
for (var i in mainLoader) {
|
||||
if (Object.prototype.hasOwnProperty.call(mainLoader, i)) {
|
||||
exports[i] = mainLoader[i];
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -35,19 +35,21 @@ if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {
|
|||
})();
|
||||
}
|
||||
|
||||
var pdfjsWebLibs;
|
||||
var pdfjsWebApp;
|
||||
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION')) {
|
||||
pdfjsWebLibs = {
|
||||
pdfjsWebPDFJS: window.pdfjsDistBuildPdf
|
||||
};
|
||||
(function () {
|
||||
//#expand __BUNDLE__
|
||||
}).call(pdfjsWebLibs);
|
||||
pdfjsWebApp = require('./app.js');
|
||||
}
|
||||
|
||||
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('FIREFOX || MOZCENTRAL')) {
|
||||
// FIXME the l10n.js file in the Firefox extension needs global FirefoxCom.
|
||||
window.FirefoxCom = pdfjsWebLibs.pdfjsWebFirefoxCom.FirefoxCom;
|
||||
window.FirefoxCom = require('./firefoxcom.js').FirefoxCom;
|
||||
require('./firefox_print_service.js');
|
||||
}
|
||||
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {
|
||||
require('./chromecom.js');
|
||||
}
|
||||
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME || GENERIC')) {
|
||||
require('./pdf_print_service.js');
|
||||
}
|
||||
|
||||
function getViewerConfiguration() {
|
||||
|
@ -162,6 +164,7 @@ function getViewerConfiguration() {
|
|||
printContainer: document.getElementById('printContainer'),
|
||||
openFileInputName: 'fileInput',
|
||||
debuggerScriptPath: './debugger.js',
|
||||
defaultUrl: DEFAULT_URL
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -174,8 +177,8 @@ function webViewerLoad() {
|
|||
web.PDFViewerApplication.run(config);
|
||||
});
|
||||
} else {
|
||||
window.PDFViewerApplication = pdfjsWebLibs.pdfjsWebApp.PDFViewerApplication;
|
||||
pdfjsWebLibs.pdfjsWebApp.PDFViewerApplication.run(config);
|
||||
window.PDFViewerApplication = pdfjsWebApp.PDFViewerApplication;
|
||||
pdfjsWebApp.PDFViewerApplication.run(config);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue