@theia/core 1.45.1 → 1.46.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/README.md +6 -6
  2. package/i18n/nls.cs.json +4 -0
  3. package/i18n/nls.de.json +4 -0
  4. package/i18n/nls.es.json +4 -0
  5. package/i18n/nls.fr.json +4 -0
  6. package/i18n/nls.hu.json +4 -0
  7. package/i18n/nls.it.json +4 -0
  8. package/i18n/nls.ja.json +4 -0
  9. package/i18n/nls.json +4 -0
  10. package/i18n/nls.pl.json +4 -0
  11. package/i18n/nls.pt-br.json +4 -0
  12. package/i18n/nls.pt-pt.json +4 -0
  13. package/i18n/nls.ru.json +4 -0
  14. package/i18n/nls.zh-cn.json +4 -0
  15. package/lib/browser/browser.d.ts +3 -0
  16. package/lib/browser/browser.d.ts.map +1 -1
  17. package/lib/browser/browser.js +5 -1
  18. package/lib/browser/browser.js.map +1 -1
  19. package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
  20. package/lib/browser/common-frontend-contribution.js +3 -3
  21. package/lib/browser/common-frontend-contribution.js.map +1 -1
  22. package/lib/browser/frontend-application-module.d.ts.map +1 -1
  23. package/lib/browser/frontend-application-module.js +2 -1
  24. package/lib/browser/frontend-application-module.js.map +1 -1
  25. package/lib/browser/tree/index.d.ts +1 -0
  26. package/lib/browser/tree/index.d.ts.map +1 -1
  27. package/lib/browser/tree/index.js +1 -0
  28. package/lib/browser/tree/index.js.map +1 -1
  29. package/lib/browser/tree/tree-preference.d.ts +11 -0
  30. package/lib/browser/tree/tree-preference.d.ts.map +1 -0
  31. package/lib/browser/tree/tree-preference.js +47 -0
  32. package/lib/browser/tree/tree-preference.js.map +1 -0
  33. package/lib/browser/tree/tree-widget.d.ts +6 -3
  34. package/lib/browser/tree/tree-widget.d.ts.map +1 -1
  35. package/lib/browser/tree/tree-widget.js +24 -3
  36. package/lib/browser/tree/tree-widget.js.map +1 -1
  37. package/lib/browser/tree/tree.d.ts.map +1 -1
  38. package/lib/browser/tree/tree.js +4 -1
  39. package/lib/browser/tree/tree.js.map +1 -1
  40. package/lib/browser/widget-manager.d.ts +9 -0
  41. package/lib/browser/widget-manager.d.ts.map +1 -1
  42. package/lib/browser/widget-manager.js +23 -0
  43. package/lib/browser/widget-manager.js.map +1 -1
  44. package/lib/browser/widgets/select-component.d.ts.map +1 -1
  45. package/lib/browser/widgets/select-component.js +1 -0
  46. package/lib/browser/widgets/select-component.js.map +1 -1
  47. package/lib/browser-only/frontend-only-application-module.d.ts +5 -0
  48. package/lib/browser-only/frontend-only-application-module.d.ts.map +1 -0
  49. package/lib/browser-only/frontend-only-application-module.js +115 -0
  50. package/lib/browser-only/frontend-only-application-module.js.map +1 -0
  51. package/lib/browser-only/i18n/i18n-frontend-only-module.d.ts +4 -0
  52. package/lib/browser-only/i18n/i18n-frontend-only-module.d.ts.map +1 -0
  53. package/lib/browser-only/i18n/i18n-frontend-only-module.js +35 -0
  54. package/lib/browser-only/i18n/i18n-frontend-only-module.js.map +1 -0
  55. package/lib/browser-only/logger-frontend-only-module.d.ts +3 -0
  56. package/lib/browser-only/logger-frontend-only-module.d.ts.map +1 -0
  57. package/lib/browser-only/logger-frontend-only-module.js +61 -0
  58. package/lib/browser-only/logger-frontend-only-module.js.map +1 -0
  59. package/lib/browser-only/messaging/frontend-only-service-connection-provider.d.ts +14 -0
  60. package/lib/browser-only/messaging/frontend-only-service-connection-provider.d.ts.map +1 -0
  61. package/lib/browser-only/messaging/frontend-only-service-connection-provider.js +57 -0
  62. package/lib/browser-only/messaging/frontend-only-service-connection-provider.js.map +1 -0
  63. package/lib/browser-only/messaging/messaging-frontend-only-module.d.ts +3 -0
  64. package/lib/browser-only/messaging/messaging-frontend-only-module.d.ts.map +1 -0
  65. package/lib/browser-only/messaging/messaging-frontend-only-module.js +48 -0
  66. package/lib/browser-only/messaging/messaging-frontend-only-module.js.map +1 -0
  67. package/lib/browser-only/preload/frontend-only-preload-module.d.ts +4 -0
  68. package/lib/browser-only/preload/frontend-only-preload-module.d.ts.map +1 -0
  69. package/lib/browser-only/preload/frontend-only-preload-module.js +52 -0
  70. package/lib/browser-only/preload/frontend-only-preload-module.js.map +1 -0
  71. package/lib/common/application-protocol.d.ts +1 -0
  72. package/lib/common/application-protocol.d.ts.map +1 -1
  73. package/lib/common/disposable.d.ts +9 -0
  74. package/lib/common/disposable.d.ts.map +1 -1
  75. package/lib/common/disposable.js +26 -1
  76. package/lib/common/disposable.js.map +1 -1
  77. package/lib/{node → common}/file-uri.d.ts +1 -1
  78. package/lib/common/file-uri.d.ts.map +1 -0
  79. package/lib/{node → common}/file-uri.js +2 -2
  80. package/lib/common/file-uri.js.map +1 -0
  81. package/lib/common/menu/menu-model-registry.d.ts +2 -2
  82. package/lib/common/menu/menu-model-registry.d.ts.map +1 -1
  83. package/lib/common/menu/menu-model-registry.js +16 -2
  84. package/lib/common/menu/menu-model-registry.js.map +1 -1
  85. package/lib/common/menu/menu.spec.js +28 -1
  86. package/lib/common/menu/menu.spec.js.map +1 -1
  87. package/lib/common/message-rpc/msg-pack-extension-manager.d.ts +1 -1
  88. package/lib/common/message-rpc/msg-pack-extension-manager.js +1 -1
  89. package/lib/common/message-rpc/rpc-protocol.d.ts +3 -1
  90. package/lib/common/message-rpc/rpc-protocol.d.ts.map +1 -1
  91. package/lib/common/message-rpc/rpc-protocol.js +19 -1
  92. package/lib/common/message-rpc/rpc-protocol.js.map +1 -1
  93. package/lib/common/messaging/proxy-factory.d.ts.map +1 -1
  94. package/lib/common/messaging/proxy-factory.js +1 -8
  95. package/lib/common/messaging/proxy-factory.js.map +1 -1
  96. package/lib/common/quick-pick-service.d.ts +1 -1
  97. package/lib/common/quick-pick-service.d.ts.map +1 -1
  98. package/lib/common/uuid.d.ts +6 -0
  99. package/lib/common/uuid.d.ts.map +1 -1
  100. package/lib/common/uuid.js +13 -1
  101. package/lib/common/uuid.js.map +1 -1
  102. package/lib/electron-main/electron-main-application.js +1 -1
  103. package/lib/electron-main/electron-main-application.js.map +1 -1
  104. package/lib/electron-main/theia-electron-window.js +1 -1
  105. package/lib/electron-main/theia-electron-window.js.map +1 -1
  106. package/lib/node/application-server.d.ts +1 -0
  107. package/lib/node/application-server.d.ts.map +1 -1
  108. package/lib/node/application-server.js +7 -1
  109. package/lib/node/application-server.js.map +1 -1
  110. package/lib/node/env-variables/env-variables-server.js +1 -1
  111. package/lib/node/env-variables/env-variables-server.js.map +1 -1
  112. package/lib/node/file-uri.spec.js +1 -1
  113. package/lib/node/file-uri.spec.js.map +1 -1
  114. package/lib/node/index.d.ts +1 -1
  115. package/lib/node/index.d.ts.map +1 -1
  116. package/lib/node/index.js +1 -1
  117. package/lib/node/index.js.map +1 -1
  118. package/package.json +10 -6
  119. package/src/browser/browser.ts +6 -1
  120. package/src/browser/common-frontend-contribution.ts +3 -3
  121. package/src/browser/frontend-application-module.ts +2 -1
  122. package/src/browser/style/select-component.css +12 -13
  123. package/src/browser/tree/index.ts +1 -0
  124. package/src/browser/tree/tree-preference.ts +50 -0
  125. package/src/browser/tree/tree-widget.tsx +24 -5
  126. package/src/browser/tree/tree.ts +2 -1
  127. package/src/browser/widget-manager.ts +25 -0
  128. package/src/browser/widgets/select-component.tsx +1 -0
  129. package/src/browser-only/frontend-only-application-module.ts +115 -0
  130. package/src/browser-only/i18n/i18n-frontend-only-module.ts +37 -0
  131. package/src/browser-only/logger-frontend-only-module.ts +63 -0
  132. package/src/browser-only/messaging/frontend-only-service-connection-provider.ts +39 -0
  133. package/src/browser-only/messaging/messaging-frontend-only-module.ts +42 -0
  134. package/src/browser-only/preload/frontend-only-preload-module.ts +49 -0
  135. package/src/common/application-protocol.ts +1 -0
  136. package/src/common/disposable.ts +25 -0
  137. package/src/{node → common}/file-uri.ts +2 -2
  138. package/src/common/menu/menu-model-registry.ts +22 -5
  139. package/src/common/menu/menu.spec.ts +30 -2
  140. package/src/common/message-rpc/msg-pack-extension-manager.ts +1 -1
  141. package/src/common/message-rpc/rpc-protocol.ts +22 -2
  142. package/src/common/messaging/proxy-factory.ts +1 -8
  143. package/src/common/quick-pick-service.ts +1 -1
  144. package/src/common/uuid.ts +13 -0
  145. package/src/electron-main/electron-main-application.ts +1 -1
  146. package/src/electron-main/theia-electron-window.ts +1 -1
  147. package/src/node/application-server.ts +8 -1
  148. package/src/node/env-variables/env-variables-server.ts +1 -1
  149. package/src/node/file-uri.spec.ts +1 -1
  150. package/src/node/index.ts +1 -1
  151. package/lib/node/file-uri.d.ts.map +0 -1
  152. package/lib/node/file-uri.js.map +0 -1
