diff --git a/plugin.js b/plugin.js index 6d66429..a7b68a4 100644 --- a/plugin.js +++ b/plugin.js @@ -45,6 +45,21 @@ import RealtimeSessions from './src/realtimeSessions/plugin.js'; import GlobalFilters from './src/globalFilters/plugin.js'; import ExportDataAction from './src/exportDataAction/plugin.js'; +// optional runtime config +let runtimeConfig = {}; + +try { + const response = await fetch('./config.json', { cache: 'no-store' }); + + if (response.ok) { + runtimeConfig = await response.json(); + } else if (response.status !== 404) { + console.warn(`Unable to load config.json: ${response.status}`); + } +} catch (error) { + console.warn('Unable to load config.json', error); +} + export default function openmctMCWSPlugin(options) { return function install(openmct) { const defaultConfig = { @@ -156,7 +171,9 @@ export default function openmctMCWSPlugin(options) { return item && typeof item === 'object' && !Array.isArray(item); } - const config = deepMerge(defaultConfig, options || {}); + // order of precedence: runtimeConfig, recipeConfig, defaultConfig + const recipeConfig = options || {}; + const config = deepMerge(defaultConfig, deepMerge(recipeConfig, runtimeConfig)); if (config.useDeveloperStorage === undefined) { // Attempt to define a reasonable default for developer storage that supports Open MCT build tool