@theia/core 1.18.0 → 1.21.0-next.12

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 (294) hide show
  1. package/README.md +3 -2
  2. package/lib/browser/about-dialog.d.ts.map +1 -1
  3. package/lib/browser/about-dialog.js +1 -1
  4. package/lib/browser/about-dialog.js.map +1 -1
  5. package/lib/browser/authentication-service.d.ts.map +1 -1
  6. package/lib/browser/authentication-service.js +1 -1
  7. package/lib/browser/authentication-service.js.map +1 -1
  8. package/lib/browser/color-registry.d.ts +3 -69
  9. package/lib/browser/color-registry.d.ts.map +1 -1
  10. package/lib/browser/color-registry.js +13 -27
  11. package/lib/browser/color-registry.js.map +1 -1
  12. package/lib/browser/common-frontend-contribution.d.ts +7 -13
  13. package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
  14. package/lib/browser/common-frontend-contribution.js +213 -250
  15. package/lib/browser/common-frontend-contribution.js.map +1 -1
  16. package/lib/browser/core-preferences.d.ts +1 -0
  17. package/lib/browser/core-preferences.d.ts.map +1 -1
  18. package/lib/browser/core-preferences.js +29 -19
  19. package/lib/browser/core-preferences.js.map +1 -1
  20. package/lib/browser/dialogs.d.ts +6 -0
  21. package/lib/browser/dialogs.d.ts.map +1 -1
  22. package/lib/browser/dialogs.js +10 -3
  23. package/lib/browser/dialogs.js.map +1 -1
  24. package/lib/browser/frontend-application-module.d.ts.map +1 -1
  25. package/lib/browser/frontend-application-module.js +9 -5
  26. package/lib/browser/frontend-application-module.js.map +1 -1
  27. package/lib/browser/frontend-application.d.ts +6 -0
  28. package/lib/browser/frontend-application.d.ts.map +1 -1
  29. package/lib/browser/frontend-application.js +13 -0
  30. package/lib/browser/frontend-application.js.map +1 -1
  31. package/lib/browser/index.d.ts +1 -0
  32. package/lib/browser/index.d.ts.map +1 -1
  33. package/lib/browser/index.js +1 -0
  34. package/lib/browser/index.js.map +1 -1
  35. package/lib/browser/keyboard/browser-keyboard-frontend-contribution.d.ts.map +1 -1
  36. package/lib/browser/keyboard/browser-keyboard-frontend-contribution.js +16 -11
  37. package/lib/browser/keyboard/browser-keyboard-frontend-contribution.js.map +1 -1
  38. package/lib/browser/keyboard/browser-keyboard-layout-provider.d.ts +1 -1
  39. package/lib/browser/keyboard/browser-keyboard-layout-provider.d.ts.map +1 -1
  40. package/lib/browser/keyboard/browser-keyboard-layout-provider.spec.js +6 -4
  41. package/lib/browser/keyboard/browser-keyboard-layout-provider.spec.js.map +1 -1
  42. package/lib/browser/keyboard/keys.d.ts +2 -251
  43. package/lib/browser/keyboard/keys.d.ts.map +1 -1
  44. package/lib/browser/keyboard/keys.js +12 -614
  45. package/lib/browser/keyboard/keys.js.map +1 -1
  46. package/lib/browser/menu/browser-context-menu-renderer.d.ts +1 -1
  47. package/lib/browser/menu/browser-context-menu-renderer.d.ts.map +1 -1
  48. package/lib/browser/menu/browser-menu-plugin.d.ts +3 -0
  49. package/lib/browser/menu/browser-menu-plugin.d.ts.map +1 -1
  50. package/lib/browser/menu/browser-menu-plugin.js +24 -4
  51. package/lib/browser/menu/browser-menu-plugin.js.map +1 -1
  52. package/lib/browser/messaging/ws-connection-provider.d.ts +3 -3
  53. package/lib/browser/messaging/ws-connection-provider.d.ts.map +1 -1
  54. package/lib/browser/messaging/ws-connection-provider.js +14 -4
  55. package/lib/browser/messaging/ws-connection-provider.js.map +1 -1
  56. package/lib/browser/{nls.d.ts → nls-loader.d.ts} +1 -6
  57. package/lib/browser/nls-loader.d.ts.map +1 -0
  58. package/lib/browser/nls-loader.js +29 -0
  59. package/lib/browser/nls-loader.js.map +1 -0
  60. package/lib/browser/preferences/preference-provider.d.ts +0 -2
  61. package/lib/browser/preferences/preference-provider.d.ts.map +1 -1
  62. package/lib/browser/preferences/preference-provider.js +1 -5
  63. package/lib/browser/preferences/preference-provider.js.map +1 -1
  64. package/lib/browser/preferences/preference-service.spec.js +0 -3
  65. package/lib/browser/preferences/preference-service.spec.js.map +1 -1
  66. package/lib/browser/progress-status-bar-item.d.ts +1 -2
  67. package/lib/browser/progress-status-bar-item.d.ts.map +1 -1
  68. package/lib/browser/progress-status-bar-item.js.map +1 -1
  69. package/lib/browser/quick-input/quick-command-frontend-contribution.d.ts.map +1 -1
  70. package/lib/browser/quick-input/quick-command-frontend-contribution.js +2 -1
  71. package/lib/browser/quick-input/quick-command-frontend-contribution.js.map +1 -1
  72. package/lib/browser/quick-input/quick-command-service.d.ts.map +1 -1
  73. package/lib/browser/quick-input/quick-command-service.js +2 -2
  74. package/lib/browser/quick-input/quick-command-service.js.map +1 -1
  75. package/lib/browser/quick-input/quick-input-service.d.ts +1 -201
  76. package/lib/browser/quick-input/quick-input-service.d.ts.map +1 -1
  77. package/lib/browser/quick-input/quick-input-service.js +11 -93
  78. package/lib/browser/quick-input/quick-input-service.js.map +1 -1
  79. package/lib/browser/quick-input/quick-view-service.d.ts +1 -2
  80. package/lib/browser/quick-input/quick-view-service.d.ts.map +1 -1
  81. package/lib/browser/quick-input/quick-view-service.js.map +1 -1
  82. package/lib/browser/shell/application-shell.d.ts +10 -8
  83. package/lib/browser/shell/application-shell.d.ts.map +1 -1
  84. package/lib/browser/shell/application-shell.js +11 -19
  85. package/lib/browser/shell/application-shell.js.map +1 -1
  86. package/lib/browser/shell/current-widget-command-adapter.d.ts +39 -0
  87. package/lib/browser/shell/current-widget-command-adapter.d.ts.map +1 -0
  88. package/lib/browser/shell/current-widget-command-adapter.js +42 -0
  89. package/lib/browser/shell/current-widget-command-adapter.js.map +1 -0
  90. package/lib/browser/shell/shell-layout-restorer.d.ts.map +1 -1
  91. package/lib/browser/shell/shell-layout-restorer.js +5 -3
  92. package/lib/browser/shell/shell-layout-restorer.js.map +1 -1
  93. package/lib/browser/shell/tab-bar-decorator.d.ts +1 -1
  94. package/lib/browser/shell/tab-bar-decorator.d.ts.map +1 -1
  95. package/lib/browser/shell/tab-bar-decorator.js.map +1 -1
  96. package/lib/browser/shell/tab-bar-toolbar.d.ts.map +1 -1
  97. package/lib/browser/shell/tab-bar-toolbar.js +2 -1
  98. package/lib/browser/shell/tab-bar-toolbar.js.map +1 -1
  99. package/lib/browser/shell/tab-bars.d.ts +22 -3
  100. package/lib/browser/shell/tab-bars.d.ts.map +1 -1
  101. package/lib/browser/shell/tab-bars.js +129 -10
  102. package/lib/browser/shell/tab-bars.js.map +1 -1
  103. package/lib/browser/storage-service.spec.js +1 -1
  104. package/lib/browser/storage-service.spec.js.map +1 -1
  105. package/lib/browser/theming.d.ts +5 -14
  106. package/lib/browser/theming.d.ts.map +1 -1
  107. package/lib/browser/theming.js +14 -0
  108. package/lib/browser/theming.js.map +1 -1
  109. package/lib/browser/tooltip-service.d.ts +52 -0
  110. package/lib/browser/tooltip-service.d.ts.map +1 -0
  111. package/lib/browser/tooltip-service.js +89 -0
  112. package/lib/browser/tooltip-service.js.map +1 -0
  113. package/lib/browser/tree/tree-model.d.ts.map +1 -1
  114. package/lib/browser/view-container.d.ts +55 -14
  115. package/lib/browser/view-container.d.ts.map +1 -1
  116. package/lib/browser/view-container.js +284 -66
  117. package/lib/browser/view-container.js.map +1 -1
  118. package/lib/browser/window/default-window-service.js +2 -2
  119. package/lib/browser/window/default-window-service.js.map +1 -1
  120. package/lib/browser/window/window-service.d.ts +1 -7
  121. package/lib/browser/window/window-service.d.ts.map +1 -1
  122. package/lib/browser/window/window-service.js +1 -5
  123. package/lib/browser/window/window-service.js.map +1 -1
  124. package/lib/browser/window-contribution.d.ts.map +1 -1
  125. package/lib/browser/window-contribution.js +2 -2
  126. package/lib/browser/window-contribution.js.map +1 -1
  127. package/lib/common/color.d.ts +84 -0
  128. package/lib/common/color.d.ts.map +1 -0
  129. package/lib/common/color.js +44 -0
  130. package/lib/common/color.js.map +1 -0
  131. package/lib/common/command.d.ts +1 -0
  132. package/lib/common/command.d.ts.map +1 -1
  133. package/lib/common/command.js +5 -2
  134. package/lib/common/command.js.map +1 -1
  135. package/lib/common/i18n/localization.d.ts +14 -0
  136. package/lib/common/i18n/localization.d.ts.map +1 -1
  137. package/lib/common/i18n/localization.js +54 -1
  138. package/lib/common/i18n/localization.js.map +1 -1
  139. package/lib/common/index.d.ts +1 -0
  140. package/lib/common/index.d.ts.map +1 -1
  141. package/lib/common/index.js +1 -0
  142. package/lib/common/index.js.map +1 -1
  143. package/lib/common/keys.d.ts +269 -0
  144. package/lib/common/keys.d.ts.map +1 -0
  145. package/lib/common/keys.js +634 -0
  146. package/lib/common/keys.js.map +1 -0
  147. package/lib/common/messaging/abstract-connection-provider.d.ts +1 -1
  148. package/lib/common/messaging/abstract-connection-provider.d.ts.map +1 -1
  149. package/lib/common/messaging/abstract-connection-provider.js +3 -1
  150. package/lib/common/messaging/abstract-connection-provider.js.map +1 -1
  151. package/lib/common/messaging/proxy-factory.js +1 -1
  152. package/lib/common/messaging/proxy-factory.js.map +1 -1
  153. package/lib/common/nls.d.ts +28 -0
  154. package/lib/common/nls.d.ts.map +1 -0
  155. package/lib/common/nls.js +91 -0
  156. package/lib/common/nls.js.map +1 -0
  157. package/lib/common/path.d.ts +6 -0
  158. package/lib/common/path.d.ts.map +1 -1
  159. package/lib/common/path.js +16 -4
  160. package/lib/common/path.js.map +1 -1
  161. package/lib/common/path.spec.js +12 -0
  162. package/lib/common/path.spec.js.map +1 -1
  163. package/lib/common/promise-util.d.ts +5 -2
  164. package/lib/common/promise-util.d.ts.map +1 -1
  165. package/lib/common/promise-util.js +16 -1
  166. package/lib/common/promise-util.js.map +1 -1
  167. package/lib/common/promise-util.spec.d.ts +2 -0
  168. package/lib/common/promise-util.spec.d.ts.map +1 -0
  169. package/lib/common/promise-util.spec.js +42 -0
  170. package/lib/common/promise-util.spec.js.map +1 -0
  171. package/lib/common/quick-pick-service.d.ts +219 -1
  172. package/lib/common/quick-pick-service.d.ts.map +1 -1
  173. package/lib/common/quick-pick-service.js +108 -1
  174. package/lib/common/quick-pick-service.js.map +1 -1
  175. package/lib/common/theme.d.ts +30 -0
  176. package/lib/common/theme.d.ts.map +1 -0
  177. package/lib/common/theme.js +18 -0
  178. package/lib/common/theme.js.map +1 -0
  179. package/lib/common/window.d.ts +29 -0
  180. package/lib/common/window.d.ts.map +1 -0
  181. package/lib/common/window.js +23 -0
  182. package/lib/common/window.js.map +1 -0
  183. package/lib/electron-browser/menu/electron-context-menu-renderer.d.ts +9 -5
  184. package/lib/electron-browser/menu/electron-context-menu-renderer.d.ts.map +1 -1
  185. package/lib/electron-browser/menu/electron-context-menu-renderer.js +40 -15
  186. package/lib/electron-browser/menu/electron-context-menu-renderer.js.map +1 -1
  187. package/lib/electron-browser/menu/electron-main-menu-factory.d.ts +5 -8
  188. package/lib/electron-browser/menu/electron-main-menu-factory.d.ts.map +1 -1
  189. package/lib/electron-browser/menu/electron-main-menu-factory.js +10 -17
  190. package/lib/electron-browser/menu/electron-main-menu-factory.js.map +1 -1
  191. package/lib/electron-browser/menu/electron-menu-contribution.d.ts +15 -7
  192. package/lib/electron-browser/menu/electron-menu-contribution.d.ts.map +1 -1
  193. package/lib/electron-browser/menu/electron-menu-contribution.js +112 -42
  194. package/lib/electron-browser/menu/electron-menu-contribution.js.map +1 -1
  195. package/lib/electron-browser/window/electron-window-preferences.d.ts +1 -0
  196. package/lib/electron-browser/window/electron-window-preferences.d.ts.map +1 -1
  197. package/lib/electron-browser/window/electron-window-preferences.js +12 -1
  198. package/lib/electron-browser/window/electron-window-preferences.js.map +1 -1
  199. package/lib/electron-browser/window/electron-window-service.d.ts +1 -1
  200. package/lib/electron-browser/window/electron-window-service.d.ts.map +1 -1
  201. package/lib/electron-common/electron-main-window-service.d.ts +1 -1
  202. package/lib/electron-common/electron-main-window-service.d.ts.map +1 -1
  203. package/lib/electron-common/electron-main-window-service.js.map +1 -1
  204. package/lib/electron-common/messaging/electron-messages.d.ts +20 -0
  205. package/lib/electron-common/messaging/electron-messages.d.ts.map +1 -0
  206. package/lib/electron-common/messaging/electron-messages.js +23 -0
  207. package/lib/electron-common/messaging/electron-messages.js.map +1 -0
  208. package/lib/electron-main/electron-main-application.d.ts +16 -0
  209. package/lib/electron-main/electron-main-application.d.ts.map +1 -1
  210. package/lib/electron-main/electron-main-application.js +91 -25
  211. package/lib/electron-main/electron-main-application.js.map +1 -1
  212. package/lib/electron-main/electron-main-window-service-impl.d.ts +1 -1
  213. package/lib/electron-main/electron-main-window-service-impl.d.ts.map +1 -1
  214. package/lib/electron-main/electron-main-window-service-impl.js.map +1 -1
  215. package/lib/electron-main/messaging/electron-messaging-contribution.d.ts +1 -1
  216. package/lib/electron-main/messaging/electron-messaging-contribution.d.ts.map +1 -1
  217. package/lib/electron-main/messaging/electron-messaging-contribution.js +1 -2
  218. package/lib/electron-main/messaging/electron-messaging-contribution.js.map +1 -1
  219. package/package.json +7 -5
  220. package/shared/@theia/application-package/lib/api.d.ts +1 -0
  221. package/shared/@theia/application-package/lib/api.js +1 -0
  222. package/src/browser/about-dialog.tsx +2 -2
  223. package/src/browser/authentication-service.ts +1 -2
  224. package/src/browser/color-registry.ts +3 -85
  225. package/src/browser/common-frontend-contribution.ts +179 -232
  226. package/src/browser/core-preferences.ts +32 -19
  227. package/src/browser/dialogs.ts +10 -3
  228. package/src/browser/frontend-application-module.ts +10 -5
  229. package/src/browser/frontend-application.ts +13 -0
  230. package/src/browser/index.ts +1 -0
  231. package/src/browser/keyboard/browser-keyboard-frontend-contribution.ts +16 -11
  232. package/src/browser/keyboard/browser-keyboard-layout-provider.spec.ts +10 -4
  233. package/src/browser/keyboard/keys.ts +2 -675
  234. package/src/browser/menu/browser-context-menu-renderer.ts +1 -1
  235. package/src/browser/menu/browser-menu-plugin.ts +25 -5
  236. package/src/browser/messaging/ws-connection-provider.ts +13 -4
  237. package/src/browser/nls-loader.ts +26 -0
  238. package/src/browser/preferences/preference-provider.ts +1 -5
  239. package/src/browser/preferences/preference-service.spec.ts +0 -3
  240. package/src/browser/progress-status-bar-item.ts +1 -2
  241. package/src/browser/quick-input/quick-command-frontend-contribution.ts +2 -2
  242. package/src/browser/quick-input/quick-command-service.ts +2 -2
  243. package/src/browser/quick-input/quick-input-service.ts +1 -278
  244. package/src/browser/quick-input/quick-view-service.ts +1 -2
  245. package/src/browser/shell/application-shell.ts +21 -25
  246. package/src/browser/shell/current-widget-command-adapter.ts +57 -0
  247. package/src/browser/shell/shell-layout-restorer.ts +4 -3
  248. package/src/browser/shell/tab-bar-decorator.ts +1 -1
  249. package/src/browser/shell/tab-bar-toolbar.tsx +3 -1
  250. package/src/browser/shell/tab-bars.ts +133 -13
  251. package/src/browser/storage-service.spec.ts +1 -1
  252. package/src/browser/style/index.css +5 -0
  253. package/src/browser/style/sidepanel.css +8 -2
  254. package/src/browser/style/tabs.css +30 -0
  255. package/src/browser/style/tooltip.css +28 -0
  256. package/src/browser/style/view-container.css +9 -9
  257. package/src/browser/theming.ts +6 -17
  258. package/src/browser/tooltip-service.tsx +98 -0
  259. package/src/browser/tree/tree-model.ts +1 -1
  260. package/src/browser/view-container.ts +312 -80
  261. package/src/browser/window/default-window-service.ts +2 -2
  262. package/src/browser/window/window-service.ts +1 -9
  263. package/src/browser/window-contribution.ts +2 -2
  264. package/src/common/color.ts +100 -0
  265. package/src/common/command.ts +11 -2
  266. package/src/common/i18n/localization.ts +54 -0
  267. package/src/common/i18n/nls.metadata.json +20421 -0
  268. package/src/common/index.ts +1 -0
  269. package/src/common/keys.ts +693 -0
  270. package/src/common/messaging/abstract-connection-provider.ts +3 -1
  271. package/src/common/messaging/proxy-factory.ts +1 -1
  272. package/src/common/nls.ts +104 -0
  273. package/src/common/path.spec.ts +15 -0
  274. package/src/common/path.ts +16 -4
  275. package/src/common/promise-util.spec.ts +41 -0
  276. package/src/common/promise-util.ts +23 -4
  277. package/src/common/quick-pick-service.ts +299 -4
  278. package/src/common/theme.ts +32 -0
  279. package/src/common/window.ts +30 -0
  280. package/src/electron-browser/menu/electron-context-menu-renderer.ts +38 -16
  281. package/src/electron-browser/menu/electron-main-menu-factory.ts +10 -15
  282. package/src/electron-browser/menu/electron-menu-contribution.ts +129 -39
  283. package/src/electron-browser/menu/electron-menu-style.css +84 -0
  284. package/src/electron-browser/window/electron-window-preferences.ts +13 -1
  285. package/src/electron-browser/window/electron-window-service.ts +1 -1
  286. package/src/electron-common/electron-main-window-service.ts +1 -2
  287. package/src/electron-common/messaging/electron-messages.ts +20 -0
  288. package/src/electron-main/electron-main-application.ts +107 -24
  289. package/src/electron-main/electron-main-window-service-impl.ts +1 -2
  290. package/src/electron-main/messaging/electron-messaging-contribution.ts +1 -2
  291. package/lib/browser/nls.d.ts.map +0 -1
  292. package/lib/browser/nls.js +0 -64
  293. package/lib/browser/nls.js.map +0 -1
  294. package/src/browser/nls.ts +0 -65
