1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

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

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

View file

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