Skip to content

Commit

Permalink
Merge pull request #6683 from yurydelendik/module-core
Browse files Browse the repository at this point in the history
Adds UMD headers to core, display and shared files.
  • Loading branch information
brendandahl committed Dec 16, 2015
2 parents a1aec82 + b084dc0 commit f1c64b6
Show file tree
Hide file tree
Showing 56 changed files with 2,427 additions and 568 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_layer.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_layer.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_layer.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_layer.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
51 changes: 51 additions & 0 deletions external/umdutils/genhtml.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* 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.
*/
/* jshint node:true */

'use strict';

// Simple util to re-generate HTML module references in right load order.

var fs = require('fs');
var path = require('path');
var umd = require('./verifier.js');

var filePath = process.argv[2];
if (!filePath) {
console.log('USAGE: node ./external/umdutils/genhtml.js <html-file-path>');
process.exit(0);
}

var content = fs.readFileSync(filePath).toString();
var m, re = /<script\s+src=['"]([^'"]+)/g;
var filesFound = [];
while ((m = re.exec(content))) {
var jsPath = m[1];
if (!/\bsrc\/.*?\.js$/.test(jsPath)) {
continue;
}
filesFound.push(jsPath);
}

var srcPrefix = filesFound[0].substring(0, filesFound[0].indexOf('src/') + 4);

var dependencies = umd.readDependencies(filesFound.map(function (p) {
return path.join(path.dirname(filePath), p);
}));

dependencies.loadOrder.forEach(function (i) {
console.log('<script src="' + i.replace('pdfjs/', srcPrefix) + '.js">'+
'</script>');
});
Loading

0 comments on commit f1c64b6

Please sign in to comment.