refactor: group options-related logic in //src/common/options

Change-Id: Ib505da278accd878478399967efd72c8d89095ce
diff --git a/src/bg.js b/src/bg.js
index 4c3da6f..fce2328 100644
--- a/src/bg.js
+++ b/src/bg.js
@@ -3,8 +3,8 @@
 // #!endif
 
 import actionApi from './common/actionApi.js';
-import {cleanUpOptPermissions} from './common/optionsPermissions.js';
-import {cleanUpOptions, disableItemsWithMissingPermissions} from './common/optionsUtils.js';
+import {cleanUpOptPermissions} from './common/options/optionsPermissions.js';
+import {cleanUpOptions, disableItemsWithMissingPermissions} from './common/options/optionsUtils.js';
 import KillSwitchMechanism from './killSwitch/index.js';
 import {handleBgOptionChange, handleBgOptionsOnStart} from './options/bgHandler.js';
 import UpdateNotifier from './updateNotifier/index.js';
diff --git a/src/common/architecture/dependenciesProvider/DependenciesProvider.ts b/src/common/architecture/dependenciesProvider/DependenciesProvider.ts
index 221cc51..68f77fd 100644
--- a/src/common/architecture/dependenciesProvider/DependenciesProvider.ts
+++ b/src/common/architecture/dependenciesProvider/DependenciesProvider.ts
@@ -1,6 +1,6 @@
 import ExtraInfo from '../../../features/extraInfo/core';
 import AutoRefresh from '../../../features/autoRefresh/core/autoRefresh';
-import OptionsProvider from '../../OptionsProvider';
+import OptionsProvider from '../../options/OptionsProvider';
 import WorkflowsImport from '../../../features/workflows/core/communityConsole/import';
 import Workflows from '../../../features/workflows/core/communityConsole/workflows';
 import StartupDataStorage from '../../../contentScripts/communityConsole/utils/StartupDataStorage';
