UNPKG

2.4 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2018 TypeFox and others.
4//
5// This program and the accompanying materials are made available under the
6// terms of the Eclipse Public License v. 2.0 which is available at
7// http://www.eclipse.org/legal/epl-2.0.
8//
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License v. 2.0 are satisfied: GNU General Public License, version 2
12// with the GNU Classpath Exception which is available at
13// https://www.gnu.org/software/classpath/license.html.
14//
15// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16// *****************************************************************************
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.FrontendApplicationConfigProvider = exports.DEFAULT_BACKGROUND_COLOR_STORAGE_KEY = void 0;
19const application_props_1 = require("@theia/application-package/lib/application-props");
20exports.DEFAULT_BACKGROUND_COLOR_STORAGE_KEY = 'theme.background';
21class FrontendApplicationConfigProvider {
22 static get() {
23 const config = FrontendApplicationConfigProvider.doGet();
24 if (config === undefined) {
25 throw new Error('The configuration is not set. Did you call FrontendApplicationConfigProvider#set?');
26 }
27 return config;
28 }
29 static set(config) {
30 if (FrontendApplicationConfigProvider.doGet() !== undefined) {
31 throw new Error('The configuration is already set.');
32 }
33 // eslint-disable-next-line @typescript-eslint/no-explicit-any
34 const globalObject = window;
35 const key = FrontendApplicationConfigProvider.KEY;
36 globalObject[key] = (0, application_props_1.deepmerge)(application_props_1.FrontendApplicationConfig.DEFAULT, config);
37 }
38 static doGet() {
39 // eslint-disable-next-line @typescript-eslint/no-explicit-any
40 const globalObject = window;
41 const key = FrontendApplicationConfigProvider.KEY;
42 return globalObject[key];
43 }
44}
45exports.FrontendApplicationConfigProvider = FrontendApplicationConfigProvider;
46FrontendApplicationConfigProvider.KEY = Symbol('FrontendApplicationConfigProvider');
47//# sourceMappingURL=frontend-application-config-provider.js.map
\No newline at end of file