@theia/core
Version:
Theia is a cloud & desktop IDE framework implemented in TypeScript.
73 lines • 2.81 kB
JavaScript
// *****************************************************************************
// Copyright (C) 2026 EclipseSource and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
// with the GNU Classpath Exception which is available at
// https://www.gnu.org/software/classpath/license.html.
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************
import { __decorate } from "tslib";
import { injectable, postConstruct } from 'inversify';
import { PreferenceProviderImpl } from './preference-provider-impl.js';
import { PreferenceScope } from './preference-scope.js';
/**
* In-memory preference provider used for process-lifetime overrides such as those
* supplied via the `--session-preference` CLI option. Values live in memory only
* and are dropped when the process exits.
*/
let SessionPreferenceProvider = class SessionPreferenceProvider extends PreferenceProviderImpl {
constructor() {
super(...arguments);
this.preferences = new Map();
}
init() {
this._ready.resolve();
}
canHandleScope(scope) {
return scope === PreferenceScope.Session;
}
getPreferences() {
const result = {};
for (const [name, value] of this.preferences) {
result[name] = value;
}
return result;
}
async setPreference(key, value, _resourceUri, overrideIdentifier) {
const storageKey = overrideIdentifier ? `[${overrideIdentifier}].${key}` : key;
const oldValue = this.preferences.get(storageKey);
if (value === undefined) {
if (!this.preferences.has(storageKey)) {
return false;
}
this.preferences.delete(storageKey);
}
else {
this.preferences.set(storageKey, value);
}
const change = {
preferenceName: key,
newValue: value,
oldValue,
scope: PreferenceScope.Session,
overrideIdentifier
};
await this.emitPreferencesChangedEvent([change]);
return true;
}
};
__decorate([
postConstruct()
], SessionPreferenceProvider.prototype, "init", null);
SessionPreferenceProvider = __decorate([
injectable()
], SessionPreferenceProvider);
export { SessionPreferenceProvider };
//# sourceMappingURL=session-preference-provider.js.map