@@ -49,7 +49,9 @@ export abstract class AbstractConnectionProvider<AbstractOptions extends object>
49
49
  protected readonly channels = new Map<number, WebSocketChannel>();
50
50
 
51
51
  protected readonly onIncomingMessageActivityEmitter: Emitter<void> = new Emitter();
52
- public onIncomingMessageActivity: Event<void> = this.onIncomingMessageActivityEmitter.event;
52
+ get onIncomingMessageActivity(): Event<void> {
53
+ return this.onIncomingMessageActivityEmitter.event;
54
+ }
53
55
 
54
56
  /**
55
57
  * Create a proxy object to remote interface of T type
@@ -240,7 +240,7 @@ export class JsonRpcProxyFactory<T extends object> implements ProxyHandler<T> {
240
240
  try {
241
241
  if (isNotify) {
242
242
  connection.sendNotification(method, ...args);
243
- resolve();
243
+ resolve(undefined);
244
244
  } else {
245
245
  const resultPromise = connection.sendRequest(method, ...args) as Promise<any>;
246
246
  resultPromise
@@ -0,0 +1,104 @@
1
+ /********************************************************************************
2
+ * Copyright (C) 2021 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 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+
17
+ import { FormatType, Localization } from './i18n/localization';
18
+
19
+ export namespace nls {
20
+
21
+ export let localization: Localization | undefined;
22
+
23
+ export const localeId = 'localeId';
24
+
25
+ export const locale = typeof window === 'object' && window && window.localStorage.getItem(localeId) || undefined;
26
+
27
+ let keyProvider: LocalizationKeyProvider | undefined;
28
+
29
+ /**
30
+ * Automatically localizes a text if that text also exists in the vscode repository.
31
+ */
32
+ export function localizeByDefault(defaultValue: string, ...args: FormatType[]): string {
33
+ const key = getDefaultKey(defaultValue);
34
+ if (key) {
35
+ return localize(key, defaultValue, ...args);
36
+ }
37
+ return Localization.format(defaultValue, args);
38
+ }
39
+
40
+ export function getDefaultKey(defaultValue: string): string {
41
+ if (localization) {
42
+ if (!keyProvider) {
43
+ keyProvider = new LocalizationKeyProvider();
44
+ }
45
+ const key = keyProvider.get(defaultValue);
46
+ if (key) {
47
+ return key;
48
+ } else {
49
+ console.warn(`Could not find translation key for default value: "${defaultValue}"`);
50
+ }
51
+ }
52
+ return '';
53
+ }
54
+
55
+ export function localize(key: string, defaultValue: string, ...args: FormatType[]): string {
56
+ return Localization.localize(localization, key, defaultValue, ...args);
57
+ }
58
+ }
59
+
60
+ interface NlsKeys {
61
+ [key: string]: (string | NlsInfo)[]
62
+ }
63
+
64
+ interface NlsInfo {
65
+ key: string
66
+ comment: string[]
67
+ }
68
+
69
+ class LocalizationKeyProvider {
70
+
71
+ private data = this.buildData();
72
+
73
+ get(defaultValue: string): string | undefined {
74
+ return this.data.get(defaultValue);
75
+ }
76
+
77
+ /**
78
+ * Transforms the data coming from the `nls.metadata.json` file into a map.
79
+ * The original data contains arrays of keys and messages.
80
+ * The result is a map that matches each message to the key that belongs to it.
81
+ *
82
+ * This allows us to skip the key in the localization process and map the original english default values to their translations in different languages.
83
+ */
84
+ private buildData(): Map<string, string> {
85
+ const bundles = require('../../src/common/i18n/nls.metadata.json');
86
+ const keys: NlsKeys = bundles.keys;
87
+ const messages: Record<string, string[]> = bundles.messages;
88
+ const data = new Map<string, string>();
89
+ for (const [fileKey, messageBundle] of Object.entries(messages)) {
90
+ const keyBundle = keys[fileKey];
91
+ for (let i = 0; i < messageBundle.length; i++) {
92
+ const message = Localization.normalize(messageBundle[i]);
93
+ const key = keyBundle[i];
94
+ const localizationKey = this.buildKey(typeof key === 'string' ? key : key.key, fileKey);
95
+ data.set(message, localizationKey);
96
+ }
97
+ }
98
+ return data;
99
+ }
100
+
101
+ private buildKey(key: string, filepath: string): string {
102
+ return `vscode/${Localization.transformKey(filepath)}/${key}`;
103
+ }
104
+ }
@@ -257,6 +257,20 @@ describe('Path', () => {
257
257
  });
