Merge pull request #8120 from yurydelendik/lib
Publishes processed sources into pdfjs-dist/lib
This commit is contained in:
commit
c290561488
41
gulpfile.js
41
gulpfile.js
@ -22,6 +22,7 @@ var gulp = require('gulp');
|
||||
var gutil = require('gulp-util');
|
||||
var rename = require('gulp-rename');
|
||||
var replace = require('gulp-replace');
|
||||
var transform = require('gulp-transform');
|
||||
var mkdirp = require('mkdirp');
|
||||
var path = require('path');
|
||||
var rimraf = require('rimraf');
|
||||
@ -924,9 +925,45 @@ gulp.task('jsdoc', function (done) {
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('lib', ['buildnumber'], function () {
|
||||
function preprocess(content) {
|
||||
content = preprocessor2.preprocessPDFJSCode(ctx, content);
|
||||
var removeCjsSrc =
|
||||
/^(var\s+\w+\s*=\s*require\('.*?)(?:\/src)(\/[^']*'\);)$/gm;
|
||||
content = content.replace(removeCjsSrc, function (all, prefix, suffix) {
|
||||
return prefix + suffix;
|
||||
});
|
||||
return licenseHeader + content;
|
||||
}
|
||||
var versionInfo = getVersionJSON();
|
||||
var ctx = {
|
||||
rootPath: __dirname,
|
||||
saveComments: false,
|
||||
defines: builder.merge(DEFINES, {
|
||||
GENERIC: true,
|
||||
BUNDLE_VERSION: versionInfo.version,
|
||||
BUNDLE_BUILD: versionInfo.commit
|
||||
})
|
||||
};
|
||||
var licenseHeader = fs.readFileSync('./src/license_header.js').toString();
|
||||
var preprocessor2 = require('./external/builder/preprocessor2.js');
|
||||
|
||||
return merge([
|
||||
gulp.src([
|
||||
'src/{core,display}/*.js',
|
||||
'src/shared/{compatibility,util}.js',
|
||||
'src/{pdf,pdf.worker}.js',
|
||||
], {base: 'src/'}),
|
||||
gulp.src(['web/*.js', '!web/viewer.js'], {base: '.'}),
|
||||
gulp.src('test/unit/*.js', {base: '.'}),
|
||||
]).pipe(transform(preprocess))
|
||||
.pipe(gulp.dest('build/lib/'));
|
||||
});
|
||||
|
||||
gulp.task('web-pre', ['generic', 'extension', 'jsdoc']);
|
||||
|
||||
gulp.task('dist-pre', ['generic', 'singlefile', 'components', 'minified']);
|
||||
gulp.task('dist-pre',
|
||||
['generic', 'singlefile', 'components', 'lib', 'minified']);
|
||||
|
||||
gulp.task('publish', ['generic'], function (done) {
|
||||
var version = JSON.parse(
|
||||
@ -1020,7 +1057,7 @@ gulp.task('baseline', function (done) {
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('unittestcli', function (done) {
|
||||
gulp.task('unittestcli', ['lib'], function (done) {
|
||||
var args = ['JASMINE_CONFIG_PATH=test/unit/clitests.json'];
|
||||
var testProcess = spawn('node_modules/.bin/jasmine', args,
|
||||
{stdio: 'inherit'});
|
||||
|
3
make.js
3
make.js
@ -42,6 +42,7 @@ var ROOT_DIR = __dirname + '/', // absolute path to project's root
|
||||
DIST_DIR = BUILD_DIR + 'dist/',
|
||||
SINGLE_FILE_DIR = BUILD_DIR + 'singlefile/',
|
||||
COMPONENTS_DIR = BUILD_DIR + 'components/',
|
||||
LIB_DIR = BUILD_DIR + 'lib/',
|
||||
REPO = 'git@github.com:mozilla/pdf.js.git';
|
||||
|
||||
function getCurrentVersion() {
|
||||
@ -186,6 +187,8 @@ target.dist = function() {
|
||||
COMPONENTS_DIR + '*',
|
||||
], DIST_DIR + 'web/');
|
||||
|
||||
cp('-R', LIB_DIR, DIST_DIR + 'lib/');
|
||||
|
||||
echo();
|
||||
echo('### Rebuilding manifests');
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
"gulp": "^3.9.1",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-replace": "^0.5.4",
|
||||
"gulp-transform": "^1.1.0",
|
||||
"gulp-util": "^3.0.7",
|
||||
"gulp-zip": "^3.2.0",
|
||||
"jasmine": "^2.5.2",
|
||||
|
@ -505,75 +505,6 @@ var ProblematicCharRanges = new Int32Array([
|
||||
0xFFF0, 0x10000
|
||||
]);
|
||||
|
||||
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {
|
||||
/**
|
||||
* Used to validate the entries in `ProblematicCharRanges`, and to ensure that
|
||||
* its total number of characters does not exceed the PUA (Private Use Area)
|
||||
* length.
|
||||
* @returns {Object} An object with {number} `numChars`, {number} `puaLength`,
|
||||
* and {number} `percentage` parameters.
|
||||
*/
|
||||
var checkProblematicCharRanges = function checkProblematicCharRanges() {
|
||||
function printRange(limits) {
|
||||
return '[' + limits.lower.toString('16').toUpperCase() + ', ' +
|
||||
limits.upper.toString('16').toUpperCase() + ')';
|
||||
}
|
||||
|
||||
var numRanges = ProblematicCharRanges.length;
|
||||
if (numRanges % 2 !== 0) {
|
||||
throw new Error('Char ranges must contain an even number of elements.');
|
||||
}
|
||||
var prevLimits, numChars = 0;
|
||||
for (var i = 0; i < numRanges; i += 2) {
|
||||
var limits = {
|
||||
lower: ProblematicCharRanges[i],
|
||||
upper: ProblematicCharRanges[i + 1],
|
||||
};
|
||||
if (!isInt(limits.lower) || !isInt(limits.upper)) {
|
||||
throw new Error('Range endpoints must be integers: ' +
|
||||
printRange(limits));
|
||||
}
|
||||
if (limits.lower < 0 || limits.upper < 0) {
|
||||
throw new Error('Range endpoints must be non-negative: ' +
|
||||
printRange(limits));
|
||||
}
|
||||
var range = limits.upper - limits.lower;
|
||||
if (range < 1) {
|
||||
throw new Error('Range must contain at least one element: ' +
|
||||
printRange(limits));
|
||||
}
|
||||
if (prevLimits) {
|
||||
if (limits.lower < prevLimits.lower) {
|
||||
throw new Error('Ranges must be sorted in ascending order: ' +
|
||||
printRange(limits) + ', ' + printRange(prevLimits));
|
||||
}
|
||||
if (limits.lower < prevLimits.upper) {
|
||||
throw new Error('Ranges must not overlap: ' +
|
||||
printRange(limits) + ', ' + printRange(prevLimits));
|
||||
}
|
||||
}
|
||||
prevLimits = {
|
||||
lower: limits.lower,
|
||||
upper: limits.upper,
|
||||
};
|
||||
// The current range is OK.
|
||||
numChars += range;
|
||||
}
|
||||
var puaLength = (PRIVATE_USE_OFFSET_END + 1) - PRIVATE_USE_OFFSET_START;
|
||||
if (numChars > puaLength) {
|
||||
throw new Error('Total number of chars must not exceed the PUA length.');
|
||||
}
|
||||
return {
|
||||
numChars: numChars,
|
||||
puaLength: puaLength,
|
||||
percentage: 100 * (numChars / puaLength),
|
||||
};
|
||||
};
|
||||
|
||||
exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED;
|
||||
exports.checkProblematicCharRanges = checkProblematicCharRanges;
|
||||
}
|
||||
|
||||
/**
|
||||
* 'Font' is the class the outside world should use, it encapsulate all the font
|
||||
* decoding logics whatever type it is (assuming the font type is supported).
|
||||
@ -3436,10 +3367,14 @@ var CFFFont = (function CFFFontClosure() {
|
||||
}
|
||||
})();
|
||||
|
||||
exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED;
|
||||
exports.PRIVATE_USE_OFFSET_START = PRIVATE_USE_OFFSET_START;
|
||||
exports.PRIVATE_USE_OFFSET_END = PRIVATE_USE_OFFSET_END;
|
||||
exports.ErrorFont = ErrorFont;
|
||||
exports.Font = Font;
|
||||
exports.FontFlags = FontFlags;
|
||||
exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
|
||||
exports.ProblematicCharRanges = ProblematicCharRanges;
|
||||
exports.ToUnicodeMap = ToUnicodeMap;
|
||||
exports.getFontType = getFontType;
|
||||
}));
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"spec_dir": "test/unit",
|
||||
"spec_dir": "build/lib/test/unit",
|
||||
"spec_files": [
|
||||
"annotation_spec.js",
|
||||
"bidi_spec.js",
|
||||
|
@ -16,16 +16,85 @@
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs-test/unit/fonts_spec', ['exports', 'pdfjs/core/fonts'],
|
||||
factory);
|
||||
define('pdfjs-test/unit/fonts_spec', ['exports', 'pdfjs/core/fonts',
|
||||
'pdfjs/shared/util'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../../src/core/fonts.js'));
|
||||
factory(exports, require('../../src/core/fonts.js'),
|
||||
require('../../src/shared/util.js'));
|
||||
} else {
|
||||
factory((root.pdfjsTestUnitFontsSpec = {}), root.pdfjsCoreFonts);
|
||||
factory((root.pdfjsTestUnitFontsSpec = {}), root.pdfjsCoreFonts,
|
||||
root.pdfjsSharedUtil);
|
||||
}
|
||||
}(this, function (exports, coreFonts) {
|
||||
}(this, function (exports, coreFonts, sharedUtil) {
|
||||
|
||||
var checkProblematicCharRanges = coreFonts.checkProblematicCharRanges;
|
||||
var ProblematicCharRanges = coreFonts.ProblematicCharRanges;
|
||||
var PRIVATE_USE_OFFSET_START = coreFonts.PRIVATE_USE_OFFSET_START;
|
||||
var PRIVATE_USE_OFFSET_END = coreFonts.PRIVATE_USE_OFFSET_END;
|
||||
var isInt = sharedUtil.isInt;
|
||||
|
||||
/**
|
||||
* Used to validate the entries in `ProblematicCharRanges`, and to ensure that
|
||||
* its total number of characters does not exceed the PUA (Private Use Area)
|
||||
* length.
|
||||
* @returns {Object} An object with {number} `numChars`, {number} `puaLength`,
|
||||
* and {number} `percentage` parameters.
|
||||
*/
|
||||
var checkProblematicCharRanges = function checkProblematicCharRanges() {
|
||||
function printRange(limits) {
|
||||
return '[' + limits.lower.toString('16').toUpperCase() + ', ' +
|
||||
limits.upper.toString('16').toUpperCase() + ')';
|
||||
}
|
||||
|
||||
var numRanges = ProblematicCharRanges.length;
|
||||
if (numRanges % 2 !== 0) {
|
||||
throw new Error('Char ranges must contain an even number of elements.');
|
||||
}
|
||||
var prevLimits, numChars = 0;
|
||||
for (var i = 0; i < numRanges; i += 2) {
|
||||
var limits = {
|
||||
lower: ProblematicCharRanges[i],
|
||||
upper: ProblematicCharRanges[i + 1],
|
||||
};
|
||||
if (!isInt(limits.lower) || !isInt(limits.upper)) {
|
||||
throw new Error('Range endpoints must be integers: ' +
|
||||
printRange(limits));
|
||||
}
|
||||
if (limits.lower < 0 || limits.upper < 0) {
|
||||
throw new Error('Range endpoints must be non-negative: ' +
|
||||
printRange(limits));
|
||||
}
|
||||
var range = limits.upper - limits.lower;
|
||||
if (range < 1) {
|
||||
throw new Error('Range must contain at least one element: ' +
|
||||
printRange(limits));
|
||||
}
|
||||
if (prevLimits) {
|
||||
if (limits.lower < prevLimits.lower) {
|
||||
throw new Error('Ranges must be sorted in ascending order: ' +
|
||||
printRange(limits) + ', ' + printRange(prevLimits));
|
||||
}
|
||||
if (limits.lower < prevLimits.upper) {
|
||||
throw new Error('Ranges must not overlap: ' +
|
||||
printRange(limits) + ', ' + printRange(prevLimits));
|
||||
}
|
||||
}
|
||||
prevLimits = {
|
||||
lower: limits.lower,
|
||||
upper: limits.upper,
|
||||
};
|
||||
// The current range is OK.
|
||||
numChars += range;
|
||||
}
|
||||
var puaLength = (PRIVATE_USE_OFFSET_END + 1) - PRIVATE_USE_OFFSET_START;
|
||||
if (numChars > puaLength) {
|
||||
throw new Error('Total number of chars must not exceed the PUA length.');
|
||||
}
|
||||
return {
|
||||
numChars: numChars,
|
||||
puaLength: puaLength,
|
||||
percentage: 100 * (numChars / puaLength),
|
||||
};
|
||||
};
|
||||
|
||||
describe('Fonts', function() {
|
||||
it('checkProblematicCharRanges', function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user