2012-09-01 07:48:21 +09:00
|
|
|
/* 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.
|
|
|
|
*/
|
2013-08-13 02:48:06 +09:00
|
|
|
/* globals PDFJS, Util */
|
2011-10-26 10:18:22 +09:00
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
2014-01-24 06:24:04 +09:00
|
|
|
// List of shared files to include;
|
|
|
|
var sharedFiles = [
|
2015-11-22 01:32:47 +09:00
|
|
|
'shared/global.js',
|
2014-06-18 07:43:33 +09:00
|
|
|
'shared/util.js'
|
2014-01-24 06:24:04 +09:00
|
|
|
];
|
|
|
|
|
|
|
|
// List of other files to include;
|
|
|
|
var otherFiles = [
|
2013-08-13 02:48:06 +09:00
|
|
|
'core/network.js',
|
2015-11-22 01:32:47 +09:00
|
|
|
'core/arithmetic_decoder.js',
|
|
|
|
'core/charsets.js',
|
|
|
|
'core/glyphlist.js',
|
|
|
|
'core/jpg.js',
|
|
|
|
'core/metrics.js',
|
|
|
|
'core/bidi.js',
|
2013-08-13 02:48:06 +09:00
|
|
|
'core/chunked_stream.js',
|
2015-11-22 01:32:47 +09:00
|
|
|
'core/jbig2.js',
|
|
|
|
'core/jpx.js',
|
|
|
|
'core/murmurhash3.js',
|
|
|
|
'core/primitives.js',
|
|
|
|
'core/stream.js',
|
|
|
|
'core/crypto.js',
|
|
|
|
'core/font_renderer.js',
|
|
|
|
'core/parser.js',
|
|
|
|
'core/cmap.js',
|
2013-08-13 02:48:06 +09:00
|
|
|
'core/obj.js',
|
2015-11-22 01:32:47 +09:00
|
|
|
'core/ps_parser.js',
|
|
|
|
'core/fonts.js',
|
2014-05-22 03:06:23 +09:00
|
|
|
'core/function.js',
|
2014-05-22 02:57:15 +09:00
|
|
|
'core/colorspace.js',
|
2015-11-22 01:32:47 +09:00
|
|
|
'core/image.js',
|
2014-01-26 03:18:22 +09:00
|
|
|
'core/pattern.js',
|
2013-08-13 02:48:06 +09:00
|
|
|
'core/evaluator.js',
|
2015-11-22 01:32:47 +09:00
|
|
|
'core/annotation.js',
|
|
|
|
'core/document.js',
|
|
|
|
'core/pdf_manager.js',
|
|
|
|
'core/worker.js'
|
2011-12-22 23:40:00 +09:00
|
|
|
];
|
|
|
|
|
2013-08-13 02:48:06 +09:00
|
|
|
function loadInOrder(index, path, files) {
|
|
|
|
if (index >= files.length) {
|
2014-05-03 02:23:46 +09:00
|
|
|
PDFJS.fakeWorkerFilesLoadedCapability.resolve();
|
2013-08-13 02:48:06 +09:00
|
|
|
return;
|
|
|
|
}
|
2014-01-24 06:24:04 +09:00
|
|
|
PDFJS.Util.loadScript(path + files[index],
|
2013-08-13 02:48:06 +09:00
|
|
|
loadInOrder.bind(null, ++index, path, files));
|
|
|
|
}
|
|
|
|
|
2011-12-22 23:40:00 +09:00
|
|
|
// Load all the files.
|
2014-05-03 02:23:46 +09:00
|
|
|
if (typeof PDFJS === 'undefined' || !PDFJS.fakeWorkerFilesLoadedCapability) {
|
2014-01-24 06:24:04 +09:00
|
|
|
var files = sharedFiles.concat(otherFiles);
|
2013-08-13 02:48:06 +09:00
|
|
|
for (var i = 0; i < files.length; i++) {
|
|
|
|
importScripts(files[i]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
var src = PDFJS.workerSrc;
|
2014-01-24 06:24:04 +09:00
|
|
|
var path = src.substr(0, src.indexOf('worker_loader.js'));
|
|
|
|
// If Util is available, we assume that shared files are already loaded. Can
|
|
|
|
// happen that they are not if PDF.js is bundled inside a special namespace.
|
|
|
|
var skipShared = typeof Util !== 'undefined';
|
|
|
|
var files = skipShared ? otherFiles : sharedFiles.concat(otherFiles);
|
|
|
|
loadInOrder(0, path, files);
|
2011-11-03 07:00:08 +09:00
|
|
|
}
|