258
258
  }
259
259
 
260
+ describe('Normalize path separator', () => {
261
+ it('should handle windows styled paths', async () => {
262
+ const path = 'C:\\a\\b\\c';
263
+ const expected = '/c:/a/b/c';
264
+ expect(new Path(path).toString()).eq(expected);
265
+ });
266
+
267
+ it('should prefix drive letter with /', async () => {
268
+ const path = 'c:/a/b/c';
269
+ const expected = '/c:/a/b/c';
270
+ expect(new Path(path).toString()).eq(expected);
271
+ });
272
+ });
273
+
260
274
  const linuxHome = '/home/test-user';
261
275
  const windowsHome = '/C:/Users/test-user';
262
276
 
@@ -340,5 +354,6 @@ describe('Path', () => {
340
354
  const expected = '~/a/b/theia';
341
355
  expect(Path.untildify(path, '')).eq(expected);
342
356
  });
357
+
343
358
  });
344
359
  });
@@ -53,11 +53,22 @@ export class Path {
53
53
  } else if (path.length >= 2 && path.charCodeAt(1) === 58 /* ':' */) {
54
54
  const code = path.charCodeAt(0);
55
55
  if (code >= 65 /* A */ && code <= 90 /* Z */) {
56
- path = `${String.fromCharCode(code + 32)}:${path.substr(2)}`; // "/c:".length === 3
56
+ path = `${String.fromCharCode(code + 32)}:${path.substr(2)}`; // "c:".length === 2
57
+ }
58
+ if (path.charCodeAt(0) !== 47 /* '/' */) {
59
+ path = `${String.fromCharCode(47)}${path}`;
57
60
  }
58
61
  }