@@ -0,0 +1,37 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 EclipseSource and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { ContainerModule } from 'inversify';
18
+ import { AsyncLocalizationProvider, LanguageInfo, Localization } from '../../common/i18n/localization';
19
+ import { LanguageQuickPickService } from '../../browser/i18n/language-quick-pick-service';
20
+
21
+ export default new ContainerModule(bind => {
22
+ const i18nMock: AsyncLocalizationProvider = {
23
+ getCurrentLanguage: async (): Promise<string> => 'en',
24
+ setCurrentLanguage: async (_languageId: string): Promise<void> => {
25
+
26
+ },
27
+ getAvailableLanguages: async (): Promise<LanguageInfo[]> =>
28
+ []
29
+ ,
30
+ loadLocalization: async (_languageId: string): Promise<Localization> => ({
31
+ translations: {},
32
+ languageId: 'en'
33
+ })
34
+ };
35
+ bind(AsyncLocalizationProvider).toConstantValue(i18nMock);
36
+ bind(LanguageQuickPickService).toSelf().inSingletonScope();
37
+ });
@@ -0,0 +1,63 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 EclipseSource and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { ContainerModule, Container } from 'inversify';
18
+ import { ILoggerServer, ILoggerClient, LogLevel, ConsoleLogger } from '../common/logger-protocol';
19
+ import { ILogger, Logger, LoggerFactory, LoggerName } from '../common/logger';
20
+
21
+ // is loaded directly after the regular logger frontend module
22
+ export const loggerFrontendOnlyModule = new ContainerModule((bind, unbind, isBound, rebind) => {
23
+ const logger: ILoggerServer = {
24
+ setLogLevel: async (_name: string, _logLevel: number): Promise<void> => { },
25
+ getLogLevel: async (_name: string): Promise<number> => LogLevel.INFO,
26
+ log: async (name: string, logLevel: number, message: string, params: unknown[]): Promise<void> => {
27
+ ConsoleLogger.log(name, logLevel, message, params);
28
+
29
+ },
30
+ child: async (_name: string): Promise<void> => { },
31
+ dispose: (): void => {
32
+ },
33
+ setClient: (_client: ILoggerClient | undefined): void => {
34
+ }
35
+ };
36
+ if (isBound(ILoggerServer)) {
37
+ rebind(ILoggerServer).toConstantValue(logger);
38
+ } else {
39
+ bind(ILoggerServer).toConstantValue(logger);
40
+ }
41
+
42
+ if (isBound(ILoggerServer)) {
43
+ rebind(LoggerFactory).toFactory(ctx =>
44
+ (name: string) => {
45
+ const child = new Container({ defaultScope: 'Singleton' });
46
+ child.parent = ctx.container;
47
+ child.bind(ILogger).to(Logger).inTransientScope();
48
+ child.bind(LoggerName).toConstantValue(name);
49
+ return child.get(ILogger);
50
+ }
51
+ );
52
+ } else {
53
+ bind(LoggerFactory).toFactory(ctx =>
54
+ (name: string) => {
55
+ const child = new Container({ defaultScope: 'Singleton' });
56
+ child.parent = ctx.container;
57
+ child.bind(ILogger).to(Logger).inTransientScope();
58
+ child.bind(LoggerName).toConstantValue(name);
59
+ return child.get(ILogger);
60
+ }
61
+ );
62
+ }
63
+ });
@@ -0,0 +1,39 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 EclipseSource and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+ import { Event, RpcProxy, Channel, RpcProxyFactory, Emitter } from '../../common';
17
+ import { injectable } from 'inversify';
18
+ import { ServiceConnectionProvider } from '../../browser/messaging/service-connection-provider';
19
+ import { ConnectionSource } from '../../browser/messaging/connection-source';
20
+
21
+ @injectable()
22
+ export class FrontendOnlyConnectionSource implements ConnectionSource {
23
+ onConnectionDidOpen = new Emitter<Channel>().event;
24
+ }
25
+
26
+ @injectable()
27
+ export class FrontendOnlyServiceConnectionProvider extends ServiceConnectionProvider {
28
+ onSocketDidOpen = Event.None;
29
+ onSocketDidClose = Event.None;
30
+ onIncomingMessageActivity = Event.None;
31
+ override createProxy<T extends object>(path: unknown, target?: unknown): RpcProxy<T> {
32
+ console.debug(`[Frontend-Only Fallback] Created proxy connection for ${path}`);
33
+ const factory = target instanceof RpcProxyFactory ? target : new RpcProxyFactory<T>(target);
34
+ return factory.createProxy();
35
+ }
36
+ override listen(path: string, handler: ServiceConnectionProvider.ConnectionHandler, reconnect: boolean): void {
37
+ console.debug('[Frontend-Only Fallback] Listen to websocket connection requested');
38
+ }
39
+ }
@@ -0,0 +1,42 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 EclipseSource and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+ import { ContainerModule } from 'inversify';
17
+ import { WebSocketConnectionSource } from '../../browser/messaging/ws-connection-source';
18
+ import { FrontendOnlyConnectionSource, FrontendOnlyServiceConnectionProvider } from './frontend-only-service-connection-provider';
19
+ import { ConnectionSource } from '../../browser/messaging/connection-source';
20
+ import { LocalConnectionProvider, RemoteConnectionProvider } from '../../browser/messaging/service-connection-provider';
21
+
22
+ // is loaded directly after the regular message frontend module
23
+ export const messagingFrontendOnlyModule = new ContainerModule((bind, unbind, isBound, rebind) => {
24
+ unbind(WebSocketConnectionSource);
25
+ bind(FrontendOnlyConnectionSource).toSelf().inSingletonScope();
26
+ if (isBound(ConnectionSource)) {
27
+ rebind(ConnectionSource).toService(FrontendOnlyConnectionSource);
28
+ } else {
29
+ bind(ConnectionSource).toService(FrontendOnlyConnectionSource);
30
+ }
31
+ bind(FrontendOnlyServiceConnectionProvider).toSelf().inSingletonScope();
32
+ if (isBound(LocalConnectionProvider)) {
33
+ rebind(LocalConnectionProvider).toService(FrontendOnlyServiceConnectionProvider);
34
+ } else {
35
+ bind(LocalConnectionProvider).toService(FrontendOnlyServiceConnectionProvider);
36
+ }
37
+ if (isBound(RemoteConnectionProvider)) {
38
+ rebind(RemoteConnectionProvider).toService(FrontendOnlyServiceConnectionProvider);
39
+ } else {
40
+ bind(RemoteConnectionProvider).toService(FrontendOnlyServiceConnectionProvider);
41
+ }
42
+ });
@@ -0,0 +1,49 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { ContainerModule } from 'inversify';
18
+ import { LocalizationServer } from '../../common/i18n/localization-server';
19
+ import { OS, OSBackendProvider } from '../../common/os';
20
+ import { Localization } from '../../common/i18n/localization';
21
+
22
+ // loaded after regular preload module
23
+ export default new ContainerModule((bind, unbind, isBound, rebind) => {
24
+ const frontendOnlyLocalizationServer: LocalizationServer = {
25
+ loadLocalization: async (languageId: string): Promise<Localization> => ({ translations: {}, languageId })
26
+ };
27
+ if (isBound(LocalizationServer)) {
28
+ rebind(LocalizationServer).toConstantValue(frontendOnlyLocalizationServer);
29
+ } else {
30
+ bind(LocalizationServer).toConstantValue(frontendOnlyLocalizationServer);
31
+ }
32
+
33
+ const frontendOnlyOSBackendProvider: OSBackendProvider = {
34
+ getBackendOS: async (): Promise<OS.Type> => {
35
+ if (window.navigator.platform.startsWith('Win')) {
36
+ return OS.Type.Windows;
37
+ } else if (window.navigator.platform.startsWith('Mac')) {
38
+ return OS.Type.OSX;
39
+ } else {
40
+ return OS.Type.Linux;
41
+ }
42
+ }
43
+ };
44
+ if (isBound(OSBackendProvider)) {
45
+ rebind(OSBackendProvider).toConstantValue(frontendOnlyOSBackendProvider);
46
+ } else {
47
+ bind(OSBackendProvider).toConstantValue(frontendOnlyOSBackendProvider);
48
+ }
49
+ });
@@ -23,6 +23,7 @@ export const ApplicationServer = Symbol('ApplicationServer');
23
23
  export interface ApplicationServer {
24
24
  getExtensionsInfos(): Promise<ExtensionInfo[]>;
25
25
  getApplicationInfo(): Promise<ApplicationInfo | undefined>;
26
+ getApplicationRoot(): Promise<string>;
26
27
  /**
27
28
  * @deprecated since 1.25.0. Use `OS.backend.type()` instead.
28
29
  */
@@ -133,3 +133,28 @@ export function disposableTimeout(...args: Parameters<typeof setTimeout>): Dispo
133
133
  const handle = setTimeout(...args);
134
134
  return { dispose: () => clearTimeout(handle) };
135
135
  }
