12 changed files with 332 additions and 323 deletions
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
/* Copyright 2017 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-env node */ |
||||
|
||||
'use strict'; |
||||
|
||||
function isPDFJSDevCheck(test) { |
||||
// Is it something like `typeof __pdfjsdev_webpack__ === 'undefined'`?
|
||||
return test.type === 'BinaryExpression' && |
||||
(test.operator === '===' || test.operator === '!==' || |
||||
test.operator === '==' || test.operator === '!=') && |
||||
test.left.type === 'UnaryExpression' && |
||||
test.left.operator === 'typeof' && |
||||
test.left.argument.type === 'Identifier' && |
||||
test.left.argument.name === '__pdfjsdev_webpack__' && |
||||
test.right.type === 'Literal' && test.right.value === 'undefined'; |
||||
} |
||||
|
||||
function isPDFJSDevEnabled(test) { |
||||
return test.operator[0] === '!'; |
||||
} |
||||
|
||||
function BlockRequirePlugin() {} |
||||
|
||||
BlockRequirePlugin.prototype.apply = function(compiler) { |
||||
compiler.plugin('compilation', function(compilation, data) { |
||||
data.normalModuleFactory.plugin('parser', function (parser, options) { |
||||
parser.plugin('statement if', function (ifNode) { |
||||
if (isPDFJSDevCheck(ifNode.test)) { |
||||
return isPDFJSDevEnabled(ifNode.test); |
||||
} |
||||
return undefined; |
||||
}); |
||||
}); |
||||
}); |
||||
}; |
||||
|
||||
module.exports = BlockRequirePlugin; |
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
/* Copyright 2017 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-env node */ |
||||
|
||||
'use strict'; |
||||
|
||||
var preprocessor2 = require('../builder/preprocessor2.js'); |
||||
|
||||
module.exports = function (source) { |
||||
// Options must be specified, ignoring request if not.
|
||||
if (!this.query || typeof this.query !== 'object') { |
||||
return source; |
||||
} |
||||
this.cacheable(); |
||||
var ctx = this.query; |
||||
source = preprocessor2.preprocessPDFJSCode(ctx, source); |
||||
return source; |
||||
}; |
@ -0,0 +1,30 @@
@@ -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; |
Loading…
Reference in new issue