UNPKG

3.6 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2019 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.bindResourceProvider = exports.bindPreferenceService = exports.bindMessageService = void 0;
19const common_1 = require("../common");
20const preferences_1 = require("./preferences");
21const injectable_preference_proxy_1 = require("./preferences/injectable-preference-proxy");
22function bindMessageService(bind) {
23 bind(common_1.MessageClient).toSelf().inSingletonScope();
24 return bind(common_1.MessageService).toSelf().inSingletonScope();
25}
26exports.bindMessageService = bindMessageService;
27function bindPreferenceService(bind) {
28 bind(preferences_1.PreferenceProvider).toSelf().inSingletonScope().whenTargetNamed(preferences_1.PreferenceScope.User);
29 bind(preferences_1.PreferenceProvider).toSelf().inSingletonScope().whenTargetNamed(preferences_1.PreferenceScope.Workspace);
30 bind(preferences_1.PreferenceProvider).toSelf().inSingletonScope().whenTargetNamed(preferences_1.PreferenceScope.Folder);
31 bind(preferences_1.PreferenceProviderProvider).toFactory(ctx => (scope) => {
32 if (scope === preferences_1.PreferenceScope.Default) {
33 return ctx.container.get(preferences_1.PreferenceSchemaProvider);
34 }
35 return ctx.container.getNamed(preferences_1.PreferenceProvider, scope);
36 });
37 bind(preferences_1.PreferenceServiceImpl).toSelf().inSingletonScope();
38 bind(preferences_1.PreferenceService).toService(preferences_1.PreferenceServiceImpl);
39 (0, preferences_1.bindPreferenceSchemaProvider)(bind);
40 bind(preferences_1.PreferenceValidationService).toSelf().inSingletonScope();
41 bind(injectable_preference_proxy_1.InjectablePreferenceProxy).toSelf();
42 bind(injectable_preference_proxy_1.PreferenceProxyFactory).toFactory(({ container }) => (schema, options = {}) => {
43 const child = container.createChild();
44 child.bind(preferences_1.PreferenceProxyOptions).toConstantValue(options !== null && options !== void 0 ? options : {});
45 child.bind(injectable_preference_proxy_1.PreferenceProxySchema).toConstantValue(() => schema);
46 const handler = child.get(injectable_preference_proxy_1.InjectablePreferenceProxy);
47 return new Proxy(Object.create(null), handler); // eslint-disable-line no-null/no-null
48 });
49}
50exports.bindPreferenceService = bindPreferenceService;
51function bindResourceProvider(bind) {
52 bind(common_1.DefaultResourceProvider).toSelf().inSingletonScope();
53 bind(common_1.ResourceProvider).toProvider(context => uri => context.container.get(common_1.DefaultResourceProvider).get(uri));
54 (0, common_1.bindContributionProvider)(bind, common_1.ResourceResolver);
55}
56exports.bindResourceProvider = bindResourceProvider;
57//# sourceMappingURL=frontend-application-bindings.js.map
\No newline at end of file