136
+
137
+ /**
138
+ * Wrapper for a {@link Disposable} that is not available immediately.
139
+ */
140
+ export class DisposableWrapper implements Disposable {
141
+
142
+ private disposed = false;
143
+ private disposable: Disposable | undefined = undefined;
144
+
145
+ set(disposable: Disposable): void {
146
+ if (this.disposed) {
147
+ disposable.dispose();
148
+ } else {
149
+ this.disposable = disposable;
150
+ }
151
+ }
152
+
153
+ dispose(): void {
154
+ this.disposed = true;
155
+ if (this.disposable) {
156
+ this.disposable.dispose();
157
+ this.disposable = undefined;
158
+ }
159
+ }
160
+ }
@@ -15,8 +15,8 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import { URI as Uri } from 'vscode-uri';
18
- import URI from '../common/uri';
19
- import { isWindows } from '../common/os';
18
+ import URI from './uri';
19
+ import { isWindows } from './os';
20
20
 
21
21
  export namespace FileUri {
22
22
 
@@ -14,13 +14,13 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { injectable, inject, named } from 'inversify';
18
- import { Disposable } from '../disposable';
19
- import { CommandRegistry, Command } from '../command';
17
+ import { inject, injectable, named } from 'inversify';
18
+ import { Command, CommandRegistry } from '../command';
20
19
  import { ContributionProvider } from '../contribution-provider';
21
- import { CompositeMenuNode, CompositeMenuNodeWrapper } from './composite-menu-node';
22
- import { CompoundMenuNode, MenuAction, MenuNode, MenuPath, MutableCompoundMenuNode, SubMenuOptions } from './menu-types';
20
+ import { Disposable } from '../disposable';
23
21
  import { ActionMenuNode } from './action-menu-node';
22
+ import { CompositeMenuNode, CompositeMenuNodeWrapper } from './composite-menu-node';
23
+ import { CompoundMenuNode, MenuAction, MenuNode, MenuNodeMetadata, MenuPath, MutableCompoundMenuNode, SubMenuOptions } from './menu-types';
24
24
 
25
25
  export const MenuContribution = Symbol('MenuContribution');
26
26
 
@@ -157,6 +157,23 @@ export class MenuModelRegistry {
157
157
  linkSubmenu(parentPath: MenuPath | string, childId: string | MenuPath, options?: SubMenuOptions, group?: string): Disposable {
158
158
  const child = this.getMenuNode(childId);
159
159
  const parent = this.getMenuNode(parentPath, group);
160
+
161
+ const isRecursive = (node: MenuNodeMetadata, childNode: MenuNodeMetadata): boolean => {
162
+ if (node.id === childNode.id) {
163
+ return true;
164
+ }
165
+ if (node.parent) {
166
+ return isRecursive(node.parent, childNode);
167
+ }
168
+ return false;
169
+ };
170
+
171
+ // check for menu contribution recursion
172
+ if (isRecursive(parent, child)) {
173
+ console.warn(`Recursive menu contribution detected: ${child.id} is already in hierarchy of ${parent.id}.`);
174
+ return Disposable.NULL;
175
+ }
176
+
160
177
  const wrapper = new CompositeMenuNodeWrapper(child, parent, options);
161
178
  return parent.addNode(wrapper);
162
179
  }
@@ -14,10 +14,10 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { CommandContribution, CommandRegistry } from '../command';
18
- import { MenuContribution, MenuModelRegistry } from './menu-model-registry';
19
17
  import * as chai from 'chai';
18
+ import { CommandContribution, CommandRegistry } from '../command';
20
19
  import { CompositeMenuNode } from './composite-menu-node';
20
+ import { MenuContribution, MenuModelRegistry } from './menu-model-registry';
21
21
 
22
22
  const expect = chai.expect;
23
23
 
@@ -61,6 +61,25 @@ describe('menu-model-registry', () => {
61
61
  expect(openGroup.children.length).equals(2);
62
62
  expect(openGroup.label).undefined;
63
63
  });
64
+
65
+ it('Should not allow to register cyclic menus.', () => {
66
+ const fileMenu = ['main', 'File'];
67
+ const fileOpenMenu = [...fileMenu, '0_open'];
68
+ const fileCloseMenu = [...fileMenu, '1_close'];
69
+ const service = createMenuRegistry({
70
+ registerMenus(menuRegistry: MenuModelRegistry): void {
71
+ menuRegistry.registerSubmenu(fileMenu, 'File');
72
+ // open menu should not be added to open menu
73
+ menuRegistry.linkSubmenu(fileOpenMenu, fileOpenMenu);
74
+ // close menu should be added
75
+ menuRegistry.linkSubmenu(fileOpenMenu, fileCloseMenu);
76
+ }
77
+ }, {
78
+ registerCommands(reg: CommandRegistry): void { }
79
+ });
80
+ const all = service.getMenu() as CompositeMenuNode;
81
+ expect(menuStructureToString(all.children[0] as CompositeMenuNode)).equals('File(0_open(1_close),1_close())');
82
+ });
64
83
  });
