UNPKG

5.28 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2023 EclipseSource 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.frontendOnlyApplicationModule = exports.bindMessageService = void 0;
19const inversify_1 = require("inversify");
20const common_1 = require("../common");
21const application_protocol_1 = require("../common/application-protocol");
22const env_variables_1 = require("./../common/env-variables");
23const frontend_application_bindings_1 = require("../browser/frontend-application-bindings");
24Object.defineProperty(exports, "bindMessageService", { enumerable: true, get: function () { return frontend_application_bindings_1.bindMessageService; } });
25const key_store_1 = require("../common/key-store");
26const quick_pick_service_1 = require("../common/quick-pick-service");
27const quick_input_1 = require("../browser/quick-input");
28const request_1 = require("@theia/request");
29const connection_status_service_1 = require("../browser/connection-status-service");
30// is loaded directly after the regular frontend module
31exports.frontendOnlyApplicationModule = new inversify_1.ContainerModule((bind, unbind, isBound, rebind) => {
32 if (isBound(common_1.CommandRegistry)) {
33 rebind(common_1.CommandRegistry).toSelf().inSingletonScope();
34 }
35 else {
36 bind(common_1.CommandRegistry).toSelf().inSingletonScope();
37 }
38 const stopwatch = {
39 start: async (_name, _options) => -1,
40 stop: async (_measurement, _message, _messageArgs) => { }
41 };
42 if (isBound(common_1.BackendStopwatch)) {
43 rebind(common_1.BackendStopwatch).toConstantValue(stopwatch);
44 }
45 else {
46 bind(common_1.BackendStopwatch).toConstantValue(stopwatch);
47 }
48 if (isBound(common_1.CommandRegistry)) {
49 rebind(quick_pick_service_1.QuickPickService).to(quick_input_1.QuickPickServiceImpl).inSingletonScope();
50 }
51 else {
52 bind(quick_pick_service_1.QuickPickService).to(quick_input_1.QuickPickServiceImpl).inSingletonScope();
53 }
54 const mockedApplicationServer = {
55 getExtensionsInfos: async () => [],
56 getApplicationInfo: async () => undefined,
57 getApplicationRoot: async () => '',
58 getBackendOS: async () => common_1.OS.Type.Linux
59 };
60 if (isBound(application_protocol_1.ApplicationServer)) {
61 rebind(application_protocol_1.ApplicationServer).toConstantValue(mockedApplicationServer);
62 }
63 else {
64 bind(application_protocol_1.ApplicationServer).toConstantValue(mockedApplicationServer);
65 }
66 const varServer = {
67 getExecPath: async () => '',
68 getVariables: async () => [],
69 getValue: async (_key) => undefined,
70 getConfigDirUri: async () => '',
71 getHomeDirUri: async () => '',
72 getDrives: async () => []
73 };
74 if (isBound(env_variables_1.EnvVariablesServer)) {
75 rebind(env_variables_1.EnvVariablesServer).toConstantValue(varServer);
76 }
77 else {
78 bind(env_variables_1.EnvVariablesServer).toConstantValue(varServer);
79 }
80 const keyStoreService = {
81 deletePassword: () => Promise.resolve(false),
82 findCredentials: () => Promise.resolve([]),
83 findPassword: () => Promise.resolve(undefined),
84 setPassword: () => Promise.resolve(),
85 getPassword: () => Promise.resolve(undefined)
86 };
87 if (isBound(key_store_1.KeyStoreService)) {
88 rebind(key_store_1.KeyStoreService).toConstantValue(keyStoreService);
89 }
90 else {
91 bind(key_store_1.KeyStoreService).toConstantValue(keyStoreService);
92 }
93 const requestService = {
94 configure: () => Promise.resolve(),
95 request: () => Promise.reject(),
96 resolveProxy: () => Promise.resolve(undefined)
97 };
98 if (isBound(request_1.BackendRequestService)) {
99 rebind(request_1.BackendRequestService).toConstantValue(requestService);
100 }
101 else {
102 bind(request_1.BackendRequestService).toConstantValue(requestService);
103 }
104 const connectionStatusService = {
105 currentStatus: connection_status_service_1.ConnectionStatus.ONLINE,
106 onStatusChange: new common_1.Emitter().event
107 };
108 if (isBound(connection_status_service_1.ConnectionStatusService)) {
109 rebind(connection_status_service_1.ConnectionStatusService).toConstantValue(connectionStatusService);
110 }
111 else {
112 bind(connection_status_service_1.ConnectionStatusService).toConstantValue(connectionStatusService);
113 }
114});
115//# sourceMappingURL=frontend-only-application-module.js.map
\No newline at end of file