Skip to content

Commit

Permalink
Adds UMD headers to core, display and shared files.
Browse files Browse the repository at this point in the history
  • Loading branch information
yurydelendik committed Dec 11, 2015
1 parent 4d6f3c8 commit e7577a7
Show file tree
Hide file tree
Showing 54 changed files with 1,870 additions and 565 deletions.
6 changes: 6 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
"browser": true,
"devel": true,
"worker": true,
"predef": [
"Promise",
"require",
"define",
"exports"
],

// Enforcing
"maxlen": 80,
Expand Down
14 changes: 7 additions & 7 deletions examples/acroforms/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
<head>
<!-- In production, only one script (pdf.js) is necessary -->
<!-- In production, change the content of PDFJS.workerSrc below -->
<script src="../../src/shared/global.js"></script>
<script src="../../src/display/dom_utils.js"></script>
<script src="../../src/shared/util.js"></script>
<script src="../../src/display/api.js"></script>
<script src="../../src/display/annotation_helper.js"></script>
<script src="../../src/display/font_loader.js"></script>
<script src="../../src/display/metadata.js"></script>
<script src="../../src/display/canvas.js"></script>
<script src="../../src/display/text_layer.js"></script>
<script src="../../src/display/webgl.js"></script>
<script src="../../src/display/pattern_helper.js"></script>
<script src="../../src/display/font_loader.js"></script>
<script src="../../src/display/dom_utils.js"></script>
<script src="../../src/display/annotation_helper.js"></script>
<script src="../../src/display/text_layer.js"></script>

<script src="../../src/display/canvas.js"></script>
<script src="../../src/display/api.js"></script>
<script>
// Specify the main script used to create a new PDF.JS web worker.
// In production, change this to point to the combined `pdf.js` file.
Expand Down
13 changes: 7 additions & 6 deletions examples/helloworld/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
<head>
<!-- In production, only one script (pdf.js) is necessary -->
<!-- In production, change the content of PDFJS.workerSrc below -->
<script src="../../src/shared/global.js"></script>
<script src="../../src/display/dom_utils.js"></script>
<script src="../../src/shared/util.js"></script>
<script src="../../src/display/api.js"></script>
<script src="../../src/display/annotation_helper.js"></script>
<script src="../../src/display/font_loader.js"></script>
<script src="../../src/display/metadata.js"></script>
<script src="../../src/display/canvas.js"></script>
<script src="../../src/display/text_layer.js"></script>
<script src="../../src/display/webgl.js"></script>
<script src="../../src/display/pattern_helper.js"></script>
<script src="../../src/display/font_loader.js"></script>
<script src="../../src/display/dom_utils.js"></script>
<script src="../../src/display/annotation_helper.js"></script>
<script src="../../src/display/text_layer.js"></script>
<script src="../../src/display/canvas.js"></script>
<script src="../../src/display/api.js"></script>

<script>
// Specify the main script used to create a new PDF.JS web worker.
Expand Down
9 changes: 6 additions & 3 deletions examples/svgviewer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
<head>
<!-- In production, only one script (pdf.js) is necessary -->
<!-- In production, change the content of PDFJS.workerSrc below -->
<script src="../../src/shared/global.js"></script>
<script src="../../src/shared/util.js"></script>
<script src="../../src/display/api.js"></script>
<script src="../../src/display/metadata.js"></script>
<script src="../../src/display/pattern_helper.js"></script>
<script src="../../src/display/font_loader.js"></script>
<script src="../../src/display/metadata.js"></script>
<script src="../../src/display/svg.js"></script>
<script src="../../src/display/webgl.js"></script>
<script src="../../src/display/pattern_helper.js"></script>
<script src="../../src/display/canvas.js"></script>
<script src="../../src/display/api.js"></script>

<script>
// Specify the main script used to create a new PDF.JS web worker.
Expand Down
15 changes: 8 additions & 7 deletions make.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,19 +520,20 @@ target.bundle = function(args) {
}

var SHARED_SRC_FILES = [
'shared/util.js',
'shared/global.js',
'shared/util.js'
];

var MAIN_SRC_FILES = SHARED_SRC_FILES.concat([
'display/api.js',
'display/metadata.js',
'display/canvas.js',
'display/webgl.js',
'display/pattern_helper.js',
'display/font_loader.js',
'display/dom_utils.js',
'display/annotation_helper.js',
'display/font_loader.js',
'display/metadata.js',
'display/text_layer.js',
'display/webgl.js',
'display/pattern_helper.js',
'display/canvas.js',
'display/api.js',
'display/svg.js'
]);

