Re-factor the default preferences generation to support build targets (PR 10548)

Originally the default preferences where simply placed in a JSON-file, checked into the repository, which over time became impractical, annoying, and error-prone to maintain; please see PR 10548.
While that improved the overall situation a fair bit, it however inherited one quite unfortunate property of the old JSON-based solution[1]: It's still not possible for *different* build targets to specify their *own* default preference values.

With some preferences, such as e.g. `enableScripting`, it's not inconceivable that you'd want to (at least) support build-specific default preference values. Currently that's not really possible, which is why this PR re-factors the default preferences generation to support this.

---
[1] This fact isn't really clear from the `AppOptions` implementation, unless you're familiar with the `gulpfile.js` code, which could lead to some confusion for those new to this part of the code-base.
This commit is contained in:
Jonas Jenwald 2021-03-18 14:33:54 +01:00
parent d775616fd4
commit 56e1d7746a
4 changed files with 195 additions and 135 deletions

View File

@ -18,5 +18,5 @@
var EXPORTED_SYMBOLS = ["PdfJsDefaultPreferences"]; var EXPORTED_SYMBOLS = ["PdfJsDefaultPreferences"];
var PdfJsDefaultPreferences = Object.freeze( var PdfJsDefaultPreferences = Object.freeze(
PDFJSDev.json("$ROOT/build/default_preferences.json") PDFJSDev.eval("DEFAULT_PREFERENCES")
); );

View File