59
62
  return path;
60
63
  }
64
+ /**
65
+ * Normalize path separator to use Path.separator
66
+ * @param Path candidate to normalize
67
+ * @returns Normalized string path
68
+ */
69
+ static normalizePathSeparator(path: string): string {
70
+ return path.split(/[\\]/).join(Path.separator);
71
+ }
61
72
 
62
73
  /**
63
74
  * Tildify path, replacing `home` with `~` if user's `home` is present at the beginning of the path.
@@ -112,11 +123,12 @@ export class Path {
112
123
  constructor(
113
124
  raw: string
114
125
  ) {
126
+ raw = Path.normalizePathSeparator(raw);
115
127
  this.raw = Path.normalizeDrive(raw);
116
- const firstIndex = raw.indexOf(Path.separator);
117
- const lastIndex = raw.lastIndexOf(Path.separator);
128
+ const firstIndex = this.raw.indexOf(Path.separator);
129
+ const lastIndex = this.raw.lastIndexOf(Path.separator);
118
130
  this.isAbsolute = firstIndex === 0;
119
- this.base = lastIndex === -1 ? raw : raw.substr(lastIndex + 1);
131
+ this.base = lastIndex === -1 ? this.raw : this.raw.substr(lastIndex + 1);
120
132
  this.isRoot = this.isAbsolute && firstIndex === lastIndex && (!this.base || Path.isDrive(this.base));
121
133
  this.root = this.computeRoot();
122
134
 
@@ -0,0 +1,41 @@
1
+ /********************************************************************************
2
+ * Copyright (C) 2021 Red Hat 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 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+ import * as assert from 'assert';
17
+ import { waitForEvent } from './promise-util';
18
+ import { Emitter } from './event';
19
+
20
+ describe('promise-util', () => {
21
+ it('should time out', async () => {
22
+ const emitter = new Emitter<string>();
23
+ try {
24
+ await waitForEvent(emitter.event, 1000);
25
+ assert.fail('did not time out');
26
+ } catch (e) {
27
+ // OK
28
+ }
29
+ });
30
+
31
+ describe('promise-util', () => {
32
+ it('should get event', async () => {
33
+ const emitter = new Emitter<string>();
34
+ setTimeout(() => {
35
+ emitter.fire('abcd');
36
+ }, 500);
37
+ assert.strictEqual(await waitForEvent(emitter.event, 1000), 'abcd');
38
+ });
39
+ });
40
+
41
+ });
@@ -14,20 +14,22 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import { CancellationToken, cancelled } from './cancellation';
17
+ import { Disposable } from './disposable';
18
+ import { Event } from './event';
19
+ import { CancellationToken, CancellationError, cancelled } from './cancellation';
18
20
 
19
21
  /**
20
22
  * Simple implementation of the deferred pattern.
21
23
  * An object that exposes a promise and functions to resolve and reject it.
22
24
  */
