[Pkg-javascript-commits] [pdf.js] 03/414: Allows requirejs and node load fake worker files.
David Prévot
taffit at moszumanska.debian.org
Tue Jun 28 17:11:59 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit b084dc09eea7da13987ba5cda7055e21cddafd38
Author: Yury Delendik <ydelendik at mozilla.com>
Date: Mon Nov 23 11:46:40 2015 -0600
Allows requirejs and node load fake worker files.
---
src/core/worker.js | 2 +-
src/display/api.js | 15 ++++++++++++---
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/core/worker.js b/src/core/worker.js
index 4245710..78632f7 100644
--- a/src/core/worker.js
+++ b/src/core/worker.js
@@ -648,7 +648,7 @@ var workerConsole = {
// Worker thread?
-if (typeof window === 'undefined') {
+if (typeof window === 'undefined' && typeof require === 'undefined') {
if (!('console' in globalScope)) {
globalScope.console = workerConsole;
}
diff --git a/src/display/api.js b/src/display/api.js
index e95409f..1cf5c51 100644
--- a/src/display/api.js
+++ b/src/display/api.js
@@ -19,7 +19,7 @@
if (typeof define === 'function' && define.amd) {
define('pdfjs/display/api', ['exports', 'pdfjs/shared/util',
'pdfjs/display/font_loader', 'pdfjs/display/canvas',
- 'pdfjs/shared/global'], factory);
+ 'pdfjs/shared/global', 'require'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../shared/util.js'), require('./font_loader.js'),
require('./canvas.js'), require('../shared/global.js'));
@@ -29,7 +29,7 @@
root.pdfjsSharedGlobal);
}
}(this, function (exports, sharedUtil, displayFontLoader, displayCanvas,
- sharedGlobal) {
+ sharedGlobal, amdRequire) {
var InvalidPDFException = sharedUtil.InvalidPDFException;
var MessageHandler = sharedUtil.MessageHandler;
@@ -1169,7 +1169,16 @@ var PDFWorker = (function PDFWorkerClosure() {
// other files and resolves the promise. In production only the
// pdf.worker.js file is needed.
//#if !PRODUCTION
- Util.loadScript(PDFJS.workerSrc);
+ if (typeof amdRequire === 'function') {
+ amdRequire(['pdfjs/core/worker'], function () {
+ PDFJS.fakeWorkerFilesLoadedCapability.resolve();
+ });
+ } else if (typeof require === 'function') {
+ require('../core/worker.js');
+ PDFJS.fakeWorkerFilesLoadedCapability.resolve();
+ } else {
+ Util.loadScript(PDFJS.workerSrc);
+ }
//#endif
//#if PRODUCTION && SINGLE_FILE
// PDFJS.fakeWorkerFilesLoadedCapability.resolve();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list