@ -172,6 +172,7 @@ function createWebpackConfig(
disableVersionInfo = false, disableVersionInfo = false,
disableSourceMaps = false, disableSourceMaps = false,
disableLicenseHeader = false, disableLicenseHeader = false,
defaultPreferencesDir = null,
} = {} } = {}
) { ) {
const versionInfo = !disableVersionInfo const versionInfo = !disableVersionInfo
@ -181,6 +182,9 @@ function createWebpackConfig(
BUNDLE_VERSION: versionInfo.version, BUNDLE_VERSION: versionInfo.version,
BUNDLE_BUILD: versionInfo.commit, BUNDLE_BUILD: versionInfo.commit,
TESTING: defines.TESTING || process.env.TESTING === "true", TESTING: defines.TESTING || process.env.TESTING === "true",
DEFAULT_PREFERENCES: defaultPreferencesDir
? getDefaultPreferences(defaultPreferencesDir)
: {},
}); });
const licenseHeaderLibre = fs const licenseHeaderLibre = fs
.readFileSync("./src/license_header_libre.js") .readFileSync("./src/license_header_libre.js")
@ -283,7 +287,7 @@ function getVersionJSON() {
return JSON.parse(fs.readFileSync(BUILD_DIR + "version.json").toString()); return JSON.parse(fs.readFileSync(BUILD_DIR + "version.json").toString());
} }
function checkChromePreferencesFile(chromePrefsPath, webPrefsPath) { function checkChromePreferencesFile(chromePrefsPath, webPrefs) {
const chromePrefs = JSON.parse(fs.readFileSync(chromePrefsPath).toString()); const chromePrefs = JSON.parse(fs.readFileSync(chromePrefsPath).toString());
let chromePrefsKeys = Object.keys(chromePrefs.properties); let chromePrefsKeys = Object.keys(chromePrefs.properties);
chromePrefsKeys = chromePrefsKeys.filter(function (key) { chromePrefsKeys = chromePrefsKeys.filter(function (key) {
@ -294,7 +298,7 @@ function checkChromePreferencesFile(chromePrefsPath, webPrefsPath) {
return !description || !description.startsWith("DEPRECATED."); return !description || !description.startsWith("DEPRECATED.");
}); });
chromePrefsKeys.sort(); chromePrefsKeys.sort();
const webPrefs = JSON.parse(fs.readFileSync(webPrefsPath).toString());
const webPrefsKeys = Object.keys(webPrefs); const webPrefsKeys = Object.keys(webPrefs);
webPrefsKeys.sort(); webPrefsKeys.sort();
const telemetryIndex = chromePrefsKeys.indexOf("disableTelemetry"); const telemetryIndex = chromePrefsKeys.indexOf("disableTelemetry");
@ -454,12 +458,18 @@ function createWorkerBundle(defines) {
.pipe(replaceJSRootName(workerAMDName, "pdfjsWorker")); .pipe(replaceJSRootName(workerAMDName, "pdfjsWorker"));
} }
function createWebBundle(defines) { function createWebBundle(defines, options) {
const viewerOutputName = "viewer.js"; const viewerOutputName = "viewer.js";
const viewerFileConfig = createWebpackConfig(defines, { const viewerFileConfig = createWebpackConfig(
filename: viewerOutputName, defines,
}); {
filename: viewerOutputName,
},
{
defaultPreferencesDir: options.defaultPreferencesDir,
}
);
return gulp.src("./web/viewer.js").pipe(webpack2Stream(viewerFileConfig)); return gulp.src("./web/viewer.js").pipe(webpack2Stream(viewerFileConfig));
} }
@ -647,9 +657,17 @@ gulp.task("buildnumber", function (done) {
); );
}); });
gulp.task("default_preferences-pre", function () { function buildDefaultPreferences(defines, dir) {
console.log(); console.log();
console.log("### Building `default_preferences.json`"); console.log("### Building default preferences");
const bundleDefines = builder.merge(defines, {
LIB: true,
SKIP_BABEL: false,
BUNDLE_VERSION: 0, // Dummy version
BUNDLE_BUILD: 0, // Dummy build
TESTING: defines.TESTING || process.env.TESTING === "true",
});
// Refer to the comment in the 'lib' task below. // Refer to the comment in the 'lib' task below.
function babelPluginReplaceNonWebPackRequire(babel) { function babelPluginReplaceNonWebPackRequire(babel) {
@ -664,10 +682,12 @@ gulp.task("default_preferences-pre", function () {
}; };
} }
function preprocess(content) { function preprocess(content) {
const skipBabel =
bundleDefines.SKIP_BABEL || /\/\*\s*no-babel-preset\s*\*\//.test(content);
content = preprocessor2.preprocessPDFJSCode(ctx, content); content = preprocessor2.preprocessPDFJSCode(ctx, content);
return babel.transform(content, { return babel.transform(content, {
sourceType: "module", sourceType: "module",
presets: undefined, // SKIP_BABEL presets: skipBabel ? undefined : ["@babel/preset-env"],
plugins: [ plugins: [
"@babel/plugin-proposal-logical-assignment-operators", "@babel/plugin-proposal-logical-assignment-operators",
"@babel/plugin-transform-modules-commonjs", "@babel/plugin-transform-modules-commonjs",
@ -679,12 +699,7 @@ gulp.task("default_preferences-pre", function () {
const ctx = { const ctx = {
rootPath: __dirname, rootPath: __dirname,
saveComments: false, saveComments: false,
defines: builder.merge(DEFINES, { defines: bundleDefines,
GENERIC: true,
LIB: true,
BUNDLE_VERSION: 0, // Dummy version
BUNDLE_BUILD: 0, // Dummy build
}),
map: { map: {
"pdfjs-lib": "../pdf", "pdfjs-lib": "../pdf",
}, },
@ -696,26 +711,17 @@ gulp.task("default_preferences-pre", function () {
}), }),
]) ])
.pipe(transform("utf8", preprocess)) .pipe(transform("utf8", preprocess))
.pipe(gulp.dest(DEFAULT_PREFERENCES_DIR + "lib/")); .pipe(gulp.dest(DEFAULT_PREFERENCES_DIR + dir));
}); }
gulp.task( function getDefaultPreferences(dir) {
"default_preferences", const { AppOptions, OptionKind } = require("./" +
gulp.series("default_preferences-pre", function (done) { DEFAULT_PREFERENCES_DIR +
const AppOptionsLib = require("./" + dir +
DEFAULT_PREFERENCES_DIR + "web/app_options.js");
"lib/web/app_options.js");
const AppOptions = AppOptionsLib.AppOptions;
const OptionKind = AppOptionsLib.OptionKind;
createStringSource( return AppOptions.getAll(OptionKind.PREFERENCE);
"default_preferences.json", }
JSON.stringify(AppOptions.getAll(OptionKind.PREFERENCE), null, 2)
)
.pipe(gulp.dest(BUILD_DIR))
.on("end", done);
})
);
gulp.task("locale", function () { gulp.task("locale", function () {
const VIEWER_LOCALE_OUTPUT = "web/locale/"; const VIEWER_LOCALE_OUTPUT = "web/locale/";
@ -827,7 +833,11 @@ function buildGeneric(defines, dir) {
createMainBundle(defines).pipe(gulp.dest(dir + "build")), createMainBundle(defines).pipe(gulp.dest(dir + "build")),
createWorkerBundle(defines).pipe(gulp.dest(dir + "build")), createWorkerBundle(defines).pipe(gulp.dest(dir + "build")),
createSandboxBundle(defines).pipe(gulp.dest(dir + "build")), createSandboxBundle(defines).pipe(gulp.dest(dir + "build")),
createWebBundle(defines).pipe(gulp.dest(dir + "web")), createWebBundle(defines, {
defaultPreferencesDir: defines.SKIP_BABEL
? "generic/"
: "generic-legacy/",
}).pipe(gulp.dest(dir + "web")),
gulp.src(COMMON_WEB_FILES, { base: "web/" }).pipe(gulp.dest(dir + "web")), gulp.src(COMMON_WEB_FILES, { base: "web/" }).pipe(gulp.dest(dir + "web")),
gulp.src("LICENSE").pipe(gulp.dest(dir)), gulp.src("LICENSE").pipe(gulp.dest(dir)),
gulp gulp
@ -857,11 +867,13 @@ gulp.task(
"generic", "generic",
gulp.series( gulp.series(
"buildnumber", "buildnumber",
"default_preferences",
"locale", "locale",
function scripting() { function scripting() {
const defines = builder.merge(DEFINES, { GENERIC: true }); const defines = builder.merge(DEFINES, { GENERIC: true });
return createTemporaryScriptingBundle(defines); return merge([
buildDefaultPreferences(defines, "generic/"),
createTemporaryScriptingBundle(defines),
]);
}, },
function () { function () {
console.log(); console.log();
@ -879,14 +891,16 @@ gulp.task(
"generic-legacy", "generic-legacy",
gulp.series( gulp.series(
"buildnumber", "buildnumber",
"default_preferences",
"locale", "locale",
function scripting() { function scripting() {
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
GENERIC: true, GENERIC: true,
SKIP_BABEL: false, SKIP_BABEL: false,
}); });
return createTemporaryScriptingBundle(defines); return merge([
buildDefaultPreferences(defines, "generic-legacy/"),
createTemporaryScriptingBundle(defines),
]);
}, },
function () { function () {
console.log(); console.log();
@ -985,7 +999,11 @@ function buildMinified(defines, dir) {
createMainBundle(defines).pipe(gulp.dest(dir + "build")), createMainBundle(defines).pipe(gulp.dest(dir + "build")),
createWorkerBundle(defines).pipe(gulp.dest(dir + "build")), createWorkerBundle(defines).pipe(gulp.dest(dir + "build")),
createSandboxBundle(defines).pipe(gulp.dest(dir + "build")), createSandboxBundle(defines).pipe(gulp.dest(dir + "build")),
createWebBundle(defines).pipe(gulp.dest(dir + "web")), createWebBundle(defines, {
defaultPreferencesDir: defines.SKIP_BABEL
? "minified/"
: "minified-legacy/",
}).pipe(gulp.dest(dir + "web")),
createImageDecodersBundle( createImageDecodersBundle(
builder.merge(defines, { IMAGE_DECODERS: true }) builder.merge(defines, { IMAGE_DECODERS: true })
).pipe(gulp.dest(dir + "image_decoders")), ).pipe(gulp.dest(dir + "image_decoders")),
@ -1016,11 +1034,13 @@ gulp.task(
"minified-pre", "minified-pre",
gulp.series( gulp.series(
"buildnumber", "buildnumber",
"default_preferences",
"locale", "locale",
function scripting() { function scripting() {
const defines = builder.merge(DEFINES, { MINIFIED: true, GENERIC: true }); const defines = builder.merge(DEFINES, { MINIFIED: true, GENERIC: true });
return createTemporaryScriptingBundle(defines); return merge([
buildDefaultPreferences(defines, "minified/"),
createTemporaryScriptingBundle(defines),
]);
}, },
function () { function () {
console.log(); console.log();
@ -1036,7 +1056,6 @@ gulp.task(
"minified-legacy-pre", "minified-legacy-pre",
gulp.series( gulp.series(
"buildnumber", "buildnumber",
"default_preferences",
"locale", "locale",
function scripting() { function scripting() {
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
@ -1044,7 +1063,10 @@ gulp.task(
GENERIC: true, GENERIC: true,
SKIP_BABEL: false, SKIP_BABEL: false,
}); });
return createTemporaryScriptingBundle(defines); return merge([
buildDefaultPreferences(defines, "minified-legacy/"),
createTemporaryScriptingBundle(defines),
]);
}, },
function () { function () {
console.log(); console.log();
@ -1155,10 +1177,14 @@ function preprocessDefaultPreferences(content) {
const MODIFICATION_WARNING = const MODIFICATION_WARNING =
"//\n// THIS FILE IS GENERATED AUTOMATICALLY, DO NOT EDIT MANUALLY!\n//\n"; "//\n// THIS FILE IS GENERATED AUTOMATICALLY, DO NOT EDIT MANUALLY!\n//\n";
const bundleDefines = builder.merge(DEFINES, {
DEFAULT_PREFERENCES: getDefaultPreferences("mozcentral/"),
});
content = preprocessor2.preprocessPDFJSCode( content = preprocessor2.preprocessPDFJSCode(
{ {
rootPath: __dirname, rootPath: __dirname,
defines: DEFINES, defines: bundleDefines,
}, },
content content
); );
@ -1177,78 +1203,93 @@ function preprocessDefaultPreferences(content) {
gulp.task( gulp.task(
"mozcentral-pre", "mozcentral-pre",
gulp.series("buildnumber", "default_preferences", function () { gulp.series(
console.log(); "buildnumber",
console.log("### Building mozilla-central extension"); function scripting() {
const defines = builder.merge(DEFINES, { MOZCENTRAL: true }); const defines = builder.merge(DEFINES, { MOZCENTRAL: true });
return buildDefaultPreferences(defines, "mozcentral/");
},
function () {
console.log();
console.log("### Building mozilla-central extension");
const defines = builder.merge(DEFINES, { MOZCENTRAL: true });
const MOZCENTRAL_DIR = BUILD_DIR + "mozcentral/", const MOZCENTRAL_DIR = BUILD_DIR + "mozcentral/",
MOZCENTRAL_EXTENSION_DIR = MOZCENTRAL_DIR + "browser/extensions/pdfjs/", MOZCENTRAL_EXTENSION_DIR = MOZCENTRAL_DIR + "browser/extensions/pdfjs/",
MOZCENTRAL_CONTENT_DIR = MOZCENTRAL_EXTENSION_DIR + "content/", MOZCENTRAL_CONTENT_DIR = MOZCENTRAL_EXTENSION_DIR + "content/",
FIREFOX_EXTENSION_DIR = "extensions/firefox/", FIREFOX_EXTENSION_DIR = "extensions/firefox/",
MOZCENTRAL_L10N_DIR = MOZCENTRAL_DIR + "browser/locales/en-US/pdfviewer/", MOZCENTRAL_L10N_DIR =
FIREFOX_CONTENT_DIR = EXTENSION_SRC_DIR + "/firefox/content/"; MOZCENTRAL_DIR + "browser/locales/en-US/pdfviewer/",
FIREFOX_CONTENT_DIR = EXTENSION_SRC_DIR + "/firefox/content/";
// Clear out everything in the firefox extension build directory // Clear out everything in the firefox extension build directory
rimraf.sync(MOZCENTRAL_DIR); rimraf.sync(MOZCENTRAL_DIR);
const versionJSON = getVersionJSON(); const versionJSON = getVersionJSON();
const version = versionJSON.version, const version = versionJSON.version,
commit = versionJSON.commit; commit = versionJSON.commit;
// Ignore the fallback cursor images, since they're unnecessary in Firefox. // Ignore the fallback cursor images, since they're unnecessary in
const MOZCENTRAL_COMMON_WEB_FILES = [ // Firefox.
...COMMON_WEB_FILES, const MOZCENTRAL_COMMON_WEB_FILES = [
"!web/images/*.cur", ...COMMON_WEB_FILES,
]; "!web/images/*.cur",
];
return merge([ return merge([
createMainBundle(defines).pipe( createMainBundle(defines).pipe(
gulp.dest(MOZCENTRAL_CONTENT_DIR + "build") gulp.dest(MOZCENTRAL_CONTENT_DIR + "build")
), ),
createScriptingBundle(defines).pipe( createScriptingBundle(defines).pipe(
gulp.dest(MOZCENTRAL_CONTENT_DIR + "build") gulp.dest(MOZCENTRAL_CONTENT_DIR + "build")
), ),
createSandboxExternal(defines).pipe( createSandboxExternal(defines).pipe(
gulp.dest(MOZCENTRAL_CONTENT_DIR + "build") gulp.dest(MOZCENTRAL_CONTENT_DIR + "build")
), ),
createWorkerBundle(defines).pipe( createWorkerBundle(defines).pipe(
gulp.dest(MOZCENTRAL_CONTENT_DIR + "build") gulp.dest(MOZCENTRAL_CONTENT_DIR + "build")
), ),
createWebBundle(defines).pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")), createWebBundle(defines, { defaultPreferencesDir: "mozcentral/" }).pipe(
gulp gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")
.src(MOZCENTRAL_COMMON_WEB_FILES, { base: "web/" }) ),
.pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")), gulp
gulp .src(MOZCENTRAL_COMMON_WEB_FILES, { base: "web/" })
.src(["external/bcmaps/*.bcmap", "external/bcmaps/LICENSE"], { .pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")),
base: "external/bcmaps", gulp
}) .src(["external/bcmaps/*.bcmap", "external/bcmaps/LICENSE"], {
.pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web/cmaps")), base: "external/bcmaps",
})
.pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web/cmaps")),
preprocessHTML("web/viewer.html", defines).pipe( preprocessHTML("web/viewer.html", defines).pipe(
gulp.dest(MOZCENTRAL_CONTENT_DIR + "web") gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")
), ),
preprocessCSS("web/viewer.css", "mozcentral", defines, true) preprocessCSS("web/viewer.css", "mozcentral", defines, true)
.pipe( .pipe(
postcss([ postcss([
autoprefixer({ overrideBrowserslist: ["last 1 firefox versions"] }), autoprefixer({
]) overrideBrowserslist: ["last 1 firefox versions"],
) }),
.pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")), ])
)
.pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR + "web")),
gulp.src("l10n/en-US/*.properties").pipe(gulp.dest(MOZCENTRAL_L10N_DIR)), gulp
gulp .src("l10n/en-US/*.properties")
.src(FIREFOX_EXTENSION_DIR + "README.mozilla") .pipe(gulp.dest(MOZCENTRAL_L10N_DIR)),
.pipe(replace(/\bPDFJSSCRIPT_VERSION\b/g, version)) gulp
.pipe(replace(/\bPDFJSSCRIPT_COMMIT\b/g, commit)) .src(FIREFOX_EXTENSION_DIR + "README.mozilla")
.pipe(gulp.dest(MOZCENTRAL_EXTENSION_DIR)), .pipe(replace(/\bPDFJSSCRIPT_VERSION\b/g, version))
gulp.src("LICENSE").pipe(gulp.dest(MOZCENTRAL_EXTENSION_DIR)), .pipe(replace(/\bPDFJSSCRIPT_COMMIT\b/g, commit))
gulp .pipe(gulp.dest(MOZCENTRAL_EXTENSION_DIR)),
.src(FIREFOX_CONTENT_DIR + "PdfJsDefaultPreferences.jsm") gulp.src("LICENSE").pipe(gulp.dest(MOZCENTRAL_EXTENSION_DIR)),
.pipe(transform("utf8", preprocessDefaultPreferences)) gulp
.pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR)), .src(FIREFOX_CONTENT_DIR + "PdfJsDefaultPreferences.jsm")
]); .pipe(transform("utf8", preprocessDefaultPreferences))
}) .pipe(gulp.dest(MOZCENTRAL_CONTENT_DIR)),
]);
}
)
); );
gulp.task("mozcentral", gulp.series("mozcentral-pre")); gulp.task("mozcentral", gulp.series("mozcentral-pre"));
@ -1257,14 +1298,16 @@ gulp.task(
"chromium-pre", "chromium-pre",
gulp.series( gulp.series(
"buildnumber", "buildnumber",
"default_preferences",
"locale", "locale",
function scripting() { function scripting() {
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
CHROME: true, CHROME: true,
SKIP_BABEL: false, SKIP_BABEL: false,
}); });
return createTemporaryScriptingBundle(defines); return merge([
buildDefaultPreferences(defines, "chromium/"),
createTemporaryScriptingBundle(defines),
]);
}, },
function () { function () {
console.log(); console.log();
@ -1292,7 +1335,7 @@ gulp.task(
createSandboxBundle(defines).pipe( createSandboxBundle(defines).pipe(
gulp.dest(CHROME_BUILD_CONTENT_DIR + "build") gulp.dest(CHROME_BUILD_CONTENT_DIR + "build")
), ),
createWebBundle(defines).pipe( createWebBundle(defines, { defaultPreferencesDir: "chromium/" }).pipe(
gulp.dest(CHROME_BUILD_CONTENT_DIR + "web") gulp.dest(CHROME_BUILD_CONTENT_DIR + "web")
), ),
gulp gulp
@ -1422,7 +1465,10 @@ function buildLib(defines, dir) {
const bundleDefines = builder.merge(defines, { const bundleDefines = builder.merge(defines, {
BUNDLE_VERSION: versionInfo.version, BUNDLE_VERSION: versionInfo.version,
BUNDLE_BUILD: versionInfo.commit, BUNDLE_BUILD: versionInfo.commit,
TESTING: process.env.TESTING === "true", TESTING: defines.TESTING || process.env.TESTING === "true",
DEFAULT_PREFERENCES: getDefaultPreferences(
defines.SKIP_BABEL ? "lib/" : "lib-legacy/"
),
}); });
const ctx = { const ctx = {
rootPath: __dirname, rootPath: __dirname,
@ -1459,10 +1505,12 @@ gulp.task(
"lib", "lib",
gulp.series( gulp.series(
"buildnumber", "buildnumber",
"default_preferences",
function scripting() { function scripting() {
const defines = builder.merge(DEFINES, { GENERIC: true, LIB: true }); const defines = builder.merge(DEFINES, { GENERIC: true, LIB: true });
return createTemporaryScriptingBundle(defines); return merge([
buildDefaultPreferences(defines, "lib/"),
createTemporaryScriptingBundle(defines),
]);
}, },
function () { function () {
const defines = builder.merge(DEFINES, { GENERIC: true, LIB: true }); const defines = builder.merge(DEFINES, { GENERIC: true, LIB: true });
@ -1479,14 +1527,16 @@ gulp.task(
"lib-legacy", "lib-legacy",
gulp.series( gulp.series(
"buildnumber", "buildnumber",
"default_preferences",
function scripting() { function scripting() {
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
GENERIC: true, GENERIC: true,
LIB: true, LIB: true,
SKIP_BABEL: false, SKIP_BABEL: false,
}); });
return createTemporaryScriptingBundle(defines); return merge([
buildDefaultPreferences(defines, "lib-legacy/"),
createTemporaryScriptingBundle(defines),
]);
}, },
function () { function () {
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
@ -1747,21 +1797,30 @@ gulp.task("lint", function (done) {
gulp.task( gulp.task(
"lint-chromium", "lint-chromium",
gulp.series("default_preferences", function (done) { gulp.series(
console.log(); function scripting() {
console.log("### Checking supplemental Chromium files"); const defines = builder.merge(DEFINES, {
CHROME: true,
SKIP_BABEL: false,
});
return buildDefaultPreferences(defines, "lint-chromium/");
},
function (done) {
console.log();
console.log("### Checking supplemental Chromium files");
if ( if (
!checkChromePreferencesFile( !checkChromePreferencesFile(
"extensions/chromium/preferences_schema.json", "extensions/chromium/preferences_schema.json",
"build/default_preferences.json" getDefaultPreferences("lint-chromium/")
) )
) { ) {
done(new Error("chromium/preferences_schema is not in sync.")); done(new Error("chromium/preferences_schema is not in sync."));
return; return;
}
done();
} }
done(); )
})
); );
gulp.task( gulp.task(
@ -2270,7 +2329,8 @@ gulp.task("externaltest", function (done) {
gulp.task( gulp.task(
"npm-test", "npm-test",
gulp.series( gulp.series(
gulp.parallel("lint", "externaltest", "unittestcli", "typestest"), gulp.parallel("lint", "externaltest", "unittestcli"),
"lint-chromium" "lint-chromium",
"typestest"
) )
); );

View File

@ -250,7 +250,7 @@ const defaultOptions = {
}; };
if ( if (
typeof PDFJSDev === "undefined" || typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || (GENERIC && !LIB)") PDFJSDev.test("!PRODUCTION || GENERIC")
) { ) {
defaultOptions.disablePreferences = { defaultOptions.disablePreferences = {
/** @type {boolean} */ /** @type {boolean} */

View File

@ -29,7 +29,7 @@ class BasePreferences {
value: Object.freeze( value: Object.freeze(
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION") typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")
? AppOptions.getAll(OptionKind.PREFERENCE) ? AppOptions.getAll(OptionKind.PREFERENCE)
: PDFJSDev.json("$ROOT/build/default_preferences.json") : PDFJSDev.eval("DEFAULT_PREFERENCES")
), ),
writable: false, writable: false,
enumerable: true, enumerable: true,