65
84
  });
66
85
 
@@ -71,3 +90,12 @@ function createMenuRegistry(menuContrib: MenuContribution, commandContrib: Comma
71
90
  menuReg.onStart();
72
91
  return menuReg;
73
92
  }
93
+
94
+ function menuStructureToString(node: CompositeMenuNode): string {
95
+ return node.children.map(c => {
96
+ if (c instanceof CompositeMenuNode) {
97
+ return `${c.id}(${menuStructureToString(c)})`;
98
+ }
99
+ return c.id;
100
+ }).join(',');
101
+ }
@@ -21,7 +21,7 @@ import { addExtension } from 'msgpackr';
21
21
  * required for the default RPC communication. MsgPackR extensions
22
22
  * are installed globally on both ends of the communication channel.
23
23
  * (frontend-backend, pluginExt-pluginMain).
24
- * Is implemented as singleton as it is also used in plugin child processes which have no access to inversify.
24
+ * Is implemented as singleton as it is also used in plugin child processes which have no access to inversify.
25
25
  */
26
26
  export class MsgPackExtensionManager {
27
27
  private static readonly INSTANCE = new MsgPackExtensionManager();
@@ -16,7 +16,7 @@
16
16
  /* eslint-disable @typescript-eslint/no-explicit-any */
17
17
 
18
18
  import { CancellationToken, CancellationTokenSource } from '../cancellation';
19
- import { Disposable, DisposableCollection } from '../disposable';
19
+ import { DisposableWrapper, Disposable, DisposableCollection } from '../disposable';
20
20
  import { Emitter, Event } from '../event';
21
21
  import { Deferred } from '../promise-util';
22
22
  import { Channel } from './channel';
@@ -57,6 +57,7 @@ export class RpcProtocol {
57
57
  static readonly CANCELLATION_TOKEN_KEY = 'add.cancellation.token';
58
58
 
59
59
  protected readonly pendingRequests: Map<number, Deferred<any>> = new Map();
60
+ protected readonly pendingRequestCancellationEventListeners: Map<number, DisposableWrapper> = new Map();
60
61
 
61
62
  protected nextMessageId: number = 0;
62
63
 
@@ -80,6 +81,8 @@ export class RpcProtocol {
80
81
  channel.onClose(event => {
81
82
  this.pendingRequests.forEach(pending => pending.reject(new Error(event.reason)));
82
83
  this.pendingRequests.clear();
84
+ this.pendingRequestCancellationEventListeners.forEach(disposable => disposable.dispose());
85
+ this.pendingRequestCancellationEventListeners.clear();
83
86
  this.toDispose.dispose();
84
87
  });
85
88
  this.toDispose.push(channel.onMessage(readBuffer => this.handleMessage(this.decoder.parse(readBuffer()))));
@@ -131,6 +134,7 @@ export class RpcProtocol {
131
134
  } else {
132
135
  throw new Error(`No reply handler for reply with id: ${id}`);
133
136
  }
137
+ this.disposeCancellationEventListener(id);
134
138
  }
135
139
 
136
140
  protected handleReplyErr(id: number, error: any): void {
@@ -141,6 +145,15 @@ export class RpcProtocol {
141
145
  } else {
142
146
  throw new Error(`No reply handler for error reply with id: ${id}`);
143
147
  }
148
+ this.disposeCancellationEventListener(id);
149
+ }
150
+
151
+ protected disposeCancellationEventListener(id: number): void {
152
+ const toDispose = this.pendingRequestCancellationEventListeners.get(id);
153
+ if (toDispose) {
154
+ this.pendingRequestCancellationEventListeners.delete(id);
155
+ toDispose.dispose();
156
+ }
144
157
  }
145
158
 
146
159
  sendRequest<T>(method: string, args: any[]): Promise<T> {
@@ -157,6 +170,10 @@ export class RpcProtocol {
157
170
 
158
171
  this.pendingRequests.set(id, reply);
159
172
 
173
+ // register disposable before output.commit() even when not available yet
174
+ const disposableWrapper = new DisposableWrapper();
175
+ this.pendingRequestCancellationEventListeners.set(id, disposableWrapper);
176
+
160
177
  const output = this.channel.getWriteBuffer();
161
178
  this.encoder.request(output, id, method, args);
162
179
  output.commit();
@@ -164,7 +181,10 @@ export class RpcProtocol {
164
181
  if (cancellationToken?.isCancellationRequested) {
165
182
  this.sendCancel(id);
166
183
  } else {
167
- cancellationToken?.onCancellationRequested(() => this.sendCancel(id));
184
+ const disposable = cancellationToken?.onCancellationRequested(() => this.sendCancel(id));
185
+ if (disposable) {
186
+ disposableWrapper.set(disposable);
187
+ }
168
188
  }
169
189
 
170
190
  return reply.promise;
@@ -168,14 +168,7 @@ export class RpcProxyFactory<T extends object> implements ProxyHandler<T> {
168
168
  throw new Error(`no target was set to handle ${method}`);
169
169
  }
170
170
  } catch (error) {
171
- const e = this.serializeError(error);
172
- if (e instanceof ResponseError) {
173
- throw e;
174
- }
175
- const reason = e.message || '';
176
- const stack = e.stack || '';
177
- console.error(`Request ${method} failed with error: ${reason}`, stack);
178
- throw e;
171
+ throw this.serializeError(error);
179
172
  }
180
173
  }
181
174
 
@@ -131,7 +131,7 @@ export namespace QuickInputButton {
131
131
  }
132
132
 
133
133
  export interface QuickInputButtonHandle extends QuickInputButton {
134
- index: number; // index of where they are in buttons array if QuickInputButton or -1 if QuickInputButtons.Back
134
+ handle: number; // index of where the button is in buttons array if QuickInputButton or -1 if QuickInputButtons.Back
135
135
  }
136
136
 
137
137
  export enum QuickInputHideReason {
@@ -21,6 +21,8 @@
21
21
 
22
22
  // based on https://github.com/microsoft/vscode/blob/1.72.2/src/vs/base/common/uuid.ts
23
23
 
24
+ import { v5 } from 'uuid';
25
+
24
26
  const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
25
27
 
26
28
  export function isUUID(value: string): boolean {
@@ -97,3 +99,14 @@ export const generateUuid = (function (): () => string {
97
99
  return result;
98
100
  };
99
101
  })();
102
+
103
+ const NAMESPACE = '4c90ee4f-d952-44b1-83ca-f04121ab8e05';
104
+ /**
105
+ * This function will hash the given value using SHA1. The result will be a uuid.
106
+ * @param value the string to hash
107
+ * @returns a uuid
108
+ */
109
+ export function hashValue(value: string): string {
110
+ // as opposed to v4, v5 is deterministic and uses SHA1 hashing
111
+ return v5(value, NAMESPACE);
112
+ }
@@ -24,7 +24,7 @@ import { existsSync, mkdirSync } from 'fs-extra';
24
24
  import { fork, ForkOptions } from 'child_process';
25
25
  import { DefaultTheme, FrontendApplicationConfig } from '@theia/application-package/lib/application-props';
26
26
  import URI from '../common/uri';
27
- import { FileUri } from '../node/file-uri';
27
+ import { FileUri } from '../common/file-uri';
28
28
  import { Deferred } from '../common/promise-util';
29
29
  import { MaybePromise } from '../common/types';
30
30
  import { ContributionProvider } from '../common/contribution-provider';
@@ -22,7 +22,7 @@ import { ElectronMainApplicationGlobals } from './electron-main-constants';
22
22
  import { DisposableCollection, Emitter, Event } from '../common';
23
23
  import { createDisposableListener } from './event-utils';
24
24
  import { URI } from '../common/uri';
25
- import { FileUri } from '../node/file-uri';
25
+ import { FileUri } from '../common/file-uri';
26
26
  import { TheiaRendererAPI } from './electron-api-main';
27
27
 
28
28
  /**
@@ -37,11 +37,18 @@ export class ApplicationServerImpl implements ApplicationServer {
37
37
  const name = pck.name;
38
38
  const version = pck.version;
39
39
 
40
- return Promise.resolve({ name, version });
40
+ return Promise.resolve({
41
+ name,
42
+ version
43
+ });
41
44
  }
42
45
  return Promise.resolve(undefined);
43
46
  }
44
47
 
48
+ getApplicationRoot(): Promise<string> {
49
+ return Promise.resolve(this.applicationPackage.projectPath);
50
+ }
51
+
45
52
  async getBackendOS(): Promise<OS.Type> {
46
53
  return OS.type();
47
54
  }
@@ -21,7 +21,7 @@ import * as drivelist from 'drivelist';
21
21
  import { pathExists, mkdir } from 'fs-extra';
22
22
  import { EnvVariable, EnvVariablesServer } from '../../common/env-variables';
23
23
  import { isWindows } from '../../common/os';
24
- import { FileUri } from '../file-uri';
24
+ import { FileUri } from '../../common/file-uri';
25
25
 
26
26
  @injectable()
27
27
  export class EnvVariablesServerImpl implements EnvVariablesServer {
@@ -17,7 +17,7 @@
17
17
  import * as os from 'os';
18
18
  import * as path from 'path';
19
19
  import * as chai from 'chai';
20
- import { FileUri } from './file-uri';
20
+ import { FileUri } from '../common/file-uri';
21
21
  import { isWindows } from '../common/os';
22
22
 
23
23
  const expect = chai.expect;
package/src/node/index.ts CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  export * from './backend-application';
18
18
  export * from './debug';
19
- export * from './file-uri';
19
+ export * from '../common/file-uri';
20
20
  export * from './messaging';
21
21
  export * from './cli';
22
22
  export { FileSystemLocking } from './filesystem-locking';
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-uri.d.ts","sourceRoot":"","sources":["../../src/node/file-uri.ts"],"names":[],"mappings":"AAiBA,OAAO,GAAG,MAAM,eAAe,CAAC;AAGhC,yBAAiB,OAAO,CAAC;IAIrB;;;OAGG;IACH,SAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,CAE3C;IAED;;;;OAIG;IACH,SAAgB,MAAM,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,MAAM,CAqBhD;CAEJ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-uri.js","sourceRoot":"","sources":["../../src/node/file-uri.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAEhF,2CAAwC;AACxC,uCAAgC;AAChC,qCAAyC;AAEzC,IAAiB,OAAO,CAwCvB;AAxCD,WAAiB,OAAO;IAEpB,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;IAE3C;;;OAGG;IACH,SAAgB,MAAM,CAAC,OAAe;QAClC,OAAO,IAAI,aAAG,CAAC,gBAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACtC,CAAC;IAFe,cAAM,SAErB,CAAA;IAED;;;;OAIG;IACH,SAAgB,MAAM,CAAC,GAAiB;QACpC,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YACzB,OAAO,MAAM,CAAC,IAAI,aAAG,CAAC,GAAG,CAAC,CAAC,CAAC;SAC/B;aAAM;YACH;;;;;;eAMG;YACH,8DAA8D;YAC9D,MAAM,mBAAmB,GAAI,GAAW,CAAC,OAAO,CAAC,MAAM,CAAC;YACxD,IAAI,cAAS,EAAE;gBACX,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;gBACvE,IAAI,kBAAkB,EAAE;oBACpB,OAAO,mBAAmB,GAAG,IAAI,CAAC;iBACrC;aACJ;YACD,OAAO,mBAAmB,CAAC;SAC9B;IACL,CAAC;IArBe,cAAM,SAqBrB,CAAA;AAEL,CAAC,EAxCgB,OAAO,GAAP,eAAO,KAAP,eAAO,QAwCvB"}