2018-02-17 21:22:26 +09:00
|
|
|
/* Copyright 2018 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.
|
|
|
|
*/
|
|
|
|
|
2018-02-18 06:22:10 +09:00
|
|
|
import { apiCompatibilityParams } from 'pdfjs-lib';
|
2018-02-17 23:08:28 +09:00
|
|
|
import { viewerCompatibilityParams } from './viewer_compatibility';
|
|
|
|
|
2018-02-17 21:22:26 +09:00
|
|
|
const OptionKind = {
|
2019-02-13 22:00:23 +09:00
|
|
|
VIEWER: 0x02,
|
|
|
|
API: 0x04,
|
|
|
|
WORKER: 0x08,
|
|
|
|
PREFERENCE: 0x80,
|
2018-02-17 21:22:26 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PLEASE NOTE: To avoid introducing unnecessary dependencies, we specify the
|
2019-02-13 22:00:23 +09:00
|
|
|
* values below *explicitly* rather than relying on imported types.
|
2018-02-17 21:22:26 +09:00
|
|
|
*/
|
|
|
|
const defaultOptions = {
|
2018-03-20 07:24:56 +09:00
|
|
|
cursorToolOnLoad: {
|
|
|
|
/** @type {number} */
|
|
|
|
value: 0,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
2018-03-20 07:24:56 +09:00
|
|
|
},
|
2018-02-18 07:25:23 +09:00
|
|
|
defaultUrl: {
|
|
|
|
/** @type {string} */
|
|
|
|
value: 'compressed.tracemonkey-pldi-09.pdf',
|
|
|
|
kind: OptionKind.VIEWER,
|
|
|
|
},
|
2018-02-17 23:08:28 +09:00
|
|
|
defaultZoomValue: {
|
|
|
|
/** @type {string} */
|
|
|
|
value: '',
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
2018-02-17 23:08:28 +09:00
|
|
|
},
|
|
|
|
disableHistory: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: false,
|
|
|
|
kind: OptionKind.VIEWER,
|
|
|
|
},
|
|
|
|
disablePageLabels: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: false,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
2018-02-17 23:08:28 +09:00
|
|
|
},
|
2018-11-29 19:31:49 +09:00
|
|
|
/**
|
|
|
|
* The `disablePreferences` is, conditionally, defined below.
|
|
|
|
*/
|
2018-02-17 23:08:28 +09:00
|
|
|
enablePrintAutoRotate: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: false,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
2018-02-17 23:08:28 +09:00
|
|
|
},
|
|
|
|
enableWebGL: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: false,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
2018-02-17 23:08:28 +09:00
|
|
|
},
|
Add general support for re-dispatching events, on `EventBus` instances, to the DOM
This patch is the first step to be able to eventually get rid of the `attachDOMEventsToEventBus` function, by allowing `EventBus` instances to simply re-dispatch most[1] events to the DOM.
Note that the re-dispatching is purposely implemented to occur *after* all registered `EventBus` listeners have been serviced, to prevent the ordering issues that necessitated the duplicated page/scale-change events.
The DOM events are currently necessary for the `mozilla-central` tests, see https://hg.mozilla.org/mozilla-central/file/tip/browser/extensions/pdfjs/test, and perhaps also for custom deployments of the PDF.js default viewer.
Once this have landed, and been successfully uplifted to `mozilla-central`, I intent to submit a patch to update the test-code to utilize the new preference. This will thus, eventually, make it possible to remove the `attachDOMEventsToEventBus` functionality.
*Please note:* I've successfully ran all `mozilla-central` tests locally, with these patches applied.
---
[1] The exception being events that originated on the `window` or `document`, since those are already globally available anyway.
2018-08-28 17:26:18 +09:00
|
|
|
eventBusDispatchToDOM: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: false,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
Add general support for re-dispatching events, on `EventBus` instances, to the DOM
This patch is the first step to be able to eventually get rid of the `attachDOMEventsToEventBus` function, by allowing `EventBus` instances to simply re-dispatch most[1] events to the DOM.
Note that the re-dispatching is purposely implemented to occur *after* all registered `EventBus` listeners have been serviced, to prevent the ordering issues that necessitated the duplicated page/scale-change events.
The DOM events are currently necessary for the `mozilla-central` tests, see https://hg.mozilla.org/mozilla-central/file/tip/browser/extensions/pdfjs/test, and perhaps also for custom deployments of the PDF.js default viewer.
Once this have landed, and been successfully uplifted to `mozilla-central`, I intent to submit a patch to update the test-code to utilize the new preference. This will thus, eventually, make it possible to remove the `attachDOMEventsToEventBus` functionality.
*Please note:* I've successfully ran all `mozilla-central` tests locally, with these patches applied.
---
[1] The exception being events that originated on the `window` or `document`, since those are already globally available anyway.
2018-08-28 17:26:18 +09:00
|
|
|
},
|
2018-02-17 23:08:28 +09:00
|
|
|
externalLinkRel: {
|
|
|
|
/** @type {string} */
|
|
|
|
value: 'noopener noreferrer nofollow',
|
|
|
|
kind: OptionKind.VIEWER,
|
|
|
|
},
|
|
|
|
externalLinkTarget: {
|
|
|
|
/** @type {number} */
|
|
|
|
value: 0,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
2018-02-17 23:08:28 +09:00
|
|
|
},
|
Add support for updating the document hash, off by default, when the browser history is updated (issue 5753)
This is *really* the best that we can do here, since other proposed solutions would interfere with (and break) the painstakingly implemented browsing history that's present in the default viewer.
I'm still not convinced that this is a good idea in general, but this patch implements it in a way where it is possible to toggle[1] for users that wish to have this feature. In particular, there's a couple of reasons why I'm not finding this feature necessary/great:
- It's already possible to easily obtain the current hash, by simply clicking on the `viewBookmark` button at any time.
- Hash changes requires a bit of special handling[2], i.e. extra code, to prevent issues when the browser history is traversed (see `PDFHistory._popState`). Currently this is only necessary when the user has manually changed the hash, with this patch it will always be the case (assuming the feature is active).
- It's not always possible to change the URL when updating the browser history. For example: In the Firefox built-in viewer, the URL cannot be modified for local files (i.e. those using the `file://` protocol).
This leads to inconsistent behaviour, and may in some cases even result in errors being thrown and the history thus not updating, if the browser prevents changes to the URL during `pushState`/`replaceState` calls.
---
[1] Using the `historyUpdateUrl` viewer preference.
[2] This depends, to a great extent, on browsers always firing `popstate` events *before* `hashchange` events, which may or may not actually be guaranteed.
2019-01-03 23:45:33 +09:00
|
|
|
historyUpdateUrl: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: false,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
Add support for updating the document hash, off by default, when the browser history is updated (issue 5753)
This is *really* the best that we can do here, since other proposed solutions would interfere with (and break) the painstakingly implemented browsing history that's present in the default viewer.
I'm still not convinced that this is a good idea in general, but this patch implements it in a way where it is possible to toggle[1] for users that wish to have this feature. In particular, there's a couple of reasons why I'm not finding this feature necessary/great:
- It's already possible to easily obtain the current hash, by simply clicking on the `viewBookmark` button at any time.
- Hash changes requires a bit of special handling[2], i.e. extra code, to prevent issues when the browser history is traversed (see `PDFHistory._popState`). Currently this is only necessary when the user has manually changed the hash, with this patch it will always be the case (assuming the feature is active).
- It's not always possible to change the URL when updating the browser history. For example: In the Firefox built-in viewer, the URL cannot be modified for local files (i.e. those using the `file://` protocol).
This leads to inconsistent behaviour, and may in some cases even result in errors being thrown and the history thus not updating, if the browser prevents changes to the URL during `pushState`/`replaceState` calls.
---
[1] Using the `historyUpdateUrl` viewer preference.
[2] This depends, to a great extent, on browsers always firing `popstate` events *before* `hashchange` events, which may or may not actually be guaranteed.
2019-01-03 23:45:33 +09:00
|
|
|
},
|
2018-02-17 23:08:28 +09:00
|
|
|
imageResourcesPath: {
|
|
|
|
/** @type {string} */
|
|
|
|
value: './images/',
|
|
|
|
kind: OptionKind.VIEWER,
|
|
|
|
},
|
2018-06-23 20:01:43 +09:00
|
|
|
/**
|
|
|
|
* The `locale` is, conditionally, defined below.
|
|
|
|
*/
|
2018-02-17 23:08:28 +09:00
|
|
|
maxCanvasPixels: {
|
|
|
|
/** @type {number} */
|
2019-02-02 18:09:05 +09:00
|
|
|
value: 16777216,
|
|
|
|
compatibility: viewerCompatibilityParams.maxCanvasPixels,
|
2018-02-17 23:08:28 +09:00
|
|
|
kind: OptionKind.VIEWER,
|
|
|
|
},
|
|
|
|
pdfBugEnabled: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: false,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
2018-02-17 23:08:28 +09:00
|
|
|
},
|
|
|
|
renderer: {
|
|
|
|
/** @type {string} */
|
|
|
|
value: 'canvas',
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
2018-02-17 23:08:28 +09:00
|
|
|
},
|
|
|
|
renderInteractiveForms: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: false,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
2018-02-17 23:08:28 +09:00
|
|
|
},
|
|
|
|
sidebarViewOnLoad: {
|
|
|
|
/** @type {number} */
|
Modify a number of the viewer preferences, whose current default value is `0`, such that they behave as expected with the view history
The intention with preferences such as `sidebarViewOnLoad`/`scrollModeOnLoad`/`spreadModeOnLoad` were always that they should be able to *unconditionally* override their view history counterparts.
Due to the way that these preferences were initially implemented[1], trying to e.g. force the sidebar to remain hidden on load cannot be guaranteed[2]. The reason for this is the use of "enumeration values" containing zero, which in hindsight was an unfortunate choice on my part.
At this point it's also not as simple as just re-numbering the affected structures, since that would wreak havoc on existing (modified) preferences. The only reasonable solution that I was able to come up with was to change the *default* values of the preferences themselves, but not their actual values or the meaning thereof.
As part of the refactoring, the `disablePageMode` preference was combined with the *adjusted* `sidebarViewOnLoad` one, to hopefully reduce confusion by not tracking related state separately.
Additionally, the `showPreviousViewOnLoad` and `disableOpenActionDestination` preferences were combined into a *new* `viewOnLoad` enumeration preference, to further avoid tracking related state separately.
2019-01-27 20:07:38 +09:00
|
|
|
value: -1,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
2018-06-29 20:07:37 +09:00
|
|
|
},
|
|
|
|
scrollModeOnLoad: {
|
|
|
|
/** @type {number} */
|
Modify a number of the viewer preferences, whose current default value is `0`, such that they behave as expected with the view history
The intention with preferences such as `sidebarViewOnLoad`/`scrollModeOnLoad`/`spreadModeOnLoad` were always that they should be able to *unconditionally* override their view history counterparts.
Due to the way that these preferences were initially implemented[1], trying to e.g. force the sidebar to remain hidden on load cannot be guaranteed[2]. The reason for this is the use of "enumeration values" containing zero, which in hindsight was an unfortunate choice on my part.
At this point it's also not as simple as just re-numbering the affected structures, since that would wreak havoc on existing (modified) preferences. The only reasonable solution that I was able to come up with was to change the *default* values of the preferences themselves, but not their actual values or the meaning thereof.
As part of the refactoring, the `disablePageMode` preference was combined with the *adjusted* `sidebarViewOnLoad` one, to hopefully reduce confusion by not tracking related state separately.
Additionally, the `showPreviousViewOnLoad` and `disableOpenActionDestination` preferences were combined into a *new* `viewOnLoad` enumeration preference, to further avoid tracking related state separately.
2019-01-27 20:07:38 +09:00
|
|
|
value: -1,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
2018-06-29 20:07:37 +09:00
|
|
|
},
|
|
|
|
spreadModeOnLoad: {
|
|
|
|
/** @type {number} */
|
Modify a number of the viewer preferences, whose current default value is `0`, such that they behave as expected with the view history
The intention with preferences such as `sidebarViewOnLoad`/`scrollModeOnLoad`/`spreadModeOnLoad` were always that they should be able to *unconditionally* override their view history counterparts.
Due to the way that these preferences were initially implemented[1], trying to e.g. force the sidebar to remain hidden on load cannot be guaranteed[2]. The reason for this is the use of "enumeration values" containing zero, which in hindsight was an unfortunate choice on my part.
At this point it's also not as simple as just re-numbering the affected structures, since that would wreak havoc on existing (modified) preferences. The only reasonable solution that I was able to come up with was to change the *default* values of the preferences themselves, but not their actual values or the meaning thereof.
As part of the refactoring, the `disablePageMode` preference was combined with the *adjusted* `sidebarViewOnLoad` one, to hopefully reduce confusion by not tracking related state separately.
Additionally, the `showPreviousViewOnLoad` and `disableOpenActionDestination` preferences were combined into a *new* `viewOnLoad` enumeration preference, to further avoid tracking related state separately.
2019-01-27 20:07:38 +09:00
|
|
|
value: -1,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
2018-02-17 23:08:28 +09:00
|
|
|
},
|
|
|
|
textLayerMode: {
|
|
|
|
/** @type {number} */
|
|
|
|
value: 1,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
2018-02-17 23:08:28 +09:00
|
|
|
},
|
|
|
|
useOnlyCssZoom: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: false,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
2018-02-17 23:08:28 +09:00
|
|
|
},
|
Modify a number of the viewer preferences, whose current default value is `0`, such that they behave as expected with the view history
The intention with preferences such as `sidebarViewOnLoad`/`scrollModeOnLoad`/`spreadModeOnLoad` were always that they should be able to *unconditionally* override their view history counterparts.
Due to the way that these preferences were initially implemented[1], trying to e.g. force the sidebar to remain hidden on load cannot be guaranteed[2]. The reason for this is the use of "enumeration values" containing zero, which in hindsight was an unfortunate choice on my part.
At this point it's also not as simple as just re-numbering the affected structures, since that would wreak havoc on existing (modified) preferences. The only reasonable solution that I was able to come up with was to change the *default* values of the preferences themselves, but not their actual values or the meaning thereof.
As part of the refactoring, the `disablePageMode` preference was combined with the *adjusted* `sidebarViewOnLoad` one, to hopefully reduce confusion by not tracking related state separately.
Additionally, the `showPreviousViewOnLoad` and `disableOpenActionDestination` preferences were combined into a *new* `viewOnLoad` enumeration preference, to further avoid tracking related state separately.
2019-01-27 20:07:38 +09:00
|
|
|
viewOnLoad: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: 0,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
Modify a number of the viewer preferences, whose current default value is `0`, such that they behave as expected with the view history
The intention with preferences such as `sidebarViewOnLoad`/`scrollModeOnLoad`/`spreadModeOnLoad` were always that they should be able to *unconditionally* override their view history counterparts.
Due to the way that these preferences were initially implemented[1], trying to e.g. force the sidebar to remain hidden on load cannot be guaranteed[2]. The reason for this is the use of "enumeration values" containing zero, which in hindsight was an unfortunate choice on my part.
At this point it's also not as simple as just re-numbering the affected structures, since that would wreak havoc on existing (modified) preferences. The only reasonable solution that I was able to come up with was to change the *default* values of the preferences themselves, but not their actual values or the meaning thereof.
As part of the refactoring, the `disablePageMode` preference was combined with the *adjusted* `sidebarViewOnLoad` one, to hopefully reduce confusion by not tracking related state separately.
Additionally, the `showPreviousViewOnLoad` and `disableOpenActionDestination` preferences were combined into a *new* `viewOnLoad` enumeration preference, to further avoid tracking related state separately.
2019-01-27 20:07:38 +09:00
|
|
|
},
|
2018-02-17 23:33:57 +09:00
|
|
|
|
2018-02-18 00:57:24 +09:00
|
|
|
cMapPacked: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: true,
|
|
|
|
kind: OptionKind.API,
|
|
|
|
},
|
|
|
|
cMapUrl: {
|
|
|
|
/** @type {string} */
|
|
|
|
value: (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION') ?
|
|
|
|
'../external/bcmaps/' : '../web/cmaps/'),
|
|
|
|
kind: OptionKind.API,
|
|
|
|
},
|
2018-02-18 06:08:45 +09:00
|
|
|
disableAutoFetch: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: false,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.API + OptionKind.PREFERENCE,
|
2018-02-18 06:51:03 +09:00
|
|
|
},
|
|
|
|
disableCreateObjectURL: {
|
|
|
|
/** @type {boolean} */
|
2019-02-02 18:09:05 +09:00
|
|
|
value: false,
|
|
|
|
compatibility: apiCompatibilityParams.disableCreateObjectURL,
|
2018-02-18 06:08:45 +09:00
|
|
|
kind: OptionKind.API,
|
|
|
|
},
|
2018-02-18 05:57:20 +09:00
|
|
|
disableFontFace: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: false,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.API + OptionKind.PREFERENCE,
|
2018-02-18 05:57:20 +09:00
|
|
|
},
|
2018-02-18 06:22:10 +09:00
|
|
|
disableRange: {
|
|
|
|
/** @type {boolean} */
|
2018-06-21 15:12:30 +09:00
|
|
|
value: false,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.API + OptionKind.PREFERENCE,
|
2018-02-18 06:22:10 +09:00
|
|
|
},
|
2018-02-18 06:28:08 +09:00
|
|
|
disableStream: {
|
|
|
|
/** @type {boolean} */
|
2018-06-21 15:12:30 +09:00
|
|
|
value: false,
|
2019-02-13 22:00:23 +09:00
|
|
|
kind: OptionKind.API + OptionKind.PREFERENCE,
|
2018-02-18 06:28:08 +09:00
|
|
|
},
|
2018-02-18 05:49:14 +09:00
|
|
|
isEvalSupported: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: true,
|
|
|
|
kind: OptionKind.API,
|
|
|
|
},
|
2018-02-18 00:13:33 +09:00
|
|
|
maxImageSize: {
|
|
|
|
/** @type {number} */
|
|
|
|
value: -1,
|
|
|
|
kind: OptionKind.API,
|
|
|
|
},
|
2018-02-18 07:13:49 +09:00
|
|
|
pdfBug: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: false,
|
|
|
|
kind: OptionKind.API,
|
|
|
|
},
|
2018-02-17 23:33:57 +09:00
|
|
|
postMessageTransfers: {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: true,
|
|
|
|
kind: OptionKind.API,
|
|
|
|
},
|
|
|
|
verbosity: {
|
|
|
|
/** @type {number} */
|
|
|
|
value: 1,
|
|
|
|
kind: OptionKind.API,
|
|
|
|
},
|
|
|
|
|
|
|
|
workerPort: {
|
|
|
|
/** @type {Object} */
|
|
|
|
value: null,
|
|
|
|
kind: OptionKind.WORKER,
|
|
|
|
},
|
|
|
|
workerSrc: {
|
|
|
|
/** @type {string} */
|
|
|
|
value: (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION') ?
|
|
|
|
'../src/worker_loader.js' : '../build/pdf.worker.js'),
|
|
|
|
kind: OptionKind.WORKER,
|
|
|
|
},
|
2018-02-17 21:22:26 +09:00
|
|
|
};
|
2018-06-23 20:01:43 +09:00
|
|
|
if (typeof PDFJSDev === 'undefined' ||
|
|
|
|
PDFJSDev.test('!PRODUCTION || GENERIC')) {
|
2018-11-29 19:31:49 +09:00
|
|
|
defaultOptions.disablePreferences = {
|
|
|
|
/** @type {boolean} */
|
|
|
|
value: false,
|
|
|
|
kind: OptionKind.VIEWER,
|
|
|
|
};
|
2018-06-23 20:01:43 +09:00
|
|
|
defaultOptions.locale = {
|
|
|
|
/** @type {string} */
|
|
|
|
value: (typeof navigator !== 'undefined' ? navigator.language : 'en-US'),
|
|
|
|
kind: OptionKind.VIEWER,
|
|
|
|
};
|
|
|
|
}
|
2018-02-17 21:22:26 +09:00
|
|
|
|
|
|
|
const userOptions = Object.create(null);
|
|
|
|
|
|
|
|
class AppOptions {
|
|
|
|
constructor() {
|
|
|
|
throw new Error('Cannot initialize AppOptions.');
|
|
|
|
}
|
|
|
|
|
|
|
|
static get(name) {
|
2019-02-02 18:09:05 +09:00
|
|
|
const userOption = userOptions[name];
|
2018-02-17 21:22:26 +09:00
|
|
|
if (userOption !== undefined) {
|
|
|
|
return userOption;
|
|
|
|
}
|
2019-02-02 18:09:05 +09:00
|
|
|
const defaultOption = defaultOptions[name];
|
|
|
|
if (defaultOption !== undefined) {
|
|
|
|
return (defaultOption.compatibility || defaultOption.value);
|
|
|
|
}
|
|
|
|
return undefined;
|
2018-02-17 21:22:26 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
static getAll(kind = null) {
|
2019-02-02 18:09:05 +09:00
|
|
|
const options = Object.create(null);
|
|
|
|
for (const name in defaultOptions) {
|
|
|
|
const defaultOption = defaultOptions[name];
|
2019-02-13 22:00:23 +09:00
|
|
|
if (kind) {
|
|
|
|
if ((kind & defaultOption.kind) === 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((kind & OptionKind.PREFERENCE) !== 0) {
|
|
|
|
options[name] = defaultOption.value;
|
|
|
|
continue;
|
|
|
|
}
|
2018-02-17 21:22:26 +09:00
|
|
|
}
|
2019-02-02 18:09:05 +09:00
|
|
|
const userOption = userOptions[name];
|
|
|
|
options[name] = (userOption !== undefined ? userOption :
|
|
|
|
(defaultOption.compatibility || defaultOption.value));
|
2018-02-17 21:22:26 +09:00
|
|
|
}
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
static set(name, value) {
|
|
|
|
userOptions[name] = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static remove(name) {
|
|
|
|
delete userOptions[name];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
AppOptions,
|
|
|
|
OptionKind,
|
|
|
|
};
|