23
- export class Deferred<T> {
25
+ export class Deferred<T = void> {
24
26
  state: 'resolved' | 'rejected' | 'unresolved' = 'unresolved';
25
- resolve: (value?: T) => void;
27
+ resolve: (value: T) => void;
26
28
  reject: (err?: any) => void; // eslint-disable-line @typescript-eslint/no-explicit-any
27
29
 
28
30
  promise = new Promise<T>((resolve, reject) => {
29
31
  this.resolve = result => {
30
- resolve(result as T);
32
+ resolve(result);
31
33
  if (this.state === 'unresolved') {
32
34
  this.state = 'resolved';
33
35
  }
@@ -90,3 +92,20 @@ export function delay<T>(ms: number): (value: T) => Promise<T> {
90
92
  export async function wait(ms: number): Promise<void> {
91
93
  await delay(ms)(undefined);
92
94
  }
95
+
96
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
97
+ export function waitForEvent<T>(event: Event<T>, ms: number, thisArg?: any, disposables?: Disposable[]): Promise<T> {
98
+ return new Promise<T>((resolve, reject) => {
99
+ const registration = setTimeout(() => {
100
+ listener.dispose();
101
+ reject(new CancellationError());
102
+ }, ms);
103
+
104
+ const listener = event((evt: T) => {
105
+ clearTimeout(registration);
106
+ listener.dispose();
107
+ resolve(evt);
108
+ }, thisArg, disposables);
109
+
110
+ });
111
+ }
@@ -13,18 +13,35 @@
13
13
  *
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
+
17
+ /********************************************************************************
18
+ * Copyright (c) 2021 SAP SE or an SAP affiliate company and others.
19
+ *
20
+ * This program and the accompanying materials are made available under the
21
+ * terms of the Eclipse Public License v. 2.0 which is available at
22
+ * http://www.eclipse.org/legal/epl-2.0.
23
+ *
24
+ * This Source Code may also be made available under the following Secondary
25
+ * Licenses when the conditions for such availability set forth in the Eclipse
26
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
27
+ * with the GNU Classpath Exception which is available at
28
+ * https://www.gnu.org/software/classpath/license.html.
29
+ *
30
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
31
+ ********************************************************************************/
32
+
33
+ import URI from './uri';
34
+ import * as fuzzy from 'fuzzy';
16
35
  import { Event } from './event';
17
- // eslint-disable-next-line @theia/runtime-import-check
18
- import { QuickInputButtonHandle, QuickPick, QuickPickItem, QuickPickOptions } from '../browser/quick-input/quick-input-service';
36
+ import { KeySequence } from './keys';
37
+ import { CancellationToken } from './cancellation';
19
38
 
20
39
  export const quickPickServicePath = '/services/quickPick';
21
40
  export const QuickPickService = Symbol('QuickPickService');
22
41
  export interface QuickPickService {
23
-
24
42
  show<T extends QuickPickItem>(items: Array<T>, options?: QuickPickOptions<T>): Promise<T | undefined>;
25
43
  setItems<T extends QuickPickItem>(items: Array<T>): void;
26
44
  hide(): void
27
-
28
45
  readonly onDidHide: Event<void>;
29
46
  readonly onDidAccept: Event<void>;
30
47
  readonly onDidChangeValue: Event<{ quickPick: QuickPick<QuickPickItem>, filter: string }>;
@@ -32,3 +49,281 @@ export interface QuickPickService {
32
49
  readonly onDidChangeSelection: Event<{ quickPick: QuickPick<QuickPickItem>, selectedItems: Array<QuickPickItem> }>;
33
50
  readonly onDidTriggerButton: Event<QuickInputButtonHandle>;
34
51
  }
52
+
53
+ export interface Match {
54
+ start: number;
55
+ end: number;
56
+ }
57
+ export interface QuickPickItemHighlights {
58
+ label?: Match[];
59
+ description?: Match[];
60
+ detail?: Match[];
61
+ }
62
+
63
+ export interface QuickPickItem {
64
+ type?: 'item' | 'separator';
65
+ id?: string;
66
+ label: string;
67
+ meta?: string;
68
+ ariaLabel?: string;
69
+ description?: string;
70
+ detail?: string;
71
+ keySequence?: KeySequence;
72
+ iconClasses?: string[];
73
+ alwaysShow?: boolean;
74
+ highlights?: QuickPickItemHighlights;
75
+ buttons?: QuickInputButton[];
76
+ execute?: () => void;
77
+ }
78
+
79
+ export namespace QuickPickItem {
80
+ export function is(item: QuickPickSeparator | QuickPickItem): item is QuickPickItem {
81
+ // if it's not a separator, it's an item
82
+ return item.type !== 'separator';
83
+ }
84
+ }
85
+
86
+ export interface QuickPickSeparator {
87
+ type: 'separator';
88
+ label?: string;
89
+ }
90
+
91
+ export namespace QuickPickSeparator {
92
+ export function is(item: QuickPickSeparator | QuickPickItem): item is QuickPickSeparator {
93
+ return item.type === 'separator';
94
+ }
95
+ }
96
+
97
+ export type QuickPicks = (QuickPickSeparator | QuickPickItem)[];
98
+
99
+ export interface QuickPickValue<V> extends QuickPickItem {
100
+ value: V
101
+ }
102
+
103
+ export interface QuickInputButton {
104
+ iconPath?: URI | { light: URI; dark: URI } | { id: string };
105
+ iconClass?: string;
106
+ tooltip?: string;
107
+ }
108
+
109
+ export interface QuickInputButtonHandle extends QuickInputButton {
110
+ index: number; // index of where they are in buttons array if QuickInputButton or -1 if QuickInputButtons.Back
111
+ }
112
+
113
+ export interface QuickInput {
114
+ readonly onDidHide: Event<void>;
115
+ readonly onDispose: Event<void>;
116
+ title: string | undefined;
117
+ description: string | undefined;
118
+ step: number | undefined;
119
+ totalSteps: number | undefined;
120
+ enabled: boolean;
121
+ contextKey: string | undefined;
122
+ busy: boolean;
123
+ ignoreFocusOut: boolean;
124
+ show(): void;
125
+ hide(): void;
126
+ dispose(): void;
127
+ }
128
+
129
+ export interface InputBox extends QuickInput {
130
+ value: string | undefined;
131
+ valueSelection: Readonly<[number, number]> | undefined;
132
+ placeholder: string | undefined;
133
+ password: boolean;
134
+ readonly onDidChangeValue: Event<string>;
135
+ readonly onDidAccept: Event<void>;
136
+ buttons: ReadonlyArray<QuickInputButton>;
137
+ readonly onDidTriggerButton: Event<QuickInputButton>;
138
+ prompt: string | undefined;
139
+ validationMessage: string | undefined;
140
+ }
141
+
142
+ export interface QuickPick<T extends QuickPickItem> extends QuickInput {
143
+ value: string;
144
+ placeholder: string | undefined;
145
+ items: ReadonlyArray<T | QuickPickSeparator>;
146
+ activeItems: ReadonlyArray<T>;
147
+ selectedItems: ReadonlyArray<T>;
148
+ canSelectMany: boolean;
149
+ matchOnDescription: boolean;
150
+ matchOnDetail: boolean;
151
+ readonly onDidAccept: Event<void>;
152
+ readonly onDidChangeValue: Event<string>;
153
+ readonly onDidTriggerButton: Event<QuickInputButton>;
154
+ readonly onDidTriggerItemButton: Event<QuickPickItemButtonEvent<T>>;
155
+ readonly onDidChangeActive: Event<T[]>;
156
+ readonly onDidChangeSelection: Event<T[]>;
157
+ }
158
+
159
+ export interface PickOptions<T extends QuickPickItem> {
160
+ placeHolder?: string;
161
+ matchOnDescription?: boolean;
162
+ matchOnDetail?: boolean;
163
+ matchOnLabel?: boolean;
164
+ autoFocusOnList?: boolean;
165
+ ignoreFocusLost?: boolean;
166
+ canPickMany?: boolean;
167
+ contextKey?: string;
168
+ activeItem?: Promise<T> | T;
169
+ onDidFocus?: (entry: T) => void;
170
+ }
171
+
172
+ export interface InputOptions {
173
+ value?: string;
174
+ valueSelection?: [number, number];
175
+ prompt?: string;
176
+ placeHolder?: string;
177
+ password?: boolean;
178
+ ignoreFocusLost?: boolean;
179
+ validateInput?(input: string): Promise<string | null | undefined> | undefined;
180
+ }
181
+
182
+ export interface QuickPickItemButtonEvent<T extends QuickPickItem> {
183
+ button: QuickInputButton;
184
+ item: T;
185
+ }
186
+
187
+ export interface QuickPickItemButtonContext<T extends QuickPickItem> extends QuickPickItemButtonEvent<T> {
188
+ removeItem(): void;
189
+ }
190
+
191
+ export interface QuickPickOptions<T extends QuickPickItem> {
192
+ busy?: boolean;
193
+ enabled?: boolean;
194
+ title?: string;
195
+ description?: string;
196
+ value?: string;
197
+ filterValue?: (value: string) => string;
198
+ ariaLabel?: string;
199
+ buttons?: Array<QuickInputButton>;
200
+ placeholder?: string;
201
+ canAcceptInBackground?: boolean;
202
+ customButton?: boolean;
203
+ customLabel?: string;
204
+ customHover?: string;
205
+ canSelectMany?: boolean;
206
+ matchOnDescription?: boolean;
207
+ matchOnDetail?: boolean;
208
+ matchOnLabel?: boolean;
209
+ sortByLabel?: boolean;
210
+ autoFocusOnList?: boolean;
211
+ ignoreFocusOut?: boolean;
212
+ valueSelection?: Readonly<[number, number]>;
213
+ validationMessage?: string;
214
+ hideInput?: boolean;
215
+ hideCheckAll?: boolean;
216
+ runIfSingle?: boolean
217
+ contextKey?: string;
218
+ activeItem?: T,
219
+ step?: number;
220
+ totalSteps?: number;
221
+
222
+ onDidAccept?: () => void,
223
+ onDidChangeActive?: (quickPick: QuickPick<T>, activeItems: Array<T>) => void,
224
+ onDidChangeSelection?: (quickPick: QuickPick<T>, selectedItems: Array<T>) => void,
225
+ onDidChangeValue?: (quickPick: QuickPick<T>, filter: string) => void,
226
+ onDidCustom?: () => void,
227
+ onDidHide?: () => void;
228
+ onDidTriggerButton?: (button: QuickInputButton) => void,
229
+ onDidTriggerItemButton?: (ItemButtonEvent: QuickPickItemButtonContext<T>) => void
230
+ }
231
+
232
+ export const QuickInputService = Symbol('QuickInputService');
233
+ export interface QuickInputService {
234
+ readonly backButton: QuickInputButton;
235
+ readonly onShow: Event<void>;
236
+ readonly onHide: Event<void>;
237
+ open(filter: string): void;
238
+ createInputBox(): InputBox;
239
+ input(options?: InputOptions, token?: CancellationToken): Promise<string | undefined>;
240
+ pick<T extends QuickPickItem, O extends PickOptions<T>>(picks: Promise<T[]> | T[], options?: O, token?: CancellationToken):
241
+ Promise<(O extends { canPickMany: true } ? T[] : T) | undefined>;
242
+ showQuickPick<T extends QuickPickItem>(items: Array<T>, options?: QuickPickOptions<T>): Promise<T>;
243
+ hide(): void;
244
+ /**
245
+ * Provides raw access to the quick pick controller.
246
+ */
247
+ createQuickPick<T extends QuickPickItem>(): QuickPick<T>;
248
+ }
249
+
250
+ /**
251
+ * Filter the list of quick pick items based on the provided filter.
252
+ * Items are filtered based on if:
253
+ * - their `label` satisfies the filter using `fuzzy`.
254
+ * - their `description` satisfies the filter using `fuzzy`.
255
+ * - their `detail` satisfies the filter using `fuzzy`.
256
+ * Filtered items are also updated to display proper highlights based on how they were filtered.
257
+ * @param items the list of quick pick items.
258
+ * @param filter the filter to search for.
259
+ * @returns the list of quick pick items that satisfy the filter.
260
+ */
261
+ export function filterItems(items: QuickPickItem[], filter: string): QuickPickItem[] {
262
+ filter = filter.trim().toLowerCase();
263
+
264
+ if (filter.length === 0) {
265
+ for (const item of items) {
266
+ item.highlights = undefined; // reset highlights from previous filtering.
267
+ }
268
+ return items;
269
+ }
270
+
271
+ const filteredItems: QuickPickItem[] = [];
272
+ for (const item of items) {
273
+ if (
274
+ fuzzy.test(filter, item.label) ||
275
+ (item.description && fuzzy.test(filter, item.description)) ||
276
+ (item.detail && fuzzy.test(filter, item.detail))
277
+ ) {
278
+ item.highlights = {
279
+ label: findMatches(item.label, filter),
280
+ description: item.description ? findMatches(item.description, filter) : undefined,
281
+ detail: item.detail ? findMatches(item.detail, filter) : undefined
282
+ };
283
+ filteredItems.push(item);
284
+ }
285
+ }
286
+ return filteredItems;
287
+ }
288
+
289
+ /**
290
+ * Find match highlights when testing a word against a pattern.
291
+ * @param word the word to test.
292
+ * @param pattern the word to match against.
293
+ * @returns the list of highlights if present.
294
+ */
295
+ export function findMatches(word: string, pattern: string): Array<{ start: number, end: number }> | undefined {
296
+ word = word.toLocaleLowerCase();
297
+ pattern = pattern.toLocaleLowerCase();
298
+
299
+ if (pattern.trim().length === 0) {
300
+ return undefined;
301
+ }
302
+
303
+ const delimiter = '\u0000'; // null byte that shouldn't appear in the input and is used to denote matches.
304
+ const matchResult = fuzzy.match(pattern.replace(/\u0000/gu, ''), word, { pre: delimiter, post: delimiter });
305
+ if (!matchResult) {
306
+ return undefined;
307
+ }
308
+
309
+ const match = matchResult.rendered;
310
+ const highlights: { start: number, end: number }[] = [];
311
+
312
+ let lastIndex = 0;
313
+ /** We need to account for the extra markers by removing them from the range */
314
+ let offset = 0;
315
+
316
+ while (true) {
317
+ const start = match.indexOf(delimiter, lastIndex);
318
+ if (start === -1) { break; }
319
+ const end = match.indexOf(delimiter, start + 1);
320
+ if (end === -1) { break; }
321
+ highlights.push({
322
+ start: start - offset++,
323
+ end: end - offset++
324
+ });
325
+ lastIndex = end + 1;
326
+ }
327
+
328
+ return highlights.length > 0 ? highlights : undefined;
329
+ }
@@ -0,0 +1,32 @@
1
+ /********************************************************************************
2
+ * Copyright (C) 2017 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 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+
17
+ export type ThemeType = 'light' | 'dark' | 'hc';
18
+
19
+ export interface Theme {
20
+ readonly id: string;
21
+ readonly type: ThemeType;
22
+ readonly label: string;
23
+ readonly description?: string;
24
+ readonly editorTheme?: string;
25
+ activate(): void;
26
+ deactivate(): void;
27
+ }
28
+
29
+ export interface ThemeChangeEvent {
30
+ readonly newTheme: Theme;
31
+ readonly oldTheme?: Theme;
32
+ }
@@ -0,0 +1,30 @@
1
+ /********************************************************************************
2
+ * Copyright (C) 2021 Ericsson 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 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+
17
+ /**
18
+ * The window hash value that is used to spawn a new default window.
19
+ */
20
+ export const DEFAULT_WINDOW_HASH: string = '!empty';
21
+
22
+ /**
23
+ * The options for opening new windows.
24
+ */
25
+ export interface NewWindowOptions {
26
+ /**
27
+ * Controls whether the window should be opened externally.
28
+ */
29
+ readonly external?: boolean;
30
+ }