diff --git a/src/common/architecture/features/Feature.ts b/src/common/architecture/features/Feature.ts
index e1a3389..76f5990 100644
--- a/src/common/architecture/features/Feature.ts
+++ b/src/common/architecture/features/Feature.ts
@@ -1,4 +1,4 @@
-import { OptionCodename } from '../../optionsPrototype';
+import { OptionCodename } from '../../options/optionsPrototype';
 import Script, { ConcreteScript } from '../scripts/Script';
 
 export default abstract class Feature {
diff --git a/src/common/csEventListener.js b/src/common/csEventListener.js
index 393f5f7..353f463 100644
--- a/src/common/csEventListener.js
+++ b/src/common/csEventListener.js
@@ -1,7 +1,7 @@
 // In order to pass i18n strings and settings values to the injected scripts,
 // which don't have access to the chrome.* APIs, we use event listeners.
 
-import {getOptions} from './optionsUtils.js';
+import {getOptions} from './options/optionsUtils.js';
 
 export function setUpListener() {
   window.addEventListener('TWPT_sendRequest', evt => {
diff --git a/src/common/mainWorldOptionsWatcher/Server.js b/src/common/mainWorldOptionsWatcher/Server.js
index efa5438..eca2955 100644
--- a/src/common/mainWorldOptionsWatcher/Server.js
+++ b/src/common/mainWorldOptionsWatcher/Server.js
@@ -1,4 +1,4 @@
-import PartialOptionsWatcher from '../partialOptionsWatcher.js';
+import PartialOptionsWatcher from '../options/partialOptionsWatcher.js';
 import MainWorldContentScriptBridgeServer from '../mainWorldContentScriptBridge/Server.js';
 
 // Main World OptionsWatcher server (used in content scripts to be able to serve
diff --git a/src/common/Option.ts b/src/common/options/Option.ts
similarity index 100%
rename from src/common/Option.ts
rename to src/common/options/Option.ts
diff --git a/src/common/OptionsProvider.ts b/src/common/options/OptionsProvider.ts
similarity index 100%
rename from src/common/OptionsProvider.ts
rename to src/common/options/OptionsProvider.ts
diff --git a/src/common/optionsPermissions.js b/src/common/options/optionsPermissions.js
similarity index 98%
rename from src/common/optionsPermissions.js
rename to src/common/options/optionsPermissions.js
index 2fa298b..f005131 100644
--- a/src/common/optionsPermissions.js
+++ b/src/common/options/optionsPermissions.js
@@ -1,5 +1,5 @@
-import actionApi from './actionApi.js';
-import {optionsPrototype} from './optionsPrototype.ts';
+import actionApi from '../actionApi.js';
+import {optionsPrototype} from './optionsPrototype';
 import {getOptions} from './optionsUtils.js';
 
 // Required permissions, including host permissions.
diff --git a/src/common/optionsPrototype.ts b/src/common/options/optionsPrototype.ts
similarity index 100%
rename from src/common/optionsPrototype.ts
rename to src/common/options/optionsPrototype.ts
diff --git a/src/common/optionsUtils.js b/src/common/options/optionsUtils.js
similarity index 98%
rename from src/common/optionsUtils.js
rename to src/common/options/optionsUtils.js
index 652f9e8..055e46b 100644
--- a/src/common/optionsUtils.js
+++ b/src/common/options/optionsUtils.js
@@ -1,5 +1,5 @@
 import {grantedOptPermissions, isPermissionsObjectEmpty, missingPermissions} from './optionsPermissions.js';
-import {optionsPrototype} from './optionsPrototype.ts';
+import {optionsPrototype} from './optionsPrototype';
 import specialOptions from './specialOptions.json5';
 
 export {optionsPrototype, specialOptions};
diff --git a/src/common/partialOptionsWatcher.js b/src/common/options/partialOptionsWatcher.js
similarity index 100%
rename from src/common/partialOptionsWatcher.js
rename to src/common/options/partialOptionsWatcher.js
diff --git a/src/common/specialOptions.json5 b/src/common/options/specialOptions.json5
similarity index 100%
rename from src/common/specialOptions.json5
rename to src/common/options/specialOptions.json5
diff --git a/src/contentScripts/communityConsole/avatars.js b/src/contentScripts/communityConsole/avatars.js
index 66123b0..c9f6bb6 100644
--- a/src/contentScripts/communityConsole/avatars.js
+++ b/src/contentScripts/communityConsole/avatars.js
@@ -2,7 +2,7 @@
 
 import {CCApi} from '../../common/api.js';
 import {parseUrl} from '../../common/commonUtils.js';
-import PartialOptionsWatcher from '../../common/partialOptionsWatcher.js';
+import PartialOptionsWatcher from '../../common/options/partialOptionsWatcher.js';
 import {createPlainTooltip} from '../../common/tooltip.js';
 
 import AvatarsDB from './utils/AvatarsDB.js'
diff --git a/src/contentScripts/communityConsole/batchLock.js b/src/contentScripts/communityConsole/batchLock.js
index 29a3dc3..9479d31 100644
--- a/src/contentScripts/communityConsole/batchLock.js
+++ b/src/contentScripts/communityConsole/batchLock.js
@@ -1,4 +1,4 @@
-import {isOptionEnabled} from '../../common/optionsUtils.js';
+import {isOptionEnabled} from '../../common/options/optionsUtils.js';
 
 import {addButtonToThreadListActions, removeChildNodes, shouldAddBtnToActionBar, softRefreshView} from './utils/common.js';
 
diff --git a/src/contentScripts/communityConsole/dragAndDropFix.js b/src/contentScripts/communityConsole/dragAndDropFix.js
index d2b93d0..0839071 100644
--- a/src/contentScripts/communityConsole/dragAndDropFix.js
+++ b/src/contentScripts/communityConsole/dragAndDropFix.js
@@ -1,4 +1,4 @@
-import {isOptionEnabled} from '../../common/optionsUtils.js';
+import {isOptionEnabled} from '../../common/options/optionsUtils.js';
 
 export function applyDragAndDropFix(node) {
   console.debug('Adding link drag&drop fix to ', node);
diff --git a/src/contentScripts/communityConsole/flattenThreads/replyActionHandler.js b/src/contentScripts/communityConsole/flattenThreads/replyActionHandler.js
index 99ef0fc..182f962 100644
--- a/src/contentScripts/communityConsole/flattenThreads/replyActionHandler.js
+++ b/src/contentScripts/communityConsole/flattenThreads/replyActionHandler.js
@@ -1,7 +1,7 @@
 import {waitFor} from 'poll-until-promise';
 
 import {parseUrl} from '../../../common/commonUtils';
-import {getOptions} from '../../../common/optionsUtils';
+import {getOptions} from '../../../common/options/optionsUtils';
 
 const kOpenReplyEditorIntervalInMs = 500;
 const kOpenReplyEditorTimeoutInMs = 10 * 1000;
diff --git a/src/contentScripts/communityConsole/main.js b/src/contentScripts/communityConsole/main.js
index 6cbfced..32576e4 100644
--- a/src/contentScripts/communityConsole/main.js
+++ b/src/contentScripts/communityConsole/main.js
@@ -1,5 +1,5 @@
 import {injectScript, injectStyles, injectStylesheet} from '../../common/contentScriptsUtils.js';
-import {getOptions} from '../../common/optionsUtils.js';
+import {getOptions} from '../../common/options/optionsUtils.js';
 import XHRProxyKillSwitchHandler from '../../xhrInterceptor/killSwitchHandler.js';
 import {injectPreviousPostsLinksUnifiedProfileIfEnabled} from '../utilsCommon/unifiedProfiles.js';
 
diff --git a/src/contentScripts/communityConsole/start.js b/src/contentScripts/communityConsole/start.js
index cf5a7a5..cace3aa 100644
--- a/src/contentScripts/communityConsole/start.js
+++ b/src/contentScripts/communityConsole/start.js
@@ -1,5 +1,5 @@
 import {injectStylesheet} from '../../common/contentScriptsUtils.js';
-import {getOptions} from '../../common/optionsUtils.js';
+import {getOptions} from '../../common/options/optionsUtils.js';
 
 import FlattenThreadsReplyActionHandler from './flattenThreads/replyActionHandler.js';
 
diff --git a/src/contentScripts/communityConsole/threadToolbar/threadToolbar.js b/src/contentScripts/communityConsole/threadToolbar/threadToolbar.js
index 6344e3c..db11640 100644
--- a/src/contentScripts/communityConsole/threadToolbar/threadToolbar.js
+++ b/src/contentScripts/communityConsole/threadToolbar/threadToolbar.js
@@ -1,4 +1,4 @@
-import {getOptions} from '../../../common/optionsUtils.js';
+import {getOptions} from '../../../common/options/optionsUtils.js';
 import {softRefreshView} from '../utils/common.js';
 
 import * as consts from './constants.js';
diff --git a/src/contentScripts/publicForum.js b/src/contentScripts/publicForum.js
index 043e8c9..d03976b 100644
--- a/src/contentScripts/publicForum.js
+++ b/src/contentScripts/publicForum.js
@@ -1,4 +1,4 @@
-import {getOptions} from '../common/optionsUtils.js';
+import {getOptions} from '../common/options/optionsUtils.js';
 
 var intersectionObserver;
 
diff --git a/src/contentScripts/publicProfile.js b/src/contentScripts/publicProfile.js
index 9c36ae1..9608ee0 100644
--- a/src/contentScripts/publicProfile.js
+++ b/src/contentScripts/publicProfile.js
@@ -1,4 +1,4 @@
-import {getOptions} from '../common/optionsUtils.js';
+import {getOptions} from '../common/options/optionsUtils.js';
 import {parseView} from '../common/TWBasicUtils.js';
 
 import PerForumStatsSection from './communityConsole/utils/PerForumStatsSection.js';
diff --git a/src/contentScripts/publicProfileStart.js b/src/contentScripts/publicProfileStart.js
index 5238337..fbe6540 100644
--- a/src/contentScripts/publicProfileStart.js
+++ b/src/contentScripts/publicProfileStart.js
@@ -1,5 +1,5 @@
 import {injectScript} from '../common/contentScriptsUtils.js';
-import {getOptions} from '../common/optionsUtils.js';
+import {getOptions} from '../common/options/optionsUtils.js';
 
 getOptions('perforumstats').then(options => {
   if (options?.perforumstats)
diff --git a/src/contentScripts/publicThread.js b/src/contentScripts/publicThread.js
index 4d98bee..bc12236 100644
--- a/src/contentScripts/publicThread.js
+++ b/src/contentScripts/publicThread.js
@@ -1,5 +1,5 @@
 import {injectStylesheet} from '../common/contentScriptsUtils.js';
-import {getOptions} from '../common/optionsUtils.js';
+import {getOptions} from '../common/options/optionsUtils.js';
 import {redirectIfApplicable} from '../redirect/index.js';
 
 const kLoadMoreButtons = [
diff --git a/src/contentScripts/publicThreadStart.js b/src/contentScripts/publicThreadStart.js
index 9581aec..a95485b 100644
--- a/src/contentScripts/publicThreadStart.js
+++ b/src/contentScripts/publicThreadStart.js
@@ -1,5 +1,5 @@
 import {injectStylesheet} from '../common/contentScriptsUtils.js';
-import {getOptions} from '../common/optionsUtils.js';
+import {getOptions} from '../common/options/optionsUtils.js';
 import {setUpRedirectIfEnabled} from '../redirect/setup.js';
 
 getOptions(['uispacing', 'redirect']).then(options => {
diff --git a/src/contentScripts/utilsCommon/unifiedProfiles.js b/src/contentScripts/utilsCommon/unifiedProfiles.js
index e1ba59f..eccb4b6 100644
--- a/src/contentScripts/utilsCommon/unifiedProfiles.js
+++ b/src/contentScripts/utilsCommon/unifiedProfiles.js
@@ -2,7 +2,7 @@
 
 import {createImmuneLink} from '../../common/commonUtils.js';
 import {escapeUsername} from '../../common/communityConsoleUtils.js';
-import {isOptionEnabled} from '../../common/optionsUtils.js';
+import {isOptionEnabled} from '../../common/options/optionsUtils.js';
 import {createPlainTooltip} from '../../common/tooltip.js';
 import {createExtBadge} from '../communityConsole/utils/common.js';
 
diff --git a/src/features/autoRefresh/autoRefresh.feature.ts b/src/features/autoRefresh/autoRefresh.feature.ts
index dd0959e..06ca388 100644
--- a/src/features/autoRefresh/autoRefresh.feature.ts
+++ b/src/features/autoRefresh/autoRefresh.feature.ts
@@ -1,6 +1,6 @@
 import Feature from '../../common/architecture/features/Feature';
 import { ConcreteScript } from '../../common/architecture/scripts/Script';
-import { OptionCodename } from '../../common/optionsPrototype';
+import { OptionCodename } from '../../common/options/optionsPrototype';
 import AutoRefreshNodeWatcherScript from './scripts/nodeWatcher.script';
 import AutoRefreshSetUpScript from './scripts/setUp.script';
 import AutoRefreshStylesScript from './scripts/styles.script';
diff --git a/src/features/autoRefresh/core/autoRefresh.js b/src/features/autoRefresh/core/autoRefresh.js
index c2d64d2..03e21d1 100644
--- a/src/features/autoRefresh/core/autoRefresh.js
+++ b/src/features/autoRefresh/core/autoRefresh.js
@@ -2,7 +2,7 @@
 
 import {CCApi} from '../../../common/api.js';
 import {getAuthUser} from '../../../common/communityConsoleUtils.js';
-import {isOptionEnabled} from '../../../common/optionsUtils.js';
+import {isOptionEnabled} from '../../../common/options/optionsUtils.js';
 import {createPlainTooltip} from '../../../common/tooltip.js';
 
 import {createExtBadge, softRefreshView} from '../../../contentScripts/communityConsole/utils/common.js';
diff --git a/src/features/extraInfo/core/index.js b/src/features/extraInfo/core/index.js
index d016904..29ae400 100644
--- a/src/features/extraInfo/core/index.js
+++ b/src/features/extraInfo/core/index.js
@@ -1,4 +1,4 @@
-import PartialOptionsWatcher from '../../../common/partialOptionsWatcher.js';
+import PartialOptionsWatcher from '../../../common/options/partialOptionsWatcher.js';
 
 import ProfileInfoHandler from './infoHandlers/profile.js';
 import ThreadInfoHandler from './infoHandlers/thread.js';
diff --git a/src/features/extraInfo/extraInfo.feature.ts b/src/features/extraInfo/extraInfo.feature.ts
index 63f0818..0f2ccd7 100644
--- a/src/features/extraInfo/extraInfo.feature.ts
+++ b/src/features/extraInfo/extraInfo.feature.ts
@@ -1,6 +1,6 @@
 import Feature from '../../common/architecture/features/Feature';
 import { ConcreteScript } from '../../common/architecture/scripts/Script';
-import { OptionCodename } from '../../common/optionsPrototype';
+import { OptionCodename } from '../../common/options/optionsPrototype';
 import CCExtraInfoDependencySetUpScript from './scripts/ccExtraInfoDependencySetUp.script';
 import CCExtraInfoInjectScript from './scripts/ccExtraInfoInject.script';
 import CCExtraInfoMainScript from './scripts/ccExtraInfoMain.script';
diff --git a/src/features/infiniteScroll/core/ccInfiniteScroll.js b/src/features/infiniteScroll/core/ccInfiniteScroll.js
index 93e693c..4dde91c 100644
--- a/src/features/infiniteScroll/core/ccInfiniteScroll.js
+++ b/src/features/infiniteScroll/core/ccInfiniteScroll.js
@@ -1,4 +1,4 @@
-import {getOptions, isOptionEnabled} from '../../../common/optionsUtils.js';
+import {getOptions, isOptionEnabled} from '../../../common/options/optionsUtils.js';
 
 const kInteropLoadMoreClasses = {
   // New (interop) UI without nested replies
diff --git a/src/features/infiniteScroll/infiniteScroll.feature.ts b/src/features/infiniteScroll/infiniteScroll.feature.ts
index 4f3ff41..b6dee6a 100644
--- a/src/features/infiniteScroll/infiniteScroll.feature.ts
+++ b/src/features/infiniteScroll/infiniteScroll.feature.ts
@@ -1,6 +1,6 @@
 import Feature from '../../common/architecture/features/Feature';
 import { ConcreteScript } from '../../common/architecture/scripts/Script';
-import { OptionCodename } from '../../common/optionsPrototype';
+import { OptionCodename } from '../../common/options/optionsPrototype';
 import CCInfiniteScrollScript from './scripts/ccInfiniteScroll.script';
 
 export default class InfiniteScrollFeature extends Feature {
diff --git a/src/features/workflows/core/communityConsole/import.js b/src/features/workflows/core/communityConsole/import.js
index 68eb5a7..92abaee 100644
--- a/src/features/workflows/core/communityConsole/import.js
+++ b/src/features/workflows/core/communityConsole/import.js
@@ -2,7 +2,7 @@
 
 import {recursiveParentElement} from '../../../../common/commonUtils.js';
 import {injectStylesheet} from '../../../../common/contentScriptsUtils.js';
-import {isOptionEnabled} from '../../../../common/optionsUtils.js';
+import {isOptionEnabled} from '../../../../common/options/optionsUtils.js';
 
 const kListCannedResponsesResponse = 'TWPT_ListCannedResponsesResponse';
 
diff --git a/src/features/workflows/core/communityConsole/workflows.js b/src/features/workflows/core/communityConsole/workflows.js
index 652df29..1110923 100644
--- a/src/features/workflows/core/communityConsole/workflows.js
+++ b/src/features/workflows/core/communityConsole/workflows.js
@@ -1,4 +1,4 @@
-import {isOptionEnabled} from '../../../../common/optionsUtils.js';
+import {isOptionEnabled} from '../../../../common/options/optionsUtils.js';
 import WorkflowsStorage from '../workflowsStorage.js';
 import {addElementToThreadListActions, shouldAddBtnToActionBar} from '../../../../contentScripts/communityConsole/utils/common.js';
 
diff --git a/src/features/workflows/workflows.feature.ts b/src/features/workflows/workflows.feature.ts
index 7a6976c..9033ecb 100644
--- a/src/features/workflows/workflows.feature.ts
+++ b/src/features/workflows/workflows.feature.ts
@@ -1,6 +1,6 @@
 import Feature from '../../common/architecture/features/Feature';
 import { ConcreteScript } from '../../common/architecture/scripts/Script';
-import { OptionCodename } from '../../common/optionsPrototype';
+import { OptionCodename } from '../../common/options/optionsPrototype';
 import WorkflowsDependenciesSetUpAtMainScript from './scripts/dependenciesSetUpAtMain.script';
 import WorkflowsDependenciesSetUpAtStartScript from './scripts/dependenciesSetUpAtStart.script';
 import WorkflowsNodeWatcherScript from './scripts/nodeWatcher.script';
diff --git a/src/killSwitch/internalKillSwitchWatcher.js b/src/killSwitch/internalKillSwitchWatcher.js
index 86ae5cb..7b2d93c 100644
--- a/src/killSwitch/internalKillSwitchWatcher.js
+++ b/src/killSwitch/internalKillSwitchWatcher.js
@@ -1,4 +1,4 @@
-import {getForceDisabledFeatures} from '../common/optionsUtils.js';
+import {getForceDisabledFeatures} from '../common/options/optionsUtils.js';
 
 /**
  * Watches for changes to an internal kill switch and calls a callback when a
diff --git a/src/options/bgHandler.js b/src/options/bgHandler.js
index 52f0d10..828eb22 100644
--- a/src/options/bgHandler.js
+++ b/src/options/bgHandler.js
@@ -9,7 +9,7 @@
 // The "blockdrafts" feature was removed, but this logic has been kept in case
 // it is needed in the future.
 
-import {isOptionEnabled} from '../common/optionsUtils.js';
+import {isOptionEnabled} from '../common/options/optionsUtils.js';
 
 // List of features controled in the background:
 export var bgFeatures = [];
diff --git a/src/options/optionsCommon.js b/src/options/optionsCommon.js
index f8d5c14..badeaf1 100644
--- a/src/options/optionsCommon.js
+++ b/src/options/optionsCommon.js
@@ -1,6 +1,6 @@
 import {getDocURL, getDocURLWithRef, getExtVersion, isProdVersion} from '../common/extUtils.js';
-import {ensureOptPermissions, grantedOptPermissions, isPermissionsObjectEmpty, missingPermissions} from '../common/optionsPermissions.js';
-import {cleanUpOptions, optionsPrototype, specialOptions} from '../common/optionsUtils.js';
+import {ensureOptPermissions, grantedOptPermissions, isPermissionsObjectEmpty, missingPermissions} from '../common/options/optionsPermissions.js';
+import {cleanUpOptions, optionsPrototype, specialOptions} from '../common/options/optionsUtils.js';
 
 import optionsPage from './optionsPage.json5';
 
diff --git a/src/redirect/setup.js b/src/redirect/setup.js
index 632bc69..57eb618 100644
--- a/src/redirect/setup.js
+++ b/src/redirect/setup.js
@@ -1,4 +1,4 @@
-import {getOptions} from '../common/optionsUtils.js';
+import {getOptions} from '../common/options/optionsUtils.js';
 
 export async function setUpRedirectIfEnabled(options = null) {
   if (options === null) options = await getOptions(['redirect']);
diff --git a/tools/printOptionsPrototypeJSON.ts b/tools/printOptionsPrototypeJSON.ts
index 5c29019..68da351 100644
--- a/tools/printOptionsPrototypeJSON.ts
+++ b/tools/printOptionsPrototypeJSON.ts
@@ -1,4 +1,4 @@
-import { optionsPrototype } from '../src/common/optionsPrototype';
+import { optionsPrototype } from '../src/common/options/optionsPrototype';
 
 const optionsPrototypeJson = JSON.stringify(optionsPrototype, null, 2);
 process.stdout.write(`${optionsPrototypeJson}\n`);