Expand Down
48 changes: 44 additions & 4 deletions src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,48 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals PDFJS, Util, isDict, isName, stringToPDFString, warn, Dict, Stream,
stringToBytes, Promise, isArray, ObjectLoader, OperatorList,
isValidUrl, OPS, AnnotationType, stringToUTF8String,
AnnotationBorderStyleType, ColorSpace, AnnotationFlag, isInt */
/* globals PDFJS */

'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs/core/annotation', ['exports', 'pdfjs/shared/util',
'pdfjs/core/primitives', 'pdfjs/core/stream', 'pdfjs/core/colorspace',
'pdfjs/core/obj', 'pdfjs/core/evaluator'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../shared/util.js'), require('./primitives.js'),
require('./stream.js'), require('./colorspace.js'), require('./obj.js'),
require('./evaluator.js'));
} else {
factory((root.pdfjsCoreAnnotation = {}), root.pdfjsSharedUtil,
root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreColorSpace,
root.pdfjsCoreObj, root.pdfjsCoreEvaluator);
}
}(this, function (exports, sharedUtil, corePrimitives, coreStream,
coreColorSpace, coreObj, coreEvaluator) {

var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
var AnnotationFlag = sharedUtil.AnnotationFlag;
var AnnotationType = sharedUtil.AnnotationType;
var OPS = sharedUtil.OPS;
var Util = sharedUtil.Util;
var isArray = sharedUtil.isArray;
var isInt = sharedUtil.isInt;
var isValidUrl = sharedUtil.isValidUrl;
var stringToBytes = sharedUtil.stringToBytes;
var stringToPDFString = sharedUtil.stringToPDFString;
var stringToUTF8String = sharedUtil.stringToUTF8String;
var warn = sharedUtil.warn;
var Dict = corePrimitives.Dict;
var Name = corePrimitives.Name;
var isDict = corePrimitives.isDict;
var isName = corePrimitives.isName;
var Stream = coreStream.Stream;
var ColorSpace = coreColorSpace.ColorSpace;
var ObjectLoader = coreObj.ObjectLoader;
var OperatorList = coreEvaluator.OperatorList;

var DEFAULT_ICON_SIZE = 22; // px

/**
Expand Down Expand Up @@ -712,3 +747,8 @@ var LinkAnnotation = (function LinkAnnotationClosure() {

return LinkAnnotation;
})();

exports.Annotation = Annotation;
exports.AnnotationBorderStyle = AnnotationBorderStyle;
exports.AnnotationFactory = AnnotationFactory;
}));
13 changes: 13 additions & 0 deletions src/core/arithmetic_decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@

'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs/core/arithmetic_decoder', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsCoreArithmeticDecoder = {}));
}
}(this, function (exports) {

/* This class implements the QM Coder decoding as defined in
* JPEG 2000 Part I Final Committee Draft Version 1.0
* Annex C.3 Arithmetic decoding procedure
Expand Down Expand Up @@ -181,3 +191,6 @@ var ArithmeticDecoder = (function ArithmeticDecoderClosure() {

return ArithmeticDecoder;
})();

exports.ArithmeticDecoder = ArithmeticDecoder;
}));
16 changes: 15 additions & 1 deletion src/core/bidi.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals PDFJS */

'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs/core/bidi', ['exports', 'pdfjs/shared/global'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../shared/global.js'));
} else {
factory((root.pdfjsCoreBidi = {}), root.pdfjsSharedGlobal);
}
}(this, function (exports, sharedGlobal) {

var PDFJS = sharedGlobal.PDFJS;

var bidi = PDFJS.bidi = (function bidiClosure() {
// Character types for symbols from 0000 to 00FF.
var baseTypes = [
Expand Down Expand Up @@ -421,3 +432,6 @@ var bidi = PDFJS.bidi = (function bidiClosure() {

return bidi;
})();

exports.bidi = bidi;
}));
15 changes: 15 additions & 0 deletions src/core/charsets.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@

'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs/core/charsets', ['exports'], factory);
} else if (typeof exports !== 'undefined') {
factory(exports);
} else {
factory((root.pdfjsCoreCharsets = {}));
}
}(this, function (exports) {

var ISOAdobeCharset = [
'.notdef', 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar',
'percent', 'ampersand', 'quoteright', 'parenleft', 'parenright',
Expand Down Expand Up @@ -114,3 +124,8 @@ var ExpertSubsetCharset = [
'eightinferior', 'nineinferior', 'centinferior', 'dollarinferior',
'periodinferior', 'commainferior'
];

exports.ISOAdobeCharset = ISOAdobeCharset;
exports.ExpertCharset = ExpertCharset;
exports.ExpertSubsetCharset = ExpertSubsetCharset;
}));
24 changes: 22 additions & 2 deletions src/core/chunked_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals assert, MissingDataException, isInt, NetworkManager, Promise,
isEmptyObj, createPromiseCapability */
/* globals NetworkManager */

