2015-12-22 04:46:50 +09:00
|
|
|
/* 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.
|
|
|
|
*/
|
2015-12-24 08:46:08 +09:00
|
|
|
/* globals PDFJS, require, module, requirejs */
|
2015-12-22 04:46:50 +09:00
|
|
|
|
|
|
|
// included from api.js for GENERIC build
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var useRequireEnsure = false;
|
|
|
|
if (typeof module !== 'undefined' && module.require) {
|
|
|
|
// node.js - disable worker and set require.ensure.
|
|
|
|
PDFJS.disableWorker = true;
|
|
|
|
if (typeof require.ensure === 'undefined') {
|
|
|
|
require.ensure = require('node-ensure');
|
|
|
|
}
|
|
|
|
useRequireEnsure = true;
|
|
|
|
}
|
|
|
|
if (typeof __webpack_require__ !== 'undefined') {
|
|
|
|
// Webpack - get/bundle pdf.worker.js as additional file.
|
|
|
|
PDFJS.workerSrc = require('entry?name=[hash]-worker.js!./pdf.worker.js');
|
|
|
|
useRequireEnsure = true;
|
|
|
|
}
|
2015-12-24 08:46:08 +09:00
|
|
|
if (typeof requirejs !== 'undefined' && requirejs.toUrl) {
|
|
|
|
PDFJS.workerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js');
|
|
|
|
}
|
|
|
|
var fakeWorkerFilesLoader = useRequireEnsure ? (function (callback) {
|
2015-12-22 04:46:50 +09:00
|
|
|
require.ensure([], function () {
|
2016-03-03 10:16:38 +09:00
|
|
|
var worker = require('./pdf.worker.js');
|
|
|
|
callback(worker.WorkerMessageHandler);
|
2015-12-22 04:46:50 +09:00
|
|
|
});
|
2015-12-24 08:46:08 +09:00
|
|
|
}) : (typeof requirejs !== 'undefined') ? (function (callback) {
|
|
|
|
requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) {
|
2016-03-03 10:16:38 +09:00
|
|
|
callback(worker.WorkerMessageHandler);
|
2015-12-24 08:46:08 +09:00
|
|
|
});
|
|
|
|
}) : null;
|