'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs/core/chunked_stream', ['exports', 'pdfjs/shared/util'],
factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../shared/util.js'));
} else {
factory((root.pdfjsCoreChunkedStream = {}), root.pdfjsSharedUtil);
}
}(this, function (exports, sharedUtil) {

var MissingDataException = sharedUtil.MissingDataException;
var assert = sharedUtil.assert;
var createPromiseCapability = sharedUtil.createPromiseCapability;
var isInt = sharedUtil.isInt;
var isEmptyObj = sharedUtil.isEmptyObj;

var ChunkedStream = (function ChunkedStreamClosure() {
function ChunkedStream(length, chunkSize, manager) {
this.bytes = new Uint8Array(length);
Expand Down Expand Up @@ -545,3 +561,7 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {

return ChunkedStreamManager;
})();

exports.ChunkedStream = ChunkedStream;
exports.ChunkedStreamManager = ChunkedStreamManager;
}));
35 changes: 33 additions & 2 deletions src/core/cmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,37 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals Util, isString, isInt, warn, error, isCmd, isEOF, isName, Lexer,
isStream, StringStream, PDFJS, assert */
/* globals PDFJS */

'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs/core/cmap', ['exports', 'pdfjs/shared/util',
'pdfjs/core/primitives', 'pdfjs/core/stream', 'pdfjs/core/parser'],
factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../shared/util.js'), require('./primitives.js'),
require('./stream.js'), require('./parser.js'));
} else {
factory((root.pdfjsCoreCMap = {}), root.pdfjsSharedUtil,
root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser);
}
}(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser) {

var Util = sharedUtil.Util;
var assert = sharedUtil.assert;
var error = sharedUtil.error;
var isInt = sharedUtil.isInt;
var isString = sharedUtil.isString;
var warn = sharedUtil.warn;
var isName = corePrimitives.isName;
var isCmd = corePrimitives.isCmd;
var isStream = corePrimitives.isStream;
var StringStream = coreStream.StringStream;
var Lexer = coreParser.Lexer;
var isEOF = coreParser.isEOF;

var BUILT_IN_CMAPS = [
// << Start unicode maps.
'Adobe-GB1-UCS2',
Expand Down Expand Up @@ -992,3 +1018,8 @@ var CMapFactory = (function CMapFactoryClosure() {
}
};
})();

exports.CMap = CMap;
exports.CMapFactory = CMapFactory;
exports.IdentityCMap = IdentityCMap;
}));
44 changes: 42 additions & 2 deletions src/core/colorspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,38 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals error, info, isArray, isDict, isName, isStream, isString,
PDFFunction, PDFImage, shadow, warn */

'use strict';

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('pdfjs/core/colorspace', ['exports', 'pdfjs/shared/util',
'pdfjs/core/primitives', 'pdfjs/core/function', 'pdfjs/core/stream'],
factory);
} else if (typeof exports !== 'undefined') {
factory(exports, require('../shared/util.js'), require('./primitives.js'),
require('./function.js'), require('./stream.js'));
} else {
factory((root.pdfjsCoreColorSpace = {}), root.pdfjsSharedUtil,
root.pdfjsCorePrimitives, root.pdfjsCoreFunction, root.pdfjsCoreStream);
}
}(this, function (exports, sharedUtil, corePrimitives, coreFunction,
coreStream) {

var error = sharedUtil.error;
var info = sharedUtil.info;
var isArray = sharedUtil.isArray;
var isString = sharedUtil.isString;
var shadow = sharedUtil.shadow;
var warn = sharedUtil.warn;
var isDict = corePrimitives.isDict;
var isName = corePrimitives.isName;
var isStream = corePrimitives.isStream;
var PDFFunction = coreFunction.PDFFunction;

var coreImage; // see _setCoreImage below
var PDFImage; // = coreImage.PDFImage;

var ColorSpace = (function ColorSpaceClosure() {
// Constructor should define this.numComps, this.defaultColor, this.name
function ColorSpace() {
Expand Down Expand Up @@ -1253,3 +1280,16 @@ var LabCS = (function LabCSClosure() {
};
return LabCS;
})();

// TODO refactor to remove dependency on image.js
function _setCoreImage(coreImage_) {
coreImage = coreImage_;
PDFImage = coreImage_.PDFImage;
}
exports._setCoreImage = _setCoreImage;

exports.ColorSpace = ColorSpace;

// TODO refactor to remove dependency on colorspace.js
coreStream._setCoreColorSpace(exports);
}));
Loading

0 comments on commit e7577a7

